aboutsummaryrefslogtreecommitdiffstats
path: root/camel/providers
diff options
context:
space:
mode:
authorNot Zed <NotZed@Ximian.com>2004-03-11 11:04:45 +0800
committerMichael Zucci <zucchi@src.gnome.org>2004-03-11 11:04:45 +0800
commit6071a963e85f69133cc1761e37b6ed942629d70d (patch)
tree95c9e1644c80d083e2baf049e66b9f99c5997051 /camel/providers
parentecda7da11e893ff29258388c7b594b5ef4fa902a (diff)
downloadgsoc2013-evolution-6071a963e85f69133cc1761e37b6ed942629d70d.tar
gsoc2013-evolution-6071a963e85f69133cc1761e37b6ed942629d70d.tar.gz
gsoc2013-evolution-6071a963e85f69133cc1761e37b6ed942629d70d.tar.bz2
gsoc2013-evolution-6071a963e85f69133cc1761e37b6ed942629d70d.tar.lz
gsoc2013-evolution-6071a963e85f69133cc1761e37b6ed942629d70d.tar.xz
gsoc2013-evolution-6071a963e85f69133cc1761e37b6ed942629d70d.tar.zst
gsoc2013-evolution-6071a963e85f69133cc1761e37b6ed942629d70d.zip
turn off NOINFERIORS always, translate to nochildren.
2004-03-11 Not Zed <NotZed@Ximian.com> * providers/imap/camel-imap-store.c (get_one_folder_offline): (parse_list_response_as_folder_info): turn off NOINFERIORS always, translate to nochildren. 2004-03-08 Not Zed <NotZed@Ximian.com> * camel-vee-store.c (vee_get_folder_info): setup virtual/system flags as appropriate. (change_folder): setup flags properly. * providers/nntp/camel-nntp-store.c (nntp_store_get_subscribed_folder_info): mark all folders as system folders. * providers/local/camel-mh-store.c (fill_fi): add this to setup folderinfo. (folder_info_new): call fill_fi to fill unread/total. (recursive_scan, folders_scan): ahh yeah, so wtf was i thinking, store->flags != get_folder_info flags!!!! * providers/local/camel-maildir-store.c (camel_folder_info_new): remove unread count arg & setup total. (fill_fi): setup total field. (scan_dir): remove the code that checked the directory directly - use fill_fi instead. It will more accurately reflect what you get when you visit the folder. (camel_folder_info_new): mark "." as a system folder. (scan_dir): try to setup children/no children flags properly. * providers/local/camel-mbox-store.c (fill_fi): setup total field. (scan_dir): init total. (get_folder_info): " 2004-03-05 Not Zed <NotZed@Ximian.com> * providers/imap/camel-imap-store.c (parse_list_response_as_folder_info): mark INBOX as a system folder. Can't be renamed/deleted. (fill_fi): setup total field. (get_folder_counts): ditto. * camel-store.c (add_special_info): set the system folder flag. * camel-store.h: time to fix up the camelfolderinfo mess. fix some member names, and add some type fields. Fixed all uses. svn path=/trunk/; revision=25019
Diffstat (limited to 'camel/providers')
-rw-r--r--camel/providers/imap/camel-imap-store.c62
-rw-r--r--camel/providers/imapp/camel-imapp-driver.c49
-rw-r--r--camel/providers/imapp/camel-imapp-driver.h19
-rw-r--r--camel/providers/imapp/camel-imapp-store.c14
-rw-r--r--camel/providers/local/camel-local-folder.c4
-rw-r--r--camel/providers/local/camel-local-store.c4
-rw-r--r--camel/providers/local/camel-maildir-store.c43
-rw-r--r--camel/providers/local/camel-mbox-store.c34
-rw-r--r--camel/providers/local/camel-mh-store.c82
-rw-r--r--camel/providers/local/camel-spool-store.c18
-rw-r--r--camel/providers/nntp/camel-nntp-store.c14
11 files changed, 217 insertions, 126 deletions
diff --git a/camel/providers/imap/camel-imap-store.c b/camel/providers/imap/camel-imap-store.c
index b40c5577be..4a164bf289 100644
--- a/camel/providers/imap/camel-imap-store.c
+++ b/camel/providers/imap/camel-imap-store.c
@@ -1007,12 +1007,13 @@ imap_build_folder_info(CamelImapStore *imap_store, const char *folder_name)
fi = g_malloc0(sizeof(*fi));
fi->full_name = g_strdup(folder_name);
- fi->unread_message_count = 0;
+ fi->unread = 0;
+ fi->total = 0;
url = camel_url_new (imap_store->base_url, NULL);
g_free (url->path);
url->path = g_strdup_printf ("/%s", folder_name);
- fi->url = camel_url_to_string (url, CAMEL_URL_HIDE_ALL);
+ fi->uri = camel_url_to_string (url, CAMEL_URL_HIDE_ALL);
camel_url_free(url);
fi->path = g_strdup_printf("/%s", folder_name);
name = strrchr (fi->path, '/');
@@ -1486,7 +1487,7 @@ imap_connect_online (CamelService *service, CamelException *ex)
}
/* if the namespace is under INBOX, check INBOX explicitly */
- if (!strncasecmp (store->namespace, "INBOX", 5) && !camel_exception_is_set (ex)) {
+ if (!g_ascii_strncasecmp (store->namespace, "INBOX", 5) && !camel_exception_is_set (ex)) {
gboolean just_subscribed = FALSE;
gboolean need_subscribe = FALSE;
@@ -2181,22 +2182,29 @@ parse_list_response_as_folder_info (CamelImapStore *imap_store,
}
fi = g_new0 (CamelFolderInfo, 1);
- fi->flags = flags;
fi->name = g_strdup(camel_store_info_name(imap_store->summary, si));
fi->path = g_strdup_printf("/%s", camel_store_info_path(imap_store->summary, si));
fi->full_name = g_strdup(fi->path+1);
+ if (!g_ascii_strcasecmp(fi->full_name, "inbox"))
+ flags |= CAMEL_FOLDER_SYSTEM;
+ /* HACK: some servers report noinferiors for all folders (uw-imapd)
+ We just translate this into nochildren, and let the imap layer enforce
+ it. See create folder */
+ if (flags & CAMEL_FOLDER_NOINFERIORS)
+ flags = (fi->flags & ~CAMEL_FOLDER_NOINFERIORS) | CAMEL_FOLDER_NOCHILDREN;
+ fi->flags = flags;
url = camel_url_new (imap_store->base_url, NULL);
camel_url_set_path(url, fi->path);
if (flags & CAMEL_FOLDER_NOSELECT || fi->name[0] == 0)
camel_url_set_param (url, "noselect", "yes");
- fi->url = camel_url_to_string (url, 0);
+ fi->uri = camel_url_to_string (url, 0);
camel_url_free (url);
/* FIXME: redundant */
if (flags & CAMEL_IMAP_FOLDER_UNMARKED)
- fi->unread_message_count = -1;
+ fi->unread = -1;
return fi;
}
@@ -2371,13 +2379,15 @@ static void
fill_fi(CamelStore *store, CamelFolderInfo *fi, guint32 flags)
{
CamelFolder *folder;
- int unread = -1;
+ fi->unread = -1;
+ fi->total = -1;
folder = camel_object_bag_get(store->folders, fi->full_name);
if (folder) {
if ((flags & CAMEL_STORE_FOLDER_INFO_FAST) == 0)
camel_folder_refresh_info(folder, NULL);
- unread = camel_folder_get_unread_message_count(folder);
+ fi->unread = camel_folder_get_unread_message_count(folder);
+ fi->total = camel_folder_get_message_count(folder);
camel_object_unref(folder);
} else {
char *storage_path, *folder_dir, *path;
@@ -2390,16 +2400,16 @@ fill_fi(CamelStore *store, CamelFolderInfo *fi, guint32 flags)
s = (CamelFolderSummary *)camel_object_new(camel_imap_summary_get_type());
camel_folder_summary_set_build_content(s, TRUE);
camel_folder_summary_set_filename(s, path);
- if (camel_folder_summary_header_load(s) != -1)
- unread = s->unread_count;
+ if (camel_folder_summary_header_load(s) != -1) {
+ fi->unread = s->unread_count;
+ fi->total = s->saved_count;
+ }
g_free(storage_path);
g_free(folder_dir);
g_free(path);
camel_object_unref(s);
}
-
- fi->unread_message_count = unread;
}
static void
@@ -2420,7 +2430,7 @@ get_folder_counts(CamelImapStore *imap_store, CamelFolderInfo *fi, CamelExceptio
/* ignore noselect folders, and check only inbox if we only check inbox */
if ((fi->flags & CAMEL_FOLDER_NOSELECT) == 0
&& ( (imap_store->parameters & IMAP_PARAM_CHECK_ALL)
- || strcasecmp(fi->full_name, "inbox") == 0) ) {
+ || g_ascii_strcasecmp(fi->full_name, "inbox") == 0) ) {
CAMEL_SERVICE_LOCK (imap_store, connect_lock);
/* For the current folder, poke it to check for new
@@ -2431,14 +2441,18 @@ get_folder_counts(CamelImapStore *imap_store, CamelFolderInfo *fi, CamelExceptio
/* we bypass the folder locking otherwise we can deadlock. we use the command lock for
any operations anyway so this is 'safe'. See comment above imap_store_refresh_folders() for info */
CAMEL_FOLDER_CLASS (CAMEL_OBJECT_GET_CLASS(imap_store->current_folder))->refresh_info(imap_store->current_folder, ex);
- fi->unread_message_count = camel_folder_get_unread_message_count (imap_store->current_folder);
+ fi->unread = camel_folder_get_unread_message_count (imap_store->current_folder);
+ fi->total = camel_folder_get_message_count(imap_store->current_folder);
} else {
- fi->unread_message_count = get_folder_status (imap_store, fi->full_name, "UNSEEN");
+ /* FIXME: this should be one round-trip */
+ fi->unread = get_folder_status (imap_store, fi->full_name, "UNSEEN");
+ fi->total = get_folder_status(imap_store, fi->full_name, "MESSAGES");
/* if we have this folder open, and the unread count has changed, update */
folder = camel_object_bag_get(CAMEL_STORE(imap_store)->folders, fi->full_name);
- if (folder && fi->unread_message_count != camel_folder_get_unread_message_count(folder)) {
+ if (folder && fi->unread != camel_folder_get_unread_message_count(folder)) {
CAMEL_FOLDER_CLASS (CAMEL_OBJECT_GET_CLASS(folder))->refresh_info(folder, ex);
- fi->unread_message_count = camel_folder_get_unread_message_count(folder);
+ fi->unread = camel_folder_get_unread_message_count(folder);
+ fi->total = camel_folder_get_message_count(folder);
}
if (folder)
camel_object_unref(folder);
@@ -2453,7 +2467,7 @@ get_folder_counts(CamelImapStore *imap_store, CamelFolderInfo *fi, CamelExceptio
if (fi->child)
q = g_slist_append(q, fi->child);
- fi = fi->sibling;
+ fi = fi->next;
}
}
}
@@ -2678,12 +2692,18 @@ get_one_folder_offline (const char *physical_path, const char *path, gpointer da
|| (si->flags & CAMEL_STORE_INFO_FOLDER_SUBSCRIBED)) {
fi = imap_build_folder_info(imap_store, path+1);
fi->flags = si->flags;
+ /* HACK: some servers report noinferiors for all folders (uw-imapd)
+ We just translate this into nochildren, and let the imap layer enforce
+ it. See create folder */
+ if (fi->flags & CAMEL_FOLDER_NOINFERIORS)
+ fi->flags = (fi->flags & ~CAMEL_FOLDER_NOINFERIORS) | CAMEL_FOLDER_NOCHILDREN;
+
if (si->flags & CAMEL_FOLDER_NOSELECT) {
- CamelURL *url = camel_url_new(fi->url, NULL);
+ CamelURL *url = camel_url_new(fi->uri, NULL);
camel_url_set_param (url, "noselect", "yes");
- g_free(fi->url);
- fi->url = camel_url_to_string (url, 0);
+ g_free(fi->uri);
+ fi->uri = camel_url_to_string (url, 0);
camel_url_free (url);
} else {
fill_fi((CamelStore *)imap_store, fi, 0);
diff --git a/camel/providers/imapp/camel-imapp-driver.c b/camel/providers/imapp/camel-imapp-driver.c
index 0e666c46bd..54c050c675 100644
--- a/camel/providers/imapp/camel-imapp-driver.c
+++ b/camel/providers/imapp/camel-imapp-driver.c
@@ -430,24 +430,37 @@ camel_imapp_driver_sync(CamelIMAPPDriver *id, gboolean expunge, CamelIMAPPFolder
}
}
-struct _fetch_data {
- struct _fetch_data *next;
- struct _fetch_data *prev;
+static void
+fetch_data_free(CamelIMAPPFetch *fd)
+{
+ if (fd->body)
+ camel_object_unref(fd->body);
+ camel_object_unref(fd->folder);
+ g_free(fd->uid);
+ g_free(fd->section);
+ g_free(fd);
+}
- CamelStream *data;
- const char *uid;
- const char *section;
-};
+struct _CamelStream * camel_imapp_driver_fetch(CamelIMAPPDriver *id, struct _CamelIMAPPFolder *folder, const char *uid, const char *body)
+{
+ return NULL;
+}
-CamelStream *
-camel_imapp_driver_fetch(CamelIMAPPDriver *id, CamelIMAPPFolder *folder, const char *uid, const char *section)
+#if 0
+void
+camel_imapp_driver_fetch(CamelIMAPPDriver *id, CamelIMAPPFolder *folder, const char *uid, const char *section, CamelIMAPPFetchFunc done, void *data)
{
- struct _fetch_data fd;
+ struct _fetch_data *fd;
CamelIMAPPCommand *ic;
- fd.data = NULL;
- fd.uid = uid;
- fd.section = section;
+ fd = g_malloc0(sizeof(*fd));
+ fd->folder = folder;
+ camel_object_ref(folder);
+ fd->uid = g_strdup(uid);
+ fd->section = g_strdup(fd->section);
+ fd->done = done;
+ fd->data = data;
+
e_dlist_addtail(&id->body_fetch, (EDListNode *)&fd);
CAMEL_TRY {
@@ -467,6 +480,7 @@ camel_imapp_driver_fetch(CamelIMAPPDriver *id, CamelIMAPPFolder *folder, const c
return fd.data;
}
+#endif
GPtrArray *
camel_imapp_driver_list(CamelIMAPPDriver *id, const char *name, guint32 flags)
@@ -738,16 +752,13 @@ driver_resp_fetch(CamelIMAPPEngine *ie, guint32 id, CamelIMAPPDriver *sdata)
}
if ((finfo->got & (FETCH_BODY|FETCH_UID)) == (FETCH_BODY|FETCH_UID)) {
- struct _fetch_data *fd, *fn;
+ CamelIMAPPFetch *fd, *fn;
- fd = (struct _fetch_data *)sdata->body_fetch.head;
+ fd = (CamelIMAPPFetch *)sdata->body_fetch.head;
fn = fd->next;
while (fn) {
if (!strcmp(finfo->uid, fd->uid) && !strcmp(finfo->section, fd->section)) {
- if (fd->data)
- camel_object_unref(fd->data);
- fd->data = finfo->body;
- camel_object_ref(fd->data);
+ fd->done(sdata, fd);
e_dlist_remove((EDListNode *)fd);
e_dlist_addtail(&sdata->body_fetch_done, (EDListNode *)fd);
break;
diff --git a/camel/providers/imapp/camel-imapp-driver.h b/camel/providers/imapp/camel-imapp-driver.h
index 3124700619..c336dd3d2a 100644
--- a/camel/providers/imapp/camel-imapp-driver.h
+++ b/camel/providers/imapp/camel-imapp-driver.h
@@ -14,10 +14,28 @@
typedef struct _CamelIMAPPDriver CamelIMAPPDriver;
typedef struct _CamelIMAPPDriverClass CamelIMAPPDriverClass;
+typedef struct _CamelIMAPPFetch CamelIMAPPFetch;
+
typedef int (*CamelIMAPPDriverFunc)(struct _CamelIMAPPDriver *driver, void *data);
typedef struct _CamelSasl * (*CamelIMAPPSASLFunc)(struct _CamelIMAPPDriver *driver, void *data);
typedef void (*CamelIMAPPLoginFunc)(struct _CamelIMAPPDriver *driver, char **login, char **pass, void *data);
+typedef void (*CamelIMAPPFetchFunc)(struct _CamelIMAPPDriver *driver, CamelIMAPPFetch *);
+
+struct _CamelIMAPPFetch {
+ struct _CamelIMAPPFetch *next;
+ struct _CamelIMAPPFetch *prev;
+
+ CamelStream *body; /* the content fetched */
+
+ struct _CamelIMAPPFolder *folder;
+ char *uid;
+ char *section;
+
+ CamelIMAPPFetchFunc done;
+ void *data;
+};
+
struct _CamelMimeMessage;
struct _CamelIMAPPDriver {
@@ -73,6 +91,7 @@ void camel_imapp_driver_update(CamelIMAPPDriver *id, struct _CamelIMAPPFolder
void camel_imapp_driver_sync(CamelIMAPPDriver *id, gboolean expunge, struct _CamelIMAPPFolder *folder);
struct _CamelStream * camel_imapp_driver_fetch(CamelIMAPPDriver *id, struct _CamelIMAPPFolder *folder, const char *uid, const char *body);
+
GPtrArray * camel_imapp_driver_list(CamelIMAPPDriver *id, const char *name, guint32 flags);
struct _CamelStream *camel_imapp_driver_get(CamelIMAPPDriver *id, struct _CamelIMAPPFolder *folder, const char *uid);
diff --git a/camel/providers/imapp/camel-imapp-store.c b/camel/providers/imapp/camel-imapp-store.c
index 50c5c4db8b..2332a09648 100644
--- a/camel/providers/imapp/camel-imapp-store.c
+++ b/camel/providers/imapp/camel-imapp-store.c
@@ -540,13 +540,17 @@ folders_build_info(CamelURL *base, struct _list_info *li)
camel_url_set_path(base, path);
fi = g_malloc0(sizeof(*fi));
- fi->url = camel_url_to_string(base, CAMEL_URL_HIDE_ALL);
+ fi->uri = camel_url_to_string(base, CAMEL_URL_HIDE_ALL);
fi->name = g_strdup(name);
fi->full_name = full_name;
fi->path = g_strdup(path);
- fi->unread_message_count = -1;
+ fi->unread = -1;
+ fi->total = -1;
fi->flags = li->flags;
+ if (!g_ascii_strcasecmp(fi->full_name, "inbox"))
+ fi->flags |= CAMEL_FOLDER_SYSTEM;
+
/* TODO: could look up count here ... */
/* ?? */
/*folder = camel_object_bag_get(store->folders, "INBOX");*/
@@ -616,7 +620,7 @@ folders_build_rec(CamelURL *base, GPtrArray *folders, int *ip, CamelFolderInfo *
fi = folders_build_info(base, li);
fi->parent = pfi;
if (last != NULL)
- last->sibling = fi;
+ last->next = fi;
last = fi;
if (first == NULL)
first = fi;
@@ -638,10 +642,10 @@ folder_info_dump(CamelFolderInfo *fi, int depth)
memset(s, ' ', depth);
s[depth] = 0;
while (fi) {
- printf("%s%s (%s)\n", s, fi->name, fi->url);
+ printf("%s%s (%s)\n", s, fi->name, fi->uri);
if (fi->child)
folder_info_dump(fi->child, depth+2);
- fi = fi->sibling;
+ fi = fi->next;
}
}
diff --git a/camel/providers/local/camel-local-folder.c b/camel/providers/local/camel-local-folder.c
index 719d133645..5ea484ef99 100644
--- a/camel/providers/local/camel-local-folder.c
+++ b/camel/providers/local/camel-local-folder.c
@@ -313,8 +313,8 @@ camel_local_folder_construct(CamelLocalFolder *lf, CamelStore *parent_store, con
fi = g_new0 (CamelFolderInfo, 1);
fi->full_name = g_strdup (full_name);
fi->name = g_strdup (name);
- fi->url = g_strdup_printf("%s:%s#%s", ((CamelService *)parent_store)->url->protocol, ((CamelService *)parent_store)->url->path, full_name);
- fi->unread_message_count = camel_folder_get_unread_message_count(folder);
+ fi->uri = g_strdup_printf("%s:%s#%s", ((CamelService *)parent_store)->url->protocol, ((CamelService *)parent_store)->url->path, full_name);
+ fi->unread = camel_folder_get_unread_message_count(folder);
camel_folder_info_build_path(fi, '/');
camel_object_trigger_event(CAMEL_OBJECT (parent_store), "folder_created", fi);
diff --git a/camel/providers/local/camel-local-store.c b/camel/providers/local/camel-local-store.c
index fae124e448..a883f4a4dd 100644
--- a/camel/providers/local/camel-local-store.c
+++ b/camel/providers/local/camel-local-store.c
@@ -427,9 +427,9 @@ delete_folder(CamelStore *store, const char *folder_name, CamelException *ex)
fi = g_new0 (CamelFolderInfo, 1);
fi->full_name = g_strdup (folder_name);
fi->name = g_path_get_basename (folder_name);
- fi->url = g_strdup_printf ("%s:%s#%s", ((CamelService *) store)->url->protocol,
+ fi->uri = g_strdup_printf ("%s:%s#%s", ((CamelService *) store)->url->protocol,
CAMEL_LOCAL_STORE(store)->toplevel_dir, folder_name);
- fi->unread_message_count = -1;
+ fi->unread = -1;
camel_folder_info_build_path(fi, '/');
camel_object_trigger_event (store, "folder_deleted", fi);
diff --git a/camel/providers/local/camel-maildir-store.c b/camel/providers/local/camel-maildir-store.c
index b0412d3d9a..5d0654c6e4 100644
--- a/camel/providers/local/camel-maildir-store.c
+++ b/camel/providers/local/camel-maildir-store.c
@@ -222,17 +222,21 @@ static void delete_folder(CamelStore * store, const char *folder_name, CamelExce
g_free(new);
}
-static CamelFolderInfo *camel_folder_info_new(const char *url, const char *full, const char *name, int unread)
+static CamelFolderInfo *camel_folder_info_new(const char *url, const char *full, const char *name)
{
CamelFolderInfo *fi;
fi = g_malloc0(sizeof(*fi));
- fi->url = g_strdup(url);
+ fi->uri = g_strdup(url);
fi->full_name = g_strdup(full);
fi->name = g_strdup(name);
- fi->unread_message_count = unread;
+ fi->unread = -1;
+ fi->total = -1;
camel_folder_info_build_path(fi, '/');
+ if (!strcmp(full, "."))
+ fi->flags |= CAMEL_FOLDER_SYSTEM;
+
d(printf("Adding maildir info: '%s' '%s' '%s' '%s'\n", fi->path, fi->name, fi->full_name, fi->url));
return fi;
@@ -242,13 +246,13 @@ static void
fill_fi(CamelStore *store, CamelFolderInfo *fi, guint32 flags)
{
CamelFolder *folder;
- int unread = -1;
folder = camel_object_bag_get(store->folders, fi->full_name);
if (folder) {
if ((flags & CAMEL_STORE_FOLDER_INFO_FAST) == 0)
camel_folder_refresh_info(folder, NULL);
- unread = camel_folder_get_unread_message_count(folder);
+ fi->unread = camel_folder_get_unread_message_count(folder);
+ fi->total = camel_folder_get_message_count(folder);
camel_object_unref(folder);
} else {
char *path, *folderpath;
@@ -260,14 +264,14 @@ fill_fi(CamelStore *store, CamelFolderInfo *fi, guint32 flags)
path = g_strdup_printf("%s/%s.ev-summary", root, fi->full_name);
folderpath = g_strdup_printf("%s/%s", root, fi->full_name);
s = (CamelFolderSummary *)camel_maildir_summary_new(path, folderpath, NULL);
- if (camel_folder_summary_header_load(s) != -1)
- unread = s->unread_count;
+ if (camel_folder_summary_header_load(s) != -1) {
+ fi->unread = s->unread_count;
+ fi->total = s->saved_count;
+ }
camel_object_unref(s);
g_free(folderpath);
g_free(path);
}
-
- fi->unread_message_count = unread;
}
/* used to find out where we've visited already */
@@ -285,8 +289,6 @@ static int scan_dir(CamelStore *store, GHashTable *visited, char *root, const ch
const char *base;
CamelFolderInfo *fi = NULL;
struct stat st;
- CamelFolder *folder;
- int unread;
/* look for folders matching the right structure, recursively */
name = g_strdup_printf("%s/%s", root, path);
@@ -310,6 +312,7 @@ static int scan_dir(CamelStore *store, GHashTable *visited, char *root, const ch
else
base = path;
+#if 0
/* if we have this folder open, get the real unread count */
folder = camel_object_bag_get(store->folders, path);
if (folder) {
@@ -348,16 +351,15 @@ static int scan_dir(CamelStore *store, GHashTable *visited, char *root, const ch
closedir(dir);
}
}
-
- fi = camel_folder_info_new(uri, path, base, -1);
- /* fills the unread count */
+#endif
+ fi = camel_folder_info_new(uri, path, base);
fill_fi(store, fi, flags);
d(printf("found! uri = %s\n", fi->url));
d(printf(" full_name = %s\n name = '%s'\n", fi->full_name, fi->name));
fi->parent = parent;
- fi->sibling = *fip;
+ fi->next = *fip;
*fip = fi;
g_free(uri);
@@ -365,10 +367,10 @@ static int scan_dir(CamelStore *store, GHashTable *visited, char *root, const ch
g_free(cur);
g_free(new);
- unread = 0;
-
/* always look further if asked */
if (((flags & CAMEL_STORE_FOLDER_INFO_RECURSIVE) || parent == NULL)) {
+ int children = 0;
+
dir = opendir(name);
if (dir == NULL) {
camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM,
@@ -394,6 +396,8 @@ static int scan_dir(CamelStore *store, GHashTable *visited, char *root, const ch
if (g_hash_table_lookup(visited, &in) == NULL) {
struct _inode *inew = g_malloc(sizeof(*inew));
+ children++;
+
*inew = in;
g_hash_table_insert(visited, inew, inew);
new = g_strdup_printf("%s/%s", path, d->d_name);
@@ -409,6 +413,11 @@ static int scan_dir(CamelStore *store, GHashTable *visited, char *root, const ch
g_free(tmp);
}
closedir(dir);
+
+ if (children)
+ fi->flags |= CAMEL_FOLDER_CHILDREN;
+ else
+ fi->flags |= CAMEL_FOLDER_NOCHILDREN;
}
g_free(name);
diff --git a/camel/providers/local/camel-mbox-store.c b/camel/providers/local/camel-mbox-store.c
index 94b2e6fbeb..595445f99c 100644
--- a/camel/providers/local/camel-mbox-store.c
+++ b/camel/providers/local/camel-mbox-store.c
@@ -330,8 +330,8 @@ delete_folder(CamelStore *store, const char *folder_name, CamelException *ex)
fi = g_new0(CamelFolderInfo, 1);
fi->full_name = g_strdup(folder_name);
fi->name = g_path_get_basename(folder_name);
- fi->url = g_strdup_printf("mbox:%s#%s",((CamelService *) store)->url->path, folder_name);
- fi->unread_message_count = -1;
+ fi->uri = g_strdup_printf("mbox:%s#%s",((CamelService *) store)->url->path, folder_name);
+ fi->unread = -1;
camel_folder_info_build_path(fi, '/');
camel_object_trigger_event(store, "folder_deleted", fi);
@@ -600,13 +600,15 @@ static void
fill_fi(CamelStore *store, CamelFolderInfo *fi, guint32 flags)
{
CamelFolder *folder;
- int unread = -1;
+ fi->unread = -1;
+ fi->total = -1;
folder = camel_object_bag_get(store->folders, fi->full_name);
if (folder) {
if ((flags & CAMEL_STORE_FOLDER_INFO_FAST) == 0)
camel_folder_refresh_info(folder, NULL);
- unread = camel_folder_get_unread_message_count(folder);
+ fi->unread = camel_folder_get_unread_message_count(folder);
+ fi->total = camel_folder_get_message_count(folder);
camel_object_unref(folder);
} else {
char *path, *folderpath;
@@ -619,15 +621,15 @@ fill_fi(CamelStore *store, CamelFolderInfo *fi, guint32 flags)
folderpath = camel_mbox_folder_get_full_path(root, fi->full_name);
mbs = (CamelMboxSummary *)camel_mbox_summary_new(path, folderpath, NULL);
- if (camel_folder_summary_header_load((CamelFolderSummary *)mbs) != -1)
- unread = ((CamelFolderSummary *)mbs)->unread_count;
+ if (camel_folder_summary_header_load((CamelFolderSummary *)mbs) != -1) {
+ fi->unread = ((CamelFolderSummary *)mbs)->unread_count;
+ fi->total = ((CamelFolderSummary *)mbs)->saved_count;
+ }
camel_object_unref(mbs);
g_free(folderpath);
g_free(path);
}
-
- fi->unread_message_count = unread;
}
static CamelFolderInfo *
@@ -692,7 +694,7 @@ scan_dir(CamelStore *store, GHashTable *visited, CamelFolderInfo *parent, const
fi->flags =(fi->flags & ~CAMEL_FOLDER_NOCHILDREN) | CAMEL_FOLDER_CHILDREN;
} else {
fi->flags &= ~CAMEL_FOLDER_NOSELECT;
- if ((ext = strchr(fi->url, ';')) && !strncmp(ext, ";noselect=yes", 13))
+ if ((ext = strchr(fi->uri, ';')) && !strncmp(ext, ";noselect=yes", 13))
memmove(ext, ext + 13, strlen(ext + 13) + 1);
}
} else {
@@ -700,13 +702,14 @@ scan_dir(CamelStore *store, GHashTable *visited, CamelFolderInfo *parent, const
fi->parent = parent;
/* add ";noselect=yes" if we haven't found the mbox file yet. when we find it, remove the noselect */
- fi->url = g_strdup_printf("mbox:%s%s#%s",((CamelService *) store)->url->path,
+ fi->uri = g_strdup_printf("mbox:%s%s#%s",((CamelService *) store)->url->path,
S_ISDIR(st.st_mode) ? ";noselect=yes" : "", full_name);
fi->name = short_name;
fi->full_name = full_name;
fi->path = g_strdup_printf("/%s", full_name);
- fi->unread_message_count = -1;
-
+ fi->unread = -1;
+ fi->total = -1;
+
if (S_ISDIR(st.st_mode))
fi->flags = CAMEL_FOLDER_NOSELECT;
else
@@ -715,7 +718,7 @@ scan_dir(CamelStore *store, GHashTable *visited, CamelFolderInfo *parent, const
if (tail == NULL)
folders = fi;
else
- tail->sibling = fi;
+ tail->next = fi;
tail = fi;
@@ -802,10 +805,11 @@ get_folder_info(CamelStore *store, const char *top, guint32 flags, CamelExceptio
fi = g_new0(CamelFolderInfo, 1);
fi->parent = NULL;
- fi->url = g_strdup_printf("mbox:%s#%s",((CamelService *) store)->url->path, top);
+ fi->uri = g_strdup_printf("mbox:%s#%s",((CamelService *) store)->url->path, top);
fi->name = g_strdup(base);
fi->full_name = g_strdup(top);
- fi->unread_message_count = -1;
+ fi->unread = -1;
+ fi->total = -1;
fi->path = g_strdup_printf("/%s", top);
subdir = g_strdup_printf("%s.sbd", path);
diff --git a/camel/providers/local/camel-mh-store.c b/camel/providers/local/camel-mh-store.c
index b16c140a66..e1c03c2349 100644
--- a/camel/providers/local/camel-mh-store.c
+++ b/camel/providers/local/camel-mh-store.c
@@ -38,6 +38,8 @@
#include <camel/camel-stream-fs.h>
#include <camel/camel-stream-buffer.h>
+#include "camel-mh-summary.h"
+
static CamelLocalStoreClass *parent_class = NULL;
#define d(x)
@@ -290,35 +292,57 @@ rename_folder(CamelStore *store, const char *old, const char *new, CamelExceptio
}
}
-static CamelFolderInfo *folder_info_new(CamelStore *store, const char *root, const char *path)
+static void
+fill_fi(CamelStore *store, CamelFolderInfo *fi, guint32 flags)
+{
+ CamelFolder *folder;
+
+ folder = camel_object_bag_get(store->folders, fi->full_name);
+ if (folder) {
+ if ((flags & CAMEL_STORE_FOLDER_INFO_FAST) == 0)
+ camel_folder_refresh_info(folder, NULL);
+ fi->unread = camel_folder_get_unread_message_count(folder);
+ fi->total = camel_folder_get_message_count(folder);
+ camel_object_unref(folder);
+ } else {
+ char *path, *folderpath;
+ CamelFolderSummary *s;
+ const char *root;
+
+ /* This should be fast enough not to have to test for INFO_FAST */
+
+ /* We could: if we have no folder, and FAST isn't specified, perform a full
+ scan of all messages for their status flags. But its probably not worth
+ it as we need to read the top of every file, i.e. very very slow */
+
+ root = camel_local_store_get_toplevel_dir((CamelLocalStore *)store);
+ path = g_strdup_printf("%s/%s.ev-summary", root, fi->full_name);
+ folderpath = g_strdup_printf("%s/%s", root, fi->full_name);
+ s = (CamelFolderSummary *)camel_mh_summary_new(path, folderpath, NULL);
+ if (camel_folder_summary_header_load(s) != -1) {
+ fi->unread = s->unread_count;
+ fi->total = s->saved_count;
+ }
+ camel_object_unref(s);
+ g_free(folderpath);
+ g_free(path);
+ }
+}
+
+static CamelFolderInfo *folder_info_new(CamelStore *store, const char *root, const char *path, guint32 flags)
{
CamelFolderInfo *fi;
char *base;
- CamelFolder *folder;
base = strrchr(path, '/');
/* Build the folder info structure. */
fi = g_malloc0(sizeof(*fi));
- fi->url = g_strdup_printf("mh:%s#%s", root, path);
+ fi->uri = g_strdup_printf("mh:%s#%s", root, path);
fi->full_name = g_strdup(path);
fi->name = g_strdup(base?base+1:path);
- fi->unread_message_count = 0;
-
- /* check unread count if open */
- folder = camel_object_bag_get(store->folders, path);
- if (folder) {
- if ((((CamelMhStore *)store)->flags & CAMEL_STORE_FOLDER_INFO_FAST) == 0)
- camel_folder_refresh_info(folder, NULL);
- fi->unread_message_count = camel_folder_get_unread_message_count(folder);
- camel_object_unref(folder);
- }
-
- /* We could: if we have no folder, and FAST isn't specified, perform a full
- scan of all messages for their status flags. But its probably not worth
- it as we need to read the top of every file, i.e. very very slow */
-
camel_folder_info_build_path(fi, '/');
+ fill_fi(store, fi, flags);
d(printf("New folderinfo:\n '%s'\n '%s'\n '%s'\n", fi->full_name, fi->url, fi->path));
@@ -333,7 +357,7 @@ struct _inode {
/* Scan path, under root, for directories to add folders for. Both
* root and path should have a trailing "/" if they aren't empty. */
-static void recursive_scan(CamelStore *store, CamelFolderInfo **fip, CamelFolderInfo *parent, GHashTable *visited, const char *root, const char *path)
+static void recursive_scan(CamelStore *store, CamelFolderInfo **fip, CamelFolderInfo *parent, GHashTable *visited, const char *root, const char *path, guint32 flags)
{
char *fullpath, *tmp;
DIR *dp;
@@ -364,12 +388,12 @@ static void recursive_scan(CamelStore *store, CamelFolderInfo **fip, CamelFolder
g_hash_table_insert(visited, inew, inew);
/* link in ... */
- fi = folder_info_new(store, root, path);
+ fi = folder_info_new(store, root, path, flags);
fi->parent = parent;
- fi->sibling = *fip;
+ fi->next = *fip;
*fip = fi;
- if ((( ((CamelMhStore *)store)->flags & CAMEL_STORE_FOLDER_INFO_RECURSIVE) || parent == NULL)) {
+ if (((flags & CAMEL_STORE_FOLDER_INFO_RECURSIVE) || parent == NULL)) {
/* now check content for possible other directories */
dp = opendir(fullpath);
if (dp == NULL)
@@ -390,10 +414,10 @@ static void recursive_scan(CamelStore *store, CamelFolderInfo **fip, CamelFolder
/* otherwise, treat at potential node, and recurse, a bit more expensive than needed, but tough! */
if (path[0]) {
tmp = g_strdup_printf("%s/%s", path, d->d_name);
- recursive_scan(store, &fi->child, fi, visited, root, tmp);
+ recursive_scan(store, &fi->child, fi, visited, root, tmp, flags);
g_free(tmp);
} else {
- recursive_scan(store, &fi->child, fi, visited, root, d->d_name);
+ recursive_scan(store, &fi->child, fi, visited, root, d->d_name, flags);
}
}
@@ -403,7 +427,7 @@ static void recursive_scan(CamelStore *store, CamelFolderInfo **fip, CamelFolder
/* scan a .folders file */
static void
-folders_scan(CamelStore *store, const char *root, const char *top, CamelFolderInfo **fip)
+folders_scan(CamelStore *store, const char *root, const char *top, CamelFolderInfo **fip, guint32 flags)
{
CamelFolderInfo *fi;
char line[512], *path, *tmp;
@@ -452,7 +476,7 @@ folders_scan(CamelStore *store, const char *root, const char *top, CamelFolderIn
continue;
/* check is not sub-subdir if not recursive */
- if (( ((CamelMhStore *)store)->flags & CAMEL_STORE_FOLDER_INFO_RECURSIVE) == 0
+ if ((flags & CAMEL_STORE_FOLDER_INFO_RECURSIVE) == 0
&& (tmp = strrchr(line, '/'))
&& tmp > line+toplen)
continue;
@@ -466,7 +490,7 @@ folders_scan(CamelStore *store, const char *root, const char *top, CamelFolderIn
path = g_strdup_printf("%s/%s", root, line);
if (stat(path, &st) == 0 && S_ISDIR(st.st_mode)) {
- fi = folder_info_new(store, root, line);
+ fi = folder_info_new(store, root, line, flags);
g_ptr_array_add(folders, fi);
}
g_free(path);
@@ -512,14 +536,14 @@ get_folder_info (CamelStore *store, const char *top, guint32 flags, CamelExcepti
/* use .folders if we are supposed to */
if (((CamelMhStore *)store)->flags & CAMEL_MH_DOTFOLDERS) {
- folders_scan(store, root, top, &fi);
+ folders_scan(store, root, top, &fi, flags);
} else {
GHashTable *visited = g_hash_table_new(inode_hash, inode_equal);
if (top == NULL)
top = "";
- recursive_scan(store, &fi, NULL, visited, root, top);
+ recursive_scan(store, &fi, NULL, visited, root, top, flags);
/* if we actually scanned from root, we have a "" root node we dont want */
if (fi != NULL && top[0] == 0) {
diff --git a/camel/providers/local/camel-spool-store.c b/camel/providers/local/camel-spool-store.c
index 09720e4a01..1aa18965ae 100644
--- a/camel/providers/local/camel-spool-store.c
+++ b/camel/providers/local/camel-spool-store.c
@@ -228,7 +228,7 @@ delete_folder(CamelStore *store, const char *folder_name, CamelException *ex)
static void free_folder_info (CamelStore *store, CamelFolderInfo *fi)
{
if (fi) {
- g_free(fi->url);
+ g_free(fi->uri);
g_free(fi->name);
g_free(fi->full_name);
g_free(fi->path);
@@ -242,10 +242,10 @@ camel_folder_info_new(const char *url, const char *full, const char *name, int u
CamelFolderInfo *fi;
fi = g_malloc0(sizeof(*fi));
- fi->url = g_strdup(url);
+ fi->uri = g_strdup(url);
fi->full_name = g_strdup(full);
fi->name = g_strdup(name);
- fi->unread_message_count = unread;
+ fi->unread = unread;
camel_folder_info_build_path(fi, '/');
d(printf("Adding spoold info: '%s' '%s' '%s' '%s'\n", fi->path, fi->name, fi->full_name, fi->url));
@@ -303,7 +303,7 @@ static int scan_dir(CamelStore *store, GHashTable *visited, char *root, const ch
uri = g_strdup_printf("%s:%s#%s", ((CamelService *)store)->url->protocol, root, path);
fi = camel_folder_info_new(uri, path, tmp, unread);
fi->parent = parent;
- fi->sibling = *fip;
+ fi->next = *fip;
*fip = fi;
g_free(uri);
}
@@ -327,7 +327,7 @@ static int scan_dir(CamelStore *store, GHashTable *visited, char *root, const ch
tmp++;
fi = camel_folder_info_new(uri, path, tmp, -1);
fi->parent = parent;
- fi->sibling = *fip;
+ fi->next = *fip;
*fip = fi;
g_free(uri);
@@ -376,7 +376,7 @@ static int scan_dir(CamelStore *store, GHashTable *visited, char *root, const ch
uri = g_strdup_printf("%s:%s#%s", ((CamelService *)store)->url->protocol, root, fname);
fi = camel_folder_info_new(uri, fname, d->d_name, unread);
fi->parent = parent;
- fi->sibling = *fip;
+ fi->next = *fip;
*fip = fi;
g_free(uri);
}
@@ -458,14 +458,14 @@ get_folder_info_mbox(CamelStore *store, const char *top, guint32 flags, CamelExc
fi = g_malloc0(sizeof(*fi));
fi->full_name = g_strdup("INBOX");
fi->name = g_strdup("INBOX");
- fi->url = g_strdup_printf("%s:%s#%s", service->url->protocol, service->url->path, fi->name);
+ fi->uri = g_strdup_printf("%s:%s#%s", service->url->protocol, service->url->path, fi->name);
folder = camel_object_bag_get(store->folders, fi->full_name);
if (folder) {
- fi->unread_message_count = camel_folder_get_unread_message_count(folder);
+ fi->unread = camel_folder_get_unread_message_count(folder);
camel_object_unref(folder);
} else
- fi->unread_message_count = -1;
+ fi->unread = -1;
camel_folder_info_build_path(fi, '/');
}
diff --git a/camel/providers/nntp/camel-nntp-store.c b/camel/providers/nntp/camel-nntp-store.c
index 77fbd59fe8..815e3d7397 100644
--- a/camel/providers/nntp/camel-nntp-store.c
+++ b/camel/providers/nntp/camel-nntp-store.c
@@ -398,7 +398,7 @@ nntp_folder_info_from_store_info (CamelNNTPStore *store, gboolean short_notation
else
fi->name = g_strdup (si->path);
- fi->unread_message_count = -1;
+ fi->unread = -1;
/* fi->path is the 'canonicalised' path used by the UI (folder-tree). Not
* as important these days, but folders used to get added to the tree based
* on its path rather than the structure of the CamelFolderInfo's.
@@ -409,7 +409,7 @@ nntp_folder_info_from_store_info (CamelNNTPStore *store, gboolean short_notation
/*camel_folder_info_build_path(fi, '/');*/
fi->path = g_strdup_printf ("/%s", si->path);
url = camel_url_new_with_base (base_url, fi->path);
- fi->url = camel_url_to_string (url, CAMEL_URL_HIDE_ALL);
+ fi->uri = camel_url_to_string (url, CAMEL_URL_HIDE_ALL);
camel_url_free (url);
return fi;
@@ -429,12 +429,12 @@ nntp_folder_info_from_name (CamelNNTPStore *store, gboolean short_notation, cons
else
fi->name = g_strdup (name);
- fi->unread_message_count = -1;
+ fi->unread = -1;
fi->path = g_strdup_printf ("/%s", name);
url = camel_url_new_with_base (base_url, fi->path);
- fi->url = camel_url_to_string (url, CAMEL_URL_HIDE_ALL);
+ fi->uri = camel_url_to_string (url, CAMEL_URL_HIDE_ALL);
camel_url_free (url);
return fi;
@@ -477,9 +477,9 @@ nntp_store_get_subscribed_folder_info (CamelNNTPStore *store, const char *top, g
fi = nntp_folder_info_from_store_info (store, store->do_short_folder_notation, si);
if (!fi)
continue;
- fi->flags |= CAMEL_FOLDER_NOINFERIORS | CAMEL_FOLDER_NOCHILDREN;
+ fi->flags |= CAMEL_FOLDER_NOINFERIORS | CAMEL_FOLDER_NOCHILDREN | CAMEL_FOLDER_SYSTEM;
if (last)
- last->sibling = fi;
+ last->next = fi;
else
first = fi;
last = fi;
@@ -539,7 +539,7 @@ nntp_store_get_cached_folder_info (CamelNNTPStore *store, const char *orig_top,
}
}
if (last)
- last->sibling = fi;
+ last->next = fi;
else
first = fi;
last = fi;