4 * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd.
6 * Contact: MyoungJune Park <mj2004.park@samsung.com>
8 * Licensed under the Apache License, Version 2.0 (the "License");
9 * you may not use this file except in compliance with the License.
10 * You may obtain a copy of the License at
12 * http://www.apache.org/licenses/LICENSE-2.0
14 * Unless required by applicable law or agreed to in writing, software
15 * distributed under the License is distributed on an "AS IS" BASIS,
16 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17 * See the License for the specific language governing permissions and
18 * limitations under the License.
23 *@defgroup setting-connectivity
24 *UG creation code for setting-connectivity
27 #include <setting-connectivity.h>
28 #include <setting-cfg.h>
31 #define UG_MODULE_API __attribute__ ((visibility("default")))
37 * This function checks the USB connection status
39 int check_usb_jack_status()
42 bool usb_connection = false;
43 int ret = runtime_info_get_value_bool(RUNTIME_INFO_KEY_USB_CONNECTED, &usb_connection);
44 if (ret == RUNTIME_INFO_ERROR_NONE && usb_connection == true) {
45 return USB_CONNECTED; /* USB is connected */
47 return USB_DISCONNECTED; /* USB is disconnected */
51 setting_view *__get_connective_view_to_load(app_control_h service)
54 char *viewtype = NULL;
56 app_control_get_extra_data(service, "viewtype", &viewtype);
60 SETTING_TRACE("viewtype:%s", viewtype);
62 if (!safeStrCmp(viewtype, "usb")) {
64 return &setting_view_connectivity_usb;
67 return NULL; /* &setting_view_connective_main; */
72 Evas_Object *__get_connective_layout_to_return(app_control_h service, void *priv)
75 SettingConnectivityUG *connectiveUG = priv;
76 char *viewtype = NULL;
78 app_control_get_extra_data(service, "viewtype", &viewtype);
82 SETTING_TRACE("viewtype:%s", viewtype);
84 if (!safeStrCmp(viewtype, "usb")) {
86 return connectiveUG->ly_usb;
89 return NULL; /* &setting_view_connective_main; */
94 static void setting_connective_ug_cb_resize(void *data, Evas *e,
95 Evas_Object *obj, void *event_info)
97 SettingConnectivityUG *ad = (SettingConnectivityUG *) data;
98 /* setting_view_update(&setting_view_about_main, ad); */
99 setting_view_update(ad->view_to_load, ad);
102 static void *setting_connective_ug_on_create(ui_gadget_h ug,
103 enum ug_mode mode, app_control_h service,
106 setting_retvm_if((!priv), NULL, "!priv");
108 SettingConnectivityUG *connectiveUG = priv;
109 connectiveUG->ug = ug;
111 connectiveUG->win_main_layout =
112 (Evas_Object *) ug_get_parent_layout(ug);
113 connectiveUG->win_get = (Evas_Object *) ug_get_window();
114 evas_object_show(connectiveUG->win_main_layout);
116 evas_object_evas_get(connectiveUG->win_main_layout);
118 setting_retvm_if(connectiveUG->win_main_layout == NULL, NULL,
119 "cannot get main window ");
121 setting_set_i18n(SETTING_PACKAGE, SETTING_LOCALEDIR);
123 /* register view node table */
124 setting_view_node_table_intialize();
125 setting_view_node_table_register(&setting_view_connectivity_usb, NULL);
126 setting_view_node_table_register(&setting_view_connectivity_usb_help,
127 &setting_view_connectivity_usb);
129 /* creating a view. */
130 setting_create_Gendial_itc("groupindex", &(connectiveUG->itc_title));
131 setting_create_Gendial_itc("1line", &(connectiveUG->itc_1text));
132 setting_create_Gendial_itc("1line", &(connectiveUG->itc_1text_1icon));
133 setting_create_Gendial_itc("1line", &(connectiveUG->itc_1text_1icon_gen)); /* toggle */
134 setting_create_Gendial_itc("dialogue/2text.3", &(connectiveUG->itc_2text_3));
135 setting_create_Gendial_itc("2line.top", &(connectiveUG->itc_2text_3_parent));
136 setting_create_Gendial_itc("1line", &(connectiveUG->itc_1icon_1text_sub));
137 setting_create_Gendial_itc("multiline_sub", &(connectiveUG->itc_help_style));
139 connectiveUG->view_to_load = __get_connective_view_to_load(service);
140 setting_retvm_if(NULL == connectiveUG->view_to_load, NULL,
141 "NULL == connectiveUG->view_to_load");
142 setting_view_node_set_cur_view(connectiveUG->view_to_load);
143 setting_view_create(connectiveUG->view_to_load, (void *)connectiveUG);
144 evas_object_event_callback_add(connectiveUG->win_main_layout,
145 EVAS_CALLBACK_RESIZE,
146 setting_connective_ug_cb_resize,
148 return __get_connective_layout_to_return(service, connectiveUG);
151 static void setting_connective_ug_on_start(ui_gadget_h ug, app_control_h service,
156 static void setting_connective_ug_on_pause(ui_gadget_h ug, app_control_h service,
161 static void setting_connective_ug_on_resume(ui_gadget_h ug, app_control_h service,
166 static void setting_connective_ug_on_destroy(ui_gadget_h ug,
167 app_control_h service, void *priv)
170 setting_retm_if((!priv), "!priv");
171 SettingConnectivityUG *connectiveUG = priv;
173 evas_object_event_callback_del(connectiveUG->win_main_layout, EVAS_CALLBACK_RESIZE, setting_connective_ug_cb_resize); /* fix flash issue for gallery */
174 connectiveUG->ug = ug;
176 /* called when this shared gadget is terminated. similar with app_exit */
177 if (&setting_view_connectivity_usb == connectiveUG->view_to_load) {
178 setting_view_destroy(&setting_view_connectivity_usb_help,
180 setting_view_destroy(&setting_view_connectivity_usb,
184 if (NULL != ug_get_layout(connectiveUG->ug)) {
185 evas_object_hide((Evas_Object *)
186 ug_get_layout(connectiveUG->ug));
187 evas_object_del((Evas_Object *)
188 ug_get_layout(connectiveUG->ug));
194 static void setting_connective_ug_on_message(ui_gadget_h ug, app_control_h msg,
195 app_control_h service, void *priv)
200 static void setting_connective_ug_on_event(ui_gadget_h ug,
201 enum ug_event event, app_control_h service,
206 case UG_EVENT_LOW_MEMORY:
208 case UG_EVENT_LOW_BATTERY:
210 case UG_EVENT_LANG_CHANGE:
212 case UG_EVENT_ROTATE_PORTRAIT:
214 case UG_EVENT_ROTATE_PORTRAIT_UPSIDEDOWN:
216 case UG_EVENT_ROTATE_LANDSCAPE:
218 case UG_EVENT_ROTATE_LANDSCAPE_UPSIDEDOWN:
220 case UG_EVENT_REGION_CHANGE:
227 static void setting_connective_ug_on_key_event(ui_gadget_h ug,
228 enum ug_key_event event,
229 app_control_h service, void *priv)
232 SettingConnectivityUG *ad = (SettingConnectivityUG *) priv;
235 case UG_KEY_EVENT_END: {
236 if (elm_naviframe_top_item_get(ad->navi_bar) ==
237 elm_naviframe_bottom_item_get(ad->navi_bar)) {
240 /* elm_naviframe_item_pop(ad->navi_bar); */
241 setting_view_cb_at_endKey(ad);
250 UG_MODULE_API int UG_MODULE_INIT(struct ug_module_ops *ops)
253 SettingConnectivityUG *connectiveUG =
254 calloc(1, sizeof(SettingConnectivityUG));
255 setting_retvm_if(!connectiveUG, -1,
256 "Create SettingConnectivityUG obj failed");
258 ops->create = setting_connective_ug_on_create;
259 ops->start = setting_connective_ug_on_start;
260 ops->pause = setting_connective_ug_on_pause;
261 ops->resume = setting_connective_ug_on_resume;
262 ops->destroy = setting_connective_ug_on_destroy;
263 ops->message = setting_connective_ug_on_message;
264 ops->event = setting_connective_ug_on_event;
265 ops->key_event = setting_connective_ug_on_key_event;
266 ops->priv = connectiveUG;
267 ops->opt = UG_OPT_INDICATOR_ENABLE;
272 UG_MODULE_API void UG_MODULE_EXIT(struct ug_module_ops *ops)
275 struct SettingConnectivityUG *connectiveUG;
276 setting_retm_if(!ops, "ops == NULL");
278 connectiveUG = ops->priv;
284 UG_MODULE_API int setting_plugin_search_init(app_control_h service, void *priv,
288 Setting_Cfg_Node_T *node;
289 Eina_List **pplist = priv;
290 const Setting_Cfg_Node_T search_configs[] = {
291 {DEVOPTION_STR_USB_DEBUGGING, NULL, NULL, 0, Cfg_Item_unResetable, 0, Cfg_Item_View_Node, NULL, NULL, NULL, NULL},
292 {DEVOPTION_STR_SHOW_CPU_USAGE, NULL, NULL, 0, Cfg_Item_unResetable, 0, Cfg_Item_View_Node, NULL, NULL, NULL, NULL},
293 {DEVOPTION_STR_RENDERTING_ENGINE, NULL, NULL, 0, Cfg_Item_unResetable, 0, Cfg_Item_View_Node, NULL, NULL, NULL, NULL},
294 {DEVOPTION_STR_LIMIT_BACKGROUND_PRECESS, NULL, NULL, 0, Cfg_Item_unResetable, 0, Cfg_Item_View_Node, NULL, NULL, NULL, NULL},
295 {DEVOPTION_STR_CRASH_VIEWER, NULL, NULL, 0, Cfg_Item_unResetable, 0, Cfg_Item_View_Node, NULL, NULL, NULL, NULL}
298 retv_if(NULL == priv, SETTING_GENERAL_ERR_NULL_DATA_PARAMETER);
299 retv_if(NULL == applocale, SETTING_GENERAL_ERR_NULL_DATA_PARAMETER);
301 *applocale = strdup("setting:/usr/apps/org.tizen.setting/res/locale");
303 size = sizeof(search_configs) / sizeof(Setting_Cfg_Node_T);
305 for (i = 0; i < size; i++) {
306 node = setting_plugin_search_item_subindex_add(
307 search_configs[i].key_name,
310 search_configs[i].item_type,
311 search_configs[i].data,
312 "Developer options");
314 *pplist = eina_list_append(*pplist, node);