tizen 2.3 release
[apps/home/settings.git] / setting-reset / src / setting-reset.c
index cdcf311..ef605a9 100755 (executable)
@@ -1,23 +1,29 @@
 /*
  * 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.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")))
@@ -31,7 +37,7 @@ static void setting_reset_ug_cb_resize(void *data, Evas *e, Evas_Object *obj,
 }
 
 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");
 
@@ -49,8 +55,8 @@ static void *setting_reset_ug_on_create(ui_gadget_h ug, enum ug_mode mode,
 
        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);
@@ -64,22 +70,22 @@ static void *setting_reset_ug_on_create(ui_gadget_h ug, enum ug_mode mode,
        return resetUG->ly_main;
 }
 
-static void setting_reset_ug_on_start(ui_gadget_h ug, service_h service,
+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,
+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,
+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,
+static void setting_reset_ug_on_destroy(ui_gadget_h ug, app_control_h service,
                                        void *priv)
 {
        SETTING_TRACE_BEGIN;
@@ -100,14 +106,14 @@ 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");
@@ -171,10 +177,10 @@ static void setting_reset_ug_on_event(ui_gadget_h ug, enum ug_event event,
                        }
                }
 
-               if (ad->reset_list)
+               if (ad->reset_list){
                        elm_genlist_realized_items_update(ad->reset_list);
-
-               // setting_reset_result_popup_update(ad);
+               }
+               setting_reset_result_popup_update(ad);
 
                break;
        }
@@ -196,7 +202,7 @@ static void setting_reset_ug_on_event(ui_gadget_h ug, enum ug_event event,
 
 static void setting_reset_ug_on_key_event(ui_gadget_h ug,
                                          enum ug_key_event event,
-                                         service_h service, void *priv)
+                                         app_control_h service, void *priv)
 {
        SETTING_TRACE_BEGIN;
 
@@ -229,6 +235,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 +245,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 +255,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 +265,60 @@ 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");
+               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);
        }
-#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;
@@ -329,7 +334,8 @@ int setting_reset_flight_mode()
 #else
                ret = vconf_set_bool(VCONFKEY_TELEPHONY_FLIGHT_MODE, FALSE);
 #endif
-       } else {
+       }
+       else {
                SETTING_TRACE_ERROR("tel_set_flight_mode error");
        }
 
@@ -340,12 +346,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;
+}
+