mirror of
https://github.com/immich-app/immich.git
synced 2025-09-29 15:31:13 -04:00
* feat: add configurable on charging only and delay * Segmented and style the settings --------- Co-authored-by: shenlong-tanwen <139912620+shalong-tanwen@users.noreply.github.com> Co-authored-by: Alex <alex.tran1502@gmail.com>
366 lines
13 KiB
Swift
366 lines
13 KiB
Swift
// Autogenerated from Pigeon (v26.0.0), do not edit directly.
|
|
// See also: https://pub.dev/packages/pigeon
|
|
|
|
import Foundation
|
|
|
|
#if os(iOS)
|
|
import Flutter
|
|
#elseif os(macOS)
|
|
import FlutterMacOS
|
|
#else
|
|
#error("Unsupported platform.")
|
|
#endif
|
|
|
|
private func wrapResult(_ result: Any?) -> [Any?] {
|
|
return [result]
|
|
}
|
|
|
|
private func wrapError(_ error: Any) -> [Any?] {
|
|
if let pigeonError = error as? PigeonError {
|
|
return [
|
|
pigeonError.code,
|
|
pigeonError.message,
|
|
pigeonError.details,
|
|
]
|
|
}
|
|
if let flutterError = error as? FlutterError {
|
|
return [
|
|
flutterError.code,
|
|
flutterError.message,
|
|
flutterError.details,
|
|
]
|
|
}
|
|
return [
|
|
"\(error)",
|
|
"\(type(of: error))",
|
|
"Stacktrace: \(Thread.callStackSymbols)",
|
|
]
|
|
}
|
|
|
|
private func createConnectionError(withChannelName channelName: String) -> PigeonError {
|
|
return PigeonError(code: "channel-error", message: "Unable to establish connection on channel: '\(channelName)'.", details: "")
|
|
}
|
|
|
|
private func isNullish(_ value: Any?) -> Bool {
|
|
return value is NSNull || value == nil
|
|
}
|
|
|
|
private func nilOrValue<T>(_ value: Any?) -> T? {
|
|
if value is NSNull { return nil }
|
|
return value as! T?
|
|
}
|
|
|
|
func deepEqualsBackgroundWorker(_ lhs: Any?, _ rhs: Any?) -> Bool {
|
|
let cleanLhs = nilOrValue(lhs) as Any?
|
|
let cleanRhs = nilOrValue(rhs) as Any?
|
|
switch (cleanLhs, cleanRhs) {
|
|
case (nil, nil):
|
|
return true
|
|
|
|
case (nil, _), (_, nil):
|
|
return false
|
|
|
|
case is (Void, Void):
|
|
return true
|
|
|
|
case let (cleanLhsHashable, cleanRhsHashable) as (AnyHashable, AnyHashable):
|
|
return cleanLhsHashable == cleanRhsHashable
|
|
|
|
case let (cleanLhsArray, cleanRhsArray) as ([Any?], [Any?]):
|
|
guard cleanLhsArray.count == cleanRhsArray.count else { return false }
|
|
for (index, element) in cleanLhsArray.enumerated() {
|
|
if !deepEqualsBackgroundWorker(element, cleanRhsArray[index]) {
|
|
return false
|
|
}
|
|
}
|
|
return true
|
|
|
|
case let (cleanLhsDictionary, cleanRhsDictionary) as ([AnyHashable: Any?], [AnyHashable: Any?]):
|
|
guard cleanLhsDictionary.count == cleanRhsDictionary.count else { return false }
|
|
for (key, cleanLhsValue) in cleanLhsDictionary {
|
|
guard cleanRhsDictionary.index(forKey: key) != nil else { return false }
|
|
if !deepEqualsBackgroundWorker(cleanLhsValue, cleanRhsDictionary[key]!) {
|
|
return false
|
|
}
|
|
}
|
|
return true
|
|
|
|
default:
|
|
// Any other type shouldn't be able to be used with pigeon. File an issue if you find this to be untrue.
|
|
return false
|
|
}
|
|
}
|
|
|
|
func deepHashBackgroundWorker(value: Any?, hasher: inout Hasher) {
|
|
if let valueList = value as? [AnyHashable] {
|
|
for item in valueList { deepHashBackgroundWorker(value: item, hasher: &hasher) }
|
|
return
|
|
}
|
|
|
|
if let valueDict = value as? [AnyHashable: AnyHashable] {
|
|
for key in valueDict.keys {
|
|
hasher.combine(key)
|
|
deepHashBackgroundWorker(value: valueDict[key]!, hasher: &hasher)
|
|
}
|
|
return
|
|
}
|
|
|
|
if let hashableValue = value as? AnyHashable {
|
|
hasher.combine(hashableValue.hashValue)
|
|
}
|
|
|
|
return hasher.combine(String(describing: value))
|
|
}
|
|
|
|
|
|
|
|
/// Generated class from Pigeon that represents data sent in messages.
|
|
struct BackgroundWorkerSettings: Hashable {
|
|
var requiresCharging: Bool
|
|
var minimumDelaySeconds: Int64
|
|
|
|
|
|
// swift-format-ignore: AlwaysUseLowerCamelCase
|
|
static func fromList(_ pigeonVar_list: [Any?]) -> BackgroundWorkerSettings? {
|
|
let requiresCharging = pigeonVar_list[0] as! Bool
|
|
let minimumDelaySeconds = pigeonVar_list[1] as! Int64
|
|
|
|
return BackgroundWorkerSettings(
|
|
requiresCharging: requiresCharging,
|
|
minimumDelaySeconds: minimumDelaySeconds
|
|
)
|
|
}
|
|
func toList() -> [Any?] {
|
|
return [
|
|
requiresCharging,
|
|
minimumDelaySeconds,
|
|
]
|
|
}
|
|
static func == (lhs: BackgroundWorkerSettings, rhs: BackgroundWorkerSettings) -> Bool {
|
|
return deepEqualsBackgroundWorker(lhs.toList(), rhs.toList()) }
|
|
func hash(into hasher: inout Hasher) {
|
|
deepHashBackgroundWorker(value: toList(), hasher: &hasher)
|
|
}
|
|
}
|
|
|
|
private class BackgroundWorkerPigeonCodecReader: FlutterStandardReader {
|
|
override func readValue(ofType type: UInt8) -> Any? {
|
|
switch type {
|
|
case 129:
|
|
return BackgroundWorkerSettings.fromList(self.readValue() as! [Any?])
|
|
default:
|
|
return super.readValue(ofType: type)
|
|
}
|
|
}
|
|
}
|
|
|
|
private class BackgroundWorkerPigeonCodecWriter: FlutterStandardWriter {
|
|
override func writeValue(_ value: Any) {
|
|
if let value = value as? BackgroundWorkerSettings {
|
|
super.writeByte(129)
|
|
super.writeValue(value.toList())
|
|
} else {
|
|
super.writeValue(value)
|
|
}
|
|
}
|
|
}
|
|
|
|
private class BackgroundWorkerPigeonCodecReaderWriter: FlutterStandardReaderWriter {
|
|
override func reader(with data: Data) -> FlutterStandardReader {
|
|
return BackgroundWorkerPigeonCodecReader(data: data)
|
|
}
|
|
|
|
override func writer(with data: NSMutableData) -> FlutterStandardWriter {
|
|
return BackgroundWorkerPigeonCodecWriter(data: data)
|
|
}
|
|
}
|
|
|
|
class BackgroundWorkerPigeonCodec: FlutterStandardMessageCodec, @unchecked Sendable {
|
|
static let shared = BackgroundWorkerPigeonCodec(readerWriter: BackgroundWorkerPigeonCodecReaderWriter())
|
|
}
|
|
|
|
/// Generated protocol from Pigeon that represents a handler of messages from Flutter.
|
|
protocol BackgroundWorkerFgHostApi {
|
|
func enable() throws
|
|
func configure(settings: BackgroundWorkerSettings) throws
|
|
func disable() throws
|
|
}
|
|
|
|
/// Generated setup class from Pigeon to handle messages through the `binaryMessenger`.
|
|
class BackgroundWorkerFgHostApiSetup {
|
|
static var codec: FlutterStandardMessageCodec { BackgroundWorkerPigeonCodec.shared }
|
|
/// Sets up an instance of `BackgroundWorkerFgHostApi` to handle messages through the `binaryMessenger`.
|
|
static func setUp(binaryMessenger: FlutterBinaryMessenger, api: BackgroundWorkerFgHostApi?, messageChannelSuffix: String = "") {
|
|
let channelSuffix = messageChannelSuffix.count > 0 ? ".\(messageChannelSuffix)" : ""
|
|
let enableChannel = FlutterBasicMessageChannel(name: "dev.flutter.pigeon.immich_mobile.BackgroundWorkerFgHostApi.enable\(channelSuffix)", binaryMessenger: binaryMessenger, codec: codec)
|
|
if let api = api {
|
|
enableChannel.setMessageHandler { _, reply in
|
|
do {
|
|
try api.enable()
|
|
reply(wrapResult(nil))
|
|
} catch {
|
|
reply(wrapError(error))
|
|
}
|
|
}
|
|
} else {
|
|
enableChannel.setMessageHandler(nil)
|
|
}
|
|
let configureChannel = FlutterBasicMessageChannel(name: "dev.flutter.pigeon.immich_mobile.BackgroundWorkerFgHostApi.configure\(channelSuffix)", binaryMessenger: binaryMessenger, codec: codec)
|
|
if let api = api {
|
|
configureChannel.setMessageHandler { message, reply in
|
|
let args = message as! [Any?]
|
|
let settingsArg = args[0] as! BackgroundWorkerSettings
|
|
do {
|
|
try api.configure(settings: settingsArg)
|
|
reply(wrapResult(nil))
|
|
} catch {
|
|
reply(wrapError(error))
|
|
}
|
|
}
|
|
} else {
|
|
configureChannel.setMessageHandler(nil)
|
|
}
|
|
let disableChannel = FlutterBasicMessageChannel(name: "dev.flutter.pigeon.immich_mobile.BackgroundWorkerFgHostApi.disable\(channelSuffix)", binaryMessenger: binaryMessenger, codec: codec)
|
|
if let api = api {
|
|
disableChannel.setMessageHandler { _, reply in
|
|
do {
|
|
try api.disable()
|
|
reply(wrapResult(nil))
|
|
} catch {
|
|
reply(wrapError(error))
|
|
}
|
|
}
|
|
} else {
|
|
disableChannel.setMessageHandler(nil)
|
|
}
|
|
}
|
|
}
|
|
/// Generated protocol from Pigeon that represents a handler of messages from Flutter.
|
|
protocol BackgroundWorkerBgHostApi {
|
|
func onInitialized() throws
|
|
func showNotification(title: String, content: String) throws
|
|
func close() throws
|
|
}
|
|
|
|
/// Generated setup class from Pigeon to handle messages through the `binaryMessenger`.
|
|
class BackgroundWorkerBgHostApiSetup {
|
|
static var codec: FlutterStandardMessageCodec { BackgroundWorkerPigeonCodec.shared }
|
|
/// Sets up an instance of `BackgroundWorkerBgHostApi` to handle messages through the `binaryMessenger`.
|
|
static func setUp(binaryMessenger: FlutterBinaryMessenger, api: BackgroundWorkerBgHostApi?, messageChannelSuffix: String = "") {
|
|
let channelSuffix = messageChannelSuffix.count > 0 ? ".\(messageChannelSuffix)" : ""
|
|
let onInitializedChannel = FlutterBasicMessageChannel(name: "dev.flutter.pigeon.immich_mobile.BackgroundWorkerBgHostApi.onInitialized\(channelSuffix)", binaryMessenger: binaryMessenger, codec: codec)
|
|
if let api = api {
|
|
onInitializedChannel.setMessageHandler { _, reply in
|
|
do {
|
|
try api.onInitialized()
|
|
reply(wrapResult(nil))
|
|
} catch {
|
|
reply(wrapError(error))
|
|
}
|
|
}
|
|
} else {
|
|
onInitializedChannel.setMessageHandler(nil)
|
|
}
|
|
let showNotificationChannel = FlutterBasicMessageChannel(name: "dev.flutter.pigeon.immich_mobile.BackgroundWorkerBgHostApi.showNotification\(channelSuffix)", binaryMessenger: binaryMessenger, codec: codec)
|
|
if let api = api {
|
|
showNotificationChannel.setMessageHandler { message, reply in
|
|
let args = message as! [Any?]
|
|
let titleArg = args[0] as! String
|
|
let contentArg = args[1] as! String
|
|
do {
|
|
try api.showNotification(title: titleArg, content: contentArg)
|
|
reply(wrapResult(nil))
|
|
} catch {
|
|
reply(wrapError(error))
|
|
}
|
|
}
|
|
} else {
|
|
showNotificationChannel.setMessageHandler(nil)
|
|
}
|
|
let closeChannel = FlutterBasicMessageChannel(name: "dev.flutter.pigeon.immich_mobile.BackgroundWorkerBgHostApi.close\(channelSuffix)", binaryMessenger: binaryMessenger, codec: codec)
|
|
if let api = api {
|
|
closeChannel.setMessageHandler { _, reply in
|
|
do {
|
|
try api.close()
|
|
reply(wrapResult(nil))
|
|
} catch {
|
|
reply(wrapError(error))
|
|
}
|
|
}
|
|
} else {
|
|
closeChannel.setMessageHandler(nil)
|
|
}
|
|
}
|
|
}
|
|
/// Generated protocol from Pigeon that represents Flutter messages that can be called from Swift.
|
|
protocol BackgroundWorkerFlutterApiProtocol {
|
|
func onIosUpload(isRefresh isRefreshArg: Bool, maxSeconds maxSecondsArg: Int64?, completion: @escaping (Result<Void, PigeonError>) -> Void)
|
|
func onAndroidUpload(completion: @escaping (Result<Void, PigeonError>) -> Void)
|
|
func cancel(completion: @escaping (Result<Void, PigeonError>) -> Void)
|
|
}
|
|
class BackgroundWorkerFlutterApi: BackgroundWorkerFlutterApiProtocol {
|
|
private let binaryMessenger: FlutterBinaryMessenger
|
|
private let messageChannelSuffix: String
|
|
init(binaryMessenger: FlutterBinaryMessenger, messageChannelSuffix: String = "") {
|
|
self.binaryMessenger = binaryMessenger
|
|
self.messageChannelSuffix = messageChannelSuffix.count > 0 ? ".\(messageChannelSuffix)" : ""
|
|
}
|
|
var codec: BackgroundWorkerPigeonCodec {
|
|
return BackgroundWorkerPigeonCodec.shared
|
|
}
|
|
func onIosUpload(isRefresh isRefreshArg: Bool, maxSeconds maxSecondsArg: Int64?, completion: @escaping (Result<Void, PigeonError>) -> Void) {
|
|
let channelName: String = "dev.flutter.pigeon.immich_mobile.BackgroundWorkerFlutterApi.onIosUpload\(messageChannelSuffix)"
|
|
let channel = FlutterBasicMessageChannel(name: channelName, binaryMessenger: binaryMessenger, codec: codec)
|
|
channel.sendMessage([isRefreshArg, maxSecondsArg] as [Any?]) { response in
|
|
guard let listResponse = response as? [Any?] else {
|
|
completion(.failure(createConnectionError(withChannelName: channelName)))
|
|
return
|
|
}
|
|
if listResponse.count > 1 {
|
|
let code: String = listResponse[0] as! String
|
|
let message: String? = nilOrValue(listResponse[1])
|
|
let details: String? = nilOrValue(listResponse[2])
|
|
completion(.failure(PigeonError(code: code, message: message, details: details)))
|
|
} else {
|
|
completion(.success(()))
|
|
}
|
|
}
|
|
}
|
|
func onAndroidUpload(completion: @escaping (Result<Void, PigeonError>) -> Void) {
|
|
let channelName: String = "dev.flutter.pigeon.immich_mobile.BackgroundWorkerFlutterApi.onAndroidUpload\(messageChannelSuffix)"
|
|
let channel = FlutterBasicMessageChannel(name: channelName, binaryMessenger: binaryMessenger, codec: codec)
|
|
channel.sendMessage(nil) { response in
|
|
guard let listResponse = response as? [Any?] else {
|
|
completion(.failure(createConnectionError(withChannelName: channelName)))
|
|
return
|
|
}
|
|
if listResponse.count > 1 {
|
|
let code: String = listResponse[0] as! String
|
|
let message: String? = nilOrValue(listResponse[1])
|
|
let details: String? = nilOrValue(listResponse[2])
|
|
completion(.failure(PigeonError(code: code, message: message, details: details)))
|
|
} else {
|
|
completion(.success(()))
|
|
}
|
|
}
|
|
}
|
|
func cancel(completion: @escaping (Result<Void, PigeonError>) -> Void) {
|
|
let channelName: String = "dev.flutter.pigeon.immich_mobile.BackgroundWorkerFlutterApi.cancel\(messageChannelSuffix)"
|
|
let channel = FlutterBasicMessageChannel(name: channelName, binaryMessenger: binaryMessenger, codec: codec)
|
|
channel.sendMessage(nil) { response in
|
|
guard let listResponse = response as? [Any?] else {
|
|
completion(.failure(createConnectionError(withChannelName: channelName)))
|
|
return
|
|
}
|
|
if listResponse.count > 1 {
|
|
let code: String = listResponse[0] as! String
|
|
let message: String? = nilOrValue(listResponse[1])
|
|
let details: String? = nilOrValue(listResponse[2])
|
|
completion(.failure(PigeonError(code: code, message: message, details: details)))
|
|
} else {
|
|
completion(.success(()))
|
|
}
|
|
}
|
|
}
|
|
}
|