[gnome-shell] fingerprint: Show different strings depending on type



commit aa392d45c95d6cc8d2ff8ed043331179a26c2711
Author: Razze <razzeee gmail com>
Date:   Sat Jan 30 20:14:04 2021 +0100

    fingerprint: Show different strings depending on type
    
    Fprintd knows if the fingerprint reader is of the swipe or press type. We now show different labels 
depending on that.
    
    Closes https://gitlab.gnome.org/GNOME/gnome-shell/-/issues/2011
    
    Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/1572>

 .../net.reactivated.Fprint.Device.xml              | 78 ++++++++++++++++++++++
 data/gnome-shell-dbus-interfaces.gresource.xml     |  1 +
 js/gdm/util.js                                     | 45 ++++++++++---
 3 files changed, 113 insertions(+), 11 deletions(-)
---
diff --git a/data/dbus-interfaces/net.reactivated.Fprint.Device.xml 
b/data/dbus-interfaces/net.reactivated.Fprint.Device.xml
new file mode 100644
index 0000000000..b3d143c218
--- /dev/null
+++ b/data/dbus-interfaces/net.reactivated.Fprint.Device.xml
@@ -0,0 +1,78 @@
+<!DOCTYPE node PUBLIC
+"-//freedesktop//DTD D-BUS Object Introspection 1.0//EN"
+"http://www.freedesktop.org/standards/dbus/1.0/introspect.dtd";>
+
+<node>
+       <interface name="net.reactivated.Fprint.Device">
+               <method name="ListEnrolledFingers">
+                       <arg type="s" name="username" direction="in">
+                       </arg>
+                       <arg type="as" name="enrolled_fingers" direction="out">
+                       </arg>
+               </method>
+
+               <method name="DeleteEnrolledFingers">
+                       <arg type="s" name="username" direction="in">
+                       </arg>
+               </method>
+
+               <method name="DeleteEnrolledFingers2">
+               </method>
+
+               <method name="Claim">
+                       <arg type="s" name="username" direction="in">
+                       </arg>
+               </method>
+
+               <method name="Release">
+               </method>
+
+               <method name="VerifyStart">
+                       <arg type="s" name="finger_name" direction="in">
+                       </arg>
+               </method>
+
+               <method name="VerifyStop">
+               </method>
+
+               <signal name="VerifyFingerSelected">
+                       <arg type="s" name="finger_name">
+                       </arg>
+               </signal>
+
+               <signal name="VerifyStatus">
+                       <arg type="s" name="result">
+                       </arg>
+
+                       <arg type="b" name="done">
+                       </arg>
+
+               </signal>
+
+               <method name="EnrollStart">
+                       <arg type="s" name="finger_name" direction="in">
+                       </arg>
+               </method>
+
+               <method name="EnrollStop">
+               </method>
+
+               <signal name="EnrollStatus">
+                       <arg type="s" name="result">
+                       </arg>
+
+                       <arg type="b" name="done">
+                       </arg>
+               </signal>
+
+               <property name="name" type="s" access="read">
+               </property>
+
+               <property name="num-enroll-stages" type="i" access="read">
+               </property>
+
+               <property name="scan-type" type="s" access="read">
+               </property>
+
+       </interface>
+</node>
diff --git a/data/gnome-shell-dbus-interfaces.gresource.xml b/data/gnome-shell-dbus-interfaces.gresource.xml
index c705a22840..e7972f6cb0 100644
--- a/data/gnome-shell-dbus-interfaces.gresource.xml
+++ b/data/gnome-shell-dbus-interfaces.gresource.xml
@@ -2,6 +2,7 @@
 <gresources>
   <gresource prefix="/org/gnome/shell/dbus-interfaces">
     <file preprocess="xml-stripblanks">net.hadess.SensorProxy.xml</file>
+    <file preprocess="xml-stripblanks">net.reactivated.Fprint.Device.xml</file>
     <file preprocess="xml-stripblanks">net.reactivated.Fprint.Manager.xml</file>
     <file preprocess="xml-stripblanks">org.freedesktop.Application.xml</file>
     <file preprocess="xml-stripblanks">org.freedesktop.bolt1.Device.xml</file>
diff --git a/js/gdm/util.js b/js/gdm/util.js
index bcf8a514c8..1bd2b6b8ba 100644
--- a/js/gdm/util.js
+++ b/js/gdm/util.js
@@ -15,6 +15,8 @@ const SmartcardManager = imports.misc.smartcardManager;
 
 const FprintManagerIface = loadInterfaceXML('net.reactivated.Fprint.Manager');
 const FprintManagerProxy = Gio.DBusProxy.makeProxyWrapper(FprintManagerIface);
+const FprintDeviceIface = loadInterfaceXML('net.reactivated.Fprint.Device');
+const FprintDeviceProxy = Gio.DBusProxy.makeProxyWrapper(FprintDeviceIface);
 
 Gio._promisify(Gdm.Client.prototype,
     'open_reauthentication_channel', 'open_reauthentication_channel_finish');
@@ -52,6 +54,12 @@ var MessageType = {
     HINT: 3,
 };
 
+const FingerprintReaderType = {
+    NONE: 0,
+    PRESS: 1,
+    SWIPE: 2,
+};
+
 function fadeInActor(actor) {
     if (actor.opacity == 255 && actor.visible)
         return null;
@@ -312,7 +320,7 @@ var ShellUserVerifier = class {
     }
 
     _checkForFingerprintReader() {
-        this._haveFingerprintReader = false;
+        this._fingerprintReaderType = FingerprintReaderType.NONE;
 
         if (!this._settings.get_boolean(FINGERPRINT_AUTHENTICATION_KEY) ||
             this._fprintManager == null) {
@@ -321,9 +329,17 @@ var ShellUserVerifier = class {
         }
 
         this._fprintManager.GetDefaultDeviceRemote(Gio.DBusCallFlags.NONE, this._cancellable,
-            (device, error) => {
-                if (!error && device) {
-                    this._haveFingerprintReader = true;
+            (params, error) => {
+                if (!error && params) {
+                    const [device] = params;
+                    const fprintDeviceProxy = new FprintDeviceProxy(Gio.DBus.system,
+                        'net.reactivated.Fprint',
+                        device);
+                    const fprintDeviceType = fprintDeviceProxy['scan-type'];
+
+                    this._fingerprintReaderType = fprintDeviceType === 'swipe'
+                        ? FingerprintReaderType.SWIPE
+                        : FingerprintReaderType.PRESS;
                     this._updateDefaultService();
                 }
             });
@@ -438,7 +454,7 @@ var ShellUserVerifier = class {
             this._defaultService = PASSWORD_SERVICE_NAME;
         else if (this._settings.get_boolean(SMARTCARD_AUTHENTICATION_KEY))
             this._defaultService = SMARTCARD_SERVICE_NAME;
-        else if (this._haveFingerprintReader)
+        else if (this._fingerprintReaderType !== FingerprintReaderType.NONE)
             this._defaultService = FINGERPRINT_SERVICE_NAME;
 
         if (!this._defaultService) {
@@ -471,7 +487,9 @@ var ShellUserVerifier = class {
     _beginVerification() {
         this._startService(this._getForegroundService());
 
-        if (this._userName && this._haveFingerprintReader && 
!this.serviceIsForeground(FINGERPRINT_SERVICE_NAME))
+        if (this._userName &&
+            this._fingerprintReaderType !== FingerprintReaderType.NONE &&
+            !this.serviceIsForeground(FINGERPRINT_SERVICE_NAME))
             this._startService(FINGERPRINT_SERVICE_NAME);
     }
 
@@ -479,14 +497,19 @@ var ShellUserVerifier = class {
         if (this.serviceIsForeground(serviceName)) {
             this._queueMessage(info, MessageType.INFO);
         } else if (serviceName == FINGERPRINT_SERVICE_NAME &&
-            this._haveFingerprintReader) {
+            this._fingerprintReaderType !== FingerprintReaderType.NONE) {
             // We don't show fingerprint messages directly since it's
             // not the main auth service. Instead we use the messages
             // as a cue to display our own message.
-
-            // Translators: this message is shown below the password entry field
-            // to indicate the user can swipe their finger instead
-            this._queueMessage(_("(or swipe finger)"), MessageType.HINT);
+            if (this._fingerprintReaderType === FingerprintReaderType.SWIPE) {
+                // Translators: this message is shown below the password entry field
+                // to indicate the user can swipe their finger on the fingerprint reader
+                this._queueMessage(_('(or swipe finger across reader)'), MessageType.HINT);
+            } else {
+                // Translators: this message is shown below the password entry field
+                // to indicate the user can place their finger on the fingerprint reader instead
+                this._queueMessage(_('(or place finger on reader)'), MessageType.HINT);
+            }
         }
     }
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]