Provide a way to use Proxy structs instead of `ObjectPath` for in and out arguments of methods & signals
xdg-portals uses a Request
interface that has a Response
signal that's common between all the portals that might require an interaction by the user. The result of a dbus call like https://flatpak.github.io/xdg-desktop-portal/portal-docs.html#gdbus-method-org-freedesktop-portal-FileChooser.OpenFile will be a Request
object path like /org/freedesktop/portal/desktop/request/1_279/t
.
What would be neat is to be able to convert the String
to a Request
object that would implement Proxy, if we can pass in the connection from the parent, it would make chaining thing easier.
let connection = zbus::Connection::new_session()?;
let proxy = AccountProxy::new(&connection)?;
let mut options = std::collections::HashMap::new();
options.insert("reason", "Factal would like to access to your avatar & user name".into());
proxy.get_user_information("az", options)?.response(|results| {
});
Note, the response is a signal and that depends on how those would be implemented in the future.
The current AccountProxy
#[dbus_proxy(
interface = "org.freedesktop.portal.Account",
default_service = "org.freedesktop.portal.Desktop",
default_path = "/org/freedesktop/portal/desktop"
)]
/// The interface lets sandboxed applications query basic information about the user,
/// like his name and avatar photo.
///
/// The portal backend will present the user with a dialog to confirm which (if any) information to share.
trait Account {
/// Gets information about the user.
///
/// # Arguments
///
/// * `window` - Identifier for the window
/// * `options` - A HashMap
/// * `handle_token` - A string that will be used as the last element of the handle. Must be a valid object path element.
/// * `reason` - A string that can be shown in the dialog to expain why the information is needed.
fn get_user_information(
&self,
window: &str,
options: HashMap<&str, Value>,
) -> Result<String>;
/// version property
#[dbus_proxy(property)]
fn version(&self) -> Result<u32>;
}
My idea is to be able to have
fn get_user_information(
&self,
window: &str,
options: HashMap<&str, Value>,
) -> Result<Request>;
While Request being a Struct that would look like this? not sure really how feasible or if logical to have such API
struct Request(String);
impl Request {
/// Closes the portal request to which this object refers and ends all related user interaction (dialogs, etc).
/// A Response signal will not be emitted in this case.
fn close(&self) -> Result<()>;
// signal
//fn response(&self) -> Result<(ResponseType, HashMap<&str, Value>)>;
}