Canorus  0.0
Public Member Functions | Static Public Member Functions | Private Attributes | Static Private Attributes | List of all members
CAPluginManager Class Reference

#include <pluginmanager.h>

Inheritance diagram for CAPluginManager:
Inheritance graph
[legend]

Public Member Functions

 CAPluginManager (CAMainWin *mainWin, CAPlugin *plugin)
 
 ~CAPluginManager ()
 
bool startElement (const QString &namespaceURI, const QString &localName, const QString &qName, const QXmlAttributes &attributes)
 
bool endElement (const QString &namespaceURI, const QString &localName, const QString &qName)
 
bool fatalError (const QXmlParseException &exception)
 
bool characters (const QString &ch)
 

Static Public Member Functions

static void readPlugins ()
 
static bool enablePlugin (CAPlugin *plugin, CAMainWin *mainWin)
 
static bool enablePlugins (CAMainWin *mainWin)
 
static bool disablePlugin (CAPlugin *plugin)
 
static bool disablePlugins ()
 
static void action (QString onAction, CADocument *document, QEvent *evt, QPoint *coords, CAMainWin *mainWin)
 
static bool exportFilterExists (const QString filter)
 
static void exportAction (QString filter, CADocument *document, QString filename)
 
static bool importFilterExists (const QString filter)
 
static void importAction (QString filter, CADocument *document, QString filename)
 
static bool installPlugin (QString path)
 
static bool removePlugin (CAPlugin *plugin)
 
static const QList< CAPlugin * > pluginList ()
 

Private Attributes

CAMainWin_mainWin
 
QString _curChars
 
QStack< QString > _tree
 
CAPlugin_curPlugin
 
QString _curPluginCanorusVersion
 
QString _curPluginLocale
 
QHash< QString, QString > _curActionText
 
QString _curActionName
 
QString _curActionLocale
 
QString _curActionOnAction
 
QHash< QString, QString > _curActionExportFilter
 
QHash< QString, QString > _curActionImportFilter
 
QString _curActionParentMenu
 
QString _curActionParentToolbar
 
bool _curActionRefresh
 
QString _curActionLang
 
QString _curActionFunction
 
QString _curActionFilename
 
QList< QString > _curActionArgs
 
QString _curMenuName
 
QHash< QString, QString > _curMenuTitle
 
QString _curMenuLocale
 
QString _curMenuParentMenu
 

Static Private Attributes

static QList< CAPlugin * > _pluginList
 
static QMultiHash< QString, CAPlugin * > _actionMap
 
static QHash< QString, CAPluginAction * > _exportFilterMap
 
static QHash< QString, CAPluginAction * > _importFilterMap
 

Detailed Description

This class is the backend for loading, unloading, installing, removing and executing plugins. It's consists of two parts:

A plugin is installed or uninstalled using installPlugin() or removePlugin() methods. installMethod() unpacks the compressed plugin into default user's plugins directory. removePlugin() deletes the plugin directory from the disk.

After plugins are installed readPlugins() method should be called. This creates a list of available plugin objects and stores their location paths.

To parse plugins descriptor files and enable plugins, call enablePlugins() to enable plugins marked as auto-load in Canorus config file or enablePlugin() to load a specific plugin. These methods use Qt's XML facilities to parse plugins descriptor files and use the non-static part of the class. They also require an already created main window as the parser creates menu structures, toolbars and other elements the plugin might offer.

An action (eg. when a user moves mouse in score viewport) is triggered by calling action() method and pass the action type (eg. "onMouseMove") and other parameters. actionExport() and actionImport() are separated and are called when Canorus user wants to export/import a document.

Todo:
Frontend window for plugin manipulation.
See also
CAPlugin, CAPluginManagerWin

Constructor & Destructor Documentation

◆ CAPluginManager()

CAPluginManager::CAPluginManager ( CAMainWin mainWin,
CAPlugin plugin 
)

Used if parsing plugin's descriptor file. It uses the given mainWin in order to create new menus and toolbars the plugin might include. If the plugin has already been created (eg. using the same plugin in multiple main windows) plugin is the existing plugin.

Todo:
This should be read from the descriptor file as well

References _curPlugin, _curPluginCanorusVersion, and _mainWin.

Referenced by enablePlugin().

Here is the caller graph for this function:

◆ ~CAPluginManager()

CAPluginManager::~CAPluginManager ( )

