Migrate environment to SignalMessaging.

This commit is contained in:
Matthew Chen 2017-12-04 10:35:47 -05:00
parent a16058e477
commit b4e8df79da
72 changed files with 318 additions and 244 deletions

View File

@ -27,7 +27,7 @@
34480B491FD0A60200BC14EF /* OWSMath.h in Headers */ = {isa = PBXBuildFile; fileRef = 34480B481FD0A60200BC14EF /* OWSMath.h */; settings = {ATTRIBUTES = (Public, ); }; }; 34480B491FD0A60200BC14EF /* OWSMath.h in Headers */ = {isa = PBXBuildFile; fileRef = 34480B481FD0A60200BC14EF /* OWSMath.h */; settings = {ATTRIBUTES = (Public, ); }; };
34480B521FD0A7A400BC14EF /* OWSLogger.h in Headers */ = {isa = PBXBuildFile; fileRef = 34480B4A1FD0A7A200BC14EF /* OWSLogger.h */; settings = {ATTRIBUTES = (Public, ); }; }; 34480B521FD0A7A400BC14EF /* OWSLogger.h in Headers */ = {isa = PBXBuildFile; fileRef = 34480B4A1FD0A7A200BC14EF /* OWSLogger.h */; settings = {ATTRIBUTES = (Public, ); }; };
34480B531FD0A7A400BC14EF /* OWSLogger.m in Sources */ = {isa = PBXBuildFile; fileRef = 34480B4B1FD0A7A300BC14EF /* OWSLogger.m */; }; 34480B531FD0A7A400BC14EF /* OWSLogger.m in Sources */ = {isa = PBXBuildFile; fileRef = 34480B4B1FD0A7A300BC14EF /* OWSLogger.m */; };
34480B551FD0A7A400BC14EF /* DebugLogger.h in Headers */ = {isa = PBXBuildFile; fileRef = 34480B4D1FD0A7A300BC14EF /* DebugLogger.h */; }; 34480B551FD0A7A400BC14EF /* DebugLogger.h in Headers */ = {isa = PBXBuildFile; fileRef = 34480B4D1FD0A7A300BC14EF /* DebugLogger.h */; settings = {ATTRIBUTES = (Public, ); }; };
34480B561FD0A7A400BC14EF /* DebugLogger.m in Sources */ = {isa = PBXBuildFile; fileRef = 34480B4E1FD0A7A300BC14EF /* DebugLogger.m */; }; 34480B561FD0A7A400BC14EF /* DebugLogger.m in Sources */ = {isa = PBXBuildFile; fileRef = 34480B4E1FD0A7A300BC14EF /* DebugLogger.m */; };
34480B571FD0A7A400BC14EF /* OWSScrubbingLogFormatter.h in Headers */ = {isa = PBXBuildFile; fileRef = 34480B4F1FD0A7A300BC14EF /* OWSScrubbingLogFormatter.h */; }; 34480B571FD0A7A400BC14EF /* OWSScrubbingLogFormatter.h in Headers */ = {isa = PBXBuildFile; fileRef = 34480B4F1FD0A7A300BC14EF /* OWSScrubbingLogFormatter.h */; };
34480B591FD0A7A400BC14EF /* OWSScrubbingLogFormatter.m in Sources */ = {isa = PBXBuildFile; fileRef = 34480B511FD0A7A400BC14EF /* OWSScrubbingLogFormatter.m */; }; 34480B591FD0A7A400BC14EF /* OWSScrubbingLogFormatter.m in Sources */ = {isa = PBXBuildFile; fileRef = 34480B511FD0A7A400BC14EF /* OWSScrubbingLogFormatter.m */; };
@ -48,7 +48,7 @@
3461293E1FD1D72B00532771 /* ExperienceUpgradeFinder.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3461293D1FD1D72B00532771 /* ExperienceUpgradeFinder.swift */; }; 3461293E1FD1D72B00532771 /* ExperienceUpgradeFinder.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3461293D1FD1D72B00532771 /* ExperienceUpgradeFinder.swift */; };
3461295A1FD1D74C00532771 /* Environment.h in Headers */ = {isa = PBXBuildFile; fileRef = 346129401FD1D74B00532771 /* Environment.h */; settings = {ATTRIBUTES = (Public, ); }; }; 3461295A1FD1D74C00532771 /* Environment.h in Headers */ = {isa = PBXBuildFile; fileRef = 346129401FD1D74B00532771 /* Environment.h */; settings = {ATTRIBUTES = (Public, ); }; };
3461295B1FD1D74C00532771 /* Environment.m in Sources */ = {isa = PBXBuildFile; fileRef = 346129411FD1D74B00532771 /* Environment.m */; }; 3461295B1FD1D74C00532771 /* Environment.m in Sources */ = {isa = PBXBuildFile; fileRef = 346129411FD1D74B00532771 /* Environment.m */; };
3461296F1FD1D74C00532771 /* Release.h in Headers */ = {isa = PBXBuildFile; fileRef = 346129561FD1D74B00532771 /* Release.h */; }; 3461296F1FD1D74C00532771 /* Release.h in Headers */ = {isa = PBXBuildFile; fileRef = 346129561FD1D74B00532771 /* Release.h */; settings = {ATTRIBUTES = (Public, ); }; };
346129701FD1D74C00532771 /* Release.m in Sources */ = {isa = PBXBuildFile; fileRef = 346129571FD1D74B00532771 /* Release.m */; }; 346129701FD1D74C00532771 /* Release.m in Sources */ = {isa = PBXBuildFile; fileRef = 346129571FD1D74B00532771 /* Release.m */; };
346129711FD1D74C00532771 /* SignalKeyingStorage.h in Headers */ = {isa = PBXBuildFile; fileRef = 346129581FD1D74B00532771 /* SignalKeyingStorage.h */; }; 346129711FD1D74C00532771 /* SignalKeyingStorage.h in Headers */ = {isa = PBXBuildFile; fileRef = 346129581FD1D74B00532771 /* SignalKeyingStorage.h */; };
346129721FD1D74C00532771 /* SignalKeyingStorage.m in Sources */ = {isa = PBXBuildFile; fileRef = 346129591FD1D74B00532771 /* SignalKeyingStorage.m */; }; 346129721FD1D74C00532771 /* SignalKeyingStorage.m in Sources */ = {isa = PBXBuildFile; fileRef = 346129591FD1D74B00532771 /* SignalKeyingStorage.m */; };
@ -71,7 +71,7 @@
346129A01FD1EFE200532771 /* CryptoTools.m in Sources */ = {isa = PBXBuildFile; fileRef = 3461299E1FD1EFE200532771 /* CryptoTools.m */; }; 346129A01FD1EFE200532771 /* CryptoTools.m in Sources */ = {isa = PBXBuildFile; fileRef = 3461299E1FD1EFE200532771 /* CryptoTools.m */; };
346129A51FD1F09100532771 /* OWSContactsManager.h in Headers */ = {isa = PBXBuildFile; fileRef = 346129A21FD1F09100532771 /* OWSContactsManager.h */; }; 346129A51FD1F09100532771 /* OWSContactsManager.h in Headers */ = {isa = PBXBuildFile; fileRef = 346129A21FD1F09100532771 /* OWSContactsManager.h */; };
346129A61FD1F09100532771 /* OWSContactsManager.m in Sources */ = {isa = PBXBuildFile; fileRef = 346129A31FD1F09100532771 /* OWSContactsManager.m */; }; 346129A61FD1F09100532771 /* OWSContactsManager.m in Sources */ = {isa = PBXBuildFile; fileRef = 346129A31FD1F09100532771 /* OWSContactsManager.m */; };
346129A91FD1F0E000532771 /* OWSFormat.h in Headers */ = {isa = PBXBuildFile; fileRef = 346129A81FD1F0DF00532771 /* OWSFormat.h */; }; 346129A91FD1F0E000532771 /* OWSFormat.h in Headers */ = {isa = PBXBuildFile; fileRef = 346129A81FD1F0DF00532771 /* OWSFormat.h */; settings = {ATTRIBUTES = (Public, ); }; };
346129AB1FD1F0EE00532771 /* OWSFormat.m in Sources */ = {isa = PBXBuildFile; fileRef = 346129AA1FD1F0EE00532771 /* OWSFormat.m */; }; 346129AB1FD1F0EE00532771 /* OWSFormat.m in Sources */ = {isa = PBXBuildFile; fileRef = 346129AA1FD1F0EE00532771 /* OWSFormat.m */; };
346129AD1FD1F34E00532771 /* ImageCache.swift in Sources */ = {isa = PBXBuildFile; fileRef = 346129AC1FD1F34E00532771 /* ImageCache.swift */; }; 346129AD1FD1F34E00532771 /* ImageCache.swift in Sources */ = {isa = PBXBuildFile; fileRef = 346129AC1FD1F34E00532771 /* ImageCache.swift */; };
346129AF1FD1F5D900532771 /* SystemContactsFetcher.swift in Sources */ = {isa = PBXBuildFile; fileRef = 346129AE1FD1F5D900532771 /* SystemContactsFetcher.swift */; }; 346129AF1FD1F5D900532771 /* SystemContactsFetcher.swift in Sources */ = {isa = PBXBuildFile; fileRef = 346129AE1FD1F5D900532771 /* SystemContactsFetcher.swift */; };
@ -144,8 +144,6 @@
34CCAF381F0C0599004084F4 /* AppUpdateNag.m in Sources */ = {isa = PBXBuildFile; fileRef = 34CCAF371F0C0599004084F4 /* AppUpdateNag.m */; }; 34CCAF381F0C0599004084F4 /* AppUpdateNag.m in Sources */ = {isa = PBXBuildFile; fileRef = 34CCAF371F0C0599004084F4 /* AppUpdateNag.m */; };
34CCAF3B1F0C2748004084F4 /* OWSAddToContactViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 34CCAF3A1F0C2748004084F4 /* OWSAddToContactViewController.m */; }; 34CCAF3B1F0C2748004084F4 /* OWSAddToContactViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 34CCAF3A1F0C2748004084F4 /* OWSAddToContactViewController.m */; };
34CE88E71F2FB9A10098030F /* ProfileViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 34CE88E61F2FB9A10098030F /* ProfileViewController.m */; }; 34CE88E71F2FB9A10098030F /* ProfileViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 34CE88E61F2FB9A10098030F /* ProfileViewController.m */; };
34CE88EC1F3237260098030F /* OWSProfileManager.m in Sources */ = {isa = PBXBuildFile; fileRef = 34CE88EA1F3237260098030F /* OWSProfileManager.m */; };
34CE88ED1F3237260098030F /* ProfileFetcherJob.swift in Sources */ = {isa = PBXBuildFile; fileRef = 34CE88EB1F3237260098030F /* ProfileFetcherJob.swift */; };
34D1F0501F7D45A60066283D /* GifPickerCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 34D1F04F1F7D45A60066283D /* GifPickerCell.swift */; }; 34D1F0501F7D45A60066283D /* GifPickerCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 34D1F04F1F7D45A60066283D /* GifPickerCell.swift */; };
34D1F0521F7E8EA30066283D /* GiphyDownloader.swift in Sources */ = {isa = PBXBuildFile; fileRef = 34D1F0511F7E8EA30066283D /* GiphyDownloader.swift */; }; 34D1F0521F7E8EA30066283D /* GiphyDownloader.swift in Sources */ = {isa = PBXBuildFile; fileRef = 34D1F0511F7E8EA30066283D /* GiphyDownloader.swift */; };
34D1F0821F8678AA0066283D /* ConversationHeaderView.m in Sources */ = {isa = PBXBuildFile; fileRef = 34D1F0661F8678AA0066283D /* ConversationHeaderView.m */; }; 34D1F0821F8678AA0066283D /* ConversationHeaderView.m in Sources */ = {isa = PBXBuildFile; fileRef = 34D1F0661F8678AA0066283D /* ConversationHeaderView.m */; };
@ -850,7 +848,6 @@
45847E861E4283C30080EAB3 /* Intents.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Intents.framework; path = System/Library/Frameworks/Intents.framework; sourceTree = SDKROOT; }; 45847E861E4283C30080EAB3 /* Intents.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Intents.framework; path = System/Library/Frameworks/Intents.framework; sourceTree = SDKROOT; };
45855F351D9498A40084F340 /* OWSContactAvatarBuilder.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = OWSContactAvatarBuilder.h; sourceTree = "<group>"; }; 45855F351D9498A40084F340 /* OWSContactAvatarBuilder.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = OWSContactAvatarBuilder.h; sourceTree = "<group>"; };
45855F361D9498A40084F340 /* OWSContactAvatarBuilder.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = OWSContactAvatarBuilder.m; sourceTree = "<group>"; }; 45855F361D9498A40084F340 /* OWSContactAvatarBuilder.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = OWSContactAvatarBuilder.m; sourceTree = "<group>"; };
4585C4651ED5DF7A00896AEA /* ProfileFetcherJob.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ProfileFetcherJob.swift; sourceTree = "<group>"; };
4585C4671ED8F8D200896AEA /* SafetyNumberConfirmationAlert.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SafetyNumberConfirmationAlert.swift; sourceTree = "<group>"; }; 4585C4671ED8F8D200896AEA /* SafetyNumberConfirmationAlert.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SafetyNumberConfirmationAlert.swift; sourceTree = "<group>"; };
4589670F1DC117CC00E9DD21 /* SignalTests-Bridging-Header.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "SignalTests-Bridging-Header.h"; sourceTree = "<group>"; }; 4589670F1DC117CC00E9DD21 /* SignalTests-Bridging-Header.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "SignalTests-Bridging-Header.h"; sourceTree = "<group>"; };
458967101DC117CC00E9DD21 /* AccountManagerTest.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = AccountManagerTest.swift; path = Models/AccountManagerTest.swift; sourceTree = "<group>"; }; 458967101DC117CC00E9DD21 /* AccountManagerTest.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = AccountManagerTest.swift; path = Models/AccountManagerTest.swift; sourceTree = "<group>"; };
@ -1641,7 +1638,6 @@
451DE9FC1DC1A28200810E42 /* SyncPushTokensJob.swift */, 451DE9FC1DC1A28200810E42 /* SyncPushTokensJob.swift */,
45D231761DC7E8F10034FA89 /* SessionResetJob.swift */, 45D231761DC7E8F10034FA89 /* SessionResetJob.swift */,
452ECA4C1E087E7200E2F016 /* MessageFetcherJob.swift */, 452ECA4C1E087E7200E2F016 /* MessageFetcherJob.swift */,
4585C4651ED5DF7A00896AEA /* ProfileFetcherJob.swift */,
451686AA1F520CDA00AC3D4B /* MultiDeviceProfileKeyUpdateJob.swift */, 451686AA1F520CDA00AC3D4B /* MultiDeviceProfileKeyUpdateJob.swift */,
); );
name = Jobs; name = Jobs;
@ -2795,11 +2791,9 @@
340CB2241EAC155C0001CAA1 /* ContactsViewHelper.m in Sources */, 340CB2241EAC155C0001CAA1 /* ContactsViewHelper.m in Sources */,
45B72DDA1FD5E70600151AF6 /* ConversationSearcher.swift in Sources */, 45B72DDA1FD5E70600151AF6 /* ConversationSearcher.swift in Sources */,
34D1F0AB1F867BFC0066283D /* OWSContactOffersCell.m in Sources */, 34D1F0AB1F867BFC0066283D /* OWSContactOffersCell.m in Sources */,
34CE88EC1F3237260098030F /* OWSProfileManager.m in Sources */,
B60C16651988999D00E97A6C /* VersionMigrations.m in Sources */, B60C16651988999D00E97A6C /* VersionMigrations.m in Sources */,
343A65981FC4CFE7000477A1 /* ConversationScrollButton.m in Sources */, 343A65981FC4CFE7000477A1 /* ConversationScrollButton.m in Sources */,
B97940271832BD2400BD66CB /* UIUtil.m in Sources */, B97940271832BD2400BD66CB /* UIUtil.m in Sources */,
34CE88ED1F3237260098030F /* ProfileFetcherJob.swift in Sources */,
34B3F8791E8DF1700035BE1A /* CountryCodeViewController.m in Sources */, 34B3F8791E8DF1700035BE1A /* CountryCodeViewController.m in Sources */,
34D1F0A91F867BFC0066283D /* ConversationViewCell.m in Sources */, 34D1F0A91F867BFC0066283D /* ConversationViewCell.m in Sources */,
3461298B1FD1E2AB00532771 /* OWS102MoveLoggingPreferenceToUserDefaults.m in Sources */, 3461298B1FD1E2AB00532771 /* OWS102MoveLoggingPreferenceToUserDefaults.m in Sources */,

View File

