PluginLoader.cc 59.6 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36
/*===========================================================================*\
 *                                                                           *
 *                              OpenFlipper                                  *
 *      Copyright (C) 2001-2009 by Computer Graphics Group, RWTH Aachen      *
 *                           www.openflipper.org                             *
 *                                                                           *
 *---------------------------------------------------------------------------*
 *  This file is part of OpenFlipper.                                        *
 *                                                                           *
 *  OpenFlipper is free software: you can redistribute it and/or modify      *
 *  it under the terms of the GNU Lesser General Public License as           *
 *  published by the Free Software Foundation, either version 3 of           *
 *  the License, or (at your option) any later version with the              *
 *  following exceptions:                                                    *
 *                                                                           *
 *  If other files instantiate templates or use macros                       *
 *  or inline functions from this file, or you compile this file and         *
 *  link it with other files to produce an executable, this file does        *
 *  not by itself cause the resulting executable to be covered by the        *
 *  GNU Lesser General Public License. This exception does not however       *
 *  invalidate any other reasons why the executable file might be            *
 *  covered by the GNU Lesser General Public License.                        *
 *                                                                           *
 *  OpenFlipper is distributed in the hope that it will be useful,           *
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of           *
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the            *
 *  GNU Lesser General Public License for more details.                      *
 *                                                                           *
 *  You should have received a copy of the GNU LesserGeneral Public          *
 *  License along with OpenFlipper. If not,                                  *
 *  see <http://www.gnu.org/licenses/>.                                      *
 *                                                                           *
\*===========================================================================*/

/*===========================================================================*\
 *                                                                           *
37 38
 *   $Revision$                                                       *
 *   $Author$                                                       *
39 40 41
 *   $Date$                   *
 *                                                                           *
\*===========================================================================*/
42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61




//=============================================================================
//
//  CLASS Core - IMPLEMENTATION of the Plugin Loading
//
//=============================================================================


//== INCLUDES =================================================================

// -------------------- mview
#include "Core.hh"

#include <QMenuBar>
#include <QToolBox>
#include <QMessageBox>
#include <QApplication>
Jan Möbius's avatar
Jan Möbius committed
62
#include <QScrollArea>
63 64 65 66 67 68 69 70 71

#include <QPluginLoader>
#include "OpenFlipper/BasePlugin/BaseInterface.hh"
#include "OpenFlipper/BasePlugin/KeyInterface.hh"
#include "OpenFlipper/BasePlugin/BackupInterface.hh"
#include "OpenFlipper/BasePlugin/LoggingInterface.hh"
#include "OpenFlipper/BasePlugin/MouseInterface.hh"
#include "OpenFlipper/BasePlugin/PickingInterface.hh"
#include "OpenFlipper/BasePlugin/ToolboxInterface.hh"
Dirk Wilden's avatar
Dirk Wilden committed
72
#include "OpenFlipper/BasePlugin/OptionsInterface.hh"
73 74 75 76
#include "OpenFlipper/BasePlugin/ToolbarInterface.hh"
#include "OpenFlipper/BasePlugin/TextureInterface.hh"
#include "OpenFlipper/BasePlugin/MenuInterface.hh"
#include "OpenFlipper/BasePlugin/ContextMenuInterface.hh"
77
#include "OpenFlipper/BasePlugin/ProcessInterface.hh"
78
#include "OpenFlipper/BasePlugin/ViewInterface.hh"
79
#include "OpenFlipper/BasePlugin/ViewModeInterface.hh"
80 81 82 83 84 85
#include "OpenFlipper/BasePlugin/LoadSaveInterface.hh"
#include "OpenFlipper/BasePlugin/StatusbarInterface.hh"
#include "OpenFlipper/BasePlugin/INIInterface.hh"
#include "OpenFlipper/BasePlugin/FileInterface.hh"
#include "OpenFlipper/BasePlugin/RPCInterface.hh"
#include "OpenFlipper/BasePlugin/ScriptInterface.hh"
86
#include "OpenFlipper/BasePlugin/SecurityInterface.hh"
87
#include "OpenFlipper/BasePlugin/TypeInterface.hh"
88 89 90 91 92 93 94 95 96

#include "OpenFlipper/INIFile/INIFile.hh"

#include "OpenFlipper/common/GlobalOptions.hh"

#include <QMessageBox>
#include <QtScript/QScriptValueIterator>

#include <ACG/QtWidgets/QtFileDialog.hh>
Dirk Wilden's avatar
Dirk Wilden committed
97
#include "OpenFlipper/widgets/PluginDialog/PluginDialog.hh"
98

Jan Möbius's avatar
Jan Möbius committed
99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142
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_;
};


143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161
//== IMPLEMENTATION ==========================================================


bool Core::checkSlot(QObject* _plugin , const char* _slotSignature) {
  const QMetaObject* meta = _plugin->metaObject();
  int id = meta->indexOfSlot( QMetaObject::normalizedSignature( _slotSignature ) );
  return ( id != -1 );
}

bool Core::checkSignal(QObject* _plugin , const char* _signalSignature) {
  const QMetaObject* meta = _plugin->metaObject();
  int id = meta->indexOfSignal( QMetaObject::normalizedSignature( _signalSignature ) );
  return ( id != -1 );
}

 /** Load plugins from dir Plugins. The plugin information gets stored, toolbox and menu entries are created and the required signals and slots are connected.
  */
void Core::loadPlugins()
{
Dirk Wilden's avatar
Dirk Wilden committed
162
  //try to load plugins from new location
163
  QDir tempDir = QDir(OpenFlipper::Options::pluginDir());
Dirk Wilden's avatar
Dirk Wilden committed
164

165 166 167 168 169
  // Possible Plugin extensions
  QStringList filter;
  if ( OpenFlipper::Options::isWindows() )
    filter << "*.dll";
  else if ( OpenFlipper::Options::isDarwin() )
Jan Möbius's avatar
Jan Möbius committed
170 171
    filter << "*.so";
//    filter << "*.dylib";
172 173 174
  else
    filter << "*.so";
  
175
  // Get all files in the Plugin dir
176
  QStringList pluginlist = tempDir.entryList(filter,QDir::Files);
Dirk Wilden's avatar
Dirk Wilden committed
177

178 179
  // Convert local file path to absolute path
  for (int i=0; i < pluginlist.size(); i++) {
180
     pluginlist[i] = tempDir.absoluteFilePath(pluginlist[i]);
181 182
  }

183 184 185 186 187 188 189 190 191 192 193
  // get all Plugin Names which will not be loaded
  QStringList dontLoadPlugins = OpenFlipperSettings().value("PluginControl/DontLoadNames").toStringList();
  
  // Output info about additional plugins
  for ( int i = 0 ; i < dontLoadPlugins.size(); ++i) 
    emit log(LOGOUT,tr("dontLoadPlugins Plugin from ini file: %1").arg( dontLoadPlugins[i] ) );
  
  // get all Plugins which should be loaded in addition to the standard plugins 
  QStringList additionalPlugins = OpenFlipperSettings().value("PluginControl/AdditionalPlugins").toStringList();
  
  // Output info about additional plugins
Jan Möbius's avatar
Jan Möbius committed
194
  for ( int i = 0 ; i < additionalPlugins.size(); ++i) {
195
    emit log(LOGOUT,tr("Additional Plugin from file: %1").arg( additionalPlugins[i] ) );
Jan Möbius's avatar
Jan Möbius committed
196
  }
197 198 199 200
  
  // Prepend the additional Plugins to the plugin list
  pluginlist = additionalPlugins << pluginlist;
  
201
  // Sort plugins to load FilePlugins first
202
  QStringList typePlugins;
203 204 205 206 207
  QStringList filePlugins;
  QStringList textureControl;
  QStringList otherPlugins;
  //plugin Liste sortieren
  for (int i=0; i < pluginlist.size(); i++)
208 209 210
    if (pluginlist[i].contains("Plugin-Type") )
      typePlugins.push_back(pluginlist[i]);
    else if (pluginlist[i].contains("Plugin-File") )
211 212 213 214 215 216
      filePlugins.push_back(pluginlist[i]);
    else if (pluginlist[i].contains("TextureControl"))
      textureControl.push_back(pluginlist[i]);
    else
      otherPlugins.push_back(pluginlist[i]);

217 218 219 220 221 222
  // This is the order in which plugins have to be loaded:
  // First load all type Plugins to register the dataTypes to the core
  // Than load the file plugins to load objects 
  // Next is textureControl to control texture based properties
  // Than load everything else.
  pluginlist = typePlugins << filePlugins << textureControl << otherPlugins;
223

224 225
  for ( int i = 0 ; i < dontLoadPlugins.size(); ++i )
    emit log(LOGWARN,tr("Skipping Plugins :\t %1").arg( dontLoadPlugins[i] ) );
226

227
  emit log(LOGOUT,"================================================================================");
228

Jan Möbius's avatar
Jan Möbius committed
229 230 231 232 233 234 235
  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)
