Mercurial > pidgin.yaz
comparison finch/gntaccount.c @ 18002:38a72d6dce7f
merge of '9e832cea16395c9007bc9e384ee379b293b99abd'
and 'bda8b30520ae63b1ce117a6799cb41a65c55018d'
author | Sadrul Habib Chowdhury <imadil@gmail.com> |
---|---|
date | Mon, 04 Jun 2007 06:32:21 +0000 |
parents | e2e709e5446b |
children | 58e28ccf08e6 |
comparison
equal
deleted
inserted
replaced
17707:01021bb5c709 | 18002:38a72d6dce7f |
---|---|
29 #include <gntcombobox.h> | 29 #include <gntcombobox.h> |
30 #include <gntentry.h> | 30 #include <gntentry.h> |
31 #include <gntlabel.h> | 31 #include <gntlabel.h> |
32 #include <gntline.h> | 32 #include <gntline.h> |
33 #include <gnttree.h> | 33 #include <gnttree.h> |
34 #include <gntwindow.h> | |
34 | 35 |
35 #include <account.h> | 36 #include <account.h> |
36 #include <accountopt.h> | 37 #include <accountopt.h> |
37 #include <connection.h> | 38 #include <connection.h> |
38 #include <notify.h> | 39 #include <notify.h> |
39 #include <plugin.h> | 40 #include <plugin.h> |
40 #include <request.h> | 41 #include <request.h> |
41 | 42 |
42 #include "gntaccount.h" | 43 #include "gntaccount.h" |
44 #include "gntblist.h" | |
43 #include "finch.h" | 45 #include "finch.h" |
44 | 46 |
45 #include <string.h> | 47 #include <string.h> |
46 | 48 |
47 typedef struct | 49 typedef struct |
741 PURPLE_CALLBACK(account_abled_cb), GINT_TO_POINTER(FALSE)); | 743 PURPLE_CALLBACK(account_abled_cb), GINT_TO_POINTER(FALSE)); |
742 purple_signal_connect(purple_accounts_get_handle(), "account-enabled", | 744 purple_signal_connect(purple_accounts_get_handle(), "account-enabled", |
743 finch_accounts_get_handle(), | 745 finch_accounts_get_handle(), |
744 PURPLE_CALLBACK(account_abled_cb), GINT_TO_POINTER(TRUE)); | 746 PURPLE_CALLBACK(account_abled_cb), GINT_TO_POINTER(TRUE)); |
745 | 747 |
746 for (iter = purple_accounts_get_all(); iter; iter = iter->next) { | 748 iter = purple_accounts_get_all(); |
747 if (purple_account_get_enabled(iter->data, FINCH_UI)) | 749 if (iter) { |
748 break; | 750 for (; iter; iter = iter->next) { |
749 } | 751 if (purple_account_get_enabled(iter->data, FINCH_UI)) |
750 if (!iter) | 752 break; |
753 } | |
754 if (!iter) | |
755 finch_accounts_show_all(); | |
756 } else { | |
757 edit_account(NULL); | |
751 finch_accounts_show_all(); | 758 finch_accounts_show_all(); |
759 } | |
752 } | 760 } |
753 | 761 |
754 void finch_accounts_uninit() | 762 void finch_accounts_uninit() |
755 { | 763 { |
756 if (accounts.window) | 764 if (accounts.window) |
863 char *alias; | 871 char *alias; |
864 PurpleAccount *account; | 872 PurpleAccount *account; |
865 } auth_and_add; | 873 } auth_and_add; |
866 | 874 |
867 static void | 875 static void |
876 free_auth_and_add(auth_and_add *aa) | |
877 { | |
878 g_free(aa->username); | |
879 g_free(aa->alias); | |
880 g_free(aa); | |
881 } | |
882 | |
883 static void | |
868 authorize_and_add_cb(auth_and_add *aa) | 884 authorize_and_add_cb(auth_and_add *aa) |
869 { | 885 { |
870 aa->auth_cb(aa->data); | 886 aa->auth_cb(aa->data); |
871 purple_blist_request_add_buddy(aa->account, aa->username, | 887 purple_blist_request_add_buddy(aa->account, aa->username, |
872 NULL, aa->alias); | 888 NULL, aa->alias); |
873 | |
874 g_free(aa->username); | |
875 g_free(aa->alias); | |
876 g_free(aa); | |
877 } | 889 } |
878 | 890 |
879 static void | 891 static void |
880 deny_no_add_cb(auth_and_add *aa) | 892 deny_no_add_cb(auth_and_add *aa) |
881 { | 893 { |
882 aa->deny_cb(aa->data); | 894 aa->deny_cb(aa->data); |
883 | |
884 g_free(aa->username); | |
885 g_free(aa->alias); | |
886 g_free(aa); | |
887 } | 895 } |
888 | 896 |
889 static void * | 897 static void * |
890 finch_request_authorize(PurpleAccount *account, const char *remote_user, | 898 finch_request_authorize(PurpleAccount *account, const char *remote_user, |
891 const char *id, const char *alias, const char *message, gboolean on_list, | 899 const char *id, const char *alias, const char *message, gboolean on_list, |
910 ? purple_connection_get_display_name(gc) | 918 ? purple_connection_get_display_name(gc) |
911 : purple_account_get_username(account))), | 919 : purple_account_get_username(account))), |
912 (message != NULL ? ": " : "."), | 920 (message != NULL ? ": " : "."), |
913 (message != NULL ? message : "")); | 921 (message != NULL ? message : "")); |
914 if (!on_list) { | 922 if (!on_list) { |
923 GntWidget *widget; | |
924 GList *iter; | |
915 auth_and_add *aa = g_new(auth_and_add, 1); | 925 auth_and_add *aa = g_new(auth_and_add, 1); |
926 | |
916 aa->auth_cb = (PurpleAccountRequestAuthorizationCb)auth_cb; | 927 aa->auth_cb = (PurpleAccountRequestAuthorizationCb)auth_cb; |
917 aa->deny_cb = (PurpleAccountRequestAuthorizationCb)deny_cb; | 928 aa->deny_cb = (PurpleAccountRequestAuthorizationCb)deny_cb; |
918 aa->data = user_data; | 929 aa->data = user_data; |
919 aa->username = g_strdup(remote_user); | 930 aa->username = g_strdup(remote_user); |
920 aa->alias = g_strdup(alias); | 931 aa->alias = g_strdup(alias); |
921 aa->account = account; | 932 aa->account = account; |
922 uihandle = purple_request_action(NULL, _("Authorize buddy?"), buffer, NULL, | 933 |
934 uihandle = gnt_vwindow_new(FALSE); | |
935 gnt_box_set_title(GNT_BOX(uihandle), _("Authorize buddy?")); | |
936 gnt_box_set_pad(GNT_BOX(uihandle), 0); | |
937 | |
938 widget = purple_request_action(NULL, _("Authorize buddy?"), buffer, NULL, | |
923 PURPLE_DEFAULT_ACTION_NONE, | 939 PURPLE_DEFAULT_ACTION_NONE, |
924 account, remote_user, NULL, | 940 account, remote_user, NULL, |
925 aa, 2, | 941 aa, 2, |
926 _("Authorize"), authorize_and_add_cb, | 942 _("Authorize"), authorize_and_add_cb, |
927 _("Deny"), deny_no_add_cb); | 943 _("Deny"), deny_no_add_cb); |
944 gnt_screen_release(widget); | |
945 gnt_box_set_toplevel(GNT_BOX(widget), FALSE); | |
946 gnt_box_add_widget(GNT_BOX(uihandle), widget); | |
947 | |
948 gnt_box_add_widget(GNT_BOX(uihandle), gnt_hline_new()); | |
949 | |
950 widget = finch_retrieve_user_info(account->gc, remote_user); | |
951 for (iter = GNT_BOX(widget)->list; iter; iter = iter->next) { | |
952 if (GNT_IS_BUTTON(iter->data)) { | |
953 gnt_widget_destroy(iter->data); | |
954 gnt_box_remove(GNT_BOX(widget), iter->data); | |
955 break; | |
956 } | |
957 } | |
958 gnt_box_set_toplevel(GNT_BOX(widget), FALSE); | |
959 gnt_screen_release(widget); | |
960 gnt_box_add_widget(GNT_BOX(uihandle), widget); | |
961 gnt_widget_show(uihandle); | |
962 | |
963 g_signal_connect_swapped(G_OBJECT(uihandle), "destroy", G_CALLBACK(free_auth_and_add), aa); | |
928 } else { | 964 } else { |
929 uihandle = purple_request_action(NULL, _("Authorize buddy?"), buffer, NULL, | 965 uihandle = purple_request_action(NULL, _("Authorize buddy?"), buffer, NULL, |
930 PURPLE_DEFAULT_ACTION_NONE, | 966 PURPLE_DEFAULT_ACTION_NONE, |
931 account, remote_user, NULL, | 967 account, remote_user, NULL, |
932 user_data, 2, | 968 user_data, 2, |