int media_filter_get_order_v2(filter_h filter, char **order);
+/* Only for system session process */
+int media_content_connect_with_uid(uid_t uid);
+
+
#ifdef __cplusplus
}
#endif /* __cplusplus */
int _content_error_capi(int type, int cotent_error);
int _content_query_sql(char *query_str);
MediaSvcHandle* _content_get_db_handle(void);
+uid_t _content_get_uid(void);
attribute_h _content_get_attirbute_handle(void);
attribute_h _content_get_alias_attirbute_handle(void);
int _media_info_get_media_info_from_db(const char *path, const char *storage_id, media_info_h media);
int media_filter_get_order_v2(filter_h filter, char **order);
+/* Only for system session process */
+int media_content_connect_with_uid(uid_t uid);
+
+
#ifdef __cplusplus
}
#endif /* __cplusplus */
int _content_error_capi(int type, int cotent_error);
int _content_query_sql(char *query_str);
MediaSvcHandle* _content_get_db_handle(void);
+uid_t _content_get_uid(void);
attribute_h _content_get_attirbute_handle(void);
attribute_h _content_get_alias_attirbute_handle(void);
int _media_info_get_media_info_from_db(const char *path, const char *storage_id, media_info_h media);
Name: capi-content-media-content
Summary: A Media content library in Tizen Native API
-Version: 0.3.19
+Version: 0.3.20
Release: 0
Group: Multimedia/API
License: Apache-2.0
static int ref_count = 0;
static GMutex db_mutex;
static __thread media_noti_cb_s *g_noti_info = NULL;
+static uid_t content_g_uid = 0;
#if 0
static int __media_content_create_attr_handle(void);
return db_handle;
}
+uid_t _content_get_uid(void)
+{
+ if (content_g_uid == 0)
+ return tzplatform_getuid(TZ_USER_NAME);
+ else
+ return content_g_uid;
+}
+
int _content_query_prepare(sqlite3_stmt **stmt, char *select_query, char *condition_query, char *option_query)
{
int len = 0;
int ret = MEDIA_CONTENT_ERROR_NONE;
/*DB will be updated by Media Server.*/
- ret = media_svc_request_update_db(query_str, tzplatform_getuid(TZ_USER_NAME));
+ ret = media_svc_request_update_db(query_str, _content_get_uid());
return _content_error_capi(MEDIA_CONTENT_TYPE, ret);
}
if (db_handle == NULL) {
ret = __media_content_create_attribute_handles();
if (ret == MEDIA_CONTENT_ERROR_NONE) {
- ret = media_svc_connect(&db_handle, tzplatform_getuid(TZ_USER_NAME), false);
+ ret = media_svc_connect(&db_handle, _content_get_uid(), false);
ret = _content_error_capi(MEDIA_CONTENT_TYPE, ret);
if (ret == MEDIA_CONTENT_ERROR_NONE)
ref_count++;
return ret;
}
+int media_content_connect_with_uid(uid_t uid)
+{
+ media_content_sec_debug("media_content_connect_with_uid [%d]", uid);
+ content_g_uid = uid;
+
+ return media_content_connect();
+}
+
int media_content_disconnect(void)
{
int ret = MEDIA_CONTENT_ERROR_NONE;
media_content_retvm_if(ignore_file == TRUE, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Invalid path");
memset(storage_id, 0x00, sizeof(storage_id));
- ret = media_svc_get_storage_id(_content_get_db_handle(), repl_path, storage_id, tzplatform_getuid(TZ_USER_NAME));
+ ret = media_svc_get_storage_id(_content_get_db_handle(), repl_path, storage_id, _content_get_uid());
if (ret != MS_MEDIA_ERR_NONE) {
media_content_error("media_svc_get_storage_id failed : %d", ret);
return _content_error_capi(MEDIA_CONTENT_TYPE, ret);
media_svc_storage_type_e storage_type;
- ret = media_svc_get_storage_type(repl_path, &storage_type, tzplatform_getuid(TZ_USER_NAME));
+ ret = media_svc_get_storage_type(repl_path, &storage_type, _content_get_uid());
if (ret != MS_MEDIA_ERR_NONE) {
media_content_sec_error("media_svc_get_storage_type failed : %d (%s)", ret, repl_path);
return _content_error_capi(MEDIA_CONTENT_TYPE, ret);
ret = media_svc_check_item_exist_by_path(_content_get_db_handle(), storage_id, repl_path);
if (ret == MS_MEDIA_ERR_NONE) {
/* Refresh */
- ret = media_svc_refresh_item(_content_get_db_handle(), storage_id, storage_type, repl_path, tzplatform_getuid(TZ_USER_NAME));
+ ret = media_svc_refresh_item(_content_get_db_handle(), storage_id, storage_type, repl_path, _content_get_uid());
if (ret != MS_MEDIA_ERR_NONE) {
media_content_error("media_svc_refresh_item failed : %d", ret);
return _content_error_capi(MEDIA_CONTENT_TYPE, ret);
} else if (ret == MS_MEDIA_ERR_DB_NO_RECORD) {
/* Insert */
- ret = media_svc_insert_item_immediately(_content_get_db_handle(), storage_id, storage_type, repl_path, tzplatform_getuid(TZ_USER_NAME));
+ ret = media_svc_insert_item_immediately(_content_get_db_handle(), storage_id, storage_type, repl_path, _content_get_uid());
if (ret != MS_MEDIA_ERR_NONE) {
if (ret == MS_MEDIA_ERR_DB_CONSTRAINT_FAIL) {
media_content_sec_error("This item is already inserted. This may be normal operation because other process already did this (%s)", repl_path);
} else {
/* This means this path has to be deleted */
media_content_debug("This path doesn't exists in file system... So now start to delete it from DB");
- ret = media_svc_delete_item_by_path(_content_get_db_handle(), storage_id, repl_path, tzplatform_getuid(TZ_USER_NAME));
+ ret = media_svc_delete_item_by_path(_content_get_db_handle(), storage_id, repl_path, _content_get_uid());
if (ret != MS_MEDIA_ERR_NONE) {
if (ret == MS_MEDIA_ERR_DB_NO_RECORD) {
media_content_error("Does not exist in media DB also... So, this is an invalid parameter");
} else {
/* This means this folder has to be deleted */
/* Or, it is real invalid path.. check storage type */
- ret = media_svc_get_storage_type(repl_path, &storage_type, tzplatform_getuid(TZ_USER_NAME));
+ ret = media_svc_get_storage_type(repl_path, &storage_type, _content_get_uid());
if (ret != MS_MEDIA_ERR_NONE) {
media_content_sec_error("media_svc_get_storage_type failed : %d (%s)", ret, repl_path);
return _content_error_capi(MEDIA_CONTENT_TYPE, ret);
media_content_debug("This path doesn't exists in file system... So will be deleted it from DB");
}
- ret = media_svc_get_storage_id(_content_get_db_handle(), repl_path, storage_id, tzplatform_getuid(TZ_USER_NAME));
+ ret = media_svc_get_storage_id(_content_get_db_handle(), repl_path, storage_id, _content_get_uid());
if (ret != MS_MEDIA_ERR_NONE) {
media_content_error("media_svc_get_storage_id failed : %d", ret);
return _content_error_capi(MEDIA_CONTENT_TYPE, ret);
cb_data->callback = callback;
cb_data->user_data = user_data;
- ret = media_directory_scanning_async(repl_path, storage_id, is_recursive, _media_content_scan_cb, cb_data, tzplatform_getuid(TZ_USER_NAME));
+ ret = media_directory_scanning_async(repl_path, storage_id, is_recursive, _media_content_scan_cb, cb_data, _content_get_uid());
if (ret != MS_MEDIA_ERR_NONE) {
media_content_error("media_directory_scanning_async failed : %d", ret);
SAFE_FREE(cb_data);
cb_data->callback = callback;
cb_data->user_data = user_data;
- ret = media_svc_get_storage_id(_content_get_db_handle(), path, storage_id, tzplatform_getuid(TZ_USER_NAME));
+ ret = media_svc_get_storage_id(_content_get_db_handle(), path, storage_id, _content_get_uid());
/*FIX ME. need to check ret value?*/
- ret = media_directory_scanning_async(path, storage_id, is_recursive, _media_content_scan_cb_v2, cb_data, tzplatform_getuid(TZ_USER_NAME));
+ ret = media_directory_scanning_async(path, storage_id, is_recursive, _media_content_scan_cb_v2, cb_data, _content_get_uid());
if (ret != MS_MEDIA_ERR_NONE)
media_content_error("media_directory_scanning_async failed : %d", ret);
ret = _media_content_replace_path(path, repl_path);
media_content_retvm_if(!STRING_VALID(repl_path), MEDIA_CONTENT_ERROR_INVALID_OPERATION, "path replacement failed");
- ret = media_directory_scanning_cancel(repl_path, tzplatform_getuid(TZ_USER_NAME));
+ ret = media_directory_scanning_cancel(repl_path, _content_get_uid());
if (ret != MS_MEDIA_ERR_NONE)
media_content_error("media_directory_scanning_async failed : %d", ret);
return ret;
}
- ret = media_svc_rename_folder(_content_get_db_handle(), _folder->storage_uuid, g_src_path, repl_path, tzplatform_getuid(TZ_USER_NAME));
+ ret = media_svc_rename_folder(_content_get_db_handle(), _folder->storage_uuid, g_src_path, repl_path, _content_get_uid());
SAFE_FREE(g_src_path);
return _content_error_capi(MEDIA_CONTENT_TYPE, ret);
_cb_data->insert_list_path = g_strdup(list_path);
if (insert_type == MEDIA_BATCH_INSERT_NORMAL)
- ret = media_files_register(list_path, __media_info_insert_completed_cb, _cb_data, tzplatform_getuid(TZ_USER_NAME));
+ ret = media_files_register(list_path, __media_info_insert_completed_cb, _cb_data, _content_get_uid());
else if (insert_type == MEDIA_BATCH_INSERT_BURSTSHOT)
- ret = media_burstshot_register(list_path, __media_info_insert_completed_cb, _cb_data, tzplatform_getuid(TZ_USER_NAME));
+ ret = media_burstshot_register(list_path, __media_info_insert_completed_cb, _cb_data, _content_get_uid());
else
ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
media_content_retvm_if(ignore_dir == TRUE, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Invalid folder path");
memset(storage_id, 0x00, sizeof(storage_id));
- ret = media_svc_get_storage_id(_content_get_db_handle(), repl_path, storage_id, tzplatform_getuid(TZ_USER_NAME));
+ ret = media_svc_get_storage_id(_content_get_db_handle(), repl_path, storage_id, _content_get_uid());
if (ret != MS_MEDIA_ERR_NONE) {
media_content_error("media_svc_get_storage_id failed : %d", ret);
return _content_error_capi(MEDIA_CONTENT_TYPE, ret);
media_svc_storage_type_e storage_type = 0;
- ret = media_svc_get_storage_type(repl_path, &storage_type, tzplatform_getuid(TZ_USER_NAME));
+ ret = media_svc_get_storage_type(repl_path, &storage_type, _content_get_uid());
if (ret != MS_MEDIA_ERR_NONE) {
media_content_sec_error("media_svc_get_storage_type failed : %d", ret);
return _content_error_capi(MEDIA_CONTENT_TYPE, ret);
}
- ret = media_svc_insert_item_immediately(_content_get_db_handle(), storage_id, storage_type, repl_path, tzplatform_getuid(TZ_USER_NAME));
+ ret = media_svc_insert_item_immediately(_content_get_db_handle(), storage_id, storage_type, repl_path, _content_get_uid());
if (ret != MS_MEDIA_ERR_NONE) {
if (ret == MS_MEDIA_ERR_DB_CONSTRAINT_FAIL) {
return ret;
}
- ret = media_svc_delete_item_by_path(_content_get_db_handle(), storage_id, path, tzplatform_getuid(TZ_USER_NAME));
+ ret = media_svc_delete_item_by_path(_content_get_db_handle(), storage_id, path, _content_get_uid());
SAFE_FREE(path);
return _content_error_capi(MEDIA_CONTENT_TYPE, ret);
}
memset(storage_id, 0x00, sizeof(storage_id));
- ret = media_svc_get_storage_id(_content_get_db_handle(), repl_path, storage_id, tzplatform_getuid(TZ_USER_NAME));
+ ret = media_svc_get_storage_id(_content_get_db_handle(), repl_path, storage_id, _content_get_uid());
if (ret != MS_MEDIA_ERR_NONE) {
media_content_error("media_svc_get_storage_id failed : %d", ret);
SAFE_FREE(file_path);
return _content_error_capi(MEDIA_CONTENT_TYPE, ret);
}
- ret = media_svc_refresh_item(_content_get_db_handle(), storage_id, storage_type, repl_path, tzplatform_getuid(TZ_USER_NAME));
+ ret = media_svc_refresh_item(_content_get_db_handle(), storage_id, storage_type, repl_path, _content_get_uid());
if (ret != MS_MEDIA_ERR_NONE)
ret = _content_error_capi(MEDIA_CONTENT_TYPE, ret);
media_content_retvm_if(ignore_dir == TRUE, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Invalid folder path");
- ret = media_svc_get_storage_type(org_repl_path, &src_storage_type, tzplatform_getuid(TZ_USER_NAME));
+ ret = media_svc_get_storage_type(org_repl_path, &src_storage_type, _content_get_uid());
if (ret != MS_MEDIA_ERR_NONE) {
media_content_sec_error("media_svc_get_storage_type failed : %d", ret);
return _content_error_capi(MEDIA_CONTENT_TYPE, ret);
}
- ret = media_svc_get_storage_type(repl_path, &dst_storage_type, tzplatform_getuid(TZ_USER_NAME));
+ ret = media_svc_get_storage_type(repl_path, &dst_storage_type, _content_get_uid());
if (ret != MS_MEDIA_ERR_NONE) {
media_content_sec_error("media_svc_get_storage_type failed : %d", ret);
return _content_error_capi(MEDIA_CONTENT_TYPE, ret);
}
memset(storage_id, 0x00, sizeof(storage_id));
- ret = media_svc_get_storage_id(_content_get_db_handle(), org_repl_path, storage_id, tzplatform_getuid(TZ_USER_NAME));
+ ret = media_svc_get_storage_id(_content_get_db_handle(), org_repl_path, storage_id, _content_get_uid());
if (ret != MS_MEDIA_ERR_NONE) {
media_content_error("media_svc_get_storage_id failed : %d", ret);
return _content_error_capi(MEDIA_CONTENT_TYPE, ret);
}
- ret = media_svc_move_item(_content_get_db_handle(), storage_id, src_storage_type, org_repl_path, dst_storage_type, repl_path, tzplatform_getuid(TZ_USER_NAME));
+ ret = media_svc_move_item(_content_get_db_handle(), storage_id, src_storage_type, org_repl_path, dst_storage_type, repl_path, _content_get_uid());
return _content_error_capi(MEDIA_CONTENT_TYPE, ret);
}
_thumb_cb->user_data = user_data;
_thumb_cb->thumbnail_completed_cb = callback;
- ret = thumbnail_request_from_db_async(_media->request_id, repl_path, (ThumbFunc)__media_info_thumbnail_completed_cb, (void *)_thumb_cb, tzplatform_getuid(TZ_USER_NAME));
+ ret = thumbnail_request_from_db_async(_media->request_id, repl_path, (ThumbFunc)__media_info_thumbnail_completed_cb, (void *)_thumb_cb, _content_get_uid());
ret = _content_error_capi(MEDIA_THUMBNAIL_TYPE, ret);
} else {
media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
_face_cb->user_data = user_data;
_face_cb->face_completed_cb = callback;
- ret = dcm_request_extract_face_async(_media->face_request_id, repl_path, (FaceFunc)__media_info_face_completed_cb, (void *)_face_cb, tzplatform_getuid(TZ_USER_NAME));
+ ret = dcm_request_extract_face_async(_media->face_request_id, repl_path, (FaceFunc)__media_info_face_completed_cb, (void *)_face_cb, _content_get_uid());
ret = _content_error_capi(MEDIA_THUMBNAIL_TYPE, ret);
} else {
media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
ret = __media_info_map_data_usr_to_svc(_media, &svc_content_info, _media->storage_type);
media_content_retvm_if(ret != MEDIA_CONTENT_ERROR_NONE, ret, "__media_info_map_data_usr_to_svc fail");
- ret = media_svc_insert_item_immediately_with_data(_content_get_db_handle(), svc_content_info, tzplatform_getuid(TZ_USER_NAME));
+ ret = media_svc_insert_item_immediately_with_data(_content_get_db_handle(), svc_content_info, _content_get_uid());
if (ret != MS_MEDIA_ERR_NONE) {
media_content_sec_error("media_svc_insert_item_immediately_with_data failed : %d (%s)", ret, _media->file_path);
media_svc_destroy_content_info(svc_content_info);
SAFE_FREE(folder_path);
media_content_retvm_if(ignore_dir == TRUE, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Invalid folder path");
- ret = media_svc_get_storage_id(_content_get_db_handle(), repl_path, storage_id, tzplatform_getuid(TZ_USER_NAME));
+ ret = media_svc_get_storage_id(_content_get_db_handle(), repl_path, storage_id, _content_get_uid());
if (ret != MS_MEDIA_ERR_NONE) {
media_content_error("media_svc_get_storage_id failed : %d", ret);
return _content_error_capi(MEDIA_CONTENT_TYPE, ret);
}
- ret = media_svc_get_storage_type(repl_path, &storage_type, tzplatform_getuid(TZ_USER_NAME));
+ ret = media_svc_get_storage_type(repl_path, &storage_type, _content_get_uid());
if (ret != MS_MEDIA_ERR_NONE) {
media_content_sec_error("media_svc_get_storage_type failed : %d", ret);
return _content_error_capi(MEDIA_CONTENT_TYPE, ret);
query_str = sqlite3_mprintf("INSERT INTO %q (playlist_id, media_uuid, play_order) values (%d, '%q', %d);",
DB_TABLE_PLAYLIST_MAP, playlist_id, media_id, play_order);
- ret = media_svc_append_query(query_str, tzplatform_getuid(TZ_USER_NAME));
+ ret = media_svc_append_query(query_str, _content_get_uid());
return _content_error_capi(MEDIA_CONTENT_TYPE, ret);
}
char *query_str = NULL;
query_str = sqlite3_mprintf(REMOVE_PLAYLIST_ITEM_FROM_PLAYLIST_MAP, playlist_id, playlist_member_id);
- ret = media_svc_append_query(query_str, tzplatform_getuid(TZ_USER_NAME));
+ ret = media_svc_append_query(query_str, _content_get_uid());
return _content_error_capi(MEDIA_CONTENT_TYPE, ret);
}
char *query_str = NULL;
query_str = sqlite3_mprintf(UPDATE_PLAYLIST_NAME_FROM_PLAYLIST, playlist_name, playlist_id);
- ret = media_svc_append_query(query_str, tzplatform_getuid(TZ_USER_NAME));
+ ret = media_svc_append_query(query_str, _content_get_uid());
return _content_error_capi(MEDIA_CONTENT_TYPE, ret);
}
char *query_str = NULL;
query_str = sqlite3_mprintf(UPDATE_PLAYLIST_THUMBNAIL_FROM_PLAYLIST, path, playlist_id);
- ret = media_svc_append_query(query_str, tzplatform_getuid(TZ_USER_NAME));
+ ret = media_svc_append_query(query_str, _content_get_uid());
return _content_error_capi(MEDIA_CONTENT_TYPE, ret);
}
char *query_str = NULL;
query_str = sqlite3_mprintf(UPDATE_PLAYLIST_ORDER_FROM_PLAYLIST_MAP, play_order, playlist_id, playlist_member_id);
- ret = media_svc_append_query(query_str, tzplatform_getuid(TZ_USER_NAME));
+ ret = media_svc_append_query(query_str, _content_get_uid());
return _content_error_capi(MEDIA_CONTENT_TYPE, ret);
}
}
}
}
- ret = media_svc_send_query(tzplatform_getuid(TZ_USER_NAME));
+ ret = media_svc_send_query(_content_get_uid());
__media_playlist_item_release(_playlist);
char *query_str = NULL;
query_str = sqlite3_mprintf("INSERT INTO %q (tag_id, media_uuid) values (%d, '%q');", DB_TABLE_TAG_MAP, tag_id, media_id);
- ret = media_svc_append_query(query_str, tzplatform_getuid(TZ_USER_NAME));
+ ret = media_svc_append_query(query_str, _content_get_uid());
return _content_error_capi(MEDIA_CONTENT_TYPE, ret);
}
char *query_str = NULL;
query_str = sqlite3_mprintf(REMOVE_TAG_ITEM_FROM_TAG_MAP, tag_id, media_id);
- ret = media_svc_append_query(query_str, tzplatform_getuid(TZ_USER_NAME));
+ ret = media_svc_append_query(query_str, _content_get_uid());
return _content_error_capi(MEDIA_CONTENT_TYPE, ret);
}
char *query_str = NULL;
query_str = sqlite3_mprintf(UPDATE_TAG_NAME_FROM_TAG, tag_name, tag_id);
- ret = media_svc_append_query(query_str, tzplatform_getuid(TZ_USER_NAME));
+ ret = media_svc_append_query(query_str, _content_get_uid());
return _content_error_capi(MEDIA_CONTENT_TYPE, ret);
}
}
}
- ret = media_svc_send_query(tzplatform_getuid(TZ_USER_NAME));
+ ret = media_svc_send_query(_content_get_uid());
__media_tag_item_release(_tag);
}
/*2. Check Scan Ignore Directory*/
- ret = media_svc_get_storage_type(dir_path, &storage_type, tzplatform_getuid(TZ_USER_NAME));
+ ret = media_svc_get_storage_type(dir_path, &storage_type, _content_get_uid());
if (ret != MS_MEDIA_ERR_NONE) {
media_content_error("media_svc_get_storage_type failed : %d", ret);
return _content_error_capi(MEDIA_CONTENT_TYPE, ret);