mcabber/src/roster.c
changeset 1581 b29ac1f171ea
parent 1504 9fafea381eb8
child 1599 dcd5d4c75199
equal deleted inserted replaced
1580:c8be6c2243d6 1581:b29ac1f171ea
   597     //sl_user = roster_find(jid, namesearch, ROSTER_TYPE_SPECIAL);
   597     //sl_user = roster_find(jid, namesearch, ROSTER_TYPE_SPECIAL);
   598     //if (!sl_user) return;
   598     //if (!sl_user) return;
   599     //roster_usr = (roster*)sl_user->data;
   599     //roster_usr = (roster*)sl_user->data;
   600     roster_usr = &roster_special;
   600     roster_usr = &roster_special;
   601     if (value) {
   601     if (value) {
       
   602       if (!(roster_usr->flags & ROSTER_FLAG_MSG))
       
   603         unread_list_modified = TRUE;
   602       roster_usr->flags |= ROSTER_FLAG_MSG;
   604       roster_usr->flags |= ROSTER_FLAG_MSG;
   603       // Append the roster_usr to unread_list, but avoid duplicates
   605       // Append the roster_usr to unread_list, but avoid duplicates
   604       if (!g_slist_find(unread_list, roster_usr))
   606       if (!g_slist_find(unread_list, roster_usr))
   605         unread_list = g_slist_append(unread_list, roster_usr);
   607         unread_list = g_slist_append(unread_list, roster_usr);
   606     } else {
   608     } else {
       
   609       if (roster_usr->flags & ROSTER_FLAG_MSG)
       
   610         unread_list_modified = TRUE;
   607       roster_usr->flags &= ~ROSTER_FLAG_MSG;
   611       roster_usr->flags &= ~ROSTER_FLAG_MSG;
   608       if (unread_list) {
   612       if (unread_list) {
   609         GSList *node = g_slist_find(unread_list, roster_usr);
   613         GSList *node = g_slist_find(unread_list, roster_usr);
   610         if (node) unread_list = g_slist_delete_link(unread_list, node);
   614         if (node)
       
   615           unread_list = g_slist_delete_link(unread_list, node);
   611       }
   616       }
   612     }
   617     }
   613     return;
   618     goto roster_msg_setflag_return;
   614   }
   619   }
   615 
   620 
   616   sl_user = roster_find(jid, jidsearch,
   621   sl_user = roster_find(jid, jidsearch,
   617                         ROSTER_TYPE_USER|ROSTER_TYPE_ROOM|ROSTER_TYPE_AGENT);
   622                         ROSTER_TYPE_USER|ROSTER_TYPE_ROOM|ROSTER_TYPE_AGENT);
   618   // If we can't find it, we add it
   623   // If we can't find it, we add it
   639     if (roster_usr->flags & ROSTER_FLAG_MSG)
   644     if (roster_usr->flags & ROSTER_FLAG_MSG)
   640       unread_list_modified = TRUE;
   645       unread_list_modified = TRUE;
   641     roster_usr->flags &= ~ROSTER_FLAG_MSG;
   646     roster_usr->flags &= ~ROSTER_FLAG_MSG;
   642     if (unread_list) {
   647     if (unread_list) {
   643       GSList *node = g_slist_find(unread_list, roster_usr);
   648       GSList *node = g_slist_find(unread_list, roster_usr);
   644       if (node) unread_list = g_slist_delete_link(unread_list, node);
   649       if (node)
       
   650         unread_list = g_slist_delete_link(unread_list, node);
   645     }
   651     }
   646     // For the group value we need to watch all buddies in this group;
   652     // For the group value we need to watch all buddies in this group;
   647     // if one is flagged, then the group will be flagged.
   653     // if one is flagged, then the group will be flagged.
   648     // I will re-use sl_user and roster_usr here, as they aren't used
   654     // I will re-use sl_user and roster_usr here, as they aren't used
   649     // anymore.
   655     // anymore.
   665   }
   671   }
   666 
   672 
   667   if (buddylist && (new_roster_item || !g_list_find(buddylist, roster_usr)))
   673   if (buddylist && (new_roster_item || !g_list_find(buddylist, roster_usr)))
   668     buddylist_build();
   674     buddylist_build();
   669 
   675 
       
   676 roster_msg_setflag_return:
   670   if (unread_list_modified) {
   677   if (unread_list_modified) {
   671     guint unread_count = g_slist_length(unread_list);
   678     guint unread_count = g_slist_length(unread_list);
   672     hlog_save_state();
   679     hlog_save_state();
   673     /* Call external command */
   680     /* Call external command */
   674     hk_ext_cmd("", 'U', (guchar)MIN(255, unread_count), NULL);
   681     hk_ext_cmd("", 'U', (guchar)MIN(255, unread_count), NULL);