aboutsummaryrefslogtreecommitdiffstats
path: root/camel/providers
diff options
context:
space:
mode:
Diffstat (limited to 'camel/providers')
-rw-r--r--camel/providers/imap/camel-imap-folder.c117
-rw-r--r--camel/providers/imap/camel-imap-folder.h2
-rw-r--r--camel/providers/imap/camel-imap-store.c194
-rw-r--r--camel/providers/imap/camel-imap-utils.c10
-rw-r--r--camel/providers/imap/camel-imap-utils.h4
-rw-r--r--camel/providers/mbox/camel-mbox-folder.c12
-rw-r--r--camel/providers/mbox/camel-mbox-store.c24
-rw-r--r--camel/providers/mh/camel-mh-folder.c12
-rw-r--r--camel/providers/mh/camel-mh-store.c17
-rw-r--r--camel/providers/nntp/camel-nntp-folder.c46
-rw-r--r--camel/providers/nntp/camel-nntp-store.c46
-rw-r--r--camel/providers/pop3/camel-pop3-folder.c2
-rw-r--r--camel/providers/vee/camel-vee-folder.c2
13 files changed, 252 insertions, 236 deletions
diff --git a/camel/providers/imap/camel-imap-folder.c b/camel/providers/imap/camel-imap-folder.c
index 63ef5b31d1..ab2d7f88b9 100644
--- a/camel/providers/imap/camel-imap-folder.c
+++ b/camel/providers/imap/camel-imap-folder.c
@@ -79,10 +79,6 @@ static void imap_copy_message_to (CamelFolder *source, const char *uid,
static void imap_move_message_to (CamelFolder *source, const char *uid,
CamelFolder *destination, CamelException *ex);
-/* subfolder listing */
-static GPtrArray *imap_get_subfolder_info_internal (CamelFolder *folder, CamelException *ex);
-static GPtrArray *imap_get_subfolder_info (CamelFolder *folder);
-
/* summary info */
static GPtrArray *imap_get_uids (CamelFolder *folder);
static GPtrArray *imap_get_summary_internal (CamelFolder *folder, CamelException *ex);
@@ -116,8 +112,6 @@ camel_imap_folder_class_init (CamelImapFolderClass *camel_imap_folder_class)
camel_folder_class->get_uids = imap_get_uids;
camel_folder_class->free_uids = camel_folder_free_nop;
- camel_folder_class->get_subfolder_info = imap_get_subfolder_info;
- camel_folder_class->free_subfolder_info = camel_folder_free_nop;
camel_folder_class->get_message_count = imap_get_message_count;
camel_folder_class->get_unread_message_count = imap_get_unread_message_count;
@@ -144,14 +138,11 @@ camel_imap_folder_init (gpointer object, gpointer klass)
CamelImapFolder *imap_folder = CAMEL_IMAP_FOLDER (object);
CamelFolder *folder = CAMEL_FOLDER (object);
- folder->can_hold_messages = TRUE;
- folder->can_hold_folders = TRUE;
folder->has_summary_capability = TRUE;
folder->has_search_capability = TRUE;
imap_folder->summary = NULL;
imap_folder->summary_hash = NULL;
- imap_folder->lsub = NULL;
/* some IMAP daemons support user-flags *
* I would not, however, rely on this feature as *
@@ -197,9 +188,6 @@ camel_imap_folder_new (CamelStore *parent, const char *folder_name)
short_name = folder_name;
camel_folder_construct (folder, parent, folder_name, short_name);
- if (!*folder_name)
- folder->can_hold_messages = FALSE;
-
return folder;
}
@@ -211,7 +199,7 @@ imap_summary_free (GPtrArray **summary)
if (array) {
for (i = 0; i < array->len; i++)
- camel_folder_info_free (array->pdata[i]);
+ camel_message_info_free (array->pdata[i]);
g_ptr_array_free (array, TRUE);
*summary = NULL;
@@ -233,25 +221,14 @@ static void
imap_finalize (CamelObject *object)
{
CamelImapFolder *imap_folder = CAMEL_IMAP_FOLDER (object);
- gint i;
-
+
imap_folder_summary_free (imap_folder);
-
- if (imap_folder->lsub) {
- for (i = 0; i < imap_folder->lsub->len; i++)
- camel_folder_info_free (imap_folder->lsub->pdata[i]);
-
- g_ptr_array_free (imap_folder->lsub, TRUE);
- }
}
static void
imap_refresh_info (CamelFolder *folder, CamelException *ex)
{
- imap_get_subfolder_info_internal (folder, ex);
-
- if (folder->can_hold_messages)
- imap_get_summary_internal (folder, ex);
+ imap_get_summary_internal (folder, ex);
}
static void
@@ -308,8 +285,6 @@ imap_get_message_count_internal (CamelFolder *folder, CamelException *ex)
GPtrArray *response;
gint status, count = 0;
- g_return_val_if_fail (folder->can_hold_messages, 0);
-
folder_path = camel_imap_store_folder_path (store, folder->full_name);
if (store->has_status_capability)
@@ -501,92 +476,6 @@ imap_get_uids (CamelFolder *folder)
return array;
}
-static GPtrArray *
-imap_get_subfolder_info_internal (CamelFolder *folder, CamelException *ex)
-{
- CamelImapFolder *imap_folder = CAMEL_IMAP_FOLDER (folder);
- CamelImapStore *store = CAMEL_IMAP_STORE (folder->parent_store);
- GPtrArray *response, *listing;
- gboolean found_inbox = FALSE;
- gint status, i;
- gchar *namespace;
- CamelFolderInfo *fi;
-
- g_return_val_if_fail (folder != NULL, g_ptr_array_new ());
-
- namespace = camel_imap_store_folder_path (store, folder->full_name);
- status = camel_imap_command_extended (store, NULL, &response, ex,
- "LIST \"\" \"%s%s*\"", namespace,
- *namespace ? store->dir_sep : "");
-
- if (status != CAMEL_IMAP_OK) {
- g_free (namespace);
-
- imap_folder->lsub = g_ptr_array_new ();
- return imap_folder->lsub;
- }
-
- /* parse out the subfolders */
- listing = g_ptr_array_new ();
- if (response) {
- for (i = 0; i < response->len; i++) {
- gchar *resp, *flags, *sep, *dir;
-
- resp = response->pdata[i];
- if (!imap_parse_list_response (resp, namespace, &flags, &sep, &dir)) {
- g_free (flags);
- g_free (sep);
- g_free (dir);
- continue;
- }
-
- g_free (flags);
-
- if (*dir) {
- d(fprintf (stderr, "adding folder: %s\n", dir));
- fi = g_new0 (CamelFolderInfo, 1);
- fi->full_name = dir;
- fi->name = strrchr (dir, *sep);
- if (fi->name)
- fi->name = g_strdup (fi->name + 1);
- else
- fi->name = g_strdup (dir);
- /* FIXME: read/unread msg count */
-
- if (!g_strcasecmp (dir, "INBOX"))
- found_inbox = TRUE;
- g_ptr_array_add (listing, fi);
- }
-
- g_free (sep);
- }
- camel_imap_response_free (response);
- }
-
- if (!*folder->name && !found_inbox) {
- fi = g_new0 (CamelFolderInfo, 1);
- fi->full_name = g_strdup ("INBOX");
- fi->name = g_strdup ("INBOX");
- /* FIXME: read/unread msg count */
-
- g_ptr_array_add (listing, fi);
- }
-
- g_free (namespace);
-
- imap_folder->lsub = listing;
-
- return listing;
-}
-
-static GPtrArray *
-imap_get_subfolder_info (CamelFolder *folder)
-{
- CamelImapFolder *imap_folder = CAMEL_IMAP_FOLDER (folder);
-
- return imap_folder->lsub;
-}
-
static CamelMimeMessage *
imap_get_message (CamelFolder *folder, const gchar *uid, CamelException *ex)
{
diff --git a/camel/providers/imap/camel-imap-folder.h b/camel/providers/imap/camel-imap-folder.h
index d4d960b2a8..41170ce698 100644
--- a/camel/providers/imap/camel-imap-folder.h
+++ b/camel/providers/imap/camel-imap-folder.h
@@ -48,8 +48,6 @@ typedef struct {
GPtrArray *summary;
GHashTable *summary_hash;
-
- GPtrArray *lsub;
} CamelImapFolder;
diff --git a/camel/providers/imap/camel-imap-store.c b/camel/providers/imap/camel-imap-store.c
index d5fc59b33e..eab33b308f 100644
--- a/camel/providers/imap/camel-imap-store.c
+++ b/camel/providers/imap/camel-imap-store.c
@@ -60,6 +60,9 @@ static CamelFolder *get_folder (CamelStore *store, const char *folder_name, gboo
static char *get_folder_name (CamelStore *store, const char *folder_name,
CamelException *ex);
static char *get_root_folder_name (CamelStore *store, CamelException *ex);
+static CamelFolderInfo *get_folder_info (CamelStore *store, const char *top,
+ gboolean fast, gboolean recursive,
+ CamelException *ex);
static void imap_keepalive (CamelRemoteStore *store);
/*static gboolean stream_is_alive (CamelStream *istream);*/
static int camel_imap_status (char *cmdid, char *respbuf);
@@ -87,6 +90,8 @@ camel_imap_store_class_init (CamelImapStoreClass *camel_imap_store_class)
camel_store_class->get_folder = get_folder;
camel_store_class->get_folder_name = get_folder_name;
camel_store_class->get_root_folder_name = get_root_folder_name;
+ camel_store_class->get_folder_info = get_folder_info;
+ camel_store_class->free_folder_info = camel_store_free_folder_info_full;
camel_remote_store_class->keepalive = imap_keepalive;
}
@@ -393,33 +398,35 @@ get_folder (CamelStore *store, const char *folder_name, gboolean create, CamelEx
CamelImapStore *imap_store = CAMEL_IMAP_STORE (store);
CamelFolder *new_folder;
char *folder_path;
- gboolean exists = FALSE;
gboolean selectable;
- new_folder = camel_imap_folder_new (store, folder_name);
-
- /* this is the top-level dir, we already know it exists - it has to! */
- if (!*folder_name) {
- camel_folder_refresh_info (new_folder, ex);
- return new_folder;
- }
-
folder_path = camel_imap_store_folder_path (imap_store, folder_name);
- if (imap_folder_exists (imap_store, folder_path, &selectable, ex)) {
- exists = TRUE;
- if (!selectable)
- new_folder->can_hold_messages = FALSE;
- }
+ if (!imap_folder_exists (imap_store, folder_path, &selectable, ex)) {
+ if (!create) {
+ g_free (folder_path);
+ return NULL;
+ }
- if (!exists && create && !imap_create (imap_store, folder_path, ex)) {
+ if (!imap_create (imap_store, folder_path, ex)) {
+ g_free (folder_path);
+ return NULL;
+ }
+ } else if (!selectable) {
+ camel_exception_setv (ex, CAMEL_EXCEPTION_STORE_NO_FOLDER,
+ "%s is not a selectable folder",
+ folder_name);
g_free (folder_path);
- camel_object_unref (CAMEL_OBJECT (new_folder));
return NULL;
}
+ g_free (folder_path);
- /* this is where we *should refresh_info, not in imap_folder_new() */
+ new_folder = camel_imap_folder_new (store, folder_name);
camel_folder_refresh_info (new_folder, ex);
-
+ if (camel_exception_is_set (ex)) {
+ camel_object_unref (CAMEL_OBJECT (new_folder));
+ return NULL;
+ }
+
return new_folder;
}
@@ -440,32 +447,145 @@ get_root_folder_name (CamelStore *store, CamelException *ex)
return g_strdup ("");
}
-static void
-imap_keepalive (CamelRemoteStore *store)
+static CamelFolderInfo *
+parse_list_response_as_folder_info (const char *response,
+ const char *namespace,
+ const char *base_url)
+{
+ CamelFolderInfo *fi;
+ char *flags, *sep, *dir;
+
+ if (!imap_parse_list_response (response, namespace,
+ &flags, &sep, &dir))
+ return NULL;
+
+ fi = g_new0 (CamelFolderInfo, 1);
+ fi->full_name = dir;
+ fi->name = strrchr (dir, *sep);
+ if (fi->name)
+ fi->name = g_strdup (fi->name + 1);
+ else
+ fi->name = g_strdup (dir);
+ g_free (sep);
+ if (!e_strstrcase (flags, "\\NoSelect"))
+ fi->url = g_strdup_printf ("%s%s", base_url, dir);
+ g_free (flags);
+ /* FIXME: read/unread msg count */
+
+ return fi;
+}
+
+static CamelFolderInfo *
+get_folder_info (CamelStore *store, const char *top, gboolean fast,
+ gboolean recursive, CamelException *ex)
{
CamelImapStore *imap_store = CAMEL_IMAP_STORE (store);
-
- camel_imap_command_extended (imap_store, NULL, NULL, NULL, "NOOP");
+ CamelURL *url = CAMEL_SERVICE (store)->url;
+ gboolean found_inbox = FALSE;
+ int status, len, i;
+ GPtrArray *response;
+ char *dir_sep, *namespace, *base_url, *list;
+ CamelFolderInfo *topfi, *fi;
+
+ if (!top)
+ top = "";
+ dir_sep = imap_store->dir_sep;
+ namespace = camel_imap_store_folder_path (imap_store, top);
+
+ /* Yah! I am complicated! */
+ base_url = camel_url_to_string (url, FALSE);
+ len = strlen (base_url);
+ if (url->path && base_url[len - 1] != *dir_sep) {
+ base_url = g_realloc (base_url, len + 2);
+ base_url[len] = *dir_sep;
+ base_url[len + 1] = '\0';
+ } else if (!url->path) {
+ base_url = g_realloc (base_url, len + 2);
+ base_url[len] = '/';
+ base_url[len + 1] = '\0';
+ }
+
+ status = camel_imap_command_extended (imap_store, NULL, &response, ex,
+ "LIST \"\" \"%s\"", namespace);
+ if (status != CAMEL_IMAP_OK) {
+ g_free (namespace);
+ g_free (base_url);
+ return NULL;
+ }
+ list = camel_imap_response_extract (response, "LIST", ex);
+ if (!list) {
+ g_free (namespace);
+ g_free (base_url);
+ return NULL;
+ }
+ topfi = parse_list_response_as_folder_info (list, namespace, base_url);
+ g_free (list);
+
+ status = camel_imap_command_extended (imap_store, NULL, &response, ex,
+ "LIST \"\" \"%s%s%c\"",
+ namespace,
+ *namespace ? dir_sep : "",
+ recursive ? '*' : '%');
+ if (status != CAMEL_IMAP_OK) {
+ g_free (namespace);
+ g_free (base_url);
+ return NULL;
+ }
+
+ /* Turn responses into CamelFolderInfo and remove any
+ * extraneous responses.
+ */
+ for (i = 0; i < response->len; i++) {
+ list = response->pdata[i];
+ response->pdata[i] = fi =
+ parse_list_response_as_folder_info (list, namespace,
+ base_url);
+ g_free (list);
+
+ if (!response->pdata[i]) {
+ g_ptr_array_remove_index_fast (response, i--);
+ continue;
+ }
+
+ if (!g_strcasecmp (fi->full_name, "INBOX"))
+ found_inbox = TRUE;
+ }
+
+ /* Add INBOX, if necessary */
+ if (!*top && !found_inbox) {
+ fi = g_new0 (CamelFolderInfo, 1);
+ fi->full_name = g_strdup ("INBOX");
+ fi->name = g_strdup ("INBOX");
+ fi->url = g_strdup_printf ("%sINBOX", base_url);
+ /* FIXME: read/unread msg count */
+
+ g_ptr_array_add (response, fi);
+ }
+
+ /* And assemble */
+ camel_folder_info_build (response, topfi, *dir_sep, TRUE);
+ g_ptr_array_free (response, FALSE);
+
+ /* Remove the top if it's the root of the store. */
+ if (!*top && !topfi->sibling) {
+ fi = topfi;
+ topfi = topfi->child;
+ fi->child = NULL;
+ camel_folder_info_free (fi);
+ }
+
+ g_free (namespace);
+ g_free (base_url);
+ return topfi;
}
-#if 0
-static gboolean
-stream_is_alive (CamelStream *istream)
+static void
+imap_keepalive (CamelRemoteStore *store)
{
- CamelStreamFs *fs_stream;
- char buf;
-
- g_return_val_if_fail (istream != NULL, FALSE);
-
- fs_stream = CAMEL_STREAM_FS (CAMEL_STREAM_BUFFER (istream)->stream);
- g_return_val_if_fail (fs_stream->fd != -1, FALSE);
-
- if (read (fs_stream->fd, (void *) &buf, 0) == 0)
- return TRUE;
+ CamelImapStore *imap_store = CAMEL_IMAP_STORE (store);
- return FALSE;
+ camel_imap_command_extended (imap_store, NULL, NULL, NULL, "NOOP");
}
-#endif
static int
camel_imap_status (char *cmdid, char *respbuf)
diff --git a/camel/providers/imap/camel-imap-utils.c b/camel/providers/imap/camel-imap-utils.c
index bb110f1f90..4658341e6a 100644
--- a/camel/providers/imap/camel-imap-utils.c
+++ b/camel/providers/imap/camel-imap-utils.c
@@ -33,12 +33,12 @@
#define d(x) x
char *
-imap_next_word (char *buf)
+imap_next_word (const char *buf)
{
char *word;
/* skip over current word */
- for (word = buf; *word && *word != ' '; word++);
+ for (word = (char *)buf; *word && *word != ' '; word++);
/* skip over white space */
for ( ; *word && *word == ' '; word++);
@@ -47,7 +47,7 @@ imap_next_word (char *buf)
}
gboolean
-imap_parse_list_response (char *buf, char *namespace, char **flags, char **sep, char **folder)
+imap_parse_list_response (const char *buf, const char *namespace, char **flags, char **sep, char **folder)
{
char *word, *ep, *f;
@@ -96,7 +96,9 @@ imap_parse_list_response (char *buf, char *namespace, char **flags, char **sep,
/* chop out the folder prefix */
if (*namespace && !strncmp (*folder, namespace, strlen (namespace))) {
- f = *folder + strlen (namespace) + strlen (*sep);
+ f = *folder + strlen (namespace);
+ if (!strncmp (f, *sep, strlen (*sep)))
+ f += strlen (*sep);
memmove (*folder, f, strlen (f) + 1);
}
diff --git a/camel/providers/imap/camel-imap-utils.h b/camel/providers/imap/camel-imap-utils.h
index 6f450fc8e8..b08c179926 100644
--- a/camel/providers/imap/camel-imap-utils.h
+++ b/camel/providers/imap/camel-imap-utils.h
@@ -30,9 +30,9 @@ extern "C" {
#include <glib.h>
-char *imap_next_word (char *buf);
+char *imap_next_word (const char *buf);
-gboolean imap_parse_list_response (char *buf, char *namespace, char **flags, char **sep, char **folder);
+gboolean imap_parse_list_response (const char *buf, const char *namespace, char **flags, char **sep, char **folder);
char *imap_translate_sexp (const char *expression);
diff --git a/camel/providers/mbox/camel-mbox-folder.c b/camel/providers/mbox/camel-mbox-folder.c
index 7aaf9d8593..163de6784f 100644
--- a/camel/providers/mbox/camel-mbox-folder.c
+++ b/camel/providers/mbox/camel-mbox-folder.c
@@ -64,7 +64,6 @@ static void mbox_append_message(CamelFolder *folder, CamelMimeMessage * message,
CamelException *ex);
static GPtrArray *mbox_get_uids(CamelFolder *folder);
-static GPtrArray *mbox_get_subfolder_info(CamelFolder *folder);
static GPtrArray *mbox_get_summary(CamelFolder *folder);
static CamelMimeMessage *mbox_get_message(CamelFolder *folder, const gchar * uid, CamelException *ex);
@@ -102,8 +101,6 @@ camel_mbox_folder_class_init(CamelMboxFolderClass * camel_mbox_folder_class)
camel_folder_class->append_message = mbox_append_message;
camel_folder_class->get_uids = mbox_get_uids;
camel_folder_class->free_uids = camel_folder_free_deep;
- camel_folder_class->get_subfolder_info = mbox_get_subfolder_info;
- camel_folder_class->free_subfolder_info = camel_folder_free_shallow;
camel_folder_class->get_summary = mbox_get_summary;
camel_folder_class->free_summary = camel_folder_free_nop;
camel_folder_class->expunge = mbox_expunge;
@@ -129,8 +126,6 @@ mbox_init(gpointer object, gpointer klass)
CamelFolder *folder = object;
CamelMboxFolder *mbox_folder = object;
- folder->can_hold_messages = TRUE;
- folder->can_hold_folders = TRUE;
folder->has_summary_capability = TRUE;
folder->has_search_capability = TRUE;
@@ -438,13 +433,6 @@ mbox_get_uids(CamelFolder *folder)
return array;
}
-static GPtrArray *
-mbox_get_subfolder_info(CamelFolder *folder)
-{
- /* No subfolders. */
- return g_ptr_array_new();
-}
-
static CamelMimeMessage *
mbox_get_message(CamelFolder *folder, const gchar * uid, CamelException *ex)
{
diff --git a/camel/providers/mbox/camel-mbox-store.c b/camel/providers/mbox/camel-mbox-store.c
index 0a6c7c2ce1..8bf77c9774 100644
--- a/camel/providers/mbox/camel-mbox-store.c
+++ b/camel/providers/mbox/camel-mbox-store.c
@@ -47,6 +47,9 @@ static void delete_folder (CamelStore *store, const char *folder_name,
static void rename_folder(CamelStore *store, const char *old_name, const char *new_name, CamelException *ex);
static char *get_folder_name (CamelStore *store, const char *folder_name,
CamelException *ex);
+static CamelFolderInfo *get_folder_info (CamelStore *store, const char *top,
+ gboolean fast, gboolean recursive,
+ CamelException *ex);
static void
camel_mbox_store_class_init (CamelMboxStoreClass *camel_mbox_store_class)
@@ -61,6 +64,8 @@ camel_mbox_store_class_init (CamelMboxStoreClass *camel_mbox_store_class)
camel_store_class->delete_folder = delete_folder;
camel_store_class->rename_folder = rename_folder;
camel_store_class->get_folder_name = get_folder_name;
+ camel_store_class->get_folder_info = get_folder_info;
+ camel_store_class->free_folder_info = camel_store_free_folder_info_full;
}
static void
@@ -117,8 +122,8 @@ get_folder (CamelStore *store, const char *folder_name, gboolean create,
if (errno != ENOENT) {
camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM,
- "Could not open folder `%s':"
- "\n%s", folder_name,
+ "Could not open file `%s':"
+ "\n%s", name,
g_strerror (errno));
g_free (name);
return NULL;
@@ -135,8 +140,8 @@ get_folder (CamelStore *store, const char *folder_name, gboolean create,
g_free (name);
if (fd == -1) {
camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM,
- "Could not create folder `%s':"
- "\n%s", folder_name,
+ "Could not create file `%s':"
+ "\n%s", name,
g_strerror (errno));
return NULL;
}
@@ -277,3 +282,14 @@ get_name (CamelService *service, gboolean brief)
else
return g_strdup_printf ("Local mail file %s", service->url->path);
}
+
+static CamelFolderInfo *
+get_folder_info (CamelStore *store, const char *top,
+ gboolean fast, gboolean recursive,
+ CamelException *ex)
+{
+ /* FIXME: This is broken, but it corresponds to what was
+ * there before.
+ */
+ return NULL;
+}
diff --git a/camel/providers/mh/camel-mh-folder.c b/camel/providers/mh/camel-mh-folder.c
index ec434bbcf0..c8b0503e95 100644
--- a/camel/providers/mh/camel-mh-folder.c
+++ b/camel/providers/mh/camel-mh-folder.c
@@ -58,7 +58,6 @@ static gint mh_get_message_count(CamelFolder * folder);
static gint mh_get_unread_message_count(CamelFolder * folder);
static void mh_append_message(CamelFolder * folder, CamelMimeMessage * message, const CamelMessageInfo *info, CamelException * ex);
static GPtrArray *mh_get_uids(CamelFolder * folder);
-static GPtrArray *mh_get_subfolder_info(CamelFolder * folder);
static GPtrArray *mh_get_summary(CamelFolder * folder);
static CamelMimeMessage *mh_get_message(CamelFolder * folder, const gchar * uid, CamelException * ex);
@@ -93,8 +92,6 @@ static void camel_mh_folder_class_init(CamelObjectClass * camel_mh_folder_class)
camel_folder_class->append_message = mh_append_message;
camel_folder_class->get_uids = mh_get_uids;
camel_folder_class->free_uids = camel_folder_free_deep;
- camel_folder_class->get_subfolder_info = mh_get_subfolder_info;
- camel_folder_class->free_subfolder_info = camel_folder_free_deep;
camel_folder_class->get_summary = mh_get_summary;
camel_folder_class->free_summary = camel_folder_free_nop;
camel_folder_class->expunge = mh_expunge;
@@ -119,8 +116,6 @@ static void mh_init(gpointer object, gpointer klass)
CamelFolder *folder = object;
CamelMhFolder *mh_folder = object;
- folder->can_hold_messages = TRUE;
- folder->can_hold_folders = TRUE;
folder->has_summary_capability = TRUE;
folder->has_search_capability = TRUE;
@@ -356,13 +351,6 @@ static GPtrArray *mh_get_uids(CamelFolder * folder)
return array;
}
-static GPtrArray *mh_get_subfolder_info(CamelFolder * folder)
-{
- /* FIXME: scan for sub-folders */
- /* No subfolders. */
- return g_ptr_array_new();
-}
-
static CamelMimeMessage *mh_get_message(CamelFolder * folder, const gchar * uid, CamelException * ex)
{
CamelMhFolder *mh_folder = CAMEL_MH_FOLDER(folder);
diff --git a/camel/providers/mh/camel-mh-store.c b/camel/providers/mh/camel-mh-store.c
index e45a5b72e2..32b01eefa1 100644
--- a/camel/providers/mh/camel-mh-store.c
+++ b/camel/providers/mh/camel-mh-store.c
@@ -45,6 +45,9 @@ static CamelFolder *get_folder(CamelStore * store, const char *folder_name, gboo
static void delete_folder(CamelStore * store, const char *folder_name, CamelException * ex);
static void rename_folder(CamelStore *store, const char *old_name, const char *new_name, CamelException *ex);
static char *get_folder_name(CamelStore * store, const char *folder_name, CamelException * ex);
+static CamelFolderInfo *get_folder_info (CamelStore *store, const char *top,
+ gboolean fast, gboolean recursive,
+ CamelException *ex);
static void camel_mh_store_class_init(CamelObjectClass * camel_mh_store_class)
{
@@ -58,6 +61,8 @@ static void camel_mh_store_class_init(CamelObjectClass * camel_mh_store_class)
camel_store_class->delete_folder = delete_folder;
camel_store_class->rename_folder = rename_folder;
camel_store_class->get_folder_name = get_folder_name;
+ camel_store_class->get_folder_info = get_folder_info;
+ camel_store_class->free_folder_info = camel_store_free_folder_info_full;
}
static void camel_mh_store_init(CamelObject * object)
@@ -207,3 +212,15 @@ static char *get_name(CamelService * service, gboolean brief)
else
return g_strdup_printf("Local mail file %s", service->url->path);
}
+
+
+static CamelFolderInfo *
+get_folder_info (CamelStore *store, const char *top,
+ gboolean fast, gboolean recursive,
+ CamelException *ex)
+{
+ /* FIXME: This is broken, but it corresponds to what was
+ * there before.
+ */
+ return NULL;
+}
diff --git a/camel/providers/nntp/camel-nntp-folder.c b/camel/providers/nntp/camel-nntp-folder.c
index 2206064289..e04571ef36 100644
--- a/camel/providers/nntp/camel-nntp-folder.c
+++ b/camel/providers/nntp/camel-nntp-folder.c
@@ -262,37 +262,6 @@ nntp_folder_get_summary (CamelFolder *folder)
return nntp_folder->summary->messages;
}
-static GPtrArray *
-nntp_folder_get_subfolder_info (CamelFolder *folder)
-{
- CamelNNTPNewsrc *newsrc;
- GPtrArray *names, *info;
- CamelFolderInfo *fi;
- int i;
-
- /* Only top-level folder has subfolders. */
- if (*folder->name)
- return NULL;
-
- newsrc = CAMEL_NNTP_STORE (camel_folder_get_parent_store (folder))->newsrc;
- if (!newsrc)
- return NULL;
-
- info = g_ptr_array_new ();
- names = camel_nntp_newsrc_get_subscribed_group_names (newsrc);
- for (i = 0; i < names->len; i++) {
- fi = g_new (CamelFolderInfo, 1);
- fi->name = fi->full_name = names->pdata[i];
- /* FIXME */
- fi->message_count = 0;
- fi->unread_message_count = 0;
- g_ptr_array_add (info, fi);
- }
- camel_nntp_newsrc_free_group_names (newsrc, names);
-
- return info;
-}
-
static GPtrArray*
nntp_folder_search_by_expression (CamelFolder *folder, const char *expression, CamelException *ex)
{
@@ -336,8 +305,6 @@ camel_nntp_folder_class_init (CamelNNTPFolderClass *camel_nntp_folder_class)
camel_folder_class->free_uids = camel_folder_free_deep;
camel_folder_class->get_summary = nntp_folder_get_summary;
camel_folder_class->free_summary = camel_folder_free_nop;
- camel_folder_class->get_subfolder_info = nntp_folder_get_subfolder_info;
- camel_folder_class->free_subfolder_info = camel_folder_free_deep;
camel_folder_class->search_by_expression = nntp_folder_search_by_expression;
camel_folder_class->get_message_info = nntp_folder_get_message_info;
}
@@ -366,18 +333,7 @@ camel_nntp_folder_new (CamelStore *parent, const char *folder_name, CamelExcepti
CamelFolder *folder = CAMEL_FOLDER (camel_object_new (CAMEL_NNTP_FOLDER_TYPE));
camel_folder_construct (folder, parent, folder_name, folder_name);
-
- /* set flags */
- if (!*folder->name) {
- /* the root folder is the only folder that has "subfolders" */
- folder->can_hold_folders = TRUE;
- folder->can_hold_messages = FALSE;
- }
- else {
- folder->can_hold_folders = FALSE;
- folder->can_hold_messages = TRUE;
- folder->has_summary_capability = TRUE;
- }
+ folder->has_summary_capability = TRUE;
camel_folder_refresh_info (folder, ex);
if (camel_exception_is_set (ex)) {
diff --git a/camel/providers/nntp/camel-nntp-store.c b/camel/providers/nntp/camel-nntp-store.c
index 609520251b..1e6ccd53c1 100644
--- a/camel/providers/nntp/camel-nntp-store.c
+++ b/camel/providers/nntp/camel-nntp-store.c
@@ -296,6 +296,50 @@ nntp_store_get_folder (CamelStore *store, const gchar *folder_name,
return camel_nntp_folder_new (store, folder_name, ex);
}
+static CamelFolderInfo *
+nntp_store_get_folder_info (CamelStore *store, const char *top,
+ gboolean fast, gboolean recursive,
+ CamelException *ex)
+{
+ CamelNNTPStore *nntp_store = (CamelNNTPStore *)store;
+ GPtrArray *names;
+ CamelFolderInfo *topfi, *last = NULL, *fi;
+ int i;
+
+ if (!nntp_store->newsrc)
+ return NULL;
+
+ topfi = g_new0 (CamelFolderInfo, 1);
+ topfi->name = g_strdup (top);
+ topfi->full_name = g_strdup (top);
+ if (*top)
+ topfi->url = g_strdup_printf ("news:%s", top);
+ /* FIXME: message_count if top != "" */
+ topfi->message_count = topfi->unread_message_count = -1;
+
+ if (!recursive || *top)
+ return topfi;
+
+ names = camel_nntp_newsrc_get_subscribed_group_names (nntp_store->newsrc);
+ for (i = 0; i < names->len; i++) {
+ fi = g_new0 (CamelFolderInfo, 1);
+ fi->name = g_strdup (names->pdata[i]);
+ fi->full_name = g_strdup (names->pdata[i]);
+ fi->url = g_strdup_printf ("news:%s", (char *)names->pdata[i]);
+ /* FIXME */
+ fi->message_count = fi->unread_message_count = -1;
+
+ if (last)
+ last->sibling = fi;
+ else
+ topfi->child = fi;
+ last = fi;
+ }
+ camel_nntp_newsrc_free_group_names (nntp_store->newsrc, names);
+
+ return topfi;
+}
+
static char *
nntp_store_get_root_folder_name (CamelStore *store, CamelException *ex)
{
@@ -332,6 +376,8 @@ camel_nntp_store_class_init (CamelNNTPStoreClass *camel_nntp_store_class)
camel_store_class->get_folder = nntp_store_get_folder;
camel_store_class->get_root_folder_name = nntp_store_get_root_folder_name;
+ camel_store_class->get_folder_info = nntp_store_get_folder_info;
+ camel_store_class->free_folder_info = camel_store_free_folder_info_full;
}
diff --git a/camel/providers/pop3/camel-pop3-folder.c b/camel/providers/pop3/camel-pop3-folder.c
index d367cac1ab..7b66c87f26 100644
--- a/camel/providers/pop3/camel-pop3-folder.c
+++ b/camel/providers/pop3/camel-pop3-folder.c
@@ -78,8 +78,6 @@ camel_pop3_folder_init (gpointer object)
CamelFolder *folder = CAMEL_FOLDER (object);
CamelPop3Folder *pop3_folder = CAMEL_POP3_FOLDER (object);
- folder->can_hold_messages = TRUE;
- folder->can_hold_folders = FALSE;
folder->has_summary_capability = FALSE;
folder->has_search_capability = FALSE;
diff --git a/camel/providers/vee/camel-vee-folder.c b/camel/providers/vee/camel-vee-folder.c
index 0be1f152d1..da47761754 100644
--- a/camel/providers/vee/camel-vee-folder.c
+++ b/camel/providers/vee/camel-vee-folder.c
@@ -119,8 +119,6 @@ camel_vee_folder_init (CamelVeeFolder *obj)
p = _PRIVATE(obj) = g_malloc0(sizeof(*p));
- folder->can_hold_messages = TRUE;
- folder->can_hold_folders = FALSE;
folder->has_summary_capability = TRUE;
folder->has_search_capability = TRUE;