BackendManager() { const QStringList pluginPaths = mobilityPlugins(QLatin1String("feedback")); foreach (const QString& pluginPath, pluginPaths) { QPluginLoader loader(pluginPath); hapticsBackend.tryLoad(loader); themeBackend.tryLoad(loader); if (QFeedbackFileInterface *newFile = qobject_cast<QFeedbackFileInterface*>(loader.instance())) { fileBackend.addFileBackend(newFile); } else { loader.unload(); } }
void QVersitContactPluginLoader::loadPlugins() { QStringList plugins = mobilityPlugins(QLatin1String("versit")); if (plugins != mPluginPaths) { mPluginPaths = plugins; foreach (const QString& pluginPath, mPluginPaths) { QPluginLoader qpl(pluginPath); QObject* plugin = qpl.instance(); QVersitContactHandlerFactory* contactPlugin = qobject_cast<QVersitContactHandlerFactory*>(plugin); if (contactPlugin && !mLoadedFactories.contains(contactPlugin->name())) { mLoadedFactories.insert(contactPlugin->name()); mContactHandlerFactories.append(contactPlugin); } }
BackendManager() { QStringList pluginPaths = mobilityPlugins(QLatin1String("feedback")); // Testing hook to force "no plugin mode" #ifdef QTM_BUILD_UNITTESTS if (qApp->property("QFEEDBACK_TEST_NO_PLUGINS").isValid()) pluginPaths.clear(); #endif foreach (const QString& pluginPath, pluginPaths) { QPluginLoader loader(pluginPath); hapticsBackend.tryLoad(loader); themeBackend.tryLoad(loader); if (QFeedbackFileInterface *newFile = qobject_cast<QFeedbackFileInterface*>(loader.instance())) { fileBackend.addFileBackend(newFile); } else { loader.unload(); } }
void QVersitOrganizerPluginLoader::loadPlugins() { QStringList plugins = mobilityPlugins(QLatin1String("versit")); if (plugins != mPluginPaths) { mPluginPaths = plugins; foreach (const QString& pluginPath, mPluginPaths) { QPluginLoader qpl(pluginPath); QObject* plugin = qpl.instance(); QVersitOrganizerHandlerFactory* organizerPlugin = qobject_cast<QVersitOrganizerHandlerFactory*>(plugin); if (organizerPlugin && !mLoadedFactories.contains(organizerPlugin->name())) { mLoadedFactories.insert(organizerPlugin->name()); mOrganizerHandlerFactories.append(organizerPlugin); } else if (!mTimeZoneHandler) { QVersitTimeZoneHandler* timeZonePlugin = qobject_cast<QVersitTimeZoneHandler*>(plugin); if (timeZonePlugin) { mTimeZoneHandler = timeZonePlugin; } } }
void QGeoSatelliteInfoSourcePrivate::loadDynamicPlugins(QHash<QString, QGeoPositionInfoSourceFactory *> &plugins) { QStringList paths; paths << mobilityPlugins(QLatin1String("position")); QPluginLoader qpl; QString blockName; QSettings settings(QSettings::SystemScope, QLatin1String("Nokia"), QLatin1String("QtLocationPosAndSat")); QVariant value = settings.value("position.plugin.operator.whitelist"); if (value.isValid()) { QStringList parts = value.toString().split(","); if (parts.size() == 4) { QFile file(parts.at(1)); file.open(QIODevice::ReadOnly); QCryptographicHash hash(QCryptographicHash::Sha1); while (!file.atEnd()) { QByteArray data = file.read(4096); hash.addData(data); } file.close(); QByteArray hexHash = hash.result().toHex(); bool loadIt = true; if (QString::number(file.size()) != parts.at(3)) { qCritical("Position info plugin: bad plugin size for %s", qPrintable(parts.at(1))); qWarning("Will fall back to platform default"); loadIt = false; } if (hexHash != parts.at(2).toLatin1()) { qCritical("Position info plugin: bad plugin hash for %s", qPrintable(parts.at(1))); qWarning("Will fall back to platform default"); loadIt = false; } if (loadIt) { qpl.setFileName(parts.at(1)); QGeoPositionInfoSourceFactory *f = qobject_cast<QGeoPositionInfoSourceFactory*>(qpl.instance()); if (f) { QString name = f->sourceName(); if (name == parts.at(0)) { plugins.insert(name, f); } else { qCritical("Position info plugin: bad plugin name for %s", qPrintable(parts.at(1))); qWarning("Will fall back to platform default"); } } } // still set blockName to ensure the plugin doesn't load blockName = parts.at(1); } else { qWarning("Position plugin whitelist: invalid format -- should be key,filename,hash,size"); } } for (int i = 0; i < paths.count(); ++i) { if (paths.at(i) != blockName) { qpl.setFileName(paths.at(i)); QGeoPositionInfoSourceFactory *f = qobject_cast<QGeoPositionInfoSourceFactory*>(qpl.instance()); if (f) { QString name = f->sourceName(); #if !defined QT_NO_DEBUG const bool showDebug = qgetenv("QT_DEBUG_PLUGINS").toInt() > 0; if (showDebug) qDebug("Dynamic: found a service provider plugin with name %s", qPrintable(name)); #endif plugins.insertMulti(name, f); } } } }