From 4fcae405c8951e5ea0bd320c29a931ca02714174 Mon Sep 17 00:00:00 2001 From: "Haejeong, Kim" Date: Tue, 13 Oct 2015 18:21:37 +0900 Subject: [PATCH] Apply tizen coding rule Change-Id: I80be849502c344927d2a4dc14848a9fb7846618f --- include/media-svc-types.h | 4 +- plugin/media-content-plugin.c | 102 ++++++++++++++--------------- src/common/media-svc-album.c | 2 +- src/common/media-svc-db-utils.c | 24 +++---- src/common/media-svc-debug.c | 13 ++-- src/common/media-svc-media-folder.c | 54 ++++++++-------- src/common/media-svc-media.c | 49 +++++++------- src/common/media-svc-noti.c | 41 ++++-------- src/common/media-svc-storage.c | 34 +++++----- src/common/media-svc-util.c | 55 +++++++--------- src/common/media-svc.c | 111 +++++++++++++++----------------- src/include/common/media-svc-db-utils.h | 2 +- src/include/common/media-svc-debug.h | 24 +++---- src/include/common/media-svc-env.h | 66 +++++++++---------- src/include/common/media-svc-util.h | 8 +-- test/media-service-test.c | 16 ++--- test/plugin/media_svc_plugin_test.c | 11 +--- 17 files changed, 291 insertions(+), 325 deletions(-) diff --git a/include/media-svc-types.h b/include/media-svc-types.h index ec36318..959d13d 100755 --- a/include/media-svc-types.h +++ b/include/media-svc-types.h @@ -124,7 +124,7 @@ typedef struct { int last_played_position; /**< last played position */ time_t favourate; /**< time favourate set */ int is_drm; /**< is_drm. o or 1 */ - int sync_status; /**< sync_status */ + int sync_status; /**< sync_status */ int storage_type; /**< Storage of media file : internal/external */ char *storage_uuid; /**< Unique ID of storage */ media_svc_content_meta_s media_meta; /**< meta data structure for audio files */ @@ -141,6 +141,6 @@ typedef enum{ MEDIA_SVC_SCAN_MAX = 4, /**< Invalid status*/ }media_svc_scan_status_type_e; -#define MEDIA_SVC_DEFAULT_GPS_VALUE -200 /**< Default GPS Value*/ +#define MEDIA_SVC_DEFAULT_GPS_VALUE -200 /**< Default GPS Value*/ #endif /*_MEDIA_SVC_TYPES_H_*/ diff --git a/plugin/media-content-plugin.c b/plugin/media-content-plugin.c index a3ba0b8..7181e7d 100755 --- a/plugin/media-content-plugin.c +++ b/plugin/media-content-plugin.c @@ -276,7 +276,7 @@ int insert_burst_item(void *handle, const char *storage_id, const char *file_pat return MEDIA_SVC_PLUGIN_ERROR_NONE; } -int set_all_storage_items_validity(void *handle, const char *storage_id, int storage_type, int validity, uid_t uid, char **err_msg) +int set_all_storage_items_validity(void *handle, const char *storage_id, int storage_type, int validity, uid_t uid, char **err_msg) { int ret = MEDIA_SVC_PLUGIN_ERROR_NONE; @@ -629,13 +629,13 @@ int get_uuid(void * handle, char **uuid, 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_generate_uuid(uuid); - if(ret < 0) { + if (ret < 0) { __set_error_message(ret, err_msg); return MEDIA_SVC_PLUGIN_ERROR; } @@ -647,13 +647,13 @@ int get_mmc_info(void * handle, char **storage_name, char **storage_path, int *v { 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_get_mmc_info(handle, storage_name, storage_path, validity, info_exist); - if(ret < 0) { + if (ret < 0) { __set_error_message(MS_MEDIA_ERR_DB_NO_RECORD, err_msg); return MEDIA_SVC_PLUGIN_ERROR; } @@ -665,13 +665,13 @@ int check_storage(void * handle, const char *storage_id, const char *storage_nam { 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_check_storage(handle, storage_id, storage_name, storage_path, validity); - if(ret < 0) { + if (ret < 0) { __set_error_message(ret, err_msg); return MEDIA_SVC_PLUGIN_ERROR; } @@ -683,13 +683,13 @@ int insert_storage(void *handle, const char *storage_id, int storage_type, const { 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_storage(handle, storage_id, storage_name, storage_path, NULL, storage_type, uid); - if(ret < 0) { + if (ret < 0) { __set_error_message(ret, err_msg); return MEDIA_SVC_PLUGIN_ERROR; } @@ -701,13 +701,13 @@ int update_storage(void *handle, const char *storage_id, const char *storage_pat { 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_storage(handle, storage_id, storage_path, uid); - if(ret < 0) { + if (ret < 0) { __set_error_message(ret, err_msg); return MEDIA_SVC_PLUGIN_ERROR; } @@ -719,13 +719,13 @@ int delete_storage(void * handle, const char *storage_id, const char *storage_na { 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_delete_storage(handle, storage_id, storage_name, uid); - if(ret < 0) { + if (ret < 0) { __set_error_message(ret, err_msg); return MEDIA_SVC_PLUGIN_ERROR; } @@ -737,13 +737,13 @@ int set_storage_validity(void * handle, const char *storage_id, int validity, ui { 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_storage_validity(handle, storage_id, validity, uid); - if(ret < 0) { + if (ret < 0) { __set_error_message(ret, err_msg); return MEDIA_SVC_PLUGIN_ERROR; } @@ -755,13 +755,13 @@ int set_all_storage_validity(void * handle, int validity, char **err_msg, uid_t { 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_storage_validity(handle, NULL, validity, uid); - if(ret < 0) { + if (ret < 0) { __set_error_message(ret, err_msg); return MEDIA_SVC_PLUGIN_ERROR; } @@ -773,13 +773,13 @@ int get_storage_id(void * handle, const char *path, char *storage_id, char **err { 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_get_storage_id(handle, path, storage_id); - if(ret < 0) { + if (ret < 0) { __set_error_message(ret, err_msg); return MEDIA_SVC_PLUGIN_ERROR; } @@ -792,13 +792,13 @@ int get_storage_scan_status(void * handle, const char *storage_id, int *status, int ret = MEDIA_SVC_PLUGIN_ERROR_NONE; media_svc_scan_status_type_e storage_status = 0; - if(handle == NULL) { + if (handle == NULL) { __set_error_message(ERR_HANDLE, err_msg); return MEDIA_SVC_PLUGIN_ERROR; } ret = media_svc_get_storage_scan_status(handle, storage_id, &storage_status); - if(ret < 0) { + if (ret < 0) { __set_error_message(ret, err_msg); return MEDIA_SVC_PLUGIN_ERROR; } @@ -813,13 +813,13 @@ int set_storage_scan_status(void *handle, const char *storage_id, int status, ui int ret = MEDIA_SVC_PLUGIN_ERROR_NONE; media_svc_scan_status_type_e storage_status = status; - if(handle == NULL) { + if (handle == NULL) { __set_error_message(ERR_HANDLE, err_msg); return MEDIA_SVC_PLUGIN_ERROR; } ret = media_svc_set_storage_scan_status(handle, storage_id, storage_status, uid); - if(ret < 0) { + if (ret < 0) { __set_error_message(ret, err_msg); return MEDIA_SVC_PLUGIN_ERROR; } @@ -831,18 +831,18 @@ int get_storage_list(void *handle, char ***storage_list, char ***storage_id_list { 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_storage_list(handle, storage_list, storage_id_list, scan_status_list, count); - if(ret < 0) { + if (ret < 0) { __set_error_message(ret, err_msg); return MEDIA_SVC_PLUGIN_ERROR; } @@ -913,7 +913,7 @@ int insert_item_scan(void * handle, const char *storage_id, const char *file_pat { 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; } @@ -923,13 +923,13 @@ int insert_item_scan(void * handle, const char *storage_id, const char *file_pat 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_pass1(handle, storage_id, storage_type, file_path, FALSE, uid); - if(ret < 0) { + if (ret < 0) { __set_error_message(ret, err_msg); return MEDIA_SVC_PLUGIN_ERROR; } @@ -941,18 +941,18 @@ int update_item_extract(void * handle, const char *storage_id, int storage_type, { 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_insert_item_pass2(handle, storage_id, storage_type, scan_type, path, FALSE, uid); - if(ret < 0) { + if (ret < 0) { __set_error_message(ret, err_msg); return MEDIA_SVC_PLUGIN_ERROR; } @@ -964,13 +964,13 @@ int insert_folder_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_insert_folder_begin(handle, item_cnt); - if(ret < 0) { + if (ret < 0) { __set_error_message(ret, err_msg); return MEDIA_SVC_PLUGIN_ERROR; } @@ -982,13 +982,13 @@ int insert_folder_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_folder_end(handle, uid); - if(ret < 0) { + if (ret < 0) { __set_error_message(ret, err_msg); return MEDIA_SVC_PLUGIN_ERROR; } @@ -1000,7 +1000,7 @@ int insert_folder(void * handle, const char *storage_id, const char *file_path, { 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; } @@ -1010,13 +1010,13 @@ int insert_folder(void * handle, const char *storage_id, const char *file_path, 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_folder(handle, storage_id, storage_type, file_path, uid); - if(ret < 0) { + if (ret < 0) { __set_error_message(ret, err_msg); return MEDIA_SVC_PLUGIN_ERROR; } @@ -1028,13 +1028,13 @@ int delete_invalid_folder(void * handle, const char *storage_id, uid_t uid, char { 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_delete_invalid_folder(handle, storage_id, uid); - if(ret < 0) { + if (ret < 0) { __set_error_message(ret, err_msg); return MEDIA_SVC_PLUGIN_ERROR; } @@ -1046,13 +1046,13 @@ int set_folder_validity(void * handle, const char *storage_id, const char* start { 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_folder_validity(handle, storage_id, start_path, validity, is_recursive, uid); - if(ret < 0) { + if (ret < 0) { __set_error_message(ret, err_msg); return MEDIA_SVC_PLUGIN_ERROR; } @@ -1064,13 +1064,13 @@ int delete_invalid_folder_by_path(void * handle, const char *storage_id, const c { 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_delete_invalid_folder_by_path(handle, storage_id, folder_path, uid, delete_count); - if(ret < 0) { + if (ret < 0) { __set_error_message(ret, err_msg); return MEDIA_SVC_PLUGIN_ERROR; } @@ -1082,13 +1082,13 @@ int check_folder_exist(void * handle, const char *storage_id, const char *folder { 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_check_folder_exist_by_path(handle, storage_id, folder_path); - if(ret < 0) { + if (ret < 0) { __set_error_message(ret, err_msg); return MEDIA_SVC_PLUGIN_ERROR; } @@ -1101,13 +1101,13 @@ int count_subfolder(void * handle, const char *storage_id, const char *folder_pa int ret = MEDIA_SVC_PLUGIN_ERROR_NONE; int cnt = 0; - if(handle == NULL) { + if (handle == NULL) { __set_error_message(ERR_HANDLE, err_msg); return MEDIA_SVC_PLUGIN_ERROR; } ret = media_svc_check_subfolder_by_path(handle, storage_id, folder_path, &cnt); - if(ret < 0) { + if (ret < 0) { __set_error_message(ret, err_msg); return MEDIA_SVC_PLUGIN_ERROR; } @@ -1121,13 +1121,13 @@ int get_folder_id(void * handle, const char *storage_id, const char *path, char { 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_get_folder_id(handle, storage_id, path, folder_id); - 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 65f1d9b..ad53a03 100755 --- a/src/common/media-svc-album.c +++ b/src/common/media-svc-album.c @@ -99,7 +99,7 @@ int _media_svc_append_album(sqlite3 *handle, const char *album, const char *arti 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); diff --git a/src/common/media-svc-db-utils.c b/src/common/media-svc-db-utils.c index 3d61c64..37ccc6d 100755 --- a/src/common/media-svc-db-utils.c +++ b/src/common/media-svc-db-utils.c @@ -97,7 +97,7 @@ int __media_svc_add_table_info(const char *name, const char *triggerName, const if (STRING_VALID(triggerName)) { tbl->triggerName = malloc(MEDIA_SVC_PATHNAME_SIZE); - if(tbl->triggerName == NULL) { + if (tbl->triggerName == NULL) { media_svc_error("MS_MEDIA_ERR_OUT_OF_MEMORY"); SAFE_FREE(tbl); return MS_MEDIA_ERR_OUT_OF_MEMORY; @@ -289,7 +289,7 @@ int _media_svc_make_table_query(sqlite3 *db_handle, const char *table_name, medi int i = 0; tb = g_hash_table_lookup(table, table_name); - if(tb == NULL) { + if (tb == NULL) { media_svc_debug("lookup fail.. table name [%s] ", table_name); tb = g_hash_table_lookup(table, MEDIA_SVC_DB_TABLE_MEDIA); } @@ -305,7 +305,7 @@ int _media_svc_make_table_query(sqlite3 *db_handle, const char *table_name, medi col_ptr = g_slist_nth_data(column_list[list], i); /*create table */ if (col_ptr->hasOption) { - if(sflag == true) { + if (sflag == true) { snprintf(temp, sizeof(temp), ", %s %s %s", col_ptr->name, col_ptr->type, col_ptr->option); strncat(table_query, temp, strlen(temp)); } else { @@ -460,7 +460,7 @@ int _media_svc_make_table_query(sqlite3 *db_handle, const char *table_name, medi for (i = 1; i < len; i++) { col_ptr = g_slist_nth_data(column_list[MEDIA_SVC_DB_LIST_TAG], i); if (col_ptr->isView) { - if(sflag == true) { + if (sflag == true) { snprintf(temp, sizeof(temp), ", tag.%s", col_ptr->name); strncat(table_query, temp, strlen(temp)); } else { @@ -564,7 +564,7 @@ int _media_svc_init_table_query(const char *event_table_name) column_list[i] = g_slist_alloc(); } - /*table specification.. (table_name, index, unique set, trigger, view, trigger name, event table, action table, view name) */ + /*table specification.. (table_name, index, unique set, trigger, view, trigger name, event table, action table, view name) */ ret = __media_svc_add_table_info(MEDIA_SVC_DB_TABLE_MEDIA, NULL, NULL, NULL, MEDIA_SVC_DB_VIEW_MEDIA); ret = __media_svc_add_table_info(MEDIA_SVC_DB_TABLE_FOLDER, MEDIA_SVC_DB_TRIGGER_FOLDER, event_table_name, MEDIA_SVC_DB_TABLE_FOLDER, NULL); ret = __media_svc_add_table_info(MEDIA_SVC_DB_TABLE_PLAYLIST_MAP, MEDIA_SVC_DB_TRIGGER_PLAYLIST_MAP, event_table_name, MEDIA_SVC_DB_TABLE_PLAYLIST_MAP, NULL); @@ -669,7 +669,7 @@ int _media_svc_init_table_query(const char *event_table_name) ret = __media_svc_add_column_info(&column_list[MEDIA_SVC_DB_LIST_FOLDER], "name_pinyin", MEDIA_SVC_DB_TYPE_TEXT, NULL, USER_V2, NULL, false, false, false); ret = __media_svc_add_column_info(&column_list[MEDIA_SVC_DB_LIST_FOLDER], "storage_type", MEDIA_SVC_DB_TYPE_INT, NULL, USER_V2, NULL, false, false, false); /* storage_uuid column is added in DB v4. When doing DB upgrade to v4, if storage_uuid is NOT NULL, alter table failed. */ - ret = __media_svc_add_column_info(&column_list[MEDIA_SVC_DB_LIST_FOLDER], "storage_uuid", MEDIA_SVC_DB_TYPE_TEXT, NULL, USER_V4, NULL, true, false, false); + ret = __media_svc_add_column_info(&column_list[MEDIA_SVC_DB_LIST_FOLDER], "storage_uuid", MEDIA_SVC_DB_TYPE_TEXT, NULL, USER_V4, NULL, true, false, false); ret = __media_svc_add_column_info(&column_list[MEDIA_SVC_DB_LIST_FOLDER], "folder_order", MEDIA_SVC_DB_TYPE_INT, "DEFAULT 0", USER_V4, NULL, false, false, false); ret = __media_svc_add_column_info(&column_list[MEDIA_SVC_DB_LIST_FOLDER], "parent_folder_uuid", MEDIA_SVC_DB_TYPE_TEXT, NULL, USER_V4, NULL, false, false, false); ret = __media_svc_add_column_info(&column_list[MEDIA_SVC_DB_LIST_FOLDER], "validity", MEDIA_SVC_DB_TYPE_INT, "DEFAULT 1", USER_V4, NULL, false, false, false); @@ -886,7 +886,7 @@ static int __media_svc_db_upgrade(sqlite3 *db_handle, int cur_version, uid_t uid media_svc_retv_if(ret != MS_MEDIA_ERR_NONE, ret); /* Upgrade issue in folder table */ - if(cur_version < USER_V4) { + if (cur_version < USER_V4) { /* Create tmp table */ sql = sqlite3_mprintf("CREATE TABLE '%q' AS SELECT * FROM '%q';", MEDIA_SVC_DB_TABLE_TMP_TABLE, MEDIA_SVC_DB_TABLE_FOLDER); media_svc_retv_if(sql == NULL, MS_MEDIA_ERR_OUT_OF_MEMORY); @@ -957,15 +957,15 @@ static int __media_svc_db_upgrade(sqlite3 *db_handle, int cur_version, uid_t uid ret = _media_svc_upgrade_table_query(db_handle, MEDIA_SVC_DB_TABLE_STORAGE, MEDIA_SVC_DB_LIST_STORAGE, uid); media_svc_retv_if(ret != MS_MEDIA_ERR_NONE, ret); - if(cur_version < USER_V4) { + if (cur_version < USER_V4) { /* Need to default value in storage_uuid */ - sql = sqlite3_mprintf("UPDATE %q SET storage_uuid = '%q';",MEDIA_SVC_DB_TABLE_MEDIA, "media"); + sql = sqlite3_mprintf("UPDATE %q SET storage_uuid = '%q';",MEDIA_SVC_DB_TABLE_MEDIA, "media"); media_svc_retv_if(sql == NULL, MS_MEDIA_ERR_OUT_OF_MEMORY); ret = _media_svc_sql_query(db_handle, sql, uid); sqlite3_free(sql); - sql = sqlite3_mprintf("UPDATE %q SET storage_uuid = '%q';",MEDIA_SVC_DB_TABLE_FOLDER, "media"); + sql = sqlite3_mprintf("UPDATE %q SET storage_uuid = '%q';",MEDIA_SVC_DB_TABLE_FOLDER, "media"); media_svc_retv_if(sql == NULL, MS_MEDIA_ERR_OUT_OF_MEMORY); ret = _media_svc_sql_query(db_handle, sql, uid); @@ -1149,7 +1149,7 @@ int _media_svc_check_db_upgrade(sqlite3 *db_handle, bool *need_full_scan, uid_t SQLITE3_FINALIZE(sql_stmt); if (cur_version < LATEST_VERSION_NUMBER) { - if(cur_version < USER_V4) { + if (cur_version < USER_V4) { *need_full_scan = true; } media_svc_error("Current DB is out of date(%d).. So start to upgrade DB(%d)", cur_version, LATEST_VERSION_NUMBER); @@ -1242,7 +1242,7 @@ int _media_svc_update_media_view(sqlite3 *db_handle, uid_t uid) char view_query[4096] = {0, }; memset(view_query, 0x00, sizeof(view_query)); - snprintf(view_query, sizeof(view_query), "DROP VIEW IF EXISTS %s; CREATE VIEW IF NOT EXISTS %s AS SELECT * from %s ", MEDIA_SVC_DB_VIEW_MEDIA, MEDIA_SVC_DB_VIEW_MEDIA, MEDIA_SVC_DB_TABLE_MEDIA); + snprintf(view_query, sizeof(view_query), "DROP VIEW IF EXISTS %s; CREATE VIEW IF NOT EXISTS %s AS SELECT * from %s ", MEDIA_SVC_DB_VIEW_MEDIA, MEDIA_SVC_DB_VIEW_MEDIA, MEDIA_SVC_DB_TABLE_MEDIA); /*Select list of storage*/ sql = sqlite3_mprintf("SELECT storage_uuid FROM '%s' WHERE validity=1 AND storage_uuid != '%s'", MEDIA_SVC_DB_TABLE_STORAGE, MEDIA_SVC_DB_TABLE_MEDIA); diff --git a/src/common/media-svc-debug.c b/src/common/media-svc-debug.c index 997c4b3..21e482f 100755 --- a/src/common/media-svc-debug.c +++ b/src/common/media-svc-debug.c @@ -41,8 +41,7 @@ FILE *get_fp() void mediainfo_init_file_debug() { if (g_log_fp == NULL) { - snprintf(_g_file_path, sizeof(_g_file_path), "/tmp/%s", - "media-info"); + snprintf(_g_file_path, sizeof(_g_file_path), "/tmp/%s", "media-info"); if (access(_g_file_path, R_OK == 0)) { remove(_g_file_path); } @@ -88,24 +87,20 @@ void mediainfo_print_debug_time(char *time_string) double totaltime = 0.0; gettimeofday(&time, NULL); - totaltime = - (double)(time.tv_sec * 1000000 + time.tv_usec - - g_time_usec) / CLOCKS_PER_SEC; + totaltime = (double)(time.tv_sec * 1000000 + time.tv_usec - g_time_usec) / CLOCKS_PER_SEC; media_svc_debug("time [%s] : %f", time_string, totaltime); #endif } 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) { #ifdef _PERFORMANCE_CHECK_ double totaltime = 0.0; totaltime = (double)(end - start) / CLOCKS_PER_SEC; - media_svc_debug("time [%s: %s] : %f", func_name, time_string, - totaltime); + media_svc_debug("time [%s: %s] : %f", func_name, time_string, totaltime); #endif } diff --git a/src/common/media-svc-media-folder.c b/src/common/media-svc-media-folder.c index 1d238e6..faffabf 100755 --- a/src/common/media-svc-media-folder.c +++ b/src/common/media-svc-media-folder.c @@ -59,7 +59,7 @@ static int __media_svc_parent_is_ext_root_path(const char *folder_path, bool *is parent_folder_path = g_path_get_dirname(folder_path); - if(!STRING_VALID(parent_folder_path)) { + if (!STRING_VALID(parent_folder_path)) { media_svc_error("error : g_path_get_dirname falied"); SAFE_FREE(parent_folder_path); return MS_MEDIA_ERR_OUT_OF_MEMORY; @@ -84,7 +84,7 @@ int _media_svc_get_folder_id_by_foldername(sqlite3 *handle, const char *storage_ char *temp_parent_uuid = NULL; char *parent_folder_path = NULL; - sql = sqlite3_mprintf("SELECT folder_uuid, parent_folder_uuid FROM '%s' WHERE storage_uuid = '%q' AND path = '%q';", MEDIA_SVC_DB_TABLE_FOLDER, storage_id, folder_name); + sql = sqlite3_mprintf("SELECT folder_uuid, parent_folder_uuid FROM '%s' WHERE storage_uuid = '%q' AND path = '%q';", MEDIA_SVC_DB_TABLE_FOLDER, storage_id, folder_name); ret = _media_svc_sql_prepare_to_step(handle, sql, &sql_stmt); @@ -106,7 +106,7 @@ int _media_svc_get_folder_id_by_foldername(sqlite3 *handle, const char *storage_ SQLITE3_FINALIZE(sql_stmt); /*root path can be null*/ - if(!STRING_VALID(parent_folder_uuid)) { + if (!STRING_VALID(parent_folder_uuid)) { bool is_root = FALSE; ret = __media_svc_is_root_path(folder_name, &is_root, uid); @@ -118,28 +118,28 @@ int _media_svc_get_folder_id_by_foldername(sqlite3 *handle, const char *storage_ return MS_MEDIA_ERR_NONE; } - /* Notice : Below code is the code only for inserting parent folder uuid when upgrade the media db version 3 to 4 */ + /* Notice : Below code is the code only for inserting parent folder uuid when upgrade the media db version 3 to 4 */ /* Check parent folder uuid */ - if(!STRING_VALID(parent_folder_uuid)) { + if (!STRING_VALID(parent_folder_uuid)) { /* update parent_uuid */ media_svc_error("[No-Error] there is no parent folder uuid. PLEASE CHECK IT"); parent_folder_path = g_path_get_dirname(folder_name); - if(!STRING_VALID(parent_folder_path)) { + if (!STRING_VALID(parent_folder_path)) { media_svc_error("error : g_path_get_dirname falied."); return MS_MEDIA_ERR_OUT_OF_MEMORY; } - 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, parent_folder_path); + 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, parent_folder_path); else - sql = sqlite3_mprintf("SELECT folder_uuid FROM '%s' WHERE path = '%q';", MEDIA_SVC_DB_TABLE_FOLDER, parent_folder_path); + sql = sqlite3_mprintf("SELECT folder_uuid FROM '%s' WHERE path = '%q';", MEDIA_SVC_DB_TABLE_FOLDER, parent_folder_path); SAFE_FREE(parent_folder_path); ret = _media_svc_sql_prepare_to_step(handle, sql, &sql_stmt); if (ret == MS_MEDIA_ERR_NONE) { - temp_parent_uuid = (char *)sqlite3_column_text(sql_stmt, 0); + temp_parent_uuid = (char *)sqlite3_column_text(sql_stmt, 0); if (temp_parent_uuid != NULL) { _strncpy_safe(parent_folder_uuid, temp_parent_uuid, MEDIA_SVC_UUID_SIZE+1); } @@ -147,11 +147,11 @@ int _media_svc_get_folder_id_by_foldername(sqlite3 *handle, const char *storage_ SQLITE3_FINALIZE(sql_stmt); } - if(STRING_VALID(parent_folder_uuid)) { - if(STRING_VALID(storage_id)) - sql = sqlite3_mprintf("UPDATE %q SET parent_folder_uuid = '%q' WHERE storage_uuid = '%q' AND path = '%q';", MEDIA_SVC_DB_TABLE_FOLDER, parent_folder_uuid, storage_id, folder_name); + if (STRING_VALID(parent_folder_uuid)) { + if (STRING_VALID(storage_id)) + sql = sqlite3_mprintf("UPDATE %q SET parent_folder_uuid = '%q' WHERE storage_uuid = '%q' AND path = '%q';", MEDIA_SVC_DB_TABLE_FOLDER, parent_folder_uuid, storage_id, folder_name); else - sql = sqlite3_mprintf("UPDATE %q SET parent_folder_uuid = '%q' WHERE path = '%q';", MEDIA_SVC_DB_TABLE_FOLDER, parent_folder_uuid, folder_name); + sql = sqlite3_mprintf("UPDATE %q SET parent_folder_uuid = '%q' WHERE path = '%q';", MEDIA_SVC_DB_TABLE_FOLDER, parent_folder_uuid, folder_name); ret = _media_svc_sql_query(handle, sql, uid); sqlite3_free(sql); } else { @@ -163,7 +163,7 @@ int _media_svc_get_folder_id_by_foldername(sqlite3 *handle, const char *storage_ } static int __media_svc_append_folder(sqlite3 *handle, const char *storage_id, media_svc_storage_type_e storage_type, - const char *folder_id, const char *folder_path, const char *parent_folder_uuid, bool stack_query, uid_t uid) + const char *folder_id, const char *folder_path, const char *parent_folder_uuid, bool stack_query, uid_t uid) { int ret = MS_MEDIA_ERR_NONE; char *folder_name = NULL; @@ -179,9 +179,9 @@ static int __media_svc_append_folder(sqlite3 *handle, const char *storage_id, me 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, folder_path, folder_name, storage_id, storage_type, folder_modified_date, folder_name_pinyin, parent_folder_uuid); + MEDIA_SVC_DB_TABLE_FOLDER, folder_id, folder_path, folder_name, storage_id, storage_type, folder_modified_date, folder_name_pinyin, parent_folder_uuid); - if(!stack_query) + if (!stack_query) { ret = _media_svc_sql_query(handle, sql, uid); sqlite3_free(sql); @@ -287,7 +287,7 @@ static int __media_svc_get_and_append_parent_folder(sqlite3 *handle, const char SAFE_FREE(dir_path); } - if(STRING_VALID(folder_uuid)) { + if (STRING_VALID(folder_uuid)) { _strncpy_safe(folder_id, folder_uuid, MEDIA_SVC_UUID_SIZE + 1); } else { media_svc_error("Fail to get folder_uuid"); @@ -317,7 +317,7 @@ int _media_svc_get_and_append_folder_id_by_path(sqlite3 *handle, const char *sto dir_path = g_path_get_dirname(path); - ret = _media_svc_get_and_append_folder(handle, storage_id, dir_path, storage_type, folder_id, uid); + ret = _media_svc_get_and_append_folder(handle, storage_id, dir_path, storage_type, folder_id, uid); SAFE_FREE(dir_path); @@ -330,7 +330,7 @@ int _media_svc_update_folder_table(sqlite3 *handle, const char *storage_id, 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, storage_id); + MEDIA_SVC_DB_TABLE_FOLDER, MEDIA_SVC_DB_TABLE_FOLDER, storage_id); ret = _media_svc_sql_query(handle, sql, uid); sqlite3_free(sql); @@ -367,7 +367,7 @@ int _media_svc_get_all_folders(sqlite3 *handle, char *start_path, char ***folder char **folder_uuid = NULL; int i = 0; - ret = __media_svc_count_all_folders(handle, start_path, &cnt); + ret = __media_svc_count_all_folders(handle, start_path, &cnt); if (ret != MS_MEDIA_ERR_NONE) { media_svc_error("error when __media_svc_count_all_folders. err = [%d]", ret); return ret; @@ -443,7 +443,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); @@ -453,7 +453,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]); } @@ -553,7 +553,7 @@ int _media_svc_get_and_append_folder_id_by_folder_path(sqlite3 *handle, const ch } else { sql = sqlite3_mprintf("UPDATE '%s' SET validity=1 WHERE storage_uuid = '%q' AND path = '%q'", MEDIA_SVC_DB_TABLE_FOLDER, storage_id, path); - if(!stack_query) + if (!stack_query) { ret = _media_svc_sql_query(handle, sql, uid); sqlite3_free(sql); @@ -657,7 +657,7 @@ int _media_svc_delete_invalid_folder_by_path(sqlite3 *handle, const char *storag return ret; } -int _media_svc_count_folder_with_path(sqlite3 *handle, const char *storage_id, const char *path, int *count) +int _media_svc_count_folder_with_path(sqlite3 *handle, const char *storage_id, const char *path, int *count) { int ret = MS_MEDIA_ERR_NONE; sqlite3_stmt *sql_stmt = NULL; @@ -675,7 +675,7 @@ int _media_svc_count_folder_with_path(sqlite3 *handle, const char *storage_id, return MS_MEDIA_ERR_NONE; } -int _media_svc_count_subfolder_with_path(sqlite3 *handle, const char *storage_id, const char *path, int *count) +int _media_svc_count_subfolder_with_path(sqlite3 *handle, const char *storage_id, const char *path, int *count) { int ret = MS_MEDIA_ERR_NONE; sqlite3_stmt *sql_stmt = NULL; @@ -709,7 +709,7 @@ int _media_svc_get_folder_uuid(sqlite3 *handle, const char *storage_id, const ch SQLITE3_FINALIZE(sql_stmt); - if(!STRING_VALID(folder_id)) + if (!STRING_VALID(folder_id)) { media_svc_error("Not found valid storage id [%s]", path); ret = MS_MEDIA_ERR_INVALID_PARAMETER; diff --git a/src/common/media-svc-media.c b/src/common/media-svc-media.c index be41aa0..9fcb6cf 100755 --- a/src/common/media-svc-media.c +++ b/src/common/media-svc-media.c @@ -42,8 +42,7 @@ __thread GList *g_media_svc_move_item_query_list = NULL; static __thread GList *g_media_svc_update_item_query_list = NULL; static int __media_svc_count_invalid_records_with_thumbnail(sqlite3 *handle, const char *storage_id, media_svc_storage_type_e storage_type, int *count); -static int __media_svc_get_invalid_records_with_thumbnail(sqlite3 *handle, const char *storage_id, media_svc_storage_type_e storage_type, - int count, media_svc_thumbnailpath_s *thumb_path); +static int __media_svc_get_invalid_records_with_thumbnail(sqlite3 *handle, const char *storage_id, media_svc_storage_type_e storage_type, int count, media_svc_thumbnailpath_s *thumb_path); static int __media_svc_count_invalid_folder_records_with_thumbnail(sqlite3 *handle, const char *storage_id, const char *folder_path, const char *folder_uuid, bool is_recursive, int *count); static int __media_svc_get_invalid_folder_records_with_thumbnail(sqlite3 *handle, const char *storage_id, const char *folder_path, const char *folder_uuid, bool is_recursive, int count, media_svc_thumbnailpath_s *thumb_path); @@ -134,9 +133,9 @@ static int __media_svc_get_invalid_folder_records_with_thumbnail(sqlite3 *handle char *sql = NULL; if (is_recursive) { - 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", storage_id, folder_path); + 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", storage_id, folder_path); } else { - sql = sqlite3_mprintf("SELECT thumbnail_path from (select thumbnail_path, validity from '%s' WHERE folder_uuid = '%q' AND thumbnail_path IS NOT NULL GROUP BY thumbnail_path HAVING count() = 1) WHERE validity=0", storage_id, folder_uuid); + sql = sqlite3_mprintf("SELECT thumbnail_path from (select thumbnail_path, validity from '%s' WHERE folder_uuid = '%q' AND thumbnail_path IS NOT NULL GROUP BY thumbnail_path HAVING count() = 1) WHERE validity=0", storage_id, folder_uuid); } media_svc_debug("[SQL query] : %s", sql); @@ -157,7 +156,7 @@ static int __media_svc_get_invalid_folder_records_with_thumbnail(sqlite3 *handle return MS_MEDIA_ERR_NONE; } -int _media_svc_count_record_with_path(sqlite3 *handle, const char *storage_id, const char *path, int *count) +int _media_svc_count_record_with_path(sqlite3 *handle, const char *storage_id, const char *path, int *count) { int ret = MS_MEDIA_ERR_NONE; sqlite3_stmt *sql_stmt = NULL; @@ -241,7 +240,7 @@ int _media_svc_insert_item_with_data(sqlite3 *handle, const char *storage_id, me } /* Get thumbnail for burst shot */ - if(ini_val == 1) { + if (ini_val == 1) { char thumb_path[MEDIA_SVC_PATHNAME_SIZE + 1] = {0, }; int width = 0; int height = 0; @@ -356,7 +355,7 @@ int _media_svc_insert_item_with_data(sqlite3 *handle, const char *storage_id, me content_info->media_meta.copyright_pinyin, content_info->media_meta.description_pinyin, content_info->storage_uuid - ); + ); if (burst_id) { sqlite3_free(burst_id); @@ -431,7 +430,7 @@ int _media_svc_update_meta_with_data(sqlite3 *handle, media_svc_content_info_s * content_info->media_meta.copyright_pinyin, content_info->media_meta.description_pinyin, content_info->path - ); + ); if (sql != NULL) { media_svc_debug("query : %s", sql); @@ -513,7 +512,7 @@ int _media_svc_update_item_with_data(sqlite3 *handle, const char *storage_id, me content_info->media_meta.datetaken, content_info->media_meta.orientation, content_info->path - ); + ); ret = _media_svc_sql_query(handle, sql, uid); sqlite3_free(sql); @@ -856,7 +855,7 @@ int _media_svc_list_query_do(sqlite3 *handle, media_svc_query_type_e query_type, else if (query_type == MEDIA_SVC_QUERY_UPDATE_ITEM) ret = _media_svc_sql_query_list(handle, &g_media_svc_update_item_query_list, uid); else if (query_type == MEDIA_SVC_QUERY_INSERT_FOLDER) - ret = _media_svc_sql_query_list(handle, _media_svc_get_folder_list_ptr(), uid); + ret = _media_svc_sql_query_list(handle, _media_svc_get_folder_list_ptr(), uid); else ret = MS_MEDIA_ERR_INVALID_PARAMETER; @@ -1043,7 +1042,7 @@ int _media_svc_insert_item_pass1(sqlite3 *handle, const char *storage_id, media_ int height = 0; ret = _media_svc_request_thumbnail_with_origin_size(content_info->path, thumb_path, sizeof(thumb_path), &width, &height); - 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) { content_info->thumbnail_path = NULL; @@ -1058,9 +1057,9 @@ int _media_svc_insert_item_pass1(sqlite3 *handle, const char *storage_id, media_ } /* Update Pinyin If Support Pinyin */ - if(_media_svc_check_pinyin_support()) + if (_media_svc_check_pinyin_support()) { - if(STRING_VALID(content_info->file_name)) + if (STRING_VALID(content_info->file_name)) _media_svc_get_pinyin_str(content_info->file_name, &content_info->file_name_pinyin); } #endif @@ -1092,7 +1091,7 @@ int _media_svc_insert_item_pass1(sqlite3 *handle, const char *storage_id, media_ #endif media_svc_debug("MAKE PASS 1 QUERY END"); - if(!stack_query) { + if (!stack_query) { ret = _media_svc_sql_query(handle, sql, uid); sqlite3_free(sql); if (ret != MS_MEDIA_ERR_NONE) { @@ -1115,25 +1114,25 @@ int _media_svc_insert_item_pass2(sqlite3 *handle, const char *storage_id, media_ media_svc_debug_fenter(); /*Update Pinyin If Support Pinyin*/ - if(_media_svc_check_pinyin_support()) + if (_media_svc_check_pinyin_support()) { - if(STRING_VALID(content_info->file_name)) + 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); } @@ -1189,7 +1188,7 @@ int _media_svc_insert_item_pass2(sqlite3 *handle, const char *storage_id, media_ content_info->path ); - if(!stack_query) { + if (!stack_query) { ret = _media_svc_sql_query(handle, sql, uid); sqlite3_free(sql); if (ret != MS_MEDIA_ERR_NONE) { diff --git a/src/common/media-svc-noti.c b/src/common/media-svc-noti.c index 914c07e..98ac82b 100755 --- a/src/common/media-svc-noti.c +++ b/src/common/media-svc-noti.c @@ -49,12 +49,12 @@ 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; @@ -85,21 +85,15 @@ int _media_svc_publish_dir_noti(media_item_type_e update_item, { int ret = MS_MEDIA_ERR_NONE; - if(STRING_VALID(path)) - { + if (STRING_VALID(path)) { ret = media_db_update_send(pid, 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; } @@ -107,7 +101,6 @@ int _media_svc_publish_dir_noti(media_item_type_e update_item, return ret; } - int _media_svc_publish_dir_noti_v2(media_item_type_e update_item, media_item_update_type_e update_type, const char *path, @@ -119,21 +112,15 @@ int _media_svc_publish_dir_noti_v2(media_item_type_e update_item, { int ret = MS_MEDIA_ERR_NONE; - if(STRING_VALID(path)) - { + if (STRING_VALID(path)) { ret = media_db_update_send_internal(pid, 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; } diff --git a/src/common/media-svc-storage.c b/src/common/media-svc-storage.c index 33ab91e..d258308 100755 --- a/src/common/media-svc-storage.c +++ b/src/common/media-svc-storage.c @@ -44,7 +44,7 @@ int _media_svc_init_storage(sqlite3 *handle, uid_t uid) if (storage_cnt == 0) { char *internal_path = _media_svc_get_path(uid); sql = sqlite3_mprintf("INSERT INTO %s (storage_uuid, storage_name, storage_path, storage_type) VALUES ('%s', '%s', '%s', 0);", - MEDIA_SVC_DB_TABLE_STORAGE, MEDIA_SVC_DB_TABLE_MEDIA, MEDIA_SVC_DB_TABLE_MEDIA, internal_path); + MEDIA_SVC_DB_TABLE_STORAGE, MEDIA_SVC_DB_TABLE_MEDIA, MEDIA_SVC_DB_TABLE_MEDIA, internal_path); ret = _media_svc_sql_query(handle, sql, uid); sqlite3_free(sql); @@ -97,7 +97,7 @@ int _media_svc_check_storage(sqlite3 *handle, const char *storage_id, const char *storage_path = NULL; *validity = 0; - if(storage_name != NULL) + if (storage_name != NULL) sql = sqlite3_mprintf("SELECT * FROM '%s' WHERE storage_uuid=%Q AND storage_name=%Q", MEDIA_SVC_DB_TABLE_STORAGE, storage_id, storage_name); else sql = sqlite3_mprintf("SELECT * FROM '%s' WHERE storage_uuid=%Q", MEDIA_SVC_DB_TABLE_STORAGE, storage_id); @@ -118,7 +118,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); @@ -200,7 +200,7 @@ int _media_svc_get_storage_uuid(sqlite3 *handle, const char *path, char *storage char *remain_path = NULL; int remain_len = 0; - if(strncmp(path, MEDIA_ROOT_PATH_INTERNAL, strlen(MEDIA_ROOT_PATH_INTERNAL)) == 0) + if (strncmp(path, MEDIA_ROOT_PATH_INTERNAL, strlen(MEDIA_ROOT_PATH_INTERNAL)) == 0) { _strncpy_safe(storage_id, MEDIA_SVC_DB_TABLE_MEDIA, MEDIA_SVC_UUID_SIZE+1); return MS_MEDIA_ERR_NONE; @@ -220,11 +220,11 @@ int _media_svc_get_storage_uuid(sqlite3 *handle, const char *path, char *storage while(sqlite3_step(sql_stmt) == SQLITE_ROW) { - if(STRING_VALID((const char *)sqlite3_column_text(sql_stmt, 1))) + if (STRING_VALID((const char *)sqlite3_column_text(sql_stmt, 1))) { - if (strlen(storage_path) == strlen((const char *)sqlite3_column_text(sql_stmt, 1))) + if (strlen(storage_path) == strlen((const char *)sqlite3_column_text(sql_stmt, 1))) { - if(strncmp(storage_path, (const char *)sqlite3_column_text(sql_stmt, 1), strlen(storage_path)) == 0) + if (strncmp(storage_path, (const char *)sqlite3_column_text(sql_stmt, 1), strlen(storage_path)) == 0) { _strncpy_safe(storage_id, (const char *)sqlite3_column_text(sql_stmt, 0), MEDIA_SVC_UUID_SIZE+1); break; @@ -237,7 +237,7 @@ int _media_svc_get_storage_uuid(sqlite3 *handle, const char *path, char *storage SQLITE3_FINALIZE(sql_stmt); SAFE_FREE(storage_path); - if(!STRING_VALID(storage_id)) + if (!STRING_VALID(storage_id)) { media_svc_error("Not found valid storage id [%s]", path); ret = MS_MEDIA_ERR_INVALID_PARAMETER; @@ -252,7 +252,7 @@ int _media_svc_get_storage_type(sqlite3 *handle, const char *storage_id, media_s sqlite3_stmt *sql_stmt = NULL; char *sql = NULL; - if(!STRING_VALID(storage_id)) + if (!STRING_VALID(storage_id)) { media_svc_error("Invalid storage_idid"); ret = MS_MEDIA_ERR_INVALID_PARAMETER; @@ -263,7 +263,7 @@ int _media_svc_get_storage_type(sqlite3 *handle, const char *storage_id, media_s 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 storage."); } else { @@ -285,7 +285,7 @@ int _media_svc_get_storage_path(sqlite3 *handle, const char *storage_id, char ** sqlite3_stmt *sql_stmt = NULL; char *sql = NULL; - if(!STRING_VALID(storage_id)) + if (!STRING_VALID(storage_id)) { media_svc_error("Invalid storage_idid"); ret = MS_MEDIA_ERR_INVALID_PARAMETER; @@ -296,7 +296,7 @@ int _media_svc_get_storage_path(sqlite3 *handle, const char *storage_id, 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 storage."); } else { @@ -318,7 +318,7 @@ int _media_svc_get_storage_scan_status(sqlite3 *handle, const char *storage_id, sqlite3_stmt *sql_stmt = NULL; char *sql = NULL; - if(!STRING_VALID(storage_id)) + if (!STRING_VALID(storage_id)) { media_svc_error("Invalid storage_id"); return MS_MEDIA_ERR_INVALID_PARAMETER; @@ -329,7 +329,7 @@ int _media_svc_get_storage_scan_status(sqlite3 *handle, const char *storage_id, 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 storage."); } else { @@ -389,7 +389,7 @@ int _media_svc_get_all_storage(sqlite3 *handle, char ***storage_list, char ***st char *sql = NULL; int cnt =0; - ret = __media_svc_count_all_storage(handle, &cnt); + ret = __media_svc_count_all_storage(handle, &cnt); if (ret != MS_MEDIA_ERR_NONE) { media_svc_error("error when __media_svc_count_all_folders. err = [%d]", ret); return ret; @@ -421,7 +421,7 @@ int _media_svc_get_all_storage(sqlite3 *handle, char ***storage_list, char ***st (*storage_list)[idx] = g_strdup((char *)sqlite3_column_text(sql_stmt, 0)); (*storage_id_list)[idx] = g_strdup((char *)sqlite3_column_text(sql_stmt, 1)); (*scan_status_list)[idx] = (int)sqlite3_column_int(sql_stmt, 2); - if(sqlite3_step(sql_stmt) != SQLITE_ROW) + if (sqlite3_step(sql_stmt) != SQLITE_ROW) break; idx++; } @@ -432,7 +432,7 @@ int _media_svc_get_all_storage(sqlite3 *handle, char ***storage_list, char ***st } else { /* free all data */ int i =0; - for (i = 0; i < idx; i ++) { + for (i = 0; i < idx; i ++) { SAFE_FREE((*storage_list)[i]); SAFE_FREE((*storage_id_list)[i]); } diff --git a/src/common/media-svc-util.c b/src/common/media-svc-util.c index be3f01f..2917497 100755 --- a/src/common/media-svc-util.c +++ b/src/common/media-svc-util.c @@ -50,7 +50,7 @@ #include "media-svc-localize_ch.h" #include "media-svc-localize_tw.h" -#define MEDIA_SVC_FILE_EXT_LEN_MAX 6 /**< Maximum file ext lenth*/ +#define MEDIA_SVC_FILE_EXT_LEN_MAX 6 /**< Maximum file ext lenth*/ /* Define data structures for media type and mime type */ #define MEDIA_SVC_CATEGORY_UNKNOWN 0x00000000 /**< Default */ @@ -102,7 +102,7 @@ static const char music_mime_table[MUSIC_MIME_NUM][MIME_LENGTH] = { "x-mp3", /*alias of audio/mpeg*/ "x-mpeg", /*alias of audio/mpeg*/ "3gpp", - "x-ogg", /*alias of audio/ogg*/ + "x-ogg", /*alias of audio/ogg*/ "vnd.ms-playready.media.pya:*.pya", /*playready*/ "wma", "aac", @@ -260,12 +260,7 @@ static int __media_svc_split_to_double(char *input, double *arr) return MS_MEDIA_ERR_NONE; } -static int __media_svc_get_exif_info(ExifData *ed, - char *buf, - int *i_value, - double *d_value, - int ifdtype, - long tagtype) +static int __media_svc_get_exif_info(ExifData *ed, char *buf, int *i_value, double *d_value, int ifdtype, long tagtype) { ExifEntry *entry; ExifTag tag; @@ -281,9 +276,9 @@ 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_ISO_SPEED_RATINGS) { + tag == EXIF_TAG_PIXEL_X_DIMENSION || + tag == EXIF_TAG_PIXEL_Y_DIMENSION || + tag == EXIF_TAG_ISO_SPEED_RATINGS) { if (i_value == NULL) { media_svc_error("i_value is NULL"); @@ -316,7 +311,7 @@ static int __media_svc_get_exif_info(ExifData *ed, *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]); */ - } else if (tag == EXIF_TAG_EXPOSURE_TIME) { + } else if (tag == EXIF_TAG_EXPOSURE_TIME) { if (buf == NULL) { media_svc_error("buf is NULL"); @@ -612,7 +607,7 @@ static int _media_svc_save_image(void *image, int size, char *image_path, uid_t struct statfs fs; char *thumb_path = __media_svc_get_thumb_path(uid); - if(!STRING_VALID(thumb_path)) { + if (!STRING_VALID(thumb_path)) { media_svc_error("fail to get thumb_path"); return MS_MEDIA_ERR_INTERNAL; } @@ -1008,7 +1003,7 @@ int _media_svc_set_default_value(media_svc_content_info_s *content_info, bool re ret = __media_svc_malloc_and_strncpy(&content_info->media_meta.year, MEDIA_SVC_TAG_UNKNOWN); media_svc_retv_del_if(ret != MS_MEDIA_ERR_NONE, ret, content_info); - if(refresh) { + if (refresh) { media_svc_debug("refresh"); return MS_MEDIA_ERR_NONE; } @@ -1023,7 +1018,7 @@ int _media_svc_set_default_value(media_svc_content_info_s *content_info, bool re } 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; @@ -1034,7 +1029,7 @@ int _media_svc_set_media_info(media_svc_content_info_s *content_info, const char ret = __media_svc_malloc_and_strncpy(&content_info->path, path); media_svc_retv_del_if(ret != MS_MEDIA_ERR_NONE, ret, content_info); - if(storage_type != MEDIA_SVC_STORAGE_CLOUD) { + if (storage_type != MEDIA_SVC_STORAGE_CLOUD) { struct stat st; memset(&st, 0, sizeof(struct stat)); if (stat(path, &st) == 0) { @@ -1075,7 +1070,7 @@ int _media_svc_set_media_info(media_svc_content_info_s *content_info, const char SAFE_FREE(file_name); media_svc_retv_del_if(ret != MS_MEDIA_ERR_NONE, ret, content_info); - if(storage_type != MEDIA_SVC_STORAGE_CLOUD) { + if (storage_type != MEDIA_SVC_STORAGE_CLOUD) { /* if the file is DRM file, drm_type value is DRM_TRUE(1). if drm_contentinfo is not NULL, the file is OMA DRM.*/ ret = __media_svc_get_mime_type(path, mime_type); @@ -1201,7 +1196,7 @@ 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 { ret = __media_svc_malloc_and_strncpy_with_size(&content_info->media_meta.datetaken, buf, datetaken_size); if (ret != MS_MEDIA_ERR_NONE) { @@ -1220,7 +1215,7 @@ 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 { ret = __media_svc_malloc_and_strncpy_with_size(&content_info->media_meta.datetaken, buf, datetaken_size); if (ret != MS_MEDIA_ERR_NONE) { @@ -1325,7 +1320,7 @@ int _media_svc_extract_image_metadata(sqlite3 *handle, media_svc_content_info_s GET_WIDTH_HEIGHT: - if(content_info->media_meta.width == 0 || + if (content_info->media_meta.width == 0 || content_info->media_meta.height == 0) { /*Get image width, height*/ unsigned int img_width = 0; @@ -1334,10 +1329,10 @@ GET_WIDTH_HEIGHT: ret = ImgGetImageInfo(path, &img_type, &img_width, &img_height); - if(content_info->media_meta.width == 0) + if (content_info->media_meta.width == 0) content_info->media_meta.width = img_width; - if(content_info->media_meta.height == 0) + if (content_info->media_meta.height == 0) content_info->media_meta.height = img_height; } @@ -1509,7 +1504,7 @@ int _media_svc_extract_music_metadata_for_update(sqlite3 *handle, media_svc_cont no_tag_title = _media_svc_get_title_from_filepath(content_info->path); if (no_tag_title) { ret = __media_svc_malloc_and_strncpy(&content_info->media_meta.title, no_tag_title); - if(ret != MS_MEDIA_ERR_NONE) + if (ret != MS_MEDIA_ERR_NONE) media_svc_error("strcpy error"); SAFE_FREE(no_tag_title); } else { @@ -1779,7 +1774,7 @@ int _media_svc_extract_media_metadata(sqlite3 *handle, media_svc_content_info_s 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)))) { + (!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; @@ -1839,7 +1834,7 @@ int _media_svc_extract_media_metadata(sqlite3 *handle, media_svc_content_info_s 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)))) + (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); @@ -1878,7 +1873,7 @@ int _media_svc_extract_media_metadata(sqlite3 *handle, media_svc_content_info_s no_tag_title = _media_svc_get_title_from_filepath(content_info->path); if (no_tag_title) { ret = __media_svc_malloc_and_strncpy(&content_info->media_meta.title, no_tag_title); - if(ret != MS_MEDIA_ERR_NONE) + if (ret != MS_MEDIA_ERR_NONE) media_svc_error("strcpy error"); SAFE_FREE(no_tag_title); } else { @@ -2094,7 +2089,7 @@ char *_media_svc_replace_path(char *s, const char *olds, const char *news) if (memcmp(s, olds, oldlen) == 0) { memcpy(sr, news, newlen); sr += newlen; - s += oldlen; + s += oldlen; } else *sr++ = *s++; } @@ -2139,7 +2134,7 @@ int _media_svc_get_pinyin_str(const char *src_str, char **pinyin_str) 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 (STRING_VALID(pinyinname[0].pinyin_name)) *pinyin_str = strdup(pinyinname[0].pinyin_name); else *pinyin_str = strdup(src_str); //Return Original Non China Character @@ -2158,11 +2153,11 @@ bool _media_svc_check_pinyin_support(void) int _media_svc_get_ini_value() { - if(g_ini_value == -1) { + if (g_ini_value == -1) { dictionary *dict = NULL; dict = iniparser_load(MEDIA_SVC_INI_DEFAULT_PATH); - if(!dict) { + if (!dict) { media_svc_error("%s load failed", MEDIA_SVC_INI_DEFAULT_PATH); return -1; } diff --git a/src/common/media-svc.c b/src/common/media-svc.c index 28de952..4b378e8 100755 --- a/src/common/media-svc.c +++ b/src/common/media-svc.c @@ -233,8 +233,8 @@ int media_svc_insert_item_begin(MediaSvcHandle *handle, int data_cnt, int with_n media_svc_retvm_if(db_handle == NULL, MS_MEDIA_ERR_INVALID_PARAMETER, "Handle is NULL"); media_svc_retvm_if(data_cnt < 1, MS_MEDIA_ERR_INVALID_PARAMETER, "data_cnt shuld be bigger than 1"); - g_media_svc_insert_item_data_cnt = data_cnt; - g_media_svc_insert_item_cur_data_cnt = 0; + g_media_svc_insert_item_data_cnt = data_cnt; + g_media_svc_insert_item_cur_data_cnt = 0; /* Prepare for making noti item list */ if (with_noti) { @@ -259,7 +259,7 @@ int media_svc_insert_item_end(MediaSvcHandle *handle, uid_t uid) media_svc_retvm_if(db_handle == NULL, MS_MEDIA_ERR_INVALID_PARAMETER, "Handle is NULL"); - if (g_media_svc_insert_item_cur_data_cnt > 0) { + if (g_media_svc_insert_item_cur_data_cnt > 0) { ret = _media_svc_list_query_do(db_handle, MEDIA_SVC_QUERY_INSERT_ITEM, uid); if (g_insert_with_noti) { @@ -271,8 +271,8 @@ int media_svc_insert_item_end(MediaSvcHandle *handle, uid_t uid) } } - g_media_svc_insert_item_data_cnt = 1; - g_media_svc_insert_item_cur_data_cnt = 0; + g_media_svc_insert_item_data_cnt = 1; + g_media_svc_insert_item_cur_data_cnt = 0; return ret; } @@ -323,7 +323,7 @@ int media_svc_insert_item_bulk(MediaSvcHandle *handle, const char *storage_id, m 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, storage_id, &content_info, is_burst, TRUE, uid); media_svc_retv_del_if(ret != MS_MEDIA_ERR_NONE, ret, &content_info); @@ -333,7 +333,7 @@ int media_svc_insert_item_bulk(MediaSvcHandle *handle, const char *storage_id, m 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, storage_id, &content_info, is_burst, TRUE, uid); media_svc_retv_del_if(ret != MS_MEDIA_ERR_NONE, ret, &content_info); @@ -530,7 +530,7 @@ int media_svc_move_item(MediaSvcHandle *handle, const char *storage_id, media_sv ret = _media_svc_update_folder_table(db_handle, storage_id, uid); media_svc_retv_if(ret != MS_MEDIA_ERR_NONE, ret); - } else if (g_media_svc_move_item_cur_data_cnt < (g_media_svc_move_item_data_cnt - 1)) { + } 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)) { @@ -549,7 +549,7 @@ int media_svc_move_item(MediaSvcHandle *handle, const char *storage_id, media_sv 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)) { + } 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)) { @@ -598,8 +598,8 @@ int media_svc_set_item_validity_begin(MediaSvcHandle *handle, int data_cnt) media_svc_retvm_if(db_handle == NULL, MS_MEDIA_ERR_INVALID_PARAMETER, "Handle is NULL"); media_svc_retvm_if(data_cnt < 1, MS_MEDIA_ERR_INVALID_PARAMETER, "data_cnt shuld be bigger than 1"); - g_media_svc_item_validity_data_cnt = data_cnt; - g_media_svc_item_validity_cur_data_cnt = 0; + g_media_svc_item_validity_data_cnt = data_cnt; + g_media_svc_item_validity_cur_data_cnt = 0; return MS_MEDIA_ERR_NONE; } @@ -613,13 +613,13 @@ int media_svc_set_item_validity_end(MediaSvcHandle *handle, uid_t uid) media_svc_retvm_if(db_handle == NULL, MS_MEDIA_ERR_INVALID_PARAMETER, "Handle is NULL"); - if (g_media_svc_item_validity_cur_data_cnt > 0) { + if (g_media_svc_item_validity_cur_data_cnt > 0) { ret = _media_svc_list_query_do(db_handle, MEDIA_SVC_QUERY_SET_ITEM_VALIDITY, uid); } - g_media_svc_item_validity_data_cnt = 1; - g_media_svc_item_validity_cur_data_cnt = 0; + g_media_svc_item_validity_data_cnt = 1; + g_media_svc_item_validity_cur_data_cnt = 0; return ret; } @@ -635,18 +635,18 @@ int media_svc_set_item_validity(MediaSvcHandle *handle, const char *storage_id, media_svc_debug("path=[%s], validity=[%d]", path, validity); - if (g_media_svc_item_validity_data_cnt == 1) { + if (g_media_svc_item_validity_data_cnt == 1) { return _media_svc_update_item_validity(db_handle, storage_id, path, validity, FALSE, uid); - } else if (g_media_svc_item_validity_cur_data_cnt < (g_media_svc_item_validity_data_cnt - 1)) { + } else if (g_media_svc_item_validity_cur_data_cnt < (g_media_svc_item_validity_data_cnt - 1)) { ret = _media_svc_update_item_validity(db_handle, storage_id, path, validity, TRUE, uid); media_svc_retv_if(ret != MS_MEDIA_ERR_NONE, ret); g_media_svc_item_validity_cur_data_cnt++; - } else if (g_media_svc_item_validity_cur_data_cnt == (g_media_svc_item_validity_data_cnt - 1)) { + } else if (g_media_svc_item_validity_cur_data_cnt == (g_media_svc_item_validity_data_cnt - 1)) { ret = _media_svc_update_item_validity(db_handle, storage_id, path, validity, TRUE, uid); media_svc_retv_if(ret != MS_MEDIA_ERR_NONE, ret); @@ -654,7 +654,7 @@ int media_svc_set_item_validity(MediaSvcHandle *handle, const char *storage_id, ret = _media_svc_list_query_do(db_handle, MEDIA_SVC_QUERY_SET_ITEM_VALIDITY, uid); media_svc_retv_if(ret != MS_MEDIA_ERR_NONE, ret); - g_media_svc_item_validity_cur_data_cnt = 0; + g_media_svc_item_validity_cur_data_cnt = 0; } else { @@ -747,7 +747,7 @@ int media_svc_delete_item_by_path(MediaSvcHandle *handle, const char *storage_id if (thumb_count == 1) { */ 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."); } // } @@ -862,7 +862,7 @@ int media_svc_refresh_item(MediaSvcHandle *handle, const char *storage_id, media } /* Initialize thumbnail information to remake thumbnail. */ - if(ini_val == 1) { + if (ini_val == 1) { char thumb_path[MEDIA_SVC_PATHNAME_SIZE + 1]; ret = _media_svc_get_thumbnail_path_by_path(db_handle, storage_id, path, thumb_path); if (ret != MS_MEDIA_ERR_NONE) { @@ -877,7 +877,7 @@ int media_svc_refresh_item(MediaSvcHandle *handle, const char *storage_id, media } } - ret = _media_svc_update_thumbnail_path(db_handle, storage_id, path, NULL, uid); + ret = _media_svc_update_thumbnail_path(db_handle, storage_id, path, NULL, uid); if (ret != MS_MEDIA_ERR_NONE) { _media_svc_destroy_content_info(&content_info); return ret; @@ -910,7 +910,7 @@ int media_svc_refresh_item(MediaSvcHandle *handle, const char *storage_id, media } #if 1 /* Extracting thumbnail */ - if(ini_val == 1) { + if (ini_val == 1) { if (content_info.thumbnail_path == NULL) { if (media_type == MEDIA_SVC_MEDIA_TYPE_IMAGE || media_type == MEDIA_SVC_MEDIA_TYPE_VIDEO) { char thumb_path[MEDIA_SVC_PATHNAME_SIZE + 1] = {0, }; @@ -957,7 +957,7 @@ int media_svc_rename_folder(MediaSvcHandle *handle, const char *storage_id, cons media_svc_retvm_if(src_path == NULL, MS_MEDIA_ERR_INVALID_PARAMETER, "src_path is NULL"); media_svc_retvm_if(dst_path == NULL, MS_MEDIA_ERR_INVALID_PARAMETER, "dst_path is NULL"); - media_svc_debug("Src path : %s, Dst Path : %s", src_path, dst_path); + media_svc_debug("Src path : %s, Dst Path : %s", src_path, dst_path); ret = _media_svc_sql_begin_trans(db_handle, uid); media_svc_retv_if(ret != MS_MEDIA_ERR_NONE, ret); @@ -1225,7 +1225,7 @@ int media_svc_update_folder_time(MediaSvcHandle *handle, const char *storage_id, int ret = MS_MEDIA_ERR_NONE; sqlite3 *db_handle = (sqlite3 *)handle; time_t sto_time = 0; - int cur_time = _media_svc_get_file_time(folder_path); + int cur_time = _media_svc_get_file_time(folder_path); char folder_uuid[MEDIA_SVC_UUID_SIZE + 1] = {0, }; media_svc_retvm_if(db_handle == NULL, MS_MEDIA_ERR_INVALID_PARAMETER, "Handle is NULL"); @@ -1249,8 +1249,8 @@ int media_svc_update_item_begin(MediaSvcHandle *handle, int data_cnt) media_svc_retvm_if(db_handle == NULL, MS_MEDIA_ERR_INVALID_PARAMETER, "Handle is NULL"); media_svc_retvm_if(data_cnt < 1, MS_MEDIA_ERR_INVALID_PARAMETER, "data_cnt shuld be bigger than 1"); - g_media_svc_update_item_data_cnt = data_cnt; - g_media_svc_update_item_cur_data_cnt = 0; + g_media_svc_update_item_data_cnt = data_cnt; + g_media_svc_update_item_cur_data_cnt = 0; return MS_MEDIA_ERR_NONE; } @@ -1264,13 +1264,13 @@ int media_svc_update_item_end(MediaSvcHandle *handle, uid_t uid) media_svc_retvm_if(db_handle == NULL, MS_MEDIA_ERR_INVALID_PARAMETER, "Handle is NULL"); - if (g_media_svc_update_item_cur_data_cnt > 0) { + if (g_media_svc_update_item_cur_data_cnt > 0) { ret = _media_svc_list_query_do(db_handle, MEDIA_SVC_QUERY_UPDATE_ITEM, uid); } - g_media_svc_update_item_data_cnt = 1; - g_media_svc_update_item_cur_data_cnt = 0; + g_media_svc_update_item_data_cnt = 1; + g_media_svc_update_item_cur_data_cnt = 0; return ret; } @@ -1313,14 +1313,14 @@ 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++; - } 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); @@ -1608,11 +1608,11 @@ static int __media_svc_copy_para_to_content(media_svc_content_info_s *content_in //new_content_info->media_meta.channel = content_info->media_meta.channel; //new_content_info->media_meta.orientation = content_info->media_meta.orientation; - if(content_info->media_meta.longitude != MEDIA_SVC_DEFAULT_GPS_VALUE) + if (content_info->media_meta.longitude != MEDIA_SVC_DEFAULT_GPS_VALUE) new_content_info->media_meta.longitude = content_info->media_meta.longitude; - if(content_info->media_meta.latitude != MEDIA_SVC_DEFAULT_GPS_VALUE) + if (content_info->media_meta.latitude != MEDIA_SVC_DEFAULT_GPS_VALUE) new_content_info->media_meta.latitude = content_info->media_meta.latitude; - if(content_info->media_meta.altitude != MEDIA_SVC_DEFAULT_GPS_VALUE) + if (content_info->media_meta.altitude != MEDIA_SVC_DEFAULT_GPS_VALUE) new_content_info->media_meta.altitude = content_info->media_meta.altitude; new_content_info->media_meta.rating = content_info->media_meta.rating; @@ -1725,7 +1725,7 @@ int media_svc_insert_item_immediately_with_data(MediaSvcHandle *handle, media_sv 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)))) { + (!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 { @@ -1740,7 +1740,7 @@ int media_svc_insert_item_immediately_with_data(MediaSvcHandle *handle, media_sv 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)))) + (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); @@ -1826,7 +1826,7 @@ int media_svc_insert_storage(MediaSvcHandle *handle, const char *storage_id, con ret = _media_svc_append_storage(db_handle, storage_id, storage_name, storage_path, storage_account, storage_type, uid); media_svc_retvm_if(ret != MS_MEDIA_ERR_NONE, ret, "append storage failed : %d", ret); - if(strcmp(storage_id, MEDIA_SVC_DB_TABLE_MEDIA)) { + if (strcmp(storage_id, MEDIA_SVC_DB_TABLE_MEDIA)) { 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); @@ -1878,7 +1878,7 @@ int media_svc_insert_folder_begin(MediaSvcHandle *handle, int data_cnt) media_svc_retvm_if(data_cnt < 1, MS_MEDIA_ERR_INVALID_PARAMETER, "data_cnt shuld be bigger than 1"); g_media_svc_insert_folder_data_cnt = data_cnt; - g_media_svc_insert_folder_cur_data_cnt = 0; + g_media_svc_insert_folder_cur_data_cnt = 0; return MS_MEDIA_ERR_NONE; } @@ -1892,13 +1892,13 @@ int media_svc_insert_folder_end(MediaSvcHandle *handle, uid_t uid) media_svc_retvm_if(db_handle == NULL, MS_MEDIA_ERR_INVALID_PARAMETER, "Handle is NULL"); - if (g_media_svc_insert_folder_cur_data_cnt > 0) { + if (g_media_svc_insert_folder_cur_data_cnt > 0) { ret = _media_svc_list_query_do(db_handle, MEDIA_SVC_QUERY_INSERT_FOLDER, uid); } - g_media_svc_insert_folder_data_cnt = 1; - g_media_svc_insert_folder_cur_data_cnt = 0; + g_media_svc_insert_folder_data_cnt = 1; + g_media_svc_insert_folder_cur_data_cnt = 0; return ret; } @@ -1914,18 +1914,18 @@ int media_svc_insert_folder(MediaSvcHandle *handle, const char *storage_id, medi media_svc_retvm_if(!STRING_VALID(path), MS_MEDIA_ERR_INVALID_PARAMETER, "path is NULL"); media_svc_retvm_if(__media_svc_check_storage(storage_type, FALSE) != TRUE, MS_MEDIA_ERR_INVALID_PARAMETER, "Invalid storage_type"); - if (g_media_svc_insert_folder_data_cnt == 1) { + if (g_media_svc_insert_folder_data_cnt == 1) { ret = _media_svc_get_and_append_folder_id_by_folder_path(handle, storage_id, path, storage_type, folder_uuid, FALSE, uid); - } else if (g_media_svc_insert_folder_cur_data_cnt < (g_media_svc_insert_folder_data_cnt - 1)) { + } else if (g_media_svc_insert_folder_cur_data_cnt < (g_media_svc_insert_folder_data_cnt - 1)) { ret = _media_svc_get_and_append_folder_id_by_folder_path(handle, storage_id, path, storage_type, folder_uuid, TRUE, uid); media_svc_retv_if(ret != MS_MEDIA_ERR_NONE, ret); g_media_svc_insert_folder_cur_data_cnt ++; - } else if (g_media_svc_insert_folder_cur_data_cnt == (g_media_svc_insert_folder_data_cnt - 1)) { + } else if (g_media_svc_insert_folder_cur_data_cnt == (g_media_svc_insert_folder_data_cnt - 1)) { ret = _media_svc_get_and_append_folder_id_by_folder_path(handle, storage_id, path, storage_type, folder_uuid, TRUE, uid); media_svc_retv_if(ret != MS_MEDIA_ERR_NONE, ret); @@ -1933,7 +1933,7 @@ int media_svc_insert_folder(MediaSvcHandle *handle, const char *storage_id, medi ret = _media_svc_list_query_do(db_handle, MEDIA_SVC_QUERY_INSERT_FOLDER, uid); media_svc_retv_if(ret != MS_MEDIA_ERR_NONE, ret); - g_media_svc_insert_folder_cur_data_cnt = 0; + g_media_svc_insert_folder_cur_data_cnt = 0; } else { media_svc_error("Error in media_svc_set_insert_folder"); @@ -2004,22 +2004,19 @@ int media_svc_insert_item_pass1(MediaSvcHandle *handle, const char *storage_id, media_svc_retv_del_if(ret != MS_MEDIA_ERR_NONE, ret, &content_info); if (g_insert_with_noti) - { _media_svc_insert_item_to_noti_list(&content_info, g_media_svc_insert_item_cur_data_cnt++); - } - } else if(g_media_svc_insert_item_cur_data_cnt < (g_media_svc_insert_item_data_cnt - 1)) { + } else if (g_media_svc_insert_item_cur_data_cnt < (g_media_svc_insert_item_data_cnt - 1)) { ret = _media_svc_insert_item_pass1(db_handle, storage_id, &content_info, is_burst, TRUE, uid); media_svc_retv_del_if(ret != MS_MEDIA_ERR_NONE, ret, &content_info); if (g_insert_with_noti) - { _media_svc_insert_item_to_noti_list(&content_info, g_media_svc_insert_item_cur_data_cnt); - } + media_svc_debug("g_media_svc_insert_item_cur_data_cnt %d", 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)) { + } else if (g_media_svc_insert_item_cur_data_cnt == (g_media_svc_insert_item_data_cnt - 1)) { ret = _media_svc_insert_item_pass1(db_handle, storage_id, &content_info, is_burst, TRUE, uid); media_svc_retv_del_if(ret != MS_MEDIA_ERR_NONE, ret, &content_info); @@ -2100,7 +2097,7 @@ int media_svc_insert_item_pass2(MediaSvcHandle *handle, const char *storage_id, while (sqlite3_step(sql_stmt) == SQLITE_ROW) { db_data = NULL; db_data = malloc(sizeof(media_svc_item_info_s)); - if(db_data == NULL) { + if (db_data == NULL) { media_svc_error("Out of memory"); continue; } @@ -2150,9 +2147,7 @@ int media_svc_insert_item_pass2(MediaSvcHandle *handle, const char *storage_id, } if (idx > 0) - { ret = _media_svc_list_query_do(db_handle, MEDIA_SVC_QUERY_UPDATE_ITEM, uid); - } g_array_free(db_data_array, FALSE); db_data_array = NULL; @@ -2184,10 +2179,10 @@ int media_svc_check_folder_exist_by_path(MediaSvcHandle *handle, const char *sto media_svc_retvm_if(!STRING_VALID(storage_id), MS_MEDIA_ERR_INVALID_PARAMETER, "storage_id is NULL"); media_svc_retvm_if(!STRING_VALID(folder_path), MS_MEDIA_ERR_INVALID_PARAMETER, "Path is NULL"); - ret = _media_svc_count_folder_with_path(db_handle, storage_id, folder_path, &count); + ret = _media_svc_count_folder_with_path(db_handle, storage_id, folder_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 { @@ -2209,11 +2204,11 @@ int media_svc_check_subfolder_by_path(MediaSvcHandle *handle, const char *storag media_svc_retvm_if(!STRING_VALID(folder_path), MS_MEDIA_ERR_INVALID_PARAMETER, "Path is NULL"); *count = 0; - ret = _media_svc_count_subfolder_with_path(db_handle, storage_id, folder_path, &cnt); + ret = _media_svc_count_subfolder_with_path(db_handle, storage_id, folder_path, &cnt); media_svc_retv_if(ret != MS_MEDIA_ERR_NONE, ret); *count = cnt; - if(cnt > 0) { + if (cnt > 0) { media_svc_debug("item is exist in database"); return MS_MEDIA_ERR_NONE; } else { diff --git a/src/include/common/media-svc-db-utils.h b/src/include/common/media-svc-db-utils.h index 027d869..e51b24b 100755 --- a/src/include/common/media-svc-db-utils.h +++ b/src/include/common/media-svc-db-utils.h @@ -26,7 +26,7 @@ #include #include -#define SQLITE3_FINALIZE(x) if(x != NULL) {sqlite3_finalize(x);} +#define SQLITE3_FINALIZE(x) if (x != NULL) {sqlite3_finalize(x);} int _media_svc_make_table_query(sqlite3 *db_handle, const char *table_name, media_svc_table_slist_e list, uid_t uid); int _media_svc_upgrade_table_query(sqlite3 *db_handle, const char *table_name, media_svc_table_slist_e list, uid_t uid); diff --git a/src/include/common/media-svc-debug.h b/src/include/common/media-svc-debug.h index 964e612..e4cc9f2 100755 --- a/src/include/common/media-svc-debug.h +++ b/src/include/common/media-svc-debug.h @@ -35,14 +35,14 @@ #define LOG_TAG "MEDIA_SERVICE" -#define FONT_COLOR_RESET "\033[0m" -#define FONT_COLOR_RED "\033[31m" -#define FONT_COLOR_GREEN "\033[32m" -#define FONT_COLOR_YELLOW "\033[33m" -#define FONT_COLOR_BLUE "\033[34m" -#define FONT_COLOR_PURPLE "\033[35m" -#define FONT_COLOR_CYAN "\033[36m" -#define FONT_COLOR_GRAY "\033[37m" +#define FONT_COLOR_RESET "\033[0m" +#define FONT_COLOR_RED "\033[31m" +#define FONT_COLOR_GREEN "\033[32m" +#define FONT_COLOR_YELLOW "\033[33m" +#define FONT_COLOR_BLUE "\033[34m" +#define FONT_COLOR_PURPLE "\033[35m" +#define FONT_COLOR_CYAN "\033[36m" +#define FONT_COLOR_GRAY "\033[37m" #define media_svc_debug(fmt, arg...) do { \ LOGD(FONT_COLOR_RESET" "fmt"", ##arg); \ @@ -61,26 +61,26 @@ } while (0) #define media_svc_retm_if(expr, fmt, arg...) do { \ - if(expr) { \ + if (expr) { \ LOGE(FONT_COLOR_RED" "fmt"", ##arg); \ return; \ } \ } while (0) #define media_svc_retv_if(expr, val) do { \ - if(expr) { \ + if (expr) { \ LOGE(FONT_COLOR_RED""); \ return (val); \ } \ } while (0) #define media_svc_retvm_if(expr, val, fmt, arg...) do { \ - if(expr) { \ + if (expr) { \ LOGE(FONT_COLOR_RED" "fmt"", ##arg); \ return (val); \ } \ } while (0) #define media_svc_retv_del_if(expr, val, p_str) do { \ - if(expr) { \ + if (expr) { \ LOGE(FONT_COLOR_RED""); \ _media_svc_destroy_content_info(p_str); \ return (val); \ diff --git a/src/include/common/media-svc-env.h b/src/include/common/media-svc-env.h index 13e7f2a..c299d0a 100755 --- a/src/include/common/media-svc-env.h +++ b/src/include/common/media-svc-env.h @@ -53,35 +53,35 @@ extern "C" { /** * Table Name */ -#define MEDIA_SVC_DB_TABLE_MEDIA "media" /**< media table*/ -#define MEDIA_SVC_DB_TABLE_FOLDER "folder" /**< media_folder table*/ -#define MEDIA_SVC_DB_TABLE_PLAYLIST "playlist" /**< playlist table*/ -#define MEDIA_SVC_DB_TABLE_PLAYLIST_MAP "playlist_map" /**< playlist_map table*/ -#define MEDIA_SVC_DB_TABLE_ALBUM "album" /**< album table*/ -#define MEDIA_SVC_DB_TABLE_TAG "tag" /**< tag table*/ -#define MEDIA_SVC_DB_TABLE_TAG_MAP "tag_map" /**< tag_map table*/ -#define MEDIA_SVC_DB_TABLE_BOOKMARK "bookmark" /**< bookmark table*/ -#define MEDIA_SVC_DB_TABLE_STORAGE "storage" /**< storage table*/ -#define MEDIA_SVC_DB_TABLE_TMP_TABLE "tmp" /**< tmp table for backup*/ -#define MEDIA_SVC_DB_TABLE_FACE "face" /**< face table*/ -#define MEDIA_SVC_DB_TABLE_FACE_SCAN_LIST "face_scan_list" /**< face_scan_list table*/ +#define MEDIA_SVC_DB_TABLE_MEDIA "media" /**< media table*/ +#define MEDIA_SVC_DB_TABLE_FOLDER "folder" /**< media_folder table*/ +#define MEDIA_SVC_DB_TABLE_PLAYLIST "playlist" /**< playlist table*/ +#define MEDIA_SVC_DB_TABLE_PLAYLIST_MAP "playlist_map" /**< playlist_map table*/ +#define MEDIA_SVC_DB_TABLE_ALBUM "album" /**< album table*/ +#define MEDIA_SVC_DB_TABLE_TAG "tag" /**< tag table*/ +#define MEDIA_SVC_DB_TABLE_TAG_MAP "tag_map" /**< tag_map table*/ +#define MEDIA_SVC_DB_TABLE_BOOKMARK "bookmark" /**< bookmark table*/ +#define MEDIA_SVC_DB_TABLE_STORAGE "storage" /**< storage table*/ +#define MEDIA_SVC_DB_TABLE_TMP_TABLE "tmp" /**< tmp table for backup*/ +#define MEDIA_SVC_DB_TABLE_FACE "face" /**< face table*/ +#define MEDIA_SVC_DB_TABLE_FACE_SCAN_LIST "face_scan_list" /**< face_scan_list table*/ /** * View Name */ -#define MEDIA_SVC_DB_VIEW_MEDIA "media_view" /**< media_view*/ -#define MEDIA_SVC_DB_VIEW_PLAYLIST "playlist_view" /**< playlist_view*/ -#define MEDIA_SVC_DB_VIEW_TAG "tag_view" /**< tag_view*/ +#define MEDIA_SVC_DB_VIEW_MEDIA "media_view" /**< media_view*/ +#define MEDIA_SVC_DB_VIEW_PLAYLIST "playlist_view" /**< playlist_view*/ +#define MEDIA_SVC_DB_VIEW_TAG "tag_view" /**< tag_view*/ /** * Trigger Name */ #define MEDIA_SVC_DB_TRIGGER_FOLDER "folder_cleanup" -#define MEDIA_SVC_DB_TRIGGER_PLAYLIST_MAP "playlist_map_cleanup" /**< media to map*/ -#define MEDIA_SVC_DB_TRIGGER_PLAYLIST_MAP1 "playlist_map_cleanup_1" /**< playlist to map*/ +#define MEDIA_SVC_DB_TRIGGER_PLAYLIST_MAP "playlist_map_cleanup" /**< media to map*/ +#define MEDIA_SVC_DB_TRIGGER_PLAYLIST_MAP1 "playlist_map_cleanup_1" /**< playlist to map*/ #define MEDIA_SVC_DB_TRIGGER_ALBUM "album_cleanup" -#define MEDIA_SVC_DB_TRIGGER_TAG_MAP "tag_map_cleanup" /**< media to map*/ -#define MEDIA_SVC_DB_TRIGGER_TAG_MAP1 "tag_map_cleanup_1" /**< tag to map*/ +#define MEDIA_SVC_DB_TRIGGER_TAG_MAP "tag_map_cleanup" /**< media to map*/ +#define MEDIA_SVC_DB_TRIGGER_TAG_MAP1 "tag_map_cleanup_1" /**< tag to map*/ #define MEDIA_SVC_DB_TRIGGER_BOOKMARK "bookmark_cleanup" #define MEDIA_SVC_DB_TRIGGER_STORAGE "storage_folder_cleanup" #define MEDIA_SVC_DB_TRIGGER_FACE_SCAN_LIST "face_scan_list_cleanup" @@ -124,29 +124,29 @@ extern "C" { -#define MEDIA_SVC_METADATA_LEN_MAX 128 /**< Length of metadata*/ -#define MEDIA_SVC_METADATA_DESCRIPTION_MAX 512 /**< Length of description*/ -#define MEDIA_SVC_PATHNAME_SIZE 4096 /**< Length of Path name. */ -#define MEDIA_SVC_UUID_SIZE 36 /**< Length of UUID*/ +#define MEDIA_SVC_METADATA_LEN_MAX 128 /**< Length of metadata*/ +#define MEDIA_SVC_METADATA_DESCRIPTION_MAX 512 /**< Length of description*/ +#define MEDIA_SVC_PATHNAME_SIZE 4096 /**< Length of Path name. */ +#define MEDIA_SVC_UUID_SIZE 36 /**< Length of UUID*/ #define MEDIA_SVC_TAG_UNKNOWN "Unknown" -#define MEDIA_SVC_MEDIA_PATH tzplatform_mkpath(TZ_USER_SHARE, "media") /**< Media path*/ +#define MEDIA_SVC_MEDIA_PATH tzplatform_mkpath(TZ_USER_SHARE, "media") /**< Media path*/ #define MEDIA_SVC_THUMB_PATH_PREFIX tzplatform_mkpath(TZ_USER_SHARE, "media/.thumb") /**< Thumbnail path prefix*/ -#define MEDIA_SVC_THUMB_INTERNAL_PATH tzplatform_mkpath(TZ_USER_SHARE, "media/.thumb/phone") /**< Phone thumbnail path*/ -#define MEDIA_SVC_THUMB_EXTERNAL_PATH tzplatform_mkpath(TZ_USER_SHARE, "media/.thumb/mmc") /**< MMC thumbnail path*/ -#define MEDIA_SVC_THUMB_DEFAULT_PATH tzplatform_mkpath(TZ_USER_SHARE, "media/.thumb/thumb_default.png") /** default thumbnail */ +#define MEDIA_SVC_THUMB_INTERNAL_PATH tzplatform_mkpath(TZ_USER_SHARE, "media/.thumb/phone") /**< Phone thumbnail path*/ +#define MEDIA_SVC_THUMB_EXTERNAL_PATH tzplatform_mkpath(TZ_USER_SHARE, "media/.thumb/mmc") /**< MMC thumbnail path*/ +#define MEDIA_SVC_THUMB_DEFAULT_PATH tzplatform_mkpath(TZ_USER_SHARE, "media/.thumb/thumb_default.png") /**< default thumbnail */ #define THUMB_EXT "jpg" enum Exif_Orientation { NOT_AVAILABLE = 0, - NORMAL = 1, - HFLIP = 2, + NORMAL = 1, + HFLIP = 2, ROT_180 = 3, - VFLIP = 4, - TRANSPOSE = 5, - ROT_90 = 6, - TRANSVERSE = 7, + VFLIP = 4, + TRANSPOSE = 5, + ROT_90 = 6, + TRANSVERSE = 7, ROT_270 = 8 }; diff --git a/src/include/common/media-svc-util.h b/src/include/common/media-svc-util.h index 4a84c8d..6784ab3 100755 --- a/src/include/common/media-svc-util.h +++ b/src/include/common/media-svc-util.h @@ -36,13 +36,13 @@ extern "C" { #endif #ifndef FALSE -#define FALSE 0 +#define FALSE 0 #endif #ifndef TRUE -#define TRUE 1 +#define TRUE 1 #endif -#define SAFE_FREE(src) { if(src) {free(src); src = NULL;}} +#define SAFE_FREE(src) { if (src) {free(src); src = NULL;}} #define STRING_VALID(str) \ ((str != NULL && strlen(str) > 0) ? TRUE : FALSE) @@ -55,7 +55,7 @@ int _media_svc_get_thumbnail_path(media_svc_storage_type_e storage_type, char *t int _media_svc_get_file_time(const char *full_path); int _media_svc_set_default_value(media_svc_content_info_s *content_info, bool refresh); 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); int _media_svc_extract_media_metadata(sqlite3 *handle, media_svc_content_info_s *content_info, uid_t uid); int __media_svc_malloc_and_strncpy(char **dst, const char *src); diff --git a/test/media-service-test.c b/test/media-service-test.c index 824d469..a50c592 100755 --- a/test/media-service-test.c +++ b/test/media-service-test.c @@ -24,19 +24,19 @@ #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); diff --git a/test/plugin/media_svc_plugin_test.c b/test/plugin/media_svc_plugin_test.c index 7cd839e..6d9e1d1 100755 --- a/test/plugin/media_svc_plugin_test.c +++ b/test/plugin/media_svc_plugin_test.c @@ -27,7 +27,7 @@ #include -#define PLUGIN_SO_FILE_NAME "/usr/lib/libmedia-content-plugin.so" +#define PLUGIN_SO_FILE_NAME "/usr/lib/libmedia-content-plugin.so" #define MEDIA_ROOT_PATH_SDCARD tzplatform_getenv(TZ_SYS_STORAGE) void *funcHandle = NULL; @@ -56,12 +56,7 @@ int __load_functions() 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) { + 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; } @@ -160,7 +155,7 @@ int main() } } /* End of While */ - ret = media_svc_insert_folder(db_handle, 0, path); + ret = media_svc_insert_folder(db_handle, 0, path); if (ret < 0) { msg_print(__LINE__, "media_svc_insert_folder error "); } else { -- 2.7.4