* Fixes NB#91689. fixes a wrong check for ASCII
[modest] / src / modest-mail-operation.c
index 6bd42b3..5c02ae9 100644 (file)
@@ -601,11 +601,6 @@ modest_mail_operation_clone_state (ModestMailOperation *self)
        ModestMailOperationState *state;
        ModestMailOperationPrivate *priv;
 
-       /* FIXME: this should be fixed properly
-        * 
-        * in some cases, priv was NULL, so checking here to
-        * make sure.
-        */
        g_return_val_if_fail (self, NULL);
        priv = MODEST_MAIL_OPERATION_GET_PRIVATE (self);
        g_return_val_if_fail (priv, NULL);
@@ -1289,10 +1284,17 @@ static void
 update_account_send_mail (UpdateAccountInfo *info)
 {
        TnyTransportAccount *transport_account = NULL;
+       ModestTnyAccountStore *account_store;
+
+       account_store = modest_runtime_get_account_store ();
+
+       /* We don't try to send messages while sending mails is blocked */
+       if (modest_tny_account_store_is_send_mail_blocked (account_store))
+               return;
 
        /* Get the transport account */
        transport_account = (TnyTransportAccount *)
-               modest_tny_account_store_get_transport_account_for_open_connection (modest_runtime_get_account_store(),
+               modest_tny_account_store_get_transport_account_for_open_connection (account_store,
                                                                                    info->account_name);
 
        if (transport_account) {
@@ -1650,7 +1652,7 @@ recurse_folders_async_cb (TnyFolderStore *folder_store,
                                /* Add pending call */
                                info->pending_calls++;
                                
-                               tny_folder_store_get_folders_async (folder, folders, NULL,
+                               tny_folder_store_get_folders_async (folder, folders, NULL, FALSE,
                                                                    recurse_folders_async_cb, 
                                                                    NULL, info);
                                g_object_unref (folders);
@@ -1801,7 +1803,7 @@ modest_mail_operation_update_account (ModestMailOperation *self,
        /* Get all folders and continue in the callback */ 
        folders = tny_simple_list_new ();
        tny_folder_store_get_folders_async (TNY_FOLDER_STORE (priv->account),
-                                           folders, NULL,
+                                           folders, NULL, FALSE,
                                            recurse_folders_async_cb, 
                                            NULL, info);
        g_object_unref (folders);
@@ -2621,14 +2623,15 @@ remove_msgs_async_cb (TnyFolder *folder,
 {
        gboolean expunge, leave_on_server;
        const gchar *account_name;
-       const gchar *proto;
        TnyAccount *account;
-       ModestTransportStoreProtocol account_proto = MODEST_PROTOCOL_TRANSPORT_STORE_UNKNOWN;
+       ModestProtocolType account_proto = MODEST_PROTOCOL_REGISTRY_TYPE_INVALID;
        ModestMailOperation *self;
        ModestMailOperationPrivate *priv;
+       ModestProtocolRegistry *protocol_registry;
 
        self = (ModestMailOperation *) user_data;
        priv = MODEST_MAIL_OPERATION_GET_PRIVATE (self);
+       protocol_registry = modest_runtime_get_protocol_registry ();
 
        if (canceled || err) {
                /* If canceled by the user, ignore the error given by Tinymail */
@@ -2650,14 +2653,11 @@ remove_msgs_async_cb (TnyFolder *folder,
        leave_on_server =
                modest_account_mgr_get_leave_on_server (modest_runtime_get_account_mgr (),
                                                        account_name);  
-       proto = tny_account_get_proto (account);
+       account_proto = modest_tny_account_get_protocol_type (account);
        g_object_unref (account);
-
-       if (proto)
-               account_proto = modest_protocol_info_get_transport_store_protocol (proto);
        
-       if (((account_proto == MODEST_PROTOCOL_STORE_POP) && !leave_on_server) ||
-                   modest_tny_folder_is_remote_folder (folder) == FALSE)
+       if (( (modest_protocol_registry_protocol_type_has_leave_on_server (protocol_registry, account_proto) && !leave_on_server) ||
+             modest_tny_folder_is_remote_folder (folder) == FALSE))
                expunge = TRUE;
        else
                expunge = FALSE;
@@ -2774,9 +2774,6 @@ notify_progress_of_multiple_messages (ModestMailOperation *self,
 
        /* We know that tinymail sends us information about
         *  transferred bytes with this particular message
-        *  
-        *  (FIXME: this is very ugly, and no I (djcb) didn't write this code,
-        *  I just added the 'if' so we don't get runtime warning)
         */
        if (status->message)
                is_num_bytes = (g_ascii_strcasecmp (status->message, "Retrieving message") == 0);
@@ -2964,12 +2961,16 @@ modest_mail_operation_xfer_msgs (ModestMailOperation *self,
        TnyAccount *dst_account = NULL;
        gboolean leave_on_server;
        ModestMailOperationState *state;
+       ModestProtocolRegistry *protocol_registry;
+       ModestProtocolType account_protocol;
 
        g_return_if_fail (self && MODEST_IS_MAIL_OPERATION (self));
        g_return_if_fail (headers && TNY_IS_LIST (headers));
        g_return_if_fail (folder && TNY_IS_FOLDER (folder));
 
        priv = MODEST_MAIL_OPERATION_GET_PRIVATE(self);
+       protocol_registry = modest_runtime_get_protocol_registry ();
+
        priv->total = tny_list_get_length (headers);
        priv->done = 0;
        priv->status = MODEST_MAIL_OPERATION_STATUS_IN_PROGRESS;
@@ -3060,8 +3061,8 @@ modest_mail_operation_xfer_msgs (ModestMailOperation *self,
           this could cause an error if we're offline while
           transferring an already downloaded message from a POP
           account */
-        if (modest_protocol_info_get_transport_store_protocol (tny_account_get_proto (priv->account)) == 
-           MODEST_PROTOCOL_STORE_POP) {
+       account_protocol = modest_tny_account_get_protocol_type (priv->account);
+        if (modest_protocol_registry_protocol_type_has_leave_on_server (protocol_registry, account_protocol)) {
                const gchar *account_name;
 
                account_name = modest_tny_account_get_parent_modest_account_name_for_server_account (priv->account);