changeset 20630:41dd71aa79d6

Another patch from Collin from ComBOTS Product GmbH. Now, if you change the alias for one of your buddies while signed in at another location it should update the alias in this location, as well. Fixes #3205.
author Mark Doliner <mark@kingant.net>
date Mon, 24 Sep 2007 00:40:20 +0000
parents 77fda34d4289
children 56cec2b6ff98
files libpurple/protocols/oscar/AUTHORS libpurple/protocols/oscar/family_feedbag.c libpurple/protocols/oscar/oscar.c
diffstat 3 files changed, 35 insertions(+), 24 deletions(-) [+]
line wrap: on
line diff
--- a/libpurple/protocols/oscar/AUTHORS	Sun Sep 23 22:17:15 2007 +0000
+++ b/libpurple/protocols/oscar/AUTHORS	Mon Sep 24 00:40:20 2007 +0000
@@ -1,3 +1,7 @@
+
+N: ComBOTS Product GmbH (htfv)
+T: 2007
+E: foss@combots.com
 
 N: Jonathan Clark
 T: 2005-2006
--- a/libpurple/protocols/oscar/family_feedbag.c	Sun Sep 23 22:17:15 2007 +0000
+++ b/libpurple/protocols/oscar/family_feedbag.c	Mon Sep 24 00:40:20 2007 +0000
@@ -1424,7 +1424,7 @@
 		aim_tlvlist_free(data);
 
 		if ((userfunc = aim_callhandler(od, snac->family, snac->subtype)))
-			ret = userfunc(od, conn, frame, type, name);
+			ret = userfunc(od, conn, frame, snac->subtype, type, name);
 
 		g_free(name);
 	}
@@ -1434,8 +1434,6 @@
 
 /*
  * Subtype 0x0009 - Incoming SSI mod.
- *
- * XXX - It would probably be good for the client to actually do something when it gets this.
  */
 static int parsemod(OscarData *od, FlapConnection *conn, aim_module_t *mod, FlapFrame *frame, aim_modsnac_t *snac, ByteStream *bs)
 {
@@ -1485,7 +1483,7 @@
 		}
 
 		if ((userfunc = aim_callhandler(od, snac->family, snac->subtype)))
-			ret = userfunc(od, conn, frame);
+			ret = userfunc(od, conn, frame, snac->subtype, type, name);
 
 		g_free(name);
 		aim_tlvlist_free(data);
--- a/libpurple/protocols/oscar/oscar.c	Sun Sep 23 22:17:15 2007 +0000
+++ b/libpurple/protocols/oscar/oscar.c	Mon Sep 24 00:40:20 2007 +0000
@@ -189,7 +189,7 @@
 static int purple_ssi_parserights  (OscarData *, FlapConnection *, FlapFrame *, ...);
 static int purple_ssi_parselist    (OscarData *, FlapConnection *, FlapFrame *, ...);
 static int purple_ssi_parseack     (OscarData *, FlapConnection *, FlapFrame *, ...);
-static int purple_ssi_parseadd     (OscarData *, FlapConnection *, FlapFrame *, ...);
+static int purple_ssi_parseaddmod  (OscarData *, FlapConnection *, FlapFrame *, ...);
 static int purple_ssi_authgiven    (OscarData *, FlapConnection *, FlapFrame *, ...);
 static int purple_ssi_authrequest  (OscarData *, FlapConnection *, FlapFrame *, ...);
 static int purple_ssi_authreply    (OscarData *, FlapConnection *, FlapFrame *, ...);
@@ -1220,7 +1220,7 @@
 	oscar_data_addhandler(od, SNAC_FAMILY_FEEDBAG, SNAC_SUBTYPE_FEEDBAG_RIGHTSINFO, purple_ssi_parserights, 0);
 	oscar_data_addhandler(od, SNAC_FAMILY_FEEDBAG, SNAC_SUBTYPE_FEEDBAG_LIST, purple_ssi_parselist, 0);
 	oscar_data_addhandler(od, SNAC_FAMILY_FEEDBAG, SNAC_SUBTYPE_FEEDBAG_SRVACK, purple_ssi_parseack, 0);
