0.9.7claws10
authorChristoph Hohmann <reboot@gmx.ch>
Tue, 2 Dec 2003 16:50:00 +0000 (16:50 +0000)
committerChristoph Hohmann <reboot@gmx.ch>
Tue, 2 Dec 2003 16:50:00 +0000 (16:50 +0000)
* src/Makefile.am
* src/account.c
* src/folder.[ch]
* src/folderview.h
* src/imap.c
* src/localfolder.[ch]          ** NEW **
* src/mainwindow.c
* src/mh.[ch]
* src/news.[ch]
* src/prefs_account.[ch]
* src/prefs_filtering.h
* src/procmsg.h
* src/remotefolder.[ch]         ** NEW **
* src/common/xml.[ch]
        add item_set_xml() and item_get_xml() virtual functions to
        FolderClass to give folders the ability to add extra information
        to the saved FolderItem data. If NULL the default function for
        FolderItem will be used.

23 files changed:
ChangeLog.claws
configure.ac
src/Makefile.am
src/account.c
src/common/xml.c
src/common/xml.h
src/folder.c
src/folder.h
src/folderview.h
src/imap.c
src/localfolder.c [new file with mode: 0644]
src/localfolder.h [new file with mode: 0644]
src/mainwindow.c
src/mh.c
src/mh.h
src/news.c
src/news.h
src/prefs_account.c
src/prefs_account.h
src/prefs_filtering.h
src/procmsg.h
src/remotefolder.c [new file with mode: 0644]
src/remotefolder.h [new file with mode: 0644]

index c529978a2066805921d688e8d29905164083e139..349edc60541376556dc35219f8b562000a418a8f 100644 (file)
@@ -1,3 +1,24 @@
+2003-12-02 [christoph] 0.9.7claws10
+
+       * src/Makefile.am
+       * src/account.c
+       * src/folder.[ch]
+       * src/folderview.h
+       * src/imap.c
+       * src/localfolder.[ch]          ** NEW **
+       * src/mainwindow.c
+       * src/mh.[ch]
+       * src/news.[ch]
+       * src/prefs_account.[ch]
+       * src/prefs_filtering.h
+       * src/procmsg.h
+       * src/remotefolder.[ch]         ** NEW **
+       * src/common/xml.[ch]
+               add item_set_xml() and item_get_xml() virtual functions to
+               FolderClass to give folders the ability to add extra information
+               to the saved FolderItem data. If NULL the default function for
+               FolderItem will be used.
+
 2003-11-29 [christoph] 0.9.7claws9
 
        * src/procheader.c
index cdf250ac9c4dc6d668c2cc653089bd9a0c673528..2d35665afecf0179fdfe6ba3f46e46867ba6cd26 100644 (file)
@@ -11,7 +11,7 @@ MINOR_VERSION=9
 MICRO_VERSION=7
 INTERFACE_AGE=0
 BINARY_AGE=0
-EXTRA_VERSION=9
+EXTRA_VERSION=10
 if test $EXTRA_VERSION -eq 0; then
     VERSION=${MAJOR_VERSION}.${MINOR_VERSION}.${MICRO_VERSION}claws
 else
index 02fdacf55bc2a17d3814379608be9db59e6a5e26..934e67ed9611aa26fcf343d5803f066a3f8c9c19 100644 (file)
@@ -120,6 +120,8 @@ sylpheed_SOURCES = \
        toolbar.c \
        undo.c \
        unmime.c \
+       localfolder.c \
+       remotefolder.c \
        vcard.c
 
 sylpheedincludedir = $(pkgincludedir)
@@ -244,6 +246,8 @@ sylpheedinclude_HEADERS = \
        toolbar.h \
        undo.h \
        unmime.h \
+       localfolder.h \
+       remotefolder.h \
        vcard.h
 
 BUILT_SOURCES = \
index 739f0cd9708f7fee4af840d8660faa91b58d6eb2..dd2e568b62db017b042aa6ebf9c6dbd833be30c3 100644 (file)
@@ -47,6 +47,7 @@
 #include "alertpanel.h"
 #include "procheader.h"
 #include "customheader.h"
+#include "remotefolder.h"
 
 typedef enum
 {
@@ -355,7 +356,7 @@ void account_add(void)
                }
 
                folder->account = ac_prefs;
-               ac_prefs->folder = REMOTE_FOLDER(folder);
+               ac_prefs->folder = folder;
                folder_add(folder);
                if (ac_prefs->protocol == A_IMAP4)
                        folder->klass->create_tree(folder);
@@ -438,7 +439,7 @@ void account_set_missing_folder(void)
                        }
 
                        folder->account = ap;
-                       ap->folder = REMOTE_FOLDER(folder);
+                       ap->folder = folder;
                        folder_add(folder);
                        if (ap->protocol == A_IMAP4)
                                folder->klass->create_tree(folder);
index 578304482b487af025d7531d7668f049f500f444..c6713ae8f1a5bb8a3ab230443fd9b8d69c3ea455 100644 (file)
@@ -57,7 +57,6 @@ static void xml_string_table_create(void)
 
 #endif /* SPARSE_MEMORY */
 
-static void xml_free_tag       (XMLTag         *tag);
 static gint xml_get_parenthesis        (XMLFile        *file,
                                 gchar          *buf,
                                 gint            len);
@@ -511,7 +510,7 @@ void xml_free_tree(GNode *node)
        g_node_destroy(node);
 }
 
