PluginLoader.cc 70.3 KB
Newer Older
1
/*===========================================================================*\
Jan Möbius's avatar
Jan Möbius committed
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
*                                                                            *
*                              OpenFlipper                                   *
*      Copyright (C) 2001-2010 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/>.                                       *
*                                                                            *
33 34 35
\*===========================================================================*/

/*===========================================================================*\
Jan Möbius's avatar
Jan Möbius committed
36 37
*                                                                            *
*   $Revision$                                                       *
38
*   $LastChangedBy$                                         *
Jan Möbius's avatar
Jan Möbius committed
39 40
*   $Date$                     *
*                                                                            *
41
\*===========================================================================*/
Jan Möbius's avatar
 
Jan Möbius committed
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>
Jan Möbius's avatar
 
Jan Möbius committed
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"
Jan Möbius's avatar
 
Jan Möbius committed
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"
Jan Möbius's avatar
 
Jan Möbius committed
78
#include "OpenFlipper/BasePlugin/ViewInterface.hh"
Jan Möbius's avatar
Jan Möbius committed
79
#include "OpenFlipper/BasePlugin/ViewModeInterface.hh"
Jan Möbius's avatar
 
Jan Möbius committed
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
#include "OpenFlipper/BasePlugin/PluginConnectionInterface.hh"
Jan Möbius's avatar
 
Jan Möbius committed
89 90 91 92 93 94 95 96 97

#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
98
#include "OpenFlipper/widgets/PluginDialog/PluginDialog.hh"
Jan Möbius's avatar
 
Jan Möbius committed
99

Jan Möbius's avatar
Jan Möbius committed
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 143
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_;
};


Jan Möbius's avatar
 
Jan Möbius committed
144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162
//== 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()
{
Jan Möbius's avatar
Jan Möbius committed
163 164 165
  
  QString licenseTexts = "";
  
Dirk Wilden's avatar
Dirk Wilden committed
166
  //try to load plugins from new location
167
  QDir tempDir = QDir(OpenFlipper::Options::pluginDir());
Dirk Wilden's avatar
Dirk Wilden committed
168

169 170 171 172 173
  // 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
174 175
    filter << "*.so";
//    filter << "*.dylib";
176 177 178
  else
    filter << "*.so";
  
Jan Möbius's avatar
 
Jan Möbius committed
179
  // Get all files in the Plugin dir
180
  QStringList pluginlist = tempDir.entryList(filter,QDir::Files);
Dirk Wilden's avatar
Dirk Wilden committed
181

182 183
  // Convert local file path to absolute path
  for (int i=0; i < pluginlist.size(); i++) {
184
     pluginlist[i] = tempDir.absoluteFilePath(pluginlist[i]);
Jan Möbius's avatar
 
Jan Möbius committed
185 186
  }

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

221 222 223 224 225 226
  // 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;
Jan Möbius's avatar
 
Jan Möbius committed
227

228 229
  for ( int i = 0 ; i < dontLoadPlugins.size(); ++i )
    emit log(LOGWARN,tr("Skipping Plugins :\t %1").arg( dontLoadPlugins[i] ) );
Jan Möbius's avatar
 
Jan Möbius committed
230

231
  emit log(LOGOUT,"================================================================================");
Jan Möbius's avatar
 
Jan Möbius committed
232

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

  splashMessage_ = "";
Jan Möbius's avatar
Jan Möbius committed
277 278
  
  if ( licenseTexts != "" ) {
Jan Möbius's avatar
Jan Möbius committed
279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327
    if ( OpenFlipper::Options::gui() ) {
      
      // split for each license block
      QStringList licenseBlocks = licenseTexts.split("==");

      // Cleanup lists to get only the ones containing valid plugins.
      for ( QStringList::iterator it = licenseBlocks.begin(); it != licenseBlocks.end() ; ++it )
        if ( ! it->contains("PluginName") ) {
          licenseBlocks.erase(it);
          it = licenseBlocks.begin();
        }
      
      // sort by the contact mails
      QMap< QString , QString > contacts;
      
      for ( QStringList::iterator it = licenseBlocks.begin(); it != licenseBlocks.end() ; ++it ) {
        QStringList lines = it->split("\n");
        
        lines = lines.filter ( "Contact mail", Qt::CaseInsensitive );
        
        // Corect one found:
        if (lines.size() == 1)  {
          QString mail = lines[0].section(":",-1).simplified();
          QString list = contacts.take(mail);
          list.append(*it);
          contacts.insert(mail,list);
        } else {
          emit log(LOGWARN,tr("Can't extract mail contact from license request"));
        }
          
      }
      
      for ( QMap<QString , QString>::iterator it = contacts.begin() ; it != contacts.end() ; ++it ) {
        
        QStringList request = it.value().split("\n");
        
        // Cleanup lists to get only the relevant part
        for ( QStringList::iterator lit = request.begin(); lit != request.end() ; ++lit ) {
          
          if ( lit->contains("Message:")  ) {
            *lit = lit->section(":",-1).simplified();
          }
          
          if ( lit->contains("Contact mail:")  ) {
            *lit = lit->section(":",-1).simplified();
          }
          
        }
        
Jan Möbius's avatar
Jan Möbius committed
328
        QMessageBox::StandardButton button = QMessageBox::warning ( 0, tr("Plugin License check failed, issuer is: %1").arg( it.key() ),  request.join("\n") + tr("\n\n The text has been copied to your clipboard.\n Open in Mail program?"),QMessageBox::Yes | QMessageBox::No,QMessageBox::Yes  );
Jan Möbius's avatar
Jan Möbius committed
329
        
Jan Möbius's avatar
Jan Möbius committed
330 331 332 333 334
        
        QClipboard *cb = QApplication::clipboard();
        
        // set a text to the Clipboard
        cb->setText(request.join("\n"));
Jan Möbius's avatar
Jan Möbius committed
335 336


337 338 339 340 341 342 343 344
        if ( button == QMessageBox::Yes ) {
           QString url = "mailto:" + it.key();
           url += "?subject=License Request&body=";
#ifdef WIN32
           url += request.join(";;");
#else
           url += request.join("\n");
#endif
Jan Möbius's avatar
Jan Möbius committed
345

346 347 348
           QUrl encodedURL(url, QUrl::TolerantMode);
           QDesktopServices::openUrl(encodedURL);
        }
Jan Möbius's avatar
Jan Möbius committed
349 350 351 352 353 354
        
      }

      
    } else {
      emit log(LOGWARN,tr("Plugin License check failed: "));
Jan Möbius's avatar
Jan Möbius committed
355 356 357
      std::cerr << licenseTexts.toStdString() << std::endl;
    }
  } 
Jan Möbius's avatar
 
Jan Möbius committed
358 359 360

  emit pluginsInitialized();

Jan Möbius's avatar
Jan Möbius committed
361
  emit log(LOGOUT,tr("Loaded %n Plugin(s)","",plugins.size()) );
Jan Möbius's avatar
 
Jan Möbius committed
362 363 364 365 366 367 368 369 370
}

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

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

371
  // Setup filters for possible plugin extensions
Jan Möbius's avatar
 
Jan Möbius committed
372 373 374
  QString filter;
  if ( OpenFlipper::Options::isWindows() )
    filter = "Plugins (*.dll)";
375
  else if ( OpenFlipper::Options::isDarwin() )
Jan Möbius's avatar
Jan Möbius committed
376 377
    // filter = "Plugins (*.dylib)";
    filter = "Plugins (*.so)";
Jan Möbius's avatar
 
Jan Möbius committed
378 379 380
  else
    filter = "Plugins (*.so)";

381
  // Ask the user to select the file to load
382
  QString filename = ACG::getOpenFileName(coreWidget_,tr("Load Plugin"),filter, OpenFlipperSettings().value("Core/CurrentDir").toString() );
Jan Möbius's avatar
 
Jan Möbius committed
383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403

  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;

404
  // Ask if the plugin is on the block list
405
  QStringList dontLoadPlugins = OpenFlipperSettings().value("PluginControl/DontLoadNames", QStringList()).toStringList();
406
  if (dontLoadPlugins.contains(name)){
Jan Möbius's avatar
 
Jan Möbius committed
407 408
      int ret = QMessageBox::question(0, tr("Plugin Loading Prevention"),
                   tr("OpenFlipper is currently configured to prevent loading this plugin.\n"
409
                      "Do you want to enable this plugin permanently?"),
Jan Möbius's avatar
 
Jan Möbius committed
410 411
                   QMessageBox::Yes | QMessageBox::No,
                   QMessageBox::Yes);
412 413 414 415 416
      if (ret == QMessageBox::Yes) {
        dontLoadPlugins.removeAll(name);
        OpenFlipperSettings().setValue("PluginControl/DontLoadNames",dontLoadPlugins);
      } else
         return;
Jan Möbius's avatar
 
Jan Möbius committed
417
  }
418 419
  
  // check if the plugin is not on the additional plugin list
420
  QStringList additionalPlugins = OpenFlipperSettings().value("PluginControl/AdditionalPlugins", QStringList()).toStringList();
421 422 423 424 425 426 427 428 429 430 431 432
  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);
    }
  }
  
Jan Möbius's avatar
Jan Möbius committed
433 434 435 436
  QString licenseText = "";
  loadPlugin(filename,false,licenseText);
  
  if ( licenseText != "" ) {
Jan Möbius's avatar
Jan Möbius committed
437
    if ( OpenFlipper::Options::gui() ) {
Jan Möbius's avatar
Jan Möbius committed
438
      QMessageBox::warning ( 0, tr("Plugin License check failed"),  licenseText );
Jan Möbius's avatar
Jan Möbius committed
439 440 441 442
      
      std::cerr << "OpenURL: " << std::endl;
      QDesktopServices::openUrl(QUrl(tr("mailto:contact@openflipper.com?subject=License Request&body=%1").arg(licenseText), QUrl::TolerantMode));
    } else {
Jan Möbius's avatar
Jan Möbius committed
443 444 445
      std::cerr << "Plugin License check failed" << std::endl;
      std::cerr << licenseText.toStdString() << std::endl;
    }
446
  }
Jan Möbius's avatar
 
Jan Möbius committed
447 448
}

Dirk Wilden's avatar
Dirk Wilden committed
449
/** @brief slot for showing loaded Plugins
Jan Möbius's avatar
 
Jan Möbius committed
450
 */
Dirk Wilden's avatar
Dirk Wilden committed
451
void Core::slotShowPlugins(){
Jan Möbius's avatar
 
Jan Möbius committed
452

Dirk Wilden's avatar
Dirk Wilden committed
453 454 455 456 457 458 459
  if ( OpenFlipper::Options::gui() ){

    int ret = 0;

    while (ret == 0){

      PluginDialog* dialog = new PluginDialog(plugins, coreWidget_);
Jan Möbius's avatar
 
Jan Möbius committed
460

Dirk Wilden's avatar
Dirk Wilden committed
461 462 463 464 465 466 467 468 469 470
      //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;
    }
  }
Jan Möbius's avatar
 
Jan Möbius committed
471 472 473 474 475 476 477
}

/** @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
478
    if (plugins[i].rpcName == name){
Jan Möbius's avatar
 
Jan Möbius committed
479 480 481 482 483 484
      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
485 486
      if ( coreWidget_->viewModes_[0]->visibleToolboxes.contains(name_nospace) )
        coreWidget_->viewModes_[0]->visibleToolboxes.removeAt(coreWidget_->viewModes_[0]->visibleToolboxes.indexOf(name_nospace));
487 488 489 490
      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;
491
        }
Jan Möbius's avatar
 
Jan Möbius committed
492 493 494

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

Jan Möbius's avatar
Jan Möbius committed
495
      emit log(LOGOUT,tr("Unloaded Plugin :\t\t %1").arg( name) );
Jan Möbius's avatar
 
Jan Möbius committed
496 497 498 499

      return;
    }

Jan Möbius's avatar
Jan Möbius committed
500
    log(LOGERR, tr("Unable to unload plugin '%1' (plugin wasn't found)").arg(name));
Jan Möbius's avatar
 
Jan Möbius committed
501 502 503 504 505
}

/** @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
506
 *  @param _licenseErrors String will be epty when no license issues occured, otherwise it contains the required information for obtaining a license
Jan Möbius's avatar
Jan Möbius committed
507
 *  @param _plugin You can provide a preloaded plugin here. If this is 0 the filename will be used to load the plugin.
Jan Möbius's avatar
 
Jan Möbius committed
508
 */
