plugin system: plugin management features added (loading and unloading)

git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@1008 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
beardog_uk 2009-02-05 15:29:43 +00:00
parent bb904ea8e8
commit ba1befd560
7 changed files with 898 additions and 68 deletions

View File

@ -137,6 +137,8 @@ HEADERS += rshare.h \
gui/LogoBar.h \
gui/xprogressbar.h \
gui/PluginsPage.h \
gui/PluginManagerWidget.h \
gui/PluginManager.h \
gui/plugins/PluginInterface.h \
lang/languagesupport.h \
util/stringutil.h \
@ -364,6 +366,8 @@ SOURCES += main.cpp \
gui/LogoBar.cpp \
gui/xprogressbar.cpp \
gui/PluginsPage.cpp \
gui/PluginManagerWidget.cpp \
gui/PluginManager.cpp \
lang/languagesupport.cpp \
util/stringutil.cpp \
util/win32.cpp \

View File

@ -0,0 +1,298 @@
#include <QFile>
#include <QDir>
#include <QRegExp>
#include <QDebug>
#include <QWidget> //a strange thing: it compiles without this header, but
//then segfaults in some place
#include "PluginManager.h"
#include "plugins/PluginInterface.h"
PluginManager::PluginManager()
{
}
void
PluginManager::defaultLoad( QString baseDir )
{
QDir workDir(baseDir);
/* //=== find a file with last loaded plugins =====
QStringList lastLoaded;
QFile llFile( workDir.absolutePath()+"last_loaded.txt" ) ;
if ( llFile.open(QIODevice::ReadOnly) )
{
QString tmps;
QTextStream stream( &llFile ); // Set the stream to read from myFile
tmps = stream.readLine();
lastLoaded = tmps.split(";");
llFile.close();
}
*/
//=== get current available plugins =====
QStringList currAvailable = workDir.entryList(QDir::Files);
#if defined(Q_OS_WIN)
QRegExp trx("*.dll") ;
#else
QRegExp trx("*.so");
#endif
trx.setPatternSyntax(QRegExp::Wildcard );
currAvailable.filter( trx );
qDebug() << " " << "can load this plugins: " << currAvailable ;
//===
foreach(QString pluginFileName, currAvailable)
{
QString fullfn( workDir.absoluteFilePath( pluginFileName ) );
readPluginFromFile( fullfn);
}// foreach(QString pluginFileName, currAvailable)
qDebug() << " " << "names are " << names;
}
//=============================================================================
void
PluginManager::readPluginFromFile(QString fullFileName)
{
qDebug() << " " << "processing file " << fullFileName;
QString errMess;
PluginInterface* plugin = loadPluginInterface(fullFileName, errMess) ;
QString plName = "Name undefined" ;
QWidget* plWidget = 0;
if (plugin)
{
plName = plugin->pluginName();
qDebug() << " " << "got pluginName:" << plName;
/*
//=== load widget (only if this plugin was loaded last time)
if ( lastLoaded.indexOf( pluginFileName) >= 0)
{
plWidget = plugin->pluginWidget() ;
if (plWidget)
{
// all was good,
qDebug() << " " << "got widget..." ;
emit loadDone( plName, plWidget);
}
else
{
errMess = "Plugin Object can't create widget" ;
}
}
*/
delete plugin;
names.append(plName);
// int tpi = (int)plWidget;
widgets.append(plWidget);
fileNames.append(fullFileName);
emit installComplete(plName);
}
else
{
emit installFailed( plName, errMess);
}
}
//=============================================================================
PluginInterface*
PluginManager::loadPluginInterface(QString fileName, QString& errorMessage)
{
errorMessage = "Default Error Message" ;
PluginInterface* plugin = 0 ;
QPluginLoader* plLoader = new QPluginLoader(fileName);
QObject *pluginObject = plLoader->instance();
if (pluginObject)
{
//qDebug() << " " << "loaded..." ;
plugin = qobject_cast<PluginInterface*> (pluginObject) ;
if (plugin)
{
errorMessage = "No error" ;
}
else
{
errorMessage = "Cast to 'PluginInterface*' failed";
}
}
else
{
errorMessage = "Istance wasn't created: " + plLoader->errorString() ;
}
delete plLoader; // plugin instance will not be deleted with this action
return plugin;
}
/*
plName = plugin->pluginName();
// names.append(plddName);
qDebug() << " " << "got pluginName:" << plName;
//=== load widget (only if this plugin was loaded last time)
if ( lastLoaded.indexOf( pluginFileName) >= 0)
{
QWidget* pw = plugin->pluginWidget() ;
if (pw)
{
// all was good,
qDebug() << " " << "got widget..." ;
plState = PS_Loaded;
emit loadDone( plName, pw);
}
else
{
errMess = "Plugin Object can't create widget" ;
plState = PS_Failed ;
}
}
else
{
plState = PS_Viewed ; //this is no error, all's normal
}
}
// delete pluginObject;
}
else
{
errMess = "Instance wasn't created: " + plLoader->errorString() ;
}
}
*/
//=============================================================================
PluginManager:: ~PluginManager()
{
// delete all widgets
foreach(QWidget* wp, widgets)
{
if (wp)
delete wp;
}
}
//=============================================================================
QStringList
PluginManager::availablePlugins()
{
return names;
}
//=============================================================================
QStringList
PluginManager::loadedPlugins()
{
}
bool
PluginManager::isLoaded(QString pluginName)
{
}
//=============================================================================
void
PluginManager::loadPlugin(QString pluginName)
{
qDebug() << "" << "PluginManager::loadPlugin called for" << pluginName;
int plIndex = names.indexOf( pluginName ) ;
if (plIndex >=0 )
{
QWidget* plWidget = widgets.at(plIndex);
//=== first, check if we loaded it before
if ( plWidget )
{
emit loadFailed( pluginName,
"Error: plugin already loaded") ;
return ;
}
//=== next, load it's interface
QString fn = fileNames.at(plIndex);
QString errMess;
PluginInterface* pliface = loadPluginInterface(fn, errMess);
if (pliface)
{
//=== now, get a widget
plWidget = pliface->pluginWidget() ;
if (plWidget)
{
// all was good,
qDebug() << " " << "got plg widget..." ;
emit loadDone( pluginName, plWidget );
widgets[plIndex] = plWidget;
return;
}
else
{
emit loadFailed(pluginName,
"Error: instance can't create a widget");
return;
}
}
else
{
emit loadFailed( pluginName,
tr("Error: failed to load interface for ")
+ pluginName +"("+errMess+")");
return;
}
}
else
{
emit loadFailed( pluginName,
tr("Error: know nothing about plugin ") + pluginName );
qDebug() << " " << "error: request to load " << pluginName
<< " failed (unknown file)" ;
return;
}
}
//=============================================================================
void
PluginManager::unloadPlugin(QString pluginName)
{
qDebug() << " " << "PluginManager::unloadPlugin called for" << pluginName;
int plIndex = names.indexOf( pluginName ) ;
if (plIndex >=0 )
{
QWidget* plWidget = widgets.at(plIndex);
qDebug() << "in pm is " << (int)plWidget;
if ( plWidget )
{ //
widgets[plIndex] = 0;//(QWidget*)0;
qDebug() << "111" ;
delete plWidget;
qDebug() << "222" ;
}
}
}
//=============================================================================

