Qt 4.8
Classes | Enumerations | Functions | Variables
Maemo Namespace Reference

Classes

struct  CommonParams
 
class  DBusDispatcher
 DBusDispatcher is a class that can send DBUS method call messages and receive unicast signals from DBUS objects. More...
 
class  DBusDispatcherPrivate
 
class  GConfItemFast
 
class  IAPConf
 
class  IAPConfPrivate
 
class  IAPMonitor
 
class  IAPMonitorPrivate
 
class  Icd
 
struct  IcdAddressInfoResult
 
struct  IcdIPInformation
 
class  IcdPrivate
 
struct  IcdScanResult
 
struct  IcdStateResult
 
struct  IcdStatisticsResult
 
class  NetworkProxyFactory
 
class  PendingCallInfo
 
class  ProxyConf
 
class  ProxyConfPrivate
 

Enumerations

enum  IcdDbusInterfaceVer { IcdOldDbusInterface = 0, IcdNewDbusInterface }
 

Functions

static bool appendVariantToDBusMessage (const QVariant &argument, DBusMessageIter *dbus_iter)
 
void conn_settings_notify_func (ConnSettingsType type, const char *id, const char *key, ConnSettingsValue *value, void *user_data)
 
static bool constantVariantList (const QVariantList &variantList)
 
static QString convertKey (const char *key)
 
static QVariant convertValue (GConfValue *src)
 
static void freePendingCallInfo (void *memory)
 
static void get_addrinfo_all_result (QList< QVariant > &args, IcdAddressInfoResult &ret)
 
static void get_scan_result (QList< QVariant > &args, IcdScanResult &ret)
 
static void get_state_all_result (QList< QVariant > &args, IcdStateResult &ret)
 
static void get_state_all_result2 (QList< QVariant > &args, IcdStateResult &ret)
 
static void get_statistics_all_result (QList< QVariant > &args, IcdStatisticsResult &ret)
 
static QHash< QString, QVariantgetHttpValues (const QString &prefix)
 
static QHash< QString, QVariantgetValues (const QString &prefix)
 
static QVariant getVariantFromDBusMessage (DBusMessageIter *iter)
 
static void pendingCallFunction (DBusPendingCall *pending, void *memory)
 
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())
 
static DBusHandlerResult signalHandler (DBusConnection *connection, DBusMessage *message, void *object_ref)
 
static QString variantToSignature (const QVariant &argument, bool constantList=true)
 

Variables

static QReadWriteLock lock
 
static int refcount = 0
 

Enumeration Type Documentation

◆ IcdDbusInterfaceVer

Enumerator
IcdOldDbusInterface 
IcdNewDbusInterface 

Definition at line 122 of file maemo_icd.h.

122  {
123  IcdOldDbusInterface = 0, // use the old OSSO-IC interface
124  IcdNewDbusInterface // use the new Icd2 interface (default)
125 };

Function Documentation

◆ appendVariantToDBusMessage()

static bool Maemo::appendVariantToDBusMessage ( const QVariant argument,
DBusMessageIter *  dbus_iter 
)
static

Definition at line 156 of file dbusdispatcher.cpp.

Referenced by prepareDBusCall().

