Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 42 additions & 8 deletions addon/globalPlugins/updateChannel.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,17 +25,26 @@
originalChannel = None
confspec = {
"channel": "integer(default=0)",
"configVersion": "integer(default=1)",
}
config.conf.spec["updateChannel"] = confspec

channels = ["default", "stable", "beta", None]
ALPHA_CHANNEL = "snapshot:alpha"
ALPHA_FALLBACK_VERSION = "alpha-0,00000000"
CONFIG_VERSION = 2
LEGACY_DISABLE_UPDATES_CHANNEL_INDEX = 3
DISABLE_UPDATES_CHANNEL_INDEX = 4

channels = ["default", "stable", "beta", ALPHA_CHANNEL, None]
channelDescriptions = [
# TRANSLATORS: default channel option in the combo box
_("Default"),
# TRANSLATORS: stable releases option in the combo box
_("Stable"),
# TRANSLATORS: release candidate and beta releases option in the combo box
_("Rc and beta"),
# TRANSLATORS: alpha snapshots option in the combo box
_("Alpha (snapshots)"),
# TRANSLATORS: disable updates option in the combo box
_("Disable updates (not recommended)"),
]
Expand All @@ -53,10 +62,25 @@ def getVersionStringFromBuildValues():
def getConfiguredChannel():
try:
# Use normal profile only if possible
return int(config.conf.profiles[0]["updateChannel"]["channel"])
updateChannelConfig = config.conf.profiles[0]["updateChannel"]
except Exception:
# When using for the first time, read from general configuration
return config.conf["updateChannel"]["channel"]
updateChannelConfig = config.conf["updateChannel"]
configuredChannel = int(updateChannelConfig["channel"])
try:
configVersion = int(updateChannelConfig["configVersion"])
except Exception:
configVersion = 1
if configVersion < CONFIG_VERSION:
if configuredChannel == LEGACY_DISABLE_UPDATES_CHANNEL_INDEX:
configuredChannel = DISABLE_UPDATES_CHANNEL_INDEX
updateChannelConfig["channel"] = configuredChannel
updateChannelConfig["configVersion"] = CONFIG_VERSION
return configuredChannel


def shouldUseAlphaFallbackVersion():
return buildVersion.updateVersionType == ALPHA_CHANNEL and not buildVersion.version.startswith("alpha-")


def checkForUpdateReplacement(auto=False):
Expand All @@ -67,14 +91,20 @@ def checkForUpdateReplacement(auto=False):
# We cannot do this when initializing the plugin
# as this breaks the process of creating portable copies (see issue #5).
ORIG_NVDA_VERSION = buildVersion.version
IS_ALPHA = originalChannel == "snapshot:alpha"
IS_ALPHA = originalChannel == ALPHA_CHANNEL
shouldReplaceVersion = False
replacementVersion = None
if IS_ALPHA and buildVersion.updateVersionType != originalChannel:
shouldReplaceVersion = True
if not shouldReplaceVersion and IS_ALPHA and getConfiguredChannel() in {1, 2}:
shouldReplaceVersion = True
if shouldUseAlphaFallbackVersion():
shouldReplaceVersion = True
replacementVersion = ALPHA_FALLBACK_VERSION
elif shouldReplaceVersion:
replacementVersion = getVersionStringFromBuildValues()
if shouldReplaceVersion:
buildVersion.version = getVersionStringFromBuildValues()
buildVersion.version = replacementVersion
importlib.reload(versionInfo)
try:
return updateCheck.checkForUpdate_orig(auto)
Expand Down Expand Up @@ -171,7 +201,7 @@ def getAvailableUpdates(self, currentChannel): # noqa C901
importlib.reload(versionInfo)
elif self.status == 2:
# Workaround for issue 3
if originalChannel == "snapshot:alpha" and originalChannel == currentChannel:
if originalChannel == ALPHA_CHANNEL and originalChannel == currentChannel:
buildVersion.updateVersionType = currentChannel
importlib.reload(versionInfo)

Expand Down Expand Up @@ -255,9 +285,13 @@ def onSave(self):
try:
# Use normal profile only if possible
config.conf.profiles[0]["updateChannel"]["channel"] = self.channels.Selection
config.conf.profiles[0]["updateChannel"]["configVersion"] = CONFIG_VERSION
except Exception:
# When configuring for the first time, required keys are created in the normal profile
config.conf.profiles[0]["updateChannel"] = {"channel": self.channels.Selection}
config.conf.profiles[0]["updateChannel"] = {
"channel": self.channels.Selection,
"configVersion": CONFIG_VERSION,
}
if self.channels.Selection == 0:
buildVersion.updateVersionType = originalChannel
else:
Expand Down Expand Up @@ -301,7 +335,7 @@ def __init__(self):
global originalChannel
originalChannel = buildVersion.updateVersionType
index = getConfiguredChannel()
if index > len(channels):
if index >= len(channels):
index = 0
if index > 0:
buildVersion.updateVersionType = channels[index]
Expand Down
2 changes: 1 addition & 1 deletion buildVars.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
addon_version = "26.3",
# Brief changelog for this version
# Translators: what's new content for the add-on version to be shown in the add-on store
addon_changelog=_("""Bug fixes"""),
addon_changelog=_("""Restored the alpha snapshots update channel."""),
# Author(s)
addon_author = "Jose Manuel Delicado <jm.delicado@nvda.es>, Javi Dominguez <fjavids@gmail.com>",
# URL for the add-on documentation support
Expand Down
5 changes: 5 additions & 0 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ You can change the NVDA update channel by going to NVDA menu, Preferences, Setti
* Default: this is the default channel used by your NVDA version. Choosing this option means the same as disabling the add-on.
* Stable: force update channel to stable. Useful when you want to upgrade to a newer stable version from a beta.
* Rc and beta: this is the channel for beta releases. You will receive the first beta version once it is released. This channel allows you to update through betas and release candidates.
* Alpha (snapshots): choose this option to update to the latest alpha snapshot. Alpha snapshots allow you to test new features, but they are unstable.
* Disable updates (not recommended): this option disables the update channel. If you check for updates an error message will be displayed. Remember that you can disable automatic updates from the General settings category. Use this option only with testing purposes.

Information about available updates for each channel will be retrieved in the background once the settings panel is opened. Press tab to navigate to a read only edit field, where you can see this information. This information will be dynamically updated when you change the update channel from the combo box. If there is an update available for the selected channel, one or two links will appear next to the edit field:
Expand All @@ -20,6 +21,10 @@ Information about available updates for each channel will be retrieved in the ba

## Changelog

### Version 26.3

* Restored the alpha snapshots update channel.

### Version 26.1

* Updated documentation clarifying important add-on changes.
Expand Down