tizen 2.3.1 release
[apps/home/settings.git] / setting-reset / src / setting-reset.c
old mode 100755 (executable)
new mode 100644 (file)
index f997f65..791835f
@@ -1,37 +1,43 @@
 /*
  * setting
- * Copyright (c) 2012 Samsung Electronics Co., Ltd.
  *
- * Licensed under the Flora License, Version 1.0 (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.h>
+#include <setting-cfg.h>
 #include <ITapiModem.h>
 #include <TapiUtility.h>
 #include <tapi_common.h>
+#include <setting-cfg.h>
 
 #ifndef UG_MODULE_API
 #define UG_MODULE_API __attribute__ ((visibility("default")))
 #endif
 
 static void setting_reset_ug_cb_resize(void *data, Evas *e, Evas_Object *obj,
-                                      void *event_info)
+                                       void *event_info)
 {
        SettingResetUG *ad = (SettingResetUG *) data;
        setting_view_update(&setting_view_reset_main, ad);
 }
 
 static void *setting_reset_ug_on_create(ui_gadget_h ug, enum ug_mode mode,
-                                       service_h service, void *priv)
+                                        app_control_h service, void *priv)
 {
        setting_retvm_if((!priv), NULL, "!priv");
 
@@ -45,12 +51,12 @@ static void *setting_reset_ug_on_create(ui_gadget_h ug, enum ug_mode mode,
        resetUG->evas = evas_object_evas_get(resetUG->win_main_layout);
 
        setting_retvm_if(resetUG->win_main_layout == NULL, NULL,
-                        "cannot get main window ");
+                        "cannot get main window ");
 
        setting_set_i18n(SETTING_PACKAGE, SETTING_LOCALEDIR);
 
-       setting_create_Gendial_itc("multiline/1text", &(resetUG->itc_1text));
-       setting_create_Gendial_itc("dialogue/bg/1icon", &(resetUG->itc_1icon));
+       setting_create_Gendial_itc("multiline_sub", &(resetUG->itc_1text));
+       setting_create_Gendial_itc("1icon", &(resetUG->itc_1icon));
 
        /*  creating a view. */
        setting_view_node_table_register(&setting_view_reset_main, NULL);
@@ -59,28 +65,28 @@ static void *setting_reset_ug_on_create(ui_gadget_h ug, enum ug_mode mode,
 
        setting_view_create(&setting_view_reset_main, (void *)resetUG);
        evas_object_event_callback_add(resetUG->win_main_layout,
-                                      EVAS_CALLBACK_RESIZE,
-                                      setting_reset_ug_cb_resize, resetUG);
+                                      EVAS_CALLBACK_RESIZE,
+                                      setting_reset_ug_cb_resize, resetUG);
        return resetUG->ly_main;
 }
 
-static void setting_reset_ug_on_start(ui_gadget_h ug, service_h service,
-                                     void *priv)
+static void setting_reset_ug_on_start(ui_gadget_h ug, app_control_h service,
+                                      void *priv)
 {
 }
 
-static void setting_reset_ug_on_pause(ui_gadget_h ug, service_h service,
-                                     void *priv)
+static void setting_reset_ug_on_pause(ui_gadget_h ug, app_control_h service,
+                                      void *priv)
 {
 }
 
-static void setting_reset_ug_on_resume(ui_gadget_h ug, service_h service,
-                                      void *priv)
+static void setting_reset_ug_on_resume(ui_gadget_h ug, app_control_h service,
+                                       void *priv)
 {
 }
 
-static void setting_reset_ug_on_destroy(ui_gadget_h ug, service_h service,
-                                       void *priv)
+static void setting_reset_ug_on_destroy(ui_gadget_h ug, app_control_h service,
+                                        void *priv)
 {
        SETTING_TRACE_BEGIN;
        setting_retm_if((!priv), "!priv");
@@ -100,112 +106,106 @@ static void setting_reset_ug_on_destroy(ui_gadget_h ug, service_h service,
        SETTING_TRACE_END;
 }
 
-static void setting_reset_ug_on_message(ui_gadget_h ug, service_h msg,
-                                       service_h service, void *priv)
+static void setting_reset_ug_on_message(ui_gadget_h ug, app_control_h msg,
+                                        app_control_h service, void *priv)
 {
        SETTING_TRACE_BEGIN;
 }
 
 static void setting_reset_ug_on_event(ui_gadget_h ug, enum ug_event event,
-                                     service_h service, void *priv)
+                                      app_control_h service, void *priv)
 {
        SETTING_TRACE_BEGIN;
        setting_retm_if(!priv, "!priv");
        SettingResetUG *ad = (SettingResetUG *) priv;
        switch (event) {
-       case UG_EVENT_LOW_MEMORY:
-               break;
-       case UG_EVENT_LOW_BATTERY:
-               break;
-       case UG_EVENT_LANG_CHANGE:
-       {
-               /* navigation item in reset setting view */
-               Elm_Object_Item *navi_it = elm_naviframe_top_item_get(ad->navi_bar);
-               ret_if(!navi_it);
-               elm_object_item_text_set(navi_it, _(RESET_SETTINGS_STR));
-
-               /* navigation item in reset main view */
-               navi_it = elm_naviframe_bottom_item_get(ad->navi_bar);
-               ret_if(!navi_it);
-               elm_object_item_text_set(navi_it, _("IDS_COM_BODY_RESET"));
-
-               if (ad->main_scroller)
-               {
-                       elm_genlist_realized_items_update(ad->main_scroller);
-               }
-               SETTING_TRACE("ad->main_scroller:%p", ad->main_scroller);
-
-               if (ad->controllbar)
-               {
-                       Elm_Object_Item *item = NULL;
-                       item = elm_toolbar_first_item_get(ad->controllbar);
-                       if (item)
-                       {
+               case UG_EVENT_LOW_MEMORY:
+                       break;
+               case UG_EVENT_LOW_BATTERY:
+                       break;
+               case UG_EVENT_LANG_CHANGE: {
+                               /* navigation item in reset setting view */
+                               Elm_Object_Item *navi_it = elm_naviframe_top_item_get(ad->navi_bar);
+                               ret_if(!navi_it);
+                               elm_object_item_text_set(navi_it, _(RESET_SETTINGS_STR));
+
+                               /* navigation item in reset main view */
+                               navi_it = elm_naviframe_bottom_item_get(ad->navi_bar);
+                               ret_if(!navi_it);
+                               elm_object_item_text_set(navi_it, _("IDS_COM_BODY_RESET"));
+
+                               if (ad->main_scroller) {
+                                       elm_genlist_realized_items_update(ad->main_scroller);
+                               }
+                               SETTING_TRACE("ad->main_scroller:%p", ad->main_scroller);
+
+                               if (ad->controllbar) {
+                                       Elm_Object_Item *item = NULL;
+                                       item = elm_toolbar_first_item_get(ad->controllbar);
+                                       if (item) {
 #if SUPPORT_BOTTOM_BTNS
-                               elm_object_item_text_set(item, _("IDS_COM_BODY_RESET"));
+                                               elm_object_item_text_set(item, _("IDS_COM_BODY_RESET"));
 #else
-                               Evas_Object *eo_btn = elm_object_item_part_content_get(item, "object");
-                               setting_retm_if(eo_btn == NULL, "get eo_lbtn failed");
-                               elm_object_text_set(eo_btn, _("IDS_COM_SK_CANCEL"));
+                                               Evas_Object *eo_btn = elm_object_item_part_content_get(item, "object");
+                                               setting_retm_if(eo_btn == NULL, "get eo_lbtn failed");
+                                               elm_object_text_set(eo_btn, _("IDS_COM_SK_CANCEL"));
 #endif
-                       }
+                                       }
 
-                       item = elm_toolbar_last_item_get(ad->controllbar);
-                       if (item)
-                       {
+                                       item = elm_toolbar_last_item_get(ad->controllbar);
+                                       if (item) {
 #if SUPPORT_BOTTOM_BTNS
-                               elm_object_item_text_set(item, _("IDS_COM_SK_CANCEL"));
+                                               elm_object_item_text_set(item, _("IDS_COM_SK_CANCEL"));
 #else
-                               Evas_Object *eo_btn = elm_object_item_part_content_get(item, "object");
-                               setting_retm_if(eo_btn == NULL, "get eo_lbtn failed");
-                               elm_object_text_set(eo_btn, _("IDS_COM_BODY_RESET"));
+                                               Evas_Object *eo_btn = elm_object_item_part_content_get(item, "object");
+                                               setting_retm_if(eo_btn == NULL, "get eo_lbtn failed");
+                                               elm_object_text_set(eo_btn, _("IDS_COM_BODY_RESET"));
 #endif
+                                       }
+                               }
+                               Evas_Object *sub_layout = elm_object_part_content_get(ad->view_layout, "elm.swallow.contents");
+                               if (sub_layout) {
+                                       Evas_Object *select_all_layout = elm_object_part_content_get(sub_layout, "search_bar");
+                                       if (select_all_layout) {
+                                               elm_object_part_text_set(select_all_layout, "elm.text", _(KeyStr_Select_All));
+                                       }
+                               }
+
+                               if (ad->reset_list) {
+                                       elm_genlist_realized_items_update(ad->reset_list);
+                               }
+                               setting_reset_result_popup_update(ad);
+
+                               break;
                        }
-               }
-               Evas_Object *sub_layout = elm_object_part_content_get(ad->view_layout, "elm.swallow.contents");
-               if (sub_layout)
-               {
-                       Evas_Object *select_all_layout = elm_object_part_content_get(sub_layout, "search_bar");
-                       if (select_all_layout) {
-                               elm_object_part_text_set(select_all_layout, "elm.text", _(KeyStr_Select_All));
-                       }
-               }
-
-               if (ad->reset_list)
-                       elm_genlist_realized_items_update(ad->reset_list);
-
-               // setting_reset_result_popup_update(ad);
 
-               break;
-       }
-
-       case UG_EVENT_ROTATE_PORTRAIT:
-               break;
-       case UG_EVENT_ROTATE_PORTRAIT_UPSIDEDOWN:
-               break;
-       case UG_EVENT_ROTATE_LANDSCAPE:
-               break;
-       case UG_EVENT_ROTATE_LANDSCAPE_UPSIDEDOWN:
-               break;
-       case UG_EVENT_REGION_CHANGE:
-               break;
-       default:
-               break;
+               case UG_EVENT_ROTATE_PORTRAIT:
+                       break;
+               case UG_EVENT_ROTATE_PORTRAIT_UPSIDEDOWN:
+                       break;
+               case UG_EVENT_ROTATE_LANDSCAPE:
+                       break;
+               case UG_EVENT_ROTATE_LANDSCAPE_UPSIDEDOWN:
+                       break;
+               case UG_EVENT_REGION_CHANGE:
+                       break;
+               default:
+                       break;
        }
 }
 
 static void setting_reset_ug_on_key_event(ui_gadget_h ug,
-                                         enum ug_key_event event,
-                                         service_h service, void *priv)
+                                          enum ug_key_event event,
+                                          app_control_h service, void *priv)
 {
        SETTING_TRACE_BEGIN;
 
        switch (event) {
-       case UG_KEY_EVENT_END:
-               ug_destroy_me(ug);
-               break;
-       default:
-               break;
+               case UG_KEY_EVENT_END:
+                       ug_destroy_me(ug);
+                       break;
+               default:
+                       break;
        }
 }
 
