Skip to content

Commit b369dc1

Browse files
committed
Merge master into ivy
2 parents 89a7b80 + e03b8c0 commit b369dc1

12 files changed

Lines changed: 231 additions & 52 deletions

File tree

ant/windows/installer.xml

Lines changed: 73 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,79 @@
66
<import file="${basedir}/ant/signing.xml"/>
77
<property environment="env"/>
88

9-
<target name="build-exe" depends="get-version,platform-detect">
9+
<target name="copy-nsis-plugins" depends="find-nsisbin">
10+
<property name="plugins.path" value="${out.dir}/nsis/Plugins"/>
11+
<mkdir dir="${plugins.path}"/>
12+
13+
<!--
14+
========================
15+
Project-specific Plugins
16+
========================
17+
-->
18+
<echo message="Copying NSIS project-specific Plugins: ant/windows/nsis/Plugins"/>
19+
<copy todir="${plugins.path}" verbose="true">
20+
<fileset dir="ant/windows/nsis/Plugins">
21+
<include name="**/*.dll"/>
22+
<include name="**/*.exe"/>
23+
</fileset>
24+
</copy>
25+
26+
<!--
27+
===================
28+
System-wide Plugins
29+
===================
30+
-->
31+
<!-- Call makensis -HDRINFO to get environment details -->
32+
<exec executable="${nsisbin}" outputproperty="nsisbin.output">
33+
<arg value="-HDRINFO"/>
34+
</exec>
35+
36+
<!-- Extract "NSISDIR" -->
37+
<loadresource property="nsisdir.path">
38+
<propertyresource name="nsisbin.output"/>
39+
<filterchain>
40+
<linecontainsregexp>
41+
<regexp pattern="NSISDIR="/>
42+
</linecontainsregexp>
43+
<replaceregex pattern=".*NSISDIR=([^,]+).*" replace="\1" flags="s"/>
44+
<striplinebreaks/>
45+
</filterchain>
46+
</loadresource>
47+
<property name="nsisdir.path" value="error occurred" description="fallback value"/>
48+
49+
<!-- Merge system-wide "x86-unicode" files directly into "Release_Unicode" -->
50+
<echo message="Copying NSIS system-wide Plugins: ${nsisdir.path}/Plugins"/>
51+
<copy todir="${plugins.path}/Release_Unicode" verbose="true" overwrite="false">
52+
<fileset dir="${nsisdir.path}/Plugins">
53+
<include name="**/*-unicode/*.*"/>
54+
</fileset>
55+
<mapper type="flatten"/>
56+
</copy>
57+
58+
<!-- Merge system-wide "x86-ansi" files directly into "Release_ANSI" -->
59+
<copy todir="${plugins.path}/Release_ANSI" verbose="true" overwrite="false">
60+
<fileset dir="${nsisdir.path}/Plugins">
61+
<include name="**/*-ansi/*.*"/>
62+
</fileset>
63+
<mapper type="flatten"/>
64+
</copy>
65+
</target>
66+
67+
<target name="sign-nsis-plugins" depends="copy-nsis-plugins">
68+
<!-- Sign Plugins before NSIS bundles them -->
69+
<fileset dir="${plugins.path}" id="plugins.dlls">
70+
<include name="**/*.dll"/>
71+
<include name="**/*.exe"/>
72+
</fileset>
73+
74+
<!-- Pass all files at once, wrapped in quotes -->
75+
<pathconvert pathsep="&quot; &quot;" property="plugins.dlls.separated" refid="plugins.dlls"/>
76+
<antcall target="sign-file">
77+
<param name="sign.file" value="&quot;${plugins.dlls.separated}&quot;"/>
78+
</antcall>
79+
</target>
80+
81+
<target name="build-exe" depends="get-version,platform-detect,sign-nsis-plugins">
1082
<!-- Get the os-preferred name for the target architecture -->
1183
<condition property="windows.target.arch" value="arm64">
1284
<isset property="target.arch.aarch64"/>

