[gaim-migrate @ 6100]

Tue, 03 Jun 2003 02:00:33 +0000

author
Christian Hammond <chipx86@chipx86.com>
date
Tue, 03 Jun 2003 02:00:33 +0000
changeset 5681
514fbc5374dc
parent 5680
fcf222b89d65
child 5682
0742fd1f34d4

[gaim-migrate @ 6100]
Rewrote the proxy code. It should now work with the new prefs, and it has a
namespace and API too!

src/account.c file | annotate | diff | comparison | revisions
src/account.h file | annotate | diff | comparison | revisions
src/ft.c file | annotate | diff | comparison | revisions
src/gaimrc.c file | annotate | diff | comparison | revisions
src/gtkaccount.c file | annotate | diff | comparison | revisions
src/gtkconv.c file | annotate | diff | comparison | revisions
src/gtkprefs.c file | annotate | diff | comparison | revisions
src/html.c file | annotate | diff | comparison | revisions
src/prefs.c file | annotate | diff | comparison | revisions
src/protocols/gg/gg.c file | annotate | diff | comparison | revisions
src/protocols/gg/libgg.c file | annotate | diff | comparison | revisions
src/protocols/irc/irc.c file | annotate | diff | comparison | revisions
src/protocols/jabber/jabber.c file | annotate | diff | comparison | revisions
src/protocols/msn/ft.c file | annotate | diff | comparison | revisions
src/protocols/msn/servconn.c file | annotate | diff | comparison | revisions
src/protocols/napster/napster.c file | annotate | diff | comparison | revisions
src/protocols/oscar/oscar.c file | annotate | diff | comparison | revisions
src/protocols/toc/toc.c file | annotate | diff | comparison | revisions
src/protocols/yahoo/yahoo.c file | annotate | diff | comparison | revisions
src/proxy.c file | annotate | diff | comparison | revisions
src/proxy.h file | annotate | diff | comparison | revisions
--- a/src/account.c	Mon Jun 02 22:30:25 2003 +0000
+++ b/src/account.c	Tue Jun 03 02:00:33 2003 +0000
@@ -298,6 +298,16 @@
 }
 
 void
+gaim_account_set_proxy_info(GaimAccount *account, GaimProxyInfo *info)
+{
+	g_return_if_fail(account != NULL);
+
+	account->proxy_info = info;
+
+	schedule_accounts_save();
+}
+
+void
 gaim_account_set_int(GaimAccount *account, const char *name, int value)
 {
 	GaimAccountSetting *setting;
@@ -433,6 +443,14 @@
 	return account->check_mail;
 }
 
+GaimProxyInfo *
+gaim_account_get_proxy_info(const GaimAccount *account)
+{
+	g_return_val_if_fail(account != NULL, NULL);
+
+	return account->proxy_info;
+}
+
 int
 gaim_account_get_int(const GaimAccount *account, const char *name,
 					 int default_value)
--- a/src/account.h	Mon Jun 02 22:30:25 2003 +0000
+++ b/src/account.h	Tue Jun 03 02:00:33 2003 +0000
@@ -26,6 +26,7 @@
 typedef struct _GaimAccount GaimAccount;
 
 #include "connection.h"
+#include "proxy.h"
 #include "prpl.h"
 
 struct _GaimAccount
@@ -47,7 +48,7 @@
 
 	GHashTable *settings;       /**< Protocol-specific settings. */
 
-	struct gaim_proxy_info *gpi; /**< Proxy information.         */
+	GaimProxyInfo *proxy_info;  /**< Proxy information.          */
 
 	GSList *permit;             /**< Permit list.                */
 	GSList *deny;               /**< Deny list.                  */
@@ -160,6 +161,14 @@
 void gaim_account_set_check_mail(GaimAccount *account, gboolean value);
 
 /**
+ * Sets the account's proxy information.
+ * 
+ * @param account The account.
+ * @param info    The proxy information.
+ */
+void gaim_account_set_proxy_info(GaimAccount *account, GaimProxyInfo *info);
+
+/**
  * Sets a protocol-specific integer setting for an account.
  *
  * @param account The account.
@@ -280,6 +289,15 @@
 gboolean gaim_account_get_check_mail(const GaimAccount *account);
 
 /**
+ * Returns the account's proxy information.
+ *
+ * @param account The account.
+ *
+ * @return The proxy information.
+ */
+GaimProxyInfo *gaim_account_get_proxy_info(const GaimAccount *account);
+
+/**
  * Returns a protocol-specific integer setting for an account.
  *
  * @param account       The account.
--- a/src/ft.c	Mon Jun 02 22:30:25 2003 +0000
+++ b/src/ft.c	Tue Jun 03 02:00:33 2003 +0000
@@ -602,8 +602,8 @@
 			xfer->remote_port = port;
 
 			/* Establish a file descriptor. */
