|
|
@ -1,10 +1,13 @@ |
|
|
|
/*
|
|
|
|
/*
|
|
|
|
* lightdm-webkit2-greeter-ext.c |
|
|
|
* lightdm-webkit2-greeter-ext.c |
|
|
|
* |
|
|
|
* |
|
|
|
* Copyright © 2014-2015 Antergos Developers <dev@antergos.com> |
|
|
|
* Copyright © 2014-2016 Antergos Developers <dev@antergos.com> |
|
|
|
|
|
|
|
* |
|
|
|
|
|
|
|
* Contributed Code: |
|
|
|
|
|
|
|
* Copyright © 2016 Scott Balneaves <sbalneav@ltsp.org> |
|
|
|
* |
|
|
|
* |
|
|
|
* Based on code from lightdm-webkit-greeter: |
|
|
|
* Based on code from lightdm-webkit-greeter: |
|
|
|
* Copyright © 2010-2015 Robert Ancell <robert.ancell@canonical.com> |
|
|
|
* Copyright © 2010-2014 Robert Ancell <robert.ancell@canonical.com> |
|
|
|
* |
|
|
|
* |
|
|
|
* This file is part of lightdm-webkit2-greeter. |
|
|
|
* This file is part of lightdm-webkit2-greeter. |
|
|
|
* |
|
|
|
* |
|
|
@ -52,49 +55,54 @@ static JSClassRef |
|
|
|
lightdm_layout_class, |
|
|
|
lightdm_layout_class, |
|
|
|
lightdm_session_class; |
|
|
|
lightdm_session_class; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static JSValueRef |
|
|
|
static JSValueRef |
|
|
|
string_or_null(JSContextRef context, const gchar *str) { |
|
|
|
string_or_null(JSContextRef context, const gchar *str) { |
|
|
|
JSValueRef result; |
|
|
|
JSValueRef result; |
|
|
|
JSStringRef string; |
|
|
|
JSStringRef string; |
|
|
|
|
|
|
|
|
|
|
|
if (str == NULL) |
|
|
|
if (str == NULL) { |
|
|
|
return JSValueMakeNull (context); |
|
|
|
return JSValueMakeNull(context); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
string = JSStringCreateWithUTF8CString (str); |
|
|
|
string = JSStringCreateWithUTF8CString(str); |
|
|
|
result = JSValueMakeString (context, string); |
|
|
|
result = JSValueMakeString(context, string); |
|
|
|
JSStringRelease (string); |
|
|
|
JSStringRelease(string); |
|
|
|
|
|
|
|
|
|
|
|
return result; |
|
|
|
return result; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static JSValueRef |
|
|
|
static JSValueRef |
|
|
|
mkexception (JSContextRef context, JSValueRef * exception, const gchar * str) |
|
|
|
mkexception(JSContextRef context, JSValueRef *exception, const gchar *str) { |
|
|
|
{ |
|
|
|
JSStringRef string = JSStringCreateWithUTF8CString(str); |
|
|
|
JSStringRef string = JSStringCreateWithUTF8CString (str); |
|
|
|
JSValueRef exceptionString = JSValueMakeString(context, string); |
|
|
|
JSValueRef exceptionString = JSValueMakeString (context, string); |
|
|
|
JSStringRelease(string); |
|
|
|
JSStringRelease (string); |
|
|
|
*exception = JSValueToObject(context, exceptionString, NULL); |
|
|
|
*exception = JSValueToObject (context, exceptionString, NULL); |
|
|
|
return JSValueMakeNull(context); |
|
|
|
return JSValueMakeNull (context); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static char * |
|
|
|
static char * |
|
|
|
escape (const gchar *text) |
|
|
|
escape(const gchar *text) { |
|
|
|
{ |
|
|
|
|
|
|
|
size_t len; |
|
|
|
size_t len; |
|
|
|
size_t i, j; |
|
|
|
size_t i, j; |
|
|
|
int count = 0; |
|
|
|
int count = 0; |
|
|
|
gchar *escaped; |
|
|
|
gchar *escaped; |
|
|
|
|
|
|
|
|
|
|
|
len = strlen (text); |
|
|
|
len = strlen(text); |
|
|
|
|
|
|
|
|
|
|
|
for (i = 0; i < len; i++) |
|
|
|
for (i = 0; i < len; i++) { |
|
|
|
if (text[i] == '\'') |
|
|
|
if (text[i] == '\'') { |
|
|
|
count++; |
|
|
|
count++; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (count == 0) |
|
|
|
if (count == 0) { |
|
|
|
return g_strdup (text); |
|
|
|
return g_strdup(text); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
escaped = g_malloc (len + count + 1); |
|
|
|
escaped = g_malloc(len + count + 1); |
|
|
|
|
|
|
|
|
|
|
|
j = 0; |
|
|
|
j = 0; |
|
|
|
for (i = 0; i <= len; i++) { |
|
|
|
for (i = 0; i <= len; i++) { |
|
|
@ -109,6 +117,7 @@ escape (const gchar *text) |
|
|
|
return escaped; |
|
|
|
return escaped; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static JSValueRef |
|
|
|
static JSValueRef |
|
|
|
get_user_name_cb(JSContextRef context, |
|
|
|
get_user_name_cb(JSContextRef context, |
|
|
|
JSObjectRef thisObject, |
|
|
|
JSObjectRef thisObject, |
|
|
@ -141,13 +150,14 @@ get_user_display_name_cb(JSContextRef context, |
|
|
|
|
|
|
|
|
|
|
|
static JSValueRef |
|
|
|
static JSValueRef |
|
|
|
get_user_home_directory_cb(JSContextRef context, |
|
|
|
get_user_home_directory_cb(JSContextRef context, |
|
|
|
JSObjectRef thisObject, |
|
|
|
JSObjectRef thisObject, |
|
|
|
JSStringRef propertyName, |
|
|
|
JSStringRef propertyName, |
|
|
|
JSValueRef *exception) { |
|
|
|
JSValueRef *exception) { |
|
|
|
LightDMUser *user = JSObjectGetPrivate(thisObject); |
|
|
|
LightDMUser *user = JSObjectGetPrivate(thisObject); |
|
|
|
return string_or_null(context, lightdm_user_get_home_directory(user)); |
|
|
|
return string_or_null(context, lightdm_user_get_home_directory(user)); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static JSValueRef |
|
|
|
static JSValueRef |
|
|
|
get_user_image_cb(JSContextRef context, |
|
|
|
get_user_image_cb(JSContextRef context, |
|
|
|
JSObjectRef thisObject, |
|
|
|
JSObjectRef thisObject, |
|
|
@ -163,7 +173,7 @@ get_user_language_cb(JSContextRef context, |
|
|
|
JSObjectRef thisObject, |
|
|
|
JSObjectRef thisObject, |
|
|
|
JSStringRef propertyName, |
|
|
|
JSStringRef propertyName, |
|
|
|
JSValueRef *exception) { |
|
|
|
JSValueRef *exception) { |
|
|
|
LightDMUser *user = JSObjectGetPrivate(thisObject); |
|
|
|
LightDMUser *user = JSObjectGetPrivate(thisObject); |
|
|
|
return string_or_null(context, lightdm_user_get_language(user)); |
|
|
|
return string_or_null(context, lightdm_user_get_language(user)); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -173,7 +183,7 @@ get_user_layout_cb(JSContextRef context, |
|
|
|
JSObjectRef thisObject, |
|
|
|
JSObjectRef thisObject, |
|
|
|
JSStringRef propertyName, |
|
|
|
JSStringRef propertyName, |
|
|
|
JSValueRef *exception) { |
|
|
|
JSValueRef *exception) { |
|
|
|
LightDMUser *user = JSObjectGetPrivate(thisObject); |
|
|
|
LightDMUser *user = JSObjectGetPrivate(thisObject); |
|
|
|
return string_or_null(context, lightdm_user_get_layout(user)); |
|
|
|
return string_or_null(context, lightdm_user_get_layout(user)); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -183,7 +193,7 @@ get_user_session_cb(JSContextRef context, |
|
|
|
JSObjectRef thisObject, |
|
|
|
JSObjectRef thisObject, |
|
|
|
JSStringRef propertyName, |
|
|
|
JSStringRef propertyName, |
|
|
|
JSValueRef *exception) { |
|
|
|
JSValueRef *exception) { |
|
|
|
LightDMUser *user = JSObjectGetPrivate(thisObject); |
|
|
|
LightDMUser *user = JSObjectGetPrivate(thisObject); |
|
|
|
return string_or_null(context, lightdm_user_get_session(user)); |
|
|
|
return string_or_null(context, lightdm_user_get_session(user)); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -313,13 +323,13 @@ get_users_cb(JSContextRef context, |
|
|
|
JSValueRef *exception) { |
|
|
|
JSValueRef *exception) { |
|
|
|
JSObjectRef array; |
|
|
|
JSObjectRef array; |
|
|
|
const GList *users, *link; |
|
|
|
const GList *users, *link; |
|
|
|
guint i, n_users = 0; |
|
|
|
guint i, n_users = 0; |
|
|
|
JSValueRef *args; |
|
|
|
JSValueRef *args; |
|
|
|
|
|
|
|
|
|
|
|
users = lightdm_user_list_get_users(lightdm_user_list_get_instance()); |
|
|
|
users = lightdm_user_list_get_users(lightdm_user_list_get_instance()); |
|
|
|
n_users = g_list_length((GList *) users); |
|
|
|
n_users = g_list_length((GList *) users); |
|
|
|
args = g_malloc(sizeof(JSValueRef) * ( n_users + 1 )); |
|
|
|
args = g_malloc(sizeof(JSValueRef) * ( n_users + 1 )); |
|
|
|
for (i = 0, link = users; link; i++, link = link->next) { |
|
|
|
for (i = 0, link = users; link; i++, link = link->next) { |
|
|
|
LightDMUser *user = link->data; |
|
|
|
LightDMUser *user = link->data; |
|
|
|
g_object_ref(user); |
|
|
|
g_object_ref(user); |
|
|
|
args[i] = JSObjectMake(context, lightdm_user_class, user); |
|
|
|
args[i] = JSObjectMake(context, lightdm_user_class, user); |
|
|
@ -338,13 +348,13 @@ get_languages_cb(JSContextRef context, |
|
|
|
JSValueRef *exception) { |
|
|
|
JSValueRef *exception) { |
|
|
|
JSObjectRef array; |
|
|
|
JSObjectRef array; |
|
|
|
const GList *languages, *link; |
|
|
|
const GList *languages, *link; |
|
|
|
guint i, n_languages = 0; |
|
|
|
guint i, n_languages = 0; |
|
|
|
JSValueRef *args; |
|
|
|
JSValueRef *args; |
|
|
|
|
|
|
|
|
|
|
|
languages = lightdm_get_languages(); |
|
|
|
languages = lightdm_get_languages(); |
|
|
|
n_languages = g_list_length((GList *) languages); |
|
|
|
n_languages = g_list_length((GList *) languages); |
|
|
|
args = g_malloc(sizeof(JSValueRef) * ( n_languages + 1 )); |
|
|
|
args = g_malloc(sizeof(JSValueRef) * ( n_languages + 1 )); |
|
|
|
for (i = 0, link = languages; link; i++, link = link->next) { |
|
|
|
for (i = 0, link = languages; link; i++, link = link->next) { |
|
|
|
LightDMLanguage *language = link->data; |
|
|
|
LightDMLanguage *language = link->data; |
|
|
|
g_object_ref(language); |
|
|
|
g_object_ref(language); |
|
|
|
args[i] = JSObjectMake(context, lightdm_language_class, language); |
|
|
|
args[i] = JSObjectMake(context, lightdm_language_class, language); |
|
|
@ -358,12 +368,13 @@ get_languages_cb(JSContextRef context, |
|
|
|
|
|
|
|
|
|
|
|
static JSValueRef |
|
|
|
static JSValueRef |
|
|
|
get_language_cb(JSContextRef context, |
|
|
|
get_language_cb(JSContextRef context, |
|
|
|
JSObjectRef thisObject, |
|
|
|
JSObjectRef thisObject, |
|
|
|
JSStringRef propertyName, |
|
|
|
JSStringRef propertyName, |
|
|
|
JSValueRef *exception) { |
|
|
|
JSValueRef *exception) { |
|
|
|
return string_or_null(context, lightdm_language_get_name((LightDMLanguage *) lightdm_get_language())); |
|
|
|
return string_or_null(context, lightdm_language_get_name((LightDMLanguage *) lightdm_get_language())); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static JSValueRef |
|
|
|
static JSValueRef |
|
|
|
get_layouts_cb(JSContextRef context, |
|
|
|
get_layouts_cb(JSContextRef context, |
|
|
|
JSObjectRef thisObject, |
|
|
|
JSObjectRef thisObject, |
|
|
@ -372,13 +383,13 @@ get_layouts_cb(JSContextRef context, |
|
|
|
|
|
|
|
|
|
|
|
JSObjectRef array; |
|
|
|
JSObjectRef array; |
|
|
|
const GList *layouts, *link; |
|
|
|
const GList *layouts, *link; |
|
|
|
guint i, n_layouts = 0; |
|
|
|
guint i, n_layouts = 0; |
|
|
|
JSValueRef *args; |
|
|
|
JSValueRef *args; |
|
|
|
|
|
|
|
|
|
|
|
layouts = lightdm_get_layouts(); |
|
|
|
layouts = lightdm_get_layouts(); |
|
|
|
n_layouts = g_list_length((GList *) layouts); |
|
|
|
n_layouts = g_list_length((GList *) layouts); |
|
|
|
args = g_malloc(sizeof(JSValueRef) * ( n_layouts + 1 )); |
|
|
|
args = g_malloc(sizeof(JSValueRef) * ( n_layouts + 1 )); |
|
|
|
for (i = 0, link = layouts; link; i++, link = link->next) { |
|
|
|
for (i = 0, link = layouts; link; i++, link = link->next) { |
|
|
|
LightDMLayout *layout = link->data; |
|
|
|
LightDMLayout *layout = link->data; |
|
|
|
g_object_ref(layout); |
|
|
|
g_object_ref(layout); |
|
|
|
args[i] = JSObjectMake(context, lightdm_layout_class, layout); |
|
|
|
args[i] = JSObjectMake(context, lightdm_layout_class, layout); |
|
|
@ -406,8 +417,8 @@ set_layout_cb(JSContextRef context, |
|
|
|
JSValueRef value, |
|
|
|
JSValueRef value, |
|
|
|
JSValueRef *exception) { |
|
|
|
JSValueRef *exception) { |
|
|
|
JSStringRef layout_arg; |
|
|
|
JSStringRef layout_arg; |
|
|
|
size_t layout_size; |
|
|
|
size_t layout_size; |
|
|
|
gchar *layout; |
|
|
|
gchar *layout; |
|
|
|
const GList *layouts, *link; |
|
|
|
const GList *layouts, *link; |
|
|
|
|
|
|
|
|
|
|
|
if (JSValueGetType(context, value) != kJSTypeString) { |
|
|
|
if (JSValueGetType(context, value) != kJSTypeString) { |
|
|
@ -420,22 +431,21 @@ set_layout_cb(JSContextRef context, |
|
|
|
|
|
|
|
|
|
|
|
layout_arg = JSValueToStringCopy(context, value, NULL); |
|
|
|
layout_arg = JSValueToStringCopy(context, value, NULL); |
|
|
|
layout_size = JSStringGetMaximumUTF8CStringSize(layout_arg); |
|
|
|
layout_size = JSStringGetMaximumUTF8CStringSize(layout_arg); |
|
|
|
layout = g_malloc (layout_size); |
|
|
|
layout = g_malloc(layout_size); |
|
|
|
JSStringGetUTF8CString(layout_arg, layout, layout_size); |
|
|
|
JSStringGetUTF8CString(layout_arg, layout, layout_size); |
|
|
|
JSStringRelease(layout_arg); |
|
|
|
JSStringRelease(layout_arg); |
|
|
|
|
|
|
|
|
|
|
|
layouts = lightdm_get_layouts (); |
|
|
|
layouts = lightdm_get_layouts(); |
|
|
|
for (link = layouts; link; link = link->next) |
|
|
|
for (link = layouts; link; link = link->next) { |
|
|
|
{ |
|
|
|
|
|
|
|
LightDMLayout *currlayout = link->data; |
|
|
|
LightDMLayout *currlayout = link->data; |
|
|
|
if (!(g_strcmp0(lightdm_layout_get_name(currlayout), layout))) { |
|
|
|
if (!( g_strcmp0(lightdm_layout_get_name(currlayout), layout))) { |
|
|
|
g_object_ref (currlayout); |
|
|
|
g_object_ref(currlayout); |
|
|
|
lightdm_set_layout (currlayout); |
|
|
|
lightdm_set_layout(currlayout); |
|
|
|
break; |
|
|
|
break; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
g_free (layout); |
|
|
|
g_free(layout); |
|
|
|
return true; |
|
|
|
return true; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -447,13 +457,13 @@ get_sessions_cb(JSContextRef context, |
|
|
|
JSValueRef *exception) { |
|
|
|
JSValueRef *exception) { |
|
|
|
JSObjectRef array; |
|
|
|
JSObjectRef array; |
|
|
|
const GList *sessions, *link; |
|
|
|
const GList *sessions, *link; |
|
|
|
guint i, n_sessions = 0; |
|
|
|
guint i, n_sessions = 0; |
|
|
|
JSValueRef *args; |
|
|
|
JSValueRef *args; |
|
|
|
|
|
|
|
|
|
|
|
sessions = lightdm_get_sessions(); |
|
|
|
sessions = lightdm_get_sessions(); |
|
|
|
n_sessions = g_list_length((GList *) sessions); |
|
|
|
n_sessions = g_list_length((GList *) sessions); |
|
|
|
args = g_malloc(sizeof(JSValueRef) * ( n_sessions + 1 )); |
|
|
|
args = g_malloc(sizeof(JSValueRef) * ( n_sessions + 1 )); |
|
|
|
for (i = 0, link = sessions; link; i++, link = link->next) { |
|
|
|
for (i = 0, link = sessions; link; i++, link = link->next) { |
|
|
|
LightDMSession *session = link->data; |
|
|
|
LightDMSession *session = link->data; |
|
|
|
g_object_ref(session); |
|
|
|
g_object_ref(session); |
|
|
|
args[i] = JSObjectMake(context, lightdm_session_class, session); |
|
|
|
args[i] = JSObjectMake(context, lightdm_session_class, session); |
|
|
@ -497,15 +507,16 @@ get_autologin_timeout_cb(JSContextRef context, |
|
|
|
|
|
|
|
|
|
|
|
static JSValueRef |
|
|
|
static JSValueRef |
|
|
|
cancel_autologin_cb(JSContextRef context, |
|
|
|
cancel_autologin_cb(JSContextRef context, |
|
|
|
JSObjectRef function, |
|
|
|
JSObjectRef function, |
|
|
|
JSObjectRef thisObject, |
|
|
|
JSObjectRef thisObject, |
|
|
|
size_t argumentCount, |
|
|
|
size_t argumentCount, |
|
|
|
const JSValueRef arguments[], |
|
|
|
const JSValueRef arguments[], |
|
|
|
JSValueRef *exception) { |
|
|
|
JSValueRef *exception) { |
|
|
|
LightDMGreeter *greeter = JSObjectGetPrivate(thisObject); |
|
|
|
LightDMGreeter *greeter = JSObjectGetPrivate(thisObject); |
|
|
|
|
|
|
|
|
|
|
|
if (argumentCount != 0) |
|
|
|
if (argumentCount != 0) { |
|
|
|
return mkexception (context, exception, "Argument count not zero"); |
|
|
|
return mkexception(context, exception, "Argument count not zero"); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
lightdm_greeter_cancel_autologin(greeter); |
|
|
|
lightdm_greeter_cancel_autologin(greeter); |
|
|
|
return JSValueMakeNull(context); |
|
|
|
return JSValueMakeNull(context); |
|
|
@ -514,107 +525,114 @@ cancel_autologin_cb(JSContextRef context, |
|
|
|
|
|
|
|
|
|
|
|
static JSValueRef |
|
|
|
static JSValueRef |
|
|
|
authenticate_cb(JSContextRef context, |
|
|
|
authenticate_cb(JSContextRef context, |
|
|
|
JSObjectRef function, |
|
|
|
JSObjectRef function, |
|
|
|
JSObjectRef thisObject, |
|
|
|
JSObjectRef thisObject, |
|
|
|
size_t argumentCount, |
|
|
|
size_t argumentCount, |
|
|
|
const JSValueRef arguments[], |
|
|
|
const JSValueRef arguments[], |
|
|
|
JSValueRef *exception) { |
|
|
|
JSValueRef *exception) { |
|
|
|
LightDMGreeter *greeter = JSObjectGetPrivate(thisObject); |
|
|
|
LightDMGreeter *greeter = JSObjectGetPrivate(thisObject); |
|
|
|
JSStringRef name_arg; |
|
|
|
JSStringRef name_arg; |
|
|
|
size_t name_size; |
|
|
|
size_t name_size; |
|
|
|
gchar *name; |
|
|
|
gchar *name; |
|
|
|
|
|
|
|
|
|
|
|
if (!( argumentCount == 1 && JSValueGetType(context, arguments[0]) == kJSTypeString )) |
|
|
|
if (!( argumentCount == 1 && JSValueGetType(context, arguments[0]) == kJSTypeString )) { |
|
|
|
return mkexception (context, exception, "Username argument not supplied"); |
|
|
|
return mkexception(context, exception, "Username argument not supplied"); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
name_arg = JSValueToStringCopy(context, arguments[0], NULL); |
|
|
|
name_arg = JSValueToStringCopy(context, arguments[0], NULL); |
|
|
|
name_size = JSStringGetMaximumUTF8CStringSize(name_arg); |
|
|
|
name_size = JSStringGetMaximumUTF8CStringSize(name_arg); |
|
|
|
name = g_malloc (name_size); |
|
|
|
name = g_malloc(name_size); |
|
|
|
JSStringGetUTF8CString(name_arg, name, name_size); |
|
|
|
JSStringGetUTF8CString(name_arg, name, name_size); |
|
|
|
JSStringRelease(name_arg); |
|
|
|
JSStringRelease(name_arg); |
|
|
|
|
|
|
|
|
|
|
|
if (*name == '\0') |
|
|
|
if (*name == '\0') { |
|
|
|
lightdm_greeter_authenticate(greeter, NULL); |
|
|
|
lightdm_greeter_authenticate(greeter, NULL); |
|
|
|
else |
|
|
|
} else { |
|
|
|
lightdm_greeter_authenticate(greeter, name); |
|
|
|
lightdm_greeter_authenticate(greeter, name); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
g_free (name); |
|
|
|
g_free(name); |
|
|
|
return JSValueMakeNull(context); |
|
|
|
return JSValueMakeNull(context); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static JSValueRef |
|
|
|
static JSValueRef |
|
|
|
authenticate_as_guest_cb (JSContextRef context, |
|
|
|
authenticate_as_guest_cb(JSContextRef context, |
|
|
|
JSObjectRef function, |
|
|
|
JSObjectRef function, |
|
|
|
JSObjectRef thisObject, |
|
|
|
JSObjectRef thisObject, |
|
|
|
size_t argumentCount, |
|
|
|
size_t argumentCount, |
|
|
|
const JSValueRef arguments[], |
|
|
|
const JSValueRef arguments[], |
|
|
|
JSValueRef * exception) { |
|
|
|
JSValueRef *exception) { |
|
|
|
LightDMGreeter *greeter = JSObjectGetPrivate (thisObject); |
|
|
|
LightDMGreeter *greeter = JSObjectGetPrivate(thisObject); |
|
|
|
|
|
|
|
|
|
|
|
if (argumentCount != 0) |
|
|
|
if (argumentCount != 0) { |
|
|
|
return mkexception (context, exception, "Argument count not zero"); |
|
|
|
return mkexception(context, exception, "Argument count not zero"); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
lightdm_greeter_authenticate_as_guest (greeter); |
|
|
|
lightdm_greeter_authenticate_as_guest(greeter); |
|
|
|
|
|
|
|
|
|
|
|
return JSValueMakeNull (context); |
|
|
|
return JSValueMakeNull(context); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static JSValueRef |
|
|
|
static JSValueRef |
|
|
|
get_hint_cb (JSContextRef context, |
|
|
|
get_hint_cb(JSContextRef context, |
|
|
|
JSObjectRef function, |
|
|
|
JSObjectRef function, |
|
|
|
JSObjectRef thisObject, |
|
|
|
JSObjectRef thisObject, |
|
|
|
size_t argumentCount, |
|
|
|
size_t argumentCount, |
|
|
|
const JSValueRef arguments[], |
|
|
|
const JSValueRef arguments[], |
|
|
|
JSValueRef * exception) { |
|
|
|
JSValueRef *exception) { |
|
|
|
LightDMGreeter *greeter = JSObjectGetPrivate (thisObject); |
|
|
|
LightDMGreeter *greeter = JSObjectGetPrivate(thisObject); |
|
|
|
JSStringRef hint_arg; |
|
|
|
JSStringRef hint_arg; |
|
|
|
size_t hint_size; |
|
|
|
size_t hint_size; |
|
|
|
gchar *hint_name; |
|
|
|
gchar *hint_name; |
|
|
|
JSStringRef hint; |
|
|
|
JSStringRef hint; |
|
|
|
JSValueRef result; |
|
|
|
JSValueRef result; |
|
|
|
|
|
|
|
|
|
|
|
if (!(argumentCount == 1 && JSValueGetType (context, arguments[0]) == kJSTypeString)) |
|
|
|
if (!( argumentCount == 1 && JSValueGetType(context, arguments[0]) == kJSTypeString )) { |
|
|
|
return mkexception (context, exception, "Hint argument not supplied"); |
|
|
|
return mkexception(context, exception, "Hint argument not supplied"); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
hint_arg = JSValueToStringCopy (context, arguments[0], NULL); |
|
|
|
hint_arg = JSValueToStringCopy(context, arguments[0], NULL); |
|
|
|
hint_size = JSStringGetMaximumUTF8CStringSize (hint_arg); |
|
|
|
hint_size = JSStringGetMaximumUTF8CStringSize(hint_arg); |
|
|
|
hint_name = g_malloc (hint_size); |
|
|
|
hint_name = g_malloc(hint_size); |
|
|
|
JSStringGetUTF8CString (hint_arg, hint_name, hint_size); |
|
|
|
JSStringGetUTF8CString(hint_arg, hint_name, hint_size); |
|
|
|
JSStringRelease (hint_arg); |
|
|
|
JSStringRelease(hint_arg); |
|
|
|
|
|
|
|
|
|
|
|
hint = JSStringCreateWithUTF8CString (lightdm_greeter_get_hint (greeter, hint_name)); |
|
|
|
hint = JSStringCreateWithUTF8CString(lightdm_greeter_get_hint(greeter, hint_name)); |
|
|
|
g_free (hint_name); |
|
|
|
g_free(hint_name); |
|
|
|
result = JSValueMakeString (context, hint); |
|
|
|
result = JSValueMakeString(context, hint); |
|
|
|
JSStringRelease (hint); |
|
|
|
JSStringRelease(hint); |
|
|
|
|
|
|
|
|
|
|
|
return result; |
|
|
|
return result; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static JSValueRef |
|
|
|
static JSValueRef |
|
|
|
respond_cb(JSContextRef context, |
|
|
|
respond_cb(JSContextRef context, |
|
|
|
JSObjectRef function, |
|
|
|
JSObjectRef function, |
|
|
|
JSObjectRef thisObject, |
|
|
|
JSObjectRef thisObject, |
|
|
|
size_t argumentCount, |
|
|
|
size_t argumentCount, |
|
|
|
const JSValueRef arguments[], |
|
|
|
const JSValueRef arguments[], |
|
|
|
JSValueRef *exception) { |
|
|
|
JSValueRef *exception) { |
|
|
|
LightDMGreeter *greeter = JSObjectGetPrivate(thisObject); |
|
|
|
LightDMGreeter *greeter = JSObjectGetPrivate(thisObject); |
|
|
|
JSStringRef response_arg; |
|
|
|
JSStringRef response_arg; |
|
|
|
size_t response_size; |
|
|
|
size_t response_size; |
|
|
|
gchar *response; |
|
|
|
gchar *response; |
|
|
|
|
|
|
|
|
|
|
|
if (!( argumentCount == 1 && JSValueGetType(context, arguments[0]) == kJSTypeString )) |
|
|
|
if (!( argumentCount == 1 && JSValueGetType(context, arguments[0]) == kJSTypeString )) { |
|
|
|
return mkexception (context, exception, "Response not supplied"); |
|
|
|
return mkexception(context, exception, "Response not supplied"); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
response_arg = JSValueToStringCopy(context, arguments[0], NULL); |
|
|
|
response_arg = JSValueToStringCopy(context, arguments[0], NULL); |
|
|
|
response_size = JSStringGetMaximumUTF8CStringSize(response_arg); |
|
|
|
response_size = JSStringGetMaximumUTF8CStringSize(response_arg); |
|
|
|
response = g_malloc (response_size); |
|
|
|
response = g_malloc(response_size); |
|
|
|
JSStringGetUTF8CString(response_arg, response, response_size); |
|
|
|
JSStringGetUTF8CString(response_arg, response, response_size); |
|
|
|
JSStringRelease(response_arg); |
|
|
|
JSStringRelease(response_arg); |
|
|
|
|
|
|
|
|
|
|
|
lightdm_greeter_respond(greeter, response); |
|
|
|
lightdm_greeter_respond(greeter, response); |
|
|
|
|
|
|
|
|
|
|
|
g_free (response); |
|
|
|
g_free(response); |
|
|
|
return JSValueMakeNull(context); |
|
|
|
return JSValueMakeNull(context); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -628,8 +646,9 @@ cancel_authentication_cb(JSContextRef context, |
|
|
|
JSValueRef *exception) { |
|
|
|
JSValueRef *exception) { |
|
|
|
LightDMGreeter *greeter = JSObjectGetPrivate(thisObject); |
|
|
|
LightDMGreeter *greeter = JSObjectGetPrivate(thisObject); |
|
|
|
|
|
|
|
|
|
|
|
if (argumentCount != 0) |
|
|
|
if (argumentCount != 0) { |
|
|
|
return mkexception (context, exception, "Argument count not zero"); |
|
|
|
return mkexception(context, exception, "Argument count not zero"); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
lightdm_greeter_cancel_authentication(greeter); |
|
|
|
lightdm_greeter_cancel_authentication(greeter); |
|
|
|
return JSValueMakeNull(context); |
|
|
|
return JSValueMakeNull(context); |
|
|
@ -645,60 +664,67 @@ get_authentication_user_cb(JSContextRef context, |
|
|
|
return string_or_null(context, lightdm_greeter_get_authentication_user(greeter)); |
|
|
|
return string_or_null(context, lightdm_greeter_get_authentication_user(greeter)); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static JSValueRef |
|
|
|
static JSValueRef |
|
|
|
get_has_guest_account_cb (JSContextRef context, |
|
|
|
get_has_guest_account_cb(JSContextRef context, |
|
|
|
JSObjectRef thisObject, |
|
|
|
JSObjectRef thisObject, |
|
|
|
JSStringRef propertyName, |
|
|
|
JSStringRef propertyName, |
|
|
|
JSValueRef * exception) { |
|
|
|
JSValueRef *exception) { |
|
|
|
LightDMGreeter *greeter = JSObjectGetPrivate (thisObject); |
|
|
|
LightDMGreeter *greeter = JSObjectGetPrivate(thisObject); |
|
|
|
return JSValueMakeBoolean (context, lightdm_greeter_get_has_guest_account_hint (greeter)); |
|
|
|
return JSValueMakeBoolean(context, lightdm_greeter_get_has_guest_account_hint(greeter)); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static JSValueRef |
|
|
|
static JSValueRef |
|
|
|
get_hide_users_cb (JSContextRef context, |
|
|
|
get_hide_users_cb(JSContextRef context, |
|
|
|
JSObjectRef thisObject, |
|
|
|
JSObjectRef thisObject, |
|
|
|
JSStringRef propertyName, |
|
|
|
JSStringRef propertyName, |
|
|
|
JSValueRef * exception) { |
|
|
|
JSValueRef *exception) { |
|
|
|
LightDMGreeter *greeter = JSObjectGetPrivate (thisObject); |
|
|
|
LightDMGreeter *greeter = JSObjectGetPrivate(thisObject); |
|
|
|
return JSValueMakeBoolean (context, lightdm_greeter_get_hide_users_hint (greeter)); |
|
|
|
return JSValueMakeBoolean(context, lightdm_greeter_get_hide_users_hint(greeter)); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static JSValueRef |
|
|
|
static JSValueRef |
|
|
|
get_select_user_cb (JSContextRef context, |
|
|
|
get_select_user_cb(JSContextRef context, |
|
|
|
JSObjectRef thisObject, |
|
|
|
JSObjectRef thisObject, |
|
|
|
JSStringRef propertyName, |
|
|
|
JSStringRef propertyName, |
|
|
|
JSValueRef * exception) { |
|
|
|
JSValueRef *exception) { |
|
|
|
LightDMGreeter *greeter = JSObjectGetPrivate (thisObject); |
|
|
|
LightDMGreeter *greeter = JSObjectGetPrivate(thisObject); |
|
|
|
return string_or_null (context, lightdm_greeter_get_select_user_hint (greeter)); |
|
|
|
return string_or_null(context, lightdm_greeter_get_select_user_hint(greeter)); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static JSValueRef |
|
|
|
static JSValueRef |
|
|
|
get_select_guest_cb (JSContextRef context, |
|
|
|
get_select_guest_cb(JSContextRef context, |
|
|
|
JSObjectRef thisObject, |
|
|
|
JSObjectRef thisObject, |
|
|
|
JSStringRef propertyName, |
|
|
|
JSStringRef propertyName, |
|
|
|
JSValueRef * exception) { |
|
|
|
JSValueRef *exception) { |
|
|
|
LightDMGreeter *greeter = JSObjectGetPrivate (thisObject); |
|
|
|
LightDMGreeter *greeter = JSObjectGetPrivate(thisObject); |
|
|
|
return JSValueMakeBoolean (context, lightdm_greeter_get_select_guest_hint (greeter)); |
|
|
|
return JSValueMakeBoolean(context, lightdm_greeter_get_select_guest_hint(greeter)); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static JSValueRef |
|
|
|
static JSValueRef |
|
|
|
get_autologin_user_cb (JSContextRef context, |
|
|
|
get_autologin_user_cb(JSContextRef context, |
|
|
|
JSObjectRef thisObject, |
|
|
|
JSObjectRef thisObject, |
|
|
|
JSStringRef propertyName, |
|
|
|
JSStringRef propertyName, |
|
|
|
JSValueRef * exception) { |
|
|
|
JSValueRef *exception) { |
|
|
|
LightDMGreeter *greeter = JSObjectGetPrivate (thisObject); |
|
|
|
LightDMGreeter *greeter = JSObjectGetPrivate(thisObject); |
|
|
|
return string_or_null (context, lightdm_greeter_get_autologin_user_hint (greeter)); |
|
|
|
return string_or_null(context, lightdm_greeter_get_autologin_user_hint(greeter)); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static JSValueRef |
|
|
|
static JSValueRef |
|
|
|
get_autologin_guest_cb (JSContextRef context, |
|
|
|
get_autologin_guest_cb(JSContextRef context, |
|
|
|
JSObjectRef thisObject, |
|
|
|
JSObjectRef thisObject, |
|
|
|
JSStringRef propertyName, |
|
|
|
JSStringRef propertyName, |
|
|
|
JSValueRef * exception) { |
|
|
|
JSValueRef *exception) { |
|
|
|
LightDMGreeter *greeter = JSObjectGetPrivate (thisObject); |
|
|
|
LightDMGreeter *greeter = JSObjectGetPrivate(thisObject); |
|
|
|
return JSValueMakeBoolean (context, lightdm_greeter_get_autologin_guest_hint (greeter)); |
|
|
|
return JSValueMakeBoolean(context, lightdm_greeter_get_autologin_guest_hint(greeter)); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static JSValueRef |
|
|
|
static JSValueRef |
|
|
|
get_is_authenticated_cb(JSContextRef context, |
|
|
|
get_is_authenticated_cb(JSContextRef context, |
|
|
|
JSObjectRef thisObject, |
|
|
|
JSObjectRef thisObject, |
|
|
@ -708,15 +734,17 @@ get_is_authenticated_cb(JSContextRef context, |
|
|
|
return JSValueMakeBoolean(context, lightdm_greeter_get_is_authenticated(greeter)); |
|
|
|
return JSValueMakeBoolean(context, lightdm_greeter_get_is_authenticated(greeter)); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static JSValueRef |
|
|
|
static JSValueRef |
|
|
|
get_in_authentication_cb(JSContextRef context, |
|
|
|
get_in_authentication_cb(JSContextRef context, |
|
|
|
JSObjectRef thisObject, |
|
|
|
JSObjectRef thisObject, |
|
|
|
JSStringRef propertyName, |
|
|
|
JSStringRef propertyName, |
|
|
|
JSValueRef *exception) { |
|
|
|
JSValueRef *exception) { |
|
|
|
LightDMGreeter *greeter = JSObjectGetPrivate(thisObject); |
|
|
|
LightDMGreeter *greeter = JSObjectGetPrivate(thisObject); |
|
|
|
return JSValueMakeBoolean(context, lightdm_greeter_get_in_authentication(greeter)); |
|
|
|
return JSValueMakeBoolean(context, lightdm_greeter_get_in_authentication(greeter)); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static JSValueRef |
|
|
|
static JSValueRef |
|
|
|
get_can_suspend_cb(JSContextRef context, |
|
|
|
get_can_suspend_cb(JSContextRef context, |
|
|
|
JSObjectRef thisObject, |
|
|
|
JSObjectRef thisObject, |
|
|
@ -733,8 +761,9 @@ suspend_cb(JSContextRef context, |
|
|
|
size_t argumentCount, |
|
|
|
size_t argumentCount, |
|
|
|
const JSValueRef arguments[], |
|
|
|
const JSValueRef arguments[], |
|
|
|
JSValueRef *exception) { |
|
|
|
JSValueRef *exception) { |
|
|
|
if (argumentCount != 0) |
|
|
|
if (argumentCount != 0) { |
|
|
|
return mkexception (context, exception, "Argument count not zero"); |
|
|
|
return mkexception(context, exception, "Argument count not zero"); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
lightdm_suspend(NULL); |
|
|
|
lightdm_suspend(NULL); |
|
|
|
return JSValueMakeNull(context); |
|
|
|
return JSValueMakeNull(context); |
|
|
@ -757,8 +786,9 @@ hibernate_cb(JSContextRef context, |
|
|
|
size_t argumentCount, |
|
|
|
size_t argumentCount, |
|
|
|
const JSValueRef arguments[], |
|
|
|
const JSValueRef arguments[], |
|
|
|
JSValueRef *exception) { |
|
|
|
JSValueRef *exception) { |
|
|
|
if (argumentCount != 0) |
|
|
|
if (argumentCount != 0) { |
|
|
|
return mkexception (context, exception, "Argument count not zero"); |
|
|
|
return mkexception(context, exception, "Argument count not zero"); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
lightdm_hibernate(NULL); |
|
|
|
lightdm_hibernate(NULL); |
|
|
|
return JSValueMakeNull(context); |
|
|
|
return JSValueMakeNull(context); |
|
|
@ -781,8 +811,9 @@ restart_cb(JSContextRef context, |
|
|
|
size_t argumentCount, |
|
|
|
size_t argumentCount, |
|
|
|
const JSValueRef arguments[], |
|
|
|
const JSValueRef arguments[], |
|
|
|
JSValueRef *exception) { |
|
|
|
JSValueRef *exception) { |
|
|
|
if (argumentCount != 0) |
|
|
|
if (argumentCount != 0) { |
|
|
|
return mkexception (context, exception, "Argument count not zero"); |
|
|
|
return mkexception(context, exception, "Argument count not zero"); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
lightdm_restart(NULL); |
|
|
|
lightdm_restart(NULL); |
|
|
|
return JSValueMakeNull(context); |
|
|
|
return JSValueMakeNull(context); |
|
|
@ -805,8 +836,9 @@ shutdown_cb(JSContextRef context, |
|
|
|
size_t argumentCount, |
|
|
|
size_t argumentCount, |
|
|
|
const JSValueRef arguments[], |
|
|
|
const JSValueRef arguments[], |
|
|
|
JSValueRef *exception) { |
|
|
|
JSValueRef *exception) { |
|
|
|
if (argumentCount != 0) |
|
|
|
if (argumentCount != 0) { |
|
|
|
return mkexception (context, exception, "Argument count not zero"); |
|
|
|
return mkexception(context, exception, "Argument count not zero"); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
lightdm_shutdown(NULL); |
|
|
|
lightdm_shutdown(NULL); |
|
|
|
return JSValueMakeNull(context); |
|
|
|
return JSValueMakeNull(context); |
|
|
@ -815,38 +847,40 @@ shutdown_cb(JSContextRef context, |
|
|
|
|
|
|
|
|
|
|
|
static JSValueRef |
|
|
|
static JSValueRef |
|
|
|
start_session_sync_cb(JSContextRef context, |
|
|
|
start_session_sync_cb(JSContextRef context, |
|
|
|
JSObjectRef function, |
|
|
|
JSObjectRef function, |
|
|
|
JSObjectRef thisObject, |
|
|
|
JSObjectRef thisObject, |
|
|
|
size_t argumentCount, |
|
|
|
size_t argumentCount, |
|
|
|
const JSValueRef arguments[], |
|
|
|
const JSValueRef arguments[], |
|
|
|
JSValueRef *exception) { |
|
|
|
JSValueRef *exception) { |
|
|
|
|
|
|
|
|
|
|
|
LightDMGreeter *greeter = JSObjectGetPrivate(thisObject); |
|
|
|
|
|
|
|
JSStringRef arg; |
|
|
|
|
|
|
|
size_t username_size, session_size; |
|
|
|
|
|
|
|
gchar *username, *session = NULL; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (!((argumentCount == 1 && JSValueGetType (context, arguments[0]) == kJSTypeString) || |
|
|
|
LightDMGreeter *greeter = JSObjectGetPrivate(thisObject); |
|
|
|
(argumentCount == 2 && JSValueGetType (context, arguments[0]) == kJSTypeString && JSValueGetType (context, arguments[1]) == kJSTypeString))) |
|
|
|
JSStringRef arg; |
|
|
|
return mkexception (context, exception, "Username or Session incorrect"); |
|
|
|
size_t username_size, session_size; |
|
|
|
|
|
|
|
gchar *username, *session = NULL; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (!(( argumentCount == 1 && JSValueGetType(context, arguments[0]) == kJSTypeString ) || |
|
|
|
|
|
|
|
( argumentCount == 2 && JSValueGetType(context, arguments[0]) == kJSTypeString |
|
|
|
|
|
|
|
&& JSValueGetType(context, arguments[1]) == kJSTypeString ))) { |
|
|
|
|
|
|
|
return mkexception(context, exception, "Username or Session incorrect"); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
arg = JSValueToStringCopy(context, arguments[0], NULL); |
|
|
|
arg = JSValueToStringCopy(context, arguments[0], NULL); |
|
|
|
username_size = JSStringGetMaximumUTF8CStringSize(arg); |
|
|
|
username_size = JSStringGetMaximumUTF8CStringSize(arg); |
|
|
|
username = g_malloc (username_size); |
|
|
|
username = g_malloc(username_size); |
|
|
|
JSStringGetUTF8CString(arg, username, username_size); |
|
|
|
JSStringGetUTF8CString(arg, username, username_size); |
|
|
|
JSStringRelease(arg); |
|
|
|
JSStringRelease(arg); |
|
|
|
|
|
|
|
|
|
|
|
if (argumentCount > 1) { |
|
|
|
if (argumentCount > 1) { |
|
|
|
arg = JSValueToStringCopy(context, arguments[1], NULL); |
|
|
|
arg = JSValueToStringCopy(context, arguments[1], NULL); |
|
|
|
session_size = JSStringGetMaximumUTF8CStringSize(arg); |
|
|
|
session_size = JSStringGetMaximumUTF8CStringSize(arg); |
|
|
|
session = g_malloc (session_size); |
|
|
|
session = g_malloc(session_size); |
|
|
|
JSStringGetUTF8CString(arg, session, session_size); |
|
|
|
JSStringGetUTF8CString(arg, session, session_size); |
|
|
|
JSStringRelease(arg); |
|
|
|
JSStringRelease(arg); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
lightdm_greeter_start_session_sync(greeter, session, NULL); |
|
|
|
lightdm_greeter_start_session_sync(greeter, session, NULL); |
|
|
|
|
|
|
|
|
|
|
|
g_free(username); |
|
|
|
g_free(username); |
|
|
|
g_free(session); |
|
|
|
g_free(session); |
|
|
|
|
|
|
|
|
|
|
|
return JSValueMakeNull(context); |
|
|
|
return JSValueMakeNull(context); |
|
|
@ -862,22 +896,23 @@ set_language_cb(JSContextRef context, |
|
|
|
JSValueRef *exception) { |
|
|
|
JSValueRef *exception) { |
|
|
|
|
|
|
|
|
|
|
|
LightDMGreeter *greeter = JSObjectGetPrivate(thisObject); |
|
|
|
LightDMGreeter *greeter = JSObjectGetPrivate(thisObject); |
|
|
|
JSStringRef arg; |
|
|
|
JSStringRef arg; |
|
|
|
size_t language_size; |
|
|
|
size_t language_size; |
|
|
|
gchar *language; |
|
|
|
gchar *language; |
|
|
|
|
|
|
|
|
|
|
|
if (!(argumentCount == 1 && JSValueGetType (context, arguments[0]) == kJSTypeString)) |
|
|
|
if (!( argumentCount == 1 && JSValueGetType(context, arguments[0]) == kJSTypeString )) { |
|
|
|
return mkexception (context, exception, "Language not supplied"); |
|
|
|
return mkexception(context, exception, "Language not supplied"); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
arg = JSValueToStringCopy(context, arguments[0], NULL); |
|
|
|
arg = JSValueToStringCopy(context, arguments[0], NULL); |
|
|
|
language_size = JSStringGetMaximumUTF8CStringSize(arg); |
|
|
|
language_size = JSStringGetMaximumUTF8CStringSize(arg); |
|
|
|
language = g_malloc (language_size); |
|
|
|
language = g_malloc(language_size); |
|
|
|
JSStringGetUTF8CString(arg, language, language_size); |
|
|
|
JSStringGetUTF8CString(arg, language, language_size); |
|
|
|
JSStringRelease(arg); |
|
|
|
JSStringRelease(arg); |
|
|
|
|
|
|
|
|
|
|
|
lightdm_greeter_set_language(greeter, language); |
|
|
|
lightdm_greeter_set_language(greeter, language); |
|
|
|
|
|
|
|
|
|
|
|
g_free (language); |
|
|
|
g_free(language); |
|
|
|
return JSValueMakeNull(context); |
|
|
|
return JSValueMakeNull(context); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -891,23 +926,24 @@ gettext_cb(JSContextRef context, |
|
|
|
JSValueRef *exception) { |
|
|
|
JSValueRef *exception) { |
|
|
|
|
|
|
|
|
|
|
|
JSStringRef string_arg, text; |
|
|
|
JSStringRef string_arg, text; |
|
|
|
size_t string_size; |
|
|
|
size_t string_size; |
|
|
|
gchar *string; |
|
|
|
gchar *string; |
|
|
|
JSValueRef result; |
|
|
|
JSValueRef result; |
|
|
|
|
|
|
|
|
|
|
|
if (!(argumentCount == 1 && JSValueGetType (context, arguments[0]) == kJSTypeString)) |
|
|
|
if (!( argumentCount == 1 && JSValueGetType(context, arguments[0]) == kJSTypeString )) { |
|
|
|
return mkexception (context, exception, "Argument not supplied"); |
|
|
|
return mkexception(context, exception, "Argument not supplied"); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
string_arg = JSValueToStringCopy(context, arguments[0], NULL); |
|
|
|
string_arg = JSValueToStringCopy(context, arguments[0], NULL); |
|
|
|
string_size = JSStringGetMaximumUTF8CStringSize(string_arg); |
|
|
|
string_size = JSStringGetMaximumUTF8CStringSize(string_arg); |
|
|
|
string = g_malloc (string_size); |
|
|
|
string = g_malloc(string_size); |
|
|
|
JSStringGetUTF8CString(string_arg, string, string_size); |
|
|
|
JSStringGetUTF8CString(string_arg, string, string_size); |
|
|
|
JSStringRelease(string_arg); |
|
|
|
JSStringRelease(string_arg); |
|
|
|
|
|
|
|
|
|
|
|
text = JSStringCreateWithUTF8CString(gettext(string)); |
|
|
|
text = JSStringCreateWithUTF8CString(gettext(string)); |
|
|
|
g_free (string); |
|
|
|
g_free(string); |
|
|
|
result = JSValueMakeString(context, text); |
|
|
|
result = JSValueMakeString(context, text); |
|
|
|
JSStringRelease (text); |
|
|
|
JSStringRelease(text); |
|
|
|
|
|
|
|
|
|
|
|
return result; |
|
|
|
return result; |
|
|
|
} |
|
|
|
} |
|
|
@ -921,34 +957,35 @@ ngettext_cb(JSContextRef context, |
|
|
|
const JSValueRef arguments[], |
|
|
|
const JSValueRef arguments[], |
|
|
|
JSValueRef *exception) { |
|
|
|
JSValueRef *exception) { |
|
|
|
|
|
|
|
|
|
|
|
JSStringRef string_arg, plural_string_arg, text; |
|
|
|
JSStringRef string_arg, plural_string_arg, text; |
|
|
|
size_t string_size, plural_string_size; |
|
|
|
size_t string_size, plural_string_size; |
|
|
|
gchar *string, *plural_string; |
|
|
|
gchar *string, *plural_string; |
|
|
|
unsigned int n; |
|
|
|
unsigned int n; |
|
|
|
JSValueRef result; |
|
|
|
JSValueRef result; |
|
|
|
|
|
|
|
|
|
|
|
if (argumentCount != 3) |
|
|
|
if (argumentCount != 3) { |
|
|
|
return mkexception (context, exception, "Needs 3 arguments"); |
|
|
|
return mkexception(context, exception, "Needs 3 arguments"); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
string_arg = JSValueToStringCopy(context, arguments[0], NULL); |
|
|
|
string_arg = JSValueToStringCopy(context, arguments[0], NULL); |
|
|
|
string_size = JSStringGetMaximumUTF8CStringSize(string_arg); |
|
|
|
string_size = JSStringGetMaximumUTF8CStringSize(string_arg); |
|
|
|
string = g_malloc (string_size); |
|
|
|
string = g_malloc(string_size); |
|
|
|
JSStringGetUTF8CString(string_arg, string, string_size); |
|
|
|
JSStringGetUTF8CString(string_arg, string, string_size); |
|
|
|
JSStringRelease(string_arg); |
|
|
|
JSStringRelease(string_arg); |
|
|
|
|
|
|
|
|
|
|
|
plural_string_arg = JSValueToStringCopy(context, arguments[1], NULL); |
|
|
|
plural_string_arg = JSValueToStringCopy(context, arguments[1], NULL); |
|
|
|
plural_string_size = JSStringGetMaximumUTF8CStringSize(plural_string_arg); |
|
|
|
plural_string_size = JSStringGetMaximumUTF8CStringSize(plural_string_arg); |
|
|
|
plural_string = g_malloc (plural_string_size); |
|
|
|
plural_string = g_malloc(plural_string_size); |
|
|
|
JSStringGetUTF8CString(plural_string_arg, string, plural_string_size); |
|
|
|
JSStringGetUTF8CString(plural_string_arg, string, plural_string_size); |
|
|
|
JSStringRelease(plural_string_arg); |
|
|
|
JSStringRelease(plural_string_arg); |
|
|
|
|
|
|
|
|
|
|
|
n = JSValueToNumber(context, arguments[2], NULL); |
|
|
|
n = JSValueToNumber(context, arguments[2], NULL); |
|
|
|
|
|
|
|
|
|
|
|
text = JSStringCreateWithUTF8CString(ngettext(string, plural_string, n)); |
|
|
|
text = JSStringCreateWithUTF8CString(ngettext(string, plural_string, n)); |
|
|
|
g_free (string); |
|
|
|
g_free(string); |
|
|
|
g_free (plural_string); |
|
|
|
g_free(plural_string); |
|
|
|
result = JSValueMakeString(context, text); |
|
|
|
result = JSValueMakeString(context, text); |
|
|
|
JSStringRelease (text); |
|
|
|
JSStringRelease(text); |
|
|
|
|
|
|
|
|
|
|
|
return result; |
|
|
|
return result; |
|
|
|
} |
|
|
|
} |
|
|
@ -1106,24 +1143,24 @@ window_object_cleared_callback(WebKitScriptWorld *world, |
|
|
|
WebKitWebPage *web_page, |
|
|
|
WebKitWebPage *web_page, |
|
|
|
WebKitFrame *frame, |
|
|
|
WebKitFrame *frame, |
|
|
|
LightDMGreeter *greeter) { |
|
|
|
LightDMGreeter *greeter) { |
|
|
|
JSObjectRef gettext_object, lightdm_greeter_object; |
|
|
|
JSObjectRef gettext_object, lightdm_greeter_object; |
|
|
|
JSGlobalContextRef jsContext; |
|
|
|
JSGlobalContextRef jsContext; |
|
|
|
JSObjectRef globalObject; |
|
|
|
JSObjectRef globalObject; |
|
|
|
WebKitDOMDocument *dom_document; |
|
|
|
WebKitDOMDocument *dom_document; |
|
|
|
WebKitDOMDOMWindow *dom_window; |
|
|
|
WebKitDOMDOMWindow *dom_window; |
|
|
|
gchar *message = "LockHint"; |
|
|
|
gchar *message = "LockHint"; |
|
|
|
|
|
|
|
|
|
|
|
page_id = webkit_web_page_get_id(web_page); |
|
|
|
page_id = webkit_web_page_get_id(web_page); |
|
|
|
|
|
|
|
|
|
|
|
jsContext = webkit_frame_get_javascript_context_for_script_world(frame, world); |
|
|
|
jsContext = webkit_frame_get_javascript_context_for_script_world(frame, world); |
|
|
|
globalObject = JSContextGetGlobalObject(jsContext); |
|
|
|
globalObject = JSContextGetGlobalObject(jsContext); |
|
|
|
|
|
|
|
|
|
|
|
gettext_class = JSClassCreate(&gettext_definition); |
|
|
|
gettext_class = JSClassCreate(&gettext_definition); |
|
|
|
lightdm_greeter_class = JSClassCreate(&lightdm_greeter_definition); |
|
|
|
lightdm_greeter_class = JSClassCreate(&lightdm_greeter_definition); |
|
|
|
lightdm_user_class = JSClassCreate(&lightdm_user_definition); |
|
|
|
lightdm_user_class = JSClassCreate(&lightdm_user_definition); |
|
|
|
lightdm_language_class = JSClassCreate(&lightdm_language_definition); |
|
|
|
lightdm_language_class = JSClassCreate(&lightdm_language_definition); |
|
|
|
lightdm_layout_class = JSClassCreate(&lightdm_layout_definition); |
|
|
|
lightdm_layout_class = JSClassCreate(&lightdm_layout_definition); |
|
|
|
lightdm_session_class = JSClassCreate(&lightdm_session_definition); |
|
|
|
lightdm_session_class = JSClassCreate(&lightdm_session_definition); |
|
|
|
|
|
|
|
|
|
|
|
gettext_object = JSObjectMake(jsContext, gettext_class, NULL); |
|
|
|
gettext_object = JSObjectMake(jsContext, gettext_class, NULL); |
|
|
|
JSObjectSetProperty(jsContext, |
|
|
|
JSObjectSetProperty(jsContext, |
|
|
@ -1144,7 +1181,7 @@ window_object_cleared_callback(WebKitScriptWorld *world, |
|
|
|
// If lightdm was started as a lock-screen, send signal to our UI process.
|
|
|
|
// If lightdm was started as a lock-screen, send signal to our UI process.
|
|
|
|
if (lightdm_greeter_get_lock_hint(greeter)) { |
|
|
|
if (lightdm_greeter_get_lock_hint(greeter)) { |
|
|
|
dom_document = webkit_web_page_get_dom_document(web_page); |
|
|
|
dom_document = webkit_web_page_get_dom_document(web_page); |
|
|
|
dom_window = webkit_dom_document_get_default_view(dom_document); |
|
|
|
dom_window = webkit_dom_document_get_default_view(dom_document); |
|
|
|
|
|
|
|
|
|
|
|
if (dom_window) { |
|
|
|
if (dom_window) { |
|
|
|
webkit_dom_dom_window_webkit_message_handlers_post_message(dom_window, "GreeterBridge", message); |
|
|
|
webkit_dom_dom_window_webkit_message_handlers_post_message(dom_window, "GreeterBridge", message); |
|
|
@ -1160,13 +1197,13 @@ show_prompt_cb(LightDMGreeter *greeter, |
|
|
|
LightDMPromptType type, |
|
|
|
LightDMPromptType type, |
|
|
|
WebKitWebExtension *extension) { |
|
|
|
WebKitWebExtension *extension) { |
|
|
|
|
|
|
|
|
|
|
|
WebKitWebPage *web_page; |
|
|
|
WebKitWebPage *web_page; |
|
|
|
WebKitFrame *web_frame; |
|
|
|
WebKitFrame *web_frame; |
|
|
|
JSGlobalContextRef jsContext; |
|
|
|
JSGlobalContextRef jsContext; |
|
|
|
JSStringRef command; |
|
|
|
JSStringRef command; |
|
|
|
gchar *string; |
|
|
|
gchar *string; |
|
|
|
gchar *etext; |
|
|
|
gchar *etext; |
|
|
|
const gchar *ct = ""; |
|
|
|
const gchar *ct = ""; |
|
|
|
|
|
|
|
|
|
|
|
web_page = webkit_web_extension_get_page(extension, page_id); |
|
|
|
web_page = webkit_web_extension_get_page(extension, page_id); |
|
|
|
|
|
|
|
|
|
|
@ -1175,23 +1212,23 @@ show_prompt_cb(LightDMGreeter *greeter, |
|
|
|
|
|
|
|
|
|
|
|
jsContext = webkit_frame_get_javascript_global_context(web_frame); |
|
|
|
jsContext = webkit_frame_get_javascript_global_context(web_frame); |
|
|
|
|
|
|
|
|
|
|
|
switch (type) { |
|
|
|
switch (type) { |
|
|
|
case LIGHTDM_PROMPT_TYPE_QUESTION: |
|
|
|
case LIGHTDM_PROMPT_TYPE_QUESTION: |
|
|
|
ct = "text"; |
|
|
|
ct = "text"; |
|
|
|
break; |
|
|
|
break; |
|
|
|
case LIGHTDM_PROMPT_TYPE_SECRET: |
|
|
|
case LIGHTDM_PROMPT_TYPE_SECRET: |
|
|
|
ct = "password"; |
|
|
|
ct = "password"; |
|
|
|
break; |
|
|
|
break; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
etext = escape (text); |
|
|
|
etext = escape(text); |
|
|
|
string = g_strdup_printf ("show_prompt('%s', '%s')", etext, ct); |
|
|
|
string = g_strdup_printf("show_prompt('%s', '%s')", etext, ct); |
|
|
|
command = JSStringCreateWithUTF8CString(string); |
|
|
|
command = JSStringCreateWithUTF8CString(string); |
|
|
|
|
|
|
|
|
|
|
|
JSEvaluateScript(jsContext, command, NULL, NULL, 0, NULL); |
|
|
|
JSEvaluateScript(jsContext, command, NULL, NULL, 0, NULL); |
|
|
|
|
|
|
|
|
|
|
|
g_free(string); |
|
|
|
g_free(string); |
|
|
|
g_free(etext); |
|
|
|
g_free(etext); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -1202,13 +1239,13 @@ show_message_cb(LightDMGreeter *greeter, |
|
|
|
LightDMMessageType type, |
|
|
|
LightDMMessageType type, |
|
|
|
WebKitWebExtension *extension) { |
|
|
|
WebKitWebExtension *extension) { |
|
|
|
|
|
|
|
|
|
|
|
WebKitWebPage *web_page; |
|
|
|
WebKitWebPage *web_page; |
|
|
|
WebKitFrame *web_frame; |
|
|
|
WebKitFrame *web_frame; |
|
|
|
JSGlobalContextRef jsContext; |
|
|
|
JSGlobalContextRef jsContext; |
|
|
|
JSStringRef command; |
|
|
|
JSStringRef command; |
|
|
|
gchar *etext; |
|
|
|
gchar *etext; |
|
|
|
gchar *string; |
|
|
|
gchar *string; |
|
|
|
const gchar *mt = ""; |
|
|
|
const gchar *mt = ""; |
|
|
|
|
|
|
|
|
|
|
|
web_page = webkit_web_extension_get_page(extension, page_id); |
|
|
|
web_page = webkit_web_extension_get_page(extension, page_id); |
|
|
|
if (web_page != NULL) { |
|
|
|
if (web_page != NULL) { |
|
|
@ -1216,17 +1253,17 @@ show_message_cb(LightDMGreeter *greeter, |
|
|
|
|
|
|
|
|
|
|
|
jsContext = webkit_frame_get_javascript_global_context(web_frame); |
|
|
|
jsContext = webkit_frame_get_javascript_global_context(web_frame); |
|
|
|
|
|
|
|
|
|
|
|
switch (type) { |
|
|
|
switch (type) { |
|
|
|
case LIGHTDM_MESSAGE_TYPE_ERROR: |
|
|
|
case LIGHTDM_MESSAGE_TYPE_ERROR: |
|
|
|
mt = "error"; |
|
|
|
mt = "error"; |
|
|
|
break; |
|
|
|
break; |
|
|
|
case LIGHTDM_MESSAGE_TYPE_INFO: |
|
|
|
case LIGHTDM_MESSAGE_TYPE_INFO: |
|
|
|
mt = "info"; |
|
|
|
mt = "info"; |
|
|
|
break; |
|
|
|
break; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
etext = escape (text); |
|
|
|
etext = escape(text); |
|
|
|
string = g_strdup_printf ("show_prompt('%s', '%s')", etext, mt); |
|
|
|
string = g_strdup_printf("show_prompt('%s', '%s')", etext, mt); |
|
|
|
command = JSStringCreateWithUTF8CString(string); |
|
|
|
command = JSStringCreateWithUTF8CString(string); |
|
|
|
|
|
|
|
|
|
|
|
JSEvaluateScript(jsContext, command, NULL, NULL, 0, NULL); |
|
|
|
JSEvaluateScript(jsContext, command, NULL, NULL, 0, NULL); |
|
|
@ -1240,10 +1277,10 @@ show_message_cb(LightDMGreeter *greeter, |
|
|
|
static void |
|
|
|
static void |
|
|
|
authentication_complete_cb(LightDMGreeter *greeter, WebKitWebExtension *extension) { |
|
|
|
authentication_complete_cb(LightDMGreeter *greeter, WebKitWebExtension *extension) { |
|
|
|
|
|
|
|
|
|
|
|
WebKitWebPage *web_page; |
|
|
|
WebKitWebPage *web_page; |
|
|
|
WebKitFrame *web_frame; |
|
|
|
WebKitFrame *web_frame; |
|
|
|
JSGlobalContextRef jsContext; |
|
|
|
JSGlobalContextRef jsContext; |
|
|
|
JSStringRef command; |
|
|
|
JSStringRef command; |
|
|
|
|
|
|
|
|
|
|
|
web_page = webkit_web_extension_get_page(extension, page_id); |
|
|
|
web_page = webkit_web_extension_get_page(extension, page_id); |
|
|
|
|
|
|
|
|
|
|
@ -1258,13 +1295,14 @@ authentication_complete_cb(LightDMGreeter *greeter, WebKitWebExtension *extensio |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static void |
|
|
|
static void |
|
|
|
autologin_timer_expired_cb(LightDMGreeter *greeter, WebKitWebExtension *extension) { |
|
|
|
autologin_timer_expired_cb(LightDMGreeter *greeter, WebKitWebExtension *extension) { |
|
|
|
|
|
|
|
|
|
|
|
WebKitWebPage *web_page; |
|
|
|
WebKitWebPage *web_page; |
|
|
|
WebKitFrame *web_frame; |
|
|
|
WebKitFrame *web_frame; |
|
|
|
JSGlobalContextRef jsContext; |
|
|
|
JSGlobalContextRef jsContext; |
|
|
|
JSStringRef command; |
|
|
|
JSStringRef command; |
|
|
|
|
|
|
|
|
|
|
|
web_page = webkit_web_extension_get_page(extension, page_id); |
|
|
|
web_page = webkit_web_extension_get_page(extension, page_id); |
|
|
|
|
|
|
|
|
|
|
|