pidgin: c3e033ad: Stop attempting to fetch oscar buddy inf...

markdoliner at pidgin.im markdoliner at pidgin.im
Tue Aug 18 18:41:33 EDT 2009


-----------------------------------------------------------------
Revision: c3e033ad36f556e3e590b25ea92dd0441cb4acea
Ancestor: 327007fa083ac3f2e7022e31c949497e38407725
Author: markdoliner at pidgin.im
Date: 2009-08-18T22:35:34
Branch: im.pidgin.pidgin
URL: http://d.pidgin.im/viewmtn/revision/info/c3e033ad36f556e3e590b25ea92dd0441cb4acea

Modified files:
        libpurple/protocols/oscar/family_buddy.c
        libpurple/protocols/oscar/family_locate.c
        libpurple/protocols/oscar/oscar.c
        libpurple/protocols/oscar/oscar.h
        libpurple/protocols/oscar/snactypes.h

ChangeLog: 

Stop attempting to fetch oscar buddy info automatically for people on our
buddy list.  tmm1 (Aman Gupta) correct pointed out that the only thing we
need this for is to show users' status messages in the buddy list, and new
AIM clients have been putting the status message in the userinfo block which
is sent as part of the presence.  So we can eliminate a lot of code.

We now grab screen name formatting when we get the initial presence for
buddies rather than when we get the auto-fetched info

And the "message" stored in the buddy's PurpleStatus will now be
plaintext even when the away message contains HTML.  This is because
the status message from the userinfo block is always plaintext.
This doesn't cause problems for any UIs that I'm aware of, but let
me know if it undesirable for you.

Fixes #9843

