CoreApi.g.swift 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325
  1. // Autogenerated from Pigeon (v26.0.1), do not edit directly.
  2. // See also: https://pub.dev/packages/pigeon
  3. import Foundation
  4. #if os(iOS)
  5. import Flutter
  6. #elseif os(macOS)
  7. import FlutterMacOS
  8. #else
  9. #error("Unsupported platform.")
  10. #endif
  11. /// Error class for passing custom error details to Dart side.
  12. final class PigeonError: Error {
  13. let code: String
  14. let message: String?
  15. let details: Sendable?
  16. init(code: String, message: String?, details: Sendable?) {
  17. self.code = code
  18. self.message = message
  19. self.details = details
  20. }
  21. var localizedDescription: String {
  22. return
  23. "PigeonError(code: \(code), message: \(message ?? "<nil>"), details: \(details ?? "<nil>")"
  24. }
  25. }
  26. private func wrapResult(_ result: Any?) -> [Any?] {
  27. return [result]
  28. }
  29. private func wrapError(_ error: Any) -> [Any?] {
  30. if let pigeonError = error as? PigeonError {
  31. return [
  32. pigeonError.code,
  33. pigeonError.message,
  34. pigeonError.details,
  35. ]
  36. }
  37. if let flutterError = error as? FlutterError {
  38. return [
  39. flutterError.code,
  40. flutterError.message,
  41. flutterError.details,
  42. ]
  43. }
  44. return [
  45. "\(error)",
  46. "\(type(of: error))",
  47. "Stacktrace: \(Thread.callStackSymbols)",
  48. ]
  49. }
  50. private func isNullish(_ value: Any?) -> Bool {
  51. return value is NSNull || value == nil
  52. }
  53. private func nilOrValue<T>(_ value: Any?) -> T? {
  54. if value is NSNull { return nil }
  55. return value as! T?
  56. }
  57. private class CoreApiPigeonCodecReader: FlutterStandardReader {
  58. }
  59. private class CoreApiPigeonCodecWriter: FlutterStandardWriter {
  60. }
  61. private class CoreApiPigeonCodecReaderWriter: FlutterStandardReaderWriter {
  62. override func reader(with data: Data) -> FlutterStandardReader {
  63. return CoreApiPigeonCodecReader(data: data)
  64. }
  65. override func writer(with data: NSMutableData) -> FlutterStandardWriter {
  66. return CoreApiPigeonCodecWriter(data: data)
  67. }
  68. }
  69. class CoreApiPigeonCodec: FlutterStandardMessageCodec, @unchecked Sendable {
  70. static let shared = CoreApiPigeonCodec(readerWriter: CoreApiPigeonCodecReaderWriter())
  71. }
  72. var coreApiPigeonMethodCodec = FlutterStandardMethodCodec(readerWriter: CoreApiPigeonCodecReaderWriter());
  73. /// Generated protocol from Pigeon that represents a handler of messages from Flutter.
  74. protocol CoreApi {
  75. func getApps(completion: @escaping (Result<String?, Error>) -> Void)
  76. func getSystemLocale() throws -> String?
  77. func connect(sessionId: String, socksPort: Int64, tunnelConfig: String, configJson: String, remainTime: Int64, isCountdown: Bool, allowVpnApps: [String], disallowVpnApps: [String], accessToken: String, aesKey: String, aesIv: String, locationId: Int64, locationCode: String, baseUrls: [String], params: String, peekTimeInterval: Int64) throws -> Bool?
  78. func disconnect() throws -> Bool?
  79. func getRemoteIp() throws -> String?
  80. func getAdvertisingId() throws -> String?
  81. func moveTaskToBack() throws -> Bool?
  82. func isConnected() throws -> Bool?
  83. func getSimInfo() throws -> String?
  84. func getChannel() throws -> String?
  85. }
  86. /// Generated setup class from Pigeon to handle messages through the `binaryMessenger`.
  87. class CoreApiSetup {
  88. static var codec: FlutterStandardMessageCodec { CoreApiPigeonCodec.shared }
  89. /// Sets up an instance of `CoreApi` to handle messages through the `binaryMessenger`.
  90. static func setUp(binaryMessenger: FlutterBinaryMessenger, api: CoreApi?, messageChannelSuffix: String = "") {
  91. let channelSuffix = messageChannelSuffix.count > 0 ? ".\(messageChannelSuffix)" : ""
  92. let getAppsChannel = FlutterBasicMessageChannel(name: "dev.flutter.pigeon.app.xixi.nomo.CoreApi.getApps\(channelSuffix)", binaryMessenger: binaryMessenger, codec: codec)
  93. if let api = api {
  94. getAppsChannel.setMessageHandler { _, reply in
  95. api.getApps { result in
  96. switch result {
  97. case .success(let res):
  98. reply(wrapResult(res))
  99. case .failure(let error):
  100. reply(wrapError(error))
  101. }
  102. }
  103. }
  104. } else {
  105. getAppsChannel.setMessageHandler(nil)
  106. }
  107. let getSystemLocaleChannel = FlutterBasicMessageChannel(name: "dev.flutter.pigeon.app.xixi.nomo.CoreApi.getSystemLocale\(channelSuffix)", binaryMessenger: binaryMessenger, codec: codec)
  108. if let api = api {
  109. getSystemLocaleChannel.setMessageHandler { _, reply in
  110. do {
  111. let result = try api.getSystemLocale()
  112. reply(wrapResult(result))
  113. } catch {
  114. reply(wrapError(error))
  115. }
  116. }
  117. } else {
  118. getSystemLocaleChannel.setMessageHandler(nil)
  119. }
  120. let connectChannel = FlutterBasicMessageChannel(name: "dev.flutter.pigeon.app.xixi.nomo.CoreApi.connect\(channelSuffix)", binaryMessenger: binaryMessenger, codec: codec)
  121. if let api = api {
  122. connectChannel.setMessageHandler { message, reply in
  123. let args = message as! [Any?]
  124. let sessionIdArg = args[0] as! String
  125. let socksPortArg = args[1] as! Int64
  126. let tunnelConfigArg = args[2] as! String
  127. let configJsonArg = args[3] as! String
  128. let remainTimeArg = args[4] as! Int64
  129. let isCountdownArg = args[5] as! Bool
  130. let allowVpnAppsArg = args[6] as! [String]
  131. let disallowVpnAppsArg = args[7] as! [String]
  132. let accessTokenArg = args[8] as! String
  133. let aesKeyArg = args[9] as! String
  134. let aesIvArg = args[10] as! String
  135. let locationIdArg = args[11] as! Int64
  136. let locationCodeArg = args[12] as! String
  137. let baseUrlsArg = args[13] as! [String]
  138. let paramsArg = args[14] as! String
  139. let peekTimeIntervalArg = args[15] as! Int64
  140. do {
  141. let result = try api.connect(sessionId: sessionIdArg, socksPort: socksPortArg, tunnelConfig: tunnelConfigArg, configJson: configJsonArg, remainTime: remainTimeArg, isCountdown: isCountdownArg, allowVpnApps: allowVpnAppsArg, disallowVpnApps: disallowVpnAppsArg, accessToken: accessTokenArg, aesKey: aesKeyArg, aesIv: aesIvArg, locationId: locationIdArg, locationCode: locationCodeArg, baseUrls: baseUrlsArg, params: paramsArg, peekTimeInterval: peekTimeIntervalArg)
  142. reply(wrapResult(result))
  143. } catch {
  144. reply(wrapError(error))
  145. }
  146. }
  147. } else {
  148. connectChannel.setMessageHandler(nil)
  149. }
  150. let disconnectChannel = FlutterBasicMessageChannel(name: "dev.flutter.pigeon.app.xixi.nomo.CoreApi.disconnect\(channelSuffix)", binaryMessenger: binaryMessenger, codec: codec)
  151. if let api = api {
  152. disconnectChannel.setMessageHandler { _, reply in
  153. do {
  154. let result = try api.disconnect()
  155. reply(wrapResult(result))
  156. } catch {
  157. reply(wrapError(error))
  158. }
  159. }
  160. } else {
  161. disconnectChannel.setMessageHandler(nil)
  162. }
  163. let getRemoteIpChannel = FlutterBasicMessageChannel(name: "dev.flutter.pigeon.app.xixi.nomo.CoreApi.getRemoteIp\(channelSuffix)", binaryMessenger: binaryMessenger, codec: codec)
  164. if let api = api {
  165. getRemoteIpChannel.setMessageHandler { _, reply in
  166. do {
  167. let result = try api.getRemoteIp()
  168. reply(wrapResult(result))
  169. } catch {
  170. reply(wrapError(error))
  171. }
  172. }
  173. } else {
  174. getRemoteIpChannel.setMessageHandler(nil)
  175. }
  176. let getAdvertisingIdChannel = FlutterBasicMessageChannel(name: "dev.flutter.pigeon.app.xixi.nomo.CoreApi.getAdvertisingId\(channelSuffix)", binaryMessenger: binaryMessenger, codec: codec)
  177. if let api = api {
  178. getAdvertisingIdChannel.setMessageHandler { _, reply in
  179. do {
  180. let result = try api.getAdvertisingId()
  181. reply(wrapResult(result))
  182. } catch {
  183. reply(wrapError(error))
  184. }
  185. }
  186. } else {
  187. getAdvertisingIdChannel.setMessageHandler(nil)
  188. }
  189. let moveTaskToBackChannel = FlutterBasicMessageChannel(name: "dev.flutter.pigeon.app.xixi.nomo.CoreApi.moveTaskToBack\(channelSuffix)", binaryMessenger: binaryMessenger, codec: codec)
  190. if let api = api {
  191. moveTaskToBackChannel.setMessageHandler { _, reply in
  192. do {
  193. let result = try api.moveTaskToBack()
  194. reply(wrapResult(result))
  195. } catch {
  196. reply(wrapError(error))
  197. }
  198. }
  199. } else {
  200. moveTaskToBackChannel.setMessageHandler(nil)
  201. }
  202. let isConnectedChannel = FlutterBasicMessageChannel(name: "dev.flutter.pigeon.app.xixi.nomo.CoreApi.isConnected\(channelSuffix)", binaryMessenger: binaryMessenger, codec: codec)
  203. if let api = api {
  204. isConnectedChannel.setMessageHandler { _, reply in
  205. do {
  206. let result = try api.isConnected()
  207. reply(wrapResult(result))
  208. } catch {
  209. reply(wrapError(error))
  210. }
  211. }
  212. } else {
  213. isConnectedChannel.setMessageHandler(nil)
  214. }
  215. let getSimInfoChannel = FlutterBasicMessageChannel(name: "dev.flutter.pigeon.app.xixi.nomo.CoreApi.getSimInfo\(channelSuffix)", binaryMessenger: binaryMessenger, codec: codec)
  216. if let api = api {
  217. getSimInfoChannel.setMessageHandler { _, reply in
  218. do {
  219. let result = try api.getSimInfo()
  220. reply(wrapResult(result))
  221. } catch {
  222. reply(wrapError(error))
  223. }
  224. }
  225. } else {
  226. getSimInfoChannel.setMessageHandler(nil)
  227. }
  228. let getChannelChannel = FlutterBasicMessageChannel(name: "dev.flutter.pigeon.app.xixi.nomo.CoreApi.getChannel\(channelSuffix)", binaryMessenger: binaryMessenger, codec: codec)
  229. if let api = api {
  230. getChannelChannel.setMessageHandler { _, reply in
  231. do {
  232. let result = try api.getChannel()
  233. reply(wrapResult(result))
  234. } catch {
  235. reply(wrapError(error))
  236. }
  237. }
  238. } else {
  239. getChannelChannel.setMessageHandler(nil)
  240. }
  241. }
  242. }
  243. private class PigeonStreamHandler<ReturnType>: NSObject, FlutterStreamHandler {
  244. private let wrapper: PigeonEventChannelWrapper<ReturnType>
  245. private var pigeonSink: PigeonEventSink<ReturnType>? = nil
  246. init(wrapper: PigeonEventChannelWrapper<ReturnType>) {
  247. self.wrapper = wrapper
  248. }
  249. func onListen(withArguments arguments: Any?, eventSink events: @escaping FlutterEventSink)
  250. -> FlutterError?
  251. {
  252. pigeonSink = PigeonEventSink<ReturnType>(events)
  253. wrapper.onListen(withArguments: arguments, sink: pigeonSink!)
  254. return nil
  255. }
  256. func onCancel(withArguments arguments: Any?) -> FlutterError? {
  257. pigeonSink = nil
  258. wrapper.onCancel(withArguments: arguments)
  259. return nil
  260. }
  261. }
  262. class PigeonEventChannelWrapper<ReturnType> {
  263. func onListen(withArguments arguments: Any?, sink: PigeonEventSink<ReturnType>) {}
  264. func onCancel(withArguments arguments: Any?) {}
  265. }
  266. class PigeonEventSink<ReturnType> {
  267. private let sink: FlutterEventSink
  268. init(_ sink: @escaping FlutterEventSink) {
  269. self.sink = sink
  270. }
  271. func success(_ value: ReturnType) {
  272. sink(value)
  273. }
  274. func error(code: String, message: String?, details: Any?) {
  275. sink(FlutterError(code: code, message: message, details: details))
  276. }
  277. func endOfStream() {
  278. sink(FlutterEndOfEventStream)
  279. }
  280. }
  281. class OnEventChangeStreamHandler: PigeonEventChannelWrapper<String> {
  282. static func register(with messenger: FlutterBinaryMessenger,
  283. instanceName: String = "",
  284. streamHandler: OnEventChangeStreamHandler) {
  285. var channelName = "dev.flutter.pigeon.app.xixi.nomo.CoreChangeEventApi.onEventChange"
  286. if !instanceName.isEmpty {
  287. channelName += ".\(instanceName)"
  288. }
  289. let internalStreamHandler = PigeonStreamHandler<String>(wrapper: streamHandler)
  290. let channel = FlutterEventChannel(name: channelName, binaryMessenger: messenger, codec: coreApiPigeonMethodCodec)
  291. channel.setStreamHandler(internalStreamHandler)
  292. }
  293. }