- Timestamp:
- 2013-08-01T15:47:48Z (11 years ago)
- Branches:
- master
- Children:
- 5d2bc9d
- Parents:
- a685409
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
otr.c
ra685409 r81265e0 8 8 OTR support (cf. http://www.cypherpunks.ca/otr/) 9 9 10 (c) 2008-2011 Sven Moritz Hallberg <pesco@khjk.org>11 (c) 2008funded by stonedcoder.org10 (c) 2008-2011,2013 Sven Moritz Hallberg <pesco@khjk.org> 11 funded by stonedcoder.org 12 12 13 13 files used to store OTR data: … … 208 208 otr_ops.is_logged_in = &op_is_logged_in; 209 209 otr_ops.inject_message = &op_inject_message; 210 otr_ops.notify = NULL; 211 otr_ops.display_otr_message = &op_display_otr_message; 210 //XXX otr_ops.display_otr_message = &op_display_otr_message; 212 211 otr_ops.update_context_list = NULL; 213 otr_ops.protocol_name = NULL;214 otr_ops.protocol_name_free = NULL;215 212 otr_ops.new_fingerprint = &op_new_fingerprint; 216 213 otr_ops.write_fingerprints = &op_write_fingerprints; … … 218 215 otr_ops.gone_insecure = &op_gone_insecure; 219 216 otr_ops.still_secure = &op_still_secure; 220 otr_ops.log_message = &op_log_message;217 //XXX otr_ops.log_message = &op_log_message; 221 218 otr_ops.max_message_size = &op_max_message_size; 222 219 otr_ops.account_name = &op_account_name; 223 220 otr_ops.account_name_free = NULL; 224 221 222 /* stuff added with libotr 4.0.0 */ 223 otr_ops.received_symkey = NULL; /* we don't use the extra key */ 224 otr_ops.otr_error_message = NULL; // TODO? 225 otr_ops.otr_error_message_free = NULL; 226 otr_ops.resent_msg_prefix = NULL; // XXX don't need? 227 otr_ops.resent_msg_prefix_free = NULL; 228 otr_ops.handle_smp_event = NULL; // XXX replace smp state machine w/this 229 otr_ops.handle_msg_event = NULL; // XXX 230 otr_ops.create_instag = NULL; // XXX 231 otr_ops.convert_msg = NULL; // XXX other plugins? de/htmlize? 232 otr_ops.timer_control = NULL; // XXX call otrl_message_poll reg'ly 233 225 234 root_command_add( "otr", 1, cmd_otr, 0 ); 226 235 register_irc_plugin( &otr_plugin ); … … 386 395 ignore_msg = otrl_message_receiving(irc->otr->us, &otr_ops, ic, 387 396 ic->acc->user, ic->acc->prpl->name, iu->bu->handle, msg, &newmsg, 388 &tlvs, NULL, NULL );397 &tlvs, NULL, NULL, NULL); 389 398 390 399 otr_handle_smp(ic, iu->bu->handle, tlvs); … … 397 406 return msg; 398 407 } else { 408 /* XXX move this to convert callback */ 409 399 410 /* OTR has processed this message */ 400 411 ConnContext *context = otrl_context_find(irc->otr->us, iu->bu->handle, 401 ic->acc->user, ic->acc->prpl->name, 0, NULL, NULL, NULL);412 ic->acc->user, ic->acc->prpl->name, OTRL_INSTAG_MASTER, 0, NULL, NULL, NULL); 402 413 403 414 /* we're done with the original msg, which will be caller-freed. */ … … 459 470 irc_t *irc = iu->irc; 460 471 struct im_connection *ic = iu->bu->ic; 472 otrl_instag_t instag = OTRL_INSTAG_MASTER; // XXX? 461 473 462 474 /* don't do OTR on certain (not classic IM) protocols, e.g. twitter */ … … 467 479 ctx = otrl_context_find(irc->otr->us, 468 480 iu->bu->handle, ic->acc->user, ic->acc->prpl->name, 469 1, NULL, NULL, NULL);481 instag, 1, NULL, NULL, NULL); 470 482 471 483 /* HTML encoding */ … … 478 490 479 491 st = otrl_message_sending(irc->otr->us, &otr_ops, ic, 480 ic->acc->user, ic->acc->prpl->name, iu->bu->handle, 481 emsg, NULL, &otrmsg, NULL, NULL);492 ic->acc->user, ic->acc->prpl->name, iu->bu->handle, instag, 493 emsg, NULL, &otrmsg, OTRL_FRAGMENT_SEND_SKIP, NULL, NULL, NULL); 482 494 if(emsg != msg) { 483 495 g_free(emsg); /* we're done with this one */ … … 492 504 return NULL; 493 505 } 494 st = otrl_message_fragment_and_send(&otr_ops, ic, ctx,495 otrmsg, OTRL_FRAGMENT_SEND_ALL, NULL);506 otr_ops.inject_message(ic, ctx->accountname, 507 ctx->protocol, ctx->username, otrmsg); 496 508 otrl_message_free(otrmsg); 497 509 } else { … … 774 786 } 775 787 776 otrl_message_disconnect(irc->otr->us, &otr_ops, 788 /* XXX we disconnect all instances; is that what we want? */ 789 otrl_message_disconnect_all_instances(irc->otr->us, &otr_ops, 777 790 u->bu->ic, u->bu->ic->acc->user, u->bu->ic->acc->prpl->name, u->bu->handle); 778 791 779 /* for some reason, libotr (3.1.0) doesn't do this itself: */ 780 if(u->flags & IRC_USER_OTR_ENCRYPTED) { 781 ConnContext *ctx; 782 ctx = otrl_context_find(irc->otr->us, u->bu->handle, u->bu->ic->acc->user, 783 u->bu->ic->acc->prpl->name, 0, NULL, NULL, NULL); 784 if(ctx) 785 op_gone_insecure(u->bu->ic, ctx); 786 else /* huh? */ 787 u->flags &= ( IRC_USER_OTR_ENCRYPTED | IRC_USER_OTR_TRUSTED ); 788 } 792 /* for some reason, libotr (4.0.0) doesn't do this itself: */ 793 if(!(u->flags & IRC_USER_OTR_ENCRYPTED)) 794 return; 795 796 ConnContext *ctx, *p; 797 ctx = otrl_context_find(irc->otr->us, u->bu->handle, u->bu->ic->acc->user, 798 u->bu->ic->acc->prpl->name, OTRL_INSTAG_MASTER, 0, NULL, NULL, NULL); 799 if(!ctx) { /* huh? */ 800 u->flags &= ( IRC_USER_OTR_ENCRYPTED | IRC_USER_OTR_TRUSTED ); 801 return; 802 } 803 804 for(p=ctx; p && p->m_context == ctx->m_context; p=p->next) 805 op_gone_insecure(u->bu->ic, p); 789 806 } 790 807 … … 831 848 832 849 ctx = otrl_context_find(irc->otr->us, u->bu->handle, 833 u->bu->ic->acc->user, u->bu->ic->acc->prpl->name, 0, NULL, NULL, NULL);850 u->bu->ic->acc->user, u->bu->ic->acc->prpl->name, OTRL_INSTAG_MASTER, 0, NULL, NULL, NULL); // XXX 834 851 if(!ctx) { 835 852 irc_rootmsg(irc, "%s: no otr context with user", args[1]); … … 895 912 *(myhandle++) = '\0'; 896 913 handle = arg; 897 ctx = otrl_context_find(irc->otr->us, handle, myhandle, protocol, 0, NULL, NULL, NULL);914 ctx = otrl_context_find(irc->otr->us, handle, myhandle, protocol, 0, OTRL_INSTAG_MASTER, NULL, NULL, NULL); // XXX 898 915 if(!ctx) { 899 916 irc_rootmsg(irc, "no such context"); … … 909 926 } 910 927 ctx = otrl_context_find(irc->otr->us, u->bu->handle, u->bu->ic->acc->user, 911 u->bu->ic->acc->prpl->name, 0, NULL, NULL, NULL);928 u->bu->ic->acc->prpl->name, OTRL_INSTAG_MASTER, 0, NULL, NULL, NULL); // XXX 912 929 if(!ctx) { 913 930 irc_rootmsg(irc, "no otr context with %s", args[1]); … … 1028 1045 1029 1046 ctx = otrl_context_find(irc->otr->us, u->bu->handle, u->bu->ic->acc->user, 1030 u->bu->ic->acc->prpl->name, 0, NULL, NULL, NULL);1047 u->bu->ic->acc->prpl->name, OTRL_INSTAG_MASTER, 0, NULL, NULL, NULL); // XXX 1031 1048 if(!ctx) { 1032 1049 irc_rootmsg(irc, "no otr context with %s", args[2]); … … 1071 1088 1072 1089 ctx = otrl_context_find(irc->otr->us, u->bu->handle, u->bu->ic->acc->user, 1073 u->bu->ic->acc->prpl->name, 0, NULL, NULL, NULL);1090 u->bu->ic->acc->prpl->name, OTRL_INSTAG_MASTER, 0, NULL, NULL, NULL); // XXX 1074 1091 if(!ctx) { 1075 1092 irc_rootmsg(irc, "no otr context with %s", args[2]); … … 1134 1151 if(!bu || !(u = bu->ui_data)) return; 1135 1152 context = otrl_context_find(us, handle, 1136 ic->acc->user, ic->acc->prpl->name, 1, NULL, NULL, NULL);1153 ic->acc->user, ic->acc->prpl->name, OTRL_INSTAG_MASTER, 1, NULL, NULL, NULL); 1137 1154 if(!context) { 1138 1155 /* huh? out of memory or what? */ … … 1266 1283 1267 1284 ctx = otrl_context_find(irc->otr->us, u->bu->handle, 1268 u->bu->ic->acc->user, u->bu->ic->acc->prpl->name, 0, NULL, NULL, NULL);1285 u->bu->ic->acc->user, u->bu->ic->acc->prpl->name, OTRL_INSTAG_MASTER, 0, NULL, NULL, NULL); 1269 1286 if(!ctx || ctx->msgstate != OTRL_MSGSTATE_ENCRYPTED) { 1270 1287 irc_rootmsg(irc, "smp: otr inactive with %s, try \x02otr connect"
Note: See TracChangeset
for help on using the changeset viewer.