| 1 |
use std::sync::Arc; |
| 2 |
|
| 3 |
use async_trait::async_trait; |
| 4 |
|
| 5 |
#[async_trait] |
| 6 |
pub trait LockdownImpl: Send + Sync { |
| 7 |
#[doc(alias = "disable-printing")] |
| 8 |
async fn disable_printing(&self) -> bool; |
| 9 |
#[doc(alias = "disable-printing")] |
| 10 |
async fn set_disable_printing(&self, disable_printing: bool) -> zbus::Result<()>; |
| 11 |
|
| 12 |
#[doc(alias = "disable-save-to-disk")] |
| 13 |
async fn disable_save_to_disk(&self) -> bool; |
| 14 |
#[doc(alias = "disable-save-to-disk")] |
| 15 |
async fn set_disable_save_to_disk(&self, disable_save_to_disk: bool) -> zbus::Result<()>; |
| 16 |
|
| 17 |
#[doc(alias = "disable-application-handlers")] |
| 18 |
async fn disable_application_handlers(&self) -> bool; |
| 19 |
#[doc(alias = "disable-application-handlers")] |
| 20 |
async fn set_disable_application_handlers( |
| 21 |
&self, |
| 22 |
disable_application_handlers: bool, |
| 23 |
) -> zbus::Result<()>; |
| 24 |
|
| 25 |
#[doc(alias = "disable-location")] |
| 26 |
async fn disable_location(&self) -> bool; |
| 27 |
#[doc(alias = "disable-location")] |
| 28 |
async fn set_disable_location(&self, disable_location: bool) -> zbus::Result<()>; |
| 29 |
|
| 30 |
#[doc(alias = "disable-camera")] |
| 31 |
async fn disable_camera(&self) -> bool; |
| 32 |
#[doc(alias = "disable-camera")] |
| 33 |
async fn set_disable_camera(&self, disable_camera: bool) -> zbus::Result<()>; |
| 34 |
|
| 35 |
#[doc(alias = "disable-microphone")] |
| 36 |
async fn disable_microphone(&self) -> bool; |
| 37 |
#[doc(alias = "disable-microphone")] |
| 38 |
async fn set_disable_microphone(&self, disable_microphone: bool) -> zbus::Result<()>; |
| 39 |
|
| 40 |
#[doc(alias = "disable-sound-output")] |
| 41 |
async fn disable_sound_output(&self) -> bool; |
| 42 |
#[doc(alias = "disable-sound-output")] |
| 43 |
async fn set_disable_sound_output(&self, disable_sound_output: bool) -> zbus::Result<()>; |
| 44 |
} |
| 45 |
|
| 46 |
pub(crate) struct LockdownInterface { |
| 47 |
imp: Arc<dyn LockdownImpl>, |
| 48 |
#[allow(dead_code)] |
| 49 |
cnx: zbus::Connection, |
| 50 |
#[allow(dead_code)] |
| 51 |
spawn: Arc<dyn futures_util::task::Spawn + Send + Sync>, |
| 52 |
} |
| 53 |
|
| 54 |
impl LockdownInterface { |
| 55 |
pub fn new( |
| 56 |
imp: Arc<dyn LockdownImpl>, |
| 57 |
cnx: zbus::Connection, |
| 58 |
spawn: Arc<dyn futures_util::task::Spawn + Send + Sync>, |
| 59 |
) -> Self { |
| 60 |
Self { imp, cnx, spawn } |
| 61 |
} |
| 62 |
} |
| 63 |
|
| 64 |
#[zbus::interface(name = "org.freedesktop.impl.portal.Lockdown")] |
| 65 |
impl LockdownInterface { |
| 66 |
#[zbus(property(emits_changed_signal = "const"), name = "version")] |
| 67 |
fn version(&self) -> u32 { |
| 68 |
1 |
| 69 |
} |
| 70 |
|
| 71 |
#[zbus(property, name = "disable-printing")] |
| 72 |
async fn disable_printing(&self) -> bool { |
| 73 |
self.imp.disable_printing().await |
| 74 |
} |
| 75 |
|
| 76 |
#[zbus(property, name = "disable-printing")] |
| 77 |
async fn set_disable_printing(&self, disable_printing: bool) -> zbus::Result<()> { |
| 78 |
let object_server = self.cnx.object_server(); |
| 79 |
let iface_ref = object_server |
| 80 |
.interface::<_, Self>(crate::proxy::DESKTOP_PATH) |
| 81 |
.await?; |
| 82 |
let ctxt = iface_ref.signal_emitter(); |
| 83 |
|
| 84 |
self.imp.set_disable_printing(disable_printing).await?; |
| 85 |
self.disable_printing_changed(ctxt).await?; |
| 86 |
Ok(()) |
| 87 |
} |
| 88 |
|
| 89 |
#[zbus(property, name = "disable-save-to-disk")] |
| 90 |
async fn disable_save_to_disk(&self) -> bool { |
| 91 |
self.imp.disable_save_to_disk().await |
| 92 |
} |
| 93 |
|
| 94 |
#[zbus(property, name = "disable-save-to-disk")] |
| 95 |
async fn set_disable_save_to_disk(&self, disable_save_to_disk: bool) -> zbus::Result<()> { |
| 96 |
let object_server = self.cnx.object_server(); |
| 97 |
let iface_ref = object_server |
| 98 |
.interface::<_, Self>(crate::proxy::DESKTOP_PATH) |
| 99 |
.await?; |
| 100 |
let ctxt = iface_ref.signal_emitter(); |
| 101 |
|
| 102 |
self.imp |
| 103 |
.set_disable_save_to_disk(disable_save_to_disk) |
| 104 |
.await?; |
| 105 |
self.disable_save_to_disk_changed(ctxt).await?; |
| 106 |
Ok(()) |
| 107 |
} |
| 108 |
|
| 109 |
#[zbus(property, name = "disable-application-handlers")] |
| 110 |
async fn disable_application_handlers(&self) -> bool { |
| 111 |
self.imp.disable_application_handlers().await |
| 112 |
} |
| 113 |
|
| 114 |
#[zbus(property, name = "disable-application-handlers")] |
| 115 |
async fn set_disable_application_handlers( |
| 116 |
&self, |
| 117 |
disable_application_handlers: bool, |
| 118 |
) -> zbus::Result<()> { |
| 119 |
let object_server = self.cnx.object_server(); |
| 120 |
let iface_ref = object_server |
| 121 |
.interface::<_, Self>(crate::proxy::DESKTOP_PATH) |
| 122 |
.await?; |
| 123 |
let ctxt = iface_ref.signal_emitter(); |
| 124 |
|
| 125 |
self.imp |
| 126 |
.set_disable_application_handlers(disable_application_handlers) |
| 127 |
.await?; |
| 128 |
self.disable_application_handlers_changed(ctxt).await?; |
| 129 |
Ok(()) |
| 130 |
} |
| 131 |
|
| 132 |
#[zbus(property, name = "disable-location")] |
| 133 |
async fn disable_location(&self) -> bool { |
| 134 |
self.imp.disable_location().await |
| 135 |
} |
| 136 |
|
| 137 |
#[zbus(property, name = "disable-location")] |
| 138 |
async fn set_disable_location(&self, disable_location: bool) -> zbus::Result<()> { |
| 139 |
let object_server = self.cnx.object_server(); |
| 140 |
let iface_ref = object_server |
| 141 |
.interface::<_, Self>(crate::proxy::DESKTOP_PATH) |
| 142 |
.await?; |
| 143 |
let ctxt = iface_ref.signal_emitter(); |
| 144 |
|
| 145 |
self.imp.set_disable_location(disable_location).await?; |
| 146 |
self.disable_location_changed(ctxt).await?; |
| 147 |
Ok(()) |
| 148 |
} |
| 149 |
|
| 150 |
#[zbus(property, name = "disable-camera")] |
| 151 |
async fn disable_camera(&self) -> bool { |
| 152 |
self.imp.disable_camera().await |
| 153 |
} |
| 154 |
|
| 155 |
#[zbus(property, name = "disable-camera")] |
| 156 |
async fn set_disable_camera(&self, disable_camera: bool) -> zbus::Result<()> { |
| 157 |
let object_server = self.cnx.object_server(); |
| 158 |
let iface_ref = object_server |
| 159 |
.interface::<_, Self>(crate::proxy::DESKTOP_PATH) |
| 160 |
.await?; |
| 161 |
let ctxt = iface_ref.signal_emitter(); |
| 162 |
|
| 163 |
self.imp.set_disable_camera(disable_camera).await?; |
| 164 |
self.disable_camera_changed(ctxt).await?; |
| 165 |
Ok(()) |
| 166 |
} |
| 167 |
|
| 168 |
#[zbus(property, name = "disable-microphone")] |
| 169 |
async fn disable_microphone(&self) -> bool { |
| 170 |
self.imp.disable_microphone().await |
| 171 |
} |
| 172 |
|
| 173 |
#[zbus(property, name = "disable-microphone")] |
| 174 |
async fn set_disable_microphone(&self, disable_microphone: bool) -> zbus::Result<()> { |
| 175 |
let object_server = self.cnx.object_server(); |
| 176 |
let iface_ref = object_server |
| 177 |
.interface::<_, Self>(crate::proxy::DESKTOP_PATH) |
| 178 |
.await?; |
| 179 |
let ctxt = iface_ref.signal_emitter(); |
| 180 |
|
| 181 |
self.imp.set_disable_microphone(disable_microphone).await?; |
| 182 |
self.disable_microphone_changed(ctxt).await?; |
| 183 |
Ok(()) |
| 184 |
} |
| 185 |
|
| 186 |
#[zbus(property, name = "disable-sound-output")] |
| 187 |
async fn disable_sound_output(&self) -> bool { |
| 188 |
self.imp.disable_sound_output().await |
| 189 |
} |
| 190 |
|
| 191 |
#[zbus(property, name = "disable-sound-output")] |
| 192 |
async fn set_disable_sound_output(&self, disable_sound_output: bool) -> zbus::Result<()> { |
| 193 |
let object_server = self.cnx.object_server(); |
| 194 |
let iface_ref = object_server |
| 195 |
.interface::<_, Self>(crate::proxy::DESKTOP_PATH) |
| 196 |
.await?; |
| 197 |
let ctxt = iface_ref.signal_emitter(); |
| 198 |
|
| 199 |
self.imp |
| 200 |
.set_disable_sound_output(disable_sound_output) |
| 201 |
.await?; |
| 202 |
self.disable_sound_output_changed(ctxt).await?; |
| 203 |
Ok(()) |
| 204 |
} |
| 205 |
} |