Code generate Swift wrappers for protocol buffers.

This commit is contained in:
Matthew Chen 2018-08-01 17:13:01 -04:00
parent faebd9af82
commit ab31e5a07f
62 changed files with 4148 additions and 4105 deletions

View File

@ -3,7 +3,7 @@
//
#import "OWSBlockedPhoneNumbersMessage.h"
#import "OWSSignalServiceProtos.pb.h"
#import <SignalServiceKit/SignalServiceKit-Swift.h>
NS_ASSUME_NONNULL_BEGIN
@ -32,12 +32,12 @@ NS_ASSUME_NONNULL_BEGIN
return self;
}
- (OWSSignalServiceProtosSyncMessageBuilder *)syncMessageBuilder
- (SSKProtoSyncMessageBuilder *)syncMessageBuilder
{
OWSSignalServiceProtosSyncMessageBlockedBuilder *blockedPhoneNumbersBuilder =
[OWSSignalServiceProtosSyncMessageBlockedBuilder new];
SSKProtoSyncMessageBlockedBuilder *blockedPhoneNumbersBuilder =
[SSKProtoSyncMessageBlockedBuilder new];
[blockedPhoneNumbersBuilder setNumbersArray:_phoneNumbers];
OWSSignalServiceProtosSyncMessageBuilder *syncMessageBuilder = [OWSSignalServiceProtosSyncMessageBuilder new];
SSKProtoSyncMessageBuilder *syncMessageBuilder = [SSKProtoSyncMessageBuilder new];
[syncMessageBuilder setBlocked:[blockedPhoneNumbersBuilder build]];
return syncMessageBuilder;

View File

@ -11,10 +11,10 @@
#import "OWSBlockingManager.h"
#import "OWSDisappearingMessagesConfiguration.h"
#import "OWSRecipientIdentity.h"
#import "OWSSignalServiceProtos.pb.h"
#import "SignalAccount.h"
#import "TSContactThread.h"
#import <ProtocolBuffers/CodedOutputStream.h>
#import <SignalServiceKit/SignalServiceKit-Swift.h>
NS_ASSUME_NONNULL_BEGIN
@ -31,7 +31,7 @@ disappearingMessagesConfiguration:(nullable OWSDisappearingMessagesConfiguration
OWSAssert(signalAccount.contact);
OWSAssert(contactsManager);
OWSSignalServiceProtosContactDetailsBuilder *contactBuilder = [OWSSignalServiceProtosContactDetailsBuilder new];
SSKProtoContactDetailsBuilder *contactBuilder = [SSKProtoContactDetailsBuilder new];
[contactBuilder setName:signalAccount.contact.fullName];
[contactBuilder setNumber:signalAccount.recipientId];
#ifdef CONVERSATION_COLORS_ENABLED
@ -39,7 +39,7 @@ disappearingMessagesConfiguration:(nullable OWSDisappearingMessagesConfiguration
#endif
if (recipientIdentity != nil) {
OWSSignalServiceProtosVerifiedBuilder *verifiedBuilder = [OWSSignalServiceProtosVerifiedBuilder new];
SSKProtoVerifiedBuilder *verifiedBuilder = [SSKProtoVerifiedBuilder new];
verifiedBuilder.destination = recipientIdentity.recipientId;
verifiedBuilder.identityKey = [recipientIdentity.identityKey prependKeyType];
verifiedBuilder.state = OWSVerificationStateToProtoState(recipientIdentity.verificationState);
@ -51,8 +51,8 @@ disappearingMessagesConfiguration:(nullable OWSDisappearingMessagesConfiguration
if (rawAvatar) {
avatarPng = UIImagePNGRepresentation(rawAvatar);
if (avatarPng) {
OWSSignalServiceProtosContactDetailsAvatarBuilder *avatarBuilder =
[OWSSignalServiceProtosContactDetailsAvatarBuilder new];
SSKProtoContactDetailsAvatarBuilder *avatarBuilder =
[SSKProtoContactDetailsAvatarBuilder new];
[avatarBuilder setContentType:OWSMimeTypeImagePng];
[avatarBuilder setLength:(uint32_t)avatarPng.length];

View File

@ -5,10 +5,10 @@
#import "OWSGroupsOutputStream.h"
#import "MIMETypeUtil.h"
#import "OWSDisappearingMessagesConfiguration.h"
#import "OWSSignalServiceProtos.pb.h"
#import "TSGroupModel.h"
#import "TSGroupThread.h"
#import <ProtocolBuffers/CodedOutputStream.h>
#import <SignalServiceKit/SignalServiceKit-Swift.h>
NS_ASSUME_NONNULL_BEGIN
@ -22,7 +22,7 @@ NS_ASSUME_NONNULL_BEGIN
TSGroupModel *group = groupThread.groupModel;
OWSAssert(group);
OWSSignalServiceProtosGroupDetailsBuilder *groupBuilder = [OWSSignalServiceProtosGroupDetailsBuilder new];
SSKProtoGroupDetailsBuilder *groupBuilder = [SSKProtoGroupDetailsBuilder new];
[groupBuilder setId:group.groupId];
[groupBuilder setName:group.groupName];
[groupBuilder setMembersArray:group.groupMemberIds];
@ -32,8 +32,8 @@ NS_ASSUME_NONNULL_BEGIN
NSData *avatarPng;
if (group.groupImage) {
OWSSignalServiceProtosGroupDetailsAvatarBuilder *avatarBuilder =
[OWSSignalServiceProtosGroupDetailsAvatarBuilder new];
SSKProtoGroupDetailsAvatarBuilder *avatarBuilder =
[SSKProtoGroupDetailsAvatarBuilder new];
[avatarBuilder setContentType:OWSMimeTypeImagePng];
avatarPng = UIImagePNGRepresentation(group.groupImage);

View File

@ -4,7 +4,7 @@
#import "OWSReadReceiptsForLinkedDevicesMessage.h"
#import "OWSLinkedDeviceReadReceipt.h"
#import "OWSSignalServiceProtos.pb.h"
#import <SignalServiceKit/SignalServiceKit-Swift.h>
NS_ASSUME_NONNULL_BEGIN
@ -33,12 +33,12 @@ NS_ASSUME_NONNULL_BEGIN
return [super initWithCoder:coder];
}
- (OWSSignalServiceProtosSyncMessageBuilder *)syncMessageBuilder
- (SSKProtoSyncMessageBuilder *)syncMessageBuilder
{
OWSSignalServiceProtosSyncMessageBuilder *syncMessageBuilder = [OWSSignalServiceProtosSyncMessageBuilder new];
SSKProtoSyncMessageBuilder *syncMessageBuilder = [SSKProtoSyncMessageBuilder new];
for (OWSLinkedDeviceReadReceipt *readReceipt in self.readReceipts) {
OWSSignalServiceProtosSyncMessageReadBuilder *readProtoBuilder =
[OWSSignalServiceProtosSyncMessageReadBuilder new];
SSKProtoSyncMessageReadBuilder *readProtoBuilder =
[SSKProtoSyncMessageReadBuilder new];
[readProtoBuilder setSender:readReceipt.senderId];
[readProtoBuilder setTimestamp:readReceipt.messageIdTimestamp];
[syncMessageBuilder addRead:[readProtoBuilder build]];

View File

@ -4,8 +4,8 @@
#import "OWSReadReceiptsForSenderMessage.h"
#import "NSDate+OWS.h"
#import "OWSSignalServiceProtos.pb.h"
#import "SignalRecipient.h"
#import <SignalServiceKit/SignalServiceKit-Swift.h>
NS_ASSUME_NONNULL_BEGIN
@ -54,20 +54,20 @@ NS_ASSUME_NONNULL_BEGIN
return YES;
}
- (NSData *)buildPlainTextData:(SignalRecipient *)recipient
- (nullable NSData *)buildPlainTextData:(SignalRecipient *)recipient
{
OWSAssert(recipient);
OWSSignalServiceProtosContentBuilder *contentBuilder = [OWSSignalServiceProtosContentBuilder new];
SSKProtoContentBuilder *contentBuilder = [SSKProtoContentBuilder new];
[contentBuilder setReceiptMessage:[self buildReceiptMessage:recipient.recipientId]];
return [[contentBuilder build] data];
}
- (OWSSignalServiceProtosReceiptMessage *)buildReceiptMessage:(NSString *)recipientId
- (SSKProtoReceiptMessage *)buildReceiptMessage:(NSString *)recipientId
{
OWSSignalServiceProtosReceiptMessageBuilder *builder = [OWSSignalServiceProtosReceiptMessageBuilder new];
SSKProtoReceiptMessageBuilder *builder = [SSKProtoReceiptMessageBuilder new];
[builder setType:OWSSignalServiceProtosReceiptMessageTypeRead];
[builder setType:SSKProtoReceiptMessageTypeRead];
OWSAssert(self.messageTimestamps.count > 0);
for (NSNumber *messageTimestamp in self.messageTimestamps) {
[builder addTimestamp:[messageTimestamp unsignedLongLongValue]];

View File

@ -5,7 +5,7 @@
#import "OWSVerificationStateSyncMessage.h"
#import "Cryptography.h"
#import "OWSIdentityManager.h"
#import "OWSSignalServiceProtos.pb.h"
#import <SignalServiceKit/SignalServiceKit-Swift.h>
NS_ASSUME_NONNULL_BEGIN
@ -54,7 +54,7 @@ NS_ASSUME_NONNULL_BEGIN
return [super initWithCoder:coder];
}
- (OWSSignalServiceProtosSyncMessageBuilder *)syncMessageBuilder
- (SSKProtoSyncMessageBuilder *)syncMessageBuilder
{
OWSAssert(self.identityKey.length == kIdentityKeyLength);
OWSAssert(self.verificationForRecipientId.length > 0);
@ -63,9 +63,9 @@ NS_ASSUME_NONNULL_BEGIN
// will figure that out on it's own.
OWSAssert(self.verificationState != OWSVerificationStateNoLongerVerified);
OWSSignalServiceProtosSyncMessageBuilder *syncMessageBuilder = [OWSSignalServiceProtosSyncMessageBuilder new];
SSKProtoSyncMessageBuilder *syncMessageBuilder = [SSKProtoSyncMessageBuilder new];
OWSSignalServiceProtosVerifiedBuilder *verifiedBuilder = [OWSSignalServiceProtosVerifiedBuilder new];
SSKProtoVerifiedBuilder *verifiedBuilder = [SSKProtoVerifiedBuilder new];
verifiedBuilder.destination = self.verificationForRecipientId;
verifiedBuilder.identityKey = self.identityKey;
verifiedBuilder.state = OWSVerificationStateToProtoState(self.verificationState);
@ -93,7 +93,7 @@ NS_ASSUME_NONNULL_BEGIN
// will figure that out on it's own.
OWSAssert(self.verificationState != OWSVerificationStateNoLongerVerified);
OWSSignalServiceProtosVerifiedBuilder *verifiedBuilder = [OWSSignalServiceProtosVerifiedBuilder new];
SSKProtoVerifiedBuilder *verifiedBuilder = [SSKProtoVerifiedBuilder new];
verifiedBuilder.destination = self.verificationForRecipientId;
verifiedBuilder.identityKey = self.identityKey;
verifiedBuilder.state = OWSVerificationStateToProtoState(self.verificationState);

View File

@ -9,7 +9,7 @@ extern NSString *const kAttachmentDownloadProgressKey;
extern NSString *const kAttachmentDownloadAttachmentIDKey;
@class OWSPrimaryStorage;
@class OWSSignalServiceProtosAttachmentPointer;
@class SSKProtoAttachmentPointer;
@class TSAttachmentPointer;
@class TSAttachmentStream;
@class TSMessage;
@ -29,7 +29,7 @@ extern NSString *const kAttachmentDownloadAttachmentIDKey;
- (instancetype)init NS_UNAVAILABLE;
- (instancetype)initWithAttachmentProtos:(NSArray<OWSSignalServiceProtosAttachmentPointer *> *)attachmentProtos
- (instancetype)initWithAttachmentProtos:(NSArray<SSKProtoAttachmentPointer *> *)attachmentProtos
networkManager:(TSNetworkManager *)networkManager
transaction:(YapDatabaseReadWriteTransaction *)transaction NS_DESIGNATED_INITIALIZER;

View File

@ -11,7 +11,6 @@
#import "OWSError.h"
#import "OWSPrimaryStorage.h"
#import "OWSRequestFactory.h"
#import "OWSSignalServiceProtos.pb.h"
#import "TSAttachmentPointer.h"
#import "TSAttachmentStream.h"
#import "TSGroupModel.h"
@ -20,6 +19,7 @@
#import "TSMessage.h"
#import "TSNetworkManager.h"
#import "TSThread.h"
#import <SignalServiceKit/SignalServiceKit-Swift.h>
#import <YapDatabase/YapDatabaseConnection.h>
NS_ASSUME_NONNULL_BEGIN
@ -56,7 +56,7 @@ static const CGFloat kAttachmentDownloadProgressTheta = 0.001f;
return self;
}
- (instancetype)initWithAttachmentProtos:(NSArray<OWSSignalServiceProtosAttachmentPointer *> *)attachmentProtos
- (instancetype)initWithAttachmentProtos:(NSArray<SSKProtoAttachmentPointer *> *)attachmentProtos
networkManager:(TSNetworkManager *)networkManager
transaction:(YapDatabaseReadWriteTransaction *)transaction
{
@ -70,7 +70,7 @@ static const CGFloat kAttachmentDownloadProgressTheta = 0.001f;
NSMutableArray<NSString *> *attachmentIds = [NSMutableArray new];
NSMutableArray<TSAttachmentPointer *> *attachmentPointers = [NSMutableArray new];
for (OWSSignalServiceProtosAttachmentPointer *attachmentProto in attachmentProtos) {
for (SSKProtoAttachmentPointer *attachmentProto in attachmentProtos) {
TSAttachmentPointer *pointer = [TSAttachmentPointer attachmentPointerFromProto:attachmentProto];
[attachmentIds addObject:pointer.uniqueId];

View File

@ -2,7 +2,7 @@
// Copyright (c) 2018 Open Whisper Systems. All rights reserved.
//
#import "OWSSignalServiceProtos.pb.h"
#import "SignalServiceKit-Swift.h"
#import "TSAttachment.h"
NS_ASSUME_NONNULL_BEGIN
@ -28,7 +28,7 @@ typedef NS_ENUM(NSUInteger, TSAttachmentPointerState) {
sourceFilename:(nullable NSString *)sourceFilename
attachmentType:(TSAttachmentType)attachmentType NS_DESIGNATED_INITIALIZER;
+ (TSAttachmentPointer *)attachmentPointerFromProto:(OWSSignalServiceProtosAttachmentPointer *)attachmentProto;
+ (TSAttachmentPointer *)attachmentPointerFromProto:(SSKProtoAttachmentPointer *)attachmentProto;
@property (atomic) TSAttachmentPointerState state;
@property (nullable, atomic) NSString *mostRecentFailureLocalizedText;

View File

@ -50,7 +50,7 @@ NS_ASSUME_NONNULL_BEGIN
}
+ (TSAttachmentPointer *)attachmentPointerFromProto:(OWSSignalServiceProtosAttachmentPointer *)attachmentProto
+ (TSAttachmentPointer *)attachmentPointerFromProto:(SSKProtoAttachmentPointer *)attachmentProto
{
OWSAssert(attachmentProto.id != 0);
OWSAssert(attachmentProto.key != nil);
@ -62,7 +62,7 @@ NS_ASSUME_NONNULL_BEGIN
TSAttachmentType attachmentType = TSAttachmentTypeDefault;
if ([attachmentProto hasFlags]) {
UInt32 flags = attachmentProto.flags;
if ((flags & (UInt32)OWSSignalServiceProtosAttachmentPointerFlagsVoiceMessage) > 0) {
if ((flags & (UInt32)SSKProtoAttachmentPointerFlagsVoiceMessage) > 0) {
attachmentType = TSAttachmentTypeVoiceMessage;
}
}

View File

@ -13,7 +13,7 @@
NS_ASSUME_NONNULL_BEGIN
@class OWSSignalServiceProtosAttachmentPointer;
@class SSKProtoAttachmentPointer;
@class TSAttachmentPointer;
@class YapDatabaseReadWriteTransaction;
@ -90,9 +90,9 @@ NS_ASSUME_NONNULL_BEGIN
#pragma mark - Protobuf
+ (nullable OWSSignalServiceProtosAttachmentPointer *)buildProtoForAttachmentId:(nullable NSString *)attachmentId;
+ (nullable SSKProtoAttachmentPointer *)buildProtoForAttachmentId:(nullable NSString *)attachmentId;
- (OWSSignalServiceProtosAttachmentPointer *)buildProto;
- (SSKProtoAttachmentPointer *)buildProto;
@end

View File

@ -769,7 +769,7 @@ NS_ASSUME_NONNULL_BEGIN
// MARK: Protobuf serialization
+ (nullable OWSSignalServiceProtosAttachmentPointer *)buildProtoForAttachmentId:(nullable NSString *)attachmentId
+ (nullable SSKProtoAttachmentPointer *)buildProtoForAttachmentId:(nullable NSString *)attachmentId
{
OWSAssert(attachmentId.length > 0);
@ -787,9 +787,9 @@ NS_ASSUME_NONNULL_BEGIN
}
- (OWSSignalServiceProtosAttachmentPointer *)buildProto
- (SSKProtoAttachmentPointer *)buildProto
{
OWSSignalServiceProtosAttachmentPointerBuilder *builder = [OWSSignalServiceProtosAttachmentPointerBuilder new];
SSKProtoAttachmentPointerBuilder *builder = [SSKProtoAttachmentPointerBuilder new];
builder.id = self.serverId;
@ -802,7 +802,7 @@ NS_ASSUME_NONNULL_BEGIN
builder.size = self.byteCount;
builder.key = self.encryptionKey;
builder.digest = self.digest;
builder.flags = self.isVoiceMessage ? OWSSignalServiceProtosAttachmentPointerFlagsVoiceMessage : 0;
builder.flags = self.isVoiceMessage ? SSKProtoAttachmentPointerFlagsVoiceMessage : 0;
if (self.shouldHaveImageSize) {
CGSize imageSize = self.imageSize;

View File

@ -5,9 +5,9 @@
NS_ASSUME_NONNULL_BEGIN
@class OWSContact;
@class OWSSignalServiceProtosAttachmentPointer;
@class OWSSignalServiceProtosDataMessage;
@class OWSSignalServiceProtosSyncMessageSent;
@class SSKProtoAttachmentPointer;
@class SSKProtoDataMessage;
@class SSKProtoSyncMessageSent;
@class TSQuotedMessage;
@class TSThread;
@class YapDatabaseReadWriteTransaction;
@ -18,10 +18,10 @@ NS_ASSUME_NONNULL_BEGIN
*/
@interface OWSIncomingSentMessageTranscript : NSObject
- (instancetype)initWithProto:(OWSSignalServiceProtosSyncMessageSent *)sentProto
- (instancetype)initWithProto:(SSKProtoSyncMessageSent *)sentProto
transaction:(YapDatabaseReadWriteTransaction *)transaction;
@property (nonatomic, readonly) OWSSignalServiceProtosDataMessage *dataMessage;
@property (nonatomic, readonly) SSKProtoDataMessage *dataMessage;
@property (nonatomic, readonly) NSString *recipientId;
@property (nonatomic, readonly) uint64_t timestamp;
@property (nonatomic, readonly) uint64_t expirationStartedAt;
@ -31,7 +31,7 @@ NS_ASSUME_NONNULL_BEGIN
@property (nonatomic, readonly) BOOL isEndSessionMessage;
@property (nonatomic, readonly, nullable) NSData *groupId;
@property (nonatomic, readonly) NSString *body;
@property (nonatomic, readonly) NSArray<OWSSignalServiceProtosAttachmentPointer *> *attachmentPointerProtos;
@property (nonatomic, readonly) NSArray<SSKProtoAttachmentPointer *> *attachmentPointerProtos;
@property (nonatomic, readonly) TSThread *thread;
@property (nonatomic, readonly, nullable) TSQuotedMessage *quotedMessage;
@property (nonatomic, readonly, nullable) OWSContact *contact;

View File

@ -6,19 +6,19 @@
#import "OWSContact.h"
#import "OWSMessageManager.h"
#import "OWSPrimaryStorage.h"
#import "OWSSignalServiceProtos.pb.h"
#import "TSContactThread.h"
#import "TSGroupModel.h"
#import "TSGroupThread.h"
#import "TSOutgoingMessage.h"
#import "TSQuotedMessage.h"
#import "TSThread.h"
#import <SignalServiceKit/SignalServiceKit-Swift.h>
NS_ASSUME_NONNULL_BEGIN
@implementation OWSIncomingSentMessageTranscript
- (instancetype)initWithProto:(OWSSignalServiceProtosSyncMessageSent *)sentProto
- (instancetype)initWithProto:(SSKProtoSyncMessageSent *)sentProto
transaction:(YapDatabaseReadWriteTransaction *)transaction
{
self = [super init];
@ -33,9 +33,9 @@ NS_ASSUME_NONNULL_BEGIN
_expirationDuration = sentProto.message.expireTimer;
_body = _dataMessage.body;
_groupId = _dataMessage.group.id;
_isGroupUpdate = _dataMessage.hasGroup && (_dataMessage.group.type == OWSSignalServiceProtosGroupContextTypeUpdate);
_isExpirationTimerUpdate = (_dataMessage.flags & OWSSignalServiceProtosDataMessageFlagsExpirationTimerUpdate) != 0;
_isEndSessionMessage = (_dataMessage.flags & OWSSignalServiceProtosDataMessageFlagsEndSession) != 0;
_isGroupUpdate = _dataMessage.hasGroup && (_dataMessage.group.type == SSKProtoGroupContextTypeUpdate);
_isExpirationTimerUpdate = (_dataMessage.flags & SSKProtoDataMessageFlagsExpirationTimerUpdate) != 0;
_isEndSessionMessage = (_dataMessage.flags & SSKProtoDataMessageFlagsEndSession) != 0;
if (self.dataMessage.hasGroup) {
_thread = [TSGroupThread getOrCreateThreadWithGroupId:_dataMessage.group.id transaction:transaction];
@ -49,7 +49,7 @@ NS_ASSUME_NONNULL_BEGIN
return self;
}
- (NSArray<OWSSignalServiceProtosAttachmentPointer *> *)attachmentPointerProtos
- (NSArray<SSKProtoAttachmentPointer *> *)attachmentPointerProtos
{
if (self.isGroupUpdate && self.dataMessage.group.hasAvatar) {
return @[ self.dataMessage.group.avatar ];

View File

@ -3,9 +3,9 @@
//
#import "OWSOutgoingSentMessageTranscript.h"
#import "OWSSignalServiceProtos.pb.h"
#import "TSOutgoingMessage.h"
#import "TSThread.h"
#import <SignalServiceKit/SignalServiceKit-Swift.h>
NS_ASSUME_NONNULL_BEGIN
@ -18,7 +18,7 @@ NS_ASSUME_NONNULL_BEGIN
* recipientId is nil when building "sent" sync messages for messages
* sent to groups.
*/
- (OWSSignalServiceProtosDataMessage *)buildDataMessage:(NSString *_Nullable)recipientId;
- (SSKProtoDataMessage *)buildDataMessage:(NSString *_Nullable)recipientId;
@end
@ -53,11 +53,11 @@ NS_ASSUME_NONNULL_BEGIN
return [super initWithCoder:coder];
}
- (OWSSignalServiceProtosSyncMessageBuilder *)syncMessageBuilder
- (SSKProtoSyncMessageBuilder *)syncMessageBuilder
{
OWSSignalServiceProtosSyncMessageBuilder *syncMessageBuilder = [OWSSignalServiceProtosSyncMessageBuilder new];
SSKProtoSyncMessageBuilder *syncMessageBuilder = [SSKProtoSyncMessageBuilder new];
OWSSignalServiceProtosSyncMessageSentBuilder *sentBuilder = [OWSSignalServiceProtosSyncMessageSentBuilder new];
SSKProtoSyncMessageSentBuilder *sentBuilder = [SSKProtoSyncMessageSentBuilder new];
[sentBuilder setTimestamp:self.message.timestamp];
[sentBuilder setDestination:self.sentRecipientId];

View File

@ -5,8 +5,8 @@
#import "OWSOutgoingSyncMessage.h"
#import "Cryptography.h"
#import "NSDate+OWS.h"
#import "OWSSignalServiceProtos.pb.h"
#import "ProtoBuf+OWS.h"
#import <SignalServiceKit/SignalServiceKit-Swift.h>
NS_ASSUME_NONNULL_BEGIN
@ -48,9 +48,9 @@ NS_ASSUME_NONNULL_BEGIN
}
// This method should not be overridden, since we want to add random padding to *every* sync message
- (OWSSignalServiceProtosSyncMessage *)buildSyncMessage
- (SSKProtoSyncMessage *)buildSyncMessage
{
OWSSignalServiceProtosSyncMessageBuilder *builder = [self syncMessageBuilder];
SSKProtoSyncMessageBuilder *builder = [self syncMessageBuilder];
// Add a random 1-512 bytes to obscure sync message type
size_t paddingBytesLength = arc4random_uniform(512) + 1;
@ -59,15 +59,15 @@ NS_ASSUME_NONNULL_BEGIN
return [builder build];
}
- (OWSSignalServiceProtosSyncMessageBuilder *)syncMessageBuilder
- (SSKProtoSyncMessageBuilder *)syncMessageBuilder
{
OWSFail(@"Abstract method should be overridden in subclass.");
return [OWSSignalServiceProtosSyncMessageBuilder new];
return [SSKProtoSyncMessageBuilder new];
}
- (NSData *)buildPlainTextData:(SignalRecipient *)recipient
- (nullable NSData *)buildPlainTextData:(SignalRecipient *)recipient
{
OWSSignalServiceProtosContentBuilder *contentBuilder = [OWSSignalServiceProtosContentBuilder new];
SSKProtoContentBuilder *contentBuilder = [SSKProtoContentBuilder new];
[contentBuilder setSyncMessage:[self buildSyncMessage]];
return [[contentBuilder build] data];
}

View File

@ -3,7 +3,7 @@
//
#import "OWSSyncConfigurationMessage.h"
#import "OWSSignalServiceProtos.pb.h"
#import <SignalServiceKit/SignalServiceKit-Swift.h>
NS_ASSUME_NONNULL_BEGIN
@ -32,14 +32,14 @@ NS_ASSUME_NONNULL_BEGIN
return [super initWithCoder:coder];
}
- (OWSSignalServiceProtosSyncMessageBuilder *)syncMessageBuilder
- (SSKProtoSyncMessageBuilder *)syncMessageBuilder
{
OWSSignalServiceProtosSyncMessageConfigurationBuilder *configurationBuilder =
[OWSSignalServiceProtosSyncMessageConfigurationBuilder new];
SSKProtoSyncMessageConfigurationBuilder *configurationBuilder =
[SSKProtoSyncMessageConfigurationBuilder new];
configurationBuilder.readReceipts = self.areReadReceiptsEnabled;
OWSSignalServiceProtosSyncMessageBuilder *builder = [OWSSignalServiceProtosSyncMessageBuilder new];
SSKProtoSyncMessageBuilder *builder = [SSKProtoSyncMessageBuilder new];
builder.configurationBuilder = configurationBuilder;

View File

@ -8,13 +8,13 @@
#import "NSDate+OWS.h"
#import "OWSContactsOutputStream.h"
#import "OWSIdentityManager.h"
#import "OWSSignalServiceProtos.pb.h"
#import "ProfileManagerProtocol.h"
#import "SignalAccount.h"
#import "TSAttachment.h"
#import "TSAttachmentStream.h"
#import "TSContactThread.h"
#import "TextSecureKitEnv.h"
#import <SignalServiceKit/SignalServiceKit-Swift.h>
NS_ASSUME_NONNULL_BEGIN
@ -49,23 +49,23 @@ NS_ASSUME_NONNULL_BEGIN
return [super initWithCoder:coder];
}
- (OWSSignalServiceProtosSyncMessageBuilder *)syncMessageBuilder
- (SSKProtoSyncMessageBuilder *)syncMessageBuilder
{
if (self.attachmentIds.count != 1) {
DDLogError(@"expected sync contact message to have exactly one attachment, but found %lu",
(unsigned long)self.attachmentIds.count);
}
OWSSignalServiceProtosAttachmentPointer *attachmentProto =
SSKProtoAttachmentPointer *attachmentProto =
[TSAttachmentStream buildProtoForAttachmentId:self.attachmentIds.firstObject];
OWSSignalServiceProtosSyncMessageContactsBuilder *contactsBuilder =
[OWSSignalServiceProtosSyncMessageContactsBuilder new];
SSKProtoSyncMessageContactsBuilder *contactsBuilder =
[SSKProtoSyncMessageContactsBuilder new];
[contactsBuilder setBlob:attachmentProto];
[contactsBuilder setIsComplete:YES];
OWSSignalServiceProtosSyncMessageBuilder *syncMessageBuilder = [OWSSignalServiceProtosSyncMessageBuilder new];
SSKProtoSyncMessageBuilder *syncMessageBuilder = [SSKProtoSyncMessageBuilder new];
[syncMessageBuilder setContactsBuilder:contactsBuilder];
return syncMessageBuilder;

View File

@ -5,12 +5,12 @@
#import "OWSSyncGroupsMessage.h"
#import "NSDate+OWS.h"
#import "OWSGroupsOutputStream.h"
#import "OWSSignalServiceProtos.pb.h"
#import "TSAttachment.h"
#import "TSAttachmentStream.h"
#import "TSContactThread.h"
#import "TSGroupModel.h"
#import "TSGroupThread.h"
#import <SignalServiceKit/SignalServiceKit-Swift.h>
NS_ASSUME_NONNULL_BEGIN
@ -26,21 +26,21 @@ NS_ASSUME_NONNULL_BEGIN
return [super initWithCoder:coder];
}
- (OWSSignalServiceProtosSyncMessageBuilder *)syncMessageBuilder
- (SSKProtoSyncMessageBuilder *)syncMessageBuilder
{
if (self.attachmentIds.count != 1) {
DDLogError(@"expected sync groups message to have exactly one attachment, but found %lu",
(unsigned long)self.attachmentIds.count);
}
OWSSignalServiceProtosAttachmentPointer *attachmentProto = [TSAttachmentStream buildProtoForAttachmentId:self.attachmentIds.firstObject];
SSKProtoAttachmentPointer *attachmentProto = [TSAttachmentStream buildProtoForAttachmentId:self.attachmentIds.firstObject];
OWSSignalServiceProtosSyncMessageGroupsBuilder *groupsBuilder =
[OWSSignalServiceProtosSyncMessageGroupsBuilder new];
SSKProtoSyncMessageGroupsBuilder *groupsBuilder =
[SSKProtoSyncMessageGroupsBuilder new];
[groupsBuilder setBlob:attachmentProto];
OWSSignalServiceProtosSyncMessageBuilder *syncMessageBuilder = [OWSSignalServiceProtosSyncMessageBuilder new];
SSKProtoSyncMessageBuilder *syncMessageBuilder = [SSKProtoSyncMessageBuilder new];
[syncMessageBuilder setGroupsBuilder:groupsBuilder];
return syncMessageBuilder;

View File

@ -4,7 +4,7 @@
#import "OWSSyncGroupsRequestMessage.h"
#import "NSDate+OWS.h"
#import "OWSSignalServiceProtos.pb.h"
#import <SignalServiceKit/SignalServiceKit-Swift.h>
NS_ASSUME_NONNULL_BEGIN
@ -57,13 +57,13 @@ NS_ASSUME_NONNULL_BEGIN
return YES;
}
- (OWSSignalServiceProtosDataMessageBuilder *)dataMessageBuilder
- (SSKProtoDataMessageBuilder *)dataMessageBuilder
{
OWSSignalServiceProtosGroupContextBuilder *groupContextBuilder = [OWSSignalServiceProtosGroupContextBuilder new];
[groupContextBuilder setType:OWSSignalServiceProtosGroupContextTypeRequestInfo];
SSKProtoGroupContextBuilder *groupContextBuilder = [SSKProtoGroupContextBuilder new];
[groupContextBuilder setType:SSKProtoGroupContextTypeRequestInfo];
[groupContextBuilder setId:self.groupId];
OWSSignalServiceProtosDataMessageBuilder *builder = [OWSSignalServiceProtosDataMessageBuilder new];
SSKProtoDataMessageBuilder *builder = [SSKProtoDataMessageBuilder new];
[builder setTimestamp:self.timestamp];
[builder setGroupBuilder:groupContextBuilder];

View File

@ -9,8 +9,8 @@ NS_ASSUME_NONNULL_BEGIN
@class CNContact;
@class OWSAttachmentInfo;
@class OWSSignalServiceProtosDataMessage;
@class OWSSignalServiceProtosDataMessageContact;
@class SSKProtoDataMessage;
@class SSKProtoDataMessageContact;
@class TSAttachment;
@class TSAttachmentStream;
@class YapDatabaseReadTransaction;
@ -173,9 +173,9 @@ NSString *NSStringForContactAddressType(OWSContactAddressType value);
#pragma mark - Proto Serialization
+ (nullable OWSSignalServiceProtosDataMessageContact *)protoForContact:(OWSContact *)contact;
+ (nullable SSKProtoDataMessageContact *)protoForContact:(OWSContact *)contact;
+ (nullable OWSContact *)contactForDataMessage:(OWSSignalServiceProtosDataMessage *)dataMessage
+ (nullable OWSContact *)contactForDataMessage:(SSKProtoDataMessage *)dataMessage
transaction:(YapDatabaseReadWriteTransaction *)transaction;
@end

View File

@ -7,11 +7,11 @@
#import "MimeTypeUtil.h"
#import "NSString+SSK.h"
#import "OWSContact+Private.h"
#import "OWSSignalServiceProtos.pb.h"
#import "PhoneNumber.h"
#import "TSAttachment.h"
#import "TSAttachmentPointer.h"
#import "TSAttachmentStream.h"
#import <SignalServiceKit/SignalServiceKit-Swift.h>
#import <YapDatabase/YapDatabaseTransaction.h>
@import Contacts;
@ -766,15 +766,15 @@ NSString *NSStringForContactAddressType(OWSContactAddressType value)
#pragma mark - Proto Serialization
+ (nullable OWSSignalServiceProtosDataMessageContact *)protoForContact:(OWSContact *)contact
+ (nullable SSKProtoDataMessageContact *)protoForContact:(OWSContact *)contact
{
OWSAssert(contact);
OWSSignalServiceProtosDataMessageContactBuilder *contactBuilder =
[OWSSignalServiceProtosDataMessageContactBuilder new];
SSKProtoDataMessageContactBuilder *contactBuilder =
[SSKProtoDataMessageContactBuilder new];
OWSSignalServiceProtosDataMessageContactNameBuilder *nameBuilder =
[OWSSignalServiceProtosDataMessageContactNameBuilder new];
SSKProtoDataMessageContactNameBuilder *nameBuilder =
[SSKProtoDataMessageContactNameBuilder new];
OWSContactName *contactName = contact.name;
if (contactName.givenName.ows_stripped.length > 0) {
@ -799,56 +799,56 @@ NSString *NSStringForContactAddressType(OWSContactAddressType value)
[contactBuilder setNameBuilder:nameBuilder];
for (OWSContactPhoneNumber *phoneNumber in contact.phoneNumbers) {
OWSSignalServiceProtosDataMessageContactPhoneBuilder *phoneBuilder =
[OWSSignalServiceProtosDataMessageContactPhoneBuilder new];
SSKProtoDataMessageContactPhoneBuilder *phoneBuilder =
[SSKProtoDataMessageContactPhoneBuilder new];
phoneBuilder.value = phoneNumber.phoneNumber;
if (phoneNumber.label.ows_stripped.length > 0) {
phoneBuilder.label = phoneNumber.label.ows_stripped;
}
switch (phoneNumber.phoneType) {
case OWSContactPhoneType_Home:
phoneBuilder.type = OWSSignalServiceProtosDataMessageContactPhoneTypeHome;
phoneBuilder.type = SSKProtoDataMessageContactPhoneTypeHome;
break;
case OWSContactPhoneType_Mobile:
phoneBuilder.type = OWSSignalServiceProtosDataMessageContactPhoneTypeMobile;
phoneBuilder.type = SSKProtoDataMessageContactPhoneTypeMobile;
break;
case OWSContactPhoneType_Work:
phoneBuilder.type = OWSSignalServiceProtosDataMessageContactPhoneTypeWork;
phoneBuilder.type = SSKProtoDataMessageContactPhoneTypeWork;
break;
case OWSContactPhoneType_Custom:
phoneBuilder.type = OWSSignalServiceProtosDataMessageContactPhoneTypeCustom;
phoneBuilder.type = SSKProtoDataMessageContactPhoneTypeCustom;
break;
}
[contactBuilder addNumber:phoneBuilder.build];
}
for (OWSContactEmail *email in contact.emails) {
OWSSignalServiceProtosDataMessageContactEmailBuilder *emailBuilder =
[OWSSignalServiceProtosDataMessageContactEmailBuilder new];
SSKProtoDataMessageContactEmailBuilder *emailBuilder =
[SSKProtoDataMessageContactEmailBuilder new];
emailBuilder.value = email.email;
if (email.label.ows_stripped.length > 0) {
emailBuilder.label = email.label.ows_stripped;
}
switch (email.emailType) {
case OWSContactEmailType_Home:
emailBuilder.type = OWSSignalServiceProtosDataMessageContactEmailTypeHome;
emailBuilder.type = SSKProtoDataMessageContactEmailTypeHome;
break;
case OWSContactEmailType_Mobile:
emailBuilder.type = OWSSignalServiceProtosDataMessageContactEmailTypeMobile;
emailBuilder.type = SSKProtoDataMessageContactEmailTypeMobile;
break;
case OWSContactEmailType_Work:
emailBuilder.type = OWSSignalServiceProtosDataMessageContactEmailTypeWork;
emailBuilder.type = SSKProtoDataMessageContactEmailTypeWork;
break;
case OWSContactEmailType_Custom:
emailBuilder.type = OWSSignalServiceProtosDataMessageContactEmailTypeCustom;
emailBuilder.type = SSKProtoDataMessageContactEmailTypeCustom;
break;
}
[contactBuilder addEmail:emailBuilder.build];
}
for (OWSContactAddress *address in contact.addresses) {
OWSSignalServiceProtosDataMessageContactPostalAddressBuilder *addressBuilder =
[OWSSignalServiceProtosDataMessageContactPostalAddressBuilder new];
SSKProtoDataMessageContactPostalAddressBuilder *addressBuilder =
[SSKProtoDataMessageContactPostalAddressBuilder new];
if (address.label.ows_stripped.length > 0) {
addressBuilder.label = address.label.ows_stripped;
}
@ -877,14 +877,14 @@ NSString *NSStringForContactAddressType(OWSContactAddressType value)
}
if (contact.avatarAttachmentId != nil) {
OWSSignalServiceProtosDataMessageContactAvatarBuilder *avatarBuilder =
[OWSSignalServiceProtosDataMessageContactAvatarBuilder new];
SSKProtoDataMessageContactAvatarBuilder *avatarBuilder =
[SSKProtoDataMessageContactAvatarBuilder new];
avatarBuilder.avatar =
[TSAttachmentStream buildProtoForAttachmentId:contact.avatarAttachmentId];
contactBuilder.avatar = [avatarBuilder build];
}
OWSSignalServiceProtosDataMessageContact *contactProto = [contactBuilder build];
SSKProtoDataMessageContact *contactProto = [contactBuilder build];
if (contactProto.number.count < 1 && contactProto.email.count < 1 && contactProto.address.count < 1) {
OWSProdLogAndFail(@"%@ contact has neither phone, email or address.", self.logTag);
return nil;
@ -892,7 +892,7 @@ NSString *NSStringForContactAddressType(OWSContactAddressType value)
return contactProto;
}
+ (nullable OWSContact *)contactForDataMessage:(OWSSignalServiceProtosDataMessage *)dataMessage
+ (nullable OWSContact *)contactForDataMessage:(SSKProtoDataMessage *)dataMessage
transaction:(YapDatabaseReadWriteTransaction *)transaction
{
OWSAssert(dataMessage);
@ -901,13 +901,13 @@ NSString *NSStringForContactAddressType(OWSContactAddressType value)
return nil;
}
OWSAssert(dataMessage.contact.count == 1);
OWSSignalServiceProtosDataMessageContact *contactProto = dataMessage.contact.firstObject;
SSKProtoDataMessageContact *contactProto = dataMessage.contact.firstObject;
OWSContact *contact = [OWSContact new];
OWSContactName *contactName = [OWSContactName new];
if (contactProto.hasName) {
OWSSignalServiceProtosDataMessageContactName *nameProto = contactProto.name;
SSKProtoDataMessageContactName *nameProto = contactProto.name;
if (nameProto.hasGivenName) {
contactName.givenName = nameProto.givenName.ows_stripped;
@ -935,7 +935,7 @@ NSString *NSStringForContactAddressType(OWSContactAddressType value)
contact.name = contactName;
NSMutableArray<OWSContactPhoneNumber *> *phoneNumbers = [NSMutableArray new];
for (OWSSignalServiceProtosDataMessageContactPhone *phoneNumberProto in contactProto.number) {
for (SSKProtoDataMessageContactPhone *phoneNumberProto in contactProto.number) {
OWSContactPhoneNumber *_Nullable phoneNumber = [self phoneNumberForProto:phoneNumberProto];
if (phoneNumber) {
[phoneNumbers addObject:phoneNumber];
@ -944,7 +944,7 @@ NSString *NSStringForContactAddressType(OWSContactAddressType value)
contact.phoneNumbers = [phoneNumbers copy];
NSMutableArray<OWSContactEmail *> *emails = [NSMutableArray new];
for (OWSSignalServiceProtosDataMessageContactEmail *emailProto in contactProto.email) {
for (SSKProtoDataMessageContactEmail *emailProto in contactProto.email) {
OWSContactEmail *_Nullable email = [self emailForProto:emailProto];
if (email) {
[emails addObject:email];
@ -953,7 +953,7 @@ NSString *NSStringForContactAddressType(OWSContactAddressType value)
contact.emails = [emails copy];
NSMutableArray<OWSContactAddress *> *addresses = [NSMutableArray new];
for (OWSSignalServiceProtosDataMessageContactPostalAddress *addressProto in contactProto.address) {
for (SSKProtoDataMessageContactPostalAddress *addressProto in contactProto.address) {
OWSContactAddress *_Nullable address = [self addressForProto:addressProto];
if (address) {
[addresses addObject:address];
@ -962,10 +962,10 @@ NSString *NSStringForContactAddressType(OWSContactAddressType value)
contact.addresses = [addresses copy];
if (contactProto.hasAvatar) {
OWSSignalServiceProtosDataMessageContactAvatar *avatarInfo = contactProto.avatar;
SSKProtoDataMessageContactAvatar *avatarInfo = contactProto.avatar;
if (avatarInfo.hasAvatar) {
OWSSignalServiceProtosAttachmentPointer *avatarAttachment = avatarInfo.avatar;
SSKProtoAttachmentPointer *avatarAttachment = avatarInfo.avatar;
TSAttachmentPointer *attachmentPointer = [TSAttachmentPointer attachmentPointerFromProto:avatarAttachment];
[attachmentPointer saveWithTransaction:transaction];
@ -982,19 +982,19 @@ NSString *NSStringForContactAddressType(OWSContactAddressType value)
}
+ (nullable OWSContactPhoneNumber *)phoneNumberForProto:
(OWSSignalServiceProtosDataMessageContactPhone *)phoneNumberProto
(SSKProtoDataMessageContactPhone *)phoneNumberProto
{
OWSContactPhoneNumber *result = [OWSContactPhoneNumber new];
result.phoneType = OWSContactPhoneType_Custom;
if (phoneNumberProto.hasType) {
switch (phoneNumberProto.type) {
case OWSSignalServiceProtosDataMessageContactPhoneTypeHome:
case SSKProtoDataMessageContactPhoneTypeHome:
result.phoneType = OWSContactPhoneType_Home;
break;
case OWSSignalServiceProtosDataMessageContactPhoneTypeMobile:
case SSKProtoDataMessageContactPhoneTypeMobile:
result.phoneType = OWSContactPhoneType_Mobile;
break;
case OWSSignalServiceProtosDataMessageContactPhoneTypeWork:
case SSKProtoDataMessageContactPhoneTypeWork:
result.phoneType = OWSContactPhoneType_Work;
break;
default:
@ -1012,19 +1012,19 @@ NSString *NSStringForContactAddressType(OWSContactAddressType value)
return result;
}
+ (nullable OWSContactEmail *)emailForProto:(OWSSignalServiceProtosDataMessageContactEmail *)emailProto
+ (nullable OWSContactEmail *)emailForProto:(SSKProtoDataMessageContactEmail *)emailProto
{
OWSContactEmail *result = [OWSContactEmail new];
result.emailType = OWSContactEmailType_Custom;
if (emailProto.hasType) {
switch (emailProto.type) {
case OWSSignalServiceProtosDataMessageContactEmailTypeHome:
case SSKProtoDataMessageContactEmailTypeHome:
result.emailType = OWSContactEmailType_Home;
break;
case OWSSignalServiceProtosDataMessageContactEmailTypeMobile:
case SSKProtoDataMessageContactEmailTypeMobile:
result.emailType = OWSContactEmailType_Mobile;
break;
case OWSSignalServiceProtosDataMessageContactEmailTypeWork:
case SSKProtoDataMessageContactEmailTypeWork:
result.emailType = OWSContactEmailType_Work;
break;
default:
@ -1042,16 +1042,16 @@ NSString *NSStringForContactAddressType(OWSContactAddressType value)
return result;
}
+ (nullable OWSContactAddress *)addressForProto:(OWSSignalServiceProtosDataMessageContactPostalAddress *)addressProto
+ (nullable OWSContactAddress *)addressForProto:(SSKProtoDataMessageContactPostalAddress *)addressProto
{
OWSContactAddress *result = [OWSContactAddress new];
result.addressType = OWSContactAddressType_Custom;
if (addressProto.hasType) {
switch (addressProto.type) {
case OWSSignalServiceProtosDataMessageContactPostalAddressTypeHome:
case SSKProtoDataMessageContactPostalAddressTypeHome:
result.addressType = OWSContactAddressType_Home;
break;
case OWSSignalServiceProtosDataMessageContactPostalAddressTypeWork:
case SSKProtoDataMessageContactPostalAddressTypeWork:
result.addressType = OWSContactAddressType_Work;
break;
default:

View File

@ -5,7 +5,7 @@
#import "OWSDisappearingMessagesConfigurationMessage.h"
#import "NSDate+OWS.h"
#import "OWSDisappearingMessagesConfiguration.h"
#import "OWSSignalServiceProtos.pb.h"
#import <SignalServiceKit/SignalServiceKit-Swift.h>
NS_ASSUME_NONNULL_BEGIN
@ -46,11 +46,11 @@ NS_ASSUME_NONNULL_BEGIN
}
- (OWSSignalServiceProtosDataMessageBuilder *)dataMessageBuilder
- (SSKProtoDataMessageBuilder *)dataMessageBuilder
{
OWSSignalServiceProtosDataMessageBuilder *dataMessageBuilder = [super dataMessageBuilder];
SSKProtoDataMessageBuilder *dataMessageBuilder = [super dataMessageBuilder];
[dataMessageBuilder setTimestamp:self.timestamp];
[dataMessageBuilder setFlags:OWSSignalServiceProtosDataMessageFlagsExpirationTimerUpdate];
[dataMessageBuilder setFlags:SSKProtoDataMessageFlagsExpirationTimerUpdate];
if (self.configuration.isEnabled) {
[dataMessageBuilder setExpireTimer:self.configuration.durationSeconds];
} else {

View File

@ -6,7 +6,7 @@
NS_ASSUME_NONNULL_BEGIN
@class OWSSignalServiceProtosDataMessageBuilder;
@class SSKProtoDataMessageBuilder;
@class SignalRecipient;
typedef NSData *_Nonnull (^DynamicOutgoingMessageBlock)(SignalRecipient *);

View File

@ -4,7 +4,7 @@
#import "OWSDynamicOutgoingMessage.h"
#import "NSDate+OWS.h"
#import "OWSSignalServiceProtos.pb.h"
#import <SignalServiceKit/SignalServiceKit-Swift.h>
NS_ASSUME_NONNULL_BEGIN
@ -50,7 +50,7 @@ NS_ASSUME_NONNULL_BEGIN
return NO;
}
- (NSData *)buildPlainTextData:(SignalRecipient *)recipient
- (nullable NSData *)buildPlainTextData:(SignalRecipient *)recipient
{
NSData *plainTextData = self.block(recipient);
OWSAssert(plainTextData);

View File

@ -3,7 +3,7 @@
//
#import "OWSEndSessionMessage.h"
#import "OWSSignalServiceProtos.pb.h"
#import <SignalServiceKit/SignalServiceKit-Swift.h>
NS_ASSUME_NONNULL_BEGIN
@ -33,11 +33,11 @@ NS_ASSUME_NONNULL_BEGIN
return NO;
}
- (OWSSignalServiceProtosDataMessageBuilder *)dataMessageBuilder
- (SSKProtoDataMessageBuilder *)dataMessageBuilder
{
OWSSignalServiceProtosDataMessageBuilder *builder = [super dataMessageBuilder];
SSKProtoDataMessageBuilder *builder = [super dataMessageBuilder];
[builder setTimestamp:self.timestamp];
[builder setFlags:OWSSignalServiceProtosDataMessageFlagsEndSession];
[builder setFlags:SSKProtoDataMessageFlagsEndSession];
return builder;
}

View File

@ -49,9 +49,9 @@ typedef NS_ENUM(NSInteger, TSGroupMetaMessage) {
TSGroupMessageRequestInfo,
};
@class OWSSignalServiceProtosAttachmentPointer;
@class OWSSignalServiceProtosContentBuilder;
@class OWSSignalServiceProtosDataMessageBuilder;
@class SSKProtoAttachmentPointer;
@class SSKProtoContentBuilder;
@class SSKProtoDataMessageBuilder;
@class SignalRecipient;
@interface TSOutgoingMessageRecipientState : MTLModel
@ -130,13 +130,13 @@ typedef NS_ENUM(NSInteger, TSGroupMetaMessage) {
/**
* The data representation of this message, to be encrypted, before being sent.
*/
- (NSData *)buildPlainTextData:(SignalRecipient *)recipient;
- (nullable NSData *)buildPlainTextData:(SignalRecipient *)recipient;
/**
* Intermediate protobuf representation
* Subclasses can augment if they want to manipulate the data message before building.
*/
- (OWSSignalServiceProtosDataMessageBuilder *)dataMessageBuilder;
- (SSKProtoDataMessageBuilder *)dataMessageBuilder;
/**
* Should this message be synced to the users other registered devices? This is

View File

@ -9,7 +9,6 @@
#import "OWSMessageSender.h"
#import "OWSOutgoingSyncMessage.h"
#import "OWSPrimaryStorage.h"
#import "OWSSignalServiceProtos.pb.h"
#import "ProtoBuf+OWS.h"
#import "SignalRecipient.h"
#import "TSAccountManager.h"
@ -18,6 +17,7 @@
#import "TSGroupThread.h"
#import "TSQuotedMessage.h"
#import "TextSecureKitEnv.h"
#import <SignalServiceKit/SignalServiceKit-Swift.h>
#import <YapDatabase/YapDatabase.h>
#import <YapDatabase/YapDatabaseTransaction.h>
@ -802,12 +802,12 @@ NSString *NSStringForOutgoingMessageRecipientState(OWSOutgoingMessageRecipientSt
}
#pragma mark -
- (OWSSignalServiceProtosDataMessageBuilder *)dataMessageBuilder
- (SSKProtoDataMessageBuilder *)dataMessageBuilder
{
TSThread *thread = self.thread;
OWSAssert(thread);
OWSSignalServiceProtosDataMessageBuilder *builder = [OWSSignalServiceProtosDataMessageBuilder new];
SSKProtoDataMessageBuilder *builder = [SSKProtoDataMessageBuilder new];
[builder setTimestamp:self.timestamp];
@ -830,11 +830,11 @@ NSString *NSStringForOutgoingMessageRecipientState(OWSOutgoingMessageRecipientSt
BOOL attachmentWasGroupAvatar = NO;
if ([thread isKindOfClass:[TSGroupThread class]]) {
TSGroupThread *gThread = (TSGroupThread *)thread;
OWSSignalServiceProtosGroupContextBuilder *groupBuilder = [OWSSignalServiceProtosGroupContextBuilder new];
SSKProtoGroupContextBuilder *groupBuilder = [SSKProtoGroupContextBuilder new];
switch (self.groupMetaMessage) {
case TSGroupMessageQuit:
[groupBuilder setType:OWSSignalServiceProtosGroupContextTypeQuit];
[groupBuilder setType:SSKProtoGroupContextTypeQuit];
break;
case TSGroupMessageUpdate:
case TSGroupMessageNew: {
@ -845,11 +845,11 @@ NSString *NSStringForOutgoingMessageRecipientState(OWSOutgoingMessageRecipientSt
[groupBuilder setMembersArray:gThread.groupModel.groupMemberIds];
[groupBuilder setName:gThread.groupModel.groupName];
[groupBuilder setType:OWSSignalServiceProtosGroupContextTypeUpdate];
[groupBuilder setType:SSKProtoGroupContextTypeUpdate];
break;
}
default:
[groupBuilder setType:OWSSignalServiceProtosGroupContextTypeDeliver];
[groupBuilder setType:SSKProtoGroupContextTypeDeliver];
break;
}
[groupBuilder setId:gThread.groupModel.groupId];
@ -866,14 +866,14 @@ NSString *NSStringForOutgoingMessageRecipientState(OWSOutgoingMessageRecipientSt
}
// Quoted Reply
OWSSignalServiceProtosDataMessageQuoteBuilder *_Nullable quotedMessageBuilder = self.quotedMessageBuilder;
SSKProtoDataMessageQuoteBuilder *_Nullable quotedMessageBuilder = self.quotedMessageBuilder;
if (quotedMessageBuilder) {
[builder setQuoteBuilder:quotedMessageBuilder];
}
// Contact Share
if (self.contactShare) {
OWSSignalServiceProtosDataMessageContact *_Nullable contactProto =
SSKProtoDataMessageContact *_Nullable contactProto =
[OWSContacts protoForContact:self.contactShare];
if (contactProto) {
[builder addContact:contactProto];
@ -885,14 +885,14 @@ NSString *NSStringForOutgoingMessageRecipientState(OWSOutgoingMessageRecipientSt
return builder;
}
- (nullable OWSSignalServiceProtosDataMessageQuoteBuilder *)quotedMessageBuilder
- (nullable SSKProtoDataMessageQuoteBuilder *)quotedMessageBuilder
{
if (!self.quotedMessage) {
return nil;
}
TSQuotedMessage *quotedMessage = self.quotedMessage;
OWSSignalServiceProtosDataMessageQuoteBuilder *quoteBuilder = [OWSSignalServiceProtosDataMessageQuoteBuilder new];
SSKProtoDataMessageQuoteBuilder *quoteBuilder = [SSKProtoDataMessageQuoteBuilder new];
[quoteBuilder setId:quotedMessage.timestamp];
[quoteBuilder setAuthor:quotedMessage.authorId];
@ -907,8 +907,8 @@ NSString *NSStringForOutgoingMessageRecipientState(OWSOutgoingMessageRecipientSt
for (OWSAttachmentInfo *attachment in quotedMessage.quotedAttachments) {
hasQuotedAttachment = YES;
OWSSignalServiceProtosDataMessageQuoteQuotedAttachmentBuilder *quotedAttachmentBuilder =
[OWSSignalServiceProtosDataMessageQuoteQuotedAttachmentBuilder new];
SSKProtoDataMessageQuoteQuotedAttachmentBuilder *quotedAttachmentBuilder =
[SSKProtoDataMessageQuoteQuotedAttachmentBuilder new];
quotedAttachmentBuilder.contentType = attachment.contentType;
quotedAttachmentBuilder.fileName = attachment.sourceFilename;
@ -930,18 +930,18 @@ NSString *NSStringForOutgoingMessageRecipientState(OWSOutgoingMessageRecipientSt
}
// recipientId is nil when building "sent" sync messages for messages sent to groups.
- (OWSSignalServiceProtosDataMessage *)buildDataMessage:(NSString *_Nullable)recipientId
- (SSKProtoDataMessage *)buildDataMessage:(NSString *_Nullable)recipientId
{
OWSAssert(self.thread);
OWSSignalServiceProtosDataMessageBuilder *builder = [self dataMessageBuilder];
SSKProtoDataMessageBuilder *builder = [self dataMessageBuilder];
[builder addLocalProfileKeyIfNecessary:self.thread recipientId:recipientId];
return [builder build];
}
- (NSData *)buildPlainTextData:(SignalRecipient *)recipient
- (nullable NSData *)buildPlainTextData:(SignalRecipient *)recipient
{
OWSSignalServiceProtosContentBuilder *contentBuilder = [OWSSignalServiceProtosContentBuilder new];
SSKProtoContentBuilder *contentBuilder = [SSKProtoContentBuilder new];
contentBuilder.dataMessage = [self buildDataMessage:recipient.recipientId];
return [[contentBuilder build] data];
}

View File

@ -7,7 +7,7 @@
NS_ASSUME_NONNULL_BEGIN
@class OWSSignalServiceProtosDataMessage;
@class SSKProtoDataMessage;
@class TSAttachment;
@class TSAttachmentStream;
@class TSQuotedMessage;
@ -89,7 +89,7 @@ NS_ASSUME_NONNULL_BEGIN
quotedAttachmentsForSending:(NSArray<TSAttachment *> *)attachments;
+ (nullable instancetype)quotedMessageForDataMessage:(OWSSignalServiceProtosDataMessage *)dataMessage
+ (nullable instancetype)quotedMessageForDataMessage:(SSKProtoDataMessage *)dataMessage
thread:(TSThread *)thread
transaction:(YapDatabaseReadWriteTransaction *)transaction;

View File

@ -3,7 +3,6 @@
//
#import "TSQuotedMessage.h"
#import "OWSSignalServiceProtos.pb.h"
#import "TSAccountManager.h"
#import "TSAttachment.h"
#import "TSAttachmentPointer.h"
@ -12,6 +11,7 @@
#import "TSInteraction.h"
#import "TSOutgoingMessage.h"
#import "TSThread.h"
#import <SignalServiceKit/SignalServiceKit-Swift.h>
#import <YapDatabase/YapDatabaseTransaction.h>
NS_ASSUME_NONNULL_BEGIN
@ -103,7 +103,7 @@ NS_ASSUME_NONNULL_BEGIN
return self;
}
+ (TSQuotedMessage *_Nullable)quotedMessageForDataMessage:(OWSSignalServiceProtosDataMessage *)dataMessage
+ (TSQuotedMessage *_Nullable)quotedMessageForDataMessage:(SSKProtoDataMessage *)dataMessage
thread:(TSThread *)thread
transaction:(YapDatabaseReadWriteTransaction *)transaction
{
@ -113,7 +113,7 @@ NS_ASSUME_NONNULL_BEGIN
return nil;
}
OWSSignalServiceProtosDataMessageQuote *quoteProto = [dataMessage quote];
SSKProtoDataMessageQuote *quoteProto = [dataMessage quote];
if (![quoteProto hasId] || [quoteProto id] == 0) {
OWSFail(@"%@ quoted message missing id", self.logTag);
@ -137,7 +137,7 @@ NS_ASSUME_NONNULL_BEGIN
}
NSMutableArray<OWSAttachmentInfo *> *attachmentInfos = [NSMutableArray new];
for (OWSSignalServiceProtosDataMessageQuoteQuotedAttachment *quotedAttachment in quoteProto.attachments) {
for (SSKProtoDataMessageQuoteQuotedAttachment *quotedAttachment in quoteProto.attachments) {
hasAttachment = YES;
OWSAttachmentInfo *attachmentInfo = [[OWSAttachmentInfo alloc] initWithAttachmentId:nil
contentType:quotedAttachment.contentType
@ -166,7 +166,7 @@ NS_ASSUME_NONNULL_BEGIN
thread.uniqueId,
(unsigned long)timestamp);
OWSSignalServiceProtosAttachmentPointer *thumbnailAttachmentProto = quotedAttachment.thumbnail;
SSKProtoAttachmentPointer *thumbnailAttachmentProto = quotedAttachment.thumbnail;
TSAttachmentPointer *thumbnailPointer =
[TSAttachmentPointer attachmentPointerFromProto:thumbnailAttachmentProto];
[thumbnailPointer saveWithTransaction:transaction];

View File

@ -12,7 +12,6 @@
#import "OWSPrimaryStorage+SessionStore.h"
#import "OWSPrimaryStorage.h"
#import "OWSQueues.h"
#import "OWSSignalServiceProtos.pb.h"
#import "OWSStorage.h"
#import "TSDatabaseView.h"
#import "TSErrorMessage.h"

View File

@ -1,10 +1,10 @@
//
// Copyright (c) 2017 Open Whisper Systems. All rights reserved.
// Copyright (c) 2018 Open Whisper Systems. All rights reserved.
//
NS_ASSUME_NONNULL_BEGIN
@class OWSSignalServiceProtosCallMessageAnswer;
@class SSKProtoCallMessageAnswer;
/**
* Sent by the call recipient upon accepting a CallOffer
@ -16,7 +16,7 @@ NS_ASSUME_NONNULL_BEGIN
@property (nonatomic, readonly) UInt64 callId;
@property (nonatomic, readonly, copy) NSString *sessionDescription;
- (OWSSignalServiceProtosCallMessageAnswer *)asProtobuf;
- (nullable SSKProtoCallMessageAnswer *)asProtobuf;
@end

View File

@ -1,9 +1,9 @@
//
// Copyright (c) 2017 Open Whisper Systems. All rights reserved.
// Copyright (c) 2018 Open Whisper Systems. All rights reserved.
//
#import "OWSCallAnswerMessage.h"
#import "OWSSignalServiceProtos.pb.h"
#import <SignalServiceKit/SignalServiceKit-Swift.h>
NS_ASSUME_NONNULL_BEGIN
@ -22,14 +22,20 @@ NS_ASSUME_NONNULL_BEGIN
return self;
}
- (OWSSignalServiceProtosCallMessageAnswer *)asProtobuf
- (nullable SSKProtoCallMessageAnswer *)asProtobuf
{
OWSSignalServiceProtosCallMessageAnswerBuilder *builder = [OWSSignalServiceProtosCallMessageAnswerBuilder new];
SSKProtoCallMessageAnswerBuilder *builder = [SSKProtoCallMessageAnswerBuilder new];
builder.id = self.callId;
builder.sessionDescription = self.sessionDescription;
return [builder build];
NSError *error;
SSKProtoCallMessageAnswer *_Nullable result = [builder buildAndReturnError:&error];
if (error || !result) {
OWSFail(@"%@ could not build protobuf: %@", self.logTag, error);
return nil;
}
return result;
}
@end

View File

@ -1,12 +1,12 @@
//
// Copyright (c) 2017 Open Whisper Systems. All rights reserved.
// Copyright (c) 2018 Open Whisper Systems. All rights reserved.
//
#import "OWSOutgoingCallMessage.h"
NS_ASSUME_NONNULL_BEGIN
@class OWSSignalServiceProtosCallMessageBusy;
@class SSKProtoCallMessageBusy;
/**
* Sent by the call recipient after receiving a call offer when they are already in a call.
@ -17,7 +17,7 @@ NS_ASSUME_NONNULL_BEGIN
@property (nonatomic, readonly) UInt64 callId;
- (OWSSignalServiceProtosCallMessageBusy *)asProtobuf;
- (nullable SSKProtoCallMessageBusy *)asProtobuf;
@end

View File

@ -1,9 +1,9 @@
//
// Copyright (c) 2017 Open Whisper Systems. All rights reserved.
// Copyright (c) 2018 Open Whisper Systems. All rights reserved.
//
#import "OWSCallBusyMessage.h"
#import "OWSSignalServiceProtos.pb.h"
#import <SignalServiceKit/SignalServiceKit-Swift.h>
NS_ASSUME_NONNULL_BEGIN
@ -21,13 +21,19 @@ NS_ASSUME_NONNULL_BEGIN
return self;
}
- (OWSSignalServiceProtosCallMessageBusy *)asProtobuf
- (nullable SSKProtoCallMessageBusy *)asProtobuf
{
OWSSignalServiceProtosCallMessageBusyBuilder *builder = [OWSSignalServiceProtosCallMessageBusyBuilder new];
SSKProtoCallMessageBusyBuilder *builder = [SSKProtoCallMessageBusyBuilder new];
builder.id = self.callId;
return [builder build];
NSError *error;
SSKProtoCallMessageBusy *_Nullable result = [builder buildAndReturnError:&error];
if (error || !result) {
OWSFail(@"%@ could not build protobuf: %@", self.logTag, error);
return nil;
}
return result;
}
@end

View File

@ -1,12 +1,12 @@
//
// Copyright (c) 2017 Open Whisper Systems. All rights reserved.
// Copyright (c) 2018 Open Whisper Systems. All rights reserved.
//
#import "OWSOutgoingCallMessage.h"
NS_ASSUME_NONNULL_BEGIN
@class OWSSignalServiceProtosCallMessageHangup;
@class SSKProtoCallMessageHangup;
/**
* Sent by either party in a call to indicate the user intentionally ended the call.
@ -17,7 +17,7 @@ NS_ASSUME_NONNULL_BEGIN
@property (nonatomic, readonly) UInt64 callId;
- (OWSSignalServiceProtosCallMessageHangup *)asProtobuf;
- (nullable SSKProtoCallMessageHangup *)asProtobuf;
@end

View File

@ -1,8 +1,9 @@
// Created by Michael Kirk on 12/8/16.
// Copyright © 2016 Open Whisper Systems. All rights reserved.
//
// Copyright (c) 2018 Open Whisper Systems. All rights reserved.
//
#import "OWSCallHangupMessage.h"
#import "OWSSignalServiceProtos.pb.h"
#import <SignalServiceKit/SignalServiceKit-Swift.h>
NS_ASSUME_NONNULL_BEGIN
@ -20,13 +21,19 @@ NS_ASSUME_NONNULL_BEGIN
return self;
}
- (OWSSignalServiceProtosCallMessageHangup *)asProtobuf
- (nullable SSKProtoCallMessageHangup *)asProtobuf
{
OWSSignalServiceProtosCallMessageHangupBuilder *builder = [OWSSignalServiceProtosCallMessageHangupBuilder new];
SSKProtoCallMessageHangupBuilder *builder = [SSKProtoCallMessageHangupBuilder new];
builder.id = self.callId;
return [builder build];
NSError *error;
SSKProtoCallMessageHangup *_Nullable result = [builder buildAndReturnError:&error];
if (error || !result) {
OWSFail(@"%@ could not build protobuf: %@", self.logTag, error);
return nil;
}
return result;
}

View File

@ -1,10 +1,10 @@
//
// Copyright (c) 2017 Open Whisper Systems. All rights reserved.
// Copyright (c) 2018 Open Whisper Systems. All rights reserved.
//
NS_ASSUME_NONNULL_BEGIN
@class OWSSignalServiceProtosCallMessageIceUpdate;
@class SSKProtoCallMessageIceUpdate;
/**
* Sent by both parties out of band of the RTC calling channels, as part of setting up those channels. The messages
@ -23,7 +23,7 @@ NS_ASSUME_NONNULL_BEGIN
@property (nonatomic, readonly) SInt32 sdpMLineIndex;
@property (nullable, nonatomic, readonly, copy) NSString *sdpMid;
- (OWSSignalServiceProtosCallMessageIceUpdate *)asProtobuf;
- (nullable SSKProtoCallMessageIceUpdate *)asProtobuf;
@end

View File

@ -1,8 +1,9 @@
// Created by Michael Kirk on 12/6/16.
// Copyright © 2016 Open Whisper Systems. All rights reserved.
//
// Copyright (c) 2018 Open Whisper Systems. All rights reserved.
//
#import "OWSCallIceUpdateMessage.h"
#import "OWSSignalServiceProtos.pb.h"
#import <SignalServiceKit/SignalServiceKit-Swift.h>
@implementation OWSCallIceUpdateMessage
@ -24,17 +25,23 @@
return self;
}
- (OWSSignalServiceProtosCallMessageIceUpdate *)asProtobuf
- (nullable SSKProtoCallMessageIceUpdate *)asProtobuf
{
OWSSignalServiceProtosCallMessageIceUpdateBuilder *builder =
[OWSSignalServiceProtosCallMessageIceUpdateBuilder new];
SSKProtoCallMessageIceUpdateBuilder *builder =
[SSKProtoCallMessageIceUpdateBuilder new];
[builder setId:self.callId];
[builder setSdp:self.sdp];
[builder setSdpMlineIndex:self.sdpMLineIndex];
[builder setSdpMid:self.sdpMid];
return [builder build];
NSError *error;
SSKProtoCallMessageIceUpdate *_Nullable result = [builder buildAndReturnError:&error];
if (error || !result) {
OWSFail(@"%@ could not build protobuf: %@", self.logTag, error);
return nil;
}
return result;
}
@end

View File

@ -1,10 +1,10 @@
//
// Copyright (c) 2017 Open Whisper Systems. All rights reserved.
// Copyright (c) 2018 Open Whisper Systems. All rights reserved.
//
NS_ASSUME_NONNULL_BEGIN
@class OWSSignalServiceProtosCallMessageOffer;
@class SSKProtoCallMessageOffer;
/**
* Sent by the call initiator to Signal their intention to set up a call with the recipient.
@ -16,7 +16,7 @@ NS_ASSUME_NONNULL_BEGIN
@property (nonatomic, readonly) UInt64 callId;
@property (nonatomic, readonly, copy) NSString *sessionDescription;
- (OWSSignalServiceProtosCallMessageOffer *)asProtobuf;
- (nullable SSKProtoCallMessageOffer *)asProtobuf;
@end

View File

@ -1,9 +1,9 @@
//
// Copyright (c) 2017 Open Whisper Systems. All rights reserved.
// Copyright (c) 2018 Open Whisper Systems. All rights reserved.
//
#import "OWSCallOfferMessage.h"
#import "OWSSignalServiceProtos.pb.h"
#import <SignalServiceKit/SignalServiceKit-Swift.h>
NS_ASSUME_NONNULL_BEGIN
@ -22,14 +22,20 @@ NS_ASSUME_NONNULL_BEGIN
return self;
}
- (OWSSignalServiceProtosCallMessageOffer *)asProtobuf
- (nullable SSKProtoCallMessageOffer *)asProtobuf
{
OWSSignalServiceProtosCallMessageOfferBuilder *builder = [OWSSignalServiceProtosCallMessageOfferBuilder new];
SSKProtoCallMessageOfferBuilder *builder = [SSKProtoCallMessageOfferBuilder new];
builder.id = self.callId;
builder.sessionDescription = self.sessionDescription;
return [builder build];
NSError *error;
SSKProtoCallMessageOffer *_Nullable result = [builder buildAndReturnError:&error];
if (error || !result) {
OWSFail(@"%@ could not build protobuf: %@", self.logTag, error);
return nil;
}
return result;
}
@end

View File

@ -17,8 +17,8 @@ extern NSString *const kNSNotificationName_IdentityStateDidChange;
extern const NSUInteger kIdentityKeyLength;
@class OWSRecipientIdentity;
@class OWSSignalServiceProtosVerified;
@class OWSStorage;
@class SSKProtoVerified;
@class YapDatabaseReadWriteTransaction;
// This class can be safely accessed and used from any thread.
@ -60,7 +60,7 @@ extern const NSUInteger kIdentityKeyLength;
- (nullable OWSRecipientIdentity *)untrustedIdentityForSendingToRecipientId:(NSString *)recipientId;
// This method can be called from any thread.
- (void)processIncomingSyncMessage:(OWSSignalServiceProtosVerified *)verified
- (void)processIncomingSyncMessage:(SSKProtoVerified *)verified
transaction:(YapDatabaseReadWriteTransaction *)transaction;
- (BOOL)saveRemoteIdentity:(NSData *)identityKey recipientId:(NSString *)recipientId;

View File

@ -679,7 +679,7 @@ NSString *const kNSNotificationName_IdentityStateDidChange = @"kNSNotificationNa
[transaction removeObjectForKey:recipientId inCollection:OWSIdentityManager_QueuedVerificationStateSyncMessages];
}
- (void)processIncomingSyncMessage:(OWSSignalServiceProtosVerified *)verified
- (void)processIncomingSyncMessage:(SSKProtoVerified *)verified
transaction:(YapDatabaseReadWriteTransaction *)transaction
{
OWSAssert(verified);
@ -700,21 +700,21 @@ NSString *const kNSNotificationName_IdentityStateDidChange = @"kNSNotificationNa
NSData *identityKey = [rawIdentityKey removeKeyType];
switch (verified.state) {
case OWSSignalServiceProtosVerifiedStateDefault:
case SSKProtoVerifiedStateDefault:
[self tryToApplyVerificationStateFromSyncMessage:OWSVerificationStateDefault
recipientId:recipientId
identityKey:identityKey
overwriteOnConflict:NO
transaction:transaction];
break;
case OWSSignalServiceProtosVerifiedStateVerified:
case SSKProtoVerifiedStateVerified:
[self tryToApplyVerificationStateFromSyncMessage:OWSVerificationStateVerified
recipientId:recipientId
identityKey:identityKey
overwriteOnConflict:YES
transaction:transaction];
break;
case OWSSignalServiceProtosVerifiedStateUnverified:
case SSKProtoVerifiedStateUnverified:
OWSFail(@"Verification state sync message for recipientId: %@ has unexpected value: %@.",
recipientId,
OWSVerificationStateToString(OWSVerificationStateNoLongerVerified));

View File

@ -13,7 +13,6 @@
#import "OWSPrimaryStorage+SessionStore.h"
#import "OWSPrimaryStorage+SignedPreKeyStore.h"
#import "OWSPrimaryStorage.h"
#import "OWSSignalServiceProtos.pb.h"
#import "SignalRecipient.h"
#import "TSAccountManager.h"
#import "TSContactThread.h"

View File

@ -4,8 +4,8 @@
NS_ASSUME_NONNULL_BEGIN
@class OWSSignalServiceProtosContent;
@class OWSSignalServiceProtosDataMessage;
@class SSKProtoContent;
@class SSKProtoDataMessage;
@class SSKProtoEnvelope;
NSString *envelopeAddress(SSKProtoEnvelope *envelope);
@ -14,8 +14,8 @@ NSString *envelopeAddress(SSKProtoEnvelope *envelope);
- (NSString *)descriptionForEnvelopeType:(SSKProtoEnvelope *)envelope;
- (NSString *)descriptionForEnvelope:(SSKProtoEnvelope *)envelope;
- (NSString *)descriptionForContent:(OWSSignalServiceProtosContent *)content;
- (NSString *)descriptionForDataMessage:(OWSSignalServiceProtosDataMessage *)dataMessage;
- (NSString *)descriptionForContent:(SSKProtoContent *)content;
- (NSString *)descriptionForDataMessage:(SSKProtoDataMessage *)dataMessage;
@end

View File

@ -3,7 +3,6 @@
//
#import "OWSMessageHandler.h"
#import "OWSSignalServiceProtos.pb.h"
#import <SignalServiceKit/SignalServiceKit-Swift.h>
NS_ASSUME_NONNULL_BEGIN
@ -57,7 +56,7 @@ NSString *envelopeAddress(SSKProtoEnvelope *envelope)
* We don't want to just log `content.description` because we'd potentially log message bodies for dataMesssages and
* sync transcripts
*/
- (NSString *)descriptionForContent:(OWSSignalServiceProtosContent *)content
- (NSString *)descriptionForContent:(SSKProtoContent *)content
{
if (content.hasSyncMessage) {
return [NSString stringWithFormat:@"<SyncMessage: %@ />", [self descriptionForSyncMessage:content.syncMessage]];
@ -78,7 +77,7 @@ NSString *envelopeAddress(SSKProtoEnvelope *envelope)
}
}
- (NSString *)descriptionForCallMessage:(OWSSignalServiceProtosCallMessage *)callMessage
- (NSString *)descriptionForCallMessage:(SSKProtoCallMessage *)callMessage
{
NSString *messageType;
UInt64 callId;
@ -110,7 +109,7 @@ NSString *envelopeAddress(SSKProtoEnvelope *envelope)
/**
* We don't want to just log `dataMessage.description` because we'd potentially log message contents
*/
- (NSString *)descriptionForDataMessage:(OWSSignalServiceProtosDataMessage *)dataMessage
- (NSString *)descriptionForDataMessage:(SSKProtoDataMessage *)dataMessage
{
NSMutableString *description = [NSMutableString new];
@ -118,11 +117,11 @@ NSString *envelopeAddress(SSKProtoEnvelope *envelope)
[description appendString:@"(Group:YES) "];
}
if ((dataMessage.flags & OWSSignalServiceProtosDataMessageFlagsEndSession) != 0) {
if ((dataMessage.flags & SSKProtoDataMessageFlagsEndSession) != 0) {
[description appendString:@"EndSession"];
} else if ((dataMessage.flags & OWSSignalServiceProtosDataMessageFlagsExpirationTimerUpdate) != 0) {
} else if ((dataMessage.flags & SSKProtoDataMessageFlagsExpirationTimerUpdate) != 0) {
[description appendString:@"ExpirationTimerUpdate"];
} else if ((dataMessage.flags & OWSSignalServiceProtosDataMessageFlagsProfileKeyUpdate) != 0) {
} else if ((dataMessage.flags & SSKProtoDataMessageFlagsProfileKeyUpdate) != 0) {
[description appendString:@"ProfileKey"];
} else if (dataMessage.attachments.count > 0) {
[description appendString:@"MessageWithAttachment"];
@ -136,19 +135,19 @@ NSString *envelopeAddress(SSKProtoEnvelope *envelope)
/**
* We don't want to just log `syncMessage.description` because we'd potentially log message contents in sent transcripts
*/
- (NSString *)descriptionForSyncMessage:(OWSSignalServiceProtosSyncMessage *)syncMessage
- (NSString *)descriptionForSyncMessage:(SSKProtoSyncMessage *)syncMessage
{
NSMutableString *description = [NSMutableString new];
if (syncMessage.hasSent) {
[description appendString:@"SentTranscript"];
} else if (syncMessage.hasRequest) {
if (syncMessage.request.type == OWSSignalServiceProtosSyncMessageRequestTypeContacts) {
if (syncMessage.request.type == SSKProtoSyncMessageRequestTypeContacts) {
[description appendString:@"ContactRequest"];
} else if (syncMessage.request.type == OWSSignalServiceProtosSyncMessageRequestTypeGroups) {
} else if (syncMessage.request.type == SSKProtoSyncMessageRequestTypeGroups) {
[description appendString:@"GroupRequest"];
} else if (syncMessage.request.type == OWSSignalServiceProtosSyncMessageRequestTypeBlocked) {
} else if (syncMessage.request.type == SSKProtoSyncMessageRequestTypeBlocked) {
[description appendString:@"BlockedRequest"];
} else if (syncMessage.request.type == OWSSignalServiceProtosSyncMessageRequestTypeConfiguration) {
} else if (syncMessage.request.type == SSKProtoSyncMessageRequestTypeConfiguration) {
[description appendString:@"ConfigurationRequest"];
} else {
// Shouldn't happen

View File

@ -295,7 +295,7 @@ NS_ASSUME_NONNULL_BEGIN
}
if (envelope.content != nil) {
OWSSignalServiceProtosContent *content = [OWSSignalServiceProtosContent parseFromData:plaintextData];
SSKProtoContent *content = [SSKProtoContent parseFromData:plaintextData];
DDLogInfo(@"%@ handling content: <Content: %@>", self.logTag, [self descriptionForContent:content]);
if (content.hasSyncMessage) {
@ -314,8 +314,8 @@ NS_ASSUME_NONNULL_BEGIN
DDLogWarn(@"%@ Ignoring envelope. Content with no known payload", self.logTag);
}
} else if (envelope.legacyMessage != nil) { // DEPRECATED - Remove after all clients have been upgraded.
OWSSignalServiceProtosDataMessage *dataMessage =
[OWSSignalServiceProtosDataMessage parseFromData:plaintextData];
SSKProtoDataMessage *dataMessage =
[SSKProtoDataMessage parseFromData:plaintextData];
DDLogInfo(
@"%@ handling message: <DataMessage: %@ />", self.logTag, [self descriptionForDataMessage:dataMessage]);
@ -326,7 +326,7 @@ NS_ASSUME_NONNULL_BEGIN
}
- (void)handleIncomingEnvelope:(SSKProtoEnvelope *)envelope
withDataMessage:(OWSSignalServiceProtosDataMessage *)dataMessage
withDataMessage:(SSKProtoDataMessage *)dataMessage
transaction:(YapDatabaseReadWriteTransaction *)transaction
{
OWSAssert(envelope);
@ -363,9 +363,9 @@ NS_ASSUME_NONNULL_BEGIN
if (!groupThread) {
// Unknown group.
if (dataMessage.group.type == OWSSignalServiceProtosGroupContextTypeUpdate) {
if (dataMessage.group.type == SSKProtoGroupContextTypeUpdate) {
// Accept group updates for unknown groups.
} else if (dataMessage.group.type == OWSSignalServiceProtosGroupContextTypeDeliver) {
} else if (dataMessage.group.type == SSKProtoGroupContextTypeDeliver) {
[self sendGroupInfoRequest:dataMessage.group.id envelope:envelope transaction:transaction];
return;
} else {
@ -375,11 +375,11 @@ NS_ASSUME_NONNULL_BEGIN
}
}
if ((dataMessage.flags & OWSSignalServiceProtosDataMessageFlagsEndSession) != 0) {
if ((dataMessage.flags & SSKProtoDataMessageFlagsEndSession) != 0) {
[self handleEndSessionMessageWithEnvelope:envelope dataMessage:dataMessage transaction:transaction];
} else if ((dataMessage.flags & OWSSignalServiceProtosDataMessageFlagsExpirationTimerUpdate) != 0) {
} else if ((dataMessage.flags & SSKProtoDataMessageFlagsExpirationTimerUpdate) != 0) {
[self handleExpirationTimerUpdateMessageWithEnvelope:envelope dataMessage:dataMessage transaction:transaction];
} else if ((dataMessage.flags & OWSSignalServiceProtosDataMessageFlagsProfileKeyUpdate) != 0) {
} else if ((dataMessage.flags & SSKProtoDataMessageFlagsProfileKeyUpdate) != 0) {
[self handleProfileKeyMessageWithEnvelope:envelope dataMessage:dataMessage];
} else if (dataMessage.attachments.count > 0) {
[self handleReceivedMediaWithEnvelope:envelope dataMessage:dataMessage transaction:transaction];
@ -429,7 +429,7 @@ NS_ASSUME_NONNULL_BEGIN
}
- (void)handleIncomingEnvelope:(SSKProtoEnvelope *)envelope
withReceiptMessage:(OWSSignalServiceProtosReceiptMessage *)receiptMessage
withReceiptMessage:(SSKProtoReceiptMessage *)receiptMessage
transaction:(YapDatabaseReadWriteTransaction *)transaction
{
OWSAssert(envelope);
@ -444,14 +444,14 @@ NS_ASSUME_NONNULL_BEGIN
}
switch (receiptMessage.type) {
case OWSSignalServiceProtosReceiptMessageTypeDelivery:
case SSKProtoReceiptMessageTypeDelivery:
DDLogVerbose(@"%@ Processing receipt message with delivery receipts.", self.logTag);
[self processDeliveryReceiptsFromRecipientId:envelope.source
sentTimestamps:sentTimestamps
deliveryTimestamp:@(envelope.timestamp)
transaction:transaction];
return;
case OWSSignalServiceProtosReceiptMessageTypeRead:
case SSKProtoReceiptMessageTypeRead:
DDLogVerbose(@"%@ Processing receipt message with read receipts.", self.logTag);
[OWSReadReceiptManager.sharedManager processReadReceiptsFromRecipientId:envelope.source
sentTimestamps:sentTimestamps
@ -464,7 +464,7 @@ NS_ASSUME_NONNULL_BEGIN
}
- (void)handleIncomingEnvelope:(SSKProtoEnvelope *)envelope
withCallMessage:(OWSSignalServiceProtosCallMessage *)callMessage
withCallMessage:(SSKProtoCallMessage *)callMessage
{
OWSAssert(envelope);
OWSAssert(callMessage);
@ -484,7 +484,7 @@ NS_ASSUME_NONNULL_BEGIN
} else if (callMessage.hasAnswer) {
[self.callMessageHandler receivedAnswer:callMessage.answer fromCallerId:envelope.source];
} else if (callMessage.iceUpdate.count > 0) {
for (OWSSignalServiceProtosCallMessageIceUpdate *iceUpdate in callMessage.iceUpdate) {
for (SSKProtoCallMessageIceUpdate *iceUpdate in callMessage.iceUpdate) {
[self.callMessageHandler receivedIceUpdate:iceUpdate fromCallerId:envelope.source];
}
} else if (callMessage.hasHangup) {
@ -499,7 +499,7 @@ NS_ASSUME_NONNULL_BEGIN
}
- (void)handleReceivedGroupAvatarUpdateWithEnvelope:(SSKProtoEnvelope *)envelope
dataMessage:(OWSSignalServiceProtosDataMessage *)dataMessage
dataMessage:(SSKProtoDataMessage *)dataMessage
transaction:(YapDatabaseReadWriteTransaction *)transaction
{
OWSAssert(envelope);
@ -537,7 +537,7 @@ NS_ASSUME_NONNULL_BEGIN
}
- (void)handleReceivedMediaWithEnvelope:(SSKProtoEnvelope *)envelope
dataMessage:(OWSSignalServiceProtosDataMessage *)dataMessage
dataMessage:(SSKProtoDataMessage *)dataMessage
transaction:(YapDatabaseReadWriteTransaction *)transaction
{
OWSAssert(envelope);
@ -585,7 +585,7 @@ NS_ASSUME_NONNULL_BEGIN
}
- (void)handleIncomingEnvelope:(SSKProtoEnvelope *)envelope
withSyncMessage:(OWSSignalServiceProtosSyncMessage *)syncMessage
withSyncMessage:(SSKProtoSyncMessage *)syncMessage
transaction:(YapDatabaseReadWriteTransaction *)transaction
{
OWSAssert(envelope);
@ -608,7 +608,7 @@ NS_ASSUME_NONNULL_BEGIN
OWSRecordTranscriptJob *recordJob =
[[OWSRecordTranscriptJob alloc] initWithIncomingSentMessageTranscript:transcript];
OWSSignalServiceProtosDataMessage *dataMessage = syncMessage.sent.message;
SSKProtoDataMessage *dataMessage = syncMessage.sent.message;
OWSAssert(dataMessage);
NSString *destination = syncMessage.sent.destination;
if (dataMessage && destination.length > 0 && dataMessage.hasProfileKey) {
@ -642,7 +642,7 @@ NS_ASSUME_NONNULL_BEGIN
transaction:transaction];
}
} else if (syncMessage.hasRequest) {
if (syncMessage.request.type == OWSSignalServiceProtosSyncMessageRequestTypeContacts) {
if (syncMessage.request.type == SSKProtoSyncMessageRequestTypeContacts) {
// We respond asynchronously because populating the sync message will
// create transactions and it's not practical (due to locking in the OWSIdentityManager)
// to plumb our transaction through.
@ -668,7 +668,7 @@ NS_ASSUME_NONNULL_BEGIN
@"%@ Failed to send Contacts response syncMessage with error: %@", self.logTag, error);
}];
});
} else if (syncMessage.request.type == OWSSignalServiceProtosSyncMessageRequestTypeGroups) {
} else if (syncMessage.request.type == SSKProtoSyncMessageRequestTypeGroups) {
OWSSyncGroupsMessage *syncGroupsMessage = [[OWSSyncGroupsMessage alloc] init];
DataSource *dataSource = [DataSourceValue
dataSourceWithSyncMessageData:[syncGroupsMessage
@ -682,10 +682,10 @@ NS_ASSUME_NONNULL_BEGIN
failure:^(NSError *error) {
DDLogError(@"%@ Failed to send Groups response syncMessage with error: %@", self.logTag, error);
}];
} else if (syncMessage.request.type == OWSSignalServiceProtosSyncMessageRequestTypeBlocked) {
} else if (syncMessage.request.type == SSKProtoSyncMessageRequestTypeBlocked) {
DDLogInfo(@"%@ Received request for block list", self.logTag);
[_blockingManager syncBlockedPhoneNumbers];
} else if (syncMessage.request.type == OWSSignalServiceProtosSyncMessageRequestTypeConfiguration) {
} else if (syncMessage.request.type == SSKProtoSyncMessageRequestTypeConfiguration) {
BOOL areReadReceiptsEnabled =
[[OWSReadReceiptManager sharedManager] areReadReceiptsEnabledWithTransaction:transaction];
OWSSyncConfigurationMessage *syncConfigurationMessage =
@ -720,7 +720,7 @@ NS_ASSUME_NONNULL_BEGIN
}
- (void)handleEndSessionMessageWithEnvelope:(SSKProtoEnvelope *)envelope
dataMessage:(OWSSignalServiceProtosDataMessage *)dataMessage
dataMessage:(SSKProtoDataMessage *)dataMessage
transaction:(YapDatabaseReadWriteTransaction *)transaction
{
OWSAssert(envelope);
@ -737,7 +737,7 @@ NS_ASSUME_NONNULL_BEGIN
}
- (void)handleExpirationTimerUpdateMessageWithEnvelope:(SSKProtoEnvelope *)envelope
dataMessage:(OWSSignalServiceProtosDataMessage *)dataMessage
dataMessage:(SSKProtoDataMessage *)dataMessage
transaction:(YapDatabaseReadWriteTransaction *)transaction
{
OWSAssert(envelope);
@ -780,7 +780,7 @@ NS_ASSUME_NONNULL_BEGIN
}
- (void)handleProfileKeyMessageWithEnvelope:(SSKProtoEnvelope *)envelope
dataMessage:(OWSSignalServiceProtosDataMessage *)dataMessage
dataMessage:(SSKProtoDataMessage *)dataMessage
{
OWSAssert(envelope);
OWSAssert(dataMessage);
@ -805,7 +805,7 @@ NS_ASSUME_NONNULL_BEGIN
}
- (void)handleReceivedTextMessageWithEnvelope:(SSKProtoEnvelope *)envelope
dataMessage:(OWSSignalServiceProtosDataMessage *)dataMessage
dataMessage:(SSKProtoDataMessage *)dataMessage
transaction:(YapDatabaseReadWriteTransaction *)transaction
{
OWSAssert(envelope);
@ -845,13 +845,13 @@ NS_ASSUME_NONNULL_BEGIN
}
- (void)handleGroupInfoRequest:(SSKProtoEnvelope *)envelope
dataMessage:(OWSSignalServiceProtosDataMessage *)dataMessage
dataMessage:(SSKProtoDataMessage *)dataMessage
transaction:(YapDatabaseReadWriteTransaction *)transaction
{
OWSAssert(envelope);
OWSAssert(dataMessage);
OWSAssert(transaction);
OWSAssert(dataMessage.group.type == OWSSignalServiceProtosGroupContextTypeRequestInfo);
OWSAssert(dataMessage.group.type == SSKProtoGroupContextTypeRequestInfo);
NSData *groupId = dataMessage.hasGroup ? dataMessage.group.id : nil;
if (!groupId) {
@ -901,7 +901,7 @@ NS_ASSUME_NONNULL_BEGIN
}
- (TSIncomingMessage *_Nullable)handleReceivedEnvelope:(SSKProtoEnvelope *)envelope
withDataMessage:(OWSSignalServiceProtosDataMessage *)dataMessage
withDataMessage:(SSKProtoDataMessage *)dataMessage
attachmentIds:(NSArray<NSString *> *)attachmentIds
transaction:(YapDatabaseReadWriteTransaction *)transaction
{
@ -914,7 +914,7 @@ NS_ASSUME_NONNULL_BEGIN
NSData *groupId = dataMessage.hasGroup ? dataMessage.group.id : nil;
OWSContact *_Nullable contact = [OWSContacts contactForDataMessage:dataMessage transaction:transaction];
if (dataMessage.group.type == OWSSignalServiceProtosGroupContextTypeRequestInfo) {
if (dataMessage.group.type == SSKProtoGroupContextTypeRequestInfo) {
[self handleGroupInfoRequest:envelope dataMessage:dataMessage transaction:transaction];
return nil;
}
@ -943,7 +943,7 @@ NS_ASSUME_NONNULL_BEGIN
}
switch (dataMessage.group.type) {
case OWSSignalServiceProtosGroupContextTypeUpdate: {
case SSKProtoGroupContextTypeUpdate: {
// Ensures that the thread exists but doesn't update it.
TSGroupThread *newGroupThread =
[TSGroupThread getOrCreateThreadWithGroupId:groupId transaction:transaction];
@ -976,7 +976,7 @@ NS_ASSUME_NONNULL_BEGIN
return nil;
}
case OWSSignalServiceProtosGroupContextTypeQuit: {
case SSKProtoGroupContextTypeQuit: {
if (!oldGroupThread) {
DDLogInfo(@"%@ ignoring quit group message from unknown group.", self.logTag);
return nil;
@ -994,7 +994,7 @@ NS_ASSUME_NONNULL_BEGIN
customMessage:updateGroupInfo] saveWithTransaction:transaction];
return nil;
}
case OWSSignalServiceProtosGroupContextTypeDeliver: {
case SSKProtoGroupContextTypeDeliver: {
if (!oldGroupThread) {
OWSFail(@"%@ ignoring deliver group message from unknown group.", self.logTag);
return nil;
@ -1191,9 +1191,9 @@ NS_ASSUME_NONNULL_BEGIN
#pragma mark - helpers
- (BOOL)isDataMessageGroupAvatarUpdate:(OWSSignalServiceProtosDataMessage *)dataMessage
- (BOOL)isDataMessageGroupAvatarUpdate:(SSKProtoDataMessage *)dataMessage
{
return dataMessage.hasGroup && dataMessage.group.type == OWSSignalServiceProtosGroupContextTypeUpdate
return dataMessage.hasGroup && dataMessage.group.type == SSKProtoGroupContextTypeUpdate
&& dataMessage.group.hasAvatar;
}
@ -1203,7 +1203,7 @@ NS_ASSUME_NONNULL_BEGIN
* but never creating a new group thread.
*/
- (nullable TSThread *)threadForEnvelope:(SSKProtoEnvelope *)envelope
dataMessage:(OWSSignalServiceProtosDataMessage *)dataMessage
dataMessage:(SSKProtoDataMessage *)dataMessage
transaction:(YapDatabaseReadWriteTransaction *)transaction
{
OWSAssert(envelope);

View File

@ -12,7 +12,6 @@
#import "OWSMessageDecrypter.h"
#import "OWSPrimaryStorage.h"
#import "OWSQueues.h"
#import "OWSSignalServiceProtos.pb.h"
#import "OWSStorage.h"
#import "TSDatabaseView.h"
#import "TSErrorMessage.h"

View File

@ -1242,7 +1242,10 @@ NSString *const OWSMessageSenderRateLimitedException = @"RateLimitedException";
NSMutableArray *messagesArray = [NSMutableArray arrayWithCapacity:recipient.devices.count];
NSData *plainText = [message buildPlainTextData:recipient];
NSData *_Nullable plainText = [message buildPlainTextData:recipient];
if (!plainText) {
OWSRaiseException(InvalidMessageException, @"Failed to build message proto");
}
DDLogDebug(@"%@ built message: %@ plainTextData.length: %lu",
self.logTag,
[message class],

View File

@ -9,10 +9,10 @@
#import "OWSCallHangupMessage.h"
#import "OWSCallIceUpdateMessage.h"
#import "OWSCallOfferMessage.h"
#import "OWSSignalServiceProtos.pb.h"
#import "ProtoBuf+OWS.h"
#import "SignalRecipient.h"
#import "TSContactThread.h"
#import <SignalServiceKit/SignalServiceKit-Swift.h>
NS_ASSUME_NONNULL_BEGIN
@ -126,28 +126,30 @@ NS_ASSUME_NONNULL_BEGIN
return YES;
}
//
///**
// * override thread accessor in superclass, since this model is never saved.
// * TODO review
// */
//- (TSThread *)thread
//{
// return _thread;
//}
- (NSData *)buildPlainTextData:(SignalRecipient *)recipient
- (nullable NSData *)buildPlainTextData:(SignalRecipient *)recipient
{
OWSAssert(recipient);
OWSSignalServiceProtosContentBuilder *contentBuilder = [OWSSignalServiceProtosContentBuilder new];
[contentBuilder setCallMessage:[self buildCallMessage:recipient.recipientId]];
return [[contentBuilder build] data];
SSKProtoContentBuilder *builder = [SSKProtoContentBuilder new];
[builder setCallMessage:[self buildCallMessage:recipient.recipientId]];
NSError *error;
SSKProtoCallMessage *_Nullable result = [builder buildAndReturnError:&error];
if (error || !result) {
OWSFail(@"%@ could not build protobuf: %@", self.logTag, error);
return nil;
}
NSData *_Nullable data = [result serializedDataAndReturnError:&error];
if (error || !result) {
OWSFail(@"%@ could not build protobuf: %@", self.logTag, error);
return nil;
}
return data;
}
- (OWSSignalServiceProtosCallMessage *)buildCallMessage:(NSString *)recipientId
- (nullable SSKProtoCallMessage *)buildCallMessage:(NSString *)recipientId
{
OWSSignalServiceProtosCallMessageBuilder *builder = [OWSSignalServiceProtosCallMessageBuilder new];
SSKProtoCallMessageBuilder *builder = [SSKProtoCallMessageBuilder new];
if (self.offerMessage) {
[builder setOffer:[self.offerMessage asProtobuf]];
@ -172,8 +174,14 @@ NS_ASSUME_NONNULL_BEGIN
}
[builder addLocalProfileKeyIfNecessary:self.thread recipientId:recipientId];
return [builder build];
NSError *error;
SSKProtoCallMessage *_Nullable result = [builder buildAndReturnError:&error];
if (error || !result) {
OWSFail(@"%@ could not build protobuf: %@", self.logTag, error);
return nil;
}
return result;
}
#pragma mark - TSYapDatabaseObject overrides

View File

@ -5,9 +5,9 @@
#import "OWSOutgoingNullMessage.h"
#import "Cryptography.h"
#import "NSDate+OWS.h"
#import "OWSSignalServiceProtos.pb.h"
#import "OWSVerificationStateSyncMessage.h"
#import "TSContactThread.h"
#import <SignalServiceKit/SignalServiceKit-Swift.h>
NS_ASSUME_NONNULL_BEGIN
@ -45,10 +45,10 @@ NS_ASSUME_NONNULL_BEGIN
#pragma mark - override TSOutgoingMessage
- (NSData *)buildPlainTextData:(SignalRecipient *)recipient
- (nullable NSData *)buildPlainTextData:(SignalRecipient *)recipient
{
OWSSignalServiceProtosContentBuilder *contentBuilder = [OWSSignalServiceProtosContentBuilder new];
OWSSignalServiceProtosNullMessageBuilder *nullMessageBuilder = [OWSSignalServiceProtosNullMessageBuilder new];
SSKProtoContentBuilder *contentBuilder = [SSKProtoContentBuilder new];
SSKProtoNullMessageBuilder *nullMessageBuilder = [SSKProtoNullMessageBuilder new];
NSUInteger contentLength = self.verificationStateSyncMessage.unpaddedVerifiedLength;

View File

@ -3,10 +3,10 @@
//
#import "OWSProfileKeyMessage.h"
#import "OWSSignalServiceProtos.pb.h"
#import "ProfileManagerProtocol.h"
#import "ProtoBuf+OWS.h"
#import "TextSecureKitEnv.h"
#import <SignalServiceKit/SignalServiceKit-Swift.h>
NS_ASSUME_NONNULL_BEGIN
@ -41,14 +41,14 @@ NS_ASSUME_NONNULL_BEGIN
return NO;
}
- (OWSSignalServiceProtosDataMessage *)buildDataMessage:(NSString *_Nullable)recipientId
- (SSKProtoDataMessage *)buildDataMessage:(NSString *_Nullable)recipientId
{
OWSAssert(self.thread);
OWSSignalServiceProtosDataMessageBuilder *builder = [self dataMessageBuilder];
SSKProtoDataMessageBuilder *builder = [self dataMessageBuilder];
[builder setTimestamp:self.timestamp];
[builder addLocalProfileKey];
[builder setFlags:OWSSignalServiceProtosDataMessageFlagsProfileKeyUpdate];
[builder setFlags:SSKProtoDataMessageFlagsProfileKeyUpdate];
if (recipientId.length > 0) {
// Once we've shared our profile key with a user (perhaps due to being

View File

@ -4,7 +4,7 @@
NS_ASSUME_NONNULL_BEGIN
@class OWSSignalServiceProtosSyncMessageRead;
@class SSKProtoSyncMessageRead;
@class TSIncomingMessage;
@class TSOutgoingMessage;
@class TSThread;
@ -49,7 +49,7 @@ extern NSString *const kIncomingMessageMarkedAsReadNotification;
#pragma mark - Linked Device Read Receipts
- (void)processReadReceiptsFromLinkedDevice:(NSArray<OWSSignalServiceProtosSyncMessageRead *> *)readReceiptProtos
- (void)processReadReceiptsFromLinkedDevice:(NSArray<SSKProtoSyncMessageRead *> *)readReceiptProtos
readTimestamp:(uint64_t)readTimestamp
transaction:(YapDatabaseReadWriteTransaction *)transaction;

View File

@ -11,7 +11,6 @@
#import "OWSPrimaryStorage.h"
#import "OWSReadReceiptsForLinkedDevicesMessage.h"
#import "OWSReadReceiptsForSenderMessage.h"
#import "OWSSignalServiceProtos.pb.h"
#import "OWSStorage.h"
#import "OWSSyncConfigurationMessage.h"
#import "TSAccountManager.h"
@ -21,6 +20,7 @@
#import "TextSecureKitEnv.h"
#import "Threading.h"
#import "YapDatabaseConnection+OWS.h"
#import <SignalServiceKit/SignalServiceKit-Swift.h>
#import <YapDatabase/YapDatabase.h>
NS_ASSUME_NONNULL_BEGIN
@ -440,14 +440,14 @@ NSString *const OWSReadReceiptManagerAreReadReceiptsEnabled = @"areReadReceiptsE
[readReceipt removeWithTransaction:transaction];
}
- (void)processReadReceiptsFromLinkedDevice:(NSArray<OWSSignalServiceProtosSyncMessageRead *> *)readReceiptProtos
- (void)processReadReceiptsFromLinkedDevice:(NSArray<SSKProtoSyncMessageRead *> *)readReceiptProtos
readTimestamp:(uint64_t)readTimestamp
transaction:(YapDatabaseReadWriteTransaction *)transaction
{
OWSAssert(readReceiptProtos);
OWSAssert(transaction);
for (OWSSignalServiceProtosSyncMessageRead *readReceiptProto in readReceiptProtos) {
for (SSKProtoSyncMessageRead *readReceiptProto in readReceiptProtos) {
NSString *_Nullable senderId = readReceiptProto.sender;
uint64_t messageIdTimestamp = readReceiptProto.timestamp;

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -15,7 +15,6 @@
#import "OWSMessageReceiver.h"
#import "OWSPrimaryStorage.h"
#import "OWSSignalService.h"
#import "OWSSignalServiceProtos.pb.h"
#import "OWSWebsocketSecurityPolicy.h"
#import "TSAccountManager.h"
#import "TSConstants.h"

View File

@ -1,25 +1,26 @@
// Created by Michael Kirk on 12/4/16.
// Copyright © 2016 Open Whisper Systems. All rights reserved.
//
// Copyright (c) 2018 Open Whisper Systems. All rights reserved.
//
NS_ASSUME_NONNULL_BEGIN
@class OWSSignalServiceProtosCallMessageOffer;
@class OWSSignalServiceProtosCallMessageAnswer;
@class OWSSignalServiceProtosCallMessageIceUpdate;
@class OWSSignalServiceProtosCallMessageHangup;
@class OWSSignalServiceProtosCallMessageBusy;
@class SSKProtoCallMessageAnswer;
@class SSKProtoCallMessageBusy;
@class SSKProtoCallMessageHangup;
@class SSKProtoCallMessageIceUpdate;
@class SSKProtoCallMessageOffer;
@protocol OWSCallMessageHandler <NSObject>
- (void)receivedOffer:(OWSSignalServiceProtosCallMessageOffer *)offer
- (void)receivedOffer:(SSKProtoCallMessageOffer *)offer
fromCallerId:(NSString *)callerId NS_SWIFT_NAME(receivedOffer(_:from:));
- (void)receivedAnswer:(OWSSignalServiceProtosCallMessageAnswer *)answer
- (void)receivedAnswer:(SSKProtoCallMessageAnswer *)answer
fromCallerId:(NSString *)callerId NS_SWIFT_NAME(receivedAnswer(_:from:));
- (void)receivedIceUpdate:(OWSSignalServiceProtosCallMessageIceUpdate *)iceUpdate
- (void)receivedIceUpdate:(SSKProtoCallMessageIceUpdate *)iceUpdate
fromCallerId:(NSString *)callerId NS_SWIFT_NAME(receivedIceUpdate(_:from:));
- (void)receivedHangup:(OWSSignalServiceProtosCallMessageHangup *)hangup
- (void)receivedHangup:(SSKProtoCallMessageHangup *)hangup
fromCallerId:(NSString *)callerId NS_SWIFT_NAME(receivedHangup(_:from:));
- (void)receivedBusy:(OWSSignalServiceProtosCallMessageBusy *)busy
- (void)receivedBusy:(SSKProtoCallMessageBusy *)busy
fromCallerId:(NSString *)callerId NS_SWIFT_NAME(receivedBusy(_:from:));
@end

View File

@ -1,20 +1,20 @@
//
// Copyright (c) 2017 Open Whisper Systems. All rights reserved.
// Copyright (c) 2018 Open Whisper Systems. All rights reserved.
//
#import "OWSSignalServiceProtos.pb.h"
#import "SignalServiceKit-Swift.h"
NS_ASSUME_NONNULL_BEGIN
@class TSThread;
@interface PBGeneratedMessageBuilder (OWS)
@end
//@interface PBGeneratedMessageBuilder (OWS)
//
//@end
#pragma mark -
@interface OWSSignalServiceProtosDataMessageBuilder (OWS)
@interface SSKProtoDataMessageBuilder (OWS)
- (void)addLocalProfileKeyIfNecessary:(TSThread *)thread recipientId:(NSString *_Nullable)recipientId;
- (void)addLocalProfileKey;
@ -23,7 +23,7 @@ NS_ASSUME_NONNULL_BEGIN
#pragma mark -
@interface OWSSignalServiceProtosCallMessageBuilder (OWS)
@interface SSKProtoCallMessageBuilder (OWS)
- (void)addLocalProfileKeyIfNecessary:(TSThread *)thread recipientId:(NSString *)recipientId;

View File

@ -2,47 +2,47 @@
// Copyright (c) 2018 Open Whisper Systems. All rights reserved.
//
#import "ProtoBuf+OWS.h"
#import "Cryptography.h"
#import "ProfileManagerProtocol.h"
#import "ProtoBuf+OWS.h"
#import "TSThread.h"
#import "TextSecureKitEnv.h"
NS_ASSUME_NONNULL_BEGIN
@implementation PBGeneratedMessageBuilder (OWS)
- (BOOL)shouldMessageHaveLocalProfileKey:(TSThread *)thread recipientId:(NSString *_Nullable)recipientId
{
OWSAssert(thread);
id<ProfileManagerProtocol> profileManager = [TextSecureKitEnv sharedEnv].profileManager;
// For 1:1 threads, we want to include the profile key IFF the
// contact is in the whitelist.
//
// For Group threads, we want to include the profile key IFF the
// recipient OR the group is in the whitelist.
if (recipientId.length > 0 && [profileManager isUserInProfileWhitelist:recipientId]) {
return YES;
} else if ([profileManager isThreadInProfileWhitelist:thread]) {
return YES;
}
return NO;
}
- (OWSAES256Key *)localProfileKey
{
id<ProfileManagerProtocol> profileManager = [TextSecureKitEnv sharedEnv].profileManager;
return profileManager.localProfileKey;
}
@end
//@implementation PBGeneratedMessageBuilder (OWS)
//
//- (BOOL)shouldMessageHaveLocalProfileKey:(TSThread *)thread recipientId:(NSString *_Nullable)recipientId
//{
// OWSAssert(thread);
//
// id<ProfileManagerProtocol> profileManager = [TextSecureKitEnv sharedEnv].profileManager;
//
// // For 1:1 threads, we want to include the profile key IFF the
// // contact is in the whitelist.
// //
// // For Group threads, we want to include the profile key IFF the
// // recipient OR the group is in the whitelist.
// if (recipientId.length > 0 && [profileManager isUserInProfileWhitelist:recipientId]) {
// return YES;
// } else if ([profileManager isThreadInProfileWhitelist:thread]) {
// return YES;
// }
//
// return NO;
//}
//
//- (OWSAES256Key *)localProfileKey
//{
// id<ProfileManagerProtocol> profileManager = [TextSecureKitEnv sharedEnv].profileManager;
// return profileManager.localProfileKey;
//}
//
//@end
#pragma mark -
@implementation OWSSignalServiceProtosDataMessageBuilder (OWS)
@implementation SSKProtoDataMessageBuilder (OWS)
- (void)addLocalProfileKeyIfNecessary:(TSThread *)thread recipientId:(NSString *_Nullable)recipientId
{
@ -72,7 +72,7 @@ NS_ASSUME_NONNULL_BEGIN
#pragma mark -
@implementation OWSSignalServiceProtosCallMessageBuilder (OWS)
@implementation SSKProtoCallMessageBuilder (OWS)
- (void)addLocalProfileKeyIfNecessary:(TSThread *)thread recipientId:(NSString *)recipientId
{

View File

@ -2,7 +2,7 @@
// Copyright (c) 2018 Open Whisper Systems. All rights reserved.
//
#import "OWSSignalServiceProtos.pb.h"
#import "SignalServiceKit-Swift.h"
#import "TSYapDatabaseObject.h"
NS_ASSUME_NONNULL_BEGIN
@ -14,7 +14,7 @@ typedef NS_ENUM(NSUInteger, OWSVerificationState) {
};
NSString *OWSVerificationStateToString(OWSVerificationState verificationState);
OWSSignalServiceProtosVerifiedState OWSVerificationStateToProtoState(OWSVerificationState verificationState);
SSKProtoVerifiedState OWSVerificationStateToProtoState(OWSVerificationState verificationState);
@interface OWSRecipientIdentity : TSYapDatabaseObject

View File

@ -21,15 +21,15 @@ NSString *OWSVerificationStateToString(OWSVerificationState verificationState)
}
}
OWSSignalServiceProtosVerifiedState OWSVerificationStateToProtoState(OWSVerificationState verificationState)
SSKProtoVerifiedState OWSVerificationStateToProtoState(OWSVerificationState verificationState)
{
switch (verificationState) {
case OWSVerificationStateDefault:
return OWSSignalServiceProtosVerifiedStateDefault;
return SSKProtoVerifiedStateDefault;
case OWSVerificationStateVerified:
return OWSSignalServiceProtosVerifiedStateVerified;
return SSKProtoVerifiedStateVerified;
case OWSVerificationStateNoLongerVerified:
return OWSSignalServiceProtosVerifiedStateUnverified;
return SSKProtoVerifiedStateUnverified;
}
}