Changeset 81265e0


Ignore:
Timestamp:
2013-08-01T15:47:48Z (7 years ago)
Author:
Sven M. Hallberg <pesco@…>
Branches:
master
Children:
5d2bc9d
Parents:
a685409
Message:

make otr compile with libotr 4.0.0, minimal functionality

Files:
2 edited

Legend:

Unmodified
Added
Removed
  • otr.c

    ra685409 r81265e0  
    88  OTR support (cf. http://www.cypherpunks.ca/otr/)
    99 
    10   (c) 2008-2011 Sven Moritz Hallberg <pesco@khjk.org>
    11   (c) 2008 funded by stonedcoder.org
     10  (c) 2008-2011,2013 Sven Moritz Hallberg <pesco@khjk.org>
     11  funded by stonedcoder.org
    1212   
    1313  files used to store OTR data:
     
    208208        otr_ops.is_logged_in = &op_is_logged_in;
    209209        otr_ops.inject_message = &op_inject_message;
    210         otr_ops.notify = NULL;
    211         otr_ops.display_otr_message = &op_display_otr_message;
     210        //XXX otr_ops.display_otr_message = &op_display_otr_message;
    212211        otr_ops.update_context_list = NULL;
    213         otr_ops.protocol_name = NULL;
    214         otr_ops.protocol_name_free = NULL;
    215212        otr_ops.new_fingerprint = &op_new_fingerprint;
    216213        otr_ops.write_fingerprints = &op_write_fingerprints;
     
    218215        otr_ops.gone_insecure = &op_gone_insecure;
    219216        otr_ops.still_secure = &op_still_secure;
    220         otr_ops.log_message = &op_log_message;
     217        //XXX otr_ops.log_message = &op_log_message;
    221218        otr_ops.max_message_size = &op_max_message_size;
    222219        otr_ops.account_name = &op_account_name;
    223220        otr_ops.account_name_free = NULL;
    224        
     221
     222        /* stuff added with libotr 4.0.0 */
     223        otr_ops.received_symkey = NULL;         /* we don't use the extra key */
     224        otr_ops.otr_error_message = NULL;       // TODO?
     225        otr_ops.otr_error_message_free = NULL;
     226        otr_ops.resent_msg_prefix = NULL;       // XXX don't need?
     227        otr_ops.resent_msg_prefix_free = NULL;
     228        otr_ops.handle_smp_event = NULL; // XXX replace smp state machine w/this
     229        otr_ops.handle_msg_event = NULL; // XXX
     230        otr_ops.create_instag = NULL;    // XXX
     231        otr_ops.convert_msg = NULL;      // XXX other plugins? de/htmlize?
     232        otr_ops.timer_control = NULL;    // XXX call otrl_message_poll reg'ly
     233               
    225234        root_command_add( "otr", 1, cmd_otr, 0 );
    226235        register_irc_plugin( &otr_plugin );
     
    386395        ignore_msg = otrl_message_receiving(irc->otr->us, &otr_ops, ic,
    387396                ic->acc->user, ic->acc->prpl->name, iu->bu->handle, msg, &newmsg,
    388                 &tlvs, NULL, NULL);
     397                &tlvs, NULL, NULL, NULL);
    389398
    390399        otr_handle_smp(ic, iu->bu->handle, tlvs);
     
    397406                return msg;
    398407        } else {
     408        /* XXX move this to convert callback */
     409
    399410                /* OTR has processed this message */
    400411                ConnContext *context = otrl_context_find(irc->otr->us, iu->bu->handle,
    401                         ic->acc->user, ic->acc->prpl->name, 0, NULL, NULL, NULL);
     412                        ic->acc->user, ic->acc->prpl->name, OTRL_INSTAG_MASTER, 0, NULL, NULL, NULL);
    402413
    403414                /* we're done with the original msg, which will be caller-freed. */
     
    459470        irc_t *irc = iu->irc;
    460471        struct im_connection *ic = iu->bu->ic;
     472        otrl_instag_t instag = OTRL_INSTAG_MASTER; // XXX?
    461473
    462474        /* don't do OTR on certain (not classic IM) protocols, e.g. twitter */
     
    467479        ctx = otrl_context_find(irc->otr->us,
    468480                        iu->bu->handle, ic->acc->user, ic->acc->prpl->name,
    469                         1, NULL, NULL, NULL);
     481                        instag, 1, NULL, NULL, NULL);
    470482
    471483        /* HTML encoding */
     
    478490       
    479491        st = otrl_message_sending(irc->otr->us, &otr_ops, ic,
    480                 ic->acc->user, ic->acc->prpl->name, iu->bu->handle,
    481                 emsg, NULL, &otrmsg, NULL, NULL);
     492                ic->acc->user, ic->acc->prpl->name, iu->bu->handle, instag,
     493                emsg, NULL, &otrmsg, OTRL_FRAGMENT_SEND_SKIP, NULL, NULL, NULL);
    482494        if(emsg != msg) {
    483495                g_free(emsg);   /* we're done with this one */
     
    492504                        return NULL;
    493505                }
    494                 st = otrl_message_fragment_and_send(&otr_ops, ic, ctx,
    495                         otrmsg, OTRL_FRAGMENT_SEND_ALL, NULL);
     506                otr_ops.inject_message(ic, ctx->accountname,
     507                        ctx->protocol, ctx->username, otrmsg);
    496508                otrl_message_free(otrmsg);
    497509        } else {
     
    774786        }
    775787       
    776         otrl_message_disconnect(irc->otr->us, &otr_ops,
     788        /* XXX we disconnect all instances; is that what we want? */
     789        otrl_message_disconnect_all_instances(irc->otr->us, &otr_ops,
    777790                u->bu->ic, u->bu->ic->acc->user, u->bu->ic->acc->prpl->name, u->bu->handle);
    778791       
    779         /* for some reason, libotr (3.1.0) doesn't do this itself: */
    780         if(u->flags & IRC_USER_OTR_ENCRYPTED) {
    781                 ConnContext *ctx;
    782                 ctx = otrl_context_find(irc->otr->us, u->bu->handle, u->bu->ic->acc->user,
    783                         u->bu->ic->acc->prpl->name, 0, NULL, NULL, NULL);
    784                 if(ctx)
    785                         op_gone_insecure(u->bu->ic, ctx);
    786                 else /* huh? */
    787                         u->flags &= ( IRC_USER_OTR_ENCRYPTED | IRC_USER_OTR_TRUSTED );
    788         }
     792        /* for some reason, libotr (4.0.0) doesn't do this itself: */
     793        if(!(u->flags & IRC_USER_OTR_ENCRYPTED))
     794                return;
     795
     796        ConnContext *ctx, *p;
     797        ctx = otrl_context_find(irc->otr->us, u->bu->handle, u->bu->ic->acc->user,
     798                u->bu->ic->acc->prpl->name, OTRL_INSTAG_MASTER, 0, NULL, NULL, NULL);
     799        if(!ctx) { /* huh? */
     800                u->flags &= ( IRC_USER_OTR_ENCRYPTED | IRC_USER_OTR_TRUSTED );
     801                return;
     802        }
     803
     804        for(p=ctx; p && p->m_context == ctx->m_context; p=p->next)
     805                op_gone_insecure(u->bu->ic, p);
    789806}
    790807
     
    831848       
    832849        ctx = otrl_context_find(irc->otr->us, u->bu->handle,
    833                 u->bu->ic->acc->user, u->bu->ic->acc->prpl->name, 0, NULL, NULL, NULL);
     850                u->bu->ic->acc->user, u->bu->ic->acc->prpl->name, OTRL_INSTAG_MASTER, 0, NULL, NULL, NULL);  // XXX
    834851        if(!ctx) {
    835852                irc_rootmsg(irc, "%s: no otr context with user", args[1]);
     
    895912                        *(myhandle++) = '\0';
    896913                        handle = arg;
    897                         ctx = otrl_context_find(irc->otr->us, handle, myhandle, protocol, 0, NULL, NULL, NULL);
     914                        ctx = otrl_context_find(irc->otr->us, handle, myhandle, protocol, 0, OTRL_INSTAG_MASTER, NULL, NULL, NULL);  // XXX
    898915                        if(!ctx) {
    899916                                irc_rootmsg(irc, "no such context");
     
    909926                        }
    910927                        ctx = otrl_context_find(irc->otr->us, u->bu->handle, u->bu->ic->acc->user,
    911                                 u->bu->ic->acc->prpl->name, 0, NULL, NULL, NULL);
     928                                u->bu->ic->acc->prpl->name, OTRL_INSTAG_MASTER, 0, NULL, NULL, NULL);  // XXX
    912929                        if(!ctx) {
    913930                                irc_rootmsg(irc, "no otr context with %s", args[1]);
     
    10281045               
    10291046                ctx = otrl_context_find(irc->otr->us, u->bu->handle, u->bu->ic->acc->user,
    1030                         u->bu->ic->acc->prpl->name, 0, NULL, NULL, NULL);
     1047                        u->bu->ic->acc->prpl->name, OTRL_INSTAG_MASTER, 0, NULL, NULL, NULL);  // XXX
    10311048                if(!ctx) {
    10321049                        irc_rootmsg(irc, "no otr context with %s", args[2]);
     
    10711088               
    10721089                ctx = otrl_context_find(irc->otr->us, u->bu->handle, u->bu->ic->acc->user,
    1073                         u->bu->ic->acc->prpl->name, 0, NULL, NULL, NULL);
     1090                        u->bu->ic->acc->prpl->name, OTRL_INSTAG_MASTER, 0, NULL, NULL, NULL);  // XXX
    10741091                if(!ctx) {
    10751092                        irc_rootmsg(irc, "no otr context with %s", args[2]);
     
    11341151        if(!bu || !(u = bu->ui_data)) return;
    11351152        context = otrl_context_find(us, handle,
    1136                 ic->acc->user, ic->acc->prpl->name, 1, NULL, NULL, NULL);
     1153                ic->acc->user, ic->acc->prpl->name, OTRL_INSTAG_MASTER, 1, NULL, NULL, NULL);
    11371154        if(!context) {
    11381155                /* huh? out of memory or what? */
     
    12661283       
    12671284        ctx = otrl_context_find(irc->otr->us, u->bu->handle,
    1268                 u->bu->ic->acc->user, u->bu->ic->acc->prpl->name, 0, NULL, NULL, NULL);
     1285                u->bu->ic->acc->user, u->bu->ic->acc->prpl->name, OTRL_INSTAG_MASTER, 0, NULL, NULL, NULL);
    12691286        if(!ctx || ctx->msgstate != OTRL_MSGSTATE_ENCRYPTED) {
    12701287                irc_rootmsg(irc, "smp: otr inactive with %s, try \x02otr connect"
  • otr.h

    ra685409 r81265e0  
    88  OTR support (cf. http://www.cypherpunks.ca/otr/)
    99 
    10   2008, Sven Moritz Hallberg <pesco@khjk.org>
    11   (c) and funded by stonedcoder.org
     10  (c) 2008,2013 Sven Moritz Hallberg <pesco@khjk.org>
     11  funded by stonedcoder.org
    1212*/
    1313
Note: See TracChangeset for help on using the changeset viewer.