1 /*
2  * Copyright (C) 2016 The Android Open Source Project
3  * Copyright (C) 2016 Mopria Alliance, Inc.
4  * Copyright (C) 2013 Hewlett-Packard Development Company, L.P.
5  *
6  * Licensed under the Apache License, Version 2.0 (the "License");
7  * you may not use this file except in compliance with the License.
8  * You may obtain a copy of the License at
9  *
10  *      http://www.apache.org/licenses/LICENSE-2.0
11  *
12  * Unless required by applicable law or agreed to in writing, software
13  * distributed under the License is distributed on an "AS IS" BASIS,
14  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15  * See the License for the specific language governing permissions and
16  * limitations under the License.
17  */
18 #ifndef __WPRINT_STATUS_TYPES_H__
19 #define __WPRINT_STATUS_TYPES_H__
20 
21 #define LONG_ONE          ((unsigned long long) 1)
22 
23 #define PRINTER_IDLE_BIT       (1 << 31)
24 #define PRINTER_IS_IDLE(X)     ((X) << PRINT_STATUS_MAX_STATE)
25 #define PRINTER_STATUS_MASK(X) ((X) & (PRINTER_IDLE_BIT - 1))
26 
27 #define BLOCKED_REASON_UNABLE_TO_CONNECT (1 << PRINT_STATUS_UNABLE_TO_CONNECT)
28 #define BLOCKED_REASONS_PRINTER_BUSY     (1 << PRINT_STATUS_BUSY)
29 #define BLOCKED_REASONS_CANCELLED        (1 << PRINT_STATUS_CANCELLED)
30 #define BLOCKED_REASON_OUT_OF_PAPER      (1 << PRINT_STATUS_OUT_OF_PAPER)
31 #define BLOCKED_REASON_OUT_OF_INK        (1 << PRINT_STATUS_OUT_OF_INK)
32 #define BLOCKED_REASON_OUT_OF_TONER      (1 << PRINT_STATUS_OUT_OF_TONER)
33 #define BLOCKED_REASON_JAMMED            (1 << PRINT_STATUS_JAMMED)
34 #define BLOCKED_REASON_DOOR_OPEN         (1 << PRINT_STATUS_DOOR_OPEN)
35 #define BLOCKED_REASON_SVC_REQUEST       (1 << PRINT_STATUS_SVC_REQUEST)
36 #define BLOCKED_REASON_LOW_ON_INK        (1 << PRINT_STATUS_LOW_ON_INK)
37 #define BLOCKED_REASON_LOW_ON_TONER      (1 << PRINT_STATUS_LOW_ON_TONER)
38 #define BLOCKED_REASON_UNKNOWN           (1 << PRINT_STATUS_UNKNOWN)
39 #define BLOCKED_REASON_BUSY              (1 << PRINT_STATUS_PRINTING)
40 #define BLOCKED_REASON_IDLE              (1 << PRINT_STATUS_IDLE)
41 #define BLOCKED_REASON_CANCELLED         (1 << PRINT_STATUS_CANCELLED)
42 #define BLOCKED_REASON_PRINT_STATUS_VERY_LOW_ON_INK (1 << PRINT_STATUS_VERY_LOW_ON_INK)
43 #define BLOCKED_REASON_PARTIAL_CANCEL    (1 << PRINT_STATUS_PARTIAL_CANCEL)
44 #define BLOCKED_REASON_PAUSED            (LONG_ONE << PRINT_STATUS_PAUSED)
45 #define BLOCKED_REASON_STOPPED		     (LONG_ONE << PRINT_STATUS_STOPPED)
46 #define BLOCKED_REASON_INPUT_CANNOT_FEED_SIZE_SELECTED  \
47     (LONG_ONE << PRINT_STATUS_INPUT_CANNOT_FEED_SIZE_SELECTED)
48 #define BLOCKED_REASON_INTERLOCK_ERROR   (LONG_ONE << PRINT_STATUS_INTERLOCK_ERROR)
49 #define BLOCKED_REASON_OUTPUT_MAILBOX_SELECT_FAILURE \
50     (LONG_ONE << PRINT_STATUS_OUTPUT_MAILBOX_SELECT_FAILURE)
51 #define BLOCKED_REASON_OUTPUT_TRAY_MISSING (LONG_ONE << PRINT_STATUS_OUTPUT_TRAY_MISSING)
52 #define BLOCKED_REASON_BANDER_ERROR      (LONG_ONE << PRINT_STATUS_BANDER_ERROR)
53 #define BLOCKED_REASON_BINDER_ERROR      (LONG_ONE << PRINT_STATUS_BINDER_ERROR)
54 #define BLOCKED_REASON_POWER_ERROR       (LONG_ONE << PRINT_STATUS_POWER_ERROR)
55 #define BLOCKED_REASON_CLEANER_ERROR     (LONG_ONE << PRINT_STATUS_CLEANER_ERROR)
56 #define BLOCKED_REASON_DIE_CUTTER_ERROR  (LONG_ONE << PRINT_STATUS_DIE_CUTTER_ERROR)
57 #define BLOCKED_REASON_FOLDER_ERROR      (LONG_ONE << PRINT_STATUS_FOLDER_ERROR)
58 #define BLOCKED_REASON_IMPRINTER_ERROR   (LONG_ONE << PRINT_STATUS_IMPRINTER_ERROR)
59 #define BLOCKED_REASON_INPUT_TRAY_ERROR	 (LONG_ONE << PRINT_STATUS_INPUT_TRAY_ERROR)
60 #define BLOCKED_REASON_INSERTER_ERROR	 (LONG_ONE << PRINT_STATUS_INSERTER_ERROR)
61 #define BLOCKED_REASON_INTERPRETER_ERROR (LONG_ONE << PRINT_STATUS_INTERPRETER_ERROR)
62 #define BLOCKED_REASON_MAKE_ENVELOPE_ERROR (LONG_ONE << PRINT_STATUS_MAKE_ENVELOPE_ERROR)
63 #define BLOCKED_REASON_MARKER_ERROR      (LONG_ONE << PRINT_STATUS_MARKER_ERROR)
64 #define BLOCKED_REASON_MEDIA_ERROR		 (LONG_ONE << PRINT_STATUS_MEDIA_ERROR)
65 #define BLOCKED_REASON_PERFORATER_ERROR  (LONG_ONE << PRINT_STATUS_PERFORATER_ERROR)
66 #define BLOCKED_REASON_PUNCHER_ERROR     (LONG_ONE << PRINT_STATUS_PUNCHER_ERROR)
67 #define BLOCKED_REASON_SEPARATION_CUTTER_ERROR (LONG_ONE << PRINT_STATUS_SEPARATION_CUTTER_ERROR)
68 #define BLOCKED_REASON_SHEET_ROTATOR_ERROR (LONG_ONE << PRINT_STATUS_SHEET_ROTATOR_ERROR)
69 #define BLOCKED_REASON_SLITTER_ERROR     (LONG_ONE << PRINT_STATUS_SLITTER_ERROR)
70 #define BLOCKED_REASON_STACKER_ERROR     (LONG_ONE << PRINT_STATUS_STACKER_ERROR)
71 #define BLOCKED_REASON_STAPLER_ERROR     (LONG_ONE << PRINT_STATUS_STAPLER_ERROR)
72 #define BLOCKED_REASON_STITCHER_ERROR    (LONG_ONE << PRINT_STATUS_STITCHER_ERROR)
73 #define BLOCKED_REASON_SUBUNIT_ERROR     (LONG_ONE << PRINT_STATUS_SUBUNIT_ERROR)
74 #define BLOCKED_REASON_TRIMMER_ERROR     (LONG_ONE << PRINT_STATUS_TRIMMER_ERROR)
75 #define BLOCKED_REASON_WRAPPER_ERROR     (LONG_ONE << PRINT_STATUS_WRAPPER_ERROR)
76 #define BLOCKED_REASON_CLIENT_ERROR	     (LONG_ONE << PRINT_STATUS_CLIENT_ERROR)
77 #define BLOCKED_REASON_SERVER_ERROR	     (LONG_ONE << PRINT_STATUS_SERVER_ERROR)
78 #define BLOCKED_REASON_ALERT_REMOVAL_OF_BINARY_CHANGE_ENTRY \
79     (LONG_ONE << PRINT_STATUS_ALERT_REMOVAL_OF_BINARY_CHANGE_ENTRY)
80 #define BLOCKED_REASON_CONFIGURATION_CHANGED (LONG_ONE << PRINT_STATUS_CONFIGURATION_CHANGED)
81 #define BLOCKED_REASON_CONNECTING_TO_DEVICE (LONG_ONE << PRINT_STATUS_CONNECTING_TO_DEVICE)
82 #define BLOCKED_REASON_STATE_DEACTIVATED (LONG_ONE << PRINT_STATUS_STATE_DEACTIVATED)
83 #define BLOCKED_REASON_DEVELOPER_ERROR   (LONG_ONE << PRINT_STATUS_DEVELOPER_ERROR)
84 #define BLOCKED_REASON_HOLD_NEW_JOBS     (LONG_ONE << PRINT_STATUS_HOLD_NEW_JOBS)
85 #define BLOCKED_REASON_OPC_LIFE_OVER     (LONG_ONE << PRINT_STATUS_OPC_LIFE_OVER)
86 #define BLOCKED_REASON_SPOOL_AREA_FULL   (LONG_ONE << PRINT_STATUS_SPOOL_AREA_FULL)
87 #define BLOCKED_REASON_TIMED_OUT         (LONG_ONE << PRINT_STATUS_TIMED_OUT)
88 #define BLOCKED_REASON_SHUTDOWN          (LONG_ONE << PRINT_STATUS_SHUTDOWN)
89 #define BLOCKED_REASON_PRINTER_MANUAL_RESET (LONG_ONE << PRINT_STATUS_PRINTER_MANUAL_RESET)
90 #define BLOCKED_REASON_PRINTER_NMS_RESET (LONG_ONE << PRINT_STATUS_PRINTER_NMS_RESET)
91 
92 #define JOB_FAIL_REASON_UNABLE_TO_CONNECT (LONG_ONE << IPP_JOB_STATE_REASON_UNABLE_TO_CONNECT)
93 #define JOB_CANCEL_REASON_JOB_CANCELED_BY_USER \
94     (LONG_ONE << IPP_JOB_STATE_REASON_JOB_CANCELED_BY_USER)
95 #define JOB_CANCEL_REASON_JOB_CANCELED_AT_DEVICE \
96     (LONG_ONE << IPP_JOB_STATE_REASON_JOB_CANCELED_AT_DEVICE)
97 #define JOB_FAIL_REASON_ABORTED_BY_SYSTEM (LONG_ONE << IPP_JOB_STATE_REASON_ABORTED_BY_SYSTEM)
98 #define JOB_FAIL_REASON_UNSUPPORTED_COMPRESSION \
99     (LONG_ONE << IPP_JOB_STATE_REASON_UNSUPPORTED_COMPRESSION)
100 #define JOB_FAIL_REASON_COMPRESSION_ERROR (LONG_ONE << IPP_JOB_STATE_REASON_COMPRESSION_ERROR)
101 #define JOB_FAIL_REASON_UNSUPPORTED_DOCUMENT_FORMAT \
102     (LONG_ONE << IPP_JOB_STATE_REASON_UNSUPPORTED_DOCUMENT_FORMAT)
103 #define JOB_FAIL_REASON_DOCUMENT_FORMAT_ERROR \
104     (LONG_ONE << IPP_JOB_STATE_REASON_DOCUMENT_FORMAT_ERROR)
105 #define JOB_FAIL_REASON_SERVICE_OFFLINE  (LONG_ONE << IPP_JOB_STATE_REASON_SERVICE_OFFLINE)
106 #define JOB_FAIL_REASON_DOCUMENT_PASSWORD_ERROR \
107     (LONG_ONE << IPP_JOB_STATE_REASON_DOCUMENT_PASSWORD_ERROR)
108 #define JOB_FAIL_REASON_DOCUMENT_PERMISSION_ERROR \
109     (LONG_ONE << IPP_JOB_STATE_REASON_DOCUMENT_PERMISSION_ERROR)
110 #define JOB_FAIL_REASON_DOCUMENT_SECURITY_ERROR \
111     (LONG_ONE << IPP_JOB_STATE_REASON_DOCUMENT_SECURITY_ERROR)
112 #define JOB_FAIL_REASON_DOCUMENT_UNPRINTABLE_ERROR \
113     (LONG_ONE << IPP_JOB_STATE_REASON_DOCUMENT_UNPRINTABLE_ERROR)
114 #define JOB_FAIL_REASON_DOCUMENT_ACCESS_ERROR \
115     (LONG_ONE << IPP_JOB_STATE_REASON_DOCUMENT_ACCESS_ERROR)
116 #define JOB_FAIL_REASON_SUBMISSION_INTERRUPTED \
117     (LONG_ONE << IPP_JOB_STATE_REASON_SUBMISSION_INTERRUPTED)
118 #define JOB_FAIL_REASON_AUTHORIZATION_FAILED \
119     (LONG_ONE << IPP_JOB_STATE_REASON_AUTHORIZATION_FAILED)
120 #define JOB_FAIL_REASON_ACCOUNT_CLOSED   (LONG_ONE << IPP_JOB_STATE_REASON_ACCOUNT_CLOSED)
121 #define JOB_FAIL_REASON_ACCOUNT_INFO_NEEDED (LONG_ONE << IPP_JOB_STATE_REASON_ACCOUNT_INFO_NEEDED)
122 #define JOB_FAIL_REASON_ACCOUNT_LIMIT_REACHED \
123     (LONG_ONE << IPP_JOB_STATE_REASON_ACCOUNT_LIMIT_REACHED)
124 
125 /*
126  * Enumeration for printer statuses
127  */
128 typedef enum {
129     PRINT_STATUS_INITIALIZING,
130     PRINT_STATUS_SHUTTING_DOWN,
131     PRINT_STATUS_UNABLE_TO_CONNECT,
132 
133     PRINT_STATUS_UNKNOWN,
134     PRINT_STATUS_OFFLINE,
135 
136     PRINT_STATUS_BUSY,
137     PRINT_STATUS_CANCELLED,
138 
139     PRINT_STATUS_IDLE,
140     PRINT_STATUS_PRINTING,
141     PRINT_STATUS_JAMMED,
142     PRINT_STATUS_OUT_OF_PAPER,
143     PRINT_STATUS_OUT_OF_INK,
144     PRINT_STATUS_OUT_OF_TONER,
145     PRINT_STATUS_DOOR_OPEN,
146     PRINT_STATUS_SVC_REQUEST,
147     PRINT_STATUS_PAUSED,
148     PRINT_STATUS_STOPPED,
149 
150     PRINT_STATUS_LOW_ON_INK,
151     PRINT_STATUS_LOW_ON_TONER,
152 
153     PRINT_STATUS_VERY_LOW_ON_INK,
154     PRINT_STATUS_PARTIAL_CANCEL,
155 
156     PRINT_STATUS_INPUT_CANNOT_FEED_SIZE_SELECTED,
157     PRINT_STATUS_INTERLOCK_ERROR,
158     PRINT_STATUS_OUTPUT_MAILBOX_SELECT_FAILURE,
159     PRINT_STATUS_OUTPUT_TRAY_MISSING,
160     PRINT_STATUS_BANDER_ERROR,
161     PRINT_STATUS_BINDER_ERROR,
162     PRINT_STATUS_POWER_ERROR,
163     PRINT_STATUS_CLEANER_ERROR,
164     PRINT_STATUS_DIE_CUTTER_ERROR,
165     PRINT_STATUS_FOLDER_ERROR,
166     PRINT_STATUS_IMPRINTER_ERROR,
167     PRINT_STATUS_INPUT_TRAY_ERROR,
168     PRINT_STATUS_INSERTER_ERROR,
169     PRINT_STATUS_INTERPRETER_ERROR,
170     PRINT_STATUS_MAKE_ENVELOPE_ERROR,
171     PRINT_STATUS_MARKER_ERROR,
172     PRINT_STATUS_MEDIA_ERROR,
173     PRINT_STATUS_PERFORATER_ERROR,
174     PRINT_STATUS_PUNCHER_ERROR,
175     PRINT_STATUS_SEPARATION_CUTTER_ERROR,
176     PRINT_STATUS_SHEET_ROTATOR_ERROR,
177     PRINT_STATUS_SLITTER_ERROR,
178     PRINT_STATUS_STACKER_ERROR,
179     PRINT_STATUS_STAPLER_ERROR,
180     PRINT_STATUS_STITCHER_ERROR,
181     PRINT_STATUS_SUBUNIT_ERROR,
182     PRINT_STATUS_TRIMMER_ERROR,
183     PRINT_STATUS_WRAPPER_ERROR,
184     PRINT_STATUS_CLIENT_ERROR,
185     PRINT_STATUS_SERVER_ERROR,
186 
187     PRINT_STATUS_ALERT_REMOVAL_OF_BINARY_CHANGE_ENTRY,
188     PRINT_STATUS_CONFIGURATION_CHANGED,
189     PRINT_STATUS_CONNECTING_TO_DEVICE,
190     PRINT_STATUS_STATE_DEACTIVATED,
191     PRINT_STATUS_DEVELOPER_ERROR,
192     PRINT_STATUS_HOLD_NEW_JOBS,
193     PRINT_STATUS_OPC_LIFE_OVER,
194     PRINT_STATUS_SPOOL_AREA_FULL,
195     PRINT_STATUS_TIMED_OUT,
196     PRINT_STATUS_SHUTDOWN,
197     PRINT_STATUS_PRINTER_MANUAL_RESET,
198     PRINT_STATUS_PRINTER_NMS_RESET,
199 
200     PRINT_STATUS_MAX_STATE // Add new entries above this line.
201 } print_status_t;
202 
203 /*
204  * Structure for handling printer status
205  */
206 typedef struct printer_state_dyn_s {
207     // Printer state (idle, printing, service request, unknown)
208     print_status_t printer_status;
209 
210     // all current print status events
211     print_status_t printer_reasons[PRINT_STATUS_MAX_STATE + 1];
212 
213     int job_id;
214 } printer_state_dyn_t;
215 
216 typedef enum {
217     IPP_JOB_STATE_UNABLE_TO_CONNECT,
218     IPP_JOB_STATE_UNKNOWN,
219     IPP_JOB_STATE_PENDING,
220     IPP_JOB_STATE_PENDING_HELD,
221     IPP_JOB_STATE_PROCESSING,
222     IPP_JOB_STATE_PROCESSING_STOPPED,
223     IPP_JOB_STATE_CANCELED,
224     IPP_JOB_STATE_ABORTED,
225     IPP_JOB_STATE_COMPLETED,
226     IPP_JOB_STATE_MAX_STATE,    // Add new entries above this line.
227 } job_state_t;
228 
229 typedef enum {
230     IPP_JOB_STATE_REASON_UNKNOWN,
231     IPP_JOB_STATE_REASON_UNABLE_TO_CONNECT,
232     IPP_JOB_STATE_REASON_JOB_CANCELED_BY_USER,
233     IPP_JOB_STATE_REASON_JOB_CANCELED_AT_DEVICE,
234     IPP_JOB_STATE_REASON_ABORTED_BY_SYSTEM,
235     IPP_JOB_STATE_REASON_UNSUPPORTED_COMPRESSION,
236     IPP_JOB_STATE_REASON_COMPRESSION_ERROR,
237     IPP_JOB_STATE_REASON_UNSUPPORTED_DOCUMENT_FORMAT,
238     IPP_JOB_STATE_REASON_DOCUMENT_FORMAT_ERROR,
239     IPP_JOB_STATE_REASON_SERVICE_OFFLINE,
240     IPP_JOB_STATE_REASON_DOCUMENT_PASSWORD_ERROR,
241     IPP_JOB_STATE_REASON_DOCUMENT_PERMISSION_ERROR,
242     IPP_JOB_STATE_REASON_DOCUMENT_SECURITY_ERROR,
243     IPP_JOB_STATE_REASON_DOCUMENT_UNPRINTABLE_ERROR,
244     IPP_JOB_STATE_REASON_DOCUMENT_ACCESS_ERROR,
245     IPP_JOB_STATE_REASON_SUBMISSION_INTERRUPTED,
246     IPP_JOB_STATE_REASON_AUTHORIZATION_FAILED,
247     IPP_JOB_STATE_REASON_ACCOUNT_CLOSED,
248     IPP_JOB_STATE_REASON_ACCOUNT_INFO_NEEDED,
249     IPP_JOB_STATE_REASON_ACCOUNT_LIMIT_REACHED,
250     IPP_JOB_STATE_REASON_MAX_VALUE,    // Add new entries above this line.
251 } job_state_reason_t;
252 
253 typedef struct job_state_dyn_s
254 {
255     job_state_t job_state;
256     // all current job state reasons
257     job_state_reason_t job_state_reasons[IPP_JOB_STATE_REASON_MAX_VALUE + 1];
258 } job_state_dyn_t;
259 
260 #endif // __WPRINT_STATUS_TYPES_H__