Mercurial > pidgin
comparison libpurple/protocols/jabber/google.c @ 26932:a8537bbcfb79
Remove trailing whitespace that has snuck in.
author | Paul Aurich <paul@darkrain42.org> |
---|---|
date | Fri, 22 May 2009 03:54:29 +0000 |
parents | f924c19ad9c2 |
children | 6e8f56783e97 |
comparison
equal
deleted
inserted
replaced
26931:6105fa42b60c | 26932:a8537bbcfb79 |
---|---|
51 | 51 |
52 typedef struct { | 52 typedef struct { |
53 GoogleSessionId id; | 53 GoogleSessionId id; |
54 GoogleSessionState state; | 54 GoogleSessionState state; |
55 PurpleMedia *media; | 55 PurpleMedia *media; |
56 JabberStream *js; | 56 JabberStream *js; |
57 char *remote_jid; | 57 char *remote_jid; |
58 } GoogleSession; | 58 } GoogleSession; |
59 | 59 |
60 static gboolean | 60 static gboolean |
61 google_session_id_equal(gconstpointer a, gconstpointer b) | 61 google_session_id_equal(gconstpointer a, gconstpointer b) |
62 { | 62 { |
63 GoogleSessionId *c = (GoogleSessionId*)a; | 63 GoogleSessionId *c = (GoogleSessionId*)a; |
64 GoogleSessionId *d = (GoogleSessionId*)b; | 64 GoogleSessionId *d = (GoogleSessionId*)b; |
65 | 65 |
66 return !strcmp(c->id, d->id) && !strcmp(c->initiator, d->initiator); | 66 return !strcmp(c->id, d->id) && !strcmp(c->initiator, d->initiator); |
67 } | 67 } |
68 | 68 |
69 static void | 69 static void |
70 google_session_destroy(GoogleSession *session) | 70 google_session_destroy(GoogleSession *session) |
93 JabberIq *iq = jabber_iq_new(session->js, JABBER_IQ_SET); | 93 JabberIq *iq = jabber_iq_new(session->js, JABBER_IQ_SET); |
94 | 94 |
95 xmlnode_set_attrib(iq->node, "to", session->remote_jid); | 95 xmlnode_set_attrib(iq->node, "to", session->remote_jid); |
96 sess = google_session_create_xmlnode(session, "terminate"); | 96 sess = google_session_create_xmlnode(session, "terminate"); |
97 xmlnode_insert_child(iq->node, sess); | 97 xmlnode_insert_child(iq->node, sess); |
98 | 98 |
99 jabber_iq_send(iq); | 99 jabber_iq_send(iq); |
100 google_session_destroy(session); | 100 google_session_destroy(session); |
101 } | 101 } |
102 | 102 |
103 static void | 103 static void |
104 google_session_send_candidates(PurpleMedia *media, gchar *session_id, | 104 google_session_send_candidates(PurpleMedia *media, gchar *session_id, |
105 gchar *participant, GoogleSession *session) | 105 gchar *participant, GoogleSession *session) |
106 { | 106 { |
107 GList *candidates = purple_media_get_local_candidates(session->media, "google-voice", | 107 GList *candidates = purple_media_get_local_candidates(session->media, "google-voice", |
108 session->remote_jid); | 108 session->remote_jid); |
381 GList *codecs = NULL; | 381 GList *codecs = NULL; |
382 xmlnode *desc_element, *codec_element; | 382 xmlnode *desc_element, *codec_element; |
383 PurpleMediaCodec *codec; | 383 PurpleMediaCodec *codec; |
384 const char *id, *encoding_name, *clock_rate; | 384 const char *id, *encoding_name, *clock_rate; |
385 GParameter *params; | 385 GParameter *params; |
386 guint num_params; | 386 guint num_params; |
387 | 387 |
388 if (session->state != UNINIT) { | 388 if (session->state != UNINIT) { |
389 purple_debug_error("jabber", "Received initiate for active session.\n"); | 389 purple_debug_error("jabber", "Received initiate for active session.\n"); |
390 return; | 390 return; |
391 } | 391 } |
412 | 412 |
413 g_free(params); | 413 g_free(params); |
414 | 414 |
415 desc_element = xmlnode_get_child(sess, "description"); | 415 desc_element = xmlnode_get_child(sess, "description"); |
416 | 416 |
417 for (codec_element = xmlnode_get_child(desc_element, "payload-type"); | 417 for (codec_element = xmlnode_get_child(desc_element, "payload-type"); |
418 codec_element; | 418 codec_element; |
419 codec_element = xmlnode_get_next_twin(codec_element)) { | 419 codec_element = xmlnode_get_next_twin(codec_element)) { |
420 encoding_name = xmlnode_get_attrib(codec_element, "name"); | 420 encoding_name = xmlnode_get_attrib(codec_element, "name"); |
421 id = xmlnode_get_attrib(codec_element, "id"); | 421 id = xmlnode_get_attrib(codec_element, "id"); |
422 clock_rate = xmlnode_get_attrib(codec_element, "clockrate"); | 422 clock_rate = xmlnode_get_attrib(codec_element, "clockrate"); |
423 | 423 |
448 jabber_iq_set_id(result, iq_id); | 448 jabber_iq_set_id(result, iq_id); |
449 xmlnode_set_attrib(result->node, "to", session->remote_jid); | 449 xmlnode_set_attrib(result->node, "to", session->remote_jid); |
450 jabber_iq_send(result); | 450 jabber_iq_send(result); |
451 } | 451 } |
452 | 452 |
453 static void | 453 static void |
454 google_session_handle_candidates(JabberStream *js, GoogleSession *session, xmlnode *sess, const char *iq_id) | 454 google_session_handle_candidates(JabberStream *js, GoogleSession *session, xmlnode *sess, const char *iq_id) |
455 { | 455 { |
456 JabberIq *result; | 456 JabberIq *result; |
457 GList *list = NULL; | 457 GList *list = NULL; |
458 xmlnode *cand; | 458 xmlnode *cand; |
459 static int name = 0; | 459 static int name = 0; |
460 char n[4]; | 460 char n[4]; |
461 | 461 |
462 for (cand = xmlnode_get_child(sess, "candidate"); cand; cand = xmlnode_get_next_twin(cand)) { | 462 for (cand = xmlnode_get_child(sess, "candidate"); cand; cand = xmlnode_get_next_twin(cand)) { |
463 PurpleMediaCandidate *info; | 463 PurpleMediaCandidate *info; |
464 const gchar *type = xmlnode_get_attrib(cand, "type"); | 464 const gchar *type = xmlnode_get_attrib(cand, "type"); |
465 const gchar *protocol = xmlnode_get_attrib(cand, "protocol"); | 465 const gchar *protocol = xmlnode_get_attrib(cand, "protocol"); |
466 const gchar *address = xmlnode_get_attrib(cand, "address"); | 466 const gchar *address = xmlnode_get_attrib(cand, "address"); |
1137 const char *attr = purple_status_get_attr_string(tune, PURPLE_TUNE_TITLE); | 1137 const char *attr = purple_status_get_attr_string(tune, PURPLE_TUNE_TITLE); |
1138 return attr ? g_strdup_printf("♫ %s", attr) : g_strdup(""); | 1138 return attr ? g_strdup_printf("♫ %s", attr) : g_strdup(""); |
1139 } | 1139 } |
1140 | 1140 |
1141 static void | 1141 static void |
1142 jabber_google_stun_lookup_cb(GSList *hosts, gpointer data, | 1142 jabber_google_stun_lookup_cb(GSList *hosts, gpointer data, |
1143 const char *error_message) | 1143 const char *error_message) |
1144 { | 1144 { |
1145 JabberStream *js = (JabberStream *) data; | 1145 JabberStream *js = (JabberStream *) data; |
1146 | 1146 |
1147 if (error_message) { | 1147 if (error_message) { |
1150 g_slist_free(hosts); | 1150 g_slist_free(hosts); |
1151 return; | 1151 return; |
1152 } | 1152 } |
1153 | 1153 |
1154 if (hosts && g_slist_next(hosts)) { | 1154 if (hosts && g_slist_next(hosts)) { |
1155 struct sockaddr *addr = g_slist_next(hosts)->data; | 1155 struct sockaddr *addr = g_slist_next(hosts)->data; |
1156 char dst[INET6_ADDRSTRLEN]; | 1156 char dst[INET6_ADDRSTRLEN]; |
1157 int port; | 1157 int port; |
1158 | 1158 |
1159 if (addr->sa_family == AF_INET6) { | 1159 if (addr->sa_family == AF_INET6) { |
1160 inet_ntop(addr->sa_family, &((struct sockaddr_in6 *) addr)->sin6_addr, | 1160 inet_ntop(addr->sa_family, &((struct sockaddr_in6 *) addr)->sin6_addr, |
1161 dst, sizeof(dst)); | 1161 dst, sizeof(dst)); |
1162 port = ntohs(((struct sockaddr_in6 *) addr)->sin6_port); | 1162 port = ntohs(((struct sockaddr_in6 *) addr)->sin6_port); |
1163 } else { | 1163 } else { |
1164 inet_ntop(addr->sa_family, &((struct sockaddr_in *) addr)->sin_addr, | 1164 inet_ntop(addr->sa_family, &((struct sockaddr_in *) addr)->sin_addr, |
1165 dst, sizeof(dst)); | 1165 dst, sizeof(dst)); |
1166 port = ntohs(((struct sockaddr_in *) addr)->sin_port); | 1166 port = ntohs(((struct sockaddr_in *) addr)->sin_port); |
1167 } | 1167 } |
1168 | 1168 |
1169 if (js) { | 1169 if (js) { |
1224 const gchar *host = xmlnode_get_attrib(server, "host"); | 1224 const gchar *host = xmlnode_get_attrib(server, "host"); |
1225 const gchar *udp = xmlnode_get_attrib(server, "udp"); | 1225 const gchar *udp = xmlnode_get_attrib(server, "udp"); |
1226 | 1226 |
1227 if (host && udp) { | 1227 if (host && udp) { |
1228 int port = atoi(udp); | 1228 int port = atoi(udp); |
1229 /* if there, would already be an ongoing query, | 1229 /* if there, would already be an ongoing query, |
1230 cancel it */ | 1230 cancel it */ |
1231 if (js->stun_query) | 1231 if (js->stun_query) |
1232 purple_dnsquery_destroy(js->stun_query); | 1232 purple_dnsquery_destroy(js->stun_query); |
1233 | 1233 |
1234 js->stun_query = purple_dnsquery_a(host, port, | 1234 js->stun_query = purple_dnsquery_a(host, port, |
1235 jabber_google_stun_lookup_cb, js); | 1235 jabber_google_stun_lookup_cb, js); |
1236 } | 1236 } |
1237 } | 1237 } |
1238 } | 1238 } |
1239 /* should perhaps handle relays later on, or maybe wait until | 1239 /* should perhaps handle relays later on, or maybe wait until |
1263 } | 1263 } |
1264 | 1264 |
1265 void | 1265 void |
1266 jabber_google_send_jingle_info(JabberStream *js) | 1266 jabber_google_send_jingle_info(JabberStream *js) |
1267 { | 1267 { |
1268 JabberIq *jingle_info = | 1268 JabberIq *jingle_info = |
1269 jabber_iq_new_query(js, JABBER_IQ_GET, GOOGLE_JINGLE_INFO_NAMESPACE); | 1269 jabber_iq_new_query(js, JABBER_IQ_GET, GOOGLE_JINGLE_INFO_NAMESPACE); |
1270 | 1270 |
1271 jabber_iq_set_callback(jingle_info, jabber_google_jingle_info_cb, | 1271 jabber_iq_set_callback(jingle_info, jabber_google_jingle_info_cb, |
1272 NULL); | 1272 NULL); |
1273 purple_debug_info("jabber", "sending google:jingleinfo query\n"); | 1273 purple_debug_info("jabber", "sending google:jingleinfo query\n"); |