2
0

Revert "Temporary build fix: Disable iCloudStoreManager integration."

This reverts commit b301d0bdd6.
This commit is contained in:
Maarten Billemont 2013-04-01 22:03:28 -04:00
parent e22be0f97c
commit 2f17639eeb
3 changed files with 178 additions and 178 deletions

View File

@ -18,7 +18,7 @@ typedef enum {
MPImportResultInternalError, MPImportResultInternalError,
} MPImportResult; } MPImportResult;
@interface MPAppDelegate_Shared (Store)//<UbiquityStoreManagerDelegate> @interface MPAppDelegate_Shared (Store)<UbiquityStoreManagerDelegate>
+ (NSManagedObjectContext *)managedObjectContextForThreadIfReady; + (NSManagedObjectContext *)managedObjectContextForThreadIfReady;
+ (BOOL)managedObjectContextPerformBlock:(void (^)(NSManagedObjectContext *moc))mocBlock; + (BOOL)managedObjectContextPerformBlock:(void (^)(NSManagedObjectContext *moc))mocBlock;

View File

@ -68,24 +68,24 @@ static char privateManagedObjectContextKey, mainManagedObjectContextKey;
- (NSManagedObjectContext *)privateManagedObjectContextIfReady { - (NSManagedObjectContext *)privateManagedObjectContextIfReady {
NSManagedObjectContext *privateManagedObjectContext = objc_getAssociatedObject(self, &privateManagedObjectContextKey); NSManagedObjectContext *privateManagedObjectContext = objc_getAssociatedObject(self, &privateManagedObjectContextKey);
// if (!privateManagedObjectContext) { if (!privateManagedObjectContext) {
// privateManagedObjectContext = [[NSManagedObjectContext alloc] initWithConcurrencyType:NSPrivateQueueConcurrencyType]; privateManagedObjectContext = [[NSManagedObjectContext alloc] initWithConcurrencyType:NSPrivateQueueConcurrencyType];
// [privateManagedObjectContext performBlockAndWait:^{ [privateManagedObjectContext performBlockAndWait:^{
// privateManagedObjectContext.mergePolicy = NSMergeByPropertyObjectTrumpMergePolicy; privateManagedObjectContext.mergePolicy = NSMergeByPropertyObjectTrumpMergePolicy;
// privateManagedObjectContext.persistentStoreCoordinator = self.storeManager.persistentStoreCoordinator; privateManagedObjectContext.persistentStoreCoordinator = self.storeManager.persistentStoreCoordinator;
// }]; }];
//
// NSManagedObjectContext *mainManagedObjectContext = [[NSManagedObjectContext alloc] initWithConcurrencyType:NSMainQueueConcurrencyType]; NSManagedObjectContext *mainManagedObjectContext = [[NSManagedObjectContext alloc] initWithConcurrencyType:NSMainQueueConcurrencyType];
// mainManagedObjectContext.parentContext = privateManagedObjectContext; mainManagedObjectContext.parentContext = privateManagedObjectContext;
//
// objc_setAssociatedObject(self, &privateManagedObjectContextKey, privateManagedObjectContext, OBJC_ASSOCIATION_RETAIN); objc_setAssociatedObject(self, &privateManagedObjectContextKey, privateManagedObjectContext, OBJC_ASSOCIATION_RETAIN);
// objc_setAssociatedObject(self, &mainManagedObjectContextKey, mainManagedObjectContext, OBJC_ASSOCIATION_RETAIN); objc_setAssociatedObject(self, &mainManagedObjectContextKey, mainManagedObjectContext, OBJC_ASSOCIATION_RETAIN);
// } }
//
// if (![privateManagedObjectContext.persistentStoreCoordinator.persistentStores count]) if (![privateManagedObjectContext.persistentStoreCoordinator.persistentStores count])
// // Store not available yet. // Store not available yet.
// return nil; return nil;
//
return privateManagedObjectContext; return privateManagedObjectContext;
} }
@ -213,57 +213,57 @@ static char privateManagedObjectContextKey, mainManagedObjectContextKey;
[[NSUserDefaults standardUserDefaults] removeObjectForKey:@"iCloudEnabledKey"]; [[NSUserDefaults standardUserDefaults] removeObjectForKey:@"iCloudEnabledKey"];
} }
//- (UbiquityStoreManager *)storeManager { - (UbiquityStoreManager *)storeManager {
//
// static UbiquityStoreManager *storeManager = nil; static UbiquityStoreManager *storeManager = nil;
// if (storeManager) if (storeManager)
// return storeManager; return storeManager;
//
// storeManager = [[UbiquityStoreManager alloc] initStoreNamed:nil withManagedObjectModel:nil localStoreURL:nil storeManager = [[UbiquityStoreManager alloc] initStoreNamed:nil withManagedObjectModel:nil localStoreURL:nil
// containerIdentifier:@"HL3Q45LX9N.com.lyndir.lhunath.MasterPassword.shared" containerIdentifier:@"HL3Q45LX9N.com.lyndir.lhunath.MasterPassword.shared"
//#if TARGET_OS_IPHONE #if TARGET_OS_IPHONE
// additionalStoreOptions:@{ additionalStoreOptions:@{
// NSPersistentStoreFileProtectionKey : NSFileProtectionComplete NSPersistentStoreFileProtectionKey : NSFileProtectionComplete
// }]; }];
//#else #else
// additionalStoreOptions:nil]; additionalStoreOptions:nil];
//#endif #endif
// storeManager.delegate = self; storeManager.delegate = self;
//
// // Migrate old store to new store location. // Migrate old store to new store location.
// [self migrateStoreForManager:storeManager]; [self migrateStoreForManager:storeManager];
//
// [[NSNotificationCenter defaultCenter] addObserverForName:UbiquityManagedStoreDidChangeNotification [[NSNotificationCenter defaultCenter] addObserverForName:UbiquityManagedStoreDidChangeNotification
// object:storeManager queue:nil object:storeManager queue:nil
// usingBlock:^(NSNotification *note) { usingBlock:^(NSNotification *note) {
// objc_setAssociatedObject(self, &privateManagedObjectContextKey, nil, OBJC_ASSOCIATION_RETAIN); objc_setAssociatedObject(self, &privateManagedObjectContextKey, nil, OBJC_ASSOCIATION_RETAIN);
// }]; }];
// [[NSNotificationCenter defaultCenter] addObserverForName:MPCheckConfigNotification object:nil queue:nil usingBlock: [[NSNotificationCenter defaultCenter] addObserverForName:MPCheckConfigNotification object:nil queue:nil usingBlock:
// ^(NSNotification *note) { ^(NSNotification *note) {
// if ([[MPConfig get].iCloud boolValue] != [self.storeManager cloudEnabled]) if ([[MPConfig get].iCloud boolValue] != [self.storeManager cloudEnabled])
// self.storeManager.cloudEnabled = [[MPConfig get].iCloud boolValue]; self.storeManager.cloudEnabled = [[MPConfig get].iCloud boolValue];
// }]; }];
//#if TARGET_OS_IPHONE #if TARGET_OS_IPHONE
// [[NSNotificationCenter defaultCenter] addObserverForName:UIApplicationWillTerminateNotification [[NSNotificationCenter defaultCenter] addObserverForName:UIApplicationWillTerminateNotification
// object:[UIApplication sharedApplication] queue:nil object:[UIApplication sharedApplication] queue:nil
// usingBlock:^(NSNotification *note) { usingBlock:^(NSNotification *note) {
// [self saveContexts]; [self saveContexts];
// }]; }];
// [[NSNotificationCenter defaultCenter] addObserverForName:UIApplicationWillResignActiveNotification [[NSNotificationCenter defaultCenter] addObserverForName:UIApplicationWillResignActiveNotification
// object:[UIApplication sharedApplication] queue:nil object:[UIApplication sharedApplication] queue:nil
// usingBlock:^(NSNotification *note) { usingBlock:^(NSNotification *note) {
// [self saveContexts]; [self saveContexts];
// }]; }];
//#else #else
// [[NSNotificationCenter defaultCenter] addObserverForName:NSApplicationWillTerminateNotification [[NSNotificationCenter defaultCenter] addObserverForName:NSApplicationWillTerminateNotification
// object:[NSApplication sharedApplication] queue:nil object:[NSApplication sharedApplication] queue:nil
// usingBlock:^(NSNotification *note) { usingBlock:^(NSNotification *note) {
// [self saveContexts]; [self saveContexts];
// }]; }];
//#endif #endif
//
// return storeManager; return storeManager;
//} }
- (void)saveContexts { - (void)saveContexts {
@ -312,71 +312,71 @@ static char privateManagedObjectContextKey, mainManagedObjectContextKey;
[MPConfig get].iCloud = @(cloudEnabled); [MPConfig get].iCloud = @(cloudEnabled);
} }
//- (void)ubiquityStoreManager:(UbiquityStoreManager *)manager didEncounterError:(NSError *)error cause:(UbiquityStoreManagerErrorCause)cause - (void)ubiquityStoreManager:(UbiquityStoreManager *)manager didEncounterError:(NSError *)error cause:(UbiquityStoreManagerErrorCause)cause
// context:(id)context { context:(id)context {
//
// err(@"StoreManager: cause=%d, context=%@, error=%@", cause, context, error); err(@"StoreManager: cause=%d, context=%@, error=%@", cause, context, error);
//
//#ifdef TESTFLIGHT_SDK_VERSION #ifdef TESTFLIGHT_SDK_VERSION
// [TestFlight passCheckpoint:PearlString(MPCheckpointMPErrorUbiquity @"_%d", cause)]; [TestFlight passCheckpoint:PearlString(MPCheckpointMPErrorUbiquity @"_%d", cause)];
//#endif #endif
//#ifdef LOCALYTICS #ifdef LOCALYTICS
// [[LocalyticsSession sharedLocalyticsSession] tagEvent:MPCheckpointMPErrorUbiquity attributes:@{ [[LocalyticsSession sharedLocalyticsSession] tagEvent:MPCheckpointMPErrorUbiquity attributes:@{
// @"cause": @(cause), @"cause": @(cause),
// @"error.domain": error.domain, @"error.domain": error.domain,
// @"error.code": @(error.code) @"error.code": @(error.code)
// }]; }];
//#endif #endif
//
// switch (cause) { switch (cause) {
// case UbiquityStoreManagerErrorCauseDeleteStore: case UbiquityStoreManagerErrorCauseDeleteStore:
// case UbiquityStoreManagerErrorCauseCreateStorePath: case UbiquityStoreManagerErrorCauseCreateStorePath:
// case UbiquityStoreManagerErrorCauseClearStore: case UbiquityStoreManagerErrorCauseClearStore:
// break; break;
// case UbiquityStoreManagerErrorCauseOpenLocalStore: { case UbiquityStoreManagerErrorCauseOpenLocalStore: {
// wrn(@"Local store could not be opened: %@", error); wrn(@"Local store could not be opened: %@", error);
//
// if (error.code == NSMigrationMissingSourceModelError) { if (error.code == NSMigrationMissingSourceModelError) {
// wrn(@"Resetting the local store."); wrn(@"Resetting the local store.");
//
//#ifdef TESTFLIGHT_SDK_VERSION #ifdef TESTFLIGHT_SDK_VERSION
// [TestFlight passCheckpoint:MPCheckpointLocalStoreReset]; [TestFlight passCheckpoint:MPCheckpointLocalStoreReset];
//#endif #endif
//#ifdef LOCALYTICS #ifdef LOCALYTICS
// [[LocalyticsSession sharedLocalyticsSession] tagEvent:MPCheckpointLocalStoreReset attributes:nil]; [[LocalyticsSession sharedLocalyticsSession] tagEvent:MPCheckpointLocalStoreReset attributes:nil];
//#endif #endif
// [manager deleteLocalStore]; [manager deleteLocalStore];
//
// Throw(@"Local store was reset, application must be restarted to use it."); Throw(@"Local store was reset, application must be restarted to use it.");
// } else } else
// // Try again. // Try again.
// [manager persistentStoreCoordinator]; [manager persistentStoreCoordinator];
// } }
// case UbiquityStoreManagerErrorCauseOpenCloudStore: { case UbiquityStoreManagerErrorCauseOpenCloudStore: {
// wrn(@"iCloud store could not be opened: %@", error); wrn(@"iCloud store could not be opened: %@", error);
//
// if (error.code == NSMigrationMissingSourceModelError) { if (error.code == NSMigrationMissingSourceModelError) {
// wrn(@"Resetting the iCloud store."); wrn(@"Resetting the iCloud store.");
//
//#ifdef TESTFLIGHT_SDK_VERSION #ifdef TESTFLIGHT_SDK_VERSION
// [TestFlight passCheckpoint:MPCheckpointCloudStoreReset]; [TestFlight passCheckpoint:MPCheckpointCloudStoreReset];
//#endif #endif
//#ifdef LOCALYTICS #ifdef LOCALYTICS
// [[LocalyticsSession sharedLocalyticsSession] tagEvent:MPCheckpointCloudStoreReset attributes:nil]; [[LocalyticsSession sharedLocalyticsSession] tagEvent:MPCheckpointCloudStoreReset attributes:nil];
//#endif #endif
// [manager deleteCloudStore]; [manager deleteCloudStore];
// break; break;
// } else } else
// // Try again. // Try again.
// [manager persistentStoreCoordinator]; [manager persistentStoreCoordinator];
// } }
// case UbiquityStoreManagerErrorCauseMigrateLocalToCloudStore: { case UbiquityStoreManagerErrorCauseMigrateLocalToCloudStore: {
// wrn(@"Couldn't migrate local store to the cloud: %@", error); wrn(@"Couldn't migrate local store to the cloud: %@", error);
// wrn(@"Resetting the iCloud store."); wrn(@"Resetting the iCloud store.");
// [manager deleteCloudStore]; [manager deleteCloudStore];
// }; };
// } }
//} }
#pragma mark - Import / Export #pragma mark - Import / Export

