From a3019499665384a3dcbbc11016d256e6d4dcd26c Mon Sep 17 00:00:00 2001 From: dequis Date: Wed, 25 Nov 2015 23:14:34 -0300 Subject: purple: fix /join #channel, which joined a different channel When joining named channels, purple_chat_join() returned NULL instead of a struct groupchat, which was actually created in the conversation created callback (prplcb_conv_new()). If the name of this channel turned out to be different to the joined one, this meant having one empty window in the irc client, and another one for the other channel. The fix is to return a mostly-empty struct groupchat immediately, and pick it up later when the PurpleConversation is created using bee_chat_by_title(). If that fails, fall back to creating a new one. This bug also meant there was no proper way to report a join failure. Future commits will address that, this one just makes that easier. Thanks to Etan Reisner (deryni) for enlightening me while i was trying to figure out how to fix this. --- protocols/purple/purple.c | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) (limited to 'protocols') diff --git a/protocols/purple/purple.c b/protocols/purple/purple.c index 5ab665fd..10864e9e 100644 --- a/protocols/purple/purple.c +++ b/protocols/purple/purple.c @@ -717,7 +717,7 @@ struct groupchat *purple_chat_join(struct im_connection *ic, const char *room, c serv_join_chat(purple_account_get_connection(pd->account), chat_hash); - return NULL; + return imcb_chat_new(ic, room); } void purple_transfer_request(struct im_connection *ic, file_transfer_t *ft, char *handle); @@ -901,9 +901,17 @@ void prplcb_conv_new(PurpleConversation *conv) struct im_connection *ic = purple_ic_by_pa(conv->account); struct groupchat *gc; - gc = imcb_chat_new(ic, conv->name); - if (conv->title != NULL) { - imcb_chat_name_hint(gc, conv->title); + gc = bee_chat_by_title(ic->bee, ic, conv->name); + + if (!gc) { + gc = imcb_chat_new(ic, conv->name); + if (conv->title != NULL) { + imcb_chat_name_hint(gc, conv->title); + } + } + + /* don't set the topic if it's just the name */ + if (conv->title != NULL && strcmp(conv->name, conv->title) != 0) { imcb_chat_topic(gc, NULL, conv->title, 0); } -- cgit v1.2.3