Mercurial > pidgin.yaz
comparison finch/gntaccount.c @ 18068:0b3d6ea61760
propagate from branch 'im.pidgin.pidgin' (head 4b50880d8517570eaa67d4cd9d88c5934bb832f1)
to branch 'im.pidgin.pidgin.2.1.0' (head fefd59692d4177b91d52f6d71b1565b76c88725d)
author | Richard Laager <rlaager@wiktel.com> |
---|---|
date | Thu, 07 Jun 2007 14:48:33 +0000 |
parents | 4ca97b26a8fb |
children | 926ccb104da0 |
comparison
equal
deleted
inserted
replaced
17782:5eebb9b24e30 | 18068:0b3d6ea61760 |
---|---|
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 |
278 const char *value = NULL; | 280 const char *value = NULL; |
279 char *s; | 281 char *s; |
280 | 282 |
281 if (dialog->account) | 283 if (dialog->account) |
282 { | 284 { |
283 s = strrchr(username, purple_account_user_split_get_separator(split)); | 285 if(purple_account_user_split_get_reverse(split)) |
286 s = strrchr(username, purple_account_user_split_get_separator(split)); | |
287 else | |
288 s = strchr(username, purple_account_user_split_get_separator(split)); | |
289 | |
284 if (s != NULL) | 290 if (s != NULL) |
285 { | 291 { |
286 *s = '\0'; | 292 *s = '\0'; |
287 s++; | 293 s++; |
288 value = s; | 294 value = s; |
633 accounts.tree = NULL; | 639 accounts.tree = NULL; |
634 } | 640 } |
635 | 641 |
636 void finch_accounts_show_all() | 642 void finch_accounts_show_all() |
637 { | 643 { |
638 GList *iter; | 644 const GList *iter; |
639 GntWidget *box, *button; | 645 GntWidget *box, *button; |
640 | 646 |
641 if (accounts.window) | 647 if (accounts.window) |
642 return; | 648 return; |
643 | 649 |
726 GPOINTER_TO_INT(user_data)); | 732 GPOINTER_TO_INT(user_data)); |
727 } | 733 } |
728 | 734 |
729 void finch_accounts_init() | 735 void finch_accounts_init() |
730 { | 736 { |
731 GList *iter; | 737 const GList *iter; |
732 | 738 |
733 purple_signal_connect(purple_accounts_get_handle(), "account-added", | 739 purple_signal_connect(purple_accounts_get_handle(), "account-added", |
734 finch_accounts_get_handle(), PURPLE_CALLBACK(account_added_callback), | 740 finch_accounts_get_handle(), PURPLE_CALLBACK(account_added_callback), |
735 NULL); | 741 NULL); |
736 purple_signal_connect(purple_accounts_get_handle(), "account-removed", | 742 purple_signal_connect(purple_accounts_get_handle(), "account-removed", |
741 PURPLE_CALLBACK(account_abled_cb), GINT_TO_POINTER(FALSE)); | 747 PURPLE_CALLBACK(account_abled_cb), GINT_TO_POINTER(FALSE)); |
742 purple_signal_connect(purple_accounts_get_handle(), "account-enabled", | 748 purple_signal_connect(purple_accounts_get_handle(), "account-enabled", |
743 finch_accounts_get_handle(), | 749 finch_accounts_get_handle(), |
744 PURPLE_CALLBACK(account_abled_cb), GINT_TO_POINTER(TRUE)); | 750 PURPLE_CALLBACK(account_abled_cb), GINT_TO_POINTER(TRUE)); |
745 | 751 |
746 for (iter = purple_accounts_get_all(); iter; iter = iter->next) { | 752 iter = purple_accounts_get_all(); |
747 if (purple_account_get_enabled(iter->data, FINCH_UI)) | 753 if (iter) { |
748 break; | 754 for (; iter; iter = iter->next) { |
749 } | 755 if (purple_account_get_enabled(iter->data, FINCH_UI)) |
750 if (!iter) | 756 break; |
757 } | |
758 if (!iter) | |
759 finch_accounts_show_all(); | |
760 } else { | |
761 edit_account(NULL); | |
751 finch_accounts_show_all(); | 762 finch_accounts_show_all(); |
763 } | |
752 } | 764 } |
753 | 765 |
754 void finch_accounts_uninit() | 766 void finch_accounts_uninit() |
755 { | 767 { |
756 if (accounts.window) | 768 if (accounts.window) |
817 static void | 829 static void |
818 add_user_cb(AddUserData *data) | 830 add_user_cb(AddUserData *data) |
819 { | 831 { |
820 PurpleConnection *gc = purple_account_get_connection(data->account); | 832 PurpleConnection *gc = purple_account_get_connection(data->account); |
821 | 833 |
822 if (g_list_find(purple_connections_get_all(), gc)) | 834 if (g_list_find((GList *)purple_connections_get_all(), gc)) |
823 { | 835 { |
824 purple_blist_request_add_buddy(data->account, data->username, | 836 purple_blist_request_add_buddy(data->account, data->username, |
825 NULL, data->alias); | 837 NULL, data->alias); |
826 } | 838 } |
827 | 839 |
863 char *alias; | 875 char *alias; |
864 PurpleAccount *account; | 876 PurpleAccount *account; |
865 } auth_and_add; | 877 } auth_and_add; |
866 | 878 |
867 static void | 879 static void |
880 free_auth_and_add(auth_and_add *aa) | |
881 { | |
882 g_free(aa->username); | |
883 g_free(aa->alias); | |
884 g_free(aa); | |
885 } | |
886 | |
887 static void | |
868 authorize_and_add_cb(auth_and_add *aa) | 888 authorize_and_add_cb(auth_and_add *aa) |
869 { | 889 { |
870 aa->auth_cb(aa->data); | 890 aa->auth_cb(aa->data); |
871 purple_blist_request_add_buddy(aa->account, aa->username, | 891 purple_blist_request_add_buddy(aa->account, aa->username, |
872 NULL, aa->alias); | 892 NULL, aa->alias); |
873 | |
874 g_free(aa->username); | |
875 g_free(aa->alias); | |
876 g_free(aa); | |
877 } | 893 } |
878 | 894 |
879 static void | 895 static void |
880 deny_no_add_cb(auth_and_add *aa) | 896 deny_no_add_cb(auth_and_add *aa) |
881 { | 897 { |
882 aa->deny_cb(aa->data); | 898 aa->deny_cb(aa->data); |
883 | |
884 g_free(aa->username); | |
885 g_free(aa->alias); | |
886 g_free(aa); | |
887 } | 899 } |
888 | 900 |
889 static void * | 901 static void * |
890 finch_request_authorize(PurpleAccount *account, const char *remote_user, | 902 finch_request_authorize(PurpleAccount *account, const char *remote_user, |
891 const char *id, const char *alias, const char *message, gboolean on_list, | 903 const char *id, const char *alias, const char *message, gboolean on_list, |
910 ? purple_connection_get_display_name(gc) | 922 ? purple_connection_get_display_name(gc) |
911 : purple_account_get_username(account))), | 923 : purple_account_get_username(account))), |
912 (message != NULL ? ": " : "."), | 924 (message != NULL ? ": " : "."), |
913 (message != NULL ? message : "")); | 925 (message != NULL ? message : "")); |
914 if (!on_list) { | 926 if (!on_list) { |
927 GntWidget *widget; | |
928 GList *iter; | |
915 auth_and_add *aa = g_new(auth_and_add, 1); | 929 auth_and_add *aa = g_new(auth_and_add, 1); |
930 | |
916 aa->auth_cb = (PurpleAccountRequestAuthorizationCb)auth_cb; | 931 aa->auth_cb = (PurpleAccountRequestAuthorizationCb)auth_cb; |
917 aa->deny_cb = (PurpleAccountRequestAuthorizationCb)deny_cb; | 932 aa->deny_cb = (PurpleAccountRequestAuthorizationCb)deny_cb; |
918 aa->data = user_data; | 933 aa->data = user_data; |
919 aa->username = g_strdup(remote_user); | 934 aa->username = g_strdup(remote_user); |
920 aa->alias = g_strdup(alias); | 935 aa->alias = g_strdup(alias); |
921 aa->account = account; | 936 aa->account = account; |
922 uihandle = purple_request_action(NULL, _("Authorize buddy?"), buffer, NULL, | 937 |
938 uihandle = gnt_vwindow_new(FALSE); | |
939 gnt_box_set_title(GNT_BOX(uihandle), _("Authorize buddy?")); | |
940 gnt_box_set_pad(GNT_BOX(uihandle), 0); | |
941 | |
942 widget = purple_request_action(NULL, _("Authorize buddy?"), buffer, NULL, | |
923 PURPLE_DEFAULT_ACTION_NONE, | 943 PURPLE_DEFAULT_ACTION_NONE, |
924 account, remote_user, NULL, | 944 account, remote_user, NULL, |
925 aa, 2, | 945 aa, 2, |
926 _("Authorize"), authorize_and_add_cb, | 946 _("Authorize"), authorize_and_add_cb, |
927 _("Deny"), deny_no_add_cb); | 947 _("Deny"), deny_no_add_cb); |
948 gnt_screen_release(widget); | |
949 gnt_box_set_toplevel(GNT_BOX(widget), FALSE); | |
950 gnt_box_add_widget(GNT_BOX(uihandle), widget); | |
951 | |
952 gnt_box_add_widget(GNT_BOX(uihandle), gnt_hline_new()); | |
953 | |
954 widget = finch_retrieve_user_info(account->gc, remote_user); | |
955 for (iter = GNT_BOX(widget)->list; iter; iter = iter->next) { | |
956 if (GNT_IS_BUTTON(iter->data)) { | |
957 gnt_widget_destroy(iter->data); | |
958 gnt_box_remove(GNT_BOX(widget), iter->data); | |
959 break; | |
960 } | |
961 } | |
962 gnt_box_set_toplevel(GNT_BOX(widget), FALSE); | |
963 gnt_screen_release(widget); | |
964 gnt_box_add_widget(GNT_BOX(uihandle), widget); | |
965 gnt_widget_show(uihandle); | |
966 | |
967 g_signal_connect_swapped(G_OBJECT(uihandle), "destroy", G_CALLBACK(free_auth_and_add), aa); | |
928 } else { | 968 } else { |
929 uihandle = purple_request_action(NULL, _("Authorize buddy?"), buffer, NULL, | 969 uihandle = purple_request_action(NULL, _("Authorize buddy?"), buffer, NULL, |
930 PURPLE_DEFAULT_ACTION_NONE, | 970 PURPLE_DEFAULT_ACTION_NONE, |
931 account, remote_user, NULL, | 971 account, remote_user, NULL, |
932 user_data, 2, | 972 user_data, 2, |