windows installer: Create file associations for Windows.
authorKeith Packard <keithp@keithp.com>
Wed, 18 Jun 2014 09:16:51 +0000 (02:16 -0700)
committerKeith Packard <keithp@keithp.com>
Wed, 18 Jun 2014 21:18:42 +0000 (14:18 -0700)
This makes icons appear for the files in the file manager, and lets
you double-click on the files to open the appropriate application.

Signed-off-by: Keith Packard <keithp@keithp.com>
altosui/Makefile.am
altosui/altos-windows.nsi.in
micropeak/Makefile.am
micropeak/micropeak-windows.nsi.in
telegps/Makefile.am
telegps/telegps-windows.nsi.in

index 98a5e193ba900c69d7ae9329efd2535d39567ed4..45f4467a055eee68537f626801bd816716673eda 100644 (file)
@@ -90,7 +90,7 @@ ICONJAR= -C $(ICONDIR) altus-metrum-16.png \
        -C $(ICONDIR) altus-metrum-128.png \
        -C $(ICONDIR) altus-metrum-256.png
 
        -C $(ICONDIR) altus-metrum-128.png \
        -C $(ICONDIR) altus-metrum-256.png
 
-WINDOWS_ICON=$(ICONDIR)/altus-metrum.ico
+WINDOWS_ICON=$(ICONDIR)/altus-metrum.ico $(ICONDIR)/altus-metrum.exe
 MACOSX_ICON=$(ICONDIR)/AltosUIIcon.icns
 
 # Firmware
 MACOSX_ICON=$(ICONDIR)/AltosUIIcon.icns
 
 # Firmware
index ab5ac4530ecf8ee9493f904d53ac317998e9d287..da36ad90bc7c683fb05b5e16e03ccbee7245a00c 100644 (file)
@@ -2,16 +2,22 @@
 !addincludedir Instdrv/NSIS/Includes
 !include x64.nsh
 !include java.nsh
 !addincludedir Instdrv/NSIS/Includes
 !include x64.nsh
 !include java.nsh
+!include refresh-sh.nsh
 
 
-!define PRODUCT_NAME "Altus Metrum Windows Software"
+!define REG_NAME "Altus Metrum"
+!define PROG_ID             "org.altusmetrum.altosui.1"
+!define PROG_ALTOSUI "org.altusmetrum.altosui.1"
+!define FAT_NAME "altosui-fat.jar"
+!define ICO_ICO "altus-metrum.ico"
+!define ICO_EXE "altus-metrum.exe"
 
 
-Name "Altus Metrum Installer"
+Name "${REG_NAME} Installer"
 
 ; Default install directory
 InstallDir "$PROGRAMFILES\AltusMetrum"
 
 ; Tell the installer where to re-install a new version
 
 ; Default install directory
 InstallDir "$PROGRAMFILES\AltusMetrum"
 
 ; Tell the installer where to re-install a new version
-InstallDirRegKey HKLM "Software\AltusMetrum" "Install_Dir"
+InstallDirRegKey HKLM "Software\${REG_NAME}" "Install_Dir"
 
 LicenseText "GNU General Public License Version 2"
 LicenseData "../COPYING"
 
 LicenseText "GNU General Public License Version 2"
 LicenseData "../COPYING"
@@ -21,7 +27,7 @@ RequestExecutionLevel admin
 
 ShowInstDetails Show
 
 
 ShowInstDetails Show
 
-ComponentText "Altus Metrum Software and Driver Installer"
+ComponentText "${REG_NAME} Software and Driver Installer"
 
 Function .onInit
        DetailPrint "Checking host operating system"
 
 Function .onInit
        DetailPrint "Checking host operating system"
@@ -33,6 +39,16 @@ Function .onInit
        ${EndIf}
 FunctionEnd
 
        ${EndIf}
 FunctionEnd
 
+Function un.onInit
+       DetailPrint "Checking host operating system"
+       ${If} ${RunningX64}
+               DetailPrint "Installer running on 64-bit host"
+               SetRegView 64
+               StrCpy $INSTDIR "$PROGRAMFILES64\AltusMetrum"
+               ${DisableX64FSRedirection}
+       ${EndIf}
+FunctionEnd
+
 ; Pages to present
 
 Page license
 ; Pages to present
 
 Page license
@@ -68,12 +84,12 @@ done:
 
 SectionEnd
 
 
 SectionEnd
 
