aboutsummaryrefslogtreecommitdiffstats
path: root/camel/providers/nntp
diff options
context:
space:
mode:
authorDan Winship <danw@src.gnome.org>2000-10-03 03:08:20 +0800
committerDan Winship <danw@src.gnome.org>2000-10-03 03:08:20 +0800
commite9dc30dbf0c018bbc845f253bfe0b26baddbeaf2 (patch)
treee70ca64851c0167f959a9e6c0c38179cd0de102b /camel/providers/nntp
parent46d07e9e465e336a5c39d8c27c846cb380fbc6fb (diff)
downloadgsoc2013-evolution-e9dc30dbf0c018bbc845f253bfe0b26baddbeaf2.tar
gsoc2013-evolution-e9dc30dbf0c018bbc845f253bfe0b26baddbeaf2.tar.gz
gsoc2013-evolution-e9dc30dbf0c018bbc845f253bfe0b26baddbeaf2.tar.bz2
gsoc2013-evolution-e9dc30dbf0c018bbc845f253bfe0b26baddbeaf2.tar.lz
gsoc2013-evolution-e9dc30dbf0c018bbc845f253bfe0b26baddbeaf2.tar.xz
gsoc2013-evolution-e9dc30dbf0c018bbc845f253bfe0b26baddbeaf2.tar.zst
gsoc2013-evolution-e9dc30dbf0c018bbc845f253bfe0b26baddbeaf2.zip
Remove camel_folder_{get,free}_subfolder_info, as we want to be able to
* camel-folder.[ch]: Remove camel_folder_{get,free}_subfolder_info, as we want to be able to scan the whole subfolder tree without having to open any folders, so this needs to be in CamelStore. Remove can_hold_folders and can_hold_messages flags; things that don't hold messages are no longer considered CamelFolders. * camel-folder-summary.[ch]: Remove CamelFolderInfo stuff. * camel-store.[ch]: Add camel_store_{get,free}_folder_info, as well as camel_store_free_folder_info_full and ..._nop for default implementations, and camel_folder_info_free and camel_folder_info_build as convenience functions. Turn CamelFolderInfo into a tree structure and also add an "url" member. * providers/*/camel-*-folder.c: Remove subfolder_info and can_hold stuff. * providers/*/camel-*-store.c: Add folder_info stuff. * providers/imap/camel-imap-folder.c (imap_summary_free): Free the summary elements with camel_message_info_free, not camel_folder_info_free. Oops. * providers/imap/camel-imap-utils.c: const poison svn path=/trunk/; revision=5663
Diffstat (limited to 'camel/providers/nntp')
-rw-r--r--camel/providers/nntp/camel-nntp-folder.c46
-rw-r--r--camel/providers/nntp/camel-nntp-store.c46
2 files changed, 47 insertions, 45 deletions
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;
}