#include "modest-tny-platform-factory.h"
#include "modest-platform.h"
#include <tny-mime-part.h>
+#include <tny-camel-folder.h>
+#include <tny-camel-imap-folder.h>
+#include <tny-camel-pop-folder.h>
#ifdef MODEST_PLATFORM_MAEMO
#include "maemo/modest-osso-state-saving.h"
run_account_setup_wizard (ModestWindow *win)
{
ModestEasysetupWizardDialog *wizard;
-
+
g_return_if_fail (MODEST_IS_WINDOW(win));
wizard = modest_easysetup_wizard_dialog_new ();
modest_msg_view_window_first_message_selected (win)) {
modest_ui_actions_on_close_window (NULL, MODEST_WINDOW (win));
} else {
- modest_msg_view_window_select_next_message (win);
+ if (!modest_msg_view_window_select_next_message (win)) {
+ gboolean ret_value;
+ g_signal_emit_by_name (G_OBJECT (win), "delete-event", NULL, &ret_value);
+ }
}
}
return;
}
+ /* Get the headers, either from the header view (if win is the main window),
+ * or from the message view window: */
header_list = get_selected_headers (win);
if (!header_list) return;
-
+
/* Check if any of the headers are already opened, or in the process of being opened */
if (MODEST_IS_MAIN_WINDOW (win)) {
gboolean found;
GList *sel_list = NULL, *tmp = NULL;
GtkTreeRowReference *row_reference = NULL;
GtkTreePath *next_path = NULL;
+ TnyFolder *folder = NULL;
+ GError *err = NULL;
/* Find last selected row */
if (MODEST_IS_MAIN_WINDOW (win)) {
gtk_tree_row_reference_free (row_reference);
}
+ /* Get folder from first header and sync it */
+ iter = tny_list_create_iterator (header_list);
+ header = TNY_HEADER (tny_iterator_get_current (iter));
+ folder = tny_header_get_folder (header);
+ 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, &err); /* 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, &err); /\* TRUE --> expunge *\/ */
+ else
+ /* local folders */
+/* tny_folder_sync_async(folder, TRUE, NULL, NULL, NULL); /\* TRUE --> expunge *\/ */
+ tny_folder_sync (folder, TRUE, &err); /* TRUE --> expunge */
+
+ if (err != NULL) {
+ printf ("DEBUG: %s: Error: code=%d, text=%s\n", __FUNCTION__, err->code, err->message);
+ g_error_free(err);
+ }
+
+ g_object_unref (header);
+ g_object_unref (iter);
+ g_object_unref (folder);
+
/* Update toolbar dimming state */
modest_ui_actions_check_toolbar_dimming_rules (MODEST_WINDOW (main_window));
switch (rf_helper->action) {
case ACTION_REPLY:
new_msg =
- modest_tny_msg_create_reply_msg (msg, from, signature,
+ modest_tny_msg_create_reply_msg (msg, header, from, signature,
rf_helper->reply_forward_type,
MODEST_TNY_MSG_REPLY_MODE_SENDER);
break;
case ACTION_REPLY_TO_ALL:
new_msg =
- modest_tny_msg_create_reply_msg (msg, from, signature, rf_helper->reply_forward_type,
+ modest_tny_msg_create_reply_msg (msg, header, from, signature, rf_helper->reply_forward_type,
MODEST_TNY_MSG_REPLY_MODE_ALL);
edit_type = MODEST_EDIT_TYPE_REPLY;
break;
if (account)
g_object_unref (G_OBJECT (account));
/* g_object_unref (msg); */
- g_object_unref (header);
free_reply_forward_helper (rf_helper);
}
TnyList *header_list = NULL;
ReplyForwardHelper *rf_helper = NULL;
guint reply_forward_type;
- gboolean continue_download;
+ gboolean continue_download = TRUE;
+ gboolean do_retrieve = TRUE;
g_return_if_fail (MODEST_IS_WINDOW(win));
if (!header_list)
return;
+ reply_forward_type =
+ modest_conf_get_int (modest_runtime_get_conf (),
+ (action == ACTION_FORWARD) ? MODEST_CONF_FORWARD_TYPE : MODEST_CONF_REPLY_TYPE,
+ NULL);
+
/* Check that the messages have been previously downloaded */
- continue_download = download_uncached_messages (header_list, GTK_WINDOW (win), TRUE);
+ do_retrieve = (action == ACTION_FORWARD) || (reply_forward_type != MODEST_TNY_MSG_REPLY_TYPE_CITE);
+ if (do_retrieve)
+ continue_download = download_uncached_messages (header_list, GTK_WINDOW (win), TRUE);
if (!continue_download) {
g_object_unref (header_list);
return;
}
- reply_forward_type =
- modest_conf_get_int (modest_runtime_get_conf (),
- (action == ACTION_FORWARD) ? MODEST_CONF_FORWARD_TYPE : MODEST_CONF_REPLY_TYPE,
- NULL);
/* We assume that we can only select messages of the
same folder and that we reply all of them from the
same account. In fact the interface currently only
if (!msg || !header) {
if (msg)
g_object_unref (msg);
- if (header)
- g_object_unref (header);
g_printerr ("modest: no message found\n");
return;
} else {
reply_forward_cb (NULL, header, msg, rf_helper);
}
+ if (header)
+ g_object_unref (header);
} else {
TnyHeader *header;
TnyIterator *iter;
- /* Retrieve messages */
- 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);
- modest_mail_operation_queue_add (modest_runtime_get_mail_operation_queue (), mail_op);
-
/* Only reply/forward to one message */
iter = tny_list_create_iterator (header_list);
header = TNY_HEADER (tny_iterator_get_current (iter));
g_object_unref (iter);
if (header) {
- modest_mail_operation_get_msg (mail_op,
- header,
- reply_forward_cb,
- rf_helper);
+ /* 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);
+ modest_mail_operation_queue_add (
+ modest_runtime_get_mail_operation_queue (), mail_op);
+
+ modest_mail_operation_get_msg (mail_op,
+ header,
+ reply_forward_cb,
+ rf_helper);
+ /* Clean */
+ g_object_unref(mail_op);
+ } else {
+ /* we put a ref here to prevent double unref as the reply
+ * forward callback unrefs the header at its end */
+ reply_forward_cb (NULL, header, NULL, rf_helper);
+ }
-/* modest_mail_operation_get_msgs_full (mail_op, */
-/* header_list, */
-/* reply_forward_cb, */
-/* rf_helper, */
-/* free_reply_forward_helper); */
g_object_unref (header);
}
- /* Clean */
- g_object_unref(mail_op);
}
/* Free */
g_return_if_fail (MODEST_IS_MAIN_WINDOW(main_window));
g_return_if_fail (MODEST_IS_HEADER_VIEW (header_view));
+ /* in the case the folder is empty, show the empty folder message and focus
+ * folder view */
+ if (!header && gtk_widget_is_focus (GTK_WIDGET (header_view))) {
+ if (modest_header_view_is_empty (header_view)) {
+ TnyFolder *folder = modest_header_view_get_folder (header_view);
+ GtkWidget *folder_view =
+ modest_main_window_get_child_widget (main_window,
+ MODEST_WIDGET_TYPE_FOLDER_VIEW);
+ if (folder != NULL)
+ modest_folder_view_select_folder (MODEST_FOLDER_VIEW (folder_view), folder, FALSE);
+ gtk_widget_grab_focus (GTK_WIDGET (folder_view));
+ return;
+ }
+ }
/* If no header has been selected then exit */
if (!header)
return;
account_name = modest_account_mgr_get_default_account (account_mgr);
if (!account_name) {
- g_printerr ("modest: no account found\n");
+ /* Run account setup wizard */
+ run_account_setup_wizard(MODEST_WINDOW(edit_window));
return;
}
(modest_runtime_get_account_store(),
account_name));
if (!transport_account) {
- g_printerr ("modest: no transport account found for '%s'\n", account_name);
- g_free (account_name);
- modest_msg_edit_window_free_msg_data (edit_window, data);
+ /* Run account setup wizard */
+ run_account_setup_wizard(MODEST_WINDOW(edit_window));
return;
}
gboolean finished = FALSE;
gint result;
gchar *folder_name = NULL, *suggested_name = NULL;
+ const gchar *proto_str = NULL;
+ TnyAccount *account;
+
+ if (TNY_IS_ACCOUNT (parent_folder))
+ account = g_object_ref (parent_folder);
+ else
+ account = tny_folder_get_account (TNY_FOLDER (parent_folder));
+ proto_str = tny_account_get_proto (TNY_ACCOUNT (account));
+
+ if (proto_str && modest_protocol_info_get_transport_store_protocol (proto_str) ==
+ MODEST_PROTOCOL_STORE_POP) {
+ finished = TRUE;
+ hildon_banner_show_information (NULL, NULL, _("mail_in_ui_folder_create_error"));
+ }
+ g_object_unref (account);
/* Run the new folder dialog */
while (!finished) {
modest_ui_actions_on_delete_folder (GtkAction *action,
ModestMainWindow *main_window)
{
+ GtkWidget *folder_view;
g_return_if_fail (MODEST_IS_MAIN_WINDOW(main_window));
delete_folder (main_window, FALSE);
+ folder_view = modest_main_window_get_child_widget (main_window,
+ MODEST_WIDGET_TYPE_FOLDER_VIEW);
+ if (!folder_view)
+ return;
+ modest_folder_view_select_first_inbox_or_local (MODEST_FOLDER_VIEW (folder_view));
}
void
{
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),
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),
ModestWindow *window)
{
g_return_if_fail (MODEST_IS_WINDOW (window));
-
+
/* Update dimmed */
modest_window_check_dimming_rules_group (window, "ModestMenuDimmingRules");
}