Mercurial > pidgin.yaz
changeset 13254:e9802db22b06
[gaim-migrate @ 15620]
This is the way we clean the code, clean the code, clean the code
This is the way we clean the code, clean the code, clean the code
So early in the morning
committer: Tailor Script <tailor@pidgin.im>
author | Mark Doliner <mark@kingant.net> |
---|---|
date | Sun, 12 Feb 2006 22:14:38 +0000 |
parents | 87a7c3077c19 |
children | f280bf585fb3 |
files | src/protocols/oscar/Makefile.am src/protocols/oscar/Makefile.mingw src/protocols/oscar/conn.c src/protocols/oscar/family_bos.c src/protocols/oscar/family_chat.c src/protocols/oscar/misc.c src/protocols/oscar/oscar.c src/protocols/oscar/oscar.h src/protocols/oscar/peer.c src/protocols/oscar/rxhandlers.c src/protocols/oscar/rxqueue.c src/protocols/oscar/snactypes.h |
diffstat | 12 files changed, 134 insertions(+), 476 deletions(-) [+] |
line wrap: on
line diff
--- a/src/protocols/oscar/Makefile.am Sun Feb 12 21:27:04 2006 +0000 +++ b/src/protocols/oscar/Makefile.am Sun Feb 12 22:14:38 2006 +0000 @@ -37,6 +37,7 @@ peer.h \ rxhandlers.c \ rxqueue.c \ + session.c \ snac.c \ snactypes.h \ tlv.c \
--- a/src/protocols/oscar/Makefile.mingw Sun Feb 12 21:27:04 2006 +0000 +++ b/src/protocols/oscar/Makefile.mingw Sun Feb 12 22:14:38 2006 +0000 @@ -96,6 +96,7 @@ peer.c \ rxhandlers.c \ rxqueue.c \ + session.c \ snac.c \ tlv.c \ txqueue.c \
--- a/src/protocols/oscar/conn.c Sun Feb 12 21:27:04 2006 +0000 +++ b/src/protocols/oscar/conn.c Sun Feb 12 22:14:38 2006 +0000 @@ -110,17 +110,21 @@ OscarConnection * aim_conn_findbygroup(OscarSession *sess, guint16 group) { - OscarConnection *cur; + GList *cur;; - for (cur = sess->connlist; cur; cur = cur->next) + for (cur = sess->oscar_connections; cur; cur = cur->next) { - aim_conn_inside_t *ins = (aim_conn_inside_t *)cur->inside; + OscarConnection *conn; + aim_conn_inside_t *ins; struct snacgroup *sg; + conn = cur->data; + ins = (aim_conn_inside_t *)conn->inside; + for (sg = ins->groups; sg; sg = sg->next) { if (sg->group == group) - return cur; + return conn; } } @@ -167,15 +171,14 @@ } } -static void -connkill_real(OscarSession *sess, OscarConnection *conn) +void +oscar_connection_destroy(OscarSession *sess, OscarConnection *conn) { - aim_rxqueue_cleanbyconn(sess, conn); aim_tx_cleanqueue(sess, conn); if (conn->fd != -1) - aim_conn_close(conn); + aim_conn_close(sess, conn); /* * This will free ->internal if it necessary... @@ -194,7 +197,7 @@ } gaim_circ_buffer_destroy(conn->buffer_outgoing); - free(conn); + g_free(conn); } /** @@ -241,8 +244,7 @@ conn->forcedlatency = 0; conn->handlerlist = NULL; - conn->next = sess->connlist; - sess->connlist = conn; + sess->oscar_connections = g_list_prepend(sess->oscar_connections, conn); return conn; } @@ -255,25 +257,14 @@ * @param deadconn Connection to be freed. */ void -aim_conn_kill(OscarSession *sess, OscarConnection **deadconn) +aim_conn_kill(OscarSession *sess, OscarConnection *conn) { - OscarConnection *cur, **prev; - - if (!deadconn || !*deadconn) + if (!conn) return; - for (prev = &sess->connlist; (cur = *prev); ) { - if (cur == *deadconn) { - *prev = cur->next; - break; - } - prev = &cur->next; - } + sess->oscar_connections = g_list_remove(sess->oscar_connections, conn); - if (!cur) - return; /* oops */ - - connkill_real(sess, cur); + oscar_connection_destroy(sess, conn); } /** @@ -283,26 +274,21 @@ * handler list and setting the fd to -1 (used to recognize * dead connections). It will also remove cookies if necessary. * - * Why only if fd >= 3? Seems rather implementation specific... - * fd's do not have to be distributed in a particular order, do they? - * - * @param deadconn The connection to close. + * @param conn The connection to close. */ void -aim_conn_close(OscarConnection *deadconn) +aim_conn_close(OscarSession *sess, OscarConnection *conn) { - aim_rxcallback_t userfunc; - - if (deadconn->fd >= 0) - close(deadconn->fd); + if (conn->type == AIM_CONN_TYPE_BOS) + aim_flap_close(sess, conn); - deadconn->fd = -1; + if (conn->fd >= 0) + close(conn->fd); - if ((userfunc = aim_callhandler(deadconn->sessv, deadconn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_CONNDEAD))) - userfunc(deadconn->sessv, NULL, deadconn); + conn->fd = -1; - if (deadconn->handlerlist) - aim_clearhandlers(deadconn); + if (conn->handlerlist) + aim_clearhandlers(conn); } /** @@ -320,42 +306,33 @@ OscarConnection * aim_getconn_type(OscarSession *sess, int type) { - OscarConnection *cur; + GList *cur; - for (cur = sess->connlist; cur; cur = cur->next) { - if ((cur->type == type) && - !(cur->status & AIM_CONN_STATUS_INPROGRESS)) - break; + for (cur = sess->oscar_connections; cur; cur = cur->next) + { + OscarConnection *conn; + conn = cur->data; + if ((conn->type == type) && + !(conn->status & AIM_CONN_STATUS_INPROGRESS)) + return conn; } - return cur; + return NULL; } OscarConnection * aim_getconn_type_all(OscarSession *sess, int type) { - OscarConnection *cur; + GList *cur; - for (cur = sess->connlist; cur; cur = cur->next) { - if (cur->type == type) - break; + for (cur = sess->oscar_connections; cur; cur = cur->next) + { + OscarConnection *conn; + if (conn->type == type) + return conn; } - return cur; -} - -/* If you pass -1 for the fd, you'll get what you ask for. Gibberish. */ -OscarConnection * -aim_getconn_fd(OscarSession *sess, int fd) -{ - OscarConnection *cur; - - for (cur = sess->connlist; cur; cur = cur->next) { - if (cur->fd == fd) - break; - } - - return cur; + return NULL; } /** @@ -411,7 +388,7 @@ * @param type Type of connection to create */ OscarConnection * -aim_newconn(OscarSession *sess, int type) +oscar_connection_new(OscarSession *sess, int type) { OscarConnection *conn; @@ -427,25 +404,6 @@ } /** - * Searches @sess for the passed connection. - * - * @param sess Session in which to look. - * @param conn Connection to look for. - * @return Returns 1 if the passed connection is present, zero otherwise. - */ -faim_export int aim_conn_in_sess(OscarSession *sess, OscarConnection *conn) -{ - OscarConnection *cur; - - for (cur = sess->connlist; cur; cur = cur->next) { - if (cur == conn) - return 1; - } - - return 0; -} - -/** * Set a forced latency value for connection. Basically causes * @newval seconds to be spent between transmits on a connection. * @@ -473,107 +431,6 @@ } /** - * Allocates a new OscarSession and initializes it with default values. - */ -OscarSession * -oscar_session_new(void) -{ - OscarSession *sess; - - sess = g_new(OscarSession, 1); - - sess->queue_outgoing = NULL; - sess->queue_incoming = NULL; - aim_initsnachash(sess); - sess->msgcookies = NULL; - sess->modlistv = NULL; - sess->snacid_next = 0x00000001; - - sess->locate.userinfo = NULL; - sess->locate.torequest = NULL; - sess->locate.requested = NULL; - sess->locate.waiting_for_response = FALSE; - sess->ssi.received_data = 0; - sess->ssi.numitems = 0; - sess->ssi.official = NULL; - sess->ssi.local = NULL; - sess->ssi.pending = NULL; - sess->ssi.timestamp = (time_t)0; - sess->ssi.waiting_for_ack = 0; - sess->icq_info = NULL; - sess->authinfo = NULL; - sess->emailinfo = NULL; - sess->peer_connections = NULL; - - /* - * This must always be set. Default to the queue-based - * version for back-compatibility. - */ - aim_tx_setenqueue(sess, AIM_TX_QUEUED, NULL); - - /* - * Register all the modules for this session... - */ - aim__registermodule(sess, misc_modfirst); /* load the catch-all first */ - aim__registermodule(sess, service_modfirst); - aim__registermodule(sess, locate_modfirst); - aim__registermodule(sess, buddylist_modfirst); - aim__registermodule(sess, msg_modfirst); - aim__registermodule(sess, adverts_modfirst); - aim__registermodule(sess, invite_modfirst); - aim__registermodule(sess, admin_modfirst); - aim__registermodule(sess, popups_modfirst); - aim__registermodule(sess, bos_modfirst); - aim__registermodule(sess, search_modfirst); - aim__registermodule(sess, stats_modfirst); - aim__registermodule(sess, translate_modfirst); - aim__registermodule(sess, chatnav_modfirst); - aim__registermodule(sess, chat_modfirst); - aim__registermodule(sess, odir_modfirst); - aim__registermodule(sess, bart_modfirst); - /* missing 0x11 - 0x12 */ - aim__registermodule(sess, ssi_modfirst); - /* missing 0x14 */ - aim__registermodule(sess, icq_modfirst); /* XXX - Make sure this isn't sent for AIM */ - /* missing 0x16 */ - aim__registermodule(sess, auth_modfirst); - aim__registermodule(sess, email_modfirst); - - return sess; -} - -/** - * Logoff and deallocate a session. - * - * @param sess Session to kill - */ -void -oscar_session_destroy(OscarSession *sess) -{ - aim_cleansnacs(sess, -1); - - if (sess->connlist) { - OscarConnection *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(cur); - connkill_real(sess, cur); - cur = tmp; - } - } - sess->connlist = NULL; - - aim__shutdownmodules(sess); - - g_free(sess); -} - -/** * Determine if a connection is connecting. * * @param conn Connection to examine. @@ -597,8 +454,6 @@ int aim_conn_completeconnect(OscarSession *sess, OscarConnection *conn) { - aim_rxcallback_t userfunc; - if (!conn || (conn->fd == -1)) return -1; @@ -609,9 +464,6 @@ conn->status &= ~AIM_CONN_STATUS_INPROGRESS; - if ((userfunc = aim_callhandler(sess, conn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_CONNCOMPLETE))) - userfunc(sess, NULL, conn); - /* Flush out the queues if there was something waiting for this conn */ aim_tx_flushqueue(sess);
--- a/src/protocols/oscar/family_bos.c Sun Feb 12 21:27:04 2006 +0000 +++ b/src/protocols/oscar/family_bos.c Sun Feb 12 22:14:38 2006 +0000 @@ -1,186 +0,0 @@ -/* - * Gaim's oscar protocol plugin - * This file is the legal property of its developers. - * Please see the AUTHORS file distributed alongside this file. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -*/ - -/* - * Family 0x0009 - Basic Oscar Service. - * - * The functionality of this family has been replaced by SSI. - */ - -#include "oscar.h" - -#include <string.h> - -/* Subtype 0x0002 - Request BOS rights. */ -faim_export int aim_bos_reqrights(OscarSession *sess, OscarConnection *conn) -{ - return aim_genericreq_n_snacid(sess, conn, 0x0009, 0x0002); -} - -/* Subtype 0x0003 - BOS Rights. */ -static int rights(OscarSession *sess, aim_module_t *mod, FlapFrame *rx, aim_modsnac_t *snac, ByteStream *bs) -{ - aim_rxcallback_t userfunc; - aim_tlvlist_t *tlvlist; - guint16 maxpermits = 0, maxdenies = 0; - int ret = 0; - - /* - * TLVs follow - */ - tlvlist = aim_tlvlist_read(bs); - - /* - * TLV type 0x0001: Maximum number of buddies on permit list. - */ - if (aim_tlv_gettlv(tlvlist, 0x0001, 1)) - maxpermits = aim_tlv_get16(tlvlist, 0x0001, 1); - - /* - * TLV type 0x0002: Maximum number of buddies on deny list. - */ - if (aim_tlv_gettlv(tlvlist, 0x0002, 1)) - maxdenies = aim_tlv_get16(tlvlist, 0x0002, 1); - - if ((userfunc = aim_callhandler(sess, rx->conn, snac->family, snac->subtype))) - ret = userfunc(sess, rx, maxpermits, maxdenies); - - aim_tlvlist_free(&tlvlist); - - return ret; -} - -/* - * Subtype 0x0004 - Set group permission mask. - * - * Normally 0x1f (all classes). - * - * The group permission mask allows you to keep users of a certain - * class or classes from talking to you. The mask should be - * a bitwise OR of all the user classes you want to see you. - * - */ -faim_export int aim_bos_setgroupperm(OscarSession *sess, OscarConnection *conn, guint32 mask) -{ - return aim_genericreq_l(sess, conn, 0x0009, 0x0004, &mask); -} - -/* - * Stubtypes 0x0005, 0x0006, 0x0007, and 0x0008 - Modify permit/deny lists. - * - * Changes your visibility depending on changetype: - * - * AIM_VISIBILITYCHANGE_PERMITADD: Lets provided list of names see you - * AIM_VISIBILITYCHANGE_PERMIDREMOVE: Removes listed names from permit list - * AIM_VISIBILITYCHANGE_DENYADD: Hides you from provided list of names - * AIM_VISIBILITYCHANGE_DENYREMOVE: Lets list see you again - * - * list should be a list of - * screen names in the form "Screen Name One&ScreenNameTwo&" etc. - * - * Equivelents to options in WinAIM: - * - Allow all users to contact me: Send an AIM_VISIBILITYCHANGE_DENYADD - * with only your name on it. - * - Allow only users on my Buddy List: Send an - * AIM_VISIBILITYCHANGE_PERMITADD with the list the same as your - * buddy list - * - Allow only the uesrs below: Send an AIM_VISIBILITYCHANGE_PERMITADD - * with everyone listed that you want to see you. - * - Block all users: Send an AIM_VISIBILITYCHANGE_PERMITADD with only - * yourself in the list - * - Block the users below: Send an AIM_VISIBILITYCHANGE_DENYADD with - * the list of users to be blocked - * - * XXX ye gods. - */ -faim_export int aim_bos_changevisibility(OscarSession *sess, OscarConnection *conn, int changetype, const char *denylist) -{ - FlapFrame *fr; - int packlen = 0; - guint16 subtype; - char *localcpy = NULL, *tmpptr = NULL; - int i; - int listcount; - aim_snacid_t snacid; - - if (!denylist) - return -EINVAL; - - if (changetype == AIM_VISIBILITYCHANGE_PERMITADD) - subtype = 0x05; - else if (changetype == AIM_VISIBILITYCHANGE_PERMITREMOVE) - subtype = 0x06; - else if (changetype == AIM_VISIBILITYCHANGE_DENYADD) - subtype = 0x07; - else if (changetype == AIM_VISIBILITYCHANGE_DENYREMOVE) - subtype = 0x08; - else - return -EINVAL; - - localcpy = strdup(denylist); - - listcount = aimutil_itemcnt(localcpy, '&'); - packlen = aimutil_tokslen(localcpy, 99, '&') + listcount + 9; - - if (!(fr = flap_frame_new(sess, conn, AIM_FRAMETYPE_FLAP, 0x02, packlen))) { - free(localcpy); - return -ENOMEM; - } - - snacid = aim_cachesnac(sess, 0x0009, subtype, 0x0000, NULL, 0); - aim_putsnac(&fr->data, 0x0009, subtype, 0x00, snacid); - - for (i = 0; (i < (listcount - 1)) && (i < 99); i++) { - tmpptr = aimutil_itemindex(localcpy, i, '&'); - - aimbs_put8(&fr->data, strlen(tmpptr)); - aimbs_putstr(&fr->data, tmpptr); - - free(tmpptr); - } - free(localcpy); - - aim_tx_enqueue(sess, fr); - - return 0; -} - -static int snachandler(OscarSession *sess, aim_module_t *mod, FlapFrame *rx, aim_modsnac_t *snac, ByteStream *bs) -{ - - if (snac->subtype == 0x0003) - return rights(sess, mod, rx, snac, bs); - - return 0; -} - -faim_internal int bos_modfirst(OscarSession *sess, aim_module_t *mod) -{ - - mod->family = 0x0009; - mod->version = 0x0001; - mod->toolid = 0x0110; - mod->toolversion = 0x0629; - mod->flags = 0; - strncpy(mod->name, "bos", sizeof(mod->name)); - mod->snachandler = snachandler; - - return 0; -}
--- a/src/protocols/oscar/family_chat.c Sun Feb 12 21:27:04 2006 +0000 +++ b/src/protocols/oscar/family_chat.c Sun Feb 12 22:14:38 2006 +0000 @@ -63,23 +63,28 @@ /* XXX get this into conn.c -- evil!! */ faim_export OscarConnection *aim_chat_getconn(OscarSession *sess, const char *name) { - OscarConnection *cur; + GList *cur; - for (cur = sess->connlist; cur; cur = cur->next) { - struct chatconnpriv *ccp = (struct chatconnpriv *)cur->internal; + for (cur = sess->oscar_connections; cur; cur = cur->next) + { + OscarConnection *conn; + struct chatconnpriv *ccp; - if (cur->type != AIM_CONN_TYPE_CHAT) + conn = cur->data; + ccp = (struct chatconnpriv *)conn->internal; + + if (conn->type != AIM_CONN_TYPE_CHAT) continue; - if (!cur->internal) { - gaim_debug_misc("oscar", "faim: chat: chat connection with no name! (fd = %d)\n", cur->fd); + if (!conn->internal) { + gaim_debug_misc("oscar", "faim: chat: chat connection with no name! (fd = %d)\n", conn->fd); continue; } if (strcmp(ccp->name, name) == 0) - break; + return conn;; } - return cur; + return NULL; } faim_export int aim_chat_attachname(OscarConnection *conn, guint16 exchange, const char *roomname, guint16 instance) @@ -126,7 +131,7 @@ if (!(conn = aim_chat_getconn(sess, name))) return -ENOENT; - aim_conn_close(conn); + aim_conn_close(sess, conn); return 0; }
--- a/src/protocols/oscar/misc.c Sun Feb 12 21:27:04 2006 +0000 +++ b/src/protocols/oscar/misc.c Sun Feb 12 22:14:38 2006 +0000 @@ -79,7 +79,7 @@ return aim_genericreq_n(sess, conn, family, subtype); if (!(fr = flap_frame_new(sess, conn, AIM_FRAMETYPE_FLAP, 0x02, 10+4))) - return -ENOMEM; + return -ENOMEM; snacid = aim_cachesnac(sess, family, subtype, 0x0000, NULL, 0); @@ -100,7 +100,7 @@ return aim_genericreq_n(sess, conn, family, subtype); if (!(fr = flap_frame_new(sess, conn, AIM_FRAMETYPE_FLAP, 0x02, 10+2))) - return -ENOMEM; + return -ENOMEM; snacid = aim_cachesnac(sess, family, subtype, 0x0000, NULL, 0);
--- a/src/protocols/oscar/oscar.c Sun Feb 12 21:27:04 2006 +0000 +++ b/src/protocols/oscar/oscar.c Sun Feb 12 22:14:38 2006 +0000 @@ -916,7 +916,7 @@ od->oscar_chats = g_slist_remove(od->oscar_chats, cc); if (cc->inpa > 0) gaim_input_remove(cc->inpa); - aim_conn_kill(od->sess, &cc->conn); + aim_conn_kill(od->sess, cc->conn); g_free(cc->name); g_free(cc->show); g_free(cc); @@ -953,8 +953,8 @@ if (dim->watcher) gaim_input_remove(dim->watcher); if (dim->conn) { - aim_conn_close(dim->conn); - aim_conn_kill(od->sess, &dim->conn); + aim_conn_close(od->sess, dim->conn); + aim_conn_kill(od->sess, dim->conn); } g_free(dim); } @@ -1176,8 +1176,8 @@ listenerconn = va_arg(ap, OscarConnection *); va_end(ap); - aim_conn_close(listenerconn); - aim_conn_kill(sess, &listenerconn); + aim_conn_close(sess, listenerconn); + aim_conn_kill(sess, listenerconn); sn = g_strdup(aim_odc_getsn(newconn)); @@ -1694,7 +1694,7 @@ if (aim_handlerendconnect(od->sess, conn) < 0) { gaim_debug_error("oscar", "connection error (rendezvous listener)\n"); - aim_conn_kill(od->sess, &conn); + aim_conn_kill(od->sess, conn); /* AAA - Don't we need to gaim_xfer_cancel here? --marv */ } } else { @@ -1745,38 +1745,38 @@ NULL); } gaim_debug_info("oscar","killing rendezvous connection\n"); - aim_conn_kill(od->sess, &conn); + aim_conn_kill(od->sess, conn); } else if (conn->type == AIM_CONN_TYPE_AUTH) { if (od->paspa > 0) gaim_input_remove(od->paspa); od->paspa = 0; gaim_debug_info("oscar", "removing authconn input watcher\n"); - aim_conn_kill(od->sess, &conn); + aim_conn_kill(od->sess, conn); } else if (conn->type == AIM_CONN_TYPE_EMAIL) { if (od->emlpa > 0) gaim_input_remove(od->emlpa); od->emlpa = 0; gaim_debug_info("oscar", "removing email input watcher\n"); - aim_conn_kill(od->sess, &conn); + aim_conn_kill(od->sess, conn); } else if (conn->type == AIM_CONN_TYPE_ICON) { if (od->icopa > 0) gaim_input_remove(od->icopa); od->icopa = 0; gaim_debug_info("oscar", "removing icon input watcher\n"); - aim_conn_kill(od->sess, &conn); + aim_conn_kill(od->sess, conn); } else if (conn->type == AIM_CONN_TYPE_RENDEZVOUS) { if (conn->subtype == AIM_CONN_SUBTYPE_OFT_DIRECTIM) gaim_odc_disconnect(od->sess, conn); gaim_debug_info("oscar","killing rendezvous connection\n"); - aim_conn_kill(od->sess, &conn); + aim_conn_kill(od->sess, conn); } else { gaim_debug_error("oscar", "holy crap! generic connection error! %hu\n", conn->type); - aim_conn_kill(od->sess, &conn); + aim_conn_kill(od->sess, conn); } } } @@ -1854,7 +1854,7 @@ /* Connect to core Gaim signals */ gaim_prefs_connect_callback(gc, "/plugins/prpl/oscar/recent_buddies", recent_buddies_cb, gc); - conn = aim_newconn(sess, AIM_CONN_TYPE_AUTH); + conn = oscar_connection_new(sess, AIM_CONN_TYPE_AUTH); if (conn == NULL) { gaim_debug_error("oscar", "internal connection error\n"); gaim_connection_error(gc, _("Unable to login to AIM")); @@ -2072,7 +2072,7 @@ aim_oft_sendheader(peer_connection->sess, PEER_TYPE_DONE, peer_connection); } - aim_conn_kill(peer_connection->sess, &peer_connection->conn); + aim_conn_kill(peer_connection->sess, peer_connection->conn); aim_oft_destroyinfo(peer_connection); xfer->data = NULL; od->file_transfers = g_slist_remove(od->file_transfers, xfer); @@ -2108,7 +2108,7 @@ /* This connection has worn out its welcome. Goodbye. */ if(peer_connection->conn) { close(peer_connection->conn->fd); - aim_conn_kill(peer_connection->sess, &peer_connection->conn); + aim_conn_kill(peer_connection->sess, peer_connection->conn); } if(peer_connection->method == AIM_XFER_DIRECT || peer_connection->method == AIM_XFER_REDIR) { @@ -2150,7 +2150,7 @@ /* Kill our listener */ gaim_input_remove(xfer->watcher); - aim_conn_kill(peer_connection->sess, &peer_connection->conn); + aim_conn_kill(peer_connection->sess, peer_connection->conn); /* Instead of failing here, request a stage 3 proxy */ g_free(peer_connection->clientip); @@ -2247,7 +2247,7 @@ } else { gaim_timeout_add(FT_PROXYIP_TIMEOUT, oscar_xfer_ip_timeout, xfer); } - peer_connection->conn = aim_newconn(od->sess, AIM_CONN_TYPE_RENDEZVOUS); + peer_connection->conn = oscar_connection_new(od->sess, AIM_CONN_TYPE_RENDEZVOUS); /* If we're routing this transfer through a AOL proxy server, do the special login * before telling the other client we're ready for action. @@ -2299,7 +2299,7 @@ if (gaim_xfer_get_status(xfer) != GAIM_XFER_STATUS_CANCEL_REMOTE) aim_im_sendch2_sendfile_cancel(peer_connection->sess, peer_connection); - aim_conn_kill(peer_connection->sess, &peer_connection->conn); + aim_conn_kill(peer_connection->sess, peer_connection->conn); aim_oft_destroyinfo(peer_connection); xfer->data = NULL; od->file_transfers = g_slist_remove(od->file_transfers, xfer); @@ -2685,7 +2685,7 @@ /* Added a few sanity checks to prevent segfaulting */ if(peer_connection) { if(peer_connection->sess && peer_connection->conn) - aim_conn_kill(peer_connection->sess, &peer_connection->conn); + aim_conn_kill(peer_connection->sess, peer_connection->conn); aim_oft_destroyinfo(peer_connection); } xfer->data = NULL; @@ -2884,9 +2884,9 @@ gaim_debug_misc("oscar", "BOSIP: %s\n", info->bosip); gaim_debug_info("oscar", "Closing auth connection...\n"); - aim_conn_kill(sess, &fr->conn); - - bosconn = aim_newconn(sess, AIM_CONN_TYPE_BOS); + aim_conn_kill(sess, fr->conn); + + bosconn = oscar_connection_new(sess, AIM_CONN_TYPE_BOS); if (bosconn == NULL) { gaim_connection_error(gc, _("Internal Error")); od->killme = TRUE; @@ -2896,7 +2896,6 @@ aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_CONNERR, gaim_connerr, 0); aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_CONNINITDONE, conninitdone_bos, 0); aim_conn_addhandler(sess, bosconn, 0x0009, 0x0003, gaim_bosrights, 0); - aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_ACK, AIM_CB_ACK_ACK, NULL, 0); aim_conn_addhandler(sess, bosconn, OSCAR_FAMILY_OSERVICE, OSCAR_SUBTYPE_OSERVICE_REDIRECT, gaim_handle_redirect, 0); aim_conn_addhandler(sess, bosconn, OSCAR_FAMILY_LOCATE, OSCAR_SUBTYPE_LOCATE_RIGHTSINFO, gaim_parse_locaterights, 0); aim_conn_addhandler(sess, bosconn, OSCAR_FAMILY_BUDDY, OSCAR_SUBTYPE_BUDDY_RIGHTSINFO, gaim_parse_buddyrights, 0); @@ -3269,7 +3268,7 @@ tstconn->fd = source; if (source < 0) { - aim_conn_kill(sess, &tstconn); + aim_conn_kill(sess, tstconn); gaim_debug_error("oscar", "unable to connect to chatnav server\n"); return; } @@ -3300,7 +3299,7 @@ tstconn->fd = source; if (source < 0) { - aim_conn_kill(sess, &tstconn); + aim_conn_kill(sess, tstconn); gaim_debug_error("oscar", "unable to connect to authorizer\n"); return; } @@ -3335,7 +3334,7 @@ tstconn->fd = source; if (source < 0) { - aim_conn_kill(sess, &tstconn); + aim_conn_kill(sess, tstconn); g_free(ccon->show); g_free(ccon->name); g_free(ccon); @@ -3367,7 +3366,7 @@ tstconn->fd = source; if (source < 0) { - aim_conn_kill(sess, &tstconn); + aim_conn_kill(sess, tstconn); gaim_debug_error("oscar", "unable to connect to email server\n"); return; } @@ -3397,7 +3396,7 @@ tstconn->fd = source; if (source < 0) { - aim_conn_kill(sess, &tstconn); + aim_conn_kill(sess, tstconn); gaim_debug_error("oscar", "unable to connect to icon server\n"); return; } @@ -3438,7 +3437,7 @@ switch(redir->group) { case 0x7: /* Authorizer */ gaim_debug_info("oscar", "Reconnecting with authorizor...\n"); - tstconn = aim_newconn(sess, AIM_CONN_TYPE_AUTH); + tstconn = oscar_connection_new(sess, AIM_CONN_TYPE_AUTH); if (tstconn == NULL) { gaim_debug_error("oscar", "unable to reconnect with authorizer\n"); @@ -3450,7 +3449,7 @@ tstconn->status |= AIM_CONN_STATUS_INPROGRESS; if (gaim_proxy_connect(account, host, port, oscar_auth_connect, gc) != 0) { - aim_conn_kill(sess, &tstconn); + aim_conn_kill(sess, tstconn); gaim_debug_error("oscar", "unable to reconnect with authorizer\n"); g_free(host); @@ -3460,7 +3459,7 @@ break; case 0xd: /* ChatNav */ - tstconn = aim_newconn(sess, AIM_CONN_TYPE_CHATNAV); + tstconn = oscar_connection_new(sess, AIM_CONN_TYPE_CHATNAV); if (tstconn == NULL) { gaim_debug_error("oscar", "unable to connect to chatnav server\n"); @@ -3472,7 +3471,7 @@ tstconn->status |= AIM_CONN_STATUS_INPROGRESS; if (gaim_proxy_connect(account, host, port, oscar_chatnav_connect, gc) != 0) { - aim_conn_kill(sess, &tstconn); + aim_conn_kill(sess, tstconn); gaim_debug_error("oscar", "unable to connect to chatnav server\n"); g_free(host); @@ -3484,7 +3483,7 @@ case 0xe: { /* Chat */ struct chat_connection *ccon; - tstconn = aim_newconn(sess, AIM_CONN_TYPE_CHAT); + tstconn = oscar_connection_new(sess, AIM_CONN_TYPE_CHAT); if (tstconn == NULL) { gaim_debug_error("oscar", "unable to connect to chat server\n"); @@ -3505,7 +3504,7 @@ ccon->conn->status |= AIM_CONN_STATUS_INPROGRESS; if (gaim_proxy_connect(account, host, port, oscar_chat_connect, ccon) != 0) { - aim_conn_kill(sess, &tstconn); + aim_conn_kill(sess, tstconn); gaim_debug_error("oscar", "unable to connect to chat server\n"); g_free(host); @@ -3521,7 +3520,7 @@ } break; case 0x0010: { /* icon */ - if (!(tstconn = aim_newconn(sess, AIM_CONN_TYPE_ICON))) { + if (!(tstconn = oscar_connection_new(sess, AIM_CONN_TYPE_ICON))) { gaim_debug_error("oscar", "unable to connect to icon server\n"); g_free(host); @@ -3532,7 +3531,7 @@ tstconn->status |= AIM_CONN_STATUS_INPROGRESS; if (gaim_proxy_connect(account, host, port, oscar_icon_connect, gc) != 0) { - aim_conn_kill(sess, &tstconn); + aim_conn_kill(sess, tstconn); gaim_debug_error("oscar", "unable to connect to icon server\n"); g_free(host); @@ -3542,7 +3541,7 @@ } break; case 0x0018: { /* email */ - if (!(tstconn = aim_newconn(sess, AIM_CONN_TYPE_EMAIL))) { + if (!(tstconn = oscar_connection_new(sess, AIM_CONN_TYPE_EMAIL))) { gaim_debug_error("oscar", "unable to connect to email server\n"); g_free(host); @@ -3553,7 +3552,7 @@ tstconn->status |= AIM_CONN_STATUS_INPROGRESS; if (gaim_proxy_connect(account, host, port, oscar_email_connect, gc) != 0) { - aim_conn_kill(sess, &tstconn); + aim_conn_kill(sess, tstconn); gaim_debug_error("oscar", "unable to connect to email server\n"); g_free(host); @@ -3802,7 +3801,7 @@ /* Stop watching listener conn; watch transfer conn instead */ gaim_input_remove(xfer->watcher); - aim_conn_kill(sess, &listenerconn); + aim_conn_kill(sess, listenerconn); peer_connection->conn = conn; xfer->fd = peer_connection->conn->fd; @@ -4327,7 +4326,7 @@ /* Stop the listener connection */ gaim_input_remove(xfer->watcher); - aim_conn_kill(sess, &peer_connection->conn); /* This is currently the listener */ + aim_conn_kill(sess, peer_connection->conn); /* This is currently the listener */ if(args->info.sendfile.use_proxy) { gaim_debug_info("oscar",
--- a/src/protocols/oscar/oscar.h Sun Feb 12 21:27:04 2006 +0000 +++ b/src/protocols/oscar/oscar.h Sun Feb 12 22:14:38 2006 +0000 @@ -479,9 +479,6 @@ /* ---- Internal Use Only ------------------------ */ - /* Connection information */ - OscarConnection *connlist; - /* * Transmit/receive queues. * @@ -542,6 +539,9 @@ int waiting_for_ack; } ssi; + /** A linked list containing OscarConnections. */ + GList *oscar_connections; + /** A linked list containing PeerConnections. */ GList *peer_connections; }; @@ -578,8 +578,7 @@ faim_export int aim_debugconn_sendconnect(OscarSession *sess, OscarConnection *conn); -/* the library should never call aim_conn_kill */ -faim_export void aim_conn_kill(OscarSession *sess, OscarConnection **deadconn); +void aim_conn_kill(OscarSession *sess, OscarConnection *deadconn); typedef int (*aim_rxcallback_t)(OscarSession *, FlapFrame *, ...); @@ -645,9 +644,9 @@ faim_export OscarConnection *aim_conn_findbygroup(OscarSession *sess, guint16 group); faim_export OscarSession *aim_conn_getsess(OscarConnection *conn); -faim_export void aim_conn_close(OscarConnection *deadconn); -faim_export OscarConnection *aim_newconn(OscarSession *, int type); -faim_export int aim_conn_in_sess(OscarSession *sess, OscarConnection *conn); +void oscar_connection_destroy(OscarSession *sess, OscarConnection *conn); +faim_export void aim_conn_close(OscarSession *sess, OscarConnection *conn); +faim_export OscarConnection *oscar_connection_new(OscarSession *, int type); faim_export int aim_conn_isready(OscarConnection *); faim_export int aim_conn_setstatus(OscarConnection *, int); faim_export int aim_conn_completeconnect(OscarSession *sess, OscarConnection *conn); @@ -658,7 +657,6 @@ faim_export OscarConnection *aim_getconn_type(OscarSession *, int type); faim_export OscarConnection *aim_getconn_type_all(OscarSession *, int type); -faim_export OscarConnection *aim_getconn_fd(OscarSession *, int fd); /* 0x0001 - family_oservice.c */ faim_export int aim_srv_setstatusmsg(OscarSession *sess, const char *msg);
--- a/src/protocols/oscar/peer.c Sun Feb 12 21:27:04 2006 +0000 +++ b/src/protocols/oscar/peer.c Sun Feb 12 22:14:38 2006 +0000 @@ -221,7 +221,7 @@ if ((addr.sa_family != PF_INET) && (addr.sa_family != PF_INET6)) { close(acceptfd); - aim_conn_close(cur); + aim_conn_close(sess, cur); return -1; } @@ -230,7 +230,7 @@ if (!(newconn = aim_cloneconn(sess, cur))) { close(acceptfd); - aim_conn_close(cur); + aim_conn_close(sess, cur); return -ENOMEM; } @@ -257,7 +257,7 @@ } else { gaim_debug_warning("oscar", "Got a connection on a listener that's not rendezvous. Closing connection.\n"); - aim_conn_close(newconn); + aim_conn_close(sess, newconn); ret = -1; } @@ -481,17 +481,20 @@ OscarConnection * aim_odc_getconn(OscarSession *sess, const char *sn) { - OscarConnection *cur; + GList *cur; struct aim_odc_intdata *intdata; if (!sess || !sn || !strlen(sn)) return NULL; - for (cur = sess->connlist; cur; cur = cur->next) { - if ((cur->type == AIM_CONN_TYPE_RENDEZVOUS) && (cur->subtype == AIM_CONN_SUBTYPE_OFT_DIRECTIM)) { - intdata = cur->internal; + for (cur = sess->oscar_connections; cur; cur = cur->next) + { + OscarConnection *conn; + conn = cur->data; + if ((conn->type == AIM_CONN_TYPE_RENDEZVOUS) && (conn->subtype == AIM_CONN_SUBTYPE_OFT_DIRECTIM)) { + intdata = conn->internal; if (!aim_sncmp(intdata->sn, sn)) - return cur; + return conn; } } @@ -541,7 +544,7 @@ aim_cachecookie(sess, cookie); /* XXX - switch to aim_cloneconn()? */ - if (!(newconn = aim_newconn(sess, AIM_CONN_TYPE_LISTENER))) { + if (!(newconn = oscar_connection_new(sess, AIM_CONN_TYPE_LISTENER))) { close(listenfd); return NULL; } @@ -563,7 +566,7 @@ /** * Connect directly to the given buddy for directim. * - * This is a wrapper for aim_newconn. + * This is a wrapper for oscar_connection_new. * * If addr is NULL, the socket is not created, but the connection is * allocated and setup to connect. @@ -590,7 +593,7 @@ strncpy(intdata->ip, addr, sizeof(intdata->ip)); /* XXX - verify that non-blocking connects actually work */ - if (!(newconn = aim_newconn(sess, AIM_CONN_TYPE_RENDEZVOUS))) { + if (!(newconn = oscar_connection_new(sess, AIM_CONN_TYPE_RENDEZVOUS))) { free(intdata); return NULL; } @@ -804,7 +807,7 @@ if (!peer_connection) return -EINVAL; - if (!(peer_connection->conn = aim_newconn(sess, AIM_CONN_TYPE_LISTENER))) { + if (!(peer_connection->conn = oscar_connection_new(sess, AIM_CONN_TYPE_LISTENER))) { close(listenfd); return -ENOMEM; } @@ -1137,7 +1140,7 @@ } if (ret == -1) - aim_conn_close(conn); + aim_conn_close(sess, conn); return ret; } @@ -1190,7 +1193,7 @@ proxy_info->err_code = aimbs_get16(&bs_body); } else { gaim_debug_warning("oscar","error reading rv proxy error packet\n"); - aim_conn_close(conn); + aim_conn_close(sess, conn); free(proxy_info); proxy_info = NULL; } @@ -1216,7 +1219,7 @@ proxy_info->ip = strdup(str_ip); } else { gaim_debug_warning("oscar","error reading rv proxy error packet\n"); - aim_conn_close(conn); + aim_conn_close(sess, conn); free(proxy_info); proxy_info = NULL; } @@ -1230,7 +1233,7 @@ } } else { gaim_debug_warning("oscar","error reading header of rv proxy packet\n"); - aim_conn_close(conn); + aim_conn_close(sess, conn); free(proxy_info); proxy_info = NULL; }
--- a/src/protocols/oscar/rxhandlers.c Sun Feb 12 21:27:04 2006 +0000 +++ b/src/protocols/oscar/rxhandlers.c Sun Feb 12 22:14:38 2006 +0000 @@ -475,14 +475,7 @@ return cur->handler; } - if (type == AIM_CB_SPECIAL_DEFAULT) { - /* gaim_debug_misc("oscar", "aim_callhandler: no default handler for family 0x%04x\n", family); */ - return NULL; /* prevent infinite recursion */ - } - - /* gaim_debug_misc("oscar", "aim_callhandler: no handler for 0x%04x/0x%04x\n", family, type); */ - - return aim_callhandler(sess, conn, family, AIM_CB_SPECIAL_DEFAULT); + return NULL; } faim_internal void aim_clonehandlers(OscarSession *sess, OscarConnection *dest, OscarConnection *src) @@ -490,7 +483,7 @@ struct aim_rxcblist_s *cur; for (cur = (struct aim_rxcblist_s *)src->handlerlist; cur; cur = cur->next) { - aim_conn_addhandler(sess, dest, cur->family, cur->type, + aim_conn_addhandler(sess, dest, cur->family, cur->type, cur->handler, cur->flags); }
--- a/src/protocols/oscar/rxqueue.c Sun Feb 12 21:27:04 2006 +0000 +++ b/src/protocols/oscar/rxqueue.c Sun Feb 12 22:14:38 2006 +0000 @@ -121,7 +121,7 @@ */ aim_bstream_init(&hdr, hdr_raw, sizeof(hdr_raw)); if (aim_bstream_recv(&hdr, conn->fd, 6) < 6) { - aim_conn_close(conn); + aim_conn_close(sess, conn); return -1; } @@ -133,7 +133,7 @@ */ if (aimbs_get8(&hdr) != 0x2a) { gaim_debug_misc("oscar", "Invalid FLAP frame received on FLAP connection!"); - aim_conn_close(conn); + aim_conn_close(sess, conn); return -1; } @@ -144,7 +144,7 @@ } /* - * Read a rendezvous header from conn into fr, and return the number of + * Read a rendezvous header from conn into fr, and return the number of * bytes in the payload. * * @return -1 on error, otherwise return the length of the payload. @@ -161,7 +161,7 @@ */ aim_bstream_init(&hdr, hdr_raw, sizeof(hdr_raw)); if (aim_bstream_recv(&hdr, conn->fd, 8) < 8) { - aim_conn_close(conn); + aim_conn_close(sess, conn); return -1; } @@ -205,7 +205,7 @@ return -ENOMEM; /* - * Rendezvous (client to client) connections do not speak FLAP, so this + * Rendezvous (client to client) connections do not speak FLAP, so this * function will break on them. */ if (conn->type == AIM_CONN_TYPE_RENDEZVOUS) @@ -235,7 +235,7 @@ /* read the payload */ if (aim_bstream_recv(&fr->data, conn->fd, payloadlen) < payloadlen) { aim_frame_destroy(fr); /* free's payload */ - aim_conn_close(conn); + aim_conn_close(sess, conn); return -1; } } else
--- a/src/protocols/oscar/snactypes.h Sun Feb 12 21:27:04 2006 +0000 +++ b/src/protocols/oscar/snactypes.h Sun Feb 12 22:14:38 2006 +0000 @@ -28,7 +28,6 @@ /* * SNAC Families. */ -#define AIM_CB_FAM_ACK 0x0000 #define OSCAR_FAMILY_OSERVICE 0x0001 #define OSCAR_FAMILY_LOCATE 0x0002 #define OSCAR_FAMILY_BUDDY 0x0003 @@ -284,17 +283,10 @@ * the SNAC-centered libfaim callback structure. * */ -#define AIM_CB_SPECIAL_AUTHSUCCESS 0x0001 -#define AIM_CB_SPECIAL_AUTHOTHER 0x0002 #define AIM_CB_SPECIAL_CONNERR 0x0003 -#define AIM_CB_SPECIAL_CONNCOMPLETE 0x0004 #define AIM_CB_SPECIAL_FLAPVER 0x0005 #define AIM_CB_SPECIAL_CONNINITDONE 0x0006 #define AIM_CB_SPECIAL_IMAGETRANSFER 0x0007 -#define AIM_CB_SPECIAL_MSGTIMEOUT 0x0008 -#define AIM_CB_SPECIAL_CONNDEAD 0x0009 -#define AIM_CB_SPECIAL_UNKNOWN 0xffff -#define AIM_CB_SPECIAL_DEFAULT AIM_CB_SPECIAL_UNKNOWN /* SNAC flags */ #define AIM_SNACFLAGS_DESTRUCTOR 0x0001