Migrate to backup proto wrappers.

pull/1/head
Matthew Chen 7 years ago
parent eaf59b122d
commit f795ec352e

@ -7,7 +7,6 @@ shift-base:CodedInputStream.m
bool:WebSocketResources.pb.m
bool:WhisperTextProtocol.pb.m
bool:OWSWebRTCDataProtos.pb.m
bool:OWSSignaliOSProtos.pb.m
# YapDatabase
bool:YapDatabaseAutoViewTransaction.m

@ -79,7 +79,7 @@ NS_ASSUME_NONNULL_BEGIN
@property (nonatomic) NSMutableArray<OWSBackupExportItem *> *exportItems;
@property (nonatomic, nullable) OWSSignaliOSProtosBackupSnapshotBuilder *backupSnapshotBuilder;
@property (nonatomic, nullable) SignalIOSProtoBackupSnapshotBuilder *backupSnapshotBuilder;
@property (nonatomic) NSUInteger cachedItemCount;
@ -111,8 +111,7 @@ NS_ASSUME_NONNULL_BEGIN
// It isn't strictly necessary to capture the entity type (the importer doesn't
// use this state), but I think it'll be helpful to have around to future-proof
// this work, help with debugging issue, etc.
- (BOOL)writeObject:(TSYapDatabaseObject *)object
entityType:(OWSSignaliOSProtosBackupSnapshotBackupEntityType)entityType
- (BOOL)writeObject:(TSYapDatabaseObject *)object entityType:(SignalIOSProtoBackupSnapshotBackupEntityType)entityType
{
OWSAssert(object);
@ -123,15 +122,22 @@ NS_ASSUME_NONNULL_BEGIN
}
if (!self.backupSnapshotBuilder) {
self.backupSnapshotBuilder = [OWSSignaliOSProtosBackupSnapshotBuilder new];
self.backupSnapshotBuilder = [SignalIOSProtoBackupSnapshotBuilder new];
}
OWSSignaliOSProtosBackupSnapshotBackupEntityBuilder *entityBuilder =
[OWSSignaliOSProtosBackupSnapshotBackupEntityBuilder new];
SignalIOSProtoBackupSnapshotBackupEntityBuilder *entityBuilder =
[SignalIOSProtoBackupSnapshotBackupEntityBuilder new];
[entityBuilder setType:entityType];
[entityBuilder setEntityData:data];
[self.backupSnapshotBuilder addEntity:[entityBuilder build]];
NSError *error;
SignalIOSProtoBackupSnapshotBackupEntity *_Nullable entity = [entityBuilder buildAndReturnError:&error];
if (!entity || error) {
OWSProdLogAndFail(@"%@ couldn't build proto: %@", self.logTag, error);
return NO;
}
[self.backupSnapshotBuilder addEntity:entity];
self.cachedItemCount = self.cachedItemCount + 1;
self.totalItemCount = self.totalItemCount + 1;
@ -158,7 +164,13 @@ NS_ASSUME_NONNULL_BEGIN
// Try to release allocated buffers ASAP.
@autoreleasepool {
NSData *_Nullable uncompressedData = [self.backupSnapshotBuilder build].data;
NSError *error;
NSData *_Nullable uncompressedData = [self.backupSnapshotBuilder buildSerializedDataAndReturnError:&error];
if (!uncompressedData || error) {
OWSProdLogAndFail(@"%@ couldn't serialize proto: %@", self.logTag, error);
return NO;
}
NSUInteger uncompressedDataLength = uncompressedData.length;
self.backupSnapshotBuilder = nil;
self.cachedItemCount = 0;
@ -475,12 +487,12 @@ NS_ASSUME_NONNULL_BEGIN
NSString *,
Class,
EntityFilter _Nullable,
OWSSignaliOSProtosBackupSnapshotBackupEntityType);
SignalIOSProtoBackupSnapshotBackupEntityType);
ExportBlock exportEntities = ^(YapDatabaseReadTransaction *transaction,
NSString *collection,
Class expectedClass,
EntityFilter _Nullable filter,
OWSSignaliOSProtosBackupSnapshotBackupEntityType entityType) {
SignalIOSProtoBackupSnapshotBackupEntityType entityType) {
__block NSUInteger count = 0;
[transaction
enumerateKeysAndObjectsInCollection:collection
@ -518,7 +530,7 @@ NS_ASSUME_NONNULL_BEGIN
[TSThread collection],
[TSThread class],
nil,
OWSSignaliOSProtosBackupSnapshotBackupEntityTypeThread);
SignalIOSProtoBackupSnapshotBackupEntityTypeThread);
if (aborted) {
return;
}
@ -548,7 +560,7 @@ NS_ASSUME_NONNULL_BEGIN
return YES;
},
OWSSignaliOSProtosBackupSnapshotBackupEntityTypeAttachment);
SignalIOSProtoBackupSnapshotBackupEntityTypeAttachment);
if (aborted) {
return;
}
@ -572,7 +584,7 @@ NS_ASSUME_NONNULL_BEGIN
}
return YES;
},
OWSSignaliOSProtosBackupSnapshotBackupEntityTypeInteraction);
SignalIOSProtoBackupSnapshotBackupEntityTypeInteraction);
if (aborted) {
return;
}
@ -581,7 +593,7 @@ NS_ASSUME_NONNULL_BEGIN
[OWSDatabaseMigration collection],
[OWSDatabaseMigration class],
nil,
OWSSignaliOSProtosBackupSnapshotBackupEntityTypeMigration);
SignalIOSProtoBackupSnapshotBackupEntityTypeMigration);
}];
if (aborted || self.isComplete) {

@ -391,12 +391,21 @@ NSString *const kOWSBackup_ImportDatabaseKeySpec = @"kOWSBackup_ImportDatabaseKe
aborted = YES;
return completion(NO);
}
OWSSignaliOSProtosBackupSnapshot *_Nullable entities;
SignalIOSProtoBackupSnapshot *_Nullable entities;
@try {
entities = [OWSSignaliOSProtosBackupSnapshot parseFromData:uncompressedData];
NSError *error;
entities = [SignalIOSProtoBackupSnapshot parseData:uncompressedData error:&error];
if (!entities || error) {
DDLogError(@"%@ could not parse proto: %@.", self.logTag, error);
// Database-related errors are unrecoverable.
aborted = YES;
return completion(NO);
}
} @catch (NSException *exception) {
OWSProdLogAndFail(@"%@ Could not parse proto: %@", self.logTag, exception.debugDescription);
// TODO: Add analytics.
aborted = YES;
return completion(NO);
}
if (!entities || entities.entity.count < 1) {
DDLogError(@"%@ missing entities.", self.logTag);
@ -404,7 +413,7 @@ NSString *const kOWSBackup_ImportDatabaseKeySpec = @"kOWSBackup_ImportDatabaseKe
aborted = YES;
return completion(NO);
}
for (OWSSignaliOSProtosBackupSnapshotBackupEntity *entity in entities.entity) {
for (SignalIOSProtoBackupSnapshotBackupEntity *entity in entities.entity) {
NSData *_Nullable entityData = entity.entityData;
if (entityData.length < 1) {
DDLogError(@"%@ missing entity data.", self.logTag);

@ -1,186 +0,0 @@
// Generated by the protocol buffer compiler. DO NOT EDIT!
#import <ProtocolBuffers/ProtocolBuffers.h>
// @@protoc_insertion_point(imports)
@class OWSSignaliOSProtosBackupSnapshot;
@class OWSSignaliOSProtosBackupSnapshotBackupEntity;
@class OWSSignaliOSProtosBackupSnapshotBackupEntityBuilder;
@class OWSSignaliOSProtosBackupSnapshotBuilder;
@class ObjectiveCFileOptions;
@class ObjectiveCFileOptionsBuilder;
@class PBDescriptorProto;
@class PBDescriptorProtoBuilder;
@class PBDescriptorProtoExtensionRange;
@class PBDescriptorProtoExtensionRangeBuilder;
@class PBEnumDescriptorProto;
@class PBEnumDescriptorProtoBuilder;
@class PBEnumOptions;
@class PBEnumOptionsBuilder;
@class PBEnumValueDescriptorProto;
@class PBEnumValueDescriptorProtoBuilder;
@class PBEnumValueOptions;
@class PBEnumValueOptionsBuilder;
@class PBFieldDescriptorProto;
@class PBFieldDescriptorProtoBuilder;
@class PBFieldOptions;
@class PBFieldOptionsBuilder;
@class PBFileDescriptorProto;
@class PBFileDescriptorProtoBuilder;
@class PBFileDescriptorSet;
@class PBFileDescriptorSetBuilder;
@class PBFileOptions;
@class PBFileOptionsBuilder;
@class PBMessageOptions;
@class PBMessageOptionsBuilder;
@class PBMethodDescriptorProto;
@class PBMethodDescriptorProtoBuilder;
@class PBMethodOptions;
@class PBMethodOptionsBuilder;
@class PBOneofDescriptorProto;
@class PBOneofDescriptorProtoBuilder;
@class PBServiceDescriptorProto;
@class PBServiceDescriptorProtoBuilder;
@class PBServiceOptions;
@class PBServiceOptionsBuilder;
@class PBSourceCodeInfo;
@class PBSourceCodeInfoBuilder;
@class PBSourceCodeInfoLocation;
@class PBSourceCodeInfoLocationBuilder;
@class PBUninterpretedOption;
@class PBUninterpretedOptionBuilder;
@class PBUninterpretedOptionNamePart;
@class PBUninterpretedOptionNamePartBuilder;
typedef NS_ENUM(SInt32, OWSSignaliOSProtosBackupSnapshotBackupEntityType) {
OWSSignaliOSProtosBackupSnapshotBackupEntityTypeUnknown = 0,
OWSSignaliOSProtosBackupSnapshotBackupEntityTypeMigration = 1,
OWSSignaliOSProtosBackupSnapshotBackupEntityTypeThread = 2,
OWSSignaliOSProtosBackupSnapshotBackupEntityTypeInteraction = 3,
OWSSignaliOSProtosBackupSnapshotBackupEntityTypeAttachment = 4,
};
BOOL OWSSignaliOSProtosBackupSnapshotBackupEntityTypeIsValidValue(OWSSignaliOSProtosBackupSnapshotBackupEntityType value);
NSString *NSStringFromOWSSignaliOSProtosBackupSnapshotBackupEntityType(OWSSignaliOSProtosBackupSnapshotBackupEntityType value);
@interface OWSSignaliOSProtosOwssignaliOsprotosRoot : NSObject {
}
+ (PBExtensionRegistry*) extensionRegistry;
+ (void) registerAllExtensions:(PBMutableExtensionRegistry*) registry;
@end
#define BackupSnapshot_entity @"entity"
@interface OWSSignaliOSProtosBackupSnapshot : PBGeneratedMessage<GeneratedMessageProtocol> {
@private
NSMutableArray * entityArray;
}
@property (readonly, strong) NSArray<OWSSignaliOSProtosBackupSnapshotBackupEntity*> * entity;
- (OWSSignaliOSProtosBackupSnapshotBackupEntity*)entityAtIndex:(NSUInteger)index;
+ (instancetype) defaultInstance;
- (instancetype) defaultInstance;
- (BOOL) isInitialized;
- (void) writeToCodedOutputStream:(PBCodedOutputStream*) output;
- (OWSSignaliOSProtosBackupSnapshotBuilder*) builder;
+ (OWSSignaliOSProtosBackupSnapshotBuilder*) builder;
+ (OWSSignaliOSProtosBackupSnapshotBuilder*) builderWithPrototype:(OWSSignaliOSProtosBackupSnapshot*) prototype;
- (OWSSignaliOSProtosBackupSnapshotBuilder*) toBuilder;
+ (OWSSignaliOSProtosBackupSnapshot*) parseFromData:(NSData*) data;
+ (OWSSignaliOSProtosBackupSnapshot*) parseFromData:(NSData*) data extensionRegistry:(PBExtensionRegistry*) extensionRegistry;
+ (OWSSignaliOSProtosBackupSnapshot*) parseFromInputStream:(NSInputStream*) input;
+ (OWSSignaliOSProtosBackupSnapshot*) parseFromInputStream:(NSInputStream*) input extensionRegistry:(PBExtensionRegistry*) extensionRegistry;
+ (OWSSignaliOSProtosBackupSnapshot*) parseFromCodedInputStream:(PBCodedInputStream*) input;
+ (OWSSignaliOSProtosBackupSnapshot*) parseFromCodedInputStream:(PBCodedInputStream*) input extensionRegistry:(PBExtensionRegistry*) extensionRegistry;
@end
#define BackupEntity_type @"type"
#define BackupEntity_entityData @"entityData"
@interface OWSSignaliOSProtosBackupSnapshotBackupEntity : PBGeneratedMessage<GeneratedMessageProtocol> {
@private
BOOL hasEntityData_:1;
BOOL hasType_:1;
NSData* entityData;
OWSSignaliOSProtosBackupSnapshotBackupEntityType type;
}
- (BOOL) hasType;
- (BOOL) hasEntityData;
@property (readonly) OWSSignaliOSProtosBackupSnapshotBackupEntityType type;
@property (readonly, strong) NSData* entityData;
+ (instancetype) defaultInstance;
- (instancetype) defaultInstance;
- (BOOL) isInitialized;
- (void) writeToCodedOutputStream:(PBCodedOutputStream*) output;
- (OWSSignaliOSProtosBackupSnapshotBackupEntityBuilder*) builder;
+ (OWSSignaliOSProtosBackupSnapshotBackupEntityBuilder*) builder;
+ (OWSSignaliOSProtosBackupSnapshotBackupEntityBuilder*) builderWithPrototype:(OWSSignaliOSProtosBackupSnapshotBackupEntity*) prototype;
- (OWSSignaliOSProtosBackupSnapshotBackupEntityBuilder*) toBuilder;
+ (OWSSignaliOSProtosBackupSnapshotBackupEntity*) parseFromData:(NSData*) data;
+ (OWSSignaliOSProtosBackupSnapshotBackupEntity*) parseFromData:(NSData*) data extensionRegistry:(PBExtensionRegistry*) extensionRegistry;
+ (OWSSignaliOSProtosBackupSnapshotBackupEntity*) parseFromInputStream:(NSInputStream*) input;
+ (OWSSignaliOSProtosBackupSnapshotBackupEntity*) parseFromInputStream:(NSInputStream*) input extensionRegistry:(PBExtensionRegistry*) extensionRegistry;
+ (OWSSignaliOSProtosBackupSnapshotBackupEntity*) parseFromCodedInputStream:(PBCodedInputStream*) input;
+ (OWSSignaliOSProtosBackupSnapshotBackupEntity*) parseFromCodedInputStream:(PBCodedInputStream*) input extensionRegistry:(PBExtensionRegistry*) extensionRegistry;
@end
@interface OWSSignaliOSProtosBackupSnapshotBackupEntityBuilder : PBGeneratedMessageBuilder {
@private
OWSSignaliOSProtosBackupSnapshotBackupEntity* resultBackupEntity;
}
- (OWSSignaliOSProtosBackupSnapshotBackupEntity*) defaultInstance;
- (OWSSignaliOSProtosBackupSnapshotBackupEntityBuilder*) clear;
- (OWSSignaliOSProtosBackupSnapshotBackupEntityBuilder*) clone;
- (OWSSignaliOSProtosBackupSnapshotBackupEntity*) build;
- (OWSSignaliOSProtosBackupSnapshotBackupEntity*) buildPartial;
- (OWSSignaliOSProtosBackupSnapshotBackupEntityBuilder*) mergeFrom:(OWSSignaliOSProtosBackupSnapshotBackupEntity*) other;
- (OWSSignaliOSProtosBackupSnapshotBackupEntityBuilder*) mergeFromCodedInputStream:(PBCodedInputStream*) input;
- (OWSSignaliOSProtosBackupSnapshotBackupEntityBuilder*) mergeFromCodedInputStream:(PBCodedInputStream*) input extensionRegistry:(PBExtensionRegistry*) extensionRegistry;
- (BOOL) hasType;
- (OWSSignaliOSProtosBackupSnapshotBackupEntityType) type;
- (OWSSignaliOSProtosBackupSnapshotBackupEntityBuilder*) setType:(OWSSignaliOSProtosBackupSnapshotBackupEntityType) value;
- (OWSSignaliOSProtosBackupSnapshotBackupEntityBuilder*) clearType;
- (BOOL) hasEntityData;
- (NSData*) entityData;
- (OWSSignaliOSProtosBackupSnapshotBackupEntityBuilder*) setEntityData:(NSData*) value;
- (OWSSignaliOSProtosBackupSnapshotBackupEntityBuilder*) clearEntityData;
@end
@interface OWSSignaliOSProtosBackupSnapshotBuilder : PBGeneratedMessageBuilder {
@private
OWSSignaliOSProtosBackupSnapshot* resultBackupSnapshot;
}
- (OWSSignaliOSProtosBackupSnapshot*) defaultInstance;
- (OWSSignaliOSProtosBackupSnapshotBuilder*) clear;
- (OWSSignaliOSProtosBackupSnapshotBuilder*) clone;
- (OWSSignaliOSProtosBackupSnapshot*) build;
- (OWSSignaliOSProtosBackupSnapshot*) buildPartial;
- (OWSSignaliOSProtosBackupSnapshotBuilder*) mergeFrom:(OWSSignaliOSProtosBackupSnapshot*) other;
- (OWSSignaliOSProtosBackupSnapshotBuilder*) mergeFromCodedInputStream:(PBCodedInputStream*) input;
- (OWSSignaliOSProtosBackupSnapshotBuilder*) mergeFromCodedInputStream:(PBCodedInputStream*) input extensionRegistry:(PBExtensionRegistry*) extensionRegistry;
- (NSMutableArray<OWSSignaliOSProtosBackupSnapshotBackupEntity*> *)entity;
- (OWSSignaliOSProtosBackupSnapshotBackupEntity*)entityAtIndex:(NSUInteger)index;
- (OWSSignaliOSProtosBackupSnapshotBuilder *)addEntity:(OWSSignaliOSProtosBackupSnapshotBackupEntity*)value;
- (OWSSignaliOSProtosBackupSnapshotBuilder *)setEntityArray:(NSArray<OWSSignaliOSProtosBackupSnapshotBackupEntity*> *)array;
- (OWSSignaliOSProtosBackupSnapshotBuilder *)clearEntity;
@end
// @@protoc_insertion_point(global_scope)

@ -1,535 +0,0 @@
// Generated by the protocol buffer compiler. DO NOT EDIT!
#import "OWSSignaliOSProtos.pb.h"
// @@protoc_insertion_point(imports)
@implementation OWSSignaliOSProtosOwssignaliOsprotosRoot
static PBExtensionRegistry* extensionRegistry = nil;
+ (PBExtensionRegistry*) extensionRegistry {
return extensionRegistry;
}
+ (void) initialize {
if (self == [OWSSignaliOSProtosOwssignaliOsprotosRoot class]) {
PBMutableExtensionRegistry* registry = [PBMutableExtensionRegistry registry];
[self registerAllExtensions:registry];
[ObjectivecDescriptorRoot registerAllExtensions:registry];
extensionRegistry = registry;
}
}
+ (void) registerAllExtensions:(PBMutableExtensionRegistry*) registry {
}
@end
@interface OWSSignaliOSProtosBackupSnapshot ()
@property (strong) NSMutableArray<OWSSignaliOSProtosBackupSnapshotBackupEntity*> * entityArray;
@end
@implementation OWSSignaliOSProtosBackupSnapshot
@synthesize entityArray;
@dynamic entity;
- (instancetype) init {
if ((self = [super init])) {
}
return self;
}
static OWSSignaliOSProtosBackupSnapshot* defaultOWSSignaliOSProtosBackupSnapshotInstance = nil;
+ (void) initialize {
if (self == [OWSSignaliOSProtosBackupSnapshot class]) {
defaultOWSSignaliOSProtosBackupSnapshotInstance = [[OWSSignaliOSProtosBackupSnapshot alloc] init];
}
}
+ (instancetype) defaultInstance {
return defaultOWSSignaliOSProtosBackupSnapshotInstance;
}
- (instancetype) defaultInstance {
return defaultOWSSignaliOSProtosBackupSnapshotInstance;
}
- (NSArray<OWSSignaliOSProtosBackupSnapshotBackupEntity*> *)entity {
return entityArray;
}
- (OWSSignaliOSProtosBackupSnapshotBackupEntity*)entityAtIndex:(NSUInteger)index {
return [entityArray objectAtIndex:index];
}
- (BOOL) isInitialized {
return YES;
}
- (void) writeToCodedOutputStream:(PBCodedOutputStream*) output {
[self.entityArray enumerateObjectsUsingBlock:^(OWSSignaliOSProtosBackupSnapshotBackupEntity *element, NSUInteger idx, BOOL *stop) {
[output writeMessage:1 value:element];
}];
[self.unknownFields writeToCodedOutputStream:output];
}
- (SInt32) serializedSize {
__block SInt32 size_ = memoizedSerializedSize;
if (size_ != -1) {
return size_;
}
size_ = 0;
[self.entityArray enumerateObjectsUsingBlock:^(OWSSignaliOSProtosBackupSnapshotBackupEntity *element, NSUInteger idx, BOOL *stop) {
size_ += computeMessageSize(1, element);
}];
size_ += self.unknownFields.serializedSize;
memoizedSerializedSize = size_;
return size_;
}
+ (OWSSignaliOSProtosBackupSnapshot*) parseFromData:(NSData*) data {
return (OWSSignaliOSProtosBackupSnapshot*)[[[OWSSignaliOSProtosBackupSnapshot builder] mergeFromData:data] build];
}
+ (OWSSignaliOSProtosBackupSnapshot*) parseFromData:(NSData*) data extensionRegistry:(PBExtensionRegistry*) extensionRegistry {
return (OWSSignaliOSProtosBackupSnapshot*)[[[OWSSignaliOSProtosBackupSnapshot builder] mergeFromData:data extensionRegistry:extensionRegistry] build];
}
+ (OWSSignaliOSProtosBackupSnapshot*) parseFromInputStream:(NSInputStream*) input {
return (OWSSignaliOSProtosBackupSnapshot*)[[[OWSSignaliOSProtosBackupSnapshot builder] mergeFromInputStream:input] build];
}
+ (OWSSignaliOSProtosBackupSnapshot*) parseFromInputStream:(NSInputStream*) input extensionRegistry:(PBExtensionRegistry*) extensionRegistry {
return (OWSSignaliOSProtosBackupSnapshot*)[[[OWSSignaliOSProtosBackupSnapshot builder] mergeFromInputStream:input extensionRegistry:extensionRegistry] build];
}
+ (OWSSignaliOSProtosBackupSnapshot*) parseFromCodedInputStream:(PBCodedInputStream*) input {
return (OWSSignaliOSProtosBackupSnapshot*)[[[OWSSignaliOSProtosBackupSnapshot builder] mergeFromCodedInputStream:input] build];
}
+ (OWSSignaliOSProtosBackupSnapshot*) parseFromCodedInputStream:(PBCodedInputStream*) input extensionRegistry:(PBExtensionRegistry*) extensionRegistry {
return (OWSSignaliOSProtosBackupSnapshot*)[[[OWSSignaliOSProtosBackupSnapshot builder] mergeFromCodedInputStream:input extensionRegistry:extensionRegistry] build];
}
+ (OWSSignaliOSProtosBackupSnapshotBuilder*) builder {
return [[OWSSignaliOSProtosBackupSnapshotBuilder alloc] init];
}
+ (OWSSignaliOSProtosBackupSnapshotBuilder*) builderWithPrototype:(OWSSignaliOSProtosBackupSnapshot*) prototype {
return [[OWSSignaliOSProtosBackupSnapshot builder] mergeFrom:prototype];
}
- (OWSSignaliOSProtosBackupSnapshotBuilder*) builder {
return [OWSSignaliOSProtosBackupSnapshot builder];
}
- (OWSSignaliOSProtosBackupSnapshotBuilder*) toBuilder {
return [OWSSignaliOSProtosBackupSnapshot builderWithPrototype:self];
}
- (void) writeDescriptionTo:(NSMutableString*) output withIndent:(NSString*) indent {
[self.entityArray enumerateObjectsUsingBlock:^(OWSSignaliOSProtosBackupSnapshotBackupEntity *element, NSUInteger idx, BOOL *stop) {
[output appendFormat:@"%@%@ {\n", indent, @"entity"];
[element writeDescriptionTo:output
withIndent:[NSString stringWithFormat:@"%@ ", indent]];
[output appendFormat:@"%@}\n", indent];
}];
[self.unknownFields writeDescriptionTo:output withIndent:indent];
}
- (void) storeInDictionary:(NSMutableDictionary *)dictionary {
for (OWSSignaliOSProtosBackupSnapshotBackupEntity* element in self.entityArray) {
NSMutableDictionary *elementDictionary = [NSMutableDictionary dictionary];
[element storeInDictionary:elementDictionary];
[dictionary setObject:[NSDictionary dictionaryWithDictionary:elementDictionary] forKey:@"entity"];
}
[self.unknownFields storeInDictionary:dictionary];
}
- (BOOL) isEqual:(id)other {
if (other == self) {
return YES;
}
if (![other isKindOfClass:[OWSSignaliOSProtosBackupSnapshot class]]) {
return NO;
}
OWSSignaliOSProtosBackupSnapshot *otherMessage = other;
return
[self.entityArray isEqualToArray:otherMessage.entityArray] &&
(self.unknownFields == otherMessage.unknownFields || (self.unknownFields != nil && [self.unknownFields isEqual:otherMessage.unknownFields]));
}
- (NSUInteger) hash {
__block NSUInteger hashCode = 7;
[self.entityArray enumerateObjectsUsingBlock:^(OWSSignaliOSProtosBackupSnapshotBackupEntity *element, NSUInteger idx, BOOL *stop) {
hashCode = hashCode * 31 + [element hash];
}];
hashCode = hashCode * 31 + [self.unknownFields hash];
return hashCode;
}
@end
@interface OWSSignaliOSProtosBackupSnapshotBackupEntity ()
@property OWSSignaliOSProtosBackupSnapshotBackupEntityType type;
@property (strong) NSData* entityData;
@end
@implementation OWSSignaliOSProtosBackupSnapshotBackupEntity
- (BOOL) hasType {
return !!hasType_;
}
- (void) setHasType:(BOOL) _value_ {
hasType_ = !!_value_;
}
@synthesize type;
- (BOOL) hasEntityData {
return !!hasEntityData_;
}
- (void) setHasEntityData:(BOOL) _value_ {
hasEntityData_ = !!_value_;
}
@synthesize entityData;
- (instancetype) init {
if ((self = [super init])) {
self.type = OWSSignaliOSProtosBackupSnapshotBackupEntityTypeUnknown;
self.entityData = [NSData data];
}
return self;
}
static OWSSignaliOSProtosBackupSnapshotBackupEntity* defaultOWSSignaliOSProtosBackupSnapshotBackupEntityInstance = nil;
+ (void) initialize {
if (self == [OWSSignaliOSProtosBackupSnapshotBackupEntity class]) {
defaultOWSSignaliOSProtosBackupSnapshotBackupEntityInstance = [[OWSSignaliOSProtosBackupSnapshotBackupEntity alloc] init];
}
}
+ (instancetype) defaultInstance {
return defaultOWSSignaliOSProtosBackupSnapshotBackupEntityInstance;
}
- (instancetype) defaultInstance {
return defaultOWSSignaliOSProtosBackupSnapshotBackupEntityInstance;
}
- (BOOL) isInitialized {
return YES;
}
- (void) writeToCodedOutputStream:(PBCodedOutputStream*) output {
if (self.hasType) {
[output writeEnum:1 value:self.type];
}
if (self.hasEntityData) {
[output writeData:2 value:self.entityData];
}
[self.unknownFields writeToCodedOutputStream:output];
}
- (SInt32) serializedSize {
__block SInt32 size_ = memoizedSerializedSize;
if (size_ != -1) {
return size_;
}
size_ = 0;
if (self.hasType) {
size_ += computeEnumSize(1, self.type);
}
if (self.hasEntityData) {
size_ += computeDataSize(2, self.entityData);
}
size_ += self.unknownFields.serializedSize;
memoizedSerializedSize = size_;
return size_;
}
+ (OWSSignaliOSProtosBackupSnapshotBackupEntity*) parseFromData:(NSData*) data {
return (OWSSignaliOSProtosBackupSnapshotBackupEntity*)[[[OWSSignaliOSProtosBackupSnapshotBackupEntity builder] mergeFromData:data] build];
}
+ (OWSSignaliOSProtosBackupSnapshotBackupEntity*) parseFromData:(NSData*) data extensionRegistry:(PBExtensionRegistry*) extensionRegistry {
return (OWSSignaliOSProtosBackupSnapshotBackupEntity*)[[[OWSSignaliOSProtosBackupSnapshotBackupEntity builder] mergeFromData:data extensionRegistry:extensionRegistry] build];
}
+ (OWSSignaliOSProtosBackupSnapshotBackupEntity*) parseFromInputStream:(NSInputStream*) input {
return (OWSSignaliOSProtosBackupSnapshotBackupEntity*)[[[OWSSignaliOSProtosBackupSnapshotBackupEntity builder] mergeFromInputStream:input] build];
}
+ (OWSSignaliOSProtosBackupSnapshotBackupEntity*) parseFromInputStream:(NSInputStream*) input extensionRegistry:(PBExtensionRegistry*) extensionRegistry {
return (OWSSignaliOSProtosBackupSnapshotBackupEntity*)[[[OWSSignaliOSProtosBackupSnapshotBackupEntity builder] mergeFromInputStream:input extensionRegistry:extensionRegistry] build];
}
+ (OWSSignaliOSProtosBackupSnapshotBackupEntity*) parseFromCodedInputStream:(PBCodedInputStream*) input {
return (OWSSignaliOSProtosBackupSnapshotBackupEntity*)[[[OWSSignaliOSProtosBackupSnapshotBackupEntity builder] mergeFromCodedInputStream:input] build];
}
+ (OWSSignaliOSProtosBackupSnapshotBackupEntity*) parseFromCodedInputStream:(PBCodedInputStream*) input extensionRegistry:(PBExtensionRegistry*) extensionRegistry {
return (OWSSignaliOSProtosBackupSnapshotBackupEntity*)[[[OWSSignaliOSProtosBackupSnapshotBackupEntity builder] mergeFromCodedInputStream:input extensionRegistry:extensionRegistry] build];
}
+ (OWSSignaliOSProtosBackupSnapshotBackupEntityBuilder*) builder {
return [[OWSSignaliOSProtosBackupSnapshotBackupEntityBuilder alloc] init];
}
+ (OWSSignaliOSProtosBackupSnapshotBackupEntityBuilder*) builderWithPrototype:(OWSSignaliOSProtosBackupSnapshotBackupEntity*) prototype {
return [[OWSSignaliOSProtosBackupSnapshotBackupEntity builder] mergeFrom:prototype];
}
- (OWSSignaliOSProtosBackupSnapshotBackupEntityBuilder*) builder {
return [OWSSignaliOSProtosBackupSnapshotBackupEntity builder];
}
- (OWSSignaliOSProtosBackupSnapshotBackupEntityBuilder*) toBuilder {
return [OWSSignaliOSProtosBackupSnapshotBackupEntity builderWithPrototype:self];
}
- (void) writeDescriptionTo:(NSMutableString*) output withIndent:(NSString*) indent {
if (self.hasType) {
[output appendFormat:@"%@%@: %@\n", indent, @"type", NSStringFromOWSSignaliOSProtosBackupSnapshotBackupEntityType(self.type)];
}
if (self.hasEntityData) {
[output appendFormat:@"%@%@: %@\n", indent, @"entityData", self.entityData];
}
[self.unknownFields writeDescriptionTo:output withIndent:indent];
}
- (void) storeInDictionary:(NSMutableDictionary *)dictionary {
if (self.hasType) {
[dictionary setObject: @(self.type) forKey: @"type"];
}
if (self.hasEntityData) {
[dictionary setObject: self.entityData forKey: @"entityData"];
}
[self.unknownFields storeInDictionary:dictionary];
}
- (BOOL) isEqual:(id)other {
if (other == self) {
return YES;
}
if (![other isKindOfClass:[OWSSignaliOSProtosBackupSnapshotBackupEntity class]]) {
return NO;
}
OWSSignaliOSProtosBackupSnapshotBackupEntity *otherMessage = other;
return
self.hasType == otherMessage.hasType &&
(!self.hasType || self.type == otherMessage.type) &&
self.hasEntityData == otherMessage.hasEntityData &&
(!self.hasEntityData || [self.entityData isEqual:otherMessage.entityData]) &&
(self.unknownFields == otherMessage.unknownFields || (self.unknownFields != nil && [self.unknownFields isEqual:otherMessage.unknownFields]));
}
- (NSUInteger) hash {
__block NSUInteger hashCode = 7;
if (self.hasType) {
hashCode = hashCode * 31 + self.type;
}
if (self.hasEntityData) {
hashCode = hashCode * 31 + [self.entityData hash];
}
hashCode = hashCode * 31 + [self.unknownFields hash];
return hashCode;
}
@end
BOOL OWSSignaliOSProtosBackupSnapshotBackupEntityTypeIsValidValue(OWSSignaliOSProtosBackupSnapshotBackupEntityType value) {
switch (value) {
case OWSSignaliOSProtosBackupSnapshotBackupEntityTypeUnknown:
case OWSSignaliOSProtosBackupSnapshotBackupEntityTypeMigration:
case OWSSignaliOSProtosBackupSnapshotBackupEntityTypeThread:
case OWSSignaliOSProtosBackupSnapshotBackupEntityTypeInteraction:
case OWSSignaliOSProtosBackupSnapshotBackupEntityTypeAttachment:
return YES;
default:
return NO;
}
}
NSString *NSStringFromOWSSignaliOSProtosBackupSnapshotBackupEntityType(OWSSignaliOSProtosBackupSnapshotBackupEntityType value) {
switch (value) {
case OWSSignaliOSProtosBackupSnapshotBackupEntityTypeUnknown:
return @"OWSSignaliOSProtosBackupSnapshotBackupEntityTypeUnknown";
case OWSSignaliOSProtosBackupSnapshotBackupEntityTypeMigration:
return @"OWSSignaliOSProtosBackupSnapshotBackupEntityTypeMigration";
case OWSSignaliOSProtosBackupSnapshotBackupEntityTypeThread:
return @"OWSSignaliOSProtosBackupSnapshotBackupEntityTypeThread";
case OWSSignaliOSProtosBackupSnapshotBackupEntityTypeInteraction:
return @"OWSSignaliOSProtosBackupSnapshotBackupEntityTypeInteraction";
case OWSSignaliOSProtosBackupSnapshotBackupEntityTypeAttachment:
return @"OWSSignaliOSProtosBackupSnapshotBackupEntityTypeAttachment";
default:
return nil;
}
}
@interface OWSSignaliOSProtosBackupSnapshotBackupEntityBuilder()
@property (strong) OWSSignaliOSProtosBackupSnapshotBackupEntity* resultBackupEntity;
@end
@implementation OWSSignaliOSProtosBackupSnapshotBackupEntityBuilder
@synthesize resultBackupEntity;
- (instancetype) init {
if ((self = [super init])) {
self.resultBackupEntity = [[OWSSignaliOSProtosBackupSnapshotBackupEntity alloc] init];
}
return self;
}
- (PBGeneratedMessage*) internalGetResult {
return resultBackupEntity;
}
- (OWSSignaliOSProtosBackupSnapshotBackupEntityBuilder*) clear {
self.resultBackupEntity = [[OWSSignaliOSProtosBackupSnapshotBackupEntity alloc] init];
return self;
}
- (OWSSignaliOSProtosBackupSnapshotBackupEntityBuilder*) clone {
return [OWSSignaliOSProtosBackupSnapshotBackupEntity builderWithPrototype:resultBackupEntity];
}
- (OWSSignaliOSProtosBackupSnapshotBackupEntity*) defaultInstance {
return [OWSSignaliOSProtosBackupSnapshotBackupEntity defaultInstance];
}
- (OWSSignaliOSProtosBackupSnapshotBackupEntity*) build {
[self checkInitialized];
return [self buildPartial];
}
- (OWSSignaliOSProtosBackupSnapshotBackupEntity*) buildPartial {
OWSSignaliOSProtosBackupSnapshotBackupEntity* returnMe = resultBackupEntity;
self.resultBackupEntity = nil;
return returnMe;
}
- (OWSSignaliOSProtosBackupSnapshotBackupEntityBuilder*) mergeFrom:(OWSSignaliOSProtosBackupSnapshotBackupEntity*) other {
if (other == [OWSSignaliOSProtosBackupSnapshotBackupEntity defaultInstance]) {
return self;
}
if (other.hasType) {
[self setType:other.type];
}
if (other.hasEntityData) {
[self setEntityData:other.entityData];
}
[self mergeUnknownFields:other.unknownFields];
return self;
}
- (OWSSignaliOSProtosBackupSnapshotBackupEntityBuilder*) mergeFromCodedInputStream:(PBCodedInputStream*) input {
return [self mergeFromCodedInputStream:input extensionRegistry:[PBExtensionRegistry emptyRegistry]];
}
- (OWSSignaliOSProtosBackupSnapshotBackupEntityBuilder*) mergeFromCodedInputStream:(PBCodedInputStream*) input extensionRegistry:(PBExtensionRegistry*) extensionRegistry {
PBUnknownFieldSetBuilder* unknownFields = [PBUnknownFieldSet builderWithUnknownFields:self.unknownFields];
while (YES) {
SInt32 tag = [input readTag];
switch (tag) {
case 0:
[self setUnknownFields:[unknownFields build]];
return self;
default: {
if (![self parseUnknownField:input unknownFields:unknownFields extensionRegistry:extensionRegistry tag:tag]) {
[self setUnknownFields:[unknownFields build]];
return self;
}
break;
}
case 8: {
OWSSignaliOSProtosBackupSnapshotBackupEntityType value = (OWSSignaliOSProtosBackupSnapshotBackupEntityType)[input readEnum];
if (OWSSignaliOSProtosBackupSnapshotBackupEntityTypeIsValidValue(value)) {
[self setType:value];
} else {
[unknownFields mergeVarintField:1 value:value];
}
break;
}
case 18: {
[self setEntityData:[input readData]];
break;
}
}
}
}
- (BOOL) hasType {
return resultBackupEntity.hasType;
}
- (OWSSignaliOSProtosBackupSnapshotBackupEntityType) type {
return resultBackupEntity.type;
}
- (OWSSignaliOSProtosBackupSnapshotBackupEntityBuilder*) setType:(OWSSignaliOSProtosBackupSnapshotBackupEntityType) value {
resultBackupEntity.hasType = YES;
resultBackupEntity.type = value;
return self;
}
- (OWSSignaliOSProtosBackupSnapshotBackupEntityBuilder*) clearType {
resultBackupEntity.hasType = NO;
resultBackupEntity.type = OWSSignaliOSProtosBackupSnapshotBackupEntityTypeUnknown;
return self;
}
- (BOOL) hasEntityData {
return resultBackupEntity.hasEntityData;
}
- (NSData*) entityData {
return resultBackupEntity.entityData;
}
- (OWSSignaliOSProtosBackupSnapshotBackupEntityBuilder*) setEntityData:(NSData*) value {
resultBackupEntity.hasEntityData = YES;
resultBackupEntity.entityData = value;
return self;
}
- (OWSSignaliOSProtosBackupSnapshotBackupEntityBuilder*) clearEntityData {
resultBackupEntity.hasEntityData = NO;
resultBackupEntity.entityData = [NSData data];
return self;
}
@end
@interface OWSSignaliOSProtosBackupSnapshotBuilder()
@property (strong) OWSSignaliOSProtosBackupSnapshot* resultBackupSnapshot;
@end
@implementation OWSSignaliOSProtosBackupSnapshotBuilder
@synthesize resultBackupSnapshot;
- (instancetype) init {
if ((self = [super init])) {
self.resultBackupSnapshot = [[OWSSignaliOSProtosBackupSnapshot alloc] init];
}
return self;
}
- (PBGeneratedMessage*) internalGetResult {
return resultBackupSnapshot;
}
- (OWSSignaliOSProtosBackupSnapshotBuilder*) clear {
self.resultBackupSnapshot = [[OWSSignaliOSProtosBackupSnapshot alloc] init];
return self;
}
- (OWSSignaliOSProtosBackupSnapshotBuilder*) clone {
return [OWSSignaliOSProtosBackupSnapshot builderWithPrototype:resultBackupSnapshot];
}
- (OWSSignaliOSProtosBackupSnapshot*) defaultInstance {
return [OWSSignaliOSProtosBackupSnapshot defaultInstance];
}
- (OWSSignaliOSProtosBackupSnapshot*) build {
[self checkInitialized];
return [self buildPartial];
}
- (OWSSignaliOSProtosBackupSnapshot*) buildPartial {
OWSSignaliOSProtosBackupSnapshot* returnMe = resultBackupSnapshot;
self.resultBackupSnapshot = nil;
return returnMe;
}
- (OWSSignaliOSProtosBackupSnapshotBuilder*) mergeFrom:(OWSSignaliOSProtosBackupSnapshot*) other {
if (other == [OWSSignaliOSProtosBackupSnapshot defaultInstance]) {
return self;
}
if (other.entityArray.count > 0) {
if (resultBackupSnapshot.entityArray == nil) {
resultBackupSnapshot.entityArray = [[NSMutableArray alloc] initWithArray:other.entityArray];
} else {
[resultBackupSnapshot.entityArray addObjectsFromArray:other.entityArray];
}
}
[self mergeUnknownFields:other.unknownFields];
return self;
}
- (OWSSignaliOSProtosBackupSnapshotBuilder*) mergeFromCodedInputStream:(PBCodedInputStream*) input {
return [self mergeFromCodedInputStream:input extensionRegistry:[PBExtensionRegistry emptyRegistry]];
}
- (OWSSignaliOSProtosBackupSnapshotBuilder*) mergeFromCodedInputStream:(PBCodedInputStream*) input extensionRegistry:(PBExtensionRegistry*) extensionRegistry {
PBUnknownFieldSetBuilder* unknownFields = [PBUnknownFieldSet builderWithUnknownFields:self.unknownFields];
while (YES) {
SInt32 tag = [input readTag];
switch (tag) {
case 0:
[self setUnknownFields:[unknownFields build]];
return self;
default: {
if (![self parseUnknownField:input unknownFields:unknownFields extensionRegistry:extensionRegistry tag:tag]) {
[self setUnknownFields:[unknownFields build]];
return self;
}
break;
}
case 10: {
OWSSignaliOSProtosBackupSnapshotBackupEntityBuilder* subBuilder = [OWSSignaliOSProtosBackupSnapshotBackupEntity builder];
[input readMessage:subBuilder extensionRegistry:extensionRegistry];
[self addEntity:[subBuilder buildPartial]];
break;
}
}
}
}
- (NSMutableArray<OWSSignaliOSProtosBackupSnapshotBackupEntity*> *)entity {
return resultBackupSnapshot.entityArray;
}
- (OWSSignaliOSProtosBackupSnapshotBackupEntity*)entityAtIndex:(NSUInteger)index {
return [resultBackupSnapshot entityAtIndex:index];
}
- (OWSSignaliOSProtosBackupSnapshotBuilder *)addEntity:(OWSSignaliOSProtosBackupSnapshotBackupEntity*)value {
if (resultBackupSnapshot.entityArray == nil) {
resultBackupSnapshot.entityArray = [[NSMutableArray alloc]init];
}
[resultBackupSnapshot.entityArray addObject:value];
return self;
}
- (OWSSignaliOSProtosBackupSnapshotBuilder *)setEntityArray:(NSArray<OWSSignaliOSProtosBackupSnapshotBackupEntity*> *)array {
resultBackupSnapshot.entityArray = [[NSMutableArray alloc]initWithArray:array];
return self;
}
- (OWSSignaliOSProtosBackupSnapshotBuilder *)clearEntity {
resultBackupSnapshot.entityArray = nil;
return self;
}
@end
// @@protoc_insertion_point(global_scope)
Loading…
Cancel
Save