From 3f2174676e7ff15fd7fbbfab2afcf2ecceb346ad Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marco=20Trevisan=20=28Trevi=C3=B1o=29?= Date: Fri, 27 Nov 2020 18:21:29 +0100 Subject: [PATCH] device: Re-define polkit auto-pointer funcs if not defined In case we're using an old polkit version that does not support auto-pointers, we need to re-define such functions manually or fprintd won't compile. Given that polkit doesn't provide us version informations in headers we need to get that from pkg-config --- config.h.in | 3 +++ meson.build | 1 + src/device.c | 6 ++++++ 3 files changed, 10 insertions(+) diff --git a/config.h.in b/config.h.in index ebab457..d45da15 100644 --- a/config.h.in +++ b/config.h.in @@ -9,3 +9,6 @@ /* Define to the version of this package. */ #mesondefine VERSION + +/* Whether current polkit version supports autopointers */ +#mesondefine POLKIT_HAS_AUTOPOINTERS diff --git a/meson.build b/meson.build index 90ab529..d0aa764 100644 --- a/meson.build +++ b/meson.build @@ -139,6 +139,7 @@ cdata.set_quoted('GETTEXT_PACKAGE', meson.project_name()) cdata.set_quoted('PACKAGE_VERSION', meson.project_version()) cdata.set_quoted('VERSION', meson.project_version()) cdata.set_quoted('SYSCONFDIR', sysconfdir) +cdata.set('POLKIT_HAS_AUTOPOINTERS', polkit_gobject_dep.version().version_compare('>= 0.114')) config_h = configure_file( input: 'config.h.in', diff --git a/src/device.c b/src/device.c index 8c2dc2b..0ebf4bf 100644 --- a/src/device.c +++ b/src/device.c @@ -129,6 +129,12 @@ enum fprint_device_signals { static guint32 last_id = ~0; static guint signals[NUM_SIGNALS] = { 0, }; +#ifndef POLKIT_HAS_AUTOPOINTERS +/* FIXME: Remove this once we're fine to depend on polkit 0.114 */ +G_DEFINE_AUTOPTR_CLEANUP_FUNC (PolkitAuthorizationResult, g_object_unref) +G_DEFINE_AUTOPTR_CLEANUP_FUNC (PolkitSubject, g_object_unref) +#endif + static void session_data_unref(SessionData *session) {