236
  for ( int i = 0 ; i < pluginlist.size() ; ++i) {
Jan Möbius's avatar
Jan Möbius committed
237 238 239 240 241 242 243 244 245 246 247 248 249 250
    
    // 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) {
    
251
    if ( OpenFlipper::Options::gui() && OpenFlipperSettings().value("Core/Gui/splash",true).toBool() ) {
Jan Möbius's avatar
Jan Möbius committed
252
      splashMessage_ = tr("Loading Plugin %1/%2").arg(i).arg(loaderThreads.size()) ;
253 254 255
      splash_->showMessage( splashMessage_ , Qt::AlignBottom | Qt::AlignLeft , Qt::white);
      QApplication::processEvents();
    }
Jan Möbius's avatar
Jan Möbius committed
256 257 258 259 260 261 262 263 264 265 266 267
    
    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];
268 269 270 271 272 273
  }

  splashMessage_ = "";

  emit pluginsInitialized();

Jan Möbius's avatar
Jan Möbius committed
274
  emit log(LOGOUT,tr("Loaded %n Plugin(s)","",plugins.size()) );
275 276 277 278 279 280 281 282 283
}

/** @brief slot for loading Plugins
 */
void Core::slotLoadPlugin(){

  if ( OpenFlipper::Options::nogui() )
    return;

284
  // Setup filters for possible plugin extensions
285 286 287
  QString filter;
  if ( OpenFlipper::Options::isWindows() )
    filter = "Plugins (*.dll)";
288
  else if ( OpenFlipper::Options::isDarwin() )
Jan Möbius's avatar
Jan Möbius committed
289 290
    // filter = "Plugins (*.dylib)";
    filter = "Plugins (*.so)";
291 292 293
  else
    filter = "Plugins (*.so)";

294
  // Ask the user to select the file to load
295
  QString filename = ACG::getOpenFileName(coreWidget_,tr("Load Plugin"),filter, OpenFlipperSettings().value("Core/CurrentDir").toString() );
296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316

  if (filename.isEmpty())
    return;

  // get the plugin name
  // and check if Plugin is in the dontLoad List
  QPluginLoader loader( filename );
  QObject *plugin = loader.instance();
  QString name;

  // Check if a plugin has been loaded
  if (plugin) {
    // Check if it is a BasePlugin
    BaseInterface* basePlugin = qobject_cast< BaseInterface * >(plugin);
    if ( basePlugin ) {
      name = basePlugin->name();
    }else
      return;
  }else
    return;

317 318
  // Ask if the plugin is on the block list
  QStringList dontLoadPlugins = OpenFlipperSettings().value("PluginControl/DontLoadNames").toStringList();
319
  if (dontLoadPlugins.contains(name)){
320 321
      int ret = QMessageBox::question(0, tr("Plugin Loading Prevention"),
                   tr("OpenFlipper is currently configured to prevent loading this plugin.\n"
322
                      "Do you want to enable this plugin permanently?"),
323 324
                   QMessageBox::Yes | QMessageBox::No,
                   QMessageBox::Yes);
325 326 327 328 329
      if (ret == QMessageBox::Yes) {
        dontLoadPlugins.removeAll(name);
        OpenFlipperSettings().setValue("PluginControl/DontLoadNames",dontLoadPlugins);
      } else
         return;
330
  }
331 332 333 334 335 336 337 338 339 340 341 342 343 344 345
  
  // check if the plugin is not on the additional plugin list
  QStringList additionalPlugins = OpenFlipperSettings().value("PluginControl/AdditionalPlugins").toStringList();
  if (!additionalPlugins.contains(name)){
    int ret = QMessageBox::question(0, tr("Plugin Loading ..."),
                                       tr("Should OpenFlipper load this plugin on next startup?"),
                                    QMessageBox::Yes | QMessageBox::No,
                                    QMessageBox::Yes);
    if (ret == QMessageBox::Yes) {
      additionalPlugins << filename;
      std::cerr << "Added: " << filename.toStdString() << std::endl;
      OpenFlipperSettings().setValue("PluginControl/AdditionalPlugins",additionalPlugins);
    }
  }
  
346 347 348
  loadPlugin(filename,false);
}

Dirk Wilden's avatar
Dirk Wilden committed
349
/** @brief slot for showing loaded Plugins
350
 */
Dirk Wilden's avatar
Dirk Wilden committed
351
void Core::slotShowPlugins(){
352

Dirk Wilden's avatar
Dirk Wilden committed
353 354 355 356 357 358 359
  if ( OpenFlipper::Options::gui() ){

    int ret = 0;

    while (ret == 0){

      PluginDialog* dialog = new PluginDialog(plugins, coreWidget_);
360

Dirk Wilden's avatar
Dirk Wilden committed
361 362 363 364 365 366 367 368 369 370
      //connect signals
      connect(dialog, SIGNAL(unloadPlugin(QString)), this, SLOT(unloadPlugin(QString)));
      connect(dialog, SIGNAL( loadPlugin() ), this, SLOT( slotLoadPlugin() ));

      //if a plugin was deleted/loaded the dialog returns 0 and it needs to be loaded again
      ret = dialog->exec();

      delete dialog;
    }
  }
371 372 373 374 375 376 377
}

/** @brief Unload a Plugin with given name (slot)
 *  @param name plugin name
 */
void Core::unloadPlugin(QString name){
  for (uint i=0; i < plugins.size(); i++)
Dirk Wilden's avatar
Dirk Wilden committed
378
    if (plugins[i].rpcName == name){
379 380 381 382 383 384
      if ( checkSlot( plugins[i].plugin , "exit()" ) )
        QMetaObject::invokeMethod(plugins[i].plugin, "exit",  Qt::DirectConnection);

      //remove toolbox widget
      QString name_nospace = name;
      name_nospace.remove(" ");
Jan Möbius's avatar
Jan Möbius committed
385 386
      if ( coreWidget_->viewModes_[0]->visibleToolboxes.contains(name_nospace) )
        coreWidget_->viewModes_[0]->visibleToolboxes.removeAt(coreWidget_->viewModes_[0]->visibleToolboxes.indexOf(name_nospace));
387 388 389 390
      for ( uint j = 0 ; j < plugins[i].toolboxWidgets.size() ; ++j )
        if (plugins[i].toolboxWidgets[j].second ){
          plugins[i].toolboxWidgets[j].second->setVisible(false);
          delete plugins[i].toolboxWidgets[j].second;
391
        }
392 393 394

      plugins.erase(plugins.begin() + i);

Jan Möbius's avatar
Jan Möbius committed
395
      emit log(LOGOUT,tr("Unloaded Plugin :\t\t %1").arg( name) );
396 397 398 399

      return;
    }

Jan Möbius's avatar
Jan Möbius committed
400
    log(LOGERR, tr("Unable to unload plugin '%1' (plugin wasn't found)").arg(name));
401 402 403 404 405
}

/** @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
Jan Möbius's avatar
Jan Möbius committed
406
 *  @param _plugin You can provide a preloaded plugin here. If this is 0 the filename will be used to load the plugin.
407
 */
Jan Möbius's avatar
Jan Möbius committed
408
void Core::loadPlugin(QString filename, bool silent, QObject* _plugin){
409 410 411 412 413 414 415 416 417 418 419 420 421 422 423

  // Only load .dll under windows
  if ( OpenFlipper::Options::isWindows() ) {
    QString dllname = filename;
    if ( ! dllname.endsWith( ".dll" ) )
      return;
  }

  // Only load .so under linux
  if ( OpenFlipper::Options::isLinux() ) {
    QString soname = filename;
    if ( ! soname.endsWith( ".so" ) )
      return;
  }

Jan Möbius's avatar
Jan Möbius committed
424 425
  // This will be the reference to our plugin
  QObject *plugin = 0;
426

Jan Möbius's avatar
Jan Möbius committed
427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442
  // 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;
  }
  
443
  // Check if a plugin has been loaded
Jan Möbius's avatar
Jan Möbius committed
444 445
  PluginInfo info;
  QString supported;
446

Jan Möbius's avatar
Jan Möbius committed
447 448 449 450 451 452
  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()) );
