mirror of
https://github.com/oxen-io/session-ios.git
synced 2023-12-13 21:30:14 +01:00
Merge branch 'charlesmchen/protoWrappers2'
This commit is contained in:
commit
faebd9af82
2
Pods
2
Pods
|
@ -1 +1 @@
|
|||
Subproject commit b8c8d320dba1c279b5c0ea03313232239e4e0ba5
|
||||
Subproject commit bd2cd84d57053c4015e9646b5c5dbc4420560996
|
|
@ -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):
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -8,22 +8,31 @@
|
|||
// the legacy proto format.
|
||||
syntax = "proto2";
|
||||
|
||||
package ProvisioningProto;
|
||||
package ProvisioningProtos;
|
||||
|
||||
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;
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
|
@ -22,7 +20,9 @@ message BackupSnapshot
|
|||
INTERACTION = 3;
|
||||
ATTACHMENT = 4;
|
||||
}
|
||||
// @required
|
||||
optional Type type = 1;
|
||||
// @required
|
||||
optional bytes entityData = 2;
|
||||
}
|
||||
|
||||
|
|
|
@ -14,32 +14,36 @@ package WebSocketProtos;
|
|||
option java_package = "org.whispersystems.signalservice.internal.websocket";
|
||||
option java_outer_classname = "WebSocketProtos";
|
||||
|
||||
message WebSocketRequestMessage
|
||||
{
|
||||
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
|
||||
{
|
||||
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;
|
||||
}
|
||||
|
||||
message WebSocketMessage
|
||||
{
|
||||
message WebSocketMessage {
|
||||
enum Type {
|
||||
UNKNOWN = 0;
|
||||
REQUEST = 1;
|
||||
RESPONSE = 2;
|
||||
}
|
||||
|
||||
// @required
|
||||
optional Type type = 1;
|
||||
optional WebSocketRequestMessage request = 2;
|
||||
optional WebSocketResponseMessage response = 3;
|
||||
|
|
|
@ -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}
|
||||
|
|
153
SignalServiceKit/src/Protos/Generated/FingerprintProto.swift
Normal file
153
SignalServiceKit/src/Protos/Generated/FingerprintProto.swift
Normal file
|
@ -0,0 +1,153 @@
|
|||
//
|
||||
// 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 {
|
||||
|
||||
// MARK: - FingerprintProtoLogicalFingerprintBuilder
|
||||
|
||||
@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 let identityData: Data
|
||||
|
||||
private init(proto: FingerprintProtos_LogicalFingerprint,
|
||||
identityData: Data) {
|
||||
self.proto = proto
|
||||
self.identityData = identityData
|
||||
}
|
||||
|
||||
@objc
|
||||
public func serializedData() throws -> Data {
|
||||
return try self.proto.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 {
|
||||
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,
|
||||
identityData: identityData)
|
||||
return result
|
||||
}
|
||||
}
|
||||
|
||||
// MARK: - FingerprintProtoLogicalFingerprints
|
||||
|
||||
@objc public class FingerprintProtoLogicalFingerprints: NSObject {
|
||||
|
||||
// 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 version: UInt32
|
||||
@objc public let localFingerprint: FingerprintProtoLogicalFingerprint
|
||||
@objc public let remoteFingerprint: FingerprintProtoLogicalFingerprint
|
||||
|
||||
private init(proto: FingerprintProtos_LogicalFingerprints,
|
||||
version: UInt32,
|
||||
localFingerprint: FingerprintProtoLogicalFingerprint,
|
||||
remoteFingerprint: FingerprintProtoLogicalFingerprint) {
|
||||
self.proto = proto
|
||||
self.version = version
|
||||
self.localFingerprint = localFingerprint
|
||||
self.remoteFingerprint = remoteFingerprint
|
||||
}
|
||||
|
||||
@objc
|
||||
public func serializedData() throws -> Data {
|
||||
return try self.proto.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 {
|
||||
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)
|
||||
|
||||
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
|
||||
}
|
||||
}
|
|
@ -27,11 +27,12 @@ fileprivate struct _GeneratedWithProtocGenSwiftVersion: SwiftProtobuf.ProtobufAP
|
|||
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.
|
||||
|
||||
/// @required
|
||||
var publicKey: Data {
|
||||
get {return _publicKey ?? SwiftProtobuf.Internal.emptyData}
|
||||
set {_publicKey = newValue}
|
||||
|
@ -41,7 +42,7 @@ struct ProvisioningProto_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}
|
||||
|
@ -59,11 +60,12 @@ struct ProvisioningProto_ProvisionEnvelope {
|
|||
fileprivate var _body: Data? = nil
|
||||
}
|
||||
|
||||
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.
|
||||
|
||||
/// @required
|
||||
var identityKeyPublic: Data {
|
||||
get {return _identityKeyPublic ?? SwiftProtobuf.Internal.emptyData}
|
||||
set {_identityKeyPublic = newValue}
|
||||
|
@ -73,6 +75,7 @@ struct ProvisioningProto_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 ProvisioningProto_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 ProvisioningProto_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 ProvisioningProto_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 ProvisioningProto_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 ProvisioningProto_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}
|
||||
|
@ -142,9 +150,9 @@ struct ProvisioningProto_ProvisionMessage {
|
|||
|
||||
// MARK: - Code below here is support for the SwiftProtobuf runtime.
|
||||
|
||||
fileprivate let _protobuf_package = "ProvisioningProto"
|
||||
fileprivate 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"),
|
||||
|
@ -171,7 +179,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 +187,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"),
|
||||
|
@ -231,7 +239,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}
|
||||
|
|
218
SignalServiceKit/src/Protos/Generated/ProvisioningProto.swift
Normal file
218
SignalServiceKit/src/Protos/Generated/ProvisioningProto.swift
Normal file
|
@ -0,0 +1,218 @@
|
|||
//
|
||||
// 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 {
|
||||
|
||||
// MARK: - ProvisioningProtoProvisionEnvelopeBuilder
|
||||
|
||||
@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 let publicKey: Data
|
||||
@objc public let body: Data
|
||||
|
||||
private init(proto: ProvisioningProtos_ProvisionEnvelope,
|
||||
publicKey: Data,
|
||||
body: Data) {
|
||||
self.proto = proto
|
||||
self.publicKey = publicKey
|
||||
self.body = body
|
||||
}
|
||||
|
||||
@objc
|
||||
public func serializedData() throws -> Data {
|
||||
return try self.proto.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 {
|
||||
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,
|
||||
publicKey: publicKey,
|
||||
body: body)
|
||||
return result
|
||||
}
|
||||
}
|
||||
|
||||
// MARK: - ProvisioningProtoProvisionMessage
|
||||
|
||||
@objc public class ProvisioningProtoProvisionMessage: NSObject {
|
||||
|
||||
// MARK: - ProvisioningProtoProvisionMessageBuilder
|
||||
|
||||
@objc public class ProvisioningProtoProvisionMessageBuilder: NSObject {
|
||||
|
||||
private var proto = ProvisioningProtos_ProvisionMessage()
|
||||
|
||||
@objc public override init() {}
|
||||
|
||||
@objc public func setIdentityKeyPublic(_ valueParam: Data) {
|
||||
proto.identityKeyPublic = valueParam
|
||||
}
|
||||
|
||||
@objc public func setIdentityKeyPrivate(_ valueParam: Data) {
|
||||
proto.identityKeyPrivate = valueParam
|
||||
}
|
||||
|
||||
@objc public func setNumber(_ valueParam: String) {
|
||||
proto.number = valueParam
|
||||
}
|
||||
|
||||
@objc public func setProvisioningCode(_ valueParam: String) {
|
||||
proto.provisioningCode = valueParam
|
||||
}
|
||||
|
||||
@objc public func setUserAgent(_ valueParam: String) {
|
||||
proto.userAgent = valueParam
|
||||
}
|
||||
|
||||
@objc public func setProfileKey(_ valueParam: Data) {
|
||||
proto.profileKey = valueParam
|
||||
}
|
||||
|
||||
@objc public func setReadReceipts(_ valueParam: Bool) {
|
||||
proto.readReceipts = valueParam
|
||||
}
|
||||
|
||||
@objc public func build() throws -> ProvisioningProtoProvisionMessage {
|
||||
let wrapper = try ProvisioningProtoProvisionMessage.parseProto(proto)
|
||||
return wrapper
|
||||
}
|
||||
}
|
||||
|
||||
fileprivate let proto: ProvisioningProtos_ProvisionMessage
|
||||
|
||||
@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 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 {
|
||||
guard proto.hasIdentityKeyPublic else {
|
||||
throw ProvisioningProtoError.invalidProtobuf(description: "\(logTag) missing required field: identityKeyPublic")
|
||||
}
|
||||
let identityKeyPublic = proto.identityKeyPublic
|
||||
|
||||
guard proto.hasIdentityKeyPrivate else {
|
||||
throw ProvisioningProtoError.invalidProtobuf(description: "\(logTag) missing required field: identityKeyPrivate")
|
||||
}
|
||||
let identityKeyPrivate = proto.identityKeyPrivate
|
||||
|
||||
guard proto.hasNumber else {
|
||||
throw ProvisioningProtoError.invalidProtobuf(description: "\(logTag) missing required field: number")
|
||||
}
|
||||
let number = proto.number
|
||||
|
||||
guard proto.hasProvisioningCode else {
|
||||
throw ProvisioningProtoError.invalidProtobuf(description: "\(logTag) missing required field: provisioningCode")
|
||||
}
|
||||
let provisioningCode = proto.provisioningCode
|
||||
|
||||
guard proto.hasUserAgent else {
|
||||
throw ProvisioningProtoError.invalidProtobuf(description: "\(logTag) missing required field: userAgent")
|
||||
}
|
||||
let userAgent = proto.userAgent
|
||||
|
||||
guard proto.hasProfileKey else {
|
||||
throw ProvisioningProtoError.invalidProtobuf(description: "\(logTag) missing required field: profileKey")
|
||||
}
|
||||
let profileKey = proto.profileKey
|
||||
|
||||
guard proto.hasReadReceipts else {
|
||||
throw ProvisioningProtoError.invalidProtobuf(description: "\(logTag) missing required field: readReceipts")
|
||||
}
|
||||
let readReceipts = proto.readReceipts
|
||||
|
||||
// MARK: - Begin Validation Logic for ProvisioningProtoProvisionMessage -
|
||||
|
||||
// MARK: - End Validation Logic for ProvisioningProtoProvisionMessage -
|
||||
|
||||
let result = ProvisioningProtoProvisionMessage(proto: proto,
|
||||
identityKeyPublic: identityKeyPublic,
|
||||
identityKeyPrivate: identityKeyPrivate,
|
||||
number: number,
|
||||
provisioningCode: provisioningCode,
|
||||
userAgent: userAgent,
|
||||
profileKey: profileKey,
|
||||
readReceipts: readReceipts)
|
||||
return result
|
||||
}
|
||||
}
|
|
@ -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}
|
||||
|
|
173
SignalServiceKit/src/Protos/Generated/SignalIOSProto.swift
Normal file
173
SignalServiceKit/src/Protos/Generated/SignalIOSProto.swift
Normal file
|
@ -0,0 +1,173 @@
|
|||
//
|
||||
// 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
|
||||
}
|
||||
}
|
||||
|
||||
// MARK: - SignalIOSProtoBackupSnapshotBackupEntityBuilder
|
||||
|
||||
@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 let type: SignalIOSProtoBackupSnapshotBackupEntityType
|
||||
@objc public let entityData: Data
|
||||
|
||||
private init(proto: IOSProtos_BackupSnapshot.BackupEntity,
|
||||
type: SignalIOSProtoBackupSnapshotBackupEntityType,
|
||||
entityData: Data) {
|
||||
self.proto = proto
|
||||
self.type = type
|
||||
self.entityData = entityData
|
||||
}
|
||||
|
||||
@objc
|
||||
public func serializedData() throws -> Data {
|
||||
return try self.proto.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 {
|
||||
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,
|
||||
type: type,
|
||||
entityData: entityData)
|
||||
return result
|
||||
}
|
||||
}
|
||||
|
||||
// MARK: - SignalIOSProtoBackupSnapshot
|
||||
|
||||
@objc public class SignalIOSProtoBackupSnapshot: NSObject {
|
||||
|
||||
// MARK: - SignalIOSProtoBackupSnapshotBuilder
|
||||
|
||||
@objc public class SignalIOSProtoBackupSnapshotBuilder: NSObject {
|
||||
|
||||
private var proto = IOSProtos_BackupSnapshot()
|
||||
|
||||
@objc public override init() {}
|
||||
|
||||
@objc public func addEntity(_ valueParam: SignalIOSProtoBackupSnapshotBackupEntity) {
|
||||
var items = proto.entity
|
||||
items.append(valueParam.proto)
|
||||
proto.entity = items
|
||||
}
|
||||
|
||||
@objc public func build() throws -> SignalIOSProtoBackupSnapshot {
|
||||
let wrapper = try SignalIOSProtoBackupSnapshot.parseProto(proto)
|
||||
return wrapper
|
||||
}
|
||||
}
|
||||
|
||||
fileprivate let proto: IOSProtos_BackupSnapshot
|
||||
|
||||
@objc public let entity: [SignalIOSProtoBackupSnapshotBackupEntity]
|
||||
|
||||
private init(proto: IOSProtos_BackupSnapshot,
|
||||
entity: [SignalIOSProtoBackupSnapshotBackupEntity]) {
|
||||
self.proto = proto
|
||||
self.entity = entity
|
||||
}
|
||||
|
||||
@objc
|
||||
public func serializedData() throws -> Data {
|
||||
return try self.proto.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(proto: proto,
|
||||
entity: entity)
|
||||
return result
|
||||
}
|
||||
}
|
335
SignalServiceKit/src/Protos/Generated/WebSocketProto.swift
Normal file
335
SignalServiceKit/src/Protos/Generated/WebSocketProto.swift
Normal file
|
@ -0,0 +1,335 @@
|
|||
//
|
||||
// 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 {
|
||||
|
||||
// MARK: - WebSocketProtoWebSocketRequestMessageBuilder
|
||||
|
||||
@objc public class WebSocketProtoWebSocketRequestMessageBuilder: NSObject {
|
||||
|
||||
private var proto = WebSocketProtos_WebSocketRequestMessage()
|
||||
|
||||
@objc public override init() {}
|
||||
|
||||
@objc public func setVerb(_ valueParam: String) {
|
||||
proto.verb = valueParam
|
||||
}
|
||||
|
||||
@objc public func setPath(_ valueParam: String) {
|
||||
proto.path = valueParam
|
||||
}
|
||||
|
||||
@objc public func setBody(_ valueParam: Data) {
|
||||
proto.body = valueParam
|
||||
}
|
||||
|
||||
@objc public func addHeaders(_ valueParam: String) {
|
||||
var items = proto.headers
|
||||
items.append(valueParam)
|
||||
proto.headers = items
|
||||
}
|
||||
|
||||
@objc public func setRequestID(_ valueParam: UInt64) {
|
||||
proto.requestID = valueParam
|
||||
}
|
||||
|
||||
@objc public func build() throws -> WebSocketProtoWebSocketRequestMessage {
|
||||
let wrapper = try WebSocketProtoWebSocketRequestMessage.parseProto(proto)
|
||||
return wrapper
|
||||
}
|
||||
}
|
||||
|
||||
fileprivate let proto: WebSocketProtos_WebSocketRequestMessage
|
||||
|
||||
@objc public let verb: String
|
||||
@objc public let path: String
|
||||
@objc public let requestID: UInt64
|
||||
|
||||
@objc public var body: Data? {
|
||||
guard proto.hasBody else {
|
||||
return nil
|
||||
}
|
||||
return proto.body
|
||||
}
|
||||
@objc public var hasBody: Bool {
|
||||
return proto.hasBody
|
||||
}
|
||||
|
||||
@objc public var headers: [String] {
|
||||
return proto.headers
|
||||
}
|
||||
|
||||
private init(proto: WebSocketProtos_WebSocketRequestMessage,
|
||||
verb: String,
|
||||
path: String,
|
||||
requestID: UInt64) {
|
||||
self.proto = proto
|
||||
self.verb = verb
|
||||
self.path = path
|
||||
self.requestID = requestID
|
||||
}
|
||||
|
||||
@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 {
|
||||
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,
|
||||
verb: verb,
|
||||
path: path,
|
||||
requestID: requestID)
|
||||
return result
|
||||
}
|
||||
}
|
||||
|
||||
// MARK: - WebSocketProtoWebSocketResponseMessage
|
||||
|
||||
@objc public class WebSocketProtoWebSocketResponseMessage: NSObject {
|
||||
|
||||
// MARK: - WebSocketProtoWebSocketResponseMessageBuilder
|
||||
|
||||
@objc public class WebSocketProtoWebSocketResponseMessageBuilder: NSObject {
|
||||
|
||||
private var proto = WebSocketProtos_WebSocketResponseMessage()
|
||||
|
||||
@objc public override init() {}
|
||||
|
||||
@objc public func setRequestID(_ valueParam: UInt64) {
|
||||
proto.requestID = valueParam
|
||||
}
|
||||
|
||||
@objc public func setStatus(_ valueParam: UInt32) {
|
||||
proto.status = valueParam
|
||||
}
|
||||
|
||||
@objc public func setMessage(_ valueParam: String) {
|
||||
proto.message = valueParam
|
||||
}
|
||||
|
||||
@objc public func addHeaders(_ valueParam: String) {
|
||||
var items = proto.headers
|
||||
items.append(valueParam)
|
||||
proto.headers = items
|
||||
}
|
||||
|
||||
@objc public func setBody(_ valueParam: Data) {
|
||||
proto.body = valueParam
|
||||
}
|
||||
|
||||
@objc public func build() throws -> WebSocketProtoWebSocketResponseMessage {
|
||||
let wrapper = try WebSocketProtoWebSocketResponseMessage.parseProto(proto)
|
||||
return wrapper
|
||||
}
|
||||
}
|
||||
|
||||
fileprivate let proto: WebSocketProtos_WebSocketResponseMessage
|
||||
|
||||
@objc public let requestID: UInt64
|
||||
@objc public let status: UInt32
|
||||
@objc public let body: Data
|
||||
|
||||
@objc public var message: String? {
|
||||
guard proto.hasMessage else {
|
||||
return nil
|
||||
}
|
||||
return proto.message
|
||||
}
|
||||
@objc public var hasMessage: Bool {
|
||||
return proto.hasMessage
|
||||
}
|
||||
|
||||
@objc public var headers: [String] {
|
||||
return proto.headers
|
||||
}
|
||||
|
||||
private init(proto: WebSocketProtos_WebSocketResponseMessage,
|
||||
requestID: UInt64,
|
||||
status: UInt32,
|
||||
body: Data) {
|
||||
self.proto = proto
|
||||
self.requestID = requestID
|
||||
self.status = status
|
||||
self.body = body
|
||||
}
|
||||
|
||||
@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 {
|
||||
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,
|
||||
requestID: requestID,
|
||||
status: status,
|
||||
body: body)
|
||||
return result
|
||||
}
|
||||
}
|
||||
|
||||
// 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
|
||||
}
|
||||
}
|
||||
|
||||
// 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 type: WebSocketProtoWebSocketMessageType
|
||||
@objc public let request: WebSocketProtoWebSocketRequestMessage?
|
||||
@objc public let response: WebSocketProtoWebSocketResponseMessage?
|
||||
|
||||
private init(proto: WebSocketProtos_WebSocketMessage,
|
||||
type: WebSocketProtoWebSocketMessageType,
|
||||
request: WebSocketProtoWebSocketRequestMessage?,
|
||||
response: WebSocketProtoWebSocketResponseMessage?) {
|
||||
self.proto = proto
|
||||
self.type = type
|
||||
self.request = request
|
||||
self.response = response
|
||||
}
|
||||
|
||||
@objc
|
||||
public func serializedData() throws -> Data {
|
||||
return try self.proto.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 {
|
||||
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)
|
||||
}
|
||||
|
||||
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(proto: proto,
|
||||
type: type,
|
||||
request: request,
|
||||
response: response)
|
||||
return result
|
||||
}
|
||||
}
|
|
@ -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}
|
||||
|
|
Loading…
Reference in a new issue