changeset 13262:b08f8f3c9197

[gaim-migrate @ 15628] More cleanup. It's dinner time! committer: Tailor Script <tailor@pidgin.im>
author Mark Doliner <mark@kingant.net>
date Sun, 12 Feb 2006 23:59:30 +0000
parents 3b04ab4d96db
children a587a6c6149c
files src/protocols/oscar/conn.c src/protocols/oscar/family_chat.c src/protocols/oscar/oscar.c src/protocols/oscar/oscar.h src/protocols/oscar/oscar_internal.h src/protocols/oscar/rxqueue.c src/protocols/oscar/session.c src/protocols/oscar/txqueue.c
diffstat 8 files changed, 64 insertions(+), 117 deletions(-) [+]
line wrap: on
line diff
--- a/src/protocols/oscar/conn.c	Sun Feb 12 23:53:55 2006 +0000
+++ b/src/protocols/oscar/conn.c	Sun Feb 12 23:59:30 2006 +0000
@@ -98,7 +98,7 @@
 	aim_conn_inside_t *ins = (aim_conn_inside_t *)conn->inside;
 	struct snacgroup *sg;
 
-	sg = g_new(struct snacgroup, 1);
+	sg = g_new0(struct snacgroup, 1);
 
 	gaim_debug_misc("oscar", "adding group 0x%04x\n", group);
 	sg->group = group;
@@ -183,7 +183,7 @@
 	 * This will free ->internal if it necessary...
 	 */
 	if (conn->type == AIM_CONN_TYPE_CHAT)
-		aim_conn_kill_chat(sess, conn);
+		oscar_connection_destroy_chat(sess, conn);
 
 	if (conn->inside != NULL)
 	{
@@ -250,22 +250,6 @@
 }
 
 /**
- * Close, clear, and free a connection structure. Should never be
- * called from within libfaim.
- *
- * @param sess Session for the connection.
- * @param deadconn Connection to be freed.
- */
-void
-aim_conn_kill(OscarSession *sess, OscarConnection *conn)
-{
-	if (!conn)
-		return;
-
-	oscar_connection_destroy(sess, conn);
-}
-
-/**
  * Close (but not free) a connection.
  *
  * This leaves everything untouched except for clearing the
@@ -349,9 +333,7 @@
 {
 	OscarConnection *conn;
 
-	if (!(conn = aim_conn_getnext(sess)))
-		return NULL;
-
+	conn = aim_conn_getnext(sess);
 	conn->fd = src->fd;
 	conn->type = src->type;
 	conn->subtype = src->subtype;
@@ -390,14 +372,12 @@
 {
 	OscarConnection *conn;
 
-	if (!(conn = aim_conn_getnext(sess)))
-		return NULL;
-
-	conn->sessv = (void *)sess;
+	conn = aim_conn_getnext(sess);
+	conn->sessv = sess;
 	conn->type = type;
-
 	conn->fd = -1;
 	conn->status = 0;
+
 	return conn;
 }
 
--- a/src/protocols/oscar/family_chat.c	Sun Feb 12 23:53:55 2006 +0000
+++ b/src/protocols/oscar/family_chat.c	Sun Feb 12 23:59:30 2006 +0000
@@ -34,7 +34,7 @@
 	guint16 instance;
 };
 
-faim_internal void aim_conn_kill_chat(OscarSession *sess, OscarConnection *conn)
+faim_internal void oscar_connection_destroy_chat(OscarSession *sess, OscarConnection *conn)
 {
 	struct chatconnpriv *ccp = (struct chatconnpriv *)conn->internal;
 
--- a/src/protocols/oscar/oscar.c	Sun Feb 12 23:53:55 2006 +0000
+++ b/src/protocols/oscar/oscar.c	Sun Feb 12 23:59:30 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);
+	oscar_connection_destroy(od->sess, cc->conn);
 	g_free(cc->name);
 	g_free(cc->show);
 	g_free(cc);
@@ -952,10 +952,8 @@
 	}
 	if (dim->watcher)
 	gaim_input_remove(dim->watcher);
-	if (dim->conn) {
-		aim_conn_close(od->sess, dim->conn);
-		aim_conn_kill(od->sess, dim->conn);
-	}
+	if (dim->conn)
+		oscar_connection_destroy(od->sess, dim->conn);
 	g_free(dim);
 }
 
@@ -1176,8 +1174,7 @@
 	listenerconn = va_arg(ap, OscarConnection *);
 	va_end(ap);
 
-	aim_conn_close(sess, listenerconn);
-	aim_conn_kill(sess, listenerconn);
+	oscar_connection_destroy(sess, listenerconn);
 
 	sn = g_strdup(aim_odc_getsn(newconn));
 
@@ -1694,7 +1691,7 @@
 		if (aim_handlerendconnect(od->sess, conn) < 0) {
 			gaim_debug_error("oscar",
 					   "connection error (rendezvous listener)\n");
-			aim_conn_kill(od->sess, conn);
+			oscar_connection_destroy(od->sess, conn);
 			/* AAA - Don't we need to gaim_xfer_cancel here? --marv */
 		}
 	} else {
@@ -1745,38 +1742,38 @@
 									  NULL);
 				}
 				gaim_debug_info("oscar","killing rendezvous connection\n");
