changeset 2010:dff412b306b8

[gaim-migrate @ 2020] this is Jeremy Brooks's patch to allow specification of host/port for Yahoo. I redid it slightly to work with some of the existing architecture. committer: Tailor Script <tailor@pidgin.im>
author Eric Warmenhoven <eric@warmenhoven.org>
date Wed, 13 Jun 2001 23:12:20 +0000
parents ac9dd6b00b34
children 8195d67364a4
files plugins/yay/buddy.c plugins/yay/conn.c plugins/yay/login.c plugins/yay/rxhandlers.c plugins/yay/yay.c plugins/yay/yay.h
diffstat 6 files changed, 172 insertions(+), 51 deletions(-) [+]
line wrap: on
line diff
--- a/plugins/yay/buddy.c	Wed Jun 13 21:28:03 2001 +0000
+++ b/plugins/yay/buddy.c	Wed Jun 13 23:12:20 2001 +0000
@@ -58,7 +58,7 @@
 
 	send = g_strconcat("GET ",
 			session->proxy_type ? "http://" : "",
-			session->proxy_type ? YAHOO_DATA_HOST : "",
+			session->proxy_type ? session->auth_host : "",
 			"/config/set_buddygrp?.bg=", grp,
 			"&.src=bl&.cmd=a&.bdl=", bdy,
 			"&.id=", id,
@@ -66,7 +66,7 @@
 			"&.amsg=", msg,
 			" HTTP/1.0\r\n",
 			"User-Agent: " YAHOO_USER_AGENT "\r\n"
-			"Host: " YAHOO_DATA_HOST "\r\n"
+			"Host: ", session->auth_host, "\r\n"
 			"Cookie: ", session->cookie,
 			"\r\n\r\n", NULL);
 	g_free(grp);
@@ -124,7 +124,7 @@
 
 	send = g_strconcat("GET ",
 			session->proxy_type ? "http://" : "",
-			session->proxy_type ? YAHOO_DATA_HOST : "",
+			session->proxy_type ? session->auth_host : "",
 			"/config/set_buddygrp?.bg=", grp,
 			"&.src=bl&.cmd=d&.bdl=", bdy,
 			"&.id=", id,
@@ -132,7 +132,7 @@
 			"&.amsg=", msg,
 			" HTTP/1.0\r\n",
 			"User-Agent: " YAHOO_USER_AGENT "\r\n"
-			"Host: " YAHOO_DATA_HOST "\r\n"
+			"Host: ", session->auth_host, "\r\n"
 			"Cookie: ", session->cookie,
 			"\r\n\r\n", NULL);
 	g_free(grp);
