Commit 5426b1a4 authored by Bastien Nocera's avatar Bastien Nocera Committed by Daniel Drake

Use GetDefaultDevice

As we're not using the non-default device anyway.
parent e207203b
......@@ -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)
{
GError *error = NULL;
GPtrArray *devices;
gchar *path;
DBusGProxy *dev;
if (!dbus_g_proxy_call (manager, "GetDevices", &error,
G_TYPE_INVALID, dbus_g_type_get_collection ("GPtrArray", DBUS_TYPE_G_OBJECT_PATH),
&devices, G_TYPE_INVALID)) {
D(g_message("list_devices failed: %s", error->message));
if (!dbus_g_proxy_call (manager, "GetDefaultDevice", &error,
G_TYPE_INVALID, DBUS_TYPE_G_OBJECT_PATH,
&path, G_TYPE_INVALID)) {
D(g_message("get_default_devices failed: %s", error->message));
g_error_free (error);
return NULL;
}
if (devices->len == 0) {
if (path == NULL) {
D(g_message("No devices found\n"));
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));
dev = dbus_g_proxy_new_for_name(connection,
......@@ -213,8 +210,7 @@ static DBusGProxy *open_device(DBusGConnection *connection, DBusGProxy *manager,
path,
"net.reactivated.Fprint.Device");
g_ptr_array_foreach(devices, (GFunc) g_free, NULL);
g_ptr_array_free(devices, TRUE);
g_free (path);
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));
......
......@@ -73,34 +73,24 @@ static void create_manager(void)
static DBusGProxy *open_device(const char *username)
{
GError *error = NULL;
GPtrArray *devices;
gchar *path;
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);
if (devices->len == 0) {
if (path == NULL) {
g_print("No devices found\n");
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);
/* FIXME use for_name_owner?? */
dev = dbus_g_proxy_new_for_name(connection, "net.reactivated.Fprint",
path, "net.reactivated.Fprint.Device");
g_ptr_array_foreach(devices, (GFunc) g_free, NULL);
g_ptr_array_free(devices, TRUE);
g_free (path);
if (!net_reactivated_Fprint_Device_claim(dev, username, &error))
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)
{
GError *error = NULL;
GPtrArray *devices;
gchar *path;
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);
if (devices->len == 0) {
if (path == NULL) {
g_print("No devices found\n");
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);
/* FIXME use for_name_owner?? */
dev = dbus_g_proxy_new_for_name(connection, "net.reactivated.Fprint",
path, "net.reactivated.Fprint.Device");
g_ptr_array_foreach(devices, (GFunc) g_free, NULL);
g_ptr_array_free(devices, TRUE);
g_free (path);
if (!net_reactivated_Fprint_Device_claim(dev, username, &error))
g_error("failed to claim device: %s", error->message);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment