summaryrefslogtreecommitdiff
path: root/irc/bitlbee/files/patch-xmpp-google
blob: a9647e34df031bbbacbf33189169b85fe92b5bb0 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
--- protocols/jabber/jabber.c	2004-11-14 22:37:47.000000000 +0100
+++ protocols/jabber/jabber.c	2005-08-24 09:47:25.000000000 +0200
@@ -565,16 +565,27 @@
 {
 	struct aim_user *user;
 	int port = -1, ssl = 0;
+	char *server = NULL, *s;
 
 	if (!gjc || gjc->state != JCONN_STATE_OFF)
 		return;
 
 	user = GJ_GC(gjc)->user;
 	if (*user->proto_opt[0]) {
-		if (isdigit(user->proto_opt[0][0]))
-			sscanf(user->proto_opt[0], "%d", &port);
+		/* If there's a dot, assume there's a hostname in the beginning */
+		if (strchr(user->proto_opt[0], '.')) {
+			server = g_strdup(user->proto_opt[0]);
+			if ((s = strchr(server, ':')))
+				*s = 0;
+		}
+		
+		/* After the hostname, there can be a port number */
+		s = strchr(user->proto_opt[0], ':');
+		if (s && isdigit(s[1]))
+			sscanf(s + 1, "%d", &port);
 		
-		if (strstr(user->proto_opt[0], "ssl"))
+		/* And if there's the string ssl, the user wants an SSL-connection */
+		if (strstr(user->proto_opt[0], ":ssl") || g_strcasecmp(user->proto_opt[0], "ssl") == 0)
 			ssl = 1;
 	}
 	
@@ -582,6 +593,9 @@
 		port = DEFAULT_PORT;
 	else if (port == -1 && ssl)
 		port = DEFAULT_PORT_SSL;
+	
+	if (server == NULL)
+		server = g_strdup(gjc->user->server);
 
 	gjc->parser = XML_ParserCreate(NULL);
 	XML_SetUserData(gjc->parser, (void *)gjc);
@@ -589,14 +603,16 @@
 	XML_SetCharacterDataHandler(gjc->parser, charData);
 	
 	if (ssl) {
-		if ((gjc->ssl = ssl_connect(gjc->user->server, port, gjab_connected_ssl, GJ_GC(gjc))))
+		if ((gjc->ssl = ssl_connect(server, port, gjab_connected_ssl, GJ_GC(gjc))))
 			gjc->fd = ssl_getfd(gjc->ssl);
 		else
 			gjc->fd = -1;
 	} else {
-		gjc->fd = proxy_connect(gjc->user->server, port, gjab_connected, GJ_GC(gjc));
+		gjc->fd = proxy_connect(server, port, gjab_connected, GJ_GC(gjc));
 	}
 	
+	g_free(server);
+	
 	if (!user->gc || (gjc->fd < 0)) {
 		STATE_EVT(JCONN_STATE_OFF)
 		return;