Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • protocols/jabber/jabber.c

    r73dd021 r3a620ff  
    114114        s->flags |= ACC_SET_OFFLINE_ONLY | SET_NULL_OK;
    115115
     116        s = set_add(&acc->set, "carbons", "true", set_eval_bool, acc);
     117        s->flags |= ACC_SET_OFFLINE_ONLY;
     118
    116119        acc->flags |= ACC_FLAG_AWAY_MESSAGE | ACC_FLAG_STATUS_MESSAGE |
    117120                      ACC_FLAG_HANDLE_DOMAINS;
     
    148151        }
    149152
     153        if (strstr(jd->server, ".facebook.com")) {
     154                imcb_error(ic, "Facebook's XMPP service is gone. Try this instead: https://wiki.bitlbee.org/HowtoFacebookMQTT");
     155                imc_logout(ic, FALSE);
     156                return;
     157        }
     158
    150159        if ((s = strchr(jd->server, '/'))) {
    151160                *s = 0;
     
    167176                jd->fd = jd->r_inpa = jd->w_inpa = -1;
    168177
    169                 if (strstr(jd->server, ".facebook.com")) {
    170                         jd->oauth2_service = &oauth2_service_facebook;
    171                 } else {
    172                         jd->oauth2_service = &oauth2_service_google;
    173                 }
     178                /* There are no other options atm, so assume google for everything
     179                   Facebook and MSN XMPP used to be here. RIP. */
     180                jd->oauth2_service = &oauth2_service_google;
    174181
    175182                oauth_params_parse(&p_in, ic->acc->pass);
     
    197204        } else {
    198205                jabber_connect(ic);
     206        }
     207}
     208
     209static void jabber_xmlconsole_enable(struct im_connection *ic)
     210{
     211        struct jabber_data *jd = ic->proto_data;
     212        const char *handle = JABBER_XMLCONSOLE_HANDLE;
     213        bee_user_t *bu;
     214       
     215        jd->flags |= JFLAG_XMLCONSOLE;
     216
     217        if (!(bu = bee_user_by_handle(ic->bee, ic, handle))) {
     218                bu = bee_user_new(ic->bee, ic, handle, 0);
     219                bu->flags |= BEE_USER_NOOTR;
    199220        }
    200221}
     
    266287
    267288        if (set_getbool(&acc->set, "xmlconsole")) {
    268                 jd->flags |= JFLAG_XMLCONSOLE;
    269                 /* Shouldn't really do this at this stage already, maybe. But
    270                    I think this shouldn't break anything. */
    271                 imcb_add_buddy(ic, JABBER_XMLCONSOLE_HANDLE, NULL);
     289                jabber_xmlconsole_enable(ic);
    272290        }
    273291
     
    334352        }
    335353        if (jd->fd >= 0) {
    336                 closesocket(jd->fd);
     354                proxy_disconnect(jd->fd);
    337355        }
    338356
     
    345363        }
    346364
    347         jabber_buddy_remove_all(ic);
     365        if (jd->buddies) {
     366                jabber_buddy_remove_all(ic);
     367        }
    348368
    349369        xt_free(jd->xt);
     
    355375        g_free(jd->internal_jid);
    356376        g_free(jd->gmail_tid);
     377        g_free(jd->muc_host);
    357378        g_free(jd->username);
    358379        g_free(jd->me);
     
    413434        }
    414435
     436        /* XEP-0364 suggests we add message processing hints (XEP-0334) to OTR messages,
     437           mostly to avoid carbons (XEP-0280) and server-side message archiving.
     438           OTR messages are roughly like this: /^\?OTR(.*\?| Error:|:)/
     439           But I'm going to simplify it to messages starting with "?OTR". */
     440        if (g_str_has_prefix(message, "?OTR")) {
     441                int i;
     442                char *hints[] = {
     443                        "no-copy", XMLNS_HINTS,
     444                        "no-permanent-store", XMLNS_HINTS,
     445                        "private", XMLNS_CARBONS,
     446                        NULL
     447                };
     448                       
     449                for (i = 0; hints[i]; i += 2) {
     450                        struct xt_node *hint;
     451                        hint = xt_new_node(hints[i], NULL, NULL);
     452                        xt_add_attr(hint, "xmlns", hints[i + 1]);
     453                        xt_add_child(node, hint);
     454                }
     455        }
     456
    415457        st = jabber_write_packet(ic, node);
    416458        xt_free_node(node);
     
    472514static void jabber_add_buddy(struct im_connection *ic, char *who, char *group)
    473515{
    474         struct jabber_data *jd = ic->proto_data;
    475 
    476516        if (g_strcasecmp(who, JABBER_XMLCONSOLE_HANDLE) == 0) {
    477                 jd->flags |= JFLAG_XMLCONSOLE;
    478                 imcb_add_buddy(ic, JABBER_XMLCONSOLE_HANDLE, NULL);
     517                jabber_xmlconsole_enable(ic);
    479518                return;
    480519        }
     
    520559        }
    521560
     561        if (jd->flags & JFLAG_HIPCHAT && jd->muc_host && !g_str_has_suffix(room, jd->muc_host)) {
     562                char *guessed_name = hipchat_guess_channel_name(ic, room);
     563                if (guessed_name) {
     564                        set_setstr(sets, "room", guessed_name);
     565                        g_free(guessed_name);
     566
     567                        /* call this same function again with the fixed name */
     568                        return jabber_chat_join_(ic, set_getstr(sets, "room"), nick, password, sets);
     569                }
     570        }
     571
    522572        if (strchr(room, '@') == NULL) {
    523573                imcb_error(ic, "%s is not a valid Jabber room name. Maybe you mean %s@conference.%s?",
     
    526576                imcb_error(ic, "Already present in chat `%s'", room);
    527577        } else {
     578                /* jabber_chat_join without the underscore is the conference.c one */
    528579                return jabber_chat_join(ic, room, final_nick, set_getstr(sets, "password"));
    529580        }
     
    590641{
    591642        struct jabber_data *jd = ic->proto_data;
    592         struct jabber_buddy *bud;
     643        struct jabber_buddy *bud, *bare;
    593644
    594645        /* Enable typing notification related code from now. */
    595646        jd->flags |= JFLAG_WANT_TYPING;
    596647
    597         if ((bud = jabber_buddy_by_jid(ic, who, 0)) == NULL) {
     648        if ((bud = jabber_buddy_by_jid(ic, who, 0)) == NULL ||
     649            (bare = jabber_buddy_by_jid(ic, who, GET_BUDDY_BARE)) == NULL) {
    598650                /* Sending typing notifications to unknown buddies is
    599651                   unsupported for now. Shouldn't be a problem, I think. */
     
    601653        }
    602654
    603         if (bud->flags & JBFLAG_DOES_XEP85) {
     655
     656        if (bud->flags & JBFLAG_DOES_XEP85 || bare->flags & JBFLAG_DOES_XEP85) {
    604657                /* We're only allowed to send this stuff if we know the other
    605                    side supports it. */
     658                   side supports it. If the bare JID has the flag, all other
     659                   resources get it, too (That is the case in gtalk) */
    606660
    607661                struct xt_node *node;
Note: See TracChangeset for help on using the changeset viewer.