@ -14,18 +14,19 @@
#import "OWSContactsSyncing.h" #import "OWSContactsSyncing.h"
#import "OWSNavigationController.h" #import "OWSNavigationController.h"
#import "OWSPreferences.h" #import "OWSPreferences.h"
#import "OWSProfileManager.h"
#import "Pastelog.h" #import "Pastelog.h"
#import "PushManager.h" #import "PushManager.h"
#import "RegistrationViewController.h" #import "RegistrationViewController.h"
#import "Release.h" #import "Release.h"
#import "SendExternalFileViewController.h" #import "SendExternalFileViewController.h"
#import "Signal-Swift.h" #import "Signal-Swift.h"
#import "SignalApp.h"
#import "SignalsNavigationController.h" #import "SignalsNavigationController.h"
#import "VersionMigrations.h" #import "VersionMigrations.h"
#import "ViewControllerUtils.h" #import "ViewControllerUtils.h"
#import <AxolotlKit/SessionCipher.h> #import <AxolotlKit/SessionCipher.h>
#import <SignalMessaging/OWSMath.h> #import <SignalMessaging/OWSMath.h>
#import <SignalMessaging/OWSProfileManager.h>
#import <SignalMessaging/SignalMessaging.h> #import <SignalMessaging/SignalMessaging.h>
#import <SignalServiceKit/NSUserDefaults+OWS.h> #import <SignalServiceKit/NSUserDefaults+OWS.h>
#import <SignalServiceKit/OWSBatchMessageProcessor.h> #import <SignalServiceKit/OWSBatchMessageProcessor.h>
@ -170,9 +171,9 @@ static NSString *const kURLHostVerifyPrefix = @"verify";
[self prepareScreenProtection]; [self prepareScreenProtection];
self.contactsSyncing = [[OWSContactsSyncing alloc] initWithContactsManager:[Environment getCurrent].contactsManager self.contactsSyncing = [[OWSContactsSyncing alloc] initWithContactsManager:[Environment current].contactsManager
identityManager:[OWSIdentityManager sharedManager] identityManager:[OWSIdentityManager sharedManager]
messageSender:[Environment getCurrent].messageSender messageSender:[Environment current].messageSender
profileManager:[OWSProfileManager sharedManager]]; profileManager:[OWSProfileManager sharedManager]];
[[NSNotificationCenter defaultCenter] addObserver:self [[NSNotificationCenter defaultCenter] addObserver:self
@ -291,17 +292,17 @@ static NSString *const kURLHostVerifyPrefix = @"verify";
[SessionCipher setSessionCipherDispatchQueue:[OWSDispatch sessionStoreQueue]]; [SessionCipher setSessionCipherDispatchQueue:[OWSDispatch sessionStoreQueue]];
TextSecureKitEnv *sharedEnv = TextSecureKitEnv *sharedEnv =
[[TextSecureKitEnv alloc] initWithCallMessageHandler:[Environment getCurrent].callMessageHandler [[TextSecureKitEnv alloc] initWithCallMessageHandler:SignalApp.sharedApp.callMessageHandler
contactsManager:[Environment getCurrent].contactsManager contactsManager:[Environment current].contactsManager
messageSender:[Environment getCurrent].messageSender messageSender:[Environment current].messageSender
notificationsManager:[Environment getCurrent].notificationsManager notificationsManager:SignalApp.sharedApp.notificationsManager
profileManager:OWSProfileManager.sharedManager]; profileManager:OWSProfileManager.sharedManager];
[TextSecureKitEnv setSharedEnv:sharedEnv]; [TextSecureKitEnv setSharedEnv:sharedEnv];
[[TSStorageManager sharedManager] setupDatabaseWithSafeBlockingMigrations:^{ [[TSStorageManager sharedManager] setupDatabaseWithSafeBlockingMigrations:^{
[VersionMigrations runSafeBlockingMigrations]; [VersionMigrations runSafeBlockingMigrations];
}]; }];
[[Environment getCurrent].contactsManager startObserving]; [[Environment current].contactsManager startObserving];
} }
- (void)application:(UIApplication *)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken - (void)application:(UIApplication *)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken
@ -336,7 +337,7 @@ static NSString *const kURLHostVerifyPrefix = @"verify";
annotation:(id)annotation { annotation:(id)annotation {
if ([url.scheme isEqualToString:kURLSchemeSGNLKey]) { if ([url.scheme isEqualToString:kURLSchemeSGNLKey]) {
if ([url.host hasPrefix:kURLHostVerifyPrefix] && ![TSAccountManager isRegistered]) { if ([url.host hasPrefix:kURLHostVerifyPrefix] && ![TSAccountManager isRegistered]) {
id signupController = [Environment getCurrent].signUpFlowNavigationController; id signupController = [Environment current].signUpFlowNavigationController;
if ([signupController isKindOfClass:[UINavigationController class]]) { if ([signupController isKindOfClass:[UINavigationController class]]) {
UINavigationController *navController = (UINavigationController *)signupController; UINavigationController *navController = (UINavigationController *)signupController;
UIViewController *controller = [navController.childViewControllers lastObject]; UIViewController *controller = [navController.childViewControllers lastObject];
@ -354,7 +355,7 @@ static NSString *const kURLHostVerifyPrefix = @"verify";
} }
} else if ([url.scheme.lowercaseString isEqualToString:@"file"]) { } else if ([url.scheme.lowercaseString isEqualToString:@"file"]) {
if ([Environment getCurrent].callService.call != nil) { if (SignalApp.sharedApp.callService.call != nil) {
DDLogWarn(@"%@ ignoring 'open with Signal' due to ongoing WebRTC call.", self.logTag); DDLogWarn(@"%@ ignoring 'open with Signal' due to ongoing WebRTC call.", self.logTag);
return NO; return NO;
} }
@ -494,9 +495,9 @@ static NSString *const kURLHostVerifyPrefix = @"verify";
viewController.attachment = attachment; viewController.attachment = attachment;
UINavigationController *navigationController = UINavigationController *navigationController =
[[UINavigationController alloc] initWithRootViewController:viewController]; [[UINavigationController alloc] initWithRootViewController:viewController];
[[[Environment getCurrent] homeViewController] presentTopLevelModalViewController:navigationController [SignalApp.sharedApp.homeViewController presentTopLevelModalViewController:navigationController
animateDismissal:NO animateDismissal:NO
animatePresentation:YES]; animatePresentation:YES];
} }
- (void)applicationDidBecomeActive:(UIApplication *)application { - (void)applicationDidBecomeActive:(UIApplication *)application {
@ -563,7 +564,7 @@ static NSString *const kURLHostVerifyPrefix = @"verify";
// Avoid blocking app launch by putting all further possible DB access in async block // Avoid blocking app launch by putting all further possible DB access in async block
dispatch_async(dispatch_get_main_queue(), ^{ dispatch_async(dispatch_get_main_queue(), ^{
[TSSocketManager requestSocketOpen]; [TSSocketManager requestSocketOpen];
[[Environment getCurrent].contactsManager fetchSystemContactsOnceIfAlreadyAuthorized]; [[Environment current].contactsManager fetchSystemContactsOnceIfAlreadyAuthorized];
// This will fetch new messages, if we're using domain fronting. // This will fetch new messages, if we're using domain fronting.
[[PushManager sharedManager] applicationDidBecomeActive]; [[PushManager sharedManager] applicationDidBecomeActive];
@ -575,7 +576,7 @@ static NSString *const kURLHostVerifyPrefix = @"verify";
// "Background App Refresh" will not be able to obtain an APN token. Enabling those settings does not // "Background App Refresh" will not be able to obtain an APN token. Enabling those settings does not
// restart the app, so we check every activation for users who haven't yet registered. // restart the app, so we check every activation for users who haven't yet registered.
__unused AnyPromise *promise = __unused AnyPromise *promise =
[OWSSyncPushTokensJob runWithAccountManager:[Environment getCurrent].accountManager [OWSSyncPushTokensJob runWithAccountManager:SignalApp.sharedApp.accountManager
preferences:[Environment preferences]]; preferences:[Environment preferences]];
} }
}); });
@ -596,7 +597,7 @@ static NSString *const kURLHostVerifyPrefix = @"verify";
// If app has not re-entered active, show screen protection if necessary. // If app has not re-entered active, show screen protection if necessary.
[self showScreenProtection]; [self showScreenProtection];
} }
[[[Environment getCurrent] homeViewController] updateInboxCountLabel]; [SignalApp.sharedApp.homeViewController updateInboxCountLabel];
[application endBackgroundTask:bgTask]; [application endBackgroundTask:bgTask];
}); });
} }
@ -609,7 +610,7 @@ static NSString *const kURLHostVerifyPrefix = @"verify";
performActionForShortcutItem:(UIApplicationShortcutItem *)shortcutItem performActionForShortcutItem:(UIApplicationShortcutItem *)shortcutItem
completionHandler:(void (^)(BOOL succeeded))completionHandler { completionHandler:(void (^)(BOOL succeeded))completionHandler {
if ([TSAccountManager isRegistered]) { if ([TSAccountManager isRegistered]) {
[[Environment getCurrent].homeViewController showNewConversationView]; [SignalApp.sharedApp.homeViewController showNewConversationView];
completionHandler(YES); completionHandler(YES);
} else { } else {
UIAlertController *controller = UIAlertController *controller =
@ -675,10 +676,10 @@ static NSString *const kURLHostVerifyPrefix = @"verify";
// * It can be received if the user taps the "video" button for a contact in the // * It can be received if the user taps the "video" button for a contact in the
// contacts app. If so, the correct response is to try to initiate a new call // contacts app. If so, the correct response is to try to initiate a new call
// to that user - unless there already is another call in progress. // to that user - unless there already is another call in progress.
if ([Environment getCurrent].callService.call != nil) { if (SignalApp.sharedApp.callService.call != nil) {
if ([phoneNumber isEqualToString:[Environment getCurrent].callService.call.remotePhoneNumber]) { if ([phoneNumber isEqualToString:SignalApp.sharedApp.callService.call.remotePhoneNumber]) {
DDLogWarn(@"%@ trying to upgrade ongoing call to video.", self.logTag); DDLogWarn(@"%@ trying to upgrade ongoing call to video.", self.logTag);
[[Environment getCurrent].callService handleCallKitStartVideo]; [SignalApp.sharedApp.callService handleCallKitStartVideo];
return YES; return YES;
} else { } else {
DDLogWarn( DDLogWarn(
@ -687,7 +688,7 @@ static NSString *const kURLHostVerifyPrefix = @"verify";
} }
} }
OutboundCallInitiator *outboundCallInitiator = [Environment getCurrent].outboundCallInitiator; OutboundCallInitiator *outboundCallInitiator = SignalApp.sharedApp.outboundCallInitiator;
OWSAssert(outboundCallInitiator); OWSAssert(outboundCallInitiator);
return [outboundCallInitiator initiateCallWithHandle:phoneNumber]; return [outboundCallInitiator initiateCallWithHandle:phoneNumber];
} else if ([userActivity.activityType isEqualToString:@"INStartAudioCallIntent"]) { } else if ([userActivity.activityType isEqualToString:@"INStartAudioCallIntent"]) {
@ -722,12 +723,12 @@ static NSString *const kURLHostVerifyPrefix = @"verify";
} }
} }
if ([Environment getCurrent].callService.call != nil) { if (SignalApp.sharedApp.callService.call != nil) {
DDLogWarn(@"%@ ignoring INStartAudioCallIntent due to ongoing WebRTC call.", self.logTag); DDLogWarn(@"%@ ignoring INStartAudioCallIntent due to ongoing WebRTC call.", self.logTag);
return NO; return NO;
} }
OutboundCallInitiator *outboundCallInitiator = [Environment getCurrent].outboundCallInitiator; OutboundCallInitiator *outboundCallInitiator = SignalApp.sharedApp.outboundCallInitiator;
OWSAssert(outboundCallInitiator); OWSAssert(outboundCallInitiator);
return [outboundCallInitiator initiateCallWithHandle:phoneNumber]; return [outboundCallInitiator initiateCallWithHandle:phoneNumber];
} else { } else {
@ -864,11 +865,11 @@ static NSString *const kURLHostVerifyPrefix = @"verify";
// Fetch messages as soon as possible after launching. In particular, when // Fetch messages as soon as possible after launching. In particular, when
// launching from the background, without this, we end up waiting some extra // launching from the background, without this, we end up waiting some extra
// seconds before receiving an actionable push notification. // seconds before receiving an actionable push notification.
__unused AnyPromise *messagePromise = [[Environment getCurrent].messageFetcherJob run]; __unused AnyPromise *messagePromise = [SignalApp.sharedApp.messageFetcherJob run];
// This should happen at any launch, background or foreground. // This should happen at any launch, background or foreground.
__unused AnyPromise *pushTokenpromise = __unused AnyPromise *pushTokenpromise =
[OWSSyncPushTokensJob runWithAccountManager:[Environment getCurrent].accountManager [OWSSyncPushTokensJob runWithAccountManager:SignalApp.sharedApp.accountManager
preferences:[Environment preferences]]; preferences:[Environment preferences]];
} }
@ -899,7 +900,7 @@ static NSString *const kURLHostVerifyPrefix = @"verify";
[OWSProfileManager.sharedManager fetchLocalUsersProfile]; [OWSProfileManager.sharedManager fetchLocalUsersProfile];
[[OWSReadReceiptManager sharedManager] prepareCachedValues]; [[OWSReadReceiptManager sharedManager] prepareCachedValues];
[[Environment getCurrent].contactsManager loadLastKnownContactRecipientIds]; [[Environment current].contactsManager loadLastKnownContactRecipientIds];
} }
- (void)registrationStateDidChange - (void)registrationStateDidChange

View File

