changeset 27581:13bacaad01aa

merge of '1423db68fabc512bc2005d658eb078fc65bd6fba' and '14624d95d88444c69810193d3cddea741c692fea'
author Paul Aurich <paul@darkrain42.org>
date Thu, 16 Jul 2009 17:07:08 +0000
parents eeeb82903ef8 (diff) 8dc4e726f8f7 (current diff)
children db0be613925b b84f51988365
files
diffstat 1 files changed, 28 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/libpurple/protocols/yahoo/yahoochat.c	Thu Jul 16 11:08:10 2009 +0000
+++ b/libpurple/protocols/yahoo/yahoochat.c	Thu Jul 16 17:07:08 2009 +0000
@@ -121,12 +121,29 @@
 	char *msg = NULL;
 	GString *members = NULL;
 	GHashTable *components;
+	PurpleConversation *c = NULL;
 
-	if (pkt->status == 2)
-		return; /* XXX */
+	if ( (pkt->status == 2) || (pkt->status == 11) )
+		return; /* Status is 11 when we are being notified about invitation being sent to someone else */
 
 	account = purple_connection_get_account(gc);
 
+	for (l = pkt->hash; l; l = l->next) {
+		struct yahoo_pair *pair = l->data;
+		if (pair->key == 57)
+		{
+			room = yahoo_string_decode(gc, pair->value, FALSE);
+			if((c = yahoo_find_conference(gc, room)))
+			{
+				/* Looks like we got invited to an already open conference. */
+				/* Laters: Should we accept this conference rather than ignoring the invitation ? */
+				purple_debug_info("yahoo","Ignoring invitation for an already existing chat, room:%s\n",room);
+				g_free(room);
+				return;
+			}
+		}
+	}
+
 	members = g_string_sized_new(512);
 
 	for (l = pkt->hash; l; l = l->next) {
@@ -143,8 +160,11 @@
 			who = pair->value;
 			g_string_append_printf(members, "%s\n", who);
 			break;
-		case 52: /* invitee (me) */
-		case 53: /* members */
+		case 51: /* This user is being invited to the conference. Comes with status = 11, so we wont reach here */
+			break;
+		case 52: /* Invited users. Assuming us invited, since we got this packet */
+			break; /* break needed, or else we add the users to the conference before they accept the invitation */
+		case 53: /* members who have already joined the conference */
 			g_string_append_printf(members, "%s\n", pair->value);
 			break;
 		case 58:
@@ -254,7 +274,10 @@
 	if (who && room) {
 		c = yahoo_find_conference(gc, room);
 		if (c)
-			yahoo_chat_add_user(PURPLE_CONV_CHAT(c), who, NULL);
+		{	/* Prevent duplicate users in the chat */
+			if( !purple_conv_chat_find_user(PURPLE_CONV_CHAT(c), who) )
+				yahoo_chat_add_user(PURPLE_CONV_CHAT(c), who, NULL);
+		}
 		g_free(room);
 	}
 }