changeset 25331:7bfaa0b61a83

propagate from branch 'im.pidgin.pidgin' (head 42f77b0e8b8ebf5ff3c30d8f8022ac5d289631e8) to branch 'im.pidgin.cpw.darkrain42.buddy-add' (head c29b3b2fa5d4e173fd9e476cfbb5a34cfc537b99)
author Paul Aurich <paul@darkrain42.org>
date Sat, 17 Jan 2009 22:42:28 +0000
parents 8a5c0c5c71f9 (current diff) 300cf4e16720 (diff)
children c02da09b567f
files libpurple/protocols/myspace/myspace.c libpurple/protocols/novell/novell.c libpurple/protocols/oscar/oscar.c pidgin/gtkblist.c
diffstat 12 files changed, 93 insertions(+), 39 deletions(-) [+]
line wrap: on
line diff
--- a/finch/gntblist.c	Thu Jan 15 03:56:58 2009 +0000
+++ b/finch/gntblist.c	Sat Jan 17 22:42:28 2009 +0000
@@ -643,10 +643,14 @@
 		purple_blist_add_group(grp, NULL);
 	}
 
-	/* XXX: Ask if there's already the same buddy in the same group (#4553) */
-
-	buddy = purple_buddy_new(account, username, alias);
-	purple_blist_add_buddy(buddy, NULL, grp, NULL);
+	/* XXX: Ask to merge if there's already a buddy with the same alias in the same group (#4553) */
+
+	if ((buddy = purple_find_buddy_in_group(account, username, grp)) == NULL)
+	{
+		buddy = purple_buddy_new(account, username, alias);
+		purple_blist_add_buddy(buddy, NULL, grp, NULL);
+	}
+
 	purple_account_add_buddy(account, buddy);
 }
 
--- a/libpurple/protocols/irc/irc.c	Thu Jan 15 03:56:58 2009 +0000
+++ b/libpurple/protocols/irc/irc.c	Sat Jan 17 22:42:28 2009 +0000
@@ -565,7 +565,7 @@
 	struct irc_conn *irc = (struct irc_conn *)gc->proto_data;
 	struct irc_buddy *ib = g_new0(struct irc_buddy, 1);
 	ib->name = g_strdup(buddy->name);
-	g_hash_table_insert(irc->buddies, ib->name, ib);
+	g_hash_table_replace(irc->buddies, ib->name, ib);
 
 	/* if the timer isn't set, this is during signon, so we don't want to flood
 	 * ourself off with ISON's, so we don't, but after that we want to know when
--- a/libpurple/protocols/myspace/myspace.c	Thu Jan 15 03:56:58 2009 +0000
+++ b/libpurple/protocols/myspace/myspace.c	Sat Jan 17 22:42:28 2009 +0000
@@ -386,7 +386,7 @@
 
 	g_return_val_if_fail(buddy != NULL, NULL);
 
-	user = msim_get_user_from_buddy(buddy);
+	user = msim_get_user_from_buddy(buddy, TRUE);
 
 	session = (MsimSession *)buddy->account->gc->proto_data;
 	g_return_val_if_fail(MSIM_SESSION_VALID(session), NULL);
@@ -431,7 +431,7 @@
 	g_return_if_fail(buddy != NULL);
 	g_return_if_fail(user_info != NULL);
 
-	user = msim_get_user_from_buddy(buddy);
+	user = msim_get_user_from_buddy(buddy, TRUE);
 
 	if (PURPLE_BUDDY_IS_ONLINE(buddy)) {
 		MsimSession *session;
@@ -1046,7 +1046,7 @@
 	g_free(display_name);
 
 	/* 3. Update buddy information */
-	user = msim_get_user_from_buddy(buddy);
+	user = msim_get_user_from_buddy(buddy, TRUE);
 
 	user->id = uid;
 	/* Keep track of the user ID across sessions */
@@ -1372,7 +1372,7 @@
 		buddy = purple_buddy_new(session->account, username, NULL);
 		purple_blist_add_buddy(buddy, NULL, NULL, NULL);
 
-		user = msim_get_user_from_buddy(buddy);
+		user = msim_get_user_from_buddy(buddy, TRUE);
 		user->id = msim_msg_get_integer(msg, "f");
 
 		/* Keep track of the user ID across sessions */
@@ -2632,6 +2632,10 @@
 	MsimMessage *body;
 
 	session = (MsimSession *)gc->proto_data;
+
+	if (msim_get_user_from_buddy(buddy, FALSE) != NULL)
+		return;
+
 	purple_debug_info("msim", "msim_add_buddy: want to add %s to %s\n",
 			buddy->name, (group && group->name) ? group->name : "(no group)");
 
--- a/libpurple/protocols/myspace/user.c	Thu Jan 15 03:56:58 2009 +0000
+++ b/libpurple/protocols/myspace/user.c	Sat Jan 17 22:42:28 2009 +0000
@@ -41,10 +41,10 @@
 }
 
 /**
- * Get the MsimUser from a PurpleBuddy, creating it if needed.
+ * Get the MsimUser from a PurpleBuddy, optionally creating it if needed.
  */
 MsimUser *
