Mercurial > ~mikael > mcabber > hg
comparison 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 |
comparison
equal
deleted
inserted
replaced
2323:d2111a776b66 | 2324:4ddd6f5c3ffc |
---|---|
106 gchar *offline_status_message; | 106 gchar *offline_status_message; |
107 | 107 |
108 /* Flag used for the UI */ | 108 /* Flag used for the UI */ |
109 guint flags; | 109 guint flags; |
110 guint ui_prio; // Boolean, positive if "attention" is requested | 110 guint ui_prio; // Boolean, positive if "attention" is requested |
111 guint unread; | |
111 | 112 |
112 // list: user -> points to his group; group -> points to its users list | 113 // list: user -> points to his group; group -> points to its users list |
113 GSList *list; | 114 GSList *list; |
114 } roster; | 115 } roster; |
115 | 116 |
727 hlog_save_state(); | 728 hlog_save_state(); |
728 roster_unread_check(); | 729 roster_unread_check(); |
729 } | 730 } |
730 } | 731 } |
731 | 732 |
733 // roster_msg_update_unread() | |
734 // If increment is true, increment the unread messages count for jid by 1. | |
735 // If increment is false, reset the unread messages count for jid to 0. | |
736 void roster_msg_update_unread(const char *jid, gboolean increment) | |
737 { | |
738 GSList *sl_user; | |
739 roster *roster_usr; | |
740 | |
741 sl_user = roster_find(jid, jidsearch, | |
742 ROSTER_TYPE_USER|ROSTER_TYPE_ROOM|ROSTER_TYPE_AGENT); | |
743 if (!sl_user) | |
744 return; | |
745 | |
746 roster_usr = (roster*)sl_user->data; | |
747 | |
748 if (increment) | |
749 roster_usr->unread++; | |
750 else | |
751 roster_usr->unread = 0; | |
752 } | |
753 | |
732 // roster_setuiprio(jid, special, prio_value, action) | 754 // roster_setuiprio(jid, special, prio_value, action) |
733 // Set the "attention" priority value for the given roster item. | 755 // Set the "attention" priority value for the given roster item. |
734 // Note that this function doesn't create the roster item if it doesn't exist. | 756 // Note that this function doesn't create the roster item if it doesn't exist. |
735 void roster_setuiprio(const char *jid, guint special, guint value, | 757 void roster_setuiprio(const char *jid, guint special, guint value, |
736 enum setuiprio_ops action) | 758 enum setuiprio_ops action) |
1539 { | 1561 { |
1540 roster *roster_usr = rosterdata; | 1562 roster *roster_usr = rosterdata; |
1541 return roster_usr->ui_prio; | 1563 return roster_usr->ui_prio; |
1542 } | 1564 } |
1543 | 1565 |
1566 guint buddy_getunread(gpointer rosterdata) | |
1567 { | |
1568 roster *roster_usr = rosterdata; | |
1569 return roster_usr->unread; | |
1570 } | |
1571 | |
1544 // buddy_setonserverflag() | 1572 // buddy_setonserverflag() |
1545 // Set the on_server flag | 1573 // Set the on_server flag |
1546 void buddy_setonserverflag(gpointer rosterdata, guint onserver) | 1574 void buddy_setonserverflag(gpointer rosterdata, guint onserver) |
1547 { | 1575 { |
1548 roster *roster_usr = rosterdata; | 1576 roster *roster_usr = rosterdata; |