[evolution-data-server] Correct runtime warnings from ubuntu-online-accounts module



commit 105448530b7b2be428495057d334a546742924db
Author: Milan Crha <mcrha redhat com>
Date:   Wed Sep 23 15:14:18 2015 +0200

    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 02a36c2..b12aece 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 ba3882e..51feee6 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;


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]