2 // ESOTRPrivateKeyGenerationWindowController.m
5 // Created by Evan Schoenberg on 3/4/05.
6 // Copyright 2006 The Adium Team. All rights reserved.
9 #import "ESOTRPrivateKeyGenerationWindowController.h"
10 #import <AIUtilities/AIStringAdditions.h>
12 @interface ESOTRPrivateKeyGenerationWindowController (PRIVATE)
13 - (id)initWithWindowNibName:(NSString *)windowNibName forIdentifier:(NSString *)inIdentifier;
16 @implementation ESOTRPrivateKeyGenerationWindowController
18 static NSMutableDictionary *keyGenerationControllerDict = nil;
20 + (void)mainThreadStartedGeneratingForIdentifier:(NSString *)inIdentifier
22 if (!keyGenerationControllerDict) keyGenerationControllerDict = [[NSMutableDictionary alloc] init];
24 if (![keyGenerationControllerDict objectForKey:inIdentifier]) {
25 ESOTRPrivateKeyGenerationWindowController *controller;
27 if ((controller = [[self alloc] initWithWindowNibName:@"OTRPrivateKeyGenerationWindow"
28 forIdentifier:inIdentifier])) {
29 [controller showWindow:nil];
30 [[controller window] makeKeyAndOrderFront:nil];
32 [keyGenerationControllerDict setObject:controller
39 * @brief We started generating a private key.
41 * Create a window controller for inIdentifier and tell it to display.
42 * Has no effect if a window is already open for inIdentifier.
44 + (void)startedGeneratingForIdentifier:(NSString *)inIdentifier
46 [self performSelectorOnMainThread:@selector(mainThreadStartedGeneratingForIdentifier:)
47 withObject:inIdentifier
54 - (id)initWithWindowNibName:(NSString *)windowNibName forIdentifier:(NSString *)inIdentifier
56 if ((self = [super initWithWindowNibName:windowNibName])) {
57 identifier = [inIdentifier retain];
64 * @brief Window loaded
66 * Start our spinning progress indicator and set up our window
70 [super windowDidLoad];
72 [[self window] setTitle:[AILocalizedString(@"Please wait",nil) stringByAppendingEllipsis]];
73 [[self window] center];
75 [progressIndicator startAnimation:nil];
76 [textField_message setStringValue:
77 [NSString stringWithFormat:AILocalizedString(@"Generating private encryption key for %@",nil),identifier]];
89 + (void)mainThreadFinishedGeneratingForIdentifier:(NSString *)inIdentifier
91 ESOTRPrivateKeyGenerationWindowController *controller;
93 controller = [keyGenerationControllerDict objectForKey:inIdentifier];
94 [controller closeWindow:nil];
96 [keyGenerationControllerDict removeObjectForKey:inIdentifier];
100 * @brief Finished generating a private key
102 * Closes the window assosiated with inIdentifier, if it is open.
104 + (void)finishedGeneratingForIdentifier:(NSString *)inIdentifier
106 [self performSelectorOnMainThread:@selector(mainThreadFinishedGeneratingForIdentifier:)
107 withObject:inIdentifier