libpurple/protocols/jabber/google.c

branch
cpw.malu.xmpp.google_relay
changeset 29468
b9903398d8be
parent 28844
11123464441f
parent 28984
1d84517d56eb
child 29469
94ef289c5587
equal deleted inserted replaced
28970:80d34d015bb2 29468:b9903398d8be
35 35
36 #include "jingle/jingle.h" 36 #include "jingle/jingle.h"
37 37
38 #ifdef USE_VV 38 #ifdef USE_VV
39 39
40 #define NS_GOOGLE_VIDEO "http://www.google.com/session/video"
41 #define NS_GOOGLE_PHONE "http://www.google.com/session/phone"
42
43 typedef struct { 40 typedef struct {
44 char *id; 41 char *id;
45 char *initiator; 42 char *initiator;
46 } GoogleSessionId; 43 } GoogleSessionId;
47 44
84 81
85 static xmlnode * 82 static xmlnode *
86 google_session_create_xmlnode(GoogleSession *session, const char *type) 83 google_session_create_xmlnode(GoogleSession *session, const char *type)
87 { 84 {
88 xmlnode *node = xmlnode_new("session"); 85 xmlnode *node = xmlnode_new("session");
89 xmlnode_set_namespace(node, "http://www.google.com/session"); 86 xmlnode_set_namespace(node, NS_GOOGLE_SESSION);
90 xmlnode_set_attrib(node, "id", session->id.id); 87 xmlnode_set_attrib(node, "id", session->id.id);
91 xmlnode_set_attrib(node, "initiator", session->id.initiator); 88 xmlnode_set_attrib(node, "initiator", session->id.initiator);
92 xmlnode_set_attrib(node, "type", type); 89 xmlnode_set_attrib(node, "type", type);
93 return node; 90 return node;
94 } 91 }
213 sess = google_session_create_xmlnode(session, "accept"); 210 sess = google_session_create_xmlnode(session, "accept");
214 } 211 }
215 xmlnode_insert_child(iq->node, sess); 212 xmlnode_insert_child(iq->node, sess);
216 desc = xmlnode_new_child(sess, "description"); 213 desc = xmlnode_new_child(sess, "description");
217 if (session->video) 214 if (session->video)
218 xmlnode_set_namespace(desc, NS_GOOGLE_VIDEO); 215 xmlnode_set_namespace(desc, NS_GOOGLE_SESSION_VIDEO);
219 else 216 else
220 xmlnode_set_namespace(desc, NS_GOOGLE_PHONE); 217 xmlnode_set_namespace(desc, NS_GOOGLE_SESSION_PHONE);
221 218
222 codecs = purple_media_get_codecs(media, "google-video"); 219 codecs = purple_media_get_codecs(media, "google-video");
223 220
224 for (iter = codecs; iter; iter = g_list_next(iter)) { 221 for (iter = codecs; iter; iter = g_list_next(iter)) {
225 PurpleMediaCodec *codec = (PurpleMediaCodec*)iter->data; 222 PurpleMediaCodec *codec = (PurpleMediaCodec*)iter->data;
248 purple_media_codec_get_encoding_name(codec); 245 purple_media_codec_get_encoding_name(codec);
249 gchar *clock_rate = g_strdup_printf("%d", 246 gchar *clock_rate = g_strdup_printf("%d",
250 purple_media_codec_get_clock_rate(codec)); 247 purple_media_codec_get_clock_rate(codec));
251 payload = xmlnode_new_child(desc, "payload-type"); 248 payload = xmlnode_new_child(desc, "payload-type");
252 if (session->video) 249 if (session->video)
253 xmlnode_set_namespace(payload, NS_GOOGLE_PHONE); 250 xmlnode_set_namespace(payload, NS_GOOGLE_SESSION_PHONE);
254 xmlnode_set_attrib(payload, "id", id); 251 xmlnode_set_attrib(payload, "id", id);
255 /* 252 /*
256 * Hack to make Gmail accept speex as the codec. 253 * Hack to make Gmail accept speex as the codec.
257 * It shouldn't have to be case sensitive. 254 * It shouldn't have to be case sensitive.
258 */ 255 */
611 xmlns = xmlnode_get_namespace(codec_element); 608 xmlns = xmlnode_get_namespace(codec_element);
612 encoding_name = xmlnode_get_attrib(codec_element, "name"); 609 encoding_name = xmlnode_get_attrib(codec_element, "name");
613 id = xmlnode_get_attrib(codec_element, "id"); 610 id = xmlnode_get_attrib(codec_element, "id");
614 611
615 if (!session->video || 612 if (!session->video ||
616 (xmlns && !strcmp(xmlns, NS_GOOGLE_PHONE))) { 613 (xmlns && !strcmp(xmlns, NS_GOOGLE_SESSION_PHONE))) {
617 clock_rate = xmlnode_get_attrib( 614 clock_rate = xmlnode_get_attrib(
618 codec_element, "clockrate"); 615 codec_element, "clockrate");
619 video = FALSE; 616 video = FALSE;
620 } else { 617 } else {
621 width = xmlnode_get_attrib(codec_element, "width"); 618 width = xmlnode_get_attrib(codec_element, "width");
788 xmlnode *codec_element = xmlnode_get_child( 785 xmlnode *codec_element = xmlnode_get_child(
789 desc_element, "payload-type"); 786 desc_element, "payload-type");
790 GList *codecs = NULL, *video_codecs = NULL; 787 GList *codecs = NULL, *video_codecs = NULL;
791 JabberIq *result = NULL; 788 JabberIq *result = NULL;
792 const gchar *xmlns = xmlnode_get_namespace(desc_element); 789 const gchar *xmlns = xmlnode_get_namespace(desc_element);
793 gboolean video = (xmlns && !strcmp(xmlns, NS_GOOGLE_VIDEO)); 790 gboolean video = (xmlns && !strcmp(xmlns, NS_GOOGLE_SESSION_VIDEO));
794 791
795 for (; codec_element; codec_element = codec_element->next) { 792 for (; codec_element; codec_element = codec_element->next) {
796 const gchar *xmlns, *encoding_name, *id, 793 const gchar *xmlns, *encoding_name, *id,
797 *clock_rate, *width, *height, *framerate; 794 *clock_rate, *width, *height, *framerate;
798 gboolean video_codec = FALSE; 795 gboolean video_codec = FALSE;
802 799
803 xmlns = xmlnode_get_namespace(codec_element); 800 xmlns = xmlnode_get_namespace(codec_element);
804 encoding_name = xmlnode_get_attrib(codec_element, "name"); 801 encoding_name = xmlnode_get_attrib(codec_element, "name");
805 id = xmlnode_get_attrib(codec_element, "id"); 802 id = xmlnode_get_attrib(codec_element, "id");
806 803
807 if (!video || purple_strequal(xmlns, NS_GOOGLE_PHONE)) 804 if (!video || purple_strequal(xmlns, NS_GOOGLE_SESSION_PHONE))
808 clock_rate = xmlnode_get_attrib( 805 clock_rate = xmlnode_get_attrib(
809 codec_element, "clockrate"); 806 codec_element, "clockrate");
810 else { 807 else {
811 clock_rate = "90000"; 808 clock_rate = "90000";
812 width = xmlnode_get_attrib(codec_element, "width"); 809 width = xmlnode_get_attrib(codec_element, "width");
1078 jabber_iq_send(iq); 1075 jabber_iq_send(iq);
1079 1076
1080 purple_debug_misc("jabber", 1077 purple_debug_misc("jabber",
1081 "Got new mail notification. Sending request for more info\n"); 1078 "Got new mail notification. Sending request for more info\n");
1082 1079
1083 iq = jabber_iq_new_query(js, JABBER_IQ_GET, "google:mail:notify"); 1080 iq = jabber_iq_new_query(js, JABBER_IQ_GET, NS_GOOGLE_MAIL_NOTIFY);
1084 jabber_iq_set_callback(iq, jabber_gmail_parse, NULL); 1081 jabber_iq_set_callback(iq, jabber_gmail_parse, NULL);
1085 query = xmlnode_get_child(iq->node, "query"); 1082 query = xmlnode_get_child(iq->node, "query");
1086 1083
1087 if (js->gmail_last_time) 1084 if (js->gmail_last_time)
1088 xmlnode_set_attrib(query, "newer-than-time", js->gmail_last_time); 1085 xmlnode_set_attrib(query, "newer-than-time", js->gmail_last_time);
1112 xmlnode_set_namespace(usersetting, "google:setting"); 1109 xmlnode_set_namespace(usersetting, "google:setting");
1113 mailnotifications = xmlnode_new_child(usersetting, "mailnotifications"); 1110 mailnotifications = xmlnode_new_child(usersetting, "mailnotifications");
1114 xmlnode_set_attrib(mailnotifications, "value", "true"); 1111 xmlnode_set_attrib(mailnotifications, "value", "true");
1115 jabber_iq_send(iq); 1112 jabber_iq_send(iq);
1116 1113
1117 iq = jabber_iq_new_query(js, JABBER_IQ_GET, "google:mail:notify"); 1114 iq = jabber_iq_new_query(js, JABBER_IQ_GET, NS_GOOGLE_MAIL_NOTIFY);
1118 jabber_iq_set_callback(iq, jabber_gmail_parse, NULL); 1115 jabber_iq_set_callback(iq, jabber_gmail_parse, NULL);
1119 jabber_iq_send(iq); 1116 jabber_iq_send(iq);
1120 } 1117 }
1121 1118
1122 void jabber_google_roster_init(JabberStream *js) 1119 void jabber_google_roster_init(JabberStream *js)
1582 jabber_google_jingle_info_cb(JabberStream *js, const char *from, 1579 jabber_google_jingle_info_cb(JabberStream *js, const char *from,
1583 JabberIqType type, const char *id, 1580 JabberIqType type, const char *id,
1584 xmlnode *packet, gpointer data) 1581 xmlnode *packet, gpointer data)
1585 { 1582 {
1586 xmlnode *query = xmlnode_get_child_with_namespace(packet, "query", 1583 xmlnode *query = xmlnode_get_child_with_namespace(packet, "query",
1587 GOOGLE_JINGLE_INFO_NAMESPACE); 1584 NS_GOOGLE_JINGLE_INFO);
1588 1585
1589 if (query) 1586 if (query)
1590 jabber_google_jingle_info_common(js, from, type, query); 1587 jabber_google_jingle_info_common(js, from, type, query);
1591 else 1588 else
1592 purple_debug_warning("jabber", "Got invalid google:jingleinfo\n"); 1589 purple_debug_warning("jabber", "Got invalid google:jingleinfo\n");
1602 1599
1603 void 1600 void
1604 jabber_google_send_jingle_info(JabberStream *js) 1601 jabber_google_send_jingle_info(JabberStream *js)
1605 { 1602 {
1606 JabberIq *jingle_info = 1603 JabberIq *jingle_info =
1607 jabber_iq_new_query(js, JABBER_IQ_GET, GOOGLE_JINGLE_INFO_NAMESPACE); 1604 jabber_iq_new_query(js, JABBER_IQ_GET, NS_GOOGLE_JINGLE_INFO);
1608 1605
1609 jabber_iq_set_callback(jingle_info, jabber_google_jingle_info_cb, 1606 jabber_iq_set_callback(jingle_info, jabber_google_jingle_info_cb,
1610 NULL); 1607 NULL);
1611 purple_debug_info("jabber", "sending google:jingleinfo query\n"); 1608 purple_debug_info("jabber", "sending google:jingleinfo query\n");
1612 jabber_iq_send(jingle_info); 1609 jabber_iq_send(jingle_info);

mercurial