From: Christoph Hohmann Date: Thu, 3 Jul 2003 20:37:07 +0000 (+0000) Subject: 0.9.0claws76 X-Git-Tag: rel_0_9_3~33 X-Git-Url: http://git.claws-mail.org/?p=claws.git;a=commitdiff_plain;h=0782be424e137566ee63b753ed348ec9d30fad82 0.9.0claws76 * src/folder.[ch] * src/imap.c * src/mbox_folder.c * src/mh.c * src/news.c move folder_item_get_path() stuff into a folder virtual function * src/procmsg.c use folder_item_fetch_msg() to get message and do not contruct the filename from path and number --- diff --git a/ChangeLog.claws b/ChangeLog.claws index 85901fb1b..66e19046a 100644 --- a/ChangeLog.claws +++ b/ChangeLog.claws @@ -1,3 +1,16 @@ +2003-07-03 [christoph] 0.9.0claws76 + + * src/folder.[ch] + * src/imap.c + * src/mbox_folder.c + * src/mh.c + * src/news.c + move folder_item_get_path() stuff into a folder virtual function + + * src/procmsg.c + use folder_item_fetch_msg() to get message and do not contruct + the filename from path and number + 2003-07-03 [paul] 0.9.0claws75 * sync with 0.9.2cvs12 @@ -49,6 +62,8 @@ * src/folder.c freeze folder updates while a folder is scanned + (closes Bug 185 New message counter) + 2003-06-26 [darko] 0.9.0claws65 * src/ldapserver.c diff --git a/configure.ac b/configure.ac index 28f373af1..d0e8f4bd7 100644 --- a/configure.ac +++ b/configure.ac @@ -11,7 +11,7 @@ MINOR_VERSION=9 MICRO_VERSION=0 INTERFACE_AGE=0 BINARY_AGE=0 -EXTRA_VERSION=claws75 +EXTRA_VERSION=claws76 VERSION=$MAJOR_VERSION.$MINOR_VERSION.$MICRO_VERSION$EXTRA_VERSION dnl set $target diff --git a/src/folder.c b/src/folder.c index 55f69d9ad..9e65240a1 100644 --- a/src/folder.c +++ b/src/folder.c @@ -859,83 +859,15 @@ void folder_unref_account_all(PrefsAccount *account) #undef CREATE_FOLDER_IF_NOT_EXIST -gchar *folder_get_path(Folder *folder) -{ - gchar *path; - - g_return_val_if_fail(folder != NULL, NULL); - - switch(FOLDER_TYPE(folder)) { - - case F_MH: - path = g_strdup(LOCAL_FOLDER(folder)->rootpath); - break; - - case F_IMAP: - g_return_val_if_fail(folder->account != NULL, NULL); - path = g_strconcat(get_imap_cache_dir(), - G_DIR_SEPARATOR_S, - folder->account->recv_server, - G_DIR_SEPARATOR_S, - folder->account->userid, - NULL); - break; - - case F_NEWS: - g_return_val_if_fail(folder->account != NULL, NULL); - path = g_strconcat(get_news_cache_dir(), - G_DIR_SEPARATOR_S, - folder->account->nntp_server, - NULL); - break; - - default: - path = NULL; - break; - } - - return path; -} - gchar *folder_item_get_path(FolderItem *item) { - gchar *folder_path; - gchar *path; + Folder *folder; g_return_val_if_fail(item != NULL, NULL); + folder = item->folder; + g_return_val_if_fail(folder != NULL, NULL); - if(FOLDER_TYPE(item->folder) != F_MBOX) { - folder_path = folder_get_path(item->folder); - g_return_val_if_fail(folder_path != NULL, NULL); - - if (folder_path[0] == G_DIR_SEPARATOR) { - if (item->path) - path = g_strconcat(folder_path, G_DIR_SEPARATOR_S, - item->path, NULL); - else - path = g_strdup(folder_path); - } else { - if (item->path) - path = g_strconcat(get_home_dir(), G_DIR_SEPARATOR_S, - folder_path, G_DIR_SEPARATOR_S, - item->path, NULL); - else - path = g_strconcat(get_home_dir(), G_DIR_SEPARATOR_S, - folder_path, NULL); - } - - g_free(folder_path); - } else { - gchar *itempath; - - itempath = mbox_get_virtual_path(item); - if (itempath == NULL) - return NULL; - path = g_strconcat(get_mbox_cache_dir(), - G_DIR_SEPARATOR_S, itempath, NULL); - g_free(itempath); - } - return path; + return folder->klass->item_get_path(folder, item); } void folder_item_set_default_flags(FolderItem *dest, MsgFlags *flags) @@ -2478,7 +2410,7 @@ static void folder_write_list_recursive(GNode *node, gpointer data) fprintf(fp, "klass->idstr); if (folder->name) PUT_ESCAPE_STR(fp, "name", folder->name); - if (FOLDER_TYPE(folder) == F_MH || FOLDER_TYPE(folder) == F_MBOX) + if (FOLDER_TYPE(folder) == F_MH || FOLDER_TYPE(folder) == F_MBOX || FOLDER_TYPE(folder) == F_MAILDIR) PUT_ESCAPE_STR(fp, "path", LOCAL_FOLDER(folder)->rootpath); if (item->collapsed && node->children) diff --git a/src/folder.h b/src/folder.h index 5b80bc8be..9f9a44baf 100644 --- a/src/folder.h +++ b/src/folder.h @@ -182,6 +182,8 @@ struct _FolderClass FolderItem *(*item_new) (Folder *folder); void (*item_destroy) (Folder *folder, FolderItem *item); + gchar *(*item_get_path) (Folder *folder, + FolderItem *item); FolderItem *(*create_folder) (Folder *folder, FolderItem *parent, const gchar *name); @@ -394,7 +396,6 @@ FolderItem *folder_get_default_processing (void); void folder_set_missing_folders (void); void folder_unref_account_all (PrefsAccount *account); -gchar *folder_get_path (Folder *folder); gchar *folder_item_get_path (FolderItem *item); gint folder_item_open (FolderItem *item); diff --git a/src/imap.c b/src/imap.c index 083358751..562c906d7 100644 --- a/src/imap.c +++ b/src/imap.c @@ -385,6 +385,9 @@ static void imap_change_flags (Folder *folder, FolderItem *item, MsgInfo *msginfo, MsgPermFlags newflags); +static gchar *imap_folder_get_path (Folder *folder); +static gchar *imap_item_get_path (Folder *folder, + FolderItem *item); FolderClass imap_class = { @@ -401,6 +404,7 @@ FolderClass imap_class = /* FolderItem functions */ imap_folder_item_new, imap_folder_item_destroy, + imap_item_get_path, imap_create_folder, imap_rename_folder, imap_remove_folder, @@ -442,7 +446,7 @@ void imap_folder_destroy(Folder *folder) { gchar *dir; - dir = folder_get_path(folder); + dir = imap_folder_get_path(folder); if (is_dir_exist(dir)) remove_dir_recursive(dir); g_free(dir); @@ -1239,6 +1243,52 @@ static FolderItem *imap_create_special_folder(Folder *folder, return new_item; } +static gchar *imap_folder_get_path(Folder *folder) +{ + gchar *folder_path; + + g_return_val_if_fail(folder != NULL, NULL); + g_return_val_if_fail(folder->account != NULL, NULL); + + folder_path = g_strconcat(get_imap_cache_dir(), + G_DIR_SEPARATOR_S, + folder->account->recv_server, + G_DIR_SEPARATOR_S, + folder->account->userid, + NULL); + + return folder_path; +} + +static gchar *imap_item_get_path(Folder *folder, FolderItem *item) +{ + gchar *folder_path, *path; + + g_return_val_if_fail(folder != NULL, NULL); + g_return_val_if_fail(item != NULL, NULL); + folder_path = imap_folder_get_path(folder); + + g_return_val_if_fail(folder_path != NULL, NULL); + if (folder_path[0] == G_DIR_SEPARATOR) { + if (item->path) + path = g_strconcat(folder_path, G_DIR_SEPARATOR_S, + item->path, NULL); + else + path = g_strdup(folder_path); + } else { + if (item->path) + path = g_strconcat(get_home_dir(), G_DIR_SEPARATOR_S, + folder_path, G_DIR_SEPARATOR_S, + item->path, NULL); + else + path = g_strconcat(get_home_dir(), G_DIR_SEPARATOR_S, + folder_path, NULL); + } + g_free(folder_path); + + return path; +} + FolderItem *imap_create_folder(Folder *folder, FolderItem *parent, const gchar *name) { diff --git a/src/mbox_folder.c b/src/mbox_folder.c index d923e1ebb..c266bb75d 100644 --- a/src/mbox_folder.c +++ b/src/mbox_folder.c @@ -70,6 +70,7 @@ static gchar * mbox_get_folderitem_name(gchar * name); static MsgInfo *mbox_get_msginfo(Folder *folder, FolderItem *item, gint num); static gint mbox_get_num_list(Folder *folder, FolderItem *item, GSList **list); static gboolean mbox_check_msgnum_validity(Folder *folder, FolderItem *item); +static gchar *mbox_folder_get_path(Folder *folder, FolderItem *item); FolderClass mbox_class = { @@ -86,6 +87,7 @@ FolderClass mbox_class = /* FolderItem functions */ NULL, NULL, + mbox_folder_get_path, mbox_create_folder, mbox_rename_folder, mbox_remove_folder, @@ -150,7 +152,7 @@ static void mbox_folder_create_parent(const gchar * path) } -static gchar *mbox_folder_get_path(FolderItem *item) +gchar *mbox_folder_get_path(Folder *folder, FolderItem *item) { gchar *folder_path; gchar *path; @@ -1209,7 +1211,7 @@ static gboolean mbox_extract_msg(FolderItem * item, gint msgnum, gboolean already_fetched; gchar * mbox_path; - mbox_path = mbox_folder_get_path(item); + mbox_path = mbox_folder_get_path(item->folder, item); if (mbox_path == NULL) return FALSE; @@ -1347,7 +1349,7 @@ gint mbox_add_msg(Folder *folder, FolderItem *dest, const gchar *file, return -1; } - mbox_path = mbox_folder_get_path(dest); + mbox_path = mbox_folder_get_path(folder, dest); if (mbox_path == NULL) return -1; @@ -1453,7 +1455,7 @@ gint mbox_remove_msg(Folder *folder, FolderItem *item, gint num) struct _message * msg; gchar * mbox_path; - mbox_path = mbox_folder_get_path(item); + mbox_path = mbox_folder_get_path(folder, item); if (mbox_path == NULL) return -1; @@ -1474,7 +1476,7 @@ gint mbox_remove_all_msg(Folder *folder, FolderItem *item) FILE * fp; gchar * mbox_path; - mbox_path = mbox_folder_get_path(item); + mbox_path = mbox_folder_get_path(folder, item); if (mbox_path == NULL) return -1; @@ -1638,7 +1640,7 @@ void mbox_scan_folder(Folder *folder, FolderItem *item) mboxcache * cached; GList * l; - mbox_path = mbox_folder_get_path(item); + mbox_path = mbox_folder_get_path(folder, item); if (mbox_path == NULL) return; @@ -1825,7 +1827,7 @@ void mbox_change_flags(Folder * folder, FolderItem * item, MsgInfo * info, MsgPe mboxcache * cache; gchar * mbox_path; - mbox_path = mbox_folder_get_path(item); + mbox_path = mbox_folder_get_path(folder, item); if (mbox_path == NULL) return; @@ -2084,7 +2086,7 @@ gint mbox_get_num_list(Folder *folder, FolderItem *item, GSList **mlist) gchar * mbox_path; gint nummsgs = 0; - mbox_path = mbox_folder_get_path(item); + mbox_path = mbox_folder_get_path(folder, item); if (mbox_path == NULL) return -1; @@ -2137,7 +2139,7 @@ MsgInfo *mbox_get_msginfo(Folder *folder, FolderItem *item, gint num) g_return_val_if_fail(folder != NULL, NULL); g_return_val_if_fail(item != NULL, NULL); - mbox_path = mbox_folder_get_path(item); + mbox_path = mbox_folder_get_path(folder, item); g_return_val_if_fail(mbox_path != NULL, NULL); @@ -2174,7 +2176,7 @@ gboolean mbox_check_msgnum_validity(Folder *folder, FolderItem *item) struct stat s; gchar *filename; - filename = mbox_folder_get_path(item); + filename = mbox_folder_get_path(folder, item); old_cache = mbox_cache_get_mbox(filename); diff --git a/src/mh.c b/src/mh.c index b4b8a0372..b7ffd328b 100644 --- a/src/mh.c +++ b/src/mh.c @@ -79,7 +79,7 @@ static MsgInfo *mh_parse_msg(const gchar * file, FolderItem * item); static void mh_scan_tree_recursive(FolderItem * item); static gboolean mh_rename_folder_func(GNode * node, gpointer data); - +static gchar *mh_item_get_path(Folder *folder, FolderItem *item); FolderClass mh_class = { @@ -96,6 +96,7 @@ FolderClass mh_class = /* FolderItem functions */ NULL, NULL, + mh_item_get_path, mh_create_folder, mh_rename_folder, mh_remove_folder, @@ -507,6 +508,36 @@ gint mh_create_tree(Folder *folder) #undef MAKE_DIR_IF_NOT_EXIST +gchar *mh_item_get_path(Folder *folder, FolderItem *item) +{ + gchar *folder_path, *path; + + g_return_val_if_fail(folder != NULL, NULL); + g_return_val_if_fail(item != NULL, NULL); + + folder_path = g_strdup(LOCAL_FOLDER(folder)->rootpath); + g_return_val_if_fail(folder_path != NULL, NULL); + + if (folder_path[0] == G_DIR_SEPARATOR) { + if (item->path) + path = g_strconcat(folder_path, G_DIR_SEPARATOR_S, + item->path, NULL); + else + path = g_strdup(folder_path); + } else { + if (item->path) + path = g_strconcat(get_home_dir(), G_DIR_SEPARATOR_S, + folder_path, G_DIR_SEPARATOR_S, + item->path, NULL); + else + path = g_strconcat(get_home_dir(), G_DIR_SEPARATOR_S, + folder_path, NULL); + } + g_free(folder_path); + + return path; +} + FolderItem *mh_create_folder(Folder *folder, FolderItem *parent, const gchar *name) { diff --git a/src/news.c b/src/news.c index ddb966d87..df017fe54 100644 --- a/src/news.c +++ b/src/news.c @@ -107,6 +107,9 @@ GSList *news_get_msginfos (Folder *folder, gint news_post_stream (Folder *folder, FILE *fp); +static gchar *news_folder_get_path (Folder *folder); +gchar *news_item_get_path (Folder *folder, + FolderItem *item); FolderClass news_class = { @@ -123,6 +126,7 @@ FolderClass news_class = /* FolderItem functions */ NULL, NULL, + news_item_get_path, NULL, NULL, NULL, @@ -164,7 +168,7 @@ void news_folder_destroy(Folder *folder) { gchar *dir; - dir = folder_get_path(folder); + dir = news_folder_get_path(folder); if (is_dir_exist(dir)) remove_dir_recursive(dir); g_free(dir); @@ -703,6 +707,48 @@ gint news_cancel_article(Folder * folder, MsgInfo * msginfo) return 0; } +static gchar *news_folder_get_path(Folder *folder) +{ + gchar *folder_path; + + g_return_val_if_fail(folder->account != NULL, NULL); + + folder_path = g_strconcat(get_news_cache_dir(), + G_DIR_SEPARATOR_S, + folder->account->nntp_server, + NULL); + return folder_path; +} + +gchar *news_item_get_path(Folder *folder, FolderItem *item) +{ + gchar *folder_path, *path; + + g_return_val_if_fail(folder != NULL, NULL); + g_return_val_if_fail(item != NULL, NULL); + folder_path = news_folder_get_path(folder); + + g_return_val_if_fail(folder_path != NULL, NULL); + if (folder_path[0] == G_DIR_SEPARATOR) { + if (item->path) + path = g_strconcat(folder_path, G_DIR_SEPARATOR_S, + item->path, NULL); + else + path = g_strdup(folder_path); + } else { + if (item->path) + path = g_strconcat(get_home_dir(), G_DIR_SEPARATOR_S, + folder_path, G_DIR_SEPARATOR_S, + item->path, NULL); + else + path = g_strconcat(get_home_dir(), G_DIR_SEPARATOR_S, + folder_path, NULL); + } + g_free(folder_path); + + return path; +} + gint news_get_num_list(Folder *folder, FolderItem *item, GSList **msgnum_list) { NNTPSession *session; diff --git a/src/procmsg.c b/src/procmsg.c index 8aee6db65..9e89c0bf4 100644 --- a/src/procmsg.c +++ b/src/procmsg.c @@ -336,17 +336,14 @@ void procmsg_copy_messages(GSList *mlist) gchar *procmsg_get_message_file_path(MsgInfo *msginfo) { - gchar *path, *file; + gchar *file; g_return_val_if_fail(msginfo != NULL, NULL); if (msginfo->plaintext_file) file = g_strdup(msginfo->plaintext_file); else { - path = folder_item_get_path(msginfo->folder); - file = g_strconcat(path, G_DIR_SEPARATOR_S, - itos(msginfo->msgnum), NULL); - g_free(path); + file = folder_item_fetch_msg(msginfo->folder, msginfo->msgnum); } return file;