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 static void __data_usage_btn_on_cb(void *data, Evas_Object *obj, void *event_info)
1332 log_print(NET_POPUP, "__data_usage_btn_on_cb()");
1333 Evas_Object *popup = (Evas_Object *)data;
1335 __net_popup_init_dbus();
1336 __net_popup_send_data_usage_msg(data_usage_app_id, data_usage_iftype);
1337 __net_popup_deinit_dbus();
1339 __data_usage_notification(NOTIFICATION_TYPE_ONGOING,
1340 NOTIFICATION_LY_ONGOING_EVENT,
1341 STC_NOTIFICATION_RESTRICTION_ON_TITLE,
1342 "IDS_SM_TMBODY_MOBILE_DATA_LIMIT_EXCEEDED_ABB",
1346 evas_object_del(popup);
1348 evas_object_del(obj);
1350 g_free(data_usage_app_id);
1351 g_free(data_usage_iftype);
1356 static void __data_usage_btn_ok_cb(void *data, Evas_Object *obj, void *event_info)
1358 log_print(NET_POPUP, "__data_usage_btn_ok_cb()");
1359 Evas_Object *popup = (Evas_Object *)data;
1361 __data_usage_notification(NOTIFICATION_TYPE_ONGOING,
1362 NOTIFICATION_LY_ONGOING_EVENT,
1363 STC_NOTIFICATION_RESTRICTION_OK_TITLE,
1364 "IDS_SM_HEADER_MOBILE_DATA_TURNED_OFF_ABB2",
1365 STC_NOTIFICATION_RESTRICTION_OK_CONTENT,
1366 "IDS_SM_SBODY_TAP_HERE_TO_TURN_IT_ON_AGAIN_ABB",
1370 evas_object_del(popup);
1372 evas_object_del(obj);
1374 g_free(data_usage_app_id);
1375 g_free(data_usage_iftype);
1380 static void __net_popup_show_popup_with_user_resp(app_control_h request,
1383 log_print(NET_POPUP, "__net_popup_show_popup_with_user_resp()\n");
1387 Evas_Object *layout;
1393 ret = app_control_get_extra_data(request, "_SYSPOPUP_CONTENT_", &resp_popup_mode);
1394 if (APP_CONTROL_ERROR_NONE != ret)
1395 log_print(NET_POPUP, "Failed to get _SYSPOPUP_CONTENT_ ret = %d", ret);
1397 secure_log_print(NET_POPUP, "_SYSPOPUP_CONTENT_ = %s\n", resp_popup_mode);
1399 win = __net_popup_create_win();
1400 evas_object_show(win);
1402 popup = elm_popup_add(win);
1403 evas_object_size_hint_weight_set(popup, EVAS_HINT_EXPAND,
1406 if (g_strcmp0(resp_popup_mode, "TETHERING_TYPE_WIFI") == 0 ||
1407 g_strcmp0(resp_popup_mode, "TETHERING_TYPE_WIFI_AP") == 0) {
1408 log_print(NET_POPUP, "Drawing Wi-Fi Tethering OFF popup");
1410 __net_popup_init_dbus();
1411 elm_object_part_text_set(popup, "title,text", ALERT_STR_WIFI);
1413 layout = elm_layout_add(popup);
1414 elm_layout_file_set(layout, NETPOPUP_EDJ, "popup");
1415 evas_object_size_hint_weight_set(layout, EVAS_HINT_EXPAND,
1418 __net_popup_send_dbus_msg("progress_on");
1419 label = elm_label_add(popup);
1420 elm_label_line_wrap_set(label, ELM_WRAP_MIXED);
1421 elm_object_text_set(label, ALERT_STR_WIFI_MOBILE_AP_ON);
1422 evas_object_size_hint_weight_set(label, EVAS_HINT_EXPAND,
1424 evas_object_size_hint_align_set(label, EVAS_HINT_FILL, EVAS_HINT_FILL);
1425 evas_object_show(label);
1427 elm_object_part_content_set(layout, "elm.swallow.content", label);
1428 evas_object_show(layout);
1429 elm_object_style_set(label, "popup/default");
1430 eext_object_event_callback_add(popup, EEXT_CALLBACK_BACK, _btn_no_cb, popup);
1431 elm_object_content_set(popup, label);
1433 btn1 = elm_button_add(popup);
1434 elm_object_style_set(btn1, "popup");
1435 elm_object_text_set(btn1, ALERT_STR_CANCEL);
1436 elm_object_part_content_set(popup, "button1", btn1);
1437 evas_object_smart_callback_add(btn1, "clicked",
1440 btn2 = elm_button_add(popup);
1441 elm_object_style_set(btn2, "popup");
1442 elm_object_text_set(btn2, ALERT_STR_OK);
1443 elm_object_part_content_set(popup, "button2", btn2);
1445 if (g_strcmp0(resp_popup_mode, "TETHERING_TYPE_WIFI") == 0)
1446 evas_object_smart_callback_add(btn2, "clicked",
1447 _tethering_wifi_btn_yes_cb, popup);
1448 else if (g_strcmp0(resp_popup_mode, "TETHERING_TYPE_WIFI_AP") == 0)
1449 evas_object_smart_callback_add(btn2, "clicked",
1450 _tethering_wifi_ap_btn_yes_cb, popup);
1452 evas_object_show(popup);
1453 evas_object_show(win);
1454 __net_popup_deinit_dbus();
1458 static void __net_popup_show_vpn_popup(app_control_h request, void *data)
1462 Evas_Object *button1;
1463 Evas_Object *button2;
1466 char *content = NULL;
1467 char *ok_btn = NULL;
1470 log_print(NET_POPUP, "__net_popup_show_vpn_popup");
1472 int ret = app_control_get_extra_data(request, APP_CONTROL_DATA_TYPE, &type);
1473 if (APP_CONTROL_ERROR_NONE != ret) {
1474 log_print(NET_POPUP, "Failed to get APP_CONTROL_DATA_TYPE ret = %d", ret);
1479 ret = app_control_get_extra_data(request, APP_CONTROL_DATA_NAME, &iface_name);
1480 if (APP_CONTROL_ERROR_NONE != ret) {
1481 log_print(NET_POPUP, "Failed to get APP_CONTROL_DATA_NAME ret = %d", ret);
1485 log_print(NET_POPUP, "type(%s) name(%s)", type, iface_name);
1487 if (strcmp(type, "up") == 0) {
1488 title = ALERT_STR_VPN_CONNECT_TITLE;
1489 content = ALERT_STR_VPN_CONNECT_CONTENT;
1490 ok_btn = ALERT_STR_VPN_CONNECT_BUTTON;
1491 ok_cb = _vpn_btn_connect_cb;
1492 } else if (strcmp(type, "down") == 0) {
1493 title = ALERT_STR_VPN_DISCONNECT_TITLE;
1494 content = ALERT_STR_VPN_DISCONNECT_CONTENT;
1495 ok_btn = ALERT_STR_VPN_DISCONNECT_BUTTON;
1496 ok_cb = _vpn_btn_disconnect_cb;
1498 log_print(NET_POPUP, "Invalid appcontrol value");
1503 log_print(NET_POPUP, "title(%s) content(%s) ok(%s)", title, content, ok_btn);
1505 win = __net_popup_create_win();
1507 popup = elm_popup_add(win);
1508 evas_object_size_hint_weight_set(popup, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
1510 elm_object_text_set(popup, content);
1511 elm_object_part_text_set(popup, "title,text", title);
1514 button1 = elm_button_add(popup);
1515 elm_object_style_set(button1, "bottom");
1516 elm_object_text_set(button1, ALERT_STR_CANCEL);
1517 elm_object_part_content_set(popup, "button1", button1);
1518 evas_object_smart_callback_add(button1, "clicked", _vpn_btn_no_cb, popup);
1521 button2 = elm_button_add(popup);
1522 elm_object_style_set(button2, "bottom");
1523 elm_object_text_set(button2, ok_btn);
1524 elm_object_part_content_set(popup, "button2", button2);
1525 evas_object_smart_callback_add(button2, "clicked", ok_cb, popup);
1527 evas_object_show(popup);
1528 evas_object_show(win);
1533 static void __net_popup_show_warning_noti(app_control_h request, void *data)
1535 log_print(NET_POPUP, "__net_popup_show_warning_noti()\n");
1537 int ret = app_control_get_extra_data(request, "_APP_ID_", &data_usage_app_id);
1538 if (APP_CONTROL_ERROR_NONE != ret) {
1539 log_print(NET_POPUP, "Failed to get _APP_ID_ ret = %d", ret);
1544 if (strcmp(data_usage_app_id, STC_TOTAL_DATACALL) &&
1545 strcmp(data_usage_app_id, STC_TOTAL_WIFI) &&
1546 strcmp(data_usage_app_id, STC_TOTAL_BLUETOOTH)) {
1547 log_print(NET_POPUP, "It's not total data usage [%s]", data_usage_app_id);
1548 g_free(data_usage_app_id);
1553 __data_usage_notification(NOTIFICATION_TYPE_ONGOING,
1554 NOTIFICATION_LY_ONGOING_EVENT,
1555 STC_NOTIFICATION_WARNING_TITLE,
1556 "IDS_COM_BODY_DATA_USAGE_WARNING",
1557 STC_NOTIFICATION_WARNING_CONTENT,
1558 "IDS_SM_SBODY_TAP_HERE_TO_VIEW_YOUR_DATA_USAGE_ABB",
1562 static void __net_popup_show_restriction_noti(app_control_h request, void *data)
1566 Evas_Object *button1;
1567 Evas_Object *button2;
1569 char *content = NULL;
1571 char *on_btn = NULL;
1572 char *ok_btn = NULL;
1573 char buf[ALERT_STR_LEN_MAX] = "";
1575 log_print(NET_POPUP, "__net_popup_show_data_usage_popup");
1577 int ret = app_control_get_extra_data(request, "_APP_ID_", &data_usage_app_id);
1578 if (APP_CONTROL_ERROR_NONE != ret) {
1579 log_print(NET_POPUP, "Failed to get _APP_ID_ ret = %d", ret);
1584 if (strcmp(data_usage_app_id, STC_TOTAL_DATACALL) &&
1585 strcmp(data_usage_app_id, STC_TOTAL_WIFI) &&
1586 strcmp(data_usage_app_id, STC_TOTAL_BLUETOOTH)) {
1587 log_print(NET_POPUP, "It's not total data usage [%s]", data_usage_app_id);
1588 g_free(data_usage_app_id);
1593 ret = app_control_get_extra_data(request, "_IF_TYPE_", &data_usage_iftype);
1594 if (APP_CONTROL_ERROR_NONE != ret) {
1595 log_print(NET_POPUP, "Failed to get _IF_TYPE_ ret = %d", ret);
1596 g_free(data_usage_app_id);
1601 ret = app_control_get_extra_data(request, "_RESTRICTION_LIMIT_", &limit);
1602 if (APP_CONTROL_ERROR_NONE != ret) {
1603 log_print(NET_POPUP, "Failed to get _RESTRICTION_LIMIT_ ret = %d", ret);
1604 g_free(data_usage_app_id);
1605 g_free(data_usage_iftype);
1610 title = ALERT_STR_DATA_USAGE_TITLE;
1611 g_snprintf(buf, ALERT_STR_LEN_MAX, ALERT_STR_DATA_USAGE_CONTENT, limit);
1613 on_btn = ALERT_STR_DATA_USAGE_TURN_ON_BUTTON;
1614 ok_btn = ALERT_STR_OK;
1616 log_print(NET_POPUP, "title(%s) content(%s) app_id(%s) iftype(%s) limit(%s)",
1617 title, content, data_usage_app_id, data_usage_iftype, limit);
1619 win = __net_popup_create_win();
1621 popup = elm_popup_add(win);
1622 evas_object_size_hint_weight_set(popup, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
1624 elm_object_text_set(popup, content);
1625 elm_object_part_text_set(popup, "title,text", title);
1628 button1 = elm_button_add(popup);
1629 elm_object_style_set(button1, "bottom");
1630 elm_object_text_set(button1, on_btn);
1631 elm_object_part_content_set(popup, "button1", button1);
1632 evas_object_smart_callback_add(button1, "clicked", __data_usage_btn_on_cb, popup);
1635 button2 = elm_button_add(popup);
1636 elm_object_style_set(button2, "bottom");
1637 elm_object_text_set(button2, ok_btn);
1638 elm_object_part_content_set(popup, "button2", button2);
1639 evas_object_smart_callback_add(button2, "clicked", __data_usage_btn_ok_cb, popup);
1641 evas_object_show(popup);
1642 evas_object_show(win);
1647 static int __net_popup_show_popup(app_control_h request, void *data)
1649 log_print(NET_POPUP, "__net_popup_show_popup()\n");
1653 Evas_Object *button;
1657 ret = app_control_get_extra_data(request, "_SYSPOPUP_CONTENT_", &mode);
1658 if (APP_CONTROL_ERROR_NONE != ret) {
1659 log_print(NET_POPUP, "Failed to get _SYSPOPUP_CONTENT_ ret = %d", ret);
1665 secure_log_print(NET_POPUP, "_SYSPOPUP_CONTENT_ = %s\n", mode);
1667 win = __net_popup_create_win();
1669 popup = elm_popup_add(win);
1670 evas_object_size_hint_weight_set(popup, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
1671 if (strcmp(mode, "connected") == 0) {
1672 elm_object_text_set(popup, ALERT_STR_MOBILE_NETWORKS_CHARGE);
1673 log_print(NET_POPUP, "alert 3g\n");
1674 } else if (strcmp(mode, "fail to connect") == 0) {
1675 elm_object_text_set(popup, ALERT_STR_ERR_UNAVAILABLE);
1676 log_print(NET_POPUP, "alert err\n");
1677 } else if (strcmp(mode, "unable to connect") == 0) {
1678 elm_object_text_set(popup, ALERT_STR_ERR_CONNECT);
1679 log_print(NET_POPUP, "alert unable to connect\n");
1680 } else if (strcmp(mode, "wrong password") == 0) {
1681 elm_object_text_set(popup, ALERT_STR_ERR_WRONG_PASSWORD);
1682 log_print(NET_POPUP, "alert wrong password\n");
1683 } else if (strcmp(mode, "not support") == 0) {
1684 elm_object_text_set(popup, ALERT_STR_ERR_NOT_SUPPORT);
1685 log_print(NET_POPUP, "alert not support\n");
1686 } else if (strcmp(mode, "wifi restricted") == 0) {
1687 elm_object_text_set(popup, ALERT_STR_RESTRICTED_USE_WIFI);
1688 log_print(NET_POPUP, "alert wifi restricted\n");
1689 } else if (strcmp(mode, "no ap found") == 0) {
1690 elm_object_text_set(popup, ALERT_STR_NO_AP_FOUND);
1691 log_print(NET_POPUP, "alert no ap found\n");
1692 } else if (strcmp(mode, "wifi connected") == 0) {
1693 char buf[ALERT_STR_LEN_MAX] = "";
1694 char *ap_name = NULL;
1696 ret = app_control_get_extra_data(request, "_AP_NAME_", &ap_name);
1698 if (ap_name != NULL)
1699 g_snprintf(buf, ALERT_STR_LEN_MAX, ALERT_STR_WIFI_CONNECTED, ap_name);
1701 g_snprintf(buf, ALERT_STR_LEN_MAX, ALERT_STR_WIFI_CONNECTED, "");
1703 elm_object_text_set(popup, buf);
1705 log_print(NET_POPUP, "alert wifi connected\n");
1708 elm_object_text_set(popup, mode);
1709 log_print(NET_POPUP, "%s\n", mode);
1712 button = elm_button_add(popup);
1713 elm_object_style_set(button, "popup");
1714 elm_object_text_set(button, ALERT_STR_OK);
1715 elm_object_part_content_set(popup, "button1", button);
1716 evas_object_smart_callback_add(button, "clicked", _ok_button_clicked_cb, popup);
1717 evas_object_show(popup);
1718 evas_object_show(win);
1724 static void __net_popup_add_found_ap_noti(void)
1726 log_print(NET_POPUP, "__net_popup_add_found_ap_noti()\n");
1728 int ret = 0, noti_flags = 0;
1729 char icon_path[ICON_PATH_LEN];
1730 notification_h noti = NULL;
1731 notification_list_h noti_list = NULL;
1732 notification_error_e noti_err = NOTIFICATION_ERROR_NONE;
1733 app_control_h service_handle = NULL;
1735 notification_get_detail_list("net.netpopup", NOTIFICATION_GROUP_ID_NONE,
1736 NOTIFICATION_PRIV_ID_NONE, -1, ¬i_list);
1737 if (noti_list != NULL) {
1738 notification_free_list(noti_list);
1742 noti = notification_create(NOTIFICATION_TYPE_ONGOING);
1744 log_print(NET_POPUP, "Failed to create notification");
1748 noti_err = notification_set_time(noti, time(NULL));
1749 if (noti_err != NOTIFICATION_ERROR_NONE) {
1750 log_print(NET_POPUP, "Failed to notification_set_time : %d", noti_err);
1754 g_snprintf(icon_path, sizeof(icon_path), "%s%s", QP_PRELOAD_NOTI_ICON_PATH, "/noti_wifi_in_range.png");
1755 noti_err = notification_set_image(noti, NOTIFICATION_IMAGE_TYPE_ICON, icon_path);
1756 if (noti_err != NOTIFICATION_ERROR_NONE) {
1757 log_print(NET_POPUP, "Failed to notification_set_image : %d", noti_err);
1761 noti_err = notification_set_layout(noti, NOTIFICATION_LY_ONGOING_EVENT);
1762 if (noti_err != NOTIFICATION_ERROR_NONE) {
1763 log_print(NET_POPUP, "Failed to notification_set_layout : %d", noti_err);
1767 noti_err = notification_set_text_domain(noti, PACKAGE,
1769 if (noti_err != NOTIFICATION_ERROR_NONE) {
1770 log_print(NET_POPUP, "Failed to notification_set_text_domain : %d", noti_err);
1774 noti_err = notification_set_text(noti, NOTIFICATION_TEXT_TYPE_TITLE,
1775 NETCONFIG_NOTIFICATION_WIFI_FOUND_TITLE,
1776 "IDS_COM_BODY_WI_FI_NETWORKS_AVAILABLE",
1777 NOTIFICATION_VARIABLE_TYPE_NONE);
1778 if (noti_err != NOTIFICATION_ERROR_NONE) {
1779 log_print(NET_POPUP, "Failed to notification_set_title : %d", noti_err);
1783 noti_err = notification_set_text(noti, NOTIFICATION_TEXT_TYPE_CONTENT,
1784 NETCONFIG_NOTIFICATION_WIFI_FOUND_CONTENT,
1785 "IDS_WIFI_SBODY_TAP_HERE_TO_CONNECT",
1786 NOTIFICATION_VARIABLE_TYPE_NONE);
1787 if (noti_err != NOTIFICATION_ERROR_NONE) {
1788 log_print(NET_POPUP, "Failed to notification_set_content: %d", noti_err);
1792 noti_flags = NOTIFICATION_DISPLAY_APP_NOTIFICATION_TRAY | NOTIFICATION_DISPLAY_APP_INDICATOR;
1793 noti_err = notification_set_display_applist(noti, noti_flags);
1794 if (noti_err != NOTIFICATION_ERROR_NONE) {
1795 log_print(NET_POPUP, "Failed to notification_set_display_applist: %d", noti_err);
1799 ret = app_control_create(&service_handle);
1800 log_print(NET_POPUP, "Service create ret[%d]", ret);
1801 if (ret != APP_CONTROL_ERROR_NONE)
1804 ret = app_control_set_app_id(service_handle, NET_WIFIQS_APPID);
1805 log_print(NET_POPUP, "Service set app id ret = %d", ret);
1806 if (ret != APP_CONTROL_ERROR_NONE)
1809 ret = app_control_add_extra_data(service_handle, "caller", "notification");
1810 log_print(NET_POPUP, "Service data addition ret = %d", ret);
1811 if (ret != APP_CONTROL_ERROR_NONE)
1814 noti_err = notification_set_launch_option(noti,
1815 NOTIFICATION_LAUNCH_OPTION_APP_CONTROL, service_handle);
1816 if (noti_err != NOTIFICATION_ERROR_NONE) {
1817 log_print(NET_POPUP, "Failed to notification_set_launch_option");
1821 noti_err = notification_post(noti);
1822 if (noti_err != NOTIFICATION_ERROR_NONE) {
1823 log_print(NET_POPUP, "Failed to insert notification[error# is %d]", noti_err);
1827 log_print(NET_POPUP, "Successfully added notification");
1832 notification_free(noti);
1835 static void __net_popup_del_found_ap_noti(void)
1837 log_print(NET_POPUP, "__net_popup_del_found_ap_noti()\n");
1839 notification_error_e noti_err = NOTIFICATION_ERROR_NONE;
1841 noti_err = notification_delete_all(NOTIFICATION_TYPE_ONGOING);
1842 if (noti_err != NOTIFICATION_ERROR_NONE) {
1843 log_print(NET_POPUP, "fail to notification_delete_by_priv_id");
1847 log_print(NET_POPUP, "Successfully deleted notification");
1850 static void __net_popup_add_ip_conflict_noti(app_control_h request)
1852 log_print(NET_POPUP, "__net_popup_add_portal_noti()\n");
1857 char icon_path[ICON_PATH_LEN];
1858 notification_h noti = NULL;
1859 app_control_h service_handle = NULL;
1860 notification_list_h noti_list = NULL;
1861 notification_error_e noti_err = NOTIFICATION_ERROR_NONE;
1863 ret = app_control_get_extra_data(request, "_MAC_ADDRESS_", &mac);
1865 if (mac == NULL || ret != APP_CONTROL_ERROR_NONE) {
1866 log_print(NET_POPUP, "Failed to retrieve mac address!!");
1871 log_print(NET_POPUP, "Successfully added notification");
1873 notification_get_detail_list("net.netpopup", NOTIFICATION_GROUP_ID_NONE,
1874 NOTIFICATION_PRIV_ID_NONE, -1, ¬i_list);
1875 if (noti_list != NULL) {
1876 notification_free_list(noti_list);
1881 noti = notification_create(NOTIFICATION_TYPE_NOTI);
1883 log_print(NET_POPUP, "fail to create notification");
1888 noti_err = notification_set_time(noti, time(NULL));
1889 if (noti_err != NOTIFICATION_ERROR_NONE) {
1890 log_print(NET_POPUP, "fail to notification_set_time : %d", noti_err);
1894 noti_err = notification_set_image(noti, NOTIFICATION_IMAGE_TYPE_ICON,
1895 NETCONFIG_NOTIFICATION_WIFI_ICON_LITE);
1896 if (noti_err != NOTIFICATION_ERROR_NONE) {
1897 log_print(NET_POPUP, "fail to notification_set_image : %d", noti_err);
1901 g_snprintf(icon_path, sizeof(icon_path), "%s%s", QP_PRELOAD_NOTI_ICON_PATH, "/noti_wifi_in_range_ongoing.png");
1902 noti_err = notification_set_image(noti, NOTIFICATION_IMAGE_TYPE_ICON, icon_path);
1903 if (noti_err != NOTIFICATION_ERROR_NONE) {
1904 log_print(NET_POPUP, "fail to notification_set_image : %d", noti_err);
1908 noti_err = notification_set_layout(noti, NOTIFICATION_LY_NOTI_EVENT_MULTIPLE);
1909 if (noti_err != NOTIFICATION_ERROR_NONE) {
1910 log_print(NET_POPUP, "fail to notification_set_layout : %d", noti_err);
1914 noti_err = notification_set_text_domain(noti, PACKAGE,
1916 if (noti_err != NOTIFICATION_ERROR_NONE) {
1917 log_print(NET_POPUP, "fail to notification_set_text_domain : %d", noti_err);
1921 noti_err = notification_set_text(noti, NOTIFICATION_TEXT_TYPE_TITLE,
1922 NETCONFIG_NOTIFICATION_IP_CONFLICT_TITLE,
1924 NOTIFICATION_VARIABLE_TYPE_NONE);
1925 if (noti_err != NOTIFICATION_ERROR_NONE) {
1926 log_print(NET_POPUP, "fail to notification_set_title : %d", noti_err);
1930 noti_err = notification_set_text(noti, NOTIFICATION_TEXT_TYPE_CONTENT,
1931 NETCONFIG_NOTIFICATION_WIFI_PORTAL_CONTENT,
1932 NETCONFIG_NOTIFICATION_WIFI_PORTAL_CONTENT,
1933 NOTIFICATION_VARIABLE_TYPE_STRING, mac,
1934 NOTIFICATION_VARIABLE_TYPE_NONE);
1935 if (noti_err != NOTIFICATION_ERROR_NONE) {
1936 log_print(NET_POPUP, "fail to notification_set_content : %d", noti_err);
1940 noti_flags = NOTIFICATION_DISPLAY_APP_NOTIFICATION_TRAY | NOTIFICATION_DISPLAY_APP_INDICATOR;
1941 noti_err = notification_set_display_applist(noti, noti_flags);
1942 if (noti_err != NOTIFICATION_ERROR_NONE) {
1943 log_print(NET_POPUP, "fail to notification_set_display_applist : %d", noti_err);
1947 ret = app_control_create(&service_handle);
1948 log_print(NET_POPUP, "service create ret[%d]", ret);
1949 if (ret != APP_CONTROL_ERROR_NONE)
1952 ret = app_control_set_app_id(service_handle, WIFI_EFL_UG);
1953 log_print(NET_POPUP, "Service set app id ret = %d", ret);
1954 if (ret != APP_CONTROL_ERROR_NONE)
1957 ret = app_control_add_extra_data(service_handle, "caller", "notification");
1958 log_print(NET_POPUP, "Service data addition ret = %d", ret);
1959 if (ret != APP_CONTROL_ERROR_NONE)
1962 noti_err = notification_set_launch_option(noti,
1963 NOTIFICATION_LAUNCH_OPTION_APP_CONTROL, service_handle);
1964 if (noti_err != NOTIFICATION_ERROR_NONE) {
1965 log_print(NET_POPUP, "fail to notification_set_launch_option");
1969 noti_err = notification_post(noti);
1970 if (noti_err != NOTIFICATION_ERROR_NONE) {
1971 log_print(NET_POPUP, "fail to notification_post");
1975 log_print(NET_POPUP, "Successfully added notification");
1980 notification_free(noti);
1982 if (service_handle != NULL)
1983 app_control_destroy(service_handle);
1986 static void __net_popup_add_portal_noti(app_control_h request)
1988 log_print(NET_POPUP, "__net_popup_add_portal_noti()\n");
1992 char *ap_name = NULL;
1993 char icon_path[ICON_PATH_LEN];
1994 notification_h noti = NULL;
1995 app_control_h service_handle = NULL;
1996 notification_list_h noti_list = NULL;
1997 notification_error_e noti_err = NOTIFICATION_ERROR_NONE;
1999 ret = app_control_get_extra_data(request, "_AP_NAME_", &ap_name);
2001 if (ap_name == NULL || ret != APP_CONTROL_ERROR_NONE) {
2002 log_print(NET_POPUP, "Failed to retrieve connected AP name!!");
2007 log_print(NET_POPUP, "Successfully added notification");
2009 notification_get_detail_list("net.netpopup", NOTIFICATION_GROUP_ID_NONE,
2010 NOTIFICATION_PRIV_ID_NONE, -1, ¬i_list);
2011 if (noti_list != NULL) {
2012 notification_free_list(noti_list);
2017 noti = notification_create(NOTIFICATION_TYPE_NOTI);
2019 log_print(NET_POPUP, "fail to create notification");
2024 noti_err = notification_set_time(noti, time(NULL));
2025 if (noti_err != NOTIFICATION_ERROR_NONE) {
2026 log_print(NET_POPUP, "fail to notification_set_time : %d", noti_err);
2030 noti_err = notification_set_image(noti, NOTIFICATION_IMAGE_TYPE_ICON,
2031 NETCONFIG_NOTIFICATION_WIFI_ICON);
2032 if (noti_err != NOTIFICATION_ERROR_NONE) {
2033 log_print(NET_POPUP, "fail to notification_set_image : %d", noti_err);
2037 g_snprintf(icon_path, sizeof(icon_path), "%s%s", QP_PRELOAD_NOTI_ICON_PATH, "/noti_wifi_in_range.png");
2038 noti_err = notification_set_image(noti, NOTIFICATION_IMAGE_TYPE_ICON, icon_path);
2039 if (noti_err != NOTIFICATION_ERROR_NONE) {
2040 log_print(NET_POPUP, "fail to notification_set_image : %d", noti_err);
2043 noti_err = notification_set_layout(noti, NOTIFICATION_LY_NOTI_EVENT_MULTIPLE);
2044 if (noti_err != NOTIFICATION_ERROR_NONE) {
2045 log_print(NET_POPUP, "fail to notification_set_layout : %d", noti_err);
2049 noti_err = notification_set_text_domain(noti, PACKAGE,
2051 if (noti_err != NOTIFICATION_ERROR_NONE) {
2052 log_print(NET_POPUP, "fail to notification_set_text_domain : %d", noti_err);
2056 noti_err = notification_set_text(noti, NOTIFICATION_TEXT_TYPE_TITLE,
2057 NETCONFIG_NOTIFICATION_WIFI_PORTAL_TITLE,
2058 "IDS_WIFI_HEADER_SIGN_IN_TO_WI_FI_NETWORK_ABB",
2059 NOTIFICATION_VARIABLE_TYPE_NONE);
2060 if (noti_err != NOTIFICATION_ERROR_NONE) {
2061 log_print(NET_POPUP, "fail to notification_set_title : %d", noti_err);
2065 noti_err = notification_set_text(noti, NOTIFICATION_TEXT_TYPE_CONTENT,
2066 NETCONFIG_NOTIFICATION_WIFI_PORTAL_CONTENT,
2067 NETCONFIG_NOTIFICATION_WIFI_PORTAL_CONTENT,
2068 NOTIFICATION_VARIABLE_TYPE_STRING, ap_name,
2069 NOTIFICATION_VARIABLE_TYPE_NONE);
2070 if (noti_err != NOTIFICATION_ERROR_NONE) {
2071 log_print(NET_POPUP, "fail to notification_set_content : %d", noti_err);
2075 noti_flags = NOTIFICATION_DISPLAY_APP_NOTIFICATION_TRAY | NOTIFICATION_DISPLAY_APP_INDICATOR;
2076 noti_err = notification_set_display_applist(noti, noti_flags);
2077 if (noti_err != NOTIFICATION_ERROR_NONE) {
2078 log_print(NET_POPUP, "fail to notification_set_display_applist : %d", noti_err);
2082 ret = app_control_create(&service_handle);
2083 log_print(NET_POPUP, "service create ret[%d]", ret);
2084 if (ret != APP_CONTROL_ERROR_NONE)
2087 ret = app_control_set_operation(service_handle, APP_CONTROL_OPERATION_VIEW);
2088 if (ret != APP_CONTROL_ERROR_NONE)
2091 log_print(NET_POPUP, "service set operation is successful");
2093 ret = app_control_set_uri(service_handle, "http://www.google.com");
2095 if (ret != APP_CONTROL_ERROR_NONE)
2098 noti_err = notification_set_launch_option(noti,
2099 NOTIFICATION_LAUNCH_OPTION_APP_CONTROL, service_handle);
2100 if (noti_err != NOTIFICATION_ERROR_NONE) {
2101 log_print(NET_POPUP, "fail to notification_set_launch_option");
2105 noti_err = notification_post(noti);
2106 if (noti_err != NOTIFICATION_ERROR_NONE) {
2107 log_print(NET_POPUP, "fail to notification_post");
2111 log_print(NET_POPUP, "Successfully added notification");
2116 notification_free(noti);
2118 if (service_handle != NULL)
2119 app_control_destroy(service_handle);
2122 static void __net_popup_del_ip_conflict_noti(void)
2124 log_print(NET_POPUP, "__net_popup_del_ip_conflict_noti()\n");
2126 notification_error_e noti_err = NOTIFICATION_ERROR_NONE;
2128 noti_err = notification_delete_all(NOTIFICATION_TYPE_NOTI);
2129 if (noti_err != NOTIFICATION_ERROR_NONE) {
2130 log_print(NET_POPUP, "fail to notification_delete_all");
2134 log_print(NET_POPUP, "Successfully deleted notification");
2137 static void __net_popup_del_portal_noti(void)
2139 log_print(NET_POPUP, "__net_popup_del_portal_noti()\n");
2141 notification_error_e noti_err = NOTIFICATION_ERROR_NONE;
2143 noti_err = notification_delete_all(NOTIFICATION_TYPE_NOTI);
2144 if (noti_err != NOTIFICATION_ERROR_NONE) {
2145 log_print(NET_POPUP, "fail to notification_delete_all");
2149 log_print(NET_POPUP, "Successfully deleted notification");
2152 EXPORT_API int main(int argc, char *argv[])
2154 log_print(NET_POPUP, "main()\n");
2156 ui_app_lifecycle_callback_s app_callback = {
2157 .create = __net_popup_create,
2158 .terminate = __net_popup_terminate,
2159 .pause = __net_popup_pause,
2160 .resume = __net_popup_resume,
2161 .app_control = __net_popup_service_cb,
2164 return ui_app_main(argc, argv, &app_callback, NULL);