116 GList *current_buddy; |
117 GList *current_buddy; |
117 GList *alternate_buddy; |
118 GList *alternate_buddy; |
118 |
119 |
119 static roster roster_special; |
120 static roster roster_special; |
120 |
121 |
121 void unread_jid_add(const char *jid); |
122 static int unread_jid_del(const char *jid); |
122 int unread_jid_del(const char *jid); |
|
123 |
123 |
124 #define DFILTER_ALL 63 |
124 #define DFILTER_ALL 63 |
125 #define DFILTER_ONLINE 62 |
125 #define DFILTER_ONLINE 62 |
126 |
126 |
127 |
127 |
588 void roster_msg_setflag(const char *jid, guint special, guint value) |
588 void roster_msg_setflag(const char *jid, guint special, guint value) |
589 { |
589 { |
590 GSList *sl_user; |
590 GSList *sl_user; |
591 roster *roster_usr, *roster_grp; |
591 roster *roster_usr, *roster_grp; |
592 int new_roster_item = FALSE; |
592 int new_roster_item = FALSE; |
|
593 guint unread_list_modified = FALSE; |
593 |
594 |
594 if (special) { |
595 if (special) { |
595 //sl_user = roster_find(jid, namesearch, ROSTER_TYPE_SPECIAL); |
596 //sl_user = roster_find(jid, namesearch, ROSTER_TYPE_SPECIAL); |
596 //if (!sl_user) return; |
597 //if (!sl_user) return; |
597 //roster_usr = (roster*)sl_user->data; |
598 //roster_usr = (roster*)sl_user->data; |
620 } |
621 } |
621 |
622 |
622 roster_usr = (roster*)sl_user->data; |
623 roster_usr = (roster*)sl_user->data; |
623 roster_grp = (roster*)roster_usr->list->data; |
624 roster_grp = (roster*)roster_usr->list->data; |
624 if (value) { |
625 if (value) { |
|
626 if (!(roster_usr->flags & ROSTER_FLAG_MSG)) |
|
627 unread_list_modified = TRUE; |
625 // Message flag is TRUE. This is easy, we just have to set both flags |
628 // Message flag is TRUE. This is easy, we just have to set both flags |
626 // to TRUE... |
629 // to TRUE... |
627 roster_usr->flags |= ROSTER_FLAG_MSG; |
630 roster_usr->flags |= ROSTER_FLAG_MSG; |
628 roster_grp->flags |= ROSTER_FLAG_MSG; // group |
631 roster_grp->flags |= ROSTER_FLAG_MSG; // group |
629 // Append the roster_usr to unread_list, but avoid duplicates |
632 // Append the roster_usr to unread_list, but avoid duplicates |
630 if (!g_slist_find(unread_list, roster_usr)) |
633 if (!g_slist_find(unread_list, roster_usr)) |
631 unread_list = g_slist_append(unread_list, roster_usr); |
634 unread_list = g_slist_append(unread_list, roster_usr); |
632 } else { |
635 } else { |
633 // Message flag is FALSE. |
636 // Message flag is FALSE. |
634 guint msg = FALSE; |
637 guint msg = FALSE; |
|
638 if (roster_usr->flags & ROSTER_FLAG_MSG) |
|
639 unread_list_modified = TRUE; |
635 roster_usr->flags &= ~ROSTER_FLAG_MSG; |
640 roster_usr->flags &= ~ROSTER_FLAG_MSG; |
636 if (unread_list) { |
641 if (unread_list) { |
637 GSList *node = g_slist_find(unread_list, roster_usr); |
642 GSList *node = g_slist_find(unread_list, roster_usr); |
638 if (node) unread_list = g_slist_delete_link(unread_list, node); |
643 if (node) unread_list = g_slist_delete_link(unread_list, node); |
639 } |
644 } |
1539 g_hash_table_insert(unread_jids, g_strdup(jid), unread_jids); |
1547 g_hash_table_insert(unread_jids, g_strdup(jid), unread_jids); |
1540 } |
1548 } |
1541 |
1549 |
1542 // unread_jid_del(jid) |
1550 // unread_jid_del(jid) |
1543 // Return TRUE if jid is found in the table (and remove it), FALSE if not |
1551 // Return TRUE if jid is found in the table (and remove it), FALSE if not |
1544 int unread_jid_del(const char *jid) |
1552 static int unread_jid_del(const char *jid) |
1545 { |
1553 { |
1546 if (!unread_jids) |
1554 if (!unread_jids) |
1547 return FALSE; |
1555 return FALSE; |
1548 return g_hash_table_remove(unread_jids, jid); |
1556 return g_hash_table_remove(unread_jids, jid); |
1549 } |
1557 } |
1550 |
1558 |
|
1559 // unread_jid_get_list() |
|
1560 // Return the JID list. |
|
1561 // The content of the list should not be modified or freed. |
|
1562 // The caller should call g_list_free() after use. |
|
1563 GList *unread_jid_get_list(void) |
|
1564 { |
|
1565 if (!unread_jids) |
|
1566 return NULL; |
|
1567 return g_hash_table_get_keys(unread_jids); |
|
1568 } |
|
1569 |
1551 /* vim: set expandtab cindent cinoptions=>2\:2(0: For Vim users... */ |
1570 /* vim: set expandtab cindent cinoptions=>2\:2(0: For Vim users... */ |