2 // ESOTRFingerprintDetailsWindowController.m
5 // Created by Evan Schoenberg on 5/11/05.
6 // Copyright 2006 The Adium Team. All rights reserved.
9 #import "ESOTRFingerprintDetailsWindowController.h"
10 #import "AdiumOTREncryption.h"
11 #import <Adium/AIAccount.h>
12 #import <Adium/AIServiceIcons.h>
13 #import <AIUtilities/AIImageAdditions.h>
17 #import <OTR/context.h>
18 #import <OTR/message.h>
20 @interface ESOTRFingerprintDetailsWindowController (PRIVATE)
21 - (id)initWithWindowNibName:(NSString *)windowNibName forFingerprintDict:(NSDictionary *)inFingerprintDict;
22 - (void)setFingerprintDict:(NSDictionary *)inFingerprintDict;
25 @implementation ESOTRFingerprintDetailsWindowController
27 static ESOTRFingerprintDetailsWindowController *sharedController = nil;
29 + (void)showDetailsForFingerprintDict:(NSDictionary *)inFingerprintDict
31 if (sharedController) {
32 [sharedController setFingerprintDict:inFingerprintDict];
35 sharedController = [[self alloc] initWithWindowNibName:@"OTRFingerprintDetailsWindow"
36 forFingerprintDict:inFingerprintDict];
39 [sharedController showWindow:nil];
40 [[sharedController window] makeKeyAndOrderFront:nil];
43 - (id)initWithWindowNibName:(NSString *)windowNibName forFingerprintDict:(NSDictionary *)inFingerprintDict
45 if ((self = [super initWithWindowNibName:windowNibName])) {
46 [self setFingerprintDict:inFingerprintDict];
54 [fingerprintDict release];
59 - (void)configureWindow
61 AIAccount *account = [fingerprintDict objectForKey:@"AIAccount"];
63 //Ensure the window is loaded
66 [textField_UID setStringValue:[fingerprintDict objectForKey:@"UID"]];
67 [textField_fingerprint setStringValue:[fingerprintDict objectForKey:@"FingerprintString"]];
69 [imageView_service setImage:[AIServiceIcons serviceIconForObject:account
70 type:AIServiceIconLarge
71 direction:AIIconNormal]];
74 - (void)setFingerprintDict:(NSDictionary *)inFingerprintDict
76 if (inFingerprintDict != fingerprintDict) {
77 [fingerprintDict release];
78 fingerprintDict = [inFingerprintDict retain];
80 [self configureWindow];
86 [imageView_lock setImage:[NSImage imageNamed:@"Lock_Locked State" forClass:[adium class]]];
88 [[self window] setTitle:AILocalizedString(@"OTR Fingerprint",nil)];
89 [button_OK setLocalizedString:AILocalizedString(@"OK",nil)];
90 [button_forgetFingerprint setLocalizedString:AILocalizedString(@"Forget Fingerprint","Button title to make Adium no longer know a user's encryption fingerprint")];
92 [super windowDidLoad];
95 - (void)windowWillClose:(id)sender
97 [super windowWillClose:sender];
99 [sharedController autorelease]; sharedController = nil;
103 * @brief Auto-saving window frame key
105 * This is the string used for saving this window's frame. It should be unique to this window.
107 - (NSString *)adiumFrameAutosaveName
109 return @"OTR Fingerprint Details Window";
112 - (IBAction)forgetFingerprint:(id)sender
114 Fingerprint *fingerprint = [[fingerprintDict objectForKey:@"FingerprintValue"] pointerValue];
116 otrg_ui_forget_fingerprint(fingerprint);
118 [self closeWindow:nil];