157  {
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 }
The QVariant class acts like a union for the most common Qt data types.
Definition: qvariant.h:92
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)
QByteArray toUtf8() const Q_REQUIRED_RESULT
Returns a UTF-8 representation of the string as a QByteArray.
Definition: qstring.cpp:4074
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
QList< QVariant > toList() const
Returns the variant as a QVariantList if the variant has type() List or StringList ; otherwise return...
Definition: qvariant.cpp:2751
bool toBool() const
Returns the variant as a bool if the variant has type() Bool.
Definition: qvariant.cpp:2691
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
static QString variantToSignature(const QVariant &argument, bool constantList=true)
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
Q_CORE_EXPORT void qDebug(const char *,...)
QStringList toStringList() const
Returns the variant as a QStringList if the variant has type() StringList, String ...
Definition: qvariant.cpp:2259
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
const T & at(int i) const
Returns the item at index position i in the list.
Definition: qlist.h:468
The QStringList class provides a list of strings.
Definition: qstringlist.h:66
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
static const char * data(const QByteArray &arr)
QByteArray toLatin1() const Q_REQUIRED_RESULT
Returns a Latin-1 representation of the string as a QByteArray.
Definition: qstring.cpp:3993
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)
Type type() const
Returns the storage type of the value stored in the variant.
Definition: qvariant.cpp:1901
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
int size() const
Returns the number of bytes in this byte array.
Definition: qbytearray.h:402
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
static bool constantVariantList(const QVariantList &variantList)
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)
dbus_bool_t dbus_message_iter_append_fixed_array(DBusMessageIter *iter, int element_type, const void *value, int n_elements)

◆ conn_settings_notify_func()

void Maemo::conn_settings_notify_func ( ConnSettingsType  type,
const char *  id,
const char *  key,
ConnSettingsValue *  value,
void *  user_data 
)

Definition at line 91 of file iapmonitor.cpp.

Referenced by Maemo::IAPMonitorPrivate::IAPMonitorPrivate().

96 {
97  Q_UNUSED(id);
98 
99  if (type != CONN_SETTINGS_CONNECTION) return;
100  IAPMonitorPrivate *priv = (IAPMonitorPrivate *)user_data;
101 
102  QString iapId(key);
103  iapId = iapId.split("/")[0];
104  if (value != 0) {
105  priv->iapAdded(iapId);
106  } else if (iapId == QString(key)) {
107  // IAP is removed only when the directory gets removed
108  priv->iapRemoved(iapId);
109  }
110 }
int type
Definition: qmetatype.cpp:239
The QString class provides a Unicode character string.
Definition: qstring.h:83
int key
static const QMetaObjectPrivate * priv(const uint *data)
#define Q_UNUSED(x)
Indicates to the compiler that the parameter with the specified name is not used in the body of a fun...
Definition: qglobal.h:1729

◆ constantVariantList()

static bool Maemo::constantVariantList ( const QVariantList variantList)
static

Definition at line 93 of file dbusdispatcher.cpp.

Referenced by appendVariantToDBusMessage().

93  {
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 }
The QVariant class acts like a union for the most common Qt data types.
Definition: qvariant.h:92
int type
Definition: qmetatype.cpp:239
bool isEmpty() const
Returns true if the list contains no items; otherwise returns false.
Definition: qlist.h:152
Type
This enum type defines the types of variable that a QVariant can contain.
Definition: qvariant.h:95
Type type() const
Returns the storage type of the value stored in the variant.
Definition: qvariant.cpp:1901
const char * variant

◆ convertKey()

static QString Maemo::convertKey ( const char *  key)
static

Definition at line 59 of file proxyconf.cpp.

Referenced by Maemo::GConfItemFast::getEntries().

60 {
61  return QString::fromUtf8(key);
62 }
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
int key

◆ convertValue()

static QVariant Maemo::convertValue ( GConfValue *  src)
static

Definition at line 64 of file proxyconf.cpp.

Referenced by QScriptEnginePrivate::convertValue(), QScriptEnginePrivate::get(), and Maemo::GConfItemFast::getEntries().

