mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-05-11 02:25:34 -04:00
ccc
git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@1031 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
parent
98911955d5
commit
b94e6f6386
7 changed files with 486 additions and 623 deletions
|
@ -12,7 +12,14 @@
|
|||
#include <QVector>
|
||||
|
||||
class PluginInterface;
|
||||
class PluginManagerWidget;
|
||||
|
||||
//! An engine for plugins management
|
||||
|
||||
//! This class performs oaa plugin management operations: installing,
|
||||
//! loading, remowing. it also provides a PluginManagerWidget for controlling
|
||||
//! itself. I supose, a appication has to create a global instance of the class,
|
||||
//! so all pages (instances of the MainPage class) could receive plugin widgets.
|
||||
class PluginManager: public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
@ -21,37 +28,96 @@ public:
|
|||
PluginManager();
|
||||
~PluginManager();
|
||||
|
||||
void defaultLoad(QString baseDir = "");
|
||||
//! Checks up 'plugins' folder for loadable plugins
|
||||
|
||||
QStringList availablePlugins();
|
||||
QStringList loadedPlugins();
|
||||
//! This is a separate method, becouse an application should create
|
||||
//! a PluginManager instance, then connect all its signals, optionally
|
||||
//! create a view widget, and only after all perform lookup
|
||||
void defaultLoad( ) ;
|
||||
|
||||
bool isLoaded(QString pluginName);
|
||||
void unloadPlugin(QString pluginName);
|
||||
//! GUI for the loader.
|
||||
|
||||
//! Returns a PluginManagerWidget instance. When called for the first time,
|
||||
//! creates a new object; after that returns pointer to the same instance.
|
||||
//! After the instance was deleteted (it could be safely done in usual way)
|
||||
//! may create a new one.
|
||||
QWidget* getViewWidget(QWidget* parent = 0);
|
||||
|
||||
//! Loads a widget of the plugin with given name
|
||||
|
||||
//! Loads a new copy (called twice will return different objects) of the
|
||||
//! plugin widget. If there is no plugin with given name, returns 0 (also
|
||||
//! emits errorAppeared(..) with an error description).
|
||||
//! PluginManager provides ablolutely no control over returned widget;
|
||||
//! the application should delete it, like all other widgets
|
||||
QWidget* pluginWidget(QString pluginName);
|
||||
|
||||
//! returns last error appeared;
|
||||
|
||||
//! Sorry, doesn't work in current implementation
|
||||
QString getLastError();
|
||||
|
||||
public slots:
|
||||
void loadPlugin(QString pluginName);
|
||||
void readPluginFromFile(QString fullFileName);
|
||||
// void loadPluginFromFile(QString fileName);
|
||||
//! processes the desctucrion of the view widget;
|
||||
void viewWidgetDestroyed(QObject * obj = 0);
|
||||
|
||||
//! processes the plugin installation request
|
||||
|
||||
//! After successful installatio a newPluginRegistered(..) signal will be
|
||||
//! emitted. On some error -- errorAppeared(..) will be emitted;
|
||||
//! 'Installation' means that plgin file (dll or so) will be checked and
|
||||
//! copied to the 'plugins' directory. Later, in pluginWidget(..) call this
|
||||
//! copy will be used
|
||||
void installPlugin(QString fileName);
|
||||
|
||||
//! Processes plugin remove request
|
||||
|
||||
//! 'Remove' means that plugin file (so or dll) will be physically deleted
|
||||
//! from 'plugins' folder.
|
||||
void removePlugin(QString pluginName);
|
||||
|
||||
signals:
|
||||
void loadDone(QString pluginName, QWidget* pluginWidget);
|
||||
void loadFailed(QString pluginName, QString errorMessage);
|
||||
void installComplete(QString pluginName);
|
||||
void installFailed(QString pluginFileName, QString errorMessage);
|
||||
//! PluginManager emits this signal on every error;
|
||||
|
||||
//! This signal is connected to the PluginManagerWidget::acceptErrorMessage.
|
||||
//! So, all error messages will appear on the view widget (only if that one
|
||||
//! was created, of course)
|
||||
void errorAppeared(QString errorDescription);
|
||||
|
||||
//! Is emitted after plugin removing;
|
||||
|
||||
//! Already loaded plugin widgets, will not be deleted. Nobody will touch
|
||||
//! them
|
||||
void pluginRemoveCompleted(QString pluginName);
|
||||
|
||||
//! Is emitted for every loadable plugin
|
||||
|
||||
void newPluginRegistered(QString pluginName);
|
||||
|
||||
protected:
|
||||
|
||||
//QList<QPluginLoader*> loaders;
|
||||
QList<QWidget*> widgets;
|
||||
// QList<int> widgets;
|
||||
PluginManagerWidget* viewWidget;
|
||||
|
||||
QStringList fileNames;
|
||||
QList<QString> names;
|
||||
// QList<int> states;
|
||||
QStringList names;
|
||||
|
||||
PluginInterface* loadPluginInterface(QString fileName,
|
||||
QString& errorMessage) ;
|
||||
QString baseFolder;
|
||||
QString lastError;
|
||||
|
||||
//! Reads information from plugin file
|
||||
|
||||
//! The function tries to read the info from the plugin file (in current
|
||||
//! implementation only pluginName).
|
||||
//! \returns 0 on success, error code (>0) on fail
|
||||
int readPluginInformation( QString fileName, QString& pluginName);
|
||||
|
||||
//! ---
|
||||
|
||||
//! Adds plugin name and plugin filename to the lists, emits nesessary
|
||||
//! signals, updates the view widget
|
||||
void acceptPlugin( QString fileName, QString pluginName);
|
||||
|
||||
|
||||
PluginInterface* loadPluginInterface(QString fileName ) ;
|
||||
|
||||
};
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue