summaryrefslogtreecommitdiff
path: root/gdbus
diff options
context:
space:
mode:
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)
{