11use std:: sync:: Arc ;
22
3- use oo7:: { dbus:: ServiceError , Key } ;
3+ use oo7:: { ashpd :: WindowIdentifierType , dbus:: ServiceError , Key } ;
44use serde:: { Deserialize , Serialize } ;
55use tokio:: sync:: OnceCell ;
66use zbus:: zvariant:: { self , as_value, Optional , OwnedObjectPath , Type } ;
@@ -36,15 +36,15 @@ struct Properties {
3636 #[ serde( with = "as_value::optional" , skip_serializing_if = "Option::is_none" ) ]
3737 choice_chosen : Option < bool > ,
3838 #[ serde( with = "as_value::optional" , skip_serializing_if = "Option::is_none" ) ]
39- caller_window : Option < String > ,
39+ caller_window : Option < WindowIdentifierType > ,
4040 #[ serde( with = "as_value::optional" , skip_serializing_if = "Option::is_none" ) ]
4141 continue_label : Option < String > ,
4242 #[ serde( with = "as_value::optional" , skip_serializing_if = "Option::is_none" ) ]
4343 cancel_label : Option < String > ,
4444}
4545
4646impl Properties {
47- fn for_lock ( keyring : & str , window_id : Option < & str > ) -> Self {
47+ fn for_lock ( keyring : & str , window_id : Option < WindowIdentifierType > ) -> Self {
4848 Self {
4949 title : None ,
5050 message : Some ( "Lock Keyring" . to_owned ( ) ) ,
@@ -54,13 +54,17 @@ impl Properties {
5454 password_strength : None ,
5555 choice_label : None ,
5656 choice_chosen : None ,
57- caller_window : window_id. map ( ToOwned :: to_owned ) ,
57+ caller_window : window_id,
5858 continue_label : Some ( "Lock" . to_owned ( ) ) ,
5959 cancel_label : Some ( "Cancel" . to_owned ( ) ) ,
6060 }
6161 }
6262
63- fn for_unlock ( keyring : & str , warning : Option < & str > , window_id : Option < & str > ) -> Self {
63+ fn for_unlock (
64+ keyring : & str ,
65+ warning : Option < & str > ,
66+ window_id : Option < WindowIdentifierType > ,
67+ ) -> Self {
6468 Self {
6569 title : Some ( "Unlock Keyring" . to_owned ( ) ) ,
6670 message : Some ( "Authentication required" . to_owned ( ) ) ,
@@ -73,7 +77,7 @@ impl Properties {
7377 password_strength : None ,
7478 choice_label : None ,
7579 choice_chosen : None ,
76- caller_window : window_id. map ( ToOwned :: to_owned ) ,
80+ caller_window : window_id,
7781 continue_label : Some ( "Unlock" . to_owned ( ) ) ,
7882 cancel_label : Some ( "Cancel" . to_owned ( ) ) ,
7983 }
@@ -138,7 +142,7 @@ pub trait Prompter {
138142
139143#[ derive( Debug , Clone ) ]
140144pub struct PrompterCallback {
141- window_id : Option < String > ,
145+ window_id : Option < WindowIdentifierType > ,
142146 private_key : Arc < Key > ,
143147 public_key : Arc < Key > ,
144148 aes_key : Arc < OnceCell < Key > > ,
@@ -202,15 +206,15 @@ impl PrompterCallback {
202206
203207impl PrompterCallback {
204208 pub async fn new (
205- window_id : Option < & str > ,
209+ window_id : Option < WindowIdentifierType > ,
206210 service : Service ,
207211 prompt_path : OwnedObjectPath ,
208212 ) -> Result < Self , oo7:: crypto:: Error > {
209213 let index = service. prompt_index ( ) . await ;
210214 let private_key = Arc :: new ( Key :: generate_private_key ( ) ?) ;
211215 let public_key = Arc :: new ( crate :: gnome:: crypto:: generate_public_key ( & private_key) ?) ;
212216 Ok ( Self {
213- window_id : window_id . map ( ToOwned :: to_owned ) ,
217+ window_id,
214218 public_key,
215219 private_key,
216220 aes_key : Default :: default ( ) ,
@@ -236,7 +240,7 @@ impl PrompterCallback {
236240
237241 let ( properties, prompt_type) = match prompt. role ( ) {
238242 PromptRole :: Lock => (
239- Properties :: for_lock ( & label, self . window_id . as_deref ( ) ) ,
243+ Properties :: for_lock ( & label, self . window_id . clone ( ) ) ,
240244 PromptType :: Confirm ,
241245 ) ,
242246 PromptRole :: Unlock => {
@@ -250,7 +254,7 @@ impl PrompterCallback {
250254 self . aes_key . set ( aes_key) . unwrap ( ) ;
251255
252256 (
253- Properties :: for_unlock ( & label, None , self . window_id . as_deref ( ) ) ,
257+ Properties :: for_unlock ( & label, None , self . window_id . clone ( ) ) ,
254258 PromptType :: Password ,
255259 )
256260 }
@@ -304,7 +308,7 @@ impl PrompterCallback {
304308 let properties = Properties :: for_unlock (
305309 & label,
306310 Some ( "The unlock password was incorrect" ) ,
307- self . window_id . as_deref ( ) ,
311+ self . window_id . clone ( ) ,
308312 ) ;
309313 let server_exchange = self
310314 . exchange
0 commit comments