common.pb.swift 9.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302
  1. // _____ _
  2. // |_ _| |_ _ _ ___ ___ _ __ __ _
  3. // | | | ' \| '_/ -_) -_) ' \/ _` |_
  4. // |_| |_||_|_| \___\___|_|_|_\__,_(_)
  5. //
  6. // Threema iOS Client
  7. // Copyright (c) 2020 Threema GmbH
  8. //
  9. // This program is free software: you can redistribute it and/or modify
  10. // it under the terms of the GNU Affero General Public License, version 3,
  11. // as published by the Free Software Foundation.
  12. //
  13. // This program is distributed in the hope that it will be useful,
  14. // but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. // GNU Affero General Public License for more details.
  17. //
  18. // You should have received a copy of the GNU Affero General Public License
  19. // along with this program. If not, see <https://www.gnu.org/licenses/>.
  20. import Foundation
  21. import SwiftProtobuf
  22. // If the compiler emits an error on this type, it is because this file
  23. // was generated by a version of the `protoc` Swift plug-in that is
  24. // incompatible with the version of SwiftProtobuf to which you are linking.
  25. // Please ensure that you are building against the same version of the API
  26. // that was used to generate this file.
  27. fileprivate struct _GeneratedWithProtocGenSwiftVersion: SwiftProtobuf.ProtobufAPIVersionCheck {
  28. struct _2: SwiftProtobuf.ProtobufAPIVersion_2 {}
  29. typealias Version = _2
  30. }
  31. /// Threema Blob to be uploaded/downloaded from the Blob server.
  32. struct Common_Blob {
  33. // SwiftProtobuf.Message conformance is added in an extension below. See the
  34. // `Message` and `Message+*Additions` files in the SwiftProtobuf library for
  35. // methods supported on all messages.
  36. /// Blob ID as given by the Blob server
  37. var id: Data = SwiftProtobuf.Internal.emptyData
  38. /// Nonce used for encrypting/decrypting the Blob.
  39. /// Note: May be omitted if unambigously defined by the context.
  40. var nonce: Data = SwiftProtobuf.Internal.emptyData
  41. /// Secret (or public) key used for encrypting/decrypting the Blob.
  42. /// Note: May be omitted if unambigously defined by the context.
  43. var key: Data = SwiftProtobuf.Internal.emptyData
  44. var unknownFields = SwiftProtobuf.UnknownStorage()
  45. init() {}
  46. }
  47. /// Generic image.
  48. struct Common_Image {
  49. // SwiftProtobuf.Message conformance is added in an extension below. See the
  50. // `Message` and `Message+*Additions` files in the SwiftProtobuf library for
  51. // methods supported on all messages.
  52. var type: Common_Image.TypeEnum = .jpeg
  53. /// The image's source
  54. var source: Common_Image.OneOf_Source? = nil
  55. /// The image's data needs to be downloaded from the Blob server
  56. var blob: Common_Blob {
  57. get {
  58. if case .blob(let v)? = source {return v}
  59. return Common_Blob()
  60. }
  61. set {source = .blob(newValue)}
  62. }
  63. /// The image's data is inlined.
  64. /// Note: This MUST only be used when explicitly allowed.
  65. /// Almost always use a global/device group shared Blob instead!
  66. var data: Data {
  67. get {
  68. if case .data(let v)? = source {return v}
  69. return SwiftProtobuf.Internal.emptyData
  70. }
  71. set {source = .data(newValue)}
  72. }
  73. var unknownFields = SwiftProtobuf.UnknownStorage()
  74. /// The image's source
  75. enum OneOf_Source: Equatable {
  76. /// The image's data needs to be downloaded from the Blob server
  77. case blob(Common_Blob)
  78. /// The image's data is inlined.
  79. /// Note: This MUST only be used when explicitly allowed.
  80. /// Almost always use a global/device group shared Blob instead!
  81. case data(Data)
  82. #if !swift(>=4.1)
  83. static func ==(lhs: Common_Image.OneOf_Source, rhs: Common_Image.OneOf_Source) -> Bool {
  84. switch (lhs, rhs) {
  85. case (.blob(let l), .blob(let r)): return l == r
  86. case (.data(let l), .data(let r)): return l == r
  87. default: return false
  88. }
  89. }
  90. #endif
  91. }
  92. /// Format type of the image
  93. enum TypeEnum: SwiftProtobuf.Enum {
  94. typealias RawValue = Int
  95. case jpeg // = 0
  96. case UNRECOGNIZED(Int)
  97. init() {
  98. self = .jpeg
  99. }
  100. init?(rawValue: Int) {
  101. switch rawValue {
  102. case 0: self = .jpeg
  103. default: self = .UNRECOGNIZED(rawValue)
  104. }
  105. }
  106. var rawValue: Int {
  107. switch self {
  108. case .jpeg: return 0
  109. case .UNRECOGNIZED(let i): return i
  110. }
  111. }
  112. }
  113. init() {}
  114. }
  115. #if swift(>=4.2)
  116. extension Common_Image.TypeEnum: CaseIterable {
  117. // The compiler won't synthesize support with the UNRECOGNIZED case.
  118. static var allCases: [Common_Image.TypeEnum] = [
  119. .jpeg,
  120. ]
  121. }
  122. #endif // swift(>=4.2)
  123. /// Unique group identity.
  124. struct Common_GroupIdentity {
  125. // SwiftProtobuf.Message conformance is added in an extension below. See the
  126. // `Message` and `Message+*Additions` files in the SwiftProtobuf library for
  127. // methods supported on all messages.
  128. /// Group id as chosen by the group's creator
  129. var groupID: UInt64 = 0
  130. /// Threema ID of the group's creator
  131. var creatorIdentity: String = String()
  132. var unknownFields = SwiftProtobuf.UnknownStorage()
  133. init() {}
  134. }
  135. // MARK: - Code below here is support for the SwiftProtobuf runtime.
  136. fileprivate let _protobuf_package = "common"
  137. extension Common_Blob: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding {
  138. static let protoMessageName: String = _protobuf_package + ".Blob"
  139. static let _protobuf_nameMap: SwiftProtobuf._NameMap = [
  140. 1: .same(proto: "id"),
  141. 2: .same(proto: "nonce"),
  142. 3: .same(proto: "key"),
  143. ]
  144. mutating func decodeMessage<D: SwiftProtobuf.Decoder>(decoder: inout D) throws {
  145. while let fieldNumber = try decoder.nextFieldNumber() {
  146. switch fieldNumber {
  147. case 1: try decoder.decodeSingularBytesField(value: &self.id)
  148. case 2: try decoder.decodeSingularBytesField(value: &self.nonce)
  149. case 3: try decoder.decodeSingularBytesField(value: &self.key)
  150. default: break
  151. }
  152. }
  153. }
  154. func traverse<V: SwiftProtobuf.Visitor>(visitor: inout V) throws {
  155. if !self.id.isEmpty {
  156. try visitor.visitSingularBytesField(value: self.id, fieldNumber: 1)
  157. }
  158. if !self.nonce.isEmpty {
  159. try visitor.visitSingularBytesField(value: self.nonce, fieldNumber: 2)
  160. }
  161. if !self.key.isEmpty {
  162. try visitor.visitSingularBytesField(value: self.key, fieldNumber: 3)
  163. }
  164. try unknownFields.traverse(visitor: &visitor)
  165. }
  166. static func ==(lhs: Common_Blob, rhs: Common_Blob) -> Bool {
  167. if lhs.id != rhs.id {return false}
  168. if lhs.nonce != rhs.nonce {return false}
  169. if lhs.key != rhs.key {return false}
  170. if lhs.unknownFields != rhs.unknownFields {return false}
  171. return true
  172. }
  173. }
  174. extension Common_Image: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding {
  175. static let protoMessageName: String = _protobuf_package + ".Image"
  176. static let _protobuf_nameMap: SwiftProtobuf._NameMap = [
  177. 1: .same(proto: "type"),
  178. 2: .same(proto: "blob"),
  179. 3: .same(proto: "data"),
  180. ]
  181. mutating func decodeMessage<D: SwiftProtobuf.Decoder>(decoder: inout D) throws {
  182. while let fieldNumber = try decoder.nextFieldNumber() {
  183. switch fieldNumber {
  184. case 1: try decoder.decodeSingularEnumField(value: &self.type)
  185. case 2:
  186. var v: Common_Blob?
  187. if let current = self.source {
  188. try decoder.handleConflictingOneOf()
  189. if case .blob(let m) = current {v = m}
  190. }
  191. try decoder.decodeSingularMessageField(value: &v)
  192. if let v = v {self.source = .blob(v)}
  193. case 3:
  194. if self.source != nil {try decoder.handleConflictingOneOf()}
  195. var v: Data?
  196. try decoder.decodeSingularBytesField(value: &v)
  197. if let v = v {self.source = .data(v)}
  198. default: break
  199. }
  200. }
  201. }
  202. func traverse<V: SwiftProtobuf.Visitor>(visitor: inout V) throws {
  203. if self.type != .jpeg {
  204. try visitor.visitSingularEnumField(value: self.type, fieldNumber: 1)
  205. }
  206. switch self.source {
  207. case .blob(let v)?:
  208. try visitor.visitSingularMessageField(value: v, fieldNumber: 2)
  209. case .data(let v)?:
  210. try visitor.visitSingularBytesField(value: v, fieldNumber: 3)
  211. case nil: break
  212. }
  213. try unknownFields.traverse(visitor: &visitor)
  214. }
  215. static func ==(lhs: Common_Image, rhs: Common_Image) -> Bool {
  216. if lhs.type != rhs.type {return false}
  217. if lhs.source != rhs.source {return false}
  218. if lhs.unknownFields != rhs.unknownFields {return false}
  219. return true
  220. }
  221. }
  222. extension Common_Image.TypeEnum: SwiftProtobuf._ProtoNameProviding {
  223. static let _protobuf_nameMap: SwiftProtobuf._NameMap = [
  224. 0: .same(proto: "JPEG"),
  225. ]
  226. }
  227. extension Common_GroupIdentity: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding {
  228. static let protoMessageName: String = _protobuf_package + ".GroupIdentity"
  229. static let _protobuf_nameMap: SwiftProtobuf._NameMap = [
  230. 1: .standard(proto: "group_id"),
  231. 2: .standard(proto: "creator_identity"),
  232. ]
  233. mutating func decodeMessage<D: SwiftProtobuf.Decoder>(decoder: inout D) throws {
  234. while let fieldNumber = try decoder.nextFieldNumber() {
  235. switch fieldNumber {
  236. case 1: try decoder.decodeSingularFixed64Field(value: &self.groupID)
  237. case 2: try decoder.decodeSingularStringField(value: &self.creatorIdentity)
  238. default: break
  239. }
  240. }
  241. }
  242. func traverse<V: SwiftProtobuf.Visitor>(visitor: inout V) throws {
  243. if self.groupID != 0 {
  244. try visitor.visitSingularFixed64Field(value: self.groupID, fieldNumber: 1)
  245. }
  246. if !self.creatorIdentity.isEmpty {
  247. try visitor.visitSingularStringField(value: self.creatorIdentity, fieldNumber: 2)
  248. }
  249. try unknownFields.traverse(visitor: &visitor)
  250. }
  251. static func ==(lhs: Common_GroupIdentity, rhs: Common_GroupIdentity) -> Bool {
  252. if lhs.groupID != rhs.groupID {return false}
  253. if lhs.creatorIdentity != rhs.creatorIdentity {return false}
  254. if lhs.unknownFields != rhs.unknownFields {return false}
  255. return true
  256. }
  257. }