* Adium is the legal property of its developers, whose names are listed in the copyright file included * with this source distribution. * This program is free software; you can redistribute it and/or modify it under the terms of the GNU * General Public License as published by the Free Software Foundation; either version 2 of the License, * or (at your option) any later version. * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even * the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General * Public License for more details. * You should have received a copy of the GNU General Public License along with this program; if not, * write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #import "ESOTRUnknownFingerprintController.h" #import "ESTextAndButtonsWindowController.h" #import <Adium/AIAccount.h> #import <Adium/AIService.h> #import "AIHTMLDecoder.h" #import <Adium/AIServiceIcons.h> #import <Adium/AIAccountControllerProtocol.h> #import "AdiumOTREncryption.h" @interface ESOTRUnknownFingerprintController () + (void)unknownFingerprintResponseInfo:(NSDictionary *)responseInfo wasAccepted:(BOOL)fingerprintAccepted; @implementation ESOTRUnknownFingerprintController + (void)showVerifyFingerprintPromptWithResponseInfo:(NSDictionary *)responseInfo NSString *who = [responseInfo objectForKey:@"who"]; NSString *theirHash = [responseInfo objectForKey:@"Their Fingerprint"]; messageString = [NSString stringWithFormat: AILocalizedString(@"Fingerprint for %@: %@\n\nHave you verified this is %@\xe2\x80\x99s fingerprint?",nil), [self showFingerprintPromptWithMessageString:messageString acceptButton:AILocalizedString(@"Yes",nil) denyButton:AILocalizedString(@"No",nil) responseInfo:responseInfo]; + (void)showFingerprintPromptWithMessageString:(NSString *)messageString acceptButton:(NSString *)acceptButton denyButton:(NSString *)denyButton responseInfo:(NSDictionary *)responseInfo AIAccount *account = [responseInfo objectForKey:@"AIAccount"]; NSImage *serviceImage = nil; serviceImage = [AIServiceIcons serviceIconForObject:account ESTextAndButtonsWindowController *textAndButtonsWindowController = [[ESTextAndButtonsWindowController alloc] initWithTitle:AILocalizedString(@"OTR Fingerprint Verification",nil) alternateButton:acceptButton otherButton:AILocalizedString(@"Help", nil) andMessage:[AIHTMLDecoder decodeHTML:messageString] [textAndButtonsWindowController showOnWindow:nil]; * @brief Window was closed, either by a button being clicked or the user closing it + (BOOL)textAndButtonsWindowDidEnd:(NSWindow *)window returnCode:(AITextAndButtonsReturnCode)returnCode suppression:(BOOL)suppression userInfo:(id)userInfo BOOL shouldCloseWindow = YES; if (userInfo && [userInfo objectForKey:@"Their Fingerprint"]) { BOOL fingerprintAccepted; if (returnCode == AITextAndButtonsOtherReturn) { NSString *who = [userInfo objectForKey:@"who"]; NSString *message = [NSString stringWithFormat:AILocalizedString(@"A fingerprint is a unique cryptographic identifier " @"that you can use to verify the identity of %@. " @"If the fingerprint you see matches their actualy fingerprint, you know nobody else can listen in on your chat.\n\n" @"To verify the fingerprint, contact %@ via some " @"other authenticated channel such as the telephone or GPG-signed email. " @"Each of you should tell your fingerprint to the other.", nil), ESTextAndButtonsWindowController *textAndButtonsWindowController = [[ESTextAndButtonsWindowController alloc] initWithTitle:nil withMessageHeader:AILocalizedString(@"What is a fingerprint?", nil) andMessage:[[[NSAttributedString alloc] initWithString:message] autorelease] [textAndButtonsWindowController showOnWindow:window]; //Don't close the original window if the help button is pressed fingerprintAccepted = ((returnCode == AITextAndButtonsDefaultReturn) ? NO : YES); [self unknownFingerprintResponseInfo:userInfo wasAccepted:fingerprintAccepted]; return shouldCloseWindow; + (void)unknownFingerprintResponseInfo:(NSDictionary *)responseInfo wasAccepted:(BOOL)fingerprintAccepted AIAccount *account = [responseInfo objectForKey:@"AIAccount"]; NSString *who = [responseInfo objectForKey:@"who"]; ConnContext *context = otrl_context_find(otrg_get_userstate(), [who UTF8String], [account.internalObjectID UTF8String], [account.service.serviceCodeUniqueID UTF8String], OTRL_INSTAG_RECENT, AILog(@"Warning: ESOTRUnknownFingerprintController: NULL context for %@",responseInfo); fprint = context->active_fingerprint; AILog(@"Warning: ESOTRUnknownFingerprintController: NULL fprint for %@",responseInfo); oldtrust = (fprint->trust && fprint->trust[0]); /* See if anything's changed */ if (fingerprintAccepted != oldtrust) { otrl_context_set_trust(fprint, fingerprintAccepted ? "verified" : ""); //Write the new info to disk, redraw the UI otrg_plugin_write_fingerprints(); otrg_ui_update_keylist(); update_security_details_for_context(context);