-				aim_conn_kill(od->sess, conn);
+				oscar_connection_destroy(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);
+				oscar_connection_destroy(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);
+				oscar_connection_destroy(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);
+				oscar_connection_destroy(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);
+				oscar_connection_destroy(od->sess, conn);
 			} else {
 				gaim_debug_error("oscar",
 						   "holy crap! generic connection error! %hu\n",
 						   conn->type);
-				aim_conn_kill(od->sess, conn);
+				oscar_connection_destroy(od->sess, conn);
 			}
 		}
 	}
@@ -2072,7 +2069,7 @@
 		aim_oft_sendheader(peer_connection->sess, PEER_TYPE_DONE, peer_connection);
 	}
 
-	aim_conn_kill(peer_connection->sess, peer_connection->conn);
+	oscar_connection_destroy(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 +2105,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);
+				oscar_connection_destroy(peer_connection->sess, peer_connection->conn);
 			}
 
 			if(peer_connection->method == AIM_XFER_DIRECT || peer_connection->method == AIM_XFER_REDIR) {
@@ -2150,7 +2147,7 @@
 
 						/* Kill our listener */
 						gaim_input_remove(xfer->watcher);
-						aim_conn_kill(peer_connection->sess, peer_connection->conn);
+						oscar_connection_destroy(peer_connection->sess, peer_connection->conn);
 
 						/* Instead of failing here, request a stage 3 proxy */
 						g_free(peer_connection->clientip);
@@ -2299,7 +2296,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);
+	oscar_connection_destroy(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 +2682,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);
+			oscar_connection_destroy(peer_connection->sess, peer_connection->conn);
 		aim_oft_destroyinfo(peer_connection);
 	}
 	xfer->data = NULL;
@@ -2884,7 +2881,7 @@
 
 	gaim_debug_misc("oscar", "BOSIP: %s\n", info->bosip);
 	gaim_debug_info("oscar", "Closing auth connection...\n");
