| 2420 g_free(accounts_window); |
2420 g_free(accounts_window); |
| 2421 accounts_window = NULL; |
2421 accounts_window = NULL; |
| 2422 } |
2422 } |
| 2423 |
2423 |
| 2424 static void |
2424 static void |
| 2425 free_add_user_data(PidginAccountAddUserData *data) |
2425 free_add_user_data(G_GNUC_UNUSED PidginMiniDialog *mini_dialog, |
| 2426 { |
2426 G_GNUC_UNUSED GtkButton *button, |
| |
2427 gpointer user_data) |
| |
2428 { |
| |
2429 PidginAccountAddUserData *data = user_data; |
| 2427 g_free(data->username); |
2430 g_free(data->username); |
| 2428 g_free(data->alias); |
2431 g_free(data->alias); |
| 2429 g_free(data); |
2432 g_free(data); |
| 2430 } |
2433 } |
| 2431 |
2434 |
| 2432 static void |
2435 static void |
| 2433 add_user_cb(PidginAccountAddUserData *data) |
2436 add_user_cb(G_GNUC_UNUSED PidginMiniDialog *mini_dialog, |
| 2434 { |
2437 G_GNUC_UNUSED GtkButton *button, gpointer user_data) |
| |
2438 { |
| |
2439 PidginAccountAddUserData *data = user_data; |
| 2435 PurpleConnection *gc = purple_account_get_connection(data->account); |
2440 PurpleConnection *gc = purple_account_get_connection(data->account); |
| 2436 |
2441 |
| 2437 if (g_list_find(purple_connections_get_all(), gc)) |
2442 if (g_list_find(purple_connections_get_all(), gc)) |
| 2438 { |
2443 { |
| 2439 purple_blist_request_add_buddy(data->account, data->username, |
2444 purple_blist_request_add_buddy(data->account, data->username, |
| 2440 NULL, data->alias); |
2445 NULL, data->alias); |
| 2441 } |
2446 } |
| 2442 |
2447 |
| 2443 free_add_user_data(data); |
2448 free_add_user_data(NULL, NULL, user_data); |
| 2444 } |
2449 } |
| 2445 |
2450 |
| 2446 static char * |
2451 static char * |
| 2447 make_info(PurpleAccount *account, PurpleConnection *gc, const char *remote_user, |
2452 make_info(PurpleAccount *account, PurpleConnection *gc, const char *remote_user, |
| 2448 const char *id, const char *alias, const char *msg) |
2453 const char *id, const char *alias, const char *msg) |
| 2474 GtkWidget *alert; |
2479 GtkWidget *alert; |
| 2475 |
2480 |
| 2476 gc = purple_account_get_connection(account); |
2481 gc = purple_account_get_connection(account); |
| 2477 |
2482 |
| 2478 buffer = make_info(account, gc, remote_user, id, alias, msg); |
2483 buffer = make_info(account, gc, remote_user, id, alias, msg); |
| 2479 alert = pidgin_make_mini_dialog(gc, "dialog-information", buffer, |
2484 alert = pidgin_mini_dialog_new_with_buttons( |
| 2480 NULL, NULL, _("Close"), NULL, NULL); |
2485 buffer, NULL, "dialog-information", NULL, |
| |
2486 _("Close"), NULL, NULL); |
| 2481 pidgin_blist_add_alert(alert); |
2487 pidgin_blist_add_alert(alert); |
| 2482 |
2488 |
| 2483 g_free(buffer); |
2489 g_free(buffer); |
| 2484 } |
2490 } |
| 2485 |
2491 |
| 2499 data->account = account; |
2505 data->account = account; |
| 2500 data->username = g_strdup(remote_user); |
2506 data->username = g_strdup(remote_user); |
| 2501 data->alias = g_strdup(alias); |
2507 data->alias = g_strdup(alias); |
| 2502 |
2508 |
| 2503 buffer = make_info(account, gc, remote_user, id, alias, msg); |
2509 buffer = make_info(account, gc, remote_user, id, alias, msg); |
| 2504 alert = pidgin_make_mini_dialog(gc, "dialog-question", |
2510 alert = pidgin_mini_dialog_new_with_buttons( |
| 2505 _("Add buddy to your list?"), buffer, data, |
2511 _("Add buddy to your list?"), buffer, "dialog-question", data, |
| 2506 _("Add"), G_CALLBACK(add_user_cb), |
2512 _("Add"), add_user_cb, _("Cancel"), free_add_user_data, NULL); |
| 2507 _("Cancel"), G_CALLBACK(free_add_user_data), NULL); |
|
| 2508 pidgin_blist_add_alert(alert); |
2513 pidgin_blist_add_alert(alert); |
| 2509 |
2514 |
| 2510 g_free(buffer); |
2515 g_free(buffer); |
| 2511 } |
2516 } |
| 2512 |
2517 |
| 2543 { |
2548 { |
| 2544 authorize_and_add_cb(ar, NULL); |
2549 authorize_and_add_cb(ar, NULL); |
| 2545 } |
2550 } |
| 2546 |
2551 |
| 2547 static void |
2552 static void |
| 2548 authorize_reason_cb(struct auth_request *ar) |
2553 authorize_reason_cb(G_GNUC_UNUSED PidginMiniDialog *mini_dialog, |
| 2549 { |
2554 G_GNUC_UNUSED GtkButton *button, gpointer user_data) |
| |
2555 { |
| |
2556 struct auth_request *ar = user_data; |
| 2550 PurpleProtocol *protocol = purple_account_get_protocol(ar->account); |
2557 PurpleProtocol *protocol = purple_account_get_protocol(ar->account); |
| 2551 |
2558 |
| 2552 if (protocol && (purple_protocol_get_options(protocol) & OPT_PROTO_AUTHORIZATION_GRANTED_MESSAGE)) { |
2559 if (protocol && (purple_protocol_get_options(protocol) & OPT_PROTO_AUTHORIZATION_GRANTED_MESSAGE)) { |
| 2553 /* Duplicate information because ar is freed by closing minidialog */ |
2560 /* Duplicate information because ar is freed by closing minidialog */ |
| 2554 struct auth_request *aa = g_new0(struct auth_request, 1); |
2561 struct auth_request *aa = g_new0(struct auth_request, 1); |
| 2582 { |
2589 { |
| 2583 ar->deny_cb(NULL, ar->data); |
2590 ar->deny_cb(NULL, ar->data); |
| 2584 } |
2591 } |
| 2585 |
2592 |
| 2586 static void |
2593 static void |
| 2587 deny_reason_cb(struct auth_request *ar) |
2594 deny_reason_cb(G_GNUC_UNUSED PidginMiniDialog *mini_dialog, |
| 2588 { |
2595 G_GNUC_UNUSED GtkButton *button, gpointer user_data) |
| |
2596 { |
| |
2597 struct auth_request *ar = user_data; |
| 2589 PurpleProtocol *protocol = purple_account_get_protocol(ar->account); |
2598 PurpleProtocol *protocol = purple_account_get_protocol(ar->account); |
| 2590 |
2599 |
| 2591 if (protocol && (purple_protocol_get_options(protocol) & OPT_PROTO_AUTHORIZATION_DENIED_MESSAGE)) { |
2600 if (protocol && (purple_protocol_get_options(protocol) & OPT_PROTO_AUTHORIZATION_DENIED_MESSAGE)) { |
| 2592 /* Duplicate information because ar is freed by closing minidialog */ |
2601 /* Duplicate information because ar is freed by closing minidialog */ |
| 2593 struct auth_request *aa = g_new0(struct auth_request, 1); |
2602 struct auth_request *aa = g_new0(struct auth_request, 1); |
| 2692 aa->username = g_strdup(remote_user); |
2701 aa->username = g_strdup(remote_user); |
| 2693 aa->alias = g_strdup(alias); |
2702 aa->alias = g_strdup(alias); |
| 2694 aa->account = account; |
2703 aa->account = account; |
| 2695 aa->add_buddy_after_auth = !on_list; |
2704 aa->add_buddy_after_auth = !on_list; |
| 2696 |
2705 |
| 2697 alert = pidgin_make_mini_dialog_with_custom_icon( |
2706 dialog = pidgin_mini_dialog_new_with_custom_icon( |
| 2698 gc, protocol_icon, |
2707 _("Authorize buddy?"), NULL, protocol_icon); |
| 2699 _("Authorize buddy?"), NULL, aa, |
2708 alert = GTK_WIDGET(dialog); |
| 2700 _("Authorize"), authorize_reason_cb, |
2709 |
| 2701 _("Deny"), deny_reason_cb, |
|
| 2702 NULL); |
|
| 2703 |
|
| 2704 dialog = PIDGIN_MINI_DIALOG(alert); |
|
| 2705 pidgin_mini_dialog_enable_description_markup(dialog); |
2710 pidgin_mini_dialog_enable_description_markup(dialog); |
| 2706 pidgin_mini_dialog_set_link_callback(dialog, G_CALLBACK(get_user_info_cb), aa); |
2711 pidgin_mini_dialog_set_link_callback(dialog, G_CALLBACK(get_user_info_cb), aa); |
| 2707 pidgin_mini_dialog_set_description(dialog, buffer); |
2712 pidgin_mini_dialog_set_description(dialog, buffer); |
| |
2713 pidgin_mini_dialog_add_button(dialog, _("Authorize"), authorize_reason_cb, aa); |
| |
2714 pidgin_mini_dialog_add_button(dialog, _("Deny"), deny_reason_cb, aa); |
| 2708 pidgin_mini_dialog_add_non_closing_button(dialog, _("Send Instant Message"), send_im_cb, aa); |
2715 pidgin_mini_dialog_add_non_closing_button(dialog, _("Send Instant Message"), send_im_cb, aa); |
| 2709 |
2716 |
| 2710 g_signal_connect_swapped(G_OBJECT(alert), "destroy", G_CALLBACK(free_auth_request), aa); |
2717 g_signal_connect_swapped(G_OBJECT(alert), "destroy", G_CALLBACK(free_auth_request), aa); |
| 2711 g_signal_connect(G_OBJECT(alert), "destroy", G_CALLBACK(purple_account_request_close), NULL); |
2718 g_signal_connect(G_OBJECT(alert), "destroy", G_CALLBACK(purple_account_request_close), NULL); |
| 2712 pidgin_blist_add_alert(alert); |
2719 pidgin_blist_add_alert(alert); |