diff --git a/build.py b/build.py index d6cecb7dd..6d7f865b4 100644 --- a/build.py +++ b/build.py @@ -19,12 +19,16 @@ copyright, git_shorthash_from_head, _static_appversion, + update_interval ) def iss_build(template_path: str, output_file: str) -> None: """Build the .iss file needed for building the installer EXE.""" - sub_vals = {"appver": _static_appversion} + sub_vals = { + "appver": _static_appversion, + "update_time": str(update_interval), + } with open(template_path, encoding="UTF8") as template_file: src = Template(template_file.read()) newfile = src.substitute(sub_vals) diff --git a/config/__init__.py b/config/__init__.py index c9a34c78a..66f973af1 100644 --- a/config/__init__.py +++ b/config/__init__.py @@ -60,7 +60,7 @@ copyright = '© 2015-2019 Jonathan Harris, 2020-2023 EDCD' update_feed = 'https://raw.githubusercontent.com/EDCD/EDMarketConnector/releases/edmarketconnector.xml' -update_interval = 8*60*60 +update_interval = 8*60*60 # 8 Hours # Providers marked to be in debug mode. Generally this is expected to switch to sending data to a log file debug_senders: list[str] = [] # TRACE logging code that should actually be used. Means not spamming it diff --git a/config/windows.py b/config/windows.py index 7fb53a372..75e3f6977 100644 --- a/config/windows.py +++ b/config/windows.py @@ -15,7 +15,7 @@ import winreg from ctypes.wintypes import DWORD, HANDLE from typing import Literal -from config import AbstractConfig, applongname, appname, logger, update_interval +from config import AbstractConfig, applongname, appname, logger assert sys.platform == 'win32' @@ -47,7 +47,7 @@ def known_folder_path(guid: uuid.UUID) -> str | None: class WinConfig(AbstractConfig): """Implementation of AbstractConfig for Windows.""" - def __init__(self, do_winsparkle=True) -> None: + def __init__(self) -> None: super().__init__() self.app_dir_path = pathlib.Path(known_folder_path(FOLDERID_LocalAppData)) / appname # type: ignore self.app_dir_path.mkdir(exist_ok=True) @@ -77,8 +77,6 @@ def __init__(self, do_winsparkle=True) -> None: try: self.__reg_handle: winreg.HKEYType = create_key_defaults(sub_key=REGISTRY_SUBKEY) - if do_winsparkle: - self.__setup_winsparkle() except OSError: logger.exception('Could not create required registry keys') @@ -89,36 +87,6 @@ def __init__(self, do_winsparkle=True) -> None: docs = known_folder_path(FOLDERID_Documents) self.set("outdir", docs if docs is not None else self.home) - def __setup_winsparkle(self): - """Ensure the necessary Registry keys for WinSparkle are present.""" - create_key_defaults = functools.partial( - winreg.CreateKeyEx, - key=winreg.HKEY_CURRENT_USER, - access=winreg.KEY_ALL_ACCESS | winreg.KEY_WOW64_64KEY, - ) - - try: - with create_key_defaults(sub_key=r'Software\EDCD\EDMarketConnector') as edcd_handle: - with winreg.CreateKeyEx(edcd_handle, sub_key='WinSparkle', - access=winreg.KEY_ALL_ACCESS | winreg.KEY_WOW64_64KEY) as winsparkle_reg: - # Set WinSparkle defaults - https://github.com/vslavik/winsparkle/wiki/Registry-Settings - UPDATE_INTERVAL_NAME = 'UpdateInterval' # noqa: N806 - CHECK_FOR_UPDATES_NAME = 'CheckForUpdates' # noqa: N806 - REG_SZ = winreg.REG_SZ # noqa: N806 - - winreg.SetValueEx(winsparkle_reg, UPDATE_INTERVAL_NAME, REG_RESERVED_ALWAYS_ZERO, REG_SZ, - str(update_interval)) - - try: - winreg.QueryValueEx(winsparkle_reg, CHECK_FOR_UPDATES_NAME) - except FileNotFoundError: - # Key doesn't exist, set it to a default - winreg.SetValueEx(winsparkle_reg, CHECK_FOR_UPDATES_NAME, REG_RESERVED_ALWAYS_ZERO, REG_SZ, - '1') - except OSError: - logger.exception('Could not open WinSparkle handle') - raise - def __get_regentry(self, key: str) -> None | list | str | int: """Access the Registry for the raw entry.""" try: diff --git a/docs/Translations.md b/docs/Translations.md index a1be7c288..959897f2e 100644 --- a/docs/Translations.md +++ b/docs/Translations.md @@ -34,8 +34,7 @@ _('stuff') #### Edit `L10n/en.template` to add the phrase -##### Hint: It is strongly recommended to use the find_localized_strings.py script to help automate this process! - +##### Hint: It is strongly recommended to use the `find_localized_strings.py` script to help automate this process! /* [] */ "" = ""; e.g. diff --git a/resources/EDMC_Installer_Config_template.txt b/resources/EDMC_Installer_Config_template.txt index 254c95ca3..b72ed5072 100644 --- a/resources/EDMC_Installer_Config_template.txt +++ b/resources/EDMC_Installer_Config_template.txt @@ -1,6 +1,7 @@ #define MyAppName "EDMarketConnector" #define MyAppLongName "Elite Dangerous Market Connector" #define MyAppVersion "$appver" +#define MyAppUpdateTime "$update_time" #define MyAppPublisher "EDCD" #define MyAppURL "https://edcd.github.io/" #define SuppURL "https://github.com/EDCD/EDMarketConnector/" @@ -34,6 +35,7 @@ AlwaysShowDirOnReadyPage=yes UninstallDisplayIcon={app}\{#MyAppExeName} MinVersion=6.2 ChangesAssociations = yes +UsedUserAreasWarning = no [Languages] Name: "english"; MessagesFile: "compiler:Default.isl" @@ -113,6 +115,11 @@ Root: HKCR; Subkey: "edmc\shell\open"; Flags: uninsdeletekey Root: HKCR; Subkey: "edmc\shell\open\command"; ValueType: string; ValueName: ""; ValueData: """{app}\EDMarketConnector.exe"" ""%1"""; Flags: uninsdeletekey ; Create the "ddeexec" subkey under the "open" subkey Root: HKCR; Subkey: "edmc\shell\open\ddeexec"; ValueType: string; ValueName: ""; ValueData: "Open(""%1"")"; Flags: uninsdeletekey +; Create WinSparkle related keys for update values +Root: HKCU; Subkey: "Software\EDCD\EDMarketConnector"; Flags: uninsdeletekey +Root: HKCU; Subkey: "Software\EDCD\EDMarketConnector\WinSparkle"; Flags: uninsdeletekey +Root: HKCU; Subkey: "Software\EDCD\EDMarketConnector\WinSparkle"; ValueType: string; ValueName: "UpdateInterval"; ValueData: "{#MyAppUpdateTime}"; Flags: createvalueifdoesntexist +Root: HKCU; Subkey: "Software\EDCD\EDMarketConnector\WinSparkle"; ValueType: string; ValueName: "CheckForUpdates"; ValueData: "1"; Flags: createvalueifdoesntexist [InstallDelete] Type: filesandordirs; Name: "{app}"