Commit 71f7d44c authored by Nicolas Fella's avatar Nicolas Fella
Browse files

Drop infrastructure to load non-decoration plugins

There are no other relevant plugins besides decoration plugins.

Printer plugins exist, but they are purely interal to eventviews and KOrganizer does not load them directly
parent bf8663e5
......@@ -46,11 +46,6 @@ KService::List KOCore::availablePlugins(const QString &type, int version)
return KServiceTypeTrader::self()->query(type, constraint);
}
KService::List KOCore::availablePlugins()
{
return availablePlugins(CalendarSupport::Plugin::serviceType(), CalendarSupport::Plugin::interfaceVersion());
}
KService::List KOCore::availableCalendarDecorations()
{
return availablePlugins(EventViews::CalendarDecoration::Decoration::serviceType(), EventViews::CalendarDecoration::Decoration::interfaceVersion());
......@@ -61,45 +56,6 @@ KService::List KOCore::availableParts()
return availablePlugins(KOrg::Part::serviceType(), KOrg::Part::interfaceVersion());
}
CalendarSupport::Plugin *KOCore::loadPlugin(const KService::Ptr &service)
{
qCDebug(KORGANIZER_LOG) << service->library();
if (!service->hasServiceType(CalendarSupport::Plugin::serviceType())) {
return nullptr;
}
KPluginLoader loader(*service);
auto factory = loader.instance();
if (!factory) {
qCDebug(KORGANIZER_LOG) << "Factory creation failed";
return nullptr;
}
auto pluginFactory = qobject_cast<CalendarSupport::PluginFactory *>(factory);
if (!pluginFactory) {
qCDebug(KORGANIZER_LOG) << "Cast failed";
return nullptr;
}
return pluginFactory->createPluginFactory();
}
CalendarSupport::Plugin *KOCore::loadPlugin(const QString &name)
{
KService::List list = availablePlugins();
KService::List::ConstIterator it;
KService::List::ConstIterator end(list.constEnd());
for (it = list.constBegin(); it != end; ++it) {
if ((*it)->desktopEntryName() == name) {
return loadPlugin(*it);
}
}
return nullptr;
}
EventViews::CalendarDecoration::Decoration *KOCore::loadCalendarDecoration(const KService::Ptr &service)
{
KPluginLoader loader(*service);
......
......@@ -28,13 +28,9 @@ public:
static KOCore *self();
Q_REQUIRED_RESULT KService::List availablePlugins();
Q_REQUIRED_RESULT KService::List availableCalendarDecorations();
Q_REQUIRED_RESULT KService::List availableParts();
CalendarSupport::Plugin *loadPlugin(const KService::Ptr &service);
CalendarSupport::Plugin *loadPlugin(const QString &);
EventViews::CalendarDecoration::Decoration *loadCalendarDecoration(const KService::Ptr &service);
EventViews::CalendarDecoration::Decoration *loadCalendarDecoration(const QString &);
......
......@@ -123,7 +123,7 @@ KOPrefsDialogPlugins::~KOPrefsDialogPlugins()
void KOPrefsDialogPlugins::usrReadConfig()
{
mTreeWidget->clear();
KService::List plugins = KOCore::self()->availablePlugins();
KService::List plugins = KOCore::self()->availableCalendarDecorations();
plugins += KOCore::self()->availableParts();
EventViews::PrefsPtr viewPrefs = KOPrefs::instance()->eventViewsPreferences();
......@@ -191,7 +191,7 @@ void KOPrefsDialogPlugins::configure()
return;
}
CalendarSupport::Plugin *plugin = KOCore::self()->loadPlugin(item->service());
EventViews::CalendarDecoration::Decoration *plugin = KOCore::self()->loadCalendarDecoration(item->service());
if (plugin) {
plugin->configure(this);
......
......@@ -23,19 +23,8 @@ int main(int argc, char **argv)
parser.addHelpOption();
parser.process(app);
KService::List plugins = KOCore::self()->availablePlugins();
KService::List::ConstIterator it;
for (it = plugins.constBegin(); it != plugins.constEnd(); ++it) {
qDebug() << "Plugin:" << (*it)->desktopEntryName() << "(" << (*it)->name() << ")";
CalendarSupport::Plugin *p = KOCore::self()->loadPlugin(*it);
if (!p) {
qDebug() << "Plugin loading failed.";
} else {
qDebug() << "PLUGIN INFO:" << p->info();
}
}
plugins = KOCore::self()->availableParts();
KService::List plugins = KOCore::self()->availableParts();
for (it = plugins.constBegin(); it != plugins.constEnd(); ++it) {
qDebug() << "Part:" << (*it)->desktopEntryName() << "(" << (*it)->name() << ")";
KOrg::Part *p = KOCore::self()->loadPart(*it, nullptr);
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment