[Storage] Portable/Extended SD format option 49/155949/1
authorRadek Kintop <r.kintop@samsung.com>
Mon, 16 Oct 2017 13:45:16 +0000 (15:45 +0200)
committerRadek Kintop <r.kintop@samsung.com>
Mon, 16 Oct 2017 13:45:16 +0000 (15:45 +0200)
Change-Id: I45187610a77c589287fe6968758d28ea313abc1d
Signed-off-by: Radek Kintop <r.kintop@samsung.com>
setting-storage/include/setting-storage.h
setting-storage/src/setting-storage-SD.c

index c15a7f059c2b62a3732b48766ad6589b3d3e324f..64e19cff978b60a331286032bae34e2e66883dea 100755 (executable)
@@ -99,6 +99,8 @@ typedef struct _SettingStorage {
        Setting_GenGroupItem_Data *sd_total;
        Setting_GenGroupItem_Data *sd_avail;
        Setting_GenGroupItem_Data *sd_format;
+       Setting_GenGroupItem_Data *sd_format_as; /* setup as extneded or */
+                                                                                       /* portable memory */
        struct mmc_contents mmc_content;
        int sd_request;
 
index 44c56a9cf0583ac6bb73dead58a25643eab36fe3..7069787bba3e95d87b18549e35d42505765f1334 100755 (executable)
@@ -285,7 +285,7 @@ static void storage_SD_sel(void *data, Evas_Object *obj, void *event_info)
        ret_if(NULL == data);
        ret_if(NULL == event_info);
 
-       elm_genlist_item_selected_set(item, 0);
+       elm_genlist_item_selected_set(item, EINA_FALSE);
 
        if (item == ad->sd_mount->item)
                storage_SD_handle_mount_unmount(ad);
@@ -295,6 +295,57 @@ static void storage_SD_sel(void *data, Evas_Object *obj, void *event_info)
                SETTING_TRACE_ERROR("item(%p) Invalid", item);
 }
 
+static void storage_format_as_portable_storage(void *data, Evas_Object *obj,
+                       void *event_info)
+{
+       Elm_Object_Item *item = event_info;
+       app_control_h app_ctl = NULL;
+
+       ret_if(!event_info);
+
+       elm_genlist_item_selected_set(item, EINA_FALSE);
+
+       if (APP_CONTROL_ERROR_NONE != app_control_create(&app_ctl)) {
+               SETTING_TRACE_ERROR("app_ctl create failure");
+               return;
+       }
+       app_control_set_app_id(app_ctl, "org.tizen.extended-sd");
+       app_control_add_extra_data(app_ctl, "_SDCARD_SETUP_TYPE_",
+                                                                       "EXTERNAL_STORAGE_SETUP");
+       app_control_set_launch_mode(app_ctl, APP_CONTROL_LAUNCH_MODE_GROUP);
+       if (APP_CONTROL_ERROR_NONE !=
+                       app_control_send_launch_request(app_ctl, NULL, NULL))
+               SETTING_TRACE_ERROR("org.tizen.extended-sd launch request failed");
+
+       app_control_destroy(app_ctl);
+}
+
+static void storage_format_as_extended_storage(void *data, Evas_Object *obj,
+                       void *event_info)
+{
+       Elm_Object_Item *item = event_info;
+       app_control_h app_ctl = NULL;
+
+       ret_if(!event_info);
+
+       elm_genlist_item_selected_set(item, EINA_FALSE);
+
+       if (APP_CONTROL_ERROR_NONE != app_control_create(&app_ctl)) {
+               SETTING_TRACE_ERROR("app_ctl creaate fail");
+               return;
+       }
+       app_control_set_app_id(app_ctl, "org.tizen.extended-sd");
+       app_control_add_extra_data(app_ctl, "_SDCARD_SETUP_TYPE_",
+                                                                       "EXTENDED_STORAGE_SETUP");
+       app_control_set_launch_mode(app_ctl, APP_CONTROL_LAUNCH_MODE_GROUP);
+       if (APP_CONTROL_ERROR_NONE !=
+                       app_control_send_launch_request(app_ctl, NULL, NULL))
+               SETTING_TRACE_ERROR("org.tizen.extended-sd launch request failed");
+
+       app_control_destroy(app_ctl);
+}
+
+
 static Setting_GenGroupItem_Data *storage_SD_gl_insert_after(
                Evas_Object *genlist, const Elm_Genlist_Item_Class *itc,
                Elm_Object_Item *before, setting_call_back_func gl_sel,
@@ -352,7 +403,7 @@ static inline void storage_SD_info_inserted_not_mounted(SettingStorage *ad)
        }
 }
 
-static inline void storage_SD_info_mounted(SettingStorage *ad)
+static void storage_SD_info_common_mounted(SettingStorage *ad)
 {
        double total = 0.0;
        double avail = 0.0;
@@ -394,7 +445,28 @@ static inline void storage_SD_info_mounted(SettingStorage *ad)
 
        if (ad->default_storage)
                elm_object_item_disabled_set(ad->default_storage->item, EINA_FALSE);
+}
 
+static inline void storage_SD_info_portable_mounted(SettingStorage *ad)
+{
+       storage_SD_info_common_mounted(ad);
+       if (ad->sd_format) {
+               ad->sd_format_as = storage_SD_gl_insert_after(ad->md.genlist,
+                                                                       &itc_1text, ad->sd_format->item,
+                                                                       storage_format_as_extended_storage, ad,
+                                                                       _("Format as device storage"), NULL, ad);
+       }
+}
+
+static inline void storage_SD_info_extended_mounted(SettingStorage *ad)
+{
+       storage_SD_info_common_mounted(ad);
+       if (ad->sd_format) {
+               ad->sd_format_as = storage_SD_gl_insert_after(ad->md.genlist,
+                                                                       &itc_1text, ad->sd_format->item,
+                                                                       storage_format_as_portable_storage, ad,
+                                                                       _("Format as portable storage"), NULL, ad);
+       }
 }
 
 static inline void storage_SD_remove_info(SettingStorage *ad)
@@ -415,6 +487,10 @@ static inline void storage_SD_remove_info(SettingStorage *ad)
                elm_object_item_del(ad->sd_format->item);
                ad->sd_format = NULL;
        }
+       if (ad->sd_format_as) {
+               elm_object_item_del(ad->sd_format_as->item);
+               ad->sd_format_as = NULL;
+       }
 }
 
 void storage_main_append_SD_info(SettingStorage *ad)
@@ -434,12 +510,12 @@ void storage_main_append_SD_info(SettingStorage *ad)
 
        if (VCONFKEY_SYSMAN_MMC_REMOVED == mmc_mode)
                storage_SD_info_removed(ad);
-       else if (VCONFKEY_SYSMAN_MMC_INSERTED_NOT_MOUNTED == mmc_mode)
+       if (VCONFKEY_SYSMAN_MMC_INSERTED_NOT_MOUNTED == mmc_mode)
                storage_SD_info_inserted_not_mounted(ad);
-       else if (VCONFKEY_SYSMAN_MMC_MOUNTED == mmc_mode)
-               storage_SD_info_mounted(ad);
-       else
-               SETTING_TRACE_ERROR("mmc_mode(%d) Invalid", mmc_mode);
+       if (VCONFKEY_SYSMAN_MMC_MOUNTED == mmc_mode)
+               storage_SD_info_portable_mounted(ad);
+       if (VCONFKEY_SYSMAN_MMC_EXTENDEDINTERNAL_MOUNTED == mmc_mode)
+               storage_SD_info_extended_mounted(ad);
 
 #if 0
        str = vconf_get_str(storage_ENCRYPT_stat);