summaryrefslogtreecommitdiff
path: root/gdbus
diff options
context:
space:
mode:
authorMarcel Holtmann <marcel@holtmann.org>2012-12-18 05:09:59 +0100
committerMarcel Holtmann <marcel@holtmann.org>2012-12-19 03:50:42 +0100
commite7ca33f9083e46405c30db595b309744e0a31edf (patch)
tree2e4e7c9182e8ba4cee0c223338bffc704db4510f /gdbus
parent5de077a604c4d4a6a8b042b87ea51fa0e4b21485 (diff)
gdbus: Add helper for sending async error replies
Diffstat (limited to 'gdbus')
-rw-r--r--gdbus/gdbus.h6
-rw-r--r--gdbus/object.c32
2 files changed, 38 insertions, 0 deletions
diff --git a/gdbus/gdbus.h b/gdbus/gdbus.h
index 5f1209f3..0e5c0126 100644
--- a/gdbus/gdbus.h
+++ b/gdbus/gdbus.h
@@ -222,6 +222,12 @@ 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_error(DBusConnection *connection, DBusMessage *message,
+ const char *name, const char *format, ...)
+ __attribute__((format(printf, 4, 5)));
+gboolean g_dbus_send_error_valist(DBusConnection *connection,
+ DBusMessage *message, const char *name,
+ const char *format, va_list args);
gboolean g_dbus_send_reply(DBusConnection *connection,
DBusMessage *message, int type, ...);
gboolean g_dbus_send_reply_valist(DBusConnection *connection,
diff --git a/gdbus/object.c b/gdbus/object.c
index 7cbd6121..776d35ee 100644
--- a/gdbus/object.c
+++ b/gdbus/object.c
@@ -1446,6 +1446,38 @@ gboolean g_dbus_send_message(DBusConnection *connection, DBusMessage *message)
return result;
}
+gboolean g_dbus_send_error_valist(DBusConnection *connection,
+ DBusMessage *message, const char *name,
+ const char *format, va_list args)
+{
+ DBusMessage *error;
+ char str[1024];
+
+ vsnprintf(str, sizeof(str), format, args);
+
+ error = dbus_message_new_error(message, name, str);
+ if (error == NULL)
+ return FALSE;
+
+ return g_dbus_send_message(connection, error);
+}
+
+gboolean g_dbus_send_error(DBusConnection *connection, DBusMessage *message,
+ const char *name, const char *format, ...)
+{
+ va_list args;
+ gboolean result;
+
+ va_start(args, format);
+
+ result = g_dbus_send_error_valist(connection, message, name,
+ format, args);
+
+ va_end(args);
+
+ return result;
+}
+
gboolean g_dbus_send_reply_valist(DBusConnection *connection,
DBusMessage *message, int type, va_list args)
{