| File: | Source/ESOTRUnknownFingerprintController.m |
| Location: | line 103, column 2 |
| Description: | dead store |
| 1 | /* |
| 2 | * Adium is the legal property of its developers, whose names are listed in the copyright file included |
| 3 | * with this source distribution. |
| 4 | * |
| 5 | * This program is free software; you can redistribute it and/or modify it under the terms of the GNU |
| 6 | * General Public License as published by the Free Software Foundation; either version 2 of the License, |
| 7 | * or (at your option) any later version. |
| 8 | * |
| 9 | * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even |
| 10 | * the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General |
| 11 | * Public License for more details. |
| 12 | * |
| 13 | * You should have received a copy of the GNU General Public License along with this program; if not, |
| 14 | * write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
| 15 | */ |
| 16 | |
| 17 | #import "ESOTRUnknownFingerprintController.h" |
| 18 | #import "ESTextAndButtonsWindowController.h" |
| 19 | #import <Adium/AIAccount.h> |
| 20 | #import <Adium/AIService.h> |
| 21 | #import "AIHTMLDecoder.h" |
| 22 | #import <Adium/AIServiceIcons.h> |
| 23 | #import <Adium/AIAccountControllerProtocol.h> |
| 24 | |
| 25 | #import "AdiumOTREncryption.h" |
| 26 | |
| 27 | @interface ESOTRUnknownFingerprintController (PRIVATE) |
| 28 | + (void)showFingerprintPromptWithMessageString:(NSString *)messageString |
| 29 | acceptButton:(NSString *)acceptButton |
| 30 | denyButton:(NSString *)denyButton |
| 31 | responseInfo:(NSDictionary *)responseInfo; |
| 32 | + (void)unknownFingerprintResponseInfo:(NSDictionary *)responseInfo wasAccepted:(BOOL)fingerprintAccepted; |
| 33 | @end |
| 34 | |
| 35 | @implementation ESOTRUnknownFingerprintController |
| 36 | |
| 37 | + (void)showUnknownFingerprintPromptWithResponseInfo:(NSDictionary *)responseInfo |
| 38 | { |
| 39 | NSString *messageString; |
| 40 | AIAccount *account = [responseInfo objectForKey:@"AIAccount"]; |
| 41 | NSString *who = [responseInfo objectForKey:@"who"]; |
| 42 | NSString *ourHash = [responseInfo objectForKey:@"Our Fingerprint"]; |
| 43 | NSString *theirHash = [responseInfo objectForKey:@"Their Fingerprint"]; |
| 44 | |
| 45 | messageString = [NSString stringWithFormat: |
| 46 | AILocalizedString[ [ NSBundle bundleForClass : [ self class ] ] localizedStringForKey : ( @ "%@ has sent you (%@) an unknown encryption fingerprint.\n\n" "Fingerprint for you: %@\n\n" "Purported fingerprint for %@: %@\n\n" "Accept this fingerprint as verified?" ) value : @ "" table : ( 0 ) ](@"%@ has sent you (%@) an unknown encryption fingerprint.\n\n" |
| 47 | "Fingerprint for you: %@\n\n" |
| 48 | "Purported fingerprint for %@: %@\n\n" |
| 49 | "Accept this fingerprint as verified?",nil), |
| 50 | who, |
| 51 | [account formattedUID], |
| 52 | ourHash, |
| 53 | who, |
| 54 | theirHash]; |
| 55 | |
| 56 | [self showFingerprintPromptWithMessageString:messageString |
| 57 | acceptButton:AILocalizedString[ [ NSBundle bundleForClass : [ self class ] ] localizedStringForKey : ( @ "Accept" ) value : @ "" table : ( 0 ) ](@"Accept",nil) |
| 58 | denyButton:AILocalizedString[ [ NSBundle bundleForClass : [ self class ] ] localizedStringForKey : ( @ "Verify Later" ) value : @ "" table : ( 0 ) ](@"Verify Later",nil) |
| 59 | responseInfo:responseInfo]; |
| 60 | } |
| 61 | |
| 62 | + (void)showVerifyFingerprintPromptWithResponseInfo:(NSDictionary *)responseInfo |
| 63 | { |
| 64 | NSString *messageString; |
| 65 | AIAccount *account = [responseInfo objectForKey:@"AIAccount"]; |
| 66 | NSString *who = [responseInfo objectForKey:@"who"]; |
| 67 | NSString *ourHash = [responseInfo objectForKey:@"Our Fingerprint"]; |
| 68 | NSString *theirHash = [responseInfo objectForKey:@"Their Fingerprint"]; |
| 69 | |
| 70 | messageString = [NSString stringWithFormat: |
| 71 | AILocalizedString[ [ NSBundle bundleForClass : [ self class ] ] localizedStringForKey : ( @ "Fingerprint for you (%@): %@\n\n" "Purported fingerprint for %@: %@\n\n" "Is this the verifiably correct fingerprint for %@?" ) value : @ "" table : ( 0 ) ](@"Fingerprint for you (%@): %@\n\n" |
| 72 | "Purported fingerprint for %@: %@\n\n" |
| 73 | "Is this the verifiably correct fingerprint for %@?",nil), |
| 74 | [account formattedUID], |
| 75 | ourHash, |
| 76 | who, |
| 77 | theirHash, |
| 78 | who]; |
| 79 | |
| 80 | [self showFingerprintPromptWithMessageString:messageString |
| 81 | acceptButton:AILocalizedString[ [ NSBundle bundleForClass : [ self class ] ] localizedStringForKey : ( @ "Yes" ) value : @ "" table : ( 0 ) ](@"Yes",nil) |
| 82 | denyButton:AILocalizedString[ [ NSBundle bundleForClass : [ self class ] ] localizedStringForKey : ( @ "No" ) value : @ "" table : ( 0 ) ](@"No",nil) |
| 83 | responseInfo:responseInfo]; |
| 84 | } |
| 85 | |
| 86 | + (void)showFingerprintPromptWithMessageString:(NSString *)messageString |
| 87 | acceptButton:(NSString *)acceptButton |
| 88 | denyButton:(NSString *)denyButton |
| 89 | responseInfo:(NSDictionary *)responseInfo |
| 90 | { |
| 91 | ESTextAndButtonsWindowController *windowController; |
| 92 | |
| 93 | AIAccount *account = [responseInfo objectForKey:@"AIAccount"]; |
| 94 | |
| 95 | NSImage *serviceImage = nil0; |
| 96 | |
| 97 | if (account) { |
| 98 | serviceImage = [AIServiceIcons serviceIconForObject:account |
| 99 | type:AIServiceIconLarge |
| 100 | direction:AIIconNormal]; |
| 101 | } |
| 102 | |
Value stored to 'windowController' is never read | |
| 103 | windowController = [ESTextAndButtonsWindowController showTextAndButtonsWindowWithTitle:AILocalizedString[ [ NSBundle bundleForClass : [ self class ] ] localizedStringForKey : ( @ "OTR Fingerprint Verification" ) value : @ "" table : ( 0 ) ](@"OTR Fingerprint Verification",nil) |
| 104 | defaultButton:acceptButton |
| 105 | alternateButton:denyButton |
| 106 | otherButton:AILocalizedString[ [ NSBundle bundleForClass : [ self class ] ] localizedStringForKey : ( @ "Help" ) value : @ "" table : ( 0 ) ](@"Help", nil) |
| 107 | onWindow:nil0 |
| 108 | withMessageHeader:nil0 |
| 109 | andMessage:[AIHTMLDecoder decodeHTML:messageString] |
| 110 | image:serviceImage |
| 111 | target:self |
| 112 | userInfo:responseInfo]; |
| 113 | } |
| 114 | |
| 115 | /*! |
| 116 | * @brief Window was closed, either by a button being clicked or the user closing it |
| 117 | */ |
| 118 | + (BOOL)textAndButtonsWindowDidEnd:(NSWindow *)window returnCode:(AITextAndButtonsReturnCode)returnCode userInfo:(id)userInfo |
| 119 | { |
| 120 | BOOL shouldCloseWindow = YES( BOOL ) 1; |
| 121 | |
| 122 | if (userInfo && [userInfo objectForKey:@"Their Fingerprint"]) { |
| 123 | BOOL fingerprintAccepted; |
| 124 | |
| 125 | if (returnCode == AITextAndButtonsOtherReturn) { |
| 126 | NSString *who = [userInfo objectForKey:@"who"]; |
| 127 | |
| 128 | NSString *message = [NSString stringWithFormat:AILocalizedString[ [ NSBundle bundleForClass : [ self class ] ] localizedStringForKey : ( @ "A fingerprint is a unique identifier " "that you should use to verify the identity of %@.\n\nTo 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." ) value : @ "" table : ( 0 ) ](@"A fingerprint is a unique identifier " |
| 129 | "that you should use to verify the identity of %@.\n\nTo verify the fingerprint, contact %@ via some " |
| 130 | "other authenticated channel such as the telephone or GPG-signed email. " |
| 131 | "Each of you should tell your fingerprint to the other.", nil), |
| 132 | who, |
| 133 | who]; |
| 134 | |
| 135 | [ESTextAndButtonsWindowController showTextAndButtonsWindowWithTitle:nil0 |
| 136 | defaultButton:nil0 |
| 137 | alternateButton:nil0 |
| 138 | otherButton:nil0 |
| 139 | onWindow:window |
| 140 | withMessageHeader:AILocalizedString[ [ NSBundle bundleForClass : [ self class ] ] localizedStringForKey : ( @ "Fingerprint Help" ) value : @ "" table : ( 0 ) ](@"Fingerprint Help", nil) |
| 141 | andMessage:[[[NSAttributedString alloc] initWithString:message] autorelease] |
| 142 | target:self |
| 143 | userInfo:nil0]; |
| 144 | |
| 145 | //Don't close the original window if the help button is pressed |
| 146 | shouldCloseWindow = NO( BOOL ) 0; |
| 147 | |
| 148 | } else { |
| 149 | fingerprintAccepted = ((returnCode == AITextAndButtonsDefaultReturn) ? YES( BOOL ) 1 : NO( BOOL ) 0); |
| 150 | |
| 151 | [self unknownFingerprintResponseInfo:userInfo |
| 152 | wasAccepted:fingerprintAccepted]; |
| 153 | } |
| 154 | } |
| 155 | |
| 156 | return shouldCloseWindow; |
| 157 | } |
| 158 | |
| 159 | + (void)unknownFingerprintResponseInfo:(NSDictionary *)responseInfo wasAccepted:(BOOL)fingerprintAccepted |
| 160 | { |
| 161 | AIAccount *account = [responseInfo objectForKey:@"AIAccount"]; |
| 162 | NSString *who = [responseInfo objectForKey:@"who"]; |
| 163 | |
| 164 | ConnContext *context = otrl_context_find(otrg_get_userstate(), |
| 165 | [who UTF8String], [[account internalObjectID] UTF8String], |
| 166 | [[[account service] serviceCodeUniqueID] UTF8String], |
| 167 | 0, NULL( ( void * ) 0 ), NULL( ( void * ) 0 ), NULL( ( void * ) 0 )); |
| 168 | Fingerprint *fprint; |
| 169 | BOOL oldtrust; |
| 170 | |
| 171 | if (context == NULL( ( void * ) 0 )) { |
| 172 | AILog(@"Warning: ESOTRUnknownFingerprintController: NULL context for %@",responseInfo); |
| 173 | return; |
| 174 | } |
| 175 | |
| 176 | fprint = context->active_fingerprint; |
| 177 | |
| 178 | if (fprint == NULL( ( void * ) 0 )) { |
| 179 | AILog(@"Warning: ESOTRUnknownFingerprintController: NULL fprint for %@",responseInfo); |
| 180 | return; |
| 181 | } |
| 182 | |
| 183 | oldtrust = (fprint->trust && fprint->trust[0]); |
| 184 | |
| 185 | /* See if anything's changed */ |
| 186 | if (fingerprintAccepted != oldtrust) { |
| 187 | otrl_context_set_trust(fprint, fingerprintAccepted ? "verified" : ""); |
| 188 | //Write the new info to disk, redraw the UI |
| 189 | otrg_plugin_write_fingerprints(); |
| 190 | otrg_ui_update_keylist(); |
| 191 | } |
| 192 | } |
| 193 | |
| 194 | @end |