diff options
author | Matthew Barnes <mbarnes@redhat.com> | 2013-02-11 23:38:29 +0800 |
---|---|---|
committer | Matthew Barnes <mbarnes@redhat.com> | 2013-02-11 23:38:29 +0800 |
commit | 3b11207dcbd01b5a18f93a406d267bb786829471 (patch) | |
tree | 0099cd20b25125d0473538126664f84526ca92ce /libemail-engine | |
parent | 60d1c3054aa60d02c763538d6b1f16d9d6ab6ade (diff) | |
download | gsoc2013-evolution-3b11207dcbd01b5a18f93a406d267bb786829471.tar.gz gsoc2013-evolution-3b11207dcbd01b5a18f93a406d267bb786829471.tar.zst gsoc2013-evolution-3b11207dcbd01b5a18f93a406d267bb786829471.zip |
Use camel_service_ref_session().
Diffstat (limited to 'libemail-engine')
-rw-r--r-- | libemail-engine/camel-sasl-xoauth2.c | 3 | ||||
-rw-r--r-- | libemail-engine/e-mail-folder-utils.c | 15 | ||||
-rw-r--r-- | libemail-engine/e-mail-utils.c | 45 | ||||
-rw-r--r-- | libemail-engine/mail-folder-cache.c | 28 | ||||
-rw-r--r-- | libemail-engine/mail-ops.c | 8 | ||||
-rw-r--r-- | libemail-engine/mail-vfolder.c | 59 |
6 files changed, 105 insertions, 53 deletions
diff --git a/libemail-engine/camel-sasl-xoauth2.c b/libemail-engine/camel-sasl-xoauth2.c index 3cf43e7393..32aad56bfb 100644 --- a/libemail-engine/camel-sasl-xoauth2.c +++ b/libemail-engine/camel-sasl-xoauth2.c @@ -80,7 +80,7 @@ sasl_xoauth2_challenge_sync (CamelSasl *sasl, gboolean success; service = camel_sasl_get_service (sasl); - session = camel_service_get_session (service); + session = camel_service_ref_session (service); settings = camel_service_ref_settings (service); uid = camel_service_get_uid (service); @@ -108,6 +108,7 @@ sasl_xoauth2_challenge_sync (CamelSasl *sasl, g_object_unref (source); g_object_unref (settings); + g_object_unref (session); /* IMAP and SMTP services will Base64-encode the request. */ diff --git a/libemail-engine/e-mail-folder-utils.c b/libemail-engine/e-mail-folder-utils.c index 5f9ea6a4e5..bd45f35702 100644 --- a/libemail-engine/e-mail-folder-utils.c +++ b/libemail-engine/e-mail-folder-utils.c @@ -223,13 +223,13 @@ mail_folder_expunge_pop3_stores (CamelFolder *folder, parent_store = camel_folder_get_parent_store (folder); service = CAMEL_SERVICE (parent_store); - session = camel_service_get_session (service); + session = camel_service_ref_session (service); registry = e_mail_session_get_registry (E_MAIL_SESSION (session)); uids = camel_folder_get_uids (folder); if (uids == NULL) - return TRUE; + goto exit; expunging_uids = g_hash_table_new_full ( (GHashFunc) g_str_hash, @@ -377,6 +377,9 @@ mail_folder_expunge_pop3_stores (CamelFolder *folder, g_hash_table_destroy (expunging_uids); +exit: + g_object_unref (session); + return success; } @@ -400,7 +403,7 @@ e_mail_folder_expunge_sync (CamelFolder *folder, parent_store = camel_folder_get_parent_store (folder); service = CAMEL_SERVICE (parent_store); - session = camel_service_get_session (service); + session = camel_service_ref_session (service); uid = camel_service_get_uid (service); store_is_local = (g_strcmp0 (uid, E_MAIL_SESSION_LOCAL_UID) == 0); @@ -420,7 +423,8 @@ e_mail_folder_expunge_sync (CamelFolder *folder, is_local_trash = (folder == local_trash); g_object_unref (local_trash); } else { - return FALSE; + success = FALSE; + goto exit; } } @@ -434,6 +438,9 @@ e_mail_folder_expunge_sync (CamelFolder *folder, success = camel_folder_expunge_sync ( folder, cancellable, error); +exit: + g_object_unref (session); + return success; } diff --git a/libemail-engine/e-mail-utils.c b/libemail-engine/e-mail-utils.c index 6614ecf67b..ba18f8a3b4 100644 --- a/libemail-engine/e-mail-utils.c +++ b/libemail-engine/e-mail-utils.c @@ -73,19 +73,20 @@ em_utils_folder_is_drafts (ESourceRegistry *registry, g_return_val_if_fail (CAMEL_IS_FOLDER (folder), FALSE); store = camel_folder_get_parent_store (folder); - session = camel_service_get_session (CAMEL_SERVICE (store)); + session = camel_service_ref_session (CAMEL_SERVICE (store)); local_drafts_folder = e_mail_session_get_local_folder ( E_MAIL_SESSION (session), E_MAIL_LOCAL_FOLDER_DRAFTS); - if (folder == local_drafts_folder) - return TRUE; + if (folder == local_drafts_folder) { + is_drafts = TRUE; + goto exit; + } folder_uri = e_mail_folder_uri_from_folder (folder); store = camel_folder_get_parent_store (folder); - session = camel_service_get_session (CAMEL_SERVICE (store)); extension_name = E_SOURCE_EXTENSION_MAIL_COMPOSITION; list = e_source_registry_list_sources (registry, extension_name); @@ -112,6 +113,9 @@ em_utils_folder_is_drafts (ESourceRegistry *registry, g_list_free_full (list, (GDestroyNotify) g_object_unref); g_free (folder_uri); +exit: + g_object_unref (session); + return is_drafts; } @@ -140,19 +144,20 @@ em_utils_folder_is_templates (ESourceRegistry *registry, g_return_val_if_fail (CAMEL_IS_FOLDER (folder), FALSE); store = camel_folder_get_parent_store (folder); - session = camel_service_get_session (CAMEL_SERVICE (store)); + session = camel_service_ref_session (CAMEL_SERVICE (store)); local_templates_folder = e_mail_session_get_local_folder ( E_MAIL_SESSION (session), E_MAIL_LOCAL_FOLDER_TEMPLATES); - if (folder == local_templates_folder) - return TRUE; + if (folder == local_templates_folder) { + is_templates = TRUE; + goto exit; + } folder_uri = e_mail_folder_uri_from_folder (folder); store = camel_folder_get_parent_store (folder); - session = camel_service_get_session (CAMEL_SERVICE (store)); extension_name = E_SOURCE_EXTENSION_MAIL_COMPOSITION; list = e_source_registry_list_sources (registry, extension_name); @@ -179,6 +184,9 @@ em_utils_folder_is_templates (ESourceRegistry *registry, g_list_free_full (list, (GDestroyNotify) g_object_unref); g_free (folder_uri); +exit: + g_object_unref (session); + return is_templates; } @@ -206,19 +214,20 @@ em_utils_folder_is_sent (ESourceRegistry *registry, g_return_val_if_fail (CAMEL_IS_FOLDER (folder), FALSE); store = camel_folder_get_parent_store (folder); - session = camel_service_get_session (CAMEL_SERVICE (store)); + session = camel_service_ref_session (CAMEL_SERVICE (store)); local_sent_folder = e_mail_session_get_local_folder ( E_MAIL_SESSION (session), E_MAIL_LOCAL_FOLDER_SENT); - if (folder == local_sent_folder) - return TRUE; + if (folder == local_sent_folder) { + is_sent = TRUE; + goto exit; + } folder_uri = e_mail_folder_uri_from_folder (folder); store = camel_folder_get_parent_store (folder); - session = camel_service_get_session (CAMEL_SERVICE (store)); extension_name = E_SOURCE_EXTENSION_MAIL_SUBMISSION; list = e_source_registry_list_sources (registry, extension_name); @@ -245,6 +254,9 @@ em_utils_folder_is_sent (ESourceRegistry *registry, g_list_free_full (list, (GDestroyNotify) g_object_unref); g_free (folder_uri); +exit: + g_object_unref (session); + return is_sent; } @@ -264,17 +276,22 @@ em_utils_folder_is_outbox (ESourceRegistry *registry, CamelStore *store; CamelSession *session; CamelFolder *local_outbox_folder; + gboolean is_outbox; g_return_val_if_fail (CAMEL_IS_FOLDER (folder), FALSE); store = camel_folder_get_parent_store (folder); - session = camel_service_get_session (CAMEL_SERVICE (store)); + session = camel_service_ref_session (CAMEL_SERVICE (store)); local_outbox_folder = e_mail_session_get_local_folder ( E_MAIL_SESSION (session), E_MAIL_LOCAL_FOLDER_OUTBOX); - return (folder == local_outbox_folder); + is_outbox = (folder == local_outbox_folder); + + g_object_unref (session); + + return is_outbox; } /* ********************************************************************** */ diff --git a/libemail-engine/mail-folder-cache.c b/libemail-engine/mail-folder-cache.c index ad8a5b1764..2f99e84c57 100644 --- a/libemail-engine/mail-folder-cache.c +++ b/libemail-engine/mail-folder-cache.c @@ -432,7 +432,7 @@ folder_changed_cb (CamelFolder *folder, full_name = camel_folder_get_full_name (folder); parent_store = camel_folder_get_parent_store (folder); - session = camel_service_get_session (CAMEL_SERVICE (parent_store)); + session = camel_service_ref_session (CAMEL_SERVICE (parent_store)); if (!last_newmail_per_folder) last_newmail_per_folder = g_hash_table_new (g_direct_hash, g_direct_equal); @@ -504,6 +504,8 @@ folder_changed_cb (CamelFolder *folder, g_free (uid); g_free (sender); g_free (subject); + + g_object_unref (session); } static void @@ -1032,15 +1034,19 @@ storeinfo_find_folder_info (CamelStore *store, StoreInfo *si, struct _find_info *fi) { + CamelSession *session; gchar *folder_name; gboolean success; if (fi->fi != NULL) return; + session = camel_service_ref_session (CAMEL_SERVICE (store)); + success = e_mail_folder_uri_parse ( - camel_service_get_session (CAMEL_SERVICE (store)), - fi->folder_uri, NULL, &folder_name, NULL); + session, fi->folder_uri, NULL, &folder_name, NULL); + + g_object_unref (session); if (success) { fi->fi = g_hash_table_lookup (si->folders, folder_name); @@ -1170,7 +1176,7 @@ mail_folder_cache_folder_available (MailFolderCache *cache, return; service = CAMEL_SERVICE (store); - session = camel_service_get_session (service); + session = camel_service_ref_session (service); provider = camel_service_get_provider (service); /* Reuse the stores mutex just because it's handy. */ @@ -1189,6 +1195,8 @@ mail_folder_cache_folder_available (MailFolderCache *cache, g_free (folder_uri); g_rec_mutex_unlock (&cache->priv->stores_mutex); + + g_object_unref (session); } static void @@ -1218,7 +1226,7 @@ mail_folder_cache_folder_unavailable (MailFolderCache *cache, return; service = CAMEL_SERVICE (store); - session = camel_service_get_session (service); + session = camel_service_ref_session (service); provider = camel_service_get_provider (service); /* Reuse the stores mutex just because it's handy. */ @@ -1240,6 +1248,8 @@ mail_folder_cache_folder_unavailable (MailFolderCache *cache, g_free (folder_uri); g_rec_mutex_unlock (&cache->priv->stores_mutex); + + g_object_unref (session); } static void @@ -1268,7 +1278,7 @@ mail_folder_cache_folder_deleted (MailFolderCache *cache, return; service = CAMEL_SERVICE (store); - session = camel_service_get_session (service); + session = camel_service_ref_session (service); /* Reuse the stores mutex just because it's handy. */ g_rec_mutex_lock (&cache->priv->stores_mutex); @@ -1292,6 +1302,8 @@ mail_folder_cache_folder_deleted (MailFolderCache *cache, g_free (folder_uri); g_rec_mutex_unlock (&cache->priv->stores_mutex); + + g_object_unref (session); } static void @@ -1507,7 +1519,7 @@ mail_folder_cache_note_store (MailFolderCache *cache, g_return_if_fail (MAIL_IS_FOLDER_CACHE (cache)); g_return_if_fail (CAMEL_IS_STORE (store)); - session = camel_service_get_session (CAMEL_SERVICE (store)); + session = camel_service_ref_session (CAMEL_SERVICE (store)); g_rec_mutex_lock (&cache->priv->stores_mutex); @@ -1590,6 +1602,8 @@ mail_folder_cache_note_store (MailFolderCache *cache, store, "folder-unsubscribed", G_CALLBACK (store_folder_unsubscribed_cb), cache); } + + g_object_unref (session); } /** diff --git a/libemail-engine/mail-ops.c b/libemail-engine/mail-ops.c index a01dc50301..2084aa1e01 100644 --- a/libemail-engine/mail-ops.c +++ b/libemail-engine/mail-ops.c @@ -257,7 +257,7 @@ fetch_mail_exec (struct _fetch_mail_msg *m, gint i; service = CAMEL_SERVICE (m->store); - session = camel_service_get_session (service); + session = camel_service_ref_session (service); fm->destination = e_mail_session_get_local_folder ( E_MAIL_SESSION (session), E_MAIL_LOCAL_FOLDER_LOCAL_INBOX); @@ -436,6 +436,8 @@ exit: if (!is_local_delivery) camel_service_disconnect_sync ( service, TRUE, cancellable, NULL); + + g_object_unref (session); } static void @@ -489,7 +491,7 @@ mail_fetch_mail (CamelStore *store, g_return_if_fail (CAMEL_IS_STORE (store)); - session = camel_service_get_session (CAMEL_SERVICE (store)); + session = camel_service_ref_session (CAMEL_SERVICE (store)); m = mail_msg_new (&fetch_mail_info); fm = (struct _filter_mail_msg *) m; @@ -515,6 +517,8 @@ mail_fetch_mail (CamelStore *store, camel_filter_driver_set_status_func (fm->driver, status, status_data); mail_msg_unordered_push (m); + + g_object_unref (session); } /* ********************************************************************** */ diff --git a/libemail-engine/mail-vfolder.c b/libemail-engine/mail-vfolder.c index b23ce0cf2e..fbddfd8110 100644 --- a/libemail-engine/mail-vfolder.c +++ b/libemail-engine/mail-vfolder.c @@ -202,7 +202,7 @@ static MailMsgInfo vfolder_setup_info = { /* sources_uri should be camel uri's */ static gint -vfolder_setup (EMailSession *session, +vfolder_setup (CamelSession *session, CamelFolder *folder, const gchar *query, GList *sources_uri) @@ -442,7 +442,6 @@ mail_vfolder_add_folder (CamelStore *store, g_return_if_fail (folder_name != NULL); service = CAMEL_SERVICE (store); - session = camel_service_get_session (service); provider = camel_service_get_provider (service); remote = (provider->flags & CAMEL_PROVIDER_IS_REMOTE) != 0; @@ -452,6 +451,7 @@ mail_vfolder_add_folder (CamelStore *store, g_return_if_fail (mail_in_main_thread ()); + session = camel_service_ref_session (service); uri = e_mail_folder_uri_build (store, folder_name); G_LOCK (vfolder); @@ -517,6 +517,7 @@ done: g_free (exuri); } + g_object_unref (session); g_free (uri); } @@ -562,8 +563,8 @@ mail_vfolder_delete_folder (CamelStore *store, g_return_if_fail (mail_in_main_thread ()); service = CAMEL_SERVICE (store); - session = camel_service_get_session (service); + session = camel_service_ref_session (service); uri = e_mail_folder_uri_build (store, folder_name); changed_count = 0; @@ -659,6 +660,7 @@ done: g_string_free (changed, TRUE); + g_object_unref (session); g_free (uri); } @@ -692,7 +694,7 @@ mail_vfolder_rename_folder (CamelStore *store, g_return_if_fail (mail_in_main_thread ()); service = CAMEL_SERVICE (store); - session = camel_service_get_session (service); + session = camel_service_ref_session (service); old_uri = e_mail_folder_uri_build (store, old_folder_name); new_uri = e_mail_folder_uri_build (store, new_folder_name); @@ -750,6 +752,8 @@ mail_vfolder_rename_folder (CamelStore *store, g_free (old_uri); g_free (new_uri); + + g_object_unref (session); } /* ********************************************************************** */ @@ -786,31 +790,25 @@ rule_add_sources (EMailSession *session, *sources_urip = sources_uri; } -static EMailSession * -get_session (CamelFolder *folder) -{ - CamelStore *store; - - store = camel_folder_get_parent_store (folder); - - return (EMailSession *) camel_service_get_session (CAMEL_SERVICE (store)); -} - static void rule_changed (EFilterRule *rule, CamelFolder *folder) { - EMailSession *session; + CamelStore *store; CamelService *service; + CamelSession *session; + MailFolderCache *cache; GList *sources_uri = NULL; GString *query; const gchar *full_name; full_name = camel_folder_get_full_name (folder); - session = get_session (folder); + store = camel_folder_get_parent_store (folder); + session = camel_service_ref_session (CAMEL_SERVICE (store)); + cache = e_mail_session_get_folder_cache (E_MAIL_SESSION (session)); service = camel_session_ref_service ( - CAMEL_SESSION (session), E_MAIL_SESSION_VFOLDER_UID); + session, E_MAIL_SESSION_VFOLDER_UID); g_return_if_fail (service != NULL); /* If the folder has changed name, then @@ -856,7 +854,8 @@ rule_changed (EFilterRule *rule, if (em_vfolder_rule_get_with ((EMVFolderRule *) rule) == EM_VFOLDER_RULE_WITH_SPECIFIC) { /* find any (currently available) folders, and add them to the ones to open */ rule_add_sources ( - session, em_vfolder_rule_get_sources ((EMVFolderRule *) rule), + E_MAIL_SESSION (session), + em_vfolder_rule_get_sources ((EMVFolderRule *) rule), &sources_uri, (EMVFolderRule *) rule); } @@ -865,13 +864,13 @@ rule_changed (EFilterRule *rule, if (em_vfolder_rule_get_with ((EMVFolderRule *) rule) == EM_VFOLDER_RULE_WITH_LOCAL || em_vfolder_rule_get_with ((EMVFolderRule *) rule) == EM_VFOLDER_RULE_WITH_LOCAL_REMOTE_ACTIVE) { - MailFolderCache *cache; GQueue queue = G_QUEUE_INIT; - cache = e_mail_session_get_folder_cache (session); mail_folder_cache_get_local_folder_uris (cache, &queue); - rule_add_sources (session, &queue, &sources_uri, NULL); + rule_add_sources ( + E_MAIL_SESSION (session), + &queue, &sources_uri, NULL); while (!g_queue_is_empty (&queue)) g_free (g_queue_pop_head (&queue)); @@ -880,13 +879,13 @@ rule_changed (EFilterRule *rule, if (em_vfolder_rule_get_with ((EMVFolderRule *) rule) == EM_VFOLDER_RULE_WITH_REMOTE_ACTIVE || em_vfolder_rule_get_with ((EMVFolderRule *) rule) == EM_VFOLDER_RULE_WITH_LOCAL_REMOTE_ACTIVE) { - MailFolderCache *cache; GQueue queue = G_QUEUE_INIT; - cache = e_mail_session_get_folder_cache (session); mail_folder_cache_get_remote_folder_uris (cache, &queue); - rule_add_sources (session, &queue, &sources_uri, NULL); + rule_add_sources ( + E_MAIL_SESSION (session), + &queue, &sources_uri, NULL); while (!g_queue_is_empty (&queue)) g_free (g_queue_pop_head (&queue)); @@ -900,6 +899,8 @@ rule_changed (EFilterRule *rule, vfolder_setup (session, folder, query->str, sources_uri); g_string_free (query, TRUE); + + g_object_unref (session); } static void @@ -987,8 +988,10 @@ store_folder_deleted_cb (CamelStore *store, /* delete it from our list */ rule = e_rule_context_find_rule ((ERuleContext *) context, info->full_name, NULL); if (rule) { + CamelSession *session; const gchar *config_dir; - EMailSession *session = E_MAIL_SESSION (camel_service_get_session (CAMEL_SERVICE (store))); + + session = camel_service_ref_session (CAMEL_SERVICE (store)); /* We need to stop listening to removed events, * otherwise we'll try and remove it again. */ @@ -997,6 +1000,10 @@ store_folder_deleted_cb (CamelStore *store, 0, 0, NULL, context_rule_removed, NULL); e_rule_context_remove_rule ((ERuleContext *) context, rule); g_object_unref (rule); + + /* FIXME This is dangerous. Either the signal closure + * needs to be referenced somehow, or ERuleContext + * needs to keep its own CamelSession reference. */ g_signal_connect ( context, "rule_removed", G_CALLBACK (context_rule_removed), session); @@ -1005,6 +1012,8 @@ store_folder_deleted_cb (CamelStore *store, user = g_build_filename (config_dir, "vfolders.xml", NULL); e_rule_context_save ((ERuleContext *) context, user); g_free (user); + + g_object_unref (session); } else { g_warning ( "Cannot find rule for deleted vfolder '%s'", |