2008-03-06 16:37:19 +00:00
|
|
|
/*
|
|
|
|
|
* fprintd example to enroll right index finger
|
|
|
|
|
* Copyright (C) 2008 Daniel Drake <dsd@gentoo.org>
|
fprintd: Use GDBus codegen based implementation
Fprintd is dependent on the deprecated dbus-glib, also this doesn't provide
various features we can take advantage of, like the ones for async
authentication mechanism.
So, remove all the dbus-glib dependencies and simplify the code, but without
any further refactor, and keeping everything as it used to work, while this
will give room for further improvements in subsequent commits.
Internally, we just use dbus-codegen to generate the skeletons, and we
use the generated FprintdDBusManager with composition, while we
implement the device skeleton interface in FprintDevice, so that we
don't have to use it as a proxy, and keep being closer to what it used
to be with dbus-glib.
Fixes: #61
2020-02-03 20:29:56 +01:00
|
|
|
* Copyright (C) 2020 Marco Trevisan <marco.trevisan@canonical.com>
|
2008-03-06 16:37:19 +00:00
|
|
|
*
|
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
|
* (at your option) any later version.
|
|
|
|
|
*
|
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
|
*
|
|
|
|
|
* You should have received a copy of the GNU General Public License along
|
|
|
|
|
* with this program; if not, write to the Free Software Foundation, Inc.,
|
|
|
|
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
|
|
|
|
*/
|
|
|
|
|
|
2020-01-14 15:16:24 +01:00
|
|
|
#define _GNU_SOURCE
|
2008-03-06 16:37:19 +00:00
|
|
|
#include <stdlib.h>
|
2013-05-07 20:55:21 +04:00
|
|
|
#include <string.h>
|
2019-12-04 11:58:28 +01:00
|
|
|
#include <locale.h>
|
fprintd: Use GDBus codegen based implementation
Fprintd is dependent on the deprecated dbus-glib, also this doesn't provide
various features we can take advantage of, like the ones for async
authentication mechanism.
So, remove all the dbus-glib dependencies and simplify the code, but without
any further refactor, and keeping everything as it used to work, while this
will give room for further improvements in subsequent commits.
Internally, we just use dbus-codegen to generate the skeletons, and we
use the generated FprintdDBusManager with composition, while we
implement the device skeleton interface in FprintDevice, so that we
don't have to use it as a proxy, and keep being closer to what it used
to be with dbus-glib.
Fixes: #61
2020-02-03 20:29:56 +01:00
|
|
|
#include "fprintd-dbus.h"
|
2008-03-06 16:37:19 +00:00
|
|
|
|
2014-02-18 18:32:08 +01:00
|
|
|
#define N_(x) x
|
|
|
|
|
#define TR(x) x
|
|
|
|
|
#include "fingerprint-strings.h"
|
|
|
|
|
|
fprintd: Use GDBus codegen based implementation
Fprintd is dependent on the deprecated dbus-glib, also this doesn't provide
various features we can take advantage of, like the ones for async
authentication mechanism.
So, remove all the dbus-glib dependencies and simplify the code, but without
any further refactor, and keeping everything as it used to work, while this
will give room for further improvements in subsequent commits.
Internally, we just use dbus-codegen to generate the skeletons, and we
use the generated FprintdDBusManager with composition, while we
implement the device skeleton interface in FprintDevice, so that we
don't have to use it as a proxy, and keep being closer to what it used
to be with dbus-glib.
Fixes: #61
2020-02-03 20:29:56 +01:00
|
|
|
static FprintDBusManager *manager = NULL;
|
|
|
|
|
static GDBusConnection *connection = NULL;
|
2020-01-27 19:24:36 +01:00
|
|
|
static char *finger_name = NULL;
|
2013-05-07 20:55:21 +04:00
|
|
|
static char **usernames = NULL;
|
2008-03-06 16:37:19 +00:00
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
create_manager (void)
|
|
|
|
|
{
|
2020-01-31 12:57:57 +01:00
|
|
|
g_autoptr(GError) error = NULL;
|
2020-12-03 23:55:48 +01:00
|
|
|
|
fprintd: Use GDBus codegen based implementation
Fprintd is dependent on the deprecated dbus-glib, also this doesn't provide
various features we can take advantage of, like the ones for async
authentication mechanism.
So, remove all the dbus-glib dependencies and simplify the code, but without
any further refactor, and keeping everything as it used to work, while this
will give room for further improvements in subsequent commits.
Internally, we just use dbus-codegen to generate the skeletons, and we
use the generated FprintdDBusManager with composition, while we
implement the device skeleton interface in FprintDevice, so that we
don't have to use it as a proxy, and keep being closer to what it used
to be with dbus-glib.
Fixes: #61
2020-02-03 20:29:56 +01:00
|
|
|
connection = g_bus_get_sync (G_BUS_TYPE_SYSTEM, NULL, &error);
|
2009-12-09 13:15:57 +00:00
|
|
|
if (connection == NULL)
|
|
|
|
|
{
|
|
|
|
|
g_print ("Failed to connect to session bus: %s\n", error->message);
|
|
|
|
|
exit (1);
|
|
|
|
|
}
|
2020-12-03 23:55:48 +01:00
|
|
|
|
fprintd: Use GDBus codegen based implementation
Fprintd is dependent on the deprecated dbus-glib, also this doesn't provide
various features we can take advantage of, like the ones for async
authentication mechanism.
So, remove all the dbus-glib dependencies and simplify the code, but without
any further refactor, and keeping everything as it used to work, while this
will give room for further improvements in subsequent commits.
Internally, we just use dbus-codegen to generate the skeletons, and we
use the generated FprintdDBusManager with composition, while we
implement the device skeleton interface in FprintDevice, so that we
don't have to use it as a proxy, and keep being closer to what it used
to be with dbus-glib.
Fixes: #61
2020-02-03 20:29:56 +01:00
|
|
|
manager = fprint_dbus_manager_proxy_new_sync (connection,
|
|
|
|
|
G_DBUS_PROXY_FLAGS_NONE,
|
|
|
|
|
"net.reactivated.Fprint",
|
|
|
|
|
"/net/reactivated/Fprint/Manager",
|
|
|
|
|
NULL, &error);
|
|
|
|
|
if (manager == NULL)
|
|
|
|
|
{
|
|
|
|
|
g_print ("Failed to get Fprintd manager: %s\n", error->message);
|
|
|
|
|
exit (1);
|
|
|
|
|
}
|
2008-03-06 16:37:19 +00:00
|
|
|
}
|
|
|
|
|
|
fprintd: Use GDBus codegen based implementation
Fprintd is dependent on the deprecated dbus-glib, also this doesn't provide
various features we can take advantage of, like the ones for async
authentication mechanism.
So, remove all the dbus-glib dependencies and simplify the code, but without
any further refactor, and keeping everything as it used to work, while this
will give room for further improvements in subsequent commits.
Internally, we just use dbus-codegen to generate the skeletons, and we
use the generated FprintdDBusManager with composition, while we
implement the device skeleton interface in FprintDevice, so that we
don't have to use it as a proxy, and keep being closer to what it used
to be with dbus-glib.
Fixes: #61
2020-02-03 20:29:56 +01:00
|
|
|
static FprintDBusDevice *
|
|
|
|
|
open_device (const char *username)
|
2008-03-06 16:37:19 +00:00
|
|
|
{
|
fprintd: Use GDBus codegen based implementation
Fprintd is dependent on the deprecated dbus-glib, also this doesn't provide
various features we can take advantage of, like the ones for async
authentication mechanism.
So, remove all the dbus-glib dependencies and simplify the code, but without
any further refactor, and keeping everything as it used to work, while this
will give room for further improvements in subsequent commits.
Internally, we just use dbus-codegen to generate the skeletons, and we
use the generated FprintdDBusManager with composition, while we
implement the device skeleton interface in FprintDevice, so that we
don't have to use it as a proxy, and keep being closer to what it used
to be with dbus-glib.
Fixes: #61
2020-02-03 20:29:56 +01:00
|
|
|
g_autoptr(FprintDBusDevice) dev = NULL;
|
2020-01-31 12:57:57 +01:00
|
|
|
g_autoptr(GError) error = NULL;
|
|
|
|
|
g_autofree char *path = NULL;
|
2020-12-03 23:55:48 +01:00
|
|
|
|
fprintd: Use GDBus codegen based implementation
Fprintd is dependent on the deprecated dbus-glib, also this doesn't provide
various features we can take advantage of, like the ones for async
authentication mechanism.
So, remove all the dbus-glib dependencies and simplify the code, but without
any further refactor, and keeping everything as it used to work, while this
will give room for further improvements in subsequent commits.
Internally, we just use dbus-codegen to generate the skeletons, and we
use the generated FprintdDBusManager with composition, while we
implement the device skeleton interface in FprintDevice, so that we
don't have to use it as a proxy, and keep being closer to what it used
to be with dbus-glib.
Fixes: #61
2020-02-03 20:29:56 +01:00
|
|
|
if (!fprint_dbus_manager_call_get_default_device_sync (manager, &path,
|
|
|
|
|
NULL, &error))
|
|
|
|
|
{
|
2020-04-03 03:29:12 +02:00
|
|
|
g_print ("Impossible to enroll: %s\n", error->message);
|
2009-12-09 13:15:57 +00:00
|
|
|
exit (1);
|
|
|
|
|
}
|
2020-12-03 23:55:48 +01:00
|
|
|
|
2008-03-06 16:37:19 +00:00
|
|
|
g_print ("Using device %s\n", path);
|
2020-12-03 23:55:48 +01:00
|
|
|
|
fprintd: Use GDBus codegen based implementation
Fprintd is dependent on the deprecated dbus-glib, also this doesn't provide
various features we can take advantage of, like the ones for async
authentication mechanism.
So, remove all the dbus-glib dependencies and simplify the code, but without
any further refactor, and keeping everything as it used to work, while this
will give room for further improvements in subsequent commits.
Internally, we just use dbus-codegen to generate the skeletons, and we
use the generated FprintdDBusManager with composition, while we
implement the device skeleton interface in FprintDevice, so that we
don't have to use it as a proxy, and keep being closer to what it used
to be with dbus-glib.
Fixes: #61
2020-02-03 20:29:56 +01:00
|
|
|
dev = fprint_dbus_device_proxy_new_sync (connection,
|
|
|
|
|
G_DBUS_PROXY_FLAGS_NONE,
|
|
|
|
|
"net.reactivated.Fprint",
|
|
|
|
|
path, NULL, &error);
|
2020-12-03 23:55:48 +01:00
|
|
|
|
fprintd: Use GDBus codegen based implementation
Fprintd is dependent on the deprecated dbus-glib, also this doesn't provide
various features we can take advantage of, like the ones for async
authentication mechanism.
So, remove all the dbus-glib dependencies and simplify the code, but without
any further refactor, and keeping everything as it used to work, while this
will give room for further improvements in subsequent commits.
Internally, we just use dbus-codegen to generate the skeletons, and we
use the generated FprintdDBusManager with composition, while we
implement the device skeleton interface in FprintDevice, so that we
don't have to use it as a proxy, and keep being closer to what it used
to be with dbus-glib.
Fixes: #61
2020-02-03 20:29:56 +01:00
|
|
|
if (error)
|
|
|
|
|
{
|
|
|
|
|
g_print ("failed to connect to device: %s\n", error->message);
|
|
|
|
|
exit (1);
|
|
|
|
|
}
|
2020-12-03 23:55:48 +01:00
|
|
|
|
fprintd: Use GDBus codegen based implementation
Fprintd is dependent on the deprecated dbus-glib, also this doesn't provide
various features we can take advantage of, like the ones for async
authentication mechanism.
So, remove all the dbus-glib dependencies and simplify the code, but without
any further refactor, and keeping everything as it used to work, while this
will give room for further improvements in subsequent commits.
Internally, we just use dbus-codegen to generate the skeletons, and we
use the generated FprintdDBusManager with composition, while we
implement the device skeleton interface in FprintDevice, so that we
don't have to use it as a proxy, and keep being closer to what it used
to be with dbus-glib.
Fixes: #61
2020-02-03 20:29:56 +01:00
|
|
|
if (!fprint_dbus_device_call_claim_sync (dev, username, NULL, &error))
|
|
|
|
|
{
|
2009-12-09 13:15:57 +00:00
|
|
|
g_print ("failed to claim device: %s\n", error->message);
|
|
|
|
|
exit (1);
|
|
|
|
|
}
|
fprintd: Use GDBus codegen based implementation
Fprintd is dependent on the deprecated dbus-glib, also this doesn't provide
various features we can take advantage of, like the ones for async
authentication mechanism.
So, remove all the dbus-glib dependencies and simplify the code, but without
any further refactor, and keeping everything as it used to work, while this
will give room for further improvements in subsequent commits.
Internally, we just use dbus-codegen to generate the skeletons, and we
use the generated FprintdDBusManager with composition, while we
implement the device skeleton interface in FprintDevice, so that we
don't have to use it as a proxy, and keep being closer to what it used
to be with dbus-glib.
Fixes: #61
2020-02-03 20:29:56 +01:00
|
|
|
return g_steal_pointer (&dev);
|
2008-03-06 16:37:19 +00:00
|
|
|
}
|
|
|
|
|
|
2008-11-21 10:26:06 +00:00
|
|
|
static void
|
|
|
|
|
enroll_result (GObject *object, const char *result, gboolean done, void *user_data)
|
2008-03-06 16:37:19 +00:00
|
|
|
{
|
|
|
|
|
gboolean *enroll_completed = user_data;
|
2020-12-03 23:55:48 +01:00
|
|
|
|
2008-11-20 16:51:46 +00:00
|
|
|
g_print ("Enroll result: %s\n", result);
|
2008-11-21 10:26:06 +00:00
|
|
|
if (done != FALSE)
|
|
|
|
|
*enroll_completed = TRUE;
|
2008-03-06 16:37:19 +00:00
|
|
|
}
|
|
|
|
|
|
fprintd: Use GDBus codegen based implementation
Fprintd is dependent on the deprecated dbus-glib, also this doesn't provide
various features we can take advantage of, like the ones for async
authentication mechanism.
So, remove all the dbus-glib dependencies and simplify the code, but without
any further refactor, and keeping everything as it used to work, while this
will give room for further improvements in subsequent commits.
Internally, we just use dbus-codegen to generate the skeletons, and we
use the generated FprintdDBusManager with composition, while we
implement the device skeleton interface in FprintDevice, so that we
don't have to use it as a proxy, and keep being closer to what it used
to be with dbus-glib.
Fixes: #61
2020-02-03 20:29:56 +01:00
|
|
|
static void
|
|
|
|
|
proxy_signal_cb (GDBusProxy *proxy,
|
|
|
|
|
const gchar *sender_name,
|
|
|
|
|
const gchar *signal_name,
|
|
|
|
|
GVariant *parameters,
|
|
|
|
|
gpointer user_data)
|
|
|
|
|
{
|
|
|
|
|
if (g_str_equal (signal_name, "EnrollStatus"))
|
|
|
|
|
{
|
|
|
|
|
const gchar *result;
|
|
|
|
|
gboolean done;
|
2020-12-03 23:55:48 +01:00
|
|
|
|
fprintd: Use GDBus codegen based implementation
Fprintd is dependent on the deprecated dbus-glib, also this doesn't provide
various features we can take advantage of, like the ones for async
authentication mechanism.
So, remove all the dbus-glib dependencies and simplify the code, but without
any further refactor, and keeping everything as it used to work, while this
will give room for further improvements in subsequent commits.
Internally, we just use dbus-codegen to generate the skeletons, and we
use the generated FprintdDBusManager with composition, while we
implement the device skeleton interface in FprintDevice, so that we
don't have to use it as a proxy, and keep being closer to what it used
to be with dbus-glib.
Fixes: #61
2020-02-03 20:29:56 +01:00
|
|
|
g_variant_get (parameters, "(&sb)", &result, &done);
|
|
|
|
|
enroll_result (G_OBJECT (proxy), result, done, user_data);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
do_enroll (FprintDBusDevice *dev)
|
2008-03-06 16:37:19 +00:00
|
|
|
{
|
2020-01-31 12:57:57 +01:00
|
|
|
g_autoptr(GError) error = NULL;
|
2008-03-06 16:37:19 +00:00
|
|
|
gboolean enroll_completed = FALSE;
|
2014-02-18 18:32:08 +01:00
|
|
|
gboolean found;
|
|
|
|
|
guint i;
|
2020-12-03 23:55:48 +01:00
|
|
|
|
fprintd: Use GDBus codegen based implementation
Fprintd is dependent on the deprecated dbus-glib, also this doesn't provide
various features we can take advantage of, like the ones for async
authentication mechanism.
So, remove all the dbus-glib dependencies and simplify the code, but without
any further refactor, and keeping everything as it used to work, while this
will give room for further improvements in subsequent commits.
Internally, we just use dbus-codegen to generate the skeletons, and we
use the generated FprintdDBusManager with composition, while we
implement the device skeleton interface in FprintDevice, so that we
don't have to use it as a proxy, and keep being closer to what it used
to be with dbus-glib.
Fixes: #61
2020-02-03 20:29:56 +01:00
|
|
|
g_signal_connect (dev, "g-signal", G_CALLBACK (proxy_signal_cb),
|
|
|
|
|
&enroll_completed);
|
2020-12-03 23:55:48 +01:00
|
|
|
|
2014-02-18 18:32:08 +01:00
|
|
|
found = FALSE;
|
|
|
|
|
for (i = 0; fingers[i].dbus_name != NULL; i++)
|
|
|
|
|
{
|
|
|
|
|
if (g_strcmp0 (fingers[i].dbus_name, finger_name) == 0)
|
|
|
|
|
{
|
|
|
|
|
found = TRUE;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (!found)
|
|
|
|
|
{
|
2020-01-31 12:57:57 +01:00
|
|
|
g_autoptr(GString) s = NULL;
|
2020-12-03 23:55:48 +01:00
|
|
|
|
2014-02-18 18:32:08 +01:00
|
|
|
s = g_string_new (NULL);
|
|
|
|
|
g_string_append_printf (s, "Invalid finger name '%s'. Name must be one of ", finger_name);
|
|
|
|
|
for (i = 0; fingers[i].dbus_name != NULL; i++)
|
|
|
|
|
{
|
|
|
|
|
g_string_append_printf (s, "%s", fingers[i].dbus_name);
|
|
|
|
|
if (fingers[i + 1].dbus_name != NULL)
|
|
|
|
|
g_string_append (s, ", ");
|
|
|
|
|
}
|
|
|
|
|
g_warning ("%s", s->str);
|
|
|
|
|
exit (1);
|
|
|
|
|
}
|
2020-12-03 23:55:48 +01:00
|
|
|
|
2013-05-07 20:55:21 +04:00
|
|
|
g_print ("Enrolling %s finger.\n", finger_name);
|
fprintd: Use GDBus codegen based implementation
Fprintd is dependent on the deprecated dbus-glib, also this doesn't provide
various features we can take advantage of, like the ones for async
authentication mechanism.
So, remove all the dbus-glib dependencies and simplify the code, but without
any further refactor, and keeping everything as it used to work, while this
will give room for further improvements in subsequent commits.
Internally, we just use dbus-codegen to generate the skeletons, and we
use the generated FprintdDBusManager with composition, while we
implement the device skeleton interface in FprintDevice, so that we
don't have to use it as a proxy, and keep being closer to what it used
to be with dbus-glib.
Fixes: #61
2020-02-03 20:29:56 +01:00
|
|
|
if (!fprint_dbus_device_call_enroll_start_sync (dev, finger_name, NULL,
|
|
|
|
|
&error))
|
|
|
|
|
{
|
2009-12-09 13:15:57 +00:00
|
|
|
g_print ("EnrollStart failed: %s\n", error->message);
|
|
|
|
|
exit (1);
|
|
|
|
|
}
|
2020-12-03 23:55:48 +01:00
|
|
|
|
2008-03-06 16:37:19 +00:00
|
|
|
while (!enroll_completed)
|
|
|
|
|
g_main_context_iteration (NULL, TRUE);
|
2020-12-03 23:55:48 +01:00
|
|
|
|
fprintd: Use GDBus codegen based implementation
Fprintd is dependent on the deprecated dbus-glib, also this doesn't provide
various features we can take advantage of, like the ones for async
authentication mechanism.
So, remove all the dbus-glib dependencies and simplify the code, but without
any further refactor, and keeping everything as it used to work, while this
will give room for further improvements in subsequent commits.
Internally, we just use dbus-codegen to generate the skeletons, and we
use the generated FprintdDBusManager with composition, while we
implement the device skeleton interface in FprintDevice, so that we
don't have to use it as a proxy, and keep being closer to what it used
to be with dbus-glib.
Fixes: #61
2020-02-03 20:29:56 +01:00
|
|
|
g_signal_handlers_disconnect_by_func (dev, proxy_signal_cb, &enroll_result);
|
2020-12-03 23:55:48 +01:00
|
|
|
|
fprintd: Use GDBus codegen based implementation
Fprintd is dependent on the deprecated dbus-glib, also this doesn't provide
various features we can take advantage of, like the ones for async
authentication mechanism.
So, remove all the dbus-glib dependencies and simplify the code, but without
any further refactor, and keeping everything as it used to work, while this
will give room for further improvements in subsequent commits.
Internally, we just use dbus-codegen to generate the skeletons, and we
use the generated FprintdDBusManager with composition, while we
implement the device skeleton interface in FprintDevice, so that we
don't have to use it as a proxy, and keep being closer to what it used
to be with dbus-glib.
Fixes: #61
2020-02-03 20:29:56 +01:00
|
|
|
if (!fprint_dbus_device_call_enroll_stop_sync (dev, NULL, &error))
|
|
|
|
|
{
|
2009-12-09 13:15:57 +00:00
|
|
|
g_print ("VerifyStop failed: %s\n", error->message);
|
|
|
|
|
exit (1);
|
|
|
|
|
}
|
2008-03-06 16:37:19 +00:00
|
|
|
}
|
|
|
|
|
|
fprintd: Use GDBus codegen based implementation
Fprintd is dependent on the deprecated dbus-glib, also this doesn't provide
various features we can take advantage of, like the ones for async
authentication mechanism.
So, remove all the dbus-glib dependencies and simplify the code, but without
any further refactor, and keeping everything as it used to work, while this
will give room for further improvements in subsequent commits.
Internally, we just use dbus-codegen to generate the skeletons, and we
use the generated FprintdDBusManager with composition, while we
implement the device skeleton interface in FprintDevice, so that we
don't have to use it as a proxy, and keep being closer to what it used
to be with dbus-glib.
Fixes: #61
2020-02-03 20:29:56 +01:00
|
|
|
static void
|
|
|
|
|
release_device (FprintDBusDevice *dev)
|
2008-03-06 16:37:19 +00:00
|
|
|
{
|
2020-01-31 12:57:57 +01:00
|
|
|
g_autoptr(GError) error = NULL;
|
fprintd: Use GDBus codegen based implementation
Fprintd is dependent on the deprecated dbus-glib, also this doesn't provide
various features we can take advantage of, like the ones for async
authentication mechanism.
So, remove all the dbus-glib dependencies and simplify the code, but without
any further refactor, and keeping everything as it used to work, while this
will give room for further improvements in subsequent commits.
Internally, we just use dbus-codegen to generate the skeletons, and we
use the generated FprintdDBusManager with composition, while we
implement the device skeleton interface in FprintDevice, so that we
don't have to use it as a proxy, and keep being closer to what it used
to be with dbus-glib.
Fixes: #61
2020-02-03 20:29:56 +01:00
|
|
|
if (!fprint_dbus_device_call_release_sync (dev, NULL, &error))
|
|
|
|
|
{
|
2009-12-09 13:15:57 +00:00
|
|
|
g_print ("ReleaseDevice failed: %s\n", error->message);
|
|
|
|
|
exit (1);
|
|
|
|
|
}
|
2008-03-06 16:37:19 +00:00
|
|
|
}
|
|
|
|
|
|
2013-05-07 20:55:21 +04:00
|
|
|
static const GOptionEntry entries[] = {
|
|
|
|
|
{ "finger", 'f', 0, G_OPTION_ARG_STRING, &finger_name, "Finger selected to verify (default is automatic)", NULL },
|
|
|
|
|
{ G_OPTION_REMAINING, '\0', 0, G_OPTION_ARG_STRING_ARRAY, &usernames, NULL, "[username]" },
|
|
|
|
|
{ NULL }
|
|
|
|
|
};
|
|
|
|
|
|
2008-03-06 16:37:19 +00:00
|
|
|
int
|
|
|
|
|
main (int argc, char **argv)
|
|
|
|
|
{
|
fprintd: Use GDBus codegen based implementation
Fprintd is dependent on the deprecated dbus-glib, also this doesn't provide
various features we can take advantage of, like the ones for async
authentication mechanism.
So, remove all the dbus-glib dependencies and simplify the code, but without
any further refactor, and keeping everything as it used to work, while this
will give room for further improvements in subsequent commits.
Internally, we just use dbus-codegen to generate the skeletons, and we
use the generated FprintdDBusManager with composition, while we
implement the device skeleton interface in FprintDevice, so that we
don't have to use it as a proxy, and keep being closer to what it used
to be with dbus-glib.
Fixes: #61
2020-02-03 20:29:56 +01:00
|
|
|
g_autoptr(FprintDBusDevice) dev = NULL;
|
2013-05-07 20:55:21 +04:00
|
|
|
GOptionContext *context;
|
2008-03-06 16:37:19 +00:00
|
|
|
|
2019-12-04 11:58:28 +01:00
|
|
|
g_autoptr(GError) err = NULL;
|
|
|
|
|
|
2013-05-07 20:55:21 +04:00
|
|
|
setlocale (LC_ALL, "");
|
|
|
|
|
|
|
|
|
|
context = g_option_context_new ("Enroll a fingerprint");
|
|
|
|
|
g_option_context_add_main_entries (context, entries, NULL);
|
|
|
|
|
|
2020-01-27 19:24:36 +01:00
|
|
|
if (g_option_context_parse (context, &argc, &argv, &err) == FALSE)
|
2020-12-03 23:55:48 +01:00
|
|
|
{
|
2020-01-27 19:24:36 +01:00
|
|
|
g_print ("couldn't parse command-line options: %s\n", err->message);
|
2013-05-07 20:55:21 +04:00
|
|
|
return 1;
|
2020-12-03 23:55:48 +01:00
|
|
|
}
|
2020-01-27 19:24:36 +01:00
|
|
|
|
|
|
|
|
if (finger_name == NULL)
|
2008-03-06 16:37:19 +00:00
|
|
|
finger_name = g_strdup ("right-index-finger");
|
|
|
|
|
|
2020-01-27 19:24:36 +01:00
|
|
|
create_manager ();
|
2008-03-06 16:37:19 +00:00
|
|
|
|
fprintd: Use GDBus codegen based implementation
Fprintd is dependent on the deprecated dbus-glib, also this doesn't provide
various features we can take advantage of, like the ones for async
authentication mechanism.
So, remove all the dbus-glib dependencies and simplify the code, but without
any further refactor, and keeping everything as it used to work, while this
will give room for further improvements in subsequent commits.
Internally, we just use dbus-codegen to generate the skeletons, and we
use the generated FprintdDBusManager with composition, while we
implement the device skeleton interface in FprintDevice, so that we
don't have to use it as a proxy, and keep being closer to what it used
to be with dbus-glib.
Fixes: #61
2020-02-03 20:29:56 +01:00
|
|
|
dev = open_device (usernames ? usernames[0] : "");
|
2008-03-06 16:37:19 +00:00
|
|
|
do_enroll (dev);
|
|
|
|
|
release_device (dev);
|
2020-01-27 19:24:36 +01:00
|
|
|
g_free (finger_name);
|
2020-02-05 14:49:01 +01:00
|
|
|
g_strfreev (usernames);
|
2008-03-06 16:37:19 +00:00
|
|
|
return 0;
|
2020-12-03 23:55:48 +01:00
|
|
|
}
|