1
/***************************************************************************
2
* Copyright (C) 2008-2011 Daniel Nicoletti *
5
* This program is free software; you can redistribute it and/or modify *
6
* it under the terms of the GNU General Public License as published by *
7
* the Free Software Foundation; either version 2 of the License, or *
8
* (at your option) any later version. *
10
* This program is distributed in the hope that it will be useful, *
11
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
12
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
13
* GNU General Public License for more details. *
15
* You should have received a copy of the GNU General Public License *
16
* along with this program; if not, write to the *
17
* Free Software Foundation, Inc., *
18
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA . *
19
***************************************************************************/
21
#include "DBusUpdaterInterface.h"
23
#include "apperupdatericonadaptor.h"
25
#include <QtDBus/QDBusConnection>
29
DBusUpdaterInterface::DBusUpdaterInterface(QObject *parent) :
33
(void) new ApperUpdaterIconAdaptor(this);
36
DBusUpdaterInterface::~DBusUpdaterInterface()
43
bool DBusUpdaterInterface::isRegistered() const
48
void DBusUpdaterInterface::ReviewUpdates()
53
void DBusUpdaterInterface::registerService()
56
QDBusServiceWatcher *watcher = qobject_cast<QDBusServiceWatcher*>(sender());
57
if (!m_registered && !QDBusConnection::sessionBus().registerService(QLatin1String("org.kde.ApperUpdaterIcon"))) {
58
kDebug() << "unable to register service to dbus";
60
// in case registration fails due to another user or application running
61
// keep an eye on it so we can register when available
62
watcher = new QDBusServiceWatcher(QLatin1String("org.kde.ApperUpdaterIcon"),
63
QDBusConnection::systemBus(),
64
QDBusServiceWatcher::WatchForUnregistration,
66
connect(watcher, SIGNAL(serviceUnregistered(QString)), this, SLOT(registerService()));
69
emit registeredChanged();
71
if (!QDBusConnection::sessionBus().registerObject("/", this)) {
72
kDebug() << "unable to register service interface to dbus";
77
emit registeredChanged();
81
void DBusUpdaterInterface::unregisterService()
83
// We need to unregister the service since
84
// plasma-desktop won't exit
85
if (QDBusConnection::sessionBus().unregisterService(QLatin1String("org.kde.ApperUpdaterIcon"))) {
87
emit registeredChanged();
89
kDebug() << "unable to unregister service to dbus";