SEBWIN-426: Ensured that lock screen is not activated when lock or switch session is allowed.
This commit is contained in:
parent
f6a3cb485b
commit
3ef3bccd7e
1 changed files with 23 additions and 15 deletions
|
@ -590,30 +590,38 @@ namespace SafeExamBrowser.Client
|
||||||
|
|
||||||
private void SystemMonitor_SessionSwitched()
|
private void SystemMonitor_SessionSwitched()
|
||||||
{
|
{
|
||||||
|
var allow = !Settings.Service.IgnoreService && (!Settings.Service.DisableUserLock || !Settings.Service.DisableUserSwitch);
|
||||||
var message = text.Get(TextKey.LockScreen_UserSessionMessage);
|
var message = text.Get(TextKey.LockScreen_UserSessionMessage);
|
||||||
var title = text.Get(TextKey.LockScreen_Title);
|
var title = text.Get(TextKey.LockScreen_Title);
|
||||||
var continueOption = new LockScreenOption { Text = text.Get(TextKey.LockScreen_UserSessionContinueOption) };
|
var continueOption = new LockScreenOption { Text = text.Get(TextKey.LockScreen_UserSessionContinueOption) };
|
||||||
var terminateOption = new LockScreenOption { Text = text.Get(TextKey.LockScreen_UserSessionTerminateOption) };
|
var terminateOption = new LockScreenOption { Text = text.Get(TextKey.LockScreen_UserSessionTerminateOption) };
|
||||||
|
|
||||||
logger.Warn("Detected user session switch!");
|
if (allow)
|
||||||
|
|
||||||
if (!sessionLocked)
|
|
||||||
{
|
{
|
||||||
sessionLocked = true;
|
logger.Info("Detected user session switch, but user lock and/or user switch are allowed.");
|
||||||
|
|
||||||
var result = ShowLockScreen(message, title, new[] { continueOption, terminateOption });
|
|
||||||
|
|
||||||
if (result.OptionId == terminateOption.Id)
|
|
||||||
{
|
|
||||||
logger.Info("Attempting to shutdown as requested by the user...");
|
|
||||||
TryRequestShutdown();
|
|
||||||
}
|
|
||||||
|
|
||||||
sessionLocked = false;
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
logger.Info("Lock screen is already active.");
|
logger.Warn("Detected user session switch!");
|
||||||
|
|
||||||
|
if (!sessionLocked)
|
||||||
|
{
|
||||||
|
sessionLocked = true;
|
||||||
|
|
||||||
|
var result = ShowLockScreen(message, title, new[] { continueOption, terminateOption });
|
||||||
|
|
||||||
|
if (result.OptionId == terminateOption.Id)
|
||||||
|
{
|
||||||
|
logger.Info("Attempting to shutdown as requested by the user...");
|
||||||
|
TryRequestShutdown();
|
||||||
|
}
|
||||||
|
|
||||||
|
sessionLocked = false;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
logger.Info("Lock screen is already active.");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue