SEBWIN-329: Implemented new configuration keys to control access to log information during runtime.
This commit is contained in:
parent
8b0cc6db71
commit
b29828b724
12 changed files with 102 additions and 58 deletions
|
@ -6,6 +6,7 @@
|
|||
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
*/
|
||||
|
||||
using System.Collections.Generic;
|
||||
using SafeExamBrowser.Contracts.Configuration.Settings;
|
||||
using SafeExamBrowser.Contracts.Logging;
|
||||
|
||||
|
@ -21,6 +22,26 @@ namespace SafeExamBrowser.Configuration.ConfigurationData
|
|||
}
|
||||
}
|
||||
|
||||
private void MapApplicationLogAccess(IDictionary<string, object> rawData, Settings settings)
|
||||
{
|
||||
var hasValue = rawData.TryGetValue(Keys.General.AllowApplicationLog, out var value);
|
||||
|
||||
if (hasValue && value is bool allow)
|
||||
{
|
||||
settings.AllowApplicationLogAccess = allow;
|
||||
}
|
||||
|
||||
if (settings.AllowApplicationLogAccess)
|
||||
{
|
||||
settings.ActionCenter.ShowApplicationLog = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
settings.ActionCenter.ShowApplicationLog = false;
|
||||
settings.Taskbar.ShowApplicationLog = false;
|
||||
}
|
||||
}
|
||||
|
||||
private void MapLogLevel(Settings settings, object value)
|
||||
{
|
||||
const int ERROR = 0, WARNING = 1, INFO = 2;
|
||||
|
|
|
@ -12,11 +12,10 @@ namespace SafeExamBrowser.Configuration.ConfigurationData
|
|||
{
|
||||
internal partial class DataMapper
|
||||
{
|
||||
private void MapApplicationLog(Settings settings, object value)
|
||||
private void MapApplicationLogButton(Settings settings, object value)
|
||||
{
|
||||
if (value is bool show)
|
||||
{
|
||||
settings.ActionCenter.ShowApplicationLog = show;
|
||||
settings.Taskbar.ShowApplicationLog = show;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -24,6 +24,7 @@ namespace SafeExamBrowser.Configuration.ConfigurationData
|
|||
MapUserInterfaceSettings(item.Key, item.Value, settings);
|
||||
}
|
||||
|
||||
MapApplicationLogAccess(rawData, settings);
|
||||
MapKioskMode(rawData, settings);
|
||||
MapUserAgentMode(rawData, settings);
|
||||
}
|
||||
|
@ -177,13 +178,10 @@ namespace SafeExamBrowser.Configuration.ConfigurationData
|
|||
{
|
||||
switch (key)
|
||||
{
|
||||
case Keys.UserInterface.AllowKeyboardLayout:
|
||||
case Keys.UserInterface.ShowKeyboardLayout:
|
||||
MapKeyboardLayout(settings, value);
|
||||
break;
|
||||
case Keys.UserInterface.AllowLog:
|
||||
MapApplicationLog(settings, value);
|
||||
break;
|
||||
case Keys.UserInterface.AllowWirelessNetwork:
|
||||
case Keys.UserInterface.ShowWirelessNetwork:
|
||||
MapWirelessNetwork(settings, value);
|
||||
break;
|
||||
case Keys.UserInterface.ShowClock:
|
||||
|
@ -192,6 +190,9 @@ namespace SafeExamBrowser.Configuration.ConfigurationData
|
|||
case Keys.UserInterface.UserInterfaceMode:
|
||||
MapUserInterfaceMode(settings, value);
|
||||
break;
|
||||
case Keys.UserInterface.Taskbar.ShowApplicationLog:
|
||||
MapApplicationLogButton(settings, value);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -144,6 +144,8 @@ namespace SafeExamBrowser.Configuration.ConfigurationData
|
|||
|
||||
settings.ServicePolicy = ServicePolicy.Optional;
|
||||
|
||||
settings.AllowApplicationLogAccess = false;
|
||||
|
||||
settings.Taskbar.EnableTaskbar = true;
|
||||
settings.Taskbar.ShowApplicationInfo = false;
|
||||
settings.Taskbar.ShowApplicationLog = false;
|
||||
|
|
|
@ -61,6 +61,7 @@ namespace SafeExamBrowser.Configuration.ConfigurationData
|
|||
internal static class General
|
||||
{
|
||||
internal const string AdminPasswordHash = "hashedAdminPassword";
|
||||
internal const string AllowApplicationLog = "allowApplicationLog";
|
||||
internal const string LogLevel = "logLevel";
|
||||
internal const string QuitPasswordHash = "hashedQuitPassword";
|
||||
internal const string StartUrl = "startURL";
|
||||
|
@ -119,11 +120,15 @@ namespace SafeExamBrowser.Configuration.ConfigurationData
|
|||
|
||||
internal static class UserInterface
|
||||
{
|
||||
internal const string AllowKeyboardLayout = "showInputLanguage";
|
||||
internal const string AllowLog = "showLogButton";
|
||||
internal const string AllowWirelessNetwork = "allowWlan";
|
||||
internal const string ShowClock = "showTime";
|
||||
internal const string ShowKeyboardLayout = "showInputLanguage";
|
||||
internal const string ShowWirelessNetwork = "allowWlan";
|
||||
internal const string UserInterfaceMode = "touchOptimized";
|
||||
|
||||
internal static class Taskbar
|
||||
{
|
||||
internal const string ShowApplicationLog = "showApplicationLogButton";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -28,15 +28,20 @@ namespace SafeExamBrowser.Contracts.Configuration.Settings
|
|||
public string AdminPasswordHash { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The mode which determines the configuration behaviour.
|
||||
/// Determines whether any log information will be accessible via the user interface.
|
||||
/// </summary>
|
||||
public ConfigurationMode ConfigurationMode { get; set; }
|
||||
public bool AllowApplicationLogAccess { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// All browser-related settings.
|
||||
/// </summary>
|
||||
public BrowserSettings Browser { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The mode which determines the configuration behaviour.
|
||||
/// </summary>
|
||||
public ConfigurationMode ConfigurationMode { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// All keyboard-related settings.
|
||||
/// </summary>
|
||||
|
|
|
@ -16,19 +16,19 @@ namespace SafeExamBrowser.Contracts.UserInterface.Windows
|
|||
/// </summary>
|
||||
public interface IRuntimeWindow : ILogObserver, IProgressIndicator, IWindow
|
||||
{
|
||||
/// <summary>
|
||||
/// Determines whether the application log is visible.
|
||||
/// </summary>
|
||||
bool ShowLog { set; }
|
||||
|
||||
/// <summary>
|
||||
/// Determines whether the progress bar is visible.
|
||||
/// </summary>
|
||||
bool ShowProgressBar { set; }
|
||||
|
||||
/// <summary>
|
||||
/// Determines whether the window will stay on top of other windows.
|
||||
/// </summary>
|
||||
bool TopMost { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Hides the progress bar.
|
||||
/// </summary>
|
||||
void HideProgressBar();
|
||||
|
||||
/// <summary>
|
||||
/// Shows the progress bar.
|
||||
/// </summary>
|
||||
void ShowProgressBar();
|
||||
bool TopMost { set; }
|
||||
}
|
||||
}
|
||||
|
|
|
@ -157,7 +157,7 @@ namespace SafeExamBrowser.Runtime
|
|||
{
|
||||
runtimeWindow.Show();
|
||||
runtimeWindow.BringToForeground();
|
||||
runtimeWindow.ShowProgressBar();
|
||||
runtimeWindow.ShowProgressBar = true;
|
||||
logger.Info(AppendDivider("Session Start Procedure"));
|
||||
|
||||
if (SessionIsRunning)
|
||||
|
@ -191,9 +191,10 @@ namespace SafeExamBrowser.Runtime
|
|||
{
|
||||
RegisterSessionEvents();
|
||||
|
||||
runtimeWindow.HideProgressBar();
|
||||
runtimeWindow.UpdateStatus(TextKey.RuntimeWindow_ApplicationRunning);
|
||||
runtimeWindow.ShowProgressBar = false;
|
||||
runtimeWindow.ShowLog = Session.Settings.AllowApplicationLogAccess;
|
||||
runtimeWindow.TopMost = Session.Settings.KioskMode != KioskMode.None;
|
||||
runtimeWindow.UpdateStatus(TextKey.RuntimeWindow_ApplicationRunning);
|
||||
|
||||
if (Session.Settings.KioskMode == KioskMode.DisableExplorerShell)
|
||||
{
|
||||
|
@ -222,7 +223,7 @@ namespace SafeExamBrowser.Runtime
|
|||
{
|
||||
if (SessionIsRunning)
|
||||
{
|
||||
runtimeWindow.HideProgressBar();
|
||||
runtimeWindow.ShowProgressBar = false;
|
||||
runtimeWindow.UpdateStatus(TextKey.RuntimeWindow_ApplicationRunning);
|
||||
runtimeWindow.TopMost = Session.Settings.KioskMode != KioskMode.None;
|
||||
|
||||
|
@ -237,7 +238,7 @@ namespace SafeExamBrowser.Runtime
|
|||
{
|
||||
runtimeWindow.Show();
|
||||
runtimeWindow.BringToForeground();
|
||||
runtimeWindow.ShowProgressBar();
|
||||
runtimeWindow.ShowProgressBar = true;
|
||||
logger.Info(AppendDivider("Session Stop Procedure"));
|
||||
|
||||
DeregisterSessionEvents();
|
||||
|
|
|
@ -54,7 +54,8 @@
|
|||
<TextBlock x:Name="StatusTextBlock" Grid.Row="1" FontSize="12" FontWeight="Bold" HorizontalAlignment="Center"
|
||||
Text="{Binding Status}" VerticalAlignment="Center" />
|
||||
<Border Grid.Row="2" BorderBrush="DodgerBlue" BorderThickness="0,0.5,0,0">
|
||||
<ScrollViewer x:Name="LogScrollViewer" HorizontalScrollBarVisibility="Auto" VerticalScrollBarVisibility="Auto" Margin="0,10,0,0" Template="{StaticResource SmallBarScrollViewer}">
|
||||
<ScrollViewer x:Name="LogScrollViewer" HorizontalScrollBarVisibility="Auto" VerticalScrollBarVisibility="Auto" Margin="0,10,0,0"
|
||||
Template="{StaticResource SmallBarScrollViewer}" Visibility="Collapsed">
|
||||
<TextBlock x:Name="LogTextBlock" Background="Transparent" FontFamily="Consolas" FontSize="10" />
|
||||
</ScrollViewer>
|
||||
</Border>
|
||||
|
|
|
@ -25,10 +25,26 @@ namespace SafeExamBrowser.UserInterface.Desktop
|
|||
private RuntimeWindowViewModel model;
|
||||
private WindowClosingEventHandler closing;
|
||||
|
||||
public bool ShowLog
|
||||
{
|
||||
set => Dispatcher.Invoke(() => LogScrollViewer.Visibility = value ? Visibility.Visible : Visibility.Collapsed);
|
||||
}
|
||||
|
||||
bool IRuntimeWindow.ShowProgressBar
|
||||
{
|
||||
set
|
||||
{
|
||||
Dispatcher.Invoke(() =>
|
||||
{
|
||||
model.AnimatedBorderVisibility = value ? Visibility.Hidden : Visibility.Visible;
|
||||
model.ProgressBarVisibility = value ? Visibility.Visible : Visibility.Hidden;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
public bool TopMost
|
||||
{
|
||||
get { return Dispatcher.Invoke(() => Topmost); }
|
||||
set { Dispatcher.Invoke(() => Topmost = value); }
|
||||
set => Dispatcher.Invoke(() => Topmost = value);
|
||||
}
|
||||
|
||||
event WindowClosingEventHandler IWindow.Closing
|
||||
|
@ -67,12 +83,6 @@ namespace SafeExamBrowser.UserInterface.Desktop
|
|||
Dispatcher.Invoke(base.Hide);
|
||||
}
|
||||
|
||||
public void HideProgressBar()
|
||||
{
|
||||
model.AnimatedBorderVisibility = Visibility.Visible;
|
||||
model.ProgressBarVisibility = Visibility.Hidden;
|
||||
}
|
||||
|
||||
public void Notify(ILogContent content)
|
||||
{
|
||||
Dispatcher.Invoke(() =>
|
||||
|
@ -107,12 +117,6 @@ namespace SafeExamBrowser.UserInterface.Desktop
|
|||
model.CurrentProgress = value;
|
||||
}
|
||||
|
||||
public void ShowProgressBar()
|
||||
{
|
||||
model.AnimatedBorderVisibility = Visibility.Hidden;
|
||||
model.ProgressBarVisibility = Visibility.Visible;
|
||||
}
|
||||
|
||||
public void UpdateStatus(TextKey key, bool busyIndication = false)
|
||||
{
|
||||
model.Status = text.Get(key);
|
||||
|
|
|
@ -54,7 +54,8 @@
|
|||
<TextBlock x:Name="StatusTextBlock" Grid.Row="1" FontSize="12" FontWeight="Bold" HorizontalAlignment="Center"
|
||||
Text="{Binding Status}" VerticalAlignment="Center" />
|
||||
<Border Grid.Row="2" BorderBrush="DodgerBlue" BorderThickness="0,0.5,0,0">
|
||||
<ScrollViewer x:Name="LogScrollViewer" HorizontalScrollBarVisibility="Auto" VerticalScrollBarVisibility="Auto" Margin="0,10,0,0" Template="{StaticResource SmallBarScrollViewer}">
|
||||
<ScrollViewer x:Name="LogScrollViewer" HorizontalScrollBarVisibility="Auto" VerticalScrollBarVisibility="Auto" Margin="0,10,0,0"
|
||||
Template="{StaticResource SmallBarScrollViewer}" Visibility="Collapsed">
|
||||
<TextBlock x:Name="LogTextBlock" Background="Transparent" FontFamily="Consolas" FontSize="10" />
|
||||
</ScrollViewer>
|
||||
</Border>
|
||||
|
|
|
@ -25,10 +25,26 @@ namespace SafeExamBrowser.UserInterface.Mobile
|
|||
private RuntimeWindowViewModel model;
|
||||
private WindowClosingEventHandler closing;
|
||||
|
||||
public bool ShowLog
|
||||
{
|
||||
set => Dispatcher.Invoke(() => LogScrollViewer.Visibility = value ? Visibility.Visible : Visibility.Collapsed);
|
||||
}
|
||||
|
||||
bool IRuntimeWindow.ShowProgressBar
|
||||
{
|
||||
set
|
||||
{
|
||||
Dispatcher.Invoke(() =>
|
||||
{
|
||||
model.AnimatedBorderVisibility = value ? Visibility.Hidden : Visibility.Visible;
|
||||
model.ProgressBarVisibility = value ? Visibility.Visible : Visibility.Hidden;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
public bool TopMost
|
||||
{
|
||||
get { return Dispatcher.Invoke(() => Topmost); }
|
||||
set { Dispatcher.Invoke(() => Topmost = value); }
|
||||
set => Dispatcher.Invoke(() => Topmost = value);
|
||||
}
|
||||
|
||||
event WindowClosingEventHandler IWindow.Closing
|
||||
|
@ -67,12 +83,6 @@ namespace SafeExamBrowser.UserInterface.Mobile
|
|||
Dispatcher.Invoke(base.Hide);
|
||||
}
|
||||
|
||||
public void HideProgressBar()
|
||||
{
|
||||
model.AnimatedBorderVisibility = Visibility.Visible;
|
||||
model.ProgressBarVisibility = Visibility.Hidden;
|
||||
}
|
||||
|
||||
public void Notify(ILogContent content)
|
||||
{
|
||||
Dispatcher.Invoke(() =>
|
||||
|
@ -107,12 +117,6 @@ namespace SafeExamBrowser.UserInterface.Mobile
|
|||
model.CurrentProgress = value;
|
||||
}
|
||||
|
||||
public void ShowProgressBar()
|
||||
{
|
||||
model.AnimatedBorderVisibility = Visibility.Hidden;
|
||||
model.ProgressBarVisibility = Visibility.Visible;
|
||||
}
|
||||
|
||||
public void UpdateStatus(TextKey key, bool busyIndication = false)
|
||||
{
|
||||
model.Status = text.Get(key);
|
||||
|
|
Loading…
Reference in a new issue