From 512f6faf8478b401a0b6021fdd440ff01577aa3a Mon Sep 17 00:00:00 2001 From: Maarten Billemont Date: Fri, 18 Jul 2014 22:04:10 -0400 Subject: [PATCH] Deprecating iCloud on Mac. --- MasterPassword/ObjC/MPAppDelegate_Store.m | 5 +- MasterPassword/ObjC/Mac/MPInitialWindow.xib | 46 +++--------- .../ObjC/Mac/MPInitialWindowController.h | 1 - .../ObjC/Mac/MPInitialWindowController.m | 9 --- MasterPassword/ObjC/Mac/MPMacAppDelegate.h | 3 - MasterPassword/ObjC/Mac/MPMacAppDelegate.m | 73 +++++++------------ .../ObjC/Mac/MPPasswordWindowController.h | 1 + .../ObjC/Mac/MPPasswordWindowController.m | 3 + .../ObjC/Mac/MPPasswordWindowController.xib | 60 +++++++++------ MasterPassword/ObjC/Mac/en.lproj/MainMenu.xib | 61 +--------------- 10 files changed, 82 insertions(+), 180 deletions(-) diff --git a/MasterPassword/ObjC/MPAppDelegate_Store.m b/MasterPassword/ObjC/MPAppDelegate_Store.m index de1f10d5..d0d54a64 100644 --- a/MasterPassword/ObjC/MPAppDelegate_Store.m +++ b/MasterPassword/ObjC/MPAppDelegate_Store.m @@ -136,9 +136,8 @@ PearlAssociatedObjectProperty( NSManagedObjectContext*, MainManagedObjectContext ^(NSNotification *note) { [[self mainManagedObjectContext] saveToStore]; }]; - [[NSNotificationCenter defaultCenter] - addObserverForName:UIApplicationWillResignActiveNotification object:UIApp - queue:[NSOperationQueue mainQueue] usingBlock: + [[NSNotificationCenter defaultCenter] addObserverForName:UIApplicationWillResignActiveNotification object:UIApp + queue:[NSOperationQueue mainQueue] usingBlock: ^(NSNotification *note) { [[self mainManagedObjectContext] saveToStore]; }]; diff --git a/MasterPassword/ObjC/Mac/MPInitialWindow.xib b/MasterPassword/ObjC/Mac/MPInitialWindow.xib index 3aa11128..18b30af0 100644 --- a/MasterPassword/ObjC/Mac/MPInitialWindow.xib +++ b/MasterPassword/ObjC/Mac/MPInitialWindow.xib @@ -1,5 +1,5 @@ - + @@ -7,7 +7,6 @@ - @@ -17,26 +16,23 @@ - + - + - + - + - - - - + @@ -51,7 +47,7 @@ from anywhere. - + @@ -64,7 +60,7 @@ from anywhere. - + - - - @@ -137,16 +116,13 @@ from anywhere. - - - - + diff --git a/MasterPassword/ObjC/Mac/MPInitialWindowController.h b/MasterPassword/ObjC/Mac/MPInitialWindowController.h index 57f4eaaa..ee7d2863 100644 --- a/MasterPassword/ObjC/Mac/MPInitialWindowController.h +++ b/MasterPassword/ObjC/Mac/MPInitialWindowController.h @@ -21,7 +21,6 @@ @interface MPInitialWindowController : NSWindowController @property(nonatomic, weak) IBOutlet NSButton *openAtLoginButton; -@property(nonatomic, weak) IBOutlet NSButton *enableCloudButton; - (IBAction)iphoneAppStore:(id)sender; - (IBAction)togglePreference:(id)sender; diff --git a/MasterPassword/ObjC/Mac/MPInitialWindowController.m b/MasterPassword/ObjC/Mac/MPInitialWindowController.m index 1f97239e..e1d299ee 100644 --- a/MasterPassword/ObjC/Mac/MPInitialWindowController.m +++ b/MasterPassword/ObjC/Mac/MPInitialWindowController.m @@ -44,15 +44,6 @@ - (IBAction)togglePreference:(id)sender { - if (sender == self.enableCloudButton) { - if (([MPMacAppDelegate get].storeManager.cloudEnabled = self.enableCloudButton.state == NSOnState)) { - NSAlert *alert = [NSAlert new]; - alert.messageText = @"iCloud Enabled"; - alert.informativeText = @"If you already have a user on another iCloud-enabled device, " - @"it may take a moment for that user to sync down to this device."; - [alert runModal]; - } - } if (sender == self.openAtLoginButton) [[MPMacAppDelegate get] setLoginItemEnabled:self.openAtLoginButton.state == NSOnState]; } diff --git a/MasterPassword/ObjC/Mac/MPMacAppDelegate.h b/MasterPassword/ObjC/Mac/MPMacAppDelegate.h index 08630db6..0825e76d 100644 --- a/MasterPassword/ObjC/Mac/MPMacAppDelegate.h +++ b/MasterPassword/ObjC/Mac/MPMacAppDelegate.h @@ -20,7 +20,6 @@ @property(nonatomic, weak) IBOutlet NSMenuItem *lockItem; @property(nonatomic, weak) IBOutlet NSMenuItem *showItem; @property(nonatomic, strong) IBOutlet NSMenu *statusMenu; -@property(nonatomic, weak) IBOutlet NSMenuItem *useCloudItem; @property(nonatomic, weak) IBOutlet NSMenuItem *hidePasswordsItem; @property(nonatomic, weak) IBOutlet NSMenuItem *rememberPasswordItem; @property(nonatomic, weak) IBOutlet NSMenuItem *openAtLoginItem; @@ -34,8 +33,6 @@ - (IBAction)togglePreference:(id)sender; - (IBAction)newUser:(NSMenuItem *)sender; - (IBAction)lock:(id)sender; -- (IBAction)rebuildCloud:(id)sender; -- (IBAction)corruptCloud:(id)sender; - (IBAction)terminate:(id)sender; - (IBAction)showPopup:(id)sender; diff --git a/MasterPassword/ObjC/Mac/MPMacAppDelegate.m b/MasterPassword/ObjC/Mac/MPMacAppDelegate.m index a8a41a6f..0c15b1ba 100644 --- a/MasterPassword/ObjC/Mac/MPMacAppDelegate.m +++ b/MasterPassword/ObjC/Mac/MPMacAppDelegate.m @@ -16,12 +16,6 @@ #define LOGIN_HELPER_BUNDLE_ID @"com.lyndir.lhunath.MasterPassword.Mac.LoginHelper" -@interface UbiquityStoreManager(Private) - -- (void)markCloudStoreCorrupted; - -@end - @implementation MPMacAppDelegate #pragma clang diagnostic push @@ -79,11 +73,6 @@ static OSStatus MPHotKeyHander(EventHandlerCallRef nextHandler, EventRef theEven [weakSelf updateMenuItems]; } ); } forKeyPath:@"activeUser" options:0 context:nil]; - [self addObserverBlock:^(NSString *keyPath, id object, NSDictionary *change, void *context) { - dispatch_async( dispatch_get_main_queue(), ^{ - [weakSelf updateMenuItems]; - } ); - } forKeyPath:@"storeManager.cloudAvailable" options:0 context:nil]; // Status item. self.statusView = [[RHStatusItemView alloc] initWithStatusBarItem: @@ -126,8 +115,9 @@ static OSStatus MPHotKeyHander(EventHandlerCallRef nextHandler, EventRef theEven err( @"Error registering 'lock' hotkey: %i", (int)status ); // Initial display. - if ([[MPMacConfig get].firstRun boolValue]){ - [(self.initialWindowController = [[MPInitialWindowController alloc] initWithWindowNibName:@"MPInitialWindow"]).window makeKeyAndOrderFront:self]; + if ([[MPMacConfig get].firstRun boolValue]) { + [(self.initialWindowController = [[MPInitialWindowController alloc] initWithWindowNibName:@"MPInitialWindow"]) + .window makeKeyAndOrderFront:self]; [NSApp activateIgnoringOtherApps:YES]; } } @@ -314,8 +304,6 @@ static OSStatus MPHotKeyHander(EventHandlerCallRef nextHandler, EventRef theEven - (IBAction)togglePreference:(id)sender { - if (sender == self.useCloudItem) - [self storeManager].cloudEnabled = self.useCloudItem.state != NSOnState; if (sender == self.hidePasswordsItem) [MPConfig get].hidePasswords = [NSNumber numberWithBool:![[MPConfig get].hidePasswords boolValue]]; if (sender == self.rememberPasswordItem) @@ -393,26 +381,6 @@ static OSStatus MPHotKeyHander(EventHandlerCallRef nextHandler, EventRef theEven self.key = nil; } -- (IBAction)rebuildCloud:(id)sender { - - if ([[NSAlert alertWithMessageText:@"iCloud Truth Push" defaultButton:@"Continue" - alternateButton:nil otherButton:@"Cancel" - informativeTextWithFormat:@"This action will force all your iCloud enabled devices to switch to this device's version of the truth." - @"\n\nThis is only necessary if you notice that your devices aren't syncing properly anymore. " - "Any data on other devices not available from here will be lost."] runModal] == NSAlertDefaultReturn) - [self.storeManager rebuildCloudContentFromCloudStoreOrLocalStore:NO]; -} - -- (IBAction)corruptCloud:(id)sender { - - if ([[NSAlert alertWithMessageText:@"iCloud Truth Pull" defaultButton:@"Continue" - alternateButton:nil otherButton:@"Cancel" - informativeTextWithFormat:@"This action will force another iCloud enabled device to push their version of the truth on all." - @"\n\nThis is only necessary if you notice that your devices aren't syncing properly anymore. " - "Any data on this device not available from the other will be lost."] runModal] == NSAlertDefaultReturn) - [self.storeManager markCloudStoreCorrupted]; -} - - (IBAction)terminate:(id)sender { [self.passwordWindowController close]; @@ -547,8 +515,7 @@ static OSStatus MPHotKeyHander(EventHandlerCallRef nextHandler, EventRef theEven if (![users count]) { NSMenuItem *noUsersItem = [self.usersItem.submenu addItemWithTitle:@"No users" action:NULL keyEquivalent:@""]; noUsersItem.enabled = NO; - noUsersItem.toolTip = @"Use the iOS app to create users and make sure iCloud is enabled in its preferences as well. " - @"Then give iCloud some time to sync the new user to your Mac."; + noUsersItem.toolTip = @"Begin by creating a user."; } self.usersItem.state = NSMixedState; @@ -627,17 +594,29 @@ static OSStatus MPHotKeyHander(EventHandlerCallRef nextHandler, EventRef theEven self.savePasswordItem.enabled = YES; self.savePasswordItem.toolTip = nil; } +} - self.useCloudItem.state = self.storeManager.cloudEnabled? NSOnState: NSOffState; - self.initialWindowController.enableCloudButton.state = self.storeManager.cloudEnabled? NSOnState: NSOffState; - self.useCloudItem.enabled = self.storeManager.cloudAvailable; - if (self.storeManager.cloudAvailable) { - self.useCloudItem.title = @"Use iCloud"; - self.useCloudItem.toolTip = nil; - } - else { - self.useCloudItem.title = @"Use iCloud (Unavailable)"; - self.useCloudItem.toolTip = @"iCloud is not set up for your Mac user."; +#pragma mark - UbiquityStoreManagerDelegate + +- (void)ubiquityStoreManager:(UbiquityStoreManager *)manager didLoadStoreForCoordinator:(NSPersistentStoreCoordinator *)coordinator + isCloud:(BOOL)isCloudStore { + + [super ubiquityStoreManager:manager didLoadStoreForCoordinator:coordinator isCloud:isCloudStore]; + + if (isCloudStore) { + NSAlert *alert = [NSAlert new]; + alert.messageText = @"iCloud Support Deprecated"; + alert.informativeText = @"Master Password is moving away from iCloud due to limited platform support and reliability issues. " + @"\n\nMaster Password's generated passwords do not require syncing. " + @"Your sites will always have the same passwords on all your devices. " + @"\n\niCloud continues to work for now but will be deactivated in a future update. " + @"Disable iCloud now to copy your iCloud sites to your device and avoid losing them when iCloud becomes discontinued."; + [alert addButtonWithTitle:@"Disable iCloud"]; + [alert addButtonWithTitle:@"Ignore For Now"]; + + NSInteger response = [alert runModal]; + if (response == NSAlertFirstButtonReturn) + [[self storeManager] migrateCloudToLocal]; } } diff --git a/MasterPassword/ObjC/Mac/MPPasswordWindowController.h b/MasterPassword/ObjC/Mac/MPPasswordWindowController.h index dcc1ff66..11928b4c 100644 --- a/MasterPassword/ObjC/Mac/MPPasswordWindowController.h +++ b/MasterPassword/ObjC/Mac/MPPasswordWindowController.h @@ -28,6 +28,7 @@ @property(nonatomic) NSString *masterPassword; @property(nonatomic) BOOL alternatePressed; @property(nonatomic) BOOL locked; +@property(nonatomic) BOOL newUser; @property(nonatomic, weak) IBOutlet NSArrayController *elementsController; @property(nonatomic, weak) IBOutlet NSImageView *blurView; diff --git a/MasterPassword/ObjC/Mac/MPPasswordWindowController.m b/MasterPassword/ObjC/Mac/MPPasswordWindowController.m index 4330f2a7..8a72102c 100644 --- a/MasterPassword/ObjC/Mac/MPPasswordWindowController.m +++ b/MasterPassword/ObjC/Mac/MPPasswordWindowController.m @@ -476,12 +476,15 @@ [MPMacAppDelegate managedObjectContextForMainThreadPerformBlock:^(NSManagedObjectContext *mainContext) { self.locked = YES; + self.newUser = YES; self.inputLabel.stringValue = @""; self.siteField.stringValue = @""; MPUserEntity *mainActiveUser = [[MPMacAppDelegate get] activeUserInContext:mainContext]; if (mainActiveUser) { + self.newUser = mainActiveUser.keyID == nil; + if ([MPMacAppDelegate get].key) { self.inputLabel.stringValue = strf( @"%@'s password for:", mainActiveUser.name ); self.locked = NO; diff --git a/MasterPassword/ObjC/Mac/MPPasswordWindowController.xib b/MasterPassword/ObjC/Mac/MPPasswordWindowController.xib index fb10cca6..bc790212 100644 --- a/MasterPassword/ObjC/Mac/MPPasswordWindowController.xib +++ b/MasterPassword/ObjC/Mac/MPPasswordWindowController.xib @@ -1,5 +1,5 @@ - + @@ -86,7 +86,6 @@ - @@ -139,13 +138,13 @@ - + - + @@ -450,12 +449,8 @@ - + - - - - NSNegateBoolean @@ -467,8 +462,12 @@ - + + + + + NSNegateBoolean @@ -486,6 +485,15 @@ + + + + + + + NSNegateBoolean + + NSNegateBoolean @@ -510,6 +518,15 @@ + + + + + + + NSNegateBoolean + + NSNegateBoolean @@ -529,7 +546,7 @@ - @@ -55,23 +54,6 @@ - - - - - - - - - - - - - - - - - @@ -199,47 +181,6 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -