Respond to CR.

This commit is contained in:
Matthew Chen 2018-10-16 16:02:37 -04:00
parent 7c1f1882d8
commit 275414cbda
22 changed files with 69 additions and 59 deletions

View File

@ -28,7 +28,6 @@
#import <SignalMessaging/OWSNavigationController.h>
#import <SignalMessaging/OWSPreferences.h>
#import <SignalMessaging/OWSProfileManager.h>
#import <SignalMessaging/OWSSyncManager.h>
#import <SignalMessaging/SignalMessaging.h>
#import <SignalMessaging/VersionMigrations.h>
#import <SignalServiceKit/AppReadiness.h>
@ -193,9 +192,6 @@ static NSTimeInterval launchStartedAt;
screenBlockingWindow:OWSScreenLockUI.sharedManager.screenBlockingWindow];
[OWSScreenLockUI.sharedManager startObserving];
// Ensure OWSSyncManager is instantiated.
[OWSSyncManager shared];
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(storageIsReady)
name:StorageIsReadyNotification

View File

@ -17,7 +17,6 @@
#import <SignalServiceKit/OWSPrimaryStorage+SessionStore.h>
#import <SignalServiceKit/OWSPrimaryStorage.h>
#import <SignalServiceKit/OWSReadReceiptManager.h>
#import <SignalServiceKit/OWSSyncConfigurationMessage.h>
#import <SignalServiceKit/OWSSyncContactsMessage.h>
#import <SignalServiceKit/OWSSyncGroupsMessage.h>
#import <SignalServiceKit/OWSSyncGroupsRequestMessage.h>
@ -142,8 +141,7 @@ NS_ASSUME_NONNULL_BEGIN
+ (void)sendConfigurationSyncMessage
{
[NSNotificationCenter.defaultCenter postNotificationNameAsync:NSNotificationName_SyncConfigurationNeeded
object:nil];
[SSKEnvironment.shared.syncManager sendConfigurationSyncMessage];
}
@end

View File

@ -14,7 +14,6 @@ NS_ASSUME_NONNULL_BEGIN
@property (nonatomic) OWSContactsManager *contactsManager;
@property (nonatomic) OWSPreferences *preferences;
@property (nonatomic) OWSSyncManager *syncManager;
@property (nonatomic) OWSSounds *sounds;
@property (nonatomic) LockInteractionController *lockInteractionController;
@property (nonatomic) OWSWindowManager *windowManager;

View File

@ -4,7 +4,6 @@
#import "MockEnvironment.h"
#import "OWSBackup.h"
#import "OWSSyncManager.h"
#import "OWSWindowManager.h"
#import <SignalMessaging/LockInteractionController.h>
#import <SignalMessaging/OWSPreferences.h>
@ -28,13 +27,11 @@ NS_ASSUME_NONNULL_BEGIN
// TODO: We should probably mock this out.
OWSPreferences *preferences = [OWSPreferences new];
OWSSyncManager *syncManager = [[OWSSyncManager alloc] initDefault];
OWSSounds *sounds = [[OWSSounds alloc] initWithPrimaryStorage:primaryStorage];
LockInteractionController *lockInteractionController = [[LockInteractionController alloc] initDefault];
OWSWindowManager *windowManager = [[OWSWindowManager alloc] initDefault];
self = [super initWithPreferences:preferences
syncManager:syncManager
sounds:sounds
lockInteractionController:lockInteractionController
windowManager:windowManager];

View File

@ -2,6 +2,8 @@
// Copyright (c) 2018 Open Whisper Systems. All rights reserved.
//
#import <SignalServiceKit/OWSSyncManagerProtocol.h>
NS_ASSUME_NONNULL_BEGIN
@class OWSContactsManager;
@ -9,7 +11,7 @@ NS_ASSUME_NONNULL_BEGIN
@class OWSMessageSender;
@class OWSProfileManager;
@interface OWSSyncManager : NSObject
@interface OWSSyncManager : NSObject <OWSSyncManagerProtocol>
- (instancetype)init NS_UNAVAILABLE;

View File

