fixed the plugin window layout (regarding N_SE-14190)
[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_ROTATE_LOCK_BOOL, &value);
856                                 // true  : auto rotation OFF
857                                 // false : auto rotation ON
858                                 value = !value;
859
860                                 ad->data_rotationMode =
861                                     setting_create_Gendial_field_groupitem(genlist,
862                                                                            &(ad->itc[GENDIAL_Type_1text_2icon]),
863                                                                            NULL,
864                                                                            setting_main_sel_list_mouse_up_cb,
865                                                                            ad,
866                                                                            SWALLOW_Type_1ICON_1RADIO,
867                                                                            icon_path,
868                                                                            NULL,
869                                                                            value,
870                                                                            keyStr,
871                                                                            NULL,
872                                                                            setting_main_list_mouse_up_cb);
873                                 __BACK_POINTER_SET(ad->data_rotationMode);
874                                 item_data = ad->data_rotationMode;
875                         }
876                         else if (!safeStrCmp(KeyStr_Brightness, keyStr)) {
877
878                                 char* pa_bright = get_brightness_mode_str();
879                                 ad->data_bright=
880                                     setting_create_Gendial_field_groupitem(genlist,
881                                                                            &(ad->itc[GENDIAL_Type_1icon_2text]),
882                                                                            NULL,
883                                                                            setting_main_click_list_ex_ug_cb,
884                                                                            ug_args,
885                                                                            SWALLOW_Type_INVALID,
886                                                                            icon_path,
887                                                                            NULL,
888                                                                            0,
889                                                                            keyStr,
890                                                                            pa_bright,
891                                                                            NULL);
892                                 __BACK_POINTER_SET(ad->data_bright);
893                                 item_data = ad->data_bright;
894                                 ncount++;
895                         }
896                         else {  /* load other UGs */
897                                 item_data = setting_create_Gendial_field_groupitem(genlist,
898                                                                        &(ad->itc[GENDIAL_Type_1text_1icon_2]),
899                                                                        NULL,
900                                                                        setting_main_click_list_ex_ug_cb,
901                                                                        ug_args,
902                                                                        SWALLOW_Type_INVALID,
903                                                                        icon_path,
904                                                                        NULL, 0,
905                                                                        keyStr,
906                                                                        NULL,
907                                                                        NULL);
908                                 ncount++;
909                         }
910
911                         if (item_data) {
912                                 if (j == 0) {
913                                         item_data->group_style = SETTING_GROUP_STYLE_TOP;
914                                 } else if (j == setting_cfg_get_menu_length(i) - 1) {
915                                         item_data->group_style = SETTING_GROUP_STYLE_BOTTOM;
916                                 } else {
917                                         item_data->group_style = SETTING_GROUP_STYLE_CENTER;
918                                 }
919
920                                 if (index == 0) {
921                                         item_data->group_style = SETTING_GROUP_STYLE_TOP;
922                                 }
923                                 index++;
924                         }
925                 }
926         }
927         //end group, only display in setting main view
928 #if SUPPORT_MORE_ITEM_FUNCTION
929                 if (SETTING_VIEW_MAIN == ad->view_load && MAIN_PROFILE_PREFERRED == ad->profile_type && idx_second_menu > 0)
930                 {
931                         char sub_text[MAX_COMMON_BUFFER_LEN] = {0, };
932                         int idx = 0;
933                         while (idx < MAX_MORE_MENU_NUM && ad->more_system_menus[idx])
934                         {
935                                 if (idx != 0)
936                                 {
937                                         safeStrNCat(sub_text, ", ", MAX_COMMON_BUFFER_LEN);
938                                 }
939                                 safeStrNCat(sub_text, _(ad->more_system_menus[idx]), MAX_COMMON_BUFFER_LEN);
940                                 idx++;
941                         }
942
943                         ad->data_moreSystem =
944                                 setting_create_Gendial_field_groupitem(ad->main_genlist,
945                                                                        &(ad->itc[GENDIAL_Type_2text_3]),
946                                                                        NULL,
947                                                                        setting_main_click_list_more_cb,
948                                                                        ad,
949                                                                        SWALLOW_Type_INVALID,
950                                                                        NULL,
951                                                                        NULL,
952                                                                        0,
953                                                                        KeyStr_MoreSystem,
954                                                                        sub_text,
955                                                                        NULL);
956                         __BACK_POINTER_SET(ad->data_moreSystem);
957
958                         /* if has <more ..> item , change the last item_date to SETTING_GROUP_STYLE_CENTER*/
959                         if (item_data && index > 1) {
960                                 item_data->group_style = SETTING_GROUP_STYLE_CENTER;
961                         }
962                         ad->data_moreSystem->group_style = SETTING_GROUP_STYLE_BOTTOM;
963
964                         item_data = ad->data_moreSystem;
965                         index++;
966                 }
967 #endif
968         if (index == 1) {
969                 item_data->group_style = SETTING_GROUP_STYLE_NONE;
970         } else if (index == 2) {
971                 item_data->group_style = SETTING_GROUP_STYLE_BOTTOM;
972         }
973 }
974
975 static void __load_system_level0_list(void *data)
976 {
977         setting_main_appdata *ad = data;
978         __load_system_menu_list(ad, Cfg_Item_Pos_Level0, ad->main_genlist);
979 }
980
981 static void __load_system_level_all_list(void *data)
982 {
983         SETTING_TRACE_BEGIN;
984         setting_main_appdata *ad = data;
985         __load_system_menu_list(ad, Cfg_Item_Pos_Level_All, ad->main_genlist);
986 }
987
988 static void __load_applications_menu_list(void *data,
989                                           Cfg_Item_Position inputPos)
990 {
991         SETTING_TRACE_BEGIN;
992         SETTING_TRACE_DEBUG("pos :%d", inputPos);
993         setting_main_appdata *ad = data;
994
995         bool is_emulator = isEmulBin();
996
997         //group title
998         setting_create_Gendial_field_group_titleItem(ad->main_genlist,
999                                                      &(ad->itc[GENDIAL_Type_group_item]),
1000                                                      NULL,
1001                                                      ELM_GENLIST_ITEM_NONE,
1002                                                      KeyStr_Applications, NULL);
1003         char *keyStr = NULL;
1004         char *icon_path = NULL;
1005         char *ug_args = NULL;
1006         Cfg_Item_Position tmpPos = Cfg_Item_Pos_Uninstall;
1007         int i, j;
1008
1009         Setting_GenGroupItem_Data *item_data = NULL;
1010         int index = 0;
1011         for (i = 0; i < setting_cfg_get_category_length(); i++) {
1012                 if (safeStrCmp
1013                     (setting_cfg_get_category_name(i), KeyStr_Applications))
1014                         continue;
1015
1016                 for (j = 0; j < setting_cfg_get_menu_length(i); j++) {
1017                         keyStr = setting_cfg_get_keyname_idx(i, j);
1018                         icon_path = setting_cfg_get_icon_path_idx(i, j);
1019                         ug_args = setting_cfg_get_ug_args_idx(i, j);
1020                         tmpPos =
1021                             (Cfg_Item_Position) setting_cfg_get_pos_idx(i, j);
1022
1023                         if (Cfg_Item_Pos_Level_All == inputPos) {
1024                         } else if (inputPos != tmpPos) {        /* not in the inputPos level */
1025                                 continue;
1026                         }
1027
1028                         if (is_emulator) {
1029                                  /* hide all except Email */
1030                                 if (safeStrCmp(KeyStr_Email, keyStr)) {
1031                                         continue;
1032                                 } else {
1033                                         /* do nothing */
1034                                 }
1035                         }
1036
1037                         item_data = setting_create_Gendial_field_groupitem(ad->main_genlist,
1038                                                                &(ad->itc[GENDIAL_Type_1text_1icon_2]),
1039                                                                NULL,
1040                                                                setting_main_click_list_ex_ug_cb,
1041                                                                ug_args,
1042                                                                SWALLOW_Type_INVALID,
1043                                                                icon_path, NULL,
1044                                                                0, keyStr, NULL,
1045                                                                NULL);
1046
1047                         if (item_data) {
1048                                 if (j == 0) {
1049                                         item_data->group_style = SETTING_GROUP_STYLE_TOP;
1050                                 } else if (j == setting_cfg_get_menu_length(i) - 1) {
1051                                         item_data->group_style = SETTING_GROUP_STYLE_BOTTOM;
1052                                 } else {
1053                                         item_data->group_style = SETTING_GROUP_STYLE_CENTER;
1054                                 }
1055
1056                                 if (index == 0) {
1057                                         item_data->group_style = SETTING_GROUP_STYLE_TOP;
1058                                 }
1059                                 index++;
1060                         }
1061                 }
1062         }
1063
1064         if (index == 1) {
1065                 item_data->group_style = SETTING_GROUP_STYLE_NONE;
1066         } else if (index == 2) {
1067                 item_data->group_style = SETTING_GROUP_STYLE_BOTTOM;
1068         }
1069
1070         SETTING_TRACE_END;
1071 }
1072
1073 static void __load_applications_level0_list(void *data)
1074 {
1075         setting_main_appdata *ad = data;
1076         __load_applications_menu_list(ad, Cfg_Item_Pos_Level0);
1077 }
1078
1079 static void __load_applications_level_all_list(void *data)
1080 {
1081         SETTING_TRACE_BEGIN;
1082         setting_main_appdata *ad = data;
1083         __load_applications_menu_list(ad, Cfg_Item_Pos_Level_All);
1084 }
1085
1086
1087 bool is_3rdapp_installed_setting_cfg(char* pkgname)
1088 {
1089         SETTING_TRACE_BEGIN;
1090         char path[512];
1091
1092         SETTING_TRACE("1");
1093         if (snprintf(path, 512, PLUGIN_PREFIX"/apps/%s/setting/setting.xml", pkgname) < 0)
1094                 return false;
1095
1096         struct stat st;
1097         bool result_opt = false;
1098
1099         if(stat(path, &st) == 0) {
1100                 result_opt = true;
1101         } else {
1102                 SETTING_TRACE_ERROR(" %s is *NOT* present\n", path);
1103                 result_opt = false;
1104         }
1105
1106         return result_opt;
1107 }
1108
1109 /**
1110  * @param data
1111  */
1112 static void draw_3rdapp(void* data, char* name, char* pkgname)
1113 {
1114         SETTING_TRACE_BEGIN;
1115         SETTING_TRACE(" name : %s", name);
1116         SETTING_TRACE(" pkgname : %s", pkgname);
1117
1118         setting_main_appdata *ad = data;
1119
1120         //3rd cfg
1121         char fullpath[512];
1122         if (snprintf(fullpath, 512,  PLUGIN_PREFIX"/apps/%s/setting/setting.xml", pkgname) < 0)
1123                 return;
1124
1125         SETTING_TRACE(" fullpath : %s", fullpath);
1126
1127         if (ad)
1128         {
1129                 if (ad->plugin_path)
1130                 {
1131                         free(ad->plugin_path);
1132                         ad->plugin_path = NULL;
1133                 }
1134                 ad->plugin_path = strdup(fullpath);
1135
1136                 setting_create_Gendial_field_groupitem(ad->main_genlist,
1137                                                            &(ad->itc[GENDIAL_Type_1text_1icon_2]),
1138                                                            NULL,
1139                                                            setting_main_click_list_plugin_cb,
1140                                                            ad,
1141                                                            SWALLOW_Type_INVALID,
1142                                                            IMG_DefaultIcon, NULL,
1143                                                            0, name, NULL,
1144                                                            NULL);
1145         }
1146         SETTING_TRACE_END;
1147 }
1148
1149 /**
1150  *
1151  * ail code here
1152  */
1153 static ail_cb_ret_e __download_apps_cb(ail_appinfo_h ai, void* data)
1154 {
1155         DrawAppInfo* pinfo = (DrawAppInfo*)data;
1156     char *id;
1157
1158         if (AIL_ERROR_OK == ail_appinfo_get_str(ai, AIL_PROP_PACKAGE_STR, &id))
1159         {
1160                 SETTING_TRACE(" 3rd party - app name : ----> %s ", id);
1161         }
1162
1163     ail_appinfo_h handle;
1164
1165     char *name = NULL;
1166     char *icon = NULL;
1167     int installed_time;
1168     bool nodisplay = false;
1169     bool removable = true;
1170
1171     if (AIL_ERROR_OK == ail_package_get_appinfo(id, &handle))
1172         {
1173                 if (AIL_ERROR_OK != ail_appinfo_get_str(handle, AIL_PROP_NAME_STR, &name))
1174                         SETTING_TRACE("cannot get name");
1175
1176                 if (AIL_ERROR_OK != ail_appinfo_get_str(handle, AIL_PROP_ICON_STR, &icon))
1177                         SETTING_TRACE("cannot get icon");
1178
1179                 if (AIL_ERROR_OK != ail_appinfo_get_bool(handle, AIL_PROP_NODISPLAY_BOOL, &nodisplay))
1180                         SETTING_TRACE("cannot get nodisplay");
1181
1182                 if (AIL_ERROR_OK != ail_appinfo_get_bool(handle, AIL_PROP_X_SLP_REMOVABLE_BOOL, &removable))
1183                         SETTING_TRACE("cannot get removable");
1184
1185                 if (AIL_ERROR_OK != ail_appinfo_get_int(handle, AIL_PROP_X_SLP_INSTALLEDTIME_INT, &installed_time))
1186                         SETTING_TRACE("cannot get installed_time");
1187
1188                 //SETTING_TRACE("installed_time = %d ", installed_time);
1189                 if (installed_time != 0 && is_3rdapp_installed_setting_cfg(id) == true )
1190                 {
1191                         SETTING_TRACE(" 3rd party - app name : ----> id : %s --- name : %s ", id, name);
1192                         SETTING_TRACE(" 3rd party - icon : ----> %s ", icon);
1193                         SETTING_TRACE(" 3rd party - nodisplay :  ----> %d ", nodisplay);
1194                         pinfo->ncount++;
1195
1196                         // draw code here
1197                         if (pinfo->draw_app != NULL)
1198                         {
1199                                 SETTING_TRACE(">>> pkg name --> %s ", id);
1200                                 pinfo->draw_app(pinfo->data, strdup(name)/* appname*/, strdup(id)/* pkg_name*/);
1201                         }
1202                 }
1203         }
1204         SETTING_TRACE_END;
1205     return AIL_CB_RET_CONTINUE;
1206 }
1207
1208
1209 /**
1210  * get 3rd party applist from AIL & searching dir/file by the defined rule
1211  * @param data ad
1212  * if data is NULL --> just get how many items are there
1213  * if data is NOT NULL --> draw UI code
1214  */
1215 static int get_downloadapp_list(void* data)
1216 {
1217         SETTING_TRACE_BEGIN;
1218
1219         setting_main_appdata *ad = data;
1220
1221         int ncount = 0;
1222         ail_filter_h f;
1223
1224         DrawAppInfo* pinfo = (DrawAppInfo*)malloc(sizeof(DrawAppInfo));
1225
1226         if (pinfo) {
1227                 pinfo->ncount = 0;
1228                 pinfo->draw_app = draw_3rdapp;
1229                 pinfo->data = ad;
1230
1231                 if (ail_filter_new(&f) == AIL_ERROR_OK)
1232                 {
1233                         if (ail_filter_add_bool(f, AIL_PROP_NODISPLAY_BOOL, false) != AIL_ERROR_OK)
1234                         {
1235                                 SETTING_TRACE("ail filter error");
1236
1237                                 free(pinfo);
1238                                 pinfo = NULL;
1239
1240                                 ail_filter_destroy(f);
1241                                 return 0;
1242                         }
1243
1244                         ail_filter_list_appinfo_foreach(f, __download_apps_cb, pinfo);
1245                         //---------------------------------------------------------------
1246                         ail_filter_destroy(f);
1247                 }
1248                 ncount = pinfo->ncount;
1249
1250                 free(pinfo);
1251                 pinfo = NULL;
1252         }
1253
1254         SETTING_TRACE_END;
1255         return ncount;
1256 }
1257
1258 static int __get_downloaded_apps_num(Cfg_Item_Position inputPos)
1259 {
1260         SETTING_TRACE_BEGIN;
1261         SETTING_TRACE_DEBUG("pos :%d", inputPos);
1262         int downloaded_apps_num = 0;
1263         Cfg_Item_Position tmpPos = Cfg_Item_Pos_Uninstall;
1264         int i, j;
1265         for (i = 0; i < setting_cfg_get_category_length(); i++) {
1266                 if (safeStrCmp
1267                     (setting_cfg_get_category_name(i), KeyStr_DownloadedAPPs))
1268                         continue;
1269
1270                 for (j = 0; j < setting_cfg_get_menu_length(i); j++) {
1271                         tmpPos = (Cfg_Item_Position) setting_cfg_get_pos_idx(i, j);
1272                         if (Cfg_Item_Pos_Level_All == inputPos) {
1273                         } else if (inputPos != tmpPos) {        /* not in the inputPos level */
1274                                 continue;
1275                         }
1276
1277                         downloaded_apps_num++;
1278                 }
1279         }
1280
1281         // draw UI with AUL code
1282 #ifdef PLUGIN
1283         downloaded_apps_num = get_downloadapp_list(NULL);
1284         SETTING_TRACE("Exit %s with return[%d]",__FUNCTION__, downloaded_apps_num);
1285 #endif
1286
1287         SETTING_TRACE("Exit %s with return[%d]",__FUNCTION__, downloaded_apps_num);
1288         return downloaded_apps_num;
1289 }
1290
1291
1292 static void __load_downloaded_apps_menu_list(void *data,
1293                                              Cfg_Item_Position inputPos)
1294 {
1295         SETTING_TRACE_BEGIN;
1296         SETTING_TRACE_DEBUG("pos :%d", inputPos);
1297         setting_main_appdata *ad = data;
1298
1299         // if the number of download apps is zero, display a bottom seperator
1300         if (0 == __get_downloaded_apps_num(inputPos)) {
1301                 Elm_Object_Item *item = NULL;
1302                 item = elm_genlist_item_append(ad->main_genlist, &itc_bottom_seperator, NULL, NULL,
1303                                         ELM_GENLIST_ITEM_NONE, NULL, NULL);
1304                 elm_genlist_item_select_mode_set(item, ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY);
1305                 return;
1306         }
1307
1308         //group title
1309         setting_create_Gendial_field_group_titleItem(ad->main_genlist,
1310                                                      &(ad->itc[GENDIAL_Type_group_item]),
1311                                                      NULL,
1312                                                      ELM_GENLIST_ITEM_NONE,
1313                                                      KeyStr_DownloadedAPPs,
1314                                                      NULL);
1315         get_downloadapp_list(ad);
1316         //SETTING_TRACE("Exit %s with return[%d]",__FUNCTION__, downloaded_apps_num);
1317         SETTING_TRACE_END;
1318 }
1319
1320 static void __load_downloaded_apps_level0_list(void *data)
1321 {
1322         setting_main_appdata *ad = data;
1323         __load_downloaded_apps_menu_list(ad, Cfg_Item_Pos_Level0);
1324 }
1325
1326 static void __load_downloaded_apps_level_all_list(void *data)
1327 {
1328         SETTING_TRACE_BEGIN;
1329         setting_main_appdata *ad = data;
1330         __load_downloaded_apps_menu_list(ad, Cfg_Item_Pos_Level_All);
1331 }
1332
1333 static void __check_all_view_clear(void *data)
1334 {
1335         SETTING_TRACE_BEGIN;
1336         ret_if(!data);
1337         setting_main_appdata *ad = data;
1338         if (ad->item_check_list) {
1339                 eina_list_free(ad->item_check_list);
1340                 ad->item_check_list = NULL;
1341         }
1342
1343         ad->gl_sel_all = NULL;
1344         ad->edit_preferred_genlist  = NULL;
1345         //ad->controllbar_all_check = NULL;
1346         ad->check_all_item =NULL;
1347 }
1348
1349 static void __prefered_buttons_cb(void *data, Evas_Object *obj, void *event_info)
1350 {
1351         SETTING_TRACE_BEGIN;
1352         ret_if(!data);
1353         setting_main_appdata *ad = (setting_main_appdata *) data;
1354         const char *key = NULL;
1355
1356         key = elm_object_text_get(obj);
1357         setting_retm_if(data == NULL
1358                         || key == NULL, "data == NULL || key == NULL");
1359
1360         SETTING_TRACE_DEBUG("press button: %s", key);
1361
1362         // "Done"
1363         if (!safeStrCmp(key, dgettext("sys_string", "IDS_COM_SK_DONE"))) {
1364
1365                 if (ad->profile_type == MAIN_PROFILE_ALL) {
1366                         SETTING_TRACE_DEBUG("Cancel to hide current view.");
1367                         setting_try_save_check_list(ad);        /* need to save too */
1368                         __check_all_view_clear(ad);
1369                         elm_naviframe_item_pop(ad->navibar_main);       // pop(preferred) --> main
1370                         return;
1371                 }
1372
1373                 // MAIN_PROFILE_PREFERRED and Etc
1374                 // redraw setting-main
1375                 setting_try_save_check_list(ad);
1376                 elm_naviframe_item_pop(ad->navibar_main);  // pop (preferred) -> main
1377
1378                 //After the view is popuped, all the object handlers should be reset NULL.
1379                 __check_all_view_clear(ad);
1380                 ad->load_fns[Func_Type_Connectivity] = __load_connectivity_level0_list;
1381                 ad->load_fns[Func_Type_System] = __load_system_level0_list;
1382                 ad->load_fns[Func_Type_Apps] = __load_applications_level0_list;
1383                 ad->load_fns[Func_Type_DownApp] = __load_downloaded_apps_level0_list;
1384                 int ret = setting_main_refresh(ad);
1385                 ret_if(ret != SETTING_RETURN_SUCCESS);
1386                 return;
1387         }
1388
1389         // "Cancel"
1390         if (!safeStrCmp(key, setting_gettext("IDS_COM_SK_CANCEL"))
1391             || !safeStrCmp(key, dgettext("sys_string", "IDS_COM_BODY_BACK"))) {
1392                 SETTING_TRACE_DEBUG("Cancel to hide current view.");
1393                 elm_naviframe_item_pop(ad->navibar_main);
1394                 //After the view is popuped, all the object handlers should be reset NULL.
1395                 __check_all_view_clear(ad);
1396                 return;
1397         }
1398 }
1399
1400
1401 static void __btnback_clicked_cb(void *data, Evas_Object *obj, void *event_info)
1402 {
1403         SETTING_TRACE_BEGIN;
1404         ret_if(!data);
1405         setting_main_appdata *ad = (setting_main_appdata *) data;
1406         elm_win_lower(ad->win_main);
1407 }
1408
1409 static Eina_Bool __refresh_on_idle(void *data)
1410 {
1411         SETTING_TRACE_BEGIN;
1412         retv_if(!data, FALSE);
1413         setting_main_appdata *ad = data;
1414         if (MAIN_PROFILE_ALL == ad->profile_type)
1415         {
1416                 ad->load_fns[Func_Type_Connectivity] = __load_connectivity_level_all_list;
1417                 ad->load_fns[Func_Type_System] = __load_system_level_all_list;
1418                 ad->load_fns[Func_Type_Apps] = __load_applications_level_all_list;
1419                 ad->load_fns[Func_Type_DownApp] = __load_downloaded_apps_level_all_list;
1420                 setting_main_refresh(ad);
1421         }
1422         else if (MAIN_PROFILE_PREFERRED == ad->profile_type)
1423         {
1424                 ad->load_fns[Func_Type_Connectivity] = __load_connectivity_level0_list;
1425                 ad->load_fns[Func_Type_System] = __load_system_level0_list;
1426                 ad->load_fns[Func_Type_Apps] = __load_applications_level0_list;
1427                 ad->load_fns[Func_Type_DownApp] = __load_downloaded_apps_level0_list;
1428                 setting_main_refresh(ad);
1429         }
1430         ad->refresh_idler = NULL;
1431         return FALSE;
1432 }
1433
1434 static void __allFrequent_btn_cb(void *data, Evas_Object *obj, void *event_info)
1435 {
1436         SETTING_TRACE_BEGIN;
1437         ret_if(!data || !obj);
1438         setting_main_appdata *ad = (setting_main_appdata *) data;
1439         //if already has the task,cancel the old task with ecore_idler_del,then add new idler task.
1440         if (ad->refresh_idler) {
1441                 ecore_idler_del(ad->refresh_idler);
1442                 ad->refresh_idler = NULL;
1443         }
1444
1445         //Elm_Object_Item *item = elm_toolbar_first_item_get(obj);
1446         //ret_if(!item);
1447         if (MAIN_PROFILE_ALL == ad->profile_type)
1448         {
1449                 SETTING_TRACE("Change to Preferred view");
1450                 elm_object_text_set(obj, _(ALL_STR));
1451                 ad->profile_type = MAIN_PROFILE_PREFERRED;
1452         }
1453         else if (MAIN_PROFILE_PREFERRED == ad->profile_type)
1454         {
1455                 SETTING_TRACE("Change to ALL view");
1456                 elm_object_text_set(obj, _(PREFERRED_STR));
1457                 ad->profile_type = MAIN_PROFILE_ALL;
1458         }
1459         else
1460         {
1461                 return;
1462         }
1463         ad->refresh_idler = ecore_idler_add((Ecore_Task_Cb) __refresh_on_idle, ad);
1464 }
1465
1466 static void __setting_show_title_toolbar(void *data, Evas_Object *obj, void *event_info)
1467 {
1468     SETTING_TRACE_BEGIN;
1469     //elm_object_item_signal_emit(data, "elm,state,sip,shown", "");
1470     setting_main_appdata *ad = (setting_main_appdata *) data;
1471
1472     Evas_Object *navi_bar = NULL;
1473
1474     if (ad->isInUGMode && ad->ug) {
1475         Evas_Object *layout = (Evas_Object *)ug_get_layout(ad->ug);
1476         if (layout)
1477             navi_bar = elm_object_part_content_get(layout, "elm.swallow.content");
1478     } else {
1479         navi_bar = ad->navibar_main;
1480     }
1481
1482     const char *support = evas_object_data_get(navi_bar, "sip.naviframe.title_obj");
1483     SETTING_TRACE("support:%s", support);
1484     if (support)
1485     {
1486         Elm_Object_Item *top_item = elm_naviframe_top_item_get(navi_bar);
1487         if (top_item)
1488             elm_object_item_signal_emit(top_item, "elm,state,sip,shown", "");
1489     }
1490 }
1491
1492 static void __setting_hide_title_toolbar(void *data, Evas_Object *obj, void *event_info)
1493 {
1494     SETTING_TRACE_BEGIN;
1495     //elm_object_item_signal_emit(data, "elm,state,sip,hidden", "");
1496     setting_main_appdata *ad = (setting_main_appdata *) data;
1497
1498     Evas_Object *navi_bar = NULL;
1499
1500     if (ad->isInUGMode && ad->ug) {
1501         Evas_Object *layout = (Evas_Object *)ug_get_layout(ad->ug);
1502         if (layout)
1503             navi_bar = elm_object_part_content_get(layout, "elm.swallow.content");
1504     } else {
1505         navi_bar = ad->navibar_main;
1506     }
1507
1508     const char *support = evas_object_data_get(navi_bar, "sip.naviframe.title_obj");
1509
1510     SETTING_TRACE("support:%s", support);
1511     if (support)
1512     {
1513         Elm_Object_Item *top_item = elm_naviframe_top_item_get(navi_bar);
1514         if (top_item)
1515             elm_object_item_signal_emit(top_item, "elm,state,sip,hidden", "");
1516     }
1517 }
1518
1519 static bool __setting_create_main_view(void *data)
1520 {
1521         SETTING_TRACE_BEGIN;
1522         /* error check */
1523         setting_retvm_if(data == NULL, FALSE, "data == NULL");
1524         setting_main_appdata *ad = (setting_main_appdata *) data;
1525
1526         Evas_Object *conform = elm_conformant_add(ad->win_main);
1527         ad->ly_main = setting_create_win_layout(ad->win_main, ad->win_main);
1528         evas_object_size_hint_weight_set(conform, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
1529         evas_object_size_hint_align_set(conform, EVAS_HINT_FILL, EVAS_HINT_FILL);
1530         elm_win_resize_object_add(ad->win_main, conform);
1531         elm_object_content_set(conform, ad->ly_main);
1532         evas_object_show(conform);
1533
1534     evas_object_smart_callback_add(conform, "virtualkeypad,state,on", __setting_show_title_toolbar, ad);
1535     evas_object_smart_callback_add(conform, "virtualkeypad,state,off", __setting_hide_title_toolbar, ad);
1536
1537         elm_win_conformant_set(ad->win_main, EINA_TRUE);
1538
1539         ad->conform = conform;
1540
1541         ad->navibar_main = setting_create_navi_bar(ad->ly_main);
1542
1543         ad->main_genlist = elm_genlist_add(ad->navibar_main);
1544         elm_object_style_set(ad->main_genlist, "dialogue");
1545         retvm_if(ad->main_genlist == NULL, FALSE,
1546                  "Cannot set scroller object as contento of layout");
1547
1548         //elm_genlist_homogeneous_set(ad->main_genlist, EINA_TRUE);
1549         elm_genlist_clear(ad->main_genlist);    /* first to clear list */
1550         evas_object_smart_callback_add(ad->main_genlist, "realized", __gl_realized, ad);
1551
1552         setting_create_navi_bar_buttons(_("IDS_COM_BODY_SETTINGS"),
1553                                         _("IDS_COM_BODY_BACK"), NULL, _("IDS_ST_OPT_ALL"),
1554                                         __btnback_clicked_cb, NULL,
1555                                         __allFrequent_btn_cb, ad, ad->main_genlist,
1556                                         ad->navibar_main, NULL);
1557
1558         ad->profile_type = MAIN_PROFILE_PREFERRED;
1559         ad->load_fns[Func_Type_Connectivity] = __load_connectivity_level0_list;
1560         ad->load_fns[Func_Type_System] = __load_system_level0_list;
1561         ad->load_fns[Func_Type_Apps] = __load_applications_level_all_list;
1562         ad->load_fns[Func_Type_DownApp] = __load_downloaded_apps_level_all_list;
1563         setting_main_refresh(ad);
1564         return TRUE;
1565 }
1566
1567 static bool __setting_create_prefered_view(void *data)
1568 {
1569         SETTING_TRACE_BEGIN;
1570         /* error check */
1571         setting_retvm_if(data == NULL, FALSE, "data == NULL");
1572         setting_main_appdata *ad = (setting_main_appdata *) data;
1573
1574         /* the genlist will be destroyed with its parent view, when using elm_naviframe_item_pop() to destroy the view. */
1575         ad->edit_preferred_genlist = elm_genlist_add(ad->win_main);
1576         elm_object_style_set(ad->edit_preferred_genlist, "dialogue");
1577         elm_genlist_clear(ad->edit_preferred_genlist);  /* first to clear list */
1578
1579         /*  [UI] edit preffered view */
1580         Evas_Object *sub_layout = elm_layout_add(ad->win_main);
1581         elm_object_style_set(sub_layout, "dialogue");
1582         elm_layout_file_set(sub_layout, SETTING_THEME_EDJ_NAME, "search_layout");
1583         evas_object_size_hint_weight_set(sub_layout, EVAS_HINT_EXPAND, 0.0);
1584         evas_object_show(sub_layout);
1585
1586         ad->gl_sel_all = elm_genlist_add(ad->win_main);
1587         elm_genlist_clear(ad->gl_sel_all);      /* first to clear list */
1588         elm_genlist_bounce_set(ad->gl_sel_all, 0, 0);
1589
1590         elm_object_part_content_set(sub_layout, "search_bar", ad->gl_sel_all);  /*  add 'Select all' */
1591         elm_object_part_content_set(sub_layout, "search_list", ad->edit_preferred_genlist);     /*  add Genlist */
1592
1593         /*  push, not create */
1594         setting_push_layout_navi_bar(_(EDIT_PREFERRED_STR),
1595                                      _("IDS_COM_SK_CANCEL"),
1596                                      _("IDS_COM_SK_DONE"), NULL,
1597                                      __prefered_buttons_cb, __prefered_buttons_cb, NULL, ad,
1598                                      sub_layout, ad->navibar_main,
1599                                      NULL);
1600         SETTING_TRACE_END;
1601         return TRUE;
1602 }
1603
1604 static void setting_main_tapi_event_cb(TapiHandle *handle, int result, void *data, void *user_data)
1605 {
1606         SETTING_TRACE_BEGIN;
1607         ret_if(!user_data);
1608         setting_main_appdata *ad = user_data;
1609         ad->b_fm_requesting = FALSE;
1610         SETTING_TRACE("result:%d", result);
1611
1612         int err = 0;
1613         switch (result) {
1614         case TAPI_POWER_FLIGHT_MODE_RESP_ON:
1615
1616                 setting_set_bool_slp_key(BOOL_SLP_SETTING_FLIGHT_MODE,
1617                                          SETTING_ON_OFF_BTN_ON, &err);
1618
1619                 //If Setting has validate operation (fm_waiting_op == FM_LEAVE) to process, process it.
1620                 //Otherwise, do nothing
1621                 if (FM_LEAVE == ad->fm_waiting_op)
1622                 {
1623                         //Send the latest operation
1624                         ad->fm_waiting_op = FM_INVALID;
1625                         err = tel_set_flight_mode(ad->handle, TAPI_POWER_FLIGHT_MODE_LEAVE,setting_main_tapi_event_cb,ad);
1626                         setting_retm_if(err != TAPI_API_SUCCESS,
1627                                         "*** [ERR] tel_set_flight_mode(TAPI_POWER_FLIGHT_MODE_LEAVE) ***");
1628
1629                         //sucessfully sent,
1630                         ad->b_fm_requesting = TRUE;
1631
1632                 }
1633                 break;
1634
1635         case TAPI_POWER_FLIGHT_MODE_RESP_OFF:
1636
1637                 setting_set_bool_slp_key(BOOL_SLP_SETTING_FLIGHT_MODE,
1638                                          SETTING_ON_OFF_BTN_OFF, &err);
1639
1640                 //If Setting has validate operation (here, fm_waiting_op == FM_ENTER) to process,process it.
1641                 //Otherwise, do nothing
1642                 if (FM_ENTER == ad->fm_waiting_op)
1643                 {
1644                         //Send the latest operation
1645                         ad->fm_waiting_op = FM_INVALID;
1646                         err = tel_set_flight_mode(ad->handle, TAPI_POWER_FLIGHT_MODE_ENTER,setting_main_tapi_event_cb,ad);
1647                         setting_retm_if(err != TAPI_API_SUCCESS,
1648                                         "*** [ERR] tel_set_flight_mode(TAPI_POWER_FLIGHT_MODE_ENTER) ***");
1649
1650                         //sucessfully sent,
1651                         ad->b_fm_requesting = TRUE;
1652                 }
1653
1654                 break;
1655
1656         case TAPI_POWER_FLIGHT_MODE_RESP_FAIL:
1657                 //Setting has a validate operation to process, Send the operation request
1658                 if (FM_ENTER == ad->fm_waiting_op)
1659                 {
1660                         ad->fm_waiting_op = FM_INVALID;
1661                         err = tel_set_flight_mode(ad->handle, TAPI_POWER_FLIGHT_MODE_ENTER,setting_main_tapi_event_cb,ad);
1662
1663                         setting_retm_if(err != TAPI_API_SUCCESS,
1664                                         "*** [ERR] tel_set_flight_mode(TAPI_POWER_FLIGHT_MODE_ENTER) ***");
1665                         ad->b_fm_requesting = TRUE;
1666                 }
1667                 else if (FM_LEAVE == ad->fm_waiting_op)
1668                 {
1669                         ad->fm_waiting_op = FM_INVALID;
1670                         err = tel_set_flight_mode(ad->handle, TAPI_POWER_FLIGHT_MODE_LEAVE,setting_main_tapi_event_cb,ad);
1671
1672                         setting_retm_if(err != TAPI_API_SUCCESS,
1673                                         "*** [ERR] tel_set_flight_mode(TAPI_POWER_FLIGHT_MODE_LEAVE) ***");
1674                         ad->b_fm_requesting = TRUE;
1675                 }
1676                 else //Current requset is the last one, Setting needs to notify user
1677                 {
1678                         setting_create_popup_without_btn(ad, ad->win_main,
1679                                              _("IDS_COM_POP_ERROR"),
1680                                              _("IDS_ST_POP_UNABLE_TO_TURN_ON_FLIGHT_MODE_VODA"),
1681                                              NULL, POPUP_INTERVAL,
1682                                              FALSE, FALSE);
1683
1684                         //It is need to rollback the status,
1685                         if (ad->data_flight) {
1686                                 ad->data_flight->chk_status = !ad->data_flight->chk_status;
1687                                 elm_check_state_set(ad->data_flight->eo_check, ad->data_flight->chk_status);
1688                         }
1689                         return;
1690                 }
1691
1692                 //sucessfully sent,
1693                 ad->b_fm_requesting = TRUE;
1694
1695                 break;
1696
1697         case TAPI_POWER_FLIGHT_MODE_RESP_MAX:
1698                 setting_create_popup_without_btn(ad, ad->win_main,
1699                                      _("IDS_COM_POP_ERROR"),
1700                                      _("IDS_COM_POP_UNEXPECTED_ERROR"),
1701                                      NULL, POPUP_INTERVAL, FALSE, FALSE);
1702
1703                 //It is need to rollback the status,
1704                 if (ad->data_flight) {
1705                         ad->data_flight->chk_status = !ad->data_flight->chk_status;
1706                         elm_check_state_set(ad->data_flight->eo_check, ad->data_flight->chk_status);
1707                 }
1708                 break;
1709         default:
1710                 /* do nothing */
1711                 break;
1712         }
1713         return;
1714 }
1715
1716 static int setting_main_refresh(void *data)
1717 {
1718         SETTING_TRACE_BEGIN;
1719         setting_main_appdata *ad = (setting_main_appdata *) data;
1720         elm_genlist_clear(ad->main_genlist);    /* first to clear list */
1721
1722 #if 0
1723         if (is_ug_installed_by_ug_args("rcs-config"))
1724         {
1725                 Elm_Object_Item *item = elm_genlist_item_append(ad->main_genlist, &itc_seperator, NULL, NULL,
1726                                             ELM_GENLIST_ITEM_NONE, NULL, NULL);
1727                 elm_genlist_item_select_mode_set(item, ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY);
1728                 setting_create_Gendial_field_groupitem(ad->main_genlist,
1729                                                        &(ad->itc[GENDIAL_Type_1text_1icon_2]),
1730                                                        NULL,
1731                                                        setting_main_click_list_ex_ug_cb,
1732                                                        "rcs-config",
1733                                                        SWALLOW_Type_INVALID,
1734                                                        IMG_Joyn, NULL,
1735                                                        0, KeyStr_Joyn, NULL,
1736                                                        NULL);
1737         }
1738 #endif
1739
1740         int i;
1741         for(i = Func_Type_Connectivity; i < Func_Type_MAX; i++)
1742                 (ad->load_fns[i]) (ad);
1743
1744         memset(ad->load_fns, 0, Func_Type_MAX *sizeof(menu_list_load_fn));
1745         SETTING_TRACE_END;
1746         return SETTING_RETURN_SUCCESS;
1747 }
1748
1749 static int setting_main_create(void *cb)
1750 {
1751         retv_if(cb == NULL, SETTING_GENERAL_ERR_NULL_DATA_PARAMETER);
1752
1753         setting_main_appdata *ad = (setting_main_appdata *) cb;
1754         g_main_ad = ad;
1755         //pass NULL to let TAPI access default module
1756         ad->handle = tel_init(NULL);
1757         if (!ad->handle) {
1758                 SETTING_TRACE_ERROR("*** [ERR] tel_init failed ***");
1759         } else {
1760                 SETTING_TRACE("tel_init ok[handle:%p]", ad->handle);
1761         }
1762         setting_create_Gendial_itc("dialogue/1text.1icon.2",
1763                                    &(ad->itc[GENDIAL_Type_1text_1icon_2]));
1764         setting_create_Gendial_itc("dialogue/1text.2icon",
1765                                    &(ad->itc[GENDIAL_Type_1text_2icon]));
1766         setting_create_Gendial_itc("dialogue/2text.1icon.3",
1767                                    &(ad->itc[GENDIAL_Type_1icon_2text]));
1768         setting_create_Gendial_itc("dialogue/1text.1icon.2",
1769                                    &(ad->itc[GENDIAL_Type_1text_2icon_2]));
1770         setting_create_Gendial_itc("dialogue/2text.2icon.3",
1771                                    &(ad->itc[GENDIAL_Type_2text_2icon_3]));
1772         setting_create_Gendial_itc("dialogue/title",
1773                                    &(ad->itc[GENDIAL_Type_group_item]));
1774         setting_create_Gendial_itc("select_all",
1775                                    &(ad->itc[GENDIAL_Type_sel_all]));
1776
1777         setting_create_Gendial_itc("dialogue/2text.3", &(ad->itc[GENDIAL_Type_2text_3]));
1778
1779         ad->view_type = SETTING_VIEW_MAIN;
1780         __setting_create_main_view(ad);
1781
1782         setting_view_main.is_create = 1;
1783
1784         return SETTING_RETURN_SUCCESS;
1785 }
1786
1787 static int setting_main_destroy(void *cb)
1788 {
1789         SETTING_TRACE_BEGIN;
1790         /* error check */
1791         retv_if(cb == NULL, SETTING_GENERAL_ERR_NULL_DATA_PARAMETER);
1792
1793         setting_main_appdata *ad = (setting_main_appdata *) cb;
1794         if (0 == setting_view_main.is_create)
1795         {
1796                 //already not exsit
1797                 return SETTING_RETURN_SUCCESS;
1798         }
1799
1800     evas_object_smart_callback_del(ad->conform, "virtualkeypad,state,on", __setting_show_title_toolbar);
1801     evas_object_smart_callback_del(ad->conform, "virtualkeypad,state,off", __setting_hide_title_toolbar);
1802
1803         if (ad->refresh_idler) {
1804                 ecore_idler_del(ad->refresh_idler);
1805                 ad->refresh_idler = NULL;
1806         }
1807
1808         if (ad->handle) {
1809                 int tapi_ret = tel_deinit(ad->handle);
1810                 if (tapi_ret != TAPI_API_SUCCESS) {
1811                         SETTING_TRACE_DEBUG("*** [ERR] tel_deinit. [%d] ***", tapi_ret);
1812                 } else {
1813                         SETTING_TRACE("***  tel_deinit OK ");
1814                 }
1815                 ad->handle = NULL;
1816         }
1817
1818         /* then destroy the UI object. */
1819         if (ad->item_check_list) {
1820                 eina_list_free(ad->item_check_list);
1821                 ad->item_check_list = NULL;
1822         } else {
1823                 SETTING_TRACE("*** ad->item_check_list is NULL - abnormal state ");
1824         }
1825
1826         if (ad->ly_main) {
1827                 evas_object_del(ad->ly_main);
1828                 ad->ly_main = NULL;
1829         }
1830
1831         if (ad->flight_popup) {
1832                 evas_object_del(ad->flight_popup);
1833                 ad->flight_popup = NULL;
1834         }
1835
1836 #if 0
1837         if (ad->plugin_node)
1838         {
1839                 setting_plugin_destroy(ad->plugin_node);
1840         }
1841 #endif
1842
1843         evas_object_smart_callback_del(ad->main_genlist, "realized", __gl_realized);
1844
1845         setting_view_main.is_create = 0;
1846         SETTING_TRACE_END;
1847         return SETTING_RETURN_SUCCESS;
1848 }
1849
1850 static int setting_main_update(void *cb)
1851 {
1852         SETTING_TRACE_BEGIN;
1853
1854         /* error check */
1855         retv_if(cb == NULL, SETTING_GENERAL_ERR_NULL_DATA_PARAMETER);
1856
1857         setting_main_appdata *ad = (setting_main_appdata *) cb;
1858
1859         if (ad->ly_main != NULL) {
1860                 //evas_object_show(ad->ly_main);
1861         }
1862
1863         return SETTING_RETURN_SUCCESS;
1864 }
1865
1866 static int setting_main_cleanup(void *cb)
1867 {
1868         SETTING_TRACE_BEGIN;
1869         /* error check */
1870         retv_if(cb == NULL, SETTING_GENERAL_ERR_NULL_DATA_PARAMETER);
1871
1872         setting_main_appdata *ad = (setting_main_appdata *) cb;
1873
1874         if (ad->ly_main != NULL) {
1875                 //evas_object_hide(ad->ly_main);
1876         }
1877
1878         return SETTING_RETURN_SUCCESS;
1879 }
1880
1881 /* ***************************************************
1882  *
1883  *general func
1884  *
1885  ***************************************************/
1886
1887 void setting_update_gl_item(void* data)
1888 {
1889         SETTING_TRACE_BEGIN;
1890         setting_main_appdata *ad = data;
1891         retm_if(!data, "Invalid argument: data is NULL");
1892
1893         int nDx = 0;
1894         Eina_Bool bGlUpdate = EINA_FALSE;
1895         Setting_GenGroupItem_Data *item_to_update = NULL;
1896
1897         for(;nDx<GL_ITEM_MAX; nDx++) {
1898                 if(EINA_TRUE == ad->updateItems[nDx]) {
1899                         switch (nDx)
1900                         {
1901                         case GL_ITEM_WIFI:
1902                                 item_to_update = ad->data_wifi;
1903                                 bGlUpdate = EINA_TRUE;
1904                                 break;
1905                         case GL_ITEM_BT:
1906                                 item_to_update = ad->data_bt;
1907                                 bGlUpdate = EINA_TRUE;
1908                                 break;
1909                         case GL_ITEM_NFC:
1910                                 item_to_update = ad->data_nfc;
1911                                 bGlUpdate = EINA_TRUE;
1912                                 break;
1913                         case GL_ITEM_FLIGHT:
1914                                 item_to_update = ad->data_flight;
1915                                 bGlUpdate = EINA_FALSE;
1916                                 break;
1917
1918
1919
1920
1921                         default: // other case
1922                                 continue;
1923                         }
1924
1925                         if (item_to_update) {
1926                                 SETTING_TRACE("gl update [%s], bGlUpdate:%d", _(item_to_update->keyStr), bGlUpdate);
1927                                 if(bGlUpdate) {
1928                                         SETTING_TRACE("gl update:%d", nDx);
1929                                         elm_object_item_data_set(item_to_update->item, item_to_update);
1930                                         elm_genlist_item_update(item_to_update->item);
1931                                 } else {
1932                                         SETTING_TRACE("chk update:%d", nDx);
1933                                         elm_check_state_set(item_to_update->eo_check, item_to_update->chk_status);
1934                                 }
1935                         }
1936
1937                         ad->updateItems[nDx] = EINA_FALSE;
1938                 } // if(EINA_TRUE == ad->updateItems[nDx])
1939
1940         }
1941
1942         SETTING_TRACE_END;
1943         return;
1944 }
1945
1946 void setting_main_destroy_ug_cb(ui_gadget_h ug, void *priv)
1947 {
1948         setting_main_appdata *ad = (setting_main_appdata *) priv;
1949         if (!ad)
1950                 return;         /*  do nothing if ad is NULL */
1951
1952         if (ug) {
1953                 ug_destroy(ug);
1954                 ad->ug = NULL;
1955         }
1956
1957         setting_main_click_list_item_reset_data(ad, NULL);
1958
1959         // update main genlist in unloading UG
1960         SETTING_TRACE("update main genlist in unloading UG");
1961         setting_update_gl_item(ad);
1962
1963         SETTING_TRACE_END;
1964 }
1965
1966 void setting_main_result_ug_cb(ui_gadget_h ug, service_h service,
1967                                       void *priv)
1968 {
1969         if (!priv) return;
1970
1971         // set default local automatically
1972         set_defaultLangICU();
1973 }
1974
1975 void setting_main_layout_ug_cb(ui_gadget_h ug, enum ug_mode mode,
1976                                       void *priv)
1977 {
1978         setting_main_appdata *ad = (setting_main_appdata *) priv;
1979         Evas_Object *base;
1980
1981         if (!priv)
1982                 return;
1983         SETTING_TRACE_BEGIN;
1984
1985         base = (Evas_Object *) ug_get_layout(ug);
1986         if (!base)
1987                 return;
1988
1989         switch (mode) {
1990         case UG_MODE_FULLVIEW:
1991                 evas_object_size_hint_weight_set(base, EVAS_HINT_EXPAND,
1992                                                  EVAS_HINT_EXPAND);
1993                 evas_object_show(base);
1994                 break;
1995         default:
1996                 break;
1997         }
1998
1999         SETTING_TRACE_END;
2000 }
2001
2002 /* ***************************************************
2003  *
2004  *call back func
2005  *
2006  ***************************************************/
2007
2008 void setting_main_click_list_item_reset_data(void *data,
2009                                                     Evas_Object *obj)
2010 {
2011         SETTING_TRACE_BEGIN;
2012         setting_main_appdata *ad = (setting_main_appdata *) data;
2013
2014         ad->isInUGMode = FALSE;
2015
2016         SETTING_TRACE_END;
2017 }
2018
2019 void /* obj is the layout clicked */
2020 setting_main_click_list_item_ug_cb(void *data, Evas_Object *obj,
2021                                    char *ug_to_load, service_h svc,
2022                                    struct ug_cbs *cbs)
2023 {
2024         SETTING_TRACE_BEGIN;
2025         setting_main_appdata *ad = (setting_main_appdata *) data;
2026         if (!ug_to_load) {
2027                 setting_create_simple_popup(ad, ad->win_main, NULL, NO_UG_FOUND_MSG);
2028                 return;
2029         }
2030 #if DISABLED_CODE
2031         char ug_file[PATH_MAX];
2032         if (snprintf
2033             (ug_file, PATH_MAX, "%s/libug-%s.so", SETTING_UG_PATH,
2034              ug_to_load) < 0)
2035                 return;
2036         SETTING_TRACE("ug_file:%s", ug_file);
2037         if (!ecore_file_exists(ug_file)) {
2038                 setting_create_simple_popup(ad, ad->win_main, NULL, NO_UG_FOUND_MSG);
2039                 return;
2040         }
2041 #endif
2042         SETTING_TRACE("to create libug-%s.so", ug_to_load);
2043         ad->ug = ug_create(NULL, ug_to_load, UG_MODE_FULLVIEW, svc, cbs);
2044         if (ad->ug) {
2045                 ad->isInUGMode = TRUE;
2046                 memset(ad->cur_loaded_ug, 0x00, MAX_DISPLAY_NAME_LEN_ON_UI);
2047                 safeCopyStr(ad->cur_loaded_ug, ug_to_load, MAX_DISPLAY_NAME_LEN_ON_UI);
2048         } else {
2049
2050                 evas_object_show(ad->ly_main);
2051
2052                 SETTING_TRACE_ERROR("errno:%d", errno);
2053                 setting_create_simple_popup(ad, ad->win_main, NULL, NO_UG_FOUND_MSG);
2054         }
2055         SETTING_TRACE_END;
2056 }
2057
2058 void
2059 setting_main_click_list_default_ug_cb(void *data, Evas_Object *obj,
2060                                       void *event_info)
2061 {
2062         setting_main_appdata *ad = data;
2063         setting_create_simple_popup(ad, ad->win_main, NULL,
2064                                           NO_UG_FOUND_MSG);
2065 }
2066
2067 void
2068 setting_main_click_list_usb_cb(void *data, Evas_Object *obj, void *event_info)
2069 {
2070         SETTING_TRACE_BEGIN;
2071         retm_if(event_info == NULL, "Invalid argument: event info is NULL");
2072
2073         int err;
2074         int value = -1;
2075         char *str_text = USB_NEED_OFF;
2076
2077         Elm_Object_Item *item = (Elm_Object_Item *) event_info;
2078 #if 0
2079         setting_get_int_slp_key(INT_SLP_SETTING_MOBILE_AP_STATUS, &value, &err);
2080         if (err != 0)
2081         {
2082                 SETTING_TRACE_ERROR("FAIL: VCONFKEY_MOBILE_HOTSPOT_MODE may not exist\n");
2083                 setting_main_click_list_ex_ug_cb(data, obj, item);
2084                 return;
2085         }
2086 #endif
2087         /* If mobile hotspot is on, going USB utilties is blocked by a popup*/
2088         if (value & VCONFKEY_MOBILE_HOTSPOT_MODE_USB)
2089         {
2090                 elm_genlist_item_selected_set(item, EINA_FALSE);
2091                 setting_create_simple_popup(g_main_ad, g_main_ad->win_main, NULL, (str_text));
2092         }
2093         else
2094         {
2095                 setting_main_click_list_ex_ug_cb(data, obj, item);
2096         }
2097
2098         SETTING_TRACE_END;
2099 }
2100
2101 void setting_main_click_list_more_cb(void *data, Evas_Object *obj, void *event_info)
2102 {
2103         SETTING_TRACE_BEGIN;
2104         retm_if(event_info == NULL, "Invalid argument: event info is NULL");
2105         Elm_Object_Item *item = (Elm_Object_Item *) event_info;
2106         elm_genlist_item_selected_set(item, EINA_FALSE);
2107         retm_if(data == NULL, "Invalid argument: data is NULL");
2108         setting_main_appdata *ad = data;
2109         Setting_GenGroupItem_Data *selected_item_data =
2110                     (Setting_GenGroupItem_Data *) elm_object_item_data_get(item);
2111         SETTING_TRACE("selected_item_data->keyStr:%s", selected_item_data->keyStr);
2112         if (0 == safeStrCmp(selected_item_data->keyStr, KeyStr_MoreConnect))
2113         {
2114                 ad->view_load = SETTING_VIEW_CONNECTIVE_MORE;
2115         }
2116         else if (0 == safeStrCmp(selected_item_data->keyStr, KeyStr_MoreSystem))
2117         {
2118                 ad->view_load = SETTING_VIEW_SYSTEM_MORE;
2119         }
2120         else
2121         {
2122                 return;
2123         }
2124         setting_view_change(&setting_view_main, &setting_view_more_menu, ad);
2125 }
2126
2127
2128 void
2129 setting_main_click_list_ex_ug_cb(void *data, Evas_Object *obj,
2130                                  void *event_info)
2131 {
2132         SETTING_TRACE_BEGIN;
2133         retm_if(event_info == NULL, "Invalid argument: event info is NULL");
2134         Elm_Object_Item *item = (Elm_Object_Item *) event_info;
2135
2136         elm_genlist_item_selected_set(item, EINA_FALSE);
2137
2138         if (g_main_ad->ug) {
2139                 SETTING_TRACE
2140                     ("[ad->ug non-NULL]skip genlist click event!!");
2141
2142                 SETTING_TRACE_END;
2143                 return;
2144         }
2145
2146         if (NULL == data) {     /* pass NULL to ug_args when create setting.cfg. */
2147                 setting_create_simple_popup(g_main_ad,
2148                                           g_main_ad->win_main,
2149                                           NULL, NO_UG_FOUND_MSG);
2150                 SETTING_TRACE_END;
2151                 return;
2152         }
2153
2154         setting_main_appdata *ad = g_main_ad;
2155
2156         /*  if UG is created by Setting app, setting_main_click_list_ex_ug_cb is diabled. */
2157         if (ad->isInUGMode) {
2158                 SETTING_TRACE("isInUGMode : TRUE - another UG is running now.");
2159                 ad->isInUGMode = FALSE;
2160                 SETTING_TRACE_END;
2161                 return;
2162         } else {
2163                 SETTING_TRACE
2164                     ("isInUGMode : FALSE - another UG is NOT running now.")
2165         }
2166
2167         Setting_GenGroupItem_Data *selected_item_data =
2168             (Setting_GenGroupItem_Data *) elm_object_item_data_get(item);
2169         setting_main_click_list_item_reset_data(ad, obj);
2170         const char *item_name = _(selected_item_data->keyStr);
2171         ret_if(!item_name);
2172
2173         struct ug_cbs *cbs = (struct ug_cbs *)calloc(1, sizeof(struct ug_cbs));
2174         setting_retm_if(!cbs, "calloc failed");
2175         cbs->layout_cb = setting_main_layout_ug_cb;
2176         cbs->result_cb = setting_main_result_ug_cb;
2177         cbs->destroy_cb = setting_main_destroy_ug_cb;
2178         cbs->priv = (void *)ad;
2179
2180         char *path = get_ug_path_from_ug_args(data);
2181         service_h svc = get_bundle_from_ug_args(data);
2182         setting_main_click_list_item_ug_cb(ad, obj, path, svc, cbs);
2183         if (path)
2184                 FREE(path);
2185         if (cbs)
2186                 FREE(cbs);
2187         path = NULL;
2188         cbs = NULL;
2189         service_destroy(svc);
2190 }
2191 void
2192 setting_main_click_list_plugin_cb(void *data, Evas_Object *obj,
2193                                  void *event_info)
2194 {
2195         SETTING_TRACE_BEGIN;
2196         retm_if(event_info == NULL, "Invalid argument: event info is NULL");
2197         Elm_Object_Item *item = (Elm_Object_Item *) event_info;
2198         elm_genlist_item_selected_set(item, EINA_FALSE);
2199
2200         setting_main_appdata *ad = data;
2201         if (ad->plugin_path)
2202         {
2203                 PluginNode* plugin_node = setting_plugin_create();
2204
2205                 plugin_node->plugin_path = strdup(ad->plugin_path);
2206
2207                 setting_plugin_load(plugin_node, (const char *)ad->plugin_path);
2208                 ad->plugin_node = (void*)plugin_node;
2209
2210                 #if 0
2211                 if(ad->plugin_path)
2212                 {
2213                         free(ad->plugin_path);
2214                         ad->plugin_path = NULL;
2215                 }
2216                 #endif
2217         }
2218 }
2219
2220 /**
2221  * @see [caller] setting_main_list_mouse_up_cb
2222  * @see [caller] setting_main_sel_list_mouse_up_cb
2223  */
2224 static void __rotate_lock_handler(int chk_status, setting_main_appdata *ad )
2225 {
2226         SETTING_TRACE_BEGIN;
2227         if( chk_status == 1)
2228         {
2229                 // toggle : 0 --> 1
2230                 int angle = elm_win_rotation_get(ad->win_main);
2231                 elm_win_rotation_with_resize_set(ad->win_main, angle);
2232         } else {
2233                 elm_win_rotation_with_resize_set(ad->win_main, 0);
2234         }
2235         vconf_set_bool(VCONFKEY_SETAPPL_ROTATE_LOCK_BOOL, !chk_status);
2236 }
2237
2238 /**
2239  * toggle cb
2240  */
2241 void setting_main_list_mouse_up_cb(void *data, Evas_Object *eo,
2242                                           void *event_info)
2243 {
2244         SETTING_TRACE_BEGIN;
2245         retm_if(data == NULL, "Data parameter is NULL");
2246         Setting_GenGroupItem_Data *list_item =
2247             (Setting_GenGroupItem_Data *) data;
2248         SETTING_TRACE("process item [%s]", list_item->keyStr);
2249         list_item->chk_status = elm_check_state_get(eo);        /* for update new state */
2250
2251         SETTING_TRACE("change radio[%s], status is:%d", _(list_item->keyStr),
2252                       list_item->chk_status);
2253         setting_main_appdata *ad = g_main_ad;
2254
2255         if (!safeStrCmp(KeyStr_UsePacketData, list_item->keyStr)) {
2256                 int err;
2257                 if (elm_check_state_get(eo)) {
2258                         setting_set_bool_slp_key
2259                             (BOOL_SLP_SETTING_USE_PACKET_DATA,
2260                              SETTING_ON_OFF_BTN_ON, &err);
2261                 } else {
2262                         setting_set_bool_slp_key
2263                             (BOOL_SLP_SETTING_USE_PACKET_DATA,
2264                              SETTING_ON_OFF_BTN_OFF, &err);
2265                 }
2266
2267         } else if (!safeStrCmp(KeyStr_Landscape, list_item->keyStr)) {
2268                 __rotate_lock_handler(list_item->chk_status, ad);
2269         }
2270
2271         return;
2272 }
2273
2274 /**
2275  * genlist touch cb
2276  */
2277 void setting_main_sel_list_mouse_up_cb(void *data, Evas_Object *eo,
2278                                               void *event_info)
2279 {
2280         SETTING_TRACE_BEGIN;
2281         setting_retm_if(data == NULL, "Data parameter is NULL");
2282
2283         retm_if(event_info == NULL, "Invalid argument: event info is NULL");
2284         Elm_Object_Item *item = (Elm_Object_Item *) event_info;
2285         elm_genlist_item_selected_set(item, 0);
2286         Setting_GenGroupItem_Data *list_item =
2287             (Setting_GenGroupItem_Data *) elm_object_item_data_get(item);
2288
2289         list_item->chk_status = elm_check_state_get(list_item->eo_check);
2290
2291         /* new status */
2292     list_item->chk_status = !list_item->chk_status;
2293     elm_check_state_set(list_item->eo_check, list_item->chk_status);
2294
2295         setting_main_appdata *ad = (setting_main_appdata *) data;
2296         if (!safeStrCmp(KeyStr_UsePacketData, list_item->keyStr)) {
2297                 /* setting_reset_slp_key_by_status(eo, BOOL_SLP_SETTING_USE_PACKET_DATA); */
2298                 int err;
2299                 setting_set_bool_slp_key(BOOL_SLP_SETTING_USE_PACKET_DATA,
2300                                          list_item->chk_status, &err);
2301
2302         } else if (!safeStrCmp(KeyStr_Landscape, list_item->keyStr)) {
2303                 __rotate_lock_handler(list_item->chk_status, ad);
2304         }
2305
2306         return;
2307 }
2308
2309 void __alternate_flight_mode(Evas_Object *check)
2310 {
2311         SETTING_TRACE_BEGIN;
2312         int ret;
2313         Eina_Bool status =  elm_check_state_get(check);
2314         SETTING_TRACE("flight mode status : %d", status);
2315         setting_main_appdata *ad = g_main_ad;
2316
2317         //Check whether some requestion is processing by TAPI
2318         if (ad->b_fm_requesting)
2319         {
2320                 //Do nothing, just mark the lastest operation..
2321                 SETTING_TRACE("Some requestion is processing by TAPI, wait to process");
2322                 ad->fm_waiting_op = status ? FM_ENTER : FM_LEAVE;
2323                 return;
2324         }
2325
2326         //otherwise, invalid waiting operation and send requsetion to TAPI:
2327         ad->fm_waiting_op = FM_INVALID;
2328         if (status) {
2329                 ret = tel_set_flight_mode(ad->handle, TAPI_POWER_FLIGHT_MODE_ENTER,setting_main_tapi_event_cb,ad);
2330                 setting_retm_if(ret != TAPI_API_SUCCESS,
2331                                 "*** [ERR] tel_set_flight_mode(TAPI_POWER_FLIGHT_MODE_ENTER) ***");
2332         } else {
2333                 ret = tel_set_flight_mode(ad->handle, TAPI_POWER_FLIGHT_MODE_LEAVE,setting_main_tapi_event_cb,ad);
2334                 setting_retm_if(ret != TAPI_API_SUCCESS,
2335                                 "*** [ERR] tel_set_flight_mode(TAPI_POWER_FLIGHT_MODE_LEAVE) ***");
2336         }
2337
2338         //sucessfully sent,
2339         ad->b_fm_requesting = TRUE;
2340         SETTING_TRACE_END;
2341 }
2342
2343 void __alternate_wifi_mode(Evas_Object *check)
2344 {
2345         SETTING_TRACE_BEGIN;
2346         int ret;
2347         Eina_Bool status =  elm_check_state_get(check);
2348         SETTING_TRACE("wifi mode status : %d", status);
2349
2350         ret = wifi_initialize();
2351         setting_retm_if(ret < 0, "*** [ERR] wifi_initialize() ***");
2352
2353
2354         if (status) {
2355                 ret = wifi_activate(NULL, NULL);
2356                 setting_retm_if(ret < 0,
2357                                 "*** [ERR] wifi_activate() ***");
2358         } else {
2359                 ret = wifi_deactivate(NULL, NULL);
2360                 setting_retm_if(ret < 0,
2361                                 "*** [ERR] wifi_deactivate() ***");
2362         }
2363         ret = wifi_deinitialize();
2364         setting_retm_if(ret < 0, "*** [ERR] wifi_deinitialize() ***");
2365
2366         SETTING_TRACE_END;
2367 }
2368
2369 void __alternate_bt_mode(Evas_Object *check)
2370 {
2371         SETTING_TRACE_BEGIN;
2372         int ret;
2373         Eina_Bool status =  elm_check_state_get(check);
2374         SETTING_TRACE("bt mode status : %d", status);
2375
2376         ret = bt_initialize();
2377         setting_retm_if(ret < 0, "*** [ERR] bt_initialize() ***");
2378
2379
2380         if (status) {
2381                 ret = bt_adapter_enable();
2382                 setting_retm_if(ret < 0,
2383                                 "*** [ERR] bt_adapter_enable() ***");
2384         } else {
2385                 ret = bt_adapter_disable();
2386                 setting_retm_if(ret < 0,
2387                                 "*** [ERR] bt_adapter_disable() ***");
2388         }
2389
2390         ret = bt_deinitialize();
2391         setting_retm_if(ret < 0, "*** [ERR] bt_deinitialize() ***");
2392
2393         SETTING_TRACE_END;
2394 }
2395
2396 void __alternate_nfc_mode(Evas_Object *check)
2397 {
2398         SETTING_TRACE_BEGIN;
2399         int ret;
2400         Eina_Bool status =  elm_check_state_get(check);
2401         SETTING_TRACE("nfc mode status : %d", status);
2402
2403         ret = nfc_manager_initialize(NULL, NULL);
2404         setting_retm_if(ret < 0, "*** [ERR] nfc_manager_initialize() ***");
2405
2406
2407         ret = nfc_manager_set_activation(status, NULL, NULL);
2408         setting_retm_if(ret < 0,
2409                         "*** [ERR] nfc_manager_set_activation() ***");
2410
2411         ret = nfc_manager_deinitialize();
2412         setting_retm_if(ret < 0, "*** [ERR] nfc_manager_deinitialize() ***");
2413
2414         SETTING_TRACE_END;
2415 }
2416
2417 void __alternate_sbeam_mode(Evas_Object *check)
2418 {
2419         SETTING_TRACE_BEGIN;
2420         int ret;
2421         Eina_Bool status =  elm_check_state_get(check);
2422         SETTING_TRACE("wifi mode status : %d", status);
2423
2424         vconf_set_bool(VCONFKEY_NFC_SBEAM, status);
2425
2426         SETTING_TRACE_END;
2427 }
2428
2429 void
2430 setting_main_click_list_network_ug_cb(void *data, Evas_Object *obj,
2431                                       void *event_info)
2432 {
2433         SETTING_TRACE_BEGIN;
2434         retm_if(event_info == NULL, "Invalid argument: event info is NULL");
2435         Elm_Object_Item *item = (Elm_Object_Item *) event_info;
2436
2437         elm_genlist_item_selected_set(item, EINA_FALSE);
2438
2439         if (g_main_ad->ug) {
2440                 SETTING_TRACE
2441                     ("[ad->ug non-NULL]skip genlist click event!!");
2442
2443                 SETTING_TRACE_END;
2444                 return;
2445         }
2446
2447         setting_main_appdata *ad = g_main_ad;
2448         setting_main_click_list_item_reset_data(ad, obj);
2449
2450         int err = 0;
2451         int value;
2452         setting_get_int_slp_key(INT_SLP_SETTING_SIM_SLOT, &value, &err);
2453         SETTING_TRACE("value:%d", value);
2454         switch (value) {
2455         case VCONFKEY_TELEPHONY_SIM_INSERTED:
2456                 {
2457                         struct ug_cbs *cbs =
2458                             (struct ug_cbs *)calloc(1, sizeof(struct ug_cbs));
2459                         setting_retm_if(!cbs, "calloc failed");
2460                         cbs->layout_cb = setting_main_layout_ug_cb;
2461                         cbs->result_cb = setting_main_result_ug_cb;
2462                         cbs->destroy_cb = setting_main_destroy_ug_cb;
2463                         cbs->priv = (void *)ad;
2464                         setting_main_click_list_item_ug_cb(data, obj,
2465                                                            "setting-network-efl",
2466                                                            NULL, cbs);
2467                         FREE(cbs);
2468                         break;
2469                 }
2470         case VCONFKEY_TELEPHONY_SIM_NOT_PRESENT:
2471                 setting_create_simple_popup(NULL, ad->win_main,
2472                                             NULL, _("IDS_ST_HEADER_INSERT_SIM_CARD_ABB"));
2473                 SETTING_TRACE("%s*** [ERR] No SIM. sim_slot_type=%d ***%s",
2474                               SETTING_FONT_RED, value, SETTING_FONT_BLACK);
2475                 return;
2476                 break;
2477         case VCONFKEY_TELEPHONY_SIM_CARD_ERROR:
2478         case VCONFKEY_TELEPHONY_SIM_UNKNOWN:
2479                 setting_create_simple_popup(NULL, ad->win_main,
2480                                             NULL,_("IDS_COM_BODY_INVALID_SIM_CARD"));
2481                 SETTING_TRACE("%s*** [ERR] Invalid SIM. sim_slot_type=%d ***%s",
2482                               SETTING_FONT_RED, value, SETTING_FONT_BLACK);
2483                 return;
2484                 break;
2485         default:
2486                 break;
2487         }
2488
2489 }
2490
2491 /**
2492  * genlist touch cb
2493  */
2494 static void
2495 setting_main_click_Gendial_list_flight_mode_cb(void *data, Evas_Object *obj,
2496                                                void *event_info)
2497 {
2498     /* error check */
2499     setting_retm_if(data == NULL, "Data parameter is NULL");
2500
2501     retm_if(event_info == NULL, "Invalid argument: event info is NULL");
2502     Elm_Object_Item *item = (Elm_Object_Item *) event_info;
2503     elm_genlist_item_selected_set(item, 0);
2504     Setting_GenGroupItem_Data *list_item =
2505         (Setting_GenGroupItem_Data *) elm_object_item_data_get(item);
2506     int old_status = elm_check_state_get(list_item->eo_check);
2507     /* new status */
2508     list_item->chk_status = !old_status;
2509     elm_check_state_set(list_item->eo_check, list_item->chk_status);
2510
2511     __alternate_flight_mode(list_item->eo_check);
2512     SETTING_TRACE_END;
2513 }
2514
2515 /**
2516  * toggle cb
2517  */
2518 void
2519 setting_main_click_list_flight_mode_cb(void *data, Evas_Object *obj,
2520                                        void *event_info)
2521 {
2522         SETTING_TRACE_BEGIN;
2523         retm_if(data == NULL, "Data parameter is NULL");
2524         Setting_GenGroupItem_Data *list_item =
2525             (Setting_GenGroupItem_Data *) data;
2526         list_item->chk_status = elm_check_state_get(obj);       /* for update new state */
2527         SETTING_TRACE("process item [%s], status:%d", _(list_item->keyStr),
2528                       list_item->chk_status);
2529
2530         __alternate_flight_mode(obj);
2531         SETTING_TRACE_END;
2532 }
2533
2534 /**
2535  * toggle cb
2536  */
2537 void
2538 setting_main_click_list_wifi_mode_cb(void *data, Evas_Object *obj,
2539                                        void *event_info)
2540 {
2541         SETTING_TRACE_BEGIN;
2542         retm_if(data == NULL, "Data parameter is NULL");
2543         Setting_GenGroupItem_Data *list_item =
2544             (Setting_GenGroupItem_Data *) data;
2545         list_item->chk_status = elm_check_state_get(obj);       /* for update new state */
2546         SETTING_TRACE("process item [%s], status:%d", _(list_item->keyStr),
2547                       list_item->chk_status);
2548
2549         __alternate_wifi_mode(obj);
2550         SETTING_TRACE_END;
2551 }
2552
2553 /**
2554  * toggle cb
2555  */
2556 void
2557 setting_main_click_list_bt_mode_cb(void *data, Evas_Object *obj,
2558                                        void *event_info)
2559 {
2560         SETTING_TRACE_BEGIN;
2561         retm_if(data == NULL, "Data parameter is NULL");
2562         Setting_GenGroupItem_Data *list_item =
2563             (Setting_GenGroupItem_Data *) data;
2564         list_item->chk_status = elm_check_state_get(obj);       /* for update new state */
2565         SETTING_TRACE("process item [%s], status:%d", _(list_item->keyStr),
2566                       list_item->chk_status);
2567
2568         __alternate_bt_mode(obj);
2569         SETTING_TRACE_END;
2570 }
2571
2572 /**
2573  * toggle cb
2574  */
2575 void
2576 setting_main_click_list_nfc_mode_cb(void *data, Evas_Object *obj,
2577                                        void *event_info)
2578 {
2579         SETTING_TRACE_BEGIN;
2580         retm_if(data == NULL, "Data parameter is NULL");
2581         Setting_GenGroupItem_Data *list_item =
2582             (Setting_GenGroupItem_Data *) data;
2583         list_item->chk_status = elm_check_state_get(obj);       /* for update new state */
2584         SETTING_TRACE("process item [%s], status:%d", _(list_item->keyStr),
2585                       list_item->chk_status);
2586
2587         __alternate_nfc_mode(obj);
2588         SETTING_TRACE_END;
2589 }
2590
2591 /**
2592  * toggle cb
2593  */
2594 void
2595 setting_main_click_list_sbeam_mode_cb(void *data, Evas_Object *obj,
2596                                        void *event_info)
2597 {
2598         SETTING_TRACE_BEGIN;
2599         retm_if(data == NULL, "Data parameter is NULL");
2600         Setting_GenGroupItem_Data *list_item =
2601             (Setting_GenGroupItem_Data *) data;
2602         list_item->chk_status = elm_check_state_get(obj);       /* for update new state */
2603         SETTING_TRACE("process item [%s], status:%d", _(list_item->keyStr),
2604                       list_item->chk_status);
2605
2606         __alternate_sbeam_mode(obj);
2607         SETTING_TRACE_END;
2608 }
2609
2610 /**
2611  * store current selection in setting.cfg
2612  */
2613 void setting_try_save_check_list(void *data)
2614 {
2615         SETTING_TRACE_BEGIN;
2616         setting_main_appdata *ad = (setting_main_appdata *) data;
2617
2618         Eina_List *check_list = ad->item_check_list;
2619         Setting_GenGroupItem_Data *list_item = NULL;
2620         int update_count = 0;
2621
2622         while (check_list) {
2623                 list_item = (Setting_GenGroupItem_Data *) eina_list_data_get(check_list);
2624                 if (NULL == list_item) continue;
2625
2626                 update_count++;
2627                 if (list_item->chk_status) {
2628                         /* to update config file */
2629                         setting_cfg_set_pos(list_item->keyStr, Cfg_Item_Pos_Level0);
2630                 } else {
2631                         /* to update config file */
2632                         setting_cfg_set_pos(list_item->keyStr, Cfg_Item_Pos_Level1);
2633                 }
2634                 check_list = eina_list_next(check_list);
2635         }
2636
2637         if (update_count == 0) {
2638                 /* to popup tips notify */
2639         } else {
2640                 setting_cfg_file_update();
2641         }
2642         SETTING_TRACE_END;
2643 }
2644
2645 void
2646 setting_main_click_edit_preferred_cb(void *data, Evas_Object *obj, void *event_info)
2647 {
2648         SETTING_TRACE_BEGIN;
2649
2650         setting_main_appdata *ad = (setting_main_appdata *) data;
2651         ad->view_type = SETTING_VIEW_ALL_CHECK;
2652         __setting_create_prefered_view(ad);
2653         __load_check_list(ad, &(ad->edit_preferred_genlist), NULL);
2654
2655         SETTING_TRACE_END;
2656 }