From dcc5a404458f33ecd1ddbe9d93c2b27caf4e9afc Mon Sep 17 00:00:00 2001 From: "ji.yong.seo" Date: Fri, 3 Jul 2015 16:51:08 +0900 Subject: [PATCH] update code by Tizen coding convention Signed-off-by: ji.yong.seo Change-Id: I8790da40afcb3d54eb7c4d2092fd994cd686392c --- include/media-svc-types.h | 72 +- include/media-svc.h | 6 +- md5/md5.c | 6 +- md5/md5.h | 2 +- md5/media-svc-hash.c | 18 +- plugin/media-content-plugin.c | 231 +- src/common/media-svc-album.c | 25 +- src/common/media-svc-db-utils.c | 273 +- src/common/media-svc-debug.c | 8 +- src/common/media-svc-localize-utils.c | 34 +- src/common/media-svc-localize_ch.c | 4251 ++++++++++++------------- src/common/media-svc-localize_tw.c | 1091 ++++--- src/common/media-svc-media-folder.c | 101 +- src/common/media-svc-media.c | 394 ++- src/common/media-svc-noti.c | 42 +- src/common/media-svc-storage.c | 7 +- src/common/media-svc-util.c | 544 ++-- src/common/media-svc.c | 348 +- src/include/common/media-svc-album.h | 4 +- src/include/common/media-svc-db-utils.h | 6 +- src/include/common/media-svc-debug.h | 82 +- src/include/common/media-svc-env.h | 30 +- src/include/common/media-svc-localize-utils.h | 2 +- src/include/common/media-svc-localize_ch.h | 2 +- src/include/common/media-svc-localize_tw.h | 4 +- src/include/common/media-svc-media-folder.h | 2 +- src/include/common/media-svc-media.h | 2 +- src/include/common/media-svc-noti.h | 12 +- src/include/common/media-svc-util.h | 8 +- test/media-service-test.c | 58 +- test/plugin/media_svc_plugin_test.c | 159 +- 31 files changed, 3849 insertions(+), 3975 deletions(-) mode change 100644 => 100755 md5/md5.c mode change 100644 => 100755 md5/md5.h mode change 100644 => 100755 src/include/common/media-svc-localize_tw.h mode change 100644 => 100755 test/media-service-test.c diff --git a/include/media-svc-types.h b/include/media-svc-types.h index b9bc3c2..0b99685 100755 --- a/include/media-svc-types.h +++ b/include/media-svc-types.h @@ -31,39 +31,39 @@ typedef void MediaSvcHandle; /**< Handle */ /** * Type definition for storage type */ -typedef enum{ +typedef enum { MEDIA_SVC_STORAGE_INTERNAL = 0, /**< Internal storage*/ MEDIA_SVC_STORAGE_EXTERNAL = 1, /**< External storage*/ MEDIA_SVC_STORAGE_CLOUD = 100, /**< Cloud Storage*/ MEDIA_SVC_STORAGE_MAX, /**< Invalid storage*/ -}media_svc_storage_type_e; +} media_svc_storage_type_e; /** * Type definition for content type */ -typedef enum{ +typedef enum { MEDIA_SVC_MEDIA_TYPE_IMAGE = 0, /**< Image Content*/ MEDIA_SVC_MEDIA_TYPE_VIDEO = 1, /**< Video Content*/ MEDIA_SVC_MEDIA_TYPE_SOUND = 2, /**< Sound Content like Ringtone*/ MEDIA_SVC_MEDIA_TYPE_MUSIC = 3, /**< Music Content like mp3*/ MEDIA_SVC_MEDIA_TYPE_OTHER = 4, /**< Not media Content*/ -}media_svc_media_type_e; +} media_svc_media_type_e; /** * Media meta data information */ typedef struct { - char * title; /**< track title*/ - char * album; /**< album name*/ - char * artist; /**< artist name*/ - char * album_artist; /**< artist name*/ - char * genre; /**< genre of track*/ - char * composer; /**< composer name*/ - char * year; /**< year*/ - char * recorded_date; /**< recorded date*/ - char * copyright; /**< copyright*/ - char * track_num; /**< track number*/ - char * description; /**< description*/ + char *title; /**< track title*/ + char *album; /**< album name*/ + char *artist; /**< artist name*/ + char *album_artist; /**< artist name*/ + char *genre; /**< genre of track*/ + char *composer; /**< composer name*/ + char *year; /**< year*/ + char *recorded_date; /**< recorded date*/ + char *copyright; /**< copyright*/ + char *track_num; /**< track number*/ + char *description; /**< description*/ int bitrate; /**< bitrate*/ int samplerate; /**< samplerate*/ int channel; /**< channel*/ @@ -71,46 +71,46 @@ typedef struct { float longitude; /**< longitude*/ float latitude; /**< latitude*/ float altitude; /**< altitude*/ - char * exposure_time; /**< exposure_time*/ + char *exposure_time; /**< exposure_time*/ float fnumber; /**< fnumber*/ int iso; /**< iso*/ - char * model; /**< model*/ + char *model; /**< model*/ int width; /**< width*/ int height; /**< height*/ - char * datetaken; /**< datetaken*/ + char *datetaken; /**< datetaken*/ int orientation; /**< orientation*/ int rating; /**< user defined rating */ - char * weather; /**< weather of image */ + char *weather; /**< weather of image */ int bitpersample; /**< bitrate*/ - char * file_name_pinyin; /**< pinyin for file_name*/ - char * title_pinyin; /**< pinyin for title*/ - char * album_pinyin; /**< pinyin for album*/ - char * artist_pinyin; /**< pinyin for artist*/ - char * album_artist_pinyin; /**< pinyin for album_artist*/ - char * genre_pinyin; /**< pinyin for genre*/ - char * composer_pinyin; /**< pinyin for composer*/ - char * copyright_pinyin; /**< pinyin for copyright*/ - char * description_pinyin; /**< pinyin for description*/ + char *file_name_pinyin; /**< pinyin for file_name*/ + char *title_pinyin; /**< pinyin for title*/ + char *album_pinyin; /**< pinyin for album*/ + char *artist_pinyin; /**< pinyin for artist*/ + char *album_artist_pinyin; /**< pinyin for album_artist*/ + char *genre_pinyin; /**< pinyin for genre*/ + char *composer_pinyin; /**< pinyin for composer*/ + char *copyright_pinyin; /**< pinyin for copyright*/ + char *description_pinyin; /**< pinyin for description*/ } media_svc_content_meta_s; /** * Media data information */ typedef struct { - char * media_uuid; /**< Unique ID of item */ - char * path; /**< Full path of media file */ - char * file_name; /**< File name of media file. Display name */ - char * file_name_pinyin; /**< File name pinyin of media file. Display name */ + char *media_uuid; /**< Unique ID of item */ + char *path; /**< Full path of media file */ + char *file_name; /**< File name of media file. Display name */ + char *file_name_pinyin; /**< File name pinyin of media file. Display name */ int media_type; /**< Type of media file : internal/external */ - char * mime_type; /**< Full path and file name of media file */ + char *mime_type; /**< Full path and file name of media file */ unsigned long long size; /**< size */ time_t added_time; /**< added time, time_t */ time_t modified_time; /**< modified time, time_t */ time_t timeline; /**< timeline of media, time_t */ - char * folder_uuid; /**< Unique ID of folder */ + char *folder_uuid; /**< Unique ID of folder */ int album_id; /**< Unique ID of album */ - char * thumbnail_path; /**< Thumbnail image file path */ + char *thumbnail_path; /**< Thumbnail image file path */ int played_count; /**< played count */ int last_played_time; /**< last played time */ int last_played_position; /**< last played position */ @@ -118,7 +118,7 @@ typedef struct { int is_drm; /**< is_drm. o or 1 */ int sync_status; /**< sync_status */ int storage_type; /**< Storage of media file : internal/external */ - char * storage_uuid; /**< Unique ID of storage */ + char *storage_uuid; /**< Unique ID of storage */ media_svc_content_meta_s media_meta; /**< meta data structure for audio files */ } media_svc_content_info_s; diff --git a/include/media-svc.h b/include/media-svc.h index c892688..4259caa 100755 --- a/include/media-svc.h +++ b/include/media-svc.h @@ -33,7 +33,7 @@ extern "C" { #endif -int media_svc_connect(MediaSvcHandle **handle,uid_t uid); +int media_svc_connect(MediaSvcHandle **handle, uid_t uid); int media_svc_disconnect(MediaSvcHandle *handle); int media_svc_create_table(MediaSvcHandle *handle, uid_t uid); int media_svc_check_item_exist_by_path(MediaSvcHandle *handle, const char *path); @@ -63,10 +63,10 @@ int media_svc_send_dir_update_noti(MediaSvcHandle *handle, const char *dir_path) int media_svc_count_invalid_items_in_folder(MediaSvcHandle *handle, const char *folder_path, int *count); int media_svc_check_db_upgrade(MediaSvcHandle *handle, uid_t uid); int media_svc_check_db_corrupt(MediaSvcHandle *handle); -int media_svc_get_folder_list(MediaSvcHandle *handle, char* start_path, char ***folder_list, time_t **modified_time_list, int **item_num_list, int *count); +int media_svc_get_folder_list(MediaSvcHandle *handle, char *start_path, char ***folder_list, time_t **modified_time_list, int **item_num_list, int *count); int media_svc_update_folder_time(MediaSvcHandle *handle, const char *folder_path, uid_t uid); int media_svc_publish_noti(MediaSvcHandle *handle, media_item_type_e update_item, media_item_update_type_e update_type, const char *path, media_type_e media_type, const char *uuid, const char *mime_type); -int media_svc_get_pinyin(MediaSvcHandle *handle, const char * src_str, char **pinyin_str); +int media_svc_get_pinyin(MediaSvcHandle *handle, const char *src_str, char **pinyin_str); int media_svc_check_pinyin_support(bool *support); int media_svc_update_item_begin(MediaSvcHandle *handle, int data_cnt); int media_svc_update_item_end(MediaSvcHandle *handle, uid_t uid); diff --git a/md5/md5.c b/md5/md5.c old mode 100644 new mode 100755 index 59b47ba..3782384 --- a/md5/md5.c +++ b/md5/md5.c @@ -34,7 +34,7 @@ void byteReverse(unsigned char *buf, unsigned longs) { uint32_t t; do { - t = (uint32_t) ((unsigned)buf[3] << 8 | buf[2]) << 16 | + t = (uint32_t)((unsigned)buf[3] << 8 | buf[2]) << 16 | ((unsigned)buf[1] << 8 | buf[0]); *(uint32_t *) buf = t; buf += 4; @@ -108,7 +108,7 @@ void MD5Update(MD5_CTX *ctx, unsigned char const *buf, unsigned len) } /* - * Final wrapup - pad to 64-byte boundary with the bit pattern + * Final wrapup - pad to 64-byte boundary with the bit pattern * 1 0* (64-bit count of bits processed, MSB-first) */ void MD5Final(unsigned char digest[16], MD5_CTX *ctx) @@ -162,7 +162,7 @@ void MD5Final(unsigned char digest[16], MD5_CTX *ctx) /* This is the central step in the MD5 algorithm. */ #define MD5STEP(f, w, x, y, z, data, s) \ -(w += f(x, y, z) + data, w = w<>(32-s), w += x) + (w += f(x, y, z) + data, w = w<>(32-s), w += x) /* * The core of the MD5 algorithm, this alters an existing MD5 hash to diff --git a/md5/md5.h b/md5/md5.h old mode 100644 new mode 100755 index dac53fb..450f540 --- a/md5/md5.h +++ b/md5/md5.h @@ -31,7 +31,7 @@ typedef struct MD5Context { } MD5_CTX; extern void MD5Init(MD5_CTX *context); -extern void MD5Update(MD5_CTX *context,unsigned char const *buf,unsigned len); +extern void MD5Update(MD5_CTX *context, unsigned char const *buf, unsigned len); extern void MD5Final(unsigned char digest[MD5_HASHBYTES], MD5_CTX *context); extern void MD5Transform(uint32_t buf[4], uint32_t const in[16]); diff --git a/md5/media-svc-hash.c b/md5/media-svc-hash.c index 98ffcdf..affe10b 100755 --- a/md5/media-svc-hash.c +++ b/md5/media-svc-hash.c @@ -27,24 +27,24 @@ static const char ACCEPTABLE_URI_CHARS[96] = { - /* ! " # $ % & ' ( ) * + , - . / */ + /* ! " # $ % & ' ( ) * + , - . / */ 0x00, 0x3F, 0x20, 0x20, 0x28, 0x00, 0x2C, 0x3F, 0x3F, 0x3F, 0x3F, 0x2A, - 0x28, 0x3F, 0x3F, 0x1C, + 0x28, 0x3F, 0x3F, 0x1C, /* 0 1 2 3 4 5 6 7 8 9 : ; < = > ? */ 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x38, 0x20, - 0x20, 0x2C, 0x20, 0x20, + 0x20, 0x2C, 0x20, 0x20, /* @ A B C D E F G H I J K L M N O */ 0x38, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, - 0x3F, 0x3F, 0x3F, 0x3F, + 0x3F, 0x3F, 0x3F, 0x3F, /* P Q R S T U V W X Y Z [ \ ] ^ _ */ 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x20, - 0x20, 0x20, 0x20, 0x3F, + 0x20, 0x20, 0x20, 0x3F, /* ` a b c d e f g h i j k l m n o */ 0x20, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, - 0x3F, 0x3F, 0x3F, 0x3F, + 0x3F, 0x3F, 0x3F, 0x3F, /* p q r s t u v w x y z { | } ~ DEL */ 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x20, - 0x20, 0x20, 0x3F, 0x20 + 0x20, 0x20, 0x3F, 0x20 }; char *_mb_svc_generate_hash_name(const char *file) @@ -69,7 +69,7 @@ char *_mb_svc_generate_hash_name(const char *file) memset(md5out, 0, sizeof(md5out)); #define _check_uri_char(c) \ -((c) >= 32 && (c) < 128 && (ACCEPTABLE_URI_CHARS[(c) - 32] & 0x08)) + ((c) >= 32 && (c) < 128 && (ACCEPTABLE_URI_CHARS[(c) - 32] & 0x08)) uri = alloca(length); if (uri == NULL) { @@ -120,7 +120,7 @@ int mb_svc_generate_hash_code(const char *origin_path, char *hash_code, int max_ } strncpy(hash_code, hash, max_length); - hash_code[strlen(hash_code)] ='\0'; + hash_code[strlen(hash_code)] = '\0'; return MS_MEDIA_ERR_NONE; } diff --git a/plugin/media-content-plugin.c b/plugin/media-content-plugin.c index b4333b8..2374a36 100755 --- a/plugin/media-content-plugin.c +++ b/plugin/media-content-plugin.c @@ -35,7 +35,7 @@ (((storage == MEDIA_SVC_STORAGE_INTERNAL) || (storage == MEDIA_SVC_STORAGE_EXTERNAL)) ? TRUE : FALSE) -typedef enum{ +typedef enum { ERR_HANDLE = 1, ERR_FILE_PATH, ERR_FOLDER_PATH, @@ -44,44 +44,44 @@ typedef enum{ ERR_STORAGE_TYPE, ERR_CHECK_ITEM, ERR_MAX, -}media_svc_error_type_e; +} media_svc_error_type_e; -static void __set_error_message(int err_type, char ** err_msg); +static void __set_error_message(int err_type, char **err_msg); -static void __set_error_message(int err_type, char ** err_msg) +static void __set_error_message(int err_type, char **err_msg) { if (err_msg) *err_msg = NULL; else return; - if(err_type == ERR_HANDLE) + if (err_type == ERR_HANDLE) *err_msg = strdup("invalid handle"); - else if(err_type == ERR_FILE_PATH) + else if (err_type == ERR_FILE_PATH) *err_msg = strdup("invalid file path"); - else if(err_type == ERR_FOLDER_PATH) + else if (err_type == ERR_FOLDER_PATH) *err_msg = strdup("invalid folder path"); - else if(err_type == ERR_MIME_TYPE) + else if (err_type == ERR_MIME_TYPE) *err_msg = strdup("invalid mime type"); - else if(err_type == ERR_NOT_MEDIAFILE) + else if (err_type == ERR_NOT_MEDIAFILE) *err_msg = strdup("not media content"); - else if(err_type == ERR_STORAGE_TYPE) + else if (err_type == ERR_STORAGE_TYPE) *err_msg = strdup("invalid storage type"); - else if(err_type == ERR_CHECK_ITEM) + else if (err_type == ERR_CHECK_ITEM) *err_msg = strdup("item does not exist"); - else if(err_type == MS_MEDIA_ERR_DB_CONNECT_FAIL) + else if (err_type == MS_MEDIA_ERR_DB_CONNECT_FAIL) *err_msg = strdup("DB connect error"); - else if(err_type == MS_MEDIA_ERR_DB_DISCONNECT_FAIL) + else if (err_type == MS_MEDIA_ERR_DB_DISCONNECT_FAIL) *err_msg = strdup("DB disconnect error"); - else if(err_type == MS_MEDIA_ERR_INVALID_PARAMETER) + else if (err_type == MS_MEDIA_ERR_INVALID_PARAMETER) *err_msg = strdup("invalid parameter"); - else if(err_type == MS_MEDIA_ERR_DB_INTERNAL) + else if (err_type == MS_MEDIA_ERR_DB_INTERNAL) *err_msg = strdup("DB internal error"); - else if(err_type == MS_MEDIA_ERR_DB_NO_RECORD) + else if (err_type == MS_MEDIA_ERR_DB_NO_RECORD) *err_msg = strdup("not found in DB"); - else if(err_type == MS_MEDIA_ERR_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) + else if (err_type == MS_MEDIA_ERR_DB_CORRUPT) *err_msg = strdup("DB corrupt error"); else *err_msg = strdup("error unknown"); @@ -89,11 +89,11 @@ static void __set_error_message(int err_type, char ** err_msg) return; } -int connect_db(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); - if(ret < 0) { + if (ret < 0) { __set_error_message(ret, err_msg); return MEDIA_SVC_PLUGIN_ERROR; } @@ -101,17 +101,17 @@ int connect_db(void ** handle, uid_t uid, char ** err_msg) return MEDIA_SVC_PLUGIN_ERROR_NONE; } -int disconnect_db(void * handle, char ** err_msg) +int disconnect_db(void *handle, char **err_msg) { int ret = MEDIA_SVC_PLUGIN_ERROR_NONE; - if(handle == NULL) { + if (handle == NULL) { __set_error_message(ERR_HANDLE, err_msg); return MEDIA_SVC_PLUGIN_ERROR; } ret = media_svc_disconnect(handle); - if(ret < 0) { + if (ret < 0) { __set_error_message(ret, err_msg); return MEDIA_SVC_PLUGIN_ERROR; } @@ -119,12 +119,12 @@ int disconnect_db(void * handle, char ** err_msg) return MEDIA_SVC_PLUGIN_ERROR_NONE; } -int check_item_exist(void* handle, const char *file_path, bool *modified, char ** err_msg) +int check_item_exist(void *handle, const char *file_path, bool *modified, char **err_msg) { int ret = MEDIA_SVC_PLUGIN_ERROR_NONE; *modified = TRUE; - if(handle == NULL) { + if (handle == NULL) { __set_error_message(ERR_HANDLE, err_msg); return MEDIA_SVC_PLUGIN_ERROR; } @@ -135,41 +135,41 @@ int check_item_exist(void* handle, const char *file_path, bool *modified, char * } ret = media_svc_check_item_exist_by_path(handle, file_path); - if(ret == MS_MEDIA_ERR_NONE) { + if (ret == MS_MEDIA_ERR_NONE) { time_t modified_time = 0; unsigned long long file_size = 0; struct stat st; ret = media_svc_get_file_info(handle, file_path, &modified_time, &file_size); - if(ret == MS_MEDIA_ERR_NONE) { + if (ret == MS_MEDIA_ERR_NONE) { memset(&st, 0, sizeof(struct stat)); if (stat(file_path, &st) == 0) { - if((st.st_mtime != modified_time) || (st.st_size != file_size)) + if ((st.st_mtime != modified_time) || (st.st_size != file_size)) *modified = TRUE; else *modified = FALSE; } } - return MEDIA_SVC_PLUGIN_ERROR_NONE; //exist + return MEDIA_SVC_PLUGIN_ERROR_NONE; /*exist */ } __set_error_message(ERR_CHECK_ITEM, err_msg); - return MEDIA_SVC_PLUGIN_ERROR; //not exist + return MEDIA_SVC_PLUGIN_ERROR; /*not exist */ } -int insert_item_begin(void * handle, int item_cnt, int with_noti, int from_pid, char ** err_msg) +int insert_item_begin(void *handle, int item_cnt, int with_noti, int from_pid, char **err_msg) { int ret = MEDIA_SVC_PLUGIN_ERROR_NONE; - if(handle == NULL) { + if (handle == NULL) { __set_error_message(ERR_HANDLE, err_msg); return MEDIA_SVC_PLUGIN_ERROR; } ret = media_svc_insert_item_begin(handle, item_cnt, with_noti, from_pid); - if(ret < 0) { + if (ret < 0) { __set_error_message(ret, err_msg); return MEDIA_SVC_PLUGIN_ERROR; } @@ -177,17 +177,17 @@ int insert_item_begin(void * handle, int item_cnt, int with_noti, int from_pid, return MEDIA_SVC_PLUGIN_ERROR_NONE; } -int insert_item_end(void * handle, uid_t uid, char ** err_msg) +int insert_item_end(void *handle, uid_t uid, char **err_msg) { int ret = MEDIA_SVC_PLUGIN_ERROR_NONE; - if(handle == NULL) { + if (handle == NULL) { __set_error_message(ERR_HANDLE, err_msg); return MEDIA_SVC_PLUGIN_ERROR; } ret = media_svc_insert_item_end(handle, uid); - if(ret < 0) { + if (ret < 0) { __set_error_message(ret, err_msg); return MEDIA_SVC_PLUGIN_ERROR; } @@ -195,11 +195,11 @@ int insert_item_end(void * handle, uid_t uid, char ** err_msg) return MEDIA_SVC_PLUGIN_ERROR_NONE; } -int insert_item(void * handle, const char *file_path, int storage_type, uid_t uid, char ** err_msg) +int insert_item(void *handle, const char *file_path, int storage_type, uid_t uid, char **err_msg) { int ret = MEDIA_SVC_PLUGIN_ERROR_NONE; - if(handle == NULL) { + if (handle == NULL) { __set_error_message(ERR_HANDLE, err_msg); return MEDIA_SVC_PLUGIN_ERROR; } @@ -209,13 +209,13 @@ int insert_item(void * handle, const char *file_path, int storage_type, uid_t ui return MEDIA_SVC_PLUGIN_ERROR; } - if(!STORAGE_VALID(storage_type)) { + if (!STORAGE_VALID(storage_type)) { __set_error_message(ERR_STORAGE_TYPE, err_msg); return MEDIA_SVC_PLUGIN_ERROR; } ret = media_svc_insert_item_bulk(handle, storage_type, file_path, FALSE, uid); - if(ret < 0) { + if (ret < 0) { __set_error_message(ret, err_msg); return MEDIA_SVC_PLUGIN_ERROR; } @@ -223,11 +223,11 @@ int insert_item(void * handle, const char *file_path, int storage_type, uid_t ui return MEDIA_SVC_PLUGIN_ERROR_NONE; } -int insert_item_immediately(void * handle, const char *file_path, int storage_type, uid_t uid, char ** err_msg) +int insert_item_immediately(void *handle, const char *file_path, int storage_type, uid_t uid, char **err_msg) { int ret = MEDIA_SVC_PLUGIN_ERROR_NONE; - if(handle == NULL) { + if (handle == NULL) { __set_error_message(ERR_HANDLE, err_msg); return MEDIA_SVC_PLUGIN_ERROR; } @@ -237,13 +237,13 @@ int insert_item_immediately(void * handle, const char *file_path, int storage_ty return MEDIA_SVC_PLUGIN_ERROR; } - if(!STORAGE_VALID(storage_type)) { + if (!STORAGE_VALID(storage_type)) { __set_error_message(ERR_STORAGE_TYPE, err_msg); return MEDIA_SVC_PLUGIN_ERROR; } ret = media_svc_insert_item_immediately(handle, storage_type, file_path, uid); - if(ret < 0) { + if (ret < 0) { __set_error_message(ret, err_msg); return MEDIA_SVC_PLUGIN_ERROR; } @@ -251,11 +251,11 @@ int insert_item_immediately(void * handle, const char *file_path, int storage_ty return MEDIA_SVC_PLUGIN_ERROR_NONE; } -int insert_burst_item(void * handle, const char *file_path, int storage_type, uid_t uid, char ** err_msg) +int insert_burst_item(void *handle, const char *file_path, int storage_type, uid_t uid, char **err_msg) { int ret = MEDIA_SVC_PLUGIN_ERROR_NONE; - if(handle == NULL) { + if (handle == NULL) { __set_error_message(ERR_HANDLE, err_msg); return MEDIA_SVC_PLUGIN_ERROR; } @@ -265,13 +265,13 @@ int insert_burst_item(void * handle, const char *file_path, int storage_type, ui return MEDIA_SVC_PLUGIN_ERROR; } - if(!STORAGE_VALID(storage_type)) { + if (!STORAGE_VALID(storage_type)) { __set_error_message(ERR_STORAGE_TYPE, err_msg); return MEDIA_SVC_PLUGIN_ERROR; } ret = media_svc_insert_item_bulk(handle, storage_type, file_path, TRUE, uid); - if(ret < 0) { + if (ret < 0) { __set_error_message(ret, err_msg); return MEDIA_SVC_PLUGIN_ERROR; } @@ -279,22 +279,22 @@ int insert_burst_item(void * handle, const char *file_path, int storage_type, ui return MEDIA_SVC_PLUGIN_ERROR_NONE; } -int set_all_storage_items_validity(void * handle, int storage_type, int validity, uid_t uid, char ** err_msg) +int set_all_storage_items_validity(void *handle, int storage_type, int validity, uid_t uid, char **err_msg) { int ret = MEDIA_SVC_PLUGIN_ERROR_NONE; - if(handle == NULL) { + if (handle == NULL) { __set_error_message(ERR_HANDLE, err_msg); return MEDIA_SVC_PLUGIN_ERROR; } - if(!STORAGE_VALID(storage_type)) { + if (!STORAGE_VALID(storage_type)) { __set_error_message(ERR_STORAGE_TYPE, err_msg); return MEDIA_SVC_PLUGIN_ERROR; } ret = media_svc_set_all_storage_items_validity(handle, storage_type, validity, uid); - if(ret < 0) { + if (ret < 0) { __set_error_message(ret, err_msg); return MEDIA_SVC_PLUGIN_ERROR; } @@ -302,11 +302,11 @@ int set_all_storage_items_validity(void * handle, int storage_type, int validity return MEDIA_SVC_PLUGIN_ERROR_NONE; } -int set_folder_item_validity(void * handle, const char * folder_path, int validity, int recursive, uid_t uid, char ** err_msg) +int set_folder_item_validity(void *handle, const char *folder_path, int validity, int recursive, uid_t uid, char **err_msg) { int ret = MEDIA_SVC_PLUGIN_ERROR_NONE; - if(handle == NULL) { + if (handle == NULL) { __set_error_message(ERR_HANDLE, err_msg); return MEDIA_SVC_PLUGIN_ERROR; } @@ -317,7 +317,7 @@ int set_folder_item_validity(void * handle, const char * folder_path, int validi } ret = media_svc_set_folder_items_validity(handle, folder_path, validity, recursive, uid); - if(ret < 0) { + if (ret < 0) { __set_error_message(ret, err_msg); return MEDIA_SVC_PLUGIN_ERROR; } @@ -325,17 +325,17 @@ int set_folder_item_validity(void * handle, const char * folder_path, int validi return MEDIA_SVC_PLUGIN_ERROR_NONE; } -int set_item_validity_begin(void * handle, int item_cnt, char ** err_msg) +int set_item_validity_begin(void *handle, int item_cnt, char **err_msg) { int ret = MEDIA_SVC_PLUGIN_ERROR_NONE; - if(handle == NULL) { + if (handle == NULL) { __set_error_message(ERR_HANDLE, err_msg); return MEDIA_SVC_PLUGIN_ERROR; } ret = media_svc_set_item_validity_begin(handle, item_cnt); - if(ret < 0) { + if (ret < 0) { __set_error_message(ret, err_msg); return MEDIA_SVC_PLUGIN_ERROR; } @@ -343,17 +343,17 @@ int set_item_validity_begin(void * handle, int item_cnt, char ** err_msg) return MEDIA_SVC_PLUGIN_ERROR_NONE; } -int set_item_validity_end(void * handle, uid_t uid, char ** err_msg) +int set_item_validity_end(void *handle, uid_t uid, char **err_msg) { int ret = MEDIA_SVC_PLUGIN_ERROR_NONE; - if(handle == NULL) { + if (handle == NULL) { __set_error_message(ERR_HANDLE, err_msg); return MEDIA_SVC_PLUGIN_ERROR; } ret = media_svc_set_item_validity_end(handle, uid); - if(ret < 0) { + if (ret < 0) { __set_error_message(ret, err_msg); return MEDIA_SVC_PLUGIN_ERROR; } @@ -361,11 +361,11 @@ int set_item_validity_end(void * handle, uid_t uid, char ** err_msg) return MEDIA_SVC_PLUGIN_ERROR_NONE; } -int set_item_validity(void * handle, const char *file_path, int storage_type, int validity, uid_t uid, char ** err_msg) +int set_item_validity(void *handle, const char *file_path, int storage_type, int validity, uid_t uid, char **err_msg) { int ret = MEDIA_SVC_PLUGIN_ERROR_NONE; - if(handle == NULL) { + if (handle == NULL) { __set_error_message(ERR_HANDLE, err_msg); return MEDIA_SVC_PLUGIN_ERROR; } @@ -375,14 +375,14 @@ int set_item_validity(void * handle, const char *file_path, int storage_type, in return MEDIA_SVC_PLUGIN_ERROR; } - if(!STORAGE_VALID(storage_type)) { + if (!STORAGE_VALID(storage_type)) { __set_error_message(ERR_STORAGE_TYPE, err_msg); return MEDIA_SVC_PLUGIN_ERROR; } ret = media_svc_set_item_validity(handle, file_path, validity, uid); - if(ret < 0) { + if (ret < 0) { __set_error_message(ret, err_msg); return MEDIA_SVC_PLUGIN_ERROR; } @@ -390,11 +390,11 @@ int set_item_validity(void * handle, const char *file_path, int storage_type, in return MEDIA_SVC_PLUGIN_ERROR_NONE; } -int delete_item(void * handle, const char *file_path, uid_t uid, char ** err_msg) +int delete_item(void *handle, const char *file_path, uid_t uid, char **err_msg) { int ret = MEDIA_SVC_PLUGIN_ERROR_NONE; - if(handle == NULL) { + if (handle == NULL) { __set_error_message(ERR_HANDLE, err_msg); return MEDIA_SVC_PLUGIN_ERROR; } @@ -405,72 +405,71 @@ int delete_item(void * handle, const char *file_path, uid_t uid, char ** err_msg } ret = media_svc_check_item_exist_by_path(handle, file_path); - if(ret == 0) { + if (ret == 0) { ret = media_svc_delete_item_by_path(handle, "media", file_path, uid); - if(ret < 0) { + if (ret < 0) { __set_error_message(ret, err_msg); return MEDIA_SVC_PLUGIN_ERROR; - } - else + } else return MEDIA_SVC_PLUGIN_ERROR_NONE; } - __set_error_message(ERR_CHECK_ITEM, err_msg); //not exist in DB so can't delete item. + __set_error_message(ERR_CHECK_ITEM, err_msg); /*not exist in DB so can't delete item. */ return MEDIA_SVC_PLUGIN_ERROR; } -int delete_all_items_in_storage(void * handle, int storage_type, uid_t uid, char ** err_msg) +int delete_all_items_in_storage(void *handle, int storage_type, uid_t uid, char **err_msg) { int ret = MEDIA_SVC_PLUGIN_ERROR_NONE; - if(handle == NULL) { + if (handle == NULL) { __set_error_message(ERR_HANDLE, err_msg); return MEDIA_SVC_PLUGIN_ERROR; } - if(!STORAGE_VALID(storage_type)) { + if (!STORAGE_VALID(storage_type)) { __set_error_message(ERR_STORAGE_TYPE, err_msg); return MEDIA_SVC_PLUGIN_ERROR; } ret = media_svc_delete_all_items_in_storage(handle, storage_type, uid); - if(ret < 0) { - __set_error_message(ret, err_msg); - return MEDIA_SVC_PLUGIN_ERROR; + if (ret < 0) { + __set_error_message(ret, err_msg); + return MEDIA_SVC_PLUGIN_ERROR; } return MEDIA_SVC_PLUGIN_ERROR_NONE; } -int delete_all_invalid_items_in_storage(void * handle, int storage_type, uid_t uid, char ** err_msg) +int delete_all_invalid_items_in_storage(void *handle, int storage_type, uid_t uid, char **err_msg) { int ret = MEDIA_SVC_PLUGIN_ERROR_NONE; - if(handle == NULL) { + if (handle == NULL) { __set_error_message(ERR_HANDLE, err_msg); return MEDIA_SVC_PLUGIN_ERROR; } - if(!STORAGE_VALID(storage_type)) { + if (!STORAGE_VALID(storage_type)) { __set_error_message(ERR_STORAGE_TYPE, err_msg); return MEDIA_SVC_PLUGIN_ERROR; } ret = media_svc_delete_invalid_items_in_storage(handle, storage_type, uid); - if(ret < 0) { - __set_error_message(ret, err_msg); - return MEDIA_SVC_PLUGIN_ERROR; + if (ret < 0) { + __set_error_message(ret, err_msg); + return MEDIA_SVC_PLUGIN_ERROR; } return MEDIA_SVC_PLUGIN_ERROR_NONE; } -int delete_all_invalid_items_in_folder(void * handle, const char *folder_path, uid_t uid, char ** err_msg) +int delete_all_invalid_items_in_folder(void *handle, const char *folder_path, uid_t uid, char **err_msg) { int ret = MEDIA_SVC_PLUGIN_ERROR_NONE; - if(handle == NULL) { + if (handle == NULL) { __set_error_message(ERR_HANDLE, err_msg); return MEDIA_SVC_PLUGIN_ERROR; } @@ -481,7 +480,7 @@ int delete_all_invalid_items_in_folder(void * handle, const char *folder_path, u } ret = media_svc_delete_invalid_items_in_folder(handle, folder_path, uid); - if(ret < 0) { + if (ret < 0) { __set_error_message(ret, err_msg); return MEDIA_SVC_PLUGIN_ERROR; } @@ -507,7 +506,7 @@ int update_end(uid_t uid) return MEDIA_SVC_PLUGIN_ERROR_NONE; } -int send_dir_update_noti(void * handle, const char *dir_path, char **err_msg) +int send_dir_update_noti(void *handle, const char *dir_path, char **err_msg) { int ret = MEDIA_SVC_PLUGIN_ERROR_NONE; @@ -525,16 +524,16 @@ int send_dir_update_noti(void * handle, const char *dir_path, char **err_msg) return MEDIA_SVC_PLUGIN_ERROR_NONE; } -int count_delete_items_in_folder(void * handle, const char *folder_path, int *count, char ** err_msg) +int count_delete_items_in_folder(void *handle, const char *folder_path, int *count, char **err_msg) { int ret = MEDIA_SVC_PLUGIN_ERROR_NONE; - if(handle == NULL) { + if (handle == NULL) { __set_error_message(ERR_HANDLE, err_msg); return MEDIA_SVC_PLUGIN_ERROR; } - if(count == NULL) { + if (count == NULL) { __set_error_message(ERR_HANDLE, err_msg); return MEDIA_SVC_PLUGIN_ERROR; } @@ -545,7 +544,7 @@ int count_delete_items_in_folder(void * handle, const char *folder_path, int *co } ret = media_svc_count_invalid_items_in_folder(handle, folder_path, count); - if(ret < 0) { + if (ret < 0) { __set_error_message(ret, err_msg); return MEDIA_SVC_PLUGIN_ERROR; } @@ -553,20 +552,20 @@ int count_delete_items_in_folder(void * handle, const char *folder_path, int *co return MEDIA_SVC_PLUGIN_ERROR_NONE; } -int check_db(void * handle, uid_t uid, char **err_msg) +int check_db(void *handle, uid_t uid, char **err_msg) { int ret = MEDIA_SVC_PLUGIN_ERROR_NONE; /*check db schema*/ ret = media_svc_create_table(handle, uid); - if(ret < 0) { + if (ret < 0) { __set_error_message(ret, err_msg); return MEDIA_SVC_PLUGIN_ERROR; } /*check db version*/ ret = media_svc_check_db_upgrade(handle, uid); - if(ret < 0) { + if (ret < 0) { __set_error_message(ret, err_msg); return MEDIA_SVC_PLUGIN_ERROR; } @@ -574,13 +573,13 @@ int check_db(void * handle, uid_t uid, char **err_msg) return MEDIA_SVC_PLUGIN_ERROR_NONE; } -int check_db_corrupt(void * handle, char **err_msg) +int check_db_corrupt(void *handle, char **err_msg) { int ret = MEDIA_SVC_PLUGIN_ERROR_NONE; /*check db version*/ ret = media_svc_check_db_corrupt(handle); - if(ret < 0) { + if (ret < 0) { __set_error_message(ret, err_msg); return MEDIA_SVC_PLUGIN_ERROR; } @@ -588,22 +587,22 @@ int check_db_corrupt(void * handle, char **err_msg) return MEDIA_SVC_PLUGIN_ERROR_NONE; } -int get_folder_list(void * handle, char* start_path, char ***folder_list, int **modified_time_list, int **item_num_list, int *count, char ** err_msg) +int get_folder_list(void *handle, char *start_path, char ***folder_list, int **modified_time_list, int **item_num_list, int *count, char **err_msg) { int ret = MEDIA_SVC_PLUGIN_ERROR_NONE; - if(handle == NULL) { + if (handle == NULL) { __set_error_message(ERR_HANDLE, err_msg); return MEDIA_SVC_PLUGIN_ERROR; } - if(count == NULL) { + if (count == NULL) { __set_error_message(ERR_HANDLE, err_msg); return MEDIA_SVC_PLUGIN_ERROR; } - ret = media_svc_get_folder_list(handle, start_path, folder_list, (time_t**)modified_time_list, item_num_list, count); - if(ret < 0) { + ret = media_svc_get_folder_list(handle, start_path, folder_list, (time_t **)modified_time_list, item_num_list, count); + if (ret < 0) { __set_error_message(ret, err_msg); return MEDIA_SVC_PLUGIN_ERROR; } @@ -611,22 +610,22 @@ int get_folder_list(void * handle, char* start_path, char ***folder_list, int ** return MEDIA_SVC_PLUGIN_ERROR_NONE; } -int update_folder_time(void * handle, char *folder_path, uid_t uid, char ** err_msg) +int update_folder_time(void *handle, char *folder_path, uid_t uid, char **err_msg) { int ret = MEDIA_SVC_PLUGIN_ERROR_NONE; - if(handle == NULL) { + if (handle == NULL) { __set_error_message(ERR_HANDLE, err_msg); return MEDIA_SVC_PLUGIN_ERROR; } - if(folder_path == NULL) { + if (folder_path == NULL) { __set_error_message(ERR_HANDLE, err_msg); return MEDIA_SVC_PLUGIN_ERROR; } ret = media_svc_update_folder_time(handle, folder_path, uid); - if(ret < 0) { + if (ret < 0) { __set_error_message(ret, err_msg); return MEDIA_SVC_PLUGIN_ERROR; } @@ -634,17 +633,17 @@ int update_folder_time(void * handle, char *folder_path, uid_t uid, char ** err_ return MEDIA_SVC_PLUGIN_ERROR_NONE; } -int update_item_begin(void * handle, int item_cnt, char ** err_msg) +int update_item_begin(void *handle, int item_cnt, char **err_msg) { int ret = MEDIA_SVC_PLUGIN_ERROR_NONE; - if(handle == NULL) { + if (handle == NULL) { __set_error_message(ERR_HANDLE, err_msg); return MEDIA_SVC_PLUGIN_ERROR; } ret = media_svc_update_item_begin(handle, item_cnt); - if(ret < 0) { + if (ret < 0) { __set_error_message(ret, err_msg); return MEDIA_SVC_PLUGIN_ERROR; } @@ -652,17 +651,17 @@ int update_item_begin(void * handle, int item_cnt, char ** err_msg) return MEDIA_SVC_PLUGIN_ERROR_NONE; } -int update_item_end(void * handle, uid_t uid, char ** err_msg) +int update_item_end(void *handle, uid_t uid, char **err_msg) { int ret = MEDIA_SVC_PLUGIN_ERROR_NONE; - if(handle == NULL) { + if (handle == NULL) { __set_error_message(ERR_HANDLE, err_msg); return MEDIA_SVC_PLUGIN_ERROR; } ret = media_svc_update_item_end(handle, uid); - if(ret < 0) { + if (ret < 0) { __set_error_message(ret, err_msg); return MEDIA_SVC_PLUGIN_ERROR; } @@ -670,22 +669,22 @@ int update_item_end(void * handle, uid_t uid, char ** err_msg) return MEDIA_SVC_PLUGIN_ERROR_NONE; } -int update_item_meta(void * handle, const char *file_path, int storage_type, uid_t uid, char ** err_msg) +int update_item_meta(void *handle, const char *file_path, int storage_type, uid_t uid, char **err_msg) { int ret = MEDIA_SVC_PLUGIN_ERROR_NONE; - if(handle == NULL) { + if (handle == NULL) { __set_error_message(ERR_HANDLE, err_msg); return MEDIA_SVC_PLUGIN_ERROR; } - if(file_path == NULL) { + if (file_path == NULL) { __set_error_message(ERR_HANDLE, err_msg); return MEDIA_SVC_PLUGIN_ERROR; } ret = media_svc_update_item_meta(handle, file_path, storage_type, uid); - if(ret < 0) { + if (ret < 0) { __set_error_message(ret, err_msg); return MEDIA_SVC_PLUGIN_ERROR; } diff --git a/src/common/media-svc-album.c b/src/common/media-svc-album.c index 7a1c7b9..65f1d9b 100755 --- a/src/common/media-svc-album.c +++ b/src/common/media-svc-album.c @@ -26,7 +26,7 @@ #include "media-svc-util.h" #include "media-svc-db-utils.h" -int _media_svc_get_album_id(sqlite3 *handle, const char *album, const char *artist, int * album_id) +int _media_svc_get_album_id(sqlite3 *handle, const char *album, const char *artist, int *album_id) { int ret = MS_MEDIA_ERR_NONE; sqlite3_stmt *sql_stmt = NULL; @@ -34,7 +34,7 @@ int _media_svc_get_album_id(sqlite3 *handle, const char *album, const char *arti media_svc_retvm_if(album == NULL, MS_MEDIA_ERR_INVALID_PARAMETER, "album is NULL"); - if(artist != 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); } else { sql = sqlite3_mprintf("SELECT album_id FROM %s WHERE name = '%q' AND artist IS NULL;", MEDIA_SVC_DB_TABLE_ALBUM, album, artist); @@ -43,10 +43,9 @@ int _media_svc_get_album_id(sqlite3 *handle, const char *album, const char *arti ret = _media_svc_sql_prepare_to_step(handle, sql, &sql_stmt); if (ret != MS_MEDIA_ERR_NONE) { - if(ret == MS_MEDIA_ERR_DB_NO_RECORD) { + if (ret == MS_MEDIA_ERR_DB_NO_RECORD) { media_svc_debug("there is no album."); - } - else { + } else { media_svc_error("error when _media_svc_get_album_id. err = [%d]", ret); } return ret; @@ -70,10 +69,9 @@ int _media_svc_get_album_art_by_album_id(sqlite3 *handle, int album_id, char **a ret = _media_svc_sql_prepare_to_step(handle, sql, &sql_stmt); if (ret != MS_MEDIA_ERR_NONE) { - if(ret == MS_MEDIA_ERR_DB_NO_RECORD) { + if (ret == MS_MEDIA_ERR_DB_NO_RECORD) { media_svc_debug("there is no album_id."); - } - else { + } else { media_svc_error("error when get album_art. err = [%d]", ret); } return ret; @@ -96,17 +94,17 @@ int _media_svc_get_album_art_by_album_id(sqlite3 *handle, int album_id, char **a 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 _media_svc_append_album(sqlite3 *handle, const char *album, const char *artist, const char *album_art, int *album_id, uid_t uid) { 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); + MEDIA_SVC_DB_TABLE_ALBUM, album, artist, album_art, album_art); ret = _media_svc_sql_query(handle, sql, uid); sqlite3_free(sql); media_svc_retv_if(ret != MS_MEDIA_ERR_NONE, ret); - //*album_id = sqlite3_last_insert_rowid(handle); + /**album_id = sqlite3_last_insert_rowid(handle); */ int inserted_album_id = 0; ret = _media_svc_get_album_id(handle, album, artist, &inserted_album_id); media_svc_retv_if(ret != MS_MEDIA_ERR_NONE, ret); @@ -128,10 +126,9 @@ int _media_svc_get_media_count_with_album_id_by_path(sqlite3 *handle, const char ret = _media_svc_sql_prepare_to_step(handle, sql, &sql_stmt); if (ret != MS_MEDIA_ERR_NONE) { - if(ret == MS_MEDIA_ERR_DB_NO_RECORD) { + if (ret == MS_MEDIA_ERR_DB_NO_RECORD) { media_svc_debug("there is no media in relted to this media's album."); - } - else { + } else { media_svc_error("error when _media_svc_get_media_count_with_album_id_by_path. err = [%d]", ret); } return ret; diff --git a/src/common/media-svc-db-utils.c b/src/common/media-svc-db-utils.c index 333dd69..6859b6d 100755 --- a/src/common/media-svc-db-utils.c +++ b/src/common/media-svc-db-utils.c @@ -41,32 +41,29 @@ static int __media_svc_rebuild_view_query(sqlite3 *db_handle, uid_t uid); static GHashTable *table; static GSList *column_list[MEDIA_SVC_DB_LIST_MAX]; -char* _media_svc_get_path(uid_t uid) +char *_media_svc_get_path(uid_t uid) { char *result_psswd = NULL; struct group *grpinfo = NULL; - if(uid == getuid()) - { + if (uid == getuid()) { result_psswd = strdup(MEDIA_ROOT_PATH_INTERNAL); grpinfo = getgrnam("users"); - if(grpinfo == NULL) { + if (grpinfo == NULL) { media_svc_error("getgrnam(users) returns NULL !"); return NULL; } - } - else - { + } else { struct passwd *userinfo = getpwuid(uid); - if(userinfo == NULL) { + if (userinfo == NULL) { media_svc_error("getpwuid(%d) returns NULL !", uid); return NULL; } grpinfo = getgrnam("users"); - if(grpinfo == NULL) { + if (grpinfo == NULL) { media_svc_error("getgrnam(users) returns NULL !"); return NULL; } - // Compare git_t type and not group name + /* Compare git_t type and not group name */ if (grpinfo->gr_gid != userinfo->pw_gid) { media_svc_error("UID [%d] does not belong to 'users' group!", uid); return NULL; @@ -81,18 +78,18 @@ int __media_svc_add_table_info(char *name, char *triggerName, char *eventTable, { table_info *tbl = NULL; tbl = malloc(sizeof(table_info)); - if(tbl == NULL) { + if (tbl == NULL) { media_svc_error("MS_MEDIA_ERR_OUT_OF_MEMORY"); return MS_MEDIA_ERR_OUT_OF_MEMORY; } memset(tbl, 0, sizeof(table_info)); - if(triggerName != NULL) { + if (triggerName != NULL) { tbl->triggerName = strndup(triggerName, strlen(triggerName)); tbl->eventTable = strndup(eventTable, strlen(eventTable)); tbl->actionTable = strndup(actionTable, strlen(actionTable)); } - if(viewName != NULL) { + if (viewName != NULL) { tbl->viewName = strndup(viewName, strlen(viewName)); } g_hash_table_insert(table, name, tbl); @@ -104,7 +101,7 @@ int __media_svc_add_column_info(GSList **slist, char *name, char *type, char *op { column_info *col = NULL; col = malloc(sizeof(column_info)); - if(col == NULL) { + if (col == NULL) { media_svc_error("MS_MEDIA_ERR_OUT_OF_MEMORY"); return MS_MEDIA_ERR_OUT_OF_MEMORY; } @@ -112,14 +109,14 @@ int __media_svc_add_column_info(GSList **slist, char *name, char *type, char *op col->name = strndup(name, strlen(name)); col->type = strndup(type, strlen(type)); - if(option != NULL) { + if (option != NULL) { col->hasOption = true; col->option = strndup(option, strlen(option)); } else { col->hasOption = false; } col->version = version; - if(indexName != NULL) { + if (indexName != NULL) { col->isIndex = true; col->indexName = strndup(indexName, strlen(indexName)); } else { @@ -138,14 +135,14 @@ static int __media_svc_rebuild_view_query(sqlite3 *db_handle, uid_t uid) int ret = MS_MEDIA_ERR_NONE; column_info *col_ptr = NULL; char *sql = NULL; - char table_query[4096] = {0,}; - char temp[1024] = {0,}; + char table_query[4096] = {0, }; + char temp[1024] = {0, }; int table_len = 0; int i, len; - //media + /*media */ _media_svc_update_media_view(db_handle, uid); - //drop playlist_view, tag_view + /*drop playlist_view, tag_view */ sql = sqlite3_mprintf(MEDIA_SVC_DB_QUERY_DROP_VIEW, MEDIA_SVC_DB_VIEW_PLAYLIST); ret = _media_svc_sql_query(db_handle, sql, uid); sqlite3_free(sql); @@ -156,13 +153,13 @@ static int __media_svc_rebuild_view_query(sqlite3 *db_handle, uid_t uid) sqlite3_free(sql); media_svc_retv_if(ret != MS_MEDIA_ERR_NONE, ret); - //create playlist_view + /*create playlist_view */ len = g_slist_length(column_list[MEDIA_SVC_DB_LIST_PLAYLIST]); - for(i=1;iisView) { - if(table_len > 0) { - if(strncmp(col_ptr->name, MEDIA_SVC_DB_COLUMN_THUMBNAIL, strlen(MEDIA_SVC_DB_COLUMN_THUMBNAIL)) == 0) + if (col_ptr->isView) { + if (table_len > 0) { + if (strncmp(col_ptr->name, MEDIA_SVC_DB_COLUMN_THUMBNAIL, strlen(MEDIA_SVC_DB_COLUMN_THUMBNAIL)) == 0) snprintf(temp, sizeof(temp), ", playlist.%s AS p_thumbnail_path", col_ptr->name); else snprintf(temp, sizeof(temp), ", playlist.%s", col_ptr->name); @@ -177,10 +174,10 @@ static int __media_svc_rebuild_view_query(sqlite3 *db_handle, uid_t uid) memset(temp, 0, sizeof(temp)); } len = g_slist_length(column_list[MEDIA_SVC_DB_LIST_PLAYLIST_MAP]); - for(i=1;iisView) { - if(strncmp(col_ptr->name, MEDIA_SVC_DB_COLUMN_MAP_ID, strlen(MEDIA_SVC_DB_COLUMN_MAP_ID)) == 0) + if (col_ptr->isView) { + if (strncmp(col_ptr->name, MEDIA_SVC_DB_COLUMN_MAP_ID, strlen(MEDIA_SVC_DB_COLUMN_MAP_ID)) == 0) snprintf(temp, sizeof(temp), ", playlist_map.%s AS pm_id", col_ptr->name); else snprintf(temp, sizeof(temp), ", playlist_map.%s", col_ptr->name); @@ -191,9 +188,9 @@ static int __media_svc_rebuild_view_query(sqlite3 *db_handle, uid_t uid) } len = g_slist_length(column_list[MEDIA_SVC_DB_LIST_MEDIA]); - for(i=1;iisView) { + if (col_ptr->isView) { snprintf(temp, sizeof(temp), ", media.%s", col_ptr->name); strncat(table_query, temp, strlen(temp)); table_len = strlen(table_query); @@ -205,15 +202,15 @@ static int __media_svc_rebuild_view_query(sqlite3 *db_handle, uid_t uid) sqlite3_free(sql); media_svc_retv_if(ret != MS_MEDIA_ERR_NONE, ret); - //create tag_view + /*create tag_view */ table_len = 0; memset(table_query, 0, sizeof(table_query)); len = g_slist_length(column_list[MEDIA_SVC_DB_LIST_TAG]); - for(i=1;iisView) { - if(table_len > 0) { + if (col_ptr->isView) { + if (table_len > 0) { snprintf(temp, sizeof(temp), ", tag.%s", col_ptr->name); strncat(table_query, temp, strlen(temp)); table_len = strlen(table_query); @@ -226,10 +223,10 @@ static int __media_svc_rebuild_view_query(sqlite3 *db_handle, uid_t uid) memset(temp, 0, sizeof(temp)); } len = g_slist_length(column_list[MEDIA_SVC_DB_LIST_TAG_MAP]); - for(i=1;iisView) { - if(strncmp(col_ptr->name, MEDIA_SVC_DB_COLUMN_MAP_ID, strlen(MEDIA_SVC_DB_COLUMN_MAP_ID)) == 0) + if (col_ptr->isView) { + if (strncmp(col_ptr->name, MEDIA_SVC_DB_COLUMN_MAP_ID, strlen(MEDIA_SVC_DB_COLUMN_MAP_ID)) == 0) snprintf(temp, sizeof(temp), ", tag_map.%s AS tm_id", col_ptr->name); else snprintf(temp, sizeof(temp), ", tag_map.%s", col_ptr->name); @@ -240,9 +237,9 @@ static int __media_svc_rebuild_view_query(sqlite3 *db_handle, uid_t uid) } len = g_slist_length(column_list[MEDIA_SVC_DB_LIST_MEDIA]); - for(i=1;iisView) { + if (col_ptr->isView) { snprintf(temp, sizeof(temp), ", media.%s", col_ptr->name); strncat(table_query, temp, strlen(temp)); table_len = strlen(table_query); @@ -263,11 +260,11 @@ int _media_svc_make_table_query(sqlite3 *db_handle, const char *table_name, medi table_info *tb = NULL; column_info *col_ptr = NULL; char *sql = NULL; - char table_query[4096] = {0,}; - char index_query[4096] = {0,}; - char trigger_query[4096] = {0,}; - char table_query_sub[1024] = {0,}; - char temp[1024] = {0,}; + char table_query[4096] = {0, }; + char index_query[4096] = {0, }; + char trigger_query[4096] = {0, }; + char table_query_sub[1024] = {0, }; + char temp[1024] = {0, }; int table_len = 0; int index_len = 0; int trigger_len = 0; @@ -280,17 +277,16 @@ int _media_svc_make_table_query(sqlite3 *db_handle, const char *table_name, medi tb = g_hash_table_lookup(table, table_name); len = g_slist_length(column_list[list]); - if(len == 0) - { + if (len == 0) { media_svc_error("Invalid column"); return MS_MEDIA_ERR_INTERNAL; } - for(i=1; ihasOption) { - if(table_len > 0) { + /*create table */ + if (col_ptr->hasOption) { + if (table_len > 0) { snprintf(temp, sizeof(temp), ", %s %s %s", col_ptr->name, col_ptr->type, col_ptr->option); strncat(table_query, temp, strlen(temp)); table_len = strlen(table_query); @@ -300,7 +296,7 @@ int _media_svc_make_table_query(sqlite3 *db_handle, const char *table_name, medi table_len = strlen(table_query); } } else { - if(table_len > 0) { + if (table_len > 0) { snprintf(temp, sizeof(temp), ", %s %s", col_ptr->name, col_ptr->type); strncat(table_query, temp, strlen(temp)); table_len = strlen(table_query); @@ -311,9 +307,9 @@ int _media_svc_make_table_query(sqlite3 *db_handle, const char *table_name, medi } } memset(temp, 0, sizeof(temp)); - //unique - if(col_ptr->isUnique) { - if(table_sub_len > 0) { + /*unique */ + if (col_ptr->isUnique) { + if (table_sub_len > 0) { snprintf(temp, sizeof(temp), ", %s", col_ptr->name); strncat(table_query_sub, temp, strlen(temp)); table_sub_len = strlen(table_query_sub); @@ -324,9 +320,9 @@ int _media_svc_make_table_query(sqlite3 *db_handle, const char *table_name, medi } } memset(temp, 0, sizeof(temp)); - //create index - if(col_ptr->isIndex) { - if(index_len > 0) { + /*create index */ + if (col_ptr->isIndex) { + if (index_len > 0) { snprintf(temp, sizeof(temp), MEDIA_SVC_DB_QUERY_INDEX, col_ptr->indexName, table_name, col_ptr->name); strncat(index_query, temp, strlen(temp)); index_len = strlen(index_query); @@ -337,9 +333,9 @@ int _media_svc_make_table_query(sqlite3 *db_handle, const char *table_name, medi } } memset(temp, 0, sizeof(temp)); - //create trigger - if(col_ptr->isTrigger) { - if(strncmp(table_name, MEDIA_SVC_DB_TABLE_ALBUM, strlen(MEDIA_SVC_DB_TABLE_ALBUM)) == 0) { + /*create trigger */ + if (col_ptr->isTrigger) { + if (strncmp(table_name, MEDIA_SVC_DB_TABLE_ALBUM, strlen(MEDIA_SVC_DB_TABLE_ALBUM)) == 0) { snprintf(temp, sizeof(temp), MEDIA_SVC_DB_QUERY_TRIGGER_WITH_COUNT, tb->triggerName, tb->eventTable, tb->actionTable, tb->eventTable, col_ptr->name, col_ptr->name, col_ptr->name, col_ptr->name); strncpy(trigger_query, temp, strlen(temp)); trigger_len = strlen(trigger_query); @@ -352,8 +348,8 @@ int _media_svc_make_table_query(sqlite3 *db_handle, const char *table_name, medi memset(temp, 0, sizeof(temp)); } - //send queries - if(table_sub_len > 0) { + /*send queries */ + if (table_sub_len > 0) { sql = sqlite3_mprintf(MEDIA_SVC_DB_QUERY_TABLE_WITH_UNIQUE, table_name, table_query, table_query_sub); ret = _media_svc_sql_query(db_handle, sql, uid); sqlite3_free(sql); @@ -368,34 +364,34 @@ int _media_svc_make_table_query(sqlite3 *db_handle, const char *table_name, medi media_svc_retv_if(ret != MS_MEDIA_ERR_NONE, ret); } - if(index_len > 0) { + if (index_len > 0) { ret = _media_svc_sql_query(db_handle, index_query, uid); memset(index_query, 0, sizeof(index_query)); media_svc_retv_if(ret != MS_MEDIA_ERR_NONE, ret); } - if(trigger_len > 0) { + if (trigger_len > 0) { ret = _media_svc_sql_query(db_handle, trigger_query, uid); memset(trigger_query, 0, sizeof(trigger_query)); media_svc_retv_if(ret != MS_MEDIA_ERR_NONE, ret); } - //create view + /*create view */ table_len = 0; - if(tb != NULL && tb->viewName != NULL) { - if(strncmp(table_name, MEDIA_SVC_DB_TABLE_MEDIA, strlen(MEDIA_SVC_DB_TABLE_MEDIA)) == 0) { + if (tb != NULL && tb->viewName != NULL) { + if (strncmp(table_name, MEDIA_SVC_DB_TABLE_MEDIA, strlen(MEDIA_SVC_DB_TABLE_MEDIA)) == 0) { sql = sqlite3_mprintf(MEDIA_SVC_DB_QUERY_VIEW_MEDIA, tb->viewName, table_name); ret = _media_svc_sql_query(db_handle, sql, uid); sqlite3_free(sql); media_svc_retv_if(ret != MS_MEDIA_ERR_NONE, ret); - } else if(strncmp(table_name, MEDIA_SVC_DB_TABLE_PLAYLIST, strlen(MEDIA_SVC_DB_TABLE_PLAYLIST)) == 0) { + } else if (strncmp(table_name, MEDIA_SVC_DB_TABLE_PLAYLIST, strlen(MEDIA_SVC_DB_TABLE_PLAYLIST)) == 0) { len = g_slist_length(column_list[MEDIA_SVC_DB_LIST_PLAYLIST]); - for(i=1; iisView) { - if(table_len > 0) { - if(strncmp(col_ptr->name, MEDIA_SVC_DB_COLUMN_THUMBNAIL, strlen(MEDIA_SVC_DB_COLUMN_THUMBNAIL)) == 0) + if (col_ptr->isView) { + if (table_len > 0) { + if (strncmp(col_ptr->name, MEDIA_SVC_DB_COLUMN_THUMBNAIL, strlen(MEDIA_SVC_DB_COLUMN_THUMBNAIL)) == 0) snprintf(temp, sizeof(temp), ", playlist.%s AS p_thumbnail_path", col_ptr->name); else snprintf(temp, sizeof(temp), ", playlist.%s", col_ptr->name); @@ -410,10 +406,10 @@ int _media_svc_make_table_query(sqlite3 *db_handle, const char *table_name, medi memset(temp, 0, sizeof(temp)); } len = g_slist_length(column_list[MEDIA_SVC_DB_LIST_PLAYLIST_MAP]); - for(i=1; iisView) { - if(strncmp(col_ptr->name, MEDIA_SVC_DB_COLUMN_MAP_ID, strlen(MEDIA_SVC_DB_COLUMN_MAP_ID)) == 0) + if (col_ptr->isView) { + if (strncmp(col_ptr->name, MEDIA_SVC_DB_COLUMN_MAP_ID, strlen(MEDIA_SVC_DB_COLUMN_MAP_ID)) == 0) snprintf(temp, sizeof(temp), ", media_count IS NOT NULL AS media_count, playlist_map.%s AS pm_id", col_ptr->name); else snprintf(temp, sizeof(temp), ", playlist_map.%s", col_ptr->name); @@ -424,9 +420,9 @@ int _media_svc_make_table_query(sqlite3 *db_handle, const char *table_name, medi } len = g_slist_length(column_list[MEDIA_SVC_DB_LIST_MEDIA]); - for(i=1; iisView) { + if (col_ptr->isView) { snprintf(temp, sizeof(temp), ", media.%s", col_ptr->name); strncat(table_query, temp, strlen(temp)); table_len = strlen(table_query); @@ -440,10 +436,10 @@ int _media_svc_make_table_query(sqlite3 *db_handle, const char *table_name, medi } else { len = g_slist_length(column_list[MEDIA_SVC_DB_LIST_TAG]); - for(i=1; iisView) { - if(table_len > 0) { + if (col_ptr->isView) { + if (table_len > 0) { snprintf(temp, sizeof(temp), ", tag.%s", col_ptr->name); strncat(table_query, temp, strlen(temp)); table_len = strlen(table_query); @@ -456,10 +452,10 @@ int _media_svc_make_table_query(sqlite3 *db_handle, const char *table_name, medi memset(temp, 0, sizeof(temp)); } len = g_slist_length(column_list[MEDIA_SVC_DB_LIST_TAG_MAP]); - for(i=1; iisView) { - if(strncmp(col_ptr->name, MEDIA_SVC_DB_COLUMN_MAP_ID, strlen(MEDIA_SVC_DB_COLUMN_MAP_ID)) == 0) + if (col_ptr->isView) { + if (strncmp(col_ptr->name, MEDIA_SVC_DB_COLUMN_MAP_ID, strlen(MEDIA_SVC_DB_COLUMN_MAP_ID)) == 0) snprintf(temp, sizeof(temp), ", media_count IS NOT NULL AS media_count, tag_map.%s AS tm_id", col_ptr->name); else snprintf(temp, sizeof(temp), ", tag_map.%s", col_ptr->name); @@ -470,9 +466,9 @@ int _media_svc_make_table_query(sqlite3 *db_handle, const char *table_name, medi } len = g_slist_length(column_list[MEDIA_SVC_DB_LIST_MEDIA]); - for(i=1; iisView) { + if (col_ptr->isView) { snprintf(temp, sizeof(temp), ", media.%s", col_ptr->name); strncat(table_query, temp, strlen(temp)); table_len = strlen(table_query); @@ -487,7 +483,7 @@ int _media_svc_make_table_query(sqlite3 *db_handle, const char *table_name, medi } } - if(strncmp(table_name, MEDIA_SVC_DB_TABLE_STORAGE, strlen(MEDIA_SVC_DB_TABLE_STORAGE)) == 0) { + if (strncmp(table_name, MEDIA_SVC_DB_TABLE_STORAGE, strlen(MEDIA_SVC_DB_TABLE_STORAGE)) == 0) { sql = sqlite3_mprintf("SELECT COUNT(*) FROM '%s' WHERE storage_uuid='%s'", MEDIA_SVC_DB_TABLE_STORAGE, MEDIA_SVC_DB_TABLE_MEDIA); ret = _media_svc_sql_prepare_to_step(db_handle, sql, &sql_stmt); media_svc_retv_if(ret != MS_MEDIA_ERR_NONE, ret); @@ -495,7 +491,7 @@ int _media_svc_make_table_query(sqlite3 *db_handle, const char *table_name, medi storage_cnt = sqlite3_column_int(sql_stmt, 0); SQLITE3_FINALIZE(sql_stmt); - if(storage_cnt == 0) { + if (storage_cnt == 0) { sql = sqlite3_mprintf("INSERT INTO %s VALUES('%s', '%s', '%s', '%s', 0, 0, 1);", MEDIA_SVC_DB_TABLE_STORAGE, MEDIA_SVC_DB_TABLE_MEDIA, MEDIA_SVC_DB_TABLE_MEDIA, _media_svc_get_path(uid), NULL); ret = _media_svc_sql_query(db_handle, sql, uid); sqlite3_free(sql); @@ -511,8 +507,8 @@ int _media_svc_upgrade_table_query(sqlite3 *db_handle, char *table_name, media_s int ret = MS_MEDIA_ERR_NONE; column_info *col_ptr = NULL; char *sql = NULL; - char temp[1024] = {0,}; - int len,i; + char temp[1024] = {0, }; + int len, i; int cur_version = 0; sqlite3_stmt *sql_stmt = NULL; @@ -529,11 +525,11 @@ int _media_svc_upgrade_table_query(sqlite3 *db_handle, char *table_name, media_s SQLITE3_FINALIZE(sql_stmt); len = g_slist_length(column_list[list]); - for(i=1;iversion > cur_version) { - //alter table - if(col_ptr->hasOption) + if (col_ptr->version > cur_version) { + /*alter table */ + if (col_ptr->hasOption) snprintf(temp, sizeof(temp), "%s %s %s", col_ptr->name, col_ptr->type, col_ptr->option); else snprintf(temp, sizeof(temp), "%s %s", col_ptr->name, col_ptr->type); @@ -541,8 +537,8 @@ int _media_svc_upgrade_table_query(sqlite3 *db_handle, char *table_name, media_s ret = _media_svc_sql_query(db_handle, sql, uid); sqlite3_free(sql); media_svc_retv_if(ret != MS_MEDIA_ERR_NONE, ret); - //create index - if(col_ptr->isIndex) { + /*create index */ + if (col_ptr->isIndex) { memset(temp, 0, sizeof(temp)); snprintf(temp, sizeof(temp), MEDIA_SVC_DB_QUERY_INDEX, col_ptr->indexName, table_name, col_ptr->name); ret = _media_svc_sql_query(db_handle, temp, uid); @@ -560,13 +556,13 @@ int _media_svc_init_table_query() int ret = MS_MEDIA_ERR_NONE; int i = 0; - //variable initialize.. + /*variable initialize.. */ table = g_hash_table_new(g_str_hash, g_str_equal); - for(i=0;i 0)) - { + if ((storage_list != NULL) && (g_list_length(storage_list) > 0)) { item_cnt = g_list_length(storage_list); - for(idx = 0; idx < item_cnt; idx++) - { + for (idx = 0; idx < item_cnt; idx++) { int table_cnt = 0; - char * storage_id = NULL; + char *storage_id = NULL; storage_id = g_list_nth_data(storage_list, idx); - if(STRING_VALID(storage_id)) - { + if (STRING_VALID(storage_id)) { /*Select list of storage*/ sql = sqlite3_mprintf("SELECT COUNT(*) FROM SQLITE_MASTER WHERE type='table' and name='%q'", storage_id); ret = _media_svc_sql_prepare_to_step(db_handle, sql, &sql_stmt); - if(ret != MS_MEDIA_ERR_NONE) - { + if (ret != MS_MEDIA_ERR_NONE) { SAFE_FREE(storage_id); continue; } @@ -1073,15 +1061,12 @@ int _media_svc_update_media_view(sqlite3 *db_handle, uid_t uid) table_cnt = sqlite3_column_int(sql_stmt, 0); SQLITE3_FINALIZE(sql_stmt); - if(table_cnt > 0) - { - char append_query[128] = {0,}; + if (table_cnt > 0) { + char append_query[128] = {0, }; memset(append_query, 0x00, sizeof(append_query)); snprintf(append_query, sizeof(append_query), " UNION SELECT * from '%s'", storage_id); strncat(view_query, append_query, strlen(append_query)); - } - else - { + } else { media_svc_error("media table not exist for storage [%s]", storage_id); } diff --git a/src/common/media-svc-debug.c b/src/common/media-svc-debug.c index 2ec252f..997c4b3 100755 --- a/src/common/media-svc-debug.c +++ b/src/common/media-svc-debug.c @@ -42,7 +42,7 @@ void mediainfo_init_file_debug() { if (g_log_fp == NULL) { snprintf(_g_file_path, sizeof(_g_file_path), "/tmp/%s", - "media-info"); + "media-info"); if (access(_g_file_path, R_OK == 0)) { remove(_g_file_path); } @@ -90,7 +90,7 @@ void mediainfo_print_debug_time(char *time_string) gettimeofday(&time, NULL); totaltime = (double)(time.tv_sec * 1000000 + time.tv_usec - - g_time_usec) / CLOCKS_PER_SEC; + g_time_usec) / CLOCKS_PER_SEC; media_svc_debug("time [%s] : %f", time_string, totaltime); #endif @@ -98,7 +98,7 @@ void mediainfo_print_debug_time(char *time_string) void mediainfo_print_debug_time_ex(long start, long end, const char *func_name, - char *time_string) + char *time_string) { #ifdef _PERFORMANCE_CHECK_ double totaltime = 0.0; @@ -106,6 +106,6 @@ mediainfo_print_debug_time_ex(long start, long end, const char *func_name, totaltime = (double)(end - start) / CLOCKS_PER_SEC; media_svc_debug("time [%s: %s] : %f", func_name, time_string, - totaltime); + totaltime); #endif } diff --git a/src/common/media-svc-localize-utils.c b/src/common/media-svc-localize-utils.c index 46fc99c..ab3992c 100755 --- a/src/common/media-svc-localize-utils.c +++ b/src/common/media-svc-localize-utils.c @@ -28,7 +28,7 @@ #include "media-svc-debug.h" #include "media-svc-localize-utils.h" -#define SAFE_STRLEN(src) ((src)?strlen(src):0) +#define SAFE_STRLEN(src) ((src) ? strlen(src) : 0) int _media_svc_check_utf8(char c) { @@ -58,13 +58,12 @@ int SAFE_SNPRINTF(char **buf, int *buf_size, int len, const char *src) remain = *buf_size - len; if (remain > strlen(src) + 1) { - temp_len = snprintf((*buf)+len, remain, "%s", src); + temp_len = snprintf((*buf) + len, remain, "%s", src); return temp_len; - } - else { + } else { char *temp; - while(1) { - temp = realloc(*buf, *buf_size*2); + while (1) { + temp = realloc(*buf, *buf_size * 2); if (NULL == temp) return -1; *buf = temp; @@ -73,14 +72,14 @@ int SAFE_SNPRINTF(char **buf, int *buf_size, int len, const char *src) if (remain > strlen(src) + 1) break; } - temp_len = snprintf((*buf)+len, remain, "%s", src); + temp_len = snprintf((*buf) + len, remain, "%s", src); return temp_len; } } static int __media_svc_remove_special_char(const char *src, char *dest, int dest_size) { - int s_pos=0, d_pos=0, char_type, src_size; + int s_pos = 0, d_pos = 0, char_type, src_size; if (NULL == src) { media_svc_error("The parameter(src) is NULL"); @@ -93,11 +92,10 @@ static int __media_svc_remove_special_char(const char *src, char *dest, int dest char_type = _media_svc_check_utf8(src[s_pos]); if (0 < char_type && char_type < dest_size - d_pos && char_type <= src_size - s_pos) { - memcpy(dest+d_pos, src+s_pos, char_type); + memcpy(dest + d_pos, src + s_pos, char_type); d_pos += char_type; s_pos += char_type; - } - else { + } else { media_svc_error("The parameter(src:%s) has invalid character set", src); dest[d_pos] = '\0'; return MS_MEDIA_ERR_INVALID_PARAMETER; @@ -117,10 +115,10 @@ static inline int __media_svc_collation_str(const char *src, char **dest) char region[50] = {0}; char *lang = NULL; - //lang = vconf_get_str(VCONFKEY_LANGSET); - if(lang != NULL) { - if(strlen(lang) < 50) { - strncpy (region, lang, strlen(lang)); + /*lang = vconf_get_str(VCONFKEY_LANGSET); */ + if (lang != NULL) { + if (strlen(lang) < 50) { + strncpy(region, lang, strlen(lang)); free(lang); } else { media_svc_error("Lang size error(%s)", lang); @@ -137,7 +135,7 @@ static inline int __media_svc_collation_str(const char *src, char **dest) collator = ucol_open(region, &status); media_svc_retvm_if(U_FAILURE(status), MS_MEDIA_ERR_INTERNAL, - "ucol_open() Failed(%s)", u_errorName(status)); + "ucol_open() Failed(%s)", u_errorName(status)); u_strFromUTF8(NULL, 0, &size, src, strlen(src), &status); if (U_FAILURE(status) && status != U_BUFFER_OVERFLOW_ERROR) { @@ -148,7 +146,7 @@ static inline int __media_svc_collation_str(const char *src, char **dest) status = U_ZERO_ERROR; tmp_result = calloc(1, sizeof(UChar) * (size + 1)); u_strFromUTF8(tmp_result, size + 1, NULL, src, -1, &status); - if (U_FAILURE(status)){ + if (U_FAILURE(status)) { media_svc_error("u_strFromUTF8 Failed(%s)", u_errorName(status)); free(tmp_result); ucol_close(collator); @@ -157,7 +155,7 @@ static inline int __media_svc_collation_str(const char *src, char **dest) size = ucol_getSortKey(collator, tmp_result, -1, NULL, 0); *dest = calloc(1, sizeof(uint8_t) * (size + 1)); - size = ucol_getSortKey(collator, tmp_result, -1, (uint8_t *)*dest, size + 1); + size = ucol_getSortKey(collator, tmp_result, -1, (uint8_t *) * dest, size + 1); ucol_close(collator); free(tmp_result); diff --git a/src/common/media-svc-localize_ch.c b/src/common/media-svc-localize_ch.c index c51e3d7..540a369 100755 --- a/src/common/media-svc-localize_ch.c +++ b/src/common/media-svc-localize_ch.c @@ -37,2116 +37,2117 @@ #define CHINESE_UNICODE_START 0x4E00 #define CHINESE_UNICODE_END 0x9FA5 -static const char* const pinyin_spell_table[] = { - "yi","ding|zheng","kao|qiao|yu","qi","shang","xia","mo","wan|mo","zhang","san", - "shang","xia","qi|ji","bu|fou","yu","mian","gai","chou","chou","zhuan", - "qie|ju","pi","shi","shi","qiu","bing","ye","cong","dong","si", - "cheng","diu","qiu","liang","diu","you","liang","yan","bing","sang", - "gun","jiu","ge","ya","pan","zhong","ji","jie","feng","guan|kuang", - "chuan","chan","lin","zhuo","zhu","ba","wan","dan","wei","zhu", - "jing","li","ju","pie","fu","yi|ji","yi","nai","wu","jiu", - "jiu","tuo|zhe","me|yao|mB","yi","ho","zhi","wu","zha","hu","fa", - "le|yue","yin","ping","pang","qiao","hu","guai","cheng|sheng","cheng|sheng","yi", - "hao","zhe","mie|nie","jiu","qi","ye","xi","xiang","gai","jiu", - "hal","hol","shu","dou","shi","ji","nang","kal","keol","tol", - "mol","ol","mai","luan","cal","ru","xue","yan","phoi","sha", - "na","qian","sol","er","zu","ceor","qian|gan","zhi|luan","gui","qian", - "luan","lin","yi","jue","liao|le","ma","yu","zheng","shi","shi", - "er","chu","yu","kui","yu","yun","hu","qi","wu","jing", - "si","sui","gen","gen","ya","xie|suo","ya","qi|zhai","ya","ji|qi", - "tou","wang|wu","kang","da","jiao","hai","yi","chan","heng|peng","mu", - "ye","xiang","jing","ting","liang","xiang","jing","ye","qin|qing","bo", - "you","xie","dan","lian","duo","wei|men","ren","ren","ji","ji", - "wang","yi","shi|shen","ren","le","ding","ze","jin","pu","chou|qiu", - "ba","zhang","jin","jie","bing","reng","cong|zong","fo","jin|san","lun", - "bing","cang","zi|zai","shi","ta","zhang","fu","xian","xian","tuo|cha|duo", - "hong","tong","ren","qian","gan|han","yi|ge","bo","dai","ling","yi", - "chao","chang|zhang","sa","chang","yi","mu","men","ren","fan","chao|miao", - "yang|ang","qian","zhong","pi","wo","wu","jian","jia|jie","yao|fo","feng", - "cang","ren","wang","fen|bin","di","fang","zhong","qi","pei","yu", - "diao","dun","wen","yi","xin","kang","yi","ji","ai","wu", - "ji|qi","fu","fa","xiu|xu","jin","pi","dan","fu","tang","zhong", - "you","huo","hui|kuai","yu","cui","yun","san","wei","chuan|zhuan","che|ju", - "ya","qian","shang","chang","lun","cang|chen","xun","xin","wei","zhu", - "chi","xian|xuan","nu","bo|bai|ba","gu","ni","ni","xie","ban","xu", - "ling","zhou","shen","qu","si|ci","peng","si|shi","qie|jia|ga","pi","zhi", - "si","yi|chi","zheng","dian|tian","han|gan","mai","dan","zhu","bu","qu", - "bi","zhao|shao","ci","wei","di","zhu","zuo","you","yang","ti|ben", - "zhan|dian","he","bi","tuo","she","yu","yi|die","fo|fu|bi|bo","zuo","gou|kou", - "ning","tong","ni","xian","qu","yong","wa","qian","shi","ka", - "bao","pei","hui|huai","ge","lao","xiang","ge","yang","bai","fa", - "ming","jia","er|nai","bing","ji","hen","huo","gui","quan","tiao", - "jiao","ci","yi","shi","xing","shen","tuo","kan","zhi","gai", - "lai","yi","chi","kua","gong","li","yin","shi","mi","zhu", - "xu","you","an","lu","mou","er","lun","dong|tong","cha","chi", - "xun","gong","zhou","yi","ru","cun","xia","si","dai","lv", - "ta","jiao|yao","zhen","ce|ze|zhai","qiao","kuai","chai","ning","nong","jin", - "wu","hou","jiong","cheng|ting","zhen","zuo","hao","qin","lv","jv", - "shu|dou","ting","shen","tuo|tui","bo","nan","xiao","bian|pian","tui","yu", - "xi","cu","e","qiu","xu","guang","ku","wu","jun","yi", - "fu","liang","zu","qiao|xiao","li","yong","hun","jing","qian","san", - "pei","su","fu","xi","li","fu","ping","bao","yu|shu","si|qi", - "xia","xin|shen","xiu","yu","di","che|ju","chou","zhi","yan","liang|lia", - "li","lai","si","jian","xiu","fu","huo","ju","xiao","pai", - "jian","biao","chu|ti","fei","feng","ya","an","bei","yu","xin", - "bi","hu|chi","chang","zhi","bing","jiu","yao","cui|zu","liang|lia","wan", - "lai","cang","zong","ge","guan","bei","tian","shu","shu","men", - "dao","tan","jue","chui","xing","peng","tang|chang","hou","yi","qi", - "ti","gan","liang|jing","jie","sui","chang","jie","fang","zhi","kong", - "juan","zong","ju","qian","ni","lun","zhuo","wo|wei","luo","song", - "leng","hun","dong","zi","ben","wu","ju","nai","cai","jian", - "zhai","ye","zhi","sha","qing","ning","ying","cheng|chen","qian","yan", - "ruan","zhong|tong","chun","jia","ji|jie","wei","yu","bing","ruo","ti", - "wei","pian","yan","feng","tang|dang","wo","e","xie","che","sheng", - "kan","di","zuo","cha","ting","bei","xie","huang","yao","zhan", - "chou|qiao","an","you","jian","xu","zha","ci","fu","bi","zhi", - "zong","mian","ji","yi","xie","xun","cai|si","duan","ce|ze|zhai","zhen", - "ou","tou","tou","bei","zan|za|zBn","lv|lou","jie","wei","fen","chang", - "kui|gui","sou","zhi|si","su","xia","fu","yuan","rong","li","nu", - "yun","jiang|gou","ma","bang","dian","tang","hao","jie","xi","shan", - "qian|jian","que|jue","cang|chen","chu","san","bei","xiao","rong","yao","ta|tan", - "suo","yang","fa","bing","jia","dai","zai","tang","gu","bin", - "chu","nuo","can","lei","cui","yong","zao|cao","zong","peng","song", - "ao","chuan|zhuan","yu","zhai","qi|cou","shang","chuang","jing","chi","sha", - "han","zhang","qing","yan","di","xie","lv|lou","bei","piao|biao","jin", - "lian","lu","man","qian","xian","tan","ying","dong","zhuan","xiang", - "shan","qiao","jiong","tui","zun","pu","xi","lao","chang","guang", - "liao","qi","cheng|deng","zhan|zhuan|chan","wei","ji","bo","hui","chuan","tie|jian", - "dan","jiao|yao","jiu","seng","fen","xian","yu|ju","e|wu","jiao","jian", - "tong|zhuang","lin","bo","gu","xian","su","xian","jiang","min","ye", - "jin","jia|jie","qiao","pi","feng","zhou","ai","sai","yi","jun", - "nong","chan|tan|shan","yi","dang","jing","xuan","kuai","jian","chu","dan", - "jiao","sha","zai","can","bin","an","ru","tai","chou","chai", - "lan","ni|yi","jin","qian","meng","wu","ning","qiong","ni","chang", - "lie","lei","lv","kuang","bao","yu","biao","zan","zhi","si", - "you","hao","qing","chen","li","teng","wei","long","chu","chan", - "rang|xiang","shu","hui|xie","li","luo","zan","nuo","tang","yan","lei", - "nang","er","wu","yun","zan","yuan","xiong","chong","zhao","xiong", - "xian","guang","dui|rui|yue","ke","dui|rui|yue","mian","tu","chang|zhang","er","dui|rui|yue", - "er|ni","jin","tu","si","yan","yan","shi","shike","dang","qibnke", - "dou","gongfenPPPU","hboke","shen","dou","baike","jing","gongli","huang","ru", - "wang","nei","quan","liang","yu|shu","ba","gong","liu|lu","xi","han", - "lan","gong","tian","guan","xing","bing","qi|ji","ju","dian","zi|ci", - "bun","yang","jian","shou","ji","yi","ji","chan","jiong","mao", - "ran","nei|na","yuan","mao","gang","ran","ce","jiong","ce","zai", - "gua","jiong","mao","zhou","mao|mo","gou","xu","mian","mi","rong", - "yin|you","xie","kan","jun","nong","yi","shen","shi","guan","meng", - "zhong","zui","yuan","ming","kou","lin","fu","xie","mi","bing", - "dong","tai","gang","feng|ping","bing","hu","chong","jue","ya","kuang", - "ye","leng","pan","fa","min","dong","xian","lie","qia","jian", - "jing|cheng","sou","mei","tu","qi","gu","zhun","song","jing|cheng","liang", - "qing","diao","ling","dong","gan","jian","yin","cou","ai","li", - "cang","ming","zhun","cui","si","duo","jin","lin","lin","ning", - "xi","du","ji","fan","fan","fan","feng","ju","chu","yi kB|yi kB no bo li|tB ko", - "feng","mu","zhi","fu","feng","ping","feng","kai","huang","kai", - "gan","deng","ping","kan|qian","xiong","kuai","tu","ao|wa","chu","ji", - "dang","han","han","zao","dao","diao","dao","ren","ren","chuang", - "fen","qie","yi","ji","kan","qian","cun","chu","wen","ji", - "dan","xing","hua","wan","jue","li","yue","lie","liu","ze", - "gang","chuang","fu","chu","qu","diao","shan","min","ling","zhong", - "pan","bie","jie","jie","pao|bao","li","shan","bie","chan","jing", - "gua","geng","dao","chuang","kui","ku","duo","er","zhi","shua", - "quan|xuan","cha|sha","ci","ke","jie","gui","ci","gui","kai","duo", - "ji","ti","jing","dou","luo","ze","yuan","cuo","xiao|xue","kei|ke", - "la","qian","cha|sha","chuang","gua","jian","cuo","li","ti","fei", - "pou","chan","qi","chuang","zi","gang","wan","bao|bo","ji","duo", - "qing","yan|shan","du|zhuo","jian","ji","bao|bo","yan","ju","huo","sheng", - "jian","duo","zhi|duan","wu","gua","fu|pi","sheng","jian","ge","da|zha", - "kai","chuang","chuan","chan","tuan|zhuan","lu|jiu","li","peng","shan","piao", - "kou","jiao|chao","gua","qiao","jue","hua","zha","zhuo","lian","ju", - "pi","liu","gui","jiao|chao","gui","jian","jian","tang","huo","ji", - "jian","yi","jian","zhi","chan","zuan","mo","li","zhu","li", - "ya","quan","ban","gong","jia","wu","mai","lie","jin|jing","keng", - "xie|lie","zhi","dong","zhu|chu","nu","jie","qu","shao","yi","zhu", - "miao","li","jin|jing","lao","lao","juan","kou","yang","wa","xiao", - "mou","kuang","jie","lie","he","shi","ke","jin|jing","gao","bo|bei", - "min","chi","lang","yong","yong","mian","ke","xun","juan","qing", - "lu","bu","meng","chi","le|lei","kai","mian","dong","xu","xu", - "kan","wu","yi","xun","weng|yang","sheng","lao","mu","lu","piao", - "shi","ji","qin","jiang","jiao|chao","quan","xiang","yi","qiao","fan", - "juan","tong|dong","ju","dan","xie","mai","xun","xun","lv","li", - "che","rang|xiang","quan","bao","shao","yun","jiu","bao","gou","wu", - "yun","mo","xiong","gai","gai","bao","cong","yi","xiong","peng", - "ju","tao|yao","ge","pu","e","pao","fu","gong","da","jiu", - "gong","bi","hua","bei","nao","chi|shi","fang","jiu","yi","za", - "jiang","kang","jiang","kuang","hu","xia","qu","fan","gui","qie", - "zang|cang","kuang","fei","hu","yu","gui","kui|gui","hui","dan","kui|gui", - "lian","lian","suan","du","jiu","jue","xi","pi","qu|ou","yi", - "ke|qia","yan","bian","ni","qu|ou","shi","xun","qian","nian","sa", - "zu","sheng","wu","hui","ban","shi","xi","wan","hua","xie", - "wan","bei","zu|cu","zhuo","xie","dan|shan|chan","mai","nan|na","dan","ji", - "bo","shuai|lv","bu|bo","guan|kuang","bian","bu","zhan","qia|ka","lu","you", - "lu","xi","gua","wo","xie","jie","jie","wei","yang|ang","qiong", - "zhi","mao","yin","wei","shao","ji","que","luan","chi","juan", - "xie","xu","jin","que","wu","ji","e","qing","xi","san", - "chang|an|han","wei","e","ting","li","zhe|zhai","han|an","li","ya","ya", - "yan","she","di","zha|zhai","pang","ya","qie","ya","zhi|shi","ce", - "mang","ti","li","she","hou","ting","zui","cuo","fei","yuan", - "ce","yuan","xiang","yan","li","jue","sha|xia","dian","chu","jiu", - "jin","ao","gui","yan","si","li","chang","qian|lan","li","yan", - "yan","yuan","si|mou","gong|hong","lin|miao","rou|qiu","qu","qu","ke","lei", - "du","xian|xuan","zhuan","san","can|shen|cen|san","can|shen|cen|san","can|shen|cen|san","can|shen|cen|san","ai|yi","dai", - "you","cha","ji","you","shuang","fan","shou","guai","ba","fa", - "ruo","li","shu","zhuo|yi|li|jue","qu","shou","bian","xu","jia","pan", - "sou","ji","wei|yu","sou","die","rui","cong","kou","gu","ju|gou", - "ling","gua","tao|dao","kou","zhi","jiao","zhao|shao","ba","ding","ke", - "tai","chi","shi","you","qiu","po","ye|xie","hao","si","tan", - "chi","le","diao","ji","dug","hong","mie","xu|yu","mang","chi", - "ge","xuan|song","yao","zi","he|ge","ji","diao","dou|cun","tong","ming", - "hou","li","tu","xiang","zha","xia|he","ye","lv","a","ma|mB", - "ou","huo","yi","jun","chou","lin","tun","yin","fei","pi|bi", - "qin","qin","jie|ge","bu","fou|pi","ba","dun","fen","e|hua","han", - "ting","hang|keng","shun","qi","hong","zhi|zi","yin|shen","wu","wu","chao", - "na|ne","xue|chuo|jue","xi","chui","dou|ru","wen","hou","hou|hong|ou","wu|yu","gao", - "ya|yB","jun","lv","e","ge","wen","dai","qi","cheng","wu", - "gao","fu","jiao","hong","chi","sheng","na|ne","tun|tian","fu|?","yi", - "dai","ou","li","bei|bai","yuan|yun","wai|he|wo|wa|gua|guo","hua|qi","qiang","wu","e", - "shi","juan","pen","wen|min","ne","mou|m","ling","ran","you","di", - "zhou","shi","zhou","tie|che","xi","yi","qi|zhi","ping","zi|ci","gua|gu", - "zi|ci","wei","xu|hou|gou","he|a|ke","nao","xia","pei","yi","xiao|hao","shen", - "hu","ming","da|dan","qu","ju|zui","xian|gan","za","tuo","duo","pou", - "pao","bi","fu","yang","he","zha|za","he|huo|hu","hai","jiu","yong", - "fu","da","zhou","wa","ka","gu","ka|ga","zuo","bu","long", - "dong","ning","tuo","si","xian","huo","qi","er","e","guang", - "zha","die|xi","yi","lie","zi","mie","mi","zhi","yao","ji|xi|qia", - "zhou","ka|luo|lo|ge","shu|xun","zan|za|zBn","xiao","ke|hai","hui","kua","huai|shi","tao", - "xian","e|an","xuan","xiu","wai|he|wo|wa|gua|guo","yan|ye","lao","yi","ai","pin", - "shen","tong","hong","xiong","duo","wa|wB","ha","zai","you","die|di", - "pai","xiang","ai","gen|hen","kuang","ya","da","xiao","bi","yue|hui", - "nian","hua","xing","kuai","duo","po","ji|jie|zhai","nong","mou","yo", - "hao","yuan|yun","long","pou","mang","ge","o","chi","shao","li", - "na|nei|nB|ne","zu","he","ku","xiao","xian","lao","po|ba|bo","zhe","zha", - "liang|lang","ba","mie","lie|lv","sui","fu","bu","han","heng|hng","geng", - "chuo|yue","ge|jia","you","yan","gu","gu","bei|bai","han","suo","chun", - "yi","ai","jia|qian","tu","dan|xian|yan","wan","li","xi","tang","zuo", - "qiu","che","wu","zao","ya","dou","qi","di","qin","ma", - "ma","gong|hong","dou","ge","lao","liang","suo","zao","huan","leng", - "sha|shB","ji","zu","wo|wei","feng","jin|yin","hu|xia","qi","shou","wei", - "shua","chang","er|wa","li","qiang","an","jie|ze|zuo","yo","nian","yu", - "tian","lai","sha","xi","tuo","hu","ai","zhou|zhao|tiao","gou","ken", - "zhuo","zhuo|zhao","shang","di","heng","lan|lin","a","cai","qiang","zhun|tun|xiang|dui", - "wu","wen","cui|qi","sha|jie|die|ti","gu","qi","qi","tao","dan","dan", - "yue|wa","zi|ci","bi|tu","cui","chuo|chuai","he","ya","qi","zhe","fei", - "liang","xian","pi","sha","lB|la","ze","qing|ying","gua","pa","ze|shi", - "se","zhuan","nie","guo","luo","yan","di","quan","tan|chan|tuo","bo", - "ding","lang","xiao","ju","tang","chi","ti","an","jiu","dan", - "ka","yong","wei","nan","shan","yu","zhe","la","jie","hou", - "han","die|zha","zhou","chai","wai","nuo|re","huo|guo|xu","yin","zan|za|zBn","yao", - "o|wo","mian","hu","yun","chuan","hui","huan","huan|yuan|xuan|he","xi","he|ye", - "ji","kui","zhong|chuang","wei","sha","xu","huang","duo|zha","yan","xuan", - "liang","yu","sang","chi","qiao|jiao","yan","dan|shan|chan","pen|ben","can|sun|qi","li", - "yo","zha|cha","wei","miao","ying","pen","pbo","kui","xi","yu", - "jie","lou","ku","zao|qiao","hu","ti","yao","he|xiao|hu","sha|a","xiu", - "qiang","se","yong","su","gong|hong","xie","yi|ai","suo","ma|mB","cha", - "hai","ke","ta|da","sang","chen","ru","sou","wa|gu","ji","beng|pang", - "wu","xian|qian|qie","shi","ge","zi","jie","lao","weng","wa","si", - "chi","hao","suo","jia","hai|hei","suo","qin","nie","he","zi", - "sai","ng","ge","na","dia","ai","qiang","tong","bi","ao", - "ao","lian","zui|sui","zhe|zhu","mo","sou","sou","tan","di","qi", - "jiao","chong","jiao|dao","kai|ge","tan","shan|can","cao","jia","ai","xiao", - "piao","lou","ga","gu","xiao|jiao","hu","hui","guo","ou","xian", - "ze","chang","xu|shi","po","de|dei","ma","ma","hu","le","du", - "ga","tang","ye","beng","ying","sai","jiao","mi","xiao","hua", - "mai","ran","zuo","peng","lao","xiao","ji","zhu","chao|zhao","kui", - "zui","xiao","si","hao","fu|?","liao","qiao","xi","chu|xu|shou","tan|chan", - "dan|tan","hei|mo","xun","e","zun","fan|bo","chi","hui","zan","chuang", - "cu|za|he","dan","jue","tun|kuo","ceng","jiao","ye","xi","qi","hao", - "lian","xu|shi","deng","hui","yin","pu","jue","qin","xun","nie", - "lu","si","yan","ying","da","zhan","o","zhou|zhuo","jin","nong", - "yue|hui","xie","qi","e","zao","yi","shi","jiao|qiao|chi","yuan","ai", - "yong","jue|xue","kuai","yu","pen","dao","ga","xin|hen","dun","dang", - "xin","sai","pi","pi","yin","zui","ning","di","lan","ta", - "huo|o","ru","hao","he|xia","yan","duo","xiu|pi","zhou|chou","ji|jie|zhai","jin", - "hao","ti","chang","xun","me","ca|cha","ti","lu","hui","bo|pao|bao", - "you","nie","yin","hu","mei|me|mo","hong","zhe","li","liu","xie|hai", - "nang","xiao","mo","yan","li","lu","long","po","dan","chen", - "pin","pi","xiang","huo","me","xi","duo","ku","yan","chan", - "ying","rang","dian","la","ta","xiao","jiao|jue","chuo","huan","huo", - "zhuan","nie","xiao","ca","li","chan","chai","li","yi","luo", - "nang","za|zan|can","su","xi","zeng","jian","yan|za|nie","zhu","lan","nie", - "nang","ramo","luo","wei|guo","hui","yin","qiu","si","nin","jian|nan", - "hui","xin","yin","nan","tuan","tuan","dun|tun","kang","yuan","jiong", - "pian","yun","cong","hu","hui","yuan","e","guo","kun","cong", - "wei|tong","tu","wei","lun","guo","qun","ri","ling","gu","guo", - "tai","guo","tu","you","guo","yin","hun","pu","yu","han", - "yuan","lun","quan|juan","yu","qing","guo","chuan|chui","wei","yuan","quan|juan", - "ku","pu","yuan","yuan","ya","tuan","tu","tu","tuan","lve", - "hui","yi","huan|yuan","luan","luan","tu","ya","tu","ting","sheng", - "pu","lu","kuai","ya","zai","wei|xu","ge","yu|zhun","wu","gui", - "pi","yi","di|de","qian|su","qian","zhen","zhuo","dang","qia","xia", - "shan","kuang","chang","qi|yin","nie","mo","ji","jia","zhi","zhi", - "ban","xun","yi","qin","mei|fen","jun","rong|keng","tun|dun","fang","ben|fen", - "ben","tan","kan","huai|pei|pi","zuo","keng","bi","jing","di|lan","jing", - "ji","kuai","di","jing","jian","tan","li","ba","wu","fen", - "zhui","po","pan|ban","tang","kun","qu","tan","zhi","tuo","gan", - "ping","dian","gua","ni","tai","pi","jiong","yang","fo","ao", - "lu","qiu","mu","ke","gou","xue","fa","di|chi","che","ling", - "zhu","fu","hu","zhi","chui","la","long","long","lu","ao", - "dai","pao","min","xing","dong|tong","ji","he","lv","ci","chi", - "lei","gai","yin","hou","dui","zhao","fu","guang","yao","duo", - "duo","gui","cha","yang","yin","fa","gou","yuan","die","xie", - "ken","shang","shou","e","bing","dian","hong","ya","kua","da", - "ka","dang","kai","hang","nao","an","xing","xian","yuan|huan","bang", - "pou|fu","ba","yi","yin","han","xu","chui","cen","geng","ai", - "beng|feng","di|fang","que|jue","yong","jun","xia|jia","di","mai|man","lang","juan", - "cheng","yan|shan","qin|jin","zhe","lie","lie","pu|bu","cheng","hua","bu", - "shi","xun","guo","jiong","ye","nian","di","yu","bu","ya", - "quan","sui|su","pi","qing|zheng","wan","ju","lun","zheng|cheng","kong","chong|shang", - "dong","dai","tan","an","cai","chu|tou","beng","xian|kan","zhi","duo", - "yi|shi","zhi","yi","pei","ji","zhun","qi","sao","ju","ni", - "ku","ke","tang","kun","ni","jian","dui","jin","gang","yu", - "e","peng|beng","gu","tu","leng","fang","ya","qian|zan|jian","kun","an", - "shen","duo|hui","nao","tu","cheng","yin","huan","bi","lian","guo", - "die","zhuan","hou","bao|bu|pu","bao","yu","di","mao|mou|wu","jie","ruan", - "e|ai|ye","geng","kan","zong","yu","huang","e","yao","yan","bao", - "ji","mei","chang","du","tuo","yin","feng","zhong","jie","jin", - "feng","gang","chuan","jian","ping","lei","jiang","huang","leng","duan", - "wan","xuan","xi","ji","kuai","ying","ta","cheng","yong","kai", - "su","su","shi","mi","ta","weng","cheng","tu","tang","que", - "zhong","li","peng","bang","sai|se","zang","dui","tian","wu","zheng", - "xun","ge","zhen","ai","gong","yan","xian","tian|zhen","yuan","wen", - "xie","liu","hai","lang","chang","peng","beng","chen","lu","lu", - "ou|qiu","qian|zan|jian","mei","mo","zhuan|tuan","shuang","shu","lou","chi","man", - "biao","jing","qi","shu","zhi|di","zhang","kan","yong","dian","chen", - "zhi|zhuo","xi","guo","qiang","jin","shang","shang","mu","cui","yan", - "ta","zeng","qian","qiang","liang","wei","zhui","qiao","zeng","xu", - "shan","shan","fa","pu","kuai|tui","tuan|dong","fan","qiao|que","mo","dun", - "dun","zun|dun","di","sheng","duo|hui","duo","tan","deng","wu","fen", - "huang","tan","da","ye","zhu","jian","ao","qiang","ji","qiao|ao", - "ken","yi|tu","pi","bi","dian","jiang","ye","yong","xue|bo|jue","tan", - "lan","ju","huai","dang","rang","qian","xun","xian|lan","xi","he", - "ai","ya","dao","hao","ruan","jin","lei","kuang","lu","yan", - "tan","wei","huai","long","long","rui","li","lin","rang","chan", - "xun","yan","lei","ba","wan","shi","ren","san","zhuang","zhuang", - "sheng","yi","mai","ke|qiao","zhu","zhuang","hu","hu","kun","yi", - "hu","xu","kun","shou","mang","dun","shou","yi","zhi|zhong","gu|ying", - "chu","jiang|xiang","feng|pang","bei","zhai","bian","sui","qun","ling","fu", - "cuo","xia","xiong|xuan","xie","nao","xia","kui","xi","wai","yuan|wan", - "mao|wan","su","duo","duo","ye","qing","yi","gou","gou","qi", - "meng","meng","yin","huo","chen","da|dai","ce","tian","tai","fu", - "guai","yao","yang","hang|ben","gao","shi","tao|ben","tai","tou","yan|tao", - "bi","yi","kua","jia|ga|xia","duo","hua","kuang","yun","jia|ga|xia","ba", - "en","lian","huan","di|ti","yan","pao","juan","qi|ji","nai","feng", - "xie","fen","dian","quan|juan","kui","zou","huan","qi|qie|xie","kai","she|chi|zha", - "ben","yi","jiang","tao","zang|zhuang","ben","xi","huang","fei","diao", - "xun|zhui","beng","dian","ao","she","weng","po|ha|tai","ao|yu","wu","ao|yu", - "jiang","lian","duo","yun","jiang","shi","fen","huo","bi","luan", - "duo|che","nv","nu","ding|tian","nai","qian","jian","ta|jie","jiu","nuan", - "cha","hao","xian","fan","ji","shuo","ru","fei|pei","wang","hong", - "zhuang","fu","ma","dan","ren","fu|you","jing","yan","hai|jie","wen", - "zhong","pa","du","ji","keng|hang","zhong","yao","jin","yun","miao", - "fou|pei|pi","chi","yue|jue","zhuang","niu","yan","na|nan","xin","fen","bi", - "yu","tuo","feng","wan|yuan","fang","wu","yu","gui","du","ba", - "ni","zhou","zhuo","zhao","da","ni|nai","yuan","tou","xian|xuan|xu","zhi|yi", - "e","mei","mo","qi","bi","shen","qie","e","he","xu", - "fa","zheng","min","ban","mu","fu","ling","zi","zi","shi", - "ran","shan","yang","gan","jie","gu","si","xing","wei","zi", - "ju","shan","pin","ren","yao","dong","jiang","shu","ji","gai", - "xiang","hua|huo","juan","jiao|xiao","gou|du","mu|lao","jian","jian","yi","nian", - "zhi","zhen","ji","xian","heng","guang","jun|xun","kua|hu","yan","ming", - "lie","pei","e","you","yan","cha","shen|xian","yin","shi","gui", - "quan","zi","song","wei","hong","wa","lou","ya","rao","jiao", - "luan","ping","xian","shao","li","cheng|sheng","xie","mang","fu","suo", - "wu|mu","wei","ke","chuo|lai","chuo","ting","niang","xing","nan","yu", - "na|nuo","pou|bi","nei|sui","juan","shen","zhi","han","di","zhuang","e", - "pin","tui","man","mian","wu|yu","yan","wu","xi|ai","yan","yu", - "si","yu","wa","li","xian","ju","qu","zhui|shui","qi","xian", - "zhuo","dong","chang","lu","ai|e","e","e","lou","mian","cong", - "pou|pei|bu","ju","po","cai","ling","wan","biao","xiao","shu","qi", - "hui","fu|fan","wo","wo","tan","fei","fei","jie","tian","ni", - "quan|juan","jing","hun","jing","qian|jin","dian","xing","hu","wan|wa","lai", - "bi","yin","zhou|chou","chuo|nao","fu","jing","lun","an|n= CHINESE_COUNT , MS_MEDIA_ERR_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]); - for(i=0, j=0; i<=len; i++) { - if (pinyin_spell_table[offset][i]== DUOYINZI_SEPERATOR - || pinyin_spell_table[offset][i] == '\0') { - strncpy(spell[count], pinyin_spell_table[offset]+j, i-j); - j=i+1; + for (i = 0, j = 0; i <= len; i++) { + if (pinyin_spell_table[offset][i] == DUOYINZI_SEPERATOR + || pinyin_spell_table[offset][i] == '\0') { + strncpy(spell[count], pinyin_spell_table[offset] + j, i - j); + j = i + 1; count++; } } @@ -2169,8 +2170,7 @@ __media_svc_has_chinese(const UChar *src) len = u_strlen(src); - for (i = 0; i < len; i++) - { + for (i = 0; i < len; i++) { if (__media_svc_is_chinese(&src[i])) return true; } @@ -2180,14 +2180,14 @@ __media_svc_has_chinese(const UChar *src) bool _media_svc_has_chinese(const char *src) { - UChar temp[strlen(src)+1]; + UChar temp[strlen(src) + 1]; UErrorCode status = 0; - media_svc_retvm_if(src==NULL, false, "src is NULL"); + media_svc_retvm_if(src == NULL, false, "src is NULL"); media_svc_retvm_if(!*src, false, "*src is NULL"); u_strFromUTF8(temp, array_sizeof(temp), NULL, src, -1, &status); - if (U_FAILURE(status)){ + if (U_FAILURE(status)) { media_svc_error("u_strFromUTF8 Failed(%s)", u_errorName(status)); return false; } @@ -2199,8 +2199,8 @@ bool _media_svc_has_chinese(const char *src) int _media_svc_convert_chinese_to_pinyin(const char *src, pinyin_name_s **name, int *size) { - UChar temp_result[strlen(src)+1]; - int count = 0, len=0, total_count=0; + UChar temp_result[strlen(src) + 1]; + int count = 0, len = 0, total_count = 0; int ret, i, j; int multi_pinyin_count = 0; UErrorCode status = 0; @@ -2208,11 +2208,11 @@ int _media_svc_convert_chinese_to_pinyin(const char *src, pinyin_name_s **name, *size = 0; - media_svc_retvm_if(src==NULL, MS_MEDIA_ERR_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)){ + if (U_FAILURE(status)) { media_svc_error("u_strFromUTF8 Failed(%s)", u_errorName(status)); return MS_MEDIA_ERR_INTERNAL; } @@ -2224,7 +2224,7 @@ int _media_svc_convert_chinese_to_pinyin(const char *src, pinyin_name_s **name, memset(spell, 0x0, len * CHINESE_DUOYINZI_MAX_COUNT * CHINESE_PINYIN_SPELL_MAX_LEN); for (count = 0; count < len; count++) { - if (temp_result[count] == 0xFEFF ||temp_result[count] == 0xFFFE) {// ||temp_result[count] == 0xFF) { + if (temp_result[count] == 0xFEFF || temp_result[count] == 0xFFFE) { /* ||temp_result[count] == 0xFF) { */ media_svc_error("FIND BOM, GO TO THE NEXT CHARACTER"); pinyin_spell_count[count] = 1; continue; @@ -2238,14 +2238,13 @@ int _media_svc_convert_chinese_to_pinyin(const char *src, pinyin_name_s **name, pinyin_spell_count[count] = ret; - if(total_count==0) + if (total_count == 0) total_count = ret; else total_count *= ret; if (ret > 1) - multi_pinyin_count ++; - } - else { + multi_pinyin_count++; + } else { UChar temp[2]; int temp_size; @@ -2253,28 +2252,28 @@ int _media_svc_convert_chinese_to_pinyin(const char *src, pinyin_name_s **name, temp[1] = 0x00; u_strToUTF8(spell[count][0], 10, &temp_size, temp, -1, &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'; + 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, MS_MEDIA_ERR_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]; int initial_len[total_count]; int pinyin_name_len = sizeof(char) * ((len + 2) * CHINESE_PINYIN_SPELL_MAX_LEN); int pinyin_initial_len = sizeof(char) * (len * 5 + 1); - for(i=0; i < count ; i++) { - for(j=0;j 0) { if (char_len == 1) initial_len[j] += snprintf(temp_name[j].pinyin_initial + initial_len[j], pinyin_initial_len - initial_len[j], - "%c", spell[i][index][0]); + "%c", spell[i][index][0]); else { char temp[10]; snprintf(temp, sizeof(temp), "%s", spell[i][index]); - temp[char_len] ='\0'; + temp[char_len] = '\0'; initial_len[j] += snprintf(temp_name[j].pinyin_initial + initial_len[j], pinyin_initial_len - initial_len[j], - "%s", temp); + "%s", temp); } } else { media_svc_error("_media_svc_check_utf8 failed"); @@ -2321,7 +2320,7 @@ void _media_svc_pinyin_free(pinyin_name_s *pinyinname, int size) if (pinyinname == NULL) return; - for (i=0;i Yi -> Bopomofo +/* Chinese->Yi->Bopomofo */ -static UChar* __media_svc_bopomofo_find(bopomofo_map *table, int size, UChar src) { +static UChar *__media_svc_bopomofo_find(bopomofo_map *table, int size, UChar src) +{ int lowerBound = 0; int upperBound = size - 1; int curIn; @@ -14048,7 +14049,7 @@ static UChar* __media_svc_bopomofo_find(bopomofo_map *table, int size, UChar src while (true) { curIn = (lowerBound + upperBound) / 2; if (table[curIn].yi_syllable == src) { - return (UChar*)table[curIn].bopomofo; + return (UChar *)table[curIn].bopomofo; } else if (lowerBound > upperBound) { return NULL; } else { @@ -14062,7 +14063,8 @@ static UChar* __media_svc_bopomofo_find(bopomofo_map *table, int size, UChar src return NULL; } -static UChar __media_svc_yi_syllable_find(han_map *table, int size, UChar src) { +static UChar __media_svc_yi_syllable_find(han_map *table, int size, UChar src) +{ int lowerBound = 0; int upperBound = size - 1; int curIn; @@ -14071,11 +14073,9 @@ static UChar __media_svc_yi_syllable_find(han_map *table, int size, UChar src) { curIn = (lowerBound + upperBound) / 2; if (table[curIn].han == src) { return table[curIn].yi_syllable; - } - else if (lowerBound > upperBound) { + } else if (lowerBound > upperBound) { return -1; - } - else { + } else { if (table[curIn].han < src) lowerBound = curIn + 1; else @@ -14116,21 +14116,19 @@ static void __media_svc_get_bopomofo(UChar src, UChar dest[], int *len) } UChar *temp = __media_svc_bopomofo_find(UNICODES, array_sizeof(UNICODES), code); - if(temp) { - int i=0; - int j=0; - while(temp[i] != 0x0 && i < 3) + if (temp) { + int i = 0; + int j = 0; + while (temp[i] != 0x0 && i < 3) dest[j++] = temp[i++]; *len = j; - } - else { + } else { dest[0] = src; dest[1] = 0x0; *len = 1; } return; - } - else { + } else { dest[0] = src; dest[1] = 0x0; *len = 1; @@ -14165,11 +14163,9 @@ static const UChar *__media_svc_get_bpmf(const UChar src) else { return NULL; } - } - else if (src >= 0x3105 && src <= 0x3129) { + } else if (src >= 0x3105 && src <= 0x3129) { code = __media_svc_yi_syllable_find(BPMF_TO_BPMF_MAP, array_sizeof(BPMF_TO_BPMF_MAP), src); - } - else + } else return NULL; return __media_svc_bopomofo_find(UNICODES, array_sizeof(UNICODES), code); @@ -14199,7 +14195,7 @@ int _media_svc_get_bopomofo(const char *src, char **dest) status = U_ZERO_ERROR; tmp_result = calloc(1, sizeof(UChar) * (size + 1)); u_strFromUTF8(tmp_result, size + 1, NULL, src, -1, &status); - if (U_FAILURE(status)){ + if (U_FAILURE(status)) { media_svc_error("u_strFromUTF8 Failed(%s)", u_errorName(status)); ret = MS_MEDIA_ERR_INTERNAL; goto DATA_FREE; @@ -14210,7 +14206,7 @@ int _media_svc_get_bopomofo(const char *src, char **dest) for (i = 0; i < size; i++) { char *tmp = NULL; int tmp_size = 0; - UChar *bopomofo = calloc(1, sizeof(UChar)*4); + UChar *bopomofo = calloc(1, sizeof(UChar) * 4); if (bopomofo == NULL) { media_svc_error("u_strToUTF8 to allocate memory Failed"); ret = MS_MEDIA_ERR_OUT_OF_MEMORY; @@ -14227,9 +14223,8 @@ int _media_svc_get_bopomofo(const char *src, char **dest) } status = U_ZERO_ERROR; - tmp = calloc(1, sizeof(char)*(tmp_size+1)); - if (tmp == NULL) - { + tmp = calloc(1, sizeof(char) * (tmp_size + 1)); + if (tmp == NULL) { media_svc_error("u_strToUTF8 to allocate memory Failed"); ret = MS_MEDIA_ERR_OUT_OF_MEMORY; free(bopomofo); @@ -14269,9 +14264,9 @@ int _media_svc_convert_chinese_to_bpmf(const char *src, media_svc_bpmf_name_s ** UErrorCode status = U_ZERO_ERROR; int32_t size = 0; - char bpmf_name[MAX_BPMF_NAME_LENGTH*3+1]; - char bpmf_initial_name[MAX_BPMF_NAME_LENGTH*3+1]; - char single_bpmf[MAX_BPMF_COUNT*3 + 1]; + char bpmf_name[MAX_BPMF_NAME_LENGTH * 3 + 1]; + char bpmf_initial_name[MAX_BPMF_NAME_LENGTH * 3 + 1]; + char single_bpmf[MAX_BPMF_COUNT * 3 + 1]; *dest = NULL; @@ -14282,13 +14277,13 @@ int _media_svc_convert_chinese_to_bpmf(const char *src, media_svc_bpmf_name_s ** } temp_string = calloc(1, sizeof(UChar) * (size + 1)); - if (temp_string == NULL){ + if (temp_string == NULL) { media_svc_error("u_strFromUTF8 Failed"); return MS_MEDIA_ERR_OUT_OF_MEMORY; } status = U_ZERO_ERROR; u_strFromUTF8(temp_string, size + 1, NULL, src, -1, &status); - if (U_FAILURE(status)){ + if (U_FAILURE(status)) { media_svc_error("u_strFromUTF8 Failed(%s)", u_errorName(status)); free(temp_string); return MS_MEDIA_ERR_INTERNAL; @@ -14298,48 +14293,46 @@ int _media_svc_convert_chinese_to_bpmf(const char *src, media_svc_bpmf_name_s ** int total_len = 0; int total_initial_len = 0; - for (i = 0; i < size; i++){ + for (i = 0; i < size; i++) { int len = 0; const UChar *bpmf = __media_svc_get_bpmf(temp_string[i]); if (bpmf) { - u_strToUTF8(single_bpmf, MAX_BPMF_COUNT*3 + 1, &len, bpmf, -1, &status); + u_strToUTF8(single_bpmf, MAX_BPMF_COUNT * 3 + 1, &len, bpmf, -1, &status); - // total - if (total_len < MAX_BPMF_NAME_LENGTH*3) { + /* total */ + if (total_len < MAX_BPMF_NAME_LENGTH * 3) { if (total_len > 0) - total_len += snprintf(bpmf_name + total_len, MAX_BPMF_NAME_LENGTH*3+1 - total_len, " %s", single_bpmf); + total_len += snprintf(bpmf_name + total_len, MAX_BPMF_NAME_LENGTH * 3 + 1 - total_len, " %s", single_bpmf); else - total_len += snprintf(bpmf_name + total_len, MAX_BPMF_NAME_LENGTH*3+1 - total_len, "%s", single_bpmf); + total_len += snprintf(bpmf_name + total_len, MAX_BPMF_NAME_LENGTH * 3 + 1 - total_len, "%s", single_bpmf); } - // initial - if (total_initial_len < MAX_BPMF_NAME_LENGTH*3) { - single_bpmf[3]='\0'; - total_initial_len += snprintf(bpmf_initial_name + total_initial_len, MAX_BPMF_NAME_LENGTH*3+1 - total_initial_len, "%s", single_bpmf); + /* initial */ + if (total_initial_len < MAX_BPMF_NAME_LENGTH * 3) { + single_bpmf[3] = '\0'; + total_initial_len += snprintf(bpmf_initial_name + total_initial_len, MAX_BPMF_NAME_LENGTH * 3 + 1 - total_initial_len, "%s", single_bpmf); } - } - else { - if ((temp_string[i] >= 0x30 && temp_string[i] <= 0x39) || // 0~9 - (temp_string[i] >= 0x41 && temp_string[i] <= 0x5a) || // A~Z - (temp_string[i] >= 0x61 && temp_string[i] <= 0x7a)) { // a~z + } else { + if ((temp_string[i] >= 0x30 && temp_string[i] <= 0x39) || /* 0~9 */ + (temp_string[i] >= 0x41 && temp_string[i] <= 0x5a) || /* A~Z */ + (temp_string[i] >= 0x61 && temp_string[i] <= 0x7a)) { /* a~z */ - single_bpmf[0] = temp_string[i]&0xff; - single_bpmf[1] = '\0'; + single_bpmf[0] = temp_string[i] & 0xff; + single_bpmf[1] = '\0'; - if (total_len < MAX_BPMF_NAME_LENGTH*3) - total_len += snprintf(bpmf_name + total_len, MAX_BPMF_NAME_LENGTH*3+1 - total_len, "%s", single_bpmf); + if (total_len < MAX_BPMF_NAME_LENGTH * 3) + total_len += snprintf(bpmf_name + total_len, MAX_BPMF_NAME_LENGTH * 3 + 1 - total_len, "%s", single_bpmf); - if (total_initial_len < MAX_BPMF_NAME_LENGTH*3) - total_initial_len += snprintf(bpmf_initial_name + total_initial_len, MAX_BPMF_NAME_LENGTH*3+1 - total_initial_len, "%s", single_bpmf); - } + if (total_initial_len < MAX_BPMF_NAME_LENGTH * 3) + total_initial_len += snprintf(bpmf_initial_name + total_initial_len, MAX_BPMF_NAME_LENGTH * 3 + 1 - total_initial_len, "%s", single_bpmf); + } } } if (total_len > 0) { media_svc_bpmf_name_s *bpmf = calloc(1, sizeof(media_svc_bpmf_name_s)); - if (bpmf == NULL) - { + if (bpmf == NULL) { free(temp_string); return MS_MEDIA_ERR_OUT_OF_MEMORY; } @@ -14357,62 +14350,62 @@ int _media_svc_convert_chinese_to_bpmf(const char *src, media_svc_bpmf_name_s ** char _media_svc_bpmf_get_fuzzy_number(const char *src) { char fuzzy_number = '*'; - switch(src[2]) { - case 0x85: // \u3105 : u3105, e3 84 85 - 1 - case 0x86: // \u3106 : u3106, e3 84 86 - 1 - case 0x87: // \u3107 : u3107, e3 84 87 - 1 - case 0x88: // \u3108 : u3108, e3 84 88 - 1 + switch (src[2]) { + case 0x85: /* \u3105 : u3105, e3 84 85 - 1 */ + case 0x86: /* \u3106 : u3106, e3 84 86 - 1 */ + case 0x87: /* \u3107 : u3107, e3 84 87 - 1 */ + case 0x88: /* \u3108 : u3108, e3 84 88 - 1 */ fuzzy_number = '1'; break; - case 0x89: // \u3109: u3109, e3 84 89 - 2 - case 0x8a: // \u310a: u310a, e3 84 8a - 2 - case 0x8b: // \u310b: u310b, e3 84 8b - 2 - case 0x8c: // \u310c: u310c, e3 84 8c - 2 + case 0x89: /* \u3109: u3109, e3 84 89 - 2 */ + case 0x8a: /* \u310a: u310a, e3 84 8a - 2 */ + case 0x8b: /* \u310b: u310b, e3 84 8b - 2 */ + case 0x8c: /* \u310c: u310c, e3 84 8c - 2 */ fuzzy_number = '2'; break; - case 0x8d: // \u310d: u310d, e3 84 8d - 3 - case 0x8e: // \u310e: u310e, e3 84 8e - 3 - case 0x8f: // \u310f: u310f, e3 84 8f - 3 + case 0x8d: /* \u310d: u310d, e3 84 8d - 3 */ + case 0x8e: /* \u310e: u310e, e3 84 8e - 3 */ + case 0x8f: /* \u310f: u310f, e3 84 8f - 3 */ fuzzy_number = '3'; break; - case 0x90: // \u3110: u3110, e3 84 90 - 4 - case 0x91: // \u3111: u3111, e3 84 91 - 4 - case 0x92: // \u3112: u3112, e3 84 92 - 4 + case 0x90: /* \u3110: u3110, e3 84 90 - 4 */ + case 0x91: /* \u3111: u3111, e3 84 91 - 4 */ + case 0x92: /* \u3112: u3112, e3 84 92 - 4 */ fuzzy_number = '4'; break; - case 0x93: // \u3113: u3113, e3 84 93 - 5 - case 0x94: // \u3114: u3114, e3 84 94 - 5 - case 0x95: // \u3115: u3115, e3 84 95 - 5 - case 0x96: // \u3116: u3116, e3 84 96 - 5 + case 0x93: /* \u3113: u3113, e3 84 93 - 5 */ + case 0x94: /* \u3114: u3114, e3 84 94 - 5 */ + case 0x95: /* \u3115: u3115, e3 84 95 - 5 */ + case 0x96: /* \u3116: u3116, e3 84 96 - 5 */ fuzzy_number = '5'; break; - case 0x97: // \u3117: u3117, e3 84 97 - 6 - case 0x98: // \u3118: u3118, e3 84 98 - 6 - case 0x99: // \u3119: u3119, e3 84 99 - 6 + case 0x97: /* \u3117: u3117, e3 84 97 - 6 */ + case 0x98: /* \u3118: u3118, e3 84 98 - 6 */ + case 0x99: /* \u3119: u3119, e3 84 99 - 6 */ fuzzy_number = '6'; break; - case 0x9a: // \u311a: u311a, e3 84 9a - 7 - case 0x9b: // \u311b: u311b, e3 84 9b - 7 - case 0x9c: // \u311c: u311c, e3 84 9c - 7 - case 0x9d: // \u311d: u311d, e3 84 9d - 7 + case 0x9a: /* \u311a: u311a, e3 84 9a - 7 */ + case 0x9b: /* \u311b: u311b, e3 84 9b - 7 */ + case 0x9c: /* \u311c: u311c, e3 84 9c - 7 */ + case 0x9d: /* \u311d: u311d, e3 84 9d - 7 */ fuzzy_number = '7'; break; - case 0x9e: // \u311e: u311e, e3 84 9e - 8 - case 0x9f: // \u311f: u311f, e3 84 9f - 8 - case 0xa0: // \u3120: u3120, e3 84 a0 - 8 - case 0xa1: // \u3121: u3121, e3 84 a1 - 8 + case 0x9e: /* \u311e: u311e, e3 84 9e - 8 */ + case 0x9f: /* \u311f: u311f, e3 84 9f - 8 */ + case 0xa0: /* \u3120: u3120, e3 84 a0 - 8 */ + case 0xa1: /* \u3121: u3121, e3 84 a1 - 8 */ fuzzy_number = '8'; break; - case 0xa2: // \u3122: u3122, e3 84 a2 - 9 - case 0xa3: // \u3123: u3123, e3 84 a3 - 9 - case 0xa4: // \u3124: u3124, e3 84 a4 - 9 - case 0xa5: // \u3125: u3125, e3 84 a5 - 9 - case 0xa6: // \u3126: u3126, e3 84 a6 - 9 + case 0xa2: /* \u3122: u3122, e3 84 a2 - 9 */ + case 0xa3: /* \u3123: u3123, e3 84 a3 - 9 */ + case 0xa4: /* \u3124: u3124, e3 84 a4 - 9 */ + case 0xa5: /* \u3125: u3125, e3 84 a5 - 9 */ + case 0xa6: /* \u3126: u3126, e3 84 a6 - 9 */ fuzzy_number = '9'; break; - case 0xa7: // \u3127: u3127, e3 84 a7 - 0 - case 0xa8: // \u3128: u3128, e3 84 a8 - 0 - case 0xa9: // \u3129: u3129, e3 84 a9 - 0 + case 0xa7: /* \u3127: u3127, e3 84 a7 - 0 */ + case 0xa8: /* \u3128: u3128, e3 84 a8 - 0 */ + case 0xa9: /* \u3129: u3129, e3 84 a9 - 0 */ fuzzy_number = '0'; break; default: diff --git a/src/common/media-svc-media-folder.c b/src/common/media-svc-media-folder.c index f500681..abefac9 100755 --- a/src/common/media-svc-media-folder.c +++ b/src/common/media-svc-media-folder.c @@ -35,7 +35,7 @@ int _media_svc_get_folder_id_by_foldername(sqlite3 *handle, const char *storage_ sqlite3_stmt *sql_stmt = NULL; char *sql = NULL; - if(STRING_VALID(storage_id)) + if (STRING_VALID(storage_id)) sql = sqlite3_mprintf("SELECT folder_uuid FROM '%s' WHERE storage_uuid = '%q' AND path = '%q';", MEDIA_SVC_DB_TABLE_FOLDER, storage_id, folder_name); else sql = sqlite3_mprintf("SELECT folder_uuid FROM '%s' WHERE path = '%q';", MEDIA_SVC_DB_TABLE_FOLDER, folder_name); @@ -43,16 +43,15 @@ int _media_svc_get_folder_id_by_foldername(sqlite3 *handle, const char *storage_ ret = _media_svc_sql_prepare_to_step(handle, sql, &sql_stmt); if (ret != MS_MEDIA_ERR_NONE) { - if(ret == MS_MEDIA_ERR_DB_NO_RECORD) { + if (ret == MS_MEDIA_ERR_DB_NO_RECORD) { media_svc_debug("there is no folder."); - } - else { + } else { media_svc_error("error when _media_svc_get_folder_id_by_foldername. err = [%d]", ret); } return ret; } - _strncpy_safe(folder_id, (const char *)sqlite3_column_text(sql_stmt, 0), MEDIA_SVC_UUID_SIZE+1); + _strncpy_safe(folder_id, (const char *)sqlite3_column_text(sql_stmt, 0), MEDIA_SVC_UUID_SIZE + 1); SQLITE3_FINALIZE(sql_stmt); @@ -60,18 +59,18 @@ int _media_svc_get_folder_id_by_foldername(sqlite3 *handle, const char *storage_ } int _media_svc_append_folder(sqlite3 *handle, const char *storage_id, media_svc_storage_type_e storage_type, - const char *folder_id, const char *path_name, const char *folder_name, int modified_date, const char *parent_folder_uuid, uid_t uid) + const char *folder_id, const char *path_name, const char *folder_name, int modified_date, const char *parent_folder_uuid, uid_t uid) { int ret = MS_MEDIA_ERR_NONE; /*Update Pinyin If Support Pinyin*/ char *folder_name_pinyin = NULL; - if(_media_svc_check_pinyin_support()) + if (_media_svc_check_pinyin_support()) _media_svc_get_pinyin_str(folder_name, &folder_name_pinyin); char *sql = sqlite3_mprintf("INSERT INTO %s (folder_uuid, path, name, storage_uuid, storage_type, modified_time, name_pinyin, parent_folder_uuid) \ values (%Q, %Q, %Q, %Q, '%d', '%d', %Q, %Q); ", - MEDIA_SVC_DB_TABLE_FOLDER, folder_id, path_name, folder_name, storage_id, storage_type, modified_date, folder_name_pinyin, parent_folder_uuid); + MEDIA_SVC_DB_TABLE_FOLDER, folder_id, path_name, folder_name, storage_id, storage_type, modified_date, folder_name_pinyin, parent_folder_uuid); ret = _media_svc_sql_query(handle, sql, uid); sqlite3_free(sql); @@ -89,7 +88,7 @@ int _media_svc_update_folder_modified_time_by_folder_uuid(sqlite3 *handle, const 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) { + if (!stack_query) { ret = _media_svc_sql_query(handle, sql, uid); sqlite3_free(sql); } else { @@ -109,71 +108,62 @@ int __media_svc_get_and_append_parent_folder(sqlite3 *handle, const char *storag char *folder_uuid = NULL; char *folder_name = NULL; int folder_modified_date = 0; - char parent_folder_uuid[MEDIA_SVC_UUID_SIZE+1] = {0,}; + char parent_folder_uuid[MEDIA_SVC_UUID_SIZE + 1] = {0, }; bool folder_search_end = FALSE; memset(parent_folder_uuid, 0, sizeof(parent_folder_uuid)); - if(strncmp(path, _media_svc_get_path(uid), strlen(_media_svc_get_path(uid))) == 0) + if (strncmp(path, _media_svc_get_path(uid), strlen(_media_svc_get_path(uid))) == 0) next_pos = strlen(_media_svc_get_path(uid)); else if (strncmp(path, MEDIA_ROOT_PATH_SDCARD, strlen(MEDIA_ROOT_PATH_SDCARD)) == 0) next_pos = strlen(MEDIA_ROOT_PATH_SDCARD); - else - { + else { media_svc_error("Invalid Path"); return MS_MEDIA_ERR_INTERNAL; } - while (!folder_search_end) - { - next = strstr(path + next_pos , token); - if (next != NULL) - { + while (!folder_search_end) { + next = strstr(path + next_pos, token); + if (next != NULL) { next_pos = (next - path); dir_path = strndup(path, next_pos); next_pos++; - } - else - { + } else { media_svc_error("End Path"); dir_path = strndup(path, strlen(path)); folder_search_end = TRUE; } ret = _media_svc_get_folder_id_by_foldername(handle, storage_id, dir_path, parent_folder_uuid); - if (ret == MS_MEDIA_ERR_DB_NO_RECORD) - { + if (ret == MS_MEDIA_ERR_DB_NO_RECORD) { media_svc_error("NOT EXIST dir path : %s", dir_path); folder_uuid = _media_info_generate_uuid(); - if(folder_uuid == NULL ) - { - media_svc_error("Invalid UUID"); + if (folder_uuid == NULL) { + media_svc_error("Invalid UUID"); SAFE_FREE(dir_path); - return MS_MEDIA_ERR_INTERNAL; - } + return MS_MEDIA_ERR_INTERNAL; + } folder_name = g_path_get_basename(dir_path); folder_modified_date = _media_svc_get_file_time(dir_path); ret = _media_svc_append_folder(handle, storage_id, storage_type, folder_uuid, dir_path, folder_name, folder_modified_date, parent_folder_uuid, uid); - if (ret != MS_MEDIA_ERR_NONE) { - media_svc_error("_media_svc_append_folder is failed"); - } + if (ret != MS_MEDIA_ERR_NONE) { + media_svc_error("_media_svc_append_folder is failed"); + } - _strncpy_safe(parent_folder_uuid, folder_uuid, MEDIA_SVC_UUID_SIZE+1); + _strncpy_safe(parent_folder_uuid, folder_uuid, MEDIA_SVC_UUID_SIZE + 1); - SAFE_FREE(folder_name); - } - else - { + SAFE_FREE(folder_name); + } else { media_svc_error("EXIST dir path : %s\n", dir_path); } SAFE_FREE(dir_path); } - _strncpy_safe(folder_id, folder_uuid, MEDIA_SVC_UUID_SIZE+1); + _strncpy_safe(folder_id, folder_uuid, MEDIA_SVC_UUID_SIZE + 1); return MS_MEDIA_ERR_NONE; } @@ -184,8 +174,7 @@ int _media_svc_get_and_append_folder(sqlite3 *handle, const char *storage_id, co ret = _media_svc_get_folder_id_by_foldername(handle, storage_id, path, folder_id); - if(ret == MS_MEDIA_ERR_DB_NO_RECORD) - { + if (ret == MS_MEDIA_ERR_DB_NO_RECORD) { ret = __media_svc_get_and_append_parent_folder(handle, storage_id, path, storage_type, folder_id, uid); } @@ -212,7 +201,7 @@ int _media_svc_update_folder_table(sqlite3 *handle, uid_t uid) 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); + MEDIA_SVC_DB_TABLE_FOLDER, MEDIA_SVC_DB_TABLE_FOLDER, MEDIA_SVC_DB_TABLE_MEDIA); ret = _media_svc_sql_query(handle, sql, uid); sqlite3_free(sql); @@ -220,7 +209,7 @@ int _media_svc_update_folder_table(sqlite3 *handle, uid_t uid) return ret; } -static int __media_svc_count_all_folders(sqlite3 *handle, char* start_path, int *count) +static int __media_svc_count_all_folders(sqlite3 *handle, char *start_path, int *count) { int ret = MS_MEDIA_ERR_NONE; sqlite3_stmt *sql_stmt = NULL; @@ -245,9 +234,9 @@ int _media_svc_get_all_folders(sqlite3 *handle, char *start_path, char ***folder int idx = 0; sqlite3_stmt *sql_stmt = NULL; char *sql = NULL; - int cnt =0; + int cnt = 0; char **folder_uuid = NULL; - int i =0; + int i = 0; ret = __media_svc_count_all_folders(handle, start_path, &cnt); if (ret != MS_MEDIA_ERR_NONE) { @@ -269,7 +258,7 @@ int _media_svc_get_all_folders(sqlite3 *handle, char *start_path, char ***folder *item_num_list = malloc(sizeof(int) * cnt); folder_uuid = malloc(sizeof(char *) * cnt); - if((*folder_list == NULL) || (*modified_time_list == NULL) || (*item_num_list == NULL) ||(folder_uuid == NULL)) { + if ((*folder_list == NULL) || (*modified_time_list == NULL) || (*item_num_list == NULL) || (folder_uuid == NULL)) { media_svc_error("Out of memory"); goto ERROR; } @@ -284,25 +273,25 @@ int _media_svc_get_all_folders(sqlite3 *handle, char *start_path, char ***folder media_svc_debug("QEURY OK"); while (1) { - if(STRING_VALID((char *)sqlite3_column_text(sql_stmt, 0))) + if (STRING_VALID((char *)sqlite3_column_text(sql_stmt, 0))) (*folder_list)[idx] = strdup((char *)sqlite3_column_text(sql_stmt, 0)); (*modified_time_list)[idx] = (int)sqlite3_column_int(sql_stmt, 1); /* get the folder's id */ - if(STRING_VALID((char *)sqlite3_column_text(sql_stmt, 2))) + if (STRING_VALID((char *)sqlite3_column_text(sql_stmt, 2))) folder_uuid[idx] = strdup((char *)sqlite3_column_text(sql_stmt, 2)); idx++; - if(sqlite3_step(sql_stmt) != SQLITE_ROW) + if (sqlite3_step(sql_stmt) != SQLITE_ROW) break; } SQLITE3_FINALIZE(sql_stmt); /*get the numbder of item in the folder by using folder's id */ - for (i = 0; i < idx; i ++) { - if(STRING_VALID(folder_uuid[i])) { + for (i = 0; i < idx; i++) { + if (STRING_VALID(folder_uuid[i])) { sql = sqlite3_mprintf("SELECT COUNT(*) FROM %s WHERE (folder_uuid='%q' AND validity = 1)", MEDIA_SVC_DB_TABLE_MEDIA, folder_uuid[i]); ret = _media_svc_sql_prepare_to_step(handle, sql, &sql_stmt); if (ret != MS_MEDIA_ERR_NONE) { @@ -313,8 +302,7 @@ int _media_svc_get_all_folders(sqlite3 *handle, char *start_path, char ***folder (*item_num_list)[i] = (int)sqlite3_column_int(sql_stmt, 0); SQLITE3_FINALIZE(sql_stmt); - } else - { + } else { media_svc_error("Invalid Folder Id"); } } @@ -329,7 +317,7 @@ int _media_svc_get_all_folders(sqlite3 *handle, char *start_path, char ***folder } /* free all data */ - for (i = 0; i < idx; i ++) { + for (i = 0; i < idx; i++) { SAFE_FREE(folder_uuid[i]); } SAFE_FREE(folder_uuid); @@ -339,7 +327,7 @@ int _media_svc_get_all_folders(sqlite3 *handle, char *start_path, char ***folder ERROR: /* free all data */ - for (i = 0; i < idx; i ++) { + for (i = 0; i < idx; i++) { SAFE_FREE((*folder_list)[i]); SAFE_FREE(folder_uuid[i]); } @@ -363,16 +351,15 @@ int _media_svc_get_folder_info_by_foldername(sqlite3 *handle, const char *folder ret = _media_svc_sql_prepare_to_step(handle, sql, &sql_stmt); if (ret != MS_MEDIA_ERR_NONE) { - if(ret == MS_MEDIA_ERR_DB_NO_RECORD) { + if (ret == MS_MEDIA_ERR_DB_NO_RECORD) { media_svc_debug("there is no folder."); - } - else { + } else { media_svc_error("error when _media_svc_get_folder_id_by_foldername. err = [%d]", ret); } return ret; } - _strncpy_safe(folder_id, (const char *)sqlite3_column_text(sql_stmt, 0), MEDIA_SVC_UUID_SIZE+1); + _strncpy_safe(folder_id, (const char *)sqlite3_column_text(sql_stmt, 0), MEDIA_SVC_UUID_SIZE + 1); *modified_time = (int)sqlite3_column_int(sql_stmt, 1); SQLITE3_FINALIZE(sql_stmt); diff --git a/src/common/media-svc-media.c b/src/common/media-svc-media.c index dcccc5b..66111d5 100755 --- a/src/common/media-svc-media.c +++ b/src/common/media-svc-media.c @@ -32,11 +32,11 @@ #include "media-svc-db-utils.h" #include "media-svc-noti.h" -#define GLOBAL_USER 0 //#define tzplatform_getenv(TZ_GLOBAL) //TODO +#define GLOBAL_USER 0 /*#define tzplatform_getenv(TZ_GLOBAL) //TODO */ -typedef struct{ +typedef struct { char thumbnail_path[MEDIA_SVC_PATHNAME_SIZE]; -}media_svc_thumbnailpath_s; +} media_svc_thumbnailpath_s; static __thread GList *g_media_svc_item_validity_query_list = NULL; static __thread GList *g_media_svc_insert_item_query_list = NULL; @@ -45,17 +45,17 @@ static __thread GList *g_media_svc_update_item_query_list = NULL; static int __media_svc_count_invalid_records_with_thumbnail(sqlite3 *handle, media_svc_storage_type_e storage_type, int *count); 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 count, media_svc_thumbnailpath_s *thumb_path); static int __media_svc_count_invalid_folder_records_with_thumbnail(sqlite3 *handle, const char *folder_path, int *count); 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 count, media_svc_thumbnailpath_s *thumb_path); static int __media_svc_count_invalid_records_with_thumbnail(sqlite3 *handle, media_svc_storage_type_e storage_type, int *count) { 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); + MEDIA_SVC_DB_TABLE_MEDIA, storage_type); ret = _media_svc_sql_prepare_to_step(handle, sql, &sql_stmt); @@ -73,14 +73,14 @@ static int __media_svc_count_invalid_records_with_thumbnail(sqlite3 *handle, med } 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 count, media_svc_thumbnailpath_s *thumb_path) { 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_DB_TABLE_MEDIA, storage_type); media_svc_debug("[SQL query] : %s", sql); @@ -92,7 +92,7 @@ static int __media_svc_get_invalid_records_with_thumbnail(sqlite3 *handle, media while (sqlite3_step(sql_stmt) == SQLITE_ROW) { _strncpy_safe(thumb_path[idx].thumbnail_path, (const char *)sqlite3_column_text(sql_stmt, 0), sizeof(thumb_path[idx])); - //media_svc_debug("thumb_path[%d]=[%s]", idx, thumb_path[idx].thumbnail_path); + /*media_svc_debug("thumb_path[%d]=[%s]", idx, thumb_path[idx].thumbnail_path); */ idx++; } @@ -106,7 +106,7 @@ static int __media_svc_count_invalid_folder_records_with_thumbnail(sqlite3 *hand 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); + MEDIA_SVC_DB_TABLE_MEDIA, folder_path); ret = _media_svc_sql_prepare_to_step(handle, sql, &sql_stmt); @@ -124,14 +124,14 @@ static int __media_svc_count_invalid_folder_records_with_thumbnail(sqlite3 *hand } 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 count, media_svc_thumbnailpath_s *thumb_path) { 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_DB_TABLE_MEDIA, folder_path); media_svc_debug("[SQL query] : %s", sql); @@ -169,32 +169,29 @@ int _media_svc_count_record_with_path(sqlite3 *handle, const char *path, int *co return MS_MEDIA_ERR_NONE; } -char* _media_svc_get_thumb_default_path(uid_t uid) +char *_media_svc_get_thumb_default_path(uid_t uid) { char *result_psswd = NULL; struct group *grpinfo = NULL; - if(uid == getuid()) - { + if (uid == getuid()) { result_psswd = strdup(MEDIA_SVC_THUMB_DEFAULT_PATH); grpinfo = getgrnam("users"); - if(grpinfo == NULL) { + if (grpinfo == NULL) { media_svc_error("getgrnam(users) returns NULL !"); return NULL; } - } - else - { + } else { struct passwd *userinfo = getpwuid(uid); - if(userinfo == NULL) { + if (userinfo == NULL) { media_svc_error("getpwuid(%d) returns NULL !", uid); return NULL; } grpinfo = getgrnam("users"); - if(grpinfo == NULL) { + if (grpinfo == NULL) { media_svc_error("getgrnam(users) returns NULL !"); return NULL; } - // Compare git_t type and not group name + /* Compare git_t type and not group name */ if (grpinfo->gr_gid != userinfo->pw_gid) { media_svc_error("UID [%d] does not belong to 'users' group!", uid); return NULL; @@ -210,9 +207,9 @@ int _media_svc_insert_item_with_data(sqlite3 *handle, media_svc_content_info_s * 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, \ - thumbnail_path, title, album_id, album, artist, album_artist, genre, composer, year, recorded_date, copyright, track_num, description,\ - bitrate, bitpersample, samplerate, channel, duration, longitude, latitude, altitude, exposure_time, fnumber, iso, model, width, height, datetaken, orientation,\ + char *db_fields = "media_uuid, path, file_name, media_type, mime_type, size, added_time, modified_time, folder_uuid, \ + thumbnail_path, title, album_id, album, artist, album_artist, genre, composer, year, recorded_date, copyright, track_num, description, \ + bitrate, bitpersample, samplerate, channel, duration, longitude, latitude, altitude, exposure_time, fnumber, iso, model, width, height, datetaken, orientation, \ rating, is_drm, storage_type, burst_id, timeline, weather, sync_status, \ file_name_pinyin, title_pinyin, album_pinyin, artist_pinyin, album_artist_pinyin, genre_pinyin, composer_pinyin, copyright_pinyin, description_pinyin, storage_uuid"; @@ -239,7 +236,7 @@ int _media_svc_insert_item_with_data(sqlite3 *handle, media_svc_content_info_s * int height = 0; ret = _media_svc_request_thumbnail_with_origin_size(content_info->path, thumb_path, sizeof(thumb_path), &width, &height, uid); - if(ret == MS_MEDIA_ERR_NONE) { + if (ret == MS_MEDIA_ERR_NONE) { ret = __media_svc_malloc_and_strncpy(&(content_info->thumbnail_path), thumb_path); if (ret != MS_MEDIA_ERR_NONE) { @@ -255,25 +252,24 @@ int _media_svc_insert_item_with_data(sqlite3 *handle, media_svc_content_info_s * } /*Update Pinyin If Support Pinyin*/ - if(_media_svc_check_pinyin_support()) - { - if(STRING_VALID(content_info->file_name)) + if (_media_svc_check_pinyin_support()) { + if (STRING_VALID(content_info->file_name)) _media_svc_get_pinyin_str(content_info->file_name, &content_info->file_name_pinyin); - if(STRING_VALID(content_info->media_meta.title)) + if (STRING_VALID(content_info->media_meta.title)) _media_svc_get_pinyin_str(content_info->media_meta.title, &content_info->media_meta.title_pinyin); - if(STRING_VALID(content_info->media_meta.album)) + if (STRING_VALID(content_info->media_meta.album)) _media_svc_get_pinyin_str(content_info->media_meta.album, &content_info->media_meta.album_pinyin); - if(STRING_VALID(content_info->media_meta.artist)) + if (STRING_VALID(content_info->media_meta.artist)) _media_svc_get_pinyin_str(content_info->media_meta.artist, &content_info->media_meta.artist_pinyin); - if(STRING_VALID(content_info->media_meta.album_artist)) + if (STRING_VALID(content_info->media_meta.album_artist)) _media_svc_get_pinyin_str(content_info->media_meta.album_artist, &content_info->media_meta.album_artist_pinyin); - if(STRING_VALID(content_info->media_meta.genre)) + if (STRING_VALID(content_info->media_meta.genre)) _media_svc_get_pinyin_str(content_info->media_meta.genre, &content_info->media_meta.genre_pinyin); - if(STRING_VALID(content_info->media_meta.composer)) + if (STRING_VALID(content_info->media_meta.composer)) _media_svc_get_pinyin_str(content_info->media_meta.composer, &content_info->media_meta.composer_pinyin); - if(STRING_VALID(content_info->media_meta.copyright)) + if (STRING_VALID(content_info->media_meta.copyright)) _media_svc_get_pinyin_str(content_info->media_meta.copyright, &content_info->media_meta.copyright_pinyin); - if(STRING_VALID(content_info->media_meta.description)) + if (STRING_VALID(content_info->media_meta.description)) _media_svc_get_pinyin_str(content_info->media_meta.description, &content_info->media_meta.description_pinyin); } @@ -282,71 +278,70 @@ int _media_svc_insert_item_with_data(sqlite3 *handle, media_svc_content_info_s * %d, %d, %d, %d, %d, %.6f, %.6f, %.6f, %Q, %.6f, %d, %Q, %d, %d, %Q, %d, \ %d, %d, %d, %Q, %d, %Q, %d, \ %Q, %Q, %Q, %Q, %Q, %Q, %Q, %Q, %Q, %Q);", - content_info->storage_uuid, db_fields, - content_info->media_uuid, - content_info->path, - content_info->file_name, - content_info->media_type, - content_info->mime_type, - content_info->size, - content_info->added_time, - content_info->modified_time, - content_info->folder_uuid, - content_info->thumbnail_path, // - content_info->media_meta.title, - content_info->album_id, - content_info->media_meta.album, - content_info->media_meta.artist, - content_info->media_meta.album_artist, - content_info->media_meta.genre, - content_info->media_meta.composer, - content_info->media_meta.year, - content_info->media_meta.recorded_date, - content_info->media_meta.copyright, - content_info->media_meta.track_num, - content_info->media_meta.description, // - content_info->media_meta.bitrate, - content_info->media_meta.bitpersample, - content_info->media_meta.samplerate, - content_info->media_meta.channel, - content_info->media_meta.duration, - content_info->media_meta.longitude, - content_info->media_meta.latitude, - content_info->media_meta.altitude, - content_info->media_meta.exposure_time, - content_info->media_meta.fnumber, - content_info->media_meta.iso, - content_info->media_meta.model, - content_info->media_meta.width, - content_info->media_meta.height, - content_info->media_meta.datetaken, - content_info->media_meta.orientation, - content_info->media_meta.rating, - content_info->is_drm, - content_info->storage_type, - burst_id, - content_info->timeline, - content_info->media_meta.weather, - content_info->sync_status, - content_info->file_name_pinyin, - content_info->media_meta.title_pinyin, - content_info->media_meta.album_pinyin, - content_info->media_meta.artist_pinyin, - content_info->media_meta.album_artist_pinyin, - content_info->media_meta.genre_pinyin, - content_info->media_meta.composer_pinyin, - content_info->media_meta.copyright_pinyin, - content_info->media_meta.description_pinyin, - content_info->storage_uuid - ); - - if (burst_id) - { + content_info->storage_uuid, db_fields, + content_info->media_uuid, + content_info->path, + content_info->file_name, + content_info->media_type, + content_info->mime_type, + content_info->size, + content_info->added_time, + content_info->modified_time, + content_info->folder_uuid, + content_info->thumbnail_path, + content_info->media_meta.title, + content_info->album_id, + content_info->media_meta.album, + content_info->media_meta.artist, + content_info->media_meta.album_artist, + content_info->media_meta.genre, + content_info->media_meta.composer, + content_info->media_meta.year, + content_info->media_meta.recorded_date, + content_info->media_meta.copyright, + content_info->media_meta.track_num, + content_info->media_meta.description, + content_info->media_meta.bitrate, + content_info->media_meta.bitpersample, + content_info->media_meta.samplerate, + content_info->media_meta.channel, + content_info->media_meta.duration, + content_info->media_meta.longitude, + content_info->media_meta.latitude, + content_info->media_meta.altitude, + content_info->media_meta.exposure_time, + content_info->media_meta.fnumber, + content_info->media_meta.iso, + content_info->media_meta.model, + content_info->media_meta.width, + content_info->media_meta.height, + content_info->media_meta.datetaken, + content_info->media_meta.orientation, + content_info->media_meta.rating, + content_info->is_drm, + content_info->storage_type, + burst_id, + content_info->timeline, + content_info->media_meta.weather, + content_info->sync_status, + content_info->file_name_pinyin, + content_info->media_meta.title_pinyin, + content_info->media_meta.album_pinyin, + content_info->media_meta.artist_pinyin, + content_info->media_meta.album_artist_pinyin, + content_info->media_meta.genre_pinyin, + content_info->media_meta.composer_pinyin, + content_info->media_meta.copyright_pinyin, + content_info->media_meta.description_pinyin, + content_info->storage_uuid + ); + + if (burst_id) { sqlite3_free(burst_id); burst_id = NULL; } - if(!stack_query) { + if (!stack_query) { ret = _media_svc_sql_query(handle, sql, uid); sqlite3_free(sql); if (ret != MS_MEDIA_ERR_NONE) { @@ -371,51 +366,50 @@ int _media_svc_update_meta_with_data(sqlite3 *handle, media_svc_content_info_s * sqlite3_free(test_sql); /*Update Pinyin If Support Pinyin*/ - if(_media_svc_check_pinyin_support()) - { - if(STRING_VALID(content_info->file_name)) + if (_media_svc_check_pinyin_support()) { + if (STRING_VALID(content_info->file_name)) _media_svc_get_pinyin_str(content_info->file_name, &content_info->file_name_pinyin); - if(STRING_VALID(content_info->media_meta.title)) + if (STRING_VALID(content_info->media_meta.title)) _media_svc_get_pinyin_str(content_info->media_meta.title, &content_info->media_meta.title_pinyin); - if(STRING_VALID(content_info->media_meta.album)) + if (STRING_VALID(content_info->media_meta.album)) _media_svc_get_pinyin_str(content_info->media_meta.album, &content_info->media_meta.album_pinyin); - if(STRING_VALID(content_info->media_meta.artist)) + if (STRING_VALID(content_info->media_meta.artist)) _media_svc_get_pinyin_str(content_info->media_meta.artist, &content_info->media_meta.artist_pinyin); - if(STRING_VALID(content_info->media_meta.album_artist)) + if (STRING_VALID(content_info->media_meta.album_artist)) _media_svc_get_pinyin_str(content_info->media_meta.album_artist, &content_info->media_meta.album_artist_pinyin); - if(STRING_VALID(content_info->media_meta.genre)) + if (STRING_VALID(content_info->media_meta.genre)) _media_svc_get_pinyin_str(content_info->media_meta.genre, &content_info->media_meta.genre_pinyin); - if(STRING_VALID(content_info->media_meta.composer)) + if (STRING_VALID(content_info->media_meta.composer)) _media_svc_get_pinyin_str(content_info->media_meta.composer, &content_info->media_meta.composer_pinyin); - if(STRING_VALID(content_info->media_meta.copyright)) + if (STRING_VALID(content_info->media_meta.copyright)) _media_svc_get_pinyin_str(content_info->media_meta.copyright, &content_info->media_meta.copyright_pinyin); - if(STRING_VALID(content_info->media_meta.description)) + if (STRING_VALID(content_info->media_meta.description)) _media_svc_get_pinyin_str(content_info->media_meta.description, &content_info->media_meta.description_pinyin); } char *sql = sqlite3_mprintf("UPDATE %s SET title=%Q, album=%Q, artist=%Q, album_artist=%Q, genre=%Q, composer=%Q, copyright=%Q, description=%Q, \ file_name_pinyin=%Q, title_pinyin=%Q, album_pinyin=%Q, artist_pinyin=%Q, album_artist_pinyin=%Q, genre_pinyin=%Q, composer_pinyin=%Q, copyright_pinyin=%Q, description_pinyin=%Q \ WHERE path=%Q", - MEDIA_SVC_DB_TABLE_MEDIA, - content_info->media_meta.title, - content_info->media_meta.album, - content_info->media_meta.artist, - content_info->media_meta.album_artist, - content_info->media_meta.genre, - content_info->media_meta.composer, - content_info->media_meta.copyright, - content_info->media_meta.description, - content_info->file_name_pinyin, - content_info->media_meta.title_pinyin, - content_info->media_meta.album_pinyin, - content_info->media_meta.artist_pinyin, - content_info->media_meta.album_artist_pinyin, - content_info->media_meta.genre_pinyin, - content_info->media_meta.composer_pinyin, - content_info->media_meta.copyright_pinyin, - content_info->media_meta.description_pinyin, - content_info->path - ); + MEDIA_SVC_DB_TABLE_MEDIA, + content_info->media_meta.title, + content_info->media_meta.album, + content_info->media_meta.artist, + content_info->media_meta.album_artist, + content_info->media_meta.genre, + content_info->media_meta.composer, + content_info->media_meta.copyright, + content_info->media_meta.description, + content_info->file_name_pinyin, + content_info->media_meta.title_pinyin, + content_info->media_meta.album_pinyin, + content_info->media_meta.artist_pinyin, + content_info->media_meta.album_artist_pinyin, + content_info->media_meta.genre_pinyin, + content_info->media_meta.composer_pinyin, + content_info->media_meta.copyright_pinyin, + content_info->media_meta.description_pinyin, + content_info->path + ); media_svc_error(""); if (sql != NULL) { @@ -441,25 +435,24 @@ int _media_svc_update_item_with_data(sqlite3 *handle, const char *storage_id, me sqlite3_free(test_sql); /*Update Pinyin If Support Pinyin*/ - if(_media_svc_check_pinyin_support()) - { - if(STRING_VALID(content_info->file_name)) + if (_media_svc_check_pinyin_support()) { + if (STRING_VALID(content_info->file_name)) _media_svc_get_pinyin_str(content_info->file_name, &content_info->file_name_pinyin); - if(STRING_VALID(content_info->media_meta.title)) + if (STRING_VALID(content_info->media_meta.title)) _media_svc_get_pinyin_str(content_info->media_meta.title, &content_info->media_meta.title_pinyin); - if(STRING_VALID(content_info->media_meta.album)) + if (STRING_VALID(content_info->media_meta.album)) _media_svc_get_pinyin_str(content_info->media_meta.album, &content_info->media_meta.album_pinyin); - if(STRING_VALID(content_info->media_meta.artist)) + if (STRING_VALID(content_info->media_meta.artist)) _media_svc_get_pinyin_str(content_info->media_meta.artist, &content_info->media_meta.artist_pinyin); - if(STRING_VALID(content_info->media_meta.album_artist)) + if (STRING_VALID(content_info->media_meta.album_artist)) _media_svc_get_pinyin_str(content_info->media_meta.album_artist, &content_info->media_meta.album_artist_pinyin); - if(STRING_VALID(content_info->media_meta.genre)) + if (STRING_VALID(content_info->media_meta.genre)) _media_svc_get_pinyin_str(content_info->media_meta.genre, &content_info->media_meta.genre_pinyin); - if(STRING_VALID(content_info->media_meta.composer)) + if (STRING_VALID(content_info->media_meta.composer)) _media_svc_get_pinyin_str(content_info->media_meta.composer, &content_info->media_meta.composer_pinyin); - if(STRING_VALID(content_info->media_meta.copyright)) + if (STRING_VALID(content_info->media_meta.copyright)) _media_svc_get_pinyin_str(content_info->media_meta.copyright, &content_info->media_meta.copyright_pinyin); - if(STRING_VALID(content_info->media_meta.description)) + if (STRING_VALID(content_info->media_meta.description)) _media_svc_get_pinyin_str(content_info->media_meta.description, &content_info->media_meta.description_pinyin); } @@ -468,40 +461,40 @@ int _media_svc_update_item_with_data(sqlite3 *handle, const char *storage_id, me composer=%Q, year=%Q, recorded_date=%Q, copyright=%Q, track_num=%Q, description=%Q, \ bitrate=%d, bitpersample=%d, samplerate=%d, channel=%d, duration=%d, longitude=%f, latitude=%f, altitude=%f, exposure_time=%Q, fnumber=%f, iso=%d, model=%Q, width=%d, height=%d, datetaken=%Q, \ orientation=%d WHERE path=%Q", - storage_id, - content_info->size, - content_info->modified_time, - content_info->thumbnail_path, - content_info->media_meta.title, - content_info->album_id, - content_info->media_meta.album, - content_info->media_meta.artist, - content_info->media_meta.album_artist, - content_info->media_meta.genre, - content_info->media_meta.composer, - content_info->media_meta.year, - content_info->media_meta.recorded_date, - content_info->media_meta.copyright, - content_info->media_meta.track_num, - content_info->media_meta.description, - content_info->media_meta.bitrate, - content_info->media_meta.bitpersample, - content_info->media_meta.samplerate, - content_info->media_meta.channel, - content_info->media_meta.duration, - content_info->media_meta.longitude, - content_info->media_meta.latitude, - content_info->media_meta.altitude, - content_info->media_meta.exposure_time, - content_info->media_meta.fnumber, - content_info->media_meta.iso, - content_info->media_meta.model, - content_info->media_meta.width, - content_info->media_meta.height, - content_info->media_meta.datetaken, - content_info->media_meta.orientation, - content_info->path - ); + storage_id, + content_info->size, + content_info->modified_time, + content_info->thumbnail_path, + content_info->media_meta.title, + content_info->album_id, + content_info->media_meta.album, + content_info->media_meta.artist, + content_info->media_meta.album_artist, + content_info->media_meta.genre, + content_info->media_meta.composer, + content_info->media_meta.year, + content_info->media_meta.recorded_date, + content_info->media_meta.copyright, + content_info->media_meta.track_num, + content_info->media_meta.description, + content_info->media_meta.bitrate, + content_info->media_meta.bitpersample, + content_info->media_meta.samplerate, + content_info->media_meta.channel, + content_info->media_meta.duration, + content_info->media_meta.longitude, + content_info->media_meta.latitude, + content_info->media_meta.altitude, + content_info->media_meta.exposure_time, + content_info->media_meta.fnumber, + content_info->media_meta.iso, + content_info->media_meta.model, + content_info->media_meta.width, + content_info->media_meta.height, + content_info->media_meta.datetaken, + content_info->media_meta.orientation, + content_info->path + ); ret = _media_svc_sql_query(handle, sql, uid); sqlite3_free(sql); @@ -518,10 +511,9 @@ int _media_svc_get_thumbnail_path_by_path(sqlite3 *handle, const char *storage_i ret = _media_svc_sql_prepare_to_step(handle, sql, &sql_stmt); if (ret != MS_MEDIA_ERR_NONE) { - if(ret == MS_MEDIA_ERR_DB_NO_RECORD) { + if (ret == MS_MEDIA_ERR_DB_NO_RECORD) { media_svc_debug("there is no thumbnail."); - } - else { + } else { media_svc_error("error when _media_svc_get_thumbnail_path_by_path. err = [%d]", ret); } return ret; @@ -560,7 +552,7 @@ int _media_svc_delete_item_by_path(sqlite3 *handle, const char *storage_id, cons int ret = MS_MEDIA_ERR_NONE; char *sql = sqlite3_mprintf("DELETE FROM '%s' WHERE path='%q'", storage_id, path); - if(!stack_query) { + if (!stack_query) { ret = _media_svc_sql_query(handle, sql, uid); sqlite3_free(sql); if (ret != MS_MEDIA_ERR_NONE) { @@ -599,7 +591,7 @@ int _media_svc_delete_invalid_items(sqlite3 *handle, media_svc_storage_type_e st 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)); + 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 MS_MEDIA_ERR_OUT_OF_MEMORY; @@ -618,7 +610,7 @@ int _media_svc_delete_invalid_items(sqlite3 *handle, media_svc_storage_type_e st char *sql = sqlite3_mprintf("DELETE FROM %s WHERE validity = 0 AND storage_type=%d", MEDIA_SVC_DB_TABLE_MEDIA, storage_type); ret = _media_svc_sql_query(handle, sql, uid); sqlite3_free(sql); - if(ret != MS_MEDIA_ERR_NONE) { + if (ret != MS_MEDIA_ERR_NONE) { SAFE_FREE(thumbpath_record); return ret; } @@ -627,7 +619,7 @@ int _media_svc_delete_invalid_items(sqlite3 *handle, media_svc_storage_type_e st for (idx = 0; idx < invalid_count; idx++) { 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)) { ret = _media_svc_remove_file(thumbpath_record[idx].thumbnail_path); - if(ret != MS_MEDIA_ERR_NONE) { + if (ret != MS_MEDIA_ERR_NONE) { media_svc_error("fail to remove thumbnail file."); } } @@ -651,7 +643,7 @@ int _media_svc_delete_invalid_folder_items(sqlite3 *handle, const char *folder_p 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)); + 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 MS_MEDIA_ERR_OUT_OF_MEMORY; @@ -670,7 +662,7 @@ int _media_svc_delete_invalid_folder_items(sqlite3 *handle, const char *folder_p char *sql = sqlite3_mprintf("DELETE FROM %s WHERE validity = 0 AND path LIKE '%q/%%'", MEDIA_SVC_DB_TABLE_MEDIA, folder_path); ret = _media_svc_sql_query(handle, sql, uid); sqlite3_free(sql); - if(ret != MS_MEDIA_ERR_NONE) { + if (ret != MS_MEDIA_ERR_NONE) { SAFE_FREE(thumbpath_record); return ret; } @@ -679,7 +671,7 @@ int _media_svc_delete_invalid_folder_items(sqlite3 *handle, const char *folder_p for (idx = 0; idx < invalid_count; idx++) { 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)) { ret = _media_svc_remove_file(thumbpath_record[idx].thumbnail_path); - if(ret != MS_MEDIA_ERR_NONE) { + if (ret != MS_MEDIA_ERR_NONE) { media_svc_error("fail to remove thumbnail file."); } } @@ -696,7 +688,7 @@ int _media_svc_update_item_validity(sqlite3 *handle, const char *path, int valid char *sql = sqlite3_mprintf("UPDATE %s SET validity=%d WHERE path= '%q'", MEDIA_SVC_DB_TABLE_MEDIA, validity, path); - if(!stack_query) { + if (!stack_query) { ret = _media_svc_sql_query(handle, sql, uid); sqlite3_free(sql); } else { @@ -741,7 +733,7 @@ int _media_svc_update_folder_item_validity(sqlite3 *handle, const char *folder_p 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 != MS_MEDIA_ERR_NONE) { - if(ret == MS_MEDIA_ERR_DB_NO_RECORD) + if (ret == MS_MEDIA_ERR_DB_NO_RECORD) media_svc_debug("folder not exist"); else media_svc_error("error when get folder_id. err = [%d]", ret); @@ -749,7 +741,7 @@ int _media_svc_update_folder_item_validity(sqlite3 *handle, const char *folder_p return ret; } - _strncpy_safe(folder_uuid, (const char *)sqlite3_column_text(sql_stmt, 0), MEDIA_SVC_UUID_SIZE+1); + _strncpy_safe(folder_uuid, (const char *)sqlite3_column_text(sql_stmt, 0), MEDIA_SVC_UUID_SIZE + 1); SQLITE3_FINALIZE(sql_stmt); /*Update folder item validity*/ @@ -774,7 +766,7 @@ int _media_svc_update_recursive_folder_item_validity(sqlite3 *handle, const char } int _media_svc_update_item_by_path(sqlite3 *handle, const char *src_path, media_svc_storage_type_e dest_storage, const char *dest_path, - const char *file_name, int modified_time, const char *folder_uuid, const char *thumb_path, bool stack_query, uid_t uid) + const char *file_name, int modified_time, const char *folder_uuid, const char *thumb_path, bool stack_query, uid_t uid) { /* update path, filename, modified_time, folder_uuid, thumbnail_path, */ /* played_count, last_played_time, last_played_position, favourite, storaget_type*/ @@ -782,21 +774,21 @@ int _media_svc_update_item_by_path(sqlite3 *handle, const char *src_path, media_ int ret = MS_MEDIA_ERR_NONE; char *sql = NULL; - if(thumb_path != NULL) { + if (thumb_path != NULL) { sql = sqlite3_mprintf("UPDATE %s SET \ path=%Q, file_name=%Q, modified_time=%d, folder_uuid=%Q, thumbnail_path=%Q, storage_type=%d, \ played_count=0, last_played_time=0, last_played_position=0 \ WHERE path=%Q", - MEDIA_SVC_DB_TABLE_MEDIA, dest_path, file_name, modified_time, folder_uuid, thumb_path, dest_storage, src_path); + MEDIA_SVC_DB_TABLE_MEDIA, dest_path, file_name, modified_time, folder_uuid, thumb_path, dest_storage, src_path); } else { sql = sqlite3_mprintf("UPDATE %s SET \ path=%Q, file_name=%Q, modified_time=%d, folder_uuid=%Q, storage_type=%d, \ played_count=0, last_played_time=0, last_played_position=0 \ WHERE path=%Q", - MEDIA_SVC_DB_TABLE_MEDIA, dest_path, file_name, modified_time, folder_uuid, dest_storage, src_path); + MEDIA_SVC_DB_TABLE_MEDIA, dest_path, file_name, modified_time, folder_uuid, dest_storage, src_path); } - if(!stack_query) { + if (!stack_query) { ret = _media_svc_sql_query(handle, sql, uid); sqlite3_free(sql); } else { @@ -814,7 +806,7 @@ int _media_svc_list_query_do(sqlite3 *handle, media_svc_query_type_e query_type, 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); + ret = _media_svc_sql_query_list(handle, &g_media_svc_item_validity_query_list, uid); else if (query_type == MEDIA_SVC_QUERY_MOVE_ITEM) ret = _media_svc_sql_query_list(handle, &g_media_svc_move_item_query_list, uid); else if (query_type == MEDIA_SVC_QUERY_INSERT_ITEM) @@ -824,14 +816,14 @@ int _media_svc_list_query_do(sqlite3 *handle, media_svc_query_type_e query_type, if (ret != MS_MEDIA_ERR_NONE) { media_svc_error("_media_svc_list_query_do failed. start rollback"); - _media_svc_sql_rollback_trans(handle,uid); + _media_svc_sql_rollback_trans(handle, uid); return ret; } ret = _media_svc_sql_end_trans(handle, uid); if (ret != MS_MEDIA_ERR_NONE) { media_svc_error("mb_svc_sqlite3_commit_trans failed.. Now start to rollback"); - _media_svc_sql_rollback_trans(handle,uid); + _media_svc_sql_rollback_trans(handle, uid); return ret; } @@ -900,18 +892,18 @@ int _media_svc_get_noti_info(sqlite3 *handle, const char *storage_id, const cha } if (update_item == MS_MEDIA_ITEM_FILE) { - if(STRING_VALID((const char *)sqlite3_column_text(sql_stmt, 0))) + if (STRING_VALID((const char *)sqlite3_column_text(sql_stmt, 0))) (*item)->media_uuid = strdup((const char *)sqlite3_column_text(sql_stmt, 0)); (*item)->media_type = sqlite3_column_int(sql_stmt, 1); - if(STRING_VALID((const char *)sqlite3_column_text(sql_stmt, 2))) + if (STRING_VALID((const char *)sqlite3_column_text(sql_stmt, 2))) (*item)->mime_type = strdup((const char *)sqlite3_column_text(sql_stmt, 2)); } else if (update_item == MS_MEDIA_ITEM_DIRECTORY) { if (is_root_dir) { - (*item)->media_uuid = NULL; + (*item)->media_uuid = NULL; } else { - if(STRING_VALID((const char *)sqlite3_column_text(sql_stmt, 0))) + if (STRING_VALID((const char *)sqlite3_column_text(sql_stmt, 0))) (*item)->media_uuid = strdup((const char *)sqlite3_column_text(sql_stmt, 0)); } } @@ -926,7 +918,7 @@ int _media_svc_count_invalid_folder_items(sqlite3 *handle, const char *folder_pa 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); + MEDIA_SVC_DB_TABLE_MEDIA, folder_path); ret = _media_svc_sql_prepare_to_step(handle, sql, &sql_stmt); @@ -967,7 +959,7 @@ int _media_svc_get_fileinfo_by_path(sqlite3 *handle, const char *path, time_t *m int ret = MS_MEDIA_ERR_NONE; sqlite3_stmt *sql_stmt = NULL; char *sql = sqlite3_mprintf("SELECT modified_time, size FROM %s WHERE path='%q'", - MEDIA_SVC_DB_TABLE_MEDIA, path); + MEDIA_SVC_DB_TABLE_MEDIA, path); ret = _media_svc_sql_prepare_to_step(handle, sql, &sql_stmt); diff --git a/src/common/media-svc-noti.c b/src/common/media-svc-noti.c index 5537f0b..405406c 100755 --- a/src/common/media-svc-noti.c +++ b/src/common/media-svc-noti.c @@ -32,21 +32,15 @@ static int __media_svc_publish_noti_by_item(media_svc_noti_item *noti_item) { int ret = MS_MEDIA_ERR_NONE; - if (noti_item && noti_item->path) - { + if (noti_item && noti_item->path) { ret = media_db_update_send(noti_item->pid, noti_item->update_item, noti_item->update_type, noti_item->path, noti_item->media_uuid, noti_item->media_type, noti_item->mime_type); - if(ret != MS_MEDIA_ERR_NONE) - { + if (ret != MS_MEDIA_ERR_NONE) { media_svc_error("media_db_update_send failed : %d [%s]", ret, noti_item->path); ret = MS_MEDIA_ERR_SEND_NOTI_FAIL; - } - else - { + } else { media_svc_debug("media_db_update_send success"); } - } - else - { + } else { media_svc_debug("invalid path"); ret = MS_MEDIA_ERR_INVALID_PARAMETER; } @@ -55,30 +49,24 @@ static int __media_svc_publish_noti_by_item(media_svc_noti_item *noti_item) } int _media_svc_publish_noti(media_item_type_e update_item, - media_item_update_type_e update_type, - const char *path, - media_type_e media_type, - const char *uuid, - const char *mime_type -) + media_item_update_type_e update_type, + const char *path, + media_type_e media_type, + const char *uuid, + const char *mime_type + ) { int ret = MS_MEDIA_ERR_NONE; - if(STRING_VALID(path)) - { + if (STRING_VALID(path)) { ret = media_db_update_send(getpid(), update_item, update_type, (char *)path, (char *)uuid, media_type, (char *)mime_type); - if(ret != MS_MEDIA_ERR_NONE) - { + if (ret != MS_MEDIA_ERR_NONE) { media_svc_error("Send noti failed : %d [%s]", ret, path); ret = MS_MEDIA_ERR_SEND_NOTI_FAIL; - } - else - { + } else { media_svc_debug("Send noti success [%d][%d]", update_item, update_type); } - } - else - { + } else { media_svc_debug("invalid path"); ret = MS_MEDIA_ERR_INVALID_PARAMETER; } @@ -110,7 +98,7 @@ int _media_svc_insert_item_to_noti_list(media_svc_content_info_s *content_info, if (noti_list && content_info) { noti_list[cnt].pid = g_noti_from_pid; - noti_list[cnt].update_item = MS_MEDIA_ITEM_INSERT; // INSERT + noti_list[cnt].update_item = MS_MEDIA_ITEM_INSERT; /* INSERT */ noti_list[cnt].update_type = MS_MEDIA_ITEM_FILE; noti_list[cnt].media_type = content_info->media_type; if (content_info->media_uuid) diff --git a/src/common/media-svc-storage.c b/src/common/media-svc-storage.c index 7be2dfa..c4f6d65 100755 --- a/src/common/media-svc-storage.c +++ b/src/common/media-svc-storage.c @@ -41,10 +41,9 @@ int _media_svc_init_storage(sqlite3 *handle, uid_t uid) storage_cnt = sqlite3_column_int(sql_stmt, 0); SQLITE3_FINALIZE(sql_stmt); - if(storage_cnt == 0) - { + if (storage_cnt == 0) { sql = sqlite3_mprintf("INSERT INTO %s (storage_uuid, storage_name, storage_path, storage_type) VALUES ('%s', '%s', '%s', 0);", - MEDIA_SVC_DB_TABLE_STORAGE, MEDIA_SVC_DB_TABLE_MEDIA, MEDIA_SVC_DB_TABLE_MEDIA, _media_svc_get_path(uid)); + MEDIA_SVC_DB_TABLE_STORAGE, MEDIA_SVC_DB_TABLE_MEDIA, MEDIA_SVC_DB_TABLE_MEDIA, _media_svc_get_path(uid)); ret = _media_svc_sql_query(handle, sql, uid); sqlite3_free(sql); @@ -58,7 +57,7 @@ int _media_svc_append_storage(sqlite3 *handle, const char *storage_id, const cha { int ret = MS_MEDIA_ERR_NONE; char *sql = sqlite3_mprintf("INSERT INTO %s (storage_uuid, storage_name, storage_path, storage_account, storage_type) values (%Q, %Q, %Q, %Q, %d); ", - MEDIA_SVC_DB_TABLE_STORAGE, storage_id, storage_name, storage_path, storage_account, storage_type); + MEDIA_SVC_DB_TABLE_STORAGE, storage_id, storage_name, storage_path, storage_account, storage_type); ret = _media_svc_sql_query(handle, sql, uid); sqlite3_free(sql); diff --git a/src/common/media-svc-util.c b/src/common/media-svc-util.c index 77fefea..a7a54a8 100755 --- a/src/common/media-svc-util.c +++ b/src/common/media-svc-util.c @@ -50,7 +50,7 @@ #include "media-svc-localize_tw.h" #define MEDIA_SVC_FILE_EXT_LEN_MAX 6 /**< Maximum file ext lenth*/ -#define GLOBAL_USER 0 //#define tzplatform_getenv(TZ_GLOBAL) //TODO +#define GLOBAL_USER 0 /*#define tzplatform_getenv(TZ_GLOBAL) //TODO */ /* Define data structures for media type and mime type */ #define MEDIA_SVC_CATEGORY_UNKNOWN 0x00000000 /**< Default */ @@ -137,7 +137,7 @@ typedef enum { MEDIA_SVC_EXTRACTED_FIELD_ALBUM_ARTIST = MEDIA_SVC_EXTRACTED_FIELD_NONE << 11, } media_svc_extracted_field_e; -static char* _media_svc_get_thumb_path(uid_t uid); +static char *_media_svc_get_thumb_path(uid_t uid); char *_media_info_generate_uuid(void) { @@ -147,7 +147,7 @@ char *_media_info_generate_uuid(void) uuid_generate(uuid_value); uuid_unparse(uuid_value, uuid_unparsed); - //media_svc_debug("UUID : %s", uuid_unparsed); + /*media_svc_debug("UUID : %s", uuid_unparsed); */ return uuid_unparsed; } @@ -163,8 +163,8 @@ void _strncpy_safe(char *x_dst, const char *x_src, int max_len) return; } - strncpy(x_dst, x_src, max_len-1); - x_dst[max_len-1] = '\0'; + strncpy(x_dst, x_src, max_len - 1); + x_dst[max_len - 1] = '\0'; } int __media_svc_malloc_and_strncpy(char **dst, const char *src) @@ -221,40 +221,32 @@ static int __media_svc_split_to_double(char *input, double *arr) char tmp_arr[255] = {0, }; int len = 0, idx = 0, arr_idx = 0, str_idx = 0; - if(!STRING_VALID(input)) - { + if (!STRING_VALID(input)) { media_svc_error("Invalid parameter"); return MS_MEDIA_ERR_INVALID_PARAMETER; } memset(tmp_arr, 0x0, sizeof(tmp_arr)); - //media_svc_debug("input: [%s]", input); + /*media_svc_debug("input: [%s]", input); */ len = strlen(input); - for (idx = 0; idx < (len+1); idx++) - { - if(input[idx] == ' ') - { + for (idx = 0; idx < (len + 1); idx++) { + if (input[idx] == ' ') { continue; - } - else if((input[idx] == ',') || (idx == len)) - { + } else if ((input[idx] == ', ') || (idx == len)) { arr[arr_idx] = atof(tmp_arr); arr_idx++; str_idx = 0; - //media_svc_debug("idx=[%d] arr_idx=[%d] tmp_attr[%s] atof(tmp_arr)=[%f]", idx, arr_idx, tmp_arr, atof(tmp_arr)); + /*media_svc_debug("idx=[%d] arr_idx=[%d] tmp_attr[%s] atof(tmp_arr)=[%f]", idx, arr_idx, tmp_arr, atof(tmp_arr)); */ memset(tmp_arr, 0x0, sizeof(tmp_arr)); - } - else - { + } else { tmp_arr[str_idx] = input[idx]; str_idx++; } } - if(arr_idx != 3) - { + if (arr_idx != 3) { media_svc_error("Error when parsing GPS [%d]", arr_idx); return MS_MEDIA_ERR_INTERNAL; } @@ -263,17 +255,17 @@ static int __media_svc_split_to_double(char *input, double *arr) } static int __media_svc_get_exif_info(ExifData *ed, - char *buf, - int *i_value, - double *d_value, - int ifdtype, - long tagtype) + char *buf, + int *i_value, + double *d_value, + int ifdtype, + long tagtype) { ExifEntry *entry; ExifTag tag; if (ed == NULL) { - //media_svc_debug("ExifData is NULL"); + /*media_svc_debug("ExifData is NULL"); */ return MS_MEDIA_ERR_INVALID_PARAMETER; } @@ -283,8 +275,8 @@ static int __media_svc_get_exif_info(ExifData *ed, if (entry) { /* Get the contents of the tag in human-readable form */ if (tag == EXIF_TAG_ORIENTATION || - tag == EXIF_TAG_PIXEL_X_DIMENSION || - tag == EXIF_TAG_PIXEL_Y_DIMENSION) { + tag == EXIF_TAG_PIXEL_X_DIMENSION || + tag == EXIF_TAG_PIXEL_Y_DIMENSION) { if (i_value == NULL) { media_svc_error("i_value is NULL"); @@ -293,7 +285,7 @@ static int __media_svc_get_exif_info(ExifData *ed, ExifByteOrder mByteOrder = exif_data_get_byte_order(ed); short exif_value = exif_get_short(entry->data, mByteOrder); - //media_svc_debug("%s : %d", exif_tag_get_name_in_ifd(tag,ifd), exif_value); + /*media_svc_debug("%s : %d", exif_tag_get_name_in_ifd(tag, ifd), exif_value); */ *i_value = (int)exif_value; } else if (tag == EXIF_TAG_GPS_LATITUDE || tag == EXIF_TAG_GPS_LONGITUDE || tag == EXIF_TAG_GPS_ALTITUDE) { @@ -308,7 +300,7 @@ static int __media_svc_get_exif_info(ExifData *ed, exif_entry_get_value(entry, gps_buf, sizeof(gps_buf)); gps_buf[strlen(gps_buf)] = '\0'; int ret = MS_MEDIA_ERR_NONE; - //media_svc_debug("%s: [%s]", exif_tag_get_name_in_ifd(tag, ifd), gps_buf); + /*media_svc_debug("%s: [%s]", exif_tag_get_name_in_ifd(tag, ifd), gps_buf); */ double tmp_arr[3] = { 0.0, 0.0, 0.0 }; @@ -316,7 +308,7 @@ static int __media_svc_get_exif_info(ExifData *ed, media_svc_retv_if(ret != MS_MEDIA_ERR_NONE, ret); *d_value = tmp_arr[0] + tmp_arr[1] / 60 + tmp_arr[2] / 3600; - //media_svc_debug("GPS value is [%f], %f, %f, %f", *d_value, tmp_arr[0], tmp_arr[1], tmp_arr[2]); + /*media_svc_debug("GPS value is [%f], %f, %f, %f", *d_value, tmp_arr[0], tmp_arr[1], tmp_arr[2]); */ } else { if (buf == NULL) { @@ -339,8 +331,7 @@ time_t __media_svc_get_timeline_from_str(const char *timstr) time_t rawtime; struct tm timeinfo; - if (!STRING_VALID(timstr)) - { + if (!STRING_VALID(timstr)) { media_svc_error("Invalid Parameter"); return 0; } @@ -350,35 +341,29 @@ time_t __media_svc_get_timeline_from_str(const char *timstr) memset(&t, 0x00, sizeof(struct tm)); tzset(); - time ( &rawtime ); - localtime_r (&rawtime, &timeinfo); + time(&rawtime); + localtime_r(&rawtime, &timeinfo); - if (strptime(timstr, "%Y:%m:%d %H:%M:%S", &t) || strptime(timstr, "%Y-%m-%d %H:%M:%S", &t)) - { + if (strptime(timstr, "%Y:%m:%d %H:%M:%S", &t) || strptime(timstr, "%Y-%m-%d %H:%M:%S", &t)) { t.tm_isdst = timeinfo.tm_isdst; - if(t.tm_isdst != 0) { + if (t.tm_isdst != 0) { media_svc_error("DST %d", t.tm_isdst); } modified_t = mktime(&t); - if(modified_t > 0) - { + if (modified_t > 0) { return modified_t; - } - else - { + } else { media_svc_error("Failed to get timeline : [%s] [%d:%d:%d: %d:%d:%d]", timstr, t.tm_year, t.tm_mon, t.tm_mday, t.tm_hour, t.tm_min, t.tm_sec); } - } - else - { + } else { media_svc_error("Failed to get timeline : [%s]", timstr); } return 0; } -static int __media_svc_get_content_type_from_mime(const char * path, const char * mimetype, int * category) +static int __media_svc_get_content_type_from_mime(const char *path, const char *mimetype, int *category) { int idx = 0; @@ -404,7 +389,7 @@ static int __media_svc_get_content_type_from_mime(const char * path, const char } } - if(strncasecmp(mimetype, "text/x-iMelody", strlen("text/x-iMelody")) == 0) { + if (strncasecmp(mimetype, "text/x-iMelody", strlen("text/x-iMelody")) == 0) { *category ^= MEDIA_SVC_CATEGORY_ETC; *category |= MEDIA_SVC_CATEGORY_SOUND; } @@ -423,7 +408,7 @@ static int __media_svc_get_content_type_from_mime(const char * path, const char } /*m3u file is playlist but mime type is "audio/x-mpegurl". but It has to be classified into MS_CATEGORY_ETC since playlist is not a sound track*/ - if(strncasecmp(mimetype, "audio/x-mpegurl", strlen("audio/x-mpegurl")) == 0) { + if (strncasecmp(mimetype, "audio/x-mpegurl", strlen("audio/x-mpegurl")) == 0) { *category ^= MEDIA_SVC_CATEGORY_SOUND; *category |= MEDIA_SVC_CATEGORY_ETC; } @@ -445,7 +430,7 @@ static int __media_svc_get_content_type_from_mime(const char * path, const char *category |= MEDIA_SVC_CATEGORY_MUSIC; } } - //even though error occued in mm_file_get_stream_info return MS_MEDIA_ERR_NONE. fail means invalid media content. + /*even though error occued in mm_file_get_stream_info return MS_MEDIA_ERR_NONE. fail means invalid media content. */ } } } @@ -500,7 +485,7 @@ static bool __media_svc_get_file_ext(const char *file_path, char *file_ext) for (i = strlen(file_path); i >= 0; i--) { if (file_path[i] == '.') { - _strncpy_safe(file_ext, &file_path[i+1], MEDIA_SVC_FILE_EXT_LEN_MAX); + _strncpy_safe(file_ext, &file_path[i + 1], MEDIA_SVC_FILE_EXT_LEN_MAX); return true; } @@ -591,7 +576,7 @@ static int _media_svc_save_image(void *image, int size, char *image_path, uid_t return MS_MEDIA_ERR_NONE; } -static char *_media_svc_get_title_from_filepath (const char *path) +static char *_media_svc_get_title_from_filepath(const char *path) { char *filename = NULL; char *title = NULL; @@ -626,7 +611,7 @@ static char *_media_svc_get_title_from_filepath (const char *path) return NULL; } - title = g_strndup(filename, new_title_len < MEDIA_SVC_PATHNAME_SIZE ? new_title_len : MEDIA_SVC_PATHNAME_SIZE-1); + title = g_strndup(filename, new_title_len < MEDIA_SVC_PATHNAME_SIZE ? new_title_len : MEDIA_SVC_PATHNAME_SIZE - 1); SAFE_FREE(filename); @@ -635,10 +620,9 @@ static char *_media_svc_get_title_from_filepath (const char *path) return title; } -int _media_svc_rename_file( const char *old_name, const char *new_name) +int _media_svc_rename_file(const char *old_name, const char *new_name) { - if((old_name == NULL) || (new_name == NULL)) - { + if ((old_name == NULL) || (new_name == NULL)) { media_svc_error("invalid file name"); return MS_MEDIA_ERR_INVALID_PARAMETER; } @@ -705,50 +689,48 @@ int _media_svc_remove_all_files_in_dir(const char *dir_path) return MS_MEDIA_ERR_NONE; } -static int _mkdir(const char *dir, mode_t mode) { - char tmp[256]; - char *p = NULL; - size_t len; - - snprintf(tmp, sizeof(tmp),"%s",dir); - len = strlen(tmp); - if(tmp[len - 1] == '/') - tmp[len - 1] = 0; - for(p = tmp + 1; *p; p++) - if(*p == '/') { - *p = 0; - mkdir(tmp, mode); - *p = '/'; - } - return mkdir(tmp, mode); +static int _mkdir(const char *dir, mode_t mode) +{ + char tmp[256]; + char *p = NULL; + size_t len; + + snprintf(tmp, sizeof(tmp), "%s", dir); + len = strlen(tmp); + if (tmp[len - 1] == '/') + tmp[len - 1] = 0; + for (p = tmp + 1; *p; p++) + if (*p == '/') { + *p = 0; + mkdir(tmp, mode); + *p = '/'; + } + return mkdir(tmp, mode); } -char* _media_svc_get_thumb_internal_path(uid_t uid) +char *_media_svc_get_thumb_internal_path(uid_t uid) { char *result_psswd = NULL; struct group *grpinfo = NULL; - if(uid == getuid()) - { + if (uid == getuid()) { result_psswd = strdup(MEDIA_SVC_THUMB_INTERNAL_PATH); grpinfo = getgrnam("users"); - if(grpinfo == NULL) { + if (grpinfo == NULL) { media_svc_error("getgrnam(users) returns NULL !"); return NULL; } - } - else - { + } else { struct passwd *userinfo = getpwuid(uid); - if(userinfo == NULL) { + if (userinfo == NULL) { media_svc_error("getpwuid(%d) returns NULL !", uid); return NULL; } grpinfo = getgrnam("users"); - if(grpinfo == NULL) { + if (grpinfo == NULL) { media_svc_error("getgrnam(users) returns NULL !"); return NULL; } - // Compare git_t type and not group name + /* Compare git_t type and not group name */ if (grpinfo->gr_gid != userinfo->pw_gid) { media_svc_error("UID [%d] does not belong to 'users' group!", uid); return NULL; @@ -756,37 +738,34 @@ char* _media_svc_get_thumb_internal_path(uid_t uid) asprintf(&result_psswd, "%s/data/file-manager-service/.thumb/phone", userinfo->pw_dir); } - _mkdir(result_psswd,S_IRWXU | S_IRWXG | S_IRWXO); + _mkdir(result_psswd, S_IRWXU | S_IRWXG | S_IRWXO); return result_psswd; } -char* _media_svc_get_thumb_external_path(uid_t uid) +char *_media_svc_get_thumb_external_path(uid_t uid) { char *result_psswd = NULL; - struct group *grpinfo = NULL; - if(uid == getuid()) - { + struct group *grpinfo = NULL; + if (uid == getuid()) { result_psswd = strdup(MEDIA_SVC_THUMB_EXTERNAL_PATH); grpinfo = getgrnam("users"); - if(grpinfo == NULL) { + if (grpinfo == NULL) { media_svc_error("getgrnam(users) returns NULL !"); return NULL; } - } - else - { + } else { struct passwd *userinfo = getpwuid(uid); - if(userinfo == NULL) { + if (userinfo == NULL) { media_svc_error("getpwuid(%d) returns NULL !", uid); return NULL; } grpinfo = getgrnam("users"); - if(grpinfo == NULL) { + if (grpinfo == NULL) { media_svc_error("getgrnam(users) returns NULL !"); return NULL; } - // Compare git_t type and not group name + /* Compare git_t type and not group name */ if (grpinfo->gr_gid != userinfo->pw_gid) { media_svc_error("UID [%d] does not belong to 'users' group!", uid); return NULL; @@ -794,12 +773,13 @@ char* _media_svc_get_thumb_external_path(uid_t uid) asprintf(&result_psswd, "%s/data/file-manager-service/.thumb/mmc", userinfo->pw_dir); } - _mkdir(result_psswd,S_IRWXU | S_IRWXG | S_IRWXO); + _mkdir(result_psswd, S_IRWXU | S_IRWXG | S_IRWXO); return result_psswd; } -static int __media_svc_check_thumb_dir(char *thumb_dir) { +static int __media_svc_check_thumb_dir(char *thumb_dir) +{ int ret = 0; DIR *dir = NULL; @@ -835,32 +815,29 @@ ERROR: return -1; } -static char* _media_svc_get_thumb_path(uid_t uid) +static char *_media_svc_get_thumb_path(uid_t uid) { char *result_psswd = NULL; struct group *grpinfo = NULL; - if(uid == getuid()) - { + if (uid == getuid()) { result_psswd = strdup(MEDIA_SVC_THUMB_PATH_PREFIX); grpinfo = getgrnam("users"); - if(grpinfo == NULL) { + if (grpinfo == NULL) { media_svc_error("getgrnam(users) returns NULL !"); return NULL; } - } - else - { + } else { struct passwd *userinfo = getpwuid(uid); - if(userinfo == NULL) { + if (userinfo == NULL) { media_svc_error("getpwuid(%d) returns NULL !", uid); return NULL; } grpinfo = getgrnam("users"); - if(grpinfo == NULL) { + if (grpinfo == NULL) { media_svc_error("getgrnam(users) returns NULL !"); return NULL; } - // Compare git_t type and not group name + /* Compare git_t type and not group name */ if (grpinfo->gr_gid != userinfo->pw_gid) { media_svc_error("UID [%d] does not belong to 'users' group!", uid); return NULL; @@ -868,7 +845,7 @@ static char* _media_svc_get_thumb_path(uid_t uid) asprintf(&result_psswd, "%s/data/file-manager-service/.thumb", userinfo->pw_dir); } - _mkdir(result_psswd,S_IRWXU | S_IRWXG | S_IRWXO); + _mkdir(result_psswd, S_IRWXU | S_IRWXG | S_IRWXO); return result_psswd; } @@ -901,15 +878,15 @@ int _media_svc_get_thumbnail_path(media_svc_storage_type_e storage_type, char *t return MS_MEDIA_ERR_INTERNAL; } - //media_svc_debug("img format is [%s]", img_format); + /*media_svc_debug("img format is [%s]", img_format); */ - if((strstr(img_format, "jpeg") != NULL) ||(strstr(img_format, "jpg") != NULL) ||(strstr(img_format, "JPG") != NULL)) { + if ((strstr(img_format, "jpeg") != NULL) || (strstr(img_format, "jpg") != NULL) || (strstr(img_format, "JPG") != NULL)) { thumbfile_ext = "jpg"; - } else if((strstr(img_format, "png") != NULL) ||(strstr(img_format, "PNG") != NULL)) { + } else if ((strstr(img_format, "png") != NULL) || (strstr(img_format, "PNG") != NULL)) { thumbfile_ext = "png"; - } else if((strstr(img_format, "gif") != NULL) ||(strstr(img_format, "GIF") != NULL)) { + } else if ((strstr(img_format, "gif") != NULL) || (strstr(img_format, "GIF") != NULL)) { thumbfile_ext = "gif"; - } else if((strstr(img_format, "bmp") != NULL) ||(strstr(img_format, "BMP") != NULL)) { + } else if ((strstr(img_format, "bmp") != NULL) || (strstr(img_format, "BMP") != NULL)) { thumbfile_ext = "bmp"; } else { media_svc_error("Not proper img format"); @@ -918,7 +895,7 @@ int _media_svc_get_thumbnail_path(media_svc_storage_type_e storage_type, char *t snprintf(savename, sizeof(savename), "%s/.%s-%s.%s", thumb_dir, file_ext, hash, thumbfile_ext); _strncpy_safe(thumb_path, savename, MEDIA_SVC_PATHNAME_SIZE); - //media_svc_debug("thumb_path is [%s]", thumb_path); + /*media_svc_debug("thumb_path is [%s]", thumb_path); */ return MS_MEDIA_ERR_NONE; } @@ -931,19 +908,19 @@ int _media_svc_get_file_time(const char *full_path) memset(&statbuf, 0, sizeof(struct stat)); fd = stat(full_path, &statbuf); if (fd == -1) { - media_svc_error("stat(%s) fails.", full_path); - return MS_MEDIA_ERR_INTERNAL; - } + media_svc_error("stat(%s) fails.", full_path); + return MS_MEDIA_ERR_INTERNAL; + } - return statbuf.st_mtime; + return statbuf.st_mtime; } int _media_svc_set_media_info(media_svc_content_info_s *content_info, const char *storage_id, media_svc_storage_type_e storage_type, - const char *path, media_svc_media_type_e *media_type, bool refresh) + const char *path, media_svc_media_type_e *media_type, bool refresh) { int ret = MS_MEDIA_ERR_NONE; - char * media_uuid = NULL; - char * file_name = NULL; + char *media_uuid = NULL; + char *file_name = NULL; struct stat st; bool drm_type = false; char mime_type[256] = {0}; @@ -956,7 +933,7 @@ int _media_svc_set_media_info(media_svc_content_info_s *content_info, const char content_info->modified_time = st.st_mtime; content_info->timeline = content_info->modified_time; content_info->size = st.st_size; - //media_svc_debug("Modified time : [%d] Size : [%lld]", content_info->modified_time, content_info->size); + /*media_svc_debug("Modified time : [%d] Size : [%lld]", content_info->modified_time, content_info->size); */ } else { media_svc_stderror("stat failed"); } @@ -971,7 +948,7 @@ int _media_svc_set_media_info(media_svc_content_info_s *content_info, const char 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 != MS_MEDIA_ERR_NONE) + if (ret != MS_MEDIA_ERR_NONE) media_svc_error("strcpy error"); SAFE_FREE(title); } else { @@ -1009,7 +986,7 @@ int _media_svc_set_media_info(media_svc_content_info_s *content_info, const char 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) { + if (refresh) { media_svc_debug("refresh"); return MS_MEDIA_ERR_NONE; } @@ -1021,7 +998,7 @@ int _media_svc_set_media_info(media_svc_content_info_s *content_info, const char time(&content_info->added_time); media_uuid = _media_info_generate_uuid(); - if(media_uuid == NULL) { + if (media_uuid == NULL) { _media_svc_destroy_content_info(content_info); return MS_MEDIA_ERR_INTERNAL; } @@ -1058,9 +1035,9 @@ int _media_svc_set_media_info(media_svc_content_info_s *content_info, const char content_info->media_type = *media_type; content_info->played_count = 0; - content_info->last_played_time= 0; - content_info->last_played_position= 0; - content_info->favourate= 0; + content_info->last_played_time = 0; + content_info->last_played_position = 0; + content_info->favourate = 0; content_info->media_meta.rating = 0; return MS_MEDIA_ERR_NONE; @@ -1150,18 +1127,18 @@ int _media_svc_extract_image_metadata(sqlite3 *handle, media_svc_content_info_s 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'"); + /*media_svc_debug("Use 'No description'"); */ ret = __media_svc_malloc_and_strncpy(&content_info->media_meta.description, MEDIA_SVC_TAG_UNKNOWN); - if(ret != MS_MEDIA_ERR_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 != MS_MEDIA_ERR_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 != MS_MEDIA_ERR_NONE) + if (ret != MS_MEDIA_ERR_NONE) media_svc_error("strcpy error"); } @@ -1169,20 +1146,20 @@ int _media_svc_extract_image_metadata(sqlite3 *handle, media_svc_content_info_s if (!has_datetaken && __media_svc_get_exif_info(ed, buf, NULL, NULL, EXIF_IFD_0, EXIF_TAG_DATE_TIME_ORIGINAL) == MS_MEDIA_ERR_NONE) { if (strlen(buf) == 0) { - //media_svc_debug("time is NULL"); + /*media_svc_debug("time is NULL"); */ } else { #if 0 ret = __media_svc_malloc_and_strncpy(&content_info->media_meta.datetaken, buf); #else ret = __media_svc_malloc_and_strncpy_with_size(&content_info->media_meta.datetaken, buf, datetaken_size); #endif - if(ret != MS_MEDIA_ERR_NONE) { + if (ret != MS_MEDIA_ERR_NONE) { media_svc_error("strcpy error"); } else { has_datetaken = TRUE; /* This is same as recorded_date */ ret = __media_svc_malloc_and_strncpy(&content_info->media_meta.recorded_date, buf); - if(ret != MS_MEDIA_ERR_NONE) + if (ret != MS_MEDIA_ERR_NONE) media_svc_error("strcpy error"); } } @@ -1192,20 +1169,20 @@ int _media_svc_extract_image_metadata(sqlite3 *handle, media_svc_content_info_s if (!has_datetaken && __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"); + /*media_svc_debug("time is NULL"); */ } else { #if 0 ret = __media_svc_malloc_and_strncpy(&content_info->media_meta.datetaken, buf); #else ret = __media_svc_malloc_and_strncpy_with_size(&content_info->media_meta.datetaken, buf, datetaken_size); #endif - if(ret != MS_MEDIA_ERR_NONE) { + if (ret != MS_MEDIA_ERR_NONE) { media_svc_error("strcpy error"); } else { has_datetaken = TRUE; /* This is same as recorded_date */ ret = __media_svc_malloc_and_strncpy(&content_info->media_meta.recorded_date, buf); - if(ret != MS_MEDIA_ERR_NONE) + if (ret != MS_MEDIA_ERR_NONE) media_svc_error("strcpy error"); } } @@ -1226,7 +1203,7 @@ int _media_svc_extract_image_metadata(sqlite3 *handle, media_svc_content_info_s media_svc_error("exposure_time_buf is NULL"); } else { ret = __media_svc_malloc_and_strncpy(&content_info->media_meta.exposure_time, exposure_time_buf); - if(ret != MS_MEDIA_ERR_NONE) + if (ret != MS_MEDIA_ERR_NONE) media_svc_error("strcpy error"); } } @@ -1259,7 +1236,7 @@ int _media_svc_extract_image_metadata(sqlite3 *handle, media_svc_content_info_s media_svc_error("model_buf is NULL"); } else { ret = __media_svc_malloc_and_strncpy(&content_info->media_meta.model, model_buf); - if(ret != MS_MEDIA_ERR_NONE) + if (ret != MS_MEDIA_ERR_NONE) media_svc_error("strcpy error"); } } @@ -1321,44 +1298,44 @@ int _media_svc_extract_music_metadata_for_update(sqlite3 *handle, media_svc_cont 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 != MS_MEDIA_ERR_NONE) + if (ret != MS_MEDIA_ERR_NONE) media_svc_error("strcpy error"); - //media_svc_debug("album[%d] : %s", size, content_info->media_meta.album); + /*media_svc_debug("album[%d] : %s", size, content_info->media_meta.album); */ } else { SAFE_FREE(err_attr_name); - //media_svc_debug("album - unknown"); + /*media_svc_debug("album - unknown"); */ } 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 != MS_MEDIA_ERR_NONE) + if (ret != MS_MEDIA_ERR_NONE) media_svc_error("strcpy error"); - //media_svc_debug("artist[%d] : %s", size, content_info->media_meta.artist); + /*media_svc_debug("artist[%d] : %s", size, content_info->media_meta.artist); */ } else { SAFE_FREE(err_attr_name); - //media_svc_debug("artist - unknown"); + /*media_svc_debug("artist - unknown"); */ } mmf_error = mm_file_get_attrs(tag, &err_attr_name, MM_FILE_TAG_ALBUM_ARTIST, &p, &size, NULL); if ((!(extracted_field & MEDIA_SVC_EXTRACTED_FIELD_ALBUM_ARTIST)) && (mmf_error == MM_ERROR_NONE) && (size > 0)) { ret = __media_svc_malloc_and_strncpy(&content_info->media_meta.album_artist, p); - if(ret != MS_MEDIA_ERR_NONE) + if (ret != MS_MEDIA_ERR_NONE) media_svc_error("strcpy error"); - //media_svc_debug("album_artist[%d] : %s", size, content_info->media_meta.album_artist); + /*media_svc_debug("album_artist[%d] : %s", size, content_info->media_meta.album_artist); */ } else { SAFE_FREE(err_attr_name); - //media_svc_debug("album_artist - unknown"); + /*media_svc_debug("album_artist - unknown"); */ } 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 != MS_MEDIA_ERR_NONE) + if (ret != MS_MEDIA_ERR_NONE) media_svc_error("strcpy error"); - //media_svc_debug("genre : %s", content_info->media_meta.genre); + /*media_svc_debug("genre : %s", content_info->media_meta.genre); */ /* If genre is Ringtone, it's categorized as sound. But this logic is commented */ /* if ((strcasecmp("Ringtone", p) == 0) | (strcasecmp("Alert tone", p) == 0)) { @@ -1367,42 +1344,40 @@ int _media_svc_extract_music_metadata_for_update(sqlite3 *handle, media_svc_cont */ } else { SAFE_FREE(err_attr_name); - //media_svc_debug("genre - unknown"); + /*media_svc_debug("genre - unknown"); */ } mmf_error = mm_file_get_attrs(tag, &err_attr_name, MM_FILE_TAG_TITLE, &p, &size, NULL); if ((!(extracted_field & MEDIA_SVC_EXTRACTED_FIELD_TITLE)) && (mmf_error == MM_ERROR_NONE) && (size > 0)/* && (!isspace(*p))*/) { - if(!isspace(*p)) { + if (!isspace(*p)) { ret = __media_svc_malloc_and_strncpy(&content_info->media_meta.title, p); - if(ret != MS_MEDIA_ERR_NONE) + if (ret != MS_MEDIA_ERR_NONE) media_svc_error("strcpy error"); extracted_field |= MEDIA_SVC_EXTRACTED_FIELD_TITLE; - } - else { + } else { int idx = 0; - for(idx = 0; idx < size; idx++) { - if(isspace(*p)) { + for (idx = 0; idx < size; idx++) { + if (isspace(*p)) { media_svc_debug("SPACE [%s]", p); p++; continue; } else { media_svc_debug("Not SPACE [%s]", p); ret = __media_svc_malloc_and_strncpy(&content_info->media_meta.title, p); - if(ret != MS_MEDIA_ERR_NONE) + if (ret != MS_MEDIA_ERR_NONE) media_svc_error("strcpy error"); break; } } - if(idx == size) - { + if (idx == size) { media_svc_debug("Can't extract title. All string is space"); 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 != MS_MEDIA_ERR_NONE) + if (ret != MS_MEDIA_ERR_NONE) media_svc_error("strcpy error"); SAFE_FREE(title); } else { @@ -1415,7 +1390,7 @@ int _media_svc_extract_music_metadata_for_update(sqlite3 *handle, media_svc_cont 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 != MS_MEDIA_ERR_NONE) + if (ret != MS_MEDIA_ERR_NONE) media_svc_error("strcpy error"); SAFE_FREE(title); } else { @@ -1426,9 +1401,9 @@ int _media_svc_extract_music_metadata_for_update(sqlite3 *handle, media_svc_cont 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 != MS_MEDIA_ERR_NONE) + if (ret != MS_MEDIA_ERR_NONE) media_svc_error("strcpy error"); - //media_svc_debug("desc : %s", content_info->media_meta.description); + /*media_svc_debug("desc : %s", content_info->media_meta.description); */ } else { SAFE_FREE(err_attr_name); } @@ -1436,24 +1411,24 @@ int _media_svc_extract_music_metadata_for_update(sqlite3 *handle, media_svc_cont 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 != MS_MEDIA_ERR_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); + /*media_svc_debug("extract composer from content : %s", content_info->media_meta.composer); */ } else { - //media_svc_debug("composer - unknown"); + /*media_svc_debug("composer - unknown"); */ SAFE_FREE(err_attr_name); } 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 != MS_MEDIA_ERR_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); + /*media_svc_debug("extract copyright from content : %s", content_info->media_meta.copyright); */ } else { - //media_svc_debug("copyright - unknown"); + /*media_svc_debug("copyright - unknown"); */ SAFE_FREE(err_attr_name); } @@ -1469,7 +1444,7 @@ int _media_svc_extract_music_metadata_for_update(sqlite3 *handle, media_svc_cont 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 != MS_MEDIA_ERR_NONE) + if (ret != MS_MEDIA_ERR_NONE) media_svc_error("strcpy error"); SAFE_FREE(title); } else { @@ -1507,44 +1482,44 @@ int _media_svc_extract_media_metadata(sqlite3 *handle, media_svc_content_info_s 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 != MS_MEDIA_ERR_NONE) + if (ret != MS_MEDIA_ERR_NONE) media_svc_error("strcpy error"); - //media_svc_debug("album[%d] : %s", size, content_info->media_meta.album); + /*media_svc_debug("album[%d] : %s", size, content_info->media_meta.album); */ } else { SAFE_FREE(err_attr_name); - //media_svc_debug("album - unknown"); + /*media_svc_debug("album - unknown"); */ } 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 != MS_MEDIA_ERR_NONE) + if (ret != MS_MEDIA_ERR_NONE) media_svc_error("strcpy error"); - //media_svc_debug("artist[%d] : %s", size, content_info->media_meta.artist); + /*media_svc_debug("artist[%d] : %s", size, content_info->media_meta.artist); */ } else { SAFE_FREE(err_attr_name); - //media_svc_debug("artist - unknown"); + /*media_svc_debug("artist - unknown"); */ } mmf_error = mm_file_get_attrs(tag, &err_attr_name, MM_FILE_TAG_ALBUM_ARTIST, &p, &size, NULL); if ((!(extracted_field & MEDIA_SVC_EXTRACTED_FIELD_ALBUM_ARTIST)) && (mmf_error == MM_ERROR_NONE) && (size > 0)) { ret = __media_svc_malloc_and_strncpy(&content_info->media_meta.album_artist, p); - if(ret != MS_MEDIA_ERR_NONE) + if (ret != MS_MEDIA_ERR_NONE) media_svc_error("strcpy error"); - //media_svc_debug("album_artist[%d] : %s", size, content_info->media_meta.album_artist); + /*media_svc_debug("album_artist[%d] : %s", size, content_info->media_meta.album_artist); */ } else { SAFE_FREE(err_attr_name); - //media_svc_debug("album_artist - unknown"); + /*media_svc_debug("album_artist - unknown"); */ } 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 != MS_MEDIA_ERR_NONE) + if (ret != MS_MEDIA_ERR_NONE) media_svc_error("strcpy error"); - //media_svc_debug("genre : %s", content_info->media_meta.genre); + /*media_svc_debug("genre : %s", content_info->media_meta.genre); */ /* If genre is Ringtone, it's categorized as sound. But this logic is commented */ /* if ((strcasecmp("Ringtone", p) == 0) | (strcasecmp("Alert tone", p) == 0)) { @@ -1553,42 +1528,40 @@ int _media_svc_extract_media_metadata(sqlite3 *handle, media_svc_content_info_s */ } else { SAFE_FREE(err_attr_name); - //media_svc_debug("genre - unknown"); + /*media_svc_debug("genre - unknown"); */ } mmf_error = mm_file_get_attrs(tag, &err_attr_name, MM_FILE_TAG_TITLE, &p, &size, NULL); if ((!(extracted_field & MEDIA_SVC_EXTRACTED_FIELD_TITLE)) && (mmf_error == MM_ERROR_NONE) && (size > 0)/* && (!isspace(*p))*/) { - if(!isspace(*p)) { + if (!isspace(*p)) { ret = __media_svc_malloc_and_strncpy(&content_info->media_meta.title, p); - if(ret != MS_MEDIA_ERR_NONE) + if (ret != MS_MEDIA_ERR_NONE) media_svc_error("strcpy error"); extracted_field |= MEDIA_SVC_EXTRACTED_FIELD_TITLE; - } - else { + } else { int idx = 0; - for(idx = 0; idx < size; idx++) { - if(isspace(*p)) { + for (idx = 0; idx < size; idx++) { + if (isspace(*p)) { media_svc_debug("SPACE [%s]", p); p++; continue; } else { media_svc_debug("Not SPACE [%s]", p); ret = __media_svc_malloc_and_strncpy(&content_info->media_meta.title, p); - if(ret != MS_MEDIA_ERR_NONE) + if (ret != MS_MEDIA_ERR_NONE) media_svc_error("strcpy error"); break; } } - if(idx == size) - { + if (idx == size) { media_svc_debug("Can't extract title. All string is space"); 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 != MS_MEDIA_ERR_NONE) + if (ret != MS_MEDIA_ERR_NONE) media_svc_error("strcpy error"); SAFE_FREE(title); } else { @@ -1601,7 +1574,7 @@ int _media_svc_extract_media_metadata(sqlite3 *handle, media_svc_content_info_s 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 != MS_MEDIA_ERR_NONE) + if (ret != MS_MEDIA_ERR_NONE) media_svc_error("strcpy error"); SAFE_FREE(title); } else { @@ -1612,16 +1585,16 @@ int _media_svc_extract_media_metadata(sqlite3 *handle, media_svc_content_info_s 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 != MS_MEDIA_ERR_NONE) + if (ret != MS_MEDIA_ERR_NONE) media_svc_error("strcpy error"); - //media_svc_debug("desc : %s", content_info->media_meta.description); + /*media_svc_debug("desc : %s", content_info->media_meta.description); */ } else { SAFE_FREE(err_attr_name); } mmf_error = mm_file_get_attrs(tag, &err_attr_name, MM_FILE_TAG_RECDATE, &p, &size, NULL); if ((mmf_error == MM_ERROR_NONE) && (size > 0)) { - if(media_type == MEDIA_SVC_MEDIA_TYPE_VIDEO) { + if (media_type == MEDIA_SVC_MEDIA_TYPE_VIDEO) { /*Creation time format is 2013-01-01 00:00:00. change it to 2013:01:01 00:00:00 like exif time format*/ char time_info[64] = {0, }; char p_value[64] = {0, }; @@ -1629,10 +1602,10 @@ int _media_svc_extract_media_metadata(sqlite3 *handle, media_svc_content_info_s memset(time_info, 0x00, sizeof(time_info)); memset(p_value, 0x00, sizeof(p_value)); strncpy(p_value, p, size); - for(idx =0; idx < size; idx++) { - if(p_value[idx] == '-') { + for (idx = 0; idx < size; idx++) { + if (p_value[idx] == '-') { time_info[idx] = ':'; - } else if(p_value[idx] != '\0') { + } else if (p_value[idx] != '\0') { time_info[idx] = p_value[idx]; } else { media_svc_error("strcpy error"); @@ -1644,7 +1617,7 @@ int _media_svc_extract_media_metadata(sqlite3 *handle, media_svc_content_info_s ret = __media_svc_malloc_and_strncpy(&content_info->media_meta.recorded_date, p); } - if(ret != MS_MEDIA_ERR_NONE) { + if (ret != MS_MEDIA_ERR_NONE) { media_svc_error("strcpy error"); } else { /* This is same as datetaken */ @@ -1654,7 +1627,7 @@ int _media_svc_extract_media_metadata(sqlite3 *handle, media_svc_content_info_s int datetaken_size = 19; ret = __media_svc_malloc_and_strncpy_with_size(&content_info->media_meta.datetaken, content_info->media_meta.recorded_date, datetaken_size); #endif - if(ret != MS_MEDIA_ERR_NONE) + if (ret != MS_MEDIA_ERR_NONE) media_svc_error("strcpy error"); content_info->timeline = __media_svc_get_timeline_from_str(content_info->media_meta.recorded_date); @@ -1664,7 +1637,7 @@ int _media_svc_extract_media_metadata(sqlite3 *handle, media_svc_content_info_s media_svc_debug("Timeline : %ld", content_info->timeline); } } - //media_svc_debug("Recorded date : %s", content_info->media_meta.recorded_date); + /*media_svc_debug("Recorded date : %s", content_info->media_meta.recorded_date); */ } else { SAFE_FREE(err_attr_name); } @@ -1672,31 +1645,31 @@ int _media_svc_extract_media_metadata(sqlite3 *handle, media_svc_content_info_s 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 != MS_MEDIA_ERR_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); + /*media_svc_debug("extract composer from content : %s", content_info->media_meta.composer); */ } else { - //media_svc_debug("composer - unknown"); + /*media_svc_debug("composer - unknown"); */ SAFE_FREE(err_attr_name); } 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 != MS_MEDIA_ERR_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); + /*media_svc_debug("extract copyright from content : %s", content_info->media_meta.copyright); */ } else { - //media_svc_debug("copyright - unknown"); + /*media_svc_debug("copyright - unknown"); */ SAFE_FREE(err_attr_name); } 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 != MS_MEDIA_ERR_NONE) + if (ret != MS_MEDIA_ERR_NONE) media_svc_error("strcpy error"); } else { SAFE_FREE(err_attr_name); @@ -1705,9 +1678,9 @@ int _media_svc_extract_media_metadata(sqlite3 *handle, media_svc_content_info_s mmf_error = mm_file_get_attrs(tag, &err_attr_name, MM_FILE_TAG_DATE, &p, &size, NULL); if ((!(extracted_field & MEDIA_SVC_EXTRACTED_FIELD_YEAR)) && (mmf_error == MM_ERROR_NONE) && (size == 4)) { int year = 0; - if((p != NULL) && (sscanf( p, "%d", &year))) { + if ((p != NULL) && (sscanf(p, "%d", &year))) { ret = __media_svc_malloc_and_strncpy(&content_info->media_meta.year, p); - if(ret != MS_MEDIA_ERR_NONE) + if (ret != MS_MEDIA_ERR_NONE) media_svc_error("strcpy error"); } else { media_svc_debug("Wrong Year Information [%s]", p); @@ -1741,8 +1714,8 @@ int _media_svc_extract_media_metadata(sqlite3 *handle, media_svc_content_info_s content_info->album_id = album_id; append_album = FALSE; - if((!strncmp(content_info->media_meta.album, MEDIA_SVC_TAG_UNKNOWN, strlen(MEDIA_SVC_TAG_UNKNOWN))) || - (!strncmp(content_info->media_meta.artist, MEDIA_SVC_TAG_UNKNOWN, strlen(MEDIA_SVC_TAG_UNKNOWN)))) { + if ((!strncmp(content_info->media_meta.album, MEDIA_SVC_TAG_UNKNOWN, strlen(MEDIA_SVC_TAG_UNKNOWN))) || + (!strncmp(content_info->media_meta.artist, MEDIA_SVC_TAG_UNKNOWN, strlen(MEDIA_SVC_TAG_UNKNOWN)))) { media_svc_debug("Unknown album or artist already exists. Extract thumbnail for Unknown."); extract_thumbnail = TRUE; @@ -1760,7 +1733,7 @@ int _media_svc_extract_media_metadata(sqlite3 *handle, media_svc_content_info_s media_svc_error("fail to get tag artwork - err(%x)", mmf_error); SAFE_FREE(err_attr_name); } else { - //media_svc_debug("artwork size1 [%d]", size); + /*media_svc_debug("artwork size1 [%d]", size); */ } mmf_error = mm_file_get_attrs(tag, &err_attr_name, MM_FILE_TAG_ARTWORK_SIZE, &size, NULL); @@ -1768,7 +1741,7 @@ int _media_svc_extract_media_metadata(sqlite3 *handle, media_svc_content_info_s media_svc_error("fail to get artwork size - err(%x)", mmf_error); SAFE_FREE(err_attr_name); } else { - //media_svc_debug("artwork size2 [%d]", size); + /*media_svc_debug("artwork size2 [%d]", size); */ } if (image != NULL && size > 0) { int ret = MS_MEDIA_ERR_NONE; @@ -1785,24 +1758,22 @@ int _media_svc_extract_media_metadata(sqlite3 *handle, media_svc_content_info_s SAFE_FREE(err_attr_name); } - if(strlen(thumb_path) > 0) - { + if (strlen(thumb_path) > 0) { ret = _media_svc_save_image(image, size, thumb_path, uid); if (ret != MS_MEDIA_ERR_NONE) { media_svc_error("Fail to Save Thumbnail Image"); - } - else { + } else { ret = __media_svc_malloc_and_strncpy(&content_info->thumbnail_path, thumb_path); - if(ret != MS_MEDIA_ERR_NONE) + if (ret != MS_MEDIA_ERR_NONE) media_svc_error("strcpy error"); } } } } - if(append_album == TRUE) { - if((strncmp(content_info->media_meta.album, MEDIA_SVC_TAG_UNKNOWN, strlen(MEDIA_SVC_TAG_UNKNOWN))) && - (strncmp(content_info->media_meta.artist, MEDIA_SVC_TAG_UNKNOWN, strlen(MEDIA_SVC_TAG_UNKNOWN)))) + if (append_album == TRUE) { + if ((strncmp(content_info->media_meta.album, MEDIA_SVC_TAG_UNKNOWN, strlen(MEDIA_SVC_TAG_UNKNOWN))) && + (strncmp(content_info->media_meta.artist, MEDIA_SVC_TAG_UNKNOWN, strlen(MEDIA_SVC_TAG_UNKNOWN)))) ret = _media_svc_append_album(handle, content_info->media_meta.album, content_info->media_meta.artist, content_info->thumbnail_path, &album_id, uid); else ret = _media_svc_append_album(handle, content_info->media_meta.album, content_info->media_meta.artist, NULL, &album_id, uid); @@ -1810,7 +1781,7 @@ int _media_svc_extract_media_metadata(sqlite3 *handle, media_svc_content_info_s content_info->album_id = album_id; } - if(media_type == MEDIA_SVC_MEDIA_TYPE_VIDEO) { + if (media_type == MEDIA_SVC_MEDIA_TYPE_VIDEO) { double longitude = 0.0; double latitude = 0.0; double altitude = 0.0; @@ -1841,7 +1812,7 @@ int _media_svc_extract_media_metadata(sqlite3 *handle, media_svc_content_info_s 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 != MS_MEDIA_ERR_NONE) + if (ret != MS_MEDIA_ERR_NONE) media_svc_error("strcpy error"); SAFE_FREE(title); } else { @@ -1865,18 +1836,18 @@ int _media_svc_extract_media_metadata(sqlite3 *handle, media_svc_content_info_s SAFE_FREE(err_attr_name); media_svc_debug("fail to get duration attr - err(%x)", mmf_error); } else { - //media_svc_debug("duration : %d", content_info->media_meta.duration); + /*media_svc_debug("duration : %d", content_info->media_meta.duration); */ } /*Sound/Music attribute*/ - if((media_type == MEDIA_SVC_MEDIA_TYPE_SOUND) || (media_type == MEDIA_SVC_MEDIA_TYPE_MUSIC)) { + if ((media_type == MEDIA_SVC_MEDIA_TYPE_SOUND) || (media_type == MEDIA_SVC_MEDIA_TYPE_MUSIC)) { mmf_error = mm_file_get_attrs(content, &err_attr_name, MM_FILE_CONTENT_AUDIO_BITRATE, &content_info->media_meta.bitrate, NULL); if (mmf_error != MM_ERROR_NONE) { SAFE_FREE(err_attr_name); media_svc_debug("fail to get audio bitrate attr - err(%x)", mmf_error); } else { - //media_svc_debug("bit rate : %d", content_info->media_meta.bitrate); + /*media_svc_debug("bit rate : %d", content_info->media_meta.bitrate); */ } mmf_error = mm_file_get_attrs(content, &err_attr_name, MM_FILE_CONTENT_AUDIO_SAMPLERATE, &content_info->media_meta.samplerate, NULL); @@ -1884,7 +1855,7 @@ int _media_svc_extract_media_metadata(sqlite3 *handle, media_svc_content_info_s SAFE_FREE(err_attr_name); media_svc_debug("fail to get sample rate attr - err(%x)", mmf_error); } else { - //media_svc_debug("sample rate : %d", content_info->media_meta.samplerate); + /*media_svc_debug("sample rate : %d", content_info->media_meta.samplerate); */ } mmf_error = mm_file_get_attrs(content, &err_attr_name, MM_FILE_CONTENT_AUDIO_CHANNELS, &content_info->media_meta.channel, NULL); @@ -1892,7 +1863,7 @@ int _media_svc_extract_media_metadata(sqlite3 *handle, media_svc_content_info_s SAFE_FREE(err_attr_name); media_svc_debug("fail to get audio channels attr - err(%x)", mmf_error); } else { - //media_svc_debug("channel : %d", content_info->media_meta.channel); + /*media_svc_debug("channel : %d", content_info->media_meta.channel); */ } mmf_error = mm_file_get_attrs(content, &err_attr_name, MM_FILE_CONTENT_AUDIO_BITPERSAMPLE, &content_info->media_meta.bitpersample, NULL); @@ -1902,7 +1873,7 @@ int _media_svc_extract_media_metadata(sqlite3 *handle, media_svc_content_info_s } else { media_svc_debug("bitpersample : %d", content_info->media_meta.bitpersample); } - }else if(media_type == MEDIA_SVC_MEDIA_TYPE_VIDEO) { /*Video attribute*/ + } else if (media_type == MEDIA_SVC_MEDIA_TYPE_VIDEO) { /*Video attribute*/ int audio_bitrate = 0; int video_bitrate = 0; @@ -1911,7 +1882,7 @@ int _media_svc_extract_media_metadata(sqlite3 *handle, media_svc_content_info_s SAFE_FREE(err_attr_name); media_svc_debug("fail to get audio bitrate attr - err(%x)", mmf_error); } else { - //media_svc_debug("audio bit rate : %d", audio_bitrate); + /*media_svc_debug("audio bit rate : %d", audio_bitrate); */ } mmf_error = mm_file_get_attrs(content, &err_attr_name, MM_FILE_CONTENT_VIDEO_BITRATE, &video_bitrate, NULL); @@ -1919,7 +1890,7 @@ int _media_svc_extract_media_metadata(sqlite3 *handle, media_svc_content_info_s SAFE_FREE(err_attr_name); media_svc_debug("fail to get audio bitrate attr - err(%x)", mmf_error); } else { - //media_svc_debug("video bit rate : %d", video_bitrate); + /*media_svc_debug("video bit rate : %d", video_bitrate); */ } content_info->media_meta.bitrate = audio_bitrate + video_bitrate; @@ -1929,7 +1900,7 @@ int _media_svc_extract_media_metadata(sqlite3 *handle, media_svc_content_info_s SAFE_FREE(err_attr_name); media_svc_debug("fail to get video width attr - err(%x)", mmf_error); } else { - //media_svc_debug("width : %d", content_info->media_meta.width); + /*media_svc_debug("width : %d", content_info->media_meta.width); */ } mmf_error = mm_file_get_attrs(content, &err_attr_name, MM_FILE_CONTENT_VIDEO_HEIGHT, &content_info->media_meta.height, NULL); @@ -1937,7 +1908,7 @@ int _media_svc_extract_media_metadata(sqlite3 *handle, media_svc_content_info_s SAFE_FREE(err_attr_name); media_svc_debug("fail to get video height attr - err(%x)", mmf_error); } else { - //media_svc_debug("height : %d", content_info->media_meta.height); + /*media_svc_debug("height : %d", content_info->media_meta.height); */ } } else { @@ -2003,24 +1974,16 @@ void _media_svc_destroy_content_info(media_svc_content_info_s *content_info) int _media_svc_get_store_type_by_path(const char *path, media_svc_storage_type_e *storage_type, uid_t uid) { - if(STRING_VALID(path)) - { - if(strncmp(path, _media_svc_get_path(uid), strlen(_media_svc_get_path(uid))) == 0) - { + if (STRING_VALID(path)) { + if (strncmp(path, _media_svc_get_path(uid), strlen(_media_svc_get_path(uid))) == 0) { *storage_type = MEDIA_SVC_STORAGE_INTERNAL; - } - else if(strncmp (path, MEDIA_ROOT_PATH_SDCARD, strlen(MEDIA_ROOT_PATH_SDCARD)) == 0) - { + } else if (strncmp(path, MEDIA_ROOT_PATH_SDCARD, strlen(MEDIA_ROOT_PATH_SDCARD)) == 0) { *storage_type = MEDIA_SVC_STORAGE_EXTERNAL; - } - else - { + } else { media_svc_error("Invalid Path"); return MS_MEDIA_ERR_INVALID_PARAMETER; } - } - else - { + } else { media_svc_error("INVALID parameter"); return MS_MEDIA_ERR_INVALID_PARAMETER; } @@ -2030,34 +1993,35 @@ int _media_svc_get_store_type_by_path(const char *path, media_svc_storage_type_e char *_media_svc_replace_path(char *s, const char *olds, const char *news) { - char *result, *sr; - size_t i, count = 0; - size_t oldlen = strlen(olds); if (oldlen < 1) return s; - size_t newlen = strlen(news); - - if (newlen != oldlen) { - for (i = 0; s[i] != '\0';) { - if (memcmp(&s[i], olds, oldlen) == 0) count++, i += oldlen; - else i++; - } - } else i = strlen(s); - - - result = (char *) calloc(1, i + 1 + count * (newlen - oldlen)); - if (result == NULL) return NULL; - - sr = result; - while (*s) { - if (memcmp(s, olds, oldlen) == 0) { - memcpy(sr, news, newlen); - sr += newlen; - s += oldlen; - } else *sr++ = *s++; - } - - *sr = '\0'; - - return result; + char *result, *sr; + size_t i, count = 0; + size_t oldlen = strlen(olds); + if (oldlen < 1) return s; + size_t newlen = strlen(news); + + if (newlen != oldlen) { + for (i = 0; s[i] != '\0';) { + if (memcmp(&s[i], olds, oldlen) == 0) count++, i += oldlen; + else i++; + } + } else i = strlen(s); + + + result = (char *) calloc(1, i + 1 + count * (newlen - oldlen)); + if (result == NULL) return NULL; + + sr = result; + while (*s) { + if (memcmp(s, olds, oldlen) == 0) { + memcpy(sr, news, newlen); + sr += newlen; + s += oldlen; + } else *sr++ = *s++; + } + + *sr = '\0'; + + return result; } bool _media_svc_is_drm_file(const char *path) @@ -2071,13 +2035,10 @@ int _media_svc_request_thumbnail_with_origin_size(const char *path, char *thumb_ ret = thumbnail_request_from_db_with_size(path, thumb_path, max_length, origin_width, origin_height, uid); - if(ret != MS_MEDIA_ERR_NONE) - { + if (ret != MS_MEDIA_ERR_NONE) { media_svc_error("thumbnail_request_from_db failed: %d", ret); ret = MS_MEDIA_ERR_INTERNAL; - } - else - { + } else { media_svc_sec_debug("thumbnail_request_from_db success: thumbnail path[%s]", thumb_path); } @@ -2091,19 +2052,17 @@ int _media_svc_get_pinyin_str(const char *src_str, char **pinyin_str) pinyin_name_s *pinyinname = NULL; *pinyin_str = NULL; - if(!STRING_VALID(src_str)) - { + if (!STRING_VALID(src_str)) { media_svc_debug("String is invalid"); return ret; } ret = _media_svc_convert_chinese_to_pinyin(src_str, &pinyinname, &size); - if (ret == MS_MEDIA_ERR_NONE) - { - if(STRING_VALID(pinyinname[0].pinyin_name)) + if (ret == MS_MEDIA_ERR_NONE) { + if (STRING_VALID(pinyinname[0].pinyin_name)) *pinyin_str = strdup(pinyinname[0].pinyin_name); else - *pinyin_str = strdup(src_str); //Return Original Non China Character + *pinyin_str = strdup(src_str); /*Return Original Non China Character */ } _media_svc_pinyin_free(pinyinname, size); @@ -2123,13 +2082,10 @@ int _media_svc_request_extract_all_thumbs(uid_t uid) ret = thumbnail_request_extract_all_thumbs(uid); - if(ret != MS_MEDIA_ERR_NONE) - { + if (ret != MS_MEDIA_ERR_NONE) { media_svc_error("thumbnail_request_from_db failed: %d", ret); ret = MS_MEDIA_ERR_INTERNAL; - } - else - { + } else { media_svc_sec_debug("thumbnail_request_extract_all_thumbs"); } diff --git a/src/common/media-svc.c b/src/common/media-svc.c index 0bd62a7..00ee16a 100755 --- a/src/common/media-svc.c +++ b/src/common/media-svc.c @@ -57,8 +57,8 @@ int media_svc_connect(MediaSvcHandle **handle, uid_t uid) media_svc_debug_func(); - ret = media_db_connect(&db_handle,uid); - if(ret != MS_MEDIA_ERR_NONE) + ret = media_db_connect(&db_handle, uid); + if (ret != MS_MEDIA_ERR_NONE) return ret; *handle = db_handle; @@ -67,7 +67,7 @@ int media_svc_connect(MediaSvcHandle **handle, uid_t uid) int media_svc_disconnect(MediaSvcHandle *handle) { - MediaDBHandle * db_handle = (MediaDBHandle *)handle; + MediaDBHandle *db_handle = (MediaDBHandle *)handle; media_svc_debug_func(); @@ -82,7 +82,7 @@ int media_svc_disconnect(MediaSvcHandle *handle) int media_svc_create_table(MediaSvcHandle *handle, uid_t uid) { int ret = MS_MEDIA_ERR_NONE; - sqlite3 * db_handle = (sqlite3 *)handle; + sqlite3 *db_handle = (sqlite3 *)handle; media_svc_debug_func(); @@ -152,7 +152,7 @@ int media_svc_get_storage_type(const char *path, media_svc_storage_type_e *stora int media_svc_get_file_info(MediaSvcHandle *handle, const char *path, time_t *modified_time, unsigned long long *size) { int ret = MS_MEDIA_ERR_NONE; - sqlite3 * db_handle = (sqlite3 *)handle; + sqlite3 *db_handle = (sqlite3 *)handle; media_svc_retvm_if(db_handle == NULL, MS_MEDIA_ERR_INVALID_PARAMETER, "Handle is NULL"); @@ -164,7 +164,7 @@ int media_svc_get_file_info(MediaSvcHandle *handle, const char *path, time_t *mo int media_svc_check_item_exist_by_path(MediaSvcHandle *handle, const char *path) { int ret = MS_MEDIA_ERR_NONE; - sqlite3 * db_handle = (sqlite3 *)handle; + sqlite3 *db_handle = (sqlite3 *)handle; int count = -1; media_svc_retvm_if(db_handle == NULL, MS_MEDIA_ERR_INVALID_PARAMETER, "Handle is NULL"); @@ -173,7 +173,7 @@ int media_svc_check_item_exist_by_path(MediaSvcHandle *handle, const char *path) ret = _media_svc_count_record_with_path(db_handle, path, &count); media_svc_retv_if(ret != MS_MEDIA_ERR_NONE, ret); - if(count > 0) { + if (count > 0) { media_svc_debug("item is exist in database"); return MS_MEDIA_ERR_NONE; } else { @@ -186,7 +186,7 @@ int media_svc_check_item_exist_by_path(MediaSvcHandle *handle, const char *path) int media_svc_insert_item_begin(MediaSvcHandle *handle, int data_cnt, int with_noti, int from_pid) { - sqlite3 * db_handle = (sqlite3 *)handle; + sqlite3 *db_handle = (sqlite3 *)handle; media_svc_debug("Transaction data count : [%d]", data_cnt); @@ -213,7 +213,7 @@ int media_svc_insert_item_begin(MediaSvcHandle *handle, int data_cnt, int with_n int media_svc_insert_item_end(MediaSvcHandle *handle, uid_t uid) { int ret = MS_MEDIA_ERR_NONE; - sqlite3 * db_handle = (sqlite3 *)handle; + sqlite3 *db_handle = (sqlite3 *)handle; media_svc_debug_func(); @@ -240,8 +240,8 @@ int media_svc_insert_item_end(MediaSvcHandle *handle, uid_t uid) 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 = MS_MEDIA_ERR_NONE; - sqlite3 * db_handle = (sqlite3 *)handle; - char folder_uuid[MEDIA_SVC_UUID_SIZE+1] = {0,}; + sqlite3 *db_handle = (sqlite3 *)handle; + char folder_uuid[MEDIA_SVC_UUID_SIZE + 1] = {0, }; media_svc_media_type_e media_type; media_svc_retvm_if(db_handle == NULL, MS_MEDIA_ERR_INVALID_PARAMETER, "Handle is NULL"); @@ -262,9 +262,9 @@ int media_svc_insert_item_bulk(MediaSvcHandle *handle, media_svc_storage_type_e return ret; } - if(media_type == MEDIA_SVC_MEDIA_TYPE_OTHER) { + if (media_type == MEDIA_SVC_MEDIA_TYPE_OTHER) { /*Do nothing.*/ - } else if(media_type == MEDIA_SVC_MEDIA_TYPE_IMAGE) { + } else if (media_type == MEDIA_SVC_MEDIA_TYPE_IMAGE) { ret = _media_svc_extract_image_metadata(handle, &content_info, media_type, uid); } else { ret = _media_svc_extract_media_metadata(handle, &content_info, media_type, uid); @@ -286,7 +286,7 @@ int media_svc_insert_item_bulk(MediaSvcHandle *handle, media_svc_storage_type_e 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)) { + } 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 != MS_MEDIA_ERR_NONE, ret, &content_info); @@ -294,7 +294,7 @@ int media_svc_insert_item_bulk(MediaSvcHandle *handle, media_svc_storage_type_e if (g_insert_with_noti) _media_svc_insert_item_to_noti_list(&content_info, g_media_svc_insert_item_cur_data_cnt); - g_media_svc_insert_item_cur_data_cnt ++; + 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)) { @@ -332,8 +332,8 @@ int media_svc_insert_item_bulk(MediaSvcHandle *handle, media_svc_storage_type_e int media_svc_insert_item_immediately(MediaSvcHandle *handle, media_svc_storage_type_e storage_type, const char *path, uid_t uid) { int ret = MS_MEDIA_ERR_NONE; - sqlite3 * db_handle = (sqlite3 *)handle; - char folder_uuid[MEDIA_SVC_UUID_SIZE+1] = {0,}; + sqlite3 *db_handle = (sqlite3 *)handle; + char folder_uuid[MEDIA_SVC_UUID_SIZE + 1] = {0, }; media_svc_media_type_e media_type; media_svc_retvm_if(db_handle == NULL, MS_MEDIA_ERR_INVALID_PARAMETER, "Handle is NULL"); @@ -355,9 +355,9 @@ int media_svc_insert_item_immediately(MediaSvcHandle *handle, media_svc_storage_ return ret; } - if(media_type == MEDIA_SVC_MEDIA_TYPE_OTHER) { + if (media_type == MEDIA_SVC_MEDIA_TYPE_OTHER) { /*Do nothing.*/ - } else if(media_type == MEDIA_SVC_MEDIA_TYPE_IMAGE) { + } else if (media_type == MEDIA_SVC_MEDIA_TYPE_IMAGE) { ret = _media_svc_extract_image_metadata(handle, &content_info, media_type, uid); } else { ret = _media_svc_extract_media_metadata(handle, &content_info, media_type, uid); @@ -380,7 +380,7 @@ int media_svc_insert_item_immediately(MediaSvcHandle *handle, media_svc_storage_ int height = 0; ret = _media_svc_request_thumbnail_with_origin_size(content_info.path, thumb_path, sizeof(thumb_path), &width, &height, uid); - if(ret == MS_MEDIA_ERR_NONE) { + if (ret == MS_MEDIA_ERR_NONE) { ret = __media_svc_malloc_and_strncpy(&(content_info.thumbnail_path), thumb_path); } @@ -409,8 +409,8 @@ int media_svc_insert_item_immediately(MediaSvcHandle *handle, media_svc_storage_ int media_svc_insert_folder(MediaSvcHandle *handle, media_svc_storage_type_e storage_type, const char *path, uid_t uid) { int ret = MS_MEDIA_ERR_NONE; - sqlite3 * db_handle = (sqlite3 *)handle; - char folder_uuid[MEDIA_SVC_UUID_SIZE+1] = {0, }; + sqlite3 *db_handle = (sqlite3 *)handle; + char folder_uuid[MEDIA_SVC_UUID_SIZE + 1] = {0, }; memset(folder_uuid, 0, sizeof(folder_uuid)); media_svc_retvm_if(db_handle == NULL, MS_MEDIA_ERR_INVALID_PARAMETER, "Handle is NULL"); @@ -430,7 +430,7 @@ int media_svc_insert_folder(MediaSvcHandle *handle, media_svc_storage_type_e sto int media_svc_move_item_begin(MediaSvcHandle *handle, int data_cnt) { - sqlite3 * db_handle = (sqlite3 *)handle; + sqlite3 *db_handle = (sqlite3 *)handle; media_svc_debug("Transaction data count : [%d]", data_cnt); @@ -446,7 +446,7 @@ int media_svc_move_item_begin(MediaSvcHandle *handle, int data_cnt) int media_svc_move_item_end(MediaSvcHandle *handle, uid_t uid) { int ret = MS_MEDIA_ERR_NONE; - sqlite3 * db_handle = (sqlite3 *)handle; + sqlite3 *db_handle = (sqlite3 *)handle; media_svc_debug_func(); @@ -468,16 +468,16 @@ int media_svc_move_item_end(MediaSvcHandle *handle, uid_t uid) } 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) + media_svc_storage_type_e dest_storage, const char *dest_path, uid_t uid) { int ret = MS_MEDIA_ERR_NONE; - sqlite3 * db_handle = (sqlite3 *)handle; + sqlite3 *db_handle = (sqlite3 *)handle; char *file_name = NULL; char *folder_path = NULL; int modified_time = 0; - char folder_uuid[MEDIA_SVC_UUID_SIZE+1] = {0,}; - char old_thumb_path[MEDIA_SVC_PATHNAME_SIZE] = {0,}; - char new_thumb_path[MEDIA_SVC_PATHNAME_SIZE] = {0,}; + char folder_uuid[MEDIA_SVC_UUID_SIZE + 1] = {0, }; + char old_thumb_path[MEDIA_SVC_PATHNAME_SIZE] = {0, }; + char new_thumb_path[MEDIA_SVC_PATHNAME_SIZE] = {0, }; int media_type = -1; media_svc_debug_func(); @@ -513,7 +513,7 @@ int media_svc_move_item(MediaSvcHandle *handle, media_svc_storage_type_e src_sto return ret; } - if((media_type == MEDIA_SVC_MEDIA_TYPE_IMAGE) ||(media_type == MEDIA_SVC_MEDIA_TYPE_VIDEO)) { + 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, DEFAULT_MEDIA_SVC_STORAGE_ID, src_path, old_thumb_path); if ((ret != MS_MEDIA_ERR_NONE) && (ret != MS_MEDIA_ERR_DB_NO_RECORD)) { @@ -533,7 +533,7 @@ int media_svc_move_item(MediaSvcHandle *handle, media_svc_storage_type_e src_sto if (g_media_svc_move_item_data_cnt == 1) { /*update item*/ - if((media_type == MEDIA_SVC_MEDIA_TYPE_IMAGE) ||(media_type == MEDIA_SVC_MEDIA_TYPE_VIDEO)) { + if ((media_type == MEDIA_SVC_MEDIA_TYPE_IMAGE) || (media_type == MEDIA_SVC_MEDIA_TYPE_VIDEO)) { ret = _media_svc_update_item_by_path(handle, src_path, dest_storage, dest_path, file_name, modified_time, folder_uuid, new_thumb_path, FALSE, uid); } else { ret = _media_svc_update_item_by_path(handle, src_path, dest_storage, dest_path, file_name, modified_time, folder_uuid, NULL, FALSE, uid); @@ -564,7 +564,7 @@ int media_svc_move_item(MediaSvcHandle *handle, media_svc_storage_type_e src_sto } else if (g_media_svc_move_item_cur_data_cnt < (g_media_svc_move_item_data_cnt - 1)) { /*update item*/ - if((media_type == MEDIA_SVC_MEDIA_TYPE_IMAGE) ||(media_type == MEDIA_SVC_MEDIA_TYPE_VIDEO)) { + if ((media_type == MEDIA_SVC_MEDIA_TYPE_IMAGE) || (media_type == MEDIA_SVC_MEDIA_TYPE_VIDEO)) { ret = _media_svc_update_item_by_path(handle, src_path, dest_storage, dest_path, file_name, modified_time, folder_uuid, new_thumb_path, TRUE, uid); } else { ret = _media_svc_update_item_by_path(handle, src_path, dest_storage, dest_path, file_name, modified_time, folder_uuid, NULL, TRUE, uid); @@ -578,12 +578,12 @@ int media_svc_move_item(MediaSvcHandle *handle, media_svc_storage_type_e src_sto SAFE_FREE(folder_path); media_svc_retv_if(ret != MS_MEDIA_ERR_NONE, ret); - g_media_svc_move_item_cur_data_cnt ++; + g_media_svc_move_item_cur_data_cnt++; } else if (g_media_svc_move_item_cur_data_cnt == (g_media_svc_move_item_data_cnt - 1)) { /*update item*/ - if((media_type == MEDIA_SVC_MEDIA_TYPE_IMAGE) ||(media_type == MEDIA_SVC_MEDIA_TYPE_VIDEO)) { + if ((media_type == MEDIA_SVC_MEDIA_TYPE_IMAGE) || (media_type == MEDIA_SVC_MEDIA_TYPE_VIDEO)) { ret = _media_svc_update_item_by_path(handle, src_path, dest_storage, dest_path, file_name, modified_time, folder_uuid, new_thumb_path, TRUE, uid); } else { ret = _media_svc_update_item_by_path(handle, src_path, dest_storage, dest_path, file_name, modified_time, folder_uuid, NULL, TRUE, uid); @@ -609,20 +609,20 @@ int media_svc_move_item(MediaSvcHandle *handle, media_svc_storage_type_e src_sto } /*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_THUMB_DEFAULT_PATH, sizeof(MEDIA_SVC_THUMB_DEFAULT_PATH)) != 0)) { - ret = _media_svc_rename_file(old_thumb_path,new_thumb_path); - if (ret != MS_MEDIA_ERR_NONE) - media_svc_error("_media_svc_rename_file failed : %d", ret); - } -// } +/* 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_THUMB_DEFAULT_PATH, sizeof(MEDIA_SVC_THUMB_DEFAULT_PATH)) != 0)) { + ret = _media_svc_rename_file(old_thumb_path, new_thumb_path); + if (ret != MS_MEDIA_ERR_NONE) + media_svc_error("_media_svc_rename_file failed : %d", ret); + } +/* } */ return MS_MEDIA_ERR_NONE; } int media_svc_set_item_validity_begin(MediaSvcHandle *handle, int data_cnt) { - sqlite3 * db_handle = (sqlite3 *)handle; + sqlite3 *db_handle = (sqlite3 *)handle; media_svc_debug("Transaction data count : [%d]", data_cnt); @@ -638,7 +638,7 @@ int media_svc_set_item_validity_begin(MediaSvcHandle *handle, int data_cnt) int media_svc_set_item_validity_end(MediaSvcHandle *handle, uid_t uid) { int ret = MS_MEDIA_ERR_NONE; - sqlite3 * db_handle = (sqlite3 *)handle; + sqlite3 *db_handle = (sqlite3 *)handle; media_svc_debug_func(); @@ -655,10 +655,10 @@ int media_svc_set_item_validity_end(MediaSvcHandle *handle, uid_t uid) return ret; } -int media_svc_set_item_validity(MediaSvcHandle *handle, const char *path, int validity,uid_t uid) +int media_svc_set_item_validity(MediaSvcHandle *handle, const char *path, int validity, uid_t uid) { int ret = MS_MEDIA_ERR_NONE; - sqlite3 * db_handle = (sqlite3 *)handle; + sqlite3 *db_handle = (sqlite3 *)handle; 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"); @@ -674,7 +674,7 @@ int media_svc_set_item_validity(MediaSvcHandle *handle, const char *path, int va ret = _media_svc_update_item_validity(db_handle, path, validity, TRUE, uid); media_svc_retv_if(ret != MS_MEDIA_ERR_NONE, ret); - g_media_svc_item_validity_cur_data_cnt ++; + 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)) { @@ -698,8 +698,8 @@ int media_svc_set_item_validity(MediaSvcHandle *handle, const char *path, int va int media_svc_delete_item_by_path(MediaSvcHandle *handle, const char *storage_id, const char *path, uid_t uid) { int ret = MS_MEDIA_ERR_NONE; - sqlite3 * db_handle = (sqlite3 *)handle; - char thumb_path[MEDIA_SVC_PATHNAME_SIZE] = {0,}; + sqlite3 *db_handle = (sqlite3 *)handle; + char thumb_path[MEDIA_SVC_PATHNAME_SIZE] = {0, }; media_svc_debug_func(); @@ -712,11 +712,11 @@ int media_svc_delete_item_by_path(MediaSvcHandle *handle, const char *storage_id media_svc_retv_if((ret != MS_MEDIA_ERR_NONE), ret); #if 0 - if((media_type == MEDIA_SVC_MEDIA_TYPE_IMAGE) ||(media_type == MEDIA_SVC_MEDIA_TYPE_VIDEO)) { + 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, storage_id, path, thumb_path); 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)) { + } 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 != MS_MEDIA_ERR_NONE), ret); @@ -764,7 +764,7 @@ int media_svc_delete_item_by_path(MediaSvcHandle *handle, const char *storage_id /*Delete thumbnail*/ if ((strlen(thumb_path) > 0) && (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 != MS_MEDIA_ERR_NONE) { + if (ret != MS_MEDIA_ERR_NONE) { media_svc_error("fail to remove thumbnail file."); } } @@ -775,8 +775,8 @@ int media_svc_delete_item_by_path(MediaSvcHandle *handle, const char *storage_id int media_svc_delete_all_items_in_storage(MediaSvcHandle *handle, media_svc_storage_type_e storage_type, uid_t uid) { int ret = MS_MEDIA_ERR_NONE; - sqlite3 * db_handle = (sqlite3 *)handle; - char * dirpath = NULL; + sqlite3 *db_handle = (sqlite3 *)handle; + char *dirpath = NULL; media_svc_debug("media_svc_delete_all_items_in_storage [%d]", storage_type); @@ -801,7 +801,7 @@ int media_svc_delete_all_items_in_storage(MediaSvcHandle *handle, media_svc_stor int media_svc_delete_invalid_items_in_storage(MediaSvcHandle *handle, media_svc_storage_type_e storage_type, uid_t uid) { - sqlite3 * db_handle = (sqlite3 *)handle; + sqlite3 *db_handle = (sqlite3 *)handle; media_svc_debug_func(); @@ -818,7 +818,7 @@ int media_svc_delete_invalid_items_in_storage(MediaSvcHandle *handle, media_svc_ int media_svc_delete_invalid_items_in_folder(MediaSvcHandle *handle, const char *folder_path, uid_t uid) { - sqlite3 * db_handle = (sqlite3 *)handle; + sqlite3 *db_handle = (sqlite3 *)handle; media_svc_debug_func(); @@ -830,7 +830,7 @@ int media_svc_delete_invalid_items_in_folder(MediaSvcHandle *handle, const char int media_svc_set_all_storage_items_validity(MediaSvcHandle *handle, media_svc_storage_type_e storage_type, int validity, uid_t uid) { - sqlite3 * db_handle = (sqlite3 *)handle; + sqlite3 *db_handle = (sqlite3 *)handle; media_svc_retvm_if(db_handle == NULL, MS_MEDIA_ERR_INVALID_PARAMETER, "Handle is NULL"); @@ -844,13 +844,13 @@ int media_svc_set_all_storage_items_validity(MediaSvcHandle *handle, media_svc_s int media_svc_set_folder_items_validity(MediaSvcHandle *handle, const char *folder_path, int validity, int recursive, uid_t uid) { - sqlite3 * db_handle = (sqlite3 *)handle; + sqlite3 *db_handle = (sqlite3 *)handle; 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); + if (recursive) + return _media_svc_update_recursive_folder_item_validity(db_handle, folder_path, validity, uid); else return _media_svc_update_folder_item_validity(db_handle, folder_path, validity, uid); } @@ -858,7 +858,7 @@ int media_svc_set_folder_items_validity(MediaSvcHandle *handle, const char *fold int media_svc_refresh_item(MediaSvcHandle *handle, media_svc_storage_type_e storage_type, const char *storage_id, const char *path, uid_t uid) { int ret = MS_MEDIA_ERR_NONE; - sqlite3 * db_handle = (sqlite3 *)handle; + sqlite3 *db_handle = (sqlite3 *)handle; media_svc_media_type_e media_type; media_svc_retvm_if(db_handle == NULL, MS_MEDIA_ERR_INVALID_PARAMETER, "Handle is NULL"); @@ -910,9 +910,9 @@ int media_svc_refresh_item(MediaSvcHandle *handle, media_svc_storage_type_e stor media_type = noti_item->media_type; - if(media_type == MEDIA_SVC_MEDIA_TYPE_OTHER) { + if (media_type == MEDIA_SVC_MEDIA_TYPE_OTHER) { /*Do nothing.*/ - } else if(media_type == MEDIA_SVC_MEDIA_TYPE_IMAGE) { + } else if (media_type == MEDIA_SVC_MEDIA_TYPE_IMAGE) { ret = _media_svc_extract_image_metadata(handle, &content_info, media_type, uid); } else { ret = _media_svc_extract_media_metadata(handle, &content_info, media_type, uid); @@ -932,17 +932,17 @@ int media_svc_refresh_item(MediaSvcHandle *handle, media_svc_storage_type_e stor int height = 0; ret = _media_svc_request_thumbnail_with_origin_size(content_info.path, thumb_path, sizeof(thumb_path), &width, &height, uid); - if(ret == MS_MEDIA_ERR_NONE) { + if (ret == MS_MEDIA_ERR_NONE) { ret = __media_svc_malloc_and_strncpy(&(content_info.thumbnail_path), thumb_path); } - if (content_info.media_meta.width <= 0) - content_info.media_meta.width = width; + if (content_info.media_meta.width <= 0) + content_info.media_meta.width = width; - if (content_info.media_meta.height <= 0) - content_info.media_meta.height = height; + if (content_info.media_meta.height <= 0) + content_info.media_meta.height = height; } - } + } #endif @@ -963,7 +963,7 @@ int media_svc_refresh_item(MediaSvcHandle *handle, media_svc_storage_type_e stor int media_svc_rename_folder(MediaSvcHandle *handle, const char *storage_id, const char *src_path, const char *dst_path, uid_t uid) { - sqlite3 * db_handle = (sqlite3 *)handle; + sqlite3 *db_handle = (sqlite3 *)handle; int ret = MS_MEDIA_ERR_NONE; media_svc_retvm_if(db_handle == NULL, MS_MEDIA_ERR_INVALID_PARAMETER, "Handle is NULL"); @@ -972,20 +972,20 @@ int media_svc_rename_folder(MediaSvcHandle *handle, const char *storage_id, cons media_svc_debug("Src path : %s, Dst Path : %s", src_path, dst_path); - ret = _media_svc_sql_begin_trans(handle,uid); + ret = _media_svc_sql_begin_trans(handle, uid); 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; - char src_path_slash[MEDIA_SVC_PATHNAME_SIZE + 1] = {0,}; - char dst_path_slash[MEDIA_SVC_PATHNAME_SIZE + 1] = {0,}; + char src_path_slash[MEDIA_SVC_PATHNAME_SIZE + 1] = {0, }; + char dst_path_slash[MEDIA_SVC_PATHNAME_SIZE + 1] = {0, }; snprintf(src_path_slash, sizeof(src_path_slash), "%s/", src_path); snprintf(dst_path_slash, sizeof(dst_path_slash), "%s/", dst_path); update_folder_path_sql = sqlite3_mprintf("UPDATE folder SET path = REPLACE( path, '%q', '%q');", src_path_slash, dst_path_slash); - //ret = _media_svc_sql_query(handle, update_folder_path_sql, uid); + /*ret = _media_svc_sql_query(handle, update_folder_path_sql, uid); */ ret = media_db_request_update_db_batch(update_folder_path_sql, uid); sqlite3_free(update_folder_path_sql); @@ -1004,7 +1004,7 @@ int media_svc_rename_folder(MediaSvcHandle *handle, const char *storage_id, cons update_folder_modified_time_sql = sqlite3_mprintf("UPDATE folder SET modified_time = %d where path like '%q';", date, dst_path); ret = media_db_request_update_db_batch(update_folder_modified_time_sql, uid); - //ret = _media_svc_sql_query(handle, update_folder_modified_time_sql, uid); + /*ret = _media_svc_sql_query(handle, update_folder_modified_time_sql, uid); */ sqlite3_free(update_folder_modified_time_sql); if (ret != SQLITE_OK) { @@ -1039,11 +1039,11 @@ int media_svc_rename_folder(MediaSvcHandle *handle, const char *storage_id, cons break; } - char media_uuid[MEDIA_SVC_UUID_SIZE + 1] = {0,}; - char media_path[MEDIA_SVC_PATHNAME_SIZE + 1] = {0,}; - char media_thumb_path[MEDIA_SVC_PATHNAME_SIZE + 1] = {0,}; - char media_new_thumb_path[MEDIA_SVC_PATHNAME_SIZE + 1] = {0,}; - //int media_type; + char media_uuid[MEDIA_SVC_UUID_SIZE + 1] = {0, }; + char media_path[MEDIA_SVC_PATHNAME_SIZE + 1] = {0, }; + char media_thumb_path[MEDIA_SVC_PATHNAME_SIZE + 1] = {0, }; + char media_new_thumb_path[MEDIA_SVC_PATHNAME_SIZE + 1] = {0, }; + /*int media_type; */ bool no_thumb = FALSE; if (STRING_VALID((const char *)sqlite3_column_text(sql_stmt, 0))) { @@ -1070,7 +1070,7 @@ int media_svc_rename_folder(MediaSvcHandle *handle, const char *storage_id, cons no_thumb = TRUE; } - //media_type = sqlite3_column_int(sql_stmt, 3); + /*media_type = sqlite3_column_int(sql_stmt, 3); */ /* Update path, thumbnail path of this item */ char *replaced_path = NULL; @@ -1094,21 +1094,21 @@ int media_svc_rename_folder(MediaSvcHandle *handle, const char *storage_id, cons 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); + _media_svc_sql_rollback_trans(handle, uid); return ret; } - + ret = _media_svc_get_thumbnail_path(storage_type, media_new_thumb_path, replaced_path, THUMB_EXT, uid); 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); + _media_svc_sql_rollback_trans(handle, uid); return ret; } } - //media_svc_debug("New media thumbnail path : %s", media_new_thumb_path); + /*media_svc_debug("New media thumbnail path : %s", media_new_thumb_path); */ } char *update_item_sql = NULL; @@ -1127,22 +1127,22 @@ int media_svc_rename_folder(MediaSvcHandle *handle, const char *storage_id, cons #endif } - ret = media_db_request_update_db_batch(update_item_sql,uid); - //ret = _media_svc_sql_query(handle, update_item_sql,uid); + ret = media_db_request_update_db_batch(update_item_sql, uid); + /*ret = _media_svc_sql_query(handle, update_item_sql, uid); */ sqlite3_free(update_item_sql); SAFE_FREE(replaced_path); if (ret != SQLITE_OK) { media_svc_error("failed to update item"); SQLITE3_FINALIZE(sql_stmt); - _media_svc_sql_rollback_trans(handle,uid); - + _media_svc_sql_rollback_trans(handle, uid); + 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)) { +/* 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)) { */ if ((!no_thumb) && (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 != MS_MEDIA_ERR_NONE) { @@ -1156,7 +1156,7 @@ int media_svc_rename_folder(MediaSvcHandle *handle, const char *storage_id, cons ret = _media_svc_sql_end_trans(handle, uid); 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); + _media_svc_sql_rollback_trans(handle, uid); return ret; } @@ -1182,7 +1182,7 @@ int media_svc_request_update_db(const char *db_query, uid_t uid) int media_svc_send_dir_update_noti(MediaSvcHandle *handle, const char *dir_path) { int ret = MS_MEDIA_ERR_NONE; - sqlite3 * db_handle = (sqlite3 *)handle; + sqlite3 *db_handle = (sqlite3 *)handle; media_svc_retvm_if(db_handle == NULL, MS_MEDIA_ERR_INVALID_PARAMETER, "Handle is NULL"); media_svc_retvm_if(!STRING_VALID(dir_path), MS_MEDIA_ERR_INVALID_PARAMETER, "dir_path is NULL"); @@ -1200,7 +1200,7 @@ int media_svc_send_dir_update_noti(MediaSvcHandle *handle, const char *dir_path) int media_svc_count_invalid_items_in_folder(MediaSvcHandle *handle, const char *folder_path, int *count) { - sqlite3 * db_handle = (sqlite3 *)handle; + sqlite3 *db_handle = (sqlite3 *)handle; media_svc_debug_func(); @@ -1213,7 +1213,7 @@ int media_svc_count_invalid_items_in_folder(MediaSvcHandle *handle, const char * int media_svc_check_db_upgrade(MediaSvcHandle *handle, uid_t uid) { - sqlite3 * db_handle = (sqlite3 *)handle; + sqlite3 *db_handle = (sqlite3 *)handle; media_svc_debug_func(); media_svc_retvm_if(db_handle == NULL, MS_MEDIA_ERR_INVALID_PARAMETER, "Handle is NULL"); @@ -1223,7 +1223,7 @@ int media_svc_check_db_upgrade(MediaSvcHandle *handle, uid_t uid) int media_svc_check_db_corrupt(MediaSvcHandle *handle) { - sqlite3 * db_handle = (sqlite3 *)handle; + sqlite3 *db_handle = (sqlite3 *)handle; media_svc_debug_func(); media_svc_retvm_if(db_handle == NULL, MS_MEDIA_ERR_INVALID_PARAMETER, "Handle is NULL"); @@ -1231,9 +1231,9 @@ int media_svc_check_db_corrupt(MediaSvcHandle *handle) return _media_db_check_corrupt(db_handle); } -int media_svc_get_folder_list(MediaSvcHandle *handle, char* start_path, char ***folder_list, time_t **modified_time_list, int **item_num_list, int *count) +int media_svc_get_folder_list(MediaSvcHandle *handle, char *start_path, char ***folder_list, time_t **modified_time_list, int **item_num_list, int *count) { - sqlite3 * db_handle = (sqlite3 *)handle; + sqlite3 *db_handle = (sqlite3 *)handle; media_svc_debug_func(); @@ -1246,10 +1246,10 @@ int media_svc_get_folder_list(MediaSvcHandle *handle, char* start_path, char *** int media_svc_update_folder_time(MediaSvcHandle *handle, const char *folder_path, uid_t uid) { int ret = MS_MEDIA_ERR_NONE; - sqlite3 * db_handle = (sqlite3 *)handle; + sqlite3 *db_handle = (sqlite3 *)handle; time_t sto_time = 0; int cur_time = _media_svc_get_file_time(folder_path); - char folder_uuid[MEDIA_SVC_UUID_SIZE+1] = {0,}; + char folder_uuid[MEDIA_SVC_UUID_SIZE + 1] = {0, }; media_svc_retvm_if(db_handle == NULL, MS_MEDIA_ERR_INVALID_PARAMETER, "Handle is NULL"); @@ -1265,7 +1265,7 @@ int media_svc_update_folder_time(MediaSvcHandle *handle, const char *folder_path int media_svc_update_item_begin(MediaSvcHandle *handle, int data_cnt) { - sqlite3 * db_handle = (sqlite3 *)handle; + sqlite3 *db_handle = (sqlite3 *)handle; media_svc_debug("Transaction data count : [%d]", data_cnt); @@ -1281,7 +1281,7 @@ int media_svc_update_item_begin(MediaSvcHandle *handle, int data_cnt) int media_svc_update_item_end(MediaSvcHandle *handle, uid_t uid) { int ret = MS_MEDIA_ERR_NONE; - sqlite3 * db_handle = (sqlite3 *)handle; + sqlite3 *db_handle = (sqlite3 *)handle; media_svc_debug_func(); @@ -1302,7 +1302,7 @@ int media_svc_update_item_end(MediaSvcHandle *handle, uid_t uid) int media_svc_update_item_meta(MediaSvcHandle *handle, const char *file_path, int storage_type, uid_t uid) { int ret = MS_MEDIA_ERR_NONE; - sqlite3 * db_handle = (sqlite3 *)handle; + sqlite3 *db_handle = (sqlite3 *)handle; media_svc_retvm_if(db_handle == NULL, MS_MEDIA_ERR_INVALID_PARAMETER, "Handle is NULL"); @@ -1325,9 +1325,9 @@ int media_svc_update_item_meta(MediaSvcHandle *handle, const char *file_path, in return ret; } - if(media_type == MEDIA_SVC_MEDIA_TYPE_MUSIC) { + if (media_type == MEDIA_SVC_MEDIA_TYPE_MUSIC) { ret = _media_svc_extract_music_metadata_for_update(db_handle, &content_info, media_type); - } else{ + } else { return MS_MEDIA_ERR_NONE; } if (ret != MS_MEDIA_ERR_NONE) { @@ -1340,12 +1340,12 @@ int media_svc_update_item_meta(MediaSvcHandle *handle, const char *file_path, in ret = _media_svc_update_meta_with_data(db_handle, &content_info); media_svc_retv_del_if(ret != MS_MEDIA_ERR_NONE, ret, &content_info); - } else if(g_media_svc_update_item_cur_data_cnt < (g_media_svc_update_item_data_cnt - 1)) { + } else if (g_media_svc_update_item_cur_data_cnt < (g_media_svc_update_item_data_cnt - 1)) { ret = _media_svc_update_meta_with_data(db_handle, &content_info); media_svc_retv_del_if(ret != MS_MEDIA_ERR_NONE, ret, &content_info); - g_media_svc_update_item_cur_data_cnt ++; + g_media_svc_update_item_cur_data_cnt++; } else if (g_media_svc_update_item_cur_data_cnt == (g_media_svc_update_item_data_cnt - 1)) { @@ -1373,7 +1373,7 @@ int media_svc_publish_noti(MediaSvcHandle *handle, media_item_type_e update_item return _media_svc_publish_noti(update_item, update_type, path, media_type, uuid, mime_type); } -int media_svc_get_pinyin(MediaSvcHandle *handle, const char * src_str, char **pinyin_str) +int media_svc_get_pinyin(MediaSvcHandle *handle, const char *src_str, char **pinyin_str) { media_svc_retvm_if(!STRING_VALID(src_str), MS_MEDIA_ERR_INVALID_PARAMETER, "String is NULL"); @@ -1387,7 +1387,7 @@ int media_svc_check_pinyin_support(bool *support) return MS_MEDIA_ERR_NONE; } -static int __media_svc_copy_para_to_content(media_svc_content_info_s *content_info ,media_svc_content_info_s *new_content_info) +static int __media_svc_copy_para_to_content(media_svc_content_info_s *content_info, media_svc_content_info_s *new_content_info) { media_svc_retvm_if(content_info == NULL, MS_MEDIA_ERR_INVALID_PARAMETER, "Handle is NULL"); media_svc_retvm_if(new_content_info == NULL, MS_MEDIA_ERR_INVALID_PARAMETER, "Handle is NULL"); @@ -1396,8 +1396,8 @@ static int __media_svc_copy_para_to_content(media_svc_content_info_s *content_in initialize media content datas */ int ret = MS_MEDIA_ERR_NONE; - char * media_uuid = NULL; - char * file_name = NULL; + char *media_uuid = NULL; + char *file_name = NULL; ret = __media_svc_malloc_and_strncpy(&new_content_info->path, content_info->path); media_svc_retv_del_if(ret != MS_MEDIA_ERR_NONE, ret, new_content_info); @@ -1429,8 +1429,8 @@ static int __media_svc_copy_para_to_content(media_svc_content_info_s *content_in ret = __media_svc_malloc_and_strncpy(&new_content_info->media_meta.artist, MEDIA_SVC_TAG_UNKNOWN); media_svc_retv_del_if(ret != MS_MEDIA_ERR_NONE, ret, new_content_info); -// ret = __media_svc_malloc_and_strncpy(&new_content_info->media_meta.album_artist, MEDIA_SVC_TAG_UNKNOWN); -// media_svc_retv_del_if(ret != MS_MEDIA_ERR_NONE, ret, new_content_info); +/* ret = __media_svc_malloc_and_strncpy(&new_content_info->media_meta.album_artist, MEDIA_SVC_TAG_UNKNOWN); */ +/* media_svc_retv_del_if(ret != MS_MEDIA_ERR_NONE, ret, new_content_info); */ ret = __media_svc_malloc_and_strncpy(&new_content_info->media_meta.genre, MEDIA_SVC_TAG_UNKNOWN); media_svc_retv_del_if(ret != MS_MEDIA_ERR_NONE, ret, new_content_info); @@ -1456,9 +1456,9 @@ static int __media_svc_copy_para_to_content(media_svc_content_info_s *content_in media_svc_retv_del_if(ret != MS_MEDIA_ERR_NONE, ret, new_content_info); new_content_info->played_count = 0; - new_content_info->last_played_time= 0; - new_content_info->last_played_position= 0; - new_content_info->favourate= 0; + new_content_info->last_played_time = 0; + new_content_info->last_played_position = 0; + new_content_info->favourate = 0; new_content_info->media_meta.rating = 0; /* end of initializing @@ -1470,110 +1470,96 @@ static int __media_svc_copy_para_to_content(media_svc_content_info_s *content_in new_content_info->is_drm = content_info->is_drm; new_content_info->media_type = content_info->media_type; - if(STRING_VALID(content_info->mime_type)) - { + if (STRING_VALID(content_info->mime_type)) { ret = __media_svc_malloc_and_strncpy(&new_content_info->mime_type, content_info->mime_type); - if(ret != MS_MEDIA_ERR_NONE) + if (ret != MS_MEDIA_ERR_NONE) media_svc_error("strcpy mime_type failed"); } - if(STRING_VALID(content_info->thumbnail_path)) - { + if (STRING_VALID(content_info->thumbnail_path)) { ret = __media_svc_malloc_and_strncpy(&new_content_info->thumbnail_path, content_info->thumbnail_path); - if(ret != MS_MEDIA_ERR_NONE) + if (ret != MS_MEDIA_ERR_NONE) media_svc_error("strcpy thumbnail_path failed"); } - if(STRING_VALID(content_info->media_meta.title)) - { + if (STRING_VALID(content_info->media_meta.title)) { ret = __media_svc_malloc_and_strncpy(&new_content_info->media_meta.title, content_info->media_meta.title); - if(ret != MS_MEDIA_ERR_NONE) + if (ret != MS_MEDIA_ERR_NONE) media_svc_error("strcpy title failed"); } - if(STRING_VALID(content_info->media_meta.album)) - { + if (STRING_VALID(content_info->media_meta.album)) { ret = __media_svc_malloc_and_strncpy(&new_content_info->media_meta.album, content_info->media_meta.album); - if(ret != MS_MEDIA_ERR_NONE) + if (ret != MS_MEDIA_ERR_NONE) media_svc_error("strcpy album failed"); } - if(STRING_VALID(content_info->media_meta.artist)) - { + if (STRING_VALID(content_info->media_meta.artist)) { ret = __media_svc_malloc_and_strncpy(&new_content_info->media_meta.artist, content_info->media_meta.artist); - if(ret != MS_MEDIA_ERR_NONE) + if (ret != MS_MEDIA_ERR_NONE) media_svc_error("strcpy artist failed"); } -/* - if(STRING_VALID(content_info->media_meta.album_artist)) - { - ret = __media_svc_malloc_and_strncpy(&new_content_info->media_meta.album_artist, content_info->media_meta.album_artist); - if(ret != MS_MEDIA_ERR_NONE) - media_svc_error("strcpy album_artist failed"); - } -*/ + /* + if(STRING_VALID(content_info->media_meta.album_artist)) + { + ret = __media_svc_malloc_and_strncpy(&new_content_info->media_meta.album_artist, content_info->media_meta.album_artist); + if(ret != MS_MEDIA_ERR_NONE) + media_svc_error("strcpy album_artist failed"); + } + */ - if(STRING_VALID(content_info->media_meta.genre)) - { + if (STRING_VALID(content_info->media_meta.genre)) { ret = __media_svc_malloc_and_strncpy(&new_content_info->media_meta.genre, content_info->media_meta.genre); - if(ret != MS_MEDIA_ERR_NONE) + if (ret != MS_MEDIA_ERR_NONE) media_svc_error("strcpy genre failed"); } - if(STRING_VALID(content_info->media_meta.composer)) - { + if (STRING_VALID(content_info->media_meta.composer)) { ret = __media_svc_malloc_and_strncpy(&new_content_info->media_meta.composer, content_info->media_meta.composer); - if(ret != MS_MEDIA_ERR_NONE) + if (ret != MS_MEDIA_ERR_NONE) media_svc_error("strcpy composer failed"); } - if(STRING_VALID(content_info->media_meta.year)) - { + if (STRING_VALID(content_info->media_meta.year)) { ret = __media_svc_malloc_and_strncpy(&new_content_info->media_meta.year, content_info->media_meta.year); - if(ret != MS_MEDIA_ERR_NONE) + if (ret != MS_MEDIA_ERR_NONE) media_svc_error("strcpy year failed"); } - if(STRING_VALID(content_info->media_meta.recorded_date)) - { + if (STRING_VALID(content_info->media_meta.recorded_date)) { ret = __media_svc_malloc_and_strncpy(&new_content_info->media_meta.recorded_date, content_info->media_meta.recorded_date); - if(ret != MS_MEDIA_ERR_NONE) + if (ret != MS_MEDIA_ERR_NONE) media_svc_error("strcpy recorded_date failed"); } - if(STRING_VALID(content_info->media_meta.copyright)) - { + if (STRING_VALID(content_info->media_meta.copyright)) { ret = __media_svc_malloc_and_strncpy(&new_content_info->media_meta.copyright, content_info->media_meta.copyright); - if(ret != MS_MEDIA_ERR_NONE) + if (ret != MS_MEDIA_ERR_NONE) media_svc_error("strcpy copyright failed"); } - if(STRING_VALID(content_info->media_meta.track_num)) - { + if (STRING_VALID(content_info->media_meta.track_num)) { ret = __media_svc_malloc_and_strncpy(&new_content_info->media_meta.track_num, content_info->media_meta.track_num); - if(ret != MS_MEDIA_ERR_NONE) + if (ret != MS_MEDIA_ERR_NONE) media_svc_error("strcpy track_num failed"); } - if(STRING_VALID(content_info->media_meta.description)) - { + if (STRING_VALID(content_info->media_meta.description)) { ret = __media_svc_malloc_and_strncpy(&new_content_info->media_meta.description, content_info->media_meta.description); - if(ret != MS_MEDIA_ERR_NONE) + if (ret != MS_MEDIA_ERR_NONE) media_svc_error("strcpy description failed"); } - if(STRING_VALID(content_info->media_meta.weather)) - { + if (STRING_VALID(content_info->media_meta.weather)) { ret = __media_svc_malloc_and_strncpy(&new_content_info->media_meta.weather, content_info->media_meta.weather); - if(ret != MS_MEDIA_ERR_NONE) + if (ret != MS_MEDIA_ERR_NONE) media_svc_error("strcpy description failed"); } - if(STRING_VALID(content_info->media_meta.datetaken)) - { + if (STRING_VALID(content_info->media_meta.datetaken)) { ret = __media_svc_malloc_and_strncpy(&new_content_info->media_meta.datetaken, content_info->media_meta.datetaken); - if(ret != MS_MEDIA_ERR_NONE) + if (ret != MS_MEDIA_ERR_NONE) media_svc_error("strcpy datetaken failed"); new_content_info->timeline = __media_svc_get_timeline_from_str(content_info->media_meta.datetaken); @@ -1603,8 +1589,8 @@ static int __media_svc_copy_para_to_content(media_svc_content_info_s *content_in int media_svc_insert_item_immediately_with_data(MediaSvcHandle *handle, media_svc_content_info_s *content_info, uid_t uid) { int ret = MS_MEDIA_ERR_NONE; - sqlite3 * db_handle = (sqlite3 *)handle; - char folder_uuid[MEDIA_SVC_UUID_SIZE+1] = {0,}; + sqlite3 *db_handle = (sqlite3 *)handle; + char folder_uuid[MEDIA_SVC_UUID_SIZE + 1] = {0, }; bool append_album = FALSE; /* Checking parameters if they are valid */ @@ -1618,14 +1604,12 @@ int media_svc_insert_item_immediately_with_data(MediaSvcHandle *handle, media_sv return MS_MEDIA_ERR_INVALID_PARAMETER; } - if (content_info->size <= 0) - { + if (content_info->size <= 0) { media_svc_error("invalid size condition[%d]", content_info->size); return MS_MEDIA_ERR_INVALID_PARAMETER; } - if (content_info->modified_time <= 0) - { + if (content_info->modified_time <= 0) { media_svc_error("invalid modified_time condition[%d]", content_info->modified_time); return MS_MEDIA_ERR_INVALID_PARAMETER; } @@ -1635,7 +1619,7 @@ int media_svc_insert_item_immediately_with_data(MediaSvcHandle *handle, media_sv memset(&_new_content_info, 0, sizeof(media_svc_content_info_s)); /* set othere data to the structure, which is passed as parameters */ - __media_svc_copy_para_to_content(content_info , &_new_content_info); + __media_svc_copy_para_to_content(content_info, &_new_content_info); /* Set or Get folder id */ ret = _media_svc_get_and_append_folder_id_by_path(handle, _new_content_info.storage_uuid, _new_content_info.path, _new_content_info.storage_type, folder_uuid, uid); @@ -1647,8 +1631,7 @@ int media_svc_insert_item_immediately_with_data(MediaSvcHandle *handle, media_sv /* register album table data */ int album_id = 0; - if(_new_content_info.media_type == MEDIA_SVC_MEDIA_TYPE_SOUND || _new_content_info.media_type == MEDIA_SVC_MEDIA_TYPE_MUSIC) - { + if (_new_content_info.media_type == MEDIA_SVC_MEDIA_TYPE_SOUND || _new_content_info.media_type == MEDIA_SVC_MEDIA_TYPE_MUSIC) { ret = _media_svc_get_album_id(handle, _new_content_info.media_meta.album, _new_content_info.media_meta.artist, &album_id); if (ret != MS_MEDIA_ERR_NONE) { @@ -1663,8 +1646,8 @@ int media_svc_insert_item_immediately_with_data(MediaSvcHandle *handle, media_sv _new_content_info.album_id = album_id; append_album = FALSE; - if((!strncmp(_new_content_info.media_meta.album, MEDIA_SVC_TAG_UNKNOWN, strlen(MEDIA_SVC_TAG_UNKNOWN))) || - (!strncmp(_new_content_info.media_meta.artist, MEDIA_SVC_TAG_UNKNOWN, strlen(MEDIA_SVC_TAG_UNKNOWN)))) { + if ((!strncmp(_new_content_info.media_meta.album, MEDIA_SVC_TAG_UNKNOWN, strlen(MEDIA_SVC_TAG_UNKNOWN))) || + (!strncmp(_new_content_info.media_meta.artist, MEDIA_SVC_TAG_UNKNOWN, strlen(MEDIA_SVC_TAG_UNKNOWN)))) { media_svc_debug("Unknown album or artist already exists. Extract thumbnail for Unknown."); } else { @@ -1676,10 +1659,10 @@ int media_svc_insert_item_immediately_with_data(MediaSvcHandle *handle, media_sv } } - if(append_album == TRUE) { + if (append_album == TRUE) { - if((strncmp(_new_content_info.media_meta.album, MEDIA_SVC_TAG_UNKNOWN, strlen(MEDIA_SVC_TAG_UNKNOWN))) && - (strncmp(_new_content_info.media_meta.artist, MEDIA_SVC_TAG_UNKNOWN, strlen(MEDIA_SVC_TAG_UNKNOWN)))) + if ((strncmp(_new_content_info.media_meta.album, MEDIA_SVC_TAG_UNKNOWN, strlen(MEDIA_SVC_TAG_UNKNOWN))) && + (strncmp(_new_content_info.media_meta.artist, MEDIA_SVC_TAG_UNKNOWN, strlen(MEDIA_SVC_TAG_UNKNOWN)))) ret = _media_svc_append_album(handle, _new_content_info.media_meta.album, _new_content_info.media_meta.artist, _new_content_info.thumbnail_path, &album_id, uid); else ret = _media_svc_append_album(handle, _new_content_info.media_meta.album, _new_content_info.media_meta.artist, NULL, &album_id, uid); @@ -1717,7 +1700,7 @@ char *media_info_generate_uuid(void) int media_svc_insert_storage(MediaSvcHandle *handle, const char *storage_id, const char *storage_name, const char *storage_path, const char *storage_account, media_svc_storage_type_e storage_type, uid_t uid) { int ret = MS_MEDIA_ERR_NONE; - sqlite3 * db_handle = (sqlite3 *)handle; + sqlite3 *db_handle = (sqlite3 *)handle; media_svc_retvm_if(db_handle == NULL, MS_MEDIA_ERR_INVALID_PARAMETER, "Handle is NULL"); media_svc_retvm_if(storage_id == NULL, MS_MEDIA_ERR_INVALID_PARAMETER, "storage_id is NULL"); @@ -1729,8 +1712,7 @@ int media_svc_insert_storage(MediaSvcHandle *handle, const char *storage_id, con ret = _media_svc_create_media_table_with_id(db_handle, storage_id, uid); media_svc_retvm_if(ret != MS_MEDIA_ERR_NONE, ret, "create media table failed : %d", ret); - if(storage_type == MEDIA_SVC_STORAGE_CLOUD) - { + if (storage_type == MEDIA_SVC_STORAGE_CLOUD) { ret = _media_svc_update_media_view(db_handle, uid); media_svc_retvm_if(ret != MS_MEDIA_ERR_NONE, ret, "update media view failed : %d", ret); } @@ -1741,7 +1723,7 @@ int media_svc_insert_storage(MediaSvcHandle *handle, const char *storage_id, con int media_svc_delete_storage(MediaSvcHandle *handle, const char *storage_id, uid_t uid) { int ret = MS_MEDIA_ERR_NONE; - sqlite3 * db_handle = (sqlite3 *)handle; + sqlite3 *db_handle = (sqlite3 *)handle; media_svc_retvm_if(db_handle == NULL, MS_MEDIA_ERR_INVALID_PARAMETER, "Handle is NULL"); media_svc_retvm_if(storage_id == NULL, MS_MEDIA_ERR_INVALID_PARAMETER, "storage_id is NULL"); diff --git a/src/include/common/media-svc-album.h b/src/include/common/media-svc-album.h index a36c083..4af3350 100755 --- a/src/include/common/media-svc-album.h +++ b/src/include/common/media-svc-album.h @@ -25,9 +25,9 @@ #include #include -int _media_svc_get_album_id(sqlite3 *handle, const char *album, const char *artist, int * album_id); +int _media_svc_get_album_id(sqlite3 *handle, const char *album, const char *artist, int *album_id); int _media_svc_get_album_art_by_album_id(sqlite3 *handle, int album_id, char **album_art); -int _media_svc_append_album(sqlite3 *handle, const char *album, const char *artist, const char *album_art, int * album_id, uid_t uid); +int _media_svc_append_album(sqlite3 *handle, const char *album, const char *artist, const char *album_art, int *album_id, uid_t uid); int _media_svc_get_media_count_with_album_id_by_path(sqlite3 *handle, const char *path, int *count); #endif /*_MEDIA_SVC_ALBUM_H_*/ diff --git a/src/include/common/media-svc-db-utils.h b/src/include/common/media-svc-db-utils.h index 125242f..bdb72ed 100755 --- a/src/include/common/media-svc-db-utils.h +++ b/src/include/common/media-svc-db-utils.h @@ -36,8 +36,8 @@ int _media_svc_create_media_table_with_id(sqlite3 *db_handle, const char *table_ int _media_svc_drop_media_table(sqlite3 *handle, const char *storage_id, uid_t uid); int _media_svc_update_media_view(sqlite3 *db_handle, uid_t uid); int _media_svc_sql_query(sqlite3 *db_handle, const char *sql_str, uid_t uid); -int _media_svc_sql_prepare_to_step(sqlite3 *handle, const char *sql_str, sqlite3_stmt** stmt); -int _media_svc_sql_prepare_to_step_simple(sqlite3 *handle, const char *sql_str, sqlite3_stmt** stmt); +int _media_svc_sql_prepare_to_step(sqlite3 *handle, const char *sql_str, sqlite3_stmt **stmt); +int _media_svc_sql_prepare_to_step_simple(sqlite3 *handle, const char *sql_str, sqlite3_stmt **stmt); int _media_svc_sql_begin_trans(sqlite3 *handle, uid_t uid); int _media_svc_sql_end_trans(sqlite3 *handle, uid_t uid); int _media_svc_sql_rollback_trans(sqlite3 *handle, uid_t uid); @@ -46,7 +46,7 @@ void _media_svc_sql_query_add(GList **query_list, char **query); void _media_svc_sql_query_release(GList **query_list); int _media_svc_check_db_upgrade(sqlite3 *db_handle, uid_t uid); int _media_db_check_corrupt(sqlite3 *db_handle); -char* _media_svc_get_path(uid_t uid); +char *_media_svc_get_path(uid_t uid); #endif /*_MEDIA_SVC_DB_UTILS_H_*/ diff --git a/src/include/common/media-svc-debug.h b/src/include/common/media-svc-debug.h index 6a066b0..1f03147 100755 --- a/src/include/common/media-svc-debug.h +++ b/src/include/common/media-svc-debug.h @@ -36,68 +36,68 @@ #define LOG_TAG "MEDIA_SERVICE" #define media_svc_debug(fmt, arg...) do { \ - LOGD(" "fmt"", ##arg); \ - } while (0) + LOGD(" "fmt"", ##arg); \ + } while (0) #define media_svc_error(fmt, arg...) do { \ - LOGE(" "fmt"", ##arg); \ - } while (0) + LOGE(" "fmt"", ##arg); \ + } while (0) #define media_svc_debug_func() do { \ - LOGD(""); \ - } while (0) + LOGD(""); \ + } while (0) #define media_svc_retm_if(expr, fmt, arg...) do { \ - if(expr) { \ - LOGE(" "fmt"", ##arg); \ - return; \ - } \ - } while (0) + if(expr) { \ + LOGE(" "fmt"", ##arg); \ + return; \ + } \ + } while (0) #define media_svc_retv_if(expr, val) do { \ - if(expr) { \ - LOGE(""); \ - return (val); \ - } \ - } while (0) + if(expr) { \ + LOGE(""); \ + return (val); \ + } \ + } while (0) #define media_svc_retvm_if(expr, val, fmt, arg...) do { \ - if(expr) { \ - LOGE(" "fmt"", ##arg); \ - return (val); \ - } \ - } while (0) + if(expr) { \ + LOGE(" "fmt"", ##arg); \ + return (val); \ + } \ + } while (0) #define media_svc_retv_del_if(expr, val, p_str) do { \ - if(expr) { \ - LOGE(""); \ - _media_svc_destroy_content_info(p_str); \ - return (val); \ - } \ - } while (0) + if(expr) { \ + LOGE(""); \ + _media_svc_destroy_content_info(p_str); \ + return (val); \ + } \ + } while (0) #define media_svc_sec_debug(fmt, arg...) do { \ - SECURE_LOGI(" "fmt"", ##arg); \ - } while (0) + SECURE_LOGI(" "fmt"", ##arg); \ + } while (0) #define media_svc_sec_warn(fmt, arg...) do { \ - SECURE_LOGW(" "fmt"", ##arg); \ - } while (0) + SECURE_LOGW(" "fmt"", ##arg); \ + } while (0) #define media_svct_sec_error(fmt, arg...) do { \ - SECURE_LOGE(" "fmt"", ##arg); \ - } while (0) + 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) + 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(); -FILE* get_fp(); -#define mediainfo_file_dbg(fmt,arg...) fprintf( get_fp(), "[%s: %d] [%s]" fmt "\n", __FILE__, __LINE__, __FUNCTION__, ##arg) +FILE *get_fp(); +#define mediainfo_file_dbg(fmt, arg...) fprintf( get_fp(), "[%s: %d] [%s]" fmt "\n", __FILE__, __LINE__, __FUNCTION__, ##arg) #endif @@ -108,9 +108,9 @@ mediainfo_get_debug_time(void); void mediainfo_reset_debug_time(void); void -mediainfo_print_debug_time(char* time_string); +mediainfo_print_debug_time(char *time_string); void -mediainfo_print_debug_time_ex(long start, long end, const char* func_name, char* time_string); +mediainfo_print_debug_time_ex(long start, long end, const char *func_name, char *time_string); #endif #endif /*_MEDIA_SVC_DEBUG_H_*/ diff --git a/src/include/common/media-svc-env.h b/src/include/common/media-svc-env.h index cc11674..8ff229e 100755 --- a/src/include/common/media-svc-env.h +++ b/src/include/common/media-svc-env.h @@ -103,11 +103,11 @@ extern "C" { #define MEDIA_SVC_DB_QUERY_VIEW_PLAYLIST "CREATE VIEW IF NOT EXISTS %s AS SELECT %s FROM playlist \ LEFT OUTER JOIN playlist_map ON playlist.playlist_id = playlist_map.playlist_id \ LEFT OUTER JOIN media ON (playlist_map.media_uuid = media.media_uuid AND media.validity=1) \ - LEFT OUTER JOIN (SELECT count(playlist_id) as media_count, playlist_id FROM playlist_map group by playlist_id) as cnt_tbl ON (cnt_tbl.playlist_id=playlist_map.playlist_id AND media.validity=1);" +LEFT OUTER JOIN (SELECT count(playlist_id) as media_count, playlist_id FROM playlist_map group by playlist_id) as cnt_tbl ON (cnt_tbl.playlist_id=playlist_map.playlist_id AND media.validity=1);" #define MEDIA_SVC_DB_QUERY_VIEW_TAG "CREATE VIEW IF NOT EXISTS %s AS SELECT %s FROM tag \ LEFT OUTER JOIN tag_map ON tag.tag_id=tag_map.tag_id \ LEFT OUTER JOIN media ON (tag_map.media_uuid = media.media_uuid AND media.validity=1) \ - LEFT OUTER JOIN (SELECT count(tag_id) as media_count, tag_id FROM tag_map group by tag_id) as cnt_tbl ON (cnt_tbl.tag_id=tag_map.tag_id AND media.validity=1);" +LEFT OUTER JOIN (SELECT count(tag_id) as media_count, tag_id FROM tag_map group by tag_id) as cnt_tbl ON (cnt_tbl.tag_id=tag_map.tag_id AND media.validity=1);" #define MEDIA_SVC_DB_QUERY_ALTER_TABLE "ALTER TABLE %s ADD COLUMN %s;" #define MEDIA_SVC_DB_QUERY_DROP_VIEW "DROP VIEW IF EXISTS %s;" @@ -129,25 +129,25 @@ extern "C" { #define THUMB_EXT "jpg" enum Exif_Orientation { - NOT_AVAILABLE=0, - NORMAL =1, - HFLIP =2, - ROT_180 =3, - VFLIP =4, - TRANSPOSE =5, - ROT_90 =6, - TRANSVERSE =7, - ROT_270 =8 + NOT_AVAILABLE = 0, + NORMAL = 1, + HFLIP = 2, + ROT_180 = 3, + VFLIP = 4, + TRANSPOSE = 5, + ROT_90 = 6, + TRANSVERSE = 7, + ROT_270 = 8 }; -typedef enum{ +typedef enum { MEDIA_SVC_QUERY_INSERT_ITEM, MEDIA_SVC_QUERY_SET_ITEM_VALIDITY, MEDIA_SVC_QUERY_MOVE_ITEM, MEDIA_SVC_QUERY_UPDATE_ITEM } media_svc_query_type_e; -typedef enum{ +typedef enum { MEDIA_SVC_DB_LIST_MEDIA = 0, MEDIA_SVC_DB_LIST_FOLDER = 1, MEDIA_SVC_DB_LIST_PLAYLIST_MAP = 2, @@ -166,7 +166,7 @@ typedef struct table_inform { char *viewName; char *eventTable; char *actionTable; -}table_info; +} table_info; typedef struct column_inform { char *name; @@ -179,7 +179,7 @@ typedef struct column_inform { bool isUnique; bool isTrigger; bool isView; -}column_info; +} column_info; #ifdef __cplusplus diff --git a/src/include/common/media-svc-localize-utils.h b/src/include/common/media-svc-localize-utils.h index 30c45ab..2a9c124 100755 --- a/src/include/common/media-svc-localize-utils.h +++ b/src/include/common/media-svc-localize-utils.h @@ -29,4 +29,4 @@ int SAFE_SNPRINTF(char **buf, int *buf_size, int len, const char *src); int _media_svc_collation_str(const char *src, char **dest); -#endif // __MEDIA_SVC_LOCALIZE_UTILS_H__ \ No newline at end of file +#endif /* __MEDIA_SVC_LOCALIZE_UTILS_H__ */ \ No newline at end of file diff --git a/src/include/common/media-svc-localize_ch.h b/src/include/common/media-svc-localize_ch.h index 794a384..5d0e132 100755 --- a/src/include/common/media-svc-localize_ch.h +++ b/src/include/common/media-svc-localize_ch.h @@ -31,4 +31,4 @@ void _media_svc_pinyin_free(pinyin_name_s *pinyinname, int size); bool _media_svc_has_chinese(const char *src); -#endif // __MEDIA_SERVICE_LOCALIZE_CH_H__ \ No newline at end of file +#endif /* __MEDIA_SERVICE_LOCALIZE_CH_H__ */ \ No newline at end of file diff --git a/src/include/common/media-svc-localize_tw.h b/src/include/common/media-svc-localize_tw.h old mode 100644 new mode 100755 index 2cad1f0..de01d3c --- a/src/include/common/media-svc-localize_tw.h +++ b/src/include/common/media-svc-localize_tw.h @@ -24,7 +24,7 @@ typedef struct { char *bpmf_initial; char *bpmf_name; -}media_svc_bpmf_name_s; +} media_svc_bpmf_name_s; int _media_svc_get_bopomofo(const char *src, char **dest); int _media_svc_convert_chinese_to_bpmf(const char *src, media_svc_bpmf_name_s **dest); @@ -32,4 +32,4 @@ void _media_svc_bpmf_name_destroy(media_svc_bpmf_name_s *bpmf); bool _media_svc_bpmf_is_bpmf(const char *src); char _media_svc_bpmf_get_fuzzy_number(const char *src); -#endif //__MEDIA_SERVICE_LOCALIZE_TW_H__ \ No newline at end of file +#endif /*__MEDIA_SERVICE_LOCALIZE_TW_H__ */ \ No newline at end of file diff --git a/src/include/common/media-svc-media-folder.h b/src/include/common/media-svc-media-folder.h index a0b8ea7..9e2b85a 100755 --- a/src/include/common/media-svc-media-folder.h +++ b/src/include/common/media-svc-media-folder.h @@ -32,7 +32,7 @@ int _media_svc_update_folder_modified_time_by_folder_uuid(sqlite3 *handle, const int _media_svc_get_and_append_folder(sqlite3 *handle, const char *storage_id, const char *path, media_svc_storage_type_e storage_type, char *folder_id, uid_t uid); int _media_svc_get_and_append_folder_id_by_path(sqlite3 *handle, const char *storage_id, const char *path, media_svc_storage_type_e storage_type, char *folder_id, uid_t uid); int _media_svc_update_folder_table(sqlite3 *handle, uid_t uid); -int _media_svc_get_all_folders(sqlite3 *handle, char* start_path, char ***folder_list, time_t **modified_time_list, int **item_num_list, int *count); +int _media_svc_get_all_folders(sqlite3 *handle, char *start_path, char ***folder_list, time_t **modified_time_list, int **item_num_list, int *count); int _media_svc_get_folder_info_by_foldername(sqlite3 *handle, const char *folder_name, char *folder_id, time_t *modified_time); #endif /*_MEDIA_SVC_MEDIA_FOLDER_H_*/ diff --git a/src/include/common/media-svc-media.h b/src/include/common/media-svc-media.h index a7f2fe4..28c8e69 100755 --- a/src/include/common/media-svc-media.h +++ b/src/include/common/media-svc-media.h @@ -48,7 +48,7 @@ int _media_svc_update_thumbnail_path(sqlite3 *handle, const char *storage_id, co int _media_svc_get_noti_info(sqlite3 *handle, const char *storage_id, const char *path, int update_item, media_svc_noti_item **item); int _media_svc_count_invalid_folder_items(sqlite3 *handle, const char *folder_path, int *count); int _media_svc_get_thumbnail_count(sqlite3 *handle, const char *thumb_path, int *count); -char* _media_svc_get_thumb_default_path(uid_t uid); +char *_media_svc_get_thumb_default_path(uid_t uid); int _media_svc_get_fileinfo_by_path(sqlite3 *handle, const char *path, time_t *modified_time, unsigned long long *size); int _media_svc_update_meta_with_data(sqlite3 *handle, media_svc_content_info_s *content_info); diff --git a/src/include/common/media-svc-noti.h b/src/include/common/media-svc-noti.h index a26f6b9..93ffa67 100755 --- a/src/include/common/media-svc-noti.h +++ b/src/include/common/media-svc-noti.h @@ -46,12 +46,12 @@ int _media_svc_destroy_noti_list(int all_cnt); int _media_svc_publish_noti_list(int all_cnt); int _media_svc_destroy_noti_item(media_svc_noti_item *item); int _media_svc_publish_noti(media_item_type_e update_item, - media_item_update_type_e update_type, - const char *path, - media_type_e media_type, - const char *uuid, - const char *mime_type -); + media_item_update_type_e update_type, + const char *path, + media_type_e media_type, + const char *uuid, + const char *mime_type + ); #endif /*_MEDIA_SVC_NOTI_H_*/ diff --git a/src/include/common/media-svc-util.h b/src/include/common/media-svc-util.h index b272f1e..15a12c1 100755 --- a/src/include/common/media-svc-util.h +++ b/src/include/common/media-svc-util.h @@ -47,13 +47,13 @@ extern "C" { char *_media_info_generate_uuid(void); void _strncpy_safe(char *x_dst, const char *x_src, int max_len); -int _media_svc_rename_file( const char *old_name, const char *new_name); +int _media_svc_rename_file(const char *old_name, const char *new_name); int _media_svc_remove_file(const char *path); int _media_svc_remove_all_files_in_dir(const char *dir_path); int _media_svc_get_thumbnail_path(media_svc_storage_type_e storage_type, char *thumb_path, const char *pathname, const char *img_format, uid_t uid); int _media_svc_get_file_time(const char *full_path); int _media_svc_set_media_info(media_svc_content_info_s *content_info, const char *storage_id, media_svc_storage_type_e storage_type, - const char *path, media_svc_media_type_e *media_type, bool refresh); + const char *path, media_svc_media_type_e *media_type, bool refresh); int _media_svc_extract_image_metadata(sqlite3 *handle, media_svc_content_info_s *content_info, media_svc_media_type_e media_type, uid_t uid); int _media_svc_extract_media_metadata(sqlite3 *handle, media_svc_content_info_s *content_info, media_svc_media_type_e media_type, uid_t uid); int __media_svc_malloc_and_strncpy(char **dst, const char *src); @@ -61,8 +61,8 @@ time_t __media_svc_get_timeline_from_str(const char *timstr); void _media_svc_destroy_content_info(media_svc_content_info_s *content_info); int _media_svc_get_store_type_by_path(const char *path, media_svc_storage_type_e *storage_type, uid_t uid); char *_media_svc_replace_path(char *s, const char *olds, const char *news); -char* _media_svc_get_thumb_internal_path(uid_t uid); -char* _media_svc_get_thumb_external_path(uid_t uid); +char *_media_svc_get_thumb_internal_path(uid_t uid); +char *_media_svc_get_thumb_external_path(uid_t uid); bool _media_svc_is_drm_file(const char *path); int _media_svc_request_thumbnail_with_origin_size(const char *path, char *thumb_path, int max_length, int *origin_width, int *origin_height, uid_t uid); int _media_svc_get_pinyin_str(const char *src_str, char **pinyin_str); diff --git a/test/media-service-test.c b/test/media-service-test.c old mode 100644 new mode 100755 index a0a5ea3..ce20ff8 --- a/test/media-service-test.c +++ b/test/media-service-test.c @@ -18,25 +18,25 @@ * limitations under the License. * */ - + #include #include #include #include -#define SAFE_FREE(src) { if(src) {free(src); src = NULL;}} +#define SAFE_FREE(src) { if(src) { free(src); src = NULL; } } GMainLoop *g_loop = NULL; MediaSvcHandle *g_db_handle = NULL; void _noti_cb(int pid, - media_item_type_e update_item, - media_item_update_type_e update_type, - char *path, - char *uuid, - media_type_e content_type, - char *mime_type, - void *user_data) + media_item_type_e update_item, + media_item_update_type_e update_type, + char *path, + char *uuid, + media_type_e content_type, + char *mime_type, + void *user_data) { media_svc_debug("Noti from PID(%d)", pid); @@ -54,7 +54,7 @@ void _noti_cb(int pid, media_svc_debug("Noti type : MS_MEDIA_ITEM_UPDATE"); } - //media_svc_debug("content type : %d", content_type); + /*media_svc_debug("content type : %d", content_type); */ printf("content type : %d\n", content_type); if (path) @@ -67,24 +67,24 @@ void _noti_cb(int pid, else printf("mime not"); - if (user_data) printf("String : %s\n", (char *)user_data); + if (user_data) printf("String : %s\n", (char *)user_data); else printf("user not"); - return; + return; } #if 1 gboolean _send_noti_batch_operations(gpointer data) { - int ret = MS_MEDIA_ERR_NONE; + int ret = MS_MEDIA_ERR_NONE; - /* First of all, noti subscription */ - char *user_str = strdup("hi"); - media_db_update_subscribe(_noti_cb, (void*)user_str); + /* First of all, noti subscription */ + char *user_str = strdup("hi"); + media_db_update_subscribe(_noti_cb, (void *)user_str); - /* 1. media_svc_insert_item_immediately */ - char *path = tzplatform_mkpath(TZ_USER_CONTENT, "test/image1.jpg"); + /* 1. media_svc_insert_item_immediately */ + char *path = tzplatform_mkpath(TZ_USER_CONTENT, "test/image1.jpg"); media_svc_storage_type_e storage_type; @@ -92,17 +92,17 @@ gboolean _send_noti_batch_operations(gpointer data) if (ret != MS_MEDIA_ERR_NONE) { media_svc_error("media_svc_get_storage_type failed : %d (%s)", ret, path); SAFE_FREE(user_str); - return FALSE; + return FALSE; } int idx = 0; char *file_list[10]; ret = media_svc_insert_item_begin(g_db_handle, 100, TRUE, getpid()); - //ret = media_svc_insert_item_begin(g_db_handle, 100); + /*ret = media_svc_insert_item_begin(g_db_handle, 100); */ for (idx = 0; idx < 10; idx++) { - char filepath[255] = {0,}; - snprintf(filepath, sizeof(filepath), "%s%d.jpg", tzplatform_mkpath(TZ_USER_CONTENT,"test/image"), idx+1); + char filepath[255] = {0, }; + snprintf(filepath, sizeof(filepath), "%s%d.jpg", tzplatform_mkpath(TZ_USER_CONTENT, "test/image"), idx + 1); media_svc_debug("File : %s\n", filepath); file_list[idx] = strdup(filepath); ret = media_svc_insert_item_bulk(g_db_handle, storage_type, file_list[idx], FALSE); @@ -126,10 +126,10 @@ gboolean _send_noti_operations(gpointer data) /* First of all, noti subscription */ char *user_str = strdup("hi"); - media_db_update_subscribe(_noti_cb, (void*)user_str); + media_db_update_subscribe(_noti_cb, (void *)user_str); /* 1. media_svc_insert_item_immediately */ - char *path = tzplatform_mkpath(TZ_USER_CONTENT,"test/image1.jpg"); + char *path = tzplatform_mkpath(TZ_USER_CONTENT, "test/image1.jpg"); media_svc_storage_type_e storage_type; ret = media_svc_get_storage_type(path, &storage_type, tzplatform_getuid(TZ_USER_NAME)); @@ -182,7 +182,7 @@ gboolean _send_noti_operations(gpointer data) /* Rename folder */ const char *src_folder_path = tzplatform_mkpath(TZ_USER_CONTENT, "test"); - const char *dst_folder_path = tzplatform_mkpath(TZ_USER_CONTENT,"test_test"); + const char *dst_folder_path = tzplatform_mkpath(TZ_USER_CONTENT, "test_test"); ret = media_svc_rename_folder(g_db_handle, src_folder_path, dst_folder_path); if (ret != MS_MEDIA_ERR_NONE) { media_svc_error("media_svc_rename_folder failed : %d", ret); @@ -210,16 +210,16 @@ int test_noti() context = g_main_loop_get_context(g_loop); source = g_idle_source_new(); #if 0 - g_source_set_callback (source, _send_noti_operations, NULL, NULL); + g_source_set_callback(source, _send_noti_operations, NULL, NULL); #else - g_source_set_callback (source, _send_noti_batch_operations, NULL, NULL); + g_source_set_callback(source, _send_noti_batch_operations, NULL, NULL); #endif - g_source_attach (source, context); + g_source_attach(source, context); g_main_loop_run(g_loop); g_main_loop_unref(g_loop); - media_db_update_unsubscribe(); + media_db_update_unsubscribe(); return MS_MEDIA_ERR_NONE; } diff --git a/test/plugin/media_svc_plugin_test.c b/test/plugin/media_svc_plugin_test.c index 31797fa..0873d32 100755 --- a/test/plugin/media_svc_plugin_test.c +++ b/test/plugin/media_svc_plugin_test.c @@ -28,41 +28,41 @@ #include #define PLUGIN_SO_FILE_NAME "/usr/lib/libmedia-content-plugin.so" -#define MEDIA_ROOT_PATH_SDCARD tzplatform_mkpath(TZ_SYS_STORAGE,"sdcard") +#define MEDIA_ROOT_PATH_SDCARD tzplatform_mkpath(TZ_SYS_STORAGE, "sdcard") void *funcHandle = NULL; static void msg_print(int line, char *msg); -int (*svc_connect) (void ** handle, char ** err_msg); -int (*svc_disconnect) (void * handle, char ** err_msg); -int (*svc_check_item_exist) (void* handle, const char *file_path, bool *modified, char ** err_msg); -int (*svc_insert_item_immediately) (void* handle, const char *file_path, int storage_type, const char * mime_type, char ** err_msg); -int (*svc_set_folder_item_validity) (void * handle, const char * folder_path, int validity, int recursive, char ** err_msg); -int (*svc_delete_all_invalid_items_in_folder) (void * handle, const char *folder_path, char ** err_msg); +int (*svc_connect)(void **handle, char **err_msg); +int (*svc_disconnect)(void *handle, char **err_msg); +int (*svc_check_item_exist)(void *handle, const char *file_path, bool *modified, char **err_msg); +int (*svc_insert_item_immediately)(void *handle, const char *file_path, int storage_type, const char *mime_type, char **err_msg); +int (*svc_set_folder_item_validity)(void *handle, const char *folder_path, int validity, int recursive, char **err_msg); +int (*svc_delete_all_invalid_items_in_folder)(void *handle, const char *folder_path, char **err_msg); int __load_functions() { msg_print(__LINE__, "__load_functions"); - funcHandle = dlopen (PLUGIN_SO_FILE_NAME, RTLD_LAZY); + funcHandle = dlopen(PLUGIN_SO_FILE_NAME, RTLD_LAZY); if (!funcHandle) { - fprintf (stderr,"error: %s\n", dlerror()); + fprintf(stderr, "error: %s\n", dlerror()); } - svc_connect = dlsym (funcHandle, "connect"); - svc_disconnect = dlsym (funcHandle, "disconnect"); - 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"); - svc_delete_all_invalid_items_in_folder = dlsym (funcHandle, "delete_all_invalid_items_in_folder"); - - if ( !svc_connect || - !svc_disconnect || - !svc_insert_item_immediately || - !svc_set_folder_item_validity || - !svc_delete_all_invalid_items_in_folder || - !svc_check_item_exist) { - fprintf(stderr,"error: %s\n", dlerror()); + svc_connect = dlsym(funcHandle, "connect"); + svc_disconnect = dlsym(funcHandle, "disconnect"); + 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"); + svc_delete_all_invalid_items_in_folder = dlsym(funcHandle, "delete_all_invalid_items_in_folder"); + + if (!svc_connect || + !svc_disconnect || + !svc_insert_item_immediately || + !svc_set_folder_item_validity || + !svc_delete_all_invalid_items_in_folder || + !svc_check_item_exist) { + fprintf(stderr, "error: %s\n", dlerror()); return -1; } @@ -73,9 +73,8 @@ int __unload_functions(void) { msg_print(__LINE__, "__unload_functions"); - if (funcHandle) - { - dlclose (funcHandle); + if (funcHandle) { + dlclose(funcHandle); } return 0; @@ -84,24 +83,24 @@ int __unload_functions(void) int main() { int ret = 0; - MediaSvcHandle * db_handle = NULL; - char * err_msg = NULL; - char path[1024] = {0,}; - char type[1024] = {0,}; + MediaSvcHandle *db_handle = NULL; + char *err_msg = NULL; + char path[1024] = {0, }; + char type[1024] = {0, }; ret = __load_functions(); - if(ret < 0) { + if (ret < 0) { msg_print(__LINE__, "__load_functions error"); return -1; } else { msg_print(__LINE__, "__load_functions success"); } - //db open ================================================== + /*db open ================================================== */ ret = svc_connect(&db_handle, &err_msg); - if(ret < 0) { + if (ret < 0) { msg_print(__LINE__, "svc_connect error"); - if(err_msg != NULL) { + if (err_msg != NULL) { printf("err_msg[%s]\n", err_msg); free(err_msg); err_msg = NULL; @@ -124,57 +123,57 @@ int main() #if 1 while (1) { - printf("Enter path and mimetype ( ex. %s image ) : ", tzplatform_mkpath(TZ_USER_CONTENT, "a.jpg")); - scanf("%s %s", path, type); - bool modified = false; - //check_item_exist ============================================ - ret = svc_check_item_exist(db_handle, path, &modified, &err_msg); - if(ret < 0) { - msg_print(__LINE__, "svc_check_item_exist error"); - if(err_msg != NULL) { - printf("err_msg[%s]\n", err_msg); - free(err_msg); - err_msg = NULL; + printf("Enter path and mimetype ( ex. %s image ) : ", tzplatform_mkpath(TZ_USER_CONTENT, "a.jpg")); + scanf("%s %s", path, type); + bool modified = false; + /*check_item_exist ============================================ */ + ret = svc_check_item_exist(db_handle, path, &modified, &err_msg); + if (ret < 0) { + msg_print(__LINE__, "svc_check_item_exist error"); + if (err_msg != NULL) { + printf("err_msg[%s]\n", err_msg); + free(err_msg); + err_msg = NULL; + } + /*__unload_functions(); */ + /*return -1; */ + } else { + if (modified) + msg_print(__LINE__, "svc_check_item_exist success. Modified"); + else + msg_print(__LINE__, "svc_check_item_exist success. Not modified"); } - //__unload_functions(); - //return -1; - } else { - if(modified) - msg_print(__LINE__, "svc_check_item_exist success. Modified"); - else - msg_print(__LINE__, "svc_check_item_exist success. Not modified"); - } - // svc_check_item_exist ============================================ - ret = svc_insert_item_immediately(db_handle, path, 0, type, &err_msg); - if(ret < 0) { - msg_print(__LINE__, "svc_insert_item_immediately error"); - if(err_msg != NULL) { - printf("err_msg[%s]\n", err_msg); - free(err_msg); - err_msg = NULL; + /* svc_check_item_exist ============================================ */ + ret = svc_insert_item_immediately(db_handle, path, 0, type, &err_msg); + if (ret < 0) { + msg_print(__LINE__, "svc_insert_item_immediately error"); + if (err_msg != NULL) { + printf("err_msg[%s]\n", err_msg); + free(err_msg); + err_msg = NULL; + } + /*__unload_functions(); */ + /*return -1; */ + } else { + msg_print(__LINE__, "svc_insert_item_immediately success"); } - //__unload_functions(); - //return -1; - } else { - msg_print(__LINE__, "svc_insert_item_immediately success"); - } - } // End of While + } /* End of While */ ret = media_svc_insert_folder(db_handle, 0, path); - if(ret < 0) { + if (ret < 0) { msg_print(__LINE__, "media_svc_insert_folder error "); } else { msg_print(__LINE__, "media_svc_insert_folder success"); } #endif - //folder test ================================================== - char *folder_path = tzplatform_mkpath(TZ_USER_CONTENT,"Sounds")); + /*folder test ================================================== */ + char *folder_path = tzplatform_mkpath(TZ_USER_CONTENT, "Sounds")); ret = svc_set_folder_item_validity(db_handle, folder_path, 0, 1, &err_msg); - if(ret < 0) { - msg_print(__LINE__, "svc_set_folder_item_validity error"); - if(err_msg != NULL) { + if (ret < 0) { + msg_print(__LINE__, "svc_set_folder_item_validity error"); + if (err_msg != NULL) { printf("err_msg[%s]\n", err_msg); free(err_msg); err_msg = NULL; @@ -184,9 +183,9 @@ int main() } ret = svc_delete_all_invalid_items_in_folder(db_handle, folder_path, &err_msg); - if(ret < 0) { - msg_print(__LINE__, "svc_delete_all_invalid_items_in_folder error"); - if(err_msg != NULL) { + if (ret < 0) { + msg_print(__LINE__, "svc_delete_all_invalid_items_in_folder error"); + if (err_msg != NULL) { printf("err_msg[%s]\n", err_msg); free(err_msg); err_msg = NULL; @@ -195,11 +194,11 @@ int main() msg_print(__LINE__, "svc_insert_item_immediately success"); } - //db close ================================================== + /*db close ================================================== */ ret = svc_disconnect(db_handle, &err_msg); - if(ret < 0) { - msg_print(__LINE__, "svc_disconnect error"); - if(err_msg != NULL) { + if (ret < 0) { + msg_print(__LINE__, "svc_disconnect error"); + if (err_msg != NULL) { printf("err_msg[%s]\n", err_msg); free(err_msg); err_msg = NULL; -- 2.7.4