Changes in otr.c [f1cf01c:69ef042]
Legend:
- Unmodified
- Added
- Removed
-
otr.c
rf1cf01c r69ef042 8 8 OTR support (cf. http://www.cypherpunks.ca/otr/) 9 9 10 (c) 2008-201 1Sven Moritz Hallberg <pesco@khjk.org>10 (c) 2008-2010 Sven Moritz Hallberg <pesco@khjk.org> 11 11 (c) 2008 funded by stonedcoder.org 12 12 … … 162 162 void otr_smp_or_smpq(irc_t *irc, const char *nick, const char *question, 163 163 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);167 164 168 165 /* update op/voice flag of given user according to encryption state and settings … … 240 237 l = g_slist_prepend( l, "always" ); 241 238 s->eval_data = l; 242 243 s = set_add( &irc->b->set, "otr_does_html", "true", set_eval_bool, irc );244 239 245 240 return TRUE; … … 390 385 ConnContext *context = otrl_context_find(irc->otr->us, iu->bu->handle, 391 386 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); 419 403 } 420 404 } else { 421 405 colormsg = g_strdup(newmsg); 422 406 } 423 424 407 otrl_message_free(newmsg); 425 408 return colormsg; … … 438 421 if(ic->acc->prpl->options & OPT_NOOTR) { 439 422 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);447 423 } 448 424 … … 632 608 irc_user_t *u; 633 609 irc_t *irc = ic->bee->ui_data; 610 const char *trust; 634 611 635 612 u = peeruser(irc, context->username, context->protocol); … … 641 618 } 642 619 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); 648 627 } 649 628 … … 662 641 return; 663 642 } 664 otr_update_uflags(context, u);643 u->flags &= ~( IRC_USER_OTR_ENCRYPTED | IRC_USER_OTR_TRUSTED ); 665 644 if(!otr_update_modeflags(irc, u)) 666 645 irc_usermsg(irc, "conversation with %s is now in the clear", u->nick); … … 681 660 return; 682 661 } 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); 689 668 } 690 669 … … 1333 1312 } 1334 1313 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 else1346 u->flags &= ~IRC_USER_OTR_TRUSTED;1347 } else {1348 u->flags &= ~IRC_USER_OTR_ENCRYPTED;1349 }1350 }1351 1352 1314 int otr_update_modeflags(irc_t *irc, irc_user_t *u) 1353 1315 { 1354 return 0;1316 return 1; 1355 1317 } 1356 1318
Note: See TracChangeset
for help on using the changeset viewer.