X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=src%2Fmedia_info.c;h=1d4b48f8bf11223f07c5cccf4a7e174a2a4bee05;hb=c4791a24e66f7810ea9b7815017d69ec5a6bb200;hp=69c80d6406bb6df739eb4046982d832edacacf91;hpb=db50dcd4b00525857ad9a0adfca75bb4a72e0dce;p=platform%2Fcore%2Fapi%2Fmedia-content.git diff --git a/src/media_info.c b/src/media_info.c index 69c80d6..1d4b48f 100644 --- a/src/media_info.c +++ b/src/media_info.c @@ -149,15 +149,15 @@ static int __media_info_insert_batch(const char **path_array, { int ret = MEDIA_CONTENT_ERROR_NONE; FILE *fp = NULL; - char list_path[255] = {0, }; + char list_path[BATCH_REQUEST_FILE_LEN] = {0, }; unsigned int idx = 0; int nwrites = 0; for (idx = 0; idx < BATCH_REQUEST_MAX; idx++) { - snprintf(list_path, sizeof(list_path), "%s/request-%ld-%d", MEDIA_CONTENT_INSERT_FILES_PATH, media_content_gettid(), idx); + snprintf(list_path, BATCH_REQUEST_FILE_LEN, "%s/request-%ld-%d", MEDIA_CONTENT_INSERT_FILES_PATH, media_content_gettid(), idx); - if (g_file_test(list_path, G_FILE_TEST_EXISTS | G_FILE_TEST_IS_REGULAR)) { - memset(list_path, 0x00, sizeof(list_path)); + if (g_file_test(list_path, G_FILE_TEST_EXISTS)) { + memset(list_path, 0x00, BATCH_REQUEST_FILE_LEN); continue; } else { content_sec_debug("The request file list path : %s", list_path); @@ -1299,10 +1299,10 @@ int media_info_get_media_from_db(const char *media_id, media_info_h *media) ret = _media_db_get_storage_id_by_media_id(media_id, &storage_id); content_retv_if(ret != MEDIA_CONTENT_ERROR_NONE, ret); - snprintf(select_query, sizeof(select_query), SELECT_MEDIA_FROM_MEDIA, storage_id, media_id); + snprintf(select_query, DEFAULT_QUERY_SIZE, SELECT_MEDIA_FROM_MEDIA, storage_id, media_id); g_free(storage_id); #else - snprintf(select_query, sizeof(select_query), SELECT_MEDIA_FROM_MEDIA, media_id); + snprintf(select_query, DEFAULT_QUERY_SIZE, SELECT_MEDIA_FROM_MEDIA, media_id); #endif ret = _content_get_result(select_query, &stmt); content_retv_if(ret != MEDIA_CONTENT_ERROR_NONE, ret); @@ -1379,48 +1379,19 @@ int media_info_update_to_db(media_info_h media) { int ret = MEDIA_CONTENT_ERROR_NONE; media_info_s *_media = (media_info_s*)media; - char *set_sql = NULL; char *sql = NULL; content_retip_if_fail(media); content_retip_if_fail(STRING_VALID(_media->media_id)); - /* This sql is due to sqlite3_mprintf's wrong operation when using floating point in the text format */ - /* This code will be removed when sqlite3_mprintf works clearly */ - char *test_sql = sqlite3_mprintf("%f, %f, %f", _media->longitude, _media->latitude, _media->altitude); - SQLITE3_SAFE_FREE(test_sql); - - /*Update Pinyin If Support Pinyin*/ - char *file_name_pinyin = NULL; - char *description_pinyin = NULL; - bool pinyin_support = FALSE; - - /*Update Pinyin If Support Pinyin*/ - media_svc_check_pinyin_support(&pinyin_support); - if (pinyin_support) { - if (STRING_VALID(_media->display_name)) - media_svc_get_pinyin(_media->display_name, &file_name_pinyin); - if (STRING_VALID(_media->description)) - media_svc_get_pinyin(_media->description, &description_pinyin); - } -#ifdef _USE_TVPD_MODE - set_sql = sqlite3_mprintf("media_display_name=%Q, media_description=%Q, media_longitude=%f, media_latitude=%f, media_file_name_pinyin=%Q, media_description_pinyin=%Q, played_count=%d, last_played_time=%d, last_played_position=%d, media_rating=%d, media_favourite=%d", - _media->display_name, _media->description, _media->longitude, _media->latitude, file_name_pinyin, description_pinyin, _media->played_count, _media->played_time, _media->played_position, _media->rating, _media->favourite); -#else - set_sql = sqlite3_mprintf("media_display_name=%Q, media_description=%Q, media_longitude=%f, media_latitude=%f, media_file_name_pinyin=%Q, media_description_pinyin=%Q, media_rating=%d, media_favourite=%d", _media->display_name, _media->description, _media->longitude, _media->latitude, file_name_pinyin, description_pinyin, _media->rating, _media->favourite); -#endif #ifdef _USE_TVPD_MODE - sql = sqlite3_mprintf("UPDATE %Q SET %s WHERE media_id=%Q", _media->storage_uuid, set_sql, _media->media_id); + sql = sqlite3_mprintf("UPDATE %Q SET played_count=%d, last_played_time=%d, last_played_position=%d, media_favourite=%d WHERE media_id=%Q", _media->storage_uuid, _media->played_count, _media->played_time, _media->played_position, _media->favourite, _media->media_id); #else - sql = sqlite3_mprintf("UPDATE %q SET %s WHERE media_id=%Q", DB_TABLE_MEDIA, set_sql, _media->media_id); + sql = sqlite3_mprintf("UPDATE %q SET media_favourite=%d WHERE media_id=%Q", DB_TABLE_MEDIA, _media->favourite, _media->media_id); #endif ret = _content_query_sql(sql); - SQLITE3_SAFE_FREE(set_sql); SQLITE3_SAFE_FREE(sql); - SAFE_FREE(file_name_pinyin); - SAFE_FREE(description_pinyin); - if (ret == MEDIA_CONTENT_ERROR_NONE) { /* Send notification for this update */ content_debug("Update is successful. Send notification for this"); @@ -1448,13 +1419,13 @@ int media_info_move_to_db(media_info_h media, const char* dst_path) media_info_s *_media = (media_info_s*)media; /* If dst_path is folder, append file_name */ - SAFE_STRLCPY(repl_path, dst_path, sizeof(repl_path)); + SAFE_STRLCPY(repl_path, dst_path, MAX_PATH_LEN); if (g_file_test(repl_path, G_FILE_TEST_IS_DIR)) { if (repl_path[strlen(repl_path) - 1] != '/') - SAFE_STRLCAT(repl_path, "/", sizeof(repl_path)); + SAFE_STRLCAT(repl_path, "/", MAX_PATH_LEN); - SAFE_STRLCAT(repl_path, _media->display_name, sizeof(repl_path)); + SAFE_STRLCAT(repl_path, _media->display_name, MAX_PATH_LEN); } /* If the two paths are the same, do nothing */ @@ -1614,53 +1585,4 @@ int media_info_cancel_face_detection(media_info_h media) ret = dcm_request_cancel_face(_media->face_request_id); return _content_error_capi(ret); -} - -int media_info_set_description(media_info_h media, const char *description) -{ - content_warn("DEPRECATION WARNING: media_info_set_description() is deprecated and will be removed from next release."); - media_info_s *_media = (media_info_s*)media; - - content_retip_if_fail(media); - - g_free(_media->description); - _media->description = g_strdup(description); - - return MEDIA_CONTENT_ERROR_NONE; -} - -int media_info_set_longitude(media_info_h media, double longitude) -{ - content_warn("DEPRECATION WARNING: media_info_set_longitude() is deprecated and will be removed from next release."); - media_info_s *_media = (media_info_s*)media; - - content_retip_if_fail(media); - - _media->longitude = longitude; - - return MEDIA_CONTENT_ERROR_NONE; -} - -int media_info_set_latitude(media_info_h media, double latitude) -{ - content_warn("DEPRECATION WARNING: media_info_set_latitude() is deprecated and will be removed from next release."); - media_info_s *_media = (media_info_s*)media; - - content_retip_if_fail(media); - - _media->latitude = latitude; - - return MEDIA_CONTENT_ERROR_NONE; -} - -int media_info_set_rating(media_info_h media, int rating) -{ - content_warn("DEPRECATION WARNING: media_info_set_rating() is deprecated and will be removed from next release."); - media_info_s *_media = (media_info_s*)media; - - content_retip_if_fail(media); - - _media->rating = rating; - - return MEDIA_CONTENT_ERROR_NONE; -} +} \ No newline at end of file