-
-
Notifications
You must be signed in to change notification settings - Fork 3
/
AniListAuthWindow.m
67 lines (54 loc) · 1.71 KB
/
AniListAuthWindow.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
//
// AniListAuthWindow.m
// Shukofukurou
//
// Created by 小鳥遊六花 on 4/3/18.
// Copyright © 2017-2018 MAL Updater OS X Group and Moy IT Solutions. All rights reserved. Licensed under 3-clause BSD License
//
#import "AniListAuthWindow.h"
#import "AuthWebView.h"
@interface AniListAuthWindow ()
@property (strong) AuthWebView *awebview;
@property (strong) IBOutlet NSView *containerview;
@end
@implementation AniListAuthWindow
- (instancetype)init {
self = [super initWithWindowNibName:@"AniListAuthWindow"];
if (!self) {
return nil;
}
return self;
}
- (NSString *)getVerifierString {
return _awebview.verifier;
}
- (void)windowDidLoad {
[super windowDidLoad];
// Implement this method to handle any initialization after your window controller's window has been loaded from its nib file.
if (!_awebview) {
_awebview = [AuthWebView new];
}
__weak AniListAuthWindow *weakself = self;
_awebview.completion = ^(NSString *pin) {
weakself.pin = pin;
[weakself.window.sheetParent endSheet:weakself.window returnCode:NSModalResponseOK];
};
_awebview.view.frame = _containerview.frame;
[_awebview.view setFrameOrigin:NSMakePoint(0, 0)];
[_containerview addSubview:_awebview.view];
}
- (IBAction)cancel:(id)sender {
[_awebview resetWebView];
[self.window.sheetParent endSheet:self.window returnCode:NSModalResponseCancel];
}
- (void)loadAuthorizationForService:(int)service {
[_awebview loadAuthorization:service];
}
- (IBAction)authorizeinbrowser:(id)sender {
[NSWorkspace.sharedWorkspace openURL:[_awebview authURL]];
}
- (IBAction)startover:(id)sender {
[_awebview resetWebView];
[_awebview reloadAuth];
}
@end