#include <media-util.h>
#include <time.h>
#include <stdbool.h>
+#include <sqlite3.h>
+
#ifdef __cplusplus
extern "C" {
#endif
-int media_svc_cleanup_db(MediaSvcHandle *handle, uid_t uid);
-int media_svc_get_user_version(MediaSvcHandle *handle, int *user_version);
+int media_svc_cleanup_db(sqlite3 *handle, uid_t uid);
+int media_svc_get_user_version(sqlite3 *handle, int *user_version);
int media_svc_create_table(uid_t uid);
-int media_svc_check_item_exist_by_path(MediaSvcHandle *handle, const char *storage_id, const char *path);
-int media_svc_insert_folder(MediaSvcHandle *handle, const char *storage_id, ms_user_storage_type_e storage_type, const char *path, uid_t uid);
+int media_svc_check_item_exist_by_path(sqlite3 *handle, const char *storage_id, const char *path);
+int media_svc_insert_folder(sqlite3 *handle, const char *storage_id, ms_user_storage_type_e storage_type, const char *path, uid_t uid);
int media_svc_insert_item_begin(int with_noti, int data_cnt, int from_pid);
int media_svc_insert_item_end(uid_t uid);
-int media_svc_insert_item_bulk(MediaSvcHandle *handle, const char *storage_id, ms_user_storage_type_e storage_type, const char *path, uid_t uid);
-int media_svc_insert_item_immediately(MediaSvcHandle *handle, const char *storage_id, ms_user_storage_type_e storage_type, const char *path, uid_t uid);
-int media_svc_move_item(MediaSvcHandle *handle, const char *src_path, const char *dest_path, uid_t uid);
+int media_svc_insert_item_bulk(sqlite3 *handle, const char *storage_id, ms_user_storage_type_e storage_type, const char *path, uid_t uid);
+int media_svc_insert_item_immediately(sqlite3 *handle, const char *storage_id, ms_user_storage_type_e storage_type, const char *path, uid_t uid);
+int media_svc_move_item(sqlite3 *handle, const char *src_path, const char *dest_path, uid_t uid);
int media_svc_set_item_validity_begin(int data_cnt);
int media_svc_set_item_validity_end(uid_t uid);
int media_svc_set_item_validity(const char *storage_id, const char *path, int validity, uid_t uid);
-int media_svc_delete_item_by_path(MediaSvcHandle *handle, const char *storage_id, const char *path, uid_t uid);
-int media_svc_delete_invalid_items_in_storage(MediaSvcHandle *handle, const char *storage_id, ms_user_storage_type_e storage_type, uid_t uid);
+int media_svc_delete_item_by_path(sqlite3 *handle, const char *storage_id, const char *path, uid_t uid);
+int media_svc_delete_invalid_items_in_storage(sqlite3 *handle, const char *storage_id, ms_user_storage_type_e storage_type, uid_t uid);
int media_svc_set_all_storage_items_validity(const char *storage_id, ms_user_storage_type_e storage_type, int validity, uid_t uid);
-int media_svc_set_folder_items_validity(MediaSvcHandle *handle, const char *storage_id, const char *folder_path, int validity, int recursive, uid_t uid);
-int media_svc_refresh_item(MediaSvcHandle *handle, const char *storage_id, ms_user_storage_type_e storage_type, const char *path, uid_t uid);
+int media_svc_set_folder_items_validity(sqlite3 *handle, const char *storage_id, const char *folder_path, int validity, int recursive, uid_t uid);
+int media_svc_refresh_item(sqlite3 *handle, const char *storage_id, ms_user_storage_type_e storage_type, const char *path, uid_t uid);
int media_svc_request_update_db(const char *db_query, uid_t uid);
-int media_svc_get_file_info(MediaSvcHandle *handle, const char *storage_id, const char *path, time_t *modified_time, unsigned long long *size);
-int media_svc_send_dir_update_noti(MediaSvcHandle *handle, const char *storage_id, const char *dir_path, const char *folder_id, media_item_update_type_e update_type, int pid);
-int media_svc_check_db_upgrade(MediaSvcHandle *handle, int user_version, uid_t uid);
+int media_svc_get_file_info(sqlite3 *handle, const char *storage_id, const char *path, time_t *modified_time, unsigned long long *size);
+int media_svc_send_dir_update_noti(sqlite3 *handle, const char *storage_id, const char *dir_path, const char *folder_id, media_item_update_type_e update_type, int pid);
+int media_svc_check_db_upgrade(sqlite3 *handle, int user_version, uid_t uid);
int media_svc_publish_noti(media_item_type_e update_item, media_item_update_type_e update_type, const char *path, media_type_e media_type, const char *uuid, const char *mime_type);
int media_svc_get_pinyin(const char *src_str, char **pinyin_str);
int media_svc_check_pinyin_support(bool *support);
int media_svc_update_item_meta(const char *file_path, const char *storage_id, int storage_type, uid_t uid);
int media_svc_generate_uuid(char **uuid);
-int media_svc_check_storage(MediaSvcHandle *handle, const char *storage_id, char **storage_path, int *validity, uid_t uid);
-int media_svc_insert_storage(MediaSvcHandle *handle, const char *storage_id, const char *storage_path, ms_user_storage_type_e storage_type, uid_t uid);
-int media_svc_update_storage(MediaSvcHandle *handle, const char *storage_id, const char *storage_path, uid_t uid);
-int media_svc_set_storage_validity(MediaSvcHandle *handle, const char *storage_id, int validity, uid_t uid);
-int media_svc_get_storage_id(MediaSvcHandle *handle, const char *path, char *storage_id, uid_t uid);
-int media_svc_get_storage_list(MediaSvcHandle *handle, char ***storage_list, char ***storage_id_list, int *count);
+int media_svc_check_storage(sqlite3 *handle, const char *storage_id, char **storage_path, int *validity, uid_t uid);
+int media_svc_insert_storage(sqlite3 *handle, const char *storage_id, const char *storage_path, ms_user_storage_type_e storage_type, uid_t uid);
+int media_svc_update_storage(sqlite3 *handle, const char *storage_id, const char *storage_path, uid_t uid);
+int media_svc_set_storage_validity(sqlite3 *handle, const char *storage_id, int validity, uid_t uid);
+int media_svc_get_storage_id(sqlite3 *handle, const char *path, char *storage_id, uid_t uid);
+int media_svc_get_storage_list(sqlite3 *handle, char ***storage_list, char ***storage_id_list, int *count);
int media_svc_delete_invalid_folder(const char *storage_id, int storage_type, uid_t uid);
-int media_svc_set_folder_validity(MediaSvcHandle *handle, const char *storage_id, const char *start_path, int validity, bool is_recursive, uid_t uid);
+int media_svc_set_folder_validity(sqlite3 *handle, const char *storage_id, const char *start_path, int validity, bool is_recursive, uid_t uid);
int media_svc_insert_folder_begin(int data_cnt);
int media_svc_insert_folder_end(uid_t uid);
-int media_svc_check_folder_exist_by_path(MediaSvcHandle *handle, const char *storage_id, const char *folder_path);
-int media_svc_get_folder_id(MediaSvcHandle *handle, const char *storage_id, const char *path, char *folder_id);
+int media_svc_check_folder_exist_by_path(sqlite3 *handle, const char *storage_id, const char *folder_path);
+int media_svc_get_folder_id(sqlite3 *handle, const char *storage_id, const char *path, char *folder_id);
int media_svc_append_query(const char *query, uid_t uid);
int media_svc_send_query(uid_t uid);
#include "media-svc.h"
#include "media-svc-util.h"
-int cleanup_db(void *handle, uid_t uid)
+int cleanup_db(sqlite3 *handle, uid_t uid)
{
return media_svc_cleanup_db(handle, uid);
}
-int check_item_exist(void *handle, const char *storage_id, const char *file_path, bool *modified)
+int check_item_exist(sqlite3 *handle, const char *storage_id, const char *file_path, bool *modified)
{
int ret = MS_MEDIA_ERR_NONE;
*modified = TRUE;
return media_svc_insert_item_end(uid);
}
-int insert_item(void *handle, const char *storage_id, const char *file_path, int storage_type, uid_t uid)
+int insert_item(sqlite3 *handle, const char *storage_id, const char *file_path, int storage_type, uid_t uid)
{
return media_svc_insert_item_bulk(handle, storage_id, storage_type, file_path, uid);
}
return media_svc_set_all_storage_items_validity(storage_id, storage_type, validity, uid);
}
-int set_folder_item_validity(void *handle, const char *storage_id, const char *folder_path, int validity, int recursive, uid_t uid)
+int set_folder_item_validity(sqlite3 *handle, const char *storage_id, const char *folder_path, int validity, int recursive, uid_t uid)
{
return media_svc_set_folder_items_validity(handle, storage_id, folder_path, validity, recursive, uid);
}
return media_svc_set_item_validity(storage_id, file_path, validity, uid);
}
-int delete_item(void *handle, const char *storage_id, const char *file_path, uid_t uid)
+int delete_item(sqlite3 *handle, const char *storage_id, const char *file_path, uid_t uid)
{
return media_svc_delete_item_by_path(handle, storage_id, file_path, uid);
}
-int delete_all_invalid_items_in_storage(void *handle, const char *storage_id, int storage_type, uid_t uid)
+int delete_all_invalid_items_in_storage(sqlite3 *handle, const char *storage_id, int storage_type, uid_t uid)
{
return media_svc_delete_invalid_items_in_storage(handle, storage_id, storage_type, uid);
}
-int send_dir_update_noti(void *handle, const char *storage_id, const char *dir_path, const char *folder_id, int update_type, int pid)
+int send_dir_update_noti(sqlite3 *handle, const char *storage_id, const char *dir_path, const char *folder_id, int update_type, int pid)
{
return media_svc_send_dir_update_noti(handle, storage_id, dir_path, folder_id, (media_item_update_type_e)update_type, pid);
}
-int check_db(void *handle, uid_t uid)
+int check_db(sqlite3 *handle, uid_t uid)
{
int ret = MS_MEDIA_ERR_NONE;
int user_version = -1;
return ret;
}
-int update_folder_time(void *handle, const char *storage_id, char *folder_path, uid_t uid)
+int update_folder_time(sqlite3 *handle, const char *storage_id, char *folder_path, uid_t uid)
{
/* For scanner V2 */
return MS_MEDIA_ERR_NONE;
return media_svc_generate_uuid(uuid);
}
-int check_storage(void * handle, const char *storage_id, char **storage_path, int *validity, uid_t uid)
+int check_storage(sqlite3 *handle, const char *storage_id, char **storage_path, int *validity, uid_t uid)
{
return media_svc_check_storage(handle, storage_id, storage_path, validity, uid);
}
-int insert_storage(void *handle, const char *storage_id, int storage_type, const char *storage_path, uid_t uid)
+int insert_storage(sqlite3 *handle, const char *storage_id, int storage_type, const char *storage_path, uid_t uid)
{
return media_svc_insert_storage(handle, storage_id, storage_path, storage_type, uid);
}
-int update_storage(void *handle, const char *storage_id, const char *storage_path, uid_t uid)
+int update_storage(sqlite3 *handle, const char *storage_id, const char *storage_path, uid_t uid)
{
return media_svc_update_storage(handle, storage_id, storage_path, uid);
}
-int set_storage_validity(void * handle, const char *storage_id, int validity, uid_t uid)
+int set_storage_validity(sqlite3 *handle, const char *storage_id, int validity, uid_t uid)
{
return media_svc_set_storage_validity(handle, storage_id, validity, uid);
}
-int set_all_storage_validity(void * handle, int validity, uid_t uid)
+int set_all_storage_validity(sqlite3 *handle, int validity, uid_t uid)
{
return media_svc_set_storage_validity(handle, NULL, validity, uid);
}
-int get_storage_id(void * handle, const char *path, char *storage_id, uid_t uid)
+int get_storage_id(sqlite3 *handle, const char *path, char *storage_id, uid_t uid)
{
return media_svc_get_storage_id(handle, path, storage_id, uid);
}
-int set_storage_scan_status(void *handle, const char *storage_id, int status, uid_t uid)
+int set_storage_scan_status(sqlite3 *handle, const char *storage_id, int status, uid_t uid)
{
/* For scanner V2 */
return MS_MEDIA_ERR_NONE;
}
-int get_storage_list(void *handle, char ***storage_list, char ***storage_id_list, int *count)
+int get_storage_list(sqlite3 *handle, char ***storage_list, char ***storage_id_list, int *count)
{
return media_svc_get_storage_list(handle, storage_list, storage_id_list, count);
}
return media_svc_update_item_meta(file_path, storage_id, storage_type, uid);
}
-int insert_item_scan(void *handle, const char *storage_id, const char *file_path, int storage_type, uid_t uid)
+int insert_item_scan(sqlite3 *handle, const char *storage_id, const char *file_path, int storage_type, uid_t uid)
{
/* For scanner V2 */
return MS_MEDIA_ERR_NONE;
}
-int get_extract_list(void* handle, const char* storage_id, int storage_type, int scan_type, const char* path, uid_t uid, void* array)
+int get_extract_list(sqlite3* handle, const char* storage_id, int storage_type, int scan_type, const char* path, uid_t uid, void* array)
{
/* For scanner V2 */
return MS_MEDIA_ERR_NONE;
}
-int update_one_extract_item(void* handle, const char* storage_id, int storage_type, void* data)
+int update_one_extract_item(sqlite3* handle, const char* storage_id, int storage_type, void* data)
{
/* For scanner V2 */
return MS_MEDIA_ERR_NONE;
}
-int query_do_update_list(void* handle)
+int query_do_update_list(sqlite3* handle)
{
/* For scanner V2 */
return MS_MEDIA_ERR_NONE;
}
-int delete_all_invalid_items_in_folder(void **handle, const char* storage_id, const char*path, bool is_recursive, uid_t uid)
+int delete_all_invalid_items_in_folder(sqlite3 *handle, const char* storage_id, const char*path, bool is_recursive, uid_t uid)
{
/* For scanner V2 */
return MS_MEDIA_ERR_NONE;
}
-int delete_invalid_folder_by_path(void **handle, const char *storage_id, const char *folder_path, uid_t uid)
+int delete_invalid_folder_by_path(sqlite3 *handle, const char *storage_id, const char *folder_path, uid_t uid)
{
/* For scanner V2 */
return MS_MEDIA_ERR_NONE;
return media_svc_insert_folder_end(uid);
}
-int insert_folder(void *handle, const char *storage_id, const char *file_path, int storage_type, uid_t uid)
+int insert_folder(sqlite3 *handle, const char *storage_id, const char *file_path, int storage_type, uid_t uid)
{
return media_svc_insert_folder(handle, storage_id, storage_type, file_path, uid);
}
return media_svc_delete_invalid_folder(storage_id, storage_type, uid);
}
-int set_folder_validity(void *handle, const char *storage_id, const char* start_path, int validity, bool is_recursive, uid_t uid)
+int set_folder_validity(sqlite3 *handle, const char *storage_id, const char* start_path, int validity, bool is_recursive, uid_t uid)
{
return media_svc_set_folder_validity(handle, storage_id, start_path, validity, is_recursive, uid);
}
-int get_folder_scan_status(void *handle, const char *storage_id, const char *path, int *status)
+int get_folder_scan_status(sqlite3 *handle, const char *storage_id, const char *path, int *status)
{
/* For scanner V2 */
return MS_MEDIA_ERR_NONE;
}
-int set_folder_scan_status(void *handle, const char *storage_id, const char *path, int status, uid_t uid)
+int set_folder_scan_status(sqlite3 *handle, const char *storage_id, const char *path, int status, uid_t uid)
{
/* For scanner V2 */
return MS_MEDIA_ERR_NONE;
}
-int check_folder_modified(void *handle, const char *path, const char *storage_id, bool *modified)
+int check_folder_modified(sqlite3 *handle, const char *path, const char *storage_id, bool *modified)
{
/* For scanner V2 */
return MS_MEDIA_ERR_NONE;
}
-int get_null_scan_folder_list(void *handle, const char *storage_id, const char *folder_path, char ***folder_list, int *count)
+int get_null_scan_folder_list(sqlite3 *handle, const char *storage_id, const char *folder_path, char ***folder_list, int *count)
{
/* For scanner V2 */
return MS_MEDIA_ERR_NONE;
}
-int change_validity_item_batch(void **handle, const char *storage_id, const char *path, int des_validity, int src_validity, uid_t uid)
+int change_validity_item_batch(sqlite3 *handle, const char *storage_id, const char *path, int des_validity, int src_validity, uid_t uid)
{
/* For scanner V2 */
return MS_MEDIA_ERR_NONE;
}
-int check_folder_exist(void *handle, const char *storage_id, const char *folder_path)
+int check_folder_exist(sqlite3 *handle, const char *storage_id, const char *folder_path)
{
return media_svc_check_folder_exist_by_path(handle, storage_id, folder_path);
}
-int get_folder_id(void *handle, const char *storage_id, const char *path, char *folder_id)
+int get_folder_id(sqlite3 *handle, const char *storage_id, const char *path, char *folder_id)
{
return media_svc_get_folder_id(handle, storage_id, path, folder_id);
}
return TRUE;
}
-int media_svc_cleanup_db(MediaSvcHandle *handle, uid_t uid)
+int media_svc_cleanup_db(sqlite3 *handle, uid_t uid)
{
- MediaDBHandle *db_handle = (MediaDBHandle *)handle;
-
media_svc_debug_fenter();
- return _media_svc_do_cleanup(db_handle, uid);
+ return _media_svc_do_cleanup(handle, uid);
}
-int media_svc_get_user_version(MediaSvcHandle *handle, int *user_version)
+int media_svc_get_user_version(sqlite3 *handle, int *user_version)
{
- sqlite3 *db_handle = (sqlite3 *)handle;
-
- return _media_svc_get_user_version(db_handle, user_version);
+ return _media_svc_get_user_version(handle, user_version);
}
int media_svc_create_table(uid_t uid)
return ret;
}
-int media_svc_get_file_info(MediaSvcHandle *handle, const char *storage_id, const char *path, time_t *modified_time, unsigned long long *size)
+int media_svc_get_file_info(sqlite3 *handle, const char *storage_id, const char *path, time_t *modified_time, unsigned long long *size)
{
- sqlite3 *db_handle = (sqlite3 *)handle;
-
- return _media_svc_get_fileinfo_by_path(db_handle, storage_id, path, modified_time, size);
+ return _media_svc_get_fileinfo_by_path(handle, storage_id, path, modified_time, size);
}
-int media_svc_check_item_exist_by_path(MediaSvcHandle *handle, const char *storage_id, const char *path)
+int media_svc_check_item_exist_by_path(sqlite3 *handle, const char *storage_id, const char *path)
{
int ret = MS_MEDIA_ERR_NONE;
- sqlite3 *db_handle = (sqlite3 *)handle;
int count = -1;
- ret = _media_svc_count_record_with_path(db_handle, storage_id, path, &count);
+ ret = _media_svc_count_record_with_path(handle, storage_id, path, &count);
media_svc_retv_if(ret != MS_MEDIA_ERR_NONE, ret);
if (count > 0) {
return ret;
}
-int media_svc_insert_item_bulk(MediaSvcHandle *handle, const char *storage_id, ms_user_storage_type_e storage_type, const char *path, uid_t uid)
+int media_svc_insert_item_bulk(sqlite3 *handle, const char *storage_id, ms_user_storage_type_e storage_type, const char *path, uid_t uid)
{
int ret = MS_MEDIA_ERR_NONE;
- sqlite3 *db_handle = (sqlite3 *)handle;
char folder_uuid[MEDIA_SVC_UUID_SIZE + 1] = {0, };
media_svc_media_type_e media_type;
- media_svc_retvm_if(db_handle == NULL, MS_MEDIA_ERR_INVALID_PARAMETER, "Handle is NULL");
+ media_svc_retvm_if(handle == NULL, MS_MEDIA_ERR_INVALID_PARAMETER, "Handle is NULL");
media_svc_retvm_if(!STRING_VALID(storage_id), MS_MEDIA_ERR_INVALID_PARAMETER, "storage_id is NULL");
media_svc_retvm_if(!STRING_VALID(path), MS_MEDIA_ERR_INVALID_PARAMETER, "path is NULL");
media_svc_retvm_if(__media_svc_check_storage(storage_type) != TRUE, MS_MEDIA_ERR_INVALID_PARAMETER, "Invalid storage_type");
else if (media_type == MEDIA_SVC_MEDIA_TYPE_IMAGE)
ret = _media_svc_extract_image_metadata(&content_info);
else
- ret = _media_svc_extract_media_metadata(db_handle, &content_info, uid);
+ ret = _media_svc_extract_media_metadata(handle, &content_info, uid);
media_svc_retv_del_if(ret != MS_MEDIA_ERR_NONE, ret, &content_info);
/*Set or Get folder id*/
- ret = _media_svc_get_and_append_folder_id_by_path(db_handle, storage_id, path, storage_type, folder_uuid, uid);
+ ret = _media_svc_get_and_append_folder_id_by_path(handle, storage_id, path, storage_type, folder_uuid, uid);
media_svc_retv_del_if(ret != MS_MEDIA_ERR_NONE, ret, &content_info);
content_info.folder_uuid = g_strdup(folder_uuid);
if (g_media_svc_insert_item_data_cnt == 1) {
- ret = _media_svc_insert_item_with_data(db_handle, storage_id, &content_info, FALSE, uid);
+ ret = _media_svc_insert_item_with_data(handle, storage_id, &content_info, FALSE, uid);
media_svc_retv_del_if(ret != MS_MEDIA_ERR_NONE, ret, &content_info);
if (g_insert_with_noti)
} else if (g_media_svc_insert_item_cur_data_cnt < (g_media_svc_insert_item_data_cnt - 1)) {
- ret = _media_svc_insert_item_with_data(db_handle, storage_id, &content_info, TRUE, uid);
+ ret = _media_svc_insert_item_with_data(handle, storage_id, &content_info, TRUE, uid);
media_svc_retv_del_if(ret != MS_MEDIA_ERR_NONE, ret, &content_info);
if (g_insert_with_noti)
} else if (g_media_svc_insert_item_cur_data_cnt == (g_media_svc_insert_item_data_cnt - 1)) {
- ret = _media_svc_insert_item_with_data(db_handle, storage_id, &content_info, TRUE, uid);
+ ret = _media_svc_insert_item_with_data(handle, storage_id, &content_info, TRUE, uid);
media_svc_retv_del_if(ret != MS_MEDIA_ERR_NONE, ret, &content_info);
if (g_insert_with_noti)
return MS_MEDIA_ERR_NONE;
}
-int media_svc_insert_item_immediately(MediaSvcHandle *handle, const char *storage_id, ms_user_storage_type_e storage_type, const char *path, uid_t uid)
+int media_svc_insert_item_immediately(sqlite3 *handle, const char *storage_id, ms_user_storage_type_e storage_type, const char *path, uid_t uid)
{
int ret = MS_MEDIA_ERR_NONE;
- sqlite3 *db_handle = (sqlite3 *)handle;
char folder_uuid[MEDIA_SVC_UUID_SIZE + 1] = {0, };
media_svc_media_type_e media_type;
- media_svc_retvm_if(db_handle == NULL, MS_MEDIA_ERR_INVALID_PARAMETER, "Handle is NULL");
+ media_svc_retvm_if(handle == NULL, MS_MEDIA_ERR_INVALID_PARAMETER, "Handle is NULL");
media_svc_retvm_if(!STRING_VALID(storage_id), MS_MEDIA_ERR_INVALID_PARAMETER, "storage_id is NULL");
media_svc_retvm_if(!STRING_VALID(path), MS_MEDIA_ERR_INVALID_PARAMETER, "path is NULL");
media_svc_retvm_if(__media_svc_check_storage(storage_type) != TRUE, MS_MEDIA_ERR_INVALID_PARAMETER, "Invalid storage_type");
} else if (media_type == MEDIA_SVC_MEDIA_TYPE_IMAGE) {
ret = _media_svc_extract_image_metadata(&content_info);
} else {
- ret = _media_svc_extract_media_metadata(db_handle, &content_info, uid);
+ ret = _media_svc_extract_media_metadata(handle, &content_info, uid);
}
media_svc_retv_del_if(ret != MS_MEDIA_ERR_NONE, ret, &content_info);
/*Set or Get folder id*/
- ret = _media_svc_get_and_append_folder_id_by_path(db_handle, storage_id, path, storage_type, folder_uuid, uid);
+ ret = _media_svc_get_and_append_folder_id_by_path(handle, storage_id, path, storage_type, folder_uuid, uid);
media_svc_retv_del_if(ret != MS_MEDIA_ERR_NONE, ret, &content_info);
content_info.folder_uuid = g_strdup(folder_uuid);
}
}
- ret = _media_svc_insert_item_with_data(db_handle, storage_id, &content_info, FALSE, uid);
+ ret = _media_svc_insert_item_with_data(handle, storage_id, &content_info, FALSE, uid);
if (ret == MS_MEDIA_ERR_NONE) {
media_svc_debug("Insertion is successful. Sending noti for this");
return ret;
}
-int media_svc_move_item(MediaSvcHandle *handle, const char *src_path, const char *dest_path, uid_t uid)
+int media_svc_move_item(sqlite3 *handle, const char *src_path, const char *dest_path, uid_t uid)
{
int ret = MS_MEDIA_ERR_NONE;
- sqlite3 *db_handle = (sqlite3 *)handle;
char *file_name = NULL;
char *folder_path = NULL;
int modified_time = 0;
media_svc_debug_fenter();
- media_svc_retvm_if(db_handle == NULL, MS_MEDIA_ERR_INVALID_PARAMETER, "Handle is NULL");
+ media_svc_retvm_if(handle == NULL, MS_MEDIA_ERR_INVALID_PARAMETER, "Handle is NULL");
media_svc_retvm_if(!STRING_VALID(src_path), MS_MEDIA_ERR_INVALID_PARAMETER, "src_path is NULL");
media_svc_retvm_if(!STRING_VALID(dest_path), MS_MEDIA_ERR_INVALID_PARAMETER, "dest_path is NULL");
/* Get storage_id */
- ret = _media_svc_get_storage_uuid(db_handle, src_path, org_stg_id, uid);
+ ret = _media_svc_get_storage_uuid(handle, src_path, org_stg_id, uid);
media_svc_retv_if(ret != MS_MEDIA_ERR_NONE, ret);
- ret = _media_svc_get_storage_uuid(db_handle, dest_path, dst_stg_id, uid);
+ ret = _media_svc_get_storage_uuid(handle, dest_path, dst_stg_id, uid);
media_svc_retv_if(ret != MS_MEDIA_ERR_NONE, ret);
/* Get storage_type */
ret = ms_user_get_storage_type(uid, src_path, &org_stg_type);
media_svc_retv_if(ret != MS_MEDIA_ERR_NONE, ret);
/*check and update folder*/
- ret = _media_svc_get_and_append_folder_id_by_path(db_handle, dst_stg_id, dest_path, dst_stg_type, folder_uuid, uid);
+ ret = _media_svc_get_and_append_folder_id_by_path(handle, dst_stg_id, dest_path, dst_stg_type, folder_uuid, uid);
media_svc_retv_if(ret != MS_MEDIA_ERR_NONE, ret);
/*get filename*/
/*get modified_time*/
modified_time = _media_svc_get_file_time(dest_path);
- ret = _media_svc_get_media_type_by_path(db_handle, org_stg_id, src_path, &media_type);
+ ret = _media_svc_get_media_type_by_path(handle, org_stg_id, src_path, &media_type);
if (ret != MS_MEDIA_ERR_NONE) {
media_svc_error("_media_svc_get_media_type_by_path failed");
SAFE_FREE(file_name);
}
/*get old thumbnail_path and remove thumbnail */
- ret = _media_svc_get_thumbnail_path_by_path(db_handle, src_path, old_thumb_path);
+ ret = _media_svc_get_thumbnail_path_by_path(handle, src_path, old_thumb_path);
if ((ret != MS_MEDIA_ERR_NONE) && (ret != MS_MEDIA_ERR_DB_NO_RECORD)) {
media_svc_error("_media_svc_get_thumbnail_path_by_path failed");
SAFE_FREE(file_name);
/* Get notification info */
media_svc_noti_item *noti_item = NULL;
- ret = _media_svc_get_noti_info(db_handle, dst_stg_id, dest_path, MS_MEDIA_ITEM_FILE, ¬i_item);
+ ret = _media_svc_get_noti_info(handle, dst_stg_id, dest_path, MS_MEDIA_ITEM_FILE, ¬i_item);
media_svc_retv_if(ret != MS_MEDIA_ERR_NONE, ret);
/* Send notification for move */
return MS_MEDIA_ERR_NONE;
}
-int media_svc_delete_item_by_path(MediaSvcHandle *handle, const char *storage_id, const char *path, uid_t uid)
+int media_svc_delete_item_by_path(sqlite3 *handle, const char *storage_id, const char *path, uid_t uid)
{
int ret = MS_MEDIA_ERR_NONE;
- sqlite3 *db_handle = (sqlite3 *)handle;
char thumb_path[MEDIA_SVC_PATHNAME_SIZE] = {0, };
media_svc_debug_fenter();
int media_type = -1;
- ret = _media_svc_get_media_type_by_path(db_handle, storage_id, path, &media_type);
+ ret = _media_svc_get_media_type_by_path(handle, storage_id, path, &media_type);
media_svc_retv_if((ret != MS_MEDIA_ERR_NONE), ret);
/*Get thumbnail path to delete*/
- ret = _media_svc_get_thumbnail_path_by_path(db_handle, path, thumb_path);
+ ret = _media_svc_get_thumbnail_path_by_path(handle, path, thumb_path);
media_svc_retv_if((ret != MS_MEDIA_ERR_NONE) && (ret != MS_MEDIA_ERR_DB_NO_RECORD), ret);
if (g_media_svc_insert_item_data_cnt == 1) {
/* Get notification info */
media_svc_noti_item *noti_item = NULL;
- ret = _media_svc_get_noti_info(db_handle, storage_id, path, MS_MEDIA_ITEM_FILE, ¬i_item);
+ ret = _media_svc_get_noti_info(handle, storage_id, path, MS_MEDIA_ITEM_FILE, ¬i_item);
media_svc_retv_if(ret != MS_MEDIA_ERR_NONE, ret);
/*Delete item*/
return MS_MEDIA_ERR_NONE;
}
-int media_svc_delete_invalid_items_in_storage(MediaSvcHandle *handle, const char *storage_id, ms_user_storage_type_e storage_type, uid_t uid)
+int media_svc_delete_invalid_items_in_storage(sqlite3 *handle, const char *storage_id, ms_user_storage_type_e storage_type, uid_t uid)
{
- sqlite3 *db_handle = (sqlite3 *)handle;
-
media_svc_debug_fenter();
+ media_svc_retvm_if(handle == NULL, MS_MEDIA_ERR_INVALID_PARAMETER, "Handle is NULL");
media_svc_retvm_if(!STRING_VALID(storage_id), MS_MEDIA_ERR_INVALID_PARAMETER, "storage_id is NULL");
media_svc_retvm_if(__media_svc_check_storage(storage_type) != TRUE, MS_MEDIA_ERR_INVALID_PARAMETER, "Invalid storage_type");
/*Delete from DB and remove thumbnail files*/
- return _media_svc_delete_invalid_items(db_handle, storage_id, storage_type, uid);
+ return _media_svc_delete_invalid_items(handle, storage_id, storage_type, uid);
}
int media_svc_set_all_storage_items_validity(const char *storage_id, ms_user_storage_type_e storage_type, int validity, uid_t uid)
return _media_svc_update_storage_item_validity(storage_id, storage_type, validity, uid);
}
-int media_svc_set_folder_items_validity(MediaSvcHandle *handle, const char *storage_id, const char *folder_path, int validity, int recursive, uid_t uid)
+int media_svc_set_folder_items_validity(sqlite3 *handle, const char *storage_id, const char *folder_path, int validity, int recursive, uid_t uid)
{
- sqlite3 *db_handle = (sqlite3 *)handle;
-
+ media_svc_retvm_if(handle == NULL, MS_MEDIA_ERR_INVALID_PARAMETER, "Handle is NULL");
media_svc_retvm_if(!STRING_VALID(storage_id), MS_MEDIA_ERR_INVALID_PARAMETER, "storage_id is NULL");
media_svc_retvm_if(!STRING_VALID(folder_path), MS_MEDIA_ERR_INVALID_PARAMETER, "folder_path is NULL");
if (recursive)
return _media_svc_update_recursive_folder_item_validity(storage_id, folder_path, validity, uid);
else
- return _media_svc_update_folder_item_validity(db_handle, storage_id, folder_path, validity, uid);
+ return _media_svc_update_folder_item_validity(handle, storage_id, folder_path, validity, uid);
}
-int media_svc_refresh_item(MediaSvcHandle *handle, const char *storage_id, ms_user_storage_type_e storage_type, const char *path, uid_t uid)
+int media_svc_refresh_item(sqlite3 *handle, const char *storage_id, ms_user_storage_type_e storage_type, const char *path, uid_t uid)
{
int ret = MS_MEDIA_ERR_NONE;
- sqlite3 *db_handle = (sqlite3 *)handle;
media_svc_media_type_e media_type;
char thumb_path[MEDIA_SVC_PATHNAME_SIZE + 1] = {0, };
- media_svc_retvm_if(db_handle == NULL, MS_MEDIA_ERR_INVALID_PARAMETER, "Handle is NULL");
+ media_svc_retvm_if(handle == NULL, MS_MEDIA_ERR_INVALID_PARAMETER, "Handle is NULL");
media_svc_retvm_if(!STRING_VALID(storage_id), MS_MEDIA_ERR_INVALID_PARAMETER, "storage_id is NULL");
media_svc_retvm_if(!STRING_VALID(path), MS_MEDIA_ERR_INVALID_PARAMETER, "path is NULL");
media_svc_retvm_if(__media_svc_check_storage(storage_type) != TRUE, MS_MEDIA_ERR_INVALID_PARAMETER, "Invalid storage_type");
return ret;
/* Initialize thumbnail information to remake thumbnail. */
- ret = _media_svc_get_thumbnail_path_by_path(db_handle, path, thumb_path);
+ ret = _media_svc_get_thumbnail_path_by_path(handle, path, thumb_path);
if (ret != MS_MEDIA_ERR_NONE && ret != MS_MEDIA_ERR_DB_NO_RECORD) {
_media_svc_destroy_content_info(&content_info);
return ret;
/* Get notification info */
media_svc_noti_item *noti_item = NULL;
- ret = _media_svc_get_noti_info(db_handle, storage_id, path, MS_MEDIA_ITEM_FILE, ¬i_item);
+ ret = _media_svc_get_noti_info(handle, storage_id, path, MS_MEDIA_ITEM_FILE, ¬i_item);
if (ret != MS_MEDIA_ERR_NONE) {
_media_svc_destroy_content_info(&content_info);
return ret;
else if (media_type == MEDIA_SVC_MEDIA_TYPE_IMAGE)
ret = _media_svc_extract_image_metadata(&content_info);
else
- ret = _media_svc_extract_media_metadata(db_handle, &content_info, uid);
+ ret = _media_svc_extract_media_metadata(handle, &content_info, uid);
if (ret != MS_MEDIA_ERR_NONE) {
_media_svc_destroy_noti_item(noti_item);
return _media_svc_sql_query(db_query, uid);
}
-int media_svc_send_dir_update_noti(MediaSvcHandle *handle, const char *storage_id, const char *dir_path, const char *folder_id, media_item_update_type_e update_type, int pid)
+int media_svc_send_dir_update_noti(sqlite3 *handle, const char *storage_id, const char *dir_path, const char *folder_id, media_item_update_type_e update_type, int pid)
{
int ret = MS_MEDIA_ERR_NONE;
- sqlite3 *db_handle = (sqlite3 *)handle;
char *uuid = NULL;
- media_svc_retvm_if(db_handle == NULL, MS_MEDIA_ERR_INVALID_PARAMETER, "Handle is NULL");
+ media_svc_retvm_if(handle == NULL, MS_MEDIA_ERR_INVALID_PARAMETER, "Handle is NULL");
media_svc_retvm_if(!STRING_VALID(dir_path), MS_MEDIA_ERR_INVALID_PARAMETER, "dir_path is NULL");
/* Get notification info */
media_svc_noti_item *noti_item = NULL;
- ret = _media_svc_get_noti_info(db_handle, storage_id, dir_path, MS_MEDIA_ITEM_DIRECTORY, ¬i_item);
+ ret = _media_svc_get_noti_info(handle, storage_id, dir_path, MS_MEDIA_ITEM_DIRECTORY, ¬i_item);
media_svc_retv_if(ret != MS_MEDIA_ERR_NONE, ret);
if (folder_id != NULL) {
return ret;
}
-int media_svc_check_db_upgrade(MediaSvcHandle *handle, int user_version, uid_t uid)
+int media_svc_check_db_upgrade(sqlite3 *handle, int user_version, uid_t uid)
{
- sqlite3 *db_handle = (sqlite3 *)handle;
-
media_svc_debug_fenter();
- media_svc_retvm_if(db_handle == NULL, MS_MEDIA_ERR_INVALID_PARAMETER, "Handle is NULL");
+ media_svc_retvm_if(handle == NULL, MS_MEDIA_ERR_INVALID_PARAMETER, "Handle is NULL");
- return _media_svc_check_db_upgrade(db_handle, user_version, uid);
+ return _media_svc_check_db_upgrade(handle, user_version, uid);
}
int media_svc_update_item_begin(int data_cnt)
return MS_MEDIA_ERR_NONE;
}
-int media_svc_set_storage_validity(MediaSvcHandle *handle, const char *storage_id, int validity, uid_t uid)
+int media_svc_set_storage_validity(sqlite3 *handle, const char *storage_id, int validity, uid_t uid)
{
int ret = MS_MEDIA_ERR_NONE;
- sqlite3 * db_handle = (sqlite3 *)handle;
- media_svc_retvm_if(db_handle == NULL, MS_MEDIA_ERR_INVALID_PARAMETER, "Handle is NULL");
+ media_svc_retvm_if(handle == NULL, MS_MEDIA_ERR_INVALID_PARAMETER, "Handle is NULL");
ret = _media_svc_update_storage_validity(storage_id, validity, uid);
media_svc_retvm_if(ret != MS_MEDIA_ERR_NONE, ret, "update storage validity failed: %d", ret);
- ret = _media_svc_update_media_view(db_handle, uid);
+ ret = _media_svc_update_media_view(handle, uid);
media_svc_retvm_if(ret != MS_MEDIA_ERR_NONE, ret, "update media view failed : %d", ret);
return ret;
}
-int media_svc_get_storage_id(MediaSvcHandle *handle, const char *path, char *storage_id, uid_t uid)
+int media_svc_get_storage_id(sqlite3 *handle, const char *path, char *storage_id, uid_t uid)
{
int ret = MS_MEDIA_ERR_NONE;
- sqlite3 * db_handle = (sqlite3 *)handle;
- media_svc_retvm_if(db_handle == NULL, MS_MEDIA_ERR_INVALID_PARAMETER, "Handle is NULL");
+ media_svc_retvm_if(handle == NULL, MS_MEDIA_ERR_INVALID_PARAMETER, "Handle is NULL");
media_svc_retvm_if(path == NULL, MS_MEDIA_ERR_INVALID_PARAMETER, "path is NULL");
- ret = _media_svc_get_storage_uuid(db_handle, path, storage_id, uid);
+ ret = _media_svc_get_storage_uuid(handle, path, storage_id, uid);
return ret;
}
-int media_svc_get_storage_list(MediaSvcHandle *handle, char ***storage_list, char ***storage_id_list, int *count)
+int media_svc_get_storage_list(sqlite3 *handle, char ***storage_list, char ***storage_id_list, int *count)
{
- sqlite3 * db_handle = (sqlite3 *)handle;
-
media_svc_debug_fenter();
- media_svc_retvm_if(db_handle == NULL, MS_MEDIA_ERR_INVALID_PARAMETER, "Handle is NULL");
+ media_svc_retvm_if(handle == NULL, MS_MEDIA_ERR_INVALID_PARAMETER, "Handle is NULL");
media_svc_retvm_if(count == NULL, MS_MEDIA_ERR_INVALID_PARAMETER, "count is NULL");
- return _media_svc_get_all_storage(db_handle, storage_list, storage_id_list, count);
+ return _media_svc_get_all_storage(handle, storage_list, storage_id_list, count);
}
int media_svc_generate_uuid(char **uuid)
return MS_MEDIA_ERR_NONE;
}
-int media_svc_check_storage(MediaSvcHandle *handle, const char *storage_id, char **storage_path, int *validity, uid_t uid)
+int media_svc_check_storage(sqlite3 *handle, const char *storage_id, char **storage_path, int *validity, uid_t uid)
{
- sqlite3 * db_handle = (sqlite3 *)handle;
-
- media_svc_retvm_if(db_handle == NULL, MS_MEDIA_ERR_INVALID_PARAMETER, "Handle is NULL");
+ media_svc_retvm_if(handle == NULL, MS_MEDIA_ERR_INVALID_PARAMETER, "Handle is NULL");
media_svc_retvm_if(storage_id == NULL, MS_MEDIA_ERR_INVALID_PARAMETER, "storage_id is NULL");
media_svc_retvm_if(storage_path == NULL, MS_MEDIA_ERR_INVALID_PARAMETER, "storage_path is NULL");
media_svc_retvm_if(validity == NULL, MS_MEDIA_ERR_INVALID_PARAMETER, "validity is NULL");
- return _media_svc_check_storage(db_handle, storage_id, storage_path, validity, uid);
+ return _media_svc_check_storage(handle, storage_id, storage_path, validity, uid);
}
-int media_svc_update_storage(MediaSvcHandle *handle, const char *storage_id, const char *storage_path, uid_t uid)
+int media_svc_update_storage(sqlite3 *handle, const char *storage_id, const char *storage_path, uid_t uid)
{
- sqlite3 * db_handle = (sqlite3 *)handle;
-
- media_svc_retvm_if(db_handle == NULL, MS_MEDIA_ERR_INVALID_PARAMETER, "Handle is NULL");
+ media_svc_retvm_if(handle == NULL, MS_MEDIA_ERR_INVALID_PARAMETER, "Handle is NULL");
media_svc_retvm_if(storage_id == NULL, MS_MEDIA_ERR_INVALID_PARAMETER, "storage_id is NULL");
media_svc_retvm_if(storage_path == NULL, MS_MEDIA_ERR_INVALID_PARAMETER, "storage_path is NULL");
- return _media_svc_update_storage_path(db_handle, storage_id, storage_path, uid);
+ return _media_svc_update_storage_path(handle, storage_id, storage_path, uid);
}
-int media_svc_insert_storage(MediaSvcHandle *handle, const char *storage_id, const char *storage_path, ms_user_storage_type_e storage_type, uid_t uid)
+int media_svc_insert_storage(sqlite3 *handle, const char *storage_id, const char *storage_path, ms_user_storage_type_e storage_type, uid_t uid)
{
int ret = MS_MEDIA_ERR_NONE;
- sqlite3 *db_handle = (sqlite3 *)handle;
- media_svc_retvm_if(db_handle == NULL, MS_MEDIA_ERR_INVALID_PARAMETER, "Handle is NULL");
+ media_svc_retvm_if(handle == NULL, MS_MEDIA_ERR_INVALID_PARAMETER, "Handle is NULL");
media_svc_retvm_if(storage_id == NULL, MS_MEDIA_ERR_INVALID_PARAMETER, "storage_id is NULL");
media_svc_retvm_if(storage_path == NULL, MS_MEDIA_ERR_INVALID_PARAMETER, "storage_path is NULL");
media_svc_retvm_if(__media_svc_check_storage(storage_type) != TRUE, MS_MEDIA_ERR_INVALID_PARAMETER, "Invalid storage_type");
ret = _media_svc_create_media_table_with_id(storage_id, uid);
media_svc_retvm_if(ret != MS_MEDIA_ERR_NONE, ret, "create media table failed : %d", ret);
- ret = _media_svc_update_media_view(db_handle, uid);
+ ret = _media_svc_update_media_view(handle, uid);
media_svc_retvm_if(ret != MS_MEDIA_ERR_NONE, ret, "update media view failed : %d", ret);
/* Remove external storage that validity is 0 */
- ret = _media_svc_delete_invalid_storage(db_handle, storage_type, uid);
+ ret = _media_svc_delete_invalid_storage(handle, storage_type, uid);
media_svc_retvm_if(ret != MS_MEDIA_ERR_NONE, ret, "Delete invalid storage failed : %d", ret);
return ret;
return ret;
}
-int media_svc_insert_folder(MediaSvcHandle *handle, const char *storage_id, ms_user_storage_type_e storage_type, const char *path, uid_t uid)
+int media_svc_insert_folder(sqlite3 *handle, const char *storage_id, ms_user_storage_type_e storage_type, const char *path, uid_t uid)
{
int ret = MS_MEDIA_ERR_NONE;
- sqlite3 * db_handle = (sqlite3 *)handle;
char folder_uuid[MEDIA_SVC_UUID_SIZE+1] = {0,};
- media_svc_retvm_if(db_handle == NULL, MS_MEDIA_ERR_INVALID_PARAMETER, "Handle is NULL");
+ media_svc_retvm_if(handle == NULL, MS_MEDIA_ERR_INVALID_PARAMETER, "Handle is NULL");
media_svc_retvm_if(!STRING_VALID(storage_id), MS_MEDIA_ERR_INVALID_PARAMETER, "storage_id is NULL");
media_svc_retvm_if(!STRING_VALID(path), MS_MEDIA_ERR_INVALID_PARAMETER, "path is NULL");
media_svc_retvm_if(__media_svc_check_storage(storage_type) != TRUE, MS_MEDIA_ERR_INVALID_PARAMETER, "Invalid storage_type");
return ret;
}
-int media_svc_set_folder_validity(MediaSvcHandle *handle, const char *storage_id, const char *start_path, int validity, bool is_recursive, uid_t uid)
+int media_svc_set_folder_validity(sqlite3 *handle, const char *storage_id, const char *start_path, int validity, bool is_recursive, uid_t uid)
{
int ret = MS_MEDIA_ERR_NONE;
- sqlite3 * db_handle = (sqlite3 *)handle;
- media_svc_retvm_if(db_handle == NULL, MS_MEDIA_ERR_INVALID_PARAMETER, "Handle is NULL");
+ media_svc_retvm_if(handle == NULL, MS_MEDIA_ERR_INVALID_PARAMETER, "Handle is NULL");
- ret = _media_svc_set_folder_validity(db_handle, storage_id, start_path, validity, is_recursive, uid);
+ ret = _media_svc_set_folder_validity(handle, storage_id, start_path, validity, is_recursive, uid);
return ret;
}
-int media_svc_check_folder_exist_by_path(MediaSvcHandle *handle, const char *storage_id, const char *folder_path)
+int media_svc_check_folder_exist_by_path(sqlite3 *handle, const char *storage_id, const char *folder_path)
{
int ret = MS_MEDIA_ERR_NONE;
- sqlite3 * db_handle = (sqlite3 *)handle;
int count = -1;
- media_svc_retvm_if(db_handle == NULL, MS_MEDIA_ERR_INVALID_PARAMETER, "Handle is NULL");
+ media_svc_retvm_if(handle == NULL, MS_MEDIA_ERR_INVALID_PARAMETER, "Handle is NULL");
media_svc_retvm_if(!STRING_VALID(storage_id), MS_MEDIA_ERR_INVALID_PARAMETER, "storage_id is NULL");
media_svc_retvm_if(!STRING_VALID(folder_path), MS_MEDIA_ERR_INVALID_PARAMETER, "Path is NULL");
- ret = _media_svc_count_folder_with_path(db_handle, storage_id, folder_path, &count);
+ ret = _media_svc_count_folder_with_path(handle, storage_id, folder_path, &count);
media_svc_retv_if(ret != MS_MEDIA_ERR_NONE, ret);
if (count > 0) {
return MS_MEDIA_ERR_NONE;
}
-int media_svc_get_folder_id(MediaSvcHandle *handle, const char *storage_id, const char *path, char *folder_id)
+int media_svc_get_folder_id(sqlite3 *handle, const char *storage_id, const char *path, char *folder_id)
{
int ret = MS_MEDIA_ERR_NONE;
- sqlite3 * db_handle = (sqlite3 *)handle;
- media_svc_retvm_if(db_handle == NULL, MS_MEDIA_ERR_INVALID_PARAMETER, "Handle is NULL");
+ media_svc_retvm_if(handle == NULL, MS_MEDIA_ERR_INVALID_PARAMETER, "Handle is NULL");
media_svc_retvm_if(path == NULL, MS_MEDIA_ERR_INVALID_PARAMETER, "path is NULL");
- ret = _media_svc_get_folder_uuid(db_handle, storage_id, path, folder_id);
+ ret = _media_svc_get_folder_uuid(handle, storage_id, path, folder_id);
return ret;
}