-Section "AltosUI Application"
+Section "${REG_NAME} Application"
        Call DetectJRE
 
        SetOutPath $INSTDIR
 
        Call DetectJRE
 
        SetOutPath $INSTDIR
 
-       File "altosui-fat.jar"
+       File "${FAT_NAME}"
        File "altoslib_@ALTOSLIB_VERSION@.jar"
        File "altosuilib_@ALTOSUILIB_VERSION@.jar"
        File "cmudict04.jar"
        File "altoslib_@ALTOSLIB_VERSION@.jar"
        File "altosuilib_@ALTOSUILIB_VERSION@.jar"
        File "cmudict04.jar"
@@ -88,13 +104,13 @@ Section "AltosUI Application"
 
        File "*.dll"
 
 
        File "*.dll"
 
-       File "../icon/*.ico"
+       File "../icon/${ICO_ICO}"
 
 
-       CreateShortCut "$SMPROGRAMS\AltusMetrum.lnk" "$SYSDIR\javaw.exe" "-jar altosui-fat.jar" "$INSTDIR\altus-metrum.ico"
+       CreateShortCut "$SMPROGRAMS\${REG_NAME}.lnk" "$SYSDIR\javaw.exe" "-jar ${FAT_NAME}" "$INSTDIR\${ICO_ICO}"
 SectionEnd
 
 SectionEnd
 
-Section "AltosUI Desktop Shortcut"
-       CreateShortCut "$DESKTOP\AltusMetrum.lnk" "$INSTDIR\altosui-fat.jar"  "" "$INSTDIR\altus-metrum.ico"
+Section "${REG_NAME} Desktop Shortcut"
+       CreateShortCut "$DESKTOP\${REG_NAME}.lnk" "$INSTDIR\${FAT_NAME}"  "" "$INSTDIR\${ICO_ICO}"
 SectionEnd
 
 Section "TeleMetrum, TeleDongle and TeleBT Firmware"
 SectionEnd
 
 Section "TeleMetrum, TeleDongle and TeleBT Firmware"
@@ -126,38 +142,88 @@ Section "Documentation"
        File "../doc/telemini.pdf"
 SectionEnd
 
        File "../doc/telemini.pdf"
 SectionEnd
 
+Section "File Associations"
+
+       SetOutPath $INSTDIR
+
+       File "../icon/${ICO_EXE}"
+
+       ; application elements
+       
+       WriteRegStr HKCR "${PROG_ID}"                   ""                              "Altus Metrum Data File"
+       WriteRegStr HKCR "${PROG_ID}"                   "FriendlyTypeName"              "Altus Metrum Data File"
+       WriteRegStr HKCR "${PROG_ID}\CurVer"            ""                              "${PROG_ID}"
+       WriteRegStr HKCR "${PROG_ID}\DefaultIcon"       ""                              '"$INSTDIR\${ICO_EXE}",-101'
+  WriteRegExpandStr HKCR "${PROG_ID}\shell\play\command" ""                            '"%SYSTEMROOT%\System32\javaw.exe" -Djava.library.path="$INSTDIR" -jar "$INSTDIR\${FAT_NAME}" "%1"'
+
+       ; .eeprom elements
+
+       WriteRegStr HKCR ".eeprom"                      ""                              "${PROG_ALTOSUI}"
+       WriteRegStr HKCR ".eeprom"                      "PerceivedType"                 "Altus Metrum Log File"
+       WriteRegStr HKCR ".eeprom"                      "Content Type"                  "application/altosui"
+
+       WriteRegStr HKCR ".eeprom\OpenWithProgids"      "${PROG_ID}"                    ""
+       WriteRegStr HKCR ".eeprom\${PROG_ID}"           ""                              "${REG_NAME}"
+       
+       ; .telem elements
+       
+       WriteRegStr HKCR ".telem"                       ""                              "${PROG_ALTOSUI}"
+       WriteRegStr HKCR ".telem"                       "PerceivedType"                 "Altus Metrum Telemetry File"
+       WriteRegStr HKCR ".telem"                       "Content Type"                  "application/altosui"
+
+       WriteRegStr HKCR ".telem\OpenWithProgids"       "${PROG_ID}"                    ""
+       WriteRegStr HKCR ".telem\${PROG_ID}"            ""                              "${REG_NAME}"
+
+       Call RefreshShellIcons
+SectionEnd
+       
 Section "Uninstaller"
 
        ; Deal with the uninstaller
 
 Section "Uninstaller"
 
        ; Deal with the uninstaller
 
