William Bowling is sharing code with you
Bitbucket is a code hosting site. Unlimited public and private repositories. Free for small teams.
Don't show this again1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 | //
// ESOTRPrivateKeyGenerationWindowController.m
// Adium
//
// Created by Evan Schoenberg on 3/4/05.
// Copyright 2006 The Adium Team. All rights reserved.
//
#import "ESOTRPrivateKeyGenerationWindowController.h"
#import <AIUtilities/AIStringAdditions.h>
@interface ESOTRPrivateKeyGenerationWindowController ()
- (id)initWithWindowNibName:(NSString *)windowNibName forIdentifier:(NSString *)inIdentifier;
@end
@implementation ESOTRPrivateKeyGenerationWindowController
static NSMutableDictionary *keyGenerationControllerDict = nil;
+ (void)mainThreadStartedGeneratingForIdentifier:(NSString *)inIdentifier
{
if (!keyGenerationControllerDict) keyGenerationControllerDict = [[NSMutableDictionary alloc] init];
if (![keyGenerationControllerDict objectForKey:inIdentifier]) {
ESOTRPrivateKeyGenerationWindowController *controller;
if ((controller = [[self alloc] initWithWindowNibName:@"OTRPrivateKeyGenerationWindow"
forIdentifier:inIdentifier])) {
[controller showWindow:nil];
[[controller window] makeKeyAndOrderFront:nil];
[keyGenerationControllerDict setObject:controller
forKey:inIdentifier];
}
}
}
/*!
* @brief We started generating a private key.
*
* Create a window controller for inIdentifier and tell it to display.
* Has no effect if a window is already open for inIdentifier.
*/
+ (void)startedGeneratingForIdentifier:(NSString *)inIdentifier
{
[self performSelectorOnMainThread:@selector(mainThreadStartedGeneratingForIdentifier:)
withObject:inIdentifier
waitUntilDone:NO];
}
/*!
* @brief Initialize
*/
- (id)initWithWindowNibName:(NSString *)windowNibName forIdentifier:(NSString *)inIdentifier
{
if ((self = [super initWithWindowNibName:windowNibName])) {
identifier = [inIdentifier retain];
}
return self;
}
/*!
* @brief Window loaded
*
* Start our spinning progress indicator and set up our window
*/
- (void)windowDidLoad
{
[super windowDidLoad];
[[self window] setTitle:[AILocalizedString(@"Please wait",nil) stringByAppendingEllipsis]];
[[self window] center];
[progressIndicator startAnimation:nil];
[textField_message setStringValue:
[NSString stringWithFormat:AILocalizedString(@"Generating private encryption key for %@",nil),identifier]];
}
/*!
* @brief Deallocate
*/
- (void)dealloc
{
[identifier release];
[super dealloc];
}
+ (void)mainThreadFinishedGeneratingForIdentifier:(NSString *)inIdentifier
{
ESOTRPrivateKeyGenerationWindowController *controller;
controller = [keyGenerationControllerDict objectForKey:inIdentifier];
[controller closeWindow:nil];
[keyGenerationControllerDict removeObjectForKey:inIdentifier];
}
/*!
* @brief Finished generating a private key
*
* Closes the window assosiated with inIdentifier, if it is open.
*/
+ (void)finishedGeneratingForIdentifier:(NSString *)inIdentifier
{
[self performSelectorOnMainThread:@selector(mainThreadFinishedGeneratingForIdentifier:)
withObject:inIdentifier
waitUntilDone:NO];
}
@end
|