From b8267709e382e8de17b0c17702a05c3a6006a60d Mon Sep 17 00:00:00 2001 From: Berenz Date: Wed, 26 Apr 2017 17:23:29 -0400 Subject: [PATCH] Adjustments for changes not caught during rebase --- src/qz/printer/action/PrintPDF.java | 4 ++-- src/qz/utils/ConnectionUtilities.java | 2 +- src/qz/utils/NetworkUtilities.java | 14 ++++++++----- src/qz/utils/SemVer.java | 30 --------------------------- 4 files changed, 12 insertions(+), 38 deletions(-) delete mode 100644 src/qz/utils/SemVer.java diff --git a/src/qz/printer/action/PrintPDF.java b/src/qz/printer/action/PrintPDF.java index ebb48d91e..4cd32cda4 100644 --- a/src/qz/printer/action/PrintPDF.java +++ b/src/qz/printer/action/PrintPDF.java @@ -102,13 +102,13 @@ public void parseData(JSONArray printData, PrintOptions options) throws JSONExce } @Override - public PrintRequestAttributeSet applyDefaultSettings(PrintOptions.Pixel pxlOpts, PageFormat page) { + public PrintRequestAttributeSet applyDefaultSettings(PrintOptions.Pixel pxlOpts, PageFormat page, Media[] supported) { if (pxlOpts.getOrientation() != null) { //page orient does not set properly on pdfs with orientation requested attribute page.setOrientation(pxlOpts.getOrientation().getAsOrientFormat()); } - return super.applyDefaultSettings(pxlOpts, page); + return super.applyDefaultSettings(pxlOpts, page, supported); } @Override diff --git a/src/qz/utils/ConnectionUtilities.java b/src/qz/utils/ConnectionUtilities.java index 27342efd9..1372275d8 100644 --- a/src/qz/utils/ConnectionUtilities.java +++ b/src/qz/utils/ConnectionUtilities.java @@ -44,7 +44,7 @@ private static String getUserAgent() { getOS(), getArch(), Constants.ABOUT_TITLE.replaceAll("[^a-zA-Z]", ""), - Constants.VERSION.MAJOR_MINOR, + Constants.VERSION.getNormalVersion(), System.getProperty("java.vm.specification.version") ); log.debug("User agent string for URL requests: {}", userAgent); diff --git a/src/qz/utils/NetworkUtilities.java b/src/qz/utils/NetworkUtilities.java index 67c8343cd..a235ecd04 100644 --- a/src/qz/utils/NetworkUtilities.java +++ b/src/qz/utils/NetworkUtilities.java @@ -30,11 +30,11 @@ public class NetworkUtilities { private static NetworkUtilities instance; private ArrayList devices; - private Device primary; + private Device primaryDevice; private NetworkUtilities(String hostname, int port) { - try { primary = new Device(getPrimaryInetAddress(hostname, port), true); } + try { primaryDevice = new Device(getPrimaryInetAddress(hostname, port), true); } catch(SocketException ignore) {} } @@ -62,7 +62,7 @@ public static JSONArray getDevicesJSON(String hostname, int port) throws JSONExc } public static JSONObject getDeviceJSON(String hostname, int port) throws JSONException { - Device primary = getInstance(hostname, port).primary; + Device primary = getInstance(hostname, port).primaryDevice; if (primary != null) { return primary.toJSON(); @@ -78,7 +78,11 @@ private ArrayList gatherDevices() throws SocketException { Enumeration interfaces = NetworkInterface.getNetworkInterfaces(); while(interfaces.hasMoreElements()) { NetworkInterface iface = interfaces.nextElement(); - devices.add(new Device(iface)); + + Device next = new Device(iface); + next.primary = next.equals(primaryDevice); + + devices.add(next); } } @@ -88,7 +92,7 @@ private ArrayList gatherDevices() throws SocketException { private static InetAddress getPrimaryInetAddress(String hostname, int port) { log.info("Initiating a temporary connection to \"{}:{}\" to determine main Network Interface", hostname, port); - try (Socket socket = new Socket()) { + try(Socket socket = new Socket()) { socket.connect(new InetSocketAddress(hostname, port)); return socket.getLocalAddress(); diff --git a/src/qz/utils/SemVer.java b/src/qz/utils/SemVer.java deleted file mode 100644 index 37b5acd09..000000000 --- a/src/qz/utils/SemVer.java +++ /dev/null @@ -1,30 +0,0 @@ -package qz.utils; - -import org.apache.commons.lang3.ArrayUtils; -import org.apache.commons.lang3.StringUtils; - -public class SemVer { - public String MAJOR; - public String MINOR; - public String PATCH; - public String PRE; - public String FULL; - public String MAJOR_MINOR; - - public SemVer(String version) { - String[] parts = StringUtils.split(version, "."); - String[] pre = StringUtils.split(version, "-"); - FULL = version; - MAJOR = parts.length > 0 ? parts[0] : ""; - MINOR = parts.length > 1 ? parts[1] : ""; - PATCH = parts.length > 2 ? parts[2] : ""; - PRE = pre.length > 1 ? pre[1] : StringUtils.join(ArrayUtils.subarray(parts, 3, parts.length - 1), "."); - MAJOR_MINOR = MAJOR + "." + MINOR; - } - - @Override - public String toString() { - return FULL; - } - -}