Skip to content

Commit ab079bd

Browse files
authored
Merge 337e5c0 into f6977fe
2 parents f6977fe + 337e5c0 commit ab079bd

5 files changed

Lines changed: 38 additions & 28 deletions

File tree

source/brailleViewer/brailleViewerGui.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
import fonts
1818
import inputCore
1919
import gui.contextHelp
20-
from utils.security import _isLockScreenModeActive, postSessionLockStateChanged
20+
from utils.security import _isLockScreenModeActive, post_sessionLockStateChanged
2121

2222
BRAILLE_UNICODE_PATTERNS_START = 0x2800
2323
BRAILLE_SPACE_CHARACTER = chr(BRAILLE_UNICODE_PATTERNS_START)
@@ -287,7 +287,7 @@ def __init__(self, numCells: int, onDestroyed: Callable[[], None]):
287287
pos=dialogPos,
288288
style=wx.CAPTION | wx.CLOSE_BOX | wx.STAY_ON_TOP
289289
)
290-
postSessionLockStateChanged.register(self.onSessionLockStateChange)
290+
post_sessionLockStateChanged.register(self.onSessionLockStateChange)
291291
self.Bind(wx.EVT_CLOSE, self._onClose)
292292
self.Bind(wx.EVT_WINDOW_DESTROY, self._onDestroy)
293293

@@ -557,7 +557,7 @@ def _onClose(self, evt):
557557

558558
def _onDestroy(self, evt: wx.Event):
559559
log.debug("braille viewer gui onDestroy")
560-
postSessionLockStateChanged.unregister(self.onSessionLockStateChange)
560+
post_sessionLockStateChanged.unregister(self.onSessionLockStateChange)
561561
self.isDestroyed = True
562562
self._notifyOfDestroyed()
563563
evt.Skip()

source/speechViewer.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
from logHandler import log
1414
from speech import SpeechSequence
1515
import gui.contextHelp
16-
from utils.security import _isLockScreenModeActive, postSessionLockStateChanged
16+
from utils.security import _isLockScreenModeActive, post_sessionLockStateChanged
1717

1818

1919
# Inherit from wx.Frame because these windows show in the alt+tab menu (where miniFrame does not)
@@ -45,7 +45,7 @@ def __init__(self, onDestroyCallBack: Callable[[], None]):
4545
pos=dialogPos,
4646
style=wx.CAPTION | wx.CLOSE_BOX | wx.RESIZE_BORDER | wx.STAY_ON_TOP
4747
)
48-
postSessionLockStateChanged.register(self.onSessionLockStateChange)
48+
post_sessionLockStateChanged.register(self.onSessionLockStateChange)
4949
self._isDestroyed = False
5050
self.onDestroyCallBack = onDestroyCallBack
5151
self.Bind(wx.EVT_CLOSE, self.onClose)
@@ -126,7 +126,7 @@ def onShouldShowOnStartupChanged(self, evt: wx.CommandEvent):
126126

127127
def onDestroy(self, evt: wx.Event):
128128
self._isDestroyed = True
129-
postSessionLockStateChanged.unregister(self.onSessionLockStateChange)
129+
post_sessionLockStateChanged.unregister(self.onSessionLockStateChange)
130130
log.debug("SpeechViewer destroyed")
131131
self.onDestroyCallBack()
132132
evt.Skip()

source/utils/security.py

Lines changed: 22 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,25 @@
2222
import NVDAObjects # noqa: F401, use for typing
2323

2424

25-
postSessionLockStateChanged = extensionPoints.Action()
25+
def __getattr__(attrName: str) -> Any:
26+
"""Module level `__getattr__` used to preserve backward compatibility.
27+
"""
28+
import NVDAState
29+
if not NVDAState._allowDeprecatedAPI():
30+
log.debug(f"Deprecated {attrName} imported while _allowDeprecatedAPI is False")
31+
elif attrName == "isObjectAboveLockScreen":
32+
log.warning(
33+
"Importing isObjectAboveLockScreen(obj) is deprecated. "
34+
"Instead use obj.isBelowLockScreen. "
35+
)
36+
return _isObjectAboveLockScreen
37+
elif attrName == "postSessionLockStateChanged":
38+
log.warning("postSessionLockStateChanged is deprecated, use post_sessionLockStateChanged instead.")
39+
return post_sessionLockStateChanged
40+
raise AttributeError(f"module {repr(__name__)} has no attribute {repr(attrName)}")
41+
42+
43+
post_sessionLockStateChanged = extensionPoints.Action()
2644
"""
2745
Notifies when a session lock or unlock event occurs.
2846
@@ -34,9 +52,9 @@ def onSessionLockStateChange(isNowLocked: bool):
3452
'''
3553
pass
3654
37-
postSessionLockStateChanged.register(onSessionLockStateChange)
38-
postSessionLockStateChanged.notify(isNowLocked=False)
39-
postSessionLockStateChanged.unregister(onSessionLockStateChange)
55+
post_sessionLockStateChanged.register(onSessionLockStateChange)
56+
post_sessionLockStateChanged.notify(isNowLocked=False)
57+
post_sessionLockStateChanged.unregister(onSessionLockStateChange)
4058
```
4159
"""
4260

