2005-09-02 [paul] 1.9.13cvs80
authorPaul Mangan <paul@claws-mail.org>
Fri, 2 Sep 2005 12:13:41 +0000 (12:13 +0000)
committerPaul Mangan <paul@claws-mail.org>
Fri, 2 Sep 2005 12:13:41 +0000 (12:13 +0000)
* src/imap.c
fix bug 795, 'Connection lost IMAP'
and add statusbar prints
Patch by Colin

ChangeLog-gtk2.claws
PATCHSETS
configure.ac
src/imap.c

index e1dba2884f04302877312f6288ac5ece82911f4f..a0eab692eafa0f20ef58c05492df0f5ae7420c02 100644 (file)
@@ -1,3 +1,10 @@
+2005-09-02 [paul]      1.9.13cvs80
+
+       * src/imap.c
+               fix bug 795, 'Connection lost IMAP'
+               and add statusbar prints
+               Patch by Colin
+
 2005-09-02 [paul]      1.9.13cvs79
 
        * src/compose.c
 2005-09-02 [paul]      1.9.13cvs79
 
        * src/compose.c
index 526c1537deca9cb0b42fdc7e91d588ca88fc5178..00b43a0d51841d0adfcc02370bbcd84bc22b3f9a 100644 (file)
--- a/PATCHSETS
+++ b/PATCHSETS
 ( cvs diff -u -r 1.179.2.64 -r 1.179.2.65 src/imap.c;  cvs diff -u -r 1.395.2.120 -r 1.395.2.121 src/summaryview.c;  ) > 1.9.13cvs77.patchset
 ( cvs diff -u -r 1.207.2.61 -r 1.207.2.62 src/folderview.c;  ) > 1.9.13cvs78.patchset
 ( cvs diff -u -r 1.382.2.158 -r 1.382.2.159 src/compose.c;  ) > 1.9.13cvs79.patchset
 ( cvs diff -u -r 1.179.2.64 -r 1.179.2.65 src/imap.c;  cvs diff -u -r 1.395.2.120 -r 1.395.2.121 src/summaryview.c;  ) > 1.9.13cvs77.patchset
 ( cvs diff -u -r 1.207.2.61 -r 1.207.2.62 src/folderview.c;  ) > 1.9.13cvs78.patchset
 ( cvs diff -u -r 1.382.2.158 -r 1.382.2.159 src/compose.c;  ) > 1.9.13cvs79.patchset
+( cvs diff -u -r 1.179.2.65 -r 1.179.2.66 src/imap.c;  ) > 1.9.13cvs80.patchset
index 045fb7357e07227d5bc7a59c9daddc4942a1de7d..c5f5d8258f13dca47e049b7095b4125e2c44225b 100644 (file)
@@ -11,7 +11,7 @@ MINOR_VERSION=9
 MICRO_VERSION=13
 INTERFACE_AGE=0
 BINARY_AGE=0
 MICRO_VERSION=13
 INTERFACE_AGE=0
 BINARY_AGE=0
-EXTRA_VERSION=79
+EXTRA_VERSION=80
 EXTRA_RELEASE=
 EXTRA_GTK2_VERSION=
 
 EXTRA_RELEASE=
 EXTRA_GTK2_VERSION=
 
index ffb281638de211dd6883de4749c5e1dece9ac3fd..e0fab6fb46410f4b8bb65992d1d7e6821890bb4b 100644 (file)
@@ -608,6 +608,38 @@ static gint imap_auth(IMAPSession *session, const gchar *user, const gchar *pass
        return ok;
 }
 
        return ok;
 }
 
