1 /*
2  * Copyright (C) 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_MEDIA_COLUMN_H_
17 #define INTERFACES_INNERKITS_NATIVE_INCLUDE_MEDIA_COLUMN_H_
18 
19 #include <set>
20 #include <string>
21 
22 namespace OHOS::Media {
23 #define EXPORT __attribute__ ((visibility ("default")))
24 enum class DirtyTypes : int32_t {
25     TYPE_SYNCED,
26     TYPE_NEW,
27     TYPE_MDIRTY,
28     TYPE_FDIRTY,
29     TYPE_DELETED,
30     TYPE_RETRY,
31     TYPE_SDIRTY,
32     TYPE_COPY
33 };
34 
35 enum class ExtraChangeType : uint32_t {
36     PHOTO_TIME_UPDATE = 100
37 };
38 
39 class MediaColumn {
40 public:
41     // Asset Base Parameter
42     static const std::string MEDIA_ID EXPORT;
43     static const std::string MEDIA_FILE_PATH EXPORT;
44     static const std::string MEDIA_SIZE EXPORT;
45     static const std::string MEDIA_TITLE EXPORT;
46     static const std::string MEDIA_NAME EXPORT;
47     static const std::string MEDIA_TYPE EXPORT;
48     static const std::string MEDIA_MIME_TYPE EXPORT;
49     static const std::string MEDIA_OWNER_PACKAGE EXPORT;
50     static const std::string MEDIA_OWNER_APPID EXPORT;
51     static const std::string MEDIA_PACKAGE_NAME EXPORT;
52     static const std::string MEDIA_DEVICE_NAME EXPORT;
53 
54     // As set Parameter about time
55     static const std::string MEDIA_DATE_MODIFIED EXPORT;
56     static const std::string MEDIA_DATE_ADDED EXPORT;
57     static const std::string MEDIA_DATE_TAKEN EXPORT;
58     static const std::string MEDIA_DURATION EXPORT;
59     static const std::string MEDIA_TIME_PENDING EXPORT;
60     static const std::string MEDIA_IS_FAV EXPORT;
61     static const std::string MEDIA_DATE_TRASHED EXPORT;
62     static const std::string MEDIA_DATE_DELETED EXPORT;
63     static const std::string MEDIA_HIDDEN EXPORT;
64 
65     // Asset Parameter deperated
66     static const std::string MEDIA_PARENT_ID EXPORT;
67     static const std::string MEDIA_RELATIVE_PATH EXPORT;
68     static const std::string MEDIA_VIRTURL_PATH EXPORT;
69 
70     // All Columns
71     static const std::set<std::string> MEDIA_COLUMNS EXPORT;
72     // Default fetch columns
73     static const std::set<std::string> DEFAULT_FETCH_COLUMNS EXPORT;
74 
75     // Util consts
76     static const std::string ASSETS_QUERY_FILTER EXPORT;
77 };
78 
79 class PhotoColumn : public MediaColumn {
80 public:
81     // column only in PhotoTable
82     static const std::string PHOTO_ORIENTATION EXPORT;
83     static const std::string PHOTO_LATITUDE EXPORT;
84     static const std::string PHOTO_LONGITUDE EXPORT;
85     static const std::string PHOTO_HEIGHT EXPORT;
86     static const std::string PHOTO_WIDTH EXPORT;
87     static const std::string PHOTO_LCD_VISIT_TIME EXPORT;
88     static const std::string PHOTO_EDIT_TIME EXPORT;
89     static const std::string PHOTO_POSITION EXPORT;
90     static const std::string PHOTO_DIRTY EXPORT;
91     static const std::string PHOTO_CLOUD_ID EXPORT;
92     static const std::string PHOTO_SUBTYPE EXPORT;
93     static const std::string PHOTO_META_DATE_MODIFIED EXPORT;
94     static const std::string PHOTO_SYNC_STATUS EXPORT;
95     static const std::string PHOTO_CLOUD_VERSION EXPORT;
96     static const std::string CAMERA_SHOT_KEY EXPORT;
97     static const std::string PHOTO_USER_COMMENT EXPORT;
98     static const std::string PHOTO_ALL_EXIF EXPORT;
99     static const std::string PHOTO_CLEAN_FLAG EXPORT;
100     static const std::string PHOTO_DYNAMIC_RANGE_TYPE EXPORT;
101     static const std::string MOVING_PHOTO_EFFECT_MODE EXPORT;
102     static const std::string PHOTO_HAS_ASTC EXPORT; // This attribute has been replaced by "thumbnail_ready"
103     static const std::string PHOTO_THUMBNAIL_READY EXPORT;
104     static const std::string PHOTO_THUMBNAIL_VISIBLE EXPORT;
105 
106     static const std::string PHOTO_SYNCING EXPORT;
107     static const std::string PHOTO_DATE_YEAR EXPORT;
108     static const std::string PHOTO_DATE_MONTH EXPORT;
109     static const std::string PHOTO_DATE_DAY EXPORT;
110     static const std::string PHOTO_SHOOTING_MODE EXPORT;
111     static const std::string PHOTO_SHOOTING_MODE_TAG EXPORT;
112     static const std::string PHOTO_LAST_VISIT_TIME EXPORT;
113     static const std::string PHOTO_HIDDEN_TIME EXPORT;
114     static const std::string PHOTO_THUMB_STATUS EXPORT;
115     static const std::string PHOTO_ID EXPORT;
116     static const std::string PHOTO_QUALITY EXPORT;
117     static const std::string PHOTO_FIRST_VISIT_TIME EXPORT;
118     static const std::string PHOTO_DEFERRED_PROC_TYPE EXPORT;
119     static const std::string PHOTO_LCD_SIZE EXPORT;
120     static const std::string PHOTO_THUMB_SIZE EXPORT;
121     static const std::string PHOTO_IS_TEMP EXPORT;
122     static const std::string PHOTO_COVER_POSITION EXPORT;
123     static const std::string PHOTO_BURST_COVER_LEVEL EXPORT;
124     static const std::string PHOTO_BURST_KEY EXPORT;
125     static const std::string PHOTO_ORIGINAL_SUBTYPE EXPORT;
126     static const std::string PHOTO_OWNER_ALBUM_ID EXPORT;
127     static const std::string PHOTO_ORIGINAL_ASSET_CLOUD_ID EXPORT;
128     static const std::string PHOTO_SOURCE_PATH EXPORT;
129     static const std::string SUPPORTED_WATERMARK_TYPE EXPORT;
130 
131     // Photo-only default fetch columns
132     static const std::set<std::string> DEFAULT_FETCH_COLUMNS EXPORT;
133     static const std::string PHOTO_DETAIL_TIME EXPORT;
134     // index in PhotoTable
135     static const std::string PHOTO_CLOUD_ID_INDEX EXPORT;
136     static const std::string PHOTO_DATE_YEAR_INDEX EXPORT;
137     static const std::string PHOTO_DATE_MONTH_INDEX EXPORT;
138     static const std::string PHOTO_DATE_DAY_INDEX EXPORT;
139     static const std::string PHOTO_SCHPT_ADDED_INDEX EXPORT;
140     static const std::string PHOTO_SCHPT_ADDED_ALBUM_INDEX EXPORT;
141     static const std::string PHOTO_SCHPT_MEDIA_TYPE_INDEX EXPORT;
142     static const std::string PHOTO_SCHPT_DAY_INDEX EXPORT;
143     static const std::string PHOTO_HIDDEN_TIME_INDEX EXPORT;
144     static const std::string PHOTO_SCHPT_HIDDEN_TIME_INDEX EXPORT;
145     static const std::string PHOTO_FAVORITE_INDEX EXPORT;
146     static const std::string PHOTO_SCHPT_READY_INDEX EXPORT;
147     // for clone query
148     static const std::string PHOTO_DISPLAYNAME_INDEX EXPORT;
149     // for burst query
150     static const std::string PHOTO_BURSTKEY_INDEX EXPORT;
151     // for count query
152     static const std::string PHOTO_SCHPT_MEDIA_TYPE_COUNT_READY_INDEX EXPORT;
153     static const std::string PHOTO_SCHPT_DATE_YEAR_COUNT_READY_INDEX EXPORT;
154     static const std::string PHOTO_SCHPT_DATE_MONTH_COUNT_READY_INDEX EXPORT;
155     // format in PhotoTable year month day
156     static const std::string PHOTO_DATE_YEAR_FORMAT EXPORT;
157     static const std::string PHOTO_DATE_MONTH_FORMAT EXPORT;
158     static const std::string PHOTO_DATE_DAY_FORMAT EXPORT;
159     static const std::string PHOTO_FRONT_CAMERA EXPORT;
160     // cloud enhancement
161     static const std::string PHOTO_CE_AVAILABLE EXPORT;
162     static const std::string PHOTO_CE_STATUS_CODE EXPORT;
163     static const std::string PHOTO_STRONG_ASSOCIATION EXPORT;
164     static const std::string PHOTO_ASSOCIATE_FILE_ID EXPORT;
165     static const std::string PHOTO_HAS_CLOUD_WATERMARK EXPORT;
166     // format in PhotoTable detail time
167     static const std::string PHOTO_DETAIL_TIME_FORMAT EXPORT;
168 
169     // table name
170     static const std::string PHOTOS_TABLE EXPORT;
171 
172     // create PhotoTable sql
173     static const std::string CREATE_PHOTO_TABLE EXPORT;
174     static const std::string CREATE_CLOUD_ID_INDEX EXPORT;
175     static const std::string CREATE_YEAR_INDEX EXPORT;
176     static const std::string CREATE_MONTH_INDEX EXPORT;
177     static const std::string CREATE_DAY_INDEX EXPORT;
178     static const std::string DROP_SCHPT_MEDIA_TYPE_INDEX EXPORT;
179     static const std::string CREATE_SCHPT_MEDIA_TYPE_INDEX EXPORT;
180     static const std::string CREATE_SCHPT_DAY_INDEX EXPORT;
181     static const std::string DROP_SCHPT_DAY_INDEX EXPORT;
182     static const std::string CREATE_HIDDEN_TIME_INDEX EXPORT;
183     static const std::string CREATE_SCHPT_HIDDEN_TIME_INDEX EXPORT;
184     static const std::string DROP_SCHPT_HIDDEN_TIME_INDEX EXPORT;
185     static const std::string CREATE_PHOTO_FAVORITE_INDEX EXPORT;
186     static const std::string DROP_PHOTO_FAVORITE_INDEX EXPORT;
187     static const std::string CREATE_PHOTO_DISPLAYNAME_INDEX EXPORT;
188     static const std::string CREATE_PHOTO_BURSTKEY_INDEX EXPORT;
189     static const std::string UPDATE_READY_ON_THUMBNAIL_UPGRADE EXPORT;
190     static const std::string UPDATA_PHOTOS_DATA_UNIQUE EXPORT;
191     static const std::string UPDATE_LCD_STATUS_NOT_UPLOADED EXPORT;
192 
193     // create indexes for Photo
194     static const std::string INDEX_SCTHP_ADDTIME EXPORT;
195     static const std::string DROP_INDEX_SCTHP_ADDTIME EXPORT;
196     static const std::string DROP_INDEX_SCHPT_ADDTIME_ALBUM EXPORT;
197     static const std::string INDEX_CAMERA_SHOT_KEY EXPORT;
198     static const std::string INDEX_SCHPT_READY EXPORT;
199     static const std::string DROP_INDEX_SCHPT_READY EXPORT;
200     static const std::string CREATE_SCHPT_YEAR_COUNT_READY_INDEX;
201     static const std::string CREATE_SCHPT_MONTH_COUNT_READY_INDEX;
202     static const std::string CREATE_SCHPT_MEDIA_TYPE_COUNT_READY_INDEX;
203     static const std::string DROP_SCHPT_YEAR_COUNT_READY_INDEX;
204     static const std::string DROP_SCHPT_MONTH_COUNT_READY_INDEX;
205     static const std::string DROP_SCHPT_MEDIA_TYPE_COUNT_READY_INDEX;
206 
207     // create Photo cloud sync trigger
208     static const std::string CREATE_PHOTOS_DELETE_TRIGGER EXPORT;
209     static const std::string CREATE_PHOTOS_FDIRTY_TRIGGER EXPORT;
210     static const std::string CREATE_PHOTOS_MDIRTY_TRIGGER EXPORT;
211     static const std::string CREATE_PHOTOS_INSERT_CLOUD_SYNC EXPORT;
212     static const std::string CREATE_PHOTOS_UPDATE_CLOUD_SYNC EXPORT;
213 
214     // photo uri
215     static const std::string PHOTO_URI_PREFIX EXPORT;
216     static const std::string PHOTO_TYPE_URI EXPORT;
217     static const std::string DEFAULT_PHOTO_URI EXPORT;
218     static const std::string PHOTO_CACHE_URI_PREFIX EXPORT;
219 
220     // cloud sync uri
221     static const std::string PHOTO_CLOUD_URI_PREFIX EXPORT;
222 
223     // cloud notify uri
224     static const std::string PHOTO_HEIGHT_ERROR_URI_PREFIX EXPORT;
225     static const std::string PHOTO_DOWNLOAD_SUCCEED_URI_PREFIX EXPORT;
226     // yuv uri
227     static const std::string PHOTO_REQUEST_PICTURE EXPORT;
228     static const std::string PHOTO_REQUEST_PICTURE_BUFFER EXPORT;
229     // all columns
230     static const std::set<std::string> PHOTO_COLUMNS EXPORT;
231 
232     static const std::string QUERY_MEDIA_VOLUME EXPORT;
233 
234     static const std::string HIGHTLIGHT_COVER_URI EXPORT;
235     static const std::string HIGHTLIGHT_URI EXPORT;
236 
237     EXPORT static bool IsPhotoColumn(const std::string &columnName);
238     EXPORT static std::string CheckUploadPhotoColumns();
239 
240     static const std::string PHOTOS_QUERY_FILTER EXPORT;
241 };
242 
243 class AudioColumn : public MediaColumn {
244 public:
245     // column only in AudioTable
246     static const std::string AUDIO_ALBUM EXPORT;
247     static const std::string AUDIO_ARTIST EXPORT;
248 
249     // table name
250     static const std::string AUDIOS_TABLE EXPORT;
251 
252     // create AudioTable sql
253     static const std::string CREATE_AUDIO_TABLE EXPORT;
254 
255     // audio uri
256     static const std::string AUDIO_URI_PREFIX EXPORT;
257     static const std::string AUDIO_TYPE_URI EXPORT;
258     static const std::string DEFAULT_AUDIO_URI EXPORT;
259 
260     // all columns
261     static const std::set<std::string> AUDIO_COLUMNS EXPORT;
262 
263     static const std::string QUERY_MEDIA_VOLUME EXPORT;
264 
265     static bool IsAudioColumn(const std::string &columnName) EXPORT;
266 };
267 
268 class PhotoExtColumn {
269 public:
270     // table name
271     static const std::string PHOTOS_EXT_TABLE EXPORT;
272 
273     // column name
274     static const std::string PHOTO_ID EXPORT;
275     static const std::string THUMBNAIL_SIZE EXPORT;
276 
277     // create table sql
278     static const std::string CREATE_PHOTO_EXT_TABLE EXPORT;
279 };
280 
281 } // namespace OHOS::Media
282 #endif // INTERFACES_INNERKITS_NATIVE_INCLUDE_MEDIA_COLUMN_H_
283