• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2021-2023 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 INTERFACES_INNERKITS_NATIVE_INCLUDE_FILE_ASSET_H_
17 #define INTERFACES_INNERKITS_NATIVE_INCLUDE_FILE_ASSET_H_
18 
19 #include <memory>
20 #include <mutex>
21 #include <string>
22 #include <variant>
23 #include <unordered_map>
24 #include "medialibrary_type_const.h"
25 
26 namespace OHOS {
27 namespace Media {
28 #define EXPORT __attribute__ ((visibility ("default")))
29 
30 constexpr int MEMBER_TYPE_INT32 = 0;
31 constexpr int MEMBER_TYPE_INT64 = 1;
32 constexpr int MEMBER_TYPE_STRING = 2;
33 constexpr int MEMBER_TYPE_DOUBLE = 3;
34 
35 constexpr int OPEN_TYPE_READONLY = 0;
36 constexpr int OPEN_TYPE_WRITE = 1;
37 
38 /**
39  * @brief Class for filling all file asset parameters
40  *
41  * @since 1.0
42  * @version 1.0
43  */
44 class FileAsset {
45 public:
46     EXPORT FileAsset();
47     EXPORT virtual ~FileAsset() = default;
48 
49     EXPORT int32_t GetId() const;
50     EXPORT void SetId(int32_t id);
51 
52     EXPORT int32_t GetCount() const;
53     EXPORT void SetCount(int32_t count);
54 
55     EXPORT const std::string &GetUri() const;
56     EXPORT void SetUri(const std::string &uri);
57 
58     EXPORT const std::string &GetPath() const;
59     EXPORT void SetPath(const std::string &path);
60 
61     EXPORT const std::string &GetRelativePath() const;
62     EXPORT void SetRelativePath(const std::string &relativePath);
63 
64     EXPORT const std::string &GetMimeType() const;
65     EXPORT void SetMimeType(const std::string &mimeType);
66 
67     EXPORT MediaType GetMediaType() const;
68     EXPORT void SetMediaType(MediaType mediaType);
69 
70     EXPORT const std::string &GetDisplayName() const;
71     EXPORT void SetDisplayName(const std::string &displayName);
72 
73     EXPORT int64_t GetSize() const;
74     EXPORT void SetSize(int64_t size);
75 
76     EXPORT int64_t GetDateAdded() const;
77     EXPORT void SetDateAdded(int64_t dataAdded);
78 
79     EXPORT int64_t GetDateModified() const;
80     EXPORT void SetDateModified(int64_t dateModified);
81 
82     EXPORT const std::string &GetTitle() const;
83     EXPORT void SetTitle(const std::string &title);
84 
85     EXPORT const std::string &GetArtist() const;
86     EXPORT void SetArtist(const std::string &artist);
87 
88     EXPORT const std::string &GetAlbum() const;
89     EXPORT void SetAlbum(const std::string &album);
90 
91     EXPORT int32_t GetPosition() const;
92     EXPORT void SetPosition(int32_t position);
93 
94     EXPORT int32_t GetWidth() const;
95     EXPORT void SetWidth(int32_t width);
96 
97     EXPORT int32_t GetHeight() const;
98     EXPORT void SetHeight(int32_t height);
99 
100     EXPORT int32_t GetDuration() const;
101     EXPORT void SetDuration(int32_t duration);
102 
103     EXPORT int32_t GetOrientation() const;
104     EXPORT void SetOrientation(int32_t orientation);
105 
106     EXPORT int32_t GetAlbumId() const;
107     EXPORT void SetAlbumId(int32_t albumId);
108 
109     EXPORT const std::string &GetAlbumName() const;
110     EXPORT void SetAlbumName(const std::string &albumName);
111 
112     EXPORT int32_t GetParent() const;
113     EXPORT void SetParent(int32_t parent);
114     EXPORT const std::string &GetAlbumUri() const;
115     EXPORT void SetAlbumUri(const std::string &albumUri);
116     EXPORT int64_t GetDateTaken() const;
117     EXPORT void SetDateTaken(int64_t dataTaken);
118 
119     EXPORT int64_t GetTimePending() const;
120     EXPORT void SetTimePending(int64_t timePending);
121 
122     EXPORT bool IsFavorite() const;
123     EXPORT void SetFavorite(bool isFavorite);
124     EXPORT int64_t GetDateTrashed() const;
125     EXPORT void SetDateTrashed(int64_t dateTrashed);
126 
127     EXPORT std::pair<std::string, int> GetPhotoIdAndQuality() const;
128     EXPORT void SetPhotoIdAndQuality(const std::string &photoId, int photoQuality);
129 
130     EXPORT void SetLatitude(int64_t latitude);
131     EXPORT int64_t GetLatitude();
132     EXPORT void SetLongitude(int64_t longitude);
133     EXPORT int64_t GetLongitude();
134 
135     EXPORT const std::string &GetSelfId() const;
136     EXPORT void SetSelfId(const std::string &selfId);
137     EXPORT int32_t GetIsTrash() const;
138     EXPORT void SetIsTrash(int32_t isTrash);
139     EXPORT const std::string GetOwnerPackage() const;
140     EXPORT void SetOwnerPackage(const std::string &ownerPackage);
141     EXPORT const std::string GetPackageName() const;
142     EXPORT void SetPackageName(const std::string &packageName);
143 
144     EXPORT const std::string &GetRecyclePath() const;
145     EXPORT void SetRecyclePath(const std::string &recyclePath);
146 
147     EXPORT ResultNapiType GetResultNapiType() const;
148     EXPORT void SetResultNapiType(const ResultNapiType type);
149 
150     EXPORT int32_t GetPhotoSubType() const;
151     EXPORT void SetPhotoSubType(int32_t photoSubType);
152 
153     EXPORT int32_t GetPhotoIndex() const;
154 
155     EXPORT const std::string &GetCameraShotKey() const;
156     EXPORT void SetCameraShotKey(const std::string &cameraShotKey);
157 
158     EXPORT bool IsHidden() const;
159     EXPORT void SetHidden(bool isHidden);
160 
161     EXPORT void SetOpenStatus(int32_t fd, int32_t openStatus);
162     EXPORT void RemoveOpenStatus(int32_t fd);
163     EXPORT int32_t GetOpenStatus(int32_t fd);
164 
165     EXPORT std::unordered_map<std::string, std::variant<int32_t, int64_t, std::string, double>> &GetMemberMap();
166     EXPORT std::variant<int32_t, int64_t, std::string, double> &GetMemberValue(const std::string &name);
167 
168     EXPORT std::string GetAssetJson();
169     EXPORT void SetResultTypeMap(const std::string &colName, ResultSetDataType type);
170 
171     EXPORT const std::string &GetAllExif() const;
172     EXPORT void SetAllExif(const std::string &allExif);
173 
174     EXPORT const std::string &GetUserComment() const;
175     EXPORT void SetUserComment(const std::string &userComment);
176 
177     EXPORT const std::string &GetFilePath() const;
178     EXPORT void SetFilePath(const std::string &filePath);
179 
180     EXPORT int64_t GetPhotoEditTime() const;
181     EXPORT void SetPhotoEditTime(int64_t photoEditTime);
182 
183 private:
184     const std::string &GetStrMember(const std::string &name) const;
185     int32_t GetInt32Member(const std::string &name) const;
186     int64_t GetInt64Member(const std::string &name) const;
187 
188     std::string albumUri_;
189     ResultNapiType resultNapiType_;
190     std::unordered_map<std::string, std::variant<int32_t, int64_t, std::string, double>> member_;
191     std::mutex openStatusMapMutex_;
192     std::shared_ptr<std::unordered_map<int32_t, int32_t>> openStatusMap_;
193     std::unordered_map<std::string, ResultSetDataType> resultTypeMap_;
194 };
195 } // namespace Media
196 } // namespace OHOS
197 
198 #endif  // INTERFACES_INNERKITS_NATIVE_INCLUDE_FILE_ASSET_H_
199