From 3b679c1556ed130b16ffcf790cb89110afc69ead Mon Sep 17 00:00:00 2001
From: David Sangrey <rixxan@hullseals.space>
Date: Sun, 6 Aug 2023 17:40:04 -0400
Subject: [PATCH 1/4] #2048 Validate RegKeys, Auth Flow

---
 companion.py                                 |  5 +++
 config/__init__.py                           |  2 +-
 resources/EDMC_Installer_Config_template.txt | 44 +++++++++++++-------
 3 files changed, 35 insertions(+), 16 deletions(-)

diff --git a/companion.py b/companion.py
index 510510d5..60322231 100644
--- a/companion.py
+++ b/companion.py
@@ -15,6 +15,7 @@ import json
 import numbers
 import os
 import random
+import sys
 import threading
 import time
 import tkinter as tk
@@ -743,6 +744,10 @@ class Session(object):
             self.state = Session.STATE_INIT  # Will try to authorize again on next login or query
             self.auth = None
             raise  # Bad thing happened
+        if getattr(sys, 'frozen', False):
+            tk.messagebox.showinfo(title="Authentication Successful",
+                                   message="Authentication with cAPI Successful.\n"
+                                           "You may now close the Frontier login tab if it is still open.")
 
     def close(self) -> None:
         """Close the `request.Session()."""
diff --git a/config/__init__.py b/config/__init__.py
index e9079c28..9d647db5 100644
--- a/config/__init__.py
+++ b/config/__init__.py
@@ -52,7 +52,7 @@ appcmdname = 'EDMC'
 # <https://semver.org/#semantic-versioning-specification-semver>
 # Major.Minor.Patch(-prerelease)(+buildmetadata)
 # NB: Do *not* import this, use the functions appversion() and appversion_nobuild()
-_static_appversion = '5.9.2'
+_static_appversion = '5.9.4-alpha1'
 _cached_version: Optional[semantic_version.Version] = None
 copyright = '© 2015-2019 Jonathan Harris, 2020-2023 EDCD'
 
