changeset 13968:6fc412e59214

[gaim-migrate @ 16525] A bunch of little things * Use GAIM_CONNECTION_IS_VALID(gc) in a lot of places where we were doing g_list_find(gaim_connections_get_all(), gc) * Get rid of a lot of places where we were doing g_list_find(gaim_connections_get_all(), gc). The handle used by the request API ensures that the ok and cancel callback functions won't be called if the gc is destroyed. However, GAIM_CONNECTION_IS_VALID(gc) is still very important for callback functions where we can't cancel the request. For example, gaim_proxy_connect() callback functions. * "Added" a function to Yahoo! that should help us notice when our buddies change their buddy icon/display picture * Some comments in a few places * Changed GAIM_CONNECTION_IS_VALID(gc) to only look through the list of "all" connections and not the list of "connecting" connections. Some time ago we changed how this was done so that the list of "all" connections now includes the "connection" connections. committer: Tailor Script <tailor@pidgin.im>
author Mark Doliner <mark@kingant.net>
date Thu, 20 Jul 2006 08:11:54 +0000
parents 99b9b58b19dd
children 8934a27fed4b
files src/buddyicon.h src/connection.h src/gtkblist.c src/protocols/jabber/jabber.c src/protocols/jabber/presence.c src/protocols/jabber/roster.c src/protocols/msn/dialog.c src/protocols/msn/userlist.c src/protocols/oscar/family_icbm.c src/protocols/oscar/oscar.c src/protocols/oscar/peer.c src/protocols/oscar/peer_proxy.c src/protocols/silc/silc.c src/protocols/yahoo/yahoo.c src/protocols/yahoo/yahoo_picture.c src/protocols/yahoo/yahoo_picture.h src/proxy.c src/util.h
diffstat 18 files changed, 231 insertions(+), 187 deletions(-) [+]
line wrap: on
line diff
--- a/src/buddyicon.h	Thu Jul 20 07:31:15 2006 +0000
+++ b/src/buddyicon.h	Thu Jul 20 08:11:54 2006 +0000
@@ -42,6 +42,10 @@
 	int ref_count;         /**< The buddy icon reference count.    */
 };
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 /**************************************************************************/
 /** @name Buddy Icon API                                                  */
 /**************************************************************************/
@@ -281,4 +285,8 @@
 
 /*@}*/
 
+#ifdef __cplusplus
+}
+#endif
+
 #endif /* _GAIM_BUDDYICON_H_ */
--- a/src/connection.h	Thu Jul 20 07:31:15 2006 +0000
+++ b/src/connection.h	Thu Jul 20 08:11:54 2006 +0000
@@ -271,7 +271,7 @@
  *
  * @return @c TRUE if gc is valid.
  */
-#define GAIM_CONNECTION_IS_VALID(gc) (g_list_find(gaim_connections_get_all(), (gc)) || g_list_find(gaim_connections_get_connecting(), (gc)))
+#define GAIM_CONNECTION_IS_VALID(gc) (g_list_find(gaim_connections_get_all(), (gc)))
 
 /*@}*/
 
--- a/src/gtkblist.c	Thu Jul 20 07:31:15 2006 +0000
+++ b/src/gtkblist.c	Thu Jul 20 08:11:54 2006 +0000
@@ -3435,6 +3435,13 @@
 	PangoLogAttr *log_attrs;
 	gchar *word;
 
+	if (strcasecmp(key, "Global Thermonuclear War") == 0)
+	{
+		gaim_notify_info(NULL, "WOPR",
+				"Wouldn't you prefer a nice game of chess?", NULL);
+		return FALSE;
+	}
+
 	gtk_tree_model_get(model, iter, column, &withmarkup, -1);
 
 	tmp = g_utf8_normalize(key, -1, G_NORMALIZE_DEFAULT);
--- a/src/protocols/jabber/jabber.c	Thu Jul 20 07:31:15 2006 +0000
+++ b/src/protocols/jabber/jabber.c	Thu Jul 20 08:11:54 2006 +0000
@@ -344,7 +344,8 @@
 	int len;
 	static char buf[4096];
 
