summaryrefslogtreecommitdiff
path: root/src/util
diff options
context:
space:
mode:
authorhj kim <backto.kim@samsung.com>2015-06-05 04:09:04 (GMT)
committerhj kim <backto.kim@samsung.com>2015-06-05 04:09:04 (GMT)
commit999b9402a56d7c9738d6d632eff2f90004bbfbaf (patch)
tree31416fd3ece796751014dab252673fc71b278240 /src/util
parentc896230ef091a244204b17bc9ab0ffa974ce2031 (diff)
downloadlibmedia-thumbnail-999b9402a56d7c9738d6d632eff2f90004bbfbaf.zip
libmedia-thumbnail-999b9402a56d7c9738d6d632eff2f90004bbfbaf.tar.gz
libmedia-thumbnail-999b9402a56d7c9738d6d632eff2f90004bbfbaf.tar.bz2
This reverts commit c896230ef091a244204b17bc9ab0ffa974ce2031. Change-Id: I94ec0a56f7c3d84ad76645b91310494b96d41932
Diffstat (limited to 'src/util')
-rwxr-xr-xsrc/util/media-thumb-db.c139
-rwxr-xr-xsrc/util/media-thumb-util.c16
2 files changed, 83 insertions, 72 deletions
diff --git a/src/util/media-thumb-db.c b/src/util/media-thumb-db.c
index 664cc47..1ee9aa5 100755
--- a/src/util/media-thumb-db.c
+++ b/src/util/media-thumb-db.c
@@ -21,7 +21,6 @@
#include "media-thumb-db.h"
#include "media-thumb-util.h"
-#include "media-thumb-debug.h"
#include <glib.h>
#include <string.h>
@@ -51,14 +50,14 @@ sqlite3 *_media_thumb_db_get_handle()
int
_media_thumb_sqlite_connect(sqlite3 **handle)
{
- int err = MS_MEDIA_ERR_NONE;
+ int err = -1;
err = db_util_open(MEDIA_DATABASE_NAME, handle,
DB_UTIL_REGISTER_HOOK_METHOD);
if (SQLITE_OK != err) {
*handle = NULL;
- return MS_MEDIA_ERR_INVALID_PARAMETER;
+ return -1;
}
/*Register busy handler*/
@@ -71,30 +70,30 @@ _media_thumb_sqlite_connect(sqlite3 **handle)
}
*handle = NULL;
- return MS_MEDIA_ERR_INVALID_PARAMETER;
+ return -1;
}
} else {
*handle = NULL;
- return MS_MEDIA_ERR_INVALID_PARAMETER;
+ return -1;
}
- return MS_MEDIA_ERR_NONE;
+ return MEDIA_THUMB_ERROR_NONE;
}
int
_media_thumb_sqlite_disconnect(sqlite3 *handle)
{
- int err = MS_MEDIA_ERR_NONE;
+ int err = -1;
if (handle != NULL) {
err = db_util_close(handle);
if (SQLITE_OK != err) {
handle = NULL;
- return MS_MEDIA_ERR_INVALID_PARAMETER;
+ return -1;
}
}
- return MS_MEDIA_ERR_NONE;
+ return MEDIA_THUMB_ERROR_NONE;
}
int
@@ -106,7 +105,7 @@ _media_thumb_get_type_from_db(sqlite3 *handle,
if (handle == NULL) {
thumb_err("DB handle is NULL");
- return MS_MEDIA_ERR_INVALID_PARAMETER;
+ return -1;
}
int err = -1;
@@ -125,21 +124,21 @@ _media_thumb_get_type_from_db(sqlite3 *handle,
sqlite3_free(path_string);
if (SQLITE_OK != err) {
- thumb_err("prepare error [%s]", sqlite3_errmsg(handle));
- return MS_MEDIA_ERR_DB_INTERNAL;
+ thumb_err("prepare error [%s]\n", sqlite3_errmsg(handle));
+ return -1;
}
err = sqlite3_step(stmt);
if (err != SQLITE_ROW) {
- thumb_err("end of row [%s]", sqlite3_errmsg(handle));
+ thumb_err("end of row [%s]\n", sqlite3_errmsg(handle));
sqlite3_finalize(stmt);
- return MS_MEDIA_ERR_DB_NO_RECORD;
+ return -1;
}
*type = sqlite3_column_int(stmt, 0);
sqlite3_finalize(stmt);
- return MS_MEDIA_ERR_NONE;
+ return MEDIA_THUMB_ERROR_NONE;
}
@@ -186,10 +185,11 @@ int _media_thumb_get_wh_from_db(sqlite3 *handle,
*height = sqlite3_column_int(stmt, 1);
sqlite3_finalize(stmt);
- return MS_MEDIA_ERR_NONE;
+ return MEDIA_THUMB_ERROR_NONE;
}
-int _media_thumb_get_thumb_path_from_db(sqlite3 *handle,
+int
+_media_thumb_get_thumb_path_from_db(sqlite3 *handle,
const char *origin_path,
char *thumb_path,
int max_length)
@@ -217,13 +217,13 @@ int _media_thumb_get_thumb_path_from_db(sqlite3 *handle,
sqlite3_free(path_string);
if (SQLITE_OK != err) {
- thumb_err("prepare error [%s]", sqlite3_errmsg(handle));
+ thumb_err("prepare error [%s]\n", sqlite3_errmsg(handle));
return -1;
}
err = sqlite3_step(stmt);
if (err != SQLITE_ROW) {
- thumb_err("end of row [%s]", sqlite3_errmsg(handle));
+ thumb_err("end of row [%s]\n", sqlite3_errmsg(handle));
sqlite3_finalize(stmt);
return -1;
}
@@ -235,23 +235,24 @@ int _media_thumb_get_thumb_path_from_db(sqlite3 *handle,
sqlite3_finalize(stmt);
- return MS_MEDIA_ERR_NONE;
+ return MEDIA_THUMB_ERROR_NONE;
}
-int _media_thumb_update_thumb_path_to_db(sqlite3 *handle,
+int
+_media_thumb_update_thumb_path_to_db(sqlite3 *handle,
const char *origin_path,
char *thumb_path,
uid_t uid)
{
thumb_dbg("");
- int err = MS_MEDIA_ERR_NONE;
+ int err = -1;
char *path_string = NULL;
char *thumbpath_string = NULL;
char *query_string = NULL;
if (handle == NULL) {
thumb_err("DB handle is NULL");
- return MS_MEDIA_ERR_INVALID_PARAMETER;
+ return -1;
}
path_string = sqlite3_mprintf("%s", origin_path);
@@ -275,7 +276,7 @@ int _media_thumb_update_thumb_path_to_db(sqlite3 *handle,
err_msg = NULL;
}
- return MS_MEDIA_ERR_DB_UPDATE_FAIL;
+ return -1;
}
if (err_msg)
@@ -289,7 +290,7 @@ int _media_thumb_update_thumb_path_to_db(sqlite3 *handle,
#endif
thumb_dbg("Query success");
- return MS_MEDIA_ERR_NONE;
+ return MEDIA_THUMB_ERROR_NONE;
}
int
@@ -299,13 +300,14 @@ _media_thumb_update_wh_to_db(sqlite3 *handle,
int height,
uid_t uid)
{
- int err = MS_MEDIA_ERR_NONE;
+ thumb_dbg("");
+ int err = -1;
char *path_string = NULL;
char *query_string = NULL;
if (handle == NULL) {
thumb_err("DB handle is NULL");
- return MS_MEDIA_ERR_INVALID_PARAMETER;
+ return -1;
}
path_string = sqlite3_mprintf("%s", origin_path);
@@ -327,31 +329,33 @@ _media_thumb_update_wh_to_db(sqlite3 *handle,
err_msg = NULL;
}
- return MS_MEDIA_ERR_DB_UPDATE_FAIL;
+ return -1;
}
if (err_msg)
sqlite3_free(err_msg);
#else
err = media_db_request_update_db(query_string, uid);
- if (err != MS_MEDIA_ERR_NONE) {
+ if (err < 0) {
thumb_err("media_db_request_update_db failed : %d", err);
return err;
}
#endif
thumb_dbg("Query success");
- return err;
+ return MEDIA_THUMB_ERROR_NONE;
}
-int _media_thumb_update_thumb_path_wh_to_db(sqlite3 *handle,
+int
+_media_thumb_update_thumb_path_wh_to_db(sqlite3 *handle,
const char *origin_path,
char *thumb_path,
int width,
int height,
uid_t uid)
{
- int err = MS_MEDIA_ERR_NONE;
+ thumb_dbg("");
+ int err = -1;
char *path_string = NULL;
char *query_string = NULL;
@@ -364,22 +368,23 @@ int _media_thumb_update_thumb_path_wh_to_db(sqlite3 *handle,
query_string = sqlite3_mprintf(UPDATE_THUMB_WH_BY_PATH, thumb_path, width, height, path_string);
err = media_db_request_update_db(query_string, uid);
- if (err != MS_MEDIA_ERR_NONE) {
+ if (err < 0) {
thumb_err("media_db_request_update_db failed : %d", err);
return err;
}
thumb_dbg("Query success");
- return err;
+ return MEDIA_THUMB_ERROR_NONE;
}
-int _media_thumb_db_connect(uid_t uid)
+int
+_media_thumb_db_connect(uid_t uid)
{
- int err = MS_MEDIA_ERR_NONE;
+ int err = -1;
/*
err = media_svc_connect(&mb_svc_handle);
- if (err != MS_MEDIA_ERR_NONE) {
+ if (err < 0) {
thumb_err("media_svc_connect failed: %d", err);
mb_svc_handle = NULL;
return err;
@@ -387,31 +392,31 @@ int _media_thumb_db_connect(uid_t uid)
*/
#ifndef _USE_MEDIA_UTIL_
err = _media_thumb_sqlite_connect(&db_handle);
- if (err != MS_MEDIA_ERR_NONE) {
+ if (err < 0) {
thumb_err("_media_thumb_sqlite_connect failed: %d", err);
db_handle = NULL;
return err;
}
#else
err = media_db_connect(&db_handle,uid);
- if (err != MS_MEDIA_ERR_NONE) {
+ if (err < 0) {
thumb_err("media_db_connect failed: %d", err);
db_handle = NULL;
- return MS_MEDIA_ERR_DB_CONNECT_FAIL;
+ return MEDIA_THUMB_ERROR_DB;
}
#endif
- return MS_MEDIA_ERR_NONE;
+ return MEDIA_THUMB_ERROR_NONE;
}
int
_media_thumb_db_disconnect()
{
- int err = MS_MEDIA_ERR_NONE;
+ int err = -1;
/*
err = media_svc_disconnect(mb_svc_handle);
- if (err != MS_MEDIA_ERR_NONE) {
+ if (err < 0) {
thumb_err("media_svc_disconnect failed: %d", err);
}
@@ -419,17 +424,17 @@ _media_thumb_db_disconnect()
*/
#ifndef _USE_MEDIA_UTIL_
err = _media_thumb_sqlite_disconnect(db_handle);
- if (err != MS_MEDIA_ERR_NONE) {
+ if (err < 0) {
thumb_err("_media_thumb_sqlite_disconnect failed: %d", err);
db_handle = NULL;
return err;
}
#else
err = media_db_disconnect(db_handle);
- if (err != MS_MEDIA_ERR_NONE) {
+ if (err < 0) {
thumb_err("media_db_disconnect failed: %d", err);
db_handle = NULL;
- return MS_MEDIA_ERR_DB_CONNECT_FAIL;
+ return MEDIA_THUMB_ERROR_DB;
}
#endif
@@ -437,11 +442,13 @@ _media_thumb_db_disconnect()
return err;
}
-int _media_thumb_get_thumb_from_db(const char *origin_path,
+int
+_media_thumb_get_thumb_from_db(const char *origin_path,
char *thumb_path,
int max_length,
int *need_update_db)
{
+ thumb_dbg("");
int err = -1;
//err = minfo_get_thumb_path(mb_svc_handle, origin_path, thumb_path, max_length);
@@ -468,16 +475,18 @@ int _media_thumb_get_thumb_from_db(const char *origin_path,
thumb_dbg("This thumb path already exist");
}
- return MS_MEDIA_ERR_NONE;
+ return MEDIA_THUMB_ERROR_NONE;
}
-int _media_thumb_get_thumb_from_db_with_size(const char *origin_path,
+int
+_media_thumb_get_thumb_from_db_with_size(const char *origin_path,
char *thumb_path,
int max_length,
int *need_update_db,
int *width,
int *height)
{
+ thumb_dbg("");
int err = -1;
//err = minfo_get_thumb_path(mb_svc_handle, origin_path, thumb_path, max_length);
@@ -515,32 +524,34 @@ int _media_thumb_get_thumb_from_db_with_size(const char *origin_path,
}
}
- return MS_MEDIA_ERR_NONE;
+ return MEDIA_THUMB_ERROR_NONE;
}
-int _media_thumb_update_db(const char *origin_path,
+int
+_media_thumb_update_db(const char *origin_path,
char *thumb_path,
int width,
int height,
uid_t uid)
{
- int err = MS_MEDIA_ERR_NONE;
+ thumb_dbg("");
+ int err = -1;
#if 0
Mitem *item = NULL;
err = minfo_get_item(mb_svc_handle, origin_path, &item);
- if (err != MS_MEDIA_ERR_NONE) {
+ if (err < 0) {
thumb_err("minfo_get_item (%s) failed: %d", origin_path, err);
- return err;
+ return MEDIA_THUMB_ERROR_DB;
}
err = minfo_update_media_thumb(mb_svc_handle, item->uuid, thumb_path);
- if (err != MS_MEDIA_ERR_NONE) {
+ if (err < 0) {
thumb_err("minfo_update_media_thumb (ID:%s, %s) failed: %d",
item->uuid, thumb_path, err);
minfo_destroy_mtype_item(item);
- return err;
+ return MEDIA_THUMB_ERROR_DB;
}
if (item->type == MINFO_ITEM_IMAGE) {
@@ -548,10 +559,10 @@ int _media_thumb_update_db(const char *origin_path,
MINFO_IMAGE_META_WIDTH, width,
MINFO_IMAGE_META_HEIGHT, height, -1);
- if (err != MS_MEDIA_ERR_NONE) {
+ if (err < 0) {
thumb_err("minfo_update_image_meta_info_int failed: %d", err);
minfo_destroy_mtype_item(item);
- return err;
+ return MEDIA_THUMB_ERROR_DB;
}
}
@@ -562,21 +573,21 @@ int _media_thumb_update_db(const char *origin_path,
err = _media_thumb_get_type_from_db(db_handle, origin_path, &media_type);
if (err < 0) {
thumb_err("_media_thumb_get_type_from_db (%s) failed: %d", origin_path, err);
- return err;
+ return MEDIA_THUMB_ERROR_DB;
}
#if 0
err = _media_thumb_update_thumb_path_to_db(db_handle, origin_path, thumb_path);
if (err < 0) {
thumb_err("_media_thumb_update_thumb_path_to_db (%s) failed: %d", origin_path, err);
- return err;
+ return MEDIA_THUMB_ERROR_DB;
}
if (media_type == THUMB_IMAGE_TYPE && width > 0 && height > 0) {
err = _media_thumb_update_wh_to_db(db_handle, origin_path, width, height);
if (err < 0) {
thumb_err("_media_thumb_update_wh_to_db (%s) failed: %d", origin_path, err);
- return err;
+ return MEDIA_THUMB_ERROR_DB;
}
}
#else
@@ -584,19 +595,19 @@ int _media_thumb_update_db(const char *origin_path,
err = _media_thumb_update_thumb_path_wh_to_db(db_handle, origin_path, thumb_path, width, height,uid);
if (err < 0) {
thumb_err("_media_thumb_update_wh_to_db (%s) failed: %d", origin_path, err);
- return err;
+ return MEDIA_THUMB_ERROR_DB;
}
} else {
err = _media_thumb_update_thumb_path_to_db(db_handle, origin_path, thumb_path, uid);
if (err < 0) {
thumb_err("_media_thumb_update_thumb_path_to_db (%s) failed: %d", origin_path, err);
- return err;
+ return MEDIA_THUMB_ERROR_DB;
}
}
#endif
thumb_dbg("_media_thumb_update_db success");
- return MS_MEDIA_ERR_NONE;
+ return MEDIA_THUMB_ERROR_NONE;
}
diff --git a/src/util/media-thumb-util.c b/src/util/media-thumb-util.c
index 2f0fef0..8421146 100755
--- a/src/util/media-thumb-util.c
+++ b/src/util/media-thumb-util.c
@@ -83,7 +83,7 @@ _media_thumb_get_file_type(const char *file_full_path)
char mimetype[255];
if (file_full_path == NULL)
- return MS_MEDIA_ERR_INVALID_PARAMETER;
+ return MEDIA_THUMB_ERROR_INVALID_PARAMETER;
ret = drm_is_drm_file(file_full_path, &drm_type);
if (ret < 0) {
@@ -382,30 +382,30 @@ int _thumbnail_get_data(const char *origin_path,
if (origin_path == NULL || size == NULL
|| width == NULL || height == NULL) {
thumb_err("Invalid parameter");
- return MS_MEDIA_ERR_INVALID_PARAMETER;
+ return MEDIA_THUMB_ERROR_INVALID_PARAMETER;
}
if (format < MEDIA_THUMB_BGRA || format > MEDIA_THUMB_RGB888) {
thumb_err("parameter format is invalid");
- 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) does not exist", origin_path);
- return MS_MEDIA_ERR_INVALID_PARAMETER;
+ return MEDIA_THUMB_ERROR_INVALID_PARAMETER;
}
thumb_width = _media_thumb_get_width(thumb_type);
if (thumb_width < 0) {
thumb_err("media_thumb_type is invalid");
- return MS_MEDIA_ERR_INVALID_PARAMETER;
+ return MEDIA_THUMB_ERROR_INVALID_PARAMETER;
}
thumb_height = _media_thumb_get_height(thumb_type);
if (thumb_height < 0) {
thumb_err("media_thumb_type is invalid");
- return MS_MEDIA_ERR_INVALID_PARAMETER;
+ return MEDIA_THUMB_ERROR_INVALID_PARAMETER;
}
thumb_dbg("Origin path : %s", origin_path);
@@ -440,5 +440,5 @@ int _thumbnail_get_data(const char *origin_path,
thumb_dbg("Thumb data is generated successfully (Size:%d, W:%d, H:%d) 0x%x",
*size, *width, *height, *data);
- return MS_MEDIA_ERR_NONE;
-} \ No newline at end of file
+ return MEDIA_THUMB_ERROR_NONE;
+}