changeset 13611:7f91efd5af77

[gaim-migrate @ 15997] Use a GList instead of creation one ourselves committer: Tailor Script <tailor@pidgin.im>
author Mark Doliner <mark@kingant.net>
date Mon, 10 Apr 2006 04:40:22 +0000
parents 060835af7634
children dd03aa8a28ad
files src/protocols/oscar/family_oservice.c src/protocols/oscar/flap_connection.c src/protocols/oscar/oscar.h
diffstat 3 files changed, 24 insertions(+), 69 deletions(-) [+]
line wrap: on
line diff
--- a/src/protocols/oscar/family_oservice.c	Mon Apr 10 03:57:58 2006 +0000
+++ b/src/protocols/oscar/family_oservice.c	Mon Apr 10 04:40:22 2006 +0000
@@ -31,9 +31,9 @@
 void
 aim_clientready(OscarData *od, FlapConnection *conn)
 {
-	struct snacgroup *sg;
 	FlapFrame *frame;
 	aim_snacid_t snacid;
+	GList *cur;
 
 	frame = flap_frame_new(od, 0x02, 1152);
 
@@ -44,17 +44,17 @@
 	 * Send only the tool versions that the server cares about (that it
 	 * marked as supporting in the server ready SNAC).
 	 */
-	for (sg = conn->groups; sg; sg = sg->next)
+	for (cur = conn->groups; cur != NULL; cur = cur->next)
 	{
 		aim_module_t *mod;
 
-		if ((mod = aim__findmodulebygroup(od, sg->group))) {
+		if ((mod = aim__findmodulebygroup(od, GPOINTER_TO_UINT(cur->data))))
+		{
 			byte_stream_put16(&frame->data, mod->family);
 			byte_stream_put16(&frame->data, mod->version);
 			byte_stream_put16(&frame->data, mod->toolid);
 			byte_stream_put16(&frame->data, mod->toolversion);
-		} else
-			gaim_debug_misc("oscar", "aim_clientready: server supports group 0x%04x but we don't!\n", sg->group);
+		}
 	}
 
 	flap_connection_send(conn, frame);
@@ -77,20 +77,14 @@
 static int
 hostonline(OscarData *od, FlapConnection *conn, aim_module_t *mod, FlapFrame *frame, aim_modsnac_t *snac, ByteStream *bs)
 {
-	guint16 *families;
-	int famcount;
-
-
-	families = malloc(byte_stream_empty(bs));
+	int group;
 
-	for (famcount = 0; byte_stream_empty(bs); famcount++) {
-		families[famcount] = byte_stream_get16(bs);
-		flap_connection_addgroup(conn, families[famcount]);
+	while (byte_stream_empty(bs))
+	{
+		group = byte_stream_get16(bs);
+		conn->groups = g_list_prepend(conn->groups, GUINT_TO_POINTER(group));
 	}
 
-	free(families);
-
-
 	/*
 	 * Next step is in the Host Versions handler.
 	 *
@@ -506,7 +500,7 @@
 {
 	FlapFrame *frame;
 	aim_snacid_t snacid;
-	struct snacgroup *sg;
+	GList *cur;
 
 	frame = flap_frame_new(od, 0x02, 1024);
 
@@ -518,8 +512,8 @@
 	 * Host Online / Server Ready said this host supports.  And
 	 * we want them all back after the migration.
 	 */
-	for (sg = conn->groups; sg; sg = sg->next)
-		byte_stream_put16(&frame->data, sg->group);
+	for (cur = conn->groups; cur != NULL; cur = cur->next)
+		byte_stream_put16(&frame->data, GPOINTER_TO_UINT(cur->data));
 
 	flap_connection_send(conn, frame);
 }
@@ -746,9 +740,9 @@
 void
 aim_setversions(OscarData *od, FlapConnection *conn)
 {
-	struct snacgroup *sg;
 	FlapFrame *frame;
 	aim_snacid_t snacid;
+	GList *cur;
 
 	frame = flap_frame_new(od, 0x02, 1152);
 
@@ -759,14 +753,15 @@
 	 * Send only the versions that the server cares about (that it
 	 * marked as supporting in the server ready SNAC).
 	 */
-	for (sg = conn->groups; sg; sg = sg->next) {
+	for (cur = conn->groups; cur != NULL; cur = cur->next)
+	{
 		aim_module_t *mod;
 
-		if ((mod = aim__findmodulebygroup(od, sg->group))) {
+		if ((mod = aim__findmodulebygroup(od, GPOINTER_TO_UINT(cur->data))))
+		{
 			byte_stream_put16(&frame->data, mod->family);
 			byte_stream_put16(&frame->data, mod->version);
-		} else
-			gaim_debug_misc("oscar", "aim_setversions: server supports group 0x%04x but we don't!\n", sg->group);
+		}
 	}
 
 	flap_connection_send(conn, frame);
--- a/src/protocols/oscar/flap_connection.c	Mon Apr 10 03:57:58 2006 +0000
+++ b/src/protocols/oscar/flap_connection.c	Mon Apr 10 04:40:22 2006 +0000
@@ -149,20 +149,6 @@
 }
 
 static void
-flap_connection_destroy_snacgroups(struct snacgroup *head)
-{
-	struct snacgroup *sg;
-	for (sg = head; sg; )
-	{
-		struct snacgroup *tmp;
-
-		tmp = sg->next;
-		free(sg);
-		sg = tmp;
-	}
-}
-
-static void
 flap_connection_destroy_rates(struct rateclass *head)
 {
 	struct rateclass *rc;
@@ -215,7 +201,7 @@
 	if (conn->type == SNAC_FAMILY_CHAT)
 		flap_connection_destroy_chat(od, conn);
 
-	flap_connection_destroy_snacgroups(conn->groups);
+	g_list_free(conn->groups);
 	flap_connection_destroy_rates(conn->rates);
 
 	od->oscar_connections = g_list_remove(od->oscar_connections, conn);
@@ -327,26 +313,10 @@
  * about such inane things.
  *
  */
-void
-flap_connection_addgroup(FlapConnection *conn, guint16 group)
-{
-	struct snacgroup *sg;
-
-	sg = g_new0(struct snacgroup, 1);
-
-	gaim_debug_misc("oscar", "Adding group 0x%04x to connection "
-			"of type 0x%04hx\n", group, conn->type);
-	sg->group = group;
-
-	sg->next = conn->groups;
-	conn->groups = sg;
-}
 
 /**
  * Find a FlapConnection that supports the given oscar
  * family.
- *
- * TODO: This should be implemented to use a hash table.
  */
 FlapConnection *
 flap_connection_findbygroup(OscarData *od, guint16 group)
@@ -356,13 +326,13 @@
 	for (cur = od->oscar_connections; cur != NULL; cur = cur->next)
 	{
 		FlapConnection *conn;
-		struct snacgroup *sg;
+		GList *l;
 
 		conn = cur->data;
 
-		for (sg = conn->groups; sg != NULL; sg = sg->next)
+		for (l = conn->groups; l != NULL; l = l->next)
 		{
-			if (sg->group == group)
+			if (GPOINTER_TO_UINT(l->data) == group)
 				return conn;
 		}
 	}
--- a/src/protocols/oscar/oscar.h	Mon Apr 10 03:57:58 2006 +0000
+++ b/src/protocols/oscar/oscar.h	Mon Apr 10 04:40:22 2006 +0000
@@ -376,7 +376,7 @@
 	guint16 subtype;
 	flap_seqnum_t seqnum;
 	guint32 status;
-	struct snacgroup *groups;
+	GList *groups;
 	struct rateclass *rates;
 
 	void *internal; /* internal conn-specific libfaim data */
@@ -563,7 +563,6 @@
 
 /* flap_connection.c */
 FlapConnection *flap_connection_new(OscarData *, int type);
-void flap_connection_addgroup(FlapConnection *conn, guint16 group);
 void flap_connection_close(OscarData *od, FlapConnection *conn);
 void flap_connection_destroy(FlapConnection *conn, OscarDisconnectReason reason);
 void flap_connection_schedule_destroy(FlapConnection *conn, OscarDisconnectReason reason);
@@ -1519,15 +1518,6 @@
 	guint16 instance;
 };
 
-/*
- * In SNACland, the terms 'family' and 'group' are synonymous -- the former
- * is my term, the latter is AOL's.
- */
-struct snacgroup {
-	guint16 group;
-	struct snacgroup *next;
-};
-
 struct snacpair {
 	guint16 group;
 	guint16 subtype;