• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2025 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_FILEMGMT_MEDIA_GALLERY_SYNC_NOTIFI_H
16 #define OHOS_FILEMGMT_MEDIA_GALLERY_SYNC_NOTIFI_H
17 
18 #include <list>
19 #include <memory>
20 #include <mutex>
21 
22 #include "dataobs_mgr_client.h"
23 #include "uri.h"
24 
25 namespace OHOS::Media::CloudSync {
26 
27 enum NotifyTaskType : uint32_t {
28     NOTIFY_BEGIN,
29     NOTIFY_END
30 };
31 
32 enum NotifySyncType : uint32_t {
33     NOTIFY_FULL_SYNC,
34     NOTIFY_INCREMENTAL_SYNC
35 };
36 
37 class MediaGallerySyncNotify : public NoCopyable {
38 using ChangeType = AAFwk::ChangeInfo::ChangeType;
39 
40 public:
41     ~MediaGallerySyncNotify() = default;
42 
43 public:
44     static MediaGallerySyncNotify &GetInstance();
45     int32_t AddNotify(const std::string &uri, const ChangeType changeType, const std::string &fileAssetId);
46     int32_t TryNotify(const std::string &uri, const ChangeType changeType, const std::string &fileAssetId);
47     int32_t NotifyProgress(NotifyTaskType taskType, const std::string &syncId, NotifySyncType syncType,
48         uint32_t totalAlbums = 0, uint32_t totalAssets = 0);
49     int32_t FinalNotify();
50     void NotifyProgressBegin();
51     void NotifyProgressEnd();
52 
53 public:
54     static std::unordered_map<ChangeType, std::list<Uri>> notifyListMap_;
55     static int32_t recordAdded_;
56     static std::mutex mtx_;
57 
58 private:
59     MediaGallerySyncNotify() = default;
60     std::string syncId_;
61 };
62 }
63 #endif // OHOS_FILEMGMT_MEDIA_GALLERY_SYNC_NOTIFI_H