2
* Copyright (C) 2010 Ivan Cukic <ivan.cukic(at)kde.org>
4
* This program is free software; you can redistribute it and/or modify
5
* it under the terms of the GNU General Public License version 2,
6
* or (at your option) any later version, as published by the Free
9
* This program is distributed in the hope that it will be useful,
10
* but WITHOUT ANY WARRANTY; without even the implied warranty of
11
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
* GNU General Public License for more details
14
* You should have received a copy of the GNU General Public
15
* License along with this program; if not, write to the
16
* Free Software Foundation, Inc.,
17
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
20
#include "manager_p.h"
22
#include <QDBusConnection>
24
#include <ktoolinvocation.h>
27
namespace KActivities {
29
Manager * Manager::s_instance = NULL;
31
// #define ACTIVITY_MANAGER_DBUS_PATH "org.kde.ActivityManager"
32
#define ACTIVITY_MANAGER_DBUS_PATH "org.kde.kactivitymanagerd"
33
#define ACTIVITY_MANAGER_DBUS_OBJECT "/ActivityManager"
36
: org::kde::ActivityManager(
37
ACTIVITY_MANAGER_DBUS_PATH,
38
ACTIVITY_MANAGER_DBUS_OBJECT,
39
QDBusConnection::sessionBus()
42
connect(&m_watcher, SIGNAL(serviceOwnerChanged(const QString &, const QString &, const QString &)),
43
this, SLOT(serviceOwnerChanged(const QString &, const QString &, const QString &)));
46
Manager * Manager::self()
49
// check if the activity manager is already running
50
if (!isActivityServiceRunning()) {
52
// not running, trying to launch it
55
int ret = KToolInvocation::startServiceByDesktopPath("kactivitymanagerd.desktop", QStringList(), &error);
57
kDebug() << "Activity: Couldn't start kactivitymanagerd: " << error << endl;
60
if (!QDBusConnection::sessionBus().interface()->isServiceRegistered(ACTIVITY_MANAGER_DBUS_PATH)) {
61
kDebug() << "Activity: The kactivitymanagerd service is still not registered";
63
kDebug() << "Activity: The kactivitymanagerd service has been registered";
67
// creating a new instance of the class
68
s_instance = new Manager();
74
bool Manager::isActivityServiceRunning()
76
return QDBusConnection::sessionBus().interface()->isServiceRegistered(ACTIVITY_MANAGER_DBUS_PATH);
79
void Manager::serviceOwnerChanged(const QString & serviceName, const QString & oldOwner, const QString & newOwner)
83
if (serviceName == ACTIVITY_MANAGER_DBUS_PATH) {
84
emit presenceChanged(!newOwner.isEmpty());
88
} // namespace KActivities