Commit 47939dae authored by Jan Möbius's avatar Jan Möbius

Parallel plugin preload

git-svn-id: http://www.openflipper.org/svnrepo/OpenFlipper/branches/Free@8791 383ad7c9-94d9-4d36-a494-682f7c89f535
parent 6b9c621c
......@@ -812,7 +812,7 @@ private slots:
int toolboxindex_;
/// Function for loading Plugins
void loadPlugin(QString filename, bool silent);
void loadPlugin(QString filename, bool silent, QObject* _plugin = 0 );
/// Load all plugins from default plugin directory and from INI-File
void loadPlugins();
......
......@@ -96,6 +96,50 @@
#include <ACG/QtWidgets/QtFileDialog.hh>
#include "OpenFlipper/widgets/PluginDialog/PluginDialog.hh"
class PreloadThread : public QThread
{
public:
/** \brief Preload thread constructor
*
* This constructor initializes the preloading thread.
* @param _fileName Filename of the Plugin to be loaded.
*/
PreloadThread(QString _fileName):
filename_(_fileName) {
}
public:
/** \brief get an instance of the loaded plugin
*
* This function returns an instance of the loaded plugin or 0 if something went wrong.
* This mehod has to be called from the main thread as the plugins have to stay in the
* core thread of the application.
*/
QObject* getInstance() { return loader_.instance(); }
/** \brief function to get the filename used in this preloader */
QString filename() { return filename_; }
/// If an error occured, this function will return the error message
QString getError() { return loader_.errorString(); }
/** \brief preload function
*
* This function is used in the thread to preload a plugin. The name is given in the constructor.
*/
void run() {
loader_.setFileName( filename_ );
loader_.load();
}
private:
QString filename_;
QPluginLoader loader_;
};
//== IMPLEMENTATION ==========================================================
......@@ -182,16 +226,45 @@ void Core::loadPlugins()
emit log(LOGOUT,"================================================================================");
// Try to load each file as a plugin
QTime time;
time.start();
std::vector< PreloadThread* > loaderThreads;
// Try to load each file as a plugin in a separate thread (only load them in seperate thread. Instance will be created in main thread)
for ( int i = 0 ; i < pluginlist.size() ; ++i) {
// create loader thread
PreloadThread* load = new PreloadThread(pluginlist[i]);
// remember loader thread
loaderThreads.push_back(load);
// start loader thread
load->start();
}
// Check each thread for a valid plugin
for ( uint i = 0 ; i < loaderThreads.size() ; ++i) {
if ( OpenFlipper::Options::gui() && OpenFlipperSettings().value("Core/Gui/splash",true).toBool() ) {
splashMessage_ = tr("Loading Plugin %1/%2").arg(i).arg(pluginlist.size()) ;
splashMessage_ = tr("Loading Plugin %1/%2").arg(i).arg(loaderThreads.size()) ;
splash_->showMessage( splashMessage_ , Qt::AlignBottom | Qt::AlignLeft , Qt::white);
QApplication::processEvents();
}
loadPlugin(pluginlist[i],true);
loaderThreads[i]->wait();
if ( loaderThreads[i]->getInstance() != 0 ) {
loadPlugin(loaderThreads[i]->filename(),true,loaderThreads[i]->getInstance());
} else {
emit log(LOGERR,tr("Unable to load Plugin :\t %1").arg( loaderThreads[i]->filename() ) );
emit log(LOGERR,tr("Error was : ") + loaderThreads[i]->getError() );
emit log(LOGOUT,"================================================================================");
}
delete loaderThreads[i];
}
splashMessage_ = "";
......@@ -330,8 +403,9 @@ void Core::unloadPlugin(QString name){
/** @brief Load a Plugin with given filename
* @param filename complete path + filename of the plugin
* @param silent if 'true': user isn't asked what to do if a plugin is already loaded
* @param _plugin You can provide a preloaded plugin here. If this is 0 the filename will be used to load the plugin.
*/
void Core::loadPlugin(QString filename, bool silent){
void Core::loadPlugin(QString filename, bool silent, QObject* _plugin){
// Only load .dll under windows
if ( OpenFlipper::Options::isWindows() ) {
......@@ -347,883 +421,883 @@ void Core::loadPlugin(QString filename, bool silent){
return;
}
// Try to open the file
QPluginLoader loader( filename );
QObject *plugin = loader.instance();
// This will be the reference to our plugin
QObject *plugin = 0;
// Try to open the file if we did not get a plugin,
// Otherwise use the supplied plugin pointer
if ( _plugin == 0 ) {
QPluginLoader loader( filename );
plugin = loader.instance();
if ( !plugin) {
emit log(LOGERR,tr("Unable to load Plugin :\t %1").arg( filename ) );
emit log(LOGERR,tr("Error was : ") + loader.errorString() );
emit log(LOGOUT,"================================================================================");
}
} else {
plugin = _plugin;
}
// Check if a plugin has been loaded
if (plugin) {
PluginInfo info;
QString supported;
PluginInfo info;
QString supported;
emit log(LOGOUT,tr("Location : \t %2").arg(filename) );
// Check if it is a BasePlugin
BaseInterface* basePlugin = qobject_cast< BaseInterface * >(plugin);
if ( basePlugin ) {
emit log(LOGOUT,tr("Found Plugin : \t %1").arg(basePlugin->name()) );
emit log(LOGOUT,tr("Location : \t %2").arg(filename) );
// Check if it is a BasePlugin
BaseInterface* basePlugin = qobject_cast< BaseInterface * >(plugin);
if ( basePlugin ) {
emit log(LOGOUT,tr("Found Plugin : \t %1").arg(basePlugin->name()) );
emit log(LOGOUT,tr("Location : \t %2").arg(filename) );
if ( OpenFlipper::Options::gui() && OpenFlipperSettings().value("Core/Gui/splash",true).toBool() ) {
splashMessage_ = splashMessage_ + " " + basePlugin->name() ;
splash_->showMessage( splashMessage_ , Qt::AlignBottom | Qt::AlignLeft , Qt::white);
QApplication::processEvents();
}
if ( OpenFlipper::Options::gui() && OpenFlipperSettings().value("Core/Gui/splash",true).toBool() ) {
splashMessage_ = splashMessage_ + " " + basePlugin->name() ;
splash_->showMessage( splashMessage_ , Qt::AlignBottom | Qt::AlignLeft , Qt::white);
QApplication::processEvents();
}
//Check if plugin is already loaded
for (uint k=0; k < plugins.size(); k++){
QString name_nospace = basePlugin->name();
name_nospace.remove(" ");
if (plugins[k].name == name_nospace){
if (silent || OpenFlipper::Options::nogui() ){ //dont load the plugin
emit log(LOGWARN, tr("\t\t\t Already loaded from %1").arg( plugins[k].path) );
emit log(LOGOUT,"================================================================================");
return;
}else{ //ask the user
int ret = QMessageBox::question(coreWidget_,
tr("Plugin already loaded"),
tr("A Plugin with the same name was already loaded from %1.\n"
"You can only load the new plugin if you unload the existing one first.\n\n"
"Do you want to unload the existing plugin first?").arg( plugins[k].path),
QMessageBox::Yes|QMessageBox::No, QMessageBox::No);
if (ret == QMessageBox::Yes)
unloadPlugin(plugins[k].name);
else{
emit log(LOGWARN, tr("\t\t\t Already loaded from %1.").arg( plugins[k].path));
emit log(LOGOUT,"================================================================================");
return;
}
//Check if plugin is already loaded
for (uint k=0; k < plugins.size(); k++){
QString name_nospace = basePlugin->name();
name_nospace.remove(" ");
if (plugins[k].name == name_nospace){
if (silent || OpenFlipper::Options::nogui() ){ //dont load the plugin
emit log(LOGWARN, tr("\t\t\t Already loaded from %1").arg( plugins[k].path) );
emit log(LOGOUT,"================================================================================");
return;
}else{ //ask the user
int ret = QMessageBox::question(coreWidget_,
tr("Plugin already loaded"),
tr("A Plugin with the same name was already loaded from %1.\n"
"You can only load the new plugin if you unload the existing one first.\n\n"
"Do you want to unload the existing plugin first?").arg( plugins[k].path),
QMessageBox::Yes|QMessageBox::No, QMessageBox::No);
if (ret == QMessageBox::Yes)
unloadPlugin(plugins[k].name);
else{
emit log(LOGWARN, tr("\t\t\t Already loaded from %1.").arg( plugins[k].path));
emit log(LOGOUT,"================================================================================");
return;
}
}
}
}
QStringList dontLoadPlugins = OpenFlipperSettings().value("PluginControl/DontLoadNames").toStringList();
if ( dontLoadPlugins.contains(basePlugin->name(), Qt::CaseInsensitive) ) {
emit log(LOGWARN,tr("OpenFlipper.ini prevented Plugin %1 from being loaded! ").arg( basePlugin->name() ));
emit log(LOGOUT,"================================================================================");
return;
}
QStringList dontLoadPlugins = OpenFlipperSettings().value("PluginControl/DontLoadNames").toStringList();
if ( dontLoadPlugins.contains(basePlugin->name(), Qt::CaseInsensitive) ) {
emit log(LOGWARN,tr("OpenFlipper.ini prevented Plugin %1 from being loaded! ").arg( basePlugin->name() ));
emit log(LOGOUT,"================================================================================");
return;
}
//Check if it is a BasePlugin
SecurityInterface * securePlugin = qobject_cast< SecurityInterface * >(plugin);
if ( securePlugin ) {
emit log(LOGINFO,tr("Plugin uses security interface. Trying to authenticate against plugin ..."));
//Check if it is a BasePlugin
SecurityInterface * securePlugin = qobject_cast< SecurityInterface * >(plugin);
if ( securePlugin ) {
emit log(LOGINFO,tr("Plugin uses security interface. Trying to authenticate against plugin ..."));
bool success = false;
QMetaObject::invokeMethod(plugin,"authenticate", Q_RETURN_ARG( bool , success ) ) ;
bool success = false;
QMetaObject::invokeMethod(plugin,"authenticate", Q_RETURN_ARG( bool , success ) ) ;
if ( success )
emit log(LOGINFO,tr("... ok. Loading plugin "));
else {
emit log(LOGERR,tr("... failed. Plugin access denied."));
emit log(LOGOUT,"================================================================================");
return;
}
if ( success )
emit log(LOGINFO,tr("... ok. Loading plugin "));
else {
emit log(LOGERR,tr("... failed. Plugin access denied."));
emit log(LOGOUT,"================================================================================");
return;
}
}
emit log(LOGOUT,tr("Plugin Desciption :\t %1 ").arg( basePlugin->description()) );
supported = "BaseInterface ";
info.name = basePlugin->name();
info.description = basePlugin->description();
info.plugin = plugin;
info.path = filename;
if ( checkSlot(plugin,"version()") )
info.version = basePlugin->version();
else
info.version = QString::number(-1);
emit log(LOGOUT,tr("Plugin Desciption :\t %1 ").arg( basePlugin->description()) );
if ( OpenFlipper::Options::nogui() ) {
supported = "BaseInterface ";
if ( ! checkSlot( plugin , "noguiSupported()" ) ) {
emit log(LOGWARN,tr("Running in nogui mode which is unsupported by this plugin, skipping") );
emit log(LOGOUT,"================================================================================");
return;
}
info.name = basePlugin->name();
info.description = basePlugin->description();
info.plugin = plugin;
info.path = filename;
}
if ( checkSlot(plugin,"version()") )
info.version = basePlugin->version();
else
info.version = QString::number(-1);
if ( OpenFlipper::Options::nogui() ) {
// Check for baseInterface of old style!
if ( checkSignal(plugin,"updated_objects(int)") ) {
log(LOGERR,tr("Plugin Uses old style updated_objects! Convert to updatedObject!"));
if ( ! checkSlot( plugin , "noguiSupported()" ) ) {
emit log(LOGWARN,tr("Running in nogui mode which is unsupported by this plugin, skipping") );
emit log(LOGOUT,"================================================================================");
return;
}
if ( checkSignal(plugin,"update_view()") ) {
log(LOGERR,tr("Plugin Uses old style update_view! Convert to updateView!"));
emit log(LOGOUT,"================================================================================");
return;
}
}
if ( checkSignal(plugin,"updateView()") )
connect(plugin,SIGNAL(updateView()),this,SLOT(updateView()));
// Check for baseInterface of old style!
if ( checkSignal(plugin,"updated_objects(int)") ) {
log(LOGERR,tr("Plugin Uses old style updated_objects! Convert to updatedObject!"));
emit log(LOGOUT,"================================================================================");
return;
}
if ( checkSignal(plugin,"updatedObject(int)") && checkSignal(plugin,"updatedObject(int,const UpdateType)") ){
log(LOGERR,tr("Plugin uses deprecated and(!) new updatedObject. Only new updatedObject will be active."));
connect(plugin,SIGNAL(updatedObject(int,const UpdateType)),this,SLOT(slotObjectUpdated(int,const UpdateType)), Qt::DirectConnection);
} else {
if ( checkSignal(plugin,"update_view()") ) {
log(LOGERR,tr("Plugin Uses old style update_view! Convert to updateView!"));
emit log(LOGOUT,"================================================================================");
return;
}
if ( checkSignal(plugin,"updatedObject(int)") ){
log(LOGWARN,tr("Plugin uses deprecated updatedObject."));
connect(plugin,SIGNAL(updatedObject(int)),this,SLOT(slotObjectUpdated(int)), Qt::DirectConnection);
}
if ( checkSignal(plugin,"updateView()") )
connect(plugin,SIGNAL(updateView()),this,SLOT(updateView()));
if ( checkSignal(plugin,"updatedObject(int,const UpdateType)") )
connect(plugin,SIGNAL(updatedObject(int,const UpdateType)),this,SLOT(slotObjectUpdated(int,const UpdateType)), Qt::DirectConnection);
}
if ( checkSlot( plugin , "slotObjectUpdated(int)" ) && checkSlot( plugin , "slotObjectUpdated(int,const UpdateType)" ) ){
log(LOGERR,tr("Plugin uses deprecated and(!) new slotObjectUpdated. Only new slotObjectUpdated will be active."));
connect(this,SIGNAL(signalObjectUpdated(int)),plugin,SLOT(slotObjectUpdated(int)), Qt::DirectConnection);
if ( checkSignal(plugin,"updatedObject(int)") && checkSignal(plugin,"updatedObject(int,const UpdateType)") ){
} else {
if ( checkSlot( plugin , "slotObjectUpdated(int)" ) ){
log(LOGWARN,tr("Plugin uses deprecated slotObjectUpdated."));
connect(this,SIGNAL(signalObjectUpdated(int)),plugin,SLOT(slotObjectUpdated(int)), Qt::DirectConnection);
}
if ( checkSlot( plugin , "slotObjectUpdated(int,const UpdateType)" ) )
connect(this,SIGNAL(signalObjectUpdated(int,const UpdateType)),plugin,SLOT(slotObjectUpdated(int,const UpdateType)), Qt::DirectConnection);
}
log(LOGERR,tr("Plugin uses deprecated and(!) new updatedObject. Only new updatedObject will be active."));
connect(plugin,SIGNAL(updatedObject(int,const UpdateType)),this,SLOT(slotObjectUpdated(int,const UpdateType)), Qt::DirectConnection);
} else {
if ( checkSignal(plugin,"objectPropertiesChanged(int)")) {
emit log (LOGERR,tr("Signal objectPropertiesChanged(int) is deprecated. " ));
emit log (LOGERR,tr("The signal will be automatically emitted by the object that has been changed and the core will deliver it to the plugins!. "));
emit log (LOGERR,tr("Please remove this signal from your plugins!. "));
// connect(plugin,SIGNAL(objectPropertiesChanged(int)),this,SLOT(slotObjectPropertiesChanged(int)), Qt::DirectConnection);
if ( checkSignal(plugin,"updatedObject(int)") ){
log(LOGWARN,tr("Plugin uses deprecated updatedObject."));
connect(plugin,SIGNAL(updatedObject(int)),this,SLOT(slotObjectUpdated(int)), Qt::DirectConnection);
}
if ( checkSlot( plugin , "slotViewChanged()" ) )
connect(this,SIGNAL(pluginViewChanged()),plugin,SLOT(slotViewChanged()), Qt::DirectConnection);
if ( checkSlot(plugin,"slotObjectPropertiesChanged(int)"))
connect(this,SIGNAL(objectPropertiesChanged(int)),plugin,SLOT(slotObjectPropertiesChanged(int)), Qt::DirectConnection);
if ( checkSignal(plugin,"updatedObject(int,const UpdateType)") )
connect(plugin,SIGNAL(updatedObject(int,const UpdateType)),this,SLOT(slotObjectUpdated(int,const UpdateType)), Qt::DirectConnection);
}
if ( checkSignal(plugin,"visibilityChanged()" ) )
emit log (LOGERR,tr("Signal visibilityChanged() now requires objectid or -1 as argument " ));
if ( checkSlot( plugin , "slotObjectUpdated(int)" ) && checkSlot( plugin , "slotObjectUpdated(int,const UpdateType)" ) ){
log(LOGERR,tr("Plugin uses deprecated and(!) new slotObjectUpdated. Only new slotObjectUpdated will be active."));
connect(this,SIGNAL(signalObjectUpdated(int)),plugin,SLOT(slotObjectUpdated(int)), Qt::DirectConnection);
} else {
if ( checkSignal(plugin,"visibilityChanged(int)") ) {
emit log (LOGERR,tr("Signal visibilityChanged(int) is deprecated! " ));
emit log (LOGERR,tr("If an object changes its visibility, it will call the required functions automatically." ));
emit log (LOGERR,tr("If you change a scenegraph node, call nodeVisibilityChanged(int). See docu of this function for details." ));
if ( checkSlot( plugin , "slotObjectUpdated(int)" ) ){
log(LOGWARN,tr("Plugin uses deprecated slotObjectUpdated."));
connect(this,SIGNAL(signalObjectUpdated(int)),plugin,SLOT(slotObjectUpdated(int)), Qt::DirectConnection);
}
if ( checkSignal(plugin,"nodeVisibilityChanged(int)") )
connect(plugin,SIGNAL(nodeVisibilityChanged(int)),this,SLOT(slotVisibilityChanged(int)), Qt::DirectConnection);
if ( checkSlot(plugin,"slotVisibilityChanged(int)") )
connect(this,SIGNAL(visibilityChanged(int)),plugin,SLOT(slotVisibilityChanged(int)), Qt::DirectConnection);
if ( checkSlot( plugin , "slotObjectUpdated(int,const UpdateType)" ) )
connect(this,SIGNAL(signalObjectUpdated(int,const UpdateType)),plugin,SLOT(slotObjectUpdated(int,const UpdateType)), Qt::DirectConnection);
}
if ( checkSignal(plugin,"objectPropertiesChanged(int)")) {
emit log (LOGERR,tr("Signal objectPropertiesChanged(int) is deprecated. " ));
emit log (LOGERR,tr("The signal will be automatically emitted by the object that has been changed and the core will deliver it to the plugins!. "));
emit log (LOGERR,tr("Please remove this signal from your plugins!. "));
}
if ( checkSlot( plugin , "slotViewChanged()" ) )
connect(this,SIGNAL(pluginViewChanged()),plugin,SLOT(slotViewChanged()), Qt::DirectConnection);
if ( checkSignal(plugin,"activeObjectChanged()" ) )
emit log (LOGERR,tr("Signal activeObjectChanged() is now objectSelectionChanged( int _objectId ) ") );
if ( checkSlot(plugin,"slotObjectPropertiesChanged(int)"))
connect(this,SIGNAL(objectPropertiesChanged(int)),plugin,SLOT(slotObjectPropertiesChanged(int)), Qt::DirectConnection);
if ( checkSlot(plugin,"slotActiveObjectChanged()" ) )
emit log (LOGERR,tr("Slot slotActiveObjectChanged() is now slotObjectSelectionChanged( int _objectId ) ") );
if ( checkSignal(plugin,"visibilityChanged()" ) )
emit log (LOGERR,tr("Signal visibilityChanged() now requires objectid or -1 as argument " ));
if ( checkSlot(plugin,"slotAllCleared()") )
connect(this,SIGNAL(allCleared()),plugin,SLOT(slotAllCleared()));
if ( checkSignal(plugin,"visibilityChanged(int)") ) {
emit log (LOGERR,tr("Signal visibilityChanged(int) is deprecated! " ));
emit log (LOGERR,tr("If an object changes its visibility, it will call the required functions automatically." ));
emit log (LOGERR,tr("If you change a scenegraph node, call nodeVisibilityChanged(int). See docu of this function for details." ));
}
if ( checkSignal(plugin,"nodeVisibilityChanged(int)") )
connect(plugin,SIGNAL(nodeVisibilityChanged(int)),this,SLOT(slotVisibilityChanged(int)), Qt::DirectConnection);
if ( checkSlot(plugin,"slotVisibilityChanged(int)") )
connect(this,SIGNAL(visibilityChanged(int)),plugin,SLOT(slotVisibilityChanged(int)), Qt::DirectConnection);
if ( checkSignal(plugin,"objectSelectionChanged(int)") ) {
emit log (LOGERR,tr("Signal objectSelectionChanged(in) is deprecated!") );
emit log (LOGERR,tr("If the selection for an object is changed, the core will emit the required signals itself!") );
}
if ( checkSignal(plugin,"activeObjectChanged()" ) )
emit log (LOGERR,tr("Signal activeObjectChanged() is now objectSelectionChanged( int _objectId ) ") );
if ( checkSlot( plugin , "slotObjectSelectionChanged(int)" ) )
connect(this,SIGNAL(objectSelectionChanged(int)),plugin,SLOT(slotObjectSelectionChanged(int) ), Qt::DirectConnection);
if ( checkSlot(plugin,"slotActiveObjectChanged()" ) )
emit log (LOGERR,tr("Slot slotActiveObjectChanged() is now slotObjectSelectionChanged( int _objectId ) ") );
if ( checkSlot(plugin,"slotAllCleared()") )
connect(this,SIGNAL(allCleared()),plugin,SLOT(slotAllCleared()));
if ( checkSlot( plugin , "pluginsInitialized()" ) )
connect(this,SIGNAL(pluginsInitialized()),plugin,SLOT(pluginsInitialized()), Qt::DirectConnection);
if ( checkSignal(plugin,"setSlotDescription(QString,QString,QStringList,QStringList)") )
connect(plugin, SIGNAL(setSlotDescription(QString,QString,QStringList,QStringList)),
this, SLOT(slotSetSlotDescription(QString,QString,QStringList,QStringList)) );
if ( checkSignal(plugin,"objectSelectionChanged(int)") ) {
emit log (LOGERR,tr("Signal objectSelectionChanged(in) is deprecated!") );
emit log (LOGERR,tr("If the selection for an object is changed, the core will emit the required signals itself!") );
}
//Check if the plugin supports Logging
LoggingInterface* logPlugin = qobject_cast< LoggingInterface * >(plugin);
if ( logPlugin ) {
supported = supported + "Logging ";
if ( checkSlot( plugin , "slotObjectSelectionChanged(int)" ) )
connect(this,SIGNAL(objectSelectionChanged(int)),plugin,SLOT(slotObjectSelectionChanged(int) ), Qt::DirectConnection);
// Create intermediate logger class which will mangle the output
PluginLogger* newlog = new PluginLogger(info.name);
loggers_.push_back(newlog);
connect(plugin,SIGNAL(log(Logtype, QString )),newlog,SLOT(slotLog(Logtype, QString )),Qt::DirectConnection);
connect(plugin,SIGNAL(log(QString )),newlog,SLOT(slotLog(QString )),Qt::DirectConnection);
// Connect it to the core widget logger
if ( OpenFlipper::Options::gui() )
connect(newlog,SIGNAL(log(Logtype, QString )),coreWidget_,SLOT(slotLog(Logtype, QString )),Qt::DirectConnection);
if ( checkSlot( plugin , "pluginsInitialized()" ) )
connect(this,SIGNAL(pluginsInitialized()),plugin,SLOT(pluginsInitialized()), Qt::DirectConnection);
// connection to console logger
connect(newlog,SIGNAL(log(Logtype, QString )),this,SLOT(slotLog(Logtype, QString )),Qt::DirectConnection);
if ( checkSignal(plugin,"setSlotDescription(QString,QString,QStringList,QStringList)") )
connect(plugin, SIGNAL(setSlotDescription(QString,QString,QStringList,QStringList)),
this, SLOT(slotSetSlotDescription(QString,QString,QStringList,QStringList)) );
}
// connection to file logger
connect(newlog,SIGNAL(log(Logtype, QString )),this,SLOT(slotLogToFile(Logtype, QString )),Qt::DirectConnection);
//Check if the plugin supports Logging
LoggingInterface* logPlugin = qobject_cast< LoggingInterface * >(plugin);
if ( logPlugin ) {
supported = supported + "Logging ";
// connection to external plugin logger
if ( checkSlot(plugin,"logOutput(Logtype,QString)") )
connect(this,SIGNAL(externalLog(Logtype,QString)), plugin, SLOT(logOutput(Logtype,QString)) ) ;
}
// Create intermediate logger class which will mangle the output
PluginLogger* newlog = new PluginLogger(info.name);
loggers_.push_back(newlog);
connect(plugin,SIGNAL(log(Logtype, QString )),newlog,SLOT(slotLog(Logtype, QString )),Qt::DirectConnection);
connect(plugin,SIGNAL(log(QString )),newlog,SLOT(slotLog(QString )),Qt::DirectConnection);
//Check if the plugin supports Menubar-Interface
MenuInterface* menubarPlugin = qobject_cast< MenuInterface * >(plugin);
if ( menubarPlugin && OpenFlipper::Options::gui() ) {
supported = supported + "Menubar ";
if ( checkSignal(plugin,"addMenubarAction(QAction*,QString)") )
connect(plugin , SIGNAL(addMenubarAction(QAction*,QString)),
coreWidget_ , SLOT(slotAddMenubarAction(QAction*,QString)),Qt::DirectConnection);
if ( checkSignal(plugin,"getMenubarMenu (QString,QMenu*&,bool)") )
connect(plugin , SIGNAL(getMenubarMenu (QString,QMenu*&,bool)),
coreWidget_ , SLOT(slotGetMenubarMenu (QString,QMenu*&,bool)),Qt::DirectConnection);
}
// Connect it to the core widget logger
if ( OpenFlipper::Options::gui() )
connect(newlog,SIGNAL(log(Logtype, QString )),coreWidget_,SLOT(slotLog(Logtype, QString )),Qt::DirectConnection);
//Check if the plugin supports ContextMenuInterface
ContextMenuInterface* contextMenuPlugin = qobject_cast< ContextMenuInterface * >(plugin);
if ( contextMenuPlugin && OpenFlipper::Options::gui() ) {
supported = supported + "ContextMenu ";
// connection to console logger
connect(newlog,SIGNAL(log(Logtype, QString )),this,SLOT(slotLog(Logtype, QString )),Qt::DirectConnection);
if ( checkSignal(plugin,"addContextMenuItem(QAction*,ContextMenuType)") )
connect(plugin , SIGNAL(addContextMenuItem(QAction*,ContextMenuType)),
coreWidget_ , SLOT(slotAddContextItem(QAction*,ContextMenuType)),Qt::DirectConnection);
// connection to file logger
connect(newlog,SIGNAL(log(Logtype, QString )),this,SLOT(slotLogToFile(Logtype, QString )),Qt::DirectConnection);
if ( checkSignal(plugin,"addContextMenuItem(QAction*,DataType,ContextMenuType)") )
connect(plugin , SIGNAL(addContextMenuItem(QAction*,DataType,ContextMenuType)),
coreWidget_ , SLOT(slotAddContextItem(QAction*,DataType,ContextMenuType)),Qt::DirectConnection);
// connection to external plugin logger
if ( checkSlot(plugin,"logOutput(Logtype,QString)") )
connect(this,SIGNAL(externalLog(Logtype,QString)), plugin, SLOT(logOutput(Logtype,QString)) ) ;
}
if ( checkSlot(plugin,"slotUpdateContextMenu(int)") )
connect(coreWidget_ , SIGNAL(updateContextMenu(int)),
plugin , SLOT(slotUpdateContextMenu(int)),Qt::DirectConnection);
//Check if the plugin supports Menubar-Interface
MenuInterface* menubarPlugin = qobject_cast< MenuInterface * >(plugin);
if ( menubarPlugin && OpenFlipper::Options::gui() ) {
supported = supported + "Menubar ";
if ( checkSignal(plugin,"addMenubarAction(QAction*,QString)") )
connect(plugin , SIGNAL(addMenubarAction(QAction*,QString)),
coreWidget_ , SLOT(slotAddMenubarAction(QAction*,QString)),Qt::DirectConnection);
if ( checkSignal(plugin,"getMenubarMenu (QString,QMenu*&,bool)") )
connect(plugin , SIGNAL(getMenubarMenu (QString,QMenu*&,bool)),
coreWidget_ , SLOT(slotGetMenubarMenu (QString,QMenu*&,bool)),Qt::DirectConnection);
}
if ( checkSlot(plugin,"slotUpdateContextMenuNode(int)") )
connect(coreWidget_ , SIGNAL(updateContextMenuNode(int)),
plugin , SLOT(slotUpdateContextMenuNode(int)),Qt::DirectConnection);
//Check if the plugin supports ContextMenuInterface
ContextMenuInterface* contextMenuPlugin = qobject_cast< ContextMenuInterface * >(plugin);
if ( contextMenuPlugin && OpenFlipper::Options::gui() ) {
supported = supported + "ContextMenu ";
if ( checkSlot(plugin,"slotUpdateContextMenuBackground()") )
connect(coreWidget_ , SIGNAL(updateContextMenuBackground()),
plugin , SLOT(slotUpdateContextMenuBackground()),Qt::DirectConnection);
}
if ( checkSignal(plugin,"addContextMenuItem(QAction*,ContextMenuType)") )
connect(plugin , SIGNAL(addContextMenuItem(QAction*,ContextMenuType)),
coreWidget_ , SLOT(slotAddContextItem(QAction*,ContextMenuType)),Qt::DirectConnection);
//Check if the plugin supports Toolbox-Interface
ToolboxInterface* toolboxPlugin = qobject_cast< ToolboxInterface * >(plugin);
if ( toolboxPlugin && OpenFlipper::Options::gui() ) {
supported = supported + "Toolbox ";
if ( checkSignal(plugin,"addContextMenuItem(QAction*,DataType,ContextMenuType)") )
connect(plugin , SIGNAL(addContextMenuItem(QAction*,DataType,ContextMenuType)),
coreWidget_ , SLOT(slotAddContextItem(QAction*,DataType,ContextMenuType)),Qt::DirectConnection);
if ( checkSlot(plugin,"slotUpdateContextMenu(int)") )
connect(coreWidget_ , SIGNAL(updateContextMenu(int)),
plugin , SLOT(slotUpdateContextMenu(int)),Qt::DirectConnection);
if ( checkSignal(plugin, "addToolbox(QString,QWidget*)"))
connect(plugin, SIGNAL( addToolbox(QString,QWidget*) ),
this, SLOT( addToolbox(QString,QWidget*) ),Qt::DirectConnection );
if ( checkSlot(plugin,"slotUpdateContextMenuNode(int)") )
connect(coreWidget_ , SIGNAL(updateContextMenuNode(int)),
plugin , SLOT(slotUpdateContextMenuNode(int)),Qt::DirectConnection);
if ( checkSlot(plugin,"slotUpdateContextMenuBackground()") )
connect(coreWidget_ , SIGNAL(updateContextMenuBackground()),
plugin , SLOT(slotUpdateContextMenuBackground()),Qt::DirectConnection);
}
//Check if the plugin supports Toolbox-Interface
ToolboxInterface* toolboxPlugin = qobject_cast< ToolboxInterface * >(plugin);
if ( toolboxPlugin && OpenFlipper::Options::gui() ) {
supported = supported + "Toolbox ";
}
//Check if the plugin supports ViewMode-Interface
ViewModeInterface* viewModePlugin = qobject_cast< ViewModeInterface * >(plugin);
if ( viewModePlugin && OpenFlipper::Options::gui() ) {
supported = supported + "ViewMode ";
if ( checkSignal(plugin, "defineViewModeToolboxes(QString,QStringList)"))
connect(plugin, SIGNAL( defineViewModeToolboxes(QString, QStringList) ),
coreWidget_, SLOT( slotAddViewModeToolboxes(QString, QStringList) ),Qt::DirectConnection );
if ( checkSignal(plugin, "defineViewModeToolbars(QString,QStringList)"))
connect(plugin, SIGNAL( defineViewModeToolbars(QString, QStringList) ),
coreWidget_, SLOT( slotAddViewModeToolbars(QString, QStringList) ),Qt::DirectConnection );