@@ -229,6 +229,9 @@ UG_MODULE_API int UG_MODULE_INIT(struct ug_module_ops *ops)
        return 0;
 }
 
+/**
+ *@brief callback function for reset UG.the exit the reset mode, it will be called to destory the resource.
+*/
 UG_MODULE_API void UG_MODULE_EXIT(struct ug_module_ops *ops)
 {
        SETTING_TRACE_BEGIN;
@@ -236,8 +239,9 @@ UG_MODULE_API void UG_MODULE_EXIT(struct ug_module_ops *ops)
        setting_retm_if(!ops, "ops == NULL");
 
        resetUG = ops->priv;
-       if (resetUG)
+       if (resetUG) {
                FREE(resetUG);
+       }
 }
 
 /* ***************************************************
@@ -245,22 +249,9 @@ UG_MODULE_API void UG_MODULE_EXIT(struct ug_module_ops *ops)
  *general func
  *
  ***************************************************/
-#if DISABLED_CODE
-static void __ask_popup_response_cb(void *data, Evas_Object *obj, void *event_info)
-{
-       if (btn_type(obj) == POPUP_RESPONSE_OK) {
-               elm_exit();//exit the Setting app
-       }
-
-       ret_if(!data);
-       SettingResetUG *ad = data;
-       if (ad->ask_popup) {
-               evas_object_del(ad->ask_popup);
-               ad->ask_popup = NULL;
-       }
-}
-#endif
-
+/**
+ *@brief callback function for reset result.when you press the button in the popup, it will be called.
+*/
 void setting_reset_result_popup_resp_cb(void *data, Evas_Object *obj, void *event_info)
 {
        SETTING_TRACE_BEGIN;
@@ -268,52 +259,59 @@ void setting_reset_result_popup_resp_cb(void *data, Evas_Object *obj, void *even
        SettingResetUG *ad = data;
        if (btn_type(obj) == POPUP_RESPONSE_OK) {
        }
+
+       if (ad->reset_process) {
+               evas_object_del(ad->reset_process);
+               ad->reset_process = NULL;
+       }
        if (ad->notify) {
                evas_object_del(ad->notify);
                ad->notify = NULL;
        }
-
+#if 0
        if (ad->old_notify) {
                evas_object_del(ad->old_notify);
                ad->old_notify = NULL;
        }
-       ad->pop_btn = NULL;
+#endif
 }
 
-/**
- * language change makes B/S on resetting "Language&Region UG"
- */
 void setting_reset_result_popup_update(void *data)
 {
-#if 1
        SETTING_TRACE_BEGIN;
        ret_if(!data);
        SettingResetUG *ad = data;
        if (ad->notify) {
-               elm_object_part_text_set(ad->notify, "title,text", _(RESET_RESULT_STR));
+               elm_object_part_text_set(ad->notify, "title,text", _(RESET_SETTINGS_STR));
                Evas_Object *btn = elm_object_part_content_get(ad->notify, "button1");
-               elm_object_style_set(btn, "popup_button/default");
-               if (btn)
-               {
+               elm_object_style_set(btn, "popup");
+               if (btn) {
                        elm_object_text_set(btn, _("IDS_COM_SK_OK"));
                }
+               /*
                Evas_Object *genlist = elm_object_content_get(ad->notify);
                if(genlist)
                {
                        elm_genlist_realized_items_update(genlist);
                        elm_object_content_set(ad->notify, genlist);
                }
-               //evas_object_show(ad->notify);
+               */
+               /*evas_object_show(ad->notify); */
        }
-#endif
 }
 
-
+/**
+ *@brief callback function for reset flight mode.when reset the flight mode,it will be called.
+*/
 static void __tapi_flight_mode_cb(TapiHandle *handle, int result, void *data, void *user_data)
 {
        SETTING_TRACE_BEGIN;
        SETTING_TRACE("result:%d", result);
 }
+
+/**
+ *@brief reset function for reset flight mode.
+*/
 int setting_reset_flight_mode()
 {
        int ret = -1;
@@ -322,7 +320,7 @@ int setting_reset_flight_mode()
                SETTING_TRACE_ERROR("tel_init error");
        }
 
-       //if callback is NULL,it will return failed directly.
+       /*if callback is NULL,it will return failed directly. */
        if (tel_set_flight_mode(handle, TAPI_POWER_FLIGHT_MODE_LEAVE, __tapi_flight_mode_cb, NULL) == 0) {
 #if SUPPORT_RUN_SYSTEM_COMMAND
                ret = excuteCmd(SETTING_POSTINST_FILE, 1, "flightmode");
@@ -340,12 +338,39 @@ int setting_reset_flight_mode()
        return ret;
 }
 
+/*
+ * @brief lock the screen,make it does not support rotation.
+ */
 int setting_reset_rotation_lock(void)
 {
 #if SUPPORT_RUN_SYSTEM_COMMAND
        return excuteCmd(SETTING_POSTINST_FILE, 1, "rotationLock");
 #else
-       return vconf_set_bool(VCONFKEY_SETAPPL_AUTO_ROTATE_SCREEN_BOOL, FALSE);
+       return vconf_set_bool(VCONFKEY_SETAPPL_ROTATE_LOCK_BOOL, TRUE);
 #endif
 }
 
+static Setting_Cfg_Node_T reset_node_array[] = {
+       {"IDS_ST_MBODY_FACTORY_RESET", NULL, "search_key:IDS_ST_MBODY_FACTORY_RESET", 0, 0, 0, Cfg_Item_View_Node, NULL, NULL, NULL, NULL},
+};
+
+/**
+ *@brief init function for setting module search,it will add the module name into the search database.
+*/
+UG_MODULE_API int setting_plugin_search_init(app_control_h service, void *priv, char **applocale)
+{
+       SETTING_TRACE_BEGIN;
+       SETTING_TRACE(">> setting-reset-efl DB search code");
+
+       *applocale = strdup("setting:/usr/apps/org.tizen.setting/res/locale");
+
+       Eina_List **pplist = (Eina_List **)priv;
+       int i;
+       int size = sizeof(reset_node_array) / sizeof(reset_node_array[0]);
+       for (i = 0; i < size; i++) {
+               Setting_Cfg_Node_T *node = setting_plugin_search_item_subindex_add(reset_node_array[i].key_name, reset_node_array[i].ug_args, IMG_Reset, reset_node_array[i].item_type,  reset_node_array[i].data, "Reset");
+               *pplist = eina_list_append(*pplist, node);
+       }
+       return 0;
+}
+