fix for applying wayland (removing X)
[apps/home/settings.git] / src / setting-handler.c
1 #include <setting-handler.h>
2 #include <setting-helper.h>
3
4 #include <wifi.h>
5 #include <bluetooth.h>
6 #include <bluetooth_internal.h>
7 #include <dbus/dbus.h>
8 #include <app_control_internal.h>
9
10
11 static Setting_GenGroupItem_Data *__mobileap_handler(void *data, char *keyStr, char *icon_path, char *ug_args, Evas_Object *genlist, Elm_Object_Item *parent)
12 {
13         /*SETTING_TRACE_BEGIN; */
14         setting_main_appdata *ad = (setting_main_appdata *)data;
15
16         ad->data_mobileApp = setting_create_Gendial_field_groupitem(genlist,
17                                                                     &(ad->itc[GENDIAL_Type_1text_1icon_2]),
18                                                                     parent,
19                                                                     setting_main_click_list_ex_ug_cb,
20                                                                     ug_args,
21                                                                     SWALLOW_Type_INVALID,
22                                                                     icon_path,
23                                                                     NULL,
24                                                                     0,
25                                                                     keyStr,
26                                                                     NULL,
27                                                                     NULL);
28         __BACK_POINTER_SET(ad->data_mobileApp);
29         if (ad->data_mobileApp) {
30                 ad->data_mobileApp->userdata = ad;
31         }
32
33         return ad->data_mobileApp;
34 }
35
36 static Setting_GenGroupItem_Data *__backlight_time_handler(void *data, char *keyStr, char *icon_path, char *ug_args, Evas_Object *genlist, Elm_Object_Item *parent)
37 {
38         SETTING_TRACE_BEGIN;
39         setting_main_appdata *ad = (setting_main_appdata *)data;
40         Setting_GenGroupItem_Data *obj = NULL;
41
42         char *pa_backlight = get_pa_backlight_time_str();
43         obj = setting_create_Gendial_field_groupitem(genlist,
44                                                      &(ad->itc[GENDIAL_Type_1icon_2text]),
45                                                      parent,
46                                                      setting_main_click_list_ex_ug_cb,
47                                                      ug_args,
48                                                      SWALLOW_Type_INVALID,
49                                                      icon_path,
50                                                      NULL,
51                                                      0,
52                                                      keyStr,
53                                                      pa_backlight,
54                                                      NULL);
55         G_FREE(pa_backlight);
56         __BACK_POINTER_SET(obj);
57         if (obj) {
58                 obj->userdata = ad;
59                 ad->data_backlight = obj;
60         }
61
62         return obj;
63 }
64
65 static Setting_GenGroupItem_Data *__developer_option_handler(void *data, char *keyStr, char *icon_path, char *ug_args, Evas_Object *genlist, Elm_Object_Item *parent)
66 {
67         SETTING_TRACE_BEGIN;
68         setting_main_appdata *ad = (setting_main_appdata *)data;
69         Setting_GenGroupItem_Data *obj = NULL;
70 #ifdef BINARY_RELEASE_TYPE_ENG
71         /*for eng binary: always show <developer option>*/
72         obj = setting_create_Gendial_field_groupitem(genlist,
73                                                      &(ad->itc[GENDIAL_Type_1text_1icon_2]),
74                                                      parent,
75                                                      setting_main_click_list_ex_ug_cb,
76                                                      ug_args,
77                                                      SWALLOW_Type_INVALID,
78                                                      icon_path,
79                                                      NULL, 0,
80                                                      keyStr,
81                                                      NULL,
82                                                      NULL);
83
84 #else
85         /*for user binary: need to check develop_option_state vconf value*/
86         int dev_op_state = 0;
87         int ret = 0;
88         ret = vconf_get_bool(VCONFKEY_SETAPPL_DEVELOPER_OPTION_STATE, &dev_op_state);
89         if (ret != 0) {
90                 SETTING_TRACE_ERROR("Failed to ger vconf value %d", ret);
91         }
92         if (dev_op_state) {
93                 obj = setting_create_Gendial_field_groupitem(genlist,
94                                                              &(ad->itc[GENDIAL_Type_1text_1icon_2]),
95                                                              parent,
96                                                              setting_main_click_list_ex_ug_cb,
97                                                              ug_args,
98                                                              SWALLOW_Type_INVALID,
99                                                              icon_path,
100                                                              NULL, 0,
101                                                              keyStr,
102                                                              NULL,
103                                                              NULL);
104         } else {
105                 SETTING_TRACE("dev_op_state is 0");
106         }
107 #endif
108         return obj;
109 }
110
111 static Setting_GenGroupItem_Data *__default_handler(void *data, char *keyStr, char *icon_path, char *ug_args, Evas_Object *genlist, Elm_Object_Item *parent)
112 {
113         /*SETTING_TRACE_BEGIN; */
114         setting_main_appdata *ad = (setting_main_appdata *)data;
115         Setting_GenGroupItem_Data *obj = setting_create_Gendial_field_groupitem(genlist,
116                                                                                 &(ad->itc[GENDIAL_Type_1text_1icon_2]),
117                                                                                 parent,
118                                                                                 setting_main_click_list_ex_ug_cb,
119                                                                                 ug_args,
120                                                                                 SWALLOW_Type_INVALID,
121                                                                                 icon_path,
122                                                                                 NULL, 0,
123                                                                                 keyStr,
124                                                                                 NULL,
125                                                                                 NULL);
126
127         return obj;
128 }
129
130 /*//////////////////////////////////////////////////////////////////////////////////////////// */
131 /* list handler */
132 static mainlist_entry mainlist_table[] = {
133         {KeyStr_FlightMode,     __default_handler, UG_HANDLE, NULL},                    /* 0 --> NOT UG */
134         {KeyStr_WiFi,                   __default_handler, UI_PROC, NULL},                              /* 1 --> UG */
135         {KeyStr_Bluetooth,              __default_handler, UI_PROC, NULL},
136         {KeyStr_MobileAP,               __mobileap_handler, UG_HANDLE, NULL},                   /* 1 --> UG */
137         {KeyStr_Location,               __default_handler, UI_PROC, NULL},                              /* 1 --> UG */
138         {KeyStr_Network,                __default_handler, UG_HANDLE, NULL},                            /* 1 --> UG */
139         {KeyStr_DeveloperOption, __developer_option_handler, UI_PROC, NULL},
140         {KeyStr_BacklightTime, __backlight_time_handler, UI_PROC, NULL},
141         {"Default",                     __default_handler, DEFAULT_UI, NULL},                           /* 1 --> UG */
142         /*-------------------------------------------------------------- */
143         {NULL, NULL, ERROR_STATE, NULL},
144 };
145
146 /*----------------------------------------------------------------------------------------- */
147 /* hash table utility */
148 static void __list_hash_free_cb(void *obj)
149 {
150         SETTING_TRACE_BEGIN;
151         /*const char *name = key; */
152         /*const char *number = data; */
153         /*printf("%s: %s\n", name, number); */
154
155 }
156
157 /* hash table utility */
158 void settinig_drawer_hash_init(void *cb)
159 {
160         SETTING_TRACE_BEGIN;
161
162         setting_main_appdata *ad = (setting_main_appdata *) cb;
163         eina_init();
164
165         mainlist_entry *pnode = NULL;
166         ad->main_list_hash = eina_hash_string_superfast_new(__list_hash_free_cb);
167
168         for (pnode = &mainlist_table[0]; pnode->title != NULL; pnode++) {
169                 eina_hash_add(ad->main_list_hash , pnode->title, pnode);
170                 /*SETTING_TRACE("init and add data to hash : %s ", pnode->title); */
171         }
172 }
173
174 /* hash table utility */
175 mainlist_entry *settinig_drawer_hash_find(void *cb, char *search_str)
176 {
177         /*SETTING_TRACE_BEGIN; */
178         /*SETTING_TRACE("------------------ HASH SEARCH ----------------------, %s", search_str); */
179         setting_main_appdata *ad = (setting_main_appdata *) cb;
180         mainlist_entry *pnode = NULL;
181
182         pnode = eina_hash_find(ad->main_list_hash, search_str);
183         return pnode;   /* statically allocated */
184 }
185 /*----------------------------------------------------------------------------------------- */
186
187
188 /* ***************************************************
189  *
190  *call back func
191  *
192  ***************************************************/
193
194
195 /* obj is the layout clicked */
196 void
197 setting_main_click_list_item_ug_cb(void *data, Evas_Object *obj,
198                                    char *ug_to_load, app_control_h svc,
199                                    struct ug_cbs *cbs)
200 {
201         SETTING_TRACE_BEGIN;
202         setting_main_appdata *ad = (setting_main_appdata *) data;
203         if (!ug_to_load) {
204                 setting_create_simple_popup(ad, ad->win_main, NULL, NO_UG_FOUND_MSG);
205                 return;
206         }
207         SETTING_TRACE("to create libug-%s.so", ug_to_load);
208         elm_object_tree_focus_allow_set(ad->ly_main, EINA_FALSE);
209
210         /*setting_conformant_keypad_state(ad->win_main, TRUE); */
211         ad->ug = setting_ug_create(NULL, ug_to_load, UG_MODE_FULLVIEW, svc, cbs);
212         if (ad->ug) {
213                 ad->isInUGMode = TRUE;
214         } else {
215                 elm_object_tree_focus_allow_set(ad->ly_main, EINA_TRUE);
216                 evas_object_show(ad->ly_main);
217                 /*don't going to access globle var errno */
218                 /*SETTING_TRACE_ERROR("errno:%d", errno); */
219                 /*SETTING_TRACE_ERROR("Failed to load /usr/ug/lib/libug-%s.so", ug_to_load); */
220                 /*SETTING_TRACE_ERROR("Failed to load lib-%s.so", ug_to_load); */
221                 setting_create_simple_popup(ad, ad->win_main, NULL, NO_UG_FOUND_MSG);
222         }
223 }
224
225 void setting_main_click_list_ex_ug_cb(void *data, Evas_Object *obj,
226                                       void *event_info)
227 {
228         SETTING_TRACE_BEGIN;
229         retm_if(event_info == NULL, "Invalid argument: event info is NULL");
230         Elm_Object_Item *item = (Elm_Object_Item *) event_info;
231
232         elm_genlist_item_selected_set(item, EINA_FALSE);
233
234
235         SETTING_TRACE("g_main_ad->isInUGMode:%d", g_main_ad->isInUGMode);
236         SETTING_TRACE("g_main_ad->ug:%p", g_main_ad->ug);
237         if (g_main_ad->isInUGMode && g_main_ad->ug) {
238                 SETTING_TRACE
239                 ("[ad->ug non-NULL]skip genlist click event!!");
240
241                 /*SETTING_TRACE_END; */
242                 return;
243         }
244
245         setting_main_appdata *ad = g_main_ad;
246
247         /*  if UG is created by Setting app, setting_main_click_list_ex_ug_cb is diabled. */
248         if (ad->isInUGMode) {
249                 SETTING_TRACE("isInUGMode : TRUE - another UG is running now.");
250                 ad->isInUGMode = FALSE;
251                 /*SETTING_TRACE_END; */
252                 return;
253         } else {
254                 SETTING_TRACE
255                 ("isInUGMode : FALSE - another UG is NOT running now.")
256         }
257
258         Setting_GenGroupItem_Data *selected_item_data =
259             (Setting_GenGroupItem_Data *) elm_object_item_data_get(item);
260         setting_retm_if(NULL == selected_item_data, "selected_item_data is NULL");
261         setting_main_click_list_item_reset_data(ad, obj);
262         const char *item_name = _(selected_item_data->keyStr);
263         SETTING_TRACE("item_name:%s", item_name);
264         ret_if(!item_name);
265
266         if (!safeStrCmp(selected_item_data->keyStr, KeyStr_Call)
267             || !safeStrCmp(selected_item_data->keyStr, KeyStr_WiFi)
268             || !safeStrCmp(selected_item_data->keyStr, KeyStr_Location)
269             || !safeStrCmp(selected_item_data->keyStr, KeyStr_Bluetooth)
270             || !safeStrCmp(selected_item_data->keyStr, KeyStr_MobileAP)
271             || !safeStrCmp(selected_item_data->keyStr, KeyStr_WiFiDirect)
272             || !safeStrCmp(selected_item_data->keyStr, KeyStr_Wallpaper)
273             || !safeStrCmp(selected_item_data->keyStr, KeyStr_Accessibility)
274            ) {
275                 if (app_launcher(data) == 0) {
276                         ad->event_freeze_timer = ecore_timer_add(1, setting_main_freeze_event_timer_cb, ad);
277                         evas_object_freeze_events_set(ad->navibar_main, EINA_TRUE);
278                 }
279                 int click_times = setting_cfg_get_click_times(selected_item_data->keyStr);
280                 setting_cfg_set_click_times(selected_item_data->keyStr, ++click_times);
281                 return;
282         }
283
284         /*2.Quick command cannot work when TTS on */
285         int tts_state = 0;
286         vconf_get_bool(VCONFKEY_SETAPPL_ACCESSIBILITY_TTS, &tts_state);
287         if (tts_state) {
288                 if (!safeStrCmp(selected_item_data->keyStr, KeyStr_QUICK_CMD)) {
289                         char noti_str[MAX_SPECIALIZITION_LEN + 1] = { 0, };
290                         snprintf(noti_str, sizeof(noti_str), _(FEATURE_UNAVALIABLE_WHILE_TTS_ON), _(KeyStr_QUICK_CMD));
291                         setting_create_popup_without_btn(NULL, ad->win_main, NULL, _(noti_str),
292                                                          NULL, 0.0, TRUE, FALSE);
293                         return;
294                 }
295         }
296
297         struct ug_cbs *cbs = (struct ug_cbs *)calloc(1, sizeof(struct ug_cbs));
298         setting_retm_if(!cbs, "calloc failed");
299         cbs->layout_cb = setting_main_layout_ug_cb;
300         cbs->result_cb = setting_main_result_ug_cb;
301         cbs->destroy_cb = setting_main_destroy_ug_cb;
302         cbs->priv = (void *)ad;
303
304         char *path = get_ug_path_from_ug_args(data);
305         app_control_h svc = get_bundle_from_ug_args(data);
306         setting_main_click_list_item_ug_cb(ad, obj, path, svc, cbs);
307         if (path) {
308                 FREE(path);
309         }
310         if (cbs) {
311                 FREE(cbs);
312         }
313         path = NULL;
314         cbs = NULL;
315         app_control_destroy(svc);
316
317 }
318
319 void setting_main_list_mouse_up_cb(void *data, Evas_Object *eo,
320                                    void *event_info)
321 {
322         /*SETTING_TRACE_BEGIN; */
323         retm_if(data == NULL, "Data parameter is NULL");
324         Setting_GenGroupItem_Data *list_item =
325             (Setting_GenGroupItem_Data *) data;
326         SETTING_TRACE("process item [%s]", list_item->keyStr);
327         list_item->chk_status = elm_check_state_get(eo);        /* for update new state */
328
329         SETTING_TRACE("change radio[%s], status is:%d", _(list_item->keyStr),
330                       list_item->chk_status);
331         setting_main_appdata *ad = g_main_ad;
332
333         if (!safeStrCmp(KeyStr_UsePacketData, list_item->keyStr)) {
334                 int err;
335                 if (elm_check_state_get(eo)) {
336                         setting_set_bool_slp_key
337                         (BOOL_SLP_SETTING_USE_PACKET_DATA,
338                          1, &err);
339                 } else {
340                         setting_set_bool_slp_key
341                         (BOOL_SLP_SETTING_USE_PACKET_DATA,
342                          0, &err);
343                 }
344         }
345         return;
346 }
347
348
349
350
351 #if SUPPORT_TETHERING
352 static void ___wifi_activated_cb(wifi_error_e result, void *user_data)
353 {
354         SETTING_TRACE_BEGIN;
355         if (result == WIFI_ERROR_NONE) {
356                 SETTING_TRACE("Wi-Fi Activation Succeeded");
357         } else {
358                 SETTING_TRACE("Wi-Fi Activation Failed! error : %d", result);
359         }
360
361         (void)wifi_deinitialize();
362 }
363
364 static void __tethering_disabled_cb(tethering_error_e error, tethering_type_e type, tethering_disabled_cause_e code, void *data)
365 {
366         int ret;
367
368         if (data) {
369                 tethering_h th = (tethering_h)data;
370                 tethering_destroy(th);
371         }
372
373         ret = wifi_initialize();
374         setting_retm_if(ret < 0, "*** [ERR] wifi_initialize() ***");
375
376         ret = wifi_activate(___wifi_activated_cb, NULL);
377         if (ret < 0) {
378                 SETTING_TRACE_ERROR("*** [ERR] wifi_activate() ***");
379                 (void)wifi_deinitialize();
380                 return;
381         }
382 }
383 #endif
384
385 static Eina_Bool __wifi_timeout(void *data)
386 {
387         /*SETTING_TRACE_BEGIN; */
388         retvm_if(!data, ECORE_CALLBACK_CANCEL, "Invalid argument: data is NULL");
389         Setting_GenGroupItem_Data *list_item = data;
390         setting_retm_if(NULL == list_item, "list_item is NULL");
391         int status, err;
392         setting_get_int_slp_key(INT_SLP_SETTING_WIFI_STATUS, &status, &err);
393         SETTING_TRACE("value:%d", status);
394
395         int i;
396         for (i = VIEW_All_List; i < VIEW_Max; i++) {
397                 list_item = g_main_ad->gl_data_item[i][GL_WiFi];
398                 if (list_item) {
399                         list_item->chk_status = status;
400                         list_item->swallow_type = SWALLOW_Type_1ICON_1RADIO;
401                         elm_object_item_data_set(list_item->item, list_item);
402                         elm_genlist_item_update(list_item->item);
403                 }
404         }
405
406         if (list_item) {
407                 setting_main_appdata *ad = list_item->userdata;
408                 ad->wifi_timer = NULL;
409         }
410
411         return ECORE_CALLBACK_CANCEL;
412 }
413
414 #if SUPPORT_TETHERING
415 static void __tethering_turn_off_resp_cb(void *data, Evas_Object *obj, void *event_info)
416 {
417         setting_retm_if(NULL == obj, "NULL == obj");
418         int response_type = btn_type(obj);
419         Setting_GenGroupItem_Data *list_item = (Setting_GenGroupItem_Data *)data;
420
421         if (g_main_ad) {
422                 evas_object_del(g_main_ad->popup_wifi_mode);
423                 g_main_ad->popup_wifi_mode = NULL;
424         }
425
426         int i = 0;
427         Setting_GenGroupItem_Data *update_item = NULL;
428         if (POPUP_RESPONSE_OK == response_type) {
429                 /*add timeout strategy.. */
430                 ret_if(!list_item->userdata);
431                 setting_main_appdata *ad = list_item->userdata;
432                 if (ad->wifi_timer) {
433                         ecore_timer_del(ad->wifi_timer);
434                         ad->wifi_timer = NULL;
435                 }
436                 ad->wifi_timer = ecore_timer_add(5.0, (Ecore_Task_Cb) __wifi_timeout, list_item);
437
438 /*#if SUPPORT_TETHERING*/
439                 int type = tethering_is_enabled(NULL, TETHERING_TYPE_WIFI) ? TETHERING_TYPE_WIFI : TETHERING_TYPE_WIFI_AP;
440
441                 tethering_h th = NULL;
442                 tethering_error_e ret = TETHERING_ERROR_NONE;
443
444                 ret = tethering_create(&th);
445                 if (ret != TETHERING_ERROR_NONE) {
446                         for (i = VIEW_All_List; i < VIEW_Max; i++) {
447                                 update_item = ad->gl_data_item[i][GL_WiFi];
448                                 if (update_item) {
449                                         update_item->chk_status = EINA_FALSE;
450                                         update_item->swallow_type = SWALLOW_Type_1ICON_1RADIO;
451                                         elm_object_item_data_set(update_item->item, update_item);
452                                         elm_genlist_item_update(update_item->item);
453                                 }
454                         }
455                 }
456
457                 ret = tethering_set_disabled_cb(th, type, __tethering_disabled_cb, th);
458                 if (ret != TETHERING_ERROR_NONE) {
459                         for (i = VIEW_All_List; i < VIEW_Max; i++) {
460                                 update_item = ad->gl_data_item[i][GL_WiFi];
461                                 if (update_item) {
462                                         update_item->chk_status = EINA_FALSE;
463                                         update_item->swallow_type = SWALLOW_Type_1ICON_1RADIO;
464                                         elm_object_item_data_set(update_item->item, update_item);
465                                         elm_genlist_item_update(update_item->item);
466                                 }
467                         }
468
469                         tethering_destroy(th);
470                         return;
471                 }
472
473                 (void) tethering_disable(th, type);
474 /*#endif*/
475         } else if (POPUP_RESPONSE_CANCEL == response_type) {
476                 for (i = VIEW_All_List; i < VIEW_Max; i++) {
477                         update_item = g_main_ad->gl_data_item[i][GL_WiFi];
478                         if (update_item) {
479                                 update_item->chk_status = EINA_FALSE;
480                                 update_item->swallow_type = SWALLOW_Type_1ICON_1RADIO;
481                                 elm_object_item_data_set(update_item->item, update_item);
482                                 elm_genlist_item_update(update_item->item);
483                         }
484                 }
485         }
486 }
487 #endif
488
489
490 void __alternate_wifi_mode(Setting_GenGroupItem_Data *list_item, Evas_Object *check)
491 {
492         /*SETTING_TRACE_BEGIN; */
493         /*int ret; */
494         Eina_Bool status =  elm_check_state_get(check);
495         SETTING_TRACE("wifi mode status : %d", status);
496
497         /*int value, err; */
498         int i = 0;
499         Setting_GenGroupItem_Data *item_to_update = NULL;
500
501 #if SUPPORT_TETHERING
502         if (tethering_is_enabled(NULL, TETHERING_TYPE_WIFI)
503             || tethering_is_enabled(NULL, TETHERING_TYPE_WIFI_AP)) {
504                 for (i = VIEW_All_List; i < VIEW_Max; i++) {
505                         item_to_update = g_main_ad->gl_data_item[i][GL_WiFi];
506                         if (item_to_update) {
507                                 item_to_update->swallow_type = SWALLOW_Type_1ICON_1PROCESS;
508                                 elm_object_item_data_set(item_to_update->item, item_to_update);
509                                 elm_genlist_item_fields_update(item_to_update->item, "elm.icon.2", ELM_GENLIST_ITEM_FIELD_CONTENT);
510                         }
511                 }
512
513                 g_main_ad->popup_wifi_mode = setting_create_popup_with_btn(list_item,
514                                                                            g_main_ad->win_main, NULL,
515                                                                            "IDS_MOBILEAP_POP_TURNING_ON_WI_FI_WILL_DISABLE_MOBILE_HOTSPOT_CONTINUE_Q_VZW",
516                                                                            __tethering_turn_off_resp_cb,
517                                                                            0, 2, "IDS_ST_BUTTON_OK", "IDS_ST_BUTTON_CANCEL_ABB");
518         } else
519 #endif
520         {
521                 int wifi_state = VCONFKEY_WIFI_OFF;
522                 vconf_get_int(VCONFKEY_WIFI_STATE, &wifi_state);
523                 DBusMessageIter iter;
524                 DBusMessage *message = NULL;
525                 DBusConnection *connection = NULL;
526                 SETTING_TRACE("status:%d", status);
527                 if (status) {
528                         if (wifi_state != VCONFKEY_WIFI_OFF) {
529                                 /* Wi-Fi is enabled */
530                                 SETTING_TRACE("Wi-Fi is already enabled");
531                                 return ;
532                         }
533                         connection = dbus_bus_get(DBUS_BUS_SYSTEM, NULL);
534                         if (connection == NULL) {
535                                 SETTING_TRACE_ERROR("Failed to get system bus");
536                                 return;
537                         }
538
539                         message = dbus_message_new_method_call(NETCONFIG_SERVICE, NETCONFIG_WIFI_PATH,
540                                                                NETCONFIG_WIFI_INTERFACE, "LoadDriver");
541                         if (message == NULL) {
542                                 SETTING_TRACE_ERROR("Failed DBus method call");
543                                 dbus_connection_unref(connection);
544                                 return ;
545                         }
546
547                         g_main_ad->wifi_op = OP_WIFI_TURNING_ON;
548
549                         dbus_message_iter_init_append(message, &iter);
550                         dbus_bool_t val = FALSE;
551                         dbus_message_iter_append_basic(&iter, DBUS_TYPE_BOOLEAN, &val);
552
553                         dbus_connection_send_with_reply(connection, message, NULL, 10000);
554
555                         dbus_message_unref(message);
556                         dbus_connection_unref(connection);
557
558                 } else {
559                         if (wifi_state == VCONFKEY_WIFI_OFF) {
560                                 /* Wi-Fi is disabled */
561                                 SETTING_TRACE("Wi-Fi is already disabled");
562                                 return ;
563                         }
564
565                         connection = dbus_bus_get(DBUS_BUS_SYSTEM, NULL);
566                         if (connection == NULL) {
567                                 SETTING_TRACE_ERROR("Failed to get system bus");
568                                 return;
569                         }
570
571                         message = dbus_message_new_method_call(NETCONFIG_SERVICE, NETCONFIG_WIFI_PATH,
572                                                                NETCONFIG_WIFI_INTERFACE, "RemoveDriver");
573                         if (message == NULL) {
574                                 SETTING_TRACE_ERROR("Failed DBus method call");
575                                 dbus_connection_unref(connection);
576                                 return;
577                         }
578                         g_main_ad->wifi_op = OP_WIFI_TURNING_OFF;
579
580                         dbus_connection_send_with_reply(connection, message, NULL, 10000);
581
582                         dbus_message_unref(message);
583                         dbus_connection_unref(connection);
584
585                 }
586
587                 for (i = VIEW_All_List; i < VIEW_Max; i++) {
588                         item_to_update = g_main_ad->gl_data_item[i][GL_WiFi];
589                         if (item_to_update) {
590                                 item_to_update->swallow_type = SWALLOW_Type_1ICON_1PROCESS;
591                                 elm_object_item_data_set(item_to_update->item, item_to_update);
592                                 elm_genlist_item_fields_update(item_to_update->item, "elm.icon.2", ELM_GENLIST_ITEM_FIELD_CONTENT);
593
594                         }
595                 }
596
597                 /*add timeout strategy.. */
598                 ret_if(!list_item->userdata);
599                 setting_main_appdata *ad = list_item->userdata;
600                 if (ad->wifi_timer) {
601                         ecore_timer_del(ad->wifi_timer);
602                         ad->wifi_timer = NULL;
603                 }
604                 ad->wifi_timer = ecore_timer_add(5.0, (Ecore_Task_Cb) __wifi_timeout, list_item);
605         }
606 }
607
608 static Eina_Bool __bt_timeout(void *data)
609 {
610         /*SETTING_TRACE_BEGIN; */
611         retvm_if(!data, ECORE_CALLBACK_CANCEL, "Invalid argument: data is NULL");
612         int status, err;
613         setting_get_bool_slp_key(INT_SLP_SETTING_BT_STATUS, &status, &err);
614         SETTING_TRACE("value:%d", status);
615
616         setting_main_appdata *ad = data;
617         Setting_GenGroupItem_Data *item_to_update;
618         int i;
619         for (i = VIEW_All_List; i < VIEW_Max; i++) {
620                 item_to_update = ad->gl_data_item[i][GL_BT];
621                 SETTING_TRACE("[%d]item_to_update:%p", i, item_to_update);
622                 if (item_to_update) {
623                         item_to_update->chk_status = status;
624                         item_to_update->swallow_type = SWALLOW_Type_1ICON_1RADIO;
625                         elm_object_item_data_set(item_to_update->item, item_to_update);
626                         /*elm_genlist_item_fields_update(item_to_update->item, "*", ELM_GENLIST_ITEM_FIELD_STATE); */
627                         elm_genlist_item_update(item_to_update->item);
628                 }
629         }
630
631
632         ad->bt_timer = NULL;
633         return ECORE_CALLBACK_CANCEL;
634 }
635
636 void __alternate_bt_mode(Setting_GenGroupItem_Data *list_item, Evas_Object *check)
637 {
638         /*SETTING_TRACE_BEGIN; */
639         int ret;
640         Eina_Bool status =  elm_check_state_get(check);
641         SETTING_TRACE("bt mode status : %d", status);
642
643         bt_adapter_state_e value;
644         ret = bt_initialize();
645         if (bt_adapter_get_state(&value) != BT_ERROR_NONE) {
646                 SETTING_TRACE_ERROR("bt_adapter_get_state() failed ");
647                 return;
648         }
649
650         setting_main_appdata *ad = g_main_ad;
651
652         if (status == value) {
653                 SETTING_TRACE("status == value");
654                 int i;
655                 for (i = VIEW_All_List; i < VIEW_Max; i++) {
656                         setting_force_update_gl_item_chk_status(ad->gl_data_item[i][GL_BT], value);
657                 }
658                 return;
659         }
660         do {
661                 /*add timeout strategy.. */
662                 Setting_GenGroupItem_Data *item_to_update;
663                 int i;
664                 for (i = VIEW_All_List; i < VIEW_Max; i++) {
665                         item_to_update = ad->gl_data_item[i][GL_BT];
666                         SETTING_TRACE("[%d]item_to_update:%p", i, item_to_update);
667                         if (item_to_update) {
668                                 item_to_update->swallow_type = SWALLOW_Type_1ICON_1PROCESS;
669                                 elm_object_item_data_set(item_to_update->item, item_to_update);
670                                 /*elm_genlist_item_update(list_item->item); */
671                                 elm_genlist_item_fields_update(item_to_update->item, "elm.icon.2", ELM_GENLIST_ITEM_FIELD_CONTENT);
672                         }
673                 }
674                 SETTING_TRACE("1111");
675                 if (ad->bt_timer) {
676                         ecore_timer_del(ad->bt_timer);
677                         ad->bt_timer = NULL;
678                 }
679                 ad->bt_timer = ecore_timer_add(5.0, (Ecore_Task_Cb) __bt_timeout, ad);
680
681                 if (ret < 0) {
682                         break;
683                 }
684                 status ? (ret = bt_adapter_enable()) : (ret = bt_adapter_disable());
685                 if (ret < 0) {
686                         break;
687                 }
688                 ret = bt_deinitialize();
689                 if (ret < 0) {
690                         break;
691                 }
692
693                 return;
694         } while (0);
695
696         int err;
697         int val = 0;
698         setting_get_int_slp_key(INT_SLP_SETTING_BT_STATUS, &val, &err);
699         setting_force_update_gl_item_chk_status(list_item, val);
700 }
701
702
703 void setting_main_high_touch_sens_chk_btn_cb(void *data, Evas_Object *obj, void *event_info)
704 {
705 #if 0
706         /*SETTING_TRACE_BEGIN; */
707         /* error check */
708         retm_if(data == NULL, "Data parameter is NULL");
709         Setting_GenGroupItem_Data *list_item = (Setting_GenGroupItem_Data *) data;
710
711         list_item->chk_status = elm_check_state_get(obj);       /*  for genlist update status */
712         //display_set_enhanced_touch(list_item->chk_status);
713
714         //int status = display_get_enhanced_touch();
715         int status = display_get_enhanced_touch();
716         SETTING_TRACE("display_get_enhanced_touch():%d", status);
717         if (status >= 0) {
718                 vconf_set_bool(VCONFKEY_SETAPPL_ENHANCED_TOUCH, (1 == status)); /*sync to vconf */
719         } else {
720                 setting_create_simple_popup(NULL, g_main_ad->win_main,
721                                             NULL, "IDS_IM_POP_UNEXPECTED_ERROR");
722                 /*rollback status */
723                 int i;
724                 for (i = VIEW_All_List; i < VIEW_Max; i++) {
725                         setting_force_update_gl_item_chk_status(g_main_ad->gl_data_item[i][GL_TouchSens], !(list_item->chk_status));
726                 }
727         }
728 #endif
729 }
730