56 q_dbus_message_iter_append_basic(it, type, arg);
78 dbus_bool_t
cast = arg;
145 if (!
ba && fd == -1) {
155 *
ba += DBUS_TYPE_ARRAY_AS_STRING DBUS_TYPE_BYTE_AS_STRING;
160 DBusMessageIter subiterator;
161 q_dbus_message_iter_open_container(&
iterator, DBUS_TYPE_ARRAY, DBUS_TYPE_BYTE_AS_STRING,
163 q_dbus_message_iter_append_fixed_array(&subiterator, DBUS_TYPE_BYTE, &cdata, arg.
length());
164 q_dbus_message_iter_close_container(&
iterator, &subiterator);
170 *
ba += DBUS_TYPE_VARIANT_AS_STRING;
177 qWarning(
"QDBusMarshaller: cannot add a null QDBusVariant");
183 const char *signature = 0;
194 qWarning(
"QDBusMarshaller: type `%s' (%d) is not registered with D-BUS. " 195 "Use qDBusRegisterMetaType to register it",
203 open(sub, DBUS_TYPE_VARIANT, signature);
213 *
ba += DBUS_TYPE_ARRAY_AS_STRING DBUS_TYPE_STRING_AS_STRING;
218 open(sub, DBUS_TYPE_ARRAY, DBUS_TYPE_STRING_AS_STRING);
221 for ( ; it !=
end; ++
it)
235 qWarning(
"QDBusMarshaller: type `%s' (%d) is not registered with D-BUS. " 236 "Use qDBusRegisterMetaType to register it",
250 qWarning(
"QDBusMarshaller: type `%s' (%d) is not registered with D-BUS. " 251 "Use qDBusRegisterMetaType to register it",
258 qWarning(
"QDBusMarshaller: type '%s' (%d) cannot be used as the key type in a D-BUS map.",
268 qWarning(
"QDBusMarshaller: type `%s' (%d) is not registered with D-BUS. " 269 "Use qDBusRegisterMetaType to register it",
277 signature = DBUS_DICT_ENTRY_BEGIN_CHAR_AS_STRING;
278 signature += ksignature;
279 signature += vsignature;
280 signature += DBUS_DICT_ENTRY_END_CHAR_AS_STRING;
298 case DBUS_TYPE_ARRAY:
303 case DBUS_TYPE_DICT_ENTRY:
307 case DBUS_TYPE_STRUCT:
308 *
ba += DBUS_STRUCT_BEGIN_CHAR;
313 q_dbus_message_iter_open_container(&
iterator, code, signature, &sub.
iterator);
319 open(*d, code, signature);
365 qWarning(
"QDBusMarshaller: cannot add an invalid QVariant");
378 demarshaller.
message = q_dbus_message_ref(d->message);
385 if (!q_dbus_message_iter_init(demarshaller.
message, &demarshaller.
iterator))
394 qWarning(
"QDBusMarshaller: type `%s' (%d) is not registered with D-BUS. " 395 "Use qDBusRegisterMetaType to register it",
402 switch (*signature) {
405 case DBUS_TYPE_INT16:
406 case DBUS_TYPE_UINT16:
407 case DBUS_TYPE_INT32:
408 case DBUS_TYPE_UINT32:
409 case DBUS_TYPE_INT64:
410 case DBUS_TYPE_UINT64:
411 case DBUS_TYPE_DOUBLE:
414 case DBUS_TYPE_BOOLEAN:
419 append( qvariant_cast<uchar>(arg) );
421 case DBUS_TYPE_BOOLEAN:
424 case DBUS_TYPE_INT16:
425 append( qvariant_cast<short>(arg) );
427 case DBUS_TYPE_UINT16:
428 append( qvariant_cast<ushort>(arg) );
430 case DBUS_TYPE_INT32:
433 case DBUS_TYPE_UINT32:
436 case DBUS_TYPE_INT64:
439 case DBUS_TYPE_UINT64:
442 case DBUS_TYPE_DOUBLE:
447 case DBUS_TYPE_STRING:
450 case DBUS_TYPE_OBJECT_PATH:
451 append( qvariant_cast<QDBusObjectPath>(arg) );
453 case DBUS_TYPE_SIGNATURE:
454 append( qvariant_cast<QDBusSignature>(arg) );
458 case DBUS_TYPE_VARIANT:
460 return append( qvariant_cast<QDBusVariant>(arg) );
462 case DBUS_TYPE_ARRAY:
465 switch (arg.
type()) {
479 case DBUS_TYPE_STRUCT:
480 case DBUS_STRUCT_BEGIN_CHAR:
483 case DBUS_TYPE_DICT_ENTRY:
484 case DBUS_DICT_ENTRY_BEGIN_CHAR:
485 qFatal(
"QDBusMarshaller::appendVariantInternal got a DICT_ENTRY!");
490 append(qvariant_cast<QDBusUnixFileDescriptor>(arg));
496 qWarning(
"QDBusMarshaller::appendVariantInternal: Found unknown D-BUS type '%s'",
513 int code = q_dbus_message_iter_get_arg_type(&demarshaller->
iterator);
520 q_dbus_message_iter_get_basic(&demarshaller->
iterator, &value);
521 q_dbus_message_iter_next(&demarshaller->
iterator);
522 q_dbus_message_iter_append_basic(&
iterator, code, &value);
526 if (code == DBUS_TYPE_ARRAY) {
527 int element = q_dbus_message_iter_get_element_type(&demarshaller->
iterator);
532 q_dbus_message_iter_recurse(&demarshaller->
iterator, &sub);
533 q_dbus_message_iter_next(&demarshaller->
iterator);
536 q_dbus_message_iter_get_fixed_array(&sub,&data,&len);
538 char signature[2] = { char(element), 0 };
539 q_dbus_message_iter_open_container(&
iterator, DBUS_TYPE_ARRAY, signature, &sub);
540 q_dbus_message_iter_append_fixed_array(&sub, element, &data, len);
541 q_dbus_message_iter_close_container(&
iterator, &sub);
553 if (code == DBUS_TYPE_VARIANT || code == DBUS_TYPE_ARRAY) {
558 open(mrecursed, code, sig);
560 while (!drecursed->
atEnd()) {
The QVariant class acts like a union for the most common Qt data types.
static QDBusArgumentPrivate * d(QDBusArgument &q)
QDBusMarshaller * beginCommon(int code, const char *signature)
bool appendCrossMarshalling(QDBusDemarshaller *arg)
QDBusMarshaller * endArray()
void error(const QString &message)
#define QT_END_NAMESPACE
This macro expands to.
#define it(className, varName)
The QDBusArgument class is used to marshall and demarshall D-Bus arguments.
static QDBusArgument create(QDBusArgumentPrivate *d)
QByteArray toUtf8() const Q_REQUIRED_RESULT
Returns a UTF-8 representation of the string as a QByteArray.
QString currentSignature()
QDBusMarshaller * beginMapEntry()
The QByteArray class provides an array of bytes.
QString toString() const
Returns the variant as a QString if the variant has type() String , Bool , ByteArray ...
const_iterator constBegin() const
Returns a const STL-style iterator pointing to the first item in the list.
The QDBusSignature class enables the programmer to identify the SIGNATURE type provided by the D-Bus ...
QLatin1String(DBUS_INTERFACE_DBUS))) Q_GLOBAL_STATIC_WITH_ARGS(QString
bool toBool() const
Returns the variant as a bool if the variant has type() Bool.
#define DBUS_TYPE_UNIX_FD
bool ref()
Atomically increments the value of this QAtomicInt.
QDBusDemarshaller * demarshaller()
The QString class provides a Unicode character string.
static const char * typeToName(Type type)
Converts the enum representation of the storage type, typ, to its string representation.
static void qIterAppend(DBusMessageIter *it, QByteArray *ba, int type, const void *arg)
QByteArray toByteArray() const
Returns the variant as a QByteArray if the variant has type() ByteArray or String (converted using QS...
bool appendVariantInternal(const QVariant &arg)
int toInt(bool *ok=0) const
Returns the variant as an int if the variant has type() Int , Bool , ByteArray , Char ...
The QDBusUnixFileDescriptor class holds one Unix file descriptor.
QDBusMarshaller * endStructure()
QStringList toStringList() const
Returns the variant as a QStringList if the variant has type() StringList, String ...
QDBusMarshaller(int flags)
#define QT_BEGIN_NAMESPACE
This macro expands to.
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.
QDBusMarshaller * beginMap(int kid, int vid)
The QStringList class provides a list of strings.
static QString fromUtf8(const char *, int size=-1)
Returns a QString initialized with the first size bytes of the UTF-8 string str.
qulonglong toULongLong(bool *ok=0) const
Returns the variant as as an unsigned long long int if the variant has type() ULongLong ...
Q_CORE_EXPORT void qWarning(const char *,...)
static const char * data(const QByteArray &arr)
Type
This enum type defines the types of variable that a QVariant can contain.
QString path() const
Returns this object path.
QByteArray toLatin1() const Q_REQUIRED_RESULT
Returns a Latin-1 representation of the string as a QByteArray.
bool isValidFixedType(int c)
Returns true if c is a valid, fixed D-Bus type.
QDBusMarshaller * beginStructure()
int length() const
Same as size().
const char * constData() const
Returns a pointer to the data stored in the byte array.
Q_CORE_EXPORT void qFatal(const char *,...)
bool isValidBasicType(int c)
Returns true if c is a valid, basic D-Bus type.
int userType() const
Returns the storage type of the value stored in the variant.
QDBusMarshaller * beginArray(int id)
QDBusMarshaller * endMapEntry()
static QString fromLatin1(const char *, int size=-1)
Returns a QString initialized with the first size characters of the Latin-1 string str...
Type type() const
Returns the storage type of the value stored in the variant.
const void * constData() const
const_iterator ConstIterator
Qt-style synonym for QList::const_iterator.
QDBusMarshaller * endCommon()
uint toUInt(bool *ok=0) const
Returns the variant as an unsigned int if the variant has type() UInt , Bool , ByteArray ...
The QDBusObjectPath class enables the programmer to identify the OBJECT_PATH type provided by the D-B...
QVariant variant() const
Returns this D-Bus variant as a QVariant object.
T qvariant_cast(const QVariant &)
double toDouble(bool *ok=0) const
Returns the variant as a double if the variant has type() Double , QMetaType::Float ...
bool appendRegisteredType(const QVariant &arg)
int fileDescriptor() const
Returns the Unix file descriptor contained by this QDBusUnixFileDescriptor object.
bool isEmpty() const
Returns true if the byte array has size 0; otherwise returns false.
void open(QDBusMarshaller &sub, int code, const char *signature)
QDBusMarshaller * endMap()
QString signature() const
Returns this signature.
static const KeyPair *const end
The QDBusVariant class enables the programmer to identify the variant type provided by the D-Bus type...
QString currentSignature()
const_iterator constEnd() const
Returns a const STL-style iterator pointing to the imaginary item after the last item in the list...
QDBusDemarshaller * beginCommon()