equal
deleted
inserted
replaced
37 ** |
37 ** |
38 ** $QT_END_LICENSE$ |
38 ** $QT_END_LICENSE$ |
39 ** |
39 ** |
40 ****************************************************************************/ |
40 ****************************************************************************/ |
41 |
41 |
42 #include <src/global/qbuildcfg.h> |
|
43 #include "qsensorpluginloader_p.h" |
42 #include "qsensorpluginloader_p.h" |
44 #include <QtCore/qcoreapplication.h> |
43 #include <QtCore/qcoreapplication.h> |
45 #include <QtCore/qdir.h> |
44 #include <QtCore/qdir.h> |
46 #include <QtCore/qdebug.h> |
45 #include <QtCore/qdebug.h> |
47 |
46 |
48 #include "qsensorplugin.h" |
47 #include "qsensorplugin.h" |
|
48 #include "qmobilitypluginsearch.h" |
49 |
49 |
50 QTM_BEGIN_NAMESPACE |
50 QTM_BEGIN_NAMESPACE |
51 |
51 |
52 QSensorPluginLoader::QSensorPluginLoader(const char *iid, const QString &location) |
52 QSensorPluginLoader::QSensorPluginLoader(const char *iid, const QString &location) |
53 : m_iid(iid) |
53 : m_iid(iid) |
68 void QSensorPluginLoader::load() |
68 void QSensorPluginLoader::load() |
69 { |
69 { |
70 if (!m_plugins.isEmpty()) |
70 if (!m_plugins.isEmpty()) |
71 return; |
71 return; |
72 |
72 |
73 QStringList paths = QCoreApplication::libraryPaths(); |
73 QStringList plugins; |
74 QString val = QLatin1String(qt_mobility_configure_prefix_path_str); |
74 plugins = mobilityPlugins(QLatin1String("sensors")); |
75 if(val.length() > 0){ |
|
76 val += QLatin1String("/plugins"); |
|
77 paths << val; |
|
78 } |
|
79 |
75 |
80 Q_FOREACH (QString const &path, paths) { |
76 /* Now discover the dynamic plugins */ |
81 QString pluginPathName(path + m_location); |
77 for (int i=0; i < plugins.count(); i++) { |
82 QDir pluginDir(pluginPathName); |
78 QPluginLoader *loader = new QPluginLoader(plugins.at(i)); |
83 |
79 |
84 if (!pluginDir.exists()) |
80 QObject *o = loader->instance(); |
|
81 if (o != 0 && o->qt_metacast(m_iid) != 0) { |
|
82 QSensorPluginInterface *p = qobject_cast<QSensorPluginInterface*>(o); |
|
83 if (p != 0) { |
|
84 m_plugins << p; |
|
85 m_loaders << loader; |
|
86 } else { |
|
87 loader->unload(); |
|
88 delete loader; |
|
89 } |
|
90 |
85 continue; |
91 continue; |
86 |
92 } else { |
87 Q_FOREACH (QString pluginLib, pluginDir.entryList(QDir::Files)) { |
93 qWarning() << "QSensorPluginLoader: Failed to load plugin: " << plugins.at(i) << loader->errorString(); |
88 QPluginLoader *loader = new QPluginLoader(pluginPathName + pluginLib); |
|
89 |
|
90 QObject *o = loader->instance(); |
|
91 if (o != 0 && o->qt_metacast(m_iid) != 0) { |
|
92 QSensorPluginInterface *p = qobject_cast<QSensorPluginInterface*>(o); |
|
93 if (p != 0) { |
|
94 m_plugins << p; |
|
95 m_loaders << loader; |
|
96 } else { |
|
97 loader->unload(); |
|
98 delete loader; |
|
99 } |
|
100 |
|
101 continue; |
|
102 } else { |
|
103 qWarning() << "QSensorPluginLoader: Failed to load plugin: " << pluginLib << loader->errorString(); |
|
104 } |
|
105 delete o; |
|
106 loader->unload(); |
|
107 delete loader; |
|
108 } |
94 } |
|
95 delete o; |
|
96 loader->unload(); |
|
97 delete loader; |
109 } |
98 } |
110 } |
99 } |
111 |
100 |
112 QTM_END_NAMESPACE |
101 QTM_END_NAMESPACE |
113 |
102 |