Browse Source

few small changes to man page verbiage

sisyphus
Dustin Falgout 9 years ago
parent
commit
2100d137c3
  1. 15
      man/lightdm-webkit2-greeter.1
  2. 622
      src/lightdm-webkit2-greeter-ext.c
  3. 4
      themes/simple/index.html

15
man/lightdm-webkit2-greeter.1

@ -50,11 +50,11 @@ expired\&. The greeter should reset the authentication process\&.
The following functions are available for the greeter to call to execute The following functions are available for the greeter to call to execute
actions within LightDM\&. actions within LightDM\&.
.PP .PP
\fBlightdm\&.authenticate(name)\fR \fBlightdm\&.authenticate(username)\fR
.RS 4 .RS 4
Specifies the name of the user we'd like to start authenticating as\&. Note that Specifies the username of the user we'd like to start authenticating as\&. Note that
if you pass an empty string (""), LightDM (via PAM) will issue a show_prompt() if you call lightdm.authenticate with no argument, LightDM (via PAM) will issue
call to ask for the username\&. The older function a show_prompt() call to ask for the username\&. The older function
lightdm\&.start_authentication() has been deprecated\&. lightdm\&.start_authentication() has been deprecated\&.
.RE .RE
.PP .PP
@ -85,11 +85,12 @@ Returns the value of a named hint provided by LightDM\&.
Hibernates the system, if the greeter has the authority to do so\&. Hibernates the system, if the greeter has the authority to do so\&.
.RE .RE
.PP .PP
\fBlightdm\&.start_session_sync(user, session)\fR \fBlightdm\&.start_session_sync(session)\fR
.RS 4 .RS 4
Once LightDM has successfully authenticated the user, start the user's session Once LightDM has successfully authenticated the user, start the user's session
by calling this function\&. "user" is the authenticated user, and "session" is by calling this function\&. "session" is the authenticated user's session\&.
the user's session\&. The older function lightdm\&.login() has been If no session is passed, start the authenticated user with the system default
session. The older function lightdm\&.login(user, session) has been
deprecated\&. deprecated\&.
.RE .RE
.PP .PP

622
src/lightdm-webkit2-greeter-ext.c

