mirror of
https://gitlab.com/mishakmak/pam-fprint-grosshack.git
synced 2026-04-09 04:13:33 +02:00
Use GetDefaultDevice
As we're not using the non-default device anyway.
This commit is contained in:
committed by
Daniel Drake
parent
e207203b44
commit
5426b1a472
@ -187,25 +187,22 @@ static DBusGProxy *create_manager (DBusGConnection **ret_conn, GMainLoop **ret_l
|
|||||||
static DBusGProxy *open_device(DBusGConnection *connection, DBusGProxy *manager, const char *username)
|
static DBusGProxy *open_device(DBusGConnection *connection, DBusGProxy *manager, const char *username)
|
||||||
{
|
{
|
||||||
GError *error = NULL;
|
GError *error = NULL;
|
||||||
GPtrArray *devices;
|
|
||||||
gchar *path;
|
gchar *path;
|
||||||
DBusGProxy *dev;
|
DBusGProxy *dev;
|
||||||
|
|
||||||
if (!dbus_g_proxy_call (manager, "GetDevices", &error,
|
if (!dbus_g_proxy_call (manager, "GetDefaultDevice", &error,
|
||||||
G_TYPE_INVALID, dbus_g_type_get_collection ("GPtrArray", DBUS_TYPE_G_OBJECT_PATH),
|
G_TYPE_INVALID, DBUS_TYPE_G_OBJECT_PATH,
|
||||||
&devices, G_TYPE_INVALID)) {
|
&path, G_TYPE_INVALID)) {
|
||||||
D(g_message("list_devices failed: %s", error->message));
|
D(g_message("get_default_devices failed: %s", error->message));
|
||||||
g_error_free (error);
|
g_error_free (error);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (devices->len == 0) {
|
if (path == NULL) {
|
||||||
D(g_message("No devices found\n"));
|
D(g_message("No devices found\n"));
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
D(g_message("found %d devices\n", devices->len));
|
|
||||||
path = g_ptr_array_index(devices, 0);
|
|
||||||
D(g_message("Using device %s\n", path));
|
D(g_message("Using device %s\n", path));
|
||||||
|
|
||||||
dev = dbus_g_proxy_new_for_name(connection,
|
dev = dbus_g_proxy_new_for_name(connection,
|
||||||
@ -213,8 +210,7 @@ static DBusGProxy *open_device(DBusGConnection *connection, DBusGProxy *manager,
|
|||||||
path,
|
path,
|
||||||
"net.reactivated.Fprint.Device");
|
"net.reactivated.Fprint.Device");
|
||||||
|
|
||||||
g_ptr_array_foreach(devices, (GFunc) g_free, NULL);
|
g_free (path);
|
||||||
g_ptr_array_free(devices, TRUE);
|
|
||||||
|
|
||||||
if (!dbus_g_proxy_call (dev, "Claim", &error, G_TYPE_STRING, username, G_TYPE_INVALID, G_TYPE_INVALID)) {
|
if (!dbus_g_proxy_call (dev, "Claim", &error, G_TYPE_STRING, username, G_TYPE_INVALID, G_TYPE_INVALID)) {
|
||||||
D(g_message("failed to claim device: %s\n", error->message));
|
D(g_message("failed to claim device: %s\n", error->message));
|
||||||
|
|||||||
@ -73,34 +73,24 @@ static void create_manager(void)
|
|||||||
static DBusGProxy *open_device(const char *username)
|
static DBusGProxy *open_device(const char *username)
|
||||||
{
|
{
|
||||||
GError *error = NULL;
|
GError *error = NULL;
|
||||||
GPtrArray *devices;
|
|
||||||
gchar *path;
|
gchar *path;
|
||||||
DBusGProxy *dev;
|
DBusGProxy *dev;
|
||||||
guint i;
|
|
||||||
|
|
||||||
if (!net_reactivated_Fprint_Manager_get_devices(manager, &devices, &error))
|
if (!net_reactivated_Fprint_Manager_get_default_device(manager, &path, &error))
|
||||||
g_error("list_devices failed: %s", error->message);
|
g_error("list_devices failed: %s", error->message);
|
||||||
|
|
||||||
if (devices->len == 0) {
|
if (path == NULL) {
|
||||||
g_print("No devices found\n");
|
g_print("No devices found\n");
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
g_print("found %d devices\n", devices->len);
|
|
||||||
for (i = 0; i < devices->len; i++) {
|
|
||||||
path = g_ptr_array_index(devices, i);
|
|
||||||
g_print("Device at %s\n", path);
|
|
||||||
}
|
|
||||||
|
|
||||||
path = g_ptr_array_index(devices, 0);
|
|
||||||
g_print("Using device %s\n", path);
|
g_print("Using device %s\n", path);
|
||||||
|
|
||||||
/* FIXME use for_name_owner?? */
|
/* FIXME use for_name_owner?? */
|
||||||
dev = dbus_g_proxy_new_for_name(connection, "net.reactivated.Fprint",
|
dev = dbus_g_proxy_new_for_name(connection, "net.reactivated.Fprint",
|
||||||
path, "net.reactivated.Fprint.Device");
|
path, "net.reactivated.Fprint.Device");
|
||||||
|
|
||||||
g_ptr_array_foreach(devices, (GFunc) g_free, NULL);
|
g_free (path);
|
||||||
g_ptr_array_free(devices, TRUE);
|
|
||||||
|
|
||||||
if (!net_reactivated_Fprint_Device_claim(dev, username, &error))
|
if (!net_reactivated_Fprint_Device_claim(dev, username, &error))
|
||||||
g_error("failed to claim device: %s", error->message);
|
g_error("failed to claim device: %s", error->message);
|
||||||
|
|||||||
@ -75,34 +75,24 @@ static void create_manager(void)
|
|||||||
static DBusGProxy *open_device(const char *username)
|
static DBusGProxy *open_device(const char *username)
|
||||||
{
|
{
|
||||||
GError *error = NULL;
|
GError *error = NULL;
|
||||||
GPtrArray *devices;
|
|
||||||
gchar *path;
|
gchar *path;
|
||||||
DBusGProxy *dev;
|
DBusGProxy *dev;
|
||||||
guint i;
|
|
||||||
|
|
||||||
if (!net_reactivated_Fprint_Manager_get_devices(manager, &devices, &error))
|
if (!net_reactivated_Fprint_Manager_get_default_device(manager, &path, &error))
|
||||||
g_error("list_devices failed: %s", error->message);
|
g_error("list_devices failed: %s", error->message);
|
||||||
|
|
||||||
if (devices->len == 0) {
|
if (path == NULL) {
|
||||||
g_print("No devices found\n");
|
g_print("No devices found\n");
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
g_print("found %d devices\n", devices->len);
|
|
||||||
for (i = 0; i < devices->len; i++) {
|
|
||||||
path = g_ptr_array_index(devices, i);
|
|
||||||
g_print("Device at %s\n", path);
|
|
||||||
}
|
|
||||||
|
|
||||||
path = g_ptr_array_index(devices, 0);
|
|
||||||
g_print("Using device %s\n", path);
|
g_print("Using device %s\n", path);
|
||||||
|
|
||||||
/* FIXME use for_name_owner?? */
|
/* FIXME use for_name_owner?? */
|
||||||
dev = dbus_g_proxy_new_for_name(connection, "net.reactivated.Fprint",
|
dev = dbus_g_proxy_new_for_name(connection, "net.reactivated.Fprint",
|
||||||
path, "net.reactivated.Fprint.Device");
|
path, "net.reactivated.Fprint.Device");
|
||||||
|
|
||||||
g_ptr_array_foreach(devices, (GFunc) g_free, NULL);
|
g_free (path);
|
||||||
g_ptr_array_free(devices, TRUE);
|
|
||||||
|
|
||||||
if (!net_reactivated_Fprint_Device_claim(dev, username, &error))
|
if (!net_reactivated_Fprint_Device_claim(dev, username, &error))
|
||||||
g_error("failed to claim device: %s", error->message);
|
g_error("failed to claim device: %s", error->message);
|
||||||
|
|||||||
Reference in New Issue
Block a user