65 {
66  if (!src) {
67  return QVariant();
68  } else {
69  switch (src->type) {
70  case GCONF_VALUE_INVALID:
72  case GCONF_VALUE_BOOL:
73  return QVariant((bool)gconf_value_get_bool(src));
74  case GCONF_VALUE_INT:
75  return QVariant(gconf_value_get_int(src));
76  case GCONF_VALUE_FLOAT:
77  return QVariant(gconf_value_get_float(src));
78  case GCONF_VALUE_STRING:
79  return QVariant(QString::fromUtf8(gconf_value_get_string(src)));
80  case GCONF_VALUE_LIST:
81  switch (gconf_value_get_list_type(src)) {
82  case GCONF_VALUE_STRING:
83  {
84  QStringList result;
85  for (GSList *elts = gconf_value_get_list(src); elts; elts = elts->next)
86  result.append(QString::fromUtf8(gconf_value_get_string((GConfValue *)elts->data)));
87  return QVariant(result);
88  }
89  default:
90  {
91  QList<QVariant> result;
92  for (GSList *elts = gconf_value_get_list(src); elts; elts = elts->next)
93  result.append(convertValue((GConfValue *)elts->data));
94  return QVariant(result);
95  }
96  }
97  case GCONF_VALUE_SCHEMA:
98  default:
99  return QVariant();
100  }
101  }
102 }
The QVariant class acts like a union for the most common Qt data types.
Definition: qvariant.h:92
static QVariant convertValue(GConfValue *src)
Definition: proxyconf.cpp:64
void append(const T &t)
Inserts value at the end of the list.
Definition: qlist.h:507
The QStringList class provides a list of strings.
Definition: qstringlist.h:66
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

◆ freePendingCallInfo()

static void Maemo::freePendingCallInfo ( void *  memory)
static

Definition at line 563 of file dbusdispatcher.cpp.

Referenced by Maemo::DBusDispatcher::callAsynchronous().

563  {
564  PendingCallInfo *info = (PendingCallInfo *)memory;
565  delete info;
566 }
static mach_timebase_info_data_t info

◆ get_addrinfo_all_result()

static void Maemo::get_addrinfo_all_result ( QList< QVariant > &  args,
IcdAddressInfoResult ret 
)
static

Definition at line 620 of file maemo_icd.cpp.

Referenced by Maemo::IcdPrivate::addrinfo().

622 {
623  int i=0;
624 
625  if (args.isEmpty())
626  return;
627 
628  ret.params.service_type = args[i++].toString();
629  ret.params.service_attrs = args[i++].toUInt();
630  ret.params.service_id = args[i++].toString();
631  ret.params.network_type = args[i++].toString();
632  ret.params.network_attrs = args[i++].toUInt();
633  ret.params.network_id = args[i++].toByteArray();
634 
635  QVariantList vl = args[i].toList();
636  QVariant reply = vl.first();
637  QList<QVariant> lst = reply.toList();
638  for (int k=0; k<lst.size()/6; k=k+6) {
639  IcdIPInformation ip_info;
640  ip_info.address = lst[k].toString();
641  ip_info.netmask = lst[k++].toString();
642  ip_info.default_gateway = lst[k++].toString();
643  ip_info.dns1 = lst[k++].toString();
644  ip_info.dns2 = lst[k++].toString();
645  ip_info.dns3 = lst[k++].toString();
646 
647  ret.ip_info << ip_info;
648  }
649 }
The QVariant class acts like a union for the most common Qt data types.
Definition: qvariant.h:92
QList< QVariant > toList() const
Returns the variant as a QVariantList if the variant has type() List or StringList ; otherwise return...
Definition: qvariant.cpp:2751
bool isEmpty() const
Returns true if the list contains no items; otherwise returns false.
Definition: qlist.h:152
T & first()
Returns a reference to the first item in the list.
Definition: qlist.h:282
int size() const
Returns the number of items in the list.
Definition: qlist.h:137

◆ get_scan_result()

static void Maemo::get_scan_result ( QList< QVariant > &  args,
IcdScanResult ret 
)
static

Definition at line 248 of file maemo_icd.cpp.

Referenced by Maemo::IcdPrivate::scan().

250 {
251  int i=0;
252 
253  if (args.isEmpty())
254  return;
255 
256  ret.status = args[i++].toUInt();
257  ret.timestamp = args[i++].toUInt();
258  ret.scan.service_type = args[i++].toString();
259  ret.service_name = args[i++].toString();
260  ret.scan.service_attrs = args[i++].toUInt();
261  ret.scan.service_id = args[i++].toString();
262  ret.service_priority = args[i++].toInt();
263  ret.scan.network_type = args[i++].toString();
264  ret.network_name = args[i++].toString();
265  ret.scan.network_attrs = args[i++].toUInt();
266  ret.scan.network_id = args[i++].toByteArray();
267  ret.network_priority = args[i++].toInt();
268  ret.signal_strength = args[i++].toInt();
269  ret.station_id = args[i++].toString();
270  ret.signal_dB = args[i++].toInt();
271 }
bool isEmpty() const
Returns true if the list contains no items; otherwise returns false.
Definition: qlist.h:152

◆ get_state_all_result()

static void Maemo::get_state_all_result ( QList< QVariant > &  args,
IcdStateResult ret 
)
static

Definition at line 382 of file maemo_icd.cpp.

Referenced by Maemo::IcdPrivate::state().

384 {
385  int i=0;
386 
387  ret.params.service_type = args[i++].toString();
388  ret.params.service_attrs = args[i++].toUInt();
389  ret.params.service_id = args[i++].toString();
390  ret.params.network_type = args[i++].toString();
391  ret.params.network_attrs = args[i++].toUInt();
392  ret.params.network_id = args[i++].toByteArray();
393  ret.error = args[i++].toString();
394  ret.state = args[i++].toInt();
395 }

◆ get_state_all_result2()

static void Maemo::get_state_all_result2 ( QList< QVariant > &  args,
IcdStateResult ret 
)
static

Definition at line 398 of file maemo_icd.cpp.

Referenced by Maemo::IcdPrivate::state().

400 {
401  int i=0;
402 
403  ret.params.network_type = args[i++].toString();
404  ret.state = args[i++].toInt();
405 
406  // Initialize the other values so that the caller can
407  // notice we only returned partial status
408  ret.params.service_type = QString();
409  ret.params.service_attrs = 0;
410  ret.params.service_id = QString();
411  ret.params.network_attrs = 0;
412  ret.params.network_id = QByteArray();
413  ret.error = QString();
414 }
The QByteArray class provides an array of bytes.
Definition: qbytearray.h:135
The QString class provides a Unicode character string.
Definition: qstring.h:83

◆ get_statistics_all_result()

static void Maemo::get_statistics_all_result ( QList< QVariant > &  args,
IcdStatisticsResult ret 
)
static

Definition at line 543 of file maemo_icd.cpp.

Referenced by Maemo::IcdPrivate::statistics().

545 {
546  int i=0;
547 
548  if (args.isEmpty())
549  return;
550 
551  ret.params.service_type = args[i++].toString();
552  ret.params.service_attrs = args[i++].toUInt();
553  ret.params.service_id = args[i++].toString();
554  ret.params.network_type = args[i++].toString();
555  ret.params.network_attrs = args[i++].toUInt();
556  ret.params.network_id = args[i++].toByteArray();
557  ret.time_active = args[i++].toUInt();
558  ret.signal_strength = (enum icd_nw_levels)args[i++].toUInt();
559  ret.bytes_sent = args[i++].toUInt();
560  ret.bytes_received = args[i++].toUInt();
561 }
bool isEmpty() const
Returns true if the list contains no items; otherwise returns false.
Definition: qlist.h:152

◆ getHttpValues()

static QHash<QString,QVariant> Maemo::getHttpValues ( const QString prefix)
static

Definition at line 206 of file proxyconf.cpp.

Referenced by Maemo::ProxyConfPrivate::readProxyData().

207 {
208  GConfItemFast item(prefix);
209  return item.getEntries();
210 }

◆ getValues()

static QHash<QString,QVariant> Maemo::getValues ( const QString prefix)
static

Definition at line 200 of file proxyconf.cpp.

Referenced by QGLContext::chooseContext(), and Maemo::ProxyConfPrivate::readProxyData().

201 {
202  GConfItemFast item(prefix);
203  return item.getEntries();
204 }

◆ getVariantFromDBusMessage()

static QVariant Maemo::getVariantFromDBusMessage ( DBusMessageIter *  iter)
static

Definition at line 290 of file dbusdispatcher.cpp.

Referenced by Maemo::DBusDispatcher::call(), and pendingCallFunction().

290  {
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 }
The QVariant class acts like a union for the most common Qt data types.
Definition: qvariant.h:92
QByteArray & append(char c)
Appends the character ch to this byte array.
The QByteArray class provides an array of bytes.
Definition: qbytearray.h:135
The QString class provides a Unicode character string.
Definition: qstring.h:83
The QChar class provides a 16-bit Unicode character.
Definition: qchar.h:72
Q_CORE_EXPORT void qDebug(const char *,...)
void append(const T &t)
Inserts value at the end of the list.
Definition: qlist.h:507
The QStringList class provides a list of strings.
Definition: qstringlist.h:66
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
int dbus_message_iter_get_element_type(DBusMessageIter *iter)
dbus_bool_t dbus_message_iter_next(DBusMessageIter *iter)
unsigned int uint
Definition: qglobal.h:996
void dbus_message_iter_recurse(DBusMessageIter *iter, DBusMessageIter *sub)
int dbus_message_iter_get_arg_type(DBusMessageIter *iter)
quint64 qulonglong
Definition: qglobal.h:952
const char * variant
static QVariant getVariantFromDBusMessage(DBusMessageIter *iter)
qint64 qlonglong
Definition: qglobal.h:951
void dbus_message_iter_get_basic(DBusMessageIter *iter, void *value)

◆ pendingCallFunction()

static void Maemo::pendingCallFunction ( DBusPendingCall *  pending,
void *  memory 
)
static

Definition at line 568 of file dbusdispatcher.cpp.

Referenced by Maemo::DBusDispatcher::callAsynchronous().

569  {
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 }
static mach_timebase_info_data_t info
void dbus_message_unref(DBusMessage *message)
void dbus_pending_call_unref(DBusPendingCall *pending)
int dbus_message_get_type(DBusMessage *message)
The QString class provides a Unicode character string.
Definition: qstring.h:83
#define Q_ASSERT(cond)
Definition: qglobal.h:1823
const char * dbus_message_get_error_name(DBusMessage *message)
dbus_bool_t dbus_message_iter_next(DBusMessageIter *iter)
dbus_bool_t dbus_message_iter_init(DBusMessage *message, DBusMessageIter *iter)
DBusMessage * dbus_pending_call_steal_reply(DBusPendingCall *pending)
int dbus_message_iter_get_arg_type(DBusMessageIter *iter)
static QVariant getVariantFromDBusMessage(DBusMessageIter *iter)

◆ prepareDBusCall()

static DBusMessage* Maemo::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() 
)
static

Definition at line 485 of file dbusdispatcher.cpp.

Referenced by Maemo::DBusDispatcher::call(), and Maemo::DBusDispatcher::callAsynchronous().

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 }
The QVariant class acts like a union for the most common Qt data types.
Definition: qvariant.h:92
bool isEmpty() const
Returns true if the list contains no items; otherwise returns false.
Definition: qlist.h:152
DBusMessage * dbus_message_new_method_call(const char *bus_name, const char *path, const char *interface, const char *method)
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
QByteArray toLatin1() const Q_REQUIRED_RESULT
Returns a Latin-1 representation of the string as a QByteArray.
Definition: qstring.cpp:3993
bool isValid() const
Returns true if the storage type of this variant is not QVariant::Invalid; otherwise returns false...
Definition: qvariant.h:485
static bool appendVariantToDBusMessage(const QVariant &argument, DBusMessageIter *dbus_iter)