Jan Möbius's avatar
Jan Möbius committed
509
void Core::loadPlugin(QString filename, bool silent, QString& _licenseErrors, QObject* _plugin){
Jan Möbius's avatar
 
Jan Möbius committed
510

Jan Möbius's avatar
Jan Möbius committed
511 512
  _licenseErrors = "";
  
Jan Möbius's avatar
 
Jan Möbius committed
513 514 515 516 517 518 519 520 521 522 523 524 525 526
  // 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
527 528
  // This will be the reference to our plugin
  QObject *plugin = 0;
Jan Möbius's avatar
 
Jan Möbius committed
529

Jan Möbius's avatar
Jan Möbius committed
530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545
  // 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;
  }
  
Jan Möbius's avatar
 
Jan Möbius committed
546
  // Check if a plugin has been loaded
Jan Möbius's avatar
Jan Möbius committed
547 548
  PluginInfo info;
  QString supported;
Jan Möbius's avatar
 
Jan Möbius committed
549

Jan Möbius's avatar
Jan Möbius committed
550
  emit log(LOGOUT,tr("Location : \t %1").arg(filename) );
Jan Möbius's avatar
Jan Möbius committed
551 552 553 554 555
  
  // 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()) );
Dirk Wilden's avatar
Dirk Wilden committed
556
    emit log(LOGOUT,tr("Location : \t %2").arg(filename) );
Jan Möbius's avatar
 
Jan Möbius committed
557

Jan Möbius's avatar
Jan Möbius committed
558 559 560 561 562
    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();
    }
Jan Möbius's avatar
 
Jan Möbius committed
563

Jan Möbius's avatar
Jan Möbius committed
564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587
    //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;
Jan Möbius's avatar
 
Jan Möbius committed
588 589
          }
        }
Dirk Wilden's avatar
Dirk Wilden committed
590
      }
Jan Möbius's avatar
Jan Möbius committed
591
    }
Jan Möbius's avatar
 
Jan Möbius committed
592

593
    QStringList dontLoadPlugins = OpenFlipperSettings().value("PluginControl/DontLoadNames",QStringList()).toStringList();
Jan Möbius's avatar
Jan Möbius committed
594 595 596 597 598 599
    
    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;
    }
Jan Möbius's avatar
 
Jan Möbius committed
600

Jan Möbius's avatar
Jan Möbius committed
601 602 603 604
    //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 ..."));
605

Jan Möbius's avatar
Jan Möbius committed
606
      bool success = false;
607 608 609 610 611
      QMetaObject::invokeMethod(plugin,"authenticate", Q_RETURN_ARG( bool , success ) ) ;
      
      QString message = "";
      QMetaObject::invokeMethod(plugin,"licenseError", Q_RETURN_ARG( QString , message ) ) ;
      _licenseErrors = message;
612

Jan Möbius's avatar
Jan Möbius committed
613 614 615 616 617
      if ( success )
        emit log(LOGINFO,tr("... ok. Loading plugin "));
      else {
        emit log(LOGERR,tr("... failed. Plugin access denied."));
        emit log(LOGOUT,"================================================================================");
Jan Möbius's avatar
Jan Möbius committed
618 619
        
        // Abort here, as the plugin will not do anything else until correct authentication.
Jan Möbius's avatar
Jan Möbius committed
620
        return;
621
      }
Jan Möbius's avatar
Jan Möbius committed
622
    }
623 624


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

Jan Möbius's avatar
Jan Möbius committed
627
    supported = "BaseInterface ";
Jan Möbius's avatar
 
Jan Möbius committed
628

Jan Möbius's avatar
Jan Möbius committed
629 630 631 632
    info.name          = basePlugin->name();
    info.description   = basePlugin->description();
    info.plugin        = plugin;
    info.path          = filename;
Jan Möbius's avatar
 
Jan Möbius committed
633

Jan Möbius's avatar
Jan Möbius committed
634 635 636 637
    if ( checkSlot(plugin,"version()") )
      info.version = basePlugin->version();
    else
      info.version = QString::number(-1);
Jan Möbius's avatar
 
Jan Möbius committed
638

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

Jan Möbius's avatar
Jan Möbius committed
641 642
      if ( ! checkSlot( plugin , "noguiSupported()" ) ) {
        emit log(LOGWARN,tr("Running in nogui mode which is unsupported by this plugin, skipping") );
643
        emit log(LOGOUT,"================================================================================");
644 645 646
        return;
      }

Jan Möbius's avatar
Jan Möbius committed
647
    }
648 649


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

Jan Möbius's avatar
Jan Möbius committed
657 658 659 660 661
    if ( checkSignal(plugin,"update_view()") ) {
      log(LOGERR,tr("Plugin Uses old style update_view! Convert to updateView!"));
      emit log(LOGOUT,"================================================================================");
      return;
    }
662

Jan Möbius's avatar
Jan Möbius committed
663 664
    if ( checkSignal(plugin,"updateView()") )
      connect(plugin,SIGNAL(updateView()),this,SLOT(updateView()));
Dirk Wilden's avatar
Dirk Wilden committed
665

666

Jan Möbius's avatar
Jan Möbius committed
667
    if ( checkSignal(plugin,"updatedObject(int)") && checkSignal(plugin,"updatedObject(int,const UpdateType)") ){
Dirk Wilden's avatar
Dirk Wilden committed
668
      
Jan Möbius's avatar
Jan Möbius committed
669 670 671 672
      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 {
673

Jan Möbius's avatar
Jan Möbius committed
674 675 676
      if ( checkSignal(plugin,"updatedObject(int)") ){
        log(LOGWARN,tr("Plugin uses deprecated updatedObject."));
        connect(plugin,SIGNAL(updatedObject(int)),this,SLOT(slotObjectUpdated(int)), Qt::DirectConnection);
677
      }
Jan Möbius's avatar
Jan Möbius committed
678

Jan Möbius's avatar
Jan Möbius committed
679 680 681
      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
682

Jan Möbius's avatar
Jan Möbius committed
683 684 685
    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."));
686
      connect(this,SIGNAL(signalObjectUpdated(int,const UpdateType)),plugin,SLOT(slotObjectUpdated(int,const UpdateType)), Qt::DirectConnection);
Jan Möbius's avatar
Jan Möbius committed
687 688
    
    } else {
Jan Möbius's avatar
 
Jan Möbius committed
689

Jan Möbius's avatar
Jan Möbius committed
690 691 692
      if ( checkSlot( plugin , "slotObjectUpdated(int)" ) ){
        log(LOGWARN,tr("Plugin uses deprecated slotObjectUpdated."));
        connect(this,SIGNAL(signalObjectUpdated(int)),plugin,SLOT(slotObjectUpdated(int)), Qt::DirectConnection);
693
      }
694

Jan Möbius's avatar
Jan Möbius committed
695 696 697 698 699 700 701 702 703 704 705 706
      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);
707

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

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

Jan Möbius's avatar
Jan Möbius committed
714 715 716 717 718 719 720 721 722
    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);
    