+static IMAPSession *imap_reconnect_if_possible(Folder *folder, IMAPSession *session)
+{
+       RemoteFolder *rfolder = REMOTE_FOLDER(folder);
+       /* Check if this is the first try to establish a
+          connection, if yes we don't try to reconnect */
+       debug_print("reconnecting\n");
+       if (rfolder->session == NULL) {
+               log_warning(_("Connecting to %s failed"),
+                           folder->account->recv_server);
+               session_destroy(SESSION(session));
+               session = NULL;
+       } else {
+               log_warning(_("IMAP4 connection to %s has been"
+                           " disconnected. Reconnecting...\n"),
+                           folder->account->recv_server);
+               statusbar_print_all(_("IMAP4 connection to %s has been"
+                           " disconnected. Reconnecting...\n"),
+                           folder->account->recv_server);
+               SESSION(session)->state = SESSION_DISCONNECTED;
+               session_destroy(SESSION(session));
+               /* Clear folders session to make imap_session_get create
+                  a new session, because of rfolder->session == NULL
+                  it will not try to reconnect again and so avoid an
+                  endless loop */
+               rfolder->session = NULL;
+               session = imap_session_get(folder);
+               rfolder->session = SESSION(session);
+               statusbar_pop_all();
+       }
+       return session;
+}
+
 static IMAPSession *imap_session_get(Folder *folder)
 {
        RemoteFolder *rfolder = REMOTE_FOLDER(folder);
 static IMAPSession *imap_session_get(Folder *folder)
 {
        RemoteFolder *rfolder = REMOTE_FOLDER(folder);
@@ -658,30 +690,8 @@ static IMAPSession *imap_session_get(Folder *folder)
        if (time(NULL) - SESSION(session)->last_access_time > SESSION_TIMEOUT_INTERVAL) {
                /* verify that the session is still alive */
                if (imap_cmd_noop(session) != IMAP_SUCCESS) {
        if (time(NULL) - SESSION(session)->last_access_time > SESSION_TIMEOUT_INTERVAL) {
                /* verify that the session is still alive */
                if (imap_cmd_noop(session) != IMAP_SUCCESS) {
-                       /* Check if this is the first try to establish a
-                          connection, if yes we don't try to reconnect */
-                       if (rfolder->session == NULL) {
-                               log_warning(_("Connecting to %s failed"),
-                                           folder->account->recv_server);
-                               session_destroy(SESSION(session));
-                               session = NULL;
-                       } else {
-                               log_warning(_("IMAP4 connection to %s has been"
-                                           " disconnected. Reconnecting...\n"),
-                                           folder->account->recv_server);
-                               statusbar_print_all(_("IMAP4 connection to %s has been"
-                                           " disconnected. Reconnecting...\n"),
-                                           folder->account->recv_server);
-                               SESSION(session)->state = SESSION_DISCONNECTED;
-                               session_destroy(SESSION(session));
-                               /* Clear folders session to make imap_session_get create
-                                  a new session, because of rfolder->session == NULL
-                                  it will not try to reconnect again and so avoid an
-                                  endless loop */
-                               rfolder->session = NULL;
-                               session = imap_session_get(folder);
-                               statusbar_pop_all();
-                       }
+                       debug_print("disconnected!\n");
+                       session = imap_reconnect_if_possible(folder, session);
                }
        }
 
                }
        }
 
@@ -745,7 +755,10 @@ static IMAPSession *imap_session_new(Folder * folder,
                if(!prefs_common.no_recv_err_panel) {
                        alertpanel_error(_("Can't connect to IMAP4 server: %s:%d"),
                                         account->recv_server, port);
                if(!prefs_common.no_recv_err_panel) {
                        alertpanel_error(_("Can't connect to IMAP4 server: %s:%d"),
                                         account->recv_server, port);
-               }
+               } else {
+                       log_error(_("Can't connect to IMAP4 server: %s:%d"),
+                                        account->recv_server, port);
+               } 
                
                return NULL;
        }
                
                return NULL;
        }
@@ -2430,8 +2443,9 @@ static gint imap_cmd_fetch(IMAPSession *session, guint32 uid,
                g_free(data);
                return -1;
        }
                g_free(data);
                return -1;
        }
-
+       statusbar_print_all(_("Fetching message..."));
        result = GPOINTER_TO_INT(imap_cmd_fetch_thread(data));
        result = GPOINTER_TO_INT(imap_cmd_fetch_thread(data));
+       statusbar_pop_all();
        g_free(data);
        return result;
 }
        g_free(data);
        return result;
 }
