diff mcabber/src/roster.c @ 225:d5ae42cbe1fa

[/trunk] Changeset 237 by mikael * Group names and JIDs completion
author mikael
date Sat, 04 Jun 2005 19:35:30 +0000
parents 73f6ce668ba8
children 72fd1273f2b7
line wrap: on
line diff
--- a/mcabber/src/roster.c	Sat Jun 04 17:34:15 2005 +0000
+++ b/mcabber/src/roster.c	Sat Jun 04 19:35:30 2005 +0000
@@ -617,3 +617,31 @@
   return roster_usr->flags;
 }
 
+//  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)
+// The list should be freed by the caller after use.
+GSList *compl_list(guint type)
+{
+  GSList *list = NULL;
+  GList  *buddy = buddylist;
+
+  for ( ; buddy ; buddy = g_list_next(buddy)) {
+    guint btype = buddy_gettype(BUDDATA(buddy));
+
+    if (type == ROSTER_TYPE_GROUP) { // (group names)
+      if (btype == ROSTER_TYPE_GROUP) {
+        const char *bname = buddy_getname(BUDDATA(buddy));
+        if ((bname) && (*bname))
+          list = g_slist_append(list, g_strdup(bname));
+      }
+    } else { // ROSTER_TYPE_USER (jid)
+        const char *bjid = buddy_getjid(BUDDATA(buddy));
+        if (bjid)
+          list = g_slist_append(list, g_strdup(bjid));
+    }
+  }
+
+  return list;
+}
+