0.8.11claws12
authorChristoph Hohmann <reboot@gmx.ch>
Fri, 14 Mar 2003 01:38:17 +0000 (01:38 +0000)
committerChristoph Hohmann <reboot@gmx.ch>
Fri, 14 Mar 2003 01:38:17 +0000 (01:38 +0000)
* src/folder.[ch]
        o error return code's should better be negative
        o replace printf with debug_print

* src/imap.c
        improve IMAP folder scan by checking UID-NEXT

* src/summaryview.c
        remove check that are unnecessary in my opinion

ChangeLog.claws
configure.ac
src/folder.c
src/folder.h
src/imap.c
src/summaryview.c

index b37d151..a07d243 100644 (file)
@@ -1,3 +1,15 @@
+2003-03-14 [christoph] 0.8.11claws12
+
+       * src/folder.[ch]
+               o error return code's should better be negative
+               o replace printf with debug_print
+
+       * src/imap.c
+               improve IMAP folder scan by checking UID-NEXT
+
+       * src/summaryview.c
+               remove check that are unnecessary in my opinion
+
 2003-03-13 [christoph] 0.8.11claws11
 
        * src/folder.[ch]
index a262f43..ef7a126 100644 (file)
@@ -11,7 +11,7 @@ MINOR_VERSION=8
 MICRO_VERSION=11
 INTERFACE_AGE=0
 BINARY_AGE=0
-EXTRA_VERSION=claws11
+EXTRA_VERSION=claws12
 VERSION=$MAJOR_VERSION.$MINOR_VERSION.$MICRO_VERSION$EXTRA_VERSION
 
 dnl set $target
index 208dd72..312373c 100644 (file)
@@ -1661,7 +1661,7 @@ gint folder_item_move_to(FolderItem *src, FolderItem *dest, FolderItem **new_ite
                dst_identifier = folder_get_identifier(dest->folder);
        }
        if (src_identifier == NULL || dst_identifier == NULL) {
-               printf("Can't get identifiers\n");
+               debug_print("Can't get identifiers\n");
                return F_MOVE_FAILED;
        }
 
index 5778e4d..7ea413c 100644 (file)
@@ -104,12 +104,12 @@ typedef enum
 
 typedef enum
 {
-       F_MOVE_OK,
-       F_MOVE_FAILED_DEST_IS_PARENT,
-       F_MOVE_FAILED_DEST_IS_CHILD,
-       F_MOVE_FAILED_DEST_OUTSIDE_MAILBOX,
-       F_MOVE_FAILED
-} FolderMoveStatus;
+       F_MOVE_OK = 0,
+       F_MOVE_FAILED_DEST_IS_PARENT = -1,
+       F_MOVE_FAILED_DEST_IS_CHILD = -2,
+       F_MOVE_FAILED_DEST_OUTSIDE_MAILBOX = -3,
+       F_MOVE_FAILED = -4,
+} FolderItemMoveResult;
 
 typedef enum
 {
index f618742..5eb74f2 100644 (file)
@@ -74,6 +74,7 @@ struct _IMAPFolderItem
        FolderItem item;
 
        guint lastuid;
+       guint uid_next;
        GSList *uid_list;
 };
 
@@ -374,6 +375,7 @@ static FolderItem *imap_folder_item_new(Folder *folder)
        
        item = g_new0(IMAPFolderItem, 1);
        item->lastuid = 0;
+       item->uid_next = 0;
        item->uid_list = NULL;
 
        return (FolderItem *)item;
@@ -394,6 +396,7 @@ static gboolean imap_reset_uid_lists_func(GNode *node, gpointer data)
        IMAPFolderItem *item = (IMAPFolderItem *)node->data;
        
        item->lastuid = 0;
+       item->uid_next = 0;
        g_slist_free(item->uid_list);
        item->uid_list = NULL;
        
