File indexing completed on 2025-01-05 04:47:03
0001 /*************************************************************************** 0002 * SPDX-FileCopyrightText: 2006 Till Adam <adam@kde.org> * 0003 * * 0004 * SPDX-License-Identifier: LGPL-2.0-or-later * 0005 ***************************************************************************/ 0006 0007 #include "akonadi.h" 0008 #include "akonadifull-version.h" 0009 #include "akonadiserver_debug.h" 0010 0011 #include "shared/akapplication.h" 0012 0013 #include "private/dbus_p.h" 0014 0015 #include <QDBusConnection> 0016 #include <QDBusConnectionInterface> 0017 #include <QTimer> 0018 0019 #include <KAboutData> 0020 0021 #include <cstdlib> 0022 0023 #ifdef QT_STATICPLUGIN 0024 0025 Q_IMPORT_PLUGIN(qsqlite3) 0026 #endif 0027 0028 int main(int argc, char **argv) 0029 { 0030 Q_INIT_RESOURCE(akonadidb); 0031 AkCoreApplication app(argc, argv, AKONADISERVER_LOG()); 0032 app.setDescription(QStringLiteral("Akonadi Server\nDo not run manually, use 'akonadictl' instead to start/stop Akonadi.")); 0033 0034 // Set KAboutData so that DrKonqi can report bugs 0035 KAboutData aboutData(QStringLiteral("akonadiserver"), 0036 QStringLiteral("Akonadi Server"), // we don't have any localization in the server 0037 QStringLiteral(AKONADI_FULL_VERSION), 0038 QStringLiteral("Akonadi Server"), // we don't have any localization in the server 0039 KAboutLicense::LGPL_V2); 0040 KAboutData::setApplicationData(aboutData); 0041 0042 #if !defined(NDEBUG) 0043 const QCommandLineOption startWithoutControlOption(QStringLiteral("start-without-control"), 0044 QStringLiteral("Allow to start the Akonadi server without the Akonadi control process being available")); 0045 app.addCommandLineOptions(startWithoutControlOption); 0046 #endif 0047 0048 app.parseCommandLine(); 0049 0050 #if !defined(NDEBUG) 0051 if (!app.commandLineArguments().isSet(QStringLiteral("start-without-control")) && 0052 #else 0053 if (true && 0054 #endif 0055 !QDBusConnection::sessionBus().interface()->isServiceRegistered(Akonadi::DBus::serviceName(Akonadi::DBus::ControlLock))) { 0056 qCCritical(AKONADISERVER_LOG) << "Akonadi control process not found - aborting."; 0057 qCCritical(AKONADISERVER_LOG) << "If you started akonadiserver manually, try 'akonadictl start' instead."; 0058 } 0059 0060 Akonadi::Server::AkonadiServer akonadi; 0061 // Make sure we do initialization from eventloop, otherwise 0062 // org.freedesktop.Akonadi.upgrading service won't be registered to DBus at all 0063 QTimer::singleShot(0, &akonadi, &Akonadi::Server::AkonadiServer::init); 0064 0065 const int result = app.exec(); 0066 0067 qCInfo(AKONADISERVER_LOG) << "Shutting down AkonadiServer..."; 0068 akonadi.quit(); 0069 0070 Q_CLEANUP_RESOURCE(akonadidb); 0071 0072 return result; 0073 }