From 98d66743a1a7792ce20b69ba7448857e9e2c2628 Mon Sep 17 00:00:00 2001 From: Evangelos Ribeiro Tzaras Date: Fri, 16 Apr 2021 19:12:27 +0200 Subject: [PATCH] application: Don't add a provider if one is already present If we initially invoked `gnome-calls -p sip` and later invoke `gnome-calls sip:user@host` we don't expect to have the default MM provider added. --- src/calls-application.c | 7 ++++--- src/calls-manager.c | 14 ++++++++++++++ src/calls-manager.h | 1 + 3 files changed, 19 insertions(+), 3 deletions(-) diff --git a/src/calls-application.c b/src/calls-application.c index cca8f0a..308a3df 100644 --- a/src/calls-application.c +++ b/src/calls-application.c @@ -104,9 +104,10 @@ handle_local_options (GApplication *application, "set-provider-name", g_variant_new_string (arg)); } else { - g_action_group_activate_action (G_ACTION_GROUP (application), - "set-provider-name", - g_variant_new_string (DEFAULT_PROVIDER_PLUGIN)); + if (!calls_manager_has_any_provider (calls_manager_get_default ())) + g_action_group_activate_action (G_ACTION_GROUP (application), + "set-provider-name", + g_variant_new_string (DEFAULT_PROVIDER_PLUGIN)); } ok = g_variant_dict_contains (options, "daemon"); diff --git a/src/calls-manager.c b/src/calls-manager.c index c5f4dea..84dbfb8 100644 --- a/src/calls-manager.c +++ b/src/calls-manager.c @@ -853,3 +853,17 @@ calls_manager_get_suitable_origins (CallsManager *self, return NULL; } + +/** + * calls_manager_has_any_provider: + * @self: The #CallsManager + * + * Returns: %TRUE if any provider is loaded, %FALSE otherwise + */ +gboolean +calls_manager_has_any_provider (CallsManager *self) +{ + g_return_val_if_fail (CALLS_IS_MANAGER (self), FALSE); + + return !!g_hash_table_size (self->providers); +} diff --git a/src/calls-manager.h b/src/calls-manager.h index a813fb6..fdb0181 100644 --- a/src/calls-manager.h +++ b/src/calls-manager.h @@ -66,5 +66,6 @@ GListModel *calls_manager_get_suitable_origins (CallsManager const gchar *calls_manager_get_contact_name (CallsCall *call); gboolean calls_manager_has_active_call (CallsManager *self); void calls_manager_hang_up_all_calls (CallsManager *self); +gboolean calls_manager_has_any_provider (CallsManager *self); G_END_DECLS