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.h>
23 static int setting_network_preferred_network_create(void *cb);
24 static int setting_network_preferred_network_destroy(void *cb);
25 static int setting_network_preferred_network_update(void *cb);
26 static int setting_network_preferred_network_cleanup(void *cb);
28 setting_view setting_view_network_preferred_network = {
29 .create = setting_network_preferred_network_create,
30 .destroy = setting_network_preferred_network_destroy,
31 .update = setting_network_preferred_network_update,
32 .cleanup = setting_network_preferred_network_cleanup,
35 static void setting_network_preferred_network_Gendial_list_item_mouse_up_cb(void
41 static void setting_network_preferred_network_click_softkey_add_cb(void *data,
45 static void setting_network_preferred_network_click_softkey_delete_cb(void
51 static void setting_network_preferred_network_click_softkey_back_cb(void *data,
55 static void setting_network_preferred_network_click_ctxpopup_menu_1_cb(void
61 static void setting_network_preferred_network_click_ctxpopup_menu_2_cb(void
68 static int setting_network_preferred_network_draw_network_list(void *data);
70 /* ***************************************************
74 ***************************************************/
76 static int setting_network_preferred_network_create(void *cb)
80 retv_if(cb == NULL, SETTING_GENERAL_ERR_NULL_DATA_PARAMETER);
81 SettingNetworkUG *ad = (SettingNetworkUG *) cb;
83 int tapi_ret = TAPI_API_SUCCESS;
86 tapi_ret = tel_get_network_preferred_plmn(ad->handle, setting_tapi_get_preferred_plmn_cb, ad);
87 if (tapi_ret != TAPI_API_SUCCESS) {
89 ("%s*** [ERR] tel_get_network_preferred_plmn. err=%d ***%s",
90 SETTING_FONT_RED, tapi_ret, SETTING_FONT_BLACK);
94 ad->scl_pref = elm_genlist_add(ad->win_main_layout);
95 elm_object_style_set(ad->scl_pref , "dialogue");
96 retvm_if(ad->scl_pref == NULL, SETTING_RETURN_FAIL,
97 "Cannot set scroller object as contento of layout");
98 elm_genlist_clear(ad->scl_pref); /* first to clear list */
100 setting_push_layout_navi_bar(_("IDS_ST_BODY_PREFERRED_NETWORKS"),
101 _("IDS_COM_BODY_BACK"), _("IDS_COM_ADD"),
102 _("IDS_COM_SK_DELETE"),
103 setting_network_preferred_network_click_softkey_back_cb,
104 setting_network_preferred_network_click_softkey_add_cb,
105 setting_network_preferred_network_click_softkey_delete_cb,
106 ad, ad->scl_pref, ad->navi_bar, NULL);
108 /* create preffered network list */
109 setting_network_preferred_network_draw_network_list(ad);
110 /* ad->pop_pref_sch = setting_network_preferred_network_create_search_popup(ad); */
112 setting_create_popup_without_btn(ad, ad->win_get, NULL, _("IDS_COM_POP_SEARCHING"),
113 NULL, 0.0, TRUE, TRUE);
115 setting_view_network_preferred_network.is_create = 1;
117 return SETTING_RETURN_SUCCESS;
120 static int setting_network_preferred_network_destroy(void *cb)
123 retv_if(cb == NULL, SETTING_GENERAL_ERR_NULL_DATA_PARAMETER);
125 SettingNetworkUG *ad = (SettingNetworkUG *) cb;
127 evas_object_del(ad->popup);
130 elm_naviframe_item_pop(ad->navi_bar);
131 setting_view_network_preferred_network.is_create = 0;
132 return SETTING_RETURN_SUCCESS;
135 static int setting_network_preferred_network_update(void *cb)
138 retv_if(cb == NULL, SETTING_GENERAL_ERR_NULL_DATA_PARAMETER);
140 SettingNetworkUG *ad = (SettingNetworkUG *) cb;
142 setting_network_preferred_network_refresh_view(ad);
144 return SETTING_RETURN_SUCCESS;
147 static int setting_network_preferred_network_cleanup(void *cb)
149 return setting_network_preferred_network_destroy(cb);
152 /* ***************************************************
156 ***************************************************/
158 int setting_network_preferred_network_refresh_view(void *data)
161 retv_if(data == NULL, SETTING_GENERAL_ERR_NULL_DATA_PARAMETER);
162 SettingNetworkUG *ad = (SettingNetworkUG *) data;
164 setting_network_preferred_network_draw_network_list(ad);
169 static int setting_network_preferred_network_draw_network_list(void *data)
172 retv_if(data == NULL, SETTING_GENERAL_ERR_NULL_DATA_PARAMETER);
173 SettingNetworkUG *ad = (SettingNetworkUG *) data;
176 elm_genlist_clear(ad->scl_pref); /* first to clear list */
177 for (i = 0; i < ad->pref_list.NumOfPrefPlmns; i++) {
178 setting_create_Gendial_field_def(ad->scl_pref, &itc_1text,
179 setting_network_preferred_network_Gendial_list_item_mouse_up_cb,
180 ad, SWALLOW_Type_INVALID, NULL,
183 pref_list.PrefPlmnRecord
184 [i].network_name, NULL, NULL);
190 /* ***************************************************
194 ***************************************************/
197 setting_network_preferred_network_Gendial_list_item_mouse_up_cb(void *data,
204 setting_retm_if(data == NULL, "Data parameter is NULL");
205 Elm_Object_Item *item = (Elm_Object_Item *) event_info;
206 elm_genlist_item_selected_set(item, 0);
207 Setting_GenGroupItem_Data *list_item =
208 (Setting_GenGroupItem_Data *) elm_object_item_data_get(item);
210 SettingNetworkUG *ad = (SettingNetworkUG *) data;
212 SETTING_TRACE("clicking item[%s]", _(list_item->keyStr));
215 for (i = 0; i < ad->pref_list.NumOfPrefPlmns; i++) {
217 (ad->pref_list.PrefPlmnRecord[i].network_name,
218 list_item->keyStr)) {
223 SETTING_TRACE("i:%d", i);
224 ad->sel_pref_idx = ad->pref_list.PrefPlmnRecord[i].Index;
225 setting_view_change(&setting_view_network_preferred_network,
226 &setting_view_network_preferred_network_edit, ad);
230 setting_network_preferred_network_click_softkey_back_cb(void *data,
235 retm_if(data == NULL,
236 "[Setting > Network > Preferred Net] Data parameter is NULL");
237 SettingNetworkUG *ad = (SettingNetworkUG *) data;
239 setting_view_change(&setting_view_network_preferred_network,
240 &setting_view_network_main, ad);
244 setting_network_preferred_network_click_ctxpopup_menu_1_cb(void *data,
249 retm_if(data == NULL,
250 "[Setting > Network > Preferred Net] Data parameter is NULL");
252 SettingNetworkUG *ad = (SettingNetworkUG *) data;
254 evas_object_del(ad->popup);
256 setting_view_change(&setting_view_network_preferred_network,
257 &setting_view_network_preferred_network_list, ad);
261 setting_network_preferred_network_click_ctxpopup_menu_2_cb(void *data,
266 retm_if(data == NULL,
267 "[Setting > Network > Preferred Net] Data parameter is NULL");
269 SettingNetworkUG *ad = (SettingNetworkUG *) data;
271 evas_object_del(ad->popup);
273 setting_view_change(&setting_view_network_preferred_network,
274 &setting_view_network_preferred_network_new, ad);
278 setting_network_preferred_network_click_softkey_add_cb(void *data,
284 retm_if(data == NULL,
285 "[Setting > Network > Preferred Net] Data parameter is NULL");
287 SettingNetworkUG *ad = (SettingNetworkUG *) data;
289 ad->popup = elm_ctxpopup_add(ad->navi_bar);
290 /* evas_object_smart_callback_add(ad->popup, "hide", _ctxpopup_cb, ad->popup); */
292 elm_ctxpopup_item_append(ad->popup, _("IDS_ST_BODY_NETWORK_LIST"), NULL,
293 setting_network_preferred_network_click_ctxpopup_menu_1_cb,
295 elm_ctxpopup_item_append(ad->popup, _("IDS_ST_POP_TEXT_NEW_NETWORK"),
297 setting_network_preferred_network_click_ctxpopup_menu_2_cb,
300 evas_object_resize(ad->popup, 480 * WIDGET_SCALE_FACTOR,
301 300 * WIDGET_SCALE_FACTOR);
303 Evas_Coord x, y, w, h;
304 evas_object_geometry_get(obj, &x, &y, &w, &h);
305 evas_object_move(ad->popup, (x + w / 2) * WIDGET_SCALE_FACTOR,
306 (y + h) * WIDGET_SCALE_FACTOR);
307 evas_object_show(ad->popup);
311 setting_network_preferred_network_click_softkey_delete_cb(void *data,
316 retm_if(data == NULL,
317 "[Setting > Network > Preferred Net] Data parameter is NULL");
319 SettingNetworkUG *ad = (SettingNetworkUG *) data;
321 if (ad->pref_list.NumOfPrefPlmns == 0) {
322 setting_create_simple_popup(ad, ad->win_get,
323 NULL, _("No Network to delete!"));
325 setting_view_change(&setting_view_network_preferred_network,
326 &setting_view_network_preferred_network_delete,