From: Kartik Tidke Date: Thu, 20 Dec 2018 20:45:13 +0000 (+0530) Subject: Removed media contant deprecated API X-Git-Tag: submit/tizen/20181224.162738^0 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=refs%2Fchanges%2F98%2F195998%2F5;p=profile%2Fmobile%2Fapps%2Fnative%2Fgallery.git Removed media contant deprecated API Change-Id: I86c796a3b02e68a8da3c885f3d0404a45420c99f Signed-off-by: Kartik Tidke --- diff --git a/src/data/gl-local-data.c b/src/data/gl-local-data.c index 4daea04..b3dcc98 100644 --- a/src/data/gl-local-data.c +++ b/src/data/gl-local-data.c @@ -19,9 +19,11 @@ #include "gl-debug.h" #include "gl-thread-util.h" #include "gl-file-util.h" +#include typedef struct _gl_transfer_data_t gl_transfer_data_s; typedef struct _gl_foreach_data_t gl_foreach_data_s; +typedef struct _gl_storage_rec_t gl_storage_rec_s; struct _gl_transfer_data_t { void **userdata; @@ -37,6 +39,36 @@ struct _gl_foreach_data_t { bool with_meta; }; +struct _gl_storage_rec_t { + int storage_id; + char *file_url; +}; + +/** + * Called to get information once for each supported storage. + * @param storage_id : The unique storage ID + * @param type : The type of the storage + * @param state : The current state of the storage + * @param path : The absolute path to the root directory of the storage + * @param user_data : The user data passed from the foreach function + * @return + */ +static bool _storage_device_supported_cb(int storage_id, storage_type_e type, + storage_state_e state, const char *path, void *user_data) +{ + gl_storage_rec_s *storage_rec = (gl_storage_rec_s *)user_data; + + if (!(storage_rec && storage_rec->file_url && path)) { + return true; + } + + if (strncmp(path, storage_rec->file_url, strlen(path)) == 0) { + storage_rec->storage_id = storage_id; + return false; + } + return true; +} + /** * create media filter condition to get local media album * @param condition : filter condition @@ -129,6 +161,7 @@ static bool __gl_local_data_get_album_list_cb(media_folder_h folder, GL_CHECK_FALSE(tmp_data->userdata); GL_CHECK_FALSE(folder); + int ret = -1; Eina_List **elist = (Eina_List **) (tmp_data->userdata); gl_album_s *album = NULL; @@ -154,21 +187,6 @@ static bool __gl_local_data_get_album_list_cb(media_folder_h folder, goto GL_LOCAL_FAILED; } - media_content_storage_e storage_type; - if (media_folder_get_storage_type(folder, &storage_type) != - MEDIA_CONTENT_ERROR_NONE) { - gl_dbgE("Get folder type failed!"); - goto GL_LOCAL_FAILED; - } - - if (storage_type == MEDIA_CONTENT_STORAGE_INTERNAL) { /* The device's internal storage */ - album->type = GL_STORE_T_PHONE; - } else if (storage_type == MEDIA_CONTENT_STORAGE_EXTERNAL) { /* The device's external storage */ - album->type = GL_STORE_T_MMC; - } else { - gl_dbgE("Undefined mode[%d]!", storage_type); - } - if (media_folder_get_name(folder, &(album->display_name)) != MEDIA_CONTENT_ERROR_NONE) { gl_dbgE("Get folder name failed!"); @@ -180,6 +198,33 @@ static bool __gl_local_data_get_album_list_cb(media_folder_h folder, gl_dbgE("Get folder path failed!"); goto GL_LOCAL_FAILED; } + + gl_storage_rec_s storage_rec; + storage_rec.storage_id = -1; + storage_rec.file_url = album->path; + storage_type_e storage_type = 0; + + ret = storage_foreach_device_supported(_storage_device_supported_cb, &storage_rec); + if (ret != STORAGE_ERROR_NONE || storage_rec.storage_id == -1) { + gl_dbgE("Get storage id failed!"); + goto GL_LOCAL_FAILED; + } + + ret = storage_get_type(storage_rec.storage_id, &storage_type); + + if (ret != STORAGE_ERROR_NONE) { + gl_dbgE("Get storage type failed!"); + goto GL_LOCAL_FAILED; + } + + if (storage_type == STORAGE_TYPE_INTERNAL) { /* The device's internal storage */ + album->type = GL_STORE_T_PHONE; + } else if (storage_type == STORAGE_TYPE_EXTERNAL) { /* The device's external storage */ + album->type = GL_STORE_T_MMC; + } else { + gl_dbgE("Undefined mode[%d]!", storage_type); + } + /* TMP: done */ if (tmp_data->filter) { if (media_folder_get_media_count_from_db @@ -272,19 +317,32 @@ static bool __gl_local_data_get_media_list_cb(media_info_h media, goto GL_LOCAL_FAILED; } - media_content_storage_e storage_type = 0; - if (media_info_get_storage_type(media, &storage_type) != - MEDIA_CONTENT_ERROR_NONE) { + gl_storage_rec_s storage_rec; + storage_rec.storage_id = -1; + storage_rec.file_url = item->file_url; + storage_type_e storage_type = 0; + + ret = storage_foreach_device_supported(_storage_device_supported_cb, &storage_rec); + if (ret != STORAGE_ERROR_NONE || storage_rec.storage_id == -1) { + gl_dbgE("Get storage id failed!"); + goto GL_LOCAL_FAILED; + } + + ret = storage_get_type(storage_rec.storage_id, &storage_type); + + if (ret != STORAGE_ERROR_NONE) { gl_dbgE("Get storage type failed!"); goto GL_LOCAL_FAILED; } - if (storage_type == MEDIA_CONTENT_STORAGE_INTERNAL) { /* The device's internal storage */ + + if (storage_type == STORAGE_TYPE_INTERNAL) { /* The device's internal storage */ item->storage_type = GL_STORE_T_PHONE; - } else if (storage_type == MEDIA_CONTENT_STORAGE_EXTERNAL) { /* The device's external storage */ + } else if (storage_type == STORAGE_TYPE_EXTERNAL) { /* The device's external storage */ item->storage_type = GL_STORE_T_MMC; } else { gl_dbgE("Undefined mode[%d]!", storage_type); } + /* Without meta */ if (!tmp_data->with_meta) { goto GL_LOCAL_SUCCESS; diff --git a/src/util/gl-util.c b/src/util/gl-util.c index 0045e3b..a85d360 100644 --- a/src/util/gl-util.c +++ b/src/util/gl-util.c @@ -1176,7 +1176,6 @@ int _gl_del_media_by_id(void *data, const char *uuid) GL_CHECK_VAL(uuid, -1); GL_CHECK_VAL(data, -1); media_info_h media_h = NULL; - media_content_storage_e storage_type = 0; int ret = -1; char *path = NULL; @@ -1185,11 +1184,7 @@ int _gl_del_media_by_id(void *data, const char *uuid) gl_dbgE("Get media failed[%d]!", ret); goto DEL_MEDIA_BY_ID_FAILED; } - ret = media_info_get_storage_type(media_h, &storage_type); - if (ret != MEDIA_CONTENT_ERROR_NONE) { - gl_dbgE("Get storage type failed!"); - goto DEL_MEDIA_BY_ID_FAILED; - } + ret = media_info_get_file_path(media_h, &path); if (ret != MEDIA_CONTENT_ERROR_NONE) { gl_dbgE("Get media file path failed!");