* sometimes, the text->html conversion screwed up, because
[modest] / src / modest-mail-operation.c
index ede8f8e..1d8bcc9 100644 (file)
@@ -805,6 +805,7 @@ create_msg_thread (gpointer thread_data)
 
        g_object_unref (info->mail_op);
        g_slice_free (CreateMsgInfo, info);
+       if (new_msg) g_object_unref(new_msg);
        return NULL;
 }
 
@@ -1589,6 +1590,14 @@ modest_mail_operation_update_account (ModestMailOperation *self,
        modest_account_mgr_set_account_busy (modest_runtime_get_account_mgr (), account_name, TRUE);
        modest_mail_operation_notify_start (self);
 
+       /* notify about the start of the operation */ 
+       ModestMailOperationState *state;
+       state = modest_mail_operation_clone_state (self);
+       state->done = 0;
+       state->total = 0;
+       g_signal_emit (G_OBJECT (self), signals[PROGRESS_CHANGED_SIGNAL], 
+                       0, state, NULL);
+       
        /* Get all folders and continue in the callback */    
        folders = tny_simple_list_new ();
        tny_folder_store_get_folders_async (TNY_FOLDER_STORE (store_account),
@@ -2153,6 +2162,15 @@ modest_mail_operation_get_msg (ModestMailOperation *self,
        helper->total_bytes = tny_header_get_message_size (header);
 
        modest_mail_operation_notify_start (self);
+       
+       /* notify about the start of the operation */ 
+       ModestMailOperationState *state;
+       state = modest_mail_operation_clone_state (self);
+       state->done = 0;
+       state->total = 0;
+       g_signal_emit (G_OBJECT (self), signals[PROGRESS_CHANGED_SIGNAL], 
+                               0, state, NULL);
+       
        tny_folder_get_msg_async (folder, header, get_msg_async_cb, get_msg_status_cb, helper);
 
        g_object_unref (G_OBJECT (folder));
@@ -2301,6 +2319,14 @@ modest_mail_operation_get_msgs_full (ModestMailOperation *self,
                modest_mail_operation_notify_start (self);
                iter = tny_list_create_iterator (header_list);
                while (!tny_iterator_is_done (iter)) { 
+                       /* notify about the start of the operation */ 
+                       ModestMailOperationState *state;
+                       state = modest_mail_operation_clone_state (self);
+                       state->done = 0;
+                       state->total = 0;
+                       g_signal_emit (G_OBJECT (self), signals[PROGRESS_CHANGED_SIGNAL], 
+                                       0, state, NULL);
+                       
                        GetMsgInfo *msg_info = NULL;
                        TnyHeader *header = TNY_HEADER (tny_iterator_get_current (iter));
                        TnyFolder *folder = tny_header_get_folder (header);
@@ -2368,6 +2394,7 @@ modest_mail_operation_remove_msg (ModestMailOperation *self,
                gboolean expunge, leave_on_server;
                const gchar *account_name;
                TnyAccount *account;
+               ModestTransportStoreProtocol account_proto;
 
                tny_header_set_flag (header, TNY_HEADER_FLAG_DELETED);
                tny_header_set_flag (header, TNY_HEADER_FLAG_SEEN);
@@ -2381,7 +2408,10 @@ modest_mail_operation_remove_msg (ModestMailOperation *self,
                        modest_account_mgr_get_leave_on_server (modest_runtime_get_account_mgr (),
                                                                account_name);
 
-               if (TNY_IS_CAMEL_POP_FOLDER (folder) && !leave_on_server)
+               account_proto = modest_protocol_info_get_transport_store_protocol (tny_account_get_proto (account));
+
+               if (((account_proto == MODEST_PROTOCOL_STORE_POP) && !leave_on_server) ||
+                   modest_tny_folder_is_remote_folder (folder) == FALSE)
                        expunge = TRUE;
                else
                        expunge = FALSE;
@@ -2475,12 +2505,29 @@ modest_mail_operation_remove_msgs (ModestMailOperation *self,
 
        tny_folder_remove_msgs (folder, remove_headers, &(priv->error));
        if (!priv->error) {
-               if (TNY_IS_CAMEL_IMAP_FOLDER (folder) || 
-                   TNY_IS_CAMEL_POP_FOLDER (folder))
-                       tny_folder_sync_async(folder, FALSE, NULL, NULL, NULL); /* FALSE --> don't expunge */ 
+               gboolean expunge, leave_on_server;
+               const gchar *account_name;
+               TnyAccount *account;
+               ModestTransportStoreProtocol account_proto;
+               
+               account = tny_folder_get_account (folder);
+               account_name = modest_tny_account_get_parent_modest_account_name_for_server_account (account);
+               leave_on_server =
+                       modest_account_mgr_get_leave_on_server (modest_runtime_get_account_mgr (),
+                                       account_name);
+
+               account_proto = modest_protocol_info_get_transport_store_protocol (tny_account_get_proto (account));
+
+               if (((account_proto == MODEST_PROTOCOL_STORE_POP) && !leave_on_server) ||
+                   modest_tny_folder_is_remote_folder (folder) == FALSE)
+                       expunge = TRUE;
                else
-                       /* local folders */
-                       tny_folder_sync_async(folder, TRUE, NULL, NULL, NULL); /* TRUE --> expunge */
+                       expunge = FALSE;
+
+               /* Sync folder */
+               tny_folder_sync_async(folder, expunge, NULL, NULL, NULL);
+               
+               g_object_unref (account);
        }
        
        
@@ -2884,6 +2931,15 @@ modest_mail_operation_refresh_folder  (ModestMailOperation *self,
           updates before the callback call then this could happen. We
           must review the design */
        modest_mail_operation_notify_start (self);
+       
+       /* notify that the operation was started */
+       ModestMailOperationState *state;
+       state = modest_mail_operation_clone_state (self);
+       state->done = 0;
+       state->total = 0;
+       g_signal_emit (G_OBJECT (self), signals[PROGRESS_CHANGED_SIGNAL], 
+                       0, state, NULL);
+       
        tny_folder_refresh_async (folder,
                                  on_refresh_folder,
                                  on_refresh_folder_status_update,