-			proxy_connect(xfer->account, xfer->remote_ip, xfer->remote_port,
-						  connect_cb, xfer);
+			gaim_proxy_connect(xfer->account, xfer->remote_ip,
+							   xfer->remote_port, connect_cb, xfer);
 
 			return;
 		}
--- a/src/gaimrc.c	Mon Jun 02 22:30:25 2003 +0000
+++ b/src/gaimrc.c	Tue Jun 03 02:00:33 2003 +0000
@@ -660,16 +660,15 @@
 	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]);
+	if(atoi(p->value[0]) != GAIM_PROXY_USE_GLOBAL) {
+		GaimProxyInfo *info;
+
+		info = gaim_proxy_info_new();
+		gaim_proxy_info_set_type(info, atoi(p->value[0]));
+		gaim_proxy_info_set_host(info, p->value[1]);
+		gaim_proxy_info_set_port(info, atoi(p->value[2]));
+		gaim_proxy_info_set_username(info, p->value[3]);
+		gaim_proxy_info_set_password(info, p->value[4]);
 	}
 
 	return account;
@@ -1143,6 +1142,8 @@
 
 static gboolean gaimrc_parse_proxy_uri(const char *proxy)
 {
+	GaimProxyInfo *info;
+
 	char *c, *d;
 	char buffer[2048];
 
@@ -1221,27 +1222,20 @@
 	}
 
 	/* NOTE: HTTP_PROXY takes precendence. */
-	if (host[0])
-		strcpy(global_proxy_info.proxyhost, host);
-	else
-		*global_proxy_info.proxyhost = '\0';
+	info = gaim_global_proxy_get_info();
 
-	if (user[0])
-		strcpy(global_proxy_info.proxyuser, user);
-	else
-		*global_proxy_info.proxyuser = '\0';
+	if (*host) gaim_proxy_info_set_host(info, host);
+	if (*user) gaim_proxy_info_set_username(info, user);
+	if (*pass) gaim_proxy_info_set_password(info, pass);
 
-	if (pass[0])
-		strcpy(global_proxy_info.proxypass, pass);
-	else
-		*global_proxy_info.proxypass = '\0';
-
-	global_proxy_info.proxyport = port;
+	gaim_proxy_info_set_port(info, port);
 
 	gaim_debug(GAIM_DEBUG_MISC, "gaimrc",
 			   "Host: '%s', User: '%s', Password: '%s', Port: %d\n",
-			   global_proxy_info.proxyhost, global_proxy_info.proxyuser,
-			   global_proxy_info.proxypass, global_proxy_info.proxyport);
+			   gaim_proxy_info_get_host(info),
+			   gaim_proxy_info_get_username(info),
+			   gaim_proxy_info_get_password(info),
+			   gaim_proxy_info_get_port(info));
 
 	return TRUE;
 }
@@ -1251,9 +1245,11 @@
 	char buf[2048];
 	struct parse parse_buffer;
 	struct parse *p;
+	GaimProxyInfo *info;
+
+	info = gaim_global_proxy_get_info();
 
 	buf[0] = 0;
-	global_proxy_info.proxyhost[0] = 0;
 	gaim_debug(GAIM_DEBUG_MISC, "gaimrc", "gaimrc_read_proxy\n");
 
 	while (buf[0] != '}') {
@@ -1266,78 +1262,60 @@
 		p = parse_line(buf, &parse_buffer);
 
 		if (!strcmp(p->option, "host")) {
-			g_snprintf(global_proxy_info.proxyhost,
-					sizeof(global_proxy_info.proxyhost), "%s", p->value[0]);
+			gaim_proxy_info_set_host(info, p->value[0]);
 			gaim_debug(GAIM_DEBUG_MISC, "gaimrc",
-					   "Set proxyhost %s\n", global_proxy_info.proxyhost);
+					   "Set proxyhost %s\n", p->value[0]);
 		} else if (!strcmp(p->option, "port")) {
-			global_proxy_info.proxyport = atoi(p->value[0]);
+			gaim_proxy_info_set_port(info, atoi(p->value[0]));
 		} else if (!strcmp(p->option, "type")) {
-			global_proxy_info.proxytype = atoi(p->value[0]);
+			gaim_proxy_info_set_type(info, atoi(p->value[0]));
 		} else if (!strcmp(p->option, "user")) {
-			g_snprintf(global_proxy_info.proxyuser,
-					sizeof(global_proxy_info.proxyuser), "%s", p->value[0]);