Mercurial > ~mikael > mcabber > hg
diff mcabber/mcabber/roster.c @ 2324:4ddd6f5c3ffc
Add support for displaying the number of unread messages for each roster entry
author | Michał Kępień <bitbucket@kempniu.pl> |
---|---|
date | Sun, 23 Sep 2018 22:52:29 +0200 |
parents | def5f64c253d |
children | ffd0e57e9563 |
line wrap: on
line diff
--- a/mcabber/mcabber/roster.c Thu Mar 22 19:27:48 2018 +0100 +++ b/mcabber/mcabber/roster.c Sun Sep 23 22:52:29 2018 +0200 @@ -108,6 +108,7 @@ /* Flag used for the UI */ guint flags; guint ui_prio; // Boolean, positive if "attention" is requested + guint unread; // list: user -> points to his group; group -> points to its users list GSList *list; @@ -729,6 +730,27 @@ } } +// roster_msg_update_unread() +// If increment is true, increment the unread messages count for jid by 1. +// If increment is false, reset the unread messages count for jid to 0. +void roster_msg_update_unread(const char *jid, gboolean increment) +{ + GSList *sl_user; + roster *roster_usr; + + sl_user = roster_find(jid, jidsearch, + ROSTER_TYPE_USER|ROSTER_TYPE_ROOM|ROSTER_TYPE_AGENT); + if (!sl_user) + return; + + roster_usr = (roster*)sl_user->data; + + if (increment) + roster_usr->unread++; + else + roster_usr->unread = 0; +} + // roster_setuiprio(jid, special, prio_value, action) // Set the "attention" priority value for the given roster item. // Note that this function doesn't create the roster item if it doesn't exist. @@ -1541,6 +1563,12 @@ return roster_usr->ui_prio; } +guint buddy_getunread(gpointer rosterdata) +{ + roster *roster_usr = rosterdata; + return roster_usr->unread; +} + // buddy_setonserverflag() // Set the on_server flag void buddy_setonserverflag(gpointer rosterdata, guint onserver)