aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authordequis <dx@dxzone.com.ar>2015-11-25 23:14:34 -0300
committerdequis <dx@dxzone.com.ar>2015-11-25 23:14:34 -0300
commita3019499665384a3dcbbc11016d256e6d4dcd26c (patch)
treea0ea27abac5882c6f22289922ad26644a1b72493
parent42a418e60fb5d3dfbcd9bdc5251bf4a6047bc3c5 (diff)
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.
-rw-r--r--protocols/purple/purple.c16
1 files changed, 12 insertions, 4 deletions
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);
}