Changeset View
Changeset View
Standalone View
Standalone View
src/personpluginmanager.cpp
Show First 20 Lines • Show All 55 Lines • ▼ Show 20 Line(s) | |||||
56 | 56 | | |||
57 | PersonPluginManagerPrivate::~PersonPluginManagerPrivate() | 57 | PersonPluginManagerPrivate::~PersonPluginManagerPrivate() | ||
58 | { | 58 | { | ||
59 | qDeleteAll(dataSourcePlugins); | 59 | qDeleteAll(dataSourcePlugins); | ||
60 | } | 60 | } | ||
61 | 61 | | |||
62 | void PersonPluginManagerPrivate::loadDataSourcePlugins() | 62 | void PersonPluginManagerPrivate::loadDataSourcePlugins() | ||
63 | { | 63 | { | ||
64 | QVector<KPluginMetaData> pluginList = KPluginLoader::findPlugins(QStringLiteral("kpeople/datasource")); | 64 | const QVector<KPluginMetaData> pluginList = KPluginLoader::findPlugins(QStringLiteral("kpeople/datasource")); | ||
65 | Q_FOREACH (const KPluginMetaData &service, pluginList) { | 65 | for (const KPluginMetaData &service : pluginList) { | ||
66 | KPluginLoader loader(service.fileName()); | 66 | KPluginLoader loader(service.fileName()); | ||
67 | KPluginFactory *factory = loader.factory(); | 67 | KPluginFactory *factory = loader.factory(); | ||
68 | BasePersonsDataSource *dataSource = factory->create<BasePersonsDataSource>(); | 68 | BasePersonsDataSource *dataSource = factory->create<BasePersonsDataSource>(); | ||
69 | if (dataSource) { | 69 | if (dataSource) { | ||
70 | const QString pluginId = dataSource->sourcePluginId(); | 70 | const QString pluginId = dataSource->sourcePluginId(); | ||
71 | if (!dataSourcePlugins.contains(pluginId)) { | 71 | if (!dataSourcePlugins.contains(pluginId)) { | ||
72 | dataSourcePlugins[pluginId] = dataSource; | 72 | dataSourcePlugins[pluginId] = dataSource; | ||
73 | } else { | 73 | } else { | ||
74 | dataSource->deleteLater(); | 74 | dataSource->deleteLater(); | ||
75 | qCDebug(KPEOPLE_LOG) << "Plugin" << pluginId << "was already loaded manually, ignoring..."; | 75 | qCDebug(KPEOPLE_LOG) << "Plugin" << pluginId << "was already loaded manually, ignoring..."; | ||
76 | } | 76 | } | ||
77 | } else { | 77 | } else { | ||
78 | qCWarning(KPEOPLE_LOG) << "Failed to create data source " << service.name() << service.fileName(); | 78 | qCWarning(KPEOPLE_LOG) << "Failed to create data source " << service.name() << service.fileName(); | ||
79 | } | 79 | } | ||
80 | } | 80 | } | ||
81 | 81 | | |||
82 | //TODO: Remove as soon as KTp sources are released with the new plugin system | 82 | //TODO: Remove as soon as KTp sources are released with the new plugin system | ||
83 | KService::List servicesList = KServiceTypeTrader::self()->query(QStringLiteral("KPeople/DataSource")); | 83 | const KService::List servicesList = KServiceTypeTrader::self()->query(QStringLiteral("KPeople/DataSource")); | ||
84 | Q_FOREACH (const KService::Ptr &service, servicesList) { | 84 | for (const KService::Ptr &service : servicesList) { | ||
85 | BasePersonsDataSource *dataSource = service->createInstance<BasePersonsDataSource>(nullptr); | 85 | BasePersonsDataSource *dataSource = service->createInstance<BasePersonsDataSource>(nullptr); | ||
86 | 86 | | |||
87 | 87 | | |||
88 | if (dataSource) { | 88 | if (dataSource) { | ||
89 | dataSourcePlugins[dataSource->sourcePluginId()] = dataSource; | 89 | dataSourcePlugins[dataSource->sourcePluginId()] = dataSource; | ||
90 | } else { | 90 | } else { | ||
91 | qCWarning(KPEOPLE_LOG) << "Failed to create data source " << service->name() << service->path(); | 91 | qCWarning(KPEOPLE_LOG) << "Failed to create data source " << service->name() << service->path(); | ||
92 | } | 92 | } | ||
▲ Show 20 Lines • Show All 45 Lines • Show Last 20 Lines |