PluginLoader.cc 53.3 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$                   *
 *                                                                           *
\*===========================================================================*/
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"
Jan Möbius's avatar
 
Jan Möbius committed
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"
Jan Möbius's avatar
 
Jan Möbius committed
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117

//== 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
118
  //try to load plugins from new location
119
  QDir tempDir = QDir(OpenFlipper::Options::pluginDir());
Dirk Wilden's avatar
Dirk Wilden committed
120

121
122
123
124
125
126
127
128
129
  // Possible Plugin extensions
  QStringList filter;
  if ( OpenFlipper::Options::isWindows() )
    filter << "*.dll";
  else if ( OpenFlipper::Options::isDarwin() )
    filter << "*.dylib";
  else
    filter << "*.so";
  
Jan Möbius's avatar
 
Jan Möbius committed
130
  // Get all files in the Plugin dir
131
  QStringList pluginlist = tempDir.entryList(filter,QDir::Files);
Dirk Wilden's avatar
Dirk Wilden committed
132

133
134
  // Convert local file path to absolute path
  for (int i=0; i < pluginlist.size(); i++) {
135
     pluginlist[i] = tempDir.absoluteFilePath(pluginlist[i]);
Jan Möbius's avatar
 
Jan Möbius committed
136
137
  }

138
139
140
141
142
143
144
145
146
147
148
  // 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
149
  for ( int i = 0 ; i < additionalPlugins.size(); ++i) {
150
    emit log(LOGOUT,tr("Additional Plugin from file: %1").arg( additionalPlugins[i] ) );
Jan Möbius's avatar
Jan Möbius committed
151
  }
152
153
154
155
  
  // Prepend the additional Plugins to the plugin list
  pluginlist = additionalPlugins << pluginlist;
  
Jan Möbius's avatar
 
Jan Möbius committed
156
  // Sort plugins to load FilePlugins first
157
  QStringList typePlugins;
Jan Möbius's avatar
 
Jan Möbius committed
158
159
160
161
162
  QStringList filePlugins;
  QStringList textureControl;
  QStringList otherPlugins;
  //plugin Liste sortieren
  for (int i=0; i < pluginlist.size(); i++)
163
164
165
    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
166
167
168
169
170
171
      filePlugins.push_back(pluginlist[i]);
    else if (pluginlist[i].contains("TextureControl"))
      textureControl.push_back(pluginlist[i]);
    else
      otherPlugins.push_back(pluginlist[i]);

172
173
174
175
176
177
  // 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
178

179
180
  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
181

182
  emit log(LOGOUT,"================================================================================");
Jan Möbius's avatar
 
Jan Möbius committed
183
184
185
186

  // Try to load each file as a plugin
  for ( int i = 0 ; i < pluginlist.size() ; ++i) {

187
    if ( OpenFlipper::Options::gui() && OpenFlipperSettings().value("Core/Gui/splash",true).toBool() ) {
Jan Möbius's avatar
Jan Möbius committed
188
      splashMessage_ = tr("Loading Plugin %1/%2").arg(i).arg(pluginlist.size()) ;
Jan Möbius's avatar
 
Jan Möbius committed
189
190
191
192
      splash_->showMessage( splashMessage_ , Qt::AlignBottom | Qt::AlignLeft , Qt::white);
      QApplication::processEvents();
    }

Dirk Wilden's avatar
Dirk Wilden committed
193
    loadPlugin(pluginlist[i],true);
Jan Möbius's avatar
 
Jan Möbius committed
194
195
196
197
198
199
  }

  splashMessage_ = "";

  emit pluginsInitialized();

Jan Möbius's avatar
Jan Möbius committed
200
  emit log(LOGOUT,tr("Loaded %n Plugin(s)","",plugins.size()) );
Jan Möbius's avatar
 
Jan Möbius committed
201
202
203
204
205
206
207
208
209
}

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

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

210
  // Setup filters for possible plugin extensions
Jan Möbius's avatar
 
Jan Möbius committed
211
212
213
  QString filter;
  if ( OpenFlipper::Options::isWindows() )
    filter = "Plugins (*.dll)";
