* Clean up some code
[modest] / src / modest-mail-operation.c
index 913b741..a82eccd 100644 (file)
@@ -971,7 +971,7 @@ modest_mail_operation_save_to_drafts_cb (ModestMailOperation *self,
        if (!priv->error) {
                SaveToDraftsAddMsgInfo *cb_info = g_slice_new(SaveToDraftsAddMsgInfo);
                cb_info->transport_account = g_object_ref(info->transport_account);
-               cb_info->draft_msg = g_object_ref(info->draft_msg);
+               cb_info->draft_msg = info->draft_msg ? g_object_ref(info->draft_msg) : NULL;
                cb_info->callback = info->callback;
                cb_info->user_data = info->user_data;
                cb_info->drafts = g_object_ref(drafts);
@@ -2339,16 +2339,11 @@ modest_mail_operation_remove_msg (ModestMailOperation *self,
 
                modest_mail_operation_notify_start (self);
 
-               if (TNY_IS_CAMEL_IMAP_FOLDER (folder))
-/*                     tny_folder_sync_async(folder, FALSE, NULL, NULL, NULL); /\* FALSE --> don't expunge *\/ */
-                       tny_folder_sync (folder, FALSE, &(priv->error)); /* FALSE --> don't expunge */
-               else if (TNY_IS_CAMEL_POP_FOLDER (folder))
-/*                     tny_folder_sync_async(folder, FALSE, NULL, NULL, NULL); /\* TRUE --> dont expunge *\/ */
-                       tny_folder_sync (folder, TRUE, &(priv->error)); /* TRUE --> expunge */
+               if (TNY_IS_CAMEL_IMAP_FOLDER (folder) ||
+                   TNY_IS_CAMEL_POP_FOLDER (folder))
+                       tny_folder_sync_async(folder, FALSE, NULL, NULL, NULL); /* FALSE --> dont expunge */
                else
-                       /* local folders */
-/*                     tny_folder_sync_async(folder, TRUE, NULL, NULL, NULL); /\* TRUE --> expunge *\/ */
-                       tny_folder_sync (folder, TRUE, &(priv->error)); /* TRUE --> expunge */
+                       tny_folder_sync_async(folder, TRUE, NULL, NULL, NULL); /* TRUE --> expunge */
        }
        
        
@@ -2844,7 +2839,6 @@ modest_mail_operation_notify_start (ModestMailOperation *self)
        priv = MODEST_MAIL_OPERATION_GET_PRIVATE(self);
 
        /* Ensure that all the fields are filled correctly */
-       g_return_if_fail (priv->account != NULL);
        g_return_if_fail (priv->op_type != MODEST_MAIL_OPERATION_TYPE_UNKNOWN);
 
        /* Notify the observers about the mail operation. We do not
@@ -2891,3 +2885,21 @@ modest_mail_operation_get_account (ModestMailOperation *self)
 
        return (priv->account) ? g_object_ref (priv->account) : NULL;
 }
+
+void
+modest_mail_operation_noop (ModestMailOperation *self)
+{
+       ModestMailOperationPrivate *priv = NULL;
+
+       g_return_if_fail (self);
+
+       priv = MODEST_MAIL_OPERATION_GET_PRIVATE(self);
+       priv->status = MODEST_MAIL_OPERATION_STATUS_SUCCESS;
+       priv->op_type = MODEST_MAIL_OPERATION_TYPE_INFO;
+       priv->done = 0;
+       priv->total = 0;
+
+       /* This mail operation does nothing actually */
+       modest_mail_operation_notify_start (self);
+       modest_mail_operation_notify_end (self);
+}