CAPluginManager Class Reference

#include <pluginmanager.h>

Inheritance diagram for CAPluginManager:

Inheritance graph
[legend]

List of all members.

Public Member Functions

 CAPluginManager (CAMainWin *mainWin, CAPlugin *plugin)
 ~CAPluginManager ()
const QList< CAPlugin * > pluginList ()
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)

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

Definition at line 25 of file pluginmanager.h.


Constructor & Destructor Documentation

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

Definition at line 63 of file pluginmanager.cpp.

References _curPlugin, _curPluginCanorusVersion, and _mainWin.

Referenced by enablePlugin().

Here is the caller graph for this function:

CAPluginManager::~CAPluginManager (  ) 

Definition at line 69 of file pluginmanager.cpp.


Member Function Documentation

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.
See also:
enablePlugin(), enablePlugins()

Definition at line 78 of file pluginmanager.cpp.

References _pluginList, CACanorus::locateResource(), and CAPlugin::setDirName().

Referenced by main().

Here is the call graph for this function:

Here is the caller graph for this function:

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

Definition at line 149 of file pluginmanager.cpp.

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:

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

Definition at line 115 of file pluginmanager.cpp.

References _pluginList, and enablePlugin().

Referenced by CAMainWin::CAMainWin().

Here is the call graph for this function:

Here is the caller graph for this function:

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.

Definition at line 180 of file pluginmanager.cpp.

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

Referenced by disablePlugins(), and removePlugin().

Here is the call graph for this function:

Here is the caller graph for this function:

bool CAPluginManager::disablePlugins (  )  [static]

Disable and deinitializes all plugins.

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

See also:
disablePlugin(), enablePlugins()

Definition at line 132 of file pluginmanager.cpp.

References _pluginList, and disablePlugin().

Here is the call graph for this function:

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

Definition at line 460 of file pluginmanager.cpp.

References _actionMap.

Referenced by endElement(), and CAMainWin::scoreViewPortMousePress().

Here is the caller graph for this function:

static bool CAPluginManager::exportFilterExists ( const QString  filter  )  [inline, static]

Definition at line 37 of file pluginmanager.h.

References _exportFilterMap.

Referenced by CAMainWin::on_uiExportDocument_triggered().

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

Definition at line 428 of file pluginmanager.cpp.

References _exportFilterMap.

Referenced by CAMainWin::on_uiExportDocument_triggered().

static bool CAPluginManager::importFilterExists ( const QString  filter  )  [inline, static]

Definition at line 39 of file pluginmanager.h.

References _importFilterMap.

Referenced by CAMainWin::on_uiImportDocument_triggered().

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

Definition at line 448 of file pluginmanager.cpp.

References _importFilterMap.

Referenced by CAMainWin::on_uiImportDocument_triggered().

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

Definition at line 214 of file pluginmanager.cpp.

bool CAPluginManager::removePlugin ( CAPlugin plugin  )  [static]

Disables and deletes the directory containing the given plugin.

See also:
installPlugin(), disablePlugin()

Definition at line 223 of file pluginmanager.cpp.

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

Here is the call graph for this function:

const QList<CAPlugin*> CAPluginManager::pluginList (  )  [inline]

Definition at line 45 of file pluginmanager.h.

References _pluginList.

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

Definition at line 231 of file pluginmanager.cpp.

References _curActionArgs, _curActionExportFilter, _curActionFilename, _curActionFunction, _curActionImportFilter, _curActionLang, _curActionLocale, _curActionName, _curActionOnAction, _curActionParentMenu, _curActionParentToolbar, _curActionRefresh, _curActionText, _curMenuLocale, _curMenuName, _curMenuParentMenu, _curMenuTitle, _curPlugin, _curPluginLocale, and _tree.

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

Definition at line 277 of file pluginmanager.cpp.

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(), CAPluginAction::setExportFilters(), CAPlugin::setHomeUrl(), CAPluginAction::setImportFilters(), CAPlugin::setName(), CAPluginAction::setOnAction(), CAPluginAction::setRefresh(), CAPluginAction::setTexts(), CAPlugin::setUpdateUrl(), and CAPlugin::setVersion().

Here is the call graph for this function:

bool CAPluginManager::fatalError ( const QXmlParseException &  exception  ) 

Definition at line 403 of file pluginmanager.cpp.

bool CAPluginManager::characters ( const QString &  ch  ) 

Definition at line 407 of file pluginmanager.cpp.

