4 * Copyright 2012 Samsung Electronics Co., Ltd
6 * Licensed under the Flora License, Version 1.1 (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
10 * http://www.tizenopensource.org/license
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.
26 #include <notification.h>
27 #include <notification_list.h>
28 #include <notification_text_domain.h>
30 #include <app_control.h>
33 #include <vconf-keys.h>
35 #include <dbus/dbus.h>
36 #include <efl_extension.h>
37 #include <tzplatform_config.h>
38 #include <vpn_service.h>
39 #include <vpn_service_internal.h>
41 #include <stc_internal.h>
43 #include "net-popup.h"
44 #include "net-popup-vpn.h"
45 #include "net-popup-strings.h"
47 #define NET_WIFIQS_APPID "net.wifi-qs"
48 #define DATA_USAGE_APPID "org.tizen.setting"
49 #define WIFI_EFL_UG "wifi-efl-ug"
51 #define LOCALEDIR "/usr/share/locale"
52 #define NETPOPUP_EDJ tzplatform_mkpath(TZ_SYS_RO_UG, "/res/edje/net-popup/netpopup-custom.edj")
53 #define QP_PRELOAD_NOTI_ICON_PATH tzplatform_mkpath(TZ_SYS_RO_APP, "/org.tizen.quickpanel/shared/res/noti_icons/Wi-Fi")
55 #define STC_NOTI_DATA_USAGE_ICON_PATH "/usr/share/icons/"
56 #define STC_NOTI_DATA_USAGE_ICON_NAME "stc_noti_datausage.png"
58 #define NETCONFIG_NOTIFICATION_WIFI_ICON \
59 tzplatform_mkpath(TZ_SYS_RO_ICONS, "/noti_wifi_in_range.png")
60 #define NETCONFIG_NOTIFICATION_WIFI_ICON_LITE \
61 tzplatform_mkpath(TZ_SYS_RO_ICONS, "/noti_wifi_in_range_ongoing.png")
62 #define NETCONFIG_NOTIFICATION_WIFI_CAPTIVE_ICON \
63 tzplatform_mkpath(TZ_SYS_RO_ICONS, "/B03_notify_Wi-fi_range.png")
64 #define NETCONFIG_NOTIFICATION_WIFI_IN_RANGE_ICON \
65 tzplatform_mkpath(TZ_SYS_RO_ICONS, "/Q02_Notification_wifi_in_range.png")
66 #define NETCONFIG_NOTIFICATION_WIFI_IN_RANGE_ICON_LITE \
67 tzplatform_mkpath(TZ_SYS_RO_ICONS, "/noti_wifi_in_range.png")
68 #define NETCONFIG_NOTIFICATION_WIFI_FOUND_TITLE \
69 dgettext(PACKAGE, "IDS_COM_BODY_WI_FI_NETWORKS_AVAILABLE")
70 #define NETCONFIG_NOTIFICATION_WIFI_FOUND_CONTENT \
71 dgettext(PACKAGE, "IDS_WIFI_SBODY_TAP_HERE_TO_CONNECT")
72 #define NETCONFIG_NOTIFICATION_WIFI_PORTAL_TITLE \
73 dgettext(PACKAGE, "IDS_WIFI_HEADER_SIGN_IN_TO_WI_FI_NETWORK_ABB")
74 #define NETCONFIG_NOTIFICATION_IP_CONFLICT_TITLE \
75 dgettext(PACKAGE, "IDS_IP_CONFLICT")
76 #define NETCONFIG_NOTIFICATION_WIFI_PORTAL_CONTENT "\"%s\""
78 #define STC_NOTIFICATION_WARNING_TITLE \
79 dgettext(PACKAGE, "IDS_COM_BODY_DATA_USAGE_WARNING")
80 #define STC_NOTIFICATION_WARNING_CONTENT \
81 dgettext(PACKAGE, "IDS_SM_SBODY_TAP_HERE_TO_VIEW_YOUR_DATA_USAGE_ABB")
82 #define STC_NOTIFICATION_RESTRICTION_OK_TITLE \
83 dgettext(PACKAGE, "IDS_SM_HEADER_MOBILE_DATA_TURNED_OFF_ABB2")
84 #define STC_NOTIFICATION_RESTRICTION_OK_CONTENT \
85 dgettext(PACKAGE, "IDS_SM_SBODY_TAP_HERE_TO_TURN_IT_ON_AGAIN_ABB")
86 #define STC_NOTIFICATION_RESTRICTION_ON_TITLE \
87 dgettext(PACKAGE, "IDS_SM_TMBODY_MOBILE_DATA_LIMIT_EXCEEDED_ABB")
89 #define STC_TOTAL_DATACALL "TOTAL_DATACALL"
90 #define STC_TOTAL_WIFI "TOTAL_WIFI"
91 #define STC_TOTAL_BLUETOOTH "TOTAL_BLUETOOTH"
93 #define USER_RESP_LEN 30
94 #define ICON_PATH_LEN 128
95 #define RESP_REMAIN_CONNECTED "RESP_REMAIN_CONNECTED"
96 #define RESP_WIFI_TETHERING_OFF "RESP_TETHERING_TYPE_WIFI_OFF"
97 #define RESP_WIFI_AP_TETHERING_OFF "RESP_TETHERING_TYPE_WIFI_AP_OFF"
98 #define RESP_TETHERING_ON "RESP_TETHERING_ON"
99 #define CAPTIVE_PORTAL_LOGIN "Login required to access Internet"
100 #define CAPTIVE_PORTAL_LOGIN_ERROR "Login not completed. Disconnected active Wifi"
102 static Ecore_Event_Handler *ecore_event_evas_handler;
103 static Ecore_Event_Handler *ecore_event_evas_quick_panel_handler;
105 #define BUF_SIZE 1024
106 long sizes[] = {1073741824, 1048576, 1024, 0};
107 char *units[] = {"GB", "MB", "KB", "B"};
109 static app_control_h g_req_handle = NULL;
110 static char *resp_popup_mode = NULL;
112 static GDBusConnection *conn = NULL;
113 static GDBusProxy *proxy = NULL;
115 /* vpn-service popup */
116 static char *iface_name = NULL;
118 /* data roaming popup */
119 static Eina_Bool turn_on_roaming = FALSE;
120 static Eina_Bool do_not_show_popup = FALSE;
122 /* data usage popup */
123 static char *data_usage_app_id = NULL;
124 static char *data_usage_iftype = NULL;
126 static int __net_popup_show_notification(app_control_h request, void *data);
127 static int __toast_popup_show(app_control_h request, void *data);
128 static int __net_popup_show_popup(app_control_h request, void *data);
129 static void __net_popup_show_warning_noti(app_control_h request, void *data);
130 static void __net_popup_show_restriction_noti(app_control_h request, void *data);
131 static void __net_popup_add_found_ap_noti(void);
132 static void __net_popup_del_found_ap_noti(void);
133 static void __net_popup_add_portal_noti(app_control_h request);
134 static void __net_popup_del_portal_noti(void);
135 static void __net_popup_show_popup_with_user_resp(app_control_h request, void *data);
136 static void __net_popup_show_vpn_popup(app_control_h request, void *data);
137 static int _net_popup_send_user_resp(char *resp, Eina_Bool state);
138 static int __net_popup_show_network_error_popup(app_control_h request, void *data);
139 static void __net_popup_add_ip_conflict_noti(app_control_h request);
140 static void __net_popup_del_ip_conflict_noti(void);
142 GDBusProxy *__net_popup_init_dbus(void)
144 log_print(NET_POPUP, "__net_popup_init_dbus()\n");
148 conn = g_bus_get_sync(G_BUS_TYPE_SYSTEM, NULL, &err);
154 proxy = g_dbus_proxy_new_sync(conn, G_DBUS_PROXY_FLAGS_NONE, NULL,
161 g_object_unref(conn);
168 void __net_popup_deinit_dbus(void)
170 log_print(NET_POPUP, "__net_popup_deinit_dbus()\n");
173 g_object_unref(proxy);
178 g_object_unref(conn);
185 int __net_popup_send_dbus_msg(const char *resp)
187 log_print(NET_POPUP, "__net_popup_send_dbus_msg()\n");
189 if (conn == NULL || resp == NULL)
192 GDBusConnection *gconn = NULL;
193 GVariant *msg = NULL;
194 char *module = "wifi";
197 gconn = g_bus_get_sync(DBUS_BUS_SYSTEM, NULL, &err);
204 msg = g_variant_new("(ss)", module, resp);
205 g_dbus_connection_emit_signal(gconn, NULL, "/Org/Tizen/Quickpanel",
206 "org.tizen.quickpanel", "ACTIVITY", msg, &err);
212 g_variant_unref(msg);
215 g_object_unref(gconn);
221 void __net_popup_send_data_usage_msg(const char *app_id,
224 log_print(NET_POPUP, "__net_popup_send_data_usage_msg()\n");
226 int ret = STC_ERROR_NONE;
228 stc_restriction_rule_h rule = NULL;
230 ret = stc_initialize(&stc);
231 if (ret != STC_ERROR_NONE) {
232 log_print(NET_POPUP, "Failed to get operation ret= %d\n", ret);
236 ret = stc_restriction_rule_create(stc, &rule);
237 if (ret != STC_ERROR_NONE) {
238 log_print(NET_POPUP, "Failed to create restriction rule ret= %d\n", ret);
242 ret = stc_restriction_rule_set_app_id(rule, app_id);
243 if (ret != STC_ERROR_NONE) {
244 log_print(NET_POPUP, "Failed to set application ID ret= %d\n", ret);
248 ret = stc_restriction_rule_set_iface_type(rule, iftype[0] - '0');
249 if (ret != STC_ERROR_NONE) {
250 log_print(NET_POPUP, "Failed to set interface type ret= %d\n", ret);
254 ret = stc_unset_restriction(stc, rule);
255 if (ret != STC_ERROR_NONE) {
256 log_print(NET_POPUP, "Failed to unset restriction ret= %d\n", ret);
260 log_print(NET_POPUP, "Success to unset restriction\n");
264 static bool __net_popup_create(void *data)
266 log_print(NET_POPUP, "__net_popup_create()\n");
268 bindtextdomain(PACKAGE, LOCALEDIR);
273 static void __net_popup_terminate(void *data)
275 log_print(NET_POPUP, "__net_popup_terminate()\n");
277 if (ecore_event_evas_handler) {
278 ecore_event_handler_del(ecore_event_evas_handler);
279 ecore_event_evas_handler = NULL;
282 if (ecore_event_evas_quick_panel_handler) {
283 ecore_event_handler_del(ecore_event_evas_quick_panel_handler);
284 ecore_event_evas_quick_panel_handler = NULL;
288 app_control_destroy(g_req_handle);
292 if (resp_popup_mode) {
293 free(resp_popup_mode);
294 resp_popup_mode = NULL;
305 static void __net_popup_pause(void *data)
307 log_print(NET_POPUP, "__net_popup_pause()\n");
310 static void __net_popup_resume(void *data)
315 static Eina_Bool __key_release_event_cb(void *data, int type,
318 log_print(NET_POPUP, "__key_release_event_cb()\n");
320 Evas_Event_Key_Down *ev = (Evas_Event_Key_Down *) event;
323 return ECORE_CALLBACK_RENEW;
326 return ECORE_CALLBACK_RENEW;
328 log_print(NET_POPUP, "key_release : %s", ev->keyname);
329 if (g_strcmp0(ev->keyname, "XF86Phone") == 0 ||
330 g_strcmp0(ev->keyname, "XF86Stop") == 0) {
334 return ECORE_CALLBACK_DONE;
338 static Eina_Bool _ecore_event_client_message_cb(void *data, int type,
341 Ecore_X_Event_Client_Message *ev = event;
343 if (ev->message_type == ECORE_X_ATOM_E_ILLUME_QUICKPANEL_STATE) {
344 if (ev->data.l[0] == ECORE_X_ATOM_E_ILLUME_QUICKPANEL_OFF)
345 log_print(NET_POPUP, "ECORE_X_ATOM_E_ILLUME_QUICKPANEL_OFF");
346 else if (ev->data.l[0] == ECORE_X_ATOM_E_ILLUME_QUICKPANEL_ON)
347 log_print(NET_POPUP, "ECORE_X_ATOM_E_ILLUME_QUICKPANEL_ON");
349 return ECORE_CALLBACK_RENEW;
353 static void __net_popup_service_cb(app_control_h request, void *data)
355 log_print(NET_POPUP, "__net_popup_service_cb()\n");
358 char *operation = NULL;
361 if (ecore_event_evas_handler == NULL) {
362 ecore_event_evas_handler = ecore_event_handler_add(ECORE_EVENT_KEY_UP,
363 __key_release_event_cb, NULL);
366 ret = app_control_get_operation(request, &operation);
367 if (APP_CONTROL_ERROR_NONE != ret)
368 log_print(NET_POPUP, "Failed to get operation ret= %d", ret);
370 if (operation != NULL && g_str_equal(operation, APP_CONTROL_OPERATION_SETTING_VPN)) {
371 app_control_clone(&g_req_handle, request);
372 __net_popup_show_vpn_popup(request, data);
385 ret = app_control_get_extra_data(request, "_SYSPOPUP_TYPE_", &type);
386 if (APP_CONTROL_ERROR_NONE != ret) {
387 log_print(NET_POPUP, "Failed to get _SYSPOPUP_TYPE_ ret = %d", ret);
393 log_print(NET_POPUP, "type = %s\n", type);
395 if (g_str_equal(type, "notification")) {
396 __net_popup_show_notification(request, data);
398 } else if (g_str_equal(type, "toast_popup")) {
399 __toast_popup_show(request, data);
400 } else if (g_str_equal(type, "popup")) {
401 __net_popup_show_popup(request, data);
402 } else if (g_str_equal(type, "warning_noti")) {
403 __net_popup_show_warning_noti(request, data);
405 } else if (g_str_equal(type, "restriction_noti")) {
406 __net_popup_show_restriction_noti(request, data);
407 } else if (g_str_equal(type, "add_found_ap_noti")) {
408 __net_popup_add_found_ap_noti();
410 } else if (g_str_equal(type, "del_found_ap_noti")) {
411 __net_popup_del_found_ap_noti();
413 } else if (g_str_equal(type, "add_portal_noti")) {
414 __net_popup_add_portal_noti(request);
416 } else if (g_str_equal(type, "del_portal_noti")) {
417 __net_popup_del_portal_noti();
419 } else if (g_str_equal(type, "add_ip_conflict_noti")) {
420 __net_popup_add_ip_conflict_noti(request);
422 } else if (g_str_equal(type, "del_ip_conflict_noti")) {
423 __net_popup_del_ip_conflict_noti();
425 } else if (g_str_equal(type, "popup_user_resp")) {
426 app_control_clone(&g_req_handle, request);
427 __net_popup_show_popup_with_user_resp(request, data);
428 } else if (g_str_equal(type, "network_error_popup")) {
429 __net_popup_show_network_error_popup(request, data);
431 __net_popup_show_notification(request, data);
440 static void __net_popup_set_orientation(Evas_Object *win)
442 log_print(NET_POPUP, "__net_popup_set_orientation()\n");
444 int rots[4] = { 0, 90, 180, 270 };
446 if (!elm_win_wm_rotation_supported_get(win))
449 elm_win_wm_rotation_available_rotations_set(win, rots, 4);
452 static Evas_Object* __net_popup_create_win(void)
454 log_print(NET_POPUP, "__net_popup_create_win()\n");
456 Evas_Object *win = NULL;
458 Ecore_Evas *ee = NULL;
463 win = elm_win_add(NULL, PACKAGE, ELM_WIN_NOTIFICATION);
465 e = evas_object_evas_get(win);
466 ee = ecore_evas_ecore_evas_get(e);
467 ecore_evas_name_class_set(ee, "APP_POPUP", "APP_POPUP");
469 elm_win_alpha_set(win, EINA_TRUE);
470 elm_win_borderless_set(win, EINA_TRUE);
472 ecore_x_window_size_get(ecore_x_window_root_first_get(), &w, &h);
473 evas_object_resize(win, w, h);
474 utilx_set_system_notification_level(ecore_x_display_get(),
475 elm_win_xwindow_get(win),
476 UTILX_NOTIFICATION_LEVEL_LOW);
479 __net_popup_set_orientation(win);
484 static void __launch_app_control(char *operation)
486 app_control_h app_control;
488 app_control_create(&app_control);
489 if (app_control == NULL) {
490 log_print(NET_POPUP, "Failed to create app control handle");
494 app_control_set_operation(app_control, operation);
495 if (app_control_send_launch_request(app_control, NULL, NULL) == APP_CONTROL_ERROR_NONE)
496 log_print(NET_POPUP, "Succeeded to launch %s", operation);
498 log_print(NET_POPUP, "Failed to launch %s", operation);
500 app_control_destroy(app_control);
503 static void __data_roaming_check_changed_cb(void* data, Evas_Object* obj, void* event_info)
505 turn_on_roaming = elm_check_state_get(obj);
506 log_print(NET_POPUP, "Romaing(%d)", turn_on_roaming);
509 static void __do_not_show_check_changed_cb(void* data, Evas_Object* obj, void* event_info)
511 do_not_show_popup = elm_check_state_get(obj);
512 log_print(NET_POPUP, "Do not show again(%d)", do_not_show_popup);
515 static void _ok_button_clicked_cb(void *data, Evas_Object *obj, void *event_info)
517 log_print(NET_POPUP, "_ok_button_clicked_cb()\n");
520 evas_object_del(data);
524 static void _cancel_button_clicked_cb(void *data, Evas_Object *obj, void *event_info)
526 log_print(NET_POPUP, "_cancel_button_clicked_cb()");
529 evas_object_del(data);
534 static void _wifi_button_clicked_cb(void *data, Evas_Object *obj, void *event_info)
536 log_print(NET_POPUP, "_wifi_button_clicked_cb()");
538 __launch_app_control(APP_CONTROL_OPERATION_SETTING_WIFI);
541 evas_object_del(data);
546 static void _settings_button_clicked_cb(void *data, Evas_Object *obj, void *event_info)
548 log_print(NET_POPUP, "_settings_button_clicked_cb()");
550 __launch_app_control(APP_CONTROL_OPERATION_SETTING);
553 evas_object_del(data);
558 static void _retry_button_clicked_cb(void *data, Evas_Object *obj, void *event_info)
560 log_print(NET_POPUP, "_retry_button_clicked_cb()");
562 int ret = vconf_set_bool(VCONFKEY_3G_ENABLE, 1);
564 log_print(NET_POPUP, "Failed to enable mobile data");
567 evas_object_del(data);
572 static void _data_raoming_button_clicked_cb(void *data, Evas_Object *obj, void *event_info)
574 log_print(NET_POPUP, "_data_roaming_button_clicked_cb()");
576 int ret = vconf_set_bool(VCONFKEY_SETAPPL_STATE_DATA_ROAMING_BOOL, turn_on_roaming);
578 log_print(NET_POPUP, "Failed to enable mobile data");
581 evas_object_del(data);
586 static void _connect_button_clicked_cb(void *data, Evas_Object *obj, void *event_info)
588 log_print(NET_POPUP, "_connect_button_clicked_cb()");
590 int ret = vconf_set_bool(VCONFKEY_3G_ENABLE, 1);
592 log_print(NET_POPUP, "Failed to enable mobile data");
595 evas_object_del(data);
600 static void _timeout_cb(void *data, Evas_Object *obj, void *event_info)
602 log_print(NET_POPUP, "_timeout_cb()\n");
604 evas_object_del(obj);
609 static int __toast_popup_show(app_control_h request, void *data)
611 log_print(NET_POPUP, "__toast_popup_show()\n");
613 char buf[ALERT_STR_LEN_MAX] = "";
616 Evas_Object *twin = NULL;
617 Evas_Object *tpop = NULL;
618 char *ap_name = NULL;
619 char *restricted_type = NULL;
621 ret = app_control_get_extra_data(request, "_SYSPOPUP_CONTENT_", &mode);
622 if (ret != APP_CONTROL_ERROR_NONE) {
623 log_print(NET_POPUP, "Failed to get _SYSPOPUP_CONTENT_ ret = %d", ret);
629 log_print(NET_POPUP, "_SYSPOPUP_CONTENT_ = %s\n", mode);
631 twin = __net_popup_create_win();
632 tpop = elm_popup_add(twin);
633 elm_object_style_set(tpop, "toast");
634 evas_object_size_hint_weight_set(tpop, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
636 elm_popup_timeout_set(tpop, 2.0);
638 evas_object_smart_callback_add(tpop, "timeout", _timeout_cb, twin);
639 if (strcmp(mode, "wrong password") == 0) {
640 log_print(NET_POPUP, "alert wrong password\n");
642 g_snprintf(buf, ALERT_STR_LEN_MAX, ALERT_STR_ERR_WRONG_PASSWORD);
643 } else if (strcmp(mode, "no ap found") == 0) {
644 log_print(NET_POPUP, "alert no ap found\n");
646 g_snprintf(buf, ALERT_STR_LEN_MAX, ALERT_STR_NO_AP_FOUND);
647 } else if (strcmp(mode, "unable to connect") == 0) {
648 log_print(NET_POPUP, "alert no ap found\n");
650 g_snprintf(buf, ALERT_STR_LEN_MAX, ALERT_STR_ERR_CONNECT);
651 } else if (strcmp(mode, "wifi connected") == 0) {
652 ret = app_control_get_extra_data(request, "_AP_NAME_", &ap_name);
654 if (APP_CONTROL_ERROR_NONE != ret) {
655 log_print(NET_POPUP, "Failed to get _AP_NAME_ ret = %d", ret);
661 g_snprintf(buf, ALERT_STR_LEN_MAX, ALERT_STR_WIFI_CONNECTED, ap_name);
663 g_snprintf(buf, ALERT_STR_LEN_MAX, ALERT_STR_WIFI_CONNECTED, "");
664 log_print(NET_POPUP, "alert wifi connected\n");
666 } else if (strcmp(mode, "warn threshold crossed") == 0) {
669 ret = app_control_get_extra_data(request, "_APP_ID_", &app_id);
671 if (APP_CONTROL_ERROR_NONE != ret) {
672 log_print(NET_POPUP, "Failed to get _APP_ID_ ret = %d", ret);
677 g_snprintf(buf, ALERT_STR_LEN_MAX, ALERT_STR_DATA_USAGE_WARNING);
679 log_print(NET_POPUP, "alert warn threshold crossed [%s]\n", app_id);
681 } else if (strcmp(mode, "security restriction") == 0) {
682 ret = app_control_get_extra_data(request, "_RESTRICTED_TYPE_", &restricted_type);
683 if (APP_CONTROL_ERROR_NONE != ret) {
684 log_print(NET_POPUP, "Failed to get _RESTRICTED_TYPE_ ret = %d", ret);
689 if (strcmp(restricted_type, "wifi") == 0)
690 g_snprintf(buf, ALERT_STR_LEN_MAX, ALERT_STR_RESTRICTED_USE_WIFI);
691 else if (strcmp(restricted_type, "wifi tethering") == 0)
692 g_snprintf(buf, ALERT_STR_LEN_MAX, ALERT_STR_SECURITY_RESTRICTION, ALERT_STR_WIFI_TETHERING);
693 else if (strcmp(restricted_type, "bt tethering") == 0)
694 g_snprintf(buf, ALERT_STR_LEN_MAX, ALERT_STR_SECURITY_RESTRICTION, ALERT_STR_BT_TETHERING);
695 else if (strcmp(restricted_type, "usb tethering") == 0)
696 g_snprintf(buf, ALERT_STR_LEN_MAX, ALERT_STR_SECURITY_RESTRICTION, ALERT_STR_USB_TETHERING);
698 log_print(NET_POPUP, "alert security restriction\n");
699 g_free(restricted_type);
701 log_print(NET_POPUP, "%s\n", mode);
703 elm_object_text_set(tpop, buf);
704 evas_object_show(tpop);
705 evas_object_show(twin);
711 static int __net_popup_show_notification(app_control_h request, void *data)
713 log_print(NET_POPUP, "__net_popup_show_notification()\n");
717 char buf[ALERT_STR_LEN_MAX] = "";
718 char *ap_name = NULL;
720 ret = app_control_get_extra_data(request, "_SYSPOPUP_CONTENT_", &mode);
722 if (APP_CONTROL_ERROR_NONE != ret) {
723 log_print(NET_POPUP, "Failed to get _SYSPOPUP_CONTENT_");
727 secure_log_print(NET_POPUP, "_SYSPOPUP_CONTENT_ = %s\n", mode);
729 if (strcmp(mode, "connected") == 0) {
730 notification_status_message_post(ALERT_STR_MOBILE_NETWORKS_CHARGE);
731 log_print(NET_POPUP, "alert 3g\n");
732 } else if (strcmp(mode, "fail to connect") == 0) {
733 notification_status_message_post(ALERT_STR_ERR_UNAVAILABLE);
734 log_print(NET_POPUP, "alert err\n");
735 } else if (strcmp(mode, "unable to connect") == 0) {
736 notification_status_message_post(ALERT_STR_ERR_CONNECT);
737 log_print(NET_POPUP, "alert unable to connect\n");
738 } else if (strcmp(mode, "wrong password") == 0) {
739 notification_status_message_post(ALERT_STR_ERR_WRONG_PASSWORD);
740 log_print(NET_POPUP, "alert wrong password\n");
741 } else if (strcmp(mode, "not support") == 0) {
742 notification_status_message_post(ALERT_STR_ERR_NOT_SUPPORT);
743 log_print(NET_POPUP, "alert not support\n");
744 } else if (strcmp(mode, "wifi restricted") == 0) {
745 notification_status_message_post(ALERT_STR_RESTRICTED_USE_WIFI);
746 log_print(NET_POPUP, "alert wifi restricted\n");
747 } else if (strcmp(mode, "no ap found") == 0) {
748 notification_status_message_post(ALERT_STR_NO_AP_FOUND);
749 log_print(NET_POPUP, "alert no ap found\n");
750 } else if (strcmp(mode, "Lengthy Password") == 0) {
751 notification_status_message_post(ALERT_STR_LENGHTY_PASSWORD);
752 log_print(NET_POPUP, "Password entered crosses 64 bytes\n");
753 } else if (strcmp(mode, "Portal Login") == 0) {
754 notification_status_message_post(CAPTIVE_PORTAL_LOGIN);
755 log_print(NET_POPUP, "Please login to access Internet\n");
756 } else if (strcmp(mode, "Portal Login Error") == 0) {
757 notification_status_message_post(CAPTIVE_PORTAL_LOGIN_ERROR);
758 log_print(NET_POPUP, "Login not completed. Disconnected Wifi\n");
759 } else if (strcmp(mode, "wifi connected") == 0) {
760 ret = app_control_get_extra_data(request, "_AP_NAME_", &ap_name);
762 if (APP_CONTROL_ERROR_NONE != ret) {
763 log_print(NET_POPUP, "Failed to get _AP_NAME_ ret = %d", ret);
769 g_snprintf(buf, ALERT_STR_LEN_MAX, ALERT_STR_WIFI_CONNECTED, ap_name);
771 g_snprintf(buf, ALERT_STR_LEN_MAX, ALERT_STR_WIFI_CONNECTED, "");
773 notification_status_message_post(buf);
775 log_print(NET_POPUP, "alert wifi connected\n");
777 } else if (strcmp(mode, "warn threshold crossed") == 0) {
778 char buf[ALERT_STR_LEN_MAX] = "";
781 ret = app_control_get_extra_data(request, "_APP_ID_", &app_id);
783 if (APP_CONTROL_ERROR_NONE != ret) {
784 log_print(NET_POPUP, "Failed to get _APP_ID_ ret = %d", ret);
789 g_snprintf(buf, ALERT_STR_LEN_MAX, ALERT_STR_DATA_USAGE_WARNING);
791 notification_status_message_post(buf);
793 log_print(NET_POPUP, "alert warn threshold crossed [%s]\n", app_id);
796 notification_status_message_post(mode);
797 log_print(NET_POPUP, "%s\n", mode);
804 static int _net_popup_send_user_resp(char *resp, Eina_Bool state)
806 log_print(NET_POPUP, "_net_popup_send_user_resp()\n");
809 app_control_h reply = NULL;
810 char checkbox_str[USER_RESP_LEN] = { '\0', };
812 log_print(NET_POPUP, "Send the user response to the caller");
813 ret = app_control_create(&reply);
814 if (APP_CONTROL_ERROR_NONE != ret) {
815 log_print(NET_POPUP, "Failed to create service ret = %d", ret);
816 app_control_destroy(g_req_handle);
823 g_strlcpy(checkbox_str, "TRUE", USER_RESP_LEN);
825 g_strlcpy(checkbox_str, "FALSE", USER_RESP_LEN);
827 log_print(NET_POPUP, "Checkbox_str[%s]", checkbox_str);
829 ret = app_control_add_extra_data(reply, "_SYSPOPUP_RESP_", resp);
830 if (APP_CONTROL_ERROR_NONE == ret) {
831 ret = app_control_add_extra_data(reply, "_SYSPOPUP_CHECKBOX_RESP_",
833 if (APP_CONTROL_ERROR_NONE == ret) {
834 ret = app_control_reply_to_launch_request(reply, g_req_handle,
835 APP_CONTROL_RESULT_SUCCEEDED);
836 if (APP_CONTROL_ERROR_NONE == ret) {
837 log_print(NET_POPUP, "Service reply success");
840 log_print(NET_POPUP, "Service reply failed ret = %d", ret);
843 log_print(NET_POPUP, "Service data addition failed ret = %d", ret);
846 log_print(NET_POPUP, "Service data addition failed ret = %d", ret);
849 app_control_destroy(reply);
850 app_control_destroy(g_req_handle);
856 static Evas_Object *__net_popup_create_checkview_layout(Evas_Object *parent)
858 Evas_Object *layout = NULL;
860 layout = elm_layout_add(parent);
861 elm_layout_file_set(layout, NETPOPUP_EDJ, "popup_checkview");
862 evas_object_size_hint_weight_set(layout, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
863 evas_object_size_hint_align_set(layout, EVAS_HINT_FILL, 1.0);
864 elm_object_content_set(parent, layout);
869 static Evas_Object *__net_popup_create_label(Evas_Object *parent)
871 Evas_Object *label = NULL;
873 label = elm_label_add(parent);
874 elm_object_style_set(label, "popup/default");
875 elm_label_line_wrap_set(label, ELM_WRAP_MIXED);
876 evas_object_size_hint_weight_set(label, EVAS_HINT_EXPAND, 0.0);
877 evas_object_size_hint_align_set(label, EVAS_HINT_FILL, EVAS_HINT_FILL);
878 evas_object_show(label);
883 static Evas_Object *__net_popup_create_cancel_button(Evas_Object *parent)
885 Evas_Object *btn = NULL;
887 btn = elm_button_add(parent);
888 elm_object_style_set(btn, "popup");
889 elm_object_text_set(btn, ALERT_STR_CANCEL);
890 evas_object_size_hint_align_set(btn, EVAS_HINT_FILL, EVAS_HINT_FILL);
891 evas_object_smart_callback_add(btn, "clicked", _cancel_button_clicked_cb, parent);
896 static Evas_Object *__net_popup_create_wifi_button(Evas_Object *parent)
898 Evas_Object *btn = NULL;
900 btn = elm_button_add(parent);
901 elm_object_style_set(btn, "popup");
902 elm_object_text_set(btn, ALERT_STR_WIFI);
903 evas_object_size_hint_align_set(btn, EVAS_HINT_FILL, EVAS_HINT_FILL);
904 evas_object_smart_callback_add(btn, "clicked", _wifi_button_clicked_cb, parent);
909 static Evas_Object *__net_popup_create_settings_button(Evas_Object *parent)
911 Evas_Object *btn = NULL;
913 btn = elm_button_add(parent);
914 elm_object_style_set(btn, "popup");
915 elm_object_text_set(btn, ALERT_STR_SETTINGS);
916 evas_object_size_hint_align_set(btn, EVAS_HINT_FILL, EVAS_HINT_FILL);
917 evas_object_smart_callback_add(btn, "clicked", _settings_button_clicked_cb, parent);
922 static Evas_Object *__net_popup_create_retry_button(Evas_Object *parent)
924 Evas_Object *btn = NULL;
926 btn = elm_button_add(parent);
927 elm_object_style_set(btn, "popup");
928 elm_object_text_set(btn, ALERT_STR_RETRY);
929 evas_object_size_hint_align_set(btn, EVAS_HINT_FILL, EVAS_HINT_FILL);
930 evas_object_smart_callback_add(btn, "clicked", _retry_button_clicked_cb, parent);
935 static Evas_Object *__net_popup_create_data_roaming_button(Evas_Object *parent)
937 Evas_Object *btn = NULL;
939 btn = elm_button_add(parent);
940 elm_object_style_set(btn, "popup");
941 elm_object_text_set(btn, ALERT_STR_OK);
942 evas_object_size_hint_align_set(btn, EVAS_HINT_FILL, EVAS_HINT_FILL);
943 evas_object_smart_callback_add(btn, "clicked", _data_raoming_button_clicked_cb, parent);
948 static Evas_Object *__net_popup_create_connect_button(Evas_Object *parent)
950 Evas_Object *btn = NULL;
952 btn = elm_button_add(parent);
953 elm_object_style_set(btn, "popup");
954 elm_object_text_set(btn, ALERT_STR_VPN_CONNECT_BUTTON);
955 evas_object_size_hint_align_set(btn, EVAS_HINT_FILL, EVAS_HINT_FILL);
956 evas_object_smart_callback_add(btn, "clicked", _connect_button_clicked_cb, parent);
961 static int __net_popup_show_network_error_popup(app_control_h request, void *data)
963 log_print(NET_POPUP, "__net_popup_show_network_error_popup()\n");
970 Evas_Object *btn1, *btn2, *btn3;
974 ret = app_control_get_extra_data(request, "_SYSPOPUP_CONTENT_", &mode);
975 if (APP_CONTROL_ERROR_NONE != ret) {
976 log_print(NET_POPUP, "Failed to get _SYSPOPUP_CONTENT_ ret = %d", ret);
982 secure_log_print(NET_POPUP, "_SYSPOPUP_CONTENT_ = %s\n", mode);
984 win = __net_popup_create_win();
985 popup = elm_popup_add(win);
986 evas_object_size_hint_weight_set(popup, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
988 if (strcmp(mode, "connect_to_mobile_network") == 0) {
989 elm_object_part_text_set(popup, "title,text", ALERT_STR_CONNECT_TO_MOBILE_NETWORK);
990 layout = __net_popup_create_checkview_layout(popup);
991 label = __net_popup_create_label(layout);
992 elm_object_text_set(label, ALERT_STR_ROAMING_WITH_PAYMENT);
993 elm_object_part_content_set(layout, "elm.swallow.content", label);
994 check = elm_check_add(popup);
995 elm_object_style_set(check, "popup");
996 elm_object_part_content_set(layout, "elm.swallow.end", check);
997 elm_object_text_set(check, ALERT_STR_DO_NOT_SHOW_AGAIN);
998 elm_check_state_set(check, EINA_FALSE);
999 evas_object_smart_callback_add(check, "changed",
1000 __do_not_show_check_changed_cb, NULL);
1001 btn1 = __net_popup_create_cancel_button(popup);
1002 elm_object_part_content_set(popup, "button1", btn1);
1003 btn2 = __net_popup_create_connect_button(popup);
1004 elm_object_part_content_set(popup, "button2", btn2);
1006 elm_object_part_text_set(popup, "title,text", ALERT_STR_NO_NETWORK_CONNECTION);
1007 if (strcmp(mode, "flight_mode") == 0) {
1008 elm_object_text_set(popup, ALERT_STR_CANT_CONNECT_TO_MOBILE);
1009 btn1 = __net_popup_create_cancel_button(popup);
1010 elm_object_part_content_set(popup, "button1", btn1);
1011 btn2 = __net_popup_create_wifi_button(popup);
1012 elm_object_part_content_set(popup, "button2", btn2);
1013 btn3 = __net_popup_create_settings_button(popup);
1014 elm_object_part_content_set(popup, "button3", btn3);
1015 } else if (strcmp(mode, "mobile_data_is_turned_off") == 0) {
1016 elm_object_text_set(popup, ALERT_STR_MOBILE_DATA_IS_TURNED_OFF);
1017 btn1 = __net_popup_create_cancel_button(popup);
1018 elm_object_part_content_set(popup, "button1", btn1);
1019 btn2 = __net_popup_create_wifi_button(popup);
1020 elm_object_part_content_set(popup, "button2", btn2);
1021 btn3 = __net_popup_create_settings_button(popup);
1022 elm_object_part_content_set(popup, "button3", btn3);
1023 } else if (strcmp(mode, "no_mobile_networks") == 0) {
1024 elm_object_text_set(popup, ALERT_STR_NO_MOBILE_NETWORKS);
1025 btn1 = __net_popup_create_cancel_button(popup);
1026 elm_object_part_content_set(popup, "button1", btn1);
1027 btn2 = __net_popup_create_retry_button(popup);
1028 elm_object_part_content_set(popup, "button2", btn2);
1029 } else if (strcmp(mode, "roaming_with_check") == 0) {
1030 layout = __net_popup_create_checkview_layout(popup);
1031 label = __net_popup_create_label(layout);
1032 elm_object_text_set(label, ALERT_STR_ROAMING_WITH_PAYMENT);
1033 elm_object_part_content_set(layout, "elm.swallow.content", label);
1034 check = elm_check_add(popup);
1035 elm_object_style_set(check, "popup");
1036 elm_object_part_content_set(layout, "elm.swallow.end", check);
1037 elm_object_text_set(check, ALERT_STR_TURN_ON_DATA_ROAMING);
1038 elm_check_state_set(check, EINA_FALSE);
1039 evas_object_smart_callback_add(check, "changed",
1040 __data_roaming_check_changed_cb, NULL);
1041 btn1 = __net_popup_create_data_roaming_button(popup);
1042 elm_object_part_content_set(popup, "button1", btn1);
1043 } else if (strcmp(mode, "roaming_with_settings") == 0) {
1044 elm_object_text_set(popup, ALERT_STR_ROAMING);
1045 btn1 = __net_popup_create_cancel_button(popup);
1046 elm_object_part_content_set(popup, "button1", btn1);
1047 btn2 = __net_popup_create_wifi_button(popup);
1048 elm_object_part_content_set(popup, "button2", btn2);
1049 btn3 = __net_popup_create_settings_button(popup);
1050 elm_object_part_content_set(popup, "button3", btn3);
1054 evas_object_show(popup);
1055 evas_object_show(win);
1061 void _tethering_wifi_btn_yes_cb(void *data, Evas_Object *obj, void *event_info)
1063 log_print(NET_POPUP, "_tethering_wifi_btn_yes_cb()\n");
1065 bool result = FALSE;
1066 Evas_Object *popup = (Evas_Object *)data;
1068 __net_popup_init_dbus();
1069 __net_popup_send_dbus_msg("progress_off");
1070 __net_popup_deinit_dbus();
1072 result = _net_popup_send_user_resp(RESP_WIFI_TETHERING_OFF, FALSE);
1074 log_print(NET_POPUP, "Failed to send user response ");
1077 evas_object_del(popup);
1082 void _tethering_wifi_ap_btn_yes_cb(void *data, Evas_Object *obj, void *event_info)
1084 log_print(NET_POPUP, "_tethering_wifi_ap_btn_yes_cb()\n");
1086 bool result = FALSE;
1087 Evas_Object *popup = (Evas_Object *)data;
1089 __net_popup_init_dbus();
1090 __net_popup_send_dbus_msg("progress_off");
1091 __net_popup_deinit_dbus();
1093 result = _net_popup_send_user_resp(RESP_WIFI_AP_TETHERING_OFF, FALSE);
1095 log_print(NET_POPUP, "Failed to send user response ");
1098 evas_object_del(popup);
1103 static void _vpn_send_result(int result)
1105 log_print(NET_POPUP, "Send the result of vpn-service to the caller");
1108 app_control_h reply = NULL;
1109 app_control_result_e resp_code;
1111 ret = app_control_create(&reply);
1112 if (APP_CONTROL_ERROR_NONE != ret) {
1113 log_print(NET_POPUP, "Failed to create service ret = %d", ret);
1114 app_control_destroy(g_req_handle);
1115 g_req_handle = NULL;
1119 if (result == VPNSVC_ERROR_NONE)
1120 resp_code = APP_CONTROL_RESULT_SUCCEEDED;
1121 else if (result == VPNSVC_ERROR_CANCELED)
1122 resp_code = APP_CONTROL_RESULT_CANCELED;
1124 resp_code = APP_CONTROL_RESULT_FAILED;
1126 ret = app_control_add_extra_data(reply, APP_CONTROL_DATA_TEXT, __get_vpn_error_message(result));
1127 if (APP_CONTROL_ERROR_NONE == ret) {
1128 ret = app_control_reply_to_launch_request(reply, g_req_handle, resp_code);
1129 if (APP_CONTROL_ERROR_NONE == ret)
1130 log_print(NET_POPUP, "Service reply success");
1132 log_print(NET_POPUP, "Service reply failed ret = %d", ret);
1134 log_print(NET_POPUP, "Service data addition failed ret = %d", ret);
1137 app_control_destroy(reply);
1138 app_control_destroy(g_req_handle);
1139 g_req_handle = NULL;
1144 void _vpn_btn_connect_cb(void *data, Evas_Object *obj, void *event_info)
1146 log_print(NET_POPUP, "_vpn_btn_connect_cb()");
1147 Evas_Object *popup = (Evas_Object *)data;
1148 int ret = VPNSVC_ERROR_NONE;
1150 ret = _vpnsvc_up(iface_name);
1151 _vpn_send_result(ret);
1158 evas_object_del(popup);
1160 evas_object_del(obj);
1165 void _vpn_btn_disconnect_cb(void *data, Evas_Object *obj, void *event_info)
1167 log_print(NET_POPUP, "_vpn_btn_disconnect_cb()");
1168 Evas_Object *popup = (Evas_Object *)data;
1169 int ret = VPNSVC_ERROR_NONE;
1171 ret = _vpnsvc_down(iface_name);
1172 _vpn_send_result(ret);
1179 evas_object_del(popup);
1181 evas_object_del(obj);
1186 void _vpn_btn_no_cb(void *data, Evas_Object *obj, void *event_info)
1188 log_print(NET_POPUP, "_vpn_btn_no_cb()");
1189 Evas_Object *popup = (Evas_Object *)data;
1191 _vpn_send_result(VPNSVC_ERROR_CANCELED);
1198 evas_object_del(popup);
1200 evas_object_del(obj);
1205 void _btn_no_cb(void *data, Evas_Object *obj, void *event_info)
1207 log_print(NET_POPUP, "_btn_no_cb()\n");
1209 bool result = FALSE;
1210 Evas_Object *popup = (Evas_Object *)data;
1212 result = _net_popup_send_user_resp(RESP_TETHERING_ON, FALSE);
1214 log_print(NET_POPUP, "Failed to send user response ");
1217 evas_object_del(popup);
1222 static void __data_usage_notification(notification_type_e type,
1223 notification_ly_type_e ly_type, const char *title_text, const char *title_key,
1224 const char *content_text, const char *content_key, const char *launch_appid)
1228 char icon_path[ICON_PATH_LEN];
1229 notification_h noti = NULL;
1230 notification_error_e noti_err = NOTIFICATION_ERROR_NONE;
1231 app_control_h service_handle = NULL;
1233 noti = notification_create(type);
1235 log_print(NET_POPUP, "Failed to create notification");
1239 noti_err = notification_set_time(noti, time(NULL));
1240 if (noti_err != NOTIFICATION_ERROR_NONE) {
1241 log_print(NET_POPUP, "Failed to notification_set_time : %d", noti_err);
1245 g_snprintf(icon_path, sizeof(icon_path), "%s%s",
1246 STC_NOTI_DATA_USAGE_ICON_PATH, STC_NOTI_DATA_USAGE_ICON_NAME);
1247 noti_err = notification_set_image(noti, NOTIFICATION_IMAGE_TYPE_ICON, icon_path);
1248 if (noti_err != NOTIFICATION_ERROR_NONE) {
1249 log_print(NET_POPUP, "Failed to notification_set_image : %d", noti_err);
1253 noti_err = notification_set_layout(noti, ly_type);
1254 if (noti_err != NOTIFICATION_ERROR_NONE) {
1255 log_print(NET_POPUP, "Failed to notification_set_layout : %d", noti_err);
1259 noti_err = notification_set_text_domain(noti, PACKAGE,
1261 if (noti_err != NOTIFICATION_ERROR_NONE) {
1262 log_print(NET_POPUP, "Failed to notification_set_text_domain : %d", noti_err);
1266 noti_err = notification_set_text(noti, NOTIFICATION_TEXT_TYPE_TITLE,
1267 title_text, title_key,
1268 NOTIFICATION_VARIABLE_TYPE_NONE);
1269 if (noti_err != NOTIFICATION_ERROR_NONE) {
1270 log_print(NET_POPUP, "Failed to notification_set_title : %d", noti_err);
1275 noti_err = notification_set_text(noti, NOTIFICATION_TEXT_TYPE_CONTENT,
1276 content_text, content_key,
1277 NOTIFICATION_VARIABLE_TYPE_NONE);
1278 if (noti_err != NOTIFICATION_ERROR_NONE) {
1279 log_print(NET_POPUP, "Failed to notification_set_content: %d", noti_err);
1284 noti_flags = NOTIFICATION_DISPLAY_APP_NOTIFICATION_TRAY |
1285 NOTIFICATION_DISPLAY_APP_TICKER | NOTIFICATION_DISPLAY_APP_INDICATOR;
1286 noti_err = notification_set_display_applist(noti, noti_flags);
1287 if (noti_err != NOTIFICATION_ERROR_NONE) {
1288 log_print(NET_POPUP, "Failed to notification_set_display_applist: %d", noti_err);
1293 ret = app_control_create(&service_handle);
1294 log_print(NET_POPUP, "Service create ret[%d]", ret);
1295 if (ret != APP_CONTROL_ERROR_NONE)
1298 ret = app_control_set_app_id(service_handle, launch_appid);
1299 log_print(NET_POPUP, "Service set app id ret = %d", ret);
1300 if (ret != APP_CONTROL_ERROR_NONE)
1303 ret = app_control_add_extra_data(service_handle, "caller", "notification");
1304 log_print(NET_POPUP, "Service data addition ret = %d", ret);
1305 if (ret != APP_CONTROL_ERROR_NONE)
1308 noti_err = notification_set_launch_option(noti,
1309 NOTIFICATION_LAUNCH_OPTION_APP_CONTROL, service_handle);
1310 if (noti_err != NOTIFICATION_ERROR_NONE) {
1311 log_print(NET_POPUP, "Failed to notification_set_launch_option");
1316 noti_err = notification_post(noti);
1317 if (noti_err != NOTIFICATION_ERROR_NONE) {
1318 log_print(NET_POPUP, "Failed to insert notification[error# is %d]", noti_err);
1322 log_print(NET_POPUP, "Successfully added notification");
1327 notification_free(noti);
1330 app_control_destroy(service_handle);
1333 static void __data_usage_btn_on_cb(void *data, Evas_Object *obj, void *event_info)
1335 log_print(NET_POPUP, "__data_usage_btn_on_cb()");
1336 Evas_Object *popup = (Evas_Object *)data;
1338 __net_popup_init_dbus();
1339 __net_popup_send_data_usage_msg(data_usage_app_id, data_usage_iftype);
1340 __net_popup_deinit_dbus();
1342 __data_usage_notification(NOTIFICATION_TYPE_ONGOING,
1343 NOTIFICATION_LY_ONGOING_EVENT,
1344 STC_NOTIFICATION_RESTRICTION_ON_TITLE,
1345 "IDS_SM_TMBODY_MOBILE_DATA_LIMIT_EXCEEDED_ABB",
1349 evas_object_del(popup);
1351 evas_object_del(obj);
1353 g_free(data_usage_app_id);
1354 g_free(data_usage_iftype);
1359 static void __data_usage_btn_ok_cb(void *data, Evas_Object *obj, void *event_info)
1361 log_print(NET_POPUP, "__data_usage_btn_ok_cb()");
1362 Evas_Object *popup = (Evas_Object *)data;
1364 __data_usage_notification(NOTIFICATION_TYPE_ONGOING,
1365 NOTIFICATION_LY_ONGOING_EVENT,
1366 STC_NOTIFICATION_RESTRICTION_OK_TITLE,
1367 "IDS_SM_HEADER_MOBILE_DATA_TURNED_OFF_ABB2",
1368 STC_NOTIFICATION_RESTRICTION_OK_CONTENT,
1369 "IDS_SM_SBODY_TAP_HERE_TO_TURN_IT_ON_AGAIN_ABB",
1373 evas_object_del(popup);
1375 evas_object_del(obj);
1377 g_free(data_usage_app_id);
1378 g_free(data_usage_iftype);
1383 static void __net_popup_show_popup_with_user_resp(app_control_h request,
1386 log_print(NET_POPUP, "__net_popup_show_popup_with_user_resp()\n");
1390 Evas_Object *layout;
1396 ret = app_control_get_extra_data(request, "_SYSPOPUP_CONTENT_", &resp_popup_mode);
1397 if (APP_CONTROL_ERROR_NONE != ret)
1398 log_print(NET_POPUP, "Failed to get _SYSPOPUP_CONTENT_ ret = %d", ret);
1400 secure_log_print(NET_POPUP, "_SYSPOPUP_CONTENT_ = %s\n", resp_popup_mode);
1402 win = __net_popup_create_win();
1403 evas_object_show(win);
1405 popup = elm_popup_add(win);
1406 evas_object_size_hint_weight_set(popup, EVAS_HINT_EXPAND,
1409 if (g_strcmp0(resp_popup_mode, "TETHERING_TYPE_WIFI") == 0 ||
1410 g_strcmp0(resp_popup_mode, "TETHERING_TYPE_WIFI_AP") == 0) {
1411 log_print(NET_POPUP, "Drawing Wi-Fi Tethering OFF popup");
1413 __net_popup_init_dbus();
1414 elm_object_part_text_set(popup, "title,text", ALERT_STR_WIFI);
1416 layout = elm_layout_add(popup);
1417 elm_layout_file_set(layout, NETPOPUP_EDJ, "popup");
1418 evas_object_size_hint_weight_set(layout, EVAS_HINT_EXPAND,
1421 __net_popup_send_dbus_msg("progress_on");
1422 label = elm_label_add(popup);
1423 elm_label_line_wrap_set(label, ELM_WRAP_MIXED);
1424 elm_object_text_set(label, ALERT_STR_WIFI_MOBILE_AP_ON);
1425 evas_object_size_hint_weight_set(label, EVAS_HINT_EXPAND,
1427 evas_object_size_hint_align_set(label, EVAS_HINT_FILL, EVAS_HINT_FILL);
1428 evas_object_show(label);
1430 elm_object_part_content_set(layout, "elm.swallow.content", label);
1431 evas_object_show(layout);
1432 elm_object_style_set(label, "popup/default");
1433 eext_object_event_callback_add(popup, EEXT_CALLBACK_BACK, _btn_no_cb, popup);
1434 elm_object_content_set(popup, label);
1436 btn1 = elm_button_add(popup);
1437 elm_object_style_set(btn1, "popup");
1438 elm_object_text_set(btn1, ALERT_STR_CANCEL);
1439 elm_object_part_content_set(popup, "button1", btn1);
1440 evas_object_smart_callback_add(btn1, "clicked",
1443 btn2 = elm_button_add(popup);
1444 elm_object_style_set(btn2, "popup");
1445 elm_object_text_set(btn2, ALERT_STR_OK);
1446 elm_object_part_content_set(popup, "button2", btn2);
1448 if (g_strcmp0(resp_popup_mode, "TETHERING_TYPE_WIFI") == 0)
1449 evas_object_smart_callback_add(btn2, "clicked",
1450 _tethering_wifi_btn_yes_cb, popup);
1451 else if (g_strcmp0(resp_popup_mode, "TETHERING_TYPE_WIFI_AP") == 0)
1452 evas_object_smart_callback_add(btn2, "clicked",
1453 _tethering_wifi_ap_btn_yes_cb, popup);
1455 evas_object_show(popup);
1456 evas_object_show(win);
1457 __net_popup_deinit_dbus();
1461 static void __net_popup_show_vpn_popup(app_control_h request, void *data)
1465 Evas_Object *button1;
1466 Evas_Object *button2;
1469 char *content = NULL;
1470 char *ok_btn = NULL;
1473 log_print(NET_POPUP, "__net_popup_show_vpn_popup");
1475 int ret = app_control_get_extra_data(request, APP_CONTROL_DATA_TYPE, &type);
1476 if (APP_CONTROL_ERROR_NONE != ret) {
1477 log_print(NET_POPUP, "Failed to get APP_CONTROL_DATA_TYPE ret = %d", ret);
1482 ret = app_control_get_extra_data(request, APP_CONTROL_DATA_NAME, &iface_name);
1483 if (APP_CONTROL_ERROR_NONE != ret) {
1484 log_print(NET_POPUP, "Failed to get APP_CONTROL_DATA_NAME ret = %d", ret);
1488 log_print(NET_POPUP, "type(%s) name(%s)", type, iface_name);
1490 if (strcmp(type, "up") == 0) {
1491 title = ALERT_STR_VPN_CONNECT_TITLE;
1492 content = ALERT_STR_VPN_CONNECT_CONTENT;
1493 ok_btn = ALERT_STR_VPN_CONNECT_BUTTON;
1494 ok_cb = _vpn_btn_connect_cb;
1495 } else if (strcmp(type, "down") == 0) {
1496 title = ALERT_STR_VPN_DISCONNECT_TITLE;
1497 content = ALERT_STR_VPN_DISCONNECT_CONTENT;
1498 ok_btn = ALERT_STR_VPN_DISCONNECT_BUTTON;
1499 ok_cb = _vpn_btn_disconnect_cb;
1501 log_print(NET_POPUP, "Invalid appcontrol value");
1506 log_print(NET_POPUP, "title(%s) content(%s) ok(%s)", title, content, ok_btn);
1508 win = __net_popup_create_win();
1510 popup = elm_popup_add(win);
1511 evas_object_size_hint_weight_set(popup, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
1513 elm_object_text_set(popup, content);
1514 elm_object_part_text_set(popup, "title,text", title);
1517 button1 = elm_button_add(popup);
1518 elm_object_style_set(button1, "bottom");
1519 elm_object_text_set(button1, ALERT_STR_CANCEL);
1520 elm_object_part_content_set(popup, "button1", button1);
1521 evas_object_smart_callback_add(button1, "clicked", _vpn_btn_no_cb, popup);
1524 button2 = elm_button_add(popup);
1525 elm_object_style_set(button2, "bottom");
1526 elm_object_text_set(button2, ok_btn);
1527 elm_object_part_content_set(popup, "button2", button2);
1528 evas_object_smart_callback_add(button2, "clicked", ok_cb, popup);
1530 evas_object_show(popup);
1531 evas_object_show(win);
1536 static void __net_popup_show_warning_noti(app_control_h request, void *data)
1538 log_print(NET_POPUP, "__net_popup_show_warning_noti()\n");
1540 int ret = app_control_get_extra_data(request, "_APP_ID_", &data_usage_app_id);
1541 if (APP_CONTROL_ERROR_NONE != ret) {
1542 log_print(NET_POPUP, "Failed to get _APP_ID_ ret = %d", ret);
1547 if (strcmp(data_usage_app_id, STC_TOTAL_DATACALL) &&
1548 strcmp(data_usage_app_id, STC_TOTAL_WIFI) &&
1549 strcmp(data_usage_app_id, STC_TOTAL_BLUETOOTH)) {
1550 log_print(NET_POPUP, "It's not total data usage [%s]", data_usage_app_id);
1551 g_free(data_usage_app_id);
1556 __data_usage_notification(NOTIFICATION_TYPE_ONGOING,
1557 NOTIFICATION_LY_ONGOING_EVENT,
1558 STC_NOTIFICATION_WARNING_TITLE,
1559 "IDS_COM_BODY_DATA_USAGE_WARNING",
1560 STC_NOTIFICATION_WARNING_CONTENT,
1561 "IDS_SM_SBODY_TAP_HERE_TO_VIEW_YOUR_DATA_USAGE_ABB",
1565 static void __net_popup_show_restriction_noti(app_control_h request, void *data)
1569 Evas_Object *button1;
1570 Evas_Object *button2;
1572 char *content = NULL;
1574 char *on_btn = NULL;
1575 char *ok_btn = NULL;
1576 char buf[ALERT_STR_LEN_MAX] = "";
1578 log_print(NET_POPUP, "__net_popup_show_data_usage_popup");
1580 int ret = app_control_get_extra_data(request, "_APP_ID_", &data_usage_app_id);
1581 if (APP_CONTROL_ERROR_NONE != ret) {
1582 log_print(NET_POPUP, "Failed to get _APP_ID_ ret = %d", ret);
1587 if (strcmp(data_usage_app_id, STC_TOTAL_DATACALL) &&
1588 strcmp(data_usage_app_id, STC_TOTAL_WIFI) &&
1589 strcmp(data_usage_app_id, STC_TOTAL_BLUETOOTH)) {
1590 log_print(NET_POPUP, "It's not total data usage [%s]", data_usage_app_id);
1591 g_free(data_usage_app_id);
1596 ret = app_control_get_extra_data(request, "_IF_TYPE_", &data_usage_iftype);
1597 if (APP_CONTROL_ERROR_NONE != ret) {
1598 log_print(NET_POPUP, "Failed to get _IF_TYPE_ ret = %d", ret);
1599 g_free(data_usage_app_id);
1604 ret = app_control_get_extra_data(request, "_RESTRICTION_LIMIT_", &limit);
1605 if (APP_CONTROL_ERROR_NONE != ret) {
1606 log_print(NET_POPUP, "Failed to get _RESTRICTION_LIMIT_ ret = %d", ret);
1607 g_free(data_usage_app_id);
1608 g_free(data_usage_iftype);
1613 title = ALERT_STR_DATA_USAGE_TITLE;
1614 g_snprintf(buf, ALERT_STR_LEN_MAX, ALERT_STR_DATA_USAGE_CONTENT, limit);
1616 on_btn = ALERT_STR_DATA_USAGE_TURN_ON_BUTTON;
1617 ok_btn = ALERT_STR_OK;
1619 log_print(NET_POPUP, "title(%s) content(%s) app_id(%s) iftype(%s) limit(%s)",
1620 title, content, data_usage_app_id, data_usage_iftype, limit);
1622 win = __net_popup_create_win();
1624 popup = elm_popup_add(win);
1625 evas_object_size_hint_weight_set(popup, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
1627 elm_object_text_set(popup, content);
1628 elm_object_part_text_set(popup, "title,text", title);
1631 button1 = elm_button_add(popup);
1632 elm_object_style_set(button1, "bottom");
1633 elm_object_text_set(button1, on_btn);
1634 elm_object_part_content_set(popup, "button1", button1);
1635 evas_object_smart_callback_add(button1, "clicked", __data_usage_btn_on_cb, popup);
1638 button2 = elm_button_add(popup);
1639 elm_object_style_set(button2, "bottom");
1640 elm_object_text_set(button2, ok_btn);
1641 elm_object_part_content_set(popup, "button2", button2);
1642 evas_object_smart_callback_add(button2, "clicked", __data_usage_btn_ok_cb, popup);
1644 evas_object_show(popup);
1645 evas_object_show(win);
1650 static int __net_popup_show_popup(app_control_h request, void *data)
1652 log_print(NET_POPUP, "__net_popup_show_popup()\n");
1656 Evas_Object *button;
1660 ret = app_control_get_extra_data(request, "_SYSPOPUP_CONTENT_", &mode);
1661 if (APP_CONTROL_ERROR_NONE != ret) {
1662 log_print(NET_POPUP, "Failed to get _SYSPOPUP_CONTENT_ ret = %d", ret);
1668 secure_log_print(NET_POPUP, "_SYSPOPUP_CONTENT_ = %s\n", mode);
1670 win = __net_popup_create_win();
1672 popup = elm_popup_add(win);
1673 evas_object_size_hint_weight_set(popup, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
1674 if (strcmp(mode, "connected") == 0) {
1675 elm_object_text_set(popup, ALERT_STR_MOBILE_NETWORKS_CHARGE);
1676 log_print(NET_POPUP, "alert 3g\n");
1677 } else if (strcmp(mode, "fail to connect") == 0) {
1678 elm_object_text_set(popup, ALERT_STR_ERR_UNAVAILABLE);
1679 log_print(NET_POPUP, "alert err\n");
1680 } else if (strcmp(mode, "unable to connect") == 0) {
1681 elm_object_text_set(popup, ALERT_STR_ERR_CONNECT);
1682 log_print(NET_POPUP, "alert unable to connect\n");
1683 } else if (strcmp(mode, "wrong password") == 0) {
1684 elm_object_text_set(popup, ALERT_STR_ERR_WRONG_PASSWORD);
1685 log_print(NET_POPUP, "alert wrong password\n");
1686 } else if (strcmp(mode, "not support") == 0) {
1687 elm_object_text_set(popup, ALERT_STR_ERR_NOT_SUPPORT);
1688 log_print(NET_POPUP, "alert not support\n");
1689 } else if (strcmp(mode, "wifi restricted") == 0) {
1690 elm_object_text_set(popup, ALERT_STR_RESTRICTED_USE_WIFI);
1691 log_print(NET_POPUP, "alert wifi restricted\n");
1692 } else if (strcmp(mode, "no ap found") == 0) {
1693 elm_object_text_set(popup, ALERT_STR_NO_AP_FOUND);
1694 log_print(NET_POPUP, "alert no ap found\n");
1695 } else if (strcmp(mode, "wifi connected") == 0) {
1696 char buf[ALERT_STR_LEN_MAX] = "";
1697 char *ap_name = NULL;
1699 ret = app_control_get_extra_data(request, "_AP_NAME_", &ap_name);
1701 if (ap_name != NULL)
1702 g_snprintf(buf, ALERT_STR_LEN_MAX, ALERT_STR_WIFI_CONNECTED, ap_name);
1704 g_snprintf(buf, ALERT_STR_LEN_MAX, ALERT_STR_WIFI_CONNECTED, "");
1706 elm_object_text_set(popup, buf);
1708 log_print(NET_POPUP, "alert wifi connected\n");
1711 elm_object_text_set(popup, mode);
1712 log_print(NET_POPUP, "%s\n", mode);
1715 button = elm_button_add(popup);
1716 elm_object_style_set(button, "popup");
1717 elm_object_text_set(button, ALERT_STR_OK);
1718 elm_object_part_content_set(popup, "button1", button);
1719 evas_object_smart_callback_add(button, "clicked", _ok_button_clicked_cb, popup);
1720 evas_object_show(popup);
1721 evas_object_show(win);
1727 static void __net_popup_add_found_ap_noti(void)
1729 log_print(NET_POPUP, "__net_popup_add_found_ap_noti()\n");
1731 int ret = 0, noti_flags = 0;
1732 char icon_path[ICON_PATH_LEN];
1733 notification_h noti = NULL;
1734 notification_list_h noti_list = NULL;
1735 notification_error_e noti_err = NOTIFICATION_ERROR_NONE;
1736 app_control_h service_handle = NULL;
1738 notification_get_detail_list("net.netpopup", NOTIFICATION_GROUP_ID_NONE,
1739 NOTIFICATION_PRIV_ID_NONE, -1, ¬i_list);
1740 if (noti_list != NULL) {
1741 notification_free_list(noti_list);
1745 noti = notification_create(NOTIFICATION_TYPE_ONGOING);
1747 log_print(NET_POPUP, "Failed to create notification");
1751 noti_err = notification_set_time(noti, time(NULL));
1752 if (noti_err != NOTIFICATION_ERROR_NONE) {
1753 log_print(NET_POPUP, "Failed to notification_set_time : %d", noti_err);
1757 g_snprintf(icon_path, sizeof(icon_path), "%s%s", QP_PRELOAD_NOTI_ICON_PATH, "/noti_wifi_in_range.png");
1758 noti_err = notification_set_image(noti, NOTIFICATION_IMAGE_TYPE_ICON, icon_path);
1759 if (noti_err != NOTIFICATION_ERROR_NONE) {
1760 log_print(NET_POPUP, "Failed to notification_set_image : %d", noti_err);
1764 noti_err = notification_set_layout(noti, NOTIFICATION_LY_ONGOING_EVENT);
1765 if (noti_err != NOTIFICATION_ERROR_NONE) {
1766 log_print(NET_POPUP, "Failed to notification_set_layout : %d", noti_err);
1770 noti_err = notification_set_text_domain(noti, PACKAGE,
1772 if (noti_err != NOTIFICATION_ERROR_NONE) {
1773 log_print(NET_POPUP, "Failed to notification_set_text_domain : %d", noti_err);
1777 noti_err = notification_set_text(noti, NOTIFICATION_TEXT_TYPE_TITLE,
1778 NETCONFIG_NOTIFICATION_WIFI_FOUND_TITLE,
1779 "IDS_COM_BODY_WI_FI_NETWORKS_AVAILABLE",
1780 NOTIFICATION_VARIABLE_TYPE_NONE);
1781 if (noti_err != NOTIFICATION_ERROR_NONE) {
1782 log_print(NET_POPUP, "Failed to notification_set_title : %d", noti_err);
1786 noti_err = notification_set_text(noti, NOTIFICATION_TEXT_TYPE_CONTENT,
1787 NETCONFIG_NOTIFICATION_WIFI_FOUND_CONTENT,
1788 "IDS_WIFI_SBODY_TAP_HERE_TO_CONNECT",
1789 NOTIFICATION_VARIABLE_TYPE_NONE);
1790 if (noti_err != NOTIFICATION_ERROR_NONE) {
1791 log_print(NET_POPUP, "Failed to notification_set_content: %d", noti_err);
1795 noti_flags = NOTIFICATION_DISPLAY_APP_NOTIFICATION_TRAY | NOTIFICATION_DISPLAY_APP_INDICATOR;
1796 noti_err = notification_set_display_applist(noti, noti_flags);
1797 if (noti_err != NOTIFICATION_ERROR_NONE) {
1798 log_print(NET_POPUP, "Failed to notification_set_display_applist: %d", noti_err);
1802 ret = app_control_create(&service_handle);
1803 log_print(NET_POPUP, "Service create ret[%d]", ret);
1804 if (ret != APP_CONTROL_ERROR_NONE)
1807 ret = app_control_set_app_id(service_handle, NET_WIFIQS_APPID);
1808 log_print(NET_POPUP, "Service set app id ret = %d", ret);
1809 if (ret != APP_CONTROL_ERROR_NONE)
1812 ret = app_control_add_extra_data(service_handle, "caller", "notification");
1813 log_print(NET_POPUP, "Service data addition ret = %d", ret);
1814 if (ret != APP_CONTROL_ERROR_NONE)
1817 noti_err = notification_set_launch_option(noti,
1818 NOTIFICATION_LAUNCH_OPTION_APP_CONTROL, service_handle);
1819 if (noti_err != NOTIFICATION_ERROR_NONE) {
1820 log_print(NET_POPUP, "Failed to notification_set_launch_option");
1824 noti_err = notification_post(noti);
1825 if (noti_err != NOTIFICATION_ERROR_NONE) {
1826 log_print(NET_POPUP, "Failed to insert notification[error# is %d]", noti_err);
1830 log_print(NET_POPUP, "Successfully added notification");
1835 notification_free(noti);
1838 static void __net_popup_del_found_ap_noti(void)
1840 log_print(NET_POPUP, "__net_popup_del_found_ap_noti()\n");
1842 notification_error_e noti_err = NOTIFICATION_ERROR_NONE;
1844 noti_err = notification_delete_all(NOTIFICATION_TYPE_ONGOING);
1845 if (noti_err != NOTIFICATION_ERROR_NONE) {
1846 log_print(NET_POPUP, "fail to notification_delete_by_priv_id");
1850 log_print(NET_POPUP, "Successfully deleted notification");
1853 static void __net_popup_add_ip_conflict_noti(app_control_h request)
1855 log_print(NET_POPUP, "__net_popup_add_portal_noti()\n");
1860 char icon_path[ICON_PATH_LEN];
1861 notification_h noti = NULL;
1862 app_control_h service_handle = NULL;
1863 notification_list_h noti_list = NULL;
1864 notification_error_e noti_err = NOTIFICATION_ERROR_NONE;
1866 ret = app_control_get_extra_data(request, "_MAC_ADDRESS_", &mac);
1868 if (mac == NULL || ret != APP_CONTROL_ERROR_NONE) {
1869 log_print(NET_POPUP, "Failed to retrieve mac address!!");
1874 log_print(NET_POPUP, "Successfully added notification");
1876 notification_get_detail_list("net.netpopup", NOTIFICATION_GROUP_ID_NONE,
1877 NOTIFICATION_PRIV_ID_NONE, -1, ¬i_list);
1878 if (noti_list != NULL) {
1879 notification_free_list(noti_list);
1884 noti = notification_create(NOTIFICATION_TYPE_NOTI);
1886 log_print(NET_POPUP, "fail to create notification");
1891 noti_err = notification_set_time(noti, time(NULL));
1892 if (noti_err != NOTIFICATION_ERROR_NONE) {
1893 log_print(NET_POPUP, "fail to notification_set_time : %d", noti_err);
1897 noti_err = notification_set_image(noti, NOTIFICATION_IMAGE_TYPE_ICON,
1898 NETCONFIG_NOTIFICATION_WIFI_ICON_LITE);
1899 if (noti_err != NOTIFICATION_ERROR_NONE) {
1900 log_print(NET_POPUP, "fail to notification_set_image : %d", noti_err);
1904 g_snprintf(icon_path, sizeof(icon_path), "%s%s", QP_PRELOAD_NOTI_ICON_PATH, "/noti_wifi_in_range_ongoing.png");
1905 noti_err = notification_set_image(noti, NOTIFICATION_IMAGE_TYPE_ICON, icon_path);
1906 if (noti_err != NOTIFICATION_ERROR_NONE) {
1907 log_print(NET_POPUP, "fail to notification_set_image : %d", noti_err);
1911 noti_err = notification_set_layout(noti, NOTIFICATION_LY_NOTI_EVENT_MULTIPLE);
1912 if (noti_err != NOTIFICATION_ERROR_NONE) {
1913 log_print(NET_POPUP, "fail to notification_set_layout : %d", noti_err);
1917 noti_err = notification_set_text_domain(noti, PACKAGE,
1919 if (noti_err != NOTIFICATION_ERROR_NONE) {
1920 log_print(NET_POPUP, "fail to notification_set_text_domain : %d", noti_err);
1924 noti_err = notification_set_text(noti, NOTIFICATION_TEXT_TYPE_TITLE,
1925 NETCONFIG_NOTIFICATION_IP_CONFLICT_TITLE,
1927 NOTIFICATION_VARIABLE_TYPE_NONE);
1928 if (noti_err != NOTIFICATION_ERROR_NONE) {
1929 log_print(NET_POPUP, "fail to notification_set_title : %d", noti_err);
1933 noti_err = notification_set_text(noti, NOTIFICATION_TEXT_TYPE_CONTENT,
1934 NETCONFIG_NOTIFICATION_WIFI_PORTAL_CONTENT,
1935 NETCONFIG_NOTIFICATION_WIFI_PORTAL_CONTENT,
1936 NOTIFICATION_VARIABLE_TYPE_STRING, mac,
1937 NOTIFICATION_VARIABLE_TYPE_NONE);
1938 if (noti_err != NOTIFICATION_ERROR_NONE) {
1939 log_print(NET_POPUP, "fail to notification_set_content : %d", noti_err);
1943 noti_flags = NOTIFICATION_DISPLAY_APP_NOTIFICATION_TRAY | NOTIFICATION_DISPLAY_APP_INDICATOR;
1944 noti_err = notification_set_display_applist(noti, noti_flags);
1945 if (noti_err != NOTIFICATION_ERROR_NONE) {
1946 log_print(NET_POPUP, "fail to notification_set_display_applist : %d", noti_err);
1950 ret = app_control_create(&service_handle);
1951 log_print(NET_POPUP, "service create ret[%d]", ret);
1952 if (ret != APP_CONTROL_ERROR_NONE)
1955 ret = app_control_set_app_id(service_handle, WIFI_EFL_UG);
1956 log_print(NET_POPUP, "Service set app id ret = %d", ret);
1957 if (ret != APP_CONTROL_ERROR_NONE)
1960 ret = app_control_add_extra_data(service_handle, "caller", "notification");
1961 log_print(NET_POPUP, "Service data addition ret = %d", ret);
1962 if (ret != APP_CONTROL_ERROR_NONE)
1965 noti_err = notification_set_launch_option(noti,
1966 NOTIFICATION_LAUNCH_OPTION_APP_CONTROL, service_handle);
1967 if (noti_err != NOTIFICATION_ERROR_NONE) {
1968 log_print(NET_POPUP, "fail to notification_set_launch_option");
1972 noti_err = notification_post(noti);
1973 if (noti_err != NOTIFICATION_ERROR_NONE) {
1974 log_print(NET_POPUP, "fail to notification_post");
1978 log_print(NET_POPUP, "Successfully added notification");
1983 notification_free(noti);
1985 if (service_handle != NULL)
1986 app_control_destroy(service_handle);
1989 static void __net_popup_add_portal_noti(app_control_h request)
1991 log_print(NET_POPUP, "__net_popup_add_portal_noti()\n");
1995 char *ap_name = NULL;
1996 char icon_path[ICON_PATH_LEN];
1997 notification_h noti = NULL;
1998 app_control_h service_handle = NULL;
1999 notification_list_h noti_list = NULL;
2000 notification_error_e noti_err = NOTIFICATION_ERROR_NONE;
2002 ret = app_control_get_extra_data(request, "_AP_NAME_", &ap_name);
2004 if (ap_name == NULL || ret != APP_CONTROL_ERROR_NONE) {
2005 log_print(NET_POPUP, "Failed to retrieve connected AP name!!");
2010 log_print(NET_POPUP, "Successfully added notification");
2012 notification_get_detail_list("net.netpopup", NOTIFICATION_GROUP_ID_NONE,
2013 NOTIFICATION_PRIV_ID_NONE, -1, ¬i_list);
2014 if (noti_list != NULL) {
2015 notification_free_list(noti_list);
2020 noti = notification_create(NOTIFICATION_TYPE_NOTI);
2022 log_print(NET_POPUP, "fail to create notification");
2027 noti_err = notification_set_time(noti, time(NULL));
2028 if (noti_err != NOTIFICATION_ERROR_NONE) {
2029 log_print(NET_POPUP, "fail to notification_set_time : %d", noti_err);
2033 noti_err = notification_set_image(noti, NOTIFICATION_IMAGE_TYPE_ICON,
2034 NETCONFIG_NOTIFICATION_WIFI_ICON);
2035 if (noti_err != NOTIFICATION_ERROR_NONE) {
2036 log_print(NET_POPUP, "fail to notification_set_image : %d", noti_err);
2040 g_snprintf(icon_path, sizeof(icon_path), "%s%s", QP_PRELOAD_NOTI_ICON_PATH, "/noti_wifi_in_range.png");
2041 noti_err = notification_set_image(noti, NOTIFICATION_IMAGE_TYPE_ICON, icon_path);
2042 if (noti_err != NOTIFICATION_ERROR_NONE) {
2043 log_print(NET_POPUP, "fail to notification_set_image : %d", noti_err);
2046 noti_err = notification_set_layout(noti, NOTIFICATION_LY_NOTI_EVENT_MULTIPLE);
2047 if (noti_err != NOTIFICATION_ERROR_NONE) {
2048 log_print(NET_POPUP, "fail to notification_set_layout : %d", noti_err);
2052 noti_err = notification_set_text_domain(noti, PACKAGE,
2054 if (noti_err != NOTIFICATION_ERROR_NONE) {
2055 log_print(NET_POPUP, "fail to notification_set_text_domain : %d", noti_err);
2059 noti_err = notification_set_text(noti, NOTIFICATION_TEXT_TYPE_TITLE,
2060 NETCONFIG_NOTIFICATION_WIFI_PORTAL_TITLE,
2061 "IDS_WIFI_HEADER_SIGN_IN_TO_WI_FI_NETWORK_ABB",
2062 NOTIFICATION_VARIABLE_TYPE_NONE);
2063 if (noti_err != NOTIFICATION_ERROR_NONE) {
2064 log_print(NET_POPUP, "fail to notification_set_title : %d", noti_err);
2068 noti_err = notification_set_text(noti, NOTIFICATION_TEXT_TYPE_CONTENT,
2069 NETCONFIG_NOTIFICATION_WIFI_PORTAL_CONTENT,
2070 NETCONFIG_NOTIFICATION_WIFI_PORTAL_CONTENT,
2071 NOTIFICATION_VARIABLE_TYPE_STRING, ap_name,
2072 NOTIFICATION_VARIABLE_TYPE_NONE);
2073 if (noti_err != NOTIFICATION_ERROR_NONE) {
2074 log_print(NET_POPUP, "fail to notification_set_content : %d", noti_err);
2078 noti_flags = NOTIFICATION_DISPLAY_APP_NOTIFICATION_TRAY | NOTIFICATION_DISPLAY_APP_INDICATOR;
2079 noti_err = notification_set_display_applist(noti, noti_flags);
2080 if (noti_err != NOTIFICATION_ERROR_NONE) {
2081 log_print(NET_POPUP, "fail to notification_set_display_applist : %d", noti_err);
2085 ret = app_control_create(&service_handle);
2086 log_print(NET_POPUP, "service create ret[%d]", ret);
2087 if (ret != APP_CONTROL_ERROR_NONE)
2090 ret = app_control_set_operation(service_handle, APP_CONTROL_OPERATION_VIEW);
2091 if (ret != APP_CONTROL_ERROR_NONE)
2094 log_print(NET_POPUP, "service set operation is successful");
2096 ret = app_control_set_uri(service_handle, "http://www.google.com");
2098 if (ret != APP_CONTROL_ERROR_NONE)
2101 noti_err = notification_set_launch_option(noti,
2102 NOTIFICATION_LAUNCH_OPTION_APP_CONTROL, service_handle);
2103 if (noti_err != NOTIFICATION_ERROR_NONE) {
2104 log_print(NET_POPUP, "fail to notification_set_launch_option");
2108 noti_err = notification_post(noti);
2109 if (noti_err != NOTIFICATION_ERROR_NONE) {
2110 log_print(NET_POPUP, "fail to notification_post");
2114 log_print(NET_POPUP, "Successfully added notification");
2119 notification_free(noti);
2121 if (service_handle != NULL)
2122 app_control_destroy(service_handle);
2125 static void __net_popup_del_ip_conflict_noti(void)
2127 log_print(NET_POPUP, "__net_popup_del_ip_conflict_noti()\n");
2129 notification_error_e noti_err = NOTIFICATION_ERROR_NONE;
2131 noti_err = notification_delete_all(NOTIFICATION_TYPE_NOTI);
2132 if (noti_err != NOTIFICATION_ERROR_NONE) {
2133 log_print(NET_POPUP, "fail to notification_delete_all");
2137 log_print(NET_POPUP, "Successfully deleted notification");
2140 static void __net_popup_del_portal_noti(void)
2142 log_print(NET_POPUP, "__net_popup_del_portal_noti()\n");
2144 notification_error_e noti_err = NOTIFICATION_ERROR_NONE;
2146 noti_err = notification_delete_all(NOTIFICATION_TYPE_NOTI);
2147 if (noti_err != NOTIFICATION_ERROR_NONE) {
2148 log_print(NET_POPUP, "fail to notification_delete_all");
2152 log_print(NET_POPUP, "Successfully deleted notification");
2155 EXPORT_API int main(int argc, char *argv[])
2157 log_print(NET_POPUP, "main()\n");
2159 ui_app_lifecycle_callback_s app_callback = {
2160 .create = __net_popup_create,
2161 .terminate = __net_popup_terminate,
2162 .pause = __net_popup_pause,
2163 .resume = __net_popup_resume,
2164 .app_control = __net_popup_service_cb,
2167 return ui_app_main(argc, argv, &app_callback, NULL);