• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1/*
2 * Copyright (c) 2023-2023 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/**
17 * request code
18 */
19export enum RequestCode {
20  START_DISCOVERY_CODE = 0,
21  STOP_DISCOVERY_CODE,
22  CONNECT_PRINTER_CODE,
23  DISCONNECT_PRINTER_CODE,
24  QUERY_PRINTER_CAPABILITY_CODE,
25  CREATE_PRINT_JOB_CODE,
26  START_PRINT_CODE,
27  CANCEL_PRINT_CODE,
28  QUERY_PRINT_EXTENSION_CODE,
29  REQUEST_PREVIEW_CODE,
30  OPEN_JOB_LIST_CODE,
31}
32
33export enum PrintErrorCode {
34  E_PRINT_NONE = 0, // no error
35  E_PRINT_NO_PERMISSION = 201, // no permission
36  E_PRINT_INVALID_PARAMETER = 401, // invalid parameter
37  E_PRINT_GENERIC_FAILURE = 13100001, // generic failure of print
38  E_PRINT_RPC_FAILURE = 13100002, // RPC failure
39  E_PRINT_SERVER_FAILURE = 13100003, // failure of print service
40  E_PRINT_INVALID_EXTENSION = 13100004, // invalid print extension
41  E_PRINT_INVALID_PRINTER = 13100005, // invalid printer
42  E_PRINT_INVALID_PRINTJOB = 13100006, // invalid print job
43  E_PRINT_FILE_IO = 13100007, // file i/o error
44}
45
46
47export enum WindowErrorCode {
48  REPEATED_OPERATION = 1300001, // Repeated operation.
49  WINDOW_STATE_ABNORMAL = 1300002, // This window state is abnormal.
50  UNAUTHORIZED_OPERATION = 1300004 // Unauthorized operation.
51}
52
53export enum PrintRangeType {
54  ALL = 0, //全部页面
55  RANGE = 1, //范围
56  CUSTOM = 2 //自定义
57}
58
59export enum PageDirection {
60  AUTO = 0, //自适应
61  VERTICAL = 1, //竖向
62  LANDSCAPE = 2 //横向
63}
64
65export enum PrintQuality {
66  ECONOMY = 3, //经济
67  STANDARD = 4, //标准
68  BEST = 5 //最佳
69}
70
71export enum Duplex {
72  SINGLE = 0, //单面
73  LONG = 1, //双面沿长边
74  SHORT = 2 //双面沿短边
75}
76
77export enum ColorCode {
78  MONOCHROME = 0, //黑白
79  COLOR = 1 //彩色
80}
81
82export enum MediaType {
83  NORMAL = 0, //普通纸
84  PHOTO = 10 //相片纸
85}
86
87export enum MouseState {
88  NONE = 0,
89  PRESS = 1,
90  HOVER = 2,
91}
92
93export class Constants {
94  static readonly NEGATIVE_1: number = -1;
95  static readonly NUMBER_0: number = 0;
96  static readonly NUMBER_1: number = 1;
97  static readonly NUMBER_2: number = 2;
98  static readonly NUMBER_3: number = 3;
99  static readonly NUMBER_4: number = 4;
100  static readonly NUMBER_5: number = 5;
101  static readonly NUMBER_6: number = 6;
102  static readonly NUMBER_7: number = 7;
103  static readonly NUMBER_8: number = 8;
104  static readonly NUMBER_9: number = 9;
105  static readonly NUMBER_10: number = 10;
106  static readonly NUMBER_11: number = 11;
107  static readonly NUMBER_48: number = 48;
108  static readonly NUMBER_90: number = 90;
109  static readonly NUMBER_99: number = 99;
110
111  static readonly CONNECT_COUNT: number = 40;
112  static readonly COUNTDOWN_INTERVAL: number = 1000;
113  static readonly TOAST_INTERVAL: number = 2000;
114  static readonly TOAST_BOTTOM: number = 64;
115  static readonly SHOW_TOAST_TIMEOUT: number = 200;
116  static readonly COUNTDOWN_ALARM_TO_FAIL: number = 26;
117  static readonly COUNTDOWN_TO_FAIL: number = 25;
118  static readonly CANVAS_MAX_WIDTH: number = 432;
119  static readonly CANVAS_MAX_HEIGHT: number = 302;
120  static readonly MAX_PIXELMAP: number = 33554432;
121  static readonly MAX_PAGES: number = 100;
122  static readonly MAX_CUSTOM_PRINT_RANGE_LENGTH: number = 50;
123
124  static readonly MAIN_WINDOW_WIDTH: number = 480;
125  static readonly MAIN_WINDOW_HEIGHT: number = 853;
126  static readonly JOB_WINDOW_WIDTH: number = 394;
127  static readonly JOB_WINDOW_HEIGHT: number = 550;
128
129  static readonly READ: number = 0o0;
130  static readonly READ_WRITE: number = 0o2;
131  static readonly CREATE: number = 0o100;
132  static readonly OPEN_SYNC1: number = 0o102;
133  static readonly OPEN_SYNC2: number = 0o640;
134  static readonly OPEN_FAIL: number = -1;
135
136  static readonly STRING_NONE: string = '';
137  static readonly STRING_ONE: string = '1';
138  static readonly STRING_NEGATIVE_ONE: string = '-1';
139  static readonly STRING_99: string = '99';
140
141  static readonly BUNDLE_NAME: string = 'com.ohos.spooler';
142  static readonly MAIN_ABILITY_NAME: string = 'MainAbility';
143  static readonly JOB_MANAGER_ABILITY_NAME: string = 'JobManagerAbility';
144  static readonly KEEP_ALIVE_ABILITY_NAME: string = 'KeepAliveAbility';
145  static readonly MAIN_SERVICE_DESCRIPTOR: string = 'PrintSpoolerService';
146  static readonly KEEP_ALIVE_SERVICE_DESCRIPTOR: string = 'KeepAliveService';
147  static readonly WANT_JOB_ID_KEY: string = 'jobId';
148  static readonly WANT_FILE_LIST_KEY: string = 'fileList';
149  static readonly WANT_CALLERPID_KEY: string = 'ohos.aafwk.param.callerUid';
150  static readonly WANT_PKG_NAME_KEY: string = 'caller.pkgName';
151  static readonly EVENT_GET_ABILITY_DATA: string = 'getAbilityData';
152  static readonly DEFAULT_CONNECTING_PRINTER_ID: string = 'noNeedDisconnect';
153  static readonly WINDOW_FLOAT_MODE: number = 102;
154  static readonly PRINT_JOB_NOTIFICATION_ID: number = 2000;
155  static readonly SHOW_JOB_COMPLETED_TIMEOUT: number = 3000; // 3秒
156  static readonly FILE_SEPARATOR = '/';
157  static readonly CN_COMMA = ',';
158  static readonly EU_COMMA = ',';
159  static readonly HYPHEN = '-';
160  static readonly DOT = '.';
161  static readonly MDNS_PRINTER = 'mdns:';
162  static readonly TEMP_JOB_FOLDER = 'jobs';
163  static readonly JPEG_SUFFIX = '.jpeg';
164}
165
166export class AppStorageKeyName {
167  static readonly JOB_QUEUE_NAME: string = 'JobQueue';
168  static readonly PRINTER_QUEUE_NAME: string = 'PrinterQueue';
169  static readonly PRINT_EXTENSION_LIST_NAME: string = 'PrintExtensionsList';
170  static readonly CONFIG_LANGUAGE: string = 'configLanguage';
171  static readonly START_PRINT_TIME: string = 'startPrintTime';
172  static readonly INGRESS_PACKAGE: string = 'ingressPackage';
173  static readonly APP_VERSION: string = 'appVersion';
174}
175
176export class GlobalThisStorageKey {
177  static readonly KEY_SERVICE_CONNECT_OPTIONS: string = 'ServiceConnectOptions';
178  static readonly KEY_JOB_ID: string = 'JobId';
179  static readonly KEY_MEDIA_SIZE_UTIL: string = 'mediaSizeUtil';
180  static readonly KEY_PRINT_ADAPTER: string = 'printAdapter';
181  static readonly KEY_PREFERENCES_ADAPTER: string = 'preferencesAdapter';
182  static readonly KEY_MAIN_ABILITY_CONTEXT: string = 'mainAbilityContext';
183  static readonly KEY_MAIN_ABILITY_WINDOW_STAGE: string = 'mainAbilityWindowStage';
184  static readonly KEY_JOB_MANAGER_ABILITY_CONTEXT: string = 'jobManagerAbilityContext';
185  static readonly KEY_NOTIFICATION_PRINTER_NAME: string = 'notificationPrinterName';
186  static readonly KEY_SERVICE_FIRST_START: string = 'serviceFirstStart';
187  static readonly KEY_PRINTER_SELECT_DIALOG_OPEN: string = 'printerSelectDialogOpen';
188  static readonly KEY_CURRENT_PIXELMAP: string = 'currentPixelMap';
189  static readonly KEY_XGATE_USERNAME: string = 'xGateUserName';
190  static readonly KEY_SECURITY_GUARD: string = 'securityGuard';
191  static readonly KEY_IMAGE_ERROR_COUNT: string = 'imageErrorCount';
192  static readonly KEY_IMAGE_ERROR_NAME: string = 'imageErrorName';
193}
194
195// 应用内公共事件
196export class AppCommonEvent {
197  static readonly PRINTER_STATE_CHANGE_EVENT: number = 1000;
198  static readonly PRINTER_UPDATE_CAPABILITY_EVENT: number = 1001;
199  static readonly START_JOB_MANAGER_ABILITY_EVENT: number = 1002;
200  static readonly TERMINATE_JOB_MANAGER_ABILITY_EVENT: number = 1003;
201  static readonly PRINTER_INVALID_EVENT: number = 1004;
202  static readonly WLAN_INACTIVE_EVENT: number = 1005;
203  static readonly WLAN_ACTIVE_EVENT: number = 1006;
204  static readonly ADD_PRINTER_EVENT: number = 1007;
205}
206
207export class PreferencesKey {
208  static readonly KEY_PRIVACY_STATEMENT_PREFERENCES: string = 'AGREE_PRIVACY_STATEMENT';
209}
210
211
212