# HG changeset patch # User Nicolas Cornu # Date 1278283947 -7200 # Node ID 02f5698ffa49026aa026e6e1ae072d45db3443a9 # Parent 8c3a03e08fd86d617fb178ce73e66554966da583 fix jingle_ft_check, make session_find use JingleNodes directly. diff -r 8c3a03e08fd8 -r 02f5698ffa49 jingle-filetransfer/filetransfer.c --- a/jingle-filetransfer/filetransfer.c Mon Jul 05 00:17:44 2010 +0200 +++ b/jingle-filetransfer/filetransfer.c Mon Jul 05 00:52:27 2010 +0200 @@ -35,7 +35,6 @@ gconstpointer jingle_ft_check(JingleContent *cn, GError **err, gpointer *data); -gconstpointer jingle_ft_parse(JingleContent *cn, GError **err, gpointer *data); static void jingle_ft_init(void); static void jingle_ft_uninit(void); @@ -59,17 +58,23 @@ gconstpointer jingle_ft_check(JingleContent *cn, GError **err, gpointer *data) { JingleFT *ft = NULL; - LmMessageNode *node; + LmMessageNode *node, *description; const gchar *datestr, *sizestr; - node = lm_message_node_get_child(cn->node, "description"); + description = lm_message_node_get_child(cn->node, "description"); + if (!description) { + g_set_error(err, JINGLE_CHECK_ERROR, JINGLE_CHECK_ERROR_MISSING, "Huh ?"); + return NULL; + } + + node = lm_message_node_get_child(description, "offer"); if (!node) { g_set_error(err, JINGLE_CHECK_ERROR, JINGLE_CHECK_ERROR_MISSING, "the offer element is missing"); return NULL; } - node = lm_message_node_get_child(cn->description, "file"); + node = lm_message_node_get_child(description, "file"); if (!node) { g_set_error(err, JINGLE_CHECK_ERROR, JINGLE_CHECK_ERROR_MISSING, "the file element is missing"); diff -r 8c3a03e08fd8 -r 02f5698ffa49 jingle/action-handlers.c --- a/jingle/action-handlers.c Mon Jul 05 00:17:44 2010 +0200 +++ b/jingle/action-handlers.c Mon Jul 05 00:52:27 2010 +0200 @@ -64,7 +64,7 @@ for (child = jn->content; child && !is_session; child = child->next) { if (g_strcmp0(((JingleContent*)(child->data))->disposition, "session") || ((JingleContent*)(child->data))->disposition == NULL) // default: session - is_session=TRUE; + is_session = TRUE; } if (!is_session) { jingle_send_iq_error(m, "cancel", "bad-request", NULL); @@ -72,17 +72,13 @@ } // if a session with the same sid already exists - if (session_find(jn->sid, jn->from) != NULL) { + if (session_find(jn) != NULL) { jingle_send_iq_error(m, "cancel", "unexpected-request", "out-of-order"); return; } - // the important from is one in the session-initiate - jn->from = lm_message_node_get_attribute(lm_message_get_node(m), "from"); - jingle_ack_iq(m); - - + for (child = jn->content; child; child = child->next) { cn = (JingleContent*)(child->data); @@ -98,7 +94,7 @@ void handle_session_terminate(LmMessage *m, JingleNode *jn) { JingleSession *sess; - if ((sess = session_find(jn->sid, jn->from)) == NULL) { + if ((sess = session_find(jn)) == NULL) { jingle_send_iq_error(m, "cancel", "item-not-found", "unknown-session"); return; } diff -r 8c3a03e08fd8 -r 02f5698ffa49 jingle/jingle.h --- a/jingle/jingle.h Mon Jul 05 00:17:44 2010 +0200 +++ b/jingle/jingle.h Mon Jul 05 00:52:27 2010 +0200 @@ -63,8 +63,6 @@ /* Random session identifier generated by the initator. */ const gchar *sid; - const gchar *from; - /* Linked list of JingleContent. */ GSList *content; diff -r 8c3a03e08fd8 -r 02f5698ffa49 jingle/sessions.c --- a/jingle/sessions.c Mon Jul 05 00:17:44 2010 +0200 +++ b/jingle/sessions.c Mon Jul 05 00:52:27 2010 +0200 @@ -40,8 +40,7 @@ js->sid = g_strdup(jn->sid); js->initiator = g_strdup(jn->initiator); - from = lm_message_node_get_attribute(lm_message_get_node(jn->message), - "from"); + from = lm_message_node_get_attribute(lm_message_get_node(jn->message), "from"); if (!from) { return NULL; } @@ -51,7 +50,7 @@ sessions = g_slist_append(sessions, js); } -JingleSession *session_find(const gchar *sid, const gchar *from) +JingleSession *session_find_by_sid(const gchar *sid, const gchar *from) { GSList *el; JingleSession *js; @@ -64,6 +63,13 @@ return NULL; } +JingleSession *session_find(const JingleNode *jn) +{ + LmMessageNode *iq = lm_message_get_node(jn->message); + const gchar *from = lm_message_node_get_attribute(iq, "from"); + return session_find_by_sid(jn->sid, from); +} + /** * Remove a session from the linked list and free it. */ diff -r 8c3a03e08fd8 -r 02f5698ffa49 jingle/sessions.h --- a/jingle/sessions.h Mon Jul 05 00:17:44 2010 +0200 +++ b/jingle/sessions.h Mon Jul 05 00:52:27 2010 +0200 @@ -19,7 +19,8 @@ JingleSession *session_new(JingleNode *jn, LmMessageNode *app, LmMessageNode *transport); -JingleSession *session_find(const gchar *sid, const gchar *from); +JingleSession *session_find_by_sid(const gchar *sid, const gchar *from); +JingleSession *session_find(const JingleNode *jn); void session_delete(JingleSession *sess); void session_remove(JingleSession *sess); void session_free(JingleSession *sess);