• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2022 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 OHOS_MEDIALIBRARY_RDB_UTILS_H
17 #define OHOS_MEDIALIBRARY_RDB_UTILS_H
18 
19 #include <atomic>
20 #include <functional>
21 #include <memory>
22 #include <string>
23 
24 #include "rdb_store.h"
25 #include "userfile_manager_types.h"
26 namespace OHOS::Media {
27 #define EXPORT __attribute__ ((visibility ("default")))
28 
29 struct AlbumCounts {
30     int count;
31     int hiddenCount;
32     int imageCount;
33     int videoCount;
34 };
35 
36 class MediaLibraryRdbUtils {
37 public:
38     EXPORT static void UpdateSystemAlbumInternal(const std::shared_ptr<NativeRdb::RdbStore> &rdbStore,
39         const std::vector<std::string> &subtypes = {});
40     EXPORT static void UpdateUserAlbumInternal(const std::shared_ptr<NativeRdb::RdbStore> &rdbStore,
41         const std::vector<std::string> &userAlbumIds = {});
42     EXPORT static void UpdateSourceAlbumInternal(const std::shared_ptr<NativeRdb::RdbStore> &rdbStore,
43         const std::vector<std::string> &sourceAlbumIds = {});
44     static void UpdateUserAlbumByUri(const std::shared_ptr<NativeRdb::RdbStore> &rdbStore,
45         const std::vector<std::string> &uris);
46     EXPORT static void UpdateAnalysisAlbumByUri(const std::shared_ptr<NativeRdb::RdbStore> &rdbStore,
47         const std::vector<std::string> &uris);
48     static void UpdateSourceAlbumByUri(const std::shared_ptr<NativeRdb::RdbStore> &rdbStore,
49         const std::vector<std::string> &uris);
50 
51     static void AddQueryFilter(NativeRdb::AbsRdbPredicates &predicates);
52     EXPORT static void UpdateHiddenAlbumInternal(const std::shared_ptr<NativeRdb::RdbStore> &rdbStore);
53     EXPORT static void UpdateAnalysisAlbumInternal(const std::shared_ptr<NativeRdb::RdbStore> &rdbStore,
54         const std::vector<std::string> &userAlbumIds = {});
55     EXPORT static void UpdateAnalysisAlbumByFile(const std::shared_ptr<NativeRdb::RdbStore> &rdbStore,
56         const std::vector<std::string> &fileIds, const std::vector<int> &albumTypes);
57     EXPORT static void UpdateAllAlbums(const std::shared_ptr<NativeRdb::RdbStore> &rdbStore,
58         const std::vector<std::string> &uris = {});
59 
60     EXPORT static int32_t RefreshAllAlbums(const std::shared_ptr<NativeRdb::RdbStore> &rdbStore,
61         std::function<void(PhotoAlbumSubType, int)> refreshProcessHandler,
62         std::function<void()> refreshCallback);
63     EXPORT static int32_t IsNeedRefreshByCheckTable(const std::shared_ptr<NativeRdb::RdbStore> &rdbStore,
64         bool &signal);
65 
66     EXPORT static void UpdateSystemAlbumCountInternal(const std::shared_ptr<NativeRdb::RdbStore> &rdbStore,
67         const std::vector<std::string> &subtypes = {});
68     EXPORT static void UpdateUserAlbumCountInternal(const std::shared_ptr<NativeRdb::RdbStore> &rdbStore,
69         const std::vector<std::string> &userAlbumIds = {});
70 
71     EXPORT static bool IsNeedRefreshAlbum();
72     EXPORT static void SetNeedRefreshAlbum(bool isNeedRefresh);
73     EXPORT static bool IsInRefreshTask();
74     EXPORT static int32_t GetAlbumIdsForPortrait(const std::shared_ptr<NativeRdb::RdbStore> &rdbStore,
75         std::vector<std::string> &portraitAlbumIds);
76 private:
77     static std::atomic<bool> isNeedRefreshAlbum;
78     static std::atomic<bool> isInRefreshTask;
79 };
80 } // namespace OHOS::Media
81 #endif // OHOS_MEDIALIBRARY_RDB_UTILS_H
82