Skip to content

Commit

Permalink
documents: Add GetHostPaths support
Browse files Browse the repository at this point in the history
  • Loading branch information
bilelmoussaoui committed Jun 7, 2024
1 parent 5b550b7 commit 3870571
Showing 1 changed file with 29 additions and 1 deletion.
30 changes: 29 additions & 1 deletion src/documents/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -478,6 +478,28 @@ impl<'a> Documents<'a> {
.call("RevokePermissions", &(doc_id.into(), app_id, permissions))
.await
}

/// Revokes access permissions for a file in the document store from an
/// application.
///
/// # Arguments
///
/// * `doc_ids` - A list of file IDs in the document store.
///
/// # Returns
///
/// A dictionary mapping document IDs to the paths in the host filesystem
///
/// # Specifications
///
/// See also [`GetHostPaths`](https://flatpak.github.io/xdg-desktop-portal/docs/doc-org.freedesktop.portal.Documents.html#org-freedesktop-portal-documents-gethostpaths).
#[doc(alias = "GetHostPaths")]
pub async fn host_paths(
&self,
doc_ids: &[DocumentID],
) -> Result<HashMap<DocumentID, FilePath>, Error> {
self.0.call_versioned("GetHostPaths", &(doc_ids,), 5).await
}
}

impl<'a> std::ops::Deref for Documents<'a> {
Expand All @@ -495,7 +517,11 @@ pub use file_transfer::FileTransfer;

#[cfg(test)]
mod tests {
use crate::documents::Permission;
use std::collections::HashMap;

use zbus::zvariant::Type;

use crate::{app_id::DocumentID, documents::Permission, FilePath};

#[test]
fn serialize_deserialize() {
Expand All @@ -505,5 +531,7 @@ mod tests {

let decoded = serde_json::from_str(&string).unwrap();
assert_eq!(permission, decoded);

assert_eq!(HashMap::<DocumentID, FilePath>::signature(), "a{say}");
}
}

0 comments on commit 3870571

Please sign in to comment.