diff --git a/SignalServiceKit/protobuf/Makefile b/SignalServiceKit/protobuf/Makefile index d7b4c47b7..af6fd13ce 100644 --- a/SignalServiceKit/protobuf/Makefile +++ b/SignalServiceKit/protobuf/Makefile @@ -2,8 +2,8 @@ PROTOC=protoc \ --plugin=/usr/local/bin/protoc-gen-objc \ - --proto_path="${HOME}/src/WhisperSystems/protobuf-objc/src/compiler/" \ - --proto_path="${HOME}/src/WhisperSystems/protobuf-objc/src/compiler/google/protobuf/" \ + --proto_path="${HOME}/src/signal/protobuf-objc/src/compiler/" \ + --proto_path="${HOME}/src/signal/protobuf-objc/src/compiler/google/protobuf/" \ --proto_path='./' all: signal_service_proto provisioning_protos fingerprint_protos diff --git a/SignalServiceKit/protobuf/OWSSignalServiceProtos.proto b/SignalServiceKit/protobuf/OWSSignalServiceProtos.proto index e4c935ac6..d7144fb54 100644 --- a/SignalServiceKit/protobuf/OWSSignalServiceProtos.proto +++ b/SignalServiceKit/protobuf/OWSSignalServiceProtos.proto @@ -87,12 +87,11 @@ message DataMessage { PROFILE_KEY_UPDATE = 4; } - message Quote - { - optional uint64 id = 1; - optional string author = 2; - optional string text = 3; - optional AttachmentPointer attachment = 4; + message Quote { + optional uint64 id = 1; + optional string author = 2; + optional string text = 3; + repeated AttachmentPointer attachments = 4; } optional string body = 1; @@ -102,7 +101,7 @@ message DataMessage { optional uint32 expireTimer = 5; optional bytes profileKey = 6; optional uint64 timestamp = 7; - optional Quote quote = 8; + optional Quote quote = 8; } message NullMessage { diff --git a/SignalServiceKit/src/Messages/Interactions/TSOutgoingMessage.m b/SignalServiceKit/src/Messages/Interactions/TSOutgoingMessage.m index 6119eef0c..67ed26ecf 100644 --- a/SignalServiceKit/src/Messages/Interactions/TSOutgoingMessage.m +++ b/SignalServiceKit/src/Messages/Interactions/TSOutgoingMessage.m @@ -473,7 +473,7 @@ NSString *const kTSOutgoingMessageSentRecipientAll = @"kTSOutgoingMessageSentRec [attachmentBuilder setFileName:self.quotedMessage.sourceFilename]; } [attachmentBuilder setContentType:self.quotedMessage.contentType]; - [quoteBuilder setAttachmentBuilder:attachmentBuilder]; + [quoteBuilder.attachments addObject:[attachmentBuilder build]]; hasQuotedAttachment = YES; } diff --git a/SignalServiceKit/src/Messages/OWSMessageManager.m b/SignalServiceKit/src/Messages/OWSMessageManager.m index 32ecf117f..ec172349d 100644 --- a/SignalServiceKit/src/Messages/OWSMessageManager.m +++ b/SignalServiceKit/src/Messages/OWSMessageManager.m @@ -1097,8 +1097,8 @@ NS_ASSUME_NONNULL_BEGIN NSData *_Nullable thumbnailData = nil; NSString *_Nullable contentType = nil; - if ([quoteProto hasAttachment]) { - OWSSignalServiceProtosAttachmentPointer *attachmentProto = [quoteProto attachment]; + if (quoteProto.attachments.count > 0) { + OWSSignalServiceProtosAttachmentPointer *attachmentProto = quoteProto.attachments.firstObject; if ([attachmentProto hasContentType] && attachmentProto.contentType.length > 0) { contentType = attachmentProto.contentType; diff --git a/SignalServiceKit/src/Messages/OWSSignalServiceProtos.pb.h b/SignalServiceKit/src/Messages/OWSSignalServiceProtos.pb.h index 1c4de7803..614ce741d 100644 --- a/SignalServiceKit/src/Messages/OWSSignalServiceProtos.pb.h +++ b/SignalServiceKit/src/Messages/OWSSignalServiceProtos.pb.h @@ -1,6 +1,4 @@ -// -// Copyright (c) 2018 Open Whisper Systems. All rights reserved. -// +// Generated by the protocol buffer compiler. DO NOT EDIT! #import @@ -105,6 +103,7 @@ @class PBUninterpretedOptionNamePart; @class PBUninterpretedOptionNamePartBuilder; + typedef NS_ENUM(SInt32, OWSSignalServiceProtosEnvelopeType) { OWSSignalServiceProtosEnvelopeTypeUnknown = 0, OWSSignalServiceProtosEnvelopeTypeCiphertext = 1, @@ -860,26 +859,25 @@ NSString *NSStringFromOWSSignalServiceProtosGroupContextType(OWSSignalServicePro #define Quote_id @"id" #define Quote_author @"author" #define Quote_text @"text" -#define Quote_attachment @"attachment" +#define Quote_attachments @"attachments" @interface OWSSignalServiceProtosDataMessageQuote : PBGeneratedMessage { @private BOOL hasId_ : 1; BOOL hasAuthor_ : 1; BOOL hasText_ : 1; - BOOL hasAttachment_ : 1; UInt64 id; NSString *author; NSString *text; - OWSSignalServiceProtosAttachmentPointer *attachment; + NSMutableArray *attachmentsArray; } - (BOOL)hasId; - (BOOL)hasAuthor; - (BOOL)hasText; -- (BOOL)hasAttachment; @property (readonly) UInt64 id; @property (readonly, strong) NSString *author; @property (readonly, strong) NSString *text; -@property (readonly, strong) OWSSignalServiceProtosAttachmentPointer *attachment; +@property (readonly, strong) NSArray *attachments; +- (OWSSignalServiceProtosAttachmentPointer *)attachmentsAtIndex:(NSUInteger)index; + (instancetype)defaultInstance; - (instancetype)defaultInstance; @@ -936,13 +934,12 @@ NSString *NSStringFromOWSSignalServiceProtosGroupContextType(OWSSignalServicePro - (OWSSignalServiceProtosDataMessageQuoteBuilder *)setText:(NSString *)value; - (OWSSignalServiceProtosDataMessageQuoteBuilder *)clearText; -- (BOOL)hasAttachment; -- (OWSSignalServiceProtosAttachmentPointer *)attachment; -- (OWSSignalServiceProtosDataMessageQuoteBuilder *)setAttachment:(OWSSignalServiceProtosAttachmentPointer *)value; -- (OWSSignalServiceProtosDataMessageQuoteBuilder *)setAttachmentBuilder: - (OWSSignalServiceProtosAttachmentPointerBuilder *)builderForValue; -- (OWSSignalServiceProtosDataMessageQuoteBuilder *)mergeAttachment:(OWSSignalServiceProtosAttachmentPointer *)value; -- (OWSSignalServiceProtosDataMessageQuoteBuilder *)clearAttachment; +- (NSMutableArray *)attachments; +- (OWSSignalServiceProtosAttachmentPointer *)attachmentsAtIndex:(NSUInteger)index; +- (OWSSignalServiceProtosDataMessageQuoteBuilder *)addAttachments:(OWSSignalServiceProtosAttachmentPointer *)value; +- (OWSSignalServiceProtosDataMessageQuoteBuilder *)setAttachmentsArray: + (NSArray *)array; +- (OWSSignalServiceProtosDataMessageQuoteBuilder *)clearAttachments; @end @interface OWSSignalServiceProtosDataMessageBuilder : PBGeneratedMessageBuilder { diff --git a/SignalServiceKit/src/Messages/OWSSignalServiceProtos.pb.m b/SignalServiceKit/src/Messages/OWSSignalServiceProtos.pb.m index c0bff0827..5c62fa6d3 100644 --- a/SignalServiceKit/src/Messages/OWSSignalServiceProtos.pb.m +++ b/SignalServiceKit/src/Messages/OWSSignalServiceProtos.pb.m @@ -1,9 +1,6 @@ -// -// Copyright (c) 2018 Open Whisper Systems. All rights reserved. -// +// Generated by the protocol buffer compiler. DO NOT EDIT! #import "OWSSignalServiceProtos.pb.h" - // @@protoc_insertion_point(imports) @implementation OWSSignalServiceProtosOwssignalServiceProtosRoot @@ -3255,7 +3252,7 @@ NSString *NSStringFromOWSSignalServiceProtosDataMessageFlags(OWSSignalServicePro @property UInt64 id; @property (strong) NSString *author; @property (strong) NSString *text; -@property (strong) OWSSignalServiceProtosAttachmentPointer *attachment; +@property (strong) NSMutableArray *attachmentsArray; @end @implementation OWSSignalServiceProtosDataMessageQuote @@ -3287,22 +3284,14 @@ NSString *NSStringFromOWSSignalServiceProtosDataMessageFlags(OWSSignalServicePro hasText_ = !!_value_; } @synthesize text; -- (BOOL)hasAttachment -{ - return !!hasAttachment_; -} -- (void)setHasAttachment:(BOOL)_value_ -{ - hasAttachment_ = !!_value_; -} -@synthesize attachment; +@synthesize attachmentsArray; +@dynamic attachments; - (instancetype)init { if ((self = [super init])) { self.id = 0L; self.author = @""; self.text = @""; - self.attachment = [OWSSignalServiceProtosAttachmentPointer defaultInstance]; } return self; } @@ -3321,6 +3310,14 @@ static OWSSignalServiceProtosDataMessageQuote *defaultOWSSignalServiceProtosData { return defaultOWSSignalServiceProtosDataMessageQuoteInstance; } +- (NSArray *)attachments +{ + return attachmentsArray; +} +- (OWSSignalServiceProtosAttachmentPointer *)attachmentsAtIndex:(NSUInteger)index +{ + return [attachmentsArray objectAtIndex:index]; +} - (BOOL)isInitialized { return YES; @@ -3336,9 +3333,10 @@ static OWSSignalServiceProtosDataMessageQuote *defaultOWSSignalServiceProtosData if (self.hasText) { [output writeString:3 value:self.text]; } - if (self.hasAttachment) { - [output writeMessage:4 value:self.attachment]; - } + [self.attachmentsArray + enumerateObjectsUsingBlock:^(OWSSignalServiceProtosAttachmentPointer *element, NSUInteger idx, BOOL *stop) { + [output writeMessage:4 value:element]; + }]; [self.unknownFields writeToCodedOutputStream:output]; } - (SInt32)serializedSize @@ -3358,9 +3356,10 @@ static OWSSignalServiceProtosDataMessageQuote *defaultOWSSignalServiceProtosData if (self.hasText) { size_ += computeStringSize(3, self.text); } - if (self.hasAttachment) { - size_ += computeMessageSize(4, self.attachment); - } + [self.attachmentsArray + enumerateObjectsUsingBlock:^(OWSSignalServiceProtosAttachmentPointer *element, NSUInteger idx, BOOL *stop) { + size_ += computeMessageSize(4, element); + }]; size_ += self.unknownFields.serializedSize; memoizedSerializedSize = size_; return size_; @@ -3429,11 +3428,12 @@ static OWSSignalServiceProtosDataMessageQuote *defaultOWSSignalServiceProtosData if (self.hasText) { [output appendFormat:@"%@%@: %@\n", indent, @"text", self.text]; } - if (self.hasAttachment) { - [output appendFormat:@"%@%@ {\n", indent, @"attachment"]; - [self.attachment writeDescriptionTo:output withIndent:[NSString stringWithFormat:@"%@ ", indent]]; - [output appendFormat:@"%@}\n", indent]; - } + [self.attachmentsArray + enumerateObjectsUsingBlock:^(OWSSignalServiceProtosAttachmentPointer *element, NSUInteger idx, BOOL *stop) { + [output appendFormat:@"%@%@ {\n", indent, @"attachments"]; + [element writeDescriptionTo:output withIndent:[NSString stringWithFormat:@"%@ ", indent]]; + [output appendFormat:@"%@}\n", indent]; + }]; [self.unknownFields writeDescriptionTo:output withIndent:indent]; } - (void)storeInDictionary:(NSMutableDictionary *)dictionary @@ -3447,10 +3447,10 @@ static OWSSignalServiceProtosDataMessageQuote *defaultOWSSignalServiceProtosData if (self.hasText) { [dictionary setObject:self.text forKey:@"text"]; } - if (self.hasAttachment) { - NSMutableDictionary *messageDictionary = [NSMutableDictionary dictionary]; - [self.attachment storeInDictionary:messageDictionary]; - [dictionary setObject:[NSDictionary dictionaryWithDictionary:messageDictionary] forKey:@"attachment"]; + for (OWSSignalServiceProtosAttachmentPointer *element in self.attachmentsArray) { + NSMutableDictionary *elementDictionary = [NSMutableDictionary dictionary]; + [element storeInDictionary:elementDictionary]; + [dictionary setObject:[NSDictionary dictionaryWithDictionary:elementDictionary] forKey:@"attachments"]; } [self.unknownFields storeInDictionary:dictionary]; } @@ -3465,9 +3465,8 @@ static OWSSignalServiceProtosDataMessageQuote *defaultOWSSignalServiceProtosData OWSSignalServiceProtosDataMessageQuote *otherMessage = other; return self.hasId == otherMessage.hasId && (!self.hasId || self.id == otherMessage.id) && self.hasAuthor == otherMessage.hasAuthor && (!self.hasAuthor || [self.author isEqual:otherMessage.author]) - && self.hasText == otherMessage.hasText && (!self.hasText || [self.text isEqual:otherMessage.text]) - && self.hasAttachment == otherMessage.hasAttachment - && (!self.hasAttachment || [self.attachment isEqual:otherMessage.attachment]) + && self.hasText == otherMessage.hasText && (!self.hasText || [self.text isEqual:otherMessage.text]) && + [self.attachmentsArray isEqualToArray:otherMessage.attachmentsArray] && (self.unknownFields == otherMessage.unknownFields || (self.unknownFields != nil && [self.unknownFields isEqual:otherMessage.unknownFields])); } @@ -3483,9 +3482,10 @@ static OWSSignalServiceProtosDataMessageQuote *defaultOWSSignalServiceProtosData if (self.hasText) { hashCode = hashCode * 31 + [self.text hash]; } - if (self.hasAttachment) { - hashCode = hashCode * 31 + [self.attachment hash]; - } + [self.attachmentsArray + enumerateObjectsUsingBlock:^(OWSSignalServiceProtosAttachmentPointer *element, NSUInteger idx, BOOL *stop) { + hashCode = hashCode * 31 + [element hash]; + }]; hashCode = hashCode * 31 + [self.unknownFields hash]; return hashCode; } @@ -3546,8 +3546,12 @@ static OWSSignalServiceProtosDataMessageQuote *defaultOWSSignalServiceProtosData if (other.hasText) { [self setText:other.text]; } - if (other.hasAttachment) { - [self mergeAttachment:other.attachment]; + if (other.attachmentsArray.count > 0) { + if (resultQuote.attachmentsArray == nil) { + resultQuote.attachmentsArray = [[NSMutableArray alloc] initWithArray:other.attachmentsArray]; + } else { + [resultQuote.attachmentsArray addObjectsFromArray:other.attachmentsArray]; + } } [self mergeUnknownFields:other.unknownFields]; return self; @@ -3591,11 +3595,8 @@ static OWSSignalServiceProtosDataMessageQuote *defaultOWSSignalServiceProtosData case 34: { OWSSignalServiceProtosAttachmentPointerBuilder *subBuilder = [OWSSignalServiceProtosAttachmentPointer builder]; - if (self.hasAttachment) { - [subBuilder mergeFrom:self.attachment]; - } [input readMessage:subBuilder extensionRegistry:extensionRegistry]; - [self setAttachment:[subBuilder buildPartial]]; + [self addAttachments:[subBuilder buildPartial]]; break; } } @@ -3661,41 +3662,31 @@ static OWSSignalServiceProtosDataMessageQuote *defaultOWSSignalServiceProtosData resultQuote.text = @""; return self; } -- (BOOL)hasAttachment +- (NSMutableArray *)attachments { - return resultQuote.hasAttachment; + return resultQuote.attachmentsArray; } -- (OWSSignalServiceProtosAttachmentPointer *)attachment +- (OWSSignalServiceProtosAttachmentPointer *)attachmentsAtIndex:(NSUInteger)index { - return resultQuote.attachment; + return [resultQuote attachmentsAtIndex:index]; } -- (OWSSignalServiceProtosDataMessageQuoteBuilder *)setAttachment:(OWSSignalServiceProtosAttachmentPointer *)value +- (OWSSignalServiceProtosDataMessageQuoteBuilder *)addAttachments:(OWSSignalServiceProtosAttachmentPointer *)value { - resultQuote.hasAttachment = YES; - resultQuote.attachment = value; + if (resultQuote.attachmentsArray == nil) { + resultQuote.attachmentsArray = [[NSMutableArray alloc] init]; + } + [resultQuote.attachmentsArray addObject:value]; return self; } -- (OWSSignalServiceProtosDataMessageQuoteBuilder *)setAttachmentBuilder: - (OWSSignalServiceProtosAttachmentPointerBuilder *)builderForValue -{ - return [self setAttachment:[builderForValue build]]; -} -- (OWSSignalServiceProtosDataMessageQuoteBuilder *)mergeAttachment:(OWSSignalServiceProtosAttachmentPointer *)value +- (OWSSignalServiceProtosDataMessageQuoteBuilder *)setAttachmentsArray: + (NSArray *)array { - if (resultQuote.hasAttachment - && resultQuote.attachment != [OWSSignalServiceProtosAttachmentPointer defaultInstance]) { - resultQuote.attachment = [[[OWSSignalServiceProtosAttachmentPointer builderWithPrototype:resultQuote.attachment] - mergeFrom:value] buildPartial]; - } else { - resultQuote.attachment = value; - } - resultQuote.hasAttachment = YES; + resultQuote.attachmentsArray = [[NSMutableArray alloc] initWithArray:array]; return self; } -- (OWSSignalServiceProtosDataMessageQuoteBuilder *)clearAttachment +- (OWSSignalServiceProtosDataMessageQuoteBuilder *)clearAttachments { - resultQuote.hasAttachment = NO; - resultQuote.attachment = [OWSSignalServiceProtosAttachmentPointer defaultInstance]; + resultQuote.attachmentsArray = nil; return self; } @end