Removed hard coded paths for PHONE, MMC and OTG 12/88512/1 submit/tizen_mobile/20160919.134849
authorbhutani.92 <bhutani.92@samsung.com>
Mon, 19 Sep 2016 11:33:01 +0000 (17:03 +0530)
committerbhutani.92 <bhutani.92@samsung.com>
Mon, 19 Sep 2016 11:33:01 +0000 (17:03 +0530)
Change-Id: Ie749924edc6562db378e11990d13ea39d728c75b
Signed-off-by: bhutani.92 <bhutani.92@samsung.com>
inc/mf-fs-util.h
src/common/mf-callback.c
src/widget/mf-view.c

index 6b63890..1222e66 100755 (executable)
@@ -58,6 +58,18 @@ static void mf_lower_string(char *str) {
        }
 }
 
+static char *mf_storage_file_get(const char path[])
+{
+       char *file = NULL;
+       if ((file = strrchr(path, '/'))) {
+               file++;
+       } else {
+               file = (char *) path;
+       }
+
+       return file;
+}
+
 static bool mf_file_get_all_supported_storage_cb(int storageId, storage_type_e type, storage_state_e state, const char *path, void *userData)
 {
        char *temp_path = g_strdup(path);
@@ -129,6 +141,47 @@ static inline char *Get_Parent_Path(int storage_type)
        return storage_path;
 }
 
+static inline char *Get_Storage_Name(storage_mode_e smode)
+{
+       char *sname = NULL;
+       char *path = NULL;
+       int error_code = storage_foreach_device_supported(mf_file_get_all_supported_storage_cb, NULL);
+       if (error_code != STORAGE_ERROR_NONE) {
+               mf_error("failed to get storage Id");
+               return NULL;
+       }
+
+       if (smode == DEVICE) {
+               if (device_id != -1) {
+                       storage_get_root_directory(device_id, &path);
+                       if (path) {
+                               sname = mf_storage_file_get(path);
+                               mf_debug("Phone Name : %s", sname);
+                       }
+               }
+       } else if (smode == MMC) {
+               if (mmc_id != -1) {
+                       storage_get_root_directory(mmc_id, &path);
+                       if (path) {
+                               sname = mf_storage_file_get(path);
+                               mf_debug("MMC Name : %s", sname);
+                       }
+               }
+#ifdef MYFILE_USB_OTG
+       } else if (smode == OTG) {
+               if (otg_id != -1) {
+                       storage_get_root_directory(otg_id, &path);
+                       if (path) {
+                               sname = mf_storage_file_get(path);
+                               mf_debug("OTG Name : %s", sname);
+                       }
+               }
+#endif
+       }
+
+       return sname;
+}
+
 #define DEBUG_FOLDER    "SLP_debug"
 
 /*     File system related value definition    */
@@ -144,12 +197,12 @@ static inline char *Get_Parent_Path(int storage_type)
 #define MEMORY_FOLDER   Get_Root_Path(STORAGE_TYPE_EXTERNAL, MMC)
 #define PHONE_PARENT    Get_Parent_Path(STORAGE_TYPE_INTERNAL)
 #define STORAGE_PARENT         Get_Parent_Path(STORAGE_TYPE_EXTERNAL)
-#define PHONE_NAME         "content"
-#define MMC_NAME           "sdcard"
+#define PHONE_NAME         Get_Storage_Name(DEVICE)
+#define MMC_NAME           Get_Storage_Name(MMC)
 
 #ifdef MYFILE_USB_OTG
 #define OTG_FOLDER             Get_Root_Path(STORAGE_TYPE_EXTERNAL, OTG)
-#define OTG_NAME               "usb"
+#define OTG_NAME               Get_Storage_Name(OTG)
 #endif
 
 #define MYFILE_NAME_PATTERN    "[\\<>:;*\"|?/]"
index ae29585..eb5f2f9 100755 (executable)
@@ -3852,6 +3852,7 @@ static void __mf_callback_storage_changed_cb(int storage_id,
                } else {
                        mf_debug("No external storage detected... Returning... [%d]", ap->mf_Status.iStorageState);
                }
+               SAFE_FREE_G_CHAR(temp_path);
                return;
        }
 
index 265e10f..8058a7f 100755 (executable)
@@ -317,19 +317,22 @@ Elm_Object_Item *mf_view_item_append(Evas_Object *parent, fsNodeInfo *pNode, voi
        real_name = g_strconcat(pNode->path, "/", pNode->name, NULL);
 
        if (real_name) {
-               if (strstr(real_name, "sdcard")) {
+               char *temp_path = g_strdup(real_name);
+               mf_util_to_lower(temp_path);
+               if (strstr(temp_path, "sdcard")) {
                        if (!strcmp(pNode->name, PHONE_NAME)) {
                                real_name = g_strdup(PHONE_FOLDER);
                        } else if (!strcmp(pNode->name, MMC_NAME)) {
                                real_name = g_strdup(MEMORY_FOLDER);
                        }
-               } else if (strstr(real_name, "usb")) {
+               } else if (strstr(temp_path, "usb")) {
                        if (!strcmp(pNode->name, PHONE_NAME)) {
                                real_name = g_strdup(PHONE_FOLDER);
                        } else if (!strcmp(pNode->name, OTG_NAME)) {
                                real_name = g_strdup(OTG_FOLDER);
                        }
                }
+               SAFE_FREE_G_CHAR(temp_path);
        } else {
                mf_error("mount path is NULL");
                return NULL;