37 ** |
37 ** |
38 ** $QT_END_LICENSE$ |
38 ** $QT_END_LICENSE$ |
39 ** |
39 ** |
40 ****************************************************************************/ |
40 ****************************************************************************/ |
41 |
41 |
42 #include <src/global/qbuildcfg.h> |
|
43 #include "qmediapluginloader_p.h" |
42 #include "qmediapluginloader_p.h" |
44 #include <QtCore/qcoreapplication.h> |
43 #include <QtCore/qcoreapplication.h> |
45 #include <QtCore/qpluginloader.h> |
44 #include <QtCore/qpluginloader.h> |
46 #include <QtCore/qdir.h> |
45 #include <QtCore/qdir.h> |
47 #include <QtCore/qdebug.h> |
46 #include <QtCore/qdebug.h> |
48 |
47 |
49 #include "qmediaserviceproviderplugin.h" |
48 #include "qmediaserviceproviderplugin.h" |
|
49 #include "qmobilitypluginsearch.h" |
50 |
50 |
51 QT_BEGIN_NAMESPACE |
51 QT_BEGIN_NAMESPACE |
52 |
|
53 |
52 |
54 typedef QMap<QString,QObjectList> ObjectListMap; |
53 typedef QMap<QString,QObjectList> ObjectListMap; |
55 Q_GLOBAL_STATIC(ObjectListMap, staticMediaPlugins); |
54 Q_GLOBAL_STATIC(ObjectListMap, staticMediaPlugins); |
56 |
55 |
57 QMediaPluginLoader::QMediaPluginLoader(const char *iid, const QString &location, Qt::CaseSensitivity): |
56 QMediaPluginLoader::QMediaPluginLoader(const char *iid, const QString &location, Qt::CaseSensitivity): |
96 m_instances.insertMulti(key, o); |
95 m_instances.insertMulti(key, o); |
97 } |
96 } |
98 } |
97 } |
99 } |
98 } |
100 } else { |
99 } else { |
101 QStringList paths = QCoreApplication::libraryPaths(); |
100 QStringList plugins = QTM_PREPEND_NAMESPACE(mobilityPlugins)(m_location); |
102 QString val = qt_mobility_configure_prefix_path_str; |
101 for (int i=0; i < plugins.count(); i++) { |
103 if(val.length() > 0){ |
102 QPluginLoader loader(plugins.at(i)); |
104 val += "/plugins"; |
103 QObject *o = loader.instance(); |
105 paths << val; |
104 if (o != 0 && o->qt_metacast(m_iid) != 0) { |
106 } |
105 QFactoryInterface* p = qobject_cast<QFactoryInterface*>(o); |
|
106 if (p != 0) { |
|
107 foreach (QString const &key, p->keys()) |
|
108 m_instances.insertMulti(key, o); |
|
109 } |
107 |
110 |
108 |
|
109 #ifdef QTM_PLUGIN_PATH |
|
110 paths << QTM_PLUGIN_PATH; |
|
111 #endif |
|
112 |
|
113 foreach (QString const &path, paths) { |
|
114 QString pluginPathName(path + m_location); |
|
115 QDir pluginDir(pluginPathName); |
|
116 |
|
117 if (!pluginDir.exists()) |
|
118 continue; |
111 continue; |
119 |
112 } else { |
120 foreach (QString pluginLib, pluginDir.entryList(QDir::Files)) { |
113 qWarning() << "QMediaPluginLoader: Failed to load plugin: " << plugins.at(i) << loader.errorString(); |
121 QPluginLoader loader(pluginPathName + pluginLib); |
|
122 |
|
123 QObject *o = loader.instance(); |
|
124 if (o != 0 && o->qt_metacast(m_iid) != 0) { |
|
125 QFactoryInterface* p = qobject_cast<QFactoryInterface*>(o); |
|
126 if (p != 0) { |
|
127 foreach (QString const &key, p->keys()) |
|
128 m_instances.insertMulti(key, o); |
|
129 } |
|
130 |
|
131 continue; |
|
132 } else { |
|
133 qWarning() << "QMediaPluginLoader: Failed to load plugin: " << pluginLib << loader.errorString(); |
|
134 } |
|
135 delete o; |
|
136 loader.unload(); |
|
137 } |
114 } |
|
115 delete o; |
|
116 loader.unload(); |
138 } |
117 } |
139 } |
118 } |
140 } |
119 } |
141 QT_END_NAMESPACE |
120 QT_END_NAMESPACE |
142 |
121 |