ant/windows/windows-installer.nsi.in

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@
55
!include LogicLib.nsh
66

77
!ifdef NSIS_UNICODE
8-
!addplugindir "${basedir}/ant/windows/nsis/Plugins/Release_Unicode"
8+
!addplugindir "${plugins.path}/Release_Unicode"
99
!else
10-
!addplugindir "${basedir}/ant/windows/nsis/Plugins/Release_ANSI"
10+
!addplugindir "${plugins.path}/Release_ANSI"
1111
!endif
1212
!addincludedir "${basedir}/ant/windows/nsis/Include"
1313
!include FindJava.nsh

ant/windows/windows-launcher.nsi.in

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22
!include LogicLib.nsh
33

44
!ifdef NSIS_UNICODE
5-
!addplugindir "${basedir}/ant/windows/nsis/Plugins/Release_Unicode"
5+
!addplugindir "${plugins.path}/Release_Unicode"
66
!else
7-
!addplugindir "${basedir}/ant/windows/nsis/Plugins/Release_ANSI"
7+
!addplugindir "${plugins.path}/Release_ANSI"
88
!endif
99
!addincludedir "${basedir}/ant/windows/nsis/Include"
1010
!include StdUtils.nsh

ant/windows/windows-uninstaller.nsi.in

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@
77
!include WinMessages.nsh
88

99
!ifdef NSIS_UNICODE
10-
!addplugindir "${basedir}/ant/windows/nsis/Plugins/Release_Unicode"
10+
!addplugindir "${plugins.path}/Release_Unicode"
1111
!else
12-
!addplugindir "${basedir}/ant/windows/nsis/Plugins/Release_ANSI"
12+
!addplugindir "${plugins.path}/Release_ANSI"
1313
!endif
1414
!addincludedir "${basedir}/ant/windows/nsis/Include"
1515
!include StdUtils.nsh

