Respond to CR.

pull/1/head
Matthew Chen 8 years ago
parent 99f0b9d3e8
commit 8312614cf7

@ -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 = "<group>"; };
346129D31FD20ADB00532771 /* UIViewController+OWS.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "UIViewController+OWS.m"; sourceTree = "<group>"; };
346129D41FD20ADC00532771 /* UIViewController+OWS.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "UIViewController+OWS.h"; sourceTree = "<group>"; };
346129D71FD5B84800532771 /* SAECallMessageHandler.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SAECallMessageHandler.swift; sourceTree = "<group>"; };
346129D81FD5B84900532771 /* SAENotificationsManager.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SAENotificationsManager.swift; sourceTree = "<group>"; };
346129DC1FD5C02900532771 /* LockInteractionController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = LockInteractionController.h; sourceTree = "<group>"; };
346129DD1FD5C02900532771 /* LockInteractionController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = LockInteractionController.m; sourceTree = "<group>"; };
346129E01FD5C0BE00532771 /* VersionMigrations.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = VersionMigrations.h; sourceTree = "<group>"; };
@ -569,6 +568,10 @@
3472229D1EB22FFE00E53955 /* AddToGroupViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AddToGroupViewController.h; sourceTree = "<group>"; };
3472229E1EB22FFE00E53955 /* AddToGroupViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = AddToGroupViewController.m; sourceTree = "<group>"; };
347850561FD86544007B8332 /* SAEFailedViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SAEFailedViewController.swift; sourceTree = "<group>"; };
347850651FD9B789007B8332 /* AppSetup.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = AppSetup.m; sourceTree = "<group>"; };
347850661FD9B789007B8332 /* AppSetup.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AppSetup.h; sourceTree = "<group>"; };
347850671FD9B78A007B8332 /* NoopCallMessageHandler.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = NoopCallMessageHandler.swift; sourceTree = "<group>"; };
347850681FD9B78A007B8332 /* NoopNotificationsManager.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = NoopNotificationsManager.swift; sourceTree = "<group>"; };
348F2EAD1F0D21BC00D4ECE0 /* DeviceSleepManager.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = DeviceSleepManager.swift; sourceTree = "<group>"; };
3495BC911F1426B800B478F5 /* ar */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = ar; path = translations/ar.lproj/Localizable.strings; sourceTree = "<group>"; };
3497DBEA1ECE257500DB2605 /* OWSCountryMetadata.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = OWSCountryMetadata.h; sourceTree = "<group>"; };
@ -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 */,

@ -25,6 +25,7 @@
#import "VersionMigrations.h"
#import "ViewControllerUtils.h"
#import <AxolotlKit/SessionCipher.h>
#import <SignalMessaging/AppSetup.h>
#import <SignalMessaging/OWSMath.h>
#import <SignalMessaging/OWSProfileManager.h>
#import <SignalMessaging/SignalMessaging.h>
@ -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);

@ -11,6 +11,7 @@ FOUNDATION_EXPORT double SignalMessagingVersionNumber;
FOUNDATION_EXPORT const unsigned char SignalMessagingVersionString[];
// The public headers of the framework
#import <SignalMessaging/AppSetup.h>
#import <SignalMessaging/DebugLogger.h>
#import <SignalMessaging/Environment.h>
#import <SignalMessaging/FullImageViewController.h>

@ -0,0 +1,21 @@
//
// Copyright (c) 2017 Open Whisper Systems. All rights reserved.
//
NS_ASSUME_NONNULL_BEGIN
@protocol OWSCallMessageHandler;
@protocol NotificationsProtocol;
typedef id<OWSCallMessageHandler> _Nonnull (^CallMessageHandlerBlock)(void);
typedef id<NotificationsProtocol> _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

@ -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 <AxolotlKit/SessionCipher.h>
#import <SignalMessaging/OWSProfileManager.h>
#import <SignalMessaging/SignalMessaging-Swift.h>
#import <SignalServiceKit/TextSecureKitEnv.h>
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<OWSCallMessageHandler> callMessageHandler = callMessageHandlerBlock();
id<NotificationsProtocol> 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

@ -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);

@ -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).")

@ -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).")

@ -6,7 +6,7 @@ import Foundation
import SignalServiceKit
@objc
class ConversationSearcher: NSObject {
public class ConversationSearcher: NSObject {
@objc
public static let shared: ConversationSearcher = ConversationSearcher()

@ -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,

@ -13,8 +13,6 @@ NS_ASSUME_NONNULL_BEGIN
- (instancetype)initWithRootViewController:(UIViewController *)rootViewController;
- (void)setupEnvironment;
@end
NS_ASSUME_NONNULL_END

@ -3,15 +3,7 @@
//
#import "ShareAppExtensionContext.h"
#import "SignalShareExtension-Swift.h"
#import <AxolotlKit/SessionCipher.h>
#import <SignalMessaging/Environment.h>
#import <SignalMessaging/OWSContactsManager.h>
#import <SignalMessaging/OWSProfileManager.h>
#import <SignalMessaging/Release.h>
#import <SignalMessaging/UIViewController+OWS.h>
#import <SignalMessaging/VersionMigrations.h>
#import <SignalServiceKit/TextSecureKitEnv.h>
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

Loading…
Cancel
Save