Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
99 changes: 56 additions & 43 deletions src/locker/plugin/fingerprint.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@
#include <iostream>
#include <giomm.h>
#include <giomm/dbusproxy.h>
#include <giomm/asyncresult.h>
#include <glibmm/ustring.h>
#include <glibmm/refptr.h>
#include <glibmm/variant.h>
#include <gtkmm/image.h>
#include <gtkmm/box.h>
Expand All @@ -29,7 +31,7 @@ WayfireLockerFingerprintPlugin::~WayfireLockerFingerprintPlugin()
{
if (device_proxy)
{
device_proxy->call_sync("Release");
device_proxy->call("Release");
}
}

Expand Down Expand Up @@ -62,14 +64,17 @@ void WayfireLockerFingerprintPlugin::get_device()
}

try {
auto default_device = manager_proxy->call_sync("GetDefaultDevice");
Glib::Variant<Glib::ustring> item_path;
default_device.get_child(item_path, 0);
Gio::DBus::Proxy::create(connection,
"net.reactivated.Fprint",
item_path.get(),
"net.reactivated.Fprint.Device",
sigc::mem_fun(*this, &WayfireLockerFingerprintPlugin::on_device_acquired));
manager_proxy->call("GetDefaultDevice", [=] (Glib::RefPtr<Gio::AsyncResult>& result)
{
auto default_device = manager_proxy->call_finish(result);
Glib::Variant<Glib::ustring> item_path;
default_device.get_child(item_path, 0);
Gio::DBus::Proxy::create(connection,
"net.reactivated.Fprint",
item_path.get(),
"net.reactivated.Fprint.Device",
sigc::mem_fun(*this, &WayfireLockerFingerprintPlugin::on_device_acquired));
});
} catch (Glib::Error & e) /* TODO : Narrow down? */
{
hide();
Expand All @@ -82,26 +87,29 @@ void WayfireLockerFingerprintPlugin::on_device_acquired(const Glib::RefPtr<Gio::
device_proxy = Gio::DBus::Proxy::create_finish(result);
update("Listing fingers...", "system-search-symbolic", "info");
char *username = getlogin();
auto reply = device_proxy->call_sync("ListEnrolledFingers", nullptr,
Glib::Variant<std::tuple<Glib::ustring>>::create(username));
Glib::Variant<std::vector<Glib::ustring>> array;
reply.get_child(array, 0);

if (array.get_n_children() == 0)
device_proxy->call("ListEnrolledFingers", [=] (Glib::RefPtr<Gio::AsyncResult>& result)
{
// Zero fingers for this user.
show();
update("No fingerprints enrolled", "dialog-error-symbolic", "bad");
// Don't hide entirely, allow the user to see this specific fail
return;
}
auto reply = device_proxy->call_finish(result);
Glib::Variant<std::vector<Glib::ustring>> array;
reply.get_child(array, 0);

show();
update("Fingerprint Device Ready", "system-search-symbolic", "info");
Glib::Variant<Glib::ustring> finger;
reply.get_child(finger, 0);
if (array.get_n_children() == 0)
{
// Zero fingers for this user.
show();
update("No fingerprints enrolled", "dialog-error-symbolic", "bad");
// Don't hide entirely, allow the user to see this specific fail
return;
}

start_fingerprint_scanning();
show();
update("Fingerprint Device Ready", "system-search-symbolic", "info");
Glib::Variant<Glib::ustring> finger;
reply.get_child(finger, 0);

start_fingerprint_scanning();
},
Glib::Variant<std::tuple<Glib::ustring>>::create(username));
}

void WayfireLockerFingerprintPlugin::start_fingerprint_scanning()
Expand Down Expand Up @@ -218,7 +226,13 @@ void WayfireLockerFingerprintPlugin::start_fingerprint_scanning()

try {
char *username = getlogin();
device_proxy->call_sync("Claim", nullptr,
device_proxy->call("Claim", [=] (Glib::RefPtr<Gio::AsyncResult>& result)
{
show();
update("Use fingerprint to unlock", "process-completed-symbolic", "good");
device_proxy->call("VerifyStart",
Glib::Variant<std::tuple<Glib::ustring>>::create({""}));
},
Glib::Variant<std::tuple<Glib::ustring>>::create({username}));
} catch (Glib::Error & e) /* TODO : Narrow down? */
{
Expand All @@ -233,12 +247,6 @@ void WayfireLockerFingerprintPlugin::start_fingerprint_scanning()
}, 3);
return;
}

show();
update("Use fingerprint to unlock", "process-completed-symbolic", "good");
device_proxy->call_sync("VerifyStart",
nullptr,
Glib::Variant<std::tuple<Glib::ustring>>::create({""}));
} else
{
update("Unable to start fingerprint scan", "dialog-error-symbolic", "bad");
Expand Down Expand Up @@ -266,8 +274,10 @@ void WayfireLockerFingerprintPlugin::stop_fingerprint_scanning()
/* Stop if running. Eventually log or respond to errors
* but for now, avoid crashing lockscreen on close-down */
try {
device_proxy->call_sync("VerifyStop");
device_proxy->call_sync("Release");
device_proxy->call("VerifyStop", [=] (Glib::RefPtr<Gio::AsyncResult>& result)
{
device_proxy->call("Release");
});
} catch (Glib::Error & e)
{}
}
Expand All @@ -291,14 +301,17 @@ void WayfireLockerFingerprintPlugin::init()
{
auto manager_proxy = Gio::DBus::Proxy::create_finish(result);
try {
auto default_device = manager_proxy->call_sync("GetDefaultDevice");
Glib::Variant<Glib::ustring> item_path;
default_device.get_child(item_path, 0);
Gio::DBus::Proxy::create(connection,
"net.reactivated.Fprint",
item_path.get(),
"net.reactivated.Fprint.Device",
sigc::mem_fun(*this, &WayfireLockerFingerprintPlugin::on_device_acquired));
manager_proxy->call("GetDefaultDevice", [=] (Glib::RefPtr<Gio::AsyncResult> & result)
{
auto default_device = manager_proxy->call_finish(result);
Glib::Variant<Glib::ustring> item_path;
default_device.get_child(item_path, 0);
Gio::DBus::Proxy::create(connection,
"net.reactivated.Fprint",
item_path.get(),
"net.reactivated.Fprint.Device",
sigc::mem_fun(*this, &WayfireLockerFingerprintPlugin::on_device_acquired));
});
} catch (Glib::Error & e) /* TODO : Narrow down? */
{
hide();
Expand Down
Loading