comparison libpurple/protocols/jabber/google.c @ 26406:2d332d327a0e

Hide and GObjectify PurpleMediaCandidate.
author Mike Ruprecht <maiku@soc.pidgin.im>
date Fri, 03 Apr 2009 00:21:10 +0000
parents 217574ec2a34
children 4f14455a86d2 ae24e54a5014
comparison
equal deleted inserted replaced
26405:70ab418e9d4f 26406:2d332d327a0e
108 session->remote_jid); 108 session->remote_jid);
109 PurpleMediaCandidate *transport; 109 PurpleMediaCandidate *transport;
110 110
111 for (;candidates;candidates = candidates->next) { 111 for (;candidates;candidates = candidates->next) {
112 JabberIq *iq; 112 JabberIq *iq;
113 char port[8]; 113 gchar *ip, *port, *pref, *username, *password;
114 char pref[8]; 114 PurpleMediaCandidateType type;
115 xmlnode *sess; 115 xmlnode *sess;
116 xmlnode *candidate; 116 xmlnode *candidate;
117 transport = (PurpleMediaCandidate*)(candidates->data); 117 transport = (PurpleMediaCandidate*)(candidates->data);
118 118
119 if (transport->component_id != PURPLE_MEDIA_COMPONENT_RTP) 119 if (purple_media_candidate_get_component_id(transport)
120 != PURPLE_MEDIA_COMPONENT_RTP)
120 continue; 121 continue;
121 122
122 iq = jabber_iq_new(session->js, JABBER_IQ_SET); 123 iq = jabber_iq_new(session->js, JABBER_IQ_SET);
123 sess = google_session_create_xmlnode(session, "candidates"); 124 sess = google_session_create_xmlnode(session, "candidates");
124 xmlnode_insert_child(iq->node, sess); 125 xmlnode_insert_child(iq->node, sess);
125 xmlnode_set_attrib(iq->node, "to", session->remote_jid); 126 xmlnode_set_attrib(iq->node, "to", session->remote_jid);
126 127
127 candidate = xmlnode_new("candidate"); 128 candidate = xmlnode_new("candidate");
128 129
129 g_snprintf(port, sizeof(port), "%d", transport->port); 130 ip = purple_media_candidate_get_ip(transport);
130 g_snprintf(pref, sizeof(pref), "%f", 131 port = g_strdup_printf("%d",
131 transport->priority/1000.0); 132 purple_media_candidate_get_port(transport));
132 133 pref = g_strdup_printf("%f",
133 xmlnode_set_attrib(candidate, "address", transport->ip); 134 purple_media_candidate_get_priority(transport)
135 /1000.0);
136 username = purple_media_candidate_get_username(transport);
137 password = purple_media_candidate_get_password(transport);
138 type = purple_media_candidate_get_candidate_type(transport);
139
140 xmlnode_set_attrib(candidate, "address", ip);
134 xmlnode_set_attrib(candidate, "port", port); 141 xmlnode_set_attrib(candidate, "port", port);
135 xmlnode_set_attrib(candidate, "name", "rtp"); 142 xmlnode_set_attrib(candidate, "name", "rtp");
136 xmlnode_set_attrib(candidate, "username", transport->username); 143 xmlnode_set_attrib(candidate, "username", username);
137 /* 144 /*
138 * As of this writing, Farsight 2 in Google compatibility 145 * As of this writing, Farsight 2 in Google compatibility
139 * mode doesn't provide a password. The Gmail client 146 * mode doesn't provide a password. The Gmail client
140 * requires this to be set. 147 * requires this to be set.
141 */ 148 */
142 xmlnode_set_attrib(candidate, "password", 149 xmlnode_set_attrib(candidate, "password",
143 transport->password != NULL ? 150 password != NULL ? password : "");
144 transport->password : "");
145 xmlnode_set_attrib(candidate, "preference", pref); 151 xmlnode_set_attrib(candidate, "preference", pref);
146 xmlnode_set_attrib(candidate, "protocol", transport->proto == 152 xmlnode_set_attrib(candidate, "protocol",
147 PURPLE_MEDIA_NETWORK_PROTOCOL_UDP ? "udp" : "tcp"); 153 purple_media_candidate_get_protocol(transport)
148 xmlnode_set_attrib(candidate, "type", transport->type == 154 == PURPLE_MEDIA_NETWORK_PROTOCOL_UDP ?
155 "udp" : "tcp");
156 xmlnode_set_attrib(candidate, "type", type ==
149 PURPLE_MEDIA_CANDIDATE_TYPE_HOST ? "local" : 157 PURPLE_MEDIA_CANDIDATE_TYPE_HOST ? "local" :
150 transport->type == 158 type ==
151 PURPLE_MEDIA_CANDIDATE_TYPE_SRFLX ? "stun" : 159 PURPLE_MEDIA_CANDIDATE_TYPE_SRFLX ? "stun" :
152 transport->type == 160 type ==
153 PURPLE_MEDIA_CANDIDATE_TYPE_RELAY ? "relay" : NULL); 161 PURPLE_MEDIA_CANDIDATE_TYPE_RELAY ? "relay" :
162 NULL);
154 xmlnode_set_attrib(candidate, "generation", "0"); 163 xmlnode_set_attrib(candidate, "generation", "0");
155 xmlnode_set_attrib(candidate, "network", "0"); 164 xmlnode_set_attrib(candidate, "network", "0");
156 xmlnode_insert_child(sess, candidate); 165 xmlnode_insert_child(sess, candidate);
166
167 g_free(ip);
168 g_free(port);
169 g_free(pref);
170 g_free(username);
171 g_free(password);
157 172
158 jabber_iq_send(iq); 173 jabber_iq_send(iq);
159 } 174 }
160 } 175 }
161 176
453 !strcmp(xmlnode_get_attrib(cand, "protocol"),"udp") ? 468 !strcmp(xmlnode_get_attrib(cand, "protocol"),"udp") ?
454 PURPLE_MEDIA_NETWORK_PROTOCOL_UDP : 469 PURPLE_MEDIA_NETWORK_PROTOCOL_UDP :
455 PURPLE_MEDIA_NETWORK_PROTOCOL_TCP, 470 PURPLE_MEDIA_NETWORK_PROTOCOL_TCP,
456 xmlnode_get_attrib(cand, "address"), 471 xmlnode_get_attrib(cand, "address"),
457 atoi(xmlnode_get_attrib(cand, "port"))); 472 atoi(xmlnode_get_attrib(cand, "port")));
458 473 g_object_set(info, "username", xmlnode_get_attrib(cand, "username"),
459 info->username = g_strdup(xmlnode_get_attrib(cand, "username")); 474 "password", xmlnode_get_attrib(cand, "password"), NULL);
460 info->password = g_strdup(xmlnode_get_attrib(cand, "password"));
461 475
462 list = g_list_append(list, info); 476 list = g_list_append(list, info);
463 } 477 }
464 478
465 purple_media_add_remote_candidates(session->media, "google-voice", session->remote_jid, list); 479 purple_media_add_remote_candidates(session->media, "google-voice", session->remote_jid, list);