+       ${DisableX64FSRedirection}
        SetOutPath $INSTDIR
 
        ; Write the install path to the registry
        SetOutPath $INSTDIR
 
        ; Write the install path to the registry
-       WriteRegStr HKLM SOFTWARE\AltusMetrum "Install_Dir" "$INSTDIR"
+       WriteRegStr HKLM "SOFTWARE\${REG_NAME}" "Install_Dir" "$INSTDIR"
 
        ; Write the uninstall keys for windows
 
        ; Write the uninstall keys for windows
-       WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\AltusMetrum" "DisplayName" "Altus Metrum"
-       WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\AltusMetrum" "UninstallString" '"$INSTDIR\uninstall.exe"'
-       WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\AltusMetrum" "NoModify" "1"
-       WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\AltusMetrum" "NoRepair" "1"
+       WriteRegStr HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\${REG_NAME}" "DisplayName" "${REG_NAME}"
+       WriteRegStr HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\${REG_NAME}" "UninstallString" '"$INSTDIR\uninstall-${REG_NAME}.exe"'
+       WriteRegStr HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\${REG_NAME}" "NoModify" "1"
+       WriteRegStr HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\${REG_NAME}" "NoRepair" "1"
 
 
-       WriteUninstaller "uninstall.exe"
+       WriteUninstaller "uninstall-${REG_NAME}.exe"
 SectionEnd
 
 Section "Uninstall"
 SectionEnd
 
 Section "Uninstall"
-       DeleteRegKey HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\AltusMetrum"
-       DeleteRegKey HKLM "Software\AltusMetrum"
 
 
-       Delete "$INSTDIR\*.*"
-       RMDir "$INSTDIR"
+       ${DisableX64FSRedirection}
 
 
-       ; Remove devices
-       InstDrv::InitDriverSetup /NOUNLOAD {4D36E96D-E325-11CE-BFC1-08002BE10318} AltusMetrumSerial
-       InstDrv::DeleteOemInfFiles /NOUNLOAD
-       InstDrv::RemoveAllDevices
+       DeleteRegKey   HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\${REG_NAME}"
+       DeleteRegKey   HKLM "SOFTWARE\${REG_NAME}"
+
+       DetailPrint "Delete uninstall reg entries"
+
+       DeleteRegKey   HKCR "${PROG_ID}"
+
+       DeleteRegKey   HKCR ".eeprom\${PROG_ID}"
+       DeleteRegValue HKCR ".eeprom\OpenWithProgids" "${PROG_ID}"
+
+       DeleteRegKey   HKCR ".telem\${PROG_ID}"
+       DeleteRegValue HKCR ".telem\OpenWithProgids" "${PROG_ID}"
+
+       DetailPrint "Delete file association reg entries"
+
+       Delete "$INSTDIR\${FAT_NAME}"
+       Delete "$INSTDIR\uninstall-${REG_NAME}.exe"
+
+       Delete "$INSTDIR\${ICO_ICO}"
+       Delete "$INSTDIR\${ICO_EXE}"
 
        ; Remove shortcuts, if any
 
        ; Remove shortcuts, if any
-       Delete "$SMPROGRAMS\AltusMetrum.lnk"
-       Delete "$DESKTOP\AltusMetrum.lnk"
+       Delete "$SMPROGRAMS\${REG_NAME}.lnk"
+       Delete "$DESKTOP\${REG_NAME}.lnk"
        
        
+       Call un.RefreshShellIcons
 SectionEnd
 SectionEnd
index 39ebc43a069df837a49ddf841c6a8783160c7ba4..1e09e523cd7031f4a6a590a4b553aa2f5b82e0c6 100644 (file)
@@ -71,7 +71,7 @@ ICONJAR= -C $(ICONDIR) micropeak-16.png \
        -C $(ICONDIR) micropeak-128.png \
        -C $(ICONDIR) micropeak-256.png
 
        -C $(ICONDIR) micropeak-128.png \
        -C $(ICONDIR) micropeak-256.png
 
-WINDOWS_ICON=$(ICONDIR)/micro-peak.ico
+WINDOWS_ICON=$(ICONDIR)/micro-peak.ico $(ICONDIR)/micro-peak.exe
 MACOSX_ICON=$(ICONDIR)/MicroPeak.icns
 
 desktopdir = $(datadir)/applications
 MACOSX_ICON=$(ICONDIR)/MicroPeak.icns
 
 desktopdir = $(datadir)/applications
