Mercurial > pidgin.yaz
comparison libpurple/protocols/silc/silc.c @ 21358:ba41f2a60253
Rename:
* PurpleDisconnectReason to PurpleConnectionError;
* elements of that enum from PURPLE_REASON_* to PURPLE_CONNECTION_ERROR_*;
* purple_connection_reason_is_fatal to purple_connection_error_is_fatal.
author | Will Thompson <will.thompson@collabora.co.uk> |
---|---|
date | Sun, 14 Oct 2007 21:08:42 +0000 |
parents | efa448405f3d |
children | e747ac0c42d6 |
comparison
equal
deleted
inserted
replaced
21357:5a3242b676ad | 21358:ba41f2a60253 |
---|---|
213 g_unlink(silcpurple_session_file(purple_account_get_username(sg->account))); | 213 g_unlink(silcpurple_session_file(purple_account_get_username(sg->account))); |
214 | 214 |
215 /* Close the connection */ | 215 /* Close the connection */ |
216 if (!sg->detaching) | 216 if (!sg->detaching) |
217 purple_connection_error_reason(gc, | 217 purple_connection_error_reason(gc, |
218 PURPLE_REASON_NETWORK_ERROR, | 218 PURPLE_CONNECTION_ERROR_NETWORK_ERROR, |
219 _("Disconnected by server")); | 219 _("Disconnected by server")); |
220 else | 220 else |
221 /* TODO: Does this work correctly? Maybe we need to set wants_to_die? */ | 221 /* TODO: Does this work correctly? Maybe we need to set wants_to_die? */ |
222 purple_account_disconnect(purple_connection_get_account(gc)); | 222 purple_account_disconnect(purple_connection_get_account(gc)); |
223 break; | 223 break; |
224 | 224 |
225 case SILC_CLIENT_CONN_ERROR: | 225 case SILC_CLIENT_CONN_ERROR: |
226 purple_connection_error_reason(gc, PURPLE_REASON_NETWORK_ERROR, | 226 purple_connection_error_reason(gc, PURPLE_CONNECTION_ERROR_NETWORK_ERROR, |
227 _("Error during connecting to SILC Server")); | 227 _("Error during connecting to SILC Server")); |
228 g_unlink(silcpurple_session_file(purple_account_get_username(sg->account))); | 228 g_unlink(silcpurple_session_file(purple_account_get_username(sg->account))); |
229 break; | 229 break; |
230 | 230 |
231 case SILC_CLIENT_CONN_ERROR_KE: | 231 case SILC_CLIENT_CONN_ERROR_KE: |
232 purple_connection_error_reason(gc, PURPLE_REASON_ENCRYPTION_ERROR, | 232 purple_connection_error_reason(gc, PURPLE_CONNECTION_ERROR_ENCRYPTION_ERROR, |
233 _("Key Exchange failed")); | 233 _("Key Exchange failed")); |
234 break; | 234 break; |
235 | 235 |
236 case SILC_CLIENT_CONN_ERROR_AUTH: | 236 case SILC_CLIENT_CONN_ERROR_AUTH: |
237 purple_connection_error_reason(gc, PURPLE_REASON_AUTHENTICATION_FAILED, | 237 purple_connection_error_reason(gc, PURPLE_CONNECTION_ERROR_AUTHENTICATION_FAILED, |
238 _("Authentication failed")); | 238 _("Authentication failed")); |
239 break; | 239 break; |
240 | 240 |
241 case SILC_CLIENT_CONN_ERROR_RESUME: | 241 case SILC_CLIENT_CONN_ERROR_RESUME: |
242 purple_connection_error_reason(gc, PURPLE_REASON_OTHER_ERROR, | 242 purple_connection_error_reason(gc, PURPLE_CONNECTION_ERROR_OTHER_ERROR, |
243 _("Resuming detached session failed. " | 243 _("Resuming detached session failed. " |
244 "Press Reconnect to create new connection.")); | 244 "Press Reconnect to create new connection.")); |
245 g_unlink(silcpurple_session_file(purple_account_get_username(sg->account))); | 245 g_unlink(silcpurple_session_file(purple_account_get_username(sg->account))); |
246 break; | 246 break; |
247 | 247 |
248 case SILC_CLIENT_CONN_ERROR_TIMEOUT: | 248 case SILC_CLIENT_CONN_ERROR_TIMEOUT: |
249 purple_connection_error_reason(gc, PURPLE_REASON_NETWORK_ERROR, | 249 purple_connection_error_reason(gc, PURPLE_CONNECTION_ERROR_NETWORK_ERROR, |
250 _("Connection Timeout")); | 250 _("Connection Timeout")); |
251 break; | 251 break; |
252 } | 252 } |
253 | 253 |
254 /* Error */ | 254 /* Error */ |
266 const char *dfile; | 266 const char *dfile; |
267 | 267 |
268 sg = gc->proto_data; | 268 sg = gc->proto_data; |
269 | 269 |
270 if (status != SILC_SOCKET_OK) { | 270 if (status != SILC_SOCKET_OK) { |
271 purple_connection_error_reason(gc, PURPLE_REASON_NETWORK_ERROR, | 271 purple_connection_error_reason(gc, PURPLE_CONNECTION_ERROR_NETWORK_ERROR, |
272 _("Connection failed")); | 272 _("Connection failed")); |
273 silc_pkcs_public_key_free(sg->public_key); | 273 silc_pkcs_public_key_free(sg->public_key); |
274 silc_pkcs_private_key_free(sg->private_key); | 274 silc_pkcs_private_key_free(sg->private_key); |
275 silc_free(sg); | 275 silc_free(sg); |
276 gc->proto_data = NULL; | 276 gc->proto_data = NULL; |
313 g_return_if_fail(gc != NULL); | 313 g_return_if_fail(gc != NULL); |
314 | 314 |
315 sg = gc->proto_data; | 315 sg = gc->proto_data; |
316 | 316 |
317 if (source < 0) { | 317 if (source < 0) { |
318 purple_connection_error_reason(gc, PURPLE_REASON_NETWORK_ERROR, | 318 purple_connection_error_reason(gc, PURPLE_CONNECTION_ERROR_NETWORK_ERROR, |
319 _("Connection failed")); | 319 _("Connection failed")); |
320 silc_pkcs_public_key_free(sg->public_key); | 320 silc_pkcs_public_key_free(sg->public_key); |
321 silc_pkcs_private_key_free(sg->private_key); | 321 silc_pkcs_private_key_free(sg->private_key); |
322 silc_free(sg); | 322 silc_free(sg); |
323 gc->proto_data = NULL; | 323 gc->proto_data = NULL; |
355 g_snprintf(prd, sizeof(prd), "%s" G_DIR_SEPARATOR_S "private_key.prv", silcpurple_silcdir()); | 355 g_snprintf(prd, sizeof(prd), "%s" G_DIR_SEPARATOR_S "private_key.prv", silcpurple_silcdir()); |
356 if (!silc_load_key_pair((char *)purple_account_get_string(account, "public-key", pkd), | 356 if (!silc_load_key_pair((char *)purple_account_get_string(account, "public-key", pkd), |
357 (char *)purple_account_get_string(account, "private-key", prd), | 357 (char *)purple_account_get_string(account, "private-key", prd), |
358 (gc->password == NULL) ? "" : gc->password, | 358 (gc->password == NULL) ? "" : gc->password, |
359 &sg->public_key, &sg->private_key)) { | 359 &sg->public_key, &sg->private_key)) { |
360 purple_connection_error_reason(gc, PURPLE_REASON_OTHER_ERROR, | 360 purple_connection_error_reason(gc, PURPLE_CONNECTION_ERROR_OTHER_ERROR, |
361 _("Could not load SILC key pair")); | 361 _("Could not load SILC key pair")); |
362 gc->proto_data = NULL; | 362 gc->proto_data = NULL; |
363 silc_free(sg); | 363 silc_free(sg); |
364 return; | 364 return; |
365 } | 365 } |
369 purple_account_get_string(account, "server", | 369 purple_account_get_string(account, "server", |
370 "silc.silcnet.org"), | 370 "silc.silcnet.org"), |
371 purple_account_get_int(account, "port", 706), | 371 purple_account_get_int(account, "port", 706), |
372 silcpurple_login_connected, gc) == NULL) | 372 silcpurple_login_connected, gc) == NULL) |
373 { | 373 { |
374 purple_connection_error_reason(gc, PURPLE_REASON_NETWORK_ERROR, | 374 purple_connection_error_reason(gc, PURPLE_CONNECTION_ERROR_NETWORK_ERROR, |
375 _("Unable to create connection")); | 375 _("Unable to create connection")); |
376 gc->proto_data = NULL; | 376 gc->proto_data = NULL; |
377 silc_free(sg); | 377 silc_free(sg); |
378 return; | 378 return; |
379 } | 379 } |
399 strcat(params.nickname_format, "%n#a"); | 399 strcat(params.nickname_format, "%n#a"); |
400 | 400 |
401 /* Allocate SILC client */ | 401 /* Allocate SILC client */ |
402 client = silc_client_alloc(&ops, ¶ms, gc, NULL); | 402 client = silc_client_alloc(&ops, ¶ms, gc, NULL); |
403 if (!client) { | 403 if (!client) { |
404 purple_connection_error_reason(gc, PURPLE_REASON_OTHER_ERROR, | 404 purple_connection_error_reason(gc, PURPLE_CONNECTION_ERROR_OTHER_ERROR, |
405 _("Out of memory")); | 405 _("Out of memory")); |
406 return; | 406 return; |
407 } | 407 } |
408 | 408 |
409 /* Get username, real name and local hostname for SILC library */ | 409 /* Get username, real name and local hostname for SILC library */ |
442 } | 442 } |
443 | 443 |
444 /* Init SILC client */ | 444 /* Init SILC client */ |
445 if (!silc_client_init(client, username, hostname, realname, | 445 if (!silc_client_init(client, username, hostname, realname, |
446 silcpurple_running, account)) { | 446 silcpurple_running, account)) { |
447 purple_connection_error_reason(gc, PURPLE_REASON_OTHER_ERROR, | 447 purple_connection_error_reason(gc, PURPLE_CONNECTION_ERROR_OTHER_ERROR, |
448 _("Cannot initialize SILC protocol")); | 448 _("Cannot initialize SILC protocol")); |
449 return; | 449 return; |
450 } | 450 } |
451 | 451 |
452 /* Check the ~/.silc dir and create it, and new key pair if necessary. */ | 452 /* Check the ~/.silc dir and create it, and new key pair if necessary. */ |
453 if (!silcpurple_check_silc_dir(gc)) { | 453 if (!silcpurple_check_silc_dir(gc)) { |
454 purple_connection_error_reason(gc, PURPLE_REASON_OTHER_ERROR, | 454 purple_connection_error_reason(gc, PURPLE_CONNECTION_ERROR_OTHER_ERROR, |
455 _("Error loading SILC key pair")); | 455 _("Error loading SILC key pair")); |
456 return; | 456 return; |
457 } | 457 } |
458 | 458 |
459 /* Schedule SILC using Glib's event loop */ | 459 /* Schedule SILC using Glib's event loop */ |