changeset 10869:3e43c132f151

[gaim-migrate @ 12556] We no longer call "serv_add_buddies" at log in. Any PRPL that relied on that should look through the buddy list itself and do whatever it needs to after calling gaim_connection_set_state(gc, GAIM_CONNECTED); committer: Tailor Script <tailor@pidgin.im>
author Mark Doliner <mark@kingant.net>
date Mon, 25 Apr 2005 03:55:11 +0000
parents 4a56b48dbaa6
children b75ce371c812
files src/connection.c src/protocols/gg/gg.c src/protocols/napster/napster.c src/protocols/silc/buddy.c src/protocols/silc/ops.c src/protocols/silc/silc.c src/protocols/silc/silcgaim.h src/util.h
diffstat 8 files changed, 110 insertions(+), 71 deletions(-) [+]
line wrap: on
line diff
--- a/src/connection.c	Mon Apr 25 03:41:16 2005 +0000
+++ b/src/connection.c	Mon Apr 25 03:55:11 2005 +0000
@@ -265,11 +265,9 @@
 	}
 
 	if (gc->state == GAIM_CONNECTED) {
-		GaimBlistNode *gnode,*cnode,*bnode;
 #if 0
 		GList *wins;
 #endif
-		GList *add_buds = NULL;
 		GaimAccount *account;
 		GaimPresence *presence;
 
@@ -311,32 +309,6 @@
 #endif
 		gaim_signal_emit(gaim_connections_get_handle(), "signed-on", gc);
 
-		/* let the prpl know what buddies we pulled out of the local list */
-		/* XXX - Remove this and let the prpl take care of it itself? */
-		for (gnode = gaim_get_blist()->root; gnode; gnode = gnode->next) {
-			if(!GAIM_BLIST_NODE_IS_GROUP(gnode))
-				continue;
-			for(cnode = gnode->child; cnode; cnode = cnode->next) {
-				if(!GAIM_BLIST_NODE_IS_CONTACT(cnode))
-					continue;
-				for(bnode = cnode->child; bnode; bnode = bnode->next) {
-					GaimBuddy *b;
-					if(!GAIM_BLIST_NODE_IS_BUDDY(bnode))
-						continue;
-
-					b = (GaimBuddy *)bnode;
-					if(b->account == gc->account) {
-						add_buds = g_list_append(add_buds, b);
-					}
-				}
-			}
-		}
-
-		if(add_buds) {
-			serv_add_buddies(gc, add_buds);
-			g_list_free(add_buds);
-		}
-
 		serv_set_permit_deny(gc);
 
 		update_keepalive(gc, TRUE);
--- a/src/protocols/gg/gg.c	Mon Apr 25 03:41:16 2005 +0000
+++ b/src/protocols/gg/gg.c	Mon Apr 25 03:55:11 2005 +0000
@@ -1,6 +1,6 @@
 /*
  * gaim - Gadu-Gadu Protocol Plugin
- * $Id: gg.c 12555 2005-04-25 03:41:16Z datallah $
+ * $Id: gg.c 12556 2005-04-25 03:55:11Z thekingant $
  *
  * Copyright (C) 2001 Arkadiusz Mi¶kiewicz <misiek@pld.ORG.PL>
  *
@@ -758,6 +758,49 @@
 	gg_free_event(e);
 }
 
+static void agg_send_buddylist(GaimConnection *gc)
+{
+	GaimBuddyList *blist;
+	GaimBlistNode *gnode, *cnode, *bnode;
+	GaimBuddy *buddy;
+	struct agg_data *gd = (struct agg_data *)gc->proto_data;
+	uin_t *userlist = NULL;
+	int userlist_size = 0;
+
+	if ((blist = gaim_get_blist()) != NULL)
+	{
+		for (gnode = blist->root; gnode != NULL; gnode = gnode->next)
+		{
+			if (!GAIM_BLIST_NODE_IS_GROUP(gnode))
+				continue;
+			for (cnode = gnode->child; cnode != NULL; cnode = cnode->next)
+			{
+				if (!GAIM_BLIST_NODE_IS_CONTACT(cnode))
+					continue;
+				for (bnode = cnode->child; bnode != NULL; bnode = bnode->next)
+				{
+					if (!GAIM_BLIST_NODE_IS_BUDDY(bnode))
+						continue;
+					buddy = (GaimBuddy *)bnode;
+					if (invalid_uin(buddy->name))
+						continue;
+					userlist_size++;
+					userlist = g_renew(uin_t, userlist, userlist_size);
+					userlist[userlist_size - 1] =
+					    (uin_t) strtol(buddy->name, (char **)NULL, 10);
+				}
+			}
+		}
+	}
+
+	if (userlist) {
+		gg_notify(gd->sess, userlist, userlist_size);
+		g_free(userlist);
+	}
+
+	agg_save_buddy_list(gc, NULL);
+}
+
 void login_callback(gpointer data, gint source, GaimInputCondition cond)
 {
 	GaimConnection *gc = data;
@@ -855,6 +898,9 @@
 		/* Our signon is complete */
 		gaim_connection_set_state(gc, GAIM_CONNECTED);
 
+		/* Send the server our buddy list */
+		agg_send_buddylist(gc);
+
 		break;
 	case GG_EVENT_CONN_FAILED:
 		gaim_input_remove(gc->inpa);
@@ -975,31 +1021,6 @@
 	agg_save_buddy_list(gc, NULL);
 }
 
