diff options
author | Ted Gould <ted@gould.cx> | 2013-08-21 16:40:00 +0000 |
---|---|---|
committer | Tarmac <Unknown> | 2013-08-21 16:40:00 +0000 |
commit | ff533d23778b9799765bfed600b676dc30a934db (patch) | |
tree | 4df30a7d77913e5a432fe7c1023c58cb4effc229 | |
parent | 933deb6d32c36e8bf6db23d5673982cab788337a (diff) | |
parent | f96b5cf389899d0cc4b7f389d8dd8ec3e9e89489 (diff) | |
download | ayatana-indicator-messages-ff533d23778b9799765bfed600b676dc30a934db.tar.gz ayatana-indicator-messages-ff533d23778b9799765bfed600b676dc30a934db.tar.bz2 ayatana-indicator-messages-ff533d23778b9799765bfed600b676dc30a934db.zip |
Add a DBus error for list_add().
Approved by Charles Kerr, PS Jenkins bot.
-rw-r--r-- | src/im-application-list.c | 8 | ||||
-rw-r--r-- | src/im-application-list.h | 2 | ||||
-rw-r--r-- | src/messages-service.c | 14 |
3 files changed, 19 insertions, 5 deletions
diff --git a/src/im-application-list.c b/src/im-application-list.c index b599b85..684a2e4 100644 --- a/src/im-application-list.c +++ b/src/im-application-list.c @@ -656,7 +656,7 @@ im_application_list_activate_app_action (GSimpleAction *action, indicator_desktop_shortcuts_nick_exec_with_context (app->shortcuts, g_action_get_name (G_ACTION (action)), NULL); } -void +gboolean im_application_list_add (ImApplicationList *list, const gchar *desktop_id) { @@ -671,13 +671,13 @@ im_application_list_add (ImApplicationList *list, g_return_if_fail (desktop_id != NULL); if (im_application_list_lookup (list, desktop_id)) - return; + return TRUE; info = g_desktop_app_info_new (desktop_id); if (!info) { g_warning ("an application with id '%s' is not installed", desktop_id); - return; + return FALSE; } id = g_app_info_get_id (G_APP_INFO (info)); @@ -733,6 +733,8 @@ im_application_list_add (ImApplicationList *list, g_object_unref (launch_action); g_object_unref (actions); + + return TRUE; } void diff --git a/src/im-application-list.h b/src/im-application-list.h index f1de220..65e3326 100644 --- a/src/im-application-list.h +++ b/src/im-application-list.h @@ -36,7 +36,7 @@ GType im_application_list_get_type (void); ImApplicationList * im_application_list_new (void); -void im_application_list_add (ImApplicationList *list, +gboolean im_application_list_add (ImApplicationList *list, const gchar *desktop_id); void im_application_list_remove (ImApplicationList *list, diff --git a/src/messages-service.c b/src/messages-service.c index 0eec2ad..a8deb6a 100644 --- a/src/messages-service.c +++ b/src/messages-service.c @@ -44,6 +44,12 @@ static IndicatorMessagesService *messages_service; static GHashTable *menus; static GSettings *settings; +enum { + DBUS_ERROR_BAD_DESKTOP_FILE, +}; + +G_DEFINE_QUARK(indicator_messages_dbus_error, dbus_error); + static void register_application (IndicatorMessagesService *service, GDBusMethodInvocation *invocation, @@ -54,7 +60,10 @@ register_application (IndicatorMessagesService *service, GDBusConnection *bus; const gchar *sender; - im_application_list_add (applications, desktop_id); + if (!im_application_list_add (applications, desktop_id)) { + g_dbus_method_invocation_return_error(invocation, dbus_error_quark(), DBUS_ERROR_BAD_DESKTOP_FILE, "Unable to find or parse desktop file for application '%s'", desktop_id); + return; + } bus = g_dbus_interface_skeleton_get_connection (G_DBUS_INTERFACE_SKELETON (service)); sender = g_dbus_method_invocation_get_sender (invocation); @@ -126,6 +135,9 @@ on_bus_acquired (GDBusConnection *bus, const gchar *profile; ImMenu *menu; + /* Register some errors */ + g_dbus_error_register_error (dbus_error_quark(), DBUS_ERROR_BAD_DESKTOP_FILE, "BadDesktopFile"); + g_dbus_connection_export_action_group (bus, INDICATOR_MESSAGES_DBUS_OBJECT, im_application_list_get_action_group (applications), &error); |