-msim_get_user_from_buddy(PurpleBuddy *buddy)
+msim_get_user_from_buddy(PurpleBuddy *buddy, gboolean create)
 {
 	MsimUser *user;
 
@@ -52,17 +52,17 @@
 		return NULL;
 	}
 
-	if (!buddy->proto_data) {
+	if (create && !buddy->proto_data) {
 		/* No MsimUser for this buddy; make one. */
 
 		user = g_new0(MsimUser, 1);
 		user->buddy = buddy;
 		user->id = purple_blist_node_get_int((PurpleBlistNode*)buddy, "UserID");
 		buddy->proto_data = (gpointer)user;
+	} else {
+		user = (MsimUser *)(buddy->proto_data);
 	}
 
-	user = (MsimUser *)(buddy->proto_data);
-
 	return user;
 }
 
@@ -97,7 +97,7 @@
 		return NULL;
 	}
 
-	user = msim_get_user_from_buddy(buddy);
+	user = msim_get_user_from_buddy(buddy, TRUE);
 
 	return user;
 }
--- a/libpurple/protocols/myspace/user.h	Thu Jan 15 03:56:58 2009 +0000
+++ b/libpurple/protocols/myspace/user.h	Sat Jan 17 22:42:28 2009 +0000
@@ -46,7 +46,7 @@
  * initiated from a user lookup. */
 typedef void (*MSIM_USER_LOOKUP_CB)(MsimSession *session, const MsimMessage *userinfo, gpointer data);
 
-MsimUser *msim_get_user_from_buddy(PurpleBuddy *buddy);
+MsimUser *msim_get_user_from_buddy(PurpleBuddy *buddy, gboolean create);
 void msim_user_free(MsimUser *user);
 MsimUser *msim_find_user(MsimSession *session, const gchar *username);
 void msim_append_user_info(MsimSession *session, PurpleNotifyUserInfo *user_info, MsimUser *user, gboolean full);
--- a/libpurple/protocols/novell/novell.c	Thu Jan 15 03:56:58 2009 +0000
+++ b/libpurple/protocols/novell/novell.c	Sat Jan 17 22:42:28 2009 +0000
@@ -2553,6 +2553,10 @@
 	if (!user->clist_synched)
 		return;
 
+	/* Don't re-add a buddy that is already on our contact list */
+	if (nm_find_user_record(user, buddy->name) != NULL)
+		return;
+
 	contact = nm_create_contact();
 	nm_contact_set_dn(contact, buddy->name);
 
--- a/libpurple/protocols/oscar/oscar.c	Thu Jan 15 03:56:58 2009 +0000
+++ b/libpurple/protocols/oscar/oscar.c	Sat Jan 17 22:42:28 2009 +0000
@@ -4813,19 +4813,26 @@
 		return;
 	}
 
