x_dst[max_len - 1] = '\0';
}
-int __media_svc_malloc_and_strncpy(char **dst, const char *src)
-{
- int len = 0;
-
- if (!STRING_VALID(src)) {
- media_svc_error("invalid src");
- return MS_MEDIA_ERR_INVALID_PARAMETER;
- }
-
- SAFE_FREE(*dst);
-
- len = strlen(src) + 1;
- *dst = malloc(len);
-
- if (*dst == NULL) {
- media_svc_error("malloc failed");
- return MS_MEDIA_ERR_INTERNAL;
- }
-
- strncpy(*dst, src, len);
- char *p = *dst;
- p[len - 1] = '\0';
-
- return MS_MEDIA_ERR_NONE;
-}
-
static int __media_svc_split_to_double(char *input, double *arr)
{
char tmp_arr[255] = {0, };
int _media_svc_set_default_value(media_svc_content_info_s *content_info, bool refresh)
{
- int ret = MS_MEDIA_ERR_NONE;
-
/* Set default GPS value before extracting meta information */
content_info->media_meta.longitude = MEDIA_SVC_DEFAULT_GPS_VALUE;
content_info->media_meta.latitude = MEDIA_SVC_DEFAULT_GPS_VALUE;
char *title = NULL;
title = __media_svc_get_title_from_filepath(content_info->path);
if (title) {
- ret = __media_svc_malloc_and_strncpy(&content_info->media_meta.title, title);
- if (ret != MS_MEDIA_ERR_NONE)
- media_svc_error("strcpy error");
+ content_info->media_meta.title = g_strdup(title);
SAFE_FREE(title);
+ media_svc_retv_del_if(content_info->media_meta.title == NULL, MS_MEDIA_ERR_INTERNAL, content_info);
} else {
media_svc_error("Can't extract title");
content_info->media_meta.title = g_strdup(MEDIA_SVC_TAG_UNKNOWN);
bool drm_type = false;
char mime_type[256] = {0, };
- ret = __media_svc_malloc_and_strncpy(&content_info->path, path);
- media_svc_retv_del_if(ret != MS_MEDIA_ERR_NONE, ret, content_info);
+ content_info->path = g_strdup(path);
+ media_svc_retv_del_if(content_info->path == NULL, MS_MEDIA_ERR_INTERNAL, content_info);
struct stat st;
memset(&st, 0, sizeof(struct stat));
return MS_MEDIA_ERR_NONE;
}
- ret = __media_svc_malloc_and_strncpy(&content_info->storage_uuid, storage_id);
- media_svc_retv_del_if(ret != MS_MEDIA_ERR_NONE, ret, content_info);
+ content_info->storage_uuid = g_strdup(storage_id);
+ media_svc_retv_del_if(content_info->storage_uuid == NULL, MS_MEDIA_ERR_INTERNAL, content_info);
content_info->storage_type = storage_type;
time(&content_info->added_time);
return MS_MEDIA_ERR_INTERNAL;
}
- ret = __media_svc_malloc_and_strncpy(&content_info->media_uuid, media_uuid);
- media_svc_retv_del_if(ret != MS_MEDIA_ERR_NONE, ret, content_info);
+ content_info->media_uuid = g_strdup(media_uuid);
+ media_svc_retv_del_if(content_info->media_uuid == NULL, MS_MEDIA_ERR_INTERNAL, content_info);
file_name = g_path_get_basename(path);
- ret = __media_svc_malloc_and_strncpy(&content_info->file_name, file_name);
+ content_info->file_name = g_strdup(file_name);
SAFE_FREE(file_name);
- media_svc_retv_del_if(ret != MS_MEDIA_ERR_NONE, ret, content_info);
+ media_svc_retv_del_if(content_info->file_name == NULL, MS_MEDIA_ERR_INTERNAL, content_info);
/* if the file is DRM file, drm_type value is DRM_TRUE(1).
if drm_contentinfo is not NULL, the file is OMA DRM.*/
return MS_MEDIA_ERR_INVALID_PARAMETER;
}
- ret = __media_svc_malloc_and_strncpy(&content_info->mime_type, mime_type);
- media_svc_retv_del_if(ret != MS_MEDIA_ERR_NONE, ret, content_info);
+ content_info->mime_type = g_strdup(mime_type);
+ media_svc_retv_del_if(content_info->mime_type == NULL, MS_MEDIA_ERR_INTERNAL, content_info);
media_svc_sec_debug("storage[%d], path[%s], media_type[%d]", storage_type, path, *media_type);
int _media_svc_extract_image_metadata(sqlite3 *handle, media_svc_content_info_s *content_info)
{
- int ret = MS_MEDIA_ERR_NONE;
double value = 0.0;
int orient_value = 0;
int exif_width = 0;
memset(buf, 0x00, sizeof(buf));
if (__media_svc_get_exif_info(ed, buf, NULL, NULL, EXIF_TAG_IMAGE_DESCRIPTION) == MS_MEDIA_ERR_NONE) {
- if (strlen(buf) == 0) {
- /*media_svc_debug("Use 'No description'"); */
- ret = __media_svc_malloc_and_strncpy(&content_info->media_meta.description, MEDIA_SVC_TAG_UNKNOWN);
- if (ret != MS_MEDIA_ERR_NONE)
- media_svc_error("strcpy error");
- } else {
- ret = __media_svc_malloc_and_strncpy(&content_info->media_meta.description, buf);
- if (ret != MS_MEDIA_ERR_NONE)
- media_svc_error("strcpy error");
- }
+ if (strlen(buf) == 0)
+ content_info->media_meta.description = g_strdup(MEDIA_SVC_TAG_UNKNOWN);
+ else
+ content_info->media_meta.description = g_strdup(buf);
} else {
- ret = __media_svc_malloc_and_strncpy(&content_info->media_meta.description, MEDIA_SVC_TAG_UNKNOWN);
- if (ret != MS_MEDIA_ERR_NONE)
- media_svc_error("strcpy error");
+ content_info->media_meta.description = g_strdup(MEDIA_SVC_TAG_UNKNOWN);
}
memset(buf, 0x00, sizeof(buf));
if (!has_datetaken && __media_svc_get_exif_info(ed, buf, NULL, NULL, EXIF_TAG_DATE_TIME_ORIGINAL) == MS_MEDIA_ERR_NONE) {
- if (strlen(buf) == 0) {
- /*media_svc_debug("time is NULL"); */
- } else {
+ if (strlen(buf) > 0) {
has_datetaken = TRUE;
content_info->media_meta.datetaken = g_strdup(buf);
memset(buf, 0x00, sizeof(buf));
if (!has_datetaken && __media_svc_get_exif_info(ed, buf, NULL, NULL, EXIF_TAG_DATE_TIME) == MS_MEDIA_ERR_NONE) {
- if (strlen(buf) == 0) {
- /*media_svc_debug("time is NULL"); */
- } else {
+ if (strlen(buf) > 0) {
has_datetaken = TRUE;
content_info->media_meta.datetaken = g_strdup(buf);
/* Get exposure_time value from exif. */
if (__media_svc_get_exif_info(ed, buf, NULL, NULL, EXIF_TAG_EXPOSURE_TIME) == MS_MEDIA_ERR_NONE) {
- if (strlen(buf) == 0) {
- /* media_svc_debug("exposure_time_buf is NULL"); */
- } else {
- ret = __media_svc_malloc_and_strncpy(&content_info->media_meta.exposure_time, buf);
- if (ret != MS_MEDIA_ERR_NONE)
- media_svc_error("strcpy error");
- }
+ if (strlen(buf) > 0)
+ content_info->media_meta.exposure_time = g_strdup(buf);
}
/* Get fnumber value from exif. */
/* Get model value from exif. */
if (__media_svc_get_exif_info(ed, buf, NULL, NULL, EXIF_TAG_MODEL) == MS_MEDIA_ERR_NONE) {
- if (strlen(buf) == 0) {
- /* media_svc_debug("model_buf is NULL"); */
- } else {
- ret = __media_svc_malloc_and_strncpy(&content_info->media_meta.model, buf);
- if (ret != MS_MEDIA_ERR_NONE)
- media_svc_error("strcpy error");
- }
+ if (strlen(buf) > 0)
+ content_info->media_meta.model = g_strdup(buf);
}
/* Get orientation value from exif. */
GET_WIDTH_HEIGHT:
- if (content_info->media_meta.width == 0 ||
- content_info->media_meta.height == 0) {
+ if (content_info->media_meta.width == 0 || content_info->media_meta.height == 0) {
/*Get image width, height*/
unsigned int img_width = 0;
unsigned int img_height = 0;
ImgCodecType img_type = IMG_CODEC_NONE;
- ret = ImgGetImageInfo(path, &img_type, &img_width, &img_height);
-
+ ImgGetImageInfo(path, &img_type, &img_width, &img_height);
if (content_info->media_meta.width == 0)
content_info->media_meta.width = img_width;
int mmf_error = FILEINFO_ERROR_NONE;
char *err_attr_name = NULL;
int album_id = 0;
- int ret = MS_MEDIA_ERR_NONE;
/*Get Content Tag attribute ===========*/
mmf_error = mm_file_create_tag_attrs(&tag, content_info->path);
if (mmf_error == FILEINFO_ERROR_NONE) {
mmf_error = mm_file_get_attrs(tag, &err_attr_name, MM_FILE_TAG_ALBUM, &p, &size, NULL);
if ((!(extracted_field & MEDIA_SVC_EXTRACTED_FIELD_ALBUM)) && (mmf_error == FILEINFO_ERROR_NONE) && (size > 0)) {
- ret = __media_svc_malloc_and_strncpy(&content_info->media_meta.album, p);
- if (ret != MS_MEDIA_ERR_NONE)
- media_svc_error("strcpy error");
-
- /*media_svc_debug("album[%d] : %s", size, content_info->media_meta.album); */
+ content_info->media_meta.album = g_strdup(p);
} else {
SAFE_FREE(err_attr_name);
- /*media_svc_debug("album - unknown"); */
}
mmf_error = mm_file_get_attrs(tag, &err_attr_name, MM_FILE_TAG_ARTIST, &p, &size, NULL);
if ((!(extracted_field & MEDIA_SVC_EXTRACTED_FIELD_ARTIST)) && (mmf_error == FILEINFO_ERROR_NONE) && (size > 0)) {
- ret = __media_svc_malloc_and_strncpy(&content_info->media_meta.artist, p);
- if (ret != MS_MEDIA_ERR_NONE)
- media_svc_error("strcpy error");
- /*media_svc_debug("artist[%d] : %s", size, content_info->media_meta.artist); */
+ content_info->media_meta.artist = g_strdup(p);
} else {
SAFE_FREE(err_attr_name);
- /*media_svc_debug("artist - unknown"); */
}
mmf_error = mm_file_get_attrs(tag, &err_attr_name, MM_FILE_TAG_ALBUM_ARTIST, &p, &size, NULL);
if ((!(extracted_field & MEDIA_SVC_EXTRACTED_FIELD_ALBUM_ARTIST)) && (mmf_error == FILEINFO_ERROR_NONE) && (size > 0)) {
- ret = __media_svc_malloc_and_strncpy(&content_info->media_meta.album_artist, p);
- if (ret != MS_MEDIA_ERR_NONE)
- media_svc_error("strcpy error");
- /*media_svc_debug("album_artist[%d] : %s", size, content_info->media_meta.album_artist); */
+ content_info->media_meta.album_artist = g_strdup(p);
} else {
SAFE_FREE(err_attr_name);
- /*media_svc_debug("album_artist - unknown"); */
}
mmf_error = mm_file_get_attrs(tag, &err_attr_name, MM_FILE_TAG_GENRE, &p, &size, NULL);
if ((!(extracted_field & MEDIA_SVC_EXTRACTED_FIELD_GENRE)) && (mmf_error == FILEINFO_ERROR_NONE) && (size > 0)) {
- ret = __media_svc_malloc_and_strncpy(&content_info->media_meta.genre, p);
- if (ret != MS_MEDIA_ERR_NONE)
- media_svc_error("strcpy error");
+ content_info->media_meta.genre = g_strdup(p);
- /*media_svc_debug("genre : %s", content_info->media_meta.genre); */
/* If genre is Ringtone, it's categorized as sound. But this logic is commented */
/*
if ((strcasecmp("Ringtone", p) == 0) | (strcasecmp("Alert tone", p) == 0)) {
*/
} else {
SAFE_FREE(err_attr_name);
- /*media_svc_debug("genre - unknown"); */
}
mmf_error = mm_file_get_attrs(tag, &err_attr_name, MM_FILE_TAG_TITLE, &p, &size, NULL);
- if ((!(extracted_field & MEDIA_SVC_EXTRACTED_FIELD_TITLE)) && (mmf_error == FILEINFO_ERROR_NONE) && (size > 0)/* && (!isspace(*p))*/) {
+ if ((!(extracted_field & MEDIA_SVC_EXTRACTED_FIELD_TITLE)) && (mmf_error == FILEINFO_ERROR_NONE) && (size > 0)) {
if (!isspace(*p)) {
- ret = __media_svc_malloc_and_strncpy(&content_info->media_meta.title, p);
- if (ret != MS_MEDIA_ERR_NONE)
- media_svc_error("strcpy error");
+ content_info->media_meta.title = g_strdup(p);
extracted_field |= MEDIA_SVC_EXTRACTED_FIELD_TITLE;
} else {
continue;
} else {
media_svc_debug("Not SPACE [%s]", p);
- ret = __media_svc_malloc_and_strncpy(&content_info->media_meta.title, p);
- if (ret != MS_MEDIA_ERR_NONE)
- media_svc_error("strcpy error");
+ content_info->media_meta.title = g_strdup(p);
break;
}
}
mmf_error = mm_file_get_attrs(tag, &err_attr_name, MM_FILE_TAG_DESCRIPTION, &p, &size, NULL);
if ((!(extracted_field & MEDIA_SVC_EXTRACTED_FIELD_DESC)) && (mmf_error == FILEINFO_ERROR_NONE) && (size > 0)) {
- ret = __media_svc_malloc_and_strncpy(&content_info->media_meta.description, p);
- if (ret != MS_MEDIA_ERR_NONE)
- media_svc_error("strcpy error");
- /*media_svc_debug("desc : %s", content_info->media_meta.description); */
+ content_info->media_meta.description = g_strdup(p);
} else {
SAFE_FREE(err_attr_name);
}
mmf_error = mm_file_get_attrs(tag, &err_attr_name, MM_FILE_TAG_AUTHOR, &p, &size, NULL);
if ((!(extracted_field & MEDIA_SVC_EXTRACTED_FIELD_AUTHOR)) && (mmf_error == FILEINFO_ERROR_NONE) && (size > 0)) {
- ret = __media_svc_malloc_and_strncpy(&content_info->media_meta.composer, p);
- if (ret != MS_MEDIA_ERR_NONE)
- media_svc_error("strcpy error");
+ content_info->media_meta.composer = g_strdup(p);
extracted_field |= MEDIA_SVC_EXTRACTED_FIELD_AUTHOR;
- /*media_svc_debug("extract composer from content : %s", content_info->media_meta.composer); */
} else {
- /*media_svc_debug("composer - unknown"); */
SAFE_FREE(err_attr_name);
}
mmf_error = mm_file_get_attrs(tag, &err_attr_name, MM_FILE_TAG_COPYRIGHT, &p, &size, NULL);
if ((!(extracted_field & MEDIA_SVC_EXTRACTED_FIELD_COPYRIGHT)) && (mmf_error == FILEINFO_ERROR_NONE) && (size > 0)) {
- ret = __media_svc_malloc_and_strncpy(&content_info->media_meta.copyright, p);
- if (ret != MS_MEDIA_ERR_NONE)
- media_svc_error("strcpy error");
- extracted_field |= MEDIA_SVC_EXTRACTED_FIELD_AUTHOR;
- /*media_svc_debug("extract copyright from content : %s", content_info->media_meta.copyright); */
+ content_info->media_meta.copyright = g_strdup(p);
+ extracted_field |= MEDIA_SVC_EXTRACTED_FIELD_COPYRIGHT;
} else {
- /*media_svc_debug("copyright - unknown"); */
SAFE_FREE(err_attr_name);
}
if (mmf_error == FILEINFO_ERROR_NONE) {
mmf_error = mm_file_get_attrs(tag, &err_attr_name, MM_FILE_TAG_ALBUM, &p, &size, NULL);
if ((!(extracted_field & MEDIA_SVC_EXTRACTED_FIELD_ALBUM)) && (mmf_error == FILEINFO_ERROR_NONE) && (size > 0)) {
- ret = __media_svc_malloc_and_strncpy(&content_info->media_meta.album, p);
- if (ret != MS_MEDIA_ERR_NONE)
- media_svc_error("strcpy error");
-
- /*media_svc_debug("album[%d] : %s", size, content_info->media_meta.album); */
+ content_info->media_meta.album = g_strdup(p);
} else {
SAFE_FREE(err_attr_name);
- /*media_svc_debug("album - unknown"); */
}
mmf_error = mm_file_get_attrs(tag, &err_attr_name, MM_FILE_TAG_ARTIST, &p, &size, NULL);
if ((!(extracted_field & MEDIA_SVC_EXTRACTED_FIELD_ARTIST)) && (mmf_error == FILEINFO_ERROR_NONE) && (size > 0)) {
- ret = __media_svc_malloc_and_strncpy(&content_info->media_meta.artist, p);
- if (ret != MS_MEDIA_ERR_NONE)
- media_svc_error("strcpy error");
- /*media_svc_debug("artist[%d] : %s", size, content_info->media_meta.artist); */
+ content_info->media_meta.artist = g_strdup(p);
} else {
SAFE_FREE(err_attr_name);
- /*media_svc_debug("artist - unknown"); */
}
mmf_error = mm_file_get_attrs(tag, &err_attr_name, MM_FILE_TAG_ALBUM_ARTIST, &p, &size, NULL);
if ((!(extracted_field & MEDIA_SVC_EXTRACTED_FIELD_ALBUM_ARTIST)) && (mmf_error == FILEINFO_ERROR_NONE) && (size > 0)) {
- ret = __media_svc_malloc_and_strncpy(&content_info->media_meta.album_artist, p);
- if (ret != MS_MEDIA_ERR_NONE)
- media_svc_error("strcpy error");
- /*media_svc_debug("album_artist[%d] : %s", size, content_info->media_meta.album_artist); */
+ content_info->media_meta.album_artist = g_strdup(p);
} else {
SAFE_FREE(err_attr_name);
- /*media_svc_debug("album_artist - unknown"); */
}
mmf_error = mm_file_get_attrs(tag, &err_attr_name, MM_FILE_TAG_GENRE, &p, &size, NULL);
if ((!(extracted_field & MEDIA_SVC_EXTRACTED_FIELD_GENRE)) && (mmf_error == FILEINFO_ERROR_NONE) && (size > 0)) {
- ret = __media_svc_malloc_and_strncpy(&content_info->media_meta.genre, p);
- if (ret != MS_MEDIA_ERR_NONE)
- media_svc_error("strcpy error");
+ content_info->media_meta.genre = g_strdup(p);
- /*media_svc_debug("genre : %s", content_info->media_meta.genre); */
/* If genre is Ringtone, it's categorized as sound. But this logic is commented */
/*
if ((strcasecmp("Ringtone", p) == 0) | (strcasecmp("Alert tone", p) == 0)) {
*/
} else {
SAFE_FREE(err_attr_name);
- /*media_svc_debug("genre - unknown"); */
}
mmf_error = mm_file_get_attrs(tag, &err_attr_name, MM_FILE_TAG_TITLE, &p, &size, NULL);
- if ((!(extracted_field & MEDIA_SVC_EXTRACTED_FIELD_TITLE)) && (mmf_error == FILEINFO_ERROR_NONE) && (size > 0)/* && (!isspace(*p))*/) {
+ if ((!(extracted_field & MEDIA_SVC_EXTRACTED_FIELD_TITLE)) && (mmf_error == FILEINFO_ERROR_NONE) && (size > 0)) {
if (!isspace(*p)) {
- ret = __media_svc_malloc_and_strncpy(&content_info->media_meta.title, p);
- if (ret != MS_MEDIA_ERR_NONE)
- media_svc_error("strcpy error");
-
+ content_info->media_meta.title = g_strdup(p);
extracted_field |= MEDIA_SVC_EXTRACTED_FIELD_TITLE;
} else {
int idx = 0;
continue;
} else {
media_svc_debug("Not SPACE [%s]", p);
- ret = __media_svc_malloc_and_strncpy(&content_info->media_meta.title, p);
- if (ret != MS_MEDIA_ERR_NONE)
- media_svc_error("strcpy error");
+ content_info->media_meta.title = g_strdup(p);
break;
}
}
mmf_error = mm_file_get_attrs(tag, &err_attr_name, MM_FILE_TAG_DESCRIPTION, &p, &size, NULL);
if ((!(extracted_field & MEDIA_SVC_EXTRACTED_FIELD_DESC)) && (mmf_error == FILEINFO_ERROR_NONE) && (size > 0)) {
- ret = __media_svc_malloc_and_strncpy(&content_info->media_meta.description, p);
- if (ret != MS_MEDIA_ERR_NONE)
- media_svc_error("strcpy error");
- /*media_svc_debug("desc : %s", content_info->media_meta.description); */
+ content_info->media_meta.description = g_strdup(p);
} else {
SAFE_FREE(err_attr_name);
}
mmf_error = mm_file_get_attrs(tag, &err_attr_name, MM_FILE_TAG_SPHERICAL, &content_info->media_meta.is_360, NULL);
-
if (mmf_error != FILEINFO_ERROR_NONE)
SAFE_FREE(err_attr_name);
p_value++;
}
*time_value = '\0';
- ret = __media_svc_malloc_and_strncpy(&content_info->media_meta.recorded_date, time_info);
+ content_info->media_meta.recorded_date = g_strdup(time_info);
SAFE_FREE(time_info);
} else {
media_svc_error("memory allocation error");
ret = MS_MEDIA_ERR_OUT_OF_MEMORY;
}
} else {
- ret = __media_svc_malloc_and_strncpy(&content_info->media_meta.recorded_date, p);
+ content_info->media_meta.recorded_date = g_strdup(p);
}
- if (ret != MS_MEDIA_ERR_NONE) {
- media_svc_error("strcpy error");
- } else {
+ if (STRING_VALID(content_info->media_meta.recorded_date)) {
/* This is same as datetaken */
content_info->media_meta.datetaken = g_strdup(content_info->media_meta.recorded_date);
else
media_svc_debug("Timeline : %ld", content_info->timeline);
}
- /*media_svc_debug("Recorded date : %s", content_info->media_meta.recorded_date); */
} else {
SAFE_FREE(err_attr_name);
}
mmf_error = mm_file_get_attrs(tag, &err_attr_name, MM_FILE_TAG_AUTHOR, &p, &size, NULL);
if ((!(extracted_field & MEDIA_SVC_EXTRACTED_FIELD_AUTHOR)) && (mmf_error == FILEINFO_ERROR_NONE) && (size > 0)) {
- ret = __media_svc_malloc_and_strncpy(&content_info->media_meta.composer, p);
- if (ret != MS_MEDIA_ERR_NONE)
- media_svc_error("strcpy error");
+ content_info->media_meta.composer = g_strdup(p);
extracted_field |= MEDIA_SVC_EXTRACTED_FIELD_AUTHOR;
- /*media_svc_debug("extract composer from content : %s", content_info->media_meta.composer); */
} else {
- /*media_svc_debug("composer - unknown"); */
SAFE_FREE(err_attr_name);
}
mmf_error = mm_file_get_attrs(tag, &err_attr_name, MM_FILE_TAG_COPYRIGHT, &p, &size, NULL);
if ((!(extracted_field & MEDIA_SVC_EXTRACTED_FIELD_COPYRIGHT)) && (mmf_error == FILEINFO_ERROR_NONE) && (size > 0)) {
- ret = __media_svc_malloc_and_strncpy(&content_info->media_meta.copyright, p);
- if (ret != MS_MEDIA_ERR_NONE)
- media_svc_error("strcpy error");
- extracted_field |= MEDIA_SVC_EXTRACTED_FIELD_AUTHOR;
- /*media_svc_debug("extract copyright from content : %s", content_info->media_meta.copyright); */
+ content_info->media_meta.copyright = g_strdup(p);
+ extracted_field |= MEDIA_SVC_EXTRACTED_FIELD_COPYRIGHT;
} else {
- /*media_svc_debug("copyright - unknown"); */
SAFE_FREE(err_attr_name);
}
mmf_error = mm_file_get_attrs(tag, &err_attr_name, MM_FILE_TAG_TRACK_NUM, &p, &size, NULL);
if ((mmf_error == FILEINFO_ERROR_NONE) && (size > 0)) {
- ret = __media_svc_malloc_and_strncpy(&content_info->media_meta.track_num, p);
- if (ret != MS_MEDIA_ERR_NONE)
- media_svc_error("strcpy error");
+ content_info->media_meta.track_num = g_strdup(p);
} else {
SAFE_FREE(err_attr_name);
}
if ((!(extracted_field & MEDIA_SVC_EXTRACTED_FIELD_YEAR)) && (mmf_error == FILEINFO_ERROR_NONE) && (size == 4)) {
int year = 0;
if ((p != NULL) && ((ret != __media_svc_safe_atoi(p, &year)) == MS_MEDIA_ERR_NONE)) {
- ret = __media_svc_malloc_and_strncpy(&content_info->media_meta.year, p);
- if (ret != MS_MEDIA_ERR_NONE)
- media_svc_error("strcpy error");
+ content_info->media_meta.year = g_strdup(p);
} else {
media_svc_debug("Wrong Year Information [%s]", p);
}
mmf_error = mm_file_get_attrs(tag, &err_attr_name, MM_FILE_TAG_RATING, &p, &size, NULL);
if ((mmf_error == FILEINFO_ERROR_NONE) && (size > 0)) {
- content_info->media_meta.rating = atoi(p);
+ int rate = 0;
+ if (__media_svc_safe_atoi(p, &rate) == MS_MEDIA_ERR_NONE)
+ content_info->media_meta.rating = rate;
} else {
SAFE_FREE(err_attr_name);
content_info->media_meta.rating = 0;
if (ret != MS_MEDIA_ERR_NONE) {
media_svc_error("Fail to Save Thumbnail Image");
} else {
- ret = __media_svc_malloc_and_strncpy(&content_info->thumbnail_path, thumb_path);
- if (ret != MS_MEDIA_ERR_NONE)
- media_svc_error("strcpy error");
+ content_info->thumbnail_path = g_strdup(thumb_path);
}
}
}
ret = _media_svc_get_and_append_folder_id_by_path(db_handle, storage_id, path, storage_type, folder_uuid, uid);
media_svc_retv_del_if(ret != MS_MEDIA_ERR_NONE, ret, &content_info);
- ret = __media_svc_malloc_and_strncpy(&content_info.folder_uuid, folder_uuid);
- media_svc_retv_del_if(ret != MS_MEDIA_ERR_NONE, ret, &content_info);
+ content_info.folder_uuid = g_strdup(folder_uuid);
+ media_svc_retv_del_if(content_info.folder_uuid == NULL, MS_MEDIA_ERR_INTERNAL, &content_info);
if (g_media_svc_insert_item_data_cnt == 1) {
ret = _media_svc_get_and_append_folder_id_by_path(db_handle, storage_id, path, storage_type, folder_uuid, uid);
media_svc_retv_del_if(ret != MS_MEDIA_ERR_NONE, ret, &content_info);
- ret = __media_svc_malloc_and_strncpy(&content_info.folder_uuid, folder_uuid);
- media_svc_retv_del_if(ret != MS_MEDIA_ERR_NONE, ret, &content_info);
+ content_info.folder_uuid = g_strdup(folder_uuid);
+ media_svc_retv_del_if(content_info.folder_uuid == NULL, MS_MEDIA_ERR_INTERNAL, &content_info);
/* Extracting thumbnail */
if (content_info.thumbnail_path == NULL) {
ret = _media_svc_request_thumbnail(content_info.path, thumb_path, sizeof(thumb_path), uid);
if (ret == MS_MEDIA_ERR_NONE)
- ret = __media_svc_malloc_and_strncpy(&(content_info.thumbnail_path), thumb_path);
+ content_info.thumbnail_path = g_strdup(thumb_path);
}
}
ret = _media_svc_request_thumbnail(content_info.path, thumb_path, sizeof(thumb_path), uid);
if (ret == MS_MEDIA_ERR_NONE)
- ret = __media_svc_malloc_and_strncpy(&(content_info.thumbnail_path), thumb_path);
+ content_info.thumbnail_path = g_strdup(thumb_path);
}
}
static int __media_svc_copy_para_to_content(media_svc_content_info_s *content_info, media_svc_content_info_s *new_content_info)
{
- int ret = MS_MEDIA_ERR_NONE;
-
media_svc_retvm_if(content_info == NULL, MS_MEDIA_ERR_INVALID_PARAMETER, "Handle is NULL");
media_svc_retvm_if(new_content_info == NULL, MS_MEDIA_ERR_INVALID_PARAMETER, "Handle is NULL");
new_content_info->played_count = content_info->played_count;
new_content_info->favourate = content_info->favourate;
- if (STRING_VALID(content_info->file_name)) {
- ret = __media_svc_malloc_and_strncpy(&new_content_info->file_name, content_info->file_name);
- if (ret != MS_MEDIA_ERR_NONE)
- media_svc_error("strcpy file_name failed");
- }
-
- if (STRING_VALID(content_info->media_meta.title)) {
- ret = __media_svc_malloc_and_strncpy(&new_content_info->media_meta.title, content_info->media_meta.title);
- if (ret != MS_MEDIA_ERR_NONE)
- media_svc_error("strcpy title failed");
- }
-
- if (STRING_VALID(content_info->media_meta.album)) {
- ret = __media_svc_malloc_and_strncpy(&new_content_info->media_meta.album, content_info->media_meta.album);
- if (ret != MS_MEDIA_ERR_NONE)
- media_svc_error("strcpy album failed");
- }
-
- if (STRING_VALID(content_info->media_meta.artist)) {
- ret = __media_svc_malloc_and_strncpy(&new_content_info->media_meta.artist, content_info->media_meta.artist);
- if (ret != MS_MEDIA_ERR_NONE)
- media_svc_error("strcpy artist failed");
- }
-
- if (STRING_VALID(content_info->media_meta.genre)) {
- ret = __media_svc_malloc_and_strncpy(&new_content_info->media_meta.genre, content_info->media_meta.genre);
- if (ret != MS_MEDIA_ERR_NONE)
- media_svc_error("strcpy genre failed");
- }
-
- if (STRING_VALID(content_info->media_meta.composer)) {
- ret = __media_svc_malloc_and_strncpy(&new_content_info->media_meta.composer, content_info->media_meta.composer);
- if (ret != MS_MEDIA_ERR_NONE)
- media_svc_error("strcpy composer failed");
- }
-
- if (STRING_VALID(content_info->media_meta.year)) {
- ret = __media_svc_malloc_and_strncpy(&new_content_info->media_meta.year, content_info->media_meta.year);
- if (ret != MS_MEDIA_ERR_NONE)
- media_svc_error("strcpy year failed");
- }
-
- if (STRING_VALID(content_info->media_meta.recorded_date)) {
- ret = __media_svc_malloc_and_strncpy(&new_content_info->media_meta.recorded_date, content_info->media_meta.recorded_date);
- if (ret != MS_MEDIA_ERR_NONE)
- media_svc_error("strcpy recorded_date failed");
- }
-
- if (STRING_VALID(content_info->media_meta.copyright)) {
- ret = __media_svc_malloc_and_strncpy(&new_content_info->media_meta.copyright, content_info->media_meta.copyright);
- if (ret != MS_MEDIA_ERR_NONE)
- media_svc_error("strcpy copyright failed");
- }
-
- if (STRING_VALID(content_info->media_meta.track_num)) {
- ret = __media_svc_malloc_and_strncpy(&new_content_info->media_meta.track_num, content_info->media_meta.track_num);
- if (ret != MS_MEDIA_ERR_NONE)
- media_svc_error("strcpy track_num failed");
- }
-
- if (STRING_VALID(content_info->media_meta.description)) {
- ret = __media_svc_malloc_and_strncpy(&new_content_info->media_meta.description, content_info->media_meta.description);
- if (ret != MS_MEDIA_ERR_NONE)
- media_svc_error("strcpy description failed");
- }
-
- if (STRING_VALID(content_info->media_meta.weather)) {
- ret = __media_svc_malloc_and_strncpy(&new_content_info->media_meta.weather, content_info->media_meta.weather);
- if (ret != MS_MEDIA_ERR_NONE)
- media_svc_error("strcpy weather failed");
- }
-
- if (STRING_VALID(content_info->media_meta.category)) {
- ret = __media_svc_malloc_and_strncpy(&new_content_info->media_meta.category, content_info->media_meta.category);
- if (ret != MS_MEDIA_ERR_NONE)
- media_svc_error("strcpy category failed");
- }
-
- if (STRING_VALID(content_info->media_meta.keyword)) {
- ret = __media_svc_malloc_and_strncpy(&new_content_info->media_meta.keyword, content_info->media_meta.keyword);
- if (ret != MS_MEDIA_ERR_NONE)
- media_svc_error("strcpy keyword failed");
- }
-
- if (STRING_VALID(content_info->media_meta.location_tag)) {
- ret = __media_svc_malloc_and_strncpy(&new_content_info->media_meta.location_tag, content_info->media_meta.location_tag);
- if (ret != MS_MEDIA_ERR_NONE)
- media_svc_error("strcpy location_tag failed");
- }
-
- if (STRING_VALID(content_info->media_meta.content_name)) {
- ret = __media_svc_malloc_and_strncpy(&new_content_info->media_meta.content_name, content_info->media_meta.content_name);
- if (ret != MS_MEDIA_ERR_NONE)
- media_svc_error("strcpy content_name failed");
- }
-
- if (STRING_VALID(content_info->media_meta.age_rating)) {
- ret = __media_svc_malloc_and_strncpy(&new_content_info->media_meta.age_rating, content_info->media_meta.age_rating);
- if (ret != MS_MEDIA_ERR_NONE)
- media_svc_error("strcpy age_rating failed");
- }
-
- if (STRING_VALID(content_info->media_meta.author)) {
- ret = __media_svc_malloc_and_strncpy(&new_content_info->media_meta.author, content_info->media_meta.author);
- if (ret != MS_MEDIA_ERR_NONE)
- media_svc_error("strcpy author failed");
- }
-
- if (STRING_VALID(content_info->media_meta.provider)) {
- ret = __media_svc_malloc_and_strncpy(&new_content_info->media_meta.provider, content_info->media_meta.provider);
- if (ret != MS_MEDIA_ERR_NONE)
- media_svc_error("strcpy provider failed");
- }
+ new_content_info->file_name = g_strdup(content_info->file_name);
+ new_content_info->media_meta.title = g_strdup(content_info->media_meta.title);
+ new_content_info->media_meta.album = g_strdup(content_info->media_meta.album);
+ new_content_info->media_meta.artist = g_strdup(content_info->media_meta.artist);
+ new_content_info->media_meta.genre = g_strdup(content_info->media_meta.genre);
+ new_content_info->media_meta.composer = g_strdup(content_info->media_meta.composer);
+ new_content_info->media_meta.year = g_strdup(content_info->media_meta.year);
+ new_content_info->media_meta.recorded_date = g_strdup(content_info->media_meta.recorded_date);
+ new_content_info->media_meta.copyright = g_strdup(content_info->media_meta.copyright);
+ new_content_info->media_meta.track_num = g_strdup(content_info->media_meta.track_num);
+ new_content_info->media_meta.description = g_strdup(content_info->media_meta.description);
+ new_content_info->media_meta.weather = g_strdup(content_info->media_meta.weather);
+ new_content_info->media_meta.category = g_strdup(content_info->media_meta.category);
+ new_content_info->media_meta.keyword = g_strdup(content_info->media_meta.keyword);
+ new_content_info->media_meta.location_tag = g_strdup(content_info->media_meta.location_tag);
+ new_content_info->media_meta.content_name = g_strdup(content_info->media_meta.content_name);
+ new_content_info->media_meta.age_rating = g_strdup(content_info->media_meta.age_rating);
+ new_content_info->media_meta.author = g_strdup(content_info->media_meta.author);
+ new_content_info->media_meta.provider = g_strdup(content_info->media_meta.provider);
if (STRING_VALID(content_info->media_meta.datetaken)) {
- ret = __media_svc_malloc_and_strncpy(&new_content_info->media_meta.datetaken, content_info->media_meta.datetaken);
- if (ret != MS_MEDIA_ERR_NONE)
- media_svc_error("strcpy datetaken failed");
+ new_content_info->media_meta.datetaken = g_strdup(content_info->media_meta.datetaken);
new_content_info->timeline = __media_svc_get_timeline_from_str(content_info->media_meta.datetaken);
if (new_content_info->timeline == 0) {
new_content_info->media_meta.rating = content_info->media_meta.rating;
- return 0;
+ return MS_MEDIA_ERR_NONE;
}
int media_svc_insert_item_immediately_with_data(MediaSvcHandle *handle, media_svc_content_info_s *content_info, uid_t uid)
ret = _media_svc_request_thumbnail(_new_content_info.path, thumb_path, sizeof(thumb_path), uid);
if (ret == MS_MEDIA_ERR_NONE)
- ret = __media_svc_malloc_and_strncpy(&(_new_content_info.thumbnail_path), thumb_path);
+ _new_content_info.thumbnail_path = g_strdup(thumb_path);
}
}
/* Set or Get folder id */
ret = _media_svc_get_and_append_folder_id_by_path(handle, _new_content_info.storage_uuid, _new_content_info.path, _new_content_info.storage_type, folder_uuid, uid);
- media_svc_retv_if(ret != MS_MEDIA_ERR_NONE, ret);
-
- ret = __media_svc_malloc_and_strncpy(&_new_content_info.folder_uuid, folder_uuid);
media_svc_retv_del_if(ret != MS_MEDIA_ERR_NONE, ret, &_new_content_info);
+ _new_content_info.folder_uuid = g_strdup(folder_uuid);
+ media_svc_retv_del_if(_new_content_info.folder_uuid == NULL, MS_MEDIA_ERR_INTERNAL, &_new_content_info);
+
/* register album table data */
int album_id = 0;
ret = _media_svc_get_and_append_folder_id_by_path(db_handle, storage_id, path, storage_type, folder_uuid, uid);
media_svc_retv_del_if(ret != MS_MEDIA_ERR_NONE, ret, &content_info);
- ret = __media_svc_malloc_and_strncpy(&content_info.folder_uuid, folder_uuid);
- media_svc_retv_del_if(ret != MS_MEDIA_ERR_NONE, ret, &content_info);
+ content_info.folder_uuid = g_strdup(folder_uuid);
+ media_svc_retv_del_if(content_info.folder_uuid == NULL, MS_MEDIA_ERR_INTERNAL, &content_info);
if (g_media_svc_insert_item_data_cnt == 1) {
media_type = db_data->media_type;
/* media_svc_debug("path is %s, media type %d", db_data->path, media_type); */
memset(&content_info, 0, sizeof(media_svc_content_info_s));
- __media_svc_malloc_and_strncpy(&content_info.path, db_data->path);
+ content_info.path = g_strdup(db_data->path);
content_info.media_type = media_type;
content_info.storage_type = storage_type;