453
    emit log(LOGOUT,tr("Location : \t %2").arg(filename) );
454

Jan Möbius's avatar
Jan Möbius committed
455 456 457 458 459
    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();
    }
460

Jan Möbius's avatar
Jan Möbius committed
461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484
    //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;
485 486
          }
        }
Dirk Wilden's avatar
Dirk Wilden committed
487
      }
Jan Möbius's avatar
Jan Möbius committed
488
    }
489

Jan Möbius's avatar
Jan Möbius committed
490 491 492 493 494 495 496
    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;
    }
497

Jan Möbius's avatar
Jan Möbius committed
498 499 500 501
    //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 ..."));
502

Jan Möbius's avatar
Jan Möbius committed
503 504
      bool success = false;
      QMetaObject::invokeMethod(plugin,"authenticate", Q_RETURN_ARG( bool , success ) ) ;
505

Jan Möbius's avatar
Jan Möbius committed
506 507 508 509 510 511
      if ( success )
        emit log(LOGINFO,tr("... ok. Loading plugin "));
      else {
        emit log(LOGERR,tr("... failed. Plugin access denied."));
        emit log(LOGOUT,"================================================================================");
        return;
512
      }
Jan Möbius's avatar
Jan Möbius committed
513
    }
514 515


Jan Möbius's avatar
Jan Möbius committed
516
    emit log(LOGOUT,tr("Plugin Desciption :\t %1 ").arg( basePlugin->description()) );
517

Jan Möbius's avatar
Jan Möbius committed
518
    supported = "BaseInterface ";
519

Jan Möbius's avatar
Jan Möbius committed
520 521 522 523
    info.name          = basePlugin->name();
    info.description   = basePlugin->description();
    info.plugin        = plugin;
    info.path          = filename;
524

Jan Möbius's avatar
Jan Möbius committed
525 526 527 528
    if ( checkSlot(plugin,"version()") )
      info.version = basePlugin->version();
    else
      info.version = QString::number(-1);
529

Jan Möbius's avatar
Jan Möbius committed
530
    if ( OpenFlipper::Options::nogui() ) {
531

Jan Möbius's avatar
Jan Möbius committed
532 533
      if ( ! checkSlot( plugin , "noguiSupported()" ) ) {
        emit log(LOGWARN,tr("Running in nogui mode which is unsupported by this plugin, skipping") );
534
        emit log(LOGOUT,"================================================================================");
535 536 537
        return;
      }

Jan Möbius's avatar
Jan Möbius committed
538
    }
539 540


Jan Möbius's avatar
Jan Möbius committed
541 542 543 544 545 546
    // 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;
    }
547

Jan Möbius's avatar
Jan Möbius committed
548 549 550 551 552
    if ( checkSignal(plugin,"update_view()") ) {
      log(LOGERR,tr("Plugin Uses old style update_view! Convert to updateView!"));
      emit log(LOGOUT,"================================================================================");
      return;
    }
553

Jan Möbius's avatar
Jan Möbius committed
554 555
    if ( checkSignal(plugin,"updateView()") )
      connect(plugin,SIGNAL(updateView()),this,SLOT(updateView()));
556

557

Jan Möbius's avatar
Jan Möbius committed
558
    if ( checkSignal(plugin,"updatedObject(int)") && checkSignal(plugin,"updatedObject(int,const UpdateType)") ){
559
      
Jan Möbius's avatar
Jan Möbius committed
560 561 562 563
      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 {
564

Jan Möbius's avatar
Jan Möbius committed
565 566 567
      if ( checkSignal(plugin,"updatedObject(int)") ){
        log(LOGWARN,tr("Plugin uses deprecated updatedObject."));
        connect(plugin,SIGNAL(updatedObject(int)),this,SLOT(slotObjectUpdated(int)), Qt::DirectConnection);
568
      }
Jan Möbius's avatar
Jan Möbius committed
569

Jan Möbius's avatar
Jan Möbius committed
570 571 572
      if ( checkSignal(plugin,"updatedObject(int,const UpdateType)") )
        connect(plugin,SIGNAL(updatedObject(int,const UpdateType)),this,SLOT(slotObjectUpdated(int,const UpdateType)), Qt::DirectConnection);
    }
Jan Möbius's avatar
Jan Möbius committed
573

Jan Möbius's avatar
Jan Möbius committed
574 575 576 577 578 579
    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 {
580

Jan Möbius's avatar
Jan Möbius committed
581 582 583
      if ( checkSlot( plugin , "slotObjectUpdated(int)" ) ){
        log(LOGWARN,tr("Plugin uses deprecated slotObjectUpdated."));
        connect(this,SIGNAL(signalObjectUpdated(int)),plugin,SLOT(slotObjectUpdated(int)), Qt::DirectConnection);
584
      }
585

Jan Möbius's avatar
Jan Möbius committed
586 587 588 589 590 591 592 593 594 595 596 597
      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);
598

Jan Möbius's avatar
Jan Möbius committed
599 600
    if ( checkSlot(plugin,"slotObjectPropertiesChanged(int)"))
      connect(this,SIGNAL(objectPropertiesChanged(int)),plugin,SLOT(slotObjectPropertiesChanged(int)), Qt::DirectConnection);
601

Jan Möbius's avatar
Jan Möbius committed
602 603
    if ( checkSignal(plugin,"visibilityChanged()" ) )
      emit log (LOGERR,tr("Signal visibilityChanged() now requires objectid or -1 as argument " ));
604

Jan Möbius's avatar
Jan Möbius committed
605 606 607 608 609 610 611 612 613
    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);
    
614

Jan Möbius's avatar
Jan Möbius committed
615 616
    if ( checkSlot(plugin,"slotVisibilityChanged(int)") )
      connect(this,SIGNAL(visibilityChanged(int)),plugin,SLOT(slotVisibilityChanged(int)), Qt::DirectConnection);
617

Jan Möbius's avatar
Jan Möbius committed
618 619
    if ( checkSignal(plugin,"activeObjectChanged()" ) )
      emit log (LOGERR,tr("Signal activeObjectChanged() is now objectSelectionChanged( int _objectId ) ") );
620

Jan Möbius's avatar
Jan Möbius committed
621 622
    if ( checkSlot(plugin,"slotActiveObjectChanged()" ) )
      emit log (LOGERR,tr("Slot slotActiveObjectChanged() is now slotObjectSelectionChanged( int _objectId ) ") );
623

Jan Möbius's avatar
Jan Möbius committed
624 625
    if ( checkSlot(plugin,"slotAllCleared()") )
      connect(this,SIGNAL(allCleared()),plugin,SLOT(slotAllCleared()));
626

627

Jan Möbius's avatar
Jan Möbius committed
628 629 630
    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!") );
631 632
    }

Jan Möbius's avatar
Jan Möbius committed
633 634
    if ( checkSlot( plugin , "slotObjectSelectionChanged(int)" ) )
      connect(this,SIGNAL(objectSelectionChanged(int)),plugin,SLOT(slotObjectSelectionChanged(int) ), Qt::DirectConnection);
635 636


Jan Möbius's avatar
Jan Möbius committed
637 638
    if ( checkSlot( plugin , "pluginsInitialized()" ) )
      connect(this,SIGNAL(pluginsInitialized()),plugin,SLOT(pluginsInitialized()), Qt::DirectConnection);
639

Jan Möbius's avatar
Jan Möbius committed
640 641 642 643
    if ( checkSignal(plugin,"setSlotDescription(QString,QString,QStringList,QStringList)") )
      connect(plugin, SIGNAL(setSlotDescription(QString,QString,QStringList,QStringList)),
              this,   SLOT(slotSetSlotDescription(QString,QString,QStringList,QStringList)) );
  }
644

Jan Möbius's avatar
Jan Möbius committed
645 646 647 648
  //Check if the plugin supports Logging
  LoggingInterface* logPlugin = qobject_cast< LoggingInterface * >(plugin);
  if ( logPlugin ) {
    supported = supported + "Logging ";
Dirk Wilden's avatar
Dirk Wilden committed
649

Jan Möbius's avatar
Jan Möbius committed
650 651 652 653 654
    // 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);
655

Jan Möbius's avatar
Jan Möbius committed
656 657 658
    // Connect it to the core widget logger
    if ( OpenFlipper::Options::gui() )
      connect(newlog,SIGNAL(log(Logtype, QString )),coreWidget_,SLOT(slotLog(Logtype, QString )),Qt::DirectConnection);
659

Jan Möbius's avatar
Jan Möbius committed
660 661
    // connection to console logger
    connect(newlog,SIGNAL(log(Logtype, QString )),this,SLOT(slotLog(Logtype, QString )),Qt::DirectConnection);
662

Jan Möbius's avatar
Jan Möbius committed
663 664
    // connection to file logger
    connect(newlog,SIGNAL(log(Logtype, QString )),this,SLOT(slotLogToFile(Logtype, QString )),Qt::DirectConnection);
665

Jan Möbius's avatar
Jan Möbius committed
666 667 668 669
    // connection to external plugin logger
    if ( checkSlot(plugin,"logOutput(Logtype,QString)") )
      connect(this,SIGNAL(externalLog(Logtype,QString)), plugin, SLOT(logOutput(Logtype,QString)) ) ;
  }