View File

@ -0,0 +1,61 @@
#ifndef _PLUGIN_MANAGER_H_
#define _PLUGIN_MANAGER_H_
#include <QObject>
#include <QString>
#include <QStringList>
#include <QList>
#include <QPluginLoader>
#include <QVector>
class PluginInterface;
class PluginManager: public QObject
{
Q_OBJECT
public:
PluginManager();
~PluginManager();
void defaultLoad(QString baseDir = "");
QStringList availablePlugins();
QStringList loadedPlugins();
bool isLoaded(QString pluginName);
void unloadPlugin(QString pluginName);
public slots:
void loadPlugin(QString pluginName);
void readPluginFromFile(QString fullFileName);
// void loadPluginFromFile(QString fileName);
signals:
void loadDone(QString pluginName, QWidget* pluginWidget);
void loadFailed(QString pluginName, QString errorMessage);
void installComplete(QString pluginName);
void installFailed(QString pluginFileName, QString errorMessage);
protected:
//QList<QPluginLoader*> loaders;
QList<QWidget*> widgets;
// QList<int> widgets;
QStringList fileNames;
QList<QString> names;
// QList<int> states;
PluginInterface* loadPluginInterface(QString fileName,
QString& errorMessage) ;
};
#endif

View File

@ -0,0 +1,162 @@
#include "PluginManagerWidget.h"
#include <QHBoxLayout>
#include <QVBoxLayout>
#include <QPushButton>
#include <QLabel>
#include <QWidget>
#include <QFileDialog>
#include <QDebug>
//=============================================================================
//=============================================================================
//=============================================================================
enum {
LBS_Load , // load button state : load (it will send signal 'needToLoad')
LBS_Unload // load button state: unload
};
PluginFrame::PluginFrame(QWidget * parent, QString pluginName)
:QFrame(parent)
{
plgName = pluginName;
// labels
labelsLay = new QVBoxLayout() ;
nameLabel = new QLabel();
nameLabel->setText(pluginName);
nameLabel->setAlignment(Qt::AlignHCenter);
labelsLay->addWidget(nameLabel);
descrLabel = new QLabel();
descrLabel->setText("plugin description will appear here someday");
descrLabel->setWordWrap(true);
labelsLay->addWidget(descrLabel);
// buttons
buttonsLay = new QVBoxLayout() ;
loadBtn = new QPushButton;
loadBtn->setText( tr("Load") );
loadBtnState = LBS_Load;
connect( loadBtn, SIGNAL( clicked() ) ,
this , SLOT ( loadButtonClicked() ) );
buttonsLay->addWidget( loadBtn );
removeBtn = new QPushButton() ;
removeBtn->setText( tr("Remove") ) ;
buttonsLay->addWidget( removeBtn ) ;
//all together
mainLay = new QHBoxLayout(this);
mainLay->addLayout(labelsLay);
mainLay->addLayout(buttonsLay);
this->setFrameStyle(QFrame::Box | QFrame::Raised);
//hlay->addWidget(lbl);
}
//=============================================================================
PluginFrame::~PluginFrame()
{
//nothing to do here at this moment
}
//=============================================================================
void
PluginFrame::loadButtonClicked()
{
if (loadBtnState == LBS_Load)
{
emit needToLoad(plgName);
return;
}
if ( loadBtnState == LBS_Unload)
{
emit needToUnload(plgName);
loadBtn->setText( tr("Load") );
loadBtnState = LBS_Load ;
}
}
//=============================================================================
void
PluginFrame::removeButtonClicked()
{
emit needToRemove( plgName );
}
//=============================================================================
void
PluginFrame::successfulLoad(QString pluginName, QWidget* wd)
{
qDebug() << " " << "PluginFrame::successfulLoad for " << pluginName
<< " -- " << plgName ;
if (pluginName == plgName )
{
qDebug() << "so...";
loadBtn->setText( tr("Unload") );
loadBtnState = LBS_Unload ;
}
}
//=============================================================================
//=============================================================================
//=============================================================================
PluginManagerWidget::PluginManagerWidget(QWidget * parent)
:QFrame(parent)
{
vlay = new QVBoxLayout(this);
instPlgLay = new QHBoxLayout();
instPlgButton = new QPushButton();
instPlgButton->setText("Install New Plugin...");
connect( instPlgButton, SIGNAL( clicked() ),
this , SLOT( instPlgButtonClicked() ) );
instPlgLay->addWidget(instPlgButton);
instPlgSpacer = new QSpacerItem(283, 20,
QSizePolicy::Expanding, QSizePolicy::Minimum);
instPlgLay->addItem(instPlgSpacer);
vlay->addLayout( instPlgLay );
}
//=============================================================================
PluginManagerWidget::~PluginManagerWidget()
{
}
//=============================================================================
void
PluginManagerWidget::addPluginWidget(PluginFrame* pf)
{
vlay->addWidget(pf);
}
//=============================================================================
void
PluginManagerWidget::instPlgButtonClicked()
{
QString fileName = QFileDialog::getOpenFileName(this,
tr("Open Plugin to install"),
"./",
tr("Plugins (*.so *.dll)"));
if (!fileName.isNull())
{
emit needToLoadFileWithPlugin(fileName);
}
}