-static void agg_add_buddies(GaimConnection *gc, GList *buddies, GList *groups)
-{
-	struct agg_data *gd = (struct agg_data *)gc->proto_data;
-	uin_t *userlist = NULL;
-	int userlist_size = 0;
-
-	while (buddies) {
-		GaimBuddy *buddy = buddies->data;
-		if (!invalid_uin(buddy->name)) {
-			userlist_size++;
-			userlist = g_renew(uin_t, userlist, userlist_size);
-			userlist[userlist_size - 1] =
-			    (uin_t) strtol(buddy->name, (char **)NULL, 10);
-		}
-		buddies = g_list_next(buddies);
-	}
-
-	if (userlist) {
-		gg_notify(gd->sess, userlist, userlist_size);
-		g_free(userlist);
-	}
-
-	agg_save_buddy_list(gc, NULL);
-}
-
 static void agg_buddy_free (GaimBuddy *buddy)
 {
     if (buddy->proto_data) {
@@ -1735,10 +1756,10 @@
 	agg_get_info,			/* get_info */
 	agg_set_status,			/* set_away */
 	NULL,						/* set_idle */
-	agg_change_passwd,		/* change_passwd */
-	agg_add_buddy,			/* add_buddy */
-	agg_add_buddies,		/* add_buddies */
-	agg_rem_buddy,			/* remove_buddy */
+	agg_change_passwd,			/* change_passwd */
+	agg_add_buddy,				/* add_buddy */
+	NULL,						/* add_buddies */
+	agg_rem_buddy,				/* remove_buddy */
 	NULL,						/* remove_buddies */
 	agg_permit_deny_dummy,		/* add_permit */
 	agg_permit_deny_dummy,		/* add_deny */
--- a/src/protocols/napster/napster.c	Mon Apr 25 03:41:16 2005 +0000
+++ b/src/protocols/napster/napster.c	Mon Apr 25 03:55:11 2005 +0000
@@ -147,12 +147,31 @@
 }
 
 /* 208 - MSG_CLIENT_ADD_HOTLIST_SEQ */
-static void nap_add_buddies(GaimConnection *gc, GList *buddies, GList *groups)
+static void nap_send_buddylist(GaimConnection *gc)
 {
-	while (buddies) {
-		GaimBuddy *buddy = buddies->data;
-		nap_write_packet(gc, 208, "%s", buddy->name);
-		buddies = buddies->next;
+	GaimBuddyList *blist;
+	GaimBlistNode *gnode, *cnode, *bnode;
+	GaimBuddy *buddy;
+
+	if ((blist = gaim_get_blist()) != NULL)
+	{
+		for (gnode = blist->root; gnode != NULL; gnode = gnode->next)
+		{
+			if (!GAIM_BLIST_NODE_IS_GROUP(gnode))
+				continue;
+			for (cnode = gnode->child; cnode != NULL; cnode = cnode->next)
+			{
+				if (!GAIM_BLIST_NODE_IS_CONTACT(cnode))
+					continue;
+				for (bnode = cnode->child; bnode != NULL; bnode = bnode->next)
+				{
+					if (!GAIM_BLIST_NODE_IS_BUDDY(bnode))
+						continue;
+					buddy = (GaimBuddy *)bnode;
+					nap_write_packet(gc, 208, "%s", buddy->name);
+				}
+			}
+		}
 	}
 }
 
@@ -278,6 +297,9 @@
 		/* Our signon is complete */
 		gaim_connection_set_state(gc, GAIM_CONNECTED);
 
+		/* Send the server our buddy list */
+		nap_send_buddylist(gc);
+
 		break;
 
 	case 201: /* MSG_SERVER_SEARCH_RESULT */
@@ -609,7 +631,7 @@
 	NULL,					/* set_idle */
 	NULL,					/* change_passwd */
 	nap_add_buddy,			/* add_buddy */
-	nap_add_buddies,		/* add_buddies */
+	NULL,					/* add_buddies */
 	nap_remove_buddy,		/* remove_buddy */
 	NULL,					/* remove_buddies */
 	NULL,					/* add_permit */
--- a/src/protocols/silc/buddy.c	Mon Apr 25 03:41:16 2005 +0000
+++ b/src/protocols/silc/buddy.c	Mon Apr 25 03:55:11 2005 +0000
@@ -1330,12 +1330,31 @@
 	silcgaim_add_buddy_i(gc, buddy, FALSE);
 }
 
-void silcgaim_add_buddies(GaimConnection *gc, GList *buddies, GList *groups)
+void silcgaim_send_buddylist(GaimConnection *gc)
 {
-	GList *curb = buddies;
-	while (curb != NULL) {
-		silcgaim_add_buddy_i(gc, curb->data, TRUE);
-		curb = curb->next;
+	GaimBuddyList *blist;
+	GaimBlistNode *gnode, *cnode, *bnode;
+	GaimBuddy *buddy;
+
+	if ((blist = gaim_get_blist()) != NULL)
+	{
+		for (gnode = blist->root; gnode != NULL; gnode = gnode->next)
+		{
+			if (!GAIM_BLIST_NODE_IS_GROUP(gnode))
+				continue;
+			for (cnode = gnode->child; cnode != NULL; cnode = cnode->next)
+			{
+				if (!GAIM_BLIST_NODE_IS_CONTACT(cnode))
+					continue;
+				for (bnode = cnode->child; bnode != NULL; bnode = bnode->next)
+				{
+					if (!GAIM_BLIST_NODE_IS_BUDDY(bnode))
+						continue;
+					buddy = (GaimBuddy *)bnode;
+					silcgaim_add_buddy_i(gc, buddy, TRUE);
+				}
+			}
+		}
 	}
 }
 
--- a/src/protocols/silc/ops.c	Mon Apr 25 03:41:16 2005 +0000
+++ b/src/protocols/silc/ops.c	Mon Apr 25 03:55:11 2005 +0000
@@ -1472,6 +1472,10 @@
 	case SILC_CLIENT_CONN_SUCCESS:
 	case SILC_CLIENT_CONN_SUCCESS_RESUME:
 		gaim_connection_set_state(gc, GAIM_CONNECTED);
+
+		/* Send the server our buddy list */
+		silcgaim_send_buddylist(gc);
+
 		g_unlink(silcgaim_session_file(gaim_account_get_username(sg->account)));
 
 		/* Send any UMODEs configured for account */
--- a/src/protocols/silc/silc.c	Mon Apr 25 03:41:16 2005 +0000
+++ b/src/protocols/silc/silc.c	Mon Apr 25 03:55:11 2005 +0000
@@ -1516,7 +1516,7 @@
 	silcgaim_idle_set,			/* set_idle */
 	silcgaim_change_passwd,		/* change_passwd */
 	silcgaim_add_buddy,			/* add_buddy */
-	silcgaim_add_buddies,		/* add_buddies */
+	NULL,						/* add_buddies */
 	silcgaim_remove_buddy,		/* remove_buddy */
 	NULL,						/* remove_buddies */
 	NULL,						/* add_permit */
--- a/src/protocols/silc/silcgaim.h	Mon Apr 25 03:41:16 2005 +0000
+++ b/src/protocols/silc/silcgaim.h	Mon Apr 25 03:55:11 2005 +0000
@@ -99,7 +99,7 @@
 				SilcVerifyPublicKey completion, void *context);
 GList *silcgaim_buddy_menu(GaimBuddy *buddy);
 void silcgaim_add_buddy(GaimConnection *gc, GaimBuddy *buddy, GaimGroup *group);
-void silcgaim_add_buddies(GaimConnection *gc, GList *buddies, GList *groups);
+void silcgaim_send_buddylist(GaimConnection *gc);
 void silcgaim_remove_buddy(GaimConnection *gc, GaimBuddy *buddy, GaimGroup *group);
 void silcgaim_buddy_keyagr_request(SilcClient client,
 				   SilcClientConnection conn,
--- a/src/util.h	Mon Apr 25 03:41:16 2005 +0000
+++ b/src/util.h	Mon Apr 25 03:55:11 2005 +0000
@@ -350,6 +350,7 @@
 
 /**
  * Returns the gaim settings directory in the user's home directory.
+ * This is usually ~/.gaim
  *
  * @return The gaim settings directory.
  *