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