Change media_content_delete_db parameter (filepath to media_id) 56/91556/3 accepted/tizen/3.0/ivi/20161028.134102 accepted/tizen/3.0/mobile/20161028.133219 accepted/tizen/3.0/tv/20161028.133528 accepted/tizen/3.0/wearable/20161028.133750 accepted/tizen/common/20161010.145934 accepted/tizen/ivi/20161010.232433 accepted/tizen/mobile/20161010.232352 accepted/tizen/tv/20161010.232411 accepted/tizen/wearable/20161010.232418 submit/tizen/20161010.091116 submit/tizen_3.0/20161028.062323 submit/tizen_3.0/20161028.082423 submit/tizen_3.0_common/20161104.104000
authorJihoon Jung <jh8801.jung@samsung.com>
Mon, 10 Oct 2016 07:35:25 +0000 (16:35 +0900)
committerJihoon Jung <jh8801.jung@samsung.com>
Mon, 10 Oct 2016 07:49:24 +0000 (16:49 +0900)
Signed-off-by: Jihoon Jung <jh8801.jung@samsung.com>
Change-Id: I1447de667291974ec6b5e6023400634e1da3d1e6

include/entity/mtp_object.h
include/util/mtp_media_info.h
packaging/mtp-responder.spec
src/entity/mtp_object.c
src/entity/mtp_store.c
src/mtp_cmd_handler_util.c
src/util/mtp_media_info.c

index 46128a7..b97dea5 100755 (executable)
@@ -20,7 +20,6 @@
 #include "mtp_list.h"
 #include "ptp_datacodes.h"
 #include "mtp_fs.h"
-#include "mtp_media_info.h"
 
 #define FIXED_LENGTH_MEMBERS_SIZE \
        (4 * sizeof(mtp_uint16) + 11 * sizeof(mtp_uint32))
