* Moved the op_type to the mail operations, it should be definitely there and not...
authorSergio Villar Senin <svillar@igalia.com>
Tue, 2 Oct 2007 17:43:37 +0000 (17:43 +0000)
committerSergio Villar Senin <svillar@igalia.com>
Tue, 2 Oct 2007 17:43:37 +0000 (17:43 +0000)
pmo-trunk-r3456

src/maemo/modest-msg-view-window.c
src/modest-mail-operation.c
src/modest-mail-operation.h
src/modest-ui-actions.c
src/widgets/modest-folder-view.c
src/widgets/modest-header-view.c

index ca7be3e..1b56900 100644 (file)
@@ -1599,8 +1599,7 @@ message_reader (ModestMsgViewWindow *window,
        }
 
        /* New mail operation */
-       mail_op = modest_mail_operation_new_with_error_handling (op_type, 
-                                                                G_OBJECT(window),
+       mail_op = modest_mail_operation_new_with_error_handling (G_OBJECT(window),
                                                                 modest_ui_actions_get_msgs_full_error_handler, 
                                                                 NULL);
                                
index 7905fab..89e369c 100644 (file)
@@ -314,8 +314,7 @@ modest_mail_operation_finalize (GObject *obj)
 }
 
 ModestMailOperation*
-modest_mail_operation_new (ModestMailOperationTypeOperation op_type, 
-                          GObject *source)
+modest_mail_operation_new (GObject *source)
 {
        ModestMailOperation *obj;
        ModestMailOperationPrivate *priv;
@@ -323,7 +322,6 @@ modest_mail_operation_new (ModestMailOperationTypeOperation op_type,
        obj = MODEST_MAIL_OPERATION(g_object_new(MODEST_TYPE_MAIL_OPERATION, NULL));
        priv = MODEST_MAIL_OPERATION_GET_PRIVATE(obj);
 
-       priv->op_type = op_type;
        if (source != NULL)
                priv->source = g_object_ref(source);
 
@@ -331,15 +329,14 @@ modest_mail_operation_new (ModestMailOperationTypeOperation op_type,
 }
 
 ModestMailOperation*
-modest_mail_operation_new_with_error_handling (ModestMailOperationTypeOperation op_type,
-                                              GObject *source,
+modest_mail_operation_new_with_error_handling (GObject *source,
                                               ErrorCheckingUserCallback error_handler,
                                               gpointer user_data)
 {
        ModestMailOperation *obj;
        ModestMailOperationPrivate *priv;
                
-       obj = modest_mail_operation_new (op_type, source);
+       obj = modest_mail_operation_new (source);
        priv = MODEST_MAIL_OPERATION_GET_PRIVATE(obj);
        
        g_return_val_if_fail (error_handler != NULL, obj);
@@ -811,6 +808,7 @@ modest_mail_operation_send_new_mail (ModestMailOperation *self,
        g_return_if_fail (TNY_IS_TRANSPORT_ACCOUNT (transport_account));
 
        priv = MODEST_MAIL_OPERATION_GET_PRIVATE(self);
+       priv->op_type = MODEST_MAIL_OPERATION_TYPE_SEND;
 
        /* Check parametters */
        if (to == NULL) {
@@ -856,6 +854,7 @@ modest_mail_operation_save_to_drafts_cb (ModestMailOperation *self,
        SaveToDraftsInfo *info = (SaveToDraftsInfo *) userdata;
 
        priv = MODEST_MAIL_OPERATION_GET_PRIVATE(self);
+
        if (!msg) {
                priv->status = MODEST_MAIL_OPERATION_STATUS_FAILED;
                g_set_error (&(priv->error), MODEST_MAIL_OPERATION_ERROR,
@@ -939,6 +938,7 @@ modest_mail_operation_save_to_drafts (ModestMailOperation *self,
 
        /* Get account and set it into mail_operation */
        priv->account = g_object_ref (transport_account);
+       priv->op_type = MODEST_MAIL_OPERATION_TYPE_INFO;
 
        info = g_slice_new0 (SaveToDraftsInfo);
        info->transport_account = g_object_ref (transport_account);
@@ -1491,6 +1491,7 @@ modest_mail_operation_update_account (ModestMailOperation *self,
        priv->total = 0;
        priv->done  = 0;
        priv->status = MODEST_MAIL_OPERATION_STATUS_IN_PROGRESS;
+       priv->op_type = MODEST_MAIL_OPERATION_TYPE_RECEIVE;
 
        /* Get the store account */
        store_account = (TnyStoreAccount *)
@@ -1584,6 +1585,7 @@ modest_mail_operation_create_folder (ModestMailOperation *self,
        g_return_val_if_fail (name, NULL);
        
        priv = MODEST_MAIL_OPERATION_GET_PRIVATE (self);
+       priv->op_type = MODEST_MAIL_OPERATION_TYPE_INFO;
 
        /* Check for already existing folder */
        if (modest_tny_folder_has_subfolder_with_name (parent, name)) {
@@ -1656,6 +1658,7 @@ modest_mail_operation_remove_folder (ModestMailOperation *self,
        /* Get the account */
        account = modest_tny_folder_get_account (folder);
        priv->account = g_object_ref(account);
+       priv->op_type = MODEST_MAIL_OPERATION_TYPE_DELETE;
 
        /* Delete folder or move to trash */
        if (remove_to_trash) {
@@ -1845,6 +1848,7 @@ modest_mail_operation_xfer_folder (ModestMailOperation *self,
        error_msg = _("mail_in_ui_folder_move_target_error");
 
        /* Get account and set it into mail_operation */
+       priv->op_type = MODEST_MAIL_OPERATION_TYPE_RECEIVE;
        priv->account = modest_tny_folder_get_account (TNY_FOLDER(folder));
        priv->status = MODEST_MAIL_OPERATION_STATUS_IN_PROGRESS;
 
@@ -1932,6 +1936,7 @@ modest_mail_operation_rename_folder (ModestMailOperation *self,
 
        /* Get account and set it into mail_operation */
        priv->account = modest_tny_folder_get_account (TNY_FOLDER(folder));
+       priv->op_type = MODEST_MAIL_OPERATION_TYPE_INFO;
 
        /* Check folder rules */
        rules = modest_tny_folder_get_rules (TNY_FOLDER (folder));
@@ -2001,6 +2006,7 @@ modest_mail_operation_get_msg (ModestMailOperation *self,
        folder = tny_header_get_folder (header);
 
        priv->status = MODEST_MAIL_OPERATION_STATUS_IN_PROGRESS;
+       priv->op_type = MODEST_MAIL_OPERATION_TYPE_RECEIVE;
 
        /* Get message from folder */
        if (folder) {
@@ -2302,6 +2308,7 @@ modest_mail_operation_get_msgs_full (ModestMailOperation *self,
        /* Init mail operation */
        priv = MODEST_MAIL_OPERATION_GET_PRIVATE (self);
        priv->status = MODEST_MAIL_OPERATION_STATUS_IN_PROGRESS;
+       priv->op_type = MODEST_MAIL_OPERATION_TYPE_RECEIVE;
        priv->done = 0;
        priv->total = tny_list_get_length(header_list);
 
@@ -2398,7 +2405,7 @@ modest_mail_operation_remove_msg (ModestMailOperation *self,
 
        /* Get account and set it into mail_operation */
        priv->account = modest_tny_folder_get_account (TNY_FOLDER(folder));
-
+       priv->op_type = MODEST_MAIL_OPERATION_TYPE_DELETE;
        priv->status = MODEST_MAIL_OPERATION_STATUS_IN_PROGRESS;
 
        /* remove message from folder */
@@ -2460,7 +2467,7 @@ modest_mail_operation_remove_msgs (ModestMailOperation *self,
        
        /* Get account and set it into mail_operation */
        priv->account = modest_tny_folder_get_account (TNY_FOLDER(folder));
-
+       priv->op_type = MODEST_MAIL_OPERATION_TYPE_DELETE;
        priv->status = MODEST_MAIL_OPERATION_STATUS_IN_PROGRESS;
 
        /* remove message from folder */
@@ -2631,6 +2638,7 @@ modest_mail_operation_xfer_msgs (ModestMailOperation *self,
        priv->total = 1;
        priv->done = 0;
        priv->status = MODEST_MAIL_OPERATION_STATUS_IN_PROGRESS;
+       priv->op_type = MODEST_MAIL_OPERATION_TYPE_RECEIVE;
 
        /* Apply folder rules */
        rules = modest_tny_folder_get_rules (TNY_FOLDER (folder));
@@ -2795,6 +2803,7 @@ modest_mail_operation_refresh_folder  (ModestMailOperation *self,
 
        /* Get account and set it into mail_operation */
        priv->account = modest_tny_folder_get_account  (folder);
+       priv->op_type = MODEST_MAIL_OPERATION_TYPE_RECEIVE;
 
        /* Create the helper */
        helper = g_slice_new0 (RefreshAsyncHelper);
@@ -2823,10 +2832,8 @@ 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); */
-       g_assert (priv->account != NULL);
-       g_assert (priv->op_type != MODEST_MAIL_OPERATION_TYPE_UNKNOWN);
+       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
           wrapp this emission because we assume that this function is
index aa293ae..cf8fc2d 100644 (file)
@@ -190,14 +190,12 @@ GType        modest_mail_operation_get_type    (void) G_GNUC_CONST;
 
 /**
  * modest_mail_operation_new:
- * @id: a #ModestMailOperationId identification of operation type.
  * @source: a #GObject which creates this new operation.
  * 
  * Creates a new instance of class #ModestMailOperation, using parameters
  * to initialize its private structure. @source parameter may be NULL.
  **/
-ModestMailOperation*    modest_mail_operation_new     (ModestMailOperationTypeOperation type,
-                                                      GObject *source);
+ModestMailOperation*    modest_mail_operation_new     (GObject *source);
 
 /**
  * modest_mail_operation_new_with_error_handling:
@@ -211,8 +209,7 @@ ModestMailOperation*    modest_mail_operation_new     (ModestMailOperationTypeOp
  * @error_handler can not be NULL, but it will be returned an mail operation
  * object without error handling capability.
  **/
-ModestMailOperation*    modest_mail_operation_new_with_error_handling     (ModestMailOperationTypeOperation op_type,
-                                                                          GObject *source,
+ModestMailOperation*    modest_mail_operation_new_with_error_handling     (GObject *source,
                                                                           ErrorCheckingUserCallback error_handler,
                                                                           gpointer user_data);
 /**
index 8b29b6e..08d9e0a 100644 (file)
@@ -378,8 +378,7 @@ headers_action_mark_as_unread (TnyHeader *header,
 void modest_do_message_delete (TnyHeader *header, ModestWindow *win)
 {
        ModestMailOperation *mail_op = NULL;
-       mail_op = modest_mail_operation_new (MODEST_MAIL_OPERATION_TYPE_DELETE, 
-               win ? G_OBJECT(win) : NULL);
+       mail_op = modest_mail_operation_new (win ? G_OBJECT(win) : NULL);
        modest_mail_operation_queue_add (modest_runtime_get_mail_operation_queue (),
                                         mail_op);
        
@@ -395,8 +394,7 @@ void modest_do_message_delete (TnyHeader *header, ModestWindow *win)
 void modest_do_messages_delete (TnyList *headers, ModestWindow *win)
 {
        ModestMailOperation *mail_op = NULL;
-       mail_op = modest_mail_operation_new (MODEST_MAIL_OPERATION_TYPE_DELETE, 
-               win ? G_OBJECT(win) : NULL);
+       mail_op = modest_mail_operation_new (win ? G_OBJECT(win) : NULL);
        modest_mail_operation_queue_add (modest_runtime_get_mail_operation_queue (),
                                         mail_op);
        
@@ -1110,8 +1108,7 @@ _modest_ui_actions_open (TnyList *headers, ModestWindow *win)
        
        /* Open each message */
        if (tny_list_get_length (not_opened_headers) > 0) {
-               mail_op = modest_mail_operation_new_with_error_handling (MODEST_MAIL_OPERATION_TYPE_RECEIVE, 
-                                                                        G_OBJECT (win), 
+               mail_op = modest_mail_operation_new_with_error_handling (G_OBJECT (win), 
                                                                         modest_ui_actions_get_msgs_full_error_handler, 
                                                                         NULL);
                modest_mail_operation_queue_add (modest_runtime_get_mail_operation_queue (), mail_op);
@@ -1405,7 +1402,6 @@ reply_forward (ReplyForwardAction action, ModestWindow *win)
                        /* Retrieve messages */
                        if (do_retrieve) {
                                mail_op = modest_mail_operation_new_with_error_handling (
-                                       MODEST_MAIL_OPERATION_TYPE_RECEIVE, 
                                        G_OBJECT(win),
                                        modest_ui_actions_get_msgs_full_error_handler, 
                                        NULL);
@@ -1613,8 +1609,7 @@ modest_ui_actions_do_send_receive (const gchar *account_name, ModestWindow *win)
        /* Set send/receive operation in progress */    
        modest_main_window_notify_send_receive_initied (MODEST_MAIN_WINDOW(win));
 
-       mail_op = modest_mail_operation_new_with_error_handling (MODEST_MAIL_OPERATION_TYPE_RECEIVE,
-                                                                G_OBJECT (win),
+       mail_op = modest_mail_operation_new_with_error_handling (G_OBJECT (win),
                                                                 modest_ui_actions_send_receive_error_handler,
                                                                 NULL);
 
@@ -2152,7 +2147,7 @@ modest_ui_actions_on_save_to_drafts (GtkWidget *widget, ModestMsgEditWindow *edi
        from = modest_account_mgr_get_from_string (account_mgr, account_name);
 
        /* Create the mail operation */         
-       mail_operation = modest_mail_operation_new (MODEST_MAIL_OPERATION_TYPE_INFO, G_OBJECT(edit_window));
+       mail_operation = modest_mail_operation_new (G_OBJECT(edit_window));
        modest_mail_operation_queue_add (modest_runtime_get_mail_operation_queue (), mail_operation);
 
        modest_mail_operation_save_to_drafts (mail_operation,
@@ -2230,7 +2225,7 @@ modest_ui_actions_on_send (GtkWidget *widget, ModestMsgEditWindow *edit_window)
        gchar *from = modest_account_mgr_get_from_string (account_mgr, account_name);
 
        /* Create the mail operation */
-       ModestMailOperation *mail_operation = modest_mail_operation_new (MODEST_MAIL_OPERATION_TYPE_SEND, G_OBJECT(edit_window));
+       ModestMailOperation *mail_operation = modest_mail_operation_new (G_OBJECT(edit_window));
        modest_mail_operation_queue_add (modest_runtime_get_mail_operation_queue (), mail_operation);
 
        modest_mail_operation_send_new_mail (mail_operation,
@@ -2462,8 +2457,7 @@ modest_ui_actions_create_folder(GtkWidget *parent_window,
                                ModestMailOperation *mail_op;
                                TnyFolder *new_folder = NULL;
 
-                               mail_op  = modest_mail_operation_new_with_error_handling (MODEST_MAIL_OPERATION_TYPE_INFO,
-                                                                                         G_OBJECT(parent_window),
+                               mail_op  = modest_mail_operation_new_with_error_handling (G_OBJECT(parent_window),
                                                                                          modest_ui_actions_new_folder_error_handler,
                                                                                          parent_window);
 
@@ -2583,8 +2577,7 @@ modest_ui_actions_on_rename_folder (GtkAction *action,
                        GtkTreeSelection *sel = NULL;
 
                        mail_op = 
-                               modest_mail_operation_new_with_error_handling (MODEST_MAIL_OPERATION_TYPE_INFO,
-                                                                              G_OBJECT(main_window),
+                               modest_mail_operation_new_with_error_handling (G_OBJECT(main_window),
                                                                               modest_ui_actions_rename_folder_error_handler,
                                                                               main_window);
 
@@ -2674,8 +2667,7 @@ delete_folder (ModestMainWindow *main_window, gboolean move_to_trash)
 
                /* Create the mail operation */
                mail_op =
-                       modest_mail_operation_new_with_error_handling (MODEST_MAIL_OPERATION_TYPE_DELETE, 
-                                                                      G_OBJECT(main_window),
+                       modest_mail_operation_new_with_error_handling (G_OBJECT(main_window),
                                                                       modest_ui_actions_delete_folder_error_handler,
                                                                       NULL);
 
@@ -3122,8 +3114,7 @@ modest_ui_actions_on_paste (GtkAction *action,
                        helper->banner = modest_platform_animation_banner (GTK_WIDGET (window), NULL,
                                                                           _CS("ckct_nw_pasting"));
                        modest_email_clipboard_get_data (e_clipboard, &src_folder, &data, &delete);
-                       mail_op = modest_mail_operation_new (MODEST_MAIL_OPERATION_TYPE_RECEIVE, 
-                                                            G_OBJECT (window));
+                       mail_op = modest_mail_operation_new (G_OBJECT (window));
                        if (helper->banner != NULL) {
                                g_object_ref (G_OBJECT (helper->banner));
                                gtk_window_set_modal (GTK_WINDOW (helper->banner), FALSE);
@@ -3154,7 +3145,7 @@ modest_ui_actions_on_paste (GtkAction *action,
                modest_email_clipboard_get_data (clipboard, &src_folder, &data, &delete);
 
                /* Create a new mail operation */
-               mail_op = modest_mail_operation_new (MODEST_MAIL_OPERATION_TYPE_RECEIVE, G_OBJECT(window));
+               mail_op = modest_mail_operation_new (G_OBJECT(window));
                
                /* Get destination folder */
                folder_store = modest_folder_view_get_selected (MODEST_FOLDER_VIEW (focused_widget));
@@ -4114,8 +4105,7 @@ modest_ui_actions_on_main_window_remove_attachments (GtkAction *action,
        } else {
                ModestMailOperation *mail_op = NULL;
                modest_window_mgr_register_header (modest_runtime_get_window_mgr (), header);
-               mail_op = modest_mail_operation_new_with_error_handling (MODEST_MAIL_OPERATION_TYPE_RECEIVE,
-                                                                        G_OBJECT (win),
+               mail_op = modest_mail_operation_new_with_error_handling (G_OBJECT (win),
                                                                         modest_ui_actions_get_msgs_full_error_handler,
                                                                         NULL);
                modest_mail_operation_queue_add (modest_runtime_get_mail_operation_queue (), mail_op);
@@ -4188,8 +4178,7 @@ modest_ui_actions_xfer_messages_from_move_to (TnyFolderStore *dst_folder,
        }
 
        ModestMailOperation *mail_op = 
-               modest_mail_operation_new_with_error_handling (MODEST_MAIL_OPERATION_TYPE_RECEIVE, 
-                                                              G_OBJECT(win),
+               modest_mail_operation_new_with_error_handling (G_OBJECT(win),
                                                               modest_ui_actions_move_folder_error_handler,
                                                               NULL);
        modest_mail_operation_queue_add (modest_runtime_get_mail_operation_queue (), 
@@ -4261,8 +4250,7 @@ modest_ui_actions_on_main_window_move_to (GtkAction *action,
                         gtk_tree_selection_unselect_all (sel);
 
                         mail_op =
-                          modest_mail_operation_new_with_error_handling (MODEST_MAIL_OPERATION_TYPE_RECEIVE,
-                                                                         G_OBJECT(win),
+                          modest_mail_operation_new_with_error_handling (G_OBJECT(win),
                                                                          modest_ui_actions_move_folder_error_handler,
                                                                          src_folder);
                         modest_mail_operation_queue_add (modest_runtime_get_mail_operation_queue (),
@@ -4547,8 +4535,7 @@ modest_ui_actions_on_retrieve_msg_contents (GtkAction *action,
                return;
 
        /* Create mail operation */
-       mail_op = modest_mail_operation_new_with_error_handling (MODEST_MAIL_OPERATION_TYPE_RECEIVE, 
-                                                                G_OBJECT (window),
+       mail_op = modest_mail_operation_new_with_error_handling (G_OBJECT (window),
                                                                 modest_ui_actions_get_msgs_full_error_handler, 
                                                                 NULL);
        modest_mail_operation_queue_add (modest_runtime_get_mail_operation_queue (), mail_op);
index 2622fe5..14657b9 100644 (file)
@@ -1620,8 +1620,7 @@ drag_and_drop_from_header_view (GtkTreeModel *source_model,
                goto cleanup;
 
        /* Transfer messages */
-       mail_op = modest_mail_operation_new_with_error_handling (MODEST_MAIL_OPERATION_TYPE_RECEIVE, 
-                                                                NULL,
+       mail_op = modest_mail_operation_new_with_error_handling (NULL,
                                                                 modest_ui_actions_move_folder_error_handler,
                                                                 NULL);
 
@@ -1715,8 +1714,7 @@ drag_and_drop_from_folder_view (GtkTreeModel     *source_model,
 
                /* Do the mail operation */
                mail_op = 
-                       modest_mail_operation_new_with_error_handling (MODEST_MAIL_OPERATION_TYPE_RECEIVE, 
-                                                                      G_OBJECT (modest_window_mgr_get_main_window (mgr)),
+                       modest_mail_operation_new_with_error_handling (G_OBJECT (modest_window_mgr_get_main_window (mgr)),
                                                                       modest_ui_actions_move_folder_error_handler,
                                                                       folder);
 
index 0adc566..d42381e 100644 (file)
@@ -1171,7 +1171,7 @@ modest_header_view_set_folder (ModestHeaderView *self,
                info->user_data = user_data;
 
                /* Create the mail operation (source will be the parent widget) */
-               mail_op = modest_mail_operation_new (MODEST_MAIL_OPERATION_TYPE_RECEIVE, source);
+               mail_op = modest_mail_operation_new (source);
                modest_mail_operation_queue_add (modest_runtime_get_mail_operation_queue (),
                                                 mail_op);