-	if ((od->ssi.received_data) && !(aim_ssi_itemlist_finditem(od->ssi.local, group->name, buddy->name, AIM_SSI_TYPE_BUDDY))) {
-		purple_debug_info("oscar",
-				   "ssi: adding buddy %s to group %s\n", buddy->name, group->name);
-		aim_ssi_addbuddy(od, buddy->name, group->name, NULL, purple_buddy_get_alias_only(buddy), NULL, NULL, 0);
-
-		/* Mobile users should always be online */
-		if (buddy->name[0] == '+') {
-			purple_prpl_got_user_status(account,
-					purple_buddy_get_name(buddy),
-					OSCAR_STATUS_ID_AVAILABLE, NULL);
-			purple_prpl_got_user_status(account,
-					purple_buddy_get_name(buddy),
-					OSCAR_STATUS_ID_MOBILE, NULL);
+	if (od->ssi.received_data) {
+		if (!aim_ssi_itemlist_finditem(od->ssi.local, group->name, buddy->name, AIM_SSI_TYPE_BUDDY)) {
+			purple_debug_info("oscar",
+					   "ssi: adding buddy %s to group %s\n", buddy->name, group->name);
+			aim_ssi_addbuddy(od, buddy->name, group->name, NULL, purple_buddy_get_alias_only(buddy), NULL, NULL, 0);
+
+			/* Mobile users should always be online */
+			if (buddy->name[0] == '+') {
+				purple_prpl_got_user_status(account,
+						purple_buddy_get_name(buddy),
+						OSCAR_STATUS_ID_AVAILABLE, NULL);
+				purple_prpl_got_user_status(account,
+						purple_buddy_get_name(buddy),
+						OSCAR_STATUS_ID_MOBILE, NULL);
+			}
+		} else if (aim_ssi_waitingforauth(od->ssi.local,
+		                                  aim_ssi_itemlist_findparentname(od->ssi.local, purple_buddy_get_name(buddy)),
+		                                  purple_buddy_get_name(buddy))) {
+			/* Not authorized -- Re-request authorization */
+			purple_auth_sendrequest(gc, purple_buddy_get_name(buddy));
 		}
 	}
 
--- a/libpurple/protocols/silc/buddy.c	Thu Jan 15 03:56:58 2009 +0000
+++ b/libpurple/protocols/silc/buddy.c	Sat Jan 17 22:42:28 2009 +0000
@@ -1390,7 +1390,12 @@
 
 void silcpurple_add_buddy(PurpleConnection *gc, PurpleBuddy *buddy, PurpleGroup *group)
 {
-	silcpurple_add_buddy_i(gc, buddy, FALSE);
+	/* Don't add if the buddy is already on the list.
+	 *
+	 * SILC doesn't have groups, so we also don't need to do anything
+	 * for a move. */
+	if (buddy->proto_data == NULL)
+		silcpurple_add_buddy_i(gc, buddy, FALSE);
 }
 
 void silcpurple_send_buddylist(PurpleConnection *gc)
--- a/libpurple/protocols/silc10/buddy.c	Thu Jan 15 03:56:58 2009 +0000
+++ b/libpurple/protocols/silc10/buddy.c	Sat Jan 17 22:42:28 2009 +0000
@@ -1390,7 +1390,12 @@
 
 void silcpurple_add_buddy(PurpleConnection *gc, PurpleBuddy *buddy, PurpleGroup *group)
 {
-	silcpurple_add_buddy_i(gc, buddy, FALSE);
+	/* Don't add if the buddy is already on the list.
+	 *
+	 * SILC doesn't have groups, so we don't need to do anything
+	 * for a move. */
+	if (buddy->proto_data == NULL)
+		silcpurple_add_buddy_i(gc, buddy, FALSE);
 }
 
 void silcpurple_send_buddylist(PurpleConnection *gc)
--- a/libpurple/prpl.h	Thu Jan 15 03:56:58 2009 +0000
+++ b/libpurple/prpl.h	Sat Jan 17 22:42:28 2009 +0000
@@ -294,6 +294,14 @@
 	void (*set_idle)(PurpleConnection *, int idletime);
 	void (*change_passwd)(PurpleConnection *, const char *old_pass,
 						  const char *new_pass);
+	/**
+	 * Add a buddy to a group on the server.
+	 *
+	 * This PRPL function may be called in situations in which the buddy is
+	 * already in the specified group. If the protocol supports
+	 * authorization and the user is not already authorized to see the
+	 * status of \a buddy, \a add_buddy should request authorization.
+	 */
 	void (*add_buddy)(PurpleConnection *, PurpleBuddy *buddy, PurpleGroup *group);
 	void (*add_buddies)(PurpleConnection *, GList *buddies, GList *groups);
 	void (*remove_buddy)(PurpleConnection *, PurpleBuddy *buddy, PurpleGroup *group);
--- a/pidgin/gtkblist.c	Thu Jan 15 03:56:58 2009 +0000
+++ b/pidgin/gtkblist.c	Sat Jan 17 22:42:28 2009 +0000
@@ -6496,14 +6496,27 @@
 			whoalias = NULL;
 
 		g = NULL;
-		if ((grp != NULL) && (*grp != '\0') && ((g = purple_find_group(grp)) == NULL))
+		if ((grp != NULL) && (*grp != '\0'))
 		{
-			g = purple_group_new(grp);
-			purple_blist_add_group(g, NULL);
+			if ((g = purple_find_group(grp)) == NULL)
+			{
+				g = purple_group_new(grp);
+				purple_blist_add_group(g, NULL);
+			}
+
+			b = purple_find_buddy_in_group(data->account, who, g);
 		}
-
-		b = purple_buddy_new(data->account, who, whoalias);
-		purple_blist_add_buddy(b, NULL, g, NULL);
+		else if ((b = purple_find_buddy(data->account, who)) != NULL)
+		{
+				g = purple_buddy_get_group(b);
+		}
+
+		if (b == NULL)
+		{
+			b = purple_buddy_new(data->account, who, whoalias);
+			purple_blist_add_buddy(b, NULL, g, NULL);
+		}
+
 		purple_account_add_buddy(data->account, b);
 
 		/* Offer to merge people with the same alias. */
--- a/pidgin/plugins/gevolution/gevo-util.c	Thu Jan 15 03:56:58 2009 +0000
+++ b/pidgin/plugins/gevolution/gevo-util.c	Sat Jan 17 22:42:28 2009 +0000
@@ -41,8 +41,12 @@
 		purple_blist_add_group(group, NULL);
 	}
 
-	buddy = purple_buddy_new(account, screenname, alias);
-	purple_blist_add_buddy(buddy, NULL, group, NULL);
+	if ((buddy = purple_find_buddy_in_group(account, screenname, group)) == NULL)
+	{
+		buddy = purple_buddy_new(account, screenname, alias);
+		purple_blist_add_buddy(buddy, NULL, group, NULL);
+	}
+
 	purple_account_add_buddy(account, buddy);
 
 	if (conv != NULL)