aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--libemail-engine/e-mail-folder-utils.c18
-rw-r--r--libemail-engine/e-mail-session-utils.c21
-rw-r--r--libemail-engine/e-mail-session.c84
-rw-r--r--libemail-engine/mail-ops.c6
-rw-r--r--libemail-engine/mail-vfolder.c19
-rw-r--r--mail/e-mail-account-store.c6
-rw-r--r--mail/e-mail-backend.c38
-rw-r--r--mail/e-mail-config-auth-check.c3
-rw-r--r--mail/e-mail-config-defaults-page.c28
-rw-r--r--mail/em-filter-source-element.c4
-rw-r--r--mail/em-folder-tree.c25
-rw-r--r--mail/em-subscription-editor.c5
-rw-r--r--mail/em-utils.c2
-rw-r--r--mail/mail-send-recv.c24
-rw-r--r--modules/mail/e-mail-shell-backend.c15
-rw-r--r--modules/mail/e-mail-shell-view-actions.c2
-rw-r--r--modules/mail/e-mail-shell-view.c14
-rw-r--r--shell/e-convert-local-mail.c14
18 files changed, 220 insertions, 108 deletions
diff --git a/libemail-engine/e-mail-folder-utils.c b/libemail-engine/e-mail-folder-utils.c
index 07613ec252..78e5434ed9 100644
--- a/libemail-engine/e-mail-folder-utils.c
+++ b/libemail-engine/e-mail-folder-utils.c
@@ -309,7 +309,7 @@ mail_folder_expunge_pop3_stores (CamelFolder *folder,
if (!enabled || g_strcmp0 (backend_name, "pop") != 0)
continue;
- service = camel_session_get_service (
+ service = camel_session_ref_service (
CAMEL_SESSION (session), source_uid);
service_uid = camel_service_get_uid (service);
@@ -321,14 +321,17 @@ mail_folder_expunge_pop3_stores (CamelFolder *folder,
"keep-on-server", &keep_on_server,
NULL);
- if (!keep_on_server || !delete_expunged)
+ if (!keep_on_server || !delete_expunged) {
+ g_object_unref (service);
continue;
+ }
folder = camel_store_get_inbox_folder_sync (
CAMEL_STORE (service), cancellable, error);
/* Abort the loop on error. */
if (folder == NULL) {
+ g_object_unref (service);
success = FALSE;
break;
}
@@ -336,6 +339,7 @@ mail_folder_expunge_pop3_stores (CamelFolder *folder,
uids = camel_folder_get_uids (folder);
if (uids == NULL) {
+ g_object_unref (service);
g_object_unref (folder);
continue;
}
@@ -359,6 +363,7 @@ mail_folder_expunge_pop3_stores (CamelFolder *folder,
folder, TRUE, cancellable, error);
g_object_unref (folder);
+ g_object_unref (service);
/* Abort the loop on error. */
if (!success)
@@ -1801,7 +1806,7 @@ e_mail_folder_uri_parse (CamelSession *session,
uid = g_strconcat (
url->user, "@", url->host, NULL);
- service = camel_session_get_service (session, uid);
+ service = camel_session_ref_service (session, uid);
g_free (uid);
}
@@ -1845,7 +1850,7 @@ e_mail_folder_uri_parse (CamelSession *session,
}
if (uid != NULL) {
- service = camel_session_get_service (session, uid);
+ service = camel_session_ref_service (session, uid);
g_free (uid);
}
@@ -1858,7 +1863,7 @@ e_mail_folder_uri_parse (CamelSession *session,
* To determine which it is, you have to check the provider
* flags for CAMEL_URL_FRAGMENT_IS_PATH. */
} else {
- service = camel_session_get_service_by_url (
+ service = camel_session_ref_service_by_url (
session, url, CAMEL_PROVIDER_STORE);
if (CAMEL_IS_STORE (service)) {
@@ -1891,6 +1896,9 @@ e_mail_folder_uri_parse (CamelSession *session,
folder_uri);
}
+ if (service != NULL)
+ g_object_unref (service);
+
g_free (folder_name);
camel_url_free (url);
diff --git a/libemail-engine/e-mail-session-utils.c b/libemail-engine/e-mail-session-utils.c
index 2ac4170a2e..0694ea60a5 100644
--- a/libemail-engine/e-mail-session-utils.c
+++ b/libemail-engine/e-mail-session-utils.c
@@ -410,15 +410,25 @@ mail_session_send_to_thread (GSimpleAsyncResult *simple,
CamelService *service;
gboolean did_connect = FALSE;
- service = camel_session_get_service (
+ service = camel_session_ref_service (
CAMEL_SESSION (session), context->transport_uid);
+ if (service == NULL) {
+ g_simple_async_result_set_error (
+ simple, CAMEL_SERVICE_ERROR,
+ CAMEL_SERVICE_ERROR_URL_INVALID,
+ _("No mail service found with UID '%s'"),
+ context->transport_uid);
+ return;
+ }
+
if (!CAMEL_IS_TRANSPORT (service)) {
- g_simple_async_result_set_error (simple,
- CAMEL_SERVICE_ERROR,
+ g_simple_async_result_set_error (
+ simple, CAMEL_SERVICE_ERROR,
CAMEL_SERVICE_ERROR_URL_INVALID,
- _("Cannot get transport for account '%s'"),
+ _("UID '%s' is not a mail transport"),
context->transport_uid);
+ g_object_unref (service);
return;
}
@@ -431,6 +441,7 @@ mail_session_send_to_thread (GSimpleAsyncResult *simple,
if (error != NULL) {
g_simple_async_result_take_error (simple, error);
+ g_object_unref (service);
return;
}
}
@@ -450,6 +461,8 @@ mail_session_send_to_thread (GSimpleAsyncResult *simple,
service, error == NULL,
cancellable, error ? NULL : &error);
+ g_object_unref (service);
+
if (error != NULL) {
g_simple_async_result_take_error (simple, error);
return;
diff --git a/libemail-engine/e-mail-session.c b/libemail-engine/e-mail-session.c
index 2bd9e345e9..c7853f9b56 100644
--- a/libemail-engine/e-mail-session.c
+++ b/libemail-engine/e-mail-session.c
@@ -78,8 +78,8 @@ struct _EMailSessionPrivate {
gulong source_disabled_handler_id;
gulong default_mail_account_handler_id;
- CamelStore *local_store;
- CamelStore *vfolder_store;
+ CamelService *local_store;
+ CamelService *vfolder_store;
FILE *filter_logfile;
GHashTable *junk_filters;
@@ -445,10 +445,12 @@ mail_session_refresh_cb (ESource *source,
const gchar *uid;
uid = e_source_get_uid (source);
- service = camel_session_get_service (session, uid);
- g_return_if_fail (CAMEL_IS_SERVICE (service));
+ service = camel_session_ref_service (session, uid);
+ g_return_if_fail (service != NULL);
g_signal_emit (session, signals[REFRESH_SERVICE], 0, service);
+
+ g_object_unref (service);
}
static gboolean
@@ -478,6 +480,7 @@ mail_session_add_from_source (EMailSession *session,
ESource *source)
{
ESourceBackend *extension;
+ CamelService *service;
const gchar *uid;
const gchar *backend_name;
const gchar *display_name;
@@ -512,12 +515,15 @@ mail_session_add_from_source (EMailSession *session,
if (mail_session_check_goa_mail_disabled (session, source))
return;
- /* Our own CamelSession.add_service() method will handle the
- * resulting CamelService, so we don't need the return value. */
- camel_session_add_service (
+ service = camel_session_add_service (
CAMEL_SESSION (session), uid,
backend_name, type, &error);
+ /* Our own CamelSession.add_service() method will handle the
+ * new CamelService, so we only need to unreference it here. */
+ if (service != NULL)
+ g_object_unref (service);
+
if (error != NULL) {
g_warning (
"Failed to add service '%s' (%s): %s",
@@ -578,10 +584,12 @@ mail_session_source_removed_cb (ESourceRegistry *registry,
camel_session = CAMEL_SESSION (session);
uid = e_source_get_uid (source);
- service = camel_session_get_service (camel_session, uid);
+ service = camel_session_ref_service (camel_session, uid);
- if (CAMEL_IS_SERVICE (service))
+ if (service != NULL) {
camel_session_remove_service (camel_session, service);
+ g_object_unref (service);
+ }
}
static void
@@ -676,8 +684,9 @@ mail_session_configure_local_store (EMailSession *session)
camel_session = CAMEL_SESSION (session);
uid = E_MAIL_SESSION_LOCAL_UID;
- service = camel_session_get_service (camel_session, uid);
- g_return_if_fail (CAMEL_IS_SERVICE (service));
+ service = camel_session_ref_service (camel_session, uid);
+ session->priv->local_store = service; /* takes ownership */
+ g_return_if_fail (service != NULL);
settings = camel_service_get_settings (service);
local_settings = CAMEL_LOCAL_SETTINGS (settings);
@@ -721,8 +730,6 @@ mail_session_configure_local_store (EMailSession *session)
g_error_free (error);
}
}
-
- session->priv->local_store = g_object_ref (service);
}
static void
@@ -735,8 +742,9 @@ mail_session_configure_vfolder_store (EMailSession *session)
camel_session = CAMEL_SESSION (session);
uid = E_MAIL_SESSION_VFOLDER_UID;
- service = camel_session_get_service (camel_session, uid);
- g_return_if_fail (CAMEL_IS_SERVICE (service));
+ service = camel_session_ref_service (camel_session, uid);
+ session->priv->vfolder_store = service; /* takes ownership */
+ g_return_if_fail (service != NULL);
camel_service_connect_sync (service, NULL, NULL);
@@ -744,8 +752,6 @@ mail_session_configure_vfolder_store (EMailSession *session)
* but it requires an EMailBackend, which we don't have access
* to from here, so it has to be called from elsewhere. Kinda
* thinking about reworking that... */
-
- session->priv->vfolder_store = g_object_ref (service);
}
static void
@@ -1944,7 +1950,7 @@ e_mail_session_get_local_store (EMailSession *session)
{
g_return_val_if_fail (E_IS_MAIL_SESSION (session), NULL);
- return session->priv->local_store;
+ return CAMEL_STORE (session->priv->local_store);
}
CamelFolder *
@@ -2037,21 +2043,30 @@ e_mail_session_get_inbox_sync (EMailSession *session,
GError **error)
{
CamelService *service;
+ CamelFolder *folder = NULL;
g_return_val_if_fail (E_IS_MAIL_SESSION (session), NULL);
g_return_val_if_fail (service_uid != NULL, NULL);
- service = camel_session_get_service (
+ service = camel_session_ref_service (
CAMEL_SESSION (session), service_uid);
- if (!CAMEL_IS_STORE (service))
+ if (service == NULL)
return NULL;
+ if (!CAMEL_IS_STORE (service))
+ goto exit;
+
if (!camel_service_connect_sync (service, cancellable, error))
- return NULL;
+ goto exit;
- return camel_store_get_inbox_folder_sync (
+ folder = camel_store_get_inbox_folder_sync (
CAMEL_STORE (service), cancellable, error);
+
+exit:
+ g_object_unref (service);
+
+ return folder;
}
void
@@ -2136,21 +2151,30 @@ e_mail_session_get_trash_sync (EMailSession *session,
GError **error)
{
CamelService *service;
+ CamelFolder *folder = NULL;
g_return_val_if_fail (E_IS_MAIL_SESSION (session), NULL);
g_return_val_if_fail (service_uid != NULL, NULL);
- service = camel_session_get_service (
+ service = camel_session_ref_service (
CAMEL_SESSION (session), service_uid);
- if (!CAMEL_IS_STORE (service))
+ if (service == NULL)
return NULL;
+ if (!CAMEL_IS_STORE (service))
+ goto exit;
+
if (!camel_service_connect_sync (service, cancellable, error))
- return NULL;
+ goto exit;
- return camel_store_get_trash_folder_sync (
+ folder = camel_store_get_trash_folder_sync (
CAMEL_STORE (service), cancellable, error);
+
+exit:
+ g_object_unref (service);
+
+ return folder;
}
void
@@ -2377,12 +2401,12 @@ e_binding_transform_source_to_service (GBinding *binding,
return FALSE;
uid = e_source_get_uid (source);
- service = camel_session_get_service (session, uid);
+ service = camel_session_ref_service (session, uid);
- if (!CAMEL_IS_SERVICE (service))
+ if (service == NULL)
return FALSE;
- g_value_set_object (target_value, service);
+ g_value_take_object (target_value, service);
return TRUE;
}
@@ -2433,7 +2457,7 @@ e_mail_session_get_vfolder_store (EMailSession *session)
{
g_return_val_if_fail (E_IS_MAIL_SESSION (session), NULL);
- return session->priv->vfolder_store;
+ return CAMEL_STORE (session->priv->vfolder_store);
}
EMVFolderContext *
diff --git a/libemail-engine/mail-ops.c b/libemail-engine/mail-ops.c
index 58a90eadb2..7120826d49 100644
--- a/libemail-engine/mail-ops.c
+++ b/libemail-engine/mail-ops.c
@@ -610,7 +610,7 @@ mail_send_message (struct _send_queue_msg *m,
if (sent_folder_uri == NULL && tmp != NULL)
sent_folder_uri = g_strstrip (g_strdup (tmp));
- service = camel_session_get_service (
+ service = camel_session_ref_service (
CAMEL_SESSION (m->session), transport_uid);
if (service != NULL)
provider = camel_service_get_provider (service);
@@ -825,6 +825,10 @@ exit:
}
if (info)
camel_message_info_free (info);
+
+ if (service != NULL)
+ g_object_unref (service);
+
g_object_unref (recipients);
g_object_unref (from);
g_free (sent_folder_uri);
diff --git a/libemail-engine/mail-vfolder.c b/libemail-engine/mail-vfolder.c
index 233e6a0f02..3d695d625f 100644
--- a/libemail-engine/mail-vfolder.c
+++ b/libemail-engine/mail-vfolder.c
@@ -811,9 +811,9 @@ rule_changed (EFilterRule *rule,
full_name = camel_folder_get_full_name (folder);
session = get_session (folder);
- service = camel_session_get_service (
+ service = camel_session_ref_service (
CAMEL_SESSION (session), E_MAIL_SESSION_VFOLDER_UID);
- g_return_if_fail (CAMEL_IS_SERVICE (service));
+ g_return_if_fail (service != NULL);
/* If the folder has changed name, then
* add it, then remove the old manually. */
@@ -846,6 +846,9 @@ rule_changed (EFilterRule *rule,
g_free (oldname);
}
+ g_object_unref (service);
+ service = NULL;
+
d(printf("Filter rule changed? for folder '%s'!!\n", folder->name));
camel_vee_folder_set_auto_update (CAMEL_VEE_FOLDER (folder),
@@ -910,9 +913,9 @@ context_rule_added (ERuleContext *ctx,
d(printf("rule added: %s\n", rule->name));
- service = camel_session_get_service (
+ service = camel_session_ref_service (
CAMEL_SESSION (session), E_MAIL_SESSION_VFOLDER_UID);
- g_return_if_fail (CAMEL_IS_SERVICE (service));
+ g_return_if_fail (service != NULL);
/* this always runs quickly */
/* FIXME Not passing a GCancellable or GError. */
@@ -929,6 +932,8 @@ context_rule_added (ERuleContext *ctx,
rule_changed (rule, folder);
}
+
+ g_object_unref (service);
}
static void
@@ -941,9 +946,9 @@ context_rule_removed (ERuleContext *ctx,
d(printf("rule removed; %s\n", rule->name));
- service = camel_session_get_service (
+ service = camel_session_ref_service (
CAMEL_SESSION (session), E_MAIL_SESSION_VFOLDER_UID);
- g_return_if_fail (CAMEL_IS_SERVICE (service));
+ g_return_if_fail (service != NULL);
/* TODO: remove from folder info cache? */
@@ -960,6 +965,8 @@ context_rule_removed (ERuleContext *ctx,
/* this must be unref'd after its deleted */
if (folder)
g_object_unref ((CamelFolder *) folder);
+
+ g_object_unref (service);
}
static void
diff --git a/mail/e-mail-account-store.c b/mail/e-mail-account-store.c
index b7228e2c71..a78034aee5 100644
--- a/mail/e-mail-account-store.c
+++ b/mail/e-mail-account-store.c
@@ -1528,7 +1528,7 @@ e_mail_account_store_load_sort_order (EMailAccountStore *store,
for (ii = 0; ii < length; ii++) {
CamelService *service;
- service = camel_session_get_service (
+ service = camel_session_ref_service (
CAMEL_SESSION (session), service_uids[ii]);
if (service != NULL)
g_queue_push_tail (&service_queue, service);
@@ -1536,7 +1536,9 @@ e_mail_account_store_load_sort_order (EMailAccountStore *store,
e_mail_account_store_reorder_services (store, &service_queue);
- g_queue_clear (&service_queue);
+ while (!g_queue_is_empty (&service_queue))
+ g_object_unref (g_queue_pop_head (&service_queue));
+
g_strfreev (service_uids);
g_key_file_free (key_file);
diff --git a/mail/e-mail-backend.c b/mail/e-mail-backend.c
index e706d5571e..e0a0275019 100644
--- a/mail/e-mail-backend.c
+++ b/mail/e-mail-backend.c
@@ -166,18 +166,22 @@ mail_backend_prepare_for_offline_cb (EShell *shell,
const gchar *uid;
uid = e_source_get_uid (source);
- service = camel_session_get_service (
+ service = camel_session_ref_service (
CAMEL_SESSION (session), uid);
- if (!CAMEL_IS_STORE (service))
+ if (service == NULL)
continue;
/* FIXME Not passing a GCancellable. */
- e_mail_store_go_offline (
- CAMEL_STORE (service), G_PRIORITY_DEFAULT,
- NULL, (GAsyncReadyCallback)
- mail_backend_store_operation_done_cb,
- g_object_ref (activity));
+ if (CAMEL_IS_STORE (service))
+ e_mail_store_go_offline (
+ CAMEL_STORE (service),
+ G_PRIORITY_DEFAULT,
+ NULL, (GAsyncReadyCallback)
+ mail_backend_store_operation_done_cb,
+ g_object_ref (activity));
+
+ g_object_unref (service);
}
g_list_free_full (list, (GDestroyNotify) g_object_unref);
@@ -210,18 +214,22 @@ mail_backend_prepare_for_online_cb (EShell *shell,
continue;
uid = e_source_get_uid (source);
- service = camel_session_get_service (
+ service = camel_session_ref_service (
CAMEL_SESSION (session), uid);
- if (!CAMEL_IS_STORE (service))
+ if (service == NULL)
continue;
/* FIXME Not passing a GCancellable. */
- e_mail_store_go_online (
- CAMEL_STORE (service), G_PRIORITY_DEFAULT,
- NULL, (GAsyncReadyCallback)
- mail_backend_store_operation_done_cb,
- g_object_ref (activity));
+ if (CAMEL_IS_STORE (service))
+ e_mail_store_go_online (
+ CAMEL_STORE (service),
+ G_PRIORITY_DEFAULT,
+ NULL, (GAsyncReadyCallback)
+ mail_backend_store_operation_done_cb,
+ g_object_ref (activity));
+
+ g_object_unref (service);
}
g_list_free_full (list, (GDestroyNotify) g_object_unref);
@@ -331,7 +339,7 @@ mail_backend_prepare_for_quit_cb (EShell *shell,
g_object_ref (activity));
}
- g_list_free (list);
+ g_list_free_full (list, (GDestroyNotify) g_object_unref);
/* Now we poll until all activities are actually cancelled or finished.
* Reffing the activity delays quitting; the reference count
diff --git a/mail/e-mail-config-auth-check.c b/mail/e-mail-config-auth-check.c
index 990ce612e3..9d12ab2270 100644
--- a/mail/e-mail-config-auth-check.c
+++ b/mail/e-mail-config-auth-check.c
@@ -146,7 +146,6 @@ mail_config_auth_check_update (EMailConfigAuthCheck *auth_check)
"user-cache-dir", temp_dir,
NULL);
- /* This returns a BORROWED reference to the CamelService. */
service = camel_session_add_service (
session, "fake-uid",
backend_class->backend_name,
@@ -182,6 +181,8 @@ mail_config_auth_check_update (EMailConfigAuthCheck *auth_check)
camel_service_query_auth_types (
service, G_PRIORITY_DEFAULT, cancellable,
mail_config_auth_check_update_done_cb, async_context);
+
+ g_object_unref (service);
}
static void
diff --git a/mail/e-mail-config-defaults-page.c b/mail/e-mail-config-defaults-page.c
index ae4f14029d..9d54fb5eec 100644
--- a/mail/e-mail-config-defaults-page.c
+++ b/mail/e-mail-config-defaults-page.c
@@ -93,7 +93,7 @@ mail_config_defaults_page_maybe_get_settings (EMailConfigDefaultsPage *page)
}
static CamelStore *
-mail_config_defaults_page_get_store (EMailConfigDefaultsPage *page)
+mail_config_defaults_page_ref_store (EMailConfigDefaultsPage *page)
{
ESource *source;
EMailSession *session;
@@ -104,9 +104,17 @@ mail_config_defaults_page_get_store (EMailConfigDefaultsPage *page)
source = e_mail_config_defaults_page_get_account_source (page);
uid = e_source_get_uid (source);
- service = camel_session_get_service (CAMEL_SESSION (session), uid);
+ service = camel_session_ref_service (CAMEL_SESSION (session), uid);
- return CAMEL_IS_STORE (service) ? CAMEL_STORE (service) : NULL;
+ if (service == NULL)
+ return NULL;
+
+ if (!CAMEL_IS_STORE (service)) {
+ g_object_unref (service);
+ return NULL;
+ }
+
+ return CAMEL_STORE (service);
}
static gboolean
@@ -185,8 +193,8 @@ mail_config_defaults_page_folder_name_to_uri (GBinding *binding,
gchar *folder_uri = NULL;
page = E_MAIL_CONFIG_DEFAULTS_PAGE (data);
- store = mail_config_defaults_page_get_store (page);
- g_return_val_if_fail (CAMEL_IS_STORE (store), FALSE);
+ store = mail_config_defaults_page_ref_store (page);
+ g_return_val_if_fail (store != NULL, FALSE);
folder_name = g_value_get_string (source_value);
@@ -197,6 +205,8 @@ mail_config_defaults_page_folder_name_to_uri (GBinding *binding,
g_free (folder_uri);
+ g_object_unref (store);
+
return TRUE;
}
@@ -286,9 +296,6 @@ mail_config_defaults_page_add_real_folder (EMailConfigDefaultsPage *page,
CamelStore *store;
GObjectClass *class;
- store = mail_config_defaults_page_get_store (page);
- g_return_val_if_fail (CAMEL_IS_STORE (store), NULL);
-
session = e_mail_config_defaults_page_get_session (page);
settings = mail_config_defaults_page_maybe_get_settings (page);
@@ -306,6 +313,9 @@ mail_config_defaults_page_add_real_folder (EMailConfigDefaultsPage *page,
if (g_object_class_find_property (class, use_property_name) == NULL)
return NULL;
+ store = mail_config_defaults_page_ref_store (page);
+ g_return_val_if_fail (store != NULL, NULL);
+
/* We're good to go. */
box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 6);
@@ -352,6 +362,8 @@ mail_config_defaults_page_add_real_folder (EMailConfigDefaultsPage *page,
G_CALLBACK (mail_config_defaults_page_restore_real_folder),
check_button);
+ g_object_unref (store);
+
return box;
}
diff --git a/mail/em-filter-source-element.c b/mail/em-filter-source-element.c
index fbc2aed1f1..2d5be7fd52 100644
--- a/mail/em-filter-source-element.c
+++ b/mail/em-filter-source-element.c
@@ -207,7 +207,7 @@ filter_source_element_xml_decode (EFilterElement *fe,
xmlFree (content);
if (url != NULL) {
- service = camel_session_get_service_by_url (
+ service = camel_session_ref_service_by_url (
CAMEL_SESSION (session),
url, CAMEL_PROVIDER_STORE);
camel_url_free (url);
@@ -218,6 +218,8 @@ filter_source_element_xml_decode (EFilterElement *fe,
uid = camel_service_get_uid (service);
active_id = g_strdup (uid);
+
+ g_object_unref (service);
}
break;
diff --git a/mail/em-folder-tree.c b/mail/em-folder-tree.c
index fd5ac582e2..ddcfc65c15 100644
--- a/mail/em-folder-tree.c
+++ b/mail/em-folder-tree.c
@@ -491,7 +491,7 @@ static void
folder_tree_expand_node (const gchar *key,
EMFolderTree *folder_tree)
{
- struct _EMFolderTreeModelStoreInfo *si;
+ struct _EMFolderTreeModelStoreInfo *si = NULL;
GtkTreeRowReference *row;
GtkTreeView *tree_view;
GtkTreeModel *model;
@@ -517,21 +517,18 @@ folder_tree_expand_node (const gchar *key,
session = em_folder_tree_get_session (folder_tree);
- service = camel_session_get_service (CAMEL_SESSION (session), uid);
-
- if (!CAMEL_IS_STORE (service))
- return;
+ service = camel_session_ref_service (CAMEL_SESSION (session), uid);
- g_object_ref (service);
+ if (CAMEL_IS_STORE (service))
+ si = em_folder_tree_model_lookup_store_info (
+ EM_FOLDER_TREE_MODEL (model),
+ CAMEL_STORE (service));
- si = em_folder_tree_model_lookup_store_info (
- EM_FOLDER_TREE_MODEL (model), CAMEL_STORE (service));
- if (si == NULL) {
+ if (service != NULL)
g_object_unref (service);
- return;
- }
- g_object_unref (service);
+ if (si == NULL)
+ return;
if (p != NULL && p[1]) {
if (!(row = g_hash_table_lookup (si->full_hash, p + 1)))
@@ -3516,12 +3513,14 @@ em_folder_tree_restore_state (EMFolderTree *folder_tree,
CamelService *service;
const gchar *uid = group_name + 6;
- service = camel_session_get_service (
+ service = camel_session_ref_service (
CAMEL_SESSION (session), uid);
if (CAMEL_IS_STORE (service)) {
store = g_object_ref (service);
success = TRUE;
}
+ if (service != NULL)
+ g_object_unref (service);
expanded = TRUE;
} else if (g_str_has_prefix (group_name, "Folder ")) {
diff --git a/mail/em-subscription-editor.c b/mail/em-subscription-editor.c
index 8221115c46..1ee5269278 100644
--- a/mail/em-subscription-editor.c
+++ b/mail/em-subscription-editor.c
@@ -1564,13 +1564,16 @@ subscription_editor_constructed (GObject *object)
source = e_source_registry_ref_default_mail_account (registry);
- service = camel_session_get_service (
+ service = camel_session_ref_service (
CAMEL_SESSION (session),
e_source_get_uid (source));
if (CAMEL_IS_SUBSCRIBABLE (service))
editor->priv->initial_store = g_object_ref (service);
+ if (service != NULL)
+ g_object_unref (service);
+
g_object_unref (source);
}
diff --git a/mail/em-utils.c b/mail/em-utils.c
index 3bfeaffe48..17ecdbcae8 100644
--- a/mail/em-utils.c
+++ b/mail/em-utils.c
@@ -1377,7 +1377,7 @@ em_utils_empty_trash (GtkWidget *parent,
mail_empty_trash (CAMEL_STORE (service));
}
- g_list_free (list);
+ g_list_free_full (list, (GDestroyNotify) g_object_unref);
}
/* ********************************************************************** */
diff --git a/mail/mail-send-recv.c b/mail/mail-send-recv.c
index 0d2cc10d00..d2190a244d 100644
--- a/mail/mail-send-recv.c
+++ b/mail/mail-send-recv.c
@@ -339,7 +339,7 @@ set_transport_service (struct _send_info *info,
g_static_mutex_lock (&status_lock);
- service = camel_session_get_service (info->session, transport_uid);
+ service = camel_session_ref_service (info->session, transport_uid);
if (CAMEL_IS_TRANSPORT (service)) {
if (info->service != NULL)
@@ -347,6 +347,9 @@ set_transport_service (struct _send_info *info,
info->service = g_object_ref (service);
}
+ if (service != NULL)
+ g_object_unref (service);
+
g_static_mutex_unlock (&status_lock);
}
@@ -1136,7 +1139,7 @@ receive_update_got_store (CamelStore *store,
}
static CamelService *
-get_default_transport (EMailSession *session)
+ref_default_transport (EMailSession *session)
{
ESource *source;
ESourceRegistry *registry;
@@ -1171,7 +1174,7 @@ get_default_transport (EMailSession *session)
return NULL;
uid = e_source_get_uid (source);
- service = camel_session_get_service (CAMEL_SESSION (session), uid);
+ service = camel_session_ref_service (CAMEL_SESSION (session), uid);
g_object_unref (source);
@@ -1198,7 +1201,7 @@ send_receive (GtkWindow *parent,
if (!camel_session_get_online (CAMEL_SESSION (session)))
return send_recv_dialog;
- transport = get_default_transport (session);
+ transport = ref_default_transport (session);
local_outbox =
e_mail_session_get_local_folder (
@@ -1207,6 +1210,9 @@ send_receive (GtkWindow *parent,
data = build_dialog (
parent, session, local_outbox, transport, allow_send);
+ if (transport != NULL)
+ g_object_unref (transport);
+
for (scan = data->infos; scan != NULL; scan = scan->next) {
struct _send_info *info = scan->data;
@@ -1357,7 +1363,7 @@ mail_send (EMailSession *session)
g_return_if_fail (E_IS_MAIL_SESSION (session));
- service = get_default_transport (session);
+ service = ref_default_transport (session);
if (service == NULL)
return;
@@ -1366,15 +1372,17 @@ mail_send (EMailSession *session)
if (info != NULL) {
info->again++;
d(printf("send of %s still in progress\n", transport->url));
+ g_object_unref (service);
return;
}
d(printf("starting non-interactive send of '%s'\n", transport->url));
type = get_receive_type (service);
-
- if (type == SEND_INVALID)
+ if (type == SEND_INVALID) {
+ g_object_unref (service);
return;
+ }
info = g_malloc0 (sizeof (*info));
info->type = SEND_SEND;
@@ -1405,4 +1413,6 @@ mail_send (EMailSession *session)
receive_get_folder, info,
receive_status, info,
send_done, info);
+
+ g_object_unref (service);
}
diff --git a/modules/mail/e-mail-shell-backend.c b/modules/mail/e-mail-shell-backend.c
index 8b00ccf0a2..7472a50f35 100644
--- a/modules/mail/e-mail-shell-backend.c
+++ b/modules/mail/e-mail-shell-backend.c
@@ -314,7 +314,7 @@ mail_shell_backend_mail_sync (EMailShellBackend *mail_shell_backend)
mail_shell_backend);
}
- g_list_free (list);
+ g_list_free_full (list, (GDestroyNotify) g_object_unref);
exit:
return TRUE;
@@ -481,8 +481,8 @@ mail_shell_backend_changes_committed_cb (EMailConfigWindow *window,
original_source = e_mail_config_window_get_original_source (window);
uid = e_source_get_uid (original_source);
- service = camel_session_get_service (CAMEL_SESSION (session), uid);
- g_return_if_fail (CAMEL_IS_STORE (service));
+ service = camel_session_ref_service (CAMEL_SESSION (session), uid);
+ g_return_if_fail (service != NULL);
shell_backend = E_SHELL_BACKEND (mail_shell_backend);
@@ -511,6 +511,8 @@ mail_shell_backend_changes_committed_cb (EMailConfigWindow *window,
mail_shell_backend_disconnect_done_cb, activity);
g_object_unref (cancellable);
+
+ g_object_unref (service);
}
static void
@@ -589,11 +591,16 @@ mail_shell_backend_constructed (GObject *object)
500);
mail_session = e_mail_backend_get_session (E_MAIL_BACKEND (object));
- vstore = camel_session_get_service (CAMEL_SESSION (mail_session), E_MAIL_SESSION_VFOLDER_UID);
+ vstore = camel_session_ref_service (
+ CAMEL_SESSION (mail_session), E_MAIL_SESSION_VFOLDER_UID);
+ g_return_if_fail (vstore != NULL);
+
g_object_bind_property (
shell_settings, "mail-enable-unmatched-search-folder",
vstore, "unmatched-enabled",
G_BINDING_SYNC_CREATE | G_BINDING_BIDIRECTIONAL);
+
+ g_object_unref (vstore);
}
static void
diff --git a/modules/mail/e-mail-shell-view-actions.c b/modules/mail/e-mail-shell-view-actions.c
index f51286bc2f..48f9d74471 100644
--- a/modules/mail/e-mail-shell-view-actions.c
+++ b/modules/mail/e-mail-shell-view-actions.c
@@ -244,7 +244,7 @@ action_mail_download_cb (GtkAction *action,
action_mail_download_finished_cb, activity);
}
- g_list_free (list);
+ g_list_free_full (list, (GDestroyNotify) g_object_unref);
}
static void
diff --git a/modules/mail/e-mail-shell-view.c b/modules/mail/e-mail-shell-view.c
index 1db444e936..ebbbcef65f 100644
--- a/modules/mail/e-mail-shell-view.c
+++ b/modules/mail/e-mail-shell-view.c
@@ -605,15 +605,16 @@ all_accounts:
/* Create a new search folder. */
/* FIXME Complete lack of error checking here. */
- service = camel_session_get_service (
+ service = camel_session_ref_service (
CAMEL_SESSION (session), E_MAIL_SESSION_VFOLDER_UID);
camel_service_connect_sync (service, NULL, NULL);
search_folder = (CamelVeeFolder *) camel_vee_folder_new (
- CAMEL_STORE (service), _("All Account Search"),
- 0);
+ CAMEL_STORE (service), _("All Account Search"), 0);
priv->search_account_all = search_folder;
+ g_object_unref (service);
+
camel_vee_folder_set_expression (search_folder, query);
all_accounts_setup:
@@ -701,15 +702,16 @@ current_account:
/* Create a new search folder. */
/* FIXME Complete lack of error checking here. */
- service = camel_session_get_service (
+ service = camel_session_ref_service (
CAMEL_SESSION (session), E_MAIL_SESSION_VFOLDER_UID);
camel_service_connect_sync (service, NULL, NULL);
search_folder = (CamelVeeFolder *) camel_vee_folder_new (
- CAMEL_STORE (service), _("Account Search"),
- 0);
+ CAMEL_STORE (service), _("Account Search"), 0);
priv->search_account_current = search_folder;
+ g_object_unref (service);
+
camel_vee_folder_set_expression (search_folder, query);
current_accout_setup:
diff --git a/shell/e-convert-local-mail.c b/shell/e-convert-local-mail.c
index 02d7e094e4..16736c95c4 100644
--- a/shell/e-convert-local-mail.c
+++ b/shell/e-convert-local-mail.c
@@ -183,8 +183,8 @@ migrate_mbox_to_maildir (EShell *shell,
ESourceRegistry *registry;
ESourceExtension *extension;
const gchar *extension_name;
- CamelService *mbox_service;
- CamelService *maildir_service;
+ CamelService *mbox_service = NULL;
+ CamelService *maildir_service = NULL;
CamelSettings *settings;
const gchar *data_dir;
const gchar *mbox_uid;
@@ -227,11 +227,18 @@ migrate_mbox_to_maildir (EShell *shell,
CAMEL_PROVIDER_STORE, &error);
if (error != NULL) {
+ if (mbox_service != NULL)
+ g_object_unref (mbox_service);
+ if (maildir_service != NULL)
+ g_object_unref (maildir_service);
g_warning ("%s: %s", G_STRFUNC, error->message);
g_error_free (error);
return FALSE;
}
+ g_return_val_if_fail (CAMEL_IS_STORE (mbox_service), FALSE);
+ g_return_val_if_fail (CAMEL_IS_STORE (maildir_service), FALSE);
+
camel_service_set_settings (mbox_service, settings);
settings = camel_service_get_settings (maildir_service);
@@ -249,6 +256,9 @@ migrate_mbox_to_maildir (EShell *shell,
while (!ms.complete)
g_main_context_iteration (NULL, TRUE);
+ g_object_unref (mbox_service);
+ g_object_unref (maildir_service);
+
return TRUE;
}