View | Details | Raw Unified | Return to bug 463557
Collapse All | Expand All

(-)configure.ac (+15 lines)
Lines 917-922 if test "x$have_libnotify" = "xyes"; the Link Here
917
fi
917
fi
918
918
919
dnl ---------------------------------------------------------------------------
919
dnl ---------------------------------------------------------------------------
920
dnl libfprint
921
dnl ---------------------------------------------------------------------------
922
923
have_libfprint=yes
924
AC_ARG_WITH(libfprint,[  --without-libfprint         disable finger print support])
925
if test x$with_libfprint != xno; then
926
	PKG_CHECK_MODULES(LIBFPRINT, libfprint, have_libfprint=yes, have_libfprint=no)
927
fi
928
if test "x$have_libfprint" = "xyes"; then
929
  AC_SUBST(LIBFPRINT_CFLAGS)
930
  AC_SUBST(LIBFPRINT_LIBS)
931
  AC_DEFINE(WITH_LIBFPRINT, 1, [Define for finger print support])
932
fi
933
934
dnl ---------------------------------------------------------------------------
920
dnl Finish
935
dnl Finish
921
dnl ---------------------------------------------------------------------------
936
dnl ---------------------------------------------------------------------------
922
937
(-)src/gnome-screensaver-dialog.c (-1 / +199 lines)
Lines 30-35 Link Here
30
#include <sys/wait.h>
30
#include <sys/wait.h>
31
#include <unistd.h>
31
#include <unistd.h>
32
32
33
#ifdef WITH_LIBFPRINT
34
#include <pthread.h>
35
#include <signal.h>
36
#include <libfprint/fprint.h>
37
#endif
33
#include <glib/gi18n.h>
38
#include <glib/gi18n.h>
34
#include <gdk/gdkx.h>
39
#include <gdk/gdkx.h>
35
#include <gtk/gtk.h>
40
#include <gtk/gtk.h>
Lines 66-71 static GOptionEntry entries [] = { Link Here
66
        { NULL }
71
        { NULL }
67
};
72
};
68
73
74
#ifdef WITH_LIBFPRINT
75
static struct fp_dscv_dev *fp_ddev, **fp_discovered_devs;
76
static struct fp_dev *fp_dev;
77
static struct fp_print_data *fp_data;
78
#endif
79
69
static char *
80
static char *
70
get_id_string (GtkWidget *widget)
81
get_id_string (GtkWidget *widget)
71
{
82
{
Lines 333-350 response_cb (GSLockPlug *plug, Link Here
333
        }
344
        }
334
}
345
}
335
346
347
#ifdef WITH_LIBFPRINT
348
typedef struct {
349
        gchar *message;
350
        GSLockPlug *plug;
351
} AuthMessageHandlerIdleData;
352
353
static gboolean
354
auth_message_handler_idle_cb (AuthMessageHandlerIdleData *idle_data)
355
{
356
        char *response;
357
358
        auth_message_handler (GS_AUTH_MESSAGE_TEXT_INFO,
359
                              idle_data->message,
360
                              &response,
361
                              idle_data->plug);
362
363
        g_free (idle_data->message);
364
        g_free (idle_data);
365
366
        return FALSE;
367
}
368
369
static void
370
auth_message_handler_idle (const gchar *message, GSLockPlug *plug)
371
{
372
        AuthMessageHandlerIdleData *idle_data;
373
374
        idle_data = g_new0 (AuthMessageHandlerIdleData, 1);
375
        idle_data->message = g_strdup (message);
376
        idle_data->plug = plug;
377
378
        g_idle_add ((GSourceFunc) auth_message_handler_idle_cb, idle_data);
379
}
380
381
static struct fp_dscv_dev
382
*discover_fingerprint_device (struct fp_dscv_dev **discovered_devs)
383
{
384
        struct fp_dscv_dev *ddev = discovered_devs[0];
385
	struct fp_driver *drv;
386
	if (!ddev)
387
		return NULL;
388
389
	drv = fp_dscv_dev_get_driver (ddev);
390
	g_debug ("Found device claimed by %s driver\n", fp_driver_get_full_name (drv));
391
392
	return ddev;
393
}
394
395
static int
396
fprint_init (void)
397
{
398
        if (fp_init () < 0)
399
		return -1;
400
401
	fp_data = NULL;
402
	fp_discovered_devs = fp_discover_devs ();
403
	if (fp_discovered_devs) {
404
		fp_ddev = discover_fingerprint_device (fp_discovered_devs);
405
		if (fp_ddev) {
406
			fp_dev = fp_dev_open (fp_ddev);
407
			if (fp_dev) {
408
				if (fp_print_data_load (fp_dev, RIGHT_INDEX, &fp_data) == 0) {
409
				} else {
410
					g_debug ("Failed to load fingerprint");
411
					g_debug ("Did you remember to enroll your right index finger first?");
412
				}
413
			} else
414
				g_debug ("Could not open fingerprint device");
415
		} else
416
			g_debug ("No fingerprint devices detected");
417
418
		fp_dscv_devs_free (fp_discovered_devs);
419
	} else
420
		g_debug ("Could not discover fingerprint devices");
421
	return 0;
422
}
423
424
static void
425
fprint_deinit (void)
426
{
427
        if (fp_data) {
428
                fp_print_data_free (fp_data);
429
                fp_data = NULL;
430
        }
431
432
        if (fp_dev) {
433
                fp_dev_close (fp_dev);
434
                fp_dev = NULL;
435
        }
436
}
437
438
static void
439
fprint_reset (void)
440
{
441
	fprint_deinit ();
442
	fprint_init ();
443
	if (fp_dev)
444
		fp_dev_reset(fp_dev);
445
446
	fprint_deinit ();
447
}
448
449
450
451
static gpointer
452
fprint_thread_func (gpointer user_data)
453
{
454
        GSLockPlug *plug = (GSLockPlug *) user_data;
455
456
        if (fp_dev && fp_data) {
457
                gboolean result = FALSE;
458
                gboolean retry;
459
                struct fp_img *img = NULL;
460
461
                auth_message_handler_idle (_("Please enter password or swipe your finger"), plug);
462
463
                do {
464
                        int r;
465
466
                        retry = FALSE;
467
468
                        r = fp_verify_finger_img (fp_dev, fp_data, &img);
469
                        fp_img_free (img);
470
471
                        switch (r) {
472
                        case FP_VERIFY_NO_MATCH :
473
                                retry = TRUE;
474
                                break;
475
                        case FP_VERIFY_MATCH :
476
                                result = TRUE;
477
                                break;
478
                        case FP_VERIFY_RETRY :
479
                                retry = TRUE;
480
                                auth_message_handler_idle (_("Scan didn't quite work. Please try again"),
481
                                                           plug);
482
                                break;
483
                        case FP_VERIFY_RETRY_TOO_SHORT :
484
                                retry = TRUE;
485
                                auth_message_handler_idle (_("Swipe was too short. Please try again"),
486
                                                           plug);
487
                                break;
488
                        case FP_VERIFY_RETRY_CENTER_FINGER :
489
                                retry = TRUE;
490
                                auth_message_handler_idle (_("Please center your finger on the sensor and try again"),
491
                                                           plug);
492
                                break;
493
                        case FP_VERIFY_RETRY_REMOVE_FINGER :
494
                                retry = TRUE;
495
                                auth_message_handler_idle (_("Please remove finger from the sensor and try again"),
496
                                                           plug);
497
                                break;
498
                        default :
499
                                retry = TRUE;
500
                                g_debug ("Finger print verification failed with error: %d", r);
501
                                break;
502
                        }
503
                } while (retry);
504
505
                if (result) {
506
                        fprint_deinit ();
507
                        g_idle_add ((GSourceFunc) quit_response_ok, NULL);
508
                }
509
        }
510
511
        return NULL;
512
}
513
#endif
514
336
static gboolean
515
static gboolean
337
auth_check_idle (GSLockPlug *plug)
516
auth_check_idle (GSLockPlug *plug)
338
{
517
{
339
        gboolean     res;
518
        gboolean     res;
340
        gboolean     again;
519
        gboolean     again;
341
        static guint loop_counter = 0;
520
        static guint loop_counter = 0;
521
#ifdef WITH_LIBFPRINT
522
        static pthread_t fprint_thread = -1;
523
524
        if (fp_dev && fp_data && fprint_thread == -1) {
525
                if (pthread_create (&fprint_thread, NULL, fprint_thread_func, plug)) {
526
                        gs_debug ("Thread creation for finger print auth failed");
527
                }
528
        }
529
#endif
342
530
343
        again = TRUE;
531
        again = TRUE;
344
        res = do_auth_check (plug);
532
        res = do_auth_check (plug);
345
533
346
        if (res) {
534
        if (res) {
347
                again = FALSE;
535
                again = FALSE;
536
#ifdef WITH_LIBFPRINT
537
                /* we received a password, reset fingerprint reader device */
538
                fprint_reset();
539
#endif
348
                g_idle_add ((GSourceFunc)quit_response_ok, NULL);
540
                g_idle_add ((GSourceFunc)quit_response_ok, NULL);
349
        } else {
541
        } else {
350
                loop_counter++;
542
                loop_counter++;
Lines 548-553 main (int argc, Link Here
548
                g_thread_init (NULL);
740
                g_thread_init (NULL);
549
        }
741
        }
550
742
743
#ifdef WITH_LIBFPRINT
744
        /* Initialize fprint for fingerprint reading for authentication */
745
       if (fprint_init() < 0)
746
                g_debug ("Failed to initialize libfprint");
747
#endif
748
551
        g_type_init ();
749
        g_type_init ();
552
750
553
        gs_profile_start (NULL);
751
        gs_profile_start (NULL);
Lines 560-566 main (int argc, Link Here
560
        error = NULL;
758
        error = NULL;
561
        if (! gtk_init_with_args (&argc, &argv, NULL, entries, NULL, &error)) {
759
        if (! gtk_init_with_args (&argc, &argv, NULL, entries, NULL, &error)) {
562
                if (error != NULL) {
760
                if (error != NULL) {
563
                        fprintf (stderr, "%s", error->message);
761
                        g_debug ("%s", error->message);
564
                        g_error_free (error);
762
                        g_error_free (error);
565
                }
763
                }
566
                exit (1);
764
                exit (1);
(-)src/Makefile.am (+2 lines)
Lines 31-36 INCLUDES = \ Link Here
31
	$(DBUS_CFLAGS)						\
31
	$(DBUS_CFLAGS)						\
32
	$(LIBGNOMEKBDUI_CFLAGS)					\
32
	$(LIBGNOMEKBDUI_CFLAGS)					\
33
	$(LIBNOTIFY_CFLAGS)					\
33
	$(LIBNOTIFY_CFLAGS)					\
34
	$(LIBFPRINT_CFLAGS)					\
34
	$(NULL)
35
	$(NULL)
35
36
36
bin_PROGRAMS = \
37
bin_PROGRAMS = \
Lines 150-155 gnome_screensaver_dialog_LDADD = \ Link Here
150
	$(AUTH_LIBS)			\
151
	$(AUTH_LIBS)			\
151
	$(LIBGNOMEKBDUI_LIBS)		\
152
	$(LIBGNOMEKBDUI_LIBS)		\
152
	$(LIBNOTIFY_LIBS)		\
153
	$(LIBNOTIFY_LIBS)		\
154
	$(LIBFPRINT_LIBS)		\
153
	$(NULL)
155
	$(NULL)
154
156
155
BUILT_SOURCES = 		\
157
BUILT_SOURCES = 		\

Return to bug 463557