Browse Source

remove debugging messages. code cleanup

sisyphus
Dustin Falgout 8 years ago
parent
commit
d3292153f3
  1. 1
      src/config.h
  2. 21
      src/greeter.c
  3. 79
      src/webkit2-extension.c
  4. 5
      themes/antergos/js/greeter.js

1
src/config.h

@ -0,0 +1 @@
../build/src/config.h

21
src/greeter.c

@ -33,20 +33,24 @@
*/ */
#include <stdlib.h> #include <stdlib.h>
#include <glib.h>
#include <gtk/gtk.h> #include <gtk/gtk.h>
#include <gdk/gdkx.h> #include <gdk/gdkx.h>
#include <glib.h>
#include <glib/gprintf.h> #include <glib/gprintf.h>
#include <glib-unix.h> #include <glib-unix.h>
#include <gtk/gtkx.h>
#include <webkit2/webkit2.h> #include <webkit2/webkit2.h>
#include <JavaScriptCore/JavaScript.h> #include <JavaScriptCore/JavaScript.h>
#include <glib/gi18n.h> #include <glib/gi18n.h>
#include <sys/mman.h> #include <sys/mman.h>
#include <config.h> #include "config.h"
#include "gresource/greeter-resources.h" #include "gresource/greeter-resources.h"
/* CLion bugs */
#ifndef gsize
typedef unsigned long gsize;
#endif
static GtkWidget *web_view; static GtkWidget *web_view;
static GtkWidget *window; static GtkWidget *window;
static WebKitSettings *webkit_settings; static WebKitSettings *webkit_settings;
@ -54,11 +58,18 @@ static GdkDisplay *default_display;
static GResource *greeter_resources; static GResource *greeter_resources;
/* Screensaver values */ /* Screensaver values */
static int timeout, interval, prefer_blanking, allow_exposures; static int
timeout,
interval,
prefer_blanking,
allow_exposures;
static gint config_timeout; static gint config_timeout;
static gboolean debug_mode, heartbeat, heartbeat_exit; static gboolean
debug_mode,
heartbeat,
heartbeat_exit;
static GdkFilterReturn static GdkFilterReturn

79
src/webkit2-extension.c