References _curChars.


Member Data Documentation

QList< CAPlugin * > CAPluginManager::_pluginList [static, private]

Definition at line 56 of file pluginmanager.h.

Referenced by disablePlugins(), enablePlugins(), pluginList(), and readPlugins().

QMultiHash< QString, CAPlugin * > CAPluginManager::_actionMap [static, private]

Definition at line 57 of file pluginmanager.h.

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

QHash< QString, CAPluginAction * > CAPluginManager::_exportFilterMap [static, private]

Definition at line 58 of file pluginmanager.h.

Referenced by endElement(), exportAction(), and exportFilterExists().

QHash< QString, CAPluginAction * > CAPluginManager::_importFilterMap [static, private]

Definition at line 59 of file pluginmanager.h.

Referenced by endElement(), importAction(), and importFilterExists().

CAMainWin* CAPluginManager::_mainWin [private]

Definition at line 62 of file pluginmanager.h.

Referenced by CAPluginManager(), and endElement().

QString CAPluginManager::_curChars [private]

Definition at line 63 of file pluginmanager.h.

Referenced by characters(), and endElement().

QStack<QString> CAPluginManager::_tree [private]

Definition at line 64 of file pluginmanager.h.

Referenced by endElement(), and startElement().

CAPlugin* CAPluginManager::_curPlugin [private]

Definition at line 66 of file pluginmanager.h.

Referenced by CAPluginManager(), endElement(), and startElement().

QString CAPluginManager::_curPluginCanorusVersion [private]

Definition at line 67 of file pluginmanager.h.

Referenced by CAPluginManager(), and endElement().

QString CAPluginManager::_curPluginLocale [private]

Definition at line 68 of file pluginmanager.h.

Referenced by endElement(), and startElement().

QHash<QString, QString> CAPluginManager::_curActionText [private]

Definition at line 71 of file pluginmanager.h.

Referenced by endElement(), and startElement().

QString CAPluginManager::_curActionName [private]

Definition at line 72 of file pluginmanager.h.

Referenced by endElement(), and startElement().

QString CAPluginManager::_curActionLocale [private]

Definition at line 73 of file pluginmanager.h.

Referenced by endElement(), and startElement().

QString CAPluginManager::_curActionOnAction [private]

Definition at line 74 of file pluginmanager.h.

Referenced by endElement(), and startElement().

QHash<QString,QString> CAPluginManager::_curActionExportFilter [private]

Definition at line 75 of file pluginmanager.h.

Referenced by endElement(), and startElement().

QHash<QString,QString> CAPluginManager::_curActionImportFilter [private]

Definition at line 75 of file pluginmanager.h.

Referenced by endElement(), and startElement().

QString CAPluginManager::_curActionParentMenu [private]

Definition at line 76 of file pluginmanager.h.

Referenced by endElement(), and startElement().

QString CAPluginManager::_curActionParentToolbar [private]

Definition at line 76 of file pluginmanager.h.

Referenced by endElement(), and startElement().

bool CAPluginManager::_curActionRefresh [private]

Definition at line 77 of file pluginmanager.h.

Referenced by endElement(), and startElement().

QString CAPluginManager::_curActionLang [private]

Definition at line 78 of file pluginmanager.h.

Referenced by endElement(), and startElement().

QString CAPluginManager::_curActionFunction [private]

Definition at line 78 of file pluginmanager.h.

Referenced by endElement(), and startElement().

QString CAPluginManager::_curActionFilename [private]

Definition at line 78 of file pluginmanager.h.

Referenced by endElement(), and startElement().

QList<QString> CAPluginManager::_curActionArgs [private]

Definition at line 79 of file pluginmanager.h.

Referenced by endElement(), and startElement().

QString CAPluginManager::_curMenuName [private]

Definition at line 82 of file pluginmanager.h.

Referenced by endElement(), and startElement().

QHash<QString, QString> CAPluginManager::_curMenuTitle [private]

Definition at line 83 of file pluginmanager.h.

Referenced by endElement(), and startElement().

QString CAPluginManager::_curMenuLocale [private]

Definition at line 84 of file pluginmanager.h.

Referenced by endElement(), and startElement().

QString CAPluginManager::_curMenuParentMenu [private]

Definition at line 85 of file pluginmanager.h.

Referenced by endElement(), and startElement().


The documentation for this class was generated from the following files:
Generated on Sat Feb 9 13:20:05 2008 for Canorus by  doxygen 1.5.3