Prevent dragging groups into groups. Fixes #8706
[adiumx.git] / Source / ESOTRFingerprintDetailsWindowController.m
blob4bba390fced5281b1ff10e1310d67c5132e58610
1 //
2 //  ESOTRFingerprintDetailsWindowController.m
3 //  Adium
4 //
5 //  Created by Evan Schoenberg on 5/11/05.
6 //  Copyright 2006 The Adium Team. All rights reserved.
7 //
9 #import "ESOTRFingerprintDetailsWindowController.h"
10 #import "AdiumOTREncryption.h"
11 #import <Adium/AIAccount.h>
12 #import <Adium/AIServiceIcons.h>
13 #import <AIUtilities/AIImageAdditions.h>
15 /* libotr headers */
16 #import <OTR/proto.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;
23 @end
25 @implementation ESOTRFingerprintDetailsWindowController
27 static ESOTRFingerprintDetailsWindowController  *sharedController = nil;
29 + (void)showDetailsForFingerprintDict:(NSDictionary *)inFingerprintDict
31         if (sharedController) {
32                 [sharedController setFingerprintDict:inFingerprintDict];
34         } else {
35                 sharedController = [[self alloc] initWithWindowNibName:@"OTRFingerprintDetailsWindow" 
36                                                                                         forFingerprintDict:inFingerprintDict];
37         }
38                 
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];
47         }
48         
49         return self;
52 - (void)dealloc
54         [fingerprintDict release];
55         
56         [super dealloc];
59 - (void)configureWindow
61         AIAccount       *account = [fingerprintDict objectForKey:@"AIAccount"];
62         
63         //Ensure the window is loaded
64         [self window];
65         
66         [textField_UID setStringValue:[fingerprintDict objectForKey:@"UID"]];
67         [textField_fingerprint setStringValue:[fingerprintDict objectForKey:@"FingerprintString"]];
68         
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];
79                 
80                 [self configureWindow];
81         }
84 - (void)windowDidLoad
86         [imageView_lock setImage:[NSImage imageNamed:@"Lock_Locked State" forClass:[adium class]]];     
87         
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")];
91         
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.
106  */
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];
122 @end