214
215
  else if ( OpenFlipper::Options::isDarwin() )
    filter = "Plugins (*.dylib)";
Jan Möbius's avatar
 
Jan Möbius committed
216
217
218
  else
    filter = "Plugins (*.so)";

219
  // Ask the user to select the file to load
Jan Möbius's avatar
 
Jan Möbius committed
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
  QString filename = ACG::getOpenFileName(coreWidget_,tr("Load Plugin"),filter,OpenFlipper::Options::currentDirStr());

  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;

242
243
  // Ask if the plugin is on the block list
  QStringList dontLoadPlugins = OpenFlipperSettings().value("PluginControl/DontLoadNames").toStringList();
244
  if (dontLoadPlugins.contains(name)){
Jan Möbius's avatar
 
Jan Möbius committed
245
246
      int ret = QMessageBox::question(0, tr("Plugin Loading Prevention"),
                   tr("OpenFlipper is currently configured to prevent loading this plugin.\n"
247
                      "Do you want to enable this plugin permanently?"),
Jan Möbius's avatar
 
Jan Möbius committed
248
249
                   QMessageBox::Yes | QMessageBox::No,
                   QMessageBox::Yes);
250
251
252
253
254
      if (ret == QMessageBox::Yes) {
        dontLoadPlugins.removeAll(name);
        OpenFlipperSettings().setValue("PluginControl/DontLoadNames",dontLoadPlugins);
      } else
         return;
Jan Möbius's avatar
 
Jan Möbius committed
255
  }
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
  
  // 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);
    }
  }
  
Jan Möbius's avatar
 
Jan Möbius committed
271
272
273
  loadPlugin(filename,false);
}

Dirk Wilden's avatar
Dirk Wilden committed
274
/** @brief slot for showing loaded Plugins
Jan Möbius's avatar
 
Jan Möbius committed
275
 */
Dirk Wilden's avatar
Dirk Wilden committed
276
void Core::slotShowPlugins(){
Jan Möbius's avatar
 
Jan Möbius committed
277

Dirk Wilden's avatar
Dirk Wilden committed
278
279
280
281
282
283
284
  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
285

Dirk Wilden's avatar
Dirk Wilden committed
286
287
288
289
290
291
292
293
294
295
      //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
296
297
298
299
300
301
302
}

/** @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
303
    if (plugins[i].rpcName == name){
Jan Möbius's avatar
 
Jan Möbius committed
304
305
306
307
308
309
      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
310
311
      if ( coreWidget_->viewModes_[0]->visibleToolboxes.contains(name_nospace) )
        coreWidget_->viewModes_[0]->visibleToolboxes.removeAt(coreWidget_->viewModes_[0]->visibleToolboxes.indexOf(name_nospace));
312
313
314
315
      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;
316
        }
Jan Möbius's avatar
 
Jan Möbius committed
317
318
319

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

Jan Möbius's avatar
Jan Möbius committed
320
      emit log(LOGOUT,tr("Unloaded Plugin :\t\t %1").arg( name) );
Jan Möbius's avatar
 
Jan Möbius committed
321
322
323
324

      return;
    }

Jan Möbius's avatar
Jan Möbius committed
325
    log(LOGERR, tr("Unable to unload plugin '%1' (plugin wasn't found)").arg(name));
Jan Möbius's avatar
 
Jan Möbius committed
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
}

/** @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
 */
