From f1081b2e9c3b67029f7c058940a91f3ec01a937b Mon Sep 17 00:00:00 2001 From: Milan Crha Date: Wed, 23 Sep 2015 15:14:18 +0200 Subject: Correct runtime warnings from ubuntu-online-accounts module --- .../e-signon-session-password.c | 2 -- .../module-ubuntu-online-accounts.c | 35 +++++++++++++++++++++- 2 files changed, 34 insertions(+), 3 deletions(-) diff --git a/modules/ubuntu-online-accounts/e-signon-session-password.c b/modules/ubuntu-online-accounts/e-signon-session-password.c index 02a36c278..b12aecef3 100644 --- a/modules/ubuntu-online-accounts/e-signon-session-password.c +++ b/modules/ubuntu-online-accounts/e-signon-session-password.c @@ -240,7 +240,6 @@ signon_session_password_process_cb (GObject *source_object, AsyncContext *async_context; GVariant *session_data; GVariant *secret; - GString *string = NULL; GError *error = NULL; simple = G_SIMPLE_ASYNC_RESULT (user_data); @@ -276,7 +275,6 @@ signon_session_password_process_cb (GObject *source_object, async_context->password = g_string_new (g_variant_get_string (secret, NULL)); - g_string_free (string, TRUE); g_variant_unref (secret); exit: diff --git a/modules/ubuntu-online-accounts/module-ubuntu-online-accounts.c b/modules/ubuntu-online-accounts/module-ubuntu-online-accounts.c index ba3882ea6..51feee640 100644 --- a/modules/ubuntu-online-accounts/module-ubuntu-online-accounts.c +++ b/modules/ubuntu-online-accounts/module-ubuntu-online-accounts.c @@ -150,7 +150,40 @@ ubuntu_online_accounts_ref_account_service (EUbuntuOnlineAccounts *extension, const gchar *extension_name; const gchar *service_type; - service_type = e_source_get_ag_service_type (source); + if (e_source_has_extension (source, E_SOURCE_EXTENSION_COLLECTION)) { + /* Asking for credentials on the main (collection) source, which + doesn't belong to any particular service, thus try to pick any + enabled service, expecting the same password/token being + used for all other services. */ + service_type = NULL; + account_services = g_object_get_data (G_OBJECT (source), "ag-account-services"); + g_warn_if_fail (account_services != NULL); + if (account_services) { + AgAccountService *ag_service; + + ag_service = g_hash_table_lookup (account_services, E_AG_SERVICE_TYPE_CALENDAR); + if (ag_service && ag_account_service_get_enabled (ag_service)) + service_type = E_AG_SERVICE_TYPE_CALENDAR; + + if (!service_type) { + ag_service = g_hash_table_lookup (account_services, E_AG_SERVICE_TYPE_CONTACTS); + if (ag_service && ag_account_service_get_enabled (ag_service)) + service_type = E_AG_SERVICE_TYPE_CONTACTS; + } + + if (!service_type) { + ag_service = g_hash_table_lookup (account_services, E_AG_SERVICE_TYPE_MAIL); + if (ag_service && ag_account_service_get_enabled (ag_service)) + service_type = E_AG_SERVICE_TYPE_MAIL; + } + + if (!service_type) + return NULL; + } + } else { + service_type = e_source_get_ag_service_type (source); + } + g_return_val_if_fail (service_type != NULL, NULL); extension_name = E_SOURCE_EXTENSION_UOA; -- cgit v1.2.1