Load cups into easysw/current.
[thirdparty/cups.git] / scripting / java / CUPSPrinter.java
1 //
2 import java.io.*;
3 import java.net.*;
4 import java.util.*;
5
6 public class CUPSPrinter
7 {
8 String printer_name;
9 String printer_location;
10 String printer_info;
11 String printer_more_info;
12
13 String[] printer_uri_supported; // Strings
14 String[] uri_authentication_supported; // Strings
15 String[] uri_security_supported; // Strings
16
17 String attributes_charset;
18 String attributes_natural_language;
19
20 int printer_state;
21 String printer_state_reasons;
22
23 boolean printer_is_accepting_jobs;
24
25 long printer_up_time;
26 long printer_current_time;
27
28 int queued_job_count;
29
30 String[] pdl_override_supported;
31 String[] ipp_versions_supported;
32
33 int[] operations_supported; // Integers
34
35 boolean multiple_document_jobs_supported;
36 int multiple_operation_time_out;
37 int[] multiple_document_handling_supported; // Integers
38
39 String charset_configured;
40 String natural_language_configured;
41 String generated_natural_language_supported;
42 String[] charset_supported; // Strings
43
44 String document_format_default;
45 String[] document_format_supported; // Strings
46
47 String[] compression_supported; // Strings
48
49 int job_priority_default;
50 int job_priority_supported;
51
52 int copies_default;
53 int lower_copies_supported;
54 int upper_copies_supported;
55
56 boolean page_ranges_supported;
57
58 int number_up_default;
59 int[] number_up_supported; // integers
60
61
62 int orientation_requested_default;
63 int[] orientation_requested_supported; // Integers
64
65 int job_quota_period;
66 int job_k_limit;
67 int job_page_limit;
68
69 String job_sheets_default; // Should this be a list too?
70 String[] job_sheets_supported; // Strings
71
72 String device_uri;
73
74 boolean color_supported;
75 int pages_per_minute;
76
77 String printer_make_and_model;
78
79 String media_default;
80 String[] media_supported; // Strings
81
82 int finishings_default;
83 int[] finishings_supported; // Integers
84
85 int printer_type;
86
87
88
89 // ---------------------------------------------
90 //
91 // Basic constructor.
92 //
93 public CUPSPrinter()
94 {
95 }
96
97
98
99
100 // ---------------------------------------------
101 //
102 // Move the attributes from an ipp request
103 // into a CUPSPrinter object.
104 //
105 public void updateAttribute( IPPAttribute a )
106 {
107 IPPValue v;
108 int i;
109
110
111 if (a.name.compareTo("printer-name") == 0)
112 {
113 v = (IPPValue)a.values.get(0);
114 printer_name = v.text;
115 }
116 else if (a.name.compareTo("printer-location") == 0)
117 {
118 v = (IPPValue)a.values.get(0);
119 printer_location = v.text;
120 }
121 else if (a.name.compareTo("printer-info") == 0)
122 {
123 v = (IPPValue)a.values.get(0);
124 printer_info = v.text;
125 }
126 else if (a.name.compareTo("printer-more-info") == 0)
127 {
128 v = (IPPValue)a.values.get(0);
129 printer_more_info = v.text;
130 }
131 else if (a.name.compareTo("printer-uri-supported") == 0)
132 {
133 printer_uri_supported = new String[a.values.size()];
134 for (i=0; i < a.values.size(); i++)
135 {
136 v = (IPPValue)a.values.get(i);
137 printer_uri_supported[i] = v.text;
138 }
139 }
140 else if (a.name.compareTo("uri-authentication-supported") == 0)
141 {
142 uri_authentication_supported = new String[a.values.size()];
143 for (i=0; i < a.values.size(); i++)
144 {
145 v = (IPPValue)a.values.get(i);
146 uri_authentication_supported[i] = v.text;
147 }
148 }
149 else if (a.name.compareTo("uri-security-supported") == 0)
150 {
151 uri_security_supported = new String[a.values.size()];
152 for (i=0; i < a.values.size(); i++)
153 {
154 v = (IPPValue)a.values.get(i);
155 uri_security_supported[i] = v.text;
156 }
157 }
158 else if (a.name.compareTo("attributes-charset") == 0)
159 {
160 v = (IPPValue)a.values.get(0);
161 attributes_charset = v.text;
162 }
163 else if (a.name.compareTo("attributes-natural-language") == 0)
164 {
165 v = (IPPValue)a.values.get(0);
166 attributes_natural_language = v.text;
167 }
168 else if (a.name.compareTo("printer-state") == 0)
169 {
170 v = (IPPValue)a.values.get(0);
171 printer_state = v.integer_value;
172 }
173 else if (a.name.compareTo("printer-state-reasons") == 0)
174 {
175 v = (IPPValue)a.values.get(0);
176 printer_state_reasons = v.text;
177 }
178 else if (a.name.compareTo("printer-is-accepting-jobs") == 0)
179 {
180 v = (IPPValue)a.values.get(0);
181 printer_is_accepting_jobs = v.boolean_value;
182 }
183 else if (a.name.compareTo("printer-up-time") == 0)
184 {
185 v = (IPPValue)a.values.get(0);
186 printer_up_time = v.integer_value;
187 }
188 else if (a.name.compareTo("printer-current-time") == 0)
189 {
190 v = (IPPValue)a.values.get(0);
191 printer_current_time = v.unix_time; // *** FIX ***
192 }
193 else if (a.name.compareTo("queue-job-count") == 0)
194 {
195 v = (IPPValue)a.values.get(0);
196 queued_job_count = v.integer_value;
197 }
198 else if (a.name.compareTo("pdl-override-supported") == 0)
199 {
200 pdl_override_supported = new String[a.values.size()];
201 for (i=0; i < a.values.size(); i++)
202 {
203 v = (IPPValue)a.values.get(i);
204 pdl_override_supported[i] = v.text;
205 }
206 }
207 else if (a.name.compareTo("ipp-versions-supported") == 0)
208 {
209 ipp_versions_supported = new String[a.values.size()];
210 for (i=0; i < a.values.size(); i++)
211 {
212 v = (IPPValue)a.values.get(i);
213 ipp_versions_supported[i] = v.text;
214 }
215 }
216 else if (a.name.compareTo("operations-supported") == 0)
217 {
218 operations_supported = new int[a.values.size()];
219 for (i=0; i < a.values.size(); i++)
220 {
221 v = (IPPValue)a.values.get(i);
222 operations_supported[i] = v.integer_value;
223 }
224 }
225 else if (a.name.compareTo("multiple-document-jobs-supported") == 0)
226 {
227 v = (IPPValue)a.values.get(0);
228 multiple_document_jobs_supported = v.boolean_value;
229 }
230 else if (a.name.compareTo("multiple-operation-time-out") == 0)
231 {
232 v = (IPPValue)a.values.get(0);
233 multiple_operation_time_out = v.integer_value;
234 }
235 else if (a.name.compareTo("multiple-document-handling-supported") == 0)
236 {
237 multiple_document_handling_supported = new int[a.values.size()];
238 for (i=0; i < a.values.size(); i++)
239 {
240 v = (IPPValue)a.values.get(i);
241 multiple_document_handling_supported[i] = v.integer_value;
242 }
243 }
244 else if (a.name.compareTo("charset-configured") == 0)
245 {
246 v = (IPPValue)a.values.get(0);
247 charset_configured = v.text;
248 }
249 else if (a.name.compareTo("natural-language-configured") == 0)
250 {
251 v = (IPPValue)a.values.get(0);
252 natural_language_configured = v.text;
253 }
254 else if (a.name.compareTo("generated-natural-language-supported") == 0)
255 {
256 // *** Should this be a list too?
257 v = (IPPValue)a.values.get(0);
258 generated_natural_language_supported = v.text;
259 }
260 else if (a.name.compareTo("charset-supported") == 0)
261 {
262 charset_supported = new String[a.values.size()];
263 for (i=0; i < a.values.size(); i++)
264 {
265 v = (IPPValue)a.values.get(i);
266 charset_supported[i] = v.text;
267 }
268 }
269 else if (a.name.compareTo("document-format-default") == 0)
270 {
271 v = (IPPValue)a.values.get(0);
272 document_format_default = v.text;
273 }
274 else if (a.name.compareTo("document-format-supported") == 0)
275 {
276 document_format_supported = new String[a.values.size()];
277 for (i=0; i < a.values.size(); i++)
278 {
279 v = (IPPValue)a.values.get(i);
280 document_format_supported[i] = v.text;
281 }
282 }
283 else if (a.name.compareTo("compression-supported") == 0)
284 {
285 compression_supported = new String[a.values.size()];
286 for (i=0; i < a.values.size(); i++)
287 {
288 v = (IPPValue)a.values.get(i);
289 compression_supported[i] = v.text;
290 }
291 }
292 else if (a.name.compareTo("job-priority-default") == 0)
293 {
294 v = (IPPValue)a.values.get(0);
295 job_priority_default = v.integer_value;
296 }
297 else if (a.name.compareTo("job-priority-supported") == 0)
298 {
299 // *** Should be a list? ***
300 v = (IPPValue)a.values.get(0);
301 job_priority_supported = v.integer_value;
302 }
303 else if (a.name.compareTo("copies-default") == 0)
304 {
305 v = (IPPValue)a.values.get(0);
306 copies_default = v.integer_value;
307 }
308 else if (a.name.compareTo("copies-supported") == 0)
309 {
310 v = (IPPValue)a.values.get(0);
311 lower_copies_supported = v.lower;
312 upper_copies_supported = v.upper;
313 }
314 else if (a.name.compareTo("page-ranges-supported") == 0)
315 {
316 v = (IPPValue)a.values.get(0);
317 page_ranges_supported = v.boolean_value;
318 }
319 else if (a.name.compareTo("number-up-default") == 0)
320 {
321 v = (IPPValue)a.values.get(0);
322 number_up_default = v.integer_value;
323 }
324 else if (a.name.compareTo("number-up-supported") == 0)
325 {
326 number_up_supported = new int[a.values.size()];
327 for (i=0; i < a.values.size(); i++)
328 {
329 v = (IPPValue)a.values.get(i);
330 number_up_supported[i] = v.integer_value;
331 }
332 }
333 else if (a.name.compareTo("orientation-requested-default") == 0)
334 {
335 v = (IPPValue)a.values.get(0);
336 orientation_requested_default = v.integer_value;
337 }
338 else if (a.name.compareTo("orientation-requested-supported") == 0)
339 {
340 orientation_requested_supported = new int[a.values.size()];
341 for (i=0; i < a.values.size(); i++)
342 {
343 v = (IPPValue)a.values.get(i);
344 orientation_requested_supported[i] = v.integer_value;
345 }
346 }
347 else if (a.name.compareTo("job-quota-period") == 0)
348 {
349 v = (IPPValue)a.values.get(0);
350 job_quota_period = v.integer_value;
351 }
352 else if (a.name.compareTo("job-k-limit") == 0)
353 {
354 v = (IPPValue)a.values.get(0);
355 job_k_limit = v.integer_value;
356 }
357 else if (a.name.compareTo("job-page-limit") == 0)
358 {
359 v = (IPPValue)a.values.get(0);
360 job_page_limit = v.integer_value;
361 }
362 else if (a.name.compareTo("job-sheets-default") == 0)
363 {
364 v = (IPPValue)a.values.get(0);
365 job_sheets_default = v.text;
366 }
367 else if (a.name.compareTo("job-sheets-supported") == 0)
368 {
369 job_sheets_supported = new String[a.values.size()];
370 for (i=0; i < a.values.size(); i++)
371 {
372 v = (IPPValue)a.values.get(i);
373 job_sheets_supported[i] = v.text;
374 }
375 }
376 else if (a.name.compareTo("device-uri") == 0)
377 {
378 v = (IPPValue)a.values.get(0);
379 device_uri = v.text;
380 }
381 else if (a.name.compareTo("color-supported") == 0)
382 {
383 v = (IPPValue)a.values.get(0);
384 color_supported = v.boolean_value;
385 }
386 else if (a.name.compareTo("pages-per-minute") == 0)
387 {
388 v = (IPPValue)a.values.get(0);
389 pages_per_minute = v.integer_value;
390 }
391 else if (a.name.compareTo("printer-make-and-model") == 0)
392 {
393 v = (IPPValue)a.values.get(0);
394 printer_make_and_model = v.text;
395 }
396 else if (a.name.compareTo("media-default") == 0)
397 {
398 v = (IPPValue)a.values.get(0);
399 media_default = v.text;
400 }
401 else if (a.name.compareTo("media-supported") == 0)
402 {
403 media_supported = new String[a.values.size()];
404 for (i=0; i < a.values.size(); i++)
405 {
406 v = (IPPValue)a.values.get(i);
407 media_supported[i] = v.text;
408 }
409 }
410 else if (a.name.compareTo("finishings-default") == 0)
411 {
412 v = (IPPValue)a.values.get(0);
413 finishings_default = v.integer_value;
414 }
415 else if (a.name.compareTo("finishings-supported") == 0)
416 {
417 finishings_supported = new int[a.values.size()];
418 for (i=0; i < a.values.size(); i++)
419 {
420 v = (IPPValue)a.values.get(i);
421 finishings_supported[i] = v.integer_value;
422 }
423 }
424 else if (a.name.compareTo("printer-type") == 0)
425 {
426 v = (IPPValue)a.values.get(0);
427 printer_type = v.integer_value;
428 }
429
430 } // End of updateAttribute()
431
432
433
434
435
436 } // End of CUPSPrinter class
437
438