Skip to content

Commit

Permalink
Merge pull request #2109 from HullSeals/enhancement/555/winsparkle_to…
Browse files Browse the repository at this point in the history
…_inno

[555] Move Default Registry Creation
  • Loading branch information
C1701D authored Dec 14, 2023
2 parents bd6f546 + 8888d01 commit 9a297fb
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 38 deletions.
6 changes: 5 additions & 1 deletion build.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion config/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
36 changes: 2 additions & 34 deletions config/windows.py
Original file line number Diff line number Diff line change
Expand Up @@ -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'

Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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')
Expand All @@ -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:
Expand Down
3 changes: 1 addition & 2 deletions docs/Translations.md
Original file line number Diff line number Diff line change
Expand Up @@ -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!
/* <use of this phrase> [<file it was first added in>] */
"<text as it appears in the code>" = "<English version of the text>";
e.g.
Expand Down
7 changes: 7 additions & 0 deletions resources/EDMC_Installer_Config_template.txt
Original file line number Diff line number Diff line change
@@ -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/"
Expand Down Expand Up @@ -34,6 +35,7 @@ AlwaysShowDirOnReadyPage=yes
UninstallDisplayIcon={app}\{#MyAppExeName}
MinVersion=6.2
ChangesAssociations = yes
UsedUserAreasWarning = no

[Languages]
Name: "english"; MessagesFile: "compiler:Default.isl"
Expand Down Expand Up @@ -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}"

0 comments on commit 9a297fb

Please sign in to comment.