@@ -56,6 +55,7 @@ typedef struct {
        mtp_char *file_path;
        ptp_array_t child_array;        /* Include all the renferences */
        slist_t propval_list;   /* Object Properties implemented */
+       mtp_char *media_id; /* Tizen Media Content variable */
 } mtp_obj_t;
 
 mtp_bool _entity_get_file_times(mtp_obj_t *obj, ptp_time_string_t *create_tm,
index 553562e..8cc9d67 100755 (executable)
@@ -21,6 +21,7 @@
 #include <media_content.h>
 #include "mtp_config.h"
 #include "mtp_datatype.h"
+#include "mtp_object.h"
 
 #define MEDIA_PATH_COND                        "MEDIA_PATH="
 #define MEDIA_PATH_COND_LEN            13      /* MEDIA_PATH="" */
@@ -95,8 +96,8 @@ mtp_bool _util_get_audio_meta_from_extractor(const mtp_char *filepath,
 mtp_bool _util_get_video_meta_from_extractor(const mtp_char *filepath,
                comp_video_meta_t *video_data);
 void _util_flush_db(void);
-void _util_delete_file_from_db(const mtp_char *filepath);
-void _util_add_file_to_db(const mtp_char *filepath);
+void _util_delete_file_from_db(const mtp_char *media_id);
+void _util_add_file_to_db(mtp_obj_t *obj, mtp_char *filepath);
 void _util_scan_folder_contents_in_db(const mtp_char *filepath);
 void _util_free_common_meta(common_meta_t *metadata);
 void _util_free_video_meta(video_meta_t *video);
index 5483681..8117d69 100755 (executable)
@@ -5,7 +5,7 @@ ExcludeArch: %arm aarch64
 
 Name:       mtp-responder
 Summary:    Media Transfer Protocol daemon (responder)
-Version:    0.0.14
+Version:    0.0.15
 Release:    1
 Group:      Network & Connectivity/Other
 License:    Apache-2.0
index 1cc13bf..fb7b817 100755 (executable)
@@ -23,6 +23,7 @@
 #include "mtp_support.h"
 #include "mtp_util.h"
 #include "mtp_device.h"
+#include "mtp_media_info.h"
 
 
 extern mtp_bool g_is_full_enum;
@@ -620,7 +621,7 @@ mtp_bool _entity_set_child_object_path(mtp_obj_t *obj, mtp_char *src_path,
                        _entity_dealloc_mtp_obj(child_obj);
                        continue;
                }
-               _util_delete_file_from_db(child_obj->file_path);
+               _util_delete_file_from_db(child_obj->media_id);
 
                if (_entity_set_object_file_path(child_obj, dest_child_path,
                                        CHAR_TYPE) == FALSE) {
@@ -748,6 +749,9 @@ void _entity_dealloc_mtp_obj(mtp_obj_t *obj)
                g_free(node);
        }
 
+       if (obj->media_id != NULL)
+               free(obj->media_id);
+
        g_free(obj->file_path);
        g_free(obj);
        obj = NULL;
index 7b9cba8..51e1ba0 100755 (executable)
@@ -925,7 +925,7 @@ mtp_uint16 _entity_delete_obj_mtp_store(mtp_store_t *store,
                                node = node->link;
                                temp = _util_delete_node(&(store->obj_list), obj);
                                g_free(temp);
-                               _util_delete_file_from_db(obj->file_path);
+                               _util_delete_file_from_db(obj->media_id);
                                _entity_dealloc_mtp_obj(obj);
                        } else {
                                node = node->link;
@@ -957,7 +957,7 @@ mtp_uint16 _entity_delete_obj_mtp_store(mtp_store_t *store,
 
                                temp = _util_delete_node(&(store->obj_list), obj);
                                g_free(temp);
-                               _util_delete_file_from_db(obj->file_path);
+                               _util_delete_file_from_db(obj->media_id);
                                _entity_dealloc_mtp_obj(obj);
                        } else {
                                switch (response) {
index a0c9927..2b51b60 100755 (executable)
@@ -982,9 +982,9 @@ mtp_err_t _hutil_move_object_entry(mtp_uint32 dst_store_id, mtp_uint32 h_parent,
                                return MTP_ERROR_GENERAL;
                        }
 
-                       _util_delete_file_from_db(obj->file_path);
+                       _util_delete_file_from_db(obj->media_id);
                        _entity_set_object_file_path(obj, dst_fpath, CHAR_TYPE);
-                       _util_add_file_to_db(obj->file_path);
+                       _util_add_file_to_db(obj, obj->file_path);
                }
 
                if (obj->obj_info->h_parent != PTP_OBJECTHANDLE_ROOT) {
@@ -1033,7 +1033,7 @@ mtp_err_t _hutil_move_object_entry(mtp_uint32 dst_store_id, mtp_uint32 h_parent,
                if (new_obj->obj_info->obj_fmt == PTP_FMT_ASSOCIATION)
                        _util_scan_folder_contents_in_db(new_obj->file_path);
                else
-                       _util_add_file_to_db(new_obj->file_path);
+                       _util_add_file_to_db(new_obj, new_obj->file_path);
 
                return MTP_ERROR_NONE;
        }
@@ -1114,7 +1114,7 @@ mtp_err_t _hutil_duplicate_object_entry(mtp_uint32 dst_store_id,
        if (new_obj->obj_info->obj_fmt == PTP_FMT_ASSOCIATION) {
                _util_scan_folder_contents_in_db(new_obj->file_path);
        } else {
-               _util_add_file_to_db(new_obj->file_path);
+               _util_add_file_to_db(new_obj, new_obj->file_path);
        }
 
        return MTP_ERROR_NONE;
@@ -1236,7 +1236,7 @@ mtp_err_t _hutil_write_file_data(mtp_uint32 store_id, mtp_obj_t *obj,
        }
 #endif /* MTP_SUPPORT_SET_PROTECTION */
 
-       _util_add_file_to_db(obj->file_path);
+       _util_add_file_to_db(obj, obj->file_path);
 
 #ifndef MTP_USE_RUNTIME_GETOBJECTPROPVALUE
        if (updatePropertyValuesMtpObject(obj) == FALSE) {
@@ -2044,9 +2044,8 @@ mtp_err_t _hutil_update_object_property(mtp_uint32 obj_handle,
                                _util_scan_folder_contents_in_db(orig_fpath);
                                _util_scan_folder_contents_in_db(dest_fpath);
                        } else {
-                               _util_delete_file_from_db(orig_fpath);
-                               _util_add_file_to_db(dest_fpath);
-
+                               _util_delete_file_from_db(obj->media_id);
+                               _util_add_file_to_db(obj, dest_fpath);
                        }
 
                        /* Finally assign new handle and update full path */
index befff54..28ee0aa 100755 (executable)
@@ -768,24 +768,25 @@ ERROR_EXIT:
 
 void _util_flush_db(void)
 {
-       _util_add_file_to_db(NULL);
+       _util_add_file_to_db(NULL, NULL);
        _util_delete_file_from_db(NULL);
 }
 
-void _util_delete_file_from_db(const mtp_char *filepath)
+void _util_delete_file_from_db(const mtp_char *media_id)
 {
        int ret;
 
-       ret_if(NULL == filepath);
+       ret_if(NULL == media_id);
 
-       ret = media_info_delete_from_db(filepath);
+       ERR("delete media_id is %s", media_id);
+       ret = media_info_delete_from_db(media_id);
        if (MEDIA_CONTENT_ERROR_NONE != ret)
                ERR("media_info_delete_from_db() Fail(%d)", ret);
 
        return;
 }
 
-void _util_add_file_to_db(const mtp_char *filepath)
+void _util_add_file_to_db(mtp_obj_t *obj, mtp_char *filepath)
 {
        mtp_int32 ret;
        media_info_h info = NULL;
@@ -796,6 +797,17 @@ void _util_add_file_to_db(const mtp_char *filepath)
        if (MEDIA_CONTENT_ERROR_NONE != ret)
                ERR("media_info_insert_to_db() Fail(%d)", ret);
 
+       if (obj->media_id != NULL) {
+               free(obj->media_id);
+               obj->media_id = NULL;
+       }
+
+       ret = media_info_get_media_id(info, &obj->media_id);
+
+       ERR("add media_id is %s", obj->media_id);
+       if (MEDIA_CONTENT_ERROR_NONE != ret)
+               ERR("media_info_get_media_id() Fail(%d)", ret);
+
        if (info)
                media_info_destroy(info);