Sync "show UD indicators" setting.

pull/1/head
Matthew Chen 7 years ago
parent 43960aadd6
commit 7c1f1882d8

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

@ -24,11 +24,11 @@
#import <SignalMessaging/AppSetup.h> #import <SignalMessaging/AppSetup.h>
#import <SignalMessaging/Environment.h> #import <SignalMessaging/Environment.h>
#import <SignalMessaging/OWSContactsManager.h> #import <SignalMessaging/OWSContactsManager.h>
#import <SignalMessaging/OWSContactsSyncing.h>
#import <SignalMessaging/OWSMath.h> #import <SignalMessaging/OWSMath.h>
#import <SignalMessaging/OWSNavigationController.h> #import <SignalMessaging/OWSNavigationController.h>
#import <SignalMessaging/OWSPreferences.h> #import <SignalMessaging/OWSPreferences.h>
#import <SignalMessaging/OWSProfileManager.h> #import <SignalMessaging/OWSProfileManager.h>
#import <SignalMessaging/OWSSyncManager.h>
#import <SignalMessaging/SignalMessaging.h> #import <SignalMessaging/SignalMessaging.h>
#import <SignalMessaging/VersionMigrations.h> #import <SignalMessaging/VersionMigrations.h>
#import <SignalServiceKit/AppReadiness.h> #import <SignalServiceKit/AppReadiness.h>
@ -193,8 +193,8 @@ static NSTimeInterval launchStartedAt;
screenBlockingWindow:OWSScreenLockUI.sharedManager.screenBlockingWindow]; screenBlockingWindow:OWSScreenLockUI.sharedManager.screenBlockingWindow];
[OWSScreenLockUI.sharedManager startObserving]; [OWSScreenLockUI.sharedManager startObserving];
// Ensure OWSContactsSyncing is instantiated. // Ensure OWSSyncManager is instantiated.
[OWSContactsSyncing sharedManager]; [OWSSyncManager shared];
[[NSNotificationCenter defaultCenter] addObserver:self [[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(storageIsReady) selector:@selector(storageIsReady)

@ -142,21 +142,8 @@ NS_ASSUME_NONNULL_BEGIN
+ (void)sendConfigurationSyncMessage + (void)sendConfigurationSyncMessage
{ {
__block BOOL areReadReceiptsEnabled; [NSNotificationCenter.defaultCenter postNotificationNameAsync:NSNotificationName_SyncConfigurationNeeded
[self.dbConnection readWithBlock:^(YapDatabaseReadTransaction *transaction) { object:nil];
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);
}];
} }
@end @end

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

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

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

@ -9,13 +9,13 @@ NS_ASSUME_NONNULL_BEGIN
@class OWSMessageSender; @class OWSMessageSender;
@class OWSProfileManager; @class OWSProfileManager;
@interface OWSContactsSyncing : NSObject @interface OWSSyncManager : NSObject
- (instancetype)init NS_UNAVAILABLE; - (instancetype)init NS_UNAVAILABLE;
- (instancetype)initDefault NS_DESIGNATED_INITIALIZER; - (instancetype)initDefault NS_DESIGNATED_INITIALIZER;
+ (instancetype)sharedManager; + (instancetype)shared;
@end @end

@ -2,25 +2,27 @@
// Copyright (c) 2018 Open Whisper Systems. All rights reserved. // Copyright (c) 2018 Open Whisper Systems. All rights reserved.
// //
#import "OWSContactsSyncing.h" #import "OWSSyncManager.h"
#import "Environment.h" #import "Environment.h"
#import "OWSContactsManager.h" #import "OWSContactsManager.h"
#import "OWSPreferences.h"
#import "OWSProfileManager.h" #import "OWSProfileManager.h"
#import "OWSReadReceiptManager.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>
#import <SignalServiceKit/OWSPrimaryStorage.h> #import <SignalServiceKit/OWSPrimaryStorage.h>
#import <SignalServiceKit/OWSSyncConfigurationMessage.h>
#import <SignalServiceKit/OWSSyncContactsMessage.h> #import <SignalServiceKit/OWSSyncContactsMessage.h>
#import <SignalServiceKit/TSAccountManager.h> #import <SignalServiceKit/TSAccountManager.h>
#import <SignalServiceKit/YapDatabaseConnection+OWS.h> #import <SignalServiceKit/YapDatabaseConnection+OWS.h>
NS_ASSUME_NONNULL_BEGIN NS_ASSUME_NONNULL_BEGIN
NSString *const kOWSPrimaryStorageOWSContactsSyncingCollection = @"kTSStorageManagerOWSContactsSyncingCollection"; NSString *const kOWSPrimaryStorageOWSSyncManagerCollection = @"kTSStorageManagerOWSSyncManagerCollection";
NSString *const kOWSPrimaryStorageOWSContactsSyncingLastMessageKey NSString *const kOWSPrimaryStorageOWSSyncManagerLastMessageKey = @"kTSStorageManagerOWSSyncManagerLastMessageKey";
= @"kTSStorageManagerOWSContactsSyncingLastMessageKey";
@interface OWSContactsSyncing () @interface OWSSyncManager ()
@property (nonatomic, readonly) dispatch_queue_t serialQueue; @property (nonatomic, readonly) dispatch_queue_t serialQueue;
@ -28,17 +30,15 @@ NSString *const kOWSPrimaryStorageOWSContactsSyncingLastMessageKey
@end @end
@implementation OWSContactsSyncing @implementation OWSSyncManager
+ (instancetype)sharedManager + (instancetype)shared {
{ OWSAssertDebug(Environment.shared.syncManager);
OWSAssertDebug(Environment.shared.contactsSyncing);
return Environment.shared.contactsSyncing; return Environment.shared.syncManager;
} }
- (instancetype)initDefault - (instancetype)initDefault {
{
self = [super init]; self = [super init];
if (!self) { if (!self) {
@ -55,12 +55,15 @@ NSString *const kOWSPrimaryStorageOWSContactsSyncingLastMessageKey
selector:@selector(profileKeyDidChange:) selector:@selector(profileKeyDidChange:)
name:kNSNotificationName_ProfileKeyDidChange name:kNSNotificationName_ProfileKeyDidChange
object:nil]; object:nil];
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(syncConfigurationNeeded:)
name:NSNotificationName_SyncConfigurationNeeded
object:nil];
return self; return self;
} }
- (void)dealloc - (void)dealloc {
{
[[NSNotificationCenter defaultCenter] removeObserver:self]; [[NSNotificationCenter defaultCenter] removeObserver:self];
} }
@ -90,10 +93,9 @@ NSString *const kOWSPrimaryStorageOWSContactsSyncingLastMessageKey
return SSKEnvironment.shared.profileManager; return SSKEnvironment.shared.profileManager;
} }
#pragma mark - #pragma mark - Notifications
- (void)signalAccountsDidChange:(id)notification - (void)signalAccountsDidChange:(id)notification {
{
OWSAssertIsOnMainThread(); OWSAssertIsOnMainThread();
[self sendSyncContactsMessageIfPossible]; [self sendSyncContactsMessageIfPossible];
@ -105,15 +107,21 @@ NSString *const kOWSPrimaryStorageOWSContactsSyncingLastMessageKey
[self sendSyncContactsMessageIfPossible]; [self sendSyncContactsMessageIfPossible];
} }
- (YapDatabaseConnection *)editingDatabaseConnection - (void)syncConfigurationNeeded:(id)notification {
{ OWSAssertIsOnMainThread();
[self sendConfigurationSyncMessage];
}
#pragma mark -
- (YapDatabaseConnection *)editingDatabaseConnection {
return OWSPrimaryStorage.sharedManager.dbReadWriteConnection; return OWSPrimaryStorage.sharedManager.dbReadWriteConnection;
} }
#pragma mark - Methods #pragma mark - Methods
- (void)sendSyncContactsMessageIfNecessary - (void)sendSyncContactsMessageIfNecessary {
{
OWSAssertIsOnMainThread(); OWSAssertIsOnMainThread();
if (!self.serialQueue) { if (!self.serialQueue) {
@ -121,7 +129,6 @@ NSString *const kOWSPrimaryStorageOWSContactsSyncingLastMessageKey
} }
dispatch_async(self.serialQueue, ^{ dispatch_async(self.serialQueue, ^{
if (self.isRequestInFlight) { if (self.isRequestInFlight) {
// De-bounce. It's okay if we ignore some new changes; // De-bounce. It's okay if we ignore some new changes;
// `sendSyncContactsMessageIfPossible` is called fairly // `sendSyncContactsMessageIfPossible` is called fairly
@ -138,8 +145,8 @@ NSString *const kOWSPrimaryStorageOWSContactsSyncingLastMessageKey
__block NSData *_Nullable lastMessageData; __block NSData *_Nullable lastMessageData;
[self.editingDatabaseConnection readWithBlock:^(YapDatabaseReadTransaction *transaction) { [self.editingDatabaseConnection readWithBlock:^(YapDatabaseReadTransaction *transaction) {
messageData = [syncContactsMessage buildPlainTextAttachmentDataWithTransaction:transaction]; messageData = [syncContactsMessage buildPlainTextAttachmentDataWithTransaction:transaction];
lastMessageData = [transaction objectForKey:kOWSPrimaryStorageOWSContactsSyncingLastMessageKey lastMessageData = [transaction objectForKey:kOWSPrimaryStorageOWSSyncManagerLastMessageKey
inCollection:kOWSPrimaryStorageOWSContactsSyncingCollection]; inCollection:kOWSPrimaryStorageOWSSyncManagerCollection];
}]; }];
if (!messageData) { if (!messageData) {
@ -162,8 +169,8 @@ NSString *const kOWSPrimaryStorageOWSContactsSyncingLastMessageKey
OWSLogInfo(@"Successfully sent contacts sync message."); OWSLogInfo(@"Successfully sent contacts sync message.");
[self.editingDatabaseConnection setObject:messageData [self.editingDatabaseConnection setObject:messageData
forKey:kOWSPrimaryStorageOWSContactsSyncingLastMessageKey forKey:kOWSPrimaryStorageOWSSyncManagerLastMessageKey
inCollection:kOWSPrimaryStorageOWSContactsSyncingCollection]; inCollection:kOWSPrimaryStorageOWSSyncManagerCollection];
dispatch_async(self.serialQueue, ^{ dispatch_async(self.serialQueue, ^{
self.isRequestInFlight = NO; self.isRequestInFlight = NO;
@ -179,8 +186,7 @@ NSString *const kOWSPrimaryStorageOWSContactsSyncingLastMessageKey
}); });
} }
- (void)sendSyncContactsMessageIfPossible - (void)sendSyncContactsMessageIfPossible {
{
OWSAssertIsOnMainThread(); OWSAssertIsOnMainThread();
if (!self.contactsManager.isSetup) { if (!self.contactsManager.isSetup) {
@ -193,6 +199,24 @@ NSString *const kOWSPrimaryStorageOWSContactsSyncingLastMessageKey
} }
} }
- (void)sendConfigurationSyncMessage {
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 @end
NS_ASSUME_NONNULL_END NS_ASSUME_NONNULL_END

@ -82,13 +82,13 @@ NS_ASSUME_NONNULL_BEGIN
OWSOutgoingReceiptManager *outgoingReceiptManager = OWSOutgoingReceiptManager *outgoingReceiptManager =
[[OWSOutgoingReceiptManager alloc] initWithPrimaryStorage:primaryStorage]; [[OWSOutgoingReceiptManager alloc] initWithPrimaryStorage:primaryStorage];
OWSContactsSyncing *contactsSyncing = [[OWSContactsSyncing alloc] initDefault]; OWSSyncManager *syncManager = [[OWSSyncManager alloc] initDefault];
OWSSounds *sounds = [[OWSSounds alloc] initWithPrimaryStorage:primaryStorage]; OWSSounds *sounds = [[OWSSounds alloc] initWithPrimaryStorage:primaryStorage];
LockInteractionController *lockInteractionController = [[LockInteractionController alloc] initDefault]; LockInteractionController *lockInteractionController = [[LockInteractionController alloc] initDefault];
OWSWindowManager *windowManager = [[OWSWindowManager alloc] initDefault]; OWSWindowManager *windowManager = [[OWSWindowManager alloc] initDefault];
[Environment setShared:[[Environment alloc] initWithPreferences:preferences [Environment setShared:[[Environment alloc] initWithPreferences:preferences
contactsSyncing:contactsSyncing syncManager:syncManager
sounds:sounds sounds:sounds
lockInteractionController:lockInteractionController lockInteractionController:lockInteractionController
windowManager:windowManager]]; windowManager:windowManager]];

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

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

@ -6,6 +6,7 @@
#import <SignalServiceKit/AppContext.h> #import <SignalServiceKit/AppContext.h>
#import <SignalServiceKit/NSNotificationCenter+OWS.h> #import <SignalServiceKit/NSNotificationCenter+OWS.h>
#import <SignalServiceKit/NSUserDefaults+OWS.h> #import <SignalServiceKit/NSUserDefaults+OWS.h>
#import <SignalServiceKit/OWSSyncConfigurationMessage.h>
#import <SignalServiceKit/TSStorageHeaders.h> #import <SignalServiceKit/TSStorageHeaders.h>
#import <SignalServiceKit/YapDatabaseConnection+OWS.h> #import <SignalServiceKit/YapDatabaseConnection+OWS.h>
#import <SignalServiceKit/YapDatabaseTransaction+OWS.h> #import <SignalServiceKit/YapDatabaseTransaction+OWS.h>
@ -199,6 +200,9 @@ NSString *const OWSPreferencesKeySystemCallLogEnabled = @"OWSPreferencesKeySyste
- (void)setShouldShowUnidentifiedDeliveryIndicators:(BOOL)value - (void)setShouldShowUnidentifiedDeliveryIndicators:(BOOL)value
{ {
[self setValueForKey:OWSPreferencesKeyShouldShowUnidentifiedDeliveryIndicators toValue:@(value)]; [self setValueForKey:OWSPreferencesKeyShouldShowUnidentifiedDeliveryIndicators toValue:@(value)];
[NSNotificationCenter.defaultCenter postNotificationNameAsync:NSNotificationName_SyncConfigurationNeeded
object:nil];
} }
#pragma mark - Calling #pragma mark - Calling

@ -6,11 +6,14 @@
NS_ASSUME_NONNULL_BEGIN NS_ASSUME_NONNULL_BEGIN
extern NSString *const NSNotificationName_SyncConfigurationNeeded;
@interface OWSSyncConfigurationMessage : OWSOutgoingSyncMessage @interface OWSSyncConfigurationMessage : OWSOutgoingSyncMessage
- (instancetype)init NS_UNAVAILABLE; - (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; - (nullable instancetype)initWithCoder:(NSCoder *)coder NS_DESIGNATED_INITIALIZER;
@end @end

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

@ -7,6 +7,7 @@
#import "AppReadiness.h" #import "AppReadiness.h"
#import "ContactsManagerProtocol.h" #import "ContactsManagerProtocol.h"
#import "MimeTypeUtil.h" #import "MimeTypeUtil.h"
#import "NSNotificationCenter+OWS.h"
#import "NotificationsProtocol.h" #import "NotificationsProtocol.h"
#import "OWSAttachmentsProcessor.h" #import "OWSAttachmentsProcessor.h"
#import "OWSBlockingManager.h" #import "OWSBlockingManager.h"
@ -848,17 +849,8 @@ NS_ASSUME_NONNULL_BEGIN
OWSLogInfo(@"Received request for block list"); OWSLogInfo(@"Received request for block list");
[self.blockingManager syncBlockList]; [self.blockingManager syncBlockList];
} else if (syncMessage.request.type == SSKProtoSyncMessageRequestTypeConfiguration) { } else if (syncMessage.request.type == SSKProtoSyncMessageRequestTypeConfiguration) {
BOOL areReadReceiptsEnabled = [NSNotificationCenter.defaultCenter postNotificationNameAsync:NSNotificationName_SyncConfigurationNeeded
[[OWSReadReceiptManager sharedManager] areReadReceiptsEnabledWithTransaction:transaction]; object:nil];
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);
}];
} else { } else {
OWSLogWarn(@"ignoring unsupported sync request message"); OWSLogWarn(@"ignoring unsupported sync request message");
} }

@ -571,15 +571,8 @@ NSString *const OWSReadReceiptManagerAreReadReceiptsEnabled = @"areReadReceiptsE
forKey:OWSReadReceiptManagerAreReadReceiptsEnabled forKey:OWSReadReceiptManagerAreReadReceiptsEnabled
inCollection:OWSReadReceiptManagerCollection]; inCollection:OWSReadReceiptManagerCollection];
OWSSyncConfigurationMessage *syncConfigurationMessage = [NSNotificationCenter.defaultCenter postNotificationNameAsync:NSNotificationName_SyncConfigurationNeeded
[[OWSSyncConfigurationMessage alloc] initWithReadReceiptsEnabled:value]; object:nil];
[self.messageSender enqueueMessage:syncConfigurationMessage
success:^{
OWSLogInfo(@"Successfully sent Configuration syncMessage.");
}
failure:^(NSError *error) {
OWSLogError(@"Failed to send Configuration syncMessage with error: %@", error);
}];
self.areReadReceiptsEnabledCached = @(value); self.areReadReceiptsEnabledCached = @(value);
} }

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

@ -14,9 +14,9 @@
#import <SignalMessaging/DebugLogger.h> #import <SignalMessaging/DebugLogger.h>
#import <SignalMessaging/Environment.h> #import <SignalMessaging/Environment.h>
#import <SignalMessaging/OWSContactsManager.h> #import <SignalMessaging/OWSContactsManager.h>
#import <SignalMessaging/OWSContactsSyncing.h>
#import <SignalMessaging/OWSMath.h> #import <SignalMessaging/OWSMath.h>
#import <SignalMessaging/OWSPreferences.h> #import <SignalMessaging/OWSPreferences.h>
#import <SignalMessaging/OWSSyncManager.h>
#import <SignalMessaging/UIColor+OWS.h> #import <SignalMessaging/UIColor+OWS.h>
#import <SignalMessaging/UIFont+OWS.h> #import <SignalMessaging/UIFont+OWS.h>
#import <SignalMessaging/UIView+OWS.h> #import <SignalMessaging/UIView+OWS.h>

Loading…
Cancel
Save