Added a debug log to investigate #8685, as it worksforme. Refs #8685
[adiumx.git] / Source / ESOTRPrivateKeyGenerationWindowController.m
blob4cd682fe5713e66b5cd4875906c5868bb4061d1f
1 //
2 //  ESOTRPrivateKeyGenerationWindowController.m
3 //  Adium
4 //
5 //  Created by Evan Schoenberg on 3/4/05.
6 //  Copyright 2006 The Adium Team. All rights reserved.
7 //
9 #import "ESOTRPrivateKeyGenerationWindowController.h"
10 #import <AIUtilities/AIStringAdditions.h>
12 @interface ESOTRPrivateKeyGenerationWindowController (PRIVATE)
13 - (id)initWithWindowNibName:(NSString *)windowNibName forIdentifier:(NSString *)inIdentifier;
14 @end
16 @implementation ESOTRPrivateKeyGenerationWindowController
18 static NSMutableDictionary      *keyGenerationControllerDict = nil;
20 + (void)mainThreadStartedGeneratingForIdentifier:(NSString *)inIdentifier
22         if (!keyGenerationControllerDict) keyGenerationControllerDict = [[NSMutableDictionary alloc] init];
23         
24         if (![keyGenerationControllerDict objectForKey:inIdentifier]) {
25                 ESOTRPrivateKeyGenerationWindowController       *controller;
26                 
27                 if ((controller = [[self alloc] initWithWindowNibName:@"OTRPrivateKeyGenerationWindow" 
28                                                                                                 forIdentifier:inIdentifier])) {
29                         [controller showWindow:nil];
30                         [[controller window] makeKeyAndOrderFront:nil];
31                         
32                         [keyGenerationControllerDict setObject:controller
33                                                                                         forKey:inIdentifier];
34                 }
35         }
38 /*!
39 * @brief We started generating a private key.
40  *
41  * Create a window controller for inIdentifier and tell it to display.
42  * Has no effect if a window is already open for inIdentifier.
43  */
44 + (void)startedGeneratingForIdentifier:(NSString *)inIdentifier
46         [self performSelectorOnMainThread:@selector(mainThreadStartedGeneratingForIdentifier:)
47                                                    withObject:inIdentifier
48                                                 waitUntilDone:NO];
51 /*!
52  * @brief Initialize
53  */
54 - (id)initWithWindowNibName:(NSString *)windowNibName forIdentifier:(NSString *)inIdentifier
56         if ((self = [super initWithWindowNibName:windowNibName])) {
57                 identifier = [inIdentifier retain];
58         }
60         return self;
63 /*!
64  * @brief Window loaded
65  *
66  * Start our spinning progress indicator and set up our window
67  */
68 - (void)windowDidLoad
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]];
80 /*!
81  * @brief Deallocate
82  */
83 - (void)dealloc
85         [identifier release];
86         [super dealloc];
89 + (void)mainThreadFinishedGeneratingForIdentifier:(NSString *)inIdentifier
90 {       
91         ESOTRPrivateKeyGenerationWindowController       *controller;
93         controller = [keyGenerationControllerDict objectForKey:inIdentifier];
94         [controller closeWindow:nil];
95         
96         [keyGenerationControllerDict removeObjectForKey:inIdentifier];
99 /*!
100  * @brief Finished generating a private key
102  * Closes the window assosiated with inIdentifier, if it is open.
103  */
104 + (void)finishedGeneratingForIdentifier:(NSString *)inIdentifier
106         [self performSelectorOnMainThread:@selector(mainThreadFinishedGeneratingForIdentifier:)
107                                                    withObject:inIdentifier
108                                                 waitUntilDone:NO];
111 @end