diff mcabber/src/roster.c @ 532:2ac8d8e49e81

Send status changes to chatrooms
author Mikael Berthe <mikael@lilotux.net>
date Thu, 24 Nov 2005 00:03:37 +0100
parents c60175268eb5
children ffdfddd351b8
line wrap: on
line diff
--- a/mcabber/src/roster.c	Tue Nov 22 23:36:12 2005 +0100
+++ b/mcabber/src/roster.c	Thu Nov 24 00:03:37 2005 +0100
@@ -774,7 +774,7 @@
 {
   roster *roster_usr = rosterdata;
 
-  if (!roster_usr->type & ROSTER_TYPE_ROOM) return;
+  if (!(roster_usr->type & ROSTER_TYPE_ROOM)) return;
 
   if (roster_usr->nickname) {
     g_free((gchar*)roster_usr->nickname);
@@ -964,6 +964,33 @@
   }
 }
 
+//  foreach_buddy(roster_type, pfunction, param)
+// Call pfunction(buddy, param) for each buddy from the roster with
+// type matching roster_type.
+void foreach_buddy(guint roster_type,
+                   void (*pfunc)(gpointer rosterdata, void *param),
+                   void *param)
+{
+  GSList *sl_roster_elt = groups;
+  roster *roster_elt;
+  GSList *sl_roster_usrelt;
+  roster *roster_usrelt;
+
+  while (sl_roster_elt) {       // group list loop
+    roster_elt = (roster*) sl_roster_elt->data;
+    sl_roster_usrelt = roster_elt->list;
+    while (sl_roster_usrelt) {  // user list loop
+      roster_usrelt = (roster*) sl_roster_usrelt->data;
+
+      if (roster_usrelt->type & roster_type)
+        pfunc(roster_usrelt, param);
+
+      sl_roster_usrelt = g_slist_next(sl_roster_usrelt);
+    }
+    sl_roster_elt = g_slist_next(sl_roster_elt);
+  }
+}
+
 //  compl_list(type)
 // Returns a list of jid's or groups.  (For commands completion)
 // type: ROSTER_TYPE_USER (jid's) or ROSTER_TYPE_GROUP (group names)
@@ -1011,4 +1038,3 @@
 
   return unread_list->data;
 }
-