tizen 2.3 release
[apps/home/settings.git] / setting-reset / src / setting-reset-main.c
index 801ecc7..bcb4abb 100755 (executable)
@@ -1,26 +1,40 @@
 /*
  * setting
- * Copyright (c) 2012 Samsung Electronics Co., Ltd.
  *
- * Licensed under the Flora License, Version 1.1 (the License);
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd.
+ *
+ * Contact: MyoungJune Park <mj2004.park@samsung.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
  * You may obtain a copy of the License at
  *
- *     http://floralicense.org/license/
+ * http://www.apache.org/licenses/LICENSE-2.0
  *
  * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an AS IS BASIS,
+ * distributed under the License is distributed on an "AS IS" BASIS,
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  * See the License for the specific language governing permissions and
  * limitations under the License.
+ *
  */
 
 #include <setting-reset-main.h>
-#include <sysman.h>
+#include <dd-deviced.h>
+#if SUPPORT_ENCRYPTION
+#include <ode.h>
+#include <act_lock_api.h>
+#endif
+
+#include <dbus/dbus-glib-lowlevel.h>
 
+#define FACTORY_RESET_DBUS_OBJPATH     "/org.tizen/factoryreset"
+#define FACTORY_RESET_DBUS_DEST        "org.tizen.factoryreset"
+#define FACTORY_RESET_DBUS_INTERFACE   FACTORY_RESET_DBUS_DEST".start"
 
 #define RESULT_FONT_SIZE 28//18
 #define ITEM_NAME_FONT_SIZE 35//22
+#define PREDEF_FACTORY_RESET   "launchfr"
 
 static int setting_reset_main_create(void *cb);
 static int setting_reset_main_destroy(void *cb);
@@ -34,18 +48,38 @@ setting_view setting_view_reset_main = {
        .cleanup = setting_reset_main_cleanup,
 };
 
-static void setting_reset_main_click_softkey_cancel_cb(void *data,
-                                                      Evas_Object *obj,
-                                                      void *event_info);
+static Eina_Bool setting_reset_main_click_softkey_cancel_cb(void *data, Elm_Object_Item *it);
+
 #if SUPPORT_RESET_DETAILS
 static void setting_reset_main_mouse_up_Gendial_list_cb(void *data, Evas_Object *obj, void *event_info);
 #endif
 
-/* ***************************************************
- *
- *basic func
- *
- ***************************************************/
+
+
+#if SUPPORT_FACTORY_RESET
+/**
+ *@brief check the file "/usr/bin/factory-reset " exist.
+*/
+static bool is_factory_reset_installed()
+{
+       char *file_name = "/usr/bin/factory-reset";
+
+       struct stat st;
+       if(stat(file_name, &st) == 0) {
+               return true;
+       }
+       else {
+               SETTING_TRACE_ERROR(" %s is *NOT* present\n", file_name);
+               return false;
+       }
+}
+#endif
+
+
+
+/**
+ *@brief create the reset main view.
+*/
 static int setting_reset_main_create(void *cb)
 {
        SETTING_TRACE_BEGIN;
@@ -54,173 +88,41 @@ static int setting_reset_main_create(void *cb)
 
        SettingResetUG *ad = (SettingResetUG *) cb;
        Evas_Object *scroller = NULL;
-#if SIMPLY_SUPPORT_ALL_RESET
-       ad->ly_main =
-           setting_create_layout_navi_bar_genlist(ad->win_main_layout,
-                                                  ad->win_get,
-                                                  _("IDS_COM_BODY_RESET"),
-                                                  _("IDS_COM_BODY_BACK"), NULL,
-                                                  setting_reset_main_click_softkey_cancel_cb,
-                                                  NULL, ad, &scroller,
-                                                  &(ad->navi_bar));
-       /* Description */
-       setting_create_Gendial_field_def(scroller, &(ad->itc_1text), NULL,
-                                        ad, SWALLOW_Type_LAYOUT_SPECIALIZTION_X,
-                                        NULL, NULL, 0, RESET_ALL_DESC,
-                                        NULL, NULL);
-       elm_genlist_item_select_mode_set(elm_genlist_item_append(scroller, &(itc_seperator), NULL, NULL,ELM_GENLIST_ITEM_NONE, NULL, NULL),
-                                        ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY);
-       /* Button */
-       Setting_GenGroupItem_Data *item_data =
-           (Setting_GenGroupItem_Data *) calloc(1,
-                                                sizeof
-                                                (Setting_GenGroupItem_Data));
-       setting_retvm_if(!item_data, SETTING_RETURN_FAIL, "calloc failed");
-       item_data->userdata = ad;
-       item_data->keyStr = (char *)g_strdup(RESET_ALL);
-       item_data->swallow_type = SWALLOW_Type_1BUTTON;
-
-       item_data->chk_change_cb = __reset_all_button_cb;
-       item_data->item = elm_genlist_item_append(scroller, &(ad->itc_1icon), item_data, NULL,
-                                                   ELM_GENLIST_ITEM_NONE,
-                                                   NULL, NULL);
-       setting_view_reset_main.is_create = 1;
-       ad->main_scroller = scroller;
-       return SETTING_RETURN_SUCCESS;
-#endif
 
 #if SUPPORT_RESET_DETAILS
        ad->ly_main =
            setting_create_layout_navi_bar_genlist(ad->win_main_layout,
                                                   ad->win_get,
-                                                  _("IDS_COM_BODY_RESET"),
-                                                  _("IDS_COM_BODY_BACK"), NULL,
-                                                  setting_reset_main_click_softkey_cancel_cb,
+                                                  _(KeyStr_Reset),
+                                                  NULL, NULL,
+                                                  NULL,
                                                   NULL, ad, &scroller,
                                                   &(ad->navi_bar));
+       ad->genlist = scroller;
+       evas_object_smart_callback_add(ad->genlist, "realized", __gl_realized_cb, ad);
+       Elm_Object_Item * navi_it = elm_naviframe_top_item_get(ad->navi_bar);
+       elm_naviframe_item_pop_cb_set(navi_it, setting_reset_main_click_softkey_cancel_cb, ad);
+       //Elm_Object_Item *item = NULL;;
+       Setting_GenGroupItem_Data *item_data = NULL;
 
-       Elm_Object_Item *item = NULL;;
 
-       item =
-           elm_genlist_item_append(scroller, &itc_seperator, NULL, NULL,
-                                   ELM_GENLIST_ITEM_NONE, NULL, NULL);
-       elm_genlist_item_select_mode_set(item, ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY);
+       ADD_GL_SEPARATOR(scroller);
 
-       /* 1. Reset settings */
-       setting_create_Gendial_field_def(scroller, &itc_1text,
+       bool isFoundOther = FALSE;
+#if SUPPORT_FACTORY_RESET
+       /* 3. Factory reset */
+       item_data = setting_create_Gendial_field_def(scroller, &itc_1text,
                                                                setting_reset_main_mouse_up_Gendial_list_cb,ad,
                                                                SWALLOW_Type_INVALID,
                                                                NULL, NULL,
-                                                               0, RESET_SETTINGS_STR, NULL, NULL);
-#if SUPPORT_SIM_CARD_PROFILE
-       /* 2. SIM card profile settings */
-       #ifdef TARGET
-       int is_sim_profile_enabled = csc_svc_sim_auto_setting_chk_feature_enable();
-       int err = 0;
-       int value = VCONFKEY_TELEPHONY_SIM_UNKNOWN;
-       setting_get_int_slp_key(INT_SLP_SETTING_SIM_SLOT, &value, &err);
-       if (is_sim_profile_enabled && VCONFKEY_TELEPHONY_SIM_INSERTED == value) {
-               setting_create_Gendial_field_def(scroller, &itc_1text,
-                                                               setting_reset_main_mouse_up_Gendial_list_cb,ad,
-                                                               SWALLOW_Type_INVALID,
-                                                               NULL, NULL,
-                                                               0, SIM_CARD_PROFILE_SETTINGS_STR, NULL, NULL);
-       } else {
-               SETTING_TRACE("is_sim_profile_enabled:%d", is_sim_profile_enabled);
-               SETTING_TRACE("value:%d", value);
-       }
-       #else
-       SETTING_TRACE("TARGET MACRO disabled");
-       #endif
-
-#endif
-
-#if DISABLED_CODE
-       /* Description */
-       setting_create_Gendial_field_def(scroller, &itc_multiline_text, NULL,
-                                        ad, SWALLOW_Type_LAYOUT_SPECIALIZTION_X,
-                                        NULL, NULL, 0, RESET_ALL_DESC,
-                                        NULL, NULL);
+                                                               0,FACTORY_RESET_STR, NULL, NULL);
+       item_data->group_style = isFoundOther ? SETTING_GROUP_STYLE_BOTTOM : SETTING_GROUP_STYLE_NONE;
 #endif
        setting_view_reset_main.is_create = 1;
        ad->main_scroller = scroller;
        return SETTING_RETURN_SUCCESS;
 
 #endif
-
-#if SUPPORT_RESET_OLD
-       Evas_Object *navi_bar = NULL;
-
-       Evas_Object *controllbar = NULL;
-
-       Evas_Object *view_layout = elm_layout_add(ad->win_main_layout);
-       elm_layout_file_set(view_layout, SETTING_THEME_EDJ_NAME,
-                           "selinfo_bottom");
-       evas_object_size_hint_weight_set(view_layout, EVAS_HINT_EXPAND, 0.0);
-
-       /*  Evas_Object * win_layout, Evas_Object * win_obj */
-       ad->ly_main =
-           setting_create_layout_navi_bar(ad->win_main_layout, ad->win_get,
-                                          _("IDS_COM_BODY_RESET"),
-                                          _("IDS_COM_SK_CANCEL"),
-                                          _("IDS_COM_BODY_RESET"), NULL,
-                                          setting_reset_main_click_softkey_cancel_cb,
-                                          setting_reset_main_click_softkey_reset_cb,
-                                          NULL, ad, view_layout, &navi_bar,
-                                          &controllbar);
-       elm_object_item_disabled_set(elm_toolbar_last_item_get
-                                        (controllbar), EINA_TRUE);
-
-       /* ******************************************create frame */
-       Setting_Done_List_Data *list_data = &(ad->list_data);   /* define a handle */
-       int idx = 0;
-       list_data->win_main = ad->ly_main;
-       list_data->UG_data = ad;
-       list_data->ly_parent = view_layout;
-       list_data->controllbar = controllbar;
-
-
-       list_data->chk_items[idx++].item_name = KeyStr_Select_All;
-       char *ug_args;
-       char *item_name;
-
-       int i = 0;
-       int j = 0;
-
-       for (; i < setting_cfg_get_category_length(); i++) {
-               SETTING_TRACE("group is:%s", _(setting_cfg_get_category_name(i)));
-
-               for (j = 0; j < setting_cfg_get_menu_length(i); j++) {
-                       /*SETTING_TRACE("i:%d\tj:%d", i, j);*/
-                       if (Cfg_Item_unResetable ==
-                           setting_cfg_get_resetable_flag_idx(i, j))
-                       {
-                           continue;
-                       }
-                       list_data->chk_items[idx].ug_args = ug_args =
-                                       setting_cfg_get_ug_args_idx(i, j);
-                       list_data->chk_items[idx].item_name = item_name =
-                                       setting_cfg_get_keyname_idx(i, j);
-
-                       SETTING_TRACE("process %s:\t%s",_(item_name), ug_args);
-                       idx++;
-               }
-       }
-
-       list_data->cur_item_num = idx;
-       SETTING_TRACE("list_data->cur_item_num:%d", list_data->cur_item_num);
-       scroller = setting_create_done_list(list_data);
-       elm_object_part_content_set(view_layout, "elm.swallow.contents", scroller);
-
-       ad->view_layout = view_layout;
-       ad->navi_bar = navi_bar;
-       ad->controllbar = controllbar;
-       /* *******************************************update info */
-
-       setting_view_reset_main.is_create = 1;
-       ad->itc_1text.func.text_get = __result_gl_text_get;
-       return SETTING_RETURN_SUCCESS;
-#endif
 }
 
 static int setting_reset_main_destroy(void *cb)
