diff options
author | Matthew Barnes <mbarnes@redhat.com> | 2012-08-12 20:58:50 +0800 |
---|---|---|
committer | Matthew Barnes <mbarnes@redhat.com> | 2012-08-12 23:44:37 +0800 |
commit | 6be2668e483cfc7a2e75ae2efcd9675388d08601 (patch) | |
tree | 3f0d28830d54da205467bf973eea9895f8003b35 /mail | |
parent | 6456e814fae763ecd9dbdbe4d3caa952ddca0a3d (diff) | |
download | gsoc2013-evolution-6be2668e483cfc7a2e75ae2efcd9675388d08601.tar.gz gsoc2013-evolution-6be2668e483cfc7a2e75ae2efcd9675388d08601.tar.zst gsoc2013-evolution-6be2668e483cfc7a2e75ae2efcd9675388d08601.zip |
Adapt to CamelSession API changes.
These functions now return new references:
camel_session_add_service()
camel_session_list_services()
These functions have been renamed and also return new references:
camel_session_get_service() -> camel_session_ref_service()
camel_session_get_service_by_url() -> camel_session_ref_service_by_url()
Diffstat (limited to 'mail')
-rw-r--r-- | mail/e-mail-account-store.c | 6 | ||||
-rw-r--r-- | mail/e-mail-backend.c | 38 | ||||
-rw-r--r-- | mail/e-mail-config-auth-check.c | 3 | ||||
-rw-r--r-- | mail/e-mail-config-defaults-page.c | 28 | ||||
-rw-r--r-- | mail/em-filter-source-element.c | 4 | ||||
-rw-r--r-- | mail/em-folder-tree.c | 25 | ||||
-rw-r--r-- | mail/em-subscription-editor.c | 5 | ||||
-rw-r--r-- | mail/em-utils.c | 2 | ||||
-rw-r--r-- | mail/mail-send-recv.c | 24 |
9 files changed, 86 insertions, 49 deletions
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); } |