• 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_CLOUDE_SYNC_OBSERVER_H
17 #define FRAMEWORKS_SERVICES_CLOUD_SYNC_NOTIFY_HANDLE_INCLUDE_CLOUDE_SYNC_OBSERVER_H
18 
19 #include <mutex>
20 
21 #include "datashare_helper.h"
22 #include "medialibrary_async_worker.h"
23 #include "userfile_manager_types.h"
24 
25 namespace OHOS {
26 namespace Media {
27 #define EXPORT __attribute__ ((visibility ("default")))
28 struct CloudSyncNotifyInfo {
29     std::list<Uri> uris;
30     DataShare::DataShareObserver::ChangeType type;
31     const void* data;
32 };
33 
34 class EXPORT CloudSyncObserver : public DataShare::DataShareObserver {
35 public:
36     CloudSyncObserver() = default;
37     ~CloudSyncObserver() = default;
38 
39     void OnChange(const ChangeInfo &changeInfo) override;
40     void DealPhotoGallery(CloudSyncNotifyInfo &notifyInfo);
41     void DealAlbumGallery(CloudSyncNotifyInfo &notifyInfo);
42     void DealCloudSync(const ChangeInfo &changeInfo);
43     void DealGalleryDownload(CloudSyncNotifyInfo &notifyInfo);
44     void HandleIndex();
45 
46     /* delayed trigger */
47     bool isPending_ = false;
48     std::mutex syncMutex_;
49 };
50 
51 class CloudSyncNotifyData : public AsyncTaskData {
52 public:
CloudSyncNotifyData(const CloudSyncNotifyInfo & info)53     CloudSyncNotifyData(const CloudSyncNotifyInfo &info):notifyInfo_(info) {};
54     virtual ~CloudSyncNotifyData() override = default;
55     CloudSyncNotifyInfo notifyInfo_;
56 };
57 } // namespace Media
58 } // namespace OHOS
59 
60 #endif //FRAMEWORKS_SERVICES_CLOUD_SYNC_NOTIFY_HANDLE_INCLUDE_CLOUDE_SYNC_OBSERVER_H
61