summaryrefslogtreecommitdiff
path: root/gdbus
diff options
context:
space:
mode:
authorMarcel Holtmann <marcel@holtmann.org>2012-12-18 04:09:59 (GMT)
committerMarcel Holtmann <marcel@holtmann.org>2012-12-19 02:49:11 (GMT)
commit95ffb025769ef1d9f1e8df39870b412b9aac68fe (patch)
tree2bc8ce67836559804837816d2c9ad3b48b3b5edb /gdbus
parent02b2ca520d2a707901c65de056a2fde0117b07c6 (diff)
downloadconnman-95ffb025769ef1d9f1e8df39870b412b9aac68fe.zip
connman-95ffb025769ef1d9f1e8df39870b412b9aac68fe.tar.gz
connman-95ffb025769ef1d9f1e8df39870b412b9aac68fe.tar.bz2
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 5f1209f..0e5c012 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 7cbd612..776d35e 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)
{