tizen 2.4 release
[apps/home/settings.git] / setting-network / src / setting-network-profile-delete.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-profile-delete.h>
22
23 static int setting_network_profile_delete_create(void *cb);
24 static int setting_network_profile_delete_destroy(void *cb);
25 static int setting_network_profile_delete_update(void *cb);
26 static int setting_network_profile_delete_cleanup(void *cb);
27
28 setting_view setting_view_network_profile_delete = {
29         .create = setting_network_profile_delete_create,
30         .destroy = setting_network_profile_delete_destroy,
31         //.update = setting_network_profile_delete_update,
32         .update = NULL,
33         .cleanup = setting_network_profile_delete_cleanup,
34 };
35
36 /* ***************************************************
37  *
38  *basic func
39  *
40  ***************************************************/
41 static void __profile_delete_list_draw(SettingNetworkUG *ad)
42 {
43         SETTING_TRACE_BEGIN;
44         if (ad->profile_del_list != NULL) {
45                 eina_list_free(ad->profile_del_list);
46                 ad->profile_del_list = NULL;
47         }
48         elm_genlist_clear(ad->gl_profile_del);  /* first to clear list */
49         Elm_Object_Item *first_item;
50         /* item = elm_genlist_item_append(scroller, &itc_seperator, NULL, NULL, ELM_GENLIST_ITEM_GROUP, NULL, NULL); */
51         first_item = elm_genlist_item_append(ad->gl_profile_del, &itc_seperator, NULL, NULL,
52                                              ELM_GENLIST_ITEM_NONE, NULL, NULL);
53         elm_genlist_item_select_mode_set(first_item, ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY);
54
55         Eina_List *elist = NULL;
56         connection_profile_h profile_h = NULL;
57         int idx = 0;
58         char *id = NULL;
59         char *apn = NULL;
60         char *name = NULL;
61         char *proxy_address = NULL;
62         connection_profile_type_e profile_type = CONNECTION_PROFILE_TYPE_CELLULAR;
63         Setting_GenGroupItem_Data *item_data = NULL;
64
65         setting_network_reget_profile_list(ad);
66
67         // CREATE GENLIST 'Select All'
68
69         // CREATE GENLIST
70         SETTING_TRACE("ad->profile_list:%p", ad->profile_list);
71         EINA_LIST_FOREACH(ad->profile_list, elist, profile_h) {
72                 SETTING_TRACE("profile_h:%p", profile_h);
73                 if (!profile_h)
74                         continue;
75                 apn = name = proxy_address = id = NULL;
76                 connection_profile_get_cellular_apn(profile_h, &apn);
77                 if (isEmptyStr(apn))
78                         continue;
79                 connection_profile_get_name(profile_h, &name);
80                 if (isEmptyStr(name))
81                         continue;
82                 connection_profile_get_proxy_address(profile_h, CONNECTION_ADDRESS_FAMILY_IPV4, &proxy_address);
83                 connection_profile_get_id(profile_h, &id);
84
85                 if (connection_profile_get_type(profile_h, &profile_type) != CONNECTION_ERROR_NONE) {
86                         SETTING_TRACE_ERROR("Fail to get profile type");
87                         continue;
88                 }
89
90                 SETTING_TRACE("Record[%s], profile_type:%d, service_type:%d, id:%s",
91                               apn, profile_type, ad->profile_service_type, id);
92
93                 item_data = (Setting_GenGroupItem_Data *) calloc(1, sizeof(Setting_GenGroupItem_Data));
94                 if (0 == item_data) {
95                         SETTING_TRACE_ERROR("calloc failed");
96                         G_FREE(apn);
97                         return;
98                 }
99                 item_data->keyStr = (char *)g_strdup(name);
100                 item_data->swallow_type = SWALLOW_Type_1CHECK_RIGHT;
101                 item_data->r_swallow_path = (char *)g_strdup("reveal/extended");
102                 item_data->chk_change_cb = setting_network_profile_delete_check_cb;
103                 item_data->userdata = ad;
104                 item_data->sub_desc = (char *)g_strdup(apn);
105                 item_data->belongs_to = (int) profile_h;
106
107                 item_data->item =
108                     elm_genlist_item_append(ad->gl_profile_del, &(itc_2text_1icon_2), item_data, NULL,
109                                             ELM_GENLIST_ITEM_NONE,
110                                             setting_network_profile_delete_mouse_up_cb, ad);
111                 ad->profile_del_list =
112                     eina_list_append(ad->profile_del_list, item_data);
113
114                 idx++;
115         }
116
117         Evas_Object *toolbar = elm_object_item_part_content_get(ad->navi_it_profile_del_list, "toolbar");
118         Evas_Object *allbtn = elm_object_item_part_content_get(ad->navi_it_profile_del_list, "title_left_btn");
119         SETTING_TRACE("idx:%d", idx);
120         if (idx == 1) {
121                 if (allbtn) elm_object_disabled_set(allbtn, EINA_FALSE);
122         } else if (idx > 1) {
123                 if (allbtn) elm_object_disabled_set(allbtn, EINA_FALSE);
124         } else {
125                 if (ad->profile_list != NULL) {
126                         eina_list_free(ad->profile_list);
127                         ad->profile_list = NULL;
128                 }
129                 SETTING_TRACE("To disable");
130                 elm_object_item_disabled_set(elm_toolbar_last_item_get(toolbar), EINA_TRUE);
131                 if (allbtn) elm_object_disabled_set(allbtn, EINA_TRUE);
132                 SETTING_TRACE("To disable");
133         }
134         G_FREE(apn);
135         G_FREE(name);
136         G_FREE(proxy_address);
137         G_FREE(id);
138         return;
139 }
140
141 //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
142 static Evas_Object* ctxpopup;
143
144 static void
145 ctxpopup_dismissed_cb(void *data, Evas_Object *obj, void *event_info)
146 {
147         SETTING_TRACE_BEGIN;
148         evas_object_del(ctxpopup);
149         ctxpopup = NULL;
150 }
151
152 static void
153 move_more_ctxpopup(Evas_Object *ctxpopup)
154 {
155         SETTING_TRACE_BEGIN;
156         Evas_Object *win;
157         Evas_Coord w, h;
158         int pos = -1;
159
160         /* We convince the top widget is a window */
161         win = elm_object_top_widget_get(ctxpopup);
162         elm_win_screen_size_get(win, NULL, NULL, &w, &h);
163         pos = elm_win_rotation_get(win);
164
165         switch (pos) {
166                 case 0:
167                 case 180:
168                         evas_object_move(ctxpopup, (w / 2), h);
169                         break;
170                 case 90:
171                         evas_object_move(ctxpopup,  (h / 2), w);
172                         break;
173                 case 270:
174                         evas_object_move(ctxpopup, (h / 2), w);
175                         break;
176         }
177 }
178
179 static void
180 naviframe_resize_cb(void *data, Evas *e, Evas_Object *obj, void *event_info)
181 {
182         SETTING_TRACE_BEGIN;
183         Evas_Object *ctxpopup = data;
184         move_more_ctxpopup(ctxpopup);
185 }
186
187 static void
188 more_ctxpopup_del_cb(void *data, Evas *e, Evas_Object *obj, void *event_info)
189 {
190         SETTING_TRACE_BEGIN;
191         Evas_Object *nf = data;
192         evas_object_event_callback_del_full(nf, EVAS_CALLBACK_RESIZE, naviframe_resize_cb, ctxpopup);
193 }
194
195 static void
196 win_rotation_changed_cb(void *data, Evas_Object *obj, void *event_info)
197 {
198         SETTING_TRACE_BEGIN;
199         Evas_Object *ctxpopup = data;
200         move_more_ctxpopup(ctxpopup);
201 }
202
203 /* Icon + Text (More button style : Naviframe Toolbar) */
204 static void create_ctxpopup_more_button_cb(void *data, Evas_Object *obj, void *event_info)
205 {
206         SETTING_TRACE_BEGIN;
207         SettingNetworkUG *ad = (SettingNetworkUG *) data;
208         Evas_Object *it_obj;
209         Evas_Object *nf = ad->navi_bar;
210         Evas_Object *win;
211         Elm_Object_Item *it;
212
213         if (ctxpopup != NULL) {
214                 evas_object_del(ctxpopup);
215         }
216
217         ctxpopup = elm_ctxpopup_add(nf);
218         elm_ctxpopup_auto_hide_disabled_set(ctxpopup, EINA_TRUE);
219         elm_object_style_set(ctxpopup, "more/default");
220         eext_object_event_callback_add(ctxpopup, EEXT_CALLBACK_BACK, eext_ctxpopup_back_cb, NULL);
221         eext_object_event_callback_add(ctxpopup, EEXT_CALLBACK_MORE, eext_ctxpopup_back_cb, NULL);
222         evas_object_smart_callback_add(ctxpopup, "dismissed", ctxpopup_dismissed_cb, NULL);
223         evas_object_event_callback_add(ctxpopup, EVAS_CALLBACK_DEL, more_ctxpopup_del_cb, nf);
224         evas_object_event_callback_add(nf, EVAS_CALLBACK_RESIZE, naviframe_resize_cb, ctxpopup);
225
226         /* We convince the top widget is a window */
227         win = elm_object_top_widget_get(nf);
228         evas_object_smart_callback_add(win, "rotation,changed", win_rotation_changed_cb, ctxpopup);
229
230         //---------------------------------------------------------------------------------------------
231         elm_ctxpopup_item_append(ctxpopup, _("IDS_ST_BUTTON_CANCEL_ABB"), NULL, setting_network_profile_delete_click_softkey_cancel_cb, ad);
232         elm_ctxpopup_item_append(ctxpopup, _("IDS_ST_BODY_DELETE"), NULL, setting_network_profile_delete_click_softkey_delete_cb, ad);
233         //---------------------------------------------------------------------------------------------
234
235         elm_ctxpopup_direction_priority_set(ctxpopup, ELM_CTXPOPUP_DIRECTION_UP, ELM_CTXPOPUP_DIRECTION_UNKNOWN, ELM_CTXPOPUP_DIRECTION_UNKNOWN, ELM_CTXPOPUP_DIRECTION_UNKNOWN);
236         move_more_ctxpopup(ctxpopup);
237         evas_object_show(ctxpopup);
238 }
239 //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
240
241
242
243 static int setting_network_profile_delete_create(void *cb)
244 {
245         SETTING_TRACE_BEGIN;
246         SettingNetworkUG *ad = (SettingNetworkUG *) cb;
247
248         Evas_Object *scroller = elm_genlist_add(ad->win_main_layout);
249         retvm_if(scroller == NULL, SETTING_DRAW_ERR_FAIL_SCROLLER,
250                  "Cannot set scroller object  as contento of layout");
251         elm_genlist_realization_mode_set(scroller, EINA_TRUE);
252         elm_object_style_set(scroller, "dialogue");
253         elm_genlist_clear(scroller);    /* first to clear list */
254         evas_object_smart_callback_add(scroller, "realized", __gl_realized_cb, NULL);
255         ad->gl_profile_del = scroller;
256
257         ad->navi_it_profile_del_list = setting_push_layout_navi_bar(_(IDS_ST_BODY_DELETE),
258                                                                     NULL,
259                                                                     _(IDS_ST_BODY_DELETE),
260                                                                     _(IDS_ST_BUTTON_CANCEL_ABB),
261                                                                     setting_network_profile_delete_click_softkey_cancel_cb,
262                                                                     setting_network_profile_delete_click_softkey_delete_cb,
263                                                                     setting_network_profile_delete_click_softkey_cancel_cb,
264                                                                     ad, scroller, ad->navi_bar, NULL);
265         /*disable Delete button */
266         Evas_Object *toolbar = elm_object_item_part_content_get(ad->navi_it_profile_del_list, "toolbar");
267         Elm_Object_Item *it = elm_toolbar_last_item_get(toolbar);
268         elm_object_item_disabled_set(it, EINA_TRUE);
269
270         Evas_Object *allbtn = elm_button_add(ad->navi_bar);
271         evas_object_size_hint_weight_set(allbtn, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
272         evas_object_size_hint_align_set(allbtn, EVAS_HINT_FILL, 0.5);
273
274         elm_object_text_set(allbtn, _("IDS_ST_OPT_ALL"));
275         evas_object_smart_callback_add(allbtn, "clicked", setting_network_profile_delete_click_softkey_select_all_cb, ad);
276         evas_object_show(allbtn);
277         elm_object_item_part_content_set(ad->navi_it_profile_del_list, "title_right_btn", allbtn);
278
279         if (ad->navi_it_profile_del_list) {
280                 elm_object_item_domain_text_translatable_set(ad->navi_it_profile_del_list, SETTING_PACKAGE, EINA_TRUE);
281                 elm_naviframe_item_pop_cb_set(ad->navi_it_profile_del_list, setting_network_profile_delete_click_softkey_cancel_cb, ad);
282         }
283
284         // Add ctx popup handler
285         Evas_Object* morebtn = elm_button_add(ad->navi_bar);
286         elm_object_style_set(morebtn, "naviframe/more/default");
287         evas_object_smart_callback_add(morebtn, "clicked", create_ctxpopup_more_button_cb, ad);
288         elm_object_item_part_content_set(ad->navi_it_profile_del_list, "toolbar_more_btn", morebtn);
289
290 #if 0
291         // ADD 'SELECT ALL'
292         ad->data_delete_all = setting_create_Gendial_field_1radio(ad->gl_profile_del, &(ad->itc_1icon_1text_sub),
293                                                                       __screen_timeout_cb, ad,
294                                                                       SWALLOW_Type_1RADIO_RIGHT,
295                                                                       rdg, 4, KeyStr_Backlight_5_MIN_STR,
296                                                                       NULL);
297         if (ad->data_delete_all) {
298                 ad->data_delete_all->userdata = ad;
299                 __BACK_POINTER_SET(ad->data_delete_all);
300         } else {
301                 SETTING_TRACE_ERROR("ad->data_delete_all is NULL");
302         }
303 #endif
304
305         __profile_delete_list_draw(ad);
306         ADD_GL_SEPARATOR(scroller);
307         setting_view_network_profile_delete.is_create = 1;
308
309         return SETTING_RETURN_SUCCESS;
310 }
311
312 static int setting_network_profile_delete_destroy(void *cb)
313 {
314         SETTING_TRACE_BEGIN;
315         SettingNetworkUG *ad = (SettingNetworkUG *) cb;
316         if (!setting_view_network_profile_delete.is_create) {
317                 return SETTING_RETURN_SUCCESS;
318         }
319
320         /* free data */
321         if (ad->profile_del_list != NULL) {
322                 eina_list_free(ad->profile_del_list);
323                 ad->profile_del_list = NULL;
324         }
325         ad->gl_profile_del = NULL;
326         ad->navi_it_profile_del_list = NULL;
327         elm_naviframe_item_pop(ad->navi_bar);
328         setting_view_network_profile_delete.is_create = 0;
329
330         return SETTING_RETURN_SUCCESS;
331 }
332
333 static int setting_network_profile_delete_update(void *cb)
334 {
335         SETTING_TRACE_BEGIN;
336         /* error check */
337         retv_if(cb == NULL, SETTING_GENERAL_ERR_NULL_DATA_PARAMETER);
338         __profile_delete_list_draw(cb);
339         return SETTING_RETURN_SUCCESS;
340 }
341
342 static int setting_network_profile_delete_cleanup(void *cb)
343 {
344         SETTING_TRACE_BEGIN;
345          setting_network_profile_delete_destroy(cb);
346         return SETTING_RETURN_SUCCESS;
347 }
348
349 /* ***************************************************
350  *
351  *general func
352  *
353  ***************************************************/
354 void ___profile_selected(void *data)
355 {
356         SettingNetworkUG *ad = data;
357         retm_if(ad == NULL, "Invalid argument: ad is NULL");
358         Eina_List *check_list = ad->profile_del_list;
359         Setting_GenGroupItem_Data *item_data = NULL;
360         int selnum = 0;
361         while (check_list) {
362                 item_data = (Setting_GenGroupItem_Data *)eina_list_data_get(check_list);
363                 if (NULL == item_data)
364                         continue;
365
366                 SETTING_TRACE("%s :%d", _(item_data->keyStr), item_data->chk_status);
367                 if (item_data->chk_status) {
368                         selnum++;
369                 }
370                 check_list = eina_list_next(check_list);
371         }
372         Elm_Object_Item *navi_it = elm_naviframe_top_item_get(ad->navi_bar);
373         if (navi_it) {
374                 Evas_Object *toolbar = elm_object_item_part_content_get(navi_it, "toolbar");
375                 Elm_Object_Item *it = elm_toolbar_last_item_get(toolbar);
376                 if (selnum != 0) {
377                         char title[MAX_DISPLAY_NAME_LEN_ON_UI + 1] = {0, };
378                         snprintf(title, MAX_DISPLAY_NAME_LEN_ON_UI, _("IDS_ST_HEADER_PD_SELECTED"), selnum);
379                         elm_object_item_text_set(navi_it, _(title));
380                         elm_object_item_disabled_set(it, EINA_FALSE);
381                 } else {
382                         elm_object_item_text_set(navi_it, _("IDS_ST_BODY_DELETE"));
383                         elm_object_item_disabled_set(it, EINA_TRUE);
384                 }
385         }
386 }
387
388 static void
389 setting_network_profile_delete_check_cb(void *data, Evas_Object *obj,
390                                         void *event_info)
391 {
392         retm_if(data == NULL, "Data parameter is NULL");
393         Setting_GenGroupItem_Data *list_item =
394             (Setting_GenGroupItem_Data *) data;
395         list_item->chk_status = elm_check_state_get(obj);       /*  for genlist update status */
396         ___profile_selected(list_item->userdata);
397 }
398
399 static void
400 setting_network_profile_delete_mouse_up_cb(void *data,
401                                            Evas_Object *obj,
402                                            void *event_info)
403 {
404         SETTING_TRACE_BEGIN;
405         /* error check */
406         retm_if(event_info == NULL, "Invalid argument: event info is NULL");
407
408         Elm_Object_Item *item = (Elm_Object_Item *) event_info;
409         elm_genlist_item_selected_set(item, 0);
410         Setting_GenGroupItem_Data *list_item =
411             (Setting_GenGroupItem_Data *) elm_object_item_data_get(item);
412         setting_retm_if(NULL == list_item, "list_item is NULL");
413         SETTING_TRACE("list_item->keyStr:%s", list_item->keyStr);
414
415         setting_update_gl_item_chk_status(list_item, !(list_item->chk_status));
416         ___profile_selected(list_item->userdata);
417 }
418
419 /* ***************************************************
420  *
421  *call back func
422  *
423  ***************************************************/
424 static Eina_Bool setting_network_profile_delete_click_softkey_cancel_cb(void *data, Elm_Object_Item *it)
425 {
426         SETTING_TRACE_BEGIN;
427         /* error check */
428         retvm_if(data == NULL, FALSE, "Data parameter is NULL");
429         SettingNetworkUG *ad = (SettingNetworkUG *) data;
430         setting_view_change(&setting_view_network_profile_delete,
431                             &setting_view_network_con_list, ad);
432
433         if (ctxpopup != NULL) {
434                 evas_object_del(ctxpopup);
435                 ctxpopup = NULL;
436         }
437         return EINA_TRUE;
438 }
439
440 static void __popup_deleted_response_cb(void *data, Evas_Object *obj,
441                                         void *event_info)
442 {
443         retm_if(data == NULL, "Data parameter is NULL");
444
445         SettingNetworkUG *ad = (SettingNetworkUG *) data;
446
447         setting_view_change(&setting_view_network_profile_delete, &setting_view_network_con_list, ad);
448 }
449
450 static void
451 setting_network_profile_delete_click_softkey_delete_cb(void *data,
452                                                        Evas_Object *
453                                                        obj, void
454                                                        *event_info)
455 {
456         SETTING_TRACE_BEGIN;
457         /* error check */
458         retm_if(data == NULL, "Data parameter is NULL");
459
460         SettingNetworkUG *ad = (SettingNetworkUG *) data;
461         Eina_List *check_list = ad->profile_del_list;
462         Setting_GenGroupItem_Data *item_data = NULL;
463         int err;
464         connection_profile_h profile_h;
465         char *name = NULL;
466         char *apn = NULL;
467         char *id = NULL;
468         char speciliztion[MAX_SPECIALIZITION_LEN] = { 0, };
469         char *def_apn = NULL;
470         char *def_name = NULL;
471         char *def_id = NULL;
472         connection_profile_h def_profile = NULL;
473         (void) connection_get_default_cellular_service_profile(ad->connection, ad->profile_service_type, &def_profile);
474         if (def_profile) connection_profile_get_cellular_apn(def_profile, &def_apn);
475         if (def_profile) connection_profile_get_name(def_profile, &def_name);
476         if (def_profile) connection_profile_get_id(def_profile, &def_id);
477         SETTING_TRACE("Default profile:%p, def_apn[%s], def_name[%s]", def_profile, def_apn, def_name);
478
479         bool result = TRUE;
480         Setting_GenGroupItem_Data *first_valid_item = NULL;
481         int ok_cnt = 0;
482         bool is_default = 0;
483         while (check_list) {
484                 item_data = (Setting_GenGroupItem_Data *) eina_list_data_get(check_list);
485                 if (NULL == item_data) {
486                         check_list = eina_list_next(check_list);
487                         continue;
488                 }
489                 SETTING_TRACE("item_data->chk_status:%d", item_data->chk_status);
490                 if (!item_data->chk_status) {
491                         if (!first_valid_item) first_valid_item = item_data;/*intilize at the first time */
492                         check_list = eina_list_next(check_list);
493                         continue;
494                 }
495                 profile_h = (connection_profile_h)(item_data->belongs_to);
496                 connection_profile_get_name(profile_h, &name);
497                 connection_profile_get_cellular_apn(profile_h, &apn);
498                 connection_profile_get_id(profile_h, &id);
499                 if (!safeStrCmp(def_apn, apn) && !safeStrCmp(def_name, name) && !safeStrCmp(def_id, id)) {
500                         is_default = TRUE;
501                 }
502                 if ((err = connection_remove_profile(ad->connection, profile_h)) != CONNECTION_ERROR_NONE) {
503                         SETTING_TRACE_ERROR("*** [ERR] connection_add_profile. err=%d ***", err);
504                         G_FREE(name);
505                         connection_profile_get_name(profile_h, &name);
506                         SETTING_TRACE("name:%s", name);
507                         if (!result) { /*already false */
508                                 g_strlcat(speciliztion, ", ", MAX_SPECIALIZITION_LEN);
509                                 g_strlcat(speciliztion, _(name), MAX_SPECIALIZITION_LEN);
510                         } else {
511                                 g_strlcat(speciliztion, _(name), MAX_SPECIALIZITION_LEN);
512                         }
513                         result = FALSE;
514                 } else {
515                         ok_cnt++;
516                         if (is_default) {
517                                 if (first_valid_item) {
518                                         connection_profile_h first_profile_h = (connection_profile_h)(first_valid_item->belongs_to);
519                                         (void)connection_set_default_cellular_service_profile(ad->connection,
520                                                                                               ad->profile_service_type,
521                                                                                               first_profile_h);
522                                 }
523                         }
524                         /*eina_list_remove(ad->profile_list, profile_h); */
525                 }
526
527                 G_FREE(apn);
528                 G_FREE(name);
529                 G_FREE(id);
530
531                 check_list = eina_list_next(check_list);
532         }
533
534         if (!result) {
535                 g_strlcat(speciliztion, _(": "), MAX_SPECIALIZITION_LEN);
536                 g_strlcat(speciliztion, _("IDS_COM_POP_DELETE_FAILED"), MAX_SPECIALIZITION_LEN);
537                 setting_create_popup(ad, ad->win_get, NULL, _(speciliztion), NULL, 0, false, false, 0);
538
539                 if (ad->navi_it_profile_del_list)
540                         elm_object_item_text_set(ad->navi_it_profile_del_list, _("IDS_ST_BODY_DELETE"));
541
542                 if (ok_cnt) __profile_delete_list_draw(ad);
543
544                 /*disable Delete button */
545                 Evas_Object *toolbar = elm_object_item_part_content_get(ad->navi_it_profile_del_list, "toolbar");
546                 Elm_Object_Item *it = elm_toolbar_last_item_get(toolbar);
547                 elm_object_item_disabled_set(it, EINA_TRUE);
548         }
549
550         if (result) {
551                 setting_create_popup(ad, ad->win_get, NULL, "IDS_ST_BODY_DELETED", __popup_deleted_response_cb, 1, FALSE, FALSE, 0);
552         }
553
554         if (def_profile) {
555                 G_FREE(def_apn);
556                 G_FREE(def_name);
557                 G_FREE(def_id);
558         }
559
560         if (ctxpopup != NULL) {
561                 evas_object_del(ctxpopup);
562                 ctxpopup = NULL;
563         }
564 }
565
566 static void
567 setting_network_profile_delete_click_softkey_select_all_cb(void *data,
568                                                            Evas_Object *obj,
569                                                            void *event_info)
570 {
571         SETTING_TRACE_BEGIN;
572         retm_if(data == NULL, "Data parameter is NULL");
573         SettingNetworkUG *ad = data;
574         Eina_List *check_list = ad->profile_del_list;
575         Setting_GenGroupItem_Data *item_data = NULL;
576         int selnum = 0;
577         int un_selnum = 0;
578         while (check_list) {
579                 item_data = (Setting_GenGroupItem_Data *)eina_list_data_get(check_list);
580                 if (NULL == item_data)
581                         continue;
582
583                 SETTING_TRACE("%s :%d", _(item_data->keyStr), item_data->chk_status);
584                 if (item_data->chk_status) {
585                         selnum++;
586                 } else {
587                         un_selnum++;
588                 }
589                 check_list = eina_list_next(check_list);
590         }
591         SETTING_TRACE("selnum:%d, un_selnum:%d", selnum, un_selnum);
592         if (un_selnum == 0 && selnum != 0) {
593                 /*current all are selected,so it need to unselect all after click the button */
594                 SETTING_TRACE("to unselect all");
595                 check_list = ad->profile_del_list;
596                 un_selnum = 0;
597                 while (check_list) {
598                         item_data = (Setting_GenGroupItem_Data *)eina_list_data_get(check_list);
599                         if (NULL == item_data)
600                                 continue;
601                         setting_update_gl_item_chk_status(item_data, 0);
602                         un_selnum++;
603                         check_list = eina_list_next(check_list);
604                 }
605                 selnum = 0;
606         } else {
607                 /*or else, to select all */
608                 SETTING_TRACE("to select all");
609                 check_list = ad->profile_del_list;
610                 selnum = 0;
611                 while (check_list) {
612                         item_data = (Setting_GenGroupItem_Data *)eina_list_data_get(check_list);
613                         if (NULL == item_data)
614                                 continue;
615
616                         setting_update_gl_item_chk_status(item_data, 1);
617                         selnum++;
618                         check_list = eina_list_next(check_list);
619                 }
620                 un_selnum = 0;
621         }
622
623         if (ad->navi_it_profile_del_list) {
624                 Evas_Object *toolbar = elm_object_item_part_content_get(ad->navi_it_profile_del_list, "toolbar");
625                 Elm_Object_Item *it = elm_toolbar_last_item_get(toolbar);
626                 if (selnum != 0) {
627                         char title[MAX_DISPLAY_NAME_LEN_ON_UI + 1] = {0, };
628                         snprintf(title, MAX_DISPLAY_NAME_LEN_ON_UI, _("IDS_ST_HEADER_PD_SELECTED"), selnum);
629                         elm_object_item_text_set(ad->navi_it_profile_del_list, _(title));
630                         elm_object_item_disabled_set(it, EINA_FALSE);
631                 } else {
632                         elm_object_item_text_set(ad->navi_it_profile_del_list, _("IDS_ST_BODY_DELETE"));
633                         elm_object_item_disabled_set(it, EINA_TRUE);
634                 }
635         }
636         return;
637 }
638
639