670

Jan Möbius's avatar
Jan Möbius committed
671 672 673 674 675 676 677 678 679 680 681 682
  //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);
  }
683

Jan Möbius's avatar
Jan Möbius committed
684 685 686 687
  //Check if the plugin supports ContextMenuInterface
  ContextMenuInterface* contextMenuPlugin = qobject_cast< ContextMenuInterface * >(plugin);
  if ( contextMenuPlugin && OpenFlipper::Options::gui() ) {
    supported = supported + "ContextMenu ";
688

Jan Möbius's avatar
Jan Möbius committed
689 690 691
    if ( checkSignal(plugin,"addContextMenuItem(QAction*,ContextMenuType)") )
      connect(plugin      , SIGNAL(addContextMenuItem(QAction*,ContextMenuType)),
              coreWidget_ , SLOT(slotAddContextItem(QAction*,ContextMenuType)),Qt::DirectConnection);
692

Jan Möbius's avatar
Jan Möbius committed
693 694 695
    if ( checkSignal(plugin,"addContextMenuItem(QAction*,DataType,ContextMenuType)") )
      connect(plugin      , SIGNAL(addContextMenuItem(QAction*,DataType,ContextMenuType)),
              coreWidget_ , SLOT(slotAddContextItem(QAction*,DataType,ContextMenuType)),Qt::DirectConnection);
696

Jan Möbius's avatar
Jan Möbius committed
697 698 699
    if ( checkSlot(plugin,"slotUpdateContextMenu(int)") )
      connect(coreWidget_ , SIGNAL(updateContextMenu(int)),
              plugin      , SLOT(slotUpdateContextMenu(int)),Qt::DirectConnection);
700

Jan Möbius's avatar
Jan Möbius committed
701 702 703
    if ( checkSlot(plugin,"slotUpdateContextMenuNode(int)") )
      connect(coreWidget_ , SIGNAL(updateContextMenuNode(int)),
              plugin      , SLOT(slotUpdateContextMenuNode(int)),Qt::DirectConnection);
704

Jan Möbius's avatar
Jan Möbius committed
705 706 707 708
    if ( checkSlot(plugin,"slotUpdateContextMenuBackground()") )
      connect(coreWidget_ , SIGNAL(updateContextMenuBackground()),
              plugin      , SLOT(slotUpdateContextMenuBackground()),Qt::DirectConnection);
  }
709

Jan Möbius's avatar
Jan Möbius committed
710 711 712 713
  //Check if the plugin supports Toolbox-Interface
  ToolboxInterface* toolboxPlugin = qobject_cast< ToolboxInterface * >(plugin);
  if ( toolboxPlugin && OpenFlipper::Options::gui() ) {
    supported = supported + "Toolbox ";
714

Dirk Wilden's avatar
Dirk Wilden committed
715

Jan Möbius's avatar
Jan Möbius committed
716 717 718
    if ( checkSignal(plugin, "addToolbox(QString,QWidget*)"))
      connect(plugin, SIGNAL( addToolbox(QString,QWidget*) ),
              this, SLOT( addToolbox(QString,QWidget*) ),Qt::DirectConnection );
719 720


721

Jan Möbius's avatar
Jan Möbius committed
722 723 724 725 726 727 728 729 730 731 732 733 734
  }
  
  //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) ),
Jan Möbius's avatar
Jan Möbius committed
735 736 737 738 739
              coreWidget_, SLOT( slotAddViewModeToolbars(QString, QStringList) ),Qt::DirectConnection );    
              
    if ( checkSignal(plugin, "defineViewModeContextMenus(QString,QStringList)"))
      connect(plugin, SIGNAL( defineViewModeContextMenus(QString, QStringList) ),
              coreWidget_, SLOT( slotAddViewModeContextMenus(QString, QStringList) ),Qt::DirectConnection );                
Jan Möbius's avatar
Jan Möbius committed
740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758
              
    if ( checkSignal(plugin, "defineViewModeIcon(QString,QString)"))
      connect(plugin, SIGNAL( defineViewModeIcon(QString, QString) ),
              coreWidget_, SLOT( slotSetViewModeIcon(QString, QString) ),Qt::DirectConnection );                          
              
  }    

  //Check if the plugin supports Options-Interface
  OptionsInterface* optionsPlugin = qobject_cast< OptionsInterface * >(plugin);
  if ( optionsPlugin && OpenFlipper::Options::gui() ) {
    supported = supported + "Options ";

    QWidget* widget = 0;
    if ( optionsPlugin->initializeOptionsWidget( widget ) ) {
          info.optionsWidget = widget;

          if ( checkSlot(plugin,"applyOptions()") )
            connect(coreWidget_ , SIGNAL( applyOptions() ),
                    plugin      , SLOT( applyOptions() ),Qt::DirectConnection);
759
    }
Jan Möbius's avatar
Jan Möbius committed
760
  }
761

Jan Möbius's avatar
Jan Möbius committed
762 763 764 765
  //Check if the plugin supports Toolbar-Interface
  ToolbarInterface* toolbarPlugin = qobject_cast< ToolbarInterface * >(plugin);
  if ( toolbarPlugin && OpenFlipper::Options::gui() ) {
    supported = supported + "Toolbars ";
766

Jan Möbius's avatar
Jan Möbius committed
767 768 769
    if ( checkSignal(plugin,"addToolbar(QToolBar*)") )
      connect(plugin,SIGNAL(addToolbar(QToolBar*)),
              coreWidget_,SLOT(slotAddToolbar(QToolBar*)),Qt::DirectConnection);
770

Jan Möbius's avatar
Jan Möbius committed
771 772 773
    if ( checkSignal(plugin,"removeToolbar(QToolBar*)") )
      connect(plugin,SIGNAL(removeToolbar(QToolBar*)),
              coreWidget_,SLOT(slotRemoveToolbar(QToolBar*)),Qt::DirectConnection);
774

Jan Möbius's avatar
Jan Möbius committed
775 776 777 778 779
    if ( checkSignal(plugin,"getToolBar(QString,QToolBar*&)") )
      connect(plugin,SIGNAL(getToolBar(QString,QToolBar*&)),
              coreWidget_,SLOT(getToolBar(QString,QToolBar*&)),Qt::DirectConnection);
        
  }
780

Jan Möbius's avatar
Jan Möbius committed
781 782 783 784
  //Check if the plugin supports StatusBar-Interface
  StatusbarInterface* statusbarPlugin = qobject_cast< StatusbarInterface * >(plugin);
  if ( statusbarPlugin && OpenFlipper::Options::gui() ) {
    supported = supported + "StatusBar ";
785

Jan Möbius's avatar
Jan Möbius committed
786 787 788
    if ( checkSignal(plugin,"showStatusMessage(QString,int)") )
      connect(plugin,SIGNAL(showStatusMessage(QString,int)),
              coreWidget_,SLOT(statusMessage(QString,int)),Qt::DirectConnection);
789

Dirk Wilden's avatar
Dirk Wilden committed
790

Jan Möbius's avatar
Jan Möbius committed
791 792 793
    if ( checkSignal(plugin,"setStatus(ApplicationStatus::applicationStatus)") )
      connect(plugin,SIGNAL(setStatus(ApplicationStatus::applicationStatus)),
              coreWidget_,SLOT(setStatus(ApplicationStatus::applicationStatus)),Qt::DirectConnection);
794

Jan Möbius's avatar
Jan Möbius committed
795 796 797 798 799 800 801
    if ( checkSignal(plugin,"clearStatusMessage()") )
      connect(plugin,SIGNAL(clearStatusMessage()),
              coreWidget_,SLOT(clearStatusMessage()));
              
    if ( checkSignal(plugin,"addWidgetToStatusbar(QWidget*)") )
      connect(plugin,SIGNAL(addWidgetToStatusbar(QWidget*)), coreWidget_,SLOT(addWidgetToStatusbar(QWidget*)));
  }
802

