|
|
@ -27,152 +27,270 @@ |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
|
|
|
|
|
|
|
|
// mock lighdm for testing
|
|
|
|
// mock lighdm for testing
|
|
|
|
if (typeof lightdm == 'undefined') { |
|
|
|
if ( typeof lightdm == 'undefined' ) { |
|
|
|
lightdm= {}; |
|
|
|
lightdm = {}; |
|
|
|
lightdm.hostname="test-host"; |
|
|
|
lightdm.hostname = "test-host"; |
|
|
|
lightdm.languages= [{code: "en_US", name: "English(US)", territory: "USA"}, {code: "en_UK", name: "English(UK)", territory: "UK"}]; |
|
|
|
lightdm.languages = [ { |
|
|
|
lightdm.default_language= lightdm.languages[0]; |
|
|
|
code: "en_US", |
|
|
|
lightdm.layouts= [{name: "test", short_description: "test description", short_description:"really long epic description"}]; |
|
|
|
name: "English(US)", |
|
|
|
lightdm.default_layout= lightdm.layouts[0]; |
|
|
|
territory: "USA" |
|
|
|
lightdm.layout= lightdm.layouts[0]; |
|
|
|
}, { code: "en_UK", name: "English(UK)", territory: "UK" } ]; |
|
|
|
lightdm.sessions=[{key: "gnome", name: "gnome", comment: "no comment"}, {key: "cinnamon", name: "cinnamon", comment: "no comment"},{key: "openbox", name: "openbox", comment: "no comment"}, {key: "key4", name: "kde", comment: "no comment"}]; |
|
|
|
lightdm.default_language = lightdm.languages[ 0 ]; |
|
|
|
|
|
|
|
lightdm.layouts = [ { |
|
|
|
lightdm.default_session=lightdm.sessions[0]['name']; |
|
|
|
name: "test", |
|
|
|
lightdm.authentication_user= null; |
|
|
|
short_description: "test description", |
|
|
|
lightdm.is_authenticated= false; |
|
|
|
short_description: "really long epic description" |
|
|
|
lightdm.can_suspend= true; |
|
|
|
} ]; |
|
|
|
lightdm.can_hibernate= true; |
|
|
|
lightdm.default_layout = lightdm.layouts[ 0 ]; |
|
|
|
lightdm.can_restart= true; |
|
|
|
lightdm.layout = lightdm.layouts[ 0 ]; |
|
|
|
lightdm.can_shutdown= true; |
|
|
|
lightdm.sessions = [ { key: "gnome", name: "gnome", comment: "no comment" }, { |
|
|
|
|
|
|
|
key: "cinnamon", |
|
|
|
|
|
|
|
name: "cinnamon", |
|
|
|
|
|
|
|
comment: "no comment" |
|
|
|
|
|
|
|
}, { key: "openbox", name: "openbox", comment: "no comment" }, { |
|
|
|
|
|
|
|
key: "key4", |
|
|
|
|
|
|
|
name: "kde", |
|
|
|
|
|
|
|
comment: "no comment" |
|
|
|
|
|
|
|
} ]; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
lightdm.default_session = lightdm.sessions[ 0 ][ 'name' ]; |
|
|
|
|
|
|
|
lightdm.authentication_user = null; |
|
|
|
|
|
|
|
lightdm.is_authenticated = false; |
|
|
|
|
|
|
|
lightdm.can_suspend = true; |
|
|
|
|
|
|
|
lightdm.can_hibernate = true; |
|
|
|
|
|
|
|
lightdm.can_restart = true; |
|
|
|
|
|
|
|
lightdm.can_shutdown = true; |
|
|
|
lightdm.awaiting_username = false; |
|
|
|
lightdm.awaiting_username = false; |
|
|
|
|
|
|
|
|
|
|
|
lightdm.users = [ |
|
|
|
lightdm.users = [ |
|
|
|
{ name: "clarkk", real_name: "Superman", display_name: "Clark Kent", image: "", language: "en_US", layout: null, session: "gnome", logged_in: false }, |
|
|
|
{ |
|
|
|
{ name: "brucew", real_name: "Batman", display_name: "Bruce Wayne", image: "", language: "en_US", layout: null, session: "cinnamon", logged_in: false}, |
|
|
|
name: "clarkk", |
|
|
|
{ name: "peterp", real_name: "Spiderman", display_name: "Peter Parker", image: "", language: "en_US", layout: null, session: "gnome", logged_in: true}, |
|
|
|
real_name: "Superman", |
|
|
|
{ name: "clarkk2", real_name: "Superman", display_name: "Clark Kent", image: "", language: "en_US", layout: null, session: "gnome", logged_in: false }, |
|
|
|
display_name: "Clark Kent", |
|
|
|
{ name: "brucew2", real_name: "Batman", display_name: "Bruce Wayne", image: "", language: "en_US", layout: null, session: "cinnamon", logged_in: false}, |
|
|
|
image: "", |
|
|
|
{ name: "peterp2", real_name: "Spiderman", display_name: "Peter Parker", image: "", language: "en_US", layout: null, session: "gnome", logged_in: true} |
|
|
|
language: "en_US", |
|
|
|
]; |
|
|
|
layout: null, |
|
|
|
|
|
|
|
session: "gnome", |
|
|
|
lightdm.num_users= lightdm.users.length; |
|
|
|
logged_in: false |
|
|
|
lightdm.timed_login_delay= 0; //set to a number higher than 0 for timed login simulation
|
|
|
|
}, |
|
|
|
lightdm.timed_login_user= lightdm.timed_login_delay > 0 ? lightdm.users[0] : null; |
|
|
|
{ |
|
|
|
|
|
|
|
name: "brucew", |
|
|
|
lightdm.get_string_property= function() {}; |
|
|
|
real_name: "Batman", |
|
|
|
lightdm.get_integer_property= function() {}; |
|
|
|
display_name: "Bruce Wayne", |
|
|
|
lightdm.get_boolean_property= function() {}; |
|
|
|
image: "", |
|
|
|
lightdm.cancel_timed_login= function() { |
|
|
|
language: "en_US", |
|
|
|
_lightdm_mock_check_argument_length(arguments, 0); |
|
|
|
layout: null, |
|
|
|
lightdm._timed_login_cancelled= true; |
|
|
|
session: "cinnamon", |
|
|
|
}; |
|
|
|
logged_in: false |
|
|
|
|
|
|
|
}, |
|
|
|
lightdm.provide_secret= function(secret) { |
|
|
|
{ |
|
|
|
if (typeof lightdm._username == 'undefined' || !lightdm._username) { |
|
|
|
name: "peterp", |
|
|
|
|
|
|
|
real_name: "Spiderman", |
|
|
|
|
|
|
|
display_name: "Peter Parker", |
|
|
|
|
|
|
|
image: "", |
|
|
|
|
|
|
|
language: "en_US", |
|
|
|
|
|
|
|
layout: null, |
|
|
|
|
|
|
|
session: "gnome", |
|
|
|
|
|
|
|
logged_in: true |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
name: "clarkk2", |
|
|
|
|
|
|
|
real_name: "Superman", |
|
|
|
|
|
|
|
display_name: "Clark Kent", |
|
|
|
|
|
|
|
image: "", |
|
|
|
|
|
|
|
language: "en_US", |
|
|
|
|
|
|
|
layout: null, |
|
|
|
|
|
|
|
session: "gnome", |
|
|
|
|
|
|
|
logged_in: false |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
name: "brucew2", |
|
|
|
|
|
|
|
real_name: "Batman", |
|
|
|
|
|
|
|
display_name: "Bruce Wayne", |
|
|
|
|
|
|
|
image: "", |
|
|
|
|
|
|
|
language: "en_US", |
|
|
|
|
|
|
|
layout: null, |
|
|
|
|
|
|
|
session: "cinnamon", |
|
|
|
|
|
|
|
logged_in: false |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
name: "peterp2", |
|
|
|
|
|
|
|
real_name: "Spiderman", |
|
|
|
|
|
|
|
display_name: "Peter Parker", |
|
|
|
|
|
|
|
image: "", |
|
|
|
|
|
|
|
language: "en_US", |
|
|
|
|
|
|
|
layout: null, |
|
|
|
|
|
|
|
session: "gnome", |
|
|
|
|
|
|
|
logged_in: true |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
]; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
lightdm.num_users = lightdm.users.length; |
|
|
|
|
|
|
|
lightdm.timed_login_delay = 0; //set to a number higher than 0 for timed login simulation
|
|
|
|
|
|
|
|
lightdm.timed_login_user = lightdm.timed_login_delay > 0 ? lightdm.users[ 0 ] : null; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
lightdm.get_string_property = function() { |
|
|
|
|
|
|
|
}; |
|
|
|
|
|
|
|
lightdm.get_integer_property = function() { |
|
|
|
|
|
|
|
}; |
|
|
|
|
|
|
|
lightdm.get_boolean_property = function() { |
|
|
|
|
|
|
|
}; |
|
|
|
|
|
|
|
lightdm.cancel_timed_login = function() { |
|
|
|
|
|
|
|
_lightdm_mock_check_argument_length( arguments, 0 ); |
|
|
|
|
|
|
|
lightdm._timed_login_cancelled = true; |
|
|
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
lightdm.provide_secret = function( secret ) { |
|
|
|
|
|
|
|
if ( typeof lightdm._username == 'undefined' || ! lightdm._username ) { |
|
|
|
throw "must call start_authentication first" |
|
|
|
throw "must call start_authentication first" |
|
|
|
} |
|
|
|
} |
|
|
|
_lightdm_mock_check_argument_length(arguments, 1); |
|
|
|
_lightdm_mock_check_argument_length( arguments, 1 ); |
|
|
|
var user= _lightdm_mock_get_user(lightdm.username); |
|
|
|
var user = _lightdm_mock_get_user( lightdm.username ); |
|
|
|
|
|
|
|
|
|
|
|
if (!user && secret == lightdm._username) { |
|
|
|
if ( ! user && secret == lightdm._username ) { |
|
|
|
lightdm.is_authenticated= true; |
|
|
|
lightdm.is_authenticated = true; |
|
|
|
lightdm.authentication_user= user; |
|
|
|
lightdm.authentication_user = user; |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
lightdm.is_authenticated= false; |
|
|
|
lightdm.is_authenticated = false; |
|
|
|
lightdm.authentication_user= null; |
|
|
|
lightdm.authentication_user = null; |
|
|
|
lightdm._username= null; |
|
|
|
lightdm._username = null; |
|
|
|
} |
|
|
|
} |
|
|
|
authentication_complete(); |
|
|
|
authentication_complete(); |
|
|
|
}; |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
lightdm.start_authentication= function(username) { |
|
|
|
lightdm.start_authentication = function( username ) { |
|
|
|
if ('undefined' === typeof username) { |
|
|
|
if ( 'undefined' === typeof username ) { |
|
|
|
show_prompt("Username?", 'text'); |
|
|
|
show_prompt( "Username?", 'text' ); |
|
|
|
lightdm.awaiting_username = true; |
|
|
|
lightdm.awaiting_username = true; |
|
|
|
return; |
|
|
|
return; |
|
|
|
} |
|
|
|
} |
|
|
|
_lightdm_mock_check_argument_length(arguments, 1); |
|
|
|
_lightdm_mock_check_argument_length( arguments, 1 ); |
|
|
|
if (lightdm._username) { |
|
|
|
if ( lightdm._username ) { |
|
|
|
throw "Already authenticating!"; |
|
|
|
throw "Already authenticating!"; |
|
|
|
} |
|
|
|
} |
|
|
|
var user= _lightdm_mock_get_user(username); |
|
|
|
var user = _lightdm_mock_get_user( username ); |
|
|
|
if (!user) { |
|
|
|
if ( ! user ) { |
|
|
|
show_error(username + " is an invalid user"); |
|
|
|
show_error( username + " is an invalid user" ); |
|
|
|
} |
|
|
|
} |
|
|
|
show_prompt("Password: "); |
|
|
|
show_prompt( "Password: " ); |
|
|
|
lightdm._username= username; |
|
|
|
lightdm._username = username; |
|
|
|
}; |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
lightdm.cancel_authentication= function() { |
|
|
|
lightdm.cancel_authentication = function() { |
|
|
|
_lightdm_mock_check_argument_length(arguments, 0); |
|
|
|
_lightdm_mock_check_argument_length( arguments, 0 ); |
|
|
|
if (!lightdm._username) { |
|
|
|
if ( ! lightdm._username ) { |
|
|
|
console.log("we are not authenticating"); |
|
|
|
console.log( "we are not authenticating" ); |
|
|
|
} |
|
|
|
} |
|
|
|
lightdm._username= null; |
|
|
|
lightdm._username = null; |
|
|
|
}; |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
lightdm.suspend= function() { |
|
|
|
lightdm.suspend = function() { |
|
|
|
alert("System Suspended. Bye Bye"); |
|
|
|
alert( "System Suspended. Bye Bye" ); |
|
|
|
document.location.reload(true); |
|
|
|
document.location.reload( true ); |
|
|
|
}; |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
lightdm.hibernate= function() { |
|
|
|
lightdm.hibernate = function() { |
|
|
|
alert("System Hibernated. Bye Bye"); |
|
|
|
alert( "System Hibernated. Bye Bye" ); |
|
|
|
document.location.reload(true); |
|
|
|
document.location.reload( true ); |
|
|
|
}; |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
lightdm.restart= function() { |
|
|
|
lightdm.restart = function() { |
|
|
|
alert("System restart. Bye Bye"); |
|
|
|
alert( "System restart. Bye Bye" ); |
|
|
|
document.location.reload(true); |
|
|
|
document.location.reload( true ); |
|
|
|
}; |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
lightdm.shutdown= function() { |
|
|
|
lightdm.shutdown = function() { |
|
|
|
alert("System Shutdown. Bye Bye"); |
|
|
|
alert( "System Shutdown. Bye Bye" ); |
|
|
|
document.location.reload(true); |
|
|
|
document.location.reload( true ); |
|
|
|
}; |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
lightdm.login= function(user, session) { |
|
|
|
lightdm.login = function( user, session ) { |
|
|
|
_lightdm_mock_check_argument_length(arguments, 2); |
|
|
|
_lightdm_mock_check_argument_length( arguments, 2 ); |
|
|
|
if (!lightdm.is_authenticated) { |
|
|
|
if ( ! lightdm.is_authenticated ) { |
|
|
|
throw "The system is not authenticated"; |
|
|
|
throw "The system is not authenticated"; |
|
|
|
} |
|
|
|
} |
|
|
|
if (user !== lightdm.authentication_user) { |
|
|
|
if ( user !== lightdm.authentication_user ) { |
|
|
|
throw "this user is not authenticated"; |
|
|
|
throw "this user is not authenticated"; |
|
|
|
} |
|
|
|
} |
|
|
|
alert("logged in successfully!!"); |
|
|
|
alert( "logged in successfully!!" ); |
|
|
|
document.location.reload(true); |
|
|
|
document.location.reload( true ); |
|
|
|
}; |
|
|
|
}; |
|
|
|
lightdm.authenticate = function(session) { |
|
|
|
lightdm.authenticate = function( session ) { |
|
|
|
lightdm.login(null, session); |
|
|
|
lightdm.login( null, session ); |
|
|
|
}; |
|
|
|
}; |
|
|
|
lightdm.respond = function(response) { |
|
|
|
lightdm.respond = function( response ) { |
|
|
|
if (true === lightdm.awaiting_username) { |
|
|
|
if ( true === lightdm.awaiting_username ) { |
|
|
|
lightdm.awaiting_username = false; |
|
|
|
lightdm.awaiting_username = false; |
|
|
|
lightdm.start_authentication(response); |
|
|
|
lightdm.start_authentication( response ); |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
lightdm.provide_secret(response); |
|
|
|
lightdm.provide_secret( response ); |
|
|
|
} |
|
|
|
} |
|
|
|
}; |
|
|
|
}; |
|
|
|
lightdm.start_session_sync = function() { |
|
|
|
lightdm.start_session_sync = function() { |
|
|
|
lightdm.login(null, null); |
|
|
|
lightdm.login( null, null ); |
|
|
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if ( lightdm.timed_login_delay > 0 ) { |
|
|
|
|
|
|
|
setTimeout( function() { |
|
|
|
|
|
|
|
if ( ! lightdm._timed_login_cancelled() ) { |
|
|
|
|
|
|
|
timed_login(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
}, lightdm.timed_login_delay ); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var config = {}, |
|
|
|
|
|
|
|
greeterutil = {}; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
config.get_str = function( section, key ) { |
|
|
|
|
|
|
|
var branding = { |
|
|
|
|
|
|
|
logo: 'img/antergos.png', |
|
|
|
|
|
|
|
user_logo: 'ing/antergos-logo-user.png', |
|
|
|
|
|
|
|
background_images: '/usr/share/antergos/wallpapers' |
|
|
|
|
|
|
|
}; |
|
|
|
|
|
|
|
if ( 'branding' === section ) { |
|
|
|
|
|
|
|
return branding[ key ]; |
|
|
|
|
|
|
|
} |
|
|
|
}; |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
if (lightdm.timed_login_delay > 0) { |
|
|
|
greeterutil.dirlist = function( directory ) { |
|
|
|
setTimeout(function() { if (!lightdm._timed_login_cancelled()) timed_login();}, lightdm.timed_login_delay); |
|
|
|
if ( '/usr/share/antergos/wallpapers' === directory ) { |
|
|
|
|
|
|
|
return [ |
|
|
|
|
|
|
|
'/usr/share/antergos/wallpapers/83II_by_bo0xVn.jpg', |
|
|
|
|
|
|
|
'/usr/share/antergos/wallpapers/antergos-wallpaper.png', |
|
|
|
|
|
|
|
'/usr/share/antergos/wallpapers/as_time_goes_by____by_moskanon-d5dgvt8.jpg', |
|
|
|
|
|
|
|
'/usr/share/antergos/wallpapers/autumn_hike___plant_details_by_aoiban-d5l7y83.jpg', |
|
|
|
|
|
|
|
'/usr/share/antergos/wallpapers/blossom_by_snipes2.jpg', |
|
|
|
|
|
|
|
'/usr/share/antergos/wallpapers/c65sk3mshowxrtlljbvh.jpg', |
|
|
|
|
|
|
|
'/usr/share/antergos/wallpapers/early_morning_by_kylekc.jpg', |
|
|
|
|
|
|
|
'/usr/share/antergos/wallpapers/extinction_by_signcropstealer-d5j4y84.jpg', |
|
|
|
|
|
|
|
'/usr/share/antergos/wallpapers/field_by_stevenfields-d59ap2i.jpg', |
|
|
|
|
|
|
|
'/usr/share/antergos/wallpapers/Grass_by_masha_darkelf666.jpg', |
|
|
|
|
|
|
|
'/usr/share/antergos/wallpapers/Grass_Fullscreen.jpg', |
|
|
|
|
|
|
|
'/usr/share/antergos/wallpapers/humble_by_splendidofsun-d5g47hb.jpg', |
|
|
|
|
|
|
|
'/usr/share/antergos/wallpapers/In_the_Grass.jpg', |
|
|
|
|
|
|
|
'/usr/share/antergos/wallpapers/morning_light.jpg', |
|
|
|
|
|
|
|
'/usr/share/antergos/wallpapers/Nautilus_Fullscreen.jpg', |
|
|
|
|
|
|
|
'/usr/share/antergos/wallpapers/nikon_d40.jpg', |
|
|
|
|
|
|
|
'/usr/share/antergos/wallpapers/sky_full_of_stars.jpg', |
|
|
|
|
|
|
|
'/usr/share/antergos/wallpapers/solely_by_stevenfields.jpg', |
|
|
|
|
|
|
|
'/usr/share/antergos/wallpapers/the_world_inside_my_lens__by_moskanon-d5fsiqs.jpg', |
|
|
|
|
|
|
|
'/usr/share/antergos/wallpapers/white_line_by_snipes2.jpg' |
|
|
|
|
|
|
|
] |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
function _lightdm_mock_check_argument_length(args, length) { |
|
|
|
function _lightdm_mock_check_argument_length( args, length ) { |
|
|
|
if (args.length != length) { |
|
|
|
if ( args.length != length ) { |
|
|
|
throw "incorrect number of arguments in function call"; |
|
|
|
throw "incorrect number of arguments in function call"; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
function _lightdm_mock_get_user(username) { |
|
|
|
function _lightdm_mock_get_user( username ) { |
|
|
|
var user= null; |
|
|
|
var user = null; |
|
|
|
for (var i= 0; i < lightdm.users.length; ++i) { |
|
|
|
for ( var i = 0; i < lightdm.users.length; ++ i ) { |
|
|
|
if (lightdm.users[i].name == username) { |
|
|
|
if ( lightdm.users[ i ].name == username ) { |
|
|
|
user= lightdm.users[i]; |
|
|
|
user = lightdm.users[ i ]; |
|
|
|
break; |
|
|
|
break; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|