@@ -230,6 +132,8 @@ static int setting_reset_main_destroy(void *cb)
        retv_if(cb == NULL, SETTING_GENERAL_ERR_NULL_DATA_PARAMETER);
 
        SettingResetUG *ad = (SettingResetUG *) cb;
+       evas_object_smart_callback_del(ad->genlist, "realized", __gl_realized_cb);
+
        if (ad->notify) {
                evas_object_del(ad->notify);
                ad->notify = NULL;
@@ -238,23 +142,27 @@ static int setting_reset_main_destroy(void *cb)
                evas_object_del(ad->old_notify);
                ad->old_notify = NULL;
        }
-       if (ad->pop_progress)
-       {
+       if (ad->pop_progress) {
                evas_object_del(ad->pop_progress);
                ad->pop_progress = NULL;
        }
 
-       if (ad->ask_popup)
-       {
+       if (ad->ask_popup) {
                evas_object_del(ad->ask_popup);
                ad->ask_popup = NULL;
        }
-       if (ad->animator)
-       {
+       if (ad->animator) {
                ecore_animator_del(ad->animator);
                ad->animator = NULL;
        }
-
+       if (ad->pop) {
+               evas_object_del(ad->pop);
+               ad->pop = NULL;
+       }
+       if (ad->pop_factory_reset) {
+               evas_object_del(ad->pop_factory_reset);
+               ad->pop_factory_reset = NULL;
+       }
        if (ad->ly_main != NULL) {
                evas_object_del(ad->ly_main);
                setting_view_reset_main.is_create = 0;
@@ -293,27 +201,289 @@ static int setting_reset_main_cleanup(void *cb)
        return SETTING_RETURN_SUCCESS;
 }
 
+static void __setting_reset_main_factory_reset()
+{
+       DBusMessage *message = NULL;
+       DBusConnection *conn = NULL;
+
+       conn = dbus_bus_get(DBUS_BUS_SYSTEM, NULL);
+       if (!conn) {
+               SETTING_TRACE_ERROR("dbus_bus_get() error");
+               return;
+       }
+       message = dbus_message_new_signal(FACTORY_RESET_DBUS_OBJPATH,
+                       FACTORY_RESET_DBUS_INTERFACE,
+                       "setting");
+       if (!message) {
+               SETTING_TRACE_ERROR("dbus_message_new_signal() error");
+               dbus_connection_unref(conn);
+               return;
+       }
+       dbus_message_set_destination(message, FACTORY_RESET_DBUS_DEST);
+       dbus_connection_send(conn, message, NULL);
+       dbus_message_unref(message);
+       dbus_connection_unref(conn);
+}
+
+/**
+ * @brief do some init before the factory reset.
+ */
+static void __setting_reset_main_elm_profile_initialise()
+{
+       SETTING_TRACE_BEGIN;
+       const char *profile = NULL;
+       const char *pdir = NULL;
+       Eina_List *l = NULL;
+       Eina_List *profs = NULL;
+
+       profs = elm_config_profile_list_get();
+       EINA_LIST_FOREACH(profs, l, profile)
+       {
+               pdir = elm_config_profile_dir_get(profile, EINA_TRUE);
+               if (pdir) {
+                       ecore_file_recursive_rm(pdir);
+                       elm_config_profile_dir_free(pdir);
+               }
+       }
+       elm_config_profile_list_free(profs);
+}
+/**
+ * @brief do some init before the factory reset.
+ */
+static void __setting_reset_main_initialise_for_factory_reset()
+{
+       SETTING_TRACE_BEGIN;
+       __setting_reset_main_elm_profile_initialise();
+}
+
+
+/*
+  *    execute /usr/bin/factory-reset after creating a process with fork()
+  */
+static void
+setting_reset_main_result_password_ug_cb(ui_gadget_h ug, app_control_h result,
+                                        void *priv)
+{
+       SETTING_TRACE_BEGIN;
+       /* error check */
+       retm_if(priv == NULL, "Data parameter is NULL");
+
+       SettingResetUG *ad = (SettingResetUG *) priv;
+
+       char *ret_str = NULL;
+       app_control_get_extra_data(result, "result", &ret_str);
+       SETTING_TRACE("result:%s", ret_str);
+
+       retm_if(ret_str == NULL, "result paremeter is NULL");
+
+       if (ret_str) {
+               if (0 == safeStrCmp("Cancel", ret_str)) {
+                       /* Do not reset */
+               }
+               else if (!strncmp(ret_str, "SETTING_PW_TYPE_", strlen("SETTING_PW_TYPE_")))
+               {
+                       setting_ug_destroy(ad->ug_loading);
+                       ad->ug_loading = NULL;
+
+                       /* before factory reset, do some initialization */
+                       __setting_reset_main_initialise_for_factory_reset();
+
+#if SUPPORT_ENCRYPTION
+                       // If ode status is "encrypted" or "mounted', call ode_restore() instead of below.
+                       char *encryption_state = NULL;
+                       encryption_state = vconf_get_str(VCONFKEY_ODE_CRYPTO_STATE);
+                       if(encryption_state && (safeStrCmp(encryption_state, "mounted") == 0 || safeStrCmp(encryption_state, "encrypted") == 0)) {
+                               ode_init();
+                               ode_restore();
+                               ode_deinit();
+                       }
+                       else {
+                               //deviced_call_predef_action(PREDEF_FACTORY_RESET, 0, NULL);
+                               __setting_reset_main_factory_reset();
+                       }
+                       FREE(encryption_state);
+#else
+                       //deviced_call_predef_action(PREDEF_FACTORY_RESET, 0, NULL);
+                       __setting_reset_main_factory_reset();
+#endif
+               }
+               FREE(ret_str);
+       }
+}
+
+/**
+ * @brief the callback function for calling ug layout,it use for call checking screen lock ug.
+*/
+static void
+setting_reset_main_layout_ug_cb(ui_gadget_h ug, enum ug_mode mode,
+                               void *priv)
+{
+       //SettingResetUG *ad = (SettingResetUG *) priv;
+       Evas_Object *base;
+
+       if (!ug || !priv) {
+               return;
+       }
+       SETTING_TRACE_BEGIN;
+
+       base = (Evas_Object *) ug_get_layout(ug);
+       if (!base) {
+               return;
+       }
+       switch (mode) {
+       case UG_MODE_FULLVIEW:
+               evas_object_size_hint_weight_set(base, EVAS_HINT_EXPAND,
+                                                EVAS_HINT_EXPAND);
+               //elm_win_resize_object_add(ad->win_get, base);
+               evas_object_show(base);
+               break;
+       default:
+               break;
+       }
+       SETTING_TRACE_END;
+}
+
+static void setting_reset_main_destroy_ug_cb(ui_gadget_h ug,
+                                                     void *priv)
+{
+       SETTING_TRACE_BEGIN;
+       /* if(ug) ug_destroy(ug); */
+       ret_if(!priv);
+       SettingResetUG *ad = (SettingResetUG *) priv;
+       if (ug) {
+               setting_ug_destroy(ug);
+               ad->ug_loading = NULL;
+       }
+}
+/**
+ *@brief the function check the lockscreen.If the screen lock was set by password,It need to check the password before reset operation.
+*/
+static bool setting_reset_main_create_password_sg(void *data, int cur_locktype)
+{
+       SETTING_TRACE_BEGIN;
+       /* error check */
+       retv_if(data == NULL, FALSE);
+
+       SettingResetUG *ad = (SettingResetUG *) data;
+
+       struct ug_cbs *cbs = (struct ug_cbs *)calloc(1, sizeof(struct ug_cbs));
+       if (!cbs)
+               return FALSE;
+       cbs->layout_cb = setting_reset_main_layout_ug_cb;
+       cbs->result_cb = setting_reset_main_result_password_ug_cb;
+       cbs->destroy_cb = setting_reset_main_destroy_ug_cb;
+       cbs->priv = (void *)ad;
+       app_control_h svc;
+       if (app_control_create(&svc))
+       {
+               FREE(cbs);
+               return FALSE;
+       }
+
+       if(cur_locktype == SETTING_SCREEN_LOCK_TYPE_SIMPLE_PASSWORD)
+       {
+               app_control_add_extra_data(svc, "viewtype", "SETTING_PW_TYPE_SIMPLE_PASSWORD");
+       }
+       else if(cur_locktype == SETTING_SCREEN_LOCK_TYPE_PASSWORD)
+       {
+               app_control_add_extra_data(svc, "viewtype", "SETTING_PW_TYPE_PASSWORD");
+       }
+       else
+       {
+               SETTING_TRACE_DEBUG("unsupported locktype : %d", cur_locktype);
+               app_control_destroy(svc);
+               FREE(cbs);
+               return FALSE;
+       }
+
+       elm_object_tree_focus_allow_set(ad->ly_main, EINA_FALSE);
+       ad->ug_loading =
+           setting_ug_create(ad->ug, "setting-password-efl", UG_MODE_FULLVIEW, svc, cbs);
+       if (NULL == ad->ug_loading) {   /* error handling */
+       }
+
+       app_control_destroy(svc);
+       FREE(cbs);
+
+       return TRUE;
+}
+
+/**
+ *@brief callback function for factory reset popup,when you excute the factory reset,it will popup the message to check.
+*/
+static void __ask_create_factory_reset_resp_cb(void *data, Evas_Object *obj,
+                                          void *event_info)
+{
+       SETTING_TRACE_BEGIN;
+
+       SettingResetUG *ad = (SettingResetUG *) data;
+       ret_if(NULL == data);
+
+       int response_type = POPUP_RESPONSE_CANCEL;
+       char *utf8 = elm_entry_markup_to_utf8(elm_object_text_get(obj));
+       if (0 == safeStrCmp(utf8, _("IDS_ST_HEADER_RESET")))
+       {
+               response_type = POPUP_RESPONSE_OK;
+       }
+       FREE(utf8);
+       int screen_lock_type = 0;
+
+       if (POPUP_RESPONSE_OK == response_type) {
+               SETTING_TRACE("OK");
+               vconf_get_int(VCONFKEY_SETAPPL_SCREEN_LOCK_TYPE_INT, &screen_lock_type);
+               if(screen_lock_type == SETTING_SCREEN_LOCK_TYPE_PASSWORD
+                       || screen_lock_type == SETTING_SCREEN_LOCK_TYPE_SIMPLE_PASSWORD)
+               {
+                       setting_reset_main_create_password_sg(ad, screen_lock_type);
+               }
+               else {
+                       /* before factory reset, do some initialization */
+                       __setting_reset_main_initialise_for_factory_reset();
+                       __setting_reset_main_factory_reset();
+                       //deviced_call_predef_action(PREDEF_FACTORY_RESET, 0, NULL);
+               }
+       }
+       else if (POPUP_RESPONSE_CANCEL == response_type) {
+               SETTING_TRACE("NO");
+               // do nothing
+       }
+
+       evas_object_del(ad->pop_factory_reset);
+       ad->pop_factory_reset = NULL;
+}
+
+/**
+ *@brief the callback for reboot,when you reset  the factory mode,it will be called to reboot the target.
+*/
+#ifdef TARGET
 static void setting_reset_reboot_resp_cb(void *data, Evas_Object *obj,
                                        void *event_info)
 {
        SETTING_TRACE_BEGIN;
-       int response_type = btn_type(obj);
+       int response_type = POPUP_RESPONSE_CANCEL;
+       char *utf8 = elm_entry_markup_to_utf8(elm_object_text_get(obj));
+       if (0 == safeStrCmp(utf8, _("IDS_ST_HEADER_RESET")))
+       {
+               response_type = POPUP_RESPONSE_OK;
+       }
+       FREE(utf8);
+
        if (POPUP_RESPONSE_OK == response_type) {                       // OK cliked
-               csc_svc_sim_auto_setting_clear_active_operator();
                // reboot here
-               sysman_request_reboot();
+               deviced_request_reboot();
 
-       } else if (POPUP_RESPONSE_CANCEL == response_type) { // cancel clicked
+       }
+       else if (POPUP_RESPONSE_CANCEL == response_type) { // cancel clicked
                // DO NOTHING
        }
 
        SettingResetUG *ad = data;
-       if (ad->pop)
-       {
+       if (ad->pop) {
                evas_object_del(ad->pop);
                ad->pop = NULL;
        }
 }
+#endif
 
 #if SUPPORT_RESET_DETAILS
 static void
@@ -333,36 +503,72 @@ setting_reset_main_mouse_up_Gendial_list_cb(void *data, Evas_Object *obj, void *
 
        SETTING_TRACE("clicking item[%s]", _(list_item->keyStr));
 
-       if (!safeStrCmp(RESET_SETTINGS_STR, list_item->keyStr))
-       {
+       if (!safeStrCmp(RESET_SETTINGS_STR, list_item->keyStr)) {
                setting_view_change(&setting_view_reset_main, &setting_view_reset_settings, ad);
        }
-#if SUPPORT_SIM_CARD_PROFILE
-       else if (!safeStrCmp(SIM_CARD_PROFILE_SETTINGS_STR, list_item->keyStr))
+#if SUPPORT_FACTORY_RESET
+       else if (!safeStrCmp(FACTORY_RESET_STR, list_item->keyStr))
        {
-               SETTING_TRACE("SIM-CARD PROFILE");
-               #ifdef TARGET
-               ad->pop = setting_create_popup_with_btn(ad, ad->win_get, NULL,
-                                        _("IDS_ST_BODY_RESET_SIM_CARD_PROFILE_SETTINGS_TO_DEFAULT_AND_SELECT_ANOTHER_SERVICE_PROVIDER_MSG"),
-                                        //setting_time_reboot_resp_cb,
-                                        setting_reset_reboot_resp_cb,
-                                        0, 2,
-                                dgettext("sys_string", "IDS_COM_SK_OK"),
-                                _("IDS_COM_SK_CANCEL"));
-               #endif
+               /* TBD */
+               SETTING_TRACE("FACTORY RESET");
+               if(is_factory_reset_installed()) {
+                       char guide_str[2048 + 1] = {0,};
+                       int ret = snprintf(guide_str, 2048, "%s %s", _(FACTORY_RESET00), _(FACTORY_RESET02));
+                       if(ret < 0) {
+                               SETTING_TRACE("snprintf failed");
+                       }
+                       //setting_create_simple_popup(NULL, ad->win_get, NULL, "NOT IMPLMENTED YET");
+                       ad->pop_factory_reset = setting_create_popup_with_btn(ad,
+                                                         ad->win_get,
+                                                         NULL, guide_str,
+                                                         __ask_create_factory_reset_resp_cb,
+                                                         0, 2, _("IDS_ST_HEADER_RESET"),_("IDS_COM_SK_CANCEL"));
+               }
+               else {
+                       setting_create_simple_popup(NULL, ad->win_get, NULL, _("IDS_MSGF_POP_UNSUPPORTED"));
+               }
        }
 #endif
-       /* to do : */
+       else if (!safeStrCmp(KeyStr_Accounts, list_item->keyStr))
+       {
+               struct ug_cbs *cbs = (struct ug_cbs *)calloc(1, sizeof(struct ug_cbs));
+               if (!cbs) {
+                       return;
+               }
+
+               cbs->layout_cb = setting_reset_main_layout_ug_cb;
+               cbs->result_cb = NULL;
+               cbs->destroy_cb = setting_reset_main_destroy_ug_cb;
+               cbs->priv = (void *)ad;
+
+               app_control_h svc;
+               if (app_control_create(&svc)) {
+                       FREE(cbs);
+                       return;
+               }
+               app_control_add_extra_data(svc, "mode", "account_list");
+               elm_object_tree_focus_allow_set(ad->ly_main, EINA_FALSE);
+               ad->ug_loading =
+                   setting_ug_create(ad->ug, "setting-myaccount-efl", UG_MODE_FULLVIEW, svc, cbs);
+
+               if (NULL == ad->ug_loading) {   /* error handling */
+                       SETTING_TRACE_ERROR("NULL == ad->ug_loading");
+               }
+               app_control_destroy(svc);
+               FREE(cbs);
+       }
 }
 #endif
 
-static void
-setting_reset_main_click_softkey_cancel_cb(void *data, Evas_Object *obj,
-                                          void *event_info)
+
+/**
+ *@brief the callback function for cancel button,when press the back key or cancel button,it will be called.
+*/
+static Eina_Bool setting_reset_main_click_softkey_cancel_cb(void *data, Elm_Object_Item *it)
 {
        SETTING_TRACE_BEGIN;
        /* error check */
-       retm_if(data == NULL, "Data parameter is NULL");
+       retvm_if(data == NULL, EINA_FALSE, "Data parameter is NULL");
 
        SettingResetUG *ad = (SettingResetUG *) data;
        if (ad->list_data.selInfoPop) {
@@ -371,5 +577,7 @@ setting_reset_main_click_softkey_cancel_cb(void *data, Evas_Object *obj,
        }
        /* Send destroy request */
        ug_destroy_me(ad->ug);
+
+       return EINA_FALSE;
 }