723

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

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

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

Jan Möbius's avatar
Jan Möbius committed
733 734
    if ( checkSlot(plugin,"slotAllCleared()") )
      connect(this,SIGNAL(allCleared()),plugin,SLOT(slotAllCleared()));
Jan Möbius's avatar
 
Jan Möbius committed
735

736

Jan Möbius's avatar
Jan Möbius committed
737 738 739
    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!") );
Jan Möbius's avatar
 
Jan Möbius committed
740 741
    }

Jan Möbius's avatar
Jan Möbius committed
742 743
    if ( checkSlot( plugin , "slotObjectSelectionChanged(int)" ) )
      connect(this,SIGNAL(objectSelectionChanged(int)),plugin,SLOT(slotObjectSelectionChanged(int) ), Qt::DirectConnection);
Jan Möbius's avatar
 
Jan Möbius committed
744 745


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

Jan Möbius's avatar
Jan Möbius committed
749 750 751 752
    if ( checkSignal(plugin,"setSlotDescription(QString,QString,QStringList,QStringList)") )
      connect(plugin, SIGNAL(setSlotDescription(QString,QString,QStringList,QStringList)),
              this,   SLOT(slotSetSlotDescription(QString,QString,QStringList,QStringList)) );
  }
Jan Möbius's avatar
 
Jan Möbius committed
753

Jan Möbius's avatar
Jan Möbius committed
754 755 756 757
  //Check if the plugin supports Logging
  LoggingInterface* logPlugin = qobject_cast< LoggingInterface * >(plugin);
  if ( logPlugin ) {
    supported = supported + "Logging ";
Dirk Wilden's avatar
Dirk Wilden committed
758

Jan Möbius's avatar
Jan Möbius committed
759 760 761 762 763
    // 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);
Jan Möbius's avatar
 
Jan Möbius committed
764

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

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

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

Jan Möbius's avatar
Jan Möbius committed
775 776 777 778
    // connection to external plugin logger
    if ( checkSlot(plugin,"logOutput(Logtype,QString)") )
      connect(this,SIGNAL(externalLog(Logtype,QString)), plugin, SLOT(logOutput(Logtype,QString)) ) ;
  }
Jan Möbius's avatar
 
Jan Möbius committed
779

Jan Möbius's avatar
Jan Möbius committed
780 781 782 783 784 785 786 787 788 789 790 791
  //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);
  }
Jan Möbius's avatar
 
Jan Möbius committed
792

Jan Möbius's avatar
Jan Möbius committed
793 794 795 796
  //Check if the plugin supports ContextMenuInterface
  ContextMenuInterface* contextMenuPlugin = qobject_cast< ContextMenuInterface * >(plugin);
  if ( contextMenuPlugin && OpenFlipper::Options::gui() ) {
    supported = supported + "ContextMenu ";
797

Jan Möbius's avatar
Jan Möbius committed
798 799 800
    if ( checkSignal(plugin,"addContextMenuItem(QAction*,ContextMenuType)") )
      connect(plugin      , SIGNAL(addContextMenuItem(QAction*,ContextMenuType)),
              coreWidget_ , SLOT(slotAddContextItem(QAction*,ContextMenuType)),Qt::DirectConnection);
Jan Möbius's avatar
 
Jan Möbius committed
801

Jan Möbius's avatar
Jan Möbius committed
802 803 804
    if ( checkSignal(plugin,"addContextMenuItem(QAction*,DataType,ContextMenuType)") )
      connect(plugin      , SIGNAL(addContextMenuItem(QAction*,DataType,ContextMenuType)),
              coreWidget_ , SLOT(slotAddContextItem(QAction*,DataType,ContextMenuType)),Qt::DirectConnection);
Jan Möbius's avatar
 
Jan Möbius committed
805

Jan Möbius's avatar
Jan Möbius committed
806 807 808
    if ( checkSlot(plugin,"slotUpdateContextMenu(int)") )
      connect(coreWidget_ , SIGNAL(updateContextMenu(int)),
              plugin      , SLOT(slotUpdateContextMenu(int)),Qt::DirectConnection);
Jan Möbius's avatar
 
Jan Möbius committed
809

Jan Möbius's avatar
Jan Möbius committed
810 811 812
    if ( checkSlot(plugin,"slotUpdateContextMenuNode(int)") )
      connect(coreWidget_ , SIGNAL(updateContextMenuNode(int)),
              plugin      , SLOT(slotUpdateContextMenuNode(int)),Qt::DirectConnection);
813

Jan Möbius's avatar
Jan Möbius committed
814 815 816 817
    if ( checkSlot(plugin,"slotUpdateContextMenuBackground()") )
      connect(coreWidget_ , SIGNAL(updateContextMenuBackground()),
              plugin      , SLOT(slotUpdateContextMenuBackground()),Qt::DirectConnection);
  }
818

Jan Möbius's avatar
Jan Möbius committed
819 820 821 822
  //Check if the plugin supports Toolbox-Interface
  ToolboxInterface* toolboxPlugin = qobject_cast< ToolboxInterface * >(plugin);
  if ( toolboxPlugin && OpenFlipper::Options::gui() ) {
    supported = supported + "Toolbox ";
823

Dirk Wilden's avatar
Dirk Wilden committed
824

Jan Möbius's avatar
Jan Möbius committed
825 826 827
    if ( checkSignal(plugin, "addToolbox(QString,QWidget*)"))
      connect(plugin, SIGNAL( addToolbox(QString,QWidget*) ),
              this, SLOT( addToolbox(QString,QWidget*) ),Qt::DirectConnection );
Jan Möbius's avatar
 
Jan Möbius committed
828 829


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

Jan Möbius's avatar
Jan Möbius committed
831 832 833 834 835 836 837 838 839 840 841 842 843
  }
  
  //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
Marlin:  
Jan Möbius committed
844 845 846 847 848
              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