@@ -2447,9 +2461,10 @@ static gint imap_cmd_append(IMAPSession *session, const gchar *destfolder,
        g_return_val_if_fail(file != NULL, IMAP_ERROR);
 
        flag_list = imap_flag_to_lep(flags);
        g_return_val_if_fail(file != NULL, IMAP_ERROR);
 
        flag_list = imap_flag_to_lep(flags);
+       statusbar_print_all(_("Adding messages..."));
        r = imap_threaded_append(session->folder, destfolder,
                         file, flag_list);
        r = imap_threaded_append(session->folder, destfolder,
                         file, flag_list);
-       
+       statusbar_pop_all();
        if (new_uid != NULL)
                *new_uid = 0;
 
        if (new_uid != NULL)
                *new_uid = 0;
 
@@ -2469,7 +2484,9 @@ static gint imap_cmd_copy(IMAPSession *session, struct mailimap_set * set,
        g_return_val_if_fail(set != NULL, IMAP_ERROR);
        g_return_val_if_fail(destfolder != NULL, IMAP_ERROR);
 
        g_return_val_if_fail(set != NULL, IMAP_ERROR);
        g_return_val_if_fail(destfolder != NULL, IMAP_ERROR);
 
+       statusbar_print_all(_("Copying messages..."));
        r = imap_threaded_copy(session->folder, set, destfolder);
        r = imap_threaded_copy(session->folder, set, destfolder);
+       statusbar_pop_all();
        if (r != MAILIMAP_NO_ERROR) {
                
                return IMAP_ERROR;
        if (r != MAILIMAP_NO_ERROR) {
                
                return IMAP_ERROR;
@@ -2764,7 +2781,7 @@ static void *get_list_of_uids_thread(void *data)
        struct mailimap_set * set;
        clist * lep_uidlist;
        int r;
        struct mailimap_set * set;
        clist * lep_uidlist;
        int r;
-       
+
        session = imap_session_get(folder);
        if (session == NULL) {
                stuff->done = TRUE;
        session = imap_session_get(folder);
        if (session == NULL) {
                stuff->done = TRUE;
@@ -2857,6 +2874,8 @@ gint imap_get_num_list(Folder *folder, FolderItem *_item, GSList **msgnum_list,
        gboolean selected_folder;
        
        debug_print("get_num_list\n");
        gboolean selected_folder;
        
        debug_print("get_num_list\n");
+       statusbar_print_all("Scanning %s...\n", FOLDER_ITEM(item)->path 
+                               ? FOLDER_ITEM(item)->path:"");
        
        g_return_val_if_fail(folder != NULL, -1);
        g_return_val_if_fail(item != NULL, -1);
        
        g_return_val_if_fail(folder != NULL, -1);
        g_return_val_if_fail(item != NULL, -1);
@@ -2872,8 +2891,12 @@ gint imap_get_num_list(Folder *folder, FolderItem *_item, GSList **msgnum_list,
        if (selected_folder) {
                ok = imap_cmd_noop(session);
                if (ok != IMAP_SUCCESS) {
        if (selected_folder) {
                ok = imap_cmd_noop(session);
                if (ok != IMAP_SUCCESS) {
-                       
-                       return -1;
+                       debug_print("disconnected!\n");
+                       session = imap_reconnect_if_possible(folder, session);
+                       if (session == NULL) {
+                               statusbar_pop_all();
+                               return -1;
+                       }
                }
                exists = session->exists;
 
                }
                exists = session->exists;
 
@@ -2882,7 +2905,7 @@ gint imap_get_num_list(Folder *folder, FolderItem *_item, GSList **msgnum_list,
                ok = imap_status(session, IMAP_FOLDER(folder), item->item.path,
                                 &exists, &recent, &uid_next, &uid_val, &unseen, FALSE);
                if (ok != IMAP_SUCCESS) {
                ok = imap_status(session, IMAP_FOLDER(folder), item->item.path,
                                 &exists, &recent, &uid_next, &uid_val, &unseen, FALSE);
                if (ok != IMAP_SUCCESS) {
-                       
+                       statusbar_pop_all();
                        return -1;
                }
                if(item->item.mtime == uid_val)
                        return -1;
                }
                if(item->item.mtime == uid_val)
@@ -2917,6 +2940,7 @@ gint imap_get_num_list(Folder *folder, FolderItem *_item, GSList **msgnum_list,
                   out which numbers have been removed */
                if (exists == nummsgs) {
                        *msgnum_list = g_slist_copy(item->uid_list);
                   out which numbers have been removed */
                if (exists == nummsgs) {
                        *msgnum_list = g_slist_copy(item->uid_list);
+                       statusbar_pop_all();
                        return nummsgs;
                } else if (exists < nummsgs) {
                        debug_print("Freeing imap uid cache");
                        return nummsgs;
                } else if (exists < nummsgs) {
                        debug_print("Freeing imap uid cache");
@@ -2928,13 +2952,14 @@ gint imap_get_num_list(Folder *folder, FolderItem *_item, GSList **msgnum_list,
 
        if (exists == 0) {
                *msgnum_list = NULL;
 
        if (exists == 0) {
                *msgnum_list = NULL;
+               statusbar_pop_all();
                return 0;
        }
 
        nummsgs = get_list_of_uids(folder, item, &uidlist);
 
        if (nummsgs < 0) {
                return 0;
        }
 
        nummsgs = get_list_of_uids(folder, item, &uidlist);
 
        if (nummsgs < 0) {
-               
+               statusbar_pop_all();
                return -1;
        }
 
                return -1;
        }
 
@@ -2961,7 +2986,7 @@ gint imap_get_num_list(Folder *folder, FolderItem *_item, GSList **msgnum_list,
        g_free(dir);
        
        debug_print("get_num_list - ok - %i\n", nummsgs);
        g_free(dir);
        
        debug_print("get_num_list - ok - %i\n", nummsgs);
-       
+       statusbar_pop_all();
        return nummsgs;
 }
 
        return nummsgs;
 }
 
@@ -3103,8 +3128,12 @@ gboolean imap_scan_required(Folder *folder, FolderItem *_item)
                          (!strcmp(session->mbox, item->item.path));
        if (selected_folder) {
                ok = imap_cmd_noop(session);
                          (!strcmp(session->mbox, item->item.path));
        if (selected_folder) {
                ok = imap_cmd_noop(session);
-               if (ok != IMAP_SUCCESS)
-                       return FALSE;
+               if (ok != IMAP_SUCCESS) {
+                       debug_print("disconnected!\n");
+                       session = imap_reconnect_if_possible(folder, session);
+                       if (session == NULL)
+                               return FALSE;
+               }
 
                if (session->folder_content_changed
                ||  session->exists != item->item.total_msgs)
 
                if (session->folder_content_changed
                ||  session->exists != item->item.total_msgs)