-------------- next part --------------
============================================================
--- libpurple/protocols/oscar/family_buddy.c	eddc81835e18c88cd7c89b4ac87e4277ee4908cd
+++ libpurple/protocols/oscar/family_buddy.c	2e279466eb6849d7332d0d42f70d397bd9bf8d5d
@@ -221,9 +221,6 @@ buddychange(OscarData *od, FlapConnectio
 	if ((userfunc = aim_callhandler(od, snac->family, snac->subtype)))
 		ret = userfunc(od, conn, frame, &userinfo);
 
-	if (snac->subtype == SNAC_SUBTYPE_BUDDY_ONCOMING && userinfo.flags & AIM_FLAG_AWAY)
-		aim_locate_autofetch_away_message(od, userinfo.bn);
-
 	aim_info_free(&userinfo);
 
 	return ret;
============================================================
--- libpurple/protocols/oscar/family_locate.c	82c212fb9ea11cd7e9d8b5e6780635ae24a59280
+++ libpurple/protocols/oscar/family_locate.c	9156684365756a4a30579f895c916488424be101
@@ -250,8 +250,6 @@ aim_locate_adduserinfo(OscarData *od, ai
 aim_locate_adduserinfo(OscarData *od, aim_userinfo_t *userinfo)
 {
 	aim_userinfo_t *cur;
-	FlapConnection *conn;
-	aim_rxcallback_t userfunc;
 
 	cur = aim_locate_finduserinfo(od, userinfo->bn);
 
@@ -353,75 +351,8 @@ aim_locate_adduserinfo(OscarData *od, ai
 		}
 		cur->away_len = 0;
 	}
-
-	/*
-	 * This callback can be used by a client if they want to know whenever
-	 * info for a buddy is updated.  For example, if a client shows away
-	 * messages in its buddy list, then it would need to know if a user's
-	 * away message changes.
-	 */
-	conn = flap_connection_findbygroup(od, SNAC_FAMILY_LOCATE);
-	if ((userfunc = aim_callhandler(od, SNAC_FAMILY_LOCATE, SNAC_SUBTYPE_LOCATE_GOTINFOBLOCK)))
-		userfunc(od, conn, NULL, cur);
 }
 
-/**
- * Remove this buddy name from our queue.  If this info was requested
- * by our info request queue, then pop the next element off of the queue.
- *
- * @param od The aim session.
- * @param bn Buddy name of the info we just received.
- * @return True if the request was explicit (client requested the info),
- *         false if the request was implicit (libfaim request the info).
- */
-static int
-aim_locate_gotuserinfo(OscarData *od, FlapConnection *conn, const char *bn)
-{
-	struct userinfo_node *cur, *del;
-	int was_explicit = TRUE;
-
-	while ((od->locate.requested != NULL) && (oscar_util_name_compare(bn, od->locate.requested->bn) == 0)) {
-		del = od->locate.requested;
-		od->locate.requested = del->next;
-		was_explicit = FALSE;
-		g_free(del->bn);
-		g_free(del);
-	}
-
-	cur = od->locate.requested;
-	while ((cur != NULL) && (cur->next != NULL)) {
-		if (oscar_util_name_compare(bn, cur->next->bn) == 0) {
-			del = cur->next;
-			cur->next = del->next;
-			was_explicit = FALSE;
-			g_free(del->bn);
-			g_free(del);
-		} else
-			cur = cur->next;
-	}
-
-	return was_explicit;
-}
-
-void
-aim_locate_autofetch_away_message(OscarData *od, const char *bn)
-{
-	struct userinfo_node *cur;
-
-	/* Make sure we haven't already made an info request for this buddy */
-	for (cur = od->locate.requested; cur != NULL; cur = cur->next)
-		if (oscar_util_name_compare(bn, cur->bn) == 0)
-			return;
-
-	/* Add a new node to our request queue */
-	cur = (struct userinfo_node *)g_malloc(sizeof(struct userinfo_node));
-	cur->bn = g_strdup(bn);
-	cur->next = od->locate.requested;
-	od->locate.requested = cur;
-
-	aim_locate_getinfoshort(od, cur->bn, 0x00000002);
-}
-
 aim_userinfo_t *aim_locate_finduserinfo(OscarData *od, const char *bn) {
 	aim_userinfo_t *cur = NULL;
 
@@ -956,7 +887,6 @@ error(OscarData *od, FlapConnection *con
 	aim_snac_t *snac2;
 	guint16 reason;
 	char *bn;
-	int was_explicit;
 
 	if (!(snac2 = aim_remsnac(od, snac->id))) {
 		purple_debug_misc("oscar", "locate error: received response from unknown request!\n");
@@ -978,15 +908,9 @@ error(OscarData *od, FlapConnection *con
 
 	reason = byte_stream_get16(bs);
 
-	/*
-	 * Remove this buddy name from our queue.  If the client requested
-	 * this buddy's info explicitly, then notify them that we do not have
-	 * info for this buddy.
-	 */
-	was_explicit = aim_locate_gotuserinfo(od, conn, bn);
-	if (was_explicit == TRUE)
-		if ((userfunc = aim_callhandler(od, snac->family, snac->subtype)))
-			ret = userfunc(od, conn, frame, reason, bn);
+	/* Notify the user that we do not have info for this buddy */
+	if ((userfunc = aim_callhandler(od, snac->family, snac->subtype)))
+		ret = userfunc(od, conn, frame, reason, bn);
 
 	if (snac2)
 		g_free(snac2->data);
@@ -1202,7 +1126,6 @@ userinfo(OscarData *od, FlapConnection *
 	aim_userinfo_t *userinfo, *userinfo2;
 	GSList *tlvlist;
 	aim_tlv_t *tlv = NULL;
-	int was_explicit;
 
 	userinfo = (aim_userinfo_t *)g_malloc(sizeof(aim_userinfo_t));
 	aim_info_extract(od, bs, userinfo);
@@ -1238,18 +1161,9 @@ userinfo(OscarData *od, FlapConnection *
 	aim_info_free(userinfo);
 	g_free(userinfo);
 
-	/*
-	 * Remove this buddy name from our queue.  If the client requested
-	 * this buddy's info explicitly, then notify them that we have info
-	 * for this buddy.
-	 */
-	if (userinfo2 != NULL)
-	{
-		was_explicit = aim_locate_gotuserinfo(od, conn, userinfo2->bn);
-		if (was_explicit == TRUE)
-			if ((userfunc = aim_callhandler(od, snac->family, snac->subtype)))
-				ret = userfunc(od, conn, frame, userinfo2);
-	}
+	/* Show the info to the user */
+	if (userinfo2 != NULL && ((userfunc = aim_callhandler(od, snac->family, snac->subtype))))
+		ret = userfunc(od, conn, frame, userinfo2);
 
 	return ret;
 }
============================================================
--- libpurple/protocols/oscar/oscar.c	1175725276226d66c8d2fa2d489eee441adf0cc2
+++ libpurple/protocols/oscar/oscar.c	508c6ad6260e1efa1cf019f46a123cbf59d8edc2
@@ -160,7 +160,6 @@ static int purple_parse_userinfo   (Osca
 static int purple_parse_misses     (OscarData *, FlapConnection *, FlapFrame *, ...);
 static int purple_parse_clientauto (OscarData *, FlapConnection *, FlapFrame *, ...);
 static int purple_parse_userinfo   (OscarData *, FlapConnection *, FlapFrame *, ...);
-static int purple_got_infoblock    (OscarData *, FlapConnection *, FlapFrame *, ...);
 static int purple_parse_motd       (OscarData *, FlapConnection *, FlapFrame *, ...);
 static int purple_chatnav_info     (OscarData *, FlapConnection *, FlapFrame *, ...);
 static int purple_conv_chat_join        (OscarData *, FlapConnection *, FlapFrame *, ...);
@@ -812,24 +811,24 @@ static void oscar_user_info_append_statu
 
 	od = purple_connection_get_protocol_data(gc);
 
-	if (userinfo == NULL)
-		userinfo = aim_locate_finduserinfo(od, purple_buddy_get_name(b));
-
-	if ((user_info == NULL) || ((b == NULL) && (userinfo == NULL)))
+	if (b == NULL && userinfo == NULL)
 		return;
 
 	if (b == NULL)
 		b = purple_find_buddy(purple_connection_get_account(gc), userinfo->bn);
+	else
+		userinfo = aim_locate_finduserinfo(od, purple_buddy_get_name(b));
 
 	if (b) {
 		presence = purple_buddy_get_presence(b);
 		status = purple_presence_get_active_status(presence);
+	}
 
-		message = g_strdup(purple_status_get_attr_string(status, "message"));
-		itmsurl = g_strdup(purple_status_get_attr_string(status, "itmsurl"));
-
-	} else {
-		/* This is an OSCAR contact for whom we don't have a PurpleBuddy but do have information. */
+	/* If we have both b and userinfo we favor userinfo, because if we're
+	   viewing someone's profile then we want the HTML away message, and
+	   the "message" attribute of the status contains only the plaintext
+	   message. */
+	if (userinfo) {
 		if ((userinfo->flags & AIM_FLAG_AWAY)) {
 			/* Away message? */
 			if ((userinfo->flags & AIM_FLAG_AWAY) && (userinfo->away_len > 0) && (userinfo->away != NULL) && (userinfo->away_encoding != NULL)) {
@@ -850,6 +849,9 @@ static void oscar_user_info_append_statu
 												 userinfo->itmsurl, userinfo->itmsurl_len);
 #endif
 		}
+	} else {
+		message = g_strdup(purple_status_get_attr_string(status, "message"));
+		itmsurl = g_strdup(purple_status_get_attr_string(status, "itmsurl"));
 	}
 
 	is_away = ((status && !purple_status_is_available(status)) ||
@@ -916,7 +918,6 @@ static void oscar_user_info_append_statu
 			g_free(message);
 			message = g_strdup(_("Offline"));
 		}
-
 	}
 
 	purple_notify_user_info_add_pair(user_info, _("Status"), message);
@@ -1478,7 +1479,6 @@ oscar_login(PurpleAccount *account)
 	oscar_data_addhandler(od, SNAC_FAMILY_LOCATE, SNAC_SUBTYPE_LOCATE_RIGHTSINFO, purple_parse_locaterights, 0);
 	oscar_data_addhandler(od, SNAC_FAMILY_LOCATE, SNAC_SUBTYPE_LOCATE_USERINFO, purple_parse_userinfo, 0);
 	oscar_data_addhandler(od, SNAC_FAMILY_LOCATE, SNAC_SUBTYPE_LOCATE_ERROR, purple_parse_locerr, 0);
-	oscar_data_addhandler(od, SNAC_FAMILY_LOCATE, SNAC_SUBTYPE_LOCATE_GOTINFOBLOCK, purple_got_infoblock, 0);
 	oscar_data_addhandler(od, SNAC_FAMILY_OSERVICE, 0x0001, purple_parse_genericerr, 0);
 	oscar_data_addhandler(od, SNAC_FAMILY_OSERVICE, 0x000f, purple_selfinfo, 0);
 	oscar_data_addhandler(od, SNAC_FAMILY_OSERVICE, 0x001f, purple_memrequest, 0);
@@ -2139,6 +2139,23 @@ static int purple_parse_oncoming(OscarDa
 	g_return_val_if_fail(info != NULL, 1);
 	g_return_val_if_fail(info->bn != NULL, 1);
 
+	/*
+	 * If this is an AIM buddy and their name has formatting, set their
+	 * server alias.
+	 */
+	if (!oscar_util_valid_name_icq(info->bn)) {
+		gboolean bn_has_formatting = FALSE;
+		char *c;
+		for (c = info->bn; *c != '\0'; c++) {
+			if (!islower(*c)) {
+				bn_has_formatting = TRUE;
+				break;
+			}
+		}
+		serv_got_alias(gc, info->bn,
+				bn_has_formatting ? info->bn : NULL);
+	}
+
 	if (info->present & AIM_USERINFO_PRESENT_FLAGS) {
 		if (info->flags & AIM_FLAG_AWAY)
 			buddy_is_away = TRUE;
@@ -3287,7 +3304,7 @@ static int purple_parse_userinfo(OscarDa
 	oscar_user_info_append_extra_info(gc, user_info, NULL, userinfo);
 
 	if ((userinfo->present & AIM_USERINFO_PRESENT_ONLINESINCE) && !oscar_util_valid_name_sms(userinfo->bn)) {
-		/* An SMS contact is always online; its Online Since valid is not useful */
+		/* An SMS contact is always online; its Online Since value is not useful */
 		time_t t = userinfo->onlinesince;
 		oscar_user_info_add_pair(user_info, _("Online Since"), purple_date_format_full(localtime(&t)));
 	}
@@ -3330,55 +3347,6 @@ static int purple_parse_userinfo(OscarDa
 	return 1;
 }
 
-static int purple_got_infoblock(OscarData *od, FlapConnection *conn, FlapFrame *fr, ...)
-{
-	PurpleConnection *gc = od->gc;
-	PurpleAccount *account = purple_connection_get_account(gc);
-	PurpleBuddy *b;
-	PurplePresence *presence;
-	PurpleStatus *status;
-	gchar *message = NULL;
-
-	va_list ap;
-	aim_userinfo_t *userinfo;
-
-	va_start(ap, fr);
-	userinfo = va_arg(ap, aim_userinfo_t *);
-	va_end(ap);
-
-	b = purple_find_buddy(account, userinfo->bn);
-	if (b == NULL)
-		return 1;
-
-	if (!oscar_util_valid_name_icq(userinfo->bn))
-	{
-		if (strcmp(purple_buddy_get_name(b), userinfo->bn) != 0)
-			serv_got_alias(gc, purple_buddy_get_name(b), userinfo->bn);
-		else
-			serv_got_alias(gc, purple_buddy_get_name(b), NULL);
-	}
-
-	presence = purple_buddy_get_presence(b);
-	status = purple_presence_get_active_status(presence);
-
-	if (purple_status_is_online(status) && !purple_status_is_available(status) &&
-			userinfo->flags & AIM_FLAG_AWAY && userinfo->away_len > 0 &&
-			userinfo->away != NULL && userinfo->away_encoding != NULL)
-	{
-		gchar *charset = oscar_encoding_extract(userinfo->away_encoding);
-		message = oscar_encoding_to_utf8(account, charset,
-		                                 userinfo->away,
-		                                 userinfo->away_len);
-		g_free(charset);
-		purple_prpl_got_user_status(account, userinfo->bn,
-				purple_status_get_id(status),
-				"message", message, NULL);
-		g_free(message);
-	}
-
-	return 1;
-}
-
 static int purple_parse_motd(OscarData *od, FlapConnection *conn, FlapFrame *fr, ...)
 {
 	char *msg;
============================================================
--- libpurple/protocols/oscar/oscar.h	afc493b61c08bb96f0ef1727db094427be0eb964
+++ libpurple/protocols/oscar/oscar.h	99102878d1c14ad9a0e1a6fdb5ce236ea69b9b22
@@ -533,7 +533,6 @@ struct _OscarData
 
 	struct {
 		struct aim_userinfo_s *userinfo;
-		struct userinfo_node *requested;
 	} locate;
 
 	/* Server-stored information (ssi) */
@@ -1133,7 +1132,6 @@ void aim_locate_dorequest(OscarData *od)
 /* 0x000f */ int aim_locate_setinterests(OscarData *od, const char *interest1, const char *interest2, const char *interest3, const char *interest4, const char *interest5, guint16 privacy);
 /* 0x0015 */ int aim_locate_getinfoshort(OscarData *od, const char *bn, guint32 flags);
 
-void aim_locate_autofetch_away_message(OscarData *od, const char *bn);
 guint32 aim_locate_getcaps(OscarData *od, ByteStream *bs, int len);
 guint32 aim_locate_getcaps_short(OscarData *od, ByteStream *bs, int len);
 void aim_info_free(aim_userinfo_t *);
============================================================
--- libpurple/protocols/oscar/snactypes.h	6c3223dfa8c30d7fbd92eddd12d18a44d3a956dd
+++ libpurple/protocols/oscar/snactypes.h	961c82c64542d5378012be00edee3b327babd45a
@@ -96,7 +96,6 @@
 #define SNAC_SUBTYPE_LOCATE_USERINFO 0x0006
 #define SNAC_SUBTYPE_LOCATE_WATCHERSUBREQ 0x0007
 #define SNAC_SUBTYPE_LOCATE_WATCHERNOT 0x0008
-#define SNAC_SUBTYPE_LOCATE_GOTINFOBLOCK 0xfffd
 #define SNAC_SUBTYPE_LOCATE_DEFAULT 0xffff
 
 /*


More information about the Commits mailing list