Mercurial > pidgin.yaz
comparison libpurple/protocols/jabber/google.c @ 29070:5c77b620375c
merged with im.pidgin.pidgin
author | Yoshiki Yazawa <yaz@honeyplanet.jp> |
---|---|
date | Mon, 30 Nov 2009 16:07:54 +0900 |
parents | 08a52bdd9619 9ae3e70a327b |
children | 4491a662d527 |
comparison
equal
deleted
inserted
replaced
29018:1929b7a0c2c8 | 29070:5c77b620375c |
---|---|
36 | 36 |
37 #include "jingle/jingle.h" | 37 #include "jingle/jingle.h" |
38 | 38 |
39 #ifdef USE_VV | 39 #ifdef USE_VV |
40 | 40 |
41 #define NS_GOOGLE_VIDEO "http://www.google.com/session/video" | |
42 #define NS_GOOGLE_PHONE "http://www.google.com/session/phone" | |
43 | |
44 typedef struct { | 41 typedef struct { |
45 char *id; | 42 char *id; |
46 char *initiator; | 43 char *initiator; |
47 } GoogleSessionId; | 44 } GoogleSessionId; |
48 | 45 |
83 | 80 |
84 static xmlnode * | 81 static xmlnode * |
85 google_session_create_xmlnode(GoogleSession *session, const char *type) | 82 google_session_create_xmlnode(GoogleSession *session, const char *type) |
86 { | 83 { |
87 xmlnode *node = xmlnode_new("session"); | 84 xmlnode *node = xmlnode_new("session"); |
88 xmlnode_set_namespace(node, "http://www.google.com/session"); | 85 xmlnode_set_namespace(node, NS_GOOGLE_SESSION); |
89 xmlnode_set_attrib(node, "id", session->id.id); | 86 xmlnode_set_attrib(node, "id", session->id.id); |
90 xmlnode_set_attrib(node, "initiator", session->id.initiator); | 87 xmlnode_set_attrib(node, "initiator", session->id.initiator); |
91 xmlnode_set_attrib(node, "type", type); | 88 xmlnode_set_attrib(node, "type", type); |
92 return node; | 89 return node; |
93 } | 90 } |
212 sess = google_session_create_xmlnode(session, "accept"); | 209 sess = google_session_create_xmlnode(session, "accept"); |
213 } | 210 } |
214 xmlnode_insert_child(iq->node, sess); | 211 xmlnode_insert_child(iq->node, sess); |
215 desc = xmlnode_new_child(sess, "description"); | 212 desc = xmlnode_new_child(sess, "description"); |
216 if (session->video) | 213 if (session->video) |
217 xmlnode_set_namespace(desc, NS_GOOGLE_VIDEO); | 214 xmlnode_set_namespace(desc, NS_GOOGLE_SESSION_VIDEO); |
218 else | 215 else |
219 xmlnode_set_namespace(desc, NS_GOOGLE_PHONE); | 216 xmlnode_set_namespace(desc, NS_GOOGLE_SESSION_PHONE); |
220 | 217 |
221 codecs = purple_media_get_codecs(media, "google-video"); | 218 codecs = purple_media_get_codecs(media, "google-video"); |
222 | 219 |
223 for (iter = codecs; iter; iter = g_list_next(iter)) { | 220 for (iter = codecs; iter; iter = g_list_next(iter)) { |
224 PurpleMediaCodec *codec = (PurpleMediaCodec*)iter->data; | 221 PurpleMediaCodec *codec = (PurpleMediaCodec*)iter->data; |
247 purple_media_codec_get_encoding_name(codec); | 244 purple_media_codec_get_encoding_name(codec); |
248 gchar *clock_rate = g_strdup_printf("%d", | 245 gchar *clock_rate = g_strdup_printf("%d", |
249 purple_media_codec_get_clock_rate(codec)); | 246 purple_media_codec_get_clock_rate(codec)); |
250 payload = xmlnode_new_child(desc, "payload-type"); | 247 payload = xmlnode_new_child(desc, "payload-type"); |
251 if (session->video) | 248 if (session->video) |
252 xmlnode_set_namespace(payload, NS_GOOGLE_PHONE); | 249 xmlnode_set_namespace(payload, NS_GOOGLE_SESSION_PHONE); |
253 xmlnode_set_attrib(payload, "id", id); | 250 xmlnode_set_attrib(payload, "id", id); |
254 /* | 251 /* |
255 * Hack to make Gmail accept speex as the codec. | 252 * Hack to make Gmail accept speex as the codec. |
256 * It shouldn't have to be case sensitive. | 253 * It shouldn't have to be case sensitive. |
257 */ | 254 */ |
438 } | 435 } |
439 | 436 |
440 desc_element = xmlnode_get_child(sess, "description"); | 437 desc_element = xmlnode_get_child(sess, "description"); |
441 xmlns = xmlnode_get_namespace(desc_element); | 438 xmlns = xmlnode_get_namespace(desc_element); |
442 | 439 |
443 if (purple_strequal(xmlns, NS_GOOGLE_PHONE)) | 440 if (purple_strequal(xmlns, NS_GOOGLE_SESSION_PHONE)) |
444 session->video = FALSE; | 441 session->video = FALSE; |
445 else if (purple_strequal(xmlns, NS_GOOGLE_VIDEO)) | 442 else if (purple_strequal(xmlns, NS_GOOGLE_SESSION_VIDEO)) |
446 session->video = TRUE; | 443 session->video = TRUE; |
447 else { | 444 else { |
448 purple_debug_error("jabber", "Received initiate with " | 445 purple_debug_error("jabber", "Received initiate with " |
449 "invalid namespace %s.\n", xmlns); | 446 "invalid namespace %s.\n", xmlns); |
450 return FALSE; | 447 return FALSE; |
497 xmlns = xmlnode_get_namespace(codec_element); | 494 xmlns = xmlnode_get_namespace(codec_element); |
498 encoding_name = xmlnode_get_attrib(codec_element, "name"); | 495 encoding_name = xmlnode_get_attrib(codec_element, "name"); |
499 id = xmlnode_get_attrib(codec_element, "id"); | 496 id = xmlnode_get_attrib(codec_element, "id"); |
500 | 497 |
501 if (!session->video || | 498 if (!session->video || |
502 (xmlns && !strcmp(xmlns, NS_GOOGLE_PHONE))) { | 499 (xmlns && !strcmp(xmlns, NS_GOOGLE_SESSION_PHONE))) { |
503 clock_rate = xmlnode_get_attrib( | 500 clock_rate = xmlnode_get_attrib( |
504 codec_element, "clockrate"); | 501 codec_element, "clockrate"); |
505 video = FALSE; | 502 video = FALSE; |
506 } else { | 503 } else { |
507 width = xmlnode_get_attrib(codec_element, "width"); | 504 width = xmlnode_get_attrib(codec_element, "width"); |
622 xmlnode *codec_element = xmlnode_get_child( | 619 xmlnode *codec_element = xmlnode_get_child( |
623 desc_element, "payload-type"); | 620 desc_element, "payload-type"); |
624 GList *codecs = NULL, *video_codecs = NULL; | 621 GList *codecs = NULL, *video_codecs = NULL; |
625 JabberIq *result = NULL; | 622 JabberIq *result = NULL; |
626 const gchar *xmlns = xmlnode_get_namespace(desc_element); | 623 const gchar *xmlns = xmlnode_get_namespace(desc_element); |
627 gboolean video = (xmlns && !strcmp(xmlns, NS_GOOGLE_VIDEO)); | 624 gboolean video = (xmlns && !strcmp(xmlns, NS_GOOGLE_SESSION_VIDEO)); |
628 | 625 |
629 for (; codec_element; codec_element = codec_element->next) { | 626 for (; codec_element; codec_element = codec_element->next) { |
630 const gchar *xmlns, *encoding_name, *id, | 627 const gchar *xmlns, *encoding_name, *id, |
631 *clock_rate, *width, *height, *framerate; | 628 *clock_rate, *width, *height, *framerate; |
632 gboolean video_codec = FALSE; | 629 gboolean video_codec = FALSE; |
636 | 633 |
637 xmlns = xmlnode_get_namespace(codec_element); | 634 xmlns = xmlnode_get_namespace(codec_element); |
638 encoding_name = xmlnode_get_attrib(codec_element, "name"); | 635 encoding_name = xmlnode_get_attrib(codec_element, "name"); |
639 id = xmlnode_get_attrib(codec_element, "id"); | 636 id = xmlnode_get_attrib(codec_element, "id"); |
640 | 637 |
641 if (!video || purple_strequal(xmlns, NS_GOOGLE_PHONE)) | 638 if (!video || purple_strequal(xmlns, NS_GOOGLE_SESSION_PHONE)) |
642 clock_rate = xmlnode_get_attrib( | 639 clock_rate = xmlnode_get_attrib( |
643 codec_element, "clockrate"); | 640 codec_element, "clockrate"); |
644 else { | 641 else { |
645 clock_rate = "90000"; | 642 clock_rate = "90000"; |
646 width = xmlnode_get_attrib(codec_element, "width"); | 643 width = xmlnode_get_attrib(codec_element, "width"); |
912 jabber_iq_send(iq); | 909 jabber_iq_send(iq); |
913 | 910 |
914 purple_debug_misc("jabber", | 911 purple_debug_misc("jabber", |
915 "Got new mail notification. Sending request for more info\n"); | 912 "Got new mail notification. Sending request for more info\n"); |
916 | 913 |
917 iq = jabber_iq_new_query(js, JABBER_IQ_GET, "google:mail:notify"); | 914 iq = jabber_iq_new_query(js, JABBER_IQ_GET, NS_GOOGLE_MAIL_NOTIFY); |
918 jabber_iq_set_callback(iq, jabber_gmail_parse, NULL); | 915 jabber_iq_set_callback(iq, jabber_gmail_parse, NULL); |
919 query = xmlnode_get_child(iq->node, "query"); | 916 query = xmlnode_get_child(iq->node, "query"); |
920 | 917 |
921 if (js->gmail_last_time) | 918 if (js->gmail_last_time) |
922 xmlnode_set_attrib(query, "newer-than-time", js->gmail_last_time); | 919 xmlnode_set_attrib(query, "newer-than-time", js->gmail_last_time); |
946 xmlnode_set_namespace(usersetting, "google:setting"); | 943 xmlnode_set_namespace(usersetting, "google:setting"); |
947 mailnotifications = xmlnode_new_child(usersetting, "mailnotifications"); | 944 mailnotifications = xmlnode_new_child(usersetting, "mailnotifications"); |
948 xmlnode_set_attrib(mailnotifications, "value", "true"); | 945 xmlnode_set_attrib(mailnotifications, "value", "true"); |
949 jabber_iq_send(iq); | 946 jabber_iq_send(iq); |
950 | 947 |
951 iq = jabber_iq_new_query(js, JABBER_IQ_GET, "google:mail:notify"); | 948 iq = jabber_iq_new_query(js, JABBER_IQ_GET, NS_GOOGLE_MAIL_NOTIFY); |
952 jabber_iq_set_callback(iq, jabber_gmail_parse, NULL); | 949 jabber_iq_set_callback(iq, jabber_gmail_parse, NULL); |
953 jabber_iq_send(iq); | 950 jabber_iq_send(iq); |
954 } | 951 } |
955 | 952 |
956 void jabber_google_roster_init(JabberStream *js) | 953 void jabber_google_roster_init(JabberStream *js) |
1403 jabber_google_jingle_info_cb(JabberStream *js, const char *from, | 1400 jabber_google_jingle_info_cb(JabberStream *js, const char *from, |
1404 JabberIqType type, const char *id, | 1401 JabberIqType type, const char *id, |
1405 xmlnode *packet, gpointer data) | 1402 xmlnode *packet, gpointer data) |
1406 { | 1403 { |
1407 xmlnode *query = xmlnode_get_child_with_namespace(packet, "query", | 1404 xmlnode *query = xmlnode_get_child_with_namespace(packet, "query", |
1408 GOOGLE_JINGLE_INFO_NAMESPACE); | 1405 NS_GOOGLE_JINGLE_INFO); |
1409 | 1406 |
1410 if (query) | 1407 if (query) |
1411 jabber_google_jingle_info_common(js, from, type, query); | 1408 jabber_google_jingle_info_common(js, from, type, query); |
1412 else | 1409 else |
1413 purple_debug_warning("jabber", "Got invalid google:jingleinfo\n"); | 1410 purple_debug_warning("jabber", "Got invalid google:jingleinfo\n"); |
1423 | 1420 |
1424 void | 1421 void |
1425 jabber_google_send_jingle_info(JabberStream *js) | 1422 jabber_google_send_jingle_info(JabberStream *js) |
1426 { | 1423 { |
1427 JabberIq *jingle_info = | 1424 JabberIq *jingle_info = |
1428 jabber_iq_new_query(js, JABBER_IQ_GET, GOOGLE_JINGLE_INFO_NAMESPACE); | 1425 jabber_iq_new_query(js, JABBER_IQ_GET, NS_GOOGLE_JINGLE_INFO); |
1429 | 1426 |
1430 jabber_iq_set_callback(jingle_info, jabber_google_jingle_info_cb, | 1427 jabber_iq_set_callback(jingle_info, jabber_google_jingle_info_cb, |
1431 NULL); | 1428 NULL); |
1432 purple_debug_info("jabber", "sending google:jingleinfo query\n"); | 1429 purple_debug_info("jabber", "sending google:jingleinfo query\n"); |
1433 jabber_iq_send(jingle_info); | 1430 jabber_iq_send(jingle_info); |