0.8.11claws1
authorChristoph Hohmann <reboot@gmx.ch>
Wed, 12 Mar 2003 15:40:51 +0000 (15:40 +0000)
committerChristoph Hohmann <reboot@gmx.ch>
Wed, 12 Mar 2003 15:40:51 +0000 (15:40 +0000)
* src/account.c
* src/folder.[ch]
* src/foldersel.c
* src/folderview.c
* src/imap.c
* src/mainwindow.c
* src/mbox_folder.c
* src/mh.c
* src/news.c
* src/prefs_scoring.c
* src/procmsg.c
* src/setup.c
* src/summaryview.c
        initial restructuring of folder system, seperating
        folders and folder classes

16 files changed:
ChangeLog.claws
configure.ac
src/account.c
src/folder.c
src/folder.h
src/foldersel.c
src/folderview.c
src/imap.c
src/mainwindow.c
src/mbox_folder.c
src/mh.c
src/news.c
src/prefs_scoring.c
src/procmsg.c
src/setup.c
src/summaryview.c

index df93e86a59cc85903ff6165b7a4a45f67ece28f4..c55ff1ffe81f9ae5bf34a555633632867c5674e1 100644 (file)
@@ -1,3 +1,21 @@
+2003-03-12 [christoph] 0.8.11claws1
+
+       * src/account.c
+       * src/folder.[ch]
+       * src/foldersel.c
+       * src/folderview.c
+       * src/imap.c
+       * src/mainwindow.c
+       * src/mbox_folder.c
+       * src/mh.c
+       * src/news.c
+       * src/prefs_scoring.c
+       * src/procmsg.c
+       * src/setup.c
+       * src/summaryview.c
+               initial restructuring of folder system, seperating
+               folders and folder classes
+
 2003-03-12 [paul]      0.8.11claws
 
        0.8.11claws release
index c61d19f6f0a93f7f543a8f9e1aa3bc45094c385c..092eaba2339563d7e1b61752be7cda35ca4250e8 100644 (file)
@@ -11,7 +11,7 @@ MINOR_VERSION=8
 MICRO_VERSION=11
 INTERFACE_AGE=0
 BINARY_AGE=0
-EXTRA_VERSION=claws
+EXTRA_VERSION=claws1
 VERSION=$MAJOR_VERSION.$MINOR_VERSION.$MICRO_VERSION$EXTRA_VERSION
 
 dnl set $target
index dfbad2694a6510751a9e7ce7e7e5cb9aeadd7601..8b8713534b11955d2941851adb536af8f2f1df9e 100644 (file)
@@ -352,7 +352,7 @@ void account_add(void)
                ac_prefs->folder = REMOTE_FOLDER(folder);
                folder_add(folder);
                if (ac_prefs->protocol == A_IMAP4)
-                       folder->create_tree(folder);
+                       folder->class->create_tree(folder);
                folderview_set_all();
        }
 }
@@ -435,7 +435,7 @@ void account_set_missing_folder(void)
                        ap->folder = REMOTE_FOLDER(folder);
                        folder_add(folder);
                        if (ap->protocol == A_IMAP4)
-                               folder->create_tree(folder);
+                               folder->class->create_tree(folder);
                }
        }
 }
index 000a1dbffcd0e5f458dc892462515302c4600cdd..40f5916ef1f0c3f544e84caad42f04f259a8482a 100644 (file)
@@ -119,18 +119,6 @@ static void folder_init(Folder *folder, const gchar *name)
        folder->draft = NULL;
        folder->queue = NULL;
        folder->trash = NULL;
