Merge branch 'charlesmchen/syncUDIndicatorSetting'

pull/1/head
Matthew Chen 7 years ago
commit c7029ddb87

@ -1 +1 @@
Subproject commit 04eb1e2b2925464ac89ba15cbcc664a630450242
Subproject commit 217e71e8943e33bc683a4977ca297f431afb02c8

@ -123,8 +123,8 @@
346129FF1FD5F31400532771 /* OWS103EnableVideoCalling.m in Sources */ = {isa = PBXBuildFile; fileRef = 346129F21FD5F31400532771 /* OWS103EnableVideoCalling.m */; };
34612A001FD5F31400532771 /* OWS105AttachmentFilePaths.h in Headers */ = {isa = PBXBuildFile; fileRef = 346129F31FD5F31400532771 /* OWS105AttachmentFilePaths.h */; };
34612A011FD5F31400532771 /* OWS104CreateRecipientIdentities.h in Headers */ = {isa = PBXBuildFile; fileRef = 346129F41FD5F31400532771 /* OWS104CreateRecipientIdentities.h */; };
34612A061FD7238600532771 /* OWSContactsSyncing.h in Headers */ = {isa = PBXBuildFile; fileRef = 34612A041FD7238500532771 /* OWSContactsSyncing.h */; settings = {ATTRIBUTES = (Public, ); }; };
34612A071FD7238600532771 /* OWSContactsSyncing.m in Sources */ = {isa = PBXBuildFile; fileRef = 34612A051FD7238500532771 /* OWSContactsSyncing.m */; };
34612A061FD7238600532771 /* OWSSyncManager.h in Headers */ = {isa = PBXBuildFile; fileRef = 34612A041FD7238500532771 /* OWSSyncManager.h */; settings = {ATTRIBUTES = (Public, ); }; };
34612A071FD7238600532771 /* OWSSyncManager.m in Sources */ = {isa = PBXBuildFile; fileRef = 34612A051FD7238500532771 /* OWSSyncManager.m */; };
34641E182088D7E900E2EDE5 /* OWSScreenLock.swift in Sources */ = {isa = PBXBuildFile; fileRef = 34641E172088D7E900E2EDE5 /* OWSScreenLock.swift */; };
34641E1F2088DA6D00E2EDE5 /* SAEScreenLockViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 34641E1E2088DA6D00E2EDE5 /* SAEScreenLockViewController.m */; };
3466087220E550F400AFFE73 /* ConversationStyle.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3466087120E550F300AFFE73 /* ConversationStyle.swift */; };
@ -754,8 +754,8 @@
346129F21FD5F31400532771 /* OWS103EnableVideoCalling.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = OWS103EnableVideoCalling.m; sourceTree = "<group>"; };
346129F31FD5F31400532771 /* OWS105AttachmentFilePaths.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = OWS105AttachmentFilePaths.h; sourceTree = "<group>"; };
346129F41FD5F31400532771 /* OWS104CreateRecipientIdentities.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = OWS104CreateRecipientIdentities.h; sourceTree = "<group>"; };
34612A041FD7238500532771 /* OWSContactsSyncing.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = OWSContactsSyncing.h; sourceTree = "<group>"; };
34612A051FD7238500532771 /* OWSContactsSyncing.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = OWSContactsSyncing.m; sourceTree = "<group>"; };
34612A041FD7238500532771 /* OWSSyncManager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = OWSSyncManager.h; sourceTree = "<group>"; };
34612A051FD7238500532771 /* OWSSyncManager.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = OWSSyncManager.m; sourceTree = "<group>"; };
34641E1020878FAF00E2EDE5 /* OWSWindowManager.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = OWSWindowManager.m; sourceTree = "<group>"; };
34641E1120878FB000E2EDE5 /* OWSWindowManager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = OWSWindowManager.h; sourceTree = "<group>"; };
34641E172088D7E900E2EDE5 /* OWSScreenLock.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = OWSScreenLock.swift; sourceTree = "<group>"; };
@ -1645,8 +1645,8 @@
children = (
346129A21FD1F09100532771 /* OWSContactsManager.h */,
346129A31FD1F09100532771 /* OWSContactsManager.m */,
34612A041FD7238500532771 /* OWSContactsSyncing.h */,
34612A051FD7238500532771 /* OWSContactsSyncing.m */,
34612A041FD7238500532771 /* OWSSyncManager.h */,
34612A051FD7238500532771 /* OWSSyncManager.m */,
346129AE1FD1F5D900532771 /* SystemContactsFetcher.swift */,
);
path = contacts;
@ -2517,7 +2517,7 @@
34AC09EC211B39B100997B47 /* OWSTableViewController.h in Headers */,
451F8A3C1FD71392005CB9DA /* UIUtil.h in Headers */,
346129D61FD20ADC00532771 /* UIViewController+OWS.h in Headers */,
34612A061FD7238600532771 /* OWSContactsSyncing.h in Headers */,
34612A061FD7238600532771 /* OWSSyncManager.h in Headers */,
34480B571FD0A7A400BC14EF /* OWSScrubbingLogFormatter.h in Headers */,
346129FC1FD5F31400532771 /* OWS101ExistingUsersBlockOnIdentityChange.h in Headers */,
34AC09F2211B39B100997B47 /* OWSViewController.h in Headers */,
@ -3250,7 +3250,7 @@
34AC09F3211B39B100997B47 /* NewNonContactConversationViewController.m in Sources */,
34AC09FA211B39B100997B47 /* SharingThreadPickerViewController.m in Sources */,
45F59A082028E4FB00E8D2B0 /* OWSAudioSession.swift in Sources */,
34612A071FD7238600532771 /* OWSContactsSyncing.m in Sources */,
34612A071FD7238600532771 /* OWSSyncManager.m in Sources */,
450C801220AD1D5B00F3A091 /* UIDevice+featureSupport.swift in Sources */,
451F8A471FD715BA005CB9DA /* OWSAvatarBuilder.m in Sources */,
34AC09E7211B39B100997B47 /* MessageApprovalViewController.swift in Sources */,

