1 // This file was automatically generated by protocompiler
3 // Compiled from OTEscrowRecord.proto
5 #import "OTEscrowRecordMetadata.h"
6 #import <ProtocolBuffer/PBConstants.h>
7 #import <ProtocolBuffer/PBHashUtil.h>
8 #import <ProtocolBuffer/PBDataReader.h>
10 #import "OTEscrowRecordMetadataClientMetadata.h"
12 #if !__has_feature(objc_arc)
13 # error This generated file depends on ARC but it is not enabled; turn on ARC, or use 'objc_use_arc' option to generate non-ARC code.
16 @implementation OTEscrowRecordMetadata
18 - (BOOL)hasBackupKeybagDigest
20 return _backupKeybagDigest != nil;
22 @synthesize backupKeybagDigest = _backupKeybagDigest;
23 - (BOOL)hasClientMetadata
25 return _clientMetadata != nil;
27 @synthesize clientMetadata = _clientMetadata;
28 @synthesize secureBackupUsesMultipleIcscs = _secureBackupUsesMultipleIcscs;
29 - (void)setSecureBackupUsesMultipleIcscs:(uint64_t)v
31 _has.secureBackupUsesMultipleIcscs = YES;
32 _secureBackupUsesMultipleIcscs = v;
34 - (void)setHasSecureBackupUsesMultipleIcscs:(BOOL)f
36 _has.secureBackupUsesMultipleIcscs = f;
38 - (BOOL)hasSecureBackupUsesMultipleIcscs
40 return _has.secureBackupUsesMultipleIcscs != 0;
44 return _bottleId != nil;
46 @synthesize bottleId = _bottleId;
47 @synthesize secureBackupTimestamp = _secureBackupTimestamp;
48 - (void)setSecureBackupTimestamp:(uint64_t)v
50 _has.secureBackupTimestamp = YES;
51 _secureBackupTimestamp = v;
53 - (void)setHasSecureBackupTimestamp:(BOOL)f
55 _has.secureBackupTimestamp = f;
57 - (BOOL)hasSecureBackupTimestamp
59 return _has.secureBackupTimestamp != 0;
61 - (BOOL)hasEscrowedSpki
63 return _escrowedSpki != nil;
65 @synthesize escrowedSpki = _escrowedSpki;
68 return _peerInfo != nil;
70 @synthesize peerInfo = _peerInfo;
71 - (BOOL)hasBottleValidity
73 return _bottleValidity != nil;
75 @synthesize bottleValidity = _bottleValidity;
78 return _serial != nil;
80 @synthesize serial = _serial;
82 - (NSString *)description
84 return [NSString stringWithFormat:@"%@ %@", [super description], [self dictionaryRepresentation]];
87 - (NSDictionary *)dictionaryRepresentation
89 NSMutableDictionary *dict = [NSMutableDictionary dictionary];
90 if (self->_backupKeybagDigest)
92 [dict setObject:self->_backupKeybagDigest forKey:@"backup_keybag_digest"];
94 if (self->_clientMetadata)
96 [dict setObject:[_clientMetadata dictionaryRepresentation] forKey:@"client_metadata"];
98 if (self->_has.secureBackupUsesMultipleIcscs)
100 [dict setObject:[NSNumber numberWithUnsignedLongLong:self->_secureBackupUsesMultipleIcscs] forKey:@"secure_backup_uses_multiple_icscs"];
104 [dict setObject:self->_bottleId forKey:@"bottle_id"];
106 if (self->_has.secureBackupTimestamp)
108 [dict setObject:[NSNumber numberWithUnsignedLongLong:self->_secureBackupTimestamp] forKey:@"secure_backup_timestamp"];
110 if (self->_escrowedSpki)
112 [dict setObject:self->_escrowedSpki forKey:@"escrowed_spki"];
116 [dict setObject:self->_peerInfo forKey:@"peer_info"];
118 if (self->_bottleValidity)
120 [dict setObject:self->_bottleValidity forKey:@"bottle_validity"];
124 [dict setObject:self->_serial forKey:@"serial"];
129 BOOL OTEscrowRecordMetadataReadFrom(__unsafe_unretained OTEscrowRecordMetadata *self, __unsafe_unretained PBDataReader *reader) {
130 while (PBReaderHasMoreData(reader)) {
134 PBReaderReadTag32AndType(reader, &tag, &aType);
136 if (PBReaderHasError(reader))
139 if (aType == TYPE_END_GROUP) {
145 case 1 /* backupKeybagDigest */:
147 NSData *new_backupKeybagDigest = PBReaderReadData(reader);
148 self->_backupKeybagDigest = new_backupKeybagDigest;
151 case 2 /* clientMetadata */:
153 OTEscrowRecordMetadataClientMetadata *new_clientMetadata = [[OTEscrowRecordMetadataClientMetadata alloc] init];
154 self->_clientMetadata = new_clientMetadata;
155 PBDataReaderMark mark_clientMetadata;
156 BOOL markError = !PBReaderPlaceMark(reader, &mark_clientMetadata);
161 BOOL inError = !OTEscrowRecordMetadataClientMetadataReadFrom(new_clientMetadata, reader);
166 PBReaderRecallMark(reader, &mark_clientMetadata);
169 case 3 /* secureBackupUsesMultipleIcscs */:
171 self->_has.secureBackupUsesMultipleIcscs = YES;
172 self->_secureBackupUsesMultipleIcscs = PBReaderReadUint64(reader);
175 case 4 /* bottleId */:
177 NSString *new_bottleId = PBReaderReadString(reader);
178 self->_bottleId = new_bottleId;
181 case 5 /* secureBackupTimestamp */:
183 self->_has.secureBackupTimestamp = YES;
184 self->_secureBackupTimestamp = PBReaderReadUint64(reader);
187 case 6 /* escrowedSpki */:
189 NSData *new_escrowedSpki = PBReaderReadData(reader);
190 self->_escrowedSpki = new_escrowedSpki;
193 case 7 /* peerInfo */:
195 NSData *new_peerInfo = PBReaderReadData(reader);
196 self->_peerInfo = new_peerInfo;
199 case 8 /* bottleValidity */:
201 NSString *new_bottleValidity = PBReaderReadString(reader);
202 self->_bottleValidity = new_bottleValidity;
207 NSString *new_serial = PBReaderReadString(reader);
208 self->_serial = new_serial;
212 if (!PBReaderSkipValueWithTag(reader, tag, aType))
217 return !PBReaderHasError(reader);
220 - (BOOL)readFrom:(PBDataReader *)reader
222 return OTEscrowRecordMetadataReadFrom(self, reader);
224 - (void)writeTo:(PBDataWriter *)writer
226 /* backupKeybagDigest */
228 if (self->_backupKeybagDigest)
230 PBDataWriterWriteDataField(writer, self->_backupKeybagDigest, 1);
235 if (self->_clientMetadata != nil)
237 PBDataWriterWriteSubmessage(writer, self->_clientMetadata, 2);
240 /* secureBackupUsesMultipleIcscs */
242 if (self->_has.secureBackupUsesMultipleIcscs)
244 PBDataWriterWriteUint64Field(writer, self->_secureBackupUsesMultipleIcscs, 3);
251 PBDataWriterWriteStringField(writer, self->_bottleId, 4);
254 /* secureBackupTimestamp */
256 if (self->_has.secureBackupTimestamp)
258 PBDataWriterWriteUint64Field(writer, self->_secureBackupTimestamp, 5);
263 if (self->_escrowedSpki)
265 PBDataWriterWriteDataField(writer, self->_escrowedSpki, 6);
272 PBDataWriterWriteDataField(writer, self->_peerInfo, 7);
277 if (self->_bottleValidity)
279 PBDataWriterWriteStringField(writer, self->_bottleValidity, 8);
286 PBDataWriterWriteStringField(writer, self->_serial, 9);
291 - (void)copyTo:(OTEscrowRecordMetadata *)other
293 if (_backupKeybagDigest)
295 other.backupKeybagDigest = _backupKeybagDigest;
299 other.clientMetadata = _clientMetadata;
301 if (self->_has.secureBackupUsesMultipleIcscs)
303 other->_secureBackupUsesMultipleIcscs = _secureBackupUsesMultipleIcscs;
304 other->_has.secureBackupUsesMultipleIcscs = YES;
308 other.bottleId = _bottleId;
310 if (self->_has.secureBackupTimestamp)
312 other->_secureBackupTimestamp = _secureBackupTimestamp;
313 other->_has.secureBackupTimestamp = YES;
317 other.escrowedSpki = _escrowedSpki;
321 other.peerInfo = _peerInfo;
325 other.bottleValidity = _bottleValidity;
329 other.serial = _serial;
333 - (id)copyWithZone:(NSZone *)zone
335 OTEscrowRecordMetadata *copy = [[[self class] allocWithZone:zone] init];
336 copy->_backupKeybagDigest = [_backupKeybagDigest copyWithZone:zone];
337 copy->_clientMetadata = [_clientMetadata copyWithZone:zone];
338 if (self->_has.secureBackupUsesMultipleIcscs)
340 copy->_secureBackupUsesMultipleIcscs = _secureBackupUsesMultipleIcscs;
341 copy->_has.secureBackupUsesMultipleIcscs = YES;
343 copy->_bottleId = [_bottleId copyWithZone:zone];
344 if (self->_has.secureBackupTimestamp)
346 copy->_secureBackupTimestamp = _secureBackupTimestamp;
347 copy->_has.secureBackupTimestamp = YES;
349 copy->_escrowedSpki = [_escrowedSpki copyWithZone:zone];
350 copy->_peerInfo = [_peerInfo copyWithZone:zone];
351 copy->_bottleValidity = [_bottleValidity copyWithZone:zone];
352 copy->_serial = [_serial copyWithZone:zone];
356 - (BOOL)isEqual:(id)object
358 OTEscrowRecordMetadata *other = (OTEscrowRecordMetadata *)object;
359 return [other isMemberOfClass:[self class]]
361 ((!self->_backupKeybagDigest && !other->_backupKeybagDigest) || [self->_backupKeybagDigest isEqual:other->_backupKeybagDigest])
363 ((!self->_clientMetadata && !other->_clientMetadata) || [self->_clientMetadata isEqual:other->_clientMetadata])
365 ((self->_has.secureBackupUsesMultipleIcscs && other->_has.secureBackupUsesMultipleIcscs && self->_secureBackupUsesMultipleIcscs == other->_secureBackupUsesMultipleIcscs) || (!self->_has.secureBackupUsesMultipleIcscs && !other->_has.secureBackupUsesMultipleIcscs))
367 ((!self->_bottleId && !other->_bottleId) || [self->_bottleId isEqual:other->_bottleId])
369 ((self->_has.secureBackupTimestamp && other->_has.secureBackupTimestamp && self->_secureBackupTimestamp == other->_secureBackupTimestamp) || (!self->_has.secureBackupTimestamp && !other->_has.secureBackupTimestamp))
371 ((!self->_escrowedSpki && !other->_escrowedSpki) || [self->_escrowedSpki isEqual:other->_escrowedSpki])
373 ((!self->_peerInfo && !other->_peerInfo) || [self->_peerInfo isEqual:other->_peerInfo])
375 ((!self->_bottleValidity && !other->_bottleValidity) || [self->_bottleValidity isEqual:other->_bottleValidity])
377 ((!self->_serial && !other->_serial) || [self->_serial isEqual:other->_serial])
385 [self->_backupKeybagDigest hash]
387 [self->_clientMetadata hash]
389 (self->_has.secureBackupUsesMultipleIcscs ? PBHashInt((NSUInteger)self->_secureBackupUsesMultipleIcscs) : 0)
391 [self->_bottleId hash]
393 (self->_has.secureBackupTimestamp ? PBHashInt((NSUInteger)self->_secureBackupTimestamp) : 0)
395 [self->_escrowedSpki hash]
397 [self->_peerInfo hash]
399 [self->_bottleValidity hash]
405 - (void)mergeFrom:(OTEscrowRecordMetadata *)other
407 if (other->_backupKeybagDigest)
409 [self setBackupKeybagDigest:other->_backupKeybagDigest];
411 if (self->_clientMetadata && other->_clientMetadata)
413 [self->_clientMetadata mergeFrom:other->_clientMetadata];
415 else if (!self->_clientMetadata && other->_clientMetadata)
417 [self setClientMetadata:other->_clientMetadata];
419 if (other->_has.secureBackupUsesMultipleIcscs)
421 self->_secureBackupUsesMultipleIcscs = other->_secureBackupUsesMultipleIcscs;
422 self->_has.secureBackupUsesMultipleIcscs = YES;
424 if (other->_bottleId)
426 [self setBottleId:other->_bottleId];
428 if (other->_has.secureBackupTimestamp)
430 self->_secureBackupTimestamp = other->_secureBackupTimestamp;
431 self->_has.secureBackupTimestamp = YES;
433 if (other->_escrowedSpki)
435 [self setEscrowedSpki:other->_escrowedSpki];
437 if (other->_peerInfo)
439 [self setPeerInfo:other->_peerInfo];
441 if (other->_bottleValidity)
443 [self setBottleValidity:other->_bottleValidity];
447 [self setSerial:other->_serial];