Member Function Documentation

◆ action()

void CAPluginManager::action ( QString  val,
CADocument document,
QEvent *  evt,
QPoint *  coords,
CAMainWin mainWin 
)
static

Gathers all the plugins actions having the given val <action> <name> tag in its descriptor file and calls them. This method is usually triggered automatically by Canorus signals (like mouseClick on score viewport or a menu action).

See also
importAction(), exportAction()

References _actionMap.

Referenced by endElement(), CAMainWin::onScoreViewSelectionChanged(), and CAMainWin::scoreViewMousePress().

Here is the caller graph for this function:

◆ characters()

bool CAPluginManager::characters ( const QString &  ch)

References _curChars.

◆ disablePlugin()

bool CAPluginManager::disablePlugin ( CAPlugin plugin)
static

Deinitializes the given plugin and remove any menus, toolbars and other GUI elements the plugin might have created from all the main windows. Plugin is unloaded, but still remains on the list - it's only disabled.

Returns True, if plugin was unloaded successfully, otherwise False.

References _actionMap, CAPlugin::action(), CAPlugin::actionList(), CAPlugin::isEnabled(), CACanorus::mainWinList(), and CAPlugin::setEnabled().

Referenced by disablePlugins(), and removePlugin().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ disablePlugins()

bool CAPluginManager::disablePlugins ( )
static

Disable and deinitializes all plugins.

Return True, if all the plugins were successfully loaded, otherwise False.

See also
disablePlugin(), enablePlugins()

References _pluginList, and disablePlugin().

Here is the call graph for this function:

◆ enablePlugin()

bool CAPluginManager::enablePlugin ( CAPlugin plugin,
CAMainWin mainWin 
)
static

Enables the plugin plugin and initializes it (action "onInit").

Returns True, if the plugin was loaded successfully, otherwise False.

See also
disablePlugin()

References _actionMap, CAPlugin::action(), CAPlugin::actionList(), CAPluginManager(), CAPlugin::dirName(), CAPlugin::isEnabled(), and CAPlugin::setEnabled().

Referenced by enablePlugins().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ enablePlugins()

bool CAPluginManager::enablePlugins ( CAMainWin mainWin)
static

Enables and initializes all plugins, which are marked as auto-load in Canorus config file. Returns true if all the plugins were successfully loaded, otherwise False.

Todo:
auto-load not yet implemented. It currently enables all the plugins.
See also
enablePlugin(), disablePlugins()

References _pluginList, and enablePlugin().

Referenced by CAMainWin::CAMainWin().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ endElement()

bool CAPluginManager::endElement ( const QString &  namespaceURI,
const QString &  localName,
const QString &  qName 
)

◆ exportAction()

void CAPluginManager::exportAction ( QString  filter,
CADocument document,
QString  filename 
)
static

Finds the appropriate action having the given export filter and calls it using the given document and fileName.

See also
importAction()

References _exportFilterMap.

Referenced by CAMainWin::on_uiExportDocument_triggered().

Here is the caller graph for this function:

◆ exportFilterExists()

static bool CAPluginManager::exportFilterExists ( const QString  filter)
inlinestatic

References _exportFilterMap.

Referenced by CAMainWin::on_uiExportDocument_triggered().

Here is the caller graph for this function:

◆ fatalError()

bool CAPluginManager::fatalError ( const QXmlParseException &  exception)

◆ importAction()

void CAPluginManager::importAction ( QString  filter,
CADocument document,
QString  filename 
)
static

Finds the appropriate action having the given import filter and calls it using the given document and fileName. The given document should already be created before calling this method.

See also
exportAction()

References _importFilterMap.

Referenced by CAMainWin::on_uiImportDocument_triggered().

Here is the caller graph for this function:

◆ importFilterExists()

static bool CAPluginManager::importFilterExists ( const QString  filter)
inlinestatic

References _importFilterMap.

Referenced by CAMainWin::on_uiImportDocument_triggered().

Here is the caller graph for this function:

◆ installPlugin()

bool CAPluginManager::installPlugin ( QString  path)
static

Extracts the plugin package at path to user's plugins directory.

Returns True, if plugin was installed and loaded successfully, otherwise False.

See also
removePlugin()
Todo:
zlib needed

◆ pluginList()

static const QList<CAPlugin*> CAPluginManager::pluginList ( )
inlinestatic

