X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=src%2Fcommon%2Fmedia-svc-media-folder.c;h=64e9441ea14975c59251902be165b41bf119a017;hb=7e83f615762d7eb12a9cf9d7b1767256df7b1396;hp=f7c5ff4b200915582dae535d3647c83f609b75a5;hpb=4b08e9cdb114fc16e0624eb9d84c5258dc23e57d;p=platform%2Fcore%2Fmultimedia%2Flibmedia-service.git diff --git a/src/common/media-svc-media-folder.c b/src/common/media-svc-media-folder.c index f7c5ff4..64e9441 100755 --- a/src/common/media-svc-media-folder.c +++ b/src/common/media-svc-media-folder.c @@ -3,8 +3,6 @@ * * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved. * - * Contact: Hyunjun Ko , Haejeong Kim - * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at @@ -20,7 +18,8 @@ */ #include -#include +#include + #include "media-svc-media-folder.h" #include "media-svc-debug.h" #include "media-svc-env.h" @@ -45,7 +44,7 @@ static int __media_svc_get_folder_id(sqlite3 *handle, const char *path, long lon return ret; } -static int __media_svc_append_folder(bool is_direct, const char *storage_id, ms_user_storage_type_e storage_type, const char *folder_path, uid_t uid) +static int __media_svc_append_folder(bool is_direct, const char *storage_id, const char *folder_path, uid_t uid) { int ret = MS_MEDIA_ERR_NONE; char *folder_name = NULL; @@ -55,8 +54,8 @@ static int __media_svc_append_folder(bool is_direct, const char *storage_id, ms_ folder_modified_date = _media_svc_get_file_time(folder_path); /* Sometime SQLITE3 returns NO_RECORD, so need to consider conflict case.. */ - char *sql = sqlite3_mprintf("INSERT OR IGNORE INTO %q (folder_path, folder_name, storage_uuid, folder_storage_type, folder_modified_time) VALUES (%Q, %Q, %Q, '%d', '%d');", - DB_TABLE_FOLDER, folder_path, folder_name, storage_id, storage_type, folder_modified_date); + char *sql = sqlite3_mprintf("INSERT OR IGNORE INTO %q (folder_path, folder_name, storage_uuid, folder_modified_time) VALUES (%Q, %Q, %Q, '%d');", + DB_TABLE_FOLDER, folder_path, folder_name, storage_id, folder_modified_date); if (is_direct) ret = _media_svc_sql_query_direct(sql, uid); @@ -85,28 +84,15 @@ int _media_svc_update_folder_modified_time(const char *folder_path, uid_t uid) return ret; } -static int __media_svc_append_parent_folder(sqlite3 *handle, bool is_direct, const char *storage_id, const char *path, ms_user_storage_type_e storage_type, uid_t uid) +static int __media_svc_append_parent_folder(sqlite3 *handle, bool is_direct, const char *storage_id, const char *path, uid_t uid) { int ret = MS_MEDIA_ERR_NONE; - unsigned int next_pos = 0; + size_t next_pos = ms_user_get_root_length(path, uid); char *next = NULL; char *dir_path = NULL; - const char *token = "/"; - char *internal_path = NULL; - - if (storage_type == MS_USER_STORAGE_INTERNAL) { - ret = ms_user_get_internal_root_path(uid, &internal_path); - media_svc_retvm_if(ret != MS_MEDIA_ERR_NONE, ret, "Fail to get root path"); - - next_pos = strlen(internal_path); - g_free(internal_path); - } else { - media_svc_retvm_if(!STRING_VALID(MEDIA_ROOT_PATH_EXTERNAL), MS_MEDIA_ERR_INTERNAL, "Failed to get root path"); - next_pos = strlen(MEDIA_ROOT_PATH_EXTERNAL) + 1; - } do { - next = strstr(path + next_pos, token); + next = strstr(path + next_pos, "/"); if (next) { next_pos = (next - path); dir_path = g_strndup(path, next_pos); @@ -117,7 +103,7 @@ static int __media_svc_append_parent_folder(sqlite3 *handle, bool is_direct, con ret = _media_svc_check_folder_by_path(handle, dir_path); if (ret == MS_MEDIA_ERR_DB_NO_RECORD) { - ret = __media_svc_append_folder(is_direct, storage_id, storage_type, dir_path, uid); + ret = __media_svc_append_folder(is_direct, storage_id, dir_path, uid); if (ret != MS_MEDIA_ERR_NONE) media_svc_error("__media_svc_append_folder is failed"); else @@ -130,7 +116,7 @@ static int __media_svc_append_parent_folder(sqlite3 *handle, bool is_direct, con return MS_MEDIA_ERR_NONE; } -int _media_svc_get_and_append_folder_id_by_path(sqlite3 *handle, bool is_direct, const char *storage_id, const char *path, ms_user_storage_type_e storage_type, long long int *folder_id, uid_t uid) +int _media_svc_get_and_append_folder_id_by_path(sqlite3 *handle, bool is_direct, const char *storage_id, const char *path, long long int *folder_id, uid_t uid) { char *dir_path = NULL; int ret = MS_MEDIA_ERR_NONE; @@ -139,7 +125,7 @@ int _media_svc_get_and_append_folder_id_by_path(sqlite3 *handle, bool is_direct, ret = __media_svc_get_folder_id(handle, dir_path, folder_id); if (ret == MS_MEDIA_ERR_DB_NO_RECORD) { - ret = __media_svc_append_parent_folder(handle, is_direct, storage_id, dir_path, storage_type, uid); + ret = __media_svc_append_parent_folder(handle, is_direct, storage_id, dir_path, uid); if (ret != MS_MEDIA_ERR_NONE) { media_svc_error("__media_svc_append_parent_folder failed"); goto FINALIZE; @@ -153,13 +139,13 @@ FINALIZE: return ret; } -int _media_svc_append_by_folder_path(sqlite3 *handle, const char *storage_id, const char *path, ms_user_storage_type_e storage_type, uid_t uid) +int _media_svc_append_by_folder_path(sqlite3 *handle, const char *storage_id, const char *path, uid_t uid) { int ret = MS_MEDIA_ERR_NONE; ret = _media_svc_check_folder_by_path(handle, path); if (ret == MS_MEDIA_ERR_DB_NO_RECORD) - ret = __media_svc_append_parent_folder(handle, true, storage_id, path, storage_type, uid); + ret = __media_svc_append_parent_folder(handle, true, storage_id, path, uid); else ret = _media_svc_set_folder_validity(true, path, 1, false, uid);