From ea0134ad61c4d665c9ce4a5f0f18abd043bf39f1 Mon Sep 17 00:00:00 2001 From: Mikunj Date: Wed, 29 May 2019 09:36:16 +1000 Subject: [PATCH] Updated protobuf. --- SignalServiceKit/protobuf/SignalService.proto | 7 +- .../src/Protos/Generated/SSKProto.swift | 104 +++++++++++++++++- .../Protos/Generated/SignalService.pb.swift | 57 +++++++++- 3 files changed, 159 insertions(+), 9 deletions(-) diff --git a/SignalServiceKit/protobuf/SignalService.proto b/SignalServiceKit/protobuf/SignalService.proto index ce2e45d2e..7c92ad5f7 100644 --- a/SignalServiceKit/protobuf/SignalService.proto +++ b/SignalServiceKit/protobuf/SignalService.proto @@ -237,6 +237,11 @@ message DataMessage { optional AttachmentPointer image = 3; } + // Loki: A custom message for our profile + message LokiProfile { + optional string displayName = 1; + } + optional string body = 1; repeated AttachmentPointer attachments = 2; optional GroupContext group = 3; @@ -247,7 +252,7 @@ message DataMessage { optional Quote quote = 8; repeated Contact contact = 9; repeated Preview preview = 10; - optional Contact profile = 101; // Loki: The current user's profile + optional LokiProfile profile = 101; // Loki: The current user's profile } message NullMessage { diff --git a/SignalServiceKit/src/Protos/Generated/SSKProto.swift b/SignalServiceKit/src/Protos/Generated/SSKProto.swift index 5fa154cd9..c1e3c4657 100644 --- a/SignalServiceKit/src/Protos/Generated/SSKProto.swift +++ b/SignalServiceKit/src/Protos/Generated/SSKProto.swift @@ -3150,6 +3150,100 @@ extension SSKProtoDataMessagePreview.SSKProtoDataMessagePreviewBuilder { #endif +// MARK: - SSKProtoDataMessageLokiProfile + +@objc public class SSKProtoDataMessageLokiProfile: NSObject { + + // MARK: - SSKProtoDataMessageLokiProfileBuilder + + @objc public class func builder() -> SSKProtoDataMessageLokiProfileBuilder { + return SSKProtoDataMessageLokiProfileBuilder() + } + + // asBuilder() constructs a builder that reflects the proto's contents. + @objc public func asBuilder() -> SSKProtoDataMessageLokiProfileBuilder { + let builder = SSKProtoDataMessageLokiProfileBuilder() + if let _value = displayName { + builder.setDisplayName(_value) + } + return builder + } + + @objc public class SSKProtoDataMessageLokiProfileBuilder: NSObject { + + private var proto = SignalServiceProtos_DataMessage.LokiProfile() + + @objc fileprivate override init() {} + + @objc public func setDisplayName(_ valueParam: String) { + proto.displayName = valueParam + } + + @objc public func build() throws -> SSKProtoDataMessageLokiProfile { + return try SSKProtoDataMessageLokiProfile.parseProto(proto) + } + + @objc public func buildSerializedData() throws -> Data { + return try SSKProtoDataMessageLokiProfile.parseProto(proto).serializedData() + } + } + + fileprivate let proto: SignalServiceProtos_DataMessage.LokiProfile + + @objc public var displayName: String? { + guard proto.hasDisplayName else { + return nil + } + return proto.displayName + } + @objc public var hasDisplayName: Bool { + return proto.hasDisplayName + } + + private init(proto: SignalServiceProtos_DataMessage.LokiProfile) { + self.proto = proto + } + + @objc + public func serializedData() throws -> Data { + return try self.proto.serializedData() + } + + @objc public class func parseData(_ serializedData: Data) throws -> SSKProtoDataMessageLokiProfile { + let proto = try SignalServiceProtos_DataMessage.LokiProfile(serializedData: serializedData) + return try parseProto(proto) + } + + fileprivate class func parseProto(_ proto: SignalServiceProtos_DataMessage.LokiProfile) throws -> SSKProtoDataMessageLokiProfile { + // MARK: - Begin Validation Logic for SSKProtoDataMessageLokiProfile - + + // MARK: - End Validation Logic for SSKProtoDataMessageLokiProfile - + + let result = SSKProtoDataMessageLokiProfile(proto: proto) + return result + } + + @objc public override var debugDescription: String { + return "\(proto)" + } +} + +#if DEBUG + +extension SSKProtoDataMessageLokiProfile { + @objc public func serializedDataIgnoringErrors() -> Data? { + return try! self.serializedData() + } +} + +extension SSKProtoDataMessageLokiProfile.SSKProtoDataMessageLokiProfileBuilder { + @objc public func buildIgnoringErrors() -> SSKProtoDataMessageLokiProfile? { + return try! self.build() + } +} + +#endif + // MARK: - SSKProtoDataMessage @objc public class SSKProtoDataMessage: NSObject { @@ -3281,7 +3375,7 @@ extension SSKProtoDataMessagePreview.SSKProtoDataMessagePreviewBuilder { proto.preview = wrappedItems.map { $0.proto } } - @objc public func setProfile(_ valueParam: SSKProtoDataMessageContact) { + @objc public func setProfile(_ valueParam: SSKProtoDataMessageLokiProfile) { proto.profile = valueParam.proto } @@ -3306,7 +3400,7 @@ extension SSKProtoDataMessagePreview.SSKProtoDataMessagePreviewBuilder { @objc public let preview: [SSKProtoDataMessagePreview] - @objc public let profile: SSKProtoDataMessageContact? + @objc public let profile: SSKProtoDataMessageLokiProfile? @objc public var body: String? { guard proto.hasBody else { @@ -3355,7 +3449,7 @@ extension SSKProtoDataMessagePreview.SSKProtoDataMessagePreviewBuilder { quote: SSKProtoDataMessageQuote?, contact: [SSKProtoDataMessageContact], preview: [SSKProtoDataMessagePreview], - profile: SSKProtoDataMessageContact?) { + profile: SSKProtoDataMessageLokiProfile?) { self.proto = proto self.attachments = attachments self.group = group @@ -3395,9 +3489,9 @@ extension SSKProtoDataMessagePreview.SSKProtoDataMessagePreviewBuilder { var preview: [SSKProtoDataMessagePreview] = [] preview = try proto.preview.map { try SSKProtoDataMessagePreview.parseProto($0) } - var profile: SSKProtoDataMessageContact? = nil + var profile: SSKProtoDataMessageLokiProfile? = nil if proto.hasProfile { - profile = try SSKProtoDataMessageContact.parseProto(proto.profile) + profile = try SSKProtoDataMessageLokiProfile.parseProto(proto.profile) } // MARK: - Begin Validation Logic for SSKProtoDataMessage - diff --git a/SignalServiceKit/src/Protos/Generated/SignalService.pb.swift b/SignalServiceKit/src/Protos/Generated/SignalService.pb.swift index b5e1f4b26..8f2176d04 100644 --- a/SignalServiceKit/src/Protos/Generated/SignalService.pb.swift +++ b/SignalServiceKit/src/Protos/Generated/SignalService.pb.swift @@ -793,8 +793,8 @@ struct SignalServiceProtos_DataMessage { } /// Loki: The current user's profile - var profile: SignalServiceProtos_DataMessage.Contact { - get {return _storage._profile ?? SignalServiceProtos_DataMessage.Contact()} + var profile: SignalServiceProtos_DataMessage.LokiProfile { + get {return _storage._profile ?? SignalServiceProtos_DataMessage.LokiProfile()} set {_uniqueStorage()._profile = newValue} } /// Returns true if `profile` has been explicitly set. @@ -1420,6 +1420,28 @@ struct SignalServiceProtos_DataMessage { fileprivate var _storage = _StorageClass.defaultInstance } + /// Loki: A custom message for our profile + struct LokiProfile { + // 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. + + var displayName: String { + get {return _displayName ?? String()} + set {_displayName = newValue} + } + /// Returns true if `displayName` has been explicitly set. + var hasDisplayName: Bool {return self._displayName != nil} + /// Clears the value of `displayName`. Subsequent reads from it will return its default value. + mutating func clearDisplayName() {self._displayName = nil} + + var unknownFields = SwiftProtobuf.UnknownStorage() + + init() {} + + fileprivate var _displayName: String? = nil + } + init() {} fileprivate var _storage = _StorageClass.defaultInstance @@ -3137,7 +3159,7 @@ extension SignalServiceProtos_DataMessage: SwiftProtobuf.Message, SwiftProtobuf. var _quote: SignalServiceProtos_DataMessage.Quote? = nil var _contact: [SignalServiceProtos_DataMessage.Contact] = [] var _preview: [SignalServiceProtos_DataMessage.Preview] = [] - var _profile: SignalServiceProtos_DataMessage.Contact? = nil + var _profile: SignalServiceProtos_DataMessage.LokiProfile? = nil static let defaultInstance = _StorageClass() @@ -3888,6 +3910,35 @@ extension SignalServiceProtos_DataMessage.Preview: SwiftProtobuf.Message, SwiftP } } +extension SignalServiceProtos_DataMessage.LokiProfile: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { + static let protoMessageName: String = SignalServiceProtos_DataMessage.protoMessageName + ".LokiProfile" + static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ + 1: .same(proto: "displayName"), + ] + + mutating func decodeMessage(decoder: inout D) throws { + while let fieldNumber = try decoder.nextFieldNumber() { + switch fieldNumber { + case 1: try decoder.decodeSingularStringField(value: &self._displayName) + default: break + } + } + } + + func traverse(visitor: inout V) throws { + if let v = self._displayName { + try visitor.visitSingularStringField(value: v, fieldNumber: 1) + } + try unknownFields.traverse(visitor: &visitor) + } + + static func ==(lhs: SignalServiceProtos_DataMessage.LokiProfile, rhs: SignalServiceProtos_DataMessage.LokiProfile) -> Bool { + if lhs._displayName != rhs._displayName {return false} + if lhs.unknownFields != rhs.unknownFields {return false} + return true + } +} + extension SignalServiceProtos_NullMessage: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { static let protoMessageName: String = _protobuf_package + ".NullMessage" static let _protobuf_nameMap: SwiftProtobuf._NameMap = [