changeset 6001:5e9364e9b29e

[gaim-migrate @ 6449] This makes the global proxy settings usable, I think. I think I'll try to get rid of PROXYHOST, PROXYPORT, etc. tomrrow. For now? Sleep. committer: Tailor Script <tailor@pidgin.im>
author Mark Doliner <mark@kingant.net>
date Thu, 03 Jul 2003 04:49:38 +0000
parents 711a425ac97c
children 6e3650c096b0
files src/gtkprefs.c src/protocols/oscar/chat.c src/proxy.c
diffstat 3 files changed, 38 insertions(+), 11 deletions(-) [+]
line wrap: on
line diff
--- a/src/gtkprefs.c	Thu Jul 03 03:23:27 2003 +0000
+++ b/src/gtkprefs.c	Thu Jul 03 04:49:38 2003 +0000
@@ -79,6 +79,7 @@
 static GtkTreeIter plugin_iter;
 
 static guint browser_pref_id = 0;
+static guint proxy_pref_id = 0;
 
 /*
  * PROTOTYPES
@@ -368,6 +369,7 @@
 
 	/* Unregister callbacks. */
 	gaim_prefs_disconnect_callback(browser_pref_id);
+	gaim_prefs_disconnect_callback(proxy_pref_id);
 
 	for (l = gaim_plugins_get_loaded(); l != NULL; l = l->next) {
 		plug = l->data;
@@ -387,16 +389,14 @@
 
 static void proxy_print_option(GtkEntry *entry, int entrynum)
 {
-	GaimProxyInfo *info = gaim_global_proxy_get_info();
-
 	if (entrynum == PROXYHOST)
-		gaim_proxy_info_set_host(info, gtk_entry_get_text(entry));
+		gaim_prefs_set_string("/core/proxy/host", gtk_entry_get_text(entry));
 	else if (entrynum == PROXYPORT)
-		gaim_proxy_info_set_port(info, atoi(gtk_entry_get_text(entry)));
+		gaim_prefs_set_int("/core/proxy/port", atoi(gtk_entry_get_text(entry)));
 	else if (entrynum == PROXYUSER)
-		gaim_proxy_info_set_username(info, gtk_entry_get_text(entry));
+		gaim_prefs_set_string("/core/proxy/username", gtk_entry_get_text(entry));
 	else if (entrynum == PROXYPASS)
-		gaim_proxy_info_set_password(info, gtk_entry_get_text(entry));
+		gaim_prefs_set_string("/core/proxy/password", gtk_entry_get_text(entry));
 
 	/* If the user specifies it, we want to save it. */
 	gaim_global_proxy_set_from_prefs(TRUE);
@@ -1112,6 +1112,16 @@
 	return ret;
 }
 
+static void
+proxy_changed_cb(const char *name, GaimPrefType type, gpointer value,
+				   gpointer data)
+{
+	GtkWidget *frame = data;
+	const char *proxy = value;
+
+	gtk_widget_set_sensitive(frame, strcmp(proxy, "none"));
+}
+
 GtkWidget *proxy_page() {
 	GtkWidget *ret;
 	GtkWidget *vbox;
@@ -1141,9 +1151,12 @@
 	if (proxy_info == NULL ||
 		gaim_proxy_info_get_type(proxy_info) == GAIM_PROXY_NONE) {
 
-		gtk_widget_set_sensitive(GTK_WIDGET(vbox), FALSE);
+		gtk_widget_set_sensitive(GTK_WIDGET(prefs_proxy_frame), FALSE);
 	}
 
+	proxy_pref_id = gaim_prefs_connect_callback("/core/proxy/type",
+												  proxy_changed_cb, prefs_proxy_frame);
+
 	table = gtk_table_new(2, 4, FALSE);
 	gtk_container_set_border_width(GTK_CONTAINER(table), 5);
 	gtk_table_set_col_spacings(GTK_TABLE(table), 5);
--- a/src/protocols/oscar/chat.c	Thu Jul 03 03:23:27 2003 +0000
+++ b/src/protocols/oscar/chat.c	Thu Jul 03 04:49:38 2003 +0000
@@ -532,7 +532,7 @@
 	/*
 	 * SubTLV: Type 1: Message
 	 */
-	aim_addtlvtochain_raw(&itl, 0x0001, strlen(msg), msg);
+	aim_addtlvtochain_raw(&itl, 0x0001, msglen, msg);
 
 	/*
 	 * Type 5: Message block.  Contains more TLVs.
--- a/src/proxy.c	Thu Jul 03 03:23:27 2003 +0000
+++ b/src/proxy.c	Thu Jul 03 04:49:38 2003 +0000
@@ -1585,9 +1585,23 @@
 {
 	GaimProxyInfo *info = gaim_global_proxy_get_info();
 
-	if (!strcmp(name, "/core/proxy/type"))
-		gaim_proxy_info_set_type(info, GPOINTER_TO_INT(value));
-	else if (!strcmp(name, "/core/proxy/host"))
+	if (!strcmp(name, "/core/proxy/type")) {
+		int proxytype;
+		char *type = value;
+
+		if (!strcmp(type, "none"))
+			proxytype = GAIM_PROXY_NONE;
+		else if (!strcmp(type, "http"))
+			proxytype = GAIM_PROXY_HTTP;
+		else if (!strcmp(type, "socks4"))
+			proxytype = GAIM_PROXY_SOCKS4;
+		else if (!strcmp(type, "socks5"))
+			proxytype = GAIM_PROXY_SOCKS5;
+		else
+			proxytype = -1;
+
+		gaim_proxy_info_set_type(info, proxytype);
+	} else if (!strcmp(name, "/core/proxy/host"))
 		gaim_proxy_info_set_host(info, value);
 	else if (!strcmp(name, "/core/proxy/port"))
 		gaim_proxy_info_set_port(info, GPOINTER_TO_INT(value));