aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--libemail-engine/camel-sasl-xoauth2.c3
-rw-r--r--libemail-engine/e-mail-folder-utils.c15
-rw-r--r--libemail-engine/e-mail-utils.c45
-rw-r--r--libemail-engine/mail-folder-cache.c28
-rw-r--r--libemail-engine/mail-ops.c8
-rw-r--r--libemail-engine/mail-vfolder.c59
-rw-r--r--mail/em-folder-properties.c13
-rw-r--r--mail/em-utils.c4
-rw-r--r--mail/mail-autofilter.c8
-rw-r--r--mail/mail-send-recv.c9
-rw-r--r--modules/online-accounts/camel-sasl-xoauth.c9
11 files changed, 136 insertions, 65 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'",
diff --git a/mail/em-folder-properties.c b/mail/em-folder-properties.c
index bfbf17f245..526dc89068 100644
--- a/mail/em-folder-properties.c
+++ b/mail/em-folder-properties.c
@@ -196,7 +196,8 @@ emfp_get_folder_item (EConfig *ec,
MailFolderCache *folder_cache;
store = camel_folder_get_parent_store (context->folder);
- session = camel_service_get_session (CAMEL_SERVICE (store));
+ session = camel_service_ref_session (CAMEL_SERVICE (store));
+
folder_cache = e_mail_session_get_folder_cache (
E_MAIL_SESSION (session));
@@ -205,6 +206,8 @@ emfp_get_folder_item (EConfig *ec,
mail_folder_cache_get_folder_info_flags (
folder_cache, context->folder, &fi_flags) &&
(fi_flags & CAMEL_FOLDER_TYPE_MASK) != CAMEL_FOLDER_TYPE_INBOX;
+
+ g_object_unref (session);
}
class = G_OBJECT_GET_CLASS (context->folder);
@@ -493,7 +496,7 @@ em_folder_properties_show (CamelStore *store,
service = CAMEL_SERVICE (store);
uid = camel_service_get_uid (service);
- session = camel_service_get_session (service);
+ session = camel_service_ref_session (service);
/* Show the Edit Rule dialog for Search Folders, but not "Unmatched".
* "Unmatched" is a special Search Folder which can't be modified. */
@@ -507,7 +510,8 @@ em_folder_properties_show (CamelStore *store,
E_MAIL_SESSION (session),
folder_uri, alert_sink);
g_free (folder_uri);
- return;
+
+ goto exit;
}
}
@@ -530,4 +534,7 @@ em_folder_properties_show (CamelStore *store,
(GAsyncReadyCallback) emfp_dialog_got_folder, context);
g_object_unref (cancellable);
+
+exit:
+ g_object_unref (session);
}
diff --git a/mail/em-utils.c b/mail/em-utils.c
index b0dc4ba509..e215fa11e0 100644
--- a/mail/em-utils.c
+++ b/mail/em-utils.c
@@ -642,7 +642,7 @@ em_utils_print_messages_to_file (CamelFolder *folder,
return FALSE;
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));
parser = e_mail_parser_new (session);
@@ -651,6 +651,8 @@ em_utils_print_messages_to_file (CamelFolder *folder,
(GAsyncReadyCallback) do_print_msg_to_file,
NULL, g_strdup (filename));
+ g_object_unref (session);
+
return TRUE;
}
diff --git a/mail/mail-autofilter.c b/mail/mail-autofilter.c
index c7cefb3735..62d1f6ee92 100644
--- a/mail/mail-autofilter.c
+++ b/mail/mail-autofilter.c
@@ -422,7 +422,7 @@ mail_filter_rename_folder (CamelStore *store,
g_return_if_fail (old_folder_name != NULL);
g_return_if_fail (new_folder_name != NULL);
- session = camel_service_get_session (CAMEL_SERVICE (store));
+ session = camel_service_ref_session (CAMEL_SERVICE (store));
old_uri = e_mail_folder_uri_build (store, old_folder_name);
new_uri = e_mail_folder_uri_build (store, new_folder_name);
@@ -447,6 +447,8 @@ mail_filter_rename_folder (CamelStore *store,
g_free (old_uri);
g_free (new_uri);
+
+ g_object_unref (session);
}
void
@@ -465,7 +467,7 @@ mail_filter_delete_folder (CamelStore *store,
g_return_if_fail (folder_name != NULL);
g_return_if_fail (E_IS_ALERT_SINK (alert_sink));
- session = camel_service_get_session (CAMEL_SERVICE (store));
+ session = camel_service_ref_session (CAMEL_SERVICE (store));
uri = e_mail_folder_uri_build (store, folder_name);
@@ -525,4 +527,6 @@ mail_filter_delete_folder (CamelStore *store,
g_free (user);
g_object_unref (fc);
g_free (uri);
+
+ g_object_unref (session);
}
diff --git a/mail/mail-send-recv.c b/mail/mail-send-recv.c
index da0a1486b4..bde01abd22 100644
--- a/mail/mail-send-recv.c
+++ b/mail/mail-send-recv.c
@@ -1307,18 +1307,18 @@ mail_receive_service (CamelService *service)
g_return_if_fail (CAMEL_IS_SERVICE (service));
uid = camel_service_get_uid (service);
- session = camel_service_get_session (service);
+ session = camel_service_ref_session (service);
data = setup_send_data (E_MAIL_SESSION (session));
info = g_hash_table_lookup (data->active, uid);
if (info != NULL)
- return;
+ goto exit;
type = get_receive_type (service);
if (type == SEND_INVALID || type == SEND_SEND)
- return;
+ goto exit;
info = g_malloc0 (sizeof (*info));
info->type = type;
@@ -1374,6 +1374,9 @@ mail_receive_service (CamelService *service)
default:
g_return_if_reached ();
}
+
+exit:
+ g_object_unref (session);
}
void
diff --git a/modules/online-accounts/camel-sasl-xoauth.c b/modules/online-accounts/camel-sasl-xoauth.c
index 45ad212475..1ebe99c439 100644
--- a/modules/online-accounts/camel-sasl-xoauth.c
+++ b/modules/online-accounts/camel-sasl-xoauth.c
@@ -278,12 +278,12 @@ sasl_xoauth_challenge_sync (CamelSasl *sasl,
gboolean success;
service = camel_sasl_get_service (sasl);
- session = camel_service_get_session (service);
+ session = camel_service_ref_session (service);
registry = e_mail_session_get_registry (E_MAIL_SESSION (session));
goa_client = goa_client_new_sync (cancellable, error);
if (goa_client == NULL)
- return NULL;
+ goto exit;
uid = camel_service_get_uid (service);
account_id = sasl_xoauth_find_account_id (registry, uid);
@@ -299,7 +299,7 @@ sasl_xoauth_challenge_sync (CamelSasl *sasl,
"the org.gnome.OnlineAccounts service from "
"which to obtain an authentication token."));
g_object_unref (goa_client);
- return NULL;
+ goto exit;
}
goa_account = goa_object_get_account (goa_object);
@@ -364,6 +364,9 @@ sasl_xoauth_challenge_sync (CamelSasl *sasl,
/* IMAP and SMTP services will Base64-encode the request. */
+exit:
+ g_object_unref (session);
+
return byte_array;
}