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