diff --git a/Signal/src/AppDelegate.m b/Signal/src/AppDelegate.m index dd5692ec1..d55c4b653 100644 --- a/Signal/src/AppDelegate.m +++ b/Signal/src/AppDelegate.m @@ -228,19 +228,17 @@ static NSString* const kCallSegue = @"2.0_6.0_Call_Segue"; } -(void) applicationDidBecomeActive:(UIApplication *)application { - [TSSocketManager becomeActive]; - [AppAudioManager.sharedInstance awake]; - + if ([TSAccountManager isRegistered]) { + [TSSocketManager becomeActive]; + [AppAudioManager.sharedInstance awake]; + [PushManager.sharedManager verifyPushPermissions]; + [AppAudioManager.sharedInstance requestRequiredPermissionsIfNeeded]; + } // Hacky way to clear notification center after processed push [UIApplication.sharedApplication setApplicationIconBadgeNumber:1]; [UIApplication.sharedApplication setApplicationIconBadgeNumber:0]; [self removeScreenProtection]; - - if (Environment.isRedPhoneRegistered) { - [PushManager.sharedManager verifyPushPermissions]; - [AppAudioManager.sharedInstance requestRequiredPermissionsIfNeeded]; - } } - (void)applicationWillResignActive:(UIApplication *)application{ diff --git a/Signal/src/environment/DebugLogger.h b/Signal/src/environment/DebugLogger.h index 8cb6caf07..e38a055d0 100644 --- a/Signal/src/environment/DebugLogger.h +++ b/Signal/src/environment/DebugLogger.h @@ -8,6 +8,8 @@ #import +#import + @interface DebugLogger : NSObject MacrosSingletonInterface @@ -20,4 +22,6 @@ MacrosSingletonInterface - (void)wipeLogs; +@property (nonatomic) DDFileLogger *fileLogger; + @end diff --git a/Signal/src/environment/DebugLogger.m b/Signal/src/environment/DebugLogger.m index ed305187a..9ccd78bbb 100644 --- a/Signal/src/environment/DebugLogger.m +++ b/Signal/src/environment/DebugLogger.m @@ -11,12 +11,9 @@ #pragma mark Logging - Production logging wants us to write some logs to a file in case we need it for debugging. #import -#import @interface DebugLogger () -@property (nonatomic) DDFileLogger *fileLogger; - @end @implementation DebugLogger diff --git a/Signal/src/textsecure/Messages/Attachements/TSAttachmentStream.h b/Signal/src/textsecure/Messages/Attachements/TSAttachmentStream.h index 6c31da75f..baa50a0c6 100644 --- a/Signal/src/textsecure/Messages/Attachements/TSAttachmentStream.h +++ b/Signal/src/textsecure/Messages/Attachements/TSAttachmentStream.h @@ -22,6 +22,8 @@ - (BOOL)isImage; - (BOOL)isVideo; -(NSURL*)mediaURL; + + (void)deleteAttachments; ++ (NSString*)attachmentsFolder; @end diff --git a/Signal/src/textsecure/Storage/TSStorageManager.m b/Signal/src/textsecure/Storage/TSStorageManager.m index 8de34be57..099315965 100644 --- a/Signal/src/textsecure/Storage/TSStorageManager.m +++ b/Signal/src/textsecure/Storage/TSStorageManager.m @@ -11,6 +11,7 @@ #import #import #import "CryptoTools.h" +#import "DebugLogger.h" #import "NSData+Base64.h" #import "TSThread.h" @@ -43,7 +44,7 @@ static NSString * keychainDBPassAccount = @"TSDatabasePass"; static dispatch_once_t onceToken; dispatch_once(&onceToken, ^{ sharedMyManager = [[self alloc] init]; - [sharedMyManager protectDatabaseFile]; + [sharedMyManager protectSignalFiles]; }); return sharedMyManager; } @@ -79,32 +80,25 @@ static NSString * keychainDBPassAccount = @"TSDatabasePass"; [self.database registerExtension:[[YapDatabaseRelationship alloc] init] withName:@"TSRelationships"]; } -/** - * Protects the preference and logs file with disk encryption and prevents them to leak to iCloud. - */ +- (void)protectSignalFiles{ + [self protectFolderAtPath:[TSAttachmentStream attachmentsFolder]]; + [self protectFolderAtPath:[self dbPath]]; + [self protectFolderAtPath:[NSHomeDirectory() stringByAppendingString:@"/Library/Caches/Logs/"]]; +} -- (void)protectDatabaseFile{ - - NSDictionary *attrs = @{NSFileProtectionKey: NSFileProtectionCompleteUntilFirstUserAuthentication}; +- (void)protectFolderAtPath:(NSString*)path { NSError *error; + NSDictionary *attrs = @{NSFileProtectionKey: NSFileProtectionCompleteUntilFirstUserAuthentication, + NSURLIsExcludedFromBackupKey:@YES}; - [NSFileManager.defaultManager setAttributes:attrs ofItemAtPath:[self dbPath] error:&error]; - [[NSURL fileURLWithPath:[self dbPath]] setResourceValue:@YES - forKey:NSURLIsExcludedFromBackupKey - error:&error]; + BOOL success = [NSFileManager.defaultManager setAttributes:attrs ofItemAtPath:path error:&error]; - if (error) { - DDLogError(@"Error while removing log files from backup: %@", error.description); - UIAlertView *alert = [[UIAlertView alloc]initWithTitle:NSLocalizedString(@"WARNING", @"") - message:NSLocalizedString(@"DISABLING_BACKUP_FAILED", @"") - delegate:nil - cancelButtonTitle:NSLocalizedString(@"OK", @"") - otherButtonTitles:nil]; - [alert show]; + if (error || !success) { + DDLogError(@"Error while removing files from backup: %@", error.description); + SignalAlertView(NSLocalizedString(@"WARNING", @""), @"DISABLING_BACKUP_FAILED"); return; } - } - (YapDatabaseConnection *)newDatabaseConnection {