Changed path to plugins folder
[mdictionary] / trunk / src / base / backbone / backbone.cpp
index f0251c5..dde87a2 100644 (file)
@@ -27,7 +27,9 @@
 void Backbone::init() {
    _searchLimit = 10;
    _interval = 250; //msec
+   _pluginPath = "/usr/lib/mdictionary/";
    loadPlugins();
+
    if(!connect(&_timer, SIGNAL(timeout()), this, SLOT(translation())))
        qDebug() << "Timer signal not connected";
 }
@@ -117,7 +119,6 @@ void Backbone::stopSearching() {
 
 
 void Backbone::search(QString word) {
-    //TODO add running searches in new threads
     _timer.stop();
     _result.clear();
     _innerResult.clear();
@@ -153,6 +154,11 @@ void Backbone::search(QString word) {
      _dicts[dict] = 1;
  }
 
+ void Backbone::removeDictionary(CommonDictInterface *dict) {
+     _dicts.remove(dict);
+
+ }
+
 
 
  void Backbone::quit() {
@@ -187,17 +193,30 @@ void Backbone::translation() {
 
 
 void Backbone::loadPlugins() {
-    QPluginLoader loader("xdxf.so");
-    if(!loader.load()) {
-        qDebug()<<loader.errorString();
+    QDir plug(QDir::toNativeSeparators(_pluginPath));
+    if(!plug.exists()) {
+        qDebug() << plug.absolutePath() << " folder dosen't exists";
         return;
     }
-    QObject *pl = loader.instance();
+    QStringList nameFilter;
+    nameFilter << "*.so";
+    plug.setFilter(QDir::Files);
+    QStringList files = plug.entryList(nameFilter);
+    qDebug() << files;
+
 
-    qDebug()<<"loaded";
-    CommonDictInterface *plugin = qobject_cast<CommonDictInterface*>(pl);
-    _plugins.append(plugin);
-    addDictionary(plugin->getNew(0)); //TODO change 0 to real settings
+    foreach(QString file, files) {
+        QPluginLoader loader(plug.absoluteFilePath(file));
+        if(!loader.load()) {
+            qDebug()<< file << " " << loader.errorString();
+            continue;
+        }
+        QObject *pl = loader.instance();
+
+        CommonDictInterface *plugin = qobject_cast<CommonDictInterface*>(pl);
+        _plugins.append(plugin);
+        addDictionary(plugin->getNew(0)); //TODO change 0 to real settings
+    }
 }