Akonadi

akonadistarter.cpp
1/*
2 SPDX-FileCopyrightText: 2008 Volker Krause <vkrause@kde.org>
3
4 SPDX-License-Identifier: LGPL-2.0-or-later
5*/
6
7#include "akonadistarter.h"
8#include "akonadictl_debug.h"
9
10#include "shared/akapplication.h"
11
12#include "private/dbus_p.h"
13#include "private/instance_p.h"
14
15#include <QCoreApplication>
16#include <QDBusConnection>
17#include <QProcess>
18#include <QStandardPaths>
19#include <QTimer>
20
21#include <iostream>
22
23AkonadiStarter::AkonadiStarter(QObject *parent)
24 : QObject(parent)
25 , mWatcher(Akonadi::DBus::serviceName(Akonadi::DBus::ControlLock), QDBusConnection::sessionBus(), QDBusServiceWatcher::WatchForRegistration)
26{
27 connect(&mWatcher, &QDBusServiceWatcher::serviceRegistered, this, [this]() {
28 mRegistered = true;
30 });
31}
32
33bool AkonadiStarter::start(bool verbose)
34{
35 qCInfo(AKONADICTL_LOG) << "Starting Akonadi Server...";
36
38 if (Akonadi::Instance::hasIdentifier()) {
39 serverArgs << QStringLiteral("--instance") << Akonadi::Instance::identifier();
40 }
41 if (verbose) {
42 serverArgs << QStringLiteral("--verbose");
43 }
44
45 const QString exec = QStandardPaths::findExecutable(QStringLiteral("akonadi_control"));
46 if (exec.isEmpty() || !QProcess::startDetached(exec, serverArgs)) {
47 std::cerr << "Error: unable to execute binary akonadi_control" << std::endl;
48 return false;
49 }
50
51 // safety timeout
53 // wait for the server to register with D-Bus
55
56 if (!mRegistered) {
57 std::cerr << "Error: akonadi_control was started but didn't register at D-Bus session bus." << std::endl
58 << "Make sure your system is set up correctly!" << std::endl;
59 return false;
60 }
61
62 qCInfo(AKONADICTL_LOG) << " done.";
63 return true;
64}
65
66#include "moc_akonadistarter.cpp"
Helper integration between Akonadi and Qt.
QCoreApplication * instance()
void serviceRegistered(const QString &serviceName)
T qobject_cast(QObject *object)
bool startDetached(const QString &program, const QStringList &arguments, const QString &workingDirectory, qint64 *pid)
QString findExecutable(const QString &executableName, const QStringList &paths)
bool isEmpty() const const
QFuture< ArgsType< Signal > > connect(Sender *sender, Signal signal)
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Tue Mar 26 2024 11:13:38 by doxygen 1.10.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.