Apply tizen coding rule 36/57936/1 accepted/tizen/ivi/20160218.022803 accepted/tizen/mobile/20160127.073128 accepted/tizen/tv/20160127.073131 accepted/tizen/wearable/20160127.073136 submit/tizen/20160127.062844 submit/tizen/20160127.062912 submit/tizen/20160127.071037 submit/tizen_common/20160218.142243 submit/tizen_ivi/20160217.000000 submit/tizen_ivi/20160217.000001
authorHaejeong Kim <backto.kim@samsung.com>
Tue, 26 Jan 2016 06:59:35 +0000 (15:59 +0900)
committerHaejeong Kim <backto.kim@samsung.com>
Tue, 26 Jan 2016 06:59:50 +0000 (15:59 +0900)
Change-Id: I5ec1f2932d8bc06e948342bbe479251424913d8e

src/media_content.c
src/media_db.c
src/media_filter.c
src/media_playlist.c
src/media_tag.c
src/media_util_private.c
test/media-content_test.c

index 4c19295..81d22b8 100755 (executable)
@@ -580,22 +580,19 @@ int _content_query_prepare(sqlite3_stmt **stmt, char *select_query, char *condit
        media_content_retvm_if(db_handle == NULL, MEDIA_CONTENT_ERROR_DB_FAILED, "database is not connected");
        media_content_retvm_if(!STRING_VALID(select_query), MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "invalid select_query");
 
-       if (!STRING_VALID(condition_query)) {
+       if (!STRING_VALID(condition_query))
                condition_query = (char *)" ";
-       }
 
-       if (!STRING_VALID(option_query)) {
+       if (!STRING_VALID(option_query))
                option_query = (char *)" ";
 
-       }
-
-       //query = sqlite3_mprintf("%s %s %s", select_query, condition_query, option_query);
+       /*query = sqlite3_mprintf("%s %s %s", select_query, condition_query, option_query);*/
        len = snprintf(query, sizeof(query), "%s %s %s", select_query, condition_query, option_query);
-       if (len > 0 && len < MAX_QUERY_SIZE) {
+       if (len > 0 && len < MAX_QUERY_SIZE)
                query[len] = '\0';
-       } else if (len >= MAX_QUERY_SIZE) {
+       else if (len >= MAX_QUERY_SIZE)
                query[MAX_QUERY_SIZE -1] = '\0';
-       else {
+       else {
                media_content_error("snprintf failed");
                return MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
        }
@@ -623,9 +620,8 @@ int _content_query_prepare(sqlite3_stmt **stmt, char *select_query, char *condit
 
 int _content_error_capi(int type, int content_error)
 {
-       if (content_error != MEDIA_CONTENT_ERROR_NONE) {
+       if (content_error != MEDIA_CONTENT_ERROR_NONE)
                media_content_error("[type : %d] content_error : %d ", type, content_error);
-       }
 
        /*Error None*/
        if (content_error == MS_MEDIA_ERR_NONE)
@@ -667,7 +663,7 @@ int _content_query_sql(char *query_str)
 {
        int ret = MEDIA_CONTENT_ERROR_NONE;
 
-       //DB will be updated by Media Server.
+       /*DB will be updated by Media Server.*/
        ret = media_svc_request_update_db(query_str, tzplatform_getuid(TZ_USER_NAME));
 
        return _content_error_capi(MEDIA_CONTENT_TYPE, ret);
@@ -686,11 +682,11 @@ int media_content_connect(void)
                                if (ret == MEDIA_CONTENT_ERROR_NONE) {
                                        ret = media_svc_connect(&db_handle, tzplatform_getuid(TZ_USER_NAME), false);
                                        ret = _content_error_capi(MEDIA_CONTENT_TYPE, ret);
-                                       if (ret == MEDIA_CONTENT_ERROR_NONE) {
+                                       if (ret == MEDIA_CONTENT_ERROR_NONE)
                                                ref_count++;
-                                       } else {
+                                       else
                                                __media_content_destroy_attribute_handle();
-                                       }
+
                                } else {
                                        media_content_error("Internal DB Connection Error");
                                }
@@ -877,11 +873,10 @@ static int __media_content_check_dir(const char *path)
                media_content_sec_error("path [%s]", path);
                media_content_stderror("open dir fail");
 
-               if (errno == EACCES || errno == EPERM) {
+               if (errno == EACCES || errno == EPERM)
                        return MEDIA_CONTENT_ERROR_PERMISSION_DENIED;
-               } else {
+               else
                        return MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
-               }
        }
 
        closedir(dp);
@@ -921,9 +916,8 @@ int media_content_scan_folder(const char *path, bool is_recursive, media_scan_co
        /*FIX ME. need to check ret value?*/
 
        ret = media_directory_scanning_async(path, storage_id, is_recursive, _media_content_scan_cb, cb_data, tzplatform_getuid(TZ_USER_NAME));
-       if (ret != MS_MEDIA_ERR_NONE) {
+       if (ret != MS_MEDIA_ERR_NONE)
                media_content_error("media_directory_scanning_async failed : %d", ret);
-       }
 
        return _content_error_capi(MEDIA_REGISTER_TYPE, ret);
 }
@@ -933,9 +927,8 @@ int media_content_cancel_scan_folder(const char *path)
        int ret = MEDIA_CONTENT_ERROR_NONE;
 
        ret = media_directory_scanning_cancel(path, tzplatform_getuid(TZ_USER_NAME));
-       if (ret != MS_MEDIA_ERR_NONE) {
+       if (ret != MS_MEDIA_ERR_NONE)
                media_content_error("media_directory_scanning_async failed : %d", ret);
-       }
 
        return _content_error_capi(MEDIA_REGISTER_TYPE, ret);
 }
index 98984f2..d809330 100755 (executable)
@@ -24,66 +24,66 @@ static int __media_db_make_query(filter_h filter, attribute_h attr, char *select
 static char * __media_db_get_group_name(media_group_e group)
 {
        switch (group) {
-               case MEDIA_CONTENT_GROUP_DISPLAY_NAME:
-                       return (char *)DB_FIELD_MEDIA_DISPLAY_NAME;
-               case MEDIA_CONTENT_GROUP_TYPE:
-                       return (char *)DB_FIELD_MEDIA_TYPE;
-               case MEDIA_CONTENT_GROUP_MIME_TYPE:
-                       return (char *) DB_FIELD_MEDIA_MIME_TYPE;
-               case MEDIA_CONTENT_GROUP_SIZE:
-                       return (char *) DB_FIELD_MEDIA_SIZE;
-               case MEDIA_CONTENT_GROUP_ADDED_TIME:
-                       return (char *) DB_FIELD_MEDIA_ADDED_TIME;
-               case MEDIA_CONTENT_GROUP_MODIFIED_TIME:
-                       return (char *) DB_FIELD_MEDIA_MODIFIED_TIME;
-               case MEDIA_CONTENT_GROUP_TITLE:
-                       return (char *) DB_FIELD_MEDIA_TITLE;
-               case MEDIA_CONTENT_GROUP_ARTIST:
-                       return (char *) DB_FIELD_MEDIA_ARTIST;
-               case MEDIA_CONTENT_GROUP_ALBUM_ARTIST:
-                       return (char *) DB_FIELD_MEDIA_ALBUM_ARTIST;
-               case MEDIA_CONTENT_GROUP_GENRE:
-                       return (char *) DB_FIELD_MEDIA_GENRE;
-               case MEDIA_CONTENT_GROUP_COMPOSER:
-                       return (char *) DB_FIELD_MEDIA_COMPOSER;
-               case MEDIA_CONTENT_GROUP_YEAR:
-                       return (char *) DB_FIELD_MEDIA_YEAR;
-               case MEDIA_CONTENT_GROUP_RECORDED_DATE:
-                       return (char *) DB_FIELD_MEDIA_RECORDED_DATE;
-               case MEDIA_CONTENT_GROUP_COPYRIGHT:
-                       return (char *) DB_FIELD_MEDIA_COPYRIGHT;
-               case MEDIA_CONTENT_GROUP_TRACK_NUM:
-                       return (char *) DB_FIELD_MEDIA_TRACK_NUM;
-               case MEDIA_CONTENT_GROUP_DESCRIPTION:
-                       return (char *) DB_FIELD_MEDIA_DESCRIPTION;
-               case MEDIA_CONTENT_GROUP_LONGITUDE:
-                       return (char *) DB_FIELD_MEDIA_LONGITUDE;
-               case MEDIA_CONTENT_GROUP_LATITUDE:
-                       return (char *) DB_FIELD_MEDIA_LATITUDE;
-               case MEDIA_CONTENT_GROUP_ALTITUDE:
-                       return (char *) DB_FIELD_MEDIA_ALTITUDE;
-               case MEDIA_CONTENT_GROUP_BURST_IMAGE:
-                       return (char *) DB_FIELD_MEDIA_BURST_ID;
-               case MEDIA_CONTENT_GROUP_RATING:
-                       return (char *) DB_FIELD_MEDIA_RATING;
-               case MEDIA_CONTENT_GROUP_AUTHOR:
-                       return (char *) DB_FIELD_MEDIA_AUTHOR;
-               case MEDIA_CONTENT_GROUP_PROVIDER:
-                       return (char *) DB_FIELD_MEDIA_PROVIDER;
-               case MEDIA_CONTENT_GROUP_CONTENT_NAME:
-                       return (char *) DB_FIELD_MEDIA_CONTENT_NAME;
-               case MEDIA_CONTENT_GROUP_CATEGORY:
-                       return (char *) DB_FIELD_MEDIA_CATEGORY;
-               case MEDIA_CONTENT_GROUP_LOCATION_TAG:
-                       return (char *) DB_FIELD_MEDIA_LOCATION_TAG;
-               case MEDIA_CONTENT_GROUP_AGE_RATING:
-                       return (char *) DB_FIELD_MEDIA_AGE_RATING;
-               case MEDIA_CONTENT_GROUP_KEYWORD:
-                       return (char *) DB_FIELD_MEDIA_KEYWORD;
-               case MEDIA_CONTENT_GROUP_WEATHER:
-                       return (char *) DB_FIELD_MEDIA_WEATHER;
-               default:
-                       return NULL;
+       case MEDIA_CONTENT_GROUP_DISPLAY_NAME:
+               return (char *)DB_FIELD_MEDIA_DISPLAY_NAME;
+       case MEDIA_CONTENT_GROUP_TYPE:
+               return (char *)DB_FIELD_MEDIA_TYPE;
+       case MEDIA_CONTENT_GROUP_MIME_TYPE:
+               return (char *) DB_FIELD_MEDIA_MIME_TYPE;
+       case MEDIA_CONTENT_GROUP_SIZE:
+               return (char *) DB_FIELD_MEDIA_SIZE;
+       case MEDIA_CONTENT_GROUP_ADDED_TIME:
+               return (char *) DB_FIELD_MEDIA_ADDED_TIME;
+       case MEDIA_CONTENT_GROUP_MODIFIED_TIME:
+               return (char *) DB_FIELD_MEDIA_MODIFIED_TIME;
+       case MEDIA_CONTENT_GROUP_TITLE:
+               return (char *) DB_FIELD_MEDIA_TITLE;
+       case MEDIA_CONTENT_GROUP_ARTIST:
+               return (char *) DB_FIELD_MEDIA_ARTIST;
+       case MEDIA_CONTENT_GROUP_ALBUM_ARTIST:
+               return (char *) DB_FIELD_MEDIA_ALBUM_ARTIST;
+       case MEDIA_CONTENT_GROUP_GENRE:
+               return (char *) DB_FIELD_MEDIA_GENRE;
+       case MEDIA_CONTENT_GROUP_COMPOSER:
+               return (char *) DB_FIELD_MEDIA_COMPOSER;
+       case MEDIA_CONTENT_GROUP_YEAR:
+               return (char *) DB_FIELD_MEDIA_YEAR;
+       case MEDIA_CONTENT_GROUP_RECORDED_DATE:
+               return (char *) DB_FIELD_MEDIA_RECORDED_DATE;
+       case MEDIA_CONTENT_GROUP_COPYRIGHT:
+               return (char *) DB_FIELD_MEDIA_COPYRIGHT;
+       case MEDIA_CONTENT_GROUP_TRACK_NUM:
+               return (char *) DB_FIELD_MEDIA_TRACK_NUM;
+       case MEDIA_CONTENT_GROUP_DESCRIPTION:
+               return (char *) DB_FIELD_MEDIA_DESCRIPTION;
+       case MEDIA_CONTENT_GROUP_LONGITUDE:
+               return (char *) DB_FIELD_MEDIA_LONGITUDE;
+       case MEDIA_CONTENT_GROUP_LATITUDE:
+               return (char *) DB_FIELD_MEDIA_LATITUDE;
+       case MEDIA_CONTENT_GROUP_ALTITUDE:
+               return (char *) DB_FIELD_MEDIA_ALTITUDE;
+       case MEDIA_CONTENT_GROUP_BURST_IMAGE:
+               return (char *) DB_FIELD_MEDIA_BURST_ID;
+       case MEDIA_CONTENT_GROUP_RATING:
+               return (char *) DB_FIELD_MEDIA_RATING;
+       case MEDIA_CONTENT_GROUP_AUTHOR:
+               return (char *) DB_FIELD_MEDIA_AUTHOR;
+       case MEDIA_CONTENT_GROUP_PROVIDER:
+               return (char *) DB_FIELD_MEDIA_PROVIDER;
+       case MEDIA_CONTENT_GROUP_CONTENT_NAME:
+               return (char *) DB_FIELD_MEDIA_CONTENT_NAME;
+       case MEDIA_CONTENT_GROUP_CATEGORY:
+               return (char *) DB_FIELD_MEDIA_CATEGORY;
+       case MEDIA_CONTENT_GROUP_LOCATION_TAG:
+               return (char *) DB_FIELD_MEDIA_LOCATION_TAG;
+       case MEDIA_CONTENT_GROUP_AGE_RATING:
+               return (char *) DB_FIELD_MEDIA_AGE_RATING;
+       case MEDIA_CONTENT_GROUP_KEYWORD:
+               return (char *) DB_FIELD_MEDIA_KEYWORD;
+       case MEDIA_CONTENT_GROUP_WEATHER:
+               return (char *) DB_FIELD_MEDIA_WEATHER;
+       default:
+               return NULL;
        }
 
        return NULL;
@@ -140,69 +140,69 @@ int _media_db_get_group_count(filter_h filter, group_list_e group_type, int *gro
        memset(select_query, 0x00, sizeof(select_query));
 
        switch (group_type) {
-               case MEDIA_GROUP_NONE:
-               case MEDIA_GROUP_TAG_BY_MEDIA_ID:
-               case MEDIA_GROUP_BOOKMARK_BY_MEDIA_ID:
-                       {
-                               media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
-                               return MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
-                       }
-                       break;
-               case MEDIA_GROUP_ALBUM:
-                       attr = _content_get_alias_attirbute_handle();
+       case MEDIA_GROUP_NONE:
+       case MEDIA_GROUP_TAG_BY_MEDIA_ID:
+       case MEDIA_GROUP_BOOKMARK_BY_MEDIA_ID:
+               {
+                       media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
+                       return MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
+               }
+               break;
+       case MEDIA_GROUP_ALBUM:
+               attr = _content_get_alias_attirbute_handle();
 
-                       if ((_filter != NULL) && STRING_VALID(_filter->storage_id))
-                               snprintf(select_query, sizeof(select_query), SELECT_ALBUM_COUNT, _filter->storage_id);
-                       else
-                               snprintf(select_query, sizeof(select_query), SELECT_ALBUM_COUNT, DB_TABLE_MEDIA_VIEW);
+               if ((_filter != NULL) && STRING_VALID(_filter->storage_id))
+                       snprintf(select_query, sizeof(select_query), SELECT_ALBUM_COUNT, _filter->storage_id);
+               else
+                       snprintf(select_query, sizeof(select_query), SELECT_ALBUM_COUNT, DB_TABLE_MEDIA_VIEW);
 
-                       break;
-               case MEDIA_GROUP_FOLDER:
-                       attr = _content_get_alias_attirbute_handle();
-                       if (!SAFE_STRLCPY(select_query, SELECT_FOLDER_COUNT, sizeof(select_query))) {
-                               media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
-                               return MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
-                       }
-
-                       if ((_filter != NULL) && STRING_VALID(_filter->storage_id))
-                               snprintf(select_query, sizeof(select_query), SELECT_FOLDER_COUNT_BY_STORAGE_ID, _filter->storage_id, _filter->storage_id);
-                       else
-                               snprintf(select_query, sizeof(select_query), SELECT_FOLDER_COUNT, DB_TABLE_MEDIA_VIEW);
+               break;
+       case MEDIA_GROUP_FOLDER:
+               attr = _content_get_alias_attirbute_handle();
+               if (!SAFE_STRLCPY(select_query, SELECT_FOLDER_COUNT, sizeof(select_query))) {
+                       media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
+                       return MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
+               }
 
-                       break;
-               case MEDIA_GROUP_PLAYLIST:
-                       if (!SAFE_STRLCPY(select_query, SELECT_PLAYLIST_COUNT, sizeof(select_query))) {
-                               media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
-                               return MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
-                       }
-                       break;
-               case MEDIA_GROUP_TAG:
-                       if (!SAFE_STRLCPY(select_query, SELECT_TAG_COUNT, sizeof(select_query))) {
-                               media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
-                               return MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
-                       }
-                       break;
-               case MEDIA_GROUP_BOOKMARK:
-                       attr = _content_get_alias_attirbute_handle();
+               if ((_filter != NULL) && STRING_VALID(_filter->storage_id))
+                       snprintf(select_query, sizeof(select_query), SELECT_FOLDER_COUNT_BY_STORAGE_ID, _filter->storage_id, _filter->storage_id);
+               else
+                       snprintf(select_query, sizeof(select_query), SELECT_FOLDER_COUNT, DB_TABLE_MEDIA_VIEW);
 
-                       if ((_filter != NULL) && STRING_VALID(_filter->storage_id))
-                               snprintf(select_query, sizeof(select_query), SELECT_BOOKMARK_COUNT, _filter->storage_id);
-                       else
-                               snprintf(select_query, sizeof(select_query), SELECT_BOOKMARK_COUNT, DB_TABLE_MEDIA_VIEW);
+               break;
+       case MEDIA_GROUP_PLAYLIST:
+               if (!SAFE_STRLCPY(select_query, SELECT_PLAYLIST_COUNT, sizeof(select_query))) {
+                       media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
+                       return MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
+               }
+               break;
+       case MEDIA_GROUP_TAG:
+               if (!SAFE_STRLCPY(select_query, SELECT_TAG_COUNT, sizeof(select_query))) {
+                       media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
+                       return MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
+               }
+               break;
+       case MEDIA_GROUP_BOOKMARK:
+               attr = _content_get_alias_attirbute_handle();
 
-                       break;
-               case MEDIA_GROUP_STORAGE:
-                       if (!SAFE_STRLCPY(select_query, SELECT_STORAGE_COUNT, sizeof(select_query))) {
-                               media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
-                               return MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
-                       }
-                       break;
-               default:
-                       {
-                               media_content_error("Invalid group type [%d]", group_type);
-                               return MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
-                       }
-                       break;
+               if ((_filter != NULL) && STRING_VALID(_filter->storage_id))
+                       snprintf(select_query, sizeof(select_query), SELECT_BOOKMARK_COUNT, _filter->storage_id);
+               else
+                       snprintf(select_query, sizeof(select_query), SELECT_BOOKMARK_COUNT, DB_TABLE_MEDIA_VIEW);
+
+               break;
+       case MEDIA_GROUP_STORAGE:
+               if (!SAFE_STRLCPY(select_query, SELECT_STORAGE_COUNT, sizeof(select_query))) {
+                       media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
+                       return MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
+               }
+               break;
+       default:
+               {
+                       media_content_error("Invalid group type [%d]", group_type);
+                       return MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
+               }
+               break;
        }
 
        ret = __media_db_make_query(filter, attr, select_query, sizeof(select_query), &condition_query, &option_query);
@@ -213,9 +213,8 @@ int _media_db_get_group_count(filter_h filter, group_list_e group_type, int *gro
        SAFE_FREE(option_query);
        media_content_retv_if(ret != MEDIA_CONTENT_ERROR_NONE, ret);
 
-       while (sqlite3_step(stmt) == SQLITE_ROW) {
+       while (sqlite3_step(stmt) == SQLITE_ROW)
                *group_count = (int)sqlite3_column_int(stmt, 0);
-       }
 
        SQLITE3_FINALIZE(stmt);
 
@@ -258,9 +257,8 @@ int _media_db_get_media_group_count(media_group_e group, filter_h filter, int *g
        SAFE_FREE(option_query);
        media_content_retv_if(ret != MEDIA_CONTENT_ERROR_NONE, ret);
 
-       while (sqlite3_step(stmt) == SQLITE_ROW) {
+       while (sqlite3_step(stmt) == SQLITE_ROW)
                *group_count = (int)sqlite3_column_int(stmt, 0);
-       }
 
        SQLITE3_FINALIZE(stmt);
 
@@ -483,7 +481,7 @@ int _media_db_get_playlist_item(int playlist_id, filter_h filter, playlist_membe
        attr = _content_get_attirbute_handle();
        memset(select_query, 0x00, sizeof(select_query));
 
-       //snprintf(select_query, sizeof(select_query), SELECT_PLAYLIST_ITEM_ID_FROM_PLAYLIST_VIEW, playlist_id);
+       /*snprintf(select_query, sizeof(select_query), SELECT_PLAYLIST_ITEM_ID_FROM_PLAYLIST_VIEW, playlist_id);*/
        snprintf(select_query, sizeof(select_query), SELECT_PLAYLIST_ITEM_ALL_FROM_PLAYLIST_VIEW, playlist_id);
 
        ret = __media_db_make_query(filter, attr, select_query, sizeof(select_query), &condition_query, &option_query);
@@ -496,7 +494,7 @@ int _media_db_get_playlist_item(int playlist_id, filter_h filter, playlist_membe
 
        while (sqlite3_step(stmt) == SQLITE_ROW) {
                int playlist_member_id = 0;
-               playlist_member_id = (int)sqlite3_column_int(stmt, MEDIA_INFO_ITEM_MAX);        //MEDIA_INFO_ITEM_MAX is pm_id
+               playlist_member_id = (int)sqlite3_column_int(stmt, MEDIA_INFO_ITEM_MAX);        /*MEDIA_INFO_ITEM_MAX is pm_id*/
 
                media_info_s *_media = (media_info_s*)calloc(1, sizeof(media_info_s));
 
@@ -820,9 +818,8 @@ int _media_db_get_group_item_count(const char *group_name, filter_h filter, grou
        SAFE_FREE(option_query);
        media_content_retv_if(ret != MEDIA_CONTENT_ERROR_NONE, ret);
 
-       while (sqlite3_step(stmt) == SQLITE_ROW) {
+       while (sqlite3_step(stmt) == SQLITE_ROW)
                *item_count = (int)sqlite3_column_int(stmt, 0);
-       }
 
        SQLITE3_FINALIZE(stmt);
 
@@ -1007,9 +1004,8 @@ int _media_db_get_media_group_item_count(const char *group_name, filter_h filter
        SAFE_FREE(option_query);
        media_content_retv_if(ret != MEDIA_CONTENT_ERROR_NONE, ret);
 
-       while (sqlite3_step(stmt) == SQLITE_ROW) {
+       while (sqlite3_step(stmt) == SQLITE_ROW)
                *item_count = (int)sqlite3_column_int(stmt, 0);
-       }
 
        SQLITE3_FINALIZE(stmt);
 
index 667302d..c3ed4de 100755 (executable)
@@ -81,28 +81,28 @@ static bool __is_pinyin_needed(void)
 static char *__get_order_str(media_content_order_e order_enum)
 {
        switch (order_enum) {
-               case MEDIA_CONTENT_ORDER_ASC:
-                       return (char *)"ASC";
-               case MEDIA_CONTENT_ORDER_DESC:
-                       return (char *)"DESC";
-               default:
-                       return (char *)" ";
+       case MEDIA_CONTENT_ORDER_ASC:
+               return (char *)"ASC";
+       case MEDIA_CONTENT_ORDER_DESC:
+               return (char *)"DESC";
+       default:
+               return (char *)" ";
        }
 }
 
 static char *__get_collate_str(media_content_collation_e collate_type)
 {
        switch (collate_type) {
-               case MEDIA_CONTENT_COLLATE_NOCASE:
+       case MEDIA_CONTENT_COLLATE_NOCASE:
+               return (char *)"NOCASE";
+       case MEDIA_CONTENT_COLLATE_RTRIM:
+               return (char *)"RTRIM";
+       case MEDIA_CONTENT_COLLATE_LOCALIZED:
+               if (__is_pinyin_needed())
                        return (char *)"NOCASE";
-               case MEDIA_CONTENT_COLLATE_RTRIM:
-                       return (char *)"RTRIM";
-               case MEDIA_CONTENT_COLLATE_LOCALIZED:
-                       if (__is_pinyin_needed())
-                               return (char *)"NOCASE";
-                       else
-                               return (char *)"localized";
-               default: return (char *)" ";
+               else
+                       return (char *)"localized";
+       default: return (char *)" ";
        }
 }
 
@@ -119,8 +119,8 @@ static char *__media_filter_replace_attr(attribute_h attr, char *name)
        attribute_s *_attr = (attribute_s *)attr;
 
        if (!g_hash_table_lookup_extended(_attr->attr_map, name, (gpointer)&key_temp, (gpointer)&generated_value)) {
-               //can't find the value
-               //media_content_error("NOT_FOUND_VALUE(%s)", name);
+               /* can't find the value */
+               /* media_content_error("NOT_FOUND_VALUE(%s)", name); */
                return NULL;
        }
 
@@ -146,7 +146,7 @@ static int __tokenize_operator(token_t *token, const char *str, int op_type)
                media_content_retvm_if(token->str == NULL, -1, "OUT_OF_MEMORY");
 
                strncpy(token->str, tmp, token_size);
-               //media_content_debug("type : [%d] str : [%s]", token->type, token->str);
+               /*media_content_debug("type : [%d] str : [%s]", token->type, token->str);*/
                ret = token_size;
        } else {
                ret = -1;
@@ -166,7 +166,7 @@ static int __tokenize_string(token_t *token, const char *str, int size)
 
                token->type = UNKNOWN_TYPE;
                strncpy(token->str, tmp, size);
-               //media_content_debug("type : [%d] str : [%s]", token->type, token->str);
+               /*media_content_debug("type : [%d] str : [%s]", token->type, token->str);*/
        } else {
                ret = -1;
        }
@@ -185,9 +185,9 @@ static int __tokenize_attribute(GList **token_list, const char *str)
        const char *dst_ptr = str + strlen(str);
 
        for (idx = 0; (*(tmp+idx)) && (tmp < dst_ptr); idx++) {
-               //media_content_debug("[%d] '%c'", idx, tmp[idx]);
-               if (tmp[idx] == ' ') {          //" "
-                       if (idx == 0) {         // ignore the space.
+               /*media_content_debug("[%d] '%c'", idx, tmp[idx]);*/
+               if (tmp[idx] == ' ') {          /* " " */
+                       if (idx == 0) {         /* ignore the space. */
                                tmp++;
                                idx = -1;
                                continue;
@@ -203,11 +203,11 @@ static int __tokenize_attribute(GList **token_list, const char *str)
                                return -1;
                        }
                        strncpy(token->str, tmp, idx);
-                       //media_content_debug("type : [%d] str : [%s]", token->type, token->str);
+                       /*media_content_debug("type : [%d] str : [%s]", token->type, token->str);*/
                        *token_list = g_list_append(*token_list, token);
                        tmp = tmp +idx + strlen(media_token[0]);
                        idx = -1;
-               } else if (tmp[idx] == ',') {   // " , "
+               } else if (tmp[idx] == ',') {   /* " , " */
                        if (idx != 0) {
                                token_t *token = (token_t*)calloc(1, sizeof(token_t));
                                media_content_retvm_if(token == NULL, -1, "OUT_OF_MEMORY");
@@ -238,7 +238,7 @@ static int __tokenize_attribute(GList **token_list, const char *str)
                }
        }
 
-       if (*tmp) {                     //remained string
+       if (*tmp) {                     /* remained string */
                token_t *token = (token_t*)calloc(1, sizeof(token_t));
                media_content_retvm_if(token == NULL, -1, "OUT_OF_MEMORY");
 
@@ -272,9 +272,9 @@ static int __tokenize(GList **token_list, const char *str)
        const char *dst_ptr = str + strlen(str);
 
        for (idx = 0; (*(tmp+idx)) && (tmp < dst_ptr); idx++) {
-               //media_content_debug("[%d] '%c'", idx, tmp[idx]);
-               if (tmp[idx] == media_token[0][0]) {            //" "
-                       if (idx == 0) {         // ignore the space.
+               /* media_content_debug("[%d] '%c'", idx, tmp[idx]); */
+               if (tmp[idx] == media_token[0][0]) {            /* " " */
+                       if (idx == 0) {         /* ignore the space. */
                                tmp++;
                                idx = -1;
                                continue;
@@ -291,14 +291,14 @@ static int __tokenize(GList **token_list, const char *str)
                                return -1;
                        }
                        strncpy(token->str, tmp, idx);
-                       //media_content_debug("type : [%d] str : [%s]", token->type, token->str);
+                       /* media_content_debug("type : [%d] str : [%s]", token->type, token->str); */
                        *token_list = g_list_append(*token_list, token);
                        tmp = tmp +idx + strlen(media_token[0]);
                        idx = -1;
-               } else if (tmp[idx] == media_token[1][0]) {     // " \" "
+               } else if (tmp[idx] == media_token[1][0]) {     /* " \" " */
                        int j;
                        bool flag = false;
-                       for (j = idx+1; tmp[j]; j++) {  //find next quotation
+                       for (j = idx+1; tmp[j]; j++) {  /* find next quotation */
                                if (tmp[j] == media_token[1][0] && tmp[j+1] == media_token[1][0]) {
                                        j += 1;
                                        continue;
@@ -315,7 +315,7 @@ static int __tokenize(GList **token_list, const char *str)
                                        }
                                        token->type = STRING_TYPE;
                                        strncpy(token->str, tmp, j+1);
-                                       //media_content_debug("type : [%d] str : [%s], j : %d", token->type, token->str, j);
+                                       /* media_content_debug("type : [%d] str : [%s], j : %d", token->type, token->str, j); */
                                        *token_list = g_list_append(*token_list, token);
                                        tmp = tmp + strlen(token->str);
                                        idx = -1;
@@ -336,12 +336,12 @@ static int __tokenize(GList **token_list, const char *str)
                                }
                                token->type = UNKNOWN_TYPE;
                                strncpy(token->str, tmp, j);
-                               //media_content_debug("type : [%d] str : [%s]", token->type, token->str);
+                               /* media_content_debug("type : [%d] str : [%s]", token->type, token->str);*/
                                *token_list = g_list_append(*token_list, token);
                                tmp = tmp +strlen(token->str);
                                idx = -1;
                        }
-               } else if (tmp[idx] == media_token[2][0]) {     // " \' "
+               } else if (tmp[idx] == media_token[2][0]) {     /* " \' "*/
                        int j;
                        bool flag = false;
                        for (j = idx+1; tmp[j]; j++) {
@@ -361,7 +361,7 @@ static int __tokenize(GList **token_list, const char *str)
                                        }
                                        token->type = STRING_TYPE;
                                        strncpy(token->str, tmp, j+1);
-                                       //media_content_debug("type : [%d] str : [%s]", token->type, token->str);
+                                       /* media_content_debug("type : [%d] str : [%s]", token->type, token->str); */
                                        *token_list = g_list_append(*token_list, token);
                                        tmp = tmp + strlen(token->str);
                                        idx = -1;
@@ -382,12 +382,12 @@ static int __tokenize(GList **token_list, const char *str)
                                }
                                token->type = UNKNOWN_TYPE;
                                strncpy(token->str, tmp, j);
-                               //media_content_debug("type : [%d] str : [%s]", token->type, token->str);
+                               /* media_content_debug("type : [%d] str : [%s]", token->type, token->str); */
                                *token_list = g_list_append(*token_list, token);
                                tmp = tmp + strlen(token->str);
                                idx = -1;
                        }
-               } else if (tmp[idx] == media_token[3][0]) {     //"("
+               } else if (tmp[idx] == media_token[3][0]) {     /* "(" */
                        if (idx != 0) {
                                token_t *token = (token_t*)calloc(1, sizeof(token_t));
                                media_content_retvm_if(token == NULL, -1, "OUT_OF_MEMORY");
@@ -415,7 +415,7 @@ static int __tokenize(GList **token_list, const char *str)
                                return -1;
                        }
 
-               } else if (tmp[idx] == media_token[4][0]) {     //")"
+               } else if (tmp[idx] == media_token[4][0]) {     /* ")" */
                        if (idx != 0) {
                                token_t *token = (token_t*)calloc(1, sizeof(token_t));
                                media_content_retvm_if(token == NULL, -1, "OUT_OF_MEMORY");
@@ -443,7 +443,7 @@ static int __tokenize(GList **token_list, const char *str)
                                return -1;
                        }
 
-               } else if (tmp[idx] == media_token[5][0]) {     //"="
+               } else if (tmp[idx] == media_token[5][0]) {     /* "=" */
                        if (idx != 0) {
                                token_t *token = (token_t*)calloc(1, sizeof(token_t));
                                media_content_retvm_if(token == NULL, -1, "OUT_OF_MEMORY");
@@ -471,7 +471,7 @@ static int __tokenize(GList **token_list, const char *str)
                                return -1;
                        }
 
-               } else if (tmp[idx] == media_token[6][0] && tmp[idx+1] == media_token[6][1]) {  //"<=",
+               } else if (tmp[idx] == media_token[6][0] && tmp[idx+1] == media_token[6][1]) {  /* "<=", */
                        if (idx != 0) {
                                token_t *token = (token_t*)calloc(1, sizeof(token_t));
                                media_content_retvm_if(token == NULL, -1, "OUT_OF_MEMORY");
@@ -499,7 +499,7 @@ static int __tokenize(GList **token_list, const char *str)
                                return -1;
                        }
 
-               } else if (tmp[idx] == media_token[7][0]) {     //"<",
+               } else if (tmp[idx] == media_token[7][0]) {     /* "<", */
                        if (idx != 0) {
                                token_t *token = (token_t*)calloc(1, sizeof(token_t));
                                media_content_retvm_if(token == NULL, -1, "OUT_OF_MEMORY");
@@ -527,7 +527,7 @@ static int __tokenize(GList **token_list, const char *str)
                                return -1;
                        }
 
-               } else if (tmp[idx] == media_token[8][0] && tmp[idx+1] == media_token[8][1]) {  //">=",
+               } else if (tmp[idx] == media_token[8][0] && tmp[idx+1] == media_token[8][1]) {  /* ">=", */
                        if (idx != 0) {
                                token_t *token = (token_t*)calloc(1, sizeof(token_t));
                                media_content_retvm_if(token == NULL, -1, "OUT_OF_MEMORY");
@@ -555,7 +555,7 @@ static int __tokenize(GList **token_list, const char *str)
                                return -1;
                        }
 
-               } else if (tmp[idx] == media_token[9][0]) {     //">",
+               } else if (tmp[idx] == media_token[9][0]) {     /* ">", */
                        if (idx != 0) {
                                token_t *token = (token_t*)calloc(1, sizeof(token_t));
                                media_content_retvm_if(token == NULL, -1, "OUT_OF_MEMORY");
@@ -582,7 +582,7 @@ static int __tokenize(GList **token_list, const char *str)
                                media_content_error("tokenize error occured");
                                return -1;
                        }
-               } else if (tmp[idx] == media_token[10][0] && tmp[idx+1] == media_token[10][1]) {        //"!=",
+               } else if (tmp[idx] == media_token[10][0] && tmp[idx+1] == media_token[10][1]) {        /* "!=", */
                        if (idx != 0) {
                                token_t *token = (token_t*)calloc(1, sizeof(token_t));
                                media_content_retvm_if(token == NULL, -1, "OUT_OF_MEMORY");
@@ -612,7 +612,7 @@ static int __tokenize(GList **token_list, const char *str)
                }
        }
 
-       if (*tmp) {                     //remained string
+       if (*tmp) {                     /* remained string */
                token_t *token = (token_t*)calloc(1, sizeof(token_t));
                media_content_retvm_if(token == NULL, -1, "OUT_OF_MEMORY");
 
@@ -726,10 +726,10 @@ int _media_filter_attribute_generate(attribute_h attr, char *condition, media_co
                }
 
                total_str_size += strlen(token->str)+1;
-               //media_content_debug("[%d][type:%d]:%s", idx, token->type, token->str);
+               /* media_content_debug("[%d][type:%d]:%s", idx, token->type, token->str); */
        }
 
-       //make the statment
+       /* make the statment */
        size = total_str_size + COLLATE_STR_SIZE + 1;
        *generated_condition = (char*)calloc(size, sizeof(char));
 
@@ -751,11 +751,11 @@ int _media_filter_attribute_generate(attribute_h attr, char *condition, media_co
                SAFE_STRLCAT(*generated_condition, SPACE, size);
        }
 
-       //media_content_debug("statement : %s(%d) (total:%d)", *generated_condition, strlen(*generated_condition), total_str_size);
+       /* media_content_debug("statement : %s(%d) (total:%d)", *generated_condition, strlen(*generated_condition), total_str_size); */
        media_content_sec_debug("Condition : %s", *generated_condition);
 
-       //if(*generated_condition != NULL)
-       //      res = 1;
+       /if(*generated_condition != NULL)
+               res = 1; */
 
        if (token_list != NULL)
                g_list_free(token_list);
@@ -770,7 +770,6 @@ int _media_filter_attribute_option_generate(attribute_h attr, filter_h filter, c
        char option_query[DEFAULT_QUERY_SIZE] = {0, };
        char condition[DEFAULT_QUERY_SIZE] = {0, };
        int size = 0;
-       //bool order_by = true;
 
        media_content_retvm_if(attr == NULL, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "invalid attr");
        media_content_retvm_if(filter == NULL, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "invalid filter");
@@ -805,11 +804,10 @@ int _media_filter_attribute_option_generate(attribute_h attr, filter_h filter, c
                                                continue;
                                        }
 
-                                       if (_filter->order_collate_type == MEDIA_CONTENT_COLLATE_NOCASE || _filter->order_collate_type == MEDIA_CONTENT_COLLATE_RTRIM || _filter->order_collate_type == MEDIA_CONTENT_COLLATE_LOCALIZED) {
+                                       if (_filter->order_collate_type == MEDIA_CONTENT_COLLATE_NOCASE || _filter->order_collate_type == MEDIA_CONTENT_COLLATE_RTRIM || _filter->order_collate_type == MEDIA_CONTENT_COLLATE_LOCALIZED)
                                                snprintf(attr_str, strlen(replace_str) + COLLATE_STR_SIZE + 1, "%s COLLATE %s %s", replace_str, __get_collate_str(_filter->order_collate_type), __get_order_str(_filter->order_type));
-                                       } else {
+                                       else
                                                snprintf(attr_str, strlen(replace_str) + COLLATE_STR_SIZE + 1, "%s %s", replace_str, __get_order_str(_filter->order_type));
-                                       }
 
                                        SAFE_FREE(token->str);
                                        token->str = attr_str;
@@ -820,10 +818,10 @@ int _media_filter_attribute_option_generate(attribute_h attr, filter_h filter, c
                        }
 
                        total_str_size += strlen(token->str) + 1;
-                       //media_content_debug("[%d][type:%d]:%s", idx, token->type, token->str);
+                       /* media_content_debug("[%d][type:%d]:%s", idx, token->type, token->str); */
                }
 
-               //make the statment
+               /* make the statment */
                char *generated_condition = NULL;
                size = total_str_size + COLLATE_STR_SIZE + 1;
                generated_condition = (char*)calloc(size, sizeof(char));
@@ -832,7 +830,7 @@ int _media_filter_attribute_option_generate(attribute_h attr, filter_h filter, c
                        token = (token_t*)g_list_nth_data(token_list, idx);
 
                        if ((token != NULL) && STRING_VALID(token->str)) {
-                               //media_content_debug("[%d] %s", idx, token->str);
+                               /* media_content_debug("[%d] %s", idx, token->str); */
                                SAFE_STRLCAT(generated_condition, token->str, size);
                                SAFE_STRLCAT(generated_condition, SPACE, size);
 
index 0729a84..61a670e 100755 (executable)
@@ -87,9 +87,8 @@ static int __media_playlist_insert_playlist_record(const char *playlist_name, in
        SQLITE3_SAFE_FREE(select_query);
        media_content_retv_if(ret != MEDIA_CONTENT_ERROR_NONE, ret);
 
-       while (sqlite3_step(stmt) == SQLITE_ROW) {
+       while (sqlite3_step(stmt) == SQLITE_ROW)
                *playlist_id = (int)sqlite3_column_int(stmt, 0);
-       }
 
        SQLITE3_FINALIZE(stmt);
 
@@ -112,9 +111,8 @@ static int __media_playlist_insert_item_to_playlist(int playlist_id, const char
        ret = _content_query_prepare(&stmt, select_query, NULL, NULL);
        media_content_retv_if(ret != MEDIA_CONTENT_ERROR_NONE, ret);
 
-       while (sqlite3_step(stmt) == SQLITE_ROW) {
+       while (sqlite3_step(stmt) == SQLITE_ROW)
                play_order = (int)sqlite3_column_int(stmt, 0);
-       }
 
        SQLITE3_FINALIZE(stmt);
 
@@ -203,7 +201,7 @@ static int __media_playlist_reset_file(const char* playlist_path)
        fp = fopen(playlist_path, "wb");
        media_content_retvm_if(fp == NULL, MEDIA_CONTENT_ERROR_INVALID_OPERATION, "fopen fail");
 
-       fputs("", fp);  // remove previous playlist
+       fputs("", fp);  /* remove previous playlist */
 
        fclose(fp);
 
@@ -214,7 +212,7 @@ static int __media_playlist_append_to_file(const char* playlist_path, const char
 {
        FILE *fp = NULL;
 
-       fp = fopen(playlist_path, "a"); // append only
+       fp = fopen(playlist_path, "a"); /* append only */
        media_content_retvm_if(fp == NULL, MEDIA_CONTENT_ERROR_INVALID_OPERATION, "fopen fail");
 
        fputs(path, fp);
@@ -228,31 +226,31 @@ static int __media_playlist_append_to_file(const char* playlist_path, const char
 
 static int __media_playlist_import_item_from_file(const char* playlist_path, char*** const item_list, int* item_count)
 {
-       int current_index = 0;                                          // Current record number
-       int current_max_size = PLAYLIST_ARRAY_SIZE;     // Current max number of records in array
-       int tmp_str_len = 0;                                            // Length of the string
+       int current_index = 0;
+       int current_max_size = PLAYLIST_ARRAY_SIZE;
+       int tmp_str_len = 0;
        char *buf = NULL;
        char *tmp_buf = NULL;
-       char *tmp_str = NULL;                                           // Next line from buffer, this string is used for parsing
+       char *tmp_str = NULL;
 
        FILE *fp = NULL;
        long int file_size = 0;
 
        *item_list = NULL; *item_count = 0;
 
-       fp = fopen(playlist_path, "rb");                // Open as binary for precise estimation of file length
+       fp = fopen(playlist_path, "rb");
        media_content_retvm_if(fp == NULL, MEDIA_CONTENT_ERROR_INVALID_OPERATION, "fopen fail");
 
-       fseek(fp, 0, SEEK_END);                                 // Move to the end of file
-       file_size = ftell(fp);                          // Here we can find the size of file
-       fseek(fp, 0 , SEEK_SET);                                        // Return to the beginning of file
+       fseek(fp, 0, SEEK_END);
+       file_size = ftell(fp);
+       fseek(fp, 0 , SEEK_SET);
 
        if (file_size == 0) {
                media_content_debug("file is empty.");
                fclose(fp);
                return MEDIA_CONTENT_ERROR_NONE;
        }
-       // Allocate the memory and copy file content there
+
        if (file_size > 0)
                buf = malloc(file_size + 1);
 
@@ -273,7 +271,6 @@ static int __media_playlist_import_item_from_file(const char* playlist_path, cha
        buf[file_size] = 0;
        fclose(fp);
 
-       // Preliminary memory allocation
        *item_list = calloc(current_max_size, sizeof(char*));
        tmp_str = malloc(MAX_TMP_STR);
        if (tmp_str == NULL || *item_list == NULL) {
@@ -283,26 +280,24 @@ static int __media_playlist_import_item_from_file(const char* playlist_path, cha
                media_content_error("Out of Memory");
                return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
        }
-       // Here we create format string for sscanf(...) that allows to get a line from buffer
+
        char format[25];
        snprintf(format, 25, "%%%d[^\n]", MAX_TMP_STR);
 
-       // This cycle gets lines one by one from buffer till the end of buffer. Empty line ("\n") must be treated specifically
        while ((sscanf(tmp_buf, format, tmp_str) == 1) || (*tmp_buf == '\n')) {
-               if (*tmp_buf == '\n') {// Check if there is an empty line, skip '\n' symbol
+               if (*tmp_buf == '\n') {
                        tmp_buf += 1;
 
                        if (tmp_buf < (buf + file_size))
-                               continue;                       // We are still in buffer
+                               continue;
                        else
-                               break;                          // Empty line was in the end of buffer
+                               break;
                }
 
-               tmp_str_len = strlen(tmp_str);          // Save the length of line
+               tmp_str_len = strlen(tmp_str);
 
-               if (tmp_str[0] != '#') {                        // Check that the line is not a comment
-                       if (!(current_index < (current_max_size - 1))) {                                // Check if we have completely filled record array
-                               // Expand array size and relocate the array (records will be copied into new one)
+               if (tmp_str[0] != '#') {
+                       if (!(current_index < (current_max_size - 1))) {
                                current_max_size += PLAYLIST_ARRAY_EXPAND;
                                char **tmp_ptr = calloc(current_max_size, sizeof(char*));
                                if (tmp_ptr == NULL) {
@@ -317,7 +312,6 @@ static int __media_playlist_import_item_from_file(const char* playlist_path, cha
                                *item_list = tmp_ptr;
                        }
 
-                       // Save new file path (current string in tmp_str)
                        (*item_list)[current_index] = malloc(tmp_str_len + 1);
                        if ((*item_list)[current_index] == NULL) {
                                __media_playlist_destroy_import_item(*item_list, current_index);
@@ -328,17 +322,16 @@ static int __media_playlist_import_item_from_file(const char* playlist_path, cha
                        }
                        memmove((*item_list)[current_index], tmp_str, tmp_str_len + 1);
 
-                       // Increase the index of buffer
                        current_index += 1;
                }
 
-               tmp_buf += (tmp_str_len + 1);                           // Move position in buffer after the string that was parsed
+               tmp_buf += (tmp_str_len + 1);
        }
 
-       *item_count = current_index;                                            // Now we need to save the number of records in array
+       *item_count = current_index;
 
        SAFE_FREE(buf);
-       SAFE_FREE(tmp_str);                                             // Free temporary variables
+       SAFE_FREE(tmp_str);
 
        return MEDIA_CONTENT_ERROR_NONE;
 }
@@ -648,9 +641,8 @@ int media_playlist_get_play_order(media_playlist_h playlist, int playlist_member
        ret = _content_query_prepare(&stmt, select_query, NULL, NULL);
        media_content_retv_if(ret != MEDIA_CONTENT_ERROR_NONE, ret);
 
-       while (sqlite3_step(stmt) == SQLITE_ROW) {
+       while (sqlite3_step(stmt) == SQLITE_ROW)
                *play_order = (int)sqlite3_column_int(stmt, 0);
-       }
 
        SQLITE3_FINALIZE(stmt);
 
@@ -824,38 +816,38 @@ int media_playlist_update_to_db(media_playlist_h playlist)
                _playlist_item = (media_playlist_item_s*)g_list_nth_data(_playlist->item_list, idx);
                if (_playlist_item != NULL) {
                        switch (_playlist_item->function) {
-                               case MEDIA_PLAYLIST_ADD:
-                               {
-                                       ret = __media_playlist_insert_item_to_playlist(_playlist->playlist_id, _playlist_item->media_id);
-                               }
-                               break;
+                       case MEDIA_PLAYLIST_ADD:
+                       {
+                               ret = __media_playlist_insert_item_to_playlist(_playlist->playlist_id, _playlist_item->media_id);
+                       }
+                       break;
 
-                               case MEDIA_PLAYLIST_REMOVE:
-                               {
-                                       ret = __media_playlist_remove_item_from_playlist(_playlist->playlist_id, _playlist_item->playlist_member_id);
-                               }
-                               break;
+                       case MEDIA_PLAYLIST_REMOVE:
+                       {
+                               ret = __media_playlist_remove_item_from_playlist(_playlist->playlist_id, _playlist_item->playlist_member_id);
+                       }
+                       break;
 
-                               case MEDIA_PLAYLIST_UPDATE_PLAYLIST_NAME:
-                               {
-                                       ret = __media_playlist_update_playlist_name(_playlist->playlist_id, _playlist_item->playlist_name);
-                               }
-                               break;
+                       case MEDIA_PLAYLIST_UPDATE_PLAYLIST_NAME:
+                       {
+                               ret = __media_playlist_update_playlist_name(_playlist->playlist_id, _playlist_item->playlist_name);
+                       }
+                       break;
 
-                               case MEDIA_PLAYLIST_UPDATE_THUMBNAIL_PATH:
-                               {
-                                       ret = __media_playlist_update_thumbnail_path(_playlist->playlist_id, _playlist_item->thumbnail_path);
-                               }
-                               break;
+                       case MEDIA_PLAYLIST_UPDATE_THUMBNAIL_PATH:
+                       {
+                               ret = __media_playlist_update_thumbnail_path(_playlist->playlist_id, _playlist_item->thumbnail_path);
+                       }
+                       break;
 
-                               case MEDIA_PLAYLIST_UPDATE_PLAY_ORDER:
-                               {
-                                       ret = __media_playlist_update_play_order(_playlist->playlist_id, _playlist_item->playlist_member_id, _playlist_item->play_order);
-                               }
-                               break;
+                       case MEDIA_PLAYLIST_UPDATE_PLAY_ORDER:
+                       {
+                               ret = __media_playlist_update_play_order(_playlist->playlist_id, _playlist_item->playlist_member_id, _playlist_item->play_order);
+                       }
+                       break;
 
-                               default:
-                               break;
+                       default:
+                       break;
                        }
                }
        }
@@ -886,9 +878,8 @@ int media_playlist_import_from_file(const char *path, const char *playlist_name,
                return ret;
        }
 
-       if (import_item_count == 0) {
+       if (import_item_count == 0)
                media_content_debug("The playlist from file is empty");
-       }
 
        for (idx = 0; idx < import_item_count; idx++) {
                filter_h filter = NULL;
index b34d218..6579683 100755 (executable)
@@ -457,26 +457,26 @@ int media_tag_update_to_db(media_tag_h tag)
                _tag_item = (media_tag_item_s*)g_list_nth_data(_tag->item_list, idx);
                if (_tag_item != NULL) {
                        switch (_tag_item->function) {
-                               case MEDIA_TAG_ADD:
-                               {
-                                       ret = __media_tag_insert_item_to_tag(_tag->tag_id, _tag_item->media_id);
-                               }
-                               break;
-
-                               case MEDIA_TAG_REMOVE:
-                               {
-                                       ret = __media_tag_remove_item_from_tag(_tag->tag_id, _tag_item->media_id);
-                               }
-                               break;
-
-                               case MEDIA_TAG_UPDATE_TAG_NAME:
-                               {
-                                       ret = __media_tag_update_tag_name(_tag->tag_id, _tag_item->tag_name);
-                               }
-                               break;
-
-                               default:
-                               break;
+                       case MEDIA_TAG_ADD:
+                       {
+                               ret = __media_tag_insert_item_to_tag(_tag->tag_id, _tag_item->media_id);
+                       }
+                       break;
+
+                       case MEDIA_TAG_REMOVE:
+                       {
+                               ret = __media_tag_remove_item_from_tag(_tag->tag_id, _tag_item->media_id);
+                       }
+                       break;
+
+                       case MEDIA_TAG_UPDATE_TAG_NAME:
+                       {
+                               ret = __media_tag_update_tag_name(_tag->tag_id, _tag_item->tag_name);
+                       }
+                       break;
+
+                       default:
+                       break;
                        }
                }
        }
index 613521d..05e6415 100755 (executable)
@@ -32,11 +32,10 @@ int _media_util_check_file_exist(const char *path)
        if (exist < 0) {
                media_content_sec_debug("path [%s]", path);
                media_content_stderror("open file fail");
-               if (errno == EACCES || errno == EPERM) {
+               if (errno == EACCES || errno == EPERM)
                        return MEDIA_CONTENT_ERROR_PERMISSION_DENIED;
-               } else {
+               else
                        return MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
-               }
        }
 
        close(exist);
@@ -114,7 +113,7 @@ int _media_util_check_ignore_dir(const char *dir_path, bool *ignore)
                                find = TRUE;
                                break;
                        } else {
-                               //media_content_sec_debug("entry.d_name[%s]", entry.d_name);
+                               /*media_content_sec_debug("entry.d_name[%s]", entry.d_name);*/
                                continue;
                        }
                }
@@ -149,7 +148,7 @@ int _media_util_check_ignore_dir(const char *dir_path, bool *ignore)
                        if (leaf_path != NULL) {
                                int seek_len = leaf_path -search_path;
                                search_path[seek_len] = '\0';
-                               //media_content_sec_debug("go to other dir [%s]", search_path);
+                               /*media_content_sec_debug("go to other dir [%s]", search_path);*/
                        } else {
                                media_content_debug("Fail to find leaf path");
                                break;
index 53bd212..d0f3ad0 100755 (executable)
@@ -26,7 +26,7 @@
 #include <tzplatform_config.h>
 
 filter_h g_filter = NULL;
-filter_h g_filter_g = NULL;    //filter for group like folder, tag, playlist, album, year ...
+filter_h g_filter_g = NULL;    /*filter for group like folder, tag, playlist, album, year ... */
 
 GMainLoop *g_loop = NULL;
 static int g_cnt = 0;
@@ -512,8 +512,8 @@ bool media_item_cb(media_info_h media, void *user_data)
        SAFE_FREE(c_value);
 
        /* Media server can't update when another db handle holds DB connection by sqlite3_prepare */
-       //ret = media_info_set_location_tag(media, "Test location tag");
-       //media_info_update_to_db(media);
+       /*ret = media_info_set_location_tag(media, "Test location tag");*/
+       /*media_info_update_to_db(media);*/
        SAFE_FREE(media_id);
 #endif
        SAFE_FREE(media_id);
@@ -860,7 +860,7 @@ bool playlist_item_cb(int playlist_member_id, media_info_h media, void *user_dat
 
        *list = g_list_append(*list, (gpointer)playlist_member_id);
 #endif
-       //media_item_cb(media, user_data);
+       /*media_item_cb(media, user_data);*/
 
        return true;
 }
@@ -873,7 +873,7 @@ int test_filter_create(void)
 
        /* Filter for media */
        const char *condition = "MEDIA_TYPE=3"; /*MEDIA_TYPE 0-image, 1-video, 2-sound, 3-music, 4-other*/
-       //const char *condition = "MEDIA_TYPE IS NOT 0 AND MEDIA_DESCRIPTION IS NOT NULL";      /*MEDIA_TYPE 0-image, 1-video, 2-sound, 3-music, 4-other*/
+       /*const char *condition = "MEDIA_TYPE IS NOT 0 AND MEDIA_DESCRIPTION IS NOT NULL"; */   /*MEDIA_TYPE 0-image, 1-video, 2-sound, 3-music, 4-other*/
 
        ret = media_filter_create(&g_filter);
 
@@ -895,18 +895,18 @@ int test_filter_create(void)
         * call media_filter_set_order(g_filter, MEDIA_CONTENT_ORDER_ASC, MEDIA_ARTIST, MEDIA_CONTENT_COLLATE_DEFAULT);
         */
        /* Able to set multi column to set order */
-       //ret = media_filter_set_order(g_filter, MEDIA_CONTENT_ORDER_ASC, "MEDIA_MODIFIED_TIME, MEDIA_DISPLAY_NAME", MEDIA_CONTENT_COLLATE_DEFAULT);
-       //ret = media_filter_set_order(g_filter, MEDIA_CONTENT_ORDER_ASC, MEDIA_ARTIST, MEDIA_CONTENT_COLLATE_DEFAULT);
-       //ret = media_filter_set_order(g_filter, MEDIA_CONTENT_ORDER_ASC, MEDIA_TRACK_NUM_INT, MEDIA_CONTENT_COLLATE_DEFAULT);
-       //ret = media_filter_set_storage(g_filter, "cfbf3d2c-71c5-4611-bccc-7cbac890146e");
+#if 0
+       ret = media_filter_set_order(g_filter, MEDIA_CONTENT_ORDER_ASC, "MEDIA_MODIFIED_TIME, MEDIA_DISPLAY_NAME", MEDIA_CONTENT_COLLATE_DEFAULT);
+       ret = media_filter_set_order(g_filter, MEDIA_CONTENT_ORDER_ASC, MEDIA_ARTIST, MEDIA_CONTENT_COLLATE_DEFAULT);
+       ret = media_filter_set_order(g_filter, MEDIA_CONTENT_ORDER_ASC, MEDIA_TRACK_NUM_INT, MEDIA_CONTENT_COLLATE_DEFAULT);
+       ret = media_filter_set_storage(g_filter, "cfbf3d2c-71c5-4611-bccc-7cbac890146e");
 
        /* Filter for group */
-       //const char *g_condition = "TAG_NAME like \"\%my\%\"";
-       //const char *g_condition = "BOOKMARK_MARKED_TIME > 300";
-
+       const char *g_condition = "TAG_NAME like \"\%my\%\"";
+       const char *g_condition = "BOOKMARK_MARKED_TIME > 300";
+#endif
        ret = media_filter_create(&g_filter_g);
 
-       //ret = media_filter_set_condition(g_filter_g, g_condition, MEDIA_CONTENT_COLLATE_DEFAULT);
        ret = media_filter_set_order(g_filter_g, MEDIA_CONTENT_ORDER_DESC, TAG_NAME, MEDIA_CONTENT_COLLATE_DEFAULT);
 
        return ret;
@@ -1123,9 +1123,6 @@ int test_gallery_scenario(void)
                                if (ret != MEDIA_CONTENT_ERROR_NONE)
                                        media_content_error("error video_meta_destroy : [%d]", ret);
                        }
-                       //media_content_debug("media_id [%d] : %s", i, media_id);
-                       //media_content_debug("media_name [%d] : %s", i, media_name);
-                       //media_content_debug("media_path [%d] : %s", i, media_path);
 
                        SAFE_FREE(media_id);
                        SAFE_FREE(media_name);
@@ -1576,7 +1573,6 @@ int test_folder_operation(void)
 
        ret = media_folder_foreach_folder_from_db(filter, folder_list_cb, &folder);
 
-       //test.3 get the media list in first folder
        filter_h m_filter = NULL;
 
        ret = media_filter_create(&m_filter);
@@ -1821,8 +1817,10 @@ int test_playlist_operation(void)
        media_playlist_foreach_playlist_from_db(filter, playlist_list_cb, NULL);
 
        /* deletes the playlist */
-       //media_playlist_delete_from_db(playlist_id_1);
-       //media_playlist_delete_from_db(playlist_id_2);
+#if 0
+       media_playlist_delete_from_db(playlist_id_1);
+       media_playlist_delete_from_db(playlist_id_2);
+#endif
 
        if (playlist_1 != NULL)
                media_playlist_destroy(playlist_1);
@@ -1993,7 +1991,7 @@ int test_tag_operation(void)
 
 int test_bookmark_operation(void)
 {
-       //bookmark is only supported for video information.
+       /* bookmark is only supported for video information. */
        int ret = MEDIA_CONTENT_ERROR_NONE;
        int bookmark_count = 0;
        filter_h filter;
@@ -2014,7 +2012,7 @@ int test_bookmark_operation(void)
        if (ret != MEDIA_CONTENT_ERROR_NONE)
                media_content_error("error media_filter_set_order : [%d]", ret);
 
-       //insert bookmark to video
+       /* insert bookmark to video */
        const char *thumbnail_path1 = tzplatform_mkpath(TZ_USER_CONTENT, "Images and videos/My video clips/teat11.jpg");
        ret = media_bookmark_insert_to_db(test_video_id, 400, thumbnail_path1);
        if (ret != MEDIA_CONTENT_ERROR_NONE)
@@ -2161,16 +2159,15 @@ int test_update_operation()
                                } else {
                                        media_content_debug("media_info_get_image success");
 
-                                       //update image meta
+                                       /* update image meta */
                                        orientation = MEDIA_CONTENT_ORIENTATION_ROT_180;
                                        image_meta_set_orientation(image_handle, orientation);
 
                                        ret = image_meta_update_to_db(image_handle);
-                                       if (ret != MEDIA_CONTENT_ERROR_NONE) {
+                                       if (ret != MEDIA_CONTENT_ERROR_NONE)
                                                media_content_error("image_meta_update_to_db failed: %d", ret);
-                                       } else {
+                                       else
                                                media_content_debug("image_meta_update_to_db success");
-                                       }
                                }
 
                        } else if (media_type == MEDIA_CONTENT_TYPE_VIDEO) {
@@ -2182,20 +2179,19 @@ int test_update_operation()
                                } else {
                                        media_content_debug("media_info_get_video success");
 
-                                       //update video meta
+                                       /* update video meta */
                                        video_meta_set_played_count(video_handle, 5);
                                        video_meta_set_played_time(video_handle, 5);
                                        video_meta_set_played_position(video_handle, 5);
                                        video_meta_update_to_db(video_handle);
 
                                        ret = video_meta_update_to_db(video_handle);
-                                       if (ret != MEDIA_CONTENT_ERROR_NONE) {
+                                       if (ret != MEDIA_CONTENT_ERROR_NONE)
                                                media_content_error("video_meta_update_to_db failed: %d", ret);
-                                       } else {
+                                       else
                                                media_content_debug("video_meta_update_to_db success");
-                                       }
                                }
-                       } else if (media_type == MEDIA_CONTENT_TYPE_MUSIC) {//update audio meta
+                       } else if (media_type == MEDIA_CONTENT_TYPE_MUSIC) {
                                audio_meta_h audio_handle = NULL;
                                ret = media_info_get_audio(media_handle, &audio_handle);
                                if (ret != MEDIA_CONTENT_ERROR_NONE) {
@@ -2208,11 +2204,10 @@ int test_update_operation()
                                        audio_meta_set_played_position(audio_handle, 180);
 
                                        ret = audio_meta_update_to_db(audio_handle);
-                                       if (ret != MEDIA_CONTENT_ERROR_NONE) {
+                                       if (ret != MEDIA_CONTENT_ERROR_NONE)
                                                media_content_error("audio_meta_update_to_db failed: %d", ret);
-                                       } else {
+                                       else
                                                media_content_debug("audio_meta_update_to_db success");
-                                       }
                                }
 
                        }
@@ -2231,8 +2226,10 @@ int test_insert(void)
 {
        int ret = MEDIA_CONTENT_ERROR_NONE;
        const char *path = "/opt/usr/media/Images/Default.jpg";
-       //const char *path = "/opt/usr/media/Others/other.txt";
-       //char *path = NULL;
+#if 0
+       const char *path = "/opt/usr/media/Others/other.txt";
+       char *path = NULL;
+#endif
        media_info_h media_item = NULL;
        media_content_debug("\n============DB Insert Test============\n\n");
 
@@ -2487,7 +2484,6 @@ int test_request_update_db(void)
        char *content_name = NULL;
        bool favorite = FALSE;
 
-       //get the content of Over the horizon
        ret = media_info_get_media_from_db("71b19196-5b38-4ab1-ab34-bfe05c369614", &media);
        if (ret != MEDIA_CONTENT_ERROR_NONE)
                media_content_error("media_info_get_media_from_db failed: %d", ret);
@@ -2711,9 +2707,8 @@ int test_batch_operations()
        }
 
        ret = media_info_insert_batch_to_db((const char **)file_list, 10, insert_batch_cb, NULL);
-       if (ret != MEDIA_CONTENT_ERROR_NONE) {
+       if (ret != MEDIA_CONTENT_ERROR_NONE)
                media_content_error("media_info_insert_batch_to_db failed : %d\n", ret);
-       }
 
        filter_h filter;
        char *condition = "MEDIA_PATH LIKE \'";
@@ -2763,9 +2758,8 @@ gboolean test_insert_burst_shot_to_db_start(gpointer data)
        }
 
        ret = media_info_insert_burst_shot_to_db((const char **)file_list, 10, insert_burst_shot_cb, NULL);
-       if (ret != MEDIA_CONTENT_ERROR_NONE) {
+       if (ret != MEDIA_CONTENT_ERROR_NONE)
                media_content_error("media_info_insert_burst_shot_to_db failed : %d\n", ret);
-       }
 
        return ret;
 }
@@ -2875,27 +2869,24 @@ void _noti_cb(media_content_error_e error,
                                char *mime_type,
                                void *user_data)
 {
-       if (error == 0) {
+       if (error == 0)
                media_content_debug("noti success! : %d\n", error);
-       } else {
+       else
                media_content_debug("error occured! : %d\n", error);
-       }
 
        media_content_debug("Noti from PID(%d)\n", pid);
 
-       if (update_item == MEDIA_ITEM_FILE) {
+       if (update_item == MEDIA_ITEM_FILE)
                media_content_debug("Noti item : MEDIA_ITEM_FILE\n");
-       } else if (update_item == MEDIA_ITEM_DIRECTORY) {
+       else if (update_item == MEDIA_ITEM_DIRECTORY)
                media_content_debug("Noti item : MEDIA_ITEM_DIRECTORY\n");
-       }
 
-       if (update_type == MEDIA_CONTENT_INSERT) {
+       if (update_type == MEDIA_CONTENT_INSERT)
                media_content_debug("Noti type : MEDIA_CONTENT_INSERT\n");
-       } else if (update_type == MEDIA_CONTENT_DELETE) {
+       else if (update_type == MEDIA_CONTENT_DELETE)
                media_content_debug("Noti type : MEDIA_CONTENT_DELETE\n");
-       } else if (update_type == MEDIA_CONTENT_UPDATE) {
+       else if (update_type == MEDIA_CONTENT_UPDATE)
                media_content_debug("Noti type : MEDIA_CONTENT_UPDATE\n");
-       }
 
        media_content_debug("content type : %d\n", media_type);
 
@@ -2916,7 +2907,6 @@ void _noti_cb(media_content_error_e error,
 
        if (user_data) media_content_debug("String : %s\n", (char *)user_data);
 
-//     g_main_loop_quit(g_loop);
        return;
 }
 
@@ -2930,11 +2920,10 @@ void _noti_cb_2(media_content_error_e error,
                                char *mime_type,
                                void *user_data)
 {
-       if (error == 0) {
+       if (error == 0)
                media_content_debug("noti_2 success! : %d\n", error);
-       } else {
+       else
                media_content_debug("error occured! : %d\n", error);
-       }
 
        media_content_debug("Noti_2 from PID(%d)\n", pid);
 
@@ -2973,7 +2962,6 @@ gboolean _send_noti_operations(gpointer data)
        const char *temp = NULL;
        temp = tzplatform_mkpath(TZ_USER_CONTENT, "test/image%%\'");
        snprintf(condition, sizeof(condition), "MEDIA_PATH LIKE \'%s", temp);
-//     strncat(condition, temp, strlen(temp));
 
        ret = media_filter_create(&filter);
        if (ret != MEDIA_CONTENT_ERROR_NONE) {