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