References _pluginList.

◆ readPlugins()

void CAPluginManager::readPlugins ( )
static

Reads the system and user's plugins directories and adds all the plugins to the internal plugins list.

Warning
This function doesn't enable or initialize any of the plugins - use enablePlugins() for this.
Todo:
Add support for a user plugins directory.
See also
enablePlugin(), enablePlugins()

References _pluginList, and CAPlugin::setDirName().

Referenced by main().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ removePlugin()

bool CAPluginManager::removePlugin ( CAPlugin plugin)
static

Disables and deletes the directory containing the given plugin.

See also
installPlugin(), disablePlugin()

References CAPlugin::dirName(), and disablePlugin().

Here is the call graph for this function:

◆ startElement()

bool CAPluginManager::startElement ( const QString &  namespaceURI,
const QString &  localName,
const QString &  qName,
const QXmlAttributes &  attributes 
)

Member Data Documentation

◆ _actionMap

QMultiHash< QString, CAPlugin * > CAPluginManager::_actionMap
staticprivate

Referenced by action(), disablePlugin(), and enablePlugin().

◆ _curActionArgs

QList<QString> CAPluginManager::_curActionArgs
private

Referenced by endElement(), and startElement().

◆ _curActionExportFilter

QHash<QString,QString> CAPluginManager::_curActionExportFilter
private

Referenced by endElement(), and startElement().

◆ _curActionFilename

QString CAPluginManager::_curActionFilename
private

Referenced by endElement(), and startElement().

◆ _curActionFunction

QString CAPluginManager::_curActionFunction
private

Referenced by endElement(), and startElement().

◆ _curActionImportFilter

QHash<QString,QString> CAPluginManager::_curActionImportFilter
private

Referenced by endElement(), and startElement().

◆ _curActionLang

QString CAPluginManager::_curActionLang
private

Referenced by endElement(), and startElement().

◆ _curActionLocale

QString CAPluginManager::_curActionLocale
private

Referenced by endElement(), and startElement().

◆ _curActionName

QString CAPluginManager::_curActionName
private

Referenced by endElement(), and startElement().

◆ _curActionOnAction

QString CAPluginManager::_curActionOnAction
private

Referenced by endElement(), and startElement().

◆ _curActionParentMenu

QString CAPluginManager::_curActionParentMenu
private

Referenced by endElement(), and startElement().

◆ _curActionParentToolbar

QString CAPluginManager::_curActionParentToolbar
private

Referenced by endElement(), and startElement().

◆ _curActionRefresh

bool CAPluginManager::_curActionRefresh
private

Referenced by endElement(), and startElement().

◆ _curActionText

QHash<QString, QString> CAPluginManager::_curActionText
private

Referenced by endElement(), and startElement().

◆ _curChars

QString CAPluginManager::_curChars
private

Referenced by characters(), and endElement().

◆ _curMenuLocale

QString CAPluginManager::_curMenuLocale
private

Referenced by endElement(), and startElement().

◆ _curMenuName

QString CAPluginManager::_curMenuName
private

Referenced by endElement(), and startElement().

◆ _curMenuParentMenu

QString CAPluginManager::_curMenuParentMenu
private

Referenced by endElement(), and startElement().

◆ _curMenuTitle

QHash<QString, QString> CAPluginManager::_curMenuTitle
private

Referenced by endElement(), and startElement().

◆ _curPlugin

CAPlugin* CAPluginManager::_curPlugin
private

◆ _curPluginCanorusVersion

QString CAPluginManager::_curPluginCanorusVersion
private

Referenced by CAPluginManager(), and endElement().

◆ _curPluginLocale

QString CAPluginManager::_curPluginLocale
private

Referenced by endElement(), and startElement().

◆ _exportFilterMap

QHash< QString, CAPluginAction * > CAPluginManager::_exportFilterMap
staticprivate

◆ _importFilterMap

QHash< QString, CAPluginAction * > CAPluginManager::_importFilterMap
staticprivate

◆ _mainWin

CAMainWin* CAPluginManager::_mainWin
private

Referenced by CAPluginManager(), and endElement().

◆ _pluginList

QList< CAPlugin * > CAPluginManager::_pluginList
staticprivate

◆ _tree

QStack<QString> CAPluginManager::_tree
private

Referenced by endElement(), and startElement().


The documentation for this class was generated from the following files: