summaryrefslogtreecommitdiff
path: root/qt
diff options
context:
space:
mode:
authorHavoc Pennington <hp@redhat.com>2005-01-15 07:15:38 +0000
committerJohn Palmieri <johnp@remedyz.boston.redhat.com>2006-06-28 08:15:10 -0400
commit3d452dcf5aa442bfce5014c56a1b244a072b8877 (patch)
tree9e2e7ba8011492b59576d72d94a910cbea08cb3c /qt
parent1bdb8df0ee11102424d78d8f6c65039ed3bc8f16 (diff)
2005-01-15 Havoc Pennington <hp@redhat.com>
* Land the new message args API and type system. This patch is huge, but the public API change is not really large. The set of D-BUS types has changed somewhat, and the arg "getters" are more geared toward language bindings; they don't make a copy, etc. There are also some known issues. See these emails for details on this huge patch: http://lists.freedesktop.org/archives/dbus/2004-December/001836.html http://lists.freedesktop.org/archives/dbus/2005-January/001922.html * dbus/dbus-marshal-*: all the new stuff * dbus/dbus-message.c: basically rewritten * dbus/dbus-memory.c (check_guards): with "guards" enabled, init freed blocks to be all non-nul bytes so using freed memory is less likely to work right * dbus/dbus-internals.c (_dbus_test_oom_handling): add DBUS_FAIL_MALLOC=N environment variable, so you can do DBUS_FAIL_MALLOC=0 to skip the out-of-memory checking, or DBUS_FAIL_MALLOC=10 to make it really, really, really slow and thorough. * qt/message.cpp: port to the new message args API (operator<<): use str.utf8() rather than str.unicode() (pretty sure this is right from the Qt docs?) * glib/dbus-gvalue.c: port to the new message args API * bus/dispatch.c, bus/driver.c: port to the new message args API * dbus/dbus-string.c (_dbus_string_init_const_len): initialize the "locked" flag to TRUE and align_offset to 0; I guess we never looked at these anyhow, but seems cleaner. * dbus/dbus-string.h (_DBUS_STRING_ALLOCATION_PADDING): move allocation padding macro to this header; use it to implement (_DBUS_STRING_STATIC): ability to declare a static string. * dbus/dbus-message.c (_dbus_message_has_type_interface_member): change to return TRUE if the interface is not set. * dbus/dbus-string.[hc]: move the D-BUS specific validation stuff to dbus-marshal-validate.[hc] * dbus/dbus-marshal-basic.c (_dbus_type_to_string): move here from dbus-internals.c * dbus/Makefile.am: cut over from dbus-marshal.[hc] to dbus-marshal-*.[hc] * dbus/dbus-object-tree.c (_dbus_decompose_path): move this function here from dbus-marshal.c
Diffstat (limited to 'qt')
-rw-r--r--qt/message.cpp64
1 files changed, 43 insertions, 21 deletions
diff --git a/qt/message.cpp b/qt/message.cpp
index 2c1f35e..55db3f3 100644
--- a/qt/message.cpp
+++ b/qt/message.cpp
@@ -185,19 +185,31 @@ QVariant Message::iterator::marshallBaseType( DBusMessageIter* i )
QVariant ret;
switch (dbus_message_iter_get_arg_type(i)) {
case DBUS_TYPE_INT32:
- ret = QVariant( dbus_message_iter_get_int32(i) );
+ {
+ dbus_int32_t v;
+ dbus_message_iter_get_basic (i, &v);
+ ret = QVariant( v );
+ }
break;
case DBUS_TYPE_UINT32:
- ret = QVariant( dbus_message_iter_get_uint32(i) );
+ {
+ dbus_uint32_t v;
+ dbus_message_iter_get_basic (i, &v);
+ ret = QVariant( v );
+ }
break;
case DBUS_TYPE_DOUBLE:
- ret = QVariant( dbus_message_iter_get_double(i) );
+ {
+ double v;
+ dbus_message_iter_get_basic (i, &v);
+ ret = QVariant( v );
+ }
break;
case DBUS_TYPE_STRING:
{
- char *str = dbus_message_iter_get_string(i);
- ret = QVariant( QString::fromLatin1(str) );
- dbus_free(str);
+ const char *v;
+ dbus_message_iter_get_basic (i, &v);
+ ret = QVariant( v );
}
break;
default:
@@ -224,14 +236,16 @@ Message::iterator::fillVar()
switch ( dbus_message_iter_get_array_type( d->iter ) ) {
case DBUS_TYPE_STRING: {
QStringList tempList;
- int count;
- char** charArray;
- dbus_message_iter_get_string_array( d->iter, &charArray, &count );
- for ( int i=0; i < count; i++ ) {
- tempList.append( QString( charArray[i] ) );
- }
+ DBusMessageIter sub;
+ dbus_message_iter_recurse (d->iter, &sub);
+ while (dbus_message_iter_get_arg_type (&sub) != DBUS_TYPE_INVALID)
+ {
+ const char *v;
+ dbus_message_iter_get_basic (&sub, &v);
+ tempList.append( QString( v ) );
+ dbus_message_iter_next (&sub);
+ }
d->var = QVariant( tempList );
- dbus_free( charArray );
break;
}
default:
@@ -241,6 +255,11 @@ Message::iterator::fillVar()
}
break;
}
+#if 0
+ /* DICT is gone for now, but expected to be reintroduced, or else
+ * reintroduced as a flag on the introspection data that can
+ * apply to array of struct of two fields
+ */
case DBUS_TYPE_DICT: {
qDebug( "Got a hash!" );
QMap<QString, QVariant> tempMap;
@@ -258,6 +277,7 @@ Message::iterator::fillVar()
d->var = QVariant();
break;
}
+#endif
default:
qDebug( "not implemented" );
d->var = QVariant();
@@ -485,49 +505,51 @@ Message::message() const
Message& Message::operator<<( bool b )
{
- dbus_message_append_args( d->msg, DBUS_TYPE_BOOLEAN, b,
+ const unsigned char byte = b;
+ dbus_message_append_args( d->msg, DBUS_TYPE_BOOLEAN, &byte,
DBUS_TYPE_INVALID );
}
Message& Message::operator<<( Q_INT8 byte )
{
- dbus_message_append_args( d->msg, DBUS_TYPE_BYTE, byte,
+ dbus_message_append_args( d->msg, DBUS_TYPE_BYTE, &byte,
DBUS_TYPE_INVALID );
}
Message& Message::operator<<( Q_INT32 num )
{
- dbus_message_append_args( d->msg, DBUS_TYPE_INT32, num,
+ dbus_message_append_args( d->msg, DBUS_TYPE_INT32, &num,
DBUS_TYPE_INVALID );
}
Message& Message::operator<<( Q_UINT32 num )
{
- dbus_message_append_args( d->msg, DBUS_TYPE_UINT32, num,
+ dbus_message_append_args( d->msg, DBUS_TYPE_UINT32, &num,
DBUS_TYPE_INVALID );
}
Message& Message::operator<<( Q_INT64 num )
{
- dbus_message_append_args( d->msg, DBUS_TYPE_INT64, num,
+ dbus_message_append_args( d->msg, DBUS_TYPE_INT64, &num,
DBUS_TYPE_INVALID );
}
Message& Message::operator<<( Q_UINT64 num )
{
- dbus_message_append_args( d->msg, DBUS_TYPE_UINT64, num,
+ dbus_message_append_args( d->msg, DBUS_TYPE_UINT64, &num,
DBUS_TYPE_INVALID );
}
Message& Message::operator<<( double num )
{
- dbus_message_append_args( d->msg, DBUS_TYPE_DOUBLE, num,
+ dbus_message_append_args( d->msg, DBUS_TYPE_DOUBLE, &num,
DBUS_TYPE_INVALID );
}
Message& Message::operator<<( const QString& str )
{
- dbus_message_append_args( d->msg, DBUS_TYPE_STRING, str.unicode(),
+ const char *u = str.utf8();
+ dbus_message_append_args( d->msg, DBUS_TYPE_STRING, &u,
DBUS_TYPE_INVALID );
}