diff options
Diffstat (limited to 'libsylph')
-rw-r--r-- | libsylph/procmsg.c | 34 | ||||
-rw-r--r-- | libsylph/procmsg.h | 1 |
2 files changed, 35 insertions, 0 deletions
diff --git a/libsylph/procmsg.c b/libsylph/procmsg.c index 3a47da3d..4cb56811 100644 --- a/libsylph/procmsg.c +++ b/libsylph/procmsg.c @@ -380,6 +380,40 @@ void procmsg_set_flags(GSList *mlist, FolderItem *item) g_hash_table_destroy(mark_table); } +static void mark_all_read_func(gpointer key, gpointer value, gpointer data) +{ + MSG_UNSET_PERM_FLAGS(*((MsgFlags *)value), MSG_NEW|MSG_UNREAD); +} + +void procmsg_mark_all_read(FolderItem *item) +{ + GHashTable *mark_table; + + debug_print("Marking all messages as read\n"); + + mark_table = procmsg_read_mark_file(item); + if (mark_table) { + g_hash_table_foreach(mark_table, mark_all_read_func, NULL); + procmsg_write_mark_file(item, mark_table); + hash_free_value_mem(mark_table); + g_hash_table_destroy(mark_table); + } + + if (item->mark_queue) { + GSList *cur; + MsgInfo *msginfo; + + for (cur = item->mark_queue; cur != NULL; cur = cur->next) { + msginfo = (MsgInfo *)cur->data; + MSG_UNSET_PERM_FLAGS + (msginfo->flags, MSG_NEW|MSG_UNREAD); + } + item->mark_dirty = TRUE; + } + + item->new = item->unread = 0; +} + static FolderSortType cmp_func_sort_type; GSList *procmsg_sort_msg_list(GSList *mlist, FolderSortKey sort_key, diff --git a/libsylph/procmsg.h b/libsylph/procmsg.h index f61b6f9b..3fc7e119 100644 --- a/libsylph/procmsg.h +++ b/libsylph/procmsg.h @@ -221,6 +221,7 @@ GSList *procmsg_read_cache (FolderItem *item, gboolean scan_file); void procmsg_set_flags (GSList *mlist, FolderItem *item); +void procmsg_mark_all_read (FolderItem *item); GSList *procmsg_sort_msg_list (GSList *mlist, FolderSortKey sort_key, FolderSortType sort_type); |