Modify read receipt photos to support sending read receipts to both linked devices and senders.

// FREEBIE
pull/1/head
Matthew Chen 8 years ago
parent 39a961e376
commit a7546aee63

@ -46,6 +46,7 @@ message ReceiptMessage {
optional Type type = 1; optional Type type = 1;
repeated uint64 timestamp = 2; repeated uint64 timestamp = 2;
optional bytes profileKey = 3;
} }
message CallMessage { message CallMessage {

@ -384,15 +384,20 @@ NSString *NSStringFromOWSSignalServiceProtosGroupContextType(OWSSignalServicePro
#define ReceiptMessage_type @"type" #define ReceiptMessage_type @"type"
#define ReceiptMessage_timestamp @"timestamp" #define ReceiptMessage_timestamp @"timestamp"
#define ReceiptMessage_profileKey @"profileKey"
@interface OWSSignalServiceProtosReceiptMessage : PBGeneratedMessage<GeneratedMessageProtocol> { @interface OWSSignalServiceProtosReceiptMessage : PBGeneratedMessage<GeneratedMessageProtocol> {
@private @private
BOOL hasProfileKey_:1;
BOOL hasType_:1; BOOL hasType_:1;
NSData* profileKey;
OWSSignalServiceProtosReceiptMessageType type; OWSSignalServiceProtosReceiptMessageType type;
PBAppendableArray * timestampArray; PBAppendableArray * timestampArray;
} }
- (BOOL) hasType; - (BOOL) hasType;
- (BOOL) hasProfileKey;
@property (readonly) OWSSignalServiceProtosReceiptMessageType type; @property (readonly) OWSSignalServiceProtosReceiptMessageType type;
@property (readonly, strong) PBArray * timestamp; @property (readonly, strong) PBArray * timestamp;
@property (readonly, strong) NSData* profileKey;
- (UInt64)timestampAtIndex:(NSUInteger)index; - (UInt64)timestampAtIndex:(NSUInteger)index;
+ (instancetype) defaultInstance; + (instancetype) defaultInstance;
@ -441,6 +446,11 @@ NSString *NSStringFromOWSSignalServiceProtosGroupContextType(OWSSignalServicePro
- (OWSSignalServiceProtosReceiptMessageBuilder *)setTimestampArray:(NSArray *)array; - (OWSSignalServiceProtosReceiptMessageBuilder *)setTimestampArray:(NSArray *)array;
- (OWSSignalServiceProtosReceiptMessageBuilder *)setTimestampValues:(const UInt64 *)values count:(NSUInteger)count; - (OWSSignalServiceProtosReceiptMessageBuilder *)setTimestampValues:(const UInt64 *)values count:(NSUInteger)count;
- (OWSSignalServiceProtosReceiptMessageBuilder *)clearTimestamp; - (OWSSignalServiceProtosReceiptMessageBuilder *)clearTimestamp;
- (BOOL) hasProfileKey;
- (NSData*) profileKey;
- (OWSSignalServiceProtosReceiptMessageBuilder*) setProfileKey:(NSData*) value;
- (OWSSignalServiceProtosReceiptMessageBuilder*) clearProfileKey;
@end @end
#define CallMessage_offer @"offer" #define CallMessage_offer @"offer"

@ -1080,6 +1080,7 @@ static OWSSignalServiceProtosContent* defaultOWSSignalServiceProtosContentInstan
@interface OWSSignalServiceProtosReceiptMessage () @interface OWSSignalServiceProtosReceiptMessage ()
@property OWSSignalServiceProtosReceiptMessageType type; @property OWSSignalServiceProtosReceiptMessageType type;
@property (strong) PBAppendableArray * timestampArray; @property (strong) PBAppendableArray * timestampArray;
@property (strong) NSData* profileKey;
@end @end
@implementation OWSSignalServiceProtosReceiptMessage @implementation OWSSignalServiceProtosReceiptMessage
@ -1093,9 +1094,17 @@ static OWSSignalServiceProtosContent* defaultOWSSignalServiceProtosContentInstan
@synthesize type; @synthesize type;
@synthesize timestampArray; @synthesize timestampArray;
@dynamic timestamp; @dynamic timestamp;
- (BOOL) hasProfileKey {
return !!hasProfileKey_;
}
- (void) setHasProfileKey:(BOOL) _value_ {
hasProfileKey_ = !!_value_;
}
@synthesize profileKey;
- (instancetype) init { - (instancetype) init {
if ((self = [super init])) { if ((self = [super init])) {
self.type = OWSSignalServiceProtosReceiptMessageTypeDelivery; self.type = OWSSignalServiceProtosReceiptMessageTypeDelivery;
self.profileKey = [NSData data];
} }
return self; return self;
} }
@ -1131,6 +1140,9 @@ static OWSSignalServiceProtosReceiptMessage* defaultOWSSignalServiceProtosReceip
[output writeUInt64:2 value:values[i]]; [output writeUInt64:2 value:values[i]];
} }
} }
if (self.hasProfileKey) {
[output writeData:3 value:self.profileKey];
}
[self.unknownFields writeToCodedOutputStream:output]; [self.unknownFields writeToCodedOutputStream:output];
} }
- (SInt32) serializedSize { - (SInt32) serializedSize {
@ -1153,6 +1165,9 @@ static OWSSignalServiceProtosReceiptMessage* defaultOWSSignalServiceProtosReceip
size_ += dataSize; size_ += dataSize;
size_ += (SInt32)(1 * count); size_ += (SInt32)(1 * count);
} }
if (self.hasProfileKey) {
size_ += computeDataSize(3, self.profileKey);
}
size_ += self.unknownFields.serializedSize; size_ += self.unknownFields.serializedSize;
memoizedSerializedSize = size_; memoizedSerializedSize = size_;
return size_; return size_;
@ -1194,6 +1209,9 @@ static OWSSignalServiceProtosReceiptMessage* defaultOWSSignalServiceProtosReceip
[self.timestampArray enumerateObjectsUsingBlock:^(id obj, NSUInteger idx, BOOL *stop) { [self.timestampArray enumerateObjectsUsingBlock:^(id obj, NSUInteger idx, BOOL *stop) {
[output appendFormat:@"%@%@: %@\n", indent, @"timestamp", obj]; [output appendFormat:@"%@%@: %@\n", indent, @"timestamp", obj];
}]; }];
if (self.hasProfileKey) {
[output appendFormat:@"%@%@: %@\n", indent, @"profileKey", self.profileKey];
}
[self.unknownFields writeDescriptionTo:output withIndent:indent]; [self.unknownFields writeDescriptionTo:output withIndent:indent];
} }
- (void) storeInDictionary:(NSMutableDictionary *)dictionary { - (void) storeInDictionary:(NSMutableDictionary *)dictionary {
@ -1206,6 +1224,9 @@ static OWSSignalServiceProtosReceiptMessage* defaultOWSSignalServiceProtosReceip
[timestampArrayArray addObject: @([self.timestampArray uint64AtIndex:i])]; [timestampArrayArray addObject: @([self.timestampArray uint64AtIndex:i])];
} }
[dictionary setObject: timestampArrayArray forKey: @"timestamp"]; [dictionary setObject: timestampArrayArray forKey: @"timestamp"];
if (self.hasProfileKey) {
[dictionary setObject: self.profileKey forKey: @"profileKey"];
}
[self.unknownFields storeInDictionary:dictionary]; [self.unknownFields storeInDictionary:dictionary];
} }
- (BOOL) isEqual:(id)other { - (BOOL) isEqual:(id)other {
@ -1220,6 +1241,8 @@ static OWSSignalServiceProtosReceiptMessage* defaultOWSSignalServiceProtosReceip
self.hasType == otherMessage.hasType && self.hasType == otherMessage.hasType &&
(!self.hasType || self.type == otherMessage.type) && (!self.hasType || self.type == otherMessage.type) &&
[self.timestampArray isEqualToArray:otherMessage.timestampArray] && [self.timestampArray isEqualToArray:otherMessage.timestampArray] &&
self.hasProfileKey == otherMessage.hasProfileKey &&
(!self.hasProfileKey || [self.profileKey isEqual:otherMessage.profileKey]) &&
(self.unknownFields == otherMessage.unknownFields || (self.unknownFields != nil && [self.unknownFields isEqual:otherMessage.unknownFields])); (self.unknownFields == otherMessage.unknownFields || (self.unknownFields != nil && [self.unknownFields isEqual:otherMessage.unknownFields]));
} }
- (NSUInteger) hash { - (NSUInteger) hash {
@ -1230,6 +1253,9 @@ static OWSSignalServiceProtosReceiptMessage* defaultOWSSignalServiceProtosReceip
[self.timestampArray enumerateObjectsUsingBlock:^(NSNumber *obj, NSUInteger idx, BOOL *stop) { [self.timestampArray enumerateObjectsUsingBlock:^(NSNumber *obj, NSUInteger idx, BOOL *stop) {
hashCode = hashCode * 31 + [obj longValue]; hashCode = hashCode * 31 + [obj longValue];
}]; }];
if (self.hasProfileKey) {
hashCode = hashCode * 31 + [self.profileKey hash];
}
hashCode = hashCode * 31 + [self.unknownFields hash]; hashCode = hashCode * 31 + [self.unknownFields hash];
return hashCode; return hashCode;
} }
@ -1303,6 +1329,9 @@ NSString *NSStringFromOWSSignalServiceProtosReceiptMessageType(OWSSignalServiceP
[resultReceiptMessage.timestampArray appendArray:other.timestampArray]; [resultReceiptMessage.timestampArray appendArray:other.timestampArray];
} }
} }
if (other.hasProfileKey) {
[self setProfileKey:other.profileKey];
}
[self mergeUnknownFields:other.unknownFields]; [self mergeUnknownFields:other.unknownFields];
return self; return self;
} }
@ -1337,6 +1366,10 @@ NSString *NSStringFromOWSSignalServiceProtosReceiptMessageType(OWSSignalServiceP
[self addTimestamp:[input readUInt64]]; [self addTimestamp:[input readUInt64]];
break; break;
} }
case 26: {
[self setProfileKey:[input readData]];
break;
}
} }
} }
} }
@ -1381,6 +1414,22 @@ NSString *NSStringFromOWSSignalServiceProtosReceiptMessageType(OWSSignalServiceP
resultReceiptMessage.timestampArray = nil; resultReceiptMessage.timestampArray = nil;
return self; return self;
} }
- (BOOL) hasProfileKey {
return resultReceiptMessage.hasProfileKey;
}
- (NSData*) profileKey {
return resultReceiptMessage.profileKey;
}
- (OWSSignalServiceProtosReceiptMessageBuilder*) setProfileKey:(NSData*) value {
resultReceiptMessage.hasProfileKey = YES;
resultReceiptMessage.profileKey = value;
return self;
}
- (OWSSignalServiceProtosReceiptMessageBuilder*) clearProfileKey {
resultReceiptMessage.hasProfileKey = NO;
resultReceiptMessage.profileKey = [NSData data];
return self;
}
@end @end
@interface OWSSignalServiceProtosCallMessage () @interface OWSSignalServiceProtosCallMessage ()

Loading…
Cancel
Save