Jan Möbius's avatar
Jan Möbius committed
803 804 805 806
  //Check if the plugin supports Key-Interface
  KeyInterface* keyPlugin = qobject_cast< KeyInterface * >(plugin);
  if ( keyPlugin && OpenFlipper::Options::gui() ) {
    supported = supported + "KeyboardEvents ";
807

Jan Möbius's avatar
Jan Möbius committed
808 809 810 811
    if ( checkSignal(plugin,"registerKey(int,Qt::KeyboardModifiers,QString,bool)") )
      connect(plugin,SIGNAL( registerKey(int, Qt::KeyboardModifiers, QString, bool) ),
              coreWidget_,SLOT(slotRegisterKey(int, Qt::KeyboardModifiers, QString, bool)) );
  }
812

Jan Möbius's avatar
Jan Möbius committed
813 814 815 816
  //Check if the plugin supports Mouse-Interface
  MouseInterface* mousePlugin = qobject_cast< MouseInterface * >(plugin);
  if ( mousePlugin && OpenFlipper::Options::gui()  ) {
    supported = supported + "MouseEvents ";
817

Jan Möbius's avatar
Jan Möbius committed
818 819 820
    if ( checkSlot( plugin , "slotMouseWheelEvent(QWheelEvent*,const std::string&)" ) )
      connect(this   , SIGNAL(PluginWheelEvent(QWheelEvent * , const std::string & )),
              plugin , SLOT(slotMouseWheelEvent(QWheelEvent* , const std::string & )));
821

Jan Möbius's avatar
Jan Möbius committed
822 823 824
    if ( checkSlot( plugin , "slotMouseEvent(QMouseEvent*)" ) )
      connect(this   , SIGNAL(PluginMouseEvent(QMouseEvent*)),
              plugin , SLOT(slotMouseEvent(QMouseEvent*)));
825

Jan Möbius's avatar
Jan Möbius committed
826 827 828
    if ( checkSlot( plugin , "slotMouseEventIdentify(QMouseEvent*)" ) )
      connect(this   , SIGNAL(PluginMouseEventIdentify(QMouseEvent*)),
              plugin , SLOT(slotMouseEventIdentify(QMouseEvent*)));
829

Jan Möbius's avatar
Jan Möbius committed
830
  }
831

Jan Möbius's avatar
Jan Möbius committed
832 833 834 835
  //Check if the plugin supports Picking-Interface
  PickingInterface* pickPlugin = qobject_cast< PickingInterface * >(plugin);
  if ( pickPlugin && OpenFlipper::Options::gui() ) {
    supported = supported + "Picking ";
836

Jan Möbius's avatar
Jan Möbius committed
837 838 839
    if ( checkSlot( plugin , "slotPickModeChanged(const std::string&)" ) )
      connect(coreWidget_,SIGNAL(signalPickModeChanged (const std::string &)),
              plugin,SLOT(slotPickModeChanged( const std::string &)));
840

Jan Möbius's avatar
Jan Möbius committed
841 842 843
    if ( checkSignal(plugin,"addPickMode(const std::string)") )
      connect(plugin,SIGNAL(addPickMode( const std::string )),
              this,SLOT(slotAddPickMode( const std::string )),Qt::DirectConnection);
Jan Möbius's avatar
Jan Möbius committed
844

Jan Möbius's avatar
Jan Möbius committed
845 846 847
    if ( checkSignal(plugin,"addHiddenPickMode(const std::string)") )
      connect(plugin,SIGNAL(addHiddenPickMode( const std::string )),
              this,SLOT(slotAddHiddenPickMode( const std::string )),Qt::DirectConnection);
Jan Möbius's avatar
Jan Möbius committed
848

Jan Möbius's avatar
Jan Möbius committed
849 850 851 852
    if ( checkSignal(plugin,"setPickModeCursor(const std::string,QCursor)") )
      for ( uint i = 0 ; i < OpenFlipper::Options::examinerWidgets() ; ++i )
        connect(plugin,SIGNAL(setPickModeCursor( const std::string ,QCursor)),
                coreWidget_,SLOT(setPickModeCursor( const std::string ,QCursor)),Qt::DirectConnection);
Jan Möbius's avatar
Jan Möbius committed
853

Jan Möbius's avatar
Jan Möbius committed
854 855 856 857
    if ( checkSignal(plugin,"setPickModeMouseTracking(const std::string,bool)") )
      for ( uint i = 0 ; i < OpenFlipper::Options::examinerWidgets() ; ++i )
        connect(plugin,SIGNAL(setPickModeMouseTracking( const std::string ,bool)),
                coreWidget_,SLOT(setPickModeMouseTracking( const std::string ,bool)),Qt::DirectConnection);
858

Jan Möbius's avatar
Jan Möbius committed
859 860 861
    if ( checkSignal(plugin,"setPickModeToolbar(const std::string,QToolBar*)") )
      connect(plugin,SIGNAL(setPickModeToolbar (const std::string, QToolBar*)),
              coreWidget_,SLOT(setPickModeToolbar (const std::string, QToolBar*)),Qt::DirectConnection);
862

Jan Möbius's avatar
Jan Möbius committed
863 864 865
    if ( checkSignal(plugin,"removePickModeToolbar(const std::string)") )
      connect(plugin,SIGNAL(removePickModeToolbar( const std::string)),
              coreWidget_,SLOT(removePickModeToolbar( const std::string)),Qt::DirectConnection);
866

Jan Möbius's avatar
Jan Möbius committed
867
  }
868

Jan Möbius's avatar
Jan Möbius committed
869 870 871 872
  //Check if the plugin supports INI-Interface
  INIInterface* iniPlugin = qobject_cast< INIInterface * >(plugin);
  if ( iniPlugin ) {
    supported = supported + "INIFile ";
873

Jan Möbius's avatar
Jan Möbius committed
874 875 876
    if ( checkSlot( plugin , "loadIniFile(INIFile&,int)" ) )
      connect(this    , SIGNAL(iniLoad( INIFile&,int)),
              plugin  , SLOT( loadIniFile( INIFile&,int) ),Qt::DirectConnection);
877

Jan Möbius's avatar
Jan Möbius committed
878 879 880
    if ( checkSlot( plugin , "saveIniFile(INIFile&,int)" ) )
      connect(this    , SIGNAL(iniSave( INIFile& , int )),
              plugin  , SLOT( saveIniFile( INIFile& , int ) ),Qt::DirectConnection);
881

Jan Möbius's avatar
Jan Möbius committed
882 883 884
    if ( checkSlot( plugin , "saveIniFileOptions(INIFile&)" ) )
      connect(this    , SIGNAL(iniSaveOptions( INIFile& )),
              plugin  , SLOT( saveIniFileOptions( INIFile& ) ),Qt::DirectConnection);
885

Jan Möbius's avatar
Jan Möbius committed
886 887 888
    if ( checkSlot( plugin , "saveOnExit(INIFile&)" ) )
      connect(this    , SIGNAL(saveOnExit( INIFile& )),
              plugin  , SLOT( saveOnExit( INIFile& ) ),Qt::DirectConnection);
889

Jan Möbius's avatar
Jan Möbius committed
890 891 892
    if ( checkSlot( plugin , "loadIniFileOptions(INIFile&)" ) )
      connect(this    , SIGNAL(iniLoadOptions( INIFile& )),
              plugin  , SLOT( loadIniFileOptions( INIFile& ) ),Qt::DirectConnection);
Dirk Wilden's avatar
Dirk Wilden committed
893

Jan Möbius's avatar
Jan Möbius committed
894 895 896 897
    if ( checkSlot( plugin , "loadIniFileOptionsLast(INIFile&)" ) )
      connect(this    , SIGNAL(iniLoadOptionsLast( INIFile& )),
              plugin  , SLOT( loadIniFileOptionsLast( INIFile& ) ),Qt::DirectConnection);
  }
Dirk Wilden's avatar
Dirk Wilden committed
898

