Store loading and locking modal alerts.
[ADDED] Waiting until the store is loaded. [UPDATED] Hide or lock password window when locked.
This commit is contained in:
parent
0df322f648
commit
d7f369350b
@ -25,7 +25,7 @@
|
||||
@property(nonatomic, weak) IBOutlet NSMenuItem *dialogStyleRegular;
|
||||
@property(nonatomic, weak) IBOutlet NSMenuItem *dialogStyleHUD;
|
||||
|
||||
- (IBAction)showPasswordWindow;
|
||||
- (IBAction)showPasswordWindow:(id)sender;
|
||||
- (IBAction)togglePreference:(NSMenuItem *)sender;
|
||||
- (IBAction)newUser:(NSMenuItem *)sender;
|
||||
- (IBAction)lock:(id)sender;
|
||||
|
@ -40,7 +40,7 @@ static OSStatus MPHotKeyHander(EventHandlerCallRef nextHandler, EventRef theEven
|
||||
|
||||
// Check which hotkey this was.
|
||||
if (hotKeyID.signature == MPShowHotKey.signature && hotKeyID.id == MPShowHotKey.id) {
|
||||
[((__bridge MPMacAppDelegate *)userData) showPasswordWindow];
|
||||
[((__bridge MPMacAppDelegate *)userData) showPasswordWindow:nil];
|
||||
return noErr;
|
||||
}
|
||||
if (hotKeyID.signature == MPLockHotKey.signature && hotKeyID.id == MPLockHotKey.id) {
|
||||
@ -168,7 +168,7 @@ static OSStatus MPHotKeyHander(EventHandlerCallRef nextHandler, EventRef theEven
|
||||
[[NSOperationQueue mainQueue] addOperationWithBlock:^{
|
||||
[self updateUsers];
|
||||
[self setActiveUser:newUser];
|
||||
[self showPasswordWindow];
|
||||
[self showPasswordWindow:nil];
|
||||
}];
|
||||
}];
|
||||
}
|
||||
@ -238,7 +238,7 @@ static OSStatus MPHotKeyHander(EventHandlerCallRef nextHandler, EventRef theEven
|
||||
else {
|
||||
[self.passwordWindow close];
|
||||
self.passwordWindow = nil;
|
||||
[self showPasswordWindow];
|
||||
[self showPasswordWindow:nil];
|
||||
}
|
||||
}
|
||||
}];
|
||||
@ -280,24 +280,24 @@ static OSStatus MPHotKeyHander(EventHandlerCallRef nextHandler, EventRef theEven
|
||||
[MPMacConfig get].usedUserName = activeUser.name;
|
||||
|
||||
if (reopenPasswordWindow)
|
||||
[self showPasswordWindow];
|
||||
[self showPasswordWindow:nil];
|
||||
}
|
||||
|
||||
- (void)updateMenuItems {
|
||||
|
||||
MPUserEntity *activeUser = [self activeUserForThread];
|
||||
if (!(self.showItem.enabled = ![self.passwordWindow.window isVisible])) {
|
||||
self.showItem.title = @"Show (Showing)";
|
||||
self.showItem.toolTip = @"Master Password is already showing.";
|
||||
}
|
||||
else if (!(self.showItem.enabled = (activeUser != nil))) {
|
||||
self.showItem.title = @"Show (No user)";
|
||||
self.showItem.toolTip = @"First select the user to show passwords for.";
|
||||
}
|
||||
else {
|
||||
self.showItem.title = @"Show";
|
||||
self.showItem.toolTip = nil;
|
||||
}
|
||||
// if (!(self.showItem.enabled = ![self.passwordWindow.window isVisible])) {
|
||||
// self.showItem.title = @"Show (Showing)";
|
||||
// self.showItem.toolTip = @"Master Password is already showing.";
|
||||
// }
|
||||
// else if (!(self.showItem.enabled = (activeUser != nil))) {
|
||||
// self.showItem.title = @"Show (No user)";
|
||||
// self.showItem.toolTip = @"First select the user to show passwords for.";
|
||||
// }
|
||||
// else {
|
||||
// self.showItem.title = @"Show";
|
||||
// self.showItem.toolTip = nil;
|
||||
// }
|
||||
|
||||
if (self.key) {
|
||||
self.lockItem.title = @"Lock";
|
||||
@ -346,7 +346,7 @@ static OSStatus MPHotKeyHander(EventHandlerCallRef nextHandler, EventRef theEven
|
||||
// [self showPasswordWindow];
|
||||
}
|
||||
|
||||
- (IBAction)showPasswordWindow {
|
||||
- (IBAction)showPasswordWindow:(id)sender {
|
||||
|
||||
// If no user, can't activate.
|
||||
if (![self activeUserForThread])
|
||||
|
@ -14,6 +14,7 @@
|
||||
#define MPAlertUnlockMP @"MPAlertUnlockMP"
|
||||
#define MPAlertIncorrectMP @"MPAlertIncorrectMP"
|
||||
#define MPAlertCreateSite @"MPAlertCreateSite"
|
||||
#define MPAlertLoadingData @"MPAlertLoadingData"
|
||||
|
||||
@interface MPPasswordWindowController()
|
||||
|
||||
@ -21,6 +22,7 @@
|
||||
@property(nonatomic) BOOL siteFieldPreventCompletion;
|
||||
|
||||
@property(nonatomic, strong) NSOperationQueue *backgroundQueue;
|
||||
@property(nonatomic, strong) NSConditionLock *loadingLock;
|
||||
@end
|
||||
|
||||
@implementation MPPasswordWindowController {
|
||||
@ -41,7 +43,7 @@
|
||||
[self.tipField setStringValue:@""];
|
||||
|
||||
[self.userLabel setStringValue:PearlString( @"%@'s password for:", [[MPMacAppDelegate get] activeUserForThread].name )];
|
||||
// [[MPMacAppDelegate get] addObserverBlock:^(NSString *keyPath, id object, NSDictionary *change, void *context) {
|
||||
[[MPMacAppDelegate get] addObserverBlock:^(NSString *keyPath, id object, NSDictionary *change, void *context) {
|
||||
// [MPMacAppDelegate managedObjectContextPerformBlock:^(NSManagedObjectContext *moc) {
|
||||
// if (![MPAlgorithmDefault migrateUser:[[MPMacAppDelegate get] activeUserInContext:moc]])
|
||||
// [NSAlert alertWithMessageText:@"Migration Needed" defaultButton:@"OK" alternateButton:nil otherButton:nil
|
||||
@ -50,18 +52,23 @@
|
||||
// @"their passwords to change. You'll need to update your profile for that site with the new password."];
|
||||
// [moc saveToStore];
|
||||
// }];
|
||||
// } forKeyPath:@"key" options:NSKeyValueObservingOptionInitial context:nil];
|
||||
if (!self.inProgress && ![MPMacAppDelegate get].key) {
|
||||
if (![MPMacAppDelegate get].activeUserForThread.saveKey)
|
||||
[self unlock];
|
||||
else
|
||||
[self.window close];
|
||||
}
|
||||
} forKeyPath:@"key" options:NSKeyValueObservingOptionInitial context:nil];
|
||||
[[NSNotificationCenter defaultCenter]
|
||||
addObserverForName:NSWindowDidBecomeKeyNotification object:self.window queue:nil usingBlock:^(NSNotification *note) {
|
||||
if (![MPMacAppDelegate managedObjectContextForThreadIfReady])
|
||||
[self waitUntilStoreLoaded];
|
||||
[self waitUntilStoreLoaded];
|
||||
if (!self.inProgress)
|
||||
[self unlock];
|
||||
[self.siteField selectText:self];
|
||||
[self.siteField selectText:nil];
|
||||
}];
|
||||
[[NSNotificationCenter defaultCenter]
|
||||
addObserverForName:NSWindowWillCloseNotification object:self.window queue:nil usingBlock:^(NSNotification *note) {
|
||||
[[NSApplication sharedApplication] hide:self];
|
||||
[[NSApplication sharedApplication] hide:nil];
|
||||
}];
|
||||
[[NSNotificationCenter defaultCenter]
|
||||
addObserverForName:MPSignedOutNotification object:nil queue:nil usingBlock:^(NSNotification *note) {
|
||||
@ -77,6 +84,18 @@
|
||||
}
|
||||
|
||||
- (void)waitUntilStoreLoaded {
|
||||
|
||||
if ([MPMacAppDelegate managedObjectContextForThreadIfReady]) {
|
||||
[self.loadingLock unlockWithCondition:1];
|
||||
return;
|
||||
}
|
||||
|
||||
[[NSAlert alertWithMessageText:@"Loading Your Data" defaultButton:nil alternateButton:nil otherButton:nil
|
||||
informativeTextWithFormat:nil]
|
||||
beginSheetModalForWindow:self.window modalDelegate:self didEndSelector:@selector(alertDidEnd:returnCode:contextInfo:)
|
||||
contextInfo:MPAlertLoadingData];
|
||||
[self.loadingLock = [[NSConditionLock alloc] initWithCondition:0] lockWhenCondition:1];
|
||||
self.loadingLock = nil;
|
||||
}
|
||||
|
||||
- (void)unlock {
|
||||
@ -123,6 +142,11 @@
|
||||
[self.window close];
|
||||
return;
|
||||
}
|
||||
if (contextInfo == MPAlertLoadingData) {
|
||||
[alert.window orderOut:nil];
|
||||
[self waitUntilStoreLoaded];
|
||||
return;
|
||||
}
|
||||
if (contextInfo == MPAlertUnlockMP) {
|
||||
switch (returnCode) {
|
||||
case NSAlertAlternateReturn: {
|
||||
|
@ -272,7 +272,8 @@
|
||||
<object class="NSMenuItem" id="291035877">
|
||||
<reference key="NSMenu" ref="764588027"/>
|
||||
<string key="NSTitle">Quit</string>
|
||||
<string key="NSKeyEquiv"/>
|
||||
<string key="NSKeyEquiv">q</string>
|
||||
<int key="NSKeyEquivModMask">1048576</int>
|
||||
<int key="NSMnemonicLoc">2147483647</int>
|
||||
<reference key="NSOnImage" ref="269450960"/>
|
||||
<reference key="NSMixedImage" ref="977440657"/>
|
||||
@ -307,14 +308,6 @@
|
||||
</object>
|
||||
<int key="connectionID">726</int>
|
||||
</object>
|
||||
<object class="IBConnectionRecord">
|
||||
<object class="IBOutletConnection" key="connection">
|
||||
<string key="label">showItem</string>
|
||||
<reference key="source" ref="976324537"/>
|
||||
<reference key="destination" ref="846612332"/>
|
||||
</object>
|
||||
<int key="connectionID">730</int>
|
||||
</object>
|
||||
<object class="IBConnectionRecord">
|
||||
<object class="IBOutletConnection" key="connection">
|
||||
<string key="label">statusMenu</string>
|
||||
@ -445,11 +438,19 @@
|
||||
</object>
|
||||
<object class="IBConnectionRecord">
|
||||
<object class="IBActionConnection" key="connection">
|
||||
<string key="label">showPasswordWindow</string>
|
||||
<string key="label">showPasswordWindow:</string>
|
||||
<reference key="source" ref="976324537"/>
|
||||
<reference key="destination" ref="846612332"/>
|
||||
</object>
|
||||
<int key="connectionID">781</int>
|
||||
<int key="connectionID">782</int>
|
||||
</object>
|
||||
<object class="IBConnectionRecord">
|
||||
<object class="IBOutletConnection" key="connection">
|
||||
<string key="label">showItem</string>
|
||||
<reference key="source" ref="976324537"/>
|
||||
<reference key="destination" ref="846612332"/>
|
||||
</object>
|
||||
<int key="connectionID">783</int>
|
||||
</object>
|
||||
</array>
|
||||
<object class="IBMutableOrderedSet" key="objectRecords">
|
||||
@ -708,13 +709,13 @@
|
||||
<nil key="activeLocalization"/>
|
||||
<dictionary class="NSMutableDictionary" key="localizations"/>
|
||||
<nil key="sourceID"/>
|
||||
<int key="maxID">781</int>
|
||||
<int key="maxID">783</int>
|
||||
</object>
|
||||
<object class="IBClassDescriber" key="IBDocument.Classes">
|
||||
<array class="NSMutableArray" key="referencedPartialClassDescriptions">
|
||||
<object class="IBPartialClassDescription">
|
||||
<string key="className">MPAppDelegate_Shared</string>
|
||||
<string key="superclassName">PearlAppDelegate</string>
|
||||
<string key="superclassName">NSObject</string>
|
||||
<object class="IBClassDescriptionSource" key="sourceIdentifier">
|
||||
<string key="majorKey">IBProjectSource</string>
|
||||
<string key="minorKey">./Classes/MPAppDelegate_Shared.h</string>
|
||||
@ -724,17 +725,13 @@
|
||||
<string key="className">MPMacAppDelegate</string>
|
||||
<string key="superclassName">MPAppDelegate_Shared</string>
|
||||
<dictionary class="NSMutableDictionary" key="actions">
|
||||
<string key="activate:">id</string>
|
||||
<string key="lock:">id</string>
|
||||
<string key="newUser:">NSMenuItem</string>
|
||||
<string key="rebuildCloud:">id</string>
|
||||
<string key="showPasswordWindow:">id</string>
|
||||
<string key="togglePreference:">NSMenuItem</string>
|
||||
</dictionary>
|
||||
<dictionary class="NSMutableDictionary" key="actionInfosByName">
|
||||
<object class="IBActionInfo" key="activate:">
|
||||
<string key="name">activate:</string>
|
||||
<string key="candidateClassName">id</string>
|
||||
</object>
|
||||
<object class="IBActionInfo" key="lock:">
|
||||
<string key="name">lock:</string>
|
||||
<string key="candidateClassName">id</string>
|
||||
@ -747,6 +744,10 @@
|
||||
<string key="name">rebuildCloud:</string>
|
||||
<string key="candidateClassName">id</string>
|
||||
</object>
|
||||
<object class="IBActionInfo" key="showPasswordWindow:">
|
||||
<string key="name">showPasswordWindow:</string>
|
||||
<string key="candidateClassName">id</string>
|
||||
</object>
|
||||
<object class="IBActionInfo" key="togglePreference:">
|
||||
<string key="name">togglePreference:</string>
|
||||
<string key="candidateClassName">NSMenuItem</string>
|
||||
@ -811,44 +812,6 @@
|
||||
<string key="minorKey">./Classes/MPMacAppDelegate.h</string>
|
||||
</object>
|
||||
</object>
|
||||
<object class="IBPartialClassDescription">
|
||||
<string key="className">PearlAppDelegate</string>
|
||||
<string key="superclassName">UIResponder</string>
|
||||
<dictionary class="NSMutableDictionary" key="outlets">
|
||||
<string key="navigationController">UINavigationController</string>
|
||||
<string key="window">UIWindow</string>
|
||||
</dictionary>
|
||||
<dictionary class="NSMutableDictionary" key="toOneOutletInfosByName">
|
||||
<object class="IBToOneOutletInfo" key="navigationController">
|
||||
<string key="name">navigationController</string>
|
||||
<string key="candidateClassName">UINavigationController</string>
|
||||
</object>
|
||||
<object class="IBToOneOutletInfo" key="window">
|
||||
<string key="name">window</string>
|
||||
<string key="candidateClassName">UIWindow</string>
|
||||
</object>
|
||||
</dictionary>
|
||||
<object class="IBClassDescriptionSource" key="sourceIdentifier">
|
||||
<string key="majorKey">IBProjectSource</string>
|
||||
<string key="minorKey">./Classes/PearlAppDelegate.h</string>
|
||||
</object>
|
||||
</object>
|
||||
<object class="IBPartialClassDescription">
|
||||
<string key="className">UINavigationController</string>
|
||||
<string key="superclassName">UIViewController</string>
|
||||
<object class="IBClassDescriptionSource" key="sourceIdentifier">
|
||||
<string key="majorKey">IBProjectSource</string>
|
||||
<string key="minorKey">./Classes/UINavigationController.h</string>
|
||||
</object>
|
||||
</object>
|
||||
<object class="IBPartialClassDescription">
|
||||
<string key="className">UIWindow</string>
|
||||
<string key="superclassName">UIView</string>
|
||||
<object class="IBClassDescriptionSource" key="sourceIdentifier">
|
||||
<string key="majorKey">IBProjectSource</string>
|
||||
<string key="minorKey">./Classes/UIWindow.h</string>
|
||||
</object>
|
||||
</object>
|
||||
</array>
|
||||
</object>
|
||||
<int key="IBDocument.localizationMode">0</int>
|
||||
|
Loading…
Reference in New Issue
Block a user