Remove 'has' accessors from proto wrappers.

This commit is contained in:
Matthew Chen 2018-08-08 13:41:12 -04:00
parent e4a123bcef
commit 7437e7a6b1
10 changed files with 55 additions and 163 deletions

View File

@ -413,7 +413,7 @@ class MessageContext(BaseContext):
type_name = field.type_swift_not_optional if field.is_required else field.type_swift type_name = field.type_swift_not_optional if field.is_required else field.type_swift
writer.add('@objc public let %s: %s' % (field.name_swift, type_name)) writer.add('@objc public let %s: %s' % (field.name_swift, type_name))
if (not field.is_required) and field.rules != 'repeated': if (not field.is_required) and field.rules != 'repeated' and (not self.is_field_a_proto(field)):
writer.add('@objc public var %s: Bool {' % field.has_accessor_name() ) writer.add('@objc public var %s: Bool {' % field.has_accessor_name() )
writer.push_indent() writer.push_indent()
writer.add('return proto.%s' % field.has_accessor_name() ) writer.add('return proto.%s' % field.has_accessor_name() )

View File

@ -324,19 +324,10 @@ public enum WebRTCProtoError: Error {
fileprivate let proto: WebRTCProtos_Data fileprivate let proto: WebRTCProtos_Data
@objc public let connected: WebRTCProtoConnected? @objc public let connected: WebRTCProtoConnected?
@objc public var hasConnected: Bool {
return proto.hasConnected
}
@objc public let hangup: WebRTCProtoHangup? @objc public let hangup: WebRTCProtoHangup?
@objc public var hasHangup: Bool {
return proto.hasHangup
}
@objc public let videoStreamingStatus: WebRTCProtoVideoStreamingStatus? @objc public let videoStreamingStatus: WebRTCProtoVideoStreamingStatus?
@objc public var hasVideoStreamingStatus: Bool {
return proto.hasVideoStreamingStatus
}
private init(proto: WebRTCProtos_Data, private init(proto: WebRTCProtos_Data,
connected: WebRTCProtoConnected?, connected: WebRTCProtoConnected?,

View File

@ -1366,11 +1366,9 @@ private class SignalCallData: NSObject {
} }
let call = callData.call let call = callData.call
if message.hasConnected { if let connected = message.connected {
Logger.debug("\(self.logTag) remote participant sent Connected via data channel: \(call.identifiersForLogs).") Logger.debug("\(self.logTag) remote participant sent Connected via data channel: \(call.identifiersForLogs).")
let connected = message.connected!
guard connected.id == call.signalingId else { guard connected.id == call.signalingId else {
// This should never happen; return to a known good state. // This should never happen; return to a known good state.
owsFail("\(self.logTag) received connected message for call with id:\(connected.id) but current call has id:\(call.signalingId)") owsFail("\(self.logTag) received connected message for call with id:\(connected.id) but current call has id:\(call.signalingId)")
@ -1382,11 +1380,9 @@ private class SignalCallData: NSObject {
self.callUIAdapter.recipientAcceptedCall(call) self.callUIAdapter.recipientAcceptedCall(call)
handleConnectedCall(callData) handleConnectedCall(callData)
} else if message.hasHangup { } else if let hangup = message.hangup {
Logger.debug("\(self.logTag) remote participant sent Hangup via data channel: \(call.identifiersForLogs).") Logger.debug("\(self.logTag) remote participant sent Hangup via data channel: \(call.identifiersForLogs).")
let hangup = message.hangup!
guard hangup.id == call.signalingId else { guard hangup.id == call.signalingId else {
// This should never happen; return to a known good state. // This should never happen; return to a known good state.
owsFail("\(self.logTag) received hangup message for call with id:\(hangup.id) but current call has id:\(call.signalingId)") owsFail("\(self.logTag) received hangup message for call with id:\(hangup.id) but current call has id:\(call.signalingId)")
@ -1396,14 +1392,9 @@ private class SignalCallData: NSObject {
} }
handleRemoteHangup(thread: call.thread, callId: hangup.id) handleRemoteHangup(thread: call.thread, callId: hangup.id)
} else if message.hasVideoStreamingStatus { } else if let videoStreamingStatus = message.videoStreamingStatus {
Logger.debug("\(self.logTag) remote participant sent VideoStreamingStatus via data channel: \(call.identifiersForLogs).") Logger.debug("\(self.logTag) remote participant sent VideoStreamingStatus via data channel: \(call.identifiersForLogs).")
guard let videoStreamingStatus = message.videoStreamingStatus else {
owsFail("\(logTag) missing videoStreamingStatus")
return
}
callData.isRemoteVideoEnabled = videoStreamingStatus.enabled callData.isRemoteVideoEnabled = videoStreamingStatus.enabled
self.fireDidUpdateVideoTracks() self.fireDidUpdateVideoTracks()
} else { } else {

View File

@ -33,11 +33,11 @@ NS_ASSUME_NONNULL_BEGIN
_expirationDuration = sentProto.message.expireTimer; _expirationDuration = sentProto.message.expireTimer;
_body = _dataMessage.body; _body = _dataMessage.body;
_groupId = _dataMessage.group.id; _groupId = _dataMessage.group.id;
_isGroupUpdate = _dataMessage.hasGroup && (_dataMessage.group.type == SSKProtoGroupContextTypeUpdate); _isGroupUpdate = _dataMessage.group != nil && (_dataMessage.group.type == SSKProtoGroupContextTypeUpdate);
_isExpirationTimerUpdate = (_dataMessage.flags & SSKProtoDataMessageFlagsExpirationTimerUpdate) != 0; _isExpirationTimerUpdate = (_dataMessage.flags & SSKProtoDataMessageFlagsExpirationTimerUpdate) != 0;
_isEndSessionMessage = (_dataMessage.flags & SSKProtoDataMessageFlagsEndSession) != 0; _isEndSessionMessage = (_dataMessage.flags & SSKProtoDataMessageFlagsEndSession) != 0;
if (self.dataMessage.hasGroup) { if (self.dataMessage.group) {
_thread = [TSGroupThread getOrCreateThreadWithGroupId:_dataMessage.group.id transaction:transaction]; _thread = [TSGroupThread getOrCreateThreadWithGroupId:_dataMessage.group.id transaction:transaction];
} else { } else {
_thread = [TSContactThread getOrCreateThreadWithContactId:_recipientId transaction:transaction]; _thread = [TSContactThread getOrCreateThreadWithContactId:_recipientId transaction:transaction];
@ -51,7 +51,7 @@ NS_ASSUME_NONNULL_BEGIN
- (NSArray<SSKProtoAttachmentPointer *> *)attachmentPointerProtos - (NSArray<SSKProtoAttachmentPointer *> *)attachmentPointerProtos
{ {
if (self.isGroupUpdate && self.dataMessage.group.hasAvatar) { if (self.isGroupUpdate && self.dataMessage.group.avatar) {
return @[ self.dataMessage.group.avatar ]; return @[ self.dataMessage.group.avatar ];
} else { } else {
return self.dataMessage.attachments; return self.dataMessage.attachments;

View File

@ -898,7 +898,7 @@ NSString *NSStringForContactAddressType(OWSContactAddressType value)
} }
} }
if (contact.avatarAttachmentId != nil) { if (contact.avatarAttachmentId) {
SSKProtoAttachmentPointer *_Nullable attachmentProto = SSKProtoAttachmentPointer *_Nullable attachmentProto =
[TSAttachmentStream buildProtoForAttachmentId:contact.avatarAttachmentId]; [TSAttachmentStream buildProtoForAttachmentId:contact.avatarAttachmentId];
if (!attachmentProto) { if (!attachmentProto) {
@ -941,29 +941,29 @@ NSString *NSStringForContactAddressType(OWSContactAddressType value)
OWSContact *contact = [OWSContact new]; OWSContact *contact = [OWSContact new];
OWSContactName *contactName = [OWSContactName new]; OWSContactName *contactName = [OWSContactName new];
if (contactProto.hasName) { if (contactProto.name) {
SSKProtoDataMessageContactName *nameProto = contactProto.name; SSKProtoDataMessageContactName *nameProto = contactProto.name;
if (nameProto.hasGivenName) { if (nameProto.givenName) {
contactName.givenName = nameProto.givenName.ows_stripped; contactName.givenName = nameProto.givenName.ows_stripped;
} }
if (nameProto.hasFamilyName) { if (nameProto.familyName) {
contactName.familyName = nameProto.familyName.ows_stripped; contactName.familyName = nameProto.familyName.ows_stripped;
} }
if (nameProto.hasPrefix) { if (nameProto.prefix) {
contactName.namePrefix = nameProto.prefix.ows_stripped; contactName.namePrefix = nameProto.prefix.ows_stripped;
} }
if (nameProto.hasSuffix) { if (nameProto.suffix) {
contactName.nameSuffix = nameProto.suffix.ows_stripped; contactName.nameSuffix = nameProto.suffix.ows_stripped;
} }
if (nameProto.hasMiddleName) { if (nameProto.middleName) {
contactName.middleName = nameProto.middleName.ows_stripped; contactName.middleName = nameProto.middleName.ows_stripped;
} }
if (nameProto.hasDisplayName) { if (nameProto.displayName) {
contactName.displayName = nameProto.displayName.ows_stripped; contactName.displayName = nameProto.displayName.ows_stripped;
} }
} }
if (contactProto.hasOrganization) { if (contactProto.organization) {
contactName.organizationName = contactProto.organization.ows_stripped; contactName.organizationName = contactProto.organization.ows_stripped;
} }
[contactName ensureDisplayName]; [contactName ensureDisplayName];
@ -996,10 +996,10 @@ NSString *NSStringForContactAddressType(OWSContactAddressType value)
} }
contact.addresses = [addresses copy]; contact.addresses = [addresses copy];
if (contactProto.hasAvatar) { if (contactProto.avatar) {
SSKProtoDataMessageContactAvatar *avatarInfo = contactProto.avatar; SSKProtoDataMessageContactAvatar *avatarInfo = contactProto.avatar;
if (avatarInfo.hasAvatar) { if (avatarInfo.avatar) {
SSKProtoAttachmentPointer *avatarAttachment = avatarInfo.avatar; SSKProtoAttachmentPointer *avatarAttachment = avatarInfo.avatar;
TSAttachmentPointer *attachmentPointer = [TSAttachmentPointer attachmentPointerFromProto:avatarAttachment]; TSAttachmentPointer *attachmentPointer = [TSAttachmentPointer attachmentPointerFromProto:avatarAttachment];

View File

@ -109,7 +109,7 @@ NS_ASSUME_NONNULL_BEGIN
{ {
OWSAssert(dataMessage); OWSAssert(dataMessage);
if (!dataMessage.hasQuote) { if (!dataMessage.quote) {
return nil; return nil;
} }
@ -160,7 +160,7 @@ NS_ASSUME_NONNULL_BEGIN
[thumbnailStream saveWithTransaction:transaction]; [thumbnailStream saveWithTransaction:transaction];
attachmentInfo.thumbnailAttachmentStreamId = thumbnailStream.uniqueId; attachmentInfo.thumbnailAttachmentStreamId = thumbnailStream.uniqueId;
} else if (quotedAttachment.hasThumbnail) { } else if (quotedAttachment.thumbnail) {
DDLogDebug(@"%@ Saving reference for fetching remote thumbnail for quoted message: %@:%lu", DDLogDebug(@"%@ Saving reference for fetching remote thumbnail for quoted message: %@:%lu",
self.logTag, self.logTag,
thread.uniqueId, thread.uniqueId,

View File

@ -58,16 +58,16 @@ NSString *envelopeAddress(SSKProtoEnvelope *envelope)
*/ */
- (NSString *)descriptionForContent:(SSKProtoContent *)content - (NSString *)descriptionForContent:(SSKProtoContent *)content
{ {
if (content.hasSyncMessage) { if (content.syncMessage) {
return [NSString stringWithFormat:@"<SyncMessage: %@ />", [self descriptionForSyncMessage:content.syncMessage]]; return [NSString stringWithFormat:@"<SyncMessage: %@ />", [self descriptionForSyncMessage:content.syncMessage]];
} else if (content.hasDataMessage) { } else if (content.dataMessage) {
return [NSString stringWithFormat:@"<DataMessage: %@ />", [self descriptionForDataMessage:content.dataMessage]]; return [NSString stringWithFormat:@"<DataMessage: %@ />", [self descriptionForDataMessage:content.dataMessage]];
} else if (content.hasCallMessage) { } else if (content.callMessage) {
NSString *callMessageDescription = [self descriptionForCallMessage:content.callMessage]; NSString *callMessageDescription = [self descriptionForCallMessage:content.callMessage];
return [NSString stringWithFormat:@"<CallMessage %@ />", callMessageDescription]; return [NSString stringWithFormat:@"<CallMessage %@ />", callMessageDescription];
} else if (content.hasNullMessage) { } else if (content.nullMessage) {
return [NSString stringWithFormat:@"<NullMessage: %@ />", content.nullMessage]; return [NSString stringWithFormat:@"<NullMessage: %@ />", content.nullMessage];
} else if (content.hasReceiptMessage) { } else if (content.receiptMessage) {
return [NSString stringWithFormat:@"<ReceiptMessage: %@ />", content.receiptMessage]; return [NSString stringWithFormat:@"<ReceiptMessage: %@ />", content.receiptMessage];
} else { } else {
// Don't fire an analytics event; if we ever add a new content type, we'd generate a ton of // Don't fire an analytics event; if we ever add a new content type, we'd generate a ton of
@ -81,17 +81,17 @@ NSString *envelopeAddress(SSKProtoEnvelope *envelope)
{ {
NSString *messageType; NSString *messageType;
UInt64 callId; UInt64 callId;
if (callMessage.hasOffer) { if (callMessage.offer) {
messageType = @"Offer"; messageType = @"Offer";
callId = callMessage.offer.id; callId = callMessage.offer.id;
} else if (callMessage.hasBusy) { } else if (callMessage.busy) {
messageType = @"Busy"; messageType = @"Busy";
callId = callMessage.busy.id; callId = callMessage.busy.id;
} else if (callMessage.hasAnswer) { } else if (callMessage.answer) {
messageType = @"Answer"; messageType = @"Answer";
callId = callMessage.answer.id; callId = callMessage.answer.id;
} else if (callMessage.hasHangup) { } else if (callMessage.hangup) {
messageType = @"Hangup"; messageType = @"Hangup";
callId = callMessage.hangup.id; callId = callMessage.hangup.id;
} else if (callMessage.iceUpdate.count > 0) { } else if (callMessage.iceUpdate.count > 0) {
@ -113,7 +113,7 @@ NSString *envelopeAddress(SSKProtoEnvelope *envelope)
{ {
NSMutableString *description = [NSMutableString new]; NSMutableString *description = [NSMutableString new];
if (dataMessage.hasGroup) { if (dataMessage.group) {
[description appendString:@"(Group:YES) "]; [description appendString:@"(Group:YES) "];
} }
@ -138,9 +138,9 @@ NSString *envelopeAddress(SSKProtoEnvelope *envelope)
- (NSString *)descriptionForSyncMessage:(SSKProtoSyncMessage *)syncMessage - (NSString *)descriptionForSyncMessage:(SSKProtoSyncMessage *)syncMessage
{ {
NSMutableString *description = [NSMutableString new]; NSMutableString *description = [NSMutableString new];
if (syncMessage.hasSent) { if (syncMessage.sent) {
[description appendString:@"SentTranscript"]; [description appendString:@"SentTranscript"];
} else if (syncMessage.hasRequest) { } else if (syncMessage.request) {
if (syncMessage.request.type == SSKProtoSyncMessageRequestTypeContacts) { if (syncMessage.request.type == SSKProtoSyncMessageRequestTypeContacts) {
[description appendString:@"ContactRequest"]; [description appendString:@"ContactRequest"];
} else if (syncMessage.request.type == SSKProtoSyncMessageRequestTypeGroups) { } else if (syncMessage.request.type == SSKProtoSyncMessageRequestTypeGroups) {
@ -154,11 +154,11 @@ NSString *envelopeAddress(SSKProtoEnvelope *envelope)
OWSFail(@"Unknown sync message request type"); OWSFail(@"Unknown sync message request type");
[description appendString:@"UnknownRequest"]; [description appendString:@"UnknownRequest"];
} }
} else if (syncMessage.hasBlocked) { } else if (syncMessage.blocked) {
[description appendString:@"Blocked"]; [description appendString:@"Blocked"];
} else if (syncMessage.read.count > 0) { } else if (syncMessage.read.count > 0) {
[description appendString:@"ReadReceipt"]; [description appendString:@"ReadReceipt"];
} else if (syncMessage.hasVerified) { } else if (syncMessage.verified) {
NSString *verifiedString = NSString *verifiedString =
[NSString stringWithFormat:@"Verification for: %@", syncMessage.verified.destination]; [NSString stringWithFormat:@"Verification for: %@", syncMessage.verified.destination];
[description appendString:verifiedString]; [description appendString:verifiedString];

View File

@ -303,17 +303,17 @@ NS_ASSUME_NONNULL_BEGIN
} }
DDLogInfo(@"%@ handling content: <Content: %@>", self.logTag, [self descriptionForContent:contentProto]); DDLogInfo(@"%@ handling content: <Content: %@>", self.logTag, [self descriptionForContent:contentProto]);
if (contentProto.hasSyncMessage) { if (contentProto.syncMessage) {
[self handleIncomingEnvelope:envelope withSyncMessage:contentProto.syncMessage transaction:transaction]; [self handleIncomingEnvelope:envelope withSyncMessage:contentProto.syncMessage transaction:transaction];
[[OWSDeviceManager sharedManager] setHasReceivedSyncMessage]; [[OWSDeviceManager sharedManager] setHasReceivedSyncMessage];
} else if (contentProto.hasDataMessage) { } else if (contentProto.dataMessage) {
[self handleIncomingEnvelope:envelope withDataMessage:contentProto.dataMessage transaction:transaction]; [self handleIncomingEnvelope:envelope withDataMessage:contentProto.dataMessage transaction:transaction];
} else if (contentProto.hasCallMessage) { } else if (contentProto.callMessage) {
[self handleIncomingEnvelope:envelope withCallMessage:contentProto.callMessage]; [self handleIncomingEnvelope:envelope withCallMessage:contentProto.callMessage];
} else if (contentProto.hasNullMessage) { } else if (contentProto.nullMessage) {
DDLogInfo(@"%@ Received null message.", self.logTag); DDLogInfo(@"%@ Received null message.", self.logTag);
} else if (contentProto.hasReceiptMessage) { } else if (contentProto.receiptMessage) {
[self handleIncomingEnvelope:envelope [self handleIncomingEnvelope:envelope
withReceiptMessage:contentProto.receiptMessage withReceiptMessage:contentProto.receiptMessage
transaction:transaction]; transaction:transaction];
@ -369,7 +369,7 @@ NS_ASSUME_NONNULL_BEGIN
} }
} }
if (dataMessage.hasGroup) { if (dataMessage.group) {
TSGroupThread *_Nullable groupThread = TSGroupThread *_Nullable groupThread =
[TSGroupThread threadWithGroupId:dataMessage.group.id transaction:transaction]; [TSGroupThread threadWithGroupId:dataMessage.group.id transaction:transaction];
@ -486,18 +486,18 @@ NS_ASSUME_NONNULL_BEGIN
// if the app exits before this block is executed. This is fine, since the call by // if the app exits before this block is executed. This is fine, since the call by
// definition will end if the app exits. // definition will end if the app exits.
dispatch_async(dispatch_get_main_queue(), ^{ dispatch_async(dispatch_get_main_queue(), ^{
if (callMessage.hasOffer) { if (callMessage.offer) {
[self.callMessageHandler receivedOffer:callMessage.offer fromCallerId:envelope.source]; [self.callMessageHandler receivedOffer:callMessage.offer fromCallerId:envelope.source];
} else if (callMessage.hasAnswer) { } else if (callMessage.answer) {
[self.callMessageHandler receivedAnswer:callMessage.answer fromCallerId:envelope.source]; [self.callMessageHandler receivedAnswer:callMessage.answer fromCallerId:envelope.source];
} else if (callMessage.iceUpdate.count > 0) { } else if (callMessage.iceUpdate.count > 0) {
for (SSKProtoCallMessageIceUpdate *iceUpdate in callMessage.iceUpdate) { for (SSKProtoCallMessageIceUpdate *iceUpdate in callMessage.iceUpdate) {
[self.callMessageHandler receivedIceUpdate:iceUpdate fromCallerId:envelope.source]; [self.callMessageHandler receivedIceUpdate:iceUpdate fromCallerId:envelope.source];
} }
} else if (callMessage.hasHangup) { } else if (callMessage.hangup) {
DDLogVerbose(@"%@ Received CallMessage with Hangup.", self.logTag); DDLogVerbose(@"%@ Received CallMessage with Hangup.", self.logTag);
[self.callMessageHandler receivedHangup:callMessage.hangup fromCallerId:envelope.source]; [self.callMessageHandler receivedHangup:callMessage.hangup fromCallerId:envelope.source];
} else if (callMessage.hasBusy) { } else if (callMessage.busy) {
[self.callMessageHandler receivedBusy:callMessage.busy fromCallerId:envelope.source]; [self.callMessageHandler receivedBusy:callMessage.busy fromCallerId:envelope.source];
} else { } else {
OWSProdInfoWEnvelope([OWSAnalyticsEvents messageManagerErrorCallMessageNoActionablePayload], envelope); OWSProdInfoWEnvelope([OWSAnalyticsEvents messageManagerErrorCallMessageNoActionablePayload], envelope);
@ -607,7 +607,7 @@ NS_ASSUME_NONNULL_BEGIN
return; return;
} }
if (syncMessage.hasSent) { if (syncMessage.sent) {
OWSIncomingSentMessageTranscript *transcript = OWSIncomingSentMessageTranscript *transcript =
[[OWSIncomingSentMessageTranscript alloc] initWithProto:syncMessage.sent [[OWSIncomingSentMessageTranscript alloc] initWithProto:syncMessage.sent
transaction:transaction]; transaction:transaction];
@ -621,7 +621,7 @@ NS_ASSUME_NONNULL_BEGIN
if (dataMessage && destination.length > 0 && dataMessage.hasProfileKey) { if (dataMessage && destination.length > 0 && dataMessage.hasProfileKey) {
// If we observe a linked device sending our profile key to another // If we observe a linked device sending our profile key to another
// user, we can infer that that user belongs in our profile whitelist. // user, we can infer that that user belongs in our profile whitelist.
if (dataMessage.hasGroup) { if (dataMessage.group) {
[self.profileManager addGroupIdToProfileWhitelist:dataMessage.group.id]; [self.profileManager addGroupIdToProfileWhitelist:dataMessage.group.id];
} else { } else {
[self.profileManager addUserToProfileWhitelist:destination]; [self.profileManager addUserToProfileWhitelist:destination];
@ -648,7 +648,7 @@ NS_ASSUME_NONNULL_BEGIN
} }
transaction:transaction]; transaction:transaction];
} }
} else if (syncMessage.hasRequest) { } else if (syncMessage.request) {
if (syncMessage.request.type == SSKProtoSyncMessageRequestTypeContacts) { if (syncMessage.request.type == SSKProtoSyncMessageRequestTypeContacts) {
// We respond asynchronously because populating the sync message will // We respond asynchronously because populating the sync message will
// create transactions and it's not practical (due to locking in the OWSIdentityManager) // create transactions and it's not practical (due to locking in the OWSIdentityManager)
@ -717,7 +717,7 @@ NS_ASSUME_NONNULL_BEGIN
} else { } else {
DDLogWarn(@"%@ ignoring unsupported sync request message", self.logTag); DDLogWarn(@"%@ ignoring unsupported sync request message", self.logTag);
} }
} else if (syncMessage.hasBlocked) { } else if (syncMessage.blocked) {
NSArray<NSString *> *blockedPhoneNumbers = [syncMessage.blocked.numbers copy]; NSArray<NSString *> *blockedPhoneNumbers = [syncMessage.blocked.numbers copy];
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{ dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
[self.blockingManager setBlockedPhoneNumbers:blockedPhoneNumbers sendSyncMessage:NO]; [self.blockingManager setBlockedPhoneNumbers:blockedPhoneNumbers sendSyncMessage:NO];
@ -727,7 +727,7 @@ NS_ASSUME_NONNULL_BEGIN
[OWSReadReceiptManager.sharedManager processReadReceiptsFromLinkedDevice:syncMessage.read [OWSReadReceiptManager.sharedManager processReadReceiptsFromLinkedDevice:syncMessage.read
readTimestamp:envelope.timestamp readTimestamp:envelope.timestamp
transaction:transaction]; transaction:transaction];
} else if (syncMessage.hasVerified) { } else if (syncMessage.verified) {
DDLogInfo(@"%@ Received verification state for %@", self.logTag, syncMessage.verified.destination); DDLogInfo(@"%@ Received verification state for %@", self.logTag, syncMessage.verified.destination);
[self.identityManager processIncomingSyncMessage:syncMessage.verified transaction:transaction]; [self.identityManager processIncomingSyncMessage:syncMessage.verified transaction:transaction];
} else { } else {
@ -869,7 +869,7 @@ NS_ASSUME_NONNULL_BEGIN
OWSAssert(transaction); OWSAssert(transaction);
OWSAssert(dataMessage.group.type == SSKProtoGroupContextTypeRequestInfo); OWSAssert(dataMessage.group.type == SSKProtoGroupContextTypeRequestInfo);
NSData *groupId = dataMessage.hasGroup ? dataMessage.group.id : nil; NSData *groupId = dataMessage.group ? dataMessage.group.id : nil;
if (!groupId) { if (!groupId) {
OWSFail(@"Group info request is missing group id."); OWSFail(@"Group info request is missing group id.");
return; return;
@ -927,7 +927,7 @@ NS_ASSUME_NONNULL_BEGIN
uint64_t timestamp = envelope.timestamp; uint64_t timestamp = envelope.timestamp;
NSString *body = dataMessage.body; NSString *body = dataMessage.body;
NSData *groupId = dataMessage.hasGroup ? dataMessage.group.id : nil; NSData *groupId = dataMessage.group ? dataMessage.group.id : nil;
OWSContact *_Nullable contact = [OWSContacts contactForDataMessage:dataMessage transaction:transaction]; OWSContact *_Nullable contact = [OWSContacts contactForDataMessage:dataMessage transaction:transaction];
if (dataMessage.group.type == SSKProtoGroupContextTypeRequestInfo) { if (dataMessage.group.type == SSKProtoGroupContextTypeRequestInfo) {
@ -1209,8 +1209,8 @@ NS_ASSUME_NONNULL_BEGIN
- (BOOL)isDataMessageGroupAvatarUpdate:(SSKProtoDataMessage *)dataMessage - (BOOL)isDataMessageGroupAvatarUpdate:(SSKProtoDataMessage *)dataMessage
{ {
return dataMessage.hasGroup && dataMessage.group.type == SSKProtoGroupContextTypeUpdate return (dataMessage.group != nil && dataMessage.group.type == SSKProtoGroupContextTypeUpdate
&& dataMessage.group.hasAvatar; && dataMessage.group.avatar != nil);
} }
/** /**
@ -1226,7 +1226,7 @@ NS_ASSUME_NONNULL_BEGIN
OWSAssert(dataMessage); OWSAssert(dataMessage);
OWSAssert(transaction); OWSAssert(transaction);
if (dataMessage.hasGroup) { if (dataMessage.group) {
NSData *groupId = dataMessage.group.id; NSData *groupId = dataMessage.group.id;
OWSAssert(groupId.length > 0); OWSAssert(groupId.length > 0);
TSGroupThread *_Nullable groupThread = [TSGroupThread threadWithGroupId:groupId transaction:transaction]; TSGroupThread *_Nullable groupThread = [TSGroupThread threadWithGroupId:groupId transaction:transaction];

View File

@ -266,29 +266,14 @@ public enum SSKProtoError: Error {
fileprivate let proto: SignalServiceProtos_Content fileprivate let proto: SignalServiceProtos_Content
@objc public let dataMessage: SSKProtoDataMessage? @objc public let dataMessage: SSKProtoDataMessage?
@objc public var hasDataMessage: Bool {
return proto.hasDataMessage
}
@objc public let syncMessage: SSKProtoSyncMessage? @objc public let syncMessage: SSKProtoSyncMessage?
@objc public var hasSyncMessage: Bool {
return proto.hasSyncMessage
}
@objc public let callMessage: SSKProtoCallMessage? @objc public let callMessage: SSKProtoCallMessage?
@objc public var hasCallMessage: Bool {
return proto.hasCallMessage
}
@objc public let nullMessage: SSKProtoNullMessage? @objc public let nullMessage: SSKProtoNullMessage?
@objc public var hasNullMessage: Bool {
return proto.hasNullMessage
}
@objc public let receiptMessage: SSKProtoReceiptMessage? @objc public let receiptMessage: SSKProtoReceiptMessage?
@objc public var hasReceiptMessage: Bool {
return proto.hasReceiptMessage
}
private init(proto: SignalServiceProtos_Content, private init(proto: SignalServiceProtos_Content,
dataMessage: SSKProtoDataMessage?, dataMessage: SSKProtoDataMessage?,
@ -931,26 +916,14 @@ public enum SSKProtoError: Error {
fileprivate let proto: SignalServiceProtos_CallMessage fileprivate let proto: SignalServiceProtos_CallMessage
@objc public let offer: SSKProtoCallMessageOffer? @objc public let offer: SSKProtoCallMessageOffer?
@objc public var hasOffer: Bool {
return proto.hasOffer
}
@objc public let answer: SSKProtoCallMessageAnswer? @objc public let answer: SSKProtoCallMessageAnswer?
@objc public var hasAnswer: Bool {
return proto.hasAnswer
}
@objc public let iceUpdate: [SSKProtoCallMessageIceUpdate] @objc public let iceUpdate: [SSKProtoCallMessageIceUpdate]
@objc public let hangup: SSKProtoCallMessageHangup? @objc public let hangup: SSKProtoCallMessageHangup?
@objc public var hasHangup: Bool {
return proto.hasHangup
}
@objc public let busy: SSKProtoCallMessageBusy? @objc public let busy: SSKProtoCallMessageBusy?
@objc public var hasBusy: Bool {
return proto.hasBusy
}
@objc public var profileKey: Data? { @objc public var profileKey: Data? {
guard proto.hasProfileKey else { guard proto.hasProfileKey else {
@ -1100,9 +1073,6 @@ public enum SSKProtoError: Error {
fileprivate let proto: SignalServiceProtos_DataMessage.Quote.QuotedAttachment fileprivate let proto: SignalServiceProtos_DataMessage.Quote.QuotedAttachment
@objc public let thumbnail: SSKProtoAttachmentPointer? @objc public let thumbnail: SSKProtoAttachmentPointer?
@objc public var hasThumbnail: Bool {
return proto.hasThumbnail
}
@objc public var contentType: String? { @objc public var contentType: String? {
guard proto.hasContentType else { guard proto.hasContentType else {
@ -1969,9 +1939,6 @@ public enum SSKProtoError: Error {
fileprivate let proto: SignalServiceProtos_DataMessage.Contact.Avatar fileprivate let proto: SignalServiceProtos_DataMessage.Contact.Avatar
@objc public let avatar: SSKProtoAttachmentPointer? @objc public let avatar: SSKProtoAttachmentPointer?
@objc public var hasAvatar: Bool {
return proto.hasAvatar
}
@objc public var isProfile: Bool { @objc public var isProfile: Bool {
return proto.isProfile return proto.isProfile
@ -2096,9 +2063,6 @@ public enum SSKProtoError: Error {
fileprivate let proto: SignalServiceProtos_DataMessage.Contact fileprivate let proto: SignalServiceProtos_DataMessage.Contact
@objc public let name: SSKProtoDataMessageContactName? @objc public let name: SSKProtoDataMessageContactName?
@objc public var hasName: Bool {
return proto.hasName
}
@objc public let number: [SSKProtoDataMessageContactPhone] @objc public let number: [SSKProtoDataMessageContactPhone]
@ -2107,9 +2071,6 @@ public enum SSKProtoError: Error {
@objc public let address: [SSKProtoDataMessageContactPostalAddress] @objc public let address: [SSKProtoDataMessageContactPostalAddress]
@objc public let avatar: SSKProtoDataMessageContactAvatar? @objc public let avatar: SSKProtoDataMessageContactAvatar?
@objc public var hasAvatar: Bool {
return proto.hasAvatar
}
@objc public var organization: String? { @objc public var organization: String? {
guard proto.hasOrganization else { guard proto.hasOrganization else {
@ -2295,14 +2256,8 @@ public enum SSKProtoError: Error {
@objc public let attachments: [SSKProtoAttachmentPointer] @objc public let attachments: [SSKProtoAttachmentPointer]
@objc public let group: SSKProtoGroupContext? @objc public let group: SSKProtoGroupContext?
@objc public var hasGroup: Bool {
return proto.hasGroup
}
@objc public let quote: SSKProtoDataMessageQuote? @objc public let quote: SSKProtoDataMessageQuote?
@objc public var hasQuote: Bool {
return proto.hasQuote
}
@objc public let contact: [SSKProtoDataMessageContact] @objc public let contact: [SSKProtoDataMessageContact]
@ -2806,9 +2761,6 @@ public enum SSKProtoError: Error {
fileprivate let proto: SignalServiceProtos_SyncMessage.Sent fileprivate let proto: SignalServiceProtos_SyncMessage.Sent
@objc public let message: SSKProtoDataMessage? @objc public let message: SSKProtoDataMessage?
@objc public var hasMessage: Bool {
return proto.hasMessage
}
@objc public var destination: String? { @objc public var destination: String? {
guard proto.hasDestination else { guard proto.hasDestination else {
@ -3009,9 +2961,6 @@ public enum SSKProtoError: Error {
fileprivate let proto: SignalServiceProtos_SyncMessage.Groups fileprivate let proto: SignalServiceProtos_SyncMessage.Groups
@objc public let blob: SSKProtoAttachmentPointer? @objc public let blob: SSKProtoAttachmentPointer?
@objc public var hasBlob: Bool {
return proto.hasBlob
}
private init(proto: SignalServiceProtos_SyncMessage.Groups, private init(proto: SignalServiceProtos_SyncMessage.Groups,
blob: SSKProtoAttachmentPointer?) { blob: SSKProtoAttachmentPointer?) {
@ -3501,41 +3450,20 @@ public enum SSKProtoError: Error {
fileprivate let proto: SignalServiceProtos_SyncMessage fileprivate let proto: SignalServiceProtos_SyncMessage
@objc public let sent: SSKProtoSyncMessageSent? @objc public let sent: SSKProtoSyncMessageSent?
@objc public var hasSent: Bool {
return proto.hasSent
}
@objc public let contacts: SSKProtoSyncMessageContacts? @objc public let contacts: SSKProtoSyncMessageContacts?
@objc public var hasContacts: Bool {
return proto.hasContacts
}
@objc public let groups: SSKProtoSyncMessageGroups? @objc public let groups: SSKProtoSyncMessageGroups?
@objc public var hasGroups: Bool {
return proto.hasGroups
}
@objc public let request: SSKProtoSyncMessageRequest? @objc public let request: SSKProtoSyncMessageRequest?
@objc public var hasRequest: Bool {
return proto.hasRequest
}
@objc public let read: [SSKProtoSyncMessageRead] @objc public let read: [SSKProtoSyncMessageRead]
@objc public let blocked: SSKProtoSyncMessageBlocked? @objc public let blocked: SSKProtoSyncMessageBlocked?
@objc public var hasBlocked: Bool {
return proto.hasBlocked
}
@objc public let verified: SSKProtoVerified? @objc public let verified: SSKProtoVerified?
@objc public var hasVerified: Bool {
return proto.hasVerified
}
@objc public let configuration: SSKProtoSyncMessageConfiguration? @objc public let configuration: SSKProtoSyncMessageConfiguration?
@objc public var hasConfiguration: Bool {
return proto.hasConfiguration
}
@objc public var padding: Data? { @objc public var padding: Data? {
guard proto.hasPadding else { guard proto.hasPadding else {
@ -3961,9 +3889,6 @@ public enum SSKProtoError: Error {
@objc public let type: SSKProtoGroupContextType @objc public let type: SSKProtoGroupContextType
@objc public let avatar: SSKProtoAttachmentPointer? @objc public let avatar: SSKProtoAttachmentPointer?
@objc public var hasAvatar: Bool {
return proto.hasAvatar
}
@objc public var name: String? { @objc public var name: String? {
guard proto.hasName else { guard proto.hasName else {
@ -4200,14 +4125,8 @@ public enum SSKProtoError: Error {
@objc public let number: String @objc public let number: String
@objc public let avatar: SSKProtoContactDetailsAvatar? @objc public let avatar: SSKProtoContactDetailsAvatar?
@objc public var hasAvatar: Bool {
return proto.hasAvatar
}
@objc public let verified: SSKProtoVerified? @objc public let verified: SSKProtoVerified?
@objc public var hasVerified: Bool {
return proto.hasVerified
}
@objc public var name: String? { @objc public var name: String? {
guard proto.hasName else { guard proto.hasName else {
@ -4476,9 +4395,6 @@ public enum SSKProtoError: Error {
@objc public let id: Data @objc public let id: Data
@objc public let avatar: SSKProtoGroupDetailsAvatar? @objc public let avatar: SSKProtoGroupDetailsAvatar?
@objc public var hasAvatar: Bool {
return proto.hasAvatar
}
@objc public var name: String? { @objc public var name: String? {
guard proto.hasName else { guard proto.hasName else {

View File

@ -375,14 +375,8 @@ public enum WebSocketProtoError: Error {
@objc public let type: WebSocketProtoWebSocketMessageType @objc public let type: WebSocketProtoWebSocketMessageType
@objc public let request: WebSocketProtoWebSocketRequestMessage? @objc public let request: WebSocketProtoWebSocketRequestMessage?
@objc public var hasRequest: Bool {
return proto.hasRequest
}
@objc public let response: WebSocketProtoWebSocketResponseMessage? @objc public let response: WebSocketProtoWebSocketResponseMessage?
@objc public var hasResponse: Bool {
return proto.hasResponse
}
private init(proto: WebSocketProtos_WebSocketMessage, private init(proto: WebSocketProtos_WebSocketMessage,
type: WebSocketProtoWebSocketMessageType, type: WebSocketProtoWebSocketMessageType,