dbus/qt message.cpp,1.9,1.10
Havoc Pennington
hp@freedesktop.org
Fri Jan 14 23:15:40 PST 2005
- Previous message: dbus HACKING,1.8,1.9
- Next message: dbus/glib dbus-gobject.c, 1.10, 1.11 dbus-gproxy.c, 1.12,
1.13 dbus-gutils.c, 1.6, 1.7 dbus-gvalue.c, 1.2, 1.3
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
Update of /cvs/dbus/dbus/qt
In directory gabe:/tmp/cvs-serv28195/qt
Modified Files:
message.cpp
Log Message:
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
Index: message.cpp
===================================================================
RCS file: /cvs/dbus/dbus/qt/message.cpp,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -d -r1.9 -r1.10
--- message.cpp 3 May 2004 17:08:00 -0000 1.9
+++ message.cpp 15 Jan 2005 07:15:38 -0000 1.10
@@ -185,19 +185,31 @@
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 @@
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 @@
}
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 @@
d->var = QVariant();
break;
}
+#endif
default:
qDebug( "not implemented" );
d->var = QVariant();
@@ -485,49 +505,51 @@
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 );
}
- Previous message: dbus HACKING,1.8,1.9
- Next message: dbus/glib dbus-gobject.c, 1.10, 1.11 dbus-gproxy.c, 1.12,
1.13 dbus-gutils.c, 1.6, 1.7 dbus-gvalue.c, 1.2, 1.3
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
More information about the dbus-commit
mailing list