use serde::de::DeserializeOwned; use tauri::{ plugin::{PluginApi, PluginHandle}, AppHandle, Runtime, }; use crate::models::*; #[cfg(target_os = "ios")] tauri::ios_plugin_binding!(init_plugin_wallpaper); // initializes the Kotlin or Swift plugin classes pub fn init( _app: &AppHandle, api: PluginApi, ) -> crate::Result> { #[cfg(target_os = "android")] let handle = api.register_android_plugin("de.wechselbild.wallpaper", "WallpaperPlugin")?; #[cfg(target_os = "ios")] let handle = api.register_ios_plugin(init_plugin_wallpaper)?; Ok(Wallpaper(handle)) } /// Access to the wallpaper APIs. pub struct Wallpaper(PluginHandle); impl Wallpaper { pub fn get_state(&self) -> crate::Result { self.0.run_mobile_plugin("getState", ()).map_err(Into::into) } pub fn get_gallery(&self, payload: GalleryRequest) -> crate::Result { self.0 .run_mobile_plugin("getGallery", payload) .map_err(Into::into) } pub fn select_images(&self) -> crate::Result { self.0 .run_mobile_plugin("selectImages", ()) .map_err(Into::into) } pub fn delete_image(&self, payload: DeleteImageRequest) -> crate::Result { self.0 .run_mobile_plugin("deleteImage", payload) .map_err(Into::into) } pub fn get_image_ids(&self) -> crate::Result> { let response: ImageIdsResponse = self.0.run_mobile_plugin("getImageIds", ())?; Ok(response.ids) } pub fn delete_images(&self, payload: DeleteImagesRequest) -> crate::Result { self.0.run_mobile_plugin("deleteImages", payload).map_err(Into::into) } pub fn set_image_crop(&self, payload: ImageCropRequest) -> crate::Result { self.0 .run_mobile_plugin("setImageCrop", payload) .map_err(Into::into) } pub fn set_setting(&self, payload: SettingRequest) -> crate::Result { self.0 .run_mobile_plugin("setSetting", payload) .map_err(Into::into) } pub fn set_interval(&self, payload: IntervalRequest) -> crate::Result { self.0 .run_mobile_plugin("setInterval", payload) .map_err(Into::into) } pub fn next_wallpaper(&self) -> crate::Result { self.0 .run_mobile_plugin("nextWallpaper", ()) .map_err(Into::into) } pub fn apply_wallpaper(&self, payload: ApplyWallpaperRequest) -> crate::Result { self.0 .run_mobile_plugin("applyWallpaper", payload) .map_err(Into::into) } pub fn get_immich_connection(&self) -> crate::Result { self.0.run_mobile_plugin("getImmichConnection", ()).map_err(Into::into) } pub fn connect_immich(&self, payload: ImmichConnectRequest) -> crate::Result { self.0.run_mobile_plugin("connectImmich", payload).map_err(Into::into) } pub fn disconnect_immich(&self) -> crate::Result { self.0.run_mobile_plugin("disconnectImmich", ()).map_err(Into::into) } pub fn get_immich_albums(&self) -> crate::Result { self.0.run_mobile_plugin("getImmichAlbums", ()).map_err(Into::into) } pub fn get_immich_assets(&self, payload: ImmichAssetsRequest) -> crate::Result { self.0.run_mobile_plugin("getImmichAssets", payload).map_err(Into::into) } pub fn import_immich_assets(&self, payload: ImmichImportRequest) -> crate::Result { self.0.run_mobile_plugin("importImmichAssets", payload).map_err(Into::into) } pub fn get_immich_import_progress(&self) -> crate::Result { self.0.run_mobile_plugin("getImmichImportProgress", ()).map_err(Into::into) } }