@@ -164,18 +182,6 @@ def objectBelowLockScreenAndWindowsIsLocked(
164182
return False
165183

166184

167-
def __getattr__(attrName: str) -> Any:
168-
import NVDAState
169-
"""Module level `__getattr__` used to preserve backward compatibility."""
170-
if attrName == "isObjectAboveLockScreen" and NVDAState._allowDeprecatedAPI():
171-
log.warning(
172-
"Importing isObjectAboveLockScreen(obj) is deprecated. "
173-
"Instead use obj.isBelowLockScreen. "
174-
)
175-
return _isObjectAboveLockScreen
176-
raise AttributeError(f"module {repr(__name__)} has no attribute {repr(attrName)}")
177-
178-
179185
def _isObjectAboveLockScreen(obj: "NVDAObjects.NVDAObject") -> bool:
180186
log.error(
181187
"This function is deprecated. "

source/winAPI/sessionTracking.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -124,13 +124,13 @@ def initialize():
124124
def pumpAll():
125125
"""Used to track the session lock state every core cycle, and detect changes."""
126126
global _wasLockedPreviousPumpAll
127-
from utils.security import postSessionLockStateChanged
127+
from utils.security import post_sessionLockStateChanged
128128
windowsIsNowLocked = _isWindowsLocked()
129129
# search for lock app module once lock state is known,
130-
# but before triggering callbacks via postSessionLockStateChanged
130+
# but before triggering callbacks via post_sessionLockStateChanged
131131
if windowsIsNowLocked != _wasLockedPreviousPumpAll:
132132
_wasLockedPreviousPumpAll = windowsIsNowLocked
133-
postSessionLockStateChanged.notify(isNowLocked=windowsIsNowLocked)
133+
post_sessionLockStateChanged.notify(isNowLocked=windowsIsNowLocked)
134134

135135

136136
def __getattr__(attrName: str) -> Any:
@@ -181,7 +181,7 @@ def _isWindowsLocked() -> bool:
181181
if not _TrackNVDAInitialization.isInitializationComplete():
182182
# Wait until initialization is complete,
183183
# so NVDA and other consumers can register the lock state
184-
# via postSessionLockStateChanged.
184+
# via post_sessionLockStateChanged.
185185
return False
186186
if _lockStateTracker is None:
187187
log.error(

user_docs/en/changes.t2t

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -100,8 +100,12 @@ Please open a GitHub issue if your Add-on has an issue with updating to the new
100100

101101
=== Deprecations ===
102102
- ``NVDAObjects.UIA.winConsoleUIA.WinTerminalUIA`` is deprecated and usage is discouraged. (#14047)
103-
- ``config.addConfigDirsToPythonPackagePath`` has been moved. Use ``addonHandler.packaging.addDirsToPythonPackagePath`` instead. (#14350)
104-
- ``braille.BrailleHandler.TETHER_*`` are deprecated. Please use ``configFlags.TetherTo.*.value`` instead. (#14233)
103+
- ``config.addConfigDirsToPythonPackagePath`` has been moved.
104+
Use ``addonHandler.packaging.addDirsToPythonPackagePath`` instead. (#14350)
105+
- ``braille.BrailleHandler.TETHER_*`` are deprecated.
106+
Please use ``configFlags.TetherTo.*.value`` instead. (#14233)
107+
- ``utils.security.postSessionLockStateChanged`` is deprecated.
108+
Please use ``utils.security.post_sessionLockStateChanged`` instead. (#14486)
105109
-
106110

107111

0 commit comments

Comments
 (0)