Changeset 3d952b5
- Timestamp:
- 2011-07-31T22:59:42Z (13 years ago)
- Branches:
- master
- Children:
- 5f1e78d, d6b6906
- Parents:
- c8b8c83 (diff), f1cf01c (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the(diff)
links above to see all the changes relative to each parent. - Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
Makefile
rc8b8c83 r3d952b5 185 185 186 186 -include .depend/*.d 187 # DO NOT DELETE -
otr.c
rc8b8c83 r3d952b5 8 8 OTR support (cf. http://www.cypherpunks.ca/otr/) 9 9 10 (c) 2008-201 0Sven Moritz Hallberg <pesco@khjk.org>10 (c) 2008-2011 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); 164 167 165 168 /* update op/voice flag of given user according to encryption state and settings … … 237 240 l = g_slist_prepend( l, "always" ); 238 241 s->eval_data = l; 242 243 s = set_add( &irc->b->set, "otr_does_html", "true", set_eval_bool, irc ); 239 244 240 245 return TRUE; … … 385 390 ConnContext *context = otrl_context_find(irc->otr->us, iu->bu->handle, 386 391 ic->acc->user, ic->acc->prpl->name, 0, NULL, NULL, NULL); 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); 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 } 403 419 } 404 420 } else { 405 421 colormsg = g_strdup(newmsg); 406 422 } 423 407 424 otrl_message_free(newmsg); 408 425 return colormsg; … … 421 438 if(ic->acc->prpl->options & OPT_NOOTR) { 422 439 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); 423 447 } 424 448 … … 608 632 irc_user_t *u; 609 633 irc_t *irc = ic->bee->ui_data; 610 const char *trust;611 634 612 635 u = peeruser(irc, context->username, context->protocol); … … 618 641 } 619 642 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); 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 } 627 648 } 628 649 … … 641 662 return; 642 663 } 643 u->flags &= ~( IRC_USER_OTR_ENCRYPTED | IRC_USER_OTR_TRUSTED);664 otr_update_uflags(context, u); 644 665 if(!otr_update_modeflags(irc, u)) 645 666 irc_usermsg(irc, "conversation with %s is now in the clear", u->nick); … … 660 681 return; 661 682 } 662 if(context->active_fingerprint->trust[0]) 663 u->flags |= IRC_USER_OTR_ENCRYPTED | IRC_USER_OTR_TRUSTED;664 else665 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);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 } 668 689 } 669 690 … … 1312 1333 } 1313 1334 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 1314 1352 int otr_update_modeflags(irc_t *irc, irc_user_t *u) 1315 1353 { 1316 return 1;1354 return 0; 1317 1355 } 1318 1356
Note: See TracChangeset
for help on using the changeset viewer.