aboutsummaryrefslogtreecommitdiffstats
path: root/camel/providers/nntp/camel-nntp-newsrc.c
diff options
context:
space:
mode:
Diffstat (limited to 'camel/providers/nntp/camel-nntp-newsrc.c')
-rw-r--r--camel/providers/nntp/camel-nntp-newsrc.c31
1 files changed, 29 insertions, 2 deletions
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)
{