comparison libpurple/protocols/jabber/google.c @ 26021:f7cf50180e1d

Duplicate FsCandidate to remove it from the public interface.
author Mike Ruprecht <maiku@soc.pidgin.im>
date Sat, 10 Jan 2009 03:58:54 +0000
parents 0605c1121613
children ac4d7695dbc7
comparison
equal deleted inserted replaced
26020:ade5b2c51047 26021:f7cf50180e1d
159 gchar *participant, GoogleSession *session) 159 gchar *participant, GoogleSession *session)
160 { 160 {
161 JabberIq *iq = jabber_iq_new(session->js, JABBER_IQ_SET); 161 JabberIq *iq = jabber_iq_new(session->js, JABBER_IQ_SET);
162 GList *candidates = purple_media_get_local_candidates(session->media, "google-voice", 162 GList *candidates = purple_media_get_local_candidates(session->media, "google-voice",
163 session->remote_jid); 163 session->remote_jid);
164 FsCandidate *transport; 164 PurpleMediaCandidate *transport;
165 xmlnode *sess; 165 xmlnode *sess;
166 xmlnode *candidate; 166 xmlnode *candidate;
167 sess = google_session_create_xmlnode(session, "candidates"); 167 sess = google_session_create_xmlnode(session, "candidates");
168 xmlnode_insert_child(iq->node, sess); 168 xmlnode_insert_child(iq->node, sess);
169 xmlnode_set_attrib(iq->node, "to", session->remote_jid); 169 xmlnode_set_attrib(iq->node, "to", session->remote_jid);
170 170
171 for (;candidates;candidates = candidates->next) { 171 for (;candidates;candidates = candidates->next) {
172 char port[8]; 172 char port[8];
173 char pref[8]; 173 char pref[8];
174 transport = (FsCandidate*)(candidates->data); 174 transport = (PurpleMediaCandidate*)(candidates->data);
175 175
176 if (!strcmp(transport->ip, "127.0.0.1")) 176 if (!strcmp(transport->ip, "127.0.0.1"))
177 continue; 177 continue;
178 178
179 candidate = xmlnode_new("candidate"); 179 candidate = xmlnode_new("candidate");
192 */ 192 */
193 xmlnode_set_attrib(candidate, "password", 193 xmlnode_set_attrib(candidate, "password",
194 transport->password != NULL ? 194 transport->password != NULL ?
195 transport->password : ""); 195 transport->password : "");
196 xmlnode_set_attrib(candidate, "preference", pref); 196 xmlnode_set_attrib(candidate, "preference", pref);
197 xmlnode_set_attrib(candidate, "protocol", transport->proto == FS_NETWORK_PROTOCOL_UDP ? "udp" : "tcp"); 197 xmlnode_set_attrib(candidate, "protocol", transport->proto ==
198 xmlnode_set_attrib(candidate, "type", transport->type == FS_CANDIDATE_TYPE_HOST ? "local" : 198 PURPLE_MEDIA_NETWORK_PROTOCOL_UDP ? "udp" : "tcp");
199 transport->type == FS_CANDIDATE_TYPE_SRFLX ? "stun" : 199 xmlnode_set_attrib(candidate, "type", transport->type ==
200 transport->type == FS_CANDIDATE_TYPE_RELAY ? "relay" : NULL); 200 PURPLE_MEDIA_CANDIDATE_TYPE_HOST ? "local" :
201 transport->type ==
202 PURPLE_MEDIA_CANDIDATE_TYPE_SRFLX ? "stun" :
203 transport->type ==
204 PURPLE_MEDIA_CANDIDATE_TYPE_RELAY ? "relay" : NULL);
201 xmlnode_set_attrib(candidate, "generation", "0"); 205 xmlnode_set_attrib(candidate, "generation", "0");
202 xmlnode_set_attrib(candidate, "network", "0"); 206 xmlnode_set_attrib(candidate, "network", "0");
203 xmlnode_insert_child(sess, candidate); 207 xmlnode_insert_child(sess, candidate);
204 208
205 } 209 }
397 xmlnode *cand; 401 xmlnode *cand;
398 static int name = 0; 402 static int name = 0;
399 char n[4]; 403 char n[4];
400 404
401 for (cand = xmlnode_get_child(sess, "candidate"); cand; cand = xmlnode_get_next_twin(cand)) { 405 for (cand = xmlnode_get_child(sess, "candidate"); cand; cand = xmlnode_get_next_twin(cand)) {
402 FsCandidate *info; 406 PurpleMediaCandidate *info;
403 g_snprintf(n, sizeof(n), "S%d", name++); 407 g_snprintf(n, sizeof(n), "S%d", name++);
404 info = fs_candidate_new(n, FS_COMPONENT_RTP, !strcmp(xmlnode_get_attrib(cand, "type"), "local") ? 408 info = purple_media_candidate_new(n, PURPLE_MEDIA_COMPONENT_RTP,
405 FS_CANDIDATE_TYPE_HOST : 409 !strcmp(xmlnode_get_attrib(cand, "type"), "local") ?
410 PURPLE_MEDIA_CANDIDATE_TYPE_HOST :
406 !strcmp(xmlnode_get_attrib(cand, "type"), "stun") ? 411 !strcmp(xmlnode_get_attrib(cand, "type"), "stun") ?
407 FS_CANDIDATE_TYPE_PRFLX : 412 PURPLE_MEDIA_CANDIDATE_TYPE_PRFLX :
408 !strcmp(xmlnode_get_attrib(cand, "type"), "relay") ? 413 !strcmp(xmlnode_get_attrib(cand, "type"), "relay") ?
409 FS_CANDIDATE_TYPE_RELAY : FS_CANDIDATE_TYPE_HOST, 414 PURPLE_MEDIA_CANDIDATE_TYPE_RELAY :
415 PURPLE_MEDIA_CANDIDATE_TYPE_HOST,
410 !strcmp(xmlnode_get_attrib(cand, "protocol"),"udp") ? 416 !strcmp(xmlnode_get_attrib(cand, "protocol"),"udp") ?
411 FS_NETWORK_PROTOCOL_UDP : FS_NETWORK_PROTOCOL_TCP, 417 PURPLE_MEDIA_NETWORK_PROTOCOL_UDP :
412 xmlnode_get_attrib(cand, "address"), atoi(xmlnode_get_attrib(cand, "port"))); 418 PURPLE_MEDIA_NETWORK_PROTOCOL_TCP,
419 xmlnode_get_attrib(cand, "address"),
420 atoi(xmlnode_get_attrib(cand, "port")));
413 421
414 info->username = g_strdup(xmlnode_get_attrib(cand, "username")); 422 info->username = g_strdup(xmlnode_get_attrib(cand, "username"));
415 info->password = g_strdup(xmlnode_get_attrib(cand, "password")); 423 info->password = g_strdup(xmlnode_get_attrib(cand, "password"));
416 424
417 list = g_list_append(list, info); 425 list = g_list_append(list, info);
418 } 426 }
419 427
420 purple_media_add_remote_candidates(session->media, "google-voice", session->remote_jid, list); 428 purple_media_add_remote_candidates(session->media, "google-voice", session->remote_jid, list);
421 fs_candidate_list_destroy(list); 429 purple_media_candidate_list_free(list);
422 430
423 result = jabber_iq_new(js, JABBER_IQ_RESULT); 431 result = jabber_iq_new(js, JABBER_IQ_RESULT);
424 jabber_iq_set_id(result, xmlnode_get_attrib(packet, "id")); 432 jabber_iq_set_id(result, xmlnode_get_attrib(packet, "id"));
425 xmlnode_set_attrib(result->node, "to", session->remote_jid); 433 xmlnode_set_attrib(result->node, "to", session->remote_jid);
426 jabber_iq_send(result); 434 jabber_iq_send(result);