/* Show and hide toolbar items */
switch (mode) {
case TOOLBAR_MODE_NORMAL:
- if (sort_action)
- gtk_action_set_visible (sort_action, TRUE);
- if (refresh_action)
- gtk_action_set_visible (refresh_action, TRUE);
- if (priv->progress_toolitem) {
+/* if (sort_action) */
+/* gtk_action_set_visible (sort_action, TRUE); */
+/* if (refresh_action) */
+/* gtk_action_set_visible (refresh_action, TRUE); */
+/* if (priv->progress_toolitem) { */
+/* gtk_tool_item_set_expand (GTK_TOOL_ITEM (priv->progress_toolitem), FALSE); */
+/* gtk_widget_hide (priv->progress_toolitem); */
+/* } */
+/* if (priv->progress_bar) */
+/* gtk_widget_hide (priv->progress_bar); */
+
+/* if (cancel_action) */
+/* gtk_action_set_visible (cancel_action, FALSE); */
+ if (priv->sort_toolitem)
+ gtk_widget_show (priv->sort_toolitem);
+
+ if (priv->refresh_toolitem)
+ gtk_widget_show (priv->refresh_toolitem);
+
+ if (priv->progress_toolitem)
gtk_tool_item_set_expand (GTK_TOOL_ITEM (priv->progress_toolitem), FALSE);
- gtk_widget_hide (priv->progress_toolitem);
- }
if (priv->progress_bar)
- gtk_widget_hide (priv->progress_bar);
-
- if (cancel_action)
- gtk_action_set_visible (cancel_action, FALSE);
+ gtk_widget_hide (priv->progress_bar);
+
+ if (priv->cancel_toolitem)
+ gtk_widget_hide (priv->cancel_toolitem);
/* Hide toolbar if optimized view is enabled */
if (priv->optimized_view)
gtk_widget_hide (GTK_WIDGET(parent_priv->toolbar));
break;
case TOOLBAR_MODE_TRANSFER:
- if (sort_action)
- gtk_action_set_visible (sort_action, FALSE);
- if (refresh_action)
- gtk_action_set_visible (refresh_action, FALSE);
- if (cancel_action)
- gtk_action_set_visible (cancel_action, TRUE);
- if (priv->progress_toolitem) {
+/* if (sort_action) */
+/* gtk_action_set_visible (sort_action, FALSE); */
+/* if (refresh_action) */
+/* gtk_action_set_visible (refresh_action, FALSE); */
+/* if (cancel_action) */
+/* gtk_action_set_visible (cancel_action, TRUE); */
+/* if (priv->progress_toolitem) { */
+/* gtk_tool_item_set_expand (GTK_TOOL_ITEM (priv->progress_toolitem), TRUE); */
+/* gtk_widget_show (priv->progress_toolitem); */
+/* } */
+/* if (priv->progress_bar) */
+/* gtk_widget_show (priv->progress_bar); */
+
+ if (priv->sort_toolitem)
+ gtk_widget_hide (priv->sort_toolitem);
+
+ if (priv->refresh_toolitem)
+ gtk_widget_hide (priv->refresh_toolitem);
+
+ if (priv->progress_toolitem)
gtk_tool_item_set_expand (GTK_TOOL_ITEM (priv->progress_toolitem), TRUE);
- gtk_widget_show (priv->progress_toolitem);
- }
if (priv->progress_bar)
- gtk_widget_show (priv->progress_bar);
+ gtk_widget_show (priv->progress_bar);
+
+ if (priv->cancel_toolitem)
+ gtk_widget_show (priv->cancel_toolitem);
/* Show toolbar if it's hiden (optimized view ) */
if (priv->optimized_view)
switch (op_type) {
case MODEST_MAIL_OPERATION_TYPE_SEND:
case MODEST_MAIL_OPERATION_TYPE_RECEIVE:
+ case MODEST_MAIL_OPERATION_TYPE_OPEN:
mode = TOOLBAR_MODE_TRANSFER;
if (priv->current_toolbar_mode == TOOLBAR_MODE_NORMAL)
mode_changed = TRUE;
/* Mark as read */
flags = tny_header_get_flags (header);
if (!(flags & TNY_HEADER_FLAG_SEEN))
-/* tny_header_set_flags (header, flags | TNY_HEADER_FLAG_SEEN); */
tny_header_set_flags (header, TNY_HEADER_FLAG_SEEN);
- /* Msg download initied */
-
+ /* Msg download completed */
+ if (flags & TNY_HEADER_FLAG_CACHED)
+ mail_op = modest_mail_operation_new (MODEST_MAIL_OPERATION_TYPE_OPEN, G_OBJECT(window));
+ else
+ mail_op = modest_mail_operation_new (MODEST_MAIL_OPERATION_TYPE_RECEIVE, G_OBJECT(window));
+
/* New mail operation */
- mail_op = modest_mail_operation_new (MODEST_MAIL_OPERATION_TYPE_RECEIVE, G_OBJECT(window));
modest_mail_operation_queue_add (modest_runtime_get_mail_operation_queue (), mail_op);
modest_mail_operation_get_msg (mail_op, header, view_msg_cb, NULL);
g_object_unref (mail_op);
/* Mark as read */
flags = tny_header_get_flags (header);
if (!(flags & TNY_HEADER_FLAG_SEEN))
-/* tny_header_set_flags (header, flags | TNY_HEADER_FLAG_SEEN); */
tny_header_set_flags (header, TNY_HEADER_FLAG_SEEN);
+ /* Msg download completed */
+ if (flags & TNY_HEADER_FLAG_CACHED)
+ mail_op = modest_mail_operation_new (MODEST_MAIL_OPERATION_TYPE_OPEN, G_OBJECT(self));
+ else
+ mail_op = modest_mail_operation_new (MODEST_MAIL_OPERATION_TYPE_RECEIVE, G_OBJECT(self));
+
/* New mail operation */
- mail_op = modest_mail_operation_new (MODEST_MAIL_OPERATION_TYPE_RECEIVE, G_OBJECT(self));
modest_mail_operation_queue_add (modest_runtime_get_mail_operation_queue (), mail_op);
modest_mail_operation_get_msg (mail_op, header, view_msg_cb, NULL);
g_object_unref (mail_op);
/* Mark as read */
flags = tny_header_get_flags (header);
if (!(flags & TNY_HEADER_FLAG_SEEN))
-/* tny_header_set_flags (header, flags | TNY_HEADER_FLAG_SEEN); */
tny_header_set_flags (header, TNY_HEADER_FLAG_SEEN);
-
+
+ /* Msg download completed */
+ if (flags & TNY_HEADER_FLAG_CACHED)
+ mail_op = modest_mail_operation_new (MODEST_MAIL_OPERATION_TYPE_OPEN, G_OBJECT(window));
+ else
+ mail_op = modest_mail_operation_new (MODEST_MAIL_OPERATION_TYPE_RECEIVE, G_OBJECT(window));
+
/* New mail operation */
- mail_op = modest_mail_operation_new (MODEST_MAIL_OPERATION_TYPE_RECEIVE, G_OBJECT(window));
modest_mail_operation_queue_add (modest_runtime_get_mail_operation_queue (), mail_op);
modest_mail_operation_get_msg (mail_op, header, view_msg_cb, NULL);
switch (op_type) {
case MODEST_MAIL_OPERATION_TYPE_SEND:
case MODEST_MAIL_OPERATION_TYPE_RECEIVE:
+ case MODEST_MAIL_OPERATION_TYPE_OPEN:
mode = TOOLBAR_MODE_TRANSFER;
break;
default:
modest_progress_bar_add_operation (ModestProgressObject *self,
ModestMailOperation *mail_op)
{
- ModestProgressBarWidget *me;
- ObservableData *data;
- ModestProgressBarWidgetPrivate *priv;
+ ModestProgressBarWidget *me = NULL;
+ ObservableData *data = NULL;
+ ModestProgressBarWidgetPrivate *priv = NULL;
+ ModestMailOperationState *state = NULL;
me = MODEST_PROGRESS_BAR_WIDGET (self);
priv = MODEST_PROGRESS_BAR_WIDGET_GET_PRIVATE (me);
me);
if (priv->observables == NULL) {
priv->current = mail_op;
+
+ /* Call progress_change handler to initialize progress message */
+ state = g_malloc0(sizeof(ModestMailOperationState));
+ state->done = 0;
+ state->total = 0;
+ state->op_type = modest_mail_operation_get_type_operation (mail_op);;
+ on_progress_changed (mail_op, state, me);
+ g_free(state);
}
priv->observables = g_slist_append (priv->observables, data);
- /* Call progress_change handler to initialize progress message */
-/* on_progress_changed (mail_op, me); */
}
static gint
static void
_modest_ui_actions_open (TnyList *headers, ModestWindow *win)
{
- ModestWindowMgr *mgr;
- TnyIterator *iter;
- ModestMailOperation *mail_op;
- TnyList *not_opened_headers;
-
+ ModestWindowMgr *mgr = NULL;
+ TnyIterator *iter = NULL;
+ ModestMailOperation *mail_op1 = NULL;
+ ModestMailOperation *mail_op2 = NULL;
+ TnyList *not_opened_headers = NULL;
+ TnyList *not_opened_cached_headers = NULL;
+ TnyHeaderFlags flags;
+
/* Look if we already have a message view for each header. If
true, then remove the header from the list of headers to
open */
mgr = modest_runtime_get_window_mgr ();
iter = tny_list_create_iterator (headers);
not_opened_headers = tny_simple_list_new ();
+ not_opened_cached_headers = tny_simple_list_new ();
while (!tny_iterator_is_done (iter)) {
ModestWindow *window;
TnyHeader *header;
header = TNY_HEADER (tny_iterator_get_current (iter));
+ flags = tny_header_get_flags (header);
window = modest_window_mgr_find_window_by_header (mgr, header);
+
/* Do not open again the message and present the
window to the user */
if (window)
gtk_window_present (GTK_WINDOW (window));
- else
+ else if (!(flags & TNY_HEADER_FLAG_CACHED))
tny_list_append (not_opened_headers, G_OBJECT (header));
-
+ /* Check if msg has already been retreived */
+ else
+ tny_list_append (not_opened_cached_headers, G_OBJECT (header));
+
g_object_unref (header);
tny_iterator_next (iter);
}
- /* Open each message */
- 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);
- if (tny_list_get_length (not_opened_headers) > 1) {
- modest_mail_operation_get_msgs_full (mail_op,
- not_opened_headers,
- open_msg_cb,
- NULL,
- NULL);
- } else {
- TnyIterator *iter = tny_list_create_iterator (not_opened_headers);
- TnyHeader *header = TNY_HEADER (tny_iterator_get_current (iter));
- modest_mail_operation_get_msg (mail_op, header, open_msg_cb, NULL);
- g_object_unref (header);
- g_object_unref (iter);
+ /* Open each uncached message */
+ if (tny_list_get_length (not_opened_headers) > 0) {
+ mail_op1 = 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_op1);
+ if (tny_list_get_length (not_opened_headers) > 1) {
+ modest_mail_operation_get_msgs_full (mail_op1,
+ not_opened_headers,
+ open_msg_cb,
+ NULL,
+ NULL);
+ } else {
+ TnyIterator *iter = tny_list_create_iterator (not_opened_headers);
+ TnyHeader *header = TNY_HEADER (tny_iterator_get_current (iter));
+ modest_mail_operation_get_msg (mail_op1, header, open_msg_cb, NULL);
+ g_object_unref (header);
+ g_object_unref (iter);
+ }
+ }
+
+ /* Open each cached message */
+ if (tny_list_get_length (not_opened_cached_headers) > 0) {
+ mail_op2 = modest_mail_operation_new_with_error_handling (MODEST_MAIL_OPERATION_TYPE_OPEN,
+ G_OBJECT (win),
+ modest_ui_actions_get_msgs_full_error_handler,
+ NULL);
+ modest_mail_operation_queue_add (modest_runtime_get_mail_operation_queue (), mail_op2);
+ if (tny_list_get_length (not_opened_cached_headers) > 1) {
+ modest_mail_operation_get_msgs_full (mail_op2,
+ not_opened_headers,
+ open_msg_cb,
+ NULL,
+ NULL);
+ } else {
+ TnyIterator *iter = tny_list_create_iterator (not_opened_cached_headers);
+ TnyHeader *header = TNY_HEADER (tny_iterator_get_current (iter));
+ modest_mail_operation_get_msg (mail_op2, header, open_msg_cb, NULL);
+ g_object_unref (header);
+ g_object_unref (iter);
+ }
}
/* Clean */
- g_object_unref (not_opened_headers);
- g_object_unref (iter);
- g_object_unref (mail_op);
+ if (not_opened_headers != NULL)
+ g_object_unref (not_opened_headers);
+ if (not_opened_cached_headers != NULL)
+ g_object_unref (not_opened_cached_headers);
+ if (iter != NULL)
+ g_object_unref (iter);
+ if (mail_op1 != NULL)
+ g_object_unref (mail_op1);
+ if (mail_op2 != NULL)
+ g_object_unref (mail_op2);
}
void