Mercurial > pidgin
changeset 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 | 812148fb2e2f |
children | 42d53c416bb9 |
files | src/core.h src/ft.c src/gaimrc.c src/html.c src/multi.c src/prefs.c src/protocols/gg/gg.c src/protocols/icq/gaim_icq.c src/protocols/irc/irc.c src/protocols/jabber/jabber.c src/protocols/msn/ft.c src/protocols/msn/msn.c src/protocols/msn/switchboard.c src/protocols/napster/napster.c src/protocols/oscar/oscar.c src/protocols/toc/toc.c src/protocols/yahoo/yahoo.c src/proxy.c src/proxy.h |
diffstat | 19 files changed, 393 insertions(+), 138 deletions(-) [+] |
line wrap: on
line diff
--- a/src/core.h Sun Mar 02 08:10:54 2003 +0000 +++ b/src/core.h Sun Mar 02 18:48:02 2003 +0000 @@ -71,6 +71,8 @@ /* buddy icon file */ char iconfile[256]; + struct gaim_proxy_info *gpi; + struct gaim_connection *gc; gboolean connecting;
--- a/src/ft.c Sun Mar 02 08:10:54 2003 +0000 +++ b/src/ft.c Sun Mar 02 18:48:02 2003 +0000 @@ -575,7 +575,7 @@ xfer->remote_port = port; /* Establish a file descriptor. */ - proxy_connect(xfer->remote_ip, xfer->remote_port, + proxy_connect(xfer->account, xfer->remote_ip, xfer->remote_port, connect_cb, xfer); return;
--- a/src/gaimrc.c Sun Mar 02 08:10:54 2003 +0000 +++ b/src/gaimrc.c Sun Mar 02 18:48:02 2003 +0000 @@ -546,6 +546,29 @@ g_snprintf(account->alias, sizeof(account->alias), "%s", p->value[0]); + if (!fgets(buf, sizeof(buf), f)) + return account; + + if (!strcmp(buf, "\t}")) + return account; + + p = parse_line(buf, &parse_buffer); + + if (strcmp(p->option, "proxy_opts")) + return account; + + if(atoi(p->value[0]) != PROXY_USE_GLOBAL) { + account->gpi = g_new0(struct gaim_proxy_info, 1); + account->gpi->proxytype = atoi(p->value[0]); + g_snprintf(account->gpi->proxyhost, sizeof(account->gpi->proxyhost), + "%s", p->value[1]); + account->gpi->proxyport = atoi(p->value[2]); + g_snprintf(account->gpi->proxyuser, sizeof(account->gpi->proxyuser), + "%s", p->value[3]); + g_snprintf(account->gpi->proxypass, sizeof(account->gpi->proxypass), + "%s", p->value[4]); + } + return account; } @@ -596,6 +619,16 @@ } #endif fprintf(f, "\t\talias { %s }\n", account->alias); + fprintf(f, "\t\tproxy_opts "); + if(account->gpi) { + fprintf(f, "{ %d } { %s } { %d } { %s } { %s }\n", + account->gpi->proxytype, account->gpi->proxyhost, + account->gpi->proxyport, account->gpi->proxyuser, + (c = escape_text2(account->gpi->proxypass))); + free(c); + } else { + fprintf(f, "{ %d }\n", PROXY_USE_GLOBAL); + } } static void gaimrc_read_users(FILE *f) @@ -988,7 +1021,7 @@ len = c - proxy; if (!strncmp(proxy, "http://", len + 3)) - proxytype = PROXY_HTTP; + global_proxy_info.proxytype = PROXY_HTTP; else return FALSE; @@ -1042,24 +1075,25 @@ /* NOTE: HTTP_PROXY takes precendence. */ if (host[0]) - strcpy(proxyhost, host); + strcpy(global_proxy_info.proxyhost, host); else - *proxyhost = '\0'; + *global_proxy_info.proxyhost = '\0'; if (user[0]) - strcpy(proxyuser, user); + strcpy(global_proxy_info.proxyuser, user); else - *proxyuser = '\0'; + *global_proxy_info.proxyuser = '\0'; if (pass[0]) - strcpy(proxypass, pass); + strcpy(global_proxy_info.proxypass, pass); else - *proxypass = '\0'; - - proxyport = port; + *global_proxy_info.proxypass = '\0'; + + global_proxy_info.proxyport = port; debug_printf("host '%s'\nuser '%s'\npassword '%s'\nport %d\n", - proxyhost, proxyuser, proxypass, proxyport); + global_proxy_info.proxyhost, global_proxy_info.proxyuser, + global_proxy_info.proxypass, global_proxy_info.proxyport); return TRUE; } @@ -1071,7 +1105,7 @@ struct parse *p; buf[0] = 0; - proxyhost[0] = 0; + global_proxy_info.proxyhost[0] = 0; debug_printf("gaimrc_read_proxy\n"); while (buf[0] != '}') { @@ -1084,73 +1118,80 @@ p = parse_line(buf, &parse_buffer); if (!strcmp(p->option, "host")) { - g_snprintf(proxyhost, sizeof(proxyhost), "%s", - p->value[0]); - debug_printf("set proxyhost %s\n", proxyhost); + g_snprintf(global_proxy_info.proxyhost, + sizeof(global_proxy_info.proxyhost), "%s", p->value[0]); + debug_printf("set proxyhost %s\n", global_proxy_info.proxyhost); } else if (!strcmp(p->option, "port")) { - proxyport = atoi(p->value[0]); + global_proxy_info.proxyport = atoi(p->value[0]); } else if (!strcmp(p->option, "type")) { - proxytype = atoi(p->value[0]); + global_proxy_info.proxytype = atoi(p->value[0]); } else if (!strcmp(p->option, "user")) { - g_snprintf(proxyuser, sizeof(proxyuser), "%s", - p->value[0]); + g_snprintf(global_proxy_info.proxyuser, + sizeof(global_proxy_info.proxyuser), "%s", p->value[0]); } else if (!strcmp(p->option, "pass")) { - g_snprintf(proxypass, sizeof(proxypass), "%s", - p->value[0]); + g_snprintf(global_proxy_info.proxypass, + sizeof(global_proxy_info.proxypass), "%s", p->value[0]); } } - if (proxyhost[0]) + if (global_proxy_info.proxyhost[0]) proxy_info_is_from_gaimrc = 1; - else if (!proxyhost[0]) { - + else { gboolean getVars = TRUE; proxy_info_is_from_gaimrc = 0; - + if (g_getenv("HTTP_PROXY")) - g_snprintf(proxyhost, sizeof(proxyhost), "%s", - g_getenv("HTTP_PROXY")); + g_snprintf(global_proxy_info.proxyhost, + sizeof(global_proxy_info.proxyhost), "%s", + g_getenv("HTTP_PROXY")); else if (g_getenv("http_proxy")) - g_snprintf(proxyhost, sizeof(proxyhost), "%s", - g_getenv("http_proxy")); + g_snprintf(global_proxy_info.proxyhost, + sizeof(global_proxy_info.proxyhost), "%s", + g_getenv("http_proxy")); else if (g_getenv("HTTPPROXY")) - g_snprintf(proxyhost, sizeof(proxyhost), "%s", - g_getenv("HTTPPROXY")); + g_snprintf(global_proxy_info.proxyhost, + sizeof(global_proxy_info.proxyhost), "%s", + g_getenv("HTTPPROXY")); - if (*proxyhost != '\0') - getVars = !gaimrc_parse_proxy_uri(proxyhost); + if (*global_proxy_info.proxyhost != '\0') + getVars = !gaimrc_parse_proxy_uri(global_proxy_info.proxyhost); if (getVars) { if (g_getenv("HTTP_PROXY_PORT")) - proxyport = atoi(g_getenv("HTTP_PROXY_PORT")); + global_proxy_info.proxyport = atoi(g_getenv("HTTP_PROXY_PORT")); else if (g_getenv("http_proxy_port")) - proxyport = atoi(g_getenv("http_proxy_port")); + global_proxy_info.proxyport = atoi(g_getenv("http_proxy_port")); else if (g_getenv("HTTPPROXYPORT")) - proxyport = atoi(g_getenv("HTTPPROXYPORT")); + global_proxy_info.proxyport = atoi(g_getenv("HTTPPROXYPORT")); if (g_getenv("HTTP_PROXY_USER")) - g_snprintf(proxyuser, sizeof(proxyuser), "%s", - g_getenv("HTTP_PROXY_USER")); + g_snprintf(global_proxy_info.proxyuser, + sizeof(global_proxy_info.proxyuser), "%s", + g_getenv("HTTP_PROXY_USER")); else if (g_getenv("http_proxy_user")) - g_snprintf(proxyuser, sizeof(proxyuser), "%s", - g_getenv("http_proxy_user")); + g_snprintf(global_proxy_info.proxyuser, + sizeof(global_proxy_info.proxyuser), "%s", + g_getenv("http_proxy_user")); else if (g_getenv("HTTPPROXYUSER")) - g_snprintf(proxyuser, sizeof(proxyuser), "%s", - g_getenv("HTTPPROXYUSER")); + g_snprintf(global_proxy_info.proxyuser, + sizeof(global_proxy_info.proxyuser), "%s", + g_getenv("HTTPPROXYUSER")); if (g_getenv("HTTP_PROXY_PASS")) - g_snprintf(proxypass, sizeof(proxypass), "%s", - g_getenv("HTTP_PROXY_PASS")); + g_snprintf(global_proxy_info.proxypass, + sizeof(global_proxy_info.proxypass), "%s", + g_getenv("HTTP_PROXY_PASS")); else if (g_getenv("http_proxy_pass")) - g_snprintf(proxypass, sizeof(proxypass), "%s", - g_getenv("http_proxy_pass")); + g_snprintf(global_proxy_info.proxypass, + sizeof(global_proxy_info.proxypass), "%s", + g_getenv("http_proxy_pass")); else if (g_getenv("HTTPPROXYPASS")) - g_snprintf(proxypass, sizeof(proxypass), "%s", - g_getenv("HTTPPROXYPASS")); + g_snprintf(global_proxy_info.proxypass, + sizeof(global_proxy_info.proxypass), "%s", + g_getenv("HTTPPROXYPASS")); - - if (proxyhost[0]) - proxytype = PROXY_HTTP; + if (global_proxy_info.proxyhost[0]) + global_proxy_info.proxytype = PROXY_HTTP; } } } @@ -1161,11 +1202,12 @@ fprintf(f, "proxy {\n"); if (proxy_info_is_from_gaimrc) { - fprintf(f, "\thost { %s }\n", proxyhost); - fprintf(f, "\tport { %d }\n", proxyport); - fprintf(f, "\ttype { %d }\n", proxytype); - fprintf(f, "\tuser { %s }\n", proxyuser); - fprintf(f, "\tpass { %s }\n", (str = escape_text2(proxypass))); + fprintf(f, "\thost { %s }\n", global_proxy_info.proxyhost); + fprintf(f, "\tport { %d }\n", global_proxy_info.proxyport); + fprintf(f, "\ttype { %d }\n", global_proxy_info.proxytype); + fprintf(f, "\tuser { %s }\n", global_proxy_info.proxyuser); + fprintf(f, "\tpass { %s }\n", + (str = escape_text2(global_proxy_info.proxypass))); free(str); } else { fprintf(f, "\thost { %s }\n", "");
--- a/src/html.c Sun Mar 02 08:10:54 2003 +0000 +++ b/src/html.c Sun Mar 02 18:48:02 2003 +0000 @@ -309,7 +309,7 @@ gunk->website = parse_url(url); gunk->full = full; - if ((sock = proxy_connect(gunk->website->address, gunk->website->port, + if ((sock = proxy_connect(NULL, gunk->website->address, gunk->website->port, grab_url_callback, gunk)) < 0) { g_free(gunk->website); g_free(gunk->url);
--- a/src/multi.c Sun Mar 02 08:10:54 2003 +0000 +++ b/src/multi.c Sun Mar 02 18:48:02 2003 +0000 @@ -19,6 +19,7 @@ * */ +#include <stdlib.h> #include <string.h> #include <ctype.h> #include <gtk/gtk.h> @@ -84,6 +85,15 @@ /* stuff for register with server */ GtkWidget *register_user; + + /* stuff for proxy options */ + GtkWidget *proxy_frame; + GtkWidget *proxy_host_box; + GtkWidget *proxytype_menu; + GtkWidget *proxyhost_entry; + GtkWidget *proxyport_entry; + GtkWidget *proxyuser_entry; + GtkWidget *proxypass_entry; }; @@ -351,6 +361,7 @@ struct gaim_account *a; struct prpl *p; GtkTreeIter iter; + int proxytype; if (!ma->account) { txt = gtk_entry_get_text(GTK_ENTRY(ma->name)); @@ -403,6 +414,23 @@ gtk_widget_destroy(ma->icondlg); ma->icondlg = NULL; + if(ma->account->gpi) + g_free(ma->account->gpi); + ma->account->gpi = NULL; + + proxytype = (int)gtk_object_get_user_data(GTK_OBJECT(gtk_menu_get_active(GTK_MENU(ma->proxytype_menu)))); + + if(proxytype != PROXY_USE_GLOBAL) { + struct gaim_proxy_info *gpi = g_new0(struct gaim_proxy_info, 1); + gpi->proxytype = proxytype; + g_snprintf(gpi->proxyhost, sizeof(gpi->proxyhost), "%s", gtk_entry_get_text(GTK_ENTRY(ma->proxyhost_entry))); + gpi->proxyport = atoi(gtk_entry_get_text(GTK_ENTRY(ma->proxyport_entry))); + g_snprintf(gpi->proxyuser, sizeof(gpi->proxyuser), "%s", gtk_entry_get_text(GTK_ENTRY(ma->proxyuser_entry))); + g_snprintf(gpi->proxypass, sizeof(gpi->proxypass), "%s", gtk_entry_get_text(GTK_ENTRY(ma->proxypass_entry))); + + ma->account->gpi = gpi; + } + /* * See if user registration is supported/required */ @@ -826,6 +854,178 @@ } +static void proxy_dropdown_set(GtkObject *w, struct mod_account *ma) { + int opt = (int)gtk_object_get_user_data(w); + gtk_widget_set_sensitive(ma->proxy_host_box, (opt != PROXY_NONE && opt != PROXY_USE_GLOBAL)); +} + +static void generate_proxy_options(struct mod_account *ma, GtkWidget *box) { + GtkWidget *frame; + GtkWidget *hbox; + GtkWidget *vbox; + GtkWidget *label; + GtkWidget *menu; + GtkWidget *dropdown; + GtkWidget *opt; + GtkWidget *entry; + GtkWidget *vbox2; + + struct gaim_proxy_info *gpi = NULL; + + if(ma->account) + gpi = ma->account->gpi; + + frame = make_frame(box, _("Proxy Options")); + ma->proxy_frame = gtk_widget_get_parent(gtk_widget_get_parent(frame)); + gtk_widget_show_all(ma->proxy_frame); + + vbox = gtk_vbox_new(FALSE, 5); + gtk_container_set_border_width(GTK_CONTAINER(vbox), 5); + gtk_container_add(GTK_CONTAINER(frame), vbox); + gtk_widget_show(vbox); + + /* make the dropdown w/o the benefit of the easy helper funcs in prefs.c */ + hbox = gtk_hbox_new(FALSE, 5); + gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0); + gtk_widget_show(hbox); + + label = gtk_label_new_with_mnemonic(_("Proxy _Type")); + gtk_size_group_add_widget(ma->sg, label); + gtk_misc_set_alignment(GTK_MISC(label), 0, 0.5); + gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0); + gtk_widget_show(label); + + dropdown = gtk_option_menu_new(); + menu = gtk_menu_new(); + + opt = gtk_menu_item_new_with_label("Use Global Proxy Settings"); + gtk_object_set_user_data(GTK_OBJECT(opt), (gpointer)PROXY_USE_GLOBAL); + g_signal_connect(G_OBJECT(opt), "activate", + G_CALLBACK(proxy_dropdown_set), ma); + gtk_widget_show(opt); + gtk_menu_shell_append(GTK_MENU_SHELL(menu), opt); + if(!gpi) + gtk_menu_set_active(GTK_MENU(menu), 0); + + opt = gtk_menu_item_new_with_label("No Proxy"); + gtk_object_set_user_data(GTK_OBJECT(opt), (gpointer)PROXY_NONE); + g_signal_connect(G_OBJECT(opt), "activate", + G_CALLBACK(proxy_dropdown_set), ma); + gtk_widget_show(opt); + gtk_menu_shell_append(GTK_MENU_SHELL(menu), opt); + if(gpi && gpi->proxytype == PROXY_NONE) + gtk_menu_set_active(GTK_MENU(menu), 1); + + opt = gtk_menu_item_new_with_label("SOCKS 4"); + gtk_object_set_user_data(GTK_OBJECT(opt), (gpointer)PROXY_SOCKS4); + g_signal_connect(G_OBJECT(opt), "activate", + G_CALLBACK(proxy_dropdown_set), ma); + gtk_widget_show(opt); + gtk_menu_shell_append(GTK_MENU_SHELL(menu), opt); + if(gpi && gpi->proxytype == PROXY_SOCKS4) + gtk_menu_set_active(GTK_MENU(menu), 2); + + opt = gtk_menu_item_new_with_label("SOCKS 5"); + gtk_object_set_user_data(GTK_OBJECT(opt), (gpointer)PROXY_SOCKS5); + g_signal_connect(G_OBJECT(opt), "activate", + G_CALLBACK(proxy_dropdown_set), ma); + gtk_widget_show(opt); + gtk_menu_shell_append(GTK_MENU_SHELL(menu), opt); + if(gpi && gpi->proxytype == PROXY_SOCKS5) + gtk_menu_set_active(GTK_MENU(menu), 3); + + opt = gtk_menu_item_new_with_label("HTTP"); + gtk_object_set_user_data(GTK_OBJECT(opt), (gpointer)PROXY_HTTP); + g_signal_connect(G_OBJECT(opt), "activate", + G_CALLBACK(proxy_dropdown_set), ma); + gtk_widget_show(opt); + gtk_menu_shell_append(GTK_MENU_SHELL(menu), opt); + if(gpi && gpi->proxytype == PROXY_HTTP) + gtk_menu_set_active(GTK_MENU(menu), 4); + + gtk_option_menu_set_menu(GTK_OPTION_MENU(dropdown), menu); + gtk_box_pack_start(GTK_BOX(hbox), dropdown, FALSE, FALSE, 0); + gtk_widget_show(dropdown); + + ma->proxytype_menu = menu; + + + vbox2 = gtk_vbox_new(FALSE, 5); + gtk_container_add(GTK_CONTAINER(vbox), vbox2); + gtk_widget_show(vbox2); + ma->proxy_host_box = vbox2; + + hbox = gtk_hbox_new(FALSE, 5); + gtk_box_pack_start(GTK_BOX(vbox2), hbox, FALSE, FALSE, 0); + gtk_widget_show(hbox); + + label = gtk_label_new_with_mnemonic(_("_Host:")); + gtk_size_group_add_widget(ma->sg, label); + gtk_misc_set_alignment(GTK_MISC(label), 0, 0.5); + gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0); + gtk_widget_show(label); + entry = gtk_entry_new(); + gtk_label_set_mnemonic_widget(GTK_LABEL(label), entry); + gtk_box_pack_start(GTK_BOX(hbox), entry, FALSE, FALSE, 0); + gtk_entry_set_text(GTK_ENTRY(entry), gpi ? gpi->proxyhost : ""); + gtk_widget_show(entry); + ma->proxyhost_entry = entry; + + hbox = gtk_hbox_new(FALSE, 5); + gtk_box_pack_start(GTK_BOX(vbox2), hbox, FALSE, FALSE, 0); + gtk_widget_show(hbox); + + label = gtk_label_new_with_mnemonic(_("Port:")); + gtk_size_group_add_widget(ma->sg, label); + gtk_misc_set_alignment(GTK_MISC(label), 0, 0.5); + gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0); + gtk_widget_show(label); + entry = gtk_entry_new(); + gtk_label_set_mnemonic_widget(GTK_LABEL(label), entry); + gtk_box_pack_start(GTK_BOX(hbox), entry, FALSE, FALSE, 0); + if(gpi && gpi->proxyport) { + char buf[128]; + g_snprintf(buf, sizeof(buf), "%d", gpi->proxyport); + gtk_entry_set_text(GTK_ENTRY(entry), buf); + } + gtk_widget_show(entry); + ma->proxyport_entry = entry; + + hbox = gtk_hbox_new(FALSE, 5); + gtk_box_pack_start(GTK_BOX(vbox2), hbox, FALSE, FALSE, 0); + gtk_widget_show(hbox); + + label = gtk_label_new_with_mnemonic(_("_User:")); + gtk_size_group_add_widget(ma->sg, label); + gtk_misc_set_alignment(GTK_MISC(label), 0, 0.5); + gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0); + gtk_widget_show(label); + entry = gtk_entry_new(); + gtk_label_set_mnemonic_widget(GTK_LABEL(label), entry); + gtk_box_pack_start(GTK_BOX(hbox), entry, FALSE, FALSE, 0); + gtk_entry_set_text(GTK_ENTRY(entry), gpi ? gpi->proxyuser : ""); + gtk_widget_show(entry); + ma->proxyuser_entry = entry; + + hbox = gtk_hbox_new(FALSE, 5); + gtk_box_pack_start(GTK_BOX(vbox2), hbox, FALSE, FALSE, 0); + gtk_widget_show(hbox); + + label = gtk_label_new_with_mnemonic(_("Pa_ssword:")); + gtk_size_group_add_widget(ma->sg, label); + gtk_misc_set_alignment(GTK_MISC(label), 0, 0.5); + gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0); + gtk_widget_show(label); + entry = gtk_entry_new(); + gtk_label_set_mnemonic_widget(GTK_LABEL(label), entry); + gtk_box_pack_start(GTK_BOX(hbox), entry, FALSE, FALSE, 0); + gtk_entry_set_text(GTK_ENTRY(entry), gpi ? gpi->proxypass : ""); + gtk_widget_show(entry); + ma->proxypass_entry = entry; + + gtk_widget_set_sensitive(vbox2, !(gpi == NULL || gpi->proxytype == PROXY_NONE)); +} + static void show_acct_mod(struct gaim_account *a) { /* This is the fucking modify account dialog. I've fucking seperated it into @@ -896,6 +1096,7 @@ generate_login_options(ma, ma->main); generate_user_options(ma, ma->main); generate_protocol_options(ma, ma->main); + generate_proxy_options(ma, ma->main); hbox = gtk_hbox_new(FALSE, 6); gtk_container_set_border_width (GTK_CONTAINER (hbox), 6);
--- a/src/prefs.c Sun Mar 02 08:10:54 2003 +0000 +++ b/src/prefs.c Sun Mar 02 18:48:02 2003 +0000 @@ -131,13 +131,13 @@ static void proxy_print_option(GtkEntry *entry, int entrynum) { if (entrynum == PROXYHOST) - g_snprintf(proxyhost, sizeof(proxyhost), "%s", gtk_entry_get_text(entry)); + g_snprintf(global_proxy_info.proxyhost, sizeof(global_proxy_info.proxyhost), "%s", gtk_entry_get_text(entry)); else if (entrynum == PROXYPORT) - proxyport = atoi(gtk_entry_get_text(entry)); + global_proxy_info.proxyport = atoi(gtk_entry_get_text(entry)); else if (entrynum == PROXYUSER) - g_snprintf(proxyuser, sizeof(proxyuser), "%s", gtk_entry_get_text(entry)); + g_snprintf(global_proxy_info.proxyuser, sizeof(global_proxy_info.proxyuser), "%s", gtk_entry_get_text(entry)); else if (entrynum == PROXYPASS) - g_snprintf(proxypass, sizeof(proxypass), "%s", gtk_entry_get_text(entry)); + g_snprintf(global_proxy_info.proxypass, sizeof(global_proxy_info.proxypass), "%s", gtk_entry_get_text(entry)); proxy_info_is_from_gaimrc = 1; /* If the user specifies it, we want to save it */ } @@ -165,7 +165,6 @@ /* OK, Apply and Cancel */ - static void pref_nb_select(GtkTreeSelection *sel, GtkNotebook *nb) { GtkTreeIter iter; char text[128]; @@ -736,7 +735,7 @@ gtk_container_set_border_width (GTK_CONTAINER (ret), 12); vbox = make_frame (ret, _("Proxy Type")); - gaim_dropdown(vbox, _("Proxy _type:"), (int*)&proxytype, -1, + gaim_dropdown(vbox, _("Proxy _type:"), (int*)&global_proxy_info.proxytype, -1, _("No proxy"), PROXY_NONE, "SOCKS 4", PROXY_SOCKS4, "SOCKS 5", PROXY_SOCKS5, @@ -750,7 +749,7 @@ vbox = make_frame(ret, _("Proxy Server")); prefs_proxy_frame = vbox; - if (proxytype == PROXY_NONE) + if (global_proxy_info.proxytype == PROXY_NONE) gtk_widget_set_sensitive(GTK_WIDGET(vbox), FALSE); table = gtk_table_new(2, 4, FALSE); @@ -769,7 +768,7 @@ gtk_table_attach(GTK_TABLE(table), entry, 1, 2, 0, 1, GTK_FILL, 0, 0, 0); g_signal_connect(GTK_OBJECT(entry), "changed", G_CALLBACK(proxy_print_option), (void *)PROXYHOST); - gtk_entry_set_text(GTK_ENTRY(entry), proxyhost); + gtk_entry_set_text(GTK_ENTRY(entry), global_proxy_info.proxyhost); hbox = gtk_hbox_new(TRUE, 5); gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0); @@ -784,9 +783,9 @@ g_signal_connect(GTK_OBJECT(entry), "changed", G_CALLBACK(proxy_print_option), (void *)PROXYPORT); - if (proxyport) { + if (global_proxy_info.proxyport) { char buf[128]; - g_snprintf(buf, sizeof(buf), "%d", proxyport); + g_snprintf(buf, sizeof(buf), "%d", global_proxy_info.proxyport); gtk_entry_set_text(GTK_ENTRY(entry), buf); } @@ -799,7 +798,7 @@ gtk_table_attach(GTK_TABLE(table), entry, 1, 2, 2, 3, GTK_FILL, 0, 0, 0); g_signal_connect(GTK_OBJECT(entry), "changed", G_CALLBACK(proxy_print_option), (void *)PROXYUSER); - gtk_entry_set_text(GTK_ENTRY(entry), proxyuser); + gtk_entry_set_text(GTK_ENTRY(entry), global_proxy_info.proxyuser); hbox = gtk_hbox_new(TRUE, 5); gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0); @@ -814,7 +813,7 @@ gtk_entry_set_visibility(GTK_ENTRY(entry), FALSE); g_signal_connect(GTK_OBJECT(entry), "changed", G_CALLBACK(proxy_print_option), (void *)PROXYPASS); - gtk_entry_set_text(GTK_ENTRY(entry), proxypass); + gtk_entry_set_text(GTK_ENTRY(entry), global_proxy_info.proxypass); gtk_widget_show_all(ret); return ret; @@ -2290,7 +2289,7 @@ *option = opt; } - if (option == (int*)&proxytype) { + if (option == (int*)&global_proxy_info.proxytype) { if (opt == PROXY_NONE) gtk_widget_set_sensitive(prefs_proxy_frame, FALSE); else
--- a/src/protocols/gg/gg.c Sun Mar 02 08:10:54 2003 +0000 +++ b/src/protocols/gg/gg.c Sun Mar 02 18:48:02 2003 +0000 @@ -1,6 +1,6 @@ /* * gaim - Gadu-Gadu Protocol Plugin - * $Id: gg.c 4896 2003-02-24 00:29:54Z faceprint $ + * $Id: gg.c 4941 2003-03-02 18:48:02Z faceprint $ * * Copyright (C) 2001 Arkadiusz Mi¶kiewicz <misiek@pld.ORG.PL> * @@ -470,13 +470,13 @@ { struct in_addr ip; char buf[256]; - + /* Remove watch on initial socket - now that we have ip and port of login server */ gaim_input_remove(gc->inpa); ip.s_addr = gd->sess->server_ip; - - if (proxy_connect(inet_ntoa(ip), gd->sess->port, login_callback, gc) < 0) { + + if (proxy_connect(gc->account, inet_ntoa(ip), gd->sess->port, login_callback, gc) < 0) { g_snprintf(buf, sizeof(buf), _("Connect to %s failed"), inet_ntoa(ip)); hide_login_progress(gc, buf); signoff(gc); @@ -572,7 +572,7 @@ gd->sess->state = GG_STATE_CONNECTING; gd->sess->check = GG_CHECK_WRITE; gd->sess->async = 1; - if (proxy_connect(GG_APPMSG_HOST, GG_APPMSG_PORT, login_callback, gc) < 0) { + if (proxy_connect(account, GG_APPMSG_HOST, GG_APPMSG_PORT, login_callback, gc) < 0) { g_snprintf(buf, sizeof(buf), _("Connect to %s failed"), GG_APPMSG_HOST); hide_login_progress(gc, buf); signoff(gc); @@ -988,7 +988,7 @@ g_free(u); g_free(p); - if (proxy_connect(GG_PUBDIR_HOST, GG_PUBDIR_PORT, http_req_callback, hi) < 0) { + if (proxy_connect(gc->account, GG_PUBDIR_HOST, GG_PUBDIR_PORT, http_req_callback, hi) < 0) { do_error_dialog(_("Unable to import Gadu-Gadu buddy list"), _("Gaim was unable to connect to the Gadu-Gadu buddy list " "server. Please try again later."), GAIM_ERROR); @@ -1055,7 +1055,7 @@ gr = g_slist_next(gr); } - if (proxy_connect(GG_PUBDIR_HOST, GG_PUBDIR_PORT, http_req_callback, he) < 0) { + if (proxy_connect(gc->account, GG_PUBDIR_HOST, GG_PUBDIR_PORT, http_req_callback, he) < 0) { do_error_dialog(_("Couldn't export buddy list"), _("Gaim was unable to connect to the buddy list server. " "Please try again later."), GAIM_ERROR); @@ -1077,7 +1077,7 @@ he->host = GG_PUBDIR_HOST; he->request = g_strdup_printf("FmNum=%s&Pass=%s&Delete=1", u, p); - if (proxy_connect(GG_PUBDIR_HOST, GG_PUBDIR_PORT, http_req_callback, he) < 0) { + if (proxy_connect(gc->account, GG_PUBDIR_HOST, GG_PUBDIR_PORT, http_req_callback, he) < 0) { do_error_dialog(_("Unable to delete Gadu-Gadu buddy list"), _("Gaim was unable to connect to the buddy list server. " "Please try again later."), GAIM_ERROR); @@ -1125,7 +1125,7 @@ g_free(enew_city); } - if (proxy_connect(GG_PUBDIR_HOST, GG_PUBDIR_PORT, http_req_callback, srch) < 0) { + if (proxy_connect(gc->account, GG_PUBDIR_HOST, GG_PUBDIR_PORT, http_req_callback, srch) < 0) { do_error_dialog(_("Unable to access directory"), _("Gaim was unable to search the Directory because it " "was unable to connect to the directory server. Please try " @@ -1158,7 +1158,7 @@ g_free(enew); g_free(eold); - if (proxy_connect(GG_REGISTER_HOST, GG_REGISTER_PORT, http_req_callback, hpass) < 0) { + if (proxy_connect(gc->account, GG_REGISTER_HOST, GG_REGISTER_PORT, http_req_callback, hpass) < 0) { do_error_dialog(_("Unable to change Gadu-Gadu password"), _("Gaim was unable to change your password due to an error connecting " "to the Gadu-Gadu server. Please try again later."), GAIM_ERROR); @@ -1233,7 +1233,7 @@ } else srch->request = g_strdup_printf("Mode=3&UserId=%s", who); - if (proxy_connect(GG_PUBDIR_HOST, GG_PUBDIR_PORT, http_req_callback, srch) < 0) { + if (proxy_connect(gc->account, GG_PUBDIR_HOST, GG_PUBDIR_PORT, http_req_callback, srch) < 0) { do_error_dialog(_("Unable to access user profile."), _("Gaim was unable to access this user's profile due to an error " "connecting to the directory server. Please try again later."), GAIM_ERROR);
--- a/src/protocols/icq/gaim_icq.c Sun Mar 02 08:10:54 2003 +0000 +++ b/src/protocols/icq/gaim_icq.c Sun Mar 02 18:48:02 2003 +0000 @@ -307,9 +307,13 @@ static void icq_login(struct gaim_account *account) { struct gaim_connection *gc = new_gaim_conn(account); struct icq_data *id = gc->proto_data = g_new0(struct icq_data, 1); + struct gaim_proxy_info *gpi = account->gpi; icq_Link *link; char ps[9]; + if(!gpi) + gpi = &global_proxy_info; + gc->checkbox = _("Send message through server"); icq_LogLevel = ICQ_LOG_MESSAGE; @@ -338,8 +342,8 @@ link->icq_RequestNotify = icq_req_not; link->icq_UserData = gc; - if (proxytype == PROXY_SOCKS5) - icq_SetProxy(link, proxyhost, proxyport, proxyuser[0], proxyuser, proxypass); + if (gpi->proxytype == PROXY_SOCKS5) + icq_SetProxy(link, gpi->proxyhost, gpi->proxyport, gpi->proxyuser[0], gpi->proxyuser, gpi->proxypass); icq_ContactClear(id->link);
--- a/src/protocols/irc/irc.c Sun Mar 02 08:10:54 2003 +0000 +++ b/src/protocols/irc/irc.c Sun Mar 02 18:48:02 2003 +0000 @@ -1221,7 +1221,7 @@ static void dcc_chat_init(struct dcc_chat *data) { if (g_slist_find(connections, data->gc)) { - proxy_connect(data->ip_address, data->port, dcc_chat_callback, data); + proxy_connect(data->gc->account, data->ip_address, data->port, dcc_chat_callback, data); } else { g_free(data); } @@ -1816,7 +1816,7 @@ idata->str = g_string_new(""); idata->fd = -1; - rc = proxy_connect(account->proto_opt[USEROPT_SERV], + rc = proxy_connect(account, account->proto_opt[USEROPT_SERV], account->proto_opt[USEROPT_PORT][0] ? atoi(account->proto_opt[USEROPT_PORT]) : 6667, irc_login_callback, gc); @@ -2603,7 +2603,7 @@ struct irc_file_transfer *ift = find_ift_by_xfer(gc, xfer); ift->xfer = xfer; - proxy_connect(ift->ip, ift->port, dcc_recv_callback, ift); + proxy_connect(gc->account, ift->ip, ift->port, dcc_recv_callback, ift); } #endif
--- a/src/protocols/jabber/jabber.c Sun Mar 02 08:10:54 2003 +0000 +++ b/src/protocols/jabber/jabber.c Sun Mar 02 18:48:02 2003 +0000 @@ -818,7 +818,7 @@ XML_SetElementHandler(gjc->parser, startElement, endElement); XML_SetCharacterDataHandler(gjc->parser, charData); - rc = proxy_connect(server, port, gjab_connected, GJ_GC(gjc)); + rc = proxy_connect(account, server, port, gjab_connected, GJ_GC(gjc)); if (!account->gc || (rc != 0)) { STATE_EVT(JCONN_STATE_OFF) return;
--- a/src/protocols/msn/ft.c Sun Mar 02 08:10:54 2003 +0000 +++ b/src/protocols/msn/ft.c Sun Mar 02 18:48:02 2003 +0000 @@ -449,7 +449,7 @@ strncpy(ip_s, ip, sizeof(ip_s)); - if (proxy_connect(ip_s, atoi(port_s), + if (proxy_connect(xfer->account, ip_s, atoi(port_s), msn_msnftp_connect, xfer) != 0) { gaim_xfer_cancel(xfer);
--- a/src/protocols/msn/msn.c Sun Mar 02 08:10:54 2003 +0000 +++ b/src/protocols/msn/msn.c Sun Mar 02 18:48:02 2003 +0000 @@ -646,7 +646,7 @@ port = 1863; ms = g_new0(struct msn_switchboard, 1); - if (proxy_connect(ssaddr, port, msn_rng_connect, ms) != 0) { + if (proxy_connect(gc->account, ssaddr, port, msn_rng_connect, ms) != 0) { g_free(ms); return 1; } @@ -784,7 +784,7 @@ close(md->fd); gaim_input_remove(md->inpa); md->inpa = 0; - if (proxy_connect(host, port, msn_login_xfr_connect, gc) != 0) { + if (proxy_connect(gc->account, host, port, msn_login_xfr_connect, gc) != 0) { hide_login_progress(gc, _("Error transferring")); signoff(gc); return 0; @@ -1080,7 +1080,7 @@ md->inpa = 0; md->fd = 0; md->sl = time(NULL); - if (proxy_connect(host, port, msn_login_xfr_connect, gc) != 0) { + if (proxy_connect(gc->account, host, port, msn_login_xfr_connect, gc) != 0) { hide_login_progress(gc, _("Unable to transfer")); signoff(gc); } @@ -1194,7 +1194,7 @@ g_snprintf(gc->username, sizeof(gc->username), "%s", msn_normalize(gc->username)); - if (proxy_connect(account->proto_opt[USEROPT_MSNSERVER][0] ? + if (proxy_connect(account, account->proto_opt[USEROPT_MSNSERVER][0] ? account->proto_opt[USEROPT_MSNSERVER] : MSN_SERVER, account->proto_opt[USEROPT_MSNPORT][0] ? atoi(account->proto_opt[USEROPT_MSNPORT]) : MSN_PORT,
--- a/src/protocols/msn/switchboard.c Sun Mar 02 08:10:54 2003 +0000 +++ b/src/protocols/msn/switchboard.c Sun Mar 02 18:48:02 2003 +0000 @@ -525,7 +525,8 @@ if (ms == NULL) return NULL; - if (proxy_connect((char *)host, port, msn_ss_xfr_connect, ms) != 0) { + if (proxy_connect(gc->account, (char *)host, port, msn_ss_xfr_connect, + ms) != 0) { msn_kill_switch(ms); return NULL;
--- a/src/protocols/napster/napster.c Sun Mar 02 08:10:54 2003 +0000 +++ b/src/protocols/napster/napster.c Sun Mar 02 18:48:02 2003 +0000 @@ -442,7 +442,7 @@ struct gaim_connection *gc = new_gaim_conn(account); gc->proto_data = g_new0(struct nap_data, 1); - if (proxy_connect(account->proto_opt[USEROPT_NAPSERVER][0] ? + if (proxy_connect(account, account->proto_opt[USEROPT_NAPSERVER][0] ? account->proto_opt[USEROPT_NAPSERVER] : NAP_SERVER, account->proto_opt[USEROPT_NAPPORT][0] ? atoi(account->proto_opt[USEROPT_NAPPORT]) : NAP_PORT,
--- a/src/protocols/oscar/oscar.c Sun Mar 02 08:10:54 2003 +0000 +++ b/src/protocols/oscar/oscar.c Sun Mar 02 18:48:02 2003 +0000 @@ -383,7 +383,7 @@ if (xfer_data->conn) { xfer_data->conn->subtype = AIM_CONN_SUBTYPE_OFT_SENDFILE; aim_conn_addhandler(od->sess, xfer_data->conn, AIM_CB_FAM_OFT, AIM_CB_OFT_PROMPT, oscar_sendfile_prompt, 0); - xfer_data->conn->fd = xfer->fd = proxy_connect(xfer->remote_ip, xfer->remote_port, oscar_sendfile_connected, xfer); + xfer_data->conn->fd = xfer->fd = proxy_connect(gc->account, xfer->remote_ip, xfer->remote_port, oscar_sendfile_connected, xfer); if (xfer->fd == -1) { do_error_dialog(_("File Transfer Aborted"), _("Unable to establish file descriptor."), GAIM_ERROR); /* gaim_xfer_cancel? */ @@ -851,7 +851,7 @@ aim_conn_addhandler(sess, conn, 0x0017, 0x0003, gaim_parse_auth_resp, 0); conn->status |= AIM_CONN_STATUS_INPROGRESS; - if (proxy_connect(account->proto_opt[USEROPT_AUTH][0] ? + if (proxy_connect(account, account->proto_opt[USEROPT_AUTH][0] ? account->proto_opt[USEROPT_AUTH] : FAIM_LOGIN_SERVER, account->proto_opt[USEROPT_AUTHPORT][0] ? atoi(account->proto_opt[USEROPT_AUTHPORT]) : FAIM_LOGIN_PORT, @@ -1122,7 +1122,7 @@ } host = g_strndup(info->bosip, i); bosconn->status |= AIM_CONN_STATUS_INPROGRESS; - rc = proxy_connect(host, port, oscar_bos_connect, gc); + rc = proxy_connect(gc->account, host, port, oscar_bos_connect, gc); g_free(host); if (rc < 0) { hide_login_progress(gc, _("Could Not Connect")); @@ -1270,7 +1270,7 @@ pos->len = len; pos->modname = modname ? g_strdup(modname) : NULL; - if (proxy_connect("gaim.sourceforge.net", 80, straight_to_hell, pos) != 0) { + if (proxy_connect(pos->gc->account, "gaim.sourceforge.net", 80, straight_to_hell, pos) != 0) { char buf[256]; if (pos->modname) g_free(pos->modname); @@ -1509,7 +1509,7 @@ aim_conn_addhandler(sess, tstconn, 0x0007, 0x0007, gaim_account_confirm, 0); tstconn->status |= AIM_CONN_STATUS_INPROGRESS; - if (proxy_connect(host, port, oscar_auth_connect, gc) != 0) { + if (proxy_connect(account, host, port, oscar_auth_connect, gc) != 0) { aim_conn_kill(sess, &tstconn); debug_printf("unable to reconnect with authorizer\n"); g_free(host); @@ -1528,7 +1528,7 @@ aim_conn_addhandler(sess, tstconn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_CONNINITDONE, conninitdone_chatnav, 0); tstconn->status |= AIM_CONN_STATUS_INPROGRESS; - if (proxy_connect(host, port, oscar_chatnav_connect, gc) != 0) { + if (proxy_connect(account, host, port, oscar_chatnav_connect, gc) != 0) { aim_conn_kill(sess, &tstconn); debug_printf("unable to connect to chatnav server\n"); g_free(host); @@ -1557,9 +1557,9 @@ ccon->exchange = redir->chat.exchange; ccon->instance = redir->chat.instance; ccon->show = extract_name(redir->chat.room); - + ccon->conn->status |= AIM_CONN_STATUS_INPROGRESS; - if (proxy_connect(host, port, oscar_chat_connect, ccon) != 0) { + if (proxy_connect(account, host, port, oscar_chat_connect, ccon) != 0) { aim_conn_kill(sess, &tstconn); debug_printf("unable to connect to chat server\n"); g_free(host); @@ -1581,7 +1581,7 @@ aim_conn_addhandler(sess, tstconn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_CONNINITDONE, conninitdone_email, 0); tstconn->status |= AIM_CONN_STATUS_INPROGRESS; - if (proxy_connect(host, port, oscar_email_connect, gc) != 0) { + if (proxy_connect(account, host, port, oscar_email_connect, gc) != 0) { aim_conn_kill(sess, &tstconn); debug_printf("unable to connect to email server\n"); g_free(host); @@ -1935,7 +1935,7 @@ } host = g_strndup(d->ip, i); dim->conn->status |= AIM_CONN_STATUS_INPROGRESS; - rc = proxy_connect(host, port, oscar_odc_callback, dim); + rc = proxy_connect(gc->account, host, port, oscar_odc_callback, dim); g_free(host); if (rc < 0) { aim_conn_kill(od->sess, &dim->conn);
--- a/src/protocols/toc/toc.c Sun Mar 02 08:10:54 2003 +0000 +++ b/src/protocols/toc/toc.c Sun Mar 02 18:48:02 2003 +0000 @@ -199,7 +199,7 @@ set_login_progress(gc, 1, buf); debug_printf("* Client connects to TOC\n"); - if (proxy_connect(account->proto_opt[USEROPT_AUTH][0] ? + if (proxy_connect(account, account->proto_opt[USEROPT_AUTH][0] ? account->proto_opt[USEROPT_AUTH] : TOC_HOST, account->proto_opt[USEROPT_AUTHPORT][0] ? atoi(account->proto_opt[USEROPT_AUTHPORT]) : TOC_PORT, @@ -1700,7 +1700,7 @@ g_snprintf(buf, sizeof(buf), "toc_rvous_accept %s %s %s", ft->user, ft->cookie, FILE_SEND_UID); sflap_send(ft->gc, buf, -1, TYPE_DATA); - if (proxy_connect(ft->ip, ft->port, toc_send_file_connect, ft) != 0) { + if (proxy_connect(account, ft->ip, ft->port, toc_send_file_connect, ft) != 0) { do_error_dialog(_("Could not connect for transfer."), NULL, GAIM_ERROR); g_free(ft->filename); g_free(ft->cookie); @@ -1902,7 +1902,7 @@ g_snprintf(buf2, sizeof(buf2), "toc_rvous_accept %s %s %s", ft->user, ft->cookie, FILE_GET_UID); sflap_send(ft->gc, buf2, -1, TYPE_DATA); - if (proxy_connect(ft->ip, ft->port, toc_get_file_connect, ft) < 0) { + if (proxy_connect(account, ft->ip, ft->port, toc_get_file_connect, ft) < 0) { do_error_dialog(_("Could not connect for transfer."), NULL, GAIM_ERROR); fclose(ft->file); g_free(ft->filename);
--- a/src/protocols/yahoo/yahoo.c Sun Mar 02 08:10:54 2003 +0000 +++ b/src/protocols/yahoo/yahoo.c Sun Mar 02 18:48:02 2003 +0000 @@ -973,7 +973,7 @@ } - if (proxy_connect(account->proto_opt[USEROPT_PAGERHOST][0] ? + if (proxy_connect(account, account->proto_opt[USEROPT_PAGERHOST][0] ? account->proto_opt[USEROPT_PAGERHOST] : YAHOO_PAGER_HOST, account->proto_opt[USEROPT_PAGERPORT][0] ? atoi(account->proto_opt[USEROPT_PAGERPORT]) : YAHOO_PAGER_PORT,
--- a/src/proxy.c Sun Mar 02 08:10:54 2003 +0000 +++ b/src/proxy.c Sun Mar 02 18:48:02 2003 +0000 @@ -55,11 +55,7 @@ #define GAIM_READ_COND (G_IO_IN | G_IO_HUP | G_IO_ERR) #define GAIM_WRITE_COND (G_IO_OUT | G_IO_HUP | G_IO_ERR | G_IO_NVAL) -char proxyhost[128] = { 0 }; -int proxyport = 0; -proxytype_t proxytype = PROXY_NONE; -char proxyuser[128] = { 0 }; -char proxypass[128] = { 0 }; +struct gaim_proxy_info global_proxy_info; struct PHB { GaimInputFunction func; @@ -67,7 +63,7 @@ char *host; int port; gint inpa; - proxytype_t proxytype; + struct gaim_proxy_info *gpi; }; typedef struct _GaimIOClosure { @@ -728,9 +724,9 @@ request_len = g_snprintf(request, sizeof(request), "CONNECT %s:%d HTTP/1.1\r\nHost: %s:%d\r\n", phb->host, phb->port, phb->host, phb->port); - if (proxyuser) { + if (phb->gpi->proxyuser) { char *t1, *t2; - t1 = g_strdup_printf("%s:%s", proxyuser, proxypass); + t1 = g_strdup_printf("%s:%s", phb->gpi->proxyuser, phb->gpi->proxypass); t2 = tobase64(t1); g_free(t1); g_return_if_fail(request_len < sizeof(request)); @@ -757,7 +753,7 @@ { int fd = -1; - debug_printf("connecting to %s:%d via %s:%d using HTTP\n", phb->host, phb->port, proxyhost, proxyport); + debug_printf("connecting to %s:%d via %s:%d using HTTP\n", phb->host, phb->port, phb->gpi->proxyhost, phb->gpi->proxyport); if ((fd = socket(addr->sa_family, SOCK_STREAM, 0)) < 0) { g_free(phb->host); @@ -873,7 +869,7 @@ { int fd = -1; - debug_printf("connecting to %s:%d via %s:%d using SOCKS4\n", phb->host, phb->port, proxyhost, proxyport); + debug_printf("connecting to %s:%d via %s:%d using SOCKS4\n", phb->host, phb->port, phb->gpi->proxyhost, phb->gpi->proxyport); if ((fd = socket(addr->sa_family, SOCK_STREAM, 0)) < 0) { g_free(phb->host); @@ -1020,12 +1016,12 @@ } if (buf[1] == 0x02) { - unsigned int i = strlen(proxyuser), j = strlen(proxypass); + unsigned int i = strlen(phb->gpi->proxyuser), j = strlen(phb->gpi->proxypass); buf[0] = 0x01; /* version 1 */ buf[1] = i; - memcpy(buf + 2, proxyuser, i); + memcpy(buf + 2, phb->gpi->proxyuser, i); buf[2 + i] = j; - memcpy(buf + 2 + i + 1, proxypass, j); + memcpy(buf + 2 + i + 1, phb->gpi->proxypass, j); if (write(source, buf, 3 + i + j) < 3 + i + j) { close(source); @@ -1064,7 +1060,7 @@ i = 0; buf[0] = 0x05; /* SOCKS version 5 */ - if (proxyuser[0]) { + if (phb->gpi->proxyuser[0]) { buf[1] = 0x02; /* two methods */ buf[2] = 0x00; /* no authentication */ buf[3] = 0x02; /* username/password authentication */ @@ -1091,7 +1087,7 @@ { int fd = -1; - debug_printf("connecting to %s:%d via %s:%d using SOCKS5\n", phb->host, phb->port, proxyhost, proxyport); + debug_printf("connecting to %s:%d via %s:%d using SOCKS5\n", phb->host, phb->port, phb->gpi->proxyhost, phb->gpi->proxyport); if ((fd = socket(addr->sa_family, SOCK_STREAM, 0)) < 0) { g_free(phb->host); @@ -1132,14 +1128,14 @@ static void connection_host_resolved(struct sockaddr *addr, size_t addrlen, gpointer data, const char *error_message) { struct PHB *phb = (struct PHB*)data; - + if(!addr) { phb->func(phb->data, -1, GAIM_INPUT_READ); return; } - switch(phb->proxytype) + switch(phb->gpi->proxytype) { case PROXY_NONE: proxy_connect_none(phb, addr, addrlen); @@ -1157,16 +1153,19 @@ } int -proxy_connect(char *host, int port, GaimInputFunction func, gpointer data) +proxy_connect(struct gaim_account *account, char *host, int port, GaimInputFunction func, gpointer data) { char *connecthost = host; int connectport = port; struct PHB *phb = g_new0(struct PHB, 1); + if(!account || !account->gpi) + phb->gpi = &global_proxy_info; + else + phb->gpi = account->gpi; phb->func = func; phb->data = data; phb->host = g_strdup(host); phb->port = port; - phb->proxytype = proxytype; if (!host || !port || (port == -1) || !func) { if(host) @@ -1175,18 +1174,18 @@ return -1; } - if ((phb->proxytype!=PROXY_NONE) && (!proxyhost || !proxyhost[0] || !proxyport || (proxyport == -1))) - phb->proxytype=PROXY_NONE; + if ((phb->gpi->proxytype!=PROXY_NONE) && (!phb->gpi->proxyhost || !phb->gpi->proxyhost[0] || !phb->gpi->proxyport || (phb->gpi->proxyport == -1))) + phb->gpi->proxytype=PROXY_NONE; - switch(phb->proxytype) + switch(phb->gpi->proxytype) { case PROXY_NONE: break; case PROXY_HTTP: case PROXY_SOCKS4: case PROXY_SOCKS5: - connecthost=proxyhost; - connectport=proxyport; + connecthost=phb->gpi->proxyhost; + connectport=phb->gpi->proxyport; break; default: g_free(phb->host);
--- a/src/proxy.h Sun Mar 02 08:10:54 2003 +0000 +++ b/src/proxy.h Sun Mar 02 18:48:02 2003 +0000 @@ -39,18 +39,25 @@ #include <glib.h> +#include "core.h" + typedef enum { + PROXY_USE_GLOBAL = -1, PROXY_NONE = 0, PROXY_HTTP, PROXY_SOCKS4, PROXY_SOCKS5, } proxytype_t; -extern char proxyhost[128]; -extern int proxyport; -extern proxytype_t proxytype; -extern char proxyuser[128]; -extern char proxypass[128]; +struct gaim_proxy_info { + int proxytype; + char proxyhost[128]; + proxytype_t proxyport; + char proxyuser[128]; + char proxypass[128]; +}; + +extern struct gaim_proxy_info global_proxy_info; extern guint proxy_info_is_from_gaimrc; typedef enum { @@ -62,6 +69,6 @@ extern gint gaim_input_add(int, GaimInputCondition, GaimInputFunction, gpointer); extern void gaim_input_remove(gint); -extern int proxy_connect(char *host, int port, GaimInputFunction func, gpointer data); +extern int proxy_connect(struct gaim_account *account, char *host, int port, GaimInputFunction func, gpointer data); #endif /* _PROXY_H_ */