Browse Source

make sure theme heartbeat is stopped before we start the session

sisyphus
Dustin Falgout 8 years ago
parent
commit
e656622f28
  1. 8
      data/heartbeat.js
  2. 75
      src/gresource/greeter-resources.c
  3. 48
      src/webkit2-extension.c

8
data/heartbeat.js

@ -62,10 +62,18 @@ class LightDMGreeterHeartbeat {
this.heartbeat = setInterval(() => {
++heartbeats;
if ( true === lightdm.session_starting ) {
clearInterval( this.heartbeat );
return;
}
window.webkit.messageHandlers.GreeterBridge.postMessage('Heartbeat');
if ( heartbeats < 5 ) {
console.log('Sending heartbeat...');
}
}, 5000);
}
}

75
src/gresource/greeter-resources.c

@ -6,7 +6,7 @@
# define SECTION
#endif
static const SECTION union { const guint8 data[2716]; const double alignment; void * const ptr;} greeter_resources_resource_data = { {
static const SECTION union { const guint8 data[2820]; const double alignment; void * const ptr;} greeter_resources_resource_data = { {
0x47, 0x56, 0x61, 0x72, 0x69, 0x61, 0x6e, 0x74,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x18, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00,
@ -23,27 +23,27 @@ static const SECTION union { const guint8 data[2716]; const double alignment; vo
0x0c, 0x01, 0x00, 0x00, 0x10, 0x01, 0x00, 0x00,
0x73, 0xf8, 0xf6, 0x72, 0x00, 0x00, 0x00, 0x00,
0x10, 0x01, 0x00, 0x00, 0x0c, 0x00, 0x76, 0x00,
0x20, 0x01, 0x00, 0x00, 0x13, 0x0a, 0x00, 0x00,
0x20, 0x01, 0x00, 0x00, 0x7b, 0x0a, 0x00, 0x00,
0xd4, 0xb5, 0x02, 0x00, 0xff, 0xff, 0xff, 0xff,
0x13, 0x0a, 0x00, 0x00, 0x01, 0x00, 0x4c, 0x00,
0x14, 0x0a, 0x00, 0x00, 0x18, 0x0a, 0x00, 0x00,
0x7b, 0x0a, 0x00, 0x00, 0x01, 0x00, 0x4c, 0x00,
0x7c, 0x0a, 0x00, 0x00, 0x80, 0x0a, 0x00, 0x00,
0x8c, 0x77, 0x10, 0x71, 0x07, 0x00, 0x00, 0x00,
0x18, 0x0a, 0x00, 0x00, 0x09, 0x00, 0x76, 0x00,
0x28, 0x0a, 0x00, 0x00, 0x64, 0x0a, 0x00, 0x00,
0x80, 0x0a, 0x00, 0x00, 0x09, 0x00, 0x76, 0x00,
0x90, 0x0a, 0x00, 0x00, 0xcc, 0x0a, 0x00, 0x00,
0xb4, 0xae, 0x96, 0xdb, 0x01, 0x00, 0x00, 0x00,
0x64, 0x0a, 0x00, 0x00, 0x09, 0x00, 0x4c, 0x00,
0x70, 0x0a, 0x00, 0x00, 0x74, 0x0a, 0x00, 0x00,
0xcc, 0x0a, 0x00, 0x00, 0x09, 0x00, 0x4c, 0x00,
0xd8, 0x0a, 0x00, 0x00, 0xdc, 0x0a, 0x00, 0x00,
0x0c, 0xa6, 0xd8, 0x48, 0x05, 0x00, 0x00, 0x00,
0x74, 0x0a, 0x00, 0x00, 0x18, 0x00, 0x4c, 0x00,
0x8c, 0x0a, 0x00, 0x00, 0x94, 0x0a, 0x00, 0x00,
0xdc, 0x0a, 0x00, 0x00, 0x18, 0x00, 0x4c, 0x00,
0xf4, 0x0a, 0x00, 0x00, 0xfc, 0x0a, 0x00, 0x00,
0xc4, 0x0d, 0xcd, 0xb1, 0x06, 0x00, 0x00, 0x00,
0x94, 0x0a, 0x00, 0x00, 0x04, 0x00, 0x4c, 0x00,
0x98, 0x0a, 0x00, 0x00, 0x9c, 0x0a, 0x00, 0x00,
0xfc, 0x0a, 0x00, 0x00, 0x04, 0x00, 0x4c, 0x00,
0x00, 0x0b, 0x00, 0x00, 0x04, 0x0b, 0x00, 0x00,
0x6a, 0x73, 0x2f, 0x00, 0x02, 0x00, 0x00, 0x00,
0x63, 0x6f, 0x6d, 0x2f, 0x05, 0x00, 0x00, 0x00,
0x68, 0x65, 0x61, 0x72, 0x74, 0x62, 0x65, 0x61,
0x74, 0x2e, 0x6a, 0x73, 0x00, 0x00, 0x00, 0x00,
0xe3, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x4b, 0x09, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x2f, 0x2a, 0x0a, 0x20, 0x2a, 0x20, 0x68, 0x65,
0x61, 0x72, 0x74, 0x62, 0x65, 0x61, 0x74, 0x2e,
0x6a, 0x73, 0x0a, 0x20, 0x2a, 0x0a, 0x20, 0x2a,
@ -303,25 +303,38 @@ static const SECTION union { const guint8 data[2716]; const double alignment; vo
0x65, 0x72, 0x76, 0x61, 0x6c, 0x28, 0x28, 0x29,
0x20, 0x3d, 0x3e, 0x20, 0x7b, 0x0a, 0x09, 0x09,
0x09, 0x2b, 0x2b, 0x68, 0x65, 0x61, 0x72, 0x74,
0x62, 0x65, 0x61, 0x74, 0x73, 0x3b, 0x0a, 0x09,
0x09, 0x09, 0x77, 0x69, 0x6e, 0x64, 0x6f, 0x77,
0x2e, 0x77, 0x65, 0x62, 0x6b, 0x69, 0x74, 0x2e,
0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x48,
0x61, 0x6e, 0x64, 0x6c, 0x65, 0x72, 0x73, 0x2e,
0x47, 0x72, 0x65, 0x65, 0x74, 0x65, 0x72, 0x42,
0x72, 0x69, 0x64, 0x67, 0x65, 0x2e, 0x70, 0x6f,
0x73, 0x74, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67,
0x65, 0x28, 0x27, 0x48, 0x65, 0x61, 0x72, 0x74,
0x62, 0x65, 0x61, 0x74, 0x27, 0x29, 0x3b, 0x0a,
0x62, 0x65, 0x61, 0x74, 0x73, 0x3b, 0x0a, 0x0a,
0x09, 0x09, 0x09, 0x69, 0x66, 0x20, 0x28, 0x20,
0x68, 0x65, 0x61, 0x72, 0x74, 0x62, 0x65, 0x61,
0x74, 0x73, 0x20, 0x3c, 0x20, 0x35, 0x20, 0x29,
0x20, 0x7b, 0x0a, 0x09, 0x09, 0x09, 0x09, 0x63,
0x6f, 0x6e, 0x73, 0x6f, 0x6c, 0x65, 0x2e, 0x6c,
0x6f, 0x67, 0x28, 0x27, 0x53, 0x65, 0x6e, 0x64,
0x69, 0x6e, 0x67, 0x20, 0x68, 0x65, 0x61, 0x72,
0x74, 0x62, 0x65, 0x61, 0x74, 0x2e, 0x2e, 0x2e,
0x27, 0x29, 0x3b, 0x0a, 0x09, 0x09, 0x09, 0x7d,
0x74, 0x72, 0x75, 0x65, 0x20, 0x3d, 0x3d, 0x3d,
0x20, 0x6c, 0x69, 0x67, 0x68, 0x74, 0x64, 0x6d,
0x2e, 0x73, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e,
0x5f, 0x73, 0x74, 0x61, 0x72, 0x74, 0x69, 0x6e,
0x67, 0x20, 0x29, 0x20, 0x7b, 0x0a, 0x09, 0x09,
0x09, 0x09, 0x63, 0x6c, 0x65, 0x61, 0x72, 0x49,
0x6e, 0x74, 0x65, 0x72, 0x76, 0x61, 0x6c, 0x28,
0x20, 0x74, 0x68, 0x69, 0x73, 0x2e, 0x68, 0x65,
0x61, 0x72, 0x74, 0x62, 0x65, 0x61, 0x74, 0x20,
0x29, 0x3b, 0x0a, 0x09, 0x09, 0x09, 0x09, 0x72,
0x65, 0x74, 0x75, 0x72, 0x6e, 0x3b, 0x0a, 0x09,
0x09, 0x09, 0x7d, 0x0a, 0x0a, 0x09, 0x09, 0x09,
0x77, 0x69, 0x6e, 0x64, 0x6f, 0x77, 0x2e, 0x77,
0x65, 0x62, 0x6b, 0x69, 0x74, 0x2e, 0x6d, 0x65,
0x73, 0x73, 0x61, 0x67, 0x65, 0x48, 0x61, 0x6e,
0x64, 0x6c, 0x65, 0x72, 0x73, 0x2e, 0x47, 0x72,
0x65, 0x65, 0x74, 0x65, 0x72, 0x42, 0x72, 0x69,
0x64, 0x67, 0x65, 0x2e, 0x70, 0x6f, 0x73, 0x74,
0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x28,
0x27, 0x48, 0x65, 0x61, 0x72, 0x74, 0x62, 0x65,
0x61, 0x74, 0x27, 0x29, 0x3b, 0x0a, 0x0a, 0x09,
0x09, 0x09, 0x69, 0x66, 0x20, 0x28, 0x20, 0x68,
0x65, 0x61, 0x72, 0x74, 0x62, 0x65, 0x61, 0x74,
0x73, 0x20, 0x3c, 0x20, 0x35, 0x20, 0x29, 0x20,
0x7b, 0x0a, 0x09, 0x09, 0x09, 0x09, 0x63, 0x6f,
0x6e, 0x73, 0x6f, 0x6c, 0x65, 0x2e, 0x6c, 0x6f,
0x67, 0x28, 0x27, 0x53, 0x65, 0x6e, 0x64, 0x69,
0x6e, 0x67, 0x20, 0x68, 0x65, 0x61, 0x72, 0x74,
0x62, 0x65, 0x61, 0x74, 0x2e, 0x2e, 0x2e, 0x27,
0x29, 0x3b, 0x0a, 0x09, 0x09, 0x09, 0x7d, 0x0a,
0x0a, 0x09, 0x09, 0x7d, 0x2c, 0x20, 0x35, 0x30,
0x30, 0x30, 0x29, 0x3b, 0x0a, 0x09, 0x7d, 0x0a,
0x7d, 0x0a, 0x0a, 0x0a, 0x6e, 0x65, 0x77, 0x20,

48
src/webkit2-extension.c

@ -71,6 +71,10 @@ static JSClassRef
config_file_class,
greeter_util_class;
static gboolean SESSION_STARTING = FALSE;
static WebKitWebExtension *WEB_EXTENSION;
/*
* Returns either a string or null.
@ -584,6 +588,16 @@ get_sessions_cb(JSContextRef context,
}
static JSValueRef
get_session_starting_cb(JSContextRef context,
JSObjectRef thisObject,
JSStringRef propertyName,
JSValueRef *exception) {
return JSValueMakeBoolean(context, SESSION_STARTING);
}
static JSValueRef
get_default_session_cb(JSContextRef context,
JSObjectRef thisObject,
@ -908,16 +922,20 @@ shutdown_cb(JSContextRef context,
static JSValueRef
start_session_cb(JSContextRef context,
JSObjectRef function,
JSObjectRef thisObject,
size_t argumentCount,
const JSValueRef arguments[],
JSValueRef *exception) {
JSObjectRef function,
JSObjectRef thisObject,
size_t argumentCount,
const JSValueRef arguments[],
JSValueRef *exception) {
gchar *session = NULL;
gboolean result;
GError *err = NULL;
WebKitDOMDOMWindow *dom_window;
WebKitDOMDocument *dom_document;
WebKitWebPage *web_page;
/* FIXME: old API required lightdm.login(username, session), but the username
* is never actually used. At some point, deprecate the old usage. For now,
* simply work around it.
@ -928,10 +946,27 @@ start_session_cb(JSContextRef context,
session = arg_to_string(context, arguments[1], exception);
}
web_page = webkit_web_extension_get_page(WEB_EXTENSION, page_id);
if (NULL != web_page) {
dom_document = webkit_web_page_get_dom_document(web_page);
dom_window = webkit_dom_document_get_default_view(dom_document);
}
if (dom_window) {
/* Stop theme heartbeat */
webkit_dom_dom_window_webkit_message_handlers_post_message(
dom_window, "GreeterBridge", "Heartbeat::Exit"
);
}
SESSION_STARTING = TRUE;
result = lightdm_greeter_start_session_sync(GREETER, session, &err);
g_free(session);
if (err != NULL) {
SESSION_STARTING = FALSE;
_mkexception(context, exception, err->message);
g_error_free(err);
}
@ -1322,6 +1357,7 @@ static const JSStaticValue lightdm_greeter_values[] = {
{"select_guest_hint", get_select_guest_hint_cb, NULL, kJSPropertyAttributeReadOnly},
{"select_user_hint", get_select_user_hint_cb, NULL, kJSPropertyAttributeReadOnly},
{"sessions", get_sessions_cb, NULL, kJSPropertyAttributeReadOnly},
{"session-starting", get_session_starting_cb, NULL, kJSPropertyAttributeReadOnly},
{"users", get_users_cb, NULL, kJSPropertyAttributeReadOnly},
/* ------>>> DEPRECATED! <<<----------->>> DEPRECATED! <<<------------>>> DEPRECATED! <<<------*/
{"default_language", get_language_cb, NULL, kJSPropertyAttributeReadOnly},
@ -1662,6 +1698,8 @@ G_MODULE_EXPORT void
webkit_web_extension_initialize(WebKitWebExtension *extension) {
LightDMGreeter *greeter = lightdm_greeter_new();
WEB_EXTENSION = extension;
g_signal_connect(G_OBJECT(greeter),
"authentication-complete",
G_CALLBACK(authentication_complete_cb),

Loading…
Cancel
Save