@ -47,6 +47,12 @@ G_MODULE_EXPORT void webkit_web_extension_initialize(WebKitWebExtension *extensi
guint64 page_id = -1; guint64 page_id = -1;
#define USER ((LightDMUser *) JSObjectGetPrivate (thisObject))
#define LANGUAGE ((LightDMLanguage *)JSObjectGetPrivate (thisObject))
#define LAYOUT ((LightDMLayout *) JSObjectGetPrivate (thisObject))
#define SESSION ((LightDMSession *) JSObjectGetPrivate (thisObject))
#define GREETER ((LightDMGreeter *) JSObjectGetPrivate (thisObject))
static JSClassRef static JSClassRef
lightdm_greeter_class, lightdm_greeter_class,
gettext_class, gettext_class,
@ -56,6 +62,14 @@ static JSClassRef
lightdm_session_class; lightdm_session_class;
/*
* string_or_null.
*
* When passed a const gchar string, either return a JSValueRef string, or a
* JSValueRef Null reference if the string is NULL. Used to ensure functions
* return proper string args.
*/
static JSValueRef static JSValueRef
string_or_null(JSContextRef context, const gchar *str) { string_or_null(JSContextRef context, const gchar *str) {
JSValueRef result; JSValueRef result;
@ -72,16 +86,66 @@ string_or_null(JSContextRef context, const gchar *str) {
return result; return result;
} }
/*
* mkexception
*
* Convert a const string to an exception which can be passed back to webkit.
*/
static void
_mkexception (JSContextRef context, JSValueRef * exception, const gchar * str) {
JSValueRef result;
JSStringRef string = JSStringCreateWithUTF8CString (str);
JSValueRef exceptionString = JSValueMakeString (context, string);
JSStringRelease (string);
result = JSValueToObject (context, exceptionString, exception);
if (result != NULL)
*exception = 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); _mkexception (context, exception, str);
JSValueRef exceptionString = JSValueMakeString(context, string); return JSValueMakeNull (context);
JSStringRelease(string); }
*exception = JSValueToObject(context, exceptionString, NULL);
return JSValueMakeNull(context); /*
* arg_to_string
*
* Convert an JSValueRef argument to a g_malloc'd gchar string. Calling function
* is responsible for g_freeing the string.
*/
static gchar *
arg_to_string (JSContextRef context, JSValueRef arg, JSValueRef * exception) {
JSStringRef string;
size_t size;
gchar *result;
if (JSValueGetType (context, arg) != kJSTypeString) {
_mkexception (context, exception, "Expected a string");
return NULL;
}
string = JSValueToStringCopy (context, arg, exception);
if (!string)
return NULL;
size = JSStringGetMaximumUTF8CStringSize (string);
result = g_malloc (size);
if (!result)
return NULL;
JSStringGetUTF8CString (string, result, size);
JSStringRelease (string);
return result;
} }
/*
* escape
*
* Simple escape function to make sure strings have any single quote characters
* escaped.
*/
static char * static char *
escape(const gchar *text) { escape(const gchar *text) {
@ -123,8 +187,7 @@ get_user_name_cb(JSContextRef context,
JSObjectRef thisObject, JSObjectRef thisObject,
JSStringRef propertyName, JSStringRef propertyName,
JSValueRef *exception) { JSValueRef *exception) {
LightDMUser *user = JSObjectGetPrivate(thisObject); return string_or_null(context, lightdm_user_get_name(USER));
return string_or_null(context, lightdm_user_get_name(user));
} }
@ -133,8 +196,7 @@ get_user_real_name_cb(JSContextRef context,
JSObjectRef thisObject, JSObjectRef thisObject,
JSStringRef propertyName, JSStringRef propertyName,
JSValueRef *exception) { JSValueRef *exception) {
LightDMUser *user = JSObjectGetPrivate(thisObject); return string_or_null(context, lightdm_user_get_real_name(USER));
return string_or_null(context, lightdm_user_get_real_name(user));
} }
@ -143,18 +205,16 @@ get_user_display_name_cb(JSContextRef context,
JSObjectRef thisObject, JSObjectRef thisObject,
JSStringRef propertyName, JSStringRef propertyName,
JSValueRef *exception) { JSValueRef *exception) {
LightDMUser *user = JSObjectGetPrivate(thisObject); return string_or_null(context, lightdm_user_get_display_name(USER));
return string_or_null(context, lightdm_user_get_display_name(user));
} }
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); return string_or_null(context, lightdm_user_get_home_directory(USER));
return string_or_null(context, lightdm_user_get_home_directory(user));
} }
@ -163,8 +223,7 @@ get_user_image_cb(JSContextRef context,
JSObjectRef thisObject, JSObjectRef thisObject,
JSStringRef propertyName, JSStringRef propertyName,
JSValueRef *exception) { JSValueRef *exception) {
LightDMUser *user = JSObjectGetPrivate(thisObject); return string_or_null(context, lightdm_user_get_image(USER));
return string_or_null(context, lightdm_user_get_image(user));
} }
@ -173,8 +232,7 @@ get_user_language_cb(JSContextRef context,
JSObjectRef thisObject, JSObjectRef thisObject,
JSStringRef propertyName, JSStringRef propertyName,
JSValueRef *exception) { JSValueRef *exception) {
LightDMUser *user = JSObjectGetPrivate(thisObject); return string_or_null(context, lightdm_user_get_language(USER));
return string_or_null(context, lightdm_user_get_language(user));
} }
@ -183,8 +241,7 @@ get_user_layout_cb(JSContextRef context,
JSObjectRef thisObject, JSObjectRef thisObject,
JSStringRef propertyName, JSStringRef propertyName,
JSValueRef *exception) { JSValueRef *exception) {
LightDMUser *user = JSObjectGetPrivate(thisObject); return string_or_null(context, lightdm_user_get_layout(USER));
return string_or_null(context, lightdm_user_get_layout(user));
} }
@ -193,8 +250,7 @@ get_user_session_cb(JSContextRef context,
JSObjectRef thisObject, JSObjectRef thisObject,
JSStringRef propertyName, JSStringRef propertyName,
JSValueRef *exception) { JSValueRef *exception) {
LightDMUser *user = JSObjectGetPrivate(thisObject); return string_or_null(context, lightdm_user_get_session(USER));
return string_or_null(context, lightdm_user_get_session(user));
} }
@ -203,8 +259,7 @@ get_user_logged_in_cb(JSContextRef context,
JSObjectRef thisObject, JSObjectRef thisObject,
JSStringRef propertyName, JSStringRef propertyName,
JSValueRef *exception) { JSValueRef *exception) {
LightDMUser *user = JSObjectGetPrivate(thisObject); return JSValueMakeBoolean(context, lightdm_user_get_logged_in(USER));
return JSValueMakeBoolean(context, lightdm_user_get_logged_in(user));
} }
@ -213,8 +268,7 @@ get_language_code_cb(JSContextRef context,
JSObjectRef thisObject, JSObjectRef thisObject,
JSStringRef propertyName, JSStringRef propertyName,
JSValueRef *exception) { JSValueRef *exception) {
LightDMLanguage *language = JSObjectGetPrivate(thisObject); return string_or_null(context, lightdm_language_get_code(LANGUAGE));
return string_or_null(context, lightdm_language_get_code(language));
} }
@ -223,8 +277,7 @@ get_language_name_cb(JSContextRef context,
JSObjectRef thisObject, JSObjectRef thisObject,
JSStringRef propertyName, JSStringRef propertyName,
JSValueRef *exception) { JSValueRef *exception) {
LightDMLanguage *language = JSObjectGetPrivate(thisObject); return string_or_null(context, lightdm_language_get_name(LANGUAGE));
return string_or_null(context, lightdm_language_get_name(language));
} }
@ -233,8 +286,7 @@ get_language_territory_cb(JSContextRef context,
JSObjectRef thisObject, JSObjectRef thisObject,
JSStringRef propertyName, JSStringRef propertyName,
JSValueRef *exception) { JSValueRef *exception) {
LightDMLanguage *language = JSObjectGetPrivate(thisObject); return string_or_null(context, lightdm_language_get_territory(LANGUAGE));
return string_or_null(context, lightdm_language_get_territory(language));
} }
@ -243,8 +295,7 @@ get_layout_name_cb(JSContextRef context,
JSObjectRef thisObject, JSObjectRef thisObject,
JSStringRef propertyName, JSStringRef propertyName,
JSValueRef *exception) { JSValueRef *exception) {
LightDMLayout *layout = JSObjectGetPrivate(thisObject); return string_or_null(context, lightdm_layout_get_name(LAYOUT));
return string_or_null(context, lightdm_layout_get_name(layout));
} }
@ -253,8 +304,7 @@ get_layout_short_description_cb(JSContextRef context,
JSObjectRef thisObject, JSObjectRef thisObject,
JSStringRef propertyName, JSStringRef propertyName,
JSValueRef *exception) { JSValueRef *exception) {
LightDMLayout *layout = JSObjectGetPrivate(thisObject); return string_or_null(context, lightdm_layout_get_short_description(LAYOUT));
return string_or_null(context, lightdm_layout_get_short_description(layout));
} }
@ -263,8 +313,7 @@ get_layout_description_cb(JSContextRef context,
JSObjectRef thisObject, JSObjectRef thisObject,
JSStringRef propertyName, JSStringRef propertyName,
JSValueRef *exception) { JSValueRef *exception) {
LightDMLayout *layout = JSObjectGetPrivate(thisObject); return string_or_null(context, lightdm_layout_get_description(LAYOUT));
return string_or_null(context, lightdm_layout_get_description(layout));
} }
@ -273,8 +322,7 @@ get_session_key_cb(JSContextRef context,
JSObjectRef thisObject, JSObjectRef thisObject,
JSStringRef propertyName, JSStringRef propertyName,
JSValueRef *exception) { JSValueRef *exception) {
LightDMSession *session = JSObjectGetPrivate(thisObject); return string_or_null(context, lightdm_session_get_key(SESSION));
return string_or_null(context, lightdm_session_get_key(session));
} }
@ -283,8 +331,7 @@ get_session_name_cb(JSContextRef context,
JSObjectRef thisObject, JSObjectRef thisObject,
JSStringRef propertyName, JSStringRef propertyName,
JSValueRef *exception) { JSValueRef *exception) {
LightDMSession *session = JSObjectGetPrivate(thisObject); return string_or_null(context, lightdm_session_get_name(SESSION));
return string_or_null(context, lightdm_session_get_name(session));
} }
@ -293,8 +340,7 @@ get_session_comment_cb(JSContextRef context,
JSObjectRef thisObject, JSObjectRef thisObject,
JSStringRef propertyName, JSStringRef propertyName,
JSValueRef *exception) { JSValueRef *exception) {
LightDMSession *session = JSObjectGetPrivate(thisObject); return string_or_null(context, lightdm_session_get_comment(SESSION));
return string_or_null(context, lightdm_session_get_comment(session));
} }
@ -336,10 +382,12 @@ get_users_cb(JSContextRef context,
args[i] = JSObjectMake(context, lightdm_user_class, user); args[i] = JSObjectMake(context, lightdm_user_class, user);
} }
array = JSObjectMakeArray(context, n_users, args, NULL); array = JSObjectMakeArray(context, n_users, args, exception);
g_free(args); g_free(args);
if (array == NULL)
return array; return JSValueMakeNull (context);
else
return array;
} }
@ -363,10 +411,12 @@ get_languages_cb(JSContextRef context,
args[i] = JSObjectMake(context, lightdm_language_class, language); args[i] = JSObjectMake(context, lightdm_language_class, language);
} }
array = JSObjectMakeArray(context, n_languages, args, NULL); array = JSObjectMakeArray(context, n_languages, args, exception);
g_free(args); g_free(args);
if (array == NULL)
return array; return JSValueMakeNull (context);
else
return array;
} }
@ -400,10 +450,12 @@ get_layouts_cb(JSContextRef context,
args[i] = JSObjectMake(context, lightdm_layout_class, layout); args[i] = JSObjectMake(context, lightdm_layout_class, layout);
} }
array = JSObjectMakeArray(context, n_layouts, args, NULL); array = JSObjectMakeArray(context, n_layouts, args, exception);
g_free(args); g_free(args);
if (array == NULL)
return array; return JSValueMakeNull (context);
else
return array;
} }
@ -422,27 +474,12 @@ set_layout_cb(JSContextRef context,
JSStringRef propertyName, JSStringRef propertyName,
JSValueRef value, JSValueRef value,
JSValueRef *exception) { JSValueRef *exception) {
JSStringRef layout_arg; gchar *layout;
size_t layout_size;
gchar *layout;
const GList *layouts, *link; const GList *layouts, *link;
if (JSValueGetType(context, value) != kJSTypeString) { layout = arg_to_string (context, value, exception);
JSStringRef string = JSStringCreateWithUTF8CString("Expected a string"); if (!layout)
JSValueRef exceptionString = JSValueMakeString(context, string);
JSStringRelease(string);
*exception = JSValueToObject(context, exceptionString, NULL);
return false; return false;
}
layout_arg = JSValueToStringCopy(context, value, NULL);
layout_size = JSStringGetMaximumUTF8CStringSize(layout_arg);
layout = g_malloc(layout_size);
JSStringGetUTF8CString(layout_arg, layout, layout_size);
JSStringRelease(layout_arg);
layouts = lightdm_get_layouts(); layouts = lightdm_get_layouts();
@ -482,10 +519,12 @@ get_sessions_cb(JSContextRef context,
args[i] = JSObjectMake(context, lightdm_session_class, session); args[i] = JSObjectMake(context, lightdm_session_class, session);
} }
array = JSObjectMakeArray(context, n_sessions, args, NULL); array = JSObjectMakeArray(context, n_sessions, args, exception);
g_free(args); g_free(args);
if (array == NULL)
return array; return JSValueMakeNull (context);
else
return array;
} }
@ -494,8 +533,7 @@ get_default_session_cb(JSContextRef context,
JSObjectRef thisObject, JSObjectRef thisObject,
JSStringRef propertyName, JSStringRef propertyName,
JSValueRef *exception) { JSValueRef *exception) {
LightDMGreeter *greeter = JSObjectGetPrivate(thisObject); return string_or_null(context, lightdm_greeter_get_default_session_hint(GREETER));
return string_or_null(context, lightdm_greeter_get_default_session_hint(greeter));
} }
@ -504,8 +542,7 @@ get_lock_hint_cb(JSContextRef context,
JSObjectRef thisObject, JSObjectRef thisObject,
JSStringRef propertyName, JSStringRef propertyName,
JSValueRef *exception) { JSValueRef *exception) {
LightDMGreeter *greeter = JSObjectGetPrivate(thisObject); return JSValueMakeBoolean(context, lightdm_greeter_get_lock_hint(GREETER));
return JSValueMakeBoolean(context, lightdm_greeter_get_lock_hint(greeter));
} }
@ -514,114 +551,72 @@ get_autologin_timeout_cb(JSContextRef context,
JSObjectRef thisObject, JSObjectRef thisObject,
JSStringRef propertyName, JSStringRef propertyName,
JSValueRef *exception) { JSValueRef *exception) {
LightDMGreeter *greeter = JSObjectGetPrivate(thisObject); return JSValueMakeNumber(context, lightdm_greeter_get_autologin_timeout_hint(GREETER));
return JSValueMakeNumber(context, lightdm_greeter_get_autologin_timeout_hint(greeter));
} }
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); lightdm_greeter_cancel_autologin(GREETER);
if (argumentCount != 0) {
return mkexception(context, exception, "Argument count not zero");
}
lightdm_greeter_cancel_autologin(greeter);
return JSValueMakeNull(context); return JSValueMakeNull(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); gchar *name = NULL;
JSStringRef name_arg;
size_t name_size;
gchar *name;
if (!( argumentCount == 1 && JSValueGetType(context, arguments[0]) == kJSTypeString )) {
return mkexception(context, exception, "Username argument not supplied");
}
name_arg = JSValueToStringCopy(context, arguments[0], NULL);
name_size = JSStringGetMaximumUTF8CStringSize(name_arg);
name = g_malloc(name_size);
JSStringGetUTF8CString(name_arg, name, name_size);
JSStringRelease(name_arg);
if (*name == '\0') { if (argumentCount > 0)
lightdm_greeter_authenticate(greeter, NULL); name = arg_to_string (context, arguments[0], exception);
} else {
lightdm_greeter_authenticate(greeter, name);
}
g_free(name); lightdm_greeter_authenticate (GREETER, name);
return JSValueMakeNull(context); g_free (name);
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); lightdm_greeter_authenticate_as_guest (GREETER);
return JSValueMakeNull (context);
if (argumentCount != 0) {
return mkexception(context, exception, "Argument count not zero");
}
lightdm_greeter_authenticate_as_guest(greeter);
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);
JSStringRef hint_arg;
size_t hint_size;
gchar *hint_name; gchar *hint_name;
JSStringRef hint;
JSValueRef result; JSValueRef result;
if (!( argumentCount == 1 && JSValueGetType(context, arguments[0]) == kJSTypeString )) { if (argumentCount != 1)
return mkexception(context, exception, "Hint argument not supplied"); return mkexception (context, exception, "Hint argument not supplied");
}
hint_arg = JSValueToStringCopy(context, arguments[0], NULL);
hint_size = JSStringGetMaximumUTF8CStringSize(hint_arg);
hint_name = g_malloc(hint_size);
JSStringGetUTF8CString(hint_arg, hint_name, hint_size);
JSStringRelease(hint_arg);
hint = JSStringCreateWithUTF8CString(lightdm_greeter_get_hint(greeter, hint_name)); hint_name = arg_to_string (context, arguments[0], exception);
g_free(hint_name); if (!hint_name)
result = JSValueMakeString(context, hint); return JSValueMakeNull (context);
JSStringRelease(hint); result = string_or_null (context, lightdm_greeter_get_hint (GREETER, hint_name));
g_free (hint_name);
return result; return result;
} }
@ -629,32 +624,24 @@ get_hint_cb(JSContextRef context,
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);
JSStringRef response_arg;
size_t response_size;
gchar *response; gchar *response;
if (!( argumentCount == 1 && JSValueGetType(context, arguments[0]) == kJSTypeString )) { if (argumentCount != 1)
return mkexception(context, exception, "Response not supplied"); return mkexception (context, exception, "Response not supplied");
}
response_arg = JSValueToStringCopy(context, arguments[0], NULL);
response_size = JSStringGetMaximumUTF8CStringSize(response_arg);
response = g_malloc(response_size);
JSStringGetUTF8CString(response_arg, response, response_size); response = arg_to_string (context, arguments[0], exception);
JSStringRelease(response_arg); if (!response)
return JSValueMakeNull (context);
lightdm_greeter_respond(greeter, response); lightdm_greeter_respond (GREETER, response);
g_free(response);
return JSValueMakeNull(context); g_free (response);
return JSValueMakeNull (context);
} }
@ -665,15 +652,7 @@ cancel_authentication_cb(JSContextRef context,
size_t argumentCount, size_t argumentCount,
const JSValueRef arguments[], const JSValueRef arguments[],
JSValueRef *exception) { JSValueRef *exception) {
lightdm_greeter_cancel_authentication(GREETER);
LightDMGreeter *greeter = JSObjectGetPrivate(thisObject);
if (argumentCount != 0) {
return mkexception(context, exception, "Argument count not zero");
}
lightdm_greeter_cancel_authentication(greeter);
return JSValueMakeNull(context); return JSValueMakeNull(context);
} }
@ -683,80 +662,61 @@ get_authentication_user_cb(JSContextRef context,
JSObjectRef thisObject, JSObjectRef thisObject,
JSStringRef propertyName, JSStringRef propertyName,
JSValueRef *exception) { JSValueRef *exception) {
LightDMGreeter *greeter = JSObjectGetPrivate(thisObject); 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) {
return JSValueMakeBoolean (context, lightdm_greeter_get_has_guest_account_hint (GREETER));
LightDMGreeter *greeter = JSObjectGetPrivate(thisObject);
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) {
return JSValueMakeBoolean (context, lightdm_greeter_get_hide_users_hint (GREETER));
LightDMGreeter *greeter = JSObjectGetPrivate(thisObject);
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) {
return string_or_null (context, lightdm_greeter_get_select_user_hint (GREETER));
LightDMGreeter *greeter = JSObjectGetPrivate(thisObject);
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) {
return JSValueMakeBoolean (context, lightdm_greeter_get_select_guest_hint (GREETER));
LightDMGreeter *greeter = JSObjectGetPrivate(thisObject);
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) {
return string_or_null (context, lightdm_greeter_get_autologin_user_hint (GREETER));
LightDMGreeter *greeter = JSObjectGetPrivate(thisObject);
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) {
return JSValueMakeBoolean (context, lightdm_greeter_get_autologin_guest_hint (GREETER));
LightDMGreeter *greeter = JSObjectGetPrivate(thisObject);
return JSValueMakeBoolean(context, lightdm_greeter_get_autologin_guest_hint(greeter));
} }
@ -765,22 +725,16 @@ get_is_authenticated_cb(JSContextRef context,
JSObjectRef thisObject, JSObjectRef thisObject,
JSStringRef propertyName, JSStringRef propertyName,
JSValueRef *exception) { JSValueRef *exception) {
return JSValueMakeBoolean(context, lightdm_greeter_get_is_authenticated(GREETER));
LightDMGreeter *greeter = JSObjectGetPrivate(thisObject);
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) {
return JSValueMakeBoolean(context, lightdm_greeter_get_in_authentication(GREETER));
LightDMGreeter *greeter = JSObjectGetPrivate(thisObject);
return JSValueMakeBoolean(context, lightdm_greeter_get_in_authentication(greeter));
} }
@ -801,11 +755,6 @@ suspend_cb(JSContextRef context,
size_t argumentCount, size_t argumentCount,
const JSValueRef arguments[], const JSValueRef arguments[],
JSValueRef *exception) { JSValueRef *exception) {
if (argumentCount != 0) {
return mkexception(context, exception, "Argument count not zero");
}
lightdm_suspend(NULL); lightdm_suspend(NULL);
return JSValueMakeNull(context); return JSValueMakeNull(context);
@ -829,11 +778,6 @@ hibernate_cb(JSContextRef context,
size_t argumentCount, size_t argumentCount,
const JSValueRef arguments[], const JSValueRef arguments[],
JSValueRef *exception) { JSValueRef *exception) {
if (argumentCount != 0) {
return mkexception(context, exception, "Argument count not zero");
}
lightdm_hibernate(NULL); lightdm_hibernate(NULL);
return JSValueMakeNull(context); return JSValueMakeNull(context);
@ -857,11 +801,6 @@ restart_cb(JSContextRef context,
size_t argumentCount, size_t argumentCount,
const JSValueRef arguments[], const JSValueRef arguments[],
JSValueRef *exception) { JSValueRef *exception) {
if (argumentCount != 0) {
return mkexception(context, exception, "Argument count not zero");
}
lightdm_restart(NULL); lightdm_restart(NULL);
return JSValueMakeNull(context); return JSValueMakeNull(context);
@ -885,11 +824,6 @@ shutdown_cb(JSContextRef context,
size_t argumentCount, size_t argumentCount,
const JSValueRef arguments[], const JSValueRef arguments[],
JSValueRef *exception) { JSValueRef *exception) {
if (argumentCount != 0) {
return mkexception(context, exception, "Argument count not zero");
}
lightdm_shutdown(NULL); lightdm_shutdown(NULL);
return JSValueMakeNull(context); return JSValueMakeNull(context);
@ -898,47 +832,39 @@ 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) {
gchar *session = NULL;
LightDMGreeter *greeter = JSObjectGetPrivate(thisObject); gboolean result;
JSStringRef arg; GError *err = NULL;
size_t username_size, session_size;
gchar *username, *session = NULL; /* FIXME: old API required lightdm.login(username, session), but the username
gint i, throw_exception = 0; * is never actually used. At some point, deprecate the old usage. For now,
* simply work around it. */
for(i=0; i < argumentCount; i++) {
if (JSValueGetType(context, arguments[i]) != kJSTypeString) { if (argumentCount == 1)
throw_exception = 1; session = arg_to_string (context, arguments[0], exception);
} else if (argumentCount == 2)
} session = arg_to_string (context, arguments[1], exception);
if (throw_exception) { else if (argumentCount == 0)
return mkexception(context, exception, "Username or Session incorrect"); session = NULL;
} else {
_mkexception (context, exception, "Incorrect parameters");
arg = JSValueToStringCopy(context, arguments[0], NULL); return JSValueMakeBoolean (context, FALSE);
username_size = JSStringGetMaximumUTF8CStringSize(arg);
username = g_malloc(username_size);
JSStringGetUTF8CString(arg, username, username_size);
JSStringRelease(arg);
if (argumentCount > 1) {
arg = JSValueToStringCopy(context, arguments[1], NULL);
session_size = JSStringGetMaximumUTF8CStringSize(arg);
session = g_malloc(session_size);
JSStringGetUTF8CString(arg, session, session_size);
JSStringRelease(arg);
} }
lightdm_greeter_start_session_sync(greeter, session, NULL); result = lightdm_greeter_start_session_sync (GREETER, session, &err);
g_free(username); g_free (session);
g_free(session); if (err != NULL) {
_mkexception (context, exception, err->message);
g_error_free (err);
}
return JSValueMakeNull(context); return JSValueMakeBoolean (context, result);
} }
@ -949,26 +875,19 @@ set_language_cb(JSContextRef context,
size_t argumentCount, size_t argumentCount,
const JSValueRef arguments[], const JSValueRef arguments[],
JSValueRef *exception) { JSValueRef *exception) {
LightDMGreeter *greeter = JSObjectGetPrivate(thisObject);
JSStringRef arg;
size_t language_size;
gchar *language; gchar *language;
if (!( argumentCount == 1 && JSValueGetType(context, arguments[0]) == kJSTypeString )) { if (argumentCount != 1)
return mkexception(context, exception, "Language not supplied"); return mkexception (context, exception, "Language not supplied");
}
arg = JSValueToStringCopy(context, arguments[0], NULL); language = arg_to_string (context, arguments[0], exception);
language_size = JSStringGetMaximumUTF8CStringSize(arg); if (!language)
language = g_malloc(language_size); return JSValueMakeNull (context);
JSStringGetUTF8CString(arg, language, language_size);
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);
} }
@ -979,26 +898,17 @@ gettext_cb(JSContextRef context,
size_t argumentCount, size_t argumentCount,
const JSValueRef arguments[], const JSValueRef arguments[],
JSValueRef *exception) { JSValueRef *exception) {
JSStringRef string_arg, text;
size_t string_size;
gchar *string; gchar *string;
JSValueRef result; JSValueRef result;
if (!( argumentCount == 1 && JSValueGetType(context, arguments[0]) == kJSTypeString )) { if (argumentCount != 1)
return mkexception(context, exception, "Argument not supplied"); return mkexception (context, exception, "Argument not supplied");
}
string_arg = JSValueToStringCopy(context, arguments[0], NULL);
string_size = JSStringGetMaximumUTF8CStringSize(string_arg);
string = g_malloc(string_size);
JSStringGetUTF8CString(string_arg, string, string_size);
JSStringRelease(string_arg);
text = JSStringCreateWithUTF8CString(gettext(string)); string = arg_to_string (context, arguments[0], exception);
g_free(string); if (!string)
result = JSValueMakeString(context, text); return JSValueMakeNull (context);
JSStringRelease(text); result = string_or_null (context, gettext (string));
g_free (string);
return result; return result;
} }
@ -1011,9 +921,6 @@ ngettext_cb(JSContextRef context,
size_t argumentCount, size_t argumentCount,
const JSValueRef arguments[], const JSValueRef arguments[],
JSValueRef *exception) { JSValueRef *exception) {
JSStringRef string_arg, plural_string_arg, text;
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;
@ -1022,25 +929,17 @@ ngettext_cb(JSContextRef context,
return mkexception(context, exception, "Needs 3 arguments"); return mkexception(context, exception, "Needs 3 arguments");
} }
string_arg = JSValueToStringCopy(context, arguments[0], NULL); string = arg_to_string (context, arguments[0], exception);
string_size = JSStringGetMaximumUTF8CStringSize(string_arg); if (!string)
string = g_malloc(string_size); return JSValueMakeNull (context);
JSStringGetUTF8CString(string_arg, string, string_size); plural_string = arg_to_string (context, arguments[1], exception);
JSStringRelease(string_arg); if (!plural_string)
return JSValueMakeNull (context);
n = JSValueToNumber (context, arguments[2], exception);
plural_string_arg = JSValueToStringCopy(context, arguments[1], NULL); result = string_or_null (context, ngettext (string, plural_string, n));
plural_string_size = JSStringGetMaximumUTF8CStringSize(plural_string_arg); g_free (string);
plural_string = g_malloc(plural_string_size); g_free (plural_string);
JSStringGetUTF8CString(plural_string_arg, string, plural_string_size);
JSStringRelease(plural_string_arg);
n = JSValueToNumber(context, arguments[2], NULL);
text = JSStringCreateWithUTF8CString(ngettext(string, plural_string, n));
g_free(string);
g_free(plural_string);
result = JSValueMakeString(context, text);
JSStringRelease(text);
return result; return result;
} }
@ -1114,7 +1013,7 @@ static const JSStaticFunction lightdm_greeter_functions[] = {
{"authenticate", authenticate_cb, kJSPropertyAttributeReadOnly}, {"authenticate", authenticate_cb, kJSPropertyAttributeReadOnly},
{"authenticate_as_guest", authenticate_as_guest_cb, kJSPropertyAttributeReadOnly}, {"authenticate_as_guest", authenticate_as_guest_cb, kJSPropertyAttributeReadOnly},
{"respond", respond_cb, kJSPropertyAttributeReadOnly}, {"respond", respond_cb, kJSPropertyAttributeReadOnly},
{"provide_secret", respond_cb, kJSPropertyAttributeReadOnly}, /* Deprecated */ {"provide_secret", respond_cb, kJSPropertyAttributeReadOnly}, /* Deprecated */
{"cancel_authentication", cancel_authentication_cb, kJSPropertyAttributeReadOnly}, {"cancel_authentication", cancel_authentication_cb, kJSPropertyAttributeReadOnly},
{"suspend", suspend_cb, kJSPropertyAttributeReadOnly}, {"suspend", suspend_cb, kJSPropertyAttributeReadOnly},
{"hibernate", hibernate_cb, kJSPropertyAttributeReadOnly}, {"hibernate", hibernate_cb, kJSPropertyAttributeReadOnly},
@ -1390,4 +1289,3 @@ webkit_web_extension_initialize(WebKitWebExtension *extension) {
lightdm_greeter_connect_sync(greeter, NULL); lightdm_greeter_connect_sync(greeter, NULL);
} }

4
themes/simple/index.html

@ -92,7 +92,7 @@
function authentication_complete() function authentication_complete()
{ {
if (lightdm.is_authenticated) { if (lightdm.is_authenticated) {
lightdm.start_session_sync (lightdm.authentication_user, lightdm.default_session); lightdm.start_session_sync (); // Start default session
} else { } else {
show_message ("Authentication Failed", "error"); show_message ("Authentication Failed", "error");
setTimeout (start_authentication, 3000); setTimeout (start_authentication, 3000);
@ -130,7 +130,7 @@
function start_authentication() function start_authentication()
{ {
clear_messages(); clear_messages();
lightdm.authenticate(""); // start with null userid, have pam prompt for userid. lightdm.authenticate(); // start with null userid, have pam prompt for userid.
} }
/* /*

Loading…
Cancel
Save