Jan Möbius's avatar
Jan Möbius committed
899 900 901 902
  //Check if the plugin supports Texture-Interface
  TextureInterface* texturePlugin = qobject_cast< TextureInterface * >(plugin);
  if ( texturePlugin && OpenFlipper::Options::gui() ) {
    supported = supported + "Textures ";
903

Jan Möbius's avatar
Jan Möbius committed
904 905 906
    if ( checkSignal(plugin,"addTexture(QString,QString,uint,int)") )
      connect(plugin , SIGNAL(addTexture( QString , QString , uint , int )),
              this   , SLOT(slotAddTexture(QString, QString, uint, int)),Qt::DirectConnection);
907

Jan Möbius's avatar
Jan Möbius committed
908 909 910
    if ( checkSlot( plugin , "slotTextureAdded(QString,QString,uint,int)" ) )
      connect(this   , SIGNAL(addTexture(QString,QString, uint, int)),
              plugin , SLOT(slotTextureAdded(QString,QString, uint, int)),Qt::DirectConnection);
911

Jan Möbius's avatar
Jan Möbius committed
912 913 914
    if ( checkSignal(plugin,"addTexture(QString,QString,uint)") )
      connect(plugin , SIGNAL(addTexture( QString , QString , uint )),
              this   , SLOT(slotAddTexture(QString, QString, uint)),Qt::DirectConnection);
915

Jan Möbius's avatar
Jan Möbius committed
916 917 918
    if ( checkSlot( plugin , "slotTextureAdded(QString,QString,uint)" ) )
      connect(this   , SIGNAL(addTexture(QString,QString, uint)),
              plugin , SLOT(slotTextureAdded(QString,QString, uint)),Qt::DirectConnection);
919

Jan Möbius's avatar
Jan Möbius committed
920 921 922
    if ( checkSignal(plugin,"updateTexture(QString,int)") )
      connect(plugin , SIGNAL(updateTexture( QString ,int )),
              this   , SLOT(slotUpdateTexture(QString , int)),Qt::DirectConnection);
923

Jan Möbius's avatar
Jan Möbius committed
924 925 926
    if ( checkSlot( plugin , "slotUpdateTexture(QString,int)" ) )
      connect(this   , SIGNAL(updateTexture(QString ,int)),
              plugin , SLOT(slotUpdateTexture(QString,int )),Qt::DirectConnection);
927

Jan Möbius's avatar
Jan Möbius committed
928 929 930
    if ( checkSignal(plugin,"updateAllTextures()") )
      connect(plugin , SIGNAL(updateAllTextures()),
              this   , SLOT(slotUpdateAllTextures()));
931

Jan Möbius's avatar
Jan Möbius committed
932 933 934
    if ( checkSlot( plugin , "slotUpdateAllTextures()" ) )
      connect(this   , SIGNAL(updateAllTextures()),
              plugin , SLOT(slotUpdateAllTextures()));
Dirk Wilden's avatar
Dirk Wilden committed
935

Jan Möbius's avatar
Jan Möbius committed
936 937 938
    if ( checkSignal(plugin,"updatedTextures(QString,int)") )
      connect(plugin , SIGNAL(updatedTextures( QString , int )),
              this   , SLOT(slotTextureUpdated( QString, int ) ),Qt::DirectConnection);
Dirk Wilden's avatar
Dirk Wilden committed
939

Jan Möbius's avatar
Jan Möbius committed
940 941 942
    if ( checkSlot( plugin , "slotTextureUpdated(QString,int)" ) )
      connect(this   , SIGNAL(updatedTextures( QString , int )),
              plugin , SLOT(slotTextureUpdated( QString, int ) ),Qt::DirectConnection);
943

Jan Möbius's avatar
Jan Möbius committed
944 945 946
    if ( checkSignal(plugin,"setTextureMode(QString,QString,int)") )
      connect(plugin , SIGNAL(setTextureMode(QString, QString, int )),
              this   , SLOT(slotSetTextureMode(QString, QString, int )),Qt::DirectConnection );
947

Jan Möbius's avatar
Jan Möbius committed
948 949 950
    if ( checkSlot( plugin , "slotSetTextureMode(QString,QString,int)" ) )
      connect(this   , SIGNAL(setTextureMode(QString, QString, int )),
              plugin , SLOT(slotSetTextureMode(QString, QString, int )),Qt::DirectConnection );
Dirk Wilden's avatar
Dirk Wilden committed
951

Jan Möbius's avatar
Jan Möbius committed
952 953 954
    if ( checkSignal(plugin,"setTextureMode(QString,QString)") )
      connect(plugin , SIGNAL(setTextureMode(QString  ,QString )),
              this   , SLOT(slotSetTextureMode(QString  ,QString )),Qt::DirectConnection );
Dirk Wilden's avatar
Dirk Wilden committed
955

Jan Möbius's avatar
Jan Möbius committed
956 957 958
    if ( checkSlot( plugin , "slotSetTextureMode(QString,QString)" ) )
      connect(this   , SIGNAL(setTextureMode(QString  ,QString )),
              plugin , SLOT(slotSetTextureMode(QString  ,QString )),Qt::DirectConnection );
959

Jan Möbius's avatar
Jan Möbius committed
960 961 962
    if ( checkSignal(plugin,"switchTexture(QString,int)") )
      connect(plugin , SIGNAL(switchTexture(QString, int )),
              this   , SLOT(slotSwitchTexture(QString, int )),Qt::DirectConnection);
963

Jan Möbius's avatar
Jan Möbius committed
964 965 966
    if ( checkSlot( plugin , "slotSwitchTexture(QString,int)" ) )
      connect(this   , SIGNAL(switchTexture(QString, int )),
              plugin , SLOT(slotSwitchTexture(QString, int )),Qt::DirectConnection);
967

Jan Möbius's avatar
Jan Möbius committed
968 969 970
    if ( checkSignal(plugin,"switchTexture(QString)") )
      connect(plugin , SIGNAL(switchTexture(QString )),
              this   , SLOT(slotSwitchTexture(QString )),Qt::DirectConnection);
971

Jan Möbius's avatar
Jan Möbius committed
972 973 974
    if ( checkSlot( plugin , "slotSwitchTexture(QString)" ) )
      connect(this   , SIGNAL(switchTexture(QString )),
              plugin , SLOT(slotSwitchTexture(QString )),Qt::DirectConnection);
975 976 977



Jan Möbius's avatar
Jan Möbius committed
978 979 980
    if ( checkSignal( plugin , "textureChangeImage(QString,QImage&,int)" ) )
      connect(plugin   , SIGNAL(textureChangeImage(QString,QImage&,int)),
              this , SLOT(slotTextureChangeImage(QString,QImage&,int)),Qt::DirectConnection);
981

Jan Möbius's avatar
Jan Möbius committed
982 983 984
    if ( checkSlot( plugin , "slotTextureChangeImage(QString,QImage&,int)" ) )
      connect(this   , SIGNAL(textureChangeImage(QString,QImage&,int)),
              plugin , SLOT(slotTextureChangeImage(QString,QImage&,int)),Qt::DirectConnection);
985

Jan Möbius's avatar
Jan Möbius committed
986 987 988
    if ( checkSignal( plugin , "textureChangeImage(QString,QImage&)" ) )
      connect(plugin   , SIGNAL(textureChangeImage(QString,QImage&)),
              this , SLOT(slotTextureChangeImage(QString,QImage&)),Qt::DirectConnection);
989

Jan Möbius's avatar
Jan Möbius committed
990 991 992
    if ( checkSlot( plugin , "slotTextureChangeImage(QString,QImage&)" ) )
      connect(this   , SIGNAL(textureChangeImage(QString,QImage&)),
              plugin , SLOT(slotTextureChangeImage(QString,QImage&)),Qt::DirectConnection);
993

Jan Möbius's avatar
Jan Möbius committed
994 995 996
    if ( checkSignal( plugin , "addMultiTexture(QString,QString,QString,int,int&)" ) )
      connect(plugin   , SIGNAL(addMultiTexture(QString,QString,QString,int,int&) ),
              this , SLOT(slotMultiTextureAdded(QString,QString,QString,int,int&) ),Qt::DirectConnection);
997

Jan Möbius's avatar
Jan Möbius committed
998 999 1000
    if ( checkSlot( plugin , "slotMultiTextureAdded( QString,QString,QString,int,int&)" ) )
      connect(this   , SIGNAL(addMultiTexture(QString,QString,QString,int,int&) ),
              plugin , SLOT(slotMultiTextureAdded( QString,QString,QString,int,int&) ),Qt::DirectConnection);
1001

1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017
    if ( checkSignal( plugin , "textureGetImage(QString,QImage&,int)" ) )
      connect(plugin   , SIGNAL(textureGetImage(QString,QImage&,int)),
              this ,   SLOT(slotTextureGetImage(QString,QImage&,int)),Qt::DirectConnection);

    if ( checkSlot( plugin , "slotTextureGetImage(QString,QImage&,int)" ) )
      connect(this   , SIGNAL(textureGetImage(QString,QImage&,int)),
              plugin , SLOT(slotTextureGetImage(QString,QImage&,int)),Qt::DirectConnection);

    if ( checkSignal( plugin , "textureGetImage(QString,QImage&)" ) )
      connect(plugin   , SIGNAL(textureGetImage(QString,QImage&)),
              this ,   SLOT(slotTextureGetImage(QString,QImage&)),Qt::DirectConnection);

    if ( checkSlot( plugin , "slotTextureGetImage(QString,QImage&)" ) )
      connect(this   , SIGNAL(textureGetImage(QString,QImage&)),
              plugin , SLOT(slotTextureGetImage(QString,QImage&)),Qt::DirectConnection);

1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033
    if ( checkSignal( plugin , "textureIndex(QString,int,int&)" ) )
      connect(plugin   , SIGNAL(textureIndex(QString,int,int&)),
              this ,   SLOT(slotTextureIndex(QString,int,int&)),Qt::DirectConnection);

    if ( checkSlot( plugin , "slotTextureIndex(QString,int,int&)" ) )
      connect(this   , SIGNAL(textureIndex(QString,int,int&)),
              plugin , SLOT(slotTextureIndex(QString,int,int&)),Qt::DirectConnection);

    if ( checkSignal( plugin , "textureName(int,int,QString&)" ) )
      connect(plugin   , SIGNAL(textureName(int,int,QString&)),
              this ,   SLOT(slotTextureName(int,int,QString&)),Qt::DirectConnection);

    if ( checkSlot( plugin , "slotTextureName(int,int,QString&)" ) )
      connect(this   , SIGNAL(textureName(int,int,QString&)),
              plugin , SLOT(slotTextureName(int,int,QString&)),Qt::DirectConnection);
              
1034 1035 1036
    if ( checkSignal( plugin , "getCurrentTexture(int,QString&)" ) )
      connect(plugin   , SIGNAL(getCurrentTexture(int,QString&)),
              this ,   SLOT(slotGetCurrentTexture(int,QString&)),Qt::DirectConnection);
1037

1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050
    if ( checkSlot( plugin , "slotGetCurrentTexture(int,QString&)" ) )
      connect(this   , SIGNAL(getCurrentTexture(int,QString&)),
              plugin , SLOT(slotGetCurrentTexture(int,QString&)),Qt::DirectConnection);

    if ( checkSignal( plugin , "getSubTextures(int,QString,QStringList&)" ) )
      connect(plugin   , SIGNAL(getSubTextures(int,QString,QStringList&)),
              this ,   SLOT(slotGetSubTextures(int,QString,QStringList&)),Qt::DirectConnection);

    if ( checkSlot( plugin , "slotGetSubTextures(int,QString,QStringList&)" ) )
      connect(this   , SIGNAL(getSubTextures(int,QString,QStringList&)),
              plugin , SLOT(slotGetSubTextures(int,QString,QStringList&)),Qt::DirectConnection);
  }
              
