File indexing completed on 2024-06-16 04:50:00

0001 /*
0002     SPDX-FileCopyrightText: 2010 Volker Krause <vkrause@kde.org>
0003 
0004     SPDX-License-Identifier: LGPL-2.0-or-later
0005 */
0006 
0007 #include "agentserver.h"
0008 #include "akonadiagentserver_debug.h"
0009 
0010 #include "private/dbus_p.h"
0011 
0012 #include "shared/akapplication.h"
0013 
0014 #include <QDBusConnection>
0015 #include <QDBusConnectionInterface>
0016 
0017 int main(int argc, char **argv)
0018 {
0019     AkCoreApplication app(argc, argv, AKONADIAGENTSERVER_LOG());
0020     app.setDescription(QStringLiteral("Akonadi Agent Server\nDo not run manually, use 'akonadictl' instead to start/stop Akonadi."));
0021     app.parseCommandLine();
0022 
0023     if (!QDBusConnection::sessionBus().interface()->isServiceRegistered(Akonadi::DBus::serviceName(Akonadi::DBus::ControlLock))) {
0024         qCCritical(AKONADIAGENTSERVER_LOG) << "Akonadi control process not found - aborting.";
0025         qFatal("If you started akonadi_agent_server manually, try 'akonadictl start' instead.");
0026     }
0027 
0028     new Akonadi::AgentServer(&app);
0029 
0030     if (!QDBusConnection::sessionBus().registerService(Akonadi::DBus::serviceName(Akonadi::DBus::AgentServer))) {
0031         qFatal("Unable to connect to dbus service: %s", qPrintable(QDBusConnection::sessionBus().lastError().message()));
0032     }
0033 
0034     return app.exec();
0035 }