View File

@ -616,49 +616,49 @@
#pragma mark - UbiquityStoreManagerDelegate #pragma mark - UbiquityStoreManagerDelegate
//- (void)ubiquityStoreManager:(UbiquityStoreManager *)manager didSwitchToCloud:(BOOL)cloudEnabled { - (void)ubiquityStoreManager:(UbiquityStoreManager *)manager didSwitchToCloud:(BOOL)cloudEnabled {
//
// [super ubiquityStoreManager:manager didSwitchToCloud:cloudEnabled]; [super ubiquityStoreManager:manager didSwitchToCloud:cloudEnabled];
//
// if (![[MPConfig get].iCloudDecided boolValue]) { if (![[MPConfig get].iCloudDecided boolValue]) {
// if (!cloudEnabled) { if (!cloudEnabled) {
// [PearlAlert showAlertWithTitle:@"iCloud" [PearlAlert showAlertWithTitle:@"iCloud"
// message: message:
// @"iCloud is now disabled.\n\n" @"iCloud is now disabled.\n\n"
// @"It is highly recommended you enable iCloud." @"It is highly recommended you enable iCloud."
// viewStyle:UIAlertViewStyleDefault initAlert:nil viewStyle:UIAlertViewStyleDefault initAlert:nil
// tappedButtonBlock:^(UIAlertView *alert, NSInteger buttonIndex) { tappedButtonBlock:^(UIAlertView *alert, NSInteger buttonIndex) {
// if (buttonIndex == [alert firstOtherButtonIndex] + 0) { if (buttonIndex == [alert firstOtherButtonIndex] + 0) {
// [PearlAlert showAlertWithTitle:@"About iCloud" [PearlAlert showAlertWithTitle:@"About iCloud"
// message: message:
// @"iCloud is Apple's solution for saving your data in \"the cloud\" " @"iCloud is Apple's solution for saving your data in \"the cloud\" "
// @"and making sure your other iPhones, iPads and Macs are in sync.\n\n" @"and making sure your other iPhones, iPads and Macs are in sync.\n\n"
// @"For Master Password, that means your sites are available on all your " @"For Master Password, that means your sites are available on all your "
// @"Apple devices, and you always have a backup of them in case " @"Apple devices, and you always have a backup of them in case "
// @"you loose one or need to restore.\n\n" @"you loose one or need to restore.\n\n"
// @"Because of the way Master Password works, it doesn't need to send your " @"Because of the way Master Password works, it doesn't need to send your "
// @"site's passwords to Apple. Only their names are saved to make it easier " @"site's passwords to Apple. Only their names are saved to make it easier "
// @"for you to find the site you need. For some sites you may have set " @"for you to find the site you need. For some sites you may have set "
// @"a user-specified password: these are sent to iCloud after being encrypted " @"a user-specified password: these are sent to iCloud after being encrypted "
// @"with your master password.\n\n" @"with your master password.\n\n"
// @"Apple can never see any of your passwords." @"Apple can never see any of your passwords."
// viewStyle:UIAlertViewStyleDefault viewStyle:UIAlertViewStyleDefault
// initAlert:nil tappedButtonBlock:^(UIAlertView *alert_, NSInteger buttonIndex_) { initAlert:nil tappedButtonBlock:^(UIAlertView *alert_, NSInteger buttonIndex_) {
// [self ubiquityStoreManager:manager didSwitchToCloud:cloudEnabled]; [self ubiquityStoreManager:manager didSwitchToCloud:cloudEnabled];
// } }
// cancelTitle:[PearlStrings get].commonButtonThanks otherTitles:nil]; cancelTitle:[PearlStrings get].commonButtonThanks otherTitles:nil];
// return; return;
// } }
//
// [MPConfig get].iCloudDecided = @YES; [MPConfig get].iCloudDecided = @YES;
// if (buttonIndex == [alert cancelButtonIndex]) if (buttonIndex == [alert cancelButtonIndex])
// return; return;
// if (buttonIndex == [alert firstOtherButtonIndex] + 1) if (buttonIndex == [alert firstOtherButtonIndex] + 1)
// manager.cloudEnabled = YES; manager.cloudEnabled = YES;
// } cancelTitle:@"Leave iCloud Off" otherTitles:@"Explain?", @"Enable iCloud", nil]; } cancelTitle:@"Leave iCloud Off" otherTitles:@"Explain?", @"Enable iCloud", nil];
// } }
// } }
//} }
#pragma mark - Google+ #pragma mark - Google+