diff options
-rw-r--r-- | Makefile | 1 | ||||
-rw-r--r-- | otr.c | 35 |
2 files changed, 25 insertions, 11 deletions
@@ -163,3 +163,4 @@ helloworld: @echo Hello World -include .depend/*.d +# DO NOT DELETE @@ -162,6 +162,9 @@ void otr_handle_smp(struct im_connection *ic, const char *handle, OtrlTLV *tlvs) void otr_smp_or_smpq(irc_t *irc, const char *nick, const char *question, const char *secret); +/* update flags within the irc_user structure to reflect OTR status of context */ +void otr_update_uflags(ConnContext *context, irc_user_t *u); + /* update op/voice flag of given user according to encryption state and settings returns 0 if neither op_buddies nor voice_buddies is set to "encrypted", i.e. msgstate should be announced seperately */ @@ -607,7 +610,6 @@ void op_gone_secure(void *opdata, ConnContext *context) check_imc(opdata, context->accountname, context->protocol); irc_user_t *u; irc_t *irc = ic->bee->ui_data; - const char *trust; u = peeruser(irc, context->username, context->protocol); if(!u) { @@ -617,11 +619,7 @@ void op_gone_secure(void *opdata, ConnContext *context) return; } - trust = context->active_fingerprint->trust; - if(trust && trust[0]) - u->flags |= IRC_USER_OTR_ENCRYPTED | IRC_USER_OTR_TRUSTED; - else - u->flags = ( u->flags & ~IRC_USER_OTR_TRUSTED ) | IRC_USER_OTR_ENCRYPTED; + otr_update_uflags(context, u); if(!otr_update_modeflags(irc, u)) irc_usermsg(irc, "conversation with %s is now off the record", u->nick); } @@ -640,7 +638,7 @@ void op_gone_insecure(void *opdata, ConnContext *context) context->username, context->protocol, context->accountname); return; } - u->flags &= ~( IRC_USER_OTR_ENCRYPTED | IRC_USER_OTR_TRUSTED ); + otr_update_uflags(context, u); if(!otr_update_modeflags(irc, u)) irc_usermsg(irc, "conversation with %s is now in the clear", u->nick); } @@ -659,10 +657,8 @@ void op_still_secure(void *opdata, ConnContext *context, int is_reply) context->username, context->protocol, context->accountname); return; } - if(context->active_fingerprint->trust[0]) - u->flags |= IRC_USER_OTR_ENCRYPTED | IRC_USER_OTR_TRUSTED; - else - u->flags = ( u->flags & ~IRC_USER_OTR_TRUSTED ) | IRC_USER_OTR_ENCRYPTED; + + otr_update_uflags(context, u); if(!otr_update_modeflags(irc, u)) irc_usermsg(irc, "otr connection with %s has been refreshed", u->nick); } @@ -1311,6 +1307,23 @@ const char *peernick(irc_t *irc, const char *handle, const char *protocol) } } +void otr_update_uflags(ConnContext *context, irc_user_t *u) +{ + const char *trust; + + if(context->active_fingerprint) { + u->flags |= IRC_USER_OTR_ENCRYPTED; + + trust = context->active_fingerprint->trust; + if(trust && trust[0]) + u->flags |= IRC_USER_OTR_TRUSTED; + else + u->flags &= ~IRC_USER_OTR_TRUSTED; + } else { + u->flags &= ~IRC_USER_OTR_ENCRYPTED; + } +} + int otr_update_modeflags(irc_t *irc, irc_user_t *u) { return 1; |