Commit 51516f45 authored by Volker Krause's avatar Volker Krause
Browse files

Integrate the Android calendar plugin as a static plugin

This decouples the calendar plugin loader class entirely from the Android
plugin, which makes it movable to KCalendarCore independent of the Android
support.
parent 020ac2de
Pipeline #192226 passed with stage
in 4 minutes and 20 seconds
......@@ -11,6 +11,7 @@ generate_export_header(KCalendarCoreExtras BASE_NAME KCalendarCoreExtras)
target_sources(KCalendarCoreExtras PRIVATE
calendarlistmodel.cpp
calendarpluginloader.cpp
integration.cpp
)
if (ANDROID)
......@@ -20,6 +21,7 @@ if (ANDROID)
androidcalendarplugin.cpp
androidicalconverter.cpp
)
target_compile_definitions(KCalendarCoreExtras PRIVATE -DQT_STATICPLUGIN)
target_link_libraries(KCalendarCoreExtras PRIVATE KAndroidExtras LibIcal)
endif()
......
......@@ -13,8 +13,10 @@
/** Android system calendar plugin. */
class AndroidCalendarPlugin : public KCalendarCore::CalendarPlugin
{
Q_OBJECT
Q_PLUGIN_METADATA(IID "org.kde.kcalendarcore.CalendarPlugin")
public:
explicit AndroidCalendarPlugin (QObject *parent, const QVariantList &args);
explicit AndroidCalendarPlugin (QObject *parent = nullptr, const QVariantList &args = {});
~AndroidCalendarPlugin();
QVector<KCalendarCore::Calendar::Ptr> calendars() const override;
......
......@@ -5,10 +5,6 @@
#include "calendarpluginloader.h"
#ifdef Q_OS_ANDROID
#include "androidcalendarplugin.h"
#endif
#include <QCoreApplication>
#include <QDirIterator>
#include <QPluginLoader>
......@@ -22,9 +18,18 @@ struct PluginLoader {
PluginLoader::PluginLoader()
{
#ifdef Q_OS_ANDROID
plugin.reset(new AndroidCalendarPlugin(nullptr, {}));
#else
// static plugins
const auto staticPluginData = QPluginLoader::staticPlugins();
for (const auto &data : staticPluginData) {
if (data.metaData().value(QLatin1String("IID")).toString() == QLatin1String("org.kde.kcalendarcore.CalendarPlugin")) {
plugin.reset(qobject_cast<KCalendarCore::CalendarPlugin*>(data.instance()));
}
if (plugin) {
return;
}
}
// dynamic plugins
QStringList searchPaths(QCoreApplication::applicationDirPath());
searchPaths += QCoreApplication::libraryPaths();
......@@ -40,7 +45,6 @@ PluginLoader::PluginLoader()
}
}
}
#endif
}
Q_GLOBAL_STATIC(PluginLoader, s_pluginLoader)
......
/*
SPDX-FileCopyrightText: 2022 Volker Krause <vkrause@kde.org>
SPDX-License-Identifier: LGPL-2.0-or-later
*/
#include <QPluginLoader>
#ifdef Q_OS_ANDROID
#include "androidcalendarplugin.h"
Q_IMPORT_PLUGIN(AndroidCalendarPlugin)
#endif
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