diff --git a/gui/src/bus.rs b/gui/src/bus.rs index a0580f5..ac487ae 100644 --- a/gui/src/bus.rs +++ b/gui/src/bus.rs @@ -4,7 +4,8 @@ //! `glib::MainContext::spawn_local`, which polls the future on the GTK main //! thread; tokio's reactor wakes the future when zbus I/O is ready. -use authforge_common::types::{Credential, PendingStatus}; +use authforge_common::policy::Policy; +use authforge_common::types::{Credential, PendingStatus, PolicyApplyResult, RecoveryCodeSummary}; const BUS_NAME: &str = "io.dangerousthings.AuthForge"; const OBJECT_PATH: &str = "/io/dangerousthings/AuthForge"; @@ -56,6 +57,35 @@ impl Daemon { pub async fn clear_pending_flag(&self, user: &str) -> zbus::Result<()> { self.proxy.call("ClearPendingFlag", &(user,)).await } + + pub async fn get_policy(&self) -> zbus::Result { + self.proxy.call("GetPolicy", &()).await + } + + /// `force=false` runs the daemon's lockout simulator first; on + /// violations, returns `PolicyApplyResult { applied: false, violations }` + /// without writing. + pub async fn set_policy(&self, p: &Policy, force: bool) -> zbus::Result { + self.proxy.call("SetPolicy", &(p, force)).await + } + + pub async fn generate_recovery_code(&self, user: &str) -> zbus::Result { + self.proxy.call("GenerateRecoveryCode", &(user,)).await + } + + pub async fn list_recovery_codes(&self) -> zbus::Result> { + self.proxy.call("ListRecoveryCodes", &()).await + } + + pub async fn revoke_recovery_code(&self, user: &str) -> zbus::Result { + self.proxy.call("RevokeRecoveryCode", &(user,)).await + } + + pub async fn subscribe_policy_changed( + &self, + ) -> zbus::Result> { + self.proxy.receive_signal("PolicyChanged").await + } } #[allow(dead_code)] // wired through keys_page.rs in Task 4.