diff options
author | dequis <dx@dxzone.com.ar> | 2015-11-23 14:49:09 -0300 |
---|---|---|
committer | dequis <dx@dxzone.com.ar> | 2015-11-23 14:49:09 -0300 |
commit | 9c8dbc75d416c8867be20ccf3732303163e620ce (patch) | |
tree | a714f5af6ca4a17db97981036c0f79ae5ffda7fd /protocols/jabber/jabber.c | |
parent | c34247d0b3111f16dae1a52d831df0d61c03ee35 (diff) |
hipchat: 'chat add hipchat "channel name"' now tries to guess the JID
It's basically prepending the organization id, appending the default MUC
host from the success packet, and generating a slug based on the name
for the middle part, which is replacing a few characters with
underscores and doing a unicode aware lowercasing.
Includes tests, which are useless other than validating the initial
implementation with the test vectors that i already tested manually.
Guaranteed to detect zero breakages in the future. Good test code.
Diffstat (limited to 'protocols/jabber/jabber.c')
-rw-r--r-- | protocols/jabber/jabber.c | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/protocols/jabber/jabber.c b/protocols/jabber/jabber.c index 35cf0c90..ddf4f2d3 100644 --- a/protocols/jabber/jabber.c +++ b/protocols/jabber/jabber.c @@ -370,6 +370,7 @@ static void jabber_logout(struct im_connection *ic) g_free(jd->away_message); g_free(jd->internal_jid); g_free(jd->gmail_tid); + g_free(jd->muc_host); g_free(jd->username); g_free(jd->me); g_free(jd); @@ -532,12 +533,24 @@ static struct groupchat *jabber_chat_join_(struct im_connection *ic, const char final_nick = (char *) nick; } + if (jd->flags & JFLAG_HIPCHAT && jd->muc_host && !g_str_has_suffix(room, jd->muc_host)) { + char *guessed_name = hipchat_guess_channel_name(ic, room); + if (guessed_name) { + set_setstr(sets, "room", guessed_name); + g_free(guessed_name); + + /* call this same function again with the fixed name */ + return jabber_chat_join_(ic, set_getstr(sets, "room"), nick, password, sets); + } + } + if (strchr(room, '@') == NULL) { imcb_error(ic, "%s is not a valid Jabber room name. Maybe you mean %s@conference.%s?", room, room, jd->server); } else if (jabber_chat_by_jid(ic, room)) { imcb_error(ic, "Already present in chat `%s'", room); } else { + /* jabber_chat_join without the underscore is the conference.c one */ return jabber_chat_join(ic, room, final_nick, set_getstr(sets, "password")); } |