@ -8,12 +8,14 @@
#import "OWSPreferences.h"
#import "OWSProfileManager.h"
#import "OWSReadReceiptManager.h"
#import <SignalServiceKit/AppReadiness.h>
#import <SignalServiceKit/DataSource.h>
#import <SignalServiceKit/MIMETypeUtil.h>
#import <SignalServiceKit/OWSMessageSender.h>
#import <SignalServiceKit/OWSPrimaryStorage.h>
#import <SignalServiceKit/OWSSyncConfigurationMessage.h>
#import <SignalServiceKit/OWSSyncContactsMessage.h>
#import <SignalServiceKit/SSKEnvironment.h>
#import <SignalServiceKit/TSAccountManager.h>
#import <SignalServiceKit/YapDatabaseConnection+OWS.h>
@ -33,9 +35,9 @@ NSString *const kOWSPrimaryStorageOWSSyncManagerLastMessageKey = @"kTSStorageMan
@implementation OWSSyncManager
+ (instancetype)shared {
OWSAssertDebug(Environment.shared.syncManager);
OWSAssertDebug(SSKEnvironment.shared.syncManager);
return Environment.shared.syncManager;
return SSKEnvironment.shared.syncManager;
}
- (instancetype)initDefault {
@ -55,10 +57,6 @@ NSString *const kOWSPrimaryStorageOWSSyncManagerLastMessageKey = @"kTSStorageMan
selector:@selector(profileKeyDidChange:)
name:kNSNotificationName_ProfileKeyDidChange
object:nil];
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(syncConfigurationNeeded:)
name:NSNotificationName_SyncConfigurationNeeded
object:nil];
return self;
}
@ -107,12 +105,6 @@ NSString *const kOWSPrimaryStorageOWSSyncManagerLastMessageKey = @"kTSStorageMan
[self sendSyncContactsMessageIfPossible];
}
- (void)syncConfigurationNeeded:(id)notification {
OWSAssertIsOnMainThread();
[self sendConfigurationSyncMessage];
}
#pragma mark -
- (YapDatabaseConnection *)editingDatabaseConnection {
@ -200,6 +192,12 @@ NSString *const kOWSPrimaryStorageOWSSyncManagerLastMessageKey = @"kTSStorageMan
}
- (void)sendConfigurationSyncMessage {
[AppReadiness runNowOrWhenAppIsReady:^{
[self sendConfigurationSyncMessage_AppReady];
}];
}
- (void)sendConfigurationSyncMessage_AppReady {
DDLogInfo(@"");
BOOL areReadReceiptsEnabled = SSKEnvironment.shared.readReceiptManager.areReadReceiptsEnabled;

View File

@ -88,7 +88,6 @@ NS_ASSUME_NONNULL_BEGIN
OWSWindowManager *windowManager = [[OWSWindowManager alloc] initDefault];
[Environment setShared:[[Environment alloc] initWithPreferences:preferences
syncManager:syncManager
sounds:sounds
lockInteractionController:lockInteractionController
windowManager:windowManager]];
@ -111,8 +110,9 @@ NS_ASSUME_NONNULL_BEGIN
ows2FAManager:ows2FAManager
disappearingMessagesJob:disappearingMessagesJob
contactDiscoveryService:contactDiscoveryService
disappearingMessagesJob:readReceiptManager
contactDiscoveryService:outgoingReceiptManager]];
readReceiptManager:readReceiptManager
outgoingReceiptManager:outgoingReceiptManager
syncManager:syncManager]];
appSpecificSingletonBlock();

View File

