#include "gl-debug.h"
#include "gl-thread-util.h"
#include "gl-file-util.h"
+#include <storage.h>
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;
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
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;
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!");
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
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;