SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}")
ENDFOREACH(flag)
-SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS} -fPIC")
+SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS} -fPIC -Wall -Werror -Wno-deprecated-declarations")
SET(CMAKE_C_FLAGS_DEBUG "-O0 -g")
SET(CMAKE_C_FLAGS_RELEASE "-O2 -fPIC")
Name: libmedia-service
Summary: Media information service library for multimedia applications
-Version: 0.3.2
+Version: 0.3.3
Release: 0
Group: Multimedia/Libraries
License: Apache-2.0 and PD
static GHashTable *table;
static GSList *column_list[MEDIA_SVC_DB_LIST_MAX];
-char *_media_svc_get_path(uid_t uid)
-{
- int ret = 0;
- char *result_path = NULL;
-
- ret = tzplatform_set_user(uid);
- if (ret != 0) {
- media_svc_error("Invalid UID[%d]", uid);
- return NULL;
- } else {
- const char *result = tzplatform_getenv(TZ_USER_CONTENT);
- result_path = strndup(result, strlen(result));
- tzplatform_reset_user();
- }
-
- return result_path;
-}
-
int __media_svc_add_table_info(const char *name, const char *trigger_name, const char *event_table, const char *action_table, const char *view_name)
{
table_info_s *tbl = NULL;
int i = 0;
int start_len = 0;
int path_len = 0;
- char *internal_path = _media_svc_get_path(uid);
+ char *internal_path = NULL;
+ int ret = MS_MEDIA_ERR_NONE;
+
+ ret = ms_user_get_internal_root_path(uid, &internal_path);
+ media_svc_retvm_if(ret != MS_MEDIA_ERR_NONE, ret, "Fail to get root path");
if (STRING_VALID(internal_path) && (strcmp(folder_path, internal_path) == 0)) {
media_svc_debug("ROOT PATH [%s]", folder_path);
char *internal_path = NULL;
memset(parent_folder_uuid, 0, sizeof(parent_folder_uuid));
- internal_path = _media_svc_get_path(uid);
+ ret = ms_user_get_internal_root_path(uid, &internal_path);
+ media_svc_retvm_if(ret != MS_MEDIA_ERR_NONE, ret, "Fail to get root path");
if (STRING_VALID(internal_path) && (strncmp(path, internal_path, strlen(internal_path)) == 0))
next_pos = strlen(internal_path);
SQLITE3_FINALIZE(sql_stmt);
if (storage_cnt == 0) {
- char *internal_path = _media_svc_get_path(uid);
+ char *internal_path = NULL;
+ ret = ms_user_get_internal_root_path(uid, &internal_path);
+ media_svc_retvm_if(ret != MS_MEDIA_ERR_NONE, ret, "Fail to get root path");
+
sql = sqlite3_mprintf("INSERT INTO %s (storage_uuid, storage_name, storage_path, storage_type) VALUES ('%s', '%s', '%s', 0);",
MEDIA_SVC_DB_TABLE_STORAGE, MEDIA_SVC_DB_TABLE_MEDIA, MEDIA_SVC_DB_TABLE_MEDIA, internal_path);
int remain_len = 0;
char *internal_path = NULL;
- internal_path = _media_svc_get_path(uid);
+ ret = ms_user_get_internal_root_path(uid, &internal_path);
+ media_svc_retvm_if(ret != MS_MEDIA_ERR_NONE, ret, "Fail to get root path");
if (STRING_VALID(internal_path) && strncmp(path, internal_path, strlen(internal_path)) == 0) {
_strncpy_safe(storage_id, MEDIA_SVC_DB_TABLE_MEDIA, MEDIA_SVC_UUID_SIZE+1);
return MS_MEDIA_ERR_NONE;
}
-static char *__media_svc_get_thumb_path(uid_t uid)
-{
- int ret = 0;
- char *result_path = NULL;
-
- ret = tzplatform_set_user(uid);
- if (ret != 0) {
- media_svc_error("Invalid UID[%d]", uid);
- return NULL;
- } else {
- const char *result = tzplatform_mkpath(TZ_USER_SHARE, "media/.thumb");
- result_path = strndup(result, strlen(result));
- tzplatform_reset_user();
- }
-
- return result_path;
-}
-
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;
static int _media_svc_save_image(unsigned char *image, unsigned int size, char *image_path, uid_t uid)
{
+ int ret = MS_MEDIA_ERR_NONE;
+
media_svc_debug("start save image, path [%s] image size [%d]", image_path, size);
if (!image) {
}
struct statfs fs;
- char *thumb_path = __media_svc_get_thumb_path(uid);
- if (!STRING_VALID(thumb_path)) {
- media_svc_error("fail to get thumb_path");
- return MS_MEDIA_ERR_INTERNAL;
- }
+ char *thumb_path = NULL;
+ ret = ms_user_get_root_thumb_store_path(uid, &thumb_path);
+ media_svc_retvm_if(ret != MS_MEDIA_ERR_NONE, ret, "ms_user_get_root_thumb_store_path fail");
if (-1 == statfs(thumb_path, &fs)) {
media_svc_error("error in statfs");
if ((bsize_kbytes * fs.f_bavail) < 1024) {
media_svc_error("not enought space...");
- return MS_MEDIA_ERR_INTERNAL;
+ return MS_MEDIA_ERR_NOT_ENOUGH_SPACE;
}
FILE *fp = NULL;
return MS_MEDIA_ERR_NONE;
}
-char *_media_svc_get_thumb_internal_path(uid_t uid)
-{
- int ret = 0;
- char *result_path = NULL;
-
- ret = tzplatform_set_user(uid);
- if (ret != 0) {
- media_svc_error("Invalid UID[%d]", uid);
- return NULL;
- } else {
- const char *result = tzplatform_mkpath(TZ_USER_SHARE, "media/.thumb/phone");
- result_path = strndup(result, strlen(result));
- tzplatform_reset_user();
- }
-
- return result_path;
-}
-
-char *_media_svc_get_thumb_external_path(uid_t uid)
-{
- int ret = 0;
- char *result_path = NULL;
-
- ret = tzplatform_set_user(uid);
- if (ret != 0) {
- media_svc_error("Invalid UID[%d]", uid);
- return NULL;
- } else {
- const char *result = tzplatform_mkpath(TZ_USER_SHARE, "media/.thumb/mmc");
- result_path = strndup(result, strlen(result));
- tzplatform_reset_user();
- }
-
- return result_path;
-}
-
static int __media_svc_check_thumb_dir(const char *thumb_dir)
{
DIR *dir = NULL;
char *thumb_dir = NULL;
char hash[255 + 1] = {0, };
char *thumbfile_ext = NULL;
- char *internal_thumb_path = _media_svc_get_thumb_internal_path(uid);
- char *external_thumb_path = _media_svc_get_thumb_external_path(uid);
+ char *internal_thumb_path = NULL;
+ char *external_thumb_path = NULL;
+
+ ret = ms_user_get_default_thumb_store_path(uid, &internal_thumb_path);
+ ret = ms_user_get_mmc_thumb_store_path(uid, &external_thumb_path);
if (!STRING_VALID(internal_thumb_path) || !STRING_VALID(external_thumb_path)) {
media_svc_error("fail to get thumbnail path");
return;
}
-int _media_svc_get_storage_type_by_path(const char *path, media_svc_storage_type_e *storage_type, uid_t uid)
-{
- if (STRING_VALID(path)) {
- char *internal_path = _media_svc_get_path(uid);
- if (STRING_VALID(internal_path) && (strncmp(path, internal_path, strlen(internal_path)) == 0)) {
- *storage_type = MEDIA_SVC_STORAGE_INTERNAL;
- } else if (STRING_VALID(MEDIA_ROOT_PATH_SDCARD) && (strncmp(path, MEDIA_ROOT_PATH_SDCARD, strlen(MEDIA_ROOT_PATH_SDCARD)) == 0)) {
- *storage_type = MEDIA_SVC_STORAGE_EXTERNAL;
- } else if (STRING_VALID(MEDIA_ROOT_PATH_USB) && (strncmp(path, MEDIA_ROOT_PATH_USB, strlen(MEDIA_ROOT_PATH_USB)) == 0)) {
- *storage_type = MEDIA_SVC_STORAGE_EXTERNAL_USB;
- } else if (STRING_VALID(MEDIA_ROOT_PATH_DISC) && (strncmp(path, MEDIA_ROOT_PATH_DISC, strlen(MEDIA_ROOT_PATH_DISC)) == 0)) {
- *storage_type = MEDIA_SVC_STORAGE_EXTERNAL;
- } else {
- media_svc_error("Invalid Path");
- media_svc_sec_error("Invalid Path [%s], internal_path [%s]", path, internal_path);
- SAFE_FREE(internal_path);
- return MS_MEDIA_ERR_INVALID_PARAMETER;
- }
- SAFE_FREE(internal_path);
- } else {
- media_svc_error("INVALID parameter");
- return MS_MEDIA_ERR_INVALID_PARAMETER;
- }
-
- return MS_MEDIA_ERR_NONE;
-}
-
char *_media_svc_replace_path(char *s, const char *olds, const char *news)
{
char result[MEDIA_SVC_PATHNAME_SIZE + 1] = {0, };
int media_svc_get_storage_type(const char *path, media_svc_storage_type_e *storage_type, uid_t uid)
{
int ret = MS_MEDIA_ERR_NONE;
- media_svc_storage_type_e type;
+ ms_user_storage_type_t type = -1;
- ret = _media_svc_get_storage_type_by_path(path, &type, uid);
- media_svc_retvm_if(ret != MS_MEDIA_ERR_NONE, ret, "_media_svc_get_storage_type_by_path failed : %d", ret);
+ ret = ms_user_get_storage_type(uid, path, &type);
+ media_svc_retvm_if(ret != MS_MEDIA_ERR_NONE, ret, "ms_user_get_storage_type failed : %d", ret);
*storage_type = type;
media_svc_retv_if(ret != MS_MEDIA_ERR_NONE, ret);
if (storage_type != MEDIA_SVC_STORAGE_EXTERNAL_USB) {
- char *internal_thumb_path = _media_svc_get_thumb_internal_path(uid);
- char *external_thumb_path = _media_svc_get_thumb_external_path(uid);
+ char *internal_thumb_path = NULL;
+ char *external_thumb_path = NULL;
+ ret = ms_user_get_default_thumb_store_path(uid, &internal_thumb_path);
+ ret = ms_user_get_mmc_thumb_store_path(uid, &external_thumb_path);
+
+ if (!STRING_VALID(internal_thumb_path) || !STRING_VALID(external_thumb_path)) {
+ media_svc_error("fail to get thumbnail path");
+ SAFE_FREE(internal_thumb_path);
+ SAFE_FREE(external_thumb_path);
+ return MS_MEDIA_ERR_INTERNAL;
+ }
const char *dirpath = (storage_type == MEDIA_SVC_STORAGE_INTERNAL) ? internal_thumb_path : external_thumb_path;
/* remove thumbnails */
}
media_svc_debug("New media path : %s", replaced_path);
- media_svc_storage_type_e storage_type;
+ ms_user_storage_type_t storage_type = -1;
if (!no_thumb) {
/* If old thumb path is default or not */
if (STRING_VALID(default_thumbnail_path) && (strncmp(media_thumb_path, default_thumbnail_path, strlen(default_thumbnail_path)) == 0)) {
_strncpy_safe(media_new_thumb_path, default_thumbnail_path, sizeof(media_new_thumb_path));
} else {
- ret = _media_svc_get_storage_type_by_path(replaced_path, &storage_type, uid);
+ ret = ms_user_get_storage_type(uid, replaced_path, &storage_type);
if (ret != MS_MEDIA_ERR_NONE) {
- media_svc_error("_media_svc_get_storage_type_by_path failed : %d", ret);
+ media_svc_sec_error("ms_user_get_storage_type failed : [%d], path[%s] storage_type[%d]", ret, replaced_path, storage_type);
SAFE_FREE(replaced_path);
SAFE_FREE(default_thumbnail_path);
_media_svc_sql_rollback_trans(uid);
media_svc_retvm_if(storage_id == NULL, MS_MEDIA_ERR_INVALID_PARAMETER, "storage_id is NULL");
ret = _media_svc_get_storage_type(db_handle, storage_id, &storage_type);
- media_svc_retvm_if(ret != MS_MEDIA_ERR_NONE, ret, "_media_svc_get_storage_type_by_path failed : %d", ret);
+ media_svc_retvm_if(ret != MS_MEDIA_ERR_NONE, ret, "_media_svc_get_storage_type failed : %d", ret);
ret = _media_svc_delete_storage(storage_id, storage_name, uid);
media_svc_retvm_if(ret != MS_MEDIA_ERR_NONE, ret, "remove storage failed : %d", ret);
void _media_svc_sql_query_release(GList **query_list);
int _media_svc_check_db_upgrade(sqlite3 *db_handle, int user_version, uid_t uid);
int _media_db_check_corrupt(sqlite3 *db_handle);
-char *_media_svc_get_path(uid_t uid);
-
#endif /*_MEDIA_SVC_DB_UTILS_H_*/
int __media_svc_malloc_and_strncpy(char **dst, const char *src);
time_t __media_svc_get_timeline_from_str(const char *timstr);
void _media_svc_destroy_content_info(media_svc_content_info_s *content_info);
-int _media_svc_get_storage_type_by_path(const char *path, media_svc_storage_type_e *storage_type, uid_t uid);
char *_media_svc_replace_path(char *s, const char *olds, const char *news);
-char *_media_svc_get_thumb_internal_path(uid_t uid);
-char *_media_svc_get_thumb_external_path(uid_t uid);
bool _media_svc_is_drm_file(const char *path);
int _media_svc_request_thumbnail_with_origin_size(const char *path, char *thumb_path, int max_length, int *origin_width, int *origin_height, uid_t uid);
int _media_svc_get_pinyin_str(const char *src_str, char **pinyin_str);