Mercurial > pidgin.yaz
comparison pidgin/gtkaccount.c @ 30909:25e200cb3532
propagate from branch 'im.pidgin.pidgin' (head dca20e09164518b0f7a773edd7e9649f41d8873d)
to branch 'im.pidgin.cpw.malu.xmpp.google_refactor' (head 7823c556f2d1bbca43f5ef9f0fea30cabc5d313f)
author | Marcus Lundblad <ml@update.uu.se> |
---|---|
date | Tue, 31 Aug 2010 18:28:10 +0000 |
parents | c62fac7ada0d |
children | a1964c506f29 |
comparison
equal
deleted
inserted
replaced
30908:c44ec533a48c | 30909:25e200cb3532 |
---|---|
2416 pidgin_blist_add_alert(alert); | 2416 pidgin_blist_add_alert(alert); |
2417 | 2417 |
2418 g_free(buffer); | 2418 g_free(buffer); |
2419 } | 2419 } |
2420 | 2420 |
2421 struct auth_and_add { | 2421 struct auth_request |
2422 { | |
2422 PurpleAccountRequestAuthorizationCb auth_cb; | 2423 PurpleAccountRequestAuthorizationCb auth_cb; |
2423 PurpleAccountRequestAuthorizationCb deny_cb; | 2424 PurpleAccountRequestAuthorizationCb deny_cb; |
2424 void *data; | 2425 void *data; |
2425 char *username; | 2426 char *username; |
2426 char *alias; | 2427 char *alias; |
2427 PurpleAccount *account; | 2428 PurpleAccount *account; |
2429 gboolean add_buddy_after_auth; | |
2428 }; | 2430 }; |
2429 | 2431 |
2430 static void | 2432 static void |
2431 free_auth_and_add(struct auth_and_add *aa) | 2433 free_auth_request(struct auth_request *ar) |
2432 { | 2434 { |
2433 g_free(aa->username); | 2435 g_free(ar->username); |
2434 g_free(aa->alias); | 2436 g_free(ar->alias); |
2435 g_free(aa); | 2437 g_free(ar); |
2436 } | 2438 } |
2437 | 2439 |
2438 static void | 2440 static void |
2439 authorize_and_add_cb(struct auth_and_add *aa) | 2441 authorize_and_add_cb(struct auth_request *ar) |
2440 { | 2442 { |
2441 aa->auth_cb(aa->data); | 2443 ar->auth_cb(ar->data); |
2442 purple_blist_request_add_buddy(aa->account, aa->username, | 2444 if (ar->add_buddy_after_auth) { |
2443 NULL, aa->alias); | 2445 purple_blist_request_add_buddy(ar->account, ar->username, NULL, ar->alias); |
2444 } | 2446 } |
2445 | 2447 } |
2446 static void | 2448 |
2447 deny_no_add_cb(struct auth_and_add *aa) | 2449 static void |
2448 { | 2450 deny_no_add_cb(struct auth_request *ar) |
2449 aa->deny_cb(aa->data); | 2451 { |
2452 ar->deny_cb(ar->data); | |
2450 } | 2453 } |
2451 | 2454 |
2452 static void * | 2455 static void * |
2453 pidgin_accounts_request_authorization(PurpleAccount *account, | 2456 pidgin_accounts_request_authorization(PurpleAccount *account, |
2454 const char *remote_user, | 2457 const char *remote_user, |
2461 void *user_data) | 2464 void *user_data) |
2462 { | 2465 { |
2463 char *buffer; | 2466 char *buffer; |
2464 PurpleConnection *gc; | 2467 PurpleConnection *gc; |
2465 GtkWidget *alert; | 2468 GtkWidget *alert; |
2469 GdkPixbuf *prpl_icon; | |
2470 struct auth_request *aa; | |
2466 | 2471 |
2467 gc = purple_account_get_connection(account); | 2472 gc = purple_account_get_connection(account); |
2468 if (message != NULL && *message == '\0') | 2473 if (message != NULL && *message == '\0') |
2469 message = NULL; | 2474 message = NULL; |
2470 | 2475 |
2471 buffer = g_strdup_printf(_("%s%s%s%s wants to add %s to his or her buddy list%s%s"), | 2476 buffer = g_strdup_printf(_("%s%s%s%s wants to add you (%s) to his or her buddy list%s%s"), |
2472 remote_user, | 2477 remote_user, |
2473 (alias != NULL ? " (" : ""), | 2478 (alias != NULL ? " (" : ""), |
2474 (alias != NULL ? alias : ""), | 2479 (alias != NULL ? alias : ""), |
2475 (alias != NULL ? ")" : ""), | 2480 (alias != NULL ? ")" : ""), |
2476 (id != NULL | 2481 (id != NULL |
2477 ? id | 2482 ? id |
2478 : (purple_connection_get_display_name(gc) != NULL | 2483 : (purple_connection_get_display_name(gc) != NULL |
2479 ? purple_connection_get_display_name(gc) | 2484 ? purple_connection_get_display_name(gc) |
2480 : purple_account_get_username(account))), | 2485 : purple_account_get_username(account))), |
2481 (message != NULL ? ": " : "."), | 2486 (message != NULL ? ": " : "."), |
2482 (message != NULL ? message : "")); | 2487 (message != NULL ? message : "")); |
2483 | 2488 |
2484 | 2489 |
2485 if (!on_list) { | 2490 prpl_icon = pidgin_create_prpl_icon(account, PIDGIN_PRPL_ICON_SMALL); |
2486 struct auth_and_add *aa = g_new0(struct auth_and_add, 1); | 2491 |
2487 aa->auth_cb = auth_cb; | 2492 aa = g_new0(struct auth_request, 1); |
2488 aa->deny_cb = deny_cb; | 2493 aa->auth_cb = auth_cb; |
2489 aa->data = user_data; | 2494 aa->deny_cb = deny_cb; |
2490 aa->username = g_strdup(remote_user); | 2495 aa->data = user_data; |
2491 aa->alias = g_strdup(alias); | 2496 aa->username = g_strdup(remote_user); |
2492 aa->account = account; | 2497 aa->alias = g_strdup(alias); |
2493 alert = pidgin_make_mini_dialog(gc, PIDGIN_STOCK_DIALOG_QUESTION, | 2498 aa->account = account; |
2494 _("Authorize buddy?"), buffer, aa, | 2499 aa->add_buddy_after_auth = !on_list; |
2495 _("Authorize"), authorize_and_add_cb, | 2500 |
2496 _("Deny"), deny_no_add_cb, | 2501 alert = pidgin_make_mini_dialog_with_custom_icon( |
2497 NULL); | 2502 gc, prpl_icon, |
2498 g_signal_connect_swapped(G_OBJECT(alert), "destroy", G_CALLBACK(free_auth_and_add), aa); | 2503 _("Authorize buddy?"), buffer, aa, |
2499 } else { | 2504 _("Authorize"), authorize_and_add_cb, |
2500 alert = pidgin_make_mini_dialog(gc, PIDGIN_STOCK_DIALOG_QUESTION, | 2505 _("Deny"), deny_no_add_cb, |
2501 _("Authorize buddy?"), buffer, user_data, | 2506 NULL); |
2502 _("Authorize"), auth_cb, | 2507 |
2503 _("Deny"), deny_cb, | 2508 g_signal_connect_swapped(G_OBJECT(alert), "destroy", G_CALLBACK(free_auth_request), aa); |
2504 NULL); | 2509 g_signal_connect(G_OBJECT(alert), "destroy", G_CALLBACK(purple_account_request_close), NULL); |
2505 } | |
2506 pidgin_blist_add_alert(alert); | 2510 pidgin_blist_add_alert(alert); |
2507 g_signal_connect(G_OBJECT(alert), "destroy", | |
2508 G_CALLBACK(purple_account_request_close), NULL); | |
2509 | 2511 |
2510 g_free(buffer); | 2512 g_free(buffer); |
2511 | 2513 |
2512 return alert; | 2514 return alert; |
2513 } | 2515 } |