summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarcel Holtmann <marcel@holtmann.org>2008-05-27 18:02:23 +0000
committerMarcel Holtmann <marcel@holtmann.org>2008-05-27 18:02:23 +0000
commit80d6914d167a731d97aff4e25497f84e96e09fe3 (patch)
tree7ae80fd6544c752707bae42d3cfa31b7a0a0234c
parent671e8bc7340909da8b0fe750176423113e9ea8c1 (diff)
Add helpers for sending async replies
-rw-r--r--gdbus/gdbus.h6
-rw-r--r--gdbus/object.c43
2 files changed, 49 insertions, 0 deletions
diff --git a/gdbus/gdbus.h b/gdbus/gdbus.h
index dc337954..6f3ddb79 100644
--- a/gdbus/gdbus.h
+++ b/gdbus/gdbus.h
@@ -179,6 +179,12 @@ DBusMessage *g_dbus_create_reply(DBusMessage *message, int type, ...);
DBusMessage *g_dbus_create_reply_valist(DBusMessage *message,
int type, va_list args);
+gboolean g_dbus_send_message(DBusConnection *connection, DBusMessage *message);
+gboolean g_dbus_send_reply(DBusConnection *connection,
+ DBusMessage *message, int type, ...);
+gboolean g_dbus_send_reply_valist(DBusConnection *connection,
+ DBusMessage *message, int type, va_list args);
+
typedef void (*name_cb_t)(const char *name, void *user_data);
guint name_listener_add(DBusConnection *connection, const char *name,
diff --git a/gdbus/object.c b/gdbus/object.c
index 56ff4433..dd3d8609 100644
--- a/gdbus/object.c
+++ b/gdbus/object.c
@@ -910,3 +910,46 @@ DBusMessage *g_dbus_create_reply(DBusMessage *message, int type, ...)
return reply;
}
+
+gboolean g_dbus_send_message(DBusConnection *connection, DBusMessage *message)
+{
+ dbus_bool_t result;
+
+ result = dbus_connection_send(connection, message, NULL);
+
+ dbus_message_unref(message);
+
+ return result;
+}
+
+gboolean g_dbus_send_reply_valist(DBusConnection *connection,
+ DBusMessage *message, int type, va_list args)
+{
+ DBusMessage *reply;
+
+ reply = dbus_message_new_method_return(message);
+ if (reply == NULL)
+ return FALSE;
+
+ if (dbus_message_append_args_valist(reply, type, args) == FALSE) {
+ dbus_message_unref(reply);
+ return FALSE;
+ }
+
+ return g_dbus_send_message(connection, reply);
+}
+
+gboolean g_dbus_send_reply(DBusConnection *connection,
+ DBusMessage *message, int type, ...)
+{
+ va_list args;
+ gboolean result;
+
+ va_start(args, type);
+
+ result = g_dbus_send_reply_valist(connection, message, type, args);
+
+ va_end(args);
+
+ return result;
+}