From b164ce94033cbaa9a8c142d2bdb44c7861d9c076 Mon Sep 17 00:00:00 2001 From: Matthew Chen Date: Wed, 1 Aug 2018 11:28:52 -0400 Subject: [PATCH 1/6] Code generate Swift wrappers for protocol buffers. --- SignalServiceKit/protobuf/Makefile | 8 + SignalServiceKit/protobuf/Provisioning.proto | 2 +- .../Protos/Generated/FingerprintProto.swift | 125 ++++++++ .../Protos/Generated/Provisioning.pb.swift | 44 ++- .../Protos/Generated/ProvisioningProto.swift | 190 +++++++++++ .../src/Protos/Generated/SignalIOSProto.swift | 145 +++++++++ .../src/Protos/Generated/WebSocketProto.swift | 298 ++++++++++++++++++ 7 files changed, 787 insertions(+), 25 deletions(-) create mode 100644 SignalServiceKit/src/Protos/Generated/FingerprintProto.swift create mode 100644 SignalServiceKit/src/Protos/Generated/ProvisioningProto.swift create mode 100644 SignalServiceKit/src/Protos/Generated/SignalIOSProto.swift create mode 100644 SignalServiceKit/src/Protos/Generated/WebSocketProto.swift diff --git a/SignalServiceKit/protobuf/Makefile b/SignalServiceKit/protobuf/Makefile index a0ae94ad1..fd5eb7ead 100644 --- a/SignalServiceKit/protobuf/Makefile +++ b/SignalServiceKit/protobuf/Makefile @@ -16,15 +16,23 @@ signal_service_protos: SignalService.proto provisioning_protos: Provisioning.proto $(PROTOC) --swift_out=../src/Protos/Generated \ Provisioning.proto + $(WRAPPER_SCRIPT) --dst-dir=../src/Protos/Generated \ + --wrapper-prefix=ProvisioningProto --proto-prefix=ProvisioningProtos --proto-file=Provisioning.proto fingerprint_protos: Fingerprint.proto $(PROTOC) --swift_out=../src/Protos/Generated \ Fingerprint.proto + $(WRAPPER_SCRIPT) --dst-dir=../src/Protos/Generated \ + --wrapper-prefix=FingerprintProto --proto-prefix=FingerprintProtos --proto-file=Fingerprint.proto websocket_protos: WebSocketResources.proto $(PROTOC) --swift_out=../src/Protos/Generated \ WebSocketResources.proto + $(WRAPPER_SCRIPT) --dst-dir=../src/Protos/Generated \ + --wrapper-prefix=WebSocketProto --proto-prefix=WebSocketProtos --proto-file=WebSocketResources.proto signal_ios_protos: SignalIOS.proto $(PROTOC) --swift_out=../src/Protos/Generated \ SignalIOS.proto + $(WRAPPER_SCRIPT) --dst-dir=../src/Protos/Generated \ + --wrapper-prefix=SignalIOSProto --proto-prefix=IOSProtos --proto-file=SignalIOS.proto diff --git a/SignalServiceKit/protobuf/Provisioning.proto b/SignalServiceKit/protobuf/Provisioning.proto index 065b94a5e..d295131c8 100644 --- a/SignalServiceKit/protobuf/Provisioning.proto +++ b/SignalServiceKit/protobuf/Provisioning.proto @@ -8,7 +8,7 @@ // the legacy proto format. syntax = "proto2"; -package ProvisioningProto; +package ProvisioningProtos; option java_package = "org.whispersystems.signalservice.internal.push"; option java_outer_classname = "ProvisioningProtos"; diff --git a/SignalServiceKit/src/Protos/Generated/FingerprintProto.swift b/SignalServiceKit/src/Protos/Generated/FingerprintProto.swift new file mode 100644 index 000000000..4048fdc56 --- /dev/null +++ b/SignalServiceKit/src/Protos/Generated/FingerprintProto.swift @@ -0,0 +1,125 @@ +// +// Copyright (c) 2018 Open Whisper Systems. All rights reserved. +// + +import Foundation + +// WARNING: This code is generated. Only edit within the markers. + +public enum FingerprintProtoError: Error { + case invalidProtobuf(description: String) +} + +// MARK: - FingerprintProtoLogicalFingerprint + +@objc public class FingerprintProtoLogicalFingerprint: NSObject { + + @objc public let identityData: Data? + + @objc public init(identityData: Data?) { + self.identityData = identityData + } + + @objc + public func serializedData() throws -> Data { + return try self.asProtobuf.serializedData() + } + + @objc public class func parseData(_ serializedData: Data) throws -> FingerprintProtoLogicalFingerprint { + let proto = try FingerprintProtos_LogicalFingerprint(serializedData: serializedData) + return try parseProto(proto) + } + + fileprivate class func parseProto(_ proto: FingerprintProtos_LogicalFingerprint) throws -> FingerprintProtoLogicalFingerprint { + var identityData: Data? = nil + if proto.hasIdentityData { + identityData = proto.identityData + } + + // MARK: - Begin Validation Logic for FingerprintProtoLogicalFingerprint - + + // MARK: - End Validation Logic for FingerprintProtoLogicalFingerprint - + + let result = FingerprintProtoLogicalFingerprint(identityData: identityData) + return result + } + + fileprivate var asProtobuf: FingerprintProtos_LogicalFingerprint { + let proto = FingerprintProtos_LogicalFingerprint.with { (builder) in + if let identityData = self.identityData { + builder.identityData = identityData + } + } + + return proto + } +} + +// MARK: - FingerprintProtoLogicalFingerprints + +@objc public class FingerprintProtoLogicalFingerprints: NSObject { + + @objc public let version: UInt32 + @objc public let localFingerprint: FingerprintProtoLogicalFingerprint? + @objc public let remoteFingerprint: FingerprintProtoLogicalFingerprint? + + @objc public init(version: UInt32, + localFingerprint: FingerprintProtoLogicalFingerprint?, + remoteFingerprint: FingerprintProtoLogicalFingerprint?) { + self.version = version + self.localFingerprint = localFingerprint + self.remoteFingerprint = remoteFingerprint + } + + @objc + public func serializedData() throws -> Data { + return try self.asProtobuf.serializedData() + } + + @objc public class func parseData(_ serializedData: Data) throws -> FingerprintProtoLogicalFingerprints { + let proto = try FingerprintProtos_LogicalFingerprints(serializedData: serializedData) + return try parseProto(proto) + } + + fileprivate class func parseProto(_ proto: FingerprintProtos_LogicalFingerprints) throws -> FingerprintProtoLogicalFingerprints { + var version: UInt32 = 0 + if proto.hasVersion { + version = proto.version + } + + var localFingerprint: FingerprintProtoLogicalFingerprint? = nil + if proto.hasLocalFingerprint { + localFingerprint = try FingerprintProtoLogicalFingerprint.parseProto(proto.localFingerprint) + } + + var remoteFingerprint: FingerprintProtoLogicalFingerprint? = nil + if proto.hasRemoteFingerprint { + remoteFingerprint = try FingerprintProtoLogicalFingerprint.parseProto(proto.remoteFingerprint) + } + + // MARK: - Begin Validation Logic for FingerprintProtoLogicalFingerprints - + + // MARK: - End Validation Logic for FingerprintProtoLogicalFingerprints - + + let result = FingerprintProtoLogicalFingerprints(version: version, + localFingerprint: localFingerprint, + remoteFingerprint: remoteFingerprint) + return result + } + + fileprivate var asProtobuf: FingerprintProtos_LogicalFingerprints { + let proto = FingerprintProtos_LogicalFingerprints.with { (builder) in + builder.version = self.version + + if let localFingerprint = self.localFingerprint { + builder.localFingerprint = localFingerprint.asProtobuf + } + + if let remoteFingerprint = self.remoteFingerprint { + builder.remoteFingerprint = remoteFingerprint.asProtobuf + } + } + + return proto + } +} diff --git a/SignalServiceKit/src/Protos/Generated/Provisioning.pb.swift b/SignalServiceKit/src/Protos/Generated/Provisioning.pb.swift index 42732a28a..3f111622a 100644 --- a/SignalServiceKit/src/Protos/Generated/Provisioning.pb.swift +++ b/SignalServiceKit/src/Protos/Generated/Provisioning.pb.swift @@ -1,10 +1,6 @@ -// DO NOT EDIT. // -// Generated by the Swift generator plugin for the protocol buffer compiler. -// Source: Provisioning.proto +// Copyright (c) 2018 Open Whisper Systems. All rights reserved. // -// For information on using the generated types, please see the documenation: -// https://github.com/apple/swift-protobuf/ //* // Copyright (C) 2014-2016 Open Whisper Systems @@ -22,12 +18,12 @@ import SwiftProtobuf // incompatible with the version of SwiftProtobuf to which you are linking. // Please ensure that your are building against the same version of the API // that was used to generate this file. -fileprivate struct _GeneratedWithProtocGenSwiftVersion: SwiftProtobuf.ProtobufAPIVersionCheck { +private struct _GeneratedWithProtocGenSwiftVersion: SwiftProtobuf.ProtobufAPIVersionCheck { struct _2: SwiftProtobuf.ProtobufAPIVersion_2 {} typealias Version = _2 } -struct ProvisioningProto_ProvisionEnvelope { +struct ProvisioningProtos_ProvisionEnvelope { // SwiftProtobuf.Message conformance is added in an extension below. See the // `Message` and `Message+*Additions` files in the SwiftProtobuf library for // methods supported on all messages. @@ -55,11 +51,11 @@ struct ProvisioningProto_ProvisionEnvelope { init() {} - fileprivate var _publicKey: Data? = nil - fileprivate var _body: Data? = nil + fileprivate var _publicKey: Data? + fileprivate var _body: Data? } -struct ProvisioningProto_ProvisionMessage { +struct ProvisioningProtos_ProvisionMessage { // SwiftProtobuf.Message conformance is added in an extension below. See the // `Message` and `Message+*Additions` files in the SwiftProtobuf library for // methods supported on all messages. @@ -131,24 +127,24 @@ struct ProvisioningProto_ProvisionMessage { init() {} - fileprivate var _identityKeyPublic: Data? = nil - fileprivate var _identityKeyPrivate: Data? = nil - fileprivate var _number: String? = nil - fileprivate var _provisioningCode: String? = nil - fileprivate var _userAgent: String? = nil - fileprivate var _profileKey: Data? = nil - fileprivate var _readReceipts: Bool? = nil + fileprivate var _identityKeyPublic: Data? + fileprivate var _identityKeyPrivate: Data? + fileprivate var _number: String? + fileprivate var _provisioningCode: String? + fileprivate var _userAgent: String? + fileprivate var _profileKey: Data? + fileprivate var _readReceipts: Bool? } // MARK: - Code below here is support for the SwiftProtobuf runtime. -fileprivate let _protobuf_package = "ProvisioningProto" +private let _protobuf_package = "ProvisioningProtos" -extension ProvisioningProto_ProvisionEnvelope: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { +extension ProvisioningProtos_ProvisionEnvelope: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { static let protoMessageName: String = _protobuf_package + ".ProvisionEnvelope" static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ 1: .same(proto: "publicKey"), - 2: .same(proto: "body"), + 2: .same(proto: "body") ] mutating func decodeMessage(decoder: inout D) throws { @@ -171,7 +167,7 @@ extension ProvisioningProto_ProvisionEnvelope: SwiftProtobuf.Message, SwiftProto try unknownFields.traverse(visitor: &visitor) } - func _protobuf_generated_isEqualTo(other: ProvisioningProto_ProvisionEnvelope) -> Bool { + func _protobuf_generated_isEqualTo(other: ProvisioningProtos_ProvisionEnvelope) -> Bool { if self._publicKey != other._publicKey {return false} if self._body != other._body {return false} if unknownFields != other.unknownFields {return false} @@ -179,7 +175,7 @@ extension ProvisioningProto_ProvisionEnvelope: SwiftProtobuf.Message, SwiftProto } } -extension ProvisioningProto_ProvisionMessage: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { +extension ProvisioningProtos_ProvisionMessage: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { static let protoMessageName: String = _protobuf_package + ".ProvisionMessage" static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ 1: .same(proto: "identityKeyPublic"), @@ -188,7 +184,7 @@ extension ProvisioningProto_ProvisionMessage: SwiftProtobuf.Message, SwiftProtob 4: .same(proto: "provisioningCode"), 5: .same(proto: "userAgent"), 6: .same(proto: "profileKey"), - 7: .same(proto: "readReceipts"), + 7: .same(proto: "readReceipts") ] mutating func decodeMessage(decoder: inout D) throws { @@ -231,7 +227,7 @@ extension ProvisioningProto_ProvisionMessage: SwiftProtobuf.Message, SwiftProtob try unknownFields.traverse(visitor: &visitor) } - func _protobuf_generated_isEqualTo(other: ProvisioningProto_ProvisionMessage) -> Bool { + func _protobuf_generated_isEqualTo(other: ProvisioningProtos_ProvisionMessage) -> Bool { if self._identityKeyPublic != other._identityKeyPublic {return false} if self._identityKeyPrivate != other._identityKeyPrivate {return false} if self._number != other._number {return false} diff --git a/SignalServiceKit/src/Protos/Generated/ProvisioningProto.swift b/SignalServiceKit/src/Protos/Generated/ProvisioningProto.swift new file mode 100644 index 000000000..e044b6c50 --- /dev/null +++ b/SignalServiceKit/src/Protos/Generated/ProvisioningProto.swift @@ -0,0 +1,190 @@ +// +// Copyright (c) 2018 Open Whisper Systems. All rights reserved. +// + +import Foundation + +// WARNING: This code is generated. Only edit within the markers. + +public enum ProvisioningProtoError: Error { + case invalidProtobuf(description: String) +} + +// MARK: - ProvisioningProtoProvisionEnvelope + +@objc public class ProvisioningProtoProvisionEnvelope: NSObject { + + @objc public let publicKey: Data? + @objc public let body: Data? + + @objc public init(publicKey: Data?, + body: Data?) { + self.publicKey = publicKey + self.body = body + } + + @objc + public func serializedData() throws -> Data { + return try self.asProtobuf.serializedData() + } + + @objc public class func parseData(_ serializedData: Data) throws -> ProvisioningProtoProvisionEnvelope { + let proto = try ProvisioningProtos_ProvisionEnvelope(serializedData: serializedData) + return try parseProto(proto) + } + + fileprivate class func parseProto(_ proto: ProvisioningProtos_ProvisionEnvelope) throws -> ProvisioningProtoProvisionEnvelope { + var publicKey: Data? = nil + if proto.hasPublicKey { + publicKey = proto.publicKey + } + + var body: Data? = nil + if proto.hasBody { + body = proto.body + } + + // MARK: - Begin Validation Logic for ProvisioningProtoProvisionEnvelope - + + // MARK: - End Validation Logic for ProvisioningProtoProvisionEnvelope - + + let result = ProvisioningProtoProvisionEnvelope(publicKey: publicKey, + body: body) + return result + } + + fileprivate var asProtobuf: ProvisioningProtos_ProvisionEnvelope { + let proto = ProvisioningProtos_ProvisionEnvelope.with { (builder) in + if let publicKey = self.publicKey { + builder.publicKey = publicKey + } + + if let body = self.body { + builder.body = body + } + } + + return proto + } +} + +// MARK: - ProvisioningProtoProvisionMessage + +@objc public class ProvisioningProtoProvisionMessage: NSObject { + + @objc public let identityKeyPublic: Data? + @objc public let identityKeyPrivate: Data? + @objc public let number: String? + @objc public let provisioningCode: String? + @objc public let userAgent: String? + @objc public let profileKey: Data? + @objc public let readReceipts: Bool + + @objc public init(identityKeyPublic: Data?, + identityKeyPrivate: Data?, + number: String?, + provisioningCode: String?, + userAgent: String?, + profileKey: Data?, + readReceipts: Bool) { + self.identityKeyPublic = identityKeyPublic + self.identityKeyPrivate = identityKeyPrivate + self.number = number + self.provisioningCode = provisioningCode + self.userAgent = userAgent + self.profileKey = profileKey + self.readReceipts = readReceipts + } + + @objc + public func serializedData() throws -> Data { + return try self.asProtobuf.serializedData() + } + + @objc public class func parseData(_ serializedData: Data) throws -> ProvisioningProtoProvisionMessage { + let proto = try ProvisioningProtos_ProvisionMessage(serializedData: serializedData) + return try parseProto(proto) + } + + fileprivate class func parseProto(_ proto: ProvisioningProtos_ProvisionMessage) throws -> ProvisioningProtoProvisionMessage { + var identityKeyPublic: Data? = nil + if proto.hasIdentityKeyPublic { + identityKeyPublic = proto.identityKeyPublic + } + + var identityKeyPrivate: Data? = nil + if proto.hasIdentityKeyPrivate { + identityKeyPrivate = proto.identityKeyPrivate + } + + var number: String? = nil + if proto.hasNumber { + number = proto.number + } + + var provisioningCode: String? = nil + if proto.hasProvisioningCode { + provisioningCode = proto.provisioningCode + } + + var userAgent: String? = nil + if proto.hasUserAgent { + userAgent = proto.userAgent + } + + var profileKey: Data? = nil + if proto.hasProfileKey { + profileKey = proto.profileKey + } + + var readReceipts: Bool = false + if proto.hasReadReceipts { + readReceipts = proto.readReceipts + } + + // MARK: - Begin Validation Logic for ProvisioningProtoProvisionMessage - + + // MARK: - End Validation Logic for ProvisioningProtoProvisionMessage - + + let result = ProvisioningProtoProvisionMessage(identityKeyPublic: identityKeyPublic, + identityKeyPrivate: identityKeyPrivate, + number: number, + provisioningCode: provisioningCode, + userAgent: userAgent, + profileKey: profileKey, + readReceipts: readReceipts) + return result + } + + fileprivate var asProtobuf: ProvisioningProtos_ProvisionMessage { + let proto = ProvisioningProtos_ProvisionMessage.with { (builder) in + if let identityKeyPublic = self.identityKeyPublic { + builder.identityKeyPublic = identityKeyPublic + } + + if let identityKeyPrivate = self.identityKeyPrivate { + builder.identityKeyPrivate = identityKeyPrivate + } + + if let number = self.number { + builder.number = number + } + + if let provisioningCode = self.provisioningCode { + builder.provisioningCode = provisioningCode + } + + if let userAgent = self.userAgent { + builder.userAgent = userAgent + } + + if let profileKey = self.profileKey { + builder.profileKey = profileKey + } + + builder.readReceipts = self.readReceipts + } + + return proto + } +} diff --git a/SignalServiceKit/src/Protos/Generated/SignalIOSProto.swift b/SignalServiceKit/src/Protos/Generated/SignalIOSProto.swift new file mode 100644 index 000000000..d79a5deef --- /dev/null +++ b/SignalServiceKit/src/Protos/Generated/SignalIOSProto.swift @@ -0,0 +1,145 @@ +// +// Copyright (c) 2018 Open Whisper Systems. All rights reserved. +// + +import Foundation + +// WARNING: This code is generated. Only edit within the markers. + +public enum SignalIOSProtoError: Error { + case invalidProtobuf(description: String) +} + +// MARK: - SignalIOSProtoBackupSnapshotBackupEntity + +@objc public class SignalIOSProtoBackupSnapshotBackupEntity: NSObject { + + // MARK: - SignalIOSProtoBackupSnapshotBackupEntityType + + @objc public enum SignalIOSProtoBackupSnapshotBackupEntityType: Int32 { + case unknown = 0 + case migration = 1 + case thread = 2 + case interaction = 3 + case attachment = 4 + } + + private class func SignalIOSProtoBackupSnapshotBackupEntityTypeWrap(_ value: IOSProtos_BackupSnapshot.BackupEntity.TypeEnum) -> SignalIOSProtoBackupSnapshotBackupEntityType { + switch value { + case .unknown: return .unknown + case .migration: return .migration + case .thread: return .thread + case .interaction: return .interaction + case .attachment: return .attachment + } + } + + private class func SignalIOSProtoBackupSnapshotBackupEntityTypeUnwrap(_ value: SignalIOSProtoBackupSnapshotBackupEntityType) -> IOSProtos_BackupSnapshot.BackupEntity.TypeEnum { + switch value { + case .unknown: return .unknown + case .migration: return .migration + case .thread: return .thread + case .interaction: return .interaction + case .attachment: return .attachment + } + } + + @objc public let type: SignalIOSProtoBackupSnapshotBackupEntityType + @objc public let entityData: Data? + + @objc public init(type: SignalIOSProtoBackupSnapshotBackupEntityType, + entityData: Data?) { + self.type = type + self.entityData = entityData + } + + @objc + public func serializedData() throws -> Data { + return try self.asProtobuf.serializedData() + } + + @objc public class func parseData(_ serializedData: Data) throws -> SignalIOSProtoBackupSnapshotBackupEntity { + let proto = try IOSProtos_BackupSnapshot.BackupEntity(serializedData: serializedData) + return try parseProto(proto) + } + + fileprivate class func parseProto(_ proto: IOSProtos_BackupSnapshot.BackupEntity) throws -> SignalIOSProtoBackupSnapshotBackupEntity { + var type: SignalIOSProtoBackupSnapshotBackupEntityType = .unknown + if proto.hasType { + type = SignalIOSProtoBackupSnapshotBackupEntityTypeWrap(proto.type) + } + + var entityData: Data? = nil + if proto.hasEntityData { + entityData = proto.entityData + } + + // MARK: - Begin Validation Logic for SignalIOSProtoBackupSnapshotBackupEntity - + + // MARK: - End Validation Logic for SignalIOSProtoBackupSnapshotBackupEntity - + + let result = SignalIOSProtoBackupSnapshotBackupEntity(type: type, + entityData: entityData) + return result + } + + fileprivate var asProtobuf: IOSProtos_BackupSnapshot.BackupEntity { + let proto = IOSProtos_BackupSnapshot.BackupEntity.with { (builder) in + builder.type = SignalIOSProtoBackupSnapshotBackupEntity.SignalIOSProtoBackupSnapshotBackupEntityTypeUnwrap(self.type) + + if let entityData = self.entityData { + builder.entityData = entityData + } + } + + return proto + } +} + +// MARK: - SignalIOSProtoBackupSnapshot + +@objc public class SignalIOSProtoBackupSnapshot: NSObject { + + @objc public let entity: [SignalIOSProtoBackupSnapshotBackupEntity] + + @objc public init(entity: [SignalIOSProtoBackupSnapshotBackupEntity]) { + self.entity = entity + } + + @objc + public func serializedData() throws -> Data { + return try self.asProtobuf.serializedData() + } + + @objc public class func parseData(_ serializedData: Data) throws -> SignalIOSProtoBackupSnapshot { + let proto = try IOSProtos_BackupSnapshot(serializedData: serializedData) + return try parseProto(proto) + } + + fileprivate class func parseProto(_ proto: IOSProtos_BackupSnapshot) throws -> SignalIOSProtoBackupSnapshot { + var entity: [SignalIOSProtoBackupSnapshotBackupEntity] = [] + for item in proto.entity { + let wrapped = try SignalIOSProtoBackupSnapshotBackupEntity.parseProto(item) + entity.append(wrapped) + } + + // MARK: - Begin Validation Logic for SignalIOSProtoBackupSnapshot - + + // MARK: - End Validation Logic for SignalIOSProtoBackupSnapshot - + + let result = SignalIOSProtoBackupSnapshot(entity: entity) + return result + } + + fileprivate var asProtobuf: IOSProtos_BackupSnapshot { + let proto = IOSProtos_BackupSnapshot.with { (builder) in + var entityUnwrapped = [IOSProtos_BackupSnapshot.BackupEntity]() + for item in entity { + entityUnwrapped.append(item.asProtobuf) + } + builder.entity = entityUnwrapped + } + + return proto + } +} diff --git a/SignalServiceKit/src/Protos/Generated/WebSocketProto.swift b/SignalServiceKit/src/Protos/Generated/WebSocketProto.swift new file mode 100644 index 000000000..57d0d7722 --- /dev/null +++ b/SignalServiceKit/src/Protos/Generated/WebSocketProto.swift @@ -0,0 +1,298 @@ +// +// Copyright (c) 2018 Open Whisper Systems. All rights reserved. +// + +import Foundation + +// WARNING: This code is generated. Only edit within the markers. + +public enum WebSocketProtoError: Error { + case invalidProtobuf(description: String) +} + +// MARK: - WebSocketProtoWebSocketRequestMessage + +@objc public class WebSocketProtoWebSocketRequestMessage: NSObject { + + @objc public let verb: String? + @objc public let path: String? + @objc public let body: Data? + @objc public let headers: [String] + @objc public let requestId: UInt64 + + @objc public init(verb: String?, + path: String?, + body: Data?, + headers: [String], + requestId: UInt64) { + self.verb = verb + self.path = path + self.body = body + self.headers = headers + self.requestId = requestId + } + + @objc + public func serializedData() throws -> Data { + return try self.asProtobuf.serializedData() + } + + @objc public class func parseData(_ serializedData: Data) throws -> WebSocketProtoWebSocketRequestMessage { + let proto = try WebSocketProtos_WebSocketRequestMessage(serializedData: serializedData) + return try parseProto(proto) + } + + fileprivate class func parseProto(_ proto: WebSocketProtos_WebSocketRequestMessage) throws -> WebSocketProtoWebSocketRequestMessage { + var verb: String? = nil + if proto.hasVerb { + verb = proto.verb + } + + var path: String? = nil + if proto.hasPath { + path = proto.path + } + + var body: Data? = nil + if proto.hasBody { + body = proto.body + } + + var headers: [String] = [] + for item in proto.headers { + let wrapped = item + headers.append(wrapped) + } + + var requestId: UInt64 = 0 + if proto.hasRequestId { + requestId = proto.requestId + } + + // MARK: - Begin Validation Logic for WebSocketProtoWebSocketRequestMessage - + + // MARK: - End Validation Logic for WebSocketProtoWebSocketRequestMessage - + + let result = WebSocketProtoWebSocketRequestMessage(verb: verb, + path: path, + body: body, + headers: headers, + requestId: requestId) + return result + } + + fileprivate var asProtobuf: WebSocketProtos_WebSocketRequestMessage { + let proto = WebSocketProtos_WebSocketRequestMessage.with { (builder) in + if let verb = self.verb { + builder.verb = verb + } + + if let path = self.path { + builder.path = path + } + + if let body = self.body { + builder.body = body + } + + var headersUnwrapped = [String]() + for item in headers { + headersUnwrapped.append(item) + } + builder.headers = headersUnwrapped + + builder.requestId = self.requestId + } + + return proto + } +} + +// MARK: - WebSocketProtoWebSocketResponseMessage + +@objc public class WebSocketProtoWebSocketResponseMessage: NSObject { + + @objc public let requestId: UInt64 + @objc public let status: UInt32 + @objc public let message: String? + @objc public let headers: [String] + @objc public let body: Data? + + @objc public init(requestId: UInt64, + status: UInt32, + message: String?, + headers: [String], + body: Data?) { + self.requestId = requestId + self.status = status + self.message = message + self.headers = headers + self.body = body + } + + @objc + public func serializedData() throws -> Data { + return try self.asProtobuf.serializedData() + } + + @objc public class func parseData(_ serializedData: Data) throws -> WebSocketProtoWebSocketResponseMessage { + let proto = try WebSocketProtos_WebSocketResponseMessage(serializedData: serializedData) + return try parseProto(proto) + } + + fileprivate class func parseProto(_ proto: WebSocketProtos_WebSocketResponseMessage) throws -> WebSocketProtoWebSocketResponseMessage { + var requestId: UInt64 = 0 + if proto.hasRequestId { + requestId = proto.requestId + } + + var status: UInt32 = 0 + if proto.hasStatus { + status = proto.status + } + + var message: String? = nil + if proto.hasMessage { + message = proto.message + } + + var headers: [String] = [] + for item in proto.headers { + let wrapped = item + headers.append(wrapped) + } + + var body: Data? = nil + if proto.hasBody { + body = proto.body + } + + // MARK: - Begin Validation Logic for WebSocketProtoWebSocketResponseMessage - + + // MARK: - End Validation Logic for WebSocketProtoWebSocketResponseMessage - + + let result = WebSocketProtoWebSocketResponseMessage(requestId: requestId, + status: status, + message: message, + headers: headers, + body: body) + return result + } + + fileprivate var asProtobuf: WebSocketProtos_WebSocketResponseMessage { + let proto = WebSocketProtos_WebSocketResponseMessage.with { (builder) in + builder.requestId = self.requestId + + builder.status = self.status + + if let message = self.message { + builder.message = message + } + + var headersUnwrapped = [String]() + for item in headers { + headersUnwrapped.append(item) + } + builder.headers = headersUnwrapped + + if let body = self.body { + builder.body = body + } + } + + return proto + } +} + +// MARK: - WebSocketProtoWebSocketMessage + +@objc public class WebSocketProtoWebSocketMessage: NSObject { + + // MARK: - WebSocketProtoWebSocketMessageType + + @objc public enum WebSocketProtoWebSocketMessageType: Int32 { + case unknown = 0 + case request = 1 + case response = 2 + } + + private class func WebSocketProtoWebSocketMessageTypeWrap(_ value: WebSocketProtos_WebSocketMessage.TypeEnum) -> WebSocketProtoWebSocketMessageType { + switch value { + case .unknown: return .unknown + case .request: return .request + case .response: return .response + } + } + + private class func WebSocketProtoWebSocketMessageTypeUnwrap(_ value: WebSocketProtoWebSocketMessageType) -> WebSocketProtos_WebSocketMessage.TypeEnum { + switch value { + case .unknown: return .unknown + case .request: return .request + case .response: return .response + } + } + + @objc public let type: WebSocketProtoWebSocketMessageType + @objc public let request: WebSocketProtoWebSocketRequestMessage? + @objc public let response: WebSocketProtoWebSocketResponseMessage? + + @objc public init(type: WebSocketProtoWebSocketMessageType, + request: WebSocketProtoWebSocketRequestMessage?, + response: WebSocketProtoWebSocketResponseMessage?) { + self.type = type + self.request = request + self.response = response + } + + @objc + public func serializedData() throws -> Data { + return try self.asProtobuf.serializedData() + } + + @objc public class func parseData(_ serializedData: Data) throws -> WebSocketProtoWebSocketMessage { + let proto = try WebSocketProtos_WebSocketMessage(serializedData: serializedData) + return try parseProto(proto) + } + + fileprivate class func parseProto(_ proto: WebSocketProtos_WebSocketMessage) throws -> WebSocketProtoWebSocketMessage { + var type: WebSocketProtoWebSocketMessageType = .unknown + if proto.hasType { + type = WebSocketProtoWebSocketMessageTypeWrap(proto.type) + } + + var request: WebSocketProtoWebSocketRequestMessage? = nil + if proto.hasRequest { + request = try WebSocketProtoWebSocketRequestMessage.parseProto(proto.request) + } + + var response: WebSocketProtoWebSocketResponseMessage? = nil + if proto.hasResponse { + response = try WebSocketProtoWebSocketResponseMessage.parseProto(proto.response) + } + + // MARK: - Begin Validation Logic for WebSocketProtoWebSocketMessage - + + // MARK: - End Validation Logic for WebSocketProtoWebSocketMessage - + + let result = WebSocketProtoWebSocketMessage(type: type, + request: request, + response: response) + return result + } + + fileprivate var asProtobuf: WebSocketProtos_WebSocketMessage { + let proto = WebSocketProtos_WebSocketMessage.with { (builder) in + builder.type = WebSocketProtoWebSocketMessage.WebSocketProtoWebSocketMessageTypeUnwrap(self.type) + + if let request = self.request { + builder.request = request.asProtobuf + } + + if let response = self.response { + builder.response = response.asProtobuf + } + } + + return proto + } +} From 377634a1f7e58e3e11fc65395b64ad0a32d50fcf Mon Sep 17 00:00:00 2001 From: Matthew Chen Date: Wed, 1 Aug 2018 11:29:46 -0400 Subject: [PATCH 2/6] Code generate Swift wrappers for protocol buffers. --- SignalServiceKit/protobuf/SignalIOS.proto | 6 ++-- .../protobuf/WebSocketResources.proto | 9 ++---- .../Protos/Generated/Provisioning.pb.swift | 32 +++++++++++-------- 3 files changed, 23 insertions(+), 24 deletions(-) diff --git a/SignalServiceKit/protobuf/SignalIOS.proto b/SignalServiceKit/protobuf/SignalIOS.proto index d118423b5..a8de17498 100644 --- a/SignalServiceKit/protobuf/SignalIOS.proto +++ b/SignalServiceKit/protobuf/SignalIOS.proto @@ -11,10 +11,8 @@ syntax = "proto2"; // iOS - package name determines class prefix package IOSProtos; -message BackupSnapshot -{ - message BackupEntity - { +message BackupSnapshot { + message BackupEntity { enum Type { UNKNOWN = 0; MIGRATION = 1; diff --git a/SignalServiceKit/protobuf/WebSocketResources.proto b/SignalServiceKit/protobuf/WebSocketResources.proto index c141d9f9c..1a4447061 100644 --- a/SignalServiceKit/protobuf/WebSocketResources.proto +++ b/SignalServiceKit/protobuf/WebSocketResources.proto @@ -14,8 +14,7 @@ package WebSocketProtos; option java_package = "org.whispersystems.signalservice.internal.websocket"; option java_outer_classname = "WebSocketProtos"; -message WebSocketRequestMessage -{ +message WebSocketRequestMessage { optional string verb = 1; optional string path = 2; optional bytes body = 3; @@ -23,8 +22,7 @@ message WebSocketRequestMessage optional uint64 requestId = 4; } -message WebSocketResponseMessage -{ +message WebSocketResponseMessage { optional uint64 requestId = 1; optional uint32 status = 2; optional string message = 3; @@ -32,8 +30,7 @@ message WebSocketResponseMessage optional bytes body = 4; } -message WebSocketMessage -{ +message WebSocketMessage { enum Type { UNKNOWN = 0; REQUEST = 1; diff --git a/SignalServiceKit/src/Protos/Generated/Provisioning.pb.swift b/SignalServiceKit/src/Protos/Generated/Provisioning.pb.swift index 3f111622a..17eebcc3b 100644 --- a/SignalServiceKit/src/Protos/Generated/Provisioning.pb.swift +++ b/SignalServiceKit/src/Protos/Generated/Provisioning.pb.swift @@ -1,6 +1,10 @@ +// DO NOT EDIT. // -// Copyright (c) 2018 Open Whisper Systems. All rights reserved. +// Generated by the Swift generator plugin for the protocol buffer compiler. +// Source: Provisioning.proto // +// For information on using the generated types, please see the documenation: +// https://github.com/apple/swift-protobuf/ //* // Copyright (C) 2014-2016 Open Whisper Systems @@ -18,7 +22,7 @@ import SwiftProtobuf // incompatible with the version of SwiftProtobuf to which you are linking. // Please ensure that your are building against the same version of the API // that was used to generate this file. -private struct _GeneratedWithProtocGenSwiftVersion: SwiftProtobuf.ProtobufAPIVersionCheck { +fileprivate struct _GeneratedWithProtocGenSwiftVersion: SwiftProtobuf.ProtobufAPIVersionCheck { struct _2: SwiftProtobuf.ProtobufAPIVersion_2 {} typealias Version = _2 } @@ -51,8 +55,8 @@ struct ProvisioningProtos_ProvisionEnvelope { init() {} - fileprivate var _publicKey: Data? - fileprivate var _body: Data? + fileprivate var _publicKey: Data? = nil + fileprivate var _body: Data? = nil } struct ProvisioningProtos_ProvisionMessage { @@ -127,24 +131,24 @@ struct ProvisioningProtos_ProvisionMessage { init() {} - fileprivate var _identityKeyPublic: Data? - fileprivate var _identityKeyPrivate: Data? - fileprivate var _number: String? - fileprivate var _provisioningCode: String? - fileprivate var _userAgent: String? - fileprivate var _profileKey: Data? - fileprivate var _readReceipts: Bool? + fileprivate var _identityKeyPublic: Data? = nil + fileprivate var _identityKeyPrivate: Data? = nil + fileprivate var _number: String? = nil + fileprivate var _provisioningCode: String? = nil + fileprivate var _userAgent: String? = nil + fileprivate var _profileKey: Data? = nil + fileprivate var _readReceipts: Bool? = nil } // MARK: - Code below here is support for the SwiftProtobuf runtime. -private let _protobuf_package = "ProvisioningProtos" +fileprivate let _protobuf_package = "ProvisioningProtos" extension ProvisioningProtos_ProvisionEnvelope: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { static let protoMessageName: String = _protobuf_package + ".ProvisionEnvelope" static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ 1: .same(proto: "publicKey"), - 2: .same(proto: "body") + 2: .same(proto: "body"), ] mutating func decodeMessage(decoder: inout D) throws { @@ -184,7 +188,7 @@ extension ProvisioningProtos_ProvisionMessage: SwiftProtobuf.Message, SwiftProto 4: .same(proto: "provisioningCode"), 5: .same(proto: "userAgent"), 6: .same(proto: "profileKey"), - 7: .same(proto: "readReceipts") + 7: .same(proto: "readReceipts"), ] mutating func decodeMessage(decoder: inout D) throws { From 0d23b06cbc048d670a9d9ff84cb9e409e2dcb09b Mon Sep 17 00:00:00 2001 From: Matthew Chen Date: Wed, 1 Aug 2018 11:44:29 -0400 Subject: [PATCH 3/6] Code generate Swift wrappers for protocol buffers. --- .../Protos/Generated/FingerprintProto.swift | 186 +++--- .../Protos/Generated/ProvisioningProto.swift | 334 +++++------ .../src/Protos/Generated/SignalIOSProto.swift | 226 ++++---- .../src/Protos/Generated/WebSocketProto.swift | 538 +++++++++--------- 4 files changed, 642 insertions(+), 642 deletions(-) diff --git a/SignalServiceKit/src/Protos/Generated/FingerprintProto.swift b/SignalServiceKit/src/Protos/Generated/FingerprintProto.swift index 4048fdc56..9c4ad211e 100644 --- a/SignalServiceKit/src/Protos/Generated/FingerprintProto.swift +++ b/SignalServiceKit/src/Protos/Generated/FingerprintProto.swift @@ -14,112 +14,112 @@ public enum FingerprintProtoError: Error { @objc public class FingerprintProtoLogicalFingerprint: NSObject { - @objc public let identityData: Data? + @objc public let identityData: Data? - @objc public init(identityData: Data?) { - self.identityData = identityData - } + @objc public init(identityData: Data?) { + self.identityData = identityData + } - @objc - public func serializedData() throws -> Data { - return try self.asProtobuf.serializedData() - } + @objc + public func serializedData() throws -> Data { + return try self.asProtobuf.serializedData() + } - @objc public class func parseData(_ serializedData: Data) throws -> FingerprintProtoLogicalFingerprint { - let proto = try FingerprintProtos_LogicalFingerprint(serializedData: serializedData) - return try parseProto(proto) - } + @objc public class func parseData(_ serializedData: Data) throws -> FingerprintProtoLogicalFingerprint { + let proto = try FingerprintProtos_LogicalFingerprint(serializedData: serializedData) + return try parseProto(proto) + } - fileprivate class func parseProto(_ proto: FingerprintProtos_LogicalFingerprint) throws -> FingerprintProtoLogicalFingerprint { - var identityData: Data? = nil - if proto.hasIdentityData { - identityData = proto.identityData - } + fileprivate class func parseProto(_ proto: FingerprintProtos_LogicalFingerprint) throws -> FingerprintProtoLogicalFingerprint { + var identityData: Data? = nil + if proto.hasIdentityData { + identityData = proto.identityData + } - // MARK: - Begin Validation Logic for FingerprintProtoLogicalFingerprint - + // MARK: - Begin Validation Logic for FingerprintProtoLogicalFingerprint - - // MARK: - End Validation Logic for FingerprintProtoLogicalFingerprint - + // MARK: - End Validation Logic for FingerprintProtoLogicalFingerprint - - let result = FingerprintProtoLogicalFingerprint(identityData: identityData) - return result - } + let result = FingerprintProtoLogicalFingerprint(identityData: identityData) + return result + } - fileprivate var asProtobuf: FingerprintProtos_LogicalFingerprint { - let proto = FingerprintProtos_LogicalFingerprint.with { (builder) in - if let identityData = self.identityData { - builder.identityData = identityData - } - } + fileprivate var asProtobuf: FingerprintProtos_LogicalFingerprint { + let proto = FingerprintProtos_LogicalFingerprint.with { (builder) in + if let identityData = self.identityData { + builder.identityData = identityData + } + } - return proto - } + return proto + } } // MARK: - FingerprintProtoLogicalFingerprints @objc public class FingerprintProtoLogicalFingerprints: NSObject { - @objc public let version: UInt32 - @objc public let localFingerprint: FingerprintProtoLogicalFingerprint? - @objc public let remoteFingerprint: FingerprintProtoLogicalFingerprint? - - @objc public init(version: UInt32, - localFingerprint: FingerprintProtoLogicalFingerprint?, - remoteFingerprint: FingerprintProtoLogicalFingerprint?) { - self.version = version - self.localFingerprint = localFingerprint - self.remoteFingerprint = remoteFingerprint - } - - @objc - public func serializedData() throws -> Data { - return try self.asProtobuf.serializedData() - } - - @objc public class func parseData(_ serializedData: Data) throws -> FingerprintProtoLogicalFingerprints { - let proto = try FingerprintProtos_LogicalFingerprints(serializedData: serializedData) - return try parseProto(proto) - } - - fileprivate class func parseProto(_ proto: FingerprintProtos_LogicalFingerprints) throws -> FingerprintProtoLogicalFingerprints { - var version: UInt32 = 0 - if proto.hasVersion { - version = proto.version - } - - var localFingerprint: FingerprintProtoLogicalFingerprint? = nil - if proto.hasLocalFingerprint { - localFingerprint = try FingerprintProtoLogicalFingerprint.parseProto(proto.localFingerprint) - } - - var remoteFingerprint: FingerprintProtoLogicalFingerprint? = nil - if proto.hasRemoteFingerprint { - remoteFingerprint = try FingerprintProtoLogicalFingerprint.parseProto(proto.remoteFingerprint) - } - - // MARK: - Begin Validation Logic for FingerprintProtoLogicalFingerprints - - - // MARK: - End Validation Logic for FingerprintProtoLogicalFingerprints - - - let result = FingerprintProtoLogicalFingerprints(version: version, - localFingerprint: localFingerprint, - remoteFingerprint: remoteFingerprint) - return result - } - - fileprivate var asProtobuf: FingerprintProtos_LogicalFingerprints { - let proto = FingerprintProtos_LogicalFingerprints.with { (builder) in - builder.version = self.version - - if let localFingerprint = self.localFingerprint { - builder.localFingerprint = localFingerprint.asProtobuf - } - - if let remoteFingerprint = self.remoteFingerprint { - builder.remoteFingerprint = remoteFingerprint.asProtobuf - } - } - - return proto - } + @objc public let version: UInt32 + @objc public let localFingerprint: FingerprintProtoLogicalFingerprint? + @objc public let remoteFingerprint: FingerprintProtoLogicalFingerprint? + + @objc public init(version: UInt32, + localFingerprint: FingerprintProtoLogicalFingerprint?, + remoteFingerprint: FingerprintProtoLogicalFingerprint?) { + self.version = version + self.localFingerprint = localFingerprint + self.remoteFingerprint = remoteFingerprint + } + + @objc + public func serializedData() throws -> Data { + return try self.asProtobuf.serializedData() + } + + @objc public class func parseData(_ serializedData: Data) throws -> FingerprintProtoLogicalFingerprints { + let proto = try FingerprintProtos_LogicalFingerprints(serializedData: serializedData) + return try parseProto(proto) + } + + fileprivate class func parseProto(_ proto: FingerprintProtos_LogicalFingerprints) throws -> FingerprintProtoLogicalFingerprints { + var version: UInt32 = 0 + if proto.hasVersion { + version = proto.version + } + + var localFingerprint: FingerprintProtoLogicalFingerprint? = nil + if proto.hasLocalFingerprint { + localFingerprint = try FingerprintProtoLogicalFingerprint.parseProto(proto.localFingerprint) + } + + var remoteFingerprint: FingerprintProtoLogicalFingerprint? = nil + if proto.hasRemoteFingerprint { + remoteFingerprint = try FingerprintProtoLogicalFingerprint.parseProto(proto.remoteFingerprint) + } + + // MARK: - Begin Validation Logic for FingerprintProtoLogicalFingerprints - + + // MARK: - End Validation Logic for FingerprintProtoLogicalFingerprints - + + let result = FingerprintProtoLogicalFingerprints(version: version, + localFingerprint: localFingerprint, + remoteFingerprint: remoteFingerprint) + return result + } + + fileprivate var asProtobuf: FingerprintProtos_LogicalFingerprints { + let proto = FingerprintProtos_LogicalFingerprints.with { (builder) in + builder.version = self.version + + if let localFingerprint = self.localFingerprint { + builder.localFingerprint = localFingerprint.asProtobuf + } + + if let remoteFingerprint = self.remoteFingerprint { + builder.remoteFingerprint = remoteFingerprint.asProtobuf + } + } + + return proto + } } diff --git a/SignalServiceKit/src/Protos/Generated/ProvisioningProto.swift b/SignalServiceKit/src/Protos/Generated/ProvisioningProto.swift index e044b6c50..bea712bc8 100644 --- a/SignalServiceKit/src/Protos/Generated/ProvisioningProto.swift +++ b/SignalServiceKit/src/Protos/Generated/ProvisioningProto.swift @@ -14,177 +14,177 @@ public enum ProvisioningProtoError: Error { @objc public class ProvisioningProtoProvisionEnvelope: NSObject { - @objc public let publicKey: Data? - @objc public let body: Data? - - @objc public init(publicKey: Data?, - body: Data?) { - self.publicKey = publicKey - self.body = body - } - - @objc - public func serializedData() throws -> Data { - return try self.asProtobuf.serializedData() - } - - @objc public class func parseData(_ serializedData: Data) throws -> ProvisioningProtoProvisionEnvelope { - let proto = try ProvisioningProtos_ProvisionEnvelope(serializedData: serializedData) - return try parseProto(proto) - } - - fileprivate class func parseProto(_ proto: ProvisioningProtos_ProvisionEnvelope) throws -> ProvisioningProtoProvisionEnvelope { - var publicKey: Data? = nil - if proto.hasPublicKey { - publicKey = proto.publicKey - } - - var body: Data? = nil - if proto.hasBody { - body = proto.body - } - - // MARK: - Begin Validation Logic for ProvisioningProtoProvisionEnvelope - - - // MARK: - End Validation Logic for ProvisioningProtoProvisionEnvelope - - - let result = ProvisioningProtoProvisionEnvelope(publicKey: publicKey, - body: body) - return result - } - - fileprivate var asProtobuf: ProvisioningProtos_ProvisionEnvelope { - let proto = ProvisioningProtos_ProvisionEnvelope.with { (builder) in - if let publicKey = self.publicKey { - builder.publicKey = publicKey - } - - if let body = self.body { - builder.body = body - } - } - - return proto - } + @objc public let publicKey: Data? + @objc public let body: Data? + + @objc public init(publicKey: Data?, + body: Data?) { + self.publicKey = publicKey + self.body = body + } + + @objc + public func serializedData() throws -> Data { + return try self.asProtobuf.serializedData() + } + + @objc public class func parseData(_ serializedData: Data) throws -> ProvisioningProtoProvisionEnvelope { + let proto = try ProvisioningProtos_ProvisionEnvelope(serializedData: serializedData) + return try parseProto(proto) + } + + fileprivate class func parseProto(_ proto: ProvisioningProtos_ProvisionEnvelope) throws -> ProvisioningProtoProvisionEnvelope { + var publicKey: Data? = nil + if proto.hasPublicKey { + publicKey = proto.publicKey + } + + var body: Data? = nil + if proto.hasBody { + body = proto.body + } + + // MARK: - Begin Validation Logic for ProvisioningProtoProvisionEnvelope - + + // MARK: - End Validation Logic for ProvisioningProtoProvisionEnvelope - + + let result = ProvisioningProtoProvisionEnvelope(publicKey: publicKey, + body: body) + return result + } + + fileprivate var asProtobuf: ProvisioningProtos_ProvisionEnvelope { + let proto = ProvisioningProtos_ProvisionEnvelope.with { (builder) in + if let publicKey = self.publicKey { + builder.publicKey = publicKey + } + + if let body = self.body { + builder.body = body + } + } + + return proto + } } // MARK: - ProvisioningProtoProvisionMessage @objc public class ProvisioningProtoProvisionMessage: NSObject { - @objc public let identityKeyPublic: Data? - @objc public let identityKeyPrivate: Data? - @objc public let number: String? - @objc public let provisioningCode: String? - @objc public let userAgent: String? - @objc public let profileKey: Data? - @objc public let readReceipts: Bool - - @objc public init(identityKeyPublic: Data?, - identityKeyPrivate: Data?, - number: String?, - provisioningCode: String?, - userAgent: String?, - profileKey: Data?, - readReceipts: Bool) { - self.identityKeyPublic = identityKeyPublic - self.identityKeyPrivate = identityKeyPrivate - self.number = number - self.provisioningCode = provisioningCode - self.userAgent = userAgent - self.profileKey = profileKey - self.readReceipts = readReceipts - } - - @objc - public func serializedData() throws -> Data { - return try self.asProtobuf.serializedData() - } - - @objc public class func parseData(_ serializedData: Data) throws -> ProvisioningProtoProvisionMessage { - let proto = try ProvisioningProtos_ProvisionMessage(serializedData: serializedData) - return try parseProto(proto) - } - - fileprivate class func parseProto(_ proto: ProvisioningProtos_ProvisionMessage) throws -> ProvisioningProtoProvisionMessage { - var identityKeyPublic: Data? = nil - if proto.hasIdentityKeyPublic { - identityKeyPublic = proto.identityKeyPublic - } - - var identityKeyPrivate: Data? = nil - if proto.hasIdentityKeyPrivate { - identityKeyPrivate = proto.identityKeyPrivate - } - - var number: String? = nil - if proto.hasNumber { - number = proto.number - } - - var provisioningCode: String? = nil - if proto.hasProvisioningCode { - provisioningCode = proto.provisioningCode - } - - var userAgent: String? = nil - if proto.hasUserAgent { - userAgent = proto.userAgent - } - - var profileKey: Data? = nil - if proto.hasProfileKey { - profileKey = proto.profileKey - } - - var readReceipts: Bool = false - if proto.hasReadReceipts { - readReceipts = proto.readReceipts - } - - // MARK: - Begin Validation Logic for ProvisioningProtoProvisionMessage - - - // MARK: - End Validation Logic for ProvisioningProtoProvisionMessage - - - let result = ProvisioningProtoProvisionMessage(identityKeyPublic: identityKeyPublic, - identityKeyPrivate: identityKeyPrivate, - number: number, - provisioningCode: provisioningCode, - userAgent: userAgent, - profileKey: profileKey, - readReceipts: readReceipts) - return result - } - - fileprivate var asProtobuf: ProvisioningProtos_ProvisionMessage { - let proto = ProvisioningProtos_ProvisionMessage.with { (builder) in - if let identityKeyPublic = self.identityKeyPublic { - builder.identityKeyPublic = identityKeyPublic - } - - if let identityKeyPrivate = self.identityKeyPrivate { - builder.identityKeyPrivate = identityKeyPrivate - } - - if let number = self.number { - builder.number = number - } - - if let provisioningCode = self.provisioningCode { - builder.provisioningCode = provisioningCode - } - - if let userAgent = self.userAgent { - builder.userAgent = userAgent - } - - if let profileKey = self.profileKey { - builder.profileKey = profileKey - } - - builder.readReceipts = self.readReceipts - } - - return proto - } + @objc public let identityKeyPublic: Data? + @objc public let identityKeyPrivate: Data? + @objc public let number: String? + @objc public let provisioningCode: String? + @objc public let userAgent: String? + @objc public let profileKey: Data? + @objc public let readReceipts: Bool + + @objc public init(identityKeyPublic: Data?, + identityKeyPrivate: Data?, + number: String?, + provisioningCode: String?, + userAgent: String?, + profileKey: Data?, + readReceipts: Bool) { + self.identityKeyPublic = identityKeyPublic + self.identityKeyPrivate = identityKeyPrivate + self.number = number + self.provisioningCode = provisioningCode + self.userAgent = userAgent + self.profileKey = profileKey + self.readReceipts = readReceipts + } + + @objc + public func serializedData() throws -> Data { + return try self.asProtobuf.serializedData() + } + + @objc public class func parseData(_ serializedData: Data) throws -> ProvisioningProtoProvisionMessage { + let proto = try ProvisioningProtos_ProvisionMessage(serializedData: serializedData) + return try parseProto(proto) + } + + fileprivate class func parseProto(_ proto: ProvisioningProtos_ProvisionMessage) throws -> ProvisioningProtoProvisionMessage { + var identityKeyPublic: Data? = nil + if proto.hasIdentityKeyPublic { + identityKeyPublic = proto.identityKeyPublic + } + + var identityKeyPrivate: Data? = nil + if proto.hasIdentityKeyPrivate { + identityKeyPrivate = proto.identityKeyPrivate + } + + var number: String? = nil + if proto.hasNumber { + number = proto.number + } + + var provisioningCode: String? = nil + if proto.hasProvisioningCode { + provisioningCode = proto.provisioningCode + } + + var userAgent: String? = nil + if proto.hasUserAgent { + userAgent = proto.userAgent + } + + var profileKey: Data? = nil + if proto.hasProfileKey { + profileKey = proto.profileKey + } + + var readReceipts: Bool = false + if proto.hasReadReceipts { + readReceipts = proto.readReceipts + } + + // MARK: - Begin Validation Logic for ProvisioningProtoProvisionMessage - + + // MARK: - End Validation Logic for ProvisioningProtoProvisionMessage - + + let result = ProvisioningProtoProvisionMessage(identityKeyPublic: identityKeyPublic, + identityKeyPrivate: identityKeyPrivate, + number: number, + provisioningCode: provisioningCode, + userAgent: userAgent, + profileKey: profileKey, + readReceipts: readReceipts) + return result + } + + fileprivate var asProtobuf: ProvisioningProtos_ProvisionMessage { + let proto = ProvisioningProtos_ProvisionMessage.with { (builder) in + if let identityKeyPublic = self.identityKeyPublic { + builder.identityKeyPublic = identityKeyPublic + } + + if let identityKeyPrivate = self.identityKeyPrivate { + builder.identityKeyPrivate = identityKeyPrivate + } + + if let number = self.number { + builder.number = number + } + + if let provisioningCode = self.provisioningCode { + builder.provisioningCode = provisioningCode + } + + if let userAgent = self.userAgent { + builder.userAgent = userAgent + } + + if let profileKey = self.profileKey { + builder.profileKey = profileKey + } + + builder.readReceipts = self.readReceipts + } + + return proto + } } diff --git a/SignalServiceKit/src/Protos/Generated/SignalIOSProto.swift b/SignalServiceKit/src/Protos/Generated/SignalIOSProto.swift index d79a5deef..ad0cb083d 100644 --- a/SignalServiceKit/src/Protos/Generated/SignalIOSProto.swift +++ b/SignalServiceKit/src/Protos/Generated/SignalIOSProto.swift @@ -14,132 +14,132 @@ public enum SignalIOSProtoError: Error { @objc public class SignalIOSProtoBackupSnapshotBackupEntity: NSObject { - // MARK: - SignalIOSProtoBackupSnapshotBackupEntityType - - @objc public enum SignalIOSProtoBackupSnapshotBackupEntityType: Int32 { - case unknown = 0 - case migration = 1 - case thread = 2 - case interaction = 3 - case attachment = 4 - } - - private class func SignalIOSProtoBackupSnapshotBackupEntityTypeWrap(_ value: IOSProtos_BackupSnapshot.BackupEntity.TypeEnum) -> SignalIOSProtoBackupSnapshotBackupEntityType { - switch value { - case .unknown: return .unknown - case .migration: return .migration - case .thread: return .thread - case .interaction: return .interaction - case .attachment: return .attachment - } - } - - private class func SignalIOSProtoBackupSnapshotBackupEntityTypeUnwrap(_ value: SignalIOSProtoBackupSnapshotBackupEntityType) -> IOSProtos_BackupSnapshot.BackupEntity.TypeEnum { - switch value { - case .unknown: return .unknown - case .migration: return .migration - case .thread: return .thread - case .interaction: return .interaction - case .attachment: return .attachment - } - } - - @objc public let type: SignalIOSProtoBackupSnapshotBackupEntityType - @objc public let entityData: Data? - - @objc public init(type: SignalIOSProtoBackupSnapshotBackupEntityType, - entityData: Data?) { - self.type = type - self.entityData = entityData - } - - @objc - public func serializedData() throws -> Data { - return try self.asProtobuf.serializedData() - } - - @objc public class func parseData(_ serializedData: Data) throws -> SignalIOSProtoBackupSnapshotBackupEntity { - let proto = try IOSProtos_BackupSnapshot.BackupEntity(serializedData: serializedData) - return try parseProto(proto) - } - - fileprivate class func parseProto(_ proto: IOSProtos_BackupSnapshot.BackupEntity) throws -> SignalIOSProtoBackupSnapshotBackupEntity { - var type: SignalIOSProtoBackupSnapshotBackupEntityType = .unknown - if proto.hasType { - type = SignalIOSProtoBackupSnapshotBackupEntityTypeWrap(proto.type) - } - - var entityData: Data? = nil - if proto.hasEntityData { - entityData = proto.entityData - } - - // MARK: - Begin Validation Logic for SignalIOSProtoBackupSnapshotBackupEntity - - - // MARK: - End Validation Logic for SignalIOSProtoBackupSnapshotBackupEntity - - - let result = SignalIOSProtoBackupSnapshotBackupEntity(type: type, - entityData: entityData) - return result - } - - fileprivate var asProtobuf: IOSProtos_BackupSnapshot.BackupEntity { - let proto = IOSProtos_BackupSnapshot.BackupEntity.with { (builder) in - builder.type = SignalIOSProtoBackupSnapshotBackupEntity.SignalIOSProtoBackupSnapshotBackupEntityTypeUnwrap(self.type) - - if let entityData = self.entityData { - builder.entityData = entityData - } - } - - return proto - } + // MARK: - SignalIOSProtoBackupSnapshotBackupEntityType + + @objc public enum SignalIOSProtoBackupSnapshotBackupEntityType: Int32 { + case unknown = 0 + case migration = 1 + case thread = 2 + case interaction = 3 + case attachment = 4 + } + + private class func SignalIOSProtoBackupSnapshotBackupEntityTypeWrap(_ value: IOSProtos_BackupSnapshot.BackupEntity.TypeEnum) -> SignalIOSProtoBackupSnapshotBackupEntityType { + switch value { + case .unknown: return .unknown + case .migration: return .migration + case .thread: return .thread + case .interaction: return .interaction + case .attachment: return .attachment + } + } + + private class func SignalIOSProtoBackupSnapshotBackupEntityTypeUnwrap(_ value: SignalIOSProtoBackupSnapshotBackupEntityType) -> IOSProtos_BackupSnapshot.BackupEntity.TypeEnum { + switch value { + case .unknown: return .unknown + case .migration: return .migration + case .thread: return .thread + case .interaction: return .interaction + case .attachment: return .attachment + } + } + + @objc public let type: SignalIOSProtoBackupSnapshotBackupEntityType + @objc public let entityData: Data? + + @objc public init(type: SignalIOSProtoBackupSnapshotBackupEntityType, + entityData: Data?) { + self.type = type + self.entityData = entityData + } + + @objc + public func serializedData() throws -> Data { + return try self.asProtobuf.serializedData() + } + + @objc public class func parseData(_ serializedData: Data) throws -> SignalIOSProtoBackupSnapshotBackupEntity { + let proto = try IOSProtos_BackupSnapshot.BackupEntity(serializedData: serializedData) + return try parseProto(proto) + } + + fileprivate class func parseProto(_ proto: IOSProtos_BackupSnapshot.BackupEntity) throws -> SignalIOSProtoBackupSnapshotBackupEntity { + var type: SignalIOSProtoBackupSnapshotBackupEntityType = .unknown + if proto.hasType { + type = SignalIOSProtoBackupSnapshotBackupEntityTypeWrap(proto.type) + } + + var entityData: Data? = nil + if proto.hasEntityData { + entityData = proto.entityData + } + + // MARK: - Begin Validation Logic for SignalIOSProtoBackupSnapshotBackupEntity - + + // MARK: - End Validation Logic for SignalIOSProtoBackupSnapshotBackupEntity - + + let result = SignalIOSProtoBackupSnapshotBackupEntity(type: type, + entityData: entityData) + return result + } + + fileprivate var asProtobuf: IOSProtos_BackupSnapshot.BackupEntity { + let proto = IOSProtos_BackupSnapshot.BackupEntity.with { (builder) in + builder.type = SignalIOSProtoBackupSnapshotBackupEntity.SignalIOSProtoBackupSnapshotBackupEntityTypeUnwrap(self.type) + + if let entityData = self.entityData { + builder.entityData = entityData + } + } + + return proto + } } // MARK: - SignalIOSProtoBackupSnapshot @objc public class SignalIOSProtoBackupSnapshot: NSObject { - @objc public let entity: [SignalIOSProtoBackupSnapshotBackupEntity] + @objc public let entity: [SignalIOSProtoBackupSnapshotBackupEntity] - @objc public init(entity: [SignalIOSProtoBackupSnapshotBackupEntity]) { - self.entity = entity - } + @objc public init(entity: [SignalIOSProtoBackupSnapshotBackupEntity]) { + self.entity = entity + } - @objc - public func serializedData() throws -> Data { - return try self.asProtobuf.serializedData() - } + @objc + public func serializedData() throws -> Data { + return try self.asProtobuf.serializedData() + } - @objc public class func parseData(_ serializedData: Data) throws -> SignalIOSProtoBackupSnapshot { - let proto = try IOSProtos_BackupSnapshot(serializedData: serializedData) - return try parseProto(proto) - } + @objc public class func parseData(_ serializedData: Data) throws -> SignalIOSProtoBackupSnapshot { + let proto = try IOSProtos_BackupSnapshot(serializedData: serializedData) + return try parseProto(proto) + } - fileprivate class func parseProto(_ proto: IOSProtos_BackupSnapshot) throws -> SignalIOSProtoBackupSnapshot { - var entity: [SignalIOSProtoBackupSnapshotBackupEntity] = [] - for item in proto.entity { - let wrapped = try SignalIOSProtoBackupSnapshotBackupEntity.parseProto(item) - entity.append(wrapped) - } + fileprivate class func parseProto(_ proto: IOSProtos_BackupSnapshot) throws -> SignalIOSProtoBackupSnapshot { + var entity: [SignalIOSProtoBackupSnapshotBackupEntity] = [] + for item in proto.entity { + let wrapped = try SignalIOSProtoBackupSnapshotBackupEntity.parseProto(item) + entity.append(wrapped) + } - // MARK: - Begin Validation Logic for SignalIOSProtoBackupSnapshot - + // MARK: - Begin Validation Logic for SignalIOSProtoBackupSnapshot - - // MARK: - End Validation Logic for SignalIOSProtoBackupSnapshot - + // MARK: - End Validation Logic for SignalIOSProtoBackupSnapshot - - let result = SignalIOSProtoBackupSnapshot(entity: entity) - return result - } + let result = SignalIOSProtoBackupSnapshot(entity: entity) + return result + } - fileprivate var asProtobuf: IOSProtos_BackupSnapshot { - let proto = IOSProtos_BackupSnapshot.with { (builder) in - var entityUnwrapped = [IOSProtos_BackupSnapshot.BackupEntity]() - for item in entity { - entityUnwrapped.append(item.asProtobuf) - } - builder.entity = entityUnwrapped - } + fileprivate var asProtobuf: IOSProtos_BackupSnapshot { + let proto = IOSProtos_BackupSnapshot.with { (builder) in + var entityUnwrapped = [IOSProtos_BackupSnapshot.BackupEntity]() + for item in entity { + entityUnwrapped.append(item.asProtobuf) + } + builder.entity = entityUnwrapped + } - return proto - } + return proto + } } diff --git a/SignalServiceKit/src/Protos/Generated/WebSocketProto.swift b/SignalServiceKit/src/Protos/Generated/WebSocketProto.swift index 57d0d7722..84ad7babe 100644 --- a/SignalServiceKit/src/Protos/Generated/WebSocketProto.swift +++ b/SignalServiceKit/src/Protos/Generated/WebSocketProto.swift @@ -14,285 +14,285 @@ public enum WebSocketProtoError: Error { @objc public class WebSocketProtoWebSocketRequestMessage: NSObject { - @objc public let verb: String? - @objc public let path: String? - @objc public let body: Data? - @objc public let headers: [String] - @objc public let requestId: UInt64 - - @objc public init(verb: String?, - path: String?, - body: Data?, - headers: [String], - requestId: UInt64) { - self.verb = verb - self.path = path - self.body = body - self.headers = headers - self.requestId = requestId - } - - @objc - public func serializedData() throws -> Data { - return try self.asProtobuf.serializedData() - } - - @objc public class func parseData(_ serializedData: Data) throws -> WebSocketProtoWebSocketRequestMessage { - let proto = try WebSocketProtos_WebSocketRequestMessage(serializedData: serializedData) - return try parseProto(proto) - } - - fileprivate class func parseProto(_ proto: WebSocketProtos_WebSocketRequestMessage) throws -> WebSocketProtoWebSocketRequestMessage { - var verb: String? = nil - if proto.hasVerb { - verb = proto.verb - } - - var path: String? = nil - if proto.hasPath { - path = proto.path - } - - var body: Data? = nil - if proto.hasBody { - body = proto.body - } - - var headers: [String] = [] - for item in proto.headers { - let wrapped = item - headers.append(wrapped) - } - - var requestId: UInt64 = 0 - if proto.hasRequestId { - requestId = proto.requestId - } - - // MARK: - Begin Validation Logic for WebSocketProtoWebSocketRequestMessage - - - // MARK: - End Validation Logic for WebSocketProtoWebSocketRequestMessage - - - let result = WebSocketProtoWebSocketRequestMessage(verb: verb, - path: path, - body: body, - headers: headers, - requestId: requestId) - return result - } - - fileprivate var asProtobuf: WebSocketProtos_WebSocketRequestMessage { - let proto = WebSocketProtos_WebSocketRequestMessage.with { (builder) in - if let verb = self.verb { - builder.verb = verb - } - - if let path = self.path { - builder.path = path - } - - if let body = self.body { - builder.body = body - } - - var headersUnwrapped = [String]() - for item in headers { - headersUnwrapped.append(item) - } - builder.headers = headersUnwrapped - - builder.requestId = self.requestId - } - - return proto - } + @objc public let verb: String? + @objc public let path: String? + @objc public let body: Data? + @objc public let headers: [String] + @objc public let requestId: UInt64 + + @objc public init(verb: String?, + path: String?, + body: Data?, + headers: [String], + requestId: UInt64) { + self.verb = verb + self.path = path + self.body = body + self.headers = headers + self.requestId = requestId + } + + @objc + public func serializedData() throws -> Data { + return try self.asProtobuf.serializedData() + } + + @objc public class func parseData(_ serializedData: Data) throws -> WebSocketProtoWebSocketRequestMessage { + let proto = try WebSocketProtos_WebSocketRequestMessage(serializedData: serializedData) + return try parseProto(proto) + } + + fileprivate class func parseProto(_ proto: WebSocketProtos_WebSocketRequestMessage) throws -> WebSocketProtoWebSocketRequestMessage { + var verb: String? = nil + if proto.hasVerb { + verb = proto.verb + } + + var path: String? = nil + if proto.hasPath { + path = proto.path + } + + var body: Data? = nil + if proto.hasBody { + body = proto.body + } + + var headers: [String] = [] + for item in proto.headers { + let wrapped = item + headers.append(wrapped) + } + + var requestId: UInt64 = 0 + if proto.hasRequestId { + requestId = proto.requestId + } + + // MARK: - Begin Validation Logic for WebSocketProtoWebSocketRequestMessage - + + // MARK: - End Validation Logic for WebSocketProtoWebSocketRequestMessage - + + let result = WebSocketProtoWebSocketRequestMessage(verb: verb, + path: path, + body: body, + headers: headers, + requestId: requestId) + return result + } + + fileprivate var asProtobuf: WebSocketProtos_WebSocketRequestMessage { + let proto = WebSocketProtos_WebSocketRequestMessage.with { (builder) in + if let verb = self.verb { + builder.verb = verb + } + + if let path = self.path { + builder.path = path + } + + if let body = self.body { + builder.body = body + } + + var headersUnwrapped = [String]() + for item in headers { + headersUnwrapped.append(item) + } + builder.headers = headersUnwrapped + + builder.requestId = self.requestId + } + + return proto + } } // MARK: - WebSocketProtoWebSocketResponseMessage @objc public class WebSocketProtoWebSocketResponseMessage: NSObject { - @objc public let requestId: UInt64 - @objc public let status: UInt32 - @objc public let message: String? - @objc public let headers: [String] - @objc public let body: Data? - - @objc public init(requestId: UInt64, - status: UInt32, - message: String?, - headers: [String], - body: Data?) { - self.requestId = requestId - self.status = status - self.message = message - self.headers = headers - self.body = body - } - - @objc - public func serializedData() throws -> Data { - return try self.asProtobuf.serializedData() - } - - @objc public class func parseData(_ serializedData: Data) throws -> WebSocketProtoWebSocketResponseMessage { - let proto = try WebSocketProtos_WebSocketResponseMessage(serializedData: serializedData) - return try parseProto(proto) - } - - fileprivate class func parseProto(_ proto: WebSocketProtos_WebSocketResponseMessage) throws -> WebSocketProtoWebSocketResponseMessage { - var requestId: UInt64 = 0 - if proto.hasRequestId { - requestId = proto.requestId - } - - var status: UInt32 = 0 - if proto.hasStatus { - status = proto.status - } - - var message: String? = nil - if proto.hasMessage { - message = proto.message - } - - var headers: [String] = [] - for item in proto.headers { - let wrapped = item - headers.append(wrapped) - } - - var body: Data? = nil - if proto.hasBody { - body = proto.body - } - - // MARK: - Begin Validation Logic for WebSocketProtoWebSocketResponseMessage - - - // MARK: - End Validation Logic for WebSocketProtoWebSocketResponseMessage - - - let result = WebSocketProtoWebSocketResponseMessage(requestId: requestId, - status: status, - message: message, - headers: headers, - body: body) - return result - } - - fileprivate var asProtobuf: WebSocketProtos_WebSocketResponseMessage { - let proto = WebSocketProtos_WebSocketResponseMessage.with { (builder) in - builder.requestId = self.requestId - - builder.status = self.status - - if let message = self.message { - builder.message = message - } - - var headersUnwrapped = [String]() - for item in headers { - headersUnwrapped.append(item) - } - builder.headers = headersUnwrapped - - if let body = self.body { - builder.body = body - } - } - - return proto - } + @objc public let requestId: UInt64 + @objc public let status: UInt32 + @objc public let message: String? + @objc public let headers: [String] + @objc public let body: Data? + + @objc public init(requestId: UInt64, + status: UInt32, + message: String?, + headers: [String], + body: Data?) { + self.requestId = requestId + self.status = status + self.message = message + self.headers = headers + self.body = body + } + + @objc + public func serializedData() throws -> Data { + return try self.asProtobuf.serializedData() + } + + @objc public class func parseData(_ serializedData: Data) throws -> WebSocketProtoWebSocketResponseMessage { + let proto = try WebSocketProtos_WebSocketResponseMessage(serializedData: serializedData) + return try parseProto(proto) + } + + fileprivate class func parseProto(_ proto: WebSocketProtos_WebSocketResponseMessage) throws -> WebSocketProtoWebSocketResponseMessage { + var requestId: UInt64 = 0 + if proto.hasRequestId { + requestId = proto.requestId + } + + var status: UInt32 = 0 + if proto.hasStatus { + status = proto.status + } + + var message: String? = nil + if proto.hasMessage { + message = proto.message + } + + var headers: [String] = [] + for item in proto.headers { + let wrapped = item + headers.append(wrapped) + } + + var body: Data? = nil + if proto.hasBody { + body = proto.body + } + + // MARK: - Begin Validation Logic for WebSocketProtoWebSocketResponseMessage - + + // MARK: - End Validation Logic for WebSocketProtoWebSocketResponseMessage - + + let result = WebSocketProtoWebSocketResponseMessage(requestId: requestId, + status: status, + message: message, + headers: headers, + body: body) + return result + } + + fileprivate var asProtobuf: WebSocketProtos_WebSocketResponseMessage { + let proto = WebSocketProtos_WebSocketResponseMessage.with { (builder) in + builder.requestId = self.requestId + + builder.status = self.status + + if let message = self.message { + builder.message = message + } + + var headersUnwrapped = [String]() + for item in headers { + headersUnwrapped.append(item) + } + builder.headers = headersUnwrapped + + if let body = self.body { + builder.body = body + } + } + + return proto + } } // MARK: - WebSocketProtoWebSocketMessage @objc public class WebSocketProtoWebSocketMessage: NSObject { - // MARK: - WebSocketProtoWebSocketMessageType - - @objc public enum WebSocketProtoWebSocketMessageType: Int32 { - case unknown = 0 - case request = 1 - case response = 2 - } - - private class func WebSocketProtoWebSocketMessageTypeWrap(_ value: WebSocketProtos_WebSocketMessage.TypeEnum) -> WebSocketProtoWebSocketMessageType { - switch value { - case .unknown: return .unknown - case .request: return .request - case .response: return .response - } - } - - private class func WebSocketProtoWebSocketMessageTypeUnwrap(_ value: WebSocketProtoWebSocketMessageType) -> WebSocketProtos_WebSocketMessage.TypeEnum { - switch value { - case .unknown: return .unknown - case .request: return .request - case .response: return .response - } - } - - @objc public let type: WebSocketProtoWebSocketMessageType - @objc public let request: WebSocketProtoWebSocketRequestMessage? - @objc public let response: WebSocketProtoWebSocketResponseMessage? - - @objc public init(type: WebSocketProtoWebSocketMessageType, - request: WebSocketProtoWebSocketRequestMessage?, - response: WebSocketProtoWebSocketResponseMessage?) { - self.type = type - self.request = request - self.response = response - } - - @objc - public func serializedData() throws -> Data { - return try self.asProtobuf.serializedData() - } - - @objc public class func parseData(_ serializedData: Data) throws -> WebSocketProtoWebSocketMessage { - let proto = try WebSocketProtos_WebSocketMessage(serializedData: serializedData) - return try parseProto(proto) - } - - fileprivate class func parseProto(_ proto: WebSocketProtos_WebSocketMessage) throws -> WebSocketProtoWebSocketMessage { - var type: WebSocketProtoWebSocketMessageType = .unknown - if proto.hasType { - type = WebSocketProtoWebSocketMessageTypeWrap(proto.type) - } - - var request: WebSocketProtoWebSocketRequestMessage? = nil - if proto.hasRequest { - request = try WebSocketProtoWebSocketRequestMessage.parseProto(proto.request) - } - - var response: WebSocketProtoWebSocketResponseMessage? = nil - if proto.hasResponse { - response = try WebSocketProtoWebSocketResponseMessage.parseProto(proto.response) - } - - // MARK: - Begin Validation Logic for WebSocketProtoWebSocketMessage - - - // MARK: - End Validation Logic for WebSocketProtoWebSocketMessage - - - let result = WebSocketProtoWebSocketMessage(type: type, - request: request, - response: response) - return result - } - - fileprivate var asProtobuf: WebSocketProtos_WebSocketMessage { - let proto = WebSocketProtos_WebSocketMessage.with { (builder) in - builder.type = WebSocketProtoWebSocketMessage.WebSocketProtoWebSocketMessageTypeUnwrap(self.type) - - if let request = self.request { - builder.request = request.asProtobuf - } - - if let response = self.response { - builder.response = response.asProtobuf - } - } - - return proto - } + // MARK: - WebSocketProtoWebSocketMessageType + + @objc public enum WebSocketProtoWebSocketMessageType: Int32 { + case unknown = 0 + case request = 1 + case response = 2 + } + + private class func WebSocketProtoWebSocketMessageTypeWrap(_ value: WebSocketProtos_WebSocketMessage.TypeEnum) -> WebSocketProtoWebSocketMessageType { + switch value { + case .unknown: return .unknown + case .request: return .request + case .response: return .response + } + } + + private class func WebSocketProtoWebSocketMessageTypeUnwrap(_ value: WebSocketProtoWebSocketMessageType) -> WebSocketProtos_WebSocketMessage.TypeEnum { + switch value { + case .unknown: return .unknown + case .request: return .request + case .response: return .response + } + } + + @objc public let type: WebSocketProtoWebSocketMessageType + @objc public let request: WebSocketProtoWebSocketRequestMessage? + @objc public let response: WebSocketProtoWebSocketResponseMessage? + + @objc public init(type: WebSocketProtoWebSocketMessageType, + request: WebSocketProtoWebSocketRequestMessage?, + response: WebSocketProtoWebSocketResponseMessage?) { + self.type = type + self.request = request + self.response = response + } + + @objc + public func serializedData() throws -> Data { + return try self.asProtobuf.serializedData() + } + + @objc public class func parseData(_ serializedData: Data) throws -> WebSocketProtoWebSocketMessage { + let proto = try WebSocketProtos_WebSocketMessage(serializedData: serializedData) + return try parseProto(proto) + } + + fileprivate class func parseProto(_ proto: WebSocketProtos_WebSocketMessage) throws -> WebSocketProtoWebSocketMessage { + var type: WebSocketProtoWebSocketMessageType = .unknown + if proto.hasType { + type = WebSocketProtoWebSocketMessageTypeWrap(proto.type) + } + + var request: WebSocketProtoWebSocketRequestMessage? = nil + if proto.hasRequest { + request = try WebSocketProtoWebSocketRequestMessage.parseProto(proto.request) + } + + var response: WebSocketProtoWebSocketResponseMessage? = nil + if proto.hasResponse { + response = try WebSocketProtoWebSocketResponseMessage.parseProto(proto.response) + } + + // MARK: - Begin Validation Logic for WebSocketProtoWebSocketMessage - + + // MARK: - End Validation Logic for WebSocketProtoWebSocketMessage - + + let result = WebSocketProtoWebSocketMessage(type: type, + request: request, + response: response) + return result + } + + fileprivate var asProtobuf: WebSocketProtos_WebSocketMessage { + let proto = WebSocketProtos_WebSocketMessage.with { (builder) in + builder.type = WebSocketProtoWebSocketMessage.WebSocketProtoWebSocketMessageTypeUnwrap(self.type) + + if let request = self.request { + builder.request = request.asProtobuf + } + + if let response = self.response { + builder.response = response.asProtobuf + } + } + + return proto + } } From e1eb58ba3b7bc7b19730ea2500034518ab658244 Mon Sep 17 00:00:00 2001 From: Matthew Chen Date: Thu, 2 Aug 2018 14:28:13 -0400 Subject: [PATCH 4/6] Swift proto parsing wrappers. --- .../Protos/Generated/FingerprintProto.swift | 122 +++--- .../Protos/Generated/ProvisioningProto.swift | 270 +++++++------ .../src/Protos/Generated/SignalIOSProto.swift | 116 +++--- .../src/Protos/Generated/WebSocketProto.swift | 356 ++++++++++-------- 4 files changed, 489 insertions(+), 375 deletions(-) diff --git a/SignalServiceKit/src/Protos/Generated/FingerprintProto.swift b/SignalServiceKit/src/Protos/Generated/FingerprintProto.swift index 9c4ad211e..532567529 100644 --- a/SignalServiceKit/src/Protos/Generated/FingerprintProto.swift +++ b/SignalServiceKit/src/Protos/Generated/FingerprintProto.swift @@ -14,15 +14,43 @@ public enum FingerprintProtoError: Error { @objc public class FingerprintProtoLogicalFingerprint: NSObject { - @objc public let identityData: Data? + // MARK: - FingerprintProtoLogicalFingerprintBuilder - @objc public init(identityData: Data?) { - self.identityData = identityData + @objc public class FingerprintProtoLogicalFingerprintBuilder: NSObject { + + private var proto = FingerprintProtos_LogicalFingerprint() + + @objc public override init() {} + + @objc public func setIdentityData(_ valueParam: Data) { + proto.identityData = valueParam + } + + @objc public func build() throws -> FingerprintProtoLogicalFingerprint { + let wrapper = try FingerprintProtoLogicalFingerprint.parseProto(proto) + return wrapper + } + } + + fileprivate let proto: FingerprintProtos_LogicalFingerprint + + @objc public var identityData: Data? { + guard proto.hasIdentityData else { + return nil + } + return proto.identityData + } + @objc public var hasIdentityData: Bool { + return proto.hasIdentityData + } + + private init(proto: FingerprintProtos_LogicalFingerprint) { + self.proto = proto } @objc public func serializedData() throws -> Data { - return try self.asProtobuf.serializedData() + return try self.proto.serializedData() } @objc public class func parseData(_ serializedData: Data) throws -> FingerprintProtoLogicalFingerprint { @@ -31,49 +59,68 @@ public enum FingerprintProtoError: Error { } fileprivate class func parseProto(_ proto: FingerprintProtos_LogicalFingerprint) throws -> FingerprintProtoLogicalFingerprint { - var identityData: Data? = nil - if proto.hasIdentityData { - identityData = proto.identityData - } - // MARK: - Begin Validation Logic for FingerprintProtoLogicalFingerprint - // MARK: - End Validation Logic for FingerprintProtoLogicalFingerprint - - let result = FingerprintProtoLogicalFingerprint(identityData: identityData) + let result = FingerprintProtoLogicalFingerprint(proto: proto) return result } - - fileprivate var asProtobuf: FingerprintProtos_LogicalFingerprint { - let proto = FingerprintProtos_LogicalFingerprint.with { (builder) in - if let identityData = self.identityData { - builder.identityData = identityData - } - } - - return proto - } } // MARK: - FingerprintProtoLogicalFingerprints @objc public class FingerprintProtoLogicalFingerprints: NSObject { - @objc public let version: UInt32 + // MARK: - FingerprintProtoLogicalFingerprintsBuilder + + @objc public class FingerprintProtoLogicalFingerprintsBuilder: NSObject { + + private var proto = FingerprintProtos_LogicalFingerprints() + + @objc public override init() {} + + @objc public func setVersion(_ valueParam: UInt32) { + proto.version = valueParam + } + + @objc public func setLocalFingerprint(_ valueParam: FingerprintProtoLogicalFingerprint) { + proto.localFingerprint = valueParam.proto + } + + @objc public func setRemoteFingerprint(_ valueParam: FingerprintProtoLogicalFingerprint) { + proto.remoteFingerprint = valueParam.proto + } + + @objc public func build() throws -> FingerprintProtoLogicalFingerprints { + let wrapper = try FingerprintProtoLogicalFingerprints.parseProto(proto) + return wrapper + } + } + + fileprivate let proto: FingerprintProtos_LogicalFingerprints + @objc public let localFingerprint: FingerprintProtoLogicalFingerprint? @objc public let remoteFingerprint: FingerprintProtoLogicalFingerprint? - @objc public init(version: UInt32, - localFingerprint: FingerprintProtoLogicalFingerprint?, - remoteFingerprint: FingerprintProtoLogicalFingerprint?) { - self.version = version + @objc public var version: UInt32 { + return proto.version + } + @objc public var hasVersion: Bool { + return proto.hasVersion + } + + private init(proto: FingerprintProtos_LogicalFingerprints, + localFingerprint: FingerprintProtoLogicalFingerprint?, + remoteFingerprint: FingerprintProtoLogicalFingerprint?) { + self.proto = proto self.localFingerprint = localFingerprint self.remoteFingerprint = remoteFingerprint } @objc public func serializedData() throws -> Data { - return try self.asProtobuf.serializedData() + return try self.proto.serializedData() } @objc public class func parseData(_ serializedData: Data) throws -> FingerprintProtoLogicalFingerprints { @@ -82,11 +129,6 @@ public enum FingerprintProtoError: Error { } fileprivate class func parseProto(_ proto: FingerprintProtos_LogicalFingerprints) throws -> FingerprintProtoLogicalFingerprints { - var version: UInt32 = 0 - if proto.hasVersion { - version = proto.version - } - var localFingerprint: FingerprintProtoLogicalFingerprint? = nil if proto.hasLocalFingerprint { localFingerprint = try FingerprintProtoLogicalFingerprint.parseProto(proto.localFingerprint) @@ -101,25 +143,9 @@ public enum FingerprintProtoError: Error { // MARK: - End Validation Logic for FingerprintProtoLogicalFingerprints - - let result = FingerprintProtoLogicalFingerprints(version: version, + let result = FingerprintProtoLogicalFingerprints(proto: proto, localFingerprint: localFingerprint, remoteFingerprint: remoteFingerprint) return result } - - fileprivate var asProtobuf: FingerprintProtos_LogicalFingerprints { - let proto = FingerprintProtos_LogicalFingerprints.with { (builder) in - builder.version = self.version - - if let localFingerprint = self.localFingerprint { - builder.localFingerprint = localFingerprint.asProtobuf - } - - if let remoteFingerprint = self.remoteFingerprint { - builder.remoteFingerprint = remoteFingerprint.asProtobuf - } - } - - return proto - } } diff --git a/SignalServiceKit/src/Protos/Generated/ProvisioningProto.swift b/SignalServiceKit/src/Protos/Generated/ProvisioningProto.swift index bea712bc8..4ee0f76fc 100644 --- a/SignalServiceKit/src/Protos/Generated/ProvisioningProto.swift +++ b/SignalServiceKit/src/Protos/Generated/ProvisioningProto.swift @@ -14,18 +14,57 @@ public enum ProvisioningProtoError: Error { @objc public class ProvisioningProtoProvisionEnvelope: NSObject { - @objc public let publicKey: Data? - @objc public let body: Data? + // MARK: - ProvisioningProtoProvisionEnvelopeBuilder - @objc public init(publicKey: Data?, - body: Data?) { - self.publicKey = publicKey - self.body = body + @objc public class ProvisioningProtoProvisionEnvelopeBuilder: NSObject { + + private var proto = ProvisioningProtos_ProvisionEnvelope() + + @objc public override init() {} + + @objc public func setPublicKey(_ valueParam: Data) { + proto.publicKey = valueParam + } + + @objc public func setBody(_ valueParam: Data) { + proto.body = valueParam + } + + @objc public func build() throws -> ProvisioningProtoProvisionEnvelope { + let wrapper = try ProvisioningProtoProvisionEnvelope.parseProto(proto) + return wrapper + } + } + + fileprivate let proto: ProvisioningProtos_ProvisionEnvelope + + @objc public var publicKey: Data? { + guard proto.hasPublicKey else { + return nil + } + return proto.publicKey + } + @objc public var hasPublicKey: Bool { + return proto.hasPublicKey + } + + @objc public var body: Data? { + guard proto.hasBody else { + return nil + } + return proto.body + } + @objc public var hasBody: Bool { + return proto.hasBody + } + + private init(proto: ProvisioningProtos_ProvisionEnvelope) { + self.proto = proto } @objc public func serializedData() throws -> Data { - return try self.asProtobuf.serializedData() + return try self.proto.serializedData() } @objc public class func parseData(_ serializedData: Data) throws -> ProvisioningProtoProvisionEnvelope { @@ -34,157 +73,150 @@ public enum ProvisioningProtoError: Error { } fileprivate class func parseProto(_ proto: ProvisioningProtos_ProvisionEnvelope) throws -> ProvisioningProtoProvisionEnvelope { - var publicKey: Data? = nil - if proto.hasPublicKey { - publicKey = proto.publicKey - } - - var body: Data? = nil - if proto.hasBody { - body = proto.body - } - // MARK: - Begin Validation Logic for ProvisioningProtoProvisionEnvelope - // MARK: - End Validation Logic for ProvisioningProtoProvisionEnvelope - - let result = ProvisioningProtoProvisionEnvelope(publicKey: publicKey, - body: body) + let result = ProvisioningProtoProvisionEnvelope(proto: proto) return result } - - fileprivate var asProtobuf: ProvisioningProtos_ProvisionEnvelope { - let proto = ProvisioningProtos_ProvisionEnvelope.with { (builder) in - if let publicKey = self.publicKey { - builder.publicKey = publicKey - } - - if let body = self.body { - builder.body = body - } - } - - return proto - } } // MARK: - ProvisioningProtoProvisionMessage @objc public class ProvisioningProtoProvisionMessage: NSObject { - @objc public let identityKeyPublic: Data? - @objc public let identityKeyPrivate: Data? - @objc public let number: String? - @objc public let provisioningCode: String? - @objc public let userAgent: String? - @objc public let profileKey: Data? - @objc public let readReceipts: Bool - - @objc public init(identityKeyPublic: Data?, - identityKeyPrivate: Data?, - number: String?, - provisioningCode: String?, - userAgent: String?, - profileKey: Data?, - readReceipts: Bool) { - self.identityKeyPublic = identityKeyPublic - self.identityKeyPrivate = identityKeyPrivate - self.number = number - self.provisioningCode = provisioningCode - self.userAgent = userAgent - self.profileKey = profileKey - self.readReceipts = readReceipts - } + // MARK: - ProvisioningProtoProvisionMessageBuilder - @objc - public func serializedData() throws -> Data { - return try self.asProtobuf.serializedData() - } + @objc public class ProvisioningProtoProvisionMessageBuilder: NSObject { - @objc public class func parseData(_ serializedData: Data) throws -> ProvisioningProtoProvisionMessage { - let proto = try ProvisioningProtos_ProvisionMessage(serializedData: serializedData) - return try parseProto(proto) - } + private var proto = ProvisioningProtos_ProvisionMessage() - fileprivate class func parseProto(_ proto: ProvisioningProtos_ProvisionMessage) throws -> ProvisioningProtoProvisionMessage { - var identityKeyPublic: Data? = nil - if proto.hasIdentityKeyPublic { - identityKeyPublic = proto.identityKeyPublic + @objc public override init() {} + + @objc public func setIdentityKeyPublic(_ valueParam: Data) { + proto.identityKeyPublic = valueParam } - var identityKeyPrivate: Data? = nil - if proto.hasIdentityKeyPrivate { - identityKeyPrivate = proto.identityKeyPrivate + @objc public func setIdentityKeyPrivate(_ valueParam: Data) { + proto.identityKeyPrivate = valueParam } - var number: String? = nil - if proto.hasNumber { - number = proto.number + @objc public func setNumber(_ valueParam: String) { + proto.number = valueParam } - var provisioningCode: String? = nil - if proto.hasProvisioningCode { - provisioningCode = proto.provisioningCode + @objc public func setProvisioningCode(_ valueParam: String) { + proto.provisioningCode = valueParam } - var userAgent: String? = nil - if proto.hasUserAgent { - userAgent = proto.userAgent + @objc public func setUserAgent(_ valueParam: String) { + proto.userAgent = valueParam } - var profileKey: Data? = nil - if proto.hasProfileKey { - profileKey = proto.profileKey + @objc public func setProfileKey(_ valueParam: Data) { + proto.profileKey = valueParam } - var readReceipts: Bool = false - if proto.hasReadReceipts { - readReceipts = proto.readReceipts + @objc public func setReadReceipts(_ valueParam: Bool) { + proto.readReceipts = valueParam } - // MARK: - Begin Validation Logic for ProvisioningProtoProvisionMessage - + @objc public func build() throws -> ProvisioningProtoProvisionMessage { + let wrapper = try ProvisioningProtoProvisionMessage.parseProto(proto) + return wrapper + } + } - // MARK: - End Validation Logic for ProvisioningProtoProvisionMessage - + fileprivate let proto: ProvisioningProtos_ProvisionMessage - let result = ProvisioningProtoProvisionMessage(identityKeyPublic: identityKeyPublic, - identityKeyPrivate: identityKeyPrivate, - number: number, - provisioningCode: provisioningCode, - userAgent: userAgent, - profileKey: profileKey, - readReceipts: readReceipts) - return result + @objc public var identityKeyPublic: Data? { + guard proto.hasIdentityKeyPublic else { + return nil + } + return proto.identityKeyPublic + } + @objc public var hasIdentityKeyPublic: Bool { + return proto.hasIdentityKeyPublic } - fileprivate var asProtobuf: ProvisioningProtos_ProvisionMessage { - let proto = ProvisioningProtos_ProvisionMessage.with { (builder) in - if let identityKeyPublic = self.identityKeyPublic { - builder.identityKeyPublic = identityKeyPublic - } + @objc public var identityKeyPrivate: Data? { + guard proto.hasIdentityKeyPrivate else { + return nil + } + return proto.identityKeyPrivate + } + @objc public var hasIdentityKeyPrivate: Bool { + return proto.hasIdentityKeyPrivate + } - if let identityKeyPrivate = self.identityKeyPrivate { - builder.identityKeyPrivate = identityKeyPrivate - } + @objc public var number: String? { + guard proto.hasNumber else { + return nil + } + return proto.number + } + @objc public var hasNumber: Bool { + return proto.hasNumber + } - if let number = self.number { - builder.number = number - } + @objc public var provisioningCode: String? { + guard proto.hasProvisioningCode else { + return nil + } + return proto.provisioningCode + } + @objc public var hasProvisioningCode: Bool { + return proto.hasProvisioningCode + } - if let provisioningCode = self.provisioningCode { - builder.provisioningCode = provisioningCode - } + @objc public var userAgent: String? { + guard proto.hasUserAgent else { + return nil + } + return proto.userAgent + } + @objc public var hasUserAgent: Bool { + return proto.hasUserAgent + } - if let userAgent = self.userAgent { - builder.userAgent = userAgent - } + @objc public var profileKey: Data? { + guard proto.hasProfileKey else { + return nil + } + return proto.profileKey + } + @objc public var hasProfileKey: Bool { + return proto.hasProfileKey + } - if let profileKey = self.profileKey { - builder.profileKey = profileKey - } + @objc public var readReceipts: Bool { + return proto.readReceipts + } + @objc public var hasReadReceipts: Bool { + return proto.hasReadReceipts + } - builder.readReceipts = self.readReceipts - } + private init(proto: ProvisioningProtos_ProvisionMessage) { + self.proto = proto + } + + @objc + public func serializedData() throws -> Data { + return try self.proto.serializedData() + } - return proto + @objc public class func parseData(_ serializedData: Data) throws -> ProvisioningProtoProvisionMessage { + let proto = try ProvisioningProtos_ProvisionMessage(serializedData: serializedData) + return try parseProto(proto) + } + + fileprivate class func parseProto(_ proto: ProvisioningProtos_ProvisionMessage) throws -> ProvisioningProtoProvisionMessage { + // MARK: - Begin Validation Logic for ProvisioningProtoProvisionMessage - + + // MARK: - End Validation Logic for ProvisioningProtoProvisionMessage - + + let result = ProvisioningProtoProvisionMessage(proto: proto) + return result } } diff --git a/SignalServiceKit/src/Protos/Generated/SignalIOSProto.swift b/SignalServiceKit/src/Protos/Generated/SignalIOSProto.swift index ad0cb083d..b5f6402d9 100644 --- a/SignalServiceKit/src/Protos/Generated/SignalIOSProto.swift +++ b/SignalServiceKit/src/Protos/Generated/SignalIOSProto.swift @@ -44,18 +44,54 @@ public enum SignalIOSProtoError: Error { } } - @objc public let type: SignalIOSProtoBackupSnapshotBackupEntityType - @objc public let entityData: Data? + // MARK: - SignalIOSProtoBackupSnapshotBackupEntityBuilder - @objc public init(type: SignalIOSProtoBackupSnapshotBackupEntityType, - entityData: Data?) { - self.type = type - self.entityData = entityData + @objc public class SignalIOSProtoBackupSnapshotBackupEntityBuilder: NSObject { + + private var proto = IOSProtos_BackupSnapshot.BackupEntity() + + @objc public override init() {} + + @objc public func setType(_ valueParam: SignalIOSProtoBackupSnapshotBackupEntityType) { + proto.type = SignalIOSProtoBackupSnapshotBackupEntityTypeUnwrap(valueParam) + } + + @objc public func setEntityData(_ valueParam: Data) { + proto.entityData = valueParam + } + + @objc public func build() throws -> SignalIOSProtoBackupSnapshotBackupEntity { + let wrapper = try SignalIOSProtoBackupSnapshotBackupEntity.parseProto(proto) + return wrapper + } + } + + fileprivate let proto: IOSProtos_BackupSnapshot.BackupEntity + + @objc public var type: SignalIOSProtoBackupSnapshotBackupEntityType { + return SignalIOSProtoBackupSnapshotBackupEntity.SignalIOSProtoBackupSnapshotBackupEntityTypeWrap(proto.type) + } + @objc public var hasType: Bool { + return proto.hasType + } + + @objc public var entityData: Data? { + guard proto.hasEntityData else { + return nil + } + return proto.entityData + } + @objc public var hasEntityData: Bool { + return proto.hasEntityData + } + + private init(proto: IOSProtos_BackupSnapshot.BackupEntity) { + self.proto = proto } @objc public func serializedData() throws -> Data { - return try self.asProtobuf.serializedData() + return try self.proto.serializedData() } @objc public class func parseData(_ serializedData: Data) throws -> SignalIOSProtoBackupSnapshotBackupEntity { @@ -64,51 +100,52 @@ public enum SignalIOSProtoError: Error { } fileprivate class func parseProto(_ proto: IOSProtos_BackupSnapshot.BackupEntity) throws -> SignalIOSProtoBackupSnapshotBackupEntity { - var type: SignalIOSProtoBackupSnapshotBackupEntityType = .unknown - if proto.hasType { - type = SignalIOSProtoBackupSnapshotBackupEntityTypeWrap(proto.type) - } - - var entityData: Data? = nil - if proto.hasEntityData { - entityData = proto.entityData - } - // MARK: - Begin Validation Logic for SignalIOSProtoBackupSnapshotBackupEntity - // MARK: - End Validation Logic for SignalIOSProtoBackupSnapshotBackupEntity - - let result = SignalIOSProtoBackupSnapshotBackupEntity(type: type, - entityData: entityData) + let result = SignalIOSProtoBackupSnapshotBackupEntity(proto: proto) return result } +} + +// MARK: - SignalIOSProtoBackupSnapshot + +@objc public class SignalIOSProtoBackupSnapshot: NSObject { + + // MARK: - SignalIOSProtoBackupSnapshotBuilder + + @objc public class SignalIOSProtoBackupSnapshotBuilder: NSObject { + + private var proto = IOSProtos_BackupSnapshot() - fileprivate var asProtobuf: IOSProtos_BackupSnapshot.BackupEntity { - let proto = IOSProtos_BackupSnapshot.BackupEntity.with { (builder) in - builder.type = SignalIOSProtoBackupSnapshotBackupEntity.SignalIOSProtoBackupSnapshotBackupEntityTypeUnwrap(self.type) + @objc public override init() {} - if let entityData = self.entityData { - builder.entityData = entityData - } + @objc public func addEntity(_ valueParam: SignalIOSProtoBackupSnapshotBackupEntity) { + var items = proto.entity + items.append(valueParam.proto) + proto.entity = items } - return proto + @objc public func build() throws -> SignalIOSProtoBackupSnapshot { + let wrapper = try SignalIOSProtoBackupSnapshot.parseProto(proto) + return wrapper + } } -} -// MARK: - SignalIOSProtoBackupSnapshot - -@objc public class SignalIOSProtoBackupSnapshot: NSObject { + fileprivate let proto: IOSProtos_BackupSnapshot @objc public let entity: [SignalIOSProtoBackupSnapshotBackupEntity] - @objc public init(entity: [SignalIOSProtoBackupSnapshotBackupEntity]) { + private init(proto: IOSProtos_BackupSnapshot, + entity: [SignalIOSProtoBackupSnapshotBackupEntity]) { + self.proto = proto self.entity = entity } @objc public func serializedData() throws -> Data { - return try self.asProtobuf.serializedData() + return try self.proto.serializedData() } @objc public class func parseData(_ serializedData: Data) throws -> SignalIOSProtoBackupSnapshot { @@ -127,19 +164,8 @@ public enum SignalIOSProtoError: Error { // MARK: - End Validation Logic for SignalIOSProtoBackupSnapshot - - let result = SignalIOSProtoBackupSnapshot(entity: entity) + let result = SignalIOSProtoBackupSnapshot(proto: proto, + entity: entity) return result } - - fileprivate var asProtobuf: IOSProtos_BackupSnapshot { - let proto = IOSProtos_BackupSnapshot.with { (builder) in - var entityUnwrapped = [IOSProtos_BackupSnapshot.BackupEntity]() - for item in entity { - entityUnwrapped.append(item.asProtobuf) - } - builder.entity = entityUnwrapped - } - - return proto - } } diff --git a/SignalServiceKit/src/Protos/Generated/WebSocketProto.swift b/SignalServiceKit/src/Protos/Generated/WebSocketProto.swift index 84ad7babe..1ad72bad8 100644 --- a/SignalServiceKit/src/Protos/Generated/WebSocketProto.swift +++ b/SignalServiceKit/src/Protos/Generated/WebSocketProto.swift @@ -14,97 +14,106 @@ public enum WebSocketProtoError: Error { @objc public class WebSocketProtoWebSocketRequestMessage: NSObject { - @objc public let verb: String? - @objc public let path: String? - @objc public let body: Data? - @objc public let headers: [String] - @objc public let requestId: UInt64 - - @objc public init(verb: String?, - path: String?, - body: Data?, - headers: [String], - requestId: UInt64) { - self.verb = verb - self.path = path - self.body = body - self.headers = headers - self.requestId = requestId - } + // MARK: - WebSocketProtoWebSocketRequestMessageBuilder - @objc - public func serializedData() throws -> Data { - return try self.asProtobuf.serializedData() - } + @objc public class WebSocketProtoWebSocketRequestMessageBuilder: NSObject { - @objc public class func parseData(_ serializedData: Data) throws -> WebSocketProtoWebSocketRequestMessage { - let proto = try WebSocketProtos_WebSocketRequestMessage(serializedData: serializedData) - return try parseProto(proto) - } + private var proto = WebSocketProtos_WebSocketRequestMessage() - fileprivate class func parseProto(_ proto: WebSocketProtos_WebSocketRequestMessage) throws -> WebSocketProtoWebSocketRequestMessage { - var verb: String? = nil - if proto.hasVerb { - verb = proto.verb + @objc public override init() {} + + @objc public func setVerb(_ valueParam: String) { + proto.verb = valueParam } - var path: String? = nil - if proto.hasPath { - path = proto.path + @objc public func setPath(_ valueParam: String) { + proto.path = valueParam } - var body: Data? = nil - if proto.hasBody { - body = proto.body + @objc public func setBody(_ valueParam: Data) { + proto.body = valueParam } - var headers: [String] = [] - for item in proto.headers { - let wrapped = item - headers.append(wrapped) + @objc public func addHeaders(_ valueParam: String) { + var items = proto.headers + items.append(valueParam) + proto.headers = items } - var requestId: UInt64 = 0 - if proto.hasRequestId { - requestId = proto.requestId + @objc public func setRequestId(_ valueParam: UInt64) { + proto.requestId = valueParam } - // MARK: - Begin Validation Logic for WebSocketProtoWebSocketRequestMessage - + @objc public func build() throws -> WebSocketProtoWebSocketRequestMessage { + let wrapper = try WebSocketProtoWebSocketRequestMessage.parseProto(proto) + return wrapper + } + } - // MARK: - End Validation Logic for WebSocketProtoWebSocketRequestMessage - + fileprivate let proto: WebSocketProtos_WebSocketRequestMessage - let result = WebSocketProtoWebSocketRequestMessage(verb: verb, - path: path, - body: body, - headers: headers, - requestId: requestId) - return result + @objc public var verb: String? { + guard proto.hasVerb else { + return nil + } + return proto.verb + } + @objc public var hasVerb: Bool { + return proto.hasVerb } - fileprivate var asProtobuf: WebSocketProtos_WebSocketRequestMessage { - let proto = WebSocketProtos_WebSocketRequestMessage.with { (builder) in - if let verb = self.verb { - builder.verb = verb - } + @objc public var path: String? { + guard proto.hasPath else { + return nil + } + return proto.path + } + @objc public var hasPath: Bool { + return proto.hasPath + } - if let path = self.path { - builder.path = path - } + @objc public var body: Data? { + guard proto.hasBody else { + return nil + } + return proto.body + } + @objc public var hasBody: Bool { + return proto.hasBody + } - if let body = self.body { - builder.body = body - } + @objc public var headers: [String] { + return proto.headers + } - var headersUnwrapped = [String]() - for item in headers { - headersUnwrapped.append(item) - } - builder.headers = headersUnwrapped + @objc public var requestId: UInt64 { + return proto.requestId + } + @objc public var hasRequestId: Bool { + return proto.hasRequestId + } - builder.requestId = self.requestId - } + private init(proto: WebSocketProtos_WebSocketRequestMessage) { + self.proto = proto + } - return proto + @objc + public func serializedData() throws -> Data { + return try self.proto.serializedData() + } + + @objc public class func parseData(_ serializedData: Data) throws -> WebSocketProtoWebSocketRequestMessage { + let proto = try WebSocketProtos_WebSocketRequestMessage(serializedData: serializedData) + return try parseProto(proto) + } + + fileprivate class func parseProto(_ proto: WebSocketProtos_WebSocketRequestMessage) throws -> WebSocketProtoWebSocketRequestMessage { + // MARK: - Begin Validation Logic for WebSocketProtoWebSocketRequestMessage - + + // MARK: - End Validation Logic for WebSocketProtoWebSocketRequestMessage - + + let result = WebSocketProtoWebSocketRequestMessage(proto: proto) + return result } } @@ -112,95 +121,103 @@ public enum WebSocketProtoError: Error { @objc public class WebSocketProtoWebSocketResponseMessage: NSObject { - @objc public let requestId: UInt64 - @objc public let status: UInt32 - @objc public let message: String? - @objc public let headers: [String] - @objc public let body: Data? + // MARK: - WebSocketProtoWebSocketResponseMessageBuilder - @objc public init(requestId: UInt64, - status: UInt32, - message: String?, - headers: [String], - body: Data?) { - self.requestId = requestId - self.status = status - self.message = message - self.headers = headers - self.body = body - } + @objc public class WebSocketProtoWebSocketResponseMessageBuilder: NSObject { - @objc - public func serializedData() throws -> Data { - return try self.asProtobuf.serializedData() - } + private var proto = WebSocketProtos_WebSocketResponseMessage() - @objc public class func parseData(_ serializedData: Data) throws -> WebSocketProtoWebSocketResponseMessage { - let proto = try WebSocketProtos_WebSocketResponseMessage(serializedData: serializedData) - return try parseProto(proto) - } + @objc public override init() {} - fileprivate class func parseProto(_ proto: WebSocketProtos_WebSocketResponseMessage) throws -> WebSocketProtoWebSocketResponseMessage { - var requestId: UInt64 = 0 - if proto.hasRequestId { - requestId = proto.requestId + @objc public func setRequestId(_ valueParam: UInt64) { + proto.requestId = valueParam } - var status: UInt32 = 0 - if proto.hasStatus { - status = proto.status + @objc public func setStatus(_ valueParam: UInt32) { + proto.status = valueParam } - var message: String? = nil - if proto.hasMessage { - message = proto.message + @objc public func setMessage(_ valueParam: String) { + proto.message = valueParam } - var headers: [String] = [] - for item in proto.headers { - let wrapped = item - headers.append(wrapped) + @objc public func addHeaders(_ valueParam: String) { + var items = proto.headers + items.append(valueParam) + proto.headers = items } - var body: Data? = nil - if proto.hasBody { - body = proto.body + @objc public func setBody(_ valueParam: Data) { + proto.body = valueParam } - // MARK: - Begin Validation Logic for WebSocketProtoWebSocketResponseMessage - + @objc public func build() throws -> WebSocketProtoWebSocketResponseMessage { + let wrapper = try WebSocketProtoWebSocketResponseMessage.parseProto(proto) + return wrapper + } + } - // MARK: - End Validation Logic for WebSocketProtoWebSocketResponseMessage - + fileprivate let proto: WebSocketProtos_WebSocketResponseMessage - let result = WebSocketProtoWebSocketResponseMessage(requestId: requestId, - status: status, - message: message, - headers: headers, - body: body) - return result + @objc public var requestId: UInt64 { + return proto.requestId + } + @objc public var hasRequestId: Bool { + return proto.hasRequestId } - fileprivate var asProtobuf: WebSocketProtos_WebSocketResponseMessage { - let proto = WebSocketProtos_WebSocketResponseMessage.with { (builder) in - builder.requestId = self.requestId - - builder.status = self.status + @objc public var status: UInt32 { + return proto.status + } + @objc public var hasStatus: Bool { + return proto.hasStatus + } - if let message = self.message { - builder.message = message - } + @objc public var message: String? { + guard proto.hasMessage else { + return nil + } + return proto.message + } + @objc public var hasMessage: Bool { + return proto.hasMessage + } - var headersUnwrapped = [String]() - for item in headers { - headersUnwrapped.append(item) - } - builder.headers = headersUnwrapped + @objc public var headers: [String] { + return proto.headers + } - if let body = self.body { - builder.body = body - } + @objc public var body: Data? { + guard proto.hasBody else { + return nil } + return proto.body + } + @objc public var hasBody: Bool { + return proto.hasBody + } + + private init(proto: WebSocketProtos_WebSocketResponseMessage) { + self.proto = proto + } + + @objc + public func serializedData() throws -> Data { + return try self.proto.serializedData() + } + + @objc public class func parseData(_ serializedData: Data) throws -> WebSocketProtoWebSocketResponseMessage { + let proto = try WebSocketProtos_WebSocketResponseMessage(serializedData: serializedData) + return try parseProto(proto) + } + + fileprivate class func parseProto(_ proto: WebSocketProtos_WebSocketResponseMessage) throws -> WebSocketProtoWebSocketResponseMessage { + // MARK: - Begin Validation Logic for WebSocketProtoWebSocketResponseMessage - + + // MARK: - End Validation Logic for WebSocketProtoWebSocketResponseMessage - - return proto + let result = WebSocketProtoWebSocketResponseMessage(proto: proto) + return result } } @@ -232,21 +249,55 @@ public enum WebSocketProtoError: Error { } } - @objc public let type: WebSocketProtoWebSocketMessageType + // MARK: - WebSocketProtoWebSocketMessageBuilder + + @objc public class WebSocketProtoWebSocketMessageBuilder: NSObject { + + private var proto = WebSocketProtos_WebSocketMessage() + + @objc public override init() {} + + @objc public func setType(_ valueParam: WebSocketProtoWebSocketMessageType) { + proto.type = WebSocketProtoWebSocketMessageTypeUnwrap(valueParam) + } + + @objc public func setRequest(_ valueParam: WebSocketProtoWebSocketRequestMessage) { + proto.request = valueParam.proto + } + + @objc public func setResponse(_ valueParam: WebSocketProtoWebSocketResponseMessage) { + proto.response = valueParam.proto + } + + @objc public func build() throws -> WebSocketProtoWebSocketMessage { + let wrapper = try WebSocketProtoWebSocketMessage.parseProto(proto) + return wrapper + } + } + + fileprivate let proto: WebSocketProtos_WebSocketMessage + @objc public let request: WebSocketProtoWebSocketRequestMessage? @objc public let response: WebSocketProtoWebSocketResponseMessage? - @objc public init(type: WebSocketProtoWebSocketMessageType, - request: WebSocketProtoWebSocketRequestMessage?, - response: WebSocketProtoWebSocketResponseMessage?) { - self.type = type + @objc public var type: WebSocketProtoWebSocketMessageType { + return WebSocketProtoWebSocketMessage.WebSocketProtoWebSocketMessageTypeWrap(proto.type) + } + @objc public var hasType: Bool { + return proto.hasType + } + + private init(proto: WebSocketProtos_WebSocketMessage, + request: WebSocketProtoWebSocketRequestMessage?, + response: WebSocketProtoWebSocketResponseMessage?) { + self.proto = proto self.request = request self.response = response } @objc public func serializedData() throws -> Data { - return try self.asProtobuf.serializedData() + return try self.proto.serializedData() } @objc public class func parseData(_ serializedData: Data) throws -> WebSocketProtoWebSocketMessage { @@ -255,11 +306,6 @@ public enum WebSocketProtoError: Error { } fileprivate class func parseProto(_ proto: WebSocketProtos_WebSocketMessage) throws -> WebSocketProtoWebSocketMessage { - var type: WebSocketProtoWebSocketMessageType = .unknown - if proto.hasType { - type = WebSocketProtoWebSocketMessageTypeWrap(proto.type) - } - var request: WebSocketProtoWebSocketRequestMessage? = nil if proto.hasRequest { request = try WebSocketProtoWebSocketRequestMessage.parseProto(proto.request) @@ -274,25 +320,9 @@ public enum WebSocketProtoError: Error { // MARK: - End Validation Logic for WebSocketProtoWebSocketMessage - - let result = WebSocketProtoWebSocketMessage(type: type, + let result = WebSocketProtoWebSocketMessage(proto: proto, request: request, response: response) return result } - - fileprivate var asProtobuf: WebSocketProtos_WebSocketMessage { - let proto = WebSocketProtos_WebSocketMessage.with { (builder) in - builder.type = WebSocketProtoWebSocketMessage.WebSocketProtoWebSocketMessageTypeUnwrap(self.type) - - if let request = self.request { - builder.request = request.asProtobuf - } - - if let response = self.response { - builder.response = response.asProtobuf - } - } - - return proto - } } From 28acea3cf0577c6defc14fc4d0cb57652cbf891c Mon Sep 17 00:00:00 2001 From: Matthew Chen Date: Fri, 3 Aug 2018 14:03:02 -0400 Subject: [PATCH 5/6] Respond to CR. --- Scripts/ProtoWrappers.py | 7 +- SignalServiceKit/protobuf/Fingerprint.proto | 4 + SignalServiceKit/protobuf/Provisioning.proto | 9 + SignalServiceKit/protobuf/SignalIOS.proto | 2 + .../protobuf/WebSocketResources.proto | 7 + .../src/Protos/Generated/Fingerprint.pb.swift | 5 +- .../Protos/Generated/FingerprintProto.swift | 58 +++--- .../Protos/Generated/Provisioning.pb.swift | 10 +- .../Protos/Generated/ProvisioningProto.swift | 166 +++++++++--------- .../src/Protos/Generated/SignalIOS.pb.swift | 2 + .../src/Protos/Generated/SignalIOSProto.swift | 38 ++-- .../src/Protos/Generated/WebSocketProto.swift | 135 +++++++------- .../Generated/WebSocketResources.pb.swift | 7 + 13 files changed, 252 insertions(+), 198 deletions(-) diff --git a/Scripts/ProtoWrappers.py b/Scripts/ProtoWrappers.py index 9c5d56113..83e91349b 100755 --- a/Scripts/ProtoWrappers.py +++ b/Scripts/ProtoWrappers.py @@ -19,6 +19,7 @@ def lowerCamlCaseForUnderscoredText(name): splits[0] = splits[0].lower() return ''.join(splits) + # The generated code for "Apple Swift Protos" suppresses # adjacent capital letters in lowerCamlCase. def lowerCamlCaseForUnderscoredText_wrapped(name): @@ -29,7 +30,11 @@ def lowerCamlCaseForUnderscoredText_wrapped(name): char = char.lower() chars.append(char) lastWasUpper = (char.upper() == char) - return ''.join(chars) + result = ''.join(chars) + if result.endswith('Id'): + result = result[:-2] + 'ID' + return result + class WriterContext: def __init__(self, proto_name, swift_name, parent=None): diff --git a/SignalServiceKit/protobuf/Fingerprint.proto b/SignalServiceKit/protobuf/Fingerprint.proto index 22a8e6541..1464c4b8d 100644 --- a/SignalServiceKit/protobuf/Fingerprint.proto +++ b/SignalServiceKit/protobuf/Fingerprint.proto @@ -9,12 +9,16 @@ option java_package = "org.whispersystems.libsignal.fingerprint"; option java_outer_classname = "FingerprintProtos"; message LogicalFingerprint { + // @required optional bytes identityData = 1; // optional bytes identifier = 2; } message LogicalFingerprints { + // @required optional uint32 version = 1; + // @required optional LogicalFingerprint localFingerprint = 2; + // @required optional LogicalFingerprint remoteFingerprint = 3; } diff --git a/SignalServiceKit/protobuf/Provisioning.proto b/SignalServiceKit/protobuf/Provisioning.proto index d295131c8..cd80a1d3f 100644 --- a/SignalServiceKit/protobuf/Provisioning.proto +++ b/SignalServiceKit/protobuf/Provisioning.proto @@ -14,16 +14,25 @@ option java_package = "org.whispersystems.signalservice.internal.push"; option java_outer_classname = "ProvisioningProtos"; message ProvisionEnvelope { + // @required optional bytes publicKey = 1; + // @required optional bytes body = 2; // Encrypted ProvisionMessage } message ProvisionMessage { + // @required optional bytes identityKeyPublic = 1; + // @required optional bytes identityKeyPrivate = 2; + // @required optional string number = 3; + // @required optional string provisioningCode = 4; + // @required optional string userAgent = 5; + // @required optional bytes profileKey = 6; + // @required optional bool readReceipts = 7; } diff --git a/SignalServiceKit/protobuf/SignalIOS.proto b/SignalServiceKit/protobuf/SignalIOS.proto index a8de17498..c71732a02 100644 --- a/SignalServiceKit/protobuf/SignalIOS.proto +++ b/SignalServiceKit/protobuf/SignalIOS.proto @@ -20,7 +20,9 @@ message BackupSnapshot { INTERACTION = 3; ATTACHMENT = 4; } + // @required optional Type type = 1; + // @required optional bytes entityData = 2; } diff --git a/SignalServiceKit/protobuf/WebSocketResources.proto b/SignalServiceKit/protobuf/WebSocketResources.proto index 1a4447061..bb354a746 100644 --- a/SignalServiceKit/protobuf/WebSocketResources.proto +++ b/SignalServiceKit/protobuf/WebSocketResources.proto @@ -15,18 +15,24 @@ option java_package = "org.whispersystems.signalservice.internal.websocket"; option java_outer_classname = "WebSocketProtos"; message WebSocketRequestMessage { + // @required optional string verb = 1; + // @required optional string path = 2; optional bytes body = 3; repeated string headers = 5; + // @required optional uint64 requestId = 4; } message WebSocketResponseMessage { + // @required optional uint64 requestId = 1; + // @required optional uint32 status = 2; optional string message = 3; repeated string headers = 5; + // @required optional bytes body = 4; } @@ -37,6 +43,7 @@ message WebSocketMessage { RESPONSE = 2; } + // @required optional Type type = 1; optional WebSocketRequestMessage request = 2; optional WebSocketResponseMessage response = 3; diff --git a/SignalServiceKit/src/Protos/Generated/Fingerprint.pb.swift b/SignalServiceKit/src/Protos/Generated/Fingerprint.pb.swift index 7357c3085..96304b197 100644 --- a/SignalServiceKit/src/Protos/Generated/Fingerprint.pb.swift +++ b/SignalServiceKit/src/Protos/Generated/Fingerprint.pb.swift @@ -27,7 +27,7 @@ struct FingerprintProtos_LogicalFingerprint { // `Message` and `Message+*Additions` files in the SwiftProtobuf library for // methods supported on all messages. - /// optional bytes identifier = 2; + /// @required var identityData: Data { get {return _identityData ?? SwiftProtobuf.Internal.emptyData} set {_identityData = newValue} @@ -49,6 +49,7 @@ struct FingerprintProtos_LogicalFingerprints { // `Message` and `Message+*Additions` files in the SwiftProtobuf library for // methods supported on all messages. + /// @required var version: UInt32 { get {return _storage._version ?? 0} set {_uniqueStorage()._version = newValue} @@ -58,6 +59,7 @@ struct FingerprintProtos_LogicalFingerprints { /// Clears the value of `version`. Subsequent reads from it will return its default value. mutating func clearVersion() {_storage._version = nil} + /// @required var localFingerprint: FingerprintProtos_LogicalFingerprint { get {return _storage._localFingerprint ?? FingerprintProtos_LogicalFingerprint()} set {_uniqueStorage()._localFingerprint = newValue} @@ -67,6 +69,7 @@ struct FingerprintProtos_LogicalFingerprints { /// Clears the value of `localFingerprint`. Subsequent reads from it will return its default value. mutating func clearLocalFingerprint() {_storage._localFingerprint = nil} + /// @required var remoteFingerprint: FingerprintProtos_LogicalFingerprint { get {return _storage._remoteFingerprint ?? FingerprintProtos_LogicalFingerprint()} set {_uniqueStorage()._remoteFingerprint = newValue} diff --git a/SignalServiceKit/src/Protos/Generated/FingerprintProto.swift b/SignalServiceKit/src/Protos/Generated/FingerprintProto.swift index 532567529..29a0aeda6 100644 --- a/SignalServiceKit/src/Protos/Generated/FingerprintProto.swift +++ b/SignalServiceKit/src/Protos/Generated/FingerprintProto.swift @@ -34,18 +34,12 @@ public enum FingerprintProtoError: Error { fileprivate let proto: FingerprintProtos_LogicalFingerprint - @objc public var identityData: Data? { - guard proto.hasIdentityData else { - return nil - } - return proto.identityData - } - @objc public var hasIdentityData: Bool { - return proto.hasIdentityData - } + @objc public let identityData: Data - private init(proto: FingerprintProtos_LogicalFingerprint) { + private init(proto: FingerprintProtos_LogicalFingerprint, + identityData: Data) { self.proto = proto + self.identityData = identityData } @objc @@ -59,11 +53,17 @@ public enum FingerprintProtoError: Error { } fileprivate class func parseProto(_ proto: FingerprintProtos_LogicalFingerprint) throws -> FingerprintProtoLogicalFingerprint { + guard proto.hasIdentityData else { + throw FingerprintProtoError.invalidProtobuf(description: "\(logTag) missing required field: identityData") + } + let identityData = proto.identityData + // MARK: - Begin Validation Logic for FingerprintProtoLogicalFingerprint - // MARK: - End Validation Logic for FingerprintProtoLogicalFingerprint - - let result = FingerprintProtoLogicalFingerprint(proto: proto) + let result = FingerprintProtoLogicalFingerprint(proto: proto, + identityData: identityData) return result } } @@ -100,20 +100,16 @@ public enum FingerprintProtoError: Error { fileprivate let proto: FingerprintProtos_LogicalFingerprints - @objc public let localFingerprint: FingerprintProtoLogicalFingerprint? - @objc public let remoteFingerprint: FingerprintProtoLogicalFingerprint? - - @objc public var version: UInt32 { - return proto.version - } - @objc public var hasVersion: Bool { - return proto.hasVersion - } + @objc public let version: UInt32 + @objc public let localFingerprint: FingerprintProtoLogicalFingerprint + @objc public let remoteFingerprint: FingerprintProtoLogicalFingerprint private init(proto: FingerprintProtos_LogicalFingerprints, - localFingerprint: FingerprintProtoLogicalFingerprint?, - remoteFingerprint: FingerprintProtoLogicalFingerprint?) { + version: UInt32, + localFingerprint: FingerprintProtoLogicalFingerprint, + remoteFingerprint: FingerprintProtoLogicalFingerprint) { self.proto = proto + self.version = version self.localFingerprint = localFingerprint self.remoteFingerprint = remoteFingerprint } @@ -129,21 +125,27 @@ public enum FingerprintProtoError: Error { } fileprivate class func parseProto(_ proto: FingerprintProtos_LogicalFingerprints) throws -> FingerprintProtoLogicalFingerprints { - var localFingerprint: FingerprintProtoLogicalFingerprint? = nil - if proto.hasLocalFingerprint { - localFingerprint = try FingerprintProtoLogicalFingerprint.parseProto(proto.localFingerprint) + guard proto.hasVersion else { + throw FingerprintProtoError.invalidProtobuf(description: "\(logTag) missing required field: version") + } + let version = proto.version + + guard proto.hasLocalFingerprint else { + throw FingerprintProtoError.invalidProtobuf(description: "\(logTag) missing required field: localFingerprint") } + let localFingerprint = try FingerprintProtoLogicalFingerprint.parseProto(proto.localFingerprint) - var remoteFingerprint: FingerprintProtoLogicalFingerprint? = nil - if proto.hasRemoteFingerprint { - remoteFingerprint = try FingerprintProtoLogicalFingerprint.parseProto(proto.remoteFingerprint) + guard proto.hasRemoteFingerprint else { + throw FingerprintProtoError.invalidProtobuf(description: "\(logTag) missing required field: remoteFingerprint") } + let remoteFingerprint = try FingerprintProtoLogicalFingerprint.parseProto(proto.remoteFingerprint) // MARK: - Begin Validation Logic for FingerprintProtoLogicalFingerprints - // MARK: - End Validation Logic for FingerprintProtoLogicalFingerprints - let result = FingerprintProtoLogicalFingerprints(proto: proto, + version: version, localFingerprint: localFingerprint, remoteFingerprint: remoteFingerprint) return result diff --git a/SignalServiceKit/src/Protos/Generated/Provisioning.pb.swift b/SignalServiceKit/src/Protos/Generated/Provisioning.pb.swift index 17eebcc3b..446b178e8 100644 --- a/SignalServiceKit/src/Protos/Generated/Provisioning.pb.swift +++ b/SignalServiceKit/src/Protos/Generated/Provisioning.pb.swift @@ -32,6 +32,7 @@ struct ProvisioningProtos_ProvisionEnvelope { // `Message` and `Message+*Additions` files in the SwiftProtobuf library for // methods supported on all messages. + /// @required var publicKey: Data { get {return _publicKey ?? SwiftProtobuf.Internal.emptyData} set {_publicKey = newValue} @@ -41,7 +42,7 @@ struct ProvisioningProtos_ProvisionEnvelope { /// Clears the value of `publicKey`. Subsequent reads from it will return its default value. mutating func clearPublicKey() {self._publicKey = nil} - /// Encrypted ProvisionMessage + /// @required var body: Data { get {return _body ?? SwiftProtobuf.Internal.emptyData} set {_body = newValue} @@ -64,6 +65,7 @@ struct ProvisioningProtos_ProvisionMessage { // `Message` and `Message+*Additions` files in the SwiftProtobuf library for // methods supported on all messages. + /// @required var identityKeyPublic: Data { get {return _identityKeyPublic ?? SwiftProtobuf.Internal.emptyData} set {_identityKeyPublic = newValue} @@ -73,6 +75,7 @@ struct ProvisioningProtos_ProvisionMessage { /// Clears the value of `identityKeyPublic`. Subsequent reads from it will return its default value. mutating func clearIdentityKeyPublic() {self._identityKeyPublic = nil} + /// @required var identityKeyPrivate: Data { get {return _identityKeyPrivate ?? SwiftProtobuf.Internal.emptyData} set {_identityKeyPrivate = newValue} @@ -82,6 +85,7 @@ struct ProvisioningProtos_ProvisionMessage { /// Clears the value of `identityKeyPrivate`. Subsequent reads from it will return its default value. mutating func clearIdentityKeyPrivate() {self._identityKeyPrivate = nil} + /// @required var number: String { get {return _number ?? String()} set {_number = newValue} @@ -91,6 +95,7 @@ struct ProvisioningProtos_ProvisionMessage { /// Clears the value of `number`. Subsequent reads from it will return its default value. mutating func clearNumber() {self._number = nil} + /// @required var provisioningCode: String { get {return _provisioningCode ?? String()} set {_provisioningCode = newValue} @@ -100,6 +105,7 @@ struct ProvisioningProtos_ProvisionMessage { /// Clears the value of `provisioningCode`. Subsequent reads from it will return its default value. mutating func clearProvisioningCode() {self._provisioningCode = nil} + /// @required var userAgent: String { get {return _userAgent ?? String()} set {_userAgent = newValue} @@ -109,6 +115,7 @@ struct ProvisioningProtos_ProvisionMessage { /// Clears the value of `userAgent`. Subsequent reads from it will return its default value. mutating func clearUserAgent() {self._userAgent = nil} + /// @required var profileKey: Data { get {return _profileKey ?? SwiftProtobuf.Internal.emptyData} set {_profileKey = newValue} @@ -118,6 +125,7 @@ struct ProvisioningProtos_ProvisionMessage { /// Clears the value of `profileKey`. Subsequent reads from it will return its default value. mutating func clearProfileKey() {self._profileKey = nil} + /// @required var readReceipts: Bool { get {return _readReceipts ?? false} set {_readReceipts = newValue} diff --git a/SignalServiceKit/src/Protos/Generated/ProvisioningProto.swift b/SignalServiceKit/src/Protos/Generated/ProvisioningProto.swift index 4ee0f76fc..783a90559 100644 --- a/SignalServiceKit/src/Protos/Generated/ProvisioningProto.swift +++ b/SignalServiceKit/src/Protos/Generated/ProvisioningProto.swift @@ -38,28 +38,15 @@ public enum ProvisioningProtoError: Error { fileprivate let proto: ProvisioningProtos_ProvisionEnvelope - @objc public var publicKey: Data? { - guard proto.hasPublicKey else { - return nil - } - return proto.publicKey - } - @objc public var hasPublicKey: Bool { - return proto.hasPublicKey - } + @objc public let publicKey: Data + @objc public let body: Data - @objc public var body: Data? { - guard proto.hasBody else { - return nil - } - return proto.body - } - @objc public var hasBody: Bool { - return proto.hasBody - } - - private init(proto: ProvisioningProtos_ProvisionEnvelope) { + private init(proto: ProvisioningProtos_ProvisionEnvelope, + publicKey: Data, + body: Data) { self.proto = proto + self.publicKey = publicKey + self.body = body } @objc @@ -73,11 +60,23 @@ public enum ProvisioningProtoError: Error { } fileprivate class func parseProto(_ proto: ProvisioningProtos_ProvisionEnvelope) throws -> ProvisioningProtoProvisionEnvelope { + guard proto.hasPublicKey else { + throw ProvisioningProtoError.invalidProtobuf(description: "\(logTag) missing required field: publicKey") + } + let publicKey = proto.publicKey + + guard proto.hasBody else { + throw ProvisioningProtoError.invalidProtobuf(description: "\(logTag) missing required field: body") + } + let body = proto.body + // MARK: - Begin Validation Logic for ProvisioningProtoProvisionEnvelope - // MARK: - End Validation Logic for ProvisioningProtoProvisionEnvelope - - let result = ProvisioningProtoProvisionEnvelope(proto: proto) + let result = ProvisioningProtoProvisionEnvelope(proto: proto, + publicKey: publicKey, + body: body) return result } } @@ -130,93 +129,90 @@ public enum ProvisioningProtoError: Error { fileprivate let proto: ProvisioningProtos_ProvisionMessage - @objc public var identityKeyPublic: Data? { - guard proto.hasIdentityKeyPublic else { - return nil - } - return proto.identityKeyPublic + @objc public let identityKeyPublic: Data + @objc public let identityKeyPrivate: Data + @objc public let number: String + @objc public let provisioningCode: String + @objc public let userAgent: String + @objc public let profileKey: Data + @objc public let readReceipts: Bool + + private init(proto: ProvisioningProtos_ProvisionMessage, + identityKeyPublic: Data, + identityKeyPrivate: Data, + number: String, + provisioningCode: String, + userAgent: String, + profileKey: Data, + readReceipts: Bool) { + self.proto = proto + self.identityKeyPublic = identityKeyPublic + self.identityKeyPrivate = identityKeyPrivate + self.number = number + self.provisioningCode = provisioningCode + self.userAgent = userAgent + self.profileKey = profileKey + self.readReceipts = readReceipts + } + + @objc + public func serializedData() throws -> Data { + return try self.proto.serializedData() } - @objc public var hasIdentityKeyPublic: Bool { - return proto.hasIdentityKeyPublic + + @objc public class func parseData(_ serializedData: Data) throws -> ProvisioningProtoProvisionMessage { + let proto = try ProvisioningProtos_ProvisionMessage(serializedData: serializedData) + return try parseProto(proto) } - @objc public var identityKeyPrivate: Data? { + fileprivate class func parseProto(_ proto: ProvisioningProtos_ProvisionMessage) throws -> ProvisioningProtoProvisionMessage { + guard proto.hasIdentityKeyPublic else { + throw ProvisioningProtoError.invalidProtobuf(description: "\(logTag) missing required field: identityKeyPublic") + } + let identityKeyPublic = proto.identityKeyPublic + guard proto.hasIdentityKeyPrivate else { - return nil + throw ProvisioningProtoError.invalidProtobuf(description: "\(logTag) missing required field: identityKeyPrivate") } - return proto.identityKeyPrivate - } - @objc public var hasIdentityKeyPrivate: Bool { - return proto.hasIdentityKeyPrivate - } + let identityKeyPrivate = proto.identityKeyPrivate - @objc public var number: String? { guard proto.hasNumber else { - return nil + throw ProvisioningProtoError.invalidProtobuf(description: "\(logTag) missing required field: number") } - return proto.number - } - @objc public var hasNumber: Bool { - return proto.hasNumber - } + let number = proto.number - @objc public var provisioningCode: String? { guard proto.hasProvisioningCode else { - return nil + throw ProvisioningProtoError.invalidProtobuf(description: "\(logTag) missing required field: provisioningCode") } - return proto.provisioningCode - } - @objc public var hasProvisioningCode: Bool { - return proto.hasProvisioningCode - } + let provisioningCode = proto.provisioningCode - @objc public var userAgent: String? { guard proto.hasUserAgent else { - return nil + throw ProvisioningProtoError.invalidProtobuf(description: "\(logTag) missing required field: userAgent") } - return proto.userAgent - } - @objc public var hasUserAgent: Bool { - return proto.hasUserAgent - } + let userAgent = proto.userAgent - @objc public var profileKey: Data? { guard proto.hasProfileKey else { - return nil + throw ProvisioningProtoError.invalidProtobuf(description: "\(logTag) missing required field: profileKey") } - return proto.profileKey - } - @objc public var hasProfileKey: Bool { - return proto.hasProfileKey - } - - @objc public var readReceipts: Bool { - return proto.readReceipts - } - @objc public var hasReadReceipts: Bool { - return proto.hasReadReceipts - } + let profileKey = proto.profileKey - private init(proto: ProvisioningProtos_ProvisionMessage) { - self.proto = proto - } - - @objc - public func serializedData() throws -> Data { - return try self.proto.serializedData() - } - - @objc public class func parseData(_ serializedData: Data) throws -> ProvisioningProtoProvisionMessage { - let proto = try ProvisioningProtos_ProvisionMessage(serializedData: serializedData) - return try parseProto(proto) - } + guard proto.hasReadReceipts else { + throw ProvisioningProtoError.invalidProtobuf(description: "\(logTag) missing required field: readReceipts") + } + let readReceipts = proto.readReceipts - fileprivate class func parseProto(_ proto: ProvisioningProtos_ProvisionMessage) throws -> ProvisioningProtoProvisionMessage { // MARK: - Begin Validation Logic for ProvisioningProtoProvisionMessage - // MARK: - End Validation Logic for ProvisioningProtoProvisionMessage - - let result = ProvisioningProtoProvisionMessage(proto: proto) + let result = ProvisioningProtoProvisionMessage(proto: proto, + identityKeyPublic: identityKeyPublic, + identityKeyPrivate: identityKeyPrivate, + number: number, + provisioningCode: provisioningCode, + userAgent: userAgent, + profileKey: profileKey, + readReceipts: readReceipts) return result } } diff --git a/SignalServiceKit/src/Protos/Generated/SignalIOS.pb.swift b/SignalServiceKit/src/Protos/Generated/SignalIOS.pb.swift index 0ac4740f9..934a293d8 100644 --- a/SignalServiceKit/src/Protos/Generated/SignalIOS.pb.swift +++ b/SignalServiceKit/src/Protos/Generated/SignalIOS.pb.swift @@ -41,6 +41,7 @@ struct IOSProtos_BackupSnapshot { // `Message` and `Message+*Additions` files in the SwiftProtobuf library for // methods supported on all messages. + /// @required var type: IOSProtos_BackupSnapshot.BackupEntity.TypeEnum { get {return _type ?? .unknown} set {_type = newValue} @@ -50,6 +51,7 @@ struct IOSProtos_BackupSnapshot { /// Clears the value of `type`. Subsequent reads from it will return its default value. mutating func clearType() {self._type = nil} + /// @required var entityData: Data { get {return _entityData ?? SwiftProtobuf.Internal.emptyData} set {_entityData = newValue} diff --git a/SignalServiceKit/src/Protos/Generated/SignalIOSProto.swift b/SignalServiceKit/src/Protos/Generated/SignalIOSProto.swift index b5f6402d9..4fb4d6cce 100644 --- a/SignalServiceKit/src/Protos/Generated/SignalIOSProto.swift +++ b/SignalServiceKit/src/Protos/Generated/SignalIOSProto.swift @@ -68,25 +68,15 @@ public enum SignalIOSProtoError: Error { fileprivate let proto: IOSProtos_BackupSnapshot.BackupEntity - @objc public var type: SignalIOSProtoBackupSnapshotBackupEntityType { - return SignalIOSProtoBackupSnapshotBackupEntity.SignalIOSProtoBackupSnapshotBackupEntityTypeWrap(proto.type) - } - @objc public var hasType: Bool { - return proto.hasType - } - - @objc public var entityData: Data? { - guard proto.hasEntityData else { - return nil - } - return proto.entityData - } - @objc public var hasEntityData: Bool { - return proto.hasEntityData - } + @objc public let type: SignalIOSProtoBackupSnapshotBackupEntityType + @objc public let entityData: Data - private init(proto: IOSProtos_BackupSnapshot.BackupEntity) { + private init(proto: IOSProtos_BackupSnapshot.BackupEntity, + type: SignalIOSProtoBackupSnapshotBackupEntityType, + entityData: Data) { self.proto = proto + self.type = type + self.entityData = entityData } @objc @@ -100,11 +90,23 @@ public enum SignalIOSProtoError: Error { } fileprivate class func parseProto(_ proto: IOSProtos_BackupSnapshot.BackupEntity) throws -> SignalIOSProtoBackupSnapshotBackupEntity { + guard proto.hasType else { + throw SignalIOSProtoError.invalidProtobuf(description: "\(logTag) missing required field: type") + } + let type = SignalIOSProtoBackupSnapshotBackupEntityTypeWrap(proto.type) + + guard proto.hasEntityData else { + throw SignalIOSProtoError.invalidProtobuf(description: "\(logTag) missing required field: entityData") + } + let entityData = proto.entityData + // MARK: - Begin Validation Logic for SignalIOSProtoBackupSnapshotBackupEntity - // MARK: - End Validation Logic for SignalIOSProtoBackupSnapshotBackupEntity - - let result = SignalIOSProtoBackupSnapshotBackupEntity(proto: proto) + let result = SignalIOSProtoBackupSnapshotBackupEntity(proto: proto, + type: type, + entityData: entityData) return result } } diff --git a/SignalServiceKit/src/Protos/Generated/WebSocketProto.swift b/SignalServiceKit/src/Protos/Generated/WebSocketProto.swift index 1ad72bad8..1251e1555 100644 --- a/SignalServiceKit/src/Protos/Generated/WebSocketProto.swift +++ b/SignalServiceKit/src/Protos/Generated/WebSocketProto.swift @@ -40,8 +40,8 @@ public enum WebSocketProtoError: Error { proto.headers = items } - @objc public func setRequestId(_ valueParam: UInt64) { - proto.requestId = valueParam + @objc public func setRequestID(_ valueParam: UInt64) { + proto.requestID = valueParam } @objc public func build() throws -> WebSocketProtoWebSocketRequestMessage { @@ -52,25 +52,9 @@ public enum WebSocketProtoError: Error { fileprivate let proto: WebSocketProtos_WebSocketRequestMessage - @objc public var verb: String? { - guard proto.hasVerb else { - return nil - } - return proto.verb - } - @objc public var hasVerb: Bool { - return proto.hasVerb - } - - @objc public var path: String? { - guard proto.hasPath else { - return nil - } - return proto.path - } - @objc public var hasPath: Bool { - return proto.hasPath - } + @objc public let verb: String + @objc public let path: String + @objc public let requestID: UInt64 @objc public var body: Data? { guard proto.hasBody else { @@ -86,15 +70,14 @@ public enum WebSocketProtoError: Error { return proto.headers } - @objc public var requestId: UInt64 { - return proto.requestId - } - @objc public var hasRequestId: Bool { - return proto.hasRequestId - } - - private init(proto: WebSocketProtos_WebSocketRequestMessage) { + private init(proto: WebSocketProtos_WebSocketRequestMessage, + verb: String, + path: String, + requestID: UInt64) { self.proto = proto + self.verb = verb + self.path = path + self.requestID = requestID } @objc @@ -108,11 +91,29 @@ public enum WebSocketProtoError: Error { } fileprivate class func parseProto(_ proto: WebSocketProtos_WebSocketRequestMessage) throws -> WebSocketProtoWebSocketRequestMessage { + guard proto.hasVerb else { + throw WebSocketProtoError.invalidProtobuf(description: "\(logTag) missing required field: verb") + } + let verb = proto.verb + + guard proto.hasPath else { + throw WebSocketProtoError.invalidProtobuf(description: "\(logTag) missing required field: path") + } + let path = proto.path + + guard proto.hasRequestID else { + throw WebSocketProtoError.invalidProtobuf(description: "\(logTag) missing required field: requestID") + } + let requestID = proto.requestID + // MARK: - Begin Validation Logic for WebSocketProtoWebSocketRequestMessage - // MARK: - End Validation Logic for WebSocketProtoWebSocketRequestMessage - - let result = WebSocketProtoWebSocketRequestMessage(proto: proto) + let result = WebSocketProtoWebSocketRequestMessage(proto: proto, + verb: verb, + path: path, + requestID: requestID) return result } } @@ -129,8 +130,8 @@ public enum WebSocketProtoError: Error { @objc public override init() {} - @objc public func setRequestId(_ valueParam: UInt64) { - proto.requestId = valueParam + @objc public func setRequestID(_ valueParam: UInt64) { + proto.requestID = valueParam } @objc public func setStatus(_ valueParam: UInt32) { @@ -159,19 +160,9 @@ public enum WebSocketProtoError: Error { fileprivate let proto: WebSocketProtos_WebSocketResponseMessage - @objc public var requestId: UInt64 { - return proto.requestId - } - @objc public var hasRequestId: Bool { - return proto.hasRequestId - } - - @objc public var status: UInt32 { - return proto.status - } - @objc public var hasStatus: Bool { - return proto.hasStatus - } + @objc public let requestID: UInt64 + @objc public let status: UInt32 + @objc public let body: Data @objc public var message: String? { guard proto.hasMessage else { @@ -187,18 +178,14 @@ public enum WebSocketProtoError: Error { return proto.headers } - @objc public var body: Data? { - guard proto.hasBody else { - return nil - } - return proto.body - } - @objc public var hasBody: Bool { - return proto.hasBody - } - - private init(proto: WebSocketProtos_WebSocketResponseMessage) { + private init(proto: WebSocketProtos_WebSocketResponseMessage, + requestID: UInt64, + status: UInt32, + body: Data) { self.proto = proto + self.requestID = requestID + self.status = status + self.body = body } @objc @@ -212,11 +199,29 @@ public enum WebSocketProtoError: Error { } fileprivate class func parseProto(_ proto: WebSocketProtos_WebSocketResponseMessage) throws -> WebSocketProtoWebSocketResponseMessage { + guard proto.hasRequestID else { + throw WebSocketProtoError.invalidProtobuf(description: "\(logTag) missing required field: requestID") + } + let requestID = proto.requestID + + guard proto.hasStatus else { + throw WebSocketProtoError.invalidProtobuf(description: "\(logTag) missing required field: status") + } + let status = proto.status + + guard proto.hasBody else { + throw WebSocketProtoError.invalidProtobuf(description: "\(logTag) missing required field: body") + } + let body = proto.body + // MARK: - Begin Validation Logic for WebSocketProtoWebSocketResponseMessage - // MARK: - End Validation Logic for WebSocketProtoWebSocketResponseMessage - - let result = WebSocketProtoWebSocketResponseMessage(proto: proto) + let result = WebSocketProtoWebSocketResponseMessage(proto: proto, + requestID: requestID, + status: status, + body: body) return result } } @@ -277,20 +282,16 @@ public enum WebSocketProtoError: Error { fileprivate let proto: WebSocketProtos_WebSocketMessage + @objc public let type: WebSocketProtoWebSocketMessageType @objc public let request: WebSocketProtoWebSocketRequestMessage? @objc public let response: WebSocketProtoWebSocketResponseMessage? - @objc public var type: WebSocketProtoWebSocketMessageType { - return WebSocketProtoWebSocketMessage.WebSocketProtoWebSocketMessageTypeWrap(proto.type) - } - @objc public var hasType: Bool { - return proto.hasType - } - private init(proto: WebSocketProtos_WebSocketMessage, + type: WebSocketProtoWebSocketMessageType, request: WebSocketProtoWebSocketRequestMessage?, response: WebSocketProtoWebSocketResponseMessage?) { self.proto = proto + self.type = type self.request = request self.response = response } @@ -306,6 +307,11 @@ public enum WebSocketProtoError: Error { } fileprivate class func parseProto(_ proto: WebSocketProtos_WebSocketMessage) throws -> WebSocketProtoWebSocketMessage { + guard proto.hasType else { + throw WebSocketProtoError.invalidProtobuf(description: "\(logTag) missing required field: type") + } + let type = WebSocketProtoWebSocketMessageTypeWrap(proto.type) + var request: WebSocketProtoWebSocketRequestMessage? = nil if proto.hasRequest { request = try WebSocketProtoWebSocketRequestMessage.parseProto(proto.request) @@ -321,6 +327,7 @@ public enum WebSocketProtoError: Error { // MARK: - End Validation Logic for WebSocketProtoWebSocketMessage - let result = WebSocketProtoWebSocketMessage(proto: proto, + type: type, request: request, response: response) return result diff --git a/SignalServiceKit/src/Protos/Generated/WebSocketResources.pb.swift b/SignalServiceKit/src/Protos/Generated/WebSocketResources.pb.swift index b3a02d079..dde0f11fa 100644 --- a/SignalServiceKit/src/Protos/Generated/WebSocketResources.pb.swift +++ b/SignalServiceKit/src/Protos/Generated/WebSocketResources.pb.swift @@ -32,6 +32,7 @@ struct WebSocketProtos_WebSocketRequestMessage { // `Message` and `Message+*Additions` files in the SwiftProtobuf library for // methods supported on all messages. + /// @required var verb: String { get {return _verb ?? String()} set {_verb = newValue} @@ -41,6 +42,7 @@ struct WebSocketProtos_WebSocketRequestMessage { /// Clears the value of `verb`. Subsequent reads from it will return its default value. mutating func clearVerb() {self._verb = nil} + /// @required var path: String { get {return _path ?? String()} set {_path = newValue} @@ -61,6 +63,7 @@ struct WebSocketProtos_WebSocketRequestMessage { var headers: [String] = [] + /// @required var requestID: UInt64 { get {return _requestID ?? 0} set {_requestID = newValue} @@ -85,6 +88,7 @@ struct WebSocketProtos_WebSocketResponseMessage { // `Message` and `Message+*Additions` files in the SwiftProtobuf library for // methods supported on all messages. + /// @required var requestID: UInt64 { get {return _requestID ?? 0} set {_requestID = newValue} @@ -94,6 +98,7 @@ struct WebSocketProtos_WebSocketResponseMessage { /// Clears the value of `requestID`. Subsequent reads from it will return its default value. mutating func clearRequestID() {self._requestID = nil} + /// @required var status: UInt32 { get {return _status ?? 0} set {_status = newValue} @@ -114,6 +119,7 @@ struct WebSocketProtos_WebSocketResponseMessage { var headers: [String] = [] + /// @required var body: Data { get {return _body ?? SwiftProtobuf.Internal.emptyData} set {_body = newValue} @@ -138,6 +144,7 @@ struct WebSocketProtos_WebSocketMessage { // `Message` and `Message+*Additions` files in the SwiftProtobuf library for // methods supported on all messages. + /// @required var type: WebSocketProtos_WebSocketMessage.TypeEnum { get {return _storage._type ?? .unknown} set {_uniqueStorage()._type = newValue} From 2819c758ff9c5608b30ef66511996147de80bedd Mon Sep 17 00:00:00 2001 From: Matthew Chen Date: Fri, 3 Aug 2018 14:04:33 -0400 Subject: [PATCH 6/6] Update Cocoapods. --- Pods | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Pods b/Pods index b8c8d320d..bd2cd84d5 160000 --- a/Pods +++ b/Pods @@ -1 +1 @@ -Subproject commit b8c8d320dba1c279b5c0ea03313232239e4e0ba5 +Subproject commit bd2cd84d57053c4015e9646b5c5dbc4420560996