Qt 4.8
dbusdispatcher.cpp
Go to the documentation of this file.
1 /****************************************************************************
2 **
3 ** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
4 ** Contact: http://www.qt-project.org/legal
5 **
6 ** This file is part of the plugins of the Qt Toolkit.
7 **
8 ** $QT_BEGIN_LICENSE:LGPL$
9 ** Commercial License Usage
10 ** Licensees holding valid commercial Qt licenses may use this file in
11 ** accordance with the commercial license agreement provided with the
12 ** Software or, alternatively, in accordance with the terms contained in
13 ** a written agreement between you and Digia. For licensing terms and
14 ** conditions see http://qt.digia.com/licensing. For further information
15 ** use the contact form at http://qt.digia.com/contact-us.
16 **
17 ** GNU Lesser General Public License Usage
18 ** Alternatively, this file may be used under the terms of the GNU Lesser
19 ** General Public License version 2.1 as published by the Free Software
20 ** Foundation and appearing in the file LICENSE.LGPL included in the
21 ** packaging of this file. Please review the following information to
22 ** ensure the GNU Lesser General Public License version 2.1 requirements
23 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
24 **
25 ** In addition, as a special exception, Digia gives you certain additional
26 ** rights. These rights are described in the Digia Qt LGPL Exception
27 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
28 **
29 ** GNU General Public License Usage
30 ** Alternatively, this file may be used under the terms of the GNU
31 ** General Public License version 3.0 as published by the Free Software
32 ** Foundation and appearing in the file LICENSE.GPL included in the
33 ** packaging of this file. Please review the following information to
34 ** ensure the GNU General Public License version 3.0 requirements will be
35 ** met: http://www.gnu.org/copyleft/gpl.html.
36 **
37 **
38 ** $QT_END_LICENSE$
39 **
40 ****************************************************************************/
41 
42 
43 #include <QDebug>
44 #include <QtCore>
45 #include <poll.h>
46 #include <dbus/dbus.h>
47 #include <dbus/dbus-glib-lowlevel.h>
48 #include <glib.h>
49 #include "dbusdispatcher.h"
50 
51 namespace Maemo {
52 
64 {
65 public:
67  const QString& path,
68  const QString& interface,
69  const QString& signalPath)
70  : service(service), path(path), interface(interface),
71  signalPath(signalPath), connection(0)
72  {
73  memset(&signal_vtable, 0, sizeof(signal_vtable));
74  }
75 
77  {
78  foreach(DBusPendingCall *call, pending_calls) {
81  }
82  }
83 
88  struct DBusConnection *connection;
90  struct DBusObjectPathVTable signal_vtable;
91 };
92 
93 static bool constantVariantList(const QVariantList& variantList) {
94  // Special case, empty list == empty struct
95  if (variantList.isEmpty()) {
96  return false;
97  } else {
98  QVariant::Type type = variantList[0].type();
99  // Iterate items in the list and check if they are same type
100  foreach(QVariant variant, variantList) {
101  if (variant.type() != type) {
102  return false;
103  }
104  }
105  }
106  return true;
107 }
108 
109 static QString variantToSignature(const QVariant& argument,
110  bool constantList = true) {
111  switch (argument.type()) {
112  case QVariant::Bool:
113  return "b";
114  case QVariant::ByteArray:
115  return "ay";
116  case QVariant::Char:
117  return "y";
118  case QVariant::Int:
119  return "i";
120  case QVariant::UInt:
121  return "u";
123  return "as";
124  case QVariant::String:
125  return "s";
126  case QVariant::LongLong:
127  return "x";
128  case QVariant::ULongLong:
129  return "t";
130  case QVariant::List:
131  {
132  QString signature;
133  QVariantList variantList = argument.toList();
134  if (!constantList) {
135  signature += DBUS_STRUCT_BEGIN_CHAR_AS_STRING;
136  foreach(QVariant listItem, variantList) {
137  signature += variantToSignature(listItem);
138  }
139  signature += DBUS_STRUCT_END_CHAR_AS_STRING;
140  } else {
141  if (variantList.isEmpty())
142  return "";
143  signature = "a" + variantToSignature(variantList[0]);
144  }
145 
146  return signature;
147  }
148  default:
149  qDebug() << "Unsupported variant type: " << argument.type();
150  break;
151  }
152 
153  return "";
154 }
155 
156 static bool appendVariantToDBusMessage(const QVariant& argument,
157  DBusMessageIter *dbus_iter) {
158  int idx = 0;
159  DBusMessageIter array_iter;
160  QStringList str_list;
161  dbus_bool_t bool_data;
162  dbus_int32_t int32_data;
163  dbus_uint32_t uint32_data;
164  dbus_int64_t int64_data;
165  dbus_uint64_t uint64_data;
166  char *str_data;
167  char char_data;
168 
169  switch (argument.type()) {
170 
171  case QVariant::Bool:
172  bool_data = argument.toBool();
173  dbus_message_iter_append_basic(dbus_iter, DBUS_TYPE_BOOLEAN,
174  &bool_data);
175  break;
176 
177  case QVariant::ByteArray:
178  str_data = argument.toByteArray().data();
179  dbus_message_iter_open_container(dbus_iter, DBUS_TYPE_ARRAY,
180  DBUS_TYPE_BYTE_AS_STRING, &array_iter);
182  DBUS_TYPE_BYTE,
183  &str_data,
184  argument.toByteArray().size());
185  dbus_message_iter_close_container(dbus_iter, &array_iter);
186  break;
187 
188  case QVariant::Char:
189  char_data = argument.toChar().toAscii();
190  dbus_message_iter_append_basic(dbus_iter, DBUS_TYPE_BYTE,
191  &char_data);
192  break;
193 
194  case QVariant::Int:
195  int32_data = argument.toInt();
196  dbus_message_iter_append_basic(dbus_iter, DBUS_TYPE_INT32,
197  &int32_data);
198  break;
199 
200  case QVariant::String: {
201  QByteArray data = argument.toString().toUtf8();
202  str_data = data.data();
203  dbus_message_iter_append_basic(dbus_iter, DBUS_TYPE_STRING,
204  &str_data);
205  break;
206  }
207 
209  str_list = argument.toStringList();
210  dbus_message_iter_open_container(dbus_iter, DBUS_TYPE_ARRAY,
211  "s", &array_iter);
212  for (idx = 0; idx < str_list.size(); idx++) {
213  QByteArray data = str_list.at(idx).toLatin1();
214  str_data = data.data();
215  dbus_message_iter_append_basic(&array_iter,
216  DBUS_TYPE_STRING,
217  &str_data);
218  }
219  dbus_message_iter_close_container(dbus_iter, &array_iter);
220  break;
221 
222  case QVariant::UInt:
223  uint32_data = argument.toUInt();
224  dbus_message_iter_append_basic(dbus_iter, DBUS_TYPE_UINT32,
225  &uint32_data);
226  break;
227 
228  case QVariant::ULongLong:
229  uint64_data = argument.toULongLong();
230  dbus_message_iter_append_basic(dbus_iter, DBUS_TYPE_UINT64,
231  &uint64_data);
232  break;
233 
234  case QVariant::LongLong:
235  int64_data = argument.toLongLong();
236  dbus_message_iter_append_basic(dbus_iter, DBUS_TYPE_INT64,
237  &int64_data);
238  break;
239 
240  case QVariant::List:
241  {
242  QVariantList variantList = argument.toList();
243  bool constantList = constantVariantList(variantList);
244  DBusMessageIter array_iter;
245 
246  // List is mapped either as an DBUS array (all items same type)
247  // DBUS struct (variable types) depending on constantList
248  if (constantList) {
249  // Resolve the signature for the first item
250  QString signature = "";
251  if (!variantList.isEmpty()) {
252  signature = variantToSignature(
253  variantList[0],
254  constantVariantList(variantList[0].toList()));
255  }
256 
257  // Mapped as DBUS array
258  dbus_message_iter_open_container(dbus_iter, DBUS_TYPE_ARRAY,
259  signature.toAscii(),
260  &array_iter);
261 
262  foreach(QVariant listItem, variantList) {
263  appendVariantToDBusMessage(listItem, &array_iter);
264  }
265 
266  dbus_message_iter_close_container(dbus_iter, &array_iter);
267  } else {
268  // Mapped as DBUS struct
269  dbus_message_iter_open_container(dbus_iter, DBUS_TYPE_STRUCT,
270  NULL,
271  &array_iter);
272 
273  foreach(QVariant listItem, variantList) {
274  appendVariantToDBusMessage(listItem, &array_iter);
275  }
276 
277  dbus_message_iter_close_container(dbus_iter, &array_iter);
278  }
279 
280  break;
281  }
282  default:
283  qDebug() << "Unsupported variant type: " << argument.type();
284  break;
285  }
286 
287  return true;
288 }
289 
290 static QVariant getVariantFromDBusMessage(DBusMessageIter *iter) {
291  dbus_bool_t bool_data;
292  dbus_int32_t int32_data;
293  dbus_uint32_t uint32_data;
294  dbus_int64_t int64_data;
295  dbus_uint64_t uint64_data;
296  char *str_data;
297  char char_data;
298  int argtype = dbus_message_iter_get_arg_type(iter);
299 
300  switch (argtype) {
301 
302  case DBUS_TYPE_BOOLEAN:
303  {
304  dbus_message_iter_get_basic(iter, &bool_data);
305  QVariant variant((bool)bool_data);
306  return variant;
307  }
308 
309  case DBUS_TYPE_ARRAY:
310  {
311  // Handle all arrays here
312  int elem_type = dbus_message_iter_get_element_type(iter);
313  DBusMessageIter array_iter;
314 
315  dbus_message_iter_recurse(iter, &array_iter);
316 
317  if (elem_type == DBUS_TYPE_BYTE) {
318  QByteArray byte_array;
319  do {
320  dbus_message_iter_get_basic(&array_iter, &char_data);
321  byte_array.append(char_data);
322  } while (dbus_message_iter_next(&array_iter));
323  QVariant variant(byte_array);
324  return variant;
325  } else if (elem_type == DBUS_TYPE_STRING) {
326  QStringList str_list;
327  do {
328  dbus_message_iter_get_basic(&array_iter, &str_data);
329  str_list.append(str_data);
330  } while (dbus_message_iter_next(&array_iter));
331  QVariant variant(str_list);
332  return variant;
333  } else {
334  QVariantList variantList;
335  do {
336  variantList << getVariantFromDBusMessage(&array_iter);
337  } while (dbus_message_iter_next(&array_iter));
338  QVariant variant(variantList);
339  return variant;
340  }
341  break;
342  }
343 
344  case DBUS_TYPE_BYTE:
345  {
346  dbus_message_iter_get_basic(iter, &char_data);
347  QChar ch(char_data);
348  QVariant variant(ch);
349  return variant;
350  }
351 
352  case DBUS_TYPE_INT32:
353  {
354  dbus_message_iter_get_basic(iter, &int32_data);
355  QVariant variant((int)int32_data);
356  return variant;
357  }
358 
359  case DBUS_TYPE_UINT32:
360  {
361  dbus_message_iter_get_basic(iter, &uint32_data);
362  QVariant variant((uint)uint32_data);
363  return variant;
364  }
365 
366  case DBUS_TYPE_STRING:
367  {
368  dbus_message_iter_get_basic(iter, &str_data);
369  QString str(QString::fromUtf8(str_data));
370  QVariant variant(str);
371  return variant;
372  }
373 
374  case DBUS_TYPE_INT64:
375  {
376  dbus_message_iter_get_basic(iter, &int64_data);
377  QVariant variant((qlonglong)int64_data);
378  return variant;
379  }
380 
381  case DBUS_TYPE_UINT64:
382  {
383  dbus_message_iter_get_basic(iter, &uint64_data);
384  QVariant variant((qulonglong)uint64_data);
385  return variant;
386  }
387 
388  case DBUS_TYPE_STRUCT:
389  {
390  // Handle all structs here
391  DBusMessageIter struct_iter;
392  dbus_message_iter_recurse(iter, &struct_iter);
393 
394  QVariantList variantList;
395  do {
396  variantList << getVariantFromDBusMessage(&struct_iter);
397  } while (dbus_message_iter_next(&struct_iter));
398  QVariant variant(variantList);
399  return variant;
400  }
401 
402  default:
403  qDebug() << "Unsupported DBUS type: " << argtype;
404  }
405 
406  return QVariant();
407 }
408 
409 static DBusHandlerResult signalHandler (DBusConnection *connection,
410  DBusMessage *message,
411  void *object_ref) {
412  (void)connection;
414  QString signal;
415  DBusDispatcher *dispatcher = (DBusDispatcher *)object_ref;
416 
417  if (dbus_message_get_type(message) == DBUS_MESSAGE_TYPE_SIGNAL) {
418  interface = dbus_message_get_interface(message);
419  signal = dbus_message_get_member(message);
420 
421  QList<QVariant> arglist;
422  DBusMessageIter dbus_iter;
423 
424  if (dbus_message_iter_init(message, &dbus_iter)) {
425  // Read return arguments
426  while (dbus_message_iter_get_arg_type (&dbus_iter) != DBUS_TYPE_INVALID) {
427  arglist << getVariantFromDBusMessage(&dbus_iter);
428  dbus_message_iter_next(&dbus_iter);
429  }
430  }
431 
432  dispatcher->emitSignalReceived(interface, signal, arglist);
433  return DBUS_HANDLER_RESULT_HANDLED;
434  }
435  (void)message;
436  return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
437 }
438 
440  const QString& path,
441  const QString& interface,
442  QObject *parent)
443  : QObject(parent),
444  d_ptr(new DBusDispatcherPrivate(service, path, interface, path)) {
445  setupDBus();
446 }
447 
449  const QString& path,
450  const QString& interface,
451  const QString& signalPath,
452  QObject *parent)
453  : QObject(parent),
454  d_ptr(new DBusDispatcherPrivate(service, path, interface, signalPath)) {
455  setupDBus();
456 }
457 
459 {
460  if (d_ptr->connection) {
463  }
464  delete d_ptr;
465 }
466 
468 {
469  d_ptr->connection = dbus_bus_get_private(DBUS_BUS_SYSTEM, NULL);
470 
471  if (d_ptr->connection == NULL)
472  qDebug() << "Unable to get DBUS connection!";
473  else {
474  d_ptr->signal_vtable.message_function = signalHandler;
475 
477  dbus_connection_setup_with_g_main(d_ptr->connection, g_main_context_get_thread_default());
478  dbus_connection_register_object_path(d_ptr->connection,
481  this);
482  }
483 }
484 
485 static DBusMessage *prepareDBusCall(const QString& service,
486  const QString& path,
487  const QString& interface,
488  const QString& method,
489  const QVariant& arg1 = QVariant(),
490  const QVariant& arg2 = QVariant(),
491  const QVariant& arg3 = QVariant(),
492  const QVariant& arg4 = QVariant(),
493  const QVariant& arg5 = QVariant(),
494  const QVariant& arg6 = QVariant(),
495  const QVariant& arg7 = QVariant(),
496  const QVariant& arg8 = QVariant())
497 {
498  DBusMessage *message = dbus_message_new_method_call(service.toLatin1(),
499  path.toLatin1(),
500  interface.toLatin1(),
501  method.toLatin1());
502  DBusMessageIter dbus_iter;
503 
504  // Append variants to DBUS message
505  QList<QVariant> arglist;
506  if (arg1.isValid()) arglist << arg1;
507  if (arg2.isValid()) arglist << arg2;
508  if (arg3.isValid()) arglist << arg3;
509  if (arg4.isValid()) arglist << arg4;
510  if (arg5.isValid()) arglist << arg5;
511  if (arg6.isValid()) arglist << arg6;
512  if (arg7.isValid()) arglist << arg7;
513  if (arg8.isValid()) arglist << arg8;
514 
515  dbus_message_iter_init_append (message, &dbus_iter);
516 
517  while (!arglist.isEmpty()) {
518  QVariant argument = arglist.takeFirst();
519  appendVariantToDBusMessage(argument, &dbus_iter);
520  }
521 
522  return message;
523 }
524 
526  const QVariant& arg1,
527  const QVariant& arg2,
528  const QVariant& arg3,
529  const QVariant& arg4,
530  const QVariant& arg5,
531  const QVariant& arg6,
532  const QVariant& arg7,
533  const QVariant& arg8) {
534  DBusMessageIter dbus_iter;
535  DBusMessage *message = prepareDBusCall(d_ptr->service, d_ptr->path,
536  d_ptr->interface, method,
537  arg1, arg2, arg3, arg4, arg5,
538  arg6, arg7, arg8);
539  DBusMessage *reply = dbus_connection_send_with_reply_and_block(
540  d_ptr->connection,
541  message, -1, NULL);
542  dbus_message_unref(message);
543 
544  QList<QVariant> replylist;
545  if (reply != NULL && dbus_message_iter_init(reply, &dbus_iter)) {
546  // Read return arguments
547  while (dbus_message_iter_get_arg_type (&dbus_iter) != DBUS_TYPE_INVALID) {
548  replylist << getVariantFromDBusMessage(&dbus_iter);
549  dbus_message_iter_next(&dbus_iter);
550  }
551  }
552  if (reply != NULL) dbus_message_unref(reply);
553  return replylist;
554 }
555 
557 public:
561 };
562 
563 static void freePendingCallInfo(void *memory) {
564  PendingCallInfo *info = (PendingCallInfo *)memory;
565  delete info;
566 }
567 
568 static void pendingCallFunction (DBusPendingCall *pending,
569  void *memory) {
570  PendingCallInfo *info = (PendingCallInfo *)memory;
571  QString errorStr;
572  QList<QVariant> replyList;
573  DBusMessage *reply = dbus_pending_call_steal_reply (pending);
574 
575  Q_ASSERT(reply != NULL);
576 
577  if (dbus_message_get_type(reply) == DBUS_MESSAGE_TYPE_ERROR) {
578  errorStr = dbus_message_get_error_name (reply);
579  } else {
580  DBusMessageIter dbus_iter;
581  dbus_message_iter_init(reply, &dbus_iter);
582  // Read return arguments
583  while (dbus_message_iter_get_arg_type (&dbus_iter) != DBUS_TYPE_INVALID) {
584  replyList << getVariantFromDBusMessage(&dbus_iter);
585  dbus_message_iter_next(&dbus_iter);
586  }
587  }
588 
589  info->priv->pending_calls.removeOne(pending);
590  info->dispatcher->emitCallReply(info->method, replyList, errorStr);
591  dbus_message_unref(reply);
592  dbus_pending_call_unref(pending);
593 }
594 
596  const QVariant& arg1,
597  const QVariant& arg2,
598  const QVariant& arg3,
599  const QVariant& arg4,
600  const QVariant& arg5,
601  const QVariant& arg6,
602  const QVariant& arg7,
603  const QVariant& arg8) {
604  DBusMessage *message = prepareDBusCall(d_ptr->service, d_ptr->path,
605  d_ptr->interface, method,
606  arg1, arg2, arg3, arg4, arg5,
607  arg6, arg7, arg8);
608  DBusPendingCall *call = NULL;
610  message, &call, -1);
612  info->method = method;
613  info->dispatcher = this;
614  info->priv = d_ptr;
615 
617  d_ptr->pending_calls.append(call);
618  return (bool)ret;
619 }
620 
622  const QString& signal,
623  const QList<QVariant>& args) {
624  emit signalReceived(interface, signal, args); }
625 
627  const QList<QVariant>& args,
628  const QString& error) {
629  emit callReply(method, args, error); }
630 
632 {
633  dbus_connection_read_write_dispatch(d_ptr->connection, timeout_ms);
634 }
635 
636 } // Maemo namespace
637 
The QVariant class acts like a union for the most common Qt data types.
Definition: qvariant.h:92
DBusDispatcher is a class that can send DBUS method call messages and receive unicast signals from DB...
DBusDispatcherPrivate * d_ptr
int type
Definition: qmetatype.cpp:239
bool callAsynchronous(const QString &method, const QVariant &arg1=QVariant(), const QVariant &arg2=QVariant(), const QVariant &arg3=QVariant(), const QVariant &arg4=QVariant(), const QVariant &arg5=QVariant(), const QVariant &arg6=QVariant(), const QVariant &arg7=QVariant(), const QVariant &arg8=QVariant())
static mach_timebase_info_data_t info
dbus_bool_t dbus_pending_call_set_notify(DBusPendingCall *pending, DBusPendingCallNotifyFunction function, void *user_data, DBusFreeFunction free_user_data)
char * data()
Returns a pointer to the data stored in the byte array.
Definition: qbytearray.h:429
dbus_bool_t dbus_message_iter_close_container(DBusMessageIter *iter, DBusMessageIter *sub)
DBusDispatcher * dispatcher
void dbus_connection_set_exit_on_disconnect(DBusConnection *connection, dbus_bool_t exit_on_disconnect)
void dbus_message_unref(DBusMessage *message)
QByteArray & append(char c)
Appends the character ch to this byte array.
QByteArray toUtf8() const Q_REQUIRED_RESULT
Returns a UTF-8 representation of the string as a QByteArray.
Definition: qstring.cpp:4074
#define error(msg)
The QByteArray class provides an array of bytes.
Definition: qbytearray.h:135
QString toString() const
Returns the variant as a QString if the variant has type() String , Bool , ByteArray ...
Definition: qvariant.cpp:2270
void dbus_pending_call_unref(DBusPendingCall *pending)
QList< QVariant > toList() const
Returns the variant as a QVariantList if the variant has type() List or StringList ; otherwise return...
Definition: qvariant.cpp:2751
dbus_bool_t dbus_connection_send_with_reply(DBusConnection *connection, DBusMessage *message, DBusPendingCall **pending_return, int timeout_milliseconds)
bool toBool() const
Returns the variant as a bool if the variant has type() Bool.
Definition: qvariant.cpp:2691
int dbus_message_get_type(DBusMessage *message)
void synchronousDispatch(int timeout_ms)
The QString class provides a Unicode character string.
Definition: qstring.h:83
static QList< QVariant > toList(char **buf, int count, T *=0)
Definition: qsql_ibase.cpp:472
#define Q_ASSERT(cond)
Definition: qglobal.h:1823
The QObject class is the base class of all Qt objects.
Definition: qobject.h:111
static QString variantToSignature(const QVariant &argument, bool constantList=true)
void signalReceived(const QString &interface, const QString &signal, const QList< QVariant > &args)
void emitSignalReceived(const QString &interface, const QString &signal, const QList< QVariant > &args)
The QChar class provides a 16-bit Unicode character.
Definition: qchar.h:72
QByteArray toByteArray() const
Returns the variant as a QByteArray if the variant has type() ByteArray or String (converted using QS...
Definition: qvariant.cpp:2383
bool isEmpty() const
Returns true if the list contains no items; otherwise returns false.
Definition: qlist.h:152
int toInt(bool *ok=0) const
Returns the variant as an int if the variant has type() Int , Bool , ByteArray , Char ...
Definition: qvariant.cpp:2625
DBusDispatcherPrivate * priv
Q_CORE_EXPORT void qDebug(const char *,...)
bool removeOne(const T &t)
Removes the first occurrence of value in the list and returns true on success; otherwise returns fals...
Definition: qlist.h:796
QStringList toStringList() const
Returns the variant as a QStringList if the variant has type() StringList, String ...
Definition: qvariant.cpp:2259
const char * dbus_message_get_error_name(DBusMessage *message)
void append(const T &t)
Inserts value at the end of the list.
Definition: qlist.h:507
DBusMessage * dbus_message_new_method_call(const char *bus_name, const char *path, const char *interface, const char *method)
qlonglong toLongLong(bool *ok=0) const
Returns the variant as a long long int if the variant has type() LongLong , Bool , ByteArray , Char , Double , Int , String , UInt , or ULongLong ; otherwise returns 0.
Definition: qvariant.cpp:2659
static DBusHandlerResult signalHandler(DBusConnection *connection, DBusMessage *message, void *object_ref)
void dbus_message_iter_init_append(DBusMessage *message, DBusMessageIter *iter)
T takeFirst()
Removes the first item in the list and returns it.
Definition: qlist.h:489
DBusDispatcherPrivate(const QString &service, const QString &path, const QString &interface, const QString &signalPath)
void dbus_pending_call_cancel(DBusPendingCall *pending)
const T & at(int i) const
Returns the item at index position i in the list.
Definition: qlist.h:468
QList< QVariant > call(const QString &method, const QVariant &arg1=QVariant(), const QVariant &arg2=QVariant(), const QVariant &arg3=QVariant(), const QVariant &arg4=QVariant(), const QVariant &arg5=QVariant(), const QVariant &arg6=QVariant(), const QVariant &arg7=QVariant(), const QVariant &arg8=QVariant())
#define emit
Definition: qobjectdefs.h:76
struct DBusConnection * connection
The QStringList class provides a list of strings.
Definition: qstringlist.h:66
DBusDispatcher(const QString &service, const QString &path, const QString &interface, QObject *parent=0)
static QString fromUtf8(const char *, int size=-1)
Returns a QString initialized with the first size bytes of the UTF-8 string str.
Definition: qstring.cpp:4302
qulonglong toULongLong(bool *ok=0) const
Returns the variant as as an unsigned long long int if the variant has type() ULongLong ...
Definition: qvariant.cpp:2675
int dbus_message_iter_get_element_type(DBusMessageIter *iter)
dbus_bool_t dbus_message_iter_next(DBusMessageIter *iter)
static const char * data(const QByteArray &arr)
unsigned int uint
Definition: qglobal.h:996
Type
This enum type defines the types of variable that a QVariant can contain.
Definition: qvariant.h:95
#define FALSE
Synonym for false.
Definition: qglobal.h:1019
QByteArray toLatin1() const Q_REQUIRED_RESULT
Returns a Latin-1 representation of the string as a QByteArray.
Definition: qstring.cpp:3993
DBusMessage * dbus_connection_send_with_reply_and_block(DBusConnection *connection, DBusMessage *message, int timeout_milliseconds, DBusError *error)
dbus_bool_t dbus_message_iter_init(DBusMessage *message, DBusMessageIter *iter)
void dbus_message_iter_recurse(DBusMessageIter *iter, DBusMessageIter *sub)
char toAscii() const
Returns the character value of the QChar obtained using the current codec used to read C strings...
Definition: qchar.cpp:1490
dbus_bool_t dbus_message_iter_append_basic(DBusMessageIter *iter, int type, const void *value)
void dbus_connection_unref(DBusConnection *connection)
Type type() const
Returns the storage type of the value stored in the variant.
Definition: qvariant.cpp:1901
QObject * parent() const
Returns a pointer to the parent object.
Definition: qobject.h:273
uint toUInt(bool *ok=0) const
Returns the variant as an unsigned int if the variant has type() UInt , Bool , ByteArray ...
Definition: qvariant.cpp:2644
int size() const
Returns the number of items in the list.
Definition: qlist.h:137
QByteArray toAscii() const Q_REQUIRED_RESULT
Returns an 8-bit representation of the string as a QByteArray.
Definition: qstring.cpp:4014
const char * dbus_message_get_member(DBusMessage *message)
DBusMessage * dbus_pending_call_steal_reply(DBusPendingCall *pending)
static DBusMessage * prepareDBusCall(const QString &service, const QString &path, const QString &interface, const QString &method, const QVariant &arg1=QVariant(), const QVariant &arg2=QVariant(), const QVariant &arg3=QVariant(), const QVariant &arg4=QVariant(), const QVariant &arg5=QVariant(), const QVariant &arg6=QVariant(), const QVariant &arg7=QVariant(), const QVariant &arg8=QVariant())
int size() const
Returns the number of bytes in this byte array.
Definition: qbytearray.h:402
struct DBusObjectPathVTable signal_vtable
int dbus_message_iter_get_arg_type(DBusMessageIter *iter)
quint64 qulonglong
Definition: qglobal.h:952
DBusConnection * dbus_bus_get_private(DBusBusType type, DBusError *error)
const char * variant
static QVariant getVariantFromDBusMessage(DBusMessageIter *iter)
void dbus_connection_close(DBusConnection *connection)
static void pendingCallFunction(DBusPendingCall *pending, void *memory)
QChar toChar() const
Returns the variant as a QChar if the variant has type() Char , Int , or UInt ; otherwise returns an ...
Definition: qvariant.cpp:2579
QList< DBusPendingCall * > pending_calls
qint64 qlonglong
Definition: qglobal.h:951
static void freePendingCallInfo(void *memory)
void emitCallReply(const QString &method, const QList< QVariant > &args, const QString &error="")
static bool constantVariantList(const QVariantList &variantList)
void callReply(const QString &method, const QList< QVariant > &args, const QString &error)
static bool appendVariantToDBusMessage(const QVariant &argument, DBusMessageIter *dbus_iter)
dbus_bool_t dbus_message_iter_open_container(DBusMessageIter *iter, int type, const char *contained_signature, DBusMessageIter *sub)
The QList class is a template class that provides lists.
Definition: qdatastream.h:62
void dbus_message_iter_get_basic(DBusMessageIter *iter, void *value)
dbus_bool_t dbus_message_iter_append_fixed_array(DBusMessageIter *iter, int element_type, const void *value, int n_elements)