1 /* 2 * Copyright (C) 2024 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 #ifndef OHOS_MEDIA_BACKUP_REPORT_DATA_TYPE_H 16 #define OHOS_MEDIA_BACKUP_REPORT_DATA_TYPE_H 17 18 #include <string> 19 #include <sstream> 20 21 namespace OHOS::Media { 22 struct AlbumMediaStatisticInfo { 23 int32_t sceneCode{-1}; 24 std::string taskId; 25 std::string albumName; 26 int32_t totalCount{0}; 27 int32_t imageCount{0}; 28 int32_t videoCount{0}; 29 int32_t hiddenCount{0}; 30 int32_t trashedCount{0}; 31 int32_t cloudCount{0}; 32 int32_t favoriteCount{0}; 33 int32_t burstCoverCount{0}; 34 int32_t burstTotalCount{0}; 35 // non-event data members 36 std::string lPath; ToStringAlbumMediaStatisticInfo37 std::string ToString() const 38 { 39 std::stringstream ss; 40 ss << "AlbumMediaStatisticInfo[" 41 << "sceneCode: " << sceneCode << ", " 42 << "taskId: " << taskId << ", " 43 << "albumName: " << albumName << ", " 44 << "totalCount: " << totalCount << ", " 45 << "imageCount: " << imageCount << ", " 46 << "videoCount: " << videoCount << ", " 47 << "hiddenCount: " << hiddenCount << ", " 48 << "trashedCount: " << trashedCount << ", " 49 << "cloudCount: " << cloudCount << ", " 50 << "favoriteCount: " << favoriteCount << ", " 51 << "burstTotalCount: " << burstTotalCount << ", " 52 << "burstCoverCount: " << burstCoverCount << "]"; 53 return ss.str(); 54 } 55 }; 56 57 class MediaRestoreResultInfo { 58 public: 59 int32_t sceneCode{-1}; 60 std::string taskId; 61 std::string errorCode; 62 std::string errorInfo; 63 std::string type; 64 std::string backupInfo; 65 int duplicateCount{0}; 66 int failedCount{0}; 67 int successCount{0}; 68 69 public: ToString()70 std::string ToString() const 71 { 72 std::stringstream ss; 73 ss << "MediaRestoreResultInfo[" 74 << "sceneCode: " << this->sceneCode << ", taskId: " << this->taskId << ", errorCode: " << this->errorCode 75 << ", errorInfo: " << this->errorInfo << ", type: " << this->type << ", backupInfo: " << this->backupInfo 76 << ", duplicateCount: " << this->duplicateCount << ", failedCount: " << this->failedCount 77 << ", successCount: " << this->successCount << "]"; 78 return ss.str(); 79 } 80 }; 81 82 class CallbackBackupInfo { 83 public: 84 std::string backupInfo; 85 std::string details; 86 int duplicateCount; 87 int failedCount; 88 int successCount; 89 90 public: ToString()91 std::string ToString() const 92 { 93 std::stringstream ss; 94 ss << "BackupInfo[ " 95 << "backupInfo: " << this->backupInfo << ", " 96 << "details: " << this->details << ", " 97 << "duplicateCount: " << this->duplicateCount << ", " 98 << "failedCount: " << this->failedCount << ", " 99 << "successCount: " << this->successCount << " ]"; 100 return ss.str(); 101 } 102 }; 103 104 class CallbackResultInfo { 105 public: 106 std::string errorCode; 107 std::string errorInfo; 108 std::string type; 109 110 public: ToString()111 std::string ToString() const 112 { 113 std::stringstream ss; 114 ss << "ResultInfo[ " 115 << "errorCode: " << this->errorCode << ", " 116 << "errorInfo: " << this->errorInfo << ", " 117 << "type: " << this->type << " ]"; 118 return ss.str(); 119 } 120 }; 121 122 class CallbackResultData { 123 public: 124 CallbackResultInfo resultInfo; 125 std::vector<CallbackBackupInfo> infos; 126 127 private: ToString(const std::vector<CallbackBackupInfo> & infoList)128 std::string ToString(const std::vector<CallbackBackupInfo> &infoList) const 129 { 130 std::stringstream ss; 131 ss << "infos[ "; 132 for (const auto &info : infoList) { 133 ss << info.ToString() << ", "; 134 } 135 ss << " ]"; 136 return ss.str(); 137 } 138 139 public: ToString()140 std::string ToString() const 141 { 142 std::stringstream ss; 143 ss << "ResultData[ " << this->resultInfo.ToString() << ", " << this->ToString(this->infos) << " ]"; 144 return ss.str(); 145 } 146 }; 147 148 class AlbumNameInfo { 149 private: 150 std::string albumName_; 151 std::string lPath_; 152 int64_t costTime_; 153 int32_t period_; 154 int32_t dbType_; 155 156 public: SetAlbumName(const std::string & albumName)157 AlbumNameInfo &SetAlbumName(const std::string &albumName) 158 { 159 this->albumName_ = albumName; 160 return *this; 161 } SetLPath(const std::string & lPath)162 AlbumNameInfo &SetLPath(const std::string &lPath) 163 { 164 this->lPath_ = lPath; 165 return *this; 166 } SetCostTime(int64_t costTime)167 AlbumNameInfo &SetCostTime(int64_t costTime) 168 { 169 this->costTime_ = costTime; 170 return *this; 171 } 172 /** 173 * @brief Set period. 0 - BEFORE, 1 - AFTER 174 */ SetPeriod(int32_t period)175 AlbumNameInfo &SetPeriod(int32_t period) 176 { 177 this->period_ = period; 178 return *this; 179 } 180 /** 181 * @brief Set db type. 0 - GALLERY, 1 - MEDIA 182 */ SetDbType(int32_t dbType)183 AlbumNameInfo &SetDbType(int32_t dbType) 184 { 185 this->dbType_ = dbType; 186 return *this; 187 } 188 /** 189 * @brief Convert AlbumNameInfo to string. Format : albumName_lPath_dbTypeName_periodName_costTime 190 */ ToString()191 std::string ToString() const 192 { 193 std::string dbTypeName = this->dbType_ == 0 ? "GALLERY" : "MEDIA"; 194 std::string periodName = this->period_ == 0 ? "BEFORE" : (this->period_ == 1 ? "AFTER" : "OLD"); 195 std::stringstream ss; 196 ss << this->albumName_ << "_" << this->lPath_ << "_" << dbTypeName << "_" << periodName << "_" 197 << this->costTime_; 198 return ss.str(); 199 } 200 }; 201 202 struct AlbumStatisticInfo { 203 std::string lPath; 204 int32_t count; 205 std::string albumName; 206 }; 207 208 enum { 209 DUAL_MEDIA_TYPE_ALL = 0, 210 DUAL_MEDIA_TYPE_IMAGE = 1, 211 DUAL_MEDIA_TYPE_VIDEO = 3, 212 DUAL_SEARCH_TYPE_ALL = 0, 213 DUAL_SEARCH_TYPE_CLOUD = 1, 214 DUAL_HIDDEN_TYPE_SKIP = -1, 215 DUAL_HIDDEN_TYPE_NOT_HIDDEN = 0, 216 DUAL_HIDDEN_TYPE_HIDDEN = 1, 217 DUAL_TRASHED_TYPE_SKIP = -1, 218 DUAL_TRASHED_TYPE_NOT_TRASHED = 0, 219 DUAL_TRASHED_TYPE_TRASHED = 1, 220 DUAL_CLOUD_TYPE_SKIP = -1, 221 DUAL_CLOUD_TYPE_NOT_CLOUD = 0, 222 DUAL_CLOUD_TYPE_CLOUD = 1, 223 DUAL_FAVORITE_TYPE_SKIP = -1, 224 DUAL_FAVORITE_TYPE_ALL = 0, 225 DUAL_FAVORITE_TYPE_FAVORITE = 1, 226 DUAL_BURST_TYPE_SKIP = -1, 227 DUAL_BURST_TYPE_ALL = 0, 228 DUAL_BURST_TYPE_COVER = 1, 229 }; 230 231 enum { 232 SINGLE_MEDIA_TYPE_ALL = 0, 233 SINGLE_MEDIA_TYPE_IMAGE = 1, 234 SINGLE_MEDIA_TYPE_VIDEO = 2, 235 SINGLE_SEARCH_TYPE_ALL = 0, 236 SINGLE_SEARCH_TYPE_CLOUD = 2, 237 SINGLE_HIDDEN_TYPE_SKIP = -1, 238 SINGLE_HIDDEN_TYPE_NOT_HIDDEN = 0, 239 SINGLE_HIDDEN_TYPE_HIDDEN = 1, 240 SINGLE_TRASHED_TYPE_SKIP = -1, 241 SINGLE_TRASHED_TYPE_NOT_TRASHED = 0, 242 SINGLE_TRASHED_TYPE_TRASHED = 1, 243 SINGLE_CLOUD_TYPE_SKIP = -1, 244 SINGLE_CLOUD_TYPE_NOT_CLOUD = 0, 245 SINGLE_CLOUD_TYPE_CLOUD = 1, 246 SINGLE_FAVORITE_TYPE_SKIP = -1, 247 SINGLE_FAVORITE_TYPE_ALL = 0, 248 SINGLE_FAVORITE_TYPE_FAVORITE = 1, 249 SINGLE_BURST_TYPE_SKIP = -1, 250 SINGLE_BURST_TYPE_ALL = 0, 251 SINGLE_BURST_TYPE_COVER = 1, 252 }; 253 254 class SearchCondition { 255 private: 256 int32_t mediaType_ = DUAL_MEDIA_TYPE_ALL; 257 int32_t hiddenType_ = DUAL_HIDDEN_TYPE_SKIP; 258 int32_t trashedType_ = DUAL_TRASHED_TYPE_SKIP; 259 int32_t cloudType_ = DUAL_CLOUD_TYPE_SKIP; 260 int32_t favoriteType_ = DUAL_FAVORITE_TYPE_SKIP; 261 int32_t burstType_ = DUAL_BURST_TYPE_SKIP; 262 263 public: GetMediaType()264 int32_t GetMediaType() 265 { 266 return this->mediaType_; 267 } SetMediaType(int32_t mediaType)268 SearchCondition &SetMediaType(int32_t mediaType) 269 { 270 this->mediaType_ = mediaType; 271 return *this; 272 } GetHiddenType()273 int32_t GetHiddenType() 274 { 275 return this->hiddenType_; 276 } SetHiddenType(int32_t hiddenType)277 SearchCondition &SetHiddenType(int32_t hiddenType) 278 { 279 this->hiddenType_ = hiddenType; 280 return *this; 281 } GetTrashedType()282 int32_t GetTrashedType() 283 { 284 return this->trashedType_; 285 } SetTrashedType(int32_t trashedType)286 SearchCondition &SetTrashedType(int32_t trashedType) 287 { 288 this->trashedType_ = trashedType; 289 return *this; 290 } GetCloudType()291 int32_t GetCloudType() 292 { 293 return this->cloudType_; 294 } SetCloudType(int32_t cloudType)295 SearchCondition &SetCloudType(int32_t cloudType) 296 { 297 this->cloudType_ = cloudType; 298 return *this; 299 } GetFavoriteType()300 int32_t GetFavoriteType() 301 { 302 return this->favoriteType_; 303 } SetFavoriteType(int32_t favoriteType)304 SearchCondition &SetFavoriteType(int32_t favoriteType) 305 { 306 this->favoriteType_ = favoriteType; 307 return *this; 308 } GetBurstType()309 int32_t GetBurstType() 310 { 311 return this->burstType_; 312 } SetBurstType(int32_t burstType)313 SearchCondition &SetBurstType(int32_t burstType) 314 { 315 this->burstType_ = burstType; 316 return *this; 317 } 318 }; 319 320 struct ErrorInfo { 321 int32_t error{-1}; 322 int32_t count{0}; 323 std::string status; 324 std::string extend; ErrorInfoErrorInfo325 ErrorInfo(int32_t error, int32_t count, int32_t errorCode) 326 : error(error), count(count), status(std::to_string(errorCode)) {} ErrorInfoErrorInfo327 ErrorInfo(int32_t error, int32_t count, const std::string &status, const std::string &extend) 328 : error(error), count(count), status(status), extend(extend) {} 329 }; 330 331 struct FileDbCheckInfo { 332 int32_t dbType{-1}; 333 int32_t dbStatus{-1}; 334 int32_t fileStatus{-1}; FileDbCheckInfoFileDbCheckInfo335 FileDbCheckInfo(int32_t dbType, int32_t dbStatus, int32_t fileStatus) 336 : dbType(dbType), dbStatus(dbStatus), fileStatus(fileStatus) {} 337 }; 338 } // namespace OHOS::Media 339 #endif // OHOS_MEDIA_BACKUP_REPORT_DATA_TYPE_H