1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738
|
From: =?utf-8?q?Jeremy_B=C3=ADcha?= <jeremy.bicha@canonical.com>
Date: Sun, 13 Apr 2025 12:04:33 -0400
Subject: Revert "Add QuickUnlock with fingerprint support"
This reverts commit bf8276570599acb4a925af97d0ac016b8d2aaf4b.
asyncio requires pygobject 3.52
---
data/gtk/settings_dialog.ui | 14 --
data/gtk/unlock_database.ui | 14 --
.../status/fingerprint-detection-symbolic.svg | 3 -
data/org.gnome.World.Secrets.gschema.xml.in | 10 -
data/resources.gresource.xml.in | 1 -
data/style.css | 64 ------
flatpak/org.gnome.World.Secrets.Devel.json | 3 +-
gsecrets/config_manager.py | 18 --
gsecrets/database_manager.py | 5 +-
gsecrets/fingerprint_verifier.py | 238 ---------------------
gsecrets/settings_dialog.py | 7 -
gsecrets/unlock_database.py | 174 +--------------
12 files changed, 4 insertions(+), 547 deletions(-)
delete mode 100644 data/icons/scalable/status/fingerprint-detection-symbolic.svg
delete mode 100644 gsecrets/fingerprint_verifier.py
diff --git a/data/gtk/settings_dialog.ui b/data/gtk/settings_dialog.ui
index f74661d..5e66adf 100644
--- a/data/gtk/settings_dialog.ui
+++ b/data/gtk/settings_dialog.ui
@@ -30,20 +30,6 @@
<property name="use_underline">True</property>
</object>
</child>
- <child>
- <object class="AdwSwitchRow">
- <property name="title" translatable="yes" comments="Quick Unlock means it only can unlock the safe if the safe was unlocked once.">Enable Quick Unlock</property>
- <property name="subtitle" translatable="yes" comments="Quick Unlock means it only can unlock the safe if the safe was unlocked once.">Re-unlock using the last four characters of the password for a single attempt.</property>
- <property name="action_name">settings.quick-unlock</property>
- </object>
- </child>
- <child>
- <object class="AdwSwitchRow">
- <property name="title" translatable="yes" comments="Quick Unlock means it only can unlock the safe if the safe was unlocked once.">Enable Fingerprint Unlock</property>
- <property name="subtitle" translatable="yes" comments="Quick Unlock means it only can unlock the safe if the safe was unlocked once.">Use the fingerprint reader to quickly unlock the safe.</property>
- <property name="action_name">settings.fingerprint-quick-unlock</property>
- </object>
- </child>
</object>
</child>
<child>
diff --git a/data/gtk/unlock_database.ui b/data/gtk/unlock_database.ui
index 9472c72..651cfb8 100644
--- a/data/gtk/unlock_database.ui
+++ b/data/gtk/unlock_database.ui
@@ -30,20 +30,6 @@
<object class="GtkBox">
<property name="orientation">vertical</property>
<property name="spacing">12</property>
- <property name="width_request">250</property>
- <child>
- <object class="GtkImage" id="fingerprint_img">
- <property name="halign">center</property>
- <property name="hexpand">True</property>
- <property name="tooltip_text" translatable="yes">Fingerprint Unlock available</property>
- <property name="visible">False</property>
- <property name="icon_name">fingerprint-detection-symbolic</property>
- <property name="pixel_size">36</property>
- <style>
- <class name="fingerprint-img"/>
- </style>
- </object>
- </child>
<child>
<object class="AdwPreferencesGroup" id="key_group">
<child>
diff --git a/data/icons/scalable/status/fingerprint-detection-symbolic.svg b/data/icons/scalable/status/fingerprint-detection-symbolic.svg
deleted file mode 100644
index 00e31cc..0000000
--- a/data/icons/scalable/status/fingerprint-detection-symbolic.svg
+++ /dev/null
@@ -1,3 +0,0 @@
-<svg xmlns="http://www.w3.org/2000/svg" width="32" height="32" viewBox="0 0 8.467 8.467">
- <path d="m 4.2684727,288.79533 c -0.5901,-0.006 -1.1811905,0.13932 -1.7135904,0.43718 a 0.26457931,0.26466281 0 1 0 0.2573486,0.46251 c 0.9016629,-0.50447 2.0027268,-0.49283 2.8938802,0.03 0.8911538,0.52282 1.4376385,1.4775 1.4376385,2.51096 v 0.52916 a 0.26458335,0.26466684 0 1 0 0.5291667,0 v -0.52916 a 0.26456806,0.26465154 0 0 0 -0.00103,-0.0264 c -0.00927,-1.21028 -0.6533118,-2.32899 -1.6980893,-2.94194 -0.5261927,-0.30871 -1.1152275,-0.46628 -1.7053224,-0.47232 z m -2.7440185,1.495 a 0.26456806,0.26465154 0 0 0 -0.2118734,0.12816 c -0.3346961,0.53804 -0.51294685,1.15776 -0.51779785,1.7911 a 0.26456806,0.26465154 0 0 0 -0.001034,0.0264 v 2.67994 a 0.26458334,0.26466683 0 0 0 0.52916665,0 v -2.67994 c 0,-0.54372 0.1520815,-1.07677 0.4392497,-1.53841 a 0.26456806,0.26465154 0 0 0 -0.2377116,-0.40721 z m 2.7088787,0.093 c -1.0089,0 -1.8331201,0.81534 -1.8505331,1.82056 a 0.26456806,0.26465154 0 0 0 -0.00155,0.032 v 0.52916 a 0.26458335,0.26466684 0 1 0 0.5291667,0 v -0.52916 c 0,-0.73404 0.5891371,-1.32344 1.3229167,-1.32344 0.7337795,0 1.3229167,0.5894 1.3229167,1.32344 v 2.64686 c 0,0 0.00212,0.18248 0.079582,0.41445 0.077301,0.23197 0.2313432,0.5351 0.5270998,0.83096 a 0.26456806,0.26465154 0 1 0 0.3741372,-0.37414 c -0.2334101,-0.23348 -0.3439509,-0.45923 -0.3989419,-0.62425 -0.054991,-0.16503 -0.05271,-0.24702 -0.05271,-0.24702 v -2.64686 a 0.26456806,0.26465154 0 0 0 -0.00156,-0.0305 c -0.016571,-1.00594 -0.8410985,-1.82211 -1.8505223,-1.82211 z m -0.00414,1.58388 a 0.26456806,0.26465154 0 0 0 -0.2604479,0.26872 v 2.64686 c 0,0 -1.558e-4,0.28954 0.071313,0.64699 0.071464,0.35745 0.208433,0.80105 0.535368,1.1281 a 0.26456806,0.26465154 0 1 0 0.3741373,-0.37414 c -0.2022317,-0.20229 -0.329846,-0.55309 -0.3906737,-0.85731 -0.060823,-0.30422 -0.060978,-0.54364 -0.060978,-0.54364 v -2.64686 a 0.26456806,0.26465154 0 0 0 -0.2687175,-0.26872 z m -1.5875,2.11718 a 0.26456806,0.26465154 0 0 0 -0.2604479,0.26872 v 1.58802 a 0.26458335,0.26466684 0 1 0 0.5291667,0 v -1.58802 a 0.26456806,0.26465154 0 0 0 -0.2687175,-0.26872 z m 4.7625001,0 a 0.26456806,0.26465154 0 0 0 -0.2604479,0.26769 v 0.52968 a 0.26458335,0.26466684 0 1 0 0.5291667,0 v -0.52968 a 0.26456806,0.26465154 0 0 0 -0.2687175,-0.26769 z" style="line-height:normal;font-variant-ligatures:normal;font-variant-position:normal;font-variant-caps:normal;font-variant-numeric:normal;font-variant-alternates:normal;font-feature-settings:normal;text-indent:0;text-align:start;text-decoration-line:none;text-decoration-style:solid;text-decoration-color:#000;text-transform:none;text-orientation:mixed;white-space:normal;shape-padding:0;isolation:auto;mix-blend-mode:normal;solid-color:#000;solid-opacity:1" color="#000" font-weight="400" font-family="sans-serif" overflow="visible" fill="#3d3846" transform="translate(0 -288.533)"/>
-</svg>
diff --git a/data/org.gnome.World.Secrets.gschema.xml.in b/data/org.gnome.World.Secrets.gschema.xml.in
index 3f10ea8..e69c55f 100644
--- a/data/org.gnome.World.Secrets.gschema.xml.in
+++ b/data/org.gnome.World.Secrets.gschema.xml.in
@@ -107,15 +107,5 @@
<summary>Separator when generating a passphrase</summary>
<description>Word separator to use when generating a passphrase.</description>
</key>
- <key type="b" name="quick-unlock">
- <default>false</default>
- <summary>Enable Quick Unlock</summary>
- <description>With quick unlock enabled, a safe can be re-entered using the last four characters of the password. If the first try is wrong, the full password is needed to unlock the safe.</description>
- </key>
- <key type="b" name="fingerprint-quick-unlock">
- <default>false</default>
- <summary>Enable Fingerprint Quick Unlock</summary>
- <description>Use the fingerprint reader to quick unlock a locked safe.</description>
- </key>
</schema>
</schemalist>
diff --git a/data/resources.gresource.xml.in b/data/resources.gresource.xml.in
index 11bd5c1..0e18731 100644
--- a/data/resources.gresource.xml.in
+++ b/data/resources.gresource.xml.in
@@ -44,7 +44,6 @@
<file preprocess="xml-stripblanks">icons/scalable/status/external-link-symbolic.svg</file>
<file preprocess="xml-stripblanks">icons/scalable/status/eye-not-looking-symbolic.svg</file>
<file preprocess="xml-stripblanks">icons/scalable/status/eye-open-negative-filled-symbolic.svg</file>
- <file preprocess="xml-stripblanks">icons/scalable/status/fingerprint-detection-symbolic.svg</file>
<file preprocess="xml-stripblanks">icons/scalable/status/info-outline-symbolic.svg</file>
<file preprocess="xml-stripblanks">icons/scalable/status/money-symbolic.svg</file>
<file preprocess="xml-stripblanks">icons/scalable/status/notepad-symbolic.svg</file>
diff --git a/data/style.css b/data/style.css
index 567fc16..0f33cfd 100644
--- a/data/style.css
+++ b/data/style.css
@@ -135,67 +135,3 @@ textview {
min-height: 24px;
margin: 3px;
}
-
-/* Fingerprint */
-.fingerprint-img {
- transition-property: color;
- transition-duration: 250ms;
- color: var(--view-fg-color);
-}
-
-.fingerprint-img.success {
- transition-property: color;
- transition-duration: 250ms;
- color: var(--success-color);
-}
-
-@keyframes wiggle {
- /* Unfortunately we can't use translation or xalign, so here's the workaround */
- 0% { padding-left: 0; padding-right: 0; }
- 10% { padding-left: 0; padding-right: 2px; }
- 20% { padding-left: 4px; padding-right: 0; }
- 30% { padding-left: 0; padding-right: 8px; }
- 40% { padding-left: 8px; padding-right: 0; }
- 50% { padding-left: 0; padding-right: 8px; }
- 60% { padding-left: 8px; padding-right: 0; }
- 70% { padding-left: 0; padding-right: 8px; }
- 80% { padding-left: 4px; padding-right: 0; }
- 90% { padding-left: 0; padding-right: 2px; }
- 100% { padding-left: 0; padding-right: 0; }
-}
-
-.fingerprint-img.retry {
- animation: wiggle;
- animation-duration: 850ms;
- animation-timing-function: ease-in;
- animation-iteration-count: 1;
-}
-
-@keyframes warning-wiggle {
- /* Unfortunately we can't use translation or xalign, so here's the workaround */
- 0% { padding-left: 0; padding-right: 0; color: var(--view-fg-color); }
- 10% { padding-left: 0; padding-right: 2px; }
- 20% { padding-left: 4px; padding-right: 0; }
- 30% { padding-left: 0; padding-right: 8px; color: var(--warning-color); }
- 40% { padding-left: 8px; padding-right: 0; }
- 50% { padding-left: 0; padding-right: 8px; }
- 60% { padding-left: 8px; padding-right: 0; }
- 70% { padding-left: 0; padding-right: 8px; color: var(--warning-color); }
- 80% { padding-left: 4px; padding-right: 0; }
- 90% { padding-left: 0; padding-right: 2px; }
- 100% { padding-left: 0; padding-right: 0; color: var(--view-fg-color); }
-}
-
-.fingerprint-img.warning {
- animation: warning-wiggle;
- animation-duration: 850ms;
- animation-timing-function: ease-in;
- animation-iteration-count: 1;
-}
-
-.fingerprint-img.error {
- transition-property: color;
- transition-duration: 250ms;
- color: var(--error-color);
-}
-
diff --git a/flatpak/org.gnome.World.Secrets.Devel.json b/flatpak/org.gnome.World.Secrets.Devel.json
index fe3ad62..645f75a 100644
--- a/flatpak/org.gnome.World.Secrets.Devel.json
+++ b/flatpak/org.gnome.World.Secrets.Devel.json
@@ -18,8 +18,7 @@
"--share=ipc",
"--socket=fallback-x11",
"--socket=pcsc",
- "--socket=wayland",
- "--system-talk-name=net.reactivated.Fprint"
+ "--socket=wayland"
],
"cleanup": [
"*.a",
diff --git a/gsecrets/config_manager.py b/gsecrets/config_manager.py
index 0fdc965..04cc3ed 100644
--- a/gsecrets/config_manager.py
+++ b/gsecrets/config_manager.py
@@ -31,8 +31,6 @@ GENERATOR_LENGTH = "generator-length"
GENERATOR_WORDS = "generator-words"
GENERATOR_SEPARATOR = "generator-separator"
LOCK_ON_SESSION_LOCK = "lock-on-session-lock"
-FINGERPRINT_QUICK_UNLOCK = "fingerprint-quick-unlock"
-QUICK_UNLOCK = "quick-unlock"
def get_lock_on_session_lock() -> bool:
@@ -199,19 +197,3 @@ def get_development_backup_mode():
def set_development_backup_mode(value):
setting.set_boolean(DEV_BACKUP_MODE, value)
-
-
-def get_fingerprint_quick_unlock():
- return setting.get_boolean(FINGERPRINT_QUICK_UNLOCK)
-
-
-def set_fingerprint_quick_unlock(value: bool) -> None:
- setting.set_boolean(FINGERPRINT_QUICK_UNLOCK, value)
-
-
-def get_quick_unlock():
- return setting.get_boolean(QUICK_UNLOCK)
-
-
-def set_quick_unlock(value: bool) -> None:
- setting.set_boolean(QUICK_UNLOCK, value)
diff --git a/gsecrets/database_manager.py b/gsecrets/database_manager.py
index 0439644..6305ec7 100644
--- a/gsecrets/database_manager.py
+++ b/gsecrets/database_manager.py
@@ -318,10 +318,7 @@ class DatabaseManager(GObject.Object):
@property
def password(self) -> str:
"""Get the current password or '' if not set."""
- if db := self.db:
- return db.password or ""
-
- return ""
+ return self.db.password or ""
@password.setter
def password(self, new_password: str | None) -> None:
diff --git a/gsecrets/fingerprint_verifier.py b/gsecrets/fingerprint_verifier.py
deleted file mode 100644
index 6141cd0..0000000
--- a/gsecrets/fingerprint_verifier.py
+++ /dev/null
@@ -1,238 +0,0 @@
-from __future__ import annotations
-
-import logging
-from typing import TYPE_CHECKING
-
-if TYPE_CHECKING:
- from collections.abc import Callable
-from typing import Any, cast
-
-from gi.repository import Gio, GLib
-
-BUS_NAME = "net.reactivated.Fprint"
-DBUS_TIMEOUT = 500 # In milliseconds
-VERIFY_STATUS_TUPLE = 2
-
-
-class FingerprintVerifier:
- """Provides easy access to a fingerprint device."""
-
- def __init__(
- self,
- on_success: Callable,
- on_retry: Callable,
- on_failure: Callable,
- ) -> None:
- """Constructor.
-
- Might throw an exception if dbus is unavailable, fprintd is missing or
- no device is available.
-
- Arguments:
- ---------
- on_success: Function to be called on success.
- on_retry: Function to be called if the fingerprint sensor suggests retrying.
- on_failure: Function to be called if the fingerprint did not match or the
- hardware refused in the process.
-
- """
- self.on_success = on_success
- self.on_retry = on_retry
- self.on_failure = on_failure
-
- self._is_claimed = False
- self._device_proxy = None
- self._signal = None
-
- def connect(self, cb: Gio.Callback) -> None:
- """Initializes the connection to the fingerprint device.
-
- Shouldn't be called manually unless disconnect was called on the object before.
-
- Might throw an exception if dbus is unavailable, fprindt is missing
- or no device is available.
- """
- if self._is_claimed:
- return
-
- async def connect_fingerprint():
- con = await Gio.bus_get(Gio.BusType.SYSTEM, None)
-
- manager_proxy = await Gio.DBusProxy.new(
- con,
- Gio.DBusProxyFlags.NONE,
- None,
- BUS_NAME,
- "/net/reactivated/Fprint/Manager",
- "net.reactivated.Fprint.Manager",
- None,
- )
- if manager_proxy is None:
- logging.debug("Fprintd not available.")
- return
-
- try:
- device_str = await manager_proxy.call(
- "GetDefaultDevice",
- None,
- Gio.DBusCallFlags.NO_AUTO_START,
- DBUS_TIMEOUT,
- None,
- )[0]
- except GLib.GError:
- logging.exception("Failed to get default fingerprint device")
- return
-
- if device_str == "":
- logging.debug("No fingerprint sensor found!")
- return
-
- self._device_proxy = await Gio.DBusProxy.new(
- con,
- Gio.DBusProxyFlags.NONE,
- None,
- BUS_NAME,
- device_str,
- "net.reactivated.Fprint.Device",
- None,
- )
- if self._device_proxy is None:
- logging.debug("Failed to find the default fingerprint device.")
- return
-
- self._signal = self._device_proxy.connect("g-signal", self._signal_handler)
- logging.debug("Successfully connected to the fingerprint device.")
-
- cb()
-
- app = Gio.Application.get_default()
- app.create_asyncio_task(connect_fingerprint())
-
- def disconnect(self) -> None:
- """Removes the handlers from the signal.
-
- Should be called when the class is not needed anymore.
- """
- if self._is_claimed or self._device_proxy is None:
- return
-
- self._is_claimed = False
- self._device_proxy.disconnect(self._signal)
- self._signal = None
- self._device_proxy = None
- logging.debug("Disconnected from the fingerprint device.")
-
- async def verify_start(self) -> bool:
- """Starts the fingerprint verification process.
-
- Returns: True if the fingerprint verification started.
-
- """
- if self._device_proxy is None:
- return False
-
- try:
- await self._claim_device()
- except GLib.Error:
- logging.exception("Failed to claim device")
- return False
-
- self._is_claimed = True
- try:
- await self._verify_start()
- except GLib.Error:
- logging.exception("Failed to start fingerprint verification on the device")
- return False
-
- logging.debug("Claimed fingerprint device, verification ongoing...")
- return True
-
- async def verify_stop(self) -> None:
- """Stops the fingerprint verification process."""
- if not self._is_claimed:
- return
-
- self._is_claimed = False
-
- try:
- await self._verify_stop()
- await self._release_device()
- logging.debug("Stopped verification, released fingerprint device.")
- except GLib.Error as err:
- logging.debug("Exception while releasing fingerprint device: %s", err)
-
- #
- # Internal methods
- #
-
- async def _claim_device(self) -> None:
- if self._device_proxy:
- await self._device_proxy.call(
- "Claim",
- GLib.Variant("(s)", ("",)),
- Gio.DBusCallFlags.NO_AUTO_START,
- DBUS_TIMEOUT,
- None,
- )
-
- async def _release_device(self) -> None:
- if self._device_proxy:
- await self._device_proxy.call(
- "Release",
- None,
- Gio.DBusCallFlags.NO_AUTO_START,
- DBUS_TIMEOUT,
- None,
- )
-
- async def _verify_start(self) -> None:
- if self._device_proxy:
- await self._device_proxy.call(
- "VerifyStart",
- GLib.Variant("(s)", ("any",)),
- Gio.DBusCallFlags.NO_AUTO_START,
- DBUS_TIMEOUT,
- None,
- )
-
- async def _verify_stop(self) -> None:
- if self._device_proxy:
- await self._device_proxy.call(
- "VerifyStop",
- None,
- Gio.DBusCallFlags.NO_AUTO_START,
- DBUS_TIMEOUT,
- None,
- )
-
- retry_results = [
- "verify-retry-scan",
- "verify-swipe-too-short",
- "verify-finger-not-centered",
- "verify-remove-and-retry",
- ]
-
- def _signal_handler(
- self,
- _proxy: Gio.DBusProxy,
- _sender: str, # pylint: disable=unused-argument
- signal: str,
- args: tuple[Any],
- ) -> None:
- if signal != "VerifyStatus" or len(args) != VERIFY_STATUS_TUPLE:
- return
-
- result, done = cast(tuple[str, bool], args) # see mypy/issues/1178
-
- if result in self.retry_results and not done:
- self.on_retry()
-
- if done:
- if result != "verify-disconnected":
- app = Gio.Application.get_default()
- app.create_asyncio_task(self.verify_stop())
-
- if result == "verify-match":
- self.on_success()
- else:
- self.on_failure()
diff --git a/gsecrets/settings_dialog.py b/gsecrets/settings_dialog.py
index a7f6d10..7a48a9f 100644
--- a/gsecrets/settings_dialog.py
+++ b/gsecrets/settings_dialog.py
@@ -106,13 +106,6 @@ class SettingsDialog(Adw.PreferencesDialog):
self._on_remember_composite_key,
)
- quick_unlock_action = settings.create_action("quick-unlock")
- action_group.add_action(quick_unlock_action)
- fingerprint_quick_unlock_action = settings.create_action(
- "fingerprint-quick-unlock",
- )
- action_group.add_action(fingerprint_quick_unlock_action)
-
self.insert_action_group("settings", action_group)
def _on_remember_composite_key(self, action, _param):
diff --git a/gsecrets/unlock_database.py b/gsecrets/unlock_database.py
index d48991b..48da162 100644
--- a/gsecrets/unlock_database.py
+++ b/gsecrets/unlock_database.py
@@ -12,7 +12,6 @@ import gsecrets.config_manager
from gsecrets import const
from gsecrets.database_manager import DatabaseManager
from gsecrets.err import QUARK, ErrorType
-from gsecrets.fingerprint_verifier import FingerprintVerifier
from gsecrets.unlocked_database import UnlockedDatabase
from gsecrets.utils import compare_passwords
@@ -36,9 +35,6 @@ class UnlockDatabase(Adw.Bin):
unlock_button = Gtk.Template.Child()
banner = Gtk.Template.Child()
_progress = Gtk.Template.Child()
- fingerprint_img = Gtk.Template.Child()
-
- FPRINT_MAX_TRIES = 3
def __init__(self, window: Window, database_file: Gio.File) -> None:
super().__init__()
@@ -65,26 +61,6 @@ class UnlockDatabase(Adw.Bin):
if gsecrets.const.IS_DEVEL:
self.status_page.props.icon_name = gsecrets.const.APP_ID
- self.fprint: FingerprintVerifier | None = None
- self.fprint_tries = 0
- if gsecrets.config_manager.get_fingerprint_quick_unlock():
- self._map_fingerprint_reader()
-
- self.quick_unlock_failed = False
-
- self.event_controller = Gtk.EventControllerFocus.new()
- self.add_controller(self.event_controller)
- self.event_controller.connect("enter", self.on_enter)
- self.event_controller.connect("leave", self.on_leave)
-
- settings = self.window.application.settings
- settings.connect(
- "changed::fingerprint-quick-unlock",
- self._on_fingerprint_settings_changed,
- )
-
- self.window.set_default_widget(self.unlock_button)
-
for key_provider in self.window.key_providers.get_key_providers():
if key_provider.available:
widget = key_provider.create_unlock_widget(self.database_manager)
@@ -93,26 +69,6 @@ class UnlockDatabase(Adw.Bin):
def do_unmap(self): # pylint: disable=arguments-differ
Gtk.Widget.do_unmap(self)
self._progress.end_pulse()
- self.remove_controller(self.event_controller)
- self._unmap_fingerprint_reader()
-
- def on_enter(self, _user_data):
- if self.database_manager and self.database_manager.password != "":
- if (
- gsecrets.config_manager.get_quick_unlock()
- and not self.quick_unlock_failed
- ):
- self.window.show_banner(_("Quick Unlock active"))
- self.provider_group.props.visible = False
- # only start reading if there are still tries left
- if self.fprint_tries < self.FPRINT_MAX_TRIES:
- self._start_fingerprint_reader()
- else:
- logging.debug("Quick unlock disabled as no password is available.")
-
- def on_leave(self, _user_data):
- if self.fprint_tries < self.FPRINT_MAX_TRIES:
- self._stop_fingerprint_reader()
def grab_entry_focus(self):
self.password_entry.grab_focus()
@@ -157,18 +113,10 @@ class UnlockDatabase(Adw.Bin):
self._open_database()
return
- quick_unlock = (
- gsecrets.config_manager.get_quick_unlock()
- and not self.quick_unlock_failed
- and entered_pwd == self.database_manager.password[-4:]
- )
-
- full_unlock = (
+ if (
compare_passwords(entered_pwd, self.database_manager.password)
and self.database_manager.composition_key == self.composition_key
- )
-
- if quick_unlock or full_unlock:
+ ):
self.database_manager.props.locked = False
self.database_manager.add_to_history()
else:
@@ -254,9 +202,6 @@ class UnlockDatabase(Adw.Bin):
self._progress.end_pulse()
- self.quick_unlock_failed = True
- self.provider_group.props.visible = True
-
def _set_sensitive(self, sensitive):
delegate = self.password_entry.get_delegate()
if delegate.has_focus() and not sensitive:
@@ -313,118 +258,3 @@ class UnlockDatabase(Adw.Bin):
def close_banner(self):
self.banner.set_revealed(False)
-
- #
- # Fingerprint-related stuff
- #
-
- def _on_fingerprint_settings_changed(self, _settings, _key):
- if gsecrets.config_manager.get_fingerprint_quick_unlock():
- logging.debug("Fingerprint got enabled, mapping fingerprint reader...")
- self._map_fingerprint_reader()
- else:
- logging.debug("Fingerprint got disabled, unmapping fingerprint reader...")
- self._unmap_fingerprint_reader()
-
- def _start_fingerprint_reader_cb(self) -> None:
- if not self.fprint:
- return
-
- async def cb():
- if await self.fprint.verify_start():
- self.fingerprint_img.props.visible = True
-
- app = Gio.Application.get_default()
- app.create_asyncio_task(cb())
-
- def _start_fingerprint_reader(self) -> None:
- if not self.fprint:
- return
- self.fprint.connect(self._start_fingerprint_reader_cb)
-
- def _stop_fingerprint_reader(self) -> None:
- if not self.fprint:
- return
-
- async def disconnect():
- await self.fprint.verify_stop()
- self.fprint.disconnect()
- self.fingerprint_img.props.visible = False
-
- app = Gio.Application.get_default()
- app.create_asyncio_task(disconnect())
-
- def _map_fingerprint_reader(self) -> None:
- logging.debug("Connecting to the fingerprint device...")
- try:
- self.fprint = FingerprintVerifier(
- self._on_fingerprint_success,
- self._on_fingerprint_retry,
- self._on_fingerprint_failure,
- )
- except RuntimeError as err:
- logging.debug("Failed initialize fingerprint: %s", err)
-
- def _unmap_fingerprint_reader(self) -> None:
- if not self.fprint:
- return
- logging.debug("Disconnecting the fingerprint device...")
- self._stop_fingerprint_reader()
- self.fprint = None
-
- def _on_fingerprint_success(self):
- """Success callback of the the FingerprintVerifier."""
- self.fingerprint_img.add_css_class("success")
- GLib.timeout_add(250, self._after_fingerprint_success)
- logging.debug("Fingerprint success")
-
- def _after_fingerprint_success(self):
- """Unlocks database after animation of _on_fingerprint_success."""
- self.database_manager.props.locked = False
-
- def _on_fingerprint_retry(self):
- """Retry callback of the the FingerprintVerifier."""
- self.fingerprint_img.add_css_class("retry")
- GLib.timeout_add(850, self._after_fingerprint_retry)
- logging.debug("Fingerprint retry")
-
- def _after_fingerprint_retry(self):
- """Cleans up animation after _on_fingerprint_retry."""
- self.fingerprint_img.remove_css_class("retry")
-
- def _on_fingerprint_failure(self):
- """Failure callback of the the FingerprintVerifier."""
- self.fprint_tries += 1
-
- async def start_fprint():
- status = await self.fprint.verify_start()
- if not status:
- # in case fingerprint sensor itself refuses
- self.fingerprint_img.add_css_class("error")
- self.window.send_notification(_("Please unlock using the password."))
- logging.debug(
- "Retry after verify-no-match failed. Fingerprint disabled.",
- )
-
- if self.fprint_tries >= self.FPRINT_MAX_TRIES:
- # at most 3 tries for unlocking with the fingerprint sensor
- self.fingerprint_img.add_css_class("error")
- self.window.send_notification(
- _("Maximum tries reached. Please unlock using the password."),
- )
- self.fprint.disconnect()
- logging.debug("Max tries reached. Fingerprint disabled.")
- else:
- # else start verification again
- self.fingerprint_img.add_css_class("warning")
- GLib.timeout_add(850, self._after_fingerprint_warning)
- logging.debug("Fingerprint no-match for try %i", self.fprint_tries)
- app = Gio.Application.get_default()
- app.create_asyncio_task(start_fprint())
-
- def _after_fingerprint_warning(self):
- """Cleans up.
-
- Animation after _on_fingerprint_failure if FPRINT_MAX_TRIES not reached
- """
- self.fingerprint_img.remove_css_class("warning")
|