@ -35,7 +35,7 @@ class AccountManager: NSObject {
} }
func register(verificationCode: String) -> Promise<Void> { func register(verificationCode: String) -> Promise<Void> {
guard verificationCode.characters.count > 0 else { guard verificationCode.count > 0 else {
let error = OWSErrorWithCodeDescription(.userError, let error = OWSErrorWithCodeDescription(.userError,
NSLocalizedString("REGISTRATION_ERROR_BLANK_VERIFICATION_CODE", NSLocalizedString("REGISTRATION_ERROR_BLANK_VERIFICATION_CODE",
comment: "alert body during registration")) comment: "alert body during registration"))

View File

@ -60,7 +60,7 @@ class CompareSafetyNumbersActivity: UIActivity {
defer { activityDidFinish(true) } defer { activityDidFinish(true) }
let pasteboardString = numericOnly(string: UIPasteboard.general.string) let pasteboardString = numericOnly(string: UIPasteboard.general.string)
guard (pasteboardString != nil && pasteboardString!.characters.count == 60) else { guard (pasteboardString != nil && pasteboardString!.count == 60) else {
Logger.warn("\(TAG) no valid safety numbers found in pasteboard: \(String(describing: pasteboardString))") Logger.warn("\(TAG) no valid safety numbers found in pasteboard: \(String(describing: pasteboardString))")
let error = OWSErrorWithCodeDescription(OWSErrorCode.userError, let error = OWSErrorWithCodeDescription(OWSErrorCode.userError,
NSLocalizedString("PRIVACY_VERIFICATION_FAILED_NO_SAFETY_NUMBERS_IN_CLIPBOARD", comment: "Alert body for user error")) NSLocalizedString("PRIVACY_VERIFICATION_FAILED_NO_SAFETY_NUMBERS_IN_CLIPBOARD", comment: "Alert body for user error"))
@ -91,7 +91,7 @@ class CompareSafetyNumbersActivity: UIActivity {
var numericOnly: String? var numericOnly: String?
if let regex = try? NSRegularExpression(pattern: "\\D", options: .caseInsensitive) { if let regex = try? NSRegularExpression(pattern: "\\D", options: .caseInsensitive) {
numericOnly = regex.stringByReplacingMatches(in: string!, options: .withTransparentBounds, range: NSMakeRange(0, string!.characters.count), withTemplate: "") numericOnly = regex.stringByReplacingMatches(in: string!, options: .withTransparentBounds, range: NSMakeRange(0, string!.count), withTemplate: "")
} }
return numericOnly return numericOnly

View File

@ -225,7 +225,7 @@ class SignalAttachment: NSObject {
if let filename = sourceFilename { if let filename = sourceFilename {
let fileExtension = (filename as NSString).pathExtension let fileExtension = (filename as NSString).pathExtension
if fileExtension.characters.count > 0 { if fileExtension.count > 0 {
if let mimeType = MIMETypeUtil.mimeType(forFileExtension:fileExtension) { if let mimeType = MIMETypeUtil.mimeType(forFileExtension:fileExtension) {
// UTI types are an imperfect means of representing file type; // UTI types are an imperfect means of representing file type;
// file extensions are also imperfect but far more reliable and // file extensions are also imperfect but far more reliable and
@ -273,7 +273,7 @@ class SignalAttachment: NSObject {
var fileExtension: String? { var fileExtension: String? {
if let filename = sourceFilename { if let filename = sourceFilename {
let fileExtension = (filename as NSString).pathExtension let fileExtension = (filename as NSString).pathExtension
if fileExtension.characters.count > 0 { if fileExtension.count > 0 {
return fileExtension return fileExtension
} }
} }
@ -477,7 +477,7 @@ class SignalAttachment: NSObject {
// NOTE: The attachment returned by this method may not be valid. // NOTE: The attachment returned by this method may not be valid.
// Check the attachment's error property. // Check the attachment's error property.
private class func imageAttachment(dataSource: DataSource?, dataUTI: String) -> SignalAttachment { private class func imageAttachment(dataSource: DataSource?, dataUTI: String) -> SignalAttachment {
assert(dataUTI.characters.count > 0) assert(dataUTI.count > 0)
assert(dataSource != nil) assert(dataSource != nil)
guard let dataSource = dataSource else { guard let dataSource = dataSource else {
@ -577,7 +577,7 @@ class SignalAttachment: NSObject {
// NOTE: The attachment returned by this method may nil or not be valid. // NOTE: The attachment returned by this method may nil or not be valid.
// Check the attachment's error property. // Check the attachment's error property.
public class func imageAttachment(image: UIImage?, dataUTI: String, filename: String?) -> SignalAttachment { public class func imageAttachment(image: UIImage?, dataUTI: String, filename: String?) -> SignalAttachment {
assert(dataUTI.characters.count > 0) assert(dataUTI.count > 0)
guard let image = image else { guard let image = image else {
let dataSource = DataSourceValue.emptyDataSource() let dataSource = DataSourceValue.emptyDataSource()
@ -779,7 +779,7 @@ class SignalAttachment: NSObject {
dataUTI: String, dataUTI: String,
validUTISet: Set<String>?, validUTISet: Set<String>?,
maxFileSize: UInt) -> SignalAttachment { maxFileSize: UInt) -> SignalAttachment {
assert(dataUTI.characters.count > 0) assert(dataUTI.count > 0)
assert(dataSource != nil) assert(dataSource != nil)
guard let dataSource = dataSource else { guard let dataSource = dataSource else {

View File

@ -2,13 +2,16 @@
// Copyright (c) 2017 Open Whisper Systems. All rights reserved. // Copyright (c) 2017 Open Whisper Systems. All rights reserved.
// //
#import <Foundation/Foundation.h>
#import <UIKit/UIKit.h>
// Separate iOS Frameworks from other imports.
#import "AppSettingsViewController.h" #import "AppSettingsViewController.h"
#import "AttachmentSharing.h" #import "AttachmentSharing.h"
#import "ContactTableViewCell.h" #import "ContactTableViewCell.h"
#import "ConversationViewItem.h" #import "ConversationViewItem.h"
#import "DateUtil.h" #import "DateUtil.h"
#import "DebugUIPage.h" #import "DebugUIPage.h"
#import "Environment.h"
#import "FingerprintViewController.h" #import "FingerprintViewController.h"
#import "FullImageViewController.h" #import "FullImageViewController.h"
#import "HomeViewController.h" #import "HomeViewController.h"
@ -24,15 +27,14 @@
#import "OWSLogger.h" #import "OWSLogger.h"
#import "OWSNavigationController.h" #import "OWSNavigationController.h"
#import "OWSPreferences.h" #import "OWSPreferences.h"
#import "OWSProfileManager.h"
#import "OWSProgressView.h" #import "OWSProgressView.h"
#import "OWSViewController.h" #import "OWSViewController.h"
#import "OWSWebRTCDataProtos.pb.h" #import "OWSWebRTCDataProtos.pb.h"
#import "PrivacySettingsTableViewController.h" #import "PrivacySettingsTableViewController.h"
#import "ProfileViewController.h" #import "ProfileViewController.h"
#import "PushManager.h" #import "PushManager.h"
#import "Release.h"
#import "RemoteVideoView.h" #import "RemoteVideoView.h"
#import "SignalApp.h"
#import "ThreadUtil.h" #import "ThreadUtil.h"
#import "UIColor+OWS.h" #import "UIColor+OWS.h"
#import "UIFont+OWS.h" #import "UIFont+OWS.h"
@ -42,7 +44,6 @@
#import "UIViewController+Permissions.h" #import "UIViewController+Permissions.h"
#import "ViewControllerUtils.h" #import "ViewControllerUtils.h"
#import <AxolotlKit/NSData+keyVersionByte.h> #import <AxolotlKit/NSData+keyVersionByte.h>
#import <Foundation/Foundation.h>
#import <JSQMessagesViewController/JSQMediaItem.h> #import <JSQMessagesViewController/JSQMediaItem.h>
#import <JSQMessagesViewController/JSQMessagesBubbleImage.h> #import <JSQMessagesViewController/JSQMessagesBubbleImage.h>
#import <JSQMessagesViewController/JSQMessagesBubbleImageFactory.h> #import <JSQMessagesViewController/JSQMessagesBubbleImageFactory.h>
@ -51,6 +52,11 @@
#import <JSQSystemSoundPlayer/JSQSystemSoundPlayer.h> #import <JSQSystemSoundPlayer/JSQSystemSoundPlayer.h>
#import <PureLayout/PureLayout.h> #import <PureLayout/PureLayout.h>
#import <Reachability/Reachability.h> #import <Reachability/Reachability.h>
#import <SignalMessaging/Environment.h>
#import <SignalMessaging/OWSFormat.h>
#import <SignalMessaging/OWSProfileManager.h>
#import <SignalMessaging/Release.h>
#import <SignalMessaging/UIViewController+OWS.h>
#import <SignalServiceKit/AppVersion.h> #import <SignalServiceKit/AppVersion.h>
#import <SignalServiceKit/Asserts.h> #import <SignalServiceKit/Asserts.h>
#import <SignalServiceKit/Contact.h> #import <SignalServiceKit/Contact.h>

View File

@ -16,8 +16,11 @@ extension UIApplication {
internal func findFrontmostViewController(ignoringAlerts: Bool) -> UIViewController? { internal func findFrontmostViewController(ignoringAlerts: Bool) -> UIViewController? {
let window = UIApplication.shared.keyWindow let window = UIApplication.shared.keyWindow
var viewController = window!.rootViewController guard let viewController = window!.rootViewController else {
return viewController.findFrontmostViewController(ignoringAlerts:ignoringAlerts) owsFail("\(self.logTag) in \(#function) Missing root view controller.")
return nil
}
return viewController.findFrontmostViewController(ignoringAlerts)
} }
func openSystemSettings() { func openSystemSettings() {

View File

@ -22,7 +22,7 @@ class CallNotificationsAdapter: NSObject {
// if #available(iOS 10.0, *) { // if #available(iOS 10.0, *) {
// adaptee = UserNotificationsAdaptee() // adaptee = UserNotificationsAdaptee()
// } else { // } else {
adaptee = Environment.getCurrent().notificationsManager adaptee = SignalApp.shared().notificationsManager
// } // }
} }

View File

@ -67,7 +67,7 @@ class UserNotificationsAdaptee: NSObject, OWSCallNotificationsAdaptee, UNUserNot
private let center: UNUserNotificationCenter private let center: UNUserNotificationCenter
var previewType: NotificationType { var previewType: NotificationType {
return Environment.getCurrent().preferences.notificationPreviewType() return Environment.current().preferences.notificationPreviewType()
} }
override init() { override init() {
@ -115,7 +115,7 @@ class UserNotificationsAdaptee: NSObject, OWSCallNotificationsAdaptee, UNUserNot
case .noNameNoPreview: case .noNameNoPreview:
return CallStrings.missedCallNotificationBodyWithoutCallerName return CallStrings.missedCallNotificationBodyWithoutCallerName
case .nameNoPreview, .namePreview: case .nameNoPreview, .namePreview:
return (Environment.getCurrent().preferences.isCallKitPrivacyEnabled() return (Environment.current().preferences.isCallKitPrivacyEnabled()
? CallStrings.missedCallNotificationBodyWithoutCallerName ? CallStrings.missedCallNotificationBodyWithoutCallerName
: String(format: CallStrings.missedCallNotificationBodyWithCallerName, callerName)) : String(format: CallStrings.missedCallNotificationBodyWithCallerName, callerName))
}}() }}()
@ -141,7 +141,7 @@ class UserNotificationsAdaptee: NSObject, OWSCallNotificationsAdaptee, UNUserNot
case .noNameNoPreview: case .noNameNoPreview:
return CallStrings.missedCallWithIdentityChangeNotificationBodyWithoutCallerName return CallStrings.missedCallWithIdentityChangeNotificationBodyWithoutCallerName
case .nameNoPreview, .namePreview: case .nameNoPreview, .namePreview:
return (Environment.getCurrent().preferences.isCallKitPrivacyEnabled() return (Environment.current().preferences.isCallKitPrivacyEnabled()
? CallStrings.missedCallWithIdentityChangeNotificationBodyWithoutCallerName ? CallStrings.missedCallWithIdentityChangeNotificationBodyWithoutCallerName
: String(format: CallStrings.missedCallWithIdentityChangeNotificationBodyWithCallerName, callerName)) : String(format: CallStrings.missedCallWithIdentityChangeNotificationBodyWithCallerName, callerName))
}}() }}()
@ -167,7 +167,7 @@ class UserNotificationsAdaptee: NSObject, OWSCallNotificationsAdaptee, UNUserNot
case .noNameNoPreview: case .noNameNoPreview:
return CallStrings.missedCallWithIdentityChangeNotificationBodyWithoutCallerName return CallStrings.missedCallWithIdentityChangeNotificationBodyWithoutCallerName
case .nameNoPreview, .namePreview: case .nameNoPreview, .namePreview:
return (Environment.getCurrent().preferences.isCallKitPrivacyEnabled() return (Environment.current().preferences.isCallKitPrivacyEnabled()
? CallStrings.missedCallWithIdentityChangeNotificationBodyWithoutCallerName ? CallStrings.missedCallWithIdentityChangeNotificationBodyWithoutCallerName
: String(format: CallStrings.missedCallWithIdentityChangeNotificationBodyWithCallerName, callerName)) : String(format: CallStrings.missedCallWithIdentityChangeNotificationBodyWithCallerName, callerName))
}}() }}()

View File

@ -240,9 +240,8 @@ NS_ASSUME_NONNULL_BEGIN
- (void)syncPushTokens - (void)syncPushTokens
{ {
OWSSyncPushTokensJob *job = OWSSyncPushTokensJob *job = [[OWSSyncPushTokensJob alloc] initWithAccountManager:SignalApp.sharedApp.accountManager
[[OWSSyncPushTokensJob alloc] initWithAccountManager:[Environment getCurrent].accountManager preferences:[Environment preferences]];
preferences:[Environment preferences]];
job.uploadOnlyIfStale = NO; job.uploadOnlyIfStale = NO;
[job run] [job run]
.then(^{ .then(^{

View File

@ -48,7 +48,7 @@
return self; return self;
} }
_contactsManager = [Environment getCurrent].contactsManager; _contactsManager = [Environment current].contactsManager;
return self; return self;
} }
@ -60,7 +60,7 @@
return self; return self;
} }
_contactsManager = [Environment getCurrent].contactsManager; _contactsManager = [Environment current].contactsManager;
return self; return self;
} }
@ -381,7 +381,7 @@
canCancel:NO canCancel:NO
backgroundBlock:^(ModalActivityIndicatorViewController *modalActivityIndicator) { backgroundBlock:^(ModalActivityIndicatorViewController *modalActivityIndicator) {
[TSAccountManager unregisterTextSecureWithSuccess:^{ [TSAccountManager unregisterTextSecureWithSuccess:^{
[Environment resetAppData]; [SignalApp resetAppData];
} }
failure:^(NSError *error) { failure:^(NSError *error) {
dispatch_async(dispatch_get_main_queue(), ^{ dispatch_async(dispatch_get_main_queue(), ^{

View File

@ -124,8 +124,8 @@ class CallViewController: OWSViewController, CallObserver, CallServiceObserver {
@available(*, unavailable, message: "use init(call:) constructor instead.") @available(*, unavailable, message: "use init(call:) constructor instead.")
required init?(coder aDecoder: NSCoder) { required init?(coder aDecoder: NSCoder) {
contactsManager = Environment.getCurrent().contactsManager contactsManager = Environment.current().contactsManager
callUIAdapter = Environment.getCurrent().callUIAdapter callUIAdapter = SignalApp.shared().callUIAdapter
allAudioSources = Set(callUIAdapter.audioService.availableInputs) allAudioSources = Set(callUIAdapter.audioService.availableInputs)
self.call = SignalCall.outgoingCall(localId: UUID(), remotePhoneNumber: "+1234567890") self.call = SignalCall.outgoingCall(localId: UUID(), remotePhoneNumber: "+1234567890")
self.thread = TSContactThread.getOrCreateThread(contactId: call.remotePhoneNumber) self.thread = TSContactThread.getOrCreateThread(contactId: call.remotePhoneNumber)
@ -134,8 +134,8 @@ class CallViewController: OWSViewController, CallObserver, CallServiceObserver {
} }
required init(call: SignalCall) { required init(call: SignalCall) {
contactsManager = Environment.getCurrent().contactsManager contactsManager = Environment.current().contactsManager
callUIAdapter = Environment.getCurrent().callUIAdapter callUIAdapter = SignalApp.shared().callUIAdapter
allAudioSources = Set(callUIAdapter.audioService.availableInputs) allAudioSources = Set(callUIAdapter.audioService.availableInputs)
self.call = call self.call = call
self.thread = TSContactThread.getOrCreateThread(contactId: call.remotePhoneNumber) self.thread = TSContactThread.getOrCreateThread(contactId: call.remotePhoneNumber)
@ -200,7 +200,7 @@ class CallViewController: OWSViewController, CallObserver, CallServiceObserver {
// Subscribe for future call updates // Subscribe for future call updates
call.addObserverAndSyncState(observer: self) call.addObserverAndSyncState(observer: self)
Environment.getCurrent().callService.addObserverAndSyncState(observer: self) SignalApp.shared().callService.addObserverAndSyncState(observer: self)
} }
// MARK: - Create Views // MARK: - Create Views
@ -927,7 +927,7 @@ class CallViewController: OWSViewController, CallObserver, CallServiceObserver {
private func markSettingsNagAsComplete() { private func markSettingsNagAsComplete() {
Logger.info("\(TAG) called \(#function)") Logger.info("\(TAG) called \(#function)")
let preferences = Environment.getCurrent().preferences! let preferences = Environment.current().preferences!
preferences.setIsCallKitEnabled(preferences.isCallKitEnabled()) preferences.setIsCallKitEnabled(preferences.isCallKitEnabled())
preferences.setIsCallKitPrivacyEnabled(preferences.isCallKitPrivacyEnabled()) preferences.setIsCallKitPrivacyEnabled(preferences.isCallKitPrivacyEnabled())
@ -1008,13 +1008,13 @@ class CallViewController: OWSViewController, CallObserver, CallServiceObserver {
} else if !ignoreNag && } else if !ignoreNag &&
call.direction == .incoming && call.direction == .incoming &&
UIDevice.current.supportsCallKit && UIDevice.current.supportsCallKit &&
(!Environment.getCurrent().preferences.isCallKitEnabled() || (!Environment.current().preferences.isCallKitEnabled() ||
Environment.getCurrent().preferences.isCallKitPrivacyEnabled()) { Environment.current().preferences.isCallKitPrivacyEnabled()) {
isShowingSettingsNag = true isShowingSettingsNag = true
// Update the nag view's copy to reflect the settings state. // Update the nag view's copy to reflect the settings state.
if Environment.getCurrent().preferences.isCallKitEnabled() { if Environment.current().preferences.isCallKitEnabled() {
settingsNagDescriptionLabel.text = NSLocalizedString("CALL_VIEW_SETTINGS_NAG_DESCRIPTION_PRIVACY", settingsNagDescriptionLabel.text = NSLocalizedString("CALL_VIEW_SETTINGS_NAG_DESCRIPTION_PRIVACY",
comment: "Reminder to the user of the benefits of disabling CallKit privacy.") comment: "Reminder to the user of the benefits of disabling CallKit privacy.")
} else { } else {
@ -1023,8 +1023,8 @@ class CallViewController: OWSViewController, CallObserver, CallServiceObserver {
} }
settingsNagDescriptionLabel.superview?.setNeedsLayout() settingsNagDescriptionLabel.superview?.setNeedsLayout()
if Environment.getCurrent().preferences.isCallKitEnabledSet() || if Environment.current().preferences.isCallKitEnabledSet() ||
Environment.getCurrent().preferences.isCallKitPrivacySet() { Environment.current().preferences.isCallKitPrivacySet() {
// User has already touched these preferences, only show // User has already touched these preferences, only show
// the "fleeting" nag, not the "blocking" nag. // the "fleeting" nag, not the "blocking" nag.

View File

@ -45,7 +45,7 @@ NS_ASSUME_NONNULL_BEGIN
return self; return self;
} }
_accountManager = [Environment getCurrent].accountManager; _accountManager = SignalApp.sharedApp.accountManager;
return self; return self;
} }
@ -57,7 +57,7 @@ NS_ASSUME_NONNULL_BEGIN
return self; return self;
} }
_accountManager = [Environment getCurrent].accountManager; _accountManager = SignalApp.sharedApp.accountManager;
return self; return self;
} }

View File

@ -109,12 +109,12 @@ open class ContactsPicker: OWSViewController, UITableViewDelegate, UITableViewDa
// MARK: - Initializers // MARK: - Initializers
init() { init() {
contactsManager = Environment.getCurrent().contactsManager contactsManager = Environment.current().contactsManager
super.init(nibName: nil, bundle: nil) super.init(nibName: nil, bundle: nil)
} }
required public init?(coder aDecoder: NSCoder) { required public init?(coder aDecoder: NSCoder) {
contactsManager = Environment.getCurrent().contactsManager contactsManager = Environment.current().contactsManager
super.init(coder: aDecoder) super.init(coder: aDecoder)
} }
@ -321,7 +321,7 @@ open class ContactsPicker: OWSViewController, UITableViewDelegate, UITableViewDa
open func updateSearchResults(searchText: String) { open func updateSearchResults(searchText: String) {
let predicate: NSPredicate let predicate: NSPredicate
if searchText.characters.count == 0 { if searchText.count == 0 {
filteredSections = sections filteredSections = sections
} else { } else {
do { do {

View File

@ -5,8 +5,8 @@
#import "ContactsViewHelper.h" #import "ContactsViewHelper.h"
#import "Environment.h" #import "Environment.h"
#import "NSString+OWS.h" #import "NSString+OWS.h"
#import "OWSProfileManager.h"
#import "Signal-Swift.h" #import "Signal-Swift.h"
#import <SignalMessaging/OWSProfileManager.h>
#import <SignalServiceKit/Contact.h> #import <SignalServiceKit/Contact.h>
#import <SignalServiceKit/OWSBlockingManager.h> #import <SignalServiceKit/OWSBlockingManager.h>
#import <SignalServiceKit/PhoneNumber.h> #import <SignalServiceKit/PhoneNumber.h>
@ -52,7 +52,7 @@ NS_ASSUME_NONNULL_BEGIN
_blockedPhoneNumbers = [_blockingManager blockedPhoneNumbers]; _blockedPhoneNumbers = [_blockingManager blockedPhoneNumbers];
_conversationSearcher = ConversationSearcher.shared; _conversationSearcher = ConversationSearcher.shared;
_contactsManager = [Environment getCurrent].contactsManager; _contactsManager = [Environment current].contactsManager;
_profileManager = [OWSProfileManager sharedManager]; _profileManager = [OWSProfileManager sharedManager];
// We don't want to notify the delegate in the `updateContacts`. // We don't want to notify the delegate in the `updateContacts`.

View File

@ -193,7 +193,7 @@ NS_ASSUME_NONNULL_BEGIN
OWSVerificationStateChangeMessage *message = (OWSVerificationStateChangeMessage *)interaction; OWSVerificationStateChangeMessage *message = (OWSVerificationStateChangeMessage *)interaction;
BOOL isVerified = message.verificationState == OWSVerificationStateVerified; BOOL isVerified = message.verificationState == OWSVerificationStateVerified;
NSString *displayName = NSString *displayName =
[[Environment getCurrent].contactsManager displayNameForPhoneIdentifier:message.recipientId]; [[Environment current].contactsManager displayNameForPhoneIdentifier:message.recipientId];
NSString *titleFormat = (isVerified NSString *titleFormat = (isVerified
? (message.isLocalChange ? (message.isLocalChange
? NSLocalizedString(@"VERIFICATION_STATE_CHANGE_FORMAT_VERIFIED_LOCAL", ? NSLocalizedString(@"VERIFICATION_STATE_CHANGE_FORMAT_VERIFIED_LOCAL",

View File

@ -263,10 +263,10 @@ typedef NS_ENUM(NSInteger, MessagesRangeSizeMode) {
- (void)commonInit - (void)commonInit
{ {
_contactsManager = [Environment getCurrent].contactsManager; _contactsManager = [Environment current].contactsManager;
_contactsUpdater = [Environment getCurrent].contactsUpdater; _contactsUpdater = [Environment current].contactsUpdater;
_messageSender = [Environment getCurrent].messageSender; _messageSender = [Environment current].messageSender;
_outboundCallInitiator = [Environment getCurrent].outboundCallInitiator; _outboundCallInitiator = SignalApp.sharedApp.outboundCallInitiator;
_storageManager = [TSStorageManager sharedManager]; _storageManager = [TSStorageManager sharedManager];
_messagesManager = [OWSMessageManager sharedManager]; _messagesManager = [OWSMessageManager sharedManager];
_networkManager = [TSNetworkManager sharedManager]; _networkManager = [TSNetworkManager sharedManager];

View File

@ -13,10 +13,10 @@ class DebugUICalling: DebugUIPage {
// MARK: Dependencies // MARK: Dependencies
var notificationsAdapter: CallNotificationsAdapter { var notificationsAdapter: CallNotificationsAdapter {
return Environment.getCurrent().callService.notificationsAdapter return SignalApp.shared().callService.notificationsAdapter
} }
var messageSender: MessageSender { var messageSender: MessageSender {
return Environment.getCurrent().messageSender return Environment.current().messageSender
} }
// MARK: Overrides // MARK: Overrides

View File

@ -244,7 +244,7 @@ NS_ASSUME_NONNULL_BEGIN
OWSSyncGroupsRequestMessage *syncGroupsRequestMessage = OWSSyncGroupsRequestMessage *syncGroupsRequestMessage =
[[OWSSyncGroupsRequestMessage alloc] initWithThread:thread [[OWSSyncGroupsRequestMessage alloc] initWithThread:thread
groupId:[Randomness generateRandomBytes:16]]; groupId:[Randomness generateRandomBytes:16]];
[[Environment getCurrent].messageSender enqueueMessage:syncGroupsRequestMessage [[Environment current].messageSender enqueueMessage:syncGroupsRequestMessage
success:^{ success:^{
DDLogWarn(@"%@ Successfully sent Request Group Info message.", self.logTag); DDLogWarn(@"%@ Successfully sent Request Group Info message.", self.logTag);
} }
@ -292,7 +292,7 @@ NS_ASSUME_NONNULL_BEGIN
NSString *randomText = [self randomText]; NSString *randomText = [self randomText];
NSString *text = [[[@(counter) description] stringByAppendingString:@" "] stringByAppendingString:randomText]; NSString *text = [[[@(counter) description] stringByAppendingString:@" "] stringByAppendingString:randomText];
OWSMessageSender *messageSender = [Environment getCurrent].messageSender; OWSMessageSender *messageSender = [Environment current].messageSender;
TSOutgoingMessage *message = [ThreadUtil sendMessageWithText:text inThread:thread messageSender:messageSender]; TSOutgoingMessage *message = [ThreadUtil sendMessageWithText:text inThread:thread messageSender:messageSender];
DDLogError(@"%@ sendTextMessageInThread timestamp: %llu.", self.logTag, message.timestamp); DDLogError(@"%@ sendTextMessageInThread timestamp: %llu.", self.logTag, message.timestamp);
} }
@ -312,7 +312,7 @@ NS_ASSUME_NONNULL_BEGIN
{ {
NSString *randomText = [[self randomText] substringToIndex:arc4random_uniform(4)]; NSString *randomText = [[self randomText] substringToIndex:arc4random_uniform(4)];
NSString *text = [[[@(counter) description] stringByAppendingString:@" "] stringByAppendingString:randomText]; NSString *text = [[[@(counter) description] stringByAppendingString:@" "] stringByAppendingString:randomText];
OWSMessageSender *messageSender = [Environment getCurrent].messageSender; OWSMessageSender *messageSender = [Environment current].messageSender;
[ThreadUtil sendMessageWithText:text inThread:thread messageSender:messageSender]; [ThreadUtil sendMessageWithText:text inThread:thread messageSender:messageSender];
} }
@ -373,7 +373,7 @@ NS_ASSUME_NONNULL_BEGIN
OWSAssert(filePath); OWSAssert(filePath);
OWSAssert(thread); OWSAssert(thread);
OWSMessageSender *messageSender = [Environment getCurrent].messageSender; OWSMessageSender *messageSender = [Environment current].messageSender;
NSString *filename = [filePath lastPathComponent]; NSString *filename = [filePath lastPathComponent];
NSString *utiType = [MIMETypeUtil utiTypeForFileExtension:filename.pathExtension]; NSString *utiType = [MIMETypeUtil utiTypeForFileExtension:filename.pathExtension];
DataSource *_Nullable dataSource = [DataSourcePath dataSourceWithFilePath:filePath]; DataSource *_Nullable dataSource = [DataSourcePath dataSourceWithFilePath:filePath];
@ -624,7 +624,7 @@ NS_ASSUME_NONNULL_BEGIN
+ (void)sendOversizeTextMessage:(TSThread *)thread + (void)sendOversizeTextMessage:(TSThread *)thread
{ {
OWSMessageSender *messageSender = [Environment getCurrent].messageSender; OWSMessageSender *messageSender = [Environment current].messageSender;
NSMutableString *message = [NSMutableString new]; NSMutableString *message = [NSMutableString new];
for (int i = 0; i < 32; i++) { for (int i = 0; i < 32; i++) {
[message appendString:@"Lorem ipsum dolor sit amet, consectetur adipiscing elit. Suspendisse rutrum, nulla " [message appendString:@"Lorem ipsum dolor sit amet, consectetur adipiscing elit. Suspendisse rutrum, nulla "
@ -665,7 +665,7 @@ NS_ASSUME_NONNULL_BEGIN
+ (void)sendRandomAttachment:(TSThread *)thread uti:(NSString *)uti length:(NSUInteger)length + (void)sendRandomAttachment:(TSThread *)thread uti:(NSString *)uti length:(NSUInteger)length
{ {
OWSMessageSender *messageSender = [Environment getCurrent].messageSender; OWSMessageSender *messageSender = [Environment current].messageSender;
DataSource *_Nullable dataSource = DataSource *_Nullable dataSource =
[DataSourceValue dataSourceWithData:[self createRandomNSDataOfSize:length] utiType:uti]; [DataSourceValue dataSourceWithData:[self createRandomNSDataOfSize:length] utiType:uti];
SignalAttachment *attachment = [SignalAttachment attachmentWithDataSource:dataSource dataUTI:uti]; SignalAttachment *attachment = [SignalAttachment attachmentWithDataSource:dataSource dataUTI:uti];
@ -1125,7 +1125,7 @@ NS_ASSUME_NONNULL_BEGIN
groupMetaMessage:TSGroupMessageNew]; groupMetaMessage:TSGroupMessageNew];
[message updateWithCustomMessage:NSLocalizedString(@"GROUP_CREATED", nil)]; [message updateWithCustomMessage:NSLocalizedString(@"GROUP_CREATED", nil)];
OWSMessageSender *messageSender = [Environment getCurrent].messageSender; OWSMessageSender *messageSender = [Environment current].messageSender;
void (^completion)(void) = ^{ void (^completion)(void) = ^{
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)1.f * NSEC_PER_SEC), dispatch_get_main_queue(), ^{ dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)1.f * NSEC_PER_SEC), dispatch_get_main_queue(), ^{
[ThreadUtil sendMessageWithText:[@(counter) description] inThread:thread messageSender:messageSender]; [ThreadUtil sendMessageWithText:[@(counter) description] inThread:thread messageSender:messageSender];

View File

@ -79,7 +79,7 @@ NS_ASSUME_NONNULL_BEGIN
{ {
DDLogInfo(@"%@ re-registering.", self.logTag); DDLogInfo(@"%@ re-registering.", self.logTag);
[[TSAccountManager sharedInstance] resetForRegistration]; [[TSAccountManager sharedInstance] resetForRegistration];
[[Environment getCurrent].preferences unsetRecordedAPNSTokens]; [[Environment current].preferences unsetRecordedAPNSTokens];
RegistrationViewController *viewController = [RegistrationViewController new]; RegistrationViewController *viewController = [RegistrationViewController new];
OWSNavigationController *navigationController = OWSNavigationController *navigationController =

View File

@ -13,7 +13,7 @@ class DebugUIProfile: DebugUIPage {
// MARK: Dependencies // MARK: Dependencies
var messageSender: MessageSender { var messageSender: MessageSender {
return Environment.getCurrent().messageSender return Environment.current().messageSender
} }
var profileManager: OWSProfileManager { var profileManager: OWSProfileManager {
return OWSProfileManager.shared() return OWSProfileManager.shared()

View File

@ -74,10 +74,9 @@ NS_ASSUME_NONNULL_BEGIN
}], }],
[OWSTableItem itemWithTitle:@"Send session reset" [OWSTableItem itemWithTitle:@"Send session reset"
actionBlock:^{ actionBlock:^{
[OWSSessionResetJob [OWSSessionResetJob runWithContactThread:thread
runWithContactThread:thread messageSender:[Environment current].messageSender
messageSender:[Environment getCurrent].messageSender storageManager:[TSStorageManager sharedManager]];
storageManager:[TSStorageManager sharedManager]];
}] }]
]]; ]];
} }

View File

@ -436,8 +436,8 @@ NS_ASSUME_NONNULL_BEGIN
+ (void)sendStressMessage:(TSOutgoingMessage *)message + (void)sendStressMessage:(TSOutgoingMessage *)message
{ {
OWSAssert(message); OWSAssert(message);
OWSMessageSender *messageSender = [Environment getCurrent].messageSender; OWSMessageSender *messageSender = [Environment current].messageSender;
[messageSender enqueueMessage:message [messageSender enqueueMessage:message
success:^{ success:^{
DDLogInfo(@"%@ Successfully sent message.", self.logTag); DDLogInfo(@"%@ Successfully sent message.", self.logTag);

View File

@ -8,9 +8,9 @@
#import "OWSTableViewController.h" #import "OWSTableViewController.h"
#import "Signal-Swift.h" #import "Signal-Swift.h"
#import "ThreadUtil.h" #import "ThreadUtil.h"
#import <Curve25519Kit/Randomness.h>
#import <AFNetworking/AFNetworking.h> #import <AFNetworking/AFNetworking.h>
#import <AxolotlKit/PreKeyBundle.h> #import <AxolotlKit/PreKeyBundle.h>
#import <Curve25519Kit/Randomness.h>
#import <SignalServiceKit/OWSBatchMessageProcessor.h> #import <SignalServiceKit/OWSBatchMessageProcessor.h>
#import <SignalServiceKit/OWSBlockingManager.h> #import <SignalServiceKit/OWSBlockingManager.h>
#import <SignalServiceKit/OWSDisappearingConfigurationUpdateInfoMessage.h> #import <SignalServiceKit/OWSDisappearingConfigurationUpdateInfoMessage.h>
@ -66,12 +66,12 @@ NS_ASSUME_NONNULL_BEGIN
+ (OWSMessageSender *)messageSender + (OWSMessageSender *)messageSender
{ {
return [Environment getCurrent].messageSender; return [Environment current].messageSender;
} }
+ (OWSContactsManager *)contactsManager + (OWSContactsManager *)contactsManager
{ {
return [Environment getCurrent].contactsManager; return [Environment current].contactsManager;
} }
+ (OWSIdentityManager *)identityManager + (OWSIdentityManager *)identityManager

View File

@ -144,7 +144,7 @@ typedef void (^CustomLayoutBlock)(void);
self.recipientId = recipientId; self.recipientId = recipientId;
OWSContactsManager *contactsManager = [Environment getCurrent].contactsManager; OWSContactsManager *contactsManager = [Environment current].contactsManager;
self.contactName = [contactsManager displayNameForPhoneIdentifier:recipientId]; self.contactName = [contactsManager displayNameForPhoneIdentifier:recipientId];
OWSRecipientIdentity *_Nullable recipientIdentity = OWSRecipientIdentity *_Nullable recipientIdentity =

View File

@ -41,7 +41,7 @@ NS_ASSUME_NONNULL_BEGIN
self.recipientId = recipientId; self.recipientId = recipientId;
self.accountManager = [TSAccountManager sharedInstance]; self.accountManager = [TSAccountManager sharedInstance];
OWSContactsManager *contactsManager = [Environment getCurrent].contactsManager; OWSContactsManager *contactsManager = [Environment current].contactsManager;
self.contactName = [contactsManager displayNameForPhoneIdentifier:recipientId]; self.contactName = [contactsManager displayNameForPhoneIdentifier:recipientId];
OWSRecipientIdentity *_Nullable recipientIdentity = OWSRecipientIdentity *_Nullable recipientIdentity =

View File

@ -13,6 +13,7 @@
#import "ProfileViewController.h" #import "ProfileViewController.h"
#import "PushManager.h" #import "PushManager.h"
#import "Signal-Swift.h" #import "Signal-Swift.h"
#import "SignalApp.h"
#import "TSAccountManager.h" #import "TSAccountManager.h"
#import "TSDatabaseView.h" #import "TSDatabaseView.h"
#import "TSGroupThread.h" #import "TSGroupThread.h"
@ -104,10 +105,10 @@ typedef NS_ENUM(NSInteger, CellState) { kArchiveState, kInboxState };
- (void)commonInit - (void)commonInit
{ {
_accountManager = [Environment getCurrent].accountManager; _accountManager = SignalApp.sharedApp.accountManager;
_contactsManager = [Environment getCurrent].contactsManager; _contactsManager = [Environment current].contactsManager;
_messagesManager = [OWSMessageManager sharedManager]; _messagesManager = [OWSMessageManager sharedManager];
_messageSender = [Environment getCurrent].messageSender; _messageSender = [Environment current].messageSender;
_blockingManager = [OWSBlockingManager sharedManager]; _blockingManager = [OWSBlockingManager sharedManager];
_blockedPhoneNumberSet = [NSSet setWithArray:[_blockingManager blockedPhoneNumbers]]; _blockedPhoneNumberSet = [NSSet setWithArray:[_blockingManager blockedPhoneNumbers]];
@ -175,7 +176,7 @@ typedef NS_ENUM(NSInteger, CellState) { kArchiveState, kInboxState };
self.view.backgroundColor = [UIColor whiteColor]; self.view.backgroundColor = [UIColor whiteColor];
// TODO: Remove this. // TODO: Remove this.
[[Environment getCurrent] setHomeViewController:self]; [SignalApp.sharedApp setHomeViewController:self];
self.navigationItem.rightBarButtonItem = self.navigationItem.rightBarButtonItem =
[[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemCompose [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemCompose
@ -628,7 +629,7 @@ typedef NS_ENUM(NSInteger, CellState) { kArchiveState, kInboxState };
{ {
OWSAssert([NSThread isMainThread]); OWSAssert([NSThread isMainThread]);
DDLogInfo(@"%@ beggining refreshing.", self.logTag); DDLogInfo(@"%@ beggining refreshing.", self.logTag);
[[Environment getCurrent].messageFetcherJob run].always(^{ [SignalApp.sharedApp.messageFetcherJob run].always(^{
DDLogInfo(@"%@ ending refreshing.", self.logTag); DDLogInfo(@"%@ ending refreshing.", self.logTag);
[refreshControl endRefreshing]; [refreshControl endRefreshing];
}); });

View File

@ -315,7 +315,7 @@ class MediaMessageView: UIView, OWSAudioAttachmentPlayerDelegate {
return nil return nil
} }
let filename = sourceFilename.trimmingCharacters(in: CharacterSet.whitespacesAndNewlines) let filename = sourceFilename.trimmingCharacters(in: CharacterSet.whitespacesAndNewlines)
guard filename.characters.count > 0 else { guard filename.count > 0 else {
return nil return nil
} }
return filename return filename
@ -342,7 +342,7 @@ class MediaMessageView: UIView, OWSAudioAttachmentPlayerDelegate {
let fileSize = attachment.dataLength let fileSize = attachment.dataLength
label.text = String(format: NSLocalizedString("ATTACHMENT_APPROVAL_FILE_SIZE_FORMAT", label.text = String(format: NSLocalizedString("ATTACHMENT_APPROVAL_FILE_SIZE_FORMAT",
comment: "Format string for file size label in call interstitial view. Embeds: {{file size as 'N mb' or 'N kb'}}."), comment: "Format string for file size label in call interstitial view. Embeds: {{file size as 'N mb' or 'N kb'}}."),
ViewControllerUtils.formatFileSize(UInt(fileSize))) OWSFormat.formatFileSize(UInt(fileSize)))
label.textColor = UIColor.ows_materialBlue() label.textColor = UIColor.ows_materialBlue()
label.font = labelFont() label.font = labelFont()

View File

@ -56,7 +56,7 @@ class MessageDetailViewController: OWSViewController, UIScrollViewDelegate {
} }
required init(viewItem: ConversationViewItem, message: TSMessage, mode: MessageMetadataViewMode) { required init(viewItem: ConversationViewItem, message: TSMessage, mode: MessageMetadataViewMode) {
self.contactsManager = Environment.getCurrent().contactsManager self.contactsManager = Environment.current().contactsManager
self.viewItem = viewItem self.viewItem = viewItem
self.message = message self.message = message
self.mode = mode self.mode = mode
@ -182,7 +182,7 @@ class MessageDetailViewController: OWSViewController, UIScrollViewDelegate {
} }
var rows = [UIView]() var rows = [UIView]()
let contactsManager = Environment.getCurrent().contactsManager! let contactsManager = Environment.current().contactsManager!
let thread = message.thread let thread = message.thread
// Content // Content
@ -314,7 +314,7 @@ class MessageDetailViewController: OWSViewController, UIScrollViewDelegate {
return nil return nil
} }
let messageBody = displayableText.fullText let messageBody = displayableText.fullText
guard messageBody.characters.count > 0 else { guard messageBody.count > 0 else {
return nil return nil
} }
return messageBody return messageBody
@ -466,7 +466,7 @@ class MessageDetailViewController: OWSViewController, UIScrollViewDelegate {
let fileSize = dataSource.dataLength() let fileSize = dataSource.dataLength()
rows.append(valueRow(name: NSLocalizedString("MESSAGE_METADATA_VIEW_ATTACHMENT_FILE_SIZE", rows.append(valueRow(name: NSLocalizedString("MESSAGE_METADATA_VIEW_ATTACHMENT_FILE_SIZE",
comment: "Label for file size of attachments in the 'message metadata' view."), comment: "Label for file size of attachments in the 'message metadata' view."),
value: ViewControllerUtils.formatFileSize(UInt(fileSize)))) value: OWSFormat.formatFileSize(UInt(fileSize))))
} }
return rows return rows
@ -502,7 +502,7 @@ class MessageDetailViewController: OWSViewController, UIScrollViewDelegate {
nameLabel.autoPinEdge(toSuperviewEdge: .top) nameLabel.autoPinEdge(toSuperviewEdge: .top)
valueLabel.autoPinEdge(toSuperviewEdge: .top) valueLabel.autoPinEdge(toSuperviewEdge: .top)
if subtitle.characters.count > 0 { if subtitle.count > 0 {
let subtitleLabel = self.valueLabel(text: subtitle) let subtitleLabel = self.valueLabel(text: subtitle)
subtitleLabel.textColor = UIColor.ows_darkGray() subtitleLabel.textColor = UIColor.ows_darkGray()
row.addSubview(subtitleLabel) row.addSubview(subtitleLabel)
@ -510,7 +510,7 @@ class MessageDetailViewController: OWSViewController, UIScrollViewDelegate {
subtitleLabel.autoPinLeading(toTrailingOf: nameLabel, margin: 10) subtitleLabel.autoPinLeading(toTrailingOf: nameLabel, margin: 10)
subtitleLabel.autoPinEdge(.top, to: .bottom, of: valueLabel, withOffset: 1) subtitleLabel.autoPinEdge(.top, to: .bottom, of: valueLabel, withOffset: 1)
subtitleLabel.autoPinEdge(toSuperviewEdge: .bottom) subtitleLabel.autoPinEdge(toSuperviewEdge: .bottom)
} else if value.characters.count > 0 { } else if value.count > 0 {
valueLabel.autoPinEdge(toSuperviewEdge: .bottom) valueLabel.autoPinEdge(toSuperviewEdge: .bottom)
} else { } else {
nameLabel.autoPinEdge(toSuperviewEdge: .bottom) nameLabel.autoPinEdge(toSuperviewEdge: .bottom)

View File

@ -32,7 +32,7 @@ NS_ASSUME_NONNULL_BEGIN
- (NSString *)stringForCollation - (NSString *)stringForCollation
{ {
OWSContactsManager *contactsManager = [Environment getCurrent].contactsManager; OWSContactsManager *contactsManager = [Environment current].contactsManager;
return [contactsManager comparableNameForSignalAccount:self]; return [contactsManager comparableNameForSignalAccount:self];
} }

View File

@ -86,7 +86,7 @@ const NSUInteger kNewGroupViewControllerAvatarWidth = 68;
- (void)commonInit - (void)commonInit
{ {
_messageSender = [Environment getCurrent].messageSender; _messageSender = [Environment current].messageSender;
_contactsViewHelper = [[ContactsViewHelper alloc] initWithDelegate:self]; _contactsViewHelper = [[ContactsViewHelper alloc] initWithDelegate:self];
_avatarViewHelper = [AvatarViewHelper new]; _avatarViewHelper = [AvatarViewHelper new];
_avatarViewHelper.delegate = self; _avatarViewHelper.delegate = self;

View File

@ -63,7 +63,7 @@ NS_ASSUME_NONNULL_BEGIN
- (void)commonInit - (void)commonInit
{ {
_contactsManager = [Environment getCurrent].contactsManager; _contactsManager = [Environment current].contactsManager;
_contactsViewHelper = [[ContactsViewHelper alloc] initWithDelegate:self]; _contactsViewHelper = [[ContactsViewHelper alloc] initWithDelegate:self];
} }

View File

@ -11,7 +11,6 @@
#import "OWSAvatarBuilder.h" #import "OWSAvatarBuilder.h"
#import "OWSBlockingManager.h" #import "OWSBlockingManager.h"
#import "OWSContactsManager.h" #import "OWSContactsManager.h"
#import "OWSProfileManager.h"
#import "PhoneNumber.h" #import "PhoneNumber.h"
#import "ShowGroupMembersViewController.h" #import "ShowGroupMembersViewController.h"
#import "Signal-Swift.h" #import "Signal-Swift.h"
@ -20,6 +19,7 @@
#import "UIView+OWS.h" #import "UIView+OWS.h"
#import "UpdateGroupViewController.h" #import "UpdateGroupViewController.h"
#import <Curve25519Kit/Curve25519.h> #import <Curve25519Kit/Curve25519.h>
#import <SignalMessaging/OWSProfileManager.h>
#import <SignalServiceKit/NSDate+OWS.h> #import <SignalServiceKit/NSDate+OWS.h>
#import <SignalServiceKit/OWSDisappearingConfigurationUpdateInfoMessage.h> #import <SignalServiceKit/OWSDisappearingConfigurationUpdateInfoMessage.h>
#import <SignalServiceKit/OWSDisappearingMessagesConfiguration.h> #import <SignalServiceKit/OWSDisappearingMessagesConfiguration.h>
@ -94,8 +94,8 @@ NS_ASSUME_NONNULL_BEGIN
- (void)commonInit - (void)commonInit
{ {
_accountManager = [TSAccountManager sharedInstance]; _accountManager = [TSAccountManager sharedInstance];
_contactsManager = [Environment getCurrent].contactsManager; _contactsManager = [Environment current].contactsManager;
_messageSender = [Environment getCurrent].messageSender; _messageSender = [Environment current].messageSender;
_blockingManager = [OWSBlockingManager sharedManager]; _blockingManager = [OWSBlockingManager sharedManager];
_contactsViewHelper = [[ContactsViewHelper alloc] initWithDelegate:self]; _contactsViewHelper = [[ContactsViewHelper alloc] initWithDelegate:self];

View File

@ -6,8 +6,8 @@
#import "Cryptography.h" #import "Cryptography.h"
#import "OWSDeviceProvisioningURLParser.h" #import "OWSDeviceProvisioningURLParser.h"
#import "OWSLinkedDevicesTableViewController.h" #import "OWSLinkedDevicesTableViewController.h"
#import "OWSProfileManager.h"
#import "Signal-Swift.h" #import "Signal-Swift.h"
#import <SignalMessaging/OWSProfileManager.h>
#import <SignalServiceKit/ECKeyPair+OWSPrivateKey.h> #import <SignalServiceKit/ECKeyPair+OWSPrivateKey.h>
#import <SignalServiceKit/OWSDevice.h> #import <SignalServiceKit/OWSDevice.h>
#import <SignalServiceKit/OWSDeviceProvisioner.h> #import <SignalServiceKit/OWSDeviceProvisioner.h>

View File

@ -164,15 +164,15 @@ NS_ASSUME_NONNULL_BEGIN
- (void)didToggleEnableCallKitSwitch:(UISwitch *)sender { - (void)didToggleEnableCallKitSwitch:(UISwitch *)sender {
DDLogInfo(@"%@ user toggled call kit preference: %@", self.logTag, (sender.isOn ? @"ON" : @"OFF")); DDLogInfo(@"%@ user toggled call kit preference: %@", self.logTag, (sender.isOn ? @"ON" : @"OFF"));
[[Environment getCurrent].preferences setIsCallKitEnabled:sender.isOn]; [[Environment current].preferences setIsCallKitEnabled:sender.isOn];
// rebuild callUIAdapter since CallKit vs not changed. // rebuild callUIAdapter since CallKit vs not changed.
[[Environment getCurrent].callService createCallUIAdapter]; [SignalApp.sharedApp.callService createCallUIAdapter];
[self updateTableContents]; [self updateTableContents];
} }
- (void)didToggleEnableCallKitPrivacySwitch:(UISwitch *)sender { - (void)didToggleEnableCallKitPrivacySwitch:(UISwitch *)sender {
DDLogInfo(@"%@ user toggled call kit privacy preference: %@", self.logTag, (sender.isOn ? @"ON" : @"OFF")); DDLogInfo(@"%@ user toggled call kit privacy preference: %@", self.logTag, (sender.isOn ? @"ON" : @"OFF"));
[[Environment getCurrent].preferences setIsCallKitPrivacyEnabled:!sender.isOn]; [[Environment current].preferences setIsCallKitPrivacyEnabled:!sender.isOn];
} }
#pragma mark - Log util #pragma mark - Log util

View File

@ -8,13 +8,13 @@
#import "HomeViewController.h" #import "HomeViewController.h"
#import "NSString+OWS.h" #import "NSString+OWS.h"
#import "OWSNavigationController.h" #import "OWSNavigationController.h"
#import "OWSProfileManager.h"
#import "Signal-Swift.h" #import "Signal-Swift.h"
#import "SignalsNavigationController.h" #import "SignalsNavigationController.h"
#import "UIColor+OWS.h" #import "UIColor+OWS.h"
#import "UIFont+OWS.h" #import "UIFont+OWS.h"
#import "UIView+OWS.h" #import "UIView+OWS.h"
#import "UIViewController+OWS.h" #import "UIViewController+OWS.h"
#import <SignalMessaging/OWSProfileManager.h>
#import <SignalServiceKit/NSDate+OWS.h> #import <SignalServiceKit/NSDate+OWS.h>
#import <SignalServiceKit/TSStorageManager.h> #import <SignalServiceKit/TSStorageManager.h>

View File

@ -50,7 +50,7 @@ NSString *const kKeychainKey_LastRegisteredPhoneNumber = @"kKeychainKey_LastRegi
// Do any additional setup after loading the view. // Do any additional setup after loading the view.
[self populateDefaultCountryNameAndCode]; [self populateDefaultCountryNameAndCode];
[[Environment getCurrent] setSignUpFlowNavigationController:self.navigationController]; [[Environment current] setSignUpFlowNavigationController:self.navigationController];
} }
- (void)viewDidLoad { - (void)viewDidLoad {

View File

@ -38,8 +38,8 @@ NS_ASSUME_NONNULL_BEGIN
{ {
[super loadView]; [super loadView];
_contactsManager = [Environment getCurrent].contactsManager; _contactsManager = [Environment current].contactsManager;
_messageSender = [Environment getCurrent].messageSender; _messageSender = [Environment current].messageSender;
self.title = NSLocalizedString(@"SEND_EXTERNAL_FILE_VIEW_TITLE", @"Title for the 'send external file' view."); self.title = NSLocalizedString(@"SEND_EXTERNAL_FILE_VIEW_TITLE", @"Title for the 'send external file' view.");
} }

View File

@ -84,7 +84,7 @@ NS_ASSUME_NONNULL_BEGIN
- (void)commonInit - (void)commonInit
{ {
_messageSender = [Environment getCurrent].messageSender; _messageSender = [Environment current].messageSender;
_contactsViewHelper = [[ContactsViewHelper alloc] initWithDelegate:self]; _contactsViewHelper = [[ContactsViewHelper alloc] initWithDelegate:self];
_avatarViewHelper = [AvatarViewHelper new]; _avatarViewHelper = [AvatarViewHelper new];
_avatarViewHelper.delegate = self; _avatarViewHelper.delegate = self;

View File

@ -304,7 +304,7 @@ protocol CallServiceObserver: class {
throw CallError.assertionError(description: errorDescription) throw CallError.assertionError(description: errorDescription)
} }
let useTurnOnly = Environment.getCurrent().preferences.doCallsHideIPAddress() let useTurnOnly = Environment.current().preferences.doCallsHideIPAddress()
let peerConnectionClient = PeerConnectionClient(iceServers: iceServers, delegate: self, callDirection: .outgoing, useTurnOnly: useTurnOnly) let peerConnectionClient = PeerConnectionClient(iceServers: iceServers, delegate: self, callDirection: .outgoing, useTurnOnly: useTurnOnly)
Logger.debug("\(self.TAG) setting peerConnectionClient in \(#function) for call: \(call.identifiersForLogs)") Logger.debug("\(self.TAG) setting peerConnectionClient in \(#function) for call: \(call.identifiersForLogs)")
@ -609,7 +609,7 @@ protocol CallServiceObserver: class {
// a TURN connection, so as not to reveal any connectivity information (IP/port) to the caller. // a TURN connection, so as not to reveal any connectivity information (IP/port) to the caller.
let unknownCaller = self.contactsManager.signalAccount(forRecipientId: thread.contactIdentifier()) == nil let unknownCaller = self.contactsManager.signalAccount(forRecipientId: thread.contactIdentifier()) == nil
let useTurnOnly = unknownCaller || Environment.getCurrent().preferences.doCallsHideIPAddress() let useTurnOnly = unknownCaller || Environment.current().preferences.doCallsHideIPAddress()
Logger.debug("\(self.TAG) setting peerConnectionClient in \(#function) for: \(newCall.identifiersForLogs)") Logger.debug("\(self.TAG) setting peerConnectionClient in \(#function) for: \(newCall.identifiersForLogs)")
let peerConnectionClient = PeerConnectionClient(iceServers: iceServers, delegate: self, callDirection: .incoming, useTurnOnly: useTurnOnly) let peerConnectionClient = PeerConnectionClient(iceServers: iceServers, delegate: self, callDirection: .incoming, useTurnOnly: useTurnOnly)

View File

@ -42,7 +42,7 @@ import SignalMessaging
public func initiateCall(recipientId: String) -> Bool { public func initiateCall(recipientId: String) -> Bool {
// Rather than an init-assigned dependency property, we access `callUIAdapter` via Environment // Rather than an init-assigned dependency property, we access `callUIAdapter` via Environment
// because it can change after app launch due to user settings // because it can change after app launch due to user settings
guard let callUIAdapter = Environment.getCurrent().callUIAdapter else { guard let callUIAdapter = SignalApp.shared().callUIAdapter else {
owsFail("\(TAG) can't initiate call because callUIAdapter is nil") owsFail("\(TAG) can't initiate call because callUIAdapter is nil")
return false return false
} }

View File

@ -794,12 +794,12 @@ class HardenedRTCSessionDescription {
// Enforce Constant bit rate. // Enforce Constant bit rate.
let cbrRegex = try! NSRegularExpression(pattern:"(a=fmtp:111 ((?!cbr=).)*)\r?\n", options:.caseInsensitive) let cbrRegex = try! NSRegularExpression(pattern:"(a=fmtp:111 ((?!cbr=).)*)\r?\n", options:.caseInsensitive)
description = cbrRegex.stringByReplacingMatches(in: description, options: [], range: NSMakeRange(0, description.characters.count), withTemplate: "$1;cbr=1\r\n") description = cbrRegex.stringByReplacingMatches(in: description, options: [], range: NSMakeRange(0, description.count), withTemplate: "$1;cbr=1\r\n")
// Strip plaintext audio-level details // Strip plaintext audio-level details
// https://tools.ietf.org/html/rfc6464 // https://tools.ietf.org/html/rfc6464
let audioLevelRegex = try! NSRegularExpression(pattern:".+urn:ietf:params:rtp-hdrext:ssrc-audio-level.*\r?\n", options:.caseInsensitive) let audioLevelRegex = try! NSRegularExpression(pattern:".+urn:ietf:params:rtp-hdrext:ssrc-audio-level.*\r?\n", options:.caseInsensitive)
description = audioLevelRegex.stringByReplacingMatches(in: description, options: [], range: NSMakeRange(0, description.characters.count), withTemplate: "") description = audioLevelRegex.stringByReplacingMatches(in: description, options: [], range: NSMakeRange(0, description.count), withTemplate: "")
return RTCSessionDescription.init(type: rtcSessionDescription.type, sdp: description) return RTCSessionDescription.init(type: rtcSessionDescription.type, sdp: description)
} }

View File

@ -25,7 +25,7 @@ final class CallKitCallManager: NSObject {
func startCall(_ call: SignalCall) { func startCall(_ call: SignalCall) {
var handle: CXHandle var handle: CXHandle
if Environment.getCurrent().preferences.isCallKitPrivacyEnabled() { if Environment.current().preferences.isCallKitPrivacyEnabled() {
let callKitId = CallKitCallManager.kAnonymousCallHandlePrefix + call.localId.uuidString let callKitId = CallKitCallManager.kAnonymousCallHandlePrefix + call.localId.uuidString
handle = CXHandle(type: .generic, value: callKitId) handle = CXHandle(type: .generic, value: callKitId)
TSStorageManager.shared().setPhoneNumber(call.remotePhoneNumber, forCallKitId:callKitId) TSStorageManager.shared().setPhoneNumber(call.remotePhoneNumber, forCallKitId:callKitId)

View File

@ -103,7 +103,7 @@ final class CallKitCallUIAdaptee: NSObject, CallUIAdaptee, CXProviderDelegate {
// Construct a CXCallUpdate describing the incoming call, including the caller. // Construct a CXCallUpdate describing the incoming call, including the caller.
let update = CXCallUpdate() let update = CXCallUpdate()
if Environment.getCurrent().preferences.isCallKitPrivacyEnabled() { if Environment.current().preferences.isCallKitPrivacyEnabled() {
let callKitId = CallKitCallManager.kAnonymousCallHandlePrefix + call.localId.uuidString let callKitId = CallKitCallManager.kAnonymousCallHandlePrefix + call.localId.uuidString
update.remoteHandle = CXHandle(type: .generic, value: callKitId) update.remoteHandle = CXHandle(type: .generic, value: callKitId)
TSStorageManager.shared().setPhoneNumber(call.remotePhoneNumber, forCallKitId:callKitId) TSStorageManager.shared().setPhoneNumber(call.remotePhoneNumber, forCallKitId:callKitId)
@ -245,7 +245,7 @@ final class CallKitCallUIAdaptee: NSObject, CallUIAdaptee, CXProviderDelegate {
action.fulfill() action.fulfill()
self.provider.reportOutgoingCall(with: call.localId, startedConnectingAt: nil) self.provider.reportOutgoingCall(with: call.localId, startedConnectingAt: nil)
if Environment.getCurrent().preferences.isCallKitPrivacyEnabled() { if Environment.current().preferences.isCallKitPrivacyEnabled() {
// Update the name used in the CallKit UI for outgoing calls. // Update the name used in the CallKit UI for outgoing calls.
let update = CXCallUpdate() let update = CXCallUpdate()
update.localizedCallerName = NSLocalizedString("CALLKIT_ANONYMOUS_CONTACT_NAME", update.localizedCallerName = NSLocalizedString("CALLKIT_ANONYMOUS_CONTACT_NAME",

View File

@ -39,7 +39,7 @@ extension CallUIAdaptee {
let callViewController = CallViewController(call: call) let callViewController = CallViewController(call: call)
callViewController.modalTransitionStyle = .crossDissolve callViewController.modalTransitionStyle = .crossDissolve
guard let presentingViewController = Environment.getCurrent().homeViewController else { guard let presentingViewController = UIApplication.shared.frontmostViewControllerIgnoringAlerts else {
owsFail("in \(#function) view controller unexpectedly nil") owsFail("in \(#function) view controller unexpectedly nil")
return return
} }
@ -91,7 +91,7 @@ extension CallUIAdaptee {
// So we use the non-CallKit call UI. // So we use the non-CallKit call UI.
Logger.info("\(TAG) choosing non-callkit adaptee for simulator.") Logger.info("\(TAG) choosing non-callkit adaptee for simulator.")
adaptee = NonCallKitCallUIAdaptee(callService: callService, notificationsAdapter: notificationsAdapter) adaptee = NonCallKitCallUIAdaptee(callService: callService, notificationsAdapter: notificationsAdapter)
} else if #available(iOS 10.0, *), Environment.getCurrent().preferences.isCallKitEnabled() { } else if #available(iOS 10.0, *), Environment.current().preferences.isCallKitEnabled() {
Logger.info("\(TAG) choosing callkit adaptee for iOS10+") Logger.info("\(TAG) choosing callkit adaptee for iOS10+")
adaptee = CallKitCallUIAdaptee(callService: callService, contactsManager: contactsManager, notificationsAdapter: notificationsAdapter) adaptee = CallKitCallUIAdaptee(callService: callService, contactsManager: contactsManager, notificationsAdapter: notificationsAdapter)
} else { } else {

View File

@ -90,7 +90,7 @@ class OWS106EnsureProfileComplete: OWSDatabaseMigration {
let (promise, fulfill, reject) = Promise<Void>.pending() let (promise, fulfill, reject) = Promise<Void>.pending()
guard let networkManager = Environment.getCurrent().networkManager else { guard let networkManager = Environment.current().networkManager else {
owsFail("\(TAG) network manager was unexpectedly not set") owsFail("\(TAG) network manager was unexpectedly not set")
return Promise(error: OWSErrorMakeAssertionError()) return Promise(error: OWSErrorMakeAssertionError())
} }

View File

@ -3,6 +3,7 @@
// //
#import "OWSDatabaseMigrationRunner.h" #import "OWSDatabaseMigrationRunner.h"
#import "OWS104CreateRecipientIdentities.h"
#import "OWSDatabaseMigration.h" #import "OWSDatabaseMigration.h"
#import "Signal-Swift.h" #import "Signal-Swift.h"
#import <SignalServiceKit/AppContext.h> #import <SignalServiceKit/AppContext.h>

View File

@ -116,9 +116,9 @@ NSString *const kNotificationsManagerNewMesssageSoundName = @"NewMessage.aifc";
case NotificationNameNoPreview: case NotificationNameNoPreview:
case NotificationNamePreview: { case NotificationNamePreview: {
alertMessage = (([UIDevice currentDevice].supportsCallKit && alertMessage = (([UIDevice currentDevice].supportsCallKit &&
[[Environment getCurrent].preferences isCallKitPrivacyEnabled]) [[Environment current].preferences isCallKitPrivacyEnabled])
? [CallStrings missedCallNotificationBodyWithoutCallerName] ? [CallStrings missedCallNotificationBodyWithoutCallerName]
: [NSString stringWithFormat:[CallStrings missedCallNotificationBodyWithCallerName], callerName]); : [NSString stringWithFormat:[CallStrings missedCallNotificationBodyWithCallerName], callerName]);
break; break;
} }
} }
@ -155,7 +155,7 @@ NSString *const kNotificationsManagerNewMesssageSoundName = @"NewMessage.aifc";
case NotificationNameNoPreview: case NotificationNameNoPreview:
case NotificationNamePreview: { case NotificationNamePreview: {
alertMessage = (([UIDevice currentDevice].supportsCallKit && alertMessage = (([UIDevice currentDevice].supportsCallKit &&
[[Environment getCurrent].preferences isCallKitPrivacyEnabled]) [[Environment current].preferences isCallKitPrivacyEnabled])
? [CallStrings missedCallWithIdentityChangeNotificationBodyWithoutCallerName] ? [CallStrings missedCallWithIdentityChangeNotificationBodyWithoutCallerName]
: [NSString : [NSString
stringWithFormat:[CallStrings missedCallWithIdentityChangeNotificationBodyWithCallerName], stringWithFormat:[CallStrings missedCallWithIdentityChangeNotificationBodyWithCallerName],
@ -195,7 +195,7 @@ NSString *const kNotificationsManagerNewMesssageSoundName = @"NewMessage.aifc";
case NotificationNameNoPreview: case NotificationNameNoPreview:
case NotificationNamePreview: { case NotificationNamePreview: {
alertMessage = (([UIDevice currentDevice].supportsCallKit && alertMessage = (([UIDevice currentDevice].supportsCallKit &&
[[Environment getCurrent].preferences isCallKitPrivacyEnabled]) [[Environment current].preferences isCallKitPrivacyEnabled])
? [CallStrings missedCallWithIdentityChangeNotificationBodyWithoutCallerName] ? [CallStrings missedCallWithIdentityChangeNotificationBodyWithoutCallerName]
: [NSString : [NSString
stringWithFormat:[CallStrings missedCallWithIdentityChangeNotificationBodyWithCallerName], stringWithFormat:[CallStrings missedCallWithIdentityChangeNotificationBodyWithCallerName],
@ -387,7 +387,7 @@ NSString *const kNotificationsManagerNewMesssageSoundName = @"NewMessage.aifc";
- (NotificationType)notificationPreviewType - (NotificationType)notificationPreviewType
{ {
OWSPreferences *prefs = [Environment getCurrent].preferences; OWSPreferences *prefs = [Environment current].preferences;
return prefs.notificationPreviewType; return prefs.notificationPreviewType;
} }

View File

@ -14,7 +14,9 @@
@interface SignalApp : NSObject @interface SignalApp : NSObject
@property (nonatomic) HomeViewController *homeViewController; @property (nonatomic, weak) HomeViewController *homeViewController;
// TODO: Convert to singletons?
@property (nonatomic, readonly) OWSWebRTCCallMessageHandler *callMessageHandler; @property (nonatomic, readonly) OWSWebRTCCallMessageHandler *callMessageHandler;
@property (nonatomic, readonly) CallService *callService; @property (nonatomic, readonly) CallService *callService;
@property (nonatomic, readonly) CallUIAdapter *callUIAdapter; @property (nonatomic, readonly) CallUIAdapter *callUIAdapter;

View File

@ -6,6 +6,8 @@
#import "ConversationViewController.h" #import "ConversationViewController.h"
#import "HomeViewController.h" #import "HomeViewController.h"
#import "Signal-Swift.h" #import "Signal-Swift.h"
#import <SignalMessaging/DebugLogger.h>
#import <SignalMessaging/Environment.h>
#import <SignalServiceKit/TSContactThread.h> #import <SignalServiceKit/TSContactThread.h>
#import <SignalServiceKit/TSGroupThread.h> #import <SignalServiceKit/TSGroupThread.h>
#import <SignalServiceKit/TSStorageManager.h> #import <SignalServiceKit/TSStorageManager.h>
@ -56,9 +58,10 @@
@synchronized(self) @synchronized(self)
{ {
if (!_callMessageHandler) { if (!_callMessageHandler) {
_callMessageHandler = [[OWSWebRTCCallMessageHandler alloc] initWithAccountManager:self.accountManager _callMessageHandler =
callService:self.callService [[OWSWebRTCCallMessageHandler alloc] initWithAccountManager:self.accountManager
messageSender:self.messageSender]; callService:self.callService
messageSender:Environment.current.messageSender];
} }
} }
@ -71,11 +74,11 @@
{ {
if (!_callService) { if (!_callService) {
OWSAssert(self.accountManager); OWSAssert(self.accountManager);
OWSAssert(self.contactsManager); OWSAssert(Environment.current.contactsManager);
OWSAssert(self.messageSender); OWSAssert(Environment.current.messageSender);
_callService = [[CallService alloc] initWithAccountManager:self.accountManager _callService = [[CallService alloc] initWithAccountManager:self.accountManager
contactsManager:self.contactsManager contactsManager:Environment.current.contactsManager
messageSender:self.messageSender messageSender:Environment.current.messageSender
notificationsAdapter:[OWSCallNotificationsAdapter new]]; notificationsAdapter:[OWSCallNotificationsAdapter new]];
} }
} }
@ -93,10 +96,11 @@
@synchronized(self) @synchronized(self)
{ {
if (!_outboundCallInitiator) { if (!_outboundCallInitiator) {
OWSAssert(self.contactsManager); OWSAssert(Environment.current.contactsManager);
OWSAssert(self.contactsUpdater); OWSAssert(Environment.current.contactsUpdater);
_outboundCallInitiator = [[OutboundCallInitiator alloc] initWithContactsManager:self.contactsManager _outboundCallInitiator =
contactsUpdater:self.contactsUpdater]; [[OutboundCallInitiator alloc] initWithContactsManager:Environment.current.contactsManager
contactsUpdater:Environment.current.contactsUpdater];
} }
} }
@ -110,7 +114,7 @@
if (!_messageFetcherJob) { if (!_messageFetcherJob) {
_messageFetcherJob = _messageFetcherJob =
[[OWSMessageFetcherJob alloc] initWithMessageReceiver:[OWSMessageReceiver sharedInstance] [[OWSMessageFetcherJob alloc] initWithMessageReceiver:[OWSMessageReceiver sharedInstance]
networkManager:self.networkManager networkManager:Environment.current.networkManager
signalService:[OWSSignalService sharedInstance]]; signalService:[OWSSignalService sharedInstance]];
} }
} }
@ -135,7 +139,7 @@
{ {
if (!_accountManager) { if (!_accountManager) {
_accountManager = [[AccountManager alloc] initWithTextSecureAccountManager:[TSAccountManager sharedInstance] _accountManager = [[AccountManager alloc] initWithTextSecureAccountManager:[TSAccountManager sharedInstance]
preferences:self.preferences]; preferences:Environment.current.preferences];
} }
} }

View File

@ -31,7 +31,7 @@
{ {
// performUpdateCheck must be invoked after Environment has been initialized because // performUpdateCheck must be invoked after Environment has been initialized because
// upgrade process may depend on Environment. // upgrade process may depend on Environment.
OWSAssert([Environment getCurrent]); OWSAssert([Environment current]);
NSString *previousVersion = AppVersion.instance.lastAppVersion; NSString *previousVersion = AppVersion.instance.lastAppVersion;
NSString *currentVersion = AppVersion.instance.currentAppVersion; NSString *currentVersion = AppVersion.instance.currentAppVersion;

View File

@ -375,7 +375,7 @@ extension GiphyError: LocalizedError {
Logger.warn("\(TAG) Image dict missing id.") Logger.warn("\(TAG) Image dict missing id.")
return nil return nil
} }
guard giphyId.characters.count > 0 else { guard giphyId.count > 0 else {
Logger.warn("\(TAG) Image dict has invalid id.") Logger.warn("\(TAG) Image dict has invalid id.")
return nil return nil
} }
@ -433,7 +433,7 @@ extension GiphyError: LocalizedError {
guard let urlString = renditionDict["url"] as? String else { guard let urlString = renditionDict["url"] as? String else {
return nil return nil
} }
guard urlString.characters.count > 0 else { guard urlString.count > 0 else {
Logger.warn("\(TAG) Rendition has invalid url.") Logger.warn("\(TAG) Rendition has invalid url.")
return nil return nil
} }

View File

@ -54,11 +54,11 @@ NSString *const Signal_Message_MarkAsRead_Identifier = @"Signal_Message_MarkAsRe
- (instancetype)initDefault - (instancetype)initDefault
{ {
return [self initWithMessageFetcherJob:[Environment getCurrent].messageFetcherJob return [self initWithMessageFetcherJob:SignalApp.sharedApp.messageFetcherJob
storageManager:[TSStorageManager sharedManager] storageManager:[TSStorageManager sharedManager]
callUIAdapter:[Environment getCurrent].callService.callUIAdapter callUIAdapter:SignalApp.sharedApp.callService.callUIAdapter
messageSender:[Environment getCurrent].messageSender messageSender:[Environment current].messageSender
notificationsManager:[Environment getCurrent].notificationsManager]; notificationsManager:SignalApp.sharedApp.notificationsManager];
} }
- (instancetype)initWithMessageFetcherJob:(OWSMessageFetcherJob *)messageFetcherJob - (instancetype)initWithMessageFetcherJob:(OWSMessageFetcherJob *)messageFetcherJob
@ -276,7 +276,7 @@ NSString *const Signal_Message_MarkAsRead_Identifier = @"Signal_Message_MarkAsRe
[thread markAllAsReadWithTransaction:transaction]; [thread markAllAsReadWithTransaction:transaction];
} }
completionBlock:^{ completionBlock:^{
[[[Environment getCurrent] homeViewController] updateInboxCountLabel]; [SignalApp.sharedApp.homeViewController updateInboxCountLabel];
[self cancelNotificationsWithThreadId:threadId]; [self cancelNotificationsWithThreadId:threadId];
completionHandler(); completionHandler();

View File

@ -185,7 +185,7 @@ extension String {
if string == "" { if string == "" {
return 0 return 0
} }
if string.characters.count > Int(kMaxJumbomojiCount * kMaxCharactersPerEmojiCount) { if string.count > Int(kMaxJumbomojiCount * kMaxCharactersPerEmojiCount) {
return 0 return 0
} }
guard string.containsOnlyEmoji else { guard string.containsOnlyEmoji else {

View File

@ -6,9 +6,11 @@
#import "OWS100RemoveTSRecipientsMigration.h" #import "OWS100RemoveTSRecipientsMigration.h"
#import "OWS102MoveLoggingPreferenceToUserDefaults.h" #import "OWS102MoveLoggingPreferenceToUserDefaults.h"
#import "OWS103EnableVideoCalling.h" #import "OWS103EnableVideoCalling.h"
#import "OWS104CreateRecipientIdentities.h"
#import "OWS105AttachmentFilePaths.h" #import "OWS105AttachmentFilePaths.h"
#import "Signal-Swift.h" #import "Signal-Swift.h"
#import <SignalMessaging/Environment.h>
#import <SignalMessaging/OWSProfileManager.h>
#import <SignalServiceKit/OWSIdentityManager.h>
NS_ASSUME_NONNULL_BEGIN NS_ASSUME_NONNULL_BEGIN
@ -53,13 +55,14 @@ NS_ASSUME_NONNULL_BEGIN
- (NSArray<OWSDatabaseMigration *> *)allMigrations - (NSArray<OWSDatabaseMigration *> *)allMigrations
{ {
TSStorageManager *storageManager = TSStorageManager.sharedManager;
return @[ return @[
[[OWS100RemoveTSRecipientsMigration alloc] initWithStorageManager:self.storageManager], [[OWS100RemoveTSRecipientsMigration alloc] initWithStorageManager:storageManager],
[[OWS102MoveLoggingPreferenceToUserDefaults alloc] initWithStorageManager:self.storageManager], [[OWS102MoveLoggingPreferenceToUserDefaults alloc] initWithStorageManager:storageManager],
[[OWS103EnableVideoCalling alloc] initWithStorageManager:self.storageManager], [[OWS103EnableVideoCalling alloc] initWithStorageManager:storageManager],
// OWS104CreateRecipientIdentities is run separately. See runSafeBlockingMigrations. // OWS104CreateRecipientIdentities is run separately. See runSafeBlockingMigrations.
[[OWS105AttachmentFilePaths alloc] initWithStorageManager:self.storageManager], [[OWS105AttachmentFilePaths alloc] initWithStorageManager:storageManager],
[[OWS106EnsureProfileComplete alloc] initWithStorageManager:self.storageManager] [[OWS106EnsureProfileComplete alloc] initWithStorageManager:storageManager]
]; ];
} }
@ -73,6 +76,16 @@ NS_ASSUME_NONNULL_BEGIN
[UIApplication.sharedApplication openSystemSettings]; [UIApplication.sharedApplication openSystemSettings];
} }
- (void)doMultiDeviceUpdateWithProfileKey:(OWSAES256Key *)profileKey
{
OWSAssert(profileKey);
[MultiDeviceProfileKeyUpdateJob runWithProfileKey:profileKey
identityManager:OWSIdentityManager.sharedManager
messageSender:Environment.current.messageSender
profileManager:OWSProfileManager.sharedManager];
}
@end @end
NS_ASSUME_NONNULL_END NS_ASSUME_NONNULL_END

View File

@ -4,8 +4,8 @@
#import "OWSContactsSyncing.h" #import "OWSContactsSyncing.h"
#import "OWSContactsManager.h" #import "OWSContactsManager.h"
#import "OWSProfileManager.h"
#import "TSAccountManager.h" #import "TSAccountManager.h"
#import <SignalMessaging/OWSProfileManager.h>
#import <SignalServiceKit/DataSource.h> #import <SignalServiceKit/DataSource.h>
#import <SignalServiceKit/MIMETypeUtil.h> #import <SignalServiceKit/MIMETypeUtil.h>
#import <SignalServiceKit/OWSMessageSender.h> #import <SignalServiceKit/OWSMessageSender.h>

View File

@ -29,7 +29,7 @@ import UIKit
} }
// Don't allow any change if inserting a single char is already over the limit (typically this means typing) // Don't allow any change if inserting a single char is already over the limit (typically this means typing)
if (replacementString.characters.count < 2) { if (replacementString.count < 2) {
return false return false
} }

View File

@ -5,9 +5,9 @@
#import "ThreadUtil.h" #import "ThreadUtil.h"
#import "OWSContactOffersInteraction.h" #import "OWSContactOffersInteraction.h"
#import "OWSContactsManager.h" #import "OWSContactsManager.h"
#import "OWSProfileManager.h"
#import "Signal-Swift.h" #import "Signal-Swift.h"
#import "TSUnreadIndicatorInteraction.h" #import "TSUnreadIndicatorInteraction.h"
#import <SignalMessaging/OWSProfileManager.h>
#import <SignalServiceKit/NSDate+OWS.h> #import <SignalServiceKit/NSDate+OWS.h>
#import <SignalServiceKit/OWSAddToContactsOfferMessage.h> #import <SignalServiceKit/OWSAddToContactsOfferMessage.h>
#import <SignalServiceKit/OWSAddToProfileWhitelistOfferMessage.h> #import <SignalServiceKit/OWSAddToProfileWhitelistOfferMessage.h>

View File

@ -11,7 +11,11 @@ FOUNDATION_EXPORT double SignalMessagingVersionNumber;
FOUNDATION_EXPORT const unsigned char SignalMessagingVersionString[]; FOUNDATION_EXPORT const unsigned char SignalMessagingVersionString[];
// The public headers of the framework // The public headers of the framework
#import <SignalMessaging/DebugLogger.h>
#import <SignalMessaging/Environment.h> #import <SignalMessaging/Environment.h>
#import <SignalMessaging/OWSDatabaseMigration.h> #import <SignalMessaging/OWSDatabaseMigration.h>
#import <SignalMessaging/OWSFormat.h>
#import <SignalMessaging/OWSLogger.h> #import <SignalMessaging/OWSLogger.h>
#import <SignalMessaging/OWSMath.h>
#import <SignalMessaging/OWSProfileManager.h> #import <SignalMessaging/OWSProfileManager.h>
#import <SignalMessaging/Rel.h>

View File

@ -36,8 +36,8 @@
@property (nonatomic, readonly, weak) UINavigationController *signUpFlowNavigationController; @property (nonatomic, readonly, weak) UINavigationController *signUpFlowNavigationController;
+ (Environment *)getCurrent; + (Environment *)current;
+ (void)setCurrent:(Environment *)curEnvironment; + (void)setCurrent:(Environment *)environment;
+ (OWSPreferences *)preferences; + (OWSPreferences *)preferences;

View File

@ -12,7 +12,7 @@
#import <SignalServiceKit/TSGroupThread.h> #import <SignalServiceKit/TSGroupThread.h>
#import <SignalServiceKit/Threading.h> #import <SignalServiceKit/Threading.h>
static Environment *environment = nil; static Environment *sharedEnvironment = nil;
@interface Environment () @interface Environment ()
@ -22,6 +22,7 @@ static Environment *environment = nil;
@property (nonatomic) OWSMessageSender *messageSender; @property (nonatomic) OWSMessageSender *messageSender;
@property (nonatomic) OWSPreferences *preferences; @property (nonatomic) OWSPreferences *preferences;
// TODO: Move to SignalApp.
@property (nonatomic, weak) UINavigationController *signUpFlowNavigationController; @property (nonatomic, weak) UINavigationController *signUpFlowNavigationController;
@end @end
@ -30,15 +31,19 @@ static Environment *environment = nil;
@implementation Environment @implementation Environment
+ (Environment *)getCurrent + (Environment *)current
{ {
NSAssert((environment != nil), @"Environment is not defined."); OWSAssert(sharedEnvironment);
return environment;
return sharedEnvironment;
} }
+ (void)setCurrent:(Environment *)curEnvironment + (void)setCurrent:(Environment *)environment
{ {
environment = curEnvironment; OWSAssert(!sharedEnvironment);
OWSAssert(environment);
sharedEnvironment = environment;
} }
- (instancetype)initWithContactsManager:(OWSContactsManager *)contactsManager - (instancetype)initWithContactsManager:(OWSContactsManager *)contactsManager
@ -91,12 +96,12 @@ static Environment *environment = nil;
+ (OWSPreferences *)preferences + (OWSPreferences *)preferences
{ {
OWSAssert([Environment getCurrent]); OWSAssert([Environment current].preferences);
OWSAssert([Environment getCurrent].preferences);
return [Environment getCurrent].preferences; return [Environment current].preferences;
} }
// TODO: Convert to singleton?
- (OWSPreferences *)preferences - (OWSPreferences *)preferences
{ {
@synchronized(self) @synchronized(self)

View File

@ -2,7 +2,7 @@
// Copyright (c) 2017 Open Whisper Systems. All rights reserved. // Copyright (c) 2017 Open Whisper Systems. All rights reserved.
// //
#import "Environment.h" @class Environment;
@interface Release : NSObject @interface Release : NSObject

View File

@ -3,6 +3,7 @@
// //
#import "Release.h" #import "Release.h"
#import "Environment.h"
#import "NotificationsManager.h" #import "NotificationsManager.h"
#import "OWSContactsManager.h" #import "OWSContactsManager.h"
#import <SignalServiceKit/ContactsUpdater.h> #import <SignalServiceKit/ContactsUpdater.h>

View File

@ -8,7 +8,9 @@
#import "UIImage+OWS.h" #import "UIImage+OWS.h"
#import <AFNetworking/AFNetworking.h> #import <AFNetworking/AFNetworking.h>
#import <SignalMessaging/SignalMessaging-Swift.h> #import <SignalMessaging/SignalMessaging-Swift.h>
#import <SignalServiceKit/AppContext.h>
#import <SignalServiceKit/Cryptography.h> #import <SignalServiceKit/Cryptography.h>
#import <SignalServiceKit/MIMETypeUtil.h>
#import <SignalServiceKit/NSData+Image.h> #import <SignalServiceKit/NSData+Image.h>
#import <SignalServiceKit/NSData+hexString.h> #import <SignalServiceKit/NSData+hexString.h>
#import <SignalServiceKit/NSDate+OWS.h> #import <SignalServiceKit/NSDate+OWS.h>
@ -21,6 +23,7 @@
#import <SignalServiceKit/SecurityUtils.h> #import <SignalServiceKit/SecurityUtils.h>
#import <SignalServiceKit/TSAccountManager.h> #import <SignalServiceKit/TSAccountManager.h>
#import <SignalServiceKit/TSGroupThread.h> #import <SignalServiceKit/TSGroupThread.h>
#import <SignalServiceKit/TSNetworkManager.h>
#import <SignalServiceKit/TSProfileAvatarUploadFormRequest.h> #import <SignalServiceKit/TSProfileAvatarUploadFormRequest.h>
#import <SignalServiceKit/TSStorageManager.h> #import <SignalServiceKit/TSStorageManager.h>
#import <SignalServiceKit/TSThread.h> #import <SignalServiceKit/TSThread.h>
@ -154,8 +157,8 @@ const NSUInteger kOWSProfileManager_MaxAvatarDiameter = 640;
- (instancetype)initDefault - (instancetype)initDefault
{ {
TSStorageManager *storageManager = [TSStorageManager sharedManager]; TSStorageManager *storageManager = [TSStorageManager sharedManager];
OWSMessageSender *messageSender = [Environment getCurrent].messageSender; OWSMessageSender *messageSender = [Environment current].messageSender;
TSNetworkManager *networkManager = [Environment getCurrent].networkManager; TSNetworkManager *networkManager = [Environment current].networkManager;
return [self initWithStorageManager:storageManager messageSender:messageSender networkManager:networkManager]; return [self initWithStorageManager:storageManager messageSender:messageSender networkManager:networkManager];
} }
@ -262,10 +265,7 @@ const NSUInteger kOWSProfileManager_MaxAvatarDiameter = 640;
// we have a registered account, syncing will fail (and there could not be any // we have a registered account, syncing will fail (and there could not be any
// linked device to sync to at this point anyway). // linked device to sync to at this point anyway).
if ([TSAccountManager isRegistered]) { if ([TSAccountManager isRegistered]) {
[MultiDeviceProfileKeyUpdateJob runWithProfileKey:userProfile.profileKey [CurrentAppContext() doMultiDeviceUpdateWithProfileKey:userProfile.profileKey];
identityManager:self.identityManager
messageSender:self.messageSender
profileManager:self];
} }
[[NSNotificationCenter defaultCenter] [[NSNotificationCenter defaultCenter]

View File

@ -19,15 +19,17 @@ public class ProfileFetcherJob: NSObject {
let ignoreThrottling: Bool let ignoreThrottling: Bool
@objc
public class func run(thread: TSThread, networkManager: TSNetworkManager) { public class func run(thread: TSThread, networkManager: TSNetworkManager) {
ProfileFetcherJob(networkManager: networkManager).run(recipientIds: thread.recipientIdentifiers) ProfileFetcherJob(networkManager: networkManager).run(recipientIds: thread.recipientIdentifiers)
} }
@objc
public class func run(recipientId: String, networkManager: TSNetworkManager, ignoreThrottling: Bool) { public class func run(recipientId: String, networkManager: TSNetworkManager, ignoreThrottling: Bool) {
ProfileFetcherJob(networkManager: networkManager, ignoreThrottling:ignoreThrottling).run(recipientIds: [recipientId]) ProfileFetcherJob(networkManager: networkManager, ignoreThrottling:ignoreThrottling).run(recipientIds: [recipientId])
} }
init(networkManager: TSNetworkManager, ignoreThrottling: Bool = false) { public init(networkManager: TSNetworkManager, ignoreThrottling: Bool = false) {
self.networkManager = networkManager self.networkManager = networkManager
self.storageManager = TSStorageManager.shared() self.storageManager = TSStorageManager.shared()
self.ignoreThrottling = ignoreThrottling self.ignoreThrottling = ignoreThrottling
@ -137,7 +139,7 @@ public class ProfileFetcherJob: NSObject {
public class SignalServiceProfile: NSObject { public class SignalServiceProfile: NSObject {
let TAG = "[SignalServiceProfile]" let TAG = "[SignalServiceProfile]"
enum ValidationError: Error { public enum ValidationError: Error {
case invalid(description: String) case invalid(description: String)
case invalidIdentityKey(description: String) case invalidIdentityKey(description: String)
case invalidProfileName(description: String) case invalidProfileName(description: String)

View File

@ -9,7 +9,7 @@
* Solution modified from * Solution modified from
* http://stackoverflow.com/questions/16821736/weak-reference-to-nstimer-target-to-prevent-retain-cycle/41003985#41003985 * http://stackoverflow.com/questions/16821736/weak-reference-to-nstimer-target-to-prevent-retain-cycle/41003985#41003985
*/ */
final class WeakTimer { public final class WeakTimer {
fileprivate weak var timer: Timer? fileprivate weak var timer: Timer?
fileprivate weak var target: AnyObject? fileprivate weak var target: AnyObject?
@ -25,7 +25,7 @@ final class WeakTimer {
repeats: repeats) repeats: repeats)
} }
class func scheduledTimer(timeInterval: TimeInterval, target: AnyObject, userInfo: Any?, repeats: Bool, action: @escaping (Timer) -> Void) -> Timer { public class func scheduledTimer(timeInterval: TimeInterval, target: AnyObject, userInfo: Any?, repeats: Bool, action: @escaping (Timer) -> Void) -> Timer {
return WeakTimer(timeInterval: timeInterval, return WeakTimer(timeInterval: timeInterval,
target: target, target: target,
userInfo: userInfo, userInfo: userInfo,

View File

@ -8,40 +8,55 @@ import Foundation
* Strings re-used in multiple places should be added here. * Strings re-used in multiple places should be added here.
*/ */
@objc class CommonStrings: NSObject { @objc public class CommonStrings: NSObject {
static let dismissButton = NSLocalizedString("DISMISS_BUTTON_TEXT", comment: "Short text to dismiss current modal / actionsheet / screen") @objc
static let cancelButton = NSLocalizedString("TXT_CANCEL_TITLE", comment:"Label for the cancel button in an alert or action sheet.") static public let dismissButton = NSLocalizedString("DISMISS_BUTTON_TEXT", comment: "Short text to dismiss current modal / actionsheet / screen")
static let retryButton = NSLocalizedString("RETRY_BUTTON_TEXT", comment:"Generic text for button that retries whatever the last action was.") @objc
static public let cancelButton = NSLocalizedString("TXT_CANCEL_TITLE", comment:"Label for the cancel button in an alert or action sheet.")
@objc
static public let retryButton = NSLocalizedString("RETRY_BUTTON_TEXT", comment:"Generic text for button that retries whatever the last action was.")
} }
@objc class MessageStrings: NSObject { @objc public class MessageStrings: NSObject {
static let newGroupDefaultTitle = NSLocalizedString("NEW_GROUP_DEFAULT_TITLE", comment: "Used in place of the group name when a group has not yet been named.") @objc
static public let newGroupDefaultTitle = NSLocalizedString("NEW_GROUP_DEFAULT_TITLE", comment: "Used in place of the group name when a group has not yet been named.")
} }
@objc class CallStrings: NSObject { @objc public class CallStrings: NSObject {
@objc
static public let callStatusFormat = NSLocalizedString("CALL_STATUS_FORMAT", comment: "embeds {{Call Status}} in call screen label. For ongoing calls, {{Call Status}} is a seconds timer like 01:23, otherwise {{Call Status}} is a short text like 'Ringing', 'Busy', or 'Failed Call'")
static let callStatusFormat = NSLocalizedString("CALL_STATUS_FORMAT", comment: "embeds {{Call Status}} in call screen label. For ongoing calls, {{Call Status}} is a seconds timer like 01:23, otherwise {{Call Status}} is a short text like 'Ringing', 'Busy', or 'Failed Call'") @objc
static public let confirmAndCallButtonTitle = NSLocalizedString("SAFETY_NUMBER_CHANGED_CONFIRM_CALL_ACTION", comment: "alert button text to confirm placing an outgoing call after the recipients Safety Number has changed.")
static let confirmAndCallButtonTitle = NSLocalizedString("SAFETY_NUMBER_CHANGED_CONFIRM_CALL_ACTION", comment: "alert button text to confirm placing an outgoing call after the recipients Safety Number has changed.") @objc
static public let callBackAlertTitle = NSLocalizedString("CALL_USER_ALERT_TITLE", comment: "Title for alert offering to call a user.")
static let callBackAlertTitle = NSLocalizedString("CALL_USER_ALERT_TITLE", comment: "Title for alert offering to call a user.") @objc
static let callBackAlertMessageFormat = NSLocalizedString("CALL_USER_ALERT_MESSAGE_FORMAT", comment: "Message format for alert offering to call a user. Embeds {{the user's display name or phone number}}.") static public let callBackAlertMessageFormat = NSLocalizedString("CALL_USER_ALERT_MESSAGE_FORMAT", comment: "Message format for alert offering to call a user. Embeds {{the user's display name or phone number}}.")
static let callBackAlertCallButton = NSLocalizedString("CALL_USER_ALERT_CALL_BUTTON", comment: "Label for call button for alert offering to call a user.") @objc
static public let callBackAlertCallButton = NSLocalizedString("CALL_USER_ALERT_CALL_BUTTON", comment: "Label for call button for alert offering to call a user.")
// MARK: Notification actions // MARK: Notification actions
static let callBackButtonTitle = NSLocalizedString("CALLBACK_BUTTON_TITLE", comment: "notification action") @objc
static let showThreadButtonTitle = NSLocalizedString("SHOW_THREAD_BUTTON_TITLE", comment: "notification action") static public let callBackButtonTitle = NSLocalizedString("CALLBACK_BUTTON_TITLE", comment: "notification action")
@objc
static public let showThreadButtonTitle = NSLocalizedString("SHOW_THREAD_BUTTON_TITLE", comment: "notification action")
// MARK: Missed Call Notification // MARK: Missed Call Notification
static let missedCallNotificationBodyWithoutCallerName = NSLocalizedString("MISSED_CALL", comment: "notification title") @objc
static let missedCallNotificationBodyWithCallerName = NSLocalizedString("MSGVIEW_MISSED_CALL_WITH_NAME", comment: "notification title. Embeds {{caller's name or phone number}}") static public let missedCallNotificationBodyWithoutCallerName = NSLocalizedString("MISSED_CALL", comment: "notification title")
@objc
static public let missedCallNotificationBodyWithCallerName = NSLocalizedString("MSGVIEW_MISSED_CALL_WITH_NAME", comment: "notification title. Embeds {{caller's name or phone number}}")
// MARK: Missed with changed identity notification (for not previously verified identity) // MARK: Missed with changed identity notification (for not previously verified identity)
static let missedCallWithIdentityChangeNotificationBodyWithoutCallerName = NSLocalizedString("MISSED_CALL_WITH_CHANGED_IDENTITY_BODY_WITHOUT_CALLER_NAME", comment: "notification title") @objc
static let missedCallWithIdentityChangeNotificationBodyWithCallerName = NSLocalizedString("MISSED_CALL_WITH_CHANGED_IDENTITY_BODY_WITH_CALLER_NAME", comment: "notification title. Embeds {{caller's name or phone number}}") static public let missedCallWithIdentityChangeNotificationBodyWithoutCallerName = NSLocalizedString("MISSED_CALL_WITH_CHANGED_IDENTITY_BODY_WITHOUT_CALLER_NAME", comment: "notification title")
@objc
static public let missedCallWithIdentityChangeNotificationBodyWithCallerName = NSLocalizedString("MISSED_CALL_WITH_CHANGED_IDENTITY_BODY_WITH_CALLER_NAME", comment: "notification title. Embeds {{caller's name or phone number}}")
} }
@objc class SafetyNumberStrings: NSObject { @objc public class SafetyNumberStrings: NSObject {
static let confirmSendButton = NSLocalizedString("SAFETY_NUMBER_CHANGED_CONFIRM_SEND_ACTION", @objc
static public let confirmSendButton = NSLocalizedString("SAFETY_NUMBER_CHANGED_CONFIRM_SEND_ACTION",
comment: "button title to confirm sending to a recipient whose safety number recently changed") comment: "button title to confirm sending to a recipient whose safety number recently changed")
} }

View File

@ -4,10 +4,11 @@
import Foundation import Foundation
@objc class OWSAlerts: NSObject { @objc public class OWSAlerts: NSObject {
let TAG = "[OWSAlerts]" let TAG = "[OWSAlerts]"
/// Cleanup and present alert for no permissions /// Cleanup and present alert for no permissions
@objc
public class func showNoMicrophonePermissionAlert() { public class func showNoMicrophonePermissionAlert() {
let alertTitle = NSLocalizedString("CALL_AUDIO_PERMISSION_TITLE", comment:"Alert title when calling and permissions for microphone are missing") let alertTitle = NSLocalizedString("CALL_AUDIO_PERMISSION_TITLE", comment:"Alert title when calling and permissions for microphone are missing")
let alertMessage = NSLocalizedString("CALL_AUDIO_PERMISSION_MESSAGE", comment:"Alert message when calling and permissions for microphone are missing") let alertMessage = NSLocalizedString("CALL_AUDIO_PERMISSION_MESSAGE", comment:"Alert message when calling and permissions for microphone are missing")
@ -22,16 +23,19 @@ import Foundation
CurrentAppContext().frontmostViewController()?.present(alertController, animated: true, completion: nil) CurrentAppContext().frontmostViewController()?.present(alertController, animated: true, completion: nil)
} }
@objc
public class func showAlert(withTitle title: String) { public class func showAlert(withTitle title: String) {
self.showAlert(withTitle: title, message: nil, buttonTitle: nil) self.showAlert(withTitle: title, message: nil, buttonTitle: nil)
} }
@objc
public class func showAlert(withTitle title: String, message: String) { public class func showAlert(withTitle title: String, message: String) {
self.showAlert(withTitle: title, message: message, buttonTitle: nil) self.showAlert(withTitle: title, message: message, buttonTitle: nil)
} }
@objc
public class func showAlert(withTitle title: String, message: String? = nil, buttonTitle: String? = nil) { public class func showAlert(withTitle title: String, message: String? = nil, buttonTitle: String? = nil) {
assert(title.characters.count > 0) assert(title.count > 0)
let actionTitle = buttonTitle ?? NSLocalizedString("OK", comment: "") let actionTitle = buttonTitle ?? NSLocalizedString("OK", comment: "")
@ -40,8 +44,9 @@ import Foundation
CurrentAppContext().frontmostViewController()?.present(alert, animated: true, completion: nil) CurrentAppContext().frontmostViewController()?.present(alert, animated: true, completion: nil)
} }
@objc
public class func showConfirmationAlert(withTitle title: String, message: String? = nil, proceedTitle: String? = nil, proceedAction: @escaping (UIAlertAction) -> Void) { public class func showConfirmationAlert(withTitle title: String, message: String? = nil, proceedTitle: String? = nil, proceedAction: @escaping (UIAlertAction) -> Void) {
assert(title.characters.count > 0) assert(title.count > 0)
let alert = UIAlertController(title: title, message: message, preferredStyle: .alert) let alert = UIAlertController(title: title, message: message, preferredStyle: .alert)
alert.addAction(self.cancelAction) alert.addAction(self.cancelAction)
@ -52,6 +57,7 @@ import Foundation
CurrentAppContext().frontmostViewController()?.present(alert, animated: true, completion: nil) CurrentAppContext().frontmostViewController()?.present(alert, animated: true, completion: nil)
} }
@objc
public class var cancelAction: UIAlertAction { public class var cancelAction: UIAlertAction {
let action = UIAlertAction(title: CommonStrings.cancelButton, style: .cancel) { _ in let action = UIAlertAction(title: CommonStrings.cancelButton, style: .cancel) { _ in
Logger.debug("Cancel item") Logger.debug("Cancel item")

View File

@ -6,6 +6,7 @@ NS_ASSUME_NONNULL_BEGIN
typedef void (^BackgroundTaskExpirationHandler)(void); typedef void (^BackgroundTaskExpirationHandler)(void);
@class OWSAES256Key;
@class OWSDatabaseMigration; @class OWSDatabaseMigration;
@protocol AppContext <NSObject> @protocol AppContext <NSObject>
@ -38,6 +39,10 @@ typedef void (^BackgroundTaskExpirationHandler)(void);
// Should only be called if isMainApp is YES. // Should only be called if isMainApp is YES.
- (void)openSystemSettings; - (void)openSystemSettings;
// Should only be called if isMainApp is YES,
// but should only be necessary to call if isMainApp is YES.
- (void)doMultiDeviceUpdateWithProfileKey:(OWSAES256Key *)profileKey;
@end @end
id<AppContext> CurrentAppContext(void); id<AppContext> CurrentAppContext(void);

View File

@ -14,7 +14,7 @@ class ShareViewController: UINavigationController, SAELoadViewDelegate {
super.loadView() super.loadView()
// This should be the first thing we do. // This should be the first thing we do.
SetCurrentAppContext(ShareAppExtensionContext(with:self)) SetCurrentAppContext(ShareAppExtensionContext(rootViewController:self))
DebugLogger.shared().enableTTYLogging() DebugLogger.shared().enableTTYLogging()
if _isDebugAssertConfiguration() { if _isDebugAssertConfiguration() {
@ -38,9 +38,9 @@ class ShareViewController: UINavigationController, SAELoadViewDelegate {
// // // //
// // This block will be cleared in databaseViewRegistrationComplete. // // This block will be cleared in databaseViewRegistrationComplete.
// [DeviceSleepManager.sharedInstance addBlockWithBlockObject:self]; // [DeviceSleepManager.sharedInstance addBlockWithBlockObject:self];
//
// [self setupEnvironment]; setupEnvironment()
//
// [UIUtil applySignalAppearence]; // [UIUtil applySignalAppearence];
// //
// if (getenv("runningTests_dontStartApp")) { // if (getenv("runningTests_dontStartApp")) {
@ -67,9 +67,9 @@ class ShareViewController: UINavigationController, SAELoadViewDelegate {
// //
// [self prepareScreenProtection]; // [self prepareScreenProtection];
// //
// self.contactsSyncing = [[OWSContactsSyncing alloc] initWithContactsManager:[Environment getCurrent].contactsManager // self.contactsSyncing = [[OWSContactsSyncing alloc] initWithContactsManager:[Environment current].contactsManager
// identityManager:[OWSIdentityManager sharedManager] // identityManager:[OWSIdentityManager sharedManager]
// messageSender:[Environment getCurrent].messageSender // messageSender:[Environment current].messageSender
// profileManager:[OWSProfileManager sharedManager]]; // profileManager:[OWSProfileManager sharedManager]];
// //
// [[NSNotificationCenter defaultCenter] addObserver:self // [[NSNotificationCenter defaultCenter] addObserver:self
@ -119,23 +119,24 @@ class ShareViewController: UINavigationController, SAELoadViewDelegate {
} }
func setupEnvironment() { func setupEnvironment() {
[Environment setCurrent:[Release releaseEnvironment]] Environment.setCurrent(Release.releaseEnvironment())
// TODO:
// // Encryption/Descryption mutates session state and must be synchronized on a serial queue. // // Encryption/Descryption mutates session state and must be synchronized on a serial queue.
// [SessionCipher setSessionCipherDispatchQueue:[OWSDispatch sessionStoreQueue]]; // [SessionCipher setSessionCipherDispatchQueue:[OWSDispatch sessionStoreQueue]];
// //
// TextSecureKitEnv *sharedEnv = // TextSecureKitEnv *sharedEnv =
// [[TextSecureKitEnv alloc] initWithCallMessageHandler:[Environment getCurrent].callMessageHandler // [[TextSecureKitEnv alloc] initWithCallMessageHandler:SignalApp.sharedApp.callMessageHandler
// contactsManager:[Environment getCurrent].contactsManager // contactsManager:[Environment current].contactsManager
// messageSender:[Environment getCurrent].messageSender // messageSender:[Environment current].messageSender
// notificationsManager:[Environment getCurrent].notificationsManager // notificationsManager:SignalApp.sharedApp.notificationsManager
// profileManager:OWSProfileManager.sharedManager]; // profileManager:OWSProfileManager.sharedManager];
// [TextSecureKitEnv setSharedEnv:sharedEnv]; // [TextSecureKitEnv setSharedEnv:sharedEnv];
// //
// [[TSStorageManager sharedManager] setupDatabaseWithSafeBlockingMigrations:^{ // [[TSStorageManager sharedManager] setupDatabaseWithSafeBlockingMigrations:^{
// [VersionMigrations runSafeBlockingMigrations]; // [VersionMigrations runSafeBlockingMigrations];
// }]; // }];
// [[Environment getCurrent].contactsManager startObserving]; // [[Environment current].contactsManager startObserving];
} }
// MARK: View Lifecycle // MARK: View Lifecycle

View File

@ -2,17 +2,24 @@
// Copyright (c) 2017 Open Whisper Systems. All rights reserved. // Copyright (c) 2017 Open Whisper Systems. All rights reserved.
// //
#import <Foundation/Foundation.h>
#import <UIKit/UIKit.h>
// Separate iOS Frameworks from other imports.
#import "DebugLogger.h" #import "DebugLogger.h"
#import "Environment.h"
#import "OWSLogger.h" #import "OWSLogger.h"
#import "OWSMath.h"
#import "OWSPreferences.h"
#import "Release.h"
#import "ShareAppExtensionContext.h" #import "ShareAppExtensionContext.h"
#import "UIColor+OWS.h" #import "UIColor+OWS.h"
#import "UIFont+OWS.h" #import "UIFont+OWS.h"
#import "UIView+OWS.h" #import "UIView+OWS.h"
#import <Foundation/Foundation.h>
#import <SignalMessaging/OWSMath.h> //#import <SignalMessaging/OWSMath.h>
#import <SignalMessaging/OWSPreferences.h> //#import <SignalMessaging/OWSPreferences.h>
#import <SignalServiceKit/AppContext.h> #import <SignalServiceKit/AppContext.h>
#import <SignalServiceKit/AppVersion.h> #import <SignalServiceKit/AppVersion.h>
#import <SignalServiceKit/Asserts.h> #import <SignalServiceKit/Asserts.h>
#import <SignalServiceKit/NSObject+OWS.h> #import <SignalServiceKit/NSObject+OWS.h>
#import <UIKit/UIKit.h>

View File

@ -92,6 +92,11 @@ NS_ASSUME_NONNULL_BEGIN
OWSFail(@"%@ called %s.", self.logTag, __PRETTY_FUNCTION__); OWSFail(@"%@ called %s.", self.logTag, __PRETTY_FUNCTION__);
} }
- (void)doMultiDeviceUpdateWithProfileKey:(OWSAES256Key *)profileKey
{
OWSFail(@"%@ called %s.", self.logTag, __PRETTY_FUNCTION__);
}
@end @end
NS_ASSUME_NONNULL_END NS_ASSUME_NONNULL_END