Removed media content deprecated API 01/196101/3
authorTezaswy Singh <tezaswy.s@samsung.com>
Fri, 21 Dec 2018 20:40:25 +0000 (02:10 +0530)
committerTezaswy Singh <tezaswy.s@samsung.com>
Mon, 24 Dec 2018 13:22:48 +0000 (18:52 +0530)
Change-Id: Ia13378a00abfd3f106e95d6be1352a815fcf2ba3

src/common/mf-media-data.c

index 5cf1a5a..9e45acb 100644 (file)
@@ -16,6 +16,7 @@
 
 
 #include <media_content.h>
+#include <storage.h>
 #include "mf-media-data.h"
 #include "mf-media-content.h"
 #include "mf-tray-item.h"
 #include "mf-util.h"
 #include "mf-file-util.h"
 
+typedef struct _mf_storage_media_t mf_storage_media_s;
+
+struct _mf_storage_media_t {
+       int storage_id;
+       char* file_url;
+};
+
 static int __mf_media_data_sort_by_priority(const void *d1, const void *d2,
                                                                                        int sequence_type);
 static int __mf_media_data_sort_by_name_cb_A2Z(const void *d1,
@@ -60,6 +68,29 @@ void mf_media_data_item_free(media_data_s ** item_data)
 }
 
 /**
+ * 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 ) {
+       mf_storage_media_s *storage_media = (mf_storage_media_s *)user_data;
+       if (!(storage_media && storage_media->file_url && path)) {
+               return true;
+       }
+
+       if (strncmp(path, storage_media->file_url, strlen(path)) == 0) {
+               storage_media->storage_id = storage_id;
+               return false;
+       }
+       return true;
+}
+
+/**
  *
  * @param media
  * @return
@@ -156,16 +187,27 @@ media_data_s *mf_media_data_get_by_media_handle(media_info_h media)
                        }
                        //}
                        //mf_debug("thumb_url: %s", item_data->thumbnail_path);
+                       mf_storage_media_s storage_media;
+                       storage_media.storage_id = -1;
+                       storage_media.file_url = item_data->fullpath;
+                       storage_type_e storage_type = 0;
+
+                       ret = storage_foreach_device_supported(_storage_device_supported_cb, &storage_media);
+                       if (ret != STORAGE_ERROR_NONE || storage_media.storage_id == -1) {
+                               mf_error("Get storage id failed");
+                               goto MF_LOCAL_FAILED;
+                       }
+
+                       ret = storage_get_type(storage_media.storage_id, &storage_type);
 
-                       media_content_storage_e storage_type = 0;
-                       if (media_info_get_storage_type(media, &storage_type) !=
-                               MEDIA_CONTENT_ERROR_NONE) {
-                               mf_debug("Get storage type failed!");
+                       if (ret != STORAGE_ERROR_NONE) {
+                               mf_error("Get storage type failed");
                                goto MF_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_data->storage_type = MYFILE_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_data->storage_type = MYFILE_MMC;
                        } else {
                                mf_debug("Undefined mode[%d]!", storage_type);