--- a/plugins/yay/conn.c	Wed Jun 13 21:28:03 2001 +0000
+++ b/plugins/yay/conn.c	Wed Jun 13 23:12:20 2001 +0000
@@ -128,25 +128,8 @@
 	conn->type = type;
 
 	if (yahoo_connector) {
-		const char *realhost = host;
 		YAHOO_PRINT(session, YAHOO_LOG_DEBUG, "Connecting using user-specified connect routine");
-		if (!host) {
-			switch (type) {
-				case YAHOO_CONN_TYPE_AUTH:
-					realhost = YAHOO_AUTH_HOST;
-					port = YAHOO_AUTH_PORT;
-					break;
-				case YAHOO_CONN_TYPE_MAIN:
-					realhost = YAHOO_PAGER_HOST;
-					port = YAHOO_PAGER_PORT;
-					break;
-				case YAHOO_CONN_TYPE_DUMB:
-					realhost = YAHOO_DATA_HOST;
-					port = YAHOO_DATA_PORT;
-					break;
-			}
-		}
-		if ((*yahoo_connector)(session, realhost, port, conn) < 0) {
+		if ((*yahoo_connector)(session, host, port, conn) < 0) {
 			YAHOO_PRINT(session, YAHOO_LOG_CRITICAL, "connect failed");
 			g_free(conn);
 			return NULL;
@@ -155,30 +138,14 @@
 		return conn;
 	}
 
-	if (host) {
-		conn->socket = yahoo_connect_host(session, host, port, &status);
-	} else if (session->proxy_type) {
+	if (session->proxy_type) {
 		YAHOO_PRINT(session, YAHOO_LOG_DEBUG, "connecting to proxy");
 		conn->socket = yahoo_connect_host(session, session->proxy_host,
 				session->proxy_port, &status);
 		if (type == YAHOO_CONN_TYPE_MAIN)
 			conn->type = YAHOO_CONN_TYPE_PROXY;
-	} else {
-		switch (type) {
-			case YAHOO_CONN_TYPE_AUTH:
-				conn->socket = yahoo_connect_host(session, YAHOO_AUTH_HOST,
-						YAHOO_AUTH_PORT, &status);
-				break;
-			case YAHOO_CONN_TYPE_MAIN:
-				conn->socket = yahoo_connect_host(session, YAHOO_PAGER_HOST,
-						YAHOO_PAGER_PORT, &status);
-				break;
-			case YAHOO_CONN_TYPE_DUMB:
-				conn->socket = yahoo_connect_host(session, YAHOO_DATA_HOST,
-						YAHOO_DATA_PORT, &status);
-				break;
-		}
-	}
+	} else
+		conn->socket = yahoo_connect_host(session, host, port, &status);
 
 	if (conn->socket < 0) {
 		g_free(conn);
@@ -235,7 +202,19 @@
 	if (!session)
 		return 0;
 
-	if (!yahoo_new_conn(session, YAHOO_CONN_TYPE_AUTH, host, port))
+	if (session->auth_host)
+		g_free(session->auth_host);
+	if (host && *host)
+		session->auth_host = g_strdup(host);
+	else
+		session->auth_host = g_strdup(YAHOO_AUTH_HOST);
+
+	if (port)
+		session->auth_port = port;
+	else
+		session->auth_port = YAHOO_AUTH_PORT;
+
+	if (!yahoo_new_conn(session, YAHOO_CONN_TYPE_AUTH, session->auth_host, session->auth_port))
 		return 0;
 
 	return 1;
@@ -246,7 +225,19 @@
 	if (!session)
 		return 0;
 
-	if (!yahoo_new_conn(session, YAHOO_CONN_TYPE_MAIN, host, port))
+	if (session->pager_host)
+		g_free(session->pager_host);
+	if (host && *host)
+		session->pager_host = g_strdup(host);
+	else
+		session->pager_host = g_strdup(YAHOO_PAGER_HOST);
+
+	if (port)
+		session->pager_port = port;
+	else
+		session->pager_port = YAHOO_AUTH_PORT;
+
+	if (!yahoo_new_conn(session, YAHOO_CONN_TYPE_MAIN, session->pager_host, session->pager_port))
 		return 0;
 
 	return 1;
@@ -307,6 +298,12 @@
 		g_free(grp);
 		session->groups = g_list_remove(session->groups, grp);
 	}
+	if (session->auth_host)
+		g_free(session->auth_host);
+	session->auth_host = NULL;
+	if (session->pager_host)
+		g_free(session->pager_host);
+	session->pager_host = NULL;
 	return 0;
 }
 
--- a/plugins/yay/login.c	Wed Jun 13 21:28:03 2001 +0000
+++ b/plugins/yay/login.c	Wed Jun 13 23:12:20 2001 +0000
@@ -44,10 +44,10 @@
 	at = g_snprintf(buf, 1024 + strlen(name) + strlen(password),
 			"GET %s%s/config/ncclogin?login=%s&passwd=%s&n=1 HTTP/1.0\r\n"
 			"User-Agent: " YAHOO_USER_AGENT "\r\n"
-			"Host: " YAHOO_AUTH_HOST "\r\n\r\n",
+			"Host: %s\r\n\r\n",
 			session->proxy_type ? "http://" : "",
-			session->proxy_type ? YAHOO_AUTH_HOST "" : " ",
-			a, b);
+			session->proxy_type ? session->auth_host : "",
+			a, b, session->auth_host);
 
 	g_free(a);
 	g_free(b);
--- a/plugins/yay/rxhandlers.c	Wed Jun 13 21:28:03 2001 +0000
+++ b/plugins/yay/rxhandlers.c	Wed Jun 13 23:12:20 2001 +0000
@@ -363,7 +363,7 @@
 		} else if (conn->type == YAHOO_CONN_TYPE_PROXY) {
 			char buf[1024];
 			g_snprintf(buf, sizeof(buf), "CONNECT %s:%d HTTP/1.1\r\n\r\n",
-					YAHOO_PAGER_HOST, YAHOO_PAGER_PORT);
+					session->pager_host, session->pager_port);
 			YAHOO_PRINT(session, YAHOO_LOG_DEBUG, buf);
 			yahoo_write(session, conn, buf, strlen(buf));
 		}
