changeset 4292:78a3d2caf84c

[gaim-migrate @ 4545] Better alias synchronization, as well as a rare crash fix (when changing the alias of buddies that you are awaiting authorization from). I'll get rid of those annoying auth dialogs at signon tomorrow. I hope. committer: Tailor Script <tailor@pidgin.im>
author Mark Doliner <mark@kingant.net>
date Sat, 11 Jan 2003 08:40:25 +0000
parents 7d3c552c4a89
children 79d871c11eb9
files src/protocols/oscar/oscar.c src/protocols/oscar/ssi.c
diffstat 2 files changed, 28 insertions(+), 18 deletions(-) [+]
line wrap: on
line diff
--- a/src/protocols/oscar/oscar.c	Sat Jan 11 08:22:26 2003 +0000
+++ b/src/protocols/oscar/oscar.c	Sat Jan 11 08:40:25 2003 +0000
@@ -4124,10 +4124,11 @@
 		switch (curitem->type) {
 			case 0x0000: { /* Buddy */
 				if (curitem->name) {
-					char *gname = aim_ssi_itemlist_findparentname(od->sess->ssi.local, curitem->name);
+					char *gname = aim_ssi_itemlist_findparentname(sess->ssi.local, curitem->name);
 					char *alias = aim_ssi_getalias(sess->ssi.local, gname, curitem->name);
 					struct buddy *buddy = find_buddy(gc, curitem->name);
 					if (buddy) {
+						/* Get server stored alias */
 						if (alias)
 							strcpy(buddy->alias, alias);
 					} else {
@@ -4205,11 +4206,20 @@
 		cur = gc->groups;
 		while (cur) {
 			GSList *curbud;
-			for (curbud=((struct group*)cur->data)->members; curbud; curbud=curbud->next)
-				if (!aim_ssi_itemlist_exists(sess->ssi.local, ((struct buddy*)curbud->data)->name)) {
+			for (curbud=((struct group*)cur->data)->members; curbud; curbud=curbud->next) {
+				struct buddy *buddy = curbud->data;
+				char *gname = aim_ssi_itemlist_findparentname(sess->ssi.local, buddy->name);
+				char *alias = aim_ssi_getalias(sess->ssi.local, gname, buddy->name);
+				if (aim_ssi_itemlist_exists(sess->ssi.local, buddy->name)) {
+					/* Store local alias on server */
+					if (!alias && buddy->alias[0])
+						aim_ssi_aliasbuddy(sess, od->conn, gname, buddy->name, buddy->alias);
+				} else {
 					debug_printf("ssi: adding buddy %s from local list to server list\n", ((struct buddy*)curbud->data)->name);
-					aim_ssi_addbuddy(od->sess, od->conn, ((struct buddy*)curbud->data)->name, ((struct group*)cur->data)->name, get_buddy_alias_only((struct buddy *)curbud->data), NULL, NULL, 0);
+					aim_ssi_addbuddy(sess, od->conn, buddy->name, ((struct group*)cur->data)->name, get_buddy_alias_only((struct buddy *)curbud->data), NULL, NULL, 0);
 				}
+				free(alias);
+			}
 			cur = g_slist_next(cur);
 		}
 
@@ -4218,7 +4228,7 @@
 			for (cur=gc->permit; cur; cur=cur->next)
 				if (!aim_ssi_itemlist_finditem(sess->ssi.local, NULL, cur->data, AIM_SSI_TYPE_PERMIT)) {
 					debug_printf("ssi: adding permit %s from local list to server list\n", (char *)cur->data);
-					aim_ssi_addpermit(od->sess, od->conn, cur->data);
+					aim_ssi_addpermit(sess, od->conn, cur->data);
 				}
 		}
 
@@ -4227,7 +4237,7 @@
 			for (cur=gc->deny; cur; cur=cur->next)
 				if (!aim_ssi_itemlist_finditem(sess->ssi.local, NULL, cur->data, AIM_SSI_TYPE_DENY)) {
 					debug_printf("ssi: adding deny %s from local list to server list\n", (char *)cur->data);
-					aim_ssi_adddeny(od->sess, od->conn, cur->data);
+					aim_ssi_adddeny(sess, od->conn, cur->data);
 				}
 		}
 
--- a/src/protocols/oscar/ssi.c	Sat Jan 11 08:22:26 2003 +0000
+++ b/src/protocols/oscar/ssi.c	Sat Jan 11 08:40:25 2003 +0000
@@ -1410,17 +1410,17 @@
 				cur->item = NULL;
 
 			} else if (cur->action == AIM_CB_SSI_MOD) {
-				/* Replace the official item with the item in the local list */
+				/* Replace the local item with the item from the official list */
 				struct aim_ssi_item *cur1;
-				if ((cur1 = aim_ssi_itemlist_find(sess->ssi.local, cur->item->gid, cur->item->bid))) {
-					free(cur1->name);
-					if (cur->item->name) {
-						cur1->name = (char *)malloc((strlen(cur->item->name)+1)*sizeof(char));
-						strcpy(cur1->name, cur->item->name);
+				if ((cur1 = aim_ssi_itemlist_find(sess->ssi.official, cur->item->gid, cur->item->bid))) {
+					free(cur->item->name);
+					if (cur1->name) {
+						cur->item->name = (char *)malloc((strlen(cur1->name)+1)*sizeof(char));
+						strcpy(cur->item->name, cur1->name);
 					} else
-						cur1->name = NULL;
-					aim_freetlvchain(&cur1->data);
-					cur1->data = aim_tlvlist_copy(cur->item->data);
+						cur->item->name = NULL;
+					aim_freetlvchain(&cur->item->data);
+					cur->item->data = aim_tlvlist_copy(cur1->data);
 				}
 
 			} else if (cur->action == AIM_CB_SSI_DEL) {
@@ -1431,11 +1431,11 @@
 		} else {
 			/* Do the exact opposite */
 			if (cur->action == AIM_CB_SSI_ADD) {
-				/* Add the item to the official list */
+				/* Add the local item to the official list */
 				aim_ssi_itemlist_add(&sess->ssi.official, cur->item->name, cur->item->gid, cur->item->bid, cur->item->type, cur->item->data);
 
 			} else if (cur->action == AIM_CB_SSI_MOD) {
-				/* Replace the old item with the new item in the items list */
+				/* Replace the official item with the item from the local list */
 				struct aim_ssi_item *cur1;
 				if ((cur1 = aim_ssi_itemlist_find(sess->ssi.official, cur->item->gid, cur->item->bid))) {
 					free(cur1->name);
@@ -1449,7 +1449,7 @@
 				}
 
 			} else if (cur->action == AIM_CB_SSI_DEL) {
-				/* Remove the item from the items list */
+				/* Remove the item from the official list */
 				aim_ssi_itemlist_del(&sess->ssi.official, cur->item);
 				cur->item = NULL;
 			}