[TSAM-11678] Do not show ctx popup in connected device naviframe
[apps/native/ug-mobile-ap.git] / src / mh_popup.c
1 /*
2 * ug-mobile-ap
3 *
4 * Copyright 2012  Samsung Electronics Co., Ltd
5
6 * Licensed under the Flora License, Version 1.0 (the "License");
7 * you may not use this file except in compliance with the License.
8 * You may obtain a copy of the License at
9
10 * http://www.tizenopensource.org/license
11
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
17 *
18 */
19
20 #include <efl_extension.h>
21 #include <app_control_internal.h>
22 #include <bundle.h>
23 #include <bundle_internal.h>
24 #include <aul.h>
25
26 #include "mh_common_utility.h"
27 #include "mobile_hotspot.h"
28 #include "mh_popup.h"
29 #include "mh_string.h"
30
31 #define MAX_BUF_SIZE    (256u)
32 #define NETPOPUP                "net.netpopup"
33 #define NETWORK_SETTING_APP     "org.tizen.setting-network"
34
35 static mh_popup_type_e popup_type = MH_POPUP_NONE;
36 static Evas_Object *popup_content = NULL;
37 static char *popup_string = NULL;
38
39 static void __launch_network_app(void)
40 {
41         int ret = APP_CONTROL_ERROR_NONE;
42         app_control_h app_control;
43
44         ret = app_control_create(&app_control);
45         if (ret != APP_CONTROL_ERROR_NONE) {
46                 ERR("app_control_create failed");
47                 return;
48         }
49         app_control_set_operation(app_control, APP_CONTROL_OPERATION_DEFAULT);
50         app_control_set_launch_mode(app_control, APP_CONTROL_LAUNCH_MODE_GROUP);
51         app_control_set_app_id(app_control, NETWORK_SETTING_APP);
52
53         ret = app_control_send_launch_request(app_control, NULL, NULL);
54         if (ret == APP_CONTROL_ERROR_NONE)
55                 DBG("Launch network ug successful");
56         else
57                 ERR("Fail to launch network ug");
58
59         app_control_destroy(app_control);
60 }
61
62 static void __handle_popup_resp(void *data, bool response)
63 {
64         __MOBILE_AP_FUNC_ENTER__;
65
66         if (data == NULL) {
67                 ERR("The param is NULL\n");
68                 return;
69         }
70
71         mh_appdata_t *ad = (mh_appdata_t *)data;
72         int ret = 0;
73         Eina_Bool state = 0;
74
75         if (ad->popup_checkbox) {
76                 state = elm_check_state_get(ad->popup_checkbox);
77                 evas_object_del(ad->popup_checkbox);
78                 ad->popup_checkbox = NULL;
79                 DBG("Checkbox status is = %d\n", state);
80         }
81         if (ad->popup) {
82                 evas_object_del(ad->popup);
83                 ad->popup = NULL;
84         }
85
86         if (response == true) {
87                 switch (popup_type) {
88                 case MH_POPUP_WIFI_ON_CHECKBOX:
89                         if (state)
90                                 _set_checkbox_status(TETHERING_TYPE_WIFI, 1);
91
92                         ad->is_wifi_teth_enabling = false;
93                         ret = tethering_enable(ad->handle, TETHERING_TYPE_WIFI);
94                         if (ret != TETHERING_ERROR_NONE) {
95                                 ERR("wifi tethering on is failed : %d\n", ret);
96                                 _update_wifi_item(ad, MH_STATE_NONE);
97                         }
98                         _wifi_tethering_checkbox_popup_status_set(false);
99                         _send_signal_qp(QP_SIGNAL_PROGRESS_ON);
100                         break;
101
102                 case MH_POPUP_BT_ON_CHECKBOX:
103                         if (state)
104                                 _set_checkbox_status(TETHERING_TYPE_BT, 1);
105
106                         ad->is_bt_teth_enabling = false;
107                         ret = tethering_enable(ad->handle, TETHERING_TYPE_BT);
108                         if (ret != TETHERING_ERROR_NONE) {
109                                 ERR("Error enable bt tethering : %d\n", ret);
110                                 _update_bt_item(ad, MH_STATE_NONE);
111                         }
112                         break;
113
114                 case MH_POPUP_USB_ON_CHECKBOX:
115                         if (state)
116                                 _set_checkbox_status(TETHERING_TYPE_USB, 1);
117
118                         if (_get_vconf_usb_state() == VCONFKEY_SYSMAN_USB_DISCONNECTED) {
119                                 _update_tethering_item(ad, MH_STATE_NONE);
120                                 break;
121                         }
122                         ad->is_usb_teth_enabling = false;
123                         ret = tethering_enable(ad->handle, TETHERING_TYPE_USB);
124                         if (ret != TETHERING_ERROR_NONE) {
125                                 ERR("Error enable usb tethering : %d\n", ret);
126                                 _update_usb_item(ad, MH_STATE_NONE);
127                         }
128                         break;
129
130                 case MH_POPUP_WIFI_OFF:
131                         ret = tethering_disable(ad->handle, TETHERING_TYPE_WIFI);
132                         if (ret != TETHERING_ERROR_NONE) {
133                                 ERR("wifi tethering off is failed : %d\n", ret);
134                                 _update_wifi_item(ad, MH_STATE_NONE);
135                         }
136                         _send_signal_qp(QP_SIGNAL_PROGRESS_OFF);
137                         break;
138
139                 case MH_POPUP_MOBILE_DATA_OFF:
140                         __launch_network_app();
141                         _update_tethering_enabling_item(ad, ad->type, MH_STATE_NONE);
142                         break;
143
144                 default:
145                         ERR("Unknown popup_type : %d\n", popup_type);
146                         break;
147                 }
148         } else {
149                 switch (popup_type) {
150                 case MH_POPUP_WIFI_ON_CHECKBOX:
151                         _update_tethering_enabling_item(ad, TETHERING_TYPE_WIFI, MH_STATE_NONE);
152                         _send_signal_qp(QP_SIGNAL_PROGRESS_RESET);
153                         _wifi_tethering_checkbox_popup_status_set(false);
154                         break;
155
156                 case MH_POPUP_BT_ON_CHECKBOX:
157                         _update_tethering_enabling_item(ad, TETHERING_TYPE_BT, MH_STATE_NONE);
158                         break;
159
160                 case MH_POPUP_USB_ON_CHECKBOX:
161                         _update_tethering_enabling_item(ad, TETHERING_TYPE_USB, MH_STATE_NONE);
162                         break;
163
164                 case MH_POPUP_WIFI_AP_OFF:
165                         if (ad->setup.genlist)
166                                 elm_naviframe_item_pop(ad->naviframe);
167                         elm_naviframe_item_pop(ad->naviframe);
168                         break;
169
170                 case MH_POPUP_WIFI_OFF:
171                         _update_tethering_enabling_item(ad, TETHERING_TYPE_WIFI, MH_STATE_NONE);
172                         _send_signal_qp(QP_SIGNAL_PROGRESS_RESET);
173                         break;
174
175                 case MH_POPUP_MOBILE_DATA_OFF:
176                         _update_tethering_enabling_item(ad, ad->type, MH_STATE_NONE);
177                         break;
178                 default:
179                         ERR("Unknown popup_type : %d\n", popup_type);
180                         break;
181                 }
182         }
183
184         __MOBILE_AP_FUNC_EXIT__;
185 }
186
187 void _teth_on(mh_appdata_t *ad)
188 {
189         __handle_popup_resp(ad, true);
190 }
191
192 static void __popup_yes_btn_clicked_cb(void *data, Evas_Object *obj, void *event_info)
193 {
194         if (data == NULL || obj == NULL) {
195                 ERR("The param is NULL\n");
196                 return;
197         }
198
199         __handle_popup_resp(data, true);
200 }
201
202 static void __popup_no_btn_clicked_cb(void *data, Evas_Object *obj, void *event_info)
203 {
204         if (data == NULL || obj == NULL) {
205                 ERR("The param is NULL\n");
206                 return;
207         }
208
209         __handle_popup_resp(data, false);
210 }
211
212 static void __popup_no_btn_mouse_event_cb(void *data, Evas *evas, Evas_Object *obj, void *event_info)
213 {
214         if (data == NULL || obj == NULL) {
215                 ERR("The param is NULL\n");
216                 return;
217         }
218
219         Evas_Event_Mouse_Up *ev = event_info;
220
221         if (ev->button == 3)
222                 __handle_popup_resp(data, false);
223 }
224
225 static void __popup_block_clicked_cb(void *data, Evas_Object *obj, void *event_info)
226 {
227         if (obj == NULL) {
228                 ERR("The param is NULL\n");
229                 return;
230         }
231
232         elm_popup_dismiss(obj);
233 }
234
235 static void __popup_hide_finished_cb(void *data, Evas_Object *obj, void *event_info)
236 {
237         if (data == NULL) {
238                 ERR("The param is NULL\n");
239                 return;
240         }
241
242         __handle_popup_resp(data, false);
243 }
244
245 void _prepare_popup_with_content(int type, Evas_Object *obj)
246 {
247         __MOBILE_AP_FUNC_ENTER__;
248
249         if (obj == NULL) {
250                 ERR("param is NULL\n");
251                 return;
252         }
253
254         popup_type = type;
255
256         if (popup_content)
257                 evas_object_del(popup_content);
258         popup_content = obj;
259
260         if (popup_string) {
261                 free(popup_string);
262                 popup_string = NULL;
263         }
264
265         __MOBILE_AP_FUNC_EXIT__;
266 }
267
268 void _prepare_popup(int type, const char *str)
269 {
270         __MOBILE_AP_FUNC_ENTER__;
271
272         if (str == NULL) {
273                 ERR("param is NULL\n");
274                 return;
275         }
276         popup_type = type;
277
278         popup_content = NULL;
279
280         if (popup_string)
281                 free(popup_string);
282
283         popup_string = strndup(str, MH_LABEL_LENGTH_MAX);
284         if (popup_string == NULL)
285                 ERR("strndup is failed\n");
286
287         __MOBILE_AP_FUNC_EXIT__;
288 }
289
290 void _prepare_popup_type(int type)
291 {
292         popup_type = type;
293 }
294
295 static void __language_changed_cb(void *data, Evas_Object *obj, void *event_info)
296 {
297         __MOBILE_AP_FUNC_ENTER__;
298
299         mh_appdata_t *ad = (mh_appdata_t *)data;
300         Evas_Object *label = NULL;
301         bool wifi_state = false;
302         char *fmt = NULL;
303         char str[MH_LABEL_LENGTH_MAX];
304
305         if (ad->type < TETHERING_TYPE_USB || ad->type > TETHERING_TYPE_BT) {
306                 ERR("Invalid Tethering type\n");
307                 return;
308         }
309
310         switch (ad->type) {
311         case TETHERING_TYPE_WIFI:
312                 wifi_is_activated(&wifi_state);
313                 _set_vconf_prev_wifi_state(wifi_state);
314                 if (wifi_state == true || _is_wifi_direct_on() == true)
315                         fmt = STR_TETH_ON_DESC_1;
316                 else
317                         fmt = STR_TETH_ON_DESC_2;
318
319                 snprintf(str, MH_LABEL_LENGTH_MAX, fmt, TETHERING_WIFI_MAX_CONNECTED_STA);
320                 break;
321
322         case TETHERING_TYPE_BT:
323                 fmt = STR_TETH_ON_DESC_2;
324                 snprintf(str, MH_LABEL_LENGTH_MAX, fmt, TETHERING_BT_MAX_CONNECTED_STA);
325                 break;
326
327         case TETHERING_TYPE_USB:
328                 snprintf(str, MH_LABEL_LENGTH_MAX, STR_TETH_ON_DESC_3);
329                 break;
330         default:
331                 break;
332         }
333
334         label = elm_label_add(ad->main.check_popup_ly);
335         elm_object_style_set(label, "popup/default");
336         elm_label_line_wrap_set(label, ELM_WRAP_MIXED);
337         elm_object_text_set(label, str);
338         evas_object_size_hint_weight_set(label, EVAS_HINT_EXPAND, 0.0);
339         evas_object_size_hint_align_set(label, EVAS_HINT_FILL, EVAS_HINT_FILL);
340         evas_object_show(label);
341         elm_object_part_content_set(ad->main.check_popup_ly, "elm.swallow.content", label);
342
343         __MOBILE_AP_FUNC_EXIT__;
344 }
345
346 static void __popup_with_checkbox(mh_appdata_t *ad)
347 {
348         __MOBILE_AP_FUNC_ENTER__;
349
350         Evas_Object *popup = NULL;
351         Evas_Object *yes_button = NULL;
352         Evas_Object *cancel_button = NULL;
353         Evas_Object *layout = NULL;
354         Evas_Object *label = NULL;
355         Evas_Object *check = NULL;
356
357         popup = elm_popup_add(ad->win);
358         elm_popup_align_set(popup, ELM_NOTIFY_ALIGN_FILL, 1.0);
359         evas_object_size_hint_weight_set(popup, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
360         ad->popup = popup;
361         switch (ad->type) {
362         case TETHERING_TYPE_WIFI:
363                 elm_object_domain_translatable_part_text_set(popup, "title,text", PACKAGE,
364                                 "IDS_MOBILEAP_MBODY_WI_FI_TETHERING");
365                 break;
366         case TETHERING_TYPE_BT:
367                 elm_object_domain_translatable_part_text_set(popup, "title,text", PACKAGE,
368                                 "IDS_MOBILEAP_BODY_BLUETOOTH_TETHERING");
369                 break;
370         case TETHERING_TYPE_USB:
371                 elm_object_domain_translatable_part_text_set(popup, "title,text", PACKAGE,
372                                 "IDS_MOBILEAP_MBODY_USB_TETHERING");
373                 break;
374         default:
375                 break;
376         }
377
378         /* layout */
379         layout = elm_layout_add(popup);
380         elm_layout_file_set(layout, FILE_PATH_OF_EDC, "popup_checkview_layout");
381         evas_object_size_hint_weight_set(layout, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
382         evas_object_size_hint_align_set(layout, EVAS_HINT_FILL, 1.0);
383         ad->main.check_popup_ly = layout;
384
385         /* check */
386         check = elm_check_add(popup);
387         elm_object_style_set(check, "popup");
388         elm_object_domain_translatable_text_set(check, PACKAGE, STR_NO_SHOW_AGAIN);
389         evas_object_size_hint_align_set(check, EVAS_HINT_FILL, EVAS_HINT_FILL);
390         evas_object_size_hint_weight_set(check, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
391         elm_object_part_content_set(layout, "elm.swallow.end", check);
392         ad->popup_checkbox = check;
393
394         /* label */
395         label = elm_label_add(layout);
396         elm_object_style_set(label, "popup/default");
397         elm_label_line_wrap_set(label, ELM_WRAP_MIXED);
398         elm_object_text_set(label, popup_string);
399         evas_object_size_hint_weight_set(label, EVAS_HINT_EXPAND, 0.0);
400         evas_object_size_hint_align_set(label, EVAS_HINT_FILL, EVAS_HINT_FILL);
401         evas_object_show(label);
402         elm_object_part_content_set(layout, "elm.swallow.content", label);
403
404         cancel_button = _create_button(popup,  "IDS_BR_SK_CANCEL",
405                                 "button1", __popup_no_btn_clicked_cb, ad);
406         yes_button = _create_button(popup, "IDS_ST_BUTTON_ENABLE_M_USE",
407                                 "button2", __popup_yes_btn_clicked_cb, ad);
408
409         evas_object_smart_callback_add(popup, "language,changed", __language_changed_cb, ad);
410
411         eext_object_event_callback_add(popup, EEXT_CALLBACK_BACK,
412                         __popup_no_btn_clicked_cb, (void *)ad);
413
414         evas_object_event_callback_add(popup, EVAS_CALLBACK_MOUSE_UP,
415                         __popup_no_btn_mouse_event_cb, (void *)ad);
416         evas_object_smart_callback_add(popup, "block,clicked",
417                         __popup_block_clicked_cb, NULL);
418         evas_object_smart_callback_add(popup, "dismissed",
419                         __popup_hide_finished_cb, ad);
420
421
422         if (check && yes_button) {
423                 elm_object_focus_next_object_set(check, yes_button, ELM_FOCUS_PREVIOUS);
424                 elm_object_focus_next_object_set(yes_button, check, ELM_FOCUS_NEXT);
425                 if (cancel_button) {
426                         elm_object_focus_next_object_set(cancel_button, check, ELM_FOCUS_PREVIOUS);
427                         elm_object_focus_next_object_set(check , cancel_button, ELM_FOCUS_NEXT);
428                 }
429         }
430
431         elm_object_content_set(popup, layout);
432         evas_object_show(popup);
433         ad->popup = popup;
434
435         __MOBILE_AP_FUNC_EXIT__;
436 }
437
438 Eina_Bool _create_popup(mh_appdata_t *ad)
439 {
440         __MOBILE_AP_FUNC_ENTER__;
441
442         Evas_Object *popup = NULL;
443         Evas_Object *cancel_button = NULL;
444         Evas_Object *yes_button = NULL;
445
446         if (ad == NULL) {
447                 ERR("The param is NULL\n");
448                 if (popup_string) {
449                         free(popup_string);
450                         popup_string = NULL;
451                 }
452                 popup_content = NULL;
453
454                 return EINA_FALSE;
455         }
456
457         if (ad->popup != NULL) {
458                 evas_object_del(ad->popup);
459                 ad->popup = NULL;
460         }
461         ad->popup_checkbox = NULL;
462         DBG("popup type : %d", popup_type);
463
464         switch (popup_type) {
465         case MH_POPUP_WIFI_ON_CHECKBOX:
466         case MH_POPUP_BT_ON_CHECKBOX:
467         case MH_POPUP_USB_ON_CHECKBOX:
468                 __popup_with_checkbox(ad);
469                 break;
470
471         case MH_POPUP_WIFI_OFF:
472                 popup = elm_popup_add(ad->win);
473                 ad->popup = popup;
474
475                 elm_object_domain_translatable_part_text_set(popup, "title,text", PACKAGE,
476                                 "IDS_MOBILEAP_MBODY_WI_FI_TETHERING");
477
478                 evas_object_size_hint_weight_set(popup,
479                                 EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
480
481                 if (popup_content == NULL)
482                         elm_object_domain_translatable_text_set(popup, PACKAGE, popup_string);
483                 else
484                         elm_object_content_set(popup, popup_content);
485
486                 cancel_button = _create_button(popup, STR_CANCEL,
487                                 "button1", __popup_no_btn_clicked_cb, ad);
488                 yes_button = _create_button(popup, STR_TURN_OFF,
489                                 "button2", __popup_yes_btn_clicked_cb, ad);
490
491                 eext_object_event_callback_add(popup, EEXT_CALLBACK_BACK,
492                                 __popup_no_btn_clicked_cb, (void *)ad);
493                 evas_object_event_callback_add(popup, EVAS_CALLBACK_MOUSE_UP,
494                                 __popup_no_btn_mouse_event_cb, (void *)ad);
495                 evas_object_smart_callback_add(popup, "block,clicked",
496                                 __popup_block_clicked_cb, NULL);
497                 evas_object_smart_callback_add(popup, "dismissed",
498                                 __popup_hide_finished_cb, ad);
499
500                 evas_object_show(popup);
501                 break;
502
503         case MH_POPUP_TETH_ENABLING_FAILED:
504         case MH_POPUP_NO_SIM:
505         case MH_POPUP_FLIGHT_MODE:
506         case MH_POPUP_NETWORK_OUT_OF_RANGE:
507                 popup = elm_popup_add(ad->win);
508                 ad->popup = popup;
509                 evas_object_size_hint_weight_set(popup, EVAS_HINT_EXPAND,
510                                 EVAS_HINT_EXPAND);
511
512                 if (popup_content == NULL)
513                         elm_object_domain_translatable_text_set(popup, PACKAGE, popup_string);
514                 else
515                         elm_object_content_set(popup, popup_content);
516                 elm_object_domain_translatable_part_text_set(popup, "title,text", PACKAGE,
517                                 STR_NO_NET_CONN);
518                 cancel_button = _create_button(popup,  STR_CANCEL,
519                                 "button1", __popup_no_btn_clicked_cb, ad);
520
521                 eext_object_event_callback_add(popup, EEXT_CALLBACK_BACK,
522                                 __popup_no_btn_clicked_cb, (void *)ad);
523                 evas_object_event_callback_add(popup, EVAS_CALLBACK_MOUSE_UP,
524                                 __popup_no_btn_mouse_event_cb, (void *)ad);
525                 evas_object_smart_callback_add(popup, "block,clicked",
526                                 __popup_block_clicked_cb, NULL);
527                 evas_object_smart_callback_add(popup, "dismissed",
528                                 __popup_hide_finished_cb, ad);
529
530                 evas_object_show(popup);
531                 break;
532
533         case MH_POPUP_MOBILE_DATA_OFF:
534                 popup = elm_popup_add(ad->win);
535                 ad->popup = popup;
536                 evas_object_size_hint_weight_set(popup, EVAS_HINT_EXPAND,
537                                 EVAS_HINT_EXPAND);
538
539                 if (popup_content == NULL)
540                         elm_object_domain_translatable_text_set(popup, PACKAGE, popup_string);
541                 else
542                         elm_object_content_set(popup, popup_content);
543                 elm_object_domain_translatable_part_text_set(popup, "title,text", PACKAGE,
544                                 STR_NO_NET_CONN);
545                 cancel_button = _create_button(popup,  STR_CANCEL,
546                                 "button1", __popup_no_btn_clicked_cb, ad);
547                 yes_button = _create_button(popup, STR_SETTING,
548                                 "button2", __popup_yes_btn_clicked_cb, ad);
549
550                 eext_object_event_callback_add(popup, EEXT_CALLBACK_BACK,
551                                 __popup_no_btn_clicked_cb, (void *)ad);
552                 evas_object_event_callback_add(popup, EVAS_CALLBACK_MOUSE_UP,
553                                 __popup_no_btn_mouse_event_cb, (void *)ad);
554                 evas_object_smart_callback_add(popup, "block,clicked",
555                                 __popup_block_clicked_cb, NULL);
556                 evas_object_smart_callback_add(popup, "dismissed",
557                                 __popup_hide_finished_cb, ad);
558
559                 evas_object_show(popup);
560                 break;
561
562         case MH_POPUP_WIFI_AP_OFF:
563                 popup = elm_popup_add(ad->win);
564                 ad->popup = popup;
565                 evas_object_size_hint_weight_set(popup,
566                                 EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
567
568                 elm_object_domain_translatable_part_text_set(popup, "title,text", PACKAGE,
569                                 STR_TETH);
570                 if (popup_content == NULL)
571                         elm_object_domain_translatable_text_set(popup, PACKAGE, popup_string);
572                 else
573                         elm_object_content_set(popup, popup_content);
574
575                 cancel_button = _create_button(popup,  STR_CANCEL,
576                                 "button1", __popup_no_btn_clicked_cb, ad);
577                 yes_button = _create_button(popup, STR_ENABLE,
578                                 "button2", __popup_yes_btn_clicked_cb, ad);
579
580                 eext_object_event_callback_add(popup, EEXT_CALLBACK_BACK,
581                                 __popup_no_btn_clicked_cb, (void *)ad);
582                 evas_object_event_callback_add(popup, EVAS_CALLBACK_MOUSE_UP,
583                                 __popup_no_btn_mouse_event_cb, (void *)ad);
584
585                 evas_object_show(popup);
586                 break;
587
588         default:
589                 ERR("Unknown popup_type : %d\n", popup_type);
590                 break;
591         }
592
593         if (cancel_button && yes_button) {
594                 elm_object_focus_next_object_set(cancel_button, yes_button, ELM_FOCUS_PREVIOUS);
595                 elm_object_focus_next_object_set(yes_button, cancel_button, ELM_FOCUS_NEXT);
596         }
597
598         if (popup_string) {
599                 free(popup_string);
600                 popup_string = NULL;
601         }
602         popup_content = NULL;
603
604         __MOBILE_AP_FUNC_EXIT__;
605
606         return EINA_TRUE;
607 }
608
609 void _destroy_popup(mh_appdata_t *ad)
610 {
611         __MOBILE_AP_FUNC_ENTER__;
612
613         if (ad == NULL) {
614                 ERR("ad is null\n");
615                 return;
616         }
617
618         if (ad->popup) {
619                 evas_object_del(ad->popup);
620                 ad->popup = NULL;
621         }
622         ad->popup_checkbox = NULL;
623
624         if (popup_string) {
625                 free(popup_string);
626                 popup_string = NULL;
627         }
628         popup_content = NULL;
629         popup_type = MH_POPUP_NONE;
630
631         __MOBILE_AP_FUNC_EXIT__;
632
633         return;
634 }
635
636 void _create_security_restriction_noti(tethering_type_e type)
637 {
638         bundle *b = NULL;
639         char restricted_type[MAX_BUF_SIZE] = {0, };
640         int ret;
641
642         switch (type) {
643         case TETHERING_TYPE_WIFI:
644                 g_strlcpy(restricted_type, "wifi tethering", MAX_BUF_SIZE - 1);
645                 break;
646         case TETHERING_TYPE_USB:
647                 g_strlcpy(restricted_type, "usb tethering", MAX_BUF_SIZE - 1);
648                 break;
649         case TETHERING_TYPE_BT:
650                 g_strlcpy(restricted_type, "bt tethering", MAX_BUF_SIZE - 1);
651                 break;
652         default:
653                 ERR("Invalid type.\n");
654                 return;
655         }
656         b = bundle_create();
657
658         bundle_add(b, "_SYSPOPUP_TYPE_", "toast_popup");
659         bundle_add(b, "_SYSPOPUP_CONTENT_", "security restriction");
660         bundle_add(b, "_RESTRICTED_TYPE_", restricted_type);
661
662         DBG("Launch security restriction alert network popup");
663         ret = aul_launch_app(NETPOPUP, b);
664         if (ret < 0)
665                 ERR("Fail to launch syspopup");
666
667         bundle_free(b);
668         return;
669 }