Changes in / [71004a3:cc17b76]


Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • otr.c

    r71004a3 rcc17b76  
    441441        int st;
    442442        char *otrmsg = NULL;
     443        char *emsg = msg;           /* the message as we hand it to libotr */
    443444        ConnContext *ctx = NULL;
    444445        irc_t *irc = iu->irc;
    445446        struct im_connection *ic = iu->bu->ic;
    446         otrl_instag_t instag = OTRL_INSTAG_BEST; // XXX?
    447         /* NB: in libotr 4.0.0 OTRL_INSTAG_RECENT will cause a null-pointer deref
    448          * in otrl_message_sending with newly-added OTR contexts.
    449          */
     447        otrl_instag_t instag = OTRL_INSTAG_RECENT; // XXX?
    450448
    451449        /* don't do OTR on certain (not classic IM) protocols, e.g. twitter */
     
    456454        st = otrl_message_sending(irc->otr->us, &otr_ops, ic,
    457455                ic->acc->user, ic->acc->prpl->name, iu->bu->handle, instag,
    458                 msg, NULL, &otrmsg, OTRL_FRAGMENT_SEND_ALL_BUT_LAST, &ctx, NULL, NULL);
    459 
    460         if(otrmsg && otrmsg != msg) {
    461                 /* libotr wants us to replace our message */
    462                 /* NB: caller will free old msg */
    463                 msg = g_strdup(otrmsg);
    464                 otrl_message_free(otrmsg);
    465         }
    466        
     456                emsg, NULL, &otrmsg, OTRL_FRAGMENT_SEND_SKIP, &ctx, NULL, NULL);
     457        /* in libotr 4.0.0 with OTRL_FRAGMENT_SEND_ALL, otrmsg must be passed
     458         * but the value it gets carries no meaning. it can be set even though
     459         * the message has been injected.
     460         * With OTRL_FRAGMENT_SEND_SKIP, libotr doesn't handle the sending, it's
     461         * up to us.
     462         */
     463
     464        if(emsg != msg) {
     465                g_free(emsg);   /* we're done with this one */
     466                emsg = NULL;
     467        }
    467468        if(st) {
    468                 irc_usernotice(iu, "otr: error handling outgoing message: %d", st);
    469                 msg = NULL;     /* do not send plaintext! */
    470         }
    471 
    472         return msg;
     469                irc_rootmsg(irc, "Error encrypting text for OTR: %d", st);
     470        }
     471       
     472        if (otrmsg != NULL) {
     473                return otrmsg;
     474        }
     475        return emsg;
    473476}
    474477
     
    13481351        irc_user_t *u;
    13491352        ConnContext *ctx;
    1350         otrl_instag_t instag = OTRL_INSTAG_BEST;  // XXX
     1353        otrl_instag_t instag = OTRL_INSTAG_RECENT;  // XXX
    13511354
    13521355        u = irc_user_by_name(irc, nick);
Note: See TracChangeset for help on using the changeset viewer.