diff options
author | hj kim <backto.kim@samsung.com> | 2015-06-04 21:09:04 -0700 |
---|---|---|
committer | hj kim <backto.kim@samsung.com> | 2015-06-04 21:09:04 -0700 |
commit | 999b9402a56d7c9738d6d632eff2f90004bbfbaf (patch) | |
tree | 31416fd3ece796751014dab252673fc71b278240 /src/media-thumbnail.c | |
parent | c896230ef091a244204b17bc9ab0ffa974ce2031 (diff) | |
download | libmedia-thumbnail-999b9402a56d7c9738d6d632eff2f90004bbfbaf.tar.gz libmedia-thumbnail-999b9402a56d7c9738d6d632eff2f90004bbfbaf.tar.bz2 libmedia-thumbnail-999b9402a56d7c9738d6d632eff2f90004bbfbaf.zip |
Revert "Modify error type"submit/tizen/20150605.041217accepted/tizen/wearable/20150606.054548accepted/tizen/tv/20150606.053731accepted/tizen/mobile/20150606.053029accepted/tizen/common/20150605.124444
This reverts commit c896230ef091a244204b17bc9ab0ffa974ce2031.
Change-Id: I94ec0a56f7c3d84ad76645b91310494b96d41932
Diffstat (limited to 'src/media-thumbnail.c')
-rwxr-xr-x | src/media-thumbnail.c | 108 |
1 files changed, 72 insertions, 36 deletions
diff --git a/src/media-thumbnail.c b/src/media-thumbnail.c index dca2285..c52c42a 100755 --- a/src/media-thumbnail.c +++ b/src/media-thumbnail.c @@ -30,24 +30,24 @@ int thumbnail_request_from_db(const char *origin_path, char *thumb_path, int max_length, uid_t uid) { - int err = MS_MEDIA_ERR_NONE; + int err = -1; //int need_update_db = 0; media_thumb_info thumb_info; if (origin_path == NULL || thumb_path == NULL) { thumb_err("Invalid parameter"); - return MS_MEDIA_ERR_INVALID_PARAMETER; + return MEDIA_THUMB_ERROR_INVALID_PARAMETER; } if (!g_file_test (origin_path, G_FILE_TEST_EXISTS | G_FILE_TEST_IS_REGULAR)) { thumb_err("Original path(%s) doesn't exist.", origin_path); - return MS_MEDIA_ERR_INVALID_PARAMETER; + return MEDIA_THUMB_ERROR_INVALID_PARAMETER; } if (max_length <= 0) { thumb_err("Length is invalid"); - return MS_MEDIA_ERR_INVALID_PARAMETER; + return MEDIA_THUMB_ERROR_INVALID_PARAMETER; } int store_type = -1; @@ -55,28 +55,51 @@ int thumbnail_request_from_db(const char *origin_path, char *thumb_path, int max if ((store_type != THUMB_PHONE) && (store_type != THUMB_MMC)) { thumb_err("origin path(%s) is invalid", origin_path); - return MS_MEDIA_ERR_INVALID_PARAMETER; + return MEDIA_THUMB_ERROR_INVALID_PARAMETER; } thumb_err("Path : %s", origin_path); +/* + err = _media_thumb_db_connect(); + if (err < 0) { + thumb_err("_media_thumb_mb_svc_connect failed: %d", err); + return MEDIA_THUMB_ERROR_DB; + } + err = _media_thumb_get_thumb_from_db(origin_path, thumb_path, max_length, &need_update_db); + if (err == 0) { + _media_thumb_db_disconnect(); + return MEDIA_THUMB_ERROR_NONE; + } +*/ /* Request for thumb file to the daemon "Thumbnail generator" */ err = _media_thumb_request(THUMB_REQUEST_DB_INSERT, MEDIA_THUMB_LARGE, origin_path, thumb_path, max_length, &thumb_info, uid); - if (err != MS_MEDIA_ERR_NONE) { + if (err < 0) { thumb_err("_media_thumb_request failed : %d", err); + //_media_thumb_db_disconnect(); return err; } +/* + // Need to update DB once generating thumb is done + if (need_update_db) { + err = _media_thumb_update_db(origin_path, thumb_path, thumb_info.origin_width, thumb_info.origin_height); + if (err < 0) { + thumb_err("_media_thumb_update_db failed : %d", err); + } + } - return MS_MEDIA_ERR_NONE; + _media_thumb_db_disconnect(); +*/ + return MEDIA_THUMB_ERROR_NONE; } int thumbnail_request_save_to_file(const char *origin_path, media_thumb_type thumb_type, const char *thumb_path, uid_t uid) { - int err = MS_MEDIA_ERR_NONE; + int err = -1; if (origin_path == NULL || thumb_path == NULL) { thumb_err("Invalid parameter"); - return MS_MEDIA_ERR_INVALID_PARAMETER; + return MEDIA_THUMB_ERROR_INVALID_PARAMETER; } media_thumb_info thumb_info; @@ -87,39 +110,39 @@ int thumbnail_request_save_to_file(const char *origin_path, media_thumb_type thu /* Request for thumb file to the daemon "Thumbnail generator" */ err = _media_thumb_request(THUMB_REQUEST_SAVE_FILE, thumb_type, origin_path, tmp_thumb_path, sizeof(tmp_thumb_path), &thumb_info, uid); - if (err != MS_MEDIA_ERR_NONE) { + if (err < 0) { thumb_err("_media_thumb_request failed : %d", err); return err; } - return MS_MEDIA_ERR_NONE; + return MEDIA_THUMB_ERROR_NONE; } int thumbnail_request_from_db_with_size(const char *origin_path, char *thumb_path, int max_length, int *origin_width, int *origin_height, uid_t uid) { - int err = MS_MEDIA_ERR_NONE; + int err = -1; //int need_update_db = 0; media_thumb_info thumb_info; if (origin_path == NULL || thumb_path == NULL) { thumb_err("Invalid parameter"); - return MS_MEDIA_ERR_INVALID_PARAMETER; + return MEDIA_THUMB_ERROR_INVALID_PARAMETER; } if (origin_width == NULL || origin_height == NULL) { thumb_err("Invalid parameter ( width or height )"); - return MS_MEDIA_ERR_INVALID_PARAMETER; + return MEDIA_THUMB_ERROR_INVALID_PARAMETER; } if (!g_file_test (origin_path, G_FILE_TEST_EXISTS | G_FILE_TEST_IS_REGULAR)) { thumb_err("Original path(%s) doesn't exist.", origin_path); - return MS_MEDIA_ERR_INVALID_PARAMETER; + return MEDIA_THUMB_ERROR_INVALID_PARAMETER; } if (max_length <= 0) { thumb_err("Length is invalid"); - return MS_MEDIA_ERR_INVALID_PARAMETER; + return MEDIA_THUMB_ERROR_INVALID_PARAMETER; } int store_type = -1; @@ -127,14 +150,26 @@ int thumbnail_request_from_db_with_size(const char *origin_path, char *thumb_pat if ((store_type != THUMB_PHONE) && (store_type != THUMB_MMC)) { thumb_err("origin path(%s) is invalid", origin_path); - return MS_MEDIA_ERR_INVALID_PARAMETER; + return MEDIA_THUMB_ERROR_INVALID_PARAMETER; } thumb_err("Path : %s", origin_path); +/* + err = _media_thumb_db_connect(); + if (err < 0) { + thumb_err("_media_thumb_mb_svc_connect failed: %d", err); + return MEDIA_THUMB_ERROR_DB; + } + err = _media_thumb_get_thumb_from_db_with_size(origin_path, thumb_path, max_length, &need_update_db, &width, &height); + if (err == 0) { + _media_thumb_db_disconnect(); + return MEDIA_THUMB_ERROR_NONE; + } +*/ /* Request for thumb file to the daemon "Thumbnail generator" */ err = _media_thumb_request(THUMB_REQUEST_DB_INSERT, MEDIA_THUMB_LARGE, origin_path, thumb_path, max_length, &thumb_info, uid); - if (err != MS_MEDIA_ERR_NONE) { + if (err < 0) { thumb_err("_media_thumb_request failed : %d", err); //_media_thumb_db_disconnect(); return err; @@ -143,12 +178,13 @@ int thumbnail_request_from_db_with_size(const char *origin_path, char *thumb_pat *origin_width = thumb_info.origin_width; *origin_height = thumb_info.origin_height; - return MS_MEDIA_ERR_NONE; + //_media_thumb_db_disconnect(); + return MEDIA_THUMB_ERROR_NONE; } int thumbnail_request_extract_all_thumbs(uid_t uid) { - int err = MS_MEDIA_ERR_NONE; + int err = -1; media_thumb_info thumb_info; media_thumb_type thumb_type = MEDIA_THUMB_LARGE; @@ -157,27 +193,27 @@ int thumbnail_request_extract_all_thumbs(uid_t uid) /* Request for thumb file to the daemon "Thumbnail generator" */ err = _media_thumb_request(THUMB_REQUEST_ALL_MEDIA, thumb_type, tmp_origin_path, tmp_thumb_path, sizeof(tmp_thumb_path), &thumb_info, uid); - if (err != MS_MEDIA_ERR_NONE) { + if (err < 0) { thumb_err("_media_thumb_request failed : %d", err); return err; } - return MS_MEDIA_ERR_NONE; + return MEDIA_THUMB_ERROR_NONE; } int thumbnail_request_from_db_async(const char *origin_path, ThumbFunc func, void *user_data, uid_t uid) { - int err = MS_MEDIA_ERR_NONE; + int err = -1; if (origin_path == NULL) { thumb_err("Invalid parameter"); - return MS_MEDIA_ERR_INVALID_PARAMETER; + return MEDIA_THUMB_ERROR_INVALID_PARAMETER; } if (!g_file_test (origin_path, G_FILE_TEST_EXISTS | G_FILE_TEST_IS_REGULAR)) { thumb_err("Original path(%s) doesn't exist.", origin_path); - return MS_MEDIA_ERR_INVALID_PARAMETER; + return MEDIA_THUMB_ERROR_INVALID_PARAMETER; } int store_type = -1; @@ -185,7 +221,7 @@ int thumbnail_request_from_db_async(const char *origin_path, ThumbFunc func, voi if ((store_type != THUMB_PHONE) && (store_type != THUMB_MMC)) { thumb_err("origin path(%s) is invalid", origin_path); - return MS_MEDIA_ERR_INVALID_PARAMETER; + return MEDIA_THUMB_ERROR_INVALID_PARAMETER; } thumb_err("Path : %s", origin_path); @@ -196,13 +232,13 @@ int thumbnail_request_from_db_async(const char *origin_path, ThumbFunc func, voi /* Request for thumb file to the daemon "Thumbnail generator" */ err = _media_thumb_request_async(THUMB_REQUEST_DB_INSERT, MEDIA_THUMB_LARGE, origin_path, userData, uid); - if (err != MS_MEDIA_ERR_NONE) { + if (err < 0) { thumb_err("_media_thumb_request failed : %d", err); SAFE_FREE(userData); return err; } - return MS_MEDIA_ERR_NONE; + return MEDIA_THUMB_ERROR_NONE; } int _media_thumbnail_cancel_cb(int error_code, char* path, void* data) @@ -210,32 +246,32 @@ int _media_thumbnail_cancel_cb(int error_code, char* path, void* data) thumb_dbg("Error code : %d", error_code); if (path) thumb_dbg("Cancel : %s", path); - return MS_MEDIA_ERR_NONE; + return MEDIA_THUMB_ERROR_NONE; } int thumbnail_request_cancel_media(const char *origin_path, uid_t uid) { - int err = MS_MEDIA_ERR_NONE; + int err = -1; media_thumb_type thumb_type = MEDIA_THUMB_LARGE; if (origin_path == NULL) { thumb_err("Invalid parameter"); - return MS_MEDIA_ERR_INVALID_PARAMETER; + return MEDIA_THUMB_ERROR_INVALID_PARAMETER; } err = _media_thumb_request_async(THUMB_REQUEST_CANCEL_MEDIA, thumb_type, origin_path, NULL, uid); - if (err != MS_MEDIA_ERR_NONE) { + if (err < 0) { thumb_err("_media_thumb_request failed : %d", err); return err; } - return MS_MEDIA_ERR_NONE; + return MEDIA_THUMB_ERROR_NONE; } int thumbnail_request_cancel_all(uid_t uid) { - int err = MS_MEDIA_ERR_NONE; + int err = -1; media_thumb_info thumb_info; media_thumb_type thumb_type = MEDIA_THUMB_LARGE; @@ -244,10 +280,10 @@ int thumbnail_request_cancel_all(uid_t uid) /* Request for thumb file to the daemon "Thumbnail generator" */ err = _media_thumb_request(THUMB_REQUEST_CANCEL_ALL, thumb_type, tmp_origin_path, tmp_thumb_path, sizeof(tmp_thumb_path), &thumb_info, uid); - if (err != MS_MEDIA_ERR_NONE) { + if (err < 0) { thumb_err("_media_thumb_request failed : %d", err); return err; } - return err; + return MEDIA_THUMB_ERROR_NONE; } |