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