+ dst_account = modest_tny_folder_get_account (folder);
+
+ if (priv->account == dst_account) {
+ /* Transfer all messages at once using the fast
+ * method. Note that depending on the server this
+ * might not be that fast, and might not be
+ * user-cancellable either */
+ helper->headers = g_object_ref (headers);
+ helper->more_msgs = NULL;
+ } else {
+ /* Transfer messages one by one so the user can cancel
+ * the operation */
+ GObject *hdr;
+ helper->headers = tny_simple_list_new ();
+ helper->more_msgs = tny_list_create_iterator (headers);
+ hdr = tny_iterator_get_current (helper->more_msgs);
+ tny_list_append (helper->headers, hdr);
+ g_object_unref (hdr);
+ }
+
+ /* If leave_on_server is set to TRUE then don't use
+ delete_original, we always pass FALSE. This is because
+ otherwise tinymail will try to sync the source folder and
+ 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) {
+ const gchar *account_name;
+
+ account_name = modest_tny_account_get_parent_modest_account_name_for_server_account (priv->account);
+ leave_on_server = modest_account_mgr_get_leave_on_server (modest_runtime_get_account_mgr (),
+ account_name);
+ } else {
+ leave_on_server = FALSE;
+ }
+
+ /* Do not delete messages if leave on server is TRUE */
+ helper->delete = (leave_on_server) ? FALSE : delete_original;