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 16 #ifndef FRAMEWORKS_SERVICES_CLOUD_SYNC_NOTIFY_HANDLE_INCLUDE_CLOUD_SYNC_NOTIFY_HANDLER_H 17 #define FRAMEWORKS_SERVICES_CLOUD_SYNC_NOTIFY_HANDLE_INCLUDE_CLOUD_SYNC_NOTIFY_HANDLER_H 18 19 #include "datashare_helper.h" 20 #include "cloud_sync_observer.h" 21 #include "medialibrary_type_const.h" 22 23 namespace OHOS { 24 namespace Media { 25 26 #define EXPORT __attribute__ ((visibility ("default"))) 27 28 /** 29 * @brief 云同步状态枚举 30 */ 31 enum CloudSyncStatus : int32_t { 32 BEGIN = 0, // 退出华为账号 33 FIRST_FIVE_HUNDRED, // 端云下行前500张 34 INCREMENT_DOWNLOAD, // 增量任务 35 TOTAL_DOWNLOAD, // 全量任务 36 TOTAL_DOWNLOAD_FINISH, // 全量下行云缩略图任务结束 37 SYNC_SWITCHED_OFF, // 关闭同步开关 38 CLOUD_CLEANING, // 关云退云场景清理本地的云数据 39 }; 40 41 class CloudSyncNotifyHandler { 42 public: CloudSyncNotifyHandler(const CloudSyncNotifyInfo & info)43 CloudSyncNotifyHandler(const CloudSyncNotifyInfo &info):notifyInfo_(info) {}; 44 ~CloudSyncNotifyHandler() = default; 45 46 EXPORT void MakeResponsibilityChain(); 47 void ThumbnailObserverOnChange(const std::list<Uri> &uris, const DataShare::DataShareObserver::ChangeType &type); 48 49 CloudSyncNotifyInfo notifyInfo_; 50 51 private: 52 static std::string GetfileIdFromPastDirtyDataFixUri(std::string uriString); 53 static int32_t QueryFilePathFromFileId(const std::string &id, std::string &filePath); 54 static int32_t QueryAlbumLpathFromFileId(const std::string &id, std::string &lpath); 55 void HandleInsertEvent(const std::list<Uri> &uris); 56 void HandleDeleteEvent(const std::list<Uri> &uris); 57 void HandleTimeUpdateEvent(const std::list<Uri> &uris); 58 void HandleExtraEvent(const std::list<Uri> &uris, const DataShare::DataShareObserver::ChangeType &type); 59 EXPORT void HandleDirtyDataFix(const std::list<Uri> &uris, const CloudSyncErrType &type); 60 void HandleContentNotFound(const std::list<Uri> &uris); 61 void HandleThumbnailNotFound(const std::list<Uri> &uris); 62 void HandleLCDNotFound(const std::list<Uri> &uris); 63 void HandleLCDSizeTooLarge(const std::list<Uri> &uris); 64 void HandleContentSizeIsZero(const std::list<Uri> &uris); 65 void HandleAlbumNotFound(const std::list<Uri> &uris); 66 void HandleThumbnailGenerateFailed(const std::list<Uri> &uris); 67 }; 68 } //namespace Media 69 } //namespace OHOS 70 71 #endif //FRAMEWORKS_SERVICES_CLOUD_SYNC_NOTIFY_HANDLE_INCLUDE_CLOUD_SYNC_NOTIFY_HANDLER_H 72