--- a/Source/AdiumOTREncryption.m Mon May 05 18:45:49 2014 +0200
+++ b/Source/AdiumOTREncryption.m Mon May 05 19:32:17 2014 +0200
@@ -753,40 +753,68 @@
otrl_instag_generate(otrg_plugin_userstate, INSTAG_PATH, accountname, protocol);
-/* Something related to Socialis Millionaire Protocol happened. Handle it. */
+/* Something related to Socialist Millionaire Protocol happened. Handle it. */ handle_smp_event_cb(void *opdata, OtrlSMPEvent smp_event, ConnContext *context, unsigned short progress_percent, char *question)
AIListContact *listContact = contactForContext(context);
+ AIChat *chat = chatForContext(context); + if (!chat) chat = [adium.chatController chatWithContact:listContact]; case OTRL_SMPEVENT_ASK_FOR_ANSWER: {
AIOTRSMPSecretAnswerWindowController *questionController = [[AIOTRSMPSecretAnswerWindowController alloc]
initWithQuestion:[NSString stringWithUTF8String:question]
completionHandler:^(NSData *answer,NSString *_question){
- otrl_message_abort_smp(otrg_get_userstate(), &ui_ops, opdata, context);
- otrl_message_respond_smp(otrg_get_userstate(), &ui_ops, opdata, context, [answer bytes], [answer length]);
+ if (context != contextForChat(chat)) { + AILogWithSignature(@"Something's wrong: %p != %p. Did the conversation close before you sent the secret question?", context, contextForChat(chat)); + otrl_message_abort_smp(otrg_get_userstate(), &ui_ops, opdata, context); + otrl_message_respond_smp(otrg_get_userstate(), &ui_ops, opdata, context, [answer bytes], [answer length]); [questionController showWindow:nil];
[questionController.window orderFront:nil];
+ [adium.contentController displayEvent:[NSString stringWithFormat:AILocalizedStringFromTableInBundle(@"%@ has sent you a secret question and is awaiting your answer to verify your identity.", nil, + [NSBundle bundleForClass:[AdiumOTREncryption class]], nil), + listContact.displayName] case OTRL_SMPEVENT_ASK_FOR_SECRET: {
AIOTRSMPSharedSecretWindowController *questionController = [[AIOTRSMPSharedSecretWindowController alloc]
completionHandler:^(NSData *answer){
- otrl_message_respond_smp(otrg_get_userstate(), &ui_ops, opdata, context, [answer bytes], [answer length]);
+ if (context != contextForChat(chat)) { + AILogWithSignature(@"Something's wrong: %p != %p. Did the conversation close before you sent the secret question?", context, contextForChat(chat)); + otrl_message_respond_smp(otrg_get_userstate(), &ui_ops, opdata, context, [answer bytes], [answer length]); [questionController showWindow:nil];
[questionController.window orderFront:nil];
+ [adium.contentController displayEvent:[NSString stringWithFormat:AILocalizedStringFromTableInBundle(@"%@ has requested to compare your shared secret to verify your identity.", nil, + [NSBundle bundleForClass:[AdiumOTREncryption class]], nil), + listContact.displayName] case OTRL_SMPEVENT_CHEATED:
@@ -797,9 +825,6 @@
[NSBundle bundleForClass:[AdiumOTREncryption class]], nil);
- AIChat *chat = chatForContext(context);
- if (!chat) chat = [adium.chatController chatWithContact:listContact];
[adium.contentController displayEvent:localizedMessage
@@ -810,9 +835,6 @@
[NSBundle bundleForClass:[AdiumOTREncryption class]], nil);
- AIChat *chat = chatForContext(context);
- if (!chat) chat = [adium.chatController chatWithContact:listContact];
[adium.contentController displayEvent:localizedMessage
@@ -960,6 +982,11 @@
completionHandler:^(NSData *answer, NSString *question) {
+ if (context != contextForChat(inChat)) { + AILogWithSignature(@"Something's wrong: %p != %p. Did the conversation close before you sent the secret question?", context, contextForChat(inChat)); otrl_message_initiate_smp_q(otrg_get_userstate(),
(const char *)[question UTF8String],
@@ -986,6 +1013,11 @@
initFrom:inChat.listObject
completionHandler:^(NSData *answer) {
+ if (context != contextForChat(inChat)) { + AILogWithSignature(@"Something's wrong: %p != %p. Did the conversation close before you sent the secret question?", context, contextForChat(inChat)); otrl_message_initiate_smp(otrg_get_userstate(),