changeset 501:7c1ca00070e8

Add COMPL_RESOURCE (resource completion category)
author Mikael Berthe <mikael@lilotux.net>
date Wed, 26 Oct 2005 23:46:53 +0200
parents 357086193b02
children 3134b4960cdb
files mcabber/src/compl.c mcabber/src/compl.h mcabber/src/roster.c
diffstat 3 files changed, 9 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/mcabber/src/compl.c	Fri Oct 21 23:13:54 2005 +0200
+++ b/mcabber/src/compl.c	Wed Oct 26 23:46:53 2005 +0200
@@ -217,6 +217,9 @@
   if (cat_flags == COMPL_JID) {
     return compl_list(ROSTER_TYPE_USER);
   }
+  if (cat_flags == COMPL_RESOURCE) {
+    return buddy_getresources(NULL);
+  }
 
   return NULL;
 }
--- a/mcabber/src/compl.h	Fri Oct 21 23:13:54 2005 +0200
+++ b/mcabber/src/compl.h	Wed Oct 26 23:46:53 2005 +0200
@@ -15,6 +15,7 @@
 #define COMPL_GROUPNAME   (1<<10)
 #define COMPL_MULTILINE   (1<<11)
 #define COMPL_ROOM        (1<<12)
+#define COMPL_RESOURCE    (1<<13)
 
 void    compl_add_category_word(guint, const char *command);
 void    compl_del_category_word(guint categ, const char *word);
--- a/mcabber/src/roster.c	Fri Oct 21 23:13:54 2005 +0200
+++ b/mcabber/src/roster.c	Wed Oct 26 23:46:53 2005 +0200
@@ -841,11 +841,16 @@
 //  buddy_getresources(roster_data)
 // Return a singly-linked-list of resource names
 // Note: the caller should free the list (and data) after use
+// If roster_data is null, the current buddy is selected
 GSList *buddy_getresources(gpointer rosterdata)
 {
   roster *roster_usr = rosterdata;
   GSList *reslist = NULL, *lp;
 
+  if (!roster_usr) {
+    if (!current_buddy) return NULL;
+    roster_usr = BUDDATA(current_buddy);
+  }
   for (lp = roster_usr->resource; lp; lp = g_slist_next(lp))
     reslist = g_slist_append(reslist, g_strdup(((res*)lp->data)->name));