Jan Möbius's avatar
Jan Möbius committed
1051 1052 1053 1054
  //Check if the plugin supports Backup-Interface
  BackupInterface* backupPlugin = qobject_cast< BackupInterface * >(plugin);
  if ( backupPlugin ) {
    supported = supported + "Backups ";
1055

Jan Möbius's avatar
Jan Möbius committed
1056 1057 1058
    if ( checkSignal( plugin , "createBackup(int,QString)" ) )
      connect(plugin , SIGNAL(createBackup( int , QString )) ,
              this   , SLOT(backupRequest( int , QString )),Qt::DirectConnection );
1059

Jan Möbius's avatar
Jan Möbius committed
1060 1061 1062 1063
    if ( checkSlot( plugin , "slotBackupRequested(int,QString,int)" ) )
      connect(this   , SIGNAL(createBackup(int,QString,int)) ,
              plugin , SLOT( slotBackupRequested(int,QString,int) ),Qt::DirectConnection);
  }
1064

Jan Möbius's avatar
Jan Möbius committed
1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116
  //Check if the plugin supports LoadSave-Interface
  LoadSaveInterface* LoadSavePlugin = qobject_cast< LoadSaveInterface * >(plugin);
  if ( LoadSavePlugin ) {
    supported = supported + "Load/Save ";
    if ( checkSignal(plugin,"load( QString,DataType,int& )" ) )
      connect(plugin , SIGNAL(load( QString,DataType,int& )) ,
              this   , SLOT(slotLoad( QString,DataType,int& )),Qt::DirectConnection );
    if ( checkSignal(plugin,"save(int,QString)" ) )
      connect(plugin , SIGNAL( save(int,QString) ) ,
              this   , SLOT( saveObject(int,QString) ), Qt::DirectConnection);

    if ( checkSlot( plugin , "fileOpened(int)" ) )
      connect(this   , SIGNAL( openedFile( int) ) ,
              plugin , SLOT( fileOpened( int ) ),Qt::DirectConnection);

    if ( checkSignal(plugin,"openedFile(int)" ) )
      connect(plugin , SIGNAL( openedFile( int ) ) ,
              this   , SLOT( slotObjectOpened ( int ) ),Qt::DirectConnection);

    if ( checkSignal(plugin,"addEmptyObject(DataType,int&)" ) )
      connect(plugin , SIGNAL( addEmptyObject( DataType, int& )) ,
              this   , SLOT( slotAddEmptyObject( DataType, int&) ),Qt::DirectConnection);

    if ( checkSignal(plugin,"copyObject(int,int&)" ) )
      connect(plugin , SIGNAL( copyObject( int, int& )) ,
              this   , SLOT( slotCopyObject( int, int&) ),Qt::DirectConnection);

    // Plugins to core
    if ( checkSignal(plugin,"emptyObjectAdded(int)" ) )
      connect(plugin , SIGNAL( emptyObjectAdded( int ) ) ,
              this   , SLOT( slotEmptyObjectAdded ( int ) ),Qt::DirectConnection);

    // core to plugins
    if ( checkSlot(plugin,"addedEmptyObject(int)" ) )
      connect(this ,   SIGNAL( emptyObjectAdded( int ) ) ,
              plugin   , SLOT( addedEmptyObject( int ) ),Qt::DirectConnection);

    if ( checkSignal(plugin,"getAllFilters(QStringList&)" ) )
      connect(plugin , SIGNAL( getAllFilters( QStringList& ) ) ,
              this   , SLOT( slotGetAllFilters ( QStringList& ) ),Qt::DirectConnection);

    if ( checkSignal(plugin,"deleteObject(int)" ) )
      connect(plugin , SIGNAL( deleteObject( int ) ) ,
              this   , SLOT( slotDeleteObject( int ) ),Qt::DirectConnection);

    if ( checkSignal(plugin,"deleteAllObjects()" ) )
      connect(plugin , SIGNAL( deleteAllObjects() ) ,
              this   , SLOT( slotDeleteAllObjects() ),Qt::DirectConnection);

    if ( checkSlot(plugin,"objectDeleted(int)" ) )
      connect(this ,   SIGNAL( objectDeleted( int ) ) ,
              plugin   , SLOT( objectDeleted( int ) ),Qt::DirectConnection);
1117

Jan Möbius's avatar
Jan Möbius committed
1118
  }
1119

