66111d52a3760ad8f0e6ff6d36044e9cc2b3cbdf
[platform/core/multimedia/libmedia-service.git] / src / common / media-svc-media.c
1 /*
2  * libmedia-service
3  *
4  * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
5  *
6  * Contact: Hyunjun Ko <zzoon.ko@samsung.com>, Haejeong Kim <backto.kim@samsung.com>
7  *
8  * Licensed under the Apache License, Version 2.0 (the "License");
9  * you may not use this file except in compliance with the License.
10  * You may obtain a copy of the License at
11  *
12  * http://www.apache.org/licenses/LICENSE-2.0
13  *
14  * Unless required by applicable law or agreed to in writing, software
15  * distributed under the License is distributed on an "AS IS" BASIS,
16  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17  * See the License for the specific language governing permissions and
18  * limitations under the License.
19  *
20  */
21
22 #include <string.h>
23 #include <unistd.h>
24 #include <sys/types.h>
25 #include <grp.h>
26 #include <pwd.h>
27 #include <media-util-err.h>
28 #include "media-svc-media.h"
29 #include "media-svc-media-folder.h"
30 #include "media-svc-debug.h"
31 #include "media-svc-util.h"
32 #include "media-svc-db-utils.h"
33 #include "media-svc-noti.h"
34
35 #define GLOBAL_USER    0 /*#define     tzplatform_getenv(TZ_GLOBAL) //TODO */
36
37 typedef struct {
38         char thumbnail_path[MEDIA_SVC_PATHNAME_SIZE];
39 } media_svc_thumbnailpath_s;
40
41 static __thread GList *g_media_svc_item_validity_query_list = NULL;
42 static __thread GList *g_media_svc_insert_item_query_list = NULL;
43 __thread GList *g_media_svc_move_item_query_list = NULL;
44 static __thread GList *g_media_svc_update_item_query_list = NULL;
45
46 static int __media_svc_count_invalid_records_with_thumbnail(sqlite3 *handle, media_svc_storage_type_e storage_type, int *count);
47 static int __media_svc_get_invalid_records_with_thumbnail(sqlite3 *handle, media_svc_storage_type_e storage_type,
48                                                           int count, media_svc_thumbnailpath_s *thumb_path);
49 static int __media_svc_count_invalid_folder_records_with_thumbnail(sqlite3 *handle, const char *folder_path, int *count);
50 static int __media_svc_get_invalid_folder_records_with_thumbnail(sqlite3 *handle, const char *folder_path,
51                                                                  int count, media_svc_thumbnailpath_s *thumb_path);
52
53 static int __media_svc_count_invalid_records_with_thumbnail(sqlite3 *handle, media_svc_storage_type_e storage_type, int *count)
54 {
55         int ret = MS_MEDIA_ERR_NONE;
56         sqlite3_stmt *sql_stmt = NULL;
57         char *sql = sqlite3_mprintf("SELECT count(*) FROM %s WHERE validity=0 AND storage_type=%d AND thumbnail_path IS NOT NULL",
58                                     MEDIA_SVC_DB_TABLE_MEDIA, storage_type);
59
60         ret = _media_svc_sql_prepare_to_step(handle, sql, &sql_stmt);
61
62         if (ret != MS_MEDIA_ERR_NONE) {
63                 media_svc_error("error when __media_svc_count_invalid_records_with_thumbnail. err = [%d]", ret);
64                 return ret;
65         }
66
67         *count = sqlite3_column_int(sql_stmt, 0);
68
69         SQLITE3_FINALIZE(sql_stmt);
70
71         return MS_MEDIA_ERR_NONE;
72
73 }
74
75 static int __media_svc_get_invalid_records_with_thumbnail(sqlite3 *handle, media_svc_storage_type_e storage_type,
76                                                           int count, media_svc_thumbnailpath_s *thumb_path)
77 {
78         int ret = MS_MEDIA_ERR_NONE;
79         sqlite3_stmt *sql_stmt = NULL;
80         int idx = 0;
81
82         char *sql = sqlite3_mprintf("SELECT thumbnail_path from (select thumbnail_path, validity from %s WHERE storage_type=%d AND thumbnail_path IS NOT NULL GROUP BY thumbnail_path HAVING count() = 1) WHERE validity=0",
83                                     MEDIA_SVC_DB_TABLE_MEDIA, storage_type);
84
85         media_svc_debug("[SQL query] : %s", sql);
86
87         ret = _media_svc_sql_prepare_to_step(handle, sql, &sql_stmt);
88         if (ret != MS_MEDIA_ERR_NONE) {
89                 media_svc_error("error when __media_svc_get_invalid_records_with_thumbnail. err = [%d]", ret);
90                 return ret;
91         }
92
93         while (sqlite3_step(sql_stmt) == SQLITE_ROW) {
94                 _strncpy_safe(thumb_path[idx].thumbnail_path, (const char *)sqlite3_column_text(sql_stmt, 0), sizeof(thumb_path[idx]));
95                 /*media_svc_debug("thumb_path[%d]=[%s]", idx, thumb_path[idx].thumbnail_path); */
96                 idx++;
97         }
98
99         SQLITE3_FINALIZE(sql_stmt);
100
101         return MS_MEDIA_ERR_NONE;
102 }
103
104 static int __media_svc_count_invalid_folder_records_with_thumbnail(sqlite3 *handle, const char *folder_path, int *count)
105 {
106         int ret = MS_MEDIA_ERR_NONE;
107         sqlite3_stmt *sql_stmt = NULL;
108         char *sql = sqlite3_mprintf("SELECT count(*) FROM %s WHERE validity=0 AND path LIKE '%q/%%' AND thumbnail_path IS NOT NULL",
109                                     MEDIA_SVC_DB_TABLE_MEDIA, folder_path);
110
111         ret = _media_svc_sql_prepare_to_step(handle, sql, &sql_stmt);
112
113         if (ret != MS_MEDIA_ERR_NONE) {
114                 media_svc_error("error when __media_svc_count_invalid_folder_records_with_thumbnail. err = [%d]", ret);
115                 return ret;
116         }
117
118         *count = sqlite3_column_int(sql_stmt, 0);
119
120         SQLITE3_FINALIZE(sql_stmt);
121
122         return MS_MEDIA_ERR_NONE;
123
124 }
125
126 static int __media_svc_get_invalid_folder_records_with_thumbnail(sqlite3 *handle, const char *folder_path,
127                                                                  int count, media_svc_thumbnailpath_s *thumb_path)
128 {
129         int ret = MS_MEDIA_ERR_NONE;
130         sqlite3_stmt *sql_stmt = NULL;
131         int idx = 0;
132
133         char *sql = sqlite3_mprintf("SELECT thumbnail_path from (select thumbnail_path, validity from %s WHERE path LIKE '%q/%%' AND thumbnail_path IS NOT NULL GROUP BY thumbnail_path HAVING count() = 1) WHERE validity=0",
134                                     MEDIA_SVC_DB_TABLE_MEDIA, folder_path);
135
136         media_svc_debug("[SQL query] : %s", sql);
137
138         ret = _media_svc_sql_prepare_to_step_simple(handle, sql, &sql_stmt);
139         if (ret != MS_MEDIA_ERR_NONE) {
140                 media_svc_error("error when __media_svc_get_invalid_folder_records_with_thumbnail. err = [%d]", ret);
141                 return ret;
142         }
143
144         while (sqlite3_step(sql_stmt) == SQLITE_ROW) {
145                 _strncpy_safe(thumb_path[idx].thumbnail_path, (const char *)sqlite3_column_text(sql_stmt, 0), sizeof(thumb_path[idx]));
146                 idx++;
147         }
148
149         SQLITE3_FINALIZE(sql_stmt);
150
151         return MS_MEDIA_ERR_NONE;
152 }
153
154 int _media_svc_count_record_with_path(sqlite3 *handle, const char *path, int *count)
155 {
156         int ret = MS_MEDIA_ERR_NONE;
157         sqlite3_stmt *sql_stmt = NULL;
158
159         char *sql = sqlite3_mprintf("SELECT count(*) FROM %s WHERE path='%q'", MEDIA_SVC_DB_TABLE_MEDIA, path);
160
161         ret = _media_svc_sql_prepare_to_step(handle, sql, &sql_stmt);
162
163         media_svc_retv_if(ret != MS_MEDIA_ERR_NONE, ret);
164
165         *count = sqlite3_column_int(sql_stmt, 0);
166
167         SQLITE3_FINALIZE(sql_stmt);
168
169         return MS_MEDIA_ERR_NONE;
170 }
171
172 char *_media_svc_get_thumb_default_path(uid_t uid)
173 {
174         char *result_psswd = NULL;
175         struct group *grpinfo = NULL;
176         if (uid == getuid()) {
177                 result_psswd = strdup(MEDIA_SVC_THUMB_DEFAULT_PATH);
178                 grpinfo = getgrnam("users");
179                 if (grpinfo == NULL) {
180                         media_svc_error("getgrnam(users) returns NULL !");
181                         return NULL;
182                 }
183         } else {
184                 struct passwd *userinfo = getpwuid(uid);
185                 if (userinfo == NULL) {
186                         media_svc_error("getpwuid(%d) returns NULL !", uid);
187                         return NULL;
188                 }
189                 grpinfo = getgrnam("users");
190                 if (grpinfo == NULL) {
191                         media_svc_error("getgrnam(users) returns NULL !");
192                         return NULL;
193                 }
194                 /* Compare git_t type and not group name */
195                 if (grpinfo->gr_gid != userinfo->pw_gid) {
196                         media_svc_error("UID [%d] does not belong to 'users' group!", uid);
197                         return NULL;
198                 }
199                 asprintf(&result_psswd, "%s/data/file-manager-service/.thumb/thumb_default.png", userinfo->pw_dir);
200         }
201
202         return result_psswd;
203 }
204
205 int _media_svc_insert_item_with_data(sqlite3 *handle, media_svc_content_info_s *content_info, int is_burst, bool stack_query, uid_t uid)
206 {
207         int ret = MS_MEDIA_ERR_NONE;
208         char *burst_id = NULL;
209
210         char *db_fields = "media_uuid, path, file_name, media_type, mime_type, size, added_time, modified_time, folder_uuid, \
211                                         thumbnail_path, title, album_id, album, artist, album_artist, genre, composer, year, recorded_date, copyright, track_num, description, \
212                                         bitrate, bitpersample, samplerate, channel, duration, longitude, latitude, altitude, exposure_time, fnumber, iso, model, width, height, datetaken, orientation, \
213                                         rating, is_drm, storage_type, burst_id, timeline, weather, sync_status, \
214                                         file_name_pinyin, title_pinyin, album_pinyin, artist_pinyin, album_artist_pinyin, genre_pinyin, composer_pinyin, copyright_pinyin, description_pinyin, storage_uuid";
215
216         /* This sql is due to sqlite3_mprintf's wrong operation when using floating point in the text format */
217         /* This code will be removed when sqlite3_mprintf works clearly */
218         char *test_sql = sqlite3_mprintf("%f, %f, %f", content_info->media_meta.longitude, content_info->media_meta.latitude, content_info->media_meta.altitude);
219         sqlite3_free(test_sql);
220
221         if (is_burst) {
222                 int burst_id_int = 0;
223                 ret = _media_svc_get_burst_id(handle, &burst_id_int);
224                 if (ret != MS_MEDIA_ERR_NONE) {
225                         burst_id = NULL;
226                 }
227
228                 if (burst_id_int > 0) {
229                         media_svc_debug("Burst id : %d", burst_id_int);
230                         burst_id = sqlite3_mprintf("%d", burst_id_int);
231                 }
232
233                 /* Get thumbnail for burst shot */
234                 char thumb_path[MEDIA_SVC_PATHNAME_SIZE + 1] = {0, };
235                 int width = 0;
236                 int height = 0;
237
238                 ret = _media_svc_request_thumbnail_with_origin_size(content_info->path, thumb_path, sizeof(thumb_path), &width, &height, uid);
239                 if (ret == MS_MEDIA_ERR_NONE) {
240
241                         ret = __media_svc_malloc_and_strncpy(&(content_info->thumbnail_path), thumb_path);
242                         if (ret != MS_MEDIA_ERR_NONE) {
243                                 content_info->thumbnail_path = NULL;
244                         }
245                 }
246
247                 if (content_info->media_meta.width <= 0)
248                         content_info->media_meta.width = width;
249
250                 if (content_info->media_meta.height <= 0)
251                         content_info->media_meta.height = height;
252         }
253
254         /*Update Pinyin If Support Pinyin*/
255         if (_media_svc_check_pinyin_support()) {
256                 if (STRING_VALID(content_info->file_name))
257                         _media_svc_get_pinyin_str(content_info->file_name, &content_info->file_name_pinyin);
258                 if (STRING_VALID(content_info->media_meta.title))
259                         _media_svc_get_pinyin_str(content_info->media_meta.title, &content_info->media_meta.title_pinyin);
260                 if (STRING_VALID(content_info->media_meta.album))
261                         _media_svc_get_pinyin_str(content_info->media_meta.album, &content_info->media_meta.album_pinyin);
262                 if (STRING_VALID(content_info->media_meta.artist))
263                         _media_svc_get_pinyin_str(content_info->media_meta.artist, &content_info->media_meta.artist_pinyin);
264                 if (STRING_VALID(content_info->media_meta.album_artist))
265                         _media_svc_get_pinyin_str(content_info->media_meta.album_artist, &content_info->media_meta.album_artist_pinyin);
266                 if (STRING_VALID(content_info->media_meta.genre))
267                         _media_svc_get_pinyin_str(content_info->media_meta.genre, &content_info->media_meta.genre_pinyin);
268                 if (STRING_VALID(content_info->media_meta.composer))
269                         _media_svc_get_pinyin_str(content_info->media_meta.composer, &content_info->media_meta.composer_pinyin);
270                 if (STRING_VALID(content_info->media_meta.copyright))
271                         _media_svc_get_pinyin_str(content_info->media_meta.copyright, &content_info->media_meta.copyright_pinyin);
272                 if (STRING_VALID(content_info->media_meta.description))
273                         _media_svc_get_pinyin_str(content_info->media_meta.description, &content_info->media_meta.description_pinyin);
274         }
275
276         char *sql = sqlite3_mprintf("INSERT INTO '%s' (%s) VALUES (%Q, %Q, %Q, %d, %Q, %lld, %d, %d, %Q, \
277                                                                                                         %Q, %Q, %d, %Q, %Q, %Q, %Q, %Q, %Q, %Q, %Q, %Q, %Q, \
278                                                                                                         %d, %d, %d, %d, %d, %.6f, %.6f, %.6f, %Q, %.6f, %d, %Q, %d, %d, %Q, %d, \
279                                                                                                         %d, %d, %d, %Q, %d, %Q, %d, \
280                                                                                                         %Q, %Q, %Q, %Q, %Q, %Q, %Q, %Q, %Q, %Q);",
281                                                                 content_info->storage_uuid, db_fields,
282                                                                 content_info->media_uuid,
283                                                                 content_info->path,
284                                                                 content_info->file_name,
285                                                                 content_info->media_type,
286                                                                 content_info->mime_type,
287                                                                 content_info->size,
288                                                                 content_info->added_time,
289                                                                 content_info->modified_time,
290                                                                 content_info->folder_uuid,
291                                                                 content_info->thumbnail_path,
292                                                                 content_info->media_meta.title,
293                                                                 content_info->album_id,
294                                                                 content_info->media_meta.album,
295                                                                 content_info->media_meta.artist,
296                                                                 content_info->media_meta.album_artist,
297                                                                 content_info->media_meta.genre,
298                                                                 content_info->media_meta.composer,
299                                                                 content_info->media_meta.year,
300                                                                 content_info->media_meta.recorded_date,
301                                                                 content_info->media_meta.copyright,
302                                                                 content_info->media_meta.track_num,
303                                                                 content_info->media_meta.description,
304                                                                 content_info->media_meta.bitrate,
305                                                                 content_info->media_meta.bitpersample,
306                                                                 content_info->media_meta.samplerate,
307                                                                 content_info->media_meta.channel,
308                                                                 content_info->media_meta.duration,
309                                                                 content_info->media_meta.longitude,
310                                                                 content_info->media_meta.latitude,
311                                                                 content_info->media_meta.altitude,
312                                                                 content_info->media_meta.exposure_time,
313                                                                 content_info->media_meta.fnumber,
314                                                                 content_info->media_meta.iso,
315                                                                 content_info->media_meta.model,
316                                                                 content_info->media_meta.width,
317                                                                 content_info->media_meta.height,
318                                                                 content_info->media_meta.datetaken,
319                                                                 content_info->media_meta.orientation,
320                                                                 content_info->media_meta.rating,
321                                                                 content_info->is_drm,
322                                                                 content_info->storage_type,
323                                                                 burst_id,
324                                                                 content_info->timeline,
325                                                                 content_info->media_meta.weather,
326                                                                 content_info->sync_status,
327                                                                 content_info->file_name_pinyin,
328                                                                 content_info->media_meta.title_pinyin,
329                                                                 content_info->media_meta.album_pinyin,
330                                                                 content_info->media_meta.artist_pinyin,
331                                                                 content_info->media_meta.album_artist_pinyin,
332                                                                 content_info->media_meta.genre_pinyin,
333                                                                 content_info->media_meta.composer_pinyin,
334                                                                 content_info->media_meta.copyright_pinyin,
335                                                                 content_info->media_meta.description_pinyin,
336                                                                 content_info->storage_uuid
337                                    );
338
339         if (burst_id) {
340                 sqlite3_free(burst_id);
341                 burst_id = NULL;
342         }
343
344         if (!stack_query) {
345                 ret = _media_svc_sql_query(handle, sql, uid);
346                 sqlite3_free(sql);
347                 if (ret != MS_MEDIA_ERR_NONE) {
348                         media_svc_error("failed to insert item");
349                         return ret;
350                 }
351         } else {
352                 media_svc_debug("query : %s", sql);
353                 _media_svc_sql_query_add(&g_media_svc_insert_item_query_list, &sql);
354         }
355
356         return MS_MEDIA_ERR_NONE;
357 }
358
359 int _media_svc_update_meta_with_data(sqlite3 *handle, media_svc_content_info_s *content_info)
360 {
361         int ret = MS_MEDIA_ERR_NONE;
362
363         /* This sql is due to sqlite3_mprintf's wrong operation when using floating point in the text format */
364         /* This code will be removed when sqlite3_mprintf works clearly */
365         char *test_sql = sqlite3_mprintf("%f, %f, %f", content_info->media_meta.longitude, content_info->media_meta.latitude, content_info->media_meta.altitude);
366         sqlite3_free(test_sql);
367
368         /*Update Pinyin If Support Pinyin*/
369         if (_media_svc_check_pinyin_support()) {
370                 if (STRING_VALID(content_info->file_name))
371                         _media_svc_get_pinyin_str(content_info->file_name, &content_info->file_name_pinyin);
372                 if (STRING_VALID(content_info->media_meta.title))
373                         _media_svc_get_pinyin_str(content_info->media_meta.title, &content_info->media_meta.title_pinyin);
374                 if (STRING_VALID(content_info->media_meta.album))
375                         _media_svc_get_pinyin_str(content_info->media_meta.album, &content_info->media_meta.album_pinyin);
376                 if (STRING_VALID(content_info->media_meta.artist))
377                         _media_svc_get_pinyin_str(content_info->media_meta.artist, &content_info->media_meta.artist_pinyin);
378                 if (STRING_VALID(content_info->media_meta.album_artist))
379                         _media_svc_get_pinyin_str(content_info->media_meta.album_artist, &content_info->media_meta.album_artist_pinyin);
380                 if (STRING_VALID(content_info->media_meta.genre))
381                         _media_svc_get_pinyin_str(content_info->media_meta.genre, &content_info->media_meta.genre_pinyin);
382                 if (STRING_VALID(content_info->media_meta.composer))
383                         _media_svc_get_pinyin_str(content_info->media_meta.composer, &content_info->media_meta.composer_pinyin);
384                 if (STRING_VALID(content_info->media_meta.copyright))
385                         _media_svc_get_pinyin_str(content_info->media_meta.copyright, &content_info->media_meta.copyright_pinyin);
386                 if (STRING_VALID(content_info->media_meta.description))
387                         _media_svc_get_pinyin_str(content_info->media_meta.description, &content_info->media_meta.description_pinyin);
388         }
389
390         char *sql = sqlite3_mprintf("UPDATE %s SET title=%Q, album=%Q, artist=%Q, album_artist=%Q, genre=%Q, composer=%Q, copyright=%Q, description=%Q, \
391                 file_name_pinyin=%Q, title_pinyin=%Q, album_pinyin=%Q, artist_pinyin=%Q, album_artist_pinyin=%Q, genre_pinyin=%Q, composer_pinyin=%Q, copyright_pinyin=%Q, description_pinyin=%Q \
392                 WHERE path=%Q",
393                                                                 MEDIA_SVC_DB_TABLE_MEDIA,
394                                                                 content_info->media_meta.title,
395                                                                 content_info->media_meta.album,
396                                                                 content_info->media_meta.artist,
397                                                                 content_info->media_meta.album_artist,
398                                                                 content_info->media_meta.genre,
399                                                                 content_info->media_meta.composer,
400                                                                 content_info->media_meta.copyright,
401                                                                 content_info->media_meta.description,
402                                                                 content_info->file_name_pinyin,
403                                                                 content_info->media_meta.title_pinyin,
404                                                                 content_info->media_meta.album_pinyin,
405                                                                 content_info->media_meta.artist_pinyin,
406                                                                 content_info->media_meta.album_artist_pinyin,
407                                                                 content_info->media_meta.genre_pinyin,
408                                                                 content_info->media_meta.composer_pinyin,
409                                                                 content_info->media_meta.copyright_pinyin,
410                                                                 content_info->media_meta.description_pinyin,
411                                                                 content_info->path
412                                    );
413
414         media_svc_error("");
415         if (sql != NULL) {
416                 media_svc_debug("query : %s", sql);
417                 _media_svc_sql_query_add(&g_media_svc_update_item_query_list, &sql);
418         } else {
419                 media_svc_error("sqlite3_mprintf failed");
420                 ret = MS_MEDIA_ERR_OUT_OF_MEMORY;
421         }
422
423         media_svc_error("");
424
425         return ret;
426 }
427
428 int _media_svc_update_item_with_data(sqlite3 *handle, const char *storage_id, media_svc_content_info_s *content_info, uid_t uid)
429 {
430         int ret = MS_MEDIA_ERR_NONE;
431
432         /* This sql is due to sqlite3_mprintf's wrong operation when using floating point in the text format */
433         /* This code will be removed when sqlite3_mprintf works clearly */
434         char *test_sql = sqlite3_mprintf("%f, %f, %f", content_info->media_meta.longitude, content_info->media_meta.latitude, content_info->media_meta.altitude);
435         sqlite3_free(test_sql);
436
437         /*Update Pinyin If Support Pinyin*/
438         if (_media_svc_check_pinyin_support()) {
439                 if (STRING_VALID(content_info->file_name))
440                         _media_svc_get_pinyin_str(content_info->file_name, &content_info->file_name_pinyin);
441                 if (STRING_VALID(content_info->media_meta.title))
442                         _media_svc_get_pinyin_str(content_info->media_meta.title, &content_info->media_meta.title_pinyin);
443                 if (STRING_VALID(content_info->media_meta.album))
444                         _media_svc_get_pinyin_str(content_info->media_meta.album, &content_info->media_meta.album_pinyin);
445                 if (STRING_VALID(content_info->media_meta.artist))
446                         _media_svc_get_pinyin_str(content_info->media_meta.artist, &content_info->media_meta.artist_pinyin);
447                 if (STRING_VALID(content_info->media_meta.album_artist))
448                         _media_svc_get_pinyin_str(content_info->media_meta.album_artist, &content_info->media_meta.album_artist_pinyin);
449                 if (STRING_VALID(content_info->media_meta.genre))
450                         _media_svc_get_pinyin_str(content_info->media_meta.genre, &content_info->media_meta.genre_pinyin);
451                 if (STRING_VALID(content_info->media_meta.composer))
452                         _media_svc_get_pinyin_str(content_info->media_meta.composer, &content_info->media_meta.composer_pinyin);
453                 if (STRING_VALID(content_info->media_meta.copyright))
454                         _media_svc_get_pinyin_str(content_info->media_meta.copyright, &content_info->media_meta.copyright_pinyin);
455                 if (STRING_VALID(content_info->media_meta.description))
456                         _media_svc_get_pinyin_str(content_info->media_meta.description, &content_info->media_meta.description_pinyin);
457         }
458
459         char *sql = sqlite3_mprintf("UPDATE '%s' SET \
460                 size=%lld, modified_time=%d, thumbnail_path=%Q, title=%Q, album_id=%d, album=%Q, artist=%Q, album_artist=%Q, genre=%Q, \
461                 composer=%Q, year=%Q, recorded_date=%Q, copyright=%Q, track_num=%Q, description=%Q, \
462                 bitrate=%d, bitpersample=%d, samplerate=%d, channel=%d, duration=%d, longitude=%f, latitude=%f, altitude=%f, exposure_time=%Q, fnumber=%f, iso=%d, model=%Q, width=%d, height=%d, datetaken=%Q, \
463                                                                                                         orientation=%d WHERE path=%Q",
464                                                                 storage_id,
465                                                                 content_info->size,
466                                                                 content_info->modified_time,
467                                                                 content_info->thumbnail_path,
468                                                                 content_info->media_meta.title,
469                                                                 content_info->album_id,
470                                                                 content_info->media_meta.album,
471                                                                 content_info->media_meta.artist,
472                                                                 content_info->media_meta.album_artist,
473                                                                 content_info->media_meta.genre,
474                                                                 content_info->media_meta.composer,
475                                                                 content_info->media_meta.year,
476                                                                 content_info->media_meta.recorded_date,
477                                                                 content_info->media_meta.copyright,
478                                                                 content_info->media_meta.track_num,
479                                                                 content_info->media_meta.description,
480                                                                 content_info->media_meta.bitrate,
481                                                                 content_info->media_meta.bitpersample,
482                                                                 content_info->media_meta.samplerate,
483                                                                 content_info->media_meta.channel,
484                                                                 content_info->media_meta.duration,
485                                                                 content_info->media_meta.longitude,
486                                                                 content_info->media_meta.latitude,
487                                                                 content_info->media_meta.altitude,
488                                                                 content_info->media_meta.exposure_time,
489                                                                 content_info->media_meta.fnumber,
490                                                                 content_info->media_meta.iso,
491                                                                 content_info->media_meta.model,
492                                                                 content_info->media_meta.width,
493                                                                 content_info->media_meta.height,
494                                                                 content_info->media_meta.datetaken,
495                                                                 content_info->media_meta.orientation,
496                                                                 content_info->path
497                                    );
498
499         ret = _media_svc_sql_query(handle, sql, uid);
500         sqlite3_free(sql);
501
502         return ret;
503 }
504 int _media_svc_get_thumbnail_path_by_path(sqlite3 *handle, const char *storage_id, const char *path, char *thumbnail_path)
505 {
506         int ret = MS_MEDIA_ERR_NONE;
507         sqlite3_stmt *sql_stmt = NULL;
508
509         char *sql = sqlite3_mprintf("SELECT thumbnail_path FROM '%s' WHERE path='%q'", storage_id, path);
510
511         ret = _media_svc_sql_prepare_to_step(handle, sql, &sql_stmt);
512
513         if (ret != MS_MEDIA_ERR_NONE) {
514                 if (ret == MS_MEDIA_ERR_DB_NO_RECORD) {
515                         media_svc_debug("there is no thumbnail.");
516                 } else {
517                         media_svc_error("error when _media_svc_get_thumbnail_path_by_path. err = [%d]", ret);
518                 }
519                 return ret;
520         }
521
522         _strncpy_safe(thumbnail_path, (const char *)sqlite3_column_text(sql_stmt, 0), MEDIA_SVC_PATHNAME_SIZE);
523
524         SQLITE3_FINALIZE(sql_stmt);
525
526         return MS_MEDIA_ERR_NONE;
527 }
528
529 int _media_svc_get_media_type_by_path(sqlite3 *handle, const char *storage_id, const char *path, int *media_type)
530 {
531         int ret = MS_MEDIA_ERR_NONE;
532         sqlite3_stmt *sql_stmt = NULL;
533
534         char *sql = sqlite3_mprintf("SELECT media_type FROM '%s' WHERE path='%q'", storage_id, path);
535
536         ret = _media_svc_sql_prepare_to_step(handle, sql, &sql_stmt);
537
538         if (ret != MS_MEDIA_ERR_NONE) {
539                 media_svc_error("error when _media_svc_get_media_type_by_path. err = [%d]", ret);
540                 return ret;
541         }
542
543         *media_type = sqlite3_column_int(sql_stmt, 0);
544
545         SQLITE3_FINALIZE(sql_stmt);
546
547         return MS_MEDIA_ERR_NONE;
548 }
549
550 int _media_svc_delete_item_by_path(sqlite3 *handle, const char *storage_id, const char *path, bool stack_query, uid_t uid)
551 {
552         int ret = MS_MEDIA_ERR_NONE;
553         char *sql = sqlite3_mprintf("DELETE FROM '%s' WHERE path='%q'", storage_id, path);
554
555         if (!stack_query) {
556                 ret = _media_svc_sql_query(handle, sql, uid);
557                 sqlite3_free(sql);
558                 if (ret != MS_MEDIA_ERR_NONE) {
559                         media_svc_error("failed to delete item");
560                         return ret;
561                 }
562         } else {
563                 media_svc_debug("query : %s", sql);
564                 _media_svc_sql_query_add(&g_media_svc_insert_item_query_list, &sql);
565         }
566
567         return ret;
568 }
569
570 int _media_svc_truncate_table(sqlite3 *handle, media_svc_storage_type_e storage_type, uid_t uid)
571 {
572         int ret = MS_MEDIA_ERR_NONE;
573         char *sql = sqlite3_mprintf("DELETE FROM %s WHERE storage_type=%d", MEDIA_SVC_DB_TABLE_MEDIA, storage_type);
574
575         ret = _media_svc_sql_query(handle, sql, uid);
576         sqlite3_free(sql);
577
578         return ret;
579 }
580
581 int _media_svc_delete_invalid_items(sqlite3 *handle, media_svc_storage_type_e storage_type, uid_t uid)
582 {
583         int idx = 0;
584         media_svc_thumbnailpath_s *thumbpath_record = NULL;
585         int invalid_count = 0;
586         int ret = MS_MEDIA_ERR_NONE;
587
588         ret = __media_svc_count_invalid_records_with_thumbnail(handle, storage_type, &invalid_count);
589         media_svc_retv_if(ret != MS_MEDIA_ERR_NONE, ret);
590
591         media_svc_debug("invalid count: %d", invalid_count);
592
593         if (invalid_count > 0) {
594                 thumbpath_record = (media_svc_thumbnailpath_s *)calloc(invalid_count, sizeof(media_svc_thumbnailpath_s));
595                 if (thumbpath_record == NULL) {
596                         media_svc_error("fail to memory allocation");
597                         return MS_MEDIA_ERR_OUT_OF_MEMORY;
598                 }
599
600                 ret = __media_svc_get_invalid_records_with_thumbnail(handle, storage_type, invalid_count, thumbpath_record);
601                 if (ret != MS_MEDIA_ERR_NONE) {
602                         media_svc_error("error when get thumbnail record");
603                         SAFE_FREE(thumbpath_record);
604                         return ret;
605                 }
606         } else {
607                 media_svc_debug("There is no item with thumbnail");
608         }
609
610         char *sql = sqlite3_mprintf("DELETE FROM %s WHERE validity = 0 AND storage_type=%d", MEDIA_SVC_DB_TABLE_MEDIA, storage_type);
611         ret = _media_svc_sql_query(handle, sql, uid);
612         sqlite3_free(sql);
613         if (ret != MS_MEDIA_ERR_NONE) {
614                 SAFE_FREE(thumbpath_record);
615                 return ret;
616         }
617
618         /*Delete thumbnails*/
619         for (idx = 0; idx < invalid_count; idx++) {
620                 if ((strlen(thumbpath_record[idx].thumbnail_path) > 0) && (strncmp(thumbpath_record[idx].thumbnail_path, _media_svc_get_thumb_default_path(uid), sizeof(_media_svc_get_thumb_default_path(uid))) != 0)) {
621                         ret = _media_svc_remove_file(thumbpath_record[idx].thumbnail_path);
622                         if (ret != MS_MEDIA_ERR_NONE) {
623                                 media_svc_error("fail to remove thumbnail file.");
624                         }
625                 }
626         }
627
628         SAFE_FREE(thumbpath_record);
629
630         return MS_MEDIA_ERR_NONE;
631 }
632
633 int _media_svc_delete_invalid_folder_items(sqlite3 *handle, const char *folder_path, uid_t uid)
634 {
635         int idx = 0;
636         media_svc_thumbnailpath_s *thumbpath_record = NULL;
637         int invalid_count = 0;
638         int ret = MS_MEDIA_ERR_NONE;
639
640         ret = __media_svc_count_invalid_folder_records_with_thumbnail(handle, folder_path, &invalid_count);
641         media_svc_retv_if(ret != MS_MEDIA_ERR_NONE, ret);
642
643         media_svc_debug("invalid count: %d", invalid_count);
644
645         if (invalid_count > 0) {
646                 thumbpath_record = (media_svc_thumbnailpath_s *)calloc(invalid_count, sizeof(media_svc_thumbnailpath_s));
647                 if (thumbpath_record == NULL) {
648                         media_svc_error("fail to memory allocation");
649                         return MS_MEDIA_ERR_OUT_OF_MEMORY;
650                 }
651
652                 ret = __media_svc_get_invalid_folder_records_with_thumbnail(handle, folder_path, invalid_count, thumbpath_record);
653                 if (ret != MS_MEDIA_ERR_NONE) {
654                         media_svc_error("error when get thumbnail record");
655                         SAFE_FREE(thumbpath_record);
656                         return ret;
657                 }
658         } else {
659                 media_svc_debug("There is no item with thumbnail");
660         }
661
662         char *sql = sqlite3_mprintf("DELETE FROM %s WHERE validity = 0 AND path LIKE '%q/%%'", MEDIA_SVC_DB_TABLE_MEDIA, folder_path);
663         ret = _media_svc_sql_query(handle, sql, uid);
664         sqlite3_free(sql);
665         if (ret != MS_MEDIA_ERR_NONE) {
666                 SAFE_FREE(thumbpath_record);
667                 return ret;
668         }
669
670         /*Delete thumbnails*/
671         for (idx = 0; idx < invalid_count; idx++) {
672                 if ((strlen(thumbpath_record[idx].thumbnail_path) > 0) && (strncmp(thumbpath_record[idx].thumbnail_path, _media_svc_get_thumb_default_path(uid), sizeof(_media_svc_get_thumb_default_path(uid))) != 0)) {
673                         ret = _media_svc_remove_file(thumbpath_record[idx].thumbnail_path);
674                         if (ret != MS_MEDIA_ERR_NONE) {
675                                 media_svc_error("fail to remove thumbnail file.");
676                         }
677                 }
678         }
679
680         SAFE_FREE(thumbpath_record);
681
682         return MS_MEDIA_ERR_NONE;
683 }
684
685 int _media_svc_update_item_validity(sqlite3 *handle, const char *path, int validity, bool stack_query, uid_t uid)
686 {
687         int ret = MS_MEDIA_ERR_NONE;
688
689         char *sql = sqlite3_mprintf("UPDATE %s SET validity=%d WHERE path= '%q'", MEDIA_SVC_DB_TABLE_MEDIA, validity, path);
690
691         if (!stack_query) {
692                 ret = _media_svc_sql_query(handle, sql, uid);
693                 sqlite3_free(sql);
694         } else {
695                 _media_svc_sql_query_add(&g_media_svc_item_validity_query_list, &sql);
696         }
697
698         return ret;
699 }
700
701 int _media_svc_update_thumbnail_path(sqlite3 *handle,  const char *storage_id, const char *path, const char *thumb_path, uid_t uid)
702 {
703         int ret = MS_MEDIA_ERR_NONE;
704
705         char *sql = sqlite3_mprintf("UPDATE '%s' SET thumbnail_path=%Q WHERE path= %Q", storage_id, thumb_path, path);
706
707         ret = _media_svc_sql_query(handle, sql, uid);
708         sqlite3_free(sql);
709
710         return ret;
711 }
712
713 int _media_svc_update_storage_item_validity(sqlite3 *handle, media_svc_storage_type_e storage_type, int validity, uid_t uid)
714 {
715         int ret = MS_MEDIA_ERR_NONE;
716
717         char *sql = sqlite3_mprintf("UPDATE %s SET validity=%d WHERE storage_type=%d", MEDIA_SVC_DB_TABLE_MEDIA, validity, storage_type);
718
719         ret = _media_svc_sql_query(handle, sql, uid);
720         sqlite3_free(sql);
721
722         return ret;
723 }
724
725 int _media_svc_update_folder_item_validity(sqlite3 *handle, const char *folder_path, int validity, uid_t uid)
726 {
727         int ret = MS_MEDIA_ERR_NONE;
728         char *sql = NULL;
729         char folder_uuid[MEDIA_SVC_UUID_SIZE + 1] = {0, };
730         sqlite3_stmt *sql_stmt = NULL;
731
732         /*Get folder ID*/
733         sql = sqlite3_mprintf("SELECT folder_uuid FROM %s WHERE path='%q'", MEDIA_SVC_DB_TABLE_FOLDER, folder_path);
734         ret = _media_svc_sql_prepare_to_step(handle, sql, &sql_stmt);
735         if (ret != MS_MEDIA_ERR_NONE) {
736                 if (ret == MS_MEDIA_ERR_DB_NO_RECORD)
737                         media_svc_debug("folder not exist");
738                 else
739                         media_svc_error("error when get folder_id. err = [%d]", ret);
740
741                 return ret;
742         }
743
744         _strncpy_safe(folder_uuid, (const char *)sqlite3_column_text(sql_stmt, 0), MEDIA_SVC_UUID_SIZE + 1);
745         SQLITE3_FINALIZE(sql_stmt);
746
747         /*Update folder item validity*/
748         sql = sqlite3_mprintf("UPDATE %s SET validity=%d WHERE (storage_type = 0 OR storage_type = 1) AND folder_uuid='%q'", MEDIA_SVC_DB_TABLE_MEDIA, validity, folder_uuid);
749         ret = _media_svc_sql_query(handle, sql, uid);
750         sqlite3_free(sql);
751
752         return ret;
753 }
754
755 int _media_svc_update_recursive_folder_item_validity(sqlite3 *handle, const char *folder_path, int validity, uid_t uid)
756 {
757         int ret = MS_MEDIA_ERR_NONE;
758
759         /*Update folder item validity*/
760         char *sql = sqlite3_mprintf("UPDATE %s SET validity=%d WHERE (storage_type = 0 OR storage_type = 1) AND path LIKE '%q/%%'", MEDIA_SVC_DB_TABLE_MEDIA, validity, folder_path);
761
762         ret = _media_svc_sql_query(handle, sql, uid);
763         sqlite3_free(sql);
764
765         return ret;
766 }
767
768 int _media_svc_update_item_by_path(sqlite3 *handle, const char *src_path, media_svc_storage_type_e dest_storage, const char *dest_path,
769                                    const char *file_name, int modified_time, const char *folder_uuid, const char *thumb_path, bool stack_query, uid_t uid)
770 {
771         /* update path, filename, modified_time, folder_uuid, thumbnail_path, */
772         /* played_count, last_played_time, last_played_position, favourite, storaget_type*/
773
774         int ret = MS_MEDIA_ERR_NONE;
775         char *sql = NULL;
776
777         if (thumb_path != NULL) {
778                 sql = sqlite3_mprintf("UPDATE %s SET \
779                                         path=%Q, file_name=%Q, modified_time=%d, folder_uuid=%Q, thumbnail_path=%Q, storage_type=%d, \
780                                         played_count=0, last_played_time=0, last_played_position=0 \
781                                         WHERE path=%Q",
782                                       MEDIA_SVC_DB_TABLE_MEDIA, dest_path, file_name, modified_time, folder_uuid, thumb_path, dest_storage, src_path);
783         } else {
784                 sql = sqlite3_mprintf("UPDATE %s SET \
785                                         path=%Q, file_name=%Q, modified_time=%d, folder_uuid=%Q, storage_type=%d, \
786                                         played_count=0, last_played_time=0, last_played_position=0 \
787                                         WHERE path=%Q",
788                                       MEDIA_SVC_DB_TABLE_MEDIA, dest_path, file_name, modified_time, folder_uuid, dest_storage, src_path);
789         }
790
791         if (!stack_query) {
792                 ret = _media_svc_sql_query(handle, sql, uid);
793                 sqlite3_free(sql);
794         } else {
795                 _media_svc_sql_query_add(&g_media_svc_move_item_query_list, &sql);
796         }
797
798         return ret;
799 }
800
801 int _media_svc_list_query_do(sqlite3 *handle, media_svc_query_type_e query_type, uid_t uid)
802 {
803         int ret = MS_MEDIA_ERR_NONE;
804
805         ret = _media_svc_sql_begin_trans(handle, uid);
806         media_svc_retv_if(ret != MS_MEDIA_ERR_NONE, ret);
807
808         if (query_type == MEDIA_SVC_QUERY_SET_ITEM_VALIDITY)
809                 ret = _media_svc_sql_query_list(handle, &g_media_svc_item_validity_query_list, uid);
810         else if (query_type == MEDIA_SVC_QUERY_MOVE_ITEM)
811                 ret = _media_svc_sql_query_list(handle, &g_media_svc_move_item_query_list, uid);
812         else if (query_type == MEDIA_SVC_QUERY_INSERT_ITEM)
813                 ret = _media_svc_sql_query_list(handle, &g_media_svc_insert_item_query_list, uid);
814         else
815                 ret = MS_MEDIA_ERR_INVALID_PARAMETER;
816
817         if (ret != MS_MEDIA_ERR_NONE) {
818                 media_svc_error("_media_svc_list_query_do failed. start rollback");
819                 _media_svc_sql_rollback_trans(handle, uid);
820                 return ret;
821         }
822
823         ret = _media_svc_sql_end_trans(handle, uid);
824         if (ret != MS_MEDIA_ERR_NONE) {
825                 media_svc_error("mb_svc_sqlite3_commit_trans failed.. Now start to rollback");
826                 _media_svc_sql_rollback_trans(handle, uid);
827                 return ret;
828         }
829
830         return MS_MEDIA_ERR_NONE;
831 }
832
833 int _media_svc_get_burst_id(sqlite3 *handle, int *id)
834 {
835         int ret = MS_MEDIA_ERR_NONE;
836         int cur_id = -1;
837         sqlite3_stmt *sql_stmt = NULL;
838         char *sql = sqlite3_mprintf("SELECT max(CAST(burst_id AS INTEGER)) FROM %s", MEDIA_SVC_DB_TABLE_MEDIA);
839
840         ret = _media_svc_sql_prepare_to_step(handle, sql, &sql_stmt);
841
842         if (ret != MS_MEDIA_ERR_NONE) {
843                 media_svc_error("error when _media_svc_get_burst_id. err = [%d]", ret);
844                 return ret;
845         }
846
847         cur_id = sqlite3_column_int(sql_stmt, 0);
848         *id = ++cur_id;
849         SQLITE3_FINALIZE(sql_stmt);
850
851         return MS_MEDIA_ERR_NONE;
852 }
853
854 int _media_svc_get_noti_info(sqlite3 *handle,  const char *storage_id, const char *path, int update_item, media_svc_noti_item **item)
855 {
856         int ret = MS_MEDIA_ERR_NONE;
857         sqlite3_stmt *sql_stmt = NULL;
858         char *sql = NULL;
859         int is_root_dir = FALSE;
860
861         if (item == NULL) {
862                 media_svc_error("invalid parameter");
863                 return MS_MEDIA_ERR_INVALID_PARAMETER;
864         }
865
866         if (update_item == MS_MEDIA_ITEM_FILE) {
867                 sql = sqlite3_mprintf("SELECT media_uuid, media_type, mime_type FROM '%s' WHERE path=%Q", storage_id, path);
868         } else if (update_item == MS_MEDIA_ITEM_DIRECTORY) {
869                 sql = sqlite3_mprintf("SELECT folder_uuid FROM '%s' WHERE path=%Q AND storage_uuid='%s'", MEDIA_SVC_DB_TABLE_FOLDER, path, storage_id);
870         } else {
871                 media_svc_error("_media_svc_get_noti_info failed : update item");
872                 return MS_MEDIA_ERR_INVALID_PARAMETER;
873         }
874
875         ret = _media_svc_sql_prepare_to_step(handle, sql, &sql_stmt);
876
877         if (ret != MS_MEDIA_ERR_NONE) {
878                 if (ret == MS_MEDIA_ERR_DB_NO_RECORD && update_item == MS_MEDIA_ITEM_DIRECTORY) {
879                         media_svc_debug("This is root directory of media");
880                         sql_stmt = NULL;
881                         is_root_dir = TRUE;
882                 } else {
883                         media_svc_error("error when _media_svc_get_noti_info. err = [%d]", ret);
884                         return ret;
885                 }
886         }
887
888         *item = calloc(1, sizeof(media_svc_noti_item));
889         if (*item == NULL) {
890                 media_svc_error("_media_svc_get_noti_info failed : calloc");
891                 return MS_MEDIA_ERR_OUT_OF_MEMORY;
892         }
893
894         if (update_item == MS_MEDIA_ITEM_FILE) {
895                 if (STRING_VALID((const char *)sqlite3_column_text(sql_stmt, 0)))
896                         (*item)->media_uuid = strdup((const char *)sqlite3_column_text(sql_stmt, 0));
897
898                 (*item)->media_type = sqlite3_column_int(sql_stmt, 1);
899
900                 if (STRING_VALID((const char *)sqlite3_column_text(sql_stmt, 2)))
901                         (*item)->mime_type = strdup((const char *)sqlite3_column_text(sql_stmt, 2));
902         } else if (update_item == MS_MEDIA_ITEM_DIRECTORY) {
903                 if (is_root_dir) {
904                         (*item)->media_uuid = NULL;
905                 } else {
906                         if (STRING_VALID((const char *)sqlite3_column_text(sql_stmt, 0)))
907                                 (*item)->media_uuid = strdup((const char *)sqlite3_column_text(sql_stmt, 0));
908                 }
909         }
910
911         SQLITE3_FINALIZE(sql_stmt);
912
913         return MS_MEDIA_ERR_NONE;
914 }
915
916 int _media_svc_count_invalid_folder_items(sqlite3 *handle, const char *folder_path, int *count)
917 {
918         int ret = MS_MEDIA_ERR_NONE;
919         sqlite3_stmt *sql_stmt = NULL;
920         char *sql = sqlite3_mprintf("SELECT count(*) FROM %s WHERE validity=0 AND path LIKE '%q/%%'",
921                                     MEDIA_SVC_DB_TABLE_MEDIA, folder_path);
922
923         ret = _media_svc_sql_prepare_to_step(handle, sql, &sql_stmt);
924
925         if (ret != MS_MEDIA_ERR_NONE) {
926                 media_svc_error("error when _media_svc_count_invalid_folder_items. err = [%d]", ret);
927                 return ret;
928         }
929
930         *count = sqlite3_column_int(sql_stmt, 0);
931
932         SQLITE3_FINALIZE(sql_stmt);
933
934         return MS_MEDIA_ERR_NONE;
935 }
936
937 int _media_svc_get_thumbnail_count(sqlite3 *handle, const char *thumb_path, int *count)
938 {
939         int ret = MS_MEDIA_ERR_NONE;
940         sqlite3_stmt *sql_stmt = NULL;
941         char *sql = sqlite3_mprintf("SELECT count(*) FROM %s WHERE thumbnail_path=%Q", MEDIA_SVC_DB_TABLE_MEDIA, thumb_path);
942
943         ret = _media_svc_sql_prepare_to_step(handle, sql, &sql_stmt);
944
945         if (ret != MS_MEDIA_ERR_NONE) {
946                 media_svc_error("error when _media_svc_get_thumbnail_count. err = [%d]", ret);
947                 return ret;
948         }
949
950         *count = sqlite3_column_int(sql_stmt, 0);
951
952         SQLITE3_FINALIZE(sql_stmt);
953
954         return MS_MEDIA_ERR_NONE;
955 }
956
957 int _media_svc_get_fileinfo_by_path(sqlite3 *handle, const char *path, time_t *modified_time, unsigned long long *size)
958 {
959         int ret = MS_MEDIA_ERR_NONE;
960         sqlite3_stmt *sql_stmt = NULL;
961         char *sql = sqlite3_mprintf("SELECT modified_time, size FROM %s WHERE path='%q'",
962                                     MEDIA_SVC_DB_TABLE_MEDIA, path);
963
964         ret = _media_svc_sql_prepare_to_step(handle, sql, &sql_stmt);
965
966         if (ret != MS_MEDIA_ERR_NONE) {
967                 media_svc_error("error when _media_svc_get_fileinfo_by_path. err = [%d]", ret);
968                 return ret;
969         }
970
971         *modified_time = (int)sqlite3_column_int(sql_stmt, 0);
972         *size = (unsigned long long)sqlite3_column_int64(sql_stmt, 1);
973
974         SQLITE3_FINALIZE(sql_stmt);
975
976         return MS_MEDIA_ERR_NONE;
977 }