* Fixes a very stupid bug by myself that was preventing opening messages in offline mode
pmo-trunk-r3873
response = gtk_dialog_run (GTK_DIALOG(dialog));
gtk_widget_destroy (dialog);
- /* TODO implement confirmation dialog */
+ return response;
+}
+
+gint
+modest_platform_run_confirmation_dialog_with_buttons (GtkWindow *parent_window,
+ const gchar *message,
+ const gchar *button_accept,
+ const gchar *button_cancel)
+{
+ gint response;
+ GtkWidget *dialog;
+
+ dialog = gtk_dialog_new_with_buttons (message,
+ parent_window,
+ GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT,
+ button_accept,
+ GTK_RESPONSE_ACCEPT,
+ button_cancel,
+ GTK_RESPONSE_CANCEL,
+ NULL);
+
+ response = gtk_dialog_run (GTK_DIALOG(dialog));
+ gtk_widget_destroy (dialog);
+
return response;
}
return response;
}
+
+gint
+modest_platform_run_confirmation_dialog_with_buttons (GtkWindow *parent_window,
+ const gchar *message,
+ const gchar *button_accept,
+ const gchar *button_cancel)
+{
+ GtkWidget *dialog;
+ gint response;
+
+ dialog = hildon_note_new_confirmation_add_buttons (parent_window, message,
+ button_accept, GTK_RESPONSE_ACCEPT,
+ button_cancel, GTK_RESPONSE_CANCEL,
+ NULL);
+ modest_window_mgr_set_modal (modest_runtime_get_window_mgr (),
+ GTK_WINDOW (dialog));
+
+ response = gtk_dialog_run (GTK_DIALOG (dialog));
+
+ on_destroy_dialog (GTK_DIALOG(dialog));
+
+ while (gtk_events_pending ())
+ gtk_main_iteration ();
+
+ return response;
+}
gint
modest_platform_run_yes_no_dialog (GtkWindow *parent_window,
gboolean poke_all;
TnyFolderObserver *inbox_observer;
guint update_timeout;
+ RetrieveAllCallback retrieve_all_cb;
} UpdateAccountInfo;
ModestAccountMgr *mgr;
ModestAccountRetrieveType retrieve_type;
TnyList *new_headers = NULL;
- gboolean headers_only;
+ gboolean headers_only, ignore_limit;
TnyTransportAccount *transport_account;
ModestTnySendQueue *send_queue;
/* Order by date */
g_ptr_array_sort (new_headers_array, (GCompareFunc) compare_headers_by_date);
- /* TODO: Ask the user, instead of just failing,
- * showing mail_nc_msg_count_limit_exceeded, with 'Get
- * all' and 'Newest only' buttons. */
+ /* Ask the users if they want to retrieve all the messages
+ even though the limit was exceeded */
+ ignore_limit = FALSE;
if (new_headers_array->len > retrieve_limit) {
- /* TODO */
+ /* Ask the user if a callback has been specified and
+ if the mail operation has a source (this means that
+ was invoked by the user and not automatically by a
+ D-Bus method) */
+ if (info->retrieve_all_cb && priv->source)
+ ignore_limit = info->retrieve_all_cb (priv->source,
+ new_headers_array->len,
+ retrieve_limit);
}
if (!headers_only) {
const gint msg_list_size = compute_message_array_size (new_headers_array);
priv->done = 0;
- priv->total = MIN (new_headers_array->len, retrieve_limit);
+ if (ignore_limit)
+ priv->total = new_headers_array->len;
+ else
+ priv->total = MIN (new_headers_array->len, retrieve_limit);
while (msg_num < priv->total) {
TnyHeader *header = TNY_HEADER (g_ptr_array_index (new_headers_array, msg_num));
TnyFolder *folder = tny_header_get_folder (header);
modest_mail_operation_update_account (ModestMailOperation *self,
const gchar *account_name,
gboolean poke_all,
+ RetrieveAllCallback retrieve_all_cb,
UpdateAccountCallback callback,
gpointer user_data)
{
info->callback = callback;
info->user_data = user_data;
info->update_timeout = g_timeout_add (250, timeout_notify_progress, self);
+ info->retrieve_all_cb = retrieve_all_cb;
/* Set account busy */
modest_account_mgr_set_account_busy (modest_runtime_get_account_mgr (), account_name, TRUE);
TnyList *new_headers,
gpointer user_data);
-
/**
* SaveToDraftsCallback:
*
gpointer user_data);
+typedef gboolean (*RetrieveAllCallback) (GObject *source,
+ guint num_msgs,
+ guint limit);
+
/* This struct represents the internal state of a mail operation in a
given time */
typedef struct {
void modest_mail_operation_update_account (ModestMailOperation *self,
const gchar *account_name,
gboolean poke_all,
+ RetrieveAllCallback retrieve_all_cb,
UpdateAccountCallback callback,
gpointer user_data);
gint modest_platform_run_confirmation_dialog (GtkWindow *parent_window,
const gchar *message);
+
+/**
+ * modest_platform_run_confirmation_dialog_with_buttons:
+ * @parent_window: the parent #GtkWindow of the dialog
+ * @message: the message to show to the user
+ * @button_accept: the text to show in the label of the accept button
+ * @button_cancel: the text to show in the label of the cancel button
+ *
+ * runs a confirmation dialog with the given values for the buttons
+ *
+ * Returns: GTK_RESPONSE_OK or GTK_RESPONSE_CANCEL
+ **/
+gint
+modest_platform_run_confirmation_dialog_with_buttons (GtkWindow *parent_window,
+ const gchar *message,
+ const gchar *button_accept,
+ const gchar *button_cancel);
+
/**
* modest_platform_run_yes_no_dialog:
* @parent_window: the parent #GtkWindow of the dialog
not_opened_headers = TNY_LIST (user_data);
status = tny_account_get_connection_status (account);
- if (err || canceled ||
- (modest_tny_folder_store_is_remote (TNY_FOLDER_STORE (account)) &&
- status != TNY_CONNECTION_STATUS_CONNECTED)) {
+ if (err || canceled) {
/* TODO: Show an error ? */
goto clean;
}
g_object_unref (source);
}
+gboolean
+retrieve_all_messages_cb (GObject *source,
+ guint num_msgs,
+ guint retrieve_limit)
+{
+ GtkWindow *window;
+ gchar *msg;
+ gint response;
+
+ window = GTK_WINDOW (source);
+ msg = g_strdup_printf (_("mail_nc_msg_count_limit_exceeded"),
+ num_msgs, retrieve_limit);
+
+ /* Ask the user if they want to retrieve all the messages */
+ response =
+ modest_platform_run_confirmation_dialog_with_buttons (window, msg,
+ _("mcen_bd_get_all"),
+ _("mcen_bd_newest_only"));
+ /* Free and return */
+ g_free (msg);
+ return (response == GTK_RESPONSE_ACCEPT) ? TRUE : FALSE;
+}
+
typedef struct {
TnyAccount *account;
ModestWindow *win;
modest_main_window_notify_send_receive_initied (MODEST_MAIN_WINDOW (info->win));
}
- mail_op = modest_mail_operation_new_with_error_handling (G_OBJECT (info->win),
+ mail_op = modest_mail_operation_new_with_error_handling ((info->win) ? G_OBJECT (info->win) : NULL,
modest_ui_actions_send_receive_error_handler,
NULL, NULL);
/* Send & receive. */
modest_mail_operation_queue_add (modest_runtime_get_mail_operation_queue (), mail_op);
modest_mail_operation_update_account (mail_op, info->account_name, (info->win) ? FALSE : TRUE,
+ (info->win) ? retrieve_all_messages_cb : NULL,
new_messages_arrived, info->win);
g_object_unref (G_OBJECT (mail_op));