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;
}
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)
{
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);
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");
}
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);
/*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);
}
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);
}
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;
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);
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);
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);
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);
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));
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);
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);
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 *)" ";
}
}
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;
}
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;
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;
}
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;
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");
}
}
- 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");
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;
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;
}
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;
}
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++) {
}
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;
}
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");
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");
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");
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");
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");
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");
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");
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");
}
}
- 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");
}
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));
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);
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");
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;
}
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));
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);
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);
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);
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);
{
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);
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);
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) {
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) {
*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);
}
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;
}
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);
_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;
}
}
}
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;
_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;
}
}
}
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);
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;
}
}
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;
#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;
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);
*list = g_list_append(*list, (gpointer)playlist_member_id);
#endif
- //media_item_cb(media, user_data);
+ /*media_item_cb(media, user_data);*/
return true;
}
/* 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);
* 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;
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);
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);
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);
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;
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)
} 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) {
} 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) {
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");
- }
}
}
{
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");
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);
}
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 \'";
}
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;
}
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);
if (user_data) media_content_debug("String : %s\n", (char *)user_data);
-// g_main_loop_quit(g_loop);
return;
}
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);
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) {