Scribus
Open source desktop publishing at your fingertips
PluginManager Class Reference

PluginManager handles plugin loading, unloading, and running. More...

#include <pluginmanager.h>

Inheritance diagram for PluginManager:
Collaboration diagram for PluginManager:

Classes

struct  PluginData
 PluginData is structure for plugin related informations. More...
 

Public Slots

void languageChange ()
 

Public Member Functions

void initPlugs ()
 Initalization of all plugins. It's called at scribus start. More...
 
bool setupPluginActions (ScribusMainWindow *)
 Called at after initPlugs to hook the loaded plugin into the GUI. Run in main window startup.
 
bool setupPluginActions (StoryEditor *sew)
 Called at after initPlugs to hook the loaded plugin into the GUI. Run in SE startup.
 
void enableOnlyStartupPluginActions (ScribusMainWindow *)
 Called when the last doc is closed.
 
void enablePluginActionsForSelection (ScribusMainWindow *)
 Called when the last doc is closed.
 
bool DLLexists (QString pluginName, bool includeDisabled=false) const
 Checks if is the plugin is in the plugin map, is loaded, and is enabled. More...
 
ScPlugingetPlugin (const QString &pluginName, bool includeDisabled) const
 Returns a pointer to the requested plugin, or 0 if not found. More...
 
void cleanupPlugins ()
 Shutdowns all plugins. Called at scribus quit.
 
void savePreferences ()
 Saves pluginManager preferences.
 
const QString getPluginPath (const QString &pluginName) const
 Return the path to the file for the named plugin. An invalid plugin name is an error.
 
bool & enableOnStartup (const QString &pluginName)
 Whether the given plug-in will be enabled on start-up. Usable as an lvalue. An invalid plugin name is an error.
 
bool enabled (const QString &pluginName)
 Whether the given plugin is currently enabled.
 
QStringList pluginNames (bool includeDisabled=false, const char *inherits=0) const
 Return a list of plugin names currently known. More...
 
virtual void changeEvent (QEvent *e)
 

Static Public Member Functions

static void * loadDLL (QString plugin)
 Static methods for loading, unloading plugins and resolving symbols These methods are platform independent, but each platform uses a different implementation.
 
static void * resolveSym (void *plugin, const char *sym)
 
static void unloadDLL (void *plugin)
 
static QString platformDllExtension ()
 Return file extension used for shared libs on this platform.
 
static int platformDllSearchFlags ()
 Return file extension used for shared libs on this platform.
 
static PluginManagerinstance ()
 Return a pointer to this instance. More...
 

Protected Types

typedef QMap< QString, PluginDataPluginMap
 Mapping of plugin names to plugin info structures.
 

Protected Member Functions

int initPlugin (const QString fileName)
 Init one plugin. This method loadDLL(...)'s each plug-in, creates a Plugin instance for them, stores a PluginData for the plugin, sets up the plug-in's actions, and connects them to any required signals. It doesn't ask plug-ins to do any time-consuming setup. It's called by initPlugs. More...
 
bool loadPlugin (PluginData &pluginData)
 Reads available info and fills PluginData structure.
 
void enablePlugin (PluginData &)
 Called by loadPlugin to hook the loaded plugin into the GUI, call its setup routine, etc. Not responsible for creating the ScPlugin instance or loading the plugin.
 
void disablePlugin (PluginData &pda)
 Called by finalizePlug when shutting down a plug-in. Unhooks the plug-in from the GUI, calls its cleanup routine, etc. DOES NOT destroy the ScPlugin instance or unload the plugin.
 
QString callDLLForNewLanguage (const PluginData &pluginData)
 Runs plugin's languageChange() method, and returns main menu item text if one exists.
 
void finalizePlug (PluginData &pluginData)
 Shuts down one plug-in. The DLL may not be unloaded, but it is cleaned up and its ScPlugin instance is destroyed. The plug-in is marked unloaded in the map. More...
 

Static Protected Member Functions

static QString getPluginName (QString fileName)
 Determines the plugin name from the file name and returns it.
 

Protected Attributes

PrefsContextprefs
 Configuration structure.
 
PluginMap pluginMap
 Plugin mapping. Each plugin has its record key() -> PluginData.
 

Detailed Description

PluginManager handles plugin loading, unloading, and running.

It contains methods and attributes for plugin running and its settings and returning values.

Derived from Franz's ScribusMainWindow stuff (petr vanek)

Member Function Documentation

bool PluginManager::DLLexists ( QString  pluginName,
bool  includeDisabled = false 
) const

Checks if is the plugin is in the plugin map, is loaded, and is enabled.

Parameters
pluginNamename of plugin to get
includeDisabledreturn true if a plugin is loaded but not enabled
Returns
bool
void PluginManager::finalizePlug ( PluginData pluginData)
protected

Shuts down one plug-in. The DLL may not be unloaded, but it is cleaned up and its ScPlugin instance is destroyed. The plug-in is marked unloaded in the map.

Parameters
pdaplugin data
ScPlugin * PluginManager::getPlugin ( const QString &  pluginName,
bool  includeDisabled 
) const

Returns a pointer to the requested plugin, or 0 if not found.

If includeDisabled is true, plugins that are loaded but not enabled are returned. If it is false, 0 is returned if the requested plugin is loaded but not enabled.

int PluginManager::initPlugin ( const QString  fileName)
protected

Init one plugin. This method loadDLL(...)'s each plug-in, creates a Plugin instance for them, stores a PluginData for the plugin, sets up the plug-in's actions, and connects them to any required signals. It doesn't ask plug-ins to do any time-consuming setup. It's called by initPlugs.

Parameters
fileNamea filename of the plugin without path
Return values
int0 init failed, 1 loaded.
void PluginManager::initPlugs ( )

Initalization of all plugins. It's called at scribus start.

Walk through all plugins, try to init them and try to re-load failed ones then. See initPlugin for more info. Reload uses a "brute force" method - Repeat until there is something to load again. It's not elegant I know. But there are no additional dependancy relations addons (XML config, plugin classes change etc.).

Note
QDir::Reversed is there due the Mac plugin dependency. barcode depends on psimport. and load on that platform expect the psimp before barcode.You know, security by obscurity ;) PV
PluginManager & PluginManager::instance ( )
static

Return a pointer to this instance.

Note
for now, returns a reference to (*ScMW->pluginManager); should probably be turned into a singleton later.
QStringList PluginManager::pluginNames ( bool  includeDisabled = false,
const char *  inherits = 0 
) const

Return a list of plugin names currently known.

If includeNotLoaded is true, names are returned for plug-ins that are not loaded (ie we have no ScPlugin instance for them).

Parameters
includeDisabledShould the names of plugins that are loaded, but disabled, be returned?
inheritsOnly return plugins that inherit from this parent (the text name of the type - uses QMetaObject).
Returns
A list of internal plugin names suitable for use with getPlugin etc.
See also
getPluginNamesT
getPlugin

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