annotate plugins/yay/conn.c @ 2074:a4367a6478eb

[gaim-migrate @ 2084] Adam's patch to do the deny setting properly committer: Tailor Script <tailor@pidgin.im>
author Eric Warmenhoven <eric@warmenhoven.org>
date Tue, 17 Jul 2001 18:05:21 +0000
parents dff412b306b8
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1546
92b3dd1e4129 [gaim-migrate @ 1556]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1 /*
92b3dd1e4129 [gaim-migrate @ 1556]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2 * libyay
92b3dd1e4129 [gaim-migrate @ 1556]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3 *
92b3dd1e4129 [gaim-migrate @ 1556]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
4 * Copyright (C) 2001 Eric Warmenhoven <warmenhoven@yahoo.com>
92b3dd1e4129 [gaim-migrate @ 1556]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
5 *
92b3dd1e4129 [gaim-migrate @ 1556]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
6 * This program is free software; you can redistribute it and/or modify
92b3dd1e4129 [gaim-migrate @ 1556]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
7 * it under the terms of the GNU General Public License as published by
92b3dd1e4129 [gaim-migrate @ 1556]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
8 * the Free Software Foundation; either version 2 of the License, or
92b3dd1e4129 [gaim-migrate @ 1556]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
9 * (at your option) any later version.
92b3dd1e4129 [gaim-migrate @ 1556]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
10 *
92b3dd1e4129 [gaim-migrate @ 1556]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
11 * This program is distributed in the hope that it will be useful,
92b3dd1e4129 [gaim-migrate @ 1556]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
92b3dd1e4129 [gaim-migrate @ 1556]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
92b3dd1e4129 [gaim-migrate @ 1556]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
14 * GNU General Public License for more details.
92b3dd1e4129 [gaim-migrate @ 1556]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
15 *
92b3dd1e4129 [gaim-migrate @ 1556]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
16 * You should have received a copy of the GNU General Public License
92b3dd1e4129 [gaim-migrate @ 1556]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
17 * along with this program; if not, write to the Free Software
92b3dd1e4129 [gaim-migrate @ 1556]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
92b3dd1e4129 [gaim-migrate @ 1556]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
19 *
92b3dd1e4129 [gaim-migrate @ 1556]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
20 */
92b3dd1e4129 [gaim-migrate @ 1556]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
21
92b3dd1e4129 [gaim-migrate @ 1556]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
22 #include "internal.h"
92b3dd1e4129 [gaim-migrate @ 1556]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
23
92b3dd1e4129 [gaim-migrate @ 1556]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
24 void (*yahoo_socket_notify)(struct yahoo_session *, int, int, gboolean) = NULL;
92b3dd1e4129 [gaim-migrate @ 1556]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
25 void (*yahoo_print)(struct yahoo_session *, int, const char *) = NULL;
1879
6497ee3751cf [gaim-migrate @ 1889]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1566
diff changeset
26 int (*yahoo_connector)(struct yahoo_session *, const char *, int, gpointer) = NULL;
1546
92b3dd1e4129 [gaim-migrate @ 1556]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
27
92b3dd1e4129 [gaim-migrate @ 1556]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
28 struct yahoo_session *yahoo_new()
92b3dd1e4129 [gaim-migrate @ 1556]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
29 {
92b3dd1e4129 [gaim-migrate @ 1556]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
30 struct yahoo_session *sess;
92b3dd1e4129 [gaim-migrate @ 1556]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
31
92b3dd1e4129 [gaim-migrate @ 1556]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
32 if (!(sess = g_new0(struct yahoo_session, 1)))
92b3dd1e4129 [gaim-migrate @ 1556]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
33 return NULL;
92b3dd1e4129 [gaim-migrate @ 1556]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
34
92b3dd1e4129 [gaim-migrate @ 1556]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
35 return sess;
92b3dd1e4129 [gaim-migrate @ 1556]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
36 }
92b3dd1e4129 [gaim-migrate @ 1556]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
37
1565
2c66d386be90 [gaim-migrate @ 1575]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1546
diff changeset
38 void yahoo_set_proxy(struct yahoo_session *session, int proxy_type, char *proxy_host, int proxy_port)
2c66d386be90 [gaim-migrate @ 1575]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1546
diff changeset
39 {
2c66d386be90 [gaim-migrate @ 1575]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1546
diff changeset
40 if (!session || !proxy_type || !proxy_host)
2c66d386be90 [gaim-migrate @ 1575]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1546
diff changeset
41 return;
2c66d386be90 [gaim-migrate @ 1575]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1546
diff changeset
42
2c66d386be90 [gaim-migrate @ 1575]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1546
diff changeset
43 session->proxy_type = proxy_type;
2c66d386be90 [gaim-migrate @ 1575]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1546
diff changeset
44 session->proxy_host = g_strdup(proxy_host);
2c66d386be90 [gaim-migrate @ 1575]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1546
diff changeset
45 session->proxy_port = proxy_port;
2c66d386be90 [gaim-migrate @ 1575]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1546
diff changeset
46 }
2c66d386be90 [gaim-migrate @ 1575]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1546
diff changeset
47
1546
92b3dd1e4129 [gaim-migrate @ 1556]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
48 static int yahoo_connect_host(struct yahoo_session *sess, const char *host, int port, int *statusret)
92b3dd1e4129 [gaim-migrate @ 1556]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
49 {
92b3dd1e4129 [gaim-migrate @ 1556]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
50 struct sockaddr_in sa;
92b3dd1e4129 [gaim-migrate @ 1556]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
51 struct hostent *hp;
92b3dd1e4129 [gaim-migrate @ 1556]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
52 int fd;
92b3dd1e4129 [gaim-migrate @ 1556]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
53
92b3dd1e4129 [gaim-migrate @ 1556]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
54 if (!(hp = gethostbyname(host))) {
92b3dd1e4129 [gaim-migrate @ 1556]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
55 YAHOO_PRINT(sess, YAHOO_LOG_WARNING, "Resolve error");
92b3dd1e4129 [gaim-migrate @ 1556]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
56 if (statusret)
92b3dd1e4129 [gaim-migrate @ 1556]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
57 *statusret = (h_errno | YAHOO_CONN_STATUS_RESOLVERR);
92b3dd1e4129 [gaim-migrate @ 1556]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
58 return -1;
92b3dd1e4129 [gaim-migrate @ 1556]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
59 }
92b3dd1e4129 [gaim-migrate @ 1556]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
60
92b3dd1e4129 [gaim-migrate @ 1556]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
61 memset(&sa, 0, sizeof(struct sockaddr_in));
92b3dd1e4129 [gaim-migrate @ 1556]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
62 sa.sin_port = htons(port);
92b3dd1e4129 [gaim-migrate @ 1556]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
63 memcpy(&sa.sin_addr, hp->h_addr, hp->h_length);
92b3dd1e4129 [gaim-migrate @ 1556]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
64 sa.sin_family = hp->h_addrtype;
92b3dd1e4129 [gaim-migrate @ 1556]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
65
92b3dd1e4129 [gaim-migrate @ 1556]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
66 fd = socket(hp->h_addrtype, SOCK_STREAM, 0);
92b3dd1e4129 [gaim-migrate @ 1556]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
67
92b3dd1e4129 [gaim-migrate @ 1556]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
68 fcntl(fd, F_SETFL, O_NONBLOCK);
92b3dd1e4129 [gaim-migrate @ 1556]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
69
92b3dd1e4129 [gaim-migrate @ 1556]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
70 if (connect(fd, (struct sockaddr *)&sa, sizeof(struct sockaddr_in)) < 0) {
92b3dd1e4129 [gaim-migrate @ 1556]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
71 if ((errno == EINPROGRESS) || (errno == EINTR)) {
92b3dd1e4129 [gaim-migrate @ 1556]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
72 YAHOO_PRINT(sess, YAHOO_LOG_NOTICE, "Connect would block");
92b3dd1e4129 [gaim-migrate @ 1556]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
73 if (statusret)
92b3dd1e4129 [gaim-migrate @ 1556]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
74 *statusret |= YAHOO_CONN_STATUS_INPROGRESS;
92b3dd1e4129 [gaim-migrate @ 1556]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
75 return fd;
92b3dd1e4129 [gaim-migrate @ 1556]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
76 }
92b3dd1e4129 [gaim-migrate @ 1556]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
77 close(fd);
92b3dd1e4129 [gaim-migrate @ 1556]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
78 fd = -1;
92b3dd1e4129 [gaim-migrate @ 1556]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
79 }
92b3dd1e4129 [gaim-migrate @ 1556]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
80
92b3dd1e4129 [gaim-migrate @ 1556]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
81 return fd;
92b3dd1e4129 [gaim-migrate @ 1556]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
82 }
92b3dd1e4129 [gaim-migrate @ 1556]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
83
1879
6497ee3751cf [gaim-migrate @ 1889]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1566
diff changeset
84 int yahoo_connected(struct yahoo_session *session, gpointer data, int fd)
6497ee3751cf [gaim-migrate @ 1889]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1566
diff changeset
85 {
6497ee3751cf [gaim-migrate @ 1889]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1566
diff changeset
86 struct yahoo_conn *conn = data;
6497ee3751cf [gaim-migrate @ 1889]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1566
diff changeset
87
6497ee3751cf [gaim-migrate @ 1889]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1566
diff changeset
88 if (fd < 0) {
6497ee3751cf [gaim-migrate @ 1889]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1566
diff changeset
89 YAHOO_PRINT(session, YAHOO_LOG_WARNING, "connect failed");
6497ee3751cf [gaim-migrate @ 1889]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1566
diff changeset
90 session->connlist = g_list_remove(session->connlist, conn);
6497ee3751cf [gaim-migrate @ 1889]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1566
diff changeset
91 g_free(conn);
6497ee3751cf [gaim-migrate @ 1889]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1566
diff changeset
92 return 0;
6497ee3751cf [gaim-migrate @ 1889]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1566
diff changeset
93 }
6497ee3751cf [gaim-migrate @ 1889]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1566
diff changeset
94
6497ee3751cf [gaim-migrate @ 1889]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1566
diff changeset
95 YAHOO_PRINT(session, YAHOO_LOG_NOTICE, "connect succeeded");
6497ee3751cf [gaim-migrate @ 1889]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1566
diff changeset
96 conn->socket = fd;
6497ee3751cf [gaim-migrate @ 1889]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1566
diff changeset
97 conn->connected = TRUE;
6497ee3751cf [gaim-migrate @ 1889]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1566
diff changeset
98 if (conn->type == YAHOO_CONN_TYPE_AUTH) {
6497ee3751cf [gaim-migrate @ 1889]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1566
diff changeset
99 if (session->callbacks[YAHOO_HANDLE_AUTHCONNECT].function)
6497ee3751cf [gaim-migrate @ 1889]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1566
diff changeset
100 (*session->callbacks[YAHOO_HANDLE_AUTHCONNECT].function)(session);
6497ee3751cf [gaim-migrate @ 1889]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1566
diff changeset
101 } else if (conn->type == YAHOO_CONN_TYPE_MAIN) {
6497ee3751cf [gaim-migrate @ 1889]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1566
diff changeset
102 if (session->callbacks[YAHOO_HANDLE_MAINCONNECT].function)
6497ee3751cf [gaim-migrate @ 1889]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1566
diff changeset
103 (*session->callbacks[YAHOO_HANDLE_MAINCONNECT].function)(session);
6497ee3751cf [gaim-migrate @ 1889]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1566
diff changeset
104 } else if (conn->type == YAHOO_CONN_TYPE_DUMB) {
6497ee3751cf [gaim-migrate @ 1889]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1566
diff changeset
105 YAHOO_PRINT(session, YAHOO_LOG_DEBUG, "sending to buddy list host");
6497ee3751cf [gaim-migrate @ 1889]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1566
diff changeset
106 yahoo_write(session, conn, conn->txqueue, strlen(conn->txqueue));
6497ee3751cf [gaim-migrate @ 1889]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1566
diff changeset
107 g_free(conn->txqueue);
6497ee3751cf [gaim-migrate @ 1889]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1566
diff changeset
108 conn->txqueue = NULL;
6497ee3751cf [gaim-migrate @ 1889]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1566
diff changeset
109 }
6497ee3751cf [gaim-migrate @ 1889]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1566
diff changeset
110
6497ee3751cf [gaim-migrate @ 1889]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1566
diff changeset
111 if (yahoo_socket_notify)
6497ee3751cf [gaim-migrate @ 1889]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1566
diff changeset
112 (*yahoo_socket_notify)(session, conn->socket, YAHOO_SOCKET_READ, TRUE);
6497ee3751cf [gaim-migrate @ 1889]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1566
diff changeset
113 else
6497ee3751cf [gaim-migrate @ 1889]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1566
diff changeset
114 YAHOO_PRINT(session, YAHOO_LOG_CRITICAL, "yahoo_socket_notify not set up");
6497ee3751cf [gaim-migrate @ 1889]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1566
diff changeset
115
6497ee3751cf [gaim-migrate @ 1889]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1566
diff changeset
116 return 1;
6497ee3751cf [gaim-migrate @ 1889]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1566
diff changeset
117 }
6497ee3751cf [gaim-migrate @ 1889]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1566
diff changeset
118
1546
92b3dd1e4129 [gaim-migrate @ 1556]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
119 struct yahoo_conn *yahoo_new_conn(struct yahoo_session *session, int type, const char *host, int port)
92b3dd1e4129 [gaim-migrate @ 1556]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
120 {
92b3dd1e4129 [gaim-migrate @ 1556]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
121 struct yahoo_conn *conn;
92b3dd1e4129 [gaim-migrate @ 1556]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
122 int status;
92b3dd1e4129 [gaim-migrate @ 1556]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
123
92b3dd1e4129 [gaim-migrate @ 1556]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
124 if (!session)
92b3dd1e4129 [gaim-migrate @ 1556]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
125 return NULL;
92b3dd1e4129 [gaim-migrate @ 1556]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
126
92b3dd1e4129 [gaim-migrate @ 1556]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
127 conn = g_new0(struct yahoo_conn, 1);
92b3dd1e4129 [gaim-migrate @ 1556]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
128 conn->type = type;
92b3dd1e4129 [gaim-migrate @ 1556]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
129
1879
6497ee3751cf [gaim-migrate @ 1889]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1566
diff changeset
130 if (yahoo_connector) {
6497ee3751cf [gaim-migrate @ 1889]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1566
diff changeset
131 YAHOO_PRINT(session, YAHOO_LOG_DEBUG, "Connecting using user-specified connect routine");
2010
dff412b306b8 [gaim-migrate @ 2020]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1879
diff changeset
132 if ((*yahoo_connector)(session, host, port, conn) < 0) {
1879
6497ee3751cf [gaim-migrate @ 1889]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1566
diff changeset
133 YAHOO_PRINT(session, YAHOO_LOG_CRITICAL, "connect failed");
6497ee3751cf [gaim-migrate @ 1889]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1566
diff changeset
134 g_free(conn);
6497ee3751cf [gaim-migrate @ 1889]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1566
diff changeset
135 return NULL;
6497ee3751cf [gaim-migrate @ 1889]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1566
diff changeset
136 }
6497ee3751cf [gaim-migrate @ 1889]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1566
diff changeset
137 session->connlist = g_list_append(session->connlist, conn);
6497ee3751cf [gaim-migrate @ 1889]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1566
diff changeset
138 return conn;
6497ee3751cf [gaim-migrate @ 1889]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1566
diff changeset
139 }
6497ee3751cf [gaim-migrate @ 1889]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1566
diff changeset
140
2010
dff412b306b8 [gaim-migrate @ 2020]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1879
diff changeset
141 if (session->proxy_type) {
1565
2c66d386be90 [gaim-migrate @ 1575]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1546
diff changeset
142 YAHOO_PRINT(session, YAHOO_LOG_DEBUG, "connecting to proxy");
2c66d386be90 [gaim-migrate @ 1575]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1546
diff changeset
143 conn->socket = yahoo_connect_host(session, session->proxy_host,
2c66d386be90 [gaim-migrate @ 1575]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1546
diff changeset
144 session->proxy_port, &status);
2c66d386be90 [gaim-migrate @ 1575]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1546
diff changeset
145 if (type == YAHOO_CONN_TYPE_MAIN)
2c66d386be90 [gaim-migrate @ 1575]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1546
diff changeset
146 conn->type = YAHOO_CONN_TYPE_PROXY;
2010
dff412b306b8 [gaim-migrate @ 2020]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1879
diff changeset
147 } else
dff412b306b8 [gaim-migrate @ 2020]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1879
diff changeset
148 conn->socket = yahoo_connect_host(session, host, port, &status);
1546
92b3dd1e4129 [gaim-migrate @ 1556]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
149
92b3dd1e4129 [gaim-migrate @ 1556]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
150 if (conn->socket < 0) {
92b3dd1e4129 [gaim-migrate @ 1556]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
151 g_free(conn);
92b3dd1e4129 [gaim-migrate @ 1556]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
152 return NULL;
92b3dd1e4129 [gaim-migrate @ 1556]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
153 }
92b3dd1e4129 [gaim-migrate @ 1556]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
154
92b3dd1e4129 [gaim-migrate @ 1556]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
155 if (yahoo_socket_notify)
92b3dd1e4129 [gaim-migrate @ 1556]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
156 (*yahoo_socket_notify)(session, conn->socket, YAHOO_SOCKET_WRITE, TRUE);
92b3dd1e4129 [gaim-migrate @ 1556]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
157 else
92b3dd1e4129 [gaim-migrate @ 1556]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
158 YAHOO_PRINT(session, YAHOO_LOG_CRITICAL, "yahoo_socket_notify not set up");
92b3dd1e4129 [gaim-migrate @ 1556]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
159
92b3dd1e4129 [gaim-migrate @ 1556]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
160 session->connlist = g_list_append(session->connlist, conn);
92b3dd1e4129 [gaim-migrate @ 1556]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
161
92b3dd1e4129 [gaim-migrate @ 1556]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
162 return conn;
92b3dd1e4129 [gaim-migrate @ 1556]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
163 }
92b3dd1e4129 [gaim-migrate @ 1556]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
164
92b3dd1e4129 [gaim-migrate @ 1556]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
165 struct yahoo_conn *yahoo_getconn_type(struct yahoo_session *sess, int type)
92b3dd1e4129 [gaim-migrate @ 1556]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
166 {
92b3dd1e4129 [gaim-migrate @ 1556]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
167 GList *c;
92b3dd1e4129 [gaim-migrate @ 1556]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
168 struct yahoo_conn *conn;
92b3dd1e4129 [gaim-migrate @ 1556]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
169
92b3dd1e4129 [gaim-migrate @ 1556]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
170 if (!sess)
92b3dd1e4129 [gaim-migrate @ 1556]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
171 return NULL;
92b3dd1e4129 [gaim-migrate @ 1556]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
172
92b3dd1e4129 [gaim-migrate @ 1556]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
173 c = sess->connlist;
92b3dd1e4129 [gaim-migrate @ 1556]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
174 while (c) {
92b3dd1e4129 [gaim-migrate @ 1556]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
175 conn = c->data;
92b3dd1e4129 [gaim-migrate @ 1556]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
176 if (conn->type == type)
92b3dd1e4129 [gaim-migrate @ 1556]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
177 return conn;
92b3dd1e4129 [gaim-migrate @ 1556]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
178 c = g_list_next(c);
92b3dd1e4129 [gaim-migrate @ 1556]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
179 }
92b3dd1e4129 [gaim-migrate @ 1556]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
180
92b3dd1e4129 [gaim-migrate @ 1556]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
181 return NULL;
92b3dd1e4129 [gaim-migrate @ 1556]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
182 }
92b3dd1e4129 [gaim-migrate @ 1556]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
183
92b3dd1e4129 [gaim-migrate @ 1556]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
184 struct yahoo_conn *yahoo_find_conn(struct yahoo_session *sess, int socket)
92b3dd1e4129 [gaim-migrate @ 1556]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
185 {
92b3dd1e4129 [gaim-migrate @ 1556]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
186 GList *c;
92b3dd1e4129 [gaim-migrate @ 1556]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
187 struct yahoo_conn *conn;
92b3dd1e4129 [gaim-migrate @ 1556]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
188
92b3dd1e4129 [gaim-migrate @ 1556]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
189 c = sess->connlist;
92b3dd1e4129 [gaim-migrate @ 1556]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
190 while (c) {
92b3dd1e4129 [gaim-migrate @ 1556]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
191 conn = c->data;
92b3dd1e4129 [gaim-migrate @ 1556]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
192 if (conn->socket == socket)
92b3dd1e4129 [gaim-migrate @ 1556]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
193 return conn;
92b3dd1e4129 [gaim-migrate @ 1556]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
194 c = g_list_next(c);
92b3dd1e4129 [gaim-migrate @ 1556]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
195 }
92b3dd1e4129 [gaim-migrate @ 1556]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
196
92b3dd1e4129 [gaim-migrate @ 1556]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
197 return NULL;
92b3dd1e4129 [gaim-migrate @ 1556]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
198 }
92b3dd1e4129 [gaim-migrate @ 1556]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
199
92b3dd1e4129 [gaim-migrate @ 1556]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
200 int yahoo_connect(struct yahoo_session *session, const char *host, int port)
92b3dd1e4129 [gaim-migrate @ 1556]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
201 {
92b3dd1e4129 [gaim-migrate @ 1556]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
202 if (!session)
92b3dd1e4129 [gaim-migrate @ 1556]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
203 return 0;
92b3dd1e4129 [gaim-migrate @ 1556]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
204
2010
dff412b306b8 [gaim-migrate @ 2020]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1879
diff changeset
205 if (session->auth_host)
dff412b306b8 [gaim-migrate @ 2020]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1879
diff changeset
206 g_free(session->auth_host);
dff412b306b8 [gaim-migrate @ 2020]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1879
diff changeset
207 if (host && *host)
dff412b306b8 [gaim-migrate @ 2020]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1879
diff changeset
208 session->auth_host = g_strdup(host);
dff412b306b8 [gaim-migrate @ 2020]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1879
diff changeset
209 else
dff412b306b8 [gaim-migrate @ 2020]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1879
diff changeset
210 session->auth_host = g_strdup(YAHOO_AUTH_HOST);
dff412b306b8 [gaim-migrate @ 2020]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1879
diff changeset
211
dff412b306b8 [gaim-migrate @ 2020]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1879
diff changeset
212 if (port)
dff412b306b8 [gaim-migrate @ 2020]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1879
diff changeset
213 session->auth_port = port;
dff412b306b8 [gaim-migrate @ 2020]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1879
diff changeset
214 else
dff412b306b8 [gaim-migrate @ 2020]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1879
diff changeset
215 session->auth_port = YAHOO_AUTH_PORT;
dff412b306b8 [gaim-migrate @ 2020]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1879
diff changeset
216
dff412b306b8 [gaim-migrate @ 2020]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1879
diff changeset
217 if (!yahoo_new_conn(session, YAHOO_CONN_TYPE_AUTH, session->auth_host, session->auth_port))
1546
92b3dd1e4129 [gaim-migrate @ 1556]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
218 return 0;
92b3dd1e4129 [gaim-migrate @ 1556]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
219
92b3dd1e4129 [gaim-migrate @ 1556]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
220 return 1;
92b3dd1e4129 [gaim-migrate @ 1556]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
221 }
92b3dd1e4129 [gaim-migrate @ 1556]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
222
92b3dd1e4129 [gaim-migrate @ 1556]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
223 int yahoo_major_connect(struct yahoo_session *session, const char *host, int port)
92b3dd1e4129 [gaim-migrate @ 1556]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
224 {
92b3dd1e4129 [gaim-migrate @ 1556]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
225 if (!session)
92b3dd1e4129 [gaim-migrate @ 1556]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
226 return 0;
92b3dd1e4129 [gaim-migrate @ 1556]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
227
2010
dff412b306b8 [gaim-migrate @ 2020]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1879
diff changeset
228 if (session->pager_host)
dff412b306b8 [gaim-migrate @ 2020]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1879
diff changeset
229 g_free(session->pager_host);
dff412b306b8 [gaim-migrate @ 2020]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1879
diff changeset
230 if (host && *host)
dff412b306b8 [gaim-migrate @ 2020]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1879
diff changeset
231 session->pager_host = g_strdup(host);
dff412b306b8 [gaim-migrate @ 2020]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1879
diff changeset
232 else
dff412b306b8 [gaim-migrate @ 2020]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1879
diff changeset
233 session->pager_host = g_strdup(YAHOO_PAGER_HOST);
dff412b306b8 [gaim-migrate @ 2020]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1879
diff changeset
234
dff412b306b8 [gaim-migrate @ 2020]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1879
diff changeset
235 if (port)
dff412b306b8 [gaim-migrate @ 2020]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1879
diff changeset
236 session->pager_port = port;
dff412b306b8 [gaim-migrate @ 2020]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1879
diff changeset
237 else
dff412b306b8 [gaim-migrate @ 2020]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1879
diff changeset
238 session->pager_port = YAHOO_AUTH_PORT;
dff412b306b8 [gaim-migrate @ 2020]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1879
diff changeset
239
dff412b306b8 [gaim-migrate @ 2020]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1879
diff changeset
240 if (!yahoo_new_conn(session, YAHOO_CONN_TYPE_MAIN, session->pager_host, session->pager_port))
1546
92b3dd1e4129 [gaim-migrate @ 1556]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
241 return 0;
92b3dd1e4129 [gaim-migrate @ 1556]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
242
92b3dd1e4129 [gaim-migrate @ 1556]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
243 return 1;
92b3dd1e4129 [gaim-migrate @ 1556]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
244 }
92b3dd1e4129 [gaim-migrate @ 1556]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
245
92b3dd1e4129 [gaim-migrate @ 1556]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
246 void yahoo_close(struct yahoo_session *session, struct yahoo_conn *conn)
92b3dd1e4129 [gaim-migrate @ 1556]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
247 {
92b3dd1e4129 [gaim-migrate @ 1556]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
248 if (!session || !conn)
92b3dd1e4129 [gaim-migrate @ 1556]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
249 return;
92b3dd1e4129 [gaim-migrate @ 1556]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
250
92b3dd1e4129 [gaim-migrate @ 1556]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
251 if (!g_list_find(session->connlist, conn))
92b3dd1e4129 [gaim-migrate @ 1556]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
252 return;
92b3dd1e4129 [gaim-migrate @ 1556]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
253
1566
e9faf5dfdba0 [gaim-migrate @ 1576]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1565
diff changeset
254 if (yahoo_socket_notify) {
e9faf5dfdba0 [gaim-migrate @ 1576]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1565
diff changeset
255 if (conn->connected)
e9faf5dfdba0 [gaim-migrate @ 1576]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1565
diff changeset
256 (*yahoo_socket_notify)(session, conn->socket, YAHOO_SOCKET_READ, FALSE);
e9faf5dfdba0 [gaim-migrate @ 1576]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1565
diff changeset
257 else
e9faf5dfdba0 [gaim-migrate @ 1576]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1565
diff changeset
258 (*yahoo_socket_notify)(session, conn->socket, YAHOO_SOCKET_WRITE, FALSE);
e9faf5dfdba0 [gaim-migrate @ 1576]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1565
diff changeset
259 }
1546
92b3dd1e4129 [gaim-migrate @ 1556]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
260 close(conn->socket);
92b3dd1e4129 [gaim-migrate @ 1556]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
261
92b3dd1e4129 [gaim-migrate @ 1556]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
262 session->connlist = g_list_remove(session->connlist, conn);
92b3dd1e4129 [gaim-migrate @ 1556]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
263 if (conn->txqueue)
92b3dd1e4129 [gaim-migrate @ 1556]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
264 g_free(conn->txqueue);
92b3dd1e4129 [gaim-migrate @ 1556]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
265 g_free(conn);
92b3dd1e4129 [gaim-migrate @ 1556]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
266 }
92b3dd1e4129 [gaim-migrate @ 1556]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
267
92b3dd1e4129 [gaim-migrate @ 1556]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
268 int yahoo_disconnect(struct yahoo_session *session)
92b3dd1e4129 [gaim-migrate @ 1556]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
269 {
92b3dd1e4129 [gaim-migrate @ 1556]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
270 if (!session)
92b3dd1e4129 [gaim-migrate @ 1556]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
271 return 0;
92b3dd1e4129 [gaim-migrate @ 1556]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
272 if (session->name)
92b3dd1e4129 [gaim-migrate @ 1556]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
273 g_free(session->name);
92b3dd1e4129 [gaim-migrate @ 1556]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
274 yahoo_logoff(session);
92b3dd1e4129 [gaim-migrate @ 1556]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
275 session->name = NULL;
92b3dd1e4129 [gaim-migrate @ 1556]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
276 while (session->connlist)
92b3dd1e4129 [gaim-migrate @ 1556]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
277 yahoo_close(session, session->connlist->data);
92b3dd1e4129 [gaim-migrate @ 1556]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
278 if (session->cookie)
92b3dd1e4129 [gaim-migrate @ 1556]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
279 g_free(session->cookie);
92b3dd1e4129 [gaim-migrate @ 1556]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
280 session->cookie = NULL;
92b3dd1e4129 [gaim-migrate @ 1556]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
281 if (session->login_cookie)
92b3dd1e4129 [gaim-migrate @ 1556]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
282 g_free(session->login_cookie);
92b3dd1e4129 [gaim-migrate @ 1556]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
283 session->login_cookie = NULL;
92b3dd1e4129 [gaim-migrate @ 1556]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
284 while (session->ignored) {
92b3dd1e4129 [gaim-migrate @ 1556]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
285 g_free(session->ignored->data);
92b3dd1e4129 [gaim-migrate @ 1556]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
286 session->ignored = g_list_remove(session->ignored, session->ignored->data);
92b3dd1e4129 [gaim-migrate @ 1556]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
287 }
92b3dd1e4129 [gaim-migrate @ 1556]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
288 if (session->identities)
92b3dd1e4129 [gaim-migrate @ 1556]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
289 g_strfreev(session->identities);
92b3dd1e4129 [gaim-migrate @ 1556]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
290 session->identities = NULL;
92b3dd1e4129 [gaim-migrate @ 1556]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
291 if (session->login)
92b3dd1e4129 [gaim-migrate @ 1556]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
292 g_free(session->login);
92b3dd1e4129 [gaim-migrate @ 1556]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
293 session->login = NULL;
92b3dd1e4129 [gaim-migrate @ 1556]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
294 while (session->groups) {
92b3dd1e4129 [gaim-migrate @ 1556]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
295 struct yahoo_group *grp = session->groups->data;
92b3dd1e4129 [gaim-migrate @ 1556]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
296 g_strfreev(grp->buddies);
92b3dd1e4129 [gaim-migrate @ 1556]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
297 g_free(grp->name);
92b3dd1e4129 [gaim-migrate @ 1556]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
298 g_free(grp);
92b3dd1e4129 [gaim-migrate @ 1556]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
299 session->groups = g_list_remove(session->groups, grp);
92b3dd1e4129 [gaim-migrate @ 1556]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
300 }
2010
dff412b306b8 [gaim-migrate @ 2020]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1879
diff changeset
301 if (session->auth_host)
dff412b306b8 [gaim-migrate @ 2020]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1879
diff changeset
302 g_free(session->auth_host);
dff412b306b8 [gaim-migrate @ 2020]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1879
diff changeset
303 session->auth_host = NULL;
dff412b306b8 [gaim-migrate @ 2020]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1879
diff changeset
304 if (session->pager_host)
dff412b306b8 [gaim-migrate @ 2020]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1879
diff changeset
305 g_free(session->pager_host);
dff412b306b8 [gaim-migrate @ 2020]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1879
diff changeset
306 session->pager_host = NULL;
1546
92b3dd1e4129 [gaim-migrate @ 1556]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
307 return 0;
92b3dd1e4129 [gaim-migrate @ 1556]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
308 }
92b3dd1e4129 [gaim-migrate @ 1556]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
309
92b3dd1e4129 [gaim-migrate @ 1556]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
310 int yahoo_delete(struct yahoo_session *session)
92b3dd1e4129 [gaim-migrate @ 1556]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
311 {
92b3dd1e4129 [gaim-migrate @ 1556]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
312 if (!session)
92b3dd1e4129 [gaim-migrate @ 1556]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
313 return 0;
1565
2c66d386be90 [gaim-migrate @ 1575]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1546
diff changeset
314 if (session->proxy_host)
2c66d386be90 [gaim-migrate @ 1575]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1546
diff changeset
315 g_free(session->proxy_host);
1546
92b3dd1e4129 [gaim-migrate @ 1556]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
316 g_free(session);
92b3dd1e4129 [gaim-migrate @ 1556]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
317 return 0;
92b3dd1e4129 [gaim-migrate @ 1556]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
318 }