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>
31 #define UG_MODULE_API __attribute__ ((visibility("default")))
36 setting_view *__get_connective_view_to_load(service_h service)
39 char *viewtype = NULL;
41 service_get_extra_data(service, "viewtype", &viewtype);
45 SETTING_TRACE("viewtype:%s", viewtype);
47 if (!safeStrCmp(viewtype, "usb")) {
48 return &setting_view_connectivity_usb;
50 return NULL; /* &setting_view_connective_main; */
55 Evas_Object *__get_connective_layout_to_return(service_h service, void *priv)
58 SettingConnectivityUG *connectiveUG = priv;
59 char *viewtype = NULL;
61 service_get_extra_data(service, "viewtype", &viewtype);
65 SETTING_TRACE("viewtype:%s", viewtype);
67 if (!safeStrCmp(viewtype, "usb")) {
68 return connectiveUG->ly_usb;
70 return NULL; /* &setting_view_connective_main; */
75 static void setting_connective_ug_cb_resize(void *data, Evas *e,
76 Evas_Object *obj, void *event_info)
78 SettingConnectivityUG *ad = (SettingConnectivityUG *) data;
79 /* setting_view_update(&setting_view_about_main, ad); */
80 setting_view_update(ad->view_to_load, ad);
83 static void *setting_connective_ug_on_create(ui_gadget_h ug,
84 enum ug_mode mode, service_h service,
87 setting_retvm_if((!priv), NULL, "!priv");
89 SettingConnectivityUG *connectiveUG = priv;
90 connectiveUG->ug = ug;
92 connectiveUG->win_main_layout =
93 (Evas_Object *) ug_get_parent_layout(ug);
94 connectiveUG->win_get = (Evas_Object *) ug_get_window();
95 evas_object_show(connectiveUG->win_main_layout);
97 evas_object_evas_get(connectiveUG->win_main_layout);
99 setting_retvm_if(connectiveUG->win_main_layout == NULL, NULL,
100 "cannot get main window ");
103 /* register view node table */
104 setting_view_node_table_intialize();
105 setting_view_node_table_register(&setting_view_connectivity_usb, NULL);
106 setting_view_node_table_register(&setting_view_connectivity_usb_help,
107 &setting_view_connectivity_usb);
109 /* creating a view. */
110 setting_create_Gendial_itc("dialogue/title", &(connectiveUG->itc_title));
111 setting_create_Gendial_itc("dialogue/1text", &(connectiveUG->itc_1text));
112 setting_create_Gendial_itc("dialogue/1text.1icon", &(connectiveUG->itc_1text_1icon));
113 setting_create_Gendial_itc("dialogue/1text.1icon", &(connectiveUG->itc_1text_1icon_gen)); /* toggle */
114 setting_create_Gendial_itc("dialogue/2text.3", &(connectiveUG->itc_2text_3));
115 setting_create_Gendial_itc("dialogue/2text.3/expandable", &(connectiveUG->itc_2text_3_parent));
116 setting_create_Gendial_itc("dialogue/1text.1icon/expandable2", &(connectiveUG->itc_1icon_1text_sub));
117 setting_create_Gendial_itc("multiline/1text", &(connectiveUG->itc_help_style));
119 connectiveUG->itc_seperator.item_style = "dialogue/separator/21/with_line";
120 connectiveUG->itc_seperator.func.text_get = NULL;
121 connectiveUG->itc_seperator.func.content_get = NULL;
122 connectiveUG->itc_seperator.func.state_get = NULL;
123 connectiveUG->itc_seperator.func.del = NULL;
127 connectiveUG->view_to_load = __get_connective_view_to_load(service);
128 setting_retvm_if(NULL == connectiveUG->view_to_load, NULL,
129 "NULL == connectiveUG->view_to_load");
130 setting_view_node_set_cur_view(connectiveUG->view_to_load);
131 setting_view_create(connectiveUG->view_to_load, (void *)connectiveUG);
132 evas_object_event_callback_add(connectiveUG->win_main_layout,
133 EVAS_CALLBACK_RESIZE,
134 setting_connective_ug_cb_resize,
136 return __get_connective_layout_to_return(service, connectiveUG);
139 static void setting_connective_ug_on_start(ui_gadget_h ug, service_h service,
144 static void setting_connective_ug_on_pause(ui_gadget_h ug, service_h service,
149 static void setting_connective_ug_on_resume(ui_gadget_h ug, service_h service,
154 static void setting_connective_ug_on_destroy(ui_gadget_h ug,
155 service_h service, void *priv)
158 setting_retm_if((!priv), "!priv");
159 SettingConnectivityUG *connectiveUG = priv;
161 evas_object_event_callback_del(connectiveUG->win_main_layout, EVAS_CALLBACK_RESIZE, setting_connective_ug_cb_resize); /* fix flash issue for gallery */
162 connectiveUG->ug = ug;
164 /* called when this shared gadget is terminated. similar with app_exit */
165 if (&setting_view_connectivity_usb == connectiveUG->view_to_load) {
166 setting_view_destroy(&setting_view_connectivity_usb_help,
168 setting_view_destroy(&setting_view_connectivity_usb,
172 if (NULL != ug_get_layout(connectiveUG->ug)) {
173 evas_object_hide((Evas_Object *)
174 ug_get_layout(connectiveUG->ug));
175 evas_object_del((Evas_Object *)
176 ug_get_layout(connectiveUG->ug));
179 int ret = check_usb_jack_status();
180 if (ret == USB_CONNECTED) /* USB cable is connected */
182 SETTING_TRACE("USB cable is connected\n");
183 /* If kill_apps_popup is loaded, no btn is pushed when Setting is terminated*/
184 ret = vconf_set_int(VCONFKEY_SETAPPL_SELECT_POPUP_BTN_INT, USB_BTN_NO);
187 SETTING_TRACE("FAIL: vconf_set_int(VCONFKEY_SETAPPL_SELECT_POPUP_BTN_INT)\n");
190 else if (ret == USB_DISCONNECTED) /* USB cable is not connected */
192 SETTING_TRACE("USB cable is not connected\n");
193 set_usb_mode_default();
197 SETTING_TRACE("FAIL: check_usb_jack_status()\n");
202 static void setting_connective_ug_on_message(ui_gadget_h ug, service_h msg,
203 service_h service, void *priv)
208 static void setting_connective_ug_on_event(ui_gadget_h ug,
209 enum ug_event event, service_h service,
214 case UG_EVENT_LOW_MEMORY:
216 case UG_EVENT_LOW_BATTERY:
218 case UG_EVENT_LANG_CHANGE:
220 case UG_EVENT_ROTATE_PORTRAIT:
222 case UG_EVENT_ROTATE_PORTRAIT_UPSIDEDOWN:
224 case UG_EVENT_ROTATE_LANDSCAPE:
226 case UG_EVENT_ROTATE_LANDSCAPE_UPSIDEDOWN:
228 case UG_EVENT_REGION_CHANGE:
235 static void setting_connective_ug_on_key_event(ui_gadget_h ug,
236 enum ug_key_event event,
237 service_h service, void *priv)
240 SettingConnectivityUG *ad = (SettingConnectivityUG *) priv;
243 case UG_KEY_EVENT_END:
245 if (elm_naviframe_top_item_get(ad->navi_bar) ==
246 elm_naviframe_bottom_item_get(ad->navi_bar)) {
249 /* elm_naviframe_item_pop(ad->navi_bar); */
250 setting_view_cb_at_endKey(ad);
259 UG_MODULE_API int UG_MODULE_INIT(struct ug_module_ops *ops)
262 SettingConnectivityUG *connectiveUG =
263 calloc(1, sizeof(SettingConnectivityUG));
264 setting_retvm_if(!connectiveUG, -1,
265 "Create SettingConnectivityUG obj failed");
267 ops->create = setting_connective_ug_on_create;
268 ops->start = setting_connective_ug_on_start;
269 ops->pause = setting_connective_ug_on_pause;
270 ops->resume = setting_connective_ug_on_resume;
271 ops->destroy = setting_connective_ug_on_destroy;
272 ops->message = setting_connective_ug_on_message;
273 ops->event = setting_connective_ug_on_event;
274 ops->key_event = setting_connective_ug_on_key_event;
275 ops->priv = connectiveUG;
276 ops->opt = UG_OPT_INDICATOR_ENABLE;
281 UG_MODULE_API void UG_MODULE_EXIT(struct ug_module_ops *ops)
284 struct SettingConnectivityUG *connectiveUG;
285 setting_retm_if(!ops, "ops == NULL");
287 connectiveUG = ops->priv;
294 UG_MODULE_API int setting_plugin_reset(service_h service, void *priv)
299 char *ug_type = NULL;
301 service_get_extra_data(service, "viewtype", &ug_type);
305 if (0 == safeStrCmp(ug_type, "usb")) {
307 #if SUPPORT_RUN_SYSTEM_COMMAND
308 ret += excuteCmd(SETTING_POSTINST_FILE, 1, "usbconnectivity");
310 ret += vconf_set_int(VCONFKEY_SETAPPL_USB_SEL_MODE_INT, SETTING_USB_SAMSUNG_KIES);
311 /* Resetting VCONFKEY_SETAPPL_USB_MODE_INT (current mode) is not necessary.
312 * If USB cable is removed, the key value is SETTING_USB_NONE_MODE by USB-setting.
313 * If USB cable is connected, the key value is changed by selected mode. */
314 ret += vconf_set_int(VCONFKEY_SETAPPL_USB_IN_MODE_CHANGE, CHANGE_COMPLETE);
323 * This function checks the USB connection status
325 int check_usb_jack_status()
328 bool usb_connection = false;
329 int ret = runtime_info_get_value_bool(RUNTIME_INFO_KEY_USB_CONNECTED, &usb_connection);
330 if (ret == RUNTIME_INFO_ERROR_NONE && usb_connection == true) {
332 return USB_CONNECTED; /* USB is connected */
335 return USB_DISCONNECTED; /* USB is disconnected */
340 * This function sets USB mode to KIES mode
342 void set_usb_mode_default()
347 ret = vconf_set_int(VCONFKEY_SETAPPL_USB_SEL_MODE_INT, SETTING_USB_SAMSUNG_KIES);