3 * Copyright (c) 2012 Samsung Electronics Co., Ltd.
5 * Licensed under the Flora License, Version 1.0 (the License);
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
9 * http://floralicense.org/license/
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an AS IS BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
17 #include <setting-network-preferred-network.h>
19 static int setting_network_preferred_network_create(void *cb);
20 static int setting_network_preferred_network_destroy(void *cb);
21 static int setting_network_preferred_network_update(void *cb);
22 static int setting_network_preferred_network_cleanup(void *cb);
24 setting_view setting_view_network_preferred_network = {
25 .create = setting_network_preferred_network_create,
26 .destroy = setting_network_preferred_network_destroy,
27 .update = setting_network_preferred_network_update,
28 .cleanup = setting_network_preferred_network_cleanup,
31 static void setting_network_preferred_network_Gendial_list_item_mouse_up_cb(void
37 static void setting_network_preferred_network_click_softkey_add_cb(void *data,
41 static void setting_network_preferred_network_click_softkey_delete_cb(void
47 static void setting_network_preferred_network_click_softkey_back_cb(void *data,
51 static void setting_network_preferred_network_click_ctxpopup_menu_1_cb(void
57 static void setting_network_preferred_network_click_ctxpopup_menu_2_cb(void
64 static int setting_network_preferred_network_draw_network_list(void *data);
66 /* ***************************************************
70 ***************************************************/
72 static int setting_network_preferred_network_create(void *cb)
76 retv_if(cb == NULL, SETTING_GENERAL_ERR_NULL_DATA_PARAMETER);
77 SettingNetworkUG *ad = (SettingNetworkUG *) cb;
79 int tapi_ret = TAPI_API_SUCCESS;
82 tapi_ret = tel_get_network_preferred_plmn(ad->handle, setting_tapi_get_preferred_plmn_cb, ad);
83 if (tapi_ret != TAPI_API_SUCCESS) {
85 ("%s*** [ERR] tel_get_network_preferred_plmn. err=%d ***%s",
86 SETTING_FONT_RED, tapi_ret, SETTING_FONT_BLACK);
90 ad->scl_pref = elm_genlist_add(ad->win_main_layout);
91 elm_object_style_set(ad->scl_pref , "dialogue");
92 retvm_if(ad->scl_pref == NULL, SETTING_RETURN_FAIL,
93 "Cannot set scroller object as contento of layout");
94 elm_genlist_clear(ad->scl_pref); /* first to clear list */
96 setting_push_layout_navi_bar(_("IDS_ST_BODY_PREFERRED_NETWORKS"),
97 _("IDS_COM_BODY_BACK"), _("IDS_COM_ADD"),
98 _("IDS_COM_SK_DELETE"),
99 setting_network_preferred_network_click_softkey_back_cb,
100 setting_network_preferred_network_click_softkey_add_cb,
101 setting_network_preferred_network_click_softkey_delete_cb,
102 ad, ad->scl_pref, ad->navi_bar, NULL);
104 /* create preffered network list */
105 setting_network_preferred_network_draw_network_list(ad);
106 /* ad->pop_pref_sch = setting_network_preferred_network_create_search_popup(ad); */
108 setting_create_popup_without_btn(ad, ad->win_get, NULL, _("IDS_COM_POP_SEARCHING"),
109 NULL, 0.0, TRUE, TRUE);
111 setting_view_network_preferred_network.is_create = 1;
113 return SETTING_RETURN_SUCCESS;
116 static int setting_network_preferred_network_destroy(void *cb)
119 retv_if(cb == NULL, SETTING_GENERAL_ERR_NULL_DATA_PARAMETER);
121 SettingNetworkUG *ad = (SettingNetworkUG *) cb;
123 evas_object_del(ad->popup);
126 elm_naviframe_item_pop(ad->navi_bar);
127 setting_view_network_preferred_network.is_create = 0;
128 return SETTING_RETURN_SUCCESS;
131 static int setting_network_preferred_network_update(void *cb)
134 retv_if(cb == NULL, SETTING_GENERAL_ERR_NULL_DATA_PARAMETER);
136 SettingNetworkUG *ad = (SettingNetworkUG *) cb;
138 setting_network_preferred_network_refresh_view(ad);
140 return SETTING_RETURN_SUCCESS;
143 static int setting_network_preferred_network_cleanup(void *cb)
145 return setting_network_preferred_network_destroy(cb);
148 /* ***************************************************
152 ***************************************************/
154 int setting_network_preferred_network_refresh_view(void *data)
157 retv_if(data == NULL, SETTING_GENERAL_ERR_NULL_DATA_PARAMETER);
158 SettingNetworkUG *ad = (SettingNetworkUG *) data;
160 setting_network_preferred_network_draw_network_list(ad);
165 static int setting_network_preferred_network_draw_network_list(void *data)
168 retv_if(data == NULL, SETTING_GENERAL_ERR_NULL_DATA_PARAMETER);
169 SettingNetworkUG *ad = (SettingNetworkUG *) data;
172 elm_genlist_clear(ad->scl_pref); /* first to clear list */
173 for (i = 0; i < ad->pref_list.NumOfPrefPlmns; i++) {
174 setting_create_Gendial_field_def(ad->scl_pref, &itc_1text,
175 setting_network_preferred_network_Gendial_list_item_mouse_up_cb,
176 ad, SWALLOW_Type_INVALID, NULL,
179 pref_list.PrefPlmnRecord
180 [i].network_name, NULL, NULL);
186 /* ***************************************************
190 ***************************************************/
193 setting_network_preferred_network_Gendial_list_item_mouse_up_cb(void *data,
200 setting_retm_if(data == NULL, "Data parameter is NULL");
201 Elm_Object_Item *item = (Elm_Object_Item *) event_info;
202 elm_genlist_item_selected_set(item, 0);
203 Setting_GenGroupItem_Data *list_item =
204 (Setting_GenGroupItem_Data *) elm_object_item_data_get(item);
206 SettingNetworkUG *ad = (SettingNetworkUG *) data;
208 SETTING_TRACE("clicking item[%s]", _(list_item->keyStr));
211 for (i = 0; i < ad->pref_list.NumOfPrefPlmns; i++) {
213 (ad->pref_list.PrefPlmnRecord[i].network_name,
214 list_item->keyStr)) {
219 SETTING_TRACE("i:%d", i);
220 ad->sel_pref_idx = ad->pref_list.PrefPlmnRecord[i].Index;
221 setting_view_change(&setting_view_network_preferred_network,
222 &setting_view_network_preferred_network_edit, ad);
226 setting_network_preferred_network_click_softkey_back_cb(void *data,
231 retm_if(data == NULL,
232 "[Setting > Network > Preferred Net] Data parameter is NULL");
233 SettingNetworkUG *ad = (SettingNetworkUG *) data;
235 setting_view_change(&setting_view_network_preferred_network,
236 &setting_view_network_main, ad);
240 setting_network_preferred_network_click_ctxpopup_menu_1_cb(void *data,
245 retm_if(data == NULL,
246 "[Setting > Network > Preferred Net] Data parameter is NULL");
248 SettingNetworkUG *ad = (SettingNetworkUG *) data;
250 evas_object_del(ad->popup);
252 setting_view_change(&setting_view_network_preferred_network,
253 &setting_view_network_preferred_network_list, ad);
257 setting_network_preferred_network_click_ctxpopup_menu_2_cb(void *data,
262 retm_if(data == NULL,
263 "[Setting > Network > Preferred Net] Data parameter is NULL");
265 SettingNetworkUG *ad = (SettingNetworkUG *) data;
267 evas_object_del(ad->popup);
269 setting_view_change(&setting_view_network_preferred_network,
270 &setting_view_network_preferred_network_new, ad);
274 setting_network_preferred_network_click_softkey_add_cb(void *data,
280 retm_if(data == NULL,
281 "[Setting > Network > Preferred Net] Data parameter is NULL");
283 SettingNetworkUG *ad = (SettingNetworkUG *) data;
285 ad->popup = elm_ctxpopup_add(ad->navi_bar);
286 /* evas_object_smart_callback_add(ad->popup, "hide", _ctxpopup_cb, ad->popup); */
288 elm_ctxpopup_item_append(ad->popup, _("IDS_ST_BODY_NETWORK_LIST"), NULL,
289 setting_network_preferred_network_click_ctxpopup_menu_1_cb,
291 elm_ctxpopup_item_append(ad->popup, _("IDS_ST_POP_TEXT_NEW_NETWORK"),
293 setting_network_preferred_network_click_ctxpopup_menu_2_cb,
296 evas_object_resize(ad->popup, 480 * WIDGET_SCALE_FACTOR,
297 300 * WIDGET_SCALE_FACTOR);
299 Evas_Coord x, y, w, h;
300 evas_object_geometry_get(obj, &x, &y, &w, &h);
301 evas_object_move(ad->popup, (x + w / 2) * WIDGET_SCALE_FACTOR,
302 (y + h) * WIDGET_SCALE_FACTOR);
303 evas_object_show(ad->popup);
307 setting_network_preferred_network_click_softkey_delete_cb(void *data,
312 retm_if(data == NULL,
313 "[Setting > Network > Preferred Net] Data parameter is NULL");
315 SettingNetworkUG *ad = (SettingNetworkUG *) data;
317 if (ad->pref_list.NumOfPrefPlmns == 0) {
318 setting_create_simple_popup(ad, ad->win_get,
319 NULL, _("No Network to delete!"));
321 setting_view_change(&setting_view_network_preferred_network,
322 &setting_view_network_preferred_network_delete,