jingle/action-handlers.c
changeset 39 405518ad71de
parent 38 121e5ae7c1e5
child 40 cbc7a83fbdf5
--- a/jingle/action-handlers.c	Thu Jul 08 13:54:57 2010 +0200
+++ b/jingle/action-handlers.c	Thu Jul 08 14:03:40 2010 +0200
@@ -30,6 +30,44 @@
 #include <jingle/send.h>
 #include <jingle/action-handlers.h>
 
+void handle_content_accept(LmMessage *m, JingleNode *jn)
+{
+  GError *err = NULL;
+  GSList *child = NULL;
+  JingleContent *cn;
+  JingleAppFuncs *appfuncs; 
+  JingleTransportFuncs *transfuncs;
+  gconstpointer description, transport;
+  const gchar *xmlns;
+  JingleSession *sess;
+
+  if (!check_contents(jn, &err)) {
+    scr_log_print(LPRINT_DEBUG, "jingle: One of the content element was invalid (%s)",
+                  err->message);
+    jingle_send_iq_error(m, "cancel", "bad-request", NULL);
+    return;
+  }
+
+  /* it's better if there is at least one content elem */
+  if (g_slist_length(jn->content) < 1) {
+    jingle_send_iq_error(m, "cancel", "bad-request", NULL);
+    return;
+  }
+  
+  // if a session with the same sid doesn't already exists
+  if ((sess = session_find(jn)) == NULL) {
+    jingle_send_iq_error(m, "cancel", "item-not-found", "unknown-session");
+    return;
+  }
+
+  jingle_ack_iq(m);
+
+  for (child = jn->content; child; child = child->next) {
+    cn = (JingleContent *)(child->data);
+    session_changestate_sessioncontent(sess, cn->name, ACTIVE);
+  }
+}
+
 void handle_content_add(LmMessage *m, JingleNode *jn)
 {
   GError *err = NULL;
@@ -56,7 +94,7 @@
   
   // if a session with the same sid doesn't already exists
   if ((sess = session_find(jn)) == NULL) {
-    jingle_send_iq_error(m, "cancel", "unexpected-request", "out-of-order");
+    jingle_send_iq_error(m, "cancel", "item-not-found", "unknown-session");
     return;
   }
 
@@ -107,7 +145,7 @@
   
   // if a session with the same sid doesn't already exists
   if ((sess = session_find(jn)) == NULL) {
-    jingle_send_iq_error(m, "cancel", "unexpected-request", "out-of-order");
+    jingle_send_iq_error(m, "cancel", "item-not-found", "unknown-session");
     return;
   }
 
@@ -152,7 +190,7 @@
   
   // if a session with the same sid doesn't already exists
   if ((sess = session_find(jn)) == NULL) {
-    jingle_send_iq_error(m, "cancel", "unexpected-request", "out-of-order");
+    jingle_send_iq_error(m, "cancel", "item-not-found", "unknown-session");
     return;
   }