js/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "qz-tray",
3-
"version": "2.2.6-SNAPSHOT",
3+
"version": "2.2.6",
44
"description": "Connects a web client to the QZ Tray software. Enables printing and device communication from javascript. ",
55
"main": "qz-tray.js",
66
"browser": {

js/qz-tray.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
'use strict';
22

33
/**
4-
* @version 2.2.6-SNAPSHOT
4+
* @version 2.2.6
55
* @overview QZ Tray Connector
66
* @license LGPL-2.1-only
77
* <p/>
@@ -53,7 +53,7 @@ var qz = (function() {
5353

5454
var _qz = {
5555
TITLE: "QZ Tray",
56-
VERSION: "2.2.6-SNAPSHOT", //must match @version above
56+
VERSION: "2.2.6", //must match @version above
5757
DEBUG: false,
5858

5959
log: {

sample.html

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2879,6 +2879,13 @@ <h4 class="panel-title">Options</h4>
28792879
}
28802880
});
28812881

2882+
$("#connectionHost").on('keyup', function(e) {
2883+
if (e.which == 13 || e.keyCode == 13) {
2884+
startConnection();
2885+
return false;
2886+
}
2887+
});
2888+
28822889
$("#fileButton").on('change', function(e) {
28832890
if (this.files && this.files[0]) {
28842891
$("#fileLocation").val(this.files[0]['name']);

src/qz/common/Constants.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ public class Constants {
1414
public static final String HEXES = "0123456789ABCDEF";
1515
public static final char[] HEXES_ARRAY = HEXES.toCharArray();
1616
public static final int BYTE_BUFFER_SIZE = 8192;
17-
public static final Version VERSION = Version.valueOf("2.3.0-SNAPSHOT");
17+
public static final Version VERSION = Version.valueOf("2.2.6");
1818
public static final Version JAVA_VERSION = SystemUtilities.getJavaVersion();
1919
public static final String JAVA_VENDOR = System.getProperty("java.vendor");
2020

src/qz/installer/TaskKiller.java

Lines changed: 3 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,7 @@ public static boolean killAll() {
5050
// Fallback to pgrep, needed for macOS (See JDK-8319589, JDK-8197387)
5151
pids.addAll(findPidsPgrep());
5252
} else {
53-
// Fallback to powershell, needed for Windows, see #1360
54-
pids.addAll(findPidsPwsh());
53+
pids.addAll(WindowsUtilities.findPids(new String[] { "java.exe", "javaw.exe" }, JAR_NAMES));
5554
}
5655

5756
// Careful not to kill ourselves ;)
@@ -84,41 +83,6 @@ private static Path getJcmdPath() throws IOException {
8483
return jcmd;
8584
}
8685

87-
88-
static final String[] PWSH_QUERY = { "powershell.exe", "-Command", "\"(Get-CimInstance Win32_Process -Filter \\\"Name = 'java.exe' OR Name = 'javaw.exe'\\\").Where({$_.CommandLine -like '*%s*'}).ProcessId\"" };
89-
90-
/**
91-
* Leverage powershell.exe when run as SYSTEM to workaround https://github.com/qzind/tray/issues/1360
92-
* TODO: Remove when jcmd is patched to work as SYSTEM account
93-
*/
94-
private static HashSet<Integer> findPidsPwsh() {
95-
HashSet<Integer> foundPids = new HashSet<>();
96-
97-
for(String jarName : JAR_NAMES) {
98-
String[] pwshQuery = PWSH_QUERY.clone();
99-
int lastIndex = pwshQuery.length - 1;
100-
// Format the last element to contain the jarName
101-
pwshQuery[lastIndex] = String.format(pwshQuery[lastIndex], jarName);
102-
String stdout = ShellUtilities.executeRaw(pwshQuery);
103-
String[] lines = stdout.split("\\s*\\r?\\n");
104-
for(String line : lines) {
105-
if(line.trim().isEmpty()) {
106-
// Don't try to process blank lines
107-
continue;
108-
}
109-
110-
int pid = parsePid(line);
111-
if (pid >= 0) {
112-
foundPids.add(pid);
113-
} else {
114-
log.warn("Could not parse PID value. Full line: '{}', Full output: '{}'", line, stdout);
115-
}
116-
}
117-
}
118-
119-
return foundPids;
120-
}
121-
12286
/**
12387
* Use pgrep to fetch all PIDs to workaround https://github.com/openjdk/jdk/pull/25824
12488
* TODO: Remove when jcmd is patched to work properly on macOS
@@ -207,7 +171,7 @@ private static String parseArgs(String[] input) {
207171
}
208172

209173
// Parses an int value form the first index of a String[], returning -1 if something went wrong
210-
private static int parsePid(String[] input) {
174+
public static int parsePid(String[] input) {
211175
if(input != null) {
212176
if(input.length == 2) {
213177
return parsePid(input[0]);
@@ -217,7 +181,7 @@ private static int parsePid(String[] input) {
217181
}
218182

219183
// Parses an int value form the provided string, returning -1 if something went wrong
220-
private static int parsePid(String input) {
184+
public static int parsePid(String input) {
221185
String pidString = input.trim();
222186
if(StringUtils.isNumeric(pidString)) {
223187
return Integer.parseInt(pidString);

src/qz/printer/PrintOptions.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,10 @@ public PrintOptions(JSONObject configOpts, PrintOutput output, PrintingUtilities
6262
rawOptions.destEncoding = Charset.forName(encodings.optString("to", Charset.defaultCharset().name()));
6363
} else {
6464
// String form, that means it is destination-encoded only
65-
rawOptions.destEncoding = Charset.forName(configOpts.optString("encoding", Charset.defaultCharset().name()));
65+
String encoding = configOpts.optString("encoding", Charset.defaultCharset().name());
66+
if(!encoding.isBlank()) {
67+
rawOptions.destEncoding = Charset.forName(encoding);
68+
}
6669
}
6770
}
6871
if (!configOpts.isNull("spool")) {

0 commit comments

Comments
 (0)