jingle/jingle.c
changeset 79 a654afc4a74a
parent 77 56c6ab96026f
child 80 1c2ef2c5debe
--- a/jingle/jingle.c	Tue Jul 27 12:20:29 2010 +0200
+++ b/jingle/jingle.c	Fri Jul 30 00:03:48 2010 +0200
@@ -274,6 +274,36 @@
 }
 
 /**
+ * Find the best resource to initiate a jingle session.
+ * Test every ressource for a given jid and return the one
+ * who support all namespaces in ns.
+ */
+gchar *jingle_find_compatible_res(const gchar *jid, const gchar *ns[])
+{
+  gchar *choosenres;
+  guint indexns;
+  gboolean found;
+  GList *roster_usr;
+  GSList *reslist, *thisres;
+
+  roster_usr = buddy_search_jid(jid);
+  reslist = buddy_getresources(roster_usr->data);
+  for (thisres = reslist; thisres; thisres = g_slist_next(thisres)) {
+    found = TRUE;
+    for (indexns = 0; ns[indexns]; indexns++) {
+	  if (!caps_has_feature(buddy_resource_getcaps(roster_usr->data, thisres->data), ns[indexns]))
+	    found = FALSE;
+	}
+	if (!found) continue;
+
+    choosenres = g_strdup(thisres->data);
+    g_slist_foreach(reslist, (GFunc)g_free, NULL);
+    g_slist_free(reslist);
+    return choosenres;
+  }
+}
+
+/**
  * Find the jingle_action corresponding to a string
  */
 JingleAction jingle_action_from_str(const gchar *string)
@@ -476,7 +506,7 @@
   sc->appfuncs->handle_data(sc->description, data2, len);
 }
 
-gchar *new_sid(void)
+gchar *jingle_generate_sid(void)
 {
   gchar *sid;
   gchar car[] = "azertyuiopqsdfghjklmwxcvbn1234567890AZERTYUIOPQSDFGHJKLMWXCVBN";