4 * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd.
6 * Contact: MyoungJune Park <mj2004.park@samsung.com>
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
12 * http://www.apache.org/licenses/LICENSE-2.0
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.
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>
27 #define UG_MODULE_API __attribute__ ((visibility("default")))
29 int setting_network_subscribe_tapi_events(void *data);
30 int setting_network_unsubscribe_tapi_events(void *data);
32 static void __selected_network_change_cb(keynode_t *key, void *data)
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)) {
41 value = "IDS_ST_BODY_NOSERVICE";
43 ad->sel_network = strdup(value);
45 if (0 != vconf_set_int(VCONFKEY_SETAPPL_SELECT_NETWORK_INT, ad->sel_net)) {
46 SETTING_TRACE_ERROR("vconf[%s] set failed");
49 if (0 != vconf_set_int(VCONFKEY_SETAPPL_SELECT_OLD_NT_ACT, ad->sel_act)) {
50 SETTING_TRACE_ERROR("vconf[%s] set failed");
53 setting_network_update_sel_network(ad);
58 static void setting_network_ug_cb_resize(void *data, Evas *e,
59 Evas_Object *obj, void *event_info)
61 SettingNetworkUG *ad = (SettingNetworkUG *) data;
62 setting_view_update(&setting_view_network_main, ad);
65 void __network_evt_cb(net_event_info_t *event_cb, void *data)
70 static void __mdm_policy_roaming_sync_receiver_cb(int result, void *p_user_data)
73 ret_if(p_user_data == NULL);
74 mdm_status_t policy_status = (mdm_status_t)result;
75 SettingNetworkUG *ad = (SettingNetworkUG*)p_user_data;
77 if(policy_status == MDM_ALLOWED)
79 setting_enable_genlist_item(ad->data_roaming->item);
81 else if(policy_status == MDM_RESTRICTED)
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,
86 POPUP_INTERVAL, FALSE, FALSE);
90 static void *setting_network_ug_on_create(ui_gadget_h ug,
91 enum ug_mode mode, service_h service,
94 setting_retvm_if((!priv), NULL, "!priv");
96 SettingNetworkUG *networkUG = priv;
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);
104 setting_retvm_if(networkUG->win_main_layout == NULL, NULL,
105 "cannot get main window ");
112 networkUG->mdm_server_state = mdm_get_service();
113 SETTING_TRACE("mdm server status: %d", networkUG->mdm_server_state);
115 if(networkUG->mdm_server_state == MDM_RESULT_SUCCESS)
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");
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);
132 err_code = net_register_client((net_event_cb_t)__network_evt_cb, networkUG);
133 if (err_code != NET_ERR_NONE) {
135 ("%s*** [ERR] net_register_client. err=%d ***%s",
136 SETTING_FONT_RED, err_code, SETTING_FONT_BLACK);
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);
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);
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);
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. ***");
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. ***");
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. ***");
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);
187 (void)vconf_notify_key_changed(VCONFKEY_TELEPHONY_NWNAME,
188 __selected_network_change_cb, networkUG);
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);
195 return networkUG->ly_main;
199 static void setting_network_ug_on_start(ui_gadget_h ug, service_h service,
204 static void setting_network_ug_on_pause(ui_gadget_h ug, service_h service,
209 static void setting_network_ug_on_resume(ui_gadget_h ug, service_h service,
214 static void setting_network_ug_on_destroy(ui_gadget_h ug, service_h service,
218 setting_retm_if((!priv), "!priv");
219 SettingNetworkUG *networkUG = priv;
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 */
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);
231 ecore_imf_shutdown();
234 if(networkUG->mdm_server_state == MDM_RESULT_SUCCESS)
236 mdm_deregister_policy_receiver(networkUG->mdm_handle);
237 mdm_release_service();
241 /* unregister dnet client */
242 int err_code = net_deregister_client();
243 if (err_code != NET_ERR_NONE) {
245 ("%s*** [ERR] net_deregister_client. err=%d ***%s",
246 SETTING_FONT_RED, err_code, SETTING_FONT_BLACK);
249 if (networkUG->handle && tel_deinit(networkUG->handle) != TAPI_API_SUCCESS) {
251 ("%s*** [ERR] setting_network_unsubscribe_tapi_events. ***%s",
252 SETTING_FONT_RED, SETTING_FONT_BLACK);
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);
260 setting_view_destroy(&setting_view_network_con, networkUG);
261 setting_view_destroy(&setting_view_network_connection_create,
263 setting_view_destroy(&setting_view_network_3gcon, networkUG);
265 setting_view_destroy(&setting_view_network_preferred_network,
267 setting_view_destroy(&setting_view_network_preferred_network_list,
269 setting_view_destroy(&setting_view_network_preferred_network_new,
271 setting_view_destroy(&setting_view_network_preferred_network_edit,
273 setting_view_destroy(&setting_view_network_preferred_network_delete,
275 setting_view_destroy(&setting_view_network_main, networkUG);
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));
285 static void setting_network_ug_on_message(ui_gadget_h ug, service_h msg,
286 service_h service, void *priv)
290 static void setting_network_ug_on_event(ui_gadget_h ug,
291 enum ug_event event, service_h service,
296 case UG_EVENT_LOW_MEMORY:
298 case UG_EVENT_LOW_BATTERY:
300 case UG_EVENT_LANG_CHANGE:
302 case UG_EVENT_ROTATE_PORTRAIT:
304 case UG_EVENT_ROTATE_PORTRAIT_UPSIDEDOWN:
306 case UG_EVENT_ROTATE_LANDSCAPE:
308 case UG_EVENT_ROTATE_LANDSCAPE_UPSIDEDOWN:
310 case UG_EVENT_REGION_CHANGE:
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)
322 SettingNetworkUG *ad = (SettingNetworkUG *) priv;
325 case UG_KEY_EVENT_END:
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)) {
332 /* elm_naviframe_item_pop(ad->navi_bar); */
333 setting_view_cb_at_endKey(ad);
342 UG_MODULE_API int UG_MODULE_INIT(struct ug_module_ops *ops)
345 SettingNetworkUG *networkUG = calloc(1, sizeof(SettingNetworkUG));
346 setting_retvm_if(!networkUG, -1, "Create SettingNetworkUG obj failed");
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;
362 UG_MODULE_API void UG_MODULE_EXIT(struct ug_module_ops *ops)
365 struct SettingNetworkUG *networkUG;
366 setting_retm_if(!ops, "ops == NULL");
368 networkUG = ops->priv;
372 /* ***************************************************
376 ***************************************************/
377 void setting_network_popup_delete(void *data)
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;
390 /* ***************************************************
394 ***************************************************/
396 void setting_tapi_set_band_cb(TapiHandle *handle, int result, void *data, void *user_data)
399 SETTING_TRACE(" - result = 0x%x", result);
401 SettingNetworkUG *ad = user_data;
402 ret_if(NULL == ad->data_net_mode);
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,
409 char *sub_des = NULL;
411 switch (ad->net_mode) {
412 case TAPI_NETWORK_BAND_TYPE_ANY:
413 sub_des = _("IDS_COM_BODY_AUTOMATIC");
416 case TAPI_NETWORK_BAND_TYPE_GSM_900_1800:
417 sub_des = _(STR_SETTING_GSM_900_1800);
420 case TAPI_NETWORK_BAND_TYPE_GSM_850_1900:
421 sub_des = _(STR_SETTING_GSM_850_1900);
424 case TAPI_NETWORK_BAND_TYPE_WCDMA:
425 sub_des = _(STR_SETTING_UMTS);
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);
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);
445 void setting_tapi_get_band_cb(TapiHandle *handle, int result, void *data, void *user_data)
448 SETTING_TRACE(" - result = 0x%x", result);
450 SettingNetworkUG *ad = user_data;
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");
465 case TAPI_NETWORK_BAND_TYPE_GSM_900_1800:
466 sub_desc = _(STR_SETTING_GSM_900_1800);
468 case TAPI_NETWORK_BAND_TYPE_GSM_850_1900:
469 sub_desc = _(STR_SETTING_GSM_850_1900);
471 case TAPI_NETWORK_BAND_TYPE_WCDMA:
472 sub_desc = _(STR_SETTING_UMTS);
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);
483 vconf_set_int(VCONFKEY_SETAPPL_NETWORK_MODE_INT, ad->net_mode);
485 /* ****END**** Fixed the problem of word twinkle SAMSUNG 2010/7/21 modify */
491 void setting_tapi_set_plmn_mode_cb(TapiHandle *handle, int result, void *data, void *user_data)
494 SETTING_TRACE(" - result = 0x%x", result);
496 SettingNetworkUG *ad = user_data;
498 setting_network_popup_delete(ad);
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))
505 /*The requeset has already been canceled, return directly*/
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);
512 //rollback sel_act and sel_net in setting_view_network_select_network.destroy()
514 &setting_view_network_select_network,
515 &setting_view_network_main, ad);
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");
525 if (0 != vconf_set_int(VCONFKEY_SETAPPL_SELECT_OLD_NT_ACT, ad->sel_act)) {
526 SETTING_TRACE_ERROR("vconf[%s] set failed");
529 ad->b_set_auto_network = FALSE;
530 ad->b_set_manul_network = FALSE;
531 setting_network_update_sel_network(ad);
533 void setting_tapi_get_plmn_mode_cb(TapiHandle *handle, int result, void *data, void *user_data)
536 SETTING_TRACE(" - result = 0x%x", result);
538 SettingNetworkUG *ad = user_data;
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) {
546 vconf_set_int(VCONFKEY_SETAPPL_SELECT_NETWORK_INT, ad->sel_net);
547 setting_network_update_sel_network(ad);
553 void setting_tapi_search_network_cb(TapiHandle *handle, int result, void *data, void *user_data)
555 ret_if(!data || !user_data);
556 SettingNetworkUG *ad = user_data;
558 SETTING_TRACE(" - result = %d", result);
559 setting_network_popup_delete(ad);
561 if (!ad->b_searching_network) {
562 /*The requeset has already been canceled, don't do detail process*/
565 //setting_finish_progress_genlist_item(ad->data_selected_network_item);
566 if (ad->data_search_network_item)
568 elm_object_item_del(ad->data_search_network_item->item);
569 ad->data_search_network_item = NULL;
572 ad->b_searching_network = FALSE;
574 if (result == TAPI_NETWORK_NO_ERR) {
576 memcpy(&(ad->plmn_info), data, sizeof(TelNetworkPlmnList_t));
578 Setting_GenGroupItem_Data *item_data = NULL;
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);
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));
589 if (TAPI_FORBIDDEN_PLMN == ad->plmn_info.network_list[cnt].type_of_plmn) {
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)
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));
608 item_data = setting_create_Gendial_field_1radio(
609 ad->genlist_sel_network,
611 setting_network_Gendial_select_plmn_cb,
615 TAPI_NETWORK_SELECTIONMODE_MANUAL+valid_cnt+1,
617 setting_network_select_network_chk_changed);
618 if (NULL == item_data)
620 SETTING_TRACE_ERROR("Failed to calloc memory");
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)
629 elm_radio_value_set(ad->chk_sel, item_data->chk_status);//let select nothing
636 SETTING_TRACE("Found %d valid networks in total[%d]", valid_cnt, cnt);
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);
644 setting_create_popup_without_btn(ad, ad->win_get, NULL, _(keyStr_Failed_Searched), NULL, POPUP_INTERVAL, FALSE, FALSE);
646 if (0 == valid_cnt && TAPI_NETWORK_SELECTIONMODE_AUTOMATIC == ad->sel_net && ad->data_auto_network_item)
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));
655 void setting_tapi_get_serving_network_cb(TapiHandle *handle, int result, void *data, void *user_data)
658 SETTING_TRACE(" - result = 0x%x", result);
659 ret_if(!user_data || !data);
660 SettingNetworkUG *ad = user_data;
661 TelNetworkServing_t *srv_nt = data;
663 if (result == TAPI_NETWORK_NO_ERR)
665 ad->sel_act = srv_nt->act;
666 vconf_set_int(VCONFKEY_SETAPPL_SELECT_OLD_NT_ACT, ad->sel_act);
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);
673 setting_network_update_sel_network(ad);
677 //if failed, do nothing..
684 void setting_tapi_cancel_manual_search_cb(TapiHandle *handle, int result, void *data, void *user_data)
687 SETTING_TRACE(" - result = 0x%x", result);
689 //SettingNetworkUG *ad = user_data;
692 void setting_tapi_set_preferred_plmn_cb(TapiHandle *handle, int result, void *data, void *user_data)
695 SETTING_TRACE(" - result = 0x%x", result);
697 SettingNetworkUG *ad = user_data;
698 setting_network_popup_delete(ad);
700 if (result != TAPI_NETWORK_NO_ERR) {
701 switch (ad->op_type) {
702 case SETTING_NETWORK_PREFERRED_NETWORK_DELETE:
704 setting_network_preferred_network_delete_failed(ad);
709 setting_create_popup_without_btn(ad, ad->win_get, NULL, _("IDS_COM_POP_ERROR"), NULL, POPUP_INTERVAL, FALSE, FALSE);
714 int tapi_ret = TAPI_API_SUCCESS;
715 switch (ad->op_type) {
716 case SETTING_NETWORK_PREFERRED_NETWORK_NEW:
719 (&setting_view_network_preferred_network_new,
720 &setting_view_network_preferred_network,ad);
722 tel_get_network_preferred_plmn
723 (ad->handle, setting_tapi_get_preferred_plmn_cb, ad);
727 case SETTING_NETWORK_PREFERRED_NETWORK_LIST:
731 (&setting_view_network_preferred_network_list,
732 &setting_view_network_preferred_network,
735 tel_get_network_preferred_plmn
736 (ad->handle, setting_tapi_get_preferred_plmn_cb, ad);
740 case SETTING_NETWORK_PREFERRED_NETWORK_EDIT:
743 (&setting_view_network_preferred_network_edit,
744 &setting_view_network_preferred_network,
747 tel_get_network_preferred_plmn
748 (ad->handle, setting_tapi_get_preferred_plmn_cb, ad);
751 case SETTING_NETWORK_PREFERRED_NETWORK_DELETE:
753 setting_network_preferred_network_delete_ok
760 (" Unknown prederred network type");
768 ("*** [ERR] tel_get_network_preferred_plmn. err=%d ***",
775 void setting_tapi_get_preferred_plmn_cb(TapiHandle *handle, int result, void *data, void *user_data)
778 SETTING_TRACE(" - result = 0x%x", result);
780 SettingNetworkUG *ad = user_data;
782 SETTING_TRACE_DEBUG("Case: TAPI_EVENT_NETWORK_GETPREFFEREDPLMN_CNF");
783 setting_network_popup_delete(ad);
785 if (result == TAPI_NETWORK_NO_ERR) {
786 memcpy(&(ad->pref_list), data,sizeof(TelNetworkPreferredPlmnList_t));
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:
793 setting_network_preferred_network_delete_draw_network_list(ad);
798 setting_network_preferred_network_refresh_view
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);
805 snprintf(info, sizeof(info), "Get %d preferred network",
806 ad->pref_list.NumOfPrefPlmns);
808 setting_create_popup_without_btn(ad, ad->win_get, NULL, _(info), NULL, POPUP_INTERVAL, FALSE, FALSE);
813 switch (ad->op_type) {
814 case SETTING_NETWORK_PREFERRED_NETWORK_DELETE:
816 setting_network_preferred_network_delete_failed
822 setting_create_popup_without_btn(ad, ad->win_get, NULL, _(keyStr_Failed_Get_PreferNetwork), NULL, POPUP_INTERVAL, FALSE, FALSE);
829 void __register_network(Setting_GenGroupItem_Data* list_item)
832 ret_if(list_item == NULL);
833 SETTING_TRACE("process item [%s]", list_item->keyStr);
834 SettingNetworkUG *ad = list_item->userdata;
837 int tapi_ret = TAPI_API_INVALID_INPUT;
839 //cancel the searching operation
841 if (ad->data_search_network_item)
843 elm_object_item_del(ad->data_search_network_item->item);
844 ad->data_search_network_item = NULL;
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);
856 ad->b_searching_network = FALSE;
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);
868 ad->network_ug_pop = setting_create_popup_without_btn(ad, ad->win_get, NULL,
869 _("IDS_COM_POP_PROCESSING"), NULL,
872 if (ad->data_auto_network_item)
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));
878 ad->b_set_manul_network = FALSE;
879 ad->b_set_auto_network = TRUE;
880 ad->sel_act = -1;//means "Automatic"
883 ad->sel_net = TAPI_NETWORK_SELECTIONMODE_MANUAL;
884 ad->b_set_manul_network = TRUE;
885 ad->b_set_auto_network = FALSE;
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++)
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));
900 if(!safeStrCmp(list_item->keyStr, name))
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));
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);
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)
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);
936 ad->network_ug_pop = setting_create_popup_without_btn(ad, ad->win_get, NULL,
937 _("IDS_COM_POP_PROCESSING"), NULL,
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);
947 void __switch_automatic_network(Setting_GenGroupItem_Data *list_item)
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
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);
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) {
964 elm_object_item_del(last_item);
967 __register_network(list_item);
971 //__register_network(list_item);
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);
979 // put error handler on the end of this function.
981 list_item->chk_status = TRUE;
982 elm_check_state_set(list_item->eo_check, list_item->chk_status);
985 ad->b_searching_network = TRUE;
986 ad->data_search_network_item = setting_create_Gendial_field_1radio(
987 ad->genlist_sel_network,
990 SWALLOW_Type_1RADIO_1SEARCH,
991 ad->chk_sel, -1, NULL, NULL);
992 if (ad->data_auto_network_item)
994 elm_genlist_item_item_class_update(ad->data_auto_network_item->item, &(itc_2text_1icon_7));
999 void setting_network_select_network_chk_changed(void *data, Evas_Object *obj, void *event_info)
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"))
1006 list_item->chk_status = elm_check_state_get(obj);
1007 __switch_automatic_network(list_item);
1009 else //"IDS_COM_BODY_AUTOMATIC"
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);
1019 void setting_network_Gendial_select_plmn_cb(void *data, Evas_Object *obj, void *event_info)
1021 SETTING_TRACE_BEGIN;
1022 retm_if(data == NULL || event_info == NULL, "Parameter is NULL");
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);
1029 SETTING_TRACE("list_item->keyStr:%s", list_item->keyStr);
1030 if (0 == safeStrCmp(list_item->keyStr, "IDS_COM_BODY_AUTOMATIC"))
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);
1039 int old_chk_status = elm_radio_value_get(ad->chk_sel);
1040 if (old_chk_status != list_item->chk_status)
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);
1049 void setting_network_update_sel_network(void *data)
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);
1057 if (ad->data_auto_network_item) {
1058 if (TAPI_NETWORK_SELECTIONMODE_AUTOMATIC == ad->sel_net)
1060 SETTING_TRACE_DEBUG("After set as Automatic, update "\
1061 "ad->data_auto_network_item to be [%s]",
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);
1070 if (ad->data_sel_net)//it indicates TAPI is not responsed in time
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));
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));
1083 SETTING_TRACE("sel_network_desc:%s", sel_network_desc);
1085 G_FREE(ad->data_sel_net->sub_desc);
1086 ad->data_sel_net->sub_desc = (char *)g_strdup(_(sel_network_desc));
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);
1093 const char *setting_network_get_act_str(TelNetworkSystemType_t type)
1097 case TAPI_NETWORK_SYSTEM_NO_SRV: //0
1098 return "NO SERVICE";
1099 case TAPI_NETWORK_SYSTEM_GSM: //1
1101 case TAPI_NETWORK_SYSTEM_GPRS: //2
1103 case TAPI_NETWORK_SYSTEM_EGPRS: //3
1105 case TAPI_NETWORK_SYSTEM_PCS1900: //4
1107 case TAPI_NETWORK_SYSTEM_UMTS: //5
1109 case TAPI_NETWORK_SYSTEM_GSM_AND_UMTS:
1110 return "GSM and UMTS";
1111 case TAPI_NETWORK_SYSTEM_HSDPA:
1113 case TAPI_NETWORK_SYSTEM_IS95A:
1115 case TAPI_NETWORK_SYSTEM_IS95B:
1117 case TAPI_NETWORK_SYSTEM_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:
1130 return "NO SERVICE";
1135 void __default_tapi_response_cb(TapiHandle *handle, int result, void *data, void *user_data)
1140 UG_MODULE_API int setting_plugin_reset(service_h service, void *priv)
1142 SETTING_TRACE_BEGIN;
1145 #if SUPPORT_RUN_SYSTEM_COMMAND
1146 ret += excuteCmd(SETTING_POSTINST_FILE, 1, "network");
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);
1155 if (net_register_client((net_event_cb_t)__network_evt_cb, NULL) != NET_ERR_NONE) {
1156 SETTING_TRACE_ERROR("net_register_client. failed");
1159 TapiHandle *tapi_handle = tel_init(NULL);
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) {
1166 SETTING_TRACE_ERROR("tel_select_network_automatic. tapi_ret=%d", tapi_ret);
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) {
1175 SETTING_TRACE_ERROR("tel_set_network_band. tapi_ret=%d", tapi_ret);
1178 //3.don't need to receive
1179 if (tel_deinit(tapi_handle) == TAPI_API_SUCCESS) {
1180 SETTING_TRACE_DEBUG("tel_deinit sucessfull");
1187 if (net_deregister_client() != NET_ERR_NONE) {
1189 SETTING_TRACE_ERROR("net_deregister_client failed");
1192 //Reset connections info..
1193 ret += excuteCmd("/usr/bin/dbus-send", 1, NET_CON_RESET_DBUS_PARA);