-	oscar_data_addhandler(od, SNAC_FAMILY_FEEDBAG, SNAC_SUBTYPE_FEEDBAG_ADD, purple_ssi_parseadd, 0);
+	oscar_data_addhandler(od, SNAC_FAMILY_FEEDBAG, SNAC_SUBTYPE_FEEDBAG_ADD, purple_ssi_parseaddmod, 0);
 	oscar_data_addhandler(od, SNAC_FAMILY_FEEDBAG, SNAC_SUBTYPE_FEEDBAG_RECVAUTH, purple_ssi_authgiven, 0);
 	oscar_data_addhandler(od, SNAC_FAMILY_FEEDBAG, SNAC_SUBTYPE_FEEDBAG_RECVAUTHREQ, purple_ssi_authrequest, 0);
 	oscar_data_addhandler(od, SNAC_FAMILY_FEEDBAG, SNAC_SUBTYPE_FEEDBAG_RECVAUTHREP, purple_ssi_authreply, 0);
@@ -4934,10 +4934,7 @@
 					b = purple_find_buddy_in_group(gc->account, curitem->name, g);
 					if (b) {
 						/* Get server stored alias */
-						if (alias_utf8) {
-							g_free(b->alias);
-							b->alias = g_strdup(alias_utf8);
-						}
+						purple_blist_alias_buddy(b, alias_utf8);
 					} else {
 						b = purple_buddy_new(gc->account, curitem->name, alias_utf8);
 
@@ -5081,16 +5078,23 @@
 	return 1;
 }
 
-static int purple_ssi_parseadd(OscarData *od, FlapConnection *conn, FlapFrame *fr, ...) {
-	PurpleConnection *gc = od->gc;
+static int
+purple_ssi_parseaddmod(OscarData *od, FlapConnection *conn, FlapFrame *fr, ...)
+{
+	PurpleConnection *gc;
+	PurpleAccount *account;
 	char *gname, *gname_utf8, *alias, *alias_utf8;
 	PurpleBuddy *b;
 	PurpleGroup *g;
 	va_list ap;
-	guint16 type;
+	guint16 snac_subtype, type;
 	const char *name;
 
+	gc = od->gc;
+	account = purple_connection_get_account(gc);
+
 	va_start(ap, fr);
+	snac_subtype = (guint16)va_arg(ap, int);
 	type = (guint16)va_arg(ap, int);
 	name = va_arg(ap, char *);
 	va_end(ap);
@@ -5099,7 +5103,7 @@
 		return 1;
 
 	gname = aim_ssi_itemlist_findparentname(od->ssi.local, name);
-	gname_utf8 = gname ? oscar_utf8_try_convert(gc->account, gname) : NULL;
+	gname_utf8 = gname ? oscar_utf8_try_convert(account, gname) : NULL;
 
 	alias = aim_ssi_getalias(od->ssi.local, gname, name);
 	if (alias != NULL)
@@ -5107,22 +5111,26 @@
 		if (g_utf8_validate(alias, -1, NULL))
 			alias_utf8 = g_strdup(alias);
 		else
-			alias_utf8 = oscar_utf8_try_convert(purple_connection_get_account(gc), alias);
+			alias_utf8 = oscar_utf8_try_convert(account, alias);
 	}
 	else
 		alias_utf8 = NULL;
-
-	b = purple_find_buddy(gc->account, name);
 	g_free(alias);
 
+	b = purple_find_buddy(account, name);
 	if (b) {
-		/* Get server stored alias */
-		if (alias_utf8) {
-			g_free(b->alias);
-			b->alias = g_strdup(alias_utf8);
-		}
-	} else {
-		b = purple_buddy_new(gc->account, name, alias_utf8);
+		/*
+		 * You're logged in somewhere else and you aliased one
+		 * of your buddies, so update our local buddy list with
+		 * the person's new alias.
+		 */
+		purple_blist_alias_buddy(b, alias_utf8);
+	} else if (snac_subtype == 0x0008) {
+		/*
+		 * You're logged in somewhere else and you added a buddy to
+		 * your server list, so add them to your local buddy list.
+		 */
+		b = purple_buddy_new(account, name, alias_utf8);
 
 		if (!(g = purple_find_group(gname_utf8 ? gname_utf8 : _("Orphans")))) {
 			g = purple_group_new(gname_utf8 ? gname_utf8 : _("Orphans"));
@@ -5133,6 +5141,7 @@
 				   "ssi: adding buddy %s to group %s to local list\n", name, gname_utf8 ? gname_utf8 : _("Orphans"));
 		purple_blist_add_buddy(b, NULL, g, NULL);
 	}
+
 	g_free(gname_utf8);
 	g_free(alias_utf8);