Jan Möbius's avatar
Jan Möbius committed
1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170
  //Check if the plugin supports View-Interface
  ViewInterface* viewPlugin = qobject_cast< ViewInterface * >(plugin);
  if ( viewPlugin  && OpenFlipper::Options::gui() ) {
    supported = supported + "View ";

    if ( checkSignal(plugin,"getStackWidget(QString,QWidget*&)" ) )
      connect(plugin      , SIGNAL(getStackWidget( QString , QWidget*&)),
              coreWidget_ , SLOT( slotGetStackWidget( QString , QWidget*& ) ) ,Qt::DirectConnection );
    if ( checkSignal(plugin,"addStackWidget(QString,QWidget*)" ) )
      connect(plugin      , SIGNAL(addStackWidget( QString , QWidget*)),
              coreWidget_ , SLOT( slotAddStackWidget( QString , QWidget* ) ) ,Qt::DirectConnection );
    if ( checkSignal(plugin,"updateStackWidget(QString,QWidget*)" ) )
      connect(plugin      , SIGNAL(updateStackWidget( QString , QWidget*)),
              coreWidget_ , SLOT( slotUpdateStackWidget( QString , QWidget* ) ) ,Qt::DirectConnection );
  }
  
  //Check if the plugin supports Process-Interface
  ProcessInterface* processPlugin = qobject_cast< ProcessInterface * >(plugin);
  if ( processPlugin ) {
    supported = supported + "Process ";

    if ( checkSignal(plugin,"startJob(QString,QString,int,int,bool)" ) )
      connect(plugin      , SIGNAL(startJob(QString, QString,int,int,bool)),
              this , SLOT( slotStartJob(QString, QString,int,int,bool) ), Qt::DirectConnection );
    else
      emit log(LOGERR,"Process Interface defined but no startJob signal found!");  
              
    if ( checkSignal(plugin,"setJobState(QString,int)" ) )
      connect(plugin      , SIGNAL(setJobState(QString,int)),
              this , SLOT( slotSetJobState(QString,int) ), Qt::QueuedConnection );
    else
      emit log(LOGERR,"Process Interface defined but no setJobState signal found!");
    
    if ( checkSignal(plugin,"setJobName(QString,QString)" ) )
      connect(plugin ,      SIGNAL(setJobName(QString, QString)),
              this , SLOT( slotSetJobName(QString, QString) ), Qt::QueuedConnection );
    else
      emit log(LOGERR,"Process Interface defined but no setJobName signal found!");
    
    if ( checkSignal(plugin,"setJobDescription(QString,QString)" ) )
      connect(plugin ,      SIGNAL(setJobDescription(QString, QString)),
              this , SLOT( slotSetJobDescription(QString, QString) ), Qt::QueuedConnection );
    else
      emit log(LOGERR,"Process Interface defined but no setJobDescription signal found!");  
              
    if ( checkSignal(plugin,"cancelJob(QString)" ) )
      connect(plugin      , SIGNAL(cancelJob(QString)),
              this , SLOT( slotCancelJob(QString) ), Qt::QueuedConnection );
              
    if ( checkSignal(plugin,"finishJob(QString)" ) )
      connect(plugin      , SIGNAL(finishJob(QString)),
1171
              this , SLOT( slotFinishJob(QString) ), Qt::QueuedConnection );
Jan Möbius's avatar
Jan Möbius committed
1172 1173 1174 1175 1176 1177 1178 1179 1180 1181
    else
      emit log(LOGERR,"Process Interface defined but no finishJob signal found!");                
              
              
    if ( checkSlot(plugin,"canceledJob(QString)" ) ) 
      connect(this ,   SIGNAL( jobCanceled( QString ) ) ,
            plugin   , SLOT( canceledJob(QString) ),Qt::DirectConnection);                
    else
      emit log(LOGERR,"Process Interface defined but no cancel canceledJob slot found!");
  }
1182

Jan Möbius's avatar
Jan Möbius committed
1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203
  //Check if the plugin supports RPC-Interface
  RPCInterface* rpcPlugin = qobject_cast< RPCInterface * >(plugin);
  if ( rpcPlugin ) {
    supported = supported + "RPC ";

    if ( checkSignal(plugin,"pluginExists(QString,bool&)" ) )
      connect(plugin  , SIGNAL( pluginExists(QString,bool&) ),
              this    , SLOT( slotPluginExists(QString,bool&) ) ,Qt::DirectConnection );
    if ( checkSignal(plugin,"functionExists(QString,QString,bool&)" ) )
      connect(plugin  , SIGNAL(functionExists(QString,QString,bool&)),
              this    , SLOT( slotFunctionExists(QString,QString,bool&) ) ,Qt::DirectConnection );
    if ( checkSignal(plugin,"call(QString,QString,bool&)" ) )
      connect(plugin  , SIGNAL(call(QString,QString,bool&)),
              this    , SLOT(slotCall(QString,QString,bool&)) ,Qt::DirectConnection );
    if ( checkSignal(plugin,"call(QString,bool&)" ) )
      connect(plugin  , SIGNAL(call(QString,bool&)),
              this    , SLOT(slotCall(QString,bool&)) ,Qt::DirectConnection );
    if ( checkSignal(plugin,"getValue(QString,QVariant&)" ) )
      connect(plugin  , SIGNAL(getValue(QString,QVariant&)),
              this    , SLOT(slotGetValue(QString,QVariant&)) ,Qt::DirectConnection );
  }
1204

Jan Möbius's avatar
Jan Möbius committed
1205 1206
  //========================================================================================
  // ===          Collect Scripting Information for Plugin      ============================
1207

Jan Möbius's avatar
Jan Möbius committed
1208 1209 1210 1211 1212 1213
  QScriptValue scriptInstance = scriptEngine_.newQObject(plugin,
                                                          QScriptEngine::QtOwnership,
                                                          QScriptEngine::ExcludeChildObjects |
                                                          QScriptEngine::ExcludeSuperClassMethods |
                                                          QScriptEngine::ExcludeSuperClassProperties
                                                          );
1214

Jan Möbius's avatar
Jan Möbius committed
1215 1216
  // Make plugin available for scripting
  QString scriptingName = info.name.remove(" ").toLower();
1217

Jan Möbius's avatar
Jan Möbius committed
1218
  scriptEngine_.globalObject().setProperty(scriptingName, scriptInstance);
1219

Jan Möbius's avatar
Jan Möbius committed
1220
  info.rpcName = scriptingName;
1221

Jan Möbius's avatar
Jan Möbius committed
1222 1223 1224
  QScriptValueIterator it(scriptInstance);
  while (it.hasNext()) {
    it.next();
1225

Jan Möbius's avatar
Jan Möbius committed
1226 1227 1228
    /// Skip all signals for function calls
    if ( checkSignal( plugin, it.name().toAscii() ) )
      continue;
1229

Jan Möbius's avatar
Jan Möbius committed
1230
    info.rpcFunctions.push_back( it.name() );
1231

Jan Möbius's avatar
Jan Möbius committed
1232
    scriptingFunctions_.push_back( scriptingName + "." + it.name() );
1233

Jan Möbius's avatar
Jan Möbius committed
1234
  }
1235

Jan Möbius's avatar
Jan Möbius committed
1236 1237 1238 1239
  //Check if the plugin supports RPC-Interface
  ScriptInterface* scriptPlugin = qobject_cast< ScriptInterface * >(plugin);
  if ( scriptPlugin ) {
    supported = supported + "Scripting ";
1240

Jan Möbius's avatar
Jan Möbius committed
1241 1242 1243
    // Create intermediate wrapper class which will mangle the call information
    ScriptingWrapper* newScript = new ScriptingWrapper(info.rpcName);
    scriptingWrappers_.push_back(newScript);
1244

Jan Möbius's avatar
Jan Möbius committed
1245
    //========= Part one, Scriptinfos via wrapper to core and than to scipting Plugin ==========
1246

Jan Möbius's avatar
Jan Möbius committed
1247
    if ( checkSignal(plugin,"scriptInfo(QString)" ) ) {
1248

Jan Möbius's avatar
Jan Möbius committed
1249 1250 1251
      // Plugin to wrapper
      connect(plugin    , SIGNAL( scriptInfo(QString) ),
              newScript , SLOT( slotScriptInfo(QString) ) ,Qt::DirectConnection );
1252

Jan Möbius's avatar
Jan Möbius committed
1253 1254 1255 1256
      // wrapper to core
      connect(newScript , SIGNAL( scriptInfo(QString,QString) ),
              this      , SLOT( slotScriptInfo(QString,QString) ));
    }
1257

Jan Möbius's avatar
Jan Möbius committed
1258 1259 1260 1261 1262
    // Core to plugins ( normally only one scripting plugin)
    if ( checkSlot(plugin,"slotScriptInfo(QString,QString)") ) {
      connect(this      , SIGNAL(scriptInfo(QString,QString)),
              plugin    , SLOT(slotScriptInfo(QString,QString)));
    }
1263

Jan Möbius's avatar
Jan Möbius committed
1264 1265 1266 1267
    // Function descriptions
    if ( checkSignal(plugin,"getDescription(QString,QString&,QStringList&,QStringList&)") )
      connect(plugin    , SIGNAL( getDescription(QString,QString&,QStringList&,QStringList&) ),
              this      , SLOT( slotGetDescription(QString,QString&,QStringList&,QStringList&) ));
1268

Jan Möbius's avatar
Jan Möbius committed
1269
    //========= Script Execution ==========
1270

Jan Möbius's avatar
Jan Möbius committed
1271 1272 1273 1274
    // Plugins to Core
    if ( checkSignal(plugin,"executeScript(QString)") )
      connect(plugin      , SIGNAL(executeScript(QString)),
              this       , SLOT(slotExecuteScript(QString)));
1275

Jan Möbius's avatar
Jan Möbius committed
1276 1277 1278 1279
    // Core to plugins ( normally only one scripting plugin)
    if ( checkSlot(plugin,"slotExecuteScript(QString)") )
      connect(this      , SIGNAL