void Core::loadPlugin(QString filename, bool silent){

  // 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;
  }

  // Try to open the file
  QPluginLoader loader( filename );
  QObject *plugin = loader.instance();

  // Check if a plugin has been loaded
  if (plugin) {
Dirk Wilden's avatar
Dirk Wilden committed
354
    PluginInfo info;
Jan Möbius's avatar
 
Jan Möbius committed
355
356
357
358
359
    QString supported;

    // Check if it is a BasePlugin
    BaseInterface* basePlugin = qobject_cast< BaseInterface * >(plugin);
    if ( basePlugin ) {
360
361
      emit log(LOGOUT,tr("Found Plugin : \t %1").arg(basePlugin->name()) );
      emit log(LOGOUT,tr("Location : \t %2").arg(filename) );
Jan Möbius's avatar
 
Jan Möbius committed
362

363
      if ( OpenFlipper::Options::gui() && OpenFlipperSettings().value("Core/Gui/splash",true).toBool() ) {
Jan Möbius's avatar
 
Jan Möbius committed
364
365
366
367
368
369
        splashMessage_ = splashMessage_ + " " + basePlugin->name() ;
        splash_->showMessage( splashMessage_ , Qt::AlignBottom | Qt::AlignLeft , Qt::white);
        QApplication::processEvents();
      }

      //Check if plugin is already loaded
Dirk Wilden's avatar
Dirk Wilden committed
370
371
372
373
374
      for (uint k=0; k < plugins.size(); k++){

          QString name_nospace =  basePlugin->name();
          name_nospace.remove(" ");

375
376
          if (plugins[k].name == name_nospace){
            if (silent || OpenFlipper::Options::nogui() ){ //dont load the plugin
Jan Möbius's avatar
Jan Möbius committed
377
              emit log(LOGWARN, tr("\t\t\t Already loaded from %1").arg( plugins[k].path) );
378
              emit log(LOGOUT,"================================================================================");
379
              return;
Jan Möbius's avatar
 
Jan Möbius committed
380
381
382
          }else{ //ask the user
            int ret = QMessageBox::question(coreWidget_,
                                            tr("Plugin already loaded"),
Jan Möbius's avatar
Jan Möbius committed
383
                                            tr("A Plugin with the same name was already loaded from %1.\n" 
384
                                               "You can only load the new plugin if you unload the existing one first.\n\n"
Jan Möbius's avatar
Jan Möbius committed
385
                                               "Do you want to unload the existing plugin first?").arg( plugins[k].path),
Jan Möbius's avatar
 
Jan Möbius committed
386
387
388
389
                                            QMessageBox::Yes|QMessageBox::No, QMessageBox::No);
            if (ret == QMessageBox::Yes)
              unloadPlugin(plugins[k].name);
            else{
Jan Möbius's avatar
Jan Möbius committed
390
              emit log(LOGWARN, tr("\t\t\t Already loaded from %1.").arg( plugins[k].path));
391
              emit log(LOGOUT,"================================================================================");
Jan Möbius's avatar
 
Jan Möbius committed
392
393
394
395
              return;
            }
          }
        }
Dirk Wilden's avatar
Dirk Wilden committed
396
      }
Jan Möbius's avatar
 
Jan Möbius committed
397

398
399
400
      QStringList dontLoadPlugins = OpenFlipperSettings().value("PluginControl/DontLoadNames").toStringList();
      
      if ( dontLoadPlugins.contains(basePlugin->name(), Qt::CaseInsensitive) ) {
Jan Möbius's avatar
Jan Möbius committed
401
        emit log(LOGWARN,tr("OpenFlipper.ini prevented Plugin %1 from being loaded! ").arg( basePlugin->name() ));
402
        emit log(LOGOUT,"================================================================================");
Jan Möbius's avatar
 
Jan Möbius committed
403
404
405
        return;
      }

406
407
408
      //Check if it is a BasePlugin
      SecurityInterface * securePlugin = qobject_cast< SecurityInterface * >(plugin);
      if ( securePlugin ) {
409
        emit log(LOGINFO,tr("Plugin uses security interface. Trying to authenticate against plugin ..."));
410
411
412
413
414

        bool success = false;
        QMetaObject::invokeMethod(plugin,"authenticate", Q_RETURN_ARG( bool , success ) ) ;

        if ( success )
415
          emit log(LOGINFO,tr("... ok. Loading plugin "));
416
        else {
417
          emit log(LOGERR,tr("... failed. Plugin access denied."));
418
          emit log(LOGOUT,"================================================================================");
419
420
421
          return;
        }
      }
422
423


Jan Möbius's avatar
Jan Möbius committed
424
      emit log(LOGOUT,tr("Plugin Desciption :\t %1 ").arg( basePlugin->description()) );
Jan Möbius's avatar
 
Jan Möbius committed
425
426
427
428
429
430
431
432

      supported = "BaseInterface ";

      info.name          = basePlugin->name();
      info.description   = basePlugin->description();
      info.plugin        = plugin;
      info.path          = filename;

433
434
435
436
437
      if ( checkSlot(plugin,"version()") )
        info.version = basePlugin->version();
      else
        info.version = QString::number(-1);

Jan Möbius's avatar
 
Jan Möbius committed
438
439
440
      if ( OpenFlipper::Options::nogui() ) {

        if ( ! checkSlot( plugin , "noguiSupported()" ) ) {
441
          emit log(LOGWARN,tr("Running in nogui mode which is unsupported by this plugin, skipping") );
442
          emit log(LOGOUT,"================================================================================");
Jan Möbius's avatar
 
Jan Möbius committed
443
444
445
446
447
448
          return;
        }

      }


449
450
      // Check for baseInterface of old style!
      if ( checkSignal(plugin,"updated_objects(int)") ) {
451
        log(LOGERR,tr("Plugin Uses old style updated_objects! Convert to updatedObject!"));
452
        emit log(LOGOUT,"================================================================================");
453
454
455
456
        return;
      }

      if ( checkSignal(plugin,"update_view()") ) {
457
        log(LOGERR,tr("Plugin Uses old style update_view! Convert to updateView!"));
458
        emit log(LOGOUT,"================================================================================");
459
460
461
462
463
464
        return;
      }

      if ( checkSignal(plugin,"updateView()") )
        connect(plugin,SIGNAL(updateView()),this,SLOT(updateView()));

465
466


467
      if ( checkSignal(plugin,"updatedObject(int)") )
468
        connect(plugin,SIGNAL(updatedObject(int)),this,SLOT(slotObjectUpdated(int)), Qt::DirectConnection);
469

470
471
472
473
      if ( checkSlot( plugin , "slotObjectUpdated(int)" ) )
        connect(this,SIGNAL(signalObjectUpdated(int)),plugin,SLOT(slotObjectUpdated(int)), Qt::DirectConnection);


474
475
476
477
478
479
      if ( checkSignal(plugin,"objectPropertiesChanged(int)")) {
        emit log (LOGERR,tr("Signal objectPropertiesChanged(int) is deprecated. " ));
        emit log (LOGERR,tr("The signal will be automatically emitted by the object that has been changed and the core will deliver it to the plugins!. "));
        emit log (LOGERR,tr("Please remove this signal from your plugins!. "));
//         connect(plugin,SIGNAL(objectPropertiesChanged(int)),this,SLOT(slotObjectPropertiesChanged(int)), Qt::DirectConnection);
      }
480
481
482
      
      if ( checkSlot( plugin , "slotViewChanged()" ) )
        connect(this,SIGNAL(pluginViewChanged()),plugin,SLOT(slotViewChanged()), Qt::DirectConnection);
Jan Möbius's avatar
Jan Möbius committed
483
484
485

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

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

490
491
492
493
494
495
496
497
498
      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);
      
499
500
501
502
503

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

      if ( checkSignal(plugin,"activeObjectChanged()" ) )
504
        emit log (LOGERR,tr("Signal activeObjectChanged() is now objectSelectionChanged( int _objectId ) ") );
505

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

Jan Möbius's avatar
Jan Möbius committed
509
510
      if ( checkSlot(plugin,"slotAllCleared()") )
        connect(this,SIGNAL(allCleared()),plugin,SLOT(slotAllCleared()));
511

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

513
514
515
516
      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!") );
      }
