Mercurial > pidgin
comparison libpurple/protocols/oscar/clientlogin.c @ 27989:2987756bc600
Make the strings in this file more localizable
author | Mark Doliner <mark@kingant.net> |
---|---|
date | Sun, 09 Aug 2009 20:56:59 +0000 |
parents | 036d94041e09 |
children | 79c14adf9669 |
comparison
equal
deleted
inserted
replaced
27988:4e7b8902da90 | 27989:2987756bc600 |
---|---|
154 | 154 |
155 /* Parse the response as XML */ | 155 /* Parse the response as XML */ |
156 response_node = xmlnode_from_str(response, response_len); | 156 response_node = xmlnode_from_str(response, response_len); |
157 if (response_node == NULL) | 157 if (response_node == NULL) |
158 { | 158 { |
159 char *msg; | |
159 purple_debug_error("oscar", "startOSCARSession could not parse " | 160 purple_debug_error("oscar", "startOSCARSession could not parse " |
160 "response as XML: %s\n", response); | 161 "response as XML: %s\n", response); |
161 purple_connection_error_reason(gc, | 162 /* Note to translators: %s in this string is a URL */ |
162 PURPLE_CONNECTION_ERROR_NETWORK_ERROR, | 163 msg = g_strdup_printf(_("Received unexpected response from %s"), |
163 _("Received unexpected response from " URL_START_OSCAR_SESSION)); | 164 URL_START_OSCAR_SESSION); |
165 purple_connection_error_reason(gc, | |
166 PURPLE_CONNECTION_ERROR_NETWORK_ERROR, msg); | |
167 g_free(msg); | |
164 return FALSE; | 168 return FALSE; |
165 } | 169 } |
166 | 170 |
167 /* Grab the necessary XML nodes */ | 171 /* Grab the necessary XML nodes */ |
168 tmp_node = xmlnode_get_child(response_node, "statusCode"); | 172 tmp_node = xmlnode_get_child(response_node, "statusCode"); |
173 cookie_node = xmlnode_get_child(data_node, "cookie"); | 177 cookie_node = xmlnode_get_child(data_node, "cookie"); |
174 } | 178 } |
175 | 179 |
176 /* Make sure we have a status code */ | 180 /* Make sure we have a status code */ |
177 if (tmp_node == NULL || (tmp = xmlnode_get_data_unescaped(tmp_node)) == NULL) { | 181 if (tmp_node == NULL || (tmp = xmlnode_get_data_unescaped(tmp_node)) == NULL) { |
182 char *msg; | |
178 purple_debug_error("oscar", "startOSCARSession response was " | 183 purple_debug_error("oscar", "startOSCARSession response was " |
179 "missing statusCode: %s\n", response); | 184 "missing statusCode: %s\n", response); |
180 purple_connection_error_reason(gc, | 185 msg = g_strdup_printf(_("Received unexpected response from %s"), |
181 PURPLE_CONNECTION_ERROR_NETWORK_ERROR, | 186 URL_START_OSCAR_SESSION); |
182 _("Received unexpected response from " URL_START_OSCAR_SESSION)); | 187 purple_connection_error_reason(gc, |
188 PURPLE_CONNECTION_ERROR_NETWORK_ERROR, msg); | |
189 g_free(msg); | |
183 xmlnode_free(response_node); | 190 xmlnode_free(response_node); |
184 return FALSE; | 191 return FALSE; |
185 } | 192 } |
186 | 193 |
187 /* Make sure the status code was 200 */ | 194 /* Make sure the status code was 200 */ |
195 PURPLE_CONNECTION_ERROR_OTHER_ERROR, | 202 PURPLE_CONNECTION_ERROR_OTHER_ERROR, |
196 _("You have been connecting and disconnecting too " | 203 _("You have been connecting and disconnecting too " |
197 "frequently. Wait ten minutes and try again. If " | 204 "frequently. Wait ten minutes and try again. If " |
198 "you continue to try, you will need to wait even " | 205 "you continue to try, you will need to wait even " |
199 "longer.")); | 206 "longer.")); |
200 else | 207 else { |
208 char *msg; | |
209 msg = g_strdup_printf(_("Received unexpected response from %s"), | |
210 URL_START_OSCAR_SESSION); | |
201 purple_connection_error_reason(gc, | 211 purple_connection_error_reason(gc, |
202 PURPLE_CONNECTION_ERROR_OTHER_ERROR, | 212 PURPLE_CONNECTION_ERROR_OTHER_ERROR, msg); |
203 _("Received unexpected response from " URL_START_OSCAR_SESSION)); | 213 g_free(msg); |
214 } | |
204 | 215 |
205 g_free(tmp); | 216 g_free(tmp); |
206 xmlnode_free(response_node); | 217 xmlnode_free(response_node); |
207 return FALSE; | 218 return FALSE; |
208 } | 219 } |
210 | 221 |
211 /* Make sure we have everything else */ | 222 /* Make sure we have everything else */ |
212 if (data_node == NULL || host_node == NULL || | 223 if (data_node == NULL || host_node == NULL || |
213 port_node == NULL || cookie_node == NULL) | 224 port_node == NULL || cookie_node == NULL) |
214 { | 225 { |
226 char *msg; | |
215 purple_debug_error("oscar", "startOSCARSession response was missing " | 227 purple_debug_error("oscar", "startOSCARSession response was missing " |
216 "something: %s\n", response); | 228 "something: %s\n", response); |
217 purple_connection_error_reason(gc, | 229 msg = g_strdup_printf(_("Received unexpected response from %s"), |
218 PURPLE_CONNECTION_ERROR_NETWORK_ERROR, | 230 URL_START_OSCAR_SESSION); |
219 _("Received unexpected response from " URL_START_OSCAR_SESSION)); | 231 purple_connection_error_reason(gc, |
232 PURPLE_CONNECTION_ERROR_NETWORK_ERROR, msg); | |
233 g_free(msg); | |
220 xmlnode_free(response_node); | 234 xmlnode_free(response_node); |
221 return FALSE; | 235 return FALSE; |
222 } | 236 } |
223 | 237 |
224 /* Extract data from the XML */ | 238 /* Extract data from the XML */ |
225 *host = xmlnode_get_data_unescaped(host_node); | 239 *host = xmlnode_get_data_unescaped(host_node); |
226 tmp = xmlnode_get_data_unescaped(port_node); | 240 tmp = xmlnode_get_data_unescaped(port_node); |
227 *cookie = xmlnode_get_data_unescaped(cookie_node); | 241 *cookie = xmlnode_get_data_unescaped(cookie_node); |
228 if (*host == NULL || **host == '\0' || tmp == NULL || *tmp == '\0' || cookie == NULL || *cookie == '\0') | 242 if (*host == NULL || **host == '\0' || tmp == NULL || *tmp == '\0' || cookie == NULL || *cookie == '\0') |
229 { | 243 { |
244 char *msg; | |
230 purple_debug_error("oscar", "startOSCARSession response was missing " | 245 purple_debug_error("oscar", "startOSCARSession response was missing " |
231 "something: %s\n", response); | 246 "something: %s\n", response); |
232 purple_connection_error_reason(gc, | 247 msg = g_strdup_printf(_("Received unexpected response from %s"), |
233 PURPLE_CONNECTION_ERROR_NETWORK_ERROR, | 248 URL_START_OSCAR_SESSION); |
234 _("Received unexpected response from " URL_START_OSCAR_SESSION)); | 249 purple_connection_error_reason(gc, |
250 PURPLE_CONNECTION_ERROR_NETWORK_ERROR, msg); | |
251 g_free(msg); | |
235 g_free(*host); | 252 g_free(*host); |
236 g_free(tmp); | 253 g_free(tmp); |
237 g_free(*cookie); | 254 g_free(*cookie); |
238 xmlnode_free(response_node); | 255 xmlnode_free(response_node); |
239 return FALSE; | 256 return FALSE; |
259 | 276 |
260 od->url_data = NULL; | 277 od->url_data = NULL; |
261 | 278 |
262 if (error_message != NULL || len == 0) { | 279 if (error_message != NULL || len == 0) { |
263 gchar *tmp; | 280 gchar *tmp; |
264 tmp = g_strdup_printf(_("Error requesting " URL_START_OSCAR_SESSION | 281 /* Note to translators: The first %s is a URL, the second is an |
265 ": %s"), error_message); | 282 error message. */ |
283 tmp = g_strdup_printf(_("Error requesting %s: %s"), | |
284 URL_START_OSCAR_SESSION, error_message); | |
266 purple_connection_error_reason(gc, | 285 purple_connection_error_reason(gc, |
267 PURPLE_CONNECTION_ERROR_NETWORK_ERROR, tmp); | 286 PURPLE_CONNECTION_ERROR_NETWORK_ERROR, tmp); |
268 g_free(tmp); | 287 g_free(tmp); |
269 return; | 288 return; |
270 } | 289 } |
337 | 356 |
338 /* Parse the response as XML */ | 357 /* Parse the response as XML */ |
339 response_node = xmlnode_from_str(response, response_len); | 358 response_node = xmlnode_from_str(response, response_len); |
340 if (response_node == NULL) | 359 if (response_node == NULL) |
341 { | 360 { |
361 char *msg; | |
342 purple_debug_error("oscar", "clientLogin could not parse " | 362 purple_debug_error("oscar", "clientLogin could not parse " |
343 "response as XML: %s\n", response); | 363 "response as XML: %s\n", response); |
344 purple_connection_error_reason(gc, | 364 msg = g_strdup_printf(_("Received unexpected response from %s"), |
345 PURPLE_CONNECTION_ERROR_NETWORK_ERROR, | 365 URL_CLIENT_LOGIN); |
346 _("Received unexpected response from " URL_CLIENT_LOGIN)); | 366 purple_connection_error_reason(gc, |
367 PURPLE_CONNECTION_ERROR_NETWORK_ERROR, msg); | |
368 g_free(msg); | |
347 return FALSE; | 369 return FALSE; |
348 } | 370 } |
349 | 371 |
350 /* Grab the necessary XML nodes */ | 372 /* Grab the necessary XML nodes */ |
351 tmp_node = xmlnode_get_child(response_node, "statusCode"); | 373 tmp_node = xmlnode_get_child(response_node, "statusCode"); |
358 tokena_node = xmlnode_get_child(token_node, "a"); | 380 tokena_node = xmlnode_get_child(token_node, "a"); |
359 } | 381 } |
360 | 382 |
361 /* Make sure we have a status code */ | 383 /* Make sure we have a status code */ |
362 if (tmp_node == NULL || (tmp = xmlnode_get_data_unescaped(tmp_node)) == NULL) { | 384 if (tmp_node == NULL || (tmp = xmlnode_get_data_unescaped(tmp_node)) == NULL) { |
385 char *msg; | |
363 purple_debug_error("oscar", "clientLogin response was " | 386 purple_debug_error("oscar", "clientLogin response was " |
364 "missing statusCode: %s\n", response); | 387 "missing statusCode: %s\n", response); |
365 purple_connection_error_reason(gc, | 388 msg = g_strdup_printf(_("Received unexpected response from %s"), |
366 PURPLE_CONNECTION_ERROR_NETWORK_ERROR, | 389 URL_CLIENT_LOGIN); |
367 _("Received unexpected response from " URL_CLIENT_LOGIN)); | 390 purple_connection_error_reason(gc, |
391 PURPLE_CONNECTION_ERROR_NETWORK_ERROR, msg); | |
392 g_free(msg); | |
368 xmlnode_free(response_node); | 393 xmlnode_free(response_node); |
369 return FALSE; | 394 return FALSE; |
370 } | 395 } |
371 | 396 |
372 /* Make sure the status code was 200 */ | 397 /* Make sure the status code was 200 */ |
391 _("Incorrect password")); | 416 _("Incorrect password")); |
392 } else if (status_code == 401 && status_detail_code == 3019) { | 417 } else if (status_code == 401 && status_detail_code == 3019) { |
393 purple_connection_error_reason(gc, | 418 purple_connection_error_reason(gc, |
394 PURPLE_CONNECTION_ERROR_OTHER_ERROR, | 419 PURPLE_CONNECTION_ERROR_OTHER_ERROR, |
395 _("AOL does not allow your screen name to authenticate here")); | 420 _("AOL does not allow your screen name to authenticate here")); |
396 } else | 421 } else { |
422 char *msg; | |
423 msg = g_strdup_printf(_("Received unexpected response from %s"), | |
424 URL_CLIENT_LOGIN); | |
397 purple_connection_error_reason(gc, | 425 purple_connection_error_reason(gc, |
398 PURPLE_CONNECTION_ERROR_OTHER_ERROR, | 426 PURPLE_CONNECTION_ERROR_OTHER_ERROR, msg); |
399 _("Received unexpected response from " URL_CLIENT_LOGIN)); | 427 g_free(msg); |
428 } | |
400 | 429 |
401 xmlnode_free(response_node); | 430 xmlnode_free(response_node); |
402 return FALSE; | 431 return FALSE; |
403 } | 432 } |
404 g_free(tmp); | 433 g_free(tmp); |
405 | 434 |
406 /* Make sure we have everything else */ | 435 /* Make sure we have everything else */ |
407 if (data_node == NULL || secret_node == NULL || | 436 if (data_node == NULL || secret_node == NULL || |
408 token_node == NULL || tokena_node == NULL) | 437 token_node == NULL || tokena_node == NULL) |
409 { | 438 { |
439 char *msg; | |
410 purple_debug_error("oscar", "clientLogin response was missing " | 440 purple_debug_error("oscar", "clientLogin response was missing " |
411 "something: %s\n", response); | 441 "something: %s\n", response); |
412 purple_connection_error_reason(gc, | 442 msg = g_strdup_printf(_("Received unexpected response from %s"), |
413 PURPLE_CONNECTION_ERROR_NETWORK_ERROR, | 443 URL_CLIENT_LOGIN); |
414 _("Received unexpected response from " URL_CLIENT_LOGIN)); | 444 purple_connection_error_reason(gc, |
445 PURPLE_CONNECTION_ERROR_NETWORK_ERROR, msg); | |
446 g_free(msg); | |
415 xmlnode_free(response_node); | 447 xmlnode_free(response_node); |
416 return FALSE; | 448 return FALSE; |
417 } | 449 } |
418 | 450 |
419 /* Extract data from the XML */ | 451 /* Extract data from the XML */ |
420 *token = xmlnode_get_data_unescaped(tokena_node); | 452 *token = xmlnode_get_data_unescaped(tokena_node); |
421 *secret = xmlnode_get_data_unescaped(secret_node); | 453 *secret = xmlnode_get_data_unescaped(secret_node); |
422 tmp = xmlnode_get_data_unescaped(hosttime_node); | 454 tmp = xmlnode_get_data_unescaped(hosttime_node); |
423 if (*token == NULL || **token == '\0' || *secret == NULL || **secret == '\0' || tmp == NULL || *tmp == '\0') | 455 if (*token == NULL || **token == '\0' || *secret == NULL || **secret == '\0' || tmp == NULL || *tmp == '\0') |
424 { | 456 { |
457 char *msg; | |
425 purple_debug_error("oscar", "clientLogin response was missing " | 458 purple_debug_error("oscar", "clientLogin response was missing " |
426 "something: %s\n", response); | 459 "something: %s\n", response); |
427 purple_connection_error_reason(gc, | 460 msg = g_strdup_printf(_("Received unexpected response from %s"), |
428 PURPLE_CONNECTION_ERROR_NETWORK_ERROR, | 461 URL_CLIENT_LOGIN); |
429 _("Received unexpected response from " URL_CLIENT_LOGIN)); | 462 purple_connection_error_reason(gc, |
463 PURPLE_CONNECTION_ERROR_NETWORK_ERROR, msg); | |
464 g_free(msg); | |
430 g_free(*token); | 465 g_free(*token); |
431 g_free(*secret); | 466 g_free(*secret); |
432 g_free(tmp); | 467 g_free(tmp); |
433 xmlnode_free(response_node); | 468 xmlnode_free(response_node); |
434 return FALSE; | 469 return FALSE; |
456 | 491 |
457 od->url_data = NULL; | 492 od->url_data = NULL; |
458 | 493 |
459 if (error_message != NULL || len == 0) { | 494 if (error_message != NULL || len == 0) { |
460 gchar *tmp; | 495 gchar *tmp; |
461 tmp = g_strdup_printf(_("Error requesting " URL_CLIENT_LOGIN | 496 tmp = g_strdup_printf(_("Error requesting %s: %s"), |
462 ": %s"), error_message); | 497 URL_CLIENT_LOGIN, error_message); |
463 purple_connection_error_reason(gc, | 498 purple_connection_error_reason(gc, |
464 PURPLE_CONNECTION_ERROR_NETWORK_ERROR, tmp); | 499 PURPLE_CONNECTION_ERROR_NETWORK_ERROR, tmp); |
465 g_free(tmp); | 500 g_free(tmp); |
466 return; | 501 return; |
467 } | 502 } |