Bug #625110 - IMAPX : Do not free connection manager on disconnect
authorMilan Crha <mcrha@redhat.com>
Thu, 2 Sep 2010 12:02:48 +0000 (14:02 +0200)
committerMilan Crha <mcrha@redhat.com>
Thu, 2 Sep 2010 12:02:48 +0000 (14:02 +0200)
camel/providers/imapx/camel-imapx-folder.c
camel/providers/imapx/camel-imapx-store.c

index c3f80d6..c0d3b4a 100644 (file)
@@ -158,8 +158,13 @@ imapx_refresh_info (CamelFolder *folder, GError **error)
        parent_store = camel_folder_get_parent_store (folder);
        istore = CAMEL_IMAPX_STORE (parent_store);
 
-       if (CAMEL_OFFLINE_STORE (istore)->state == CAMEL_OFFLINE_STORE_NETWORK_UNAVAIL)
-               return TRUE;
+       if (CAMEL_OFFLINE_STORE (istore)->state == CAMEL_OFFLINE_STORE_NETWORK_UNAVAIL) {
+               g_set_error (
+                       error, CAMEL_SERVICE_ERROR,
+                       CAMEL_SERVICE_ERROR_UNAVAILABLE,
+                       _("You must be working online to complete this operation"));
+               return FALSE;
+       }
 
        if (!camel_service_connect((CamelService *)istore, error))
                return FALSE;
@@ -184,8 +189,13 @@ imapx_expunge (CamelFolder *folder, GError **error)
        parent_store = camel_folder_get_parent_store (folder);
        istore = CAMEL_IMAPX_STORE (parent_store);
 
-       if (CAMEL_OFFLINE_STORE (istore)->state == CAMEL_OFFLINE_STORE_NETWORK_UNAVAIL)
-               return TRUE;
+       if (CAMEL_OFFLINE_STORE (istore)->state == CAMEL_OFFLINE_STORE_NETWORK_UNAVAIL) {
+               g_set_error (
+                       error, CAMEL_SERVICE_ERROR,
+                       CAMEL_SERVICE_ERROR_UNAVAILABLE,
+                       _("You must be working online to complete this operation"));
+               return FALSE;
+       }
 
        server = camel_imapx_store_get_server(istore, camel_folder_get_full_name (folder), error);
        if (server) {
@@ -208,8 +218,13 @@ imapx_sync (CamelFolder *folder, gboolean expunge, GError **error)
        parent_store = camel_folder_get_parent_store (folder);
        istore = CAMEL_IMAPX_STORE (parent_store);
 
-       if (CAMEL_OFFLINE_STORE (istore)->state == CAMEL_OFFLINE_STORE_NETWORK_UNAVAIL)
-               return TRUE;
+       if (CAMEL_OFFLINE_STORE (istore)->state == CAMEL_OFFLINE_STORE_NETWORK_UNAVAIL) {
+               g_set_error (
+                       error, CAMEL_SERVICE_ERROR,
+                       CAMEL_SERVICE_ERROR_UNAVAILABLE,
+                       _("You must be working online to complete this operation"));
+               return FALSE;
+       }
 
        server = camel_imapx_store_get_server(istore, camel_folder_get_full_name (folder), NULL);
        if (server)
@@ -260,8 +275,13 @@ imapx_get_message (CamelFolder *folder, const gchar *uid, GError **error)
                        return NULL;
                }
 
-               if (CAMEL_OFFLINE_STORE (istore)->state == CAMEL_OFFLINE_STORE_NETWORK_UNAVAIL)
+               if (CAMEL_OFFLINE_STORE (istore)->state == CAMEL_OFFLINE_STORE_NETWORK_UNAVAIL) {
+                       g_set_error (
+                               error, CAMEL_SERVICE_ERROR,
+                               CAMEL_SERVICE_ERROR_UNAVAILABLE,
+                               _("You must be working online to complete this operation"));
                        return NULL;
+               }
 
                server = camel_imapx_store_get_server(istore, camel_folder_get_full_name (folder), error);
                if (server) {
@@ -298,8 +318,13 @@ imapx_sync_message (CamelFolder *folder, const gchar *uid, GError **error)
        parent_store = camel_folder_get_parent_store (folder);
        istore = CAMEL_IMAPX_STORE (parent_store);
 
-       if (CAMEL_OFFLINE_STORE (istore)->state == CAMEL_OFFLINE_STORE_NETWORK_UNAVAIL)
-               return TRUE;
+       if (CAMEL_OFFLINE_STORE (istore)->state == CAMEL_OFFLINE_STORE_NETWORK_UNAVAIL) {
+               g_set_error (
+                       error, CAMEL_SERVICE_ERROR,
+                       CAMEL_SERVICE_ERROR_UNAVAILABLE,
+                       _("You must be working online to complete this operation"));
+               return FALSE;
+       }
 
        server = camel_imapx_store_get_server (istore, camel_folder_get_full_name (folder), error);
        if (server == NULL)
@@ -325,8 +350,13 @@ imapx_transfer_messages_to (CamelFolder *source, GPtrArray *uids,
        parent_store = camel_folder_get_parent_store (source);
        istore = CAMEL_IMAPX_STORE (parent_store);
 
-       if (CAMEL_OFFLINE_STORE (istore)->state == CAMEL_OFFLINE_STORE_NETWORK_UNAVAIL)
-               return TRUE;
+       if (CAMEL_OFFLINE_STORE (istore)->state == CAMEL_OFFLINE_STORE_NETWORK_UNAVAIL) {
+               g_set_error (
+                       error, CAMEL_SERVICE_ERROR,
+                       CAMEL_SERVICE_ERROR_UNAVAILABLE,
+                       _("You must be working online to complete this operation"));
+               return FALSE;
+       }
 
        server = camel_imapx_store_get_server (istore, camel_folder_get_full_name (source), error);
        if (server) {
@@ -351,8 +381,13 @@ imapx_append_message(CamelFolder *folder, CamelMimeMessage *message, const Camel
        parent_store = camel_folder_get_parent_store (folder);
        istore = CAMEL_IMAPX_STORE (parent_store);
 
-       if (CAMEL_OFFLINE_STORE (istore)->state == CAMEL_OFFLINE_STORE_NETWORK_UNAVAIL)
-               return TRUE;
+       if (CAMEL_OFFLINE_STORE (istore)->state == CAMEL_OFFLINE_STORE_NETWORK_UNAVAIL) {
+               g_set_error (
+                       error, CAMEL_SERVICE_ERROR,
+                       CAMEL_SERVICE_ERROR_UNAVAILABLE,
+                       _("You must be working online to complete this operation"));
+               return FALSE;
+       }
 
        if (appended_uid)
                *appended_uid = NULL;
index b7ef310..ebdbb23 100644 (file)
@@ -128,6 +128,10 @@ imapx_store_finalize (GObject *object)
        /* SIGH */
 
        camel_service_disconnect((CamelService *)imapx_store, TRUE, NULL);
+       if (imapx_store->con_man) {
+               g_object_unref (imapx_store->con_man);
+               imapx_store->con_man = NULL;
+       }
        g_mutex_free (imapx_store->get_finfo_lock);
 
        g_free (imapx_store->base_url);
@@ -274,8 +278,6 @@ imapx_disconnect (CamelService *service, gboolean clean, GError **error)
 
        if (istore->con_man) {
                camel_imapx_conn_manager_close_connections (istore->con_man);
-               g_object_unref (istore->con_man);
-               istore->con_man = NULL;
        }
 
        camel_service_unlock (service, CAMEL_SERVICE_REC_CONNECT_LOCK);