Changes in / [3d952b5:c8b8c83]


Ignore:
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • Makefile

    r3d952b5 rc8b8c83  
    185185
    186186-include .depend/*.d
    187 # DO NOT DELETE
  • otr.c

    r3d952b5 rc8b8c83  
    88  OTR support (cf. http://www.cypherpunks.ca/otr/)
    99 
    10   (c) 2008-2011 Sven Moritz Hallberg <pesco@khjk.org>
     10  (c) 2008-2010 Sven Moritz Hallberg <pesco@khjk.org>
    1111  (c) 2008 funded by stonedcoder.org
    1212   
     
    162162void otr_smp_or_smpq(irc_t *irc, const char *nick, const char *question,
    163163                const char *secret);
    164 
    165 /* update flags within the irc_user structure to reflect OTR status of context */
    166 void otr_update_uflags(ConnContext *context, irc_user_t *u);
    167164
    168165/* update op/voice flag of given user according to encryption state and settings
     
    240237        l = g_slist_prepend( l, "always" );
    241238        s->eval_data = l;
    242 
    243         s = set_add( &irc->b->set, "otr_does_html", "true", set_eval_bool, irc );
    244239       
    245240        return TRUE;
     
    390385                ConnContext *context = otrl_context_find(irc->otr->us, iu->bu->handle,
    391386                        ic->acc->user, ic->acc->prpl->name, 0, NULL, NULL, NULL);
    392 
    393                 if(context && context->msgstate == OTRL_MSGSTATE_ENCRYPTED) {
    394                         /* HTML decoding */
    395                         /* perform any necessary stripping that the top level would miss */
    396                         if(set_getbool(&ic->bee->set, "otr_does_html") &&
    397                            !(ic->flags & OPT_DOES_HTML) &&
    398                            set_getbool(&ic->bee->set, "strip_html")) {
    399                                 strip_html(newmsg);
    400                         }
    401 
    402                         /* coloring */
    403                         if(set_getbool(&ic->bee->set, "otr_color_encrypted")) {
    404                                 /* color according to f'print trust */
    405                                 int color;
    406                                 const char *trust = context->active_fingerprint->trust;
    407                                 if(trust && trust[0] != '\0')
    408                                         color=3;   /* green */
    409                                 else
    410                                         color=5;   /* red */
    411 
    412                                 if(newmsg[0] == ',') {
    413                                         /* could be a problem with the color code */
    414                                         /* insert a space between color spec and message */
    415                                         colormsg = g_strdup_printf("\x03%.2d %s\x0F", color, newmsg);
    416                                 } else {
    417                                         colormsg = g_strdup_printf("\x03%.2d%s\x0F", color, newmsg);
    418                                 }
     387                if(context && context->msgstate == OTRL_MSGSTATE_ENCRYPTED &&
     388                   set_getbool(&ic->bee->set, "otr_color_encrypted")) {
     389                        /* color according to f'print trust */
     390                        int color;
     391                        const char *trust = context->active_fingerprint->trust;
     392                        if(trust && trust[0] != '\0')
     393                                color=3;   /* green */
     394                        else
     395                                color=5;   /* red */
     396
     397                        if(newmsg[0] == ',') {
     398                                /* could be a problem with the color code */
     399                                /* insert a space between color spec and message */
     400                                colormsg = g_strdup_printf("\x03%.2d %s\x0F", color, newmsg);
     401                        } else {
     402                                colormsg = g_strdup_printf("\x03%.2d%s\x0F", color, newmsg);
    419403                        }
    420404                } else {
    421405                        colormsg = g_strdup(newmsg);
    422406                }
    423 
    424407                otrl_message_free(newmsg);
    425408                return colormsg;
     
    438421        if(ic->acc->prpl->options & OPT_NOOTR) {
    439422                return msg;
    440         }
    441 
    442         /* HTML encoding */
    443         /* consider OTR plaintext to be HTML if otr_does_html is set */
    444         if(set_getbool(&ic->bee->set, "otr_does_html") &&
    445            (g_strncasecmp(msg, "<html>", 6) != 0)) {
    446                 msg = escape_html(msg);
    447423        }
    448424       
     
    632608        irc_user_t *u;
    633609        irc_t *irc = ic->bee->ui_data;
     610        const char *trust;
    634611
    635612        u = peeruser(irc, context->username, context->protocol);
     
    641618        }
    642619       
    643         otr_update_uflags(context, u);
    644         if(!otr_update_modeflags(irc, u)) {
    645                 char *trust = u->flags & IRC_USER_OTR_TRUSTED ? "trusted" : "untrusted!";
    646                 irc_usermsg(irc, "conversation with %s is now off the record (%s)", u->nick, trust);
    647         }
     620        trust = context->active_fingerprint->trust;
     621        if(trust && trust[0])
     622                u->flags |= IRC_USER_OTR_ENCRYPTED | IRC_USER_OTR_TRUSTED;
     623        else
     624                u->flags = ( u->flags & ~IRC_USER_OTR_TRUSTED ) | IRC_USER_OTR_ENCRYPTED;
     625        if(!otr_update_modeflags(irc, u))
     626                irc_usermsg(irc, "conversation with %s is now off the record", u->nick);
    648627}
    649628
     
    662641                return;
    663642        }
    664         otr_update_uflags(context, u);
     643        u->flags &= ~( IRC_USER_OTR_ENCRYPTED | IRC_USER_OTR_TRUSTED );
    665644        if(!otr_update_modeflags(irc, u))
    666645                irc_usermsg(irc, "conversation with %s is now in the clear", u->nick);
     
    681660                return;
    682661        }
    683 
    684         otr_update_uflags(context, u);
    685         if(!otr_update_modeflags(irc, u)) {
    686                 char *trust = u->flags & IRC_USER_OTR_TRUSTED ? "trusted" : "untrusted!";
    687                 irc_usermsg(irc, "otr connection with %s has been refreshed (%s)", u->nick, trust);
    688         }
     662        if(context->active_fingerprint->trust[0])
     663                u->flags |= IRC_USER_OTR_ENCRYPTED | IRC_USER_OTR_TRUSTED;
     664        else
     665                u->flags = ( u->flags & ~IRC_USER_OTR_TRUSTED ) | IRC_USER_OTR_ENCRYPTED;
     666        if(!otr_update_modeflags(irc, u))
     667                irc_usermsg(irc, "otr connection with %s has been refreshed", u->nick);
    689668}
    690669
     
    13331312}
    13341313
    1335 void otr_update_uflags(ConnContext *context, irc_user_t *u)
    1336 {
    1337         const char *trust;
    1338 
    1339         if(context->active_fingerprint) {
    1340                 u->flags |= IRC_USER_OTR_ENCRYPTED;
    1341 
    1342                 trust = context->active_fingerprint->trust;
    1343                 if(trust && trust[0])
    1344                         u->flags |= IRC_USER_OTR_TRUSTED;
    1345                 else
    1346                         u->flags &= ~IRC_USER_OTR_TRUSTED;
    1347         } else {
    1348                 u->flags &= ~IRC_USER_OTR_ENCRYPTED;
    1349         }
    1350 }
    1351 
    13521314int otr_update_modeflags(irc_t *irc, irc_user_t *u)
    13531315{
    1354         return 0;
     1316        return 1;
    13551317}
    13561318
Note: See TracChangeset for help on using the changeset viewer.