849 850 851
              
    if ( checkSignal(plugin, "defineViewModeIcon(QString,QString)"))
      connect(plugin, SIGNAL( defineViewModeIcon(QString, QString) ),
852 853 854 855 856 857
              coreWidget_, SLOT( slotSetViewModeIcon(QString, QString) ),Qt::DirectConnection );

    if ( checkSignal(plugin, "setViewMode(QString,bool)"))
      connect(plugin,    SIGNAL( setViewMode(QString, bool) ),
              coreWidget_, SLOT( setViewMode(QString, bool) ),Qt::DirectConnection );
  }
Jan Möbius's avatar
Jan Möbius committed
858 859 860 861 862 863 864 865 866 867 868 869 870

  //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);
Jan Möbius's avatar
 
Jan Möbius committed
871
    }
Jan Möbius's avatar
Jan Möbius committed
872
  }
Jan Möbius's avatar
 
Jan Möbius committed
873

Jan Möbius's avatar
Jan Möbius committed
874 875 876 877
  //Check if the plugin supports Toolbar-Interface
  ToolbarInterface* toolbarPlugin = qobject_cast< ToolbarInterface * >(plugin);
  if ( toolbarPlugin && OpenFlipper::Options::gui() ) {
    supported = supported + "Toolbars ";
Jan Möbius's avatar
 
Jan Möbius committed
878

Jan Möbius's avatar
Jan Möbius committed
879 880 881
    if ( checkSignal(plugin,"addToolbar(QToolBar*)") )
      connect(plugin,SIGNAL(addToolbar(QToolBar*)),
              coreWidget_,SLOT(slotAddToolbar(QToolBar*)),Qt::DirectConnection);
Jan Möbius's avatar
 
Jan Möbius committed
882

Jan Möbius's avatar
Jan Möbius committed
883 884 885
    if ( checkSignal(plugin,"removeToolbar(QToolBar*)") )
      connect(plugin,SIGNAL(removeToolbar(QToolBar*)),
              coreWidget_,SLOT(slotRemoveToolbar(QToolBar*)),Qt::DirectConnection);
Jan Möbius's avatar
 
Jan Möbius committed
886

Jan Möbius's avatar
Jan Möbius committed
887 888 889 890 891
    if ( checkSignal(plugin,"getToolBar(QString,QToolBar*&)") )
      connect(plugin,SIGNAL(getToolBar(QString,QToolBar*&)),
              coreWidget_,SLOT(getToolBar(QString,QToolBar*&)),Qt::DirectConnection);
        
  }
Jan Möbius's avatar
 
Jan Möbius committed
892

Jan Möbius's avatar
Jan Möbius committed
893 894 895 896
  //Check if the plugin supports StatusBar-Interface
  StatusbarInterface* statusbarPlugin = qobject_cast< StatusbarInterface * >(plugin);
  if ( statusbarPlugin && OpenFlipper::Options::gui() ) {
    supported = supported + "StatusBar ";
Jan Möbius's avatar
 
Jan Möbius committed
897

Jan Möbius's avatar
Jan Möbius committed
898 899 900
    if ( checkSignal(plugin,"showStatusMessage(QString,int)") )
      connect(plugin,SIGNAL(showStatusMessage(QString,int)),
              coreWidget_,SLOT(statusMessage(QString,int)),Qt::DirectConnection);
Jan Möbius's avatar
 
Jan Möbius committed
901

Dirk Wilden's avatar
Dirk Wilden committed
902

Jan Möbius's avatar
Jan Möbius committed
903 904 905
    if ( checkSignal(plugin,"setStatus(ApplicationStatus::applicationStatus)") )
      connect(plugin,SIGNAL(setStatus(ApplicationStatus::applicationStatus)),
              coreWidget_,SLOT(setStatus(ApplicationStatus::applicationStatus)),Qt::DirectConnection);
Jan Möbius's avatar
 
Jan Möbius committed
906

Jan Möbius's avatar
Jan Möbius committed
907 908 909 910 911 912 913
    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*)));
  }
Jan Möbius's avatar
 
Jan Möbius committed
914

Jan Möbius's avatar
Jan Möbius committed
915 916 917 918
  //Check if the plugin supports Key-Interface
  KeyInterface* keyPlugin = qobject_cast< KeyInterface * >(plugin);
  if ( keyPlugin && OpenFlipper::Options::gui() ) {
    supported = supported + "KeyboardEvents ";
Jan Möbius's avatar
 
Jan Möbius committed
919

Jan Möbius's avatar
Jan Möbius committed
920 921 922 923
    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)) );
  }
Jan Möbius's avatar
 
Jan Möbius committed
924

Jan Möbius's avatar
Jan Möbius committed
925 926 927 928
  //Check if the plugin supports Mouse-Interface
  MouseInterface* mousePlugin = qobject_cast< MouseInterface * >(plugin);
  if ( mousePlugin && OpenFlipper::Options::gui()  ) {
    supported = supported + "MouseEvents ";
Jan Möbius's avatar
 
Jan Möbius committed
929

Jan Möbius's avatar
Jan Möbius committed
930 931 932
    if ( checkSlot( plugin , "slotMouseWheelEvent(QWheelEvent*,const std::string&)" ) )
      connect(this   , SIGNAL(PluginWheelEvent(QWheelEvent * , const std::string & )),
              plugin , SLOT(slotMouseWheelEvent(QWheelEvent* , const std::string & )));
Jan Möbius's avatar
 
Jan Möbius committed
933

Jan Möbius's avatar
Jan Möbius committed
934 935 936
    if ( checkSlot( plugin , "slotMouseEvent(QMouseEvent*)" ) )
      connect(this   , SIGNAL(PluginMouseEvent(QMouseEvent*)),
              plugin , SLOT(slotMouseEvent(QMouseEvent*)));
Jan Möbius's avatar
 
Jan Möbius committed
937

Jan Möbius's avatar
Jan Möbius committed
938 939 940
    if ( checkSlot( plugin , "slotMouseEventIdentify(QMouseEvent*)" ) )
      connect(this   , SIGNAL(PluginMouseEventIdentify(QMouseEvent*)),
              plugin , SLOT(slotMouseEventIdentify(QMouseEvent*)));
Jan Möbius's avatar
Mike:  
Jan Möbius committed
941 942 943 944
              
    if ( checkSlot( plugin , "slotMouseEventLight(QMouseEvent*)" ) )
      connect(this   , SIGNAL(PluginMouseEventLight(QMouseEvent*)),
              plugin , SLOT(slotMouseEventLight(QMouseEvent*)));
Jan Möbius's avatar
 
Jan Möbius committed
945

Jan Möbius's avatar
Jan Möbius committed
946
  }