@ -31,37 +31,56 @@
* along with lightdm-webkit2-greeter; If not, see <http://www.gnu.org/licenses/>. * along with lightdm-webkit2-greeter; If not, see <http://www.gnu.org/licenses/>.
*/ */
/* WebKitWebExtension
* This extension runs inside the web process allowing us to interact directly with
* the web page including the DOM and JavaScriptWorld.
*/
#define _GNU_SOURCE #define _GNU_SOURCE
#include <stdlib.h> #include <stdlib.h>
#include <glib.h>
#include <gtk/gtk.h> #include <gtk/gtk.h>
#include <glib/gi18n.h> #include <glib/gi18n.h>
#include <glib.h>
#include <glib/gstdio.h> #include <glib/gstdio.h>
#include <webkit2/webkit-web-extension.h>
#include <webkitdom/WebKitDOMCustom.h> #include <webkitdom/WebKitDOMCustom.h>
#include <webkit2/webkit-web-extension.h>
#include <JavaScriptCore/JavaScript.h> #include <JavaScriptCore/JavaScript.h>
#include <lightdm.h> #include <lightdm.h>
#include <config.h> #include "config.h"
G_MODULE_EXPORT void webkit_web_extension_initialize(WebKitWebExtension *extension);
guint64 page_id = -1; /* CLion bugs */
GKeyFile *keyfile; #ifndef guint64
typedef unsigned long guint64;
#endif
/* Convenience macros for use in functions that can be called from JavaScript
* running in the web process. They are used to confirm that calls were made by one of
* the classes that we injected into the web page.
*/
#define USER ((LightDMUser *) JSObjectGetPrivate (thisObject)) #define USER ((LightDMUser *) JSObjectGetPrivate (thisObject))
#define LAYOUT ((LightDMLayout *) JSObjectGetPrivate (thisObject)) #define LAYOUT ((LightDMLayout *) JSObjectGetPrivate (thisObject))
#define SESSION ((LightDMSession *) JSObjectGetPrivate (thisObject)) #define SESSION ((LightDMSession *) JSObjectGetPrivate (thisObject))
#define GREETER ((LightDMGreeter *) JSObjectGetPrivate (thisObject)) #define GREETER ((LightDMGreeter *) JSObjectGetPrivate (thisObject))
#define LANGUAGE ((LightDMLanguage *) JSObjectGetPrivate (thisObject)) #define LANGUAGE ((LightDMLanguage *) JSObjectGetPrivate (thisObject))
/* /*
* Put all our translatable strings up top * Translatable strings
*/ */
#define EXPECTSTRING _("Expected a string") #define EXPECTSTRING _("Expected a string")
#define ARGNOTSUPPLIED _("Argument(s) not supplied") #define ARGNOTSUPPLIED _("Argument(s) not supplied")
G_MODULE_EXPORT void webkit_web_extension_initialize(WebKitWebExtension *extension);
guint64 page_id;
GKeyFile *keyfile;
static JSClassRef static JSClassRef
lightdm_greeter_class, lightdm_greeter_class,
gettext_class, gettext_class,
@ -477,8 +496,7 @@ get_language_cb(JSContextRef context,
JSObjectRef thisObject, JSObjectRef thisObject,
JSStringRef propertyName, JSStringRef propertyName,
JSValueRef *exception) { JSValueRef *exception) {
return string_or_null(context, return string_or_null(context, lightdm_language_get_name(lightdm_get_language()));
lightdm_language_get_name((LightDMLanguage *) lightdm_get_language()));
} }
@ -1302,7 +1320,7 @@ txt2html_cb(JSContextRef context,
static gchar * static gchar *
remove_query_string(gchar *str) { remove_query_and_hash(gchar *str) {
gchar *ptr = NULL; gchar *ptr = NULL;
ptr = strchr(str, '?'); ptr = strchr(str, '?');
@ -1311,6 +1329,12 @@ remove_query_string(gchar *str) {
*ptr = '\0'; *ptr = '\0';
} }
ptr = strchr(str, '#');
if (NULL != ptr) {
*ptr = '\0';
}
return g_strstrip(str); return g_strstrip(str);
} }
@ -1720,12 +1744,12 @@ get_config_option(const gchar *section, const gchar *key) {
static gboolean static gboolean
is_requested_file_path_allowed(const char *file_path) { should_block_request(const char *file_path) {
gchar *background_images_dir; gchar *background_images_dir;
gchar *user_image; gchar *user_image;
gchar *logo; gchar *logo;
gboolean result = FALSE; gboolean result = TRUE;
char *normalized_path; char *canonical_path;
if (NULL == file_path) { if (NULL == file_path) {
return result; return result;
@ -1744,20 +1768,20 @@ is_requested_file_path_allowed(const char *file_path) {
logo = get_config_option("branding", "logo"); logo = get_config_option("branding", "logo");
paths = g_slist_prepend(paths, logo); paths = g_slist_prepend(paths, logo);
normalized_path = canonicalize_file_name(file_path); canonical_path = canonicalize_file_name(file_path);
if (NULL != normalized_path) { if (NULL != canonical_path) {
for (iter = paths; iter; iter = iter->next) { for (iter = paths; iter; iter = iter->next) {
if (strcmp(normalized_path, iter->data) == 0 || g_str_has_prefix(normalized_path, iter->data)) { if (strcmp(canonical_path, iter->data) == 0 || g_str_has_prefix(canonical_path, iter->data)) {
/* Requested path is allowed */ /* Requested path is allowed (don't block request). */
result = TRUE; result = FALSE;
break; break;
} }
} }
} }
g_slist_free(paths); g_slist_free(paths);
g_free(normalized_path); g_free(canonical_path);
g_free(background_images_dir); g_free(background_images_dir);
g_free(user_image); g_free(user_image);
g_free(logo); g_free(logo);
@ -1805,13 +1829,11 @@ web_page_send_request_cb(WebKitWebPage *web_page,
request_file_path = g_filename_from_uri(request_uri, NULL, NULL); request_file_path = g_filename_from_uri(request_uri, NULL, NULL);
request_file_path_without_query = g_strdup(request_file_path); request_file_path_without_query = g_strdup(request_file_path);
request_file_path_without_query = remove_query_string(request_file_path_without_query); request_file_path_without_query = remove_query_and_hash(request_file_path_without_query);
g_message(request_file_path_without_query);
g_free(request_scheme); g_free(request_scheme);
return (FALSE == is_requested_file_path_allowed(request_file_path_without_query)); return should_block_request(request_file_path_without_query);
} }
@ -1887,9 +1909,12 @@ webkit_web_extension_initialize(WebKitWebExtension *extension) {
/* load greeter settings from config file */ /* load greeter settings from config file */
keyfile = g_key_file_new(); keyfile = g_key_file_new();
g_key_file_load_from_file(keyfile, g_key_file_load_from_file(
CONFIG_DIR "lightdm-webkit2-greeter.conf", keyfile,
G_KEY_FILE_NONE, NULL); CONFIG_DIR "lightdm-webkit2-greeter.conf",
G_KEY_FILE_NONE,
NULL
);
} }
/* vim: set ts=4 sw=4 tw=0 noet : */ /* vim: set ts=4 sw=4 tw=0 noet : */

5
themes/antergos/js/greeter.js

@ -99,7 +99,8 @@ class AntergosThemeUtils {
if ('' === this.cache_backend) { if ('' === this.cache_backend) {
this.cache_backend = 'Cookies'; this.cache_backend = 'Cookies';
} }
console.log(`AntergosThemeUtils.cache_backend is: ${this.cache_backend}`);
this.log(`AntergosThemeUtils.cache_backend is: ${this.cache_backend}`);
} }
@ -730,8 +731,6 @@ class AntergosTheme {
_self.selected_user = null; _self.selected_user = null;
_self.auth_pending = false; _self.auth_pending = false;
console.log($(event.target));
if ( $(event.target).hasClass('alert') ) { if ( $(event.target).hasClass('alert') ) {
/* We were triggered by the authentication failed message being dismissed. /* We were triggered by the authentication failed message being dismissed.
* Keep the same account selected so user can retry without re-selecting an account. * Keep the same account selected so user can retry without re-selecting an account.

Loading…
Cancel
Save