sync with 0.9.4cvs9
authorPaul Mangan <paul@claws-mail.org>
Tue, 26 Aug 2003 07:13:40 +0000 (07:13 +0000)
committerPaul Mangan <paul@claws-mail.org>
Tue, 26 Aug 2003 07:13:40 +0000 (07:13 +0000)
ChangeLog
ChangeLog.claws
ChangeLog.jp
configure.ac
src/folder.c
src/folder.h
src/imap.c

index 1e6706d..8bec507 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2003-08-26
+
+       * src/folder.[ch]: folder_item_remove_children(): new. It removes
+         all children under a FolderItem.
+       * src/folderview.c: folderview_rescan_tree(): modified the message.
+       * src/imap.c: imap_scan_tree(), imap_scan_tree_recursive(): reuse
+         the previous FolderItem objects.
+
 2003-08-25
 
        * src/folder.[ch]: added a reference to its own GNode in FolderItem.
index d7dd23a..c55b929 100644 (file)
@@ -1,3 +1,8 @@
+2003-08-26 [paul]      0.9.4claws38
+
+       * sync with 0.9.4cvs9
+               see ChangeLog 2003-08-26
+
 2003-08-25 [paul]      0.9.4claws37
 
        * sync with 0.9.4cvs8
index 905371f..36544c4 100644 (file)
@@ -1,3 +1,11 @@
+2003-08-26
+
+       * src/folder.[ch]: folder_item_remove_children(): ¿·µ¬¡£ FolderItem
+         ¤Î²¼¤ÎÁ´¤Æ¤Î»Ò¤òºï½ü¡£
+       * src/folderview.c: folderview_rescan_tree(): ¥á¥Ã¥»¡¼¥¸¤ò½¤Àµ¡£
+       * src/imap.c: imap_scan_tree(), imap_scan_tree_recursive(): °ÊÁ°¤Î
+         FolderItem ¥ª¥Ö¥¸¥§¥¯¥È¤òºÆÍøÍÑ¡£
+
 2003-08-25
 
        * src/folder.[ch]: FolderItem ¤Ë¼«Ê¬¼«¿È¤Î GNode ¤Ø¤Î»²¾È¤òÄɲá£
index 5f824b6..7fd21c3 100644 (file)
@@ -11,7 +11,7 @@ MINOR_VERSION=9
 MICRO_VERSION=4
 INTERFACE_AGE=0
 BINARY_AGE=0
-EXTRA_VERSION=37
+EXTRA_VERSION=38
 if test $EXTRA_VERSION -eq 0; then
     VERSION=${MAJOR_VERSION}.${MINOR_VERSION}.${MICRO_VERSION}claws
 else
index 5bc8eee..10902e1 100644 (file)
@@ -253,6 +253,22 @@ void folder_item_remove(FolderItem *item)
        g_node_destroy(node);
 }
 
