File tree Expand file tree Collapse file tree 3 files changed +27
-9
lines changed Expand file tree Collapse file tree 3 files changed +27
-9
lines changed Original file line number Diff line number Diff line change @@ -45,7 +45,7 @@ impl Service {
45
45
Algorithm :: Plain => None ,
46
46
Algorithm :: Encrypted => Some ( Key :: from ( input) ) ,
47
47
} ;
48
- let ( session, key) = Session :: new ( client_public_key) ;
48
+ let ( session, key) = Session :: new ( client_public_key, Arc :: clone ( & self . manager ) ) ;
49
49
// TODO: clean up the default generated key
50
50
// TODO call self.manager.set_sessions();
51
51
let key = key
Original file line number Diff line number Diff line change @@ -17,11 +17,20 @@ impl ServiceManager {
17
17
}
18
18
}
19
19
20
- pub async fn session ( & self , path : ObjectPath < ' _ > ) -> Option < & Session > {
21
- self . sessions . read ( ) . await . get ( & path. into ( ) )
20
+ pub async fn session ( & self , path : ObjectPath < ' _ > ) -> Option < Session > {
21
+ self . sessions
22
+ . read ( )
23
+ . await
24
+ . get ( & path. into ( ) )
25
+ . to_owned ( )
26
+ . cloned ( )
22
27
}
23
28
24
- pub async fn insert_session ( & mut self , path : OwnedObjectPath , session : Session ) {
25
- self . sessions . write ( ) . await . insert ( path, session) ;
29
+ pub async fn insert_session ( & mut self , path : ObjectPath < ' _ > , session : Session ) {
30
+ self . sessions . write ( ) . await . insert ( path. into ( ) , session) ;
31
+ }
32
+
33
+ pub async fn remove_session ( & mut self , path : ObjectPath < ' _ > ) {
34
+ self . sessions . write ( ) . await . remove ( & path. into ( ) ) ;
26
35
}
27
36
}
Original file line number Diff line number Diff line change 1
1
// org.freedesktop.Secret.Session
2
2
3
+ use std:: sync:: Arc ;
4
+
3
5
use oo7:: Key ;
4
6
use zbus:: { fdo, interface, zvariant} ;
5
7
use zvariant:: { ObjectPath , OwnedObjectPath } ;
6
8
7
- #[ derive( Debug ) ]
9
+ use super :: service_manager:: ServiceManager ;
10
+
11
+ #[ derive( Debug , Clone ) ]
8
12
pub struct Session {
9
- client_public_key : Option < Key > ,
13
+ client_public_key : Arc < Option < Key > > ,
14
+ manager : Arc < ServiceManager > ,
10
15
pub path : OwnedObjectPath ,
11
16
}
12
17
@@ -22,12 +27,16 @@ impl Session {
22
27
}
23
28
24
29
impl Session {
25
- pub fn new ( client_public_key : Option < Key > ) -> ( Self , Option < Key > ) {
30
+ pub fn new (
31
+ client_public_key : Option < Key > ,
32
+ manager : Arc < ServiceManager > ,
33
+ ) -> ( Self , Option < Key > ) {
26
34
// make use of the keys
27
35
let service_key = vec ! [ 0 ] ;
28
36
let instance = Self {
29
- client_public_key,
37
+ client_public_key : Arc :: new ( client_public_key ) ,
30
38
path : OwnedObjectPath :: try_from ( format ! ( "{}" , "a" ) ) . unwrap ( ) ,
39
+ manager,
31
40
} ;
32
41
33
42
( instance, Some ( Key :: new ( service_key) ) )
You can’t perform that action at this time.
0 commit comments