diff --git a/Signal.xcodeproj/project.pbxproj b/Signal.xcodeproj/project.pbxproj index 85f0fc047b..b784d5bc89 100644 --- a/Signal.xcodeproj/project.pbxproj +++ b/Signal.xcodeproj/project.pbxproj @@ -186,12 +186,10 @@ 34AC09EE211B39B100997B47 /* EditContactShareNameViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 34AC09D0211B39B000997B47 /* EditContactShareNameViewController.swift */; }; 34AC09EF211B39B100997B47 /* ViewControllerUtils.m in Sources */ = {isa = PBXBuildFile; fileRef = 34AC09D1211B39B000997B47 /* ViewControllerUtils.m */; }; 34AC09F0211B39B100997B47 /* AttachmentApprovalViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 34AC09D2211B39B000997B47 /* AttachmentApprovalViewController.swift */; }; - 34AC09F1211B39B100997B47 /* LockInteractionController.h in Headers */ = {isa = PBXBuildFile; fileRef = 34AC09D3211B39B000997B47 /* LockInteractionController.h */; settings = {ATTRIBUTES = (Public, ); }; }; 34AC09F2211B39B100997B47 /* OWSViewController.h in Headers */ = {isa = PBXBuildFile; fileRef = 34AC09D4211B39B000997B47 /* OWSViewController.h */; settings = {ATTRIBUTES = (Public, ); }; }; 34AC09F3211B39B100997B47 /* NewNonContactConversationViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 34AC09D5211B39B100997B47 /* NewNonContactConversationViewController.m */; }; 34AC09F4211B39B100997B47 /* SelectThreadViewController.h in Headers */ = {isa = PBXBuildFile; fileRef = 34AC09D6211B39B100997B47 /* SelectThreadViewController.h */; settings = {ATTRIBUTES = (Public, ); }; }; 34AC09F5211B39B100997B47 /* SharingThreadPickerViewController.h in Headers */ = {isa = PBXBuildFile; fileRef = 34AC09D7211B39B100997B47 /* SharingThreadPickerViewController.h */; settings = {ATTRIBUTES = (Public, ); }; }; - 34AC09F6211B39B100997B47 /* LockInteractionController.m in Sources */ = {isa = PBXBuildFile; fileRef = 34AC09D8211B39B100997B47 /* LockInteractionController.m */; }; 34AC09F7211B39B100997B47 /* MediaMessageView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 34AC09D9211B39B100997B47 /* MediaMessageView.swift */; }; 34AC09F8211B39B100997B47 /* CountryCodeViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 34AC09DA211B39B100997B47 /* CountryCodeViewController.m */; }; 34AC09F9211B39B100997B47 /* CountryCodeViewController.h in Headers */ = {isa = PBXBuildFile; fileRef = 34AC09DB211B39B100997B47 /* CountryCodeViewController.h */; settings = {ATTRIBUTES = (Public, ); }; }; @@ -854,12 +852,10 @@ 34AC09D0211B39B000997B47 /* EditContactShareNameViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = EditContactShareNameViewController.swift; sourceTree = ""; }; 34AC09D1211B39B000997B47 /* ViewControllerUtils.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ViewControllerUtils.m; sourceTree = ""; }; 34AC09D2211B39B000997B47 /* AttachmentApprovalViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AttachmentApprovalViewController.swift; sourceTree = ""; }; - 34AC09D3211B39B000997B47 /* LockInteractionController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = LockInteractionController.h; sourceTree = ""; }; 34AC09D4211B39B000997B47 /* OWSViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = OWSViewController.h; sourceTree = ""; }; 34AC09D5211B39B100997B47 /* NewNonContactConversationViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = NewNonContactConversationViewController.m; sourceTree = ""; }; 34AC09D6211B39B100997B47 /* SelectThreadViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SelectThreadViewController.h; sourceTree = ""; }; 34AC09D7211B39B100997B47 /* SharingThreadPickerViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SharingThreadPickerViewController.h; sourceTree = ""; }; - 34AC09D8211B39B100997B47 /* LockInteractionController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = LockInteractionController.m; sourceTree = ""; }; 34AC09D9211B39B100997B47 /* MediaMessageView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MediaMessageView.swift; sourceTree = ""; }; 34AC09DA211B39B100997B47 /* CountryCodeViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = CountryCodeViewController.m; sourceTree = ""; }; 34AC09DB211B39B100997B47 /* CountryCodeViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CountryCodeViewController.h; sourceTree = ""; }; @@ -2061,8 +2057,6 @@ 34AC09DB211B39B100997B47 /* CountryCodeViewController.h */, 34AC09DA211B39B100997B47 /* CountryCodeViewController.m */, 34AC09D0211B39B000997B47 /* EditContactShareNameViewController.swift */, - 34AC09D3211B39B000997B47 /* LockInteractionController.h */, - 34AC09D8211B39B100997B47 /* LockInteractionController.m */, 34AC09D9211B39B100997B47 /* MediaMessageView.swift */, 34AC09C9211B39AF00997B47 /* MessageApprovalViewController.swift */, 34AC09CC211B39B000997B47 /* ModalActivityIndicatorViewController.swift */, @@ -2630,7 +2624,6 @@ 346129951FD1E30000532771 /* OWSDatabaseMigration.h in Headers */, 34B6D27420F664C900765BE2 /* OWSUnreadIndicator.h in Headers */, 34AC09E4211B39B100997B47 /* ScreenLockViewController.h in Headers */, - 34AC09F1211B39B100997B47 /* LockInteractionController.h in Headers */, 346129B41FD1F7E800532771 /* OWSProfileManager.h in Headers */, 342950892124CB0A0000B063 /* OWSSearchBar.h in Headers */, 346941A1215D2EE400B5BFAD /* Theme.h in Headers */, @@ -3345,7 +3338,6 @@ 34AC0A1F211B39EA00997B47 /* AvatarImageView.swift in Sources */, 3466087220E550F400AFFE73 /* ConversationStyle.swift in Sources */, 3478506B1FD9B78A007B8332 /* NoopCallMessageHandler.swift in Sources */, - 34AC09F6211B39B100997B47 /* LockInteractionController.m in Sources */, 346129AD1FD1F34E00532771 /* ImageCache.swift in Sources */, 452C7CA72037628B003D51A5 /* Weak.swift in Sources */, 34D5872F208E2C4200D2255A /* OWS109OutgoingMessageState.m in Sources */, diff --git a/Signal/test/mocks/MockEnvironment.h b/Signal/test/mocks/MockEnvironment.h index 7fb59f8012..5406613f7f 100644 --- a/Signal/test/mocks/MockEnvironment.h +++ b/Signal/test/mocks/MockEnvironment.h @@ -1,5 +1,5 @@ // -// Copyright (c) 2018 Open Whisper Systems. All rights reserved. +// Copyright (c) 2019 Open Whisper Systems. All rights reserved. // #import "Environment.h" @@ -15,7 +15,6 @@ NS_ASSUME_NONNULL_BEGIN @property (nonatomic) OWSContactsManager *contactsManager; @property (nonatomic) OWSPreferences *preferences; @property (nonatomic) OWSSounds *sounds; -@property (nonatomic) LockInteractionController *lockInteractionController; @property (nonatomic) OWSWindowManager *windowManager; @end diff --git a/Signal/test/mocks/MockEnvironment.m b/Signal/test/mocks/MockEnvironment.m index ac1bf215a7..20f27cf2b7 100644 --- a/Signal/test/mocks/MockEnvironment.m +++ b/Signal/test/mocks/MockEnvironment.m @@ -1,11 +1,10 @@ // -// Copyright (c) 2018 Open Whisper Systems. All rights reserved. +// Copyright (c) 2019 Open Whisper Systems. All rights reserved. // #import "MockEnvironment.h" #import "OWSBackup.h" #import "OWSWindowManager.h" -#import #import #import #import @@ -28,14 +27,12 @@ NS_ASSUME_NONNULL_BEGIN // TODO: We should probably mock this out. OWSAudioSession *audioSession = [OWSAudioSession new]; - LockInteractionController *lockInteractionController = [[LockInteractionController alloc] initDefault]; OWSPreferences *preferences = [OWSPreferences new]; OWSSounds *sounds = [[OWSSounds alloc] initWithPrimaryStorage:primaryStorage]; id proximityMonitoringManager = [OWSProximityMonitoringManagerImpl new]; OWSWindowManager *windowManager = [[OWSWindowManager alloc] initDefault]; self = [super initWithAudioSession:audioSession - lockInteractionController:lockInteractionController preferences:preferences proximityMonitoringManager:proximityMonitoringManager sounds:sounds diff --git a/SignalMessaging/SignalMessaging.h b/SignalMessaging/SignalMessaging.h index 9be5e6dc65..bd2a2b93c0 100644 --- a/SignalMessaging/SignalMessaging.h +++ b/SignalMessaging/SignalMessaging.h @@ -1,5 +1,5 @@ // -// Copyright (c) 2018 Open Whisper Systems. All rights reserved. +// Copyright (c) 2019 Open Whisper Systems. All rights reserved. // #import @@ -20,7 +20,6 @@ FOUNDATION_EXPORT const unsigned char SignalMessagingVersionString[]; #import #import #import -#import #import #import #import diff --git a/SignalMessaging/environment/AppSetup.m b/SignalMessaging/environment/AppSetup.m index 023f5bc6bf..a9ebe1f525 100644 --- a/SignalMessaging/environment/AppSetup.m +++ b/SignalMessaging/environment/AppSetup.m @@ -1,5 +1,5 @@ // -// Copyright (c) 2018 Open Whisper Systems. All rights reserved. +// Copyright (c) 2019 Open Whisper Systems. All rights reserved. // #import "AppSetup.h" @@ -92,11 +92,9 @@ NS_ASSUME_NONNULL_BEGIN OWSAudioSession *audioSession = [OWSAudioSession new]; OWSSounds *sounds = [[OWSSounds alloc] initWithPrimaryStorage:primaryStorage]; id proximityMonitoringManager = [OWSProximityMonitoringManagerImpl new]; - LockInteractionController *lockInteractionController = [[LockInteractionController alloc] initDefault]; OWSWindowManager *windowManager = [[OWSWindowManager alloc] initDefault]; [Environment setShared:[[Environment alloc] initWithAudioSession:audioSession - lockInteractionController:lockInteractionController preferences:preferences proximityMonitoringManager:proximityMonitoringManager sounds:sounds diff --git a/SignalMessaging/environment/Environment.h b/SignalMessaging/environment/Environment.h index 2ad9aa44a7..b1894bd26d 100644 --- a/SignalMessaging/environment/Environment.h +++ b/SignalMessaging/environment/Environment.h @@ -1,10 +1,9 @@ // -// Copyright (c) 2018 Open Whisper Systems. All rights reserved. +// Copyright (c) 2019 Open Whisper Systems. All rights reserved. // #import -@class LockInteractionController; @class OWSAudioSession; @class OWSContactsManager; @class OWSPreferences; @@ -26,7 +25,6 @@ - (instancetype)init NS_UNAVAILABLE; - (instancetype)initWithAudioSession:(OWSAudioSession *)audioSession - lockInteractionController:(LockInteractionController *)lockInteractionController preferences:(OWSPreferences *)preferences proximityMonitoringManager:(id)proximityMonitoringManager sounds:(OWSSounds *)sounds @@ -34,7 +32,6 @@ @property (nonatomic, readonly) OWSAudioSession *audioSession; @property (nonatomic, readonly) OWSContactsManager *contactsManager; -@property (nonatomic, readonly) LockInteractionController *lockInteractionController; @property (nonatomic, readonly) id proximityMonitoringManager; @property (nonatomic, readonly) OWSPreferences *preferences; @property (nonatomic, readonly) OWSSounds *sounds; diff --git a/SignalMessaging/environment/Environment.m b/SignalMessaging/environment/Environment.m index d6bef08323..dd4b6f12a3 100644 --- a/SignalMessaging/environment/Environment.m +++ b/SignalMessaging/environment/Environment.m @@ -1,5 +1,5 @@ // -// Copyright (c) 2018 Open Whisper Systems. All rights reserved. +// Copyright (c) 2019 Open Whisper Systems. All rights reserved. // #import "Environment.h" @@ -13,7 +13,6 @@ static Environment *sharedEnvironment = nil; @property (nonatomic) OWSAudioSession *audioSession; @property (nonatomic) OWSContactsManager *contactsManager; -@property (nonatomic) LockInteractionController *lockInteractionController; @property (nonatomic) OWSPreferences *preferences; @property (nonatomic) id proximityMonitoringManager; @property (nonatomic) OWSSounds *sounds; @@ -50,7 +49,6 @@ static Environment *sharedEnvironment = nil; } - (instancetype)initWithAudioSession:(OWSAudioSession *)audioSession - lockInteractionController:(LockInteractionController *)lockInteractionController preferences:(OWSPreferences *)preferences proximityMonitoringManager:(id)proximityMonitoringManager sounds:(OWSSounds *)sounds @@ -62,14 +60,12 @@ static Environment *sharedEnvironment = nil; } OWSAssertDebug(audioSession); - OWSAssertDebug(lockInteractionController); OWSAssertDebug(preferences); OWSAssertDebug(proximityMonitoringManager); OWSAssertDebug(sounds); OWSAssertDebug(windowManager); _audioSession = audioSession; - _lockInteractionController = lockInteractionController; _preferences = preferences; _proximityMonitoringManager = proximityMonitoringManager; _sounds = sounds; diff --git a/SignalMessaging/environment/VersionMigrations.m b/SignalMessaging/environment/VersionMigrations.m index 6743f92f9a..84b0811755 100644 --- a/SignalMessaging/environment/VersionMigrations.m +++ b/SignalMessaging/environment/VersionMigrations.m @@ -1,10 +1,9 @@ // -// Copyright (c) 2018 Open Whisper Systems. All rights reserved. +// Copyright (c) 2019 Open Whisper Systems. All rights reserved. // #import "VersionMigrations.h" #import "Environment.h" -#import "LockInteractionController.h" #import "OWSDatabaseMigrationRunner.h" #import "SignalKeyingStorage.h" #import @@ -86,7 +85,6 @@ NS_ASSUME_NONNULL_BEGIN if ([self isVersion:previousVersion atLeast:@"2.0.0" andLessThan:@"2.1.70"] && [self.tsAccountManager isRegistered]) { [self clearVideoCache]; - [self blockingAttributesUpdate]; } if ([self isVersion:previousVersion atLeast:@"2.0.0" andLessThan:@"2.3.0"] && [self.tsAccountManager isRegistered]) { @@ -135,49 +133,6 @@ NS_ASSUME_NONNULL_BEGIN } } -#pragma mark - Update Account Attributes - -+ (void)blockingAttributesUpdate -{ - LIControllerBlockingOperation blockingOperation = ^BOOL(void) { - [[NSUserDefaults appUserDefaults] setObject:@YES forKey:NEEDS_TO_REGISTER_ATTRIBUTES]; - - __block dispatch_semaphore_t sema = dispatch_semaphore_create(0); - - __block BOOL success; - - TSRequest *request = [OWSRequestFactory updateAttributesRequest]; - [[TSNetworkManager sharedManager] makeRequest:request - success:^(NSURLSessionDataTask *task, id responseObject) { - success = YES; - dispatch_semaphore_signal(sema); - } - failure:^(NSURLSessionDataTask *task, NSError *error) { - if (!IsNSErrorNetworkFailure(error)) { - OWSProdError([OWSAnalyticsEvents errorUpdateAttributesRequestFailed]); - } - success = NO; - OWSLogError(@"Updating attributess failed with error: %@", error.description); - dispatch_semaphore_signal(sema); - }]; - - - dispatch_semaphore_wait(sema, DISPATCH_TIME_FOREVER); - - return success; - }; - - LIControllerRetryBlock retryBlock = [LockInteractionController defaultNetworkRetry]; - - [LockInteractionController performBlock:blockingOperation - completionBlock:^{ - [[NSUserDefaults appUserDefaults] removeObjectForKey:NEEDS_TO_REGISTER_ATTRIBUTES]; - OWSLogWarn(@"Successfully updated attributes."); - } - retryBlock:retryBlock - usesNetwork:YES]; -} - #pragma mark Upgrading to 2.3.0 // We removed bloom filter contact discovery. Clean up any local bloom filter data. diff --git a/SignalMessaging/viewControllers/LockInteractionController.h b/SignalMessaging/viewControllers/LockInteractionController.h deleted file mode 100644 index 7e47377d8c..0000000000 --- a/SignalMessaging/viewControllers/LockInteractionController.h +++ /dev/null @@ -1,22 +0,0 @@ -// -// Copyright (c) 2018 Open Whisper Systems. All rights reserved. -// - -@interface LockInteractionController : NSObject - -- (instancetype)init NS_UNAVAILABLE; -- (instancetype)initDefault NS_DESIGNATED_INITIALIZER; - -typedef void (^LIControllerCompletionBlock)(void); -typedef BOOL (^LIControllerBlockingOperation)(void); -typedef void (^LIControllerRetryBlock)( - LIControllerBlockingOperation operationBlock, LIControllerCompletionBlock completionBlock); - -+ (void)performBlock:(LIControllerBlockingOperation)blockingOperation - completionBlock:(LIControllerCompletionBlock)completionBlock - retryBlock:(LIControllerRetryBlock)retryBlock - usesNetwork:(BOOL)networkFlag; - -+ (LIControllerRetryBlock)defaultNetworkRetry; - -@end diff --git a/SignalMessaging/viewControllers/LockInteractionController.m b/SignalMessaging/viewControllers/LockInteractionController.m deleted file mode 100644 index 302a069720..0000000000 --- a/SignalMessaging/viewControllers/LockInteractionController.m +++ /dev/null @@ -1,108 +0,0 @@ -// -// Copyright (c) 2018 Open Whisper Systems. All rights reserved. -// - -#import "LockInteractionController.h" -#import "Environment.h" -#import - -@interface LockInteractionController () - -@property (nonatomic) UIAlertController *alertController; - -@end - -#pragma mark - - -@implementation LockInteractionController - -+ (instancetype)sharedController -{ - OWSAssertDebug(Environment.shared.lockInteractionController); - - return Environment.shared.lockInteractionController; -} - -- (instancetype)initDefault { - self = [super init]; - - if (!self) { - return self; - } - - OWSAssertIsOnMainThread(); - OWSSingletonAssert(); - - return self; -} - -+ (void)performBlock:(LIControllerBlockingOperation)blockingOperation - completionBlock:(LIControllerCompletionBlock)completionBlock - retryBlock:(LIControllerRetryBlock)retryBlock - usesNetwork:(BOOL)networkFlag - -{ - if (networkFlag) { - [CurrentAppContext() setNetworkActivityIndicatorVisible:networkFlag]; - } - - LockInteractionController *sharedController = [LockInteractionController sharedController]; - sharedController.alertController = - [UIAlertController alertControllerWithTitle:NSLocalizedString(@"Upgrading Signal ...", nil) - message:nil - preferredStyle:UIAlertControllerStyleAlert]; - - [CurrentAppContext().frontmostViewController presentViewController:sharedController.alertController - animated:YES - completion:nil]; - - dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{ - BOOL success = blockingOperation(); - - dispatch_async(dispatch_get_main_queue(), ^{ - [sharedController.alertController - dismissViewControllerAnimated:YES - completion:^{ - if (networkFlag) { - [CurrentAppContext() setNetworkActivityIndicatorVisible:NO]; - } - - if (!success) { - retryBlock(blockingOperation, completionBlock); - } else { - completionBlock(); - } - }]; - }); - - }); -} - - -+ (LIControllerRetryBlock)defaultNetworkRetry -{ - LIControllerRetryBlock retryBlock = ^void( - LIControllerBlockingOperation blockingOperation, LIControllerCompletionBlock completionBlock) { - UIAlertController *retryController = - [UIAlertController alertControllerWithTitle:@"Upgrading Signal failed" - message:@"An network error occured while upgrading, please check " - @"your connectivity and try again." - preferredStyle:UIAlertControllerStyleAlert]; - - [retryController - addAction:[UIAlertAction actionWithTitle:NSLocalizedString(@"REGISTER_FAILED_TRY_AGAIN", nil) - style:UIAlertActionStyleDefault - handler:^(UIAlertAction *action) { - [self performBlock:blockingOperation - completionBlock:completionBlock - retryBlock:[LockInteractionController defaultNetworkRetry] - usesNetwork:YES]; - }]]; - - [CurrentAppContext().frontmostViewController presentViewController:retryController animated:YES completion:nil]; - }; - - return retryBlock; -} - -@end