@ -24,7 +24,6 @@
#import <SignalMessaging/AppSetup.h>
#import <SignalMessaging/Environment.h>
#import <SignalMessaging/OWSContactsManager.h>
#import <SignalMessaging/OWSContactsSyncing.h>
#import <SignalMessaging/OWSMath.h>
#import <SignalMessaging/OWSNavigationController.h>
#import <SignalMessaging/OWSPreferences.h>
@ -193,9 +192,6 @@ static NSTimeInterval launchStartedAt;
screenBlockingWindow:OWSScreenLockUI.sharedManager.screenBlockingWindow];
[OWSScreenLockUI.sharedManager startObserving];
// Ensure OWSContactsSyncing is instantiated.
[OWSContactsSyncing sharedManager];
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(storageIsReady)
name:StorageIsReadyNotification

@ -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,21 +141,7 @@ NS_ASSUME_NONNULL_BEGIN
+ (void)sendConfigurationSyncMessage
{
__block BOOL areReadReceiptsEnabled;
[self.dbConnection readWithBlock:^(YapDatabaseReadTransaction *transaction) {
areReadReceiptsEnabled =
[[OWSReadReceiptManager sharedManager] areReadReceiptsEnabledWithTransaction:transaction];
}];
OWSSyncConfigurationMessage *syncConfigurationMessage =
[[OWSSyncConfigurationMessage alloc] initWithReadReceiptsEnabled:areReadReceiptsEnabled];
[self.messageSender enqueueMessage:syncConfigurationMessage
success:^{
OWSLogInfo(@"Successfully sent Configuration response syncMessage.");
}
failure:^(NSError *error) {
OWSLogError(@"Failed to send Configuration response syncMessage with error: %@", error);
}];
[SSKEnvironment.shared.syncManager sendConfigurationSyncMessage];
}
@end

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

@ -4,7 +4,6 @@
#import "MockEnvironment.h"
#import "OWSBackup.h"
#import "OWSContactsSyncing.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];
OWSContactsSyncing *contactsSyncing = [[OWSContactsSyncing alloc] initDefault];
OWSSounds *sounds = [[OWSSounds alloc] initWithPrimaryStorage:primaryStorage];
LockInteractionController *lockInteractionController = [[LockInteractionController alloc] initDefault];
OWSWindowManager *windowManager = [[OWSWindowManager alloc] initDefault];
self = [super initWithPreferences:preferences
contactsSyncing:contactsSyncing
sounds:sounds
lockInteractionController:lockInteractionController
windowManager:windowManager];

