26 #include <jingle/jingle.h> |
26 #include <jingle/jingle.h> |
27 #include <jingle/check.h> |
27 #include <jingle/check.h> |
28 #include <jingle/sessions.h> |
28 #include <jingle/sessions.h> |
29 #include <jingle/register.h> |
29 #include <jingle/register.h> |
30 #include <jingle/send.h> |
30 #include <jingle/send.h> |
|
31 #include <jingle/action-handlers.h> |
31 |
32 |
32 /* The session-initiate action is used to request negotiation of a new Jingle |
33 /* The session-initiate action is used to request negotiation of a new Jingle |
33 * session. When sending a session-initiate with one <content/> element, the |
34 * session. When sending a session-initiate with one <content/> element, the |
34 * value of the <content/> element's 'disposition' attribute MUST be "session" |
35 * value of the <content/> element's 'disposition' attribute MUST be "session" |
35 * (if there are multiple <content/> elements then at least one MUST have a |
36 * (if there are multiple <content/> elements then at least one MUST have a |
57 return; |
58 return; |
58 } |
59 } |
59 |
60 |
60 // one of the content element must be a "session" |
61 // one of the content element must be a "session" |
61 for (child = jn->content; child && !is_session; child = child->next) { |
62 for (child = jn->content; child && !is_session; child = child->next) { |
62 if(g_strcmp0(((JingleContent*)(child->data))->disposition, "session") || |
63 if (g_strcmp0(((JingleContent*)(child->data))->disposition, "session") || |
63 ((JingleContent*)(child->data))->disposition == NULL) // default: session |
64 ((JingleContent*)(child->data))->disposition == NULL) // default: session |
64 is_session=TRUE; |
65 is_session=TRUE; |
65 } |
66 } |
66 if(!is_session) { |
67 if (!is_session) { |
67 jingle_send_iq_error(m, "cancel", "bad-request", NULL); |
68 jingle_send_iq_error(m, "cancel", "bad-request", NULL); |
68 return; |
69 return; |
69 } |
70 } |
70 |
71 |
71 // if a session with the same sid already exists |
72 // if a session with the same sid already exists |
81 jingle_ack_iq(m); |
82 jingle_ack_iq(m); |
82 |
83 |
83 is_session = FALSE; |
84 is_session = FALSE; |
84 // Do we support any of this xmlns ? |
85 // Do we support any of this xmlns ? |
85 for (child = jn->content; child && !is_session; child = child->next) { |
86 for (child = jn->content; child && !is_session; child = child->next) { |
86 if(jingle_get_appfuncs(((JingleContent*)(child->data))->xmlns_desc) != NULL) |
87 if (jingle_get_appfuncs(get_xmlnsdesc(child)) != NULL) |
87 is_session = TRUE; |
88 is_session = TRUE; |
88 } |
89 } |
89 if(!is_session) { // None of the app is supported |
90 if (!is_session) { // None of the app is supported |
90 jingle_send_session_terminate(m, "unsupported-applications"); |
91 jingle_send_session_terminate(m, "unsupported-applications"); |
91 return; |
92 return; |
92 } |
93 } |
93 |
94 |
94 is_session = FALSE; |
95 is_session = FALSE; |
95 // Do we support any of this xmlns ? |
96 // Do we support any of this xmlns ? |
96 for (child = jn->content; child && !is_session; child = child->next) { |
97 for (child = jn->content; child && !is_session; child = child->next) { |
97 if(jingle_get_transportfuncs(((JingleContent*)(child->data))->xmlns_trans) != NULL) |
98 if (jingle_get_transportfuncs(get_xmlnstrans(child)) != NULL) |
98 is_session = TRUE; |
99 is_session = TRUE; |
99 } |
100 } |
100 if(!is_session) { // None of the transport is supported |
101 if (!is_session) { // None of the transport is supported |
101 jingle_send_session_terminate(m, "unsupported-transports"); |
102 jingle_send_session_terminate(m, "unsupported-transports"); |
102 return; |
103 return; |
|
104 } |
|
105 |
|
106 // Next we ask parsing to the modules |
|
107 for (child = jn->content; child; child = child->next) { |
|
108 ((JingleContent*)(child->data))->description = jingle_get_appfuncs(get_xmlnsdesc(child))->check((JingleContent*)(child->data), NULL, NULL); |
|
109 ((JingleContent*)(child->data))->transport = jingle_get_appfuncs(get_xmlnstrans(child))->check((JingleContent*)(child->data), NULL, NULL); |
103 } |
110 } |
104 } |
111 } |
105 |
112 |
106 void handle_session_terminate(LmMessage *m, JingleNode *jn) |
113 void handle_session_terminate(LmMessage *m, JingleNode *jn) |
107 { |
114 { |
109 if ((sess = session_find(jn->sid, jn->from)) == NULL) { |
116 if ((sess = session_find(jn->sid, jn->from)) == NULL) { |
110 jingle_send_iq_error(m, "cancel", "item-not-found", "unknown-session"); |
117 jingle_send_iq_error(m, "cancel", "item-not-found", "unknown-session"); |
111 return; |
118 return; |
112 } |
119 } |
113 session_delete(sess); |
120 session_delete(sess); |
|
121 jingle_ack_iq(m); |
114 } |
122 } |
|
123 |
|
124 const gchar* get_xmlnstrans(const GSList* list) |
|
125 { |
|
126 return ((JingleContent*)(list->data))->xmlns_trans; |
|
127 } |
|
128 |
|
129 const gchar* get_xmlnsdesc(const GSList* list) |
|
130 { |
|
131 return ((JingleContent*)(list->data))->xmlns_desc; |
|
132 } |