RES: Chat

Sadrul Habib Chowdhury imadil at gmail.com
Fri Dec 28 07:21:00 EST 2007


* Rafael Franco Carvalho had this to say on [28 Dec 2007, 08:52:05 -0200]:
> 
> Hi Sean,
> 
> >libpurple gives certain meanings to these terms: a 'chat' refers to a
> >multi-user chat, or conference, and an account is an IM account
> >belonging to the local user. By these definitions, you're saying that
> >a Pidgin user can only have his MSN account in one multi-user chat at
> >a time. Is that what you mean?
> 
> Yes, I mean exactly you said above. If you look Evan Schoenberg's e-mail
> you'll see a better explanation of this behavior: "A single multi-user chat
> entitled 'MSN Chat' ends up getting all messages for all joined multi-user
> chats."
> 

It looks like we always try to create a chat with the same name ('MSN
Chat'), which confuses purple. The fix would be to create a chat with a
different name each time. Either of the attached patches will work
around the bug on most occasions, I think. But I am not sure how the
change in server.c will affect the other prpls, and the change in msn.c
is very ugly ... I don't like either of the patches. Perhaps you can
find a cleaner fix? :)

Sadrul
-------------- next part --------------
#
# old_revision [e7dd3b30ece9f95dd95249583812659312c457e6]
#
# patch "libpurple/protocols/msn/msn.c"
#  from [bb0de7cd52ec8ed9aa827db242e84131973de907]
#    to [a1100ff6bea6aaca65a491bbcdc552e437fc5e13]
#
============================================================
--- libpurple/protocols/msn/msn.c	bb0de7cd52ec8ed9aa827db242e84131973de907
+++ libpurple/protocols/msn/msn.c	a1100ff6bea6aaca65a491bbcdc552e437fc5e13
@@ -445,6 +445,8 @@ initiate_chat_cb(PurpleBlistNode *node, 
 {
 	PurpleBuddy *buddy;
 	PurpleConnection *gc;
+	char name[128];
+	static int count = 0;
 
 	MsnSession *session;
 	MsnSwitchBoard *swboard;
@@ -462,7 +464,8 @@ initiate_chat_cb(PurpleBlistNode *node, 
 
 	/* TODO: This might move somewhere else, after USR might be */
 	swboard->chat_id = session->conv_seq++;
-	swboard->conv = serv_got_joined_chat(gc, swboard->chat_id, "MSN Chat");
+	snprintf(name, sizeof(name), "MSN Chat:%d", ++count);
+	swboard->conv = serv_got_joined_chat(gc, swboard->chat_id, name);
 	swboard->flag = MSN_SB_FLAG_IM;
 
 	purple_conv_chat_add_user(PURPLE_CONV_CHAT(swboard->conv),
-------------- next part --------------
#
# old_revision [e7dd3b30ece9f95dd95249583812659312c457e6]
#
# patch "libpurple/server.c"
#  from [c3f99b11b1dddfcb13ca83be1716ae2b99221047]
#    to [b808176777584276356f7a6eb342ee00a99edf99]
#
============================================================
--- libpurple/server.c	c3f99b11b1dddfcb13ca83be1716ae2b99221047
+++ libpurple/server.c	b808176777584276356f7a6eb342ee00a99edf99
@@ -816,11 +816,21 @@ PurpleConversation *serv_got_joined_chat
 	PurpleConversation *conv;
 	PurpleConvChat *chat;
 	PurpleAccount *account;
+	int cid;
+	int tries = 0;
 
 	account = purple_connection_get_account(gc);
 
 	conv = purple_conversation_new(PURPLE_CONV_TYPE_CHAT, account, name);
 	chat = PURPLE_CONV_CHAT(conv);
+	cid = purple_conv_chat_get_id(chat);
+	while (cid && cid != id) {
+		char *nname = g_strdup_printf("%s:%d", name, ++tries);
+		conv = purple_conversation_new(PURPLE_CONV_TYPE_CHAT, account, nname);
+		chat = PURPLE_CONV_CHAT(conv);
+		cid = purple_conv_chat_get_id(chat);
+		g_free(nname);
+	}
 
 	if (!g_slist_find(gc->buddy_chats, conv))
 		gc->buddy_chats = g_slist_append(gc->buddy_chats, conv);


More information about the Devel mailing list