Change the name of plug-in API. (Duplicate connect() API).
Change-Id: I0221a64f4f3b0b31a39034b0bfe53509d8dc809c
Signed-off-by: Minje Ahn <minje.ahn@samsung.com>
SET(BINDIR "${PREFIX}/bin")
SET(DATADIR "${PREFIX}/share")
SET(EXEC_PREFIX "\${prefix}")
+SET(LIBDIR "\${prefix}/lib")
SET(INCLUDEDIR "\${prefix}/include")
IF("${CMAKE_BUILD_TYPE}" STREQUAL "")
INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/include ${CMAKE_SOURCE_DIR}/src/include/common ${CMAKE_SOURCE_DIR} ${CMAKE_SOURCE_DIR}/uuid ${CMAKE_SOURCE_DIR}/md5)
-INCLUDE(FindPkgConfig)
-pkg_check_modules(pkgs REQUIRED glib-2.0 dlog sqlite3 db-util libexif mm-common mm-fileinfo drm-client media-thumbnail libmedia-utils aul)
+FIND_PROGRAM(UNAME NAMES uname)
+EXEC_PROGRAM("${UNAME}" ARGS "-m" OUTPUT_VARIABLE "ARCH")
+INCLUDE(FindPkgConfig)
+pkg_check_modules(pkgs REQUIRED glib-2.0 dlog sqlite3 db-util libexif mm-common mm-fileinfo media-thumbnail libmedia-utils aul vconf drm-client)
FOREACH(flag ${pkgs_CFLAGS})
SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}")
SET(CMAKE_C_FLAGS_DEBUG "-O0 -g")
SET(CMAKE_C_FLAGS_RELEASE "-O2 -fPIC")
-FIND_PROGRAM(UNAME NAMES uname)
-EXEC_PROGRAM("${UNAME}" ARGS "-m" OUTPUT_VARIABLE "ARCH")
IF("${ARCH}" STREQUAL "arm")
ADD_DEFINITIONS("-DTARGET")
MESSAGE("add -DTARGET")
INSTALL(TARGETS ${MEDIACONTENT-PLUGIN-LIB} LIBRARY DESTINATION ${LIB_INSTALL_DIR})
INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/include/media-svc.h DESTINATION include/media-service/)
-INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/include/media-svc-error.h DESTINATION include/media-service/)
INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/include/media-svc-types.h DESTINATION include/media-service/)
+++ /dev/null
-/*
- * libmedia-service
- *
- * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
- *
- * Contact: Hyunjun Ko <zzoon.ko@samsung.com>, Haejeong Kim <backto.kim@samsung.com>
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-
-
-#ifndef _MEDIA_SVC_ERROR_H_
-#define _MEDIA_SVC_ERROR_H_
-
-/**
- @addtogroup MEDIA_SVC
- @{
- * @file media-svc-error.h
- * @brief This file defines error codes for media service.
-
- */
-
-/**
- @defgroup MEDIA_SVC_COMMON Global data structure and error code
- @{
-
- @par
- type definition and error code
- */
-
-
-#define MEDIA_INFO_ERROR_NONE 0 /**< No Error */
-
-#define MEDIA_INFO_ERROR_INVALID_PARAMETER -1 /**< Invalid parameter */
-#define MEDIA_INFO_ERROR_INVALID_MEDIA -2 /**< Invalid media */
-#define MEDIA_INFO_ERROR_INVALID_FILE_FORMAT -3 /**< Invalid file format */
-#define MEDIA_INFO_ERROR_INVALID_PATH -4 /**< Invalid file path */
-#define MEDIA_INFO_ERROR_OUT_OF_MEMORY -5 /**< Out of memory */
-#define MEDIA_INFO_ERROR_OUT_OF_STORAGE -6 /**< Out of storage */
-#define MEDIA_INFO_ERROR_INSERT_FAIL -7 /**< Insert failed */
-#define MEDIA_INFO_ERROR_DRM_INSERT_FAIL -8 /**< DRM file insert failed */
-
-#define MEDIA_INFO_ERROR_ITEM_NOT_FOUND -11 /**< Item not found */
-#define MEDIA_INFO_ERROR_FILE_NOT_FOUND -12 /**< File not found */
-#define MEDIA_INFO_ERROR_APPEND_ITEM_FAILED -13 /**< Append item failed */
-#define MEDIA_INFO_ERROR_REMOVE_ITEM_FAILED -14 /**< Remove item failed */
-#define MEDIA_INFO_ERROR_GET_ITEM_FAILED -15 /**< Get item failed */
-#define MEDIA_INFO_ERROR_REMOVE_FILE_FAILED -16 /**< Remove file failed */
-#define MEDIA_INFO_ERROR_EXTRACT_FAILED -17 /**< Extract Failed */
-#define MEDIA_INFO_ERROR_MAKE_PLAYLIST_NAME_FAILED -18 /**< fail to make new playlist name */
-
-#define MEDIA_INFO_ERROR_DATABASE_CONNECT -100 /**< DB connect error */
-#define MEDIA_INFO_ERROR_DATABASE_DISCONNECT -101 /**< DB disconnect error */
-#define MEDIA_INFO_ERROR_DATABASE_QUERY -104 /**< DB query error */
-#define MEDIA_INFO_ERROR_DATABASE_TABLE_OPEN -105 /**< DB table open error */
-#define MEDIA_INFO_ERROR_DATABASE_INVALID -106 /**< DB invalid error */
-#define MEDIA_INFO_ERROR_DATABASE_INTERNAL -107 /**< DB internal error */
-#define MEDIA_INFO_ERROR_DATABASE_NO_RECORD -108 /**< Item not found in DB */
-
-#define MEDIA_INFO_ERROR_SOCKET_CONN -201 /**< Socket connect error */
-#define MEDIA_INFO_ERROR_SOCKET_MSG -202 /**< Socket message error */
-#define MEDIA_INFO_ERROR_SOCKET_SEND -203 /**< Socket send error */
-#define MEDIA_INFO_ERROR_SOCKET_RECEIVE -204 /**< Socket receive error */
-#define MEDIA_INFO_ERROR_SOCKET_RECEIVE_TIMEOUT -205 /**< Socket time out */
-
-#define MEDIA_INFO_ERROR_SEND_NOTI_FAIL -301 /**< Sending Notifications fail */
-
-#define MEDIA_INFO_ERROR_INTERNAL -998 /**< Internal error */
-#define MEDIA_INFO_ERROR_UNKNOWN -999 /**< Unknown error */
-#define MEDIA_INFO_ERROR_NOT_IMPLEMENTED -200 /**< Not implemented */
-/**
- @}
-*/
-
-/**
- @}
-*/
-
-#endif /*_MEDIA_SVC_ERROR_H_*/
#define _MEDIA_SVC_H_
#include "media-svc-types.h"
-#include "media-svc-error.h"
#include <media-util-noti.h>
#include <stdbool.h>
#ifdef __cplusplus
#include <string.h>
#include <alloca.h>
#include "media-svc-hash.h"
-#include "media-svc-error.h"
+#include "media-util-err.h"
static const char ACCEPTABLE_URI_CHARS[96] = {
char *hash = NULL;
if (max_length < ((2 * MD5_HASHBYTES) + 1)) {
- return MEDIA_INFO_ERROR_INVALID_PARAMETER;
+ return MS_MEDIA_ERR_INVALID_PARAMETER;
}
hash = _mb_svc_generate_hash_name(origin_path);
if (hash == NULL) {
- return MEDIA_INFO_ERROR_INTERNAL;
+ return MS_MEDIA_ERR_INTERNAL;
}
strncpy(hash_code, hash, max_length);
hash_code[strlen(hash_code)] ='\0';
- return MEDIA_INFO_ERROR_NONE;
+ return MS_MEDIA_ERR_NONE;
}
#include <mm_file.h>
#include <media-thumbnail.h>
#include "media-svc.h"
+#include "media-svc-util.h"
#define MEDIA_SVC_PLUGIN_ERROR_NONE 0
#define MEDIA_SVC_PLUGIN_ERROR -1
ERR_MAX,
}media_svc_error_type_e;
-#define MS_CATEGORY_UNKNOWN 0x00000000 /**< Default */
-#define MS_CATEGORY_ETC 0x00000001 /**< ETC category */
-#define MS_CATEGORY_IMAGE 0x00000002 /**< Image category */
-#define MS_CATEGORY_VIDEO 0x00000004 /**< Video category */
-#define MS_CATEGORY_MUSIC 0x00000008 /**< Music category */
-#define MS_CATEGORY_SOUND 0x00000010 /**< Sound category */
-
-#define CONTENT_TYPE_NUM 4
-#define MUSIC_MIME_NUM 29
-#define SOUND_MIME_NUM 1
-#define MIME_TYPE_LENGTH 255
-#define MIME_LENGTH 50
-#define _3GP_FILE ".3gp"
-#define _MP4_FILE ".mp4"
-
-
-typedef struct {
- char content_type[15];
- int category_by_mime;
-} fex_content_table_t;
-
-static const fex_content_table_t content_category[CONTENT_TYPE_NUM] = {
- {"audio", MS_CATEGORY_SOUND},
- {"image", MS_CATEGORY_IMAGE},
- {"video", MS_CATEGORY_VIDEO},
- {"application", MS_CATEGORY_ETC},
-};
-
-static const char music_mime_table[MUSIC_MIME_NUM][MIME_LENGTH] = {
- /*known mime types of normal files*/
- "mpeg",
- "ogg",
- "x-ms-wma",
- "x-flac",
- "mp4",
- /* known mime types of drm files*/
- "mp3",
- "x-mp3", /*alias of audio/mpeg*/
- "x-mpeg", /*alias of audio/mpeg*/
- "3gpp",
- "x-ogg", /*alias of audio/ogg*/
- "vnd.ms-playready.media.pya:*.pya", /*playready*/
- "wma",
- "aac",
- "x-m4a", /*alias of audio/mp4*/
- /* below mimes are rare*/
- "x-vorbis+ogg",
- "x-flac+ogg",
- "x-matroska",
- "ac3",
- "mp2",
- "x-ape",
- "x-ms-asx",
- "vnd.rn-realaudio",
-
- "x-vorbis", /*alias of audio/x-vorbis+ogg*/
- "vorbis", /*alias of audio/x-vorbis+ogg*/
- "x-oggflac",
- "x-mp2", /*alias of audio/mp2*/
- "x-pn-realaudio", /*alias of audio/vnd.rn-realaudio*/
- "vnd.m-realaudio", /*alias of audio/vnd.rn-realaudio*/
- "x-wav",
-};
-
-static const char sound_mime_table[SOUND_MIME_NUM][MIME_LENGTH] = {
- "x-smaf",
-};
-
static void __set_error_message(int err_type, char ** err_msg);
static void __set_error_message(int err_type, char ** err_msg)
*err_msg = strdup("invalid storage type");
else if(err_type == ERR_CHECK_ITEM)
*err_msg = strdup("item does not exist");
- else if(err_type == MEDIA_INFO_ERROR_DATABASE_CONNECT)
+ else if(err_type == MS_MEDIA_ERR_DB_CONNECT_FAIL)
*err_msg = strdup("DB connect error");
- else if(err_type == MEDIA_INFO_ERROR_DATABASE_DISCONNECT)
+ else if(err_type == MS_MEDIA_ERR_DB_DISCONNECT_FAIL)
*err_msg = strdup("DB disconnect error");
- else if(err_type == MEDIA_INFO_ERROR_INVALID_PARAMETER)
+ else if(err_type == MS_MEDIA_ERR_INVALID_PARAMETER)
*err_msg = strdup("invalid parameter");
- else if(err_type == MEDIA_INFO_ERROR_DATABASE_INTERNAL)
+ else if(err_type == MS_MEDIA_ERR_DB_INTERNAL)
*err_msg = strdup("DB internal error");
- else if(err_type == MEDIA_INFO_ERROR_DATABASE_NO_RECORD)
+ else if(err_type == MS_MEDIA_ERR_DB_NO_RECORD)
*err_msg = strdup("not found in DB");
- else if(err_type == MEDIA_INFO_ERROR_INTERNAL)
+ else if(err_type == MS_MEDIA_ERR_INTERNAL)
*err_msg = strdup("media service internal error");
+ else if(err_type == MS_MEDIA_ERR_DB_CORRUPT)
+ *err_msg = strdup("DB corrupt error");
else
*err_msg = strdup("error unknown");
return MEDIA_SVC_PLUGIN_ERROR_NONE;
}
-int connect(void ** handle, uid_t uid, char ** err_msg)
+int connect_db(void ** handle, uid_t uid, char ** err_msg)
{
int ret = media_svc_connect(handle,uid);
return MEDIA_SVC_PLUGIN_ERROR_NONE;
}
-int disconnect(void * handle, char ** err_msg)
+int disconnect_db(void * handle, char ** err_msg)
{
int ret = MEDIA_SVC_PLUGIN_ERROR_NONE;
}
ret = media_svc_check_item_exist_by_path(handle, file_path);
- if(ret == MEDIA_INFO_ERROR_NONE)
+ if(ret == MS_MEDIA_ERR_NONE) {
return MEDIA_SVC_PLUGIN_ERROR_NONE; //exist
+ }
__set_error_message(ERR_CHECK_ITEM, err_msg);
*
*/
+#include <media-util-err.h>
#include "media-svc-album.h"
-#include "media-svc-error.h"
#include "media-svc-debug.h"
#include "media-svc-env.h"
#include "media-svc-util.h"
int _media_svc_get_album_id(sqlite3 *handle, const char *album, const char *artist, int * album_id)
{
- int ret = MEDIA_INFO_ERROR_NONE;
+ int ret = MS_MEDIA_ERR_NONE;
sqlite3_stmt *sql_stmt = NULL;
char *sql = NULL;
- media_svc_retvm_if(album == NULL, MEDIA_INFO_ERROR_INVALID_PARAMETER, "album is NULL");
+ media_svc_retvm_if(album == NULL, MS_MEDIA_ERR_INVALID_PARAMETER, "album is NULL");
if(artist != NULL) {
sql = sqlite3_mprintf("SELECT album_id FROM %s WHERE name = '%q' AND artist = '%q';", MEDIA_SVC_DB_TABLE_ALBUM, album, artist);
ret = _media_svc_sql_prepare_to_step(handle, sql, &sql_stmt);
- if (ret != MEDIA_INFO_ERROR_NONE) {
- if(ret == MEDIA_INFO_ERROR_DATABASE_NO_RECORD) {
+ if (ret != MS_MEDIA_ERR_NONE) {
+ if(ret == MS_MEDIA_ERR_DB_NO_RECORD) {
media_svc_debug("there is no album.");
}
else {
int _media_svc_get_album_art_by_album_id(sqlite3 *handle, int album_id, char **album_art)
{
- int ret = MEDIA_INFO_ERROR_NONE;
+ int ret = MS_MEDIA_ERR_NONE;
sqlite3_stmt *sql_stmt = NULL;
char *value = NULL;
ret = _media_svc_sql_prepare_to_step(handle, sql, &sql_stmt);
- if (ret != MEDIA_INFO_ERROR_NONE) {
- if(ret == MEDIA_INFO_ERROR_DATABASE_NO_RECORD) {
+ if (ret != MS_MEDIA_ERR_NONE) {
+ if(ret == MS_MEDIA_ERR_DB_NO_RECORD) {
media_svc_debug("there is no album_id.");
}
else {
- media_svc_error("error when _media_svc_get_folder_id_by_foldername. err = [%d]", ret);
+ media_svc_error("error when get album_art. err = [%d]", ret);
}
return ret;
}
if (STRING_VALID(value)) {
ret = __media_svc_malloc_and_strncpy(album_art, value);
- if (ret < 0) {
- media_svc_error("__media_svc_malloc_and_strncpy failed: %d", ret);
+ if (ret != MS_MEDIA_ERR_NONE) {
SQLITE3_FINALIZE(sql_stmt);
return ret;
}
SQLITE3_FINALIZE(sql_stmt);
- return MEDIA_INFO_ERROR_NONE;
+ return MS_MEDIA_ERR_NONE;
}
int _media_svc_append_album(sqlite3 *handle, const char *album, const char *artist, const char *album_art, int * album_id, uid_t uid)
{
- int err = -1;
+ int ret = MS_MEDIA_ERR_NONE;
char *sql = sqlite3_mprintf("INSERT INTO %s (name, artist, album_art, album_art) values (%Q, %Q, %Q, %Q); ",
MEDIA_SVC_DB_TABLE_ALBUM, album, artist, album_art, album_art);
- err = _media_svc_sql_query(handle, sql, uid);
+ ret = _media_svc_sql_query(handle, sql, uid);
sqlite3_free(sql);
- if (err != SQLITE_OK) {
- media_svc_error("failed to insert albums");
- return MEDIA_INFO_ERROR_DATABASE_INTERNAL;
- }
+ media_svc_retv_if(ret != MS_MEDIA_ERR_NONE, ret);
//*album_id = sqlite3_last_insert_rowid(handle);
int inserted_album_id = 0;
- err = _media_svc_get_album_id(handle, album, artist, &inserted_album_id);
- if (err < 0) {
- media_svc_error("Failed _media_svc_get_album_id : %d", err);
- return err;
- }
+ ret = _media_svc_get_album_id(handle, album, artist, &inserted_album_id);
+ media_svc_retv_if(ret != MS_MEDIA_ERR_NONE, ret);
*album_id = inserted_album_id;
- return MEDIA_INFO_ERROR_NONE;
+ return MS_MEDIA_ERR_NONE;
}
int _media_svc_get_media_count_with_album_id_by_path(sqlite3 *handle, const char *path, int *count)
{
- int ret = MEDIA_INFO_ERROR_NONE;
+ int ret = MS_MEDIA_ERR_NONE;
sqlite3_stmt *sql_stmt = NULL;
char *sql = NULL;
- media_svc_retvm_if(path == NULL, MEDIA_INFO_ERROR_INVALID_PARAMETER, "path is NULL");
+ media_svc_retvm_if(path == NULL, MS_MEDIA_ERR_INVALID_PARAMETER, "path is NULL");
sql = sqlite3_mprintf("select count(media_uuid) from %s INNER JOIN (select album_id from %s where path=%Q and album_id > 0) as album ON album.album_id=media.album_id;", MEDIA_SVC_DB_TABLE_MEDIA, MEDIA_SVC_DB_TABLE_MEDIA, path);
ret = _media_svc_sql_prepare_to_step(handle, sql, &sql_stmt);
- if (ret != MEDIA_INFO_ERROR_NONE) {
- if(ret == MEDIA_INFO_ERROR_DATABASE_NO_RECORD) {
+ if (ret != MS_MEDIA_ERR_NONE) {
+ if(ret == MS_MEDIA_ERR_DB_NO_RECORD) {
media_svc_debug("there is no media in relted to this media's album.");
}
else {
*/
#include <unistd.h>
+#include <sys/stat.h>
#include <db-util.h>
#include <media-util.h>
+#include <errno.h>
#include "media-svc-env.h"
#include "media-svc-debug.h"
-#include "media-svc-error.h"
#include "media-svc-util.h"
#include "media-svc-db-utils.h"
+#include "media-util-err.h"
#include "media-util-db.h"
+#include "media-svc-media.h"
static int __media_svc_create_update_media_table(sqlite3 *db_handle);
int _media_svc_connect_db_with_handle(sqlite3 **db_handle)
{
- int ret = MEDIA_INFO_ERROR_NONE;
+ int ret = MS_MEDIA_ERR_NONE;
media_svc_debug_func();
media_svc_error("error when db open");
*db_handle = NULL;
- return MEDIA_INFO_ERROR_DATABASE_CONNECT;
+ return MS_MEDIA_ERR_DB_INTERNAL;
}
/*Register busy handler*/
db_util_close(*db_handle);
*db_handle = NULL;
- return MEDIA_INFO_ERROR_DATABASE_CONNECT;
+ return MS_MEDIA_ERR_DB_INTERNAL;
}
} else {
*db_handle = NULL;
- return MEDIA_INFO_ERROR_DATABASE_CONNECT;
+ return MS_MEDIA_ERR_DB_INTERNAL;
}
- return MEDIA_INFO_ERROR_NONE;
+ return MS_MEDIA_ERR_NONE;
}
int _media_svc_disconnect_db_with_handle(sqlite3 *db_handle)
{
- int ret = MEDIA_INFO_ERROR_NONE;
+ int ret = MS_MEDIA_ERR_NONE;
media_svc_debug_func();
if (SQLITE_OK != ret) {
media_svc_error("Error when db close : %s", sqlite3_errmsg(db_handle));
db_handle = NULL;
- return MEDIA_INFO_ERROR_DATABASE_DISCONNECT;
+ return MS_MEDIA_ERR_DB_INTERNAL;
}
- return MEDIA_INFO_ERROR_NONE;
+ return MS_MEDIA_ERR_NONE;
}
int _media_svc_create_media_table(sqlite3 *db_handle, uid_t uid)
{
- int ret = MEDIA_INFO_ERROR_NONE;
- char * sql = NULL;
+ int ret = MS_MEDIA_ERR_NONE;
+ char *sql = NULL;
media_svc_debug_func();
sql = sqlite3_mprintf(MEDIA_DB_SCHEMA, MEDIA_SVC_DB_TABLE_MEDIA);
- media_svc_retv_if(sql == NULL, MEDIA_INFO_ERROR_OUT_OF_MEMORY);
+ media_svc_retv_if(sql == NULL, MS_MEDIA_ERR_OUT_OF_MEMORY);
ret = _media_svc_sql_query(db_handle, sql, uid);
sqlite3_free(sql);
if (ret != SQLITE_OK) {
media_svc_error("It failed to create db table (%d)", ret);
- return MEDIA_INFO_ERROR_DATABASE_TABLE_OPEN;
+ return MS_MEDIA_ERR_DB_INTERNAL;
}
/* Create Index*/
MEDIA_SVC_DB_TABLE_MEDIA,
MEDIA_SVC_DB_TABLE_MEDIA);
- media_svc_retv_if(sql == NULL, MEDIA_INFO_ERROR_OUT_OF_MEMORY);
+ media_svc_retv_if(sql == NULL, MS_MEDIA_ERR_OUT_OF_MEMORY);
ret = _media_svc_sql_query(db_handle, sql, uid);
sqlite3_free(sql);
if (ret != SQLITE_OK) {
media_svc_error("It failed to create db table (%d)", ret);
- return MEDIA_INFO_ERROR_DATABASE_TABLE_OPEN;
+ return MS_MEDIA_ERR_DB_INTERNAL;
}
- return MEDIA_INFO_ERROR_NONE;
+ return MS_MEDIA_ERR_NONE;
}
int _media_svc_create_folder_table(sqlite3 *db_handle, uid_t uid)
{
- int ret = MEDIA_INFO_ERROR_NONE;
- char * sql = NULL;
+ int ret = MS_MEDIA_ERR_NONE;
+ char *sql = NULL;
media_svc_debug_func();
);",
MEDIA_SVC_DB_TABLE_FOLDER);
- media_svc_retv_if(sql == NULL, MEDIA_INFO_ERROR_OUT_OF_MEMORY);
+ media_svc_retv_if(sql == NULL, MS_MEDIA_ERR_OUT_OF_MEMORY);
ret = _media_svc_sql_query(db_handle, sql, uid);
sqlite3_free(sql);
if (ret != SQLITE_OK) {
media_svc_error("It failed to create db table (%d)", ret);
- return MEDIA_INFO_ERROR_DATABASE_TABLE_OPEN;
+ return MS_MEDIA_ERR_DB_INTERNAL;
}
/* Create Trigger to remove folder which have no content from folder when media remove from media_table*/
WHERE (SELECT count(*) FROM %s WHERE folder_uuid=old.folder_uuid)=1 AND folder_uuid=old.folder_uuid;END;",
MEDIA_SVC_DB_TABLE_MEDIA, MEDIA_SVC_DB_TABLE_FOLDER, MEDIA_SVC_DB_TABLE_MEDIA);
- media_svc_retv_if(sql == NULL, MEDIA_INFO_ERROR_OUT_OF_MEMORY);
+ media_svc_retv_if(sql == NULL, MS_MEDIA_ERR_OUT_OF_MEMORY);
ret = _media_svc_sql_query(db_handle, sql, uid);
sqlite3_free(sql);
if (ret != SQLITE_OK) {
media_svc_error("It failed to create trigger (%d)", ret);
- return MEDIA_INFO_ERROR_DATABASE_TABLE_OPEN;
+ return MS_MEDIA_ERR_DB_INTERNAL;
}
/* Create Index*/
",
MEDIA_SVC_DB_TABLE_FOLDER);
- media_svc_retv_if(sql == NULL, MEDIA_INFO_ERROR_OUT_OF_MEMORY);
+ media_svc_retv_if(sql == NULL, MS_MEDIA_ERR_OUT_OF_MEMORY);
ret = _media_svc_sql_query(db_handle, sql, uid);
sqlite3_free(sql);
- media_svc_retv_if(ret != MEDIA_INFO_ERROR_NONE, ret);
- return MEDIA_INFO_ERROR_NONE;
+ media_svc_retv_if(ret != MS_MEDIA_ERR_NONE, ret);
+ return MS_MEDIA_ERR_NONE;
}
int _media_svc_create_playlist_table(sqlite3 *db_handle, uid_t uid)
{
- int ret = MEDIA_INFO_ERROR_NONE;
+ int ret = MS_MEDIA_ERR_NONE;
char * sql = NULL;
media_svc_debug_func();
);",
MEDIA_SVC_DB_TABLE_PLAYLIST);
- media_svc_retv_if(sql == NULL, MEDIA_INFO_ERROR_OUT_OF_MEMORY);
+ media_svc_retv_if(sql == NULL, MS_MEDIA_ERR_OUT_OF_MEMORY);
ret = _media_svc_sql_query(db_handle, sql, uid);
sqlite3_free(sql);
if (ret != SQLITE_OK) {
media_svc_error("It failed to create db table (%d)", ret);
- return MEDIA_INFO_ERROR_DATABASE_TABLE_OPEN;
+ return MS_MEDIA_ERR_DB_INTERNAL;
}
/*Create playlist_map table*/
);",
MEDIA_SVC_DB_TABLE_PLAYLIST_MAP);
- media_svc_retv_if(sql == NULL, MEDIA_INFO_ERROR_OUT_OF_MEMORY);
+ media_svc_retv_if(sql == NULL, MS_MEDIA_ERR_OUT_OF_MEMORY);
ret = _media_svc_sql_query(db_handle, sql, uid);
sqlite3_free(sql);
if (ret != SQLITE_OK) {
media_svc_error("It failed to create db table (%d)", ret);
- return MEDIA_INFO_ERROR_DATABASE_TABLE_OPEN;
+ return MS_MEDIA_ERR_DB_INTERNAL;
}
/* Create playlist_view*/
WHERE playlist_id IN (select pm.playlist_id from playlist_map AS pm INNER JOIN media AS m ON (pm.media_uuid= m.media_uuid) AND m.validity=0); \
");
- media_svc_retv_if(sql == NULL, MEDIA_INFO_ERROR_OUT_OF_MEMORY);
+ media_svc_retv_if(sql == NULL, MS_MEDIA_ERR_OUT_OF_MEMORY);
ret = _media_svc_sql_query(db_handle, sql, uid);
sqlite3_free(sql);
- media_svc_retv_if(ret != MEDIA_INFO_ERROR_NONE, ret);
+ media_svc_retv_if(ret != MS_MEDIA_ERR_NONE, ret);
/* Create Trigger to remove media from playlist_map when media remove from media_table*/
sql = sqlite3_mprintf("CREATE TRIGGER IF NOT EXISTS playlist_map_cleanup \
DELETE ON %s BEGIN DELETE FROM %s WHERE media_uuid=old.media_uuid;END;",
MEDIA_SVC_DB_TABLE_MEDIA, MEDIA_SVC_DB_TABLE_PLAYLIST_MAP);
- media_svc_retv_if(sql == NULL, MEDIA_INFO_ERROR_OUT_OF_MEMORY);
+ media_svc_retv_if(sql == NULL, MS_MEDIA_ERR_OUT_OF_MEMORY);
ret = _media_svc_sql_query(db_handle, sql, uid);
sqlite3_free(sql);
if (ret != SQLITE_OK) {
media_svc_error("It failed to create trigger (%d)", ret);
- return MEDIA_INFO_ERROR_DATABASE_TABLE_OPEN;
+ return MS_MEDIA_ERR_DB_INTERNAL;
}
/* Create Trigger to remove media from playlist_map when playlist removed from playlist table*/
DELETE ON %s BEGIN DELETE FROM %s WHERE playlist_id=old.playlist_id;END;",
MEDIA_SVC_DB_TABLE_PLAYLIST, MEDIA_SVC_DB_TABLE_PLAYLIST_MAP);
- media_svc_retv_if(sql == NULL, MEDIA_INFO_ERROR_OUT_OF_MEMORY);
+ media_svc_retv_if(sql == NULL, MS_MEDIA_ERR_OUT_OF_MEMORY);
ret = _media_svc_sql_query(db_handle, sql, uid);
sqlite3_free(sql);
if (ret != SQLITE_OK) {
media_svc_error("It failed to create trigger (%d)", ret);
- return MEDIA_INFO_ERROR_DATABASE_TABLE_OPEN;
+ return MS_MEDIA_ERR_DB_INTERNAL;
}
- return MEDIA_INFO_ERROR_NONE;
+ return MS_MEDIA_ERR_NONE;
}
int _media_svc_create_album_table(sqlite3 *db_handle, uid_t uid)
{
- int ret = MEDIA_INFO_ERROR_NONE;
+ int ret = MS_MEDIA_ERR_NONE;
char * sql = NULL;
media_svc_debug_func();
);",
MEDIA_SVC_DB_TABLE_ALBUM);
- media_svc_retv_if(sql == NULL, MEDIA_INFO_ERROR_OUT_OF_MEMORY);
+ media_svc_retv_if(sql == NULL, MS_MEDIA_ERR_OUT_OF_MEMORY);
ret = _media_svc_sql_query(db_handle, sql, uid);
sqlite3_free(sql);
if (ret != SQLITE_OK) {
media_svc_error("It failed to create db table (%d)", ret);
- return MEDIA_INFO_ERROR_DATABASE_TABLE_OPEN;
+ return MS_MEDIA_ERR_DB_INTERNAL;
}
/* Create Trigger to remove album when media remove from media_table*/
WHERE (SELECT count(*) FROM %s WHERE album_id=old.album_id)=1 AND album_id=old.album_id;END;",
MEDIA_SVC_DB_TABLE_MEDIA, MEDIA_SVC_DB_TABLE_ALBUM, MEDIA_SVC_DB_TABLE_MEDIA);
- media_svc_retv_if(sql == NULL, MEDIA_INFO_ERROR_OUT_OF_MEMORY);
+ media_svc_retv_if(sql == NULL, MS_MEDIA_ERR_OUT_OF_MEMORY);
ret = _media_svc_sql_query(db_handle, sql, uid);
sqlite3_free(sql);
if (ret != SQLITE_OK) {
media_svc_error("It failed to create trigger (%d)", ret);
- return MEDIA_INFO_ERROR_DATABASE_TABLE_OPEN;
+ return MS_MEDIA_ERR_DB_INTERNAL;
}
- return MEDIA_INFO_ERROR_NONE;
+ return MS_MEDIA_ERR_NONE;
}
int _media_svc_create_tag_table(sqlite3 *db_handle, uid_t uid)
{
- int ret = MEDIA_INFO_ERROR_NONE;
+ int ret = MS_MEDIA_ERR_NONE;
char * sql = NULL;
media_svc_debug_func();
);",
MEDIA_SVC_DB_TABLE_TAG);
- media_svc_retv_if(sql == NULL, MEDIA_INFO_ERROR_OUT_OF_MEMORY);
+ media_svc_retv_if(sql == NULL, MS_MEDIA_ERR_OUT_OF_MEMORY);
ret = _media_svc_sql_query(db_handle, sql, uid);
sqlite3_free(sql);
if (ret != SQLITE_OK) {
media_svc_error("It failed to create db table (%d)", ret);
- return MEDIA_INFO_ERROR_DATABASE_TABLE_OPEN;
+ return MS_MEDIA_ERR_DB_INTERNAL;
}
/*Create tag_map table*/
);",
MEDIA_SVC_DB_TABLE_TAG_MAP);
- media_svc_retv_if(sql == NULL, MEDIA_INFO_ERROR_OUT_OF_MEMORY);
+ media_svc_retv_if(sql == NULL, MS_MEDIA_ERR_OUT_OF_MEMORY);
ret = _media_svc_sql_query(db_handle, sql, uid);
sqlite3_free(sql);
if (ret != SQLITE_OK) {
media_svc_error("It failed to create db table (%d)", ret);
- return MEDIA_INFO_ERROR_DATABASE_TABLE_OPEN;
+ return MS_MEDIA_ERR_DB_INTERNAL;
}
/*Create tag_view*/
NOT IN (select tag_id from tag_map); \
");
- media_svc_retv_if(sql == NULL, MEDIA_INFO_ERROR_OUT_OF_MEMORY);
+ media_svc_retv_if(sql == NULL, MS_MEDIA_ERR_OUT_OF_MEMORY);
ret = _media_svc_sql_query(db_handle, sql, uid);
sqlite3_free(sql);
- media_svc_retv_if(ret != MEDIA_INFO_ERROR_NONE, ret);
+ media_svc_retv_if(ret != MS_MEDIA_ERR_NONE, ret);
/* Create Trigger to remove media from tag_map when media remove from media_table*/
sql = sqlite3_mprintf("CREATE TRIGGER IF NOT EXISTS tag_map_cleanup \
DELETE ON %s BEGIN DELETE FROM %s WHERE media_uuid=old.media_uuid;END;",
MEDIA_SVC_DB_TABLE_MEDIA, MEDIA_SVC_DB_TABLE_TAG_MAP);
- media_svc_retv_if(sql == NULL, MEDIA_INFO_ERROR_OUT_OF_MEMORY);
+ media_svc_retv_if(sql == NULL, MS_MEDIA_ERR_OUT_OF_MEMORY);
ret = _media_svc_sql_query(db_handle, sql, uid);
sqlite3_free(sql);
if (ret != SQLITE_OK) {
media_svc_error("It failed to create trigger (%d)", ret);
- return MEDIA_INFO_ERROR_DATABASE_TABLE_OPEN;
+ return MS_MEDIA_ERR_DB_INTERNAL;
}
/* Create Trigger to remove media from tag_map when tag removed from tag table*/
DELETE ON %s BEGIN DELETE FROM %s WHERE tag_id=old.tag_id;END;",
MEDIA_SVC_DB_TABLE_TAG, MEDIA_SVC_DB_TABLE_TAG_MAP);
- media_svc_retv_if(sql == NULL, MEDIA_INFO_ERROR_OUT_OF_MEMORY);
+ media_svc_retv_if(sql == NULL, MS_MEDIA_ERR_OUT_OF_MEMORY);
ret = _media_svc_sql_query(db_handle, sql, uid);
sqlite3_free(sql);
if (ret != SQLITE_OK) {
media_svc_error("It failed to create trigger (%d)", ret);
- return MEDIA_INFO_ERROR_DATABASE_TABLE_OPEN;
+ return MS_MEDIA_ERR_DB_INTERNAL;
}
- return MEDIA_INFO_ERROR_NONE;
+ return MS_MEDIA_ERR_NONE;
}
int _media_svc_create_bookmark_table(sqlite3 *db_handle, uid_t uid)
{
- int ret = MEDIA_INFO_ERROR_NONE;
+ int ret = MS_MEDIA_ERR_NONE;
char * sql = NULL;
media_svc_debug_func();
);",
MEDIA_SVC_DB_TABLE_BOOKMARK);
- media_svc_retv_if(sql == NULL, MEDIA_INFO_ERROR_OUT_OF_MEMORY);
+ media_svc_retv_if(sql == NULL, MS_MEDIA_ERR_OUT_OF_MEMORY);
ret = _media_svc_sql_query(db_handle, sql, uid);
sqlite3_free(sql);
if (ret != SQLITE_OK) {
media_svc_error("It failed to create db table (%d)", ret);
- return MEDIA_INFO_ERROR_DATABASE_TABLE_OPEN;
+ return MS_MEDIA_ERR_DB_INTERNAL;
}
/* Create Trigger to remove media from tag_map when media remove from media_table*/
DELETE ON %s BEGIN DELETE FROM %s WHERE media_uuid=old.media_uuid;END;",
MEDIA_SVC_DB_TABLE_MEDIA, MEDIA_SVC_DB_TABLE_BOOKMARK);
- media_svc_retv_if(sql == NULL, MEDIA_INFO_ERROR_OUT_OF_MEMORY);
+ media_svc_retv_if(sql == NULL, MS_MEDIA_ERR_OUT_OF_MEMORY);
ret = _media_svc_sql_query(db_handle, sql, uid);
sqlite3_free(sql);
if (ret != SQLITE_OK) {
media_svc_error("It failed to create trigger (%d)", ret);
- return MEDIA_INFO_ERROR_DATABASE_TABLE_OPEN;
+ return MS_MEDIA_ERR_DB_INTERNAL;
}
- return MEDIA_INFO_ERROR_NONE;
+ return MS_MEDIA_ERR_NONE;
}
int _media_svc_create_custom_table(sqlite3 *db_handle, uid_t uid)
{
- int ret = MEDIA_INFO_ERROR_NONE;
+ int ret = MS_MEDIA_ERR_NONE;
char * sql = NULL;
media_svc_debug_func();
);",
MEDIA_SVC_DB_TABLE_CUSTOM);
- media_svc_retv_if(sql == NULL, MEDIA_INFO_ERROR_OUT_OF_MEMORY);
+ media_svc_retv_if(sql == NULL, MS_MEDIA_ERR_OUT_OF_MEMORY);
ret = _media_svc_sql_query(db_handle, sql, uid);
sqlite3_free(sql);
if (ret != SQLITE_OK) {
media_svc_error("It failed to create db table (%d)", ret);
- return MEDIA_INFO_ERROR_DATABASE_TABLE_OPEN;
+ return MS_MEDIA_ERR_DB_INTERNAL;
}
/* Create Trigger to remove media from tag_map when media remove from media_table*/
DELETE ON %s BEGIN DELETE FROM %s WHERE media_uuid=old.media_uuid;END;",
MEDIA_SVC_DB_TABLE_MEDIA, MEDIA_SVC_DB_TABLE_CUSTOM);
- media_svc_retv_if(sql == NULL, MEDIA_INFO_ERROR_OUT_OF_MEMORY);
+ media_svc_retv_if(sql == NULL, MS_MEDIA_ERR_OUT_OF_MEMORY);
ret = _media_svc_sql_query(db_handle, sql, uid);
sqlite3_free(sql);
if (ret != SQLITE_OK) {
media_svc_error("It failed to create trigger (%d)", ret);
- return MEDIA_INFO_ERROR_DATABASE_TABLE_OPEN;
+ return MS_MEDIA_ERR_DB_INTERNAL;
}
/* Create Index*/
",
MEDIA_SVC_DB_TABLE_CUSTOM);
- media_svc_retv_if(sql == NULL, MEDIA_INFO_ERROR_OUT_OF_MEMORY);
+ media_svc_retv_if(sql == NULL, MS_MEDIA_ERR_OUT_OF_MEMORY);
ret = _media_svc_sql_query(db_handle, sql, uid);
sqlite3_free(sql);
if (ret != SQLITE_OK) {
media_svc_error("It failed to create db table (%d)", ret);
- return MEDIA_INFO_ERROR_DATABASE_TABLE_OPEN;
+ return MS_MEDIA_ERR_DB_INTERNAL;
}
- return MEDIA_INFO_ERROR_NONE;
+ return MS_MEDIA_ERR_NONE;
}
int _media_svc_request_update_db(const char *sql_str, uid_t uid)
int _media_svc_sql_query(sqlite3 *db_handle, const char *sql_str, uid_t uid)
{
- int err = -1;
+ int ret = MS_MEDIA_ERR_NONE;
media_svc_debug("[SQL query] : %s", sql_str);
-#if 1
- //DB will be updated by Media Server.
- err = _media_svc_request_update_db(sql_str, uid);
-
- return _media_svc_error_convert(err);
-#else
- char *zErrMsg = NULL;
- media_svc_retvm_if(sql_str == NULL, MEDIA_INFO_ERROR_INVALID_PARAMETER, "sql_str is NULL");
-
- err = sqlite3_exec(db_handle, sql_str, NULL, NULL, &zErrMsg);
- if (SQLITE_OK != err) {
- media_svc_error("failed to execute [%s], err[%d]", zErrMsg, err);
- } else {
- media_svc_debug("query success");
- }
+ //DB will be updated by Media Server.
+ ret = _media_svc_request_update_db(sql_str, uid);
- if (zErrMsg)
- sqlite3_free (zErrMsg);
- return err;
-#endif
+ return ret;
}
int _media_svc_sql_prepare_to_step(sqlite3 *handle, const char *sql_str, sqlite3_stmt** stmt)
sqlite3_free((char *)sql_str);
if (err != SQLITE_OK) {
- media_svc_error ("prepare error [%s]", sqlite3_errmsg(handle));
- return MEDIA_INFO_ERROR_DATABASE_INTERNAL;
+ media_svc_error ("prepare error %d[%s]", err, sqlite3_errmsg(handle));
+ return MS_MEDIA_ERR_DB_INTERNAL;
}
err = sqlite3_step(*stmt);
if (err != SQLITE_ROW) {
media_svc_error("Item not found. end of row [%s]", sqlite3_errmsg(handle));
SQLITE3_FINALIZE(*stmt);
- return MEDIA_INFO_ERROR_DATABASE_NO_RECORD;
+ return MS_MEDIA_ERR_DB_NO_RECORD;
}
- return MEDIA_INFO_ERROR_NONE;
+ return MS_MEDIA_ERR_NONE;
}
int _media_svc_sql_begin_trans(sqlite3 *handle, uid_t uid)
{
- int err = MEDIA_INFO_ERROR_NONE;
-
- media_svc_debug("========_media_svc_sql_begin_trans");
-#if 1
- //err = _media_svc_request_update_db("BEGIN IMMEDIATE;");
- err = media_db_request_update_db_batch_start("BEGIN IMMEDIATE;", uid);
+ int ret = MS_MEDIA_ERR_NONE;
- return _media_svc_error_convert(err);
-#else
- char *err_msg = NULL;
+ media_svc_error("========_media_svc_sql_begin_trans");
- if (SQLITE_OK != sqlite3_exec(handle, "BEGIN IMMEDIATE;", NULL, NULL, &err_msg)) {
- media_svc_error("Error:failed to begin transaction: error=%s", err_msg);
- sqlite3_free(err_msg);
- return MEDIA_INFO_ERROR_DATABASE_INTERNAL;
- }
+ ret = media_db_request_update_db_batch_start("BEGIN IMMEDIATE;", uid);
- sqlite3_free(err_msg);
- return err;
-#endif
+ return ret;
}
int _media_svc_sql_end_trans(sqlite3 *handle, uid_t uid)
{
- int err = MEDIA_INFO_ERROR_NONE;
-
- media_svc_debug("========_media_svc_sql_end_trans");
-#if 1
- err = media_db_request_update_db_batch_end("COMMIT;", uid);
- //err = _media_svc_request_update_db("COMMIT;");
- return _media_svc_error_convert(err);
-#else
- char *err_msg = NULL;
- if (SQLITE_OK != sqlite3_exec(handle, "COMMIT;", NULL, NULL, &err_msg)) {
- media_svc_error("Error:failed to end transaction: error=%s", err_msg);
- sqlite3_free(err_msg);
- return MEDIA_INFO_ERROR_DATABASE_INTERNAL;
- }
+ int ret = MS_MEDIA_ERR_NONE;
+
+ media_svc_error("========_media_svc_sql_end_trans");
- sqlite3_free(err_msg);
- return err;
-#endif
+ ret = media_db_request_update_db_batch_end("COMMIT;", uid);
+
+ return ret;
}
int _media_svc_sql_rollback_trans(sqlite3 *handle, uid_t uid)
{
- int err = MEDIA_INFO_ERROR_NONE;
-
- media_svc_debug("========_media_svc_sql_rollback_trans");
-#if 1
- err = _media_svc_request_update_db("ROLLBACK;", uid);
- return _media_svc_error_convert(err);
-#else
- char *err_msg = NULL;
- if (SQLITE_OK != sqlite3_exec(handle, "ROLLBACK;", NULL, NULL, &err_msg)) {
- media_svc_error("Error:failed to rollback transaction: error=%s", err_msg);
- sqlite3_free(err_msg);
- return MEDIA_INFO_ERROR_DATABASE_INTERNAL;
- }
+ media_svc_error("========_media_svc_sql_rollback_trans");
+
+ return _media_svc_request_update_db("ROLLBACK;", uid);
- sqlite3_free(err_msg);
- return err;
-#endif
}
int _media_svc_sql_query_list(sqlite3 *handle, GList **query_list, uid_t uid)
{
- int i = 0;
+ int ret = MS_MEDIA_ERR_NONE;
+ int idx = 0;
int length = g_list_length(*query_list);
- int err = -1;
char *sql = NULL;
media_svc_debug("query list length : [%d]", length);
- for (i = 0; i < length; i++) {
- sql = (char*)g_list_nth_data(*query_list, i);
+ for (idx = 0; idx < length; idx++) {
+ sql = (char*)g_list_nth_data(*query_list, idx);
if(sql != NULL) {
- //err = _media_svc_sql_query(handle, sql);
- err = media_db_request_update_db_batch(sql, uid);
- //if (err != SQLITE_OK) {
- // media_svc_error("A query failed in batch");
- if (err < MS_MEDIA_ERR_NONE) {
- media_svc_error("media_db_request_update_db_batch failed : %d", err);
+ //ret = _media_svc_sql_query(handle, sql);
+ ret = media_db_request_update_db_batch(sql, uid);
+ if (ret != MS_MEDIA_ERR_NONE) {
+ media_svc_error("media_db_request_update_db_batch failed : %d", ret);
}
sqlite3_free(sql);
sql = NULL;
_media_svc_sql_query_release(query_list);
- return MEDIA_INFO_ERROR_NONE;
+ return MS_MEDIA_ERR_NONE;
}
(double)(time.tv_sec * 1000000 + time.tv_usec -
g_time_usec) / CLOCKS_PER_SEC;
- media_svc_debug("time [%s] : %f \n", time_string, totaltime);
+ media_svc_debug("time [%s] : %f", time_string, totaltime);
#endif
}
totaltime = (double)(end - start) / CLOCKS_PER_SEC;
- media_svc_debug("time [%s: %s] : %f \n", func_name, time_string,
+ media_svc_debug("time [%s: %s] : %f", func_name, time_string,
totaltime);
#endif
}
*
*/
-#include "media-svc-error.h"
+#include "media-util-err.h"
+#include "media-svc-debug.h"
#include "media-svc-localize-utils.h"
int _media_svc_check_utf8(char c)
else if ((c & (char)0xfe) == (char)0xfc)
return 6;
else
- return MEDIA_INFO_ERROR_INVALID_PARAMETER;
+ return MS_MEDIA_ERR_INVALID_PARAMETER;
}
#include <stdbool.h>
#include <string.h>
-#include "media-svc-error.h"
+#include "media-util-err.h"
#include "media-svc-types.h"
#include "media-svc-debug.h"
#include "media-svc-localize_ch.h"
int count=0;
offset = src - CHINESE_UNICODE_START;
- media_svc_retvm_if(offset < 0 || offset >= CHINESE_COUNT , MEDIA_INFO_ERROR_INVALID_PARAMETER, "src is invalid");
+ media_svc_retvm_if(offset < 0 || offset >= CHINESE_COUNT , MS_MEDIA_ERR_INVALID_PARAMETER, "src is invalid");
len = strlen(pinyin_spell_table[offset]);
*size = 0;
- media_svc_retvm_if(src==NULL, MEDIA_INFO_ERROR_INVALID_PARAMETER, "src is NULL");
- media_svc_retvm_if(!*src, MEDIA_INFO_ERROR_INVALID_PARAMETER, "*src is NULL");
+ media_svc_retvm_if(src==NULL, MS_MEDIA_ERR_INVALID_PARAMETER, "src is NULL");
+ media_svc_retvm_if(!*src, MS_MEDIA_ERR_INVALID_PARAMETER, "*src is NULL");
u_strFromUTF8(temp_result, array_sizeof(temp_result), NULL, src, -1, &status);
if (U_FAILURE(status)){
media_svc_error("u_strFromUTF8 Failed(%s)", u_errorName(status));
- return MEDIA_INFO_ERROR_INTERNAL;
+ return MS_MEDIA_ERR_INTERNAL;
}
len = u_strlen(temp_result);
if (__media_svc_is_chinese(&temp_result[count])) {
ret = __media_svc_get_pinyinspell(temp_result[count], spell[count]);
- media_svc_retvm_if(ret < MEDIA_INFO_ERROR_NONE, MEDIA_INFO_ERROR_INTERNAL, "__media_svc_get_pinyinspell() Failed(%d)", ret);
+ media_svc_retvm_if(ret < MS_MEDIA_ERR_NONE, MS_MEDIA_ERR_INTERNAL, "__media_svc_get_pinyinspell() Failed(%d)", ret);
if (multi_pinyin_count >= MEDIA_SVC_CHINESE_MULTIPLE_PINYIN_MAX_LEN)
ret = 1;
temp[0] = temp_result[count];
temp[1] = 0x00;
u_strToUTF8(spell[count][0], 10, &temp_size, temp, -1, &status);
- media_svc_retvm_if(U_FAILURE(status), MEDIA_INFO_ERROR_INTERNAL, "u_strToUTF8() Failed(%s)", u_errorName(status));
+ media_svc_retvm_if(U_FAILURE(status), MS_MEDIA_ERR_INTERNAL, "u_strToUTF8() Failed(%s)", u_errorName(status));
spell[count][0][temp_size]='\0';
pinyin_spell_count[count] = 1;
}
*size = total_count;
temp_name = calloc(total_count, sizeof(pinyin_name_s));
- media_svc_retvm_if(temp_name == NULL, MEDIA_INFO_ERROR_OUT_OF_MEMORY,"calloc Failed()");
+ media_svc_retvm_if(temp_name == NULL, MS_MEDIA_ERR_OUT_OF_MEMORY,"calloc Failed()");
int repeat = 1;
int name_len[total_count];
*name = temp_name;
- return MEDIA_INFO_ERROR_NONE;
+ return MS_MEDIA_ERR_NONE;
}
void _media_svc_pinyin_free(pinyin_name_s *pinyinname, int size)
*/
#include <glib/gstdio.h>
+#include <media-util-err.h>
#include "media-svc-media-folder.h"
-#include "media-svc-error.h"
#include "media-svc-debug.h"
#include "media-svc-env.h"
#include "media-svc-util.h"
int _media_svc_get_folder_id_by_foldername(sqlite3 *handle, const char *folder_name, char *folder_id)
{
- int ret = MEDIA_INFO_ERROR_NONE;
+ int ret = MS_MEDIA_ERR_NONE;
sqlite3_stmt *sql_stmt = NULL;
char *sql = sqlite3_mprintf("SELECT folder_uuid FROM %s WHERE path = '%q';", MEDIA_SVC_DB_TABLE_FOLDER, folder_name);
ret = _media_svc_sql_prepare_to_step(handle, sql, &sql_stmt);
- if (ret != MEDIA_INFO_ERROR_NONE) {
- if(ret == MEDIA_INFO_ERROR_DATABASE_NO_RECORD) {
+ if (ret != MS_MEDIA_ERR_NONE) {
+ if(ret == MS_MEDIA_ERR_DB_NO_RECORD) {
media_svc_debug("there is no folder.");
}
else {
int _media_svc_append_folder(sqlite3 *handle, media_svc_storage_type_e storage_type,
const char *folder_id, const char *path_name, const char *folder_name, int modified_date, uid_t uid)
{
- int err = -1;
+ int ret = MS_MEDIA_ERR_NONE;
/*Update Pinyin If Support Pinyin*/
char *folder_name_pinyin = NULL;
char *sql = sqlite3_mprintf("INSERT INTO %s (folder_uuid, path, name, storage_type, modified_time, name_pinyin) values (%Q, %Q, %Q, '%d', '%d', %Q); ",
MEDIA_SVC_DB_TABLE_FOLDER, folder_id, path_name, folder_name, storage_type, modified_date, folder_name_pinyin);
- err = _media_svc_sql_query(handle, sql, uid);
+ ret = _media_svc_sql_query(handle, sql, uid);
sqlite3_free(sql);
- if (err != SQLITE_OK) {
+ if (ret != SQLITE_OK) {
media_svc_error("failed to insert folder");
- return MEDIA_INFO_ERROR_DATABASE_INTERNAL;
+ return MS_MEDIA_ERR_DB_INTERNAL;
}
SAFE_FREE(folder_name_pinyin);
- return MEDIA_INFO_ERROR_NONE;
+ return ret;
}
int _media_svc_update_folder_modified_time_by_folder_uuid(sqlite3 *handle, const char *folder_uuid, const char *folder_path, bool stack_query, uid_t uid)
{
- int err = -1;
+ int ret = MS_MEDIA_ERR_NONE;
int modified_time = 0;
modified_time = _media_svc_get_file_time(folder_path);
char *sql = sqlite3_mprintf("UPDATE %s SET modified_time=%d WHERE folder_uuid=%Q;", MEDIA_SVC_DB_TABLE_FOLDER, modified_time, folder_uuid);
if(!stack_query) {
- err = _media_svc_sql_query(handle, sql, uid);
+ ret = _media_svc_sql_query(handle, sql, uid);
sqlite3_free(sql);
- if (err != SQLITE_OK) {
+ if (ret != SQLITE_OK) {
media_svc_error("failed to update folder");
- return MEDIA_INFO_ERROR_DATABASE_INTERNAL;
+ return MS_MEDIA_ERR_DB_INTERNAL;
}
} else {
_media_svc_sql_query_add(&g_media_svc_move_item_query_list, &sql);
}
- return MEDIA_INFO_ERROR_NONE;
+ return ret;
}
int _media_svc_get_and_append_folder_id_by_path(sqlite3 *handle, const char *path, media_svc_storage_type_e storage_type, char *folder_id, uid_t uid)
{
char *path_name = NULL;
- int ret = MEDIA_INFO_ERROR_NONE;
+ int ret = MS_MEDIA_ERR_NONE;
path_name = g_path_get_dirname(path);
ret = _media_svc_get_folder_id_by_foldername(handle, path_name, folder_id);
- if(ret == MEDIA_INFO_ERROR_DATABASE_NO_RECORD) {
+ if(ret == MS_MEDIA_ERR_DB_NO_RECORD) {
char *folder_name = NULL;
int folder_modified_date = 0;
char *folder_uuid = _media_info_generate_uuid();
if(folder_uuid == NULL ) {
media_svc_error("Invalid UUID");
SAFE_FREE(path_name);
- return MEDIA_INFO_ERROR_INTERNAL;
+ return MS_MEDIA_ERR_INTERNAL;
}
folder_name = g_path_get_basename(path_name);
int _media_svc_update_folder_table(sqlite3 *handle, uid_t uid)
{
- int err = -1;
+ int ret = MS_MEDIA_ERR_NONE;
char *sql = NULL;
sql = sqlite3_mprintf("DELETE FROM %s WHERE folder_uuid IN (SELECT folder_uuid FROM %s WHERE folder_uuid NOT IN (SELECT folder_uuid FROM %s))",
MEDIA_SVC_DB_TABLE_FOLDER, MEDIA_SVC_DB_TABLE_FOLDER, MEDIA_SVC_DB_TABLE_MEDIA);
- err = _media_svc_sql_query(handle, sql, uid);
+ ret = _media_svc_sql_query(handle, sql, uid);
sqlite3_free(sql);
- if (err != SQLITE_OK) {
+ if (ret != SQLITE_OK) {
media_svc_error("failed to delete folder item");
- return MEDIA_INFO_ERROR_DATABASE_INTERNAL;
+ return MS_MEDIA_ERR_DB_INTERNAL;
}
- return MEDIA_INFO_ERROR_NONE;
+ return MS_MEDIA_ERR_NONE;
}
#include <string.h>
#include <grp.h>
#include <pwd.h>
+#include <media-util-err.h>
#include "media-svc-media.h"
#include "media-svc-media-folder.h"
-#include "media-svc-error.h"
#include "media-svc-debug.h"
#include "media-svc-util.h"
#include "media-svc-db-utils.h"
static int __media_svc_count_invalid_records_with_thumbnail(sqlite3 *handle, media_svc_storage_type_e storage_type, int *count)
{
- int ret = MEDIA_INFO_ERROR_NONE;
+ int ret = MS_MEDIA_ERR_NONE;
sqlite3_stmt *sql_stmt = NULL;
char *sql = sqlite3_mprintf("SELECT count(*) FROM %s WHERE validity=0 AND storage_type=%d AND thumbnail_path IS NOT NULL",
MEDIA_SVC_DB_TABLE_MEDIA, storage_type);
ret = _media_svc_sql_prepare_to_step(handle, sql, &sql_stmt);
- if (ret != MEDIA_INFO_ERROR_NONE) {
+ if (ret != MS_MEDIA_ERR_NONE) {
media_svc_error("error when __media_svc_count_invalid_records_with_thumbnail. err = [%d]", ret);
return ret;
}
SQLITE3_FINALIZE(sql_stmt);
- return MEDIA_INFO_ERROR_NONE;
+ return MS_MEDIA_ERR_NONE;
}
static int __media_svc_get_invalid_records_with_thumbnail(sqlite3 *handle, media_svc_storage_type_e storage_type,
int count, media_svc_thumbnailpath_s * thumb_path)
{
- int err = -1;
- int idx = 0;
+ int ret = MS_MEDIA_ERR_NONE;
sqlite3_stmt *sql_stmt = NULL;
+ int idx = 0;
char *sql = sqlite3_mprintf("SELECT thumbnail_path from (select thumbnail_path, validity from %s WHERE storage_type=%d AND thumbnail_path IS NOT NULL GROUP BY thumbnail_path HAVING count() = 1) WHERE validity=0",
MEDIA_SVC_DB_TABLE_MEDIA, storage_type);
media_svc_debug("[SQL query] : %s", sql);
- err = sqlite3_prepare_v2(handle, sql, -1, &sql_stmt, NULL);
+ ret = sqlite3_prepare_v2(handle, sql, -1, &sql_stmt, NULL);
sqlite3_free(sql);
- if (err != SQLITE_OK) {
+ if (ret != SQLITE_OK) {
media_svc_error("prepare error [%s]", sqlite3_errmsg(handle));
- return MEDIA_INFO_ERROR_DATABASE_INTERNAL;
+ return MS_MEDIA_ERR_DB_INTERNAL;
}
while (sqlite3_step(sql_stmt) == SQLITE_ROW) {
SQLITE3_FINALIZE(sql_stmt);
- return MEDIA_INFO_ERROR_NONE;
+ return MS_MEDIA_ERR_NONE;
}
static int __media_svc_count_invalid_folder_records_with_thumbnail(sqlite3 *handle, const char *folder_path, int *count)
{
- int ret = MEDIA_INFO_ERROR_NONE;
+ int ret = MS_MEDIA_ERR_NONE;
sqlite3_stmt *sql_stmt = NULL;
char *sql = sqlite3_mprintf("SELECT count(*) FROM %s WHERE validity=0 AND path LIKE '%q/%%' AND thumbnail_path IS NOT NULL",
MEDIA_SVC_DB_TABLE_MEDIA, folder_path);
ret = _media_svc_sql_prepare_to_step(handle, sql, &sql_stmt);
- if (ret != MEDIA_INFO_ERROR_NONE) {
+ if (ret != MS_MEDIA_ERR_NONE) {
media_svc_error("error when __media_svc_count_invalid_folder_records_with_thumbnail. err = [%d]", ret);
return ret;
}
SQLITE3_FINALIZE(sql_stmt);
- return MEDIA_INFO_ERROR_NONE;
+ return MS_MEDIA_ERR_NONE;
}
static int __media_svc_get_invalid_folder_records_with_thumbnail(sqlite3 *handle, const char *folder_path,
int count, media_svc_thumbnailpath_s * thumb_path)
{
- int err = -1;
- int idx = 0;
+ int ret = MS_MEDIA_ERR_NONE;
sqlite3_stmt *sql_stmt = NULL;
+ int idx = 0;
char *sql = sqlite3_mprintf("SELECT thumbnail_path from (select thumbnail_path, validity from %s WHERE path LIKE '%q/%%' AND thumbnail_path IS NOT NULL GROUP BY thumbnail_path HAVING count() = 1) WHERE validity=0",
MEDIA_SVC_DB_TABLE_MEDIA, folder_path);
media_svc_debug("[SQL query] : %s", sql);
- err = sqlite3_prepare_v2(handle, sql, -1, &sql_stmt, NULL);
+ ret = sqlite3_prepare_v2(handle, sql, -1, &sql_stmt, NULL);
sqlite3_free(sql);
- if (err != SQLITE_OK) {
+ if (ret != MS_MEDIA_ERR_NONE) {
media_svc_error("prepare error [%s]", sqlite3_errmsg(handle));
- return MEDIA_INFO_ERROR_DATABASE_INTERNAL;
+ return ret;
}
while (sqlite3_step(sql_stmt) == SQLITE_ROW) {
SQLITE3_FINALIZE(sql_stmt);
- return MEDIA_INFO_ERROR_NONE;
+ return MS_MEDIA_ERR_NONE;
}
int _media_svc_count_record_with_path(sqlite3 *handle, const char *path, int *count)
{
- int ret = MEDIA_INFO_ERROR_NONE;
+ int ret = MS_MEDIA_ERR_NONE;
sqlite3_stmt *sql_stmt = NULL;
char *sql = sqlite3_mprintf("SELECT count(*) FROM %s WHERE path='%q'", MEDIA_SVC_DB_TABLE_MEDIA, path);
ret = _media_svc_sql_prepare_to_step(handle, sql, &sql_stmt);
- media_svc_retv_if(ret != MEDIA_INFO_ERROR_NONE, ret);
+ media_svc_retv_if(ret != MS_MEDIA_ERR_NONE, ret);
*count = sqlite3_column_int(sql_stmt, 0);
SQLITE3_FINALIZE(sql_stmt);
- return MEDIA_INFO_ERROR_NONE;
+ return MS_MEDIA_ERR_NONE;
}
char* _media_svc_get_thumb_default_path(uid_t uid)
int _media_svc_insert_item_with_data(sqlite3 *handle, media_svc_content_info_s *content_info, int is_burst, bool stack_query, uid_t uid)
{
media_svc_debug("");
- int err = -1;
+ int ret = MS_MEDIA_ERR_NONE;
char *burst_id = NULL;
char * db_fields = "media_uuid, path, file_name, media_type, mime_type, size, added_time, modified_time, folder_uuid, \
if (is_burst) {
int burst_id_int = 0;
- err = _media_svc_get_burst_id(handle, &burst_id_int);
- if (err < 0) {
+ ret = _media_svc_get_burst_id(handle, &burst_id_int);
+ if (ret != MS_MEDIA_ERR_NONE) {
burst_id = NULL;
}
int width = 0;
int height = 0;
- err = thumbnail_request_from_db_with_size(content_info->path, thumb_path, sizeof(thumb_path), &width, &height, uid);
- if (err < 0) {
- media_svc_error("thumbnail_request_from_db failed: %d", err);
+ ret = thumbnail_request_from_db_with_size(content_info->path, thumb_path, sizeof(thumb_path), &width, &height, uid);
+ if (ret != MS_MEDIA_ERR_NONE) {
+ media_svc_error("thumbnail_request_from_db failed: %d", ret);
} else {
media_svc_debug("thumbnail_request_from_db success: %s", thumb_path);
- err = __media_svc_malloc_and_strncpy(&(content_info->thumbnail_path), thumb_path);
- if (err < 0) {
+ ret = __media_svc_malloc_and_strncpy(&(content_info->thumbnail_path), thumb_path);
+ if (ret != MS_MEDIA_ERR_NONE) {
content_info->thumbnail_path = NULL;
}
}
burst_id = NULL;
if(!stack_query) {
- err = _media_svc_sql_query(handle, sql, uid);
+ ret = _media_svc_sql_query(handle, sql, uid);
sqlite3_free(sql);
- if (err != SQLITE_OK) {
+ if (ret != MS_MEDIA_ERR_NONE) {
media_svc_error("failed to insert item");
-
- return MEDIA_INFO_ERROR_DATABASE_INTERNAL;
+ return ret;
}
} else {
media_svc_debug("query : %s", sql);
_media_svc_sql_query_add(&g_media_svc_insert_item_query_list, &sql);
}
- return MEDIA_INFO_ERROR_NONE;
+ return MS_MEDIA_ERR_NONE;
}
int _media_svc_update_item_with_data(sqlite3 *handle, media_svc_content_info_s *content_info, uid_t uid)
{
- int err = -1;
+ int ret = MS_MEDIA_ERR_NONE;
/* 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 */
content_info->path
);
- err = _media_svc_sql_query(handle, sql, uid);
+ ret = _media_svc_sql_query(handle, sql, uid);
sqlite3_free(sql);
- if (err != SQLITE_OK) {
- media_svc_error("failed to update item");
-
- return MEDIA_INFO_ERROR_DATABASE_INTERNAL;
- }
- return MEDIA_INFO_ERROR_NONE;
+ return ret;
}
int _media_svc_get_thumbnail_path_by_path(sqlite3 *handle, const char *path, char *thumbnail_path)
{
- int ret = MEDIA_INFO_ERROR_NONE;
+ int ret = MS_MEDIA_ERR_NONE;
sqlite3_stmt *sql_stmt = NULL;
char *sql = sqlite3_mprintf("SELECT thumbnail_path FROM %s WHERE path='%q'", MEDIA_SVC_DB_TABLE_MEDIA, path);
ret = _media_svc_sql_prepare_to_step(handle, sql, &sql_stmt);
- if (ret != MEDIA_INFO_ERROR_NONE) {
- if(ret == MEDIA_INFO_ERROR_DATABASE_NO_RECORD) {
+ if (ret != MS_MEDIA_ERR_NONE) {
+ if(ret == MS_MEDIA_ERR_DB_NO_RECORD) {
media_svc_debug("there is no thumbnail.");
}
else {
SQLITE3_FINALIZE(sql_stmt);
- return MEDIA_INFO_ERROR_NONE;
+ return MS_MEDIA_ERR_NONE;
}
int _media_svc_get_media_type_by_path(sqlite3 *handle, const char *path, int *media_type)
{
- int ret = MEDIA_INFO_ERROR_NONE;
+ int ret = MS_MEDIA_ERR_NONE;
sqlite3_stmt *sql_stmt = NULL;
char *sql = sqlite3_mprintf("SELECT media_type FROM %s WHERE path='%q'", MEDIA_SVC_DB_TABLE_MEDIA, path);
ret = _media_svc_sql_prepare_to_step(handle, sql, &sql_stmt);
- if (ret != MEDIA_INFO_ERROR_NONE) {
+ if (ret != MS_MEDIA_ERR_NONE) {
media_svc_error("error when _media_svc_get_media_type_by_path. err = [%d]", ret);
return ret;
}
SQLITE3_FINALIZE(sql_stmt);
- return MEDIA_INFO_ERROR_NONE;
+ return MS_MEDIA_ERR_NONE;
}
int _media_svc_delete_item_by_path(sqlite3 *handle, const char *path, uid_t uid)
{
- int err = -1;
+ int ret = MS_MEDIA_ERR_NONE;
char *sql = sqlite3_mprintf("DELETE FROM %s WHERE validity=1 AND path='%q'", MEDIA_SVC_DB_TABLE_MEDIA, path);
- err = _media_svc_sql_query(handle, sql, uid);
+ ret = _media_svc_sql_query(handle, sql, uid);
sqlite3_free(sql);
- if (err != SQLITE_OK) {
- media_svc_error("It failed to delete item (%d)", err);
- return MEDIA_INFO_ERROR_DATABASE_INTERNAL;
+ if (ret != MS_MEDIA_ERR_NONE) {
+ media_svc_error("failed to delete item");
+ return ret;
}
- return MEDIA_INFO_ERROR_NONE;
+ return ret;
}
int _media_svc_truncate_table(sqlite3 *handle, media_svc_storage_type_e storage_type, uid_t uid)
{
- int err = -1;
+ int ret = MS_MEDIA_ERR_NONE;
char *sql = sqlite3_mprintf("DELETE FROM %s WHERE storage_type=%d", MEDIA_SVC_DB_TABLE_MEDIA, storage_type);
- err = _media_svc_sql_query(handle, sql, uid);
+ ret = _media_svc_sql_query(handle, sql, uid);
sqlite3_free(sql);
- if (err != SQLITE_OK) {
- media_svc_error("It failed to truncate table (%d)", err);
- return MEDIA_INFO_ERROR_DATABASE_INTERNAL;
- }
-
- return MEDIA_INFO_ERROR_NONE;
+ return ret;
}
int _media_svc_delete_invalid_items(sqlite3 *handle, media_svc_storage_type_e storage_type, uid_t uid)
{
int idx = 0;
media_svc_thumbnailpath_s *thumbpath_record = NULL;
- int err = -1;
int invalid_count = 0;
- int ret = MEDIA_INFO_ERROR_NONE;
+ int ret = MS_MEDIA_ERR_NONE;
ret = __media_svc_count_invalid_records_with_thumbnail(handle, storage_type, &invalid_count);
- media_svc_retv_if(ret != MEDIA_INFO_ERROR_NONE, ret);
+ media_svc_retv_if(ret != MS_MEDIA_ERR_NONE, ret);
media_svc_debug("invalid count: %d\n", invalid_count);
thumbpath_record = (media_svc_thumbnailpath_s *)calloc( invalid_count, sizeof(media_svc_thumbnailpath_s));
if (thumbpath_record == NULL) {
media_svc_error("fail to memory allocation");
- return MEDIA_INFO_ERROR_OUT_OF_MEMORY;
+ return MS_MEDIA_ERR_OUT_OF_MEMORY;
}
ret = __media_svc_get_invalid_records_with_thumbnail(handle, storage_type, invalid_count, thumbpath_record);
- if (ret != MEDIA_INFO_ERROR_NONE) {
+ if (ret != MS_MEDIA_ERR_NONE) {
media_svc_error("error when get thumbnail record");
SAFE_FREE(thumbpath_record);
return ret;
}
char *sql = sqlite3_mprintf("DELETE FROM %s WHERE validity = 0 AND storage_type=%d", MEDIA_SVC_DB_TABLE_MEDIA, storage_type);
- err = _media_svc_sql_query(handle, sql, uid);
+ ret = _media_svc_sql_query(handle, sql, uid);
sqlite3_free(sql);
- if (err != SQLITE_OK) {
- media_svc_error("To delete invalid items is failed(%d)", err);
+ if(ret != MS_MEDIA_ERR_NONE) {
SAFE_FREE(thumbpath_record);
- return MEDIA_INFO_ERROR_DATABASE_INTERNAL;
+ return ret;
}
/*Delete thumbnails*/
if ((strlen(thumbpath_record[idx].thumbnail_path) > 0) && (strncmp(thumbpath_record[idx].thumbnail_path, _media_svc_get_thumb_default_path(uid), sizeof(_media_svc_get_thumb_default_path(uid))) != 0)) {
if (_media_svc_remove_file(thumbpath_record[idx].thumbnail_path) == FALSE) {
media_svc_error("fail to remove thumbnail file.");
- //SAFE_FREE(thumbpath_record);
- //return MEDIA_INFO_ERROR_INTERNAL;
}
}
}
SAFE_FREE(thumbpath_record);
- return MEDIA_INFO_ERROR_NONE;
+ return MS_MEDIA_ERR_NONE;
}
int _media_svc_delete_invalid_folder_items(sqlite3 *handle, const char *folder_path, uid_t uid)
{
int idx = 0;
media_svc_thumbnailpath_s *thumbpath_record = NULL;
- int err = -1;
int invalid_count = 0;
- int ret = MEDIA_INFO_ERROR_NONE;
+ int ret = MS_MEDIA_ERR_NONE;
ret = __media_svc_count_invalid_folder_records_with_thumbnail(handle, folder_path, &invalid_count);
- media_svc_retv_if(ret != MEDIA_INFO_ERROR_NONE, ret);
+ media_svc_retv_if(ret != MS_MEDIA_ERR_NONE, ret);
- media_svc_debug("invalid count: %d\n", invalid_count);
+ media_svc_debug("invalid count: %d", invalid_count);
if (invalid_count > 0) {
thumbpath_record = (media_svc_thumbnailpath_s *)calloc( invalid_count, sizeof(media_svc_thumbnailpath_s));
if (thumbpath_record == NULL) {
media_svc_error("fail to memory allocation");
- return MEDIA_INFO_ERROR_OUT_OF_MEMORY;
+ return MS_MEDIA_ERR_OUT_OF_MEMORY;
}
ret = __media_svc_get_invalid_folder_records_with_thumbnail(handle, folder_path, invalid_count, thumbpath_record);
- if (ret != MEDIA_INFO_ERROR_NONE) {
+ if (ret != MS_MEDIA_ERR_NONE) {
media_svc_error("error when get thumbnail record");
SAFE_FREE(thumbpath_record);
return ret;
}
char *sql = sqlite3_mprintf("DELETE FROM %s WHERE validity = 0 AND path LIKE '%q/%%'", MEDIA_SVC_DB_TABLE_MEDIA, folder_path);
- err = _media_svc_sql_query(handle, sql, uid);
+ ret = _media_svc_sql_query(handle, sql, uid);
sqlite3_free(sql);
- if (err != SQLITE_OK) {
- media_svc_error("To delete invalid items is failed(%d)", err);
+ if(ret != MS_MEDIA_ERR_NONE) {
SAFE_FREE(thumbpath_record);
- return MEDIA_INFO_ERROR_DATABASE_INTERNAL;
+ return ret;
}
/*Delete thumbnails*/
if ((strlen(thumbpath_record[idx].thumbnail_path) > 0) && (strncmp(thumbpath_record[idx].thumbnail_path, _media_svc_get_thumb_default_path(uid), sizeof(_media_svc_get_thumb_default_path(uid))) != 0)) {
if (_media_svc_remove_file(thumbpath_record[idx].thumbnail_path) == FALSE) {
media_svc_error("fail to remove thumbnail file [%s].", thumbpath_record[idx].thumbnail_path);
- //SAFE_FREE(thumbpath_record);
- //return MEDIA_INFO_ERROR_INTERNAL;
}
}
}
SAFE_FREE(thumbpath_record);
- return MEDIA_INFO_ERROR_NONE;
+ return MS_MEDIA_ERR_NONE;
}
-
int _media_svc_update_item_validity(sqlite3 *handle, const char *path, int validity, bool stack_query, uid_t uid)
{
- int err = -1;
+ int ret = MS_MEDIA_ERR_NONE;
char *sql = sqlite3_mprintf("UPDATE %s SET validity=%d WHERE path= '%q'", MEDIA_SVC_DB_TABLE_MEDIA, validity, path);
if(!stack_query) {
- err = _media_svc_sql_query(handle, sql, uid);
+ ret = _media_svc_sql_query(handle, sql, uid);
sqlite3_free(sql);
- if (err != SQLITE_OK) {
- media_svc_error("To update item as valid is failed(%d)", err);
- return MEDIA_INFO_ERROR_DATABASE_INTERNAL;
- }
} else {
_media_svc_sql_query_add(&g_media_svc_item_validity_query_list, &sql);
}
- return MEDIA_INFO_ERROR_NONE;
+ return ret;
}
int _media_svc_update_thumbnail_path(sqlite3 *handle, const char *path, const char *thumb_path, uid_t uid)
{
- int err = -1;
+ int ret = MS_MEDIA_ERR_NONE;
char *sql = sqlite3_mprintf("UPDATE %s SET thumbnail_path=%Q WHERE path= %Q", MEDIA_SVC_DB_TABLE_MEDIA, thumb_path, path);
- err = _media_svc_sql_query(handle, sql, uid);
+ ret = _media_svc_sql_query(handle, sql, uid);
sqlite3_free(sql);
- if (err != SQLITE_OK) {
- media_svc_error("To update thumb path failed(%d)", err);
- return MEDIA_INFO_ERROR_DATABASE_INTERNAL;
- }
- return MEDIA_INFO_ERROR_NONE;
+ return ret;
}
int _media_svc_update_storage_item_validity(sqlite3 *handle, media_svc_storage_type_e storage_type, int validity, uid_t uid)
{
- int err = -1;
+ int ret = MS_MEDIA_ERR_NONE;
+
char *sql = sqlite3_mprintf("UPDATE %s SET validity=%d WHERE storage_type=%d", MEDIA_SVC_DB_TABLE_MEDIA, validity, storage_type);
- err = _media_svc_sql_query(handle, sql, uid);
+
+ ret = _media_svc_sql_query(handle, sql, uid);
sqlite3_free(sql);
- if (err != SQLITE_OK) {
- media_svc_error("To update item as valid is failed(%d)", err);
- return MEDIA_INFO_ERROR_DATABASE_INTERNAL;
- }
- return MEDIA_INFO_ERROR_NONE;
+ return ret;
}
int _media_svc_update_folder_item_validity(sqlite3 *handle, const char *folder_path, int validity, uid_t uid)
{
- int err = -1;
- int ret = MEDIA_INFO_ERROR_NONE;
+ int ret = MS_MEDIA_ERR_NONE;
char *sql = NULL;
char folder_uuid[MEDIA_SVC_UUID_SIZE + 1] = {0, };
sqlite3_stmt *sql_stmt = NULL;
/*Get folder ID*/
sql = sqlite3_mprintf("SELECT folder_uuid FROM %s WHERE path='%q'", MEDIA_SVC_DB_TABLE_FOLDER, folder_path);
ret = _media_svc_sql_prepare_to_step(handle, sql, &sql_stmt);
- if (ret != MEDIA_INFO_ERROR_NONE) {
+ if (ret != MS_MEDIA_ERR_NONE) {
media_svc_error("error when get folder_id. err = [%d]", ret);
return ret;
}
/*Update folder item validity*/
sql = sqlite3_mprintf("UPDATE %s SET validity=%d WHERE folder_uuid='%q'", MEDIA_SVC_DB_TABLE_MEDIA, validity, folder_uuid);
- err = _media_svc_sql_query(handle, sql, uid);
+ ret = _media_svc_sql_query(handle, sql, uid);
sqlite3_free(sql);
- if (err != SQLITE_OK) {
- media_svc_error("To update folder item as valid is failed(%d)", err);
- return MEDIA_INFO_ERROR_DATABASE_INTERNAL;
- }
- return MEDIA_INFO_ERROR_NONE;
+ return ret;
}
int _media_svc_update_recursive_folder_item_validity(sqlite3 *handle, const char *folder_path, int validity, uid_t uid)
{
- int err = -1;
+ int ret = MS_MEDIA_ERR_NONE;
/*Update folder item validity*/
char *sql = sqlite3_mprintf("UPDATE %s SET validity=%d WHERE path LIKE '%q/%%'", MEDIA_SVC_DB_TABLE_MEDIA, validity, folder_path);
- err = _media_svc_sql_query(handle, sql, uid);
+ ret = _media_svc_sql_query(handle, sql, uid);
sqlite3_free(sql);
- if (err != SQLITE_OK) {
- media_svc_error("To update recursive folder item validity is failed(%d)", err);
- return MEDIA_INFO_ERROR_DATABASE_INTERNAL;
- }
- return MEDIA_INFO_ERROR_NONE;
+ return ret;
}
int _media_svc_update_item_by_path(sqlite3 *handle, const char *src_path, media_svc_storage_type_e dest_storage, const char *dest_path,
/* update path, filename, modified_time, folder_uuid, thumbnail_path, */
/* played_count, last_played_time, last_played_position, favourite, storaget_type*/
- int err = -1;
+ int ret = MS_MEDIA_ERR_NONE;
char *sql = NULL;
if(thumb_path != NULL) {
}
if(!stack_query) {
- err = _media_svc_sql_query(handle, sql, uid);
+ ret = _media_svc_sql_query(handle, sql, uid);
sqlite3_free(sql);
- if (err != SQLITE_OK) {
- media_svc_error("It failed to update metadata (%d)", err);
- return MEDIA_INFO_ERROR_DATABASE_INTERNAL;
- }
} else {
_media_svc_sql_query_add(&g_media_svc_move_item_query_list, &sql);
}
- return MEDIA_INFO_ERROR_NONE;
+ return ret;
}
int _media_svc_list_query_do(sqlite3 *handle, media_svc_query_type_e query_type, uid_t uid)
{
- int ret = MEDIA_INFO_ERROR_NONE;
+ int ret = MS_MEDIA_ERR_NONE;
ret = _media_svc_sql_begin_trans(handle, uid);
- media_svc_retv_if(ret != MEDIA_INFO_ERROR_NONE, ret);
+ media_svc_retv_if(ret != MS_MEDIA_ERR_NONE, ret);
if (query_type == MEDIA_SVC_QUERY_SET_ITEM_VALIDITY)
ret = _media_svc_sql_query_list(handle, &g_media_svc_item_validity_query_list,uid);
else if (query_type == MEDIA_SVC_QUERY_INSERT_ITEM)
ret = _media_svc_sql_query_list(handle, &g_media_svc_insert_item_query_list, uid);
else
- ret = MEDIA_INFO_ERROR_INVALID_PARAMETER;
+ ret = MS_MEDIA_ERR_INVALID_PARAMETER;
- if (ret != MEDIA_INFO_ERROR_NONE) {
+ if (ret != MS_MEDIA_ERR_NONE) {
media_svc_error("_media_svc_list_query_do failed. start rollback");
_media_svc_sql_rollback_trans(handle,uid);
return ret;
}
ret = _media_svc_sql_end_trans(handle, uid);
- if (ret != MEDIA_INFO_ERROR_NONE) {
+ if (ret != MS_MEDIA_ERR_NONE) {
media_svc_error("mb_svc_sqlite3_commit_trans failed.. Now start to rollback\n");
_media_svc_sql_rollback_trans(handle,uid);
return ret;
}
- return MEDIA_INFO_ERROR_NONE;
+ return MS_MEDIA_ERR_NONE;
}
int _media_svc_get_media_id_by_path(sqlite3 *handle, const char *path, char *media_uuid, int max_length)
{
- int ret = MEDIA_INFO_ERROR_NONE;
+ int ret = MS_MEDIA_ERR_NONE;
sqlite3_stmt *sql_stmt = NULL;
char *sql = sqlite3_mprintf("SELECT media_uuid FROM %s WHERE validity=1 AND path='%q'",
MEDIA_SVC_DB_TABLE_MEDIA, path);
ret = _media_svc_sql_prepare_to_step(handle, sql, &sql_stmt);
- if (ret != MEDIA_INFO_ERROR_NONE) {
+ if (ret != MS_MEDIA_ERR_NONE) {
media_svc_error("error when __media_svc_count_invalid_records_with_thumbnail. err = [%d]", ret);
return ret;
}
SQLITE3_FINALIZE(sql_stmt);
- return MEDIA_INFO_ERROR_NONE;
+ return MS_MEDIA_ERR_NONE;
}
int _media_svc_get_burst_id(sqlite3 *handle, int *id)
{
- int ret = MEDIA_INFO_ERROR_NONE;
+ int ret = MS_MEDIA_ERR_NONE;
int cur_id = -1;
sqlite3_stmt *sql_stmt = NULL;
char *sql = sqlite3_mprintf("SELECT max(CAST(burst_id AS INTEGER)) FROM %s", MEDIA_SVC_DB_TABLE_MEDIA);
ret = _media_svc_sql_prepare_to_step(handle, sql, &sql_stmt);
- if (ret != MEDIA_INFO_ERROR_NONE) {
+ if (ret != MS_MEDIA_ERR_NONE) {
media_svc_error("error when _media_svc_get_burst_id. err = [%d]", ret);
return ret;
}
*id = ++cur_id;
SQLITE3_FINALIZE(sql_stmt);
- return MEDIA_INFO_ERROR_NONE;
+ return MS_MEDIA_ERR_NONE;
}
int _media_svc_get_noti_info(sqlite3 *handle, const char *path, int update_item, media_svc_noti_item **item)
{
- int ret = MEDIA_INFO_ERROR_NONE;
+ int ret = MS_MEDIA_ERR_NONE;
sqlite3_stmt *sql_stmt = NULL;
char *sql = NULL;
int is_root_dir = FALSE;
if (item == NULL) {
media_svc_error("_media_svc_get_noti_info failed");
- return MEDIA_INFO_ERROR_INVALID_PARAMETER;
+ return MS_MEDIA_ERR_INVALID_PARAMETER;
}
if (update_item == MS_MEDIA_ITEM_FILE) {
sql = sqlite3_mprintf("SELECT folder_uuid FROM %s WHERE path=%Q", MEDIA_SVC_DB_TABLE_FOLDER, path);
} else {
media_svc_error("_media_svc_get_noti_info failed : update item");
- return MEDIA_INFO_ERROR_INVALID_PARAMETER;
+ return MS_MEDIA_ERR_INVALID_PARAMETER;
}
ret = _media_svc_sql_prepare_to_step(handle, sql, &sql_stmt);
- if (ret != MEDIA_INFO_ERROR_NONE) {
- if (ret == MEDIA_INFO_ERROR_DATABASE_NO_RECORD && update_item == MS_MEDIA_ITEM_DIRECTORY) {
- media_svc_error("This is root directory of media");
+ if (ret != MS_MEDIA_ERR_NONE) {
+ if (ret == MS_MEDIA_ERR_DB_NO_RECORD && update_item == MS_MEDIA_ITEM_DIRECTORY) {
+ media_svc_debug("This is root directory of media");
sql_stmt = NULL;
is_root_dir = TRUE;
} else {
*item = calloc(1, sizeof(media_svc_noti_item));
if (*item == NULL) {
media_svc_error("_media_svc_get_noti_info failed : calloc");
- return MEDIA_INFO_ERROR_OUT_OF_MEMORY;
+ return MS_MEDIA_ERR_OUT_OF_MEMORY;
}
if (update_item == MS_MEDIA_ITEM_FILE) {
SQLITE3_FINALIZE(sql_stmt);
- return MEDIA_INFO_ERROR_NONE;
+ return MS_MEDIA_ERR_NONE;
}
int _media_svc_count_invalid_folder_items(sqlite3 *handle, const char *folder_path, int *count)
{
- int ret = MEDIA_INFO_ERROR_NONE;
+ int ret = MS_MEDIA_ERR_NONE;
sqlite3_stmt *sql_stmt = NULL;
char *sql = sqlite3_mprintf("SELECT count(*) FROM %s WHERE validity=0 AND path LIKE '%q/%%'",
MEDIA_SVC_DB_TABLE_MEDIA, folder_path);
ret = _media_svc_sql_prepare_to_step(handle, sql, &sql_stmt);
- if (ret != MEDIA_INFO_ERROR_NONE) {
+ if (ret != MS_MEDIA_ERR_NONE) {
media_svc_error("error when __media_svc_count_invalid_folder_records_with_thumbnail. err = [%d]", ret);
return ret;
}
SQLITE3_FINALIZE(sql_stmt);
- return MEDIA_INFO_ERROR_NONE;
+ return MS_MEDIA_ERR_NONE;
}
int _media_svc_get_thumbnail_count(sqlite3 *handle, const char *thumb_path, int *count)
{
- int ret = MEDIA_INFO_ERROR_NONE;
+ int ret = MS_MEDIA_ERR_NONE;
sqlite3_stmt *sql_stmt = NULL;
char *sql = sqlite3_mprintf("SELECT count(*) FROM %s WHERE thumbnail_path=%Q", MEDIA_SVC_DB_TABLE_MEDIA, thumb_path);
ret = _media_svc_sql_prepare_to_step(handle, sql, &sql_stmt);
- if (ret != MEDIA_INFO_ERROR_NONE) {
+ if (ret != MS_MEDIA_ERR_NONE) {
media_svc_error("error when _media_svc_get_thumbnail_count. err = [%d]", ret);
return ret;
}
SQLITE3_FINALIZE(sql_stmt);
- return MEDIA_INFO_ERROR_NONE;
+ return MS_MEDIA_ERR_NONE;
}
g_inserted_noti_list = calloc(count, sizeof(media_svc_noti_item));
if (g_inserted_noti_list == NULL) {
media_svc_error("Failed to prepare noti items");
- return MEDIA_INFO_ERROR_OUT_OF_MEMORY;
+ return MS_MEDIA_ERR_OUT_OF_MEMORY;
}
- return MEDIA_INFO_ERROR_NONE;
+ return MS_MEDIA_ERR_NONE;
}
int _media_svc_insert_item_to_noti_list(media_svc_content_info_s *content_info, int cnt)
noti_list[cnt].mime_type = strdup(content_info->mime_type);
}
- return MEDIA_INFO_ERROR_NONE;
+ return MS_MEDIA_ERR_NONE;
}
-
int _media_svc_destroy_noti_list(int all_cnt)
{
int i = 0;
g_inserted_noti_list = NULL;
}
- return MEDIA_INFO_ERROR_NONE;
+ return MS_MEDIA_ERR_NONE;
}
int _media_svc_publish_noti_list(int all_cnt)
{
- int err = MEDIA_INFO_ERROR_NONE;
- int i = 0;
+ int ret = MS_MEDIA_ERR_NONE;
+ int idx = 0;
media_svc_noti_item *noti_list = g_inserted_noti_list;
if (noti_list) {
- for (i = 0; i < all_cnt; i++) {
- err = _media_svc_publish_noti_by_item(&(noti_list[i]));
- if (err < 0) {
- media_svc_error("_media_svc_publish_noti failed : %d", err);
- }
+ for (idx = 0; idx < all_cnt; idx++) {
+ ret = __media_svc_publish_noti_by_item(&(noti_list[idx]));
}
}
- return err;
+ return ret;
}
if (item == NULL || content_info == NULL) {
media_svc_error("_media_svc_create_noti_item : invalid param");
- return MEDIA_INFO_ERROR_INVALID_PARAMETER;
+ return MS_MEDIA_ERR_INVALID_PARAMETER;
}
_item = calloc(1, sizeof(media_svc_noti_item));
if (_item == NULL) {
media_svc_error("Failed to prepare noti items");
- return MEDIA_INFO_ERROR_OUT_OF_MEMORY;
+ return MS_MEDIA_ERR_OUT_OF_MEMORY;
}
_item->pid = pid;
*item = _item;
- return MEDIA_INFO_ERROR_NONE;
+ return MS_MEDIA_ERR_NONE;
}
int _media_svc_destroy_noti_item(media_svc_noti_item *item)
SAFE_FREE(item);
}
- return MEDIA_INFO_ERROR_NONE;
+ return MS_MEDIA_ERR_NONE;
}
int _media_svc_publish_noti_by_item(media_svc_noti_item *noti_item)
{
- int err = MEDIA_INFO_ERROR_NONE;
+ int err = MS_MEDIA_ERR_NONE;
if (noti_item && noti_item->path) {
err = media_db_update_send(noti_item->pid,
const char *mime_type
)
{
- int err = MEDIA_INFO_ERROR_NONE;
+ int err = MS_MEDIA_ERR_NONE;
if (path) {
err = media_db_update_send(getpid(),
(char *)mime_type);
if (err < 0) {
media_svc_error("media_db_update_send failed : %d [%s]", err, path);
- return MEDIA_INFO_ERROR_SEND_NOTI_FAIL;
+ return MS_MEDIA_ERR_SEND_NOTI_FAIL;
} else {
media_svc_debug("media_db_update_send success");
}
#include <grp.h>
#include <pwd.h>
#include "uuid.h"
+#include "media-util-err.h"
#include "media-svc-util.h"
-#include "media-svc-error.h"
+#include "media-svc-db-utils.h"
#include "media-svc-debug.h"
#include "media-svc-env.h"
#include "media-svc-hash.h"
char *_media_info_generate_uuid(void)
{
uuid_t uuid_value;
- static char uuid_unparsed[50];
+ static char uuid_unparsed[50];
uuid_generate(uuid_value);
uuid_unparse(uuid_value, uuid_unparsed);
if (!STRING_VALID(src)) {
media_svc_error("invalid src");
- return MEDIA_INFO_ERROR_INVALID_PARAMETER;
+ return MS_MEDIA_ERR_INVALID_PARAMETER;
}
SAFE_FREE(*dst);
if (*dst == NULL) {
media_svc_error("malloc failed");
- return MEDIA_INFO_ERROR_INTERNAL;
+ return MS_MEDIA_ERR_INTERNAL;
}
strncpy(*dst, src, len);
char *p = *dst;
p[len - 1] = '\0';
- return MEDIA_INFO_ERROR_NONE;
+ return MS_MEDIA_ERR_NONE;
}
static void __media_svc_split_to_double(char *input, double *arr, int *num)
if (ed == NULL) {
//media_svc_debug("ExifData is NULL");
- return MEDIA_INFO_ERROR_INVALID_PARAMETER;
+ return MS_MEDIA_ERR_INVALID_PARAMETER;
}
ifd = ifdtype;
if (i_value == NULL) {
media_svc_error("i_value is NULL");
- return MEDIA_INFO_ERROR_INVALID_PARAMETER;
+ return MS_MEDIA_ERR_INVALID_PARAMETER;
}
ExifByteOrder mByteOrder = exif_data_get_byte_order(ed);
if (d_value == NULL) {
media_svc_error("d_value is NULL");
- return MEDIA_INFO_ERROR_INVALID_PARAMETER;
+ return MS_MEDIA_ERR_INVALID_PARAMETER;
}
/* Get the contents of the tag in human-readable form */
__media_svc_split_to_double(gps_buf, tmp_arr, &count);
if (count != 3) {
media_svc_error("Value is invalid");
- return MEDIA_INFO_ERROR_INTERNAL;
+ return MS_MEDIA_ERR_INTERNAL;
}
*d_value = tmp_arr[0] + tmp_arr[1] / 60 + tmp_arr[2] / 3600;
if (buf == NULL) {
media_svc_error("buf is NULL");
- return MEDIA_INFO_ERROR_INVALID_PARAMETER;
+ return MS_MEDIA_ERR_INVALID_PARAMETER;
}
exif_entry_get_value(entry, buf, MEDIA_SVC_METADATA_LEN_MAX);
}
}
- return MEDIA_INFO_ERROR_NONE;
+ return MS_MEDIA_ERR_NONE;
}
unsigned int _media_svc_get_current_time(void)
if((old_name == NULL) || (new_name == NULL))
{
media_svc_error("invalid file name");
- return MEDIA_INFO_ERROR_INVALID_PARAMETER;
+ return MS_MEDIA_ERR_INVALID_PARAMETER;
}
if (rename(old_name, new_name) < 0) {
media_svc_error("Old : [%s] New : [%s] errno : [%s]", old_name, new_name, strerror(errno));
- return MEDIA_INFO_ERROR_INTERNAL;
+ return MS_MEDIA_ERR_INTERNAL;
}
- return MEDIA_INFO_ERROR_NONE;
+ return MS_MEDIA_ERR_NONE;
}
bool _media_svc_remove_file(const char *path)
dir = opendir(dir_path);
if (dir == NULL) {
media_svc_error("%s is not exist", dir_path);
- return MEDIA_INFO_ERROR_INVALID_PARAMETER;
+ return MS_MEDIA_ERR_INVALID_PARAMETER;
}
while ((entry = readdir(dir)) != NULL) {
if (unlink(filename) != 0) {
media_svc_error("failed to remove : %s", filename);
closedir(dir);
- return MEDIA_INFO_ERROR_INTERNAL;
+ return MS_MEDIA_ERR_INTERNAL;
}
}
closedir(dir);
- return MEDIA_INFO_ERROR_NONE;
+ return MS_MEDIA_ERR_NONE;
}
char *_media_svc_get_title_from_filepath (const char *path)
if (!image) {
media_svc_error("invalid image..");
- return MEDIA_INFO_ERROR_INVALID_PARAMETER;
+ return MS_MEDIA_ERR_INVALID_PARAMETER;
}
struct statfs fs;
if (-1 == statfs(_media_svc_get_thumb_path(uid), &fs)) {
media_svc_error("error in statfs");
- return MEDIA_INFO_ERROR_INTERNAL;
+ return MS_MEDIA_ERR_INTERNAL;
}
long bsize_kbytes = fs.f_bsize >> 10;
if ((bsize_kbytes * fs.f_bavail) < 1024) {
media_svc_error("not enought space...");
- return MEDIA_INFO_ERROR_INTERNAL;
+ return MS_MEDIA_ERR_INTERNAL;
}
FILE *fp = NULL;
if (fp == NULL) {
media_svc_error("failed to open file");
- return MEDIA_INFO_ERROR_INTERNAL;
+ return MS_MEDIA_ERR_INTERNAL;
}
nwrite = fwrite(image, 1, size, fp);
if (nwrite != size) {
media_svc_error("failed to write thumbnail");
fclose(fp);
- return MEDIA_INFO_ERROR_INTERNAL;
+ return MS_MEDIA_ERR_INTERNAL;
}
fclose(fp);
}
- return MEDIA_INFO_ERROR_NONE;
+ return MS_MEDIA_ERR_NONE;
}
fd = stat(full_path, &statbuf);
if (fd == -1) {
media_svc_error("stat(%s) fails.", full_path);
- return MEDIA_INFO_ERROR_INTERNAL;
+ return MS_MEDIA_ERR_INTERNAL;
}
return statbuf.st_mtime;
int _media_svc_set_media_info(media_svc_content_info_s *content_info, media_svc_storage_type_e storage_type,
const char *path, media_svc_media_type_e *media_type, bool refresh, drm_content_info_s **drm_contentInfo)
{
- int ret = MEDIA_INFO_ERROR_NONE;
+ int ret = MS_MEDIA_ERR_NONE;
char * media_uuid = NULL;
char * file_name = NULL;
struct stat st;
char mime_type[256] = {0};
ret = __media_svc_malloc_and_strncpy(&content_info->path, path);
- media_svc_retv_del_if(ret != MEDIA_INFO_ERROR_NONE, ret, content_info);
+ media_svc_retv_del_if(ret != MS_MEDIA_ERR_NONE, ret, content_info);
memset(&st, 0, sizeof(struct stat));
if (stat(path, &st) == 0) {
title = _media_svc_get_title_from_filepath(content_info->path);
if (title) {
ret = __media_svc_malloc_and_strncpy(&content_info->media_meta.title, title);
- if(ret != MEDIA_INFO_ERROR_NONE)
+ if(ret != MS_MEDIA_ERR_NONE)
media_svc_error("strcpy error");
SAFE_FREE(title);
} else {
media_svc_error("Can't extract title from filepath [%s]", content_info->path);
ret = __media_svc_malloc_and_strncpy(&content_info->media_meta.title, MEDIA_SVC_TAG_UNKNOWN);
- media_svc_retv_del_if(ret != MEDIA_INFO_ERROR_NONE, ret, content_info);
+ media_svc_retv_del_if(ret != MS_MEDIA_ERR_NONE, ret, content_info);
}
/* Set default value before extracting meta information */
ret = __media_svc_malloc_and_strncpy(&content_info->media_meta.description, MEDIA_SVC_TAG_UNKNOWN);
- media_svc_retv_del_if(ret != MEDIA_INFO_ERROR_NONE, ret, content_info);
+ media_svc_retv_del_if(ret != MS_MEDIA_ERR_NONE, ret, content_info);
ret = __media_svc_malloc_and_strncpy(&content_info->media_meta.copyright, MEDIA_SVC_TAG_UNKNOWN);
- media_svc_retv_del_if(ret != MEDIA_INFO_ERROR_NONE, ret, content_info);
+ media_svc_retv_del_if(ret != MS_MEDIA_ERR_NONE, ret, content_info);
ret = __media_svc_malloc_and_strncpy(&content_info->media_meta.track_num, MEDIA_SVC_TAG_UNKNOWN);
- media_svc_retv_del_if(ret != MEDIA_INFO_ERROR_NONE, ret, content_info);
+ media_svc_retv_del_if(ret != MS_MEDIA_ERR_NONE, ret, content_info);
ret = __media_svc_malloc_and_strncpy(&content_info->media_meta.album, MEDIA_SVC_TAG_UNKNOWN);
- media_svc_retv_del_if(ret != MEDIA_INFO_ERROR_NONE, ret, content_info);
+ media_svc_retv_del_if(ret != MS_MEDIA_ERR_NONE, ret, content_info);
ret = __media_svc_malloc_and_strncpy(&content_info->media_meta.artist, MEDIA_SVC_TAG_UNKNOWN);
- media_svc_retv_del_if(ret != MEDIA_INFO_ERROR_NONE, ret, content_info);
+ media_svc_retv_del_if(ret != MS_MEDIA_ERR_NONE, ret, content_info);
ret = __media_svc_malloc_and_strncpy(&content_info->media_meta.album_artist, MEDIA_SVC_TAG_UNKNOWN);
- media_svc_retv_del_if(ret != MEDIA_INFO_ERROR_NONE, ret, content_info);
+ media_svc_retv_del_if(ret != MS_MEDIA_ERR_NONE, ret, content_info);
ret = __media_svc_malloc_and_strncpy(&content_info->media_meta.genre, MEDIA_SVC_TAG_UNKNOWN);
- media_svc_retv_del_if(ret != MEDIA_INFO_ERROR_NONE, ret, content_info);
+ media_svc_retv_del_if(ret != MS_MEDIA_ERR_NONE, ret, content_info);
ret = __media_svc_malloc_and_strncpy(&content_info->media_meta.composer, MEDIA_SVC_TAG_UNKNOWN);
- media_svc_retv_del_if(ret != MEDIA_INFO_ERROR_NONE, ret, content_info);
+ media_svc_retv_del_if(ret != MS_MEDIA_ERR_NONE, ret, content_info);
ret = __media_svc_malloc_and_strncpy(&content_info->media_meta.year, MEDIA_SVC_TAG_UNKNOWN);
- media_svc_retv_del_if(ret != MEDIA_INFO_ERROR_NONE, ret, content_info);
+ media_svc_retv_del_if(ret != MS_MEDIA_ERR_NONE, ret, content_info);
/* refresh is TRUE when file modified. so only modified_time and size are changed*/
if(refresh) {
media_svc_debug("refresh");
- return MEDIA_INFO_ERROR_NONE;
+ return MS_MEDIA_ERR_NONE;
}
content_info->storage_type = storage_type;
time(&content_info->added_time);
media_uuid = _media_info_generate_uuid();
- media_svc_retvm_if(media_uuid == NULL, MEDIA_INFO_ERROR_INTERNAL, "Invalid UUID");
+ media_svc_retvm_if(media_uuid == NULL, MS_MEDIA_ERR_INTERNAL, "Invalid UUID");
ret = __media_svc_malloc_and_strncpy(&content_info->media_uuid, media_uuid);
- media_svc_retv_del_if(ret != MEDIA_INFO_ERROR_NONE, ret, content_info);
+ media_svc_retv_del_if(ret != MS_MEDIA_ERR_NONE, ret, content_info);
file_name = g_path_get_basename(path);
ret = __media_svc_malloc_and_strncpy(&content_info->file_name, file_name);
SAFE_FREE(file_name);
- media_svc_retv_del_if(ret != MEDIA_INFO_ERROR_NONE, ret, content_info);
+ media_svc_retv_del_if(ret != MS_MEDIA_ERR_NONE, ret, content_info);
/* if the file is DRM file, drm_type value is DRM_TRUE(1).
if drm_contentinfo is not NULL, the file is OMA DRM.*/
ret = _media_svc_get_mime_type(path, mime_type, &drm_type, drm_contentInfo);
if (ret < 0) {
media_svc_error("media_svc_get_mime_type failed : %d (%s)", ret, path);
- return MEDIA_INFO_ERROR_INVALID_PATH;
+ return MS_MEDIA_ERR_INVALID_PARAMETER;
}
media_svc_error("mime [%s]", mime_type);
content_info->is_drm = drm_type;
ret = _media_svc_get_media_type(path, mime_type, media_type);
- media_svc_retv_if(ret != MEDIA_INFO_ERROR_NONE, ret);
+ media_svc_retv_if(ret != MS_MEDIA_ERR_NONE, ret);
if ((*media_type < MEDIA_SVC_MEDIA_TYPE_IMAGE) || (*media_type > MEDIA_SVC_MEDIA_TYPE_OTHER)) {
media_svc_error("invalid media_type condition[%d]", *media_type);
- return MEDIA_INFO_ERROR_INVALID_PARAMETER;
+ return MS_MEDIA_ERR_INVALID_PARAMETER;
}
ret = __media_svc_malloc_and_strncpy(&content_info->mime_type, mime_type);
- media_svc_retv_del_if(ret != MEDIA_INFO_ERROR_NONE, ret, content_info);
+ media_svc_retv_del_if(ret != MS_MEDIA_ERR_NONE, ret, content_info);
- media_svc_debug("storage[%d], path[%s], media_type[%d]", storage_type, path, *media_type);
+ media_svc_sec_debug("storage[%d], path[%s], media_type[%d]", storage_type, path, *media_type);
content_info->media_type = *media_type;
content_info->favourate= 0;
content_info->media_meta.rating = 0;
- return MEDIA_INFO_ERROR_NONE;
+ return MS_MEDIA_ERR_NONE;
}
int _media_svc_extract_image_metadata(media_svc_content_info_s *content_info, media_svc_media_type_e media_type)
{
if (content_info == NULL || media_type != MEDIA_SVC_MEDIA_TYPE_IMAGE) {
media_svc_error("content_info == NULL || media_type != MEDIA_SVC_MEDIA_TYPE_IMAGE");
- return MEDIA_INFO_ERROR_INVALID_PARAMETER;
+ return MS_MEDIA_ERR_INVALID_PARAMETER;
}
char buf[MEDIA_SVC_METADATA_LEN_MAX + 1] = { '\0' };
memset(buf, 0x00, sizeof(buf));
memset(description_buf, 0x00, sizeof(description_buf));
- int ret = MEDIA_INFO_ERROR_NONE;
+ int ret = MS_MEDIA_ERR_NONE;
double value = 0.0;
int orient_value = 0;
int exif_width = 0;
char *path = content_info->path;
if (path == NULL) {
media_svc_error("path is NULL");
- return MEDIA_INFO_ERROR_INVALID_PARAMETER;
+ return MS_MEDIA_ERR_INVALID_PARAMETER;
}
/* Load an ExifData object from an EXIF file */
media_svc_debug("There is no exif data in [ %s ]", path);
}
- if (__media_svc_get_exif_info(ed, buf, NULL, NULL, EXIF_IFD_0, EXIF_TAG_GPS_LATITUDE_REF) == MEDIA_INFO_ERROR_NONE) {
+ if (__media_svc_get_exif_info(ed, buf, NULL, NULL, EXIF_IFD_0, EXIF_TAG_GPS_LATITUDE_REF) == MS_MEDIA_ERR_NONE) {
if (strlen(buf) != 0) {
- if (__media_svc_get_exif_info(ed, NULL, NULL, &value, EXIF_IFD_GPS, EXIF_TAG_GPS_LATITUDE) == MEDIA_INFO_ERROR_NONE) {
+ if (__media_svc_get_exif_info(ed, NULL, NULL, &value, EXIF_IFD_GPS, EXIF_TAG_GPS_LATITUDE) == MS_MEDIA_ERR_NONE) {
if (strcmp(buf, "S") == 0) {
value = -1 * value;
memset(buf, 0x00, sizeof(buf));
- if (__media_svc_get_exif_info(ed, buf, NULL, NULL, EXIF_IFD_0, EXIF_TAG_GPS_LONGITUDE_REF) == MEDIA_INFO_ERROR_NONE) {
+ if (__media_svc_get_exif_info(ed, buf, NULL, NULL, EXIF_IFD_0, EXIF_TAG_GPS_LONGITUDE_REF) == MS_MEDIA_ERR_NONE) {
if (strlen(buf) != 0) {
- if (__media_svc_get_exif_info(ed, NULL, NULL, &value, EXIF_IFD_GPS, EXIF_TAG_GPS_LONGITUDE) == MEDIA_INFO_ERROR_NONE) {
+ if (__media_svc_get_exif_info(ed, NULL, NULL, &value, EXIF_IFD_GPS, EXIF_TAG_GPS_LONGITUDE) == MS_MEDIA_ERR_NONE) {
if (strcmp(buf, "W") == 0) {
value = -1 * value;
}
memset(buf, 0x00, sizeof(buf));
- if (__media_svc_get_exif_info(ed, description_buf, NULL, NULL, EXIF_IFD_0, EXIF_TAG_IMAGE_DESCRIPTION) == MEDIA_INFO_ERROR_NONE) {
+ if (__media_svc_get_exif_info(ed, description_buf, NULL, NULL, EXIF_IFD_0, EXIF_TAG_IMAGE_DESCRIPTION) == MS_MEDIA_ERR_NONE) {
if (strlen(description_buf) == 0) {
//media_svc_debug("Use 'No description'");
ret = __media_svc_malloc_and_strncpy(&content_info->media_meta.description, MEDIA_SVC_TAG_UNKNOWN);
- if(ret != MEDIA_INFO_ERROR_NONE)
+ if(ret != MS_MEDIA_ERR_NONE)
media_svc_error("strcpy error");
} else {
ret = __media_svc_malloc_and_strncpy(&content_info->media_meta.description, description_buf);
- if(ret != MEDIA_INFO_ERROR_NONE)
+ if(ret != MS_MEDIA_ERR_NONE)
media_svc_error("strcpy error");
}
} else {
ret = __media_svc_malloc_and_strncpy(&content_info->media_meta.description, MEDIA_SVC_TAG_UNKNOWN);
- if(ret != MEDIA_INFO_ERROR_NONE)
+ if(ret != MS_MEDIA_ERR_NONE)
media_svc_error("strcpy error");
}
memset(buf, 0x00, sizeof(buf));
- if (__media_svc_get_exif_info(ed, buf, NULL, NULL, EXIF_IFD_0, EXIF_TAG_DATE_TIME) == MEDIA_INFO_ERROR_NONE) {
+ if (__media_svc_get_exif_info(ed, buf, NULL, NULL, EXIF_IFD_0, EXIF_TAG_DATE_TIME) == MS_MEDIA_ERR_NONE) {
if (strlen(buf) == 0) {
//media_svc_debug("time is NULL");
} else {
//media_svc_debug("time is %s", buf);
ret = __media_svc_malloc_and_strncpy(&content_info->media_meta.datetaken, buf);
- if(ret != MEDIA_INFO_ERROR_NONE) {
+ if(ret != MS_MEDIA_ERR_NONE) {
media_svc_error("strcpy error");
} else {
/* This is same as recorded_date */
ret = __media_svc_malloc_and_strncpy(&content_info->media_meta.recorded_date, buf);
- if(ret != MEDIA_INFO_ERROR_NONE)
+ if(ret != MS_MEDIA_ERR_NONE)
media_svc_error("strcpy error");
}
}
}
/* Get orientation value from exif. */
- if (__media_svc_get_exif_info(ed, NULL, &orient_value, NULL, EXIF_IFD_0, EXIF_TAG_ORIENTATION) == MEDIA_INFO_ERROR_NONE) {
+ if (__media_svc_get_exif_info(ed, NULL, &orient_value, NULL, EXIF_IFD_0, EXIF_TAG_ORIENTATION) == MS_MEDIA_ERR_NONE) {
if (orient_value >= NOT_AVAILABLE && orient_value <= ROT_270) {
content_info->media_meta.orientation = orient_value;
} else {
}
/* Get width value from exif. */
- if (__media_svc_get_exif_info(ed, NULL, &exif_width, NULL, EXIF_IFD_EXIF, EXIF_TAG_PIXEL_X_DIMENSION) == MEDIA_INFO_ERROR_NONE) {
+ if (__media_svc_get_exif_info(ed, NULL, &exif_width, NULL, EXIF_IFD_EXIF, EXIF_TAG_PIXEL_X_DIMENSION) == MS_MEDIA_ERR_NONE) {
if (exif_width > 0) {
content_info->media_meta.width = exif_width;
} else {
}
/* Get height value from exif. */
- if (__media_svc_get_exif_info(ed, NULL, &exif_height, NULL, EXIF_IFD_EXIF, EXIF_TAG_PIXEL_Y_DIMENSION) == MEDIA_INFO_ERROR_NONE) {
+ if (__media_svc_get_exif_info(ed, NULL, &exif_height, NULL, EXIF_IFD_EXIF, EXIF_TAG_PIXEL_Y_DIMENSION) == MS_MEDIA_ERR_NONE) {
if (exif_height > 0) {
content_info->media_meta.height = exif_height;
} else {
title = _media_svc_get_title_from_filepath(content_info->path);
if (title) {
ret = __media_svc_malloc_and_strncpy(&content_info->media_meta.title, title);
- if(ret != MEDIA_INFO_ERROR_NONE)
+ if(ret != MS_MEDIA_ERR_NONE)
media_svc_error("strcpy error");
SAFE_FREE(title);
} else {
else
content_info->thumbnail_path = NULL;
- if(ret != MEDIA_INFO_ERROR_NONE)
+ if(ret != MS_MEDIA_ERR_NONE)
media_svc_error("strcpy error");
#endif
- return MEDIA_INFO_ERROR_NONE;
+ return MS_MEDIA_ERR_NONE;
}
int _media_svc_extract_media_metadata(sqlite3 *handle, media_svc_content_info_s *content_info, media_svc_media_type_e media_type, drm_content_info_s *drm_contentInfo, uid_t uid)
bool append_album = FALSE;
int album_id = 0;
double gps_value = 0.0;
- int ret = MEDIA_INFO_ERROR_NONE;
+ int ret = MS_MEDIA_ERR_NONE;
char *path = content_info->path;
#ifdef __SUPPORT_DRM
if (drm_file_type == DRM_TYPE_OMA_V1) {
if (strlen(drm_contentInfo->title) > 0) {
ret = __media_svc_malloc_and_strncpy(&content_info->media_meta.title, drm_contentInfo->title);
- if(ret != MEDIA_INFO_ERROR_NONE)
+ if(ret != MS_MEDIA_ERR_NONE)
media_svc_error("strcpy error");
extracted_field |= MEDIA_SVC_EXTRACTED_FIELD_TITLE;
}
if (strlen(drm_contentInfo->description) > 0) {
ret = __media_svc_malloc_and_strncpy(&content_info->media_meta.description, drm_contentInfo->description);
- if(ret != MEDIA_INFO_ERROR_NONE)
+ if(ret != MS_MEDIA_ERR_NONE)
media_svc_error("strcpy error");
extracted_field |= MEDIA_SVC_EXTRACTED_FIELD_DESC;
}
} else if (drm_file_type == DRM_TYPE_OMA_V2) {
if (strlen(drm_contentInfo->title) > 0) {
ret = __media_svc_malloc_and_strncpy(&content_info->media_meta.title, drm_contentInfo->title);
- if(ret != MEDIA_INFO_ERROR_NONE)
+ if(ret != MS_MEDIA_ERR_NONE)
media_svc_error("strcpy error");
extracted_field |= MEDIA_SVC_EXTRACTED_FIELD_TITLE;
}
if (strlen(drm_contentInfo->description) > 0) {
ret = __media_svc_malloc_and_strncpy(&content_info->media_meta.description, drm_contentInfo->description);
- if(ret != MEDIA_INFO_ERROR_NONE)
+ if(ret != MS_MEDIA_ERR_NONE)
media_svc_error("strcpy error");
extracted_field |= MEDIA_SVC_EXTRACTED_FIELD_DESC;
}
if (strlen(drm_contentInfo->copyright) > 0) {
ret = __media_svc_malloc_and_strncpy(&content_info->media_meta.copyright, drm_contentInfo->copyright);
- if(ret != MEDIA_INFO_ERROR_NONE)
+ if(ret != MS_MEDIA_ERR_NONE)
media_svc_error("strcpy error");
extracted_field |= MEDIA_SVC_EXTRACTED_FIELD_COPYRIGHT;
}
if (strlen(drm_contentInfo->author) > 0) {
ret = __media_svc_malloc_and_strncpy(&content_info->media_meta.composer, drm_contentInfo->author);
- if(ret != MEDIA_INFO_ERROR_NONE)
+ if(ret != MS_MEDIA_ERR_NONE)
media_svc_error("strcpy error");
ret = __media_svc_malloc_and_strncpy(&content_info->media_meta.artist, drm_contentInfo->author);
- if(ret != MEDIA_INFO_ERROR_NONE)
+ if(ret != MS_MEDIA_ERR_NONE)
media_svc_error("strcpy error");
extracted_field |= MEDIA_SVC_EXTRACTED_FIELD_AUTHOR;
if (title) {
ret = __media_svc_malloc_and_strncpy(&content_info->media_meta.title, title);
SAFE_FREE(title);
- if(ret != MEDIA_INFO_ERROR_NONE)
+ if(ret != MS_MEDIA_ERR_NONE)
media_svc_error("strcpy error");
} else {
media_svc_error("Can't extract title from filepath [%s]", content_info->path);
}
}
- return MEDIA_INFO_ERROR_NONE;
+ return MS_MEDIA_ERR_NONE;
} else {
media_svc_debug("Some Not OMA Content's metadata is not incrypted so fileinfo can extracted metadata");
}
} else {
media_svc_error("Not support type");
- return MEDIA_INFO_ERROR_INVALID_PARAMETER;
+ return MS_MEDIA_ERR_INVALID_PARAMETER;
}
mmf_error = mm_file_destroy_content_attrs(content);
mmf_error = mm_file_get_attrs(tag, &err_attr_name, MM_FILE_TAG_ALBUM, &p, &size, NULL);
if ((!(extracted_field & MEDIA_SVC_EXTRACTED_FIELD_ALBUM)) && (mmf_error == MM_ERROR_NONE) && (size > 0)) {
ret = __media_svc_malloc_and_strncpy(&content_info->media_meta.album, p);
- if(ret != MEDIA_INFO_ERROR_NONE)
+ if(ret != MS_MEDIA_ERR_NONE)
media_svc_error("strcpy error");
//media_svc_debug("album[%d] : %s", size, content_info->media_meta.album);
mmf_error = mm_file_get_attrs(tag, &err_attr_name, MM_FILE_TAG_ARTIST, &p, &size, NULL);
if ((!(extracted_field & MEDIA_SVC_EXTRACTED_FIELD_ARTIST)) && (mmf_error == MM_ERROR_NONE) && (size > 0)) {
ret = __media_svc_malloc_and_strncpy(&content_info->media_meta.artist, p);
- if(ret != MEDIA_INFO_ERROR_NONE)
+ if(ret != MS_MEDIA_ERR_NONE)
media_svc_error("strcpy error");
//media_svc_debug("artist[%d] : %s", size, content_info->media_meta.artist);
} else {
mmf_error = mm_file_get_attrs(tag, &err_attr_name, MM_FILE_TAG_GENRE, &p, &size, NULL);
if ((!(extracted_field & MEDIA_SVC_EXTRACTED_FIELD_GENRE)) && (mmf_error == MM_ERROR_NONE) && (size > 0)) {
ret = __media_svc_malloc_and_strncpy(&content_info->media_meta.genre, p);
- if(ret != MEDIA_INFO_ERROR_NONE)
+ if(ret != MS_MEDIA_ERR_NONE)
media_svc_error("strcpy error");
//media_svc_debug("genre : %s", content_info->media_meta.genre);
if ((!(extracted_field & MEDIA_SVC_EXTRACTED_FIELD_TITLE)) && (mmf_error == MM_ERROR_NONE) && (size > 0)/* && (!isspace(*p))*/) {
if(!isspace(*p)) {
ret = __media_svc_malloc_and_strncpy(&content_info->media_meta.title, p);
- if(ret != MEDIA_INFO_ERROR_NONE)
+ if(ret != MS_MEDIA_ERR_NONE)
media_svc_error("strcpy error");
extracted_field |= MEDIA_SVC_EXTRACTED_FIELD_TITLE;
} else {
media_svc_debug("Not SPACE [%s]", p);
ret = __media_svc_malloc_and_strncpy(&content_info->media_meta.title, p);
- if(ret != MEDIA_INFO_ERROR_NONE)
+ if(ret != MS_MEDIA_ERR_NONE)
media_svc_error("strcpy error");
break;
}
title = _media_svc_get_title_from_filepath(content_info->path);
if (title) {
ret = __media_svc_malloc_and_strncpy(&content_info->media_meta.title, title);
- if(ret != MEDIA_INFO_ERROR_NONE)
+ if(ret != MS_MEDIA_ERR_NONE)
media_svc_error("strcpy error");
SAFE_FREE(title);
} else {
title = _media_svc_get_title_from_filepath(content_info->path);
if (title) {
ret = __media_svc_malloc_and_strncpy(&content_info->media_meta.title, title);
- if(ret != MEDIA_INFO_ERROR_NONE)
+ if(ret != MS_MEDIA_ERR_NONE)
media_svc_error("strcpy error");
SAFE_FREE(title);
} else {
mmf_error = mm_file_get_attrs(tag, &err_attr_name, MM_FILE_TAG_DESCRIPTION, &p, &size, NULL);
if ((!(extracted_field & MEDIA_SVC_EXTRACTED_FIELD_DESC)) && (mmf_error == MM_ERROR_NONE) && (size > 0)) {
ret = __media_svc_malloc_and_strncpy(&content_info->media_meta.description, p);
- if(ret != MEDIA_INFO_ERROR_NONE)
+ if(ret != MS_MEDIA_ERR_NONE)
media_svc_error("strcpy error");
//media_svc_debug("desc : %s", content_info->media_meta.description);
} else {
mmf_error = mm_file_get_attrs(tag, &err_attr_name, MM_FILE_TAG_RECDATE, &p, &size, NULL);
if ((!(extracted_field & MEDIA_SVC_EXTRACTED_FIELD_DESC)) && (mmf_error == MM_ERROR_NONE) && (size > 0)) {
ret = __media_svc_malloc_and_strncpy(&content_info->media_meta.recorded_date, p);
- if(ret != MEDIA_INFO_ERROR_NONE) {
+ if(ret != MS_MEDIA_ERR_NONE) {
media_svc_error("strcpy error");
} else {
/* This is same as datetaken */
ret = __media_svc_malloc_and_strncpy(&content_info->media_meta.datetaken, p);
- if(ret != MEDIA_INFO_ERROR_NONE)
+ if(ret != MS_MEDIA_ERR_NONE)
media_svc_error("strcpy error");
}
//media_svc_debug("Recorded date : %s", content_info->media_meta.recorded_date);
mmf_error = mm_file_get_attrs(tag, &err_attr_name, MM_FILE_TAG_AUTHOR, &p, &size, NULL);
if ((!(extracted_field & MEDIA_SVC_EXTRACTED_FIELD_AUTHOR)) && (mmf_error == MM_ERROR_NONE) && (size > 0)) {
ret = __media_svc_malloc_and_strncpy(&content_info->media_meta.composer, p);
- if(ret != MEDIA_INFO_ERROR_NONE)
+ if(ret != MS_MEDIA_ERR_NONE)
media_svc_error("strcpy error");
extracted_field |= MEDIA_SVC_EXTRACTED_FIELD_AUTHOR;
//media_svc_debug("extract composer from content : %s", content_info->media_meta.composer);
mmf_error = mm_file_get_attrs(tag, &err_attr_name, MM_FILE_TAG_COPYRIGHT, &p, &size, NULL);
if ((!(extracted_field & MEDIA_SVC_EXTRACTED_FIELD_COPYRIGHT)) && (mmf_error == MM_ERROR_NONE) && (size > 0)) {
ret = __media_svc_malloc_and_strncpy(&content_info->media_meta.copyright, p);
- if(ret != MEDIA_INFO_ERROR_NONE)
+ if(ret != MS_MEDIA_ERR_NONE)
media_svc_error("strcpy error");
extracted_field |= MEDIA_SVC_EXTRACTED_FIELD_AUTHOR;
//media_svc_debug("extract copyright from content : %s", content_info->media_meta.copyright);
mmf_error = mm_file_get_attrs(tag, &err_attr_name, MM_FILE_TAG_TRACK_NUM, &p, &size, NULL);
if ((mmf_error == MM_ERROR_NONE) && (size > 0)) {
ret = __media_svc_malloc_and_strncpy(&content_info->media_meta.track_num, p);
- if(ret != MEDIA_INFO_ERROR_NONE)
+ if(ret != MS_MEDIA_ERR_NONE)
media_svc_error("strcpy error");
} else {
SAFE_FREE(err_attr_name);
int year = 0;
if((p != NULL) && (sscanf( p, "%d", &year))) {
ret = __media_svc_malloc_and_strncpy(&content_info->media_meta.year, p);
- if(ret != MEDIA_INFO_ERROR_NONE)
+ if(ret != MS_MEDIA_ERR_NONE)
media_svc_error("strcpy error");
} else {
media_svc_debug("Wrong Year Information [%s]", p);
content_info->album_id = album_id;
ret = _media_svc_get_album_id(handle, content_info->media_meta.album, content_info->media_meta.artist, &album_id);
- if (ret != MEDIA_INFO_ERROR_NONE) {
- if (ret == MEDIA_INFO_ERROR_DATABASE_NO_RECORD) {
+ if (ret != MS_MEDIA_ERR_NONE) {
+ if (ret == MS_MEDIA_ERR_DB_NO_RECORD) {
media_svc_debug("album does not exist. So start to make album art");
extract_thumbnail = TRUE;
append_album = TRUE;
media_svc_debug("album already exists. don't need to make album art");
ret = _media_svc_get_album_art_by_album_id(handle, album_id, &content_info->thumbnail_path);
- media_svc_retv_del_if((ret != MEDIA_INFO_ERROR_NONE) && (ret != MEDIA_INFO_ERROR_DATABASE_NO_RECORD), ret, content_info);
+ media_svc_retv_del_if((ret != MS_MEDIA_ERR_NONE) && (ret != MS_MEDIA_ERR_DB_NO_RECORD), ret, content_info);
extract_thumbnail = FALSE;
}
}
}
if (image != NULL && size > 0) {
bool result = FALSE;
- int ret = MEDIA_INFO_ERROR_NONE;
+ int ret = MS_MEDIA_ERR_NONE;
char thumb_path[MEDIA_SVC_PATHNAME_SIZE] = "\0";
int artwork_mime_size = -1;
if(strlen(thumb_path) > 0)
{
ret = _media_svc_save_image(image, size, thumb_path, uid);
- if (ret != MEDIA_INFO_ERROR_NONE) {
+ if (ret != MS_MEDIA_ERR_NONE) {
media_svc_error("Fail to Save Thumbnail Image");
}
else {
ret = __media_svc_malloc_and_strncpy(&content_info->thumbnail_path, thumb_path);
- if(ret != MEDIA_INFO_ERROR_NONE)
+ if(ret != MS_MEDIA_ERR_NONE)
media_svc_error("strcpy error");
}
}
}
ret = __media_svc_malloc_and_strncpy(&content_info->thumbnail_path, thumb_path);
- if(ret != MEDIA_INFO_ERROR_NONE)
+ if(ret != MS_MEDIA_ERR_NONE)
media_svc_error("strcpy error");
if (content_info->media_meta.width <= 0) content_info->media_meta.width = width;
title = _media_svc_get_title_from_filepath(content_info->path);
if (title) {
ret = __media_svc_malloc_and_strncpy(&content_info->media_meta.title, title);
- if(ret != MEDIA_INFO_ERROR_NONE)
+ if(ret != MS_MEDIA_ERR_NONE)
media_svc_error("strcpy error");
SAFE_FREE(title);
} else {
content_info->album_id = album_id;
}
- return MEDIA_INFO_ERROR_NONE;
+ return MS_MEDIA_ERR_NONE;
}
void _media_svc_destroy_content_info(media_svc_content_info_s *content_info)
else
{
media_svc_error("INVALID parameter");
- return MEDIA_INFO_ERROR_INVALID_PARAMETER;
+ return MS_MEDIA_ERR_INVALID_PARAMETER;
}
- return MEDIA_INFO_ERROR_NONE;
+ return MS_MEDIA_ERR_NONE;
}
char *_media_svc_replace_path(char *s, const char *olds, const char *news)
return result;
}
-int _media_svc_error_convert(int error)
-{
- media_svc_debug("error : [%d]", error);
-
- if(error == MS_MEDIA_ERR_NONE) /*Error None*/
- return MEDIA_INFO_ERROR_NONE;
- else if(error == MS_MEDIA_ERR_DB_CONNECT_FAIL) /*DB Connect Fail*/
- return MEDIA_INFO_ERROR_DATABASE_CONNECT;
- else if(error == MS_MEDIA_ERR_DB_DISCONNECT_FAIL) /*DB Disconnect Fail*/
- return MEDIA_INFO_ERROR_DATABASE_DISCONNECT;
- else if(error == MS_MEDIA_ERR_SOCKET_CONN) /*Socket Connect Fail*/
- return MEDIA_INFO_ERROR_SOCKET_CONN;
- else if(error == MS_MEDIA_ERR_INVALID_PARAMETER || error == MS_MEDIA_ERR_INVALID_PATH)
- return MEDIA_INFO_ERROR_INVALID_PARAMETER;
-
- return MEDIA_INFO_ERROR_INTERNAL;
-}
-
-
bool _media_svc_is_drm_file(const char *path)
{
#ifdef __SUPPORT_DRM
int _media_svc_get_mime_in_drm_info(const char *path, char *mime, drm_content_info_s **drm_contentInfo)
{
#ifdef __SUPPORT_DRM
- int ret = MEDIA_INFO_ERROR_NONE;
+ int ret = MS_MEDIA_ERR_NONE;
drm_file_type_e file_type = DRM_TYPE_UNDEFINED;
if (path == NULL || mime == NULL)
- return MEDIA_INFO_ERROR_INVALID_PARAMETER;
+ return MS_MEDIA_ERR_INVALID_PARAMETER;
ret = drm_get_file_type(path, &file_type);
if (ret != DRM_RETURN_SUCCESS) {
media_svc_error("drm_get_file_type() failed : %d", ret);
- return MEDIA_INFO_ERROR_INVALID_MEDIA;
+ return MS_MEDIA_ERR_INTERNAL;
} else {
if (file_type == DRM_TYPE_OMA_V1
|| file_type == DRM_TYPE_OMA_V2
media_svc_error("drm_svc_get_content_info() fails :%d ", ret);
free(*drm_contentInfo);
*drm_contentInfo = NULL;
- return MEDIA_INFO_ERROR_INVALID_MEDIA;
+ return MS_MEDIA_ERR_INTERNAL;
}
if (STRING_VALID((*drm_contentInfo)->mime_type)) {
} else {
free(*drm_contentInfo);
*drm_contentInfo = NULL;
- return MEDIA_INFO_ERROR_INVALID_MEDIA;
+ return MS_MEDIA_ERR_INTERNAL;
}
} else {
media_svc_error("THIS IS DRM BUT YOU SHOULD USE API OF AUL LIBRARY");
*drm_contentInfo = NULL;
- return MEDIA_INFO_ERROR_INVALID_MEDIA;
+ return MS_MEDIA_ERR_INTERNAL;
}
}
- return MEDIA_INFO_ERROR_NONE;
+ return MS_MEDIA_ERR_NONE;
#else
*drm_contentInfo = NULL;
- return MEDIA_INFO_ERROR_INVALID_MEDIA;
+ return MS_MEDIA_ERR_INTERNAL;
#endif
}
*/
int _media_svc_get_mime_type(const char *path, char *mimetype, drm_bool_type_e *is_drm, drm_content_info_s **drm_contentInfo)
{
- int ret = MEDIA_INFO_ERROR_NONE;
+ int ret = MS_MEDIA_ERR_NONE;
if (path == NULL)
- return MEDIA_INFO_ERROR_INVALID_PARAMETER;
+ return MS_MEDIA_ERR_INVALID_PARAMETER;
#ifdef __SUPPORT_DRM
/* In case of drm file. */
if (_media_svc_is_drm_file(path)) {
*is_drm = DRM_TRUE;
ret = _media_svc_get_mime_in_drm_info(path, mimetype, drm_contentInfo);
- if (ret == MEDIA_INFO_ERROR_NONE) {
+ if (ret == MS_MEDIA_ERR_NONE) {
return ret;
}
}
/*in case of normal files or failure to get mime in drm */
if (aul_get_mime_from_file(path, mimetype, 255) < 0) {
media_svc_error("aul_get_mime_from_file fail");
- return MEDIA_INFO_ERROR_INVALID_MEDIA;
+ return MS_MEDIA_ERR_INTERNAL;
}
- return MEDIA_INFO_ERROR_NONE;
+ return MS_MEDIA_ERR_NONE;
}
int _media_svc_get_media_type(const char *path, const char *mime_type, media_svc_media_type_e *media_type)
{
- int ret = MEDIA_INFO_ERROR_NONE;
+ int ret = MS_MEDIA_ERR_NONE;
int category = 0;
media_svc_media_type_e type;
int _media_svc_get_pinyin_str(const char *src_str, char **pinyin_str)
{
- int ret = MEDIA_INFO_ERROR_NONE;
+ int ret = MS_MEDIA_ERR_NONE;
int size = 0;
pinyin_name_s *pinyinname = NULL;
*pinyin_str = NULL;
}
ret = _media_svc_convert_chinese_to_pinyin(src_str, &pinyinname, &size);
- if (ret == MEDIA_INFO_ERROR_NONE)
+ if (ret == MS_MEDIA_ERR_NONE)
{
if(STRING_VALID(pinyinname[0].pinyin_name))
*pinyin_str = strdup(pinyinname[0].pinyin_name);
*/
#include <string.h>
+#include <errno.h>
#include <drm_client.h>
#include <media-util.h>
#include "media-svc.h"
int media_svc_connect(MediaSvcHandle **handle, uid_t uid)
{
- int ret = MEDIA_INFO_ERROR_NONE;
+ int ret = MS_MEDIA_ERR_NONE;
MediaDBHandle *db_handle = NULL;
media_svc_debug_func();
#if 1 //Use libmedia_utils API
ret = media_db_connect(&db_handle,uid);
if(ret != MS_MEDIA_ERR_NONE)
- return _media_svc_error_convert(ret);
+ return ret;
#else
sqlite3 * db_handle = NULL;
ret = _media_svc_connect_db_with_handle(&db_handle);
- media_svc_retv_if(ret != MEDIA_INFO_ERROR_NONE, ret);
+ media_svc_retv_if(ret != MS_MEDIA_ERR_NONE, ret);
#endif
*handle = db_handle;
- return MEDIA_INFO_ERROR_NONE;
-
+ return MS_MEDIA_ERR_NONE;
}
int media_svc_disconnect(MediaSvcHandle *handle)
media_svc_debug_func();
- media_svc_retvm_if(db_handle == NULL, MEDIA_INFO_ERROR_INVALID_PARAMETER, "Handle is NULL");
+ media_svc_retvm_if(db_handle == NULL, MS_MEDIA_ERR_INVALID_PARAMETER, "Handle is NULL");
#if 1 //Use libmedia_utils API
- int ret = MEDIA_INFO_ERROR_NONE;
+ int ret = MS_MEDIA_ERR_NONE;
ret = media_db_disconnect(db_handle);
- return _media_svc_error_convert(ret);
+ return ret;
#else
sqlite3 * db_handle = (sqlite3 *)handle;
int media_svc_create_table(MediaSvcHandle *handle, uid_t uid)
{
- int ret = MEDIA_INFO_ERROR_NONE;
+ int ret = MS_MEDIA_ERR_NONE;
sqlite3 * db_handle = (sqlite3 *)handle;
media_svc_debug_func();
- media_svc_retvm_if(db_handle == NULL, MEDIA_INFO_ERROR_INVALID_PARAMETER, "Handle is NULL");
+ media_svc_retvm_if(db_handle == NULL, MS_MEDIA_ERR_INVALID_PARAMETER, "Handle is NULL");
/*create media table*/
ret = _media_svc_create_media_table(handle, uid);
- media_svc_retv_if(ret != MEDIA_INFO_ERROR_NONE, ret);
+ media_svc_retv_if(ret != MS_MEDIA_ERR_NONE, ret);
/*create folder table*/
ret = _media_svc_create_folder_table(handle, uid);
- media_svc_retv_if(ret != MEDIA_INFO_ERROR_NONE, ret);
+ media_svc_retv_if(ret != MS_MEDIA_ERR_NONE, ret);
/*create playlist table*/
ret = _media_svc_create_playlist_table(handle, uid);
- media_svc_retv_if(ret != MEDIA_INFO_ERROR_NONE, ret);
+ media_svc_retv_if(ret != MS_MEDIA_ERR_NONE, ret);
/* create album table*/
ret = _media_svc_create_album_table(handle, uid);
- media_svc_retv_if(ret != MEDIA_INFO_ERROR_NONE, ret);
+ media_svc_retv_if(ret != MS_MEDIA_ERR_NONE, ret);
/*create tag table*/
ret = _media_svc_create_tag_table(handle,uid);
- media_svc_retv_if(ret != MEDIA_INFO_ERROR_NONE, ret);
+ media_svc_retv_if(ret != MS_MEDIA_ERR_NONE, ret);
/*create bookmark table*/
ret = _media_svc_create_bookmark_table(handle, uid);
- media_svc_retv_if(ret != MEDIA_INFO_ERROR_NONE, ret);
+ media_svc_retv_if(ret != MS_MEDIA_ERR_NONE, ret);
#if 0 /*unify media and custom table*/
/*create custom table*/
ret = _media_svc_create_custom_table(handle, uid);
- media_svc_retv_if(ret != MEDIA_INFO_ERROR_NONE, ret);
+ media_svc_retv_if(ret != MS_MEDIA_ERR_NONE, ret);
#endif
- return MEDIA_INFO_ERROR_NONE;
+ return MS_MEDIA_ERR_NONE;
}
int media_svc_get_storage_type(const char *path, media_svc_storage_type_e *storage_type)
{
- int ret = MEDIA_INFO_ERROR_NONE;
+ int ret = MS_MEDIA_ERR_NONE;
media_svc_storage_type_e type;
ret = _media_svc_get_store_type_by_path(path, &type);
- media_svc_retvm_if(ret < MEDIA_INFO_ERROR_NONE, ret, "_media_svc_get_store_type_by_path failed : %d", ret);
+ media_svc_retvm_if(ret < MS_MEDIA_ERR_NONE, ret, "_media_svc_get_store_type_by_path failed : %d", ret);
*storage_type = type;
int media_svc_get_mime_type(const char *path, char *mimetype)
{
- int ret = MEDIA_INFO_ERROR_NONE;
+ int ret = MS_MEDIA_ERR_NONE;
drm_bool_type_e is_drm = DRM_FALSE;
drm_content_info_s *drm_contentInfo = NULL;
int media_svc_get_media_type(const char *path, const char *mime_type, media_svc_media_type_e *media_type)
{
- int ret = MEDIA_INFO_ERROR_NONE;
+ int ret = MS_MEDIA_ERR_NONE;
ret = _media_svc_get_media_type(path, mime_type, media_type);
int media_svc_check_item_exist_by_path(MediaSvcHandle *handle, const char *path)
{
- int ret = MEDIA_INFO_ERROR_NONE;
+ int ret = MS_MEDIA_ERR_NONE;
sqlite3 * db_handle = (sqlite3 *)handle;
int count = -1;
- media_svc_retvm_if(db_handle == NULL, MEDIA_INFO_ERROR_INVALID_PARAMETER, "Handle is NULL");
- media_svc_retvm_if(!STRING_VALID(path), MEDIA_INFO_ERROR_INVALID_PARAMETER, "Path is NULL");
+ media_svc_retvm_if(db_handle == NULL, MS_MEDIA_ERR_INVALID_PARAMETER, "Handle is NULL");
+ media_svc_retvm_if(!STRING_VALID(path), MS_MEDIA_ERR_INVALID_PARAMETER, "Path is NULL");
ret = _media_svc_count_record_with_path(db_handle, path, &count);
- media_svc_retv_if(ret != MEDIA_INFO_ERROR_NONE, ret);
+ media_svc_retv_if(ret != MS_MEDIA_ERR_NONE, ret);
if(count > 0) {
media_svc_debug("item is exist in database");
- return MEDIA_INFO_ERROR_NONE;
+ return MS_MEDIA_ERR_NONE;
} else {
media_svc_debug("item is not exist in database");
- return MEDIA_INFO_ERROR_DATABASE_NO_RECORD;
+ return MS_MEDIA_ERR_DB_NO_RECORD;
}
- return MEDIA_INFO_ERROR_NONE;
+ return MS_MEDIA_ERR_NONE;
}
int media_svc_insert_item_begin(MediaSvcHandle *handle, int data_cnt, int with_noti, int from_pid)
media_svc_debug("Transaction data count : [%d]", data_cnt);
- media_svc_retvm_if(db_handle == NULL, MEDIA_INFO_ERROR_INVALID_PARAMETER, "Handle is NULL");
- media_svc_retvm_if(data_cnt < 1, MEDIA_INFO_ERROR_INVALID_PARAMETER, "data_cnt shuld be bigger than 1");
+ media_svc_retvm_if(db_handle == NULL, MS_MEDIA_ERR_INVALID_PARAMETER, "Handle is NULL");
+ media_svc_retvm_if(data_cnt < 1, MS_MEDIA_ERR_INVALID_PARAMETER, "data_cnt shuld be bigger than 1");
g_media_svc_insert_item_data_cnt = data_cnt;
g_media_svc_insert_item_cur_data_cnt = 0;
/* Prepare for making noti item list */
if (with_noti) {
media_svc_debug("making noti list from pid[%d]", from_pid);
- if (_media_svc_create_noti_list(data_cnt) != MEDIA_INFO_ERROR_NONE) {
- return MEDIA_INFO_ERROR_OUT_OF_MEMORY;
+ if (_media_svc_create_noti_list(data_cnt) != MS_MEDIA_ERR_NONE) {
+ return MS_MEDIA_ERR_OUT_OF_MEMORY;
}
_media_svc_set_noti_from_pid(from_pid);
g_insert_with_noti = TRUE;
}
- return MEDIA_INFO_ERROR_NONE;
+ return MS_MEDIA_ERR_NONE;
}
int media_svc_insert_item_end(MediaSvcHandle *handle, uid_t uid)
{
- int ret = MEDIA_INFO_ERROR_NONE;
+ int ret = MS_MEDIA_ERR_NONE;
sqlite3 * db_handle = (sqlite3 *)handle;
media_svc_debug_func();
- media_svc_retvm_if(db_handle == NULL, MEDIA_INFO_ERROR_INVALID_PARAMETER, "Handle is NULL");
+ media_svc_retvm_if(db_handle == NULL, MS_MEDIA_ERR_INVALID_PARAMETER, "Handle is NULL");
if (g_media_svc_insert_item_cur_data_cnt > 0) {
int media_svc_insert_item_bulk(MediaSvcHandle *handle, media_svc_storage_type_e storage_type, const char *path, int is_burst, uid_t uid)
{
- int ret = MEDIA_INFO_ERROR_NONE;
+ int ret = MS_MEDIA_ERR_NONE;
sqlite3 * db_handle = (sqlite3 *)handle;
char folder_uuid[MEDIA_SVC_UUID_SIZE+1] = {0,};
media_svc_media_type_e media_type;
drm_content_info_s *drm_contentInfo = NULL;
- media_svc_retvm_if(db_handle == NULL, MEDIA_INFO_ERROR_INVALID_PARAMETER, "Handle is NULL");
- media_svc_retvm_if(!STRING_VALID(path), MEDIA_INFO_ERROR_INVALID_PARAMETER, "path is NULL");
+ media_svc_retvm_if(db_handle == NULL, MS_MEDIA_ERR_INVALID_PARAMETER, "Handle is NULL");
+ media_svc_retvm_if(!STRING_VALID(path), MS_MEDIA_ERR_INVALID_PARAMETER, "path is NULL");
if ((storage_type != MEDIA_SVC_STORAGE_INTERNAL) && (storage_type != MEDIA_SVC_STORAGE_EXTERNAL)) {
media_svc_error("storage type is incorrect[%d]", storage_type);
- return MEDIA_INFO_ERROR_INVALID_PARAMETER;
+ return MS_MEDIA_ERR_INVALID_PARAMETER;
}
media_svc_content_info_s content_info;
/*Set media info*/
/* if drm_contentinfo is not NULL, the file is OMA DRM.*/
ret = _media_svc_set_media_info(&content_info, storage_type, path, &media_type, FALSE, &drm_contentInfo);
- media_svc_retv_if(ret != MEDIA_INFO_ERROR_NONE, ret);
+ media_svc_retv_if(ret != MS_MEDIA_ERR_NONE, ret);
if(media_type == MEDIA_SVC_MEDIA_TYPE_OTHER) {
/*Do nothing.*/
ret = _media_svc_extract_media_metadata(handle, &content_info, media_type, drm_contentInfo, uid);
}
SAFE_FREE(drm_contentInfo);
- media_svc_retv_if(ret != MEDIA_INFO_ERROR_NONE, ret);
+ media_svc_retv_if(ret != MS_MEDIA_ERR_NONE, ret);
/*Set or Get folder id*/
ret = _media_svc_get_and_append_folder_id_by_path(handle, path, storage_type, folder_uuid, uid);
- media_svc_retv_if(ret != MEDIA_INFO_ERROR_NONE, ret);
+ media_svc_retv_if(ret != MS_MEDIA_ERR_NONE, ret);
ret = __media_svc_malloc_and_strncpy(&content_info.folder_uuid, folder_uuid);
- media_svc_retv_del_if(ret != MEDIA_INFO_ERROR_NONE, ret, &content_info);
+ media_svc_retv_del_if(ret != MS_MEDIA_ERR_NONE, ret, &content_info);
if (g_media_svc_insert_item_data_cnt == 1) {
ret = _media_svc_insert_item_with_data(db_handle, &content_info, is_burst, FALSE, uid);
- media_svc_retv_del_if(ret != MEDIA_INFO_ERROR_NONE, ret, &content_info);
+ media_svc_retv_del_if(ret != MS_MEDIA_ERR_NONE, ret, &content_info);
if (g_insert_with_noti)
_media_svc_insert_item_to_noti_list(&content_info, g_media_svc_insert_item_cur_data_cnt++);
} else if(g_media_svc_insert_item_cur_data_cnt < (g_media_svc_insert_item_data_cnt - 1)) {
ret = _media_svc_insert_item_with_data(db_handle, &content_info, is_burst, TRUE, uid);
- media_svc_retv_del_if(ret != MEDIA_INFO_ERROR_NONE, ret, &content_info);
+ media_svc_retv_del_if(ret != MS_MEDIA_ERR_NONE, ret, &content_info);
if (g_insert_with_noti)
_media_svc_insert_item_to_noti_list(&content_info, g_media_svc_insert_item_cur_data_cnt);
} else if (g_media_svc_insert_item_cur_data_cnt == (g_media_svc_insert_item_data_cnt - 1)) {
ret = _media_svc_insert_item_with_data(db_handle, &content_info, is_burst, TRUE, uid);
- media_svc_retv_del_if(ret != MEDIA_INFO_ERROR_NONE, ret, &content_info);
+ media_svc_retv_del_if(ret != MS_MEDIA_ERR_NONE, ret, &content_info);
if (g_insert_with_noti)
_media_svc_insert_item_to_noti_list(&content_info, g_media_svc_insert_item_cur_data_cnt);
ret = _media_svc_list_query_do(db_handle, MEDIA_SVC_QUERY_INSERT_ITEM, uid);
- media_svc_retv_del_if(ret != MEDIA_INFO_ERROR_NONE, ret, &content_info);
+ media_svc_retv_del_if(ret != MS_MEDIA_ERR_NONE, ret, &content_info);
if (g_insert_with_noti) {
_media_svc_publish_noti_list(g_media_svc_insert_item_cur_data_cnt + 1);
_media_svc_destroy_noti_list(g_media_svc_insert_item_cur_data_cnt + 1);
/* Recreate noti list */
- if (_media_svc_create_noti_list(g_media_svc_insert_item_data_cnt) != MEDIA_INFO_ERROR_NONE) {
- return MEDIA_INFO_ERROR_OUT_OF_MEMORY;
+ if (_media_svc_create_noti_list(g_media_svc_insert_item_data_cnt) != MS_MEDIA_ERR_NONE) {
+ return MS_MEDIA_ERR_OUT_OF_MEMORY;
}
}
} else {
media_svc_error("Error in media_svc_insert_item_bulk");
_media_svc_destroy_content_info(&content_info);
- return MEDIA_INFO_ERROR_INTERNAL;
+ return MS_MEDIA_ERR_INTERNAL;
}
_media_svc_destroy_content_info(&content_info);
- return MEDIA_INFO_ERROR_NONE;
+ return MS_MEDIA_ERR_NONE;
}
int media_svc_insert_item_immediately(MediaSvcHandle *handle, media_svc_storage_type_e storage_type, const char *path, uid_t uid)
{
- int ret = MEDIA_INFO_ERROR_NONE;
+ int ret = MS_MEDIA_ERR_NONE;
sqlite3 * db_handle = (sqlite3 *)handle;
char folder_uuid[MEDIA_SVC_UUID_SIZE+1] = {0,};
media_svc_media_type_e media_type;
drm_content_info_s *drm_contentInfo = NULL;
- media_svc_retvm_if(db_handle == NULL, MEDIA_INFO_ERROR_INVALID_PARAMETER, "Handle is NULL");
- media_svc_retvm_if(!STRING_VALID(path), MEDIA_INFO_ERROR_INVALID_PARAMETER, "path is NULL");
+ media_svc_retvm_if(db_handle == NULL, MS_MEDIA_ERR_INVALID_PARAMETER, "Handle is NULL");
+ media_svc_retvm_if(!STRING_VALID(path), MS_MEDIA_ERR_INVALID_PARAMETER, "path is NULL");
if ((storage_type != MEDIA_SVC_STORAGE_INTERNAL) && (storage_type != MEDIA_SVC_STORAGE_EXTERNAL)) {
media_svc_error("storage type is incorrect[%d]", storage_type);
- return MEDIA_INFO_ERROR_INVALID_PARAMETER;
+ return MS_MEDIA_ERR_INVALID_PARAMETER;
}
media_svc_content_info_s content_info;
/*Set media info*/
ret = _media_svc_set_media_info(&content_info, storage_type, path, &media_type, FALSE, &drm_contentInfo);
- media_svc_retv_if(ret != MEDIA_INFO_ERROR_NONE, ret);
+ media_svc_retv_if(ret != MS_MEDIA_ERR_NONE, ret);
if(media_type == MEDIA_SVC_MEDIA_TYPE_OTHER) {
/*Do nothing.*/
} else if(media_type == MEDIA_SVC_MEDIA_TYPE_IMAGE) {
ret = _media_svc_extract_image_metadata(&content_info, media_type);
- media_svc_retv_if(ret != MEDIA_INFO_ERROR_NONE, ret);
+ media_svc_retv_if(ret != MS_MEDIA_ERR_NONE, ret);
} else {
ret = _media_svc_extract_media_metadata(handle, &content_info, media_type, drm_contentInfo, uid);
- media_svc_retv_if(ret != MEDIA_INFO_ERROR_NONE, ret);
+ media_svc_retv_if(ret != MS_MEDIA_ERR_NONE, ret);
}
/*Set or Get folder id*/
ret = _media_svc_get_and_append_folder_id_by_path(handle, path, storage_type, folder_uuid, uid);
- media_svc_retv_if(ret != MEDIA_INFO_ERROR_NONE, ret);
+ media_svc_retv_if(ret != MS_MEDIA_ERR_NONE, ret);
ret = __media_svc_malloc_and_strncpy(&content_info.folder_uuid, folder_uuid);
- media_svc_retv_del_if(ret != MEDIA_INFO_ERROR_NONE, ret, &content_info);
+ media_svc_retv_del_if(ret != MS_MEDIA_ERR_NONE, ret, &content_info);
#if 1
/* Extracting thumbnail */
if (media_type == MEDIA_SVC_MEDIA_TYPE_IMAGE || media_type == MEDIA_SVC_MEDIA_TYPE_VIDEO) {
#endif
ret = _media_svc_insert_item_with_data(db_handle, &content_info, FALSE, FALSE, uid);
- if (ret == MEDIA_INFO_ERROR_NONE) {
+ if (ret == MS_MEDIA_ERR_NONE) {
media_svc_debug("Insertion is successful. Sending noti for this");
_media_svc_publish_noti(MS_MEDIA_ITEM_FILE, MS_MEDIA_ITEM_INSERT, content_info.path, content_info.media_type, content_info.media_uuid, content_info.mime_type);
}
int media_svc_insert_folder(MediaSvcHandle *handle, media_svc_storage_type_e storage_type, const char *path, uid_t uid)
{
- int ret = MEDIA_INFO_ERROR_NONE;
+ int ret = MS_MEDIA_ERR_NONE;
sqlite3 * db_handle = (sqlite3 *)handle;
- media_svc_retvm_if(db_handle == NULL, MEDIA_INFO_ERROR_INVALID_PARAMETER, "Handle is NULL");
- media_svc_retvm_if(!STRING_VALID(path), MEDIA_INFO_ERROR_INVALID_PARAMETER, "path is NULL");
+ media_svc_retvm_if(db_handle == NULL, MS_MEDIA_ERR_INVALID_PARAMETER, "Handle is NULL");
+ media_svc_retvm_if(!STRING_VALID(path), MS_MEDIA_ERR_INVALID_PARAMETER, "path is NULL");
if ((storage_type != MEDIA_SVC_STORAGE_INTERNAL) && (storage_type != MEDIA_SVC_STORAGE_EXTERNAL)) {
media_svc_error("storage type is incorrect[%d]", storage_type);
- return MEDIA_INFO_ERROR_INVALID_PARAMETER;
+ return MS_MEDIA_ERR_INVALID_PARAMETER;
}
media_svc_debug("storage[%d], folder_path[%s]", storage_type, path);
char *folder_uuid = _media_info_generate_uuid();
if(folder_uuid == NULL ) {
media_svc_error("Invalid UUID");
- return MEDIA_INFO_ERROR_INTERNAL;
+ return MS_MEDIA_ERR_INTERNAL;
}
folder_name = g_path_get_basename(path);
ret = _media_svc_append_folder(handle, storage_type, folder_uuid, path, folder_name, folder_modified_date, uid);
SAFE_FREE(folder_name);
- if (ret < MEDIA_INFO_ERROR_NONE) {
+ if (ret != MS_MEDIA_ERR_NONE) {
media_svc_error("_media_svc_append_folder error [%d]", ret);
return ret;
}
- return MEDIA_INFO_ERROR_NONE;
+ return MS_MEDIA_ERR_NONE;
}
int media_svc_move_item_begin(MediaSvcHandle *handle, int data_cnt)
media_svc_debug("Transaction data count : [%d]", data_cnt);
- media_svc_retvm_if(db_handle == NULL, MEDIA_INFO_ERROR_INVALID_PARAMETER, "Handle is NULL");
- media_svc_retvm_if(data_cnt < 1, MEDIA_INFO_ERROR_INVALID_PARAMETER, "data_cnt shuld be bigger than 1");
+ media_svc_retvm_if(db_handle == NULL, MS_MEDIA_ERR_INVALID_PARAMETER, "Handle is NULL");
+ media_svc_retvm_if(data_cnt < 1, MS_MEDIA_ERR_INVALID_PARAMETER, "data_cnt shuld be bigger than 1");
g_media_svc_move_item_data_cnt = data_cnt;
g_media_svc_move_item_cur_data_cnt = 0;
- return MEDIA_INFO_ERROR_NONE;
+ return MS_MEDIA_ERR_NONE;
}
int media_svc_move_item_end(MediaSvcHandle *handle, uid_t uid)
{
- int ret = MEDIA_INFO_ERROR_NONE;
+ int ret = MS_MEDIA_ERR_NONE;
sqlite3 * db_handle = (sqlite3 *)handle;
media_svc_debug_func();
- media_svc_retvm_if(db_handle == NULL, MEDIA_INFO_ERROR_INVALID_PARAMETER, "Handle is NULL");
+ media_svc_retvm_if(db_handle == NULL, MS_MEDIA_ERR_INVALID_PARAMETER, "Handle is NULL");
if (g_media_svc_move_item_cur_data_cnt > 0) {
/*clean up old folder path*/
ret = _media_svc_update_folder_table(handle, uid);
- media_svc_retv_if(ret != MEDIA_INFO_ERROR_NONE, ret);
+ media_svc_retv_if(ret != MS_MEDIA_ERR_NONE, ret);
g_media_svc_move_item_data_cnt = 1;
g_media_svc_move_item_cur_data_cnt = 0;
int media_svc_move_item(MediaSvcHandle *handle, media_svc_storage_type_e src_storage, const char *src_path,
media_svc_storage_type_e dest_storage, const char *dest_path, uid_t uid)
{
- int ret = MEDIA_INFO_ERROR_NONE;
+ int ret = MS_MEDIA_ERR_NONE;
sqlite3 * db_handle = (sqlite3 *)handle;
char *file_name = NULL;
char *folder_path = NULL;
media_svc_debug_func();
- media_svc_retvm_if(db_handle == NULL, MEDIA_INFO_ERROR_INVALID_PARAMETER, "Handle is NULL");
- media_svc_retvm_if(!STRING_VALID(src_path), MEDIA_INFO_ERROR_INVALID_PARAMETER, "src_path is NULL");
- media_svc_retvm_if(!STRING_VALID(dest_path), MEDIA_INFO_ERROR_INVALID_PARAMETER, "dest_path is NULL");
+ media_svc_retvm_if(db_handle == NULL, MS_MEDIA_ERR_INVALID_PARAMETER, "Handle is NULL");
+ media_svc_retvm_if(!STRING_VALID(src_path), MS_MEDIA_ERR_INVALID_PARAMETER, "src_path is NULL");
+ media_svc_retvm_if(!STRING_VALID(dest_path), MS_MEDIA_ERR_INVALID_PARAMETER, "dest_path is NULL");
if ((src_storage != MEDIA_SVC_STORAGE_INTERNAL) && (src_storage != MEDIA_SVC_STORAGE_EXTERNAL)) {
media_svc_error("src_storage type is incorrect[%d]", src_storage);
- return MEDIA_INFO_ERROR_INVALID_PARAMETER;
+ return MS_MEDIA_ERR_INVALID_PARAMETER;
}
if ((dest_storage != MEDIA_SVC_STORAGE_INTERNAL) && (dest_storage != MEDIA_SVC_STORAGE_EXTERNAL)) {
media_svc_error("dest_storage type is incorrect[%d]", dest_storage);
- return MEDIA_INFO_ERROR_INVALID_PARAMETER;
+ return MS_MEDIA_ERR_INVALID_PARAMETER;
}
/*check and update folder*/
ret = _media_svc_get_and_append_folder_id_by_path(handle, dest_path, dest_storage, folder_uuid, uid);
- media_svc_retv_if(ret != MEDIA_INFO_ERROR_NONE, ret);
+ media_svc_retv_if(ret != MS_MEDIA_ERR_NONE, ret);
/*get filename*/
file_name = g_path_get_basename(dest_path);
/*get thumbnail_path to update. only for Imgae and Video items. Audio share album_art(thumbnail)*/
ret = _media_svc_get_media_type_by_path(handle, src_path, &media_type);
- media_svc_retv_if(ret != MEDIA_INFO_ERROR_NONE, ret);
+ media_svc_retv_if(ret != MS_MEDIA_ERR_NONE, ret);
if((media_type == MEDIA_SVC_MEDIA_TYPE_IMAGE) ||(media_type == MEDIA_SVC_MEDIA_TYPE_VIDEO)) {
/*get old thumbnail_path*/
ret = _media_svc_get_thumbnail_path_by_path(handle, src_path, old_thumb_path);
- media_svc_retv_if((ret != MEDIA_INFO_ERROR_NONE) && (ret != MEDIA_INFO_ERROR_DATABASE_NO_RECORD), ret);
+ media_svc_retv_if((ret != MS_MEDIA_ERR_NONE) && (ret != MS_MEDIA_ERR_DB_NO_RECORD), ret);
/* If old thumb path is default or not */
if (strncmp(old_thumb_path, _media_svc_get_thumb_default_path(uid), sizeof(_media_svc_get_thumb_default_path(uid))) == 0) {
ret = _media_svc_update_item_by_path(handle, src_path, dest_storage, dest_path, file_name, modified_time, folder_uuid, NULL, FALSE, uid);
}
SAFE_FREE(file_name);
- media_svc_retv_if(ret != MEDIA_INFO_ERROR_NONE, ret);
+ media_svc_retv_if(ret != MS_MEDIA_ERR_NONE, ret);
media_svc_debug("Move is successful. Sending noti for this");
/* Get notification info */
media_svc_noti_item *noti_item = NULL;
ret = _media_svc_get_noti_info(handle, dest_path, MS_MEDIA_ITEM_FILE, ¬i_item);
- media_svc_retv_if(ret != MEDIA_INFO_ERROR_NONE, ret);
+ media_svc_retv_if(ret != MS_MEDIA_ERR_NONE, ret);
/* Send notification for move */
_media_svc_publish_noti(MS_MEDIA_ITEM_FILE, MS_MEDIA_ITEM_UPDATE, src_path, media_type, noti_item->media_uuid, noti_item->mime_type);
folder_path = g_path_get_dirname(dest_path);
ret = _media_svc_update_folder_modified_time_by_folder_uuid(handle, folder_uuid, folder_path, FALSE, uid);
SAFE_FREE(folder_path);
- media_svc_retv_if(ret != MEDIA_INFO_ERROR_NONE, ret);
+ media_svc_retv_if(ret != MS_MEDIA_ERR_NONE, ret);
ret = _media_svc_update_folder_table(handle, uid);
- media_svc_retv_if(ret != MEDIA_INFO_ERROR_NONE, ret);
+ media_svc_retv_if(ret != MS_MEDIA_ERR_NONE, ret);
} else if (g_media_svc_move_item_cur_data_cnt < (g_media_svc_move_item_data_cnt - 1)) {
ret = _media_svc_update_item_by_path(handle, src_path, dest_storage, dest_path, file_name, modified_time, folder_uuid, NULL, TRUE, uid);
}
SAFE_FREE(file_name);
- media_svc_retv_if(ret != MEDIA_INFO_ERROR_NONE, ret);
+ media_svc_retv_if(ret != MS_MEDIA_ERR_NONE, ret);
/*update folder modified_time*/
folder_path = g_path_get_dirname(dest_path);
ret = _media_svc_update_folder_modified_time_by_folder_uuid(handle, folder_uuid, folder_path, TRUE, uid);
SAFE_FREE(folder_path);
- media_svc_retv_if(ret != MEDIA_INFO_ERROR_NONE, ret);
+ media_svc_retv_if(ret != MS_MEDIA_ERR_NONE, ret);
g_media_svc_move_item_cur_data_cnt ++;
ret = _media_svc_update_item_by_path(handle, src_path, dest_storage, dest_path, file_name, modified_time, folder_uuid, NULL, TRUE, uid);
}
SAFE_FREE(file_name);
- media_svc_retv_if(ret != MEDIA_INFO_ERROR_NONE, ret);
+ media_svc_retv_if(ret != MS_MEDIA_ERR_NONE, ret);
/*update folder modified_time*/
folder_path = g_path_get_dirname(dest_path);
ret = _media_svc_update_folder_modified_time_by_folder_uuid(handle, folder_uuid, folder_path, TRUE, uid);
SAFE_FREE(folder_path);
- media_svc_retv_if(ret != MEDIA_INFO_ERROR_NONE, ret);
+ media_svc_retv_if(ret != MS_MEDIA_ERR_NONE, ret);
/*update db*/
ret = _media_svc_list_query_do(db_handle, MEDIA_SVC_QUERY_MOVE_ITEM, uid);
- media_svc_retv_if(ret != MEDIA_INFO_ERROR_NONE, ret);
+ media_svc_retv_if(ret != MS_MEDIA_ERR_NONE, ret);
g_media_svc_move_item_cur_data_cnt = 0;
} else {
media_svc_error("Error in media_svc_move_item");
- return MEDIA_INFO_ERROR_INTERNAL;
+ return MS_MEDIA_ERR_INTERNAL;
}
/*rename thumbnail file*/
if((media_type == MEDIA_SVC_MEDIA_TYPE_IMAGE) ||(media_type == MEDIA_SVC_MEDIA_TYPE_VIDEO)) {
if((strlen(old_thumb_path) > 0) && (strncmp(old_thumb_path, _media_svc_get_thumb_default_path(uid), sizeof(_media_svc_get_thumb_default_path(uid))) != 0)) {
ret = _media_svc_rename_file(old_thumb_path,new_thumb_path);
- if (ret < 0)
+ if (ret != MS_MEDIA_ERR_NONE)
media_svc_error("_media_svc_rename_file failed : %d", ret);
}
}
- return MEDIA_INFO_ERROR_NONE;
+ return MS_MEDIA_ERR_NONE;
}
int media_svc_set_item_validity_begin(MediaSvcHandle *handle, int data_cnt)
media_svc_debug("Transaction data count : [%d]", data_cnt);
- media_svc_retvm_if(db_handle == NULL, MEDIA_INFO_ERROR_INVALID_PARAMETER, "Handle is NULL");
- media_svc_retvm_if(data_cnt < 1, MEDIA_INFO_ERROR_INVALID_PARAMETER, "data_cnt shuld be bigger than 1");
+ media_svc_retvm_if(db_handle == NULL, MS_MEDIA_ERR_INVALID_PARAMETER, "Handle is NULL");
+ media_svc_retvm_if(data_cnt < 1, MS_MEDIA_ERR_INVALID_PARAMETER, "data_cnt shuld be bigger than 1");
g_media_svc_item_validity_data_cnt = data_cnt;
g_media_svc_item_validity_cur_data_cnt = 0;
- return MEDIA_INFO_ERROR_NONE;
+ return MS_MEDIA_ERR_NONE;
}
int media_svc_set_item_validity_end(MediaSvcHandle *handle, uid_t uid)
{
- int ret = MEDIA_INFO_ERROR_NONE;
+ int ret = MS_MEDIA_ERR_NONE;
sqlite3 * db_handle = (sqlite3 *)handle;
media_svc_debug_func();
- media_svc_retvm_if(db_handle == NULL, MEDIA_INFO_ERROR_INVALID_PARAMETER, "Handle is NULL");
+ media_svc_retvm_if(db_handle == NULL, MS_MEDIA_ERR_INVALID_PARAMETER, "Handle is NULL");
if (g_media_svc_item_validity_cur_data_cnt > 0) {
int media_svc_set_item_validity(MediaSvcHandle *handle, const char *path, int validity,uid_t uid)
{
- int ret = MEDIA_INFO_ERROR_NONE;
+ int ret = MS_MEDIA_ERR_NONE;
sqlite3 * db_handle = (sqlite3 *)handle;
- media_svc_retvm_if(db_handle == NULL, MEDIA_INFO_ERROR_INVALID_PARAMETER, "Handle is NULL");
- media_svc_retvm_if(!STRING_VALID(path), MEDIA_INFO_ERROR_INVALID_PARAMETER, "path is NULL");
+ media_svc_retvm_if(db_handle == NULL, MS_MEDIA_ERR_INVALID_PARAMETER, "Handle is NULL");
+ media_svc_retvm_if(!STRING_VALID(path), MS_MEDIA_ERR_INVALID_PARAMETER, "path is NULL");
media_svc_debug("path=[%s], validity=[%d]", path, validity);
} else if (g_media_svc_item_validity_cur_data_cnt < (g_media_svc_item_validity_data_cnt - 1)) {
ret = _media_svc_update_item_validity(db_handle, path, validity, TRUE, uid);
- media_svc_retv_if(ret != MEDIA_INFO_ERROR_NONE, ret);
+ media_svc_retv_if(ret != MS_MEDIA_ERR_NONE, ret);
g_media_svc_item_validity_cur_data_cnt ++;
} else if (g_media_svc_item_validity_cur_data_cnt == (g_media_svc_item_validity_data_cnt - 1)) {
ret = _media_svc_update_item_validity(db_handle, path, validity, TRUE, uid);
- media_svc_retv_if(ret != MEDIA_INFO_ERROR_NONE, ret);
+ media_svc_retv_if(ret != MS_MEDIA_ERR_NONE, ret);
ret = _media_svc_list_query_do(db_handle, MEDIA_SVC_QUERY_SET_ITEM_VALIDITY, uid);
- media_svc_retv_if(ret != MEDIA_INFO_ERROR_NONE, ret);
+ media_svc_retv_if(ret != MS_MEDIA_ERR_NONE, ret);
g_media_svc_item_validity_cur_data_cnt = 0;
} else {
media_svc_error("Error in media_svc_set_item_validity");
- return MEDIA_INFO_ERROR_INTERNAL;
+ return MS_MEDIA_ERR_INTERNAL;
}
- return MEDIA_INFO_ERROR_NONE;
+ return MS_MEDIA_ERR_NONE;
}
int media_svc_delete_item_by_path(MediaSvcHandle *handle, const char *path, uid_t uid)
{
- int ret = MEDIA_INFO_ERROR_NONE;
+ int ret = MS_MEDIA_ERR_NONE;
sqlite3 * db_handle = (sqlite3 *)handle;
char thumb_path[MEDIA_SVC_PATHNAME_SIZE] = {0,};
media_svc_debug_func();
- media_svc_retvm_if(db_handle == NULL, MEDIA_INFO_ERROR_INVALID_PARAMETER, "Handle is NULL");
- media_svc_retvm_if(!STRING_VALID(path), MEDIA_INFO_ERROR_INVALID_PARAMETER, "path is NULL");
+ media_svc_retvm_if(db_handle == NULL, MS_MEDIA_ERR_INVALID_PARAMETER, "Handle is NULL");
+ media_svc_retvm_if(!STRING_VALID(path), MS_MEDIA_ERR_INVALID_PARAMETER, "path is NULL");
int media_type = -1;
ret = _media_svc_get_media_type_by_path(db_handle, path, &media_type);
- media_svc_retv_if((ret != MEDIA_INFO_ERROR_NONE), ret);
+ media_svc_retv_if((ret != MS_MEDIA_ERR_NONE), ret);
if((media_type == MEDIA_SVC_MEDIA_TYPE_IMAGE) ||(media_type == MEDIA_SVC_MEDIA_TYPE_VIDEO)) {
/*Get thumbnail path to delete*/
ret = _media_svc_get_thumbnail_path_by_path(db_handle, path, thumb_path);
- media_svc_retv_if((ret != MEDIA_INFO_ERROR_NONE) && (ret != MEDIA_INFO_ERROR_DATABASE_NO_RECORD), ret);
+ media_svc_retv_if((ret != MS_MEDIA_ERR_NONE) && (ret != MS_MEDIA_ERR_DB_NO_RECORD), ret);
} else if ((media_type == MEDIA_SVC_MEDIA_TYPE_SOUND) ||(media_type == MEDIA_SVC_MEDIA_TYPE_MUSIC)) {
int count = 0;
ret = _media_svc_get_media_count_with_album_id_by_path(db_handle, path, &count);
- media_svc_retv_if((ret != MEDIA_INFO_ERROR_NONE), ret);
+ media_svc_retv_if((ret != MS_MEDIA_ERR_NONE), ret);
if (count == 1) {
/*Get thumbnail path to delete*/
ret = _media_svc_get_thumbnail_path_by_path(db_handle, path, thumb_path);
- media_svc_retv_if((ret != MEDIA_INFO_ERROR_NONE) && (ret != MEDIA_INFO_ERROR_DATABASE_NO_RECORD), ret);
+ media_svc_retv_if((ret != MS_MEDIA_ERR_NONE) && (ret != MS_MEDIA_ERR_DB_NO_RECORD), ret);
}
}
/* Get notification info */
media_svc_noti_item *noti_item = NULL;
ret = _media_svc_get_noti_info(handle, path, MS_MEDIA_ITEM_FILE, ¬i_item);
- media_svc_retv_if(ret != MEDIA_INFO_ERROR_NONE, ret);
+ media_svc_retv_if(ret != MS_MEDIA_ERR_NONE, ret);
/*Delete item*/
ret = _media_svc_delete_item_by_path(db_handle, path, uid);
- if (ret != MEDIA_INFO_ERROR_NONE) {
+ if (ret != MS_MEDIA_ERR_NONE) {
media_svc_error("_media_svc_delete_item_by_path failed : %d", ret);
_media_svc_destroy_noti_item(noti_item);
/* Get count of media, which contains same thumbnail for music */
if ((media_type == MEDIA_SVC_MEDIA_TYPE_SOUND) ||(media_type == MEDIA_SVC_MEDIA_TYPE_MUSIC)) {
ret = _media_svc_get_thumbnail_count(db_handle, thumb_path, &thumb_count);
- if (ret < MEDIA_INFO_ERROR_NONE) {
+ if (ret != MS_MEDIA_ERR_NONE) {
media_svc_error("Failed to get thumbnail count : %d", ret);
}
}
}
}
- return MEDIA_INFO_ERROR_NONE;
+ return MS_MEDIA_ERR_NONE;
}
int media_svc_delete_all_items_in_storage(MediaSvcHandle *handle, media_svc_storage_type_e storage_type, uid_t uid)
{
- int ret = MEDIA_INFO_ERROR_NONE;
+ int ret = MS_MEDIA_ERR_NONE;
sqlite3 * db_handle = (sqlite3 *)handle;
char * dirpath = NULL;
media_svc_debug("media_svc_delete_all_items_in_storage [%d]", storage_type);
- media_svc_retvm_if(db_handle == NULL, MEDIA_INFO_ERROR_INVALID_PARAMETER, "Handle is NULL");
+ media_svc_retvm_if(db_handle == NULL, MS_MEDIA_ERR_INVALID_PARAMETER, "Handle is NULL");
if ((storage_type != MEDIA_SVC_STORAGE_INTERNAL) && (storage_type != MEDIA_SVC_STORAGE_EXTERNAL)) {
media_svc_error("storage type is incorrect[%d]", storage_type);
- return MEDIA_INFO_ERROR_INVALID_PARAMETER;
+ return MS_MEDIA_ERR_INVALID_PARAMETER;
}
ret = _media_svc_truncate_table(db_handle, storage_type, uid);
- media_svc_retv_if(ret != MEDIA_INFO_ERROR_NONE, ret);
+ media_svc_retv_if(ret != MS_MEDIA_ERR_NONE, ret);
dirpath = (storage_type == MEDIA_SVC_STORAGE_INTERNAL) ? _media_svc_get_thumb_internal_path(uid) : _media_svc_get_thumb_external_path(uid);
/* remove thumbnails */
ret = _media_svc_remove_all_files_in_dir(dirpath);
- media_svc_retv_if(ret != MEDIA_INFO_ERROR_NONE, ret);
+ media_svc_retv_if(ret != MS_MEDIA_ERR_NONE, ret);
- return MEDIA_INFO_ERROR_NONE;
+ return MS_MEDIA_ERR_NONE;
}
int media_svc_delete_invalid_items_in_storage(MediaSvcHandle *handle, media_svc_storage_type_e storage_type, uid_t uid)
media_svc_debug_func();
- media_svc_retvm_if(db_handle == NULL, MEDIA_INFO_ERROR_INVALID_PARAMETER, "Handle is NULL");
+ media_svc_retvm_if(db_handle == NULL, MS_MEDIA_ERR_INVALID_PARAMETER, "Handle is NULL");
if ((storage_type != MEDIA_SVC_STORAGE_INTERNAL) && (storage_type != MEDIA_SVC_STORAGE_EXTERNAL)) {
media_svc_error("storage type is incorrect[%d]", storage_type);
- return MEDIA_INFO_ERROR_INVALID_PARAMETER;
+ return MS_MEDIA_ERR_INVALID_PARAMETER;
}
/*Delete from DB and remove thumbnail files*/
media_svc_debug_func();
- media_svc_retvm_if(db_handle == NULL, MEDIA_INFO_ERROR_INVALID_PARAMETER, "Handle is NULL");
+ media_svc_retvm_if(db_handle == NULL, MS_MEDIA_ERR_INVALID_PARAMETER, "Handle is NULL");
/*Delete from DB and remove thumbnail files*/
return _media_svc_delete_invalid_folder_items(db_handle, folder_path, uid);
{
sqlite3 * db_handle = (sqlite3 *)handle;
- media_svc_retvm_if(db_handle == NULL, MEDIA_INFO_ERROR_INVALID_PARAMETER, "Handle is NULL");
+ media_svc_retvm_if(db_handle == NULL, MS_MEDIA_ERR_INVALID_PARAMETER, "Handle is NULL");
if ((storage_type != MEDIA_SVC_STORAGE_INTERNAL) && (storage_type != MEDIA_SVC_STORAGE_EXTERNAL)) {
media_svc_error("storage type is incorrect[%d]", storage_type);
- return MEDIA_INFO_ERROR_INVALID_PARAMETER;
+ return MS_MEDIA_ERR_INVALID_PARAMETER;
}
return _media_svc_update_storage_item_validity(db_handle, storage_type, validity, uid);
{
sqlite3 * db_handle = (sqlite3 *)handle;
- media_svc_retvm_if(db_handle == NULL, MEDIA_INFO_ERROR_INVALID_PARAMETER, "Handle is NULL");
- media_svc_retvm_if(!STRING_VALID(folder_path), MEDIA_INFO_ERROR_INVALID_PARAMETER, "folder_path is NULL");
+ media_svc_retvm_if(db_handle == NULL, MS_MEDIA_ERR_INVALID_PARAMETER, "Handle is NULL");
+ media_svc_retvm_if(!STRING_VALID(folder_path), MS_MEDIA_ERR_INVALID_PARAMETER, "folder_path is NULL");
if(recursive)
return _media_svc_update_recursive_folder_item_validity(db_handle, folder_path, validity , uid);
int media_svc_refresh_item(MediaSvcHandle *handle, media_svc_storage_type_e storage_type, const char *path, uid_t uid)
{
- int ret = MEDIA_INFO_ERROR_NONE;
+ int ret = MS_MEDIA_ERR_NONE;
sqlite3 * db_handle = (sqlite3 *)handle;
media_svc_media_type_e media_type;
drm_content_info_s *drm_contentInfo = NULL;
- media_svc_retvm_if(db_handle == NULL, MEDIA_INFO_ERROR_INVALID_PARAMETER, "Handle is NULL");
- media_svc_retvm_if(!STRING_VALID(path), MEDIA_INFO_ERROR_INVALID_PARAMETER, "path is NULL");
+ media_svc_retvm_if(db_handle == NULL, MS_MEDIA_ERR_INVALID_PARAMETER, "Handle is NULL");
+ media_svc_retvm_if(!STRING_VALID(path), MS_MEDIA_ERR_INVALID_PARAMETER, "path is NULL");
if ((storage_type != MEDIA_SVC_STORAGE_INTERNAL) && (storage_type != MEDIA_SVC_STORAGE_EXTERNAL)) {
media_svc_error("storage type is incorrect[%d]", storage_type);
- return MEDIA_INFO_ERROR_INVALID_PARAMETER;
+ return MS_MEDIA_ERR_INVALID_PARAMETER;
}
-
media_svc_content_info_s content_info;
memset(&content_info, 0, sizeof(media_svc_content_info_s));
/*Set media info*/
ret = _media_svc_set_media_info(&content_info, storage_type, path, &media_type, TRUE, &drm_contentInfo);
- media_svc_retv_if(ret != MEDIA_INFO_ERROR_NONE, ret);
+ media_svc_retv_if(ret != MS_MEDIA_ERR_NONE, ret);
/* Initialize thumbnail information to remake thumbnail. */
char thumb_path[MEDIA_SVC_PATHNAME_SIZE + 1];
ret = _media_svc_get_thumbnail_path_by_path(handle, path, thumb_path);
- media_svc_retv_if(ret != MEDIA_INFO_ERROR_NONE, ret);
+ media_svc_retv_if(ret != MS_MEDIA_ERR_NONE, ret);
if (g_file_test(thumb_path, G_FILE_TEST_EXISTS) && (strncmp(thumb_path, _media_svc_get_thumb_default_path(uid), sizeof(_media_svc_get_thumb_default_path(uid))) != 0)) {
ret = _media_svc_remove_file(thumb_path);
- if (ret < MEDIA_INFO_ERROR_NONE) {
+ if (ret != MS_MEDIA_ERR_NONE) {
media_svc_error("_media_svc_remove_file failed : %s", thumb_path);
}
}
ret = _media_svc_update_thumbnail_path(handle, path, NULL, uid);
- media_svc_retv_if(ret != MEDIA_INFO_ERROR_NONE, ret);
+ media_svc_retv_if(ret != MS_MEDIA_ERR_NONE, ret);
/* Get notification info */
media_svc_noti_item *noti_item = NULL;
ret = _media_svc_get_noti_info(handle, path, MS_MEDIA_ITEM_FILE, ¬i_item);
- media_svc_retv_if(ret != MEDIA_INFO_ERROR_NONE, ret);
+ media_svc_retv_if(ret != MS_MEDIA_ERR_NONE, ret);
media_type = noti_item->media_type;
/*Do nothing.*/
} else if(media_type == MEDIA_SVC_MEDIA_TYPE_IMAGE) {
ret = _media_svc_extract_image_metadata(&content_info, media_type);
- if (ret != MEDIA_INFO_ERROR_NONE) {
+ if (ret != MS_MEDIA_ERR_NONE) {
_media_svc_destroy_noti_item(noti_item);
return ret;
}
} else {
ret = _media_svc_extract_media_metadata(handle, &content_info, media_type, drm_contentInfo, uid);
- if (ret != MEDIA_INFO_ERROR_NONE) {
+ if (ret != MS_MEDIA_ERR_NONE) {
_media_svc_destroy_noti_item(noti_item);
return ret;
}
#endif
ret = _media_svc_update_item_with_data(db_handle, &content_info, uid);
- if (ret == MEDIA_INFO_ERROR_NONE) {
+ if (ret == MS_MEDIA_ERR_NONE) {
media_svc_debug("Update is successful. Sending noti for this");
_media_svc_publish_noti(MS_MEDIA_ITEM_FILE, MS_MEDIA_ITEM_UPDATE, content_info.path, noti_item->media_type, noti_item->media_uuid, noti_item->mime_type);
} else {
int media_svc_rename_folder(MediaSvcHandle *handle, const char *src_path, const char *dst_path, uid_t uid)
{
sqlite3 * db_handle = (sqlite3 *)handle;
- int ret = MEDIA_INFO_ERROR_NONE;
+ int ret = MS_MEDIA_ERR_NONE;
- media_svc_retvm_if(db_handle == NULL, MEDIA_INFO_ERROR_INVALID_PARAMETER, "Handle is NULL");
- media_svc_retvm_if(src_path == NULL, MEDIA_INFO_ERROR_INVALID_PARAMETER, "src_path is NULL");
- media_svc_retvm_if(dst_path == NULL, MEDIA_INFO_ERROR_INVALID_PARAMETER, "dst_path is NULL");
+ media_svc_retvm_if(db_handle == NULL, MS_MEDIA_ERR_INVALID_PARAMETER, "Handle is NULL");
+ media_svc_retvm_if(src_path == NULL, MS_MEDIA_ERR_INVALID_PARAMETER, "src_path is NULL");
+ media_svc_retvm_if(dst_path == NULL, MS_MEDIA_ERR_INVALID_PARAMETER, "dst_path is NULL");
media_svc_debug("Src path : %s, Dst Path : %s", src_path, dst_path);
/* Get notification info */
media_svc_noti_item *noti_item = NULL;
ret = _media_svc_get_noti_info(handle, src_path, MS_MEDIA_ITEM_DIRECTORY, ¬i_item);
- media_svc_retv_if(ret != MEDIA_INFO_ERROR_NONE, ret);
+ media_svc_retv_if(ret != MS_MEDIA_ERR_NONE, ret);
ret = _media_svc_sql_begin_trans(handle,uid);
- media_svc_retv_if(ret != MEDIA_INFO_ERROR_NONE, ret);
+ media_svc_retv_if(ret != MS_MEDIA_ERR_NONE, ret);
/* Update all folder record's path, which are matched by old parent path */
char *update_folder_path_sql = NULL;
media_svc_error("failed to update folder path");
_media_svc_sql_rollback_trans(handle, uid);
- return MEDIA_INFO_ERROR_DATABASE_INTERNAL;
+ return MS_MEDIA_ERR_DB_INTERNAL;
}
/* Update all folder record's modified date, which are changed above */
media_svc_error("failed to update folder modified time");
_media_svc_sql_rollback_trans(handle, uid);
- return MEDIA_INFO_ERROR_DATABASE_INTERNAL;
+ return MS_MEDIA_ERR_DB_INTERNAL;
}
/* Update all items */
ret = sqlite3_prepare_v2(handle, select_all_sql, -1, &sql_stmt, NULL);
sqlite3_free((char *)select_all_sql);
- if (ret != SQLITE_OK) {
+ if (ret != MS_MEDIA_ERR_NONE) {
media_svc_error ("prepare error [%s]", sqlite3_errmsg(handle));
_media_svc_sql_rollback_trans(handle, uid);
- return MEDIA_INFO_ERROR_DATABASE_INTERNAL;
+ return MS_MEDIA_ERR_DB_INTERNAL;
}
while (1) {
media_uuid[sizeof(media_uuid) - 1] = '\0';
} else {
media_svc_error("media UUID is NULL");
- return MEDIA_INFO_ERROR_DATABASE_INVALID;
+ return MS_MEDIA_ERR_DB_INTERNAL;
}
if (STRING_VALID((const char *)sqlite3_column_text(sql_stmt, 1))) {
media_path[sizeof(media_path) - 1] = '\0';
} else {
media_svc_error("media path is NULL");
- return MEDIA_INFO_ERROR_DATABASE_INVALID;
+ return MS_MEDIA_ERR_DB_INTERNAL;
}
if (STRING_VALID((const char *)sqlite3_column_text(sql_stmt, 2))) {
media_svc_error("_media_svc_replace_path failed");
SQLITE3_FINALIZE(sql_stmt);
_media_svc_sql_rollback_trans(handle, uid);
- return MEDIA_INFO_ERROR_INTERNAL;
+ return MS_MEDIA_ERR_INTERNAL;
}
media_svc_debug("New media path : %s", replaced_path);
strncpy(media_new_thumb_path, _media_svc_get_thumb_default_path(uid), sizeof(media_new_thumb_path));
} else {
ret = _media_svc_get_store_type_by_path(replaced_path, &storage_type);
- if (ret < 0) {
+ if (ret != MS_MEDIA_ERR_NONE) {
media_svc_error("_media_svc_get_store_type_by_path failed : %d", ret);
SAFE_FREE(replaced_path);
_media_svc_sql_rollback_trans(handle,uid);
- return MEDIA_INFO_ERROR_DATABASE_INTERNAL;
+ return ret;
}
ret = _media_svc_get_thumbnail_path(storage_type, media_new_thumb_path, replaced_path, THUMB_EXT, uid);
- if (ret < 0) {
+ if (ret != MS_MEDIA_ERR_NONE) {
media_svc_error("_media_svc_get_thumbnail_path failed : %d", ret);
SAFE_FREE(replaced_path);
SQLITE3_FINALIZE(sql_stmt);
_media_svc_sql_rollback_trans(handle,uid);
- return MEDIA_INFO_ERROR_INTERNAL;
+ return ret;
}
}
SQLITE3_FINALIZE(sql_stmt);
_media_svc_sql_rollback_trans(handle,uid);
- return MEDIA_INFO_ERROR_DATABASE_INTERNAL;
+ return MS_MEDIA_ERR_DB_INTERNAL;
}
/* Rename thumbnail file of file system */
if ((!no_thumb) && (media_type == MEDIA_SVC_MEDIA_TYPE_IMAGE || media_type == MEDIA_SVC_MEDIA_TYPE_VIDEO)
&& (strncmp(media_thumb_path, _media_svc_get_thumb_default_path(uid), sizeof(_media_svc_get_thumb_default_path(uid))) != 0)) {
ret = _media_svc_rename_file(media_thumb_path, media_new_thumb_path);
- if (ret < 0) {
+ if (ret != MS_MEDIA_ERR_NONE) {
media_svc_error("_media_svc_rename_file failed : %d", ret);
}
}
SQLITE3_FINALIZE(sql_stmt);
ret = _media_svc_sql_end_trans(handle, uid);
- if (ret != MEDIA_INFO_ERROR_NONE) {
+ if (ret != MS_MEDIA_ERR_NONE) {
media_svc_error("mb_svc_sqlite3_commit_trans failed.. Now start to rollback\n");
_media_svc_sql_rollback_trans(handle,uid);
return ret;
_media_svc_publish_noti(MS_MEDIA_ITEM_DIRECTORY, MS_MEDIA_ITEM_UPDATE, src_path, -1, noti_item->media_uuid, NULL);
_media_svc_destroy_noti_item(noti_item);
- return MEDIA_INFO_ERROR_NONE;
+ return MS_MEDIA_ERR_NONE;
}
int media_svc_request_update_db(const char *db_query, uid_t uid)
{
- int ret = MEDIA_INFO_ERROR_NONE;
+ int ret = MS_MEDIA_ERR_NONE;
- media_svc_retvm_if(!STRING_VALID(db_query), MEDIA_INFO_ERROR_INVALID_PARAMETER, "db_query is NULL");
+ media_svc_retvm_if(!STRING_VALID(db_query), MS_MEDIA_ERR_INVALID_PARAMETER, "db_query is NULL");
ret = _media_svc_request_update_db(db_query, uid);
- return _media_svc_error_convert(ret);
+ return ret;
}
int media_svc_send_dir_update_noti(MediaSvcHandle *handle, const char *dir_path)
{
- int ret = MEDIA_INFO_ERROR_NONE;
+ int ret = MS_MEDIA_ERR_NONE;
sqlite3 * db_handle = (sqlite3 *)handle;
- media_svc_retvm_if(!STRING_VALID(dir_path), MEDIA_INFO_ERROR_INVALID_PARAMETER, "dir_path is NULL");
+ media_svc_retvm_if(!STRING_VALID(dir_path), MS_MEDIA_ERR_INVALID_PARAMETER, "dir_path is NULL");
/* Get notification info */
media_svc_noti_item *noti_item = NULL;
ret = _media_svc_get_noti_info(db_handle, dir_path, MS_MEDIA_ITEM_DIRECTORY, ¬i_item);
- media_svc_retv_if(ret != MEDIA_INFO_ERROR_NONE, ret);
+ media_svc_retv_if(ret != MS_MEDIA_ERR_NONE, ret);
ret = _media_svc_publish_noti(MS_MEDIA_ITEM_DIRECTORY, MS_MEDIA_ITEM_UPDATE, dir_path, -1, noti_item->media_uuid, NULL);
_media_svc_destroy_noti_item(noti_item);
media_svc_debug_func();
- media_svc_retvm_if(db_handle == NULL, MEDIA_INFO_ERROR_INVALID_PARAMETER, "Handle is NULL");
- media_svc_retvm_if(folder_path == NULL, MEDIA_INFO_ERROR_INVALID_PARAMETER, "folder_path is NULL");
- media_svc_retvm_if(count == NULL, MEDIA_INFO_ERROR_INVALID_PARAMETER, "count is NULL");
+ media_svc_retvm_if(db_handle == NULL, MS_MEDIA_ERR_INVALID_PARAMETER, "Handle is NULL");
+ media_svc_retvm_if(folder_path == NULL, MS_MEDIA_ERR_INVALID_PARAMETER, "folder_path is NULL");
+ media_svc_retvm_if(count == NULL, MS_MEDIA_ERR_INVALID_PARAMETER, "count is NULL");
return _media_svc_count_invalid_folder_items(db_handle, folder_path, count);
}
int media_svc_get_pinyin(MediaSvcHandle *handle, const char * src_str, char **pinyin_str)
{
- media_svc_retvm_if(!STRING_VALID(src_str), MEDIA_INFO_ERROR_INVALID_PARAMETER, "String is NULL");
+ media_svc_retvm_if(!STRING_VALID(src_str), MS_MEDIA_ERR_INVALID_PARAMETER, "String is NULL");
return _media_svc_get_pinyin_str(src_str, pinyin_str);
}
{
*support = _media_svc_check_pinyin_support();
- return MEDIA_INFO_ERROR_NONE;
+ return MS_MEDIA_ERR_NONE;
}
#include <stdio.h>
#include <stdlib.h>
#include <dlog.h>
+#include <errno.h>
#ifdef LOG_TAG
#undef LOG_TAG
} \
} while (0)
+#define media_svc_sec_debug(fmt, arg...) do { \
+ SECURE_LOGI(" "fmt"", ##arg); \
+ } while (0)
+
+#define media_svc_sec_warn(fmt, arg...) do { \
+ SECURE_LOGW(" "fmt"", ##arg); \
+ } while (0)
+
+#define media_svct_sec_error(fmt, arg...) do { \
+ SECURE_LOGE(" "fmt"", ##arg); \
+ } while (0)
+
+#define ERR_BUF_LENGHT 256
+#define media_svc_stderror(fmt) do { \
+ char buf[ERR_BUF_LENGHT] = {0,}; \
+ strerror_r(errno, buf, ERR_BUF_LENGHT); \
+ LOGE(fmt" : standard error= [%s]", buf); \
+ } while (0)
+
#ifdef _USE_LOG_FILE_
void mediainfo_init_file_debug();
void mediainfo_close_file_debug();
#ifndef _MEDIA_SVC_NOTI_H_
#define _MEDIA_SVC_NOTI_H_
+#include "media-svc-types.h"
#include "media-svc-env.h"
#include "media-svc-debug.h"
-#include "media-svc-error.h"
#include <media-util-noti.h>
typedef struct _media_svc_noti_item media_svc_noti_item;
};
void _media_svc_set_noti_from_pid(int pid);
-
int _media_svc_create_noti_list(int count);
int _media_svc_insert_item_to_noti_list(media_svc_content_info_s *content_info, int cnt);
int _media_svc_destroy_noti_list(int all_cnt);
#include <stdlib.h>
#include <stdio.h>
#include <dlfcn.h>
+#include <stdbool.h>
#include <media-svc.h>
#include <tzplatform_config.h>
}
svc_check_item = dlsym (funcHandle, "check_item");
- svc_connect = dlsym (funcHandle, "connect");
- svc_disconnect = dlsym (funcHandle, "disconnect");
+ svc_connect = dlsym (funcHandle, "connect_db");
+ svc_disconnect = dlsym (funcHandle, "disconnect_db");
svc_check_item_exist = dlsym (funcHandle, "check_item_exist");
svc_insert_item_immediately = dlsym (funcHandle, "insert_item_immediately");
svc_set_folder_item_validity = dlsym (funcHandle, "set_folder_item_validity");