/* * Copyright (c) 2024 ETH Zürich, IT Services * * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ using SafeExamBrowser.Logging.Contracts; using SafeExamBrowser.Monitoring.Contracts.System; using SafeExamBrowser.Monitoring.Contracts.System.Events; using SafeExamBrowser.Monitoring.System.Components; using SafeExamBrowser.SystemComponents.Contracts.Registry; using SafeExamBrowser.WindowsApi.Contracts; namespace SafeExamBrowser.Monitoring.System { public class SystemSentinel : ISystemSentinel { private readonly Cursors cursors; private readonly EaseOfAccess easeOfAccess; private readonly StickyKeys stickyKeys; public event SentinelEventHandler CursorChanged; public event SentinelEventHandler EaseOfAccessChanged; public event SentinelEventHandler StickyKeysChanged; public SystemSentinel(ILogger logger, INativeMethods nativeMethods, IRegistry registry) { this.cursors = new Cursors(logger, registry); this.easeOfAccess = new EaseOfAccess(logger, registry); this.stickyKeys = new StickyKeys(logger, nativeMethods); } public bool DisableStickyKeys() { return stickyKeys.Disable(); } public bool EnableStickyKeys() { return stickyKeys.Enable(); } public bool RevertStickyKeys() { return stickyKeys.Revert(); } public void StartMonitoringCursors() { cursors.CursorChanged += (args) => CursorChanged?.Invoke(args); cursors.StartMonitoring(); } public void StartMonitoringEaseOfAccess() { easeOfAccess.EaseOfAccessChanged += (args) => EaseOfAccessChanged?.Invoke(args); easeOfAccess.StartMonitoring(); } public void StartMonitoringStickyKeys() { stickyKeys.Changed += (args) => StickyKeysChanged?.Invoke(args); stickyKeys.StartMonitoring(); } public void StopMonitoring() { cursors.StopMonitoring(); easeOfAccess.StopMonitoring(); stickyKeys.StopMonitoring(); } public bool VerifyCursors() { return cursors.Verify(); } public bool VerifyEaseOfAccess() { return easeOfAccess.Verify(); } } }