From a3a9066303ccec45eaf4fb6b43e7dcea04783df6 Mon Sep 17 00:00:00 2001 From: Tres Finocchiaro Date: Tue, 20 Sep 2016 21:57:25 -0400 Subject: [PATCH] Autostart by default (#107) --- ant/apple/apple-launcher.sh.in | 6 ++ ant/apple/apple-postinstall.sh.in | 27 +++++ ant/apple/apple-uninstall.sh.in | 5 + ant/firefox/locator.sh.in | 8 +- ant/linux/linux-installer.sh.in | 18 ++++ ant/linux/linux-keygen.sh.in | 6 ++ .../Plugins/Release_ANSI/AccessControl.dll | Bin 0 -> 13312 bytes .../Plugins/Release_Unicode/AccessControl.dll | Bin 0 -> 15360 bytes ant/windows/windows-cleanup.js | 2 +- ant/windows/windows-packager.nsi.in | 16 ++- build.xml | 2 + src/qz/deploy/DeployUtilities.java | 39 ++----- src/qz/deploy/LinuxDeploy.java | 97 +++++++++--------- src/qz/deploy/MacDeploy.java | 91 ++++++---------- src/qz/deploy/WindowsDeploy.java | 89 +++++++--------- src/qz/utils/FileUtilities.java | 19 ++++ 16 files changed, 227 insertions(+), 198 deletions(-) create mode 100644 ant/windows/nsis/Plugins/Release_ANSI/AccessControl.dll create mode 100644 ant/windows/nsis/Plugins/Release_Unicode/AccessControl.dll diff --git a/ant/apple/apple-launcher.sh.in b/ant/apple/apple-launcher.sh.in index c8f097949..2624c5d0a 100644 --- a/ant/apple/apple-launcher.sh.in +++ b/ant/apple/apple-launcher.sh.in @@ -20,6 +20,12 @@ iconpath=$installpath/${apple.resources}/${apple.icon} ${apple.jvmver} > /dev/null 2>&1 fallback=$? +# If launched at startup, check override first +if [[ "$1" == "--autostart" ]] && [[ "$(cat "$installpath/.autostart")" == "0" ]]; then + echo "Skipping autostart" + exit 0 +fi + # Fallback on Internet Plug-Ins version if needed if [ $fallback -eq 0 ]; then ${apple.jvmcmd} java ${launch.opts} -Xdock:name="${project.name}" -Xdock:icon="$iconpath" -jar -Dapple.awt.UIElement="true" "$jarpath" -NSRequiresAquaSystemAppearance False diff --git a/ant/apple/apple-postinstall.sh.in b/ant/apple/apple-postinstall.sh.in index 6fb1c8715..cbc198a2e 100644 --- a/ant/apple/apple-postinstall.sh.in +++ b/ant/apple/apple-postinstall.sh.in @@ -20,6 +20,33 @@ if [ $? -eq 0 ]; then "${apple.installdir}/auth/firefox/${firefoxcert.name}" "install" fi +# Install startup +site=$(echo "${vendor.website}"|rev|cut -d/ -f1|rev) +package=$(echo "$site" |rev |cut -d. -f1|rev).$(echo "$site" |rev |cut -d. -f2|rev).${project.filename} +cat > /Library/LaunchAgents/$package.plist << EOT + + + + + Label$package + KeepAlive + + SuccessfulExit + AfterInitialDemand + + RunAtLoad + ProgramArguments + + ${apple.installdir}/${apple.macos}/${project.name} + --autostart + + + +EOT + +printf 1 > "${apple.installdir}/.autostart" +chmod 777 "${apple.installdir}/.autostart" + # Cleanup resources from previous versions rm -rf "${apple.installdir}/demo/js/3rdparty" rm "${apple.installdir}/demo/js/qz-websocket.js" diff --git a/ant/apple/apple-uninstall.sh.in b/ant/apple/apple-uninstall.sh.in index 3a09e0510..046d54e84 100644 --- a/ant/apple/apple-uninstall.sh.in +++ b/ant/apple/apple-uninstall.sh.in @@ -26,6 +26,11 @@ else echo -e "${bash.skipped}" fi +# Remove startup entry +site=$(echo "${vendor.website}"|rev|cut -d/ -f1|rev) +package=$(echo "$site" |rev |cut -d. -f1|rev).$(echo "$site" |rev |cut -d. -f2|rev).${project.filename} +rm -f /Library/LaunchAgents/$package.plist + # Uninstall ${project.name} system certificates "${apple.installdir}/auth/${apple.keygen.name}" "uninstall" diff --git a/ant/firefox/locator.sh.in b/ant/firefox/locator.sh.in index fa4548fee..771a7bba4 100755 --- a/ant/firefox/locator.sh.in +++ b/ant/firefox/locator.sh.in @@ -44,7 +44,7 @@ function get_osx_targetdir() elif [[ "/$r" == "$HOME/Applications"* ]]; then dir_out="/$r" return_val=0 - #If nothing else, remember it if we don't have anything else yet + #If nothing else, remember it if we don't have anything else yet elif [ dir_out == "" ]; then dir_out="/$r" return_val=0 @@ -66,7 +66,7 @@ function get_targetdir() lowerbin=$(echo "$with_bin" |tr '[:upper:]' '[:lower:]') location=$(readlink -f "$(which $lowerdir 2> /dev/null)") targetdir=$(dirname "$location") - if [ -f "$targetdir/$lowerbin" ] && file -b "$targetdir/$lowerbin" |grep -q ELF; then + if [[ "$targetdir" != "/usr/bin" ]] && [ -f "$targetdir/$lowerbin" ] && file -b "$targetdir/$lowerbin" |grep -q ELF; then dir_out="$targetdir" return 0 else @@ -94,10 +94,10 @@ if [ "$#" == 0 ]; then elif [ "$#" == 1 ]; then with_dir=$1 with_bin=$1 -else +else with_dir=$1 with_bin=$2 -fi +fi if [[ "$OSTYPE" == "darwin"* ]]; then # Mac OSX diff --git a/ant/linux/linux-installer.sh.in b/ant/linux/linux-installer.sh.in index 7aa9050d8..a23df0c4c 100644 --- a/ant/linux/linux-installer.sh.in +++ b/ant/linux/linux-installer.sh.in @@ -240,6 +240,24 @@ rm -f "/lib/udev/rules.d/${linux.udev.name}" > /dev/null 2>&1 mv "$destdir/${linux.udev.name}" "/lib/udev/rules.d/${linux.udev.name}" > /dev/null 2>&1 udevadm control --reload-rules > /dev/null 2>&1 +progress_dialog 93 "Cleaning up old versions..." + +# Remove old startup entries +for i in /home/* ; do + if [ -n "${project.filename}" ]; then + rm "$i/.config/autostart/${project.filename}.desktop" > /dev/null 2>&1 + fi + if [ -n "${project.name}" ]; then + rm "$i/.config/autostart/${project.name}.desktop" > /dev/null 2>&1 + fi +done + +progress_dialog 94 "Adding startup entry..." +cp "${shortcut}" "/etc/xdg/autostart/${project.filename}.desktop" + +# Allow oridinary users to write +chmod 777 "/etc/xdg/autostart/${project.filename}.desktop" + cd "${destdir}" progress_dialog 95 "Installation complete... Starting ${project.name}..." which sudo > /dev/null 2>&1 diff --git a/ant/linux/linux-keygen.sh.in b/ant/linux/linux-keygen.sh.in index 113eb00cf..d94bcb12d 100644 --- a/ant/linux/linux-keygen.sh.in +++ b/ant/linux/linux-keygen.sh.in @@ -142,6 +142,12 @@ if [ -n "$trustedcertpath" ]; then exit 0 fi +# Check for keytool command +"${jks.keytool} -help" > /dev/null 2>&1 +if [ $? -ne 0 ]; then + export PATH=$PATH:/usr/java/latest/bin/ +fi + # Handle self-signed certificate echo -e "\nCreating keystore for secure websockets..." # Delete old files if exist diff --git a/ant/windows/nsis/Plugins/Release_ANSI/AccessControl.dll b/ant/windows/nsis/Plugins/Release_ANSI/AccessControl.dll new file mode 100644 index 0000000000000000000000000000000000000000..0de0324fc659e3d2d70a91657f76e50bdbb0af77 GIT binary patch literal 13312 zcmeHO4SZD9mA^?QVT6GhAfcm095o0E;!7qUlle;0WC;9BU|>Q9Klm7u2Qwi|;^aL( zlxXTCZH8yM*80&^yM^Mmu5De{x|X(9gV03kN3pn&E?TjryAMNasu72p_3i(>_a+|_ zHSX^3x7*)u-|u(k-h1vj=bn4+x#!;d-kq8o?`9c{F#|wR7(0NJo-+0K(|?Yldd6ix zoxz^E=;g}~q*cFsd2Kk-YHNu#Z;6Gr+3G{lXtQA3#M@$G)E0@_Dpv+<+nO8rCDW%* z&DBNkSUvMWyZw$MDcE9Jc_bg@?Dq{v3RL{PUT~IP9TrR#@NOs4Iv?f z{LN|jDFaZamH@^)WsLPKiSbR%^^Cnlx>AQo76%yflri?DF~$GS{uNrlUC7uy@ZH^j z20$&q3AhSi1^fl|uLF7kPXg`*>;yDWxd3>;X#hjn2B-zl^Eh~)0o;zdM!?MgKcEb- z1aJjl79a~SXon0yKi~!M(DNYh^sEW^RtIiotfstT+42=W0XuCG|5r>iNgi18tTuZ~2wGPa^wh-}`)m@g`B<6}Sv z#7)=pyIM!-Gz66cyigZv5_!t668YFJy;R9J@d95Fjx;r}+E{2iA8S=<${QNM+z^TJ z^+I!O7ejezq={$MkyfE{1j|?zALV0_df!gIUKGHomxHkgl}5^|`A`E}DmFEh*Vpr{ z&@iwoS|5%zM^AuPm=1USg_fjta5nCZ_4B*Ov=IEV2phwW>5@iY%pw zD$`f4)+1r%EiHVsp;8SVYMqu<>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HcmV?d00001 diff --git a/ant/windows/nsis/Plugins/Release_Unicode/AccessControl.dll b/ant/windows/nsis/Plugins/Release_Unicode/AccessControl.dll new file mode 100644 index 0000000000000000000000000000000000000000..cc27f63f4a7dbbd2266d0227fe30151a8b60290e GIT binary patch literal 15360 zcmeHO4|o*SwZBO=u)xADnAoVPtO^QG#Mzzv-z1xmYyvfbg@r6C0YkE36V^@K%z!9S ze4Dgc$5s1kebhgF`k>a@_GzsJYFkbG6F~95RV-AgkJ`cTo@tG`)yTZxxwD&WBx3CA z_rBNfbMl>;JLjHr?z!jRy)!$hz3f(&#uzgIG>x%6xYAL^&!;{eLHCT=kIrC^OnL5{ zJt;NMowL&4(qU~6wQUGBTxo4=2nO3E>w2FxBnPc6L2KnQkM+v7Cf~y8)2Ggfi+k&lxFPzInDwNrJw5Q6N(k1KGF-{{>SBw9N0tA4Q* zGxkFe9DrOmb${N0&Hy>!%N`i(C#T?9DEY3I(7$^jPNbIr7?}jxIIN6av9PH@YCwBU z3QlDJ=*)5eNk+}T6_-IAG{+9~SB^tl4c;J^-U1meb~TqJgIXVJY`+&Hw0utA3UD-VovWZ(0Dt9> z*a&P#+*TfF7X-!+DQ#%Auxt1zqf(c#&2eqWSflt#9w~%Nj8efRNL*3?_+Y&yzL4aRLM_1!o|dMSZ8&)uYY3)KW({)sG`7AW-MV1CoNm3SMNT)cjxFi4 z*ybi$20ZK{HW#*+aZMZoygC<)h#i*yTUsPXm&rz?6OP8CC5M(3T8e3@vI4dNc;`42 zTFPt|VYArjDYMu;xPG3D@uZ)D(Ix@t>SX56Xdq_ZJwxmj zUq-JGnt^lSW}|s`Usx3e&c|Ij$5q8~`2(|nYY3TeZr(hJ(|OIim!{%AiTkDSyC-o2 zcM>;n-o7J-v?rcir5q0*w|M*qPh%GU0i2YBT4p zJqStWU47|8P&-m>0y6d3oxpk2`Db8^eSOD_JL@D^g)q#T9e72DcvC)~PYcf=GxI-00GJs#6dg15>b^GU?%wrWlOj8Sy=9}i!A=|U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3S3fHp0#ZVY+aJaJFC*@`W;?MpzE3w+bD?^+K2M zufpBJeZs@SZs8f>Md1zj;a%ZVAF14+*-D`W$w#(LMJ7{~; z_9xr>wwP_2eWv|P`}y_@?WOigd#(La`&#=|_RaQf_M7bAw(qn*VE;M1_>}#1`|sh& zzt}&5FD>F3;#~2c#1gSWtPxj>^c!U91Ma)bh*7&fdF7Q>EiVWqHIxB}Mn z3jv{Bkc6v+t->}~wMV!~xK+4K*e={9+#~E19ugiA_6WZgdWENieZm1)`c>hea9B7Z n92HbyP#6+o!mz+#bqnl1$2QL<*otjs*b{wqd}V?EZx;9;_nEiW literal 0 HcmV?d00001 diff --git a/ant/windows/windows-cleanup.js b/ant/windows/windows-cleanup.js index b0a4fcba0..7a32778d9 100644 --- a/ant/windows/windows-cleanup.js +++ b/ant/windows/windows-cleanup.js @@ -45,4 +45,4 @@ function getArg(index, defaultVal) { */ function trim(val) { return val.replace(/^\s+/,'').replace(/\s+$/,''); -} \ No newline at end of file +} diff --git a/ant/windows/windows-packager.nsi.in b/ant/windows/windows-packager.nsi.in index 81e069b3f..186adfaa9 100644 --- a/ant/windows/windows-packager.nsi.in +++ b/ant/windows/windows-packager.nsi.in @@ -96,19 +96,22 @@ Section ${If} ${RunningX64} ${DisableX64FSRedirection} ${EndIf} - + ; Handle edge-case where jscript support is unregistered nsExec::ExecToLog "regsvr32.exe /s $\"%systemroot%\system32\jscript.dll$\"" ; Remove ${vendor.company} certificates nsExec::ExecToLog "cscript.exe //NoLogo //E:jscript $\"$INSTDIR\auth\${windows.keygen.name}$\" $\"$INSTDIR$\" uninstall" + ; Perform cleanup operations from previous install + nsExec::ExecToLog "cscript.exe //NoLogo //E:jscript $\"$INSTDIR\utils\${windows.cleanup.name}$\" $\"${project.name}$\"" + keygen: ; Exports a self-signed certificate and properties file DetailPrint "Generating a unique certificate for HTTPS support..." nsExec::ExecToLog "cscript.exe //NoLogo //E:jscript $\"$INSTDIR\auth\${windows.keygen.name}$\" $\"$INSTDIR$\" install" Pop $0 - + ; Secure websockets is required, handle errors ${If} "$0" != "0" ${If} "$0" == "${windows.err.java}" @@ -130,6 +133,10 @@ Section ${EndIf} CreateShortCut "$SMPROGRAMS\${project.name}.lnk" "$INSTDIR\${project.filename}.exe" "" "$INSTDIR\${windows.icon}" 0 + CreateShortCut "$SMSTARTUP\${project.name}.lnk" "$INSTDIR\${project.filename}.exe" "" "$INSTDIR\${windows.icon}" 0 + + ; Grant R+W to Authenticated Users (S-1-5-11) + AccessControl::GrantOnFile "$SMSTARTUP\${project.name}.lnk" "(S-1-5-11)" "GenericRead + GenericWrite" ; Delete matching firewall rules DetailPrint "Removing ${project.name} firewall rules..." @@ -164,7 +171,7 @@ Section "Uninstall" ${If} ${RunningX64} ${DisableX64FSRedirection} ${EndIf} - + ; Remove ${vendor.company} certificates nsExec::ExecToLog "cscript.exe //NoLogo //E:jscript $\"$INSTDIR\auth\${windows.keygen.name}$\" $\"$INSTDIR$\" uninstall" @@ -174,7 +181,7 @@ Section "Uninstall" ; Remove startup entries nsExec::ExecToLog "cscript.exe //NoLogo //E:jscript $\"$INSTDIR\utils\${windows.cleanup.name}$\" $\"${project.name}$\"" - + ; Delete matching firewall rules DetailPrint "Removing ${project.name} firewall rules..." nsExec::ExecToLog "netsh.exe advfirewall firewall delete rule name= $\"${project.name}$\"" @@ -191,6 +198,7 @@ Section "Uninstall" Delete "$DESKTOP\${project.name}.url" Delete "$DESKTOP\${project.name}.lnk" + Delete "$SMSTARTUP\${project.name}.lnk" ; Sets the context of shell folders to current user SetShellVarContext current diff --git a/build.xml b/build.xml index 6bdadd7fd..d80b5b6ec 100644 --- a/build.xml +++ b/build.xml @@ -253,6 +253,8 @@ + + diff --git a/src/qz/deploy/DeployUtilities.java b/src/qz/deploy/DeployUtilities.java index c7700edae..f4639448f 100644 --- a/src/qz/deploy/DeployUtilities.java +++ b/src/qz/deploy/DeployUtilities.java @@ -114,7 +114,7 @@ public boolean createShortcut(ToggleType toggleType) { * @param toggleType Shortcut type, i.e. ToggleType.STARTUP or ToggleType.DESKTOP * @return Whether or not the shortcut already exists */ - public boolean hasShortcut(ToggleType toggleType) { + private boolean hasShortcut(ToggleType toggleType) { boolean hasShortcut = false; switch(toggleType) { case STARTUP: @@ -166,7 +166,7 @@ public boolean removeShortcut(ToggleType toggleType) { * @return The calculated working path value, or an empty string if one * could not be determined */ - static String getParentDirectory(String filePath) { + private static String getParentDirectory(String filePath) { // Working path should always default to the JARs parent folder int lastSlash = filePath.lastIndexOf(File.separator); return lastSlash < 0? "":filePath.substring(0, lastSlash); @@ -202,25 +202,6 @@ public static DeployUtilities getSystemShortcutCreator() { } } - /** - * Creates all appropriate parent folders for the file path specified - * - * @param filePath The file in which to create parent directories for - * @return Whether or not the parent folder creation was successful - */ - static boolean createParentFolder(String filePath) { - String parentDirectory = getParentDirectory(filePath); - File f = new File(parentDirectory); - try { - f.mkdirs(); - return f.exists(); - } - catch(SecurityException e) { - log.error("Error while creating parent directories for: {}", filePath, e); - } - return false; - } - /** * Returns whether or not a file exists * @@ -296,7 +277,8 @@ static boolean writeArrayToFile(String filePath, String[] array) { * @param filePath The full file path to set the execute flag on * @return true if successful, false otherwise */ - static boolean setExecutable(String filePath) { + @SuppressWarnings("ResultOfMethodCallIgnored") + private static boolean setExecutable(String filePath) { if (!SystemUtilities.isWindows()) { try { File f = new File(filePath); @@ -315,7 +297,7 @@ static boolean setExecutable(String filePath) { /** * Gets the path to qz-tray.properties */ - public static String detectPropertiesPath() { + private static String detectPropertiesPath() { // Use supplied path from IDE or command line // i.e -DsslPropertiesFile=C:\qz-tray.properties String override = System.getProperty("sslPropertiesFile"); @@ -354,7 +336,7 @@ public static Properties loadTrayProperties() { * @return A String value representing the absolute path to the currently running * jar */ - public static String detectJarPath() { + private static String detectJarPath() { try { String jarPath = new File(DeployUtilities.class.getProtectionDomain() .getCodeSource().getLocation().getPath()).getCanonicalPath(); @@ -379,15 +361,6 @@ public String getJarPath() { return jarPath; } - /** - * Set the jar path for which we will create a shortcut for - * - * @param jarPath The full file path of the jar file - */ - public void setJarPath(String jarPath) { - this.jarPath = jarPath; - } - /** * Small Enum for differentiating "desktop" and "startup" */ diff --git a/src/qz/deploy/LinuxDeploy.java b/src/qz/deploy/LinuxDeploy.java index 7c9d24721..0dd7296b2 100644 --- a/src/qz/deploy/LinuxDeploy.java +++ b/src/qz/deploy/LinuxDeploy.java @@ -10,97 +10,102 @@ package qz.deploy; +import java.awt.Toolkit; +import java.lang.reflect.Field; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import qz.common.Constants; -import qz.utils.ShellUtilities; - -import java.io.File; -import java.io.UnsupportedEncodingException; -import java.net.URLDecoder; +import qz.utils.*; /** * @author Tres Finocchiaro */ -public class LinuxDeploy extends DeployUtilities { +class LinuxDeploy extends DeployUtilities { private static final Logger log = LoggerFactory.getLogger(LinuxDeploy.class); + private static String STARTUP = "/etc/xdg/autostart/"; + private static String DESKTOP = System.getProperty("user.home") + "/Desktop/"; + private static String DELETED_ICON = "process-stop"; + + private String appLauncher = "/usr/share/applications/" + getShortcutName(); + @Override public boolean createStartupShortcut() { ShellUtilities.execute(new String[] { "mkdir", "-p", System.getProperty("user.home") + "/.config/autostart/" }); - return createShortcut(System.getProperty("user.home") + "/.config/autostart/"); + return copyShortcut(appLauncher, STARTUP); } @Override public boolean createDesktopShortcut() { - return createShortcut(System.getProperty("user.home") + "/Desktop/"); + return copyShortcut(appLauncher, DESKTOP); } @Override public boolean removeStartupShortcut() { - return deleteFile(System.getProperty("user.home") + "/.config/autostart/" + getShortcutName()); + return writeArrayToFile(STARTUP + getShortcutName(), new String[]{ + "[Desktop Entry]", + "Type=Application", + "Name=" + Constants.ABOUT_TITLE + " (Disabled)", + "Exec=/bin/true", + "Icon=" + DELETED_ICON, + "Terminal=false", + }); } @Override public boolean removeDesktopShortcut() { - return deleteFile(System.getProperty("user.home") + "/Desktop/" + getShortcutName()); + return deleteFile(DESKTOP + getShortcutName()); } @Override public boolean hasStartupShortcut() { - String target = System.getProperty("user.home") + "/.config/autostart/"; - upgradeLegacyShortcut(target); - return fileExists(target + getShortcutName()); + try { + String contents = FileUtilities.readLocalFile(STARTUP + getShortcutName()); + return !contents.contains("Icon=" + DELETED_ICON); + } catch (Exception ex) { + log.warn("Unable to read startup shortcut {}", STARTUP + getShortcutName(), ex); + } + return false; } @Override public boolean hasDesktopShortcut() { - String target = System.getProperty("user.home") + "/Desktop/"; - upgradeLegacyShortcut(target); - return fileExists(target + getShortcutName()); + // Upgrade legacy "QZ Tray.desktop" shortcuts + String shortcut = DESKTOP + Constants.ABOUT_TITLE + ".desktop"; + if (fileExists(shortcut)) { + if (ShellUtilities.execute(new String[] { "rm", shortcut })) { + copyShortcut(appLauncher, DESKTOP); + } + } + return fileExists(DESKTOP + getShortcutName()); } - /** - * Creates a Linux ".desktop" shortcut - * - * @param target target location of shortcut - * @return Whether or not the shortcut was created successfully - */ - public boolean createShortcut(String target) { + private static boolean copyShortcut(String source, String target) { return ShellUtilities.execute(new String[] { - "cp", getAppPath(), target + "cp", source, target }); } @Override - public String getShortcutName() { - return Constants.PROPS_FILE + ".desktop"; - } - - /** - * Returns the path to the jar executable or desktop launcher - * @return - */ - public String getAppPath() { - return "/usr/share/applications/" + getShortcutName(); + public void setShortcutName(String name) { + super.setShortcutName(name); + // Fix window titles on Gnome 3 per JDK-6528430 + try { + Toolkit t = Toolkit.getDefaultToolkit(); + Field f = t.getClass().getDeclaredField("awtAppClassName"); + f.setAccessible(true); + f.set(t, name); + } + catch (Exception ignore) {} } - /** - * Upgrade 1.9 shortcut to new 2.0 format - * @return - */ - private boolean upgradeLegacyShortcut(String target) { - String shortcut = target + Constants.ABOUT_TITLE + ".desktop"; - if (fileExists(shortcut)) { - if (ShellUtilities.execute(new String[] { "rm", shortcut })) { - return createShortcut(target); - } - } - return false; + @Override + public String getShortcutName() { + return Constants.PROPS_FILE + ".desktop"; } } diff --git a/src/qz/deploy/MacDeploy.java b/src/qz/deploy/MacDeploy.java index 9b295fa90..ac8d82c99 100644 --- a/src/qz/deploy/MacDeploy.java +++ b/src/qz/deploy/MacDeploy.java @@ -11,41 +11,44 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import qz.utils.FileUtilities; import qz.utils.ShellUtilities; +import java.io.BufferedWriter; import java.io.File; -import java.io.IOException; +import java.io.FileWriter; import java.io.UnsupportedEncodingException; import java.net.URLDecoder; /** * @author Tres Finocchiaro */ -public class MacDeploy extends DeployUtilities { +class MacDeploy extends DeployUtilities { private static final Logger log = LoggerFactory.getLogger(MacDeploy.class); + private String autostartToggle = getAppPath() + "/.autostart"; + private String desktopShortcut = System.getProperty("user.home") + "/Desktop/" + getShortcutName(); + @Override public boolean hasStartupShortcut() { - return ShellUtilities.executeAppleScript( - "tell application \"System Events\" to get the name " - + "of every login item where name is \"" + getShortcutName() + "\"", - getShortcutName() - ); + removeLegacyStartup(); + try { + return FileUtilities.readLocalFile(autostartToggle).contains("1"); + } catch (Exception err) { + log.warn("Could not read .autostart file", err); + } + return false; } @Override public boolean hasDesktopShortcut() { - return isSymlink(System.getProperty("user.home") + "/Desktop/" + getShortcutName()); + return FileUtilities.isSymlink(desktopShortcut); } @Override public boolean createStartupShortcut() { - return ShellUtilities.executeAppleScript( - "tell application \"System Events\" to make login item " - + "at end with properties {path:\"" + getAppPath() + "\", " - + "hidden:true, name:\"" + getShortcutName() + "\"}" - ); + return writeAutostart(1); } @Override @@ -61,28 +64,26 @@ public String getJarPath() { return jarPath; } - /** - * Returns the jar's filename, which may be the identity of the startup - * entry - * - * @return The jar's filename without the preceeding path information - */ private String getJarName() { return new File(getJarPath()).getName(); } @Override public boolean createDesktopShortcut() { - - - return ShellUtilities.execute(new String[] { - "ln", "-sf", getAppPath(), - System.getProperty("user.home") + "/Desktop/" + getShortcutName() - }); + return ShellUtilities.execute(new String[] {"ln", "-sf", getAppPath(), desktopShortcut}); } @Override public boolean removeStartupShortcut() { + return writeAutostart(0); + } + + @Override + public boolean removeDesktopShortcut() { + return ShellUtilities.execute(new String[] {"unlink", desktopShortcut}); + } + + private boolean removeLegacyStartup() { return ShellUtilities.executeAppleScript( "tell application \"System Events\" to delete " + "every login item where name is \"" + getShortcutName() + "\" or " @@ -90,44 +91,20 @@ public boolean removeStartupShortcut() { ); } - @Override - public boolean removeDesktopShortcut() { - return ShellUtilities.execute(new String[] { - "unlink", - System.getProperty("user.home") + "/Desktop/" + getShortcutName() - }); - } - - /** - * Determines if the specified file is a symbolic link. - * - * @param filePath path of file to check for symbolic link - * @return true if a symbolic link is found - */ - public static boolean isSymlink(String filePath) { - log.info("Verifying symbolic link: {}", filePath); - boolean returnVal = false; - if (filePath != null) { - File f = new File(filePath); - if (f.exists()) { - try { - File canonicalFile = (f.getParent() == null? f:f.getParentFile().getCanonicalFile()); - returnVal = !canonicalFile.getCanonicalFile().equals(canonicalFile.getAbsoluteFile()); - } - catch(IOException ex) { - log.error("IOException checking for symlink", ex); - } - } + private boolean writeAutostart(int i) { + try(BufferedWriter w = new BufferedWriter(new FileWriter(autostartToggle))) { + w.write("" + i); + return true; + } catch(Exception err) { + log.warn("Could not write to .autostart", err); } - - log.info("Symbolic link result: {}", returnVal); - return returnVal; + return false; } /** * Returns path to executable jar or app bundle */ - public String getAppPath() { + private String getAppPath() { String target = getJarPath(); if (target.contains("/Applications/")) { // Use the parent folder instead i.e. "/Applications/QZ Tray.app" diff --git a/src/qz/deploy/WindowsDeploy.java b/src/qz/deploy/WindowsDeploy.java index ca6e2e0f4..714ee9eb9 100644 --- a/src/qz/deploy/WindowsDeploy.java +++ b/src/qz/deploy/WindowsDeploy.java @@ -12,7 +12,6 @@ package qz.deploy; import mslinks.ShellLink; -import qz.common.Constants; import qz.utils.ShellUtilities; import java.io.IOException; @@ -21,20 +20,11 @@ * @author Tres Finocchiaro */ public class WindowsDeploy extends DeployUtilities { - - // Try using ${windows.icon} first, if it exists - private static String qzIcon = System.getenv("programfiles").replace(" (x86)", "") + "\\" + Constants.ABOUT_TITLE + "\\windows-icon.ico"; - private static String defaultIcon = System.getenv("windir") + "\\system32\\SHELL32.dll"; - private static boolean useQzIcon = fileExists(qzIcon); + private static String DELETED_ICON = System.getenv("windir") + "\\system32\\SHELL32.dll"; @Override public boolean createStartupShortcut() { - return ShellUtilities.executeRegScript( - "HKCU\\Software\\Microsoft\\Windows\\CurrentVersion\\Run\\", - "add", - getShortcutName(), - quoteWrap(getAppPath()) - ); + return createShortcut(getStartupDirectory()); } @Override @@ -44,11 +34,17 @@ public boolean createDesktopShortcut() { @Override public boolean removeStartupShortcut() { - return ShellUtilities.executeRegScript( - "HKCU\\Software\\Microsoft\\Windows\\CurrentVersion\\Run\\", - "delete", - getShortcutName() - ); + try { + // Dummy shortcut + ShellLink link = ShellLink.createLink("%SystemRoot%\\system32\\rundll32.exe", getStartupDirectory() + getShortcutName() + ".lnk"); + link.setIconLocation(DELETED_ICON); + link.getHeader().setIconIndex(131); + link.saveTo(getStartupDirectory() + getShortcutName() + ".lnk"); + return true; + } catch (Exception ex) { + log.warn("Error removing startup shortcut", ex); + return false; + } } @Override @@ -59,11 +55,16 @@ public boolean removeDesktopShortcut() { @Override public boolean hasStartupShortcut() { - return ShellUtilities.executeRegScript( - "HKCU\\Software\\Microsoft\\Windows\\CurrentVersion\\Run\\", - "query", - getShortcutName() - ); + try { + ShellLink link = new ShellLink(getStartupDirectory() + getShortcutName() + ".lnk"); + return link.getIconLocation() == null || !link.getIconLocation().equals(DELETED_ICON); + } catch (NegativeArraySizeException ignore) { + // Per mslinks issues #4 + return true; + } catch (Exception ex) { + log.warn("Error detecting startup shortcut", ex); + return false; + } } @Override @@ -72,9 +73,8 @@ public boolean hasDesktopShortcut() { } /** - * Enables websockets in IE/Edge by unchecking "Include all local (intranet) sites not listed in other zones" - * This has no effect on domain networks with "Automatically detect intranet network" checked. - * In addition, Edge requires CheckNetIsolation command to be effective. + * Remove flag "Include all local (intranet) sites not listed in other zones". Requires CheckNetIsolation + * to be effective; Has no effect on domain networks with "Automatically detect intranet network" checked. * * @return true if successful */ @@ -85,20 +85,11 @@ public static boolean configureIntranetZone() { // If the above value is set, remove it using bitwise XOR, thus disabling this setting int data = ShellUtilities.getRegistryDWORD(path, name); - if (data != -1) { - if ((data & value) == value) { - return ShellUtilities.setRegistryDWORD(path, name, data ^ value); - } - return true; // already set - } - return false; + return data != -1 && ((data & value) != value || ShellUtilities.setRegistryDWORD(path, name, data ^ value)); } /** - * Legacy Edge version: Configure loopback connections via - * - about:flags > Developer Settings > Allow localhost loopback - * - * Modern Edge versions: Utilize CheckNetIsolation.exe via desktop installer instead. + * Set legacy Edge flag: about:flags > Developer Settings > Allow localhost loopback * * @return true if successful */ @@ -109,23 +100,7 @@ public static boolean configureEdgeLoopback() { // If the above value does not exist, add it using bitwise OR, thus enabling this setting int data = ShellUtilities.getRegistryDWORD(path, name); - if (data != -1) { - if ((data & value) != value) { - return ShellUtilities.setRegistryDWORD(path, name, data | value); - } - return true; // already set - } - return false; - } - - /** - * Returns the string with Windows formatted escaped double quotes, useful for - * inserting registry keys - * - * @return The supplied string wrapped in double quotes - */ - private String quoteWrap(String text) { - return "\\\"" + text + "\\\""; + return data != -1 && ((data & value) == value || ShellUtilities.setRegistryDWORD(path, name, data | value)); } /** @@ -150,4 +125,12 @@ private boolean createShortcut(String folderPath) { private String getAppPath() { return getJarPath().replaceAll(".jar$", ".exe"); } + + private static String getStartupDirectory() { + if (System.getenv("programdata") == null) { + // XP + return System.getenv("allusersprofile") + "\\Start Menu\\Programs\\Startup\\"; + } + return System.getenv("programdata") + "\\Microsoft\\Windows\\Start Menu\\Programs\\Startup\\"; + } } diff --git a/src/qz/utils/FileUtilities.java b/src/qz/utils/FileUtilities.java index ca6d5d7fe..1c2bb4bcd 100644 --- a/src/qz/utils/FileUtilities.java +++ b/src/qz/utils/FileUtilities.java @@ -96,6 +96,25 @@ public static boolean isBadPath(String path) { return path.contains(SystemUtilities.getDataDirectory()); } + public static boolean isSymlink(String filePath) { + log.info("Verifying symbolic link: {}", filePath); + boolean returnVal = false; + if (filePath != null) { + File f = new File(filePath); + if (f.exists()) { + try { + File canonicalFile = (f.getParent() == null? f:f.getParentFile().getCanonicalFile()); + returnVal = !canonicalFile.getCanonicalFile().equals(canonicalFile.getAbsoluteFile()); + } + catch(IOException ex) { + log.error("IOException checking for symlink", ex); + } + } + } + + log.info("Symbolic link result: {}", returnVal); + return returnVal; + } public static String readLocalFile(String file) throws IOException { return new String(readFile(new DataInputStream(new FileInputStream(file))), Charsets.UTF_8);