Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add missing PRINTER_INFO_X structs #1429

Draft
wants to merge 22 commits into
base: master
Choose a base branch
from
Draft
Changes from 1 commit
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Fix compilation
tresf committed Mar 29, 2022
commit 7880ff3dc78dd878d92048db9206994f4c0a8e73
7 changes: 4 additions & 3 deletions contrib/platform/src/com/sun/jna/platform/win32/WinGDI.java
Original file line number Diff line number Diff line change
@@ -28,8 +28,9 @@
import com.sun.jna.Structure;
import com.sun.jna.Structure.FieldOrder;
import com.sun.jna.platform.win32.WinNT.HANDLE;
import com.sun.jna.platform.win32.WinDef.HBITMAP;
import com.sun.jna.platform.win32.WinDef.RECT;
import com.sun.jna.Union;

import static com.sun.jna.platform.win32.WinDef.*;

/**
* Ported from WinGDI.h.
@@ -95,7 +96,7 @@ public DUMMYSTRUCTNAME2() {
public short dmYResolution;
public short dmTTOption;
public short dmCollate;
public byte[] dmFormName = new byte[Winspool2.CCHFORMNAME];
public byte[] dmFormName = new byte[Winspool.CCHFORMNAME];
public WORD dmLogPixels;
public DWORD dmBitsPerPel;
public DWORD dmPelsWidth;
3 changes: 3 additions & 0 deletions contrib/platform/src/com/sun/jna/platform/win32/Winspool.java
Original file line number Diff line number Diff line change
@@ -29,6 +29,7 @@
import com.sun.jna.Structure;
import com.sun.jna.Structure.FieldOrder;
import com.sun.jna.Union;
import com.sun.jna.platform.win32.WinGDI.DEVMODE;
import com.sun.jna.platform.win32.WinBase.SYSTEMTIME;
import com.sun.jna.platform.win32.WinDef.DWORD;
import com.sun.jna.platform.win32.WinDef.DWORDByReference;
@@ -41,6 +42,8 @@
import com.sun.jna.win32.StdCallLibrary;
import com.sun.jna.win32.W32APIOptions;

import static com.sun.jna.platform.win32.WinDef.*;

/**
* Ported from Winspool.h. Windows SDK 6.0a
*
62 changes: 46 additions & 16 deletions contrib/platform/src/com/sun/jna/platform/win32/WinspoolUtil.java
Original file line number Diff line number Diff line change
@@ -25,13 +25,12 @@

import static com.sun.jna.platform.win32.WinError.ERROR_INSUFFICIENT_BUFFER;
import static com.sun.jna.platform.win32.WinError.ERROR_SUCCESS;
import static com.sun.jna.platform.win32.Winspool.*;

import com.sun.jna.platform.win32.WinNT.HANDLEByReference;
import com.sun.jna.platform.win32.Winspool.JOB_INFO_1;
import com.sun.jna.platform.win32.Winspool.PRINTER_INFO_1;
import com.sun.jna.platform.win32.Winspool.PRINTER_INFO_2;
import com.sun.jna.platform.win32.Winspool.PRINTER_INFO_4;
import com.sun.jna.platform.win32.Winspool;
import com.sun.jna.ptr.IntByReference;
import com.sun.jna.Structure;

/**
* Winspool Utility API.
@@ -168,47 +167,78 @@ private static Structure initStructByType(int structType, int size) {
}
}

public static JOB_INFO_1[] getJobInfo1(HANDLEByReference phPrinter) {
IntByReference pcbNeeded = new IntByReference();
IntByReference pcReturned = new IntByReference();
Winspool.INSTANCE.EnumJobs(phPrinter.getValue(), 0, 255, 1, null, 0,
pcbNeeded, pcReturned);
if (pcbNeeded.getValue() <= 0) {
return new JOB_INFO_1[0];
}

int lastError = ERROR_SUCCESS;
JOB_INFO_1 pJobEnum;
do {
pJobEnum = new JOB_INFO_1(pcbNeeded.getValue());
if (!Winspool.INSTANCE.EnumJobs(phPrinter.getValue(), 0, 255, 1,
pJobEnum.getPointer(), pcbNeeded.getValue(), pcbNeeded,
pcReturned)) {
lastError = Kernel32.INSTANCE.GetLastError();
}
} while (lastError == ERROR_INSUFFICIENT_BUFFER);
if (lastError != ERROR_SUCCESS) {
throw new Win32Exception(lastError);
}
if (pcReturned.getValue() <= 0) {
return new JOB_INFO_1[0];
}

pJobEnum.read();

return (JOB_INFO_1[]) pJobEnum.toArray(pcReturned.getValue());
}

public static PRINTER_INFO_1[] getAllPrinterInfo1() {
return getPrinterInfo1(Winspool.PRINTER_ENUM_LOCAL | Winspool.PRINTER_ENUM_CONNECTIONS);
return getPrinterInfo1(PRINTER_ENUM_LOCAL | PRINTER_ENUM_CONNECTIONS);
}

public static PRINTER_INFO_2[] getAllPrinterInfo2() {
return getPrinterInfo2(Winspool.PRINTER_ENUM_LOCAL | Winspool.PRINTER_ENUM_CONNECTIONS);
return getPrinterInfo2(PRINTER_ENUM_LOCAL | PRINTER_ENUM_CONNECTIONS);
}

public static PRINTER_INFO_3[] getAllPrinterInfo3() {
return getPrinterInfo3(Winspool.PRINTER_ENUM_LOCAL | Winspool.PRINTER_ENUM_CONNECTIONS);
return getPrinterInfo3(PRINTER_ENUM_LOCAL | PRINTER_ENUM_CONNECTIONS);
}

public static PRINTER_INFO_4[] getAllPrinterInfo4() {
return getPrinterInfo4(Winspool.PRINTER_ENUM_LOCAL | Winspool.PRINTER_ENUM_CONNECTIONS);
return getPrinterInfo4(PRINTER_ENUM_LOCAL | PRINTER_ENUM_CONNECTIONS);
}

public static PRINTER_INFO_5[] getAllPrinterInfo5() {
return getPrinterInfo5(Winspool.PRINTER_ENUM_LOCAL | Winspool.PRINTER_ENUM_CONNECTIONS);
return getPrinterInfo5(PRINTER_ENUM_LOCAL | PRINTER_ENUM_CONNECTIONS);
}

public static PRINTER_INFO_6[] getAllPrinterInfo6() {
return getPrinterInfo6(Winspool.PRINTER_ENUM_LOCAL | Winspool.PRINTER_ENUM_CONNECTIONS);
return getPrinterInfo6(PRINTER_ENUM_LOCAL | PRINTER_ENUM_CONNECTIONS);
}

public static PRINTER_INFO_7[] getAllPrinterInfo7() {
return getPrinterInfo7(Winspool.PRINTER_ENUM_LOCAL | Winspool.PRINTER_ENUM_CONNECTIONS);
return getPrinterInfo7(PRINTER_ENUM_LOCAL | PRINTER_ENUM_CONNECTIONS);
}

public static PRINTER_INFO_8[] getAllPrinterInfo8() {
return getPrinterInfo8(Winspool.PRINTER_ENUM_LOCAL | Winspool.PRINTER_ENUM_CONNECTIONS);
return getPrinterInfo8(PRINTER_ENUM_LOCAL | PRINTER_ENUM_CONNECTIONS);
}

public static PRINTER_INFO_9[] getAllPrinterInfo9() {
return getPrinterInfo9(Winspool.PRINTER_ENUM_LOCAL | Winspool.PRINTER_ENUM_CONNECTIONS);
return getPrinterInfo9(PRINTER_ENUM_LOCAL | PRINTER_ENUM_CONNECTIONS);
}

/**
* The PRINTER_INFO_1 structure specifies general printer information.
*/
public static PRINTER_INFO_1[] getPrinterInfo1() {
return getPrinterInfo1(Winspool.PRINTER_ENUM_LOCAL);
return getPrinterInfo1(PRINTER_ENUM_LOCAL);
}

/**
@@ -243,7 +273,7 @@ public static PRINTER_INFO_2[] getPrinterInfo2(int flags) {
* The PRINTER_INFO_2 structure specifies general printer information.
*/
public static PRINTER_INFO_2[] getPrinterInfo2() {
return getPrinterInfo2(Winspool.PRINTER_ENUM_LOCAL);
return getPrinterInfo2(PRINTER_ENUM_LOCAL);
}

/**
@@ -264,7 +294,7 @@ public static PRINTER_INFO_3[] getPrinterInfo3(int flags) {
* The PRINTER_INFO_3 structure specifies printer security information.
*/
public static PRINTER_INFO_3[] getPrinterInfo3() {
return getPrinterInfo3(Winspool.PRINTER_ENUM_LOCAL);
return getPrinterInfo3(PRINTER_ENUM_LOCAL);
}

/**