@ -8,7 +8,6 @@
@class OWSContactsManager;
@class OWSPreferences;
@class OWSSounds;
@class OWSSyncManager;
@class OWSWindowManager;
/**
@ -24,14 +23,12 @@
- (instancetype)init NS_UNAVAILABLE;
- (instancetype)initWithPreferences:(OWSPreferences *)preferences
syncManager:(OWSSyncManager *)syncManager
sounds:(OWSSounds *)sounds
lockInteractionController:(LockInteractionController *)lockInteractionController
windowManager:(OWSWindowManager *)windowManager;
@property (nonatomic, readonly) OWSContactsManager *contactsManager;
@property (nonatomic, readonly) OWSPreferences *preferences;
@property (nonatomic, readonly) OWSSyncManager *syncManager;
@property (nonatomic, readonly) OWSSounds *sounds;
@property (nonatomic, readonly) LockInteractionController *lockInteractionController;
@property (nonatomic, readonly) OWSWindowManager *windowManager;

View File

@ -13,7 +13,6 @@ static Environment *sharedEnvironment = nil;
@property (nonatomic) OWSContactsManager *contactsManager;
@property (nonatomic) OWSPreferences *preferences;
@property (nonatomic) OWSSyncManager *syncManager;
@property (nonatomic) OWSSounds *sounds;
@property (nonatomic) LockInteractionController *lockInteractionController;
@property (nonatomic) OWSWindowManager *windowManager;
@ -49,7 +48,6 @@ static Environment *sharedEnvironment = nil;
}
- (instancetype)initWithPreferences:(OWSPreferences *)preferences
syncManager:(OWSSyncManager *)syncManager
sounds:(OWSSounds *)sounds
lockInteractionController:(LockInteractionController *)lockInteractionController
windowManager:(OWSWindowManager *)windowManager {
@ -59,13 +57,11 @@ static Environment *sharedEnvironment = nil;
}
OWSAssertDebug(preferences);
OWSAssertDebug(syncManager);
OWSAssertDebug(sounds);
OWSAssertDebug(lockInteractionController);
OWSAssertDebug(windowManager);
_preferences = preferences;
_syncManager = syncManager;
_sounds = sounds;
_lockInteractionController = lockInteractionController;
_windowManager = windowManager;

View File

@ -6,7 +6,8 @@
#import <SignalServiceKit/AppContext.h>
#import <SignalServiceKit/NSNotificationCenter+OWS.h>
#import <SignalServiceKit/NSUserDefaults+OWS.h>
#import <SignalServiceKit/OWSSyncConfigurationMessage.h>
#import <SignalServiceKit/OWSSyncManagerProtocol.h>
#import <SignalServiceKit/SSKEnvironment.h>
#import <SignalServiceKit/TSStorageHeaders.h>
#import <SignalServiceKit/YapDatabaseConnection+OWS.h>
#import <SignalServiceKit/YapDatabaseTransaction+OWS.h>
@ -201,8 +202,7 @@ NSString *const OWSPreferencesKeySystemCallLogEnabled = @"OWSPreferencesKeySyste
{
[self setValueForKey:OWSPreferencesKeyShouldShowUnidentifiedDeliveryIndicators toValue:@(value)];
[NSNotificationCenter.defaultCenter postNotificationNameAsync:NSNotificationName_SyncConfigurationNeeded
object:nil];
[SSKEnvironment.shared.syncManager sendConfigurationSyncMessage];
}
#pragma mark - Calling

View File

@ -6,8 +6,6 @@
NS_ASSUME_NONNULL_BEGIN
extern NSString *const NSNotificationName_SyncConfigurationNeeded;
@interface OWSSyncConfigurationMessage : OWSOutgoingSyncMessage
- (instancetype)init NS_UNAVAILABLE;

View File

@ -7,8 +7,6 @@
NS_ASSUME_NONNULL_BEGIN
NSString *const NSNotificationName_SyncConfigurationNeeded = @"NSNotificationName_SyncConfigurationNeeded";
@interface OWSSyncConfigurationMessage ()
@property (nonatomic, readonly) BOOL areReadReceiptsEnabled;

View File

@ -27,7 +27,6 @@
#import "OWSPrimaryStorage.h"
#import "OWSReadReceiptManager.h"
#import "OWSRecordTranscriptJob.h"
#import "OWSSyncConfigurationMessage.h"
#import "OWSSyncContactsMessage.h"
#import "OWSSyncGroupsMessage.h"
#import "OWSSyncGroupsRequestMessage.h"
@ -849,8 +848,7 @@ NS_ASSUME_NONNULL_BEGIN
OWSLogInfo(@"Received request for block list");
[self.blockingManager syncBlockList];
} else if (syncMessage.request.type == SSKProtoSyncMessageRequestTypeConfiguration) {
[NSNotificationCenter.defaultCenter postNotificationNameAsync:NSNotificationName_SyncConfigurationNeeded
object:nil];
[SSKEnvironment.shared.syncManager sendConfigurationSyncMessage];
} else {
OWSLogWarn(@"ignoring unsupported sync request message");
}

View File

@ -4,7 +4,6 @@
#import "OWSReadReceiptManager.h"
#import "AppReadiness.h"
#import "NSNotificationCenter+OWS.h"
#import "OWSLinkedDeviceReadReceipt.h"
#import "OWSMessageSender.h"
#import "OWSOutgoingReceiptManager.h"
@ -12,7 +11,6 @@
#import "OWSReadReceiptsForLinkedDevicesMessage.h"
#import "OWSReceiptsForSenderMessage.h"
#import "OWSStorage.h"
#import "OWSSyncConfigurationMessage.h"
#import "SSKEnvironment.h"
#import "TSAccountManager.h"
#import "TSContactThread.h"
@ -571,8 +569,7 @@ NSString *const OWSReadReceiptManagerAreReadReceiptsEnabled = @"areReadReceiptsE
forKey:OWSReadReceiptManagerAreReadReceiptsEnabled
inCollection:OWSReadReceiptManagerCollection];
[NSNotificationCenter.defaultCenter postNotificationNameAsync:NSNotificationName_SyncConfigurationNeeded
object:nil];
[SSKEnvironment.shared.syncManager sendConfigurationSyncMessage];
self.areReadReceiptsEnabledCached = @(value);
}

View File

@ -28,6 +28,7 @@ NS_ASSUME_NONNULL_BEGIN
@protocol OWSCallMessageHandler;
@protocol ProfileManagerProtocol;
@protocol OWSUDManager;
@protocol OWSSyncManagerProtocol;
@interface SSKEnvironment : NSObject
@ -49,8 +50,9 @@ NS_ASSUME_NONNULL_BEGIN
ows2FAManager:(OWS2FAManager *)ows2FAManager
disappearingMessagesJob:(OWSDisappearingMessagesJob *)disappearingMessagesJob
contactDiscoveryService:(ContactDiscoveryService *)contactDiscoveryService
disappearingMessagesJob:(OWSReadReceiptManager *)readReceiptManager
contactDiscoveryService:(OWSOutgoingReceiptManager *)outgoingReceiptManager NS_DESIGNATED_INITIALIZER;
readReceiptManager:(OWSReadReceiptManager *)readReceiptManager
outgoingReceiptManager:(OWSOutgoingReceiptManager *)outgoingReceiptManager
syncManager:(id<OWSSyncManagerProtocol>)syncManager NS_DESIGNATED_INITIALIZER;
- (instancetype)init NS_UNAVAILABLE;
@ -83,6 +85,7 @@ NS_ASSUME_NONNULL_BEGIN
@property (nonatomic, readonly) ContactDiscoveryService *contactDiscoveryService;
@property (nonatomic, readonly) OWSReadReceiptManager *readReceiptManager;
@property (nonatomic, readonly) OWSOutgoingReceiptManager *outgoingReceiptManager;
@property (nonatomic, readonly) id<OWSSyncManagerProtocol> syncManager;
// This property is configured after Environment is created.
@property (atomic, nullable) id<OWSCallMessageHandler> callMessageHandler;

View File

@ -32,6 +32,7 @@ static SSKEnvironment *sharedSSKEnvironment;
@property (nonatomic) ContactDiscoveryService *contactDiscoveryService;
@property (nonatomic) OWSReadReceiptManager *readReceiptManager;
@property (nonatomic) OWSOutgoingReceiptManager *outgoingReceiptManager;
@property (nonatomic) id<OWSSyncManagerProtocol> syncManager;
@end
@ -64,9 +65,9 @@ static SSKEnvironment *sharedSSKEnvironment;
ows2FAManager:(OWS2FAManager *)ows2FAManager
disappearingMessagesJob:(OWSDisappearingMessagesJob *)disappearingMessagesJob
contactDiscoveryService:(ContactDiscoveryService *)contactDiscoveryService
disappearingMessagesJob:(OWSReadReceiptManager *)readReceiptManager
contactDiscoveryService:(OWSOutgoingReceiptManager *)outgoingReceiptManager
{
readReceiptManager:(OWSReadReceiptManager *)readReceiptManager
outgoingReceiptManager:(OWSOutgoingReceiptManager *)outgoingReceiptManager
syncManager:(id<OWSSyncManagerProtocol>)syncManager {
self = [super init];
if (!self) {
return self;
@ -92,6 +93,7 @@ static SSKEnvironment *sharedSSKEnvironment;
OWSAssertDebug(contactDiscoveryService);
OWSAssertDebug(readReceiptManager);
OWSAssertDebug(outgoingReceiptManager);
OWSAssertDebug(syncManager);
_contactsManager = contactsManager;
_messageSender = messageSender;
@ -113,6 +115,7 @@ static SSKEnvironment *sharedSSKEnvironment;
_contactDiscoveryService = contactDiscoveryService;
_readReceiptManager = readReceiptManager;
_outgoingReceiptManager = outgoingReceiptManager;
_syncManager = syncManager;
return self;
}

View File

@ -5,3 +5,4 @@
// Anything used by Swift outside of the framework must be imported.
#import "OWSFileSystem.h"
#import "OWSOperation.h"
#import "OWSSyncManagerProtocol.h"

View File

@ -72,6 +72,7 @@ NS_ASSUME_NONNULL_BEGIN
OWSReadReceiptManager *readReceiptManager = [[OWSReadReceiptManager alloc] initWithPrimaryStorage:primaryStorage];
OWSOutgoingReceiptManager *outgoingReceiptManager =
[[OWSOutgoingReceiptManager alloc] initWithPrimaryStorage:primaryStorage];
id<OWSSyncManagerProtocol> syncManager = [[OWSMockSyncManager alloc] init];
self = [super initWithContactsManager:contactsManager
messageSender:messageSender
@ -91,11 +92,13 @@ NS_ASSUME_NONNULL_BEGIN
ows2FAManager:ows2FAManager
disappearingMessagesJob:disappearingMessagesJob
contactDiscoveryService:contactDiscoveryService
disappearingMessagesJob:readReceiptManager
contactDiscoveryService:outgoingReceiptManager];
readReceiptManager:readReceiptManager
outgoingReceiptManager:outgoingReceiptManager
syncManager:syncManager];
if (!self) {
return nil;
}
self.callMessageHandler = [OWSFakeCallMessageHandler new];
self.notificationsManager = [OWSFakeNotificationsManager new];
return self;

View File

@ -0,0 +1,17 @@
//
// Copyright (c) 2018 Open Whisper Systems. All rights reserved.
//
import Foundation
#if DEBUG
@objc
public class OWSMockSyncManager: NSObject, OWSSyncManagerProtocol {
@objc public func sendConfigurationSyncMessage() {
Logger.info("")
}
}
#endif

View File

@ -0,0 +1,13 @@
//
// Copyright (c) 2018 Open Whisper Systems. All rights reserved.
//
NS_ASSUME_NONNULL_BEGIN
@protocol OWSSyncManagerProtocol <NSObject>
- (void)sendConfigurationSyncMessage;
@end
NS_ASSUME_NONNULL_END

View File

@ -104,9 +104,6 @@ public class ShareViewController: UIViewController, ShareViewDelegate, SAEFailed
// We don't need to use "screen protection" in the SAE.
// Ensure OWSSyncManager is instantiated.
OWSSyncManager.shared()
NotificationCenter.default.addObserver(self,
selector: #selector(storageIsReady),
name: .StorageIsReady,

View File

@ -16,7 +16,6 @@
#import <SignalMessaging/OWSContactsManager.h>
#import <SignalMessaging/OWSMath.h>
#import <SignalMessaging/OWSPreferences.h>
#import <SignalMessaging/OWSSyncManager.h>
#import <SignalMessaging/UIColor+OWS.h>
#import <SignalMessaging/UIFont+OWS.h>
#import <SignalMessaging/UIView+OWS.h>