Browse Source

cleanup code formatting

sisyphus
Dustin Falgout 9 years ago
parent
commit
a019b8f356
  1. 3
      .gitmodules
  2. 94
      src/lightdm-webkit2-greeter-ext.c

3
.gitmodules vendored

@ -1,6 +1,3 @@
[submodule "themes/antergos"]
path = themes/antergos
url = http://github.com/antergos/lightdm-webkit-theme-antergos.git
[submodule "themes/lightdm-webkit-theme-antergos"]
path = themes/lightdm-webkit-theme-antergos
url = http://github.com/antergos/lightdm-webkit-theme-antergos.git

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

@ -1,10 +1,13 @@
/*
* 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:
* 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.
*
@ -52,13 +55,15 @@ static JSClassRef
lightdm_layout_class,
lightdm_session_class;
static JSValueRef
string_or_null(JSContextRef context, const gchar *str) {
JSValueRef result;
JSStringRef string;
if (str == NULL)
if (str == NULL) {
return JSValueMakeNull(context);
}
string = JSStringCreateWithUTF8CString(str);
result = JSValueMakeString(context, string);
@ -67,9 +72,9 @@ string_or_null(JSContextRef context, const gchar *str) {
return result;
}
static JSValueRef
mkexception (JSContextRef context, JSValueRef * exception, const gchar * str)
{
mkexception(JSContextRef context, JSValueRef *exception, const gchar *str) {
JSStringRef string = JSStringCreateWithUTF8CString(str);
JSValueRef exceptionString = JSValueMakeString(context, string);
JSStringRelease(string);
@ -77,9 +82,9 @@ mkexception (JSContextRef context, JSValueRef * exception, const gchar * str)
return JSValueMakeNull(context);
}
static char *
escape (const gchar *text)
{
escape(const gchar *text) {
size_t len;
size_t i, j;
int count = 0;
@ -87,12 +92,15 @@ escape (const gchar *text)
len = strlen(text);
for (i = 0; i < len; i++)
if (text[i] == '\'')
for (i = 0; i < len; i++) {
if (text[i] == '\'') {
count++;
}
}
if (count == 0)
if (count == 0) {
return g_strdup(text);
}
escaped = g_malloc(len + count + 1);
@ -109,6 +117,7 @@ escape (const gchar *text)
return escaped;
}
static JSValueRef
get_user_name_cb(JSContextRef context,
JSObjectRef thisObject,
@ -148,6 +157,7 @@ get_user_home_directory_cb(JSContextRef context,
return string_or_null(context, lightdm_user_get_home_directory(user));
}
static JSValueRef
get_user_image_cb(JSContextRef context,
JSObjectRef thisObject,
@ -364,6 +374,7 @@ get_language_cb(JSContextRef context,
return string_or_null(context, lightdm_language_get_name((LightDMLanguage *) lightdm_get_language()));
}
static JSValueRef
get_layouts_cb(JSContextRef context,
JSObjectRef thisObject,
@ -425,8 +436,7 @@ set_layout_cb(JSContextRef context,
JSStringRelease(layout_arg);
layouts = lightdm_get_layouts();
for (link = layouts; link; link = link->next)
{
for (link = layouts; link; link = link->next) {
LightDMLayout *currlayout = link->data;
if (!( g_strcmp0(lightdm_layout_get_name(currlayout), layout))) {
g_object_ref(currlayout);
@ -504,8 +514,9 @@ cancel_autologin_cb(JSContextRef context,
JSValueRef *exception) {
LightDMGreeter *greeter = JSObjectGetPrivate(thisObject);
if (argumentCount != 0)
if (argumentCount != 0) {
return mkexception(context, exception, "Argument count not zero");
}
lightdm_greeter_cancel_autologin(greeter);
return JSValueMakeNull(context);
@ -524,8 +535,9 @@ authenticate_cb(JSContextRef context,
size_t name_size;
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");
}
name_arg = JSValueToStringCopy(context, arguments[0], NULL);
name_size = JSStringGetMaximumUTF8CStringSize(name_arg);
@ -533,15 +545,17 @@ authenticate_cb(JSContextRef context,
JSStringGetUTF8CString(name_arg, name, name_size);
JSStringRelease(name_arg);
if (*name == '\0')
if (*name == '\0') {
lightdm_greeter_authenticate(greeter, NULL);
else
} else {
lightdm_greeter_authenticate(greeter, name);
}
g_free(name);
return JSValueMakeNull(context);
}
static JSValueRef
authenticate_as_guest_cb(JSContextRef context,
JSObjectRef function,
@ -551,14 +565,16 @@ authenticate_as_guest_cb (JSContextRef context,
JSValueRef *exception) {
LightDMGreeter *greeter = JSObjectGetPrivate(thisObject);
if (argumentCount != 0)
if (argumentCount != 0) {
return mkexception(context, exception, "Argument count not zero");
}
lightdm_greeter_authenticate_as_guest(greeter);
return JSValueMakeNull(context);
}
static JSValueRef
get_hint_cb(JSContextRef context,
JSObjectRef function,
@ -573,8 +589,9 @@ get_hint_cb (JSContextRef context,
JSStringRef hint;
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");
}
hint_arg = JSValueToStringCopy(context, arguments[0], NULL);
hint_size = JSStringGetMaximumUTF8CStringSize(hint_arg);
@ -603,8 +620,9 @@ respond_cb(JSContextRef context,
size_t response_size;
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");
}
response_arg = JSValueToStringCopy(context, arguments[0], NULL);
response_size = JSStringGetMaximumUTF8CStringSize(response_arg);
@ -628,8 +646,9 @@ cancel_authentication_cb(JSContextRef context,
JSValueRef *exception) {
LightDMGreeter *greeter = JSObjectGetPrivate(thisObject);
if (argumentCount != 0)
if (argumentCount != 0) {
return mkexception(context, exception, "Argument count not zero");
}
lightdm_greeter_cancel_authentication(greeter);
return JSValueMakeNull(context);
@ -645,6 +664,7 @@ get_authentication_user_cb(JSContextRef context,
return string_or_null(context, lightdm_greeter_get_authentication_user(greeter));
}
static JSValueRef
get_has_guest_account_cb(JSContextRef context,
JSObjectRef thisObject,
@ -654,6 +674,7 @@ get_has_guest_account_cb (JSContextRef context,
return JSValueMakeBoolean(context, lightdm_greeter_get_has_guest_account_hint(greeter));
}
static JSValueRef
get_hide_users_cb(JSContextRef context,
JSObjectRef thisObject,
@ -663,6 +684,7 @@ get_hide_users_cb (JSContextRef context,
return JSValueMakeBoolean(context, lightdm_greeter_get_hide_users_hint(greeter));
}
static JSValueRef
get_select_user_cb(JSContextRef context,
JSObjectRef thisObject,
@ -672,6 +694,7 @@ get_select_user_cb (JSContextRef context,
return string_or_null(context, lightdm_greeter_get_select_user_hint(greeter));
}
static JSValueRef
get_select_guest_cb(JSContextRef context,
JSObjectRef thisObject,
@ -681,6 +704,7 @@ get_select_guest_cb (JSContextRef context,
return JSValueMakeBoolean(context, lightdm_greeter_get_select_guest_hint(greeter));
}
static JSValueRef
get_autologin_user_cb(JSContextRef context,
JSObjectRef thisObject,
@ -690,6 +714,7 @@ get_autologin_user_cb (JSContextRef context,
return string_or_null(context, lightdm_greeter_get_autologin_user_hint(greeter));
}
static JSValueRef
get_autologin_guest_cb(JSContextRef context,
JSObjectRef thisObject,
@ -699,6 +724,7 @@ get_autologin_guest_cb (JSContextRef context,
return JSValueMakeBoolean(context, lightdm_greeter_get_autologin_guest_hint(greeter));
}
static JSValueRef
get_is_authenticated_cb(JSContextRef context,
JSObjectRef thisObject,
@ -708,6 +734,7 @@ get_is_authenticated_cb(JSContextRef context,
return JSValueMakeBoolean(context, lightdm_greeter_get_is_authenticated(greeter));
}
static JSValueRef
get_in_authentication_cb(JSContextRef context,
JSObjectRef thisObject,
@ -717,6 +744,7 @@ get_in_authentication_cb(JSContextRef context,
return JSValueMakeBoolean(context, lightdm_greeter_get_in_authentication(greeter));
}
static JSValueRef
get_can_suspend_cb(JSContextRef context,
JSObjectRef thisObject,
@ -733,8 +761,9 @@ suspend_cb(JSContextRef context,
size_t argumentCount,
const JSValueRef arguments[],
JSValueRef *exception) {
if (argumentCount != 0)
if (argumentCount != 0) {
return mkexception(context, exception, "Argument count not zero");
}
lightdm_suspend(NULL);
return JSValueMakeNull(context);
@ -757,8 +786,9 @@ hibernate_cb(JSContextRef context,
size_t argumentCount,
const JSValueRef arguments[],
JSValueRef *exception) {
if (argumentCount != 0)
if (argumentCount != 0) {
return mkexception(context, exception, "Argument count not zero");
}
lightdm_hibernate(NULL);
return JSValueMakeNull(context);
@ -781,8 +811,9 @@ restart_cb(JSContextRef context,
size_t argumentCount,
const JSValueRef arguments[],
JSValueRef *exception) {
if (argumentCount != 0)
if (argumentCount != 0) {
return mkexception(context, exception, "Argument count not zero");
}
lightdm_restart(NULL);
return JSValueMakeNull(context);
@ -805,8 +836,9 @@ shutdown_cb(JSContextRef context,
size_t argumentCount,
const JSValueRef arguments[],
JSValueRef *exception) {
if (argumentCount != 0)
if (argumentCount != 0) {
return mkexception(context, exception, "Argument count not zero");
}
lightdm_shutdown(NULL);
return JSValueMakeNull(context);
@ -827,8 +859,10 @@ start_session_sync_cb(JSContextRef context,
gchar *username, *session = NULL;
if (!(( argumentCount == 1 && JSValueGetType(context, arguments[0]) == kJSTypeString ) ||
(argumentCount == 2 && JSValueGetType (context, arguments[0]) == kJSTypeString && JSValueGetType (context, arguments[1]) == 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);
username_size = JSStringGetMaximumUTF8CStringSize(arg);
@ -866,8 +900,9 @@ set_language_cb(JSContextRef context,
size_t language_size;
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");
}
arg = JSValueToStringCopy(context, arguments[0], NULL);
language_size = JSStringGetMaximumUTF8CStringSize(arg);
@ -895,8 +930,9 @@ gettext_cb(JSContextRef context,
gchar *string;
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");
}
string_arg = JSValueToStringCopy(context, arguments[0], NULL);
string_size = JSStringGetMaximumUTF8CStringSize(string_arg);
@ -927,8 +963,9 @@ ngettext_cb(JSContextRef context,
unsigned int n;
JSValueRef result;
if (argumentCount != 3)
if (argumentCount != 3) {
return mkexception(context, exception, "Needs 3 arguments");
}
string_arg = JSValueToStringCopy(context, arguments[0], NULL);
string_size = JSStringGetMaximumUTF8CStringSize(string_arg);
@ -1258,6 +1295,7 @@ authentication_complete_cb(LightDMGreeter *greeter, WebKitWebExtension *extensio
}
}
static void
autologin_timer_expired_cb(LightDMGreeter *greeter, WebKitWebExtension *extension) {

Loading…
Cancel
Save