jingle/sessions.c
changeset 33 92e92ce901e7
parent 32 72bbe33f151a
child 35 a0fd92a93af7
--- a/jingle/sessions.c	Tue Jul 06 02:21:33 2010 +0200
+++ b/jingle/sessions.c	Tue Jul 06 16:57:11 2010 +0200
@@ -24,6 +24,7 @@
 
 #include <jingle/jingle.h>
 #include <jingle/sessions.h>
+#include <jingle/register.h>
 
 
 static GSList *sessions;
@@ -69,6 +70,35 @@
   return session_find_by_sid(jn->sid, from);
 }
 
+void session_add_content(JingleSession *sess, JingleContent *cn)
+{
+  SessionContent *sc = g_new0(SessionContent, 1);
+  const gchar *tmpchar = lm_message_node_get_attribute(cn->description,
+                                                       "xmlns");
+  sc->appfuncs = jingle_get_appfuncs(tmpchar);
+  tmpchar = lm_message_node_get_attribute(cn->transport, "xmlns");
+  sc->transfuncs = jingle_get_transportfuncs(tmpchar);
+  // TODO errors
+  sc->description = sc->appfuncs->check(cn, NULL);
+  sc->transport = sc->appfuncs->check(cn, NULL);
+
+  sess->content = g_slist_append(sess->content, sc);
+}
+
+SessionContent *session_find_sessioncontent(JingleSession *sess,
+                                        gconstpointer desc, gconstpointer trans)
+{
+  GSList *el;
+  SessionContent *sc;
+  for (el = sess->content; el; el = el->next) {
+    sc = (SessionContent*) el->data;
+    if (sc->appfuncs->cmp(sc->description, desc) == TRUE &&
+        sc->transfuncs->cmp(sc->transport, trans) == TRUE)
+      return sc;
+  }
+  return NULL;
+}
+
 /**
  * Remove a session from the linked list and free it.
  */