Skip to content

Commit 280b105

Browse files
committed
wip: ui: 0-click credential selection
1 parent d7b8a73 commit 280b105

3 files changed

Lines changed: 71 additions & 4 deletions

File tree

  • credentialsd-ui
  • credentialsd/src/credential_service

credentialsd-ui/data/resources/ui/window.ui

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,46 @@
6262
<child>
6363
<object class="GtkStack" id="stack">
6464

65+
<child>
66+
<object class="GtkStackPage">
67+
<property name="name">start_page</property>
68+
<property name="title" translatable="yes">Choose device</property>
69+
<property name="child">
70+
<object class="GtkBox">
71+
<property name="orientation">vertical</property>
72+
<child>
73+
<object class="GtkPicture" id="qr_code_pic">
74+
<binding name="visible">
75+
<lookup name="qr_code_visible">
76+
<lookup name="view-model">
77+
CredentialsUiWindow
78+
</lookup>
79+
</lookup>
80+
</binding>
81+
</object>
82+
</child>
83+
<child>
84+
<object class="GtkLabel">
85+
<property name="label" translatable="yes">Scan the QR code above with another device, or tap or activate your security key</property>
86+
</object>
87+
</child>
88+
<child>
89+
<object class="GtkLabel">
90+
<binding name="label">
91+
<lookup name="prompt">
92+
<lookup name="view-model">
93+
CredentialsUiWindow
94+
</lookup>
95+
</lookup>
96+
</binding>
97+
</object>
98+
</child>
99+
</object>
100+
</property>
101+
</object>
102+
</child>
103+
104+
65105
<child>
66106
<object class="GtkStackPage">
67107
<property name="name">choose_device</property>
@@ -151,6 +191,7 @@
151191
</binding>
152192
</object>
153193
</child>
194+
<!--
154195
<child>
155196
<object class="GtkPicture" id="qr_code_pic">
156197
<binding name="visible">
@@ -162,6 +203,7 @@
162203
</binding>
163204
</object>
164205
</child>
206+
-->
165207
<child>
166208
<object class="GtkLabel">
167209
<binding name="label">

credentialsd-ui/src/gui/view_model/mod.rs

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -238,7 +238,14 @@ impl ViewModel {
238238
}
239239

240240
Event::Background(BackgroundEvent::UsbConnected) => {
241-
info!("Found USB device")
241+
info!("Found USB device");
242+
self.tx_update
243+
.send(ViewUpdate::WaitingForDevice(Device {
244+
id: "TODO: bogus".to_string(),
245+
transport: Transport::Usb,
246+
}))
247+
.await
248+
.unwrap();
242249
}
243250
// TODO: Add this event
244251
// Event::Background(BackgroundEvent::DevicesUpdated(devices)) => {
@@ -332,7 +339,14 @@ impl ViewModel {
332339
.unwrap()
333340
}
334341
Event::Background(BackgroundEvent::NfcConnected) => {
335-
info!("Found NFC device")
342+
info!("Found NFC device");
343+
self.tx_update
344+
.send(ViewUpdate::WaitingForDevice(Device {
345+
id: "TODO: bogus".to_string(),
346+
transport: Transport::Nfc,
347+
}))
348+
.await
349+
.unwrap();
336350
}
337351

338352
Event::Background(BackgroundEvent::NfcIdle | BackgroundEvent::NfcWaiting) => {}
@@ -348,6 +362,13 @@ impl ViewModel {
348362
}
349363
Event::Background(BackgroundEvent::HybridConnecting) => {
350364
self.hybrid_qr_code_data = None;
365+
self.tx_update
366+
.send(ViewUpdate::WaitingForDevice(Device {
367+
id: "TODO: bogus".to_string(),
368+
transport: Transport::HybridQr,
369+
}))
370+
.await
371+
.unwrap();
351372
self.tx_update
352373
.send(ViewUpdate::HybridConnecting)
353374
.await

credentialsd/src/credential_service/usb.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,9 +46,13 @@ impl InProcessUsbHandler {
4646
if hid_devices.is_empty() {
4747
let state = UsbStateInternal::Waiting;
4848
Ok(state)
49-
} else if hid_devices.len() == 1 {
49+
}
50+
/*
51+
else if hid_devices.len() == 1 {
5052
Ok(UsbStateInternal::Connected(hid_devices.swap_remove(0)))
51-
} else {
53+
}
54+
*/
55+
else {
5256
Ok(UsbStateInternal::SelectingDevice(hid_devices))
5357
}
5458
}

0 commit comments

Comments
 (0)