From cb4d5905ef6c2f86873e52fbd4d4015d5ef5f906 Mon Sep 17 00:00:00 2001 From: Minje Ahn Date: Fri, 6 Jan 2017 10:36:22 +0900 Subject: [PATCH] Sync with tizen_3.0 patch Change-Id: I115ed2acf5c9ba35de95432f95660110127db06c Signed-off-by: Minje Ahn --- include/media-svc.h | 2 +- packaging/libmedia-service.spec | 2 +- plugin/media-content-plugin.c | 4 ++-- src/common/media-svc-storage.c | 30 ++++++++++++++++++++++++++---- src/common/media-svc-util.c | 24 +++++++++++++----------- src/common/media-svc.c | 4 ++-- src/include/common/media-svc-storage.h | 2 +- 7 files changed, 46 insertions(+), 22 deletions(-) diff --git a/include/media-svc.h b/include/media-svc.h index be9f754..9890eb9 100755 --- a/include/media-svc.h +++ b/include/media-svc.h @@ -75,7 +75,7 @@ void media_svc_destroy_content_info(media_svc_content_info_s *content_info); int media_svc_generate_uuid(char **uuid); int media_svc_get_mmc_info(MediaSvcHandle *handle, char **storage_name, char **storage_path, int *validity, bool *info_exist); -int media_svc_check_storage(MediaSvcHandle *handle, const char *storage_id, const char *storage_name, char **storage_path, int *validity); +int media_svc_check_storage(MediaSvcHandle *handle, const char *storage_id, const char *storage_name, char **storage_path, int *validity, uid_t uid); int media_svc_insert_storage(MediaSvcHandle *handle, const char *storage_id, const char *storage_name, const char *storage_path, const char *storage_account, media_svc_storage_type_e storage_type, uid_t uid); int media_svc_update_storage(MediaSvcHandle *handle, const char *storage_id, const char *storage_path, uid_t uid); int media_svc_delete_storage(MediaSvcHandle *handle, const char *storage_id, const char *storage_name, uid_t uid); diff --git a/packaging/libmedia-service.spec b/packaging/libmedia-service.spec index 58ff608..9789b99 100644 --- a/packaging/libmedia-service.spec +++ b/packaging/libmedia-service.spec @@ -1,6 +1,6 @@ Name: libmedia-service Summary: Media information service library for multimedia applications -Version: 0.2.88 +Version: 0.2.91 Release: 0 Group: Multimedia/Libraries License: Apache-2.0 and public domain diff --git a/plugin/media-content-plugin.c b/plugin/media-content-plugin.c index bedbd9e..9a9c29e 100755 --- a/plugin/media-content-plugin.c +++ b/plugin/media-content-plugin.c @@ -635,7 +635,7 @@ int get_mmc_info(void * handle, char **storage_name, char **storage_path, int *v return MEDIA_SVC_PLUGIN_ERROR_NONE; } -int check_storage(void * handle, const char *storage_id, const char *storage_name, char **storage_path, int *validity, char **err_msg) +int check_storage(void * handle, const char *storage_id, const char *storage_name, char **storage_path, int *validity, uid_t uid, char **err_msg) { int ret = MEDIA_SVC_PLUGIN_ERROR_NONE; @@ -644,7 +644,7 @@ int check_storage(void * handle, const char *storage_id, const char *storage_nam return MEDIA_SVC_PLUGIN_ERROR; } - ret = media_svc_check_storage(handle, storage_id, storage_name, storage_path, validity); + ret = media_svc_check_storage(handle, storage_id, storage_name, storage_path, validity, uid); if (ret < 0) { __set_error_message(ret, err_msg); return MEDIA_SVC_PLUGIN_ERROR; diff --git a/src/common/media-svc-storage.c b/src/common/media-svc-storage.c index 30d72ae..92692a9 100755 --- a/src/common/media-svc-storage.c +++ b/src/common/media-svc-storage.c @@ -87,7 +87,7 @@ int _media_svc_get_mmc_info(MediaSvcHandle *handle, char **storage_name, char ** return MS_MEDIA_ERR_NONE; } -int _media_svc_check_storage(sqlite3 *handle, const char *storage_id, const char *storage_name, char **storage_path, int *validity) +int _media_svc_check_storage(sqlite3 *handle, const char *storage_id, const char *storage_name, char **storage_path, int *validity, uid_t uid) { int ret = MS_MEDIA_ERR_NONE; sqlite3_stmt *sql_stmt = NULL; @@ -110,6 +110,28 @@ int _media_svc_check_storage(sqlite3 *handle, const char *storage_id, const char SQLITE3_FINALIZE(sql_stmt); + /*check storage media table*/ + if (STRING_VALID(storage_id)) { + int table_cnt = 0; + + /*Select list of storage*/ + sql = sqlite3_mprintf("SELECT COUNT(*) FROM SQLITE_MASTER WHERE type='table' and name='%q'", storage_id); + ret = _media_svc_sql_prepare_to_step(handle, sql, &sql_stmt); + media_svc_retv_if(ret != MS_MEDIA_ERR_NONE, ret); + + table_cnt = sqlite3_column_int(sql_stmt, 0); + SQLITE3_FINALIZE(sql_stmt); + + if (table_cnt > 0) { + /*DO NOT THING*/ + } else { + media_svc_error("media table not exist for storage [%s]", storage_id); + /*make storage media table*/ + ret = _media_svc_create_media_table_with_id(storage_id, uid); + media_svc_retvm_if(ret != MS_MEDIA_ERR_NONE, ret, "create media table failed : %d", ret); + } + } + return MS_MEDIA_ERR_NONE; } @@ -133,7 +155,7 @@ int _media_svc_update_storage_path(sqlite3 *handle, const char *storage_id, cons int validity = 0; /*Get old path*/ - ret = _media_svc_check_storage(handle, storage_id, NULL, &old_storage_path, &validity); + ret = _media_svc_check_storage(handle, storage_id, NULL, &old_storage_path, &validity, uid); media_svc_retv_if(ret != MS_MEDIA_ERR_NONE, ret); /*Storage table update*/ @@ -248,7 +270,7 @@ int _media_svc_get_storage_type(sqlite3 *handle, const char *storage_id, media_s char *sql = NULL; if (!STRING_VALID(storage_id)) { - media_svc_error("Invalid storage_idid"); + media_svc_error("Invalid storage_id"); ret = MS_MEDIA_ERR_INVALID_PARAMETER; } @@ -279,7 +301,7 @@ int _media_svc_get_storage_path(sqlite3 *handle, const char *storage_id, char ** char *sql = NULL; if (!STRING_VALID(storage_id)) { - media_svc_error("Invalid storage_idid"); + media_svc_error("Invalid storage_id"); ret = MS_MEDIA_ERR_INVALID_PARAMETER; } diff --git a/src/common/media-svc-util.c b/src/common/media-svc-util.c index 7474d9a..2331fc8 100755 --- a/src/common/media-svc-util.c +++ b/src/common/media-svc-util.c @@ -261,7 +261,7 @@ static int __media_svc_split_to_double(char *input, double *arr) } if (arr_idx != 3) { - media_svc_error("Error when parsing GPS [%d]", arr_idx); + media_svc_debug("Error when parsing GPS [%d]", arr_idx); return MS_MEDIA_ERR_INTERNAL; } @@ -287,7 +287,7 @@ static int __media_svc_get_exif_info(ExifData *ed, char *buf, int *i_value, doub tag == EXIF_TAG_ISO_SPEED_RATINGS) { if (i_value == NULL) { - media_svc_error("i_value is NULL"); + media_svc_debug("i_value is NULL"); return MS_MEDIA_ERR_INVALID_PARAMETER; } @@ -298,7 +298,7 @@ static int __media_svc_get_exif_info(ExifData *ed, char *buf, int *i_value, doub } else if (tag == EXIF_TAG_GPS_LATITUDE || tag == EXIF_TAG_GPS_LONGITUDE || tag == EXIF_TAG_GPS_ALTITUDE) { if (d_value == NULL) { - media_svc_error("d_value is NULL"); + media_svc_debug("d_value is NULL"); return MS_MEDIA_ERR_INVALID_PARAMETER; } @@ -317,7 +317,7 @@ static int __media_svc_get_exif_info(ExifData *ed, char *buf, int *i_value, doub } else if (tag == EXIF_TAG_EXPOSURE_TIME) { if (buf == NULL) { - media_svc_error("buf is NULL"); + media_svc_debug("buf is NULL"); return MS_MEDIA_ERR_INVALID_PARAMETER; } @@ -330,7 +330,7 @@ static int __media_svc_get_exif_info(ExifData *ed, char *buf, int *i_value, doub } else if (tag == EXIF_TAG_FNUMBER) { if (d_value == NULL) { - media_svc_error("d_value is NULL"); + media_svc_debug("d_value is NULL"); return MS_MEDIA_ERR_INVALID_PARAMETER; } @@ -344,7 +344,7 @@ static int __media_svc_get_exif_info(ExifData *ed, char *buf, int *i_value, doub } else { if (buf == NULL) { - media_svc_error("buf is NULL"); + media_svc_debug("buf is NULL"); return MS_MEDIA_ERR_INVALID_PARAMETER; } @@ -379,13 +379,13 @@ time_t __media_svc_get_timeline_from_str(const char *timstr) if (strptime(timstr, "%Y:%m:%d %H:%M:%S", &t) || strptime(timstr, "%Y-%m-%d %H:%M:%S", &t)) { t.tm_isdst = timeinfo.tm_isdst; if (t.tm_isdst != 0) - media_svc_error("DST %d", t.tm_isdst); + media_svc_debug("DST %d", t.tm_isdst); modified_t = mktime(&t); if (modified_t > 0) return modified_t; else - media_svc_error("Failed to get timeline : [%s] [%d:%d:%d: %d:%d:%d]", timstr, t.tm_year, t.tm_mon, t.tm_mday, t.tm_hour, t.tm_min, t.tm_sec); + media_svc_debug("Failed to get timeline : [%s] [%d:%d:%d: %d:%d:%d]", timstr, t.tm_year, t.tm_mon, t.tm_mday, t.tm_hour, t.tm_min, t.tm_sec); } else { media_svc_error("Failed to get timeline : [%s]", timstr); } @@ -618,7 +618,8 @@ static char *__media_svc_get_thumb_path(uid_t uid) return result_passwd; } -static int __media_svc_encode_jpeg(unsigned char *src, unsigned long width, unsigned long height, image_util_colorspace_e colorspace, int quality, unsigned char **dst, unsigned long long *dst_size) { +static int __media_svc_encode_jpeg(unsigned char *src, unsigned long width, unsigned long height, image_util_colorspace_e colorspace, int quality, unsigned char **dst, unsigned long long *dst_size) +{ int res = IMAGE_UTIL_ERROR_NONE; image_util_encode_h encoder = NULL; unsigned char *encoded_data = NULL; @@ -681,7 +682,8 @@ static int __media_svc_encode_jpeg(unsigned char *src, unsigned long width, unsi return MS_MEDIA_ERR_NONE; } -static int __media_svc_decode_jpeg(unsigned char *src, unsigned long long size, image_util_colorspace_e colorspace, unsigned char **dst, unsigned long *width, unsigned long *height, unsigned long long *dst_size) { +static int __media_svc_decode_jpeg(unsigned char *src, unsigned long long size, image_util_colorspace_e colorspace, unsigned char **dst, unsigned long *width, unsigned long *height, unsigned long long *dst_size) +{ int res = IMAGE_UTIL_ERROR_NONE; image_util_decode_h decoder = NULL; res = image_util_decode_create(&decoder); @@ -1995,7 +1997,7 @@ int _media_svc_extract_media_metadata(sqlite3 *handle, media_svc_content_info_s char *p_value = p; char *time_value = time_info; if (time_info != NULL) { - while(*p_value != '\0') { + while (*p_value != '\0') { if (*p_value == '-') *time_value = ':'; else diff --git a/src/common/media-svc.c b/src/common/media-svc.c index 916d120..bc2e554 100755 --- a/src/common/media-svc.c +++ b/src/common/media-svc.c @@ -1812,7 +1812,7 @@ int media_svc_get_mmc_info(MediaSvcHandle *handle, char **storage_name, char **s return _media_svc_get_mmc_info(db_handle, storage_name, storage_path, validity, info_exist); } -int media_svc_check_storage(MediaSvcHandle *handle, const char *storage_id, const char *storage_name, char **storage_path, int *validity) +int media_svc_check_storage(MediaSvcHandle *handle, const char *storage_id, const char *storage_name, char **storage_path, int *validity, uid_t uid) { sqlite3 * db_handle = (sqlite3 *)handle; @@ -1821,7 +1821,7 @@ int media_svc_check_storage(MediaSvcHandle *handle, const char *storage_id, cons media_svc_retvm_if(storage_path == NULL, MS_MEDIA_ERR_INVALID_PARAMETER, "storage_path is NULL"); media_svc_retvm_if(validity == NULL, MS_MEDIA_ERR_INVALID_PARAMETER, "validity is NULL"); - return _media_svc_check_storage(db_handle, storage_id, storage_name, storage_path, validity); + return _media_svc_check_storage(db_handle, storage_id, storage_name, storage_path, validity, uid); } int media_svc_update_storage(MediaSvcHandle *handle, const char *storage_id, const char *storage_path, uid_t uid) diff --git a/src/include/common/media-svc-storage.h b/src/include/common/media-svc-storage.h index f83c265..9169383 100755 --- a/src/include/common/media-svc-storage.h +++ b/src/include/common/media-svc-storage.h @@ -26,7 +26,7 @@ int _media_svc_init_storage(sqlite3 *handle, uid_t uid); int _media_svc_get_mmc_info(MediaSvcHandle *handle, char **storage_name, char **storage_path, int *validity, bool *info_exist); -int _media_svc_check_storage(sqlite3 *handle, const char *storage_id, const char *storage_name, char **storage_path, int *validity); +int _media_svc_check_storage(sqlite3 *handle, const char *storage_id, const char *storage_name, char **storage_path, int *validity, uid_t uid); int _media_svc_append_storage(const char *storage_id, const char *storage_name, const char *storage_path, const char *storage_account, media_svc_storage_type_e storage_type, uid_t uid); int _media_svc_update_storage_path(sqlite3 *handle, const char *storage_id, const char *path, uid_t uid); int _media_svc_delete_storage(const char *storage_id, const char *storage_name, uid_t uid); -- 2.7.4