diff --git a/resources/EDMC_Installer_Config_template.txt b/resources/EDMC_Installer_Config_template.txt
index 7810270b..3abdc23a 100644
--- a/resources/EDMC_Installer_Config_template.txt
+++ b/resources/EDMC_Installer_Config_template.txt
@@ -32,7 +32,7 @@ LicenseFile=LICENSE
 AlwaysShowDirOnReadyPage=yes
 UninstallDisplayIcon={app}\{#MyAppExeName}
 MinVersion=6.2
-
+ChangesAssociations = yes
 
 [Languages]
 Name: "english"; MessagesFile: "compiler:Default.isl"
@@ -53,28 +53,42 @@ Filename: "{app}\{#MyAppExeName}"; Description: "{cm:LaunchProgram,{#StringChang
 
 ;Check if a WiX-based installation exists. If so, kill it with fire.
 [Code]
+function IsWixInstalled: Boolean;
+var
+  Uninstall: String;
+begin
+  Result := RegQueryStringValue(HKLM, 'SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{5E9AD4D3-0365-41D5-9586-9368745DD109}', 'UninstallString', Uninstall);
+end;
+
 procedure CurStepChanged(CurStep: TSetupStep);
 var
   ResultCode: Integer;
   Uninstall: String;
 begin
-  if (CurStep = ssInstall) then begin
-    if RegQueryStringValue(HKLM, 'SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{5E9AD4D3-0365-41D5-9586-9368745DD109}', 'UninstallString', Uninstall) then begin
-      MsgBox('Warning: an old version of EDMC is installed! Please close EDMC while we remove the old version!', mbInformation, MB_OK);
-      Uninstall := '/x {5E9AD4D3-0365-41D5-9586-9368745DD109}';
-      Exec('MsiExec.exe', Uninstall, '', SW_SHOW, ewWaitUntilTerminated, ResultCode);
-    end;
+  if (CurStep = ssInstall) and IsWixInstalled then
+  begin
+    MsgBox('Warning: an old version of EDMC is installed! Please close EDMC while we remove the old version!', mbInformation, MB_OK);
+    Uninstall := '/x {5E9AD4D3-0365-41D5-9586-9368745DD109}';
+    Exec('MsiExec.exe', Uninstall, '', SW_SHOW, ewWaitUntilTerminated, ResultCode);
   end;
 end;
 
 
-[Registry]
-; Create the registry key for the custom file type
-Root: HKCR; Subkey: "edmc"; Flags: uninsdeletekey
-; Create the registry values for the custom file type
-Root: HKCR; Subkey: "edmc"; ValueType: string; ValueName: ""; ValueData: "{#MyAppName}"; Flags: uninsdeletevalue
-Root: HKCR; Subkey: "edmc\DefaultIcon"; ValueType: string; ValueName: ""; ValueData: "{app}\{#MyAppExeName},0"; Flags: uninsdeletevalue
-Root: HKCR; Subkey: "edmc\shell\open\command"; ValueType: string; ValueName: ""; ValueData: """{app}\{#MyAppExeName}"" ""%1"""; Flags: uninsdeletevalue
 
-; Register the URL protocol handler
+[Registry]
+; Create the main registry key under HKCR
+Root: HKCR; Subkey: "edmc"; Flags: uninsdeletevalue
+; Create a default value under the "edmc" key
+Root: HKCR; Subkey: "edmc"; ValueType: string; ValueName: ""; ValueData: "{#MyAppName}"; Flags: uninsdeletevalue
+; Create the "URL Protocol" value under the "edmc" key
 Root: HKCR; Subkey: "edmc"; ValueType: string; ValueName: "URL Protocol"; ValueData: ""; Flags: uninsdeletevalue
+; Create the "DefaultIcon" subkey under the "edmc" key
+Root: HKCR; Subkey: "edmc\DefaultIcon"; ValueType: string; ValueName: ""; ValueData: "{app}\EDMarketConnector.exe,0"; Flags: uninsdeletevalue
+; Create the "shell" subkey under the "edmc" key
+Root: HKCR; Subkey: "edmc\shell"; Flags: uninsdeletevalue
+; Create the "open" subkey under the "shell" subkey
+Root: HKCR; Subkey: "edmc\shell\open"; Flags: uninsdeletevalue
+; Create the "command" subkey under the "open" subkey
+Root: HKCR; Subkey: "edmc\shell\open\command"; ValueType: string; ValueName: ""; ValueData: """{app}\EDMarketConnector.exe"" ""%1"""; Flags: uninsdeletevalue
+; Create the "ddeexec" subkey under the "open" subkey
+Root: HKCR; Subkey: "edmc\shell\open\ddeexec"; ValueType: string; ValueName: ""; ValueData: "Open(""%1"")"; Flags: uninsdeletevalue

From 70bcbd9d561ae8ca4a519182c116e57a78e93b78 Mon Sep 17 00:00:00 2001
From: David Sangrey <rixxan@hullseals.space>
Date: Sun, 6 Aug 2023 19:00:46 -0400
Subject: [PATCH 2/4] #2048 Improve Cleanup

---
 resources/EDMC_Installer_Config_template.txt | 17 ++++++++---------
 1 file changed, 8 insertions(+), 9 deletions(-)

diff --git a/resources/EDMC_Installer_Config_template.txt b/resources/EDMC_Installer_Config_template.txt
index 3abdc23a..4de0a4f9 100644
--- a/resources/EDMC_Installer_Config_template.txt
+++ b/resources/EDMC_Installer_Config_template.txt
@@ -74,21 +74,20 @@ begin
 end;
 
 
-
 [Registry]
 ; Create the main registry key under HKCR
-Root: HKCR; Subkey: "edmc"; Flags: uninsdeletevalue
+Root: HKCR; Subkey: "edmc"; Flags: uninsdeletekey
 ; Create a default value under the "edmc" key
-Root: HKCR; Subkey: "edmc"; ValueType: string; ValueName: ""; ValueData: "{#MyAppName}"; Flags: uninsdeletevalue
+Root: HKCR; Subkey: "edmc"; ValueType: string; ValueName: ""; ValueData: "{#MyAppName}"; Flags: uninsdeletekey
 ; Create the "URL Protocol" value under the "edmc" key
-Root: HKCR; Subkey: "edmc"; ValueType: string; ValueName: "URL Protocol"; ValueData: ""; Flags: uninsdeletevalue
+Root: HKCR; Subkey: "edmc"; ValueType: string; ValueName: "URL Protocol"; ValueData: ""; Flags: uninsdeletekey
 ; Create the "DefaultIcon" subkey under the "edmc" key
-Root: HKCR; Subkey: "edmc\DefaultIcon"; ValueType: string; ValueName: ""; ValueData: "{app}\EDMarketConnector.exe,0"; Flags: uninsdeletevalue
+Root: HKCR; Subkey: "edmc\DefaultIcon"; ValueType: string; ValueName: ""; ValueData: "{app}\EDMarketConnector.exe,0"; Flags: uninsdeletekey
 ; Create the "shell" subkey under the "edmc" key
-Root: HKCR; Subkey: "edmc\shell"; Flags: uninsdeletevalue
+Root: HKCR; Subkey: "edmc\shell"; Flags: uninsdeletekey
 ; Create the "open" subkey under the "shell" subkey
-Root: HKCR; Subkey: "edmc\shell\open"; Flags: uninsdeletevalue
+Root: HKCR; Subkey: "edmc\shell\open"; Flags: uninsdeletekey
 ; Create the "command" subkey under the "open" subkey
-Root: HKCR; Subkey: "edmc\shell\open\command"; ValueType: string; ValueName: ""; ValueData: """{app}\EDMarketConnector.exe"" ""%1"""; Flags: uninsdeletevalue
+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: uninsdeletevalue
+Root: HKCR; Subkey: "edmc\shell\open\ddeexec"; ValueType: string; ValueName: ""; ValueData: "Open(""%1"")"; Flags: uninsdeletekey

From 77fd48c0334a1bce31cfbf7f8cd65d0f7d983847 Mon Sep 17 00:00:00 2001
From: David Sangrey <rixxan@hullseals.space>
Date: Tue, 8 Aug 2023 14:30:17 -0400
Subject: [PATCH 3/4] #2062 Update Shortcut Description to Old Version

---
 resources/EDMC_Installer_Config_template.txt | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/resources/EDMC_Installer_Config_template.txt b/resources/EDMC_Installer_Config_template.txt
index 4de0a4f9..4b8f053d 100644
--- a/resources/EDMC_Installer_Config_template.txt
+++ b/resources/EDMC_Installer_Config_template.txt
@@ -1,4 +1,5 @@
 #define MyAppName "EDMarketConnector"
+#define MyAppLongName "Elite Dangerous Market Connector"
 #define MyAppVersion "$appver"
 #define MyAppPublisher "EDCD"
 #define MyAppURL "https://edcd.github.io/"
@@ -45,8 +46,8 @@ Source: "dist.win32\{#MyAppExeName}"; DestDir: "{app}"; Flags: ignoreversion
 Source: "dist.win32\*"; DestDir: "{app}"; Flags: ignoreversion recursesubdirs createallsubdirs
 
 [Icons]
-Name: "{autoprograms}\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}"
-Name: "{autodesktop}\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}"; Tasks: desktopicon
+Name: "{autoprograms}\{#MyAppLongName}"; Filename: "{app}\{#MyAppExeName}"; Comment: "EDMC";
+Name: "{autodesktop}\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}"; Tasks: desktopicon;
 
 [Run]
 Filename: "{app}\{#MyAppExeName}"; Description: "{cm:LaunchProgram,{#StringChange(MyAppName, '&', '&&')}}"; Flags: nowait postinstall skipifsilent

From 6e8f8815df95b4e506854474da21788af300123f Mon Sep 17 00:00:00 2001
From: David Sangrey <rixxan@hullseals.space>
Date: Tue, 8 Aug 2023 14:59:19 -0400
Subject: [PATCH 4/4] Release/5.9.4 Update Changelog

---
 ChangeLog.md | 15 +++++++++++++++
 1 file changed, 15 insertions(+)

diff --git a/ChangeLog.md b/ChangeLog.md
index 50739ec4..f15c3608 100644
--- a/ChangeLog.md
+++ b/ChangeLog.md
@@ -33,6 +33,21 @@ produce the Windows executables and installer.
   currently used version in a given branch.
 
 ---
+Release 5.9.4
+===
+This release fixes a widely-reported bug that resulted in the cAPI Authentication
+flow being disrupted for a subset of users. Thank you to all the CMDRs who reported this to
+us and provided logs to us so that we could get the issue isolated.
+
+- Fixes a missing registry issue that could cause the EDMC:// protocol to fail.
+(#2061, #2059, #2058, #2057)
+- Renames the default start menu shortcut to be more clear. (#2062)
+
+Known Issues
+--
+- The popup on the EDMC Authentication Box is not translated yet. Ich spreche kein Deutsch.
+- The cAPI is giving an Error: 500 on the /shipyard endpoint on carriers. We think this is an FDEV issue.
+
 Release 5.9.3
 ===
 This release is identical to 5.9.3, except reverts a bad change.