1 /* 2 * Copyright (c) 2022 Huawei Device Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 16 #ifndef PRINT_CONSTANT_H 17 #define PRINT_CONSTANT_H 18 19 #include <string> 20 21 namespace OHOS::Print { 22 #define PRINT_RET_NONE 23 24 #define PRINT_MAX_PRINT_COUNT 1000 25 #define PRINT_CALLBACK_ADAPTER "printCallback_adapter" 26 #define PRINT_GET_FILE_CALLBACK_ADAPTER "getPrintFileCallback_adapter" 27 28 #define NEW_PRINT_INTERFACE_SWITCH false 29 30 #define PRINT_ASSERT_BASE(env, assertion, message, retVal) \ 31 do { \ 32 if (!(assertion)) { \ 33 PRINT_HILOGE(message); \ 34 return retVal; \ 35 } \ 36 } while (0) 37 38 #define PRINT_ASSERT(env, assertion, message) PRINT_ASSERT_BASE(env, assertion, message, nullptr) 39 40 #define PRINT_ASSERT_RETURN_VOID(env, assertion, message) PRINT_ASSERT_BASE(env, assertion, message, PRINT_RET_NONE) 41 42 #define PRINT_CALL_BASE(env, theCall, retVal) \ 43 do { \ 44 if ((theCall) != napi_ok) { \ 45 return retVal; \ 46 } \ 47 } while (0) 48 49 #define PRINT_CALL(env, theCall) PRINT_CALL_BASE(env, theCall, nullptr) 50 51 #define PRINT_CALL_RETURN_VOID(env, theCall) PRINT_CALL_BASE(env, theCall, PRINT_RET_NONE) 52 53 #define CHECK_IS_EXCEED_PRINT_RANGE_BASE(count, retVal) \ 54 do { \ 55 if ((count) > PRINT_MAX_PRINT_COUNT) { \ 56 PRINT_HILOGW("input val is exceed print max range:%{public}d", PRINT_MAX_PRINT_COUNT); \ 57 return retVal; \ 58 } \ 59 } while (0) 60 61 #define CHECK_IS_EXCEED_PRINT_RANGE(count) CHECK_IS_EXCEED_PRINT_RANGE_BASE(count, nullptr) 62 #define CHECK_IS_EXCEED_PRINT_RANGE_BOOL(count) CHECK_IS_EXCEED_PRINT_RANGE_BASE(count, false) 63 #define CHECK_IS_EXCEED_PRINT_RANGE_VOID(count) CHECK_IS_EXCEED_PRINT_RANGE_BASE(count, PRINT_RET_NONE) 64 #define CHECK_IS_EXCEED_PRINT_RANGE_INT(count) CHECK_IS_EXCEED_PRINT_RANGE_BASE(count, E_PRINT_INVALID_PARAMETER) 65 66 67 enum PrintErrorCode { 68 E_PRINT_NONE = 0, 69 E_PRINT_NO_PERMISSION = 201, 70 E_PRINT_INVALID_PARAMETER = 401, 71 E_PRINT_GENERIC_FAILURE = 13100001, 72 E_PRINT_RPC_FAILURE = 13100002, 73 E_PRINT_SERVER_FAILURE = 13100003, 74 E_PRINT_INVALID_EXTENSION = 13100004, 75 E_PRINT_INVALID_PRINTER = 13100005, 76 E_PRINT_INVALID_PRINTJOB = 13100006, 77 E_PRINT_FILE_IO = 13100007, 78 E_PRINT_UNKNOWN = 13100255, 79 }; 80 81 const uint32_t PRINT_INVALID_ID = 0xFFFFFFFF; // -1 82 83 enum PrinterState { 84 PRINTER_ADDED = 0, // new printers arrival 85 PRINTER_REMOVED = 1, // printers lost 86 PRINTER_UPDATE_CAP = 2, // printers update 87 PRINTER_CONNECTED = 3, // printer has been connected 88 PRINTER_DISCONNECTED = 4, // printer has been disconnected 89 PRINTER_RUNNING = 5, // printer is working 90 PRINTER_UNKNOWN = 6, // unknown printer state 91 }; 92 93 enum PrintJobState { 94 PRINT_JOB_PREPARED = 0, // initial state of print job 95 PRINT_JOB_QUEUED = 1, // deliver print job to the printer 96 PRINT_JOB_RUNNING = 2, // executing print job 97 PRINT_JOB_BLOCKED = 3, // print job has been blocked 98 PRINT_JOB_COMPLETED = 4, // print job ocmpleted 99 PRINT_JOB_UNKNOWN = 100, // unknown state of print job 100 PRINT_JOB_CREATE_FILE_COMPLETED = 101, // For internal use only: create print file completed 101 PRINT_JOB_SPOOLER_CLOSED = 102, // For internal use only: spooler closed 102 }; 103 104 enum PrintJobSubState { 105 PRINT_JOB_COMPLETED_SUCCESS = 0, // print job succeed 106 PRINT_JOB_COMPLETED_FAILED = 1, // print job fail 107 PRINT_JOB_COMPLETED_CANCELLED = 2, // print job has been cancelled 108 PRINT_JOB_COMPLETED_FILE_CORRUPT = 3, // print job has been corrupted 109 PRINT_JOB_BLOCKED_OFFLINE = 4, // printer is offline 110 PRINT_JOB_BLOCKED_BUSY = 5, // printer is occupied by other process 111 PRINT_JOB_BLOCKED_CANCELLED = 6, // print job has been canncelled 112 PRINT_JOB_BLOCKED_OUT_OF_PAPER = 7, // out of paper 113 PRINT_JOB_BLOCKED_OUT_OF_INK = 8, // out of ink 114 PRINT_JOB_BLOCKED_OUT_OF_TONER = 9, // out of toner 115 PRINT_JOB_BLOCKED_JAMMED = 10, // paper jam 116 PRINT_JOB_BLOCKED_DOOR_OPEN = 11, // cover open 117 PRINT_JOB_BLOCKED_SERVICE_REQUEST = 12, // service request 118 PRINT_JOB_BLOCKED_LOW_ON_INK = 13, // low on ink 119 PRINT_JOB_BLOCKED_LOW_ON_TONER = 14, // low on toner 120 PRINT_JOB_BLOCKED_REALLY_LOW_ON_INK = 15, // really low on ink 121 PRINT_JOB_BLOCKED_BAD_CERTIFICATE = 16, // bad certification 122 PRINT_JOB_BLOCKED_DRIVER_EXCEPTION = 17, // printer driver exception 123 124 PRINT_JOB_BLOCKED_ACCOUNT_ERROR = 18, // An error occurred when printing the account. 125 PRINT_JOB_BLOCKED_PRINT_PERMISSION_ERROR = 19, // The printing permission is abnormal. 126 PRINT_JOB_BLOCKED_PRINT_COLOR_PERMISSION_ERROR = 20, // Color printing permission exception 127 PRINT_JOB_BLOCKED_NETWORK_ERROR = 21, // The device is not connected to the network. 128 PRINT_JOB_BLOCKED_SERVER_CONNECTION_ERROR = 22, // Unable to connect to the server 129 PRINT_JOB_BLOCKED_LARGE_FILE_ERROR = 23, // Large file exception 130 PRINT_JOB_BLOCKED_FILE_PARSING_ERROR = 24, // File parsing exception. 131 PRINT_JOB_BLOCKED_SLOW_FILE_CONVERSION = 25, // The file conversion is too slow. 132 PRINT_JOB_RUNNING_UPLOADING_FILES = 26, // Uploading file... 133 PRINT_JOB_RUNNING_CONVERTING_FILES = 27, // Converting files... 134 PRINT_JOB_CREATE_FILE_COMPLETED_SUCCESS = 28, // print job create file succeed 135 PRINT_JOB_CREATE_FILE_COMPLETED_FAILED = 29, // print job create file fail 136 PRINT_JOB_BLOCKED_UNKNOWN = 99, // unknown issue 137 PRINT_JOB_SPOOLER_CLOSED_FOR_CANCELED = 101, // For internal use only: Click Cancel 138 PRINT_JOB_SPOOLER_CLOSED_FOR_STARTED = 102, // For internal use only: Click Start 139 }; 140 141 enum PrintFileCreatedInfoCode { 142 PRINT_FILE_CREATED_SUCCESS = 0, 143 PRINT_FILE_CREATED_FAIL = 1, 144 PRINT_FILE_CREATED_SUCCESS_UNRENDERED = 2, 145 }; 146 147 enum PrintDocumentAdapterState { 148 PREVIEW_ABILITY_DESTROY = 0, 149 PRINT_TASK_SUCCEED = 1, 150 PRINT_TASK_FAIL = 2, 151 PRINT_TASK_CANCEL = 3, 152 PRINT_TASK_BLOCK = 4, 153 }; 154 155 enum PrintExtensionState { 156 PRINT_EXTENSION_UNLOAD, 157 PRINT_EXTENSION_LOADING, 158 PRINT_EXTENSION_LOADED, 159 }; 160 161 enum PrintParamStatus { 162 PRINT_PARAM_NOT_SET, 163 PRINT_PARAM_OPT, 164 PRINT_PARAM_SET, 165 }; 166 167 enum PrintDirectionMode { 168 DIRECTION_MODE_AUTO = 0, 169 DIRECTION_MODE_PORTRAIT = 1, 170 DIRECTION_MODE_LANDSCAPE = 2, 171 }; 172 173 enum PrintColorMode { 174 PRINT_COLOR_MODE_MONOCHROME = 0, 175 PRINT_COLOR_MODE_COLOR = 1, 176 }; 177 178 enum PrintDuplexMode { 179 DUPLEX_MODE_NONE = 0, 180 DUPLEX_MODE_LONG_EDGE = 1, 181 DUPLEX_MODE_SHORT_EDGE = 2, 182 }; 183 184 enum PrintPageType { 185 PAGE_ISO_A3 = 0, 186 PAGE_ISO_A4 = 1, 187 PAGE_ISO_A5 = 2, 188 PAGE_JIS_B5 = 3, 189 PAGE_ISO_C5 = 4, 190 PAGE_ISO_DL = 5, 191 PAGE_LETTER = 6, 192 PAGE_LEGAL = 7, 193 PAGE_PHOTO_4X6 = 8, 194 PAGE_PHOTO_5X7 = 9, 195 PAGE_INT_DL_ENVELOPE = 10, 196 PAGE_B_TABLOID = 11, 197 }; 198 } // namespace OHOS::Print 199 #endif // PRINT_CONSTANT_H