forked from sparkle-project/Sparkle
-
Notifications
You must be signed in to change notification settings - Fork 2
/
SUPasswordPrompt.m
86 lines (71 loc) · 1.27 KB
/
SUPasswordPrompt.m
1
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
//
// SUPasswordPrompt.m
// Sparkle
//
// Created by rudy on 8/18/09.
// Copyright 2009 Ambrosia Software, Inc.. All rights reserved.
//
#import "SUPasswordPrompt.h"
@implementation SUPasswordPrompt
- (id)initWithHost:(SUHost *)aHost
{
self = [super initWithHost:aHost windowNibName:@"SUPasswordPrompt"];
if (self)
{
[self setName:[aHost name]];
[self setIcon:[aHost icon]];
mPassword = nil;
[self setShouldCascadeWindows:NO];
}
return self;
}
- (void)awakeFromNib
{
[mIconView setImage:[self icon]];
}
- (void)setName:(NSString*)name
{
[mName release];
mName = [name retain];
}
- (NSString*)name
{
return mName;
}
- (void)setIcon:(NSImage*)icon
{
[mIcon release];
mIcon = [icon retain];
}
- (NSImage*)icon
{
return mIcon;
}
- (NSString *)password
{
return mPassword;
}
- (void)setPassword:(NSString*)password
{
[mPassword release];
mPassword = [password retain];
}
- (NSInteger)run
{
//modally run a password prompt
NSInteger result = [NSApp runModalForWindow:[self window]];
if(result)
[self setPassword:[mPasswordField stringValue]];
return result;
}
- (IBAction)accept:(id)sender
{
[[self window] orderOut:self];
[NSApp stopModalWithCode:1];
}
- (IBAction)cancel:(id)sender
{
[[self window] orderOut:self];
[NSApp stopModalWithCode:0];
}
@end