qtmobility/src/sensors/qsensorpluginloader.cpp
changeset 8 71781823f776
parent 5 453da2cfceef
child 11 06b8e2af4411
--- a/qtmobility/src/sensors/qsensorpluginloader.cpp	Fri May 14 16:41:33 2010 +0300
+++ b/qtmobility/src/sensors/qsensorpluginloader.cpp	Thu May 27 13:42:11 2010 +0300
@@ -39,13 +39,13 @@
 **
 ****************************************************************************/
 
-#include <src/global/qbuildcfg.h>
 #include "qsensorpluginloader_p.h"
 #include <QtCore/qcoreapplication.h>
 #include <QtCore/qdir.h>
 #include <QtCore/qdebug.h>
 
 #include "qsensorplugin.h"
+#include "qmobilitypluginsearch.h"
 
 QTM_BEGIN_NAMESPACE
 
@@ -70,42 +70,31 @@
     if (!m_plugins.isEmpty())
         return;
 
-    QStringList     paths = QCoreApplication::libraryPaths();
-    QString val = QLatin1String(qt_mobility_configure_prefix_path_str);
-    if(val.length() > 0){
-        val += QLatin1String("/plugins");
-        paths << val;
-    }
+    QStringList plugins;
+    plugins = mobilityPlugins(QLatin1String("sensors"));
 
-    Q_FOREACH (QString const &path, paths) {
-        QString pluginPathName(path + m_location);
-        QDir pluginDir(pluginPathName);
-
-        if (!pluginDir.exists())
-            continue;
-
-        Q_FOREACH (QString pluginLib, pluginDir.entryList(QDir::Files)) {
-            QPluginLoader *loader = new QPluginLoader(pluginPathName + pluginLib);
+    /* Now discover the dynamic plugins */
+    for (int i=0; i < plugins.count(); i++) {
+        QPluginLoader *loader = new QPluginLoader(plugins.at(i));
 
-            QObject *o = loader->instance();
-            if (o != 0 && o->qt_metacast(m_iid) != 0) {
-                QSensorPluginInterface *p = qobject_cast<QSensorPluginInterface*>(o);
-                if (p != 0) {
-                    m_plugins << p;
-                    m_loaders << loader;
-                } else {
-                    loader->unload();
-                    delete loader;
-                }
+        QObject *o = loader->instance();
+        if (o != 0 && o->qt_metacast(m_iid) != 0) {
+            QSensorPluginInterface *p = qobject_cast<QSensorPluginInterface*>(o);
+            if (p != 0) {
+                m_plugins << p;
+                m_loaders << loader;
+            } else {
+                loader->unload();
+                delete loader;
+            }
 
-                continue;
-            } else {
-                qWarning() << "QSensorPluginLoader: Failed to load plugin: " << pluginLib << loader->errorString();
-            }
-            delete o;
-            loader->unload();
-            delete loader;
+            continue;
+        } else {
+            qWarning() << "QSensorPluginLoader: Failed to load plugin: " << plugins.at(i) << loader->errorString();
         }
+        delete o;
+        loader->unload();
+        delete loader;
     }
 }