@@ -3301,7 +3304,7 @@ gint imap_get_num_list(Folder *folder, FolderItem *_item, GSList **msgnum_list)
 {
        IMAPFolderItem *item = (IMAPFolderItem *)_item;
        IMAPSession *session;
-       gint ok, lastuid_old, nummsgs = 0, exists, resent, unseen, uid_val;
+       gint ok, lastuid_old, nummsgs = 0, exists, recent, unseen, uid_val, uid_next;
        GSList *uidlist, *elem;
        gchar *dir, *cmd_buf;
 
@@ -3314,13 +3317,42 @@ gint imap_get_num_list(Folder *folder, FolderItem *_item, GSList **msgnum_list)
        session = imap_session_get(folder);
        g_return_val_if_fail(session != NULL, -1);
 
-       ok = imap_select(session, IMAP_FOLDER(folder), item->item.path,
-                        &exists, &resent, &unseen, &uid_val);
+       ok = imap_status(session, IMAP_FOLDER(folder), item->item.path,
+                        &exists, &recent, &uid_next, &uid_val, &unseen);
        if (ok != IMAP_SUCCESS)
                return -1;
 
-       if (exists == 0)
+       /* If old uid_next matches new uid_next we can be sure no message
+          was added to the folder */
+       if (uid_next == item->uid_next) {
+               nummsgs = g_slist_length(item->uid_list);
+               
+               /* If number of messages is still the same we
+                   know our caches message numbers are still valid,
+                   otherwise if the number of messages has decrease
+                  we discard our cache to start a new scan to find
+                  out which numbers have been removed */
+               if (exists == nummsgs) {
+                       *msgnum_list = g_slist_copy(item->uid_list);
+                       return nummsgs;
+               } else if (exists < nummsgs) {
+                       debug_print("Freeing imap uid cache");
+                       item->lastuid = 0;
+                       g_slist_free(item->uid_list);
+                       item->uid_list = NULL;
+               }
+       }
+       item->uid_next = uid_next;
+
+       if (exists == 0) {
+               *msgnum_list = NULL;
                return 0;
+       }
+
+       ok = imap_select(session, IMAP_FOLDER(folder), item->item.path,
+                        &exists, &recent, &unseen, &uid_val);
+       if (ok != IMAP_SUCCESS)
+               return -1;
 
        cmd_buf = g_strdup_printf("UID %d:*", item->lastuid + 1);
        ok = imap_cmd_search(SESSION(session)->sock, cmd_buf, &uidlist);
@@ -3361,6 +3393,7 @@ gint imap_get_num_list(Folder *folder, FolderItem *_item, GSList **msgnum_list)
 
        lastuid_old = item->lastuid;
        *msgnum_list = g_slist_copy(item->uid_list);
+       nummsgs = g_slist_length(*msgnum_list);
        debug_print("Got %d uids from cache\n", g_slist_length(item->uid_list));
 
        for (elem = uidlist; elem != NULL; elem = g_slist_next(elem)) {
@@ -3378,9 +3411,11 @@ gint imap_get_num_list(Folder *folder, FolderItem *_item, GSList **msgnum_list)
        }
        g_slist_free(uidlist);
 
-       if (g_slist_length(item->uid_list) != exists) {
+       if (nummsgs != exists) {
                /* Cache contains more messages then folder, we have cached
-                   an old UID of a message that was removed */
+                   an old UID of a message that was removed and new messages
+                   have been added too, otherwise the uid_next check would
+                  not have failed */
                debug_print("Freeing imap uid cache");
                item->lastuid = 0;
                g_slist_free(item->uid_list);
index fee3ae8..813b856 100644 (file)
@@ -932,10 +932,7 @@ gboolean summary_show(SummaryView *summaryview, FolderItem *item)
                messageview_clear(summaryview->messageview);
 
        buf = NULL;
-       if (!item || !item->path || !item->parent || item->no_select ||
-           (FOLDER_TYPE(item->folder) == F_MH &&
-            ((buf = folder_item_get_path(item)) == NULL ||
-             change_dir(buf) < 0))) {
+       if (!item || !item->path || !item->parent || item->no_select) {
                g_free(buf);
                debug_print("empty folder\n\n");
                summary_set_hide_read_msgs_menu(summaryview, FALSE);
@@ -3622,9 +3619,6 @@ static void summary_execute_delete(SummaryView *summaryview)
        GSList *cur;
 
        trash = summaryview->folder_item->folder->trash;
-       if (FOLDER_TYPE(summaryview->folder_item->folder) == F_MH) {
-               g_return_if_fail(trash != NULL);
-       }
 
        /* search deleting messages and execute */
        gtk_ctree_pre_recursive