Changeset 367ea3c


Ignore:
Timestamp:
2014-02-01T23:59:00Z (6 years ago)
Author:
unknown <pesco@…>
Branches:
master
Children:
329f9fe
Parents:
cc17b76
Message:

work around libotr 4 not sending outgoing plaintext messages

File:
1 edited

Legend:

Unmodified
Added
Removed
  • otr.c

    rcc17b76 r367ea3c  
    441441        int st;
    442442        char *otrmsg = NULL;
    443         char *emsg = msg;           /* the message as we hand it to libotr */
    444443        ConnContext *ctx = NULL;
    445444        irc_t *irc = iu->irc;
     
    454453        st = otrl_message_sending(irc->otr->us, &otr_ops, ic,
    455454                ic->acc->user, ic->acc->prpl->name, iu->bu->handle, instag,
    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         }
     455                msg, NULL, &otrmsg, OTRL_FRAGMENT_SEND_ALL_BUT_LAST, &ctx, NULL, NULL);
     456
     457        if(otrmsg && otrmsg != msg) {
     458                /* libotr wants us to replace our message */
     459                /* NB: caller will free old msg */
     460                msg = g_strdup(otrmsg);
     461                otrl_message_free(otrmsg);
     462        }
     463       
    468464        if(st) {
    469                 irc_rootmsg(irc, "Error encrypting text for OTR: %d", st);
    470         }
    471        
    472         if (otrmsg != NULL) {
    473                 return otrmsg;
    474         }
    475         return emsg;
     465                irc_usernotice(iu, "otr: error handling outgoing message: %d", st);
     466                msg = NULL;     /* do not send plaintext! */
     467        }
     468
     469        return msg;
    476470}
    477471
Note: See TracChangeset for help on using the changeset viewer.