account = tny_folder_get_account(TNY_FOLDER(folder));
}
- if (!account && !TNY_IS_ACCOUNT(account)) {
+ if (!TNY_IS_ACCOUNT(account)) {
g_warning ("%s: could not get account", __FUNCTION__);
return FALSE;
}
if (modest_msg_view_window_last_message_selected (win) &&
modest_msg_view_window_first_message_selected (win)) {
modest_ui_actions_on_close_window (NULL, MODEST_WINDOW (win));
- } else if (!modest_msg_view_window_select_next_message (win)) {
+ } else if (!modest_msg_view_window_select_next_message (win) &&
+ !modest_msg_view_window_select_previous_message (win)) {
gboolean ret_value;
g_signal_emit_by_name (G_OBJECT (win), "delete-event", NULL, &ret_value);
}
error = modest_mail_operation_get_error (mail_op);
/* Show error */
- modest_platform_run_information_dialog ((GtkWindow *) win, err_msg);
+ if (err_msg)
+ modest_platform_run_information_dialog ((GtkWindow *) win, err_msg);
if (win)
g_object_unref (win);
switch (rf_helper->action) {
case ACTION_REPLY:
new_msg =
- modest_tny_msg_create_reply_msg (msg, header, from, signature,
+ modest_tny_msg_create_reply_msg (msg, header, from,
+ (use_signature) ? signature : NULL,
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, header, from, signature, rf_helper->reply_forward_type,
+ modest_tny_msg_create_reply_msg (msg, header, from,
+ (use_signature) ? signature : NULL,
+ rf_helper->reply_forward_type,
MODEST_TNY_MSG_REPLY_MODE_ALL);
edit_type = MODEST_EDIT_TYPE_REPLY;
break;
case ACTION_FORWARD:
new_msg =
- modest_tny_msg_create_forward_msg (msg, from, signature, rf_helper->reply_forward_type);
+ modest_tny_msg_create_forward_msg (msg, from, (use_signature) ? signature : NULL,
+ rf_helper->reply_forward_type);
edit_type = MODEST_EDIT_TYPE_FORWARD;
break;
default:
send&receive was invoked by the user then do not show any
visual notification, only play a sound and activate the LED
(for the Maemo version) */
- if ((new_headers != NULL) && (tny_list_get_length (new_headers) > 0))
+ if (TNY_IS_LIST(new_headers) && (tny_list_get_length (new_headers)) > 0)
modest_platform_on_new_headers_received (new_headers,
show_visual_notifications);
MODEST_MAIL_OPERATION_ERROR_ITEM_NOT_FOUND,
"modest: could not find send queue for account\n");
} else {
- /* Keeep messages in outbox folder */
- tny_send_queue_cancel (send_queue, FALSE, &error);
- }
+ /* Cancel the current send */
+ tny_account_cancel (TNY_ACCOUNT (transport_account));
+
+ /* Suspend all pending messages */
+ tny_send_queue_cancel (send_queue, TNY_SEND_QUEUE_CANCEL_ACTION_SUSPEND, &error);
+ }
frees:
if (transport_account != NULL)
g_object_unref(edit_window);
}
-void
+gboolean
modest_ui_actions_on_save_to_drafts (GtkWidget *widget, ModestMsgEditWindow *edit_window)
{
TnyTransportAccount *transport_account;
MsgData *data;
gchar *account_name, *from;
ModestAccountMgr *account_mgr;
- char *info_text;
+/* char *info_text; */
+ gboolean had_error = FALSE;
+ guint64 available_disk, expected_size;
+ gint parts_count;
+ guint64 parts_size;
- g_return_if_fail (MODEST_IS_MSG_EDIT_WINDOW(edit_window));
+ g_return_val_if_fail (MODEST_IS_MSG_EDIT_WINDOW(edit_window), FALSE);
data = modest_msg_edit_window_get_msg_data (edit_window);
+ /* Check size */
+ available_disk = modest_folder_available_space (NULL);
+ modest_msg_edit_window_get_parts_size (edit_window, &parts_count, &parts_size);
+ expected_size = modest_tny_msg_estimate_size (data->plain_body,
+ data->html_body,
+ parts_count,
+ parts_size);
+
+ if ((available_disk != -1) && expected_size > available_disk) {
+ modest_msg_edit_window_free_msg_data (edit_window, data);
+
+ modest_platform_information_banner (NULL, NULL, dgettext("ke-recv", "cerm_device_memory_full"));
+ return FALSE;
+ }
+
account_name = g_strdup (data->account_name);
account_mgr = modest_runtime_get_account_mgr();
if (!account_name)
if (!account_name) {
g_printerr ("modest: no account found\n");
modest_msg_edit_window_free_msg_data (edit_window, data);
- return;
+ return FALSE;
}
if (!strcmp (account_name, MODEST_LOCAL_FOLDERS_ACCOUNT_ID)) {
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);
- return;
+ return FALSE;
}
from = modest_account_mgr_get_from_string (account_mgr, account_name);
data->priority_flags,
on_save_to_drafts_cb,
g_object_ref(edit_window));
- info_text = g_strdup_printf (_("mail_va_saved_to_drafts"), _("mcen_me_folder_drafts"));
- modest_platform_information_banner (NULL, NULL, info_text);
+
+/* info_text = g_strdup_printf (_("mail_va_saved_to_drafts"), _("mcen_me_folder_drafts")); */
+ modest_platform_information_banner (NULL, NULL, _CS("sfil_ib_saving"));
+ modest_msg_edit_window_reset_modified (edit_window);
/* Frees */
- g_free (info_text);
g_free (from);
g_free (account_name);
g_object_unref (G_OBJECT (transport_account));
g_object_unref (G_OBJECT (mail_operation));
modest_msg_edit_window_free_msg_data (edit_window, data);
- modest_msg_edit_window_reset_modified (edit_window);
/* ** FIXME **
* If the drafts folder is selected then make the header view
*/
ModestMainWindow *win = MODEST_MAIN_WINDOW(modest_window_mgr_get_main_window(
modest_runtime_get_window_mgr(), FALSE));
- if (win != NULL) {
+ if (!had_error && win != NULL) {
ModestFolderView *view = MODEST_FOLDER_VIEW(modest_main_window_get_child_widget(
win, MODEST_MAIN_WINDOW_WIDGET_TYPE_FOLDER_VIEW));
if (view != NULL) {
if (folder != NULL) g_object_unref(folder);
}
}
+
+ return !had_error;
}
/* For instance, when clicking the Send toolbar button when editing a message: */
-void
+gboolean
modest_ui_actions_on_send (GtkWidget *widget, ModestMsgEditWindow *edit_window)
{
TnyTransportAccount *transport_account = NULL;
+ gboolean had_error = FALSE;
+ guint64 available_disk, expected_size;
+ gint parts_count;
+ guint64 parts_size;
- g_return_if_fail (MODEST_IS_MSG_EDIT_WINDOW(edit_window));
+ g_return_val_if_fail (MODEST_IS_MSG_EDIT_WINDOW(edit_window), TRUE);
if (!modest_msg_edit_window_check_names (edit_window, TRUE))
- return;
+ return TRUE;
/* FIXME: Code added just for testing. The final version will
use the send queue provided by tinymail and some
classifier */
MsgData *data = modest_msg_edit_window_get_msg_data (edit_window);
+ /* Check size */
+ available_disk = modest_folder_available_space (NULL);
+ modest_msg_edit_window_get_parts_size (edit_window, &parts_count, &parts_size);
+ expected_size = modest_tny_msg_estimate_size (data->plain_body,
+ data->html_body,
+ parts_count,
+ parts_size);
+
+ if ((available_disk != -1) && expected_size > available_disk) {
+ modest_msg_edit_window_free_msg_data (edit_window, data);
+
+ modest_platform_information_banner (NULL, NULL, dgettext("ke-recv", "cerm_device_memory_full"));
+ return FALSE;
+ }
+
ModestAccountMgr *account_mgr = modest_runtime_get_account_mgr();
gchar *account_name = g_strdup (data->account_name);
if (!account_name)
modest_msg_edit_window_free_msg_data (edit_window, data);
/* Run account setup wizard */
if (!modest_ui_actions_run_account_setup_wizard (MODEST_WINDOW(edit_window))) {
- return;
+ return TRUE;
}
}
modest_msg_edit_window_free_msg_data (edit_window, data);
/* Run account setup wizard */
if (!modest_ui_actions_run_account_setup_wizard(MODEST_WINDOW(edit_window)))
- return;
+ return TRUE;
}
gchar *from = modest_account_mgr_get_from_string (account_mgr, account_name);
if (modest_mail_operation_get_status (mail_operation) == MODEST_MAIL_OPERATION_STATUS_IN_PROGRESS)
modest_platform_information_banner (NULL, NULL, _("mcen_ib_outbox_waiting_to_be_sent"));
+
+ if (modest_mail_operation_get_error (mail_operation) != NULL) {
+ const GError *error = modest_mail_operation_get_error (mail_operation);
+ if (error->code == MODEST_MAIL_OPERATION_ERROR_INSTANCE_CREATION_FAILED) {
+ g_warning ("%s failed: %s\n", __FUNCTION__, (modest_mail_operation_get_error (mail_operation))->message);
+ modest_platform_information_banner (NULL, NULL, _CS("sfil_ni_not_enough_memory"));
+ had_error = TRUE;
+ }
+ }
/* Free data: */
g_free (from);
g_object_unref (G_OBJECT (mail_operation));
modest_msg_edit_window_free_msg_data (edit_window, data);
- modest_msg_edit_window_set_sent (edit_window, TRUE);
- /* Save settings and close the window: */
- modest_ui_actions_on_close_window (NULL, MODEST_WINDOW (edit_window));
+ if (!had_error) {
+ modest_msg_edit_window_set_sent (edit_window, TRUE);
+
+ /* Save settings and close the window: */
+ modest_ui_actions_on_close_window (NULL, MODEST_WINDOW (edit_window));
+ }
+
+ return !had_error;
}
void
if ((gpointer) local_account != (gpointer) folder_store &&
(gpointer) mmc_account != (gpointer) folder_store) {
+ const char *proto_name = tny_account_get_proto (TNY_ACCOUNT (folder_store));
+ ModestTransportStoreProtocol proto = MODEST_PROTOCOL_STORE_MAILDIR;
+ if (proto_name != NULL) {
+ proto = modest_protocol_info_get_transport_store_protocol (proto_name);
+ }
is_local_account = FALSE;
/* New button should be dimmed on remote
- account root */
- new_sensitive = FALSE;
+ POP account root */
+ new_sensitive = (proto != MODEST_PROTOCOL_STORE_POP);
}
g_object_unref (local_account);
}
if (MODEST_IS_MSG_VIEW_WINDOW (object)) {
ModestMsgViewWindow *self = MODEST_MSG_VIEW_WINDOW (object);
- if (!modest_msg_view_window_select_next_message (self))
- if (!modest_msg_view_window_select_previous_message (self))
- /* No more messages to view, so close this window */
- modest_ui_actions_on_close_window (NULL, MODEST_WINDOW(self));
+ if (modest_msg_view_window_last_message_selected (self) &&
+ modest_msg_view_window_first_message_selected (self)) {
+ modest_ui_actions_on_close_window (NULL, MODEST_WINDOW (self));
+ } else if (!modest_msg_view_window_select_next_message (self) &&
+ !modest_msg_view_window_select_previous_message (self)) {
+ /* No more messages to view, so close this window */
+ modest_ui_actions_on_close_window (NULL, MODEST_WINDOW(self));
+ }
} else if (MODEST_IS_MAIN_WINDOW (object) && helper->reference != NULL) {
GtkWidget *header_view;
GtkTreePath *path;
gchar *message = NULL;
/* Don't show anything if the user cancelled something */
- if (err->code == TNY_TRANSPORT_ACCOUNT_ERROR_SEND_USER_CANCEL)
+ if (err->code == TNY_SYSTEM_ERROR_CANCEL)
return;
/* Get the server name: */
/* Show the appropriate message text for the GError: */
switch (err->code) {
- case TNY_TRANSPORT_ACCOUNT_ERROR_SEND_HOST_LOOKUP_FAILED:
+ case TNY_SERVICE_ERROR_CONNECT:
message = g_strdup_printf (_("emev_ib_ui_smtp_server_invalid"), server_name);
break;
- case TNY_TRANSPORT_ACCOUNT_ERROR_SEND_SERVICE_UNAVAILABLE:
- message = g_strdup_printf (_("emev_ib_ui_smtp_server_invalid"), server_name);
- break;
- case TNY_TRANSPORT_ACCOUNT_ERROR_SEND_AUTHENTICATION_NOT_SUPPORTED:
+ case TNY_SERVICE_ERROR_AUTHENTICATE:
message = g_strdup_printf (_("emev_ni_ui_smtp_authentication_fail_error"), server_name);
break;
- case TNY_TRANSPORT_ACCOUNT_ERROR_SEND:
+ case TNY_SERVICE_ERROR_SEND:
message = g_strdup (_("emev_ib_ui_smtp_send_error"));
break;
default:
- g_warning ("%s: unexpected TNY_TRANSPORT_ACCOUNT_ERROR %d",
+ g_warning ("%s: unexpected ERROR %d",
__FUNCTION__, err->code);
message = g_strdup (_("emev_ib_ui_smtp_send_error"));
break;
#else
gtk_widget_queue_draw (header_view);
#endif
+
+ /* Rerun dimming rules, because the message could become deletable for example */
+ modest_window_check_dimming_rules_group (MODEST_WINDOW (main_window),
+ MODEST_DIMMING_RULES_TOOLBAR);
/* Free */
frees: