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-preferred-network-new.h>
22 #include <setting-network-preferred-network.h>
24 static int setting_network_preferred_network_new_create(void *cb);
25 static int setting_network_preferred_network_new_destroy(void *cb);
26 static int setting_network_preferred_network_new_update(void *cb);
27 static int setting_network_preferred_network_new_cleanup(void *cb);
29 setting_view setting_view_network_preferred_network_new = {
30 .create = setting_network_preferred_network_new_create,
31 .destroy = setting_network_preferred_network_new_destroy,
32 .update = setting_network_preferred_network_new_update,
33 .cleanup = setting_network_preferred_network_new_cleanup,
36 /* ***************************************************
40 ***************************************************/
42 static int setting_network_preferred_network_new_create(void *cb)
45 retv_if(cb == NULL, SETTING_GENERAL_ERR_NULL_DATA_PARAMETER);
47 SettingNetworkUG *ad = (SettingNetworkUG *) cb;
49 Evas_Object *scroller = NULL;
50 /* Add basic layout */
51 setting_push_layout_navi_bar_genlist(ad->win_main_layout, ad->win_get,
52 _("IDS_ST_HEADER_NEW_NETWORK"),
53 _("IDS_COM_SK_CANCEL"),
55 setting_network_preferred_network_new_click_softkey_cancel_cb,
56 setting_network_preffered_network_new_click_softkey_save_cb,
57 ad, &scroller, ad->navi_bar);
58 Elm_Object_Item *item = NULL;;
61 elm_genlist_item_append(scroller, &itc_seperator, NULL, NULL,
62 ELM_GENLIST_ITEM_NONE, NULL, NULL);
63 elm_genlist_item_select_mode_set(item, ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY);
66 setting_create_Gendial_field_def(scroller,
68 NULL, SWALLOW_Type_LAYOUT_ENTRY,
70 "IDS_ST_BODY_COUNTRY_CODE",
72 setting_network_preferred_network_new_entry_changed_cb);
73 if (ad->data_new_mcc) {
74 ad->data_new_mcc->userdata = ad;
75 ad->data_new_mcc->input_type = ELM_INPUT_PANEL_LAYOUT_NUMBERONLY;
77 SETTING_TRACE_ERROR("ad->data_new_mcc is NULL");
81 setting_create_Gendial_field_def(scroller,
83 NULL, SWALLOW_Type_LAYOUT_ENTRY,
85 "IDS_ST_BODY_NETWORK_CODE",
87 setting_network_preferred_network_new_entry_changed_cb);
88 if (ad->data_new_mnc) {
89 ad->data_new_mnc->userdata = ad;
90 ad->data_new_mnc->input_type = ELM_INPUT_PANEL_LAYOUT_NUMBERONLY;
92 SETTING_TRACE_ERROR("ad->data_new_mnc is NULL");
95 (void)setting_create_Gendial_field_titleItem(scroller,
97 "IDS_ST_BODY_NETWORK_TYPE",
99 ad->chk_new_type = elm_radio_add(scroller);
100 elm_radio_state_value_set(ad->chk_new_type, 0);
102 setting_create_Gendial_field_1radio(scroller, &itc_1text_1icon_2,
103 setting_mouse_up_Gendial_list_radio_cb,
106 ad->chk_new_type, 0, "IDS_ST_BODY_GSM", NULL);
108 setting_create_Gendial_field_1radio(scroller, &itc_1text_1icon_2,
109 setting_mouse_up_Gendial_list_radio_cb,
112 ad->chk_new_type, 1, "UMTS", NULL);
113 setting_view_network_preferred_network_new.is_create = 1;
114 return SETTING_RETURN_SUCCESS;
117 static int setting_network_preferred_network_new_destroy(void *cb)
120 retv_if(cb == NULL, SETTING_GENERAL_ERR_NULL_DATA_PARAMETER);
122 SettingNetworkUG *ad = (SettingNetworkUG *) cb;
124 elm_naviframe_item_pop(ad->navi_bar);
125 setting_view_network_preferred_network_new.is_create = 0;
126 return SETTING_RETURN_SUCCESS;
129 static int setting_network_preferred_network_new_update(void *cb)
131 return SETTING_RETURN_SUCCESS;
134 static int setting_network_preferred_network_new_cleanup(void *cb)
136 return setting_network_preferred_network_new_destroy(cb);
139 /* ***************************************************
143 ***************************************************/
145 /* ***************************************************
149 ***************************************************/
151 setting_network_preferred_network_new_entry_changed_cb(void *data,
155 retm_if(data == NULL, "Data parameter is NULL");
156 Setting_GenGroupItem_Data *list_item =
157 (Setting_GenGroupItem_Data *) data;
158 /* SettingNetworkUG *ad = list_item->userdata; */
159 const char *entry_str = elm_entry_entry_get(obj);
160 /* SETTING_TRACE("entry_str:%s", entry_str); */
161 list_item->sub_desc = (char *)g_strdup(entry_str);
165 setting_network_preffered_network_new_click_softkey_save_cb(void *data,
171 retm_if(data == NULL,
172 "[Setting > Netwrok > Preferred New] Data parameter is NULL");
174 SettingNetworkUG *ad = (SettingNetworkUG *) data;
176 int tapi_ret = TAPI_API_SUCCESS;
178 TelNetworkPreferredPlmnInfo_t pref_plmn_info = { 0, };
180 int network_type = 0;
181 const char *mcc = NULL;
182 const char *mnc = NULL;
183 if (ad->data_new_mcc) {
184 mcc = ad->data_new_mcc->sub_desc;
186 if (ad->data_new_mnc) {
187 mnc = ad->data_new_mnc->sub_desc;
190 setting_retm_if(isEmptyStr(mcc)
192 "mcc or mnc got from editfiled error");
193 int mcc_len = strlen(mcc);
194 int mnc_len = strlen(mnc);
195 if (COUNTRY_CODE_LEN != mcc_len) {
196 if ((NETWORK_CODE_LEN < mnc_len) || (mnc_len <= 0)) {
197 setting_create_popup_without_btn(ad, ad->win_get,
198 NULL, _("please input country code made up of 3 digital number and network code made up of 1 ~ 3 digital number"),
199 NULL, POPUP_INTERVAL, FALSE, FALSE);
201 setting_create_popup_without_btn(ad, ad->win_get,
202 NULL, _("please input country code made up of 3 digital number"),
203 NULL, POPUP_INTERVAL, FALSE, FALSE);
208 if ((NETWORK_CODE_LEN < mnc_len) || (mnc_len <= 0)) {
209 setting_create_popup_without_btn(ad, ad->win_get,
210 NULL, _("please input network code made up of 1 ~ 3 digital number"),
211 NULL, POPUP_INTERVAL, FALSE, FALSE);
215 network_type = elm_radio_value_get(ad->chk_new_type);
218 safeCopyStr((char *)pref_plmn_info.Plmn, (char *)mcc, 3);
219 safeCopyStr((char *)pref_plmn_info.Plmn + 3, (char *)mnc, 3);
221 SETTING_TRACE_DEBUG("%s*** mcc=%s, mnc=%s, plmn=%s ***%s",
222 SETTING_FONT_BGREEN, mcc, mnc,
223 (char *)(pref_plmn_info.Plmn), SETTING_FONT_BLACK);
225 /* save network type */
226 if (network_type == 0) {
227 pref_plmn_info.SystemType = TAPI_NETWORK_SYSTEM_GSM;
229 pref_plmn_info.SystemType = TAPI_NETWORK_SYSTEM_UMTS;
232 pref_plmn_info.Index =
233 ad->pref_list.PrefPlmnRecord[ad->pref_list.NumOfPrefPlmns -
237 setting_create_popup_without_btn(ad, ad->win_get, NULL, _("IDS_ST_POP_SAVING"),
238 NULL, 0.0, TRUE, TRUE);
240 tel_set_network_preferred_plmn(ad->handle, TAPI_NETWORK_PREF_PLMN_ADD,
241 &pref_plmn_info, setting_tapi_set_preferred_plmn_cb, ad);
242 if (tapi_ret != TAPI_API_SUCCESS) {
244 ("%s*** [ERR] tel_set_network_preferred_plmn(PLMN_ADD) err=%d ***%s",
245 SETTING_FONT_RED, tapi_ret, SETTING_FONT_BLACK);
246 setting_create_popup_without_btn(ad, ad->win_get, NULL, _("Save Failed!"), NULL, POPUP_INTERVAL, FALSE, FALSE);
249 ad->op_type = SETTING_NETWORK_PREFERRED_NETWORK_NEW;
253 setting_network_preferred_network_new_click_softkey_cancel_cb(void *data,
257 SettingNetworkUG *ad = (SettingNetworkUG *) data;
260 retm_if(data == NULL,
261 "[Setting > Network > Preferred New] Data parameter is NULL");
262 ad->op_type = SETTING_NETWORK_PREFERRED_NETWORK_NONE;
263 setting_view_change(&setting_view_network_preferred_network_new,
264 &setting_view_network_preferred_network, ad);