diff --git a/SafeExamBrowser.Configuration/ConfigurationData/DataMapper.General.cs b/SafeExamBrowser.Configuration/ConfigurationData/DataMapper.General.cs index 4d2d514a..053642be 100644 --- a/SafeExamBrowser.Configuration/ConfigurationData/DataMapper.General.cs +++ b/SafeExamBrowser.Configuration/ConfigurationData/DataMapper.General.cs @@ -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 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; diff --git a/SafeExamBrowser.Configuration/ConfigurationData/DataMapper.UserInterface.cs b/SafeExamBrowser.Configuration/ConfigurationData/DataMapper.UserInterface.cs index dab6bbb7..bcbf3522 100644 --- a/SafeExamBrowser.Configuration/ConfigurationData/DataMapper.UserInterface.cs +++ b/SafeExamBrowser.Configuration/ConfigurationData/DataMapper.UserInterface.cs @@ -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; } } diff --git a/SafeExamBrowser.Configuration/ConfigurationData/DataMapper.cs b/SafeExamBrowser.Configuration/ConfigurationData/DataMapper.cs index e0fbaac0..ee9fb9fd 100644 --- a/SafeExamBrowser.Configuration/ConfigurationData/DataMapper.cs +++ b/SafeExamBrowser.Configuration/ConfigurationData/DataMapper.cs @@ -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; } } } diff --git a/SafeExamBrowser.Configuration/ConfigurationData/DataValues.cs b/SafeExamBrowser.Configuration/ConfigurationData/DataValues.cs index b375e403..6d1106eb 100644 --- a/SafeExamBrowser.Configuration/ConfigurationData/DataValues.cs +++ b/SafeExamBrowser.Configuration/ConfigurationData/DataValues.cs @@ -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; diff --git a/SafeExamBrowser.Configuration/ConfigurationData/Keys.cs b/SafeExamBrowser.Configuration/ConfigurationData/Keys.cs index 212848e2..4e3c3192 100644 --- a/SafeExamBrowser.Configuration/ConfigurationData/Keys.cs +++ b/SafeExamBrowser.Configuration/ConfigurationData/Keys.cs @@ -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"; + } } } } diff --git a/SafeExamBrowser.Contracts/Configuration/Settings/Settings.cs b/SafeExamBrowser.Contracts/Configuration/Settings/Settings.cs index 8ce08374..a06b0983 100644 --- a/SafeExamBrowser.Contracts/Configuration/Settings/Settings.cs +++ b/SafeExamBrowser.Contracts/Configuration/Settings/Settings.cs @@ -28,15 +28,20 @@ namespace SafeExamBrowser.Contracts.Configuration.Settings public string AdminPasswordHash { get; set; } /// - /// The mode which determines the configuration behaviour. + /// Determines whether any log information will be accessible via the user interface. /// - public ConfigurationMode ConfigurationMode { get; set; } + public bool AllowApplicationLogAccess { get; set; } /// /// All browser-related settings. /// public BrowserSettings Browser { get; set; } + /// + /// The mode which determines the configuration behaviour. + /// + public ConfigurationMode ConfigurationMode { get; set; } + /// /// All keyboard-related settings. /// diff --git a/SafeExamBrowser.Contracts/UserInterface/Windows/IRuntimeWindow.cs b/SafeExamBrowser.Contracts/UserInterface/Windows/IRuntimeWindow.cs index c028d35e..9119fd21 100644 --- a/SafeExamBrowser.Contracts/UserInterface/Windows/IRuntimeWindow.cs +++ b/SafeExamBrowser.Contracts/UserInterface/Windows/IRuntimeWindow.cs @@ -16,19 +16,19 @@ namespace SafeExamBrowser.Contracts.UserInterface.Windows /// public interface IRuntimeWindow : ILogObserver, IProgressIndicator, IWindow { + /// + /// Determines whether the application log is visible. + /// + bool ShowLog { set; } + + /// + /// Determines whether the progress bar is visible. + /// + bool ShowProgressBar { set; } + /// /// Determines whether the window will stay on top of other windows. /// - bool TopMost { get; set; } - - /// - /// Hides the progress bar. - /// - void HideProgressBar(); - - /// - /// Shows the progress bar. - /// - void ShowProgressBar(); + bool TopMost { set; } } } diff --git a/SafeExamBrowser.Runtime/RuntimeController.cs b/SafeExamBrowser.Runtime/RuntimeController.cs index f18a8bc6..1640f183 100644 --- a/SafeExamBrowser.Runtime/RuntimeController.cs +++ b/SafeExamBrowser.Runtime/RuntimeController.cs @@ -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(); diff --git a/SafeExamBrowser.UserInterface.Desktop/RuntimeWindow.xaml b/SafeExamBrowser.UserInterface.Desktop/RuntimeWindow.xaml index 787ae7f1..8859c749 100644 --- a/SafeExamBrowser.UserInterface.Desktop/RuntimeWindow.xaml +++ b/SafeExamBrowser.UserInterface.Desktop/RuntimeWindow.xaml @@ -54,7 +54,8 @@ - + diff --git a/SafeExamBrowser.UserInterface.Desktop/RuntimeWindow.xaml.cs b/SafeExamBrowser.UserInterface.Desktop/RuntimeWindow.xaml.cs index 2e0ee802..c80b2876 100644 --- a/SafeExamBrowser.UserInterface.Desktop/RuntimeWindow.xaml.cs +++ b/SafeExamBrowser.UserInterface.Desktop/RuntimeWindow.xaml.cs @@ -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); diff --git a/SafeExamBrowser.UserInterface.Mobile/RuntimeWindow.xaml b/SafeExamBrowser.UserInterface.Mobile/RuntimeWindow.xaml index f7ebd6bb..7bc9534f 100644 --- a/SafeExamBrowser.UserInterface.Mobile/RuntimeWindow.xaml +++ b/SafeExamBrowser.UserInterface.Mobile/RuntimeWindow.xaml @@ -54,7 +54,8 @@ - + diff --git a/SafeExamBrowser.UserInterface.Mobile/RuntimeWindow.xaml.cs b/SafeExamBrowser.UserInterface.Mobile/RuntimeWindow.xaml.cs index 319e6174..b59cf751 100644 --- a/SafeExamBrowser.UserInterface.Mobile/RuntimeWindow.xaml.cs +++ b/SafeExamBrowser.UserInterface.Mobile/RuntimeWindow.xaml.cs @@ -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);