index bb5da1bb64e4e33846344a57bb5e3c5c9058e43b..d8e475051778d61d9e6b7d34972081417f80269b 100644 (file)
@@ -1,15 +1,22 @@
-!addplugindir Instdrv/NSIS/Plugins
+!addplugindir ../altosui/Instdrv/NSIS/Plugins
 !addincludedir ../altosui/Instdrv/NSIS/Includes
 !include x64.nsh
 !include java.nsh
 !addincludedir ../altosui/Instdrv/NSIS/Includes
 !include x64.nsh
 !include java.nsh
+!include refresh-sh.nsh
 
 
-Name "Altus Metrum MicroPeak Installer"
+!define REG_NAME "MicroPeak"
+!define PROG_ID "org.altusmetrum.micropeak.1"
+!define FAT_NAME "micropeak-fat.jar"
+!define ICO_ICO "micro-peak.ico"
+!define ICO_EXE "micro-peak.exe"
+
+Name "${REG_NAME} Installer"
 
 ; Default install directory
 InstallDir "$PROGRAMFILES\AltusMetrum"
 
 ; Tell the installer where to re-install a new version
 
 ; Default install directory
 InstallDir "$PROGRAMFILES\AltusMetrum"
 
 ; Tell the installer where to re-install a new version
-InstallDirRegKey HKLM "Software\AltusMetrum" "Install_Dir"
+InstallDirRegKey HKLM "Software\${REG_NAME}" "Install_Dir"
 
 LicenseText "GNU General Public License Version 2"
 LicenseData "../COPYING"
 
 LicenseText "GNU General Public License Version 2"
 LicenseData "../COPYING"
@@ -19,7 +26,7 @@ RequestExecutionLevel admin
 
 ShowInstDetails Show
 
 
 ShowInstDetails Show
 
-ComponentText "Altus Metrum MicroPeak Software Installer"
+ComponentText "${REG_NAME} Software and Driver Installer"
 
 Function .onInit
        DetailPrint "Checking host operating system"
 
 Function .onInit
        DetailPrint "Checking host operating system"
@@ -31,6 +38,16 @@ Function .onInit
        ${EndIf}
 FunctionEnd
 
        ${EndIf}
 FunctionEnd
 
+Function un.onInit
+       DetailPrint "Checking host operating system"
+       ${If} ${RunningX64}
+               DetailPrint "Installer running on 64-bit host"
+               SetRegView 64
+               StrCpy $INSTDIR "$PROGRAMFILES64\AltusMetrum"
+               ${DisableX64FSRedirection}
+       ${EndIf}
+FunctionEnd
+
 ; Pages to present
 
 Page license
 ; Pages to present
 
 Page license
@@ -43,12 +60,21 @@ UninstPage instfiles
 
 ; And the stuff to install
 
 
 ; And the stuff to install
 
-Section "MicroPeak Application"
+Section "FTDI USB Driver"
+       SetOutPath $INSTDIR
+
+       File "CDM20824_Setup.exe"
+
+       StrCpy $2 "$INSTDIR\CDM20824_Setup.exe"
+       ExecWait $2
+SectionEnd
+
+Section "${REG_NAME} Application"
        Call DetectJRE
 
        SetOutPath $INSTDIR
 
        Call DetectJRE
 
        SetOutPath $INSTDIR
 
-       File "micropeak-fat.jar"
+       File "${FAT_NAME}"
        File "altoslib_@ALTOSLIB_VERSION@.jar"
        File "altosuilib_@ALTOSUILIB_VERSION@.jar"
        File "jfreechart.jar"
        File "altoslib_@ALTOSLIB_VERSION@.jar"
        File "altosuilib_@ALTOSUILIB_VERSION@.jar"
        File "jfreechart.jar"
@@ -56,22 +82,13 @@ Section "MicroPeak Application"
 
        File "*.dll"
 
 
        File "*.dll"
 
