1
/* Copyright (C) 2008 Michael Jansen <kde@michael-jansen.biz>
3
This library is free software; you can redistribute it and/or
4
modify it under the terms of the GNU Library General Public
5
License as published by the Free Software Foundation; either
6
version 2 of the License, or (at your option) any later version.
8
This library is distributed in the hope that it will be useful,
9
but WITHOUT ANY WARRANTY; without even the implied warranty of
10
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11
Library General Public License for more details.
13
You should have received a copy of the GNU Library General Public License
14
along with this library; see the file COPYING.LIB. If not, write to
15
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
16
Boston, MA 02110-1301, USA.
23
#include "khotkeysglobal.h"
25
#include <QtDBus/QtDBus>
27
#include <KDE/KConfigGroup>
28
#include <KDE/KConfig>
30
#include "KDE/KLocale"
33
namespace KHotKeys { namespace Daemon {
38
KConfig khotkeysrc( KHOTKEYS_CONFIG_FILE );
39
KConfigGroup main( &khotkeysrc, "Main" );
40
return ! main.readEntry( "Disabled", false );
43
static QDBusInterface* Kded()
45
QDBusInterface *iface = new QDBusInterface( "org.kde.kded", "/kded","org.kde.kded" );
46
if (!iface->isValid())
48
QDBusError err = iface->lastError();
51
kError() << "Failed to contact kded [" << err.name() << "]:" << err.message();
60
std::auto_ptr<QDBusInterface> kded( Kded() );
66
// I started with checking if i could get a valid /KHotKeys Interface. But
67
// it resisted to work. So lets do the other thing.
68
QDBusReply<QStringList> modules = kded->call( "loadedModules" );
69
return modules.value().contains("khotkeys");
76
std::auto_ptr<QDBusInterface> kded( Kded() );
82
// Inform kdedkhotkeys demon to reload settings
83
QDBusConnection bus = QDBusConnection::sessionBus();
91
QDBusError err = iface.lastError();
94
kError() << err.name() << ":" << err.message();
99
QDBusMessage reply = iface.call("reread_configuration");
100
QDBusError err = iface.lastError();
103
kError() << err.name() << ":" << err.message();
113
std::auto_ptr<QDBusInterface> kded( Kded() );
114
if (!kded->isValid())
118
QDBusReply<bool> reply = kded->call( "loadModule", "khotkeys" );
119
QDBusError err = reply.error();
123
kError() << "Unable to start server org.kde.khotkeys (kded module) ["
124
<< err.name() << "]:" << err.message();
128
Q_ASSERT( reply.isValid() );
136
kError() << "Unable to start server org.kde.khotkeys (kded module)";
149
std::auto_ptr<QDBusInterface> kded( Kded() );
150
if (!kded->isValid())
155
QDBusReply<bool> reply = kded->call( "unloadModule", "khotkeys" );
156
QDBusError err = reply.error();
161
kError() << "Error when stopping khotkeys kded module [" << err.name() << "]:" << err.message();
165
Q_ASSERT( reply.isValid() );
173
kError() << "Failed to stop server org.kde.khotkeys (kded module)";
178
}} // namespace KHotKeys::Daemon