Skip to content

Commit

Permalink
Winspool: Don't guard job deletion calls.
Browse files Browse the repository at this point in the history
Closes #1305
  • Loading branch information
tresf committed Nov 19, 2024
1 parent b3a0e60 commit 6fa6ce6
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/qz/printer/status/job/WmiJobStatusMap.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public enum WmiJobStatusMap implements NativeStatus.NativeMap {
BLOCKED_DEVQ(NativeJobStatus.ABORTED, 0x00000200), // The driver cannot print the job
RESTART(NativeJobStatus.RESTART, 0x00000800), // Job has been restarted
COMPLETE(NativeJobStatus.SENT, 0x00001000), // Windows XP and later: Job is sent to the printer, but the job may not be printed yet
RETAINED(NativeJobStatus.RETAINED, 0x00002000), // Windows Vista and later: Job has been retained in the print queue and cannot be deleted
RETAINED(NativeJobStatus.RETAINED, 0x00002000), // Windows Vista and later: Job has been retained in the print queue and cannot be deleted (Edit: it actually can https://github.com/qzind/tray/issues/1305)
RENDERING_LOCALLY(NativeJobStatus.RENDERING_LOCALLY, 0x00004000), // Job rendering locally on the client
USER_INTERVENTION(NativeJobStatus.USER_INTERVENTION, 0x40000000); // Printer has an error that requires the user to do something

Expand Down
6 changes: 2 additions & 4 deletions src/qz/utils/PrintingUtilities.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
import qz.printer.action.ProcessorFactory;
import qz.printer.info.NativePrinter;
import qz.printer.status.CupsUtils;
import qz.printer.status.job.WmiJobStatusMap;
import qz.ws.PrintSocketClient;

import javax.print.PrintException;
Expand Down Expand Up @@ -277,10 +276,9 @@ private static ArrayList<Integer> getActiveJobIds(NativePrinter printer) {
WinNT.HANDLEByReference phPrinter = getWmiPrinter(printer);
Winspool.JOB_INFO_1[] jobs = WinspoolUtil.getJobInfo1(phPrinter);
ArrayList<Integer> jobIds = new ArrayList<>();
// skip retained jobs and complete jobs
int skipMask = (int)WmiJobStatusMap.RETAINED.getRawCode() | (int)WmiJobStatusMap.PRINTED.getRawCode();
// Blindly add all jobs despite Microsoft's API claiming otherwise
// See also: https://github.com/qzind/tray/issues/1305
for(Winspool.JOB_INFO_1 job : jobs) {
if ((job.Status & skipMask) != 0) continue;
jobIds.add(job.JobId);
}
return jobIds;
Expand Down

0 comments on commit 6fa6ce6

Please sign in to comment.