Merge branch 'mkirk/sync-colors'

pull/1/head
Michael Kirk 7 years ago
commit c4d52505b7

@ -417,6 +417,7 @@
4C20B2B720CA0034001BAC90 /* ThreadViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4542DF51208B82E9007B4E76 /* ThreadViewModel.swift */; };
4C20B2B920CA10DE001BAC90 /* ConversationSearchViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4C20B2B820CA10DE001BAC90 /* ConversationSearchViewController.swift */; };
4C4AEC4520EC343B0020E72B /* DismissableTextField.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4C4AEC4420EC343B0020E72B /* DismissableTextField.swift */; };
4CC0B59C20EC5F2E00CF6EE0 /* ConversationConfigurationSyncOperation.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4CC0B59B20EC5F2E00CF6EE0 /* ConversationConfigurationSyncOperation.swift */; };
70377AAB1918450100CAF501 /* MobileCoreServices.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 70377AAA1918450100CAF501 /* MobileCoreServices.framework */; };
768A1A2B17FC9CD300E00ED8 /* libz.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = 768A1A2A17FC9CD300E00ED8 /* libz.dylib */; };
76C87F19181EFCE600C4ACAB /* MediaPlayer.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 76C87F18181EFCE600C4ACAB /* MediaPlayer.framework */; };
@ -1077,6 +1078,7 @@
4C13C9F520E57BA30089A98B /* ColorPickerViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ColorPickerViewController.swift; sourceTree = "<group>"; };
4C20B2B820CA10DE001BAC90 /* ConversationSearchViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ConversationSearchViewController.swift; sourceTree = "<group>"; };
4C4AEC4420EC343B0020E72B /* DismissableTextField.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DismissableTextField.swift; sourceTree = "<group>"; };
4CC0B59B20EC5F2E00CF6EE0 /* ConversationConfigurationSyncOperation.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ConversationConfigurationSyncOperation.swift; sourceTree = "<group>"; };
69349DE607F5BA6036C9AC60 /* Pods-SignalShareExtension.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-SignalShareExtension.debug.xcconfig"; path = "Pods/Target Support Files/Pods-SignalShareExtension/Pods-SignalShareExtension.debug.xcconfig"; sourceTree = "<group>"; };
70377AAA1918450100CAF501 /* MobileCoreServices.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = MobileCoreServices.framework; path = System/Library/Frameworks/MobileCoreServices.framework; sourceTree = SDKROOT; };
748A5CAEDD7C919FC64C6807 /* Pods_SignalTests.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_SignalTests.framework; sourceTree = BUILT_PRODUCTS_DIR; };
@ -2016,6 +2018,7 @@
45CD81EE1DC030E7004C9430 /* SyncPushTokensJob.swift */,
452ECA4C1E087E7200E2F016 /* MessageFetcherJob.swift */,
451686AA1F520CDA00AC3D4B /* MultiDeviceProfileKeyUpdateJob.swift */,
4CC0B59B20EC5F2E00CF6EE0 /* ConversationConfigurationSyncOperation.swift */,
);
path = Jobs;
sourceTree = "<group>";
@ -3198,6 +3201,7 @@
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
4CC0B59C20EC5F2E00CF6EE0 /* ConversationConfigurationSyncOperation.swift in Sources */,
3461293E1FD1D72B00532771 /* ExperienceUpgradeFinder.swift in Sources */,
34D1F0BD1F8D108C0066283D /* AttachmentUploadView.m in Sources */,
452EC6DF205E9E30000E787C /* MediaGalleryViewController.swift in Sources */,

@ -0,0 +1,114 @@
//
// Copyright (c) 2018 Open Whisper Systems. All rights reserved.
//
import Foundation
@objc
class ConversationConfigurationSyncOperation: OWSOperation {
enum ColorSyncOperationError: Error {
case assertionError(description: String)
}
private var dbConnection: YapDatabaseConnection {
return OWSPrimaryStorage.shared().dbReadConnection
}
private var messageSender: MessageSender {
return Environment.current().messageSender
}
private var contactsManager: OWSContactsManager {
return Environment.current().contactsManager
}
private var profileManager: OWSProfileManager {
return OWSProfileManager.shared()
}
private var identityManager: OWSIdentityManager {
return OWSIdentityManager.shared()
}
private let thread: TSThread
@objc
public init(thread: TSThread) {
self.thread = thread
super.init()
}
override public func run() {
if let contactThread = thread as? TSContactThread {
sync(contactThread: contactThread)
} else if let groupThread = thread as? TSGroupThread {
sync(groupThread: groupThread)
} else {
self.reportAssertionError(description: "unknown thread type")
}
}
private func reportAssertionError(description: String) {
let error = ColorSyncOperationError.assertionError(description: description)
self.reportError(error)
}
private func sync(contactThread: TSContactThread) {
guard let signalAccount: SignalAccount = self.contactsManager.signalAccount(forRecipientId: contactThread.contactIdentifier()) else {
reportAssertionError(description: "unable to find signalAccount")
return
}
let syncMessage: OWSSyncContactsMessage = OWSSyncContactsMessage(signalAccounts: [signalAccount],
identityManager: self.identityManager,
profileManager: self.profileManager)
var dataSource: DataSource? = nil
self.dbConnection.readWrite { transaction in
let messageData: Data = syncMessage.buildPlainTextAttachmentData(with: transaction)
dataSource = DataSourceValue.dataSource(withSyncMessageData: messageData)
}
guard let attachmentDataSource = dataSource else {
self.reportAssertionError(description: "unable to build attachment data source")
return
}
self.sendConfiguration(attachmentDataSource: attachmentDataSource, syncMessage: syncMessage)
}
private func sync(groupThread: TSGroupThread) {
// TODO sync only the affected group
// The current implementation works, but seems wasteful.
// Does desktop handle single group sync correctly?
// What does Android do?
let syncMessage: OWSSyncGroupsMessage = OWSSyncGroupsMessage()
var dataSource: DataSource? = nil
self.dbConnection.read { transaction in
let messageData: Data = syncMessage.buildPlainTextAttachmentData(with: transaction)
dataSource = DataSourceValue.dataSource(withSyncMessageData: messageData)
}
guard let attachmentDataSource = dataSource else {
self.reportAssertionError(description: "unable to build attachment data source")
return
}
self.sendConfiguration(attachmentDataSource: attachmentDataSource, syncMessage: syncMessage)
}
private func sendConfiguration(attachmentDataSource: DataSource, syncMessage: OWSOutgoingSyncMessage) {
self.messageSender.enqueueTemporaryAttachment(attachmentDataSource,
contentType: OWSMimeTypeApplicationOctetStream,
in: syncMessage,
success: {
self.reportSuccess()
},
failure: { error in
self.reportError(error)
})
}
}

