CoreApi.g.swift 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341
  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. func openPackage(packageName: String) throws
  86. }
  87. /// Generated setup class from Pigeon to handle messages through the `binaryMessenger`.
  88. class CoreApiSetup {
  89. static var codec: FlutterStandardMessageCodec { CoreApiPigeonCodec.shared }
  90. /// Sets up an instance of `CoreApi` to handle messages through the `binaryMessenger`.
  91. static func setUp(binaryMessenger: FlutterBinaryMessenger, api: CoreApi?, messageChannelSuffix: String = "") {
  92. let channelSuffix = messageChannelSuffix.count > 0 ? ".\(messageChannelSuffix)" : ""
  93. let getAppsChannel = FlutterBasicMessageChannel(name: "dev.flutter.pigeon.app.xixi.nomo.CoreApi.getApps\(channelSuffix)", binaryMessenger: binaryMessenger, codec: codec)
  94. if let api = api {
  95. getAppsChannel.setMessageHandler { _, reply in
  96. api.getApps { result in
  97. switch result {
  98. case .success(let res):
  99. reply(wrapResult(res))
  100. case .failure(let error):
  101. reply(wrapError(error))
  102. }
  103. }
  104. }
  105. } else {
  106. getAppsChannel.setMessageHandler(nil)
  107. }
  108. let getSystemLocaleChannel = FlutterBasicMessageChannel(name: "dev.flutter.pigeon.app.xixi.nomo.CoreApi.getSystemLocale\(channelSuffix)", binaryMessenger: binaryMessenger, codec: codec)
  109. if let api = api {
  110. getSystemLocaleChannel.setMessageHandler { _, reply in
  111. do {
  112. let result = try api.getSystemLocale()
  113. reply(wrapResult(result))
  114. } catch {
  115. reply(wrapError(error))
  116. }
  117. }
  118. } else {
  119. getSystemLocaleChannel.setMessageHandler(nil)
  120. }
  121. let connectChannel = FlutterBasicMessageChannel(name: "dev.flutter.pigeon.app.xixi.nomo.CoreApi.connect\(channelSuffix)", binaryMessenger: binaryMessenger, codec: codec)
  122. if let api = api {
  123. connectChannel.setMessageHandler { message, reply in
  124. let args = message as! [Any?]
  125. let sessionIdArg = args[0] as! String
  126. let socksPortArg = args[1] as! Int64
  127. let tunnelConfigArg = args[2] as! String
  128. let configJsonArg = args[3] as! String
  129. let remainTimeArg = args[4] as! Int64
  130. let isCountdownArg = args[5] as! Bool
  131. let allowVpnAppsArg = args[6] as! [String]
  132. let disallowVpnAppsArg = args[7] as! [String]
  133. let accessTokenArg = args[8] as! String
  134. let aesKeyArg = args[9] as! String
  135. let aesIvArg = args[10] as! String
  136. let locationIdArg = args[11] as! Int64
  137. let locationCodeArg = args[12] as! String
  138. let baseUrlsArg = args[13] as! [String]
  139. let paramsArg = args[14] as! String
  140. let peekTimeIntervalArg = args[15] as! Int64
  141. do {
  142. 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)
  143. reply(wrapResult(result))
  144. } catch {
  145. reply(wrapError(error))
  146. }
  147. }
  148. } else {
  149. connectChannel.setMessageHandler(nil)
  150. }
  151. let disconnectChannel = FlutterBasicMessageChannel(name: "dev.flutter.pigeon.app.xixi.nomo.CoreApi.disconnect\(channelSuffix)", binaryMessenger: binaryMessenger, codec: codec)
  152. if let api = api {
  153. disconnectChannel.setMessageHandler { _, reply in
  154. do {
  155. let result = try api.disconnect()
  156. reply(wrapResult(result))
  157. } catch {
  158. reply(wrapError(error))
  159. }
  160. }
  161. } else {
  162. disconnectChannel.setMessageHandler(nil)
  163. }
  164. let getRemoteIpChannel = FlutterBasicMessageChannel(name: "dev.flutter.pigeon.app.xixi.nomo.CoreApi.getRemoteIp\(channelSuffix)", binaryMessenger: binaryMessenger, codec: codec)
  165. if let api = api {
  166. getRemoteIpChannel.setMessageHandler { _, reply in
  167. do {
  168. let result = try api.getRemoteIp()
  169. reply(wrapResult(result))
  170. } catch {
  171. reply(wrapError(error))
  172. }
  173. }
  174. } else {
  175. getRemoteIpChannel.setMessageHandler(nil)
  176. }
  177. let getAdvertisingIdChannel = FlutterBasicMessageChannel(name: "dev.flutter.pigeon.app.xixi.nomo.CoreApi.getAdvertisingId\(channelSuffix)", binaryMessenger: binaryMessenger, codec: codec)
  178. if let api = api {
  179. getAdvertisingIdChannel.setMessageHandler { _, reply in
  180. do {
  181. let result = try api.getAdvertisingId()
  182. reply(wrapResult(result))
  183. } catch {
  184. reply(wrapError(error))
  185. }
  186. }
  187. } else {
  188. getAdvertisingIdChannel.setMessageHandler(nil)
  189. }
  190. let moveTaskToBackChannel = FlutterBasicMessageChannel(name: "dev.flutter.pigeon.app.xixi.nomo.CoreApi.moveTaskToBack\(channelSuffix)", binaryMessenger: binaryMessenger, codec: codec)
  191. if let api = api {
  192. moveTaskToBackChannel.setMessageHandler { _, reply in
  193. do {
  194. let result = try api.moveTaskToBack()
  195. reply(wrapResult(result))
  196. } catch {
  197. reply(wrapError(error))
  198. }
  199. }
  200. } else {
  201. moveTaskToBackChannel.setMessageHandler(nil)
  202. }
  203. let isConnectedChannel = FlutterBasicMessageChannel(name: "dev.flutter.pigeon.app.xixi.nomo.CoreApi.isConnected\(channelSuffix)", binaryMessenger: binaryMessenger, codec: codec)
  204. if let api = api {
  205. isConnectedChannel.setMessageHandler { _, reply in
  206. do {
  207. let result = try api.isConnected()
  208. reply(wrapResult(result))
  209. } catch {
  210. reply(wrapError(error))
  211. }
  212. }
  213. } else {
  214. isConnectedChannel.setMessageHandler(nil)
  215. }
  216. let getSimInfoChannel = FlutterBasicMessageChannel(name: "dev.flutter.pigeon.app.xixi.nomo.CoreApi.getSimInfo\(channelSuffix)", binaryMessenger: binaryMessenger, codec: codec)
  217. if let api = api {
  218. getSimInfoChannel.setMessageHandler { _, reply in
  219. do {
  220. let result = try api.getSimInfo()
  221. reply(wrapResult(result))
  222. } catch {
  223. reply(wrapError(error))
  224. }
  225. }
  226. } else {
  227. getSimInfoChannel.setMessageHandler(nil)
  228. }
  229. let getChannelChannel = FlutterBasicMessageChannel(name: "dev.flutter.pigeon.app.xixi.nomo.CoreApi.getChannel\(channelSuffix)", binaryMessenger: binaryMessenger, codec: codec)
  230. if let api = api {
  231. getChannelChannel.setMessageHandler { _, reply in
  232. do {
  233. let result = try api.getChannel()
  234. reply(wrapResult(result))
  235. } catch {
  236. reply(wrapError(error))
  237. }
  238. }
  239. } else {
  240. getChannelChannel.setMessageHandler(nil)
  241. }
  242. let openPackageChannel = FlutterBasicMessageChannel(name: "dev.flutter.pigeon.app.xixi.nomo.CoreApi.openPackage\(channelSuffix)", binaryMessenger: binaryMessenger, codec: codec)
  243. if let api = api {
  244. openPackageChannel.setMessageHandler { message, reply in
  245. let args = message as! [Any?]
  246. let packageNameArg = args[0] as! String
  247. do {
  248. try api.openPackage(packageName: packageNameArg)
  249. reply(wrapResult(nil))
  250. } catch {
  251. reply(wrapError(error))
  252. }
  253. }
  254. } else {
  255. openPackageChannel.setMessageHandler(nil)
  256. }
  257. }
  258. }
  259. private class PigeonStreamHandler<ReturnType>: NSObject, FlutterStreamHandler {
  260. private let wrapper: PigeonEventChannelWrapper<ReturnType>
  261. private var pigeonSink: PigeonEventSink<ReturnType>? = nil
  262. init(wrapper: PigeonEventChannelWrapper<ReturnType>) {
  263. self.wrapper = wrapper
  264. }
  265. func onListen(withArguments arguments: Any?, eventSink events: @escaping FlutterEventSink)
  266. -> FlutterError?
  267. {
  268. pigeonSink = PigeonEventSink<ReturnType>(events)
  269. wrapper.onListen(withArguments: arguments, sink: pigeonSink!)
  270. return nil
  271. }
  272. func onCancel(withArguments arguments: Any?) -> FlutterError? {
  273. pigeonSink = nil
  274. wrapper.onCancel(withArguments: arguments)
  275. return nil
  276. }
  277. }
  278. class PigeonEventChannelWrapper<ReturnType> {
  279. func onListen(withArguments arguments: Any?, sink: PigeonEventSink<ReturnType>) {}
  280. func onCancel(withArguments arguments: Any?) {}
  281. }
  282. class PigeonEventSink<ReturnType> {
  283. private let sink: FlutterEventSink
  284. init(_ sink: @escaping FlutterEventSink) {
  285. self.sink = sink
  286. }
  287. func success(_ value: ReturnType) {
  288. sink(value)
  289. }
  290. func error(code: String, message: String?, details: Any?) {
  291. sink(FlutterError(code: code, message: message, details: details))
  292. }
  293. func endOfStream() {
  294. sink(FlutterEndOfEventStream)
  295. }
  296. }
  297. class OnEventChangeStreamHandler: PigeonEventChannelWrapper<String> {
  298. static func register(with messenger: FlutterBinaryMessenger,
  299. instanceName: String = "",
  300. streamHandler: OnEventChangeStreamHandler) {
  301. var channelName = "dev.flutter.pigeon.app.xixi.nomo.CoreChangeEventApi.onEventChange"
  302. if !instanceName.isEmpty {
  303. channelName += ".\(instanceName)"
  304. }
  305. let internalStreamHandler = PigeonStreamHandler<String>(wrapper: streamHandler)
  306. let channel = FlutterEventChannel(name: channelName, binaryMessenger: messenger, codec: coreApiPigeonMethodCodec)
  307. channel.setStreamHandler(internalStreamHandler)
  308. }
  309. }