mirror of
https://gitlab.com/mishakmak/pam-fprint-grosshack.git
synced 2026-04-08 20:03:34 +02:00
verify: Fix verify script to work correctly
The verify script would start an async routine. However, this blocks the dbus return, which really is needed. Also, we should only return one item of the script for each VerifyStart run. So, fix things by pop'ing the first item and putting it on the bus from a GLib.add_timeout handler.
This commit is contained in:
@ -18,6 +18,7 @@ __email__ = 'hadess@hadess.net'
|
|||||||
__copyright__ = '(c) 2020 Red Hat Inc.'
|
__copyright__ = '(c) 2020 Red Hat Inc.'
|
||||||
__license__ = 'LGPL 3+'
|
__license__ = 'LGPL 3+'
|
||||||
|
|
||||||
|
from gi.repository import GLib
|
||||||
import dbus
|
import dbus
|
||||||
import asyncio
|
import asyncio
|
||||||
|
|
||||||
@ -213,13 +214,9 @@ def can_verify_finger(device, finger_name):
|
|||||||
return True
|
return True
|
||||||
return False
|
return False
|
||||||
|
|
||||||
async def send_verify_script(device, script):
|
def device_emit_signal(device, *args):
|
||||||
for [result, done, timeout] in device.verify_script:
|
print("emitting signal", *args)
|
||||||
await asyncio.sleep(timeout)
|
device.EmitSignal(*args)
|
||||||
device.EmitSignal(DEVICE_IFACE, 'VerifyStatus', 'sb', [
|
|
||||||
result,
|
|
||||||
done
|
|
||||||
])
|
|
||||||
|
|
||||||
@dbus.service.method(DEVICE_IFACE,
|
@dbus.service.method(DEVICE_IFACE,
|
||||||
in_signature='s', out_signature='')
|
in_signature='s', out_signature='')
|
||||||
@ -249,13 +246,21 @@ def VerifyStart(device, finger_name):
|
|||||||
if finger_name == 'any' and not device.has_identification:
|
if finger_name == 'any' and not device.has_identification:
|
||||||
finger_name = device.fingers[device.claimed_user][0]
|
finger_name = device.fingers[device.claimed_user][0]
|
||||||
device.selected_finger = finger_name
|
device.selected_finger = finger_name
|
||||||
device.EmitSignal(DEVICE_IFACE, 'VerifyFingerSelected', 's', [
|
# Needs to happen after method return
|
||||||
finger_name
|
GLib.idle_add(device.EmitSignal,
|
||||||
])
|
DEVICE_IFACE, 'VerifyFingerSelected', 's', [
|
||||||
|
device.selected_finger
|
||||||
|
])
|
||||||
|
|
||||||
if device.verify_script is not None and len(device.verify_script) > 0:
|
if device.verify_script is not None and len(device.verify_script) > 0:
|
||||||
asyncio.run(send_verify_script(device, device.verify_script))
|
result, done, timeout = device.verify_script.pop(0)
|
||||||
|
GLib.timeout_add(timeout,
|
||||||
|
device_emit_signal,
|
||||||
|
device,
|
||||||
|
DEVICE_IFACE, 'VerifyStatus', 'sb', [
|
||||||
|
result,
|
||||||
|
done
|
||||||
|
])
|
||||||
|
|
||||||
@dbus.service.method(DEVICE_MOCK_IFACE,
|
@dbus.service.method(DEVICE_MOCK_IFACE,
|
||||||
in_signature='sb', out_signature='')
|
in_signature='sb', out_signature='')
|
||||||
|
|||||||
Reference in New Issue
Block a user