pidgin: 5c8a08b1: Check to see if we are already in a room...

sadrul at pidgin.im sadrul at pidgin.im
Sat May 3 23:30:43 EDT 2008


-----------------------------------------------------------------
Revision: 5c8a08b14b2889338776d85a99ee17e521f0abcd
Ancestor: 0c7cfe99ca83a1d8e6ef18d225db62eab6ea13a8
Author: sadrul at pidgin.im
Date: 2008-05-04T03:24:18
Branch: im.pidgin.pidgin
URL: http://d.pidgin.im/viewmtn/revision/info/5c8a08b14b2889338776d85a99ee17e521f0abcd

Modified files:
        finch/gntblist.c

ChangeLog: 

Check to see if we are already in a room before attempting to join. If
we are already in that room, then focus the conversation. This should
address the issue where finch doesn't play well when adding a chat in the
buddylist with auto-join turned on while already in that chat.

-------------- next part --------------
============================================================
--- finch/gntblist.c	ffe2495f02317998831ac3b55ed2fe601b7ee09e
+++ finch/gntblist.c	90bfc00688cbd11a5ded336714a9f0ba0f5bc587
@@ -644,6 +644,32 @@ static void
 }
 
 static void
+join_chat(PurpleChat *chat)
+{
+	PurpleAccount *account = purple_chat_get_account(chat);
+	const char *name;
+	PurpleConversation *conv;
+	const char *alias;
+
+	/* This hack here is to work around the fact that there's no good way of
+	 * getting the actual name of a chat. I don't understand why we return
+	 * the alias for a chat when all we want is the name. */
+	alias = chat->alias;
+	chat->alias = NULL;
+	name = purple_chat_get_name(chat);
+	conv = purple_find_conversation_with_account(
+			PURPLE_CONV_TYPE_CHAT, name, account);
+	chat->alias = (char *)alias;
+
+	if (!conv || purple_conv_chat_has_left(PURPLE_CONV_CHAT(conv))) {
+		serv_join_chat(purple_account_get_connection(account),
+				purple_chat_get_components(chat));
+	} else if (conv) {
+		purple_conversation_present(conv);
+	}
+}
+
+static void
 add_chat_cb(void *data, PurpleRequestFields *allfields)
 {
 	PurpleAccount *account;
@@ -682,8 +708,9 @@ add_chat_cb(void *data, PurpleRequestFie
 		purple_blist_add_chat(chat, grp, NULL);
 		purple_blist_alias_chat(chat, alias);
 		purple_blist_node_set_bool((PurpleBlistNode*)chat, "gnt-autojoin", autojoin);
-		if (autojoin)
-			serv_join_chat(purple_account_get_connection(purple_chat_get_account(chat)), purple_chat_get_components(chat));
+		if (autojoin) {
+			join_chat(chat);
+		}
 	}
 }
 
@@ -945,7 +972,7 @@ selection_activate(GntWidget *widget, Fi
 
 	if (!node)
 		return;
-	
+
 	if (PURPLE_BLIST_NODE_IS_CONTACT(node))
 		node = (PurpleBlistNode*)purple_contact_get_priority_buddy((PurpleContact*)node);
 
@@ -968,8 +995,7 @@ selection_activate(GntWidget *widget, Fi
 	}
 	else if (PURPLE_BLIST_NODE_IS_CHAT(node))
 	{
-		PurpleChat *chat = (PurpleChat*)node;
-		serv_join_chat(purple_account_get_connection(purple_chat_get_account(chat)), purple_chat_get_components(chat));
+		join_chat((PurpleChat*)node);
 	}
 }
 


More information about the Commits mailing list