Jan Möbius's avatar
 
Jan Möbius committed
947

Jan Möbius's avatar
Jan Möbius committed
948 949 950 951
  //Check if the plugin supports Picking-Interface
  PickingInterface* pickPlugin = qobject_cast< PickingInterface * >(plugin);
  if ( pickPlugin && OpenFlipper::Options::gui() ) {
    supported = supported + "Picking ";
952

Jan Möbius's avatar
Jan Möbius committed
953 954 955
    if ( checkSlot( plugin , "slotPickModeChanged(const std::string&)" ) )
      connect(coreWidget_,SIGNAL(signalPickModeChanged (const std::string &)),
              plugin,SLOT(slotPickModeChanged( const std::string &)));
956

Jan Möbius's avatar
Jan Möbius committed
957 958 959
    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
Dennis:  
Jan Möbius committed
960

Jan Möbius's avatar
Jan Möbius committed
961 962 963
    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
Dennis:  
Jan Möbius committed
964

Jan Möbius's avatar
Jan Möbius committed
965 966 967 968
    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
Dennis:  
Jan Möbius committed
969

Jan Möbius's avatar
Jan Möbius committed
970 971 972 973
    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);
Jan Möbius's avatar
 
Jan Möbius committed
974

Jan Möbius's avatar
Jan Möbius committed
975 976 977
    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);
Jan Möbius's avatar
 
Jan Möbius committed
978

Jan Möbius's avatar
Jan Möbius committed
979 980 981
    if ( checkSignal(plugin,"removePickModeToolbar(const std::string)") )
      connect(plugin,SIGNAL(removePickModeToolbar( const std::string)),
              coreWidget_,SLOT(removePickModeToolbar( const std::string)),Qt::DirectConnection);
Jan Möbius's avatar
 
Jan Möbius committed
982

Jan Möbius's avatar
Jan Möbius committed
983
  }
Jan Möbius's avatar
 
Jan Möbius committed
984

Jan Möbius's avatar
Jan Möbius committed
985 986 987 988
  //Check if the plugin supports INI-Interface
  INIInterface* iniPlugin = qobject_cast< INIInterface * >(plugin);
  if ( iniPlugin ) {
    supported = supported + "INIFile ";
Jan Möbius's avatar
 
Jan Möbius committed
989

Jan Möbius's avatar
Jan Möbius committed
990 991 992
    if ( checkSlot( plugin , "loadIniFile(INIFile&,int)" ) )
      connect(this    , SIGNAL(iniLoad( INIFile&,int)),
              plugin  , SLOT( loadIniFile( INIFile&,int) ),Qt::DirectConnection);
993

Jan Möbius's avatar
Jan Möbius committed
994 995 996
    if ( checkSlot( plugin , "saveIniFile(INIFile&,int)" ) )
      connect(this    , SIGNAL(iniSave( INIFile& , int )),
              plugin  , SLOT( saveIniFile( INIFile& , int ) ),Qt::DirectConnection);
997

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

Jan Möbius's avatar
Jan Möbius committed
1002 1003 1004
    if ( checkSlot( plugin , "saveOnExit(INIFile&)" ) )
      connect(this    , SIGNAL(saveOnExit( INIFile& )),
              plugin  , SLOT( saveOnExit( INIFile& ) ),Qt::DirectConnection);
Jan Möbius's avatar
 
Jan Möbius committed
1005

Jan Möbius's avatar
Jan Möbius committed
1006 1007 1008
    if ( checkSlot( plugin , "loadIniFileOptions(INIFile&)" ) )
      connect(this    , SIGNAL(iniLoadOptions( INIFile& )),
              plugin  , SLOT( loadIniFileOptions( INIFile& ) ),Qt::DirectConnection);
Dirk Wilden's avatar
Dirk Wilden committed
1009

Jan Möbius's avatar
Jan Möbius committed
1010 1011 1012 1013
    if ( checkSlot( plugin , "loadIniFileOptionsLast(INIFile&)" ) )
      connect(this    , SIGNAL(iniLoadOptionsLast( INIFile& )),
              plugin  , SLOT( loadIniFileOptionsLast( INIFile& ) ),Qt::DirectConnection);
  }
Dirk Wilden's avatar
Dirk Wilden committed
1014

Jan Möbius's avatar
Jan Möbius committed
1015 1016 1017 1018
  //Check if the plugin supports Texture-Interface
  TextureInterface* texturePlugin = qobject_cast< TextureInterface * >(plugin);
  if ( texturePlugin && OpenFlipper::Options::gui() ) {
    supported = supported + "Textures ";
Jan Möbius's avatar
 
Jan Möbius committed
1019

Jan Möbius's avatar
Jan Möbius committed
1020 1021 1022
    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);
Jan Möbius's avatar
 
Jan Möbius committed
1023

Jan Möbius's avatar
Jan Möbius committed
1024 1025 1026
    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);
Jan Möbius's avatar
 
Jan Möbius committed
1027

Jan Möbius's avatar
Jan Möbius committed
1028 1029 1030
    if ( checkSignal(plugin,"addTexture(QString,QString,uint)") )
      connect(plugin , SIGNAL(addTexture( QString , QString , uint )),
              this   , SLOT(slotAddTexture(QString, QString, uint)),Qt::DirectConnection);
Jan Möbius's avatar
 
Jan Möbius committed
1031

Jan Möbius's avatar
Jan Möbius committed
1032 1033 1034
    if ( checkSlot( plugin , "slotTextureAdded(QString,QString,uint)" ) )
      connect(this   , SIGNAL(addTexture(QString,QString, uint)),
              plugin , SLOT(slotTextureAdded(QString,QString, uint)),Qt::DirectConnection);
Jan Möbius's avatar
 
Jan Möbius committed
1035

Jan Möbius's avatar
Jan Möbius committed
1036 1037 1038
    if ( checkSignal(plugin,"updateTexture(QString,int)") )
      connect(plugin , SIGNAL(updateTexture( QString ,int )),
              this   , SLOT(slotUpdateTexture(QString , int)),Qt::DirectConnection);
Jan Möbius's avatar
 
Jan Möbius committed
1039

