4 * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
6 * Contact: Hyunjun Ko <zzoon.ko@samsung.com>, Haejeong Kim <backto.kim@samsung.com>
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
12 * http://www.apache.org/licenses/LICENSE-2.0
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.
24 #include <sys/types.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"
36 char thumbnail_path[MEDIA_SVC_PATHNAME_SIZE];
37 } media_svc_thumbnailpath_s;
39 static __thread GList *g_media_svc_item_validity_query_list = NULL;
40 static __thread GList *g_media_svc_insert_item_query_list = NULL;
41 __thread GList *g_media_svc_move_item_query_list = NULL;
42 static __thread GList *g_media_svc_update_item_query_list = NULL;
44 static int __media_svc_count_invalid_records_with_thumbnail(sqlite3 *handle, const char *storage_id, media_svc_storage_type_e storage_type, int *count);
45 static int __media_svc_get_invalid_records_with_thumbnail(sqlite3 *handle, const char *storage_id, media_svc_storage_type_e storage_type,
46 int count, media_svc_thumbnailpath_s *thumb_path);
47 static int __media_svc_count_invalid_folder_records_with_thumbnail(sqlite3 *handle, const char *storage_id, const char *folder_path, const char *folder_uuid, bool is_recursive, int *count);
48 static int __media_svc_get_invalid_folder_records_with_thumbnail(sqlite3 *handle, const char *storage_id, const char *folder_path, const char *folder_uuid, bool is_recursive, int count, media_svc_thumbnailpath_s *thumb_path);
50 static int __media_svc_count_invalid_records_with_thumbnail(sqlite3 *handle, const char *storage_id, media_svc_storage_type_e storage_type, int *count)
52 int ret = MS_MEDIA_ERR_NONE;
53 sqlite3_stmt *sql_stmt = NULL;
54 char *sql = sqlite3_mprintf("SELECT count(*) FROM '%s' WHERE validity=0 AND storage_type=%d AND thumbnail_path IS NOT NULL",
55 storage_id, storage_type);
57 ret = _media_svc_sql_prepare_to_step(handle, sql, &sql_stmt);
59 if (ret != MS_MEDIA_ERR_NONE) {
60 media_svc_error("error when __media_svc_count_invalid_records_with_thumbnail. err = [%d]", ret);
64 *count = sqlite3_column_int(sql_stmt, 0);
66 SQLITE3_FINALIZE(sql_stmt);
68 return MS_MEDIA_ERR_NONE;
72 static int __media_svc_get_invalid_records_with_thumbnail(sqlite3 *handle, const char *storage_id, media_svc_storage_type_e storage_type,
73 int count, media_svc_thumbnailpath_s * thumb_path)
75 int ret = MS_MEDIA_ERR_NONE;
76 sqlite3_stmt *sql_stmt = NULL;
79 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",
80 MEDIA_SVC_DB_TABLE_MEDIA, storage_type);
82 media_svc_debug("[SQL query] : %s", sql);
84 ret = _media_svc_sql_prepare_to_step(handle, sql, &sql_stmt);
85 if (ret != MS_MEDIA_ERR_NONE) {
86 media_svc_error("error when __media_svc_get_invalid_records_with_thumbnail. err = [%d]", ret);
90 while (sqlite3_step(sql_stmt) == SQLITE_ROW) {
91 _strncpy_safe(thumb_path[idx].thumbnail_path, (const char *)sqlite3_column_text(sql_stmt, 0), sizeof(thumb_path[idx]));
92 /*media_svc_debug("thumb_path[%d]=[%s]", idx, thumb_path[idx].thumbnail_path); */
96 SQLITE3_FINALIZE(sql_stmt);
98 return MS_MEDIA_ERR_NONE;
101 static int __media_svc_count_invalid_folder_records_with_thumbnail(sqlite3 *handle, const char *storage_id, const char *folder_path, const char *folder_uuid, bool is_recursive, int *count)
103 int ret = MS_MEDIA_ERR_NONE;
104 sqlite3_stmt *sql_stmt = NULL;
108 sql = sqlite3_mprintf("SELECT count(*) FROM '%s' WHERE validity=0 AND path LIKE '%q/%%' AND thumbnail_path IS NOT NULL", storage_id, folder_path);
110 sql = sqlite3_mprintf("SELECT count(*) FROM '%s' WHERE validity=0 AND folder_uuid = '%q' AND thumbnail_path IS NOT NULL", storage_id, folder_uuid);
113 ret = _media_svc_sql_prepare_to_step(handle, sql, &sql_stmt);
115 if (ret != MS_MEDIA_ERR_NONE) {
116 media_svc_error("error when __media_svc_count_invalid_folder_records_with_thumbnail. err = [%d]", ret);
120 *count = sqlite3_column_int(sql_stmt, 0);
122 SQLITE3_FINALIZE(sql_stmt);
124 return MS_MEDIA_ERR_NONE;
128 static int __media_svc_get_invalid_folder_records_with_thumbnail(sqlite3 *handle, const char *storage_id, const char *folder_path, const char *folder_uuid, bool is_recursive,
129 int count, media_svc_thumbnailpath_s * thumb_path)
131 int ret = MS_MEDIA_ERR_NONE;
132 sqlite3_stmt *sql_stmt = NULL;
137 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", storage_id, folder_path);
139 sql = sqlite3_mprintf("SELECT thumbnail_path from (select thumbnail_path, validity from '%s' WHERE folder_uuid = '%q' AND thumbnail_path IS NOT NULL GROUP BY thumbnail_path HAVING count() = 1) WHERE validity=0", storage_id, folder_uuid);
142 media_svc_debug("[SQL query] : %s", sql);
144 ret = _media_svc_sql_prepare_to_step_simple(handle, sql, &sql_stmt);
145 if (ret != MS_MEDIA_ERR_NONE) {
146 media_svc_error("error when __media_svc_get_invalid_folder_records_with_thumbnail. err = [%d]", ret);
150 while (sqlite3_step(sql_stmt) == SQLITE_ROW) {
151 _strncpy_safe(thumb_path[idx].thumbnail_path, (const char *)sqlite3_column_text(sql_stmt, 0), sizeof(thumb_path[idx]));
155 SQLITE3_FINALIZE(sql_stmt);
157 return MS_MEDIA_ERR_NONE;
160 int _media_svc_count_record_with_path(sqlite3 *handle, const char *storage_id, const char *path, int *count)
162 int ret = MS_MEDIA_ERR_NONE;
163 sqlite3_stmt *sql_stmt = NULL;
165 char *sql = sqlite3_mprintf("SELECT count(*) FROM '%s' WHERE path='%q'", storage_id, path);
167 ret = _media_svc_sql_prepare_to_step(handle, sql, &sql_stmt);
169 media_svc_retv_if(ret != MS_MEDIA_ERR_NONE, ret);
171 *count = sqlite3_column_int(sql_stmt, 0);
173 SQLITE3_FINALIZE(sql_stmt);
175 return MS_MEDIA_ERR_NONE;
178 char *_media_svc_get_thumb_default_path(uid_t uid)
180 char *result_psswd = NULL;
181 struct group *grpinfo = NULL;
182 if (uid == getuid()) {
183 result_psswd = strdup(MEDIA_SVC_THUMB_DEFAULT_PATH);
184 grpinfo = getgrnam("users");
185 if (grpinfo == NULL) {
186 media_svc_error("getgrnam(users) returns NULL !");
192 struct passwd *userinfo = getpwuid(uid);
193 if (userinfo == NULL) {
194 media_svc_error("getpwuid(%d) returns NULL !", uid);
197 grpinfo = getgrnam("users");
198 if (grpinfo == NULL) {
199 media_svc_error("getgrnam(users) returns NULL !");
202 /* Compare git_t type and not group name */
203 if (grpinfo->gr_gid != userinfo->pw_gid) {
204 media_svc_error("UID [%d] does not belong to 'users' group!", uid);
207 asprintf(&result_psswd, "%s/share/media/.thumb/thumb_default.png", userinfo->pw_dir);
213 int _media_svc_insert_item_with_data(sqlite3 *handle, const char *storage_id, media_svc_content_info_s *content_info, int is_burst, bool stack_query, uid_t uid)
215 int ret = MS_MEDIA_ERR_NONE;
216 char *burst_id = NULL;
217 int ini_val = _media_svc_get_ini_value();
219 const char *db_fields = "media_uuid, path, file_name, media_type, mime_type, size, added_time, modified_time, folder_uuid, \
220 thumbnail_path, title, album_id, album, artist, album_artist, genre, composer, year, recorded_date, copyright, track_num, description, \
221 bitrate, bitpersample, samplerate, channel, duration, longitude, latitude, altitude, exposure_time, fnumber, iso, model, width, height, datetaken, orientation, \
222 rating, is_drm, storage_type, burst_id, timeline, weather, sync_status, \
223 file_name_pinyin, title_pinyin, album_pinyin, artist_pinyin, album_artist_pinyin, genre_pinyin, composer_pinyin, copyright_pinyin, description_pinyin, storage_uuid";
225 /* This sql is due to sqlite3_mprintf's wrong operation when using floating point in the text format */
226 /* This code will be removed when sqlite3_mprintf works clearly */
227 char *test_sql = sqlite3_mprintf("%f, %f, %f", content_info->media_meta.longitude, content_info->media_meta.latitude, content_info->media_meta.altitude);
228 sqlite3_free(test_sql);
231 int burst_id_int = 0;
232 ret = _media_svc_get_burst_id(handle, storage_id, &burst_id_int);
233 if (ret != MS_MEDIA_ERR_NONE) {
237 if (burst_id_int > 0) {
238 media_svc_debug("Burst id : %d", burst_id_int);
239 burst_id = sqlite3_mprintf("%d", burst_id_int);
242 /* Get thumbnail for burst shot */
244 char thumb_path[MEDIA_SVC_PATHNAME_SIZE + 1] = {0, };
248 ret = _media_svc_request_thumbnail_with_origin_size(content_info->path, thumb_path, sizeof(thumb_path), &width, &height, uid);
249 if (ret == MS_MEDIA_ERR_NONE) {
250 ret = __media_svc_malloc_and_strncpy(&(content_info->thumbnail_path), thumb_path);
251 if (ret != MS_MEDIA_ERR_NONE) {
252 content_info->thumbnail_path = NULL;
256 if (content_info->media_meta.width <= 0)
257 content_info->media_meta.width = width;
259 if (content_info->media_meta.height <= 0)
260 content_info->media_meta.height = height;
264 /*Update Pinyin If Support Pinyin*/
265 if (_media_svc_check_pinyin_support()) {
266 if (STRING_VALID(content_info->file_name))
267 _media_svc_get_pinyin_str(content_info->file_name, &content_info->file_name_pinyin);
268 if (STRING_VALID(content_info->media_meta.title))
269 _media_svc_get_pinyin_str(content_info->media_meta.title, &content_info->media_meta.title_pinyin);
270 if (STRING_VALID(content_info->media_meta.album))
271 _media_svc_get_pinyin_str(content_info->media_meta.album, &content_info->media_meta.album_pinyin);
272 if (STRING_VALID(content_info->media_meta.artist))
273 _media_svc_get_pinyin_str(content_info->media_meta.artist, &content_info->media_meta.artist_pinyin);
274 if (STRING_VALID(content_info->media_meta.album_artist))
275 _media_svc_get_pinyin_str(content_info->media_meta.album_artist, &content_info->media_meta.album_artist_pinyin);
276 if (STRING_VALID(content_info->media_meta.genre))
277 _media_svc_get_pinyin_str(content_info->media_meta.genre, &content_info->media_meta.genre_pinyin);
278 if (STRING_VALID(content_info->media_meta.composer))
279 _media_svc_get_pinyin_str(content_info->media_meta.composer, &content_info->media_meta.composer_pinyin);
280 if (STRING_VALID(content_info->media_meta.copyright))
281 _media_svc_get_pinyin_str(content_info->media_meta.copyright, &content_info->media_meta.copyright_pinyin);
282 if (STRING_VALID(content_info->media_meta.description))
283 _media_svc_get_pinyin_str(content_info->media_meta.description, &content_info->media_meta.description_pinyin);
286 char *sql = sqlite3_mprintf("INSERT INTO '%s' (%s) VALUES (%Q, %Q, %Q, %d, %Q, %lld, %d, %d, %Q, \
287 %Q, %Q, %d, %Q, %Q, %Q, %Q, %Q, %Q, %Q, %Q, %Q, %Q, \
288 %d, %d, %d, %d, %d, %.6f, %.6f, %.6f, %Q, %.6f, %d, %Q, %d, %d, %Q, %d, \
289 %d, %d, %d, %Q, %d, %Q, %d, \
290 %Q, %Q, %Q, %Q, %Q, %Q, %Q, %Q, %Q, %Q);",
291 content_info->storage_uuid, db_fields,
292 content_info->media_uuid,
294 content_info->file_name,
295 content_info->media_type,
296 content_info->mime_type,
298 content_info->added_time,
299 content_info->modified_time,
300 content_info->folder_uuid,
301 content_info->thumbnail_path,
302 content_info->media_meta.title,
303 content_info->album_id,
304 content_info->media_meta.album,
305 content_info->media_meta.artist,
306 content_info->media_meta.album_artist,
307 content_info->media_meta.genre,
308 content_info->media_meta.composer,
309 content_info->media_meta.year,
310 content_info->media_meta.recorded_date,
311 content_info->media_meta.copyright,
312 content_info->media_meta.track_num,
313 content_info->media_meta.description,
314 content_info->media_meta.bitrate,
315 content_info->media_meta.bitpersample,
316 content_info->media_meta.samplerate,
317 content_info->media_meta.channel,
318 content_info->media_meta.duration,
319 content_info->media_meta.longitude,
320 content_info->media_meta.latitude,
321 content_info->media_meta.altitude,
322 content_info->media_meta.exposure_time,
323 content_info->media_meta.fnumber,
324 content_info->media_meta.iso,
325 content_info->media_meta.model,
326 content_info->media_meta.width,
327 content_info->media_meta.height,
328 content_info->media_meta.datetaken,
329 content_info->media_meta.orientation,
330 content_info->media_meta.rating,
331 content_info->is_drm,
332 content_info->storage_type,
334 content_info->timeline,
335 content_info->media_meta.weather,
336 content_info->sync_status,
337 content_info->file_name_pinyin,
338 content_info->media_meta.title_pinyin,
339 content_info->media_meta.album_pinyin,
340 content_info->media_meta.artist_pinyin,
341 content_info->media_meta.album_artist_pinyin,
342 content_info->media_meta.genre_pinyin,
343 content_info->media_meta.composer_pinyin,
344 content_info->media_meta.copyright_pinyin,
345 content_info->media_meta.description_pinyin,
346 content_info->storage_uuid
350 sqlite3_free(burst_id);
355 ret = _media_svc_sql_query(handle, sql, uid);
357 if (ret != MS_MEDIA_ERR_NONE) {
358 media_svc_error("failed to insert item");
362 media_svc_debug("query : %s", sql);
363 _media_svc_sql_query_add(&g_media_svc_insert_item_query_list, &sql);
366 return MS_MEDIA_ERR_NONE;
369 int _media_svc_update_meta_with_data(sqlite3 *handle, media_svc_content_info_s *content_info)
371 int ret = MS_MEDIA_ERR_NONE;
373 /* This sql is due to sqlite3_mprintf's wrong operation when using floating point in the text format */
374 /* This code will be removed when sqlite3_mprintf works clearly */
375 char *test_sql = sqlite3_mprintf("%f, %f, %f", content_info->media_meta.longitude, content_info->media_meta.latitude, content_info->media_meta.altitude);
376 sqlite3_free(test_sql);
378 /*Update Pinyin If Support Pinyin*/
379 if (_media_svc_check_pinyin_support()) {
380 if (STRING_VALID(content_info->file_name))
381 _media_svc_get_pinyin_str(content_info->file_name, &content_info->file_name_pinyin);
382 if (STRING_VALID(content_info->media_meta.title))
383 _media_svc_get_pinyin_str(content_info->media_meta.title, &content_info->media_meta.title_pinyin);
384 if (STRING_VALID(content_info->media_meta.album))
385 _media_svc_get_pinyin_str(content_info->media_meta.album, &content_info->media_meta.album_pinyin);
386 if (STRING_VALID(content_info->media_meta.artist))
387 _media_svc_get_pinyin_str(content_info->media_meta.artist, &content_info->media_meta.artist_pinyin);
388 if (STRING_VALID(content_info->media_meta.album_artist))
389 _media_svc_get_pinyin_str(content_info->media_meta.album_artist, &content_info->media_meta.album_artist_pinyin);
390 if (STRING_VALID(content_info->media_meta.genre))
391 _media_svc_get_pinyin_str(content_info->media_meta.genre, &content_info->media_meta.genre_pinyin);
392 if (STRING_VALID(content_info->media_meta.composer))
393 _media_svc_get_pinyin_str(content_info->media_meta.composer, &content_info->media_meta.composer_pinyin);
394 if (STRING_VALID(content_info->media_meta.copyright))
395 _media_svc_get_pinyin_str(content_info->media_meta.copyright, &content_info->media_meta.copyright_pinyin);
396 if (STRING_VALID(content_info->media_meta.description))
397 _media_svc_get_pinyin_str(content_info->media_meta.description, &content_info->media_meta.description_pinyin);
400 char *sql = sqlite3_mprintf("UPDATE %s SET title=%Q, album=%Q, artist=%Q, album_artist=%Q, genre=%Q, composer=%Q, copyright=%Q, description=%Q, \
401 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 \
403 MEDIA_SVC_DB_TABLE_MEDIA,
404 content_info->media_meta.title,
405 content_info->media_meta.album,
406 content_info->media_meta.artist,
407 content_info->media_meta.album_artist,
408 content_info->media_meta.genre,
409 content_info->media_meta.composer,
410 content_info->media_meta.copyright,
411 content_info->media_meta.description,
412 content_info->file_name_pinyin,
413 content_info->media_meta.title_pinyin,
414 content_info->media_meta.album_pinyin,
415 content_info->media_meta.artist_pinyin,
416 content_info->media_meta.album_artist_pinyin,
417 content_info->media_meta.genre_pinyin,
418 content_info->media_meta.composer_pinyin,
419 content_info->media_meta.copyright_pinyin,
420 content_info->media_meta.description_pinyin,
425 media_svc_debug("query : %s", sql);
426 _media_svc_sql_query_add(&g_media_svc_update_item_query_list, &sql);
428 media_svc_error("sqlite3_mprintf failed");
429 ret = MS_MEDIA_ERR_OUT_OF_MEMORY;
435 int _media_svc_update_item_with_data(sqlite3 *handle, const char *storage_id, media_svc_content_info_s *content_info, uid_t uid)
437 int ret = MS_MEDIA_ERR_NONE;
439 /* This sql is due to sqlite3_mprintf's wrong operation when using floating point in the text format */
440 /* This code will be removed when sqlite3_mprintf works clearly */
441 char *test_sql = sqlite3_mprintf("%f, %f, %f", content_info->media_meta.longitude, content_info->media_meta.latitude, content_info->media_meta.altitude);
442 sqlite3_free(test_sql);
444 /*Update Pinyin If Support Pinyin*/
445 if (_media_svc_check_pinyin_support()) {
446 if (STRING_VALID(content_info->file_name))
447 _media_svc_get_pinyin_str(content_info->file_name, &content_info->file_name_pinyin);
448 if (STRING_VALID(content_info->media_meta.title))
449 _media_svc_get_pinyin_str(content_info->media_meta.title, &content_info->media_meta.title_pinyin);
450 if (STRING_VALID(content_info->media_meta.album))
451 _media_svc_get_pinyin_str(content_info->media_meta.album, &content_info->media_meta.album_pinyin);
452 if (STRING_VALID(content_info->media_meta.artist))
453 _media_svc_get_pinyin_str(content_info->media_meta.artist, &content_info->media_meta.artist_pinyin);
454 if (STRING_VALID(content_info->media_meta.album_artist))
455 _media_svc_get_pinyin_str(content_info->media_meta.album_artist, &content_info->media_meta.album_artist_pinyin);
456 if (STRING_VALID(content_info->media_meta.genre))
457 _media_svc_get_pinyin_str(content_info->media_meta.genre, &content_info->media_meta.genre_pinyin);
458 if (STRING_VALID(content_info->media_meta.composer))
459 _media_svc_get_pinyin_str(content_info->media_meta.composer, &content_info->media_meta.composer_pinyin);
460 if (STRING_VALID(content_info->media_meta.copyright))
461 _media_svc_get_pinyin_str(content_info->media_meta.copyright, &content_info->media_meta.copyright_pinyin);
462 if (STRING_VALID(content_info->media_meta.description))
463 _media_svc_get_pinyin_str(content_info->media_meta.description, &content_info->media_meta.description_pinyin);
466 char *sql = sqlite3_mprintf("UPDATE '%s' SET \
467 size=%lld, modified_time=%d, thumbnail_path=%Q, title=%Q, album_id=%d, album=%Q, artist=%Q, album_artist=%Q, genre=%Q, \
468 composer=%Q, year=%Q, recorded_date=%Q, copyright=%Q, track_num=%Q, description=%Q, \
469 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, \
470 orientation=%d WHERE path=%Q",
473 content_info->modified_time,
474 content_info->thumbnail_path,
475 content_info->media_meta.title,
476 content_info->album_id,
477 content_info->media_meta.album,
478 content_info->media_meta.artist,
479 content_info->media_meta.album_artist,
480 content_info->media_meta.genre,
481 content_info->media_meta.composer,
482 content_info->media_meta.year,
483 content_info->media_meta.recorded_date,
484 content_info->media_meta.copyright,
485 content_info->media_meta.track_num,
486 content_info->media_meta.description,
487 content_info->media_meta.bitrate,
488 content_info->media_meta.bitpersample,
489 content_info->media_meta.samplerate,
490 content_info->media_meta.channel,
491 content_info->media_meta.duration,
492 content_info->media_meta.longitude,
493 content_info->media_meta.latitude,
494 content_info->media_meta.altitude,
495 content_info->media_meta.exposure_time,
496 content_info->media_meta.fnumber,
497 content_info->media_meta.iso,
498 content_info->media_meta.model,
499 content_info->media_meta.width,
500 content_info->media_meta.height,
501 content_info->media_meta.datetaken,
502 content_info->media_meta.orientation,
506 ret = _media_svc_sql_query(handle, sql, uid);
511 int _media_svc_get_thumbnail_path_by_path(sqlite3 *handle, const char *storage_id, const char *path, char *thumbnail_path)
513 int ret = MS_MEDIA_ERR_NONE;
514 sqlite3_stmt *sql_stmt = NULL;
516 char *sql = sqlite3_mprintf("SELECT thumbnail_path FROM '%s' WHERE path='%q'", storage_id, path);
518 ret = _media_svc_sql_prepare_to_step(handle, sql, &sql_stmt);
520 if (ret != MS_MEDIA_ERR_NONE) {
521 if (ret == MS_MEDIA_ERR_DB_NO_RECORD) {
522 media_svc_debug("there is no thumbnail.");
524 media_svc_error("error when _media_svc_get_thumbnail_path_by_path. err = [%d]", ret);
529 _strncpy_safe(thumbnail_path, (const char *)sqlite3_column_text(sql_stmt, 0), MEDIA_SVC_PATHNAME_SIZE);
531 SQLITE3_FINALIZE(sql_stmt);
533 return MS_MEDIA_ERR_NONE;
536 int _media_svc_get_media_type_by_path(sqlite3 *handle, const char *storage_id, const char *path, int *media_type)
538 int ret = MS_MEDIA_ERR_NONE;
539 sqlite3_stmt *sql_stmt = NULL;
541 char *sql = sqlite3_mprintf("SELECT media_type FROM '%s' WHERE path='%q'", storage_id, path);
543 ret = _media_svc_sql_prepare_to_step(handle, sql, &sql_stmt);
545 if (ret != MS_MEDIA_ERR_NONE) {
546 media_svc_error("error when _media_svc_get_media_type_by_path. err = [%d]", ret);
550 *media_type = sqlite3_column_int(sql_stmt, 0);
552 SQLITE3_FINALIZE(sql_stmt);
554 return MS_MEDIA_ERR_NONE;
557 int _media_svc_delete_item_by_path(sqlite3 *handle, const char *storage_id, const char *path, bool stack_query, uid_t uid)
559 int ret = MS_MEDIA_ERR_NONE;
560 char *sql = sqlite3_mprintf("DELETE FROM '%s' WHERE path='%q'", storage_id, path);
563 ret = _media_svc_sql_query(handle, sql, uid);
565 if (ret != MS_MEDIA_ERR_NONE) {
566 media_svc_error("failed to delete item");
570 media_svc_debug("query : %s", sql);
571 _media_svc_sql_query_add(&g_media_svc_insert_item_query_list, &sql);
577 int _media_svc_truncate_table(sqlite3 *handle, const char *storage_id, media_svc_storage_type_e storage_type, uid_t uid)
579 int ret = MS_MEDIA_ERR_NONE;
581 char *sql = sqlite3_mprintf("DELETE FROM '%s' where storage_type=%d", storage_id, storage_type);
583 ret = _media_svc_sql_query(handle, sql, uid);
589 int _media_svc_delete_invalid_items(sqlite3 *handle, const char *storage_id, media_svc_storage_type_e storage_type, uid_t uid)
592 media_svc_thumbnailpath_s *thumbpath_record = NULL;
593 int invalid_count = 0;
594 int ret = MS_MEDIA_ERR_NONE;
596 ret = __media_svc_count_invalid_records_with_thumbnail(handle, storage_id, storage_type, &invalid_count);
597 media_svc_retv_if(ret != MS_MEDIA_ERR_NONE, ret);
599 media_svc_debug("invalid count: %d", invalid_count);
601 if (invalid_count > 0) {
602 thumbpath_record = (media_svc_thumbnailpath_s *)calloc(invalid_count, sizeof(media_svc_thumbnailpath_s));
603 if (thumbpath_record == NULL) {
604 media_svc_error("fail to memory allocation");
605 return MS_MEDIA_ERR_OUT_OF_MEMORY;
608 ret = __media_svc_get_invalid_records_with_thumbnail(handle, storage_id, storage_type, invalid_count, thumbpath_record);
609 if (ret != MS_MEDIA_ERR_NONE) {
610 media_svc_error("error when get thumbnail record");
611 SAFE_FREE(thumbpath_record);
615 media_svc_debug("There is no item with thumbnail");
618 char *sql = sqlite3_mprintf("DELETE FROM '%s' WHERE validity = 0", storage_id);
620 ret = _media_svc_sql_query(handle, sql, uid);
622 if (ret != MS_MEDIA_ERR_NONE) {
623 SAFE_FREE(thumbpath_record);
627 /*Delete thumbnails*/
628 for (idx = 0; idx < invalid_count; idx++) {
629 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)) {
630 ret = _media_svc_remove_file(thumbpath_record[idx].thumbnail_path);
631 if (ret != MS_MEDIA_ERR_NONE) {
632 media_svc_error("fail to remove thumbnail file.");
637 SAFE_FREE(thumbpath_record);
639 return MS_MEDIA_ERR_NONE;
642 int _media_svc_delete_invalid_folder_items(sqlite3 *handle, const char *storage_id, const char *folder_path, bool is_recursive, uid_t uid)
645 media_svc_thumbnailpath_s *thumbpath_record = NULL;
646 int invalid_count = 0;
647 int ret = MS_MEDIA_ERR_NONE;
648 char folder_uuid[MEDIA_SVC_UUID_SIZE+1] = {0,};
651 /*get folder uuid from DB*/
652 ret = _media_svc_get_folder_id_by_foldername(handle, storage_id, folder_path, folder_uuid, uid);
653 media_svc_retv_if(ret != MS_MEDIA_ERR_NONE, ret);
655 ret = __media_svc_count_invalid_folder_records_with_thumbnail(handle, storage_id, folder_path, folder_uuid, is_recursive, &invalid_count);
656 media_svc_retv_if(ret != MS_MEDIA_ERR_NONE, ret);
658 media_svc_debug("invalid count: %d", invalid_count);
660 if (invalid_count > 0) {
661 thumbpath_record = (media_svc_thumbnailpath_s *)calloc(invalid_count, sizeof(media_svc_thumbnailpath_s));
662 if (thumbpath_record == NULL) {
663 media_svc_error("fail to memory allocation");
664 return MS_MEDIA_ERR_OUT_OF_MEMORY;
667 ret = __media_svc_get_invalid_folder_records_with_thumbnail(handle, storage_id, folder_path, folder_uuid, is_recursive, invalid_count, thumbpath_record);
668 if (ret != MS_MEDIA_ERR_NONE) {
669 media_svc_error("error when get thumbnail record");
670 SAFE_FREE(thumbpath_record);
674 media_svc_debug("There is no item with thumbnail");
678 sql = sqlite3_mprintf("DELETE FROM '%s' WHERE validity = 0 AND path LIKE '%q/%%'", storage_id, folder_path);
680 sql = sqlite3_mprintf("DELETE FROM '%s' WHERE validity = 0 AND folder_uuid='%q'", storage_id, folder_uuid);
683 ret = _media_svc_sql_query(handle, sql, uid);
685 if (ret != MS_MEDIA_ERR_NONE) {
686 SAFE_FREE(thumbpath_record);
690 /*Delete thumbnails*/
691 if (thumbpath_record != NULL) {
692 for (idx = 0; idx < invalid_count; idx++) {
693 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)) {
694 ret = _media_svc_remove_file(thumbpath_record[idx].thumbnail_path);
695 if (ret != MS_MEDIA_ERR_NONE) {
696 media_svc_error("fail to remove thumbnail file.");
701 SAFE_FREE(thumbpath_record);
704 return MS_MEDIA_ERR_NONE;
707 int _media_svc_update_item_validity(sqlite3 *handle, const char *storage_id, const char *path, int validity, bool stack_query, uid_t uid)
709 int ret = MS_MEDIA_ERR_NONE;
711 char *sql = sqlite3_mprintf("UPDATE '%s' SET validity=%d WHERE path= '%q'", storage_id, validity, path);
714 ret = _media_svc_sql_query(handle, sql, uid);
717 _media_svc_sql_query_add(&g_media_svc_item_validity_query_list, &sql);
723 int _media_svc_update_thumbnail_path(sqlite3 *handle, const char *storage_id, const char *path, const char *thumb_path, uid_t uid)
725 int ret = MS_MEDIA_ERR_NONE;
727 char *sql = sqlite3_mprintf("UPDATE '%s' SET thumbnail_path=%Q WHERE path= %Q", storage_id, thumb_path, path);
729 ret = _media_svc_sql_query(handle, sql, uid);
735 int _media_svc_update_storage_item_validity(sqlite3 *handle, const char *storage_id, media_svc_storage_type_e storage_type, int validity, uid_t uid)
737 int ret = MS_MEDIA_ERR_NONE;
739 char *sql = sqlite3_mprintf("UPDATE '%s' SET validity=%d WHERE storage_type=%d", storage_id, validity, storage_type);
741 ret = _media_svc_sql_query(handle, sql, uid);
747 int _media_svc_update_folder_item_validity(sqlite3 *handle, const char *storage_id, const char *folder_path, int validity, uid_t uid)
749 int ret = MS_MEDIA_ERR_NONE;
751 char folder_uuid[MEDIA_SVC_UUID_SIZE + 1] = {0, };
752 sqlite3_stmt *sql_stmt = NULL;
755 sql = sqlite3_mprintf("SELECT folder_uuid FROM '%s' WHERE path='%q' AND storage_uuid='%q'", MEDIA_SVC_DB_TABLE_FOLDER, folder_path, storage_id);
757 ret = _media_svc_sql_prepare_to_step(handle, sql, &sql_stmt);
758 if (ret != MS_MEDIA_ERR_NONE) {
759 if (ret == MS_MEDIA_ERR_DB_NO_RECORD)
760 media_svc_debug("folder not exist");
762 media_svc_error("error when get folder_id. err = [%d]", ret);
767 _strncpy_safe(folder_uuid, (const char *)sqlite3_column_text(sql_stmt, 0), MEDIA_SVC_UUID_SIZE + 1);
768 SQLITE3_FINALIZE(sql_stmt);
770 /*Update folder item validity*/
771 sql = sqlite3_mprintf("UPDATE '%s' SET validity=%d WHERE folder_uuid='%q'", storage_id, validity, folder_uuid);
773 ret = _media_svc_sql_query(handle, sql, uid);
779 int _media_svc_update_recursive_folder_item_validity(sqlite3 *handle, const char *storage_id, const char *folder_path, int validity, uid_t uid)
781 int ret = MS_MEDIA_ERR_NONE;
783 /*Update folder item validity*/
784 char *sql = sqlite3_mprintf("UPDATE '%s' SET validity=%d WHERE (storage_type = 0 OR storage_type = 1) AND path LIKE '%q/%%'", storage_id, validity, folder_path);
786 ret = _media_svc_sql_query(handle, sql, uid);
792 int _media_svc_update_item_by_path(sqlite3 *handle, const char *storage_id, const char *src_path, media_svc_storage_type_e dest_storage, const char *dest_path,
793 const char *file_name, int modified_time, const char *folder_uuid, const char *thumb_path, bool stack_query, uid_t uid)
795 /* update path, filename, modified_time, folder_uuid, thumbnail_path, */
796 /* played_count, last_played_time, last_played_position, favourite, storaget_type*/
798 int ret = MS_MEDIA_ERR_NONE;
801 if (thumb_path != NULL) {
802 sql = sqlite3_mprintf("UPDATE '%s' SET \
803 path=%Q, file_name=%Q, modified_time=%d, folder_uuid=%Q, thumbnail_path=%Q, storage_type=%d, \
804 played_count=0, last_played_time=0, last_played_position=0 \
806 storage_id, dest_path, file_name, modified_time, folder_uuid, thumb_path, dest_storage, src_path);
808 sql = sqlite3_mprintf("UPDATE '%s' SET \
809 path=%Q, file_name=%Q, modified_time=%d, folder_uuid=%Q, storage_type=%d, \
810 played_count=0, last_played_time=0, last_played_position=0 \
812 storage_id, dest_path, file_name, modified_time, folder_uuid, dest_storage, src_path);
816 ret = _media_svc_sql_query(handle, sql, uid);
819 _media_svc_sql_query_add(&g_media_svc_move_item_query_list, &sql);
825 int _media_svc_list_query_do(sqlite3 *handle, media_svc_query_type_e query_type, uid_t uid)
827 int ret = MS_MEDIA_ERR_NONE;
829 ret = _media_svc_sql_begin_trans(handle, uid);
830 media_svc_retv_if(ret != MS_MEDIA_ERR_NONE, ret);
832 if (query_type == MEDIA_SVC_QUERY_SET_ITEM_VALIDITY)
833 ret = _media_svc_sql_query_list(handle, &g_media_svc_item_validity_query_list, uid);
834 else if (query_type == MEDIA_SVC_QUERY_MOVE_ITEM)
835 ret = _media_svc_sql_query_list(handle, &g_media_svc_move_item_query_list, uid);
836 else if (query_type == MEDIA_SVC_QUERY_INSERT_ITEM)
837 ret = _media_svc_sql_query_list(handle, &g_media_svc_insert_item_query_list, uid);
838 else if (query_type == MEDIA_SVC_QUERY_UPDATE_ITEM)
839 ret = _media_svc_sql_query_list(handle, &g_media_svc_update_item_query_list, uid);
840 else if (query_type == MEDIA_SVC_QUERY_INSERT_FOLDER)
841 ret = _media_svc_sql_query_list(handle, _media_svc_get_folder_list_ptr(), uid);
843 ret = MS_MEDIA_ERR_INVALID_PARAMETER;
845 if (ret != MS_MEDIA_ERR_NONE) {
846 media_svc_error("_media_svc_list_query_do failed. start rollback");
847 _media_svc_sql_rollback_trans(handle, uid);
851 ret = _media_svc_sql_end_trans(handle, uid);
852 if (ret != MS_MEDIA_ERR_NONE) {
853 media_svc_error("mb_svc_sqlite3_commit_trans failed.. Now start to rollback");
854 _media_svc_sql_rollback_trans(handle, uid);
858 return MS_MEDIA_ERR_NONE;
861 int _media_svc_get_burst_id(sqlite3 *handle, const char *storage_id, int *id)
863 int ret = MS_MEDIA_ERR_NONE;
865 sqlite3_stmt *sql_stmt = NULL;
866 char *sql = sqlite3_mprintf("SELECT max(CAST(burst_id AS INTEGER)) FROM '%s'", storage_id);
868 ret = _media_svc_sql_prepare_to_step(handle, sql, &sql_stmt);
870 if (ret != MS_MEDIA_ERR_NONE) {
871 media_svc_error("error when _media_svc_get_burst_id. err = [%d]", ret);
875 cur_id = sqlite3_column_int(sql_stmt, 0);
877 SQLITE3_FINALIZE(sql_stmt);
879 return MS_MEDIA_ERR_NONE;
882 int _media_svc_get_noti_info(sqlite3 *handle, const char *storage_id, const char *path, int update_item, media_svc_noti_item **item)
884 int ret = MS_MEDIA_ERR_NONE;
885 sqlite3_stmt *sql_stmt = NULL;
887 int is_root_dir = FALSE;
890 media_svc_error("invalid parameter");
891 return MS_MEDIA_ERR_INVALID_PARAMETER;
894 if (update_item == MS_MEDIA_ITEM_FILE) {
895 sql = sqlite3_mprintf("SELECT media_uuid, media_type, mime_type FROM '%s' WHERE path=%Q", storage_id, path);
896 } else if (update_item == MS_MEDIA_ITEM_DIRECTORY) {
897 sql = sqlite3_mprintf("SELECT folder_uuid FROM '%s' WHERE path=%Q AND storage_uuid='%s'", MEDIA_SVC_DB_TABLE_FOLDER, path, storage_id);
899 media_svc_error("_media_svc_get_noti_info failed : update item");
900 return MS_MEDIA_ERR_INVALID_PARAMETER;
903 ret = _media_svc_sql_prepare_to_step(handle, sql, &sql_stmt);
905 if (ret != MS_MEDIA_ERR_NONE) {
906 if (ret == MS_MEDIA_ERR_DB_NO_RECORD && update_item == MS_MEDIA_ITEM_DIRECTORY) {
907 media_svc_debug("This is root directory of media");
911 media_svc_error("error when _media_svc_get_noti_info. err = [%d]", ret);
916 *item = calloc(1, sizeof(media_svc_noti_item));
918 media_svc_error("_media_svc_get_noti_info failed : calloc");
919 return MS_MEDIA_ERR_OUT_OF_MEMORY;
922 if (update_item == MS_MEDIA_ITEM_FILE) {
923 if (STRING_VALID((const char *)sqlite3_column_text(sql_stmt, 0)))
924 (*item)->media_uuid = strdup((const char *)sqlite3_column_text(sql_stmt, 0));
926 (*item)->media_type = sqlite3_column_int(sql_stmt, 1);
928 if (STRING_VALID((const char *)sqlite3_column_text(sql_stmt, 2)))
929 (*item)->mime_type = strdup((const char *)sqlite3_column_text(sql_stmt, 2));
930 } else if (update_item == MS_MEDIA_ITEM_DIRECTORY) {
932 (*item)->media_uuid = NULL;
934 if (STRING_VALID((const char *)sqlite3_column_text(sql_stmt, 0)))
935 (*item)->media_uuid = strdup((const char *)sqlite3_column_text(sql_stmt, 0));
939 SQLITE3_FINALIZE(sql_stmt);
941 return MS_MEDIA_ERR_NONE;
944 int _media_svc_count_invalid_folder_items(sqlite3 *handle, const char *storage_id, const char *folder_path, int *count)
946 int ret = MS_MEDIA_ERR_NONE;
947 sqlite3_stmt *sql_stmt = NULL;
949 char *sql = sqlite3_mprintf("SELECT count(*) FROM '%s' WHERE validity=0 AND path LIKE '%q/%%'", storage_id, folder_path);
951 ret = _media_svc_sql_prepare_to_step(handle, sql, &sql_stmt);
953 if (ret != MS_MEDIA_ERR_NONE) {
954 media_svc_error("error when _media_svc_count_invalid_folder_items. err = [%d]", ret);
958 *count = sqlite3_column_int(sql_stmt, 0);
960 SQLITE3_FINALIZE(sql_stmt);
962 return MS_MEDIA_ERR_NONE;
965 int _media_svc_get_thumbnail_count(sqlite3 *handle, const char *storage_id, const char *thumb_path, int *count)
967 int ret = MS_MEDIA_ERR_NONE;
968 sqlite3_stmt *sql_stmt = NULL;
969 char *sql = sqlite3_mprintf("SELECT count(*) FROM '%s' WHERE thumbnail_path=%Q", storage_id, thumb_path);
971 ret = _media_svc_sql_prepare_to_step(handle, sql, &sql_stmt);
973 if (ret != MS_MEDIA_ERR_NONE) {
974 media_svc_error("error when _media_svc_get_thumbnail_count. err = [%d]", ret);
978 *count = sqlite3_column_int(sql_stmt, 0);
980 SQLITE3_FINALIZE(sql_stmt);
982 return MS_MEDIA_ERR_NONE;
985 int _media_svc_get_fileinfo_by_path(sqlite3 *handle, const char *storage_id, const char *path, time_t *modified_time, unsigned long long *size)
987 int ret = MS_MEDIA_ERR_NONE;
988 sqlite3_stmt *sql_stmt = NULL;
989 char *sql = sqlite3_mprintf("SELECT modified_time, size FROM '%s' WHERE path='%q'", storage_id, path);
991 ret = _media_svc_sql_prepare_to_step(handle, sql, &sql_stmt);
993 if (ret != MS_MEDIA_ERR_NONE) {
994 media_svc_error("error when _media_svc_get_fileinfo_by_path. err = [%d]", ret);
998 *modified_time = (int)sqlite3_column_int(sql_stmt, 0);
999 *size = (unsigned long long)sqlite3_column_int64(sql_stmt, 1);
1001 SQLITE3_FINALIZE(sql_stmt);
1003 return MS_MEDIA_ERR_NONE;
1006 int _media_svc_insert_item_pass1(sqlite3 *handle, const char *storage_id, media_svc_content_info_s *content_info, int is_burst, bool stack_query, uid_t uid)
1008 int ret = MS_MEDIA_ERR_NONE;
1009 char *burst_id = NULL;
1011 media_svc_debug("START pass1");
1013 char * db_fields = (char *)"media_uuid, folder_uuid, path, file_name, media_type, mime_type, size, added_time, modified_time, is_drm, storage_type, timeline, burst_id, storage_uuid";
1016 int burst_id_int = 0;
1017 ret = _media_svc_get_burst_id(handle, storage_id, &burst_id_int);
1018 if (ret != MS_MEDIA_ERR_NONE) {
1022 if (burst_id_int > 0) {
1023 media_svc_debug("Burst id : %d", burst_id_int);
1024 burst_id = sqlite3_mprintf("%d", burst_id_int);
1027 /* Get thumbnail for burst shot */
1028 char thumb_path[MEDIA_SVC_PATHNAME_SIZE + 1] = {0, };
1032 ret = _media_svc_request_thumbnail_with_origin_size(content_info->path, thumb_path, sizeof(thumb_path), &width, &height);
1033 if(ret == MS_MEDIA_ERR_NONE) {
1034 ret = __media_svc_malloc_and_strncpy(&(content_info->thumbnail_path), thumb_path);
1035 if (ret != MS_MEDIA_ERR_NONE) {
1036 content_info->thumbnail_path = NULL;
1040 if (content_info->media_meta.width <= 0)
1041 content_info->media_meta.width = width;
1043 if (content_info->media_meta.height <= 0)
1044 content_info->media_meta.height = height;
1047 /* Update Pinyin If Support Pinyin */
1048 if(_media_svc_check_pinyin_support())
1050 if(STRING_VALID(content_info->file_name))
1051 _media_svc_get_pinyin_str(content_info->file_name, &content_info->file_name_pinyin);
1055 char *sql = sqlite3_mprintf("INSERT INTO '%s' (%s) VALUES (%Q, %Q, %Q, %Q, %d, %Q, %lld, \
1056 %d, %d, %d, %d, %d, %Q, %Q);",
1057 storage_id, db_fields,
1058 content_info->media_uuid,
1059 content_info->folder_uuid,
1061 content_info->file_name,
1062 content_info->media_type,
1063 content_info->mime_type,
1065 content_info->added_time,
1066 content_info->modified_time,
1067 content_info->is_drm,
1068 content_info->storage_type,
1069 content_info->timeline,
1076 sqlite3_free(burst_id);
1080 media_svc_debug("MAKE PASS 1 QUERY END");
1083 ret = _media_svc_sql_query(handle, sql, uid);
1085 if (ret != MS_MEDIA_ERR_NONE) {
1086 media_svc_error("failed to insert item");
1090 media_svc_debug("query : %s", sql);
1091 _media_svc_sql_query_add(&g_media_svc_insert_item_query_list, &sql);
1093 media_svc_debug("END");
1094 return MS_MEDIA_ERR_NONE;
1097 int _media_svc_insert_item_pass2(sqlite3 *handle, const char *storage_id, media_svc_content_info_s *content_info, int is_burst, bool stack_query, uid_t uid)
1099 int ret = MS_MEDIA_ERR_NONE;
1100 //char *burst_id = NULL;
1102 media_svc_debug_fenter();
1104 /*Update Pinyin If Support Pinyin*/
1105 if(_media_svc_check_pinyin_support())
1107 if(STRING_VALID(content_info->file_name))
1108 _media_svc_get_pinyin_str(content_info->file_name, &content_info->file_name_pinyin);
1109 if(STRING_VALID(content_info->media_meta.title))
1110 _media_svc_get_pinyin_str(content_info->media_meta.title, &content_info->media_meta.title_pinyin);
1111 if(STRING_VALID(content_info->media_meta.album))
1112 _media_svc_get_pinyin_str(content_info->media_meta.album, &content_info->media_meta.album_pinyin);
1113 if(STRING_VALID(content_info->media_meta.artist))
1114 _media_svc_get_pinyin_str(content_info->media_meta.artist, &content_info->media_meta.artist_pinyin);
1115 if(STRING_VALID(content_info->media_meta.album_artist))
1116 _media_svc_get_pinyin_str(content_info->media_meta.album_artist, &content_info->media_meta.album_artist_pinyin);
1117 if(STRING_VALID(content_info->media_meta.genre))
1118 _media_svc_get_pinyin_str(content_info->media_meta.genre, &content_info->media_meta.genre_pinyin);
1119 if(STRING_VALID(content_info->media_meta.composer))
1120 _media_svc_get_pinyin_str(content_info->media_meta.composer, &content_info->media_meta.composer_pinyin);
1121 if(STRING_VALID(content_info->media_meta.copyright))
1122 _media_svc_get_pinyin_str(content_info->media_meta.copyright, &content_info->media_meta.copyright_pinyin);
1123 if(STRING_VALID(content_info->media_meta.description))
1124 _media_svc_get_pinyin_str(content_info->media_meta.description, &content_info->media_meta.description_pinyin);
1127 /*modified month does not exist in Tizen 2.4*/
1128 char *sql = sqlite3_mprintf("UPDATE '%s' SET \
1129 thumbnail_path=%Q, title=%Q, album_id=%d, album=%Q, artist=%Q, album_artist=%Q, genre=%Q, composer=%Q, year=%Q, \
1130 recorded_date=%Q, copyright=%Q, track_num=%Q, description=%Q, bitrate=%d, bitpersample=%d, samplerate=%d, channel=%d, \
1131 duration=%d, longitude=%.6f, latitude=%.6f, altitude=%.6f, width=%d, height=%d, datetaken=%Q, orientation=%d, exposure_time=%Q,\
1132 fnumber=%.6f, iso=%d, model=%Q, rating=%d, weather=%Q, file_name_pinyin=%Q, title_pinyin=%Q, album_pinyin=%Q, \
1133 artist_pinyin=%Q, album_artist_pinyin=%Q, genre_pinyin=%Q, composer_pinyin=%Q, copyright_pinyin=%Q, description_pinyin=%Q WHERE path=%Q",
1135 //content_info->folder_uuid,
1136 content_info->thumbnail_path, //
1137 content_info->media_meta.title,
1138 content_info->album_id,
1139 content_info->media_meta.album,
1140 content_info->media_meta.artist,
1141 content_info->media_meta.album_artist,
1142 content_info->media_meta.genre,
1143 content_info->media_meta.composer,
1144 content_info->media_meta.year,
1145 content_info->media_meta.recorded_date,
1146 content_info->media_meta.copyright,
1147 content_info->media_meta.track_num,
1148 content_info->media_meta.description, //
1149 content_info->media_meta.bitrate,
1150 content_info->media_meta.bitpersample,
1151 content_info->media_meta.samplerate,
1152 content_info->media_meta.channel,
1153 content_info->media_meta.duration,
1154 content_info->media_meta.longitude,
1155 content_info->media_meta.latitude,
1156 content_info->media_meta.altitude,
1157 content_info->media_meta.width,
1158 content_info->media_meta.height,
1159 content_info->media_meta.datetaken,
1160 content_info->media_meta.orientation,
1161 content_info->media_meta.exposure_time,
1162 content_info->media_meta.fnumber,
1163 content_info->media_meta.iso,
1164 content_info->media_meta.model,
1165 content_info->media_meta.rating,
1166 content_info->media_meta.weather,
1167 content_info->file_name_pinyin,
1168 content_info->media_meta.title_pinyin,
1169 content_info->media_meta.album_pinyin,
1170 content_info->media_meta.artist_pinyin,
1171 content_info->media_meta.album_artist_pinyin,
1172 content_info->media_meta.genre_pinyin,
1173 content_info->media_meta.composer_pinyin,
1174 content_info->media_meta.copyright_pinyin,
1175 content_info->media_meta.description_pinyin,
1180 ret = _media_svc_sql_query(handle, sql, uid);
1182 if (ret != MS_MEDIA_ERR_NONE) {
1184 media_svc_error("failed to insert item");
1188 //media_svc_debug("query : %s", sql);
1189 _media_svc_sql_query_add(&g_media_svc_update_item_query_list, &sql);
1192 media_svc_debug_fleave();
1194 return MS_MEDIA_ERR_NONE;