diff options
Diffstat (limited to 'camel/providers')
-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 |
4 files changed, 54 insertions, 30 deletions
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; |