Mercurial > pidgin
comparison libpurple/protocols/jabber/google.c @ 28645:7b4ade7c6d8a
jabber: Start putting all the namespaces in one location with consistent naming.
author | Paul Aurich <paul@darkrain42.org> |
---|---|
date | Thu, 26 Nov 2009 22:35:07 +0000 |
parents | fa7f3426ed13 |
children | 9feec7d1d95c |
comparison
equal
deleted
inserted
replaced
28644:932661a155b7 | 28645:7b4ade7c6d8a |
---|---|
34 #include "chat.h" | 34 #include "chat.h" |
35 | 35 |
36 #include "jingle/jingle.h" | 36 #include "jingle/jingle.h" |
37 | 37 |
38 #ifdef USE_VV | 38 #ifdef USE_VV |
39 | |
40 #define NS_GOOGLE_VIDEO "http://www.google.com/session/video" | |
41 #define NS_GOOGLE_PHONE "http://www.google.com/session/phone" | |
42 | 39 |
43 typedef struct { | 40 typedef struct { |
44 char *id; | 41 char *id; |
45 char *initiator; | 42 char *initiator; |
46 } GoogleSessionId; | 43 } GoogleSessionId; |
211 sess = google_session_create_xmlnode(session, "accept"); | 208 sess = google_session_create_xmlnode(session, "accept"); |
212 } | 209 } |
213 xmlnode_insert_child(iq->node, sess); | 210 xmlnode_insert_child(iq->node, sess); |
214 desc = xmlnode_new_child(sess, "description"); | 211 desc = xmlnode_new_child(sess, "description"); |
215 if (session->video) | 212 if (session->video) |
216 xmlnode_set_namespace(desc, NS_GOOGLE_VIDEO); | 213 xmlnode_set_namespace(desc, NS_GOOGLE_SESSION_VIDEO); |
217 else | 214 else |
218 xmlnode_set_namespace(desc, NS_GOOGLE_PHONE); | 215 xmlnode_set_namespace(desc, NS_GOOGLE_SESSION_PHONE); |
219 | 216 |
220 codecs = purple_media_get_codecs(media, "google-video"); | 217 codecs = purple_media_get_codecs(media, "google-video"); |
221 | 218 |
222 for (iter = codecs; iter; iter = g_list_next(iter)) { | 219 for (iter = codecs; iter; iter = g_list_next(iter)) { |
223 PurpleMediaCodec *codec = (PurpleMediaCodec*)iter->data; | 220 PurpleMediaCodec *codec = (PurpleMediaCodec*)iter->data; |
246 purple_media_codec_get_encoding_name(codec); | 243 purple_media_codec_get_encoding_name(codec); |
247 gchar *clock_rate = g_strdup_printf("%d", | 244 gchar *clock_rate = g_strdup_printf("%d", |
248 purple_media_codec_get_clock_rate(codec)); | 245 purple_media_codec_get_clock_rate(codec)); |
249 payload = xmlnode_new_child(desc, "payload-type"); | 246 payload = xmlnode_new_child(desc, "payload-type"); |
250 if (session->video) | 247 if (session->video) |
251 xmlnode_set_namespace(payload, NS_GOOGLE_PHONE); | 248 xmlnode_set_namespace(payload, NS_GOOGLE_SESSION_PHONE); |
252 xmlnode_set_attrib(payload, "id", id); | 249 xmlnode_set_attrib(payload, "id", id); |
253 /* | 250 /* |
254 * Hack to make Gmail accept speex as the codec. | 251 * Hack to make Gmail accept speex as the codec. |
255 * It shouldn't have to be case sensitive. | 252 * It shouldn't have to be case sensitive. |
256 */ | 253 */ |
437 } | 434 } |
438 | 435 |
439 desc_element = xmlnode_get_child(sess, "description"); | 436 desc_element = xmlnode_get_child(sess, "description"); |
440 xmlns = xmlnode_get_namespace(desc_element); | 437 xmlns = xmlnode_get_namespace(desc_element); |
441 | 438 |
442 if (purple_strequal(xmlns, NS_GOOGLE_PHONE)) | 439 if (purple_strequal(xmlns, NS_GOOGLE_SESSION_PHONE)) |
443 session->video = FALSE; | 440 session->video = FALSE; |
444 else if (purple_strequal(xmlns, NS_GOOGLE_VIDEO)) | 441 else if (purple_strequal(xmlns, NS_GOOGLE_SESSION_VIDEO)) |
445 session->video = TRUE; | 442 session->video = TRUE; |
446 else { | 443 else { |
447 purple_debug_error("jabber", "Received initiate with " | 444 purple_debug_error("jabber", "Received initiate with " |
448 "invalid namespace %s.\n", xmlns); | 445 "invalid namespace %s.\n", xmlns); |
449 return FALSE; | 446 return FALSE; |
496 xmlns = xmlnode_get_namespace(codec_element); | 493 xmlns = xmlnode_get_namespace(codec_element); |
497 encoding_name = xmlnode_get_attrib(codec_element, "name"); | 494 encoding_name = xmlnode_get_attrib(codec_element, "name"); |
498 id = xmlnode_get_attrib(codec_element, "id"); | 495 id = xmlnode_get_attrib(codec_element, "id"); |
499 | 496 |
500 if (!session->video || | 497 if (!session->video || |
501 (xmlns && !strcmp(xmlns, NS_GOOGLE_PHONE))) { | 498 (xmlns && !strcmp(xmlns, NS_GOOGLE_SESSION_PHONE))) { |
502 clock_rate = xmlnode_get_attrib( | 499 clock_rate = xmlnode_get_attrib( |
503 codec_element, "clockrate"); | 500 codec_element, "clockrate"); |
504 video = FALSE; | 501 video = FALSE; |
505 } else { | 502 } else { |
506 width = xmlnode_get_attrib(codec_element, "width"); | 503 width = xmlnode_get_attrib(codec_element, "width"); |
621 xmlnode *codec_element = xmlnode_get_child( | 618 xmlnode *codec_element = xmlnode_get_child( |
622 desc_element, "payload-type"); | 619 desc_element, "payload-type"); |
623 GList *codecs = NULL, *video_codecs = NULL; | 620 GList *codecs = NULL, *video_codecs = NULL; |
624 JabberIq *result = NULL; | 621 JabberIq *result = NULL; |
625 const gchar *xmlns = xmlnode_get_namespace(desc_element); | 622 const gchar *xmlns = xmlnode_get_namespace(desc_element); |
626 gboolean video = (xmlns && !strcmp(xmlns, NS_GOOGLE_VIDEO)); | 623 gboolean video = (xmlns && !strcmp(xmlns, NS_GOOGLE_SESSION_VIDEO)); |
627 | 624 |
628 for (; codec_element; codec_element = codec_element->next) { | 625 for (; codec_element; codec_element = codec_element->next) { |
629 const gchar *xmlns, *encoding_name, *id, | 626 const gchar *xmlns, *encoding_name, *id, |
630 *clock_rate, *width, *height, *framerate; | 627 *clock_rate, *width, *height, *framerate; |
631 gboolean video_codec = FALSE; | 628 gboolean video_codec = FALSE; |
635 | 632 |
636 xmlns = xmlnode_get_namespace(codec_element); | 633 xmlns = xmlnode_get_namespace(codec_element); |
637 encoding_name = xmlnode_get_attrib(codec_element, "name"); | 634 encoding_name = xmlnode_get_attrib(codec_element, "name"); |
638 id = xmlnode_get_attrib(codec_element, "id"); | 635 id = xmlnode_get_attrib(codec_element, "id"); |
639 | 636 |
640 if (!video || purple_strequal(xmlns, NS_GOOGLE_PHONE)) | 637 if (!video || purple_strequal(xmlns, NS_GOOGLE_SESSION_PHONE)) |
641 clock_rate = xmlnode_get_attrib( | 638 clock_rate = xmlnode_get_attrib( |
642 codec_element, "clockrate"); | 639 codec_element, "clockrate"); |
643 else { | 640 else { |
644 clock_rate = "90000"; | 641 clock_rate = "90000"; |
645 width = xmlnode_get_attrib(codec_element, "width"); | 642 width = xmlnode_get_attrib(codec_element, "width"); |
1399 jabber_google_jingle_info_cb(JabberStream *js, const char *from, | 1396 jabber_google_jingle_info_cb(JabberStream *js, const char *from, |
1400 JabberIqType type, const char *id, | 1397 JabberIqType type, const char *id, |
1401 xmlnode *packet, gpointer data) | 1398 xmlnode *packet, gpointer data) |
1402 { | 1399 { |
1403 xmlnode *query = xmlnode_get_child_with_namespace(packet, "query", | 1400 xmlnode *query = xmlnode_get_child_with_namespace(packet, "query", |
1404 GOOGLE_JINGLE_INFO_NAMESPACE); | 1401 NS_GOOGLE_JINGLE_INFO); |
1405 | 1402 |
1406 if (query) | 1403 if (query) |
1407 jabber_google_jingle_info_common(js, from, type, query); | 1404 jabber_google_jingle_info_common(js, from, type, query); |
1408 else | 1405 else |
1409 purple_debug_warning("jabber", "Got invalid google:jingleinfo\n"); | 1406 purple_debug_warning("jabber", "Got invalid google:jingleinfo\n"); |
1419 | 1416 |
1420 void | 1417 void |
1421 jabber_google_send_jingle_info(JabberStream *js) | 1418 jabber_google_send_jingle_info(JabberStream *js) |
1422 { | 1419 { |
1423 JabberIq *jingle_info = | 1420 JabberIq *jingle_info = |
1424 jabber_iq_new_query(js, JABBER_IQ_GET, GOOGLE_JINGLE_INFO_NAMESPACE); | 1421 jabber_iq_new_query(js, JABBER_IQ_GET, NS_GOOGLE_JINGLE_INFO); |
1425 | 1422 |
1426 jabber_iq_set_callback(jingle_info, jabber_google_jingle_info_cb, | 1423 jabber_iq_set_callback(jingle_info, jabber_google_jingle_info_cb, |
1427 NULL); | 1424 NULL); |
1428 purple_debug_info("jabber", "sending google:jingleinfo query\n"); | 1425 purple_debug_info("jabber", "sending google:jingleinfo query\n"); |
1429 jabber_iq_send(jingle_info); | 1426 jabber_iq_send(jingle_info); |