Delete parse / use check
authorNicolas Cornu <nicolas.cornu@ensi-bourges.fr>
Sun, 04 Jul 2010 23:02:55 +0200
changeset 29 9215053e8fb0
parent 28 ed7520776c41
child 30 8c3a03e08fd8
Delete parse / use check
jingle/action-handlers.c
jingle/action-handlers.h
jingle/check.c
jingle/jingle.h
jingle/register.h
--- a/jingle/action-handlers.c	Sun Jul 04 01:30:26 2010 +0200
+++ b/jingle/action-handlers.c	Sun Jul 04 23:02:55 2010 +0200
@@ -28,6 +28,7 @@
 #include <jingle/sessions.h>
 #include <jingle/register.h>
 #include <jingle/send.h>
+#include <jingle/action-handlers.h>
 
 /* The session-initiate action is used to request negotiation of a new Jingle
  * session. When sending a session-initiate with one <content/> element, the
@@ -59,11 +60,11 @@
   
   // one of the content element must be a "session"
   for (child = jn->content; child && !is_session; child = child->next) {
-    if(g_strcmp0(((JingleContent*)(child->data))->disposition, "session") ||
+    if (g_strcmp0(((JingleContent*)(child->data))->disposition, "session") ||
        ((JingleContent*)(child->data))->disposition == NULL) // default: session
       is_session=TRUE;
   }
-  if(!is_session) {
+  if (!is_session) {
     jingle_send_iq_error(m, "cancel", "bad-request", NULL);
     return;  
   }
@@ -83,10 +84,10 @@
   is_session = FALSE;  
   // Do we support any of this xmlns ?
   for (child = jn->content; child && !is_session; child = child->next) {
-    if(jingle_get_appfuncs(((JingleContent*)(child->data))->xmlns_desc) != NULL)
+    if (jingle_get_appfuncs(get_xmlnsdesc(child)) != NULL)
       is_session = TRUE;
   }
-  if(!is_session) { // None of the app is supported
+  if (!is_session) { // None of the app is supported
     jingle_send_session_terminate(m, "unsupported-applications");
     return;
   }
@@ -94,13 +95,19 @@
   is_session = FALSE;  
   // Do we support any of this xmlns ?
   for (child = jn->content; child && !is_session; child = child->next) {
-    if(jingle_get_transportfuncs(((JingleContent*)(child->data))->xmlns_trans) != NULL)
+    if (jingle_get_transportfuncs(get_xmlnstrans(child)) != NULL)
       is_session = TRUE;
   }
-  if(!is_session) { // None of the transport is supported
+  if (!is_session) { // None of the transport is supported
     jingle_send_session_terminate(m, "unsupported-transports");
     return;
   }
+  
+  // Next we ask parsing to the modules
+  for (child = jn->content; child; child = child->next) {
+    ((JingleContent*)(child->data))->description = jingle_get_appfuncs(get_xmlnsdesc(child))->check((JingleContent*)(child->data), NULL, NULL);
+    ((JingleContent*)(child->data))->transport = jingle_get_appfuncs(get_xmlnstrans(child))->check((JingleContent*)(child->data), NULL, NULL);
+  }
 }
 
 void handle_session_terminate(LmMessage *m, JingleNode *jn)
@@ -111,4 +118,15 @@
     return;
   }
   session_delete(sess);
+  jingle_ack_iq(m);
 }
+
+const gchar* get_xmlnstrans(const GSList* list)
+{
+  return ((JingleContent*)(list->data))->xmlns_trans;
+}
+
+const gchar* get_xmlnsdesc(const GSList* list)
+{
+  return ((JingleContent*)(list->data))->xmlns_desc;
+}
--- a/jingle/action-handlers.h	Sun Jul 04 01:30:26 2010 +0200
+++ b/jingle/action-handlers.h	Sun Jul 04 23:02:55 2010 +0200
@@ -7,5 +7,6 @@
 
 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/check.c	Sun Jul 04 01:30:26 2010 +0200
+++ b/jingle/check.c	Sun Jul 04 23:02:55 2010 +0200
@@ -139,8 +139,6 @@
   
   cn->xmlns_desc = lm_message_node_get_attribute(tmpnode, "xmlns");
   
-  cn->description = (gconstpointer*)jingle_get_appfuncs(cn->xmlns_desc)->parse(tmpnode);
-  
   tmpnode = lm_message_node_get_child(node, "transport");
   if (tmpnode == NULL) {
     g_set_error(err, JINGLE_CHECK_ERROR, JINGLE_CHECK_ERROR_MISSING,
@@ -151,8 +149,6 @@
 
   cn->xmlns_trans = lm_message_node_get_attribute(tmpnode, "xmlns");
   
-  cn->transport = (gconstpointer*)jingle_get_transportfuncs(cn->xmlns_trans)->parse(tmpnode);
-  
   return cn;
 }
 
--- a/jingle/jingle.h	Sun Jul 04 01:30:26 2010 +0200
+++ b/jingle/jingle.h	Sun Jul 04 23:02:55 2010 +0200
@@ -96,12 +96,12 @@
   /* each content element (must) contain one description
    * child element that specifies a desired application.
    * the content of this node is app specific. */
-  gconstpointer *description;
+  gconstpointer description;
 
   /* each content element (must) contain one transport
    * child element that specifies a potential transport
    * method */
-  gconstpointer *transport;
+  gconstpointer transport;
   
   const gchar *xmlns_desc;
   const gchar *xmlns_trans;
--- a/jingle/register.h	Sun Jul 04 01:30:26 2010 +0200
+++ b/jingle/register.h	Sun Jul 04 23:02:55 2010 +0200
@@ -10,13 +10,11 @@
 
 typedef gconstpointer (*JingleAppCheck) (JingleContent *cn, GError **err, gpointer *data);
 typedef void (*JingleAppHandle) (JingleNode *jn, JingleContent *cn, gpointer *data);
-typedef LmMessageNode* (*JingleAppGetLM) (gconstpointer *data);
-typedef gconstpointer* (*JingleAppConvertLM) (LmMessageNode *node);
+typedef LmMessageNode* (*JingleAppGetLM) (gconstpointer data);
 
 typedef gconstpointer (*JingleTransportCheck) (JingleContent *cn, GError **err, gpointer *data);
 typedef void (*JingleTransportHandle) (JingleNode *jn, JingleContent *cn, gpointer *data);
-typedef LmMessageNode* (*JingleTransportGetLM) (gconstpointer *data);
-typedef gconstpointer* (*JingleTransportConvertLM) (LmMessageNode *node);
+typedef LmMessageNode* (*JingleTransportGetLM) (gconstpointer data);
 
 typedef struct {
   /* check if the description of a JingleContent is correct */
@@ -25,9 +23,6 @@
   /* Give a LM from a internal struct */
   JingleAppGetLM desc;
   
-  /* Give a gconstpointer from a LmMessageNode */
-  JingleAppConvertLM parse;
-  
   /* If we got a LM with the good xmlns */
   JingleAppHandle handle;
 
@@ -38,8 +33,7 @@
   JingleAppCheck  check;
 
   JingleTransportGetLM trans;
-  
-  JingleTransportConvertLM parse;
+
   /* */
   JingleAppHandle handle;