• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 };
39 
40 const std::string CLOUDSYNC_STATUS_KEY = "persist.kernel.cloudsync.status";
41 
42 class CloudSyncNotifyHandler {
43 public:
CloudSyncNotifyHandler(const CloudSyncNotifyInfo & info)44     CloudSyncNotifyHandler(const CloudSyncNotifyInfo &info):notifyInfo_(info) {};
45     ~CloudSyncNotifyHandler() = default;
46 
47     EXPORT void MakeResponsibilityChain();
48     void ThumbnailObserverOnChange(const std::list<Uri> &uris, const DataShare::DataShareObserver::ChangeType &type);
49 
50     CloudSyncNotifyInfo notifyInfo_;
51 
52 private:
53     static std::string GetfileIdFromPastDirtyDataFixUri(std::string uriString);
54     static int32_t QueryFilePathFromFileId(const std::string &id, std::string &filePath);
55     static int32_t QueryAlbumLpathFromFileId(const std::string &id, std::string &lpath);
56     void HandleInsertEvent(const std::list<Uri> &uris);
57     void HandleDeleteEvent(const std::list<Uri> &uris);
58     void HandleTimeUpdateEvent(const std::list<Uri> &uris);
59     void HandleExtraEvent(const std::list<Uri> &uris, const DataShare::DataShareObserver::ChangeType &type);
60     EXPORT void HandleDirtyDataFix(const std::list<Uri> &uris, const CloudSyncErrType &type);
61     void HandleContentNotFound(const std::list<Uri> &uris);
62     void HandleThumbnailNotFound(const std::list<Uri> &uris);
63     void HandleLCDNotFound(const std::list<Uri> &uris);
64     void HandleLCDSizeTooLarge(const std::list<Uri> &uris);
65     void HandleContentSizeIsZero(const std::list<Uri> &uris);
66     void HandleAlbumNotFound(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