◆ signalHandler()

static DBusHandlerResult Maemo::signalHandler ( DBusConnection *  connection,
DBusMessage *  message,
void *  object_ref 
)
static

Definition at line 409 of file dbusdispatcher.cpp.

Referenced by Maemo::DBusDispatcher::setupDBus().

411  {
412  (void)connection;
413  QString interface;
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 }
int dbus_message_get_type(DBusMessage *message)
The QString class provides a Unicode character string.
Definition: qstring.h:83
dbus_bool_t dbus_message_iter_next(DBusMessageIter *iter)
dbus_bool_t dbus_message_iter_init(DBusMessage *message, DBusMessageIter *iter)
const char * dbus_message_get_member(DBusMessage *message)
int dbus_message_iter_get_arg_type(DBusMessageIter *iter)
static QVariant getVariantFromDBusMessage(DBusMessageIter *iter)

◆ variantToSignature()

static QString Maemo::variantToSignature ( const QVariant argument,
bool  constantList = true 
)
static

Definition at line 109 of file dbusdispatcher.cpp.

Referenced by appendVariantToDBusMessage().

110  {
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 }
The QVariant class acts like a union for the most common Qt data types.
Definition: qvariant.h:92
QList< QVariant > toList() const
Returns the variant as a QVariantList if the variant has type() List or StringList ; otherwise return...
Definition: qvariant.cpp:2751
The QString class provides a Unicode character string.
Definition: qstring.h:83
static QString variantToSignature(const QVariant &argument, bool constantList=true)
bool isEmpty() const
Returns true if the list contains no items; otherwise returns false.
Definition: qlist.h:152
Q_CORE_EXPORT void qDebug(const char *,...)
Type type() const
Returns the storage type of the value stored in the variant.
Definition: qvariant.cpp:1901

Variable Documentation

◆ lock

QReadWriteLock Maemo::lock
static

Definition at line 399 of file proxyconf.cpp.

