Akonadi

server/main.cpp
1/***************************************************************************
2 * SPDX-FileCopyrightText: 2006 Till Adam <adam@kde.org> *
3 * *
4 * SPDX-License-Identifier: LGPL-2.0-or-later *
5 ***************************************************************************/
6
7#include "akonadi.h"
8#include "akonadifull-version.h"
9#include "akonadiserver_debug.h"
10
11#include "shared/akapplication.h"
12
13#include "private/dbus_p.h"
14
15#include <QDBusConnection>
16#include <QDBusConnectionInterface>
17#include <QTimer>
18
19#include <KAboutData>
20#include <KCrash>
21#include <cstdlib>
22
23#ifdef QT_STATICPLUGIN
24
25Q_IMPORT_PLUGIN(qsqlite3)
26#endif
27
28int main(int argc, char **argv)
29{
30 Q_INIT_RESOURCE(akonadidb);
31 AkCoreApplication app(argc, argv, AKONADISERVER_LOG());
32 app.setDescription(QStringLiteral("Akonadi Server\nDo not run manually, use 'akonadictl' instead to start/stop Akonadi."));
33
34 // Set KAboutData so that DrKonqi can report bugs
35 KAboutData aboutData(QStringLiteral("akonadiserver"),
36 QStringLiteral("Akonadi Server"), // we don't have any localization in the server
37 QStringLiteral(AKONADI_FULL_VERSION),
38 QStringLiteral("Akonadi Server"), // we don't have any localization in the server
42#if !defined(NDEBUG)
43 const QCommandLineOption startWithoutControlOption(QStringLiteral("start-without-control"),
44 QStringLiteral("Allow to start the Akonadi server without the Akonadi control process being available"));
45 app.addCommandLineOptions(startWithoutControlOption);
46#endif
47
48 app.parseCommandLine();
49
50#if !defined(NDEBUG)
51 if (!app.commandLineArguments().isSet(QStringLiteral("start-without-control")) &&
52#else
53 if (true &&
54#endif
55 !QDBusConnection::sessionBus().interface()->isServiceRegistered(Akonadi::DBus::serviceName(Akonadi::DBus::ControlLock))) {
56 qCCritical(AKONADISERVER_LOG) << "Akonadi control process not found - aborting.";
57 qCCritical(AKONADISERVER_LOG) << "If you started akonadiserver manually, try 'akonadictl start' instead.";
58 }
59
60 Akonadi::Server::AkonadiServer akonadi;
61 // Make sure we do initialization from eventloop, otherwise
62 // org.freedesktop.Akonadi.upgrading service won't be registered to DBus at all
63 QTimer::singleShot(0, &akonadi, &Akonadi::Server::AkonadiServer::init);
64
65 const int result = app.exec();
66
67 qCInfo(AKONADISERVER_LOG) << "Shutting down AkonadiServer...";
68 akonadi.quit();
69
70 Q_CLEANUP_RESOURCE(akonadidb);
71
72 return result;
73}
static void setApplicationData(const KAboutData &aboutData)
KCRASH_EXPORT void initialize()
QDBusConnection sessionBus()
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Mon Nov 4 2024 16:31:59 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.