gardesk/gargears / eadd636

Browse files

add garcard placeholder integration

Authored by mfwolffe <wolffemf@dukes.jmu.edu>
SHA
eadd636ac0d9fce9709f93b9cfdee7cd3276d600
Parents
8941ec6
Tree
1c4c4c9

6 changed files

StatusFile+-
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;
55
 use crate::ipc::{ConnectionManager, IpcEvent};
66
 use crate::panels::{
77
     Component, GarPanel, GarbarPanel, GarbgPanel, GarclipPanel, GarfieldPanel, GarlaunchPanel,
8
-    GarlockPanel, GarnotifyPanel, GarshotPanel, GartermPanel, GartrayPanel,
8
+    GarlockPanel, GarnotifyPanel, GarshotPanel, GartermPanel, GartrayPanel, PlaceholderPanel,
99
 };
1010
 use crate::ui::{Layout, Sidebar};
1111
 use crate::ui::{Panel, PanelAction};
@@ -153,6 +153,14 @@ impl App {
153153
             Component::Garnotify,
154154
             Box::new(GarnotifyPanel::new(connection_manager.take_garnotify_adapter())),
155155
         );
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
+        );
156164
 
157165
         Ok(Self {
158166
             window,
@@ -271,6 +279,14 @@ impl App {
271279
             Component::Garnotify,
272280
             Box::new(GarnotifyPanel::new(connection_manager.take_garnotify_adapter())),
273281
         );
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
+        );
274290
 
275291
         Ok(Self {
276292
             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 @@
33
 mod gar;
44
 mod garbar;
55
 mod garbg;
6
+mod garcard;
67
 mod garclip;
78
 mod garfield;
89
 mod garlaunch;
@@ -15,6 +16,7 @@ mod gartray;
1516
 pub use gar::{GarAdapter, GarKeybind, GarRule};
1617
 pub use garbar::GarbarAdapter;
1718
 pub use garbg::{GarbgAdapter, GarbgEvent};
19
+pub use garcard::GarcardAdapter;
1820
 pub use garclip::GarclipAdapter;
1921
 pub use garfield::GarfieldAdapter;
2022
 pub use garlaunch::GarlaunchAdapter;
gargears/src/ipc/discovery.rsmodified
@@ -28,6 +28,7 @@ pub fn socket_path_for(component: Component) -> PathBuf {
2828
         Component::Garclip => "garclip.sock",
2929
         Component::Garlaunch => "garlaunch.sock",
3030
         Component::Garnotify => "garnotify.sock",
31
+        Component::Garcard => "garcard.sock",
3132
     };
3233
 
3334
     PathBuf::from(runtime_dir).join(socket_name)
gargears/src/ipc/manager.rsmodified
@@ -1,7 +1,7 @@
11
 //! Connection manager for coordinating IPC with all gardesk daemons
22
 
33
 use crate::ipc::adapters::{
4
-    GarbgAdapter, GarbgEvent, GarAdapter, GarbarAdapter, GarclipAdapter, GarfieldAdapter,
4
+    GarbgAdapter, GarbgEvent, GarcardAdapter, GarAdapter, GarbarAdapter, GarclipAdapter, GarfieldAdapter,
55
     GarlaunchAdapter, GarlockAdapter, GarnotifyAdapter, GarshotAdapter, GartermAdapter,
66
     GartrayAdapter,
77
 };
@@ -54,6 +54,7 @@ pub struct ConnectionManager {
5454
     pub garclip: GarclipAdapter,
5555
     pub garlaunch: GarlaunchAdapter,
5656
     pub garnotify: GarnotifyAdapter,
57
+    pub garcard: GarcardAdapter,
5758
 
5859
     // Connection state
5960
     connection_state: HashMap<Component, bool>,
@@ -77,6 +78,7 @@ impl ConnectionManager {
7778
             garclip: GarclipAdapter::new(),
7879
             garlaunch: GarlaunchAdapter::new(),
7980
             garnotify: GarnotifyAdapter::new(),
81
+            garcard: GarcardAdapter::new(),
8082
             connection_state: HashMap::new(),
8183
             pending_events: Vec::new(),
8284
         }
@@ -111,6 +113,7 @@ impl ConnectionManager {
111113
             Component::Garclip => self.garclip.connect(),
112114
             Component::Garlaunch => self.garlaunch.connect(),
113115
             Component::Garnotify => self.garnotify.connect(),
116
+            Component::Garcard => self.garcard.connect(),
114117
         };
115118
 
116119
         match &result {
@@ -147,6 +150,7 @@ impl ConnectionManager {
147150
             Component::Garclip => self.garclip.disconnect(),
148151
             Component::Garlaunch => self.garlaunch.disconnect(),
149152
             Component::Garnotify => self.garnotify.disconnect(),
153
+            Component::Garcard => self.garcard.disconnect(),
150154
         }
151155
 
152156
         self.connection_state.insert(component, false);
@@ -169,6 +173,7 @@ impl ConnectionManager {
169173
             Component::Garclip => self.garclip.is_connected(),
170174
             Component::Garlaunch => self.garlaunch.is_connected(),
171175
             Component::Garnotify => self.garnotify.is_connected(),
176
+            Component::Garcard => self.garcard.is_connected(),
172177
         }
173178
     }
174179
 
@@ -262,6 +267,7 @@ impl ConnectionManager {
262267
             Component::Garclip => self.garclip.reconnect(),
263268
             Component::Garlaunch => self.garlaunch.reconnect(),
264269
             Component::Garnotify => self.garnotify.reconnect(),
270
+            Component::Garcard => self.garcard.reconnect(),
265271
             // garterm uses different socket scheme, just try fresh connect
266272
             Component::Garterm => self.garterm.connect(),
267273
         }
@@ -280,6 +286,7 @@ impl ConnectionManager {
280286
             Component::Garclip => self.garclip.should_reconnect(),
281287
             Component::Garlaunch => self.garlaunch.should_reconnect(),
282288
             Component::Garnotify => self.garnotify.should_reconnect(),
289
+            Component::Garcard => self.garcard.should_reconnect(),
283290
             Component::Garterm => true, // Always allow garterm reconnect
284291
         }
285292
     }
@@ -297,6 +304,7 @@ impl ConnectionManager {
297304
             Component::Garclip => self.garclip.reset_backoff(),
298305
             Component::Garlaunch => self.garlaunch.reset_backoff(),
299306
             Component::Garnotify => self.garnotify.reset_backoff(),
307
+            Component::Garcard => self.garcard.reset_backoff(),
300308
             Component::Garterm => {} // garterm doesn't track backoff
301309
         }
302310
     }
gargears/src/panels/mod.rsmodified
@@ -42,6 +42,7 @@ pub enum Component {
4242
     Garclip,
4343
     Garlaunch,
4444
     Garnotify,
45
+    Garcard,
4546
 }
4647
 
4748
 impl Component {
@@ -59,6 +60,7 @@ impl Component {
5960
             Component::Garclip,
6061
             Component::Garlaunch,
6162
             Component::Garnotify,
63
+            Component::Garcard,
6264
         ]
6365
     }
6466
 
@@ -76,6 +78,7 @@ impl Component {
7678
             Component::Garclip => "garclip",
7779
             Component::Garlaunch => "garlaunch",
7880
             Component::Garnotify => "garnotify",
81
+            Component::Garcard => "garcard",
7982
         }
8083
     }
8184
 
@@ -93,6 +96,7 @@ impl Component {
9396
             Component::Garclip => "Clipboard manager",
9497
             Component::Garlaunch => "Application launcher",
9598
             Component::Garnotify => "Notification daemon",
99
+            Component::Garcard => "Authentication agent",
96100
         }
97101
     }
98102
 
@@ -110,6 +114,7 @@ impl Component {
110114
             "garclip" => Some(Component::Garclip),
111115
             "garlaunch" => Some(Component::Garlaunch),
112116
             "garnotify" => Some(Component::Garnotify),
117
+            "garcard" => Some(Component::Garcard),
113118
             _ => None,
114119
         }
115120
     }