From b19a5f24162d983f657d25fa4e6f62b17bdc400d Mon Sep 17 00:00:00 2001 From: Bilal Elmoussaoui Date: Thu, 15 Sep 2022 18:37:47 +0200 Subject: [PATCH] backend: Add generic types for now --- Cargo.toml | 1 + src/backend/access.rs | 27 +++++++++++++++++++++++++++ src/backend/account.rs | 32 ++++++++++++++++++++++++++++++++ src/backend/mod.rs | 5 +++++ src/backend/request.rs | 10 ++++++++++ src/backend/session.rs | 18 ++++++++++++++++++ src/backend/wallpaper.rs | 36 ++++++++++++++++++++++++++++++++++++ src/lib.rs | 4 ++++ 8 files changed, 133 insertions(+) create mode 100644 src/backend/access.rs create mode 100644 src/backend/account.rs create mode 100644 src/backend/mod.rs create mode 100644 src/backend/request.rs create mode 100644 src/backend/session.rs create mode 100644 src/backend/wallpaper.rs diff --git a/Cargo.toml b/Cargo.toml index 1ce3e9d64..279164f83 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -12,6 +12,7 @@ version = "0.4.0" [features] default = ["async-std"] +backend = [] gtk3_x11 = ["gdk3x11", "dep:gtk3"] gtk3_wayland = ["gdk3wayland", "dep:gtk3"] gtk3 = ["gtk3_x11", "gtk3_wayland"] diff --git a/src/backend/access.rs b/src/backend/access.rs new file mode 100644 index 000000000..836aa28bf --- /dev/null +++ b/src/backend/access.rs @@ -0,0 +1,27 @@ +use std::collections::HashMap; + +use zbus::dbus_interface; +use zvariant::{OwnedValue, Value}; + +use crate::{ + desktop::{request::Response, HandleToken, ResponseError}, + WindowIdentifierType, +}; + +pub struct Access {} + +#[dbus_interface(name = "org.freedesktop.impl.portal.Access")] +impl Access { + fn access_dialog( + &self, + _handle: HandleToken, + _app_id: &str, + _window_identifier: WindowIdentifierType, + _title: &str, + _subtitle: &str, + _body: &str, + _options: HashMap<&str, Value<'_>>, + ) -> Response> { + Response::Err(ResponseError::Cancelled) + } +} diff --git a/src/backend/account.rs b/src/backend/account.rs new file mode 100644 index 000000000..8dcf968fd --- /dev/null +++ b/src/backend/account.rs @@ -0,0 +1,32 @@ +use zbus::dbus_interface; +use zvariant::DeserializeDict; + +use crate::{ + desktop::{ + account::UserInfo, + request::{Response, ResponseError}, + HandleToken, + }, + WindowIdentifierType, +}; + +#[derive(Debug, DeserializeDict, zvariant::Type)] +#[zvariant(signature = "dict")] +pub struct UserInfoOptions { + reason: Option, +} + +pub struct Account {} + +#[dbus_interface(name = "org.freedesktop.impl.portal.Account")] +impl Account { + async fn get_user_information( + &self, + handle: HandleToken, + app_id: &str, + window_identifier: WindowIdentifierType, + options: UserInfoOptions, + ) -> Response { + Response::Err(ResponseError::Cancelled) + } +} diff --git a/src/backend/mod.rs b/src/backend/mod.rs new file mode 100644 index 000000000..072f7ef3c --- /dev/null +++ b/src/backend/mod.rs @@ -0,0 +1,5 @@ +mod access; +mod account; +mod request; +mod session; +mod wallpaper; diff --git a/src/backend/request.rs b/src/backend/request.rs new file mode 100644 index 000000000..9e3ec31fb --- /dev/null +++ b/src/backend/request.rs @@ -0,0 +1,10 @@ +use zbus::dbus_interface; + +pub struct Request {} + +#[dbus_interface(name = "org.freedesktop.impl.portal.Request")] +impl Request { + async fn close(&self) -> zbus::fdo::Result<()> { + Ok(()) + } +} diff --git a/src/backend/session.rs b/src/backend/session.rs new file mode 100644 index 000000000..c8121a5c2 --- /dev/null +++ b/src/backend/session.rs @@ -0,0 +1,18 @@ +use zbus::{dbus_interface, SignalContext}; + +pub struct Session {} + +#[dbus_interface(name = "org.freedesktop.impl.portal.Session")] +impl Session { + async fn close(&self) -> zbus::fdo::Result<()> { + Ok(()) + } + + #[dbus_interface(property)] + fn version(&self) -> u32 { + 2 + } + + #[dbus_interface(signal)] + async fn closed(signal_ctxt: &SignalContext<'_>, message: &str) -> zbus::Result<()>; +} diff --git a/src/backend/wallpaper.rs b/src/backend/wallpaper.rs new file mode 100644 index 000000000..8f0783233 --- /dev/null +++ b/src/backend/wallpaper.rs @@ -0,0 +1,36 @@ +use zbus::dbus_interface; +use zvariant::{DeserializeDict, Type}; + +use crate::{ + desktop::{ + request::{BasicResponse, Response}, + wallpaper::SetOn, + HandleToken, + }, + WindowIdentifierType, +}; + +#[derive(DeserializeDict, Type, Debug, Default)] +#[zvariant(signature = "dict")] +pub struct WallpaperOptions { + #[zvariant(rename = "show-preview")] + show_preview: Option, + #[zvariant(rename = "set-on")] + set_on: Option, +} + +pub struct Wallpaper {} + +#[dbus_interface(name = "org.freedesktop.impl.portal.Wallpaper")] +impl Wallpaper { + async fn set_wallpaper_uri( + &self, + handle: HandleToken, + app_id: &str, + window_identifier: WindowIdentifierType, + uri: url::Url, + options: WallpaperOptions, + ) -> Response { + todo!() + } +} diff --git a/src/lib.rs b/src/lib.rs index 27940c8de..24a6a3f91 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -25,6 +25,10 @@ pub mod documents; mod error; mod window_identifier; pub use self::window_identifier::WindowIdentifier; +#[cfg(feature = "backend")] +pub use self::window_identifier::WindowIdentifierType; +#[cfg(feature = "backend")] +pub mod backend; /// Spawn commands outside the sandbox or monitor if the running application has /// received an update & install it. pub mod flatpak;