Mercurial > pidgin
comparison src/multi.c @ 4634:d19872836812
[gaim-migrate @ 4941]
This will let you set up different proxy settings for different accounts.
Mainly useful to the corporate users that need to connect to an internal
jabber server, and still want to connect to "external" stuff through a
proxy, or something along those lines. I'm sure someone will come up with
another use for it.
committer: Tailor Script <tailor@pidgin.im>
author | Nathan Walp <nwalp@pidgin.im> |
---|---|
date | Sun, 02 Mar 2003 18:48:02 +0000 |
parents | 5cdfd20daa07 |
children | 42d53c416bb9 |
comparison
equal
deleted
inserted
replaced
4633:812148fb2e2f | 4634:d19872836812 |
---|---|
17 * along with this program; if not, write to the Free Software | 17 * along with this program; if not, write to the Free Software |
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | 18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
19 * | 19 * |
20 */ | 20 */ |
21 | 21 |
22 #include <stdlib.h> | |
22 #include <string.h> | 23 #include <string.h> |
23 #include <ctype.h> | 24 #include <ctype.h> |
24 #include <gtk/gtk.h> | 25 #include <gtk/gtk.h> |
25 #include "prpl.h" | 26 #include "prpl.h" |
26 #include "multi.h" | 27 #include "multi.h" |
82 /* stuff for mail check prompt */ | 83 /* stuff for mail check prompt */ |
83 GtkWidget *checkmail; | 84 GtkWidget *checkmail; |
84 | 85 |
85 /* stuff for register with server */ | 86 /* stuff for register with server */ |
86 GtkWidget *register_user; | 87 GtkWidget *register_user; |
88 | |
89 /* stuff for proxy options */ | |
90 GtkWidget *proxy_frame; | |
91 GtkWidget *proxy_host_box; | |
92 GtkWidget *proxytype_menu; | |
93 GtkWidget *proxyhost_entry; | |
94 GtkWidget *proxyport_entry; | |
95 GtkWidget *proxyuser_entry; | |
96 GtkWidget *proxypass_entry; | |
87 }; | 97 }; |
88 | 98 |
89 | 99 |
90 struct mod_account_opt { | 100 struct mod_account_opt { |
91 struct mod_account *ma; | 101 struct mod_account *ma; |
349 GList *tmp; | 359 GList *tmp; |
350 const char *txt; | 360 const char *txt; |
351 struct gaim_account *a; | 361 struct gaim_account *a; |
352 struct prpl *p; | 362 struct prpl *p; |
353 GtkTreeIter iter; | 363 GtkTreeIter iter; |
364 int proxytype; | |
354 | 365 |
355 if (!ma->account) { | 366 if (!ma->account) { |
356 txt = gtk_entry_get_text(GTK_ENTRY(ma->name)); | 367 txt = gtk_entry_get_text(GTK_ENTRY(ma->name)); |
357 ma->account = gaim_account_new(txt, ma->protocol, ma->options); | 368 ma->account = gaim_account_new(txt, ma->protocol, ma->options); |
358 } | 369 } |
400 | 411 |
401 g_snprintf(a->iconfile, sizeof(a->iconfile), "%s", ma->iconfile); | 412 g_snprintf(a->iconfile, sizeof(a->iconfile), "%s", ma->iconfile); |
402 if (ma->icondlg) | 413 if (ma->icondlg) |
403 gtk_widget_destroy(ma->icondlg); | 414 gtk_widget_destroy(ma->icondlg); |
404 ma->icondlg = NULL; | 415 ma->icondlg = NULL; |
416 | |
417 if(ma->account->gpi) | |
418 g_free(ma->account->gpi); | |
419 ma->account->gpi = NULL; | |
420 | |
421 proxytype = (int)gtk_object_get_user_data(GTK_OBJECT(gtk_menu_get_active(GTK_MENU(ma->proxytype_menu)))); | |
422 | |
423 if(proxytype != PROXY_USE_GLOBAL) { | |
424 struct gaim_proxy_info *gpi = g_new0(struct gaim_proxy_info, 1); | |
425 gpi->proxytype = proxytype; | |
426 g_snprintf(gpi->proxyhost, sizeof(gpi->proxyhost), "%s", gtk_entry_get_text(GTK_ENTRY(ma->proxyhost_entry))); | |
427 gpi->proxyport = atoi(gtk_entry_get_text(GTK_ENTRY(ma->proxyport_entry))); | |
428 g_snprintf(gpi->proxyuser, sizeof(gpi->proxyuser), "%s", gtk_entry_get_text(GTK_ENTRY(ma->proxyuser_entry))); | |
429 g_snprintf(gpi->proxypass, sizeof(gpi->proxypass), "%s", gtk_entry_get_text(GTK_ENTRY(ma->proxypass_entry))); | |
430 | |
431 ma->account->gpi = gpi; | |
432 } | |
405 | 433 |
406 /* | 434 /* |
407 * See if user registration is supported/required | 435 * See if user registration is supported/required |
408 */ | 436 */ |
409 if((p = find_prpl(ma->protocol)) == NULL) { | 437 if((p = find_prpl(ma->protocol)) == NULL) { |
822 gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(ma->register_user), FALSE); | 850 gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(ma->register_user), FALSE); |
823 gtk_box_pack_start(GTK_BOX(vbox), ma->register_user, FALSE, FALSE, 0); | 851 gtk_box_pack_start(GTK_BOX(vbox), ma->register_user, FALSE, FALSE, 0); |
824 gtk_widget_show(ma->register_user); | 852 gtk_widget_show(ma->register_user); |
825 } | 853 } |
826 | 854 |
855 } | |
856 | |
857 static void proxy_dropdown_set(GtkObject *w, struct mod_account *ma) { | |
858 int opt = (int)gtk_object_get_user_data(w); | |
859 gtk_widget_set_sensitive(ma->proxy_host_box, (opt != PROXY_NONE && opt != PROXY_USE_GLOBAL)); | |
860 } | |
861 | |
862 static void generate_proxy_options(struct mod_account *ma, GtkWidget *box) { | |
863 GtkWidget *frame; | |
864 GtkWidget *hbox; | |
865 GtkWidget *vbox; | |
866 GtkWidget *label; | |
867 GtkWidget *menu; | |
868 GtkWidget *dropdown; | |
869 GtkWidget *opt; | |
870 GtkWidget *entry; | |
871 GtkWidget *vbox2; | |
872 | |
873 struct gaim_proxy_info *gpi = NULL; | |
874 | |
875 if(ma->account) | |
876 gpi = ma->account->gpi; | |
877 | |
878 frame = make_frame(box, _("Proxy Options")); | |
879 ma->proxy_frame = gtk_widget_get_parent(gtk_widget_get_parent(frame)); | |
880 gtk_widget_show_all(ma->proxy_frame); | |
881 | |
882 vbox = gtk_vbox_new(FALSE, 5); | |
883 gtk_container_set_border_width(GTK_CONTAINER(vbox), 5); | |
884 gtk_container_add(GTK_CONTAINER(frame), vbox); | |
885 gtk_widget_show(vbox); | |
886 | |
887 /* make the dropdown w/o the benefit of the easy helper funcs in prefs.c */ | |
888 hbox = gtk_hbox_new(FALSE, 5); | |
889 gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0); | |
890 gtk_widget_show(hbox); | |
891 | |
892 label = gtk_label_new_with_mnemonic(_("Proxy _Type")); | |
893 gtk_size_group_add_widget(ma->sg, label); | |
894 gtk_misc_set_alignment(GTK_MISC(label), 0, 0.5); | |
895 gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0); | |
896 gtk_widget_show(label); | |
897 | |
898 dropdown = gtk_option_menu_new(); | |
899 menu = gtk_menu_new(); | |
900 | |
901 opt = gtk_menu_item_new_with_label("Use Global Proxy Settings"); | |
902 gtk_object_set_user_data(GTK_OBJECT(opt), (gpointer)PROXY_USE_GLOBAL); | |
903 g_signal_connect(G_OBJECT(opt), "activate", | |
904 G_CALLBACK(proxy_dropdown_set), ma); | |
905 gtk_widget_show(opt); | |
906 gtk_menu_shell_append(GTK_MENU_SHELL(menu), opt); | |
907 if(!gpi) | |
908 gtk_menu_set_active(GTK_MENU(menu), 0); | |
909 | |
910 opt = gtk_menu_item_new_with_label("No Proxy"); | |
911 gtk_object_set_user_data(GTK_OBJECT(opt), (gpointer)PROXY_NONE); | |
912 g_signal_connect(G_OBJECT(opt), "activate", | |
913 G_CALLBACK(proxy_dropdown_set), ma); | |
914 gtk_widget_show(opt); | |
915 gtk_menu_shell_append(GTK_MENU_SHELL(menu), opt); | |
916 if(gpi && gpi->proxytype == PROXY_NONE) | |
917 gtk_menu_set_active(GTK_MENU(menu), 1); | |
918 | |
919 opt = gtk_menu_item_new_with_label("SOCKS 4"); | |
920 gtk_object_set_user_data(GTK_OBJECT(opt), (gpointer)PROXY_SOCKS4); | |
921 g_signal_connect(G_OBJECT(opt), "activate", | |
922 G_CALLBACK(proxy_dropdown_set), ma); | |
923 gtk_widget_show(opt); | |
924 gtk_menu_shell_append(GTK_MENU_SHELL(menu), opt); | |
925 if(gpi && gpi->proxytype == PROXY_SOCKS4) | |
926 gtk_menu_set_active(GTK_MENU(menu), 2); | |
927 | |
928 opt = gtk_menu_item_new_with_label("SOCKS 5"); | |
929 gtk_object_set_user_data(GTK_OBJECT(opt), (gpointer)PROXY_SOCKS5); | |
930 g_signal_connect(G_OBJECT(opt), "activate", | |
931 G_CALLBACK(proxy_dropdown_set), ma); | |
932 gtk_widget_show(opt); | |
933 gtk_menu_shell_append(GTK_MENU_SHELL(menu), opt); | |
934 if(gpi && gpi->proxytype == PROXY_SOCKS5) | |
935 gtk_menu_set_active(GTK_MENU(menu), 3); | |
936 | |
937 opt = gtk_menu_item_new_with_label("HTTP"); | |
938 gtk_object_set_user_data(GTK_OBJECT(opt), (gpointer)PROXY_HTTP); | |
939 g_signal_connect(G_OBJECT(opt), "activate", | |
940 G_CALLBACK(proxy_dropdown_set), ma); | |
941 gtk_widget_show(opt); | |
942 gtk_menu_shell_append(GTK_MENU_SHELL(menu), opt); | |
943 if(gpi && gpi->proxytype == PROXY_HTTP) | |
944 gtk_menu_set_active(GTK_MENU(menu), 4); | |
945 | |
946 gtk_option_menu_set_menu(GTK_OPTION_MENU(dropdown), menu); | |
947 gtk_box_pack_start(GTK_BOX(hbox), dropdown, FALSE, FALSE, 0); | |
948 gtk_widget_show(dropdown); | |
949 | |
950 ma->proxytype_menu = menu; | |
951 | |
952 | |
953 vbox2 = gtk_vbox_new(FALSE, 5); | |
954 gtk_container_add(GTK_CONTAINER(vbox), vbox2); | |
955 gtk_widget_show(vbox2); | |
956 ma->proxy_host_box = vbox2; | |
957 | |
958 hbox = gtk_hbox_new(FALSE, 5); | |
959 gtk_box_pack_start(GTK_BOX(vbox2), hbox, FALSE, FALSE, 0); | |
960 gtk_widget_show(hbox); | |
961 | |
962 label = gtk_label_new_with_mnemonic(_("_Host:")); | |
963 gtk_size_group_add_widget(ma->sg, label); | |
964 gtk_misc_set_alignment(GTK_MISC(label), 0, 0.5); | |
965 gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0); | |
966 gtk_widget_show(label); | |
967 entry = gtk_entry_new(); | |
968 gtk_label_set_mnemonic_widget(GTK_LABEL(label), entry); | |
969 gtk_box_pack_start(GTK_BOX(hbox), entry, FALSE, FALSE, 0); | |
970 gtk_entry_set_text(GTK_ENTRY(entry), gpi ? gpi->proxyhost : ""); | |
971 gtk_widget_show(entry); | |
972 ma->proxyhost_entry = entry; | |
973 | |
974 hbox = gtk_hbox_new(FALSE, 5); | |
975 gtk_box_pack_start(GTK_BOX(vbox2), hbox, FALSE, FALSE, 0); | |
976 gtk_widget_show(hbox); | |
977 | |
978 label = gtk_label_new_with_mnemonic(_("Port:")); | |
979 gtk_size_group_add_widget(ma->sg, label); | |
980 gtk_misc_set_alignment(GTK_MISC(label), 0, 0.5); | |
981 gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0); | |
982 gtk_widget_show(label); | |
983 entry = gtk_entry_new(); | |
984 gtk_label_set_mnemonic_widget(GTK_LABEL(label), entry); | |
985 gtk_box_pack_start(GTK_BOX(hbox), entry, FALSE, FALSE, 0); | |
986 if(gpi && gpi->proxyport) { | |
987 char buf[128]; | |
988 g_snprintf(buf, sizeof(buf), "%d", gpi->proxyport); | |
989 gtk_entry_set_text(GTK_ENTRY(entry), buf); | |
990 } | |
991 gtk_widget_show(entry); | |
992 ma->proxyport_entry = entry; | |
993 | |
994 hbox = gtk_hbox_new(FALSE, 5); | |
995 gtk_box_pack_start(GTK_BOX(vbox2), hbox, FALSE, FALSE, 0); | |
996 gtk_widget_show(hbox); | |
997 | |
998 label = gtk_label_new_with_mnemonic(_("_User:")); | |
999 gtk_size_group_add_widget(ma->sg, label); | |
1000 gtk_misc_set_alignment(GTK_MISC(label), 0, 0.5); | |
1001 gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0); | |
1002 gtk_widget_show(label); | |
1003 entry = gtk_entry_new(); | |
1004 gtk_label_set_mnemonic_widget(GTK_LABEL(label), entry); | |
1005 gtk_box_pack_start(GTK_BOX(hbox), entry, FALSE, FALSE, 0); | |
1006 gtk_entry_set_text(GTK_ENTRY(entry), gpi ? gpi->proxyuser : ""); | |
1007 gtk_widget_show(entry); | |
1008 ma->proxyuser_entry = entry; | |
1009 | |
1010 hbox = gtk_hbox_new(FALSE, 5); | |
1011 gtk_box_pack_start(GTK_BOX(vbox2), hbox, FALSE, FALSE, 0); | |
1012 gtk_widget_show(hbox); | |
1013 | |
1014 label = gtk_label_new_with_mnemonic(_("Pa_ssword:")); | |
1015 gtk_size_group_add_widget(ma->sg, label); | |
1016 gtk_misc_set_alignment(GTK_MISC(label), 0, 0.5); | |
1017 gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0); | |
1018 gtk_widget_show(label); | |
1019 entry = gtk_entry_new(); | |
1020 gtk_label_set_mnemonic_widget(GTK_LABEL(label), entry); | |
1021 gtk_box_pack_start(GTK_BOX(hbox), entry, FALSE, FALSE, 0); | |
1022 gtk_entry_set_text(GTK_ENTRY(entry), gpi ? gpi->proxypass : ""); | |
1023 gtk_widget_show(entry); | |
1024 ma->proxypass_entry = entry; | |
1025 | |
1026 gtk_widget_set_sensitive(vbox2, !(gpi == NULL || gpi->proxytype == PROXY_NONE)); | |
827 } | 1027 } |
828 | 1028 |
829 static void show_acct_mod(struct gaim_account *a) | 1029 static void show_acct_mod(struct gaim_account *a) |
830 { | 1030 { |
831 /* This is the fucking modify account dialog. I've fucking seperated it into | 1031 /* This is the fucking modify account dialog. I've fucking seperated it into |
894 ma->sg = gtk_size_group_new(GTK_SIZE_GROUP_HORIZONTAL); | 1094 ma->sg = gtk_size_group_new(GTK_SIZE_GROUP_HORIZONTAL); |
895 | 1095 |
896 generate_login_options(ma, ma->main); | 1096 generate_login_options(ma, ma->main); |
897 generate_user_options(ma, ma->main); | 1097 generate_user_options(ma, ma->main); |
898 generate_protocol_options(ma, ma->main); | 1098 generate_protocol_options(ma, ma->main); |
1099 generate_proxy_options(ma, ma->main); | |
899 | 1100 |
900 hbox = gtk_hbox_new(FALSE, 6); | 1101 hbox = gtk_hbox_new(FALSE, 6); |
901 gtk_container_set_border_width (GTK_CONTAINER (hbox), 6); | 1102 gtk_container_set_border_width (GTK_CONTAINER (hbox), 6); |
902 gtk_box_pack_end(GTK_BOX(vbox), hbox, FALSE, FALSE, 0); | 1103 gtk_box_pack_end(GTK_BOX(vbox), hbox, FALSE, FALSE, 0); |
903 | 1104 |