• Skip to content
  • Skip to link menu
KDE API Reference
  • KDE API Reference
  • kdeutils API Reference
  • KDE Home
  • Contact Us
 

kremotecontrol

  • sources
  • kde-4.12
  • kdeutils
  • kremotecontrol
  • libkremotecontrol
dbusinterface.cpp
Go to the documentation of this file.
1 /*************************************************************************
2  * Copyright (C) 2009 Michael Zanetti <michael_zanetti@gmx.net *
3  * *
4  * This program is free software; you can redistribute it and/or *
5  * modify it under the terms of the GNU General Public License as *
6  * published by the Free Software Foundation; either version 2 of *
7  * the License or (at your option) version 3 or any later version *
8  * accepted by the membership of KDE e.V. (or its successor approved *
9  * by the membership of KDE e.V.), which shall act as a proxy *
10  * defined in Section 14 of version 3 of the license. *
11  * *
12  * This program is distributed in the hope that it will be useful, *
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of *
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
15  * GNU General Public License for more details. *
16  * *
17  * You should have received a copy of the GNU General Public License *
18  * along with this program. If not, see <http://www.gnu.org/licenses/>. *
19  *************************************************************************/
20 /*
21  * dbusinterface.cpp
22  *
23  * Created on: 14.02.2009
24  * Author: Michael Zanetti
25  */
26 
27 
28 
29 #include "dbusinterface.h"
30 
31 #include <kdebug.h>
32 #include <kwindowsystem.h>
33 #include <knotification.h>
34 #include <klocale.h>
35 #include <kiconloader.h>
36 #include <ktoolinvocation.h>
37 
38 #include <QtCore/QStringList>
39 #include <QtDBus/QDBusConnectionInterface>
40 #include <QtDBus/QDBusInterface>
41 #include <QtDBus/qdbusconnection.h>
42 #include <QtXml/QDomDocument>
43 #include <QScriptEngine>
44 
45 static DBusInterface *theInstance = NULL;
46 
47 DBusInterface::DBusInterface() {
48 }
49 
50 DBusInterface *DBusInterface::getInstance() {
51  if (!theInstance) {
52  theInstance = new DBusInterface();
53  }
54  return theInstance;
55 }
56 
57 DBusInterface::~DBusInterface() {
58  //delete(DBusInterface::theInstance);
59  //DBusInterface::theInstance = 0;
60 }
61 
62 QStringList DBusInterface::allRegisteredPrograms() {
63  QDBusConnectionInterface *dBusIface = QDBusConnection::sessionBus().interface();
64  return dBusIface->registeredServiceNames();
65 }
66 
67 QStringList DBusInterface::registeredPrograms() {
68  QStringList returnList;
69 
70  QStringList allServices = allRegisteredPrograms();
71 
72  //Throw out invalid entries
73  for (int i = 0; i < allServices.size(); ++i) {
74  QString tmp = allServices.at(i);
75 
76  QRegExp r1( QLatin1String( "[a-zA-Z]{1,3}\\.[a-zA-Z0-9-]+\\.[a-zA-Z0-9_-\\.]+" ));
77  if (!r1.exactMatch(tmp)) {
78  continue;
79  }
80  if (nodes(tmp).isEmpty()) {
81  continue;
82  }
83  QRegExp r2( QLatin1String( "[a-zA-Z0-9_\\.-]+-[0-9]+" ));
84  if (r2.exactMatch(tmp)) {
85  tmp.truncate(tmp.lastIndexOf( QLatin1Char( '-' )));
86  }
87  if (!returnList.contains(tmp)) {
88  returnList << tmp;
89  }
90 
91  }
92 
93  return returnList;
94 }
95 
96 QStringList DBusInterface::nodes(const QString &program) {
97  return getNodes(program, QLatin1String("/"));
98  kDebug() << "getting Nodes of" << program;
99  QDBusInterface dBusIface(program, QLatin1String( "/" ), QLatin1String( "org.freedesktop.DBus.Introspectable" ));
100  QDBusMessage msg = QDBusMessage::createMethodCall(program, QLatin1String( "/" ), QLatin1String( "org.freedesktop.DBus.Introspectable" ), QLatin1String( "Introspect" ));
101  QDBusReply<QString> response = dBusIface.connection().call(msg, QDBus::Block, 1);
102 
103  QDomDocument domDoc;
104  domDoc.setContent(response);
105  if (domDoc.toString().isEmpty()) { // No reply... perhaps a multi-instance...
106  kDebug() << "no reply from" << program;
107  QStringList instances = allRegisteredPrograms().filter(program);
108  if (!instances.isEmpty()) {
109  QDBusInterface iFace(instances.first(), QLatin1String( "/" ), QLatin1String( "org.freedesktop.DBus.Introspectable" ));
110  QDBusMessage msg = QDBusMessage::createMethodCall(instances.first(), QLatin1String( "/" ), QLatin1String( "org.freedesktop.DBus.Introspectable" ), QLatin1String( "Introspect" ));
111  QDBusReply<QString> response = iFace.connection().call(msg, QDBus::Block, 1);
112 // response = iFace.call("Introspect");
113  domDoc.setContent(response);
114  }
115  }
116  kDebug() << "got Nodes of" << program;
117 
118  QDomElement node = domDoc.documentElement();
119 
120  QDomElement child = node.firstChildElement();
121  QStringList returnList;
122  while (!child.isNull()) {
123  if (child.tagName() == QLatin1String("node")) {
124  QString name = child.attribute(QLatin1String("name"));
125  if (name != QLatin1String( "org" ) && name != QLatin1String( "modules" ) && !functions(program, name).isEmpty()) {
126  returnList << name;
127  }
128  }
129  child = child.nextSiblingElement();
130  }
131  return returnList;
132 }
133 
134 QStringList DBusInterface::getNodes(const QString& service, const QString& node)
135 {
136  QStringList nodes;
137  QDBusMessage msg = QDBusMessage::createMethodCall(service, node, QLatin1String( "org.freedesktop.DBus.Introspectable" ), QLatin1String( "Introspect" ));
138  QDBusReply<QString> response = QDBusConnection::sessionBus().call(msg, QDBus::Block, 1);
139 
140  QDomDocument domDoc;
141  domDoc.setContent(response);
142  if (domDoc.toString().isEmpty()) { // No reply... perhaps a multi-instance...
143  kDebug() << "no reply from" << service;
144  QStringList instances = allRegisteredPrograms().filter(service);
145  if (!instances.isEmpty()) {
146  QDBusMessage msg = QDBusMessage::createMethodCall(instances.first(), node, QLatin1String( "org.freedesktop.DBus.Introspectable" ), QLatin1String( "Introspect" ));
147  QDBusReply<QString> response = QDBusConnection::sessionBus().call(msg, QDBus::Block, 1);
148 // response = iFace.call("Introspect");
149  domDoc.setContent(response);
150  }
151  }
152 
153  QDomElement child = domDoc.documentElement().firstChildElement();
154  while (!child.isNull()) {
155  if (child.tagName() == QLatin1String("node")) {
156  QString name = child.attribute(QLatin1String("name"));
157  kDebug() << "got node:" << service << node + name;
158  if (node.endsWith("/")) {
159  name = node + name;
160  } else {
161  name = node + QLatin1String("/") + name;
162  }
163  nodes << name;
164  nodes << getNodes(service, name);
165  }
166  child = child.nextSiblingElement();
167  }
168  return nodes;
169 }
170 
171 
172 QMultiMap<QString, Prototype> DBusInterface::functions(const QString &program, const QString &object) {
173  //return QList<Prototype>();
174  QDBusInterface dBusIface(program, object, QLatin1String( "org.freedesktop.DBus.Introspectable" ));
175  QDBusReply<QString> response = dBusIface.call(QLatin1String( "Introspect" ));
176 
177  QDomDocument domDoc;
178  domDoc.setContent(response);
179 
180  if (domDoc.toString().isEmpty()) { // No reply... perhaps a multi-instance...
181  QStringList instances = allRegisteredPrograms().filter(program);
182  if (!instances.isEmpty()) {
183  QDBusInterface iFace(instances.first(), QLatin1Char( '/' ) + object, QLatin1String( "org.freedesktop.DBus.Introspectable" ));
184  response = iFace.call(QLatin1String( "Introspect" ));
185  domDoc.setContent(response);
186  }
187  }
188 
189  QDomElement node = domDoc.documentElement();
190  QDomElement child = node.firstChildElement();
191 
192  QMultiMap<QString, Prototype> funcList;
193 
194  while (!child.isNull()) {
195  if (child.tagName() == QLatin1String("interface")) {
196  if (child.attribute(QLatin1String( "name" )) == QLatin1String( "org.freedesktop.DBus.Properties" ) ||
197  child.attribute(QLatin1String( "name" )) == QLatin1String( "org.freedesktop.DBus.Introspectable" )) {
198  child = child.nextSiblingElement();
199  continue;
200  }
201  QString interface = child.attribute(QLatin1String("name"));
202  QDomElement subChild = child.firstChildElement();
203  while (!subChild.isNull()) {
204  if (subChild.tagName() == QLatin1String("method")) {
205  QString functionName = subChild.attribute(QLatin1String("name"));
206  QDomElement argDom = subChild.firstChildElement();
207  QList<Argument> argList;
208  while (!argDom.isNull()) {
209  Argument argument;
210  if (argDom.tagName() == QLatin1String("arg")) {
211  QString tmpArg = argDom.attribute(QLatin1String("type"));
212  if (tmpArg == QLatin1String( "i" )) {
213  argument.setValue(QVariant::Int);
214  } else if (tmpArg == QLatin1String( "u" )) {
215  argument.setValue(QVariant::UInt);
216  } else if (tmpArg == QLatin1String( "x" )) {
217  argument.setValue(QVariant::LongLong);
218  } else if (tmpArg == QLatin1String( "s" )) {
219  argument.setValue(QVariant::String);
220  } else if (tmpArg == QLatin1String( "b" )) {
221  argument.setValue(QVariant::Bool);
222  } else if (tmpArg == QLatin1String( "d" )) {
223  argument.setValue(QVariant::Double);
224  } else if (tmpArg == QLatin1String( "as" )) {
225  argument.setValue(QVariant::StringList);
226  } else if (tmpArg == QLatin1String( "ay" )) {
227  argument.setValue(QVariant::ByteArray);
228  } else {
229  argDom = argDom.nextSiblingElement();
230  continue;
231  }
232 
233  if (argDom.attribute(QLatin1String("direction")) == QLatin1String( "in" )) {
234  if (!argDom.attribute(QLatin1String("name")).isEmpty()) {
235  argument.setDescription(argDom.attribute(QLatin1String("name")));
236  } else {
237  argument.setDescription(i18nc("The name of a parameter", "unknown"));
238  }
239  argList.append(argument);
240  }
241  }
242  argDom = argDom.nextSiblingElement();
243  }
244  Prototype function(functionName, argList);
245  if(!funcList.contains(interface, function)){
246  funcList.insertMulti(interface, function);
247  }
248  }
249  subChild = subChild.nextSiblingElement();
250  }
251  }
252  child = child.nextSiblingElement();
253  }
254  return funcList;
255 }
256 
257 QStringList DBusInterface::configuredRemotes() {
258  QStringList remotes;
259  QDBusMessage m = QDBusMessage::createMethodCall(QLatin1String( "org.kde.kded" ), QLatin1String( "/modules/kremotecontroldaemon" ),
260  QLatin1String( "org.kde.krcd" ), QLatin1String( "configuredRemotes" ));
261  QDBusMessage response = QDBusConnection::sessionBus().call(m);
262  if (response.type() == QDBusMessage::ErrorMessage) {
263  kDebug() << response.errorMessage();
264  } else {
265  remotes = response.arguments().at(0).toStringList();
266  }
267  return remotes;
268 }
269 
270 void DBusInterface::considerButtonEvents(const QString& remoteName) {
271  QDBusMessage m = QDBusMessage::createMethodCall(QLatin1String( "org.kde.kded" ), QLatin1String( "/modules/kremotecontroldaemon" ),
272  QLatin1String( "org.kde.krcd" ), QLatin1String( "considerButtonEvents" ));
273  m << remoteName;
274  QDBusMessage response = QDBusConnection::sessionBus().call(m);
275  if (response.type() == QDBusMessage::ErrorMessage) {
276  kDebug() << response.errorMessage();
277  }
278 }
279 
280 void DBusInterface::ignoreButtonEvents(const QString& remoteName) {
281  QDBusMessage m = QDBusMessage::createMethodCall(QLatin1String( "org.kde.kded" ), QLatin1String( "/modules/kremotecontroldaemon" ),
282  QLatin1String( "org.kde.krcd" ), QLatin1String( "ignoreButtonEvents" ));
283  m << remoteName;
284  QDBusMessage response = QDBusConnection::sessionBus().call(m);
285  if (response.type() == QDBusMessage::ErrorMessage) {
286  kDebug() << response.errorMessage();
287  }
288 }
289 
290 void DBusInterface::reloadRemoteControlDaemon() {
291  QDBusMessage m = QDBusMessage::createMethodCall(QLatin1String( "org.kde.kded" ), QLatin1String( "/modules/kremotecontroldaemon" ),
292  QLatin1String( "org.kde.krcd" ), QLatin1String( "reloadConfiguration" ));
293  QDBusMessage response = QDBusConnection::sessionBus().call(m);
294  if (response.type() == QDBusMessage::ErrorMessage) {
295  kDebug() << response.errorMessage();
296  }
297 
298 }
299 
300 bool DBusInterface::isProgramRunning(const QString &program) {
301  QDBusConnectionInterface *dBusIface = QDBusConnection::sessionBus().interface();
302  if (dBusIface->isServiceRegistered(program)) {
303  return true;
304  }
305  return false;
306 }
307 
308 bool DBusInterface::isUnique(const QString &program){
309  QStringList instances = allRegisteredPrograms().filter(program);
310  kDebug() << "instances of " << program << instances;
311 
312  // If there are more than 1 it is oviously not unique
313  // If there are 0 we cannot know... Return false so the user can at least try to specify what he likes.
314  if(instances.count() != 1){
315  return false;
316  }
317 
318  // So... we have exactly one instance...
319  // check if there are any trailing numbers. If yes, it is a multi-instance-app
320  QRegExp r2( QLatin1String( "[a-zA-Z0-9_\\.-]+-[0-9]+" ));
321  if(r2.exactMatch(instances.first())){
322  return false;
323  }
324 
325  return true;
326 }
327 
328 bool DBusInterface::searchForProgram(const DBusAction *action, QStringList &programs) {
329  QDBusConnectionInterface *dBusIface = QDBusConnection::sessionBus().interface();
330  programs.clear();
331 
332  if (action->destination() == DBusAction::Unique) {
333  QString service = action->application();
334 
335  kDebug() << "searching for prog:" << service;
336  if (dBusIface->isServiceRegistered(service)) {
337  kDebug() << "adding Program: " << service;
338  programs += service;
339  } else {
340  kDebug() << "nope... " << service << " not here.";
341  }
342  } else {
343 
344  // find all instances...
345  const QStringList buf = dBusIface->registeredServiceNames();
346 
347  for (QStringList::const_iterator i = buf.constBegin(); i != buf.constEnd(); ++i) {
348  QString program = *i;
349  if (program.contains(action->application()))
350  programs += program;
351  }
352 
353  if (programs.size() == 1) {
354  kDebug() << "Yeah! found it!";
355  } else if (programs.size() == 0) {
356  kDebug() << "Nope... not here...";
357  } else {
358  kDebug() << "found multiple instances...";
359  }
360 
361  if (programs.size() > 1 && action->destination() == DBusAction::None) {
362  kDebug() << "Multiple instances of" << action->application() << "found but destination is set to None";
363  return false;
364  } else if (programs.size() > 1 && action->destination() == DBusAction::Top) {
365  QList<WId> s = KWindowSystem::stackingOrder();
366  // go through all the (ordered) window pids
367  for (int i = 0; i < s.size(); i++) {
368  int p = KWindowSystem::windowInfo(s.at(i), NET::WMPid).win();
369  QString id = action->application() + QLatin1Char( '-' ) + QString().setNum(p);
370  if (programs.contains(id)) {
371  programs.clear();
372  programs += id;
373  break;
374  }
375  }
376  while (programs.size() > 1) programs.removeLast();
377  } else if (programs.size() > 1 && action->destination() == DBusAction::Bottom) {
378  QList<WId> s = KWindowSystem::stackingOrder();
379  // go through all the (ordered) window pids
380  for (int i = 0; i < s.size(); ++i) {
381  int p = KWindowSystem::windowInfo(s.at(i), NET::WMPid).win();
382  QString id = action->application() + QLatin1Char( '-' ) + QString().setNum(p);
383  if (programs.contains(id)) {
384  programs.clear();
385  programs += id;
386  break;
387  }
388  }
389  while (programs.size() > 1) programs.removeFirst();
390  }
391  }
392  kDebug() << "returning true";
393  return true;
394 }
395 
396 void DBusInterface::executeAction(const DBusAction* action) {
397  kDebug() << "executeAction called";
398  QDBusConnectionInterface *dBusIface = QDBusConnection::sessionBus().interface();
399 
400  QStringList programs;
401 
402  if (!searchForProgram(action, programs)) {
403  return;
404  }
405 
406  // if programs.size()==0 here, then the app is definately not running.
407  kDebug() << "Autostart: " << action->autostart();
408  kDebug() << "programs.size: " << programs.size();
409  if (action->autostart() && !programs.size()) {
410  kDebug() << "Should start " << action->application();
411  QString runCommand = action->application();
412  runCommand.remove(QRegExp( QLatin1String( "org.[a-zA-Z0-9]*." )));
413  kDebug() << "runCommand" << runCommand;
414  KToolInvocation::startServiceByDesktopName(runCommand);
415  }
416  if (action->function().name().isEmpty()) // Just start
417  return;
418 
419  if (!searchForProgram(action, programs)) {
420  kDebug() << "Failed to start the application" << action->application();
421  return;
422  }
423 
424  for (QStringList::iterator i = programs.begin(); i != programs.end(); ++i) {
425  const QString &program = *i;
426  kDebug() << "Searching DBus for program:" << program;
427  if (dBusIface->isServiceRegistered(program)) {
428  kDebug() << "Sending data (" << program << ", " << action->node() << ", " << action->interface() << ". " << action->function().name();
429 
430  if(action->function().name().startsWith("script:")) {
431  QString scriptText = action->function().name().remove(0, 7);
432 
433  QScriptEngine scriptEngine;
434  QDBusIfaceWrapper *appIface = new QDBusIfaceWrapper(program, action->node());
435  QScriptValue objectValue = scriptEngine.newQObject(appIface);
436  scriptEngine.globalObject().setProperty("dbus", objectValue);
437  int argCount = 1;
438  foreach(const Argument &arg, action->function().args()) {
439  QScriptValue argValue;
440  switch(arg.value().type()) {
441  case QVariant::Int:
442  case QVariant::LongLong:
443  argValue = QScriptValue(arg.value().toInt());
444  break;
445  case QVariant::UInt:
446  argValue = QScriptValue(arg.value().toUInt());
447  break;
448  case QVariant::Double:
449  argValue = QScriptValue(arg.value().toDouble());
450  break;
451  case QVariant::Bool:
452  argValue = QScriptValue(arg.value().toBool());
453  break;
454  case QVariant::StringList:
455  argValue = QScriptValue(arg.value().toStringList().join(","));
456  break;
457  case QVariant::ByteArray:
458  case QVariant::String:
459  argValue = QScriptValue(arg.value().toString());
460  default:
461  argValue = QScriptValue(arg.value().toInt());
462  }
463 
464  scriptEngine.globalObject().setProperty("arg" + QString::number(argCount++), argValue);
465  }
466  qDebug() << "its a script:" << scriptText;
467  scriptEngine.evaluate(scriptText);
468  } else {
469 
470  QDBusMessage m = QDBusMessage::createMethodCall(program, action->node(), action->interface(), action->function().name());
471 
472  foreach(const Argument &arg, action->function().args()){
473  kDebug() << "Got argument:" << arg.value().type() << "value" << arg.value();
474  m << arg.value();
475  }
476  QDBusMessage response = QDBusConnection::sessionBus().call(m);
477  if (response.type() == QDBusMessage::ErrorMessage) {
478  kDebug() << response.errorMessage();
479  }
480  }
481  }
482  }
483 }
484 
485 void DBusInterface::changeMode(const QString& remoteName, const QString& modeName) {
486  QDBusMessage m = QDBusMessage::createMethodCall(QLatin1String( "org.kde.kded" ), QLatin1String( "/modules/kremotecontroldaemon" ),
487  QLatin1String( "org.kde.krcd" ), QLatin1String( "changeMode" ));
488  m << remoteName;
489  m << modeName;
490  QDBusReply<bool> reply = QDBusConnection::sessionBus().call(m);
491  if(!reply.isValid()){
492  kDebug() << "Couldn't change to mode " << modeName << " on remote " << remoteName;
493  }
494 }
495 
496 QString DBusInterface::currentMode(const QString& remoteName) {
497  QDBusMessage m = QDBusMessage::createMethodCall(QLatin1String( "org.kde.kded" ), QLatin1String( "/modules/kremotecontroldaemon" ),
498  QLatin1String( "org.kde.krcd" ), QLatin1String( "currentMode" ));
499  m << remoteName;
500  QDBusReply<QString> reply = QDBusConnection::sessionBus().call(m);
501  if (reply.isValid()) {
502  return reply;
503  } else {
504  kDebug() << reply.error().message();
505  return QString();
506  }
507 }
508 
509 QStringList DBusInterface::modesForRemote(const QString& remoteName) {
510  QDBusMessage m = QDBusMessage::createMethodCall(QLatin1String( "org.kde.kded" ), QLatin1String( "/modules/kremotecontroldaemon" ),
511  QLatin1String( "org.kde.krcd" ), QLatin1String( "modesForRemote" ));
512  m << remoteName;
513  QDBusReply<QStringList> reply = QDBusConnection::sessionBus().call(m);
514  if (reply.isValid()) {
515  return reply;
516  } else {
517  kDebug() << reply.error().message();
518  return QStringList();
519  }
520 }
521 
522 QString DBusInterface::modeIcon(const QString& remoteName, const QString& modeName) {
523  QDBusMessage m = QDBusMessage::createMethodCall(QLatin1String( "org.kde.kded" ), QLatin1String( "/modules/kremotecontroldaemon" ),
524  QLatin1String( "org.kde.krcd" ), QLatin1String( "modeIcon" ));
525  m << remoteName;
526  m << modeName;
527  QDBusReply<QString> reply = QDBusConnection::sessionBus().call(m);
528  if (reply.isValid()) {
529  return reply;
530  } else {
531  kDebug() << reply.error().message();
532  return QLatin1String( "" );
533  }
534 
535 }
536 
537 bool DBusInterface::eventsIgnored(const QString& remoteName) {
538  QDBusMessage m = QDBusMessage::createMethodCall(QLatin1String( "org.kde.kded" ), QLatin1String( "/modules/kremotecontroldaemon" ),
539  QLatin1String( "org.kde.krcd" ), QLatin1String( "eventsIgnored" ));
540  m << remoteName;
541  QDBusReply<bool> reply = QDBusConnection::sessionBus().call(m);
542  if (reply.isValid()) {
543  return reply;
544  } else {
545  kDebug() << reply.error().message();
546  return false;
547  }
548 }
549 
550 bool DBusInterface::isKdedModuleRunning() {
551  QDBusMessage m = QDBusMessage::createMethodCall(QLatin1String( "org.kde.kded" ), QLatin1String( "/kded" ), QLatin1String( "org.kde.kded" ), QLatin1String( "loadedModules" ));
552  QDBusReply<QStringList> reply = QDBusConnection::sessionBus().call(m);
553  if(reply.isValid()){
554  return reply.value().contains(QLatin1String( "kremotecontroldaemon" ));
555  }
556  kDebug() << reply.error().message();
557  return false;
558 }
559 
560 bool DBusInterface::loadKdedModule() {
561  QDBusMessage m = QDBusMessage::createMethodCall(QLatin1String( "org.kde.kded" ), QLatin1String( "/kded" ), QLatin1String( "org.kde.kded" ), QLatin1String( "loadModule" ));
562  m << QLatin1String( "kremotecontroldaemon" );
563  QDBusReply<bool> reply = QDBusConnection::sessionBus().call(m);
564  if(!reply.isValid() || !reply.value()){
565  return false;
566  }
567 
568  m = QDBusMessage::createMethodCall(QLatin1String( "org.kde.kded" ), QLatin1String( "/kded" ), QLatin1String( "org.kde.kded" ), QLatin1String( "setModuleAutoloading" ));
569  m << QLatin1String( "kremotecontroldaemon" ) << true;
570  QDBusConnection::sessionBus().call(m);
571  return true;
572 }
573 
574 bool DBusInterface::unloadKdedModule() {
575  QDBusMessage m = QDBusMessage::createMethodCall(QLatin1String( "org.kde.kded" ), QLatin1String( "/kded" ), QLatin1String( "org.kde.kded" ), QLatin1String( "unloadModule" ));
576  m << QLatin1String( "kremotecontroldaemon" );
577  QDBusReply<bool> reply = QDBusConnection::sessionBus().call(m);
578  if(!reply.isValid() || !reply.value()){
579  return false;
580  }
581 
582  m = QDBusMessage::createMethodCall(QLatin1String( "org.kde.kded" ), QLatin1String( "/kded" ), QLatin1String( "org.kde.kded" ), QLatin1String( "setModuleAutoloading" ));
583  m << QLatin1String( "kremotecontroldaemon" ) << false;
584  QDBusConnection::sessionBus().call(m);
585  return true;
586 }
587 
588 QDBusIfaceWrapper::QDBusIfaceWrapper(const QString &program, const QString &path):
589  m_program(program),
590  m_path(path)
591 {
592 
593 }
594 
595 int QDBusIfaceWrapper::call(const QString& method)
596 {
597  QDBusInterface iface(m_program, m_path);
598  qDebug() << "calling" << method;
599  QDBusReply<int> ret = iface.call(method);
600  qDebug() << "return value is" << ret.value();
601  return ret;
602 }
603 
604 int QDBusIfaceWrapper::call(const QString& method, int value)
605 {
606  QDBusInterface iface(m_program, m_path);
607  qDebug() << "calling" << method << "with arg" << value;
608  QDBusReply<int> ret = iface.call(method, value);
609  qDebug() << "return value is" << ret.value();
610  return ret;
611 }
612 
613 int QDBusIfaceWrapper::call(const QString& method, const QString &value)
614 {
615  QDBusInterface iface(m_program, m_path);
616  qDebug() << "calling" << method << "with arg" << value;
617  QDBusReply<int> ret = iface.call(method, value);
618  qDebug() << "return value is" << ret.value();
619  return ret;
620 }
Argument
Definition: argument.h:27
Action::Bottom
Definition: action.h:34
QDBusIfaceWrapper
Definition: dbusinterface.h:85
QDBusIfaceWrapper::call
int call(const QString &method)
Definition: dbusinterface.cpp:595
Action::destination
ActionDestination destination() const
Definition: action.cpp:61
Prototype::name
QString name() const
Definition: prototype.cpp:28
dbusinterface.h
DBusAction::node
QString node() const
Definition: dbusaction.cpp:37
DBusAction::function
Prototype function() const
Definition: dbusaction.cpp:55
Action::autostart
bool autostart() const
Definition: action.cpp:53
Argument::setValue
void setValue(const QVariant &value)
Definition: argument.cpp:36
DBusInterface::considerButtonEvents
void considerButtonEvents(const QString &remoteName)
Definition: dbusinterface.cpp:270
DBusInterface::getInstance
static DBusInterface * getInstance()
Definition: dbusinterface.cpp:50
DBusInterface
Definition: dbusinterface.h:36
DBusInterface::loadKdedModule
bool loadKdedModule()
Loads the kremotecontrol kded module and sets autoLoading to true.
Definition: dbusinterface.cpp:560
Argument::setDescription
void setDescription(const QString &description)
Definition: argument.cpp:44
QDBusIfaceWrapper::QDBusIfaceWrapper
QDBusIfaceWrapper(const QString &program, const QString &path)
Definition: dbusinterface.cpp:588
DBusInterface::reloadRemoteControlDaemon
void reloadRemoteControlDaemon()
Definition: dbusinterface.cpp:290
DBusInterface::~DBusInterface
~DBusInterface()
Definition: dbusinterface.cpp:57
DBusInterface::modesForRemote
QStringList modesForRemote(const QString &remoteName)
Definition: dbusinterface.cpp:509
DBusInterface::modeIcon
QString modeIcon(const QString &remoteName, const QString &modeName)
Definition: dbusinterface.cpp:522
DBusAction
Definition: dbusaction.h:32
Action::Unique
Definition: action.h:34
Prototype
Definition: prototype.h:28
DBusInterface::functions
QMultiMap< QString, Prototype > functions(const QString &program, const QString &object)
Definition: dbusinterface.cpp:172
DBusInterface::isKdedModuleRunning
bool isKdedModuleRunning()
Definition: dbusinterface.cpp:550
DBusInterface::changeMode
void changeMode(const QString &remoteName, const QString &modeName)
Definition: dbusinterface.cpp:485
Action::Top
Definition: action.h:34
DBusInterface::nodes
QStringList nodes(const QString &program)
Definition: dbusinterface.cpp:96
DBusInterface::isUnique
bool isUnique(const QString &program)
Definition: dbusinterface.cpp:308
DBusInterface::registeredPrograms
QStringList registeredPrograms()
Definition: dbusinterface.cpp:67
DBusAction::interface
QString interface() const
Definition: dbusaction.cpp:45
DBusInterface::currentMode
QString currentMode(const QString &remoteName)
Definition: dbusinterface.cpp:496
Prototype::args
QList< Argument > args() const
Definition: prototype.cpp:32
DBusInterface::eventsIgnored
bool eventsIgnored(const QString &remoteName)
Definition: dbusinterface.cpp:537
DBusInterface::isProgramRunning
bool isProgramRunning(const QString &program)
Definition: dbusinterface.cpp:300
Action::None
Definition: action.h:34
DBusInterface::unloadKdedModule
bool unloadKdedModule()
Unloads the kremotecontrol kded module and sets autoLoading to false.
Definition: dbusinterface.cpp:574
DBusAction::application
QString application() const
Definition: dbusaction.cpp:29
DBusInterface::configuredRemotes
QStringList configuredRemotes()
Definition: dbusinterface.cpp:257
DBusInterface::ignoreButtonEvents
void ignoreButtonEvents(const QString &remoteName)
Definition: dbusinterface.cpp:280
Argument::value
QVariant value() const
Definition: argument.cpp:32
theInstance
static DBusInterface * theInstance
Definition: dbusinterface.cpp:45
DBusInterface::executeAction
void executeAction(const DBusAction *action)
Definition: dbusinterface.cpp:396
This file is part of the KDE documentation.
Documentation copyright © 1996-2014 The KDE developers.
Generated on Tue Oct 14 2014 23:07:43 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

kremotecontrol

Skip menu "kremotecontrol"
  • Main Page
  • Namespace List
  • Namespace Members
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • File Members

kdeutils API Reference

Skip menu "kdeutils API Reference"
  • ark
  • filelight
  • kcalc
  • kcharselect
  • kdf
  • kfloppy
  • kgpg
  • kremotecontrol
  • ktimer
  • kwallet
  • superkaramba
  • sweeper

Search



Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal