Canorus  0.7
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
Public Member Functions | Static Public Member Functions | Private Attributes | Static Private Attributes
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 ()
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:
            - Static members
                    Used globally to read, install/remove and enable/disable plugins.
            - Non-static members
                    Inherits the QXml facilities and is used for parsing the plugin's descriptor file.

    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.
    \sa CAPlugin, CAPluginManagerWin

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

References _curPlugin, _curPluginCanorusVersion, and _mainWin.

Referenced by enablePlugin().

Here is the caller graph for this function:


Member Function Documentation

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::onScoreViewPortSelectionChanged(), and CAMainWin::scoreViewPortMousePress().

Here is the caller graph for this function:

bool CAPluginManager::characters ( const QString &  ch)

References _curChars.

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::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:

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:

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:

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.
    \sa 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:

bool CAPluginManager::endElement ( const QString &  namespaceURI,
const QString &  localName,
const QString &  qName 
)
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:

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

References _exportFilterMap.

Referenced by CAMainWin::on_uiExportDocument_triggered().

Here is the caller graph for this function:

bool CAPluginManager::fatalError ( const QXmlParseException &  exception)
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:

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

References _importFilterMap.

Referenced by CAMainWin::on_uiImportDocument_triggered().

Here is the caller graph for this function:

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
static const QList<CAPlugin*> CAPluginManager::pluginList ( ) [inline, static]

References _pluginList.

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.
    \sa 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:

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:

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

Member Data Documentation

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

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

QList<QString> CAPluginManager::_curActionArgs [private]

Referenced by endElement(), and startElement().

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

Referenced by endElement(), and startElement().

Referenced by endElement(), and startElement().

Referenced by endElement(), and startElement().

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

Referenced by endElement(), and startElement().

Referenced by endElement(), and startElement().

Referenced by endElement(), and startElement().

Referenced by endElement(), and startElement().

Referenced by endElement(), and startElement().

Referenced by endElement(), and startElement().

Referenced by endElement(), and startElement().

Referenced by endElement(), and startElement().

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

Referenced by endElement(), and startElement().

QString CAPluginManager::_curChars [private]

Referenced by characters(), and endElement().

Referenced by endElement(), and startElement().

QString CAPluginManager::_curMenuName [private]

Referenced by endElement(), and startElement().

Referenced by endElement(), and startElement().

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

Referenced by endElement(), and startElement().

Referenced by CAPluginManager(), and endElement().

Referenced by endElement(), and startElement().

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

Referenced by CAPluginManager(), and endElement().

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

Referenced by endElement(), and startElement().


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