1 /* 2 * Copyright (C) 2021-2022 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 DOWNLOAD_INFO_H 17 #define DOWNLOAD_INFO_H 18 19 #include <string> 20 #include <stdint.h> 21 #include <iosfwd> 22 #include "constant.h" 23 24 namespace OHOS::Request::Download { 25 class DownloadInfo final { 26 public: 27 DownloadInfo(); 28 29 void SetDescription(const std::string &description); 30 31 void SetDownloadedBytes(int64_t downloadedBytes); 32 33 void SetDownloadId(uint32_t downloadId); 34 35 void SetFailedReason(ErrorCode failedReason); 36 37 void SetFileName(const std::string &fileName); 38 39 void SetFilePath(const std::string &filePath); 40 41 void SetPausedReason(PausedReason pausedReason); 42 43 void SetStatus(DownloadStatus status); 44 45 void SetTargetURI(const std::string &targetURI); 46 47 void SetDownloadTitle(const std::string & downloadTitle); 48 49 void SetDownloadTotalBytes(int64_t downloadTotalBytes); 50 51 void SetNetworkType(uint32_t networkType); 52 void SetRoaming(bool enableRoaming); 53 void SetMetered(bool enableMetered); 54 55 [[nodiscard]] const std::string &GetDescription() const; 56 57 [[nodiscard]] int64_t GetDownloadedBytes() const; 58 59 [[nodiscard]] uint32_t GetDownloadId() const; 60 61 [[nodiscard]] ErrorCode GetFailedReason() const; 62 63 [[nodiscard]] const std::string &GetFileName() const; 64 65 [[nodiscard]] const std::string &GetFilePath() const; 66 67 [[nodiscard]] PausedReason GetPausedReason() const; 68 69 [[nodiscard]] DownloadStatus GetStatus() const; 70 71 [[nodiscard]] const std::string &GetTargetURI() const; 72 73 [[nodiscard]] const std::string &GetDownloadTitle() const; 74 75 [[nodiscard]] int64_t GetDownloadTotalBytes() const; 76 77 [[nodiscard]] uint32_t GetNetworkType() const; 78 [[nodiscard]] bool GetMetered() const; 79 [[nodiscard]] bool GetRoaming() const; 80 [[nodiscard]] std::string GetTaskType() const; 81 void Dump(); 82 83 private: 84 std::string description_; 85 86 int64_t downloadedBytes_; 87 88 uint32_t downloadId_; 89 90 ErrorCode failedReason_; 91 92 std::string fileName_; 93 94 std::string filePath_; 95 96 PausedReason pausedReason_; 97 98 DownloadStatus status_; 99 100 std::string targetURI_; 101 102 std::string downloadTitle_; 103 104 std::string taskType_; 105 106 int64_t downloadTotalBytes_; 107 108 bool enableMetered_ {false}; 109 bool enableRoaming_ {false}; 110 uint32_t networkType_ {0}; 111 }; 112 } // namespace OHOS::Request::Download 113 #endif /* DOWNLOAD_INFO_H */ 114