handle content accept
authorNicolas Cornu <nicolas.cornu@ensi-bourges.fr>
Thu, 08 Jul 2010 14:03:40 +0200
changeset 39 405518ad71de
parent 38 121e5ae7c1e5
child 40 cbc7a83fbdf5
handle content accept
jingle/action-handlers.c
jingle/action-handlers.h
jingle/jingle.c
--- 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;
   }
 
--- a/jingle/action-handlers.h	Thu Jul 08 13:54:57 2010 +0200
+++ b/jingle/action-handlers.h	Thu Jul 08 14:03:40 2010 +0200
@@ -4,11 +4,10 @@
 #include <glib.h>
 #include <loudmouth/loudmouth.h>
 
+void handle_content_accept(LmMessage *m, JingleNode *jn);
 void handle_content_add(LmMessage *m, JingleNode *jn);
 void handle_content_reject(LmMessage *m, JingleNode *jn);
 void handle_content_remove(LmMessage *m, JingleNode *jn);
 void handle_session_initiate(LmMessage *m, JingleNode *jn);
 void handle_session_terminate(LmMessage *m, JingleNode *jn);
-const gchar* get_xmlnsdesc(const GSList* list);
-const gchar* get_xmlnstrans(const GSList* list);
 #endif
--- a/jingle/jingle.c	Thu Jul 08 13:54:57 2010 +0200
+++ b/jingle/jingle.c	Thu Jul 08 14:03:40 2010 +0200
@@ -56,11 +56,11 @@
  */
 struct JingleActionList jingle_action_list[] = {
   { NULL,                NULL }, // for JINGLE_UNKNOWN_ACTION
-  { "content-accept",    NULL },
+  { "content-accept",    handle_content_accept },
   { "content-add",       handle_content_add },
   { "content-modify",    NULL },
-  { "content-reject",    NULL },
-  { "content-remove",    NULL },
+  { "content-reject",    handle_content_reject },
+  { "content-remove",    handle_content_remove },
   { "description-info",  NULL },
   { "security-info",     NULL },
   { "session-accept",    NULL },