-	if(!g_list_find(gaim_connections_get_all(), gc)) {
+	/* TODO: It should be possible to make this check unnecessary */
+	if(!GAIM_CONNECTION_IS_VALID(gc)) {
 		gaim_ssl_close(gsc);
 		return;
 	}
--- a/src/protocols/jabber/presence.c	Thu Jul 20 07:31:15 2006 +0000
+++ b/src/protocols/jabber/presence.c	Thu Jul 20 08:11:54 2006 +0000
@@ -182,32 +182,30 @@
 
 static void authorize_add_cb(struct _jabber_add_permit *jap)
 {
-	if(g_list_find(gaim_connections_get_all(), jap->gc)) {
-		GaimBuddy *buddy = NULL;
+	GaimBuddy *buddy = NULL;
 
-		jabber_presence_subscription_set(jap->gc->proto_data, jap->who,
-				"subscribed");
+	jabber_presence_subscription_set(jap->gc->proto_data, jap->who,
+			"subscribed");
 
-		buddy = gaim_find_buddy(jap->gc->account, jap->who);
+	buddy = gaim_find_buddy(jap->gc->account, jap->who);
 
-		if (buddy) {
-			JabberBuddy *jb = NULL;
+	if (buddy) {
+		JabberBuddy *jb = NULL;
 
-			jb = jabber_buddy_find(jap->js, jap->who, TRUE);
+		jb = jabber_buddy_find(jap->js, jap->who, TRUE);
 
-			if ((jb->subscription & JABBER_SUB_TO) == 0) {
-				gaim_account_request_add(jap->gc->account,
+		if ((jb->subscription & JABBER_SUB_TO) == 0) {
+			gaim_account_request_add(jap->gc->account,
 				                         jap->who, NULL,
-				                         NULL, NULL);
-			} else {
-				gaim_account_notify_added(jap->gc->account,
-				                          jap->who, NULL,
-				                          NULL, NULL);
-			}
+			                         NULL, NULL);
 		} else {
-			gaim_account_request_add(jap->gc->account, jap->who,
-			                         NULL, NULL, NULL);
+			gaim_account_notify_added(jap->gc->account,
+			                          jap->who, NULL,
+			                          NULL, NULL);
 		}
+	} else {
+		gaim_account_request_add(jap->gc->account, jap->who,
+		                         NULL, NULL, NULL);
 	}
 
 	g_free(jap->who);
@@ -216,10 +214,8 @@
 
 static void deny_add_cb(struct _jabber_add_permit *jap)
 {
-	if(g_list_find(gaim_connections_get_all(), jap->gc)) {
-		jabber_presence_subscription_set(jap->gc->proto_data, jap->who,
-				"unsubscribed");
-	}
+	jabber_presence_subscription_set(jap->gc->proto_data, jap->who,
+			"unsubscribed");
 
 	g_free(jap->who);
 	g_free(jap);
--- a/src/protocols/jabber/roster.c	Thu Jul 20 07:31:15 2006 +0000
+++ b/src/protocols/jabber/roster.c	Thu Jul 20 08:11:54 2006 +0000
@@ -104,7 +104,6 @@
 		gaim_blist_add_buddy(b, NULL, g, NULL);
 		gaim_blist_alias_buddy(b, alias);
 
-
 		/* If we just learned about ourself, then fake our status,
 		 * because we won't be receiving a normal presence message
 		 * about ourself. */
@@ -117,8 +116,6 @@
 			jabber_presence_fake_to_self(js, status);
 		}
 
-
-
 		g_free(g2->data);
 		g2 = g_slist_delete_link(g2, g2);
 	}
--- a/src/protocols/msn/dialog.c	Thu Jul 20 07:31:15 2006 +0000
+++ b/src/protocols/msn/dialog.c	Thu Jul 20 08:11:54 2006 +0000
@@ -57,19 +57,17 @@
 static void
 msn_add_cb(MsnAddRemData *data)
 {
+	MsnSession *session;
+	MsnUserList *userlist;
+
 	msn_complete_sync_issue(data);
 
-	if (g_list_find(gaim_connections_get_all(), data->gc) != NULL)
-	{
-		MsnSession *session = data->gc->proto_data;
-		MsnUserList *userlist = session->userlist;
+	session = data->gc->proto_data;
+	userlist = session->userlist;
 
-		msn_userlist_add_buddy(userlist, data->who, MSN_LIST_FL, data->group);
-	}
+	msn_userlist_add_buddy(userlist, data->who, MSN_LIST_FL, data->group);
 
-	if (data->group != NULL)
-		g_free(data->group);
-
+	g_free(data->group);
 	g_free(data->who);
 	g_free(data);
 }
@@ -77,19 +75,17 @@
 static void
 msn_rem_cb(MsnAddRemData *data)
 {
+	MsnSession *session;
+	MsnUserList *userlist;
+
 	msn_complete_sync_issue(data);
 
-	if (g_list_find(gaim_connections_get_all(), data->gc) != NULL)
-	{
-		MsnSession *session = data->gc->proto_data;
-		MsnUserList *userlist = session->userlist;
+	session = data->gc->proto_data;
+	userlist = session->userlist;
 
-		msn_userlist_rem_buddy(userlist, data->who, MSN_LIST_FL, data->group);
-	}
+	msn_userlist_rem_buddy(userlist, data->who, MSN_LIST_FL, data->group);
 
-	if (data->group != NULL)
-		g_free(data->group);
-
+	g_free(data->group);
 	g_free(data->who);
 	g_free(data);
 }
--- a/src/protocols/msn/userlist.c	Thu Jul 20 07:31:15 2006 +0000
+++ b/src/protocols/msn/userlist.c	Thu Jul 20 08:11:54 2006 +0000
@@ -40,23 +40,20 @@
 static void
 msn_accept_add_cb(MsnPermitAdd *pa)
 {
-	if (g_list_find(gaim_connections_get_all(), pa->gc) != NULL)
-	{
-		MsnSession *session = pa->gc->proto_data;
-		MsnUserList *userlist = session->userlist;
-		GaimBuddy *buddy;
+	MsnSession *session = pa->gc->proto_data;
+	MsnUserList *userlist = session->userlist;
+	GaimBuddy *buddy;
 
-		msn_userlist_add_buddy(userlist, pa->who, MSN_LIST_AL, NULL);
+	msn_userlist_add_buddy(userlist, pa->who, MSN_LIST_AL, NULL);
 
-		buddy = gaim_find_buddy(pa->gc->account, pa->who);
+	buddy = gaim_find_buddy(pa->gc->account, pa->who);
 
-		if (buddy != NULL)
-			gaim_account_notify_added(pa->gc->account, pa->who,
-				NULL, pa->friendly, NULL);
-		else
-			gaim_account_request_add(pa->gc->account, pa->who,
-				NULL, pa->friendly, NULL);
-	}
+	if (buddy != NULL)
+		gaim_account_notify_added(pa->gc->account, pa->who,
+			NULL, pa->friendly, NULL);
+	else
+		gaim_account_request_add(pa->gc->account, pa->who,
+			NULL, pa->friendly, NULL);
 
 	g_free(pa->who);
 	g_free(pa->friendly);
@@ -66,13 +63,10 @@
 static void
 msn_cancel_add_cb(MsnPermitAdd *pa)
 {
-	if (g_list_find(gaim_connections_get_all(), pa->gc) != NULL)
-	{
-		MsnSession *session = pa->gc->proto_data;
-		MsnUserList *userlist = session->userlist;
+	MsnSession *session = pa->gc->proto_data;
+	MsnUserList *userlist = session->userlist;
 
-		msn_userlist_add_buddy(userlist, pa->who, MSN_LIST_BL, NULL);
-	}
+	msn_userlist_add_buddy(userlist, pa->who, MSN_LIST_BL, NULL);
 
 	g_free(pa->who);
 	g_free(pa->friendly);
--- a/src/protocols/oscar/family_icbm.c	Thu Jul 20 07:31:15 2006 +0000
+++ b/src/protocols/oscar/family_icbm.c	Thu Jul 20 08:11:54 2006 +0000
@@ -1718,9 +1718,9 @@
 	return ret;
 }
 
-static void incomingim_ch2_buddylist(OscarData *od, FlapConnection *conn, aim_module_t *mod, FlapFrame *frame, aim_modsnac_t *snac, aim_userinfo_t *userinfo, IcbmArgsCh2 *args, ByteStream *servdata)
+static void
+incomingim_ch2_buddylist(OscarData *od, FlapConnection *conn, aim_module_t *mod, FlapFrame *frame, aim_modsnac_t *snac, aim_userinfo_t *userinfo, IcbmArgsCh2 *args, ByteStream *servdata)
 {
-
 	/*
 	 * This goes like this...
 	 *
@@ -1740,7 +1740,8 @@
 	 *     ...
 	 *   ...
 	 */
-	while (servdata && byte_stream_empty(servdata)) {
+	while (byte_stream_empty(servdata))
+	{
 		guint16 gnlen, numb;
 		int i;
 		char *gn;
@@ -1767,51 +1768,49 @@
 	return;
 }
 
-static void incomingim_ch2_buddyicon_free(OscarData *od, IcbmArgsCh2 *args)
+static void
+incomingim_ch2_buddyicon_free(OscarData *od, IcbmArgsCh2 *args)
 {
-
 	free(args->info.icon.icon);
 
 	return;
 }
 
-static void incomingim_ch2_buddyicon(OscarData *od, FlapConnection *conn, aim_module_t *mod, FlapFrame *frame, aim_modsnac_t *snac, aim_userinfo_t *userinfo, IcbmArgsCh2 *args, ByteStream *servdata)
+static void
+incomingim_ch2_buddyicon(OscarData *od, FlapConnection *conn, aim_module_t *mod, FlapFrame *frame, aim_modsnac_t *snac, aim_userinfo_t *userinfo, IcbmArgsCh2 *args, ByteStream *servdata)
 {
-
-	if (servdata) {
-		args->info.icon.checksum = byte_stream_get32(servdata);
-		args->info.icon.length = byte_stream_get32(servdata);
-		args->info.icon.timestamp = byte_stream_get32(servdata);
-		args->info.icon.icon = byte_stream_getraw(servdata, args->info.icon.length);
-	}
+	args->info.icon.checksum = byte_stream_get32(servdata);
+	args->info.icon.length = byte_stream_get32(servdata);
+	args->info.icon.timestamp = byte_stream_get32(servdata);
+	args->info.icon.icon = byte_stream_getraw(servdata, args->info.icon.length);
 
 	args->destructor = (void *)incomingim_ch2_buddyicon_free;
 
 	return;
 }
 
-static void incomingim_ch2_chat_free(OscarData *od, IcbmArgsCh2 *args)
+static void
+incomingim_ch2_chat_free(OscarData *od, IcbmArgsCh2 *args)
 {
-
 	/* XXX - aim_chat_roominfo_free() */
 	free(args->info.chat.roominfo.name);
 
 	return;
 }
 
-static void incomingim_ch2_chat(OscarData *od, FlapConnection *conn, aim_module_t *mod, FlapFrame *frame, aim_modsnac_t *snac, aim_userinfo_t *userinfo, IcbmArgsCh2 *args, ByteStream *servdata)
+static void
+incomingim_ch2_chat(OscarData *od, FlapConnection *conn, aim_module_t *mod, FlapFrame *frame, aim_modsnac_t *snac, aim_userinfo_t *userinfo, IcbmArgsCh2 *args, ByteStream *servdata)
 {
-
 	/*
 	 * Chat room info.
 	 */
-	if (servdata)
-		aim_chat_readroominfo(servdata, &args->info.chat.roominfo);
+	aim_chat_readroominfo(servdata, &args->info.chat.roominfo);
 
 	args->destructor = (void *)incomingim_ch2_chat_free;
 }
 
-static void incomingim_ch2_icqserverrelay_free(OscarData *od, IcbmArgsCh2 *args)
+static void
+incomingim_ch2_icqserverrelay_free(OscarData *od, IcbmArgsCh2 *args)
 {
 	free((char *)args->info.rtfmsg.rtfmsg);
 }
@@ -1824,12 +1823,13 @@
  * Note that this is all little-endian.  Cringe.
  *
  */
-static void incomingim_ch2_icqserverrelay(OscarData *od, FlapConnection *conn, aim_module_t *mod, FlapFrame *frame, aim_modsnac_t *snac, aim_userinfo_t *userinfo, IcbmArgsCh2 *args, ByteStream *servdata)
+static void
+incomingim_ch2_icqserverrelay(OscarData *od, FlapConnection *conn, aim_module_t *mod, FlapFrame *frame, aim_modsnac_t *snac, aim_userinfo_t *userinfo, IcbmArgsCh2 *args, ByteStream *servdata)
 {
 	guint16 hdrlen, anslen, msglen;
 
-	if (servdata == NULL)
-		/* Odd...  Oh well. */
+	if (byte_stream_empty(servdata) < 24)
+		/* Someone sent us a short server relay ICBM.  Weird.  (Maybe?) */
 		return;
 
 	hdrlen = byte_stream_getle16(servdata);
@@ -1855,48 +1855,47 @@
 	args->destructor = (void *)incomingim_ch2_icqserverrelay_free;
 }
 
-static void incomingim_ch2_sendfile_free(OscarData *od, IcbmArgsCh2 *args)
+static void
+incomingim_ch2_sendfile_free(OscarData *od, IcbmArgsCh2 *args)
 {
 	free(args->info.sendfile.filename);
 }
 
-static void incomingim_ch2_sendfile(OscarData *od, FlapConnection *conn, aim_module_t *mod, FlapFrame *frame, aim_modsnac_t *snac, aim_userinfo_t *userinfo, IcbmArgsCh2 *args, ByteStream *servdata)
+/* Someone is sending us a file */
+static void
+incomingim_ch2_sendfile(OscarData *od, FlapConnection *conn, aim_module_t *mod, FlapFrame *frame, aim_modsnac_t *snac, aim_userinfo_t *userinfo, IcbmArgsCh2 *args, ByteStream *servdata)
 {
+	int flen;
 
 	args->destructor = (void *)incomingim_ch2_sendfile_free;
 
 	/* Maybe there is a better way to tell what kind of sendfile
 	 * this is?  Maybe TLV t(000a)? */
-	if (servdata) { /* Someone is sending us a file */
-		int flen;
-
-		/* subtype is one of AIM_OFT_SUBTYPE_* */
-		args->info.sendfile.subtype = byte_stream_get16(servdata);
-		args->info.sendfile.totfiles = byte_stream_get16(servdata);
-		args->info.sendfile.totsize = byte_stream_get32(servdata);
-
-		/*
-		 * I hope to God I'm right when I guess that there is a
-		 * 32 char max filename length for single files.  I think
-		 * OFT tends to do that.  Gotta love inconsistency.  I saw
-		 * a 26 byte filename?
-		 */
-		/* AAA - create an byte_stream_getnullstr function (don't anymore)(maybe) */
-		/* Use an inelegant way of getting the null-terminated filename,
-		 * since there's no easy bstream routine. */
-		for (flen = 0; byte_stream_get8(servdata); flen++);
-		byte_stream_advance(servdata, -flen -1);
-		args->info.sendfile.filename = byte_stream_getstr(servdata, flen);
-
-		/* There is sometimes more after the null-terminated filename,
-		 * but I'm unsure of its format. */
-		/* I don't believe him. */
-		/* There is sometimes a null byte inside a unicode filename,
-		 * but as far as I can tell the filename is the last
-		 * piece of data that will be in this message. --Jonathan */
-	}
-
-	return;
+
+	/* subtype is one of AIM_OFT_SUBTYPE_* */
+	args->info.sendfile.subtype = byte_stream_get16(servdata);
+	args->info.sendfile.totfiles = byte_stream_get16(servdata);
+	args->info.sendfile.totsize = byte_stream_get32(servdata);
+
+	/*
+	 * I hope to God I'm right when I guess that there is a
+	 * 32 char max filename length for single files.  I think
+	 * OFT tends to do that.  Gotta love inconsistency.  I saw
+	 * a 26 byte filename?
+	 */
+	/* AAA - create an byte_stream_getnullstr function (don't anymore)(maybe) */
+	/* Use an inelegant way of getting the null-terminated filename,
+	 * since there's no easy bstream routine. */
+	for (flen = 0; byte_stream_get8(servdata); flen++);
+	byte_stream_advance(servdata, -flen -1);
+	args->info.sendfile.filename = byte_stream_getstr(servdata, flen);
+
+	/* There is sometimes more after the null-terminated filename,
+	 * but I'm unsure of its format. */
+	/* I don't believe him. */
+	/* There is sometimes a null byte inside a unicode filename,
+	 * but as far as I can tell the filename is the last
+	 * piece of data that will be in this message. --Jonathan */
 }
 
 typedef void (*ch2_args_destructor_t)(OscarData *od, IcbmArgsCh2 *args);
@@ -2071,24 +2070,24 @@
 
 		byte_stream_init(&sdbs, servdatatlv->value, servdatatlv->length);
 		sdbsptr = &sdbs;
+
+		/*
+		 * The rest of the handling depends on what type it is.
+		 *
+		 * Not all of them have special handling (yet).
+		 */
+		if (args.type & OSCAR_CAPABILITY_BUDDYICON)
+			incomingim_ch2_buddyicon(od, conn, mod, frame, snac, userinfo, &args, sdbsptr);
+		else if (args.type & OSCAR_CAPABILITY_SENDBUDDYLIST)
+			incomingim_ch2_buddylist(od, conn, mod, frame, snac, userinfo, &args, sdbsptr);
+		else if (args.type & OSCAR_CAPABILITY_CHAT)
+			incomingim_ch2_chat(od, conn, mod, frame, snac, userinfo, &args, sdbsptr);
+		else if (args.type & OSCAR_CAPABILITY_ICQSERVERRELAY)
+			incomingim_ch2_icqserverrelay(od, conn, mod, frame, snac, userinfo, &args, sdbsptr);
+		else if (args.type & OSCAR_CAPABILITY_SENDFILE)
+			incomingim_ch2_sendfile(od, conn, mod, frame, snac, userinfo, &args, sdbsptr);
 	}
 
-	/*
-	 * The rest of the handling depends on what type it is.
-	 *
-	 * Not all of them have special handling (yet).
-	 */
-	if (args.type & OSCAR_CAPABILITY_BUDDYICON)
-		incomingim_ch2_buddyicon(od, conn, mod, frame, snac, userinfo, &args, sdbsptr);
-	else if (args.type & OSCAR_CAPABILITY_SENDBUDDYLIST)
-		incomingim_ch2_buddylist(od, conn, mod, frame, snac, userinfo, &args, sdbsptr);
-	else if (args.type & OSCAR_CAPABILITY_CHAT)
-		incomingim_ch2_chat(od, conn, mod, frame, snac, userinfo, &args, sdbsptr);
-	else if (args.type & OSCAR_CAPABILITY_ICQSERVERRELAY)
-		incomingim_ch2_icqserverrelay(od, conn, mod, frame, snac, userinfo, &args, sdbsptr);
-	else if (args.type & OSCAR_CAPABILITY_SENDFILE)
-		incomingim_ch2_sendfile(od, conn, mod, frame, snac, userinfo, &args, sdbsptr);
-
 	if ((userfunc = aim_callhandler(od, snac->family, snac->subtype)))
 		ret = userfunc(od, conn, frame, channel, userinfo, &args);
 
--- a/src/protocols/oscar/oscar.c	Thu Jul 20 07:31:15 2006 +0000
+++ b/src/protocols/oscar/oscar.c	Thu Jul 20 08:11:54 2006 +0000
@@ -954,7 +954,7 @@
 	new_conn_data = data;
 	gc = new_conn_data->gc;
 
-	if (!g_list_find(gaim_connections_get_all(), gc))
+	if (!GAIM_CONNECTION_IS_VALID(gc))
 	{
 		if (source >= 0)
 			close(source);
@@ -2182,12 +2182,10 @@
 gaim_auth_dontrequest(struct name_data *data)
 {
 	GaimConnection *gc = data->gc;
-
-	if (g_list_find(gaim_connections_get_all(), gc)) {
-		/* Remove from local list */
-		GaimBuddy *b = gaim_find_buddy(gaim_connection_get_account(gc), data->name);
-		gaim_blist_remove_buddy(b);
-	}
+	GaimBuddy *b = gaim_find_buddy(gaim_connection_get_account(gc), data->name);
+
+	/* Remove from local list */
+	gaim_blist_remove_buddy(b);
 
 	oscar_free_name_data(data);
 }
@@ -2240,11 +2238,9 @@
 gaim_auth_grant(struct name_data *data)
 {
 	GaimConnection *gc = data->gc;
-
-	if (g_list_find(gaim_connections_get_all(), gc)) {
-		OscarData *od = gc->proto_data;
-		aim_ssi_sendauthreply(od, data->name, 0x01, NULL);
-	}
+	OscarData *od = gc->proto_data;
+
+	aim_ssi_sendauthreply(od, data->name, 0x01, NULL);
 
 	oscar_free_name_data(data);
 }
@@ -2254,11 +2250,9 @@
 gaim_auth_dontgrant(struct name_data *data, char *msg)
 {
 	GaimConnection *gc = data->gc;
-
-	if (g_list_find(gaim_connections_get_all(), gc)) {
-		OscarData *od = gc->proto_data;
-		aim_ssi_sendauthreply(od, data->name, 0x00, msg ? msg : _("No reason given."));
-	}
+	OscarData *od = gc->proto_data;
+
+	aim_ssi_sendauthreply(od, data->name, 0x00, msg ? msg : _("No reason given."));
 }
 
 static void
@@ -2277,9 +2271,7 @@
 {
 	GaimConnection *gc = data->gc;
 
-	if (g_list_find(gaim_connections_get_all(), gc)) {
-		gaim_blist_request_add_buddy(gaim_connection_get_account(gc), data->name, NULL, data->nick);
-	}
+	gaim_blist_request_add_buddy(gaim_connection_get_account(gc), data->name, NULL, data->nick);
 
 	oscar_free_name_data(data);
 }
@@ -2780,7 +2772,11 @@
 		} break;
 
 		default: {
-			gaim_debug_error("oscar", "Received unknown typing notification message from %s.  Type1 is 0x%04x and type2 is 0x%04hx.\n", sn, type1, type2);
+			/*
+			 * It looks like iChat sometimes sends typing notification
+			 * with type1=0x0001 and type2=0x000f.  Not sure why.
+			 */
+			gaim_debug_info("oscar", "Received unknown typing notification message from %s.  Type1 is 0x%04x and type2 is 0x%04hx.\n", sn, type1, type2);
 		} break;
 	}
 
--- a/src/protocols/oscar/peer.c	Thu Jul 20 07:31:15 2006 +0000
+++ b/src/protocols/oscar/peer.c	Thu Jul 20 08:11:54 2006 +0000
@@ -481,7 +481,7 @@
 	conn = new_conn_data->conn;
 	g_free(new_conn_data);
 
-	if (!g_list_find(gaim_connections_get_all(), gc))
+	if (!GAIM_CONNECTION_IS_VALID(gc))
 	{
 		if (source >= 0)
 			close(source);
@@ -573,7 +573,7 @@
 	conn = new_conn_data->conn;
 	g_free(new_conn_data);
 
-	if (!g_list_find(gaim_connections_get_all(), gc))
+	if (!GAIM_CONNECTION_IS_VALID(gc))
 	{
 		if (listenerfd != -1)
 			close(listenerfd);
--- a/src/protocols/oscar/peer_proxy.c	Thu Jul 20 07:31:15 2006 +0000
+++ b/src/protocols/oscar/peer_proxy.c	Thu Jul 20 08:11:54 2006 +0000
@@ -337,7 +337,7 @@
 	conn = new_conn_data->conn;
 	g_free(new_conn_data);
 
-	if (!g_list_find(gaim_connections_get_all(), gc))
+	if (!GAIM_CONNECTION_IS_VALID(gc))
 	{
 		if (source >= 0)
 			close(source);
--- a/src/protocols/silc/silc.c	Thu Jul 20 07:31:15 2006 +0000
+++ b/src/protocols/silc/silc.c	Thu Jul 20 08:11:54 2006 +0000
@@ -152,28 +152,24 @@
 	const char *dfile;
 
 	g_return_if_fail(gc != NULL);
-	sg = gc->proto_data;
+
+	if (!GAIM_CONNECTION_IS_VALID(gc)) {
+		close(source);
+		return;
+	}
 
 	if (source < 0) {
 		gaim_connection_error(gc, _("Connection failed"));
 		return;
 	}
 
+	sg = gc->proto_data;
 	if (sg == NULL)
 		return;
 
 	client = sg->client;
 	account = sg->account;
 
-	if (!g_list_find(gaim_connections_get_all(), gc)) {
-		close(source);
-		g_source_remove(sg->scheduler);
-		silc_client_stop(sg->client);
-		silc_client_free(sg->client);
-		silc_free(sg);
-		return;
-	}
-
 	/* Get session detachment data, if available */
 	memset(&params, 0, sizeof(params));
 	dfile = silcgaim_session_file(gaim_account_get_username(sg->account));
--- a/src/protocols/yahoo/yahoo.c	Thu Jul 20 07:31:15 2006 +0000
+++ b/src/protocols/yahoo/yahoo.c	Thu Jul 20 08:11:54 2006 +0000
@@ -810,6 +810,7 @@
 	if (!msg || !g_utf8_validate(msg, -1, NULL))
 		return;
 
+	/* TODO: Does this really need to be escaped?  It seems like it doesn't. */
 	escmsg = g_markup_escape_text(msg, -1);
 
 	prim = g_strdup_printf(_("Yahoo! system message for %s:"),
@@ -2132,6 +2133,9 @@
 	case YAHOO_SERVICE_PICTURE_UPLOAD:
 		yahoo_process_picture_upload(gc, pkt);
 		break;
+	case YAHOO_SERVICE_AVATAR_UPDATE:
+		yahoo_process_avatar_update(gc, pkt);
+		break;
 	case YAHOO_SERVICE_AUDIBLE:
 		yahoo_process_audible(gc, pkt);
 		break;
@@ -2234,7 +2238,7 @@
 	struct yahoo_data *yd;
 	struct yahoo_packet *pkt;
 
-	if (!g_list_find(gaim_connections_get_all(), gc)) {
+	if (!GAIM_CONNECTION_IS_VALID(gc)) {
 		close(source);
 		return;
 	}
@@ -2261,7 +2265,7 @@
 	struct yahoo_data *yd;
 	struct yahoo_packet *pkt;
 
-	if (!g_list_find(gaim_connections_get_all(), gc)) {
+	if (!GAIM_CONNECTION_IS_VALID(gc)) {
 		close(source);
 		return;
 	}
--- a/src/protocols/yahoo/yahoo_picture.c	Thu Jul 20 07:31:15 2006 +0000
+++ b/src/protocols/yahoo/yahoo_picture.c	Thu Jul 20 08:11:54 2006 +0000
@@ -225,6 +225,50 @@
 	}
 }
 
+void yahoo_process_avatar_update(GaimConnection *gc, struct yahoo_packet *pkt)
+{
+	GSList *l = pkt->hash;
+	char *who = NULL;
+	int avatar = 0;
+
+	while (l) {
+		struct yahoo_pair *pair = l->data;
+
+		switch (pair->key) {
+		case 4:
+			who = pair->value;
+			break;
+		case 5:
+			/* us */
+			break;
+		case 206:
+			/*
+			 * 0 - No icon or avatar
+			 * 1 - Using an avatar
+			 * 2 - Using an icon
+			 */
+			avatar = strtol(pair->value, NULL, 10);
+			break;
+		}
+		l = l->next;
+	}
+
+	if (who) {
+		if (avatar == 2)
+			yahoo_send_picture_request(gc, who);
+		else if ((avatar == 0) || (avatar == 1)) {
+			GaimBuddy *b = gaim_find_buddy(gc->account, who);
+			YahooFriend *f;
+			gaim_buddy_icons_set_for_user(gc->account, who, NULL, 0);
+			if (b)
+				gaim_blist_node_remove_setting((GaimBlistNode *)b, YAHOO_ICON_CHECKSUM_KEY);
+			if ((f = yahoo_friend_find(gc, who)))
+				yahoo_friend_set_buddy_icon_need_request(f, TRUE);
+			gaim_debug_misc("yahoo", "Setting user %s's icon to NULL.\n", who);
+		}
+	}
+}
+
 void yahoo_send_picture_info(GaimConnection *gc, const char *who)
 {
 	struct yahoo_data *yd = gc->proto_data;
--- a/src/protocols/yahoo/yahoo_picture.h	Thu Jul 20 07:31:15 2006 +0000
+++ b/src/protocols/yahoo/yahoo_picture.h	Thu Jul 20 08:11:54 2006 +0000
@@ -35,6 +35,8 @@
 void yahoo_process_picture_checksum(GaimConnection *gc, struct yahoo_packet *pkt);
 void yahoo_process_picture_upload(GaimConnection *gc, struct yahoo_packet *pkt);
 
+void yahoo_process_avatar_update(GaimConnection *gc, struct yahoo_packet *pkt);
+
 void yahoo_set_buddy_icon(GaimConnection *gc, const char *iconfile);
 void yahoo_buddy_icon_upload(GaimConnection *gc, struct yahoo_buddy_icon_upload_data *d);
 void yahoo_buddy_icon_upload_data_free(struct yahoo_buddy_icon_upload_data *d);
--- a/src/proxy.c	Thu Jul 20 07:31:15 2006 +0000
+++ b/src/proxy.c	Thu Jul 20 08:11:54 2006 +0000
@@ -86,9 +86,9 @@
 {
 	g_return_if_fail(info != NULL);
 
-	if (info->host     != NULL) g_free(info->host);
-	if (info->username != NULL) g_free(info->username);
-	if (info->password != NULL) g_free(info->password);
+	g_free(info->host);
+	g_free(info->username);
+	g_free(info->password);
 
 	g_free(info);
 }
@@ -106,8 +106,7 @@
 {
 	g_return_if_fail(info != NULL);
 
-	if (info->host != NULL)
-		g_free(info->host);
+	g_free(info->host);
 
 	info->host = (host == NULL ? NULL : g_strdup(host));
 }
@@ -125,8 +124,7 @@
 {
 	g_return_if_fail(info != NULL);
 
-	if (info->username != NULL)
-		g_free(info->username);
+	g_free(info->username);
 
 	info->username = (username == NULL ? NULL : g_strdup(username));
 }
@@ -136,8 +134,7 @@
 {
 	g_return_if_fail(info != NULL);
 
-	if (info->password != NULL)
-		g_free(info->password);
+	g_free(info->password);
 
 	info->password = (password == NULL ? NULL : g_strdup(password));
 }
@@ -303,7 +300,7 @@
 trap_gdb_bug()
 {
 	const char *message =
-		"Gaim's DNS child got a SIGTRAP signal. \n"
+		"Gaim's DNS child got a SIGTRAP signal.\n"
 		"This can be caused by trying to run gaim inside gdb.\n"
 		"There is a known gdb bug which prevents this.  Supposedly gaim\n"
 		"should have detected you were using gdb and used an ugly hack,\n"
@@ -2319,6 +2316,12 @@
 	return gpi;
 }
 
+/*
+ * TODO: It would be really good if this returned some sort of handle
+ *       that we could use to cancel the connection.  As it is now,
+ *       each callback has to check to make sure gc is still valid.
+ *       And that is ugly.
+ */
 int
 gaim_proxy_connect(GaimAccount *account, const char *host, int port,
 				   GaimInputFunction func, gpointer data)
--- a/src/util.h	Thu Jul 20 07:31:15 2006 +0000
+++ b/src/util.h	Thu Jul 20 08:11:54 2006 +0000
@@ -343,11 +343,12 @@
  * in a GData hash table. The names of the attributes are lower-cased
  * in the hash table, and the name of the tag is case insensitive.
  *
- * @param needle	the name of the tag
- * @param haystack	the null-delimited string to search in
- * @param start		a pointer to the start of the tag if found
- * @param end		a pointer to the end of the tag if found
- * @param attributes	the attributes, if the tag was found
+ * @param needle	  The name of the tag
+ * @param haystack	  The null-delimited string to search in
+ * @param start		  A pointer to the start of the tag if found
+ * @param end		  A pointer to the end of the tag if found
+ * @param attributes  The attributes, if the tag was found.  This should
+ *                    be freed with g_datalist_clear().
  * @return TRUE if the tag was found
  */
 gboolean gaim_markup_find_tag(const char *needle, const char *haystack,