-       File "../icon/*.ico"
+       File "../icon/${ICO_ICO}"
 
 
-       CreateShortCut "$SMPROGRAMS\MicroPeak.lnk" "$SYSDIR\javaw.exe" "-jar micropeak-fat.jar" "$INSTDIR\micro-peak.ico"
+       CreateShortCut "$SMPROGRAMS\${REG_NAME}.lnk" "$SYSDIR\javaw.exe" "-jar ${FAT_NAME}" "$INSTDIR\${ICO_ICO}"
 SectionEnd
 
 SectionEnd
 
-Section "FTDI USB Driver"
-       SetOutPath $INSTDIR
-
-       File "CDM20824_Setup.exe"
-
-       StrCpy $2 "$INSTDIR\CDM20824_Setup.exe"
-       ExecWait $2
-SectionEnd
-
-Section "MicroPeak Desktop Shortcut"
-       CreateShortCut "$DESKTOP\MicroPeak.lnk" "$INSTDIR\micropeak-fat.jar"  "" "$INSTDIR\micro-peak.ico"
+Section "${REG_NAME} Desktop Shortcut"
+       CreateShortCut "$DESKTOP\${REG_NAME}.lnk" "$INSTDIR\${FAT_NAME}"  "" "$INSTDIR\${ICO_ICO}"
 SectionEnd
 
 Section "Documentation"
 SectionEnd
 
 Section "Documentation"
@@ -81,33 +98,74 @@ Section "Documentation"
        File "../doc/micropeak.pdf"
 SectionEnd
 
        File "../doc/micropeak.pdf"
 SectionEnd
 
+Section "File Associations"
+
+       SetOutPath $INSTDIR
+
+       File "../icon/${ICO_EXE}"
+
+       ; application elements
+       
+       WriteRegStr HKCR "${PROG_ID}"                   ""                              "MicroPeak Data File"
+       WriteRegStr HKCR "${PROG_ID}"                   "FriendlyTypeName"              "MicroPeak Data File"
+       WriteRegStr HKCR "${PROG_ID}\CurVer"            ""                              "${PROG_ID}"
+       WriteRegStr HKCR "${PROG_ID}\DefaultIcon"       ""                              '"$INSTDIR\${ICO_EXE}",-101'
+  WriteRegExpandStr HKCR "${PROG_ID}\shell\play\command" ""                            '"%SYSTEMROOT%\System32\javaw.exe" -Djava.library.path="$INSTDIR" -jar "$INSTDIR\${FAT_NAME}" "%1"'
+
+       ; .mpd elements
+
+       WriteRegStr HKCR ".mpd"                         ""                              "${PROG_ID}"
+       WriteRegStr HKCR ".mpd"                         "PerceivedType"                 "MicroPeak Data File"
+       WriteRegStr HKCR ".mpd"                         "Content Type"                  "application/micropeak"
+
+       WriteRegStr HKCR ".mpd\OpenWithProgids"         "${PROG_ID}"                    ""
+       WriteRegStr HKCR ".mpd\${PROG_ID}"              ""                              "${REG_NAME}"
+
+       Call RefreshShellIcons
+SectionEnd
+       
 Section "Uninstaller"
 
        ; Deal with the uninstaller
 
 Section "Uninstaller"
 
        ; Deal with the uninstaller
 
+       ${DisableX64FSRedirection}
        SetOutPath $INSTDIR
 
        ; Write the install path to the registry
        SetOutPath $INSTDIR
 
        ; Write the install path to the registry
-       WriteRegStr HKLM SOFTWARE\AltusMetrum "Install_Dir" "$INSTDIR"
+       WriteRegStr HKLM "SOFTWARE\${REG_NAME}" "Install_Dir" "$INSTDIR"
 
        ; Write the uninstall keys for windows
 
        ; Write the uninstall keys for windows
-       WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\AltusMetrum" "DisplayName" "Altus Metrum"
-       WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\AltusMetrum" "UninstallString" '"$INSTDIR\uninstall.exe"'
-       WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\AltusMetrum" "NoModify" "1"
-       WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\AltusMetrum" "NoRepair" "1"
+       WriteRegStr HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\${REG_NAME}" "DisplayName" "${REG_NAME}"
+       WriteRegStr HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\${REG_NAME}" "UninstallString" '"$INSTDIR\uninstall-${REG_NAME}.exe"'
+       WriteRegStr HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\${REG_NAME}" "NoModify" "1"
+       WriteRegStr HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\${REG_NAME}" "NoRepair" "1"
 
 
-       WriteUninstaller "uninstall.exe"
+       WriteUninstaller "uninstall-${REG_NAME}.exe"
 SectionEnd
 
 Section "Uninstall"
 SectionEnd
 
 Section "Uninstall"
