Changeset 934db064 for otr.c


Ignore:
Timestamp:
2010-09-01T22:09:27Z (14 years ago)
Author:
Wilmer van der Gaast <wilmer@…>
Branches:
master
Children:
2dcaf9a
Parents:
0c85c08
Message:

Do encryption and decryption. Somehow SMP and other things aren't working
so well yet, at least when testing with Pidgin on the other side. Not sure
where the bug is.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • otr.c

    r0c85c08 r934db064  
    344344}
    345345
    346 char *otr_handle_message(struct im_connection *ic, const char *handle, const char *msg)
     346char *otr_filter_msg_in(irc_user_t *iu, char *msg, int flags)
    347347{
    348348        int ignore_msg;
     
    350350        OtrlTLV *tlvs = NULL;
    351351        char *colormsg;
    352         irc_t *irc = ic->bee->ui_data;
     352        irc_t *irc = iu->irc;
     353        struct im_connection *ic = iu->bu->ic;
    353354       
    354355        /* don't do OTR on certain (not classic IM) protocols, e.g. twitter */
    355356        if(ic->acc->prpl->options & OPT_NOOTR) {
    356                 return (g_strdup(msg));
     357                return msg;
    357358        }
    358359       
    359360        ignore_msg = otrl_message_receiving(irc->otr->us, &otr_ops, ic,
    360                 ic->acc->user, ic->acc->prpl->name, handle, msg, &newmsg,
     361                ic->acc->user, ic->acc->prpl->name, iu->bu->handle, msg, &newmsg,
    361362                &tlvs, NULL, NULL);
    362363
    363         otr_handle_smp(ic, handle, tlvs);
     364        otr_handle_smp(ic, iu->bu->handle, tlvs);
    364365       
    365366        if(ignore_msg) {
     
    371372        } else {
    372373                /* OTR has processed this message */
    373                 ConnContext *context = otrl_context_find(irc->otr->us, handle,
     374                ConnContext *context = otrl_context_find(irc->otr->us, iu->bu->handle,
    374375                        ic->acc->user, ic->acc->prpl->name, 0, NULL, NULL, NULL);
    375376                if(context && context->msgstate == OTRL_MSGSTATE_ENCRYPTED &&
    376                    set_getbool(&ic->bee->set, "color_encrypted")) {
     377                   set_getbool(&ic->bee->set, "otr_color_encrypted")) {
    377378                        /* color according to f'print trust */
    378379                        int color;
     
    398399}
    399400
    400 int otr_send_message(struct im_connection *ic, const char *handle, const char *msg, int flags)
     401char *otr_filter_msg_out(irc_user_t *iu, char *msg, int flags)
    401402{       
    402403        int st;
    403404        char *otrmsg = NULL;
    404405        ConnContext *ctx = NULL;
    405         irc_t *irc = ic->bee->ui_data;
     406        irc_t *irc = iu->irc;
     407        struct im_connection *ic = iu->bu->ic;
    406408
    407409        /* don't do OTR on certain (not classic IM) protocols, e.g. twitter */
    408410        if(ic->acc->prpl->options & OPT_NOOTR) {
    409                 /* TODO(wilmer): const */
    410                 return (ic->acc->prpl->buddy_msg(ic, (char*) handle, (char*) msg, flags));
     411                return msg;
    411412        }
    412413       
    413414        st = otrl_message_sending(irc->otr->us, &otr_ops, ic,
    414                 ic->acc->user, ic->acc->prpl->name, handle,
     415                ic->acc->user, ic->acc->prpl->name, iu->bu->handle,
    415416                msg, NULL, &otrmsg, NULL, NULL);
    416417        if(st) {
    417                 return st;
     418                return NULL;
    418419        }
    419420
    420421        ctx = otrl_context_find(irc->otr->us,
    421                         handle, ic->acc->user, ic->acc->prpl->name,
     422                        iu->bu->handle, ic->acc->user, ic->acc->prpl->name,
    422423                        1, NULL, NULL, NULL);
    423424
     
    425426                if(!ctx) {
    426427                        otrl_message_free(otrmsg);
    427                         return 1;
     428                        return NULL;
    428429                }
    429430                st = otrl_message_fragment_and_send(&otr_ops, ic, ctx,
     
    433434                /* note: otrl_message_sending handles policy, so that if REQUIRE_ENCRYPTION is set,
    434435                   this case does not occur */
    435                 st = ic->acc->prpl->buddy_msg( ic, (char *)handle, (char *)msg, flags );
    436         }
    437        
    438         return st;
     436                return msg;
     437        }
     438       
     439        /* TODO: Error reporting should be done here now (if st!=0), probably. */
     440       
     441        return NULL;
    439442}
    440443
     
    443446        otr_irc_new,
    444447        otr_irc_free,
     448        otr_filter_msg_out,
     449        otr_filter_msg_in,
    445450};
    446451
     
    716721        }
    717722       
    718         /* TODO(wilmer): imc_buddy_msg(u->bu->ic, u->bu->handle, "?OTR?", 0); */
     723        bee_user_msg(irc->b, u->bu, "?OTR?", 0);
    719724}
    720725
Note: See TracChangeset for help on using the changeset viewer.