Commit 3a40acbd authored by Volker Krause's avatar Volker Krause
Browse files

Add an environment variable to disable Akonadi auto-launching

This is useful e.g. in the CI environment for automated tests.
parent 16b5e7d8
Pipeline #203630 failed with stage
in 2 minutes and 9 seconds
......@@ -7,6 +7,14 @@ target_sources(akonadicalendarplugin PRIVATE
singlecollectioncalendar.cpp
)
ecm_qt_declare_logging_category(akonadicalendarplugin
HEADER akonadicalendarplugin_debug.h
IDENTIFIER AKONADICALENDARPLUGIN_LOG
CATEGORY_NAME org.kde.kcalendarcore.akonadiplugin
DESCRIPTION "KCalendarCore (Akonadi plugin)"
EXPORT AKONADI-CALENDAR
)
target_link_libraries(akonadicalendarplugin PRIVATE
KF5::CalendarCore
KF5::AkonadiCalendar
......
......@@ -4,11 +4,13 @@
*/
#include "akonadicalendarplugin.h"
#include "akonadicalendarplugin_debug.h"
#include "singlecollectioncalendar.h"
#include <Akonadi/CollectionFetchJob>
#include <Akonadi/CollectionFetchScope>
#include <Akonadi/Monitor>
#include <Akonadi/ServerManager>
#include <KCalendarCore/Event>
#include <KCalendarCore/Journal>
......@@ -24,6 +26,13 @@ static bool filterCollection(const Akonadi::Collection &col)
AkonadiCalendarPlugin::AkonadiCalendarPlugin(QObject *parent, const QVariantList &args)
: KCalendarCore::CalendarPlugin(parent, args)
{
// don't automatically start Akonadi if that's explicitly forbidden
// (useful in e.g. the CI environment)
if (qEnvironmentVariableIsSet("AKONADI_CALENDAR_KCALENDARCORE_PLUGIN_NO_AUTO_LAUNCH") && !Akonadi::ServerManager::isRunning()) {
qCWarning(AKONADICALENDARPLUGIN_LOG) << "Akonadi is not running, but auto-launch is disabled!";
return;
}
auto job = new Akonadi::CollectionFetchJob(Akonadi::Collection::root(), Akonadi::CollectionFetchJob::Recursive, this);
job->fetchScope().setContentMimeTypes(KCalendarCore::Incidence::mimeTypes());
connect(job, &Akonadi::CollectionFetchJob::finished, this, [this, job]() {
......
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