diff --git a/demo/gtk-libfprint-test.c b/demo/gtk-libfprint-test.c index 9ef8768..6850063 100644 --- a/demo/gtk-libfprint-test.c +++ b/demo/gtk-libfprint-test.c @@ -526,7 +526,7 @@ libfprint_demo_window_init (LibfprintDemoWindow *window) return; } - if (!fp_device_supports_capture (g_ptr_array_index (devices, 0))) + if (!fp_device_has_feature (g_ptr_array_index (devices, 0), FP_DEVICE_FEATURE_CAPTURE)) { libfprint_demo_set_mode (window, NOIMAGING_MODE); return; diff --git a/examples/enroll.c b/examples/enroll.c index e85fd60..f133c8b 100644 --- a/examples/enroll.c +++ b/examples/enroll.c @@ -76,7 +76,7 @@ on_enroll_completed (FpDevice *dev, GAsyncResult *res, void *user_data) { enroll_data->ret_value = EXIT_SUCCESS; - if (fp_device_has_storage (dev)) + if (fp_device_has_feature (dev, FP_DEVICE_FEATURE_STORAGE)) g_debug ("Device has storage, saving a print reference locally"); else g_debug ("Device has not storage, saving print only locally"); diff --git a/examples/identify.c b/examples/identify.c index 9ad0e66..bc2fe00 100644 --- a/examples/identify.c +++ b/examples/identify.c @@ -212,7 +212,7 @@ on_list_completed (FpDevice *dev, GAsyncResult *res, gpointer user_data) static void start_identification (FpDevice *dev, IdentifyData *identify_data) { - if (fp_device_has_storage (dev)) + if (fp_device_has_feature (dev, FP_DEVICE_FEATURE_STORAGE)) { g_print ("Creating finger template, using device storage...\n"); fp_device_list_prints (dev, NULL, @@ -293,7 +293,7 @@ main (void) return EXIT_FAILURE; } - if (!fp_device_supports_identify (dev)) + if (!fp_device_has_feature (dev, FP_DEVICE_FEATURE_IDENTIFY)) { g_warning ("Device %s does not support identification.", fp_device_get_name (dev)); diff --git a/examples/img-capture.c b/examples/img-capture.c index ff499c5..f032d8e 100644 --- a/examples/img-capture.c +++ b/examples/img-capture.c @@ -162,7 +162,7 @@ main (int argc, const char *argv[]) return EXIT_FAILURE; } - if (!fp_device_supports_capture (dev)) + if (!fp_device_has_feature (dev, FP_DEVICE_FEATURE_CAPTURE)) { g_warning ("Device %s doesn't support capture", fp_device_get_name (dev)); diff --git a/examples/manage-prints.c b/examples/manage-prints.c index 8f49e5f..4d206cc 100644 --- a/examples/manage-prints.c +++ b/examples/manage-prints.c @@ -231,7 +231,7 @@ on_device_opened (FpDevice *dev, return; } - if (!fp_device_has_storage (dev)) + if (!fp_device_has_feature (dev, FP_DEVICE_FEATURE_STORAGE)) { g_warning ("Device %s doesn't support storage", fp_device_get_name (dev)); g_main_loop_quit (list_data->loop); diff --git a/examples/verify.c b/examples/verify.c index 494d63e..4b16323 100644 --- a/examples/verify.c +++ b/examples/verify.c @@ -260,7 +260,7 @@ start_verification (FpDevice *dev, VerifyData *verify_data) return; } - if (fp_device_has_storage (dev)) + if (fp_device_has_feature (dev, FP_DEVICE_FEATURE_STORAGE)) { g_print ("Creating finger template, using device storage...\n"); fp_device_list_prints (dev, NULL, diff --git a/libfprint/fp-device.c b/libfprint/fp-device.c index 5027e03..a0f2172 100644 --- a/libfprint/fp-device.c +++ b/libfprint/fp-device.c @@ -621,6 +621,7 @@ fp_device_get_nr_enroll_stages (FpDevice *device) * Check whether the device supports identification. * * Returns: Whether the device supports identification + * Deprecated: 1.92.0: Use fp_device_has_feature() instead. */ gboolean fp_device_supports_identify (FpDevice *device) @@ -639,6 +640,7 @@ fp_device_supports_identify (FpDevice *device) * Check whether the device supports capturing images. * * Returns: Whether the device supports image capture + * Deprecated: 1.92.0: Use fp_device_has_feature() instead. */ gboolean fp_device_supports_capture (FpDevice *device) @@ -658,6 +660,7 @@ fp_device_supports_capture (FpDevice *device) * prints stored on the with fp_device_list_prints() and you should * always delete prints from the device again using * fp_device_delete_print(). + * Deprecated: 1.92.0: Use fp_device_has_feature() instead. */ gboolean fp_device_has_storage (FpDevice *device) @@ -1073,6 +1076,7 @@ fp_device_identify (FpDevice *device, { g_autoptr(GTask) task = NULL; FpDevicePrivate *priv = fp_device_get_instance_private (device); + FpDeviceClass *cls = FP_DEVICE_GET_CLASS (device); FpMatchData *data; int i; @@ -1094,7 +1098,7 @@ fp_device_identify (FpDevice *device, return; } - if (!fp_device_supports_identify (device)) + if (!cls->identify || !(cls->features & FP_DEVICE_FEATURE_IDENTIFY)) { g_task_return_error (task, fpi_device_error_new_msg (FP_DEVICE_ERROR_NOT_SUPPORTED, @@ -1121,7 +1125,7 @@ fp_device_identify (FpDevice *device, // Attach the match data as task data so that it is destroyed g_task_set_task_data (priv->current_task, data, (GDestroyNotify) match_data_free); - FP_DEVICE_GET_CLASS (device)->identify (device); + cls->identify (device); } /** @@ -1352,6 +1356,7 @@ fp_device_list_prints (FpDevice *device, { g_autoptr(GTask) task = NULL; FpDevicePrivate *priv = fp_device_get_instance_private (device); + FpDeviceClass *cls = FP_DEVICE_GET_CLASS (device); task = g_task_new (device, cancellable, callback, user_data); if (g_task_return_error_if_cancelled (task)) @@ -1371,7 +1376,7 @@ fp_device_list_prints (FpDevice *device, return; } - if (!fp_device_has_storage (device)) + if (!cls->list || !(cls->features & FP_DEVICE_FEATURE_STORAGE)) { g_task_return_error (task, fpi_device_error_new_msg (FP_DEVICE_ERROR_NOT_SUPPORTED, @@ -1383,7 +1388,7 @@ fp_device_list_prints (FpDevice *device, priv->current_task = g_steal_pointer (&task); maybe_cancel_on_cancelled (device, cancellable); - FP_DEVICE_GET_CLASS (device)->list (device); + cls->list (device); } /** diff --git a/libfprint/fp-device.h b/libfprint/fp-device.h index 2b35894..603ffdc 100644 --- a/libfprint/fp-device.h +++ b/libfprint/fp-device.h @@ -206,10 +206,6 @@ FpDeviceFeature fp_device_get_features (FpDevice *device); gboolean fp_device_has_feature (FpDevice *device, FpDeviceFeature feature); -gboolean fp_device_supports_identify (FpDevice *device); -gboolean fp_device_supports_capture (FpDevice *device); -gboolean fp_device_has_storage (FpDevice *device); - /* Opening the device */ void fp_device_open (FpDevice *device, GCancellable *cancellable, @@ -335,5 +331,12 @@ GPtrArray * fp_device_list_prints_sync (FpDevice *device, GCancellable *cancellable, GError **error); +/* Deprecated functions */ +G_DEPRECATED_FOR (fp_device_get_features) +gboolean fp_device_supports_identify (FpDevice *device); +G_DEPRECATED_FOR (fp_device_get_features) +gboolean fp_device_supports_capture (FpDevice *device); +G_DEPRECATED_FOR (fp_device_get_features) +gboolean fp_device_has_storage (FpDevice *device); G_END_DECLS diff --git a/scripts/uncrustify.cfg b/scripts/uncrustify.cfg index c1fb82e..1dbd3ba 100644 --- a/scripts/uncrustify.cfg +++ b/scripts/uncrustify.cfg @@ -137,3 +137,7 @@ pos_conditional Trail # custom keywords set FOR udev_list_entry_foreach + +# macros +macro-open G_GNUC_BEGIN_IGNORE_DEPRECATIONS +macro-close G_GNUC_END_IGNORE_DEPRECATIONS diff --git a/tests/test-fp-device.c b/tests/test-fp-device.c index a473092..a633eb9 100644 --- a/tests/test-fp-device.c +++ b/tests/test-fp-device.c @@ -203,7 +203,9 @@ test_device_supports_identify (void) fp_device_open_sync (tctx->device, NULL, NULL); g_assert_true (fp_device_has_feature (tctx->device, FP_DEVICE_FEATURE_IDENTIFY)); - g_assert_true (fp_device_supports_identify (tctx->device)); + G_GNUC_BEGIN_IGNORE_DEPRECATIONS + g_assert_true (fp_device_supports_identify (tctx->device)); + G_GNUC_END_IGNORE_DEPRECATIONS } static void @@ -213,7 +215,9 @@ test_device_supports_capture (void) fp_device_open_sync (tctx->device, NULL, NULL); g_assert_true (fp_device_has_feature (tctx->device, FP_DEVICE_FEATURE_CAPTURE)); - g_assert_true (fp_device_supports_capture (tctx->device)); + G_GNUC_BEGIN_IGNORE_DEPRECATIONS + g_assert_true (fp_device_supports_capture (tctx->device)); + G_GNUC_END_IGNORE_DEPRECATIONS } static void @@ -223,7 +227,9 @@ test_device_has_storage (void) fp_device_open_sync (tctx->device, NULL, NULL); g_assert_false (fp_device_has_feature (tctx->device, FP_DEVICE_FEATURE_STORAGE)); - g_assert_false (fp_device_has_storage (tctx->device)); + G_GNUC_BEGIN_IGNORE_DEPRECATIONS + g_assert_false (fp_device_has_storage (tctx->device)); + G_GNUC_END_IGNORE_DEPRECATIONS } int diff --git a/tests/test-fpi-device.c b/tests/test-fpi-device.c index 5a5ee96..8bb51f2 100644 --- a/tests/test-fpi-device.c +++ b/tests/test-fpi-device.c @@ -1588,7 +1588,9 @@ test_driver_supports_identify (void) dev_class->identify = fake_device_stub_identify; device = g_object_new (FPI_TYPE_DEVICE_FAKE, NULL); - g_assert_true (fp_device_supports_identify (device)); + G_GNUC_BEGIN_IGNORE_DEPRECATIONS + g_assert_true (fp_device_supports_identify (device)); + G_GNUC_END_IGNORE_DEPRECATIONS g_assert_true (fp_device_has_feature (device, FP_DEVICE_FEATURE_IDENTIFY)); } @@ -1601,7 +1603,9 @@ test_driver_do_not_support_identify (void) dev_class->features &= ~FP_DEVICE_FEATURE_IDENTIFY; device = g_object_new (FPI_TYPE_DEVICE_FAKE, NULL); - g_assert_false (fp_device_supports_identify (device)); + G_GNUC_BEGIN_IGNORE_DEPRECATIONS + g_assert_false (fp_device_supports_identify (device)); + G_GNUC_END_IGNORE_DEPRECATIONS g_assert_false (fp_device_has_feature (device, FP_DEVICE_FEATURE_IDENTIFY)); } @@ -1621,7 +1625,9 @@ test_driver_identify (void) expected_matched = g_ptr_array_index (prints, g_random_int_range (0, 499)); fp_print_set_description (expected_matched, "fake-verified"); - g_assert_true (fp_device_supports_identify (device)); + G_GNUC_BEGIN_IGNORE_DEPRECATIONS + g_assert_true (fp_device_supports_identify (device)); + G_GNUC_END_IGNORE_DEPRECATIONS g_assert_true (fp_device_has_feature (device, FP_DEVICE_FEATURE_IDENTIFY)); match_data->gallery = prints; @@ -1655,7 +1661,9 @@ test_driver_identify_fail (void) FpDeviceClass *dev_class = FP_DEVICE_GET_CLASS (device); FpiDeviceFake *fake_dev = FPI_DEVICE_FAKE (device); - g_assert_true (fp_device_supports_identify (device)); + G_GNUC_BEGIN_IGNORE_DEPRECATIONS + g_assert_true (fp_device_supports_identify (device)); + G_GNUC_END_IGNORE_DEPRECATIONS g_assert_true (fp_device_has_feature (device, FP_DEVICE_FEATURE_IDENTIFY)); fake_dev->ret_print = make_fake_print (device, NULL); @@ -1692,7 +1700,9 @@ test_driver_identify_retry (void) expected_matched = g_ptr_array_index (prints, g_random_int_range (0, 499)); fp_print_set_description (expected_matched, "fake-verified"); - g_assert_true (fp_device_supports_identify (device)); + G_GNUC_BEGIN_IGNORE_DEPRECATIONS + g_assert_true (fp_device_supports_identify (device)); + G_GNUC_END_IGNORE_DEPRECATIONS g_assert_true (fp_device_has_feature (device, FP_DEVICE_FEATURE_IDENTIFY)); fake_dev->ret_error = fpi_device_retry_new (FP_DEVICE_RETRY_GENERAL); @@ -1727,7 +1737,9 @@ test_driver_identify_error (void) expected_matched = g_ptr_array_index (prints, g_random_int_range (0, 499)); fp_print_set_description (expected_matched, "fake-verified"); - g_assert_true (fp_device_supports_identify (device)); + G_GNUC_BEGIN_IGNORE_DEPRECATIONS + g_assert_true (fp_device_supports_identify (device)); + G_GNUC_END_IGNORE_DEPRECATIONS g_assert_true (fp_device_has_feature (device, FP_DEVICE_FEATURE_IDENTIFY)); fake_dev->ret_error = fpi_device_error_new (FP_DEVICE_ERROR_GENERAL); @@ -1935,7 +1947,9 @@ test_driver_supports_capture (void) dev_class->capture = fake_device_stub_capture; device = g_object_new (FPI_TYPE_DEVICE_FAKE, NULL); - g_assert_true (fp_device_supports_capture (device)); + G_GNUC_BEGIN_IGNORE_DEPRECATIONS + g_assert_true (fp_device_supports_capture (device)); + G_GNUC_END_IGNORE_DEPRECATIONS g_assert_true (fp_device_has_feature (device, FP_DEVICE_FEATURE_CAPTURE)); } @@ -1949,7 +1963,9 @@ test_driver_do_not_support_capture (void) dev_class->capture = NULL; device = g_object_new (FPI_TYPE_DEVICE_FAKE, NULL); - g_assert_false (fp_device_supports_capture (device)); + G_GNUC_BEGIN_IGNORE_DEPRECATIONS + g_assert_false (fp_device_supports_capture (device)); + G_GNUC_END_IGNORE_DEPRECATIONS g_assert_false (fp_device_has_feature (device, FP_DEVICE_FEATURE_CAPTURE)); } @@ -2023,7 +2039,9 @@ test_driver_has_storage (void) dev_class->features |= FP_DEVICE_FEATURE_STORAGE; device = g_object_new (FPI_TYPE_DEVICE_FAKE, NULL); - g_assert_true (fp_device_has_storage (device)); + G_GNUC_BEGIN_IGNORE_DEPRECATIONS + g_assert_true (fp_device_has_storage (device)); + G_GNUC_END_IGNORE_DEPRECATIONS g_assert_true (fp_device_has_feature (device, FP_DEVICE_FEATURE_STORAGE)); } @@ -2036,7 +2054,9 @@ test_driver_has_not_storage (void) dev_class->features &= ~FP_DEVICE_FEATURE_STORAGE; device = g_object_new (FPI_TYPE_DEVICE_FAKE, NULL); - g_assert_false (fp_device_has_storage (device)); + G_GNUC_BEGIN_IGNORE_DEPRECATIONS + g_assert_false (fp_device_has_storage (device)); + G_GNUC_END_IGNORE_DEPRECATIONS g_assert_false (fp_device_has_feature (device, FP_DEVICE_FEATURE_STORAGE)); } @@ -2089,7 +2109,9 @@ test_driver_list_no_storage (void) dev_class->features &= ~FP_DEVICE_FEATURE_STORAGE; device = auto_close_fake_device_new (); - g_assert_false (fp_device_has_storage (device)); + G_GNUC_BEGIN_IGNORE_DEPRECATIONS + g_assert_false (fp_device_has_storage (device)); + G_GNUC_END_IGNORE_DEPRECATIONS g_assert_false (fp_device_has_feature (device, FP_DEVICE_FEATURE_STORAGE)); prints = fp_device_list_prints_sync (device, NULL, &error);