From b2b70258f2da2c3b8a47a9558fdd8a56838d90d2 Mon Sep 17 00:00:00 2001 From: Michael Kirk Date: Wed, 11 Apr 2018 13:37:22 -0400 Subject: [PATCH] Make our protos backwards compatible with Signal-Android Android doesn't have a flags field (yet?). We should make sure our existing fields align with theirs. // FREEBIE --- .../protobuf/OWSSignalServiceProtos.proto | 4 +- .../src/Messages/OWSSignalServiceProtos.pb.h | 16 +-- .../src/Messages/OWSSignalServiceProtos.pb.m | 104 +++++++++--------- protobuf/Makefile | 4 +- 4 files changed, 64 insertions(+), 64 deletions(-) diff --git a/SignalServiceKit/protobuf/OWSSignalServiceProtos.proto b/SignalServiceKit/protobuf/OWSSignalServiceProtos.proto index 962d524e0..e19f11dd7 100644 --- a/SignalServiceKit/protobuf/OWSSignalServiceProtos.proto +++ b/SignalServiceKit/protobuf/OWSSignalServiceProtos.proto @@ -95,8 +95,8 @@ message DataMessage { optional string contentType = 1; optional string fileName = 2; - optional uint32 flags = 3; - optional AttachmentPointer thumbnail = 4; + optional AttachmentPointer thumbnail = 3; + optional uint32 flags = 4; } optional uint64 id = 1; diff --git a/SignalServiceKit/src/Messages/OWSSignalServiceProtos.pb.h b/SignalServiceKit/src/Messages/OWSSignalServiceProtos.pb.h index 8baec7b00..52d0094ce 100644 --- a/SignalServiceKit/src/Messages/OWSSignalServiceProtos.pb.h +++ b/SignalServiceKit/src/Messages/OWSSignalServiceProtos.pb.h @@ -908,8 +908,8 @@ NSString *NSStringFromOWSSignalServiceProtosGroupContextType(OWSSignalServicePro #define QuotedAttachment_contentType @"contentType" #define QuotedAttachment_fileName @"fileName" -#define QuotedAttachment_flags @"flags" #define QuotedAttachment_thumbnail @"thumbnail" +#define QuotedAttachment_flags @"flags" @interface OWSSignalServiceProtosDataMessageQuoteQuotedAttachment : PBGeneratedMessage { @private BOOL hasContentType_:1; @@ -923,12 +923,12 @@ NSString *NSStringFromOWSSignalServiceProtosGroupContextType(OWSSignalServicePro } - (BOOL) hasContentType; - (BOOL) hasFileName; -- (BOOL) hasFlags; - (BOOL) hasThumbnail; +- (BOOL) hasFlags; @property (readonly, strong) NSString* contentType; @property (readonly, strong) NSString* fileName; -@property (readonly) UInt32 flags; @property (readonly, strong) OWSSignalServiceProtosAttachmentPointer* thumbnail; +@property (readonly) UInt32 flags; + (instancetype) defaultInstance; - (instancetype) defaultInstance; @@ -975,17 +975,17 @@ NSString *NSStringFromOWSSignalServiceProtosGroupContextType(OWSSignalServicePro - (OWSSignalServiceProtosDataMessageQuoteQuotedAttachmentBuilder*) setFileName:(NSString*) value; - (OWSSignalServiceProtosDataMessageQuoteQuotedAttachmentBuilder*) clearFileName; -- (BOOL) hasFlags; -- (UInt32) flags; -- (OWSSignalServiceProtosDataMessageQuoteQuotedAttachmentBuilder*) setFlags:(UInt32) value; -- (OWSSignalServiceProtosDataMessageQuoteQuotedAttachmentBuilder*) clearFlags; - - (BOOL) hasThumbnail; - (OWSSignalServiceProtosAttachmentPointer*) thumbnail; - (OWSSignalServiceProtosDataMessageQuoteQuotedAttachmentBuilder*) setThumbnail:(OWSSignalServiceProtosAttachmentPointer*) value; - (OWSSignalServiceProtosDataMessageQuoteQuotedAttachmentBuilder*) setThumbnailBuilder:(OWSSignalServiceProtosAttachmentPointerBuilder*) builderForValue; - (OWSSignalServiceProtosDataMessageQuoteQuotedAttachmentBuilder*) mergeThumbnail:(OWSSignalServiceProtosAttachmentPointer*) value; - (OWSSignalServiceProtosDataMessageQuoteQuotedAttachmentBuilder*) clearThumbnail; + +- (BOOL) hasFlags; +- (UInt32) flags; +- (OWSSignalServiceProtosDataMessageQuoteQuotedAttachmentBuilder*) setFlags:(UInt32) value; +- (OWSSignalServiceProtosDataMessageQuoteQuotedAttachmentBuilder*) clearFlags; @end @interface OWSSignalServiceProtosDataMessageQuoteBuilder : PBGeneratedMessageBuilder { diff --git a/SignalServiceKit/src/Messages/OWSSignalServiceProtos.pb.m b/SignalServiceKit/src/Messages/OWSSignalServiceProtos.pb.m index b03a232e6..9d5b77f24 100644 --- a/SignalServiceKit/src/Messages/OWSSignalServiceProtos.pb.m +++ b/SignalServiceKit/src/Messages/OWSSignalServiceProtos.pb.m @@ -3456,8 +3456,8 @@ static OWSSignalServiceProtosDataMessageQuote* defaultOWSSignalServiceProtosData @interface OWSSignalServiceProtosDataMessageQuoteQuotedAttachment () @property (strong) NSString* contentType; @property (strong) NSString* fileName; -@property UInt32 flags; @property (strong) OWSSignalServiceProtosAttachmentPointer* thumbnail; +@property UInt32 flags; @end @implementation OWSSignalServiceProtosDataMessageQuoteQuotedAttachment @@ -3476,13 +3476,6 @@ static OWSSignalServiceProtosDataMessageQuote* defaultOWSSignalServiceProtosData hasFileName_ = !!_value_; } @synthesize fileName; -- (BOOL) hasFlags { - return !!hasFlags_; -} -- (void) setHasFlags:(BOOL) _value_ { - hasFlags_ = !!_value_; -} -@synthesize flags; - (BOOL) hasThumbnail { return !!hasThumbnail_; } @@ -3490,12 +3483,19 @@ static OWSSignalServiceProtosDataMessageQuote* defaultOWSSignalServiceProtosData hasThumbnail_ = !!_value_; } @synthesize thumbnail; +- (BOOL) hasFlags { + return !!hasFlags_; +} +- (void) setHasFlags:(BOOL) _value_ { + hasFlags_ = !!_value_; +} +@synthesize flags; - (instancetype) init { if ((self = [super init])) { self.contentType = @""; self.fileName = @""; - self.flags = 0; self.thumbnail = [OWSSignalServiceProtosAttachmentPointer defaultInstance]; + self.flags = 0; } return self; } @@ -3521,11 +3521,11 @@ static OWSSignalServiceProtosDataMessageQuoteQuotedAttachment* defaultOWSSignalS if (self.hasFileName) { [output writeString:2 value:self.fileName]; } - if (self.hasFlags) { - [output writeUInt32:3 value:self.flags]; - } if (self.hasThumbnail) { - [output writeMessage:4 value:self.thumbnail]; + [output writeMessage:3 value:self.thumbnail]; + } + if (self.hasFlags) { + [output writeUInt32:4 value:self.flags]; } [self.unknownFields writeToCodedOutputStream:output]; } @@ -3542,11 +3542,11 @@ static OWSSignalServiceProtosDataMessageQuoteQuotedAttachment* defaultOWSSignalS if (self.hasFileName) { size_ += computeStringSize(2, self.fileName); } - if (self.hasFlags) { - size_ += computeUInt32Size(3, self.flags); - } if (self.hasThumbnail) { - size_ += computeMessageSize(4, self.thumbnail); + size_ += computeMessageSize(3, self.thumbnail); + } + if (self.hasFlags) { + size_ += computeUInt32Size(4, self.flags); } size_ += self.unknownFields.serializedSize; memoizedSerializedSize = size_; @@ -3589,15 +3589,15 @@ static OWSSignalServiceProtosDataMessageQuoteQuotedAttachment* defaultOWSSignalS if (self.hasFileName) { [output appendFormat:@"%@%@: %@\n", indent, @"fileName", self.fileName]; } - if (self.hasFlags) { - [output appendFormat:@"%@%@: %@\n", indent, @"flags", [NSNumber numberWithInteger:self.flags]]; - } if (self.hasThumbnail) { [output appendFormat:@"%@%@ {\n", indent, @"thumbnail"]; [self.thumbnail writeDescriptionTo:output withIndent:[NSString stringWithFormat:@"%@ ", indent]]; [output appendFormat:@"%@}\n", indent]; } + if (self.hasFlags) { + [output appendFormat:@"%@%@: %@\n", indent, @"flags", [NSNumber numberWithInteger:self.flags]]; + } [self.unknownFields writeDescriptionTo:output withIndent:indent]; } - (void) storeInDictionary:(NSMutableDictionary *)dictionary { @@ -3607,14 +3607,14 @@ static OWSSignalServiceProtosDataMessageQuoteQuotedAttachment* defaultOWSSignalS if (self.hasFileName) { [dictionary setObject: self.fileName forKey: @"fileName"]; } - if (self.hasFlags) { - [dictionary setObject: [NSNumber numberWithInteger:self.flags] forKey: @"flags"]; - } if (self.hasThumbnail) { NSMutableDictionary *messageDictionary = [NSMutableDictionary dictionary]; [self.thumbnail storeInDictionary:messageDictionary]; [dictionary setObject:[NSDictionary dictionaryWithDictionary:messageDictionary] forKey:@"thumbnail"]; } + if (self.hasFlags) { + [dictionary setObject: [NSNumber numberWithInteger:self.flags] forKey: @"flags"]; + } [self.unknownFields storeInDictionary:dictionary]; } - (BOOL) isEqual:(id)other { @@ -3630,10 +3630,10 @@ static OWSSignalServiceProtosDataMessageQuoteQuotedAttachment* defaultOWSSignalS (!self.hasContentType || [self.contentType isEqual:otherMessage.contentType]) && self.hasFileName == otherMessage.hasFileName && (!self.hasFileName || [self.fileName isEqual:otherMessage.fileName]) && - self.hasFlags == otherMessage.hasFlags && - (!self.hasFlags || self.flags == otherMessage.flags) && self.hasThumbnail == otherMessage.hasThumbnail && (!self.hasThumbnail || [self.thumbnail isEqual:otherMessage.thumbnail]) && + self.hasFlags == otherMessage.hasFlags && + (!self.hasFlags || self.flags == otherMessage.flags) && (self.unknownFields == otherMessage.unknownFields || (self.unknownFields != nil && [self.unknownFields isEqual:otherMessage.unknownFields])); } - (NSUInteger) hash { @@ -3644,12 +3644,12 @@ static OWSSignalServiceProtosDataMessageQuoteQuotedAttachment* defaultOWSSignalS if (self.hasFileName) { hashCode = hashCode * 31 + [self.fileName hash]; } - if (self.hasFlags) { - hashCode = hashCode * 31 + [[NSNumber numberWithInteger:self.flags] hash]; - } if (self.hasThumbnail) { hashCode = hashCode * 31 + [self.thumbnail hash]; } + if (self.hasFlags) { + hashCode = hashCode * 31 + [[NSNumber numberWithInteger:self.flags] hash]; + } hashCode = hashCode * 31 + [self.unknownFields hash]; return hashCode; } @@ -3716,12 +3716,12 @@ NSString *NSStringFromOWSSignalServiceProtosDataMessageQuoteQuotedAttachmentFlag if (other.hasFileName) { [self setFileName:other.fileName]; } - if (other.hasFlags) { - [self setFlags:other.flags]; - } if (other.hasThumbnail) { [self mergeThumbnail:other.thumbnail]; } + if (other.hasFlags) { + [self setFlags:other.flags]; + } [self mergeUnknownFields:other.unknownFields]; return self; } @@ -3751,11 +3751,7 @@ NSString *NSStringFromOWSSignalServiceProtosDataMessageQuoteQuotedAttachmentFlag [self setFileName:[input readString]]; break; } - case 24: { - [self setFlags:[input readUInt32]]; - break; - } - case 34: { + case 26: { OWSSignalServiceProtosAttachmentPointerBuilder* subBuilder = [OWSSignalServiceProtosAttachmentPointer builder]; if (self.hasThumbnail) { [subBuilder mergeFrom:self.thumbnail]; @@ -3764,6 +3760,10 @@ NSString *NSStringFromOWSSignalServiceProtosDataMessageQuoteQuotedAttachmentFlag [self setThumbnail:[subBuilder buildPartial]]; break; } + case 32: { + [self setFlags:[input readUInt32]]; + break; + } } } } @@ -3799,22 +3799,6 @@ NSString *NSStringFromOWSSignalServiceProtosDataMessageQuoteQuotedAttachmentFlag resultQuotedAttachment.fileName = @""; return self; } -- (BOOL) hasFlags { - return resultQuotedAttachment.hasFlags; -} -- (UInt32) flags { - return resultQuotedAttachment.flags; -} -- (OWSSignalServiceProtosDataMessageQuoteQuotedAttachmentBuilder*) setFlags:(UInt32) value { - resultQuotedAttachment.hasFlags = YES; - resultQuotedAttachment.flags = value; - return self; -} -- (OWSSignalServiceProtosDataMessageQuoteQuotedAttachmentBuilder*) clearFlags { - resultQuotedAttachment.hasFlags = NO; - resultQuotedAttachment.flags = 0; - return self; -} - (BOOL) hasThumbnail { return resultQuotedAttachment.hasThumbnail; } @@ -3845,6 +3829,22 @@ NSString *NSStringFromOWSSignalServiceProtosDataMessageQuoteQuotedAttachmentFlag resultQuotedAttachment.thumbnail = [OWSSignalServiceProtosAttachmentPointer defaultInstance]; return self; } +- (BOOL) hasFlags { + return resultQuotedAttachment.hasFlags; +} +- (UInt32) flags { + return resultQuotedAttachment.flags; +} +- (OWSSignalServiceProtosDataMessageQuoteQuotedAttachmentBuilder*) setFlags:(UInt32) value { + resultQuotedAttachment.hasFlags = YES; + resultQuotedAttachment.flags = value; + return self; +} +- (OWSSignalServiceProtosDataMessageQuoteQuotedAttachmentBuilder*) clearFlags { + resultQuotedAttachment.hasFlags = NO; + resultQuotedAttachment.flags = 0; + return self; +} @end @interface OWSSignalServiceProtosDataMessageQuoteBuilder() diff --git a/protobuf/Makefile b/protobuf/Makefile index 6431433bd..539571080 100644 --- a/protobuf/Makefile +++ b/protobuf/Makefile @@ -3,8 +3,8 @@ PROTOC=protoc \ --plugin=/usr/local/bin/proto-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: webrtc_data_proto