• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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     E_GROUP_NOT_FOUND = 21900008,
51 };
52 
53 struct ExceptionError {
54     ExceptionErrorCode code = E_OK;
55     std::string errInfo;
56 };
57 
58 static constexpr const char *E_OK_INFO = "Check succeeded";
59 static constexpr const char *E_PERMISSION_INFO = "The permissions check fails";
60 static constexpr const char *E_PARAMETER_CHECK_INFO = "The parameters check fails";
61 static constexpr const char *E_UNSUPPORTED_INFO = "Call unsupported api";
62 static constexpr const char *E_FILE_IO_INFO = "Invalid file or file system error";
63 static constexpr const char *E_FILE_PATH_INFO = "File path not supported or invalid";
64 static constexpr const char *E_SERVICE_ERROR_INFO = "Task service ability error";
65 static constexpr const char *E_OTHER_INFO = "Others error";
66 static constexpr const char *E_TASK_QUEUE_INFO = "The application task queue is full";
67 static constexpr const char *E_TASK_MODE_INFO = "Operation with wrong task mode";
68 static constexpr const char *E_TASK_NOT_FOUND_INFO = "Task removed or not found";
69 static constexpr const char *E_TASK_STATE_INFO = "Operation with wrong task state";
70 static constexpr const char *E_GROUP_NOT_FOUND_INFO = "Group deleted or not found";
71 
72 static constexpr const char *FUNCTION_PAUSE = "pause";
73 static constexpr const char *FUNCTION_QUERY = "query";
74 static constexpr const char *FUNCTION_QUERY_MIME_TYPE = "queryMimeType";
75 static constexpr const char *FUNCTION_REMOVE = "remove";
76 static constexpr const char *FUNCTION_RESUME = "resume";
77 static constexpr const char *FUNCTION_ON = "on";
78 static constexpr const char *FUNCTION_OFF = "off";
79 static constexpr const char *FUNCTION_START = "start";
80 static constexpr const char *FUNCTION_STOP = "stop";
81 static constexpr const char *FUNCTION_SUSPEND = "suspend";
82 static constexpr const char *FUNCTION_GET_TASK_INFO = "getTaskInfo";
83 static constexpr const char *FUNCTION_GET_TASK_MIME_TYPE = "getTaskMimeType";
84 static constexpr const char *FUNCTION_DELETE = "delete";
85 static constexpr const char *FUNCTION_RESTORE = "restore";
86 static constexpr const char *FUNCTION_SET_MAX_SPEED = "setMaxSpeed";
87 
88 constexpr const std::uint32_t CONFIG_PARAM_AT_FIRST = 0;
89 constexpr const std::uint32_t CONFIG_PARAM_AT_SECOND = 1;
90 
91 static constexpr const char *PARAM_KEY_METHOD = "method";
92 static constexpr const char *PARAM_KEY_FILES = "files";
93 static constexpr const char *PARAM_KEY_DATA = "data";
94 
95 static constexpr uint32_t NETWORK_MOBILE = 0x00000001;
96 static constexpr uint32_t NETWORK_WIFI = 0x00010000;
97 
98 static const std::string tlsVersion = "X-TLS-Version";
99 static const std::string cipherList = "X-Cipher-List";
100 static const std::string TLS_VERSION = "CURL_SSLVERSION_TLSv1_2";
101 static const std::string TLS_CIPHER = "TLS_DHE_RSA_WITH_AES_128_GCM_SHA256,TLS_DHE_RSA_WITH_AES_256_GCM_SHA384,"
102                                       "TLS_DHE_DSS_WITH_AES_128_GCM_SHA256,TLS_DSS_RSA_WITH_AES_256_GCM_SHA384,"
103                                       "TLS_PSK_WITH_AES_256_GCM_SHA384,TLS_DHE_PSK_WITH_AES_128_GCM_SHA256,"
104                                       "TLS_DHE_PSK_WITH_AES_256_GCM_SHA384,"
105                                       "TLS_DHE_PSK_WITH_CHACHA20_POLY1305_SHA256,"
106                                       "TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256,"
107                                       "TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384,"
108                                       "TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256,TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384,"
109                                       "TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305_SHA256,"
110                                       "TLS_ECDHE_PSK_WITH_CHACHA20_POLY1305_SHA256,"
111                                       "TLS_ECDHE_PSK_WITH_AES_128_GCM_SHA256,TLS_ECDHE_PSK_WITH_AES_256_GCM_SHA384,"
112                                       "TLS_ECDHE_PSK_WITH_AES_128_GCM_SHA256,"
113                                       "TLS_DHE_RSA_WITH_AES_128_CCM,TLS_DHE_RSA_WITH_AES_256_CCM,"
114                                       "TLS_DHE_RSA_WITH_CHACHA20_POLY1305_SHA256,TLS_PSK_WITH_AES_256_CCM,"
115                                       "TLS_DHE_PSK_WITH_AES_128_CCM,TLS_DHE_PSK_WITH_AES_256_CCM,"
116                                       "TLS_ECDHE_ECDSA_WITH_AES_128_CCM,TLS_ECDHE_ECDSA_WITH_AES_256_CCM,"
117                                       "TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305_SHA256,TLS_AES_128_GCM_SHA256,"
118                                       "TLS_AES_256_GCM_SHA384,TLS_CHACHA20_POLY1305_SHA256,TLS_AES_128_CCM_SHA256,"
119                                       "TLS_SM4_GCM_SM3,TLS_SM4_CCM_SM3";
120 
121 } // namespace OHOS::Request
122 
123 #endif // CONSTANT_H
124