add garcard placeholder integration
Authored by
mfwolffe <wolffemf@dukes.jmu.edu>
- SHA
eadd636ac0d9fce9709f93b9cfdee7cd3276d600- Parents
-
8941ec6 - Tree
1c4c4c9
eadd636
eadd636ac0d9fce9709f93b9cfdee7cd3276d6008941ec6
1c4c4c9| Status | File | + | - |
|---|---|---|---|
| M |
gargears/src/app.rs
|
17 | 1 |
| A |
gargears/src/ipc/adapters/garcard.rs
|
58 | 0 |
| M |
gargears/src/ipc/adapters/mod.rs
|
2 | 0 |
| M |
gargears/src/ipc/discovery.rs
|
1 | 0 |
| M |
gargears/src/ipc/manager.rs
|
9 | 1 |
| M |
gargears/src/panels/mod.rs
|
5 | 0 |
gargears/src/app.rsmodified@@ -5,7 +5,7 @@ use crate::ipc::discovery::DaemonStatus; | ||
| 5 | 5 | use crate::ipc::{ConnectionManager, IpcEvent}; |
| 6 | 6 | use crate::panels::{ |
| 7 | 7 | Component, GarPanel, GarbarPanel, GarbgPanel, GarclipPanel, GarfieldPanel, GarlaunchPanel, |
| 8 | - GarlockPanel, GarnotifyPanel, GarshotPanel, GartermPanel, GartrayPanel, | |
| 8 | + GarlockPanel, GarnotifyPanel, GarshotPanel, GartermPanel, GartrayPanel, PlaceholderPanel, | |
| 9 | 9 | }; |
| 10 | 10 | use crate::ui::{Layout, Sidebar}; |
| 11 | 11 | use crate::ui::{Panel, PanelAction}; |
@@ -153,6 +153,14 @@ impl App { | ||
| 153 | 153 | Component::Garnotify, |
| 154 | 154 | Box::new(GarnotifyPanel::new(connection_manager.take_garnotify_adapter())), |
| 155 | 155 | ); |
| 156 | + panels.insert( | |
| 157 | + Component::Garcard, | |
| 158 | + Box::new(PlaceholderPanel::new( | |
| 159 | + "garcard", | |
| 160 | + "Polkit authentication agent", | |
| 161 | + connection_manager.is_connected(Component::Garcard), | |
| 162 | + )), | |
| 163 | + ); | |
| 156 | 164 | |
| 157 | 165 | Ok(Self { |
| 158 | 166 | window, |
@@ -271,6 +279,14 @@ impl App { | ||
| 271 | 279 | Component::Garnotify, |
| 272 | 280 | Box::new(GarnotifyPanel::new(connection_manager.take_garnotify_adapter())), |
| 273 | 281 | ); |
| 282 | + panels.insert( | |
| 283 | + Component::Garcard, | |
| 284 | + Box::new(PlaceholderPanel::new( | |
| 285 | + "garcard", | |
| 286 | + "Polkit authentication agent", | |
| 287 | + connection_manager.is_connected(Component::Garcard), | |
| 288 | + )), | |
| 289 | + ); | |
| 274 | 290 | |
| 275 | 291 | Ok(Self { |
| 276 | 292 | window, |
gargears/src/ipc/adapters/garcard.rsadded@@ -0,0 +1,58 @@ | ||
| 1 | +//! IPC adapter for garcard (authentication agent) | |
| 2 | + | |
| 3 | +use crate::ipc::client::IpcClient; | |
| 4 | +use crate::ipc::discovery::socket_path_for; | |
| 5 | +use crate::panels::Component; | |
| 6 | +use anyhow::Result; | |
| 7 | +use std::path::PathBuf; | |
| 8 | + | |
| 9 | +/// Adapter for garcard authentication agent | |
| 10 | +pub struct GarcardAdapter { | |
| 11 | + client: IpcClient, | |
| 12 | +} | |
| 13 | + | |
| 14 | +impl GarcardAdapter { | |
| 15 | + pub fn new() -> Self { | |
| 16 | + use std::time::Duration; | |
| 17 | + Self { | |
| 18 | + client: IpcClient::new().with_timeout(Duration::from_secs(5)), | |
| 19 | + } | |
| 20 | + } | |
| 21 | + | |
| 22 | + pub fn socket_path(&self) -> PathBuf { | |
| 23 | + socket_path_for(Component::Garcard) | |
| 24 | + } | |
| 25 | + | |
| 26 | + pub fn connect(&mut self) -> Result<()> { | |
| 27 | + self.client.connect(&self.socket_path()) | |
| 28 | + } | |
| 29 | + | |
| 30 | + /// Attempt reconnection with exponential backoff | |
| 31 | + pub fn reconnect(&mut self) -> Result<()> { | |
| 32 | + self.client.reconnect() | |
| 33 | + } | |
| 34 | + | |
| 35 | + /// Check if we should attempt reconnection | |
| 36 | + pub fn should_reconnect(&self) -> bool { | |
| 37 | + self.client.should_attempt_reconnect() | |
| 38 | + } | |
| 39 | + | |
| 40 | + /// Reset backoff state | |
| 41 | + pub fn reset_backoff(&mut self) { | |
| 42 | + self.client.reset_backoff(); | |
| 43 | + } | |
| 44 | + | |
| 45 | + pub fn disconnect(&mut self) { | |
| 46 | + self.client.disconnect(); | |
| 47 | + } | |
| 48 | + | |
| 49 | + pub fn is_connected(&self) -> bool { | |
| 50 | + self.client.is_connected() | |
| 51 | + } | |
| 52 | +} | |
| 53 | + | |
| 54 | +impl Default for GarcardAdapter { | |
| 55 | + fn default() -> Self { | |
| 56 | + Self::new() | |
| 57 | + } | |
| 58 | +} | |
gargears/src/ipc/adapters/mod.rsmodified@@ -3,6 +3,7 @@ | ||
| 3 | 3 | mod gar; |
| 4 | 4 | mod garbar; |
| 5 | 5 | mod garbg; |
| 6 | +mod garcard; | |
| 6 | 7 | mod garclip; |
| 7 | 8 | mod garfield; |
| 8 | 9 | mod garlaunch; |
@@ -15,6 +16,7 @@ mod gartray; | ||
| 15 | 16 | pub use gar::{GarAdapter, GarKeybind, GarRule}; |
| 16 | 17 | pub use garbar::GarbarAdapter; |
| 17 | 18 | pub use garbg::{GarbgAdapter, GarbgEvent}; |
| 19 | +pub use garcard::GarcardAdapter; | |
| 18 | 20 | pub use garclip::GarclipAdapter; |
| 19 | 21 | pub use garfield::GarfieldAdapter; |
| 20 | 22 | pub use garlaunch::GarlaunchAdapter; |
gargears/src/ipc/discovery.rsmodified@@ -28,6 +28,7 @@ pub fn socket_path_for(component: Component) -> PathBuf { | ||
| 28 | 28 | Component::Garclip => "garclip.sock", |
| 29 | 29 | Component::Garlaunch => "garlaunch.sock", |
| 30 | 30 | Component::Garnotify => "garnotify.sock", |
| 31 | + Component::Garcard => "garcard.sock", | |
| 31 | 32 | }; |
| 32 | 33 | |
| 33 | 34 | PathBuf::from(runtime_dir).join(socket_name) |
gargears/src/ipc/manager.rsmodified@@ -1,7 +1,7 @@ | ||
| 1 | 1 | //! Connection manager for coordinating IPC with all gardesk daemons |
| 2 | 2 | |
| 3 | 3 | use crate::ipc::adapters::{ |
| 4 | - GarbgAdapter, GarbgEvent, GarAdapter, GarbarAdapter, GarclipAdapter, GarfieldAdapter, | |
| 4 | + GarbgAdapter, GarbgEvent, GarcardAdapter, GarAdapter, GarbarAdapter, GarclipAdapter, GarfieldAdapter, | |
| 5 | 5 | GarlaunchAdapter, GarlockAdapter, GarnotifyAdapter, GarshotAdapter, GartermAdapter, |
| 6 | 6 | GartrayAdapter, |
| 7 | 7 | }; |
@@ -54,6 +54,7 @@ pub struct ConnectionManager { | ||
| 54 | 54 | pub garclip: GarclipAdapter, |
| 55 | 55 | pub garlaunch: GarlaunchAdapter, |
| 56 | 56 | pub garnotify: GarnotifyAdapter, |
| 57 | + pub garcard: GarcardAdapter, | |
| 57 | 58 | |
| 58 | 59 | // Connection state |
| 59 | 60 | connection_state: HashMap<Component, bool>, |
@@ -77,6 +78,7 @@ impl ConnectionManager { | ||
| 77 | 78 | garclip: GarclipAdapter::new(), |
| 78 | 79 | garlaunch: GarlaunchAdapter::new(), |
| 79 | 80 | garnotify: GarnotifyAdapter::new(), |
| 81 | + garcard: GarcardAdapter::new(), | |
| 80 | 82 | connection_state: HashMap::new(), |
| 81 | 83 | pending_events: Vec::new(), |
| 82 | 84 | } |
@@ -111,6 +113,7 @@ impl ConnectionManager { | ||
| 111 | 113 | Component::Garclip => self.garclip.connect(), |
| 112 | 114 | Component::Garlaunch => self.garlaunch.connect(), |
| 113 | 115 | Component::Garnotify => self.garnotify.connect(), |
| 116 | + Component::Garcard => self.garcard.connect(), | |
| 114 | 117 | }; |
| 115 | 118 | |
| 116 | 119 | match &result { |
@@ -147,6 +150,7 @@ impl ConnectionManager { | ||
| 147 | 150 | Component::Garclip => self.garclip.disconnect(), |
| 148 | 151 | Component::Garlaunch => self.garlaunch.disconnect(), |
| 149 | 152 | Component::Garnotify => self.garnotify.disconnect(), |
| 153 | + Component::Garcard => self.garcard.disconnect(), | |
| 150 | 154 | } |
| 151 | 155 | |
| 152 | 156 | self.connection_state.insert(component, false); |
@@ -169,6 +173,7 @@ impl ConnectionManager { | ||
| 169 | 173 | Component::Garclip => self.garclip.is_connected(), |
| 170 | 174 | Component::Garlaunch => self.garlaunch.is_connected(), |
| 171 | 175 | Component::Garnotify => self.garnotify.is_connected(), |
| 176 | + Component::Garcard => self.garcard.is_connected(), | |
| 172 | 177 | } |
| 173 | 178 | } |
| 174 | 179 | |
@@ -262,6 +267,7 @@ impl ConnectionManager { | ||
| 262 | 267 | Component::Garclip => self.garclip.reconnect(), |
| 263 | 268 | Component::Garlaunch => self.garlaunch.reconnect(), |
| 264 | 269 | Component::Garnotify => self.garnotify.reconnect(), |
| 270 | + Component::Garcard => self.garcard.reconnect(), | |
| 265 | 271 | // garterm uses different socket scheme, just try fresh connect |
| 266 | 272 | Component::Garterm => self.garterm.connect(), |
| 267 | 273 | } |
@@ -280,6 +286,7 @@ impl ConnectionManager { | ||
| 280 | 286 | Component::Garclip => self.garclip.should_reconnect(), |
| 281 | 287 | Component::Garlaunch => self.garlaunch.should_reconnect(), |
| 282 | 288 | Component::Garnotify => self.garnotify.should_reconnect(), |
| 289 | + Component::Garcard => self.garcard.should_reconnect(), | |
| 283 | 290 | Component::Garterm => true, // Always allow garterm reconnect |
| 284 | 291 | } |
| 285 | 292 | } |
@@ -297,6 +304,7 @@ impl ConnectionManager { | ||
| 297 | 304 | Component::Garclip => self.garclip.reset_backoff(), |
| 298 | 305 | Component::Garlaunch => self.garlaunch.reset_backoff(), |
| 299 | 306 | Component::Garnotify => self.garnotify.reset_backoff(), |
| 307 | + Component::Garcard => self.garcard.reset_backoff(), | |
| 300 | 308 | Component::Garterm => {} // garterm doesn't track backoff |
| 301 | 309 | } |
| 302 | 310 | } |
gargears/src/panels/mod.rsmodified@@ -42,6 +42,7 @@ pub enum Component { | ||
| 42 | 42 | Garclip, |
| 43 | 43 | Garlaunch, |
| 44 | 44 | Garnotify, |
| 45 | + Garcard, | |
| 45 | 46 | } |
| 46 | 47 | |
| 47 | 48 | impl Component { |
@@ -59,6 +60,7 @@ impl Component { | ||
| 59 | 60 | Component::Garclip, |
| 60 | 61 | Component::Garlaunch, |
| 61 | 62 | Component::Garnotify, |
| 63 | + Component::Garcard, | |
| 62 | 64 | ] |
| 63 | 65 | } |
| 64 | 66 | |
@@ -76,6 +78,7 @@ impl Component { | ||
| 76 | 78 | Component::Garclip => "garclip", |
| 77 | 79 | Component::Garlaunch => "garlaunch", |
| 78 | 80 | Component::Garnotify => "garnotify", |
| 81 | + Component::Garcard => "garcard", | |
| 79 | 82 | } |
| 80 | 83 | } |
| 81 | 84 | |
@@ -93,6 +96,7 @@ impl Component { | ||
| 93 | 96 | Component::Garclip => "Clipboard manager", |
| 94 | 97 | Component::Garlaunch => "Application launcher", |
| 95 | 98 | Component::Garnotify => "Notification daemon", |
| 99 | + Component::Garcard => "Authentication agent", | |
| 96 | 100 | } |
| 97 | 101 | } |
| 98 | 102 | |
@@ -110,6 +114,7 @@ impl Component { | ||
| 110 | 114 | "garclip" => Some(Component::Garclip), |
| 111 | 115 | "garlaunch" => Some(Component::Garlaunch), |
| 112 | 116 | "garnotify" => Some(Component::Garnotify), |
| 117 | + "garcard" => Some(Component::Garcard), | |
| 113 | 118 | _ => None, |
| 114 | 119 | } |
| 115 | 120 | } |