-       DeleteRegKey HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\AltusMetrum"
-       DeleteRegKey HKLM "Software\AltusMetrum"
 
 
-       Delete "$INSTDIR\*.*"
-       RMDir "$INSTDIR"
+       ${DisableX64FSRedirection}
+
+       DeleteRegKey   HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\${REG_NAME}"
+       DeleteRegKey   HKLM "SOFTWARE\${REG_NAME}"
+
+       DetailPrint "Delete uninstall reg entries"
+
+       DeleteRegKey   HKCR "${PROG_ID}"
+
+       DeleteRegKey   HKCR ".mpd\${PROG_ID}"
+       DeleteRegValue HKCR ".mpd\OpenWithProgids" "${PROG_ID}"
+
+       Delete "$INSTDIR\${FAT_NAME}"
+       Delete "$INSTDIR\uninstall-${REG_NAME}.exe"
+
+       Delete "$INSTDIR\${ICO_ICO}"
+       Delete "$INSTDIR\${ICO_EXE}"
 
        ; Remove shortcuts, if any
 
        ; Remove shortcuts, if any
-       Delete "$SMPROGRAMS\MicroPeak.lnk"
-       Delete "$DESKTOP\MicroPeak.lnk"
+       Delete "$SMPROGRAMS\${REG_NAME}.lnk"
+       Delete "$DESKTOP\${REG_NAME}.lnk"
        
        
+       Call un.RefreshShellIcons
 SectionEnd
 SectionEnd
index 7b550e9eccd00573c9b53be1d8d78045944c2080..8868c72385fcfa2079f1a9b8fa6c9dd1e252fdc6 100644 (file)
@@ -73,7 +73,7 @@ ICONJAR= -C $(ICONDIR) telegps-16.png \
        -C $(ICONDIR) telegps-128.png \
        -C $(ICONDIR) telegps-256.png
 
        -C $(ICONDIR) telegps-128.png \
        -C $(ICONDIR) telegps-256.png
 
-WINDOWS_ICON=$(ICONDIR)/telegps.ico
+WINDOWS_ICON=$(ICONDIR)/telegps.ico $(ICONDIR)/telegps.exe
 MACOSX_ICON=$(ICONDIR)/TeleGPS.icns
 
 # Firmware
 MACOSX_ICON=$(ICONDIR)/TeleGPS.icns
 
 # Firmware
index b41455206532d5152840c88be662d70e5a598f9e..3f9648f99a6ec946780d0a6d7294c38f1555bf2e 100644 (file)
@@ -2,14 +2,22 @@
 !addincludedir ../altosui/Instdrv/NSIS/Includes
 !include x64.nsh
 !include java.nsh
 !addincludedir ../altosui/Instdrv/NSIS/Includes
 !include x64.nsh
 !include java.nsh
+!include refresh-sh.nsh
 
 
-Name "TeleGPS Installer"
+!define REG_NAME "TeleGPS"
+!define PROG_ID "org.altusmetrum.telegps.1"
+!define PROG_ALTOSUI "org.altusmetrum.altosui.1"
+!define FAT_NAME "telegps-fat.jar"
+!define ICO_ICO "telegps.ico"
+!define ICO_EXE "telegps.exe"
+
+Name "${REG_NAME} Installer"
 
 ; Default install directory
 InstallDir "$PROGRAMFILES\AltusMetrum"
 
 ; Tell the installer where to re-install a new version
 
 ; Default install directory
 InstallDir "$PROGRAMFILES\AltusMetrum"
 
 ; Tell the installer where to re-install a new version
-InstallDirRegKey HKLM "Software\AltusMetrum" "Install_Dir"
+InstallDirRegKey HKLM "Software\${REG_NAME}" "Install_Dir"
 
 LicenseText "GNU General Public License Version 2"
 LicenseData "../COPYING"
 
 LicenseText "GNU General Public License Version 2"
 LicenseData "../COPYING"
@@ -19,7 +27,7 @@ RequestExecutionLevel admin
 
 ShowInstDetails Show
 
 
 ShowInstDetails Show
 
-ComponentText "TeleGPS Software Installer"
+ComponentText "${REG_NAME} Software and Driver Installer"
 
 Function .onInit
        DetailPrint "Checking host operating system"
 
 Function .onInit
        DetailPrint "Checking host operating system"
