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, int count, media_svc_thumbnailpath_s *thumb_path);
46 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);
47 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);
49 static int __media_svc_count_invalid_records_with_thumbnail(sqlite3 *handle, const char *storage_id, media_svc_storage_type_e storage_type, int *count)
51 int ret = MS_MEDIA_ERR_NONE;
52 sqlite3_stmt *sql_stmt = NULL;
53 char *sql = sqlite3_mprintf("SELECT count(*) FROM '%s' WHERE validity=0 AND storage_type=%d AND thumbnail_path IS NOT NULL",
54 storage_id, storage_type);
56 ret = _media_svc_sql_prepare_to_step(handle, sql, &sql_stmt);
58 if (ret != MS_MEDIA_ERR_NONE) {
59 media_svc_error("error when __media_svc_count_invalid_records_with_thumbnail. err = [%d]", ret);
63 *count = sqlite3_column_int(sql_stmt, 0);
65 SQLITE3_FINALIZE(sql_stmt);
67 return MS_MEDIA_ERR_NONE;
71 static int __media_svc_get_invalid_records_with_thumbnail(sqlite3 *handle, const char *storage_id, media_svc_storage_type_e storage_type,
72 int count, media_svc_thumbnailpath_s * thumb_path)
74 int ret = MS_MEDIA_ERR_NONE;
75 sqlite3_stmt *sql_stmt = NULL;
78 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",
79 MEDIA_SVC_DB_TABLE_MEDIA, storage_type);
81 media_svc_debug("[SQL query] : %s", sql);
83 ret = _media_svc_sql_prepare_to_step(handle, sql, &sql_stmt);
84 if (ret != MS_MEDIA_ERR_NONE) {
85 media_svc_error("error when __media_svc_get_invalid_records_with_thumbnail. err = [%d]", ret);
89 while (sqlite3_step(sql_stmt) == SQLITE_ROW) {
90 _strncpy_safe(thumb_path[idx].thumbnail_path, (const char *)sqlite3_column_text(sql_stmt, 0), sizeof(thumb_path[idx]));
91 /*media_svc_debug("thumb_path[%d]=[%s]", idx, thumb_path[idx].thumbnail_path); */
95 SQLITE3_FINALIZE(sql_stmt);
97 return MS_MEDIA_ERR_NONE;
100 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)
102 int ret = MS_MEDIA_ERR_NONE;
103 sqlite3_stmt *sql_stmt = NULL;
107 sql = sqlite3_mprintf("SELECT count(*) FROM '%s' WHERE validity=0 AND path LIKE '%q/%%' AND thumbnail_path IS NOT NULL", storage_id, folder_path);
109 sql = sqlite3_mprintf("SELECT count(*) FROM '%s' WHERE validity=0 AND folder_uuid = '%q' AND thumbnail_path IS NOT NULL", storage_id, folder_uuid);
111 ret = _media_svc_sql_prepare_to_step(handle, sql, &sql_stmt);
113 if (ret != MS_MEDIA_ERR_NONE) {
114 media_svc_error("error when __media_svc_count_invalid_folder_records_with_thumbnail. err = [%d]", ret);
118 *count = sqlite3_column_int(sql_stmt, 0);
120 SQLITE3_FINALIZE(sql_stmt);
122 return MS_MEDIA_ERR_NONE;
126 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,
127 int count, media_svc_thumbnailpath_s * thumb_path)
129 int ret = MS_MEDIA_ERR_NONE;
130 sqlite3_stmt *sql_stmt = NULL;
135 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);
137 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);
139 media_svc_debug("[SQL query] : %s", sql);
141 ret = _media_svc_sql_prepare_to_step_simple(handle, sql, &sql_stmt);
142 if (ret != MS_MEDIA_ERR_NONE) {
143 media_svc_error("error when __media_svc_get_invalid_folder_records_with_thumbnail. err = [%d]", ret);
147 while (sqlite3_step(sql_stmt) == SQLITE_ROW) {
148 _strncpy_safe(thumb_path[idx].thumbnail_path, (const char *)sqlite3_column_text(sql_stmt, 0), sizeof(thumb_path[idx]));
152 SQLITE3_FINALIZE(sql_stmt);
154 return MS_MEDIA_ERR_NONE;
157 int _media_svc_count_record_with_path(sqlite3 *handle, const char *storage_id, const char *path, int *count)
159 int ret = MS_MEDIA_ERR_NONE;
160 sqlite3_stmt *sql_stmt = NULL;
162 char *sql = sqlite3_mprintf("SELECT count(*) FROM '%s' WHERE path='%q'", storage_id, path);
164 ret = _media_svc_sql_prepare_to_step(handle, sql, &sql_stmt);
166 media_svc_retv_if(ret != MS_MEDIA_ERR_NONE, ret);
168 *count = sqlite3_column_int(sql_stmt, 0);
170 SQLITE3_FINALIZE(sql_stmt);
172 return MS_MEDIA_ERR_NONE;
175 char *_media_svc_get_thumb_default_path(uid_t uid)
177 char *result_passwd = NULL;
178 struct group *grpinfo = NULL;
179 if (uid == getuid()) {
180 grpinfo = getgrnam("users");
181 if (grpinfo == NULL) {
182 media_svc_error("getgrnam(users) returns NULL !");
185 result_passwd = g_strdup(MEDIA_SVC_THUMB_DEFAULT_PATH);
187 char passwd_str[MEDIA_SVC_PATHNAME_SIZE] = {0, };
188 struct passwd *userinfo = getpwuid(uid);
189 if (userinfo == NULL) {
190 media_svc_error("getpwuid(%d) returns NULL !", uid);
193 grpinfo = getgrnam("users");
194 if (grpinfo == NULL) {
195 media_svc_error("getgrnam(users) returns NULL !");
198 /* Compare git_t type and not group name */
199 if (grpinfo->gr_gid != userinfo->pw_gid) {
200 media_svc_error("UID [%d] does not belong to 'users' group!", uid);
203 sprintf(passwd_str, "%s/share/media/.thumb/thumb_default.png", userinfo->pw_dir);
204 result_passwd = g_strdup(passwd_str);
207 return result_passwd;
210 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)
212 int ret = MS_MEDIA_ERR_NONE;
213 char *burst_id = NULL;
214 int ini_val = _media_svc_get_ini_value();
216 const char *db_fields = "media_uuid, path, file_name, media_type, mime_type, size, added_time, modified_time, folder_uuid, \
217 thumbnail_path, title, album_id, album, artist, album_artist, genre, composer, year, recorded_date, copyright, track_num, description, \
218 category, keyword, location_tag, content_name, age_rating, author, provider, last_played_time, played_count, favourite, \
219 bitrate, bitpersample, samplerate, channel, duration, longitude, latitude, altitude, exposure_time, fnumber, iso, model, width, height, datetaken, orientation, \
220 rating, is_drm, storage_type, burst_id, timeline, weather, sync_status, \
221 file_name_pinyin, title_pinyin, album_pinyin, artist_pinyin, album_artist_pinyin, genre_pinyin, composer_pinyin, copyright_pinyin, description_pinyin, storage_uuid";
223 /* This sql is due to sqlite3_mprintf's wrong operation when using floating point in the text format */
224 /* This code will be removed when sqlite3_mprintf works clearly */
225 char *test_sql = sqlite3_mprintf("%f, %f, %f", content_info->media_meta.longitude, content_info->media_meta.latitude, content_info->media_meta.altitude);
226 sqlite3_free(test_sql);
229 int burst_id_int = 0;
230 ret = _media_svc_get_burst_id(handle, storage_id, &burst_id_int);
231 if (ret != MS_MEDIA_ERR_NONE)
234 if (burst_id_int > 0) {
235 media_svc_debug("Burst id : %d", burst_id_int);
236 burst_id = sqlite3_mprintf("%d", burst_id_int);
239 /* Get thumbnail for burst shot */
241 char thumb_path[MEDIA_SVC_PATHNAME_SIZE + 1] = {0, };
245 ret = _media_svc_request_thumbnail_with_origin_size(content_info->path, thumb_path, sizeof(thumb_path), &width, &height, uid);
246 if (ret == MS_MEDIA_ERR_NONE) {
247 ret = __media_svc_malloc_and_strncpy(&(content_info->thumbnail_path), thumb_path);
248 if (ret != MS_MEDIA_ERR_NONE)
249 content_info->thumbnail_path = NULL;
252 if (content_info->media_meta.width <= 0)
253 content_info->media_meta.width = width;
255 if (content_info->media_meta.height <= 0)
256 content_info->media_meta.height = height;
260 /*Update Pinyin If Support Pinyin*/
261 if (_media_svc_check_pinyin_support()) {
262 if (STRING_VALID(content_info->file_name))
263 _media_svc_get_pinyin_str(content_info->file_name, &content_info->file_name_pinyin);
264 if (STRING_VALID(content_info->media_meta.title))
265 _media_svc_get_pinyin_str(content_info->media_meta.title, &content_info->media_meta.title_pinyin);
266 if (STRING_VALID(content_info->media_meta.album))
267 _media_svc_get_pinyin_str(content_info->media_meta.album, &content_info->media_meta.album_pinyin);
268 if (STRING_VALID(content_info->media_meta.artist))
269 _media_svc_get_pinyin_str(content_info->media_meta.artist, &content_info->media_meta.artist_pinyin);
270 if (STRING_VALID(content_info->media_meta.album_artist))
271 _media_svc_get_pinyin_str(content_info->media_meta.album_artist, &content_info->media_meta.album_artist_pinyin);
272 if (STRING_VALID(content_info->media_meta.genre))
273 _media_svc_get_pinyin_str(content_info->media_meta.genre, &content_info->media_meta.genre_pinyin);
274 if (STRING_VALID(content_info->media_meta.composer))
275 _media_svc_get_pinyin_str(content_info->media_meta.composer, &content_info->media_meta.composer_pinyin);
276 if (STRING_VALID(content_info->media_meta.copyright))
277 _media_svc_get_pinyin_str(content_info->media_meta.copyright, &content_info->media_meta.copyright_pinyin);
278 if (STRING_VALID(content_info->media_meta.description))
279 _media_svc_get_pinyin_str(content_info->media_meta.description, &content_info->media_meta.description_pinyin);
282 char *sql = sqlite3_mprintf("INSERT INTO '%s' (%s) VALUES (%Q, %Q, %Q, %d, %Q, %lld, %d, %d, %Q, \
283 %Q, %Q, %d, %Q, %Q, %Q, %Q, %Q, %Q, %Q, %Q, %Q, %Q, \
284 %Q, %Q, %Q, %Q, %Q, %Q, %Q, %d, %d, %d, \
285 %d, %d, %d, %d, %d, %.6f, %.6f, %.6f, %Q, %.6f, %d, %Q, %d, %d, %Q, %d, \
286 %d, %d, %d, %Q, %d, %Q, %d, \
287 %Q, %Q, %Q, %Q, %Q, %Q, %Q, %Q, %Q, %Q);",
288 content_info->storage_uuid, db_fields,
289 content_info->media_uuid,
291 content_info->file_name,
292 content_info->media_type,
293 content_info->mime_type,
295 content_info->added_time,
296 content_info->modified_time,
297 content_info->folder_uuid, /**/
298 content_info->thumbnail_path,
299 content_info->media_meta.title,
300 content_info->album_id,
301 content_info->media_meta.album,
302 content_info->media_meta.artist,
303 content_info->media_meta.album_artist,
304 content_info->media_meta.genre,
305 content_info->media_meta.composer,
306 content_info->media_meta.year,
307 content_info->media_meta.recorded_date,
308 content_info->media_meta.copyright,
309 content_info->media_meta.track_num,
310 content_info->media_meta.description, /**/
311 content_info->media_meta.category,
312 content_info->media_meta.keyword,
313 content_info->media_meta.location_tag,
314 content_info->media_meta.content_name,
315 content_info->media_meta.age_rating,
316 content_info->media_meta.author,
317 content_info->media_meta.provider,
318 content_info->last_played_time,
319 content_info->played_count,
320 content_info->favourate, /**/
321 content_info->media_meta.bitrate,
322 content_info->media_meta.bitpersample,
323 content_info->media_meta.samplerate,
324 content_info->media_meta.channel,
325 content_info->media_meta.duration,
326 content_info->media_meta.longitude,
327 content_info->media_meta.latitude,
328 content_info->media_meta.altitude,
329 content_info->media_meta.exposure_time,
330 content_info->media_meta.fnumber,
331 content_info->media_meta.iso,
332 content_info->media_meta.model,
333 content_info->media_meta.width,
334 content_info->media_meta.height,
335 content_info->media_meta.datetaken,
336 content_info->media_meta.orientation,
337 content_info->media_meta.rating,
338 content_info->is_drm,
339 content_info->storage_type,
341 content_info->timeline,
342 content_info->media_meta.weather,
343 content_info->sync_status,
344 content_info->file_name_pinyin,
345 content_info->media_meta.title_pinyin,
346 content_info->media_meta.album_pinyin,
347 content_info->media_meta.artist_pinyin,
348 content_info->media_meta.album_artist_pinyin,
349 content_info->media_meta.genre_pinyin,
350 content_info->media_meta.composer_pinyin,
351 content_info->media_meta.copyright_pinyin,
352 content_info->media_meta.description_pinyin,
353 content_info->storage_uuid
357 sqlite3_free(burst_id);
362 ret = _media_svc_sql_query(handle, sql, uid);
364 if (ret != MS_MEDIA_ERR_NONE) {
365 media_svc_error("failed to insert item");
369 media_svc_debug("query : %s", sql);
370 _media_svc_sql_query_add(&g_media_svc_insert_item_query_list, &sql);
373 return MS_MEDIA_ERR_NONE;
376 int _media_svc_update_meta_with_data(sqlite3 *handle, media_svc_content_info_s *content_info)
378 int ret = MS_MEDIA_ERR_NONE;
380 /* This sql is due to sqlite3_mprintf's wrong operation when using floating point in the text format */
381 /* This code will be removed when sqlite3_mprintf works clearly */
382 char *test_sql = sqlite3_mprintf("%f, %f, %f", content_info->media_meta.longitude, content_info->media_meta.latitude, content_info->media_meta.altitude);
383 sqlite3_free(test_sql);
385 /*Update Pinyin If Support Pinyin*/
386 if (_media_svc_check_pinyin_support()) {
387 if (STRING_VALID(content_info->file_name))
388 _media_svc_get_pinyin_str(content_info->file_name, &content_info->file_name_pinyin);
389 if (STRING_VALID(content_info->media_meta.title))
390 _media_svc_get_pinyin_str(content_info->media_meta.title, &content_info->media_meta.title_pinyin);
391 if (STRING_VALID(content_info->media_meta.album))
392 _media_svc_get_pinyin_str(content_info->media_meta.album, &content_info->media_meta.album_pinyin);
393 if (STRING_VALID(content_info->media_meta.artist))
394 _media_svc_get_pinyin_str(content_info->media_meta.artist, &content_info->media_meta.artist_pinyin);
395 if (STRING_VALID(content_info->media_meta.album_artist))
396 _media_svc_get_pinyin_str(content_info->media_meta.album_artist, &content_info->media_meta.album_artist_pinyin);
397 if (STRING_VALID(content_info->media_meta.genre))
398 _media_svc_get_pinyin_str(content_info->media_meta.genre, &content_info->media_meta.genre_pinyin);
399 if (STRING_VALID(content_info->media_meta.composer))
400 _media_svc_get_pinyin_str(content_info->media_meta.composer, &content_info->media_meta.composer_pinyin);
401 if (STRING_VALID(content_info->media_meta.copyright))
402 _media_svc_get_pinyin_str(content_info->media_meta.copyright, &content_info->media_meta.copyright_pinyin);
403 if (STRING_VALID(content_info->media_meta.description))
404 _media_svc_get_pinyin_str(content_info->media_meta.description, &content_info->media_meta.description_pinyin);
407 char *sql = sqlite3_mprintf("UPDATE %s SET title=%Q, album=%Q, artist=%Q, album_artist=%Q, genre=%Q, composer=%Q, copyright=%Q, description=%Q, \
408 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 \
410 MEDIA_SVC_DB_TABLE_MEDIA,
411 content_info->media_meta.title,
412 content_info->media_meta.album,
413 content_info->media_meta.artist,
414 content_info->media_meta.album_artist,
415 content_info->media_meta.genre,
416 content_info->media_meta.composer,
417 content_info->media_meta.copyright,
418 content_info->media_meta.description,
419 content_info->file_name_pinyin,
420 content_info->media_meta.title_pinyin,
421 content_info->media_meta.album_pinyin,
422 content_info->media_meta.artist_pinyin,
423 content_info->media_meta.album_artist_pinyin,
424 content_info->media_meta.genre_pinyin,
425 content_info->media_meta.composer_pinyin,
426 content_info->media_meta.copyright_pinyin,
427 content_info->media_meta.description_pinyin,
432 media_svc_debug("query : %s", sql);
433 _media_svc_sql_query_add(&g_media_svc_update_item_query_list, &sql);
435 media_svc_error("sqlite3_mprintf failed");
436 ret = MS_MEDIA_ERR_OUT_OF_MEMORY;
442 int _media_svc_update_item_with_data(sqlite3 *handle, const char *storage_id, media_svc_content_info_s *content_info, uid_t uid)
444 int ret = MS_MEDIA_ERR_NONE;
446 /* This sql is due to sqlite3_mprintf's wrong operation when using floating point in the text format */
447 /* This code will be removed when sqlite3_mprintf works clearly */
448 char *test_sql = sqlite3_mprintf("%f, %f, %f", content_info->media_meta.longitude, content_info->media_meta.latitude, content_info->media_meta.altitude);
449 sqlite3_free(test_sql);
451 /*Update Pinyin If Support Pinyin*/
452 if (_media_svc_check_pinyin_support()) {
453 if (STRING_VALID(content_info->file_name))
454 _media_svc_get_pinyin_str(content_info->file_name, &content_info->file_name_pinyin);
455 if (STRING_VALID(content_info->media_meta.title))
456 _media_svc_get_pinyin_str(content_info->media_meta.title, &content_info->media_meta.title_pinyin);
457 if (STRING_VALID(content_info->media_meta.album))
458 _media_svc_get_pinyin_str(content_info->media_meta.album, &content_info->media_meta.album_pinyin);
459 if (STRING_VALID(content_info->media_meta.artist))
460 _media_svc_get_pinyin_str(content_info->media_meta.artist, &content_info->media_meta.artist_pinyin);
461 if (STRING_VALID(content_info->media_meta.album_artist))
462 _media_svc_get_pinyin_str(content_info->media_meta.album_artist, &content_info->media_meta.album_artist_pinyin);
463 if (STRING_VALID(content_info->media_meta.genre))
464 _media_svc_get_pinyin_str(content_info->media_meta.genre, &content_info->media_meta.genre_pinyin);
465 if (STRING_VALID(content_info->media_meta.composer))
466 _media_svc_get_pinyin_str(content_info->media_meta.composer, &content_info->media_meta.composer_pinyin);
467 if (STRING_VALID(content_info->media_meta.copyright))
468 _media_svc_get_pinyin_str(content_info->media_meta.copyright, &content_info->media_meta.copyright_pinyin);
469 if (STRING_VALID(content_info->media_meta.description))
470 _media_svc_get_pinyin_str(content_info->media_meta.description, &content_info->media_meta.description_pinyin);
473 char *sql = sqlite3_mprintf("UPDATE '%s' SET \
474 size=%lld, modified_time=%d, thumbnail_path=%Q, title=%Q, album_id=%d, album=%Q, artist=%Q, album_artist=%Q, genre=%Q, \
475 composer=%Q, year=%Q, recorded_date=%Q, copyright=%Q, track_num=%Q, description=%Q, \
476 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, \
477 orientation=%d WHERE path=%Q",
480 content_info->modified_time,
481 content_info->thumbnail_path,
482 content_info->media_meta.title,
483 content_info->album_id,
484 content_info->media_meta.album,
485 content_info->media_meta.artist,
486 content_info->media_meta.album_artist,
487 content_info->media_meta.genre,
488 content_info->media_meta.composer,
489 content_info->media_meta.year,
490 content_info->media_meta.recorded_date,
491 content_info->media_meta.copyright,
492 content_info->media_meta.track_num,
493 content_info->media_meta.description,
494 content_info->media_meta.bitrate,
495 content_info->media_meta.bitpersample,
496 content_info->media_meta.samplerate,
497 content_info->media_meta.channel,
498 content_info->media_meta.duration,
499 content_info->media_meta.longitude,
500 content_info->media_meta.latitude,
501 content_info->media_meta.altitude,
502 content_info->media_meta.exposure_time,
503 content_info->media_meta.fnumber,
504 content_info->media_meta.iso,
505 content_info->media_meta.model,
506 content_info->media_meta.width,
507 content_info->media_meta.height,
508 content_info->media_meta.datetaken,
509 content_info->media_meta.orientation,
513 ret = _media_svc_sql_query(handle, sql, uid);
518 int _media_svc_get_thumbnail_path_by_path(sqlite3 *handle, const char *storage_id, const char *path, char *thumbnail_path)
520 int ret = MS_MEDIA_ERR_NONE;
521 sqlite3_stmt *sql_stmt = NULL;
523 char *sql = sqlite3_mprintf("SELECT thumbnail_path FROM '%s' WHERE path='%q'", storage_id, path);
525 ret = _media_svc_sql_prepare_to_step(handle, sql, &sql_stmt);
527 if (ret != MS_MEDIA_ERR_NONE) {
528 if (ret == MS_MEDIA_ERR_DB_NO_RECORD)
529 media_svc_debug("there is no thumbnail.");
531 media_svc_error("error when _media_svc_get_thumbnail_path_by_path. err = [%d]", ret);
536 _strncpy_safe(thumbnail_path, (const char *)sqlite3_column_text(sql_stmt, 0), MEDIA_SVC_PATHNAME_SIZE);
538 SQLITE3_FINALIZE(sql_stmt);
540 return MS_MEDIA_ERR_NONE;
543 int _media_svc_get_media_type_by_path(sqlite3 *handle, const char *storage_id, const char *path, int *media_type)
545 int ret = MS_MEDIA_ERR_NONE;
546 sqlite3_stmt *sql_stmt = NULL;
548 char *sql = sqlite3_mprintf("SELECT media_type FROM '%s' WHERE path='%q'", storage_id, path);
550 ret = _media_svc_sql_prepare_to_step(handle, sql, &sql_stmt);
552 if (ret != MS_MEDIA_ERR_NONE) {
553 media_svc_error("error when _media_svc_get_media_type_by_path. err = [%d]", ret);
557 *media_type = sqlite3_column_int(sql_stmt, 0);
559 SQLITE3_FINALIZE(sql_stmt);
561 return MS_MEDIA_ERR_NONE;
564 int _media_svc_delete_item_by_path(sqlite3 *handle, const char *storage_id, const char *path, bool stack_query, uid_t uid)
566 int ret = MS_MEDIA_ERR_NONE;
567 char *sql = sqlite3_mprintf("DELETE FROM '%s' WHERE path='%q'", storage_id, path);
570 ret = _media_svc_sql_query(handle, sql, uid);
572 if (ret != MS_MEDIA_ERR_NONE) {
573 media_svc_error("failed to delete item");
577 media_svc_debug("query : %s", sql);
578 _media_svc_sql_query_add(&g_media_svc_insert_item_query_list, &sql);
584 int _media_svc_truncate_table(sqlite3 *handle, const char *storage_id, media_svc_storage_type_e storage_type, uid_t uid)
586 int ret = MS_MEDIA_ERR_NONE;
588 char *sql = sqlite3_mprintf("DELETE FROM '%s' where storage_type=%d", storage_id, storage_type);
590 ret = _media_svc_sql_query(handle, sql, uid);
596 int _media_svc_delete_invalid_items(sqlite3 *handle, const char *storage_id, media_svc_storage_type_e storage_type, uid_t uid)
599 media_svc_thumbnailpath_s *thumbpath_record = NULL;
600 int invalid_count = 0;
601 int ret = MS_MEDIA_ERR_NONE;
603 ret = __media_svc_count_invalid_records_with_thumbnail(handle, storage_id, storage_type, &invalid_count);
604 media_svc_retv_if(ret != MS_MEDIA_ERR_NONE, ret);
606 media_svc_debug("invalid count: %d", invalid_count);
608 if (invalid_count > 0) {
609 thumbpath_record = (media_svc_thumbnailpath_s *)calloc(invalid_count, sizeof(media_svc_thumbnailpath_s));
610 if (thumbpath_record == NULL) {
611 media_svc_error("fail to memory allocation");
612 return MS_MEDIA_ERR_OUT_OF_MEMORY;
615 ret = __media_svc_get_invalid_records_with_thumbnail(handle, storage_id, storage_type, invalid_count, thumbpath_record);
616 if (ret != MS_MEDIA_ERR_NONE) {
617 media_svc_error("error when get thumbnail record");
618 SAFE_FREE(thumbpath_record);
622 media_svc_debug("There is no item with thumbnail");
625 char *sql = sqlite3_mprintf("DELETE FROM '%s' WHERE validity = 0", storage_id);
627 ret = _media_svc_sql_query(handle, sql, uid);
629 if (ret != MS_MEDIA_ERR_NONE) {
630 SAFE_FREE(thumbpath_record);
634 /*Delete thumbnails*/
635 char *default_thumbnail_path = _media_svc_get_thumb_default_path(uid);
636 for (idx = 0; idx < invalid_count; idx++) {
637 if ((strlen(thumbpath_record[idx].thumbnail_path) > 0) && (STRING_VALID(default_thumbnail_path)) && (strncmp(thumbpath_record[idx].thumbnail_path, default_thumbnail_path, strlen(default_thumbnail_path)) != 0)) {
638 ret = _media_svc_remove_file(thumbpath_record[idx].thumbnail_path);
639 if (ret != MS_MEDIA_ERR_NONE)
640 media_svc_error("fail to remove thumbnail file.");
644 SAFE_FREE(thumbpath_record);
645 SAFE_FREE(default_thumbnail_path);
647 return MS_MEDIA_ERR_NONE;
650 int _media_svc_delete_invalid_folder_items(sqlite3 *handle, const char *storage_id, const char *folder_path, bool is_recursive, uid_t uid)
653 media_svc_thumbnailpath_s *thumbpath_record = NULL;
654 int invalid_count = 0;
655 int ret = MS_MEDIA_ERR_NONE;
656 char folder_uuid[MEDIA_SVC_UUID_SIZE+1] = {0,};
659 /*get folder uuid from DB*/
660 ret = _media_svc_get_folder_id_by_foldername(handle, storage_id, folder_path, folder_uuid, uid);
661 media_svc_retv_if(ret != MS_MEDIA_ERR_NONE, ret);
663 ret = __media_svc_count_invalid_folder_records_with_thumbnail(handle, storage_id, folder_path, folder_uuid, is_recursive, &invalid_count);
664 media_svc_retv_if(ret != MS_MEDIA_ERR_NONE, ret);
666 media_svc_debug("invalid count: %d", invalid_count);
668 if (invalid_count > 0) {
669 thumbpath_record = (media_svc_thumbnailpath_s *)calloc(invalid_count, sizeof(media_svc_thumbnailpath_s));
670 if (thumbpath_record == NULL) {
671 media_svc_error("fail to memory allocation");
672 return MS_MEDIA_ERR_OUT_OF_MEMORY;
675 ret = __media_svc_get_invalid_folder_records_with_thumbnail(handle, storage_id, folder_path, folder_uuid, is_recursive, invalid_count, thumbpath_record);
676 if (ret != MS_MEDIA_ERR_NONE) {
677 media_svc_error("error when get thumbnail record");
678 SAFE_FREE(thumbpath_record);
682 media_svc_debug("There is no item with thumbnail");
686 sql = sqlite3_mprintf("DELETE FROM '%s' WHERE validity = 0 AND path LIKE '%q/%%'", storage_id, folder_path);
688 sql = sqlite3_mprintf("DELETE FROM '%s' WHERE validity = 0 AND folder_uuid='%q'", storage_id, folder_uuid);
690 ret = _media_svc_sql_query(handle, sql, uid);
692 if (ret != MS_MEDIA_ERR_NONE) {
693 SAFE_FREE(thumbpath_record);
697 /*Delete thumbnails*/
698 if (thumbpath_record != NULL) {
699 char *default_thumbnail_path = _media_svc_get_thumb_default_path(uid);
700 if (STRING_VALID(default_thumbnail_path)) {
701 for (idx = 0; idx < invalid_count; idx++) {
702 if ((strlen(thumbpath_record[idx].thumbnail_path) > 0) && (strncmp(thumbpath_record[idx].thumbnail_path, default_thumbnail_path, strlen(default_thumbnail_path)) != 0)) {
703 ret = _media_svc_remove_file(thumbpath_record[idx].thumbnail_path);
704 if (ret != MS_MEDIA_ERR_NONE)
705 media_svc_error("fail to remove thumbnail file.");
710 SAFE_FREE(thumbpath_record);
711 SAFE_FREE(default_thumbnail_path);
714 return MS_MEDIA_ERR_NONE;
717 int _media_svc_update_item_validity(sqlite3 *handle, const char *storage_id, const char *path, int validity, bool stack_query, uid_t uid)
719 int ret = MS_MEDIA_ERR_NONE;
721 char *sql = sqlite3_mprintf("UPDATE '%s' SET validity=%d WHERE path= '%q'", storage_id, validity, path);
724 ret = _media_svc_sql_query(handle, sql, uid);
727 _media_svc_sql_query_add(&g_media_svc_item_validity_query_list, &sql);
733 int _media_svc_update_thumbnail_path(sqlite3 *handle, const char *storage_id, const char *path, const char *thumb_path, uid_t uid)
735 int ret = MS_MEDIA_ERR_NONE;
737 char *sql = sqlite3_mprintf("UPDATE '%s' SET thumbnail_path=%Q WHERE path= %Q", storage_id, thumb_path, path);
739 ret = _media_svc_sql_query(handle, sql, uid);
745 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)
747 int ret = MS_MEDIA_ERR_NONE;
749 char *sql = sqlite3_mprintf("UPDATE '%s' SET validity=%d WHERE storage_type=%d", storage_id, validity, storage_type);
751 ret = _media_svc_sql_query(handle, sql, uid);
757 int _media_svc_update_folder_item_validity(sqlite3 *handle, const char *storage_id, const char *folder_path, int validity, uid_t uid)
759 int ret = MS_MEDIA_ERR_NONE;
761 char folder_uuid[MEDIA_SVC_UUID_SIZE + 1] = {0, };
762 sqlite3_stmt *sql_stmt = NULL;
765 sql = sqlite3_mprintf("SELECT folder_uuid FROM '%s' WHERE path='%q' AND storage_uuid='%q'", MEDIA_SVC_DB_TABLE_FOLDER, folder_path, storage_id);
767 ret = _media_svc_sql_prepare_to_step(handle, sql, &sql_stmt);
768 if (ret != MS_MEDIA_ERR_NONE) {
769 if (ret == MS_MEDIA_ERR_DB_NO_RECORD)
770 media_svc_debug("folder not exist");
772 media_svc_error("error when get folder_id. err = [%d]", ret);
777 _strncpy_safe(folder_uuid, (const char *)sqlite3_column_text(sql_stmt, 0), MEDIA_SVC_UUID_SIZE + 1);
778 SQLITE3_FINALIZE(sql_stmt);
780 /*Update folder item validity*/
781 sql = sqlite3_mprintf("UPDATE '%s' SET validity=%d WHERE folder_uuid='%q'", storage_id, validity, folder_uuid);
783 ret = _media_svc_sql_query(handle, sql, uid);
789 int _media_svc_update_recursive_folder_item_validity(sqlite3 *handle, const char *storage_id, const char *folder_path, int validity, uid_t uid)
791 int ret = MS_MEDIA_ERR_NONE;
793 /*Update folder item validity*/
794 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);
796 ret = _media_svc_sql_query(handle, sql, uid);
802 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,
803 const char *file_name, int modified_time, const char *folder_uuid, const char *thumb_path, bool stack_query, uid_t uid)
805 /* update path, filename, modified_time, folder_uuid, thumbnail_path, */
806 /* played_count, last_played_time, last_played_position, favourite, storaget_type*/
808 int ret = MS_MEDIA_ERR_NONE;
811 if (thumb_path != NULL) {
812 sql = sqlite3_mprintf("UPDATE '%s' SET \
813 path=%Q, file_name=%Q, modified_time=%d, folder_uuid=%Q, thumbnail_path=%Q, storage_type=%d, \
814 played_count=0, last_played_time=0, last_played_position=0 \
816 storage_id, dest_path, file_name, modified_time, folder_uuid, thumb_path, dest_storage, src_path);
818 sql = sqlite3_mprintf("UPDATE '%s' SET \
819 path=%Q, file_name=%Q, modified_time=%d, folder_uuid=%Q, storage_type=%d, \
820 played_count=0, last_played_time=0, last_played_position=0 \
822 storage_id, dest_path, file_name, modified_time, folder_uuid, dest_storage, src_path);
826 ret = _media_svc_sql_query(handle, sql, uid);
829 _media_svc_sql_query_add(&g_media_svc_move_item_query_list, &sql);
835 int _media_svc_list_query_do(sqlite3 *handle, media_svc_query_type_e query_type, uid_t uid)
837 int ret = MS_MEDIA_ERR_NONE;
839 ret = _media_svc_sql_begin_trans(handle, uid);
840 media_svc_retv_if(ret != MS_MEDIA_ERR_NONE, ret);
842 if (query_type == MEDIA_SVC_QUERY_SET_ITEM_VALIDITY)
843 ret = _media_svc_sql_query_list(handle, &g_media_svc_item_validity_query_list, uid);
844 else if (query_type == MEDIA_SVC_QUERY_MOVE_ITEM)
845 ret = _media_svc_sql_query_list(handle, &g_media_svc_move_item_query_list, uid);
846 else if (query_type == MEDIA_SVC_QUERY_INSERT_ITEM)
847 ret = _media_svc_sql_query_list(handle, &g_media_svc_insert_item_query_list, uid);
848 else if (query_type == MEDIA_SVC_QUERY_UPDATE_ITEM)
849 ret = _media_svc_sql_query_list(handle, &g_media_svc_update_item_query_list, uid);
850 else if (query_type == MEDIA_SVC_QUERY_INSERT_FOLDER)
851 ret = _media_svc_sql_query_list(handle, _media_svc_get_folder_list_ptr(), uid);
853 ret = MS_MEDIA_ERR_INVALID_PARAMETER;
855 if (ret != MS_MEDIA_ERR_NONE) {
856 media_svc_error("_media_svc_list_query_do failed. start rollback");
857 _media_svc_sql_rollback_trans(handle, uid);
861 ret = _media_svc_sql_end_trans(handle, uid);
862 if (ret != MS_MEDIA_ERR_NONE) {
863 media_svc_error("mb_svc_sqlite3_commit_trans failed.. Now start to rollback");
864 _media_svc_sql_rollback_trans(handle, uid);
868 return MS_MEDIA_ERR_NONE;
871 int _media_svc_get_burst_id(sqlite3 *handle, const char *storage_id, int *id)
873 int ret = MS_MEDIA_ERR_NONE;
875 sqlite3_stmt *sql_stmt = NULL;
876 char *sql = sqlite3_mprintf("SELECT max(CAST(burst_id AS INTEGER)) FROM '%s'", storage_id);
878 ret = _media_svc_sql_prepare_to_step(handle, sql, &sql_stmt);
880 if (ret != MS_MEDIA_ERR_NONE) {
881 media_svc_error("error when _media_svc_get_burst_id. err = [%d]", ret);
885 cur_id = sqlite3_column_int(sql_stmt, 0);
887 SQLITE3_FINALIZE(sql_stmt);
889 return MS_MEDIA_ERR_NONE;
892 int _media_svc_get_noti_info(sqlite3 *handle, const char *storage_id, const char *path, int update_item, media_svc_noti_item **item)
894 int ret = MS_MEDIA_ERR_NONE;
895 sqlite3_stmt *sql_stmt = NULL;
897 int is_root_dir = FALSE;
900 media_svc_error("invalid parameter");
901 return MS_MEDIA_ERR_INVALID_PARAMETER;
904 if (update_item == MS_MEDIA_ITEM_FILE)
905 sql = sqlite3_mprintf("SELECT media_uuid, media_type, mime_type FROM '%s' WHERE path=%Q", storage_id, path);
906 else if (update_item == MS_MEDIA_ITEM_DIRECTORY)
907 sql = sqlite3_mprintf("SELECT folder_uuid FROM '%s' WHERE path=%Q AND storage_uuid='%s'", MEDIA_SVC_DB_TABLE_FOLDER, path, storage_id);
909 media_svc_error("_media_svc_get_noti_info failed : update item");
910 return MS_MEDIA_ERR_INVALID_PARAMETER;
913 ret = _media_svc_sql_prepare_to_step(handle, sql, &sql_stmt);
915 if (ret != MS_MEDIA_ERR_NONE) {
916 if (ret == MS_MEDIA_ERR_DB_NO_RECORD && update_item == MS_MEDIA_ITEM_DIRECTORY) {
917 media_svc_debug("This is root directory of media");
921 media_svc_error("error when _media_svc_get_noti_info. err = [%d]", ret);
926 *item = calloc(1, sizeof(media_svc_noti_item));
928 media_svc_error("_media_svc_get_noti_info failed : calloc");
929 return MS_MEDIA_ERR_OUT_OF_MEMORY;
932 if (update_item == MS_MEDIA_ITEM_FILE) {
933 (*item)->media_uuid = g_strdup((const char *)sqlite3_column_text(sql_stmt, 0));
934 (*item)->media_type = sqlite3_column_int(sql_stmt, 1);
935 (*item)->mime_type = g_strdup((const char *)sqlite3_column_text(sql_stmt, 2));
936 } else if (update_item == MS_MEDIA_ITEM_DIRECTORY) {
938 (*item)->media_uuid = NULL;
940 (*item)->media_uuid = g_strdup((const char *)sqlite3_column_text(sql_stmt, 0));
943 SQLITE3_FINALIZE(sql_stmt);
945 return MS_MEDIA_ERR_NONE;
948 int _media_svc_count_invalid_folder_items(sqlite3 *handle, const char *storage_id, const char *folder_path, int *count)
950 int ret = MS_MEDIA_ERR_NONE;
951 sqlite3_stmt *sql_stmt = NULL;
953 char *sql = sqlite3_mprintf("SELECT count(*) FROM '%s' WHERE validity=0 AND path LIKE '%q/%%'", storage_id, folder_path);
955 ret = _media_svc_sql_prepare_to_step(handle, sql, &sql_stmt);
957 if (ret != MS_MEDIA_ERR_NONE) {
958 media_svc_error("error when _media_svc_count_invalid_folder_items. err = [%d]", ret);
962 *count = sqlite3_column_int(sql_stmt, 0);
964 SQLITE3_FINALIZE(sql_stmt);
966 return MS_MEDIA_ERR_NONE;
969 int _media_svc_get_thumbnail_count(sqlite3 *handle, const char *storage_id, const char *thumb_path, int *count)
971 int ret = MS_MEDIA_ERR_NONE;
972 sqlite3_stmt *sql_stmt = NULL;
973 char *sql = sqlite3_mprintf("SELECT count(*) FROM '%s' WHERE thumbnail_path=%Q", storage_id, thumb_path);
975 ret = _media_svc_sql_prepare_to_step(handle, sql, &sql_stmt);
977 if (ret != MS_MEDIA_ERR_NONE) {
978 media_svc_error("error when _media_svc_get_thumbnail_count. err = [%d]", ret);
982 *count = sqlite3_column_int(sql_stmt, 0);
984 SQLITE3_FINALIZE(sql_stmt);
986 return MS_MEDIA_ERR_NONE;
989 int _media_svc_get_fileinfo_by_path(sqlite3 *handle, const char *storage_id, const char *path, time_t *modified_time, unsigned long long *size)
991 int ret = MS_MEDIA_ERR_NONE;
992 sqlite3_stmt *sql_stmt = NULL;
993 char *sql = sqlite3_mprintf("SELECT modified_time, size FROM '%s' WHERE path='%q'", storage_id, path);
995 ret = _media_svc_sql_prepare_to_step(handle, sql, &sql_stmt);
997 if (ret != MS_MEDIA_ERR_NONE) {
998 media_svc_error("error when _media_svc_get_fileinfo_by_path. err = [%d]", ret);
1002 *modified_time = (int)sqlite3_column_int(sql_stmt, 0);
1003 *size = (unsigned long long)sqlite3_column_int64(sql_stmt, 1);
1005 SQLITE3_FINALIZE(sql_stmt);
1007 return MS_MEDIA_ERR_NONE;
1010 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)
1012 int ret = MS_MEDIA_ERR_NONE;
1013 char *burst_id = NULL;
1015 media_svc_debug("START pass1");
1017 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";
1020 int burst_id_int = 0;
1021 ret = _media_svc_get_burst_id(handle, storage_id, &burst_id_int);
1022 if (ret != MS_MEDIA_ERR_NONE) {
1026 if (burst_id_int > 0) {
1027 media_svc_debug("Burst id : %d", burst_id_int);
1028 burst_id = sqlite3_mprintf("%d", burst_id_int);
1031 /* Get thumbnail for burst shot */
1032 char thumb_path[MEDIA_SVC_PATHNAME_SIZE + 1] = {0, };
1036 ret = _media_svc_request_thumbnail_with_origin_size(content_info->path, thumb_path, sizeof(thumb_path), &width, &height);
1037 if (ret == MS_MEDIA_ERR_NONE) {
1038 ret = __media_svc_malloc_and_strncpy(&(content_info->thumbnail_path), thumb_path);
1039 if (ret != MS_MEDIA_ERR_NONE) {
1040 content_info->thumbnail_path = NULL;
1044 if (content_info->media_meta.width <= 0)
1045 content_info->media_meta.width = width;
1047 if (content_info->media_meta.height <= 0)
1048 content_info->media_meta.height = height;
1051 /* Update Pinyin If Support Pinyin */
1052 if (_media_svc_check_pinyin_support()) {
1053 if (STRING_VALID(content_info->file_name))
1054 _media_svc_get_pinyin_str(content_info->file_name, &content_info->file_name_pinyin);
1058 char *sql = sqlite3_mprintf("INSERT INTO '%s' (%s) VALUES (%Q, %Q, %Q, %Q, %d, %Q, %lld, \
1059 %d, %d, %d, %d, %d, %Q, %Q);",
1060 storage_id, db_fields,
1061 content_info->media_uuid,
1062 content_info->folder_uuid,
1064 content_info->file_name,
1065 content_info->media_type,
1066 content_info->mime_type,
1068 content_info->added_time,
1069 content_info->modified_time,
1070 content_info->is_drm,
1071 content_info->storage_type,
1072 content_info->timeline,
1078 sqlite3_free(burst_id);
1082 media_svc_debug("MAKE PASS 1 QUERY END");
1085 ret = _media_svc_sql_query(handle, sql, uid);
1087 if (ret != MS_MEDIA_ERR_NONE) {
1088 media_svc_error("failed to insert item");
1092 media_svc_debug("query : %s", sql);
1093 _media_svc_sql_query_add(&g_media_svc_insert_item_query_list, &sql);
1095 media_svc_debug("END");
1096 return MS_MEDIA_ERR_NONE;
1099 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)
1101 int ret = MS_MEDIA_ERR_NONE;
1103 media_svc_debug_fenter();
1105 /*Update Pinyin If Support Pinyin*/
1106 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;