From a91adf9c80b113702115a4ff23d503f7fbf2ecda Mon Sep 17 00:00:00 2001 From: Nikos Tsipinakis Date: Thu, 9 Apr 2020 20:02:16 +0200 Subject: [PATCH] Implement error handling in NotificationAction call --- src/dbus.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/dbus.c b/src/dbus.c index 6f288c6..e3427b8 100644 --- a/src/dbus.c +++ b/src/dbus.c @@ -103,7 +103,6 @@ struct dbus_method { GDBusMethodInvocation *invocation); }; -// TODO: call it interface methods #define DBUS_METHOD(name) static void dbus_cb_##name( \ GDBusConnection *connection, \ const gchar *sender, \ @@ -216,8 +215,14 @@ static void dbus_cb_dunst_NotificationAction(GDBusConnection *connection, LOG_D("CMD: Calling action for notification %d", notification_nr); - if (notification_nr < 0 || queues_length_waiting() < notification_nr) - return; //FIXME return error + if (notification_nr < 0 || queues_length_waiting() < notification_nr) { + g_dbus_method_invocation_return_error(invocation, + G_DBUS_ERROR, + G_DBUS_ERROR_INVALID_ARGS, + "Couldn't activate action for notification in position %d, %d notifications currently open", + notification_nr, queues_length_waiting()); + return; + } const GList *list = g_list_nth_data(queues_get_displayed(), notification_nr); @@ -627,7 +632,6 @@ static void dbus_cb_bus_acquired(GDBusConnection *connection, const gchar *name, gpointer user_data) { - // TODO: deduplicate the code GError *err = NULL; if(!g_dbus_connection_register_object( connection,