@@ -31,6 +39,16 @@ Function .onInit
        ${EndIf}
 FunctionEnd
 
        ${EndIf}
 FunctionEnd
 
+Function un.onInit
+       DetailPrint "Checking host operating system"
+       ${If} ${RunningX64}
+               DetailPrint "Installer running on 64-bit host"
+               SetRegView 64
+               StrCpy $INSTDIR "$PROGRAMFILES64\AltusMetrum"
+               ${DisableX64FSRedirection}
+       ${EndIf}
+FunctionEnd
+
 ; Pages to present
 
 Page license
 ; Pages to present
 
 Page license
@@ -66,12 +84,12 @@ done:
 
 SectionEnd
 
 
 SectionEnd
 
-Section "TeleGPS Application"
+Section "${REG_NAME} Application"
        Call DetectJRE
 
        SetOutPath $INSTDIR
 
        Call DetectJRE
 
        SetOutPath $INSTDIR
 
-       File "telegps-fat.jar"
+       File "${FAT_NAME}"
        File "altoslib_@ALTOSLIB_VERSION@.jar"
        File "altosuilib_@ALTOSUILIB_VERSION@.jar"
        File "cmudict04.jar"
        File "altoslib_@ALTOSLIB_VERSION@.jar"
        File "altosuilib_@ALTOSUILIB_VERSION@.jar"
        File "cmudict04.jar"
@@ -86,13 +104,13 @@ Section "TeleGPS Application"
 
        File "*.dll"
 
 
        File "*.dll"
 
-       File "../icon/*.ico"
+       File "../icon/${ICO_ICO}"
 
 
-       CreateShortCut "$SMPROGRAMS\TeleGPS.lnk" "$SYSDIR\javaw.exe" "-jar telegps-fat.jar" "$INSTDIR\telegps.ico"
+       CreateShortCut "$SMPROGRAMS\${REG_NAME}.lnk" "$SYSDIR\javaw.exe" "-jar ${FAT_NAME}" "$INSTDIR\${ICO_ICO}"
 SectionEnd
 
 SectionEnd
 
-Section "TeleGPS Desktop Shortcut"
-       CreateShortCut "$DESKTOP\TeleGPS.lnk" "$INSTDIR\telegps-fat.jar"  "" "$INSTDIR\telegps.ico"
+Section "${REG_NAME} Desktop Shortcut"
+       CreateShortCut "$DESKTOP\${REG_NAME}.lnk" "$INSTDIR\${FAT_NAME}"  "" "$INSTDIR\${ICO_ICO}"
 SectionEnd
 
 Section "TeleGPS, TeleDongle and TeleBT Firmware"
 SectionEnd
 
 Section "TeleGPS, TeleDongle and TeleBT Firmware"
@@ -114,38 +132,88 @@ Section "Documentation"
        File "../doc/telemetry.pdf"
 SectionEnd
 
        File "../doc/telemetry.pdf"
 SectionEnd
 
+Section "File Associations"
+
+       SetOutPath $INSTDIR
+
+       File "../icon/${ICO_EXE}"
+
+       ; application elements
+       
+       WriteRegStr HKCR "${PROG_ID}"                   ""                              "Altus Metrum Data File"
+       WriteRegStr HKCR "${PROG_ID}"                   "FriendlyTypeName"              "Altus Metrum Data File"
+       WriteRegStr HKCR "${PROG_ID}\CurVer"            ""                              "${PROG_ID}"
+       WriteRegStr HKCR "${PROG_ID}\DefaultIcon"       ""                              '"$INSTDIR\${ICO_EXE}",-101'
+  WriteRegExpandStr HKCR "${PROG_ID}\shell\play\command" ""                            '"%SYSTEMROOT%\System32\javaw.exe" -Djava.library.path="$INSTDIR" -jar "$INSTDIR\${FAT_NAME}" "%1"'
+
+       ; .eeprom elements
+
+       WriteRegStr HKCR ".eeprom"                      ""                              "${PROG_ALTOSUI}"
+       WriteRegStr HKCR ".eeprom"                      "PerceivedType"                 "Altus Metrum Log File"
+       WriteRegStr HKCR ".eeprom"                      "Content Type"                  "application/altosui"
+
+       WriteRegStr HKCR ".eeprom\OpenWithProgids"      "${PROG_ID}"                    ""
+       WriteRegStr HKCR ".eeprom\${PROG_ID}"           ""                              "${REG_NAME}"
+       
+       ; .telem elements
+       
+       WriteRegStr HKCR ".telem"                       ""                              "${PROG_ALTOSUI}"
+       WriteRegStr HKCR ".telem"                       "PerceivedType"                 "Altus Metrum Telemetry File"
+       WriteRegStr HKCR ".telem"                       "Content Type"                  "application/altosui"
+
+       WriteRegStr HKCR ".telem\OpenWithProgids"       "${PROG_ID}"                    ""
+       WriteRegStr HKCR ".telem\${PROG_ID}"            ""                              "${REG_NAME}"
+
+       Call RefreshShellIcons
+SectionEnd
+       
 Section "Uninstaller"
 
        ; Deal with the uninstaller
 
 Section "Uninstaller"
 
        ; Deal with the uninstaller
 
