|
|
|
@ -1,36 +1,57 @@
|
|
|
|
|
/*
|
|
|
|
|
* lightdm-webkit2-greeter-ext.c |
|
|
|
|
* |
|
|
|
|
* Copyright (C) 2010 Robert Ancell. |
|
|
|
|
* Author: Robert Ancell <robert.ancell@canonical.com> |
|
|
|
|
* Webkit2 port: Copyright (C) 2014 Antergos |
|
|
|
|
* Copyright © 2014-2015 Antergos Developers <dev@antergos.com> |
|
|
|
|
* |
|
|
|
|
* Based on code from lightdm-webkit-greeter: |
|
|
|
|
* Copyright © 2010-2015 Robert Ancell <robert.ancell@canonical.com> |
|
|
|
|
* |
|
|
|
|
* This file is part of lightdm-webkit2-greeter. |
|
|
|
|
* |
|
|
|
|
* lightdm-webkit2-greeter is free software; you can redistribute it and/or modify |
|
|
|
|
* it under the terms of the GNU General Public License as published by |
|
|
|
|
* the Free Software Foundation; either version 3 of the License, or |
|
|
|
|
* (at your option) any later version. |
|
|
|
|
* |
|
|
|
|
* lightdm-webkit2-greeter is distributed in the hope that it will be useful, |
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
|
|
|
* GNU General Public License for more details. |
|
|
|
|
* |
|
|
|
|
* The following additional terms are in effect as per Section 7 of the license: |
|
|
|
|
* |
|
|
|
|
* The preservation of all legal notices and author attributions in |
|
|
|
|
* the material or in the Appropriate Legal Notices displayed |
|
|
|
|
* by works containing it is required. |
|
|
|
|
* |
|
|
|
|
* You should have received a copy of the GNU General Public License |
|
|
|
|
* along with lightdm-webkit2-greeter; If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
|
* |
|
|
|
|
* This program is free software: you can redistribute it and/or modify it under |
|
|
|
|
* the terms of the GNU General Public License as published by the Free Software |
|
|
|
|
* Foundation, either version 3 of the License, or (at your option) any later |
|
|
|
|
* version. See http://www.gnu.org/copyleft/gpl.html the full text of the
|
|
|
|
|
* license. |
|
|
|
|
*/ |
|
|
|
|
|
|
|
|
|
#include <stdlib.h> |
|
|
|
|
#include <config.h> |
|
|
|
|
#include <gtk/gtk.h> |
|
|
|
|
#include <glib/gi18n.h> |
|
|
|
|
|
|
|
|
|
#include <webkit2/webkit-web-extension.h> |
|
|
|
|
#define WEBKIT_DOM_USE_UNSTABLE_API |
|
|
|
|
#include <webkitdom/WebKitDOMDOMWindowUnstable.h> |
|
|
|
|
#include <JavaScriptCore/JavaScript.h> |
|
|
|
|
#include <glib/gi18n.h> |
|
|
|
|
|
|
|
|
|
#include <JavaScriptCore/JavaScript.h> |
|
|
|
|
#include <lightdm.h> |
|
|
|
|
|
|
|
|
|
#include <config.h> |
|
|
|
|
|
|
|
|
|
G_MODULE_EXPORT void |
|
|
|
|
webkit_web_extension_initialize(WebKitWebExtension *extension); |
|
|
|
|
G_MODULE_EXPORT void webkit_web_extension_initialize(WebKitWebExtension *extension); |
|
|
|
|
|
|
|
|
|
guint64 page_id = -1; |
|
|
|
|
|
|
|
|
|
static JSClassRef gettext_class; |
|
|
|
|
static JSClassRef lightdm_greeter_class, lightdm_user_class, lightdm_language_class, lightdm_layout_class, lightdm_session_class; |
|
|
|
|
static JSClassRef |
|
|
|
|
lightdm_greeter_class, |
|
|
|
|
gettext_class, |
|
|
|
|
lightdm_user_class, |
|
|
|
|
lightdm_language_class, |
|
|
|
|
lightdm_layout_class, |
|
|
|
|
lightdm_session_class; |
|
|
|
|
|
|
|
|
|
static JSValueRef |
|
|
|
|
get_user_name_cb(JSContextRef context, |
|
|
|
@ -89,8 +110,9 @@ get_user_language_cb(JSContextRef context,
|
|
|
|
|
const gchar *language = lightdm_user_get_language(user); |
|
|
|
|
JSStringRef string; |
|
|
|
|
|
|
|
|
|
if (!language) |
|
|
|
|
if (!language) { |
|
|
|
|
return JSValueMakeNull(context); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
string = JSStringCreateWithUTF8CString(language); |
|
|
|
|
return JSValueMakeString(context, string); |
|
|
|
@ -105,8 +127,9 @@ get_user_layout_cb(JSContextRef context,
|
|
|
|
|
const gchar *layout = lightdm_user_get_layout(user); |
|
|
|
|
JSStringRef string; |
|
|
|
|
|
|
|
|
|
if (!layout) |
|
|
|
|
if (!layout) { |
|
|
|
|
return JSValueMakeNull(context); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
string = JSStringCreateWithUTF8CString(layout); |
|
|
|
|
return JSValueMakeString(context, string); |
|
|
|
@ -121,8 +144,9 @@ get_user_session_cb(JSContextRef context,
|
|
|
|
|
const gchar *session = lightdm_user_get_session(user); |
|
|
|
|
JSStringRef string; |
|
|
|
|
|
|
|
|
|
if (!session) |
|
|
|
|
if (!session) { |
|
|
|
|
return JSValueMakeNull(context); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
string = JSStringCreateWithUTF8CString(session); |
|
|
|
|
return JSValueMakeString(context, string); |
|
|
|
@ -161,7 +185,6 @@ get_language_name_cb(JSContextRef context,
|
|
|
|
|
return JSValueMakeString(context, string); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static JSValueRef |
|
|
|
|
get_language_territory_cb(JSContextRef context, |
|
|
|
|
JSObjectRef thisObject, |
|
|
|
@ -282,7 +305,7 @@ get_users_cb(JSContextRef context,
|
|
|
|
|
|
|
|
|
|
users = lightdm_user_list_get_users(lightdm_user_list_get_instance()); |
|
|
|
|
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) { |
|
|
|
|
LightDMUser *user = link->data; |
|
|
|
|
g_object_ref(user); |
|
|
|
@ -306,7 +329,7 @@ get_languages_cb(JSContextRef context,
|
|
|
|
|
|
|
|
|
|
languages = lightdm_get_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) { |
|
|
|
|
LightDMLanguage *language = link->data; |
|
|
|
|
g_object_ref(language); |
|
|
|
@ -347,6 +370,7 @@ get_layouts_cb(JSContextRef context,
|
|
|
|
|
JSObjectRef thisObject, |
|
|
|
|
JSStringRef propertyName, |
|
|
|
|
JSValueRef *exception) { |
|
|
|
|
|
|
|
|
|
JSObjectRef array; |
|
|
|
|
const GList *layouts, *link; |
|
|
|
|
guint i, n_layouts = 0; |
|
|
|
@ -354,7 +378,7 @@ get_layouts_cb(JSContextRef context,
|
|
|
|
|
|
|
|
|
|
layouts = lightdm_get_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) { |
|
|
|
|
LightDMLayout *layout = link->data; |
|
|
|
|
g_object_ref(layout); |
|
|
|
@ -371,6 +395,7 @@ get_layout_cb(JSContextRef context,
|
|
|
|
|
JSObjectRef thisObject, |
|
|
|
|
JSStringRef propertyName, |
|
|
|
|
JSValueRef *exception) { |
|
|
|
|
|
|
|
|
|
JSStringRef string; |
|
|
|
|
|
|
|
|
|
string = JSStringCreateWithUTF8CString(lightdm_layout_get_name(lightdm_get_layout())); |
|
|
|
@ -388,8 +413,9 @@ set_layout_cb(JSContextRef context,
|
|
|
|
|
char layout[1024]; |
|
|
|
|
|
|
|
|
|
// FIXME: Throw exception
|
|
|
|
|
if (JSValueGetType(context, value) != kJSTypeString) |
|
|
|
|
if (JSValueGetType(context, value) != kJSTypeString) { |
|
|
|
|
return false; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
layout_arg = JSValueToStringCopy(context, value, NULL); |
|
|
|
|
JSStringGetUTF8CString(layout_arg, layout, 1024); |
|
|
|
@ -412,7 +438,7 @@ get_sessions_cb(JSContextRef context,
|
|
|
|
|
|
|
|
|
|
sessions = lightdm_get_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) { |
|
|
|
|
LightDMSession *session = link->data; |
|
|
|
|
g_object_ref(session); |
|
|
|
@ -472,8 +498,9 @@ cancel_timed_login_cb(JSContextRef context,
|
|
|
|
|
LightDMGreeter *greeter = JSObjectGetPrivate(thisObject); |
|
|
|
|
|
|
|
|
|
// FIXME: Throw exception
|
|
|
|
|
if (argumentCount != 0) |
|
|
|
|
if (argumentCount != 0) { |
|
|
|
|
return JSValueMakeNull(context); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
lightdm_greeter_cancel_autologin(greeter); |
|
|
|
|
return JSValueMakeNull(context); |
|
|
|
@ -491,8 +518,9 @@ start_authentication_cb(JSContextRef context,
|
|
|
|
|
char name[1024]; |
|
|
|
|
|
|
|
|
|
// FIXME: Throw exception
|
|
|
|
|
if (!(argumentCount == 1 && JSValueGetType(context, arguments[0]) == kJSTypeString)) |
|
|
|
|
if (!( argumentCount == 1 && JSValueGetType(context, arguments[0]) == kJSTypeString )) { |
|
|
|
|
return JSValueMakeNull(context); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
name_arg = JSValueToStringCopy(context, arguments[0], NULL); |
|
|
|
|
JSStringGetUTF8CString(name_arg, name, 1024); |
|
|
|
@ -514,8 +542,9 @@ provide_secret_cb(JSContextRef context,
|
|
|
|
|
char secret[1024]; |
|
|
|
|
|
|
|
|
|
// FIXME: Throw exception
|
|
|
|
|
if (!(argumentCount == 1 && JSValueGetType(context, arguments[0]) == kJSTypeString)) |
|
|
|
|
if (!( argumentCount == 1 && JSValueGetType(context, arguments[0]) == kJSTypeString )) { |
|
|
|
|
return JSValueMakeNull(context); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
secret_arg = JSValueToStringCopy(context, arguments[0], NULL); |
|
|
|
|
JSStringGetUTF8CString(secret_arg, secret, 1024); |
|
|
|
@ -536,8 +565,9 @@ cancel_authentication_cb(JSContextRef context,
|
|
|
|
|
LightDMGreeter *greeter = JSObjectGetPrivate(thisObject); |
|
|
|
|
|
|
|
|
|
// FIXME: Throw exception
|
|
|
|
|
if (argumentCount != 0) |
|
|
|
|
if (argumentCount != 0) { |
|
|
|
|
return JSValueMakeNull(context); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
lightdm_greeter_cancel_authentication(greeter); |
|
|
|
|
return JSValueMakeNull(context); |
|
|
|
@ -577,8 +607,9 @@ suspend_cb(JSContextRef context,
|
|
|
|
|
const JSValueRef arguments[], |
|
|
|
|
JSValueRef *exception) { |
|
|
|
|
// FIXME: Throw exception
|
|
|
|
|
if (argumentCount != 0) |
|
|
|
|
if (argumentCount != 0) { |
|
|
|
|
return JSValueMakeNull(context); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
lightdm_suspend(NULL); |
|
|
|
|
return JSValueMakeNull(context); |
|
|
|
@ -600,8 +631,9 @@ hibernate_cb(JSContextRef context,
|
|
|
|
|
const JSValueRef arguments[], |
|
|
|
|
JSValueRef *exception) { |
|
|
|
|
// FIXME: Throw exception
|
|
|
|
|
if (argumentCount != 0) |
|
|
|
|
if (argumentCount != 0) { |
|
|
|
|
return JSValueMakeNull(context); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
lightdm_hibernate(NULL); |
|
|
|
|
return JSValueMakeNull(context); |
|
|
|
@ -623,8 +655,9 @@ restart_cb(JSContextRef context,
|
|
|
|
|
const JSValueRef arguments[], |
|
|
|
|
JSValueRef *exception) { |
|
|
|
|
// FIXME: Throw exception
|
|
|
|
|
if (argumentCount != 0) |
|
|
|
|
if (argumentCount != 0) { |
|
|
|
|
return JSValueMakeNull(context); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
lightdm_restart(NULL); |
|
|
|
|
return JSValueMakeNull(context); |
|
|
|
@ -646,8 +679,9 @@ shutdown_cb(JSContextRef context,
|
|
|
|
|
const JSValueRef arguments[], |
|
|
|
|
JSValueRef *exception) { |
|
|
|
|
// FIXME: Throw exception
|
|
|
|
|
if (argumentCount != 0) |
|
|
|
|
if (argumentCount != 0) { |
|
|
|
|
return JSValueMakeNull(context); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
lightdm_shutdown(NULL); |
|
|
|
|
return JSValueMakeNull(context); |
|
|
|
@ -717,8 +751,9 @@ gettext_cb(JSContextRef context,
|
|
|
|
|
char string[1024]; |
|
|
|
|
|
|
|
|
|
// FIXME: Throw exception
|
|
|
|
|
if (argumentCount != 1) |
|
|
|
|
if (argumentCount != 1) { |
|
|
|
|
return JSValueMakeNull(context); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
string_arg = JSValueToStringCopy(context, arguments[0], NULL); |
|
|
|
|
JSStringGetUTF8CString(string_arg, string, 1024); |
|
|
|
@ -740,8 +775,9 @@ ngettext_cb(JSContextRef context,
|
|
|
|
|
unsigned int n; |
|
|
|
|
|
|
|
|
|
// FIXME: Throw exception
|
|
|
|
|
if (argumentCount != 3) |
|
|
|
|
if (argumentCount != 3) { |
|
|
|
|
return JSValueMakeNull(context); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
string_arg = JSValueToStringCopy(context, arguments[0], NULL); |
|
|
|
|
JSStringGetUTF8CString(string_arg, string, 1024); |
|
|
|
@ -757,8 +793,7 @@ ngettext_cb(JSContextRef context,
|
|
|
|
|
return JSValueMakeString(context, result); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
static const JSStaticValue lightdm_user_values[] = |
|
|
|
|
{ |
|
|
|
|
static const JSStaticValue lightdm_user_values[] = { |
|
|
|
|
{"name", get_user_name_cb, NULL, kJSPropertyAttributeReadOnly}, |
|
|
|
|
{"real_name", get_user_real_name_cb, NULL, kJSPropertyAttributeReadOnly}, |
|
|
|
|
{"display_name", get_user_display_name_cb, NULL, kJSPropertyAttributeReadOnly}, |
|
|
|
@ -767,35 +802,27 @@ static const JSStaticValue lightdm_user_values[] =
|
|
|
|
|
{"layout", get_user_layout_cb, NULL, kJSPropertyAttributeReadOnly}, |
|
|
|
|
{"session", get_user_session_cb, NULL, kJSPropertyAttributeReadOnly}, |
|
|
|
|
{"logged_in", get_user_logged_in_cb, NULL, kJSPropertyAttributeReadOnly}, |
|
|
|
|
{NULL, NULL, NULL, 0} |
|
|
|
|
}; |
|
|
|
|
{NULL, NULL, NULL, 0}}; |
|
|
|
|
|
|
|
|
|
static const JSStaticValue lightdm_language_values[] = |
|
|
|
|
{ |
|
|
|
|
static const JSStaticValue lightdm_language_values[] = { |
|
|
|
|
{"code", get_language_code_cb, NULL, kJSPropertyAttributeReadOnly}, |
|
|
|
|
{"name", get_language_name_cb, NULL, kJSPropertyAttributeReadOnly}, |
|
|
|
|
{"territory", get_language_territory_cb, NULL, kJSPropertyAttributeReadOnly}, |
|
|
|
|
{NULL, NULL, NULL, 0} |
|
|
|
|
}; |
|
|
|
|
{NULL, NULL, NULL, 0}}; |
|
|
|
|
|
|
|
|
|
static const JSStaticValue lightdm_layout_values[] = |
|
|
|
|
{ |
|
|
|
|
static const JSStaticValue lightdm_layout_values[] = { |
|
|
|
|
{"name", get_layout_name_cb, NULL, kJSPropertyAttributeReadOnly}, |
|
|
|
|
{"short_description", get_layout_short_description_cb, NULL, kJSPropertyAttributeReadOnly}, |
|
|
|
|
{"description", get_layout_description_cb, NULL, kJSPropertyAttributeReadOnly}, |
|
|
|
|
{NULL, NULL, NULL, 0} |
|
|
|
|
}; |
|
|
|
|
{NULL, NULL, NULL, 0}}; |
|
|
|
|
|
|
|
|
|
static const JSStaticValue lightdm_session_values[] = |
|
|
|
|
{ |
|
|
|
|
static const JSStaticValue lightdm_session_values[] = { |
|
|
|
|
{"key", get_session_key_cb, NULL, kJSPropertyAttributeReadOnly}, |
|
|
|
|
{"name", get_session_name_cb, NULL, kJSPropertyAttributeReadOnly}, |
|
|
|
|
{"comment", get_session_comment_cb, NULL, kJSPropertyAttributeReadOnly}, |
|
|
|
|
{NULL, NULL, NULL, 0} |
|
|
|
|
}; |
|
|
|
|
{NULL, NULL, NULL, 0}}; |
|
|
|
|
|
|
|
|
|
static const JSStaticValue lightdm_greeter_values[] = |
|
|
|
|
{ |
|
|
|
|
static const JSStaticValue lightdm_greeter_values[] = { |
|
|
|
|
{"hostname", get_hostname_cb, NULL, kJSPropertyAttributeReadOnly}, |
|
|
|
|
{"users", get_users_cb, NULL, kJSPropertyAttributeReadOnly}, |
|
|
|
|
{"default_language", get_default_language_cb, NULL, kJSPropertyAttributeReadOnly}, |
|
|
|
@ -814,11 +841,9 @@ static const JSStaticValue lightdm_greeter_values[] =
|
|
|
|
|
{"can_hibernate", get_can_hibernate_cb, NULL, kJSPropertyAttributeReadOnly}, |
|
|
|
|
{"can_restart", get_can_restart_cb, NULL, kJSPropertyAttributeReadOnly}, |
|
|
|
|
{"can_shutdown", get_can_shutdown_cb, NULL, kJSPropertyAttributeReadOnly}, |
|
|
|
|
{NULL, NULL, NULL, 0} |
|
|
|
|
}; |
|
|
|
|
{NULL, NULL, NULL, 0}}; |
|
|
|
|
|
|
|
|
|
static const JSStaticFunction lightdm_greeter_functions[] = |
|
|
|
|
{ |
|
|
|
|
static const JSStaticFunction lightdm_greeter_functions[] = { |
|
|
|
|
{"cancel_timed_login", cancel_timed_login_cb, kJSPropertyAttributeReadOnly}, |
|
|
|
|
{"start_authentication", start_authentication_cb, kJSPropertyAttributeReadOnly}, |
|
|
|
|
{"provide_secret", provide_secret_cb, kJSPropertyAttributeReadOnly}, |
|
|
|
@ -828,82 +853,71 @@ static const JSStaticFunction lightdm_greeter_functions[] =
|
|
|
|
|
{"restart", restart_cb, kJSPropertyAttributeReadOnly}, |
|
|
|
|
{"shutdown", shutdown_cb, kJSPropertyAttributeReadOnly}, |
|
|
|
|
{"set_language", set_language_cb, kJSPropertyAttributeReadOnly}, |
|
|
|
|
{"login", login_cb, kJSPropertyAttributeReadOnly}, |
|
|
|
|
{NULL, NULL, 0} |
|
|
|
|
}; |
|
|
|
|
{"login", login_cb, kJSPropertyAttributeReadOnly}, {NULL, NULL, 0}}; |
|
|
|
|
|
|
|
|
|
static const JSStaticFunction gettext_functions[] = |
|
|
|
|
{ |
|
|
|
|
static const JSStaticFunction gettext_functions[] = { |
|
|
|
|
{"gettext", gettext_cb, kJSPropertyAttributeReadOnly}, |
|
|
|
|
{"ngettext", ngettext_cb, kJSPropertyAttributeReadOnly}, |
|
|
|
|
{NULL, NULL, 0} |
|
|
|
|
}; |
|
|
|
|
{NULL, NULL, 0}}; |
|
|
|
|
|
|
|
|
|
static const JSClassDefinition lightdm_user_definition = |
|
|
|
|
{ |
|
|
|
|
static const JSClassDefinition lightdm_user_definition = { |
|
|
|
|
0, /* Version */ |
|
|
|
|
kJSClassAttributeNone, /* Attributes */ |
|
|
|
|
"LightDMUser", /* Class name */ |
|
|
|
|
NULL, /* Parent class */ |
|
|
|
|
lightdm_user_values, /* Static values */ |
|
|
|
|
}; |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
static const JSClassDefinition lightdm_language_definition = |
|
|
|
|
{ |
|
|
|
|
static const JSClassDefinition lightdm_language_definition = { |
|
|
|
|
0, /* Version */ |
|
|
|
|
kJSClassAttributeNone, /* Attributes */ |
|
|
|
|
"LightDMLanguage", /* Class name */ |
|
|
|
|
NULL, /* Parent class */ |
|
|
|
|
lightdm_language_values, /* Static values */ |
|
|
|
|
}; |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
static const JSClassDefinition lightdm_layout_definition = |
|
|
|
|
{ |
|
|
|
|
static const JSClassDefinition lightdm_layout_definition = { |
|
|
|
|
0, /* Version */ |
|
|
|
|
kJSClassAttributeNone, /* Attributes */ |
|
|
|
|
"LightDMLayout", /* Class name */ |
|
|
|
|
NULL, /* Parent class */ |
|
|
|
|
lightdm_layout_values, /* Static values */ |
|
|
|
|
}; |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
static const JSClassDefinition lightdm_session_definition = |
|
|
|
|
{ |
|
|
|
|
static const JSClassDefinition lightdm_session_definition = { |
|
|
|
|
0, /* Version */ |
|
|
|
|
kJSClassAttributeNone, /* Attributes */ |
|
|
|
|
"LightDMSession", /* Class name */ |
|
|
|
|
NULL, /* Parent class */ |
|
|
|
|
lightdm_session_values, /* Static values */ |
|
|
|
|
}; |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
static const JSClassDefinition lightdm_greeter_definition = |
|
|
|
|
{ |
|
|
|
|
static const JSClassDefinition lightdm_greeter_definition = { |
|
|
|
|
0, /* Version */ |
|
|
|
|
kJSClassAttributeNone, /* Attributes */ |
|
|
|
|
"LightDMGreeter", /* Class name */ |
|
|
|
|
NULL, /* Parent class */ |
|
|
|
|
lightdm_greeter_values, /* Static values */ |
|
|
|
|
lightdm_greeter_functions, /* Static functions */ |
|
|
|
|
}; |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
static const JSClassDefinition gettext_definition = |
|
|
|
|
{ |
|
|
|
|
static const JSClassDefinition gettext_definition = { |
|
|
|
|
0, /* Version */ |
|
|
|
|
kJSClassAttributeNone, /* Attributes */ |
|
|
|
|
"GettextClass", /* Class name */ |
|
|
|
|
NULL, /* Parent class */ |
|
|
|
|
NULL, |
|
|
|
|
NULL, /* Static values */ |
|
|
|
|
gettext_functions, /* Static functions */ |
|
|
|
|
}; |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
static void |
|
|
|
|
web_page_created_callback(WebKitWebExtension *extension, |
|
|
|
|
WebKitWebPage *web_page, |
|
|
|
|
gpointer user_data) { |
|
|
|
|
/* guint64 page_id = webkit_web_page_get_id (web_page); */ |
|
|
|
|
|
|
|
|
|
web_page_created_callback(WebKitWebExtension *extension, WebKitWebPage *web_page, gpointer user_data) { |
|
|
|
|
/*@formatter:off*/ |
|
|
|
|
g_print("Page %" G_GUINT64_FORMAT "created for %s\n", |
|
|
|
|
webkit_web_page_get_id(web_page), |
|
|
|
|
webkit_web_page_get_uri(web_page)); |
|
|
|
|
webkit_web_page_get_uri(web_page) |
|
|
|
|
); |
|
|
|
|
/*@formatter:on*/ |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
static void |
|
|
|
@ -929,21 +943,21 @@ window_object_cleared_callback(WebKitScriptWorld *world,
|
|
|
|
|
|
|
|
|
|
gettext_object = JSObjectMake(jsContext, gettext_class, NULL); |
|
|
|
|
|
|
|
|
|
JSObjectSetProperty(jsContext, |
|
|
|
|
globalObject, |
|
|
|
|
JSStringCreateWithUTF8CString("gettext"), |
|
|
|
|
gettext_object, kJSPropertyAttributeNone, NULL); |
|
|
|
|
JSObjectSetProperty(jsContext, globalObject, JSStringCreateWithUTF8CString("gettext"), gettext_object, |
|
|
|
|
kJSPropertyAttributeNone, NULL); |
|
|
|
|
|
|
|
|
|
lightdm_greeter_object = JSObjectMake(jsContext, lightdm_greeter_class, greeter); |
|
|
|
|
|
|
|
|
|
JSObjectSetProperty(jsContext, |
|
|
|
|
globalObject, |
|
|
|
|
JSStringCreateWithUTF8CString("lightdm"), |
|
|
|
|
lightdm_greeter_object, kJSPropertyAttributeNone, NULL); |
|
|
|
|
JSObjectSetProperty(jsContext, globalObject, JSStringCreateWithUTF8CString("lightdm"), lightdm_greeter_object, |
|
|
|
|
kJSPropertyAttributeNone, NULL); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
static void |
|
|
|
|
show_prompt_cb(LightDMGreeter *greeter, const gchar *text, LightDMPromptType type, WebKitWebExtension *extension) { |
|
|
|
|
show_prompt_cb(LightDMGreeter *greeter, |
|
|
|
|
const gchar *text, |
|
|
|
|
LightDMPromptType type, |
|
|
|
|
WebKitWebExtension *extension) { |
|
|
|
|
|
|
|
|
|
WebKitWebPage *web_page; |
|
|
|
|
WebKitFrame *web_frame; |
|
|
|
|
JSGlobalContextRef jsContext; |
|
|
|
@ -969,7 +983,11 @@ show_prompt_cb(LightDMGreeter *greeter, const gchar *text, LightDMPromptType typ
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
static void |
|
|
|
|
show_message_cb(LightDMGreeter *greeter, const gchar *text, LightDMMessageType type, WebKitWebExtension *extension) { |
|
|
|
|
show_message_cb(LightDMGreeter *greeter, |
|
|
|
|
const gchar *text, |
|
|
|
|
LightDMMessageType type, |
|
|
|
|
WebKitWebExtension *extension) { |
|
|
|
|
|
|
|
|
|
WebKitWebPage *web_page; |
|
|
|
|
WebKitFrame *web_frame; |
|
|
|
|
JSGlobalContextRef jsContext; |
|
|
|
@ -993,6 +1011,7 @@ show_message_cb(LightDMGreeter *greeter, const gchar *text, LightDMMessageType t
|
|
|
|
|
|
|
|
|
|
static void |
|
|
|
|
authentication_complete_cb(LightDMGreeter *greeter, WebKitWebExtension *extension) { |
|
|
|
|
|
|
|
|
|
WebKitWebPage *web_page; |
|
|
|
|
WebKitFrame *web_frame; |
|
|
|
|
JSGlobalContextRef jsContext; |
|
|
|
@ -1011,7 +1030,7 @@ authentication_complete_cb(LightDMGreeter *greeter, WebKitWebExtension *extensio
|
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/*static gboolean
|
|
|
|
|
static gboolean |
|
|
|
|
fade_timer_cb(gpointer data) { |
|
|
|
|
gdouble opacity; |
|
|
|
|
|
|
|
|
@ -1031,7 +1050,8 @@ quit_cb(LightDMGreeter *greeter, const gchar *username) {
|
|
|
|
|
|
|
|
|
|
// Fade out the greeter
|
|
|
|
|
g_timeout_add(40, (GSourceFunc) fade_timer_cb, NULL); |
|
|
|
|
}*/ |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
G_MODULE_EXPORT void |
|
|
|
|
webkit_web_extension_initialize(WebKitWebExtension *extension) { |
|
|
|
@ -1042,14 +1062,15 @@ webkit_web_extension_initialize(WebKitWebExtension *extension) {
|
|
|
|
|
g_signal_connect(G_OBJECT(greeter), "authentication-complete", G_CALLBACK(authentication_complete_cb), extension); |
|
|
|
|
g_signal_connect(G_OBJECT(greeter), "show-prompt", G_CALLBACK(show_prompt_cb), extension); |
|
|
|
|
g_signal_connect(G_OBJECT(greeter), "show-message", G_CALLBACK(show_message_cb), extension); |
|
|
|
|
// g_signal_connect(G_OBJECT(greeter), "quit", G_CALLBACK(quit_cb), extension);
|
|
|
|
|
|
|
|
|
|
g_signal_connect(extension, "page-created", G_CALLBACK(web_page_created_callback), NULL); |
|
|
|
|
/* TODO: Find the best way to send quit signal to the main window from our web-extension (probably dbus).
|
|
|
|
|
* g_signal_connect(G_OBJECT(greeter), "quit", G_CALLBACK(quit_cb), extension); |
|
|
|
|
*/ |
|
|
|
|
|
|
|
|
|
/* g_signal_connect(extension, "page-created", G_CALLBACK(web_page_created_callback), NULL); */ |
|
|
|
|
|
|
|
|
|
g_signal_connect(webkit_script_world_get_default(), |
|
|
|
|
"window-object-cleared", |
|
|
|
|
G_CALLBACK(window_object_cleared_callback), |
|
|
|
|
greeter); |
|
|
|
|
g_signal_connect(webkit_script_world_get_default(), "window-object-cleared", |
|
|
|
|
G_CALLBACK(window_object_cleared_callback), greeter); |
|
|
|
|
|
|
|
|
|
lightdm_greeter_connect_sync(greeter, NULL); |
|
|
|
|
} |
|
|
|
|