Merge "change setting icon for TIZEN" into 2.0_beta
[apps/core/preloaded/settings.git] / setting-network / src / setting-network.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 #include <setting-network.h>
22 #include <setting-network-preferred-network-delete.h>
23 #include <setting-network-preferred-network.h>
24 #include <setting-debug.h>
25
26 #ifndef UG_MODULE_API
27 #define UG_MODULE_API __attribute__ ((visibility("default")))
28 #endif
29 int setting_network_subscribe_tapi_events(void *data);
30 int setting_network_unsubscribe_tapi_events(void *data);
31
32 static void __selected_network_change_cb(keynode_t *key, void *data)
33 {
34         SETTING_TRACE_BEGIN;
35         setting_retm_if(!data, "!data");
36         SettingNetworkUG *ad = data;
37         char *value = vconf_keynode_get_str(key);
38         char *vconf_name = vconf_keynode_get_name(key);
39         if (!safeStrCmp(vconf_name, VCONFKEY_TELEPHONY_NWNAME)) {
40                 if (NULL == value) {
41                     value = "IDS_ST_BODY_NOSERVICE";
42                 }
43                 ad->sel_network = strdup(value);
44
45                 if (0 != vconf_set_int(VCONFKEY_SETAPPL_SELECT_NETWORK_INT, ad->sel_net)) {
46                         SETTING_TRACE_ERROR("vconf[%s] set failed");
47                 }
48                 
49                 if (0 != vconf_set_int(VCONFKEY_SETAPPL_SELECT_OLD_NT_ACT, ad->sel_act)) {
50                         SETTING_TRACE_ERROR("vconf[%s] set failed");
51                 }
52
53                 setting_network_update_sel_network(ad);
54         }
55 }
56
57
58 static void setting_network_ug_cb_resize(void *data, Evas *e,
59                                          Evas_Object *obj, void *event_info)
60 {
61         SettingNetworkUG *ad = (SettingNetworkUG *) data;
62         setting_view_update(&setting_view_network_main, ad);
63 }
64
65 void __network_evt_cb(net_event_info_t *event_cb, void *data)
66 {
67 }
68
69 #ifdef SUPPORT_MDM
70 static void __mdm_policy_roaming_sync_receiver_cb(int result, void *p_user_data)
71 {
72         SETTING_TRACE_BEGIN;
73         ret_if(p_user_data == NULL);
74         mdm_status_t policy_status = (mdm_status_t)result;
75         SettingNetworkUG *ad = (SettingNetworkUG*)p_user_data;
76
77         if(policy_status == MDM_ALLOWED)
78         {
79                 setting_enable_genlist_item(ad->data_roaming->item);
80         }
81         else if(policy_status == MDM_RESTRICTED)
82         {
83                 setting_disable_genlist_item(ad->data_roaming->item);
84                 setting_create_popup_without_btn(ad, ad->ly_main, NULL, MDM_POLICY_DATA_ROAMING_RESTRICTED_STR,
85                                           NULL,
86                                           POPUP_INTERVAL, FALSE, FALSE);
87         }
88 }
89 #endif
90 static void *setting_network_ug_on_create(ui_gadget_h ug,
91                                           enum ug_mode mode, service_h service,
92                                           void *priv)
93 {
94         setting_retvm_if((!priv), NULL, "!priv");
95
96         SettingNetworkUG *networkUG = priv;
97         networkUG->ug = ug;
98
99         networkUG->win_main_layout = (Evas_Object *) ug_get_parent_layout(ug);
100         networkUG->win_get = (Evas_Object *) ug_get_window();
101         evas_object_show(networkUG->win_main_layout);
102         networkUG->evas = evas_object_evas_get(networkUG->win_main_layout);
103
104         setting_retvm_if(networkUG->win_main_layout == NULL, NULL,
105                          "cannot get main window ");
106
107
108         /* init */
109         ecore_imf_init();
110
111 #ifdef SUPPORT_MDM
112         networkUG->mdm_server_state = mdm_get_service();
113         SETTING_TRACE("mdm server status: %d", networkUG->mdm_server_state);
114
115         if(networkUG->mdm_server_state == MDM_RESULT_SUCCESS)
116         {
117                 networkUG->mdm_handle = mdm_register_policy_receiver(MDM_POLICY_ON_ROAMING_SYNC, networkUG, __mdm_policy_roaming_sync_receiver_cb);
118                 if(networkUG->mdm_handle == -1)
119                         SETTING_TRACE_DEBUG("[ERR] failed to register mdm policy receiver");
120         }
121 #endif
122
123         //pass NULL to let TAPI access default module
124         networkUG->handle =  tel_init(NULL);
125         if (!networkUG->handle) {
126                 SETTING_TRACE_DEBUG("%s*** [ERR] tel_init. ***%s",
127                                     SETTING_FONT_RED, SETTING_FONT_BLACK);
128                 //return NULL;
129         }
130
131         int err_code = -1;
132         err_code = net_register_client((net_event_cb_t)__network_evt_cb, networkUG);
133         if (err_code != NET_ERR_NONE) {
134                 SETTING_TRACE_DEBUG
135                     ("%s*** [ERR] net_register_client. err=%d ***%s",
136                      SETTING_FONT_RED, err_code, SETTING_FONT_BLACK);
137         }
138
139         /* register view node table */
140         setting_view_node_table_intialize();
141         setting_view_node_table_register(&setting_view_network_main, NULL);
142         setting_view_node_table_register(&setting_view_network_select_network,
143                                          &setting_view_network_main);
144         setting_view_node_table_register(&setting_view_network_main_help,
145                                          &setting_view_network_main);
146
147         setting_view_node_table_register(&setting_view_network_con, &setting_view_network_main);
148         setting_view_node_table_register(&setting_view_network_connection_create, &setting_view_network_con);
149         setting_view_node_table_register(&setting_view_network_3gcon,
150                                          &setting_view_network_main);
151
152         setting_view_node_table_register
153             (&setting_view_network_preferred_network,
154              &setting_view_network_main);
155         setting_view_node_table_register
156             (&setting_view_network_preferred_network_list,
157              &setting_view_network_preferred_network);
158         setting_view_node_table_register
159             (&setting_view_network_preferred_network_new,
160              &setting_view_network_preferred_network);
161         setting_view_node_table_register
162             (&setting_view_network_preferred_network_edit,
163              &setting_view_network_preferred_network);
164         setting_view_node_table_register
165             (&setting_view_network_preferred_network_delete,
166              &setting_view_network_preferred_network);
167
168         if (tel_get_network_band(networkUG->handle, setting_tapi_get_band_cb, networkUG) != TAPI_API_SUCCESS) {
169                 SETTING_TRACE_ERROR("*** [ERR] tel_get_network_band. ***");
170         }
171
172         if (tel_get_network_selection_mode(networkUG->handle, setting_tapi_get_plmn_mode_cb, networkUG) != TAPI_API_SUCCESS) {
173                 SETTING_TRACE_ERROR("*** [ERR] tel_get_network_selection_mode. ***");
174         }
175         
176         if (tel_get_network_serving(networkUG->handle, setting_tapi_get_serving_network_cb, networkUG) != TAPI_API_SUCCESS) {
177                 SETTING_TRACE_ERROR("*** [ERR] tel_get_network_serving. ***");
178         }
179
180         /*  creating a view. */
181         setting_view_node_set_cur_view(&setting_view_network_main);
182         setting_view_create(&setting_view_network_main, (void *)networkUG);
183         evas_object_event_callback_add(networkUG->win_main_layout,
184                                        EVAS_CALLBACK_RESIZE,
185                                        setting_network_ug_cb_resize, networkUG);
186
187         (void)vconf_notify_key_changed(VCONFKEY_TELEPHONY_NWNAME,
188                                      __selected_network_change_cb, networkUG);
189
190         networkUG->view_type_string = NULL;
191         service_get_extra_data(service, "viewtype", &(networkUG->view_type_string));
192         if(networkUG->view_type_string) {
193                 SETTING_TRACE("viewtype:%s", networkUG->view_type_string);
194         }
195         return networkUG->ly_main;
196 }
197
198
199 static void setting_network_ug_on_start(ui_gadget_h ug, service_h service,
200                                         void *priv)
201 {
202 }
203
204 static void setting_network_ug_on_pause(ui_gadget_h ug, service_h service,
205                                         void *priv)
206 {
207 }
208
209 static void setting_network_ug_on_resume(ui_gadget_h ug, service_h service,
210                                          void *priv)
211 {
212 }
213
214 static void setting_network_ug_on_destroy(ui_gadget_h ug, service_h service,
215                                           void *priv)
216 {
217         SETTING_TRACE_BEGIN;
218         setting_retm_if((!priv), "!priv");
219         SettingNetworkUG *networkUG = priv;
220
221         (void)vconf_ignore_key_changed(VCONFKEY_TELEPHONY_NWNAME,
222                                        __selected_network_change_cb);
223         evas_object_event_callback_del(networkUG->win_main_layout, EVAS_CALLBACK_RESIZE, setting_network_ug_cb_resize); /* fix flash issue for gallery */
224         networkUG->ug = ug;
225
226         G_FREE(networkUG->ed_pxy_addr_desc);
227         G_FREE(networkUG->ed_pxy_port_desc);
228         FREE(networkUG->prof_list);
229         FREE(networkUG->sel_network);
230         /* release */
231         ecore_imf_shutdown();
232
233 #ifdef SUPPORT_MDM
234         if(networkUG->mdm_server_state == MDM_RESULT_SUCCESS)
235         {
236                 mdm_deregister_policy_receiver(networkUG->mdm_handle);
237                 mdm_release_service();
238         }
239 #endif
240
241         /*  unregister dnet client */
242         int err_code = net_deregister_client();
243         if (err_code != NET_ERR_NONE) {
244                 SETTING_TRACE_DEBUG
245                     ("%s*** [ERR] net_deregister_client. err=%d ***%s",
246                      SETTING_FONT_RED, err_code, SETTING_FONT_BLACK);
247         }
248
249         if (networkUG->handle && tel_deinit(networkUG->handle) != TAPI_API_SUCCESS) {
250                 SETTING_TRACE_DEBUG
251                     ("%s*** [ERR] setting_network_unsubscribe_tapi_events. ***%s",
252                      SETTING_FONT_RED, SETTING_FONT_BLACK);
253         }
254
255         setting_network_popup_delete(networkUG);
256         /*  delete the allocated objects. */
257         setting_view_destroy(&setting_view_network_select_network, networkUG);
258         setting_view_destroy(&setting_view_network_main_help, networkUG);
259
260         setting_view_destroy(&setting_view_network_con, networkUG);
261         setting_view_destroy(&setting_view_network_connection_create,
262                              networkUG);
263         setting_view_destroy(&setting_view_network_3gcon, networkUG);
264
265         setting_view_destroy(&setting_view_network_preferred_network,
266                              networkUG);
267         setting_view_destroy(&setting_view_network_preferred_network_list,
268                              networkUG);
269         setting_view_destroy(&setting_view_network_preferred_network_new,
270                              networkUG);
271         setting_view_destroy(&setting_view_network_preferred_network_edit,
272                              networkUG);
273         setting_view_destroy(&setting_view_network_preferred_network_delete,
274                              networkUG);
275         setting_view_destroy(&setting_view_network_main, networkUG);
276
277         if (NULL != ug_get_layout(networkUG->ug)) {
278                 evas_object_hide((Evas_Object *) ug_get_layout(networkUG->ug));
279                 evas_object_del((Evas_Object *) ug_get_layout(networkUG->ug));
280         }
281
282         SETTING_TRACE_END;
283 }
284
285 static void setting_network_ug_on_message(ui_gadget_h ug, service_h msg,
286                                           service_h service, void *priv)
287 {
288 }
289
290 static void setting_network_ug_on_event(ui_gadget_h ug,
291                                         enum ug_event event, service_h service,
292                                         void *priv)
293 {
294         SETTING_TRACE_BEGIN;
295         switch (event) {
296         case UG_EVENT_LOW_MEMORY:
297                 break;
298         case UG_EVENT_LOW_BATTERY:
299                 break;
300         case UG_EVENT_LANG_CHANGE:
301                 break;
302         case UG_EVENT_ROTATE_PORTRAIT:
303                 break;
304         case UG_EVENT_ROTATE_PORTRAIT_UPSIDEDOWN:
305                 break;
306         case UG_EVENT_ROTATE_LANDSCAPE:
307                 break;
308         case UG_EVENT_ROTATE_LANDSCAPE_UPSIDEDOWN:
309                 break;
310         case UG_EVENT_REGION_CHANGE:
311                 break;
312         default:
313                 break;
314         }
315 }
316
317 static void setting_network_ug_on_key_event(ui_gadget_h ug,
318                                             enum ug_key_event event,
319                                             service_h service, void *priv)
320 {
321         SETTING_TRACE_BEGIN;
322         SettingNetworkUG *ad = (SettingNetworkUG *) priv;
323
324         switch (event) {
325         case UG_KEY_EVENT_END:
326                 {
327                         /* setting_network_popup_delete(ad); */
328                         if (elm_naviframe_top_item_get(ad->navi_bar) ==
329                            elm_naviframe_bottom_item_get(ad->navi_bar)) {
330                                 ug_destroy_me(ug);
331                         } else {
332                                 /* elm_naviframe_item_pop(ad->navi_bar); */
333                                 setting_view_cb_at_endKey(ad);
334                         }
335                 }
336                 break;
337         default:
338                 break;
339         }
340 }
341
342 UG_MODULE_API int UG_MODULE_INIT(struct ug_module_ops *ops)
343 {
344         SETTING_TRACE_BEGIN;
345         SettingNetworkUG *networkUG = calloc(1, sizeof(SettingNetworkUG));
346         setting_retvm_if(!networkUG, -1, "Create SettingNetworkUG obj failed");
347
348         ops->create = setting_network_ug_on_create;
349         ops->start = setting_network_ug_on_start;
350         ops->pause = setting_network_ug_on_pause;
351         ops->resume = setting_network_ug_on_resume;
352         ops->destroy = setting_network_ug_on_destroy;
353         ops->message = setting_network_ug_on_message;
354         ops->event = setting_network_ug_on_event;
355         ops->key_event = setting_network_ug_on_key_event;
356         ops->priv = networkUG;
357         ops->opt = UG_OPT_INDICATOR_ENABLE;
358
359         return 0;
360 }
361
362 UG_MODULE_API void UG_MODULE_EXIT(struct ug_module_ops *ops)
363 {
364         SETTING_TRACE_BEGIN;
365         struct SettingNetworkUG *networkUG;
366         setting_retm_if(!ops, "ops == NULL");
367
368         networkUG = ops->priv;
369         FREE(networkUG);
370 }
371
372 /* ***************************************************
373  *
374  *general func
375  *
376  ***************************************************/
377 void setting_network_popup_delete(void *data)
378 {
379         SETTING_TRACE_BEGIN;
380         /* error check */
381         retm_if(data == NULL,
382                 "setting_network_tapi_popup_create Data parameter is NULL");
383         SettingNetworkUG *ad = (SettingNetworkUG *) data;
384         if (ad->network_ug_pop != NULL) {
385                 evas_object_del(ad->network_ug_pop);
386                 ad->network_ug_pop = NULL;
387         }
388 }
389
390 /* ***************************************************
391  *
392  *call back func
393  *
394  ***************************************************/
395
396 void setting_tapi_set_band_cb(TapiHandle *handle, int result, void *data, void *user_data)
397 {
398         SETTING_TRACE_BEGIN;
399         SETTING_TRACE(" - result = 0x%x", result);
400         ret_if(!user_data);
401         SettingNetworkUG *ad = user_data;
402         ret_if(NULL == ad->data_net_mode);
403
404         int err;
405         if (result == TAPI_NETWORK_NO_ERR) {
406                 ad->net_mode = elm_radio_value_get(ad->data_net_mode->rgd);//get value from radio
407                 setting_set_int_slp_key(ad->data_net_mode->int_slp_setting_binded,
408                                         ad->net_mode, &err);
409                 char *sub_des = NULL;
410
411                 switch (ad->net_mode) {
412                 case TAPI_NETWORK_BAND_TYPE_ANY:
413                         sub_des = _("IDS_COM_BODY_AUTOMATIC");
414                         break;
415
416                 case TAPI_NETWORK_BAND_TYPE_GSM_900_1800:
417                         sub_des = _(STR_SETTING_GSM_900_1800);
418                         break;
419
420                 case TAPI_NETWORK_BAND_TYPE_GSM_850_1900:
421                         sub_des = _(STR_SETTING_GSM_850_1900);
422                         break;
423
424                 case TAPI_NETWORK_BAND_TYPE_WCDMA:
425                         sub_des = _(STR_SETTING_UMTS);
426                         break;
427                 default:
428                         break;
429                 }
430                 if (ad->data_net_mode) {
431                         ad->data_net_mode->sub_desc = (char *)g_strdup(sub_des);
432                         elm_object_item_data_set(ad->data_net_mode->item, ad->data_net_mode);
433                         elm_genlist_item_update(ad->data_net_mode->item);
434                 }
435
436
437         } else {
438                 //rollback
439                 //get value from vconf
440                 setting_get_int_slp_key(ad->data_net_mode->int_slp_setting_binded,
441                                         &(ad->net_mode), &err);
442                 elm_radio_value_set(ad->data_net_mode->rgd, ad->net_mode);
443         }
444 }
445 void setting_tapi_get_band_cb(TapiHandle *handle, int result, void *data, void *user_data)
446 {
447         SETTING_TRACE_BEGIN;
448         SETTING_TRACE(" - result = 0x%x", result);
449         ret_if(!user_data);
450         SettingNetworkUG *ad = user_data;
451
452         if (result == TAPI_NETWORK_NO_ERR) {
453                 TelNetworkBand_t band;
454                 int temp_net_mode = 0;
455                 memcpy(&band, data, sizeof(TelNetworkBand_t));
456                 temp_net_mode = (int)band;
457                 /*  ***BEGIN***  Fixed the problem of word twinkle  SAMSUNG 2010/7/21 modify */
458                 if (temp_net_mode != ad->net_mode) {
459                         ad->net_mode = temp_net_mode;
460                         const char *sub_desc = NULL;
461                         switch (ad->net_mode) {
462                         case TAPI_NETWORK_BAND_TYPE_ANY:
463                                 sub_desc = _("IDS_COM_BODY_AUTOMATIC");
464                                 break;
465                         case TAPI_NETWORK_BAND_TYPE_GSM_900_1800:
466                                 sub_desc = _(STR_SETTING_GSM_900_1800);
467                                 break;
468                         case TAPI_NETWORK_BAND_TYPE_GSM_850_1900:
469                                 sub_desc = _(STR_SETTING_GSM_850_1900);
470                                 break;
471                         case TAPI_NETWORK_BAND_TYPE_WCDMA:
472                                 sub_desc = _(STR_SETTING_UMTS);
473                                 break;
474                         default:
475                                 break;
476                         }
477                         if (ad->data_net_mode) {
478                                 ad->data_net_mode->sub_desc = (char *)g_strdup(sub_desc);
479                                 elm_object_item_data_set (ad->data_net_mode->item, ad->data_net_mode);
480                                 elm_genlist_item_update(ad->data_net_mode->item);
481
482                         }
483                         vconf_set_int(VCONFKEY_SETAPPL_NETWORK_MODE_INT, ad->net_mode);
484                 }
485                 /*  ****END****  Fixed the problem of word twinkle  SAMSUNG 2010/7/21 modify */
486         } else {
487         }
488 }
489
490
491 void setting_tapi_set_plmn_mode_cb(TapiHandle *handle, int result, void *data, void *user_data)
492 {
493         SETTING_TRACE_BEGIN;
494         SETTING_TRACE(" - result = 0x%x", result);
495         ret_if(!user_data);
496         SettingNetworkUG *ad = user_data;
497
498         setting_network_popup_delete(ad);
499
500         if ((TAPI_NETWORK_SELECTIONMODE_AUTOMATIC == ad->sel_net
501             && !ad->b_set_auto_network) ||
502             (TAPI_NETWORK_SELECTIONMODE_MANUAL == ad->sel_net
503             && !ad->b_set_manul_network))
504         {
505                 /*The requeset has already been canceled, return directly*/
506                 return;
507         }
508
509         if(result != TAPI_NETWORK_NO_ERR) {/*roolback..*/
510                 setting_create_popup_without_btn(ad, ad->win_get, NULL, _(keyStr_Failed_Select_Network), NULL, POPUP_INTERVAL, FALSE, FALSE);
511
512                 //rollback sel_act and sel_net in setting_view_network_select_network.destroy()
513                 setting_view_change(
514                         &setting_view_network_select_network,
515                         &setting_view_network_main, ad);
516
517                 return;
518
519         }
520
521         setting_create_popup_without_btn(ad, ad->win_get, NULL, _(KeyStr_Saved), NULL, POPUP_INTERVAL, FALSE, FALSE);
522         if (0 != vconf_set_int(VCONFKEY_SETAPPL_SELECT_NETWORK_INT, ad->sel_net)) {
523                 SETTING_TRACE_ERROR("vconf[%s] set failed");
524         }
525         if (0 != vconf_set_int(VCONFKEY_SETAPPL_SELECT_OLD_NT_ACT, ad->sel_act)) {
526                 SETTING_TRACE_ERROR("vconf[%s] set failed");
527         }
528         
529         ad->b_set_auto_network = FALSE;
530         ad->b_set_manul_network = FALSE;
531         setting_network_update_sel_network(ad);
532 }
533 void setting_tapi_get_plmn_mode_cb(TapiHandle *handle, int result, void *data, void *user_data)
534 {
535         SETTING_TRACE_BEGIN;
536         SETTING_TRACE(" - result = 0x%x", result);
537         ret_if(!user_data);
538         SettingNetworkUG *ad = user_data;
539
540         if (result == TAPI_NETWORK_NO_ERR) {
541                 TelNetworkSelectionMode_t sel;
542                 memcpy(&sel, data, sizeof(TelNetworkSelectionMode_t));
543                 SETTING_TRACE_DEBUG("ad->sel_net[%d] %s sel[%d]", ad->sel_net, ad->sel_net == sel ? "==" : "!=", sel);
544                 if (ad->sel_net != sel) {
545                         ad->sel_net = sel;
546                         vconf_set_int(VCONFKEY_SETAPPL_SELECT_NETWORK_INT, ad->sel_net);
547                         setting_network_update_sel_network(ad);
548                 }
549         } else {
550         }
551 }
552
553 void setting_tapi_search_network_cb(TapiHandle *handle, int result, void *data, void *user_data)
554 {
555         ret_if(!data || !user_data);
556         SettingNetworkUG *ad = user_data;
557         SETTING_TRACE_BEGIN;
558         SETTING_TRACE(" - result = %d", result);
559         setting_network_popup_delete(ad);
560
561         if (!ad->b_searching_network) {
562                 /*The requeset has already been canceled, don't do detail process*/
563                 return;
564         }
565         //setting_finish_progress_genlist_item(ad->data_selected_network_item);
566         if (ad->data_search_network_item)
567         {
568                 elm_object_item_del(ad->data_search_network_item->item);
569                 ad->data_search_network_item = NULL;
570         }
571
572         ad->b_searching_network = FALSE;
573         int valid_cnt = 0;
574         if (result == TAPI_NETWORK_NO_ERR) {
575                 int cnt = 0;
576                 memcpy(&(ad->plmn_info), data, sizeof(TelNetworkPlmnList_t));
577
578                 Setting_GenGroupItem_Data *item_data = NULL;
579
580                 const char *pa_net_name = vconf_get_str(VCONFKEY_TELEPHONY_NWNAME);
581                 SETTING_TRACE("VCONFKEY_TELEPHONY_NWNAME:pa_net_name:%s", pa_net_name);
582
583                 char name[MAX_COMMON_BUFFER_LEN] = {0, };
584                 while(cnt < ad->plmn_info.networks_count) {
585                         SETTING_TRACE("network name from TAPI[%d]:%s(%s)", cnt,
586                                       ad->plmn_info.network_list[cnt].network_name,
587                                       setting_network_get_act_str(ad->plmn_info.network_list[cnt].access_technology));
588
589                         if (TAPI_FORBIDDEN_PLMN == ad->plmn_info.network_list[cnt].type_of_plmn) {
590                                 cnt++;
591                                 continue;
592                         }
593
594                         if (TAPI_NETWORK_SELECTIONMODE_MANUAL == ad->sel_net
595                             && 0 == safeStrCmp(pa_net_name, ad->plmn_info.network_list[cnt].network_name)
596                             && ad->plmn_info.network_list[cnt].access_technology == ad->sel_act)
597                         {
598                                 //already displayed.
599                                 cnt++;
600                                 continue;
601                         }
602                         
603                         memset(name, 0, MAX_COMMON_BUFFER_LEN);
604                         snprintf(name, MAX_COMMON_BUFFER_LEN, "%s (%s)",
605                                  ad->plmn_info.network_list[cnt].network_name,
606                                  setting_network_get_act_str(ad->plmn_info.network_list[cnt].access_technology));
607
608                         item_data = setting_create_Gendial_field_1radio(
609                                                 ad->genlist_sel_network,
610                                                 &itc_1text_2icon_2,
611                                                 setting_network_Gendial_select_plmn_cb,
612                                                 ad,
613                                                 SWALLOW_Type_1RADIO,
614                                                 ad->chk_sel,
615                                                 TAPI_NETWORK_SELECTIONMODE_MANUAL+valid_cnt+1,
616                                                 name,
617                                                 setting_network_select_network_chk_changed);
618                         if (NULL == item_data)
619                         {
620                                 SETTING_TRACE_ERROR("Failed to calloc memory");
621                                 cnt++;
622                                 continue;
623                         }
624                         item_data->userdata = ad;
625                         if (TAPI_NETWORK_SELECTIONMODE_AUTOMATIC != ad->sel_net
626                             && 0 == safeStrCmp(pa_net_name, ad->plmn_info.network_list[cnt].network_name)
627                             && ad->plmn_info.network_list[cnt].access_technology == ad->sel_act)
628                         {
629                                 elm_radio_value_set(ad->chk_sel, item_data->chk_status);//let select nothing
630                         }
631                         cnt++;
632                         valid_cnt++;
633                 }
634                 FREE(pa_net_name);
635
636                 SETTING_TRACE("Found %d valid networks in total[%d]", valid_cnt, cnt);
637                 valid_cnt = 0;
638                 if (valid_cnt > 0){
639                         setting_create_popup_without_btn(ad, ad->win_get, NULL, _(keyStr_Searched), NULL, POPUP_INTERVAL, FALSE, FALSE);
640                 } else { //there is no invalid plmn nearby
641                         setting_create_popup_without_btn(ad, ad->win_get, NULL, _("There is no network nearby"), NULL, POPUP_INTERVAL, FALSE, FALSE);
642                 }
643         } else {
644                 setting_create_popup_without_btn(ad, ad->win_get, NULL, _(keyStr_Failed_Searched), NULL, POPUP_INTERVAL, FALSE, FALSE);
645         }
646         if (0 == valid_cnt && TAPI_NETWORK_SELECTIONMODE_AUTOMATIC == ad->sel_net && ad->data_auto_network_item)
647         {
648                 ad->data_auto_network_item->chk_status = TRUE;
649                 elm_object_item_data_set(ad->data_auto_network_item->item, ad->data_auto_network_item);
650                 elm_genlist_item_item_class_update(ad->data_auto_network_item->item, &(itc_2text_1icon_6));
651         }
652 }
653
654
655 void setting_tapi_get_serving_network_cb(TapiHandle *handle, int result, void *data, void *user_data)
656 {
657         SETTING_TRACE_BEGIN;
658         SETTING_TRACE(" - result = 0x%x", result);
659         ret_if(!user_data || !data);
660         SettingNetworkUG *ad = user_data;
661         TelNetworkServing_t *srv_nt = data;
662         
663         if (result == TAPI_NETWORK_NO_ERR)
664         {
665                 ad->sel_act = srv_nt->act;
666                 vconf_set_int(VCONFKEY_SETAPPL_SELECT_OLD_NT_ACT, ad->sel_act);
667                 
668                 FREE(ad->sel_network);
669                 ad->sel_network = vconf_get_str(VCONFKEY_TELEPHONY_NWNAME);
670                 if (NULL == ad->sel_network) {
671                     ad->sel_network = strndup("IDS_ST_BODY_NOSERVICE", strlen("IDS_ST_BODY_NOSERVICE")+1);
672                 }
673                 setting_network_update_sel_network(ad);
674         }
675         else
676         {
677                 //if failed, do nothing..
678         }
679         SETTING_TRACE_END;
680         
681 }
682
683
684 void setting_tapi_cancel_manual_search_cb(TapiHandle *handle, int result, void *data, void *user_data)
685 {
686         SETTING_TRACE_BEGIN;
687         SETTING_TRACE(" - result = 0x%x", result);
688         ret_if(!user_data);
689         //SettingNetworkUG *ad = user_data;
690 }
691
692 void setting_tapi_set_preferred_plmn_cb(TapiHandle *handle, int result, void *data, void *user_data)
693 {
694         SETTING_TRACE_BEGIN;
695         SETTING_TRACE(" - result = 0x%x", result);
696         ret_if(!user_data);
697         SettingNetworkUG *ad = user_data;
698         setting_network_popup_delete(ad);
699
700         if (result != TAPI_NETWORK_NO_ERR) {
701                 switch (ad->op_type) {
702                 case SETTING_NETWORK_PREFERRED_NETWORK_DELETE:
703                 {
704                         setting_network_preferred_network_delete_failed(ad);
705                         break;
706                 }
707                 default:
708                 {
709                         setting_create_popup_without_btn(ad, ad->win_get, NULL, _("IDS_COM_POP_ERROR"), NULL, POPUP_INTERVAL, FALSE, FALSE);
710                         break;
711                 }
712                 }
713         } else {
714                 int tapi_ret = TAPI_API_SUCCESS;
715                 switch (ad->op_type) {
716                 case SETTING_NETWORK_PREFERRED_NETWORK_NEW:
717                 {
718                         setting_view_change
719                             (&setting_view_network_preferred_network_new,
720                              &setting_view_network_preferred_network,ad);
721                         tapi_ret =
722                             tel_get_network_preferred_plmn
723                             (ad->handle, setting_tapi_get_preferred_plmn_cb, ad);
724                         break;
725                 }
726
727                 case SETTING_NETWORK_PREFERRED_NETWORK_LIST:
728                 {
729
730                         setting_view_change
731                             (&setting_view_network_preferred_network_list,
732                              &setting_view_network_preferred_network,
733                              ad);
734                         tapi_ret =
735                             tel_get_network_preferred_plmn
736                             (ad->handle, setting_tapi_get_preferred_plmn_cb, ad);
737                         break;
738                 }
739
740                 case SETTING_NETWORK_PREFERRED_NETWORK_EDIT:
741                 {
742                         setting_view_change
743                             (&setting_view_network_preferred_network_edit,
744                              &setting_view_network_preferred_network,
745                              ad);
746                         tapi_ret =
747                             tel_get_network_preferred_plmn
748                             (ad->handle, setting_tapi_get_preferred_plmn_cb, ad);
749                         break;
750                 }
751                 case SETTING_NETWORK_PREFERRED_NETWORK_DELETE:
752                 {
753                         setting_network_preferred_network_delete_ok
754                             (ad);
755                         return;
756                 }
757                 default:
758                 {
759                         SETTING_TRACE_DEBUG
760                             (" Unknown prederred network type");
761                         break;
762                 }
763                 }
764
765                 if (tapi_ret !=
766                     TAPI_API_SUCCESS) {
767                         SETTING_TRACE_ERROR
768                             ("*** [ERR] tel_get_network_preferred_plmn. err=%d ***",
769                              tapi_ret);
770                 }
771         }
772
773 }
774
775 void setting_tapi_get_preferred_plmn_cb(TapiHandle *handle, int result, void *data, void *user_data)
776 {
777         SETTING_TRACE_BEGIN;
778         SETTING_TRACE(" - result = 0x%x", result);
779         ret_if(!user_data);
780         SettingNetworkUG *ad = user_data;
781
782         SETTING_TRACE_DEBUG("Case: TAPI_EVENT_NETWORK_GETPREFFEREDPLMN_CNF");
783         setting_network_popup_delete(ad);
784
785         if (result == TAPI_NETWORK_NO_ERR) {
786                 memcpy(&(ad->pref_list), data,sizeof(TelNetworkPreferredPlmnList_t));
787
788                 SETTING_TRACE("*********** ad->op_type = %d",ad->op_type);
789                 SETTING_TRACE("ad->pref_list.NumOfPrefPlmns:%d",ad->pref_list.NumOfPrefPlmns);
790                 switch (ad->op_type) {
791                 case SETTING_NETWORK_PREFERRED_NETWORK_DELETE:
792                 {
793                         setting_network_preferred_network_delete_draw_network_list(ad);
794                         break;
795                 }
796                 default:
797                 {
798                         setting_network_preferred_network_refresh_view
799                             (ad);
800                         char info[MAX_DISPLAY_NAME_LEN_ON_UI] = { 0 };
801                         if (ad->pref_list.NumOfPrefPlmns > 1) {
802                                 snprintf(info, sizeof(info), "Get %d preferred networks",
803                                      ad->pref_list.NumOfPrefPlmns);
804                         } else {
805                                 snprintf(info, sizeof(info), "Get %d preferred network",
806                                      ad->pref_list.NumOfPrefPlmns);
807                         }
808                         setting_create_popup_without_btn(ad, ad->win_get, NULL, _(info), NULL, POPUP_INTERVAL, FALSE, FALSE);
809                         break;
810                 }
811                 }
812         } else {
813                 switch (ad->op_type) {
814                 case SETTING_NETWORK_PREFERRED_NETWORK_DELETE:
815                 {
816                         setting_network_preferred_network_delete_failed
817                             (ad);
818                         break;
819                 }
820                 default:
821                 {
822                         setting_create_popup_without_btn(ad, ad->win_get, NULL, _(keyStr_Failed_Get_PreferNetwork), NULL, POPUP_INTERVAL, FALSE, FALSE);
823                         break;
824                 }
825                 }
826         }
827 }
828
829 void __register_network(Setting_GenGroupItem_Data* list_item)
830 {
831         SETTING_TRACE_BEGIN;
832         ret_if(list_item == NULL);
833         SETTING_TRACE("process item [%s]", list_item->keyStr);
834         SettingNetworkUG *ad = list_item->userdata;
835         ret_if(ad == NULL);
836
837         int tapi_ret = TAPI_API_INVALID_INPUT;
838
839         //cancel the searching operation
840
841         if (ad->data_search_network_item)
842         {
843             elm_object_item_del(ad->data_search_network_item->item);
844             ad->data_search_network_item = NULL;
845         }
846
847         if (ad->b_searching_network) {
848                 SETTING_TRACE("Sending tel_cancel_network_manual_search..");
849                 tapi_ret = tel_cancel_network_manual_search(ad->handle, setting_tapi_cancel_manual_search_cb, ad);
850                 if (tapi_ret != TAPI_API_SUCCESS) {
851                         SETTING_TRACE_ERROR("*** [ERR] tel_cancel_network_manual_search. "\
852                                             "tapi_ret=%d ***", tapi_ret);
853                 }
854                 else
855                 {
856                         ad->b_searching_network = FALSE;
857                 }
858         }
859
860         if (0 == safeStrCmp(list_item->keyStr, "IDS_COM_BODY_AUTOMATIC")) {
861                 ad->sel_net = TAPI_NETWORK_SELECTIONMODE_AUTOMATIC;
862                 SETTING_TRACE("Sending tel_select_network_automatic..");
863                 tapi_ret = tel_select_network_automatic(ad->handle, setting_tapi_set_plmn_mode_cb, ad);
864                 if (tapi_ret != TAPI_API_SUCCESS) {
865                     SETTING_TRACE_DEBUG("*** [ERR] tel_select_network_automatic."\
866                                             " tapi_ret=%d ***",tapi_ret);
867                 } else {
868                         ad->network_ug_pop = setting_create_popup_without_btn(ad, ad->win_get, NULL,
869                                                          _("IDS_COM_POP_PROCESSING"), NULL,
870                                                          0.0, TRUE, TRUE);
871
872                         if (ad->data_auto_network_item)
873                         {
874                                 ad->data_auto_network_item->sub_desc = (char *)g_strdup("....");
875                                 elm_genlist_item_item_class_update(ad->data_auto_network_item->item, &(itc_2text_1icon_6));
876                         }
877
878                         ad->b_set_manul_network = FALSE;
879                         ad->b_set_auto_network = TRUE;
880                         ad->sel_act = -1;//means "Automatic"
881                 }
882         } else {
883                 ad->sel_net = TAPI_NETWORK_SELECTIONMODE_MANUAL;
884                 ad->b_set_manul_network = TRUE;
885                 ad->b_set_auto_network = FALSE;
886
887                 int cnt = 0;
888                 SETTING_TRACE("ad->plmn_info.networks_count:%d",
889                                 ad->plmn_info.networks_count);
890                 char name[MAX_COMMON_BUFFER_LEN] = {0, };
891                 for(; cnt < ad->plmn_info.networks_count; cnt++)
892                 {
893                         SETTING_TRACE("ad->plmn_info.network_list[cnt].network_name:%s",
894                                         ad->plmn_info.network_list[cnt].network_name);
895                         memset(name, 0, MAX_COMMON_BUFFER_LEN);
896                         snprintf(name, MAX_COMMON_BUFFER_LEN, "%s (%s)",
897                                  ad->plmn_info.network_list[cnt].network_name,
898                                  setting_network_get_act_str(ad->plmn_info.network_list[cnt].access_technology));
899
900                         if(!safeStrCmp(list_item->keyStr, name))
901                         {
902                                 break;
903                         }
904                 }
905
906
907                 SETTING_TRACE_DEBUG("*** [Selected PLMN] name=%s, "\
908                                 "srv provider=%s, PLMN ID=%u, type=%d, "\
909                                 "access tech=%d ***",
910                                 ad->plmn_info.network_list[cnt].network_name,
911                                 ad->plmn_info.network_list[cnt].service_provider_name,
912                                 ad->plmn_info.network_list[cnt].plmn_id,
913                                 (int)(ad->plmn_info.network_list[cnt].type_of_plmn),
914                                 (int)(ad->plmn_info.network_list[cnt].access_technology));
915
916                 //ASYNC API - TAPI_EVENT_NETWORK_SELECT_CNF
917                 SETTING_TRACE("Sending tel_select_network_manual..");
918                 char plmn_id[MAX_COMMON_BUFFER_LEN] = {0, };
919                 snprintf(plmn_id, MAX_COMMON_BUFFER_LEN, "%d", ad->plmn_info.network_list[cnt].plmn_id);
920
921                 tapi_ret = tel_select_network_manual(ad->handle,
922                                         plmn_id, ad->plmn_info.network_list[cnt].access_technology,
923                                         setting_tapi_set_plmn_mode_cb, ad);
924                 if(tapi_ret != TAPI_API_SUCCESS)
925                 {
926                         SETTING_TRACE_DEBUG("%s*** [ERR] "\
927                                         "tel_select_network_manual. "\
928                                         "tapi_ret=%d ***%s", SETTING_FONT_RED,
929                                         tapi_ret, SETTING_FONT_BLACK);
930                         setting_create_popup_without_btn(ad, ad->win_get, NULL, _("IDS_ST_BODY_FAILED_TO_SELECT_NETWORK"), NULL, POPUP_INTERVAL, FALSE, FALSE);
931
932                         return;
933                 }
934                 else
935                 {
936                         ad->network_ug_pop = setting_create_popup_without_btn(ad, ad->win_get, NULL,
937                                                          _("IDS_COM_POP_PROCESSING"), NULL,
938                                                          0.0, TRUE, TRUE);
939                         ad->sel_act = ad->plmn_info.network_list[cnt].access_technology;
940                         FREE(ad->sel_network);
941                         ad->sel_network = strdup(ad->plmn_info.network_list[cnt].network_name);
942                 }
943         }
944 }
945
946
947 void __switch_automatic_network(Setting_GenGroupItem_Data *list_item)
948 {
949         SETTING_TRACE_BEGIN;
950         ret_if(!list_item || !list_item->userdata || !list_item->keyStr);
951         ret_if(0 != safeStrCmp(list_item->keyStr, "IDS_COM_BODY_AUTOMATIC"));
952         SettingNetworkUG *ad = list_item->userdata;
953         SETTING_TRACE("The value of toogle changes to be %d", list_item->chk_status);
954         if (list_item->chk_status) //set automatic
955         {
956                 Elm_Object_Item *last_item = elm_genlist_last_item_get(ad->genlist_sel_network);
957                 SETTING_TRACE("ad->data_auto_network_item->item:%p", ad->data_auto_network_item->item);
958                 for (;;) {
959                         last_item = elm_genlist_last_item_get(ad->genlist_sel_network);
960                         SETTING_TRACE("last_item:%p", last_item);
961                         if (last_item == ad->data_auto_network_item->item) {
962                                 break;
963                         }
964                         elm_object_item_del(last_item);
965                 }
966
967                 __register_network(list_item);
968         }
969         else //select a plmn
970         {
971                 //__register_network(list_item);
972                 int tapi_ret;
973                 //searching list
974                 tapi_ret = tel_search_network(ad->handle, setting_tapi_search_network_cb, ad); //ASYNC API - TAPI_EVENT_NETWORK_SEARCH_CNF
975                 if(tapi_ret != TAPI_API_SUCCESS) { // error handling..
976                         SETTING_TRACE_ERROR("%s*** [ERR] tel_search_network. tapi_ret=%d ***%s", SETTING_FONT_RED, tapi_ret, SETTING_FONT_BLACK);
977                         setting_create_popup_without_btn(ad, ad->win_get, NULL, _(STR_SETTING_OPERATION_FAILED), NULL, POPUP_INTERVAL, FALSE, FALSE);
978
979                         // put error handler on the end of this function.
980                         //rollback..
981                         list_item->chk_status = TRUE;
982                         elm_check_state_set(list_item->eo_check, list_item->chk_status);
983                         return;
984                 }
985                 ad->b_searching_network = TRUE;
986                 ad->data_search_network_item = setting_create_Gendial_field_1radio(
987                                                                 ad->genlist_sel_network,
988                                                                 &itc_1text_2icon_2,
989                                                                 NULL, NULL,
990                                                                 SWALLOW_Type_1RADIO_1SEARCH,
991                                                                 ad->chk_sel, -1, NULL, NULL);
992                 if (ad->data_auto_network_item)
993                 {
994                         elm_genlist_item_item_class_update(ad->data_auto_network_item->item, &(itc_2text_1icon_7));
995                 }
996         }
997 }
998
999 void setting_network_select_network_chk_changed(void *data, Evas_Object *obj, void *event_info)
1000 {
1001         SETTING_TRACE_BEGIN;
1002         retm_if(data == NULL || obj == NULL, "Parameter is NULL");
1003         Setting_GenGroupItem_Data *list_item = (Setting_GenGroupItem_Data *)data;
1004         if (0 == safeStrCmp(list_item->keyStr, "IDS_COM_BODY_AUTOMATIC"))
1005         {
1006                 list_item->chk_status = elm_check_state_get(obj);
1007                 __switch_automatic_network(list_item);
1008         }
1009         else //"IDS_COM_BODY_AUTOMATIC"
1010         {
1011                 list_item->chk_status = elm_radio_value_get(obj);
1012                 SETTING_TRACE("The value of radio changes to be %d", list_item->chk_status);
1013                 __register_network(list_item);
1014         }
1015
1016 }
1017
1018
1019 void setting_network_Gendial_select_plmn_cb(void *data, Evas_Object *obj, void *event_info)
1020 {
1021         SETTING_TRACE_BEGIN;
1022         retm_if(data == NULL || event_info == NULL, "Parameter is NULL");
1023
1024         SettingNetworkUG *ad = (SettingNetworkUG*)data;
1025         Elm_Object_Item *item = (Elm_Object_Item*)event_info;
1026         elm_genlist_item_selected_set(item, 0);
1027         Setting_GenGroupItem_Data *list_item = (Setting_GenGroupItem_Data*)elm_object_item_data_get(item);
1028
1029         SETTING_TRACE("list_item->keyStr:%s", list_item->keyStr);
1030         if (0 == safeStrCmp(list_item->keyStr, "IDS_COM_BODY_AUTOMATIC"))
1031         {
1032                 list_item->chk_status = !elm_check_state_get(list_item->eo_check);
1033                 elm_check_state_set(list_item->eo_check, list_item->chk_status);
1034                 __switch_automatic_network(list_item);
1035                 return;
1036         }
1037         else
1038         {
1039                 int old_chk_status = elm_radio_value_get(ad->chk_sel);
1040                 if (old_chk_status != list_item->chk_status)
1041                 {
1042                         SETTING_TRACE("The value of radio changes to be %d",
1043                                         list_item->chk_status);
1044                         elm_radio_value_set(ad->chk_sel, list_item->chk_status);
1045                         __register_network(list_item);
1046                 }
1047         }
1048 }
1049 void setting_network_update_sel_network(void *data)
1050 {
1051         SETTING_TRACE_BEGIN;
1052         SettingNetworkUG *ad = data;
1053         SETTING_TRACE("ad->sel_net:%d", ad->sel_net);
1054         SETTING_TRACE("ad->sel_network:%s", ad->sel_network);
1055         SETTING_TRACE("sel_act = [%s(%d)]", setting_network_get_act_str(ad->sel_act),ad->sel_act);
1056         
1057         if (ad->data_auto_network_item) {
1058                 if (TAPI_NETWORK_SELECTIONMODE_AUTOMATIC == ad->sel_net)
1059                 {
1060                    SETTING_TRACE_DEBUG("After set as Automatic, update "\
1061                                    "ad->data_auto_network_item to be [%s]",
1062                                    ad->sel_network);
1063                    ad->data_auto_network_item->sub_desc = (char *)g_strdup(_(ad->sel_network));
1064                     elm_object_item_data_set( ad->data_auto_network_item->item, ad->data_auto_network_item);
1065                     elm_genlist_item_update( ad->data_auto_network_item->item);
1066                 } else {
1067                 }
1068         }
1069
1070         if (ad->data_sel_net)//it indicates TAPI is not responsed in time
1071         {
1072                 char sel_network_desc[MAX_COMMON_BUFFER_LEN] = { 0, };
1073                 if (TAPI_NETWORK_SELECTIONMODE_AUTOMATIC == ad->sel_net) {
1074                         snprintf(sel_network_desc, MAX_COMMON_BUFFER_LEN,
1075                                  "%s. %s", _("IDS_COM_BODY_AUTOMATIC"), _(ad->sel_network));
1076                 
1077                 } else {
1078                         snprintf(sel_network_desc, MAX_COMMON_BUFFER_LEN,
1079                                  "%s. %s (%s)", _("IDS_COM_BODY_MANUAL"), _(ad->sel_network),
1080                                  setting_network_get_act_str(ad->sel_act));
1081                 }
1082                 
1083                 SETTING_TRACE("sel_network_desc:%s", sel_network_desc);
1084                 
1085                 G_FREE(ad->data_sel_net->sub_desc);
1086                 ad->data_sel_net->sub_desc = (char *)g_strdup(_(sel_network_desc));
1087                 
1088                 elm_object_item_data_set(ad->data_sel_net->item, ad->data_sel_net);
1089                 elm_genlist_item_update(ad->data_sel_net->item);
1090         }
1091 }
1092
1093 const char *setting_network_get_act_str(TelNetworkSystemType_t type)
1094 {
1095         switch (type)
1096         {
1097             case TAPI_NETWORK_SYSTEM_NO_SRV: //0
1098                 return "NO SERVICE";
1099             case TAPI_NETWORK_SYSTEM_GSM: //1
1100                 return "GSM";
1101             case TAPI_NETWORK_SYSTEM_GPRS: //2
1102                 return "GPRS";
1103             case TAPI_NETWORK_SYSTEM_EGPRS: //3
1104                 return "EGPRS";
1105             case TAPI_NETWORK_SYSTEM_PCS1900: //4
1106                 return "PCS1900";
1107             case TAPI_NETWORK_SYSTEM_UMTS: //5
1108                 return "UMTS";
1109             case TAPI_NETWORK_SYSTEM_GSM_AND_UMTS:
1110                 return "GSM and UMTS";
1111             case TAPI_NETWORK_SYSTEM_HSDPA:
1112                 return "HSDPA";
1113             case TAPI_NETWORK_SYSTEM_IS95A:
1114                 return "IS95A";
1115             case TAPI_NETWORK_SYSTEM_IS95B:
1116                 return "IS95B";
1117             case TAPI_NETWORK_SYSTEM_CDMA_1X:
1118                 return "CDMA 1X";
1119             case TAPI_NETWORK_SYSTEM_EVDO_REV_0:
1120                 return "EV-DO rev0";
1121             case TAPI_NETWORK_SYSTEM_1X_EVDO_REV_0_HYBRID:
1122                 return "1X and EV-DO rev0";
1123             case TAPI_NETWORK_SYSTEM_EVDO_REV_A:
1124                 return "EV-DO revA";
1125             case TAPI_NETWORK_SYSTEM_1X_EVDO_REV_A_HYBRID:
1126                 return "1X and EV-DO revA";
1127             case TAPI_NETWORK_SYSTEM_EVDV:
1128                 return "EV-DV";
1129             default:
1130                 return "NO SERVICE";
1131         }
1132 }
1133
1134
1135 void __default_tapi_response_cb(TapiHandle *handle, int result, void *data, void *user_data)
1136 {
1137 }
1138
1139
1140 UG_MODULE_API int setting_plugin_reset(service_h service, void *priv)
1141 {
1142         SETTING_TRACE_BEGIN;
1143         int ret = 0;
1144         /* network         */
1145 #if SUPPORT_RUN_SYSTEM_COMMAND
1146         ret += excuteCmd(SETTING_POSTINST_FILE, 1, "network");
1147 #else
1148         ret += vconf_set_int(VCONFKEY_SETAPPL_SELECT_NETWORK_INT, TAPI_NETWORK_SELECTIONMODE_AUTOMATIC);
1149         ret += vconf_set_int(VCONFKEY_SETAPPL_SELECT_OLD_NT_ACT, 0);
1150         ret += vconf_set_int(VCONFKEY_SETAPPL_NETWORK_MODE_INT, TAPI_NETWORK_BAND_TYPE_ANY);
1151         ret += vconf_set_bool(VCONFKEY_3G_ENABLE, TRUE);
1152         ret += vconf_set_bool(VCONFKEY_SETAPPL_STATE_DATA_ROAMING_BOOL, TRUE);
1153 #endif
1154
1155         if (net_register_client((net_event_cb_t)__network_evt_cb, NULL) != NET_ERR_NONE) {
1156                 SETTING_TRACE_ERROR("net_register_client. failed");
1157         }
1158
1159         TapiHandle *tapi_handle = tel_init(NULL);
1160         if (tapi_handle) {
1161                 SETTING_TRACE_DEBUG("tel_init sucessfull");
1162                 //1.tel_select_network_automatic
1163                 int tapi_ret = tel_select_network_automatic(tapi_handle, __default_tapi_response_cb, NULL);
1164                 if (tapi_ret != TAPI_API_SUCCESS) {
1165                         ret++;
1166                         SETTING_TRACE_ERROR("tel_select_network_automatic. tapi_ret=%d", tapi_ret);
1167                 }
1168
1169                 //2.tel_set_network_band
1170                 tapi_ret = tel_set_network_band(tapi_handle, TAPI_NETWORK_BAND_MODE_ONLY,
1171                                                 TAPI_NETWORK_BAND_TYPE_ANY,
1172                                                  __default_tapi_response_cb, NULL);
1173                 if (tapi_ret != TAPI_API_SUCCESS) {
1174                         ret++;
1175                         SETTING_TRACE_ERROR("tel_set_network_band. tapi_ret=%d", tapi_ret);
1176                 }
1177
1178                 //3.don't need to receive
1179                 if (tel_deinit(tapi_handle) == TAPI_API_SUCCESS) {
1180                         SETTING_TRACE_DEBUG("tel_deinit sucessfull");
1181                 }
1182
1183         }
1184
1185
1186
1187         if (net_deregister_client() != NET_ERR_NONE) {
1188                 ret++;
1189                 SETTING_TRACE_ERROR("net_deregister_client failed");
1190         }
1191
1192         //Reset connections info..
1193         ret += excuteCmd("/usr/bin/dbus-send", 1, NET_CON_RESET_DBUS_PARA);
1194
1195         SETTING_TRACE_END;
1196         return ret;
1197 }