Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/ikvm-fork.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/awt
diff options
context:
space:
mode:
authorsmallsql <smallsql>2010-12-15 17:53:33 +0300
committersmallsql <smallsql>2010-12-15 17:53:33 +0300
commit8270a2d62e35751aaba2f73c10816cf3865c262a (patch)
tree7212a9be5b16334ef8d3689d093bb078bbbe6f07 /awt
parent46be1e2aa9af6a9b5ff19f3ee95adba015e14b3a (diff)
Some fixes on the printing API from Karsten Heinrich
Diffstat (limited to 'awt')
-rw-r--r--awt/printing.cs114
1 files changed, 109 insertions, 5 deletions
diff --git a/awt/printing.cs b/awt/printing.cs
index 7d5983ec..1cce4826 100644
--- a/awt/printing.cs
+++ b/awt/printing.cs
@@ -1,5 +1,6 @@
/*
Copyright (C) 2009 Volker Berlin (i-net software)
+ Copyright (C) 2010 Karsten Heinrich (i-net software)
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages
@@ -115,12 +116,31 @@ namespace ikvm.awt.printing
private const int ERROR_INSUFFICIENT_BUFFER = 122;
- private const int PRINTER_STATUS_DOOR_OPEN = 0x400000;
- private const int PRINTER_STATUS_ERROR = 0x2;
- private const int PRINTER_STATUS_NO_TONER = 0x40000;
- private const int PRINTER_STATUS_OFFLINE = 0x80;
- private const int PRINTER_STATUS_OUT_OF_MEMORY = 0x200000;
+ private const int PRINTER_STATUS_PAUSED = 0x1;
+ private const int PRINTER_STATUS_ERROR = 0x2; // MSDN says that this value is not used
+ private const int PRINTER_STATUS_PENDING_DELETION = 0x4;
+ private const int PRINTER_STATUS_PAPER_JAM = 0x8;
+ private const int PRINTER_STATUS_PAPER_OUT = 0x10;
+ private const int PRINTER_STATUS_MANUAL_FEED = 0x20;
+ private const int PRINTER_STATUS_PAPER_PROBLEM = 0x40;
+ private const int PRINTER_STATUS_OFFLINE = 0x80;
+ private const int PRINTER_STATUS_IO_ACTIVE = 0x100;
+ private const int PRINTER_STATUS_BUSY = 0x200;
+ private const int PRINTER_STATUS_PRINTING = 0x400;
+ private const int PRINTER_STATUS_OUTPUT_BIN_FULL = 0x800;
+ private const int PRINTER_STATUS_NOT_AVAILABLE = 0x1000;
+ private const int PRINTER_STATUS_WAITING = 0x2000;
+ private const int PRINTER_STATUS_PROCESSING = 0x4000;
+ private const int PRINTER_STATUS_INITIALIZING = 0x8000;
+ private const int PRINTER_STATUS_WARMING_UP = 0x10000;
+ private const int PRINTER_STATUS_TONER_LOW = 0x20000;
+ private const int PRINTER_STATUS_NO_TONER = 0x40000;
+ private const int PRINTER_STATUS_PAGE_PUNT = 0x80000;
private const int PRINTER_STATUS_USER_INTERVENTION = 0x100000;
+ private const int PRINTER_STATUS_OUT_OF_MEMORY = 0x200000;
+ private const int PRINTER_STATUS_DOOR_OPEN = 0x400000;
+ private const int PRINTER_STATUS_SERVER_UNKNOWN = 0x800000;
+ private const int PRINTER_STATUS_POWER_SAVE = 0x1000000;
/// <summary>
/// Get a printer status
@@ -134,6 +154,27 @@ namespace ikvm.awt.printing
int status;
if (GetPrinterInfo2(printerName, out cJobs, out status))
{
+ if (category == (java.lang.Class)typeof(javax.print.attribute.standard.PrinterState))
+ {
+ if ((status &
+ (PRINTER_STATUS_ERROR | PRINTER_STATUS_NO_TONER | PRINTER_STATUS_OUT_OF_MEMORY |
+ PRINTER_STATUS_OFFLINE | PRINTER_STATUS_USER_INTERVENTION |
+ PRINTER_STATUS_DOOR_OPEN | PRINTER_STATUS_NOT_AVAILABLE )) > 0)
+ {
+ return javax.print.attribute.standard.PrinterState.STOPPED;
+ }
+ if( (status & (PRINTER_STATUS_BUSY | PRINTER_STATUS_PRINTING ))> 0 )
+ {
+ return javax.print.attribute.standard.PrinterState.PROCESSING;
+ }
+ return null;
+ // null seems to be the default instead of unknown - UNKOWN ist not used in the reference RT
+ // javax.print.attribute.standard.PrinterState.UNKNOWN;
+ }
+ if (category == (java.lang.Class)typeof(javax.print.attribute.standard.PrinterStateReasons))
+ {
+ return extractResions(status);
+ }
if (category == (java.lang.Class)typeof(javax.print.attribute.standard.QueuedJobCount))
{
return new javax.print.attribute.standard.QueuedJobCount(cJobs);
@@ -159,6 +200,65 @@ namespace ikvm.awt.printing
return null;
}
+ private javax.print.attribute.standard.PrinterStateReasons extractResions(int status)
+ {
+ javax.print.attribute.standard.PrinterStateReasons reasons = new javax.print.attribute.standard.PrinterStateReasons();
+ if ((status & PRINTER_STATUS_PAUSED) > 0)
+ {
+ reasons.put(javax.print.attribute.standard.PrinterStateReason.PAUSED, javax.print.attribute.standard.Severity.REPORT);
+ }
+ if ((status & PRINTER_STATUS_ERROR) > 0)
+ {
+ reasons.put(javax.print.attribute.standard.PrinterStateReason.OTHER, javax.print.attribute.standard.Severity.ERROR);
+ }
+ if ((status & PRINTER_STATUS_PENDING_DELETION) > 0) { }
+ if ((status & PRINTER_STATUS_PAPER_JAM) > 0)
+ {
+ reasons.put(javax.print.attribute.standard.PrinterStateReason.MEDIA_JAM, javax.print.attribute.standard.Severity.WARNING);
+ }
+ if ((status & PRINTER_STATUS_PAPER_OUT) > 0)
+ {
+ reasons.put(javax.print.attribute.standard.PrinterStateReason.MEDIA_EMPTY, javax.print.attribute.standard.Severity.WARNING);
+ }
+ if ((status & PRINTER_STATUS_MANUAL_FEED) > 0) { }
+ if ((status & PRINTER_STATUS_PAPER_PROBLEM) > 0) {}
+ if ((status & PRINTER_STATUS_OFFLINE) > 0) {
+ reasons.put(javax.print.attribute.standard.PrinterStateReason.TIMED_OUT, javax.print.attribute.standard.Severity.ERROR);
+ }
+ if ((status & PRINTER_STATUS_IO_ACTIVE) > 0) { }
+ if ((status & PRINTER_STATUS_BUSY) > 0) { }
+ if ((status & PRINTER_STATUS_PRINTING) > 0) { }
+ if ((status & PRINTER_STATUS_OUTPUT_BIN_FULL) > 0) {
+ reasons.put(javax.print.attribute.standard.PrinterStateReason.OUTPUT_AREA_FULL, javax.print.attribute.standard.Severity.WARNING);
+ }
+ if ((status & PRINTER_STATUS_NOT_AVAILABLE) > 0) { }
+ if ((status & PRINTER_STATUS_WAITING) > 0) { }
+ if ((status & PRINTER_STATUS_PROCESSING) > 0) { }
+ if ((status & PRINTER_STATUS_INITIALIZING) > 0) { }
+ if ((status & PRINTER_STATUS_WARMING_UP) > 0) { }
+ if ((status & PRINTER_STATUS_TONER_LOW) > 0) {
+ reasons.put(javax.print.attribute.standard.PrinterStateReason.TONER_LOW, javax.print.attribute.standard.Severity.WARNING);
+ }
+ if ((status & PRINTER_STATUS_NO_TONER) > 0) {
+ reasons.put(javax.print.attribute.standard.PrinterStateReason.TONER_EMPTY, javax.print.attribute.standard.Severity.ERROR);
+ }
+ if ((status & PRINTER_STATUS_PAGE_PUNT) > 0) { }
+ if ((status & PRINTER_STATUS_USER_INTERVENTION) > 0) {
+ reasons.put(javax.print.attribute.standard.PrinterStateReason.OTHER, javax.print.attribute.standard.Severity.ERROR);
+ }
+ if ((status & PRINTER_STATUS_OUT_OF_MEMORY) > 0) {
+ reasons.put(javax.print.attribute.standard.PrinterStateReason.OTHER, javax.print.attribute.standard.Severity.ERROR);
+ }
+ if ((status & PRINTER_STATUS_DOOR_OPEN) > 0) {
+ reasons.put(javax.print.attribute.standard.PrinterStateReason.DOOR_OPEN, javax.print.attribute.standard.Severity.ERROR);
+ }
+ if ((status & PRINTER_STATUS_SERVER_UNKNOWN) > 0) { }
+ if ((status & PRINTER_STATUS_POWER_SAVE) > 0) {
+ reasons.put(javax.print.attribute.standard.PrinterStateReason.PAUSED, javax.print.attribute.standard.Severity.REPORT);
+ }
+ return reasons.isEmpty() ? null : reasons;
+ }
+
/// <summary>
/// Get infos from the PRINTER_INFO_2 struc
/// </summary>
@@ -228,4 +328,8 @@ namespace ikvm.awt.printing
return ClosePrinter(handle);
}
}
+
+ class Win32Print
+ {
+ }
}