From 67c89f7144bd0b1e640717e8ebe58ee97cca5493 Mon Sep 17 00:00:00 2001 From: Christoph Hohmann Date: Tue, 2 Dec 2003 16:50:00 +0000 Subject: [PATCH] 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. --- ChangeLog.claws | 21 +++ configure.ac | 2 +- src/Makefile.am | 4 + src/account.c | 5 +- src/common/xml.c | 3 +- src/common/xml.h | 2 + src/folder.c | 383 ++++++++++++++++++++---------------------- src/folder.h | 73 +++----- src/folderview.h | 2 +- src/imap.c | 3 + src/localfolder.c | 37 ++++ src/localfolder.h | 42 +++++ src/mainwindow.c | 1 + src/mh.c | 2 + src/mh.h | 1 + src/news.c | 14 ++ src/news.h | 12 +- src/prefs_account.c | 1 + src/prefs_account.h | 21 +-- src/prefs_filtering.h | 2 + src/procmsg.h | 2 +- src/remotefolder.c | 37 ++++ src/remotefolder.h | 44 +++++ 23 files changed, 434 insertions(+), 280 deletions(-) create mode 100644 src/localfolder.c create mode 100644 src/localfolder.h create mode 100644 src/remotefolder.c create mode 100644 src/remotefolder.h diff --git a/ChangeLog.claws b/ChangeLog.claws index c529978a2..349edc605 100644 --- a/ChangeLog.claws +++ b/ChangeLog.claws @@ -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 diff --git a/configure.ac b/configure.ac index cdf250ac9..2d35665af 100644 --- a/configure.ac +++ b/configure.ac @@ -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 diff --git a/src/Makefile.am b/src/Makefile.am index 02fdacf55..934e67ed9 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -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 = \ diff --git a/src/account.c b/src/account.c index 739f0cd97..dd2e568b6 100644 --- a/src/account.c +++ b/src/account.c @@ -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); diff --git a/src/common/xml.c b/src/common/xml.c index 578304482..c6713ae8f 100644 --- a/src/common/xml.c +++ b/src/common/xml.c @@ -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; diff --git a/src/common/xml.h b/src/common/xml.h index c88791340..337bb50e9 100644 --- a/src/common/xml.h +++ b/src/common/xml.h @@ -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__ */ diff --git a/src/folder.c b/src/folder.c index 3f1603b54..0872e7adc 100644 --- a/src/folder.c +++ b/src/folder.c @@ -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, "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) { diff --git a/src/folder.h b/src/folder.h index b34a8043b..370bcc72b 100644 --- a/src/folder.h +++ b/src/folder.h @@ -26,31 +26,19 @@ 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, diff --git a/src/folderview.h b/src/folderview.h index 782c7833c..b93a49f51 100644 --- a/src/folderview.h +++ b/src/folderview.h @@ -26,9 +26,9 @@ typedef struct _FolderView FolderView; #include #include -#include "folder.h" #include "mainwindow.h" #include "summaryview.h" +#include "folder.h" struct _FolderView { diff --git a/src/imap.c b/src/imap.c index 4e195724e..b12f4b410 100644 --- a/src/imap.c +++ b/src/imap.c @@ -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 index 000000000..98a097d76 --- /dev/null +++ b/src/localfolder.c @@ -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 + +#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 index 000000000..7c7e8f984 --- /dev/null +++ b/src/localfolder.h @@ -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 + +#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 */ diff --git a/src/mainwindow.c b/src/mainwindow.c index 43d9b7c58..d68ba0c6b 100644 --- a/src/mainwindow.c +++ b/src/mainwindow.c @@ -86,6 +86,7 @@ #include "pluginwindow.h" #include "hooks.h" #include "progressindicator.h" +#include "localfolder.h" #define AC_LABEL_WIDTH 240 diff --git a/src/mh.c b/src/mh.c index b107833f3..dd1338e70 100644 --- 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, diff --git a/src/mh.h b/src/mh.h index 160259c15..399271662 100644 --- a/src/mh.h +++ b/src/mh.h @@ -23,6 +23,7 @@ #include #include "folder.h" +#include "localfolder.h" typedef struct _MHFolder MHFolder; diff --git a/src/news.c b/src/news.c index 3ea0cd53f..24a4adb21 100644 --- a/src/news.c +++ b/src/news.c @@ -48,6 +48,7 @@ #include "inputdialog.h" #include "log.h" #include "progressindicator.h" +#include "remotefolder.h" #if USE_OPENSSL # include "ssl.h" #endif @@ -57,6 +58,17 @@ #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, diff --git a/src/news.h b/src/news.h index 5230e6ae6..23bdd499d 100644 --- a/src/news.h +++ b/src/news.h @@ -23,19 +23,9 @@ #include #include -#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 { diff --git a/src/prefs_account.c b/src/prefs_account.c index 39ea542c4..ad9906c1a 100644 --- a/src/prefs_account.c +++ b/src/prefs_account.c @@ -49,6 +49,7 @@ #include "colorlabel.h" #include "smtp.h" #include "imap.h" +#include "remotefolder.h" static gboolean cancelled; diff --git a/src/prefs_account.h b/src/prefs_account.h index d06d3b418..95c5e6559 100644 --- a/src/prefs_account.h +++ b/src/prefs_account.h @@ -24,17 +24,8 @@ # include "config.h" #endif -#include - 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 + +#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); diff --git a/src/prefs_filtering.h b/src/prefs_filtering.h index bfa305d34..8055d1452 100644 --- a/src/prefs_filtering.h +++ b/src/prefs_filtering.h @@ -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); diff --git a/src/procmsg.h b/src/procmsg.h index 4a8f71b18..e5d78542c 100644 --- a/src/procmsg.h +++ b/src/procmsg.h @@ -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 index 000000000..9f018ad70 --- /dev/null +++ b/src/remotefolder.c @@ -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 + +#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 index 000000000..ce3a61e7b --- /dev/null +++ b/src/remotefolder.h @@ -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 + +#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 */ -- 2.25.1