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 
22 namespace OHOS {
23 namespace Media {
24 
25 #define EXPORT __attribute__ ((visibility ("default")))
26 
27 /**
28  * @brief 云同步状态枚举
29  */
30 enum CloudSyncStatus : int32_t {
31     BEGIN = 0,                                   // 退出华为账号
32     FIRST_FIVE_HUNDRED,                          // 端云下行前500张
33     INCREMENT_DOWNLOAD,                          // 增量任务
34     TOTAL_DOWNLOAD,                              // 全量任务
35     TOTAL_DOWNLOAD_FINISH,                       // 全量下行云缩略图任务结束
36     SYNC_SWITCHED_OFF,                           // 关闭同步开关
37 };
38 
39 const std::string CLOUDSYNC_STATUS_KEY = "persist.kernel.cloudsync.status";
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     void HandleInsertEvent(const std::list<Uri> &uris);
53     void HandleDeleteEvent(const std::list<Uri> &uris);
54     void HandleTimeUpdateEvent(const std::list<Uri> &uris);
55     void HandleExtraEvent(const std::list<Uri> &uris, const DataShare::DataShareObserver::ChangeType &type);
56 };
57 } //namespace Media
58 } //namespace OHOS
59 
60 #endif //FRAMEWORKS_SERVICES_CLOUD_SYNC_NOTIFY_HANDLE_INCLUDE_CLOUD_SYNC_NOTIFY_HANDLER_H
61