tizen 2.3 release
[apps/home/settings.git] / setting-connectivity / src / setting-connectivity.c
index db6fa0a..3ce1e2e 100755 (executable)
@@ -1,18 +1,22 @@
 /*
  * 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.
+ *
  */
 
 /**
@@ -21,7 +25,7 @@
  */
 
 #include <setting-connectivity.h>
-#include <devman.h>
+#include <setting-cfg.h>
 
 #ifndef UG_MODULE_API
 #define UG_MODULE_API __attribute__ ((visibility("default")))
 
 #define USB_BTN_NO     0
 
-setting_view *__get_connective_view_to_load(service_h service)
+/**
+  * This function checks the USB connection status
+  */
+int check_usb_jack_status()
+{
+       SETTING_TRACE_BEGIN;
+       bool usb_connection = false;
+       int ret = runtime_info_get_value_bool(RUNTIME_INFO_KEY_USB_CONNECTED, &usb_connection);
+       if (ret == RUNTIME_INFO_ERROR_NONE && usb_connection == true) {
+               return USB_CONNECTED;   /*  USB is connected */
+       } else {
+               return USB_DISCONNECTED;       /*  USB is disconnected */
+       }
+}
+
+setting_view *__get_connective_view_to_load(app_control_h service)
 {
        SETTING_TRACE_BEGIN;
        char *viewtype = NULL;
 
-       service_get_extra_data(service, "viewtype", &viewtype);
+       app_control_get_extra_data(service, "viewtype", &viewtype);
        if(!viewtype)
                return NULL;
 
        SETTING_TRACE("viewtype:%s", viewtype);
 
        if (!safeStrCmp(viewtype, "usb")) {
+               FREE(viewtype);
                return &setting_view_connectivity_usb;
        } else {
+               FREE(viewtype);
                return NULL;    /* &setting_view_connective_main; */
        }
 
 }
 