Jan Möbius's avatar
Jan Möbius committed
1040 1041 1042
    if ( checkSlot( plugin , "slotUpdateTexture(QString,int)" ) )
      connect(this   , SIGNAL(updateTexture(QString ,int)),
              plugin , SLOT(slotUpdateTexture(QString,int )),Qt::DirectConnection);
Jan Möbius's avatar
 
Jan Möbius committed
1043

Jan Möbius's avatar
Jan Möbius committed
1044 1045 1046
    if ( checkSignal(plugin,"updateAllTextures()") )
      connect(plugin , SIGNAL(updateAllTextures()),
              this   , SLOT(slotUpdateAllTextures()));
Jan Möbius's avatar
 
Jan Möbius committed
1047

Jan Möbius's avatar
Jan Möbius committed
1048 1049 1050
    if ( checkSlot( plugin , "slotUpdateAllTextures()" ) )
      connect(this   , SIGNAL(updateAllTextures()),
              plugin , SLOT(slotUpdateAllTextures()));
Dirk Wilden's avatar
Dirk Wilden committed
1051

Jan Möbius's avatar
Jan Möbius committed
1052 1053 1054
    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
1055

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

Jan Möbius's avatar
Jan Möbius committed
1060 1061 1062
    if ( checkSignal(plugin,"setTextureMode(QString,QString,int)") )
      connect(plugin , SIGNAL(setTextureMode(QString, QString, int )),
              this   , SLOT(slotSetTextureMode(QString, QString, int )),Qt::DirectConnection );
Jan Möbius's avatar
 
Jan Möbius committed
1063

Jan Möbius's avatar
Jan Möbius committed
1064 1065 1066
    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
1067

Jan Möbius's avatar
Jan Möbius committed
1068 1069 1070
    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
1071

Jan Möbius's avatar
Jan Möbius committed
1072 1073 1074
    if ( checkSlot( plugin , "slotSetTextureMode(QString,QString)" ) )
      connect(this   , SIGNAL(setTextureMode(QString  ,QString )),
              plugin , SLOT(slotSetTextureMode(QString  ,QString )),Qt::DirectConnection );
Jan Möbius's avatar
 
Jan Möbius committed
1075

Jan Möbius's avatar
Jan Möbius committed
1076 1077 1078
    if ( checkSignal(plugin,"switchTexture(QString,int)") )
      connect(plugin , SIGNAL(switchTexture(QString, int )),
              this   , SLOT(slotSwitchTexture(QString, int )),Qt::DirectConnection);
1079

Jan Möbius's avatar
Jan Möbius committed
1080 1081 1082
    if ( checkSlot( plugin , "slotSwitchTexture(QString,int)" ) )
      connect(this   , SIGNAL(switchTexture(QString, int )),
              plugin , SLOT(slotSwitchTexture(QString, int )),Qt::DirectConnection);
1083

Jan Möbius's avatar
Jan Möbius committed
1084 1085 1086
    if ( checkSignal(plugin,"switchTexture(QString)") )
      connect(plugin , SIGNAL(switchTexture(QString )),
              this   , SLOT(slotSwitchTexture(QString )),Qt::DirectConnection);
1087

Jan Möbius's avatar
Jan Möbius committed
1088 1089 1090
    if ( checkSlot( plugin , "slotSwitchTexture(QString)" ) )
      connect(this   , SIGNAL(switchTexture(QString )),
              plugin , SLOT(slotSwitchTexture(QString )),Qt::DirectConnection);
1091 1092 1093



Jan Möbius's avatar
Jan Möbius committed
1094 1095 1096
    if ( checkSignal( plugin , "textureChangeImage(QString,QImage&,int)" ) )
      connect(plugin   , SIGNAL(textureChangeImage(QString,QImage&,int)),
              this , SLOT(slotTextureChangeImage(QString,QImage&,int)),Qt::DirectConnection);
1097

Jan Möbius's avatar
Jan Möbius committed
1098 1099 1100
    if ( checkSlot( plugin , "slotTextureChangeImage(QString,QImage&,int)" ) )
      connect(this   , SIGNAL(textureChangeImage(QString,QImage&,int)),
              plugin , SLOT(slotTextureChangeImage(QString,QImage&,int)),Qt::DirectConnection);
1101

Jan Möbius's avatar
Jan Möbius committed
1102 1103 1104
    if ( checkSignal( plugin , "textureChangeImage(QString,QImage&)" ) )
      connect(plugin   , SIGNAL(textureChangeImage(QString,QImage&)),
              this , SLOT(slotTextureChangeImage(QString,QImage&)),Qt::DirectConnection);
1105

Jan Möbius's avatar
Jan Möbius committed
1106 1107 1108
    if ( checkSlot( plugin , "slotTextureChangeImage(QString,QImage&)" ) )
      connect(this   , SIGNAL(textureChangeImage(QString,QImage&)),
              plugin , SLOT(slotTextureChangeImage(QString,QImage&)),Qt::DirectConnection);
Jan Möbius's avatar
 
Jan Möbius committed
1109

Jan Möbius's avatar
Jan Möbius committed
1110 1111 1112
    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);
Jan Möbius's avatar
 
Jan Möbius committed
1113

Jan Möbius's avatar
Jan Möbius committed
1114 1115 1116
    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);
Jan Möbius's avatar
 
Jan Möbius committed
1117

1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133
    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);

1134 1135 1136
    if ( checkSignal( plugin , "textureIndex(QString,int,int&)" ) )
      connect(plugin   , SIGNAL(textureIndex(QString,int,int&)),
              this ,   SLOT(slotTextureIndex(QString,int,int&)),Qt::DirectConnection);
1137
    
1138 1139 1140
    if ( checkSlot( plugin , "slotTextureIndex(QString,int,int&)" ) )
      connect(this   , SIGNAL(textureIndex(QString,int,int&)),
              plugin , SLOT(slotTextureIndex(QString,int,int&)),Qt::DirectConnection);
1141
              
1142 1143 1144 1145 1146 1147 1148 1149
    if ( checkSignal( plugin , "textureIndexPropertyName(int,QString&)" ) )
      connect(plugin   , SIGNAL(textureIndexPropertyName(int,QString&)),
              this ,   SLOT(slotTextureIndexPropertyName(int,QString&)),Qt::DirectConnection);
    
    if ( checkSlot( plugin , "slotTextureIndexPropertyName(int,QString&)" ) )
      connect(this   , SIGNAL(textureIndexPropertyName(int,QString&)),
              plugin , SLOT(slotTextureIndexPropertyName(int,QString&)),Qt::DirectConnection);
              
