|
22 | 22 | import COMRegistrationFixes |
23 | 23 | import winKernel |
24 | 24 | from typing import ( |
| 25 | + Any, |
25 | 26 | Dict, |
26 | 27 | Union, |
27 | 28 | ) |
| 29 | +import NVDAState |
28 | 30 | from NVDAState import WritePaths |
29 | 31 |
|
| 32 | + |
| 33 | +def __getattr__(attrName: str) -> Any: |
| 34 | + """Module level `__getattr__` used to preserve backward compatibility.""" |
| 35 | + if attrName == "CONFIG_IN_LOCAL_APPDATA_SUBKEY" and NVDAState._allowDeprecatedAPI(): |
| 36 | + # Note: this should only log in situations where it will not be excessively noisy. |
| 37 | + log.warning( |
| 38 | + "Importing CONFIG_IN_LOCAL_APPDATA_SUBKEY from here is deprecated. " |
| 39 | + "Instead use config.RegistryKey.CONFIG_IN_LOCAL_APPDATA_SUBKEY. ", |
| 40 | + stack_info=True, |
| 41 | + ) |
| 42 | + return config.RegistryKey.CONFIG_IN_LOCAL_APPDATA_SUBKEY.value |
| 43 | + raise AttributeError(f"module {repr(__name__)} has no attribute {repr(attrName)}") |
| 44 | + |
| 45 | + |
30 | 46 | _wsh=None |
31 | 47 | def _getWSH(): |
32 | 48 | global _wsh |
@@ -298,7 +314,21 @@ def registerInstallation( |
298 | 314 | with winreg.CreateKeyEx(winreg.HKEY_LOCAL_MACHINE, config.RegistryKey.NVDA.value, 0, winreg.KEY_WRITE) as k: |
299 | 315 | winreg.SetValueEx(k,"startMenuFolder",None,winreg.REG_SZ,startMenuFolder) |
300 | 316 | if configInLocalAppData: |
301 | | - winreg.SetValueEx(k,config.CONFIG_IN_LOCAL_APPDATA_SUBKEY,None,winreg.REG_DWORD,int(configInLocalAppData)) |
| 317 | + winreg.SetValueEx( |
| 318 | + k, |
| 319 | + config.RegistryKey.CONFIG_IN_LOCAL_APPDATA_SUBKEY.value, |
| 320 | + None, |
| 321 | + winreg.REG_DWORD, |
| 322 | + int(configInLocalAppData) |
| 323 | + ) |
| 324 | + if NVDAState._forceSecureModeEnabled(): |
| 325 | + winreg.SetValueEx( |
| 326 | + k, |
| 327 | + config.RegistryKey.FORCE_SECURE_MODE_SUBKEY.value, |
| 328 | + None, |
| 329 | + winreg.REG_DWORD, |
| 330 | + 1 |
| 331 | + ) |
302 | 332 | registerEaseOfAccess(installDir) |
303 | 333 | if startOnLogonScreen is not None: |
304 | 334 | config._setStartOnLogonScreen(startOnLogonScreen) |
@@ -605,13 +635,9 @@ def tryCopyFile(sourceFilePath,destFilePath): |
605 | 635 | errorCode = ctypes.GetLastError() |
606 | 636 | raise OSError("Unable to copy file %s to %s, error %d"%(sourceFilePath,destFilePath,errorCode)) |
607 | 637 |
|
608 | | -def install(shouldCreateDesktopShortcut=True,shouldRunAtLogon=True): |
| 638 | + |
| 639 | +def install(shouldCreateDesktopShortcut: bool = True, shouldRunAtLogon: bool = True): |
609 | 640 | prevInstallPath=getInstallPath(noDefault=True) |
610 | | - try: |
611 | | - k = winreg.OpenKey(winreg.HKEY_LOCAL_MACHINE, config.RegistryKey.NVDA.value) |
612 | | - configInLocalAppData = bool(winreg.QueryValueEx(k, config.CONFIG_IN_LOCAL_APPDATA_SUBKEY)[0]) |
613 | | - except WindowsError: |
614 | | - configInLocalAppData = False |
615 | 641 | unregisterInstallation(keepDesktopShortcut=shouldCreateDesktopShortcut) |
616 | 642 | installDir=defaultInstallPath |
617 | 643 | startMenuFolder=defaultStartMenuFolder |
@@ -642,7 +668,7 @@ def install(shouldCreateDesktopShortcut=True,shouldRunAtLogon=True): |
642 | 668 | startMenuFolder, |
643 | 669 | shouldCreateDesktopShortcut, |
644 | 670 | shouldRunAtLogon, |
645 | | - configInLocalAppData |
| 671 | + NVDAState._configInLocalAppDataEnabled() |
646 | 672 | ) |
647 | 673 | COMRegistrationFixes.fixCOMRegistrations() |
648 | 674 |
|
|
0 commit comments