--- a/jingle/check.c Thu Jul 01 22:11:10 2010 +0200
+++ b/jingle/check.c Fri Jul 02 17:04:41 2010 +0200
@@ -27,7 +27,7 @@
#include <jingle/check.h>
#include <jingle/jingle.h>
-
+#include <jingle/register.h>
static JingleContent *check_content(LmMessageNode *node, GError **err);
gint index_in_array(const gchar *str, const gchar **array);
@@ -104,7 +104,8 @@
JingleContent *cn = g_new0(JingleContent, 1);
const gchar *creatorstr, *sendersstr;
gint tmp, tmp2;
-
+ LmMessageNode *tmpnode = NULL;
+
creatorstr = lm_message_node_get_attribute(node, "creator");
cn->disposition = lm_message_node_get_attribute(node, "disposition");
cn->name = lm_message_node_get_attribute(node, "name");
@@ -128,16 +129,30 @@
cn->creator = (JingleCreator)tmp;
cn->senders = (JingleSenders)tmp2;
-
- cn->description = lm_message_node_get_child(node, "description");
- cn->transport = lm_message_node_get_child(node, "transport");
- if (cn->description == NULL || cn->transport == NULL) {
+ tmpnode = lm_message_node_get_child(node, "description");
+ if(tmpnode == NULL) {
g_set_error(err, JINGLE_CHECK_ERROR, JINGLE_CHECK_ERROR_MISSING,
"a child element of content is missing");
g_free(cn);
return NULL;
}
+ 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,
+ "a child element of content is missing");
+ g_free(cn);
+ return NULL;
+ }
+
+ 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.c Thu Jul 01 22:11:10 2010 +0200
+++ b/jingle/jingle.c Fri Jul 02 17:04:41 2010 +0200
@@ -281,7 +281,7 @@
{
JingleContent* content = (JingleContent*) data;
LmMessageNode* dad = (LmMessageNode*) userdata;
- LmMessageNode* node = (LmMessageNode*) lm_message_node_add_child(dad, "content", NULL), *node2= NULL;
+ LmMessageNode* node = (LmMessageNode*) lm_message_node_add_child(dad, "content", NULL);
if (content->creator == JINGLE_CREATOR_INITIATOR)
lm_message_node_set_attribute(node, "creator", "initiator");
@@ -300,7 +300,8 @@
lm_message_node_set_attribute(node, "senders", "initiator");
else if (content->senders == JINGLE_SENDERS_RESPONDER)
lm_message_node_set_attribute(node, "senders", "responder");
-
- // Care of desc & app
-
+
+ // Care of desc & trans
+ node->children = jingle_get_appfuncs(content->xmlns_desc)->desc(content->description);
+ node->children->next = jingle_get_transportfuncs(content->xmlns_trans)->trans(content->transport);
}
--- a/jingle/jingle.h Thu Jul 01 22:11:10 2010 +0200
+++ b/jingle/jingle.h Fri Jul 02 17:04:41 2010 +0200
@@ -94,12 +94,15 @@
/* each content element (must) contain one description
* child element that specifies a desired application.
* the content of this node is app specific. */
- LmMessageNode *description;
+ gconstpointer *description;
/* each content element (must) contain one transport
* child element that specifies a potential transport
* method */
- LmMessageNode *transport;
+ gconstpointer *transport;
+
+ const gchar *xmlns_desc;
+ const gchar *xmlns_trans;
} JingleContent;
--- a/jingle/register.h Thu Jul 01 22:11:10 2010 +0200
+++ b/jingle/register.h Fri Jul 02 17:04:41 2010 +0200
@@ -10,17 +10,25 @@
typedef gconstpointer (*JingleAppCheck) (JingleContent *cn, GError **err, gpointer *data);
typedef void (*JingleAppHandle) (JingleNode *jn, JingleContent *cn, gpointer *data);
-typedef LmMessageNode* (*JingleAppGetDescription) (JingleNode *jn, JingleContent *cn, gpointer *data);
+typedef LmMessageNode* (*JingleAppGetLM) (gconstpointer *data);
+typedef gconstpointer* (*JingleAppConvertLM) (LmMessageNode *node);
+
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 struct {
/* check if the description of a JingleContent is correct */
- JingleAppCheck check;
+ JingleAppCheck check;
- JingleAppGetDescription desc;
+ /* 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;
} JingleAppFuncs;
@@ -29,17 +37,18 @@
/* check if the transport of a JingleContent is correct */
JingleAppCheck check;
+ JingleTransportGetLM trans;
+
+ JingleTransportConvertLM parse;
/* */
JingleAppHandle handle;
} JingleTransportFuncs;
-void jingle_register_app(const gchar *xmlns,
- JingleAppFuncs *funcs,
+void jingle_register_app(const gchar *xmlns, JingleAppFuncs *funcs,
gpointer data);
-void jingle_register_transport(const gchar *xmlns,
- JingleTransportFuncs *funcs,
+void jingle_register_transport(const gchar *xmlns, JingleTransportFuncs *funcs,
gpointer data);
JingleAppFuncs *jingle_get_appfuncs(const gchar *xmlns);
JingleTransportFuncs *jingle_get_transportfuncs(const gchar *xmlns);
--- a/jingle/sessions.h Thu Jul 01 22:11:10 2010 +0200
+++ b/jingle/sessions.h Fri Jul 02 17:04:41 2010 +0200
@@ -17,8 +17,7 @@
} JingleSession;
-JingleSession *session_new(JingleNode *jn,
- LmMessageNode *app,
+JingleSession *session_new(JingleNode *jn, LmMessageNode *app,
LmMessageNode *transport);
JingleSession *session_find();
void session_delete(JingleSession *sess);