aec632f63f6922d8b47557f6a91c5271dc5483e8
[apps/core/preloaded/settings.git] / src / setting-main.c
1 /*
2  * setting
3  *
4  * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd.
5  *
6  * Contact: MyoungJune Park <mj2004.park@samsung.com>
7  *
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
11  *
12  * http://www.apache.org/licenses/LICENSE-2.0
13  *
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.
19  *
20  */
21
22 #include <tapi_common.h>
23 #include <aul.h>
24 #include <ail.h>
25 #include <time.h>
26 #include <setting-main.h>
27 #include <setting-plugin.h>
28 #include <wifi.h>
29 #include <bluetooth.h>
30 #include <nfc.h>
31
32 #define PLUGIN_PREFIX "/opt"
33
34 typedef struct _DrawAppInfo
35 {
36         int ncount;
37         //------------------------------------
38         void (*draw_app)(void* arg, char* name, char* pkgname);
39         void* data;
40 } DrawAppInfo;
41
42 static int setting_main_create(void *cb);
43 static int setting_main_destroy(void *cb);
44 static int setting_main_update(void *cb);
45 static int setting_main_cleanup(void *cb);
46
47 setting_view setting_view_main = {
48         .create = setting_main_create,
49         .update = setting_main_update,
50         .destroy = setting_main_destroy,
51         .cleanup = setting_main_cleanup,
52 };
53
54 setting_main_appdata *g_main_ad = NULL;
55
56 static void setting_main_tapi_event_cb(TapiHandle *handle, int result, void *data, void *user_data);
57 static int setting_main_refresh(void *data);
58 static void __alternate_flight_mode(Evas_Object *check);
59 static void setting_main_click_Gendial_list_flight_mode_cb(void *data,
60                                                            Evas_Object *obj,
61                                                            void *event_info);
62 static void __alternate_flight_mode(Evas_Object *check);
63
64 void setting_main_click_list_item_ug_cb(void *data, Evas_Object *obj, char *ug_to_load, service_h svc, struct ug_cbs *cbs);
65
66 static void
67 __setting_chk_changed(void *data, Evas_Object *obj, void *event_info)
68 {
69         /* SETTING_TRACE_BEGIN; */
70         retm_if(data == NULL, "Data parameter is NULL");
71         Setting_GenGroupItem_Data *list_item =
72             (Setting_GenGroupItem_Data *) data;
73         /* SETTING_TRACE("process item [%s]", _(list_item->keyStr)); */
74         list_item->chk_status = elm_check_state_get(obj);
75
76         Eina_List *check_list = g_main_ad->item_check_list;
77         Setting_GenGroupItem_Data *item = NULL;
78         bool isFoundNotSelSomeone = FALSE;
79         bool isFoundSelSomeone = FALSE;
80         while (check_list) {
81                 item = (Setting_GenGroupItem_Data *)
82                     eina_list_data_get(check_list);
83                 if (NULL == item) {
84                         continue;
85                 }
86                 if (!(item->chk_status)) {
87                         isFoundNotSelSomeone = TRUE;
88                 } else {
89                         isFoundSelSomeone = TRUE;
90                 }
91                 if (isFoundNotSelSomeone && isFoundSelSomeone) {
92                         break;
93                 }
94                 check_list = eina_list_next(check_list);
95         }
96
97         if (isFoundNotSelSomeone) {
98                 g_main_ad->check_all_item->chk_status = 0;      /* for update new state */
99         } else {
100                 g_main_ad->check_all_item->chk_status = 1;      /* for update new state */
101         }
102         elm_object_item_data_set(g_main_ad->check_all_item->item, g_main_ad->check_all_item);
103         elm_genlist_item_update(g_main_ad->check_all_item->item);
104
105         if (isFoundSelSomeone) {
106                 /* SETTING_TRACE("Set it to active"); */
107                 /*
108                 elm_object_item_disabled_set(elm_toolbar_last_item_get
109                                                  (g_main_ad->controllbar_all_check),
110                                                  EINA_FALSE);*/
111         }
112 }
113
114 static void __setting_list_changed(void *data, Evas_Object *obj,
115                                    void *event_info)
116 {
117
118         SETTING_TRACE_BEGIN;
119         /* error check */
120         retm_if(event_info == NULL, "Invalid argument: event info is NULL");
121
122         Elm_Object_Item *item = (Elm_Object_Item *) event_info;
123         elm_genlist_item_selected_set(item, 0);
124         Setting_GenGroupItem_Data *list_item =
125             (Setting_GenGroupItem_Data *) elm_object_item_data_get(item);
126
127         int old_status = elm_check_state_get(list_item->eo_check);
128         /* new status */
129         list_item->chk_status = !old_status;
130         elm_check_state_set(list_item->eo_check, list_item->chk_status);
131
132         Eina_List *check_list = g_main_ad->item_check_list;
133         Setting_GenGroupItem_Data *group_item = NULL;
134         bool isFoundNotSelSomeone = FALSE;
135         bool isFoundSelSomeone = FALSE;
136         while (check_list) {
137                 group_item = (Setting_GenGroupItem_Data *)
138                     eina_list_data_get(check_list);
139                 if (NULL == group_item) {
140                         continue;
141                 }
142                 if (!(group_item->chk_status)) {
143                         isFoundNotSelSomeone = TRUE;
144                         /* break; */
145                 } else {
146                         isFoundSelSomeone = TRUE;
147                 }
148                 if (isFoundNotSelSomeone && isFoundSelSomeone) {
149                         break;
150                 }
151
152                 check_list = eina_list_next(check_list);
153         }
154
155         if (isFoundNotSelSomeone) {
156                 g_main_ad->check_all_item->chk_status = 0;      /* for update new state */
157         } else {
158                 g_main_ad->check_all_item->chk_status = 1;      /* for update new state */
159         }
160         elm_object_item_data_set(g_main_ad->check_all_item->item, g_main_ad->check_all_item);
161         elm_genlist_item_update(g_main_ad->check_all_item->item);
162
163         if (isFoundSelSomeone) {
164                 /* SETTING_TRACE("Set it to active"); */
165                 /*
166                 elm_object_item_disabled_set(elm_toolbar_last_item_get
167                                                  (g_main_ad->controllbar_all_check),
168                                                  EINA_FALSE);*/
169         }
170
171 }
172
173 static void
174 __setting_chk_sel_all_changed(void *data, Evas_Object *obj, void *event_info)
175 {
176         /* SETTING_TRACE_BEGIN; */
177         retm_if(data == NULL, "Data parameter is NULL");
178         Setting_GenGroupItem_Data *list_item =
179             (Setting_GenGroupItem_Data *) data;
180         bool is_all_checked = elm_check_state_get(obj);
181         list_item->chk_status = is_all_checked; /* for update new state */
182         /* SETTING_TRACE("is_all_checked:%d", is_all_checked); */
183
184         Eina_List *check_list = g_main_ad->item_check_list;
185
186         while (check_list) {
187                 list_item = (Setting_GenGroupItem_Data *)
188                     eina_list_data_get(check_list);
189                 if (NULL == list_item) {
190                         continue;
191                 }
192                 list_item->chk_status = is_all_checked;
193                 elm_object_item_data_set(list_item->item, list_item);
194                 elm_genlist_item_update(list_item->item);
195                 check_list = eina_list_next(check_list);
196         }
197         if (is_all_checked) {
198                 /*
199                 elm_object_item_disabled_set(elm_toolbar_last_item_get
200                                                  (g_main_ad->controllbar_all_check),
201                                                  EINA_FALSE);*/
202         }
203 }
204
205 static void __setting_list_sel_all_changed(void *data, Evas_Object *obj,
206                                            void *event_info)
207 {
208         /* error check */
209         SETTING_TRACE_BEGIN;
210         SETTING_TRACE();
211         retm_if(event_info == NULL, "Invalid argument: event info is NULL");
212         Elm_Object_Item *item = (Elm_Object_Item *) event_info;
213         elm_genlist_item_selected_set(item, 0);
214         Setting_GenGroupItem_Data *list_item =
215             (Setting_GenGroupItem_Data *) elm_object_item_data_get(item);
216
217         int old_status = elm_check_state_get(list_item->eo_check);
218         /* new status */
219         int is_all_checked = list_item->chk_status = !old_status;
220         elm_check_state_set(list_item->eo_check, list_item->chk_status);
221
222         Eina_List *check_list = g_main_ad->item_check_list;
223
224         while (check_list) {
225                 list_item = (Setting_GenGroupItem_Data *)
226                     eina_list_data_get(check_list);
227                 if (NULL == list_item) {
228                         continue;
229                 }
230                 list_item->chk_status = is_all_checked;
231                 /* elm_check_state_set(list_item->eo_check, is_all_checked); */
232                 elm_object_item_data_set(list_item->item, list_item);
233                 elm_genlist_item_update(list_item->item);
234                 check_list = eina_list_next(check_list);
235         }
236         if (is_all_checked) {
237                 /*
238                 elm_object_item_disabled_set(elm_toolbar_last_item_get
239                                                  (g_main_ad->controllbar_all_check),
240                                                  EINA_FALSE);*/
241         }
242
243 }
244
245 static void __load_check_list(void *data, Evas_Object **genlist,
246                               char *menuNameKey)
247 {
248         SETTING_TRACE_BEGIN;
249         setting_main_appdata *ad = (setting_main_appdata *) data;
250
251         bool state = FALSE;
252         char *keyStr = NULL;
253         Cfg_Item_Position pos = Cfg_Item_Pos_Uninstall;
254         bool isFoundNonSelItem = FALSE;
255         bool isFoundSelSomeoneItem = FALSE;
256
257         int i, j;
258         char *icon_path = NULL;
259
260         ad->check_all_item =
261             setting_create_Gendial_field_def(ad->gl_sel_all,
262                                              &(ad->itc[GENDIAL_Type_sel_all]),
263                                              __setting_list_sel_all_changed, ad,
264                                              SWALLOW_Type_1CHECK, NULL, NULL,
265                                              state, KeyStr_Select_All, NULL,
266                                              __setting_chk_sel_all_changed);
267         __BACK_POINTER_SET(ad->check_all_item);
268
269         Setting_GenGroupItem_Data *item = NULL;
270         Setting_GenGroupItem_Data *category_item = NULL;
271         for (i = 0; i < setting_cfg_get_category_length(); i++) {
272                 if (NULL == menuNameKey) {
273                         /* SETTING_TRACE("load all the items in config file"); */
274                 } else
275                     if (safeStrCmp
276                         (setting_cfg_get_category_name(i), menuNameKey)) {
277                         continue;
278                 }
279                 char *category_name = setting_cfg_get_category_name(i);
280
281                 category_item =
282                     setting_create_Gendial_field_group_titleItem(*genlist,
283                                                                  &(ad->itc
284                                                                    [GENDIAL_Type_group_item]),
285                                                                  NULL,
286                                                                  ELM_GENLIST_ITEM_NONE,
287                                                                  category_name,
288                                                                  NULL);
289                 if (category_item) {
290                         for (j = 0; j < setting_cfg_get_menu_length(i); j++) {
291                                 keyStr = setting_cfg_get_keyname_idx(i, j);
292                                 pos = (Cfg_Item_Position) setting_cfg_get_pos_idx(i, j);
293
294                                 if (Cfg_Item_Pos_Level1 == pos) {
295                                         state = FALSE;
296                                         isFoundNonSelItem = TRUE;
297                                 } else {
298                                         state = TRUE;
299                                         isFoundSelSomeoneItem = TRUE;
300                                 }
301
302                         icon_path = setting_cfg_get_icon_path_idx(i, j);
303                         item =
304                             setting_create_Gendial_field_groupitem(*genlist,
305                                                                    &(ad->itc
306                                                                      [GENDIAL_Type_1text_2icon_2]),
307                                                                    category_item->item,
308                                                                    __setting_list_changed,
309                                                                    ad,
310                                                                    SWALLOW_Type_1CHECKICON,
311                                                                    NULL,
312                                                                    icon_path,
313                                                                    state,
314                                                                    keyStr, NULL,
315                                                                    __setting_chk_changed);
316
317                                 ad->item_check_list =
318                                     eina_list_append(ad->item_check_list, item);
319                         }
320                 } else {
321                         SETTING_TRACE_ERROR("category_item is NULL");
322                 }
323         }
324
325         if (ad->check_all_item) {
326                 if (isFoundNonSelItem) {
327                         ad->check_all_item->chk_status = 0;     /* for update new state */
328                 } else {
329                         ad->check_all_item->chk_status = 1;     /* for update new state */
330                 }
331                 elm_object_item_data_set(ad->check_all_item->item, ad->check_all_item);
332                 elm_genlist_item_update(ad->check_all_item->item);
333         } else {
334                 SETTING_TRACE_ERROR("ad->check_all_item is NULL");
335         }
336
337         if (isFoundSelSomeoneItem) {
338         /*      elm_object_item_disabled_set(elm_toolbar_last_item_get
339                                                  (ad->controllbar_all_check),
340                                                  EINA_FALSE);
341                                                  */
342         } else {
343         /*
344                 elm_object_item_disabled_set(elm_toolbar_last_item_get
345                                                  (ad->controllbar_all_check),
346                                                  EINA_TRUE);*/
347         }
348         SETTING_TRACE_END;
349 }
350
351
352 static Setting_GenGroupItem_Data * __flightmode_handler(void* data, char* keyStr, char* icon_path, char* ug_name, Evas_Object *genlist)
353 {
354         // NOT UG --> it's just UI drawing
355
356         setting_main_appdata *ad = (setting_main_appdata *)data;
357         int value, err;
358         setting_get_bool_slp_key (BOOL_SLP_SETTING_FLIGHT_MODE, &value, &err);
359
360         /* create flight_mode */
361         ad->data_flight = setting_create_Gendial_field_groupitem(genlist,
362                                                    &(ad->itc[GENDIAL_Type_1text_2icon]),
363                                                    NULL,
364                                                    setting_main_click_Gendial_list_flight_mode_cb,
365                                                    ad,
366                                                    SWALLOW_Type_1ICON_1RADIO,
367                                                    icon_path,
368                                                    NULL,
369                                                    value,
370                                                    keyStr,
371                                                    NULL,
372                                                    setting_main_click_list_flight_mode_cb);
373         __BACK_POINTER_SET(ad->data_flight);
374
375         return ad->data_flight;
376 }
377
378 static Setting_GenGroupItem_Data * __wifi_handler(void* data, char* keyStr, char* icon_path, char* ug_args, Evas_Object *genlist)
379 {
380         setting_main_appdata *ad = (setting_main_appdata *)data;
381         int value, err;
382         setting_get_int_slp_key(INT_SLP_SETTING_WIFI_STATUS, &value, &err);
383
384         char* pa_wifi = get_pa_Wi_Fi_on_off_str();
385         ad->data_wifi = setting_create_Gendial_field_groupitem(genlist,
386                                                    &(ad->itc[GENDIAL_Type_2text_2icon_3]),
387                                                    NULL,
388                                                    setting_main_click_list_ex_ug_cb,
389                                                    ug_args,
390                                                    SWALLOW_Type_1ICON_1RADIO,
391                                                    icon_path,
392                                                    NULL,
393                                                    value,
394                                                    keyStr,
395                                                    pa_wifi,
396                                                    setting_main_click_list_wifi_mode_cb);
397         __BACK_POINTER_SET(ad->data_wifi);
398         G_FREE(pa_wifi);
399
400         return ad->data_wifi;
401 }
402
403 static Setting_GenGroupItem_Data * __bluetooth_handler(void* data, char* keyStr, char* icon_path, char* ug_args, Evas_Object *genlist)
404 {
405         setting_main_appdata *ad = (setting_main_appdata *)data;
406         int value, err;
407         setting_get_int_slp_key(INT_SLP_SETTING_BT_STATUS, &value, &err);
408
409         ad->data_bt = setting_create_Gendial_field_groupitem(genlist,
410                                                    &(ad->itc[GENDIAL_Type_2text_2icon_3]),
411                                                    NULL,
412                                                    setting_main_click_list_ex_ug_cb,
413                                                    ug_args,
414                                                    SWALLOW_Type_1ICON_1RADIO,
415                                                    icon_path,
416                                                    NULL,
417                                                    value,
418                                                    keyStr,
419                                                    get_BT_on_off_str
420                                                    (),
421                                                    setting_main_click_list_bt_mode_cb);
422         __BACK_POINTER_SET(ad->data_bt);
423
424         return ad->data_bt;
425 }
426
427 static Setting_GenGroupItem_Data * __allshare_handler(void* data, char* keyStr, char* icon_path, char* ug_args, Evas_Object *genlist)
428 {
429         setting_main_appdata *ad = (setting_main_appdata *)data;
430
431         Setting_GenGroupItem_Data * obj = setting_create_Gendial_field_groupitem(genlist,
432                                                                    &(ad->itc[GENDIAL_Type_1text_1icon_2]),
433                                                                    NULL,
434                                                                    setting_main_click_list_default_ug_cb,
435                                                                    ad,
436                                                                    SWALLOW_Type_INVALID,
437                                                                    icon_path,
438                                                                    NULL, 0,
439                                                                    keyStr,
440                                                                    NULL,
441                                                                    NULL);
442         return obj;
443 }
444
445 static Setting_GenGroupItem_Data * __network_handler(void* data, char* keyStr, char* icon_path, char* ug_args, Evas_Object *genlist)
446 {
447         setting_main_appdata *ad = (setting_main_appdata *)data;
448
449         ad->data_network = setting_create_Gendial_field_groupitem(genlist,
450                                                                        &(ad->itc[GENDIAL_Type_1text_1icon_2]),
451                                                                        NULL,
452                                                                        setting_main_click_list_network_ug_cb,
453                                                                        ad,
454                                                                        SWALLOW_Type_INVALID,
455                                                                        icon_path,
456                                                                        NULL, 0,
457                                                                        keyStr,
458                                                                        NULL,
459                                                                        NULL);
460
461         return ad->data_network;
462 }
463
464 static Setting_GenGroupItem_Data * __nfc_handler(void* data, char* keyStr, char* icon_path, char* ug_args, Evas_Object *genlist)
465 {
466         setting_main_appdata *ad = (setting_main_appdata *)data;
467
468         int value, err;
469         setting_get_bool_slp_key(BOOL_SLP_SETTING_NFC_STATUS, &value, &err);
470
471         ad->data_nfc = setting_create_Gendial_field_groupitem(genlist,
472                                                    &(ad->itc[GENDIAL_Type_2text_2icon_3]),
473                                                    NULL,
474                                                    setting_main_click_list_ex_ug_cb,
475                                                    ug_args,
476                                                    SWALLOW_Type_1ICON_1RADIO,
477                                                    icon_path,
478                                                    NULL,
479                                                    value,
480                                                    keyStr,
481                                                    get_NFC_on_off_str(),
482                                                    setting_main_click_list_nfc_mode_cb);
483         __BACK_POINTER_SET(ad->data_nfc);
484
485 #if DISABLED_CODE
486         setting_create_Gendial_field_def(genlist, &itc_multiline_text, NULL,
487                  ad, SWALLOW_Type_LAYOUT_SPECIALIZTION_X,
488                  NULL, NULL, 0, SETTING_NFC_DESC, NULL, NULL);
489         elm_genlist_item_select_mode_set(elm_genlist_item_append(genlist, &(itc_seperator), NULL, NULL,ELM_GENLIST_ITEM_NONE, NULL, NULL),
490                                          ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY);
491 #endif
492         return ad->data_nfc;
493 }
494
495 static Setting_GenGroupItem_Data * __default_handler(void* data, char* keyStr, char* icon_path, char* ug_args, Evas_Object *genlist)
496 {
497         setting_main_appdata *ad = (setting_main_appdata *)data;
498         Setting_GenGroupItem_Data * obj = setting_create_Gendial_field_groupitem(genlist,
499                                                            &(ad->itc[GENDIAL_Type_1text_1icon_2]),
500                                                            NULL,
501                                                            setting_main_click_list_ex_ug_cb,
502                                                            ug_args,
503                                                            SWALLOW_Type_INVALID,
504                                                            icon_path,
505                                                            NULL, 0,
506                                                            keyStr,
507                                                            NULL,
508                                                            NULL);
509
510
511         return obj;
512 }
513
514 typedef struct mainlist_entry mainlist_entry;
515
516 struct mainlist_entry {
517         char* title;
518         Setting_GenGroupItem_Data* (*ui_handler)(void* data, char* title, char* iconpath, char* ugname, Evas_Object *genlist);
519 };
520
521
522 enum {
523         MAINLIST_ENTRY_FLIGHT_MODE = 0,
524         MAINLIST_ENTRY_WIFI,
525         MAINLIST_ENTRY_BT,
526         MAINLIST_ENTRY_ALLSHARE,
527         MAINLIST_ENTRY_NETWORK,
528         MAINLIST_ENTRY_NFC,
529         MAINLIST_ENTRY_DEFAULT,
530         MAINLIST_ENTRY_MAX,
531 };
532
533 static mainlist_entry mainlist_table[] = {
534                 {KeyStr_FlightMode,     __flightmode_handler},                  // 0 --> NOT UG
535                 {KeyStr_WiFi,                   __wifi_handler},                                // 1 --> UG
536                 {KeyStr_Bluetooth,              __bluetooth_handler},                   // 1 --> UG
537                 {KeyStr_AllShare,               __allshare_handler},                    // NOT UG
538                 {KeyStr_Network,                __network_handler},                             // 1 --> UG
539                 {KeyStr_NFC,                    __nfc_handler},                                 // 1 --> UG
540                 {"Default",                     __default_handler},                             // 1 --> UG
541
542                 //--------------------------------------------------------------
543                 {NULL, NULL},
544         };
545
546
547 void __gl_realized(void *data, Evas_Object *obj, void *event_info)
548 {
549         //SETTING_TRACE_BEGIN;
550         setting_retm_if(data == NULL, "invalid parameter: data is NULL");
551         setting_retm_if(event_info == NULL, "invalid parameter: event_info is NULL");
552         setting_main_appdata *ad = (setting_main_appdata *)data;
553         Elm_Object_Item *item = (Elm_Object_Item *)event_info;
554         Setting_GenGroupItem_Data *list_item = (Setting_GenGroupItem_Data *)elm_object_item_data_get(item);
555
556         //setting_retm_if(list_item == NULL, "list_item is NULL");
557
558         if (list_item) {
559                 if (list_item->group_style == SETTING_GROUP_STYLE_TOP) {
560                         elm_object_item_signal_emit(item, "elm,state,top", "");
561                 } else if (list_item->group_style == SETTING_GROUP_STYLE_BOTTOM) {
562                         elm_object_item_signal_emit(item, "elm,state,bottom", "");
563                 } else if (list_item->group_style == SETTING_GROUP_STYLE_CENTER) {
564                         elm_object_item_signal_emit(item, "elm,state,center", "");
565                 } else if (list_item->group_style == SETTING_GROUP_STYLE_NONE) {
566                         /* do nothing */
567                 } else {
568                         SETTING_TRACE_ERROR("list_item->group_style is wrong");
569                 }
570         } else {
571                 /* item is used for description */
572                 elm_object_item_signal_emit(item, "elm,state,center", "");
573         }
574 }
575
576 // Flight Mode  - not UG
577 // All share    - not UG
578 // WiFi                 - added toggle
579 // Bluetooth
580 // Mobile AP
581 // Network
582 // NFC
583 // Other UGs
584 void __load_connectivity_menu_list(void *data, Cfg_Item_Position inputPos, Evas_Object *genlist)
585 {
586         SETTING_TRACE_BEGIN;
587         setting_main_appdata *ad = data;
588         //group title, only display in setting main view
589         if (SETTING_VIEW_MAIN == ad->view_load) {
590                 setting_create_Gendial_field_group_titleItem(ad->main_genlist,
591                                                      &(ad->itc[GENDIAL_Type_group_item]),
592                                                      NULL,
593                                                      ELM_GENLIST_ITEM_NONE,
594                                                      KeyStr_Connectivity, NULL);
595         }
596
597         int idx_second_menu = 0;
598
599         char *keyStr = NULL;
600         char *icon_path = NULL;
601         char *ug_args = NULL;
602         Cfg_Item_Position tmpPos = Cfg_Item_Pos_Uninstall;
603         int i, j;
604
605         bool is_emulator = isEmulBin();
606
607         Setting_GenGroupItem_Data *item_data = NULL;
608         int index = 0;
609
610         for (i = 0; i < setting_cfg_get_category_length(); i++) {
611                 if (safeStrCmp
612                     (setting_cfg_get_category_name(i), KeyStr_Connectivity))
613                         continue;
614
615                 for (j = 0; j < setting_cfg_get_menu_length(i); j++) {
616                         keyStr = setting_cfg_get_keyname_idx(i, j);
617                         tmpPos = (Cfg_Item_Position) setting_cfg_get_pos_idx(i, j);
618                         ug_args = setting_cfg_get_ug_args_idx(i, j);
619                         icon_path = setting_cfg_get_icon_path_idx(i, j);
620                         /* SETTING_TRACE_DEBUG("Got an item[keyStr:%s, ug_args:%s, pos:%d]", */
621                         /*                     keyStr, ug_args, tmpPos); */
622
623                         if (is_emulator) {
624                                 if (!safeStrCmp(KeyStr_FlightMode, keyStr)) {
625                                         continue; /* hide Flight Mode in Emulator*/
626                                 } else if (!safeStrCmp(KeyStr_WiFi, keyStr)) {
627                                         continue; /* hide WIFI in Emulator*/
628                                 } else if (!safeStrCmp(KeyStr_WiFiDirect, keyStr)) {
629                                         continue; /* hide WiFiDirect in Emulator*/
630                                 } else if (!safeStrCmp(KeyStr_Network, keyStr)) {
631                                         continue; /* hide Network in Emulator*/
632                                 } else if (!safeStrCmp(KeyStr_Bluetooth, keyStr)) {
633                                         continue; /* hide Bluetooth in Emulator*/
634                                 } else if (!safeStrCmp(KeyStr_MobileAP, keyStr)) {
635                                         continue; /* hide Tethering in Emulator*/
636                                 } else {
637                                         /* do nothing */
638                                 }
639                         }
640
641                         if (idx_second_menu < MAX_MORE_MENU_NUM
642                             && Cfg_Item_Pos_Level1 == tmpPos
643                             && SETTING_VIEW_MAIN == ad->view_load
644                             && MAIN_PROFILE_PREFERRED == ad->profile_type) {
645
646                                 if (is_ug_installed_by_ug_args(ug_args)) {
647                                         ad->more_connective_menus[idx_second_menu++] = keyStr;
648                                 }
649                         }
650
651                         if (Cfg_Item_Pos_Level_All == inputPos) {
652                         } else if (inputPos != tmpPos) {        /* not in the inputPos level */
653                                 continue;
654                         }
655
656                         if (!safeStrCmp(KeyStr_FlightMode, keyStr)) {   /* load special radio */
657                                 // ug == NULL
658                                 item_data = mainlist_table[MAINLIST_ENTRY_FLIGHT_MODE].ui_handler(ad, keyStr, icon_path, ug_args, genlist);
659
660                         } else if (!safeStrCmp(KeyStr_AllShare, keyStr)) {      /* NOT UG */
661
662                                 item_data = mainlist_table[MAINLIST_ENTRY_ALLSHARE].ui_handler(ad, keyStr, icon_path, ug_args, genlist);
663
664                         } else if (!safeStrCmp(KeyStr_WiFi, keyStr) && is_ug_installed_by_ug_args(ug_args)) {   /* load special icon */
665
666                                 item_data = mainlist_table[MAINLIST_ENTRY_WIFI].ui_handler(ad, keyStr, icon_path, ug_args, genlist);
667
668                         } else if (!safeStrCmp(KeyStr_Bluetooth, keyStr) && is_ug_installed_by_ug_args(ug_args)) {      /* load special icon */
669
670                                 item_data = mainlist_table[MAINLIST_ENTRY_BT].ui_handler(ad, keyStr, icon_path, ug_args, genlist);
671
672                         }
673 #if 0
674  else if (!safeStrCmp(KeyStr_MobileAP, keyStr) && is_ug_installed_by_ug_args(ug_args)) {        /* load special icon */
675
676                                 item_data = mainlist_table[MAINLIST_ENTRY_MOBILEAP].ui_handler(ad, keyStr, icon_path, ug_args, genlist);
677
678                         }
679 #endif
680                          else if (!safeStrCmp(KeyStr_Network, keyStr) && is_ug_installed_by_ug_args(ug_args)) { /* load special UG */
681
682                                 item_data = mainlist_table[MAINLIST_ENTRY_NETWORK].ui_handler(ad, keyStr, icon_path, ug_args, genlist);
683
684                         } else if (!safeStrCmp(KeyStr_NFC, keyStr) && is_ug_installed_by_ug_args(ug_args)) {    /* load special icon */
685                                 int nfc_value = FALSE; //default
686                                 vconf_get_bool(VCONFKEY_NFC_FEATURE, &nfc_value);
687                                 if (VCONFKEY_NFC_FEATURE_ON == nfc_value)
688                                 {
689                                         item_data = mainlist_table[MAINLIST_ENTRY_NFC].ui_handler(ad, keyStr, icon_path, ug_args, genlist);
690                                 }
691                         } else {        /* load other UGs */
692                                 if (is_ug_installed_by_ug_args(ug_args))
693                                 {
694                                         item_data = mainlist_table[MAINLIST_ENTRY_DEFAULT].ui_handler(ad, keyStr, icon_path, ug_args, genlist);
695                                 }
696                         }
697
698                         if (item_data) {
699                                 if (j == 0) {
700                                         item_data->group_style = SETTING_GROUP_STYLE_TOP;
701                                 } else if (j == setting_cfg_get_menu_length(i) - 1) {
702                                         item_data->group_style = SETTING_GROUP_STYLE_BOTTOM;
703                                 } else {
704                                         item_data->group_style = SETTING_GROUP_STYLE_CENTER;
705                                 }
706
707                                 if (index == 0) {
708                                         item_data->group_style = SETTING_GROUP_STYLE_TOP;
709                                 }
710                                 index++;
711                         }
712                 }
713         }
714
715         //end group , only display in setting main view
716 #if SUPPORT_MORE_ITEM_FUNCTION
717                 if (SETTING_VIEW_MAIN == ad->view_load && MAIN_PROFILE_PREFERRED == ad->profile_type && idx_second_menu > 0)
718                 {
719                         char sub_text[MAX_COMMON_BUFFER_LEN] = {0, };
720                         int idx = 0;
721                         while (idx < MAX_MORE_MENU_NUM && ad->more_connective_menus[idx])
722                         {
723                                 if (idx != 0)
724                                 {
725                                         safeStrNCat(sub_text, ", ", MAX_COMMON_BUFFER_LEN);
726                                 }
727                                 safeStrNCat(sub_text, _(ad->more_connective_menus[idx]), MAX_COMMON_BUFFER_LEN);
728                                 idx++;
729                         }
730
731                         ad->data_moreConnect =
732                                 setting_create_Gendial_field_groupitem(ad->main_genlist,
733                                                                        &(ad->itc[GENDIAL_Type_2text_3]),
734                                                                        NULL,
735                                                                        setting_main_click_list_more_cb,
736                                                                        ad,
737                                                                        SWALLOW_Type_INVALID,
738                                                                        NULL,
739                                                                        NULL,
740                                                                        0,
741                                                                        KeyStr_MoreConnect,
742                                                                        sub_text,
743                                                                        NULL);
744                         __BACK_POINTER_SET(ad->data_moreConnect);
745
746                         /* if has <more ..> item , change the last item_date to SETTING_GROUP_STYLE_CENTER*/
747                         if (item_data && index > 1) {
748                                 item_data->group_style = SETTING_GROUP_STYLE_CENTER;
749                         }
750                         ad->data_moreConnect->group_style = SETTING_GROUP_STYLE_BOTTOM;
751
752                         item_data = ad->data_moreConnect;
753                         index++;
754                 }
755 #endif
756
757         if (index == 1) {
758                 item_data->group_style = SETTING_GROUP_STYLE_NONE;
759         } else if (index == 2) {
760                 item_data->group_style = SETTING_GROUP_STYLE_BOTTOM;
761         }
762         SETTING_TRACE_END;
763 }
764
765 void __load_connectivity_level0_list(void *data)
766 {
767         setting_main_appdata *ad = data;
768         __load_connectivity_menu_list(ad, Cfg_Item_Pos_Level0, ad->main_genlist);
769 }
770
771 void __load_connectivity_level_all_list(void *data)
772 {
773         SETTING_TRACE_BEGIN;
774         setting_main_appdata *ad = data;
775         __load_connectivity_menu_list(ad, Cfg_Item_Pos_Level_All, ad->main_genlist);
776 }
777
778 void __load_system_menu_list(void *data, Cfg_Item_Position inputPos, Evas_Object *genlist)
779 {
780         SETTING_TRACE_BEGIN;
781         SETTING_TRACE_DEBUG("pos :%d", inputPos);
782         setting_main_appdata *ad = data;
783         //group title, only display in setting main view
784         if (SETTING_VIEW_MAIN == ad->view_load) {
785                 setting_create_Gendial_field_group_titleItem(ad->main_genlist,
786                                                      &(ad->itc[GENDIAL_Type_group_item]),
787                                                      NULL,
788                                                      ELM_GENLIST_ITEM_NONE,
789                                                      KeyStr_System, NULL);
790         }
791         int idx_second_menu = 0;
792
793         char *keyStr = NULL;
794         char *icon_path = NULL;
795         char *ug_args = NULL;
796
797         Cfg_Item_Position tmpPos = Cfg_Item_Pos_Uninstall;
798
799         int ncount = 0;
800         int i, j;
801
802         bool is_emulator = isEmulBin();
803
804         Setting_GenGroupItem_Data *item_data = NULL;
805         int index = 0;
806
807         //SETTING_TRACE("setting_cfg_get_category_length() :: %d ", setting_cfg_get_category_length());
808         for (i = 0; i < setting_cfg_get_category_length(); i++) {
809                 if (safeStrCmp(setting_cfg_get_category_name(i), KeyStr_System))
810                         continue;
811
812                 //SETTING_TRACE(" setting_cfg_get_menu_length(%d) :: %d ",i, setting_cfg_get_menu_length(i) );
813                 for (j = 0; j < setting_cfg_get_menu_length(i); j++) {
814                         keyStr = setting_cfg_get_keyname_idx(i, j);
815                         /* sg_path = setting_cfg_get_ugpath_idx(i, j); */
816                         tmpPos = (Cfg_Item_Position) setting_cfg_get_pos_idx(i, j);
817                         icon_path = setting_cfg_get_icon_path_idx(i, j);
818                         ug_args = setting_cfg_get_ug_args_idx(i, j);
819
820                         //SETTING_TRACE("KeyString :  %s , tmpPos : %d , inputPos : %d ", keyStr, tmpPos, inputPos );
821
822                         if (is_emulator) {
823                                 if (!safeStrCmp(KeyStr_Security, keyStr)) {
824                                         continue; /* hide Security in Emulator*/
825                                 } else if (!safeStrCmp(KeyStr_Memory, keyStr)) {
826                                         continue; /* hide Memory in Emulator*/
827                                 } else if (!safeStrCmp(KeyStr_Powersaving, keyStr)) {
828                                         continue; /* hide Powersaving in Emulator*/
829                                 } else {
830                                         /* do nothing */
831                                 }
832                         }
833
834                         if (idx_second_menu < MAX_MORE_MENU_NUM
835                             && Cfg_Item_Pos_Level1 == tmpPos
836                             && SETTING_VIEW_MAIN == ad->view_load
837                             && MAIN_PROFILE_PREFERRED == ad->profile_type) {
838
839                             if (is_ug_installed_by_ug_args(ug_args)) {
840                                 ad->more_system_menus[idx_second_menu++] = keyStr;
841                             }
842                         }
843
844                         if (Cfg_Item_Pos_Level_All == inputPos) {
845                                 // do nothing
846                                 //SETTING_TRACE("Cfg_Item_Pos_Level_All == inputPos ---> no draw --- WHY?? ");
847                         } else if (inputPos != tmpPos) {        /* not in the inputPos level */
848                                 //SETTING_TRACE("inputPos == tmp Pos ---> no draw --- WHY?? ");
849                                 continue;
850                         }
851
852                         if (!safeStrCmp(KeyStr_Landscape, keyStr)) {    /* load special UG */
853                                 int value = 0;
854                                 vconf_get_bool
855                                     (VCONFKEY_SETAPPL_AUTO_ROTATE_SCREEN_BOOL, &value);
856
857                                 ad->data_rotationMode =
858                                     setting_create_Gendial_field_groupitem(genlist,
859                                                                            &(ad->itc[GENDIAL_Type_1text_2icon]),
860                                                                            NULL,
861                                                                            setting_main_sel_list_mouse_up_cb,
862                                                                            ad,
863                                                                            SWALLOW_Type_1ICON_1RADIO,
864                                                                            icon_path,
865                                                                            NULL,
866                                                                            value,
867                                                                            keyStr,
868                                                                            NULL,
869                                                                            setting_main_list_mouse_up_cb);
870                                 __BACK_POINTER_SET(ad->data_rotationMode);
871                                 item_data = ad->data_rotationMode;
872                         }
873                         else if (!safeStrCmp(KeyStr_Brightness, keyStr)) {
874
875                                 char* pa_bright = get_brightness_mode_str();
876                                 ad->data_bright=
877                                     setting_create_Gendial_field_groupitem(genlist,
878                                                                            &(ad->itc[GENDIAL_Type_1icon_2text]),
879                                                                            NULL,
880                                                                            setting_main_click_list_ex_ug_cb,
881                                                                            ug_args,
882                                                                            SWALLOW_Type_INVALID,
883                                                                            icon_path,
884                                                                            NULL,
885                                                                            0,
886                                                                            keyStr,
887                                                                            pa_bright,
888                                                                            NULL);
889                                 __BACK_POINTER_SET(ad->data_bright);
890                                 item_data = ad->data_bright;
891                                 ncount++;
892                         }
893                         else {  /* load other UGs */
894                                 item_data = setting_create_Gendial_field_groupitem(genlist,
895                                                                        &(ad->itc[GENDIAL_Type_1text_1icon_2]),
896                                                                        NULL,
897                                                                        setting_main_click_list_ex_ug_cb,
898                                                                        ug_args,
899                                                                        SWALLOW_Type_INVALID,
900                                                                        icon_path,
901                                                                        NULL, 0,
902                                                                        keyStr,
903                                                                        NULL,
904                                                                        NULL);
905                                 ncount++;
906                         }
907
908                         if (item_data) {
909                                 if (j == 0) {
910                                         item_data->group_style = SETTING_GROUP_STYLE_TOP;
911                                 } else if (j == setting_cfg_get_menu_length(i) - 1) {
912                                         item_data->group_style = SETTING_GROUP_STYLE_BOTTOM;
913                                 } else {
914                                         item_data->group_style = SETTING_GROUP_STYLE_CENTER;
915                                 }
916
917                                 if (index == 0) {
918                                         item_data->group_style = SETTING_GROUP_STYLE_TOP;
919                                 }
920                                 index++;
921                         }
922                 }
923         }
924         //end group, only display in setting main view
925 #if SUPPORT_MORE_ITEM_FUNCTION
926                 if (SETTING_VIEW_MAIN == ad->view_load && MAIN_PROFILE_PREFERRED == ad->profile_type && idx_second_menu > 0)
927                 {
928                         char sub_text[MAX_COMMON_BUFFER_LEN] = {0, };
929                         int idx = 0;
930                         while (idx < MAX_MORE_MENU_NUM && ad->more_system_menus[idx])
931                         {
932                                 if (idx != 0)
933                                 {
934                                         safeStrNCat(sub_text, ", ", MAX_COMMON_BUFFER_LEN);
935                                 }
936                                 safeStrNCat(sub_text, _(ad->more_system_menus[idx]), MAX_COMMON_BUFFER_LEN);
937                                 idx++;
938                         }
939
940                         ad->data_moreSystem =
941                                 setting_create_Gendial_field_groupitem(ad->main_genlist,
942                                                                        &(ad->itc[GENDIAL_Type_2text_3]),
943                                                                        NULL,
944                                                                        setting_main_click_list_more_cb,
945                                                                        ad,
946                                                                        SWALLOW_Type_INVALID,
947                                                                        NULL,
948                                                                        NULL,
949                                                                        0,
950                                                                        KeyStr_MoreSystem,
951                                                                        sub_text,
952                                                                        NULL);
953                         __BACK_POINTER_SET(ad->data_moreSystem);
954
955                         /* if has <more ..> item , change the last item_date to SETTING_GROUP_STYLE_CENTER*/
956                         if (item_data && index > 1) {
957                                 item_data->group_style = SETTING_GROUP_STYLE_CENTER;
958                         }
959                         ad->data_moreSystem->group_style = SETTING_GROUP_STYLE_BOTTOM;
960
961                         item_data = ad->data_moreSystem;
962                         index++;
963                 }
964 #endif
965         if (index == 1) {
966                 item_data->group_style = SETTING_GROUP_STYLE_NONE;
967         } else if (index == 2) {
968                 item_data->group_style = SETTING_GROUP_STYLE_BOTTOM;
969         }
970 }
971
972 static void __load_system_level0_list(void *data)
973 {
974         setting_main_appdata *ad = data;
975         __load_system_menu_list(ad, Cfg_Item_Pos_Level0, ad->main_genlist);
976 }
977
978 static void __load_system_level_all_list(void *data)
979 {
980         SETTING_TRACE_BEGIN;
981         setting_main_appdata *ad = data;
982         __load_system_menu_list(ad, Cfg_Item_Pos_Level_All, ad->main_genlist);
983 }
984
985 static void __load_applications_menu_list(void *data,
986                                           Cfg_Item_Position inputPos)
987 {
988         SETTING_TRACE_BEGIN;
989         SETTING_TRACE_DEBUG("pos :%d", inputPos);
990         setting_main_appdata *ad = data;
991
992         bool is_emulator = isEmulBin();
993
994         //group title
995         setting_create_Gendial_field_group_titleItem(ad->main_genlist,
996                                                      &(ad->itc[GENDIAL_Type_group_item]),
997                                                      NULL,
998                                                      ELM_GENLIST_ITEM_NONE,
999                                                      KeyStr_Applications, NULL);
1000         char *keyStr = NULL;
1001         char *icon_path = NULL;
1002         char *ug_args = NULL;
1003         Cfg_Item_Position tmpPos = Cfg_Item_Pos_Uninstall;
1004         int i, j;
1005
1006         Setting_GenGroupItem_Data *item_data = NULL;
1007         int index = 0;
1008         for (i = 0; i < setting_cfg_get_category_length(); i++) {
1009                 if (safeStrCmp
1010                     (setting_cfg_get_category_name(i), KeyStr_Applications))
1011                         continue;
1012
1013                 for (j = 0; j < setting_cfg_get_menu_length(i); j++) {
1014                         keyStr = setting_cfg_get_keyname_idx(i, j);
1015                         icon_path = setting_cfg_get_icon_path_idx(i, j);
1016                         ug_args = setting_cfg_get_ug_args_idx(i, j);
1017                         tmpPos =
1018                             (Cfg_Item_Position) setting_cfg_get_pos_idx(i, j);
1019
1020                         if (Cfg_Item_Pos_Level_All == inputPos) {
1021                         } else if (inputPos != tmpPos) {        /* not in the inputPos level */
1022                                 continue;
1023                         }
1024
1025                         if (is_emulator) {
1026                                  /* hide all except Email */
1027                                 if (safeStrCmp(KeyStr_Email, keyStr)) {
1028                                         continue;
1029                                 } else {
1030                                         /* do nothing */
1031                                 }
1032                         }
1033
1034                         item_data = setting_create_Gendial_field_groupitem(ad->main_genlist,
1035                                                                &(ad->itc[GENDIAL_Type_1text_1icon_2]),
1036                                                                NULL,
1037                                                                setting_main_click_list_ex_ug_cb,
1038                                                                ug_args,
1039                                                                SWALLOW_Type_INVALID,
1040                                                                icon_path, NULL,
1041                                                                0, keyStr, NULL,
1042                                                                NULL);
1043
1044                         if (item_data) {
1045                                 if (j == 0) {
1046                                         item_data->group_style = SETTING_GROUP_STYLE_TOP;
1047                                 } else if (j == setting_cfg_get_menu_length(i) - 1) {
1048                                         item_data->group_style = SETTING_GROUP_STYLE_BOTTOM;
1049                                 } else {
1050                                         item_data->group_style = SETTING_GROUP_STYLE_CENTER;
1051                                 }
1052
1053                                 if (index == 0) {
1054                                         item_data->group_style = SETTING_GROUP_STYLE_TOP;
1055                                 }
1056                                 index++;
1057                         }
1058                 }
1059         }
1060
1061         if (index == 1) {
1062                 item_data->group_style = SETTING_GROUP_STYLE_NONE;
1063         } else if (index == 2) {
1064                 item_data->group_style = SETTING_GROUP_STYLE_BOTTOM;
1065         }
1066
1067         SETTING_TRACE_END;
1068 }
1069
1070 static void __load_applications_level0_list(void *data)
1071 {
1072         setting_main_appdata *ad = data;
1073         __load_applications_menu_list(ad, Cfg_Item_Pos_Level0);
1074 }
1075
1076 static void __load_applications_level_all_list(void *data)
1077 {
1078         SETTING_TRACE_BEGIN;
1079         setting_main_appdata *ad = data;
1080         __load_applications_menu_list(ad, Cfg_Item_Pos_Level_All);
1081 }
1082
1083
1084 bool is_3rdapp_installed_setting_cfg(char* pkgname)
1085 {
1086         SETTING_TRACE_BEGIN;
1087         char path[512];
1088
1089         SETTING_TRACE("1");
1090         if (snprintf(path, 512, PLUGIN_PREFIX"/apps/%s/setting/setting.xml", pkgname) < 0)
1091                 return false;
1092
1093         struct stat st;
1094         bool result_opt = false;
1095
1096         if(stat(path, &st) == 0) {
1097                 result_opt = true;
1098         } else {
1099                 SETTING_TRACE_ERROR(" %s is *NOT* present\n", path);
1100                 result_opt = false;
1101         }
1102
1103         return result_opt;
1104 }
1105
1106 /**
1107  * @param data
1108  */
1109 static void draw_3rdapp(void* data, char* name, char* pkgname)
1110 {
1111         SETTING_TRACE_BEGIN;
1112         SETTING_TRACE(" name : %s", name);
1113         SETTING_TRACE(" pkgname : %s", pkgname);
1114
1115         setting_main_appdata *ad = data;
1116
1117         //3rd cfg
1118         char fullpath[512];
1119         if (snprintf(fullpath, 512,  PLUGIN_PREFIX"/apps/%s/setting/setting.xml", pkgname) < 0)
1120                 return;
1121
1122         SETTING_TRACE(" fullpath : %s", fullpath);
1123
1124         if (ad)
1125         {
1126                 if (ad->plugin_path)
1127                 {
1128                         free(ad->plugin_path);
1129                         ad->plugin_path = NULL;
1130                 }
1131                 ad->plugin_path = strdup(fullpath);
1132
1133                 setting_create_Gendial_field_groupitem(ad->main_genlist,
1134                                                            &(ad->itc[GENDIAL_Type_1text_1icon_2]),
1135                                                            NULL,
1136                                                            setting_main_click_list_plugin_cb,
1137                                                            ad,
1138                                                            SWALLOW_Type_INVALID,
1139                                                            IMG_DefaultIcon, NULL,
1140                                                            0, name, NULL,
1141                                                            NULL);
1142         }
1143         SETTING_TRACE_END;
1144 }
1145
1146 /**
1147  *
1148  * ail code here
1149  */
1150 static ail_cb_ret_e __download_apps_cb(ail_appinfo_h ai, void* data)
1151 {
1152         DrawAppInfo* pinfo = (DrawAppInfo*)data;
1153     char *id;
1154
1155         if (AIL_ERROR_OK == ail_appinfo_get_str(ai, AIL_PROP_PACKAGE_STR, &id))
1156         {
1157                 SETTING_TRACE(" 3rd party - app name : ----> %s ", id);
1158         }
1159
1160     ail_appinfo_h handle;
1161
1162     char *name = NULL;
1163     char *icon = NULL;
1164     int installed_time;
1165     bool nodisplay = false;
1166     bool removable = true;
1167
1168     if (AIL_ERROR_OK == ail_package_get_appinfo(id, &handle))
1169         {
1170                 if (AIL_ERROR_OK != ail_appinfo_get_str(handle, AIL_PROP_NAME_STR, &name))
1171                         SETTING_TRACE("cannot get name");
1172
1173                 if (AIL_ERROR_OK != ail_appinfo_get_str(handle, AIL_PROP_ICON_STR, &icon))
1174                         SETTING_TRACE("cannot get icon");
1175
1176                 if (AIL_ERROR_OK != ail_appinfo_get_bool(handle, AIL_PROP_NODISPLAY_BOOL, &nodisplay))
1177                         SETTING_TRACE("cannot get nodisplay");
1178
1179                 if (AIL_ERROR_OK != ail_appinfo_get_bool(handle, AIL_PROP_X_SLP_REMOVABLE_BOOL, &removable))
1180                         SETTING_TRACE("cannot get removable");
1181
1182                 if (AIL_ERROR_OK != ail_appinfo_get_int(handle, AIL_PROP_X_SLP_INSTALLEDTIME_INT, &installed_time))
1183                         SETTING_TRACE("cannot get installed_time");
1184
1185                 //SETTING_TRACE("installed_time = %d ", installed_time);
1186                 if (installed_time != 0 && is_3rdapp_installed_setting_cfg(id) == true )
1187                 {
1188                         SETTING_TRACE(" 3rd party - app name : ----> id : %s --- name : %s ", id, name);
1189                         SETTING_TRACE(" 3rd party - icon : ----> %s ", icon);
1190                         SETTING_TRACE(" 3rd party - nodisplay :  ----> %d ", nodisplay);
1191                         pinfo->ncount++;
1192
1193                         // draw code here
1194                         if (pinfo->draw_app != NULL)
1195                         {
1196                                 SETTING_TRACE(">>> pkg name --> %s ", id);
1197                                 pinfo->draw_app(pinfo->data, strdup(name)/* appname*/, strdup(id)/* pkg_name*/);
1198                         }
1199                 }
1200         }
1201         SETTING_TRACE_END;
1202     return AIL_CB_RET_CONTINUE;
1203 }
1204
1205
1206 /**
1207  * get 3rd party applist from AIL & searching dir/file by the defined rule
1208  * @param data ad
1209  * if data is NULL --> just get how many items are there
1210  * if data is NOT NULL --> draw UI code
1211  */
1212 static int get_downloadapp_list(void* data)
1213 {
1214         SETTING_TRACE_BEGIN;
1215
1216         setting_main_appdata *ad = data;
1217
1218         int ncount = 0;
1219         ail_filter_h f;
1220
1221         DrawAppInfo* pinfo = (DrawAppInfo*)malloc(sizeof(DrawAppInfo));
1222
1223         if (pinfo) {
1224                 pinfo->ncount = 0;
1225                 pinfo->draw_app = draw_3rdapp;
1226                 pinfo->data = ad;
1227
1228                 if (ail_filter_new(&f) == AIL_ERROR_OK)
1229                 {
1230                         if (ail_filter_add_bool(f, AIL_PROP_NODISPLAY_BOOL, false) != AIL_ERROR_OK)
1231                         {
1232                                 SETTING_TRACE("ail filter error");
1233
1234                                 free(pinfo);
1235                                 pinfo = NULL;
1236
1237                                 ail_filter_destroy(f);
1238                                 return 0;
1239                         }
1240
1241                         ail_filter_list_appinfo_foreach(f, __download_apps_cb, pinfo);
1242                         //---------------------------------------------------------------
1243                         ail_filter_destroy(f);
1244                 }
1245                 ncount = pinfo->ncount;
1246
1247                 free(pinfo);
1248                 pinfo = NULL;
1249         }
1250
1251         SETTING_TRACE_END;
1252         return ncount;
1253 }
1254
1255 static int __get_downloaded_apps_num(Cfg_Item_Position inputPos)
1256 {
1257         SETTING_TRACE_BEGIN;
1258         SETTING_TRACE_DEBUG("pos :%d", inputPos);
1259         int downloaded_apps_num = 0;
1260         Cfg_Item_Position tmpPos = Cfg_Item_Pos_Uninstall;
1261         int i, j;
1262         for (i = 0; i < setting_cfg_get_category_length(); i++) {
1263                 if (safeStrCmp
1264                     (setting_cfg_get_category_name(i), KeyStr_DownloadedAPPs))
1265                         continue;
1266
1267                 for (j = 0; j < setting_cfg_get_menu_length(i); j++) {
1268                         tmpPos = (Cfg_Item_Position) setting_cfg_get_pos_idx(i, j);
1269                         if (Cfg_Item_Pos_Level_All == inputPos) {
1270                         } else if (inputPos != tmpPos) {        /* not in the inputPos level */
1271                                 continue;
1272                         }
1273
1274                         downloaded_apps_num++;
1275                 }
1276         }
1277
1278         // draw UI with AUL code
1279 #ifdef PLUGIN
1280         downloaded_apps_num = get_downloadapp_list(NULL);
1281         SETTING_TRACE("Exit %s with return[%d]",__FUNCTION__, downloaded_apps_num);
1282 #endif
1283
1284         SETTING_TRACE("Exit %s with return[%d]",__FUNCTION__, downloaded_apps_num);
1285         return downloaded_apps_num;
1286 }
1287
1288
1289 static void __load_downloaded_apps_menu_list(void *data,
1290                                              Cfg_Item_Position inputPos)
1291 {
1292         SETTING_TRACE_BEGIN;
1293         SETTING_TRACE_DEBUG("pos :%d", inputPos);
1294         setting_main_appdata *ad = data;
1295
1296         // if the number of download apps is zero, display a bottom seperator
1297         if (0 == __get_downloaded_apps_num(inputPos)) {
1298                 Elm_Object_Item *item = NULL;
1299                 item = elm_genlist_item_append(ad->main_genlist, &itc_bottom_seperator, NULL, NULL,
1300                                         ELM_GENLIST_ITEM_NONE, NULL, NULL);
1301                 elm_genlist_item_select_mode_set(item, ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY);
1302                 return;
1303         }
1304
1305         //group title
1306         setting_create_Gendial_field_group_titleItem(ad->main_genlist,
1307                                                      &(ad->itc[GENDIAL_Type_group_item]),
1308                                                      NULL,
1309                                                      ELM_GENLIST_ITEM_NONE,
1310                                                      KeyStr_DownloadedAPPs,
1311                                                      NULL);
1312         get_downloadapp_list(ad);
1313         //SETTING_TRACE("Exit %s with return[%d]",__FUNCTION__, downloaded_apps_num);
1314         SETTING_TRACE_END;
1315 }
1316
1317 static void __load_downloaded_apps_level0_list(void *data)
1318 {
1319         setting_main_appdata *ad = data;
1320         __load_downloaded_apps_menu_list(ad, Cfg_Item_Pos_Level0);
1321 }
1322
1323 static void __load_downloaded_apps_level_all_list(void *data)
1324 {
1325         SETTING_TRACE_BEGIN;
1326         setting_main_appdata *ad = data;
1327         __load_downloaded_apps_menu_list(ad, Cfg_Item_Pos_Level_All);
1328 }
1329
1330 static void __check_all_view_clear(void *data)
1331 {
1332         SETTING_TRACE_BEGIN;
1333         ret_if(!data);
1334         setting_main_appdata *ad = data;
1335         if (ad->item_check_list) {
1336                 eina_list_free(ad->item_check_list);
1337                 ad->item_check_list = NULL;
1338         }
1339
1340         ad->gl_sel_all = NULL;
1341         ad->edit_preferred_genlist  = NULL;
1342         //ad->controllbar_all_check = NULL;
1343         ad->check_all_item =NULL;
1344 }
1345
1346 static void __prefered_buttons_cb(void *data, Evas_Object *obj, void *event_info)
1347 {
1348         SETTING_TRACE_BEGIN;
1349         ret_if(!data);
1350         setting_main_appdata *ad = (setting_main_appdata *) data;
1351         const char *key = NULL;
1352
1353         key = elm_object_text_get(obj);
1354         setting_retm_if(data == NULL
1355                         || key == NULL, "data == NULL || key == NULL");
1356
1357         SETTING_TRACE_DEBUG("press button: %s", key);
1358
1359         // "Done"
1360         if (!safeStrCmp(key, dgettext("sys_string", "IDS_COM_SK_DONE"))) {
1361
1362                 if (ad->profile_type == MAIN_PROFILE_ALL) {
1363                         SETTING_TRACE_DEBUG("Cancel to hide current view.");
1364                         setting_try_save_check_list(ad);        /* need to save too */
1365                         __check_all_view_clear(ad);
1366                         elm_naviframe_item_pop(ad->navibar_main);       // pop(preferred) --> main
1367                         return;
1368                 }
1369
1370                 // MAIN_PROFILE_PREFERRED and Etc
1371                 // redraw setting-main
1372                 setting_try_save_check_list(ad);
1373                 elm_naviframe_item_pop(ad->navibar_main);  // pop (preferred) -> main
1374
1375                 //After the view is popuped, all the object handlers should be reset NULL.
1376                 __check_all_view_clear(ad);
1377                 ad->load_fns[Func_Type_Connectivity] = __load_connectivity_level0_list;
1378                 ad->load_fns[Func_Type_System] = __load_system_level0_list;
1379                 ad->load_fns[Func_Type_Apps] = __load_applications_level0_list;
1380                 ad->load_fns[Func_Type_DownApp] = __load_downloaded_apps_level0_list;
1381                 int ret = setting_main_refresh(ad);
1382                 ret_if(ret != SETTING_RETURN_SUCCESS);
1383                 return;
1384         }
1385
1386         // "Cancel"
1387         if (!safeStrCmp(key, setting_gettext("IDS_COM_SK_CANCEL"))
1388             || !safeStrCmp(key, dgettext("sys_string", "IDS_COM_BODY_BACK"))) {
1389                 SETTING_TRACE_DEBUG("Cancel to hide current view.");
1390                 elm_naviframe_item_pop(ad->navibar_main);
1391                 //After the view is popuped, all the object handlers should be reset NULL.
1392                 __check_all_view_clear(ad);
1393                 return;
1394         }
1395 }
1396
1397
1398 static void __btnback_clicked_cb(void *data, Evas_Object *obj, void *event_info)
1399 {
1400         SETTING_TRACE_BEGIN;
1401         ret_if(!data);
1402         setting_main_appdata *ad = (setting_main_appdata *) data;
1403         elm_win_lower(ad->win_main);
1404 }
1405
1406 static Eina_Bool __refresh_on_idle(void *data)
1407 {
1408         SETTING_TRACE_BEGIN;
1409         retv_if(!data, FALSE);
1410         setting_main_appdata *ad = data;
1411         if (MAIN_PROFILE_ALL == ad->profile_type)
1412         {
1413                 ad->load_fns[Func_Type_Connectivity] = __load_connectivity_level_all_list;
1414                 ad->load_fns[Func_Type_System] = __load_system_level_all_list;
1415                 ad->load_fns[Func_Type_Apps] = __load_applications_level_all_list;
1416                 ad->load_fns[Func_Type_DownApp] = __load_downloaded_apps_level_all_list;
1417                 setting_main_refresh(ad);
1418         }
1419         else if (MAIN_PROFILE_PREFERRED == ad->profile_type)
1420         {
1421                 ad->load_fns[Func_Type_Connectivity] = __load_connectivity_level0_list;
1422                 ad->load_fns[Func_Type_System] = __load_system_level0_list;
1423                 ad->load_fns[Func_Type_Apps] = __load_applications_level0_list;
1424                 ad->load_fns[Func_Type_DownApp] = __load_downloaded_apps_level0_list;
1425                 setting_main_refresh(ad);
1426         }
1427         ad->refresh_idler = NULL;
1428         return FALSE;
1429 }
1430
1431 static void __allFrequent_btn_cb(void *data, Evas_Object *obj, void *event_info)
1432 {
1433         SETTING_TRACE_BEGIN;
1434         ret_if(!data || !obj);
1435         setting_main_appdata *ad = (setting_main_appdata *) data;
1436         //if already has the task,cancel the old task with ecore_idler_del,then add new idler task.
1437         if (ad->refresh_idler) {
1438                 ecore_idler_del(ad->refresh_idler);
1439                 ad->refresh_idler = NULL;
1440         }
1441
1442         //Elm_Object_Item *item = elm_toolbar_first_item_get(obj);
1443         //ret_if(!item);
1444         if (MAIN_PROFILE_ALL == ad->profile_type)
1445         {
1446                 SETTING_TRACE("Change to Preferred view");
1447                 elm_object_text_set(obj, _(ALL_STR));
1448                 ad->profile_type = MAIN_PROFILE_PREFERRED;
1449         }
1450         else if (MAIN_PROFILE_PREFERRED == ad->profile_type)
1451         {
1452                 SETTING_TRACE("Change to ALL view");
1453                 elm_object_text_set(obj, _(PREFERRED_STR));
1454                 ad->profile_type = MAIN_PROFILE_ALL;
1455         }
1456         else
1457         {
1458                 return;
1459         }
1460         ad->refresh_idler = ecore_idler_add((Ecore_Task_Cb) __refresh_on_idle, ad);
1461 }
1462
1463 static void __setting_show_title_toolbar(void *data, Evas_Object *obj, void *event_info)
1464 {
1465     SETTING_TRACE_BEGIN;
1466     //elm_object_item_signal_emit(data, "elm,state,sip,shown", "");
1467     setting_main_appdata *ad = (setting_main_appdata *) data;
1468
1469     Evas_Object *navi_bar = NULL;
1470
1471     if (ad->isInUGMode && ad->ug) {
1472         Evas_Object *layout = (Evas_Object *)ug_get_layout(ad->ug);
1473         if (layout)
1474             navi_bar = elm_object_part_content_get(layout, "elm.swallow.content");
1475     } else {
1476         navi_bar = ad->navibar_main;
1477     }
1478
1479     const char *support = evas_object_data_get(navi_bar, "sip.naviframe.title_obj");
1480     SETTING_TRACE("support:%s", support);
1481     if (support)
1482     {
1483         Elm_Object_Item *top_item = elm_naviframe_top_item_get(navi_bar);
1484         if (top_item)
1485             elm_object_item_signal_emit(top_item, "elm,state,sip,shown", "");
1486     }
1487 }
1488
1489 static void __setting_hide_title_toolbar(void *data, Evas_Object *obj, void *event_info)
1490 {
1491     SETTING_TRACE_BEGIN;
1492     //elm_object_item_signal_emit(data, "elm,state,sip,hidden", "");
1493     setting_main_appdata *ad = (setting_main_appdata *) data;
1494
1495     Evas_Object *navi_bar = NULL;
1496
1497     if (ad->isInUGMode && ad->ug) {
1498         Evas_Object *layout = (Evas_Object *)ug_get_layout(ad->ug);
1499         if (layout)
1500             navi_bar = elm_object_part_content_get(layout, "elm.swallow.content");
1501     } else {
1502         navi_bar = ad->navibar_main;
1503     }
1504
1505     const char *support = evas_object_data_get(navi_bar, "sip.naviframe.title_obj");
1506
1507     SETTING_TRACE("support:%s", support);
1508     if (support)
1509     {
1510         Elm_Object_Item *top_item = elm_naviframe_top_item_get(navi_bar);
1511         if (top_item)
1512             elm_object_item_signal_emit(top_item, "elm,state,sip,hidden", "");
1513     }
1514 }
1515
1516 static bool __setting_create_main_view(void *data)
1517 {
1518         SETTING_TRACE_BEGIN;
1519         /* error check */
1520         setting_retvm_if(data == NULL, FALSE, "data == NULL");
1521         setting_main_appdata *ad = (setting_main_appdata *) data;
1522
1523         Evas_Object *conform = elm_conformant_add(ad->win_main);
1524         ad->ly_main = setting_create_win_layout(ad->win_main, ad->win_main);
1525         evas_object_size_hint_weight_set(conform, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
1526         evas_object_size_hint_align_set(conform, EVAS_HINT_FILL, EVAS_HINT_FILL);
1527         elm_win_resize_object_add(ad->win_main, conform);
1528         elm_object_content_set(conform, ad->ly_main);
1529         evas_object_show(conform);
1530
1531     evas_object_smart_callback_add(conform, "virtualkeypad,state,on", __setting_show_title_toolbar, ad);
1532     evas_object_smart_callback_add(conform, "virtualkeypad,state,off", __setting_hide_title_toolbar, ad);
1533
1534         elm_win_conformant_set(ad->win_main, EINA_TRUE);
1535
1536         ad->conform = conform;
1537
1538         ad->navibar_main = setting_create_navi_bar(ad->ly_main);
1539
1540         ad->main_genlist = elm_genlist_add(ad->navibar_main);
1541         elm_object_style_set(ad->main_genlist, "dialogue");
1542         retvm_if(ad->main_genlist == NULL, FALSE,
1543                  "Cannot set scroller object as contento of layout");
1544
1545         //elm_genlist_homogeneous_set(ad->main_genlist, EINA_TRUE);
1546         elm_genlist_clear(ad->main_genlist);    /* first to clear list */
1547         evas_object_smart_callback_add(ad->main_genlist, "realized", __gl_realized, ad);
1548
1549         setting_create_navi_bar_buttons(_("IDS_COM_BODY_SETTINGS"),
1550                                         _("IDS_COM_BODY_BACK"), NULL, _("IDS_ST_OPT_ALL"),
1551                                         __btnback_clicked_cb, NULL,
1552                                         __allFrequent_btn_cb, ad, ad->main_genlist,
1553                                         ad->navibar_main, NULL);
1554
1555         ad->profile_type = MAIN_PROFILE_PREFERRED;
1556         ad->load_fns[Func_Type_Connectivity] = __load_connectivity_level0_list;
1557         ad->load_fns[Func_Type_System] = __load_system_level0_list;
1558         ad->load_fns[Func_Type_Apps] = __load_applications_level_all_list;
1559         ad->load_fns[Func_Type_DownApp] = __load_downloaded_apps_level_all_list;
1560         setting_main_refresh(ad);
1561         return TRUE;
1562 }
1563
1564 static bool __setting_create_prefered_view(void *data)
1565 {
1566         SETTING_TRACE_BEGIN;
1567         /* error check */
1568         setting_retvm_if(data == NULL, FALSE, "data == NULL");
1569         setting_main_appdata *ad = (setting_main_appdata *) data;
1570
1571         /* the genlist will be destroyed with its parent view, when using elm_naviframe_item_pop() to destroy the view. */
1572         ad->edit_preferred_genlist = elm_genlist_add(ad->win_main);
1573         elm_object_style_set(ad->edit_preferred_genlist, "dialogue");
1574         elm_genlist_clear(ad->edit_preferred_genlist);  /* first to clear list */
1575
1576         /*  [UI] edit preffered view */
1577         Evas_Object *sub_layout = elm_layout_add(ad->win_main);
1578         elm_object_style_set(sub_layout, "dialogue");
1579         elm_layout_file_set(sub_layout, SETTING_THEME_EDJ_NAME, "search_layout");
1580         evas_object_size_hint_weight_set(sub_layout, EVAS_HINT_EXPAND, 0.0);
1581         evas_object_show(sub_layout);
1582
1583         ad->gl_sel_all = elm_genlist_add(ad->win_main);
1584         elm_genlist_clear(ad->gl_sel_all);      /* first to clear list */
1585         elm_genlist_bounce_set(ad->gl_sel_all, 0, 0);
1586
1587         elm_object_part_content_set(sub_layout, "search_bar", ad->gl_sel_all);  /*  add 'Select all' */
1588         elm_object_part_content_set(sub_layout, "search_list", ad->edit_preferred_genlist);     /*  add Genlist */
1589
1590         /*  push, not create */
1591         setting_push_layout_navi_bar(_(EDIT_PREFERRED_STR),
1592                                      _("IDS_COM_SK_CANCEL"),
1593                                      _("IDS_COM_SK_DONE"), NULL,
1594                                      __prefered_buttons_cb, __prefered_buttons_cb, NULL, ad,
1595                                      sub_layout, ad->navibar_main,
1596                                      NULL);
1597         SETTING_TRACE_END;
1598         return TRUE;
1599 }
1600
1601 static void setting_main_tapi_event_cb(TapiHandle *handle, int result, void *data, void *user_data)
1602 {
1603         SETTING_TRACE_BEGIN;
1604         ret_if(!user_data);
1605         setting_main_appdata *ad = user_data;
1606         ad->b_fm_requesting = FALSE;
1607         SETTING_TRACE("result:%d", result);
1608
1609         int err = 0;
1610         switch (result) {
1611         case TAPI_POWER_FLIGHT_MODE_RESP_ON:
1612
1613                 setting_set_bool_slp_key(BOOL_SLP_SETTING_FLIGHT_MODE,
1614                                          SETTING_ON_OFF_BTN_ON, &err);
1615
1616                 //If Setting has validate operation (fm_waiting_op == FM_LEAVE) to process, process it.
1617                 //Otherwise, do nothing
1618                 if (FM_LEAVE == ad->fm_waiting_op)
1619                 {
1620                         //Send the latest operation
1621                         ad->fm_waiting_op = FM_INVALID;
1622                         err = tel_set_flight_mode(ad->handle, TAPI_POWER_FLIGHT_MODE_LEAVE,setting_main_tapi_event_cb,ad);
1623                         setting_retm_if(err != TAPI_API_SUCCESS,
1624                                         "*** [ERR] tel_set_flight_mode(TAPI_POWER_FLIGHT_MODE_LEAVE) ***");
1625
1626                         //sucessfully sent,
1627                         ad->b_fm_requesting = TRUE;
1628
1629                 }
1630                 break;
1631
1632         case TAPI_POWER_FLIGHT_MODE_RESP_OFF:
1633
1634                 setting_set_bool_slp_key(BOOL_SLP_SETTING_FLIGHT_MODE,
1635                                          SETTING_ON_OFF_BTN_OFF, &err);
1636
1637                 //If Setting has validate operation (here, fm_waiting_op == FM_ENTER) to process,process it.
1638                 //Otherwise, do nothing
1639                 if (FM_ENTER == ad->fm_waiting_op)
1640                 {
1641                         //Send the latest operation
1642                         ad->fm_waiting_op = FM_INVALID;
1643                         err = tel_set_flight_mode(ad->handle, TAPI_POWER_FLIGHT_MODE_ENTER,setting_main_tapi_event_cb,ad);
1644                         setting_retm_if(err != TAPI_API_SUCCESS,
1645                                         "*** [ERR] tel_set_flight_mode(TAPI_POWER_FLIGHT_MODE_ENTER) ***");
1646
1647                         //sucessfully sent,
1648                         ad->b_fm_requesting = TRUE;
1649                 }
1650
1651                 break;
1652
1653         case TAPI_POWER_FLIGHT_MODE_RESP_FAIL:
1654                 //Setting has a validate operation to process, Send the operation request
1655                 if (FM_ENTER == ad->fm_waiting_op)
1656                 {
1657                         ad->fm_waiting_op = FM_INVALID;
1658                         err = tel_set_flight_mode(ad->handle, TAPI_POWER_FLIGHT_MODE_ENTER,setting_main_tapi_event_cb,ad);
1659
1660                         setting_retm_if(err != TAPI_API_SUCCESS,
1661                                         "*** [ERR] tel_set_flight_mode(TAPI_POWER_FLIGHT_MODE_ENTER) ***");
1662                         ad->b_fm_requesting = TRUE;
1663                 }
1664                 else if (FM_LEAVE == ad->fm_waiting_op)
1665                 {
1666                         ad->fm_waiting_op = FM_INVALID;
1667                         err = tel_set_flight_mode(ad->handle, TAPI_POWER_FLIGHT_MODE_LEAVE,setting_main_tapi_event_cb,ad);
1668
1669                         setting_retm_if(err != TAPI_API_SUCCESS,
1670                                         "*** [ERR] tel_set_flight_mode(TAPI_POWER_FLIGHT_MODE_LEAVE) ***");
1671                         ad->b_fm_requesting = TRUE;
1672                 }
1673                 else //Current requset is the last one, Setting needs to notify user
1674                 {
1675                         setting_create_popup_without_btn(ad, ad->win_main,
1676                                              _("IDS_COM_POP_ERROR"),
1677                                              _("IDS_ST_POP_UNABLE_TO_TURN_ON_FLIGHT_MODE_VODA"),
1678                                              NULL, POPUP_INTERVAL,
1679                                              FALSE, FALSE);
1680
1681                         //It is need to rollback the status,
1682                         if (ad->data_flight) {
1683                                 ad->data_flight->chk_status = !ad->data_flight->chk_status;
1684                                 elm_check_state_set(ad->data_flight->eo_check, ad->data_flight->chk_status);
1685                         }
1686                         return;
1687                 }
1688
1689                 //sucessfully sent,
1690                 ad->b_fm_requesting = TRUE;
1691
1692                 break;
1693
1694         case TAPI_POWER_FLIGHT_MODE_RESP_MAX:
1695                 setting_create_popup_without_btn(ad, ad->win_main,
1696                                      _("IDS_COM_POP_ERROR"),
1697                                      _("IDS_COM_POP_UNEXPECTED_ERROR"),
1698                                      NULL, POPUP_INTERVAL, FALSE, FALSE);
1699
1700                 //It is need to rollback the status,
1701                 if (ad->data_flight) {
1702                         ad->data_flight->chk_status = !ad->data_flight->chk_status;
1703                         elm_check_state_set(ad->data_flight->eo_check, ad->data_flight->chk_status);
1704                 }
1705                 break;
1706         default:
1707                 /* do nothing */
1708                 break;
1709         }
1710         return;
1711 }
1712
1713 static int setting_main_refresh(void *data)
1714 {
1715         SETTING_TRACE_BEGIN;
1716         setting_main_appdata *ad = (setting_main_appdata *) data;
1717         elm_genlist_clear(ad->main_genlist);    /* first to clear list */
1718
1719 #if 0
1720         if (is_ug_installed_by_ug_args("rcs-config"))
1721         {
1722                 Elm_Object_Item *item = elm_genlist_item_append(ad->main_genlist, &itc_seperator, NULL, NULL,
1723                                             ELM_GENLIST_ITEM_NONE, NULL, NULL);
1724                 elm_genlist_item_select_mode_set(item, ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY);
1725                 setting_create_Gendial_field_groupitem(ad->main_genlist,
1726                                                        &(ad->itc[GENDIAL_Type_1text_1icon_2]),
1727                                                        NULL,
1728                                                        setting_main_click_list_ex_ug_cb,
1729                                                        "rcs-config",
1730                                                        SWALLOW_Type_INVALID,
1731                                                        IMG_Joyn, NULL,
1732                                                        0, KeyStr_Joyn, NULL,
1733                                                        NULL);
1734         }
1735 #endif
1736
1737         int i;
1738         for(i = Func_Type_Connectivity; i < Func_Type_MAX; i++)
1739                 (ad->load_fns[i]) (ad);
1740
1741         memset(ad->load_fns, 0, Func_Type_MAX *sizeof(menu_list_load_fn));
1742         SETTING_TRACE_END;
1743         return SETTING_RETURN_SUCCESS;
1744 }
1745
1746 static int setting_main_create(void *cb)
1747 {
1748         retv_if(cb == NULL, SETTING_GENERAL_ERR_NULL_DATA_PARAMETER);
1749
1750         setting_main_appdata *ad = (setting_main_appdata *) cb;
1751         g_main_ad = ad;
1752         //pass NULL to let TAPI access default module
1753         ad->handle = tel_init(NULL);
1754         if (!ad->handle) {
1755                 SETTING_TRACE_ERROR("*** [ERR] tel_init failed ***");
1756         } else {
1757                 SETTING_TRACE("tel_init ok[handle:%p]", ad->handle);
1758         }
1759         setting_create_Gendial_itc("dialogue/1text.1icon.2",
1760                                    &(ad->itc[GENDIAL_Type_1text_1icon_2]));
1761         setting_create_Gendial_itc("dialogue/1text.2icon",
1762                                    &(ad->itc[GENDIAL_Type_1text_2icon]));
1763         setting_create_Gendial_itc("dialogue/2text.1icon.3",
1764                                    &(ad->itc[GENDIAL_Type_1icon_2text]));
1765         setting_create_Gendial_itc("dialogue/1text.1icon.2",
1766                                    &(ad->itc[GENDIAL_Type_1text_2icon_2]));
1767         setting_create_Gendial_itc("dialogue/2text.2icon.3",
1768                                    &(ad->itc[GENDIAL_Type_2text_2icon_3]));
1769         setting_create_Gendial_itc("dialogue/title",
1770                                    &(ad->itc[GENDIAL_Type_group_item]));
1771         setting_create_Gendial_itc("select_all",
1772                                    &(ad->itc[GENDIAL_Type_sel_all]));
1773
1774         setting_create_Gendial_itc("dialogue/2text.3", &(ad->itc[GENDIAL_Type_2text_3]));
1775
1776         ad->view_type = SETTING_VIEW_MAIN;
1777         __setting_create_main_view(ad);
1778
1779         setting_view_main.is_create = 1;
1780
1781         return SETTING_RETURN_SUCCESS;
1782 }
1783
1784 static int setting_main_destroy(void *cb)
1785 {
1786         SETTING_TRACE_BEGIN;
1787         /* error check */
1788         retv_if(cb == NULL, SETTING_GENERAL_ERR_NULL_DATA_PARAMETER);
1789
1790         setting_main_appdata *ad = (setting_main_appdata *) cb;
1791         if (0 == setting_view_main.is_create)
1792         {
1793                 //already not exsit
1794                 return SETTING_RETURN_SUCCESS;
1795         }
1796
1797     evas_object_smart_callback_del(ad->conform, "virtualkeypad,state,on", __setting_show_title_toolbar);
1798     evas_object_smart_callback_del(ad->conform, "virtualkeypad,state,off", __setting_hide_title_toolbar);
1799
1800         if (ad->refresh_idler) {
1801                 ecore_idler_del(ad->refresh_idler);
1802                 ad->refresh_idler = NULL;
1803         }
1804
1805         if (ad->handle) {
1806                 int tapi_ret = tel_deinit(ad->handle);
1807                 if (tapi_ret != TAPI_API_SUCCESS) {
1808                         SETTING_TRACE_DEBUG("*** [ERR] tel_deinit. [%d] ***", tapi_ret);
1809                 } else {
1810                         SETTING_TRACE("***  tel_deinit OK ");
1811                 }
1812                 ad->handle = NULL;
1813         }
1814
1815         /* then destroy the UI object. */
1816         if (ad->item_check_list) {
1817                 eina_list_free(ad->item_check_list);
1818                 ad->item_check_list = NULL;
1819         } else {
1820                 SETTING_TRACE("*** ad->item_check_list is NULL - abnormal state ");
1821         }
1822
1823         if (ad->ly_main) {
1824                 evas_object_del(ad->ly_main);
1825                 ad->ly_main = NULL;
1826         }
1827
1828         if (ad->flight_popup) {
1829                 evas_object_del(ad->flight_popup);
1830                 ad->flight_popup = NULL;
1831         }
1832
1833 #if 0
1834         if (ad->plugin_node)
1835         {
1836                 setting_plugin_destroy(ad->plugin_node);
1837         }
1838 #endif
1839
1840         evas_object_smart_callback_del(ad->main_genlist, "realized", __gl_realized);
1841
1842         setting_view_main.is_create = 0;
1843         SETTING_TRACE_END;
1844         return SETTING_RETURN_SUCCESS;
1845 }
1846
1847 static int setting_main_update(void *cb)
1848 {
1849         SETTING_TRACE_BEGIN;
1850
1851         /* error check */
1852         retv_if(cb == NULL, SETTING_GENERAL_ERR_NULL_DATA_PARAMETER);
1853
1854         setting_main_appdata *ad = (setting_main_appdata *) cb;
1855
1856         if (ad->ly_main != NULL) {
1857                 //evas_object_show(ad->ly_main);
1858         }
1859
1860         return SETTING_RETURN_SUCCESS;
1861 }
1862
1863 static int setting_main_cleanup(void *cb)
1864 {
1865         SETTING_TRACE_BEGIN;
1866         /* error check */
1867         retv_if(cb == NULL, SETTING_GENERAL_ERR_NULL_DATA_PARAMETER);
1868
1869         setting_main_appdata *ad = (setting_main_appdata *) cb;
1870
1871         if (ad->ly_main != NULL) {
1872                 //evas_object_hide(ad->ly_main);
1873         }
1874
1875         return SETTING_RETURN_SUCCESS;
1876 }
1877
1878 /* ***************************************************
1879  *
1880  *general func
1881  *
1882  ***************************************************/
1883
1884 void setting_update_gl_item(void* data)
1885 {
1886         SETTING_TRACE_BEGIN;
1887         setting_main_appdata *ad = data;
1888         retm_if(!data, "Invalid argument: data is NULL");
1889
1890         int nDx = 0;
1891         Eina_Bool bGlUpdate = EINA_FALSE;
1892         Setting_GenGroupItem_Data *item_to_update = NULL;
1893
1894         for(;nDx<GL_ITEM_MAX; nDx++) {
1895                 if(EINA_TRUE == ad->updateItems[nDx]) {
1896                         switch (nDx)
1897                         {
1898                         case GL_ITEM_WIFI:
1899                                 item_to_update = ad->data_wifi;
1900                                 bGlUpdate = EINA_TRUE;
1901                                 break;
1902                         case GL_ITEM_BT:
1903                                 item_to_update = ad->data_bt;
1904                                 bGlUpdate = EINA_TRUE;
1905                                 break;
1906                         case GL_ITEM_NFC:
1907                                 item_to_update = ad->data_nfc;
1908                                 bGlUpdate = EINA_TRUE;
1909                                 break;
1910                         case GL_ITEM_FLIGHT:
1911                                 item_to_update = ad->data_flight;
1912                                 bGlUpdate = EINA_FALSE;
1913                                 break;
1914
1915
1916
1917
1918                         default: // other case
1919                                 continue;
1920                         }
1921
1922                         if (item_to_update) {
1923                                 SETTING_TRACE("gl update [%s], bGlUpdate:%d", _(item_to_update->keyStr), bGlUpdate);
1924                                 if(bGlUpdate) {
1925                                         SETTING_TRACE("gl update:%d", nDx);
1926                                         elm_object_item_data_set(item_to_update->item, item_to_update);
1927                                         elm_genlist_item_update(item_to_update->item);
1928                                 } else {
1929                                         SETTING_TRACE("chk update:%d", nDx);
1930                                         elm_check_state_set(item_to_update->eo_check, item_to_update->chk_status);
1931                                 }
1932                         }
1933
1934                         ad->updateItems[nDx] = EINA_FALSE;
1935                 } // if(EINA_TRUE == ad->updateItems[nDx])
1936
1937         }
1938
1939         SETTING_TRACE_END;
1940         return;
1941 }
1942
1943 void setting_main_destroy_ug_cb(ui_gadget_h ug, void *priv)
1944 {
1945         setting_main_appdata *ad = (setting_main_appdata *) priv;
1946         if (!ad)
1947                 return;         /*  do nothing if ad is NULL */
1948
1949         if (ug) {
1950                 ug_destroy(ug);
1951                 ad->ug = NULL;
1952         }
1953
1954         setting_main_click_list_item_reset_data(ad, NULL);
1955
1956         // update main genlist in unloading UG
1957         SETTING_TRACE("update main genlist in unloading UG");
1958         setting_update_gl_item(ad);
1959
1960         SETTING_TRACE_END;
1961 }
1962
1963 void setting_main_result_ug_cb(ui_gadget_h ug, service_h service,
1964                                       void *priv)
1965 {
1966         if (!priv) return;
1967
1968         // set default local automatically
1969         set_defaultLangICU();
1970 }
1971
1972 void setting_main_layout_ug_cb(ui_gadget_h ug, enum ug_mode mode,
1973                                       void *priv)
1974 {
1975         setting_main_appdata *ad = (setting_main_appdata *) priv;
1976         Evas_Object *base;
1977
1978         if (!priv)
1979                 return;
1980         SETTING_TRACE_BEGIN;
1981
1982         base = (Evas_Object *) ug_get_layout(ug);
1983         if (!base)
1984                 return;
1985
1986         switch (mode) {
1987         case UG_MODE_FULLVIEW:
1988                 evas_object_size_hint_weight_set(base, EVAS_HINT_EXPAND,
1989                                                  EVAS_HINT_EXPAND);
1990                 evas_object_show(base);
1991                 break;
1992         default:
1993                 break;
1994         }
1995
1996         SETTING_TRACE_END;
1997 }
1998
1999 /* ***************************************************
2000  *
2001  *call back func
2002  *
2003  ***************************************************/
2004
2005 void setting_main_click_list_item_reset_data(void *data,
2006                                                     Evas_Object *obj)
2007 {
2008         SETTING_TRACE_BEGIN;
2009         setting_main_appdata *ad = (setting_main_appdata *) data;
2010
2011         ad->isInUGMode = FALSE;
2012
2013         SETTING_TRACE_END;
2014 }
2015
2016 void /* obj is the layout clicked */
2017 setting_main_click_list_item_ug_cb(void *data, Evas_Object *obj,
2018                                    char *ug_to_load, service_h svc,
2019                                    struct ug_cbs *cbs)
2020 {
2021         SETTING_TRACE_BEGIN;
2022         setting_main_appdata *ad = (setting_main_appdata *) data;
2023         if (!ug_to_load) {
2024                 setting_create_simple_popup(ad, ad->win_main, NULL, NO_UG_FOUND_MSG);
2025                 return;
2026         }
2027 #if DISABLED_CODE
2028         char ug_file[PATH_MAX];
2029         if (snprintf
2030             (ug_file, PATH_MAX, "%s/libug-%s.so", SETTING_UG_PATH,
2031              ug_to_load) < 0)
2032                 return;
2033         SETTING_TRACE("ug_file:%s", ug_file);
2034         if (!ecore_file_exists(ug_file)) {
2035                 setting_create_simple_popup(ad, ad->win_main, NULL, NO_UG_FOUND_MSG);
2036                 return;
2037         }
2038 #endif
2039         SETTING_TRACE("to create libug-%s.so", ug_to_load);
2040         ad->ug = ug_create(NULL, ug_to_load, UG_MODE_FULLVIEW, svc, cbs);
2041         if (ad->ug) {
2042                 ad->isInUGMode = TRUE;
2043                 memset(ad->cur_loaded_ug, 0x00, MAX_DISPLAY_NAME_LEN_ON_UI);
2044                 safeCopyStr(ad->cur_loaded_ug, ug_to_load, MAX_DISPLAY_NAME_LEN_ON_UI);
2045         } else {
2046
2047                 evas_object_show(ad->ly_main);
2048
2049                 SETTING_TRACE_ERROR("errno:%d", errno);
2050                 setting_create_simple_popup(ad, ad->win_main, NULL, NO_UG_FOUND_MSG);
2051         }
2052         SETTING_TRACE_END;
2053 }
2054
2055 void
2056 setting_main_click_list_default_ug_cb(void *data, Evas_Object *obj,
2057                                       void *event_info)
2058 {
2059         setting_main_appdata *ad = data;
2060         setting_create_simple_popup(ad, ad->win_main, NULL,
2061                                           NO_UG_FOUND_MSG);
2062 }
2063
2064 void
2065 setting_main_click_list_usb_cb(void *data, Evas_Object *obj, void *event_info)
2066 {
2067         SETTING_TRACE_BEGIN;
2068         retm_if(event_info == NULL, "Invalid argument: event info is NULL");
2069
2070         int err;
2071         int value = -1;
2072         char *str_text = USB_NEED_OFF;
2073
2074         Elm_Object_Item *item = (Elm_Object_Item *) event_info;
2075 #if 0
2076         setting_get_int_slp_key(INT_SLP_SETTING_MOBILE_AP_STATUS, &value, &err);
2077         if (err != 0)
2078         {
2079                 SETTING_TRACE_ERROR("FAIL: VCONFKEY_MOBILE_HOTSPOT_MODE may not exist\n");
2080                 setting_main_click_list_ex_ug_cb(data, obj, item);
2081                 return;
2082         }
2083 #endif
2084         /* If mobile hotspot is on, going USB utilties is blocked by a popup*/
2085         if (value & VCONFKEY_MOBILE_HOTSPOT_MODE_USB)
2086         {
2087                 elm_genlist_item_selected_set(item, EINA_FALSE);
2088                 setting_create_simple_popup(g_main_ad, g_main_ad->win_main, NULL, (str_text));
2089         }
2090         else
2091         {
2092                 setting_main_click_list_ex_ug_cb(data, obj, item);
2093         }
2094
2095         SETTING_TRACE_END;
2096 }
2097
2098 void setting_main_click_list_more_cb(void *data, Evas_Object *obj, void *event_info)
2099 {
2100         SETTING_TRACE_BEGIN;
2101         retm_if(event_info == NULL, "Invalid argument: event info is NULL");
2102         Elm_Object_Item *item = (Elm_Object_Item *) event_info;
2103         elm_genlist_item_selected_set(item, EINA_FALSE);
2104         retm_if(data == NULL, "Invalid argument: data is NULL");
2105         setting_main_appdata *ad = data;
2106         Setting_GenGroupItem_Data *selected_item_data =
2107                     (Setting_GenGroupItem_Data *) elm_object_item_data_get(item);
2108         SETTING_TRACE("selected_item_data->keyStr:%s", selected_item_data->keyStr);
2109         if (0 == safeStrCmp(selected_item_data->keyStr, KeyStr_MoreConnect))
2110         {
2111                 ad->view_load = SETTING_VIEW_CONNECTIVE_MORE;
2112         }
2113         else if (0 == safeStrCmp(selected_item_data->keyStr, KeyStr_MoreSystem))
2114         {
2115                 ad->view_load = SETTING_VIEW_SYSTEM_MORE;
2116         }
2117         else
2118         {
2119                 return;
2120         }
2121         setting_view_change(&setting_view_main, &setting_view_more_menu, ad);
2122 }
2123
2124
2125 void
2126 setting_main_click_list_ex_ug_cb(void *data, Evas_Object *obj,
2127                                  void *event_info)
2128 {
2129         SETTING_TRACE_BEGIN;
2130         retm_if(event_info == NULL, "Invalid argument: event info is NULL");
2131         Elm_Object_Item *item = (Elm_Object_Item *) event_info;
2132
2133         elm_genlist_item_selected_set(item, EINA_FALSE);
2134
2135         if (g_main_ad->ug) {
2136                 SETTING_TRACE
2137                     ("[ad->ug non-NULL]skip genlist click event!!");
2138
2139                 SETTING_TRACE_END;
2140                 return;
2141         }
2142
2143         if (NULL == data) {     /* pass NULL to ug_args when create setting.cfg. */
2144                 setting_create_simple_popup(g_main_ad,
2145                                           g_main_ad->win_main,
2146                                           NULL, NO_UG_FOUND_MSG);
2147                 SETTING_TRACE_END;
2148                 return;
2149         }
2150
2151         setting_main_appdata *ad = g_main_ad;
2152
2153         /*  if UG is created by Setting app, setting_main_click_list_ex_ug_cb is diabled. */
2154         if (ad->isInUGMode) {
2155                 SETTING_TRACE("isInUGMode : TRUE - another UG is running now.");
2156                 ad->isInUGMode = FALSE;
2157                 SETTING_TRACE_END;
2158                 return;
2159         } else {
2160                 SETTING_TRACE
2161                     ("isInUGMode : FALSE - another UG is NOT running now.")
2162         }
2163
2164         Setting_GenGroupItem_Data *selected_item_data =
2165             (Setting_GenGroupItem_Data *) elm_object_item_data_get(item);
2166         setting_main_click_list_item_reset_data(ad, obj);
2167         const char *item_name = _(selected_item_data->keyStr);
2168         ret_if(!item_name);
2169
2170         struct ug_cbs *cbs = (struct ug_cbs *)calloc(1, sizeof(struct ug_cbs));
2171         setting_retm_if(!cbs, "calloc failed");
2172         cbs->layout_cb = setting_main_layout_ug_cb;
2173         cbs->result_cb = setting_main_result_ug_cb;
2174         cbs->destroy_cb = setting_main_destroy_ug_cb;
2175         cbs->priv = (void *)ad;
2176
2177         char *path = get_ug_path_from_ug_args(data);
2178         service_h svc = get_bundle_from_ug_args(data);
2179         setting_main_click_list_item_ug_cb(ad, obj, path, svc, cbs);
2180         if (path)
2181                 FREE(path);
2182         if (cbs)
2183                 FREE(cbs);
2184         path = NULL;
2185         cbs = NULL;
2186         service_destroy(svc);
2187 }
2188 void
2189 setting_main_click_list_plugin_cb(void *data, Evas_Object *obj,
2190                                  void *event_info)
2191 {
2192         SETTING_TRACE_BEGIN;
2193         retm_if(event_info == NULL, "Invalid argument: event info is NULL");
2194         Elm_Object_Item *item = (Elm_Object_Item *) event_info;
2195         elm_genlist_item_selected_set(item, EINA_FALSE);
2196
2197         setting_main_appdata *ad = data;
2198         if (ad->plugin_path)
2199         {
2200                 PluginNode* plugin_node = setting_plugin_create();
2201
2202                 plugin_node->plugin_path = strdup(ad->plugin_path);
2203
2204                 setting_plugin_load(plugin_node, (const char *)ad->plugin_path);
2205                 ad->plugin_node = (void*)plugin_node;
2206
2207                 #if 0
2208                 if(ad->plugin_path)
2209                 {
2210                         free(ad->plugin_path);
2211                         ad->plugin_path = NULL;
2212                 }
2213                 #endif
2214         }
2215 }
2216
2217 /**
2218  * @see [caller] setting_main_list_mouse_up_cb
2219  * @see [caller] setting_main_sel_list_mouse_up_cb
2220  */
2221 static void __rotate_lock_handler(int chk_status, setting_main_appdata *ad )
2222 {
2223         SETTING_TRACE_BEGIN;
2224         if( chk_status == 1)
2225         {
2226                 // toggle : 0 --> 1
2227                 int angle = elm_win_rotation_get(ad->win_main);
2228                 elm_win_rotation_with_resize_set(ad->win_main, angle);
2229         } else {
2230                 elm_win_rotation_with_resize_set(ad->win_main, 0);
2231         }
2232         vconf_set_bool(VCONFKEY_SETAPPL_AUTO_ROTATE_SCREEN_BOOL, chk_status);
2233 }
2234
2235 /**
2236  * toggle cb
2237  */
2238 void setting_main_list_mouse_up_cb(void *data, Evas_Object *eo,
2239                                           void *event_info)
2240 {
2241         SETTING_TRACE_BEGIN;
2242         retm_if(data == NULL, "Data parameter is NULL");
2243         Setting_GenGroupItem_Data *list_item =
2244             (Setting_GenGroupItem_Data *) data;
2245         SETTING_TRACE("process item [%s]", list_item->keyStr);
2246         list_item->chk_status = elm_check_state_get(eo);        /* for update new state */
2247
2248         SETTING_TRACE("change radio[%s], status is:%d", _(list_item->keyStr),
2249                       list_item->chk_status);
2250         setting_main_appdata *ad = g_main_ad;
2251
2252         if (!safeStrCmp(KeyStr_UsePacketData, list_item->keyStr)) {
2253                 int err;
2254                 if (elm_check_state_get(eo)) {
2255                         setting_set_bool_slp_key
2256                             (BOOL_SLP_SETTING_USE_PACKET_DATA,
2257                              SETTING_ON_OFF_BTN_ON, &err);
2258                 } else {
2259                         setting_set_bool_slp_key
2260                             (BOOL_SLP_SETTING_USE_PACKET_DATA,
2261                              SETTING_ON_OFF_BTN_OFF, &err);
2262                 }
2263
2264         } else if (!safeStrCmp(KeyStr_Landscape, list_item->keyStr)) {
2265                 __rotate_lock_handler(list_item->chk_status, ad);
2266         }
2267
2268         return;
2269 }
2270
2271 /**
2272  * genlist touch cb
2273  */
2274 void setting_main_sel_list_mouse_up_cb(void *data, Evas_Object *eo,
2275                                               void *event_info)
2276 {
2277         SETTING_TRACE_BEGIN;
2278         setting_retm_if(data == NULL, "Data parameter is NULL");
2279
2280         retm_if(event_info == NULL, "Invalid argument: event info is NULL");
2281         Elm_Object_Item *item = (Elm_Object_Item *) event_info;
2282         elm_genlist_item_selected_set(item, 0);
2283         Setting_GenGroupItem_Data *list_item =
2284             (Setting_GenGroupItem_Data *) elm_object_item_data_get(item);
2285
2286         list_item->chk_status = elm_check_state_get(list_item->eo_check);
2287
2288         /* new status */
2289     list_item->chk_status = !list_item->chk_status;
2290     elm_check_state_set(list_item->eo_check, list_item->chk_status);
2291
2292         setting_main_appdata *ad = (setting_main_appdata *) data;
2293         if (!safeStrCmp(KeyStr_UsePacketData, list_item->keyStr)) {
2294                 /* setting_reset_slp_key_by_status(eo, BOOL_SLP_SETTING_USE_PACKET_DATA); */
2295                 int err;
2296                 setting_set_bool_slp_key(BOOL_SLP_SETTING_USE_PACKET_DATA,
2297                                          list_item->chk_status, &err);
2298
2299         } else if (!safeStrCmp(KeyStr_Landscape, list_item->keyStr)) {
2300                 __rotate_lock_handler(list_item->chk_status, ad);
2301         }
2302
2303         return;
2304 }
2305
2306 void __alternate_flight_mode(Evas_Object *check)
2307 {
2308         SETTING_TRACE_BEGIN;
2309         int ret;
2310         Eina_Bool status =  elm_check_state_get(check);
2311         SETTING_TRACE("flight mode status : %d", status);
2312         setting_main_appdata *ad = g_main_ad;
2313
2314         //Check whether some requestion is processing by TAPI
2315         if (ad->b_fm_requesting)
2316         {
2317                 //Do nothing, just mark the lastest operation..
2318                 SETTING_TRACE("Some requestion is processing by TAPI, wait to process");
2319                 ad->fm_waiting_op = status ? FM_ENTER : FM_LEAVE;
2320                 return;
2321         }
2322
2323         //otherwise, invalid waiting operation and send requsetion to TAPI:
2324         ad->fm_waiting_op = FM_INVALID;
2325         if (status) {
2326                 ret = tel_set_flight_mode(ad->handle, TAPI_POWER_FLIGHT_MODE_ENTER,setting_main_tapi_event_cb,ad);
2327                 setting_retm_if(ret != TAPI_API_SUCCESS,
2328                                 "*** [ERR] tel_set_flight_mode(TAPI_POWER_FLIGHT_MODE_ENTER) ***");
2329         } else {
2330                 ret = tel_set_flight_mode(ad->handle, TAPI_POWER_FLIGHT_MODE_LEAVE,setting_main_tapi_event_cb,ad);
2331                 setting_retm_if(ret != TAPI_API_SUCCESS,
2332                                 "*** [ERR] tel_set_flight_mode(TAPI_POWER_FLIGHT_MODE_LEAVE) ***");
2333         }
2334
2335         //sucessfully sent,
2336         ad->b_fm_requesting = TRUE;
2337         SETTING_TRACE_END;
2338 }
2339
2340 void __alternate_wifi_mode(Evas_Object *check)
2341 {
2342         SETTING_TRACE_BEGIN;
2343         int ret;
2344         Eina_Bool status =  elm_check_state_get(check);
2345         SETTING_TRACE("wifi mode status : %d", status);
2346
2347         ret = wifi_initialize();
2348         setting_retm_if(ret < 0, "*** [ERR] wifi_initialize() ***");
2349
2350
2351         if (status) {
2352                 ret = wifi_activate(NULL, NULL);
2353                 setting_retm_if(ret < 0,
2354                                 "*** [ERR] wifi_activate() ***");
2355         } else {
2356                 ret = wifi_deactivate(NULL, NULL);
2357                 setting_retm_if(ret < 0,
2358                                 "*** [ERR] wifi_deactivate() ***");
2359         }
2360         ret = wifi_deinitialize();
2361         setting_retm_if(ret < 0, "*** [ERR] wifi_deinitialize() ***");
2362
2363         SETTING_TRACE_END;
2364 }
2365
2366 void __alternate_bt_mode(Evas_Object *check)
2367 {
2368         SETTING_TRACE_BEGIN;
2369         int ret;
2370         Eina_Bool status =  elm_check_state_get(check);
2371         SETTING_TRACE("bt mode status : %d", status);
2372
2373         ret = bt_initialize();
2374         setting_retm_if(ret < 0, "*** [ERR] bt_initialize() ***");
2375
2376
2377         if (status) {
2378                 ret = bt_adapter_enable();
2379                 setting_retm_if(ret < 0,
2380                                 "*** [ERR] bt_adapter_enable() ***");
2381         } else {
2382                 ret = bt_adapter_disable();
2383                 setting_retm_if(ret < 0,
2384                                 "*** [ERR] bt_adapter_disable() ***");
2385         }
2386
2387         ret = bt_deinitialize();
2388         setting_retm_if(ret < 0, "*** [ERR] bt_deinitialize() ***");
2389
2390         SETTING_TRACE_END;
2391 }
2392
2393 void __alternate_nfc_mode(Evas_Object *check)
2394 {
2395         SETTING_TRACE_BEGIN;
2396         int ret;
2397         Eina_Bool status =  elm_check_state_get(check);
2398         SETTING_TRACE("nfc mode status : %d", status);
2399
2400         ret = nfc_manager_initialize(NULL, NULL);
2401         setting_retm_if(ret < 0, "*** [ERR] nfc_manager_initialize() ***");
2402
2403
2404         ret = nfc_manager_set_activation(status, NULL, NULL);
2405         setting_retm_if(ret < 0,
2406                         "*** [ERR] nfc_manager_set_activation() ***");
2407
2408         ret = nfc_manager_deinitialize();
2409         setting_retm_if(ret < 0, "*** [ERR] nfc_manager_deinitialize() ***");
2410
2411         SETTING_TRACE_END;
2412 }
2413
2414 void __alternate_sbeam_mode(Evas_Object *check)
2415 {
2416         SETTING_TRACE_BEGIN;
2417         int ret;
2418         Eina_Bool status =  elm_check_state_get(check);
2419         SETTING_TRACE("wifi mode status : %d", status);
2420
2421         vconf_set_bool(VCONFKEY_NFC_SBEAM, status);
2422
2423         SETTING_TRACE_END;
2424 }
2425
2426 void
2427 setting_main_click_list_network_ug_cb(void *data, Evas_Object *obj,
2428                                       void *event_info)
2429 {
2430         SETTING_TRACE_BEGIN;
2431         retm_if(event_info == NULL, "Invalid argument: event info is NULL");
2432         Elm_Object_Item *item = (Elm_Object_Item *) event_info;
2433
2434         elm_genlist_item_selected_set(item, EINA_FALSE);
2435
2436         if (g_main_ad->ug) {
2437                 SETTING_TRACE
2438                     ("[ad->ug non-NULL]skip genlist click event!!");
2439
2440                 SETTING_TRACE_END;
2441                 return;
2442         }
2443
2444         setting_main_appdata *ad = g_main_ad;
2445         setting_main_click_list_item_reset_data(ad, obj);
2446
2447         int err = 0;
2448         int value;
2449         setting_get_int_slp_key(INT_SLP_SETTING_SIM_SLOT, &value, &err);
2450         SETTING_TRACE("value:%d", value);
2451         switch (value) {
2452         case VCONFKEY_TELEPHONY_SIM_INSERTED:
2453                 {
2454                         struct ug_cbs *cbs =
2455                             (struct ug_cbs *)calloc(1, sizeof(struct ug_cbs));
2456                         setting_retm_if(!cbs, "calloc failed");
2457                         cbs->layout_cb = setting_main_layout_ug_cb;
2458                         cbs->result_cb = setting_main_result_ug_cb;
2459                         cbs->destroy_cb = setting_main_destroy_ug_cb;
2460                         cbs->priv = (void *)ad;
2461                         setting_main_click_list_item_ug_cb(data, obj,
2462                                                            "setting-network-efl",
2463                                                            NULL, cbs);
2464                         FREE(cbs);
2465                         break;
2466                 }
2467         case VCONFKEY_TELEPHONY_SIM_NOT_PRESENT:
2468                 setting_create_simple_popup(NULL, ad->win_main,
2469                                             NULL, _("IDS_ST_HEADER_INSERT_SIM_CARD_ABB"));
2470                 SETTING_TRACE("%s*** [ERR] No SIM. sim_slot_type=%d ***%s",
2471                               SETTING_FONT_RED, value, SETTING_FONT_BLACK);
2472                 return;
2473                 break;
2474         case VCONFKEY_TELEPHONY_SIM_CARD_ERROR:
2475         case VCONFKEY_TELEPHONY_SIM_UNKNOWN:
2476                 setting_create_simple_popup(NULL, ad->win_main,
2477                                             NULL,_("IDS_COM_BODY_INVALID_SIM_CARD"));
2478                 SETTING_TRACE("%s*** [ERR] Invalid SIM. sim_slot_type=%d ***%s",
2479                               SETTING_FONT_RED, value, SETTING_FONT_BLACK);
2480                 return;
2481                 break;
2482         default:
2483                 break;
2484         }
2485
2486 }
2487
2488 /**
2489  * genlist touch cb
2490  */
2491 static void
2492 setting_main_click_Gendial_list_flight_mode_cb(void *data, Evas_Object *obj,
2493                                                void *event_info)
2494 {
2495     /* error check */
2496     setting_retm_if(data == NULL, "Data parameter is NULL");
2497
2498     retm_if(event_info == NULL, "Invalid argument: event info is NULL");
2499     Elm_Object_Item *item = (Elm_Object_Item *) event_info;
2500     elm_genlist_item_selected_set(item, 0);
2501     Setting_GenGroupItem_Data *list_item =
2502         (Setting_GenGroupItem_Data *) elm_object_item_data_get(item);
2503     int old_status = elm_check_state_get(list_item->eo_check);
2504     /* new status */
2505     list_item->chk_status = !old_status;
2506     elm_check_state_set(list_item->eo_check, list_item->chk_status);
2507
2508     __alternate_flight_mode(list_item->eo_check);
2509     SETTING_TRACE_END;
2510 }
2511
2512 /**
2513  * toggle cb
2514  */
2515 void
2516 setting_main_click_list_flight_mode_cb(void *data, Evas_Object *obj,
2517                                        void *event_info)
2518 {
2519         SETTING_TRACE_BEGIN;
2520         retm_if(data == NULL, "Data parameter is NULL");
2521         Setting_GenGroupItem_Data *list_item =
2522             (Setting_GenGroupItem_Data *) data;
2523         list_item->chk_status = elm_check_state_get(obj);       /* for update new state */
2524         SETTING_TRACE("process item [%s], status:%d", _(list_item->keyStr),
2525                       list_item->chk_status);
2526
2527         __alternate_flight_mode(obj);
2528         SETTING_TRACE_END;
2529 }
2530
2531 /**
2532  * toggle cb
2533  */
2534 void
2535 setting_main_click_list_wifi_mode_cb(void *data, Evas_Object *obj,
2536                                        void *event_info)
2537 {
2538         SETTING_TRACE_BEGIN;
2539         retm_if(data == NULL, "Data parameter is NULL");
2540         Setting_GenGroupItem_Data *list_item =
2541             (Setting_GenGroupItem_Data *) data;
2542         list_item->chk_status = elm_check_state_get(obj);       /* for update new state */
2543         SETTING_TRACE("process item [%s], status:%d", _(list_item->keyStr),
2544                       list_item->chk_status);
2545
2546         __alternate_wifi_mode(obj);
2547         SETTING_TRACE_END;
2548 }
2549
2550 /**
2551  * toggle cb
2552  */
2553 void
2554 setting_main_click_list_bt_mode_cb(void *data, Evas_Object *obj,
2555                                        void *event_info)
2556 {
2557         SETTING_TRACE_BEGIN;
2558         retm_if(data == NULL, "Data parameter is NULL");
2559         Setting_GenGroupItem_Data *list_item =
2560             (Setting_GenGroupItem_Data *) data;
2561         list_item->chk_status = elm_check_state_get(obj);       /* for update new state */
2562         SETTING_TRACE("process item [%s], status:%d", _(list_item->keyStr),
2563                       list_item->chk_status);
2564
2565         __alternate_bt_mode(obj);
2566         SETTING_TRACE_END;
2567 }
2568
2569 /**
2570  * toggle cb
2571  */
2572 void
2573 setting_main_click_list_nfc_mode_cb(void *data, Evas_Object *obj,
2574                                        void *event_info)
2575 {
2576         SETTING_TRACE_BEGIN;
2577         retm_if(data == NULL, "Data parameter is NULL");
2578         Setting_GenGroupItem_Data *list_item =
2579             (Setting_GenGroupItem_Data *) data;
2580         list_item->chk_status = elm_check_state_get(obj);       /* for update new state */
2581         SETTING_TRACE("process item [%s], status:%d", _(list_item->keyStr),
2582                       list_item->chk_status);
2583
2584         __alternate_nfc_mode(obj);
2585         SETTING_TRACE_END;
2586 }
2587
2588 /**
2589  * toggle cb
2590  */
2591 void
2592 setting_main_click_list_sbeam_mode_cb(void *data, Evas_Object *obj,
2593                                        void *event_info)
2594 {
2595         SETTING_TRACE_BEGIN;
2596         retm_if(data == NULL, "Data parameter is NULL");
2597         Setting_GenGroupItem_Data *list_item =
2598             (Setting_GenGroupItem_Data *) data;
2599         list_item->chk_status = elm_check_state_get(obj);       /* for update new state */
2600         SETTING_TRACE("process item [%s], status:%d", _(list_item->keyStr),
2601                       list_item->chk_status);
2602
2603         __alternate_sbeam_mode(obj);
2604         SETTING_TRACE_END;
2605 }
2606
2607 /**
2608  * store current selection in setting.cfg
2609  */
2610 void setting_try_save_check_list(void *data)
2611 {
2612         SETTING_TRACE_BEGIN;
2613         setting_main_appdata *ad = (setting_main_appdata *) data;
2614
2615         Eina_List *check_list = ad->item_check_list;
2616         Setting_GenGroupItem_Data *list_item = NULL;
2617         int update_count = 0;
2618
2619         while (check_list) {
2620                 list_item = (Setting_GenGroupItem_Data *) eina_list_data_get(check_list);
2621                 if (NULL == list_item) continue;
2622
2623                 update_count++;
2624                 if (list_item->chk_status) {
2625                         /* to update config file */
2626                         setting_cfg_set_pos(list_item->keyStr, Cfg_Item_Pos_Level0);
2627                 } else {
2628                         /* to update config file */
2629                         setting_cfg_set_pos(list_item->keyStr, Cfg_Item_Pos_Level1);
2630                 }
2631                 check_list = eina_list_next(check_list);
2632         }
2633
2634         if (update_count == 0) {
2635                 /* to popup tips notify */
2636         } else {
2637                 setting_cfg_file_update();
2638         }
2639         SETTING_TRACE_END;
2640 }
2641
2642 void
2643 setting_main_click_edit_preferred_cb(void *data, Evas_Object *obj, void *event_info)
2644 {
2645         SETTING_TRACE_BEGIN;
2646
2647         setting_main_appdata *ad = (setting_main_appdata *) data;
2648         ad->view_type = SETTING_VIEW_ALL_CHECK;
2649         __setting_create_prefered_view(ad);
2650         __load_check_list(ad, &(ad->edit_preferred_genlist), NULL);
2651
2652         SETTING_TRACE_END;
2653 }