Skip to content
This repository was archived by the owner on Apr 12, 2020. It is now read-only.

Commit 538fa60

Browse files
committed
Token caching, Apple ID UI, moved around some menus
1 parent 5a2e017 commit 538fa60

11 files changed

Lines changed: 269 additions & 78 deletions

AltDeploy.xcodeproj/project.pbxproj

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88

99
/* Begin PBXBuildFile section */
1010
CE5F0E3B23C3894300445F16 /* AltPlugin.mailbundle in Resources */ = {isa = PBXBuildFile; fileRef = CE5F0E3A23C3894300445F16 /* AltPlugin.mailbundle */; };
11+
CE64527723C8D1A200BA4593 /* ALTPreferencesViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = CE64527623C8D1A200BA4593 /* ALTPreferencesViewController.m */; };
1112
CE72335323C8BD0F0019006B /* AppIcon.icns in Resources */ = {isa = PBXBuildFile; fileRef = CE72335223C8BD0F0019006B /* AppIcon.icns */; };
1213
CE77230B23C76FDC0000C344 /* libcrypto.a in Frameworks */ = {isa = PBXBuildFile; fileRef = CE77230A23C76FDC0000C344 /* libcrypto.a */; };
1314
CE77230D23C76FDE0000C344 /* libimobiledevice.a in Frameworks */ = {isa = PBXBuildFile; fileRef = CE77230C23C76FDE0000C344 /* libimobiledevice.a */; };
@@ -72,6 +73,8 @@
7273

7374
/* Begin PBXFileReference section */
7475
CE5F0E3A23C3894300445F16 /* AltPlugin.mailbundle */ = {isa = PBXFileReference; lastKnownFileType = folder; path = AltPlugin.mailbundle; sourceTree = "<group>"; };
76+
CE64527523C8D1A200BA4593 /* ALTPreferencesViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ALTPreferencesViewController.h; sourceTree = "<group>"; };
77+
CE64527623C8D1A200BA4593 /* ALTPreferencesViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = ALTPreferencesViewController.m; sourceTree = "<group>"; };
7578
CE72335223C8BD0F0019006B /* AppIcon.icns */ = {isa = PBXFileReference; lastKnownFileType = image.icns; path = AppIcon.icns; sourceTree = "<group>"; };
7679
CE77230A23C76FDC0000C344 /* libcrypto.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = libcrypto.a; path = Dependencies/libcrypto.a; sourceTree = "<group>"; };
7780
CE77230C23C76FDE0000C344 /* libimobiledevice.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = libimobiledevice.a; path = Dependencies/libimobiledevice.a; sourceTree = "<group>"; };
@@ -489,6 +492,8 @@
489492
CEA6377B23C3941200CEC7A9 /* AltDeploy.entitlements */,
490493
CEA6377D23C3941200CEC7A9 /* Info.plist */,
491494
CEA6377F23C3941200CEC7A9 /* apple.pem */,
495+
CE64527523C8D1A200BA4593 /* ALTPreferencesViewController.h */,
496+
CE64527623C8D1A200BA4593 /* ALTPreferencesViewController.m */,
492497
);
493498
path = AltDeploy;
494499
sourceTree = "<group>";
@@ -610,6 +615,7 @@
610615
CEA24B7723C1278B00A6DB11 /* NSError+ALTServerError.m in Sources */,
611616
CEA24BF723C132E000A6DB11 /* Result+Conveniences.swift in Sources */,
612617
CEA24BEC23C130CD00A6DB11 /* ALTDeviceManager+Installation.swift in Sources */,
618+
CE64527723C8D1A200BA4593 /* ALTPreferencesViewController.m in Sources */,
613619
CEA24B6123C1234100A6DB11 /* ALTSigner.mm in Sources */,
614620
CEBF418023C259CA004338D2 /* SAMKeychain.m in Sources */,
615621
CEBF417D23C2599C004338D2 /* SAMKeychainQuery.m in Sources */,
@@ -767,6 +773,7 @@
767773
"$(PROJECT_DIR)/Dependencies",
768774
);
769775
MACOSX_DEPLOYMENT_TARGET = 10.13;
776+
MARKETING_VERSION = 1.1;
770777
OTHER_CFLAGS = "-Dunix=1";
771778
PRODUCT_BUNDLE_IDENTIFIER = com.pixelomer.altdeploy;
772779
PRODUCT_NAME = "$(TARGET_NAME)";
@@ -800,6 +807,7 @@
800807
"$(PROJECT_DIR)/Dependencies",
801808
);
802809
MACOSX_DEPLOYMENT_TARGET = 10.13;
810+
MARKETING_VERSION = 1.1;
803811
OTHER_CFLAGS = "-Dunix=1";
804812
PRODUCT_BUNDLE_IDENTIFIER = com.pixelomer.altdeploy;
805813
PRODUCT_NAME = "$(TARGET_NAME)";

