equal
deleted
inserted
replaced
20 */ |
20 */ |
21 |
21 |
22 #include <glib.h> |
22 #include <glib.h> |
23 |
23 |
24 #include <mcabber/logprint.h> |
24 #include <mcabber/logprint.h> |
|
25 #include <mcabber/xmpp.h> |
25 |
26 |
26 #include <jingle/jingle.h> |
27 #include <jingle/jingle.h> |
27 #include <jingle/sessions.h> |
28 #include <jingle/sessions.h> |
28 #include <jingle/register.h> |
29 #include <jingle/register.h> |
29 #include <jingle/send.h> |
30 #include <jingle/send.h> |
174 return sc; |
175 return sc; |
175 } |
176 } |
176 return NULL; |
177 return NULL; |
177 } |
178 } |
178 |
179 |
179 SessionContent *session_find_by_transport(gconstpointer data) |
180 JingleSession *session_find_by_transport(gconstpointer data) |
|
181 { |
|
182 GSList *el, *el1; |
|
183 JingleSession *sess; |
|
184 SessionContent *sc; |
|
185 for (el1 = sessions; el1; el1 = el1->next) { |
|
186 sess = (JingleSession*) el1->data; |
|
187 for (el = sess->content; el; el = el->next) { |
|
188 sc = (SessionContent*) el->data; |
|
189 if (data == sc->transport) |
|
190 return sess; |
|
191 } |
|
192 } |
|
193 return NULL; |
|
194 } |
|
195 |
|
196 JingleSession *session_find_by_app(gconstpointer data) |
|
197 { |
|
198 GSList *el, *el1; |
|
199 JingleSession *sess; |
|
200 SessionContent *sc; |
|
201 for (el1 = sessions; el1; el1 = el1->next) { |
|
202 sess = (JingleSession*) el1->data; |
|
203 for (el = sess->content; el; el = el->next) { |
|
204 sc = (SessionContent*) el->data; |
|
205 if (data == sc->description) |
|
206 return sess; |
|
207 } |
|
208 } |
|
209 return NULL; |
|
210 } |
|
211 |
|
212 SessionContent *sessioncontent_find_by_transport(gconstpointer data) |
180 { |
213 { |
181 GSList *el, *el1; |
214 GSList *el, *el1; |
182 JingleSession *sess; |
215 JingleSession *sess; |
183 SessionContent *sc; |
216 SessionContent *sc; |
184 for (el1 = sessions; el1; el1 = el1->next) { |
217 for (el1 = sessions; el1; el1 = el1->next) { |
190 } |
223 } |
191 } |
224 } |
192 return NULL; |
225 return NULL; |
193 } |
226 } |
194 |
227 |
195 SessionContent *session_find_by_app(gconstpointer data) |
228 SessionContent *sessioncontent_find_by_app(gconstpointer data) |
196 { |
229 { |
197 GSList *el, *el1; |
230 GSList *el, *el1; |
198 JingleSession *sess; |
231 JingleSession *sess; |
199 SessionContent *sc; |
232 SessionContent *sc; |
200 for (el1 = sessions; el1; el1 = el1->next) { |
233 for (el1 = sessions; el1; el1 = el1->next) { |
206 } |
239 } |
207 } |
240 } |
208 return NULL; |
241 return NULL; |
209 } |
242 } |
210 |
243 |
|
244 JingleSession *session_find_by_sessioncontent(SessionContent *data) |
|
245 { |
|
246 GSList *el, *el1; |
|
247 JingleSession *sess; |
|
248 SessionContent *sc; |
|
249 for (el1 = sessions; el1; el1 = el1->next) { |
|
250 sess = (JingleSession*) el1->data; |
|
251 for (el = sess->content; el; el = el->next) { |
|
252 sc = (SessionContent*) el->data; |
|
253 if (data == sc) |
|
254 return sess; |
|
255 } |
|
256 } |
|
257 return NULL; |
|
258 } |
|
259 |
211 gint session_remove_sessioncontent(JingleSession *sess, const gchar *name) |
260 gint session_remove_sessioncontent(JingleSession *sess, const gchar *name) |
212 { |
261 { |
213 SessionContent *sc; |
262 SessionContent *sc; |
214 sc = session_find_sessioncontent(sess, name); |
263 sc = session_find_sessioncontent(sess, name); |
215 if(sc == NULL) return 0; |
264 if(sc == NULL) return 0; |
268 } |
317 } |
269 |
318 |
270 g_free(sess); |
319 g_free(sess); |
271 } |
320 } |
272 |
321 |
273 void jingle_handle_app(JingleSession *sess, const gchar *name, |
322 void jingle_handle_app(const gchar *name, |
274 const gchar *xmlns_app, gconstpointer app, |
323 const gchar *xmlns_app, gconstpointer app, |
275 const gchar *to) |
324 const gchar *to) |
276 { |
325 { |
|
326 JingleSession *sess = session_find_by_app(app); |
277 const gchar *xmlns = jingle_transport_for_app(xmlns_app, NULL); |
327 const gchar *xmlns = jingle_transport_for_app(xmlns_app, NULL); |
278 JingleTransportFuncs *trans = jingle_get_transportfuncs(xmlns); |
328 JingleTransportFuncs *trans = jingle_get_transportfuncs(xmlns); |
279 |
329 |
280 if (trans == NULL) { |
330 if (trans == NULL) { |
281 scr_LogPrint(LPRINT_LOGNORM, "Unable to find a transport for %s", xmlns_app); |
331 scr_LogPrint(LPRINT_LOGNORM, "Unable to find a transport for %s", xmlns_app); |
344 if (size != 0) |
394 if (size != 0) |
345 sc->transfuncs->send(sc2, sc->transport, data, size); |
395 sc->transfuncs->send(sc2, sc->transport, data, size); |
346 else |
396 else |
347 sc->transfuncs->end(sc2, sc->transport); |
397 sc->transfuncs->end(sc2, sc->transport); |
348 } |
398 } |
|
399 |
|
400 void new_session_with_apps(const gchar *recipientjid, const gchar **names, |
|
401 gconstpointer *datas, const gchar **ns) |
|
402 { |
|
403 const gchar *myjid = g_strdup(lm_connection_get_jid(lconnection)); |
|
404 gchar *sid = jingle_generate_sid(); |
|
405 JingleSession *sess = session_new(sid, myjid, recipientjid, JINGLE_SESSION_OUTGOING); |
|
406 const gchar **name, **el1 = ns; |
|
407 gconstpointer *data1 = datas; |
|
408 |
|
409 for (name = names; name; ++name) { |
|
410 session_add_content(sess, *name, JINGLE_SESSION_STATE_PENDING); |
|
411 session_add_app(sess, *name, *el1, *data1); |
|
412 if (!++data1 || !++el1) |
|
413 break; |
|
414 } |
|
415 g_free(sid); |
|
416 } |