0.8.6claws120
authorChristoph Hohmann <reboot@gmx.ch>
Fri, 20 Dec 2002 17:03:14 +0000 (17:03 +0000)
committerChristoph Hohmann <reboot@gmx.ch>
Fri, 20 Dec 2002 17:03:14 +0000 (17:03 +0000)
* src/summaryview.c
        don't use "changed" to check if op_count has to be changed as it
        is also set when the message has unread children
        (closes bug [ 653221 ] crash while deleting duplicates)

ChangeLog.claws
configure.in
src/imap.c
src/summaryview.c

index 52aac08..8e05418 100644 (file)
@@ -1,3 +1,10 @@
+2002-12-20 [christoph] 0.8.6claws120
+
+       * src/summaryview.c
+               don't use "changed" to check if op_count has to be changed as it
+               is also set when the message has unread children
+               (closes bug [ 653221 ] crash while deleting duplicates)
+
 2002-12-20 [paul]      0.8.6claws119
 
        * sync with 0.8.6cvs27
index 59ccb01..e9afaec 100644 (file)
@@ -11,7 +11,7 @@ MINOR_VERSION=8
 MICRO_VERSION=6
 INTERFACE_AGE=0
 BINARY_AGE=0
-EXTRA_VERSION=claws119
+EXTRA_VERSION=claws120
 VERSION=$MAJOR_VERSION.$MINOR_VERSION.$MICRO_VERSION$EXTRA_VERSION
 
 dnl set $target
index bd9f008..823d3a7 100644 (file)
@@ -398,6 +398,7 @@ static void imap_reset_uid_lists(Folder *folder)
 static IMAPSession *imap_session_get(Folder *folder)
 {
        RemoteFolder *rfolder = REMOTE_FOLDER(folder);
+       Session *session = NULL;
        gushort port;
 
        g_return_val_if_fail(folder != NULL, NULL);
@@ -413,25 +414,31 @@ static IMAPSession *imap_session_get(Folder *folder)
                : IMAP4_PORT;
 #endif
 
-       if (!rfolder->session) {
-               rfolder->session =
-                       imap_session_new(folder->account);
-               if (rfolder->session) {
-                       if (!IMAP_SESSION(rfolder->session)->authenticated)
-                               imap_session_authenticate(IMAP_SESSION(rfolder->session), folder->account);
-                       if (IMAP_SESSION(rfolder->session)->authenticated) {
-                               imap_parse_namespace(IMAP_SESSION(rfolder->session),
-                                                    IMAP_FOLDER(folder));
-                               rfolder->session->last_access_time = time(NULL);
-                               imap_reset_uid_lists(folder);
-                       } else {
-                               session_destroy(rfolder->session);
-                               rfolder->session = NULL;
-                       }
-               }
-               return IMAP_SESSION(rfolder->session);
+       /* Make sure we have a session */
+       if (rfolder->session != NULL) {
+               session = rfolder->session;
+       } else {
+               imap_reset_uid_lists(folder);
+               session = imap_session_new(folder->account);
+               session->last_access_time = time(NULL);
+       }
+       if(!session) {
+               return NULL;
+       }
+
+       /* Make sure session is authenticated */
+       if (!IMAP_SESSION(session)->authenticated)
+               imap_session_authenticate(IMAP_SESSION(session), folder->account);
+       if (!IMAP_SESSION(session)->authenticated) {
+               session_destroy(session);
+               rfolder->session = NULL;
+               return NULL;
        }
 
+       /* Make sure we have parsed the IMAP namespace */
+       imap_parse_namespace(IMAP_SESSION(session),
+                            IMAP_FOLDER(folder));
+
        /* I think the point of this code is to avoid sending a
         * keepalive if we've used the session recently and therefore
         * think it's still alive.  Unfortunately, most of the code
@@ -440,36 +447,36 @@ static IMAPSession *imap_session_get(Folder *folder)
         * A better solution than sending a NOOP every time would be
         * for every command to be prepared to retry until it is
         * successfully sent. -- mbp */
-       if (time(NULL) - rfolder->session->last_access_time < SESSION_TIMEOUT) {
-               rfolder->session->last_access_time = time(NULL);
-               return IMAP_SESSION(rfolder->session);
-       }
-
-       if (imap_cmd_noop(rfolder->session->sock) != IMAP_SUCCESS) {
-               log_warning(_("IMAP4 connection to %s:%d has been"
-                             " disconnected. Reconnecting...\n"),
-                           folder->account->recv_server, port);
-               session_destroy(rfolder->session);
-               rfolder->session =
-                       imap_session_new(folder->account);
-               if (rfolder->session) {
-                       if (!IMAP_SESSION(rfolder->session)->authenticated)
-                               imap_session_authenticate(IMAP_SESSION(rfolder->session), folder->account);
-                       if (IMAP_SESSION(rfolder->session)->authenticated) {
-                               imap_parse_namespace(IMAP_SESSION(rfolder->session),
-                                                    IMAP_FOLDER(folder));
-                               rfolder->session->last_access_time = time(NULL);
-                               imap_reset_uid_lists(folder);
+       if (time(NULL) - session->last_access_time > SESSION_TIMEOUT) {
+               /* verify that the session is still alive */
+               if (imap_cmd_noop(session->sock) != 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 %s:%d failed"),
+                                           folder->account->recv_server, port);
+                               session_destroy(session);
+                               session = NULL;
                        } else {
-                               session_destroy(rfolder->session);
+                               log_warning(_("IMAP4 connection to %s:%d has been"
+                                             " disconnected. Reconnecting...\n"),
+                                           folder->account->recv_server, port);
+                               session_destroy(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 = SESSION(imap_session_get(folder));
                        }
                }
        }
 
-       if (rfolder->session)
-               rfolder->session->last_access_time = time(NULL);
-       return IMAP_SESSION(rfolder->session);
+       rfolder->session = session;
+       if (session) {
+               session->last_access_time = time(NULL);
+       }
+       return IMAP_SESSION(session);
 }
 
 Session *imap_session_new(const PrefsAccount *account)
index 93323ee..0817a83 100644 (file)
@@ -2713,18 +2713,19 @@ static void summary_mark_row(SummaryView *summaryview, GtkCTreeNode *row)
        if (MSG_IS_MOVE(msginfo->flags)) {
                summaryview->moved--;
                changed = TRUE;
+               msginfo->to_folder->op_count--;
+               if (msginfo->to_folder->op_count == 0)
+                       folder_update_item(msginfo->to_folder, FALSE);
        }
        if (MSG_IS_COPY(msginfo->flags)) {
                summaryview->copied--;
                changed = TRUE;
-       }
-       changed |= summary_update_unread_children (summaryview, msginfo, TRUE);
-
-       if (changed && !prefs_common.immediate_exec) {
                msginfo->to_folder->op_count--;
                if (msginfo->to_folder->op_count == 0)
                        folder_update_item(msginfo->to_folder, FALSE);
        }
+       changed |= summary_update_unread_children (summaryview, msginfo, TRUE);
+
        msginfo->to_folder = NULL;
        procmsg_msginfo_unset_flags(msginfo, MSG_DELETED, MSG_MOVE | MSG_COPY);
        procmsg_msginfo_set_flags(msginfo, MSG_MARKED, 0);
@@ -2941,18 +2942,19 @@ static void summary_delete_row(SummaryView *summaryview, GtkCTreeNode *row)
        if (MSG_IS_MOVE(msginfo->flags)) {
                summaryview->moved--;
                changed = TRUE;
+               msginfo->to_folder->op_count--;
+               if (msginfo->to_folder->op_count == 0)
+                       folder_update_item(msginfo->to_folder, FALSE);
        }
        if (MSG_IS_COPY(msginfo->flags)) {
                summaryview->copied--;
                changed = TRUE;
-       }
-       changed |= summary_update_unread_children (summaryview, msginfo, FALSE);
-
-       if (changed && !prefs_common.immediate_exec) {
                msginfo->to_folder->op_count--;
                if (msginfo->to_folder->op_count == 0)
                        folder_update_item(msginfo->to_folder, FALSE);
        }
+       changed |= summary_update_unread_children (summaryview, msginfo, FALSE);
+
        msginfo->to_folder = NULL;
        procmsg_msginfo_unset_flags(msginfo, MSG_MARKED, MSG_MOVE | MSG_COPY);
        procmsg_msginfo_set_flags(msginfo, MSG_DELETED, 0);