From 6bbd183ac97a9866785c9b32a977e6e5ae24bb93 Mon Sep 17 00:00:00 2001 From: Maarten Billemont Date: Fri, 11 May 2012 17:04:51 +0200 Subject: [PATCH] TestFlight checkpoint update + iCloud warning. [UPDATED] Check TARGET_OS_IPHONE instead of __IPHONE_OS_VERSION_MIN_REQUIRED. [UPDATED] A few TestFlight checkpoints names have been updated. [ADDED] A few new TestFlight checkpoints for new features. [ADDED] Warn the user when he's not using iCloud and allow him to switch back to iCloud. --- External/Pearl | 2 +- MasterPassword/MPAppDelegate_Key.m | 18 +++++++++--------- MasterPassword/MPAppDelegate_Shared.m | 4 ++-- MasterPassword/MPAppDelegate_Store.m | 20 ++++++++++++++++++-- MasterPassword/MPElementStoredEntity.m | 2 +- MasterPassword/MPTypes.h | 11 ++++++++--- MasterPassword/iOS/MPAppDelegate.m | 23 ++++++++++++++++++++++- 7 files changed, 61 insertions(+), 19 deletions(-) diff --git a/External/Pearl b/External/Pearl index a8346d67..489ac300 160000 --- a/External/Pearl +++ b/External/Pearl @@ -1 +1 @@ -Subproject commit a8346d6715eb258d11d41a4775e8f1abee620312 +Subproject commit 489ac3004875581ebd0f46256ad6a45e6172b92a diff --git a/MasterPassword/MPAppDelegate_Key.m b/MasterPassword/MPAppDelegate_Key.m index 865ded1e..9cac58c8 100644 --- a/MasterPassword/MPAppDelegate_Key.m +++ b/MasterPassword/MPAppDelegate_Key.m @@ -43,7 +43,7 @@ static NSDictionary *keyHashQuery() { [PearlKeyChain deleteItemForQuery:keyHashQuery()]; [[NSNotificationCenter defaultCenter] postNotificationName:MPNotificationKeyForgotten object:self]; -#ifdef __IPHONE_OS_VERSION_MIN_REQUIRED +#if TARGET_OS_IPHONE [TestFlight passCheckpoint:MPTestFlightCheckpointMPForgotten]; #endif } @@ -64,7 +64,7 @@ static NSDictionary *keyHashQuery() { // Key should not be stored in keychain. Delete it. if ([PearlKeyChain deleteItemForQuery:keyQuery()] != errSecItemNotFound) dbg(@"Deleted key from key chain."); -#ifdef __IPHONE_OS_VERSION_MIN_REQUIRED +#if TARGET_OS_IPHONE [TestFlight passCheckpoint:MPTestFlightCheckpointMPUnstored]; #endif } @@ -86,14 +86,14 @@ static NSDictionary *keyHashQuery() { if (![keyHash isEqual:tryKeyHash]) { dbg(@"Key phrase hash mismatch. Expected: %@, answer: %@.", keyHash, tryKeyHash); -#ifdef __IPHONE_OS_VERSION_MIN_REQUIRED +#if TARGET_OS_IPHONE [TestFlight passCheckpoint:MPTestFlightCheckpointMPMismatch]; #endif return NO; } -#ifdef __IPHONE_OS_VERSION_MIN_REQUIRED - [TestFlight passCheckpoint:MPTestFlightCheckpointMPAsked]; +#if TARGET_OS_IPHONE + [TestFlight passCheckpoint:MPTestFlightCheckpointMPEntered]; #endif [self updateKey:tryKey]; @@ -117,7 +117,7 @@ static NSDictionary *keyHashQuery() { [PearlKeyChain addOrUpdateItemForQuery:keyHashQuery() withAttributes:[NSDictionary dictionaryWithObjectsAndKeys: self.keyHash, (__bridge id)kSecValueData, -#ifdef __IPHONE_OS_VERSION_MIN_REQUIRED +#if TARGET_OS_IPHONE kSecAttrAccessibleWhenUnlocked, (__bridge id)kSecAttrAccessible, #endif nil]]; @@ -126,14 +126,14 @@ static NSDictionary *keyHashQuery() { [PearlKeyChain addOrUpdateItemForQuery:keyQuery() withAttributes:[NSDictionary dictionaryWithObjectsAndKeys: key, (__bridge id)kSecValueData, -#ifdef __IPHONE_OS_VERSION_MIN_REQUIRED +#if TARGET_OS_IPHONE kSecAttrAccessibleWhenUnlocked, (__bridge id)kSecAttrAccessible, #endif nil]]; } -#ifdef __IPHONE_OS_VERSION_MIN_REQUIRED - [TestFlight passCheckpoint:[NSString stringWithFormat:MPTestFlightCheckpointSetKeyphraseLength, key.length]]; +#if TARGET_OS_IPHONE + [TestFlight passCheckpoint:MPTestFlightCheckpointSetKey]; #endif } } diff --git a/MasterPassword/MPAppDelegate_Shared.m b/MasterPassword/MPAppDelegate_Shared.m index b46aaf1d..90b0e9bd 100644 --- a/MasterPassword/MPAppDelegate_Shared.m +++ b/MasterPassword/MPAppDelegate_Shared.m @@ -12,7 +12,7 @@ + (MPAppDelegate *)get { -#ifdef __IPHONE_OS_VERSION_MIN_REQUIRED +#if TARGET_OS_IPHONE return (MPAppDelegate *)[UIApplication sharedApplication].delegate; #elif defined (__MAC_OS_X_VERSION_MIN_REQUIRED) return (MPAppDelegate *)[NSApplication sharedApplication].delegate; @@ -23,7 +23,7 @@ - (NSURL *)applicationFilesDirectory { -#if __IPHONE_OS_VERSION_MIN_REQUIRED +#if TARGET_OS_IPHONE return [[[NSFileManager defaultManager] URLsForDirectory:NSDocumentDirectory inDomains:NSUserDomainMask] lastObject]; #else NSURL *appSupportURL = [[[NSFileManager defaultManager] URLsForDirectory:NSApplicationSupportDirectory inDomains:NSUserDomainMask] lastObject]; diff --git a/MasterPassword/MPAppDelegate_Store.m b/MasterPassword/MPAppDelegate_Store.m index fe260a2e..90914e51 100644 --- a/MasterPassword/MPAppDelegate_Store.m +++ b/MasterPassword/MPAppDelegate_Store.m @@ -182,7 +182,10 @@ static NSDateFormatter *rfc3339DateFormatter = nil; } - (void)ubiquityStoreManager:(UbiquityStoreManager *)manager didEncounterError:(NSError *)error cause:(UbiquityStoreManagerErrorCause)cause context:(id)context { - + +#if TARGET_OS_IPHONE + [TestFlight passCheckpoint:str(@"MPTestFlightCheckpointMPErrorUbiquity_%d", cause)]; +#endif err(@"StoreManager: cause=%d, context=%@, error=%@", cause, context, error); switch (cause) { @@ -192,6 +195,9 @@ static NSDateFormatter *rfc3339DateFormatter = nil; case UbiquityStoreManagerErrorCauseClearStore: break; case UbiquityStoreManagerErrorCauseOpenLocalStore: { +#if TARGET_OS_IPHONE + [TestFlight passCheckpoint:MPTestFlightCheckpointLocalStoreIncompatible]; +#endif wrn(@"Local store could not be opened, resetting it."); manager.hardResetEnabled = YES; [manager hardResetLocalStorage]; @@ -200,10 +206,12 @@ static NSDateFormatter *rfc3339DateFormatter = nil; return; } case UbiquityStoreManagerErrorCauseOpenCloudStore: { +#if TARGET_OS_IPHONE + [TestFlight passCheckpoint:MPTestFlightCheckpointCloudStoreIncompatible]; +#endif wrn(@"iCloud store could not be opened, resetting it."); manager.hardResetEnabled = YES; [manager hardResetCloudStorage]; - [manager useiCloudStore:YES alertUser:NO]; break; } } @@ -347,6 +355,10 @@ static NSDateFormatter *rfc3339DateFormatter = nil; } [self saveContext]; +#if TARGET_OS_IPHONE + [TestFlight passCheckpoint:MPTestFlightCheckpointSitesImported]; +#endif + return MPImportResultSuccess; } @@ -403,6 +415,10 @@ static NSDateFormatter *rfc3339DateFormatter = nil; [rfc3339DateFormatter stringFromDate:[NSDate dateWithTimeIntervalSinceReferenceDate:lastUsed]], uses, type, [name cStringUsingEncoding:NSUTF8StringEncoding], content? content: @""]; } +#if TARGET_OS_IPHONE + [TestFlight passCheckpoint:MPTestFlightCheckpointSitesExported]; +#endif + return export; } diff --git a/MasterPassword/MPElementStoredEntity.m b/MasterPassword/MPElementStoredEntity.m index a2d6bfd0..19c06f4b 100644 --- a/MasterPassword/MPElementStoredEntity.m +++ b/MasterPassword/MPElementStoredEntity.m @@ -53,7 +53,7 @@ [PearlKeyChain addOrUpdateItemForQuery:[MPElementStoredEntity queryForDevicePrivateElementNamed:self.name] withAttributes:[NSDictionary dictionaryWithObjectsAndKeys: encryptedContent, (__bridge id)kSecValueData, -#ifdef __IPHONE_OS_VERSION_MIN_REQUIRED +#if TARGET_OS_IPHONE kSecAttrAccessibleWhenUnlockedThisDeviceOnly, (__bridge id)kSecAttrAccessible, #endif nil]]; diff --git a/MasterPassword/MPTypes.h b/MasterPassword/MPTypes.h index 57644056..d3a5b622 100644 --- a/MasterPassword/MPTypes.h +++ b/MasterPassword/MPTypes.h @@ -62,9 +62,14 @@ typedef enum { #define MPTestFlightCheckpointMPChanged @"MPTestFlightCheckpointMPChanged" #define MPTestFlightCheckpointMPUnstored @"MPTestFlightCheckpointMPUnstored" #define MPTestFlightCheckpointMPMismatch @"MPTestFlightCheckpointMPMismatch" -#define MPTestFlightCheckpointMPAsked @"MPTestFlightCheckpointMPAsked" -#define MPTestFlightCheckpointStoreIncompatible @"MPTestFlightCheckpointStoreIncompatible" -#define MPTestFlightCheckpointSetKeyphraseLength @"MPTestFlightCheckpointSetKeyphraseLength_%d" +#define MPTestFlightCheckpointMPEntered @"MPTestFlightCheckpointMPEntered" +#define MPTestFlightCheckpointLocalStoreIncompatible @"MPTestFlightCheckpointLocalStoreIncompatible" +#define MPTestFlightCheckpointCloudStoreIncompatible @"MPTestFlightCheckpointCloudStoreIncompatible" +#define MPTestFlightCheckpointSetKey @"MPTestFlightCheckpointSetKey" +#define MPTestFlightCheckpointCloudEnabled @"MPTestFlightCheckpointCloudEnabled" +#define MPTestFlightCheckpointCloudDisabled @"MPTestFlightCheckpointCloudDisabled" +#define MPTestFlightCheckpointSitesImported @"MPTestFlightCheckpointSitesImported" +#define MPTestFlightCheckpointSitesExported @"MPTestFlightCheckpointSitesExported" #define MPNotificationStoreUpdated @"MPNotificationStoreUpdated" #define MPNotificationKeySet @"MPNotificationKeySet" diff --git a/MasterPassword/iOS/MPAppDelegate.m b/MasterPassword/iOS/MPAppDelegate.m index 61aa326e..649bbc16 100644 --- a/MasterPassword/iOS/MPAppDelegate.m +++ b/MasterPassword/iOS/MPAppDelegate.m @@ -398,7 +398,28 @@ - (void)ubiquityStoreManager:(UbiquityStoreManager *)manager didSwitchToiCloud:(BOOL)didSwitch { - inf(@"didSwitchToiCloud: %d", didSwitch); +#if TARGET_OS_IPHONE + [TestFlight passCheckpoint:didSwitch? MPTestFlightCheckpointCloudEnabled: MPTestFlightCheckpointCloudDisabled]; +#endif + + inf(@"Using iCloud? %@", didSwitch? @"YES": @"NO"); + if (!didSwitch) { + [PearlAlert showAlertWithTitle:@"iCloud" + message: + @"iCloud is now disabled.\n" + @"It is highly recommended you enable iCloud. " + @"Doing so will let you easily access all your sites from any of your devices. " + @"It will also make it easier to recover from the loss of a device.\n\n" + @"iCloud only backs up your site names. If you use stored passwords, " + @"those are always encrypted with your master password. " + @"Apple cannot see any of your private information." + viewStyle:UIAlertViewStyleDefault tappedButtonBlock:^(UIAlertView *alert, NSInteger buttonIndex) { + if (buttonIndex == [alert cancelButtonIndex]) + return; + + [manager useiCloudStore:YES alertUser:YES]; + } cancelTitle:@"Leave Off" otherTitles:@"Enable iCloud", nil]; + } } #pragma mark - TestFlight