comparison finch/gntaccount.c @ 17523:f8e3b38f8e12

merge of '73e35014c64a318321f84ca240fbc590a80e4bec' and 'f9cc29b95a26f2096158d49d01c9007d6907e441'
author Sadrul Habib Chowdhury <imadil@gmail.com>
date Sat, 26 May 2007 23:57:42 +0000
parents 8c3a3407af58 7f652ef12ed6
children e2e709e5446b
comparison
equal deleted inserted replaced
17419:8c3a3407af58 17523:f8e3b38f8e12
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
863 char *alias; 865 char *alias;
864 PurpleAccount *account; 866 PurpleAccount *account;
865 } auth_and_add; 867 } auth_and_add;
866 868
867 static void 869 static void
870 free_auth_and_add(auth_and_add *aa)
871 {
872 g_free(aa->username);
873 g_free(aa->alias);
874 g_free(aa);
875 }
876
877 static void
868 authorize_and_add_cb(auth_and_add *aa) 878 authorize_and_add_cb(auth_and_add *aa)
869 { 879 {
870 aa->auth_cb(aa->data); 880 aa->auth_cb(aa->data);
871 purple_blist_request_add_buddy(aa->account, aa->username, 881 purple_blist_request_add_buddy(aa->account, aa->username,
872 NULL, aa->alias); 882 NULL, aa->alias);
873
874 g_free(aa->username);
875 g_free(aa->alias);
876 g_free(aa);
877 } 883 }
878 884
879 static void 885 static void
880 deny_no_add_cb(auth_and_add *aa) 886 deny_no_add_cb(auth_and_add *aa)
881 { 887 {
882 aa->deny_cb(aa->data); 888 aa->deny_cb(aa->data);
883
884 g_free(aa->username);
885 g_free(aa->alias);
886 g_free(aa);
887 } 889 }
888 890
889 static void * 891 static void *
890 finch_request_authorize(PurpleAccount *account, const char *remote_user, 892 finch_request_authorize(PurpleAccount *account, const char *remote_user,
891 const char *id, const char *alias, const char *message, gboolean on_list, 893 const char *id, const char *alias, const char *message, gboolean on_list,
910 ? purple_connection_get_display_name(gc) 912 ? purple_connection_get_display_name(gc)
911 : purple_account_get_username(account))), 913 : purple_account_get_username(account))),
912 (message != NULL ? ": " : "."), 914 (message != NULL ? ": " : "."),
913 (message != NULL ? message : "")); 915 (message != NULL ? message : ""));
914 if (!on_list) { 916 if (!on_list) {
917 GntWidget *widget;
918 GList *iter;
915 auth_and_add *aa = g_new(auth_and_add, 1); 919 auth_and_add *aa = g_new(auth_and_add, 1);
920
916 aa->auth_cb = (PurpleAccountRequestAuthorizationCb)auth_cb; 921 aa->auth_cb = (PurpleAccountRequestAuthorizationCb)auth_cb;
917 aa->deny_cb = (PurpleAccountRequestAuthorizationCb)deny_cb; 922 aa->deny_cb = (PurpleAccountRequestAuthorizationCb)deny_cb;
918 aa->data = user_data; 923 aa->data = user_data;
919 aa->username = g_strdup(remote_user); 924 aa->username = g_strdup(remote_user);
920 aa->alias = g_strdup(alias); 925 aa->alias = g_strdup(alias);
921 aa->account = account; 926 aa->account = account;
922 uihandle = purple_request_action(NULL, _("Authorize buddy?"), buffer, NULL, 927
928 uihandle = gnt_vwindow_new(FALSE);
929 gnt_box_set_title(GNT_BOX(uihandle), _("Authorize buddy?"));
930 gnt_box_set_pad(GNT_BOX(uihandle), 0);
931
932 widget = purple_request_action(NULL, _("Authorize buddy?"), buffer, NULL,
923 PURPLE_DEFAULT_ACTION_NONE, 933 PURPLE_DEFAULT_ACTION_NONE,
924 account, remote_user, NULL, 934 account, remote_user, NULL,
925 aa, 2, 935 aa, 2,
926 _("Authorize"), authorize_and_add_cb, 936 _("Authorize"), authorize_and_add_cb,
927 _("Deny"), deny_no_add_cb); 937 _("Deny"), deny_no_add_cb);
938 gnt_screen_release(widget);
939 gnt_box_set_toplevel(GNT_BOX(widget), FALSE);
940 gnt_box_add_widget(GNT_BOX(uihandle), widget);
941
942 gnt_box_add_widget(GNT_BOX(uihandle), gnt_hline_new());
943
944 widget = finch_retrieve_user_info(account->gc, remote_user);
945 for (iter = GNT_BOX(widget)->list; iter; iter = iter->next) {
946 if (GNT_IS_BUTTON(iter->data)) {
947 gnt_widget_destroy(iter->data);
948 gnt_box_remove(GNT_BOX(widget), iter->data);
949 break;
950 }
951 }
952 gnt_box_set_toplevel(GNT_BOX(widget), FALSE);
953 gnt_screen_release(widget);
954 gnt_box_add_widget(GNT_BOX(uihandle), widget);
955 gnt_widget_show(uihandle);
956
957 g_signal_connect_swapped(G_OBJECT(uihandle), "destroy", G_CALLBACK(free_auth_and_add), aa);
928 } else { 958 } else {
929 uihandle = purple_request_action(NULL, _("Authorize buddy?"), buffer, NULL, 959 uihandle = purple_request_action(NULL, _("Authorize buddy?"), buffer, NULL,
930 PURPLE_DEFAULT_ACTION_NONE, 960 PURPLE_DEFAULT_ACTION_NONE,
931 account, remote_user, NULL, 961 account, remote_user, NULL,
932 user_data, 2, 962 user_data, 2,