+/**
+ * Utility function that transfer messages from both the main window
+ * and the msg view window when using the "Move to" dialog
+ */
+static void
+modest_ui_actions_xfer_messages_from_move_to (TnyFolderStore *dst_folder,
+ ModestWindow *win)
+{
+ TnyList *headers = NULL;
+ gint response = 0;
+ TnyAccount *dst_account = NULL;
+ const gchar *proto_str = NULL;
+ gboolean dst_is_pop = FALSE;
+
+ if (!TNY_IS_FOLDER (dst_folder)) {
+ modest_platform_information_banner (GTK_WIDGET (win),
+ NULL,
+ _CS("ckdg_ib_unable_to_move_to_current_location"));
+ return;
+ }
+
+ dst_account = tny_folder_get_account (TNY_FOLDER (dst_folder));
+ proto_str = tny_account_get_proto (dst_account);
+ dst_is_pop = (modest_protocol_info_get_transport_store_protocol (proto_str) ==
+ MODEST_PROTOCOL_STORE_POP);
+ g_object_unref (dst_account);
+
+ /* Get selected headers */
+ headers = get_selected_headers (MODEST_WINDOW (win));
+
+ if (dst_is_pop) {
+ modest_platform_information_banner (GTK_WIDGET (win),
+ NULL,
+ ngettext("mail_in_ui_folder_move_target_error",
+ "mail_in_ui_folder_move_targets_error",
+ tny_list_get_length (headers)));
+ g_object_unref (headers);
+ return;
+ }
+
+ /* Ask for user confirmation */
+ response = msgs_move_to_confirmation (GTK_WINDOW (win),
+ TNY_FOLDER (dst_folder),
+ headers);
+
+ /* Transfer messages */
+ if (response == GTK_RESPONSE_OK) {
+ ModestMailOperation *mail_op =
+ modest_mail_operation_new_with_error_handling (MODEST_MAIL_OPERATION_TYPE_RECEIVE,
+ G_OBJECT(win),
+ modest_ui_actions_move_folder_error_handler,
+ NULL);
+ modest_mail_operation_queue_add (modest_runtime_get_mail_operation_queue (),
+ mail_op);
+
+ modest_mail_operation_xfer_msgs (mail_op,
+ headers,
+ TNY_FOLDER (dst_folder),
+ TRUE,
+ (MODEST_IS_MSG_VIEW_WINDOW (win)) ? transfer_msgs_from_viewer_cb : NULL,
+ NULL);
+
+ g_object_unref (G_OBJECT (mail_op));
+ }
+ g_object_unref (headers);
+}
+
+