20
20
#include "agentmanager.h"
21
21
#include "controlmanager.h"
22
22
#include "processcontrol.h"
23
24
#include "akapplication.h"
24
25
#include "akcrash.h"
25
26
#include "akdebug.h"
27
#include "protocol_p.h"
29
29
#include <QtCore/QCoreApplication>
30
30
#include <QtDBus/QDBusConnection>
49
49
int main( int argc, char **argv )
51
AkApplication app( argc, argv );
51
AkCoreApplication app( argc, argv );
52
52
app.setDescription( QLatin1String("Akonadi Control Process\nDo not run this manually, use 'akonadictl' instead to start/stop Akonadi.") );
53
53
app.parseCommandLine();
55
55
// try to acquire the lock first, that means there is no second instance trying to start up at the same time
56
56
// registering the real service name happens in AgentManager::continueStartup(), when everything is in fact up and running
57
if ( !QDBusConnection::sessionBus().registerService( QLatin1String(AKONADI_DBUS_CONTROL_SERVICE_LOCK) ) ) {
57
if ( !QDBusConnection::sessionBus().registerService( AkDBus::serviceName(AkDBus::ControlLock) ) ) {
58
58
// We couldn't register. Most likely, it's already running.
59
59
const QString lastError = QDBusConnection::sessionBus().lastError().message();
60
60
if (lastError.isEmpty())
61
akFatal() << "Unable to register service as" << AKONADI_DBUS_CONTROL_SERVICE_LOCK << "Maybe it's already running?";
61
akFatal() << "Unable to register service as" << AkDBus::serviceName(AkDBus::ControlLock) << "Maybe it's already running?";
63
akFatal() << "Unable to register service as" << AKONADI_DBUS_CONTROL_SERVICE_LOCK << "Error was:" << lastError;
63
akFatal() << "Unable to register service as" << AkDBus::serviceName(AkDBus::ControlLock) << "Error was:" << lastError;
66
66
// older Akonadi server versions don't use the lock service yet, so check if one is already running before we try to start another one
67
if ( QDBusConnection::sessionBus().interface()->isServiceRegistered( QLatin1String(AKONADI_DBUS_CONTROL_SERVICE) ) )
67
if ( QDBusConnection::sessionBus().interface()->isServiceRegistered( AkDBus::serviceName(AkDBus::Control) ) )
68
68
akFatal() << "Another Akonadi control process is already running.";
70
70
new ControlManager;