AltDeploy.xcodeproj/xcshareddata/xcschemes/AltDeploy.xcscheme

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,9 @@
3131
</Testables>
3232
</TestAction>
3333
<LaunchAction
34-
buildConfiguration = "Release"
35-
selectedDebuggerIdentifier = ""
36-
selectedLauncherIdentifier = "Xcode.IDEFoundation.Launcher.PosixSpawn"
34+
buildConfiguration = "Debug"
35+
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
36+
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
3737
launchStyle = "0"
3838
useCustomWorkingDirectory = "NO"
3939
ignoresPersistentStateOnLaunch = "NO"

AltDeploy/ALTAddAppleIDViewController.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,10 @@ NS_ASSUME_NONNULL_BEGIN
1414
- (void)didAddAppleID;
1515
@end
1616

17-
@interface ALTAddAppleIDViewController : NSViewController
17+
@interface ALTAddAppleIDViewController : NSViewController<NSTextFieldDelegate>
18+
@property (weak) IBOutlet NSTextField *usernameField;
19+
@property (weak) IBOutlet NSSecureTextField *passwordField;
20+
@property (weak) IBOutlet NSButton *saveButton;
1821
@property (nonatomic, weak) id <ALTAddAppleIDDelegate> delegate;
1922
@end
2023

AltDeploy/ALTAddAppleIDViewController.m

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -9,21 +9,16 @@
99
#import "ALTAddAppleIDViewController.h"
1010
#import "ALTAppleIDManager.h"
1111

12-
@interface ALTAddAppleIDViewController ()
13-
@property (weak) IBOutlet NSTextField *usernameField;
14-
@property (weak) IBOutlet NSSecureTextField *passwordField;
15-
@property (weak) IBOutlet NSButton *saveButton;
16-
@end
17-
1812
@implementation ALTAddAppleIDViewController
1913

2014
- (void)viewDidLoad {
2115
[super viewDidLoad];
22-
23-
NSString *username = nil;
24-
if ([[ALTAppleIDManager sharedManager] getLastAppleID:&username]) {
25-
[self.usernameField setStringValue:username];
26-
}
16+
[self controlTextDidChange:(_Nonnull id)nil];
17+
self.usernameField.delegate = self.passwordField.delegate = self;
18+
}
19+
20+
- (void)controlTextDidChange:(NSNotification *)notif {
21+
self.saveButton.enabled = (self.usernameField.stringValue.length && self.passwordField.stringValue.length);
2722
}
2823

2924
- (IBAction)didClickButton:(NSButton *)sender {

AltDeploy/ALTMainViewController.h

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,20 @@
1010

1111
NS_ASSUME_NONNULL_BEGIN
1212

13-
@interface ALTMainViewController : NSViewController
13+
@protocol ALTAddAppleIDDelegate;
14+
@protocol ALTDragDropViewDelegate;
1415

16+
@interface ALTMainViewController : NSViewController<ALTAddAppleIDDelegate, ALTDragDropViewDelegate>
17+
@property (weak) IBOutlet NSTextField *descriptionLabel;
18+
@property (weak) IBOutlet NSProgressIndicator *progressIndicator;
19+
@property (weak) IBOutlet NSView *progressContainerView;
20+
@property (weak) IBOutlet NSPopUpButton *accountButton;
21+
@property (weak) IBOutlet NSPopUpButton *deviceButton;
22+
@property (weak) IBOutlet NSPopUpButton *actionButton;
23+
@property (weak) IBOutlet NSButton *startButton;
1524
+ (BOOL)isPluginInstalled;
1625
+ (NSString *)mailBundlesPath;
1726
+ (NSString *)altPluginPath;
18-
1927
@end
2028

2129
NS_ASSUME_NONNULL_END

AltDeploy/ALTMainViewController.m

Lines changed: 33 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -18,18 +18,6 @@
1818
@class ALTDeviceManager;
1919
@protocol Installation;
2020

21-
@interface ALTMainViewController () <ALTAddAppleIDDelegate, ALTDragDropViewDelegate>
22-
23-
@property (weak) IBOutlet NSTextField *descriptionLabel;
24-
@property (weak) IBOutlet NSProgressIndicator *progressIndicator;
25-
@property (weak) IBOutlet NSView *progressContainerView;
26-
@property (weak) IBOutlet NSPopUpButton *accountButton;
27-
@property (weak) IBOutlet NSPopUpButton *deviceButton;
28-
@property (weak) IBOutlet NSPopUpButton *actionButton;
29-
@property (weak) IBOutlet NSButton *startButton;
30-
31-
@end
32-
3321
@implementation ALTMainViewController {
3422
NSArray <NSDictionary *> *accounts;
3523
NSArray <NSString *> *devices;
@@ -68,24 +56,25 @@ - (void)viewDidLoad {
6856
@"RegisterDeviceAutomatically": @(YES)
6957
}];
7058

71-
NSMenuItem *item0 = NSApp.mainMenu.itemArray[0].submenu.itemArray[2];
72-
item0.action = @selector(didClickAddAppleID:);
73-
item0.target = self;
59+
NSMenuItem *item = NSApp.mainMenu.itemArray[0].submenu.itemArray[3];
60+
item.action = @selector(didClickAddAppleID:);
61+
item.target = self;
7462

75-
NSMenuItem *item1 = NSApp.mainMenu.itemArray[0].submenu.itemArray[3];
76-
item1.action = @selector(didClickKeychainAccess:);
77-
item1.target = self;
63+
item = NSApp.mainMenu.itemArray[0].submenu.itemArray[4];
64+
item.action = @selector(didClickKeychainAccess:);
65+
item.target = self;
7866

79-
registerDeviceMenuItem = NSApp.mainMenu.itemArray[0].submenu.itemArray[4];
67+
registerDeviceMenuItem = NSApp.mainMenu.itemArray[0].submenu.itemArray[5];
8068
registerDeviceMenuItem.action = @selector(didClickRegisterDeviceAutomatically:);
8169
registerDeviceMenuItem.target = self;
8270
registerDeviceMenuItem.state = [[NSUserDefaults standardUserDefaults] boolForKey:@"RegisterDeviceAutomatically"] ? NSControlStateValueOn : NSControlStateValueOff;
8371

84-
NSMenuItem *itemHelp = NSApp.mainMenu.itemArray[4].submenu.itemArray[0];
85-
itemHelp.action = @selector(showHelp:);
86-
itemHelp.target = self;
72+
item = NSApp.mainMenu.itemArray[4].submenu.itemArray[0];
73+
item.action = @selector(showHelp:);
74+
item.target = self;
75+
NSApp.helpMenu = [NSMenu new];
8776

88-
mailPluginMenuItem = NSApp.mainMenu.itemArray[0].submenu.itemArray[6];
77+
mailPluginMenuItem = NSApp.mainMenu.itemArray[0].submenu.itemArray[7];
8978
mailPluginMenuItem.action = @selector(didClickInstallPlugin:);
9079
mailPluginMenuItem.target = self;
9180

@@ -123,8 +112,8 @@ - (void)setRepresentedObject:(id)representedObject {
123112

124113
- (void)dragDropView:(ALTDragDropView *)view droppedWithFilenames:(NSArray <NSString *> *)filenames {
125114
if (filenames.count == 1) {
126-
self.actionButton.enabled = YES;
127115
self->selectedFileURL = [NSURL fileURLWithPath:filenames.firstObject];
116+
[_actionButton.menu performActionForItemAtIndex:0];
128117
[self didChooseAction:self.actionButton];
129118
}
130119
}
@@ -179,7 +168,6 @@ - (void)beginMailPluginInstallation {
179168
@"do shell script \"/bin/bash -c \\\"\\\\\\\"\\\\$(base64 -D <<< \\\\\\\"%@\\\\\\\")\\\\\\\" -i\\\"\" with administrator privileges",
180169
[[NSBundle.mainBundle.executablePath dataUsingEncoding:NSUTF8StringEncoding] base64EncodedStringWithOptions:0]
181170
];
182-
NSLog(@"%@", script);
183171
NSAppleScript *appleScript = [[NSAppleScript alloc] initWithSource:script];
184172
NSAlert *alert = [NSAlert new];
185173
[alert addButtonWithTitle:@"OK"];
@@ -460,25 +448,26 @@ - (void)didClickStart:(id)sender {
460448
ALTDevice *device = [[ALTDevice alloc] initWithName:@"targetDevice" identifier:devices[_deviceButton.indexOfSelectedItem]];
461449
NSProgress *progress = nil;
462450
progress = [ALTDeviceManager.sharedManager installApplicationTo:device
463-
appleID:username
464-
password:password
465-
applicationURL:fileURL
466-
completion:^(NSError * _Nullable error) {
467-
[progress removeObserver:self forKeyPath:@"localizedDescription"];
468-
if (error) {
469-
dispatch_async(dispatch_get_main_queue(), ^{
470-
NSAlert *alert = [NSAlert alertWithError:error];
471-
[alert addButtonWithTitle:@"Dismiss"];
472-
[alert runModal];
473-
[self setProgressVisible:NO];
474-
});
475-
}
476-
else {
477-
dispatch_async(dispatch_get_main_queue(), ^{
478-
[self setProgressVisible:NO];
479-
});
480-
}
481-
}];
451+
appleID:username
452+
password:password
453+
applicationURL:fileURL
454+
completion:^(NSError * _Nullable error) {
455+
[progress removeObserver:self forKeyPath:@"localizedDescription"];
456+
if (error) {
457+
dispatch_async(dispatch_get_main_queue(), ^{
458+
NSAlert *alert = [NSAlert alertWithError:error];
459+
[alert addButtonWithTitle:@"Dismiss"];
460+
[alert runModal];
461+
[self setProgressVisible:NO];
462+
});
463+
}
464+
else {
465+
dispatch_async(dispatch_get_main_queue(), ^{
466+
[self setProgressVisible:NO];
467+
});
468+
}
469+
}
470+
];
482471
// FIXME: Race condition
483472
// If the completionHandler is called before the addObserver call,
484473
// the app will crash.
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
//
2+
// ALTPreferencesViewController.h
3+
// AltDeploy
4+
//
5+
// Created by PixelOmer on 10.01.2020.
6+
// Copyright © 2020 PixelOmer. All rights reserved.
7+
//
8+
9+
#import <Cocoa/Cocoa.h>
10+
11+
NS_ASSUME_NONNULL_BEGIN
12+
13+
@interface ALTPreferencesViewController : NSViewController
14+
@property (weak) IBOutlet NSTableView *tableView;
15+
16+
@end
17+
18+
NS_ASSUME_NONNULL_END
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
//
2+
// ALTPreferencesViewController.m
3+
// AltDeploy
4+
//
5+
// Created by PixelOmer on 10.01.2020.
6+
// Copyright © 2020 PixelOmer. All rights reserved.
7+
//
8+
9+
#import "ALTPreferencesViewController.h"
10+
11+
@implementation ALTPreferencesViewController
12+
13+
- (void)viewDidLoad {
14+
[super viewDidLoad];
15+
16+
// Do view setup here.
17+
}
18+
19+
@end

0 commit comments

Comments
 (0)