-	aim_conn_kill(sess, fr->conn);
+	oscar_connection_destroy(sess, fr->conn);
 
 	bosconn = oscar_connection_new(sess, AIM_CONN_TYPE_BOS);
 	if (bosconn == NULL) {
@@ -3268,7 +3265,7 @@
 	tstconn->fd = source;
 
 	if (source < 0) {
-		aim_conn_kill(sess, tstconn);
+		oscar_connection_destroy(sess, tstconn);
 		gaim_debug_error("oscar", "unable to connect to chatnav server\n");
 		return;
 	}
@@ -3299,7 +3296,7 @@
 	tstconn->fd = source;
 
 	if (source < 0) {
-		aim_conn_kill(sess, tstconn);
+		oscar_connection_destroy(sess, tstconn);
 		gaim_debug_error("oscar", "unable to connect to authorizer\n");
 		return;
 	}
@@ -3334,7 +3331,7 @@
 	tstconn->fd = source;
 
 	if (source < 0) {
-		aim_conn_kill(sess, tstconn);
+		oscar_connection_destroy(sess, tstconn);
 		g_free(ccon->show);
 		g_free(ccon->name);
 		g_free(ccon);
@@ -3366,7 +3363,7 @@
 	tstconn->fd = source;
 
 	if (source < 0) {
-		aim_conn_kill(sess, tstconn);
+		oscar_connection_destroy(sess, tstconn);
 		gaim_debug_error("oscar", "unable to connect to email server\n");
 		return;
 	}
@@ -3396,7 +3393,7 @@
 	tstconn->fd = source;
 
 	if (source < 0) {
-		aim_conn_kill(sess, tstconn);
+		oscar_connection_destroy(sess, tstconn);
 		gaim_debug_error("oscar", "unable to connect to icon server\n");
 		return;
 	}
@@ -3449,7 +3446,7 @@
 
 		tstconn->status |= AIM_CONN_STATUS_INPROGRESS;
 		if (gaim_proxy_connect(account, host, port, oscar_auth_connect, gc) != 0) {
-			aim_conn_kill(sess, tstconn);
+			oscar_connection_destroy(sess, tstconn);
 			gaim_debug_error("oscar",
 					   "unable to reconnect with authorizer\n");
 			g_free(host);
@@ -3471,7 +3468,7 @@
 
 		tstconn->status |= AIM_CONN_STATUS_INPROGRESS;
 		if (gaim_proxy_connect(account, host, port, oscar_chatnav_connect, gc) != 0) {
-			aim_conn_kill(sess, tstconn);
+			oscar_connection_destroy(sess, tstconn);
 			gaim_debug_error("oscar",
 					   "unable to connect to chatnav server\n");
 			g_free(host);
@@ -3504,7 +3501,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);
+			oscar_connection_destroy(sess, tstconn);
 			gaim_debug_error("oscar",
 					   "unable to connect to chat server\n");
 			g_free(host);
@@ -3531,7 +3528,7 @@
 
 		tstconn->status |= AIM_CONN_STATUS_INPROGRESS;
 		if (gaim_proxy_connect(account, host, port, oscar_icon_connect, gc) != 0) {
-			aim_conn_kill(sess, tstconn);
+			oscar_connection_destroy(sess, tstconn);
 			gaim_debug_error("oscar",
 					   "unable to connect to icon server\n");
 			g_free(host);
@@ -3552,7 +3549,7 @@
 
 		tstconn->status |= AIM_CONN_STATUS_INPROGRESS;
 		if (gaim_proxy_connect(account, host, port, oscar_email_connect, gc) != 0) {
-			aim_conn_kill(sess, tstconn);
+			oscar_connection_destroy(sess, tstconn);
 			gaim_debug_error("oscar",
 					   "unable to connect to email server\n");
 			g_free(host);
@@ -3801,7 +3798,7 @@
 		/* Stop watching listener conn; watch transfer conn instead */
 		gaim_input_remove(xfer->watcher);
 
-		aim_conn_kill(sess, listenerconn);
+		oscar_connection_destroy(sess, listenerconn);
 
 		peer_connection->conn = conn;
 		xfer->fd = peer_connection->conn->fd;
@@ -4326,7 +4323,7 @@
 
 				/* Stop the listener connection */
 				gaim_input_remove(xfer->watcher);
-				aim_conn_kill(sess, peer_connection->conn); /* This is currently the listener */
+				oscar_connection_destroy(sess, peer_connection->conn); /* This is currently the listener */
 
 				if(args->info.sendfile.use_proxy) {
 					gaim_debug_info("oscar",
@@ -4561,7 +4558,7 @@
 
 
 static void gaim_auth_sendrequest(GaimConnection *gc, char *name) {
-	struct name_data *data = g_new(struct name_data, 1);
+	struct name_data *data = g_new0(struct name_data, 1);
 	GaimBuddy *buddy;
 	gchar *dialog_msg, *nombre;
 
--- a/src/protocols/oscar/oscar.h	Sun Feb 12 23:53:55 2006 +0000
+++ b/src/protocols/oscar/oscar.h	Sun Feb 12 23:59:30 2006 +0000
@@ -577,7 +577,7 @@
 
 faim_export int aim_debugconn_sendconnect(OscarSession *sess, OscarConnection *conn);
 
-void aim_conn_kill(OscarSession *sess, OscarConnection *deadconn);
+void oscar_connection_destroy(OscarSession *sess, OscarConnection *deadconn);
 
 typedef int (*aim_rxcallback_t)(OscarSession *, FlapFrame *, ...);
 
@@ -634,7 +634,6 @@
 faim_export int aim_tx_setenqueue(OscarSession *sess, int what, int (*func)(OscarSession *, FlapFrame *));
 
 faim_export int aim_tx_flushqueue(OscarSession *);
-faim_export void aim_tx_purgequeue(OscarSession *);
 
 faim_export int aim_conn_addhandler(OscarSession *, OscarConnection *conn, guint16 family, guint16 type, aim_rxcallback_t newhandler, guint16 flags);
 faim_export int aim_clearhandlers(OscarConnection *conn);
--- a/src/protocols/oscar/oscar_internal.h	Sun Feb 12 23:53:55 2006 +0000
+++ b/src/protocols/oscar/oscar_internal.h	Sun Feb 12 23:59:30 2006 +0000
@@ -81,8 +81,6 @@
 faim_internal int aim_genericreq_l(OscarSession *, OscarConnection *conn, guint16 family, guint16 subtype, guint32 *);
 faim_internal int aim_genericreq_s(OscarSession *, OscarConnection *conn, guint16 family, guint16 subtype, guint16 *);
 
-#define AIMBS_CURPOSPAIR(x) ((x)->data + (x)->offset), ((x)->len - (x)->offset)
-
 /* bstream.c */
 faim_internal int aim_bstream_init(ByteStream *bs, guint8 *data, int len);
 faim_internal int aim_bstream_empty(ByteStream *bs);
@@ -218,7 +216,7 @@
 
 faim_internal int aim_chat_readroominfo(ByteStream *bs, struct aim_chat_roominfo *outinfo);
 
-faim_internal void aim_conn_kill_chat(OscarSession *sess, OscarConnection *conn);
+faim_internal void oscar_connection_destroy_chat(OscarSession *sess, OscarConnection *conn);
 
 /* These are all handled internally now. */
 faim_internal int aim_setversions(OscarSession *sess, OscarConnection *conn);
--- a/src/protocols/oscar/rxqueue.c	Sun Feb 12 23:53:55 2006 +0000
+++ b/src/protocols/oscar/rxqueue.c	Sun Feb 12 23:59:30 2006 +0000
@@ -280,7 +280,7 @@
 }
 
 /*
- * Since aim_get_command will aim_conn_kill dead connections, we need
+ * Since aim_get_command will oscar_connection_destroy dead connections, we need
  * to clean up the rxqueue of unprocessed connections on that socket.
  *
  * XXX: this is something that was handled better in the old connection
--- a/src/protocols/oscar/session.c	Sun Feb 12 23:53:55 2006 +0000
+++ b/src/protocols/oscar/session.c	Sun Feb 12 23:59:30 2006 +0000
@@ -30,29 +30,9 @@
 
 	sess = g_new0(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.
--- a/src/protocols/oscar/txqueue.c	Sun Feb 12 23:53:55 2006 +0000
+++ b/src/protocols/oscar/txqueue.c	Sun Feb 12 23:59:30 2006 +0000
@@ -81,12 +81,7 @@
 
 	if (datalen > 0) {
 		guint8 *data;
-
-		if (!(data = (unsigned char *)malloc(datalen))) {
-			aim_frame_destroy(fr);
-			return NULL;
-		}
-
+		data = malloc(datalen);
 		aim_bstream_init(&fr->data, data, datalen);
 	}
 
@@ -171,8 +166,7 @@
 
 	payloadlen = aim_bstream_curpos(&fr->data);
 
-	if (!(bs_raw = malloc(6 + payloadlen)))
-		return -ENOMEM;
+	bs_raw = malloc(6 + payloadlen);
 
 	aim_bstream_init(&bs, bs_raw, 6 + payloadlen);
 
@@ -208,8 +202,7 @@
 
 	payloadlen = aim_bstream_curpos(&fr->data);
 
-	if (!(bs_raw = malloc(8 + payloadlen)))
-		return -ENOMEM;
+	bs_raw = malloc(8 + payloadlen);
 
 	aim_bstream_init(&bs, bs_raw, 8 + payloadlen);
 
@@ -246,6 +239,27 @@
 	return -1;
 }
 
+/*
+ * This is responsible for removing sent commands from the transmit
+ * queue. This is not a required operation, but it of course helps
+ * reduce memory footprint at run time!
+ */
+static void
+aim_tx_purgequeue(OscarSession *sess)
+{
+	FlapFrame *cur, **prev;
+
+	for (prev = &sess->queue_outgoing; (cur = *prev); ) {
+		if (cur->handled) {
+			*prev = cur->next;
+			aim_frame_destroy(cur);
+		} else
+			prev = &cur->next;
+	}
+
+	return;
+}
+
 int
 aim_tx_flushqueue(OscarSession *sess)
 {
@@ -269,27 +283,6 @@
 	return 0;
 }
 
-/*
- * This is responsible for removing sent commands from the transmit
- * queue. This is not a required operation, but it of course helps
- * reduce memory footprint at run time!
- */
-void
-aim_tx_purgequeue(OscarSession *sess)
-{
-	FlapFrame *cur, **prev;
-
-	for (prev = &sess->queue_outgoing; (cur = *prev); ) {
-		if (cur->handled) {
-			*prev = cur->next;
-			aim_frame_destroy(cur);
-		} else
-			prev = &cur->next;
-	}
-
-	return;
-}
-
 /**
  * Get rid of packets waiting for tx on a dying conn.  For now this
  * simply marks all packets as sent and lets them disappear without