diff --git a/addon/globalPlugins/nvdaRd/__init__.py b/addon/globalPlugins/nvdaRd/__init__.py index 7f0b923..b564a01 100644 --- a/addon/globalPlugins/nvdaRd/__init__.py +++ b/addon/globalPlugins/nvdaRd/__init__.py @@ -18,7 +18,7 @@ import api import bdDetect import atexit -from systemUtils import _isSecureDesktop +from utils.security import isRunningOnSecureDesktop from IAccessibleHandler import SecureDesktopNVDAObject from .secureDesktop import SecureDesktopHandler @@ -46,7 +46,7 @@ def chooseNVDAObjectOverlayClasses(self, obj: NVDAObject, clsList: List[Type[NVD @classmethod def _updateRegistryForRdPipe(cls, install, rdp, citrix): - if _isSecureDesktop(): + if isRunningOnSecureDesktop(): return if citrix and not rdPipe.isCitrixSupported(): citrix = False @@ -91,17 +91,17 @@ def initializeOperatingModeServer(self): if configuration.getRecoverRemoteSpeech(): self._synthDetector = _SynthDetector() self._triggerBackgroundDetectRescan(True) - if not _isSecureDesktop(): + if not isRunningOnSecureDesktop(): post_sessionLockStateChanged.register(self._handleLockStateChanged) def initializeOperatingModeCommonClient(self): - if _isSecureDesktop(): + if isRunningOnSecureDesktop(): return self._ioThread = hwIo.ioThread.IoThread() self._ioThread.start() def initializeOperatingModeRdClient(self): - if _isSecureDesktop(): + if isRunningOnSecureDesktop(): return self._registerRdPipeInRegistry() self._handlers: Dict[str, handlers.RemoteHandler] = {} @@ -114,7 +114,7 @@ def initializeOperatingModeRdClient(self): self._initializeExistingPipes() def initializeOperatingModeSecureDesktop(self): - if _isSecureDesktop(): + if isRunningOnSecureDesktop(): return self._sdHandler: typing.Optional[SecureDesktopHandler] = None @@ -133,10 +133,10 @@ def __init__(self): self.initializeOperatingModeSecureDesktop() if ( configuredOperatingMode & configuration.OperatingMode.SERVER - or (configuredOperatingMode & configuration.OperatingMode.SECURE_DESKTOP and _isSecureDesktop()) + or (configuredOperatingMode & configuration.OperatingMode.SECURE_DESKTOP and isRunningOnSecureDesktop()) ): self.initializeOperatingModeServer() - if _isSecureDesktop(): + if isRunningOnSecureDesktop(): return config.post_configProfileSwitch.register(self._handlePostConfigProfileSwitch) gui.settingsDialogs.NVDASettingsDialog.categoryClasses.append(settingsPanel.NvdaRDSettingsPanel) @@ -170,14 +170,14 @@ def _handleNewPipe(self, action: directoryChanges.FileNotifyInformationAction, f handler.terminate() def terminateOperatingModeServer(self): - if not _isSecureDesktop(): + if not isRunningOnSecureDesktop(): post_sessionLockStateChanged.unregister(self._handleLockStateChanged) if self._synthDetector: self._synthDetector.terminate() bdDetect.scanForDevices.unregister(detection.bgScanRD) def terminateOperatingModeRdClient(self): - if _isSecureDesktop(): + if isRunningOnSecureDesktop(): return if self._pipeWatcher: self._pipeWatcher.stop() @@ -189,14 +189,14 @@ def terminateOperatingModeRdClient(self): self._unregisterRdPipeFromRegistry() def terminateOperatingModeCommonClient(self): - if _isSecureDesktop(): + if isRunningOnSecureDesktop(): return if self._ioThread: self._ioThread.stop() self._ioThread = None def terminateOperatingModeSecureDesktop(self): - if _isSecureDesktop(): + if isRunningOnSecureDesktop(): return self._handleSecureDesktop(False) @@ -209,14 +209,14 @@ def _unregisterRdPipeFromRegistry(cls): def terminate(self): try: - if not _isSecureDesktop(): + if not isRunningOnSecureDesktop(): settingsPanel.NvdaRDSettingsPanel.post_onSave.unregister(self._handlePostConfigProfileSwitch) gui.settingsDialogs.NVDASettingsDialog.categoryClasses.remove(settingsPanel.NvdaRDSettingsPanel) config.post_configProfileSwitch.unregister(self._handlePostConfigProfileSwitch) configuredOperatingMode = configuration.getOperatingMode() if ( configuredOperatingMode & configuration.OperatingMode.SERVER - or (configuredOperatingMode & configuration.OperatingMode.SECURE_DESKTOP and _isSecureDesktop()) + or (configuredOperatingMode & configuration.OperatingMode.SECURE_DESKTOP and isRunningOnSecureDesktop()) ): self.terminateOperatingModeServer() if configuredOperatingMode & configuration.OperatingMode.SECURE_DESKTOP: @@ -240,10 +240,10 @@ def _handlePostConfigProfileSwitch(self): # NOQA: C901 newServer = newOperatingMode & configuration.OperatingMode.SERVER oldSecureDesktop = oldOperatingMode & configuration.OperatingMode.SECURE_DESKTOP newSecureDesktop = newOperatingMode & configuration.OperatingMode.SECURE_DESKTOP - oldSecureDesktopOrServer = (oldSecureDesktop and _isSecureDesktop()) or oldServer - newSecureDesktopOrServer = (newSecureDesktop and _isSecureDesktop()) or newServer - oldSecureDesktopOrClient = (oldSecureDesktop and not _isSecureDesktop()) or oldClient - newSecureDesktopOrClient = (newSecureDesktop and not _isSecureDesktop()) or newClient + oldSecureDesktopOrServer = (oldSecureDesktop and isRunningOnSecureDesktop()) or oldServer + newSecureDesktopOrServer = (newSecureDesktop and isRunningOnSecureDesktop()) or newServer + oldSecureDesktopOrClient = (oldSecureDesktop and not isRunningOnSecureDesktop()) or oldClient + newSecureDesktopOrClient = (newSecureDesktop and not isRunningOnSecureDesktop()) or newClient if oldSecureDesktopOrServer and not newSecureDesktopOrServer: self.terminateOperatingModeServer() elif not oldSecureDesktopOrServer and newSecureDesktopOrServer: @@ -311,7 +311,7 @@ def _handleRemoteDisconnect(self, handler: handlers.RemoteHandler, error: int) - def event_gainFocus(self, obj, nextHandler): configuredOperatingMode = configuration.getOperatingMode() - if not _isSecureDesktop(): + if not isRunningOnSecureDesktop(): if configuredOperatingMode & configuration.OperatingMode.CLIENT: for handler in self._handlers.values(): try: diff --git a/addon/lib/detection.py b/addon/lib/detection.py index 9b899f8..6cb8c1b 100644 --- a/addon/lib/detection.py +++ b/addon/lib/detection.py @@ -8,7 +8,7 @@ ) from .namedPipe import PIPE_DIRECTORY, getSecureDesktopNamedPipes import os.path -from systemUtils import _isSecureDesktop +from utils.security import isRunningOnSecureDesktop KEY_VIRTUAL_CHANNEL = "WTSVirtualChannel" KEY_NAMED_PIPE_SERVER = "NamedPipeServer" @@ -23,7 +23,7 @@ def bgScanRD( operatingMode = configuration.getOperatingMode() if limitToDevices and RemoteDriver.name not in limitToDevices: return - if _isSecureDesktop() and operatingMode & configuration.OperatingMode.SECURE_DESKTOP: + if isRunningOnSecureDesktop() and operatingMode & configuration.OperatingMode.SECURE_DESKTOP: sdId = f"NVDA_SD-{driverType.name}" sdPort = os.path.join(PIPE_DIRECTORY, sdId) if sdPort in getSecureDesktopNamedPipes():