+void folder_item_remove_children(FolderItem *item)
+{
+       GNode *node, *next;
+
+       g_return_if_fail(item != NULL);
+       g_return_if_fail(item->folder != NULL);
+       g_return_if_fail(item->node != NULL);
+
+       node = item->node->children;
+       while (node != NULL) {
+               next = node->next;
+               folder_item_remove(FOLDER_ITEM(node->data));
+               node = next;
+       }
+}
+
 void folder_item_destroy(FolderItem *item)
 {
        Folder *folder;
index 35abd7d..4670ea5 100644 (file)
@@ -359,13 +359,14 @@ void        folder_destroy                (Folder         *folder);
 void        folder_local_folder_destroy        (LocalFolder    *lfolder);
 void        folder_remote_folder_destroy(RemoteFolder  *rfolder);
 
-FolderItem *folder_item_new    (Folder         *folder,
-                                const gchar    *name,
-                                const gchar    *path);
-void        folder_item_append (FolderItem     *parent,
-                                FolderItem     *item);
-void        folder_item_remove (FolderItem     *item);
-void        folder_item_destroy        (FolderItem     *item);
+FolderItem *folder_item_new            (Folder         *folder,
+                                        const gchar    *name,
+                                        const gchar    *path);
+void        folder_item_append         (FolderItem     *parent,
+                                        FolderItem     *item);
+void        folder_item_remove         (FolderItem     *item);
+void        folder_item_remove_children        (FolderItem     *item);
+void        folder_item_destroy                (FolderItem     *item);
 
 void        folder_set_ui_func (Folder         *folder,
                                 FolderUIFunc    func,
index 6f29266..a284c79 100644 (file)
@@ -1160,7 +1160,7 @@ gint imap_close(Folder *folder, FolderItem *item)
 
 void imap_scan_tree(Folder *folder)
 {
-       FolderItem *item;
+       FolderItem *item = NULL;
        IMAPSession *session;
        gchar *root_folder = NULL;
 
@@ -1184,12 +1184,17 @@ void imap_scan_tree(Folder *folder)
                debug_print("IMAP root directory: %s\n", root_folder);
        }
 
-       item = folder_item_new(folder, folder->name, root_folder);
-       item->folder = folder;
-       item->no_select = TRUE;
-       folder->node = item->node = g_node_new(item);
+       if (folder->node)
+               item = FOLDER_ITEM(folder->node->data);
+       if (!item || ((item->path || root_folder) &&
+                     strcmp2(item->path, root_folder) != 0)) {
+               folder_tree_destroy(folder);
+               item = folder_item_new(folder, folder->name, root_folder);
+               item->folder = folder;
+               folder->node = item->node = g_node_new(item);
+       }
 
-       imap_scan_tree_recursive(session, item);
+       imap_scan_tree_recursive(session, FOLDER_ITEM(folder->node->data));
        imap_create_missing_folders(folder);
 }
 
@@ -1199,6 +1204,7 @@ static gint imap_scan_tree_recursive(IMAPSession *session, FolderItem *item)
        IMAPFolder *imapfolder;
        FolderItem *new_item;
        GSList *item_list, *cur;
+       GNode *node;
        gchar *real_path;
        gchar *wildcard_path;
        gchar separator;
@@ -1238,16 +1244,59 @@ static gint imap_scan_tree_recursive(IMAPSession *session, FolderItem *item)
        item_list = imap_parse_list(imapfolder, session, real_path, NULL);
        g_free(real_path);
 
+       node = item->node->children;
+       while (node != NULL) {
+               FolderItem *old_item = FOLDER_ITEM(node->data);
+               new_item = NULL;
+               GNode *next = node->next;
+
+               for (cur = item_list; cur != NULL; cur = cur->next) {
+                       FolderItem *cur_item = FOLDER_ITEM(cur->data);
+                       if (!strcmp2(old_item->path, cur_item->path)) {
+                               new_item = cur_item;
+                               break;
+                       }
+               }
+               if (!new_item) {
+                       debug_print("folder '%s' not found. removing...\n",
+                                   old_item->path);
+                       folder_item_remove(old_item);
+               } else {
+                       old_item->no_sub = new_item->no_sub;
+                       old_item->no_select = new_item->no_select;
+                       if (old_item->no_sub == TRUE && node->children) {
+                               debug_print("folder '%s' doesn't have "
+                                           "subfolders. removing...\n",
+                                           old_item->path);
+                               folder_item_remove_children(old_item);
+                       }
+               }
+
+               node = next;
+       }
+
        for (cur = item_list; cur != NULL; cur = cur->next) {
-               new_item = cur->data;
-               if (!strcmp(new_item->path, "INBOX")) {
-                       if (!folder->inbox) {
-                               new_item->stype = F_INBOX;
-                               folder->inbox = new_item;
-                       } else {
-                               folder_item_destroy(new_item);
-                               continue;
+               FolderItem *cur_item = FOLDER_ITEM(cur->data);
+               new_item = NULL;
+               for (node = item->node->children; node != NULL;
+                    node = node->next) {
+                       if (!strcmp2(FOLDER_ITEM(node->data)->path,
+                                    cur_item->path)) {
+                               new_item = FOLDER_ITEM(node->data);
+                               folder_item_destroy(cur_item);
+                               cur_item = NULL;
+                               break;
                        }
+               }
+               if (!new_item) {
+                       new_item = cur_item;
+                       debug_print("new folder '%s' found.\n", new_item->path);
+                       folder_item_append(item, new_item);
+               }
+
+               if (!strcmp(new_item->path, "INBOX")) {
+                       new_item->stype = F_INBOX;
+                       folder->inbox = new_item;
                } else if (!item->parent || item->stype == F_INBOX) {
                        gchar *base;
 
@@ -1267,7 +1316,7 @@ static gint imap_scan_tree_recursive(IMAPSession *session, FolderItem *item)
                                folder->trash = new_item;
                        }
                }
-               folder_item_append(item, new_item);
+
                if (new_item->no_sub == FALSE)
                        imap_scan_tree_recursive(session, new_item);
        }
@@ -1353,7 +1402,7 @@ static GSList *imap_parse_list(IMAPFolder *folder, IMAPSession *session,
 
                item_list = g_slist_append(item_list, new_item);
 
-               debug_print("folder %s has been added.\n", loc_path);
+               debug_print("folder '%s' found.\n", loc_path);
                g_free(loc_path);
                g_free(loc_name);
        }