Akonadi

server/main.cpp
1 /***************************************************************************
2  * SPDX-FileCopyrightText: 2006 Till Adam <[email protected]> *
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 
21 #include <cstdlib>
22 
23 #ifdef QT_STATICPLUGIN
24 
25 Q_IMPORT_PLUGIN(qsqlite3)
26 #endif
27 
28 int 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
39  KAboutLicense::LGPL_V2);
41 
42 #if !defined(NDEBUG)
43  const QCommandLineOption startWithoutControlOption(
44  QStringLiteral("start-without-control"),
45  QStringLiteral("Allow to start the Akonadi server without the Akonadi control process being available"));
46  app.addCommandLineOptions(startWithoutControlOption);
47 #endif
48 
49  app.parseCommandLine();
50 
51 #if !defined(NDEBUG)
52  if (!app.commandLineArguments().isSet(QStringLiteral("start-without-control")) &&
53 #else
54  if (true &&
55 #endif
56  !QDBusConnection::sessionBus().interface()->isServiceRegistered(Akonadi::DBus::serviceName(Akonadi::DBus::ControlLock))) {
57  qCCritical(AKONADISERVER_LOG) << "Akonadi control process not found - aborting.";
58  qCCritical(AKONADISERVER_LOG) << "If you started akonadiserver manually, try 'akonadictl start' instead.";
59  }
60 
61  Akonadi::Server::AkonadiServer akonadi;
62  // Make sure we do initialization from eventloop, otherwise
63  // org.freedesktop.Akonadi.upgrading service won't be registered to DBus at all
64  QTimer::singleShot(0, &akonadi, &Akonadi::Server::AkonadiServer::init);
65 
66  const int result = app.exec();
67 
68  qCInfo(AKONADISERVER_LOG) << "Shutting down AkonadiServer...";
69  akonadi.quit();
70 
71  Q_CLEANUP_RESOURCE(akonadidb);
72 
73  return result;
74 }
QDBusConnection sessionBus()
static void setApplicationData(const KAboutData &aboutData)
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Sun Jul 12 2020 23:16:57 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.