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 /libemail-engine | |
parent | 6456e814fae763ecd9dbdbe4d3caa952ddca0a3d (diff) | |
download | gsoc2013-evolution-6be2668e483cfc7a2e75ae2efcd9675388d08601.tar gsoc2013-evolution-6be2668e483cfc7a2e75ae2efcd9675388d08601.tar.gz gsoc2013-evolution-6be2668e483cfc7a2e75ae2efcd9675388d08601.tar.bz2 gsoc2013-evolution-6be2668e483cfc7a2e75ae2efcd9675388d08601.tar.lz gsoc2013-evolution-6be2668e483cfc7a2e75ae2efcd9675388d08601.tar.xz 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 'libemail-engine')
-rw-r--r-- | libemail-engine/e-mail-folder-utils.c | 18 | ||||
-rw-r--r-- | libemail-engine/e-mail-session-utils.c | 21 | ||||
-rw-r--r-- | libemail-engine/e-mail-session.c | 84 | ||||
-rw-r--r-- | libemail-engine/mail-ops.c | 6 | ||||
-rw-r--r-- | libemail-engine/mail-vfolder.c | 19 |
5 files changed, 102 insertions, 46 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 |