517
518

      if ( checkSlot( plugin , "slotObjectSelectionChanged(int)" ) )
519
        connect(this,SIGNAL(objectSelectionChanged(int)),plugin,SLOT(slotObjectSelectionChanged(int) ), Qt::DirectConnection);
Jan Möbius's avatar
 
Jan Möbius committed
520
521
522
523


      if ( checkSlot( plugin , "pluginsInitialized()" ) )
        connect(this,SIGNAL(pluginsInitialized()),plugin,SLOT(pluginsInitialized()), Qt::DirectConnection);
524
525
526
527

      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
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
    }

    //Check if the plugin supports Logging
    LoggingInterface* logPlugin = qobject_cast< LoggingInterface * >(plugin);
    if ( logPlugin ) {
      supported = supported + "Logging ";

      // Create intermediate logger class which will mangle the output
      PluginLogger* newlog = new PluginLogger(info.name);
      loggers_.push_back(newlog);
      connect(plugin,SIGNAL(log(Logtype, QString )),newlog,SLOT(slotLog(Logtype, QString )),Qt::DirectConnection);
      connect(plugin,SIGNAL(log(QString )),newlog,SLOT(slotLog(QString )),Qt::DirectConnection);

      // Connect it to the core widget logger
      if ( OpenFlipper::Options::gui() )
        connect(newlog,SIGNAL(log(Logtype, QString )),coreWidget_,SLOT(slotLog(Logtype, QString )),Qt::DirectConnection);

      // connection to console logger
      connect(newlog,SIGNAL(log(Logtype, QString )),this,SLOT(slotLog(Logtype, QString )),Qt::DirectConnection);

Dirk Wilden's avatar
Dirk Wilden committed
548
549
550
      // 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
551
552
553
554
555
556
557
558
559
560
      // connection to external plugin logger
      if ( checkSlot(plugin,"logOutput(Logtype,QString)") )
        connect(this,SIGNAL(externalLog(Logtype,QString)), plugin, SLOT(logOutput(Logtype,QString)) ) ;
    }

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