--- a/plugins/yay/yay.c	Wed Jun 13 21:28:03 2001 +0000
+++ b/plugins/yay/yay.c	Wed Jun 13 23:12:20 2001 +0000
@@ -51,6 +51,11 @@
 
 #define USEROPT_MAIL 0
 
+#define USEROPT_AUTHHOST 1
+#define USEROPT_AUTHPORT 2
+#define USEROPT_PAGERHOST 3
+#define USEROPT_PAGERPORT 4
+
 struct conn {
 	int socket;
 	int type;
@@ -286,7 +291,8 @@
 	struct gaim_connection *gc = sess->user_data;
 
 	set_login_progress(gc, 3, "Got login cookie");
-	if (yahoo_major_connect(sess, NULL, 0) < 1) {
+	if (yahoo_major_connect(sess, gc->user->proto_opt[USEROPT_PAGERHOST],
+				atoi(gc->user->proto_opt[USEROPT_PAGERPORT])) < 1) {
 		hide_login_progress(gc, "Login error");
 		signoff(gc);
 	}
@@ -405,7 +411,8 @@
 
 	set_login_progress(gc, 1, "Connecting");
 
-	if (!yahoo_connect(yd->sess, NULL, 0)) {
+	if (!yahoo_connect(yd->sess, user->proto_opt[USEROPT_AUTHHOST],
+				atoi(user->proto_opt[USEROPT_AUTHPORT]))) {
 		hide_login_progress(gc, "Connection problem");
 		signoff(gc);
 		return;
@@ -729,9 +736,36 @@
 	return button;
 }
 
+static void yahoo_print_option(GtkEntry *entry, struct aim_user *user) {
+	int entrynum;
+	
+	entrynum = (int) gtk_object_get_user_data(GTK_OBJECT(entry));
+
+	if (entrynum == USEROPT_AUTHHOST) {
+		g_snprintf(user->proto_opt[USEROPT_AUTHHOST],
+				sizeof(user->proto_opt[USEROPT_AUTHHOST]),
+				"%s", gtk_entry_get_text(entry));
+	} else if (entrynum == USEROPT_AUTHPORT) {
+		g_snprintf(user->proto_opt[USEROPT_AUTHPORT],
+				sizeof(user->proto_opt[USEROPT_AUTHPORT]),
+				"%s", gtk_entry_get_text(entry));
+	} else if (entrynum == USEROPT_PAGERHOST) {
+		g_snprintf(user->proto_opt[USEROPT_PAGERHOST],
+				sizeof(user->proto_opt[USEROPT_PAGERHOST]),
+				"%s", gtk_entry_get_text(entry));
+	} else if (entrynum == USEROPT_PAGERPORT) {
+		g_snprintf(user->proto_opt[USEROPT_PAGERPORT],
+				sizeof(user->proto_opt[USEROPT_PAGERPORT]),
+				"%s", gtk_entry_get_text(entry));
+	}
+}
+
 static void yahoo_user_opts(GtkWidget *book, struct aim_user *user)
 {
 	GtkWidget *vbox;
+	GtkWidget *hbox; 
+	GtkWidget *label;
+	GtkWidget *entry;
 
 	vbox = gtk_vbox_new(FALSE, 5);
 	gtk_container_set_border_width(GTK_CONTAINER(vbox), 5);
@@ -739,6 +773,93 @@
 	gtk_widget_show(vbox);
 
 	yahoo_protoopt_button("Notify me of new Yahoo! Mail", user, USEROPT_MAIL, vbox);
+	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("Yahoo Auth Host:");
+	gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0);
+	gtk_widget_show(label);
+
+	entry = gtk_entry_new();
+	gtk_box_pack_end(GTK_BOX(hbox), entry, FALSE, FALSE, 0);
+	gtk_object_set_user_data(GTK_OBJECT(entry), (void *)USEROPT_AUTHHOST);
+	gtk_signal_connect(GTK_OBJECT(entry), "changed",
+			   GTK_SIGNAL_FUNC(yahoo_print_option), user);
+	if (user->proto_opt[USEROPT_AUTHHOST][0]) {
+		debug_printf("setting text %s\n", user->proto_opt[USEROPT_AUTHHOST]);
+		gtk_entry_set_text(GTK_ENTRY(entry), user->proto_opt[USEROPT_AUTHHOST]);
+	} else {
+		gtk_entry_set_text(GTK_ENTRY(entry), YAHOO_AUTH_HOST);
+	}
+	gtk_widget_show(entry);
+
+	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("Yahoo Auth Port:");
+	gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0);
+	gtk_widget_show(label);
+
+	entry = gtk_entry_new();
+	gtk_box_pack_end(GTK_BOX(hbox), entry, FALSE, FALSE, 0);
+	gtk_object_set_user_data(GTK_OBJECT(entry), (void *)USEROPT_AUTHPORT);
+	gtk_signal_connect(GTK_OBJECT(entry), "changed",
+			   GTK_SIGNAL_FUNC(yahoo_print_option), user);
+	if (user->proto_opt[USEROPT_AUTHPORT][0]) {
+		debug_printf("setting text %s\n", user->proto_opt[USEROPT_AUTHPORT]);
+		gtk_entry_set_text(GTK_ENTRY(entry), user->proto_opt[USEROPT_AUTHPORT]);
+	} else {
+		g_snprintf(user->proto_opt[USEROPT_AUTHPORT], sizeof(user->proto_opt[USEROPT_AUTHPORT]),
+					"%d", YAHOO_AUTH_PORT);
+		gtk_entry_set_text(GTK_ENTRY(entry), user->proto_opt[USEROPT_AUTHPORT]);
+	}
+	gtk_widget_show(entry);
+
+	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("Yahoo Pager Host:");
+	gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0);
+	gtk_widget_show(label);
+
+	entry = gtk_entry_new();
+	gtk_box_pack_end(GTK_BOX(hbox), entry, FALSE, FALSE, 0);
+	gtk_object_set_user_data(GTK_OBJECT(entry), (void *)USEROPT_PAGERHOST);
+	gtk_signal_connect(GTK_OBJECT(entry), "changed",
+			   GTK_SIGNAL_FUNC(yahoo_print_option), user);
+	if (user->proto_opt[USEROPT_PAGERHOST][0]) {
+		debug_printf("setting text %s\n", user->proto_opt[USEROPT_PAGERHOST]);
+		gtk_entry_set_text(GTK_ENTRY(entry), user->proto_opt[USEROPT_PAGERHOST]);
+	} else {
+		gtk_entry_set_text(GTK_ENTRY(entry), YAHOO_PAGER_HOST);
+	}
+	gtk_widget_show(entry);
+
+	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("Yahoo Pager Port:");
+	gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0);
+	gtk_widget_show(label);
+
+	entry = gtk_entry_new();
+	gtk_box_pack_end(GTK_BOX(hbox), entry, FALSE, FALSE, 0);
+	gtk_object_set_user_data(GTK_OBJECT(entry), (void *)USEROPT_PAGERPORT);
+	gtk_signal_connect(GTK_OBJECT(entry), "changed",
+			   GTK_SIGNAL_FUNC(yahoo_print_option), user);
+	if (user->proto_opt[USEROPT_PAGERPORT][0]) {
+		debug_printf("setting text %s\n", user->proto_opt[USEROPT_PAGERPORT]);
+		gtk_entry_set_text(GTK_ENTRY(entry), user->proto_opt[USEROPT_PAGERPORT]);
+	} else {
+		g_snprintf(user->proto_opt[USEROPT_PAGERPORT], sizeof(user->proto_opt[USEROPT_PAGERPORT]),
+					"%d", YAHOO_PAGER_PORT);
+		gtk_entry_set_text(GTK_ENTRY(entry), user->proto_opt[USEROPT_PAGERPORT]);
+	}
+	gtk_widget_show(entry);
 }
 
 static void toggle_offline(GtkToggleButton *button, struct conversation *c)
--- a/plugins/yay/yay.h	Wed Jun 13 21:28:03 2001 +0000
+++ b/plugins/yay/yay.h	Wed Jun 13 23:12:20 2001 +0000
@@ -41,8 +41,6 @@
 #define YAHOO_AUTH_PORT 80
 #define YAHOO_PAGER_HOST "cs.yahoo.com"
 #define YAHOO_PAGER_PORT 5050
-#define YAHOO_DATA_HOST YAHOO_AUTH_HOST
-#define YAHOO_DATA_PORT YAHOO_AUTH_PORT
 
 enum yahoo_status {
 	YAHOO_STATUS_AVAILABLE,
@@ -133,6 +131,11 @@
 	char *proxy_host;
 	int proxy_port;
 
+	char *auth_host;
+	int auth_port;
+	char *pager_host;
+	int pager_port;
+
 	char *name;
 
 	char *cookie;