1 /*
2  * Copyright (C) 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 #ifndef CONSTANT_H
17 #define CONSTANT_H
18 #include <cstdint>
19 #include <string>
20 
21 namespace OHOS::Request {
22 
23 enum PausedReason {
24     PAUSED_QUEUED_FOR_WIFI,
25     PAUSED_WAITING_FOR_NETWORK,
26     PAUSED_WAITING_TO_RETRY,
27     PAUSED_BY_USER,
28     PAUSED_UNKNOWN,
29 };
30 
31 enum ExceptionErrorCode : int32_t {
32     E_OK = 0,
33     E_UNLOADING_SA,
34     E_IPC_SIZE_TOO_LARGE,
35     E_MIMETYPE_NOT_FOUND,
36     E_TASK_INDEX_TOO_LARGE,
37     E_CHANNEL_NOT_OPEN = 5,
38     E_PERMISSION = 201,
39     E_NOT_SYSTEM_APP = 202,
40     E_PARAMETER_CHECK = 401,
41     E_UNSUPPORTED = 801,
42     E_FILE_IO = 13400001,
43     E_FILE_PATH = 13400002,
44     E_SERVICE_ERROR = 13400003,
45     E_OTHER = 13499999,
46     E_TASK_QUEUE = 21900004,
47     E_TASK_MODE = 21900005,
48     E_TASK_NOT_FOUND = 21900006,
49     E_TASK_STATE = 21900007,
50 };
51 
52 struct ExceptionError {
53     ExceptionErrorCode code;
54     std::string errInfo;
55 };
56 
57 static constexpr const char *E_OK_INFO = "check succeeded";
58 static constexpr const char *E_PERMISSION_INFO = "the permissions check fails";
59 static constexpr const char *E_PARAMETER_CHECK_INFO = "the parameters check fails";
60 static constexpr const char *E_UNSUPPORTED_INFO = "call unsupported api";
61 static constexpr const char *E_FILE_IO_INFO = " file operation error";
62 static constexpr const char *E_FILE_PATH_INFO = "bad file path";
63 static constexpr const char *E_SERVICE_ERROR_INFO = "task service ability error";
64 static constexpr const char *E_OTHER_INFO = "other error";
65 static constexpr const char *E_TASK_QUEUE_INFO = "the application task queue is full";
66 static constexpr const char *E_TASK_MODE_INFO = "task mode error";
67 static constexpr const char *E_TASK_NOT_FOUND_INFO = "task not found";
68 static constexpr const char *E_TASK_STATE_INFO = "task state error";
69 
70 static constexpr const char *FUNCTION_PAUSE = "pause";
71 static constexpr const char *FUNCTION_QUERY = "query";
72 static constexpr const char *FUNCTION_QUERY_MIME_TYPE = "queryMimeType";
73 static constexpr const char *FUNCTION_REMOVE = "remove";
74 static constexpr const char *FUNCTION_RESUME = "resume";
75 static constexpr const char *FUNCTION_ON = "on";
76 static constexpr const char *FUNCTION_OFF = "off";
77 static constexpr const char *FUNCTION_START = "start";
78 static constexpr const char *FUNCTION_STOP = "stop";
79 static constexpr const char *FUNCTION_SUSPEND = "suspend";
80 static constexpr const char *FUNCTION_GET_TASK_INFO = "getTaskInfo";
81 static constexpr const char *FUNCTION_GET_TASK_MIME_TYPE = "getTaskMimeType";
82 static constexpr const char *FUNCTION_DELETE = "delete";
83 static constexpr const char *FUNCTION_RESTORE = "restore";
84 
85 constexpr const std::uint32_t CONFIG_PARAM_AT_FIRST = 0;
86 constexpr const std::uint32_t CONFIG_PARAM_AT_SECOND = 1;
87 
88 static constexpr const char *PARAM_KEY_METHOD = "method";
89 static constexpr const char *PARAM_KEY_FILES = "files";
90 static constexpr const char *PARAM_KEY_DATA = "data";
91 
92 static constexpr uint32_t NETWORK_MOBILE = 0x00000001;
93 static constexpr uint32_t NETWORK_WIFI = 0x00010000;
94 
95 static const std::string tlsVersion = "X-TLS-Version";
96 static const std::string cipherList = "X-Cipher-List";
97 static const std::string TLS_VERSION = "CURL_SSLVERSION_TLSv1_2";
98 static const std::string TLS_CIPHER = "TLS_DHE_RSA_WITH_AES_128_GCM_SHA256,TLS_DHE_RSA_WITH_AES_256_GCM_SHA384,"
99                                       "TLS_DHE_DSS_WITH_AES_128_GCM_SHA256,TLS_DSS_RSA_WITH_AES_256_GCM_SHA384,"
100                                       "TLS_PSK_WITH_AES_256_GCM_SHA384,TLS_DHE_PSK_WITH_AES_128_GCM_SHA256,"
101                                       "TLS_DHE_PSK_WITH_AES_256_GCM_SHA384,"
102                                       "TLS_DHE_PSK_WITH_CHACHA20_POLY1305_SHA256,"
103                                       "TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256,"
104                                       "TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384,"
105                                       "TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256,TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384,"
106                                       "TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305_SHA256,"
107                                       "TLS_ECDHE_PSK_WITH_CHACHA20_POLY1305_SHA256,"
108                                       "TLS_ECDHE_PSK_WITH_AES_128_GCM_SHA256,TLS_ECDHE_PSK_WITH_AES_256_GCM_SHA384,"
109                                       "TLS_ECDHE_PSK_WITH_AES_128_GCM_SHA256,"
110                                       "TLS_DHE_RSA_WITH_AES_128_CCM,TLS_DHE_RSA_WITH_AES_256_CCM,"
111                                       "TLS_DHE_RSA_WITH_CHACHA20_POLY1305_SHA256,TLS_PSK_WITH_AES_256_CCM,"
112                                       "TLS_DHE_PSK_WITH_AES_128_CCM,TLS_DHE_PSK_WITH_AES_256_CCM,"
113                                       "TLS_ECDHE_ECDSA_WITH_AES_128_CCM,TLS_ECDHE_ECDSA_WITH_AES_256_CCM,"
114                                       "TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305_SHA256,TLS_AES_128_GCM_SHA256,"
115                                       "TLS_AES_256_GCM_SHA384,TLS_CHACHA20_POLY1305_SHA256,TLS_AES_128_CCM_SHA256,"
116                                       "TLS_SM4_GCM_SM3,TLS_SM4_CCM_SM3";
117 
118 } // namespace OHOS::Request
119 
120 #endif // CONSTANT_H
121