Referenced by QSocks5BindStore::add(), QUrl::addEncodedQueryItem(), QUrl::addQueryItem(), QDir::addResourceSearchPath(), QResource::addSearchPath(), QUrl::allEncodedQueryItemValues(), QPatternist::NamePool::allocateLocalName(), QPatternist::NamePool::allocateNamespace(), QPatternist::NamePool::allocatePrefix(), QUrl::allQueryItemValues(), QDeclarativeMetaType::attachedPropertiesFuncById(), QDeclarativeMetaType::attachedPropertiesFuncId(), QAudioInputPrivate::audioDeviceError(), QAudioOutputPrivate::audioDeviceError(), QAudioInputPrivate::audioDeviceFull(), QAudioOutputPrivate::audioDeviceIdle(), QUrl::authority(), QWindowsPipeWriter::bytesToWrite(), QGL2GradientCacheWrapper::cacheForContext(), QGL2GradientCache::cleanCache(), QFontEngineQPF::cleanUpAfterClientCrash(), QSocks5BindStore::contains(), QDeclarativeMetaType::customStringConverter(), QUrl::detach(), QNetworkSession::disconnectNotify(), QFutureInterfaceBasePrivate::disconnectOutputInterface(), QBlittable::drawPixmapOpacity(), QUrl::encodedFragment(), QUrl::encodedPassword(), QUrl::encodedPath(), QUrl::encodedQuery(), QUrl::encodedQueryItems(), QUrl::encodedQueryItemValue(), QUrl::encodedUserName(), QResourcePrivate::ensureInitialized(), QUrl::errorString(), QBlittablePixmapData::fill(), QUrl::fragment(), QGL2GradientCache::getBuffer(), QGradientCache::getBuffer(), QWSDisplay::grab(), QWSDisplay::grabbed(), QUrl::hasEncodedQueryItem(), QUrl::hasFragment(), QUrl::hasQuery(), QUrl::host(), QDeclarativeTypePrivate::init(), QWSDisplay::initLock(), QAudioOutputPrivate::inputReady(), QDeclarativeMetaType::interfaceIId(), QtSharedPointer::internalSafetyCheckRemove(), QUrl::isEmpty(), QDeclarativeMetaType::isInterface(), QDeclarativeMetaType::isList(), QUrl::isLocalFile(), QUrl::isParentOf(), QDeclarativeMetaType::isQObject(), QUrl::isRelative(), QFutureInterfaceBase::isResultReadyAt(), QSslCertificate::issuerInfo(), QUrl::isValid(), QDeclarativeMetaType::listType(), QResourcePrivate::load(), QReadWriteLock::lockForRead(), QReadWriteLock::lockForWrite(), QMutex::lockInline(), QDBusConnection::objectRegisteredAt(), QDeclarativeMetaType::parentFunctions(), QUrl::password(), QUrl::path(), QUrl::port(), QWSKeyboardHandler::processKeycode(), QBlitterPaintEnginePrivate::QBlitterPaintEnginePrivate(), QDeclarativeMetaType::qmlComponents(), QDeclarativeMetaType::qmlType(), QDeclarativeMetaType::qmlTypeNames(), QDeclarativeMetaType::qmlTypes(), qRegisterResourceData(), qt_adopted_thread_watcher_function(), qt_watch_adopted_thread(), QUrl::queryItems(), qUnregisterResourceData(), QDirectPainter::region(), registerAutoParentFunction(), registerComponent(), QDeclarativeMetaType::registerCustomStringConverter(), registerInterface(), QResource::registerResource(), registerType(), QUrl::removeAllEncodedQueryItems(), QUrl::removeEncodedQueryItem(), QFutureInterfaceBase::resultCount(), QFutureInterface< T >::resultPointer(), QFutureInterface< T >::resultReference(), QFutureInterface< T >::results(), QSocks5BindStore::retrieve(), QUrl::scheme(), QResource::searchPaths(), QSslCertificate::serialNumber(), QGlobalNetworkProxy::setApplicationProxy(), QGlobalNetworkProxy::setApplicationProxyFactory(), QUrl::setAuthority(), QUrl::setEncodedFragment(), QUrl::setEncodedPassword(), QUrl::setEncodedPath(), QUrl::setEncodedQuery(), QUrl::setEncodedQueryItems(), QUrl::setEncodedUrl(), QUrl::setEncodedUserName(), QUrl::setFragment(), QUrl::setHost(), QWSIdentifyCommand::setId(), QUrl::setPassword(), QUrl::setPath(), QUrl::setPort(), QUrl::setQueryDelimiters(), QUrl::setQueryItems(), QUrl::setScheme(), QFutureInterfaceBase::setThrottled(), QUrl::setUrl(), QUrl::setUserInfo(), QUrl::setUserName(), QProcessPrivate::startProcess(), QPatternist::NamePool::stringForLocalName(), QPatternist::NamePool::stringForNamespace(), QPatternist::NamePool::stringForPrefix(), QSslCertificate::subjectInfo(), QSocks5BindStore::timerEvent(), QUrl::toEncoded(), QPatternist::NamePool::toLexical(), QUrl::toLocalFile(), QUrl::toString(), QReadWriteLock::tryLockForRead(), QReadWriteLock::tryLockForWrite(), QDeclarativeMetaType::typeCategory(), QWSDisplay::ungrab(), QReadWriteLock::unlock(), QResource::unregisterResource(), QUrl::userInfo(), QUrl::userName(), QSslCertificate::version(), QFutureInterfaceBase::waitForFinished(), QFutureInterfaceBase::waitForNextResult(), QFutureInterfaceBase::waitForResult(), QFutureInterfaceBase::waitForResume(), and QWSDisplay::~QWSDisplay().

◆ refcount

int Maemo::refcount = 0
static