39 */ |
39 */ |
40 |
40 |
41 void handle_session_initiate(LmMessage *m, JingleNode *jn) |
41 void handle_session_initiate(LmMessage *m, JingleNode *jn) |
42 { |
42 { |
43 GError *err = NULL; |
43 GError *err = NULL; |
44 gboolean is_session = FALSE, support_both = FALSE; |
|
45 GSList *child = NULL; |
44 GSList *child = NULL; |
|
45 gboolean valid_disposition = FALSE; |
46 JingleContent *cn; |
46 JingleContent *cn; |
47 JingleAppFuncs *af; |
47 JingleAppFuncs *appfuncs; |
48 JingleTransportFuncs *tf; |
48 JingleTransportFuncs *transfuncs; |
|
49 gconstpointer description, transport; |
|
50 const gchar *xmlns; |
49 |
51 |
50 if (!check_contents(jn, &err)) { |
52 if (!check_contents(jn, &err)) { |
51 scr_log_print(LPRINT_DEBUG, "jingle: One of the content element was invalid (%s)", |
53 scr_log_print(LPRINT_DEBUG, "jingle: One of the content element was invalid (%s)", |
52 err->message); |
54 err->message); |
53 jingle_send_iq_error(m, "cancel", "bad-request", NULL); |
55 jingle_send_iq_error(m, "cancel", "bad-request", NULL); |
58 if (g_slist_length(jn->content) < 1) { |
60 if (g_slist_length(jn->content) < 1) { |
59 jingle_send_iq_error(m, "cancel", "bad-request", NULL); |
61 jingle_send_iq_error(m, "cancel", "bad-request", NULL); |
60 return; |
62 return; |
61 } |
63 } |
62 |
64 |
63 // one of the content element must be a "session" |
65 /* When sending a session-initiate at least one <content/> element MUST have |
64 for (child = jn->content; child && !is_session; child = child->next) { |
66 * a disposition of "session"); if this rule is violated, the responder MUST |
65 if (g_strcmp0(((JingleContent*)(child->data))->disposition, "session") || |
67 * return a <bad-request/> error to the initiator. |
66 ((JingleContent*)(child->data))->disposition == NULL) // default: session |
68 */ |
67 is_session = TRUE; |
69 for (child = jn->content; child && !valid_disposition; child = child->next) { |
|
70 cn = (JingleContent*)(child->data); |
|
71 if (g_strcmp0(cn->disposition, "session") == 0 || cn->disposition == NULL) |
|
72 valid_disposition = TRUE; |
68 } |
73 } |
69 if (!is_session) { |
74 if (!valid_disposition) { |
70 jingle_send_iq_error(m, "cancel", "bad-request", NULL); |
75 jingle_send_iq_error(m, "cancel", "bad-request", NULL); |
71 return; |
76 return; |
72 } |
77 } |
73 |
78 |
74 // if a session with the same sid already exists |
79 // if a session with the same sid already exists |
78 } |
83 } |
79 |
84 |
80 jingle_ack_iq(m); |
85 jingle_ack_iq(m); |
81 |
86 |
82 for (child = jn->content; child; child = child->next) { |
87 for (child = jn->content; child; child = child->next) { |
83 cn = (JingleContent*)(child->data); |
88 cn = (JingleContent *)(child->data); |
84 |
89 |
85 af = jingle_get_appfuncs(cn->xmlns_desc); |
90 xmlns = lm_message_node_get_attribute(cn->description, "xmlns"); |
86 tf = jingle_get_transportfuncs(cn->xmlns_trans); |
91 appfuncs = jingle_get_appfuncs(xmlns); |
87 if (af == NULL && tf == NULL) continue; |
92 if (appfuncs == NULL) continue; |
88 |
93 |
89 cn->description = af->check(cn, NULL, NULL); |
94 xmlns = lm_message_node_get_attribute(cn->transport, "xmlns"); |
90 cn->transport = tf->check(cn, NULL, NULL); |
95 transfuncs = jingle_get_transportfuncs(xmlns); |
|
96 if (appfuncs == NULL) continue; // negociate another transport ? |
|
97 |
|
98 description = appfuncs->check(cn, &err); |
|
99 if (description == NULL || err != NULL) continue; |
|
100 transport = transfuncs->check(cn, &err); |
|
101 if (transport == NULL || err != NULL) continue; |
91 } |
102 } |
92 } |
103 } |
93 |
104 |
94 void handle_session_terminate(LmMessage *m, JingleNode *jn) |
105 void handle_session_terminate(LmMessage *m, JingleNode *jn) |
95 { |
106 { |