From: Robert McQueen Date: Tue, 15 Nov 2005 19:34:33 +0000 (+0000) Subject: 2005-11-15 Robert McQueen X-Git-Tag: dbus-0.60~11 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=c33af17b934fcc8528b393ed2dca603e4940e6b3;p=thirdparty%2Fdbus.git 2005-11-15 Robert McQueen * dbus/dbus-glib-lowlevel.h, glib/dbus-gobject.c: Patch from Rob Taylor to add two methods, dbus_g_method_return_get_reply and dbus_g_method_return_send_reply, to allow you to get the reply message from a DBusGMethodInvocation, append arbitrary stuff to it, and send it. The GLib bindings can't marshal a return value of something like a(s) if the array is empty - ultimately they should be made to heed the signature of the out arguments as the Python bindings now can, but this is a workable interim solution which might have other applications. --- diff --git a/ChangeLog b/ChangeLog index 39e678337..c63f80a2b 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,15 @@ +2005-11-15 Robert McQueen + + * dbus/dbus-glib-lowlevel.h, glib/dbus-gobject.c: Patch from Rob + Taylor to add two methods, dbus_g_method_return_get_reply and + dbus_g_method_return_send_reply, to allow you to get the reply + message from a DBusGMethodInvocation, append arbitrary stuff to it, + and send it. The GLib bindings can't marshal a return value of + something like a(s) if the array is empty - ultimately they should be + made to heed the signature of the out arguments as the Python bindings + now can, but this is a workable interim solution which might have + other applications. + 2005-11-15 Robert McQueen * bus/driver.c, bus/services.c, bus/services.h: Add a ReleaseName diff --git a/dbus/dbus-glib-lowlevel.h b/dbus/dbus-glib-lowlevel.h index 941321513..9f6fc84e2 100644 --- a/dbus/dbus-glib-lowlevel.h +++ b/dbus/dbus-glib-lowlevel.h @@ -57,6 +57,10 @@ DBusMessage* dbus_g_message_get_message (DBusGMessage *gmessage); * g-functions anyhow) */ +DBusMessage * dbus_g_method_return_get_reply (DBusGMethodInvocation *context); + +void dbus_g_method_return_send_reply (DBusGMethodInvocation *context, DBusMessage *reply); + G_END_DECLS #endif /* DBUS_GLIB_LOWLEVEL_H */ diff --git a/glib/dbus-gobject.c b/glib/dbus-gobject.c index 66bd60d9b..1abe2581d 100644 --- a/glib/dbus-gobject.c +++ b/glib/dbus-gobject.c @@ -1858,6 +1858,40 @@ dbus_g_object_register_marshaller_array (GClosureMarshal marshaller, g_static_rw_lock_writer_unlock (&globals_lock); } + +/** + * Get the reply message to append reply values + * Used as a sidedoor when you can't generate dbus values + * of the correct type due to glib binding limitations + * + * @param context the method context + */ +DBusMessage * +dbus_g_method_return_get_reply (DBusGMethodInvocation *context) +{ + return dbus_message_new_method_return (dbus_g_message_get_message (context->message)); +} + +/** + * Send a manually created reply message + * Used as a sidedoor when you can't generate dbus values + * of the correct type due to glib binding limitations + * + * @param context the method context + * @param reply the reply message, will be unreffed + */ +void +dbus_g_method_return_send_reply (DBusGMethodInvocation *context, DBusMessage *reply) +{ + dbus_connection_send (dbus_g_connection_get_connection (context->connection), reply, NULL); + dbus_message_unref (reply); + + dbus_g_connection_unref (context->connection); + dbus_g_message_unref (context->message); + g_free (context); +} + + /** * Send a return message for a given method invocation, with arguments. * This function also frees the sending context.