]>
Commit | Line | Data |
---|---|---|
ef416fc2 | 1 | package com.easysw.cups; |
2 | ||
3 | /** | |
4 | * @version 1.00 06-NOV-2002 | |
bc44d920 | 5 | * @author Apple Inc. |
ef416fc2 | 6 | * |
7 | * Internet Printing Protocol definitions for the Common UNIX Printing | |
8 | * System (CUPS). | |
9 | * | |
bc44d920 | 10 | * Copyright 2007 by Apple Inc. |
ef416fc2 | 11 | * Copyright 1997-2002 by Easy Software Products. |
12 | * | |
13 | * These coded instructions, statements, and computer programs are the | |
bc44d920 | 14 | * property of Apple Inc. and are protected by Federal copyright |
15 | * law. Distribution and use rights are outlined in the file "LICENSE.txt" | |
16 | * which should have been included with this file. If this file is | |
17 | * file is missing or damaged, see the license at "http://www.cups.org/". | |
ef416fc2 | 18 | */ |
19 | ||
20 | ||
21 | /** | |
22 | * A <code>CupsJob</code> object holds job data, and has methods to | |
23 | * process cups job list responses into a usable form. | |
24 | * | |
25 | * @author TDB | |
26 | * @version 1.0 | |
27 | * @since JDK1.3 | |
28 | */ | |
29 | ||
30 | // | |
31 | import java.io.*; | |
32 | import java.net.*; | |
33 | ||
34 | public class CupsJob | |
35 | { | |
36 | public int job_id; | |
37 | public String job_more_info; | |
38 | public String job_uri; | |
39 | public String job_printer_uri; | |
40 | public long job_printer_up_time; | |
41 | public String job_name; | |
42 | public String job_originating_user_name; | |
43 | public String document_format; | |
44 | public String job_originating_host_name; | |
45 | public int job_priority; | |
46 | public int job_state; | |
47 | public int job_media_sheets_completed; | |
48 | public int job_k_octets; | |
49 | public long time_at_creation; | |
50 | public long time_at_processing; | |
51 | public long time_at_completed; | |
52 | public String job_hold_until; | |
53 | public String job_sheets; | |
54 | public String job_state_reasons; | |
55 | ||
56 | ||
57 | /** | |
58 | * Constructor - set some default values. | |
59 | */ | |
60 | public CupsJob() | |
61 | { | |
62 | job_id = -1; | |
63 | job_more_info = ""; | |
64 | job_uri = ""; | |
65 | job_printer_uri = ""; | |
66 | job_printer_up_time = 0; | |
67 | job_name = ""; | |
68 | job_originating_user_name = ""; | |
69 | document_format = ""; | |
70 | job_originating_host_name = ""; | |
71 | job_priority = -1; | |
72 | job_state = 0; | |
73 | job_media_sheets_completed = 0; | |
74 | job_k_octets = 0; | |
75 | time_at_creation = 0; | |
76 | time_at_processing = 0; | |
77 | time_at_completed = 0; | |
78 | job_hold_until = ""; | |
79 | job_sheets = ""; | |
80 | job_state_reasons = ""; | |
81 | } | |
82 | ||
83 | ||
84 | ||
85 | ||
86 | /** | |
87 | * Process an attribute from a cups.doRequest() call | |
88 | * and move the value into a local member. | |
89 | * | |
90 | * @see <code>IPPDefs</code> | |
91 | * @see <code>IPPValues</code> | |
92 | * @see <code>IPPAttributes</code> | |
93 | */ | |
94 | public void updateAttribute( IPPAttribute a ) | |
95 | { | |
96 | IPPValue val; | |
97 | ||
98 | // | |
99 | // Kick out if no values are present. | |
100 | // | |
101 | if (a.values.size() < 1) | |
102 | return; | |
103 | ||
104 | val = (IPPValue)a.values.get(0); | |
105 | if (a.name.compareTo("job-more-info") == 0) | |
106 | { | |
107 | job_more_info = val.text; | |
108 | } | |
109 | else if (a.name.compareTo("job-uri") == 0) | |
110 | { | |
111 | job_uri = val.text; | |
112 | } | |
113 | else if (a.name.compareTo("job-printer-up-time") == 0) | |
114 | { | |
115 | job_printer_up_time = val.integer_value; | |
116 | } | |
117 | else if (a.name.compareTo("job-originating-user-name") == 0) | |
118 | { | |
119 | job_originating_user_name = val.text; | |
120 | } | |
121 | else if (a.name.compareTo("document-format") == 0) | |
122 | { | |
123 | document_format = val.text; | |
124 | } | |
125 | else if (a.name.compareTo("job-priority") == 0) | |
126 | { | |
127 | job_priority = val.integer_value; | |
128 | } | |
129 | else if (a.name.compareTo("job-originating-host-name") == 0) | |
130 | { | |
131 | job_originating_host_name = val.text; | |
132 | } | |
133 | else if (a.name.compareTo("job-id") == 0) | |
134 | { | |
135 | job_id = val.integer_value; | |
136 | } | |
137 | else if (a.name.compareTo("job-state") == 0) | |
138 | { | |
139 | job_state = val.integer_value; | |
140 | } | |
141 | else if (a.name.compareTo("job-media-sheets-completed") == 0) | |
142 | { | |
143 | job_media_sheets_completed = val.integer_value; | |
144 | } | |
145 | else if (a.name.compareTo("job-printer-uri") == 0) | |
146 | { | |
147 | job_printer_uri = val.text; | |
148 | } | |
149 | else if (a.name.compareTo("job-name") == 0) | |
150 | { | |
151 | job_name = val.text; | |
152 | } | |
153 | else if (a.name.compareTo("job-k-octets") == 0) | |
154 | { | |
155 | job_k_octets = val.integer_value; | |
156 | } | |
157 | else if (a.name.compareTo("time-at-creation") == 0) | |
158 | { | |
159 | time_at_creation = val.integer_value; | |
160 | } | |
161 | else if (a.name.compareTo("time-at-processing") == 0) | |
162 | { | |
163 | time_at_processing = val.integer_value; | |
164 | } | |
165 | else if (a.name.compareTo("time-at-completed") == 0) | |
166 | { | |
167 | time_at_completed = val.integer_value; | |
168 | } | |
169 | else if (a.name.compareTo("job-hold-until") == 0) | |
170 | { | |
171 | job_hold_until = val.text; | |
172 | } | |
173 | else if (a.name.compareTo("job-sheets") == 0) | |
174 | { | |
175 | job_sheets = val.text; | |
176 | } | |
177 | else if (a.name.compareTo("job-state-reasons") == 0) | |
178 | { | |
179 | job_state_reasons = val.text; | |
180 | } | |
181 | } | |
182 | ||
183 | ||
184 | /** | |
185 | * Convert a job status to a string. | |
186 | * | |
187 | * @see <code>IPPDefs</code> | |
188 | */ | |
189 | public String jobStatusText() | |
190 | { | |
191 | switch( job_state ) | |
192 | { | |
193 | case 3: return("Pending"); | |
194 | case 4: return("Held"); | |
195 | case 5: return("Processing"); | |
196 | case 6: return("Stopped"); | |
197 | case 7: return("Cancelled"); | |
198 | case 8: return("Aborted"); | |
199 | case 9: return("Completed"); | |
200 | } | |
201 | return("Unknown"); | |
202 | } | |
203 | ||
204 | ||
205 | } | |
206 | ||
207 | // eof .... |