Apply tizen coding rule 50/49550/1 accepted/tizen/mobile/20151015.093334 accepted/tizen/tv/20151015.093346 accepted/tizen/wearable/20151015.093402 submit/tizen/20151015.062305
authorHaejeong, Kim <backto.kim@samsung.com>
Thu, 15 Oct 2015 02:40:44 +0000 (11:40 +0900)
committerHaejeong, Kim <backto.kim@samsung.com>
Thu, 15 Oct 2015 02:40:44 +0000 (11:40 +0900)
Change-Id: Ia14d7543fcb7a7efded300ebe9aabab23948f6cc

plugin/media-content-plugin.c
src/common/media-svc-db-utils.c
src/common/media-svc-media-folder.c
src/common/media-svc-media.c
src/common/media-svc-storage.c
src/common/media-svc-util.c
src/common/media-svc.c
test/plugin/media_svc_plugin_test.c

index 7181e7d..cfbf296 100755 (executable)
@@ -827,7 +827,7 @@ int set_storage_scan_status(void *handle, const char *storage_id, int status, ui
        return MEDIA_SVC_PLUGIN_ERROR_NONE;
 }
 
-int get_storage_list(void *handle, char ***storage_list, char ***storage_id_list,int **scan_status_list, int *count, char **err_msg)
+int get_storage_list(void *handle, char ***storage_list, char ***storage_id_list, int **scan_status_list, int *count, char **err_msg)
 {
        int ret = MEDIA_SVC_PLUGIN_ERROR_NONE;
 
index 37ccc6d..dbf4a74 100755 (executable)
@@ -110,9 +110,8 @@ int __media_svc_add_table_info(const char *name, const char *triggerName, const
                tbl->actionTable = strndup(actionTable, strlen(actionTable));
        }
 
-       if (STRING_VALID(viewName)) {
+       if (STRING_VALID(viewName))
                tbl->viewName = strndup(viewName, strlen(viewName));
-       }
 
        g_hash_table_insert(table, (gpointer)name, (gpointer)tbl);
 
@@ -560,9 +559,8 @@ int _media_svc_init_table_query(const char *event_table_name)
 
        /*variable initialize.. */
        table = g_hash_table_new(g_str_hash, g_str_equal);
-       for (i = 0; i < MEDIA_SVC_DB_LIST_MAX; i++) {
+       for (i = 0; i < MEDIA_SVC_DB_LIST_MAX; i++)
                column_list[i] = g_slist_alloc();
-       }
 
        /*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);
@@ -743,7 +741,8 @@ int _media_svc_init_table_query(const char *event_table_name)
 
        return ret;
 }
-void __media_svc_table_free(table_info *tb) {
+void __media_svc_table_free(table_info *tb)
+{
        SAFE_FREE(tb->triggerName);
        SAFE_FREE(tb->viewName);
        SAFE_FREE(tb->eventTable);
@@ -751,7 +750,8 @@ void __media_svc_table_free(table_info *tb) {
        SAFE_FREE(tb);
 }
 
-void __media_svc_column_free(column_info *col) {
+void __media_svc_column_free(column_info *col)
+{
        SAFE_FREE(col->name);
        SAFE_FREE(col->type);
        SAFE_FREE(col->option);
@@ -769,109 +769,109 @@ void _media_svc_destroy_table_query()
        /* Table Free */
        tb = g_hash_table_lookup(table, MEDIA_SVC_DB_TABLE_MEDIA);
        __media_svc_table_free(tb);
-       g_hash_table_remove (table, MEDIA_SVC_DB_TABLE_MEDIA);
+       g_hash_table_remove(table, MEDIA_SVC_DB_TABLE_MEDIA);
 
        tb = g_hash_table_lookup(table, MEDIA_SVC_DB_TABLE_FOLDER);
        __media_svc_table_free(tb);
-       g_hash_table_remove (table, MEDIA_SVC_DB_TABLE_FOLDER);
+       g_hash_table_remove(table, MEDIA_SVC_DB_TABLE_FOLDER);
 
        tb = g_hash_table_lookup(table, MEDIA_SVC_DB_TABLE_PLAYLIST);
        __media_svc_table_free(tb);
-       g_hash_table_remove (table, MEDIA_SVC_DB_TABLE_PLAYLIST);
+       g_hash_table_remove(table, MEDIA_SVC_DB_TABLE_PLAYLIST);
 
        tb = g_hash_table_lookup(table, MEDIA_SVC_DB_TABLE_PLAYLIST_MAP);
        __media_svc_table_free(tb);
-       g_hash_table_remove (table, MEDIA_SVC_DB_TABLE_PLAYLIST_MAP);
+       g_hash_table_remove(table, MEDIA_SVC_DB_TABLE_PLAYLIST_MAP);
 
        tb = g_hash_table_lookup(table, MEDIA_SVC_DB_TABLE_ALBUM);
        __media_svc_table_free(tb);
-       g_hash_table_remove (table, MEDIA_SVC_DB_TABLE_ALBUM);
+       g_hash_table_remove(table, MEDIA_SVC_DB_TABLE_ALBUM);
 
        tb = g_hash_table_lookup(table, MEDIA_SVC_DB_TABLE_TAG);
        __media_svc_table_free(tb);
-       g_hash_table_remove (table, MEDIA_SVC_DB_TABLE_TAG);
+       g_hash_table_remove(table, MEDIA_SVC_DB_TABLE_TAG);
 
        tb = g_hash_table_lookup(table, MEDIA_SVC_DB_TABLE_TAG_MAP);
        __media_svc_table_free(tb);
-       g_hash_table_remove (table, MEDIA_SVC_DB_TABLE_TAG_MAP);
+       g_hash_table_remove(table, MEDIA_SVC_DB_TABLE_TAG_MAP);
 
        tb = g_hash_table_lookup(table, MEDIA_SVC_DB_TABLE_BOOKMARK);
        __media_svc_table_free(tb);
-       g_hash_table_remove (table, MEDIA_SVC_DB_TABLE_BOOKMARK);
+       g_hash_table_remove(table, MEDIA_SVC_DB_TABLE_BOOKMARK);
 
        tb = g_hash_table_lookup(table, MEDIA_SVC_DB_TABLE_STORAGE);
        __media_svc_table_free(tb);
-       g_hash_table_remove (table, MEDIA_SVC_DB_TABLE_STORAGE);
+       g_hash_table_remove(table, MEDIA_SVC_DB_TABLE_STORAGE);
 
        g_hash_table_destroy(table);
 
        /* Column Free */
        len = g_slist_length(column_list[MEDIA_SVC_DB_LIST_MEDIA]);
 
-       for(i=1; i<len; i++) {
+       for (i = 1; i < len; i++) {
                col_ptr = g_slist_nth_data(column_list[MEDIA_SVC_DB_LIST_MEDIA], i);
                __media_svc_column_free(col_ptr);
        }
 
        len = g_slist_length(column_list[MEDIA_SVC_DB_LIST_FOLDER]);
 
-       for(i=1; i<len; i++) {
+       for (i = 1; i < len; i++) {
                col_ptr = g_slist_nth_data(column_list[MEDIA_SVC_DB_LIST_FOLDER], i);
                __media_svc_column_free(col_ptr);
        }
 
        len = g_slist_length(column_list[MEDIA_SVC_DB_LIST_PLAYLIST_MAP]);
 
-       for(i=1; i<len; i++) {
+       for (i = 1; i < len; i++) {
                col_ptr = g_slist_nth_data(column_list[MEDIA_SVC_DB_LIST_PLAYLIST_MAP], i);
                __media_svc_column_free(col_ptr);
        }
 
        len = g_slist_length(column_list[MEDIA_SVC_DB_LIST_PLAYLIST]);
 
-       for(i=1; i<len; i++) {
+       for (i = 1; i < len; i++) {
                col_ptr = g_slist_nth_data(column_list[MEDIA_SVC_DB_LIST_PLAYLIST], i);
                __media_svc_column_free(col_ptr);
        }
 
        len = g_slist_length(column_list[MEDIA_SVC_DB_LIST_ALBUM]);
 
-       for(i=1; i<len; i++) {
+       for (i = 1; i < len; i++) {
                col_ptr = g_slist_nth_data(column_list[MEDIA_SVC_DB_LIST_ALBUM], i);
                __media_svc_column_free(col_ptr);
        }
 
        len = g_slist_length(column_list[MEDIA_SVC_DB_LIST_TAG_MAP]);
 
-       for(i=1; i<len; i++) {
+       for (i = 1; i < len; i++) {
                col_ptr = g_slist_nth_data(column_list[MEDIA_SVC_DB_LIST_TAG_MAP], i);
                __media_svc_column_free(col_ptr);
        }
 
        len = g_slist_length(column_list[MEDIA_SVC_DB_LIST_TAG]);
 
-       for(i=1; i<len; i++) {
+       for (i = 1; i < len; i++) {
                col_ptr = g_slist_nth_data(column_list[MEDIA_SVC_DB_LIST_TAG], i);
                __media_svc_column_free(col_ptr);
        }
 
        len = g_slist_length(column_list[MEDIA_SVC_DB_LIST_BOOKMARK]);
 
-       for(i=1; i<len; i++) {
+       for (i = 1; i < len; i++) {
                col_ptr = g_slist_nth_data(column_list[MEDIA_SVC_DB_LIST_BOOKMARK], i);
                __media_svc_column_free(col_ptr);
        }
 
        len = g_slist_length(column_list[MEDIA_SVC_DB_LIST_STORAGE]);
 
-       for(i=1; i<len; i++) {
+       for (i = 1; i < len; i++) {
                col_ptr = g_slist_nth_data(column_list[MEDIA_SVC_DB_LIST_STORAGE], i);
                __media_svc_column_free(col_ptr);
        }
 
-       for(i=0; i<MEDIA_SVC_DB_LIST_MAX; i++) {
+       for (i = 0; i < MEDIA_SVC_DB_LIST_MAX; i++)
                g_slist_free(column_list[i]);
-       }
+
 }
 
 static int __media_svc_db_upgrade(sqlite3 *db_handle, int cur_version, uid_t uid)
@@ -892,9 +892,8 @@ static int __media_svc_db_upgrade(sqlite3 *db_handle, int cur_version, uid_t uid
                media_svc_retv_if(sql == NULL, MS_MEDIA_ERR_OUT_OF_MEMORY);
 
                ret = _media_svc_sql_query(db_handle, sql, uid);
-               if (ret != MS_MEDIA_ERR_NONE) {
+               if (ret != MS_MEDIA_ERR_NONE)
                        media_svc_error("Error when create backup folder table");
-               }
                sqlite3_free(sql);
 
                /* Drop original table */
@@ -902,9 +901,8 @@ static int __media_svc_db_upgrade(sqlite3 *db_handle, int cur_version, uid_t uid
                media_svc_retv_if(sql == NULL, MS_MEDIA_ERR_OUT_OF_MEMORY);
 
                ret = _media_svc_sql_query(db_handle, sql, uid);
-               if (ret != MS_MEDIA_ERR_NONE) {
+               if (ret != MS_MEDIA_ERR_NONE)
                        media_svc_error("Error when drop table");
-               }
                sqlite3_free(sql);
 
                /* Create new table */
@@ -916,9 +914,8 @@ static int __media_svc_db_upgrade(sqlite3 *db_handle, int cur_version, uid_t uid
                media_svc_retv_if(sql == NULL, MS_MEDIA_ERR_OUT_OF_MEMORY);
 
                ret = _media_svc_sql_query(db_handle, sql, uid);
-               if (ret != MS_MEDIA_ERR_NONE) {
+               if (ret != MS_MEDIA_ERR_NONE)
                        media_svc_error("Error when backup folder table");
-               }
                sqlite3_free(sql);
 
                /* Drop tmp table*/
@@ -926,9 +923,8 @@ static int __media_svc_db_upgrade(sqlite3 *db_handle, int cur_version, uid_t uid
                media_svc_retv_if(sql == NULL, MS_MEDIA_ERR_OUT_OF_MEMORY);
 
                ret = _media_svc_sql_query(db_handle, sql, uid);
-               if (ret != MS_MEDIA_ERR_NONE) {
+               if (ret != MS_MEDIA_ERR_NONE)
                        media_svc_error("Error when drop backup folder table");
-               }
                sqlite3_free(sql);
 
        } else {
@@ -959,13 +955,13 @@ static int __media_svc_db_upgrade(sqlite3 *db_handle, int cur_version, uid_t uid
 
        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);
@@ -1012,11 +1008,10 @@ int _media_svc_sql_prepare_to_step(sqlite3 *handle, const char *sql_str, sqlite3
 
        if (err != SQLITE_OK) {
                media_svc_error("prepare error %d[%s]", err, sqlite3_errmsg(handle));
-               if (err == SQLITE_CORRUPT) {
+               if (err == SQLITE_CORRUPT)
                        return MS_MEDIA_ERR_DB_CORRUPT;
-               } else if (err == SQLITE_PERM) {
+               else if (err == SQLITE_PERM)
                        return MS_MEDIA_ERR_DB_PERMISSION;
-               }
 
                return MS_MEDIA_ERR_DB_INTERNAL;
        }
@@ -1047,11 +1042,10 @@ int _media_svc_sql_prepare_to_step_simple(sqlite3 *handle, const char *sql_str,
 
        if (err != SQLITE_OK) {
                media_svc_error("prepare error %d[%s]", err, sqlite3_errmsg(handle));
-               if (err == SQLITE_CORRUPT) {
+               if (err == SQLITE_CORRUPT)
                        return MS_MEDIA_ERR_DB_CORRUPT;
-               } else if (err == SQLITE_PERM) {
+               else if (err == SQLITE_PERM)
                        return MS_MEDIA_ERR_DB_PERMISSION;
-               }
 
                return MS_MEDIA_ERR_DB_INTERNAL;
        }
@@ -1102,9 +1096,8 @@ int _media_svc_sql_query_list(sqlite3 *handle, GList **query_list, uid_t uid)
                if (sql != NULL) {
                        /*ret = _media_svc_sql_query(handle, sql); */
                        ret = media_db_request_update_db_batch(sql, uid);
-                       if (ret != MS_MEDIA_ERR_NONE) {
+                       if (ret != MS_MEDIA_ERR_NONE)
                                media_svc_error("media_db_request_update_db_batch failed : %d", ret);
-                       }
                        sqlite3_free(sql);
                        sql = NULL;
                }
@@ -1149,9 +1142,9 @@ 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);
                return __media_svc_db_upgrade(db_handle, cur_version, uid);
        } else {
@@ -1250,9 +1243,8 @@ int _media_svc_update_media_view(sqlite3 *db_handle, uid_t uid)
        media_svc_retv_if(ret != MS_MEDIA_ERR_NONE, ret);
 
        while (sqlite3_step(sql_stmt) == SQLITE_ROW) {
-               if (STRING_VALID((const char *)sqlite3_column_text(sql_stmt, 0))) {
+               if (STRING_VALID((const char *)sqlite3_column_text(sql_stmt, 0)))
                        storage_list = g_list_append(storage_list, strdup((char *)sqlite3_column_text(sql_stmt, 0)));
-               }
        }
        SQLITE3_FINALIZE(sql_stmt);
 
index faffabf..69266ab 100755 (executable)
@@ -181,13 +181,10 @@ static int __media_svc_append_folder(sqlite3 *handle, const char *storage_id, me
                                                        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);
 
-       if (!stack_query)
-       {
+       if (!stack_query) {
                ret = _media_svc_sql_query(handle, sql, uid);
                sqlite3_free(sql);
-       }
-       else
-       {
+       } else {
                _media_svc_sql_query_add(&g_media_svc_insert_folder_query_list, &sql);
        }
 
@@ -553,13 +550,10 @@ 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);
-               }
-               else
-               {
+               } else {
                        _media_svc_sql_query_add(&g_media_svc_insert_folder_query_list, &sql);
                }
        }
@@ -709,8 +703,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;
        }
index 9fcb6cf..601e99f 100755 (executable)
@@ -103,11 +103,10 @@ static int __media_svc_count_invalid_folder_records_with_thumbnail(sqlite3 *hand
        sqlite3_stmt *sql_stmt = NULL;
        char *sql = NULL;
 
-       if (is_recursive) {
+       if (is_recursive)
                sql = sqlite3_mprintf("SELECT count(*) FROM '%s' WHERE validity=0 AND path LIKE '%q/%%' AND thumbnail_path IS NOT NULL", storage_id, folder_path);
-       } else {
+       else
                sql = sqlite3_mprintf("SELECT count(*) FROM '%s' WHERE validity=0 AND folder_uuid = '%q' AND thumbnail_path IS NOT NULL", storage_id, folder_uuid);
-       }
 
        ret = _media_svc_sql_prepare_to_step(handle, sql, &sql_stmt);
 
@@ -132,11 +131,10 @@ static int __media_svc_get_invalid_folder_records_with_thumbnail(sqlite3 *handle
        int idx = 0;
        char *sql = NULL;
 
-       if (is_recursive) {
+       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);
-       } else {
+       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);
-       }
 
        media_svc_debug("[SQL query] : %s", sql);
 
@@ -230,9 +228,8 @@ int _media_svc_insert_item_with_data(sqlite3 *handle, const char *storage_id, me
        if (is_burst) {
                int burst_id_int = 0;
                ret = _media_svc_get_burst_id(handle, storage_id, &burst_id_int);
-               if (ret != MS_MEDIA_ERR_NONE) {
+               if (ret != MS_MEDIA_ERR_NONE)
                        burst_id = NULL;
-               }
 
                if (burst_id_int > 0) {
                        media_svc_debug("Burst id : %d", burst_id_int);
@@ -248,9 +245,8 @@ int _media_svc_insert_item_with_data(sqlite3 *handle, const char *storage_id, me
                        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) {
                                ret = __media_svc_malloc_and_strncpy(&(content_info->thumbnail_path), thumb_path);
-                               if (ret != MS_MEDIA_ERR_NONE) {
+                               if (ret != MS_MEDIA_ERR_NONE)
                                        content_info->thumbnail_path = NULL;
-                               }
                        }
 
                        if (content_info->media_meta.width <= 0)
@@ -298,7 +294,7 @@ int _media_svc_insert_item_with_data(sqlite3 *handle, const char *storage_id, me
                                                                content_info->size,
                                                                content_info->added_time,
                                                                content_info->modified_time,
-                                                               content_info->folder_uuid,              //
+                                                               content_info->folder_uuid,              /**/
                                                                content_info->thumbnail_path,
                                                                content_info->media_meta.title,
                                                                content_info->album_id,
@@ -311,7 +307,7 @@ int _media_svc_insert_item_with_data(sqlite3 *handle, const char *storage_id, me
                                                                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.description,   /**/
                                                                content_info->media_meta.category,
                                                                content_info->media_meta.keyword,
                                                                content_info->media_meta.location_tag,
@@ -321,7 +317,7 @@ int _media_svc_insert_item_with_data(sqlite3 *handle, const char *storage_id, me
                                                                content_info->media_meta.provider,
                                                                content_info->last_played_time,
                                                                content_info->played_count,
-                                                               content_info->favourate,        //
+                                                               content_info->favourate,        /**/
                                                                content_info->media_meta.bitrate,
                                                                content_info->media_meta.bitpersample,
                                                                content_info->media_meta.samplerate,
@@ -529,11 +525,11 @@ 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;
        }
 
@@ -638,11 +634,10 @@ int _media_svc_delete_invalid_items(sqlite3 *handle, const char *storage_id, med
        /*Delete thumbnails*/
        char *default_thumbnail_path = _media_svc_get_thumb_default_path(uid);
        for (idx = 0; idx < invalid_count; idx++) {
-               if ((strlen(thumbpath_record[idx].thumbnail_path) > 0) && (STRING_VALID(default_thumbnail_path)) && (strncmp(thumbpath_record[idx].thumbnail_path,default_thumbnail_path, strlen(default_thumbnail_path)) != 0)) {
+               if ((strlen(thumbpath_record[idx].thumbnail_path) > 0) && (STRING_VALID(default_thumbnail_path)) && (strncmp(thumbpath_record[idx].thumbnail_path, default_thumbnail_path, strlen(default_thumbnail_path)) != 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.");
-                       }
                }
        }
 
@@ -687,11 +682,10 @@ int _media_svc_delete_invalid_folder_items(sqlite3 *handle, const char *storage_
                media_svc_debug("There is no item with thumbnail");
        }
 
-       if (is_recursive) {
+       if (is_recursive)
                sql = sqlite3_mprintf("DELETE FROM '%s' WHERE validity = 0 AND path LIKE '%q/%%'", storage_id, folder_path);
-       } else {
+       else
                sql = sqlite3_mprintf("DELETE FROM '%s' WHERE validity = 0 AND folder_uuid='%q'", storage_id, folder_uuid);
-       }
 
        ret = _media_svc_sql_query(handle, sql, uid);
        sqlite3_free(sql);
@@ -707,9 +701,8 @@ int _media_svc_delete_invalid_folder_items(sqlite3 *handle, const char *storage_
                        for (idx = 0; idx < invalid_count; idx++) {
                                if ((strlen(thumbpath_record[idx].thumbnail_path) > 0) && (strncmp(thumbpath_record[idx].thumbnail_path, default_thumbnail_path, strlen(default_thumbnail_path)) != 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.");
-                                       }
                                }
                        }
                }
@@ -908,11 +901,11 @@ int _media_svc_get_noti_info(sqlite3 *handle, const char *storage_id, const char
                return MS_MEDIA_ERR_INVALID_PARAMETER;
        }
 
-       if (update_item == MS_MEDIA_ITEM_FILE) {
+       if (update_item == MS_MEDIA_ITEM_FILE)
                sql = sqlite3_mprintf("SELECT media_uuid, media_type, mime_type FROM '%s' WHERE path=%Q", storage_id, path);
-       } else if (update_item == MS_MEDIA_ITEM_DIRECTORY) {
+       else if (update_item == MS_MEDIA_ITEM_DIRECTORY)
                sql = sqlite3_mprintf("SELECT folder_uuid FROM '%s' WHERE path=%Q AND storage_uuid='%s'", MEDIA_SVC_DB_TABLE_FOLDER, path, storage_id);
-       else {
+       else {
                media_svc_error("_media_svc_get_noti_info failed : update item");
                return MS_MEDIA_ERR_INVALID_PARAMETER;
        }
@@ -941,11 +934,10 @@ int _media_svc_get_noti_info(sqlite3 *handle, const char *storage_id, const char
                (*item)->media_type = sqlite3_column_int(sql_stmt, 1);
                (*item)->mime_type = g_strdup((const char *)sqlite3_column_text(sql_stmt, 2));
        } else if (update_item == MS_MEDIA_ITEM_DIRECTORY) {
-               if (is_root_dir) {
+               if (is_root_dir)
                        (*item)->media_uuid = NULL;
-               } else {
+               else
                        (*item)->media_uuid = g_strdup((const char *)sqlite3_column_text(sql_stmt, 0));
-               }
        }
 
        SQLITE3_FINALIZE(sql_stmt);
@@ -1057,8 +1049,7 @@ 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))
                        _media_svc_get_pinyin_str(content_info->file_name, &content_info->file_name_pinyin);
        }
@@ -1083,8 +1074,7 @@ int _media_svc_insert_item_pass1(sqlite3 *handle, const char *storage_id, media_
                storage_id
                );
 #if 0
-       if (burst_id)
-       {
+       if (burst_id) {
                sqlite3_free(burst_id);
                burst_id = NULL;
        }
@@ -1109,13 +1099,11 @@ int _media_svc_insert_item_pass1(sqlite3 *handle, const char *storage_id, media_
 int _media_svc_insert_item_pass2(sqlite3 *handle, const char *storage_id, media_svc_content_info_s *content_info, int is_burst, bool stack_query, uid_t uid)
 {
        int ret = MS_MEDIA_ERR_NONE;
-       //char *burst_id = NULL;
 
        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))
                        _media_svc_get_pinyin_str(content_info->file_name, &content_info->file_name_pinyin);
                if (STRING_VALID(content_info->media_meta.title))
@@ -1145,7 +1133,7 @@ int _media_svc_insert_item_pass2(sqlite3 *handle, const char *storage_id, media_
                artist_pinyin=%Q, album_artist_pinyin=%Q, genre_pinyin=%Q, composer_pinyin=%Q, copyright_pinyin=%Q, description_pinyin=%Q WHERE path=%Q",
                storage_id,
                //content_info->folder_uuid,
-               content_info->thumbnail_path,           //
+               content_info->thumbnail_path,           /**/
                content_info->media_meta.title,
                content_info->album_id,
                content_info->media_meta.album,
@@ -1157,7 +1145,7 @@ int _media_svc_insert_item_pass2(sqlite3 *handle, const char *storage_id, media_
                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.description,   /**/
                content_info->media_meta.bitrate,
                content_info->media_meta.bitpersample,
                content_info->media_meta.samplerate,
@@ -1197,7 +1185,7 @@ int _media_svc_insert_item_pass2(sqlite3 *handle, const char *storage_id, media_
                        return ret;
                }
        } else {
-               //media_svc_debug("query : %s", sql);
+               /*media_svc_debug("query : %s", sql);*/
                _media_svc_sql_query_add(&g_media_svc_update_item_query_list, &sql);
        }
 
index d258308..30d2c24 100755 (executable)
@@ -70,9 +70,8 @@ int _media_svc_get_mmc_info(MediaSvcHandle *handle, char **storage_name, char **
                *validity = 0;
                *info_exist = FALSE;
 
-               if (ret == MS_MEDIA_ERR_DB_NO_RECORD) {
+               if (ret == MS_MEDIA_ERR_DB_NO_RECORD)
                        *info_exist = FALSE;
-               }
 
                return ret;
        }
@@ -179,11 +178,10 @@ int _media_svc_update_storage_validity(sqlite3 *handle, const char *storage_id,
        int ret = MS_MEDIA_ERR_NONE;
        char *sql = NULL;
 
-       if (storage_id == NULL) {
+       if (storage_id == NULL)
                sql = sqlite3_mprintf("UPDATE '%s' SET validity=%d WHERE storage_uuid != 'media' AND storage_type != %d", MEDIA_SVC_DB_TABLE_STORAGE, validity, MEDIA_SVC_STORAGE_CLOUD);
-       } else {
+       else
                sql = sqlite3_mprintf("UPDATE '%s' SET validity=%d WHERE storage_uuid=%Q;", MEDIA_SVC_DB_TABLE_STORAGE, validity, storage_id);
-       }
 
        ret = _media_svc_sql_query(handle, sql, uid);
        sqlite3_free(sql);
@@ -200,8 +198,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;
        }
@@ -218,14 +215,10 @@ int _media_svc_get_storage_uuid(sqlite3 *handle, const char *path, char *storage
 
        storage_path = strndup(path, strlen(path) - remain_len);
 
-       while(sqlite3_step(sql_stmt) == SQLITE_ROW)
-       {
-               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 (strncmp(storage_path, (const char *)sqlite3_column_text(sql_stmt, 1), strlen(storage_path)) == 0)
-                               {
+       while (sqlite3_step(sql_stmt) == SQLITE_ROW)    {
+               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 (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,8 +230,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,8 +244,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,12 +254,11 @@ 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 {
+               else
                        media_svc_error("error when _media_svc_get_storage_type. err = [%d]", ret);
-               }
+
                return ret;
        }
 
@@ -285,8 +275,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,12 +285,11 @@ 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 {
+               else
                        media_svc_error("error when _media_svc_get_storage_type. err = [%d]", ret);
-               }
+
                return ret;
        }
 
@@ -318,8 +306,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,12 +316,11 @@ 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 {
+               else
                        media_svc_error("error when _media_svc_get_storage_scan_status. err = [%d]", ret);
-               }
+
                return ret;
        }
 
@@ -350,11 +336,10 @@ int _media_svc_set_storage_scan_status(sqlite3 *handle, const char *storage_id,
        int ret = MS_MEDIA_ERR_NONE;
        char *sql = NULL;
 
-       if (storage_id == NULL) {
+       if (storage_id == NULL)
                sql = sqlite3_mprintf("UPDATE '%s' SET scan_status=%d WHERE storage_uuid != 'media'", MEDIA_SVC_DB_TABLE_STORAGE, scan_status);
-       } else {
+       else
                sql = sqlite3_mprintf("UPDATE '%s' SET scan_status=%d WHERE storage_uuid=%Q", MEDIA_SVC_DB_TABLE_STORAGE, scan_status, storage_id);
-       }
 
        ret = _media_svc_sql_query(handle, sql, uid);
        sqlite3_free(sql);
@@ -387,7 +372,7 @@ int _media_svc_get_all_storage(sqlite3 *handle, char ***storage_list, char ***st
        int idx = 0;
        sqlite3_stmt *sql_stmt = NULL;
        char *sql = NULL;
-       int cnt =0;
+       int cnt = 0;
 
        ret = __media_svc_count_all_storage(handle, &cnt);
        if (ret != MS_MEDIA_ERR_NONE) {
@@ -431,8 +416,8 @@ int _media_svc_get_all_storage(sqlite3 *handle, char ***storage_list, char ***st
                media_svc_debug("OK");
        } else {
                /* free all data */
-               int i =0;
-               for (i = 0; i < idx; i ++) {
+               int i = 0;
+               for (i = 0; i < idx; i++) {
                        SAFE_FREE((*storage_list)[i]);
                        SAFE_FREE((*storage_id_list)[i]);
                }
index 2917497..7ebc658 100755 (executable)
@@ -72,7 +72,7 @@
        do { \
                value = iniparser_getint(dict, key, default); \
                media_svc_debug("get %s = %d", key, value); \
-       } while(0)
+       } while (0)
 #define MEDIA_SVC_INI_DEFAULT_PATH "/usr/etc/media_content_config.ini"
 
 static int g_ini_value = -1;
@@ -1009,9 +1009,9 @@ int _media_svc_set_default_value(media_svc_content_info_s *content_info, bool re
        }
 
        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;
@@ -2049,7 +2049,7 @@ int _media_svc_get_storage_type_by_path(const char *path, media_svc_storage_type
                        *storage_type = MEDIA_SVC_STORAGE_INTERNAL;
                } else if (STRING_VALID(MEDIA_ROOT_PATH_SDCARD) && (strncmp(path, MEDIA_ROOT_PATH_SDCARD, strlen(MEDIA_ROOT_PATH_SDCARD)) == 0)) {
                        *storage_type = MEDIA_SVC_STORAGE_EXTERNAL;
-               } else if (STRING_VALID(MEDIA_ROOT_PATH_USB) && (strncmp (path, MEDIA_ROOT_PATH_USB, strlen(MEDIA_ROOT_PATH_USB)) == 0)) {
+               } else if (STRING_VALID(MEDIA_ROOT_PATH_USB) && (strncmp(path, MEDIA_ROOT_PATH_USB, strlen(MEDIA_ROOT_PATH_USB)) == 0)) {
                        *storage_type = MEDIA_SVC_STORAGE_EXTERNAL_USB;
                } else {
                        media_svc_error("Invalid Path");
@@ -2162,7 +2162,7 @@ int _media_svc_get_ini_value()
                        return -1;
                }
 
-               MEDIA_SVC_INI_GET_INT(dict, "media-content-config:thumbnail_activation",g_ini_value, 0);
+               MEDIA_SVC_INI_GET_INT(dict, "media-content-config:thumbnail_activation", g_ini_value, 0);
                iniparser_freedict(dict);
        }
        media_svc_debug("Thumb-server activation level = %d", g_ini_value);
index 4b378e8..0501b91 100755 (executable)
@@ -53,10 +53,10 @@ static __thread int g_insert_with_noti = FALSE;
 
 #define DEFAULT_MEDIA_SVC_STORAGE_ID "media"
 
-typedef struct{
+typedef struct {
        int media_type;
        char *path;
-}media_svc_item_info_s;
+} media_svc_item_info_s;
 
 static bool __media_svc_check_storage(media_svc_storage_type_e storage_type, bool check_all)
 {
@@ -239,9 +239,8 @@ int media_svc_insert_item_begin(MediaSvcHandle *handle, int data_cnt, int with_n
        /* Prepare for making noti item list */
        if (with_noti) {
                media_svc_debug("making noti list from pid[%d]", from_pid);
-               if (_media_svc_create_noti_list(data_cnt) != MS_MEDIA_ERR_NONE) {
+               if (_media_svc_create_noti_list(data_cnt) != MS_MEDIA_ERR_NONE)
                        return MS_MEDIA_ERR_OUT_OF_MEMORY;
-               }
 
                _media_svc_set_noti_from_pid(from_pid);
                g_insert_with_noti = TRUE;
@@ -295,9 +294,8 @@ int media_svc_insert_item_bulk(MediaSvcHandle *handle, const char *storage_id, m
        /*Set media info*/
        /* if drm_contentinfo is not NULL, the file is OMA DRM.*/
        ret = _media_svc_set_media_info(&content_info, storage_id, storage_type, path, &media_type, FALSE);
-       if (ret != MS_MEDIA_ERR_NONE) {
+       if (ret != MS_MEDIA_ERR_NONE)
                return ret;
-       }
 
        if (media_type == MEDIA_SVC_MEDIA_TYPE_OTHER) {
                /*Do nothing.*/
@@ -414,9 +412,8 @@ int media_svc_insert_item_immediately(MediaSvcHandle *handle, const char *storag
                                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;
@@ -491,11 +488,11 @@ int media_svc_move_item(MediaSvcHandle *handle, const char *storage_id, media_sv
 
                /* If old thumb path is default or not */
                char *default_thumbnail_path = _media_svc_get_thumb_default_path(uid);
-               if (STRING_VALID(default_thumbnail_path) && (strncmp(old_thumb_path, default_thumbnail_path, strlen(default_thumbnail_path)) == 0)) {
+               if (STRING_VALID(default_thumbnail_path) && (strncmp(old_thumb_path, default_thumbnail_path, strlen(default_thumbnail_path)) == 0))
                        strncpy(new_thumb_path, default_thumbnail_path, sizeof(new_thumb_path));
-               } else {
+               else
                        _media_svc_get_thumbnail_path(dest_storage, new_thumb_path, dest_path, THUMB_EXT, uid);
-               }
+
                SAFE_FREE(default_thumbnail_path);
        }
 
@@ -1473,7 +1470,7 @@ static int __media_svc_copy_para_to_content(media_svc_content_info_s *content_in
                new_content_info->added_time = content_info->added_time;
        new_content_info->last_played_time = content_info->last_played_time;
        new_content_info->played_count = content_info->played_count;
-       new_content_info->favourate= content_info->favourate;
+       new_content_info->favourate = content_info->favourate;
 
        if (STRING_VALID(content_info->file_name)) {
                        ret = __media_svc_malloc_and_strncpy(&new_content_info->file_name, content_info->file_name);
@@ -1923,7 +1920,7 @@ int media_svc_insert_folder(MediaSvcHandle *handle, const char *storage_id, medi
                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 ++;
+               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)) {
 
@@ -2014,7 +2011,7 @@ int media_svc_insert_item_pass1(MediaSvcHandle *handle, const char *storage_id,
                        _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 ++;
+               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)) {
 
@@ -2103,7 +2100,7 @@ int media_svc_insert_item_pass2(MediaSvcHandle *handle, const char *storage_id,
                }
 
                db_data->path = g_strdup((const char *)sqlite3_column_text(sql_stmt, 0));
-               db_data->media_type = (int)sqlite3_column_int(sql_stmt,1);
+               db_data->media_type = (int)sqlite3_column_int(sql_stmt, 1);
 
                g_array_append_val(db_data_array, db_data);
        }
@@ -2113,9 +2110,9 @@ int media_svc_insert_item_pass2(MediaSvcHandle *handle, const char *storage_id,
        while (db_data_array->len != 0) {
                db_data = NULL;
                db_data = g_array_index(db_data_array, media_svc_item_info_s*, 0);
-               g_array_remove_index (db_data_array, 0);
+               g_array_remove_index(db_data_array, 0);
 
-               if ((db_data == NULL) ||(db_data->path == NULL)) {
+               if ((db_data == NULL) || (db_data->path == NULL)) {
                        media_svc_error("invalid db data");
                        continue;
                }
index 6d9e1d1..9ac5888 100755 (executable)
@@ -56,7 +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;
        }