View File

@ -0,0 +1,82 @@
#ifndef _PLUGIN_MANAGER_WIDGET_
#define _PLUGIN_MANAGER_WIDGET_
#include <QFrame>
#include <QString>
class QWidget;
class QLabel;
class QHBoxLayout;
class QVBoxLayout;
class QPushButton;
class QSpacerItem;
//=============================================================================
class PluginFrame : public QFrame
{
Q_OBJECT
public:
PluginFrame(QWidget* parent , QString pluginName );
virtual ~PluginFrame();
signals:
void needToLoad(QString pluginName);
void needToUnload(QString pluginName);
void needToRemove(QString pluginName);
public slots:
void successfulLoad(QString pluginName, QWidget* wd=0);
protected slots:
void loadButtonClicked() ;
void removeButtonClicked();
protected:
QString plgName;
QPushButton* loadBtn;
unsigned char loadBtnState;
QPushButton* removeBtn;
QVBoxLayout* buttonsLay;
QHBoxLayout* mainLay; // main layout for the frame
QVBoxLayout* labelsLay;
QLabel* nameLabel;
QLabel* descrLabel;
};
//=============================================================================
class PluginManagerWidget: public QFrame
{
Q_OBJECT
public:
PluginManagerWidget(QWidget* parent);
virtual ~PluginManagerWidget();
void addPluginWidget(PluginFrame* pf);
signals:
void needToLoadFileWithPlugin(QString fileName) ;
protected:
QVBoxLayout* vlay;
QPushButton* instPlgButton;
QHBoxLayout* instPlgLay;
QSpacerItem* instPlgSpacer;
protected slots:
void instPlgButtonClicked();
};
//=============================================================================
#endif

