From 0a32a1312df98d8dc854425ef5d8ebe398755f4f Mon Sep 17 00:00:00 2001 From: Dustin Falgout Date: Sun, 16 Oct 2016 21:04:52 -0500 Subject: [PATCH] update api usage for lightdm 1.19.2+ --- meson.build | 9 ++++--- src/webkit2-extension.c | 60 ++++++++++++++++++++++++++++++++++++++++- 2 files changed, 65 insertions(+), 4 deletions(-) diff --git a/meson.build b/meson.build index 8960a35..2e5cf0a 100644 --- a/meson.build +++ b/meson.build @@ -1,4 +1,4 @@ -project('lightdm-webkit2-greeter', 'c', version: '2.1.5', license: 'GPL-3') +project('lightdm-webkit2-greeter', 'c', version: '2.1.6', license: 'GPL-3') # ================================== # @@ -28,7 +28,8 @@ webkit2_webext = dependency('webkit2gtk-web-extension-4.0', version: '>=2.10.7' greeter_deps = [dbus_glib, gtk3, webkit2, x11] webext_deps = [webkit2_webext, lightdm_gobject] -has_webkitgtk_214 = webkit2.version().version_compare('>=2.14.0') +has_webkitgtk_2_14 = webkit2.version().version_compare('>=2.14.0') +has_lightdm_1_19_2 = lightdm_gobject.version().version_compare('>=1.19.2') # =================================== # @@ -55,7 +56,9 @@ conf.set('DESKTOP_DIR', '"@0@"'.format(get_option('with-desktop-dir'))) conf.set('WEBEXT_DIR', '"@0@"'.format(get_option('with-webext-dir'))) -conf.set('HAS_WEBKITGTK_2_14', has_webkitgtk_214) +conf.set('HAS_WEBKITGTK_2_14', has_webkitgtk_2_14) + +conf.set('HAS_LIGHTDM_1_19_2', has_lightdm_1_19_2) # ===================================== # diff --git a/src/webkit2-extension.c b/src/webkit2-extension.c index b0ab0e2..08302e9 100644 --- a/src/webkit2-extension.c +++ b/src/webkit2-extension.c @@ -38,6 +38,7 @@ #define _GNU_SOURCE #include +#include #include #include #include @@ -52,7 +53,7 @@ /* CLion bugs */ #ifndef guint64 -#define guint64 typedef unsigned long guint64; +typedef unsigned long guint64; #endif @@ -672,7 +673,19 @@ authenticate_cb(JSContextRef context, name = arg_to_string(context, arguments[0], exception); } + #ifdef HAS_LIGHTDM_1_19_2 + GError *err = NULL; + + lightdm_greeter_authenticate(GREETER, name, &err); + + if (NULL != err) { + _mkexception(context, exception, err->message); + g_error_free(err); + } + #else lightdm_greeter_authenticate(GREETER, name); + #endif + g_free(name); return JSValueMakeNull(context); @@ -687,7 +700,18 @@ authenticate_as_guest_cb(JSContextRef context, const JSValueRef arguments[], JSValueRef *exception) { + #ifdef HAS_LIGHTDM_1_19_2 + GError *err = NULL; + + lightdm_greeter_authenticate_as_guest(GREETER, &err); + + if (NULL != err) { + _mkexception(context, exception, err->message); + g_error_free(err); + } + #else lightdm_greeter_authenticate_as_guest(GREETER); + #endif return JSValueMakeNull(context); } @@ -741,7 +765,19 @@ respond_cb(JSContextRef context, return JSValueMakeNull(context); } + #ifdef HAS_LIGHTDM_1_19_2 + GError *err = NULL; + + lightdm_greeter_respond(GREETER, response, &err); + + if (NULL != err) { + _mkexception(context, exception, err->message); + g_error_free(err); + } + #else lightdm_greeter_respond(GREETER, response); + #endif + g_free(response); return JSValueMakeNull(context); @@ -756,7 +792,18 @@ cancel_authentication_cb(JSContextRef context, const JSValueRef arguments[], JSValueRef *exception) { + #ifdef HAS_LIGHTDM_1_19_2 + GError *err = NULL; + + lightdm_greeter_cancel_authentication(GREETER, &err); + + if (NULL != err) { + _mkexception(context, exception, err->message); + g_error_free(err); + } + #else lightdm_greeter_cancel_authentication(GREETER); + #endif return JSValueMakeNull(context); } @@ -1014,7 +1061,18 @@ set_language_cb(JSContextRef context, return JSValueMakeNull(context); } + #ifdef HAS_LIGHTDM_1_19_2 + GError *err = NULL; + + lightdm_greeter_set_language(GREETER, language, &err); + + if (NULL != err) { + _mkexception(context, exception, err->message); + g_error_free(err); + } + #else lightdm_greeter_set_language(GREETER, language); + #endif g_free(language);