diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/im-application-list.c | 28 | ||||
-rw-r--r-- | src/im-application-list.h | 2 | ||||
-rw-r--r-- | src/messages-service.c | 7 |
3 files changed, 15 insertions, 22 deletions
diff --git a/src/im-application-list.c b/src/im-application-list.c index 6da2950..3221413 100644 --- a/src/im-application-list.c +++ b/src/im-application-list.c @@ -205,7 +205,7 @@ im_application_list_new (void) return g_object_new (IM_TYPE_APPLICATION_LIST, NULL); } -gboolean +void im_application_list_add (ImApplicationList *list, const gchar *desktop_id) { @@ -213,20 +213,18 @@ im_application_list_add (ImApplicationList *list, Application *app; const gchar *id; - g_return_val_if_fail (IM_IS_APPLICATION_LIST (list), FALSE); - g_return_val_if_fail (desktop_id != NULL, FALSE); + g_return_if_fail (IM_IS_APPLICATION_LIST (list)); + g_return_if_fail (desktop_id != NULL); - if (g_hash_table_contains (list->applications, desktop_id)) - { - g_warning ("an application with id '%s' already exists", desktop_id); - return FALSE; - } + app = g_hash_table_lookup (list->applications, desktop_id); + if (app) + return; info = g_desktop_app_info_new (desktop_id); if (!info) { - g_warning ("application with id '%s' already exists", desktop_id); - return FALSE; + g_warning ("an application with id '%s' is no installed", desktop_id); + return; } id = g_app_info_get_id (G_APP_INFO (info)); @@ -238,8 +236,6 @@ im_application_list_add (ImApplicationList *list, g_hash_table_insert (list->applications, (gpointer) id, app); g_action_muxer_insert (list->muxer, id, G_ACTION_GROUP (app->actions)); - - return TRUE; } void @@ -483,9 +479,11 @@ im_application_list_set_remote (ImApplicationList *list, if (app->proxy || app->cancellable) { - g_warning ("application '%s' is already running on '%s'", - id, g_dbus_proxy_get_name_owner (G_DBUS_PROXY (app->proxy))); - return; + g_warning ("replacing '%s' at %s with %s", id, unique_bus_name, + g_dbus_proxy_get_name_owner (G_DBUS_PROXY (app->proxy))); + g_cancellable_cancel (app->cancellable); + g_object_unref (app->cancellable); + g_clear_object (&app->proxy); } app->cancellable = g_cancellable_new (); diff --git a/src/im-application-list.h b/src/im-application-list.h index 3bf21c9..ecba312 100644 --- a/src/im-application-list.h +++ b/src/im-application-list.h @@ -35,7 +35,7 @@ GType im_application_list_get_type (void); ImApplicationList * im_application_list_new (void); -gboolean im_application_list_add (ImApplicationList *list, +void 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 18f3d0a..b3731a8 100644 --- a/src/messages-service.c +++ b/src/messages-service.c @@ -119,12 +119,7 @@ register_application (IndicatorMessagesService *service, GDBusConnection *bus; const gchar *sender; - if (!im_application_list_add (applications, desktop_id)) { - g_dbus_method_invocation_return_dbus_error (invocation, - "com.canonical.indicator.messages.RegistrationFailed", - "registration failed"); - return; - } + im_application_list_add (applications, desktop_id); bus = g_dbus_interface_skeleton_get_connection (G_DBUS_INTERFACE_SKELETON (service)); sender = g_dbus_method_invocation_get_sender (invocation); |