From 9a2f681e3902e65540df691f99263f01bd99510e Mon Sep 17 00:00:00 2001 From: Dustin Falgout Date: Fri, 13 May 2016 00:45:16 -0500 Subject: [PATCH] add bugsnag error reporting to the default theme --- NEWS | 5 ++++ configure.ac | 2 ++ src/lightdm-webkit2-greeter-ext.c | 46 ++++++++++--------------------- src/lightdm-webkit2-greeter.c | 2 +- themes/_vendor/js/Makefile.am | 1 + themes/_vendor/js/mock.js | 12 +++++++- themes/antergos/js/greeter.js | 5 +--- 7 files changed, 35 insertions(+), 38 deletions(-) diff --git a/NEWS b/NEWS index 42fb7f1..98d22da 100644 --- a/NEWS +++ b/NEWS @@ -1,3 +1,8 @@ +Overview of changes in lightdm-webkit2-greeter 2.1.5 + + * Added bugsnag automated error reporting to the default greeter theme. + * Updated translations. + Overview of changes in lightdm-webkit2-greeter 2.1.4 * Implemented a theme heartbeat to allow the greeter to detect and respond to theme failures. diff --git a/configure.ac b/configure.ac index 0a45dba..ebb5461 100644 --- a/configure.ac +++ b/configure.ac @@ -1,6 +1,8 @@ dnl Process this file with autoconf to produce a configure script. AC_INIT(lightdm-webkit2-greeter, 2.1.5) +AC_DEFINE(GREETER_VERSION, "2.1.5", Greeter Version) + AC_SUBST(THEME_DIR) AC_CONFIG_HEADER(config.h) AC_PREREQ([2.59]) diff --git a/src/lightdm-webkit2-greeter-ext.c b/src/lightdm-webkit2-greeter-ext.c index a58bbb2..4f368c3 100644 --- a/src/lightdm-webkit2-greeter-ext.c +++ b/src/lightdm-webkit2-greeter-ext.c @@ -1435,34 +1435,6 @@ static const JSClassDefinition greeter_util_definition = { }; -static void -inject_bugsnag_script(WebKitScriptWorld *world, WebKitFrame *frame) { - gchar *bugsnag, *string; - JSGlobalContextRef jsContext; - JSStringRef command; - - bugsnag = "4ea62a82" - "03b5b1af" - "7c33da0d" - "c2f6a60f"; - - string = g_strdup_printf( - "var s = document.createElement('script');" - "s.src = '../_vendor/js/bugsnag-2.5.0.min.js" - "s['data-apikey'] = %s;" - "$('head').append(s);", - bugsnag - ); - - jsContext = webkit_frame_get_javascript_context_for_script_world(frame, world); - command = JSStringCreateWithUTF8CString(string); - - JSEvaluateScript(jsContext, command, NULL, NULL, 0, NULL); - g_free(bugsnag); - g_free(string); -} - - static void window_object_cleared_callback(WebKitScriptWorld *world, WebKitWebPage *web_page, @@ -1477,11 +1449,11 @@ window_object_cleared_callback(WebKitScriptWorld *world, config_file_object, greeter_util_object, globalObject; + JSStringRef command; gboolean report_errors; gchar *message = "LockHint"; - gchar *theme; + gchar *theme, *bugsnag, *string;; - page_id = webkit_web_page_get_id(web_page); jsContext = webkit_frame_get_javascript_context_for_script_world(frame, world); globalObject = JSContextGetGlobalObject(jsContext); @@ -1542,8 +1514,18 @@ window_object_cleared_callback(WebKitScriptWorld *world, theme = g_key_file_get_string(keyfile, "greeter", "theme", NULL); report_errors = g_key_file_get_boolean(keyfile, "greeter", "report-errors", NULL); - if (strcmp("antergos", theme) == 0 && report_errors) { - inject_bugsnag_script(world, frame); + if (report_errors && strcmp("antergos", theme) == 0) { + bugsnag = "4ea62a82" + "03b5b1af" + "7c33da0d" + "c2f6a60f"; + + string = g_strdup_printf("window._inject_bugsnag('%s', '%s');", bugsnag, GREETER_VERSION); + command = JSStringCreateWithUTF8CString(string); + + JSEvaluateScript(jsContext, command, NULL, NULL, 0, NULL); + g_free(bugsnag); + g_free(string); } g_free(theme); diff --git a/src/lightdm-webkit2-greeter.c b/src/lightdm-webkit2-greeter.c index 50e057b..d61ddf9 100644 --- a/src/lightdm-webkit2-greeter.c +++ b/src/lightdm-webkit2-greeter.c @@ -348,7 +348,7 @@ main(int argc, char **argv) { webkit_web_view_set_background_color(WEBKIT_WEB_VIEW(web_view), gdk_rgba_copy(&bg_color)); /* Maybe disable the context (right-click) menu. */ - g_signal_connect(web_view, "context-menu", G_CALLBACK(context_menu_cb), NULL); + //g_signal_connect(web_view, "context-menu", G_CALLBACK(context_menu_cb), NULL); /* There's no turning back now, let's go! */ gtk_container_add(GTK_CONTAINER(window), web_view); diff --git a/themes/_vendor/js/Makefile.am b/themes/_vendor/js/Makefile.am index 98d3070..2012e07 100644 --- a/themes/_vendor/js/Makefile.am +++ b/themes/_vendor/js/Makefile.am @@ -1,6 +1,7 @@ vendorjsdir = $(THEME_DIR)/_vendor/js vendorjs_DATA = \ bootstrap.min.js \ + bugsnag-2.5.0.min.js \ jquery.min.js \ js.cookie.min.js \ mock.js \ diff --git a/themes/_vendor/js/mock.js b/themes/_vendor/js/mock.js index 6e5c3a1..81445a3 100644 --- a/themes/_vendor/js/mock.js +++ b/themes/_vendor/js/mock.js @@ -299,4 +299,14 @@ function _lightdm_mock_get_user( username ) { } } return user; -} \ No newline at end of file +} + +window._inject_bugsnag = function(num, ver) { + var s = document.createElement('script'); + s.src = '../_vendor/js/bugsnag-2.5.0.min.js'; + jQuery('head').append(s); + setTimeout(function() { + Bugsnag.apiKey = num; + Bugsnag.appVersion = ver; + }, 500); +}; diff --git a/themes/antergos/js/greeter.js b/themes/antergos/js/greeter.js index 4b0c678..760a341 100644 --- a/themes/antergos/js/greeter.js +++ b/themes/antergos/js/greeter.js @@ -46,7 +46,6 @@ String.prototype.capitalize = function() { - /** * This should be the base class for all the theme's components. However, webkit's * support of extending (subclassing) ES6 classes is not stable enough to use. @@ -95,7 +94,7 @@ class AntergosThemeUtils { this.heartbeat = setInterval(() => { ++heartbeats; window.webkit.messageHandlers.GreeterBridge.postMessage('Heartbeat'); - if (heartbeats < 20) { + if (heartbeats < 5) { console.log('Sending heartbeat...'); } }, 5000); @@ -897,8 +896,6 @@ class AntergosTheme { - - /** * Initialize the theme once the window has loaded. */