PluginLoader.cc

00001 /*===========================================================================*\
00002  *                                                                           *
00003  *                              OpenFlipper                                  *
00004  *      Copyright (C) 2001-2009 by Computer Graphics Group, RWTH Aachen      *
00005  *                           www.openflipper.org                             *
00006  *                                                                           *
00007  *---------------------------------------------------------------------------*
00008  *  This file is part of OpenFlipper.                                        *
00009  *                                                                           *
00010  *  OpenFlipper is free software: you can redistribute it and/or modify      *
00011  *  it under the terms of the GNU Lesser General Public License as           *
00012  *  published by the Free Software Foundation, either version 3 of           *
00013  *  the License, or (at your option) any later version with the              *
00014  *  following exceptions:                                                    *
00015  *                                                                           *
00016  *  If other files instantiate templates or use macros                       *
00017  *  or inline functions from this file, or you compile this file and         *
00018  *  link it with other files to produce an executable, this file does        *
00019  *  not by itself cause the resulting executable to be covered by the        *
00020  *  GNU Lesser General Public License. This exception does not however       *
00021  *  invalidate any other reasons why the executable file might be            *
00022  *  covered by the GNU Lesser General Public License.                        *
00023  *                                                                           *
00024  *  OpenFlipper is distributed in the hope that it will be useful,           *
00025  *  but WITHOUT ANY WARRANTY; without even the implied warranty of           *
00026  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the            *
00027  *  GNU Lesser General Public License for more details.                      *
00028  *                                                                           *
00029  *  You should have received a copy of the GNU LesserGeneral Public          *
00030  *  License along with OpenFlipper. If not,                                  *
00031  *  see <http://www.gnu.org/licenses/>.                                      *
00032  *                                                                           *
00033 \*===========================================================================*/
00034 
00035 /*===========================================================================*\
00036  *                                                                           *
00037  *   $Revision: 7305 $                                                         *
00038  *   $Author: moebius $                                                      *
00039  *   $Date: 2009-10-02 13:08:12 +0200 (Fr, 02. Okt 2009) $                   *
00040  *                                                                           *
00041 \*===========================================================================*/
00042 
00043 
00044 
00045 
00046 //=============================================================================
00047 //
00048 //  CLASS Core - IMPLEMENTATION of the Plugin Loading
00049 //
00050 //=============================================================================
00051 
00052 
00053 //== INCLUDES =================================================================
00054 
00055 // -------------------- mview
00056 #include "Core.hh"
00057 
00058 #include <QMenuBar>
00059 #include <QToolBox>
00060 #include <QMessageBox>
00061 #include <QApplication>
00062 #include <QScrollArea>
00063 
00064 #include <QPluginLoader>
00065 #include "OpenFlipper/BasePlugin/BaseInterface.hh"
00066 #include "OpenFlipper/BasePlugin/KeyInterface.hh"
00067 #include "OpenFlipper/BasePlugin/BackupInterface.hh"
00068 #include "OpenFlipper/BasePlugin/LoggingInterface.hh"
00069 #include "OpenFlipper/BasePlugin/MouseInterface.hh"
00070 #include "OpenFlipper/BasePlugin/PickingInterface.hh"
00071 #include "OpenFlipper/BasePlugin/ToolboxInterface.hh"
00072 #include "OpenFlipper/BasePlugin/OptionsInterface.hh"
00073 #include "OpenFlipper/BasePlugin/ToolbarInterface.hh"
00074 #include "OpenFlipper/BasePlugin/TextureInterface.hh"
00075 #include "OpenFlipper/BasePlugin/MenuInterface.hh"
00076 #include "OpenFlipper/BasePlugin/ContextMenuInterface.hh"
00077 #include "OpenFlipper/BasePlugin/ProcessInterface.hh"
00078 #include "OpenFlipper/BasePlugin/ViewInterface.hh"
00079 #include "OpenFlipper/BasePlugin/ViewModeInterface.hh"
00080 #include "OpenFlipper/BasePlugin/LoadSaveInterface.hh"
00081 #include "OpenFlipper/BasePlugin/StatusbarInterface.hh"
00082 #include "OpenFlipper/BasePlugin/INIInterface.hh"
00083 #include "OpenFlipper/BasePlugin/FileInterface.hh"
00084 #include "OpenFlipper/BasePlugin/RPCInterface.hh"
00085 #include "OpenFlipper/BasePlugin/ScriptInterface.hh"
00086 #include "OpenFlipper/BasePlugin/SecurityInterface.hh"
00087 
00088 #include "OpenFlipper/INIFile/INIFile.hh"
00089 
00090 #include "OpenFlipper/common/GlobalOptions.hh"
00091 
00092 #include <QMessageBox>
00093 #include <QtScript/QScriptValueIterator>
00094 
00095 #include <ACG/QtWidgets/QtFileDialog.hh>
00096 #include "OpenFlipper/widgets/PluginDialog/PluginDialog.hh"
00097 
00098 //== IMPLEMENTATION ==========================================================
00099 
00100 
00101 bool Core::checkSlot(QObject* _plugin , const char* _slotSignature) {
00102   const QMetaObject* meta = _plugin->metaObject();
00103   int id = meta->indexOfSlot( QMetaObject::normalizedSignature( _slotSignature ) );
00104   return ( id != -1 );
00105 }
00106 
00107 bool Core::checkSignal(QObject* _plugin , const char* _signalSignature) {
00108   const QMetaObject* meta = _plugin->metaObject();
00109   int id = meta->indexOfSignal( QMetaObject::normalizedSignature( _signalSignature ) );
00110   return ( id != -1 );
00111 }
00112 
00115 void Core::loadPlugins()
00116 {
00117   //try to load plugins from new location
00118   QDir tempDir = QDir(OpenFlipper::Options::pluginDir());
00119 
00120   QStringList filters;
00121 
00122 
00123   filters << "*.dll";
00124   filters << "*.dylib";
00125   filters << "*.so";
00126 
00127 
00128   // Get all files in the Plugin dir
00129   QStringList pluginlist = tempDir.entryList(filters,QDir::Files);
00130 
00131   for (int i=0; i < pluginlist.size(); i++)
00132      pluginlist[i] = tempDir.absoluteFilePath(pluginlist[i]);
00133 
00134   // Get all config files to be used
00135   QStringList configFiles = OpenFlipper::Options::optionFiles();
00136 
00137   QStringList iniPlugins;
00138   for ( int fileCount = 0 ; fileCount < (int)configFiles.size() ; ++fileCount) {
00139     INIFile ini;
00140 
00141     if (  ini.connect(configFiles[fileCount],false) ) {
00142 
00143       // get all Plugin Names which will not be loaded
00144       QString dontLoadString;
00145       if (ini.get_entry( dontLoadString,"Plugins","DontLoad" ) ) {
00146         dontLoadPlugins_ = dontLoadPlugins_ + dontLoadString.split(";",QString::SkipEmptyParts);
00147       }
00148 
00149       std::vector< QString > loadKeys;
00150 
00151       if ( OpenFlipper::Options::is64bit() )
00152         loadKeys.push_back("Load64");
00153 
00154       if ( OpenFlipper::Options::is32bit() )
00155         loadKeys.push_back("Load32");
00156 
00157       loadKeys.push_back("Load");
00158 
00159       for ( uint keyit = 0 ; keyit < loadKeys.size() ; ++ keyit) {
00160         //Load additional Plugins given by ini file
00161         std::vector< QString > additionalPlugins;
00162         if (ini.get_entry( additionalPlugins,"Plugins",loadKeys[keyit] ) ) {
00163           for ( uint i = 0 ; i < additionalPlugins.size(); ++i) {
00164             iniPlugins << additionalPlugins[i];
00165               emit log(LOGOUT,tr("Additional Plugin from ini file: %1").arg( additionalPlugins[i] ) );
00166           }
00167         }
00168       }
00169 
00170       ini.disconnect();
00171 
00172    } else
00173       emit log(LOGWARN,tr("Failed to connect to ProgramOptions.ini file: %1").arg( configFiles[fileCount]) );
00174   }
00175 
00176   pluginlist = iniPlugins << pluginlist;
00177 
00178 
00179   // Sort plugins to load FilePlugins first
00180   QStringList filePlugins;
00181   QStringList textureControl;
00182   QStringList otherPlugins;
00183   //plugin Liste sortieren
00184   for (int i=0; i < pluginlist.size(); i++)
00185     if (pluginlist[i].contains("Plugin-File") )
00186       filePlugins.push_back(pluginlist[i]);
00187     else if (pluginlist[i].contains("TextureControl"))
00188       textureControl.push_back(pluginlist[i]);
00189     else
00190       otherPlugins.push_back(pluginlist[i]);
00191 
00192   pluginlist = filePlugins << textureControl << otherPlugins;
00193 
00194   // Remove Whitespace from beginning and end of Plugin Names
00195   for ( int i = 0 ; i < dontLoadPlugins_.size() ; ++i )
00196     dontLoadPlugins_[i] = dontLoadPlugins_[i].trimmed();
00197 
00198   for ( int i = 0 ; i < dontLoadPlugins_.size(); ++i )
00199     emit log(LOGWARN,tr("Skipping Plugins :\t %1").arg( dontLoadPlugins_[i] ) );
00200 
00201   emit log(LOGOUT,"=============================================================================================");
00202 
00203 
00204   // Try to load each file as a plugin
00205   for ( int i = 0 ; i < pluginlist.size() ; ++i) {
00206 
00207     if ( OpenFlipper::Options::gui() && OpenFlipper::Options::splash() ) {
00208       splashMessage_ = tr("Loading Plugin %1/%2").arg(i).arg(pluginlist.size()) ;
00209       splash_->showMessage( splashMessage_ , Qt::AlignBottom | Qt::AlignLeft , Qt::white);
00210       QApplication::processEvents();
00211     }
00212 
00213     loadPlugin(pluginlist[i],true);
00214   }
00215 
00216   splashMessage_ = "";
00217 
00218   emit pluginsInitialized();
00219 
00220   emit log(LOGOUT,tr("Loaded %n Plugin(s)","",plugins.size()) );
00221 }
00222 
00225 void Core::slotLoadPlugin(){
00226 
00227   if ( OpenFlipper::Options::nogui() )
00228     return;
00229 
00230 
00231   QString filter;
00232   if ( OpenFlipper::Options::isWindows() )
00233     filter = "Plugins (*.dll)";
00234   else if ( OpenFlipper::Options::isDarwin() )
00235     filter = "Plugins (*.dylib)";
00236   else
00237     filter = "Plugins (*.so)";
00238 
00239 
00240   QString filename = ACG::getOpenFileName(coreWidget_,tr("Load Plugin"),filter,OpenFlipper::Options::currentDirStr());
00241 
00242   if (filename.isEmpty())
00243     return;
00244 
00245   // get the plugin name
00246   // and check if Plugin is in the dontLoad List
00247 
00248   QPluginLoader loader( filename );
00249   QObject *plugin = loader.instance();
00250   QString name;
00251 
00252   // Check if a plugin has been loaded
00253   if (plugin) {
00254     // Check if it is a BasePlugin
00255     BaseInterface* basePlugin = qobject_cast< BaseInterface * >(plugin);
00256     if ( basePlugin ) {
00257       name = basePlugin->name();
00258     }else
00259       return;
00260   }else
00261     return;
00262 
00263   if (dontLoadPlugins_.contains(name)){
00264       int ret = QMessageBox::question(0, tr("Plugin Loading Prevention"),
00265                    tr("OpenFlipper is currently configured to prevent loading this plugin.\n"
00266                       "Do you want to enable this plugin?"),
00267                    QMessageBox::Yes | QMessageBox::No,
00268                    QMessageBox::Yes);
00269       if (ret == QMessageBox::Yes)
00270         dontLoadPlugins_.removeAll(name);
00271       else
00272         return;
00273   }
00274   loadPlugin(filename,false);
00275 }
00276 
00279 void Core::slotShowPlugins(){
00280 
00281   if ( OpenFlipper::Options::gui() ){
00282 
00283     int ret = 0;
00284 
00285     while (ret == 0){
00286 
00287       PluginDialog* dialog = new PluginDialog(plugins, coreWidget_);
00288 
00289       //connect signals
00290       connect(dialog, SIGNAL(unloadPlugin(QString)), this, SLOT(unloadPlugin(QString)));
00291       connect(dialog, SIGNAL(dontLoadPlugins(QStringList)), this, SLOT(dontLoadPlugins(QStringList)));
00292       connect(dialog, SIGNAL( loadPlugin() ), this, SLOT( slotLoadPlugin() ));
00293 
00294       //if a plugin was deleted/loaded the dialog returns 0 and it needs to be loaded again
00295       ret = dialog->exec();
00296 
00297       delete dialog;
00298     }
00299   }
00300 }
00301 
00305 void Core::unloadPlugin(QString name){
00306   for (uint i=0; i < plugins.size(); i++)
00307     if (plugins[i].rpcName == name){
00308       if ( checkSlot( plugins[i].plugin , "exit()" ) )
00309         QMetaObject::invokeMethod(plugins[i].plugin, "exit",  Qt::DirectConnection);
00310 
00311       //remove toolbox widget
00312       QString name_nospace = name;
00313       name_nospace.remove(" ");
00314       if ( coreWidget_->viewModes_[0]->visibleToolboxes.contains(name_nospace) )
00315         coreWidget_->viewModes_[0]->visibleToolboxes.removeAt(coreWidget_->viewModes_[0]->visibleToolboxes.indexOf(name_nospace));
00316       for ( uint j = 0 ; j < plugins[i].toolboxWidgets.size() ; ++j )
00317         if (plugins[i].toolboxWidgets[j].second ){
00318           plugins[i].toolboxWidgets[j].second->setVisible(false);
00319           delete plugins[i].toolboxWidgets[j].second;
00320         }
00321 
00322       plugins.erase(plugins.begin() + i);
00323 
00324       emit log(LOGOUT,tr("Unloaded Plugin :\t\t %1").arg( name) );
00325 
00326       return;
00327     }
00328 
00329     log(LOGERR, tr("Unable to unload plugin '%1' (plugin wasn't found)").arg(name));
00330 }
00331 
00335 void Core::dontLoadPlugins(QStringList _plugins){
00336   for (int i=0; i < _plugins.size(); i++)
00337     dontLoadPlugins_ << _plugins[i];
00338 }
00339 
00344 void Core::loadPlugin(QString filename, bool silent){
00345 
00346   // Only load .dll under windows
00347   if ( OpenFlipper::Options::isWindows() ) {
00348     QString dllname = filename;
00349     if ( ! dllname.endsWith( ".dll" ) )
00350       return;
00351   }
00352 
00353   // Only load .so under linux
00354   if ( OpenFlipper::Options::isLinux() ) {
00355     QString soname = filename;
00356     if ( ! soname.endsWith( ".so" ) )
00357       return;
00358   }
00359 
00360   // Try to open the file
00361   QPluginLoader loader( filename );
00362   QObject *plugin = loader.instance();
00363 
00364   // Check if a plugin has been loaded
00365   if (plugin) {
00366     PluginInfo info;
00367     QString supported;
00368 
00369     // Check if it is a BasePlugin
00370     BaseInterface* basePlugin = qobject_cast< BaseInterface * >(plugin);
00371     if ( basePlugin ) {
00372       emit log(LOGOUT,tr("Found Plugin :\t\t %1 at %2.").arg(basePlugin->name()).arg( filename));
00373 
00374       if ( OpenFlipper::Options::gui() && OpenFlipper::Options::splash() ) {
00375         splashMessage_ = splashMessage_ + " " + basePlugin->name() ;
00376         splash_->showMessage( splashMessage_ , Qt::AlignBottom | Qt::AlignLeft , Qt::white);
00377         QApplication::processEvents();
00378       }
00379 
00380       //Check if plugin is already loaded
00381       for (uint k=0; k < plugins.size(); k++){
00382 
00383           QString name_nospace =  basePlugin->name();
00384           name_nospace.remove(" ");
00385 
00386           if (plugins[k].name == name_nospace){
00387             if (silent || OpenFlipper::Options::nogui() ){ //dont load the plugin
00388               emit log(LOGWARN, tr("\t\t\t Already loaded from %1").arg( plugins[k].path) );
00389               emit log(LOGOUT,"=============================================================================================");
00390               return;
00391           }else{ //ask the user
00392             int ret = QMessageBox::question(coreWidget_,
00393                                             tr("Plugin already loaded"),
00394                                             tr("A Plugin with the same name was already loaded from %1.\n" 
00395                                                "You can only load the new plugin if you unload the existing one first.\n\n"
00396                                                "Do you want to unload the existing plugin first?").arg( plugins[k].path),
00397                                             QMessageBox::Yes|QMessageBox::No, QMessageBox::No);
00398             if (ret == QMessageBox::Yes)
00399               unloadPlugin(plugins[k].name);
00400             else{
00401               emit log(LOGWARN, tr("\t\t\t Already loaded from %1.").arg( plugins[k].path));
00402               emit log(LOGOUT,"=============================================================================================");
00403               return;
00404             }
00405           }
00406         }
00407       }
00408 
00409       if ( dontLoadPlugins_.contains(basePlugin->name(), Qt::CaseInsensitive) ) {
00410         emit log(LOGWARN,tr("OpenFlipper.ini prevented Plugin %1 from being loaded! ").arg( basePlugin->name() ));
00411         emit log(LOGOUT,"=============================================================================================");
00412         return;
00413       }
00414 
00415       //Check if it is a BasePlugin
00416       SecurityInterface * securePlugin = qobject_cast< SecurityInterface * >(plugin);
00417       if ( securePlugin ) {
00418         emit log(LOGINFO,tr("Plugin uses security interface. Trying to authenticate against plugin ..."));
00419 
00420         bool success = false;
00421         QMetaObject::invokeMethod(plugin,"authenticate", Q_RETURN_ARG( bool , success ) ) ;
00422 
00423         if ( success )
00424           emit log(LOGINFO,tr("... ok. Loading plugin "));
00425         else {
00426           emit log(LOGERR,tr("... failed. Plugin access denied."));
00427           emit log(LOGOUT,"=============================================================================================");
00428           return;
00429         }
00430       }
00431 
00432 
00433       emit log(LOGOUT,tr("Plugin Desciption :\t %1 ").arg( basePlugin->description()) );
00434 
00435       supported = "BaseInterface ";
00436 
00437       info.name          = basePlugin->name();
00438       info.description   = basePlugin->description();
00439       info.plugin        = plugin;
00440       info.path          = filename;
00441 
00442       if ( checkSlot(plugin,"version()") )
00443         info.version = basePlugin->version();
00444       else
00445         info.version = QString::number(-1);
00446 
00447       if ( OpenFlipper::Options::nogui() ) {
00448 
00449         if ( ! checkSlot( plugin , "noguiSupported()" ) ) {
00450           emit log(LOGWARN,tr("Running in nogui mode which is unsupported by this plugin, skipping") );
00451           emit log(LOGOUT,"=============================================================================================");
00452           return;
00453         }
00454 
00455       }
00456 
00457 
00458       // Check for baseInterface of old style!
00459       if ( checkSignal(plugin,"updated_objects(int)") ) {
00460         log(LOGERR,tr("Plugin Uses old style updated_objects! Convert to updatedObject!"));
00461         emit log(LOGOUT,"=============================================================================================");
00462         return;
00463       }
00464 
00465       if ( checkSignal(plugin,"update_view()") ) {
00466         log(LOGERR,tr("Plugin Uses old style update_view! Convert to updateView!"));
00467         emit log(LOGOUT,"=============================================================================================");
00468         return;
00469       }
00470 
00471       if ( checkSignal(plugin,"updateView()") )
00472         connect(plugin,SIGNAL(updateView()),this,SLOT(updateView()));
00473 
00474 
00475 
00476       if ( checkSignal(plugin,"updatedObject(int)") )
00477         connect(plugin,SIGNAL(updatedObject(int)),this,SLOT(slotObjectUpdated(int)), Qt::DirectConnection);
00478 
00479       if ( checkSlot( plugin , "slotObjectUpdated(int)" ) )
00480         connect(this,SIGNAL(signalObjectUpdated(int)),plugin,SLOT(slotObjectUpdated(int)), Qt::DirectConnection);
00481 
00482 
00483       if ( checkSignal(plugin,"objectPropertiesChanged(int)"))
00484         connect(plugin,SIGNAL(objectPropertiesChanged(int)),this,SLOT(slotObjectPropertiesChanged(int)), Qt::DirectConnection);
00485       
00486       if ( checkSlot( plugin , "slotViewChanged()" ) )
00487         connect(this,SIGNAL(pluginViewChanged()),plugin,SLOT(slotViewChanged()), Qt::DirectConnection);
00488 
00489       if ( checkSlot(plugin,"slotObjectPropertiesChanged(int)"))
00490         connect(this,SIGNAL(objectPropertiesChanged(int)),plugin,SLOT(slotObjectPropertiesChanged(int)), Qt::DirectConnection);
00491 
00492       if ( checkSignal(plugin,"visibilityChanged()" ) )
00493         emit log (LOGERR,tr("Signal visibilityChanged() now requires objectid or -1 as argument " ));
00494 
00495       if ( checkSignal(plugin,"visibilityChanged(int)") )
00496         connect(plugin,SIGNAL(visibilityChanged(int)),this,SLOT(slotVisibilityChanged(int)), Qt::DirectConnection);
00497 
00498       if ( checkSlot(plugin,"slotVisibilityChanged(int)") )
00499         connect(this,SIGNAL(visibilityChanged(int)),plugin,SLOT(slotVisibilityChanged(int)), Qt::DirectConnection);
00500 
00501       if ( checkSignal(plugin,"activeObjectChanged()" ) )
00502         emit log (LOGERR,tr("Signal activeObjectChanged() is now objectSelectionChanged( int _objectId ) ") );
00503 
00504       if ( checkSlot(plugin,"slotActiveObjectChanged()" ) )
00505         emit log (LOGERR,tr("Slot slotActiveObjectChanged() is now slotObjectSelectionChanged( int _objectId ) ") );
00506 
00507       if ( checkSlot(plugin,"slotAllCleared()") )
00508         connect(this,SIGNAL(allCleared()),plugin,SLOT(slotAllCleared()));
00509 
00510 
00511       if ( checkSignal(plugin,"objectSelectionChanged(int)") )
00512         connect(plugin,SIGNAL(objectSelectionChanged(int)),this,SLOT(slotObjectSelectionChanged(int) ));
00513 
00514       if ( checkSlot( plugin , "slotObjectSelectionChanged(int)" ) )
00515         connect(this,SIGNAL(objectSelectionChanged(int)),plugin,SLOT(slotObjectSelectionChanged(int) ));
00516 
00517 
00518       if ( checkSlot( plugin , "pluginsInitialized()" ) )
00519         connect(this,SIGNAL(pluginsInitialized()),plugin,SLOT(pluginsInitialized()), Qt::DirectConnection);
00520 
00521       if ( checkSignal(plugin,"setSlotDescription(QString,QString,QStringList,QStringList)") )
00522         connect(plugin, SIGNAL(setSlotDescription(QString,QString,QStringList,QStringList)),
00523                 this,   SLOT(slotSetSlotDescription(QString,QString,QStringList,QStringList)) );
00524     }
00525 
00526     //Check if the plugin supports Logging
00527     LoggingInterface* logPlugin = qobject_cast< LoggingInterface * >(plugin);
00528     if ( logPlugin ) {
00529       supported = supported + "Logging ";
00530 
00531       // Create intermediate logger class which will mangle the output
00532       PluginLogger* newlog = new PluginLogger(info.name);
00533       loggers_.push_back(newlog);
00534       connect(plugin,SIGNAL(log(Logtype, QString )),newlog,SLOT(slotLog(Logtype, QString )),Qt::DirectConnection);
00535       connect(plugin,SIGNAL(log(QString )),newlog,SLOT(slotLog(QString )),Qt::DirectConnection);
00536 
00537       // Connect it to the core widget logger
00538       if ( OpenFlipper::Options::gui() )
00539         connect(newlog,SIGNAL(log(Logtype, QString )),coreWidget_,SLOT(slotLog(Logtype, QString )),Qt::DirectConnection);
00540 
00541       // connection to console logger
00542       connect(newlog,SIGNAL(log(Logtype, QString )),this,SLOT(slotLog(Logtype, QString )),Qt::DirectConnection);
00543 
00544       // connection to file logger
00545       connect(newlog,SIGNAL(log(Logtype, QString )),this,SLOT(slotLogToFile(Logtype, QString )),Qt::DirectConnection);
00546 
00547       // connection to external plugin logger
00548       if ( checkSlot(plugin,"logOutput(Logtype,QString)") )
00549         connect(this,SIGNAL(externalLog(Logtype,QString)), plugin, SLOT(logOutput(Logtype,QString)) ) ;
00550     }
00551 
00552     //Check if the plugin supports Menubar-Interface
00553     MenuInterface* menubarPlugin = qobject_cast< MenuInterface * >(plugin);
00554     if ( menubarPlugin && OpenFlipper::Options::gui() ) {
00555       supported = supported + "Menubar ";
00556 
00557       if ( checkSignal(plugin,"addMenubarAction(QAction*,QString)") )
00558         connect(plugin      , SIGNAL(addMenubarAction(QAction*,QString)),
00559                 coreWidget_ , SLOT(slotAddMenubarAction(QAction*,QString)),Qt::DirectConnection);
00560       if ( checkSignal(plugin,"getMenubarMenu (QString,QMenu*&,bool)") )
00561         connect(plugin      , SIGNAL(getMenubarMenu (QString,QMenu*&,bool)),
00562                 coreWidget_ , SLOT(slotGetMenubarMenu (QString,QMenu*&,bool)),Qt::DirectConnection);
00563     }
00564 
00565     //Check if the plugin supports ContextMenuInterface
00566     ContextMenuInterface* contextMenuPlugin = qobject_cast< ContextMenuInterface * >(plugin);
00567     if ( contextMenuPlugin && OpenFlipper::Options::gui() ) {
00568       supported = supported + "ContextMenu ";
00569 
00570       if ( checkSignal(plugin,"addContextMenuItem(QAction*,ContextMenuType)") )
00571         connect(plugin      , SIGNAL(addContextMenuItem(QAction*,ContextMenuType)),
00572                 coreWidget_ , SLOT(slotAddContextItem(QAction*,ContextMenuType)),Qt::DirectConnection);
00573 
00574       if ( checkSignal(plugin,"addContextMenuItem(QAction*,DataType,ContextMenuType)") )
00575         connect(plugin      , SIGNAL(addContextMenuItem(QAction*,DataType,ContextMenuType)),
00576                 coreWidget_ , SLOT(slotAddContextItem(QAction*,DataType,ContextMenuType)),Qt::DirectConnection);
00577 
00578       if ( checkSlot(plugin,"slotUpdateContextMenu(int)") )
00579         connect(coreWidget_ , SIGNAL(updateContextMenu(int)),
00580                 plugin      , SLOT(slotUpdateContextMenu(int)),Qt::DirectConnection);
00581 
00582       if ( checkSlot(plugin,"slotUpdateContextMenuNode(int)") )
00583         connect(coreWidget_ , SIGNAL(updateContextMenuNode(int)),
00584                 plugin      , SLOT(slotUpdateContextMenuNode(int)),Qt::DirectConnection);
00585 
00586       if ( checkSlot(plugin,"slotUpdateContextMenuBackground()") )
00587         connect(coreWidget_ , SIGNAL(updateContextMenuBackground()),
00588                 plugin      , SLOT(slotUpdateContextMenuBackground()),Qt::DirectConnection);
00589     }
00590 
00591     //Check if the plugin supports Toolbox-Interface
00592     ToolboxInterface* toolboxPlugin = qobject_cast< ToolboxInterface * >(plugin);
00593     if ( toolboxPlugin && OpenFlipper::Options::gui() ) {
00594       supported = supported + "Toolbox ";
00595 
00596 
00597       if ( checkSignal(plugin, "addToolbox(QString,QWidget*)"))
00598         connect(plugin, SIGNAL( addToolbox(QString,QWidget*) ),
00599                 this, SLOT( addToolbox(QString,QWidget*) ),Qt::DirectConnection );
00600 
00601 
00602 
00603     }
00604     
00605     //Check if the plugin supports ViewMode-Interface
00606     ViewModeInterface* viewModePlugin = qobject_cast< ViewModeInterface * >(plugin);
00607     if ( viewModePlugin && OpenFlipper::Options::gui() ) {
00608       supported = supported + "ViewMode ";
00609       
00610       if ( checkSignal(plugin, "defineViewModeToolboxes(QString,QStringList)"))
00611         connect(plugin, SIGNAL( defineViewModeToolboxes(QString, QStringList) ),
00612                 coreWidget_, SLOT( slotAddViewModeToolboxes(QString, QStringList) ),Qt::DirectConnection );
00613                 
00614       if ( checkSignal(plugin, "defineViewModeToolbars(QString,QStringList)"))
00615         connect(plugin, SIGNAL( defineViewModeToolbars(QString, QStringList) ),
00616                 coreWidget_, SLOT( slotAddViewModeToolbars(QString, QStringList) ),Qt::DirectConnection );                
00617                 
00618       if ( checkSignal(plugin, "defineViewModeIcon(QString,QString)"))
00619         connect(plugin, SIGNAL( defineViewModeIcon(QString, QString) ),
00620                 coreWidget_, SLOT( slotSetViewModeIcon(QString, QString) ),Qt::DirectConnection );                          
00621                 
00622     }    
00623 
00624     //Check if the plugin supports Options-Interface
00625     OptionsInterface* optionsPlugin = qobject_cast< OptionsInterface * >(plugin);
00626     if ( optionsPlugin && OpenFlipper::Options::gui() ) {
00627       supported = supported + "Options ";
00628 
00629       QWidget* widget = 0;
00630       if ( optionsPlugin->initializeOptionsWidget( widget ) ) {
00631             info.optionsWidget = widget;
00632 
00633             if ( checkSlot(plugin,"applyOptions()") )
00634               connect(coreWidget_ , SIGNAL( applyOptions() ),
00635                       plugin      , SLOT( applyOptions() ),Qt::DirectConnection);
00636       }
00637     }
00638 
00639     //Check if the plugin supports Toolbar-Interface
00640     ToolbarInterface* toolbarPlugin = qobject_cast< ToolbarInterface * >(plugin);
00641     if ( toolbarPlugin && OpenFlipper::Options::gui() ) {
00642       supported = supported + "Toolbars ";
00643 
00644       if ( checkSignal(plugin,"addToolbar(QToolBar*)") )
00645         connect(plugin,SIGNAL(addToolbar(QToolBar*)),
00646                 coreWidget_,SLOT(slotAddToolbar(QToolBar*)),Qt::DirectConnection);
00647 
00648       if ( checkSignal(plugin,"removeToolbar(QToolBar*)") )
00649         connect(plugin,SIGNAL(removeToolbar(QToolBar*)),
00650                 coreWidget_,SLOT(slotRemoveToolbar(QToolBar*)),Qt::DirectConnection);
00651 
00652       if ( checkSignal(plugin,"getToolBar(QString,QToolBar*&)") )
00653         connect(plugin,SIGNAL(getToolBar(QString,QToolBar*&)),
00654                 coreWidget_,SLOT(getToolBar(QString,QToolBar*&)),Qt::DirectConnection);
00655           
00656     }
00657 
00658     //Check if the plugin supports StatusBar-Interface
00659     StatusbarInterface* statusbarPlugin = qobject_cast< StatusbarInterface * >(plugin);
00660     if ( statusbarPlugin && OpenFlipper::Options::gui() ) {
00661       supported = supported + "StatusBar ";
00662 
00663       if ( checkSignal(plugin,"showStatusMessage(QString,int)") )
00664         connect(plugin,SIGNAL(showStatusMessage(QString,int)),
00665                 coreWidget_,SLOT(statusMessage(QString,int)),Qt::DirectConnection);
00666 
00667 
00668       if ( checkSignal(plugin,"setStatus(ApplicationStatus::applicationStatus)") )
00669         connect(plugin,SIGNAL(setStatus(ApplicationStatus::applicationStatus)),
00670                 coreWidget_,SLOT(setStatus(ApplicationStatus::applicationStatus)),Qt::DirectConnection);
00671 
00672       if ( checkSignal(plugin,"clearStatusMessage()") )
00673         connect(plugin,SIGNAL(clearStatusMessage()),
00674                 coreWidget_,SLOT(clearStatusMessage()));
00675 
00676     }
00677 
00678     //Check if the plugin supports Key-Interface
00679     KeyInterface* keyPlugin = qobject_cast< KeyInterface * >(plugin);
00680     if ( keyPlugin && OpenFlipper::Options::gui() ) {
00681       supported = supported + "KeyboardEvents ";
00682 
00683       if ( checkSignal(plugin,"registerKey(int,Qt::KeyboardModifiers,QString,bool)") )
00684         connect(plugin,SIGNAL( registerKey(int, Qt::KeyboardModifiers, QString, bool) ),
00685                 coreWidget_,SLOT(slotRegisterKey(int, Qt::KeyboardModifiers, QString, bool)) );
00686 
00687 //       if ( checkSlot( plugin , "slotKeyEvent(QKeyEvent*)" ) )
00688 //         connect(coreWidget_,SIGNAL(PluginKeyEvent(QKeyEvent* )), plugin,SLOT(slotKeyEvent(QKeyEvent*)));
00689 //
00690 //       if ( checkSlot( plugin , "slotKeyReleaseEvent(QKeyEvent*)" ) )
00691 //         connect(coreWidget_,SIGNAL(PluginKeyReleaseEvent(QKeyEvent* )), plugin,SLOT(slotKeyReleaseEvent(QKeyEvent*)));
00692     }
00693 
00694     //Check if the plugin supports Mouse-Interface
00695     MouseInterface* mousePlugin = qobject_cast< MouseInterface * >(plugin);
00696     if ( mousePlugin && OpenFlipper::Options::gui()  ) {
00697       supported = supported + "MouseEvents ";
00698 
00699       if ( checkSlot( plugin , "slotMouseWheelEvent(QWheelEvent*,const std::string&)" ) )
00700         connect(this   , SIGNAL(PluginWheelEvent(QWheelEvent * , const std::string & )),
00701                 plugin , SLOT(slotMouseWheelEvent(QWheelEvent* , const std::string & )));
00702 
00703       if ( checkSlot( plugin , "slotMouseEvent(QMouseEvent*)" ) )
00704         connect(this   , SIGNAL(PluginMouseEvent(QMouseEvent*)),
00705                 plugin , SLOT(slotMouseEvent(QMouseEvent*)));
00706 
00707       if ( checkSlot( plugin , "slotMouseEventIdentify(QMouseEvent*)" ) )
00708         connect(this   , SIGNAL(PluginMouseEventIdentify(QMouseEvent*)),
00709                 plugin , SLOT(slotMouseEventIdentify(QMouseEvent*)));
00710 
00711     }
00712 
00713     //Check if the plugin supports Picking-Interface
00714     PickingInterface* pickPlugin = qobject_cast< PickingInterface * >(plugin);
00715     if ( pickPlugin && OpenFlipper::Options::gui() ) {
00716       supported = supported + "Picking ";
00717 
00718       if ( checkSlot( plugin , "slotPickModeChanged(const std::string&)" ) )
00719         connect(coreWidget_,SIGNAL(signalPickModeChanged (const std::string &)),
00720                 plugin,SLOT(slotPickModeChanged( const std::string &)));
00721 
00722       if ( checkSignal(plugin,"addPickMode(const std::string)") )
00723         connect(plugin,SIGNAL(addPickMode( const std::string )),
00724                 this,SLOT(slotAddPickMode( const std::string )),Qt::DirectConnection);
00725 
00726       if ( checkSignal(plugin,"addHiddenPickMode(const std::string)") )
00727         connect(plugin,SIGNAL(addHiddenPickMode( const std::string )),
00728                 this,SLOT(slotAddHiddenPickMode( const std::string )),Qt::DirectConnection);
00729 
00730       if ( checkSignal(plugin,"setPickModeCursor(const std::string,QCursor)") )
00731         for ( uint i = 0 ; i < OpenFlipper::Options::examinerWidgets() ; ++i )
00732           connect(plugin,SIGNAL(setPickModeCursor( const std::string ,QCursor)),
00733                   coreWidget_,SLOT(setPickModeCursor( const std::string ,QCursor)),Qt::DirectConnection);
00734 
00735       if ( checkSignal(plugin,"setPickModeMouseTracking(const std::string,bool)") )
00736         for ( uint i = 0 ; i < OpenFlipper::Options::examinerWidgets() ; ++i )
00737           connect(plugin,SIGNAL(setPickModeMouseTracking( const std::string ,bool)),
00738                   coreWidget_,SLOT(setPickModeMouseTracking( const std::string ,bool)),Qt::DirectConnection);
00739 
00740       if ( checkSignal(plugin,"setPickModeToolbar(const std::string,QToolBar*)") )
00741         connect(plugin,SIGNAL(setPickModeToolbar (const std::string, QToolBar*)),
00742                 coreWidget_,SLOT(setPickModeToolbar (const std::string, QToolBar*)),Qt::DirectConnection);
00743 
00744       if ( checkSignal(plugin,"removePickModeToolbar(const std::string)") )
00745         connect(plugin,SIGNAL(removePickModeToolbar( const std::string)),
00746                 coreWidget_,SLOT(removePickModeToolbar( const std::string)),Qt::DirectConnection);
00747 
00748     }
00749 
00750     //Check if the plugin supports INI-Interface
00751     INIInterface* iniPlugin = qobject_cast< INIInterface * >(plugin);
00752     if ( iniPlugin ) {
00753       supported = supported + "INIFile ";
00754 
00755       if ( checkSlot( plugin , "loadIniFile(INIFile&,int)" ) )
00756         connect(this    , SIGNAL(iniLoad( INIFile&,int)),
00757                 plugin  , SLOT( loadIniFile( INIFile&,int) ),Qt::DirectConnection);
00758 
00759       if ( checkSlot( plugin , "saveIniFile(INIFile&,int)" ) )
00760         connect(this    , SIGNAL(iniSave( INIFile& , int )),
00761                 plugin  , SLOT( saveIniFile( INIFile& , int ) ),Qt::DirectConnection);
00762 
00763       if ( checkSlot( plugin , "saveIniFileOptions(INIFile&)" ) )
00764         connect(this    , SIGNAL(iniSaveOptions( INIFile& )),
00765                 plugin  , SLOT( saveIniFileOptions( INIFile& ) ),Qt::DirectConnection);
00766 
00767       if ( checkSlot( plugin , "saveOnExit(INIFile&)" ) )
00768         connect(this    , SIGNAL(saveOnExit( INIFile& )),
00769                 plugin  , SLOT( saveOnExit( INIFile& ) ),Qt::DirectConnection);
00770 
00771       if ( checkSlot( plugin , "loadIniFileOptions(INIFile&)" ) )
00772         connect(this    , SIGNAL(iniLoadOptions( INIFile& )),
00773                 plugin  , SLOT( loadIniFileOptions( INIFile& ) ),Qt::DirectConnection);
00774 
00775       if ( checkSlot( plugin , "loadIniFileOptionsLast(INIFile&)" ) )
00776         connect(this    , SIGNAL(iniLoadOptionsLast( INIFile& )),
00777                 plugin  , SLOT( loadIniFileOptionsLast( INIFile& ) ),Qt::DirectConnection);
00778     }
00779 
00780     //Check if the plugin supports Texture-Interface
00781     TextureInterface* texturePlugin = qobject_cast< TextureInterface * >(plugin);
00782     if ( texturePlugin && OpenFlipper::Options::gui() ) {
00783       supported = supported + "Textures ";
00784 
00785       if ( checkSignal(plugin,"addTexture(QString,QString,uint,int)") )
00786         connect(plugin , SIGNAL(addTexture( QString , QString , uint , int )),
00787                 this   , SLOT(slotAddTexture(QString, QString, uint, int)),Qt::DirectConnection);
00788 
00789       if ( checkSlot( plugin , "slotTextureAdded(QString,QString,uint,int)" ) )
00790         connect(this   , SIGNAL(addTexture(QString,QString, uint, int)),
00791                 plugin , SLOT(slotTextureAdded(QString,QString, uint, int)),Qt::DirectConnection);
00792 
00793       if ( checkSignal(plugin,"addTexture(QString,QString,uint)") )
00794         connect(plugin , SIGNAL(addTexture( QString , QString , uint )),
00795                 this   , SLOT(slotAddTexture(QString, QString, uint)),Qt::DirectConnection);
00796 
00797       if ( checkSlot( plugin , "slotTextureAdded(QString,QString,uint)" ) )
00798         connect(this   , SIGNAL(addTexture(QString,QString, uint)),
00799                 plugin , SLOT(slotTextureAdded(QString,QString, uint)),Qt::DirectConnection);
00800 
00801       if ( checkSignal(plugin,"updateTexture(QString,int)") )
00802         connect(plugin , SIGNAL(updateTexture( QString ,int )),
00803                 this   , SLOT(slotUpdateTexture(QString , int)));
00804 
00805       if ( checkSlot( plugin , "slotUpdateTexture(QString,int)" ) )
00806         connect(this   , SIGNAL(updateTexture(QString ,int)),
00807                 plugin , SLOT(slotUpdateTexture(QString,int )));
00808 
00809       if ( checkSignal(plugin,"updateAllTextures()") )
00810         connect(plugin , SIGNAL(updateAllTextures()),
00811                 this   , SLOT(slotUpdateAllTextures()));
00812 
00813       if ( checkSlot( plugin , "slotUpdateAllTextures()" ) )
00814         connect(this   , SIGNAL(updateAllTextures()),
00815                 plugin , SLOT(slotUpdateAllTextures()));
00816 
00817       if ( checkSignal(plugin,"updatedTextures(QString,int)") )
00818         connect(plugin , SIGNAL(updatedTextures( QString , int )),
00819                 this   , SLOT(slotTextureUpdated( QString, int ) ));
00820 
00821       if ( checkSlot( plugin , "slotTextureUpdated(QString,int)" ) )
00822         connect(this   , SIGNAL(updatedTextures( QString , int )),
00823                 plugin , SLOT(slotTextureUpdated( QString, int ) ));
00824 
00825       if ( checkSignal(plugin,"setTextureMode(QString,QString,int)") )
00826         connect(plugin , SIGNAL(setTextureMode(QString, QString, int )),
00827                 this   , SLOT(slotSetTextureMode(QString, QString, int )),Qt::DirectConnection );
00828 
00829       if ( checkSlot( plugin , "slotSetTextureMode(QString,QString,int)" ) )
00830         connect(this   , SIGNAL(setTextureMode(QString, QString, int )),
00831                 plugin , SLOT(slotSetTextureMode(QString, QString, int )),Qt::DirectConnection );
00832 
00833       if ( checkSignal(plugin,"setTextureMode(QString,QString)") )
00834         connect(plugin , SIGNAL(setTextureMode(QString  ,QString )),
00835                 this   , SLOT(slotSetTextureMode(QString  ,QString )),Qt::DirectConnection );
00836 
00837       if ( checkSlot( plugin , "slotSetTextureMode(QString,QString)" ) )
00838         connect(this   , SIGNAL(setTextureMode(QString  ,QString )),
00839                 plugin , SLOT(slotSetTextureMode(QString  ,QString )),Qt::DirectConnection );
00840 
00841       if ( checkSignal(plugin,"switchTexture(QString,int)") )
00842         connect(plugin , SIGNAL(switchTexture(QString, int )),
00843                 this   , SLOT(slotSwitchTexture(QString, int )),Qt::DirectConnection);
00844 
00845       if ( checkSlot( plugin , "slotSwitchTexture(QString,int)" ) )
00846         connect(this   , SIGNAL(switchTexture(QString, int )),
00847                 plugin , SLOT(slotSwitchTexture(QString, int )),Qt::DirectConnection);
00848 
00849       if ( checkSignal(plugin,"switchTexture(QString)") )
00850         connect(plugin , SIGNAL(switchTexture(QString )),
00851                 this   , SLOT(slotSwitchTexture(QString )),Qt::DirectConnection);
00852 
00853       if ( checkSlot( plugin , "slotSwitchTexture(QString)" ) )
00854         connect(this   , SIGNAL(switchTexture(QString )),
00855                 plugin , SLOT(slotSwitchTexture(QString )),Qt::DirectConnection);
00856 
00857 
00858 
00859       if ( checkSignal( plugin , "textureChangeImage(QString,QImage&,int)" ) )
00860         connect(plugin   , SIGNAL(textureChangeImage(QString,QImage&,int)),
00861                 this , SLOT(slotTextureChangeImage(QString,QImage&,int)),Qt::DirectConnection);
00862 
00863       if ( checkSlot( plugin , "slotTextureChangeImage(QString,QImage&,int)" ) )
00864         connect(this   , SIGNAL(textureChangeImage(QString,QImage&,int)),
00865                 plugin , SLOT(slotTextureChangeImage(QString,QImage&,int)),Qt::DirectConnection);
00866 
00867       if ( checkSignal( plugin , "textureChangeImage(QString,QImage&)" ) )
00868         connect(plugin   , SIGNAL(textureChangeImage(QString,QImage&)),
00869                 this , SLOT(slotTextureChangeImage(QString,QImage&)),Qt::DirectConnection);
00870 
00871       if ( checkSlot( plugin , "slotTextureChangeImage(QString,QImage&)" ) )
00872         connect(this   , SIGNAL(textureChangeImage(QString,QImage&)),
00873                 plugin , SLOT(slotTextureChangeImage(QString,QImage&)),Qt::DirectConnection);
00874 
00875       if ( checkSignal( plugin , "addMultiTexture(QString,QString,QString,int,int&)" ) )
00876         connect(plugin   , SIGNAL(addMultiTexture(QString,QString,QString,int,int&) ),
00877                 this , SLOT(slotMultiTextureAdded(QString,QString,QString,int,int&) ),Qt::DirectConnection);
00878 
00879       if ( checkSlot( plugin , "slotMultiTextureAdded( QString,QString,QString,int,int&)" ) )
00880         connect(this   , SIGNAL(addMultiTexture(QString,QString,QString,int,int&) ),
00881                 plugin , SLOT(slotMultiTextureAdded( QString,QString,QString,int,int&) ),Qt::DirectConnection);
00882 
00883     }
00884 
00885     //Check if the plugin supports Backup-Interface
00886     BackupInterface* backupPlugin = qobject_cast< BackupInterface * >(plugin);
00887     if ( backupPlugin ) {
00888       supported = supported + "Backups ";
00889 
00890       if ( checkSignal( plugin , "createBackup(int,QString)" ) )
00891         connect(plugin , SIGNAL(createBackup( int , QString )) ,
00892                 this   , SLOT(backupRequest( int , QString )),Qt::DirectConnection );
00893 
00894       if ( checkSlot( plugin , "slotBackupRequested(int,QString,int)" ) )
00895         connect(this   , SIGNAL(createBackup(int,QString,int)) ,
00896                 plugin , SLOT( slotBackupRequested(int,QString,int) ),Qt::DirectConnection);
00897     }
00898 
00899     //Check if the plugin supports LoadSave-Interface
00900     LoadSaveInterface* LoadSavePlugin = qobject_cast< LoadSaveInterface * >(plugin);
00901     if ( LoadSavePlugin ) {
00902       supported = supported + "Load/Save ";
00903       if ( checkSignal(plugin,"load( QString,DataType,int& )" ) )
00904         connect(plugin , SIGNAL(load( QString,DataType,int& )) ,
00905                 this   , SLOT(slotLoad( QString,DataType,int& )),Qt::DirectConnection );
00906       if ( checkSignal(plugin,"save(int,QString)" ) )
00907         connect(plugin , SIGNAL( save(int,QString) ) ,
00908                 this   , SLOT( saveObject(int,QString) ), Qt::DirectConnection);
00909 
00910       if ( checkSlot( plugin , "fileOpened(int)" ) )
00911         connect(this   , SIGNAL( openedFile( int) ) ,
00912                 plugin , SLOT( fileOpened( int ) ),Qt::DirectConnection);
00913 
00914       if ( checkSignal(plugin,"openedFile(int)" ) )
00915         connect(plugin , SIGNAL( openedFile( int ) ) ,
00916                 this   , SLOT( slotObjectOpened ( int ) ),Qt::DirectConnection);
00917 
00918       if ( checkSignal(plugin,"addEmptyObject(DataType,int&)" ) )
00919         connect(plugin , SIGNAL( addEmptyObject( DataType, int& )) ,
00920                 this   , SLOT( slotAddEmptyObject( DataType, int&) ),Qt::DirectConnection);
00921 
00922       if ( checkSignal(plugin,"copyObject(int,int&)" ) )
00923         connect(plugin , SIGNAL( copyObject( int, int& )) ,
00924                 this   , SLOT( slotCopyObject( int, int&) ),Qt::DirectConnection);
00925 
00926       if ( checkSignal(plugin,"emptyObjectAdded(int)" ) )
00927         connect(plugin , SIGNAL( emptyObjectAdded( int ) ) ,
00928                 this   , SLOT( slotEmptyObjectAdded ( int ) ),Qt::DirectConnection);
00929 
00930       if ( checkSlot(plugin,"addedEmptyObject(int)" ) )
00931         connect(this ,   SIGNAL( emptyObjectAdded( int ) ) ,
00932                 plugin   , SLOT( addedEmptyObject( int ) ),Qt::DirectConnection);
00933 
00934       if ( checkSignal(plugin,"getAllFilters(QStringList&)" ) )
00935         connect(plugin , SIGNAL( getAllFilters( QStringList& ) ) ,
00936                 this   , SLOT( slotGetAllFilters ( QStringList& ) ),Qt::DirectConnection);
00937 
00938       if ( checkSignal(plugin,"deleteObject(int)" ) )
00939         connect(plugin , SIGNAL( deleteObject( int ) ) ,
00940                 this   , SLOT( slotDeleteObject( int ) ),Qt::DirectConnection);
00941 
00942       if ( checkSignal(plugin,"deleteAllObjects()" ) )
00943         connect(plugin , SIGNAL( deleteAllObjects() ) ,
00944                 this   , SLOT( slotDeleteAllObjects() ),Qt::DirectConnection);
00945 
00946       if ( checkSlot(plugin,"objectDeleted(int)" ) )
00947         connect(this ,   SIGNAL( objectDeleted( int ) ) ,
00948                 plugin   , SLOT( objectDeleted( int ) ),Qt::DirectConnection);
00949 
00950     }
00951 
00952     //Check if the plugin supports View-Interface
00953     ViewInterface* viewPlugin = qobject_cast< ViewInterface * >(plugin);
00954     if ( viewPlugin  && OpenFlipper::Options::gui() ) {
00955       supported = supported + "View ";
00956 
00957       if ( checkSignal(plugin,"getStackWidget(QString,QWidget*&)" ) )
00958         connect(plugin      , SIGNAL(getStackWidget( QString , QWidget*&)),
00959                 coreWidget_ , SLOT( slotGetStackWidget( QString , QWidget*& ) ) ,Qt::DirectConnection );
00960       if ( checkSignal(plugin,"addStackWidget(QString,QWidget*)" ) )
00961         connect(plugin      , SIGNAL(addStackWidget( QString , QWidget*)),
00962                 coreWidget_ , SLOT( slotAddStackWidget( QString , QWidget* ) ) ,Qt::DirectConnection );
00963       if ( checkSignal(plugin,"updateStackWidget(QString,QWidget*)" ) )
00964         connect(plugin      , SIGNAL(updateStackWidget( QString , QWidget*)),
00965                 coreWidget_ , SLOT( slotUpdateStackWidget( QString , QWidget* ) ) ,Qt::DirectConnection );
00966     }
00967     
00968     //Check if the plugin supports Process-Interface
00969     ProcessInterface* processPlugin = qobject_cast< ProcessInterface * >(plugin);
00970     if ( processPlugin ) {
00971       supported = supported + "Process ";
00972 
00973       if ( checkSignal(plugin,"startJob(QString,QString,int,int,bool)" ) )
00974         connect(plugin      , SIGNAL(startJob(QString, QString,int,int,bool)),
00975                 this , SLOT( slotStartJob(QString, QString,int,int,bool) ) ,Qt::DirectConnection );
00976       else
00977         emit log(LOGERR,"Process Interface defined but no startJob signal found!");  
00978                 
00979       if ( checkSignal(plugin,"setJobState(QString,int)" ) )
00980         connect(plugin      , SIGNAL(setJobState(QString,int)),
00981                 this , SLOT( slotSetJobState(QString,int) ) ,Qt::DirectConnection );
00982       else
00983         emit log(LOGERR,"Process Interface defined but no setJobState signal found!");  
00984                 
00985       if ( checkSignal(plugin,"cancelJob(QString)" ) )
00986         connect(plugin      , SIGNAL(cancelJob(QString)),
00987                 this , SLOT( slotCancelJob(QString) ) ,Qt::DirectConnection );
00988                 
00989       if ( checkSignal(plugin,"finishJob(QString)" ) )
00990         connect(plugin      , SIGNAL(finishJob(QString)),
00991                 this , SLOT( slotFinishJob(QString) ) ,Qt::DirectConnection ); 
00992       else
00993         emit log(LOGERR,"Process Interface defined but no finishJob signal found!");                
00994                 
00995                 
00996       if ( checkSlot(plugin,"canceledJob(QString)" ) ) 
00997         connect(this ,   SIGNAL( jobCanceled( QString ) ) ,
00998               plugin   , SLOT( canceledJob(QString) ),Qt::DirectConnection);                
00999       else
01000         emit log(LOGERR,"Process Interface defined but no cancel canceledJob slot found!");
01001     }
01002 
01003     //Check if the plugin supports RPC-Interface
01004     RPCInterface* rpcPlugin = qobject_cast< RPCInterface * >(plugin);
01005     if ( rpcPlugin ) {
01006       supported = supported + "RPC ";
01007 
01008       if ( checkSignal(plugin,"pluginExists(QString,bool&)" ) )
01009         connect(plugin  , SIGNAL( pluginExists(QString,bool&) ),
01010                 this    , SLOT( slotPluginExists(QString,bool&) ) ,Qt::DirectConnection );
01011       if ( checkSignal(plugin,"functionExists(QString,QString,bool&)" ) )
01012         connect(plugin  , SIGNAL(functionExists(QString,QString,bool&)),
01013                 this    , SLOT( slotFunctionExists(QString,QString,bool&) ) ,Qt::DirectConnection );
01014       if ( checkSignal(plugin,"call(QString,QString,bool&)" ) )
01015         connect(plugin  , SIGNAL(call(QString,QString,bool&)),
01016                 this    , SLOT(slotCall(QString,QString,bool&)) ,Qt::DirectConnection );
01017       if ( checkSignal(plugin,"call(QString,bool&)" ) )
01018         connect(plugin  , SIGNAL(call(QString,bool&)),
01019                 this    , SLOT(slotCall(QString,bool&)) ,Qt::DirectConnection );
01020       if ( checkSignal(plugin,"getValue(QString,QVariant&)" ) )
01021         connect(plugin  , SIGNAL(getValue(QString,QVariant&)),
01022                 this    , SLOT(slotGetValue(QString,QVariant&)) ,Qt::DirectConnection );
01023     }
01024 
01025     //========================================================================================
01026     // ===          Collect Scripting Information for Plugin      ============================
01027 
01028     QScriptValue scriptInstance = scriptEngine_.newQObject(plugin,
01029                                                            QScriptEngine::QtOwnership,
01030                                                            QScriptEngine::ExcludeChildObjects |
01031                                                            QScriptEngine::ExcludeSuperClassMethods |
01032                                                            QScriptEngine::ExcludeSuperClassProperties
01033                                                            );
01034 
01035     // Make plugin available for scripting
01036     QString scriptingName = info.name.remove(" ").toLower();
01037 
01038     scriptEngine_.globalObject().setProperty(scriptingName, scriptInstance);
01039 
01040     info.rpcName = scriptingName;
01041 
01042     QScriptValueIterator it(scriptInstance);
01043     while (it.hasNext()) {
01044       it.next();
01045 
01047       if ( checkSignal( plugin, it.name().toAscii() ) )
01048         continue;
01049 
01050       info.rpcFunctions.push_back( it.name() );
01051 
01052       scriptingFunctions_.push_back( scriptingName + "." + it.name() );
01053 
01054     }
01055 
01056     //Check if the plugin supports RPC-Interface
01057     ScriptInterface* scriptPlugin = qobject_cast< ScriptInterface * >(plugin);
01058     if ( scriptPlugin ) {
01059       supported = supported + "Scripting ";
01060 
01061       // Create intermediate wrapper class which will mangle the call information
01062       ScriptingWrapper* newScript = new ScriptingWrapper(info.rpcName);
01063       scriptingWrappers_.push_back(newScript);
01064 
01065       //========= Part one, Scriptinfos via wrapper to core and than to scipting Plugin ==========
01066 
01067       if ( checkSignal(plugin,"scriptInfo(QString)" ) ) {
01068 
01069         // Plugin to wrapper
01070         connect(plugin    , SIGNAL( scriptInfo(QString) ),
01071                 newScript , SLOT( slotScriptInfo(QString) ) ,Qt::DirectConnection );
01072 
01073         // wrapper to core
01074         connect(newScript , SIGNAL( scriptInfo(QString,QString) ),
01075                 this      , SLOT( slotScriptInfo(QString,QString) ));
01076       }
01077 
01078       // Core to plugins ( normally only one scripting plugin)
01079       if ( checkSlot(plugin,"slotScriptInfo(QString,QString)") ) {
01080         connect(this      , SIGNAL(scriptInfo(QString,QString)),
01081                 plugin    , SLOT(slotScriptInfo(QString,QString)));
01082       }
01083 
01084       // Function descriptions
01085       if ( checkSignal(plugin,"getDescription(QString,QString&,QStringList&,QStringList&)") )
01086         connect(plugin    , SIGNAL( getDescription(QString,QString&,QStringList&,QStringList&) ),
01087                 this      , SLOT( slotGetDescription(QString,QString&,QStringList&,QStringList&) ));
01088 
01089       //========= Script Execution ==========
01090 
01091       // Plugins to Core
01092       if ( checkSignal(plugin,"executeScript(QString)") )
01093         connect(plugin      , SIGNAL(executeScript(QString)),
01094                 this       , SLOT(slotExecuteScript(QString)));
01095 
01096       // Core to plugins ( normally only one scripting plugin)
01097       if ( checkSlot(plugin,"slotExecuteScript(QString)") )
01098         connect(this      , SIGNAL(executeScript(QString)),
01099                 plugin       , SLOT(slotExecuteScript(QString)));
01100 
01101       // Core to plugins ( normally only one scripting plugin)
01102       if ( checkSlot(plugin,"slotExecuteFileScript(QString)") )
01103         connect(this      , SIGNAL(executeFileScript(QString)),
01104                 plugin       , SLOT(slotExecuteFileScript(QString)));
01105 
01106       //========= Engine  ==========
01107 
01108       // Plugins to Core
01109       if ( checkSignal(plugin,"getScriptingEngine(QScriptEngine*&)") )
01110         connect(plugin      , SIGNAL(getScriptingEngine(QScriptEngine*&)),
01111                 this       , SLOT(slotGetScriptingEngine(QScriptEngine*&)));
01112 
01113       // Plugins to Core
01114       if ( checkSignal(plugin,"getAvailableFunctions(QStringList&)") )
01115         connect(plugin      , SIGNAL(getAvailableFunctions(QStringList&)),
01116                 this       , SLOT(slotGetAllAvailableFunctions(QStringList&)));
01117 
01118     }
01119 
01120     //========================================================================================
01121     //========================================================================================
01122 
01123     plugins.push_back(info);
01124 
01125     // Initialize Plugin
01126     if ( basePlugin ) {
01127       if ( checkSlot(plugin,"initializePlugin()") )
01128          QMetaObject::invokeMethod(plugin, "initializePlugin",  Qt::DirectConnection);
01129     }
01130 
01131 
01132     //Check if its a filePlugin
01133     FileInterface* filePlugin = qobject_cast< FileInterface * >(plugin);
01134     if ( filePlugin ){
01135       supported = supported + "File ";
01136 
01137       // Collect supported Data from file plugin
01138       fileTypes ft;
01139       ft.type = filePlugin->supportedType();
01140       ft.loadFilters = filePlugin->getLoadFilters();
01141       ft.saveFilters = filePlugin->getSaveFilters();
01142       ft.plugin = filePlugin;
01143 
01144       supportedTypes_.push_back(ft);
01145     }
01146 
01147     emit log(LOGOUT,"=============================================================================================");
01148   } else {
01149     emit log(LOGERR,tr("Unable to load Plugin :\t %1").arg( filename ) );
01150     emit log(LOGERR,tr("Error was : ") + loader.errorString() );
01151     emit log(LOGOUT,"=============================================================================================");
01152   }
01153 
01154 
01155 
01156 }

acg pic Project OpenFlipper, ©  Computer Graphics Group, RWTH Aachen. Documentation generated using doxygen .