From: Jason Boyer Date: Wed, 9 May 2018 00:55:51 +0000 (-0400) Subject: LP1731922: Add Firefox support to Hatch X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=refs%2Fheads%2Fuser%2Fcsharp%2Flp1731922_ff_support_signoff;p=working%2FHatch.git LP1731922: Add Firefox support to Hatch Firefox has an unnecessarily picky manifest parser so it requires a separate manifest, and there was also an issue with the batch file and quoting command line parameters that was causing silent failures. The installer has also been updated to put the necessary NativeMessagingHosts key in place but FF doesn't offer the same kind of auto-install abilities that Chrome does. Signed-off-by: Jason Boyer Signed-off-by: Chris Sharp --- diff --git a/extension/app/extension.js b/extension/app/extension.js index fddd095b19..a46a2d3299 100644 --- a/extension/app/extension.js +++ b/extension/app/extension.js @@ -39,10 +39,19 @@ function connectToHatch() { /** * Called when the connection to Hatch goes away. */ -function onDisconnected() { - console.warn("Hatch disconnected: " + chrome.runtime.lastError.message); +function onDisconnected(port) { + var reason = "unspecified reason"; + + if (port && port.error) { + reason = port.error.message; + } else if (chrome.runtime.lastError) { + reason = chrome.runtime.lastError.message; + } + + console.warn("Hatch disconnected: " + reason); hatchPort = null; + // Firefox gives some indication a NativeMessaging app doesn't exist, does Chrome? (port.error.message starts with No such...) if (hatchHostUnavailable) return; // If we can reasonablly assume a connection to the Hatch host diff --git a/extension/app/manifest.json b/extension/app/manifest.json index e953e356a6..2c48b4ec0e 100644 --- a/extension/app/manifest.json +++ b/extension/app/manifest.json @@ -24,5 +24,11 @@ "permissions": [ "nativeMessaging" ], + "applications": { + "gecko": { + "id": "hatch-native-messenger@evergreen-ils.org", + "strict_min_version": "50.0" + } + }, "minimum_chrome_version": "38" } diff --git a/extension/host/org.evergreen_ils.hatch.chrome.json b/extension/host/org.evergreen_ils.hatch.chrome.json new file mode 100644 index 0000000000..8cf84211f2 --- /dev/null +++ b/extension/host/org.evergreen_ils.hatch.chrome.json @@ -0,0 +1,9 @@ +{ + "name": "org.evergreen_ils.hatch", + "description": "Hatch Native Messaging Host", + "path": "/path/to/hatch.sh", + "type": "stdio", + "allowed_origins": [ + "chrome-extension://ppooibdipmklfichpmkcgplfgdplgahl/" + ] +} diff --git a/extension/host/org.evergreen_ils.hatch.firefox.json b/extension/host/org.evergreen_ils.hatch.firefox.json new file mode 100644 index 0000000000..85dea656b3 --- /dev/null +++ b/extension/host/org.evergreen_ils.hatch.firefox.json @@ -0,0 +1,9 @@ +{ + "name": "org.evergreen_ils.hatch", + "description": "Hatch Native Messaging Host", + "path": "/path/to/hatch.sh", + "type": "stdio", + "allowed_extensions": [ + "hatch-native-messenger@evergreen-ils.org" + ] +} diff --git a/extension/host/org.evergreen_ils.hatch.json b/extension/host/org.evergreen_ils.hatch.json deleted file mode 100644 index 8cf84211f2..0000000000 --- a/extension/host/org.evergreen_ils.hatch.json +++ /dev/null @@ -1,9 +0,0 @@ -{ - "name": "org.evergreen_ils.hatch", - "description": "Hatch Native Messaging Host", - "path": "/path/to/hatch.sh", - "type": "stdio", - "allowed_origins": [ - "chrome-extension://ppooibdipmklfichpmkcgplfgdplgahl/" - ] -} diff --git a/hatch.bat b/hatch.bat index 1b208f873c..dd76b2e151 100755 --- a/hatch.bat +++ b/hatch.bat @@ -30,12 +30,17 @@ SET JAVA=%PROGRAMDATA%\Oracle\Java\javapath\java IF %ERRORLEVEL% EQU 0 GOTO Huzzah REM I don't blame you -EXIT %ERRORLEVEL% +EXIT /B %ERRORLEVEL% REM There you are. :Huzzah -IF "%1" == "compile" ( +REM %~1 means to strip %1 of any surrounding quotes. +REM This is necessary if you're going to use a construction like "%1" == "etc" because a quoted %1 will +REM cause silent failures when the batch file is run and dies because the IF command has a syntax error. +REM Specifically, "Files was unexpected at this time." + +IF "%~1" == "compile" ( %JAVAC% -cp "lib\*" -Xdiags:verbose^ -d lib src\org\evergreen_ils\hatch\*.java @@ -45,7 +50,7 @@ IF "%1" == "compile" ( ) ELSE ( - IF "%1" == "test" ( + IF "%~1" == "test" ( %JAVA% -cp "lib\*"^ -Djava.util.logging.config.file=logging.properties^ diff --git a/installer/windows/hatch.nsi b/installer/windows/hatch.nsi index 68fed3e904..06731f321c 100644 --- a/installer/windows/hatch.nsi +++ b/installer/windows/hatch.nsi @@ -62,6 +62,10 @@ ${EndIf} ; Find any installed JRE/JDK and return the version or -1 Function DetectJava + ; FYI: Because it appears there won't ever be a 64 bit version of makensis for linux + ; this script assumes that it will always be run as part of a 32 bit installer. + ; If that should ever change this script will require some significant adjustment. + ; 32 bit JRE >= 9 ReadRegStr $0 HKLM "SOFTWARE\JavaSoft\JRE" "CurrentVersion" StrCmp $0 "" +1 Found @@ -173,14 +177,13 @@ section "install" File ..\..\hatch.bat File ..\..\hatch.properties File ..\..\logging.properties - - ; Set path variable in org.ils_evergreen.hatch.json to $INSTDIR\hatch.bat - ${StrRep} '$0' '$INSTDIR' '\' '\\' - !insertmacro _ReplaceInFile "$INSTDIR\extension\host\org.evergreen_ils.hatch.json" "/path/to/hatch.sh" "$0\\hatch.bat" - AccessControl::EnableFileInheritance "$INSTDIR\extension\host\org.evergreen_ils.hatch.json" - ; Uninstaller - writeUninstaller "$INSTDIR\Uninstall ${APPNAME}.exe" + ; Set path variable in org.ils_evergreen.hatch.*.json to $INSTDIR\hatch.bat + ${StrRep} '$0' '$INSTDIR' '\' '\\' + !insertmacro _ReplaceInFile "$INSTDIR\extension\host\org.evergreen_ils.hatch.chrome.json" "/path/to/hatch.sh" "$0\\hatch.bat" + !insertmacro _ReplaceInFile "$INSTDIR\extension\host\org.evergreen_ils.hatch.firefox.json" "/path/to/hatch.sh" "$0\\hatch.bat" + AccessControl::EnableFileInheritance "$INSTDIR\extension\host\org.evergreen_ils.hatch.chrome.json" + AccessControl::EnableFileInheritance "$INSTDIR\extension\host\org.evergreen_ils.hatch.firefox.json" ; Registry info for Add/Remove Programs WriteRegStr HKLM "SOFTWARE\${COMPANYNAME}\${APPNAME}" "Install Path" $INSTDIR @@ -207,8 +210,25 @@ section "install" WriteRegDWORD HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\${APPNAME}" "EstimatedSize" ${INSTALLSIZE} ; Connect Hatch to Chrome and install the Hatch extension from the Chrome Web Store - WriteRegStr HKLM "SOFTWARE\Google\Chrome\NativeMessagingHosts\org.evergreen_ils.hatch" "" "$INSTDIR\extension\host\org.evergreen_ils.hatch.json" + WriteRegStr HKLM "SOFTWARE\Google\Chrome\NativeMessagingHosts\org.evergreen_ils.hatch" "" "$INSTDIR\extension\host\org.evergreen_ils.hatch.chrome.json" WriteRegStr HKLM "Software\Google\Chrome\Extensions\${EXTENSIONID}" "update_url" "${EXTENSION_UPDATEURL}" + + ; Firefox won't check both the 32 and 64 bit views, so it's on us to put the key in the right place. + ; Firefox doesn't allow automatic installation of remote extensions either, so there's no (good) auto-install option here. :-/ + ; A link should be added to the web client to simplify locating the FF extension. (Links to both would likely be a good practice.) + ${If} ${RunningX64} + SetRegView 64 + ${EndIf} + + WriteRegStr HKLM "SOFTWARE\Mozilla\NativeMessagingHosts\org.evergreen_ils.hatch" "" "$INSTDIR\extension\host\org.evergreen_ils.hatch.firefox.json" + + ${If} ${RunningX64} + SetRegView 32 + ${EndIf} + + ; Uninstaller + writeUninstaller "$INSTDIR\Uninstall ${APPNAME}.exe" + SectionEnd @@ -217,7 +237,7 @@ SectionEnd function un.onInit SetShellVarContext all - + # Verify uninstaller MessageBox MB_OKCANCEL "Permanently remove ${APPNAME}?" /SD IDOK IDOK next Abort @@ -225,7 +245,7 @@ function un.onInit !insertmacro VerifyUserIsAdmin functionEnd -section "uninstall" +section "uninstall" # Remove the actual files Delete /REBOOTOK "$INSTDIR\hatch.bat" Delete /REBOOTOK "$INSTDIR\hatch.properties" @@ -235,18 +255,25 @@ section "uninstall" RmDir /r /REBOOTOK "$INSTDIR\lib" # Delete uninstaller last Delete /REBOOTOK "$INSTDIR\Uninstall ${APPNAME}.exe" - + # Remove installation directory RmDir /REBOOTOK "$INSTDIR" - + # Remove uninstaller info from registry DeleteRegKey HKLM "SOFTWARE\${COMPANYNAME}\${APPNAME}" DeleteRegKey HKLM "SOFTWARE\${COMPANYNAME}" DeleteRegKey HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\${APPNAME}" DeleteRegKey HKLM "SOFTWARE\Google\Chrome\NativeMessagingHosts\org.evergreen_ils.hatch" DeleteRegKey HKLM "SOFTWARE\Google\Chrome\Extensions\${EXTENSIONID}" + ${If} ${RunningX64} - DeleteRegKey HKLM "SOFTWARE\Wow6432Node\Google\Chrome\Extensions\${EXTENSIONID}" + SetRegView 64 + ${EndIf} + + DeleteRegKey HKLM "SOFTWARE\Mozilla\NativeMessagingHosts\org.evergreen_ils.hatch" + + ${If} ${RunningX64} + SetRegView 32 ${EndIf} IfRebootFlag 0 Done @@ -254,5 +281,5 @@ section "uninstall" Reboot Done: - + sectionEnd