From 8312614cf749c228132998cd880fb87ed5b48db1 Mon Sep 17 00:00:00 2001 From: Matthew Chen Date: Thu, 7 Dec 2017 13:53:13 -0500 Subject: [PATCH] Respond to CR. --- Signal.xcodeproj/project.pbxproj | 25 +++++---- Signal/src/AppDelegate.m | 30 +++-------- SignalMessaging/SignalMessaging.h | 1 + SignalMessaging/environment/AppSetup.h | 21 ++++++++ SignalMessaging/environment/AppSetup.m | 51 +++++++++++++++++++ SignalMessaging/environment/Environment.m | 4 ++ .../environment/NoopCallMessageHandler.swift | 2 +- .../NoopNotificationsManager.swift | 2 +- .../utils/ConversationSearcher.swift | 2 +- .../ShareViewController.swift | 7 ++- .../utils/ShareAppExtensionContext.h | 2 - .../utils/ShareAppExtensionContext.m | 32 ------------ 12 files changed, 110 insertions(+), 69 deletions(-) create mode 100644 SignalMessaging/environment/AppSetup.h create mode 100644 SignalMessaging/environment/AppSetup.m rename SignalShareExtension/SAECallMessageHandler.swift => SignalMessaging/environment/NoopCallMessageHandler.swift (92%) rename SignalShareExtension/SAENotificationsManager.swift => SignalMessaging/environment/NoopNotificationsManager.swift (86%) diff --git a/Signal.xcodeproj/project.pbxproj b/Signal.xcodeproj/project.pbxproj index 0fb95c169..2e092061d 100644 --- a/Signal.xcodeproj/project.pbxproj +++ b/Signal.xcodeproj/project.pbxproj @@ -72,8 +72,6 @@ 346129D21FD2085A00532771 /* CommonStrings.swift in Sources */ = {isa = PBXBuildFile; fileRef = 346129D11FD2085A00532771 /* CommonStrings.swift */; }; 346129D51FD20ADC00532771 /* UIViewController+OWS.m in Sources */ = {isa = PBXBuildFile; fileRef = 346129D31FD20ADB00532771 /* UIViewController+OWS.m */; }; 346129D61FD20ADC00532771 /* UIViewController+OWS.h in Headers */ = {isa = PBXBuildFile; fileRef = 346129D41FD20ADC00532771 /* UIViewController+OWS.h */; settings = {ATTRIBUTES = (Public, ); }; }; - 346129D91FD5B84900532771 /* SAECallMessageHandler.swift in Sources */ = {isa = PBXBuildFile; fileRef = 346129D71FD5B84800532771 /* SAECallMessageHandler.swift */; }; - 346129DA1FD5B84900532771 /* SAENotificationsManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = 346129D81FD5B84900532771 /* SAENotificationsManager.swift */; }; 346129DE1FD5C02A00532771 /* LockInteractionController.h in Headers */ = {isa = PBXBuildFile; fileRef = 346129DC1FD5C02900532771 /* LockInteractionController.h */; }; 346129DF1FD5C02A00532771 /* LockInteractionController.m in Sources */ = {isa = PBXBuildFile; fileRef = 346129DD1FD5C02900532771 /* LockInteractionController.m */; }; 346129E21FD5C0BE00532771 /* VersionMigrations.h in Headers */ = {isa = PBXBuildFile; fileRef = 346129E01FD5C0BE00532771 /* VersionMigrations.h */; settings = {ATTRIBUTES = (Public, ); }; }; @@ -104,7 +102,10 @@ 3478504C1FD7496D007B8332 /* Images.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = B66DBF4919D5BBC8006EA940 /* Images.xcassets */; }; 347850551FD749C0007B8332 /* Localizable.strings in Resources */ = {isa = PBXBuildFile; fileRef = B6F509951AA53F760068F56A /* Localizable.strings */; }; 347850571FD86544007B8332 /* SAEFailedViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 347850561FD86544007B8332 /* SAEFailedViewController.swift */; }; - 348F2EAE1F0D21BC00D4ECE0 /* DeviceSleepManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = 348F2EAD1F0D21BC00D4ECE0 /* DeviceSleepManager.swift */; }; + 347850691FD9B78A007B8332 /* AppSetup.m in Sources */ = {isa = PBXBuildFile; fileRef = 347850651FD9B789007B8332 /* AppSetup.m */; }; + 3478506A1FD9B78A007B8332 /* AppSetup.h in Headers */ = {isa = PBXBuildFile; fileRef = 347850661FD9B789007B8332 /* AppSetup.h */; settings = {ATTRIBUTES = (Public, ); }; }; + 3478506B1FD9B78A007B8332 /* NoopCallMessageHandler.swift in Sources */ = {isa = PBXBuildFile; fileRef = 347850671FD9B78A007B8332 /* NoopCallMessageHandler.swift */; }; + 3478506C1FD9B78A007B8332 /* NoopNotificationsManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = 347850681FD9B78A007B8332 /* NoopNotificationsManager.swift */; }; 3497DBEC1ECE257500DB2605 /* OWSCountryMetadata.m in Sources */ = {isa = PBXBuildFile; fileRef = 3497DBEB1ECE257500DB2605 /* OWSCountryMetadata.m */; }; 3497DBEF1ECE2E4700DB2605 /* DomainFrontingCountryViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 3497DBEE1ECE2E4700DB2605 /* DomainFrontingCountryViewController.m */; }; 34B0796D1FCF46B100E248C2 /* MainAppContext.m in Sources */ = {isa = PBXBuildFile; fileRef = 34B0796B1FCF46B000E248C2 /* MainAppContext.m */; }; @@ -540,8 +541,6 @@ 346129D11FD2085A00532771 /* CommonStrings.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CommonStrings.swift; sourceTree = ""; }; 346129D31FD20ADB00532771 /* UIViewController+OWS.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "UIViewController+OWS.m"; sourceTree = ""; }; 346129D41FD20ADC00532771 /* UIViewController+OWS.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "UIViewController+OWS.h"; sourceTree = ""; }; - 346129D71FD5B84800532771 /* SAECallMessageHandler.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SAECallMessageHandler.swift; sourceTree = ""; }; - 346129D81FD5B84900532771 /* SAENotificationsManager.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SAENotificationsManager.swift; sourceTree = ""; }; 346129DC1FD5C02900532771 /* LockInteractionController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = LockInteractionController.h; sourceTree = ""; }; 346129DD1FD5C02900532771 /* LockInteractionController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = LockInteractionController.m; sourceTree = ""; }; 346129E01FD5C0BE00532771 /* VersionMigrations.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = VersionMigrations.h; sourceTree = ""; }; @@ -569,6 +568,10 @@ 3472229D1EB22FFE00E53955 /* AddToGroupViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AddToGroupViewController.h; sourceTree = ""; }; 3472229E1EB22FFE00E53955 /* AddToGroupViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = AddToGroupViewController.m; sourceTree = ""; }; 347850561FD86544007B8332 /* SAEFailedViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SAEFailedViewController.swift; sourceTree = ""; }; + 347850651FD9B789007B8332 /* AppSetup.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = AppSetup.m; sourceTree = ""; }; + 347850661FD9B789007B8332 /* AppSetup.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AppSetup.h; sourceTree = ""; }; + 347850671FD9B78A007B8332 /* NoopCallMessageHandler.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = NoopCallMessageHandler.swift; sourceTree = ""; }; + 347850681FD9B78A007B8332 /* NoopNotificationsManager.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = NoopNotificationsManager.swift; sourceTree = ""; }; 348F2EAD1F0D21BC00D4ECE0 /* DeviceSleepManager.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = DeviceSleepManager.swift; sourceTree = ""; }; 3495BC911F1426B800B478F5 /* ar */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = ar; path = translations/ar.lproj/Localizable.strings; sourceTree = ""; }; 3497DBEA1ECE257500DB2605 /* OWSCountryMetadata.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = OWSCountryMetadata.h; sourceTree = ""; }; @@ -1148,9 +1151,13 @@ 3461293F1FD1D74B00532771 /* environment */ = { isa = PBXGroup; children = ( + 347850661FD9B789007B8332 /* AppSetup.h */, + 347850651FD9B789007B8332 /* AppSetup.m */, 346129401FD1D74B00532771 /* Environment.h */, 346129411FD1D74B00532771 /* Environment.m */, 346129921FD1E30000532771 /* migrations */, + 347850671FD9B78A007B8332 /* NoopCallMessageHandler.swift */, + 347850681FD9B78A007B8332 /* NoopNotificationsManager.swift */, 346129561FD1D74B00532771 /* Release.h */, 346129571FD1D74B00532771 /* Release.m */, 346129581FD1D74B00532771 /* SignalKeyingStorage.h */, @@ -1472,10 +1479,8 @@ children = ( 4535186F1FC635DD00210559 /* Info.plist */, 4535186C1FC635DD00210559 /* MainInterface.storyboard */, - 346129D71FD5B84800532771 /* SAECallMessageHandler.swift */, 347850561FD86544007B8332 /* SAEFailedViewController.swift */, 3461284A1FD0B93F00532771 /* SAELoadViewController.swift */, - 346129D81FD5B84900532771 /* SAENotificationsManager.swift */, 4535186A1FC635DD00210559 /* ShareViewController.swift */, 34480B371FD092A900BC14EF /* SignalShareExtension-Bridging-Header.h */, 34480B381FD092E300BC14EF /* SignalShareExtension-Prefix.pch */, @@ -2031,6 +2036,7 @@ 451F8A4A1FD715D9005CB9DA /* OWSContactAvatarBuilder.h in Headers */, 34480B5B1FD0A7E300BC14EF /* SignalMessaging-Prefix.pch in Headers */, 45194F921FD7215600333B2C /* OWSContactOffersInteraction.h in Headers */, + 3478506A1FD9B78A007B8332 /* AppSetup.h in Headers */, 346129A51FD1F09100532771 /* OWSContactsManager.h in Headers */, 451F8A421FD714C7005CB9DA /* ContactTableViewCell.h in Headers */, 34480B681FD0AA9400BC14EF /* UIFont+OWS.h in Headers */, @@ -2650,10 +2656,8 @@ isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; files = ( - 346129DA1FD5B84900532771 /* SAENotificationsManager.swift in Sources */, 4535186B1FC635DD00210559 /* ShareViewController.swift in Sources */, 34480B361FD0929200BC14EF /* ShareAppExtensionContext.m in Sources */, - 346129D91FD5B84900532771 /* SAECallMessageHandler.swift in Sources */, 3461284B1FD0B94000532771 /* SAELoadViewController.swift in Sources */, 347850571FD86544007B8332 /* SAEFailedViewController.swift in Sources */, ); @@ -2672,6 +2676,7 @@ 45E547201FD755E700DFC09E /* AttachmentApprovalViewController.swift in Sources */, 346129B51FD1F7E800532771 /* OWSProfileManager.m in Sources */, 346129701FD1D74C00532771 /* Release.m in Sources */, + 3478506C1FD9B78A007B8332 /* NoopNotificationsManager.swift in Sources */, 34480B621FD0A98800BC14EF /* UIColor+OWS.m in Sources */, 34480B531FD0A7A400BC14EF /* OWSLogger.m in Sources */, 34480B641FD0A98800BC14EF /* UIView+OWS.m in Sources */, @@ -2685,6 +2690,7 @@ 450998661FD8BD9C00D89EB3 /* FullImageViewController.m in Sources */, 346129FB1FD5F31400532771 /* OWS101ExistingUsersBlockOnIdentityChange.m in Sources */, 450998651FD8A34D00D89EB3 /* DeviceSleepManager.swift in Sources */, + 3478506B1FD9B78A007B8332 /* NoopCallMessageHandler.swift in Sources */, 451F8A3D1FD713CA005CB9DA /* ThreadViewHelper.m in Sources */, 346129AD1FD1F34E00532771 /* ImageCache.swift in Sources */, 451F8A341FD710C3005CB9DA /* ConversationSearcher.swift in Sources */, @@ -2705,6 +2711,7 @@ 451F8A431FD714FE005CB9DA /* AvatarImageView.swift in Sources */, 346129C91FD2072E00532771 /* NSString+OWS.m in Sources */, 346129CB1FD2072E00532771 /* Promise+retainUntilComplete.swift in Sources */, + 347850691FD9B78A007B8332 /* AppSetup.m in Sources */, 346129FF1FD5F31400532771 /* OWS103EnableVideoCalling.m in Sources */, 346129E31FD5C0BE00532771 /* VersionMigrations.m in Sources */, 451F8A3F1FD71455005CB9DA /* OWSTableViewController.m in Sources */, diff --git a/Signal/src/AppDelegate.m b/Signal/src/AppDelegate.m index 518e66119..9a7a68517 100644 --- a/Signal/src/AppDelegate.m +++ b/Signal/src/AppDelegate.m @@ -25,6 +25,7 @@ #import "VersionMigrations.h" #import "ViewControllerUtils.h" #import +#import #import #import #import @@ -138,7 +139,12 @@ static NSString *const kURLHostVerifyPrefix = @"verify"; // This block will be cleared in databaseViewRegistrationComplete. [DeviceSleepManager.sharedInstance addBlockWithBlockObject:self]; - [self setupEnvironment]; + [AppSetup setupEnvironment:^{ + return SignalApp.sharedApp.callMessageHandler; + } + notificationsProtocolBlock:^{ + return SignalApp.sharedApp.notificationsManager; + }]; [UIUtil applySignalAppearence]; @@ -166,6 +172,7 @@ static NSString *const kURLHostVerifyPrefix = @"verify"; [self prepareScreenProtection]; + // Ensure OWSContactsSyncing is instantiated. [OWSContactsSyncing sharedManager]; [[NSNotificationCenter defaultCenter] addObserver:self @@ -294,27 +301,6 @@ static NSString *const kURLHostVerifyPrefix = @"verify"; return viewController; } -- (void)setupEnvironment -{ - [Environment setCurrent:[Release releaseEnvironment]]; - - // Encryption/Decryption mutates session state and must be synchronized on a serial queue. - [SessionCipher setSessionCipherDispatchQueue:[OWSDispatch sessionStoreQueue]]; - - TextSecureKitEnv *sharedEnv = - [[TextSecureKitEnv alloc] initWithCallMessageHandler:SignalApp.sharedApp.callMessageHandler - contactsManager:[Environment current].contactsManager - messageSender:[Environment current].messageSender - notificationsManager:SignalApp.sharedApp.notificationsManager - profileManager:OWSProfileManager.sharedManager]; - [TextSecureKitEnv setSharedEnv:sharedEnv]; - - [[TSStorageManager sharedManager] setupDatabaseWithSafeBlockingMigrations:^{ - [VersionMigrations runSafeBlockingMigrations]; - }]; - [[Environment current].contactsManager startObserving]; -} - - (void)application:(UIApplication *)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken { DDLogInfo(@"%@ registered vanilla push token: %@", self.logTag, deviceToken); diff --git a/SignalMessaging/SignalMessaging.h b/SignalMessaging/SignalMessaging.h index c9f025d28..80b4d85d3 100644 --- a/SignalMessaging/SignalMessaging.h +++ b/SignalMessaging/SignalMessaging.h @@ -11,6 +11,7 @@ FOUNDATION_EXPORT double SignalMessagingVersionNumber; FOUNDATION_EXPORT const unsigned char SignalMessagingVersionString[]; // The public headers of the framework +#import #import #import #import diff --git a/SignalMessaging/environment/AppSetup.h b/SignalMessaging/environment/AppSetup.h new file mode 100644 index 000000000..a24695c44 --- /dev/null +++ b/SignalMessaging/environment/AppSetup.h @@ -0,0 +1,21 @@ +// +// Copyright (c) 2017 Open Whisper Systems. All rights reserved. +// + +NS_ASSUME_NONNULL_BEGIN + +@protocol OWSCallMessageHandler; +@protocol NotificationsProtocol; + +typedef id _Nonnull (^CallMessageHandlerBlock)(void); +typedef id _Nonnull (^NotificationsManagerBlock)(void); + +// This is _NOT_ a singleton and will be instantiated each time that the SAE is used. +@interface AppSetup : NSObject + ++ (void)setupEnvironment:(CallMessageHandlerBlock)callMessageHandlerBlock + notificationsProtocolBlock:(NotificationsManagerBlock)notificationsManagerBlock; + +@end + +NS_ASSUME_NONNULL_END diff --git a/SignalMessaging/environment/AppSetup.m b/SignalMessaging/environment/AppSetup.m new file mode 100644 index 000000000..6bc25aadf --- /dev/null +++ b/SignalMessaging/environment/AppSetup.m @@ -0,0 +1,51 @@ +// +// Copyright (c) 2017 Open Whisper Systems. All rights reserved. +// + +#import "AppSetup.h" +#import "Environment.h" +#import "Release.h" +#import "VersionMigrations.h" +#import +#import +#import +#import + +NS_ASSUME_NONNULL_BEGIN + +@implementation AppSetup + ++ (void)setupEnvironment:(CallMessageHandlerBlock)callMessageHandlerBlock + notificationsProtocolBlock:(NotificationsManagerBlock)notificationsManagerBlock +{ + OWSAssert(callMessageHandlerBlock); + OWSAssert(notificationsManagerBlock); + + static dispatch_once_t onceToken; + dispatch_once(&onceToken, ^{ + [Environment setCurrent:[Release releaseEnvironment]]; + + // Encryption/Decryption mutates session state and must be synchronized on a serial queue. + [SessionCipher setSessionCipherDispatchQueue:[OWSDispatch sessionStoreQueue]]; + + id callMessageHandler = callMessageHandlerBlock(); + id notificationsManager = notificationsManagerBlock(); + + TextSecureKitEnv *sharedEnv = + [[TextSecureKitEnv alloc] initWithCallMessageHandler:callMessageHandler + contactsManager:[Environment current].contactsManager + messageSender:[Environment current].messageSender + notificationsManager:notificationsManager + profileManager:OWSProfileManager.sharedManager]; + [TextSecureKitEnv setSharedEnv:sharedEnv]; + + [[TSStorageManager sharedManager] setupDatabaseWithSafeBlockingMigrations:^{ + [VersionMigrations runSafeBlockingMigrations]; + }]; + [[Environment current].contactsManager startObserving]; + }); +} + +@end + +NS_ASSUME_NONNULL_END diff --git a/SignalMessaging/environment/Environment.m b/SignalMessaging/environment/Environment.m index 4bc5b050b..7756b2061 100644 --- a/SignalMessaging/environment/Environment.m +++ b/SignalMessaging/environment/Environment.m @@ -38,6 +38,10 @@ static Environment *sharedEnvironment = nil; + (void)setCurrent:(Environment *)environment { + // The main app environment should only be set once. + // + // App extensions may be opened multiple times in the same process, + // so statics will persist. OWSAssert(!sharedEnvironment || !CurrentAppContext().isMainApp); OWSAssert(environment); diff --git a/SignalShareExtension/SAECallMessageHandler.swift b/SignalMessaging/environment/NoopCallMessageHandler.swift similarity index 92% rename from SignalShareExtension/SAECallMessageHandler.swift rename to SignalMessaging/environment/NoopCallMessageHandler.swift index df23ca8b5..1af88b458 100644 --- a/SignalShareExtension/SAECallMessageHandler.swift +++ b/SignalMessaging/environment/NoopCallMessageHandler.swift @@ -5,7 +5,7 @@ import SignalServiceKit @objc -public class SAECallMessageHandler: NSObject, OWSCallMessageHandler { +public class NoopCallMessageHandler: NSObject, OWSCallMessageHandler { public func receivedOffer(_ offer: OWSSignalServiceProtosCallMessageOffer, from callerId: String) { owsFail("\(self.logTag) in \(#function).") diff --git a/SignalShareExtension/SAENotificationsManager.swift b/SignalMessaging/environment/NoopNotificationsManager.swift similarity index 86% rename from SignalShareExtension/SAENotificationsManager.swift rename to SignalMessaging/environment/NoopNotificationsManager.swift index b060a6a33..3f7afd148 100644 --- a/SignalShareExtension/SAENotificationsManager.swift +++ b/SignalMessaging/environment/NoopNotificationsManager.swift @@ -5,7 +5,7 @@ import SignalServiceKit @objc -public class SAENotificationsManager: NSObject, NotificationsProtocol { +public class NoopNotificationsManager: NSObject, NotificationsProtocol { public func notifyUser(for incomingMessage: TSIncomingMessage!, in thread: TSThread!, contactsManager: ContactsManagerProtocol!, transaction: YapDatabaseReadTransaction!) { owsFail("\(self.logTag) in \(#function).") diff --git a/SignalMessaging/utils/ConversationSearcher.swift b/SignalMessaging/utils/ConversationSearcher.swift index 53a1fe44f..4af8093b3 100644 --- a/SignalMessaging/utils/ConversationSearcher.swift +++ b/SignalMessaging/utils/ConversationSearcher.swift @@ -6,7 +6,7 @@ import Foundation import SignalServiceKit @objc -class ConversationSearcher: NSObject { +public class ConversationSearcher: NSObject { @objc public static let shared: ConversationSearcher = ConversationSearcher() diff --git a/SignalShareExtension/ShareViewController.swift b/SignalShareExtension/ShareViewController.swift index 766c34740..689acce43 100644 --- a/SignalShareExtension/ShareViewController.swift +++ b/SignalShareExtension/ShareViewController.swift @@ -39,7 +39,11 @@ public class ShareViewController: UINavigationController, SAELoadViewDelegate, S // We don't need to use DeviceSleepManager in the SAE. - appContext.setupEnvironment() + AppSetup.setupEnvironment({ + return NoopCallMessageHandler() + }) { + return NoopNotificationsManager() + } // TODO: // [UIUtil applySignalAppearence]; @@ -77,6 +81,7 @@ public class ShareViewController: UINavigationController, SAELoadViewDelegate, S // We don't need to use "screen protection" in the SAE. + // Ensure OWSContactsSyncing is instantiated. OWSContactsSyncing.sharedManager() NotificationCenter.default.addObserver(self, diff --git a/SignalShareExtension/utils/ShareAppExtensionContext.h b/SignalShareExtension/utils/ShareAppExtensionContext.h index 9eb19c92c..ab176cf42 100644 --- a/SignalShareExtension/utils/ShareAppExtensionContext.h +++ b/SignalShareExtension/utils/ShareAppExtensionContext.h @@ -13,8 +13,6 @@ NS_ASSUME_NONNULL_BEGIN - (instancetype)initWithRootViewController:(UIViewController *)rootViewController; -- (void)setupEnvironment; - @end NS_ASSUME_NONNULL_END diff --git a/SignalShareExtension/utils/ShareAppExtensionContext.m b/SignalShareExtension/utils/ShareAppExtensionContext.m index 89e135b23..6795771b4 100644 --- a/SignalShareExtension/utils/ShareAppExtensionContext.m +++ b/SignalShareExtension/utils/ShareAppExtensionContext.m @@ -3,15 +3,7 @@ // #import "ShareAppExtensionContext.h" -#import "SignalShareExtension-Swift.h" -#import -#import -#import -#import -#import #import -#import -#import NS_ASSUME_NONNULL_BEGIN @@ -124,30 +116,6 @@ NS_ASSUME_NONNULL_BEGIN OWSFail(@"%@ called %s.", self.logTag, __PRETTY_FUNCTION__); } -- (void)setupEnvironment -{ - static dispatch_once_t onceToken; - dispatch_once(&onceToken, ^{ - [Environment setCurrent:[Release releaseEnvironment]]; - - // Encryption/Decryption mutates session state and must be synchronized on a serial queue. - [SessionCipher setSessionCipherDispatchQueue:[OWSDispatch sessionStoreQueue]]; - - TextSecureKitEnv *sharedEnv = - [[TextSecureKitEnv alloc] initWithCallMessageHandler:[SAECallMessageHandler new] - contactsManager:[Environment current].contactsManager - messageSender:[Environment current].messageSender - notificationsManager:[SAENotificationsManager new] - profileManager:OWSProfileManager.sharedManager]; - [TextSecureKitEnv setSharedEnv:sharedEnv]; - - [[TSStorageManager sharedManager] setupDatabaseWithSafeBlockingMigrations:^{ - [VersionMigrations runSafeBlockingMigrations]; - }]; - [[Environment current].contactsManager startObserving]; - }); -} - @end NS_ASSUME_NONNULL_END