From ad3010861da1134b3efc2c9e19132e9dc9dd4a62 Mon Sep 17 00:00:00 2001 From: IvanRF Date: Sat, 23 Jan 2016 20:13:40 -0300 Subject: [PATCH] Added printer attributes and status --- CHANGES.md | 1 + .../com/sun/jna/platform/win32/Winspool.java | 163 ++++++++++++------ .../sun/jna/platform/win32/WinspoolUtil.java | 7 + 3 files changed, 117 insertions(+), 54 deletions(-) diff --git a/CHANGES.md b/CHANGES.md index 8871e13e82..654383a915 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -33,6 +33,7 @@ Features * [#574](https://github.com/java-native-access/jna/pull/574): Using static final un-modifiable List of field names for structure(s) - [@lgoldstein](https://github.com/lgoldstein). * [#577](https://github.com/java-native-access/jna/pull/577): Apply generic definitions wherever applicable - [@lgoldstein](https://github.com/lgoldstein). * [#569](https://github.com/java-native-access/jna/pull/569): Added `com.sun.jna.platform.win32.Winspool.PRINTER_INFO_2` support. Added GetPrinter and ClosePrinter functions in `com.sun.jna.platform.win32.Winspool` - [@IvanRF](https://github.com/IvanRF). +* [#583](https://github.com/java-native-access/jna/pull/583): Added printer attributes and status - [@IvanRF](https://github.com/IvanRF). Bug Fixes --------- diff --git a/contrib/platform/src/com/sun/jna/platform/win32/Winspool.java b/contrib/platform/src/com/sun/jna/platform/win32/Winspool.java index 0acbbb372a..bb929189f6 100644 --- a/contrib/platform/src/com/sun/jna/platform/win32/Winspool.java +++ b/contrib/platform/src/com/sun/jna/platform/win32/Winspool.java @@ -40,60 +40,108 @@ public interface Winspool extends StdCallLibrary { Winspool INSTANCE = Native.loadLibrary("Winspool.drv", Winspool.class, W32APIOptions.DEFAULT_OPTIONS); - int CCHDEVICENAME = 32; - - int PRINTER_CHANGE_ADD_PRINTER = 0x00000001; - int PRINTER_CHANGE_SET_PRINTER = 0x00000002; - int PRINTER_CHANGE_DELETE_PRINTER = 0x00000004; - int PRINTER_CHANGE_FAILED_CONNECTION_PRINTER = 0x00000008; - int PRINTER_CHANGE_PRINTER = 0x000000FF; - int PRINTER_CHANGE_ADD_JOB = 0x00000100; - int PRINTER_CHANGE_SET_JOB = 0x00000200; - int PRINTER_CHANGE_DELETE_JOB = 0x00000400; - int PRINTER_CHANGE_WRITE_JOB = 0x00000800; - int PRINTER_CHANGE_JOB = 0x0000FF00; - int PRINTER_CHANGE_ADD_FORM = 0x00010000; - int PRINTER_CHANGE_SET_FORM = 0x00020000; - int PRINTER_CHANGE_DELETE_FORM = 0x00040000; - int PRINTER_CHANGE_FORM = 0x00070000; - int PRINTER_CHANGE_ADD_PORT = 0x00100000; - int PRINTER_CHANGE_CONFIGURE_PORT = 0x00200000; - int PRINTER_CHANGE_DELETE_PORT = 0x00400000; - int PRINTER_CHANGE_PORT = 0x00700000; - int PRINTER_CHANGE_ADD_PRINT_PROCESSOR = 0x01000000; - int PRINTER_CHANGE_DELETE_PRINT_PROCESSOR = 0x04000000; - int PRINTER_CHANGE_PRINT_PROCESSOR = 0x07000000; - int PRINTER_CHANGE_SERVER = 0x08000000; - int PRINTER_CHANGE_ADD_PRINTER_DRIVER = 0x10000000; - int PRINTER_CHANGE_SET_PRINTER_DRIVER = 0x20000000; - int PRINTER_CHANGE_DELETE_PRINTER_DRIVER = 0x40000000; - int PRINTER_CHANGE_PRINTER_DRIVER = 0x70000000; - int PRINTER_CHANGE_TIMEOUT = 0x80000000; - int PRINTER_CHANGE_ALL_WIN7 = 0x7F77FFFF; - int PRINTER_CHANGE_ALL = 0x7777FFFF; - - int PRINTER_ENUM_DEFAULT = 0x00000001; - int PRINTER_ENUM_LOCAL = 0x00000002; - int PRINTER_ENUM_CONNECTIONS = 0x00000004; - int PRINTER_ENUM_FAVORITE = 0x00000004; - int PRINTER_ENUM_NAME = 0x00000008; - int PRINTER_ENUM_REMOTE = 0x00000010; - int PRINTER_ENUM_SHARED = 0x00000020; - int PRINTER_ENUM_NETWORK = 0x00000040; - - int PRINTER_ENUM_EXPAND = 0x00004000; - int PRINTER_ENUM_CONTAINER = 0x00008000; - - int PRINTER_ENUM_ICONMASK = 0x00ff0000; - int PRINTER_ENUM_ICON1 = 0x00010000; - int PRINTER_ENUM_ICON2 = 0x00020000; - int PRINTER_ENUM_ICON3 = 0x00040000; - int PRINTER_ENUM_ICON4 = 0x00080000; - int PRINTER_ENUM_ICON5 = 0x00100000; - int PRINTER_ENUM_ICON6 = 0x00200000; - int PRINTER_ENUM_ICON7 = 0x00400000; - int PRINTER_ENUM_ICON8 = 0x00800000; - int PRINTER_ENUM_HIDE = 0x01000000; + public static final int CCHDEVICENAME = 32; + + public static final int PRINTER_STATUS_PAUSED = 0x00000001; + public static final int PRINTER_STATUS_ERROR = 0x00000002; + public static final int PRINTER_STATUS_PENDING_DELETION = 0x00000004; + public static final int PRINTER_STATUS_PAPER_JAM = 0x00000008; + public static final int PRINTER_STATUS_PAPER_OUT = 0x00000010; + public static final int PRINTER_STATUS_MANUAL_FEED = 0x00000020; + public static final int PRINTER_STATUS_PAPER_PROBLEM = 0x00000040; + public static final int PRINTER_STATUS_OFFLINE = 0x00000080; + public static final int PRINTER_STATUS_IO_ACTIVE = 0x00000100; + public static final int PRINTER_STATUS_BUSY = 0x00000200; + public static final int PRINTER_STATUS_PRINTING = 0x00000400; + public static final int PRINTER_STATUS_OUTPUT_BIN_FULL = 0x00000800; + public static final int PRINTER_STATUS_NOT_AVAILABLE = 0x00001000; + public static final int PRINTER_STATUS_WAITING = 0x00002000; + public static final int PRINTER_STATUS_PROCESSING = 0x00004000; + public static final int PRINTER_STATUS_INITIALIZING = 0x00008000; + public static final int PRINTER_STATUS_WARMING_UP = 0x00010000; + public static final int PRINTER_STATUS_TONER_LOW = 0x00020000; + public static final int PRINTER_STATUS_NO_TONER = 0x00040000; + public static final int PRINTER_STATUS_PAGE_PUNT = 0x00080000; + public static final int PRINTER_STATUS_USER_INTERVENTION = 0x00100000; + public static final int PRINTER_STATUS_OUT_OF_MEMORY = 0x00200000; + public static final int PRINTER_STATUS_DOOR_OPEN = 0x00400000; + public static final int PRINTER_STATUS_SERVER_UNKNOWN = 0x00800000; + public static final int PRINTER_STATUS_POWER_SAVE = 0x01000000; + + public static final int PRINTER_ATTRIBUTE_QUEUED = 0x00000001; + public static final int PRINTER_ATTRIBUTE_DIRECT = 0x00000002; + public static final int PRINTER_ATTRIBUTE_DEFAULT = 0x00000004; + public static final int PRINTER_ATTRIBUTE_SHARED = 0x00000008; + public static final int PRINTER_ATTRIBUTE_NETWORK = 0x00000010; + public static final int PRINTER_ATTRIBUTE_HIDDEN = 0x00000020; + public static final int PRINTER_ATTRIBUTE_LOCAL = 0x00000040; + public static final int PRINTER_ATTRIBUTE_ENABLE_DEVQ = 0x00000080; + public static final int PRINTER_ATTRIBUTE_KEEPPRINTEDJOBS = 0x00000100; + public static final int PRINTER_ATTRIBUTE_DO_COMPLETE_FIRST = 0x00000200; + public static final int PRINTER_ATTRIBUTE_WORK_OFFLINE = 0x00000400; + public static final int PRINTER_ATTRIBUTE_ENABLE_BIDI = 0x00000800; + public static final int PRINTER_ATTRIBUTE_RAW_ONLY = 0x00001000; + public static final int PRINTER_ATTRIBUTE_PUBLISHED = 0x00002000; + public static final int PRINTER_ATTRIBUTE_FAX = 0x00004000; + public static final int PRINTER_ATTRIBUTE_TS = 0x00008000; + public static final int PRINTER_ATTRIBUTE_PUSHED_USER = 0x00020000; + public static final int PRINTER_ATTRIBUTE_PUSHED_MACHINE = 0x00040000; + public static final int PRINTER_ATTRIBUTE_MACHINE = 0x00080000; + public static final int PRINTER_ATTRIBUTE_FRIENDLY_NAME = 0x00100000; + public static final int PRINTER_ATTRIBUTE_TS_GENERIC_DRIVER = 0x00200000; + + public static final int PRINTER_CHANGE_ADD_PRINTER = 0x00000001; + public static final int PRINTER_CHANGE_SET_PRINTER = 0x00000002; + public static final int PRINTER_CHANGE_DELETE_PRINTER = 0x00000004; + public static final int PRINTER_CHANGE_FAILED_CONNECTION_PRINTER = 0x00000008; + public static final int PRINTER_CHANGE_PRINTER = 0x000000FF; + public static final int PRINTER_CHANGE_ADD_JOB = 0x00000100; + public static final int PRINTER_CHANGE_SET_JOB = 0x00000200; + public static final int PRINTER_CHANGE_DELETE_JOB = 0x00000400; + public static final int PRINTER_CHANGE_WRITE_JOB = 0x00000800; + public static final int PRINTER_CHANGE_JOB = 0x0000FF00; + public static final int PRINTER_CHANGE_ADD_FORM = 0x00010000; + public static final int PRINTER_CHANGE_SET_FORM = 0x00020000; + public static final int PRINTER_CHANGE_DELETE_FORM = 0x00040000; + public static final int PRINTER_CHANGE_FORM = 0x00070000; + public static final int PRINTER_CHANGE_ADD_PORT = 0x00100000; + public static final int PRINTER_CHANGE_CONFIGURE_PORT = 0x00200000; + public static final int PRINTER_CHANGE_DELETE_PORT = 0x00400000; + public static final int PRINTER_CHANGE_PORT = 0x00700000; + public static final int PRINTER_CHANGE_ADD_PRINT_PROCESSOR = 0x01000000; + public static final int PRINTER_CHANGE_DELETE_PRINT_PROCESSOR = 0x04000000; + public static final int PRINTER_CHANGE_PRINT_PROCESSOR = 0x07000000; + public static final int PRINTER_CHANGE_SERVER = 0x08000000; + public static final int PRINTER_CHANGE_ADD_PRINTER_DRIVER = 0x10000000; + public static final int PRINTER_CHANGE_SET_PRINTER_DRIVER = 0x20000000; + public static final int PRINTER_CHANGE_DELETE_PRINTER_DRIVER = 0x40000000; + public static final int PRINTER_CHANGE_PRINTER_DRIVER = 0x70000000; + public static final int PRINTER_CHANGE_TIMEOUT = 0x80000000; + public static final int PRINTER_CHANGE_ALL_WIN7 = 0x7F77FFFF; + public static final int PRINTER_CHANGE_ALL = 0x7777FFFF; + + public static final int PRINTER_ENUM_DEFAULT = 0x00000001; + public static final int PRINTER_ENUM_LOCAL = 0x00000002; + public static final int PRINTER_ENUM_CONNECTIONS = 0x00000004; + public static final int PRINTER_ENUM_FAVORITE = 0x00000004; + public static final int PRINTER_ENUM_NAME = 0x00000008; + public static final int PRINTER_ENUM_REMOTE = 0x00000010; + public static final int PRINTER_ENUM_SHARED = 0x00000020; + public static final int PRINTER_ENUM_NETWORK = 0x00000040; + + public static final int PRINTER_ENUM_EXPAND = 0x00004000; + public static final int PRINTER_ENUM_CONTAINER = 0x00008000; + + public static final int PRINTER_ENUM_ICONMASK = 0x00ff0000; + public static final int PRINTER_ENUM_ICON1 = 0x00010000; + public static final int PRINTER_ENUM_ICON2 = 0x00020000; + public static final int PRINTER_ENUM_ICON3 = 0x00040000; + public static final int PRINTER_ENUM_ICON4 = 0x00080000; + public static final int PRINTER_ENUM_ICON5 = 0x00100000; + public static final int PRINTER_ENUM_ICON6 = 0x00200000; + public static final int PRINTER_ENUM_ICON7 = 0x00400000; + public static final int PRINTER_ENUM_ICON8 = 0x00800000; + public static final int PRINTER_ENUM_HIDE = 0x01000000; /** * The EnumPrinters function enumerates available printers, print servers, @@ -388,6 +436,13 @@ public PRINTER_INFO_2(int size) { protected List getFieldOrder() { return FIELDS; } + + /** + * Checks if the printer attributes have one of the values PRINTER_ATTRIBUTE_XXX. + */ + public boolean hasAttribute(int value) { + return (Attributes & value) == value; + } } /** diff --git a/contrib/platform/src/com/sun/jna/platform/win32/WinspoolUtil.java b/contrib/platform/src/com/sun/jna/platform/win32/WinspoolUtil.java index 15c9876bd6..76bb8466ae 100644 --- a/contrib/platform/src/com/sun/jna/platform/win32/WinspoolUtil.java +++ b/contrib/platform/src/com/sun/jna/platform/win32/WinspoolUtil.java @@ -119,6 +119,13 @@ public static PRINTER_INFO_2 getPrinterInfo2(String printerName) { return pinfo2; } + /** + * Checks if the printer attributes have one of the values PRINTER_ATTRIBUTE_XXX. + */ + public static boolean hasAttribute(PRINTER_INFO_2 printerInfo, int value) { + return printerInfo != null && (printerInfo.Attributes & value) == value; + } + public static PRINTER_INFO_4[] getPrinterInfo4() { IntByReference pcbNeeded = new IntByReference(); IntByReference pcReturned = new IntByReference();