diff options
author | Dan Winship <danw@src.gnome.org> | 2000-09-20 01:27:09 +0800 |
---|---|---|
committer | Dan Winship <danw@src.gnome.org> | 2000-09-20 01:27:09 +0800 |
commit | 7dcc0325454ed6c71c2532befbb6aadb32391766 (patch) | |
tree | 744535557a2ab1e23278778ac464dcab718e03c1 /camel/providers/nntp | |
parent | 053af645da6e5f74474d13c19ce73d236d9b76a9 (diff) | |
download | gsoc2013-evolution-7dcc0325454ed6c71c2532befbb6aadb32391766.tar.gz gsoc2013-evolution-7dcc0325454ed6c71c2532befbb6aadb32391766.tar.zst gsoc2013-evolution-7dcc0325454ed6c71c2532befbb6aadb32391766.zip |
Removed (camel_folder_init, camel_folder_construct): New object init
* camel-folder.c: (init): Removed
(camel_folder_init, camel_folder_construct): New object init
function and public object constructor to replace the old init
method in a more Gtk-like fashion.
(get_parent_folder, camel_folder_get_parent_folder): Removed. No
CamelFolder subclass was ever setting the parent_folder member, no
code has ever needed to look at it, and fixing it would actually
be pretty hard.
(get_subfolder_info, camel_folder_get_subfolder_info): Renamed
from ..._names. Deals in CamelFolderInfo now.
(free_subfolder_info, camel_folder_free_subfolder_info): Likewise.
(get_subfolder, camel_folder_get_subfolder): Removed.
CamelFolderInfo contains the subfolder's full name, so this is
unnecessary now, and removing it lets us get rid of the
CamelFolder separator member, which is needed for the default
implementation of this function, but not otherwise needed for most
providers.
Also, lots of code style fixes.
* providers/*: Update CamelFolder subclasses for changes, although
none of them fill in the message counts in the CamelFolderInfo
yet.
svn path=/trunk/; revision=5503
Diffstat (limited to 'camel/providers/nntp')
-rw-r--r-- | camel/providers/nntp/camel-nntp-folder.c | 116 | ||||
-rw-r--r-- | camel/providers/nntp/camel-nntp-folder.h | 1 | ||||
-rw-r--r-- | camel/providers/nntp/camel-nntp-newsrc.c | 1 | ||||
-rw-r--r-- | camel/providers/nntp/camel-nntp-store.c | 7 | ||||
-rw-r--r-- | camel/providers/nntp/camel-nntp-utils.c | 8 |
5 files changed, 59 insertions, 74 deletions
diff --git a/camel/providers/nntp/camel-nntp-folder.c b/camel/providers/nntp/camel-nntp-folder.c index 6ab92923a2..2206064289 100644 --- a/camel/providers/nntp/camel-nntp-folder.c +++ b/camel/providers/nntp/camel-nntp-folder.c @@ -57,37 +57,6 @@ static CamelFolderClass *parent_class=NULL; #define CNNTPS_CLASS(so) CAMEL_STORE_CLASS (CAMEL_OBJECT_GET_CLASS(so)) -static void -nntp_folder_init (CamelFolder *folder, CamelStore *parent_store, - CamelFolder *parent_folder, const gchar *name, - gchar *separator, gboolean path_begins_with_sep, - CamelException *ex) -{ - CamelNNTPFolder *nntp_folder = CAMEL_NNTP_FOLDER (folder); - - /* call parent method */ - parent_class->init (folder, parent_store, parent_folder, - name, separator, path_begins_with_sep, - ex); - if (camel_exception_is_set (ex)) return; - - /* set flags */ - - if (!strcmp (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; - } - - /* XX */ - nntp_folder->group_name = g_strdup (strrchr (name, '/') + 1); -} - static void nntp_refresh_info (CamelFolder *folder, CamelException *ex) { @@ -101,7 +70,7 @@ nntp_refresh_info (CamelFolder *folder, CamelException *ex) nntp_folder->summary_file_path = g_strdup_printf ("%s/%s-ev-summary", root_dir_path, - nntp_folder->group_name); + folder->name); nntp_folder->summary = camel_folder_summary_new (); camel_folder_summary_set_filename (nntp_folder->summary, @@ -134,16 +103,6 @@ nntp_folder_sync (CamelFolder *folder, gboolean expunge, camel_nntp_newsrc_write (store->newsrc); } -static CamelFolder* -nntp_folder_get_subfolder (CamelFolder *folder, - const gchar *folder_name, - gboolean create, - CamelException *ex) -{ - g_assert (0); - return NULL; -} - static gint nntp_folder_get_message_count (CamelFolder *folder) { @@ -180,7 +139,7 @@ nntp_folder_set_message_flags (CamelFolder *folder, const char *uid, sscanf (uid, "%d", &article_num); camel_nntp_newsrc_mark_article_read (nntp_store->newsrc, - nntp_folder->group_name, + folder->name, article_num); } @@ -304,27 +263,34 @@ nntp_folder_get_summary (CamelFolder *folder) } static GPtrArray * -nntp_folder_get_subfolder_names (CamelFolder *folder) +nntp_folder_get_subfolder_info (CamelFolder *folder) { - if (!strcmp (folder->name, "/")) { - CamelStore *store = camel_folder_get_parent_store (folder); + CamelNNTPNewsrc *newsrc; + GPtrArray *names, *info; + CamelFolderInfo *fi; + int i; - if (CAMEL_NNTP_STORE (store)->newsrc) { - GPtrArray *array = camel_nntp_newsrc_get_subscribed_group_names (CAMEL_NNTP_STORE (store)->newsrc); - return array; - } - } - - return NULL; -} + /* Only top-level folder has subfolders. */ + if (*folder->name) + return NULL; -static void -nntp_folder_free_subfolder_names (CamelFolder *folder, GPtrArray *subfolders) -{ - if (subfolders) { - CamelStore *store = camel_folder_get_parent_store (folder); - camel_nntp_newsrc_free_group_names (CAMEL_NNTP_STORE (store)->newsrc, subfolders); + 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* @@ -360,10 +326,8 @@ camel_nntp_folder_class_init (CamelNNTPFolderClass *camel_nntp_folder_class) /* virtual method definition */ /* virtual method overload */ - camel_folder_class->init = nntp_folder_init; camel_folder_class->refresh_info = nntp_refresh_info; camel_folder_class->sync = nntp_folder_sync; - camel_folder_class->get_subfolder = nntp_folder_get_subfolder; camel_folder_class->get_message_count = nntp_folder_get_message_count; camel_folder_class->set_message_flags = nntp_folder_set_message_flags; camel_folder_class->get_message_flags = nntp_folder_get_message_flags; @@ -372,8 +336,8 @@ 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_names = nntp_folder_get_subfolder_names; - camel_folder_class->free_subfolder_names = nntp_folder_free_subfolder_names; + 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; } @@ -399,12 +363,26 @@ camel_nntp_folder_get_type (void) CamelFolder * camel_nntp_folder_new (CamelStore *parent, const char *folder_name, CamelException *ex) { - CamelFolder *new_folder = CAMEL_FOLDER (camel_object_new (CAMEL_NNTP_FOLDER_TYPE)); + CamelFolder *folder = CAMEL_FOLDER (camel_object_new (CAMEL_NNTP_FOLDER_TYPE)); - CF_CLASS (new_folder)->init (new_folder, parent, NULL, - folder_name, ".", FALSE, ex); + camel_folder_construct (folder, parent, folder_name, folder_name); - CF_CLASS (new_folder)->refresh_info (new_folder, ex); + /* 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; + } - return new_folder; + camel_folder_refresh_info (folder, ex); + if (camel_exception_is_set (ex)) { + camel_object_unref (CAMEL_OBJECT (folder)); + folder = NULL; + } + return folder; } diff --git a/camel/providers/nntp/camel-nntp-folder.h b/camel/providers/nntp/camel-nntp-folder.h index db1687c907..eed946fb5c 100644 --- a/camel/providers/nntp/camel-nntp-folder.h +++ b/camel/providers/nntp/camel-nntp-folder.h @@ -46,7 +46,6 @@ extern "C" { typedef struct { CamelFolder parent_object; - gchar *group_name; gchar *summary_file_path; /* contains the messages summary */ CamelFolderSummary *summary; } CamelNNTPFolder; diff --git a/camel/providers/nntp/camel-nntp-newsrc.c b/camel/providers/nntp/camel-nntp-newsrc.c index af40308219..a44e42c910 100644 --- a/camel/providers/nntp/camel-nntp-newsrc.c +++ b/camel/providers/nntp/camel-nntp-newsrc.c @@ -29,6 +29,7 @@ #include <fcntl.h> #include <unistd.h> #include "camel-nntp-newsrc.h" +#include <camel/camel-folder-summary.h> typedef struct { guint low; diff --git a/camel/providers/nntp/camel-nntp-store.c b/camel/providers/nntp/camel-nntp-store.c index bedcd3f13c..609520251b 100644 --- a/camel/providers/nntp/camel-nntp-store.c +++ b/camel/providers/nntp/camel-nntp-store.c @@ -296,6 +296,12 @@ nntp_store_get_folder (CamelStore *store, const gchar *folder_name, return camel_nntp_folder_new (store, folder_name, ex); } +static char * +nntp_store_get_root_folder_name (CamelStore *store, CamelException *ex) +{ + return g_strdup (""); +} + static void finalize (CamelObject *object) { @@ -325,6 +331,7 @@ camel_nntp_store_class_init (CamelNNTPStoreClass *camel_nntp_store_class) camel_service_class->get_name = nntp_store_get_name; camel_store_class->get_folder = nntp_store_get_folder; + camel_store_class->get_root_folder_name = nntp_store_get_root_folder_name; } diff --git a/camel/providers/nntp/camel-nntp-utils.c b/camel/providers/nntp/camel-nntp-utils.c index c741146f26..1a990fb94f 100644 --- a/camel/providers/nntp/camel-nntp-utils.c +++ b/camel/providers/nntp/camel-nntp-utils.c @@ -87,7 +87,7 @@ get_OVER_headers(CamelNNTPStore *nntp_store, CamelFolder *folder, new_info->subject = g_strdup(subject); new_info->from = g_strdup(from); - new_info->to = g_strdup(nntp_folder->group_name); + new_info->to = g_strdup(folder->name); new_info->date_sent = header_decode_date(date, NULL); #if 0 /* XXX do we need to fill in both dates? */ @@ -98,7 +98,7 @@ get_OVER_headers(CamelNNTPStore *nntp_store, CamelFolder *folder, new_info->message_id = g_strdup(message_id); if (camel_nntp_newsrc_article_is_read (nntp_store->newsrc, - nntp_folder->group_name, + folder->name, atoi (split_line[0]))) new_info->flags |= CAMEL_MESSAGE_SEEN; @@ -222,7 +222,7 @@ camel_nntp_get_headers (CamelStore *store, int status; status = camel_nntp_command (nntp_store, ex, &ret, - "GROUP %s", CAMEL_NNTP_FOLDER (folder)->group_name); + "GROUP %s", folder->name); sscanf (ret, "%d %d %d", &nb_message, &first_message, &last_message); g_free (ret); @@ -232,7 +232,7 @@ camel_nntp_get_headers (CamelStore *store, camel_exception_setv (ex, CAMEL_EXCEPTION_FOLDER_INVALID, "group %s not found on server", - CAMEL_NNTP_FOLDER (folder)->group_name); + folder->name); return; } |