@ -16,10 +16,13 @@ import SignalMessaging
let TAG = "[MultiDeviceProfileKeyUpdateJob]"
let profileKey: OWSAES256Key
let identityManager: OWSIdentityManager
let messageSender: MessageSender
let profileManager: OWSProfileManager
private let profileKey: OWSAES256Key
private let identityManager: OWSIdentityManager
private let messageSender: MessageSender
private let profileManager: OWSProfileManager
private var editingDatabaseConnection: YapDatabaseConnection {
return OWSPrimaryStorage.shared().dbReadWriteConnection
}
@objc public required init(profileKey: OWSAES256Key, identityManager: OWSIdentityManager, messageSender: MessageSender, profileManager: OWSProfileManager) {
self.profileKey = profileKey
@ -45,8 +48,17 @@ import SignalMessaging
identityManager: self.identityManager,
profileManager: self.profileManager)
let dataSource = DataSourceValue.dataSource(withSyncMessage: syncContactsMessage.buildPlainTextAttachmentData())
self.messageSender.enqueueTemporaryAttachment(dataSource,
var dataSource: DataSource? = nil
self.editingDatabaseConnection.readWrite { transaction in
dataSource = DataSourceValue.dataSource(withSyncMessageData: syncContactsMessage.buildPlainTextAttachmentData(with: transaction))
}
guard let attachmentDataSource = dataSource else {
owsFail("\(self.logTag) in \(#function) dataSource was unexpectedly nil")
return
}
self.messageSender.enqueueTemporaryAttachment(attachmentDataSource,
contentType: OWSMimeTypeApplicationOctetStream,
in: syncContactsMessage,
success: {

@ -99,8 +99,13 @@ NS_ASSUME_NONNULL_BEGIN
[[OWSSyncContactsMessage alloc] initWithSignalAccounts:self.contactsManager.signalAccounts
identityManager:self.identityManager
profileManager:self.profileManager];
DataSource *dataSource =
[DataSourceValue dataSourceWithSyncMessage:[syncContactsMessage buildPlainTextAttachmentData]];
__block DataSource *dataSource;
[self.dbConnection readWriteWithBlock:^(YapDatabaseReadWriteTransaction *_Nonnull transaction) {
dataSource = [DataSourceValue
dataSourceWithSyncMessageData:[syncContactsMessage
buildPlainTextAttachmentDataWithTransaction:transaction]];
}];
[self.messageSender enqueueTemporaryAttachment:dataSource
contentType:OWSMimeTypeApplicationOctetStream
inMessage:syncContactsMessage
@ -118,7 +123,7 @@ NS_ASSUME_NONNULL_BEGIN
__block DataSource *dataSource;
[self.dbConnection readWithBlock:^(YapDatabaseReadTransaction *transaction) {
dataSource = [DataSourceValue
dataSourceWithSyncMessage:[syncGroupsMessage buildPlainTextAttachmentDataWithTransaction:transaction]];
dataSourceWithSyncMessageData:[syncGroupsMessage buildPlainTextAttachmentDataWithTransaction:transaction]];
}];
[self.messageSender enqueueTemporaryAttachment:dataSource
contentType:OWSMimeTypeApplicationOctetStream

@ -281,9 +281,7 @@ const CGFloat kIconViewLength = 24;
[weakSelf showMediaGallery];
}]];
//#define SHOW_CONVERSATION_COLORS_UI
#ifdef SHOW_CONVERSATION_COLORS_UI
#ifdef CONVERSATION_COLORS_ENABLED
[mainSection addItem:[OWSTableItem
itemWithCustomCellBlock:^{
NSString *colorName = self.thread.conversationColorName;
@ -1265,13 +1263,20 @@ const CGFloat kIconViewLength = 24;
DDLogDebug(@"%@ in %s picked color: %@", self.logTag, __PRETTY_FUNCTION__, colorName);
[self.editingDatabaseConnection readWriteWithBlock:^(YapDatabaseReadWriteTransaction *_Nonnull transaction) {
[self.thread updateConversationColorName:colorName transaction:transaction];
[self.contactsManager.avatarCache removeAllImages];
[self updateTableContents];
[self.conversationSettingsViewDelegate conversationColorWasUpdated];
[self dismissViewControllerAnimated:YES completion:nil];
}];
[self.contactsManager.avatarCache removeAllImages];
[self updateTableContents];
[self.conversationSettingsViewDelegate conversationColorWasUpdated];
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
ConversationConfigurationSyncOperation *operation =
[[ConversationConfigurationSyncOperation alloc] initWithThread:self.thread];
OWSAssert(operation.isReady);
[operation start];
});
[self dismissViewControllerAnimated:YES completion:nil];
}
- (void)colorPickerDidCancel:(ColorPickerViewController *)colorPicker

@ -95,6 +95,11 @@ NSString *const kOWSPrimaryStorageOWSContactsSyncingLastMessageKey
[self sendSyncContactsMessageIfPossible];
}
- (YapDatabaseConnection *)editingDatabaseConnection
{
return OWSPrimaryStorage.sharedManager.dbReadWriteConnection;
}
#pragma mark - Methods
- (void)sendSyncContactsMessageIfNecessary
@ -119,11 +124,13 @@ NSString *const kOWSPrimaryStorageOWSContactsSyncingLastMessageKey
identityManager:self.identityManager
profileManager:self.profileManager];
NSData *messageData = [syncContactsMessage buildPlainTextAttachmentData];
NSData *lastMessageData =
[OWSPrimaryStorage.dbReadConnection objectForKey:kOWSPrimaryStorageOWSContactsSyncingLastMessageKey
inCollection:kOWSPrimaryStorageOWSContactsSyncingCollection];
__block NSData *messageData;
__block NSData *lastMessageData;
[self.editingDatabaseConnection readWithBlock:^(YapDatabaseReadTransaction *_Nonnull transaction) {
messageData = [syncContactsMessage buildPlainTextAttachmentDataWithTransaction:transaction];
lastMessageData = [transaction objectForKey:kOWSPrimaryStorageOWSContactsSyncingLastMessageKey
inCollection:kOWSPrimaryStorageOWSContactsSyncingCollection];
}];
if (lastMessageData && [lastMessageData isEqual:messageData]) {
// Ignore redundant contacts sync message.
@ -132,17 +139,16 @@ NSString *const kOWSPrimaryStorageOWSContactsSyncingLastMessageKey
self.isRequestInFlight = YES;
DataSource *dataSource =
[DataSourceValue dataSourceWithSyncMessage:[syncContactsMessage buildPlainTextAttachmentData]];
DataSource *dataSource = [DataSourceValue dataSourceWithSyncMessageData:messageData];
[self.messageSender enqueueTemporaryAttachment:dataSource
contentType:OWSMimeTypeApplicationOctetStream
inMessage:syncContactsMessage
success:^{
DDLogInfo(@"%@ Successfully sent contacts sync message.", self.logTag);
[OWSPrimaryStorage.dbReadWriteConnection setObject:messageData
forKey:kOWSPrimaryStorageOWSContactsSyncingLastMessageKey
inCollection:kOWSPrimaryStorageOWSContactsSyncingCollection];
[self.editingDatabaseConnection setObject:messageData
forKey:kOWSPrimaryStorageOWSContactsSyncingLastMessageKey
inCollection:kOWSPrimaryStorageOWSContactsSyncingCollection];
dispatch_async(self.serialQueue, ^{
self.isRequestInFlight = NO;

@ -324,4 +324,5 @@ message GroupDetails {
optional Avatar avatar = 4;
optional bool active = 5 [default = true];
optional uint32 expireTimer = 6;
optional string color = 7;
}

@ -47,7 +47,14 @@ NS_ASSUME_NONNULL_BEGIN
_lastMessageDate = nil;
_creationDate = [NSDate date];
_messageDraft = nil;
_conversationColorName = [self.class randomConversationColorName];
NSString *_Nullable contactId = self.contactIdentifier;
if (contactId.length > 0) {
// To be consistent with colors synced to desktop
_conversationColorName = [self.class stableConversationColorNameForString:contactId];
} else {
_conversationColorName = [self.class stableConversationColorNameForString:self.uniqueId];
}
}
return self;
@ -60,8 +67,14 @@ NS_ASSUME_NONNULL_BEGIN
return self;
}
if (!_conversationColorName) {
_conversationColorName = [self.class stableConversationColorNameForString:self.uniqueId];
if (_conversationColorName.length == 0) {
NSString *_Nullable contactId = self.contactIdentifier;
if (contactId.length > 0) {
// To be consistent with colors synced to desktop
_conversationColorName = [self.class stableConversationColorNameForString:contactId];
} else {
_conversationColorName = [self.class stableConversationColorNameForString:self.uniqueId];
}
}
return self;

@ -20,7 +20,7 @@ NS_ASSUME_NONNULL_BEGIN
relay:(nullable NSString *)relay;
// Unlike getOrCreateThreadWithContactId, this will _NOT_ create a thread if one does not already exist.
+ (nullable instancetype)getThreadWithContactId:(NSString *)contactId;
+ (nullable instancetype)getThreadWithContactId:(NSString *)contactId transaction:(YapDatabaseReadTransaction *)transaction;
- (NSString *)contactIdentifier;

@ -83,17 +83,9 @@ NS_ASSUME_NONNULL_BEGIN
return thread;
}
+ (nullable instancetype)getThreadWithContactId:(NSString *)contactId
+ (nullable instancetype)getThreadWithContactId:(NSString *)contactId transaction:(YapDatabaseReadTransaction *)transaction;
{
OWSAssert(contactId.length > 0);
__block TSContactThread *_Nullable thread;
[[self dbReadWriteConnection] readWithBlock:^(YapDatabaseReadTransaction *transaction) {
thread =
[TSContactThread fetchObjectWithUniqueID:[self threadIdFromContactId:contactId] transaction:transaction];
}];
return thread;
return [TSContactThread fetchObjectWithUniqueID:[self threadIdFromContactId:contactId] transaction:transaction];
}
- (NSString *)contactIdentifier {

@ -6,6 +6,7 @@
NS_ASSUME_NONNULL_BEGIN
@class OWSDisappearingMessagesConfiguration;
@class OWSRecipientIdentity;
@class SignalAccount;
@ -16,7 +17,10 @@ NS_ASSUME_NONNULL_BEGIN
- (void)writeSignalAccount:(SignalAccount *)signalAccount
recipientIdentity:(nullable OWSRecipientIdentity *)recipientIdentity
profileKeyData:(nullable NSData *)profileKeyData
contactsManager:(id<ContactsManagerProtocol>)contactsManager;
contactsManager:(id<ContactsManagerProtocol>)contactsManager
conversationColorName:(NSString *)conversationColorName
disappearingMessagesConfiguration:(nullable OWSDisappearingMessagesConfiguration *)disappearingMessagesConfiguration;
@end

@ -24,6 +24,8 @@ NS_ASSUME_NONNULL_BEGIN
recipientIdentity:(nullable OWSRecipientIdentity *)recipientIdentity
profileKeyData:(nullable NSData *)profileKeyData
contactsManager:(id<ContactsManagerProtocol>)contactsManager
conversationColorName:(NSString *)conversationColorName
disappearingMessagesConfiguration:(nullable OWSDisappearingMessagesConfiguration *)disappearingMessagesConfiguration
{
OWSAssert(signalAccount);
OWSAssert(signalAccount.contact);
@ -32,6 +34,9 @@ NS_ASSUME_NONNULL_BEGIN
OWSSignalServiceProtosContactDetailsBuilder *contactBuilder = [OWSSignalServiceProtosContactDetailsBuilder new];
[contactBuilder setName:signalAccount.contact.fullName];
[contactBuilder setNumber:signalAccount.recipientId];
#ifdef CONVERSATION_COLORS_ENABLED
[contactBuilder setColor:conversationColorName];
#endif
if (recipientIdentity != nil) {
OWSSignalServiceProtosVerifiedBuilder *verifiedBuilder = [OWSSignalServiceProtosVerifiedBuilder new];
@ -65,14 +70,8 @@ NS_ASSUME_NONNULL_BEGIN
// legacy client "not specifying".
[contactBuilder setExpireTimer:0];
TSContactThread *_Nullable contactThread = [TSContactThread getThreadWithContactId:signalAccount.recipientId];
if (contactThread) {
OWSDisappearingMessagesConfiguration *_Nullable disappearingMessagesConfiguration =
[OWSDisappearingMessagesConfiguration fetchObjectWithUniqueID:contactThread.uniqueId];
if (disappearingMessagesConfiguration && disappearingMessagesConfiguration.isEnabled) {
[contactBuilder setExpireTimer:disappearingMessagesConfiguration.durationSeconds];
}
if (disappearingMessagesConfiguration && disappearingMessagesConfiguration.isEnabled) {
[contactBuilder setExpireTimer:disappearingMessagesConfiguration.durationSeconds];
}
if ([OWSBlockingManager.sharedManager isRecipientIdBlocked:signalAccount.recipientId]) {

@ -26,6 +26,9 @@ NS_ASSUME_NONNULL_BEGIN
[groupBuilder setId:group.groupId];
[groupBuilder setName:group.groupName];
[groupBuilder setMembersArray:group.groupMemberIds];
#ifdef CONVERSATION_COLORS_ENABLED
[groupBuilder setColor:groupThread.conversationColorName];
#endif
NSData *avatarPng;
if (group.groupImage) {

@ -21,7 +21,7 @@ NS_ASSUME_NONNULL_BEGIN
- (nullable instancetype)initWithCoder:(NSCoder *)coder NS_DESIGNATED_INITIALIZER;
- (NSData *)buildPlainTextAttachmentData;
- (NSData *)buildPlainTextAttachmentDataWithTransaction:(YapDatabaseReadTransaction *)transaction;
@end

@ -13,6 +13,7 @@
#import "SignalAccount.h"
#import "TSAttachment.h"
#import "TSAttachmentStream.h"
#import "TSContactThread.h"
#import "TextSecureKitEnv.h"
NS_ASSUME_NONNULL_BEGIN
@ -70,7 +71,7 @@ NS_ASSUME_NONNULL_BEGIN
return syncMessageBuilder;
}
- (NSData *)buildPlainTextAttachmentData
- (NSData *)buildPlainTextAttachmentDataWithTransaction:(YapDatabaseReadTransaction *)transaction
{
id<ContactsManagerProtocol> contactsManager = TextSecureKitEnv.sharedEnv.contactsManager;
@ -86,10 +87,24 @@ NS_ASSUME_NONNULL_BEGIN
[self.identityManager recipientIdentityForRecipientId:signalAccount.recipientId];
NSData *_Nullable profileKeyData = [self.profileManager profileKeyDataForRecipientId:signalAccount.recipientId];
OWSDisappearingMessagesConfiguration *_Nullable disappearingMessagesConfiguration;
NSString *conversationColorName;
TSContactThread *_Nullable contactThread = [TSContactThread getThreadWithContactId:signalAccount.recipientId transaction:transaction];
if (contactThread) {
conversationColorName = contactThread.conversationColorName;
disappearingMessagesConfiguration = [contactThread disappearingMessagesConfigurationWithTransaction:transaction];
} else {
conversationColorName = [TSThread stableConversationColorNameForString:signalAccount.recipientId];
}
[contactsOutputStream writeSignalAccount:signalAccount
recipientIdentity:recipientIdentity
profileKeyData:profileKeyData
contactsManager:contactsManager];
contactsManager:contactsManager
conversationColorName:conversationColorName
disappearingMessagesConfiguration:disappearingMessagesConfiguration];
}
[contactsOutputStream flush];

@ -657,8 +657,9 @@ NS_ASSUME_NONNULL_BEGIN
[[OWSSyncContactsMessage alloc] initWithSignalAccounts:self.contactsManager.signalAccounts
identityManager:self.identityManager
profileManager:self.profileManager];
DataSource *dataSource =
[DataSourceValue dataSourceWithSyncMessage:[syncContactsMessage buildPlainTextAttachmentData]];
DataSource *dataSource = [DataSourceValue
dataSourceWithSyncMessageData:[syncContactsMessage
buildPlainTextAttachmentDataWithTransaction:transaction]];
[self.messageSender enqueueTemporaryAttachment:dataSource
contentType:OWSMimeTypeApplicationOctetStream
inMessage:syncContactsMessage
@ -673,7 +674,8 @@ NS_ASSUME_NONNULL_BEGIN
} else if (syncMessage.request.type == OWSSignalServiceProtosSyncMessageRequestTypeGroups) {
OWSSyncGroupsMessage *syncGroupsMessage = [[OWSSyncGroupsMessage alloc] init];
DataSource *dataSource = [DataSourceValue
dataSourceWithSyncMessage:[syncGroupsMessage buildPlainTextAttachmentDataWithTransaction:transaction]];
dataSourceWithSyncMessageData:[syncGroupsMessage
buildPlainTextAttachmentDataWithTransaction:transaction]];
[self.messageSender enqueueTemporaryAttachment:dataSource
contentType:OWSMimeTypeApplicationOctetStream
inMessage:syncGroupsMessage

@ -2840,15 +2840,18 @@ NSString *NSStringFromOWSSignalServiceProtosGroupContextType(OWSSignalServicePro
#define GroupDetails_avatar @"avatar"
#define GroupDetails_active @"active"
#define GroupDetails_expireTimer @"expireTimer"
#define GroupDetails_color @"color"
@interface OWSSignalServiceProtosGroupDetails : PBGeneratedMessage<GeneratedMessageProtocol> {
@private
BOOL hasActive_:1;
BOOL hasName_:1;
BOOL hasColor_:1;
BOOL hasAvatar_:1;
BOOL hasId_:1;
BOOL hasExpireTimer_:1;
BOOL active_:1;
NSString* name;
NSString* color;
OWSSignalServiceProtosGroupDetailsAvatar* avatar;
NSData* id;
UInt32 expireTimer;
@ -2859,12 +2862,14 @@ NSString *NSStringFromOWSSignalServiceProtosGroupContextType(OWSSignalServicePro
- (BOOL) hasAvatar;
- (BOOL) hasActive;
- (BOOL) hasExpireTimer;
- (BOOL) hasColor;
@property (readonly, strong) NSData* id;
@property (readonly, strong) NSString* name;
@property (readonly, strong) NSArray * members;
@property (readonly, strong) OWSSignalServiceProtosGroupDetailsAvatar* avatar;
- (BOOL) active;
@property (readonly) UInt32 expireTimer;
@property (readonly, strong) NSString* color;
- (NSString*)membersAtIndex:(NSUInteger)index;
+ (instancetype) defaultInstance;
@ -2994,6 +2999,11 @@ NSString *NSStringFromOWSSignalServiceProtosGroupContextType(OWSSignalServicePro
- (UInt32) expireTimer;
- (OWSSignalServiceProtosGroupDetailsBuilder*) setExpireTimer:(UInt32) value;
- (OWSSignalServiceProtosGroupDetailsBuilder*) clearExpireTimer;
- (BOOL) hasColor;
- (NSString*) color;
- (OWSSignalServiceProtosGroupDetailsBuilder*) setColor:(NSString*) value;
- (OWSSignalServiceProtosGroupDetailsBuilder*) clearColor;
@end

@ -12439,6 +12439,7 @@ static OWSSignalServiceProtosContactDetailsAvatar* defaultOWSSignalServiceProtos
@property (strong) OWSSignalServiceProtosGroupDetailsAvatar* avatar;
@property BOOL active;
@property UInt32 expireTimer;
@property (strong) NSString* color;
@end
@implementation OWSSignalServiceProtosGroupDetails
@ -12485,6 +12486,13 @@ static OWSSignalServiceProtosContactDetailsAvatar* defaultOWSSignalServiceProtos
hasExpireTimer_ = !!_value_;
}
@synthesize expireTimer;
- (BOOL) hasColor {
return !!hasColor_;
}
- (void) setHasColor:(BOOL) _value_ {
hasColor_ = !!_value_;
}
@synthesize color;
- (instancetype) init {
if ((self = [super init])) {
self.id = [NSData data];
@ -12492,6 +12500,7 @@ static OWSSignalServiceProtosContactDetailsAvatar* defaultOWSSignalServiceProtos
self.avatar = [OWSSignalServiceProtosGroupDetailsAvatar defaultInstance];
self.active = YES;
self.expireTimer = 0;
self.color = @"";
}
return self;
}
@ -12535,6 +12544,9 @@ static OWSSignalServiceProtosGroupDetails* defaultOWSSignalServiceProtosGroupDet
if (self.hasExpireTimer) {
[output writeUInt32:6 value:self.expireTimer];
}
if (self.hasColor) {
[output writeString:7 value:self.color];
}
[self.unknownFields writeToCodedOutputStream:output];
}
- (SInt32) serializedSize {
@ -12568,6 +12580,9 @@ static OWSSignalServiceProtosGroupDetails* defaultOWSSignalServiceProtosGroupDet
if (self.hasExpireTimer) {
size_ += computeUInt32Size(6, self.expireTimer);
}
if (self.hasColor) {
size_ += computeStringSize(7, self.color);
}
size_ += self.unknownFields.serializedSize;
memoizedSerializedSize = size_;
return size_;
@ -12624,6 +12639,9 @@ static OWSSignalServiceProtosGroupDetails* defaultOWSSignalServiceProtosGroupDet
if (self.hasExpireTimer) {
[output appendFormat:@"%@%@: %@\n", indent, @"expireTimer", [NSNumber numberWithInteger:self.expireTimer]];
}
if (self.hasColor) {
[output appendFormat:@"%@%@: %@\n", indent, @"color", self.color];
}
[self.unknownFields writeDescriptionTo:output withIndent:indent];
}
- (void) storeInDictionary:(NSMutableDictionary *)dictionary {
@ -12645,6 +12663,9 @@ static OWSSignalServiceProtosGroupDetails* defaultOWSSignalServiceProtosGroupDet
if (self.hasExpireTimer) {
[dictionary setObject: [NSNumber numberWithInteger:self.expireTimer] forKey: @"expireTimer"];
}
if (self.hasColor) {
[dictionary setObject: self.color forKey: @"color"];
}
[self.unknownFields storeInDictionary:dictionary];
}
- (BOOL) isEqual:(id)other {
@ -12667,6 +12688,8 @@ static OWSSignalServiceProtosGroupDetails* defaultOWSSignalServiceProtosGroupDet
(!self.hasActive || self.active == otherMessage.active) &&
self.hasExpireTimer == otherMessage.hasExpireTimer &&
(!self.hasExpireTimer || self.expireTimer == otherMessage.expireTimer) &&
self.hasColor == otherMessage.hasColor &&
(!self.hasColor || [self.color isEqual:otherMessage.color]) &&
(self.unknownFields == otherMessage.unknownFields || (self.unknownFields != nil && [self.unknownFields isEqual:otherMessage.unknownFields]));
}
- (NSUInteger) hash {
@ -12689,6 +12712,9 @@ static OWSSignalServiceProtosGroupDetails* defaultOWSSignalServiceProtosGroupDet
if (self.hasExpireTimer) {
hashCode = hashCode * 31 + [[NSNumber numberWithInteger:self.expireTimer] hash];
}
if (self.hasColor) {
hashCode = hashCode * 31 + [self.color hash];
}
hashCode = hashCode * 31 + [self.unknownFields hash];
return hashCode;
}
@ -13009,6 +13035,9 @@ static OWSSignalServiceProtosGroupDetailsAvatar* defaultOWSSignalServiceProtosGr
if (other.hasExpireTimer) {
[self setExpireTimer:other.expireTimer];
}
if (other.hasColor) {
[self setColor:other.color];
}
[self mergeUnknownFields:other.unknownFields];
return self;
}
@ -13059,6 +13088,10 @@ static OWSSignalServiceProtosGroupDetailsAvatar* defaultOWSSignalServiceProtosGr
[self setExpireTimer:[input readUInt32]];
break;
}
case 58: {
[self setColor:[input readString]];
break;
}
}
}
}
@ -13177,6 +13210,22 @@ static OWSSignalServiceProtosGroupDetailsAvatar* defaultOWSSignalServiceProtosGr
resultGroupDetails.expireTimer = 0;
return self;
}
- (BOOL) hasColor {
return resultGroupDetails.hasColor;
}
- (NSString*) color {
return resultGroupDetails.color;
}
- (OWSSignalServiceProtosGroupDetailsBuilder*) setColor:(NSString*) value {
resultGroupDetails.hasColor = YES;
resultGroupDetails.color = value;
return self;
}
- (OWSSignalServiceProtosGroupDetailsBuilder*) clearColor {
resultGroupDetails.hasColor = NO;
resultGroupDetails.color = @"";
return self;
}
@end

@ -17,6 +17,8 @@ typedef NS_ENUM(NSInteger, TSWhisperMessageType) {
#define textSecureHTTPTimeOut 10
//#define CONVERSATION_COLORS_ENABLED
#define kLegalTermsUrlString @"https://signal.org/legal/"
#define SHOW_LEGAL_TERMS_LINK

@ -47,7 +47,7 @@ NS_ASSUME_NONNULL_BEGIN
+ (nullable DataSource *)dataSourceWithOversizeText:(NSString *_Nullable)text;
+ (DataSource *)dataSourceWithSyncMessage:(NSData *)data;
+ (DataSource *)dataSourceWithSyncMessageData:(NSData *)data;
+ (DataSource *)emptyDataSource;

@ -158,7 +158,7 @@ NS_ASSUME_NONNULL_BEGIN
return [self dataSourceWithData:data fileExtension:kOversizeTextAttachmentFileExtension];
}
+ (DataSource *)dataSourceWithSyncMessage:(NSData *)data
+ (DataSource *)dataSourceWithSyncMessageData:(NSData *)data
{
return [self dataSourceWithData:data fileExtension:kSyncMessageFileExtension];
}

Loading…
Cancel
Save