• 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 
16 #ifndef OHOS_MEDIALIBRARY_PHOTO_ASSET_CHCNAGE_INFO_H
17 #define OHOS_MEDIALIBRARY_PHOTO_ASSET_CHCNAGE_INFO_H
18 
19 #include <string>
20 #include <vector>
21 
22 #include "accurate_common_data.h"
23 #include "abs_rdb_predicates.h"
24 #include "result_set.h"
25 #include "media_column.h"
26 #include "medialibrary_type_const.h"
27 
28 namespace OHOS {
29 namespace Media::AccurateRefresh {
30 #define EXPORT __attribute__ ((visibility ("default")))
31 
32 class EXPORT PhotoAssetChangeInfo : public Parcelable {
33 public:
PhotoAssetChangeInfo()34     PhotoAssetChangeInfo() { }
PhotoAssetChangeInfo(int32_t fileId,std::string uri,std::string dateDay,std::string ownerAlbumUri,bool isFavorite,int32_t mediaType,bool isHidden,int64_t dateTrashedMs,int32_t strongAssociation,int32_t thumbnailVisible,int64_t dateAddedMs,int64_t dateTakenMs,int32_t subType,int32_t syncStatus,int32_t cleanFlag,int32_t timePending,bool isTemp,int32_t burstCoverLevel,int32_t ownerAlbumId,int64_t hiddenTime,int64_t thumbnailReady,std::string displayName,std::string path,int32_t position,int64_t size)35     PhotoAssetChangeInfo(int32_t fileId, std::string uri, std::string dateDay, std::string ownerAlbumUri,
36         bool isFavorite, int32_t mediaType, bool isHidden, int64_t dateTrashedMs, int32_t strongAssociation,
37         int32_t thumbnailVisible, int64_t dateAddedMs, int64_t dateTakenMs, int32_t subType,
38         int32_t syncStatus, int32_t cleanFlag, int32_t timePending, bool isTemp, int32_t burstCoverLevel,
39         int32_t ownerAlbumId, int64_t hiddenTime, int64_t thumbnailReady, std::string displayName,
40         std::string path, int32_t position, int64_t size) : fileId_(fileId), uri_(uri), dateDay_(dateDay),
41         ownerAlbumUri_(ownerAlbumUri), isFavorite_(isFavorite), mediaType_(mediaType), isHidden_(isHidden),
42         dateTrashedMs_(dateTrashedMs), strongAssociation_(strongAssociation), thumbnailVisible_(thumbnailVisible),
43         dateAddedMs_(dateAddedMs), dateTakenMs_(dateTakenMs), subType_(subType), syncStatus_(syncStatus),
44         cleanFlag_(cleanFlag), timePending_(timePending), isTemp_(isTemp), burstCoverLevel_(burstCoverLevel),
45         ownerAlbumId_(ownerAlbumId), hiddenTime_(hiddenTime), thumbnailReady_(thumbnailReady),
46         displayName_(displayName), path_(path), position_(position), size_(size) {}
47 
48 public:
49     int32_t fileId_ = INVALID_INT32_VALUE;
50     std::string uri_ = EMPTY_STR;
51     std::string dateDay_ = EMPTY_STR;
52 
53     // 相册相关
54     std::string ownerAlbumUri_; // todo 或者使用ownerAlbumId
55     bool isFavorite_ = false;
56     int32_t mediaType_ = INVALID_INT32_VALUE;
57     bool isHidden_ = false;
58     int64_t dateTrashedMs_ = INVALID_INT64_VALUE;
59     int32_t strongAssociation_ = INVALID_INT32_VALUE;
60     int32_t thumbnailVisible_ = INVALID_INT32_VALUE;
61 
62     int64_t dateAddedMs_ = INVALID_INT64_VALUE;
63     int64_t dateTakenMs_ = INVALID_INT64_VALUE;
64 
65     // 内部使用
66     int32_t subType_ = INVALID_INT32_VALUE;
67     int32_t syncStatus_ = INVALID_INT32_VALUE;
68     int32_t cleanFlag_ = INVALID_INT32_VALUE;
69     int32_t timePending_ = INVALID_INT32_VALUE;
70     bool isTemp_ = false;
71     int32_t burstCoverLevel_ = INVALID_INT32_VALUE;
72     int32_t ownerAlbumId_ = INVALID_INT32_VALUE;
73     int64_t hiddenTime_ = INVALID_INT64_VALUE;
74     int64_t thumbnailReady_ = INVALID_INT64_VALUE;
75     std::string displayName_ = EMPTY_STR;
76     std::string path_ = EMPTY_STR;
77     int32_t dirty_ = INVALID_INT32_VALUE;
78     int64_t timestamp_ = INVALID_INT64_VALUE;
79     int32_t position_ = INVALID_INT32_VALUE;
80     int64_t size_ = INVALID_INT64_VALUE;
81 
82     std::string ToString(bool isDetail = false) const;
83     bool Marshalling(Parcel &parcel) const override;
84     bool Marshalling(Parcel &parcel, bool isSystem) const;
85     bool ReadFromParcel(Parcel &parcel);
86     static std::shared_ptr<PhotoAssetChangeInfo> Unmarshalling(Parcel &parcel);
87 
88     static const std::vector<std::string>& GetPhotoAssetColumns();
89     static std::vector<PhotoAssetChangeInfo> GetInfoFromResult(const std::shared_ptr<NativeRdb::ResultSet> &resultSet,
90         const std::vector<std::string> &columns);
91     static ResultSetDataType GetDataType(const std::string &column);
92 
93     PhotoAssetChangeInfo(const PhotoAssetChangeInfo &info) = default;
94     PhotoAssetChangeInfo& operator=(const PhotoAssetChangeInfo &info);
95     bool operator==(const PhotoAssetChangeInfo &info) const;
96     bool operator!=(const PhotoAssetChangeInfo &info) const;
97     std::string GetDataDiff(const PhotoAssetChangeInfo &compare);
98 private:
99     std::string GetAssetDiff(const PhotoAssetChangeInfo &asset, const PhotoAssetChangeInfo &compare);
100 
101 private:
102     static const std::vector<std::string> photoAssetColumns_;
103     static const std::map<std::string, ResultSetDataType> photoAssetCloumnTypes_;
104     bool isSystem_ = false;
105 };
106 
107 enum ThumbnailChangeStatus : int32_t {
108     THUMBNAIL_NOT_EXISTS = 0,
109     THUMBNAIL_ADD,
110     THUMBNAIL_UPDATE,
111     THUMBNAIL_NOT_CHANGE,
112 };
113 
114 class EXPORT PhotoAssetChangeData : public AccurateRefreshChangeData<PhotoAssetChangeInfo> {
115 public:
116     bool Marshalling(Parcel &parcel) const override;
117     bool Marshalling(Parcel &parcel, bool isSystem) const;
118     bool ReadFromParcel(Parcel &parcel) override;
119     static std::shared_ptr<PhotoAssetChangeData> Unmarshalling(Parcel &parcel);
120     std::string ToString(bool isDetail = false) const override
121     {
122         return AccurateRefreshChangeData::ToString(isDetail) + ", isContentChanged_: " +
123             std::to_string(isContentChanged_) + ", thumbnailChangeStatus_: " +
124             std::to_string(thumbnailChangeStatus_);
125     }
126     int32_t GetFileId();
127 
128 public:
129     bool isContentChanged_ = false;
130     int32_t thumbnailChangeStatus_ = ThumbnailChangeStatus::THUMBNAIL_NOT_EXISTS;
131     bool isMultiOperation_ = false;
132 };
133 
134 class PhotoAssetContentInfo {
135 public:
136     bool isContentChanged_ = false;
137     int32_t thumbnailChangeStatus_ = ThumbnailChangeStatus::THUMBNAIL_NOT_EXISTS;
138 };
139 
140 } // namespace Media
141 } // namespace OHOS
142 
143 #endif