-static void xml_free_tag(XMLTag *tag)
+void xml_free_tag(XMLTag *tag)
 {
        if (!tag) return;
 
index c88791340e61941eb246464051035a32c4c585a9..337bb50e9810d2af25af830e2fa491601c2bfeb0 100644 (file)
@@ -91,4 +91,6 @@ gint xml_file_put_escape_str  (FILE           *fp,
 void xml_free_node             (XMLNode        *node);
 void xml_free_tree             (GNode          *node);
 
+void xml_free_tag              (XMLTag         *tag);
+
 #endif /* __XML_H__ */
index 3f1603b54913a8bdb46da1349c849d4739c5a1d5..0872e7adc1cdf9cbf3227e5ec43de90333ab9949 100644 (file)
@@ -48,6 +48,7 @@
 #include "hooks.h"
 #include "log.h"
 #include "folder_item_prefs.h"
+#include "remotefolder.h"
 
 /* Dependecies to be removed ?! */
 #include "prefs_common.h"
@@ -55,7 +56,7 @@
 
 static GList *folder_list = NULL;
 
-static void folder_init                (Folder         *folder,
+void folder_init               (Folder         *folder,
                                 const gchar    *name);
 
 static gboolean folder_read_folder_func        (GNode          *node,
@@ -112,7 +113,7 @@ Folder *folder_new(FolderClass *klass, const gchar *name, const gchar *path)
        return folder;
 }
 
-static void folder_init(Folder *folder, const gchar *name)
+void folder_init(Folder *folder, const gchar *name)
 {
        g_return_if_fail(folder != NULL);
 
@@ -127,20 +128,6 @@ static void folder_init(Folder *folder, const gchar *name)
        folder->trash = NULL;
 }
 
-void folder_local_folder_init(Folder *folder, const gchar *name,
-                             const gchar *path)
-{
-       folder_init(folder, name);
-       LOCAL_FOLDER(folder)->rootpath = g_strdup(path);
-}
-
-void folder_remote_folder_init(Folder *folder, const gchar *name,
-                              const gchar *path)
-{
-       folder_init(folder, name);
-       REMOTE_FOLDER(folder)->session = NULL;
-}
-
 void folder_destroy(Folder *folder)
 {
        g_return_if_fail(folder != NULL);
@@ -156,21 +143,6 @@ void folder_destroy(Folder *folder)
        g_free(folder);
 }
 
-void folder_local_folder_destroy(LocalFolder *lfolder)
-{
-       g_return_if_fail(lfolder != NULL);
-
-       g_free(lfolder->rootpath);
-}
-
-void folder_remote_folder_destroy(RemoteFolder *rfolder)
-{
-       g_return_if_fail(rfolder != NULL);
-
-       if (rfolder->session)
-               session_destroy(rfolder->session);
-}
-
 FolderItem *folder_item_new(Folder *folder, const gchar *name, const gchar *path)
 {
        FolderItem *item = NULL;
@@ -315,6 +287,163 @@ void folder_item_destroy(FolderItem *item)
        }
 }
 
+static void add_xml_attr(XMLTag *tag, const gchar *name, gchar *value)
+{
+       XMLAttr *attr;
+
+       attr = g_new0(XMLAttr, 1);
+       attr->name = g_strdup(name);
+       attr->value = value;
+
+       tag->attr = g_list_append(tag->attr, attr);
+}
+
+void folder_item_set_attrs(Folder *folder, FolderItem *item, XMLTag *tag)
+{
+       GList *cur;
+
+       for (cur = tag->attr; cur != NULL; cur = g_list_next(cur)) {
+               XMLAttr *attr = (XMLAttr *) cur->data;
+
+               if (!attr || !attr->name || !attr->value) continue;
+               if (!strcmp(attr->name, "type")) {
+                       if (!strcasecmp(attr->value, "normal"))
+                               item->stype = F_NORMAL;
+                       else if (!strcasecmp(attr->value, "inbox"))
+                               item->stype = F_INBOX;
+                       else if (!strcasecmp(attr->value, "outbox"))
+                               item->stype = F_OUTBOX;
+                       else if (!strcasecmp(attr->value, "draft"))
+                               item->stype = F_DRAFT;
+                       else if (!strcasecmp(attr->value, "queue"))
+                               item->stype = F_QUEUE;
+                       else if (!strcasecmp(attr->value, "trash"))
+                               item->stype = F_TRASH;
+               } else if (!strcmp(attr->name, "name")) {
+                       if (item->name != NULL)
+                               g_free(item->name);
+                       item->name = g_strdup(attr->value);
+               } else if (!strcmp(attr->name, "path")) {
+                       if (item->path != NULL)
+                               g_free(item->path);
+                       item->path = g_strdup(attr->value);
+               } else if (!strcmp(attr->name, "mtime"))
+                       item->mtime = strtoul(attr->value, NULL, 10);
+               else if (!strcmp(attr->name, "new"))
+                       item->new_msgs = atoi(attr->value);
+               else if (!strcmp(attr->name, "unread"))
+                       item->unread_msgs = atoi(attr->value);
+               else if (!strcmp(attr->name, "unreadmarked"))
+                       item->unreadmarked_msgs = atoi(attr->value);
+               else if (!strcmp(attr->name, "total"))
+                       item->total_msgs = atoi(attr->value);
+               else if (!strcmp(attr->name, "no_sub"))
+                       item->no_sub = *attr->value == '1' ? TRUE : FALSE;
+               else if (!strcmp(attr->name, "no_select"))
+                       item->no_select = *attr->value == '1' ? TRUE : FALSE;
+               else if (!strcmp(attr->name, "collapsed"))
+                       item->collapsed = *attr->value == '1' ? TRUE : FALSE;
+               else if (!strcmp(attr->name, "thread_collapsed"))
+                       item->thread_collapsed =  *attr->value == '1' ? TRUE : FALSE;
+               else if (!strcmp(attr->name, "threaded"))
+                       item->threaded =  *attr->value == '1' ? TRUE : FALSE;
+               else if (!strcmp(attr->name, "hidereadmsgs"))
+                       item->hide_read_msgs =  *attr->value == '1' ? TRUE : FALSE;
+               else if (!strcmp(attr->name, "reqretrcpt"))
+                       item->ret_rcpt =  *attr->value == '1' ? TRUE : FALSE;
+               else if (!strcmp(attr->name, "sort_key")) {
+                       if (!strcmp(attr->value, "none"))
+                               item->sort_key = SORT_BY_NONE;
+                       else if (!strcmp(attr->value, "number"))
+                               item->sort_key = SORT_BY_NUMBER;
+                       else if (!strcmp(attr->value, "size"))
+                               item->sort_key = SORT_BY_SIZE;
+                       else if (!strcmp(attr->value, "date"))
+                               item->sort_key = SORT_BY_DATE;
+                       else if (!strcmp(attr->value, "from"))
+                               item->sort_key = SORT_BY_FROM;
+                       else if (!strcmp(attr->value, "subject"))
+                               item->sort_key = SORT_BY_SUBJECT;
+                       else if (!strcmp(attr->value, "score"))
+                               item->sort_key = SORT_BY_SCORE;
+                       else if (!strcmp(attr->value, "label"))
+                               item->sort_key = SORT_BY_LABEL;
+                       else if (!strcmp(attr->value, "mark"))
+                               item->sort_key = SORT_BY_MARK;
+                       else if (!strcmp(attr->value, "unread"))
+                               item->sort_key = SORT_BY_STATUS;
+                       else if (!strcmp(attr->value, "mime"))
+                               item->sort_key = SORT_BY_MIME;
+                       else if (!strcmp(attr->value, "to"))
+                               item->sort_key = SORT_BY_TO;
+                       else if (!strcmp(attr->value, "locked"))
+                               item->sort_key = SORT_BY_LOCKED;
+               } else if (!strcmp(attr->name, "sort_type")) {
+                       if (!strcmp(attr->value, "ascending"))
+                               item->sort_type = SORT_ASCENDING;
+                       else
+                               item->sort_type = SORT_DESCENDING;
+               } else if (!strcmp(attr->name, "account_id")) {
+                       PrefsAccount *account;
+
+                       account = account_find_from_id(atoi(attr->value));
+                       if (!account)
+                               g_warning("account_id: %s not found\n", attr->value);
+                       else
+                               item->account = account;
+               } else if (!strcmp(attr->name, "apply_sub"))
+                       item->apply_sub = *attr->value == '1' ? TRUE : FALSE;
+       }
+}
+
+XMLTag *folder_item_get_attrs(Folder *folder, FolderItem *item)
+{
+       static gchar *folder_item_stype_str[] = {"normal", "inbox", "outbox",
+                                                "draft", "queue", "trash"};
+       static gchar *sort_key_str[] = {"none", "number", "size", "date",
+                                       "from", "subject", "score", "label",
+                                       "mark", "unread", "mime", "to", 
+                                       "locked"};
+       XMLTag *tag;
+
+       tag = g_new0(XMLTag, 1);
+       tag->tag = g_strdup("folderitem");
+
+       add_xml_attr(tag, "type", g_strdup(folder_item_stype_str[item->stype]));
+       if (item->name)
+               add_xml_attr(tag, "name", g_strdup(item->name));
+       if (item->path)
+               add_xml_attr(tag, "path", g_strdup(item->path));
+       if (item->no_sub)
+               add_xml_attr(tag, "no_sub", g_strdup("1"));
+       if (item->no_select)
+               add_xml_attr(tag, "no_select", g_strdup("1"));
+       add_xml_attr(tag, "collapsed", g_strdup(item->collapsed && item->node->children ? "1" : "0"));
+       add_xml_attr(tag, "thread_collapsed", g_strdup(item->thread_collapsed ? "1" : "0"));
+       add_xml_attr(tag, "threaded", g_strdup(item->threaded ? "1" : "0"));
+       add_xml_attr(tag, "hidereadmsgs", g_strdup(item->hide_read_msgs ? "1" : "0"));
+       if (item->ret_rcpt)
+               add_xml_attr(tag, "reqretrcpt", g_strdup("1"));
+
+       if (item->sort_key != SORT_BY_NONE) {
+               add_xml_attr(tag, "sort_key", g_strdup(sort_key_str[item->sort_key]));
+               add_xml_attr(tag, "sort_type", g_strdup(item->sort_type == SORT_ASCENDING ? "ascending" : "descending"));
+       }
+
+       add_xml_attr(tag, "mtime", g_strdup_printf("%ld", (unsigned long int) item->mtime));
+       add_xml_attr(tag, "new", g_strdup_printf("%d", item->new_msgs));
+       add_xml_attr(tag, "unread", g_strdup_printf("%d", item->unread_msgs));
+       add_xml_attr(tag, "unreadmarked", g_strdup_printf("%d", item->unreadmarked_msgs));
+       add_xml_attr(tag, "total", g_strdup_printf("%d", item->total_msgs));
+
+       if (item->account)
+               add_xml_attr(tag, "account_id", g_strdup_printf("%d", item->account->account_id));
+       if (item->apply_sub)
+               add_xml_attr(tag, "apply_sub", g_strdup("1"));
+
+       return tag;
+}
+
 void folder_set_ui_func(Folder *folder, FolderUIFunc func, gpointer data)
 {
        g_return_if_fail(folder != NULL);
@@ -2293,19 +2422,6 @@ static gboolean folder_build_tree(GNode *node, gpointer data)
        Folder *folder = FOLDER(data);
        FolderItem *item;
        XMLNode *xmlnode;
-       GList *list;
-       SpecialFolderItemType stype = F_NORMAL;
-       const gchar *name = NULL;
-       const gchar *path = NULL;
-       PrefsAccount *account = NULL;
-       gboolean no_sub = FALSE, no_select = FALSE, collapsed = FALSE, 
-                threaded = TRUE, apply_sub = FALSE;
-       gboolean ret_rcpt = FALSE, hidereadmsgs = FALSE,
-                thread_collapsed = FALSE; /* CLAWS */
-       FolderSortKey sort_key = SORT_BY_NONE;
-       FolderSortType sort_type = SORT_ASCENDING;
-       gint new = 0, unread = 0, total = 0, unreadmarked = 0;
-       time_t mtime = 0;
 
        g_return_val_if_fail(node->data != NULL, FALSE);
        if (!node->parent) return FALSE;
@@ -2316,112 +2432,15 @@ static gboolean folder_build_tree(GNode *node, gpointer data)
                return FALSE;
        }
 
-       list = xmlnode->tag->attr;
-       for (; list != NULL; list = list->next) {
-               XMLAttr *attr = list->data;
-
-               if (!attr || !attr->name || !attr->value) continue;
-               if (!strcmp(attr->name, "type")) {
-                       if (!strcasecmp(attr->value, "normal"))
-                               stype = F_NORMAL;
-                       else if (!strcasecmp(attr->value, "inbox"))
-                               stype = F_INBOX;
-                       else if (!strcasecmp(attr->value, "outbox"))
-                               stype = F_OUTBOX;
-                       else if (!strcasecmp(attr->value, "draft"))
-                               stype = F_DRAFT;
-                       else if (!strcasecmp(attr->value, "queue"))
-                               stype = F_QUEUE;
-                       else if (!strcasecmp(attr->value, "trash"))
-                               stype = F_TRASH;
-               } else if (!strcmp(attr->name, "name"))
-                       name = attr->value;
-               else if (!strcmp(attr->name, "path"))
-                       path = attr->value;
-               else if (!strcmp(attr->name, "mtime"))
-                       mtime = strtoul(attr->value, NULL, 10);
-               else if (!strcmp(attr->name, "new"))
-                       new = atoi(attr->value);
-               else if (!strcmp(attr->name, "unread"))
-                       unread = atoi(attr->value);
-               else if (!strcmp(attr->name, "unreadmarked"))
-                       unreadmarked = atoi(attr->value);
-               else if (!strcmp(attr->name, "total"))
-                       total = atoi(attr->value);
-               else if (!strcmp(attr->name, "no_sub"))
-                       no_sub = *attr->value == '1' ? TRUE : FALSE;
-               else if (!strcmp(attr->name, "no_select"))
-                       no_select = *attr->value == '1' ? TRUE : FALSE;
-               else if (!strcmp(attr->name, "collapsed"))
-                       collapsed = *attr->value == '1' ? TRUE : FALSE;
-               else if (!strcmp(attr->name, "thread_collapsed"))
-                       thread_collapsed =  *attr->value == '1' ? TRUE : FALSE;
-               else if (!strcmp(attr->name, "threaded"))
-                       threaded =  *attr->value == '1' ? TRUE : FALSE;
-               else if (!strcmp(attr->name, "hidereadmsgs"))
-                       hidereadmsgs =  *attr->value == '1' ? TRUE : FALSE;
-               else if (!strcmp(attr->name, "reqretrcpt"))
-                       ret_rcpt =  *attr->value == '1' ? TRUE : FALSE;
-               else if (!strcmp(attr->name, "sort_key")) {
-                       if (!strcmp(attr->value, "none"))
-                               sort_key = SORT_BY_NONE;
-                       else if (!strcmp(attr->value, "number"))
-                               sort_key = SORT_BY_NUMBER;
-                       else if (!strcmp(attr->value, "size"))
-                               sort_key = SORT_BY_SIZE;
-                       else if (!strcmp(attr->value, "date"))
-                               sort_key = SORT_BY_DATE;
-                       else if (!strcmp(attr->value, "from"))
-                               sort_key = SORT_BY_FROM;
-                       else if (!strcmp(attr->value, "subject"))
-                               sort_key = SORT_BY_SUBJECT;
-                       else if (!strcmp(attr->value, "score"))
-                               sort_key = SORT_BY_SCORE;
-                       else if (!strcmp(attr->value, "label"))
-                               sort_key = SORT_BY_LABEL;
-                       else if (!strcmp(attr->value, "mark"))
-                               sort_key = SORT_BY_MARK;
-                       else if (!strcmp(attr->value, "unread"))
-                               sort_key = SORT_BY_STATUS;
-                       else if (!strcmp(attr->value, "mime"))
-                               sort_key = SORT_BY_MIME;
-                       else if (!strcmp(attr->value, "to"))
-                               sort_key = SORT_BY_TO;
-                       else if (!strcmp(attr->value, "locked"))
-                               sort_key = SORT_BY_LOCKED;
-               } else if (!strcmp(attr->name, "sort_type")) {
-                       if (!strcmp(attr->value, "ascending"))
-                               sort_type = SORT_ASCENDING;
-                       else
-                               sort_type = SORT_DESCENDING;
-               } else if (!strcmp(attr->name, "account_id")) {
-                       account = account_find_from_id(atoi(attr->value));
-                       if (!account) g_warning("account_id: %s not found\n",
-                                               attr->value);
-               } else if (!strcmp(attr->name, "apply_sub"))
-                       apply_sub = *attr->value == '1' ? TRUE : FALSE;
-       }
-
-       item = folder_item_new(folder, name, path);
-       item->stype = stype;
-       item->mtime = mtime;
-       item->new_msgs = new;
-       item->unread_msgs = unread;
-       item->unreadmarked_msgs = unreadmarked;
-       item->total_msgs = total;
-       item->no_sub = no_sub;
-       item->no_select = no_select;
-       item->collapsed = collapsed;
-       item->thread_collapsed = thread_collapsed;
-       item->threaded  = threaded;
-       item->hide_read_msgs  = hidereadmsgs;
-       item->ret_rcpt  = ret_rcpt;
-       item->sort_key  = sort_key;
-       item->sort_type = sort_type;
+       item = folder_item_new(folder, "", "");
+       if (folder->klass->item_set_xml != NULL)
+               folder->klass->item_set_xml(folder, item, xmlnode->tag);
+       else
+               folder_item_set_attrs(folder, item, xmlnode->tag);
        item->node = node;
        item->parent = FOLDER_ITEM(node->parent->data);
        item->folder = folder;
-       switch (stype) {
+       switch (item->stype) {
        case F_INBOX:  folder->inbox  = item; break;
        case F_OUTBOX: folder->outbox = item; break;
        case F_DRAFT:  folder->draft  = item; break;
@@ -2429,8 +2448,6 @@ static gboolean folder_build_tree(GNode *node, gpointer data)
        case F_TRASH:  folder->trash  = item; break;
        default:       break;
        }
-       item->account = account;
-       item->apply_sub = apply_sub;
        folder_item_prefs_read_config(item);
 
        node->data = item;
@@ -2492,7 +2509,7 @@ static gboolean folder_read_folder_func(GNode *node, gpointer data)
        g_return_val_if_fail(folder != NULL, FALSE);
        folder->account = account;
        if (account != NULL)
-               account->folder = REMOTE_FOLDER(folder);
+               account->folder = folder;
        item = FOLDER_ITEM(folder->node->data);
        node->data = item;
        item->node = node;
@@ -2535,12 +2552,7 @@ static void folder_write_list_recursive(GNode *node, gpointer data)
        FILE *fp = (FILE *)data;
        FolderItem *item;
        gint i, depth;
-       static gchar *folder_item_stype_str[] = {"normal", "inbox", "outbox",
-                                                "draft", "queue", "trash"};
-       static gchar *sort_key_str[] = {"none", "number", "size", "date",
-                                       "from", "subject", "score", "label",
-                                       "mark", "unread", "mime", "to", 
-                                       "locked"};
+
        g_return_if_fail(node != NULL);
        g_return_if_fail(fp != NULL);
 
@@ -2571,54 +2583,23 @@ static void folder_write_list_recursive(GNode *node, gpointer data)
                if (item->ret_rcpt) 
                        fputs(" reqretrcpt=\"1\"", fp);
        } else {
-               fprintf(fp, "<folderitem type=\"%s\"",
-                       folder_item_stype_str[item->stype]);
-               if (item->name)
-                       PUT_ESCAPE_STR(fp, "name", item->name);
-               if (item->path)
-                       PUT_ESCAPE_STR(fp, "path", item->path);
-
-               if (item->no_sub)
-                       fputs(" no_sub=\"1\"", fp);
-               if (item->no_select)
-                       fputs(" no_select=\"1\"", fp);
-               if (item->collapsed && node->children)
-                       fputs(" collapsed=\"1\"", fp);
-               else
-                       fputs(" collapsed=\"0\"", fp);
-               if (item->thread_collapsed)
-                       fputs(" thread_collapsed=\"1\"", fp);
-               else
-                       fputs(" thread_collapsed=\"0\"", fp);
-               if (item->threaded)
-                       fputs(" threaded=\"1\"", fp);
-               else
-                       fputs(" threaded=\"0\"", fp);
-               if (item->hide_read_msgs)
-                       fputs(" hidereadmsgs=\"1\"", fp);
-               else
-                       fputs(" hidereadmsgs=\"0\"", fp);
-               if (item->ret_rcpt)
-                       fputs(" reqretrcpt=\"1\"", fp);
+               XMLTag *tag;
+               GList *cur;
 
-               if (item->sort_key != SORT_BY_NONE) {
-                       fprintf(fp, " sort_key=\"%s\"",
-                               sort_key_str[item->sort_key]);
-                       if (item->sort_type == SORT_ASCENDING)
-                               fprintf(fp, " sort_type=\"ascending\"");
-                       else
-                               fprintf(fp, " sort_type=\"descending\"");
-               }
+               if (item->folder->klass->item_get_xml != NULL)
+                       tag = item->folder->klass->item_get_xml(item->folder, item);
+               else
+                       tag = folder_item_get_attrs(item->folder, item);
 
-               fprintf(fp,
-                       " mtime=\"%lu\" new=\"%d\" unread=\"%d\" unreadmarked=\"%d\" total=\"%d\"",
-                       item->mtime, item->new_msgs, item->unread_msgs, item->unreadmarked_msgs, item->total_msgs);
+               fprintf(fp, "<%s", tag->tag);
+               for (cur = tag->attr; cur != NULL; cur = g_list_next(cur)) {
+                       XMLAttr *attr = (XMLAttr *) cur->data;
 
-               if (item->account)
-                       fprintf(fp, " account_id=\"%d\"",
-                               item->account->account_id);
-               if (item->apply_sub)
-                       fputs(" apply_sub=\"1\"", fp);
+                       fprintf(fp, " %s=\"", attr->name);
+                       xml_file_put_escape_str(fp, attr->value);
+                       fputs("\"", fp);
+               }
+               xml_free_tag(tag);
        }
 
        if (node->children) {
index b34a8043bba3a213eafba8e70b71ad1175700784..370bcc72b6519998608ef29634ec98665a77591f 100644 (file)
 typedef struct _Folder         Folder;
 typedef struct _FolderClass    FolderClass;
 
-typedef struct _LocalFolder    LocalFolder;
-typedef struct _RemoteFolder   RemoteFolder;
-#if 0
-typedef struct _MaildirFolder  MaildirFolder;
-#endif
-
 typedef struct _FolderItem     FolderItem;
 typedef struct _FolderUpdateData       FolderUpdateData;
 typedef struct _FolderItemUpdateData   FolderItemUpdateData;
+typedef struct _PersistPrefs           PersistPrefs;
 
 #define FOLDER(obj)            ((Folder *)obj)
 #define FOLDER_CLASS(obj)      (FOLDER(obj)->klass)
 #define FOLDER_TYPE(obj)       (FOLDER(obj)->klass->type)
 
-#define LOCAL_FOLDER(obj)      ((LocalFolder *)obj)
-#define REMOTE_FOLDER(obj)     ((RemoteFolder *)obj)
-
 #define FOLDER_IS_LOCAL(obj)   (FOLDER_TYPE(obj) == F_MH      || \
                                 FOLDER_TYPE(obj) == F_MBOX    || \
                                 FOLDER_TYPE(obj) == F_MAILDIR)
 
-#if 0
-#define MAILDIR_FOLDER(obj)    ((MaildirFolder *)obj)
-#endif
-
 #define FOLDER_ITEM(obj)       ((FolderItem *)obj)
 
 #define FOLDER_UPDATE_HOOKLIST "folder_update"
@@ -130,12 +118,13 @@ typedef void (*FolderDestroyNotify)       (Folder         *folder,
 typedef void (*FolderItemFunc)         (FolderItem     *item,
                                         gpointer        data);
 
+
 #include "folder_item_prefs.h"
 
-#include "prefs_account.h"
-#include "session.h"
 #include "procmsg.h"
 #include "msgcache.h"
+#include "xml.h"
+#include "prefs_account.h"
 
 struct _Folder
 {
@@ -178,21 +167,26 @@ struct _FolderClass
 
        /* FolderItem functions */
        FolderItem      *(*item_new)            (Folder         *folder);
-       void            (*item_destroy)         (Folder         *folder,
+       void             (*item_destroy)        (Folder         *folder,
+                                                FolderItem     *item);
+       void             (*item_set_xml)        (Folder         *folder,
+                                                FolderItem     *item,
+                                                XMLTag         *tag);
+       XMLTag          *(*item_get_xml)        (Folder         *folder,
                                                 FolderItem     *item);
        gchar           *(*item_get_path)       (Folder         *folder,
                                                 FolderItem     *item);
        FolderItem      *(*create_folder)       (Folder         *folder,
                                                 FolderItem     *parent,
                                                 const gchar    *name);
-       gint            (*rename_folder)        (Folder         *folder,
+       gint             (*rename_folder)       (Folder         *folder,
                                                 FolderItem     *item,
                                                 const gchar    *name);
-       gint            (*remove_folder)        (Folder         *folder,
+       gint             (*remove_folder)       (Folder         *folder,
                                                 FolderItem     *item);
-       gint            (*close)                (Folder         *folder,
+       gint             (*close)               (Folder         *folder,
                                                 FolderItem     *item);
-       gint            (*get_num_list)         (Folder         *folder,
+       gint             (*get_num_list)        (Folder         *folder,
                                                 FolderItem     *item,
                                                 GSList        **list,
                                                 gboolean       *old_uids_valid);
@@ -244,27 +238,6 @@ struct _FolderClass
                                                 MsgPermFlags    newflags);
 };
 
-struct _LocalFolder
-{
-       Folder folder;
-
-       gchar *rootpath;
-};
-
-struct _RemoteFolder
-{
-       Folder folder;
-
-       Session *session;
-};
-
-#if 0
-struct _MaildirFolder
-{
-       LocalFolder lfolder;
-};
-#endif
-
 struct _FolderItem
 {
        SpecialFolderItemType stype;
@@ -316,7 +289,8 @@ struct _FolderItem
        FolderItemPrefs * prefs;
 };
 
-typedef struct {
+struct _PersistPrefs
+{
        FolderSortKey   sort_key;
        FolderSortType  sort_type;
        guint           collapsed       : 1;
@@ -324,7 +298,7 @@ typedef struct {
        guint           threaded        : 1;
        guint           hide_read_msgs  : 1; /* CLAWS */
        guint           ret_rcpt        : 1; /* CLAWS */
-} PersistPrefs;
+};
 
 struct _FolderUpdateData
 {
@@ -344,16 +318,13 @@ void          folder_register_class       (FolderClass    *klass);
 Folder     *folder_new                 (FolderClass    *type,
                                         const gchar    *name,
                                         const gchar    *path);
-void        folder_local_folder_init   (Folder         *folder,
-                                        const gchar    *name,
-                                        const gchar    *path);
-void        folder_remote_folder_init  (Folder         *folder,
-                                        const gchar    *name,
-                                        const gchar    *path);
+void       folder_init                 (Folder         *folder,
+                                        const gchar    *name);
 
 void        folder_destroy             (Folder         *folder);
-void        folder_local_folder_destroy        (LocalFolder    *lfolder);
-void        folder_remote_folder_destroy(RemoteFolder  *rfolder);
+
+XMLTag            *folder_item_get_attrs       (Folder          *folder,
+                                        FolderItem      *item);
 
 FolderItem *folder_item_new            (Folder         *folder,
                                         const gchar    *name,
index 782c7833c001a5792b0f3abf541a937ab9c1f9c4..b93a49f518f929398987157a0217610efd655401 100644 (file)
@@ -26,9 +26,9 @@ typedef struct _FolderView    FolderView;
 #include <gtk/gtkwidget.h>
 #include <gtk/gtkctree.h>
 
-#include "folder.h"
 #include "mainwindow.h"
 #include "summaryview.h"
+#include "folder.h"
 
 struct _FolderView
 {
index 4e195724ee61537bb6a970e2c919aa4dadbcfbdd..b12f4b4100c36884a2c5a6de99c2ebb0da883583 100644 (file)
@@ -54,6 +54,7 @@
 #include "utils.h"
 #include "inputdialog.h"
 #include "log.h"
+#include "remotefolder.h"
 
 typedef struct _IMAPFolder     IMAPFolder;
 typedef struct _IMAPSession    IMAPSession;
@@ -452,6 +453,8 @@ static FolderClass imap_class =
        /* FolderItem functions */
        imap_folder_item_new,
        imap_folder_item_destroy,
+       NULL,
+       NULL,
        imap_item_get_path,
        imap_create_folder,
        imap_rename_folder,
diff --git a/src/localfolder.c b/src/localfolder.c
new file mode 100644 (file)
index 0000000..98a097d
--- /dev/null
@@ -0,0 +1,37 @@
+/*
+ * Sylpheed -- a GTK+ based, lightweight, and fast e-mail client
+ * Copyright (C) 2002 by the Sylpheed Claws Team and Hiroyuki Yamamoto
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ */
+
+#include <glib.h>
+
+#include "folder.h"
+#include "localfolder.h"
+
+void folder_local_folder_init(Folder *folder, const gchar *name,
+                             const gchar *path)
+{
+       folder_init(folder, name);
+       LOCAL_FOLDER(folder)->rootpath = g_strdup(path);
+}
+
+void folder_local_folder_destroy(LocalFolder *lfolder)
+{
+       g_return_if_fail(lfolder != NULL);
+
+       g_free(lfolder->rootpath);
+}
diff --git a/src/localfolder.h b/src/localfolder.h
new file mode 100644 (file)
index 0000000..7c7e8f9
--- /dev/null
@@ -0,0 +1,42 @@
+/*
+ * Sylpheed -- a GTK+ based, lightweight, and fast e-mail client
+ * Copyright (C) 2002 by the Sylpheed Claws Team and Hiroyuki Yamamoto
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ */
+
+#ifndef LOCALFOLDER_H
+#define LOCALFOLDER_H 1
+
+typedef struct _LocalFolder    LocalFolder;
+
+#define LOCAL_FOLDER(obj)      ((LocalFolder *)obj)
+
+#include <glib.h>
+
+#include "folder.h"
+
+struct _LocalFolder
+{
+       Folder folder;
+
+       gchar *rootpath;
+};
+
+void   folder_local_folder_init        (Folder *folder, const gchar *name,
+                                        const gchar *path);
+void   folder_local_folder_destroy     (LocalFolder    *lfolder);
+
+#endif /* LOCALFOLDER_H */
index 43d9b7c5895d9f1c8bd335874f45cc1f3fcd8f43..d68ba0c6bb433a1874459360a1b118ad025a4518 100644 (file)
@@ -86,6 +86,7 @@
 #include "pluginwindow.h"
 #include "hooks.h"
 #include "progressindicator.h"
+#include "localfolder.h"
 
 #define AC_LABEL_WIDTH 240
 
index b107833f3f65251955d046d6533c8d96be7af756..dd1338e70ce857cd076ce42f3c66d797dc04ffd2 100644 (file)
--- a/src/mh.c
+++ b/src/mh.c
@@ -119,6 +119,8 @@ static FolderClass mh_class =
        /* FolderItem functions */
        NULL,
        NULL,
+       NULL,
+       NULL,
        mh_item_get_path,
        mh_create_folder,
        mh_rename_folder,
index 160259c159e379daa5b2aff74e69a402e4a8b9e7..3992716623baeb2980f548edb4cbc52b12201c53 100644 (file)
--- a/src/mh.h
+++ b/src/mh.h
@@ -23,6 +23,7 @@
 #include <glib.h>
 
 #include "folder.h"
+#include "localfolder.h"
 
 typedef struct _MHFolder       MHFolder;
 
index 3ea0cd53f5698808440784460e9322b0d0d9d906..24a4adb21098f512dc147a7bbef1bf979984f8e1 100644 (file)
@@ -48,6 +48,7 @@
 #include "inputdialog.h"
 #include "log.h"
 #include "progressindicator.h"
+#include "remotefolder.h"
 #if USE_OPENSSL
 #  include "ssl.h"
 #endif
 #define NNTPS_PORT     563
 #endif
 
+typedef struct _NewsFolder     NewsFolder;
+
+#define NEWS_FOLDER(obj)       ((NewsFolder *)obj)
+
+struct _NewsFolder
+{
+       RemoteFolder rfolder;
+
+       gboolean use_auth;
+};
+
 static void news_folder_init            (Folder        *folder,
                                          const gchar   *name,
                                          const gchar   *path);
@@ -133,6 +145,8 @@ static FolderClass news_class =
        /* FolderItem functions */
        NULL,
        NULL,
+       NULL,
+       NULL,
        news_item_get_path,
        NULL,
        NULL,
index 5230e6ae6615603008d4c65a40fb85d4f4b69c62..23bdd499d76f93fb151f98f753ee1460ca3da274 100644 (file)
 #include <glib.h>
 #include <stdio.h>
 
-#include "folder.h"
-
-typedef struct _NewsFolder     NewsFolder;
 typedef struct _NewsGroupInfo  NewsGroupInfo;
 
-#define NEWS_FOLDER(obj)       ((NewsFolder *)obj)
-
-struct _NewsFolder
-{
-       RemoteFolder rfolder;
-
-       gboolean use_auth;
-};
+#include "folder.h"
 
 struct _NewsGroupInfo
 {
index 39ea542c473c51adf5f6fbd5ad112bc74473eb23..ad9906c1ace3b509aaf2ea937bb6144e7f9ebab2 100644 (file)
@@ -49,6 +49,7 @@
 #include "colorlabel.h"
 #include "smtp.h"
 #include "imap.h"
+#include "remotefolder.h"
 
 static gboolean cancelled;
 
index d06d3b418822ce4d44d52ac61881e2a5d52869ce..95c5e65593bda9f1b61275988a91535414f8db4b 100644 (file)
 #  include "config.h"
 #endif
 
-#include <glib.h>
-
 typedef struct _PrefsAccount   PrefsAccount;
 
-#include "folder.h"
-#include "smtp.h"
-
-#ifdef USE_GPGME
-#  include "rfc2015.h"
-#endif
-
 typedef enum {
        A_POP3,
        A_APOP,
@@ -64,6 +55,16 @@ typedef enum {
 } DefaultGnuPGMode;
 #endif /* USE_GPGME */
 
+#include <glib.h>
+
+#include "smtp.h"
+#include "folder.h"
+
+#ifdef USE_GPGME
+#  include "rfc2015.h"
+#endif
+
+
 struct _PrefsAccount
 {
        gchar *account_name;
@@ -191,7 +192,7 @@ struct _PrefsAccount
        /* Unique account ID */
        gint account_id;
 
-       RemoteFolder *folder;
+       Folder *folder;
 };
 
 PrefsAccount *prefs_account_new                (void);
index bfa305d34e982e0a88200b604bd831cef0e6aae3..8055d14526c66dbc75b181db61667671f5b78eae 100644 (file)
@@ -36,6 +36,8 @@ typedef enum
        FILTER_BY_SUBJECT
 } PrefsFilterType;
 
+#include "folder.h"
+
 void prefs_filtering_open              (FolderItem * item,
                                         const gchar    *header,
                                         const gchar    *key);
index 4a8f71b189c2d51ff500ebff8b8e5683144da6c3..e5d78542cf77c14b576bbde829be3acc6e8adcef 100644 (file)
@@ -151,9 +151,9 @@ typedef enum {
        MSGINFO_UPDATE_DELETED = 1 << 1,
 } MsgInfoUpdateFlags;
 
-#include "folder.h"
 #include "procmime.h"
 #include "prefs_filtering.h"
+#include "folder.h"
 
 struct _MsgFlags
 {
diff --git a/src/remotefolder.c b/src/remotefolder.c
new file mode 100644 (file)
index 0000000..9f018ad
--- /dev/null
@@ -0,0 +1,37 @@
+/*
+ * Sylpheed -- a GTK+ based, lightweight, and fast e-mail client
+ * Copyright (C) 2002 by the Sylpheed Claws Team and Hiroyuki Yamamoto
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ */
+
+#include <glib.h>
+
+#include "remotefolder.h"
+
+void folder_remote_folder_init(Folder *folder, const gchar *name,
+                              const gchar *path)
+{
+       folder_init(folder, name);
+       REMOTE_FOLDER(folder)->session = NULL;
+}
+
+void folder_remote_folder_destroy(RemoteFolder *rfolder)
+{
+       g_return_if_fail(rfolder != NULL);
+
+       if (rfolder->session)
+               session_destroy(rfolder->session);
+}
diff --git a/src/remotefolder.h b/src/remotefolder.h
new file mode 100644 (file)
index 0000000..ce3a61e
--- /dev/null
@@ -0,0 +1,44 @@
+/*
+ * Sylpheed -- a GTK+ based, lightweight, and fast e-mail client
+ * Copyright (C) 2002 by the Sylpheed Claws Team and Hiroyuki Yamamoto
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ */
+
+#ifndef REMOTEFOLDER_H
+#define REMOTEFOLDER_H 1
+
+typedef struct _RemoteFolder   RemoteFolder;
+
+#define REMOTE_FOLDER(obj)     ((RemoteFolder *)obj)
+
+#include <glib.h>
+
+#include "folder.h"
+#include "session.h"
+
+struct _RemoteFolder
+{
+       Folder folder;
+
+       Session *session;
+};
+
+void        folder_remote_folder_init  (Folder         *folder,
+                                        const gchar    *name,
+                                        const gchar    *path);
+void        folder_remote_folder_destroy(RemoteFolder  *rfolder);
+
+#endif /* REMOTEFOLDER_H */