@ -28,7 +28,6 @@ FOUNDATION_EXPORT const unsigned char SignalMessagingVersionString[];
#import <SignalMessaging/OWSContactAvatarBuilder.h>
#import <SignalMessaging/OWSContactOffersInteraction.h>
#import <SignalMessaging/OWSContactsManager.h>
#import <SignalMessaging/OWSContactsSyncing.h>
#import <SignalMessaging/OWSConversationColor.h>
#import <SignalMessaging/OWSDatabaseMigration.h>
#import <SignalMessaging/OWSFormat.h>
@ -40,6 +39,7 @@ FOUNDATION_EXPORT const unsigned char SignalMessagingVersionString[];
#import <SignalMessaging/OWSQuotedReplyModel.h>
#import <SignalMessaging/OWSSearchBar.h>
#import <SignalMessaging/OWSSounds.h>
#import <SignalMessaging/OWSSyncManager.h>
#import <SignalMessaging/OWSTableViewController.h>
#import <SignalMessaging/OWSTextField.h>
#import <SignalMessaging/OWSTextView.h>

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

@ -2,25 +2,29 @@
// Copyright (c) 2018 Open Whisper Systems. All rights reserved.
//
#import "OWSContactsSyncing.h"
#import "OWSSyncManager.h"
#import "Environment.h"
#import "OWSContactsManager.h"
#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>
NS_ASSUME_NONNULL_BEGIN
NSString *const kOWSPrimaryStorageOWSContactsSyncingCollection = @"kTSStorageManagerOWSContactsSyncingCollection";
NSString *const kOWSPrimaryStorageOWSContactsSyncingLastMessageKey
= @"kTSStorageManagerOWSContactsSyncingLastMessageKey";
NSString *const kSyncManagerCollection = @"kTSStorageManagerOWSSyncManagerCollection";
NSString *const kSyncManagerLastContactSyncKey = @"kTSStorageManagerOWSSyncManagerLastMessageKey";
@interface OWSContactsSyncing ()
@interface OWSSyncManager ()
@property (nonatomic, readonly) dispatch_queue_t serialQueue;
@ -28,17 +32,15 @@ NSString *const kOWSPrimaryStorageOWSContactsSyncingLastMessageKey
@end
@implementation OWSContactsSyncing
@implementation OWSSyncManager
+ (instancetype)sharedManager
{
OWSAssertDebug(Environment.shared.contactsSyncing);
+ (instancetype)shared {
OWSAssertDebug(SSKEnvironment.shared.syncManager);
return Environment.shared.contactsSyncing;
return SSKEnvironment.shared.syncManager;
}
- (instancetype)initDefault
{
- (instancetype)initDefault {
self = [super init];
if (!self) {
@ -59,8 +61,7 @@ NSString *const kOWSPrimaryStorageOWSContactsSyncingLastMessageKey
return self;
}
- (void)dealloc
{
- (void)dealloc {
[[NSNotificationCenter defaultCenter] removeObserver:self];
}
@ -90,10 +91,9 @@ NSString *const kOWSPrimaryStorageOWSContactsSyncingLastMessageKey
return SSKEnvironment.shared.profileManager;
}
#pragma mark -
#pragma mark - Notifications
- (void)signalAccountsDidChange:(id)notification
{
- (void)signalAccountsDidChange:(id)notification {
OWSAssertIsOnMainThread();
[self sendSyncContactsMessageIfPossible];
@ -105,15 +105,15 @@ NSString *const kOWSPrimaryStorageOWSContactsSyncingLastMessageKey
[self sendSyncContactsMessageIfPossible];
}
- (YapDatabaseConnection *)editingDatabaseConnection
{
#pragma mark -
- (YapDatabaseConnection *)editingDatabaseConnection {
return OWSPrimaryStorage.sharedManager.dbReadWriteConnection;
}
#pragma mark - Methods
- (void)sendSyncContactsMessageIfNecessary
{
- (void)sendSyncContactsMessageIfNecessary {
OWSAssertIsOnMainThread();
if (!self.serialQueue) {
@ -121,7 +121,6 @@ NSString *const kOWSPrimaryStorageOWSContactsSyncingLastMessageKey
}
dispatch_async(self.serialQueue, ^{
if (self.isRequestInFlight) {
// De-bounce. It's okay if we ignore some new changes;
// `sendSyncContactsMessageIfPossible` is called fairly
@ -138,8 +137,8 @@ NSString *const kOWSPrimaryStorageOWSContactsSyncingLastMessageKey
__block NSData *_Nullable lastMessageData;
[self.editingDatabaseConnection readWithBlock:^(YapDatabaseReadTransaction *transaction) {
messageData = [syncContactsMessage buildPlainTextAttachmentDataWithTransaction:transaction];
lastMessageData = [transaction objectForKey:kOWSPrimaryStorageOWSContactsSyncingLastMessageKey
inCollection:kOWSPrimaryStorageOWSContactsSyncingCollection];
lastMessageData = [transaction objectForKey:kSyncManagerLastContactSyncKey
inCollection:kSyncManagerCollection];
}];
if (!messageData) {
@ -162,8 +161,8 @@ NSString *const kOWSPrimaryStorageOWSContactsSyncingLastMessageKey
OWSLogInfo(@"Successfully sent contacts sync message.");
[self.editingDatabaseConnection setObject:messageData
forKey:kOWSPrimaryStorageOWSContactsSyncingLastMessageKey
inCollection:kOWSPrimaryStorageOWSContactsSyncingCollection];
forKey:kSyncManagerLastContactSyncKey
inCollection:kSyncManagerCollection];
dispatch_async(self.serialQueue, ^{
self.isRequestInFlight = NO;
@ -179,8 +178,7 @@ NSString *const kOWSPrimaryStorageOWSContactsSyncingLastMessageKey
});
}
- (void)sendSyncContactsMessageIfPossible
{
- (void)sendSyncContactsMessageIfPossible {
OWSAssertIsOnMainThread();
if (!self.contactsManager.isSetup) {
@ -193,6 +191,30 @@ NSString *const kOWSPrimaryStorageOWSContactsSyncingLastMessageKey
}
}
- (void)sendConfigurationSyncMessage {
[AppReadiness runNowOrWhenAppIsReady:^{
[self sendConfigurationSyncMessage_AppReady];
}];
}
- (void)sendConfigurationSyncMessage_AppReady {
DDLogInfo(@"");
BOOL areReadReceiptsEnabled = SSKEnvironment.shared.readReceiptManager.areReadReceiptsEnabled;
BOOL showUnidentifiedDeliveryIndicators = Environment.shared.preferences.shouldShowUnidentifiedDeliveryIndicators;
OWSSyncConfigurationMessage *syncConfigurationMessage =
[[OWSSyncConfigurationMessage alloc] initWithReadReceiptsEnabled:areReadReceiptsEnabled
showUnidentifiedDeliveryIndicators:showUnidentifiedDeliveryIndicators];
[self.messageSender enqueueMessage:syncConfigurationMessage
success:^{
OWSLogInfo(@"Send configuration sync message succeeded.");
}
failure:^(NSError *error) {
OWSLogError(@"Send configuration sync message failed with error: %@", error);
}];
}
@end
NS_ASSUME_NONNULL_END

@ -82,13 +82,12 @@ NS_ASSUME_NONNULL_BEGIN
OWSOutgoingReceiptManager *outgoingReceiptManager =
[[OWSOutgoingReceiptManager alloc] initWithPrimaryStorage:primaryStorage];
OWSContactsSyncing *contactsSyncing = [[OWSContactsSyncing alloc] initDefault];
OWSSyncManager *syncManager = [[OWSSyncManager alloc] initDefault];
OWSSounds *sounds = [[OWSSounds alloc] initWithPrimaryStorage:primaryStorage];
LockInteractionController *lockInteractionController = [[LockInteractionController alloc] initDefault];
OWSWindowManager *windowManager = [[OWSWindowManager alloc] initDefault];
[Environment setShared:[[Environment alloc] initWithPreferences:preferences
contactsSyncing:contactsSyncing
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();

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

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

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

@ -283,6 +283,7 @@ message SyncMessage {
message Configuration {
optional bool readReceipts = 1;
optional bool unidentifiedDeliveryIndicators = 2;
}
optional Sent sent = 1;

@ -10,7 +10,8 @@ NS_ASSUME_NONNULL_BEGIN
- (instancetype)init NS_UNAVAILABLE;
- (instancetype)initWithReadReceiptsEnabled:(BOOL)readReceiptsEnabled NS_DESIGNATED_INITIALIZER;
- (instancetype)initWithReadReceiptsEnabled:(BOOL)readReceiptsEnabled
showUnidentifiedDeliveryIndicators:(BOOL)showUnidentifiedDeliveryIndicators NS_DESIGNATED_INITIALIZER;
- (nullable instancetype)initWithCoder:(NSCoder *)coder NS_DESIGNATED_INITIALIZER;
@end

@ -10,19 +10,21 @@ NS_ASSUME_NONNULL_BEGIN
@interface OWSSyncConfigurationMessage ()
@property (nonatomic, readonly) BOOL areReadReceiptsEnabled;
@property (nonatomic, readonly) BOOL showUnidentifiedDeliveryIndicators;
@end
@implementation OWSSyncConfigurationMessage
- (instancetype)initWithReadReceiptsEnabled:(BOOL)areReadReceiptsEnabled
{
showUnidentifiedDeliveryIndicators:(BOOL)showUnidentifiedDeliveryIndicators {
self = [super init];
if (!self) {
return nil;
}
_areReadReceiptsEnabled = areReadReceiptsEnabled;
_showUnidentifiedDeliveryIndicators = showUnidentifiedDeliveryIndicators;
return self;
}
@ -36,6 +38,7 @@ NS_ASSUME_NONNULL_BEGIN
{
SSKProtoSyncMessageConfigurationBuilder *configurationBuilder = [SSKProtoSyncMessageConfiguration builder];
configurationBuilder.readReceipts = self.areReadReceiptsEnabled;
configurationBuilder.unidentifiedDeliveryIndicators = self.showUnidentifiedDeliveryIndicators;
NSError *error;
SSKProtoSyncMessageConfiguration *_Nullable configurationProto = [configurationBuilder buildAndReturnError:&error];

@ -7,6 +7,7 @@
#import "AppReadiness.h"
#import "ContactsManagerProtocol.h"
#import "MimeTypeUtil.h"
#import "NSNotificationCenter+OWS.h"
#import "NotificationsProtocol.h"
#import "OWSAttachmentsProcessor.h"
#import "OWSBlockingManager.h"
@ -26,7 +27,6 @@
#import "OWSPrimaryStorage.h"
#import "OWSReadReceiptManager.h"
#import "OWSRecordTranscriptJob.h"
#import "OWSSyncConfigurationMessage.h"
#import "OWSSyncContactsMessage.h"
#import "OWSSyncGroupsMessage.h"
#import "OWSSyncGroupsRequestMessage.h"
@ -848,17 +848,7 @@ NS_ASSUME_NONNULL_BEGIN
OWSLogInfo(@"Received request for block list");
[self.blockingManager syncBlockList];
} else if (syncMessage.request.type == SSKProtoSyncMessageRequestTypeConfiguration) {
BOOL areReadReceiptsEnabled =
[[OWSReadReceiptManager sharedManager] areReadReceiptsEnabledWithTransaction:transaction];
OWSSyncConfigurationMessage *syncConfigurationMessage =
[[OWSSyncConfigurationMessage alloc] initWithReadReceiptsEnabled:areReadReceiptsEnabled];
[self.messageSender enqueueMessage:syncConfigurationMessage
success:^{
OWSLogInfo(@"Successfully sent Configuration response syncMessage.");
}
failure:^(NSError *error) {
OWSLogError(@"Failed to send Configuration response syncMessage with error: %@", error);
}];
[SSKEnvironment.shared.syncManager sendConfigurationSyncMessage];
} else {
OWSLogWarn(@"ignoring unsupported sync request message");
}

@ -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,15 +569,7 @@ NSString *const OWSReadReceiptManagerAreReadReceiptsEnabled = @"areReadReceiptsE
forKey:OWSReadReceiptManagerAreReadReceiptsEnabled
inCollection:OWSReadReceiptManagerCollection];
OWSSyncConfigurationMessage *syncConfigurationMessage =
[[OWSSyncConfigurationMessage alloc] initWithReadReceiptsEnabled:value];
[self.messageSender enqueueMessage:syncConfigurationMessage
success:^{
OWSLogInfo(@"Successfully sent Configuration syncMessage.");
}
failure:^(NSError *error) {
OWSLogError(@"Failed to send Configuration syncMessage with error: %@", error);
}];
[SSKEnvironment.shared.syncManager sendConfigurationSyncMessage];
self.areReadReceiptsEnabledCached = @(value);
}

@ -3984,6 +3984,9 @@ extension SSKProtoSyncMessageRead.SSKProtoSyncMessageReadBuilder {
if hasReadReceipts {
builder.setReadReceipts(readReceipts)
}
if hasUnidentifiedDeliveryIndicators {
builder.setUnidentifiedDeliveryIndicators(unidentifiedDeliveryIndicators)
}
return builder
}
@ -3997,6 +4000,10 @@ extension SSKProtoSyncMessageRead.SSKProtoSyncMessageReadBuilder {
proto.readReceipts = valueParam
}
@objc public func setUnidentifiedDeliveryIndicators(_ valueParam: Bool) {
proto.unidentifiedDeliveryIndicators = valueParam
}
@objc public func build() throws -> SSKProtoSyncMessageConfiguration {
return try SSKProtoSyncMessageConfiguration.parseProto(proto)
}
@ -4015,6 +4022,13 @@ extension SSKProtoSyncMessageRead.SSKProtoSyncMessageReadBuilder {
return proto.hasReadReceipts
}
@objc public var unidentifiedDeliveryIndicators: Bool {
return proto.unidentifiedDeliveryIndicators
}
@objc public var hasUnidentifiedDeliveryIndicators: Bool {
return proto.hasUnidentifiedDeliveryIndicators
}
private init(proto: SignalServiceProtos_SyncMessage.Configuration) {
self.proto = proto
}

@ -1646,11 +1646,21 @@ struct SignalServiceProtos_SyncMessage {
/// Clears the value of `readReceipts`. Subsequent reads from it will return its default value.
mutating func clearReadReceipts() {self._readReceipts = nil}
var unidentifiedDeliveryIndicators: Bool {
get {return _unidentifiedDeliveryIndicators ?? false}
set {_unidentifiedDeliveryIndicators = newValue}
}
/// Returns true if `unidentifiedDeliveryIndicators` has been explicitly set.
var hasUnidentifiedDeliveryIndicators: Bool {return self._unidentifiedDeliveryIndicators != nil}
/// Clears the value of `unidentifiedDeliveryIndicators`. Subsequent reads from it will return its default value.
mutating func clearUnidentifiedDeliveryIndicators() {self._unidentifiedDeliveryIndicators = nil}
var unknownFields = SwiftProtobuf.UnknownStorage()
init() {}
fileprivate var _readReceipts: Bool? = nil
fileprivate var _unidentifiedDeliveryIndicators: Bool? = nil
}
init() {}
@ -3895,12 +3905,14 @@ extension SignalServiceProtos_SyncMessage.Configuration: SwiftProtobuf.Message,
static let protoMessageName: String = SignalServiceProtos_SyncMessage.protoMessageName + ".Configuration"
static let _protobuf_nameMap: SwiftProtobuf._NameMap = [
1: .same(proto: "readReceipts"),
2: .same(proto: "unidentifiedDeliveryIndicators"),
]
mutating func decodeMessage<D: SwiftProtobuf.Decoder>(decoder: inout D) throws {
while let fieldNumber = try decoder.nextFieldNumber() {
switch fieldNumber {
case 1: try decoder.decodeSingularBoolField(value: &self._readReceipts)
case 2: try decoder.decodeSingularBoolField(value: &self._unidentifiedDeliveryIndicators)
default: break
}
}
@ -3910,11 +3922,15 @@ extension SignalServiceProtos_SyncMessage.Configuration: SwiftProtobuf.Message,
if let v = self._readReceipts {
try visitor.visitSingularBoolField(value: v, fieldNumber: 1)
}
if let v = self._unidentifiedDeliveryIndicators {
try visitor.visitSingularBoolField(value: v, fieldNumber: 2)
}
try unknownFields.traverse(visitor: &visitor)
}
static func ==(lhs: SignalServiceProtos_SyncMessage.Configuration, rhs: SignalServiceProtos_SyncMessage.Configuration) -> Bool {
if lhs._readReceipts != rhs._readReceipts {return false}
if lhs._unidentifiedDeliveryIndicators != rhs._unidentifiedDeliveryIndicators {return false}
if lhs.unknownFields != rhs.unknownFields {return false}
return true
}

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

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

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

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

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

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

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

@ -14,7 +14,6 @@
#import <SignalMessaging/DebugLogger.h>
#import <SignalMessaging/Environment.h>
#import <SignalMessaging/OWSContactsManager.h>
#import <SignalMessaging/OWSContactsSyncing.h>
#import <SignalMessaging/OWSMath.h>
#import <SignalMessaging/OWSPreferences.h>
#import <SignalMessaging/UIColor+OWS.h>

Loading…
Cancel
Save