View File

@ -4,42 +4,105 @@
#include <QTabWidget>
#include <QLabel>
#include <QSizePolicy>
#include <QTextEdit>
#include <QtPlugin>
#include <QPluginLoader>
#include <QDir>
#include <QDebug>
#include <QStringList>
#include <QRegExp>
#include <QUiLoader>
#include <QtScript>
#include <QApplication> // for qApp->....
//#include <QUiLoader>
//#include <QtScript>
#include <QFile>
//#include <QIODevice>
#include <QMessageBox>
#include <QGroupBox>
#include "PluginsPage.h"
#include "PluginManagerWidget.h"
#include "PluginManager.h"
#include "rshare.h"
#include "plugins/PluginInterface.h"
//#include "plugins/PluginInterface.h"
//==============================================================================
PluginsPage::PluginsPage(QWidget *parent )
// :QGroupBox(parent)
:MainPage(parent)
{
//=== create some gui elements =====
pluginPageLayout = new QVBoxLayout(this);
pluginPanel = new QGroupBox(this) ;
pluginPanel->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding) ;
pluginPanel->setTitle("RetroShare plugins");
pluginPageLayout->addWidget(pluginPanel);
pluginPanelLayout = new QVBoxLayout(pluginPanel);
// pluginPanel = new QGroupBox(this) ;
// pluginPanel->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding) ;
// this->setTitle("RetroShare plugins");
pluginTabs = new QTabWidget(this) ;
pluginPageLayout->addWidget(pluginTabs);
pmFrame = new QFrame;
pmLay = new QVBoxLayout(pmFrame);
pluginManagerWidget = new PluginManagerWidget(pmFrame);
pmLay->addWidget( pluginManagerWidget );
pmSpacer = new QSpacerItem(283, 20,
QSizePolicy::Expanding, QSizePolicy::Minimum);
pmLay->addItem(pmSpacer);
errlogConsole = new QTextEdit();
pmLay->addWidget( errlogConsole );
pluginTabs->addTab( pmFrame, "Manager" ) ;
// pluginTabs->addTab( errlogConsole, "Error messages" );
//=== try to load binary plugins =====
pluginManager = new PluginManager();
connect( pluginManager, SIGNAL( loadDone(QString, QWidget*) ),
this , SLOT( loadDone(QString, QWidget*) ) );
connect( pluginManager, SIGNAL(loadFailed(QString, QString)) ,
this , SLOT( loadFailed(QString, QString ) ) );
connect( pluginManagerWidget, SIGNAL( needToLoadFileWithPlugin(QString)),
pluginManager , SLOT( readPluginFromFile(QString) ) );
connect( pluginManager, SIGNAL( installComplete(QString) ),
this , SLOT( installComplete(QString) ) );
connect( pluginManager, SIGNAL(installFailed(QString, QString)) ,
this , SLOT( installFailed(QString, QString ) ) );
pluginManager->defaultLoad( Rshare::dataDirectory() + "/plugins" );
// a variant for a toy app: qApp->applicationDirPath()+"///plugins" ) ;
//QStringList lll = pluginManager->availablePlugins();
//foreach( QString pn, lll)
//{
// qDebug() << " " << "----" << pn << "----" ;
//}
/*
QDir pluginsDir(qApp->applicationDirPath()+"///plugins");
if (pluginsDir.exists())
loadBinaryPlugins( pluginsDir );
else
{
qDebug() << " " << "plugins will not be loaded: " << pluginsDir.absolutePath() ;
}
*/
// pluginPageLayout->addWidget(pluginPanel);
/*
pluginPanelLayout = new QVBoxLayout(pluginPanel);
pluginTabs = new QTabWidget(pluginPanel);
pluginPanelLayout->addWidget(pluginTabs);
QLabel* lbl1 = new QLabel();
QString defMess = "If you see only this tab, it's a bug :(\n";
defMess+= "If you see this tub and calculator, it's a bug too";
lbl1->setText(defMess);
lbl1->setText("If you see only this tab, it's a bug :( If you see this tub and calculator, it's a bug too");
pluginTabs->addTab(lbl1, "LLL");//Rshare::dataDirectory());
//"L #1");
@ -47,13 +110,23 @@ PluginsPage::PluginsPage(QWidget *parent )
//lbl2->setText("Label #2");
//pluginTabs->addTab(lbl2, "L #2; for debugging purposes");
QDir pluginsDir(Rshare::dataDirectory() + "/plugins");
QDir pluginsDir(Rshare::dataDirectory());
if ( !pluginsDir.exists() )
{
lbl1->setText("failed to locate 'plugins' directory. Nothing to load" );
return ;
// this piece of code is magical and untested ;
// but on Windows it works
#if defined(Q_OS_WIN)
if (pluginsDir.dirName().toLower() == "debug" || pluginsDir.dirName().toLower() == "release")
pluginsDir.cdUp();
#elif defined(Q_OS_MAC)
if (pluginsDir.dirName() == "MacOS") {
pluginsDir.cdUp();
pluginsDir.cdUp();
pluginsDir.cdUp();
}
#endif
// eof magick
pluginsDir.cd("plugins");
foreach (QString fileName, pluginsDir.entryList(QDir::Files))
{
@ -87,17 +160,9 @@ PluginsPage::PluginsPage(QWidget *parent )
}
// script plugins loading; warning, code is dirty; will be changed later
engine = new QScriptEngine(parent);
engine = new QScriptEngine;
pluginsDir.setPath(Rshare::dataDirectory() + "/script_plugins");
if ( !pluginsDir.exists() )
{
QString tmps = lbl1->text();
tmps += " Failed to locate 'script_plugins' directory. " ;
lbl1->setText( tmps);
return ;
}
pluginsDir.cd("../script_plugins");
@ -118,53 +183,171 @@ PluginsPage::PluginsPage(QWidget *parent )
QRegExp rx_qs(".*js");
ti = scfList.indexOf(rx_qs);
if(ti > -1)
{
QFile scriptFile( spDir.absoluteFilePath( scfList.at(ti) ) );
scriptFile.open(QIODevice::ReadOnly);
engine->evaluate(scriptFile.readAll());
scriptFile.close();
}
QFile scriptFile( spDir.absoluteFilePath( scfList.at(ti) ) );
scriptFile.open(QIODevice::ReadOnly);
engine->evaluate(scriptFile.readAll());
scriptFile.close();
QUiLoader loader;
QRegExp rx_ui(".*ui");
QWidget *ui = NULL ;
ti = scfList.indexOf(rx_ui) ;
QFile uiFile( spDir.absoluteFilePath( scfList.at(ti) ) );
qDebug() << "ui file is " << scfList.at(ti) ;
uiFile.open(QIODevice::ReadOnly);
QWidget *ui = loader.load(&uiFile);
uiFile.close();
if(ti > -1)
{
ti = scfList.indexOf(rx_ui) ;
QFile uiFile( spDir.absoluteFilePath( scfList.at(ti) ) );
qDebug() << "ui file is " << scfList.at(ti) ;
uiFile.open(QIODevice::ReadOnly);
ui = loader.load(&uiFile);
uiFile.close();
}
QScriptValue ctor = engine->evaluate("Plugin");
QScriptValue scriptUi = engine->newQObject(ui, QScriptEngine::ScriptOwnership);
QScriptValue calc = ctor.construct(QScriptValueList() << scriptUi);
if (!ui)
qDebug() << "ui is null :(" ;
else
{
QScriptValue ctor = engine->evaluate("Plugin");
QScriptValue scriptUi = engine->newQObject(ui, QScriptEngine::ScriptOwnership);
QScriptValue calc = ctor.construct(QScriptValueList() << scriptUi);
}
//ui->show();
pluginTabs->addTab(ui,"Script plugin");
}
//What has a head like a cat, feet like a cat, a tail like a cat, but isn't a cat?
}
*/
}
//==============================================================================
PluginsPage::~PluginsPage()
{
// nothing to do here at this moment
//delete engine;
// remove all pages, exept first (i.e remove all pages with plugins)
for( int pi=1; pi<pluginTabs->count(); pi++)
{
pluginTabs->removeTab(pi); // widgets itself will be deleted
//in ~PluginManager()
}
}
//=============================================================================
void
PluginsPage::installComplete(QString pluginName)
{
PluginFrame* pf = new PluginFrame( pluginManagerWidget, pluginName);
connect( pluginManager, SIGNAL( loadDone(QString, QWidget*) ),
pf , SLOT( successfulLoad(QString, QWidget*) ) );
connect( pf , SIGNAL( needToLoad(QString) ),
pluginManager, SLOT( loadPlugin(QString) ) );
// connect( pf , SIGNAL( needToUnload(QString) ),
// pluginManager, SLOT( unloadPlugin(QString) ) );
connect( pf , SIGNAL( needToUnload(QString) ),
this , SLOT( unloadPlugin(QString) ) );
pluginManagerWidget->addPluginWidget(pf);
}
//=============================================================================
void
PluginsPage::installFailed(QString pluginFileName, QString errorMessage)
{
QString tmps = QString("failed to install plugin from %1 (%2)")
.arg(pluginFileName)
.arg(errorMessage);
errlogConsole->append(tmps);
}
//=============================================================================
void
PluginsPage::loadDone(QString pluginName, QWidget* pluginWidget)
{
pluginTabs->addTab( pluginWidget, pluginName );
}
//==============================================================================
void
PluginsPage::loadFailed(QString pluginName, QString errorMessage)
{
QString tmps = QString("failed to load plugin %1 (%2)")
.arg(pluginName)
.arg(errorMessage);
errlogConsole->append(tmps);
}
//==============================================================================
void
PluginsPage::unloadPlugin(QString pluginName)
{
qDebug() << " " << "PluginsPage::unloadPlugin called for " << pluginName ;
for (int tabi=0; tabi< pluginTabs->count(); tabi++)
{
if( pluginTabs->tabText(tabi) == pluginName)
{
QWidget* tw= pluginTabs->widget(tabi);
pluginTabs->removeTab( tabi);//the plugin widget will not be deleted !!
//plugin manager will delete it in
//it's unloadPlugin
// qDebug() << " " << "in pp " << (int) tw ;
// delete tw;
pluginManager->unloadPlugin( pluginName );
return;
}
}
}
//==============================================================================
int
PluginsPage::loadBinaryPlugins(const QDir directory)
{/*
//=== find a file with last loaded plugins =====
QStringList lastLoaded;
QFile llFile( directory.absolutePath()+"last_loaded.txt" ) ;
if ( llFile.open(QIODevice::ReadOnly) )
{
QString tmps;
QTextStream stream( &llFile ); // Set the stream to read from myFile
tmps = stream.readLine();
lastLoaded = tmps.split(";");
llFile.close();
}
//=== get current available plugins =====
QStringList currAvailable = directory.entryList(QDir::Files);
#if defined(Q_OS_WIN)
QRegExp trx("*.dll")
#else
QRegExp trx("*.so");
#endif
trx.setPatternSyntax(QRegExp::Wildcard );
currAvailable.filter( trx );
qDebug() << " " << "can load this plugins: " << currAvailable ;
//=== create widgets for all available; also load which were loaded before
foreach(QString pluginFileName, currAvailable)
{
QString tmps( directory.absoluteFilePath( pluginFileName ) );
pluginManagerWidget->addPluginWidget( tmps );
}
*/
}
//==============================================================================
//=============================================================================
//==============================================================================

