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 REQUEST_COMMON_UTILS_H 17 #define REQUEST_COMMON_UTILS_H 18 19 #include <cstdint> 20 #include <unordered_map> 21 #include <unordered_set> 22 #include <vector> 23 24 #include "log.h" 25 #include "parameter.h" 26 #include "request_common.h" 27 #include "visibility.h" 28 29 namespace OHOS::Request { 30 class CommonUtils { 31 private: 32 static constexpr const char *REASON_OK_INFO = "Task successful"; 33 static constexpr const char *TASK_SURVIVAL_ONE_MONTH_INFO = "The task has not been completed for a month yet"; 34 static constexpr const char *WAITTING_NETWORK_ONE_DAY_INFO = "The task waiting for network recovery has not been " 35 "completed for a day yet"; 36 static constexpr const char *STOPPED_NEW_FRONT_TASK_INFO = "Stopped by a new front task"; 37 static constexpr const char *RUNNING_TASK_MEET_LIMITS_INFO = "Too many task in running state"; 38 static constexpr const char *USER_OPERATION_INFO = "User operation"; 39 static constexpr const char *APP_BACKGROUND_OR_TERMINATE_INFO = "The app is background or terminate"; 40 static constexpr const char *NETWORK_OFFLINE_INFO = "NetWork is offline"; 41 static constexpr const char *UNSUPPORTED_NETWORK_TYPE_INFO = "NetWork type not meet the task config"; 42 static constexpr const char *BUILD_CLIENT_FAILED_INFO = "Build client error"; 43 static constexpr const char *BUILD_REQUEST_FAILED_INFO = "Build request error"; 44 static constexpr const char *GET_FILESIZE_FAILED_INFO = "Failed because cannot get the file size from the server " 45 "and " 46 "the precise is setted true by user"; 47 static constexpr const char *CONTINUOUS_TASK_TIMEOUT_INFO = "Continuous processing task time out"; 48 static constexpr const char *CONNECT_ERROR_INFO = "Connect error"; 49 static constexpr const char *REQUEST_ERROR_INFO = "Request error"; 50 static constexpr const char *UPLOAD_FILE_ERROR_INFO = "There are some files upload failed"; 51 static constexpr const char *REDIRECT_ERROR_INFO = "Redirect error"; 52 static constexpr const char *PROTOCOL_ERROR_INFO = "Http protocol error"; 53 static constexpr const char *IO_ERROR_INFO = "Io Error"; 54 static constexpr const char *UNSUPPORT_RANGE_REQUEST_INFO = "Range request not supported"; 55 static constexpr const char *OTHERS_ERROR_INFO = "Some other error occured"; 56 static constexpr const char *ACCOUNT_STOPPED_INFO = "Account stopped"; 57 static constexpr const char *NETWORK_CHANGED_INFO = "Network changed"; 58 static constexpr const char *DNS_INFO = "DNS error"; 59 static constexpr const char *TCP_INFO = "TCP error"; 60 static constexpr const char *SSL_INFO = "TSL/SSL error"; 61 static constexpr const char *INSUFFICIENT_SPACE_INFO = "Insufficient space error"; 62 static constexpr const char *NETWORK_APP_INFO = "NetWork is offline and the app is background or terminate"; 63 static constexpr const char *NETWORK_ACCOUNT_INFO = "NetWork is offline and the account is stopped"; 64 static constexpr const char *APP_ACCOUNT_INFO = "The account is stopped and the app is background or terminate"; 65 static constexpr const char *NETWORK_ACCOUNT_APP_INFO = "NetWork is offline and the account is stopped and the " 66 "app is" 67 "background or terminate"; 68 static constexpr const char *LOW_SPEED_INFO = "Below low speed limit"; 69 70 public: 71 REQUEST_API static Faults GetFaultByReason(Reason code); 72 REQUEST_API static std::string GetMsgByReason(Reason code); 73 }; 74 } // namespace OHOS::Request 75 #endif // COMMON_UTILS_H 76