diff src/protocols/novell/novell.c @ 9285:7a8aa87164ae

[gaim-migrate @ 10088] Ok I'm done. This started out as shx's patch to make add/remove buddy/buddies take GaimBuddy and GaimGroup's in various places. I think his diff was like 2000 lines and mine is like 5000. I tried to clean up blist.c a bit and make it more uniform. There are some more g_return_if_fail() checks. Removed some code that was deprecated--it's probably been long enough. Removed some #include <multi.h>'s. Make blist.xml saving happen on a timer, like prefs.xml and accounts.xml. Sorry if this doesn't merge cleanly with whatever you're doing. People should really test this a lot. committer: Tailor Script <tailor@pidgin.im>
author Mark Doliner <mark@kingant.net>
date Tue, 15 Jun 2004 02:37:27 +0000
parents 54fb1f466953
children b3bda982996b
line wrap: on
line diff
--- a/src/protocols/novell/novell.c	Tue Jun 15 01:17:16 2004 +0000
+++ b/src/protocols/novell/novell.c	Tue Jun 15 02:37:27 2004 +0000
@@ -2430,15 +2430,15 @@
 }
 
 static void
-novell_add_buddy(GaimConnection * gc, const char *name, GaimGroup * group)
+novell_add_buddy(GaimConnection * gc, GaimBuddy *buddy, GaimGroup * group)
 {
-	GaimBuddy *buddy;
 	NMFolder *folder = NULL;
 	NMContact *contact;
 	NMUser *user;
 	NMERR_T rc = NM_OK;
-
-	if (gc == NULL || name == NULL || group == NULL)
+	const char *alias;
+
+	if (gc == NULL || buddy == NULL || group == NULL)
 		return;
 
 	user = (NMUser *) gc->proto_data;
@@ -2446,21 +2446,17 @@
 		return;
 
 	contact = nm_create_contact();
-	nm_contact_set_dn(contact, name);
+	nm_contact_set_dn(contact, buddy->name);
 
 	/* Remove the GaimBuddy (we will add it back after adding it
 	 * to the server side list). Save the alias if there is one.
 	 */
-	buddy = gaim_find_buddy_in_group(user->client_data, name, group);
-	if (buddy) {
-		const char *alias = gaim_get_buddy_alias(buddy);
-
-		if (alias && strcmp(alias, name))
-			nm_contact_set_display_name(contact, gaim_get_buddy_alias(buddy));
-		gaim_blist_remove_buddy(buddy);
-		buddy = NULL;
-	}
-
+	alias = gaim_get_buddy_alias(buddy);
+	if (alias && strcmp(alias, buddy->name))
+		nm_contact_set_display_name(contact, alias);
+
+	gaim_blist_remove_buddy(buddy);
+	buddy = NULL;
 
 	folder = nm_find_folder(user, group->name);
 	if (folder) {
@@ -2481,7 +2477,7 @@
 }
 
 static void
-novell_remove_buddy(GaimConnection * gc, const char *name, const char *group_name)
+novell_remove_buddy(GaimConnection * gc, GaimBuddy *buddy, GaimGroup *group)
 {
 	NMContact *contact;
 	NMFolder *folder;
@@ -2489,13 +2485,13 @@
 	const char *dn;
 	NMERR_T rc = NM_OK;
 
-	if (gc == NULL || name == NULL || group_name == NULL)
+	if (gc == NULL || buddy == NULL || group == NULL)
 		return;
 
 	user = (NMUser *) gc->proto_data;
-	if (user && (dn = nm_lookup_dn(user, name))) {
-
-		folder = nm_find_folder(user, group_name);
+	if (user && (dn = nm_lookup_dn(user, buddy->name))) {
+
+		folder = nm_find_folder(user, group->name);
 		if (folder) {
 			contact = nm_folder_find_contact(folder, dn);
 			if (contact) {
@@ -2513,17 +2509,17 @@
 }
 
 static void
-novell_remove_group(GaimConnection * gc, const char *name)
+novell_remove_group(GaimConnection * gc, GaimGroup *group)
 {
 	NMUser *user;
 	NMERR_T rc = NM_OK;
 
-	if (gc == NULL || name == NULL)
+	if (gc == NULL || group == NULL)
 		return;
 
 	user = (NMUser *) gc->proto_data;
 	if (user) {
-		NMFolder *folder = nm_find_folder(user, name);
+		NMFolder *folder = nm_find_folder(user, group->name);
 
 		if (folder) {
 			rc = nm_send_remove_folder(user, folder,
@@ -2632,21 +2628,21 @@
 
 static void
 novell_rename_group(GaimConnection * gc, const char *old_name,
-					const char *new_name, GList * tobemoved)
+					GaimGroup *group, GList *moved_buddies)
 {
 	NMERR_T rc = NM_OK;
 	NMFolder *folder;
 	NMUser *user;
 
-	if (gc == NULL || old_name == NULL || new_name == NULL || tobemoved == NULL) {
+	if (gc == NULL || old_name == NULL || group == NULL || moved_buddies == NULL) {
 		return;
 	}
 
 	user = gc->proto_data;
 	if (user) {
 		/* Does new folder exist already? */
-		if (nm_find_folder(user, new_name)) {
-			/* Gaim currently calls novell_group_buddy() for
+		if (nm_find_folder(user, group->name)) {
+			/* Gaim currently calls novell_group_buddy()
 			 * for all buddies in the group, so we don't
 			 * need to worry about this situation.
 			 */
@@ -2656,7 +2652,7 @@
 		folder = nm_find_folder(user, old_name);
 
 		if (folder) {
-			rc = nm_send_rename_folder(user, folder, new_name,
+			rc = nm_send_rename_folder(user, folder, group->name,
 									   _rename_folder_resp_cb, NULL);
 			_check_for_disconnect(user, rc);
 		}