Changeset ad2d8bc
- Timestamp:
- 2010-08-25T23:03:11Z (14 years ago)
- Branches:
- master
- Children:
- 8358691
- Parents:
- be999a5
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
Makefile
rbe999a5 rad2d8bc 10 10 11 11 # Program variables 12 objects = bitlbee.o dcc.o help.o ipc.o irc.o irc_im.o irc_channel.o irc_commands.o irc_send.o irc_user.o irc_util.o nick.o query.o root_commands.o set.o storage.o $(STORAGE_OBJS)12 objects = bitlbee.o dcc.o help.o ipc.o irc.o irc_im.o irc_channel.o irc_commands.o irc_send.o irc_user.o irc_util.o nick.o otr.o query.o root_commands.o set.o storage.o $(STORAGE_OBJS) 13 13 headers = bitlbee.h commands.h conf.h config.h help.h ipc.h irc.h log.h nick.h query.h set.h sock.h storage.h lib/events.h lib/ftutil.h lib/http_client.h lib/ini.h lib/md5.h lib/misc.h lib/proxy.h lib/sha1.h lib/ssl_client.h lib/url.h protocols/account.h protocols/bee.h protocols/ft.h protocols/nogaim.h 14 14 subdirs = lib protocols -
irc.h
rbe999a5 rad2d8bc 97 97 /* Replaced with iu->last_channel IRC_USER_PRIVATE = 1, */ 98 98 IRC_USER_AWAY = 2, 99 100 IRC_USER_OTR_ENCRYPTED = 0x10000, 101 IRC_USER_OTR_TRUSTED = 0x20000, 99 102 } irc_user_flags_t; 100 103 -
otr.c
rbe999a5 rad2d8bc 146 146 int hexval(char a); 147 147 148 /* determine the user_t for a given handle/protocol pair148 /* determine the irc_user_t for a given handle/protocol pair 149 149 returns NULL if not found */ 150 user_t *peeruser(irc_t *irc, const char *handle, const char *protocol);150 irc_user_t *peeruser(irc_t *irc, const char *handle, const char *protocol); 151 151 152 152 /* handle SMP TLVs from a received message */ … … 156 156 returns 0 if neither op_buddies nor voice_buddies is set to "encrypted", 157 157 i.e. msgstate should be announced seperately */ 158 int otr_update_modeflags(irc_t *irc, user_t *u);158 int otr_update_modeflags(irc_t *irc, irc_user_t *u); 159 159 160 160 /* show general info about the OTR subsystem; called by 'otr info' */ … … 238 238 int kg=0; 239 239 240 g_snprintf(s, 511, "%s%s.otr_keys", global.conf->configdir, irc-> nick);240 g_snprintf(s, 511, "%s%s.otr_keys", global.conf->configdir, irc->user->nick); 241 241 e = otrl_privkey_read(irc->otr->us, s); 242 242 if(e && e!=enoent) { 243 243 irc_usermsg(irc, "otr load: %s: %s", s, gcry_strerror(e)); 244 244 } 245 g_snprintf(s, 511, "%s%s.otr_fprints", global.conf->configdir, irc-> nick);245 g_snprintf(s, 511, "%s%s.otr_fprints", global.conf->configdir, irc->user->nick); 246 246 e = otrl_privkey_read_fingerprints(irc->otr->us, s, NULL, NULL); 247 247 if(e && e!=enoent) { … … 250 250 251 251 /* check for otr keys on all accounts */ 252 for(a=irc-> accounts; a; a=a->next) {252 for(a=irc->b->accounts; a; a=a->next) { 253 253 kg = otr_check_for_key(a) || kg; 254 254 } … … 269 269 gcry_error_t e; 270 270 271 g_snprintf(s, 511, "%s%s.otr_fprints", global.conf->configdir, irc-> nick);271 g_snprintf(s, 511, "%s%s.otr_fprints", global.conf->configdir, irc->user->nick); 272 272 e = otrl_privkey_write_fingerprints(irc->otr->us, s); 273 273 if(e) { … … 301 301 int otr_check_for_key(account_t *a) 302 302 { 303 irc_t *irc = a-> irc;303 irc_t *irc = a->bee->ui_data; 304 304 OtrlPrivKey *k; 305 305 … … 329 329 OtrlTLV *tlvs = NULL; 330 330 char *colormsg; 331 irc_t *irc = ic->bee->ui_data; 331 332 332 333 /* don't do OTR on certain (not classic IM) protocols, e.g. twitter */ … … 335 336 } 336 337 337 ignore_msg = otrl_message_receiving(i c->irc->otr->us, &global.otr_ops, ic,338 ignore_msg = otrl_message_receiving(irc->otr->us, &global.otr_ops, ic, 338 339 ic->acc->user, ic->acc->prpl->name, handle, msg, &newmsg, 339 340 &tlvs, NULL, NULL); … … 349 350 } else { 350 351 /* OTR has processed this message */ 351 ConnContext *context = otrl_context_find(i c->irc->otr->us, handle,352 ConnContext *context = otrl_context_find(irc->otr->us, handle, 352 353 ic->acc->user, ic->acc->prpl->name, 0, NULL, NULL, NULL); 353 354 if(context && context->msgstate == OTRL_MSGSTATE_ENCRYPTED && 354 set_getbool(&ic-> irc->set, "color_encrypted")) {355 set_getbool(&ic->bee->set, "color_encrypted")) { 355 356 /* color according to f'print trust */ 356 357 int color; … … 381 382 char *otrmsg = NULL; 382 383 ConnContext *ctx = NULL; 384 irc_t *irc = ic->bee->ui_data; 383 385 384 386 /* don't do OTR on certain (not classic IM) protocols, e.g. twitter */ 385 387 if(ic->acc->prpl->options & OPT_NOOTR) { 386 return (ic->acc->prpl->buddy_msg(ic, handle, msg, flags)); 387 } 388 389 st = otrl_message_sending(ic->irc->otr->us, &global.otr_ops, ic, 388 /* TODO(wilmer): const */ 389 return (ic->acc->prpl->buddy_msg(ic, (char*) handle, (char*) msg, flags)); 390 } 391 392 st = otrl_message_sending(irc->otr->us, &global.otr_ops, ic, 390 393 ic->acc->user, ic->acc->prpl->name, handle, 391 394 msg, NULL, &otrmsg, NULL, NULL); … … 394 397 } 395 398 396 ctx = otrl_context_find(i c->irc->otr->us,399 ctx = otrl_context_find(irc->otr->us, 397 400 handle, ic->acc->user, ic->acc->prpl->name, 398 401 1, NULL, NULL, NULL); … … 451 454 { 452 455 struct im_connection *ic = check_imc(opdata, context->accountname, context->protocol); 456 irc_t *irc = ic->bee->ui_data; 453 457 const char *p; 454 458 455 459 /* policy override during keygen: if we're missing the key for context but are currently 456 460 generating it, then that's as much as we can do. => temporarily return NEVER. */ 457 if(keygen_in_progress(i c->irc, context->accountname, context->protocol) &&458 !otrl_privkey_find(i c->irc->otr->us, context->accountname, context->protocol))461 if(keygen_in_progress(irc, context->accountname, context->protocol) && 462 !otrl_privkey_find(irc->otr->us, context->accountname, context->protocol)) 459 463 return OTRL_POLICY_NEVER; 460 464 461 p = set_getstr(&ic-> irc->set, "otr_policy");465 p = set_getstr(&ic->bee->set, "otr_policy"); 462 466 if(!strcmp(p, "never")) 463 467 return OTRL_POLICY_NEVER; … … 476 480 { 477 481 struct im_connection *ic = check_imc(opdata, accountname, protocol); 482 irc_t *irc = ic->bee->ui_data; 478 483 479 484 /* will fail silently if keygen already in progress */ 480 otr_keygen(i c->irc, accountname, protocol);485 otr_keygen(irc, accountname, protocol); 481 486 } 482 487 … … 485 490 { 486 491 struct im_connection *ic = check_imc(opdata, accountname, protocol); 487 user_t *u;488 489 /* lookup the user_t for the given recipient */490 u = user_findhandle(ic, recipient);491 if( u) {492 if( u->online)492 bee_user_t *bu; 493 494 /* lookup the irc_user_t for the given recipient */ 495 bu = bee_user_by_handle(ic->bee, ic, recipient); 496 if(bu) { 497 if(bu->flags & BEE_USER_ONLINE) 493 498 return 1; 494 499 else … … 503 508 { 504 509 struct im_connection *ic = check_imc(opdata, accountname, protocol); 510 irc_t *irc = ic->bee->ui_data; 505 511 506 512 if (strcmp(accountname, recipient) == 0) { 507 513 /* huh? injecting messages to myself? */ 508 irc_usermsg(i c->irc, "note to self: %s", message);514 irc_usermsg(irc, "note to self: %s", message); 509 515 } else { 510 516 /* need to drop some consts here :-( */ … … 520 526 struct im_connection *ic = check_imc(opdata, accountname, protocol); 521 527 char *msg = g_strdup(message); 528 irc_t *irc = ic->bee->ui_data; 522 529 523 530 strip_html(msg); 524 irc_usermsg(i c->irc, "otr: %s", msg);531 irc_usermsg(irc, "otr: %s", msg); 525 532 526 533 g_free(msg); … … 533 540 { 534 541 struct im_connection *ic = check_imc(opdata, accountname, protocol); 542 irc_t *irc = ic->bee->ui_data; 535 543 char hunam[45]; /* anybody looking? ;-) */ 536 544 537 545 otrl_privkey_hash_to_human(hunam, fingerprint); 538 irc_usermsg(i c->irc, "new fingerprint for %s: %s",539 peernick(i c->irc, username, protocol), hunam);546 irc_usermsg(irc, "new fingerprint for %s: %s", 547 peernick(irc, username, protocol), hunam); 540 548 } 541 549 … … 543 551 { 544 552 struct im_connection *ic = (struct im_connection *)opdata; 545 546 otr_save(ic->irc); 553 irc_t *irc = ic->bee->ui_data; 554 555 otr_save(irc); 547 556 } 548 557 … … 551 560 struct im_connection *ic = 552 561 check_imc(opdata, context->accountname, context->protocol); 553 user_t *u; 562 irc_user_t *u; 563 irc_t *irc = ic->bee->ui_data; 554 564 const char *trust; 555 565 556 u = peeruser(i c->irc, context->username, context->protocol);566 u = peeruser(irc, context->username, context->protocol); 557 567 if(!u) { 558 568 log_message(LOGLVL_ERROR, 559 "BUG: otr.c: op_gone_secure: user_t for %s/%s/%s not found!",569 "BUG: otr.c: op_gone_secure: irc_user_t for %s/%s/%s not found!", 560 570 context->username, context->protocol, context->accountname); 561 571 return; … … 564 574 trust = context->active_fingerprint->trust; 565 575 if(trust && trust[0]) 566 u-> encrypted = 2;576 u->flags |= IRC_USER_OTR_ENCRYPTED | IRC_USER_OTR_TRUSTED; 567 577 else 568 u-> encrypted = 1;569 if(!otr_update_modeflags(i c->irc, u))570 irc_usermsg(i c->irc, "conversation with %s is now off the record", u->nick);578 u->flags = ( u->flags & ~IRC_USER_OTR_TRUSTED ) | IRC_USER_OTR_ENCRYPTED; 579 if(!otr_update_modeflags(irc, u)) 580 irc_usermsg(irc, "conversation with %s is now off the record", u->nick); 571 581 } 572 582 … … 575 585 struct im_connection *ic = 576 586 check_imc(opdata, context->accountname, context->protocol); 577 user_t *u; 578 579 u = peeruser(ic->irc, context->username, context->protocol); 587 irc_t *irc = ic->bee->ui_data; 588 irc_user_t *u; 589 590 u = peeruser(irc, context->username, context->protocol); 580 591 if(!u) { 581 592 log_message(LOGLVL_ERROR, 582 "BUG: otr.c: op_gone_insecure: user_t for %s/%s/%s not found!",593 "BUG: otr.c: op_gone_insecure: irc_user_t for %s/%s/%s not found!", 583 594 context->username, context->protocol, context->accountname); 584 595 return; 585 596 } 586 u-> encrypted = 0;587 if(!otr_update_modeflags(i c->irc, u))588 irc_usermsg(i c->irc, "conversation with %s is now in the clear", u->nick);597 u->flags &= ~( IRC_USER_OTR_ENCRYPTED | IRC_USER_OTR_TRUSTED ); 598 if(!otr_update_modeflags(irc, u)) 599 irc_usermsg(irc, "conversation with %s is now in the clear", u->nick); 589 600 } 590 601 … … 593 604 struct im_connection *ic = 594 605 check_imc(opdata, context->accountname, context->protocol); 595 user_t *u; 596 597 u = peeruser(ic->irc, context->username, context->protocol); 606 irc_t *irc = ic->bee->ui_data; 607 irc_user_t *u; 608 609 u = peeruser(irc, context->username, context->protocol); 598 610 if(!u) { 599 611 log_message(LOGLVL_ERROR, 600 "BUG: otr.c: op_still_secure: user_t for %s/%s/%s not found!",612 "BUG: otr.c: op_still_secure: irc_user_t for %s/%s/%s not found!", 601 613 context->username, context->protocol, context->accountname); 602 614 return; 603 615 } 604 616 if(context->active_fingerprint->trust[0]) 605 u-> encrypted = 2;617 u->flags |= IRC_USER_OTR_ENCRYPTED | IRC_USER_OTR_TRUSTED; 606 618 else 607 u-> encrypted = 1;608 if(!otr_update_modeflags(i c->irc, u))609 irc_usermsg(i c->irc, "otr connection with %s has been refreshed", u->nick);619 u->flags = ( u->flags & ~IRC_USER_OTR_TRUSTED ) | IRC_USER_OTR_ENCRYPTED; 620 if(!otr_update_modeflags(irc, u)) 621 irc_usermsg(irc, "otr connection with %s has been refreshed", u->nick); 610 622 } 611 623 … … 630 642 { 631 643 struct im_connection *ic = (struct im_connection *)opdata; 632 633 return peernick(ic->irc, account, protocol); 644 irc_t *irc = ic->bee->ui_data; 645 646 return peernick(irc, account, protocol); 634 647 } 635 648 … … 639 652 void cmd_otr_disconnect(irc_t *irc, char **args) 640 653 { 641 user_t *u;642 643 u = user_find(irc, args[1]);644 if(!u || !u-> ic) {654 irc_user_t *u; 655 656 u = irc_user_by_name(irc, args[1]); 657 if(!u || !u->bu || !u->bu->ic) { 645 658 irc_usermsg(irc, "%s: unknown user", args[1]); 646 659 return; … … 648 661 649 662 otrl_message_disconnect(irc->otr->us, &global.otr_ops, 650 u-> ic, u->ic->acc->user, u->ic->acc->prpl->name,u->handle);663 u->bu->ic, u->bu->ic->acc->user, u->bu->ic->acc->prpl->name, u->bu->handle); 651 664 652 665 /* for some reason, libotr (3.1.0) doesn't do this itself: */ 653 if(u-> encrypted) {666 if(u->flags & IRC_USER_OTR_ENCRYPTED) { 654 667 ConnContext *ctx; 655 ctx = otrl_context_find(irc->otr->us, u-> handle,u->ic->acc->user,656 u-> ic->acc->prpl->name, 0, NULL, NULL, NULL);668 ctx = otrl_context_find(irc->otr->us, u->bu->handle, u->bu->ic->acc->user, 669 u->bu->ic->acc->prpl->name, 0, NULL, NULL, NULL); 657 670 if(ctx) 658 op_gone_insecure(u-> ic, ctx);671 op_gone_insecure(u->bu->ic, ctx); 659 672 else /* huh? */ 660 u-> encrypted = 0;673 u->flags &= ( IRC_USER_OTR_ENCRYPTED | IRC_USER_OTR_TRUSTED ); 661 674 } 662 675 } … … 664 677 void cmd_otr_connect(irc_t *irc, char **args) 665 678 { 666 user_t *u;667 668 u = user_find(irc, args[1]);669 if(!u || !u-> ic) {679 irc_user_t *u; 680 681 u = irc_user_by_name(irc, args[1]); 682 if(!u || !u->bu || !u->bu->ic) { 670 683 irc_usermsg(irc, "%s: unknown user", args[1]); 671 684 return; 672 685 } 673 if(! u->online) {686 if(!(u->bu->flags & BEE_USER_ONLINE)) { 674 687 irc_usermsg(irc, "%s is offline", args[1]); 675 688 return; 676 689 } 677 690 678 imc_buddy_msg(u->ic, u->handle, "?OTR?", 0);691 /* TODO(wilmer): imc_buddy_msg(u->bu->ic, u->bu->handle, "?OTR?", 0); */ 679 692 } 680 693 681 694 void cmd_otr_smp(irc_t *irc, char **args) 682 695 { 683 user_t *u;696 irc_user_t *u; 684 697 ConnContext *ctx; 685 698 686 u = user_find(irc, args[1]);687 if(!u || !u-> ic) {699 u = irc_user_by_name(irc, args[1]); 700 if(!u || !u->bu || !u->bu->ic) { 688 701 irc_usermsg(irc, "%s: unknown user", args[1]); 689 702 return; 690 703 } 691 if(! u->online) {704 if(!(u->bu->flags & BEE_USER_ONLINE)) { 692 705 irc_usermsg(irc, "%s is offline", args[1]); 693 706 return; 694 707 } 695 708 696 ctx = otrl_context_find(irc->otr->us, u-> handle,697 u-> ic->acc->user,u->ic->acc->prpl->name, 1, NULL, NULL, NULL);709 ctx = otrl_context_find(irc->otr->us, u->bu->handle, 710 u->bu->ic->acc->user, u->bu->ic->acc->prpl->name, 1, NULL, NULL, NULL); 698 711 if(!ctx) { 699 712 /* huh? out of memory or what? */ … … 705 718 "SMP already in phase %d, sending abort before reinitiating", 706 719 ctx->smstate->nextExpected+1); 707 otrl_message_abort_smp(irc->otr->us, &global.otr_ops, u-> ic, ctx);720 otrl_message_abort_smp(irc->otr->us, &global.otr_ops, u->bu->ic, ctx); 708 721 otrl_sm_state_free(ctx->smstate); 709 722 } … … 714 727 irc_usermsg(irc, "smp: initiating with %s...", u->nick); 715 728 otrl_message_initiate_smp(irc->otr->us, &global.otr_ops, 716 u-> ic, ctx, (unsigned char *)args[2], strlen(args[2]));729 u->bu->ic, ctx, (unsigned char *)args[2], strlen(args[2])); 717 730 /* smp is now in EXPECT2 */ 718 731 } else { … … 721 734 irc_usermsg(irc, "smp: responding to %s...", u->nick); 722 735 otrl_message_respond_smp(irc->otr->us, &global.otr_ops, 723 u-> ic, ctx, (unsigned char *)args[2], strlen(args[2]));736 u->bu->ic, ctx, (unsigned char *)args[2], strlen(args[2])); 724 737 /* smp is now in EXPECT3 */ 725 738 } … … 728 741 void cmd_otr_trust(irc_t *irc, char **args) 729 742 { 730 user_t *u;743 irc_user_t *u; 731 744 ConnContext *ctx; 732 745 unsigned char raw[20]; … … 734 747 int i,j; 735 748 736 u = user_find(irc, args[1]);737 if(!u || !u-> ic) {749 u = irc_user_by_name(irc, args[1]); 750 if(!u || !u->bu || !u->bu->ic) { 738 751 irc_usermsg(irc, "%s: unknown user", args[1]); 739 752 return; 740 753 } 741 754 742 ctx = otrl_context_find(irc->otr->us, u-> handle,743 u-> ic->acc->user,u->ic->acc->prpl->name, 0, NULL, NULL, NULL);755 ctx = otrl_context_find(irc->otr->us, u->bu->handle, 756 u->bu->ic->acc->user, u->bu->ic->acc->prpl->name, 0, NULL, NULL, NULL); 744 757 if(!ctx) { 745 758 irc_usermsg(irc, "%s: no otr context with user", args[1]); … … 780 793 otrl_context_set_trust(fp, trust); 781 794 irc_usermsg(irc, "fingerprint match, trust set to \"%s\"", trust); 782 if(u-> encrypted)783 u-> encrypted = 2;795 if(u->flags & IRC_USER_OTR_ENCRYPTED) 796 u->flags |= IRC_USER_OTR_TRUSTED; 784 797 otr_update_modeflags(irc, u); 785 798 } … … 812 825 } 813 826 } else { 814 user_t *u = user_find(irc, args[1]);815 if(!u || !u-> ic) {827 irc_user_t *u = irc_user_by_name(irc, args[1]); 828 if(!u || !u->bu || !u->bu->ic) { 816 829 irc_usermsg(irc, "%s: unknown user", args[1]); 817 830 g_free(arg); 818 831 return; 819 832 } 820 ctx = otrl_context_find(irc->otr->us, u-> handle,u->ic->acc->user,821 u-> ic->acc->prpl->name, 0, NULL, NULL, NULL);833 ctx = otrl_context_find(irc->otr->us, u->bu->handle, u->bu->ic->acc->user, 834 u->bu->ic->acc->prpl->name, 0, NULL, NULL, NULL); 822 835 if(!ctx) { 823 836 irc_usermsg(irc, "no otr context with %s", args[1]); … … 848 861 } 849 862 850 a = irc-> accounts;863 a = irc->b->accounts; 851 864 for(i=0; i<n && a; i++, a=a->next); 852 865 if(!a) { … … 862 875 if(otrl_privkey_find(irc->otr->us, a->user, a->prpl->name)) { 863 876 char *s = g_strdup_printf("account %d already has a key, replace it?", n); 864 query_add(irc, NULL, s, yes_keygen, NULL, a);877 query_add(irc, NULL, s, yes_keygen, NULL, NULL, a); 865 878 g_free(s); 866 879 } else { … … 918 931 if(!strcmp(args[1], "fingerprint")) 919 932 { 920 user_t *u;933 irc_user_t *u; 921 934 ConnContext *ctx; 922 935 Fingerprint *fp; … … 931 944 932 945 /* TODO: allow context specs ("user/proto/account") in 'otr forget fingerprint'? */ 933 u = user_find(irc, args[2]);934 if(!u || !u-> ic) {946 u = irc_user_by_name(irc, args[2]); 947 if(!u || !u->bu || !u->bu->ic) { 935 948 irc_usermsg(irc, "%s: unknown user", args[2]); 936 949 return; 937 950 } 938 951 939 ctx = otrl_context_find(irc->otr->us, u-> handle,u->ic->acc->user,940 u-> ic->acc->prpl->name, 0, NULL, NULL, NULL);952 ctx = otrl_context_find(irc->otr->us, u->bu->handle, u->bu->ic->acc->user, 953 u->bu->ic->acc->prpl->name, 0, NULL, NULL, NULL); 941 954 if(!ctx) { 942 955 irc_usermsg(irc, "no otr context with %s", args[2]); … … 962 975 p->fst = irc; 963 976 p->snd = fp; 964 query_add(irc, NULL, s, yes_forget_fingerprint, NULL, p);977 query_add(irc, NULL, s, yes_forget_fingerprint, NULL, NULL, p); 965 978 g_free(s); 966 979 } … … 968 981 else if(!strcmp(args[1], "context")) 969 982 { 970 user_t *u;983 irc_user_t *u; 971 984 ConnContext *ctx; 972 985 char *s; … … 974 987 975 988 /* TODO: allow context specs ("user/proto/account") in 'otr forget contex'? */ 976 u = user_find(irc, args[2]);977 if(!u || !u-> ic) {989 u = irc_user_by_name(irc, args[2]); 990 if(!u || !u->bu || !u->bu->ic) { 978 991 irc_usermsg(irc, "%s: unknown user", args[2]); 979 992 return; 980 993 } 981 994 982 ctx = otrl_context_find(irc->otr->us, u-> handle,u->ic->acc->user,983 u-> ic->acc->prpl->name, 0, NULL, NULL, NULL);995 ctx = otrl_context_find(irc->otr->us, u->bu->handle, u->bu->ic->acc->user, 996 u->bu->ic->acc->prpl->name, 0, NULL, NULL, NULL); 984 997 if(!ctx) { 985 998 irc_usermsg(irc, "no otr context with %s", args[2]); … … 998 1011 p->fst = irc; 999 1012 p->snd = ctx; 1000 query_add(irc, NULL, s, yes_forget_context, NULL, p);1013 query_add(irc, NULL, s, yes_forget_context, NULL, NULL, p); 1001 1014 g_free(s); 1002 1015 } … … 1015 1028 s = g_strdup_printf("about to forget the private key for %s/%s, are you sure?", 1016 1029 key->accountname, key->protocol); 1017 query_add(irc, NULL, s, yes_forget_key, NULL, key);1030 query_add(irc, NULL, s, yes_forget_key, NULL, NULL, key); 1018 1031 g_free(s); 1019 1032 } … … 1032 1045 void otr_handle_smp(struct im_connection *ic, const char *handle, OtrlTLV *tlvs) 1033 1046 { 1034 irc_t *irc = ic-> irc;1047 irc_t *irc = ic->bee->ui_data; 1035 1048 OtrlUserState us = irc->otr->us; 1036 1049 OtrlMessageAppOps *ops = &global.otr_ops; … … 1038 1051 ConnContext *context; 1039 1052 NextExpectedSMP nextMsg; 1040 user_t *u; 1041 1042 u = user_findhandle(ic, handle); 1043 if(!u) return; 1053 irc_user_t *u; 1054 bee_user_t *bu; 1055 1056 bu = bee_user_by_handle(ic->bee, ic, handle); 1057 if(!bu || !(u = bu->ui_data)) return; 1044 1058 context = otrl_context_find(us, handle, 1045 1059 ic->acc->user, ic->acc->prpl->name, 1, NULL, NULL, NULL); … … 1054 1068 if (nextMsg != OTRL_SMP_EXPECT1) { 1055 1069 irc_usermsg(irc, "smp %s: spurious SMP1 received, aborting", u->nick); 1056 otrl_message_abort_smp(us, ops, u-> ic, context);1070 otrl_message_abort_smp(us, ops, u->bu->ic, context); 1057 1071 otrl_sm_state_free(context->smstate); 1058 1072 } else { … … 1067 1081 if (nextMsg != OTRL_SMP_EXPECT2) { 1068 1082 irc_usermsg(irc, "smp %s: spurious SMP2 received, aborting", u->nick); 1069 otrl_message_abort_smp(us, ops, u-> ic, context);1083 otrl_message_abort_smp(us, ops, u->bu->ic, context); 1070 1084 otrl_sm_state_free(context->smstate); 1071 1085 } else { … … 1078 1092 if (nextMsg != OTRL_SMP_EXPECT3) { 1079 1093 irc_usermsg(irc, "smp %s: spurious SMP3 received, aborting", u->nick); 1080 otrl_message_abort_smp(us, ops, u-> ic, context);1094 otrl_message_abort_smp(us, ops, u->bu->ic, context); 1081 1095 otrl_sm_state_free(context->smstate); 1082 1096 } else { … … 1098 1112 if (nextMsg != OTRL_SMP_EXPECT4) { 1099 1113 irc_usermsg(irc, "smp %s: spurious SMP4 received, aborting", u->nick); 1100 otrl_message_abort_smp(us, ops, u-> ic, context);1114 otrl_message_abort_smp(us, ops, u->bu->ic, context); 1101 1115 otrl_sm_state_free(context->smstate); 1102 1116 } else { … … 1143 1157 } 1144 1158 1145 user_t *peeruser(irc_t *irc, const char *handle, const char *protocol) 1146 { 1147 user_t *u; 1148 1149 for(u=irc->users; u; u=u->next) { 1159 irc_user_t *peeruser(irc_t *irc, const char *handle, const char *protocol) 1160 { 1161 GSList *l; 1162 1163 for(l=irc->b->users; l; l = l->next) { 1164 bee_user_t *bu = l->data; 1150 1165 struct prpl *prpl; 1151 if(! u->ic || !u->handle)1166 if(!bu->ui_data || !bu->ic || !bu->handle) 1152 1167 continue; 1153 prpl = u->ic->acc->prpl;1168 prpl = bu->ic->acc->prpl; 1154 1169 if(strcmp(prpl->name, protocol) == 0 1155 && prpl->handle_cmp( u->handle, handle) == 0) {1156 return u;1170 && prpl->handle_cmp(bu->handle, handle) == 0) { 1171 return bu->ui_data; 1157 1172 } 1158 1173 } … … 1179 1194 static char fallback[512]; 1180 1195 1181 user_t *u = peeruser(irc, handle, protocol);1196 irc_user_t *u = peeruser(irc, handle, protocol); 1182 1197 if(u) { 1183 1198 return u->nick; … … 1188 1203 } 1189 1204 1190 int otr_update_modeflags(irc_t *irc, user_t *u) 1191 { 1192 char *vb = set_getstr(&irc->set, "voice_buddies"); 1193 char *hb = set_getstr(&irc->set, "halfop_buddies"); 1194 char *ob = set_getstr(&irc->set, "op_buddies"); 1195 int encrypted = u->encrypted; 1196 int trusted = u->encrypted > 1; 1197 char flags[7]; 1198 int nflags=0; 1199 char *p = flags; 1200 char *from; 1201 int i; 1202 1203 if(!strcmp(vb, "encrypted")) { 1204 *(p++) = encrypted ? '+' : '-'; 1205 *(p++) = 'v'; 1206 nflags++; 1207 } else if(!strcmp(vb, "trusted")) { 1208 *(p++) = trusted ? '+' : '-'; 1209 *(p++) = 'v'; 1210 nflags++; 1211 } 1212 if(!strcmp(hb, "encrypted")) { 1213 *(p++) = encrypted ? '+' : '-'; 1214 *(p++) = 'h'; 1215 nflags++; 1216 } else if(!strcmp(hb, "trusted")) { 1217 *(p++) = trusted ? '+' : '-'; 1218 *(p++) = 'h'; 1219 nflags++; 1220 } 1221 if(!strcmp(ob, "encrypted")) { 1222 *(p++) = encrypted ? '+' : '-'; 1223 *(p++) = 'o'; 1224 nflags++; 1225 } else if(!strcmp(ob, "trusted")) { 1226 *(p++) = trusted ? '+' : '-'; 1227 *(p++) = 'o'; 1228 nflags++; 1229 } 1230 *p = '\0'; 1231 1232 p = g_malloc(nflags * (strlen(u->nick)+1) + 1); 1233 *p = '\0'; 1234 if(!p) 1235 return 0; 1236 for(i=0; i<nflags; i++) { 1237 strcat(p, " "); 1238 strcat(p, u->nick); 1239 } 1240 if(set_getbool(&irc->set, "simulate_netsplit")) 1241 from = g_strdup(irc->myhost); 1242 else 1243 from = g_strdup_printf("%s!%s@%s", irc->mynick, irc->mynick, irc->myhost); 1244 irc_write(irc, ":%s MODE %s %s%s", from, irc->channel, flags, p); 1245 g_free(from); 1246 g_free(p); 1247 1205 int otr_update_modeflags(irc_t *irc, irc_user_t *u) 1206 { 1248 1207 return 1; 1249 1208 } … … 1450 1409 irc_usermsg(irc, "\x1f" "connection contexts:\x1f (bold=currently encrypted)"); 1451 1410 for(ctx=irc->otr->us->context_root; ctx; ctx=ctx->next) {\ 1452 user_t *u;1411 irc_user_t *u; 1453 1412 char *userstring; 1454 1413 … … 1576 1535 irc->otr->sent_protocol = NULL; 1577 1536 irc->otr->todo = NULL; 1578 b_input_add(from[0], GAIM_INPUT_READ, keygen_finish_handler, irc);1537 b_input_add(from[0], B_EV_IO_READ, keygen_finish_handler, irc); 1579 1538 } 1580 1539 … … 1641 1600 irc_usermsg(irc, "%s", msg); 1642 1601 if(filename[0]) { 1643 char *kf = g_strdup_printf("%s%s.otr_keys", global.conf->configdir, irc-> nick);1602 char *kf = g_strdup_printf("%s%s.otr_keys", global.conf->configdir, irc->user->nick); 1644 1603 char *tmp = g_strdup_printf("%s.new", kf); 1645 1604 copyfile(filename, tmp); … … 1709 1668 { 1710 1669 account_t *acc = (account_t *)data; 1711 1712 if(keygen_in_progress(acc->irc, acc->user, acc->prpl->name)) { 1713 irc_usermsg(acc->irc, "keygen for %s/%s already in progress", 1670 irc_t *irc = acc->bee->ui_data; 1671 1672 if(keygen_in_progress(irc, acc->user, acc->prpl->name)) { 1673 irc_usermsg(irc, "keygen for %s/%s already in progress", 1714 1674 acc->user, acc->prpl->name); 1715 1675 } else { 1716 irc_usermsg( acc->irc, "starting background keygen for %s/%s",1676 irc_usermsg(irc, "starting background keygen for %s/%s", 1717 1677 acc->user, acc->prpl->name); 1718 irc_usermsg( acc->irc, "you will be notified when it completes");1719 otr_keygen( acc->irc, acc->user, acc->prpl->name);1678 irc_usermsg(irc, "you will be notified when it completes"); 1679 otr_keygen(irc, acc->user, acc->prpl->name); 1720 1680 } 1721 1681 }
Note: See TracChangeset
for help on using the changeset viewer.