-
-       /* Init Folder functions */
-       folder->item_new = NULL;
-       folder->item_destroy = NULL;
-       folder->fetch_msg = NULL;
-       folder->get_msginfo = NULL;
-       folder->get_msginfos = NULL;
-       folder->get_num_list = NULL;
-       folder->ui_func = NULL;
-       folder->ui_func_data = NULL;
-       folder->change_flags = NULL;
-       folder->check_msgnum_validity = NULL;
 }
 
 void folder_local_folder_init(Folder *folder, const gchar *name,
@@ -150,15 +138,15 @@ void folder_remote_folder_init(Folder *folder, const gchar *name,
 void folder_destroy(Folder *folder)
 {
        g_return_if_fail(folder != NULL);
-       g_return_if_fail(folder->destroy != NULL);
-
-       folder->destroy(folder);
+       g_return_if_fail(folder->class->destroy != NULL);
 
        folder_list = g_list_remove(folder_list, folder);
 
        folder_tree_destroy(folder);
        g_free(folder->name);
        g_free(folder);
+
+       folder->class->destroy(folder);
 }
 
 void folder_local_folder_destroy(LocalFolder *lfolder)
@@ -194,8 +182,8 @@ FolderItem *folder_item_new(Folder *folder, const gchar *name, const gchar *path
 {
        FolderItem *item = NULL;
 
-       if (folder->item_new) {
-               item = folder->item_new(folder);
+       if (folder->class->item_new) {
+               item = folder->class->item_new(folder);
        } else {
                item = g_new0(FolderItem, 1);
        }
@@ -277,8 +265,8 @@ void folder_item_destroy(FolderItem *item)
        g_free(item->path);
 
        if (item->folder != NULL) {
-               if(item->folder->item_destroy) {
-                       item->folder->item_destroy(item->folder, item);
+               if(item->folder->class->item_destroy) {
+                       item->folder->class->item_destroy(item->folder, item);
                } else {
                        g_free(item);
                }
@@ -344,20 +332,20 @@ void folder_add(Folder *folder)
 
        for (i = 0, cur = folder_list; cur != NULL; cur = cur->next, i++) {
                cur_folder = FOLDER(cur->data);
-               if (folder->type == F_MH) {
-                       if (cur_folder->type != F_MH) break;
-               } else if (folder->type == F_MBOX) {
-                       if (cur_folder->type != F_MH &&
-                           cur_folder->type != F_MBOX) break;
-               } else if (folder->type == F_IMAP) {
-                       if (cur_folder->type != F_MH &&
-                           cur_folder->type != F_MBOX &&
-                           cur_folder->type != F_IMAP) break;
-               } else if (folder->type == F_NEWS) {
-                       if (cur_folder->type != F_MH &&
-                           cur_folder->type != F_MBOX &&
-                           cur_folder->type != F_IMAP &&
-                           cur_folder->type != F_NEWS) break;
+               if (FOLDER_TYPE(folder) == F_MH) {
+                       if (FOLDER_TYPE(cur_folder) != F_MH) break;
+               } else if (FOLDER_TYPE(folder) == F_MBOX) {
+                       if (FOLDER_TYPE(cur_folder) != F_MH &&
+                           FOLDER_TYPE(cur_folder) != F_MBOX) break;
+               } else if (FOLDER_TYPE(folder) == F_IMAP) {
+                       if (FOLDER_TYPE(cur_folder) != F_MH &&
+                           FOLDER_TYPE(cur_folder) != F_MBOX &&
+                           FOLDER_TYPE(cur_folder) != F_IMAP) break;
+               } else if (FOLDER_TYPE(folder) == F_NEWS) {
+                       if (FOLDER_TYPE(cur_folder) != F_MH &&
+                           FOLDER_TYPE(cur_folder) != F_MBOX &&
+                           FOLDER_TYPE(cur_folder) != F_IMAP &&
+                           FOLDER_TYPE(cur_folder) != F_NEWS) break;
                }
        }
 
@@ -436,13 +424,13 @@ void folder_scan_tree(Folder *folder)
 {
        GHashTable *pptable;
        
-       if (!folder->scan_tree)
+       if (!folder->class->scan_tree)
                return;
        
        pptable = folder_persist_prefs_new(folder);
        folder_tree_destroy(folder);
 
-       folder->scan_tree(folder);
+       folder->class->scan_tree(folder);
 
        g_node_traverse(folder->node, G_POST_ORDER, G_TRAVERSE_ALL, -1, folder_scan_tree_func, pptable);
        folder_persist_prefs_free(pptable);
@@ -456,7 +444,7 @@ FolderItem *folder_create_folder(FolderItem *parent, const gchar *name)
 {
        FolderItem *new_item;
 
-       new_item = parent->folder->create_folder(parent->folder, parent, name);
+       new_item = parent->folder->class->create_folder(parent->folder, parent, name);
        if (new_item)
                new_item->cache = msgcache_new();
 
@@ -544,7 +532,7 @@ Folder *folder_find_from_path(const gchar *path)
 
        for (list = folder_list; list != NULL; list = list->next) {
                folder = list->data;
-               if ((folder->type == F_MH || folder->type == F_MBOX) &&
+               if ((FOLDER_TYPE(folder) == F_MH || FOLDER_TYPE(folder) == F_MBOX) &&
                    !path_cmp(LOCAL_FOLDER(folder)->rootpath, path))
                        return folder;
        }
@@ -559,7 +547,7 @@ Folder *folder_find_from_name(const gchar *name, FolderType type)
 
        for (list = folder_list; list != NULL; list = list->next) {
                folder = list->data;
-               if (folder->type == type && strcmp2(name, folder->name) == 0)
+               if (FOLDER_TYPE(folder) == type && strcmp2(name, folder->name) == 0)
                        return folder;
        }
 
@@ -638,7 +626,7 @@ gchar *folder_get_identifier(Folder *folder)
 
        g_return_val_if_fail(folder != NULL, NULL);
 
-       type_str = folder_get_type_string(folder->type);
+       type_str = folder_get_type_string(FOLDER_TYPE(folder));
        return g_strconcat(type_str, "/", folder->name, NULL);
 }
 
@@ -777,7 +765,7 @@ void folder_set_missing_folders(void)
 
        for (list = folder_list; list != NULL; list = list->next) {
                folder = list->data;
-               if (folder->type != F_MH) continue;
+               if (FOLDER_TYPE(folder) != F_MH) continue;
                rootitem = FOLDER_ITEM(folder->node->data);
                g_return_if_fail(rootitem != NULL);
 
@@ -785,7 +773,7 @@ void folder_set_missing_folders(void)
                    folder->queue && folder->trash)
                        continue;
 
-               if (folder->create_tree(folder) < 0) {
+               if (folder->class->create_tree(folder) < 0) {
                        g_warning("%s: can't create the folder tree.\n",
                                  LOCAL_FOLDER(folder)->rootpath);
                        continue;
@@ -918,16 +906,12 @@ void folder_item_set_default_flags(FolderItem *dest, MsgFlags *flags)
                flags->perm_flags = 0;
        }
        flags->tmp_flags = MSG_CACHED;
-       if (dest->folder->type == F_MH) {
+       if (FOLDER_TYPE(dest->folder) == F_MH) {
                if (dest->stype == F_QUEUE) {
                        MSG_SET_TMP_FLAGS(*flags, MSG_QUEUED);
                } else if (dest->stype == F_DRAFT) {
                        MSG_SET_TMP_FLAGS(*flags, MSG_DRAFT);
                }
-       } else if (dest->folder->type == F_IMAP) {
-               MSG_SET_TMP_FLAGS(*flags, MSG_IMAP);
-       } else if (dest->folder->type == F_NEWS) {
-               MSG_SET_TMP_FLAGS(*flags, MSG_NEWS);
        }
 }
 
@@ -949,7 +933,7 @@ static gint folder_sort_folder_list(gconstpointer a, gconstpointer b)
 
 gint folder_item_open(FolderItem *item)
 {
-       if(((item->folder->type == F_IMAP) && !item->no_select) || (item->folder->type == F_NEWS)) {
+       if(((FOLDER_TYPE(item->folder) == F_IMAP) && !item->no_select) || (FOLDER_TYPE(item->folder) == F_NEWS)) {
                folder_item_scan(item);
        }
 
@@ -1010,18 +994,18 @@ gint folder_item_scan(FolderItem *item)
        folder = item->folder;
 
        g_return_val_if_fail(folder != NULL, -1);
-       g_return_val_if_fail(folder->get_num_list != NULL, -1);
+       g_return_val_if_fail(folder->class->get_num_list != NULL, -1);
 
        debug_print("Scanning folder %s for cache changes.\n", item->path);
 
        /* Get list of messages for folder and cache */
-       if (folder->get_num_list(item->folder, item, &folder_list) < 0) {
+       if (folder->class->get_num_list(item->folder, item, &folder_list) < 0) {
                debug_print("Error fetching list of message numbers\n");
                return(-1);
        }
 
-       if (!folder->check_msgnum_validity || 
-           folder->check_msgnum_validity(folder, item)) {
+       if (!folder->class->check_msgnum_validity || 
+           folder->class->check_msgnum_validity(folder, item)) {
                if (!item->cache)
                        folder_item_read_cache(item);
                cache_list = msgcache_get_msg_list(item->cache);
@@ -1069,7 +1053,7 @@ gint folder_item_scan(FolderItem *item)
                if (folder_cur_num < cache_cur_num) {
                        gboolean add = FALSE;
 
-                       switch(folder->type) {
+                       switch(FOLDER_TYPE(folder)) {
                                case F_NEWS:
                                        if (folder_cur_num < cache_max_num)
                                                break;
@@ -1134,7 +1118,7 @@ gint folder_item_scan(FolderItem *item)
                        MsgInfo *msginfo;
 
                        msginfo = msgcache_get_msg(item->cache, folder_cur_num);
-                       if (folder->is_msg_changed && folder->is_msg_changed(folder, item, msginfo)) {
+                       if (folder->class->is_msg_changed && folder->class->is_msg_changed(folder, item, msginfo)) {
                                msgcache_remove_msg(item->cache, msginfo->msgnum);
                                new_list = g_slist_prepend(new_list, GINT_TO_POINTER(msginfo->msgnum));
                                procmsg_msginfo_free(msginfo);
@@ -1168,9 +1152,9 @@ gint folder_item_scan(FolderItem *item)
        g_slist_free(folder_list);
 
        if (new_list != NULL) {
-               if (folder->get_msginfos) {
-                       newmsg_list = folder->get_msginfos(folder, item, new_list);
-               } else if (folder->get_msginfo) {
+               if (folder->class->get_msginfos) {
+                       newmsg_list = folder->class->get_msginfos(folder, item, new_list);
+               } else if (folder->class->get_msginfo) {
                        GSList *elem;
        
                        for (elem = new_list; elem != NULL; elem = g_slist_next(elem)) {
@@ -1178,7 +1162,7 @@ gint folder_item_scan(FolderItem *item)
                                guint num;
 
                                num = GPOINTER_TO_INT(elem->data);
-                               msginfo = folder->get_msginfo(folder, item, num);
+                               msginfo = folder->class->get_msginfo(folder, item, num);
                                if (msginfo != NULL) {
                                        newmsg_list = g_slist_prepend(newmsg_list, msginfo);
                                        debug_print("Added newly found message %d to cache.\n", num);
@@ -1383,8 +1367,8 @@ MsgInfo *folder_item_get_msginfo(FolderItem *item, gint num)
        if ((msginfo = msgcache_get_msg(item->cache, num)) != NULL)
                return msginfo;
        
-       g_return_val_if_fail(folder->get_msginfo, NULL);
-       if ((msginfo = folder->get_msginfo(folder, item, num)) != NULL) {
+       g_return_val_if_fail(folder->class->get_msginfo, NULL);
+       if ((msginfo = folder->class->get_msginfo(folder, item, num)) != NULL) {
                msgcache_add_msg(item->cache, msginfo);
                return msginfo;
        }
@@ -1429,9 +1413,9 @@ gchar *folder_item_fetch_msg(FolderItem *item, gint num)
 
        folder = item->folder;
 
-       g_return_val_if_fail(folder->fetch_msg != NULL, NULL);
+       g_return_val_if_fail(folder->class->fetch_msg != NULL, NULL);
 
-       return folder->fetch_msg(folder, item, num);
+       return folder->class->fetch_msg(folder, item, num);
 }
 
 static gint folder_item_get_msg_num_by_file(FolderItem *dest, const gchar *file)
@@ -1481,15 +1465,15 @@ gint folder_item_add_msg(FolderItem *dest, const gchar *file,
 
        folder = dest->folder;
 
-       g_return_val_if_fail(folder->add_msg != NULL, -1);
+       g_return_val_if_fail(folder->class->add_msg != NULL, -1);
 
        if (!dest->cache)
                folder_item_read_cache(dest);
 
-       num = folder->add_msg(folder, dest, file, FALSE);
+       num = folder->class->add_msg(folder, dest, file, FALSE);
 
         if (num > 0) {
-               msginfo = folder->get_msginfo(folder, dest, num);
+               msginfo = folder->class->get_msginfo(folder, dest, num);
 
                if (msginfo != NULL) {
                        if (MSG_IS_NEW(msginfo->flags))
@@ -1606,7 +1590,7 @@ FolderItem *folder_item_move_recursive (FolderItem *src, FolderItem *dest)
        new_id = folder_item_get_identifier(new_item);
        debug_print("updating rules : %s => %s\n", old_id, new_id);
        
-       src->folder->remove_folder(src->folder, src);
+       src->folder->class->remove_folder(src->folder, src);
        folder_write_list();
 
        if (old_id != NULL && new_id != NULL)
@@ -1728,8 +1712,8 @@ gint folder_item_move_msgs_with_dest(FolderItem *dest, GSList *msglist)
 
        folder = dest->folder;
 
-       g_return_val_if_fail(folder->copy_msg != NULL, -1);
-       g_return_val_if_fail(folder->remove_msg != NULL, -1);
+       g_return_val_if_fail(folder->class->copy_msg != NULL, -1);
+       g_return_val_if_fail(folder->class->remove_msg != NULL, -1);
 
        /* 
         * Copy messages to destination folder and 
@@ -1742,7 +1726,7 @@ gint folder_item_move_msgs_with_dest(FolderItem *dest, GSList *msglist)
                if (!item && msginfo->folder != NULL)
                        item = msginfo->folder;
 
-               num = folder->copy_msg(folder, dest, msginfo);
+               num = folder->class->copy_msg(folder, dest, msginfo);
                newmsgnums = g_slist_append(newmsgnums, GINT_TO_POINTER(num));
        }
 
@@ -1782,7 +1766,7 @@ gint folder_item_move_msgs_with_dest(FolderItem *dest, GSList *msglist)
                                continue;
 
                        if (!folderscan) {
-                               newmsginfo = folder->get_msginfo(folder, dest, num);
+                               newmsginfo = folder->class->get_msginfo(folder, dest, num);
                                if (newmsginfo) {
                                        newmsginfo->flags.perm_flags = msginfo->flags.perm_flags;
                                        if (dest->stype == F_OUTBOX ||
@@ -1827,9 +1811,9 @@ gint folder_item_move_msgs_with_dest(FolderItem *dest, GSList *msglist)
                l2 = g_slist_next(l2);
                
                if (num >= 0) {
-                       item->folder->remove_msg(item->folder,
-                                                msginfo->folder,
-                                                msginfo->msgnum);
+                       item->folder->class->remove_msg(item->folder,
+                                                       msginfo->folder,
+                                                       msginfo->msgnum);
                        if (!item->cache)
                                folder_item_read_cache(item);
                        msgcache_remove_msg(item->cache, msginfo->msgnum);
@@ -1846,8 +1830,8 @@ gint folder_item_move_msgs_with_dest(FolderItem *dest, GSList *msglist)
        }
 
 
-       if (folder->finished_copy)
-               folder->finished_copy(folder, dest);
+       if (folder->class->finished_copy)
+               folder->class->finished_copy(folder, dest);
 
        g_slist_free(newmsgnums);
        return lastnum;
@@ -1917,7 +1901,7 @@ gint folder_item_copy_msgs_with_dest(FolderItem *dest, GSList *msglist)
 
        folder = dest->folder;
  
-       g_return_val_if_fail(folder->copy_msg != NULL, -1);
+       g_return_val_if_fail(folder->class->copy_msg != NULL, -1);
 
        /* 
         * Copy messages to destination folder and 
@@ -1926,7 +1910,7 @@ gint folder_item_copy_msgs_with_dest(FolderItem *dest, GSList *msglist)
        for (l = msglist ; l != NULL ; l = g_slist_next(l)) {
                MsgInfo * msginfo = (MsgInfo *) l->data;
 
-               num = folder->copy_msg(folder, dest, msginfo);
+               num = folder->class->copy_msg(folder, dest, msginfo);
                newmsgnums = g_slist_append(newmsgnums, GINT_TO_POINTER(num));
        }
 
@@ -1966,7 +1950,7 @@ gint folder_item_copy_msgs_with_dest(FolderItem *dest, GSList *msglist)
                                continue;
 
                        if (!folderscan) {
-                               newmsginfo = folder->get_msginfo(folder, dest, num);
+                               newmsginfo = folder->class->get_msginfo(folder, dest, num);
                                if (newmsginfo) {
                                        newmsginfo->flags.perm_flags = msginfo->flags.perm_flags;
                                        if (dest->stype == F_OUTBOX ||
@@ -1998,8 +1982,8 @@ gint folder_item_copy_msgs_with_dest(FolderItem *dest, GSList *msglist)
                }
        }
        
-       if (folder->finished_copy)
-               folder->finished_copy(folder, dest);
+       if (folder->class->finished_copy)
+               folder->class->finished_copy(folder, dest);
 
        g_slist_free(newmsgnums);
        return lastnum;
@@ -2016,7 +2000,7 @@ gint folder_item_remove_msg(FolderItem *item, gint num)
        folder = item->folder;
        if (!item->cache) folder_item_read_cache(item);
 
-       ret = folder->remove_msg(folder, item, num);
+       ret = folder->class->remove_msg(folder, item, num);
 
        msginfo = msgcache_get_msg(item->cache, num);
        if (msginfo != NULL) {
@@ -2046,8 +2030,8 @@ gint folder_item_remove_msgs(FolderItem *item, GSList *msglist)
 
        if (!item->cache) folder_item_read_cache(item);
 
-       if (folder->remove_msgs) {
-               ret = folder->remove_msgs(folder, item, msglist);
+       if (folder->class->remove_msgs) {
+               ret = folder->class->remove_msgs(folder, item, msglist);
                if (ret == 0)
                        folder_item_scan(item);
                return ret;
@@ -2074,13 +2058,13 @@ gint folder_item_remove_all_msg(FolderItem *item)
 
        folder = item->folder;
 
-       g_return_val_if_fail(folder->remove_all_msg != NULL, -1);
+       g_return_val_if_fail(folder->class->remove_all_msg != NULL, -1);
 
-       result = folder->remove_all_msg(folder, item);
+       result = folder->class->remove_all_msg(folder, item);
 
        if (result == 0) {
-               if (folder->finished_remove)
-                       folder->finished_remove(folder, item);
+               if (folder->class->finished_remove)
+                       folder->class->finished_remove(folder, item);
 
                folder_item_free_cache(item);
                item->cache = msgcache_new();
@@ -2103,9 +2087,9 @@ gboolean folder_item_is_msg_changed(FolderItem *item, MsgInfo *msginfo)
 
        folder = item->folder;
 
-       g_return_val_if_fail(folder->is_msg_changed != NULL, -1);
+       g_return_val_if_fail(folder->class->is_msg_changed != NULL, -1);
 
-       return folder->is_msg_changed(folder, item, msginfo);
+       return folder->class->is_msg_changed(folder, item, msginfo);
 }
 
 gchar *folder_item_get_cache_file(FolderItem *item)
@@ -2416,10 +2400,10 @@ static void folder_write_list_recursive(GNode *node, gpointer data)
        if (depth == 1) {
                Folder *folder = item->folder;
 
-               fprintf(fp, "<folder type=\"%s\"", folder_type_str[folder->type]);
+               fprintf(fp, "<folder type=\"%s\"", folder_type_str[FOLDER_TYPE(folder)]);
                if (folder->name)
                        PUT_ESCAPE_STR(fp, "name", folder->name);
-               if (folder->type == F_MH || folder->type == F_MBOX)
+               if (FOLDER_TYPE(folder) == F_MH || FOLDER_TYPE(folder) == F_MBOX)
                        PUT_ESCAPE_STR(fp, "path",
                                       LOCAL_FOLDER(folder)->rootpath);
                if (item->collapsed && node->children)
@@ -2592,9 +2576,9 @@ static void folder_create_processing_folder(void)
 
        if (!is_dir_exist(tmpname)) {
                debug_print("*TMP* creating %s\n", tmpname);
-               processing_folder_item = processing_folder->create_folder(processing_folder,
-                                                                         processing_folder->node->data,
-                                                                         PROCESSING_FOLDER);
+               processing_folder_item = processing_folder->class->create_folder(processing_folder,
+                                                                                processing_folder->node->data,
+                                                                                PROCESSING_FOLDER);
                g_assert(processing_folder_item);                                                                         
        }
        else {
index 045c43b9715fb3b8f88a92fc0ac312ec268871d0..ba8369b790ccdbc4728305a8bd3937aae1290c9f 100644 (file)
@@ -24,6 +24,7 @@
 #include <time.h>
 
 typedef struct _Folder                 Folder;
+typedef struct _FolderClass            FolderClass;
 typedef struct _LocalFolder            LocalFolder;
 typedef struct _RemoteFolder           RemoteFolder;
 #if 0
@@ -40,7 +41,7 @@ typedef struct _FolderItemUpdateData  FolderItemUpdateData;
 #include "msgcache.h"
 
 #define FOLDER(obj)            ((Folder *)obj)
-#define FOLDER_TYPE(obj)       (FOLDER(obj)->type)
+#define FOLDER_TYPE(obj)       (FOLDER(obj)->class->type)
 
 #define LOCAL_FOLDER(obj)      ((LocalFolder *)obj)
 #define REMOTE_FOLDER(obj)     ((RemoteFolder *)obj)
@@ -126,7 +127,7 @@ typedef void (*FolderItemFunc)              (FolderItem     *item,
 
 struct _Folder
 {
-       FolderType type;
+       FolderClass *class;
 
        gchar *name;
        PrefsAccount *account;
@@ -145,6 +146,12 @@ struct _Folder
        gpointer data;
 
        GHashTable *newsart;
+};
+
+struct _FolderClass
+{
+       FolderType  type;
+       gchar      *idstr;
 
        /* virtual functions */
 /*
index 6ed0c0ddcd9d7d3ea05b53da797cb72a7849b267..0c00cf39c44f86996664224ee0082b7a3cd0bba3 100644 (file)
@@ -238,7 +238,7 @@ static gboolean foldersel_gnode_func(GtkCTree *ctree, guint depth,
                name = item->name;
 
                if (!item->parent) {
-                       switch (item->folder->type) {
+                       switch (FOLDER_TYPE(item->folder)) {
                        case F_MBOX:
                                Xstrcat_a(name, name, " (MBOX)", ); break;
                        case F_MH:
@@ -311,7 +311,7 @@ static void foldersel_set_tree(Folder *cur_folder, FolderSelectionType type)
                g_return_if_fail(folder != NULL);
 
                if (type != FOLDER_SEL_ALL) {
-                       if (folder->type == F_NEWS)
+                       if (FOLDER_TYPE(folder) == F_NEWS)
                                continue;
                }
 
index 6883db18c5d207792a9f825d63337e1c9261e319..854e05c6a3a36417d6e9236c2d066bc263853cab 100644 (file)
@@ -787,10 +787,10 @@ static void folderview_scan_tree_func(Folder *folder, FolderItem *item,
 
        if (FOLDER_IS_LOCAL(folder))
                rootpath = LOCAL_FOLDER(folder)->rootpath;
-       else if (folder->type == F_IMAP && folder->account &&
+       else if (FOLDER_TYPE(folder) == F_IMAP && folder->account &&
                 folder->account->recv_server)
                rootpath = folder->account->recv_server;
-       else if (folder->type == F_NEWS && folder->account &&
+       else if (FOLDER_TYPE(folder) == F_NEWS && folder->account &&
                 folder->account->nntp_server)
                rootpath = folder->account->nntp_server;
        else
@@ -844,7 +844,7 @@ void folderview_rescan_tree(Folder *folder)
 
        g_return_if_fail(folder != NULL);
 
-       if (!folder->scan_tree) return;
+       if (!folder->class->scan_tree) return;
 
        inc_lock();
        window = label_window_create(_("Rebuilding folder tree..."));
@@ -1177,7 +1177,7 @@ static void folderview_update_node(FolderView *folderview, GtkCTreeNode *node)
                        openmask = folderopenxpmmask;
                }
                if (!item->parent) {
-                       switch (item->folder->type) {
+                       switch (FOLDER_TYPE(item->folder)) {
                        case F_MH:
                                name = " (MH)"; break;
                        case F_MBOX:
@@ -1191,7 +1191,7 @@ static void folderview_update_node(FolderView *folderview, GtkCTreeNode *node)
                        }
                        name = g_strconcat(item->name, name, NULL);
                } else {
-                       if (item->folder->type == F_NEWS &&
+                       if (FOLDER_TYPE(item->folder) == F_NEWS &&
                            item->path &&
                            !strcmp2(item->name, item->path))
                                name = get_abbrev_newsgroup_name
@@ -1418,7 +1418,7 @@ void folderview_new_folder(FolderView *folderview)
        g_return_if_fail(item != NULL);
        g_return_if_fail(item->folder != NULL);
 
-       switch (item->folder->type) {
+       switch (FOLDER_TYPE(item->folder)) {
        case F_MBOX:
                folderview_new_mbox_folder_cb(folderview, 0, NULL);
                break;
@@ -1448,7 +1448,7 @@ void folderview_rename_folder(FolderView *folderview)
        if (!item->path) return;
        if (item->stype != F_NORMAL) return;
 
-       switch (item->folder->type) {
+       switch (FOLDER_TYPE(item->folder)) {
        case F_MBOX:
                folderview_rename_mbox_folder_cb(folderview, 0, NULL);
        case F_MH:
@@ -1475,7 +1475,7 @@ void folderview_delete_folder(FolderView *folderview)
        if (!item->path) return;
        if (item->stype != F_NORMAL) return;
 
-       switch (item->folder->type) {
+       switch (FOLDER_TYPE(item->folder)) {
        case F_MH:
        case F_MBOX:
        case F_MAILDIR:
@@ -1733,7 +1733,7 @@ static void folderview_selected(GtkCTree *ctree, GtkCTreeNode *row,
        if (item->folder) 
                toolbar_set_compose_button
                        (folderview->mainwin->toolbar,
-                        item->folder->type == F_NEWS ? 
+                        FOLDER_TYPE(item->folder) == F_NEWS ? 
                         COMPOSEBUTTON_NEWS : COMPOSEBUTTON_MAIL);
 
        if (item->path)
@@ -1953,7 +1953,7 @@ static void folderview_new_folder_cb(FolderView *folderview, guint action,
                                  _("NewFolder"));
        if (!new_folder) return;
 
-       if (item->folder->type != F_MBOX) {
+       if (FOLDER_TYPE(item->folder) != F_MBOX) {
                if (strchr(new_folder, G_DIR_SEPARATOR) != NULL) {
                        alertpanel_error(_("`%c' can't be included in folder name."),
                                         G_DIR_SEPARATOR);
@@ -2070,7 +2070,7 @@ static void folderview_rename_folder_cb(FolderView *folderview, guint action,
        Xstrdup_a(old_path, item->path, {g_free(new_folder); return;});
        old_id = folder_item_get_identifier(item);
 
-       if (item->folder->rename_folder(item->folder, item, new_folder) < 0) {
+       if (item->folder->class->rename_folder(item->folder, item, new_folder) < 0) {
                g_free(old_id);
                g_free(new_folder);
                return;
@@ -2137,7 +2137,7 @@ static void folderview_rename_mbox_folder_cb(FolderView *folderview,
                return;
        }
 
-       if (item->folder->rename_folder(item->folder, item, new_folder) < 0) {
+       if (item->folder->class->rename_folder(item->folder, item, new_folder) < 0) {
                g_free(new_folder);
                return;
        }
@@ -2191,7 +2191,7 @@ static void folderview_delete_folder_cb(FolderView *folderview, guint action,
        Xstrdup_a(old_path, item->path, return);
        old_id = folder_item_get_identifier(item);
 
-       if (item->folder->remove_folder(item->folder, item) < 0) {
+       if (item->folder->class->remove_folder(item->folder, item) < 0) {
                alertpanel_error(_("Can't remove the folder `%s'."), name);
                if (folderview->opened == folderview->selected)
                        summary_show(folderview->summaryview,
@@ -2269,7 +2269,7 @@ static void folderview_new_imap_folder_cb(FolderView *folderview, guint action,
        item = gtk_ctree_node_get_row_data(ctree, folderview->selected);
        g_return_if_fail(item != NULL);
        g_return_if_fail(item->folder != NULL);
-       g_return_if_fail(item->folder->type == F_IMAP);
+       g_return_if_fail(FOLDER_TYPE(item->folder) == F_IMAP);
        g_return_if_fail(item->folder->account != NULL);
 
        new_folder = input_dialog
@@ -2327,7 +2327,7 @@ static void folderview_rm_imap_server_cb(FolderView *folderview, guint action,
        item = gtk_ctree_node_get_row_data(ctree, folderview->selected);
        g_return_if_fail(item != NULL);
        g_return_if_fail(item->folder != NULL);
-       g_return_if_fail(item->folder->type == F_IMAP);
+       g_return_if_fail(FOLDER_TYPE(item->folder) == F_IMAP);
        g_return_if_fail(item->folder->account != NULL);
 
        name_ = trim_string(item->folder->name, 32);
@@ -2377,7 +2377,7 @@ static void folderview_new_news_group_cb(FolderView *folderview, guint action,
        g_return_if_fail(item != NULL);
        folder = item->folder;
        g_return_if_fail(folder != NULL);
-       g_return_if_fail(folder->type == F_NEWS);
+       g_return_if_fail(FOLDER_TYPE(folder) == F_NEWS);
        g_return_if_fail(folder->account != NULL);
 
        if (GTK_CTREE_ROW(folderview->selected)->parent != NULL)
@@ -2462,7 +2462,7 @@ static void folderview_rm_news_group_cb(FolderView *folderview, guint action,
        item = gtk_ctree_node_get_row_data(ctree, folderview->selected);
        g_return_if_fail(item != NULL);
        g_return_if_fail(item->folder != NULL);
-       g_return_if_fail(item->folder->type == F_NEWS);
+       g_return_if_fail(FOLDER_TYPE(item->folder) == F_NEWS);
        g_return_if_fail(item->folder->account != NULL);
 
        name_ = trim_string(item->path, 32);
@@ -2501,7 +2501,7 @@ static void folderview_rm_news_server_cb(FolderView *folderview, guint action,
        item = gtk_ctree_node_get_row_data(ctree, folderview->selected);
        g_return_if_fail(item != NULL);
        g_return_if_fail(item->folder != NULL);
-       g_return_if_fail(item->folder->type == F_NEWS);
+       g_return_if_fail(FOLDER_TYPE(item->folder) == F_NEWS);
        g_return_if_fail(item->folder->account != NULL);
 
        name_ = trim_string(item->folder->name, 32);
@@ -2583,12 +2583,12 @@ static void folderview_move_to_cb(FolderView *folderview)
 
        if (folderview->selected)
                from_folder = gtk_ctree_node_get_row_data(GTK_CTREE(folderview->ctree), folderview->selected);
-       if (!from_folder || from_folder->folder->type == F_NEWS)
+       if (!from_folder || FOLDER_TYPE(from_folder->folder) == F_NEWS)
                return;
 
        to_folder = foldersel_folder_sel(from_folder->folder, FOLDER_SEL_MOVE, NULL);
        
-       if (!to_folder || to_folder->folder->type == F_NEWS)
+       if (!to_folder || FOLDER_TYPE(to_folder->folder) == F_NEWS)
                return;
 
        folderview_move_to(folderview, from_folder, to_folder);
@@ -2683,7 +2683,7 @@ static gboolean folderview_drag_motion_cb(GtkWidget      *widget,
 
                if (item && item->folder && item->path &&
                    src_item && src_item != item) {
-                       switch (item->folder->type) {
+                       switch (FOLDER_TYPE(item->folder)) {
                        case F_MH:
                        case F_MBOX:
                        case F_IMAP:
@@ -2695,7 +2695,7 @@ static gboolean folderview_drag_motion_cb(GtkWidget      *widget,
                } else if (item && item->folder && folder_item_get_path(item) &&
                           src_item && src_item != item) {
                        /* a root folder - acceptable only from folderview */
-                       if (item->folder->type == F_MH || item->folder->type == F_IMAP)
+                       if (FOLDER_TYPE(item->folder) == F_MH || FOLDER_TYPE(item->folder) == F_IMAP)
                                acceptable = TRUE;
                }
                        
@@ -2764,7 +2764,7 @@ static void folderview_drag_received_cb(GtkWidget        *widget,
                /* re-check (due to acceptable possibly set for folder moves */
                if (!(item && item->folder && item->path &&
                      src_item && src_item != item && 
-                     (item->folder->type == F_MH || item->folder->type == F_IMAP))) {
+                     (FOLDER_TYPE(item->folder) == F_MH || FOLDER_TYPE(item->folder) == F_IMAP))) {
                        return;
                }
                if (item && src_item) {
@@ -2776,8 +2776,8 @@ static void folderview_drag_received_cb(GtkWidget        *widget,
                                case GDK_ACTION_MOVE:
                                case GDK_ACTION_DEFAULT:
                                default:
-                       if (src_item->folder->type != item->folder->type ||
-                           (item->folder->type == F_IMAP &&
+                       if (FOLDER_TYPE(src_item->folder) != FOLDER_TYPE(item->folder) ||
+                           (FOLDER_TYPE(item->folder) == F_IMAP &&
                             src_item->folder != item->folder))
                                summary_copy_selected_to(folderview->summaryview, item);
                        else
index c4a1a146ec159c5967045ff75ea17ee61e7ba1ff..eb0224700cb464cb56cdd404b08af192a69bf554 100644 (file)
@@ -294,11 +294,46 @@ MsgInfo *imap_get_msginfo                         (Folder         *folder,
 gboolean imap_check_msgnum_validity            (Folder         *folder,
                                                 FolderItem     *item);
 
+FolderClass imap_class =
+{
+       F_IMAP,
+       "imap",
+
+       imap_folder_item_new,
+       imap_folder_item_destroy,
+       imap_fetch_msg,
+       imap_get_msginfo,
+       imap_get_msginfos,
+       imap_add_msg,
+       imap_move_msg,
+       NULL,
+       imap_copy_msg,
+       NULL,
+       imap_remove_msg,
+       imap_remove_msgs,
+       imap_remove_all_msg,
+       imap_is_msg_changed,
+       NULL,
+       imap_get_num_list,
+       imap_scan_tree,
+       imap_create_tree,
+       imap_create_folder,
+       imap_rename_folder,
+       imap_remove_folder,
+       imap_folder_destroy,
+       NULL,
+       NULL,
+       NULL,
+       NULL,
+       imap_check_msgnum_validity,
+};
+
 Folder *imap_folder_new(const gchar *name, const gchar *path)
 {
        Folder *folder;
 
        folder = (Folder *)g_new0(IMAPFolder, 1);
+       folder->class = &imap_class;
        imap_folder_init(folder, name, path);
 
        return folder;
@@ -319,43 +354,7 @@ void imap_folder_destroy(Folder *folder)
 static void imap_folder_init(Folder *folder, const gchar *name,
                             const gchar *path)
 {
-       folder->type = F_IMAP;
-
        folder_remote_folder_init((Folder *)folder, name, path);
-
-/*
-       folder->get_msg_list        = imap_get_msg_list;
-*/
-       folder->item_new              = imap_folder_item_new;
-       folder->item_destroy          = imap_folder_item_destroy;
-       folder->fetch_msg             = imap_fetch_msg;
-       folder->add_msg               = imap_add_msg;
-       folder->move_msg              = imap_move_msg;
-/*
-       folder->move_msgs_with_dest   = imap_move_msgs_with_dest;
-*/
-       folder->copy_msg              = imap_copy_msg;
-/*
-       folder->copy_msgs_with_dest   = imap_copy_msgs_with_dest;
-*/
-       folder->remove_msg            = imap_remove_msg;
-       folder->remove_msgs           = imap_remove_msgs;
-       folder->remove_all_msg        = imap_remove_all_msg;
-       folder->is_msg_changed        = imap_is_msg_changed;
-/*
-       folder->scan                = imap_scan_folder;
-*/
-       folder->scan_tree             = imap_scan_tree;
-       folder->create_tree           = imap_create_tree;
-       folder->create_folder         = imap_create_folder;
-       folder->rename_folder         = imap_rename_folder;
-       folder->remove_folder         = imap_remove_folder;
-       folder->destroy               = imap_folder_destroy;
-       folder->check_msgnum_validity = imap_check_msgnum_validity;
-
-       folder->get_num_list          = imap_get_num_list;
-       folder->get_msginfo           = imap_get_msginfo;
-       folder->get_msginfos          = imap_get_msginfos;
 }
 
 static FolderItem *imap_folder_item_new(Folder *folder)
@@ -406,7 +405,7 @@ static IMAPSession *imap_session_get(Folder *folder)
        gushort port;
 
        g_return_val_if_fail(folder != NULL, NULL);
-       g_return_val_if_fail(folder->type == F_IMAP, NULL);
+       g_return_val_if_fail(FOLDER_TYPE(folder) == F_IMAP, NULL);
        g_return_val_if_fail(folder->account != NULL, NULL);
 
 #if USE_OPENSSL
@@ -692,7 +691,7 @@ static gint imap_do_copy(Folder *folder, FolderItem *dest, MsgInfo *msginfo,
        gint ok;
     
        g_return_val_if_fail(folder != NULL, -1);
-       g_return_val_if_fail(folder->type == F_IMAP, -1);
+       g_return_val_if_fail(FOLDER_TYPE(folder) == F_IMAP, -1);
        g_return_val_if_fail(dest != NULL, -1);
        g_return_val_if_fail(msginfo != NULL, -1);
 
@@ -936,7 +935,7 @@ gint imap_remove_msg(Folder *folder, FolderItem *item, gint uid)
        gchar *dir;
 
        g_return_val_if_fail(folder != NULL, -1);
-       g_return_val_if_fail(folder->type == F_IMAP, -1);
+       g_return_val_if_fail(FOLDER_TYPE(folder) == F_IMAP, -1);
        g_return_val_if_fail(item != NULL, -1);
 
        session = imap_session_get(folder);
@@ -979,7 +978,7 @@ gint imap_remove_msgs(Folder *folder, FolderItem *item, GSList *msglist)
        guint32 uid;
 
        g_return_val_if_fail(folder != NULL, -1);
-       g_return_val_if_fail(folder->type == F_IMAP, -1);
+       g_return_val_if_fail(FOLDER_TYPE(folder) == F_IMAP, -1);
        g_return_val_if_fail(item != NULL, -1);
        g_return_val_if_fail(msglist != NULL, -1);
 
@@ -1606,7 +1605,7 @@ static GSList *imap_get_uncached_messages(IMAPSession *session,
        g_return_val_if_fail(session != NULL, NULL);
        g_return_val_if_fail(item != NULL, NULL);
        g_return_val_if_fail(item->folder != NULL, NULL);
-       g_return_val_if_fail(item->folder->type == F_IMAP, NULL);
+       g_return_val_if_fail(FOLDER_TYPE(item->folder) == F_IMAP, NULL);
        g_return_val_if_fail(first_uid <= last_uid, NULL);
 
        if (imap_cmd_envelope(SESSION(session)->sock, first_uid, last_uid)
@@ -1671,7 +1670,7 @@ static void imap_delete_all_cached_messages(FolderItem *item)
 
        g_return_if_fail(item != NULL);
        g_return_if_fail(item->folder != NULL);
-       g_return_if_fail(item->folder->type == F_IMAP);
+       g_return_if_fail(FOLDER_TYPE(item->folder) == F_IMAP);
 
        debug_print("Deleting all cached messages...\n");
 
@@ -2205,7 +2204,7 @@ gint imap_msg_set_perm_flags(MsgInfo *msginfo, MsgPermFlags flags)
        g_return_val_if_fail(msginfo->folder->folder != NULL, -1);
 
        folder = msginfo->folder->folder;
-       g_return_val_if_fail(folder->type == F_IMAP, -1);
+       g_return_val_if_fail(FOLDER_TYPE(folder) == F_IMAP, -1);
 
        session = imap_session_get(folder);
        if (!session) return -1;
@@ -2241,7 +2240,7 @@ gint imap_msg_unset_perm_flags(MsgInfo *msginfo, MsgPermFlags flags)
        g_return_val_if_fail(msginfo->folder->folder != NULL, -1);
 
        folder = msginfo->folder->folder;
-       g_return_val_if_fail(folder->type == F_IMAP, -1);
+       g_return_val_if_fail(FOLDER_TYPE(folder) == F_IMAP, -1);
 
        session = imap_session_get(folder);
        if (!session) return -1;
@@ -3298,7 +3297,7 @@ gint imap_get_num_list(Folder *folder, FolderItem *_item, GSList **msgnum_list)
        g_return_val_if_fail(folder != NULL, -1);
        g_return_val_if_fail(item != NULL, -1);
        g_return_val_if_fail(item->item.path != NULL, -1);
-       g_return_val_if_fail(folder->type == F_IMAP, -1);
+       g_return_val_if_fail(FOLDER_TYPE(folder) == F_IMAP, -1);
        g_return_val_if_fail(folder->account != NULL, -1);
 
        session = imap_session_get(folder);
@@ -3533,7 +3532,7 @@ gboolean imap_check_msgnum_validity(Folder *folder, FolderItem *_item)
        g_return_val_if_fail(folder != NULL, FALSE);
        g_return_val_if_fail(item != NULL, FALSE);
        g_return_val_if_fail(item->item.folder != NULL, FALSE);
-       g_return_val_if_fail(item->item.folder->type == F_IMAP, FALSE);
+       g_return_val_if_fail(FOLDER_TYPE(&item->item.folder) == F_IMAP, FALSE);
 
        session = imap_session_get(folder);
        g_return_val_if_fail(session != NULL, FALSE);
index 8aeeadbb0b8a6b29d88be47d53607b693667fd73..2191fe8b118d9dbd89caf18c9b13a49abc27f6f5 100644 (file)
@@ -1398,7 +1398,7 @@ void main_window_add_mailbox(MainWindow *mainwin)
                folder = folder_new(F_MH, g_basename(path), path);
        g_free(path);
 
-       if (folder->create_tree(folder) < 0) {
+       if (folder->class->create_tree(folder) < 0) {
                alertpanel_error(_("Creation of the mailbox failed.\n"
                                   "Maybe some files already exist, or you don't have the permission to write there."));
                folder_destroy(folder);
@@ -1440,7 +1440,7 @@ void main_window_add_mbox(MainWindow *mainwin)
        folder = folder_new(F_MBOX, g_basename(path), path);
        g_free(path);
 
-       if (folder->create_tree(folder) < 0) {
+       if (folder->class->create_tree(folder) < 0) {
                alertpanel_error(_("Creation of the mailbox failed."));
                folder_destroy(folder);
                return;
@@ -1497,7 +1497,7 @@ SensitiveCond main_window_get_current_state(MainWindow *mainwin)
        if (selection == SUMMARY_SELECTED_SINGLE)
                state |= M_SINGLE_TARGET_EXIST;
        if (mainwin->summaryview->folder_item &&
-           mainwin->summaryview->folder_item->folder->type == F_NEWS)
+           mainwin->summaryview->folder_item->folder->class->type == F_NEWS)
                state |= M_NEWS;
        else
                state |= M_NOT_NEWS;
index c9b7f18c71ae761a6e2f2330a5f7458b35f53c83..3864fddc3ad17346e5e87a521eb574f54da9a745 100644 (file)
@@ -50,11 +50,46 @@ MsgInfo *mbox_get_msginfo(Folder *folder, FolderItem *item, gint num);
 gint mbox_get_num_list(Folder *folder, FolderItem *item, GSList **list);
 gboolean mbox_check_msgnum_validity(Folder *folder, FolderItem *item);
 
+FolderClass mbox_class =
+{
+       F_MBOX,
+       "mbox",
+
+       NULL,
+       NULL,
+       mbox_fetch_msg,
+       mbox_get_msginfo,
+       NULL,
+       mbox_add_msg,
+       NULL,
+       NULL,
+       mbox_copy_msg,
+       NULL,
+       mbox_remove_msg,
+       NULL,
+       mbox_remove_all_msg,
+       NULL,
+       NULL,
+       mbox_get_num_list,
+       NULL,
+       mbox_create_tree,
+       mbox_create_folder,
+       mbox_rename_folder,
+       mbox_remove_folder,
+       mbox_folder_destroy,
+       NULL,
+       NULL,
+       NULL,
+       NULL,
+       mbox_check_msgnum_validity,
+};
+
 Folder *mbox_folder_new(const gchar *name, const gchar *path)
 {
        Folder *folder;
 
        folder = (Folder *)g_new0(MBOXFolder, 1);
+       folder->class = &mbox_class;
        mbox_folder_init(folder, name, path);
 
        return folder;
@@ -67,30 +102,7 @@ void mbox_folder_destroy(Folder *folder)
 
 static void mbox_folder_init(Folder *folder, const gchar *name, const gchar *path)
 {
-       folder->type = F_MBOX;
-
        folder_local_folder_init(folder, name, path);
-
-/*
-       folder->get_msg_list        = mbox_get_msg_list;
-*/
-       folder->fetch_msg           = mbox_fetch_msg;
-       folder->get_msginfo         = mbox_get_msginfo;
-       folder->add_msg             = mbox_add_msg;
-       folder->copy_msg            = mbox_copy_msg;
-       folder->remove_msg          = mbox_remove_msg;
-       folder->remove_all_msg      = mbox_remove_all_msg;
-/*
-       folder->scan                = mbox_scan_folder;
-*/
-       folder->get_num_list        = mbox_get_num_list;
-       folder->create_tree         = mbox_create_tree;
-       folder->create_folder       = mbox_create_folder;
-       folder->rename_folder       = mbox_rename_folder;
-       folder->remove_folder       = mbox_remove_folder;
-       folder->destroy             = mbox_folder_destroy;
-       folder->check_msgnum_validity
-                                   = mbox_check_msgnum_validity;
 }
 
 static void mbox_folder_create_parent(const gchar * path)
@@ -1638,21 +1650,18 @@ gint mbox_copy_msg(Folder *folder, FolderItem *dest, MsgInfo *msginfo)
 
        src_folder = msginfo->folder->folder;
        
-       g_return_val_if_fail(src_folder->fetch_msg != NULL, -1);
-       
        /*
        mbox_path = mbox_folder_get_path(msginfo->folder);
        mbox_rewrite(mbox_path);
        g_free(mbox_path);
        */
 
-       filename = src_folder->fetch_msg(src_folder,
-                                        msginfo->folder,
+       filename = folder_item_fetch_msg(msginfo->folder,
                                         msginfo->msgnum);
        if (filename == NULL)
                return -1;
 
-       num = folder->add_msg(folder, dest, filename, FALSE);
+       num = mbox_add_msg(folder, dest, filename, FALSE);
 
        /*
        mbox_path = mbox_folder_get_path(dest);
index 81f142e950ebc3f032c4779159c743f3cdc01480..eb83b9b98721830b5de5ee1700c81e93349f6f2b 100644 (file)
--- a/src/mh.c
+++ b/src/mh.c
@@ -108,11 +108,46 @@ static gboolean mh_rename_folder_func             (GNode          *node,
                                                 gpointer        data);
 
 
+FolderClass mh_class =
+{
+       F_MH,
+       "mh",
+
+       NULL,
+       NULL,
+       mh_fetch_msg,
+       mh_get_msginfo,
+       NULL,
+       mh_add_msg,
+       mh_move_msg,
+       mh_move_msgs_with_dest,
+       mh_copy_msg,
+       mh_copy_msgs_with_dest,
+       mh_remove_msg,
+       NULL,
+       mh_remove_all_msg,
+       mh_is_msg_changed,
+       NULL,
+       mh_get_num_list,
+       mh_scan_tree,
+       mh_create_tree,
+       mh_create_folder,
+       mh_rename_folder,
+       mh_remove_folder,
+       mh_folder_destroy,
+       NULL,
+       NULL,
+       NULL,
+       NULL,
+       NULL,
+};
+
 Folder *mh_folder_new(const gchar *name, const gchar *path)
 {
        Folder *folder;
 
        folder = (Folder *)g_new0(MHFolder, 1);
+       folder->class = &mh_class;
        mh_folder_init(folder, name, path);
 
        return folder;
@@ -125,29 +160,8 @@ void mh_folder_destroy(Folder *folder)
 
 static void mh_folder_init(Folder *folder, const gchar *name, const gchar *path)
 {
-       folder->type = F_MH;
-
        folder_local_folder_init(folder, name, path);
 
-/*     folder->get_msg_list        = mh_get_msg_list; */
-       folder->fetch_msg           = mh_fetch_msg;
-       folder->get_msginfo         = mh_get_msginfo;
-       folder->add_msg             = mh_add_msg;
-       folder->move_msg            = mh_move_msg;
-       folder->move_msgs_with_dest = mh_move_msgs_with_dest;
-       folder->copy_msg            = mh_copy_msg;
-       folder->copy_msgs_with_dest = mh_copy_msgs_with_dest;
-       folder->remove_msg          = mh_remove_msg;
-       folder->remove_all_msg      = mh_remove_all_msg;
-       folder->is_msg_changed      = mh_is_msg_changed;
-/*     folder->scan                = mh_scan_folder; */
-       folder->get_num_list        = mh_get_num_list;
-       folder->scan_tree           = mh_scan_tree;
-       folder->create_tree         = mh_create_tree;
-       folder->create_folder       = mh_create_folder;
-       folder->rename_folder       = mh_rename_folder;
-       folder->remove_folder       = mh_remove_folder;
-       folder->destroy             = mh_folder_destroy;
 }
 
 void mh_get_last_num(Folder *folder, FolderItem *item)
index 246a3b871f125ff9a9865b1f85affa69f81146f9..7ec2929c4a5bc83ea32a8d4b40bc52964472306b 100644 (file)
@@ -106,11 +106,46 @@ GSList *news_get_msginfos          (Folder        *folder,
 gint news_post_stream                   (Folder        *folder, 
                                          FILE          *fp);
 
+FolderClass news_class =
+{
+       F_NEWS,
+       "news",
+
+       NULL,
+       NULL,
+       news_fetch_msg,
+       news_get_msginfo,
+       news_get_msginfos,
+       NULL,
+       NULL,
+       NULL,
+       NULL,
+       NULL,
+       news_remove_msg,
+       NULL,
+       NULL,
+       NULL,
+       NULL,
+       news_get_num_list,
+       NULL,
+       NULL,
+       NULL,
+       NULL,
+       NULL,
+       news_folder_destroy,
+       NULL,
+       NULL,
+       NULL,
+       NULL,
+       NULL,
+};
+
 Folder *news_folder_new(const gchar *name, const gchar *path)
 {
        Folder *folder;
 
        folder = (Folder *)g_new0(NewsFolder, 1);
+       folder->class = &news_class;
        news_folder_init(folder, name, path);
 
        return folder;
@@ -131,22 +166,7 @@ void news_folder_destroy(Folder *folder)
 static void news_folder_init(Folder *folder, const gchar *name,
                             const gchar *path)
 {
-       folder->type = F_NEWS;
-
        folder_remote_folder_init(folder, name, path);
-
-/*
-       folder->get_msg_list = news_get_article_list;
-*/
-       folder->fetch_msg    = news_fetch_msg;
-/*
-       folder->scan         = news_scan_group;
-*/
-       folder->destroy      = news_folder_destroy;
-       folder->remove_msg   = news_remove_msg;
-       folder->get_num_list = news_get_num_list;
-       folder->get_msginfo  = news_get_msginfo;
-       folder->get_msginfos = news_get_msginfos;
 }
 
 #if USE_OPENSSL
@@ -252,7 +272,7 @@ NNTPSession *news_session_get(Folder *folder)
        RemoteFolder *rfolder = REMOTE_FOLDER(folder);
 
        g_return_val_if_fail(folder != NULL, NULL);
-       g_return_val_if_fail(folder->type == F_NEWS, NULL);
+       g_return_val_if_fail(FOLDER_TYPE(folder) == F_NEWS, NULL);
        g_return_val_if_fail(folder->account != NULL, NULL);
 
        if (!rfolder->session) {
@@ -419,7 +439,7 @@ GSList *news_get_group_list(Folder *folder)
        gchar buf[NNTPBUFSIZE];
 
        g_return_val_if_fail(folder != NULL, NULL);
-       g_return_val_if_fail(folder->type == F_NEWS, NULL);
+       g_return_val_if_fail(FOLDER_TYPE(folder) == F_NEWS, NULL);
 
        path = folder_item_get_path(FOLDER_ITEM(folder->node->data));
        if (!is_dir_exist(path))
@@ -506,7 +526,7 @@ void news_remove_group_list_cache(Folder *folder)
        gchar *path, *filename;
 
        g_return_if_fail(folder != NULL);
-       g_return_if_fail(folder->type == F_NEWS);
+       g_return_if_fail(FOLDER_TYPE(folder) == F_NEWS);
 
        path = folder_item_get_path(FOLDER_ITEM(folder->node->data));
        filename = g_strconcat(path, G_DIR_SEPARATOR_S, NEWSGROUP_LIST, NULL);
@@ -525,7 +545,7 @@ gint news_post(Folder *folder, const gchar *file)
        gint ok;
 
        g_return_val_if_fail(folder != NULL, -1);
-       g_return_val_if_fail(folder->type == F_NEWS, -1);
+       g_return_val_if_fail(FOLDER_TYPE(folder) == F_NEWS, -1);
        g_return_val_if_fail(file != NULL, -1);
 
        if ((fp = fopen(file, "rb")) == NULL) {
@@ -546,7 +566,7 @@ gint news_post_stream(Folder *folder, FILE *fp)
        gint ok;
 
        g_return_val_if_fail(folder != NULL, -1);
-       g_return_val_if_fail(folder->type == F_NEWS, -1);
+       g_return_val_if_fail(FOLDER_TYPE(folder) == F_NEWS, -1);
        g_return_val_if_fail(fp != NULL, -1);
 
        session = news_session_get(folder);
@@ -785,7 +805,7 @@ gint news_get_num_list(Folder *folder, FolderItem *item, GSList **msgnum_list)
 
        g_return_val_if_fail(item != NULL, -1);
        g_return_val_if_fail(item->folder != NULL, -1);
-       g_return_val_if_fail(item->folder->type == F_NEWS, -1);
+       g_return_val_if_fail(FOLDER_TYPE(folder) == F_NEWS, -1);
 
        session = news_session_get(folder);
        g_return_val_if_fail(session != NULL, -1);
@@ -833,7 +853,7 @@ MsgInfo *news_get_msginfo(Folder *folder, FolderItem *item, gint num)
        g_return_val_if_fail(session != NULL, NULL);
        g_return_val_if_fail(item != NULL, NULL);
        g_return_val_if_fail(item->folder != NULL, NULL);
-       g_return_val_if_fail(item->folder->type == F_NEWS, NULL);
+       g_return_val_if_fail(FOLDER_TYPE(item->folder) == F_NEWS, NULL);
 
        log_message(_("getting xover %d in %s...\n"),
                    num, item->path);
@@ -1019,7 +1039,7 @@ GSList *news_get_msginfos(Folder *folder, FolderItem *item, GSList *msgnum_list)
        guint tofetch, fetched;
        
        g_return_val_if_fail(folder != NULL, NULL);
-       g_return_val_if_fail(folder->type == F_NEWS, NULL);
+       g_return_val_if_fail(FOLDER_TYPE(folder) == F_NEWS, NULL);
        g_return_val_if_fail(msgnum_list != NULL, NULL);
        g_return_val_if_fail(item != NULL, NULL);
        
index c8cd52b9469ba29939adb43a466fa60ddd8cafb6..bada3cf01ba178e714b95bbfbbac8129aecc0887 100644 (file)
@@ -396,7 +396,7 @@ static void prefs_scoring_set_dialog(ScoringProp * cond)
                prefs_scoring = cur_item->prefs->scoring;
                cur_kill_score = cur_item->prefs->kill_score;
                cur_important_score = cur_item->prefs->important_score;
-               if (cur_item->folder->type != F_NEWS) {
+               if (FOLDER_TYPE(cur_item->folder) != F_NEWS) {
                        gtk_widget_hide(scoring.kill_score_label);
                        gtk_widget_hide(scoring.kill_score_entry);
                }
index 95e1415600ac7b8ac9323bbc3e5b6501f1828dce..2240b14ec3065591a820080be29db026a5011769 100644 (file)
@@ -1058,10 +1058,10 @@ gint procmsg_send_message_queue(const gchar *file)
 
 #define CHANGE_FLAGS(msginfo) \
 { \
-if (msginfo->folder->folder->change_flags != NULL) \
-msginfo->folder->folder->change_flags(msginfo->folder->folder, \
-                                     msginfo->folder, \
-                                     msginfo); \
+if (msginfo->folder->folder->class->change_flags != NULL) \
+msginfo->folder->folder->class->change_flags(msginfo->folder->folder, \
+                                            msginfo->folder, \
+                                            msginfo); \
 }
 
 void procmsg_msginfo_set_flags(MsgInfo *msginfo, MsgPermFlags perm_flags, MsgTmpFlags tmp_flags)
@@ -1116,7 +1116,7 @@ void procmsg_msginfo_set_flags(MsgInfo *msginfo, MsgPermFlags perm_flags, MsgTmp
 
        }
 
-       if (msginfo->folder->folder->type == F_IMAP)
+       if (FOLDER_TYPE(msginfo->folder->folder) == F_IMAP)
                imap_msg_set_perm_flags(msginfo, perm_flags);
 
        msginfo->flags.perm_flags |= perm_flags;
@@ -1181,7 +1181,7 @@ void procmsg_msginfo_unset_flags(MsgInfo *msginfo, MsgPermFlags perm_flags, MsgT
 
        }
 
-       if (msginfo->folder->folder->type == F_IMAP)
+       if (FOLDER_TYPE(msginfo->folder->folder) == F_IMAP)
                imap_msg_unset_perm_flags(msginfo, perm_flags);
 
        msginfo->flags.perm_flags &= ~perm_flags;
index 8d2798aad6925c4f83bb05719b9cf4a1d44ddb5c..32b9fb53335e2b7108f7db65126094a9b91c1c63 100644 (file)
@@ -59,7 +59,7 @@ void setup(MainWindow *mainwin)
                folder = folder_new(F_MH, g_basename(path), path);
        g_free(path);
 
-       if (folder->create_tree(folder) < 0) {
+       if (folder->class->create_tree(folder) < 0) {
                alertpanel_error(_("Creation of the mailbox failed.\n"
                                   "Maybe some files already exist, or you don't have the permission to write there."));
                folder_destroy(folder);
index b88a3af40a355f0fa292b99b23a9829236f63499..91c3671aad9a5d5219b46b8556a0dce4066fbbba 100644 (file)
@@ -933,7 +933,7 @@ gboolean summary_show(SummaryView *summaryview, FolderItem *item)
 
        buf = NULL;
        if (!item || !item->path || !item->parent || item->no_select ||
-           (item->folder->type == F_MH &&
+           (FOLDER_TYPE(item->folder) == F_MH &&
             ((buf = folder_item_get_path(item)) == NULL ||
              change_dir(buf) < 0))) {
                g_free(buf);
@@ -1270,7 +1270,7 @@ static void summary_set_menu_sensitive(SummaryView *summaryview)
                return;
        }
 
-       if (summaryview->folder_item->folder->type != F_NEWS)
+       if (FOLDER_TYPE(summaryview->folder_item->folder) != F_NEWS)
                menu_set_sensitive(ifactory, "/Move...", TRUE);
        else
                menu_set_sensitive(ifactory, "/Move...", FALSE);
@@ -1933,7 +1933,7 @@ static void summary_status_show(SummaryView *summaryview)
                }
        }
 
-       if (summaryview->folder_item->folder->type == F_NEWS) {
+       if (FOLDER_TYPE(summaryview->folder_item->folder) == F_NEWS) {
                if (summaryview->folder_item->path != NULL) {
                        gchar *group;
                        group = get_abbrev_newsgroup_name
@@ -2835,7 +2835,7 @@ static void summary_mark_row_as_read(SummaryView *summaryview,
 
        msginfo = gtk_ctree_node_get_row_data(ctree, row);
 
-       if(!MSG_IS_NEW(msginfo->flags) && !MSG_IS_UNREAD(msginfo->flags))
+       if(!(MSG_IS_NEW(msginfo->flags) || MSG_IS_UNREAD(msginfo->flags)))
                return;
 
        if (MSG_IS_NEW(msginfo->flags) && !MSG_IS_IGNORE_THREAD(msginfo->flags))
@@ -2877,11 +2877,6 @@ void summary_mark_all_read(SummaryView *summaryview)
        for (node = GTK_CTREE_NODE(GTK_CLIST(ctree)->row_list); node != NULL;
             node = gtkut_ctree_node_next(ctree, node))
                summary_mark_row_as_read(summaryview, node);
-       for (node = GTK_CTREE_NODE(GTK_CLIST(ctree)->row_list); node != NULL;
-            node = gtkut_ctree_node_next(ctree, node)) {
-               if (!GTK_CTREE_ROW(node)->expanded)
-                       summary_set_row_marks(summaryview, node);
-       }
        gtk_clist_thaw(clist);
        folder_item_update_thaw();
 
@@ -2935,7 +2930,7 @@ static gboolean check_permission(SummaryView *summaryview, MsgInfo * msginfo)
        GList * cur;
        gboolean found;
 
-       switch (summaryview->folder_item->folder->type) {
+       switch (FOLDER_TYPE(summaryview->folder_item->folder)) {
 
        case F_NEWS:
 
@@ -3106,7 +3101,7 @@ void summary_delete(SummaryView *summaryview)
 void summary_delete_duplicated(SummaryView *summaryview)
 {
        if (!summaryview->folder_item ||
-           summaryview->folder_item->folder->type == F_NEWS) return;
+           FOLDER_TYPE(summaryview->folder_item->folder) == F_NEWS) return;
        if (summaryview->folder_item->stype == F_TRASH) return;
 
        main_window_cursor_wait(summaryview->mainwin);
@@ -3219,7 +3214,7 @@ void summary_move_selected_to(SummaryView *summaryview, FolderItem *to_folder)
 
        if (!to_folder) return;
        if (!summaryview->folder_item ||
-           summaryview->folder_item->folder->type == F_NEWS) return;
+           FOLDER_TYPE(summaryview->folder_item->folder) == F_NEWS) return;
 
        if (summary_is_locked(summaryview)) return;
 
@@ -3255,7 +3250,7 @@ void summary_move_to(SummaryView *summaryview)
        FolderItem *to_folder;
 
        if (!summaryview->folder_item ||
-           summaryview->folder_item->folder->type == F_NEWS) return;
+           FOLDER_TYPE(summaryview->folder_item->folder) == F_NEWS) return;
 
        to_folder = foldersel_folder_sel(summaryview->folder_item->folder,
                                         FOLDER_SEL_MOVE, NULL);
@@ -3638,7 +3633,7 @@ static void summary_execute_delete(SummaryView *summaryview)
        GSList *cur;
 
        trash = summaryview->folder_item->folder->trash;
-       if (summaryview->folder_item->folder->type == F_MH) {
+       if (FOLDER_TYPE(summaryview->folder_item->folder) == F_MH) {
                g_return_if_fail(trash != NULL);
        }