+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
* 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
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
#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)
fprintf(fp, "<folder type=\"%s\"", folder->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)
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);
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);
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 =
{
/* FolderItem functions */
imap_folder_item_new,
imap_folder_item_destroy,
+ imap_item_get_path,
imap_create_folder,
imap_rename_folder,
imap_remove_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);
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)
{
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 =
{
/* FolderItem functions */
NULL,
NULL,
+ mbox_folder_get_path,
mbox_create_folder,
mbox_rename_folder,
mbox_remove_folder,
}
-static gchar *mbox_folder_get_path(FolderItem *item)
+gchar *mbox_folder_get_path(Folder *folder, FolderItem *item)
{
gchar *folder_path;
gchar *path;
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;
return -1;
}
- mbox_path = mbox_folder_get_path(dest);
+ mbox_path = mbox_folder_get_path(folder, dest);
if (mbox_path == NULL)
return -1;
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;
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;
mboxcache * cached;
GList * l;
- mbox_path = mbox_folder_get_path(item);
+ mbox_path = mbox_folder_get_path(folder, item);
if (mbox_path == NULL)
return;
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;
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;
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);
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);
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 =
{
/* FolderItem functions */
NULL,
NULL,
+ mh_item_get_path,
mh_create_folder,
mh_rename_folder,
mh_remove_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)
{
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 =
{
/* FolderItem functions */
NULL,
NULL,
+ news_item_get_path,
NULL,
NULL,
NULL,
{
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);
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;
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;