+       ${DisableX64FSRedirection}
        SetOutPath $INSTDIR
 
        ; Write the install path to the registry
        SetOutPath $INSTDIR
 
        ; Write the install path to the registry
-       WriteRegStr HKLM SOFTWARE\AltusMetrum "Install_Dir" "$INSTDIR"
+       WriteRegStr HKLM "SOFTWARE\${REG_NAME}" "Install_Dir" "$INSTDIR"
 
        ; Write the uninstall keys for windows
 
        ; Write the uninstall keys for windows
-       WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\AltusMetrum" "DisplayName" "Altus Metrum"
-       WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\AltusMetrum" "UninstallString" '"$INSTDIR\uninstall.exe"'
-       WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\AltusMetrum" "NoModify" "1"
-       WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\AltusMetrum" "NoRepair" "1"
+       WriteRegStr HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\${REG_NAME}" "DisplayName" "${REG_NAME}"
+       WriteRegStr HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\${REG_NAME}" "UninstallString" '"$INSTDIR\uninstall-${REG_NAME}.exe"'
+       WriteRegStr HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\${REG_NAME}" "NoModify" "1"
+       WriteRegStr HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\${REG_NAME}" "NoRepair" "1"
 
 
-       WriteUninstaller "uninstall.exe"
+       WriteUninstaller "uninstall-${REG_NAME}.exe"
 SectionEnd
 
 Section "Uninstall"
 SectionEnd
 
 Section "Uninstall"
-       DeleteRegKey HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\AltusMetrum"
-       DeleteRegKey HKLM "Software\AltusMetrum"
 
 
-       Delete "$INSTDIR\*.*"
-       RMDir "$INSTDIR"
+       ${DisableX64FSRedirection}
 
 
-       ; Remove devices
-       InstDrv::InitDriverSetup /NOUNLOAD {4D36E96D-E325-11CE-BFC1-08002BE10318} AltusMetrumSerial
-       InstDrv::DeleteOemInfFiles /NOUNLOAD
-       InstDrv::RemoveAllDevices
+       DeleteRegKey   HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\${REG_NAME}"
+       DeleteRegKey   HKLM "SOFTWARE\${REG_NAME}"
+
+       DetailPrint "Delete uninstall reg entries"
+
+       DeleteRegKey   HKCR "${PROG_ID}"
+
+       DeleteRegKey   HKCR ".eeprom\${PROG_ID}"
+       DeleteRegValue HKCR ".eeprom\OpenWithProgids" "${PROG_ID}"
+
+       DeleteRegKey   HKCR ".telem\${PROG_ID}"
+       DeleteRegValue HKCR ".telem\OpenWithProgids" "${PROG_ID}"
+
+       DetailPrint "Delete file association reg entries"
+
+       Delete "$INSTDIR\${FAT_NAME}"
+       Delete "$INSTDIR\uninstall-${REG_NAME}.exe"
+
+       Delete "$INSTDIR\${ICO_ICO}"
+       Delete "$INSTDIR\${ICO_EXE}"
 
        ; Remove shortcuts, if any
 
        ; Remove shortcuts, if any
-       Delete "$SMPROGRAMS\TeleGPS.lnk"
-       Delete "$DESKTOP\TeleGPS.lnk"
+       Delete "$SMPROGRAMS\${REG_NAME}.lnk"
+       Delete "$DESKTOP\${REG_NAME}.lnk"
        
        
+       Call un.RefreshShellIcons
 SectionEnd
 SectionEnd