Skip to content

Commit e79e5f1

Browse files
server: Various fixes post using WindowIdentifierType
1 parent 3b40dd9 commit e79e5f1

2 files changed

Lines changed: 8 additions & 10 deletions

File tree

server/src/gnome/prompter.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ struct Properties {
4444
}
4545

4646
impl Properties {
47-
fn for_lock(keyring: &str, window_id: Option<WindowIdentifierType>) -> 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,7 +54,7 @@ impl Properties {
5454
password_strength: None,
5555
choice_label: None,
5656
choice_chosen: None,
57-
caller_window: window_id,
57+
caller_window: window_id.map(ToOwned::to_owned),
5858
continue_label: Some("Lock".to_owned()),
5959
cancel_label: Some("Cancel".to_owned()),
6060
}
@@ -63,7 +63,7 @@ impl Properties {
6363
fn for_unlock(
6464
keyring: &str,
6565
warning: Option<&str>,
66-
window_id: Option<WindowIdentifierType>,
66+
window_id: Option<&WindowIdentifierType>,
6767
) -> Self {
6868
Self {
6969
title: Some("Unlock Keyring".to_owned()),
@@ -77,7 +77,7 @@ impl Properties {
7777
password_strength: None,
7878
choice_label: None,
7979
choice_chosen: None,
80-
caller_window: window_id,
80+
caller_window: window_id.map(ToOwned::to_owned),
8181
continue_label: Some("Unlock".to_owned()),
8282
cancel_label: Some("Cancel".to_owned()),
8383
}
@@ -240,7 +240,7 @@ impl PrompterCallback {
240240

241241
let (properties, prompt_type) = match prompt.role() {
242242
PromptRole::Lock => (
243-
Properties::for_lock(&label, self.window_id.clone()),
243+
Properties::for_lock(&label, self.window_id.as_ref()),
244244
PromptType::Confirm,
245245
),
246246
PromptRole::Unlock => {
@@ -254,7 +254,7 @@ impl PrompterCallback {
254254
self.aes_key.set(aes_key).unwrap();
255255

256256
(
257-
Properties::for_unlock(&label, None, self.window_id.clone()),
257+
Properties::for_unlock(&label, None, self.window_id.as_ref()),
258258
PromptType::Password,
259259
)
260260
}
@@ -308,7 +308,7 @@ impl PrompterCallback {
308308
let properties = Properties::for_unlock(
309309
&label,
310310
Some("The unlock password was incorrect"),
311-
self.window_id.clone(),
311+
self.window_id.as_ref(),
312312
);
313313
let server_exchange = self
314314
.exchange

server/src/prompt.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,9 +57,7 @@ impl Prompt {
5757
};
5858

5959
let callback = PrompterCallback::new(
60-
(*window_id)
61-
.map(|w| ashpd::WindowIdentifierType::from_str(w).ok())
62-
.flatten(),
60+
(*window_id).and_then(|w| ashpd::WindowIdentifierType::from_str(w).ok()),
6361
self.service.clone(),
6462
self.path.clone(),
6563
)

0 commit comments

Comments
 (0)