1150 1151 1152 1153 1154 1155 1156 1157
    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);
              
1158 1159 1160 1161 1162 1163 1164 1165
    if ( checkSignal( plugin , "textureFilename(int,QString,QString&)" ) )
      connect(plugin , SIGNAL(textureFilename(int,QString,QString&)),
              this   , SLOT(slotTextureFilename(int,QString,QString&)),Qt::DirectConnection);
              
    if ( checkSlot( plugin , "slotTextureFilename(int,QString,QString&)" ) )
      connect(this   , SIGNAL(textureFilename(int,QString,QString&)),
              plugin , SLOT(slotTextureFilename(int,QString,QString&)),Qt::DirectConnection);
              
1166 1167 1168
    if ( checkSignal( plugin , "getCurrentTexture(int,QString&)" ) )
      connect(plugin   , SIGNAL(getCurrentTexture(int,QString&)),
              this ,   SLOT(slotGetCurrentTexture(int,QString&)),Qt::DirectConnection);
Jan Möbius's avatar
 
Jan Möbius committed
1169

1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182
    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
1183 1184 1185 1186
  //Check if the plugin supports Backup-Interface
  BackupInterface* backupPlugin = qobject_cast< BackupInterface * >(plugin);
  if ( backupPlugin ) {
    supported = supported + "Backups ";
1187

Dirk Wilden's avatar
Dirk Wilden committed
1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199
    // Incoming Signal that a backup group should be created 
    // send to local slot generating group id and delivers to all other plugins
    if ( checkSignal( plugin , "createBackupGroup(QString,int&)" ) ) {
      connect(plugin , SIGNAL(createBackupGroup(QString , int&)) ,
              this   , SLOT(slotBackupGroup(QString , int&)),Qt::DirectConnection );
    }
    // Signal send from core to plugins that they should create a backup group
    if ( checkSlot( plugin , "slotBackupGroup(QString,int)" ) ) {
      connect(this   , SIGNAL(createBackupGroup(QString,int)) ,
              plugin , SLOT( slotBackupGroup(QString,int) ),Qt::DirectConnection);
    }
    
Jan Möbius's avatar
Jan Möbius committed
1200 1201
    // Incoming Signal that a backup should be created 
    // send to local slot generating backup id and delivers to all other plugins
Dirk Wilden's avatar
Dirk Wilden committed
1202 1203 1204
    if ( checkSignal( plugin , "createBackup(int,QString,int&,int)" ) ) {
      connect(plugin , SIGNAL(createBackup( int , QString , int&, int)) ,
              this   , SLOT(slotBackup( int , QString , int&, int)),Qt::DirectConnection );
Jan Möbius's avatar
Jan Möbius committed
1205 1206 1207 1208 1209 1210 1211 1212 1213
    }
    
    // send to local slot generating backup id and delivers to all other plugins
    if ( checkSignal( plugin , "createBackup(int,QString)" ) ) {
      connect(plugin , SIGNAL(createBackup( int , QString)) ,
              this   , SLOT(slotBackup( int , QString)),Qt::DirectConnection );
    }
    
    // Signal send from core to plugins that they should create a backup
Dirk Wilden's avatar
Dirk Wilden committed
1214 1215 1216
    if ( checkSlot( plugin , "slotBackup(int,QString,int,int)" ) ) {
      connect(this   , SIGNAL(createBackup(int,QString,int,int)) ,
              plugin , SLOT( slotBackup(int,QString,int,int) ),Qt::DirectConnection);
Jan Möbius's avatar
Jan Möbius committed
1217 1218
    }
    
Jan Möbius's avatar
Jan Möbius committed
1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230
    // Signal send from plugin to core that a backup should be made persistent
    if ( checkSignal( plugin , "makeBackupPersistent(int,int)" ) ) {
      connect(plugin , SIGNAL(makeBackupPersistent(int,int)) ,
              this , SIGNAL( makeBackupPersistent(int,int)) ,Qt::DirectConnection);
    }
    
    // Signal send from core to Backup plugin that the given backup should be persistent
    if ( checkSlot( plugin , "slotMakeBackupPersistent(int,int)" ) ) {
      connect(this   , SIGNAL(makeBackupPersistent(int,int)) ,
              plugin , SLOT( slotMakeBackupPersistent(int,int) ),Qt::DirectConnection);
    }

Jan Möbius's avatar
Jan Möbius committed
1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241
    // Signal from plugin to restore an object with the given id
    if ( checkSignal( plugin , "restoreObject(int,int)" ) ) {
      connect(plugin , SIGNAL(restoreObject(int,int)) ,
              this   , SLOT(slotRestore( int , int)),Qt::DirectConnection );
    }
    
    // Signal send from core to backup plugin that it should restore the given object
    if ( checkSlot( plugin , "slotRestoreObject(int,int)" ) ) {
      connect(this   , SIGNAL(restoreObject(int,int)) ,
              plugin , SLOT( slotRestoreObject(int,int) ),Qt::DirectConnection);
    }
Dirk Wilden's avatar
Dirk Wilden committed
1242 1243 1244 1245 1246 1247 1248


    // Signal from plugin to restore a group with the given id
    if ( checkSignal( plugin , "restoreGroup(int)" ) ) {
      connect(plugin , SIGNAL(restoreGroup(int)) ,
              this   , SLOT(slotRestoreGroup(int)),Qt::DirectConnection );
    }
Jan Möbius's avatar
Jan Möbius committed
1249
    
Dirk Wilden's avatar
Dirk Wilden committed
1250 1251 1252 1253 1254 1255
    // Signal send from core to backup plugin that it should restore the given group
    if ( checkSlot( plugin , "slotRestoreGroup(int)" ) ) {
      connect(this   , SIGNAL(restoreGroup(int)) ,
              plugin , SLOT( slotRestoreGroup(int) ),Qt::DirectConnection);
    }

Jan Möbius's avatar
Jan Möbius committed
1256
    //====================================================================================
Jan Möbius's avatar
Jan Möbius committed
1257
    // Backup Plugin signals for communication with the other plugins about restore state
Jan Möbius's avatar
Jan Möbius committed
1258 1259 1260 1261
    //====================================================================================
    
    // Stage one :