-Evas_Object *__get_connective_layout_to_return(service_h service, void *priv)
+Evas_Object *__get_connective_layout_to_return(app_control_h service, void *priv)
 {
        SETTING_TRACE_BEGIN;
        SettingConnectivityUG *connectiveUG = priv;
        char *viewtype = NULL;
 
-       service_get_extra_data(service, "viewtype", &viewtype);
+       app_control_get_extra_data(service, "viewtype", &viewtype);
        if(!viewtype)
                return NULL;
 
        SETTING_TRACE("viewtype:%s", viewtype);
 
        if (!safeStrCmp(viewtype, "usb")) {
+               FREE(viewtype);
                return connectiveUG->ly_usb;
        } else {
+               FREE(viewtype);
                return NULL;    /* &setting_view_connective_main; */
        }
 
@@ -77,7 +100,7 @@ static void setting_connective_ug_cb_resize(void *data, Evas *e,
 }
 
 static void *setting_connective_ug_on_create(ui_gadget_h ug,
-                                            enum ug_mode mode, service_h service,
+                                            enum ug_mode mode, app_control_h service,
                                             void *priv)
 {
        setting_retvm_if((!priv), NULL, "!priv");
@@ -104,22 +127,14 @@ static void *setting_connective_ug_on_create(ui_gadget_h ug,
                                         &setting_view_connectivity_usb);
 
        /*  creating a view. */
-       setting_create_Gendial_itc("dialogue/title", &(connectiveUG->itc_title));
-       setting_create_Gendial_itc("dialogue/1text", &(connectiveUG->itc_1text));
-       setting_create_Gendial_itc("dialogue/1text.1icon", &(connectiveUG->itc_1text_1icon));
-       setting_create_Gendial_itc("dialogue/1text.1icon", &(connectiveUG->itc_1text_1icon_gen));       /* toggle */
+       setting_create_Gendial_itc("groupindex", &(connectiveUG->itc_title));
+       setting_create_Gendial_itc("1line", &(connectiveUG->itc_1text));
+       setting_create_Gendial_itc("1line", &(connectiveUG->itc_1text_1icon));
+       setting_create_Gendial_itc("1line", &(connectiveUG->itc_1text_1icon_gen));      /* toggle */
        setting_create_Gendial_itc("dialogue/2text.3", &(connectiveUG->itc_2text_3));
-       setting_create_Gendial_itc("dialogue/2text.3/expandable", &(connectiveUG->itc_2text_3_parent));
-       setting_create_Gendial_itc("dialogue/1text.1icon/expandable2", &(connectiveUG->itc_1icon_1text_sub));
-       setting_create_Gendial_itc("multiline/1text", &(connectiveUG->itc_help_style));
-
-       connectiveUG->itc_seperator.item_style = "dialogue/separator";
-       connectiveUG->itc_seperator.func.text_get = NULL;
-       connectiveUG->itc_seperator.func.content_get = NULL;
-       connectiveUG->itc_seperator.func.state_get = NULL;
-       connectiveUG->itc_seperator.func.del = NULL;
-
-
+       setting_create_Gendial_itc("2line.top", &(connectiveUG->itc_2text_3_parent));
+       setting_create_Gendial_itc("1line", &(connectiveUG->itc_1icon_1text_sub));
+       setting_create_Gendial_itc("multiline_sub", &(connectiveUG->itc_help_style));
 
        connectiveUG->view_to_load = __get_connective_view_to_load(service);
        setting_retvm_if(NULL == connectiveUG->view_to_load, NULL,
@@ -133,23 +148,23 @@ static void *setting_connective_ug_on_create(ui_gadget_h ug,
        return __get_connective_layout_to_return(service, connectiveUG);
 }
 
-static void setting_connective_ug_on_start(ui_gadget_h ug, service_h service,
+static void setting_connective_ug_on_start(ui_gadget_h ug, app_control_h service,
                                           void *priv)
 {
 }
 
-static void setting_connective_ug_on_pause(ui_gadget_h ug, service_h service,
+static void setting_connective_ug_on_pause(ui_gadget_h ug, app_control_h service,
                                           void *priv)
 {
 }
 
-static void setting_connective_ug_on_resume(ui_gadget_h ug, service_h service,
+static void setting_connective_ug_on_resume(ui_gadget_h ug, app_control_h service,
                                            void *priv)
 {
 }
 
 static void setting_connective_ug_on_destroy(ui_gadget_h ug,
-                                            service_h service, void *priv)
+                                            app_control_h service, void *priv)
 {
        SETTING_TRACE_BEGIN;
        setting_retm_if((!priv), "!priv");
@@ -176,14 +191,14 @@ static void setting_connective_ug_on_destroy(ui_gadget_h ug,
        SETTING_TRACE_END;
 }
 
-static void setting_connective_ug_on_message(ui_gadget_h ug, service_h msg,
-                                            service_h service, void *priv)
+static void setting_connective_ug_on_message(ui_gadget_h ug, app_control_h msg,
+                                            app_control_h service, void *priv)
 {
        SETTING_TRACE_BEGIN;
 }
 
 static void setting_connective_ug_on_event(ui_gadget_h ug,
-                                          enum ug_event event, service_h service,
+                                          enum ug_event event, app_control_h service,
                                           void *priv)
 {
        SETTING_TRACE_BEGIN;
@@ -211,7 +226,7 @@ static void setting_connective_ug_on_event(ui_gadget_h ug,
 
 static void setting_connective_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;
        SettingConnectivityUG *ad = (SettingConnectivityUG *) priv;
@@ -267,29 +282,39 @@ UG_MODULE_API void UG_MODULE_EXIT(struct ug_module_ops *ops)
        }
 }
 
-/*****/
-UG_MODULE_API int setting_plugin_reset(service_h service, void *priv)
+UG_MODULE_API int setting_plugin_search_init(app_control_h service, void *priv,
+               char** applocale)
 {
-       SETTING_TRACE_BEGIN;
-
-       int ret = 0;
-       char *ug_type = NULL;
-
-       service_get_extra_data(service, "viewtype", &ug_type);
-       if(!ug_type)
-               return -1;
-
-       if (0 == safeStrCmp(ug_type, "usb")) {
-               /* usb */
-#if SUPPORT_RUN_SYSTEM_COMMAND
-               ret += excuteCmd(SETTING_POSTINST_FILE, 1, "usbconnectivity");
-#else
-               ret += vconf_set_bool(VCONFKEY_SETAPPL_USB_DEBUG_MODE_BOOL, 0);
-               /* Resetting VCONFKEY_SETAPPL_USB_MODE_INT (current mode) is not necessary.
-                * If USB cable is removed, the key value is SETTING_USB_NONE_MODE by USB-setting.
-                * If USB cable is connected, the key value is changed by selected mode. */
-               ret += vconf_set_int(VCONFKEY_SETAPPL_USB_IN_MODE_CHANGE, CHANGE_COMPLETE);
-#endif
+       int i, size;
+       Setting_Cfg_Node_T *node;
+       Eina_List **pplist = priv;
+       const Setting_Cfg_Node_T search_configs[] = {
+               {DEVOPTION_STR_USB_DEBUGGING, NULL, NULL, 0, Cfg_Item_unResetable, 0, Cfg_Item_View_Node, NULL, NULL, NULL, NULL},
+               {DEVOPTION_STR_SHOW_CPU_USAGE, NULL, NULL, 0, Cfg_Item_unResetable, 0, Cfg_Item_View_Node, NULL, NULL, NULL, NULL},
+               {DEVOPTION_STR_RENDERTING_ENGINE, NULL, NULL, 0, Cfg_Item_unResetable, 0, Cfg_Item_View_Node, NULL, NULL, NULL, NULL},
+               {DEVOPTION_STR_LIMIT_BACKGROUND_PRECESS, NULL, NULL, 0, Cfg_Item_unResetable, 0, Cfg_Item_View_Node, NULL, NULL, NULL, NULL},
+               {DEVOPTION_STR_CRASH_VIEWER, NULL, NULL, 0, Cfg_Item_unResetable, 0, Cfg_Item_View_Node, NULL, NULL, NULL, NULL}
+       };
+
+       retv_if(NULL == priv, SETTING_GENERAL_ERR_NULL_DATA_PARAMETER);
+       retv_if(NULL == applocale, SETTING_GENERAL_ERR_NULL_DATA_PARAMETER);
+
+       *applocale = strdup("setting:/usr/apps/org.tizen.setting/res/locale");
+
+       size = sizeof(search_configs)/sizeof(Setting_Cfg_Node_T);
+
+       for ( i = 0; i < size; i++ )
+       {
+               node = setting_plugin_search_item_subindex_add(
+                                       search_configs[i].key_name,
+                                       "viewtype:usb",
+                                       IMG_USBconnection,
+                                       search_configs[i].item_type,
+                                       search_configs[i].data,
+                                       "Developer options");
+
+               *pplist = eina_list_append(*pplist, node);
        }
-       return ret;
+       return 0;
 }
+