View File

@ -3,37 +3,77 @@
//#include <QFileDialog>
//#include "chat/PopupChatDialog.h"
#include "mainpage.h"
//#include "ui_PeersDialog.h"
class QGroupBox;
#include <QGroupBox>
#include <QString>
#include <QDir>
//class QGroupBox;
class QVBoxLayout;
class QTabWidget;
class QFrame;
class QLabel;
class QTextEdit;
class QSpacerItem;
class QScriptEngine;
class PluginManagerWidget;
class PluginManager;
class PluginsPage : public MainPage
{
Q_OBJECT
Q_OBJECT
public:
/** Default Constructor */
PluginsPage(QWidget *parent = 0);
PluginsPage(QWidget *parent = 0);
/** Default Destructor */
~PluginsPage() ;
virtual ~PluginsPage() ;
public slots:
void loadDone(QString pluginName, QWidget* pluginWidget);
void loadFailed(QString pluginName, QString errorMessage);
void installComplete(QString pluginName);
void installFailed(QString pluginFileName, QString errorMessage);
void unloadPlugin(QString pluginName);
protected:
QVBoxLayout* pluginPageLayout;
QGroupBox* pluginPanel;
QVBoxLayout* pluginPanelLayout;
QVBoxLayout* pluginPageLayout;
QGroupBox* pluginPanel;
QVBoxLayout* pluginPanelLayout;
QTextEdit* errlogConsole;
QTabWidget* pluginTabs ;
// QPushButton* instPlgButton;
// QHBoxLayout* insPlgLay;
// QSpacerItem* instPlgSpacer;
QScriptEngine* engine;
QTabWidget* pluginTabs ;
QVBoxLayout* pmLay;
QFrame* pmFrame;
QSpacerItem* pmSpacer;
QString errorStrLog;
PluginManagerWidget* pluginManagerWidget;
// QFrame* pluginControlsContainer;
PluginManager* pluginManager;
//QScriptEngine* engine;
int loadBinaryPlugins(const QDir directory);//tring& errorString);
int loadScriptPlugins(const QString directory, QString& errorString);
int loadBinaryPlugin(const QString fileName, QString& errorString);
int loadScriptPlugin(const QString dirName, QString& errorString);
};
#endif