2007-07-04 Murray Cumming <murrayc@murrayc.com>
authorMurray Cumming <murrayc@murrayc.com>
Wed, 4 Jul 2007 14:23:38 +0000 (14:23 +0000)
committerMurray Cumming <murrayc@murrayc.com>
Wed, 4 Jul 2007 14:23:38 +0000 (14:23 +0000)
* src/modest-ui-actions.c: (open_msg_cb): Add a printf() to provide a
clue when this has failed, because the error dialog is not always shown
(at least in earlier version).

(modest_ui_actions_get_msgs_full_error_handler): prinf() the actual
GError message, because the generic error dialog is not helpful.
I am getting
'This message is not currently available (can't let a new connection go online)'
when trying to open an IMAP message.

(_modest_ui_actions_open): Offer a connection when some messages would
have to be downloaded and we are offline.

pmo-trunk-r2569

ChangeLog2
src/modest-ui-actions.c

index 3b2d210..be4e2eb 100644 (file)
@@ -1,3 +1,18 @@
+2007-07-04   Murray Cumming <murrayc@murrayc.com>
+
+       * src/modest-ui-actions.c: (open_msg_cb): Add a printf() to provide a 
+       clue when this has failed, because the error dialog is not always shown 
+       (at least in earlier version).
+       
+       (modest_ui_actions_get_msgs_full_error_handler): prinf() the actual 
+       GError message, because the generic error dialog is not helpful.
+       I am getting
+       'This message is not currently available (can't let a new connection go online)'
+       when trying to open an IMAP message.
+       
+       (_modest_ui_actions_open): Offer a connection when some messages would 
+       have to be downloaded and we are offline.
+
 2007-07-04  Johannes Schmid <johannes.schmid@openismus.com>
 
        * src/widgets/modest-folder-view.c:
@@ -6,7 +21,7 @@
        NOTE: For the last two changes you need to update your tinymail copy
        because of API changes!
 
-2007-07-04  Johanens Schmid <johannes.schmid@openismus.com>
+2007-07-04  Johannes Schmid <johannes.schmid@openismus.com>
 
        * src/modest-tny-local-folders-account.c:
        Set the folder type for the TnyMergeFolder to TNY_MERGE_FOLDER_OUTBOX
index b99cf71..b26c725 100644 (file)
@@ -645,8 +645,11 @@ open_msg_cb (ModestMailOperation *mail_op,
        /* Do nothing if there was any problem with the mail
           operation. The error will be shown by the error_handler of
           the mail operation */
-       if (!modest_ui_actions_msg_retrieval_check (mail_op, header, msg))
+       if (!modest_ui_actions_msg_retrieval_check (mail_op, header, msg)) {
+               printf ("DEBUG: %s: modest_ui_actions_msg_retrieval_check() failed.\n", 
+                       __FUNCTION__);
                return;
+       }
 
        parent_win = (ModestWindow *) modest_mail_operation_get_source (mail_op);
        folder = tny_header_get_folder (header);
@@ -739,6 +742,8 @@ modest_ui_actions_get_msgs_full_error_handler (ModestMailOperation *mail_op,
        GObject *win = modest_mail_operation_get_source (mail_op);
 
        error = modest_mail_operation_get_error (mail_op);
+       printf ("DEBUG: %s: Error: code=%d, text=%s\n", __FUNCTION__, error->code, error->message);
        if (error->code == MODEST_MAIL_OPERATION_ERROR_MESSAGE_SIZE_LIMIT) {
 
                modest_platform_run_information_dialog ((win) ? GTK_WINDOW (win) : NULL,
@@ -798,9 +803,6 @@ _modest_ui_actions_open (TnyList *headers, ModestWindow *win)
                                g_warning ("debug: header %p already registered, waiting for window",
                                           header);
                } else {
-                       /* register the header before actually creating the window */
-                       modest_window_mgr_register_header (mgr, header);
-                               
                        if (!(flags & TNY_HEADER_FLAG_CACHED))
                                tny_list_append (not_opened_headers, G_OBJECT (header));
                        /* Check if msg has already been retreived */
@@ -810,6 +812,47 @@ _modest_ui_actions_open (TnyList *headers, ModestWindow *win)
                g_object_unref (header);
                tny_iterator_next (iter);
        }
+       g_object_unref (iter);
+       iter = NULL;
+       
+       /* If some messages would have to be downloaded, ask the user to 
+        * make a connection. It's generally easier to do this here (in the mainloop) 
+        * than later in a thread:
+        */
+       if (tny_list_get_length (not_opened_cached_headers) > 0) {
+               gboolean connected = modest_platform_connect_and_wait (GTK_WINDOW (win));
+               
+               /* Don't go further if a connection would be necessary but none is available: */
+               if (!connected) {
+                       g_object_unref (not_opened_headers);
+                       g_object_unref (not_opened_cached_headers);
+                       return;
+               }
+       }
+       
+       /* Register the headers before actually creating the windows: */
+       TnyIterator *iter_not_opened = tny_list_create_iterator (not_opened_headers);
+       while (!tny_iterator_is_done (iter_not_opened)) {
+               TnyHeader *header = TNY_HEADER (tny_iterator_get_current (iter_not_opened));
+               modest_window_mgr_register_header (mgr, header);
+               g_object_unref (header);
+               
+               tny_iterator_next (iter_not_opened);
+       }
+       g_object_unref (iter_not_opened);
+       iter_not_opened = NULL;
+       
+       TnyIterator *iter_cached = tny_list_create_iterator (not_opened_cached_headers);
+       while (!tny_iterator_is_done (iter_cached)) {
+               TnyHeader *header = TNY_HEADER (tny_iterator_get_current (iter_cached));
+               modest_window_mgr_register_header (mgr, header);
+               g_object_unref (header);
+               
+               tny_iterator_next (iter_cached);
+       }
+       g_object_unref (iter_cached);
+       iter_cached = NULL;
+       
        
        /* Open each uncached message */
        if (tny_list_get_length (not_opened_headers) > 0) {