Jan Möbius's avatar
Jan Möbius committed
561
562
563
564
565
566
      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
567
568
569
570
571
572
573
    }

    //Check if the plugin supports ContextMenuInterface
    ContextMenuInterface* contextMenuPlugin = qobject_cast< ContextMenuInterface * >(plugin);
    if ( contextMenuPlugin && OpenFlipper::Options::gui() ) {
      supported = supported + "ContextMenu ";

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

Jan Möbius's avatar
   
Jan Möbius committed
578
579
580
      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
581
582
583
584
585

      if ( checkSlot(plugin,"slotUpdateContextMenu(int)") )
        connect(coreWidget_ , SIGNAL(updateContextMenu(int)),
                plugin      , SLOT(slotUpdateContextMenu(int)),Qt::DirectConnection);

586
587
588
589
590
591
592
      if ( checkSlot(plugin,"slotUpdateContextMenuNode(int)") )
        connect(coreWidget_ , SIGNAL(updateContextMenuNode(int)),
                plugin      , SLOT(slotUpdateContextMenuNode(int)),Qt::DirectConnection);

      if ( checkSlot(plugin,"slotUpdateContextMenuBackground()") )
        connect(coreWidget_ , SIGNAL(updateContextMenuBackground()),
                plugin      , SLOT(slotUpdateContextMenuBackground()),Qt::DirectConnection);
Jan Möbius's avatar
 
Jan Möbius committed
593
594
595
596
597
598
599
600
    }

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


601
602
      if ( checkSignal(plugin, "addToolbox(QString,QWidget*)"))
        connect(plugin, SIGNAL( addToolbox(QString,QWidget*) ),
Jan Möbius's avatar
Jan Möbius committed
603
                this, SLOT( addToolbox(QString,QWidget*) ),Qt::DirectConnection );
604
605
606



Jan Möbius's avatar
 
Jan Möbius committed
607
    }
Jan Möbius's avatar
Jan Möbius committed
608
609
610
611
612
613
614
615
616
617
    
    //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 );
                
618
619
620
621
      if ( checkSignal(plugin, "defineViewModeToolbars(QString,QStringList)"))
        connect(plugin, SIGNAL( defineViewModeToolbars(QString, QStringList) ),
                coreWidget_, SLOT( slotAddViewModeToolbars(QString, QStringList) ),Qt::DirectConnection );                
                
622
623
624
625
      if ( checkSignal(plugin, "defineViewModeIcon(QString,QString)"))
        connect(plugin, SIGNAL( defineViewModeIcon(QString, QString) ),
                coreWidget_, SLOT( slotSetViewModeIcon(QString, QString) ),Qt::DirectConnection );                          
                
Jan Möbius's avatar
Jan Möbius committed
626
    }    
Jan Möbius's avatar
 
Jan Möbius committed
627

Dirk Wilden's avatar
Dirk Wilden committed
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
    //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);
      }
    }

    //Check if the plugin supports Toolbar-Interface
Jan Möbius's avatar
 
Jan Möbius committed
644
645
646
647
648
649
650
651
652
653
654
    ToolbarInterface* toolbarPlugin = qobject_cast< ToolbarInterface * >(plugin);
    if ( toolbarPlugin && OpenFlipper::Options::gui() ) {
      supported = supported + "Toolbars ";

      if ( checkSignal(plugin,"addToolbar(QToolBar*)") )
        connect(plugin,SIGNAL(addToolbar(QToolBar*)),
                coreWidget_,SLOT(slotAddToolbar(QToolBar*)),Qt::DirectConnection);

      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
655
656
657
658

      if ( checkSignal(plugin,"getToolBar(QString,QToolBar*&)") )
        connect(plugin,SIGNAL(getToolBar(QString,QToolBar*&)),
                coreWidget_,SLOT(getToolBar(QString,QToolBar*&)),Qt::DirectConnection);
659
          
Jan Möbius's avatar
 
Jan Möbius committed
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
    }

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

      if ( checkSignal(plugin,"showStatusMessage(QString,int)") )
        connect(plugin,SIGNAL(showStatusMessage(QString,int)),
                coreWidget_,SLOT(statusMessage(QString,int)),Qt::DirectConnection);


      if ( checkSignal(plugin,"setStatus(ApplicationStatus::applicationStatus)") )
        connect(plugin,SIGNAL(setStatus(ApplicationStatus::applicationStatus)),
                coreWidget_,SLOT(setStatus(ApplicationStatus::applicationStatus)),Qt::DirectConnection);

      if ( checkSignal(plugin,"clearStatusMessage()") )
        connect(plugin,SIGNAL(clearStatusMessage()),
                coreWidget_,SLOT(clearStatusMessage()));

    }

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

Dirk Wilden's avatar
Dirk Wilden committed
687
688
689
      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)) );
Dirk Wilden's avatar
Dirk Wilden committed
690
691
692

//       if ( checkSlot( plugin , "slotKeyEvent(QKeyEvent*)" ) )
//         connect(coreWidget_,SIGNAL(PluginKeyEvent(QKeyEvent* )), plugin,SLOT(slotKeyEvent(QKeyEvent*)));
693
//
Dirk Wilden's avatar
Dirk Wilden committed
694
695
//       if ( checkSlot( plugin , "slotKeyReleaseEvent(QKeyEvent*)" ) )
//         connect(coreWidget_,SIGNAL(PluginKeyReleaseEvent(QKeyEvent* )), plugin,SLOT(slotKeyReleaseEvent(QKeyEvent*)));
Jan Möbius's avatar
 
Jan Möbius committed
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
    }

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

      if ( checkSlot( plugin , "slotMouseWheelEvent(QWheelEvent*,const std::string&)" ) )
        connect(this   , SIGNAL(PluginWheelEvent(QWheelEvent * , const std::string & )),
                plugin , SLOT(slotMouseWheelEvent(QWheelEvent* , const std::string & )));

      if ( checkSlot( plugin , "slotMouseEvent(QMouseEvent*)" ) )
        connect(this   , SIGNAL(PluginMouseEvent(QMouseEvent*)),
                plugin , SLOT(slotMouseEvent(QMouseEvent*)));

      if ( checkSlot( plugin , "slotMouseEventIdentify(QMouseEvent*)" ) )
        connect(this   , SIGNAL(PluginMouseEventIdentify(QMouseEvent*)),
                plugin , SLOT(slotMouseEventIdentify(QMouseEvent*)));

    }

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

      if ( checkSlot( plugin , "slotPickModeChanged(const std::string&)" ) )