diff options
author | Chris Toshok <toshok@helixcode.com> | 2000-10-11 12:37:33 +0800 |
---|---|---|
committer | Chris Toshok <toshok@src.gnome.org> | 2000-10-11 12:37:33 +0800 |
commit | 4f8ffe430fdfe646741aaaf569929b286fc1be2f (patch) | |
tree | 65e8406cd00ce8eaaa08aa207e33a35a68aa4a89 | |
parent | 139f2405f0a36396f7e3e171ad03a18e8d78ea69 (diff) | |
download | gsoc2013-evolution-4f8ffe430fdfe646741aaaf569929b286fc1be2f.tar.gz gsoc2013-evolution-4f8ffe430fdfe646741aaaf569929b286fc1be2f.tar.zst gsoc2013-evolution-4f8ffe430fdfe646741aaaf569929b286fc1be2f.zip |
fill in message_count and unread_message_count properly.
2000-10-10 Chris Toshok <toshok@helixcode.com>
* providers/nntp/camel-nntp-store.c
(build_folder_info_from_grouplist): fill in message_count and
unread_message_count properly.
* providers/nntp/camel-nntp-newsrc.h: reformat.
* providers/nntp/camel-nntp-grouplist.c
(camel_nntp_get_grouplist_from_file): remove spew.
* providers/nntp/camel-nntp-newsrc.c
(camel_nntp_newsrc_group_get_num_articles_read): new function.
(camel_nntp_newsrc_group_get_highest_article_read): robustification.
svn path=/trunk/; revision=5832
-rw-r--r-- | camel/ChangeLog | 15 | ||||
-rw-r--r-- | camel/providers/nntp/camel-nntp-grouplist.c | 6 | ||||
-rw-r--r-- | camel/providers/nntp/camel-nntp-newsrc.c | 31 | ||||
-rw-r--r-- | camel/providers/nntp/camel-nntp-newsrc.h | 41 | ||||
-rw-r--r-- | camel/providers/nntp/camel-nntp-store.c | 6 |
5 files changed, 69 insertions, 30 deletions
diff --git a/camel/ChangeLog b/camel/ChangeLog index 73c7501ffd..0c868c7ae3 100644 --- a/camel/ChangeLog +++ b/camel/ChangeLog @@ -1,3 +1,18 @@ +2000-10-10 Chris Toshok <toshok@helixcode.com> + + * providers/nntp/camel-nntp-store.c + (build_folder_info_from_grouplist): fill in message_count and + unread_message_count properly. + + * providers/nntp/camel-nntp-newsrc.h: reformat. + + * providers/nntp/camel-nntp-grouplist.c + (camel_nntp_get_grouplist_from_file): remove spew. + + * providers/nntp/camel-nntp-newsrc.c + (camel_nntp_newsrc_group_get_num_articles_read): new function. + (camel_nntp_newsrc_group_get_highest_article_read): robustification. + 2000-10-10 Joe Shaw <joe@helixcode.com> * providers/imap/camel-imap-store.c diff --git a/camel/providers/nntp/camel-nntp-grouplist.c b/camel/providers/nntp/camel-nntp-grouplist.c index 9a4443656a..ee1da0da6f 100644 --- a/camel/providers/nntp/camel-nntp-grouplist.c +++ b/camel/providers/nntp/camel-nntp-grouplist.c @@ -111,8 +111,6 @@ camel_nntp_get_grouplist_from_file (CamelNNTPStore *store, CamelException *ex) list->store = store; sscanf (buf, "%d", &list->time); - printf ("time is %d\n", list->time); - while (fgets (buf, 300, fp)) { CamelNNTPGroupListEntry *entry = g_new (CamelNNTPGroupListEntry, 1); char **split_line = g_strsplit (buf, " ", 4); @@ -123,13 +121,9 @@ camel_nntp_get_grouplist_from_file (CamelNNTPStore *store, CamelException *ex) g_strfreev (split_line); - printf ("adding %s\n", entry->group_name); - list->group_list = g_list_append (list->group_list, entry); } - printf ("done\n"); - fclose (fp); return list; diff --git a/camel/providers/nntp/camel-nntp-newsrc.c b/camel/providers/nntp/camel-nntp-newsrc.c index 9fa05fbe49..b474dd3a40 100644 --- a/camel/providers/nntp/camel-nntp-newsrc.c +++ b/camel/providers/nntp/camel-nntp-newsrc.c @@ -65,15 +65,32 @@ camel_nntp_newsrc_group_add (CamelNNTPNewsrc *newsrc, const char *group_name, gb return new_group; } -static long +static int camel_nntp_newsrc_group_get_highest_article_read(CamelNNTPNewsrc *newsrc, NewsrcGroup *group) { - if (group->ranges->len == 0) + if (!group || group->ranges->len == 0) return 0; return g_array_index(group->ranges, ArticleRange, group->ranges->len - 1).high; } +static int +camel_nntp_newsrc_group_get_num_articles_read(CamelNNTPNewsrc *newsrc, NewsrcGroup *group) +{ + int i; + int count = 0; + + if (group == NULL) + return 0; + + for (i = 0; i < group->ranges->len; i ++) + count += (g_array_index(group->ranges, ArticleRange, i).high - + g_array_index(group->ranges, ArticleRange, i).low) + 1; + + return count; +} + + static void camel_nntp_newsrc_group_mark_range_read(CamelNNTPNewsrc *newsrc, NewsrcGroup *group, long low, long high) { @@ -169,6 +186,16 @@ camel_nntp_newsrc_get_highest_article_read (CamelNNTPNewsrc *newsrc, const char return camel_nntp_newsrc_group_get_highest_article_read (newsrc, group); } +int +camel_nntp_newsrc_get_num_articles_read (CamelNNTPNewsrc *newsrc, const char *group_name) +{ + NewsrcGroup *group; + + group = g_hash_table_lookup (newsrc->groups, group_name); + + return camel_nntp_newsrc_group_get_num_articles_read (newsrc, group); +} + void camel_nntp_newsrc_mark_article_read (CamelNNTPNewsrc *newsrc, const char *group_name, int num) { diff --git a/camel/providers/nntp/camel-nntp-newsrc.h b/camel/providers/nntp/camel-nntp-newsrc.h index 6a202f8a01..652e3edbce 100644 --- a/camel/providers/nntp/camel-nntp-newsrc.h +++ b/camel/providers/nntp/camel-nntp-newsrc.h @@ -7,26 +7,27 @@ typedef struct CamelNNTPNewsrc CamelNNTPNewsrc; -int camel_nntp_newsrc_get_highest_article_read (CamelNNTPNewsrc *newsrc, const char *group_name); -void camel_nntp_newsrc_mark_article_read (CamelNNTPNewsrc *newsrc, - const char *group_name, int num); -void camel_nntp_newsrc_mark_range_read (CamelNNTPNewsrc *newsrc, - const char *group_name, long low, long high); - -gboolean camel_nntp_newsrc_article_is_read (CamelNNTPNewsrc *newsrc, - const char *group_name, long num); - -gboolean camel_nntp_newsrc_group_is_subscribed (CamelNNTPNewsrc *newsrc, const char *group_name); -void camel_nntp_newsrc_subscribe_group (CamelNNTPNewsrc *newsrc, const char *group_name); -void camel_nntp_newsrc_unsubscribe_group (CamelNNTPNewsrc *newsrc, const char *group_name); - -GPtrArray *camel_nntp_newsrc_get_subscribed_group_names (CamelNNTPNewsrc *newsrc); -GPtrArray *camel_nntp_newsrc_get_all_group_names (CamelNNTPNewsrc *newsrc); -void camel_nntp_newsrc_free_group_names (CamelNNTPNewsrc *newsrc, GPtrArray *group_names); - -void camel_nntp_newsrc_write_to_file (CamelNNTPNewsrc *newsrc, FILE *fp); -void camel_nntp_newsrc_write (CamelNNTPNewsrc *newsrc); -CamelNNTPNewsrc *camel_nntp_newsrc_read_for_server (const char *server); +int camel_nntp_newsrc_get_highest_article_read (CamelNNTPNewsrc *newsrc, const char *group_name); +int camel_nntp_newsrc_get_num_articles_read (CamelNNTPNewsrc *newsrc, const char *group_name); +void camel_nntp_newsrc_mark_article_read (CamelNNTPNewsrc *newsrc, + const char *group_name, int num); +void camel_nntp_newsrc_mark_range_read (CamelNNTPNewsrc *newsrc, + const char *group_name, long low, long high); + +gboolean camel_nntp_newsrc_article_is_read (CamelNNTPNewsrc *newsrc, + const char *group_name, long num); + +gboolean camel_nntp_newsrc_group_is_subscribed (CamelNNTPNewsrc *newsrc, const char *group_name); +void camel_nntp_newsrc_subscribe_group (CamelNNTPNewsrc *newsrc, const char *group_name); +void camel_nntp_newsrc_unsubscribe_group (CamelNNTPNewsrc *newsrc, const char *group_name); + +GPtrArray* camel_nntp_newsrc_get_subscribed_group_names (CamelNNTPNewsrc *newsrc); +GPtrArray* camel_nntp_newsrc_get_all_group_names (CamelNNTPNewsrc *newsrc); +void camel_nntp_newsrc_free_group_names (CamelNNTPNewsrc *newsrc, GPtrArray *group_names); + +void camel_nntp_newsrc_write_to_file (CamelNNTPNewsrc *newsrc, FILE *fp); +void camel_nntp_newsrc_write (CamelNNTPNewsrc *newsrc); +CamelNNTPNewsrc *camel_nntp_newsrc_read_for_server (const char *server); #endif /* _CAMEL_NNTP_NEWSRC_H_ */ diff --git a/camel/providers/nntp/camel-nntp-store.c b/camel/providers/nntp/camel-nntp-store.c index e814ac3ae3..a83bb8778c 100644 --- a/camel/providers/nntp/camel-nntp-store.c +++ b/camel/providers/nntp/camel-nntp-store.c @@ -354,8 +354,10 @@ build_folder_info_from_grouplist (CamelNNTPStore *nntp_store) url->user ? url->user : "", url->user ? "@" : "", url->host, (char *)entry->group_name); - /* FIXME */ - fi->message_count = fi->unread_message_count = -1; + + fi->message_count = entry->high - entry->low; + fi->unread_message_count = (fi->message_count - + camel_nntp_newsrc_get_num_articles_read (nntp_store->newsrc, entry->group_name)); if (last) last->sibling = fi; |