# HG changeset patch # User franky # Date 1239560456 -7200 # Node ID e1a642472f4e80e241208787ed89a38ecc274da9 # Parent 72fef01d90613753a169b89fa42f3e5db5e3d737 Use otr context where possible, saves one mc_strtolower() per received message diff -r 72fef01d9061 -r e1a642472f4e mcabber/src/jabglue.c --- a/mcabber/src/jabglue.c Tue Jan 27 22:24:02 2009 +0100 +++ b/mcabber/src/jabglue.c Sun Apr 12 20:20:56 2009 +0200 @@ -1811,7 +1811,6 @@ #ifdef HAVE_LIBOTR if (otr_enabled()) { decrypted_otr = (char*)body; - mc_strtolower(bjid); otr_msg = otr_receive(&decrypted_otr, bjid, &free_msg); if (!decrypted_otr) { goto gotmessage_return; diff -r 72fef01d9061 -r e1a642472f4e mcabber/src/otr.c --- a/mcabber/src/otr.c Tue Jan 27 22:24:02 2009 +0100 +++ b/mcabber/src/otr.c Sun Apr 12 20:20:56 2009 +0200 @@ -34,6 +34,7 @@ #include "settings.h" #include "nohtml.h" +#define OTR_PROTOCOL_NAME "jabber" static OtrlUserState userstate = NULL; static char * account = NULL; @@ -128,7 +129,7 @@ OTRL_INIT; - userstate = otrl_userstate_create (); + userstate = otrl_userstate_create(); root = otr_get_dir(); account = jidtodisp(fjid); @@ -138,7 +139,7 @@ if (otrl_privkey_read(userstate, keyfile)){ scr_LogPrint(LPRINT_LOGNORM, "Could not read OTR key from %s", keyfile); - cb_create_privkey(NULL, account, "jabber"); + cb_create_privkey(NULL, account, OTR_PROTOCOL_NAME); } if (otrl_privkey_read_fingerprints(userstate, fprfile, NULL, NULL)){ scr_LogPrint(LPRINT_LOGNORM, "Could not read OTR fingerprints from %s", @@ -204,8 +205,8 @@ char * lowcasebuddy = g_strdup(buddy); mc_strtolower(lowcasebuddy); - ctx = otrl_context_find(userstate, lowcasebuddy, account, "jabber", 1, &null, - NULL, NULL); + ctx = otrl_context_find(userstate, lowcasebuddy, account, OTR_PROTOCOL_NAME, + 1, &null, NULL, NULL); g_free(lowcasebuddy); return ctx; } @@ -365,18 +366,20 @@ OtrlTLV *tlv = NULL; ConnContext * ctx; + ctx = otr_get_context(buddy); *free_msg = 0; - ignore_message = otrl_message_receiving(userstate, &ops, NULL, account, - "jabber", buddy, *otr_data, &newmessage, &tlvs, NULL, NULL); + ignore_message = otrl_message_receiving(userstate, &ops, NULL, + ctx->accountname, ctx->protocol, + ctx->username, *otr_data, + &newmessage, &tlvs,NULL, NULL); - ctx = otr_get_context(buddy); tlv = otrl_tlv_find(tlvs, OTRL_TLV_DISCONNECTED); if (tlv) { /* Notify the user that the other side disconnected. */ if (ctx) { cb_gone_insecure(NULL, ctx); - otr_disconnect(buddy); + otr_disconnect(ctx->username); } } @@ -407,8 +410,9 @@ htmlmsg = html_escape(*msg); - err = otrl_message_sending(userstate, &ops, NULL, account, "jabber", buddy, - htmlmsg, NULL, &newmessage, NULL, NULL); + err = otrl_message_sending(userstate, &ops, NULL, ctx->accountname, + ctx->protocol, ctx->username, htmlmsg, NULL, + &newmessage, NULL, NULL); g_free(htmlmsg); @@ -430,7 +434,7 @@ { const char *state, *auth, *policy; ConnContext * ctx = otr_get_context(buddy); - OtrlPolicy p = cb_policy (ctx->app_data, ctx); + OtrlPolicy p = cb_policy(ctx->app_data, ctx); if (!userstate || !ctx) return;