2
0

iCloud availability check.

[UPDATED]   Disable iCloud preference when iCloud is unavailable.
[FIXED]     Username in incorrect-mp error popup.
This commit is contained in:
Maarten Billemont 2013-05-31 00:14:04 -04:00
parent af1efe7bc6
commit 35a600080b
3 changed files with 22 additions and 6 deletions

@ -1 +1 @@
Subproject commit f2341a290e66796df0e7b555a24e33f5470ff7f5 Subproject commit 174f955efa883b58d37bc8b2ee93142e98c64f81

View File

@ -224,10 +224,13 @@ static OSStatus MPHotKeyHander(EventHandlerCallRef nextHandler, EventRef theEven
__weak id weakSelf = self; __weak id weakSelf = self;
[self addObserverBlock:^(NSString *keyPath, id object, NSDictionary *change, void *context) { [self addObserverBlock:^(NSString *keyPath, id object, NSDictionary *change, void *context) {
[weakSelf updateMenuItems]; [weakSelf updateMenuItems];
} forKeyPath:@"key" options:NSKeyValueObservingOptionInitial context:nil]; } forKeyPath:@"key" options:0 context:nil];
[self addObserverBlock:^(NSString *keyPath, id object, NSDictionary *change, void *context) { [self addObserverBlock:^(NSString *keyPath, id object, NSDictionary *change, void *context) {
[weakSelf updateMenuItems]; [weakSelf updateMenuItems];
} forKeyPath:@"activeUser" options:NSKeyValueObservingOptionInitial context:nil]; } forKeyPath:@"activeUser" options:0 context:nil];
[self addObserverBlock:^(NSString *keyPath, id object, NSDictionary *change, void *context) {
[weakSelf updateMenuItems];
} forKeyPath:@"storeManager.cloudAvailable" options:0 context:nil];
// Status item. // Status item.
self.statusItem = [[NSStatusBar systemStatusBar] statusItemWithLength:NSSquareStatusItemLength]; self.statusItem = [[NSStatusBar systemStatusBar] statusItemWithLength:NSSquareStatusItemLength];
@ -358,6 +361,15 @@ static OSStatus MPHotKeyHander(EventHandlerCallRef nextHandler, EventRef theEven
} }
self.useICloudItem.state = self.storeManager.cloudEnabled? NSOnState: NSOffState; self.useICloudItem.state = self.storeManager.cloudEnabled? NSOnState: NSOffState;
self.useICloudItem.enabled = self.storeManager.cloudAvailable;
if (self.storeManager.cloudAvailable) {
self.useICloudItem.title = @"Use iCloud";
self.useICloudItem.toolTip = nil;
}
else {
self.useICloudItem.title = @"Use iCloud (Unavailable)";
self.useICloudItem.toolTip = @"iCloud is not set up for your Mac user.";
}
} }
- (IBAction)showPasswordWindow:(id)sender { - (IBAction)showPasswordWindow:(id)sender {

View File

@ -60,8 +60,11 @@
}]; }];
[[NSNotificationCenter defaultCenter] [[NSNotificationCenter defaultCenter]
addObserverForName:NSWindowWillCloseNotification object:self.window queue:nil usingBlock:^(NSNotification *note) { addObserverForName:NSWindowWillCloseNotification object:self.window queue:nil usingBlock:^(NSNotification *note) {
[NSApp endSheet:[self.window attachedSheet]]; NSWindow *sheet = [self.window attachedSheet];
[[NSApplication sharedApplication] hide:nil]; if (sheet)
[NSApp endSheet:sheet];
[NSApp hide:nil];
}]; }];
[[NSNotificationCenter defaultCenter] [[NSNotificationCenter defaultCenter]
addObserverForName:MPSignedOutNotification object:nil queue:nil usingBlock:^(NSNotification *note) { addObserverForName:MPSignedOutNotification object:nil queue:nil usingBlock:^(NSNotification *note) {
@ -201,6 +204,7 @@
NSString *password = [(NSSecureTextField *)alert.accessoryView stringValue]; NSString *password = [(NSSecureTextField *)alert.accessoryView stringValue];
[MPMacAppDelegate managedObjectContextPerformBlock:^(NSManagedObjectContext *moc) { [MPMacAppDelegate managedObjectContextPerformBlock:^(NSManagedObjectContext *moc) {
MPUserEntity *activeUser = [[MPMacAppDelegate get] activeUserInContext:moc]; MPUserEntity *activeUser = [[MPMacAppDelegate get] activeUserInContext:moc];
NSString *userName = activeUser.name;
BOOL success = [[MPMacAppDelegate get] signInAsUser:activeUser saveInContext:moc BOOL success = [[MPMacAppDelegate get] signInAsUser:activeUser saveInContext:moc
usingMasterPassword:password]; usingMasterPassword:password];
self.inProgress = NO; self.inProgress = NO;
@ -212,7 +216,7 @@
self.contentContainer.alphaValue = 1; self.contentContainer.alphaValue = 1;
else { else {
[[NSAlert alertWithError:[NSError errorWithDomain:MPErrorDomain code:0 userInfo:@{ [[NSAlert alertWithError:[NSError errorWithDomain:MPErrorDomain code:0 userInfo:@{
NSLocalizedDescriptionKey : PearlString( @"Incorrect master password for user %@", activeUser.name ) NSLocalizedDescriptionKey : PearlString( @"Incorrect master password for user %@", userName )
}]] beginSheetModalForWindow:self.window modalDelegate:self }]] beginSheetModalForWindow:self.window modalDelegate:self
didEndSelector:@selector(alertDidEnd:returnCode:contextInfo:) contextInfo:MPAlertIncorrectMP]; didEndSelector:@selector(alertDidEnd:returnCode:contextInfo:) contextInfo:MPAlertIncorrectMP];
} }