|
Canorus 0.0
|
#include <pluginmanager.h>

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 |
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.
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.
References _curPlugin, _curPluginCanorusVersion, and _mainWin.
Referenced by enablePlugin().

| CAPluginManager::~CAPluginManager | ( | ) |
|
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).
References _actionMap.
Referenced by endElement(), CAMainWin::onScoreViewSelectionChanged(), and CAMainWin::scoreViewMousePress().

|
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().


|
static |
Disable and deinitializes all plugins.
Return True, if all the plugins were successfully loaded, otherwise False.
References _pluginList, and disablePlugin().

Enables the plugin plugin and initializes it (action "onInit").
Returns True, if the plugin was loaded successfully, otherwise False.
References _actionMap, CAPlugin::action(), CAPlugin::actionList(), CAPluginManager(), CAPlugin::dirName(), CAPlugin::isEnabled(), and CAPlugin::setEnabled().
Referenced by enablePlugins().


|
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.
References _pluginList, and enablePlugin().
Referenced by CAMainWin::CAMainWin().


| bool CAPluginManager::endElement | ( | const QString & | namespaceURI, |
| const QString & | localName, | ||
| const QString & | qName | ||
| ) |
References _curActionArgs, _curActionExportFilter, _curActionFilename, _curActionFunction, _curActionImportFilter, _curActionLang, _curActionLocale, _curActionName, _curActionOnAction, _curActionParentMenu, _curActionParentToolbar, _curActionRefresh, _curActionText, _curChars, _curMenuLocale, _curMenuName, _curMenuParentMenu, _curMenuTitle, _curPlugin, _curPluginCanorusVersion, _curPluginLocale, _exportFilterMap, _importFilterMap, _mainWin, _tree, action(), CAPlugin::addAction(), CAPlugin::addMenu(), CAMainWin::exportDialog(), CAMainWin::importDialog(), CAPlugin::menu(), CAPlugin::setAuthor(), CAPlugin::setDescription(), CAPlugin::setHomeUrl(), CAPlugin::setName(), CAPlugin::setUpdateUrl(), and CAPlugin::setVersion().

|
static |
Finds the appropriate action having the given export filter and calls it using the given document and fileName.
References _exportFilterMap.
Referenced by CAMainWin::on_uiExportDocument_triggered().

|
inlinestatic |
References _exportFilterMap.
Referenced by CAMainWin::on_uiExportDocument_triggered().

| bool CAPluginManager::fatalError | ( | const QXmlParseException & | exception | ) |
|
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.
References _importFilterMap.
Referenced by CAMainWin::on_uiImportDocument_triggered().

|
inlinestatic |
References _importFilterMap.
Referenced by CAMainWin::on_uiImportDocument_triggered().

|
static |
Extracts the plugin package at path to user's plugins directory.
Returns True, if plugin was installed and loaded successfully, otherwise False.
References _pluginList.
|
static |
Reads the system and user's plugins directories and adds all the plugins to the internal plugins list.
References _pluginList, and CAPlugin::setDirName().
Referenced by main().


|
static |
Disables and deletes the directory containing the given plugin.
References CAPlugin::dirName(), and disablePlugin().

| bool CAPluginManager::startElement | ( | const QString & | namespaceURI, |
| const QString & | localName, | ||
| const QString & | qName, | ||
| const QXmlAttributes & | attributes | ||
| ) |
References _curActionArgs, _curActionExportFilter, _curActionFilename, _curActionFunction, _curActionImportFilter, _curActionLang, _curActionLocale, _curActionName, _curActionOnAction, _curActionParentMenu, _curActionParentToolbar, _curActionRefresh, _curActionText, _curMenuLocale, _curMenuName, _curMenuParentMenu, _curMenuTitle, _curPlugin, _curPluginLocale, and _tree.
|
staticprivate |
Referenced by action(), disablePlugin(), and enablePlugin().
|
private |
Referenced by endElement(), and startElement().
|
private |
Referenced by endElement(), and startElement().
|
private |
Referenced by endElement(), and startElement().
|
private |
Referenced by endElement(), and startElement().
|
private |
Referenced by endElement(), and startElement().
|
private |
Referenced by endElement(), and startElement().
|
private |
Referenced by endElement(), and startElement().
|
private |
Referenced by endElement(), and startElement().
|
private |
Referenced by endElement(), and startElement().
|
private |
Referenced by endElement(), and startElement().
|
private |
Referenced by endElement(), and startElement().
|
private |
Referenced by endElement(), and startElement().
|
private |
Referenced by endElement(), and startElement().
|
private |
Referenced by characters(), and endElement().
|
private |
Referenced by endElement(), and startElement().
|
private |
Referenced by endElement(), and startElement().
|
private |
Referenced by endElement(), and startElement().
|
private |
Referenced by endElement(), and startElement().
|
private |
Referenced by CAPluginManager(), endElement(), and startElement().
|
private |
Referenced by CAPluginManager(), and endElement().
|
private |
Referenced by endElement(), and startElement().
|
staticprivate |
Referenced by endElement(), exportAction(), and exportFilterExists().
|
staticprivate |
Referenced by endElement(), importAction(), and importFilterExists().
|
private |
Referenced by CAPluginManager(), and endElement().
|
staticprivate |
Referenced by disablePlugins(), enablePlugins(), pluginList(), and readPlugins().
|
private |
Referenced by endElement(), and startElement().