Mercurial > pidgin
changeset 10271:361c9170d8af
[gaim-migrate @ 11420]
This is a better way to do the aim logout thing. I don't know why
I did it the other way. That's a lie, I know why. It's because
I'm dumb.
committer: Tailor Script <tailor@pidgin.im>
author | Mark Doliner <mark@kingant.net> |
---|---|
date | Sat, 27 Nov 2004 16:09:31 +0000 |
parents | e5451763f5b9 |
children | bf1ebc8f3bf3 |
files | src/protocols/oscar/aim.h src/protocols/oscar/chat.c src/protocols/oscar/conn.c src/protocols/oscar/ft.c src/protocols/oscar/oscar.c src/protocols/oscar/rxqueue.c |
diffstat | 6 files changed, 42 insertions(+), 40 deletions(-) [+] |
line wrap: on
line diff
--- a/src/protocols/oscar/aim.h Sat Nov 27 16:06:27 2004 +0000 +++ b/src/protocols/oscar/aim.h Sat Nov 27 16:09:31 2004 +0000 @@ -567,7 +567,7 @@ faim_export aim_conn_t *aim_conn_findbygroup(aim_session_t *sess, fu16_t group); faim_export aim_session_t *aim_conn_getsess(aim_conn_t *conn); -faim_export void aim_conn_close(aim_session_t *sess, aim_conn_t *deadconn); +faim_export void aim_conn_close(aim_conn_t *deadconn); faim_export aim_conn_t *aim_newconn(aim_session_t *, int type, const char *dest); faim_export aim_conn_t *aim_select(aim_session_t *, struct timeval *, int *); faim_export int aim_conn_in_sess(aim_session_t *sess, aim_conn_t *conn);
--- a/src/protocols/oscar/chat.c Sat Nov 27 16:06:27 2004 +0000 +++ b/src/protocols/oscar/chat.c Sat Nov 27 16:09:31 2004 +0000 @@ -4,7 +4,7 @@ */ #define FAIM_INTERNAL -#include <aim.h> +#include <aim.h> #include <string.h> @@ -107,7 +107,7 @@ if (!(conn = aim_chat_getconn(sess, name))) return -ENOENT; - aim_conn_close(sess, conn); + aim_conn_close(conn); return 0; }
--- a/src/protocols/oscar/conn.c Sat Nov 27 16:06:27 2004 +0000 +++ b/src/protocols/oscar/conn.c Sat Nov 27 16:09:31 2004 +0000 @@ -159,7 +159,7 @@ aim_tx_cleanqueue(sess, *deadconn); if ((*deadconn)->fd != -1) - aim_conn_close(sess, *deadconn); + aim_conn_close(*deadconn); /* * XXX ->priv should never be touched by the library. I know @@ -191,6 +191,28 @@ } /** + * This sends an empty channel 4 SNAC. This is sent to signify + * that we're logging off. This shouldn't really be necessary-- + * usually the AIM server will detect that the TCP connection has + * been destroyed. + */ +static int +aim_flap_close(aim_session_t *sess, aim_conn_t *conn) +{ + aim_frame_t *fr; + + if (!sess || !conn) + return -EINVAL; + + if (!(fr = aim_tx_new(sess, conn, AIM_FRAMETYPE_FLAP, 0x04, 0))) + return -ENOMEM; + + aim_tx_enqueue(sess, fr); + + return 0; +} + +/** * Clears out the connection list, killing remaining connections. * * @param sess Session to be cleared. @@ -201,9 +223,13 @@ if (sess->connlist) { aim_conn_t *cur = sess->connlist, *tmp; + /* Attempt to send the log-off packet */ + if (cur->type == AIM_CONN_TYPE_BOS) + aim_flap_close(sess, cur); + while (cur) { tmp = cur->next; - aim_conn_close(sess, cur); + aim_conn_close(cur); connkill_real(sess, &cur); cur = tmp; } @@ -297,28 +323,6 @@ } /** - * This sends an empty channel 4 SNAC. This is sent to signify - * that we're logging off. This shouldn't really be necessary-- - * usually the AIM server will detect that the TCP connection has - * been destroyed. - */ -static int -aim_flap_close(aim_session_t *sess, aim_conn_t *conn) -{ - aim_frame_t *fr; - - if (!sess || !conn) - return -EINVAL; - - if (!(fr = aim_tx_new(sess, conn, AIM_FRAMETYPE_FLAP, 0x04, 0))) - return -ENOMEM; - - aim_tx_enqueue(sess, fr); - - return 0; -} - -/** * Close (but not free) a connection. * * This leaves everything untouched except for clearing the @@ -330,12 +334,10 @@ * * @param deadconn The connection to close. */ -faim_export void aim_conn_close(aim_session_t *sess, aim_conn_t *deadconn) +faim_export void aim_conn_close(aim_conn_t *deadconn) { aim_rxcallback_t userfunc; - aim_flap_close(sess, deadconn); - if (deadconn->fd >= 0) close(deadconn->fd);
--- a/src/protocols/oscar/ft.c Sat Nov 27 16:06:27 2004 +0000 +++ b/src/protocols/oscar/ft.c Sat Nov 27 16:09:31 2004 +0000 @@ -196,7 +196,7 @@ if ((addr.sa_family != PF_INET) && (addr.sa_family != PF_INET6)) { close(acceptfd); - aim_conn_close(sess, cur); + aim_conn_close(cur); return -1; } @@ -205,7 +205,7 @@ if (!(newconn = aim_cloneconn(sess, cur))) { close(acceptfd); - aim_conn_close(sess, cur); + aim_conn_close(cur); return -ENOMEM; } @@ -232,7 +232,7 @@ } else { faimdprintf(sess, 1,"Got a connection on a listener that's not rendezvous. Closing connection.\n"); - aim_conn_close(sess, newconn); + aim_conn_close(newconn); ret = -1; } @@ -932,7 +932,7 @@ } if (ret == -1) - aim_conn_close(sess, conn); + aim_conn_close(conn); return ret; }
--- a/src/protocols/oscar/oscar.c Sat Nov 27 16:06:27 2004 +0000 +++ b/src/protocols/oscar/oscar.c Sat Nov 27 16:09:31 2004 +0000 @@ -880,7 +880,7 @@ if (dim->watcher) gaim_input_remove(dim->watcher); if (dim->conn) { - aim_conn_close(od->sess, dim->conn); + aim_conn_close(dim->conn); aim_conn_kill(od->sess, &dim->conn); } g_free(dim); @@ -1100,7 +1100,7 @@ listenerconn = va_arg(ap, aim_conn_t *); va_end(ap); - aim_conn_close(sess, listenerconn); + aim_conn_close(listenerconn); aim_conn_kill(sess, &listenerconn); sn = g_strdup(aim_odc_getsn(newconn));
--- a/src/protocols/oscar/rxqueue.c Sat Nov 27 16:06:27 2004 +0000 +++ b/src/protocols/oscar/rxqueue.c Sat Nov 27 16:09:31 2004 +0000 @@ -102,7 +102,7 @@ */ aim_bstream_init(&hdr, hdr_raw, sizeof(hdr_raw)); if (aim_bstream_recv(&hdr, conn->fd, 6) < 6) { - aim_conn_close(sess, conn); + aim_conn_close(conn); return -1; } @@ -114,7 +114,7 @@ */ if (aimbs_get8(&hdr) != 0x2a) { faimdprintf(sess, 0, "Invalid FLAP frame received on FLAP connection!"); - aim_conn_close(sess, conn); + aim_conn_close(conn); return -1; } @@ -142,7 +142,7 @@ */ aim_bstream_init(&hdr, hdr_raw, sizeof(hdr_raw)); if (aim_bstream_recv(&hdr, conn->fd, 8) < 8) { - aim_conn_close(sess, conn); + aim_conn_close(conn); return -1; } @@ -212,7 +212,7 @@ /* read the payload */ if (aim_bstream_recv(&fr->data, conn->fd, payloadlen) < payloadlen) { aim_frame_destroy(fr); /* free's payload */ - aim_conn_close(sess, conn); + aim_conn_close(conn); return -1; } } else