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>
42 #include <system_info.h>
44 #include "net-popup.h"
45 #include "net-popup-w.h"
46 #include "net-popup-vpn.h"
47 #include "net-popup-strings.h"
49 #define NET_POPUP_APPID "org.tizen.net-popup"
50 #define NET_WIFIQS_APPID "net.wifi-qs"
51 #define DATA_USAGE_APPID "org.tizen.setting"
52 #define WIFI_EFL_UG "wifi-efl-ug"
54 #define LOCALEDIR "/usr/share/locale"
55 #define NETPOPUP_EDJ "/usr/apps/" \
57 "/res/edje/netpopup-custom.edj"
58 #define QP_PRELOAD_NOTI_ICON_PATH tzplatform_mkpath(TZ_SYS_RO_APP, "/org.tizen.quickpanel/shared/res/noti_icons/Wi-Fi")
60 #define STC_NOTI_DATA_USAGE_ICON_PATH "/usr/share/icons/"
61 #define STC_NOTI_DATA_USAGE_ICON_NAME "stc_noti_datausage.png"
63 #define NETCONFIG_NOTIFICATION_WIFI_ICON \
64 tzplatform_mkpath(TZ_SYS_RO_ICONS, "/noti_wifi_in_range.png")
65 #define NETCONFIG_NOTIFICATION_WIFI_ICON_LITE \
66 tzplatform_mkpath(TZ_SYS_RO_ICONS, "/noti_wifi_in_range_ongoing.png")
67 #define NETCONFIG_NOTIFICATION_WIFI_CAPTIVE_ICON \
68 tzplatform_mkpath(TZ_SYS_RO_ICONS, "/B03_notify_Wi-fi_range.png")
69 #define NETCONFIG_NOTIFICATION_WIFI_IN_RANGE_ICON \
70 tzplatform_mkpath(TZ_SYS_RO_ICONS, "/Q02_Notification_wifi_in_range.png")
71 #define NETCONFIG_NOTIFICATION_WIFI_IN_RANGE_ICON_LITE \
72 tzplatform_mkpath(TZ_SYS_RO_ICONS, "/noti_wifi_in_range.png")
73 #define NETCONFIG_NOTIFICATION_WIFI_FOUND_TITLE \
74 dgettext(DOMAIN_NAME, "IDS_COM_BODY_WI_FI_NETWORKS_AVAILABLE")
75 #define NETCONFIG_NOTIFICATION_WIFI_FOUND_CONTENT \
76 dgettext(DOMAIN_NAME, "IDS_WIFI_SBODY_TAP_HERE_TO_CONNECT")
77 #define NETCONFIG_NOTIFICATION_WIFI_PORTAL_TITLE \
78 dgettext(DOMAIN_NAME, "IDS_WIFI_HEADER_SIGN_IN_TO_WI_FI_NETWORK_ABB")
79 #define NETCONFIG_NOTIFICATION_IP_CONFLICT_TITLE \
80 dgettext(DOMAIN_NAME, "IDS_IP_CONFLICT")
81 #define NETCONFIG_NOTIFICATION_WIFI_PORTAL_CONTENT "\"%s\""
83 #define STC_NOTIFICATION_WARNING_TITLE \
84 dgettext(DOMAIN_NAME, "IDS_COM_BODY_DATA_USAGE_WARNING")
85 #define STC_NOTIFICATION_WARNING_CONTENT \
86 dgettext(DOMAIN_NAME, "IDS_SM_SBODY_TAP_HERE_TO_VIEW_YOUR_DATA_USAGE_ABB")
87 #define STC_NOTIFICATION_RESTRICTION_OK_TITLE \
88 dgettext(DOMAIN_NAME, "IDS_SM_HEADER_MOBILE_DATA_TURNED_OFF_ABB2")
89 #define STC_NOTIFICATION_RESTRICTION_OK_CONTENT \
90 dgettext(DOMAIN_NAME, "IDS_SM_SBODY_TAP_HERE_TO_TURN_IT_ON_AGAIN_ABB")
91 #define STC_NOTIFICATION_RESTRICTION_ON_TITLE \
92 dgettext(DOMAIN_NAME, "IDS_SM_TMBODY_MOBILE_DATA_LIMIT_EXCEEDED_ABB")
94 #define STC_TOTAL_DATACALL "TOTAL_DATACALL"
95 #define STC_TOTAL_WIFI "TOTAL_WIFI"
96 #define STC_TOTAL_BLUETOOTH "TOTAL_BLUETOOTH"
98 #define USER_RESP_LEN 30
99 #define ICON_PATH_LEN 128
100 #define RESP_REMAIN_CONNECTED "RESP_REMAIN_CONNECTED"
101 #define RESP_WIFI_TETHERING_OFF "RESP_TETHERING_TYPE_WIFI_OFF"
102 #define RESP_WIFI_AP_TETHERING_OFF "RESP_TETHERING_TYPE_WIFI_AP_OFF"
103 #define RESP_TETHERING_ON "RESP_TETHERING_ON"
104 #define CAPTIVE_PORTAL_LOGIN "Login required to access Internet"
105 #define CAPTIVE_PORTAL_LOGIN_ERROR "Login not completed. Disconnected active Wifi"
107 static Ecore_Event_Handler *ecore_event_evas_handler;
109 #define BUF_SIZE 1024
110 long sizes[] = {1073741824, 1048576, 1024, 0};
111 char *units[] = {"GB", "MB", "KB", "B"};
113 static tizen_profile_t g_profile = TIZEN_PROFILE_UNKNOWN;
115 static app_control_h g_req_handle = NULL;
117 static GDBusConnection *conn = NULL;
118 static GDBusProxy *proxy = NULL;
120 /* vpn-service popup */
121 static char *iface_name = NULL;
123 /* data roaming popup */
124 static Eina_Bool turn_on_roaming = FALSE;
125 static Eina_Bool do_not_show_popup = FALSE;
127 /* data usage popup */
128 static char *data_usage_app_id = NULL;
129 static char *data_usage_iftype = NULL;
131 static int __net_popup_show_notification(app_control_h request, void *data);
132 static int __toast_popup_show(app_control_h request, void *data);
133 static int __net_popup_show_popup(app_control_h request, void *data);
134 static void __net_popup_show_warning_noti(app_control_h request, void *data);
135 static void __net_popup_show_restriction_noti(app_control_h request, void *data);
136 static void __net_popup_add_found_ap_noti(void);
137 static void __net_popup_del_found_ap_noti(void);
138 static void __net_popup_add_portal_noti(app_control_h request);
139 static void __net_popup_del_portal_noti(void);
140 static void __net_popup_show_popup_with_user_resp(app_control_h request, void *data);
141 static void __net_popup_show_vpn_popup(app_control_h request, void *data);
142 static int _net_popup_send_user_resp(char *resp, Eina_Bool state);
143 static int __net_popup_show_network_error_popup(app_control_h request, void *data);
144 static void __net_popup_add_ip_conflict_noti(app_control_h request);
145 static void __net_popup_del_ip_conflict_noti(void);
147 static void __net_popup_get_tizen_profile(void)
149 char *profile_name = NULL;
151 system_info_get_platform_string("http://tizen.org/feature/profile", &profile_name);
153 switch (*profile_name) {
156 g_profile = TIZEN_PROFILE_MOBILE;
157 log_print(NET_POPUP, "mobile profile\n");
161 g_profile = TIZEN_PROFILE_WEARABLE;
162 log_print(NET_POPUP, "wearable profile\n");
166 g_profile = TIZEN_PROFILE_TV;
167 log_print(NET_POPUP, "tv profile\n");
171 g_profile = TIZEN_PROFILE_IVI;
172 log_print(NET_POPUP, "ivi profile\n");
175 g_profile = TIZEN_PROFILE_COMMON;
176 log_print(NET_POPUP, "common profile\n");
181 GDBusProxy *__net_popup_init_dbus(void)
183 log_print(NET_POPUP, "__net_popup_init_dbus()\n");
187 conn = g_bus_get_sync(G_BUS_TYPE_SYSTEM, NULL, &err);
193 proxy = g_dbus_proxy_new_sync(conn, G_DBUS_PROXY_FLAGS_NONE, NULL,
200 g_object_unref(conn);
207 void __net_popup_deinit_dbus(void)
209 log_print(NET_POPUP, "__net_popup_deinit_dbus()\n");
212 g_object_unref(proxy);
217 g_object_unref(conn);
224 void __net_popup_send_data_usage_msg(const char *app_id,
227 log_print(NET_POPUP, "__net_popup_send_data_usage_msg()\n");
229 int ret = STC_ERROR_NONE;
231 stc_restriction_rule_h rule = NULL;
233 ret = stc_initialize(&stc);
234 if (ret != STC_ERROR_NONE) {
235 log_print(NET_POPUP, "Failed to initialize ret= %d\n", ret);
239 ret = stc_restriction_rule_create(stc, &rule);
240 if (ret != STC_ERROR_NONE) {
241 log_print(NET_POPUP, "Failed to create restriction rule ret= %d\n", ret);
245 ret = stc_restriction_rule_set_app_id(rule, app_id);
246 if (ret != STC_ERROR_NONE) {
247 log_print(NET_POPUP, "Failed to set application ID ret= %d\n", ret);
251 ret = stc_restriction_rule_set_iface_type(rule, iftype[0] - '0');
252 if (ret != STC_ERROR_NONE) {
253 log_print(NET_POPUP, "Failed to set interface type ret= %d\n", ret);
257 ret = stc_unset_restriction(stc, rule);
258 if (ret != STC_ERROR_NONE) {
259 log_print(NET_POPUP, "Failed to unset restriction ret= %d\n", ret);
263 log_print(NET_POPUP, "Success to unset restriction\n");
267 ret = stc_restriction_rule_destroy(rule);
268 if (ret != STC_ERROR_NONE)
269 log_print(NET_POPUP, "Failed to destroy restriction rule ret= %d\n", ret);
273 ret = stc_deinitialize(stc);
274 if (ret != STC_ERROR_NONE)
275 log_print(NET_POPUP, "Failed to deinitialize ret= %d\n", ret);
281 static bool __net_popup_create(void *data)
283 log_print(NET_POPUP, "__net_popup_create()\n");
285 bindtextdomain(DOMAIN_NAME, LOCALEDIR);
290 static void __net_popup_terminate(void *data)
292 log_print(NET_POPUP, "__net_popup_terminate()\n");
294 if (ecore_event_evas_handler) {
295 ecore_event_handler_del(ecore_event_evas_handler);
296 ecore_event_evas_handler = NULL;
300 app_control_destroy(g_req_handle);
312 static void __net_popup_pause(void *data)
314 log_print(NET_POPUP, "__net_popup_pause()\n");
317 static void __net_popup_resume(void *data)
322 static Eina_Bool __key_release_event_cb(void *data, int type,
325 log_print(NET_POPUP, "__key_release_event_cb()\n");
327 Evas_Event_Key_Down *ev = (Evas_Event_Key_Down *) event;
330 return ECORE_CALLBACK_RENEW;
333 return ECORE_CALLBACK_RENEW;
335 log_print(NET_POPUP, "key_release : %s", ev->keyname);
336 if (g_strcmp0(ev->keyname, "XF86Phone") == 0 ||
337 g_strcmp0(ev->keyname, "XF86Stop") == 0) {
341 return ECORE_CALLBACK_DONE;
345 static Eina_Bool _ecore_event_client_message_cb(void *data, int type,
348 Ecore_X_Event_Client_Message *ev = event;
350 if (ev->message_type == ECORE_X_ATOM_E_ILLUME_QUICKPANEL_STATE) {
351 if (ev->data.l[0] == ECORE_X_ATOM_E_ILLUME_QUICKPANEL_OFF)
352 log_print(NET_POPUP, "ECORE_X_ATOM_E_ILLUME_QUICKPANEL_OFF");
353 else if (ev->data.l[0] == ECORE_X_ATOM_E_ILLUME_QUICKPANEL_ON)
354 log_print(NET_POPUP, "ECORE_X_ATOM_E_ILLUME_QUICKPANEL_ON");
356 return ECORE_CALLBACK_RENEW;
360 static void __net_popup_service_cb(app_control_h request, void *data)
362 log_print(NET_POPUP, "__net_popup_service_cb()\n");
365 char *operation = NULL;
368 if (ecore_event_evas_handler == NULL) {
369 ecore_event_evas_handler = ecore_event_handler_add(ECORE_EVENT_KEY_UP,
370 __key_release_event_cb, NULL);
373 ret = app_control_get_operation(request, &operation);
374 if (APP_CONTROL_ERROR_NONE != ret)
375 log_print(NET_POPUP, "Failed to get operation ret= %d", ret);
377 if (operation != NULL && g_str_equal(operation, APP_CONTROL_OPERATION_SETTING_VPN)) {
378 app_control_clone(&g_req_handle, request);
379 __net_popup_show_vpn_popup(request, data);
392 ret = app_control_get_extra_data(request, "_SYSPOPUP_TYPE_", &type);
393 if (APP_CONTROL_ERROR_NONE != ret) {
394 log_print(NET_POPUP, "Failed to get _SYSPOPUP_TYPE_ ret = %d", ret);
400 log_print(NET_POPUP, "type = %s\n", type);
402 if (g_str_equal(type, "notification")) {
403 __net_popup_show_notification(request, data);
405 } else if (g_str_equal(type, "toast_popup")) {
406 __toast_popup_show(request, data);
407 } else if (g_str_equal(type, "popup")) {
408 __net_popup_show_popup(request, data);
409 } else if (g_str_equal(type, "warning_noti")) {
410 __net_popup_show_warning_noti(request, data);
412 } else if (g_str_equal(type, "restriction_noti")) {
413 __net_popup_show_restriction_noti(request, data);
414 } else if (g_str_equal(type, "add_found_ap_noti")) {
415 __net_popup_add_found_ap_noti();
417 } else if (g_str_equal(type, "del_found_ap_noti")) {
418 __net_popup_del_found_ap_noti();
420 } else if (g_str_equal(type, "add_portal_noti")) {
421 __net_popup_add_portal_noti(request);
423 } else if (g_str_equal(type, "del_portal_noti")) {
424 __net_popup_del_portal_noti();
426 } else if (g_str_equal(type, "add_ip_conflict_noti")) {
427 __net_popup_add_ip_conflict_noti(request);
429 } else if (g_str_equal(type, "del_ip_conflict_noti")) {
430 __net_popup_del_ip_conflict_noti();
432 } else if (g_str_equal(type, "popup_user_resp")) {
433 app_control_clone(&g_req_handle, request);
434 __net_popup_show_popup_with_user_resp(request, data);
435 } else if (g_str_equal(type, "network_error_popup")) {
436 __net_popup_show_network_error_popup(request, data);
438 __net_popup_show_notification(request, data);
447 static void __net_popup_set_orientation(Evas_Object *win)
449 log_print(NET_POPUP, "__net_popup_set_orientation()\n");
451 int rots[4] = { 0, 90, 180, 270 };
453 if (!elm_win_wm_rotation_supported_get(win))
456 elm_win_wm_rotation_available_rotations_set(win, rots, 4);
459 static Evas_Object* __net_popup_create_win(void)
461 log_print(NET_POPUP, "__net_popup_create_win()\n");
463 Evas_Object *win = NULL;
465 Ecore_Evas *ee = NULL;
470 win = elm_win_add(NULL, PACKAGE, ELM_WIN_NOTIFICATION);
472 e = evas_object_evas_get(win);
473 ee = ecore_evas_ecore_evas_get(e);
474 ecore_evas_name_class_set(ee, "APP_POPUP", "APP_POPUP");
476 elm_win_alpha_set(win, EINA_TRUE);
477 elm_win_borderless_set(win, EINA_TRUE);
479 ecore_x_window_size_get(ecore_x_window_root_first_get(), &w, &h);
480 evas_object_resize(win, w, h);
481 utilx_set_system_notification_level(ecore_x_display_get(),
482 elm_win_xwindow_get(win),
483 UTILX_NOTIFICATION_LEVEL_LOW);
486 __net_popup_set_orientation(win);
491 static void __launch_app_control(char *operation)
493 app_control_h app_control;
495 app_control_create(&app_control);
496 if (app_control == NULL) {
497 log_print(NET_POPUP, "Failed to create app control handle");
501 app_control_set_operation(app_control, operation);
502 if (app_control_send_launch_request(app_control, NULL, NULL) == APP_CONTROL_ERROR_NONE)
503 log_print(NET_POPUP, "Succeeded to launch %s", operation);
505 log_print(NET_POPUP, "Failed to launch %s", operation);
507 app_control_destroy(app_control);
510 static void __data_roaming_check_changed_cb(void* data, Evas_Object* obj, void* event_info)
512 turn_on_roaming = elm_check_state_get(obj);
513 log_print(NET_POPUP, "Romaing(%d)", turn_on_roaming);
516 static void __do_not_show_check_changed_cb(void* data, Evas_Object* obj, void* event_info)
518 do_not_show_popup = elm_check_state_get(obj);
519 log_print(NET_POPUP, "Do not show again(%d)", do_not_show_popup);
522 static void _ok_button_clicked_cb(void *data, Evas_Object *obj, void *event_info)
524 log_print(NET_POPUP, "_ok_button_clicked_cb()\n");
527 evas_object_del(data);
531 static void _cancel_button_clicked_cb(void *data, Evas_Object *obj, void *event_info)
533 log_print(NET_POPUP, "_cancel_button_clicked_cb()");
536 evas_object_del(data);
541 static void _wifi_button_clicked_cb(void *data, Evas_Object *obj, void *event_info)
543 log_print(NET_POPUP, "_wifi_button_clicked_cb()");
545 __launch_app_control(APP_CONTROL_OPERATION_SETTING_WIFI);
548 evas_object_del(data);
553 static void _settings_button_clicked_cb(void *data, Evas_Object *obj, void *event_info)
555 log_print(NET_POPUP, "_settings_button_clicked_cb()");
557 __launch_app_control(APP_CONTROL_OPERATION_SETTING);
560 evas_object_del(data);
565 static void _retry_button_clicked_cb(void *data, Evas_Object *obj, void *event_info)
567 log_print(NET_POPUP, "_retry_button_clicked_cb()");
569 int ret = vconf_set_bool(VCONFKEY_3G_ENABLE, 1);
571 log_print(NET_POPUP, "Failed to enable mobile data");
574 evas_object_del(data);
579 static void _data_raoming_button_clicked_cb(void *data, Evas_Object *obj, void *event_info)
581 log_print(NET_POPUP, "_data_roaming_button_clicked_cb()");
583 int ret = vconf_set_bool(VCONFKEY_SETAPPL_STATE_DATA_ROAMING_BOOL, turn_on_roaming);
585 log_print(NET_POPUP, "Failed to enable mobile data");
588 evas_object_del(data);
593 static void _connect_button_clicked_cb(void *data, Evas_Object *obj, void *event_info)
595 log_print(NET_POPUP, "_connect_button_clicked_cb()");
597 int ret = vconf_set_bool(VCONFKEY_3G_ENABLE, 1);
599 log_print(NET_POPUP, "Failed to enable mobile data");
602 evas_object_del(data);
607 static void _timeout_cb(void *data, Evas_Object *obj, void *event_info)
609 log_print(NET_POPUP, "_timeout_cb()\n");
611 evas_object_del(obj);
616 static int __toast_popup_show(app_control_h request, void *data)
618 log_print(NET_POPUP, "__toast_popup_show()\n");
620 char buf[ALERT_STR_LEN_MAX] = "";
623 Evas_Object *twin = NULL;
624 Evas_Object *tpop = NULL;
625 char *ap_name = NULL;
626 char *restricted_type = NULL;
628 ret = app_control_get_extra_data(request, "_SYSPOPUP_CONTENT_", &mode);
629 if (ret != APP_CONTROL_ERROR_NONE) {
630 log_print(NET_POPUP, "Failed to get _SYSPOPUP_CONTENT_ ret = %d", ret);
636 log_print(NET_POPUP, "_SYSPOPUP_CONTENT_ = %s\n", mode);
638 twin = __net_popup_create_win();
639 tpop = elm_popup_add(twin);
640 elm_object_style_set(tpop, "toast");
641 evas_object_size_hint_weight_set(tpop, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
643 elm_popup_timeout_set(tpop, 2.0);
645 evas_object_smart_callback_add(tpop, "timeout", _timeout_cb, twin);
646 if (strcmp(mode, "wrong password") == 0) {
647 log_print(NET_POPUP, "alert wrong password\n");
649 g_snprintf(buf, ALERT_STR_LEN_MAX, ALERT_STR_ERR_WRONG_PASSWORD);
650 } else if (strcmp(mode, "no ap found") == 0) {
651 log_print(NET_POPUP, "alert no ap found\n");
653 g_snprintf(buf, ALERT_STR_LEN_MAX, ALERT_STR_NO_AP_FOUND);
654 } else if (strcmp(mode, "unable to connect") == 0) {
655 log_print(NET_POPUP, "alert no ap found\n");
657 g_snprintf(buf, ALERT_STR_LEN_MAX, ALERT_STR_ERR_CONNECT);
658 } else if (strcmp(mode, "wifi connected") == 0) {
659 ret = app_control_get_extra_data(request, "_AP_NAME_", &ap_name);
661 if (APP_CONTROL_ERROR_NONE != ret) {
662 log_print(NET_POPUP, "Failed to get _AP_NAME_ ret = %d", ret);
668 g_snprintf(buf, ALERT_STR_LEN_MAX, ALERT_STR_WIFI_CONNECTED, ap_name);
670 g_snprintf(buf, ALERT_STR_LEN_MAX, ALERT_STR_WIFI_CONNECTED, "");
671 log_print(NET_POPUP, "alert wifi connected\n");
673 } else if (strcmp(mode, "warn threshold crossed") == 0) {
676 ret = app_control_get_extra_data(request, "_APP_ID_", &app_id);
678 if (APP_CONTROL_ERROR_NONE != ret) {
679 log_print(NET_POPUP, "Failed to get _APP_ID_ ret = %d", ret);
684 g_snprintf(buf, ALERT_STR_LEN_MAX, ALERT_STR_DATA_USAGE_WARNING);
686 log_print(NET_POPUP, "alert warn threshold crossed [%s]\n", app_id);
688 } else if (strcmp(mode, "security restriction") == 0) {
689 ret = app_control_get_extra_data(request, "_RESTRICTED_TYPE_", &restricted_type);
690 if (APP_CONTROL_ERROR_NONE != ret) {
691 log_print(NET_POPUP, "Failed to get _RESTRICTED_TYPE_ ret = %d", ret);
696 if (strcmp(restricted_type, "wifi") == 0)
697 g_snprintf(buf, ALERT_STR_LEN_MAX, ALERT_STR_RESTRICTED_USE_WIFI);
698 else if (strcmp(restricted_type, "wifi tethering") == 0)
699 g_snprintf(buf, ALERT_STR_LEN_MAX, ALERT_STR_SECURITY_RESTRICTION, ALERT_STR_WIFI_TETHERING);
700 else if (strcmp(restricted_type, "bt tethering") == 0)
701 g_snprintf(buf, ALERT_STR_LEN_MAX, ALERT_STR_SECURITY_RESTRICTION, ALERT_STR_BT_TETHERING);
702 else if (strcmp(restricted_type, "usb tethering") == 0)
703 g_snprintf(buf, ALERT_STR_LEN_MAX, ALERT_STR_SECURITY_RESTRICTION, ALERT_STR_USB_TETHERING);
705 log_print(NET_POPUP, "alert security restriction\n");
706 g_free(restricted_type);
708 log_print(NET_POPUP, "%s\n", mode);
710 elm_object_text_set(tpop, buf);
711 evas_object_show(tpop);
712 evas_object_show(twin);
718 static int __net_popup_show_notification(app_control_h request, void *data)
720 log_print(NET_POPUP, "__net_popup_show_notification()\n");
724 char buf[ALERT_STR_LEN_MAX] = "";
725 char *ap_name = NULL;
727 ret = app_control_get_extra_data(request, "_SYSPOPUP_CONTENT_", &mode);
729 if (APP_CONTROL_ERROR_NONE != ret) {
730 log_print(NET_POPUP, "Failed to get _SYSPOPUP_CONTENT_");
734 secure_log_print(NET_POPUP, "_SYSPOPUP_CONTENT_ = %s\n", mode);
736 if (strcmp(mode, "connected") == 0) {
737 notification_status_message_post(ALERT_STR_MOBILE_NETWORKS_CHARGE);
738 log_print(NET_POPUP, "alert 3g\n");
739 } else if (strcmp(mode, "fail to connect") == 0) {
740 notification_status_message_post(ALERT_STR_ERR_UNAVAILABLE);
741 log_print(NET_POPUP, "alert err\n");
742 } else if (strcmp(mode, "unable to connect") == 0) {
743 notification_status_message_post(ALERT_STR_ERR_CONNECT);
744 log_print(NET_POPUP, "alert unable to connect\n");
745 } else if (strcmp(mode, "wrong password") == 0) {
746 notification_status_message_post(ALERT_STR_ERR_WRONG_PASSWORD);
747 log_print(NET_POPUP, "alert wrong password\n");
748 } else if (strcmp(mode, "not support") == 0) {
749 notification_status_message_post(ALERT_STR_ERR_NOT_SUPPORT);
750 log_print(NET_POPUP, "alert not support\n");
751 } else if (strcmp(mode, "wifi restricted") == 0) {
752 notification_status_message_post(ALERT_STR_RESTRICTED_USE_WIFI);
753 log_print(NET_POPUP, "alert wifi restricted\n");
754 } else if (strcmp(mode, "no ap found") == 0) {
755 notification_status_message_post(ALERT_STR_NO_AP_FOUND);
756 log_print(NET_POPUP, "alert no ap found\n");
757 } else if (strcmp(mode, "Lengthy Password") == 0) {
758 notification_status_message_post(ALERT_STR_LENGHTY_PASSWORD);
759 log_print(NET_POPUP, "Password entered crosses 64 bytes\n");
760 } else if (strcmp(mode, "Portal Login") == 0) {
761 notification_status_message_post(CAPTIVE_PORTAL_LOGIN);
762 log_print(NET_POPUP, "Please login to access Internet\n");
763 } else if (strcmp(mode, "Portal Login Error") == 0) {
764 notification_status_message_post(CAPTIVE_PORTAL_LOGIN_ERROR);
765 log_print(NET_POPUP, "Login not completed. Disconnected Wifi\n");
766 } else if (strcmp(mode, "wifi connected") == 0) {
767 ret = app_control_get_extra_data(request, "_AP_NAME_", &ap_name);
769 if (APP_CONTROL_ERROR_NONE != ret) {
770 log_print(NET_POPUP, "Failed to get _AP_NAME_ ret = %d", ret);
776 g_snprintf(buf, ALERT_STR_LEN_MAX, ALERT_STR_WIFI_CONNECTED, ap_name);
778 g_snprintf(buf, ALERT_STR_LEN_MAX, ALERT_STR_WIFI_CONNECTED, "");
780 notification_status_message_post(buf);
782 log_print(NET_POPUP, "alert wifi connected\n");
784 } else if (strcmp(mode, "warn threshold crossed") == 0) {
785 char buf[ALERT_STR_LEN_MAX] = "";
788 ret = app_control_get_extra_data(request, "_APP_ID_", &app_id);
790 if (APP_CONTROL_ERROR_NONE != ret) {
791 log_print(NET_POPUP, "Failed to get _APP_ID_ ret = %d", ret);
796 g_snprintf(buf, ALERT_STR_LEN_MAX, ALERT_STR_DATA_USAGE_WARNING);
798 notification_status_message_post(buf);
800 log_print(NET_POPUP, "alert warn threshold crossed [%s]\n", app_id);
803 notification_status_message_post(mode);
804 log_print(NET_POPUP, "%s\n", mode);
811 static int _net_popup_send_user_resp(char *resp, Eina_Bool state)
813 log_print(NET_POPUP, "_net_popup_send_user_resp()\n");
816 app_control_h reply = NULL;
817 char checkbox_str[USER_RESP_LEN] = { '\0', };
819 log_print(NET_POPUP, "Send the user response to the caller");
820 ret = app_control_create(&reply);
821 if (APP_CONTROL_ERROR_NONE != ret) {
822 log_print(NET_POPUP, "Failed to create service ret = %d", ret);
823 app_control_destroy(g_req_handle);
830 g_strlcpy(checkbox_str, "TRUE", USER_RESP_LEN);
832 g_strlcpy(checkbox_str, "FALSE", USER_RESP_LEN);
834 log_print(NET_POPUP, "Checkbox_str[%s]", checkbox_str);
836 ret = app_control_add_extra_data(reply, "_SYSPOPUP_RESP_", resp);
837 if (APP_CONTROL_ERROR_NONE == ret) {
838 ret = app_control_add_extra_data(reply, "_SYSPOPUP_CHECKBOX_RESP_",
840 if (APP_CONTROL_ERROR_NONE == ret) {
841 ret = app_control_reply_to_launch_request(reply, g_req_handle,
842 APP_CONTROL_RESULT_SUCCEEDED);
843 if (APP_CONTROL_ERROR_NONE == ret) {
844 log_print(NET_POPUP, "Service reply success");
847 log_print(NET_POPUP, "Service reply failed ret = %d", ret);
850 log_print(NET_POPUP, "Service data addition failed ret = %d", ret);
853 log_print(NET_POPUP, "Service data addition failed ret = %d", ret);
856 app_control_destroy(reply);
857 app_control_destroy(g_req_handle);
863 static Evas_Object *__net_popup_create_checkview_layout(Evas_Object *parent)
865 Evas_Object *layout = NULL;
867 layout = elm_layout_add(parent);
868 elm_layout_file_set(layout, NETPOPUP_EDJ, "popup_checkview");
869 evas_object_size_hint_weight_set(layout, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
870 evas_object_size_hint_align_set(layout, EVAS_HINT_FILL, 1.0);
871 elm_object_content_set(parent, layout);
876 static Evas_Object *__net_popup_create_label(Evas_Object *parent)
878 Evas_Object *label = NULL;
880 label = elm_label_add(parent);
881 elm_object_style_set(label, "popup/default");
882 elm_label_line_wrap_set(label, ELM_WRAP_MIXED);
883 evas_object_size_hint_weight_set(label, EVAS_HINT_EXPAND, 0.0);
884 evas_object_size_hint_align_set(label, EVAS_HINT_FILL, EVAS_HINT_FILL);
885 evas_object_show(label);
890 static Evas_Object *__net_popup_create_cancel_button(Evas_Object *parent)
892 Evas_Object *btn = NULL;
894 btn = elm_button_add(parent);
895 elm_object_style_set(btn, "popup");
896 elm_object_text_set(btn, ALERT_STR_CANCEL);
897 evas_object_size_hint_align_set(btn, EVAS_HINT_FILL, EVAS_HINT_FILL);
898 evas_object_smart_callback_add(btn, "clicked", _cancel_button_clicked_cb, parent);
903 static Evas_Object *__net_popup_create_wifi_button(Evas_Object *parent)
905 Evas_Object *btn = NULL;
907 btn = elm_button_add(parent);
908 elm_object_style_set(btn, "popup");
909 elm_object_text_set(btn, ALERT_STR_WIFI);
910 evas_object_size_hint_align_set(btn, EVAS_HINT_FILL, EVAS_HINT_FILL);
911 evas_object_smart_callback_add(btn, "clicked", _wifi_button_clicked_cb, parent);
916 static Evas_Object *__net_popup_create_settings_button(Evas_Object *parent)
918 Evas_Object *btn = NULL;
920 btn = elm_button_add(parent);
921 elm_object_style_set(btn, "popup");
922 elm_object_text_set(btn, ALERT_STR_SETTINGS);
923 evas_object_size_hint_align_set(btn, EVAS_HINT_FILL, EVAS_HINT_FILL);
924 evas_object_smart_callback_add(btn, "clicked", _settings_button_clicked_cb, parent);
929 static Evas_Object *__net_popup_create_retry_button(Evas_Object *parent)
931 Evas_Object *btn = NULL;
933 btn = elm_button_add(parent);
934 elm_object_style_set(btn, "popup");
935 elm_object_text_set(btn, ALERT_STR_RETRY);
936 evas_object_size_hint_align_set(btn, EVAS_HINT_FILL, EVAS_HINT_FILL);
937 evas_object_smart_callback_add(btn, "clicked", _retry_button_clicked_cb, parent);
942 static Evas_Object *__net_popup_create_data_roaming_button(Evas_Object *parent)
944 Evas_Object *btn = NULL;
946 btn = elm_button_add(parent);
947 elm_object_style_set(btn, "popup");
948 elm_object_text_set(btn, ALERT_STR_OK);
949 evas_object_size_hint_align_set(btn, EVAS_HINT_FILL, EVAS_HINT_FILL);
950 evas_object_smart_callback_add(btn, "clicked", _data_raoming_button_clicked_cb, parent);
955 static Evas_Object *__net_popup_create_connect_button(Evas_Object *parent)
957 Evas_Object *btn = NULL;
959 btn = elm_button_add(parent);
960 elm_object_style_set(btn, "popup");
961 elm_object_text_set(btn, ALERT_STR_VPN_CONNECT_BUTTON);
962 evas_object_size_hint_align_set(btn, EVAS_HINT_FILL, EVAS_HINT_FILL);
963 evas_object_smart_callback_add(btn, "clicked", _connect_button_clicked_cb, parent);
968 static int __net_popup_show_network_error_popup(app_control_h request, void *data)
970 log_print(NET_POPUP, "__net_popup_show_network_error_popup()\n");
977 Evas_Object *btn1, *btn2, *btn3;
981 ret = app_control_get_extra_data(request, "_SYSPOPUP_CONTENT_", &mode);
982 if (APP_CONTROL_ERROR_NONE != ret) {
983 log_print(NET_POPUP, "Failed to get _SYSPOPUP_CONTENT_ ret = %d", ret);
989 secure_log_print(NET_POPUP, "_SYSPOPUP_CONTENT_ = %s\n", mode);
991 win = __net_popup_create_win();
992 popup = elm_popup_add(win);
993 evas_object_size_hint_weight_set(popup, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
995 if (strcmp(mode, "connect_to_mobile_network") == 0) {
996 elm_object_part_text_set(popup, "title,text", ALERT_STR_CONNECT_TO_MOBILE_NETWORK);
997 layout = __net_popup_create_checkview_layout(popup);
998 label = __net_popup_create_label(layout);
999 elm_object_text_set(label, ALERT_STR_ROAMING_WITH_PAYMENT);
1000 elm_object_part_content_set(layout, "elm.swallow.content", label);
1001 check = elm_check_add(popup);
1002 elm_object_style_set(check, "popup");
1003 elm_object_part_content_set(layout, "elm.swallow.end", check);
1004 elm_object_text_set(check, ALERT_STR_DO_NOT_SHOW_AGAIN);
1005 elm_check_state_set(check, EINA_FALSE);
1006 evas_object_smart_callback_add(check, "changed",
1007 __do_not_show_check_changed_cb, NULL);
1008 btn1 = __net_popup_create_cancel_button(popup);
1009 elm_object_part_content_set(popup, "button1", btn1);
1010 btn2 = __net_popup_create_connect_button(popup);
1011 elm_object_part_content_set(popup, "button2", btn2);
1013 elm_object_part_text_set(popup, "title,text", ALERT_STR_NO_NETWORK_CONNECTION);
1014 if (strcmp(mode, "flight_mode") == 0) {
1015 elm_object_text_set(popup, ALERT_STR_CANT_CONNECT_TO_MOBILE);
1016 btn1 = __net_popup_create_cancel_button(popup);
1017 elm_object_part_content_set(popup, "button1", btn1);
1018 btn2 = __net_popup_create_wifi_button(popup);
1019 elm_object_part_content_set(popup, "button2", btn2);
1020 btn3 = __net_popup_create_settings_button(popup);
1021 elm_object_part_content_set(popup, "button3", btn3);
1022 } else if (strcmp(mode, "mobile_data_is_turned_off") == 0) {
1023 elm_object_text_set(popup, ALERT_STR_MOBILE_DATA_IS_TURNED_OFF);
1024 btn1 = __net_popup_create_cancel_button(popup);
1025 elm_object_part_content_set(popup, "button1", btn1);
1026 btn2 = __net_popup_create_wifi_button(popup);
1027 elm_object_part_content_set(popup, "button2", btn2);
1028 btn3 = __net_popup_create_settings_button(popup);
1029 elm_object_part_content_set(popup, "button3", btn3);
1030 } else if (strcmp(mode, "no_mobile_networks") == 0) {
1031 elm_object_text_set(popup, ALERT_STR_NO_MOBILE_NETWORKS);
1032 btn1 = __net_popup_create_cancel_button(popup);
1033 elm_object_part_content_set(popup, "button1", btn1);
1034 btn2 = __net_popup_create_retry_button(popup);
1035 elm_object_part_content_set(popup, "button2", btn2);
1036 } else if (strcmp(mode, "roaming_with_check") == 0) {
1037 layout = __net_popup_create_checkview_layout(popup);
1038 label = __net_popup_create_label(layout);
1039 elm_object_text_set(label, ALERT_STR_ROAMING_WITH_PAYMENT);
1040 elm_object_part_content_set(layout, "elm.swallow.content", label);
1041 check = elm_check_add(popup);
1042 elm_object_style_set(check, "popup");
1043 elm_object_part_content_set(layout, "elm.swallow.end", check);
1044 elm_object_text_set(check, ALERT_STR_TURN_ON_DATA_ROAMING);
1045 elm_check_state_set(check, EINA_FALSE);
1046 evas_object_smart_callback_add(check, "changed",
1047 __data_roaming_check_changed_cb, NULL);
1048 btn1 = __net_popup_create_data_roaming_button(popup);
1049 elm_object_part_content_set(popup, "button1", btn1);
1050 } else if (strcmp(mode, "roaming_with_settings") == 0) {
1051 elm_object_text_set(popup, ALERT_STR_ROAMING);
1052 btn1 = __net_popup_create_cancel_button(popup);
1053 elm_object_part_content_set(popup, "button1", btn1);
1054 btn2 = __net_popup_create_wifi_button(popup);
1055 elm_object_part_content_set(popup, "button2", btn2);
1056 btn3 = __net_popup_create_settings_button(popup);
1057 elm_object_part_content_set(popup, "button3", btn3);
1061 evas_object_show(popup);
1062 evas_object_show(win);
1068 void _tethering_wifi_btn_yes_cb(void *data, Evas_Object *obj, void *event_info)
1070 log_print(NET_POPUP, "_tethering_wifi_btn_yes_cb()\n");
1072 bool result = FALSE;
1073 Evas_Object *popup = (Evas_Object *)data;
1075 result = _net_popup_send_user_resp(RESP_WIFI_TETHERING_OFF, FALSE);
1077 log_print(NET_POPUP, "Failed to send user response ");
1080 evas_object_del(popup);
1085 void _tethering_wifi_ap_btn_yes_cb(void *data, Evas_Object *obj, void *event_info)
1087 log_print(NET_POPUP, "_tethering_wifi_ap_btn_yes_cb()\n");
1089 bool result = FALSE;
1090 Evas_Object *popup = (Evas_Object *)data;
1092 result = _net_popup_send_user_resp(RESP_WIFI_AP_TETHERING_OFF, FALSE);
1094 log_print(NET_POPUP, "Failed to send user response ");
1097 evas_object_del(popup);
1102 static void _vpn_send_result(int result)
1104 log_print(NET_POPUP, "Send the result of vpn-service to the caller");
1107 app_control_h reply = NULL;
1108 app_control_result_e resp_code;
1110 ret = app_control_create(&reply);
1111 if (APP_CONTROL_ERROR_NONE != ret) {
1112 log_print(NET_POPUP, "Failed to create service ret = %d", ret);
1113 app_control_destroy(g_req_handle);
1114 g_req_handle = NULL;
1118 if (result == VPNSVC_ERROR_NONE)
1119 resp_code = APP_CONTROL_RESULT_SUCCEEDED;
1120 else if (result == VPNSVC_ERROR_CANCELED)
1121 resp_code = APP_CONTROL_RESULT_CANCELED;
1123 resp_code = APP_CONTROL_RESULT_FAILED;
1125 ret = app_control_add_extra_data(reply, APP_CONTROL_DATA_TEXT, __get_vpn_error_message(result));
1126 if (APP_CONTROL_ERROR_NONE == ret) {
1127 ret = app_control_reply_to_launch_request(reply, g_req_handle, resp_code);
1128 if (APP_CONTROL_ERROR_NONE == ret)
1129 log_print(NET_POPUP, "Service reply success");
1131 log_print(NET_POPUP, "Service reply failed ret = %d", ret);
1133 log_print(NET_POPUP, "Service data addition failed ret = %d", ret);
1136 app_control_destroy(reply);
1137 app_control_destroy(g_req_handle);
1138 g_req_handle = NULL;
1143 void _vpn_btn_connect_cb(void *data, Evas_Object *obj, void *event_info)
1145 log_print(NET_POPUP, "_vpn_btn_connect_cb()");
1146 Evas_Object *popup = (Evas_Object *)data;
1147 int ret = VPNSVC_ERROR_NONE;
1149 ret = _vpnsvc_up(iface_name);
1150 _vpn_send_result(ret);
1157 evas_object_del(popup);
1159 evas_object_del(obj);
1164 void _vpn_btn_disconnect_cb(void *data, Evas_Object *obj, void *event_info)
1166 log_print(NET_POPUP, "_vpn_btn_disconnect_cb()");
1167 Evas_Object *popup = (Evas_Object *)data;
1168 int ret = VPNSVC_ERROR_NONE;
1170 ret = _vpnsvc_down(iface_name);
1171 _vpn_send_result(ret);
1178 evas_object_del(popup);
1180 evas_object_del(obj);
1185 void _vpn_btn_no_cb(void *data, Evas_Object *obj, void *event_info)
1187 log_print(NET_POPUP, "_vpn_btn_no_cb()");
1188 Evas_Object *popup = (Evas_Object *)data;
1190 _vpn_send_result(VPNSVC_ERROR_CANCELED);
1197 evas_object_del(popup);
1199 evas_object_del(obj);
1204 void _btn_no_cb(void *data, Evas_Object *obj, void *event_info)
1206 log_print(NET_POPUP, "_btn_no_cb()\n");
1208 bool result = FALSE;
1209 Evas_Object *popup = (Evas_Object *)data;
1211 result = _net_popup_send_user_resp(RESP_TETHERING_ON, FALSE);
1213 log_print(NET_POPUP, "Failed to send user response ");
1216 evas_object_del(popup);
1221 static void __data_usage_notification(notification_type_e type,
1222 notification_ly_type_e ly_type, const char *title_text, const char *title_key,
1223 const char *content_text, const char *content_key, const char *launch_appid)
1227 char icon_path[ICON_PATH_LEN];
1228 notification_h noti = NULL;
1229 notification_error_e noti_err = NOTIFICATION_ERROR_NONE;
1230 app_control_h service_handle = NULL;
1232 noti = notification_create(type);
1234 log_print(NET_POPUP, "Failed to create notification");
1238 noti_err = notification_set_time(noti, time(NULL));
1239 if (noti_err != NOTIFICATION_ERROR_NONE) {
1240 log_print(NET_POPUP, "Failed to notification_set_time : %d", noti_err);
1244 g_snprintf(icon_path, sizeof(icon_path), "%s%s",
1245 STC_NOTI_DATA_USAGE_ICON_PATH, STC_NOTI_DATA_USAGE_ICON_NAME);
1246 noti_err = notification_set_image(noti, NOTIFICATION_IMAGE_TYPE_ICON, icon_path);
1247 if (noti_err != NOTIFICATION_ERROR_NONE) {
1248 log_print(NET_POPUP, "Failed to notification_set_image : %d", noti_err);
1252 noti_err = notification_set_layout(noti, ly_type);
1253 if (noti_err != NOTIFICATION_ERROR_NONE) {
1254 log_print(NET_POPUP, "Failed to notification_set_layout : %d", noti_err);
1258 noti_err = notification_set_text_domain(noti, PACKAGE,
1260 if (noti_err != NOTIFICATION_ERROR_NONE) {
1261 log_print(NET_POPUP, "Failed to notification_set_text_domain : %d", noti_err);
1265 noti_err = notification_set_text(noti, NOTIFICATION_TEXT_TYPE_TITLE,
1266 title_text, title_key,
1267 NOTIFICATION_VARIABLE_TYPE_NONE);
1268 if (noti_err != NOTIFICATION_ERROR_NONE) {
1269 log_print(NET_POPUP, "Failed to notification_set_title : %d", noti_err);
1274 noti_err = notification_set_text(noti, NOTIFICATION_TEXT_TYPE_CONTENT,
1275 content_text, content_key,
1276 NOTIFICATION_VARIABLE_TYPE_NONE);
1277 if (noti_err != NOTIFICATION_ERROR_NONE) {
1278 log_print(NET_POPUP, "Failed to notification_set_content: %d", noti_err);
1283 noti_flags = NOTIFICATION_DISPLAY_APP_NOTIFICATION_TRAY |
1284 NOTIFICATION_DISPLAY_APP_TICKER | NOTIFICATION_DISPLAY_APP_INDICATOR;
1285 noti_err = notification_set_display_applist(noti, noti_flags);
1286 if (noti_err != NOTIFICATION_ERROR_NONE) {
1287 log_print(NET_POPUP, "Failed to notification_set_display_applist: %d", noti_err);
1292 ret = app_control_create(&service_handle);
1293 log_print(NET_POPUP, "Service create ret[%d]", ret);
1294 if (ret != APP_CONTROL_ERROR_NONE)
1297 ret = app_control_set_app_id(service_handle, launch_appid);
1298 log_print(NET_POPUP, "Service set app id ret = %d", ret);
1299 if (ret != APP_CONTROL_ERROR_NONE)
1302 ret = app_control_add_extra_data(service_handle, "caller", "notification");
1303 log_print(NET_POPUP, "Service data addition ret = %d", ret);
1304 if (ret != APP_CONTROL_ERROR_NONE)
1307 noti_err = notification_set_launch_option(noti,
1308 NOTIFICATION_LAUNCH_OPTION_APP_CONTROL, service_handle);
1309 if (noti_err != NOTIFICATION_ERROR_NONE) {
1310 log_print(NET_POPUP, "Failed to notification_set_launch_option");
1315 noti_err = notification_post(noti);
1316 if (noti_err != NOTIFICATION_ERROR_NONE) {
1317 log_print(NET_POPUP, "Failed to insert notification[error# is %d]", noti_err);
1321 log_print(NET_POPUP, "Successfully added notification");
1326 notification_free(noti);
1329 app_control_destroy(service_handle);
1332 static void __data_usage_btn_on_cb(void *data, Evas_Object *obj, void *event_info)
1334 log_print(NET_POPUP, "__data_usage_btn_on_cb()");
1335 Evas_Object *popup = (Evas_Object *)data;
1337 __net_popup_init_dbus();
1338 __net_popup_send_data_usage_msg(data_usage_app_id, data_usage_iftype);
1339 __net_popup_deinit_dbus();
1341 __data_usage_notification(NOTIFICATION_TYPE_ONGOING,
1342 NOTIFICATION_LY_ONGOING_EVENT,
1343 STC_NOTIFICATION_RESTRICTION_ON_TITLE,
1344 "IDS_SM_TMBODY_MOBILE_DATA_LIMIT_EXCEEDED_ABB",
1348 evas_object_del(popup);
1350 evas_object_del(obj);
1352 g_free(data_usage_app_id);
1353 g_free(data_usage_iftype);
1358 static void __data_usage_btn_ok_cb(void *data, Evas_Object *obj, void *event_info)
1360 log_print(NET_POPUP, "__data_usage_btn_ok_cb()");
1361 Evas_Object *popup = (Evas_Object *)data;
1363 __data_usage_notification(NOTIFICATION_TYPE_ONGOING,
1364 NOTIFICATION_LY_ONGOING_EVENT,
1365 STC_NOTIFICATION_RESTRICTION_OK_TITLE,
1366 "IDS_SM_HEADER_MOBILE_DATA_TURNED_OFF_ABB2",
1367 STC_NOTIFICATION_RESTRICTION_OK_CONTENT,
1368 "IDS_SM_SBODY_TAP_HERE_TO_TURN_IT_ON_AGAIN_ABB",
1372 evas_object_del(popup);
1374 evas_object_del(obj);
1376 g_free(data_usage_app_id);
1377 g_free(data_usage_iftype);
1382 static void __net_popup_show_popup_with_user_resp(app_control_h request,
1385 log_print(NET_POPUP, "__net_popup_show_popup_with_user_resp()\n");
1389 Evas_Object *layout;
1393 char *resp_popup_mode = NULL;
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 if (g_strcmp0(resp_popup_mode, "TETHERING_TYPE_WIFI") != 0 &&
1401 g_strcmp0(resp_popup_mode, "TETHERING_TYPE_WIFI_AP") != 0) {
1402 log_print(NET_POPUP, "Invalid popup mode [%s]", resp_popup_mode);
1403 g_free(resp_popup_mode);
1408 secure_log_print(NET_POPUP, "_SYSPOPUP_CONTENT_ = %s\n", resp_popup_mode);
1410 win = __net_popup_create_win();
1411 evas_object_show(win);
1413 popup = elm_popup_add(win);
1414 evas_object_size_hint_weight_set(popup, EVAS_HINT_EXPAND,
1417 log_print(NET_POPUP, "Drawing Wi-Fi Tethering OFF popup");
1419 __net_popup_init_dbus();
1420 elm_object_part_text_set(popup, "title,text", ALERT_STR_WIFI);
1422 layout = elm_layout_add(popup);
1423 elm_layout_file_set(layout, NETPOPUP_EDJ, "popup");
1424 evas_object_size_hint_weight_set(layout, EVAS_HINT_EXPAND,
1427 label = elm_label_add(popup);
1428 elm_label_line_wrap_set(label, ELM_WRAP_MIXED);
1429 elm_object_text_set(label, ALERT_STR_WIFI_MOBILE_AP_ON);
1430 evas_object_size_hint_weight_set(label, EVAS_HINT_EXPAND,
1432 evas_object_size_hint_align_set(label, EVAS_HINT_FILL, EVAS_HINT_FILL);
1433 evas_object_show(label);
1435 elm_object_part_content_set(layout, "elm.swallow.content", label);
1436 evas_object_show(layout);
1437 elm_object_style_set(label, "popup/default");
1438 eext_object_event_callback_add(popup, EEXT_CALLBACK_BACK, _btn_no_cb, popup);
1439 elm_object_content_set(popup, label);
1441 btn1 = elm_button_add(popup);
1442 elm_object_style_set(btn1, "popup");
1443 elm_object_text_set(btn1, ALERT_STR_CANCEL);
1444 elm_object_part_content_set(popup, "button1", btn1);
1445 evas_object_smart_callback_add(btn1, "clicked",
1448 btn2 = elm_button_add(popup);
1449 elm_object_style_set(btn2, "popup");
1450 elm_object_text_set(btn2, ALERT_STR_OK);
1451 elm_object_part_content_set(popup, "button2", btn2);
1453 if (g_strcmp0(resp_popup_mode, "TETHERING_TYPE_WIFI") == 0)
1454 evas_object_smart_callback_add(btn2, "clicked",
1455 _tethering_wifi_btn_yes_cb, popup);
1456 else if (g_strcmp0(resp_popup_mode, "TETHERING_TYPE_WIFI_AP") == 0)
1457 evas_object_smart_callback_add(btn2, "clicked",
1458 _tethering_wifi_ap_btn_yes_cb, popup);
1460 evas_object_show(popup);
1461 evas_object_show(win);
1462 __net_popup_deinit_dbus();
1465 static void __net_popup_show_vpn_popup(app_control_h request, void *data)
1469 Evas_Object *button1;
1470 Evas_Object *button2;
1473 char *content = NULL;
1474 char *ok_btn = NULL;
1477 log_print(NET_POPUP, "__net_popup_show_vpn_popup");
1479 int ret = app_control_get_extra_data(request, APP_CONTROL_DATA_TYPE, &type);
1480 if (APP_CONTROL_ERROR_NONE != ret) {
1481 log_print(NET_POPUP, "Failed to get APP_CONTROL_DATA_TYPE ret = %d", ret);
1486 ret = app_control_get_extra_data(request, APP_CONTROL_DATA_NAME, &iface_name);
1487 if (APP_CONTROL_ERROR_NONE != ret) {
1488 log_print(NET_POPUP, "Failed to get APP_CONTROL_DATA_NAME ret = %d", ret);
1493 log_print(NET_POPUP, "type(%s) name(%s)", type, iface_name);
1495 if (strcmp(type, "up") == 0) {
1496 title = ALERT_STR_VPN_CONNECT_TITLE;
1497 content = ALERT_STR_VPN_CONNECT_CONTENT;
1498 ok_btn = ALERT_STR_VPN_CONNECT_BUTTON;
1499 ok_cb = _vpn_btn_connect_cb;
1500 } else if (strcmp(type, "down") == 0) {
1501 title = ALERT_STR_VPN_DISCONNECT_TITLE;
1502 content = ALERT_STR_VPN_DISCONNECT_CONTENT;
1503 ok_btn = ALERT_STR_VPN_DISCONNECT_BUTTON;
1504 ok_cb = _vpn_btn_disconnect_cb;
1506 log_print(NET_POPUP, "Invalid appcontrol value");
1514 log_print(NET_POPUP, "title(%s) content(%s) ok(%s)", title, content, ok_btn);
1516 win = __net_popup_create_win();
1518 popup = elm_popup_add(win);
1519 evas_object_size_hint_weight_set(popup, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
1521 elm_object_text_set(popup, content);
1522 elm_object_part_text_set(popup, "title,text", title);
1525 button1 = elm_button_add(popup);
1526 elm_object_style_set(button1, "bottom");
1527 elm_object_text_set(button1, ALERT_STR_CANCEL);
1528 elm_object_part_content_set(popup, "button1", button1);
1529 evas_object_smart_callback_add(button1, "clicked", _vpn_btn_no_cb, popup);
1532 button2 = elm_button_add(popup);
1533 elm_object_style_set(button2, "bottom");
1534 elm_object_text_set(button2, ok_btn);
1535 elm_object_part_content_set(popup, "button2", button2);
1536 evas_object_smart_callback_add(button2, "clicked", ok_cb, popup);
1538 evas_object_show(popup);
1539 evas_object_show(win);
1544 static void __net_popup_show_warning_noti(app_control_h request, void *data)
1546 log_print(NET_POPUP, "__net_popup_show_warning_noti()\n");
1548 int ret = app_control_get_extra_data(request, "_APP_ID_", &data_usage_app_id);
1549 if (APP_CONTROL_ERROR_NONE != ret) {
1550 log_print(NET_POPUP, "Failed to get _APP_ID_ ret = %d", ret);
1555 if (strcmp(data_usage_app_id, STC_TOTAL_DATACALL) &&
1556 strcmp(data_usage_app_id, STC_TOTAL_WIFI) &&
1557 strcmp(data_usage_app_id, STC_TOTAL_BLUETOOTH)) {
1558 log_print(NET_POPUP, "It's not total data usage [%s]", data_usage_app_id);
1559 g_free(data_usage_app_id);
1564 __data_usage_notification(NOTIFICATION_TYPE_ONGOING,
1565 NOTIFICATION_LY_ONGOING_EVENT,
1566 STC_NOTIFICATION_WARNING_TITLE,
1567 "IDS_COM_BODY_DATA_USAGE_WARNING",
1568 STC_NOTIFICATION_WARNING_CONTENT,
1569 "IDS_SM_SBODY_TAP_HERE_TO_VIEW_YOUR_DATA_USAGE_ABB",
1573 static void __net_popup_show_restriction_noti(app_control_h request, void *data)
1577 Evas_Object *button1;
1578 Evas_Object *button2;
1580 char *content = NULL;
1582 char *on_btn = NULL;
1583 char *ok_btn = NULL;
1584 char buf[ALERT_STR_LEN_MAX] = "";
1586 log_print(NET_POPUP, "__net_popup_show_data_usage_popup");
1588 int ret = app_control_get_extra_data(request, "_APP_ID_", &data_usage_app_id);
1589 if (APP_CONTROL_ERROR_NONE != ret) {
1590 log_print(NET_POPUP, "Failed to get _APP_ID_ ret = %d", ret);
1595 if (strcmp(data_usage_app_id, STC_TOTAL_DATACALL) &&
1596 strcmp(data_usage_app_id, STC_TOTAL_WIFI) &&
1597 strcmp(data_usage_app_id, STC_TOTAL_BLUETOOTH)) {
1598 log_print(NET_POPUP, "It's not total data usage [%s]", data_usage_app_id);
1599 g_free(data_usage_app_id);
1604 ret = app_control_get_extra_data(request, "_IF_TYPE_", &data_usage_iftype);
1605 if (APP_CONTROL_ERROR_NONE != ret) {
1606 log_print(NET_POPUP, "Failed to get _IF_TYPE_ ret = %d", ret);
1607 g_free(data_usage_app_id);
1612 ret = app_control_get_extra_data(request, "_RESTRICTION_LIMIT_", &limit);
1613 if (APP_CONTROL_ERROR_NONE != ret) {
1614 log_print(NET_POPUP, "Failed to get _RESTRICTION_LIMIT_ ret = %d", ret);
1615 g_free(data_usage_app_id);
1616 g_free(data_usage_iftype);
1621 title = ALERT_STR_DATA_USAGE_TITLE;
1622 g_snprintf(buf, ALERT_STR_LEN_MAX, ALERT_STR_DATA_USAGE_CONTENT, limit);
1624 on_btn = ALERT_STR_DATA_USAGE_TURN_ON_BUTTON;
1625 ok_btn = ALERT_STR_OK;
1627 log_print(NET_POPUP, "title(%s) content(%s) app_id(%s) iftype(%s) limit(%s)",
1628 title, content, data_usage_app_id, data_usage_iftype, limit);
1630 win = __net_popup_create_win();
1632 popup = elm_popup_add(win);
1633 evas_object_size_hint_weight_set(popup, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
1635 elm_object_text_set(popup, content);
1636 elm_object_part_text_set(popup, "title,text", title);
1639 button1 = elm_button_add(popup);
1640 elm_object_style_set(button1, "bottom");
1641 elm_object_text_set(button1, on_btn);
1642 elm_object_part_content_set(popup, "button1", button1);
1643 evas_object_smart_callback_add(button1, "clicked", __data_usage_btn_on_cb, popup);
1646 button2 = elm_button_add(popup);
1647 elm_object_style_set(button2, "bottom");
1648 elm_object_text_set(button2, ok_btn);
1649 elm_object_part_content_set(popup, "button2", button2);
1650 evas_object_smart_callback_add(button2, "clicked", __data_usage_btn_ok_cb, popup);
1652 evas_object_show(popup);
1653 evas_object_show(win);
1658 static int __net_popup_show_popup(app_control_h request, void *data)
1660 log_print(NET_POPUP, "__net_popup_show_popup()\n");
1664 Evas_Object *button;
1668 ret = app_control_get_extra_data(request, "_SYSPOPUP_CONTENT_", &mode);
1669 if (APP_CONTROL_ERROR_NONE != ret) {
1670 log_print(NET_POPUP, "Failed to get _SYSPOPUP_CONTENT_ ret = %d", ret);
1676 secure_log_print(NET_POPUP, "_SYSPOPUP_CONTENT_ = %s\n", mode);
1678 win = __net_popup_create_win();
1680 popup = elm_popup_add(win);
1681 evas_object_size_hint_weight_set(popup, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
1682 if (strcmp(mode, "connected") == 0) {
1683 elm_object_text_set(popup, ALERT_STR_MOBILE_NETWORKS_CHARGE);
1684 log_print(NET_POPUP, "alert 3g\n");
1685 } else if (strcmp(mode, "fail to connect") == 0) {
1686 elm_object_text_set(popup, ALERT_STR_ERR_UNAVAILABLE);
1687 log_print(NET_POPUP, "alert err\n");
1688 } else if (strcmp(mode, "unable to connect") == 0) {
1689 elm_object_text_set(popup, ALERT_STR_ERR_CONNECT);
1690 log_print(NET_POPUP, "alert unable to connect\n");
1691 } else if (strcmp(mode, "wrong password") == 0) {
1692 elm_object_text_set(popup, ALERT_STR_ERR_WRONG_PASSWORD);
1693 log_print(NET_POPUP, "alert wrong password\n");
1694 } else if (strcmp(mode, "not support") == 0) {
1695 elm_object_text_set(popup, ALERT_STR_ERR_NOT_SUPPORT);
1696 log_print(NET_POPUP, "alert not support\n");
1697 } else if (strcmp(mode, "wifi restricted") == 0) {
1698 elm_object_text_set(popup, ALERT_STR_RESTRICTED_USE_WIFI);
1699 log_print(NET_POPUP, "alert wifi restricted\n");
1700 } else if (strcmp(mode, "no ap found") == 0) {
1701 elm_object_text_set(popup, ALERT_STR_NO_AP_FOUND);
1702 log_print(NET_POPUP, "alert no ap found\n");
1703 } else if (strcmp(mode, "wifi connected") == 0) {
1704 char buf[ALERT_STR_LEN_MAX] = "";
1705 char *ap_name = NULL;
1707 ret = app_control_get_extra_data(request, "_AP_NAME_", &ap_name);
1709 if (ap_name != NULL)
1710 g_snprintf(buf, ALERT_STR_LEN_MAX, ALERT_STR_WIFI_CONNECTED, ap_name);
1712 g_snprintf(buf, ALERT_STR_LEN_MAX, ALERT_STR_WIFI_CONNECTED, "");
1714 elm_object_text_set(popup, buf);
1716 log_print(NET_POPUP, "alert wifi connected\n");
1719 elm_object_text_set(popup, mode);
1720 log_print(NET_POPUP, "%s\n", mode);
1723 button = elm_button_add(popup);
1724 elm_object_style_set(button, "popup");
1725 elm_object_text_set(button, ALERT_STR_OK);
1726 elm_object_part_content_set(popup, "button1", button);
1727 evas_object_smart_callback_add(button, "clicked", _ok_button_clicked_cb, popup);
1728 evas_object_show(popup);
1729 evas_object_show(win);
1735 static void __net_popup_add_found_ap_noti(void)
1737 log_print(NET_POPUP, "__net_popup_add_found_ap_noti()\n");
1739 int ret = 0, noti_flags = 0;
1740 char icon_path[ICON_PATH_LEN];
1741 notification_h noti = NULL;
1742 notification_list_h noti_list = NULL;
1743 notification_error_e noti_err = NOTIFICATION_ERROR_NONE;
1744 app_control_h service_handle = NULL;
1746 notification_get_detail_list(NET_POPUP_APPID, NOTIFICATION_GROUP_ID_NONE,
1747 NOTIFICATION_PRIV_ID_NONE, -1, ¬i_list);
1748 if (noti_list != NULL) {
1749 notification_free_list(noti_list);
1753 noti = notification_create(NOTIFICATION_TYPE_ONGOING);
1755 log_print(NET_POPUP, "Failed to create notification");
1759 noti_err = notification_set_time(noti, time(NULL));
1760 if (noti_err != NOTIFICATION_ERROR_NONE) {
1761 log_print(NET_POPUP, "Failed to notification_set_time : %d", noti_err);
1765 g_snprintf(icon_path, sizeof(icon_path), "%s%s", QP_PRELOAD_NOTI_ICON_PATH, "/noti_wifi_in_range.png");
1766 noti_err = notification_set_image(noti, NOTIFICATION_IMAGE_TYPE_ICON, icon_path);
1767 if (noti_err != NOTIFICATION_ERROR_NONE) {
1768 log_print(NET_POPUP, "Failed to notification_set_image : %d", noti_err);
1772 noti_err = notification_set_layout(noti, NOTIFICATION_LY_ONGOING_EVENT);
1773 if (noti_err != NOTIFICATION_ERROR_NONE) {
1774 log_print(NET_POPUP, "Failed to notification_set_layout : %d", noti_err);
1778 noti_err = notification_set_text_domain(noti, PACKAGE,
1780 if (noti_err != NOTIFICATION_ERROR_NONE) {
1781 log_print(NET_POPUP, "Failed to notification_set_text_domain : %d", noti_err);
1785 noti_err = notification_set_text(noti, NOTIFICATION_TEXT_TYPE_TITLE,
1786 NETCONFIG_NOTIFICATION_WIFI_FOUND_TITLE,
1787 "IDS_COM_BODY_WI_FI_NETWORKS_AVAILABLE",
1788 NOTIFICATION_VARIABLE_TYPE_NONE);
1789 if (noti_err != NOTIFICATION_ERROR_NONE) {
1790 log_print(NET_POPUP, "Failed to notification_set_title : %d", noti_err);
1794 noti_err = notification_set_text(noti, NOTIFICATION_TEXT_TYPE_CONTENT,
1795 NETCONFIG_NOTIFICATION_WIFI_FOUND_CONTENT,
1796 "IDS_WIFI_SBODY_TAP_HERE_TO_CONNECT",
1797 NOTIFICATION_VARIABLE_TYPE_NONE);
1798 if (noti_err != NOTIFICATION_ERROR_NONE) {
1799 log_print(NET_POPUP, "Failed to notification_set_content: %d", noti_err);
1803 noti_flags = NOTIFICATION_DISPLAY_APP_NOTIFICATION_TRAY | NOTIFICATION_DISPLAY_APP_INDICATOR;
1804 noti_err = notification_set_display_applist(noti, noti_flags);
1805 if (noti_err != NOTIFICATION_ERROR_NONE) {
1806 log_print(NET_POPUP, "Failed to notification_set_display_applist: %d", noti_err);
1810 ret = app_control_create(&service_handle);
1811 log_print(NET_POPUP, "Service create ret[%d]", ret);
1812 if (ret != APP_CONTROL_ERROR_NONE)
1815 ret = app_control_set_app_id(service_handle, NET_WIFIQS_APPID);
1816 log_print(NET_POPUP, "Service set app id ret = %d", ret);
1817 if (ret != APP_CONTROL_ERROR_NONE)
1820 ret = app_control_add_extra_data(service_handle, "caller", "notification");
1821 log_print(NET_POPUP, "Service data addition ret = %d", ret);
1822 if (ret != APP_CONTROL_ERROR_NONE)
1825 noti_err = notification_set_launch_option(noti,
1826 NOTIFICATION_LAUNCH_OPTION_APP_CONTROL, service_handle);
1827 if (noti_err != NOTIFICATION_ERROR_NONE) {
1828 log_print(NET_POPUP, "Failed to notification_set_launch_option");
1832 noti_err = notification_post(noti);
1833 if (noti_err != NOTIFICATION_ERROR_NONE) {
1834 log_print(NET_POPUP, "Failed to insert notification[error# is %d]", noti_err);
1838 log_print(NET_POPUP, "Successfully added notification");
1843 notification_free(noti);
1846 app_control_destroy(service_handle);
1849 static void __net_popup_del_found_ap_noti(void)
1851 log_print(NET_POPUP, "__net_popup_del_found_ap_noti()\n");
1853 notification_error_e noti_err = NOTIFICATION_ERROR_NONE;
1855 noti_err = notification_delete_all(NOTIFICATION_TYPE_ONGOING);
1856 if (noti_err != NOTIFICATION_ERROR_NONE) {
1857 log_print(NET_POPUP, "fail to notification_delete_by_priv_id");
1861 log_print(NET_POPUP, "Successfully deleted notification");
1864 static void __net_popup_add_ip_conflict_noti(app_control_h request)
1866 log_print(NET_POPUP, "__net_popup_add_portal_noti()\n");
1871 char icon_path[ICON_PATH_LEN];
1872 notification_h noti = NULL;
1873 app_control_h service_handle = NULL;
1874 notification_list_h noti_list = NULL;
1875 notification_error_e noti_err = NOTIFICATION_ERROR_NONE;
1877 ret = app_control_get_extra_data(request, "_MAC_ADDRESS_", &mac);
1879 if (mac == NULL || ret != APP_CONTROL_ERROR_NONE) {
1880 log_print(NET_POPUP, "Failed to retrieve mac address!!");
1885 log_print(NET_POPUP, "Successfully added notification");
1887 notification_get_detail_list(NET_POPUP_APPID, NOTIFICATION_GROUP_ID_NONE,
1888 NOTIFICATION_PRIV_ID_NONE, -1, ¬i_list);
1889 if (noti_list != NULL) {
1890 notification_free_list(noti_list);
1895 noti = notification_create(NOTIFICATION_TYPE_NOTI);
1897 log_print(NET_POPUP, "fail to create notification");
1902 noti_err = notification_set_time(noti, time(NULL));
1903 if (noti_err != NOTIFICATION_ERROR_NONE) {
1904 log_print(NET_POPUP, "fail to notification_set_time : %d", noti_err);
1908 noti_err = notification_set_image(noti, NOTIFICATION_IMAGE_TYPE_ICON,
1909 NETCONFIG_NOTIFICATION_WIFI_ICON_LITE);
1910 if (noti_err != NOTIFICATION_ERROR_NONE) {
1911 log_print(NET_POPUP, "fail to notification_set_image : %d", noti_err);
1915 g_snprintf(icon_path, sizeof(icon_path), "%s%s", QP_PRELOAD_NOTI_ICON_PATH, "/noti_wifi_in_range_ongoing.png");
1916 noti_err = notification_set_image(noti, NOTIFICATION_IMAGE_TYPE_ICON, icon_path);
1917 if (noti_err != NOTIFICATION_ERROR_NONE) {
1918 log_print(NET_POPUP, "fail to notification_set_image : %d", noti_err);
1922 noti_err = notification_set_layout(noti, NOTIFICATION_LY_NOTI_EVENT_MULTIPLE);
1923 if (noti_err != NOTIFICATION_ERROR_NONE) {
1924 log_print(NET_POPUP, "fail to notification_set_layout : %d", noti_err);
1928 noti_err = notification_set_text_domain(noti, PACKAGE,
1930 if (noti_err != NOTIFICATION_ERROR_NONE) {
1931 log_print(NET_POPUP, "fail to notification_set_text_domain : %d", noti_err);
1935 noti_err = notification_set_text(noti, NOTIFICATION_TEXT_TYPE_TITLE,
1936 NETCONFIG_NOTIFICATION_IP_CONFLICT_TITLE,
1938 NOTIFICATION_VARIABLE_TYPE_NONE);
1939 if (noti_err != NOTIFICATION_ERROR_NONE) {
1940 log_print(NET_POPUP, "fail to notification_set_title : %d", noti_err);
1944 noti_err = notification_set_text(noti, NOTIFICATION_TEXT_TYPE_CONTENT,
1945 NETCONFIG_NOTIFICATION_WIFI_PORTAL_CONTENT,
1946 NETCONFIG_NOTIFICATION_WIFI_PORTAL_CONTENT,
1947 NOTIFICATION_VARIABLE_TYPE_STRING, mac,
1948 NOTIFICATION_VARIABLE_TYPE_NONE);
1949 if (noti_err != NOTIFICATION_ERROR_NONE) {
1950 log_print(NET_POPUP, "fail to notification_set_content : %d", noti_err);
1954 noti_flags = NOTIFICATION_DISPLAY_APP_NOTIFICATION_TRAY | NOTIFICATION_DISPLAY_APP_INDICATOR;
1955 noti_err = notification_set_display_applist(noti, noti_flags);
1956 if (noti_err != NOTIFICATION_ERROR_NONE) {
1957 log_print(NET_POPUP, "fail to notification_set_display_applist : %d", noti_err);
1961 ret = app_control_create(&service_handle);
1962 log_print(NET_POPUP, "service create ret[%d]", ret);
1963 if (ret != APP_CONTROL_ERROR_NONE)
1966 ret = app_control_set_app_id(service_handle, WIFI_EFL_UG);
1967 log_print(NET_POPUP, "Service set app id ret = %d", ret);
1968 if (ret != APP_CONTROL_ERROR_NONE)
1971 ret = app_control_add_extra_data(service_handle, "caller", "notification");
1972 log_print(NET_POPUP, "Service data addition ret = %d", ret);
1973 if (ret != APP_CONTROL_ERROR_NONE)
1976 noti_err = notification_set_launch_option(noti,
1977 NOTIFICATION_LAUNCH_OPTION_APP_CONTROL, service_handle);
1978 if (noti_err != NOTIFICATION_ERROR_NONE) {
1979 log_print(NET_POPUP, "fail to notification_set_launch_option");
1983 noti_err = notification_post(noti);
1984 if (noti_err != NOTIFICATION_ERROR_NONE) {
1985 log_print(NET_POPUP, "fail to notification_post");
1989 log_print(NET_POPUP, "Successfully added notification");
1994 notification_free(noti);
1996 if (service_handle != NULL)
1997 app_control_destroy(service_handle);
2000 static void __net_popup_add_portal_noti(app_control_h request)
2002 log_print(NET_POPUP, "__net_popup_add_portal_noti()\n");
2006 char *ap_name = NULL;
2007 char icon_path[ICON_PATH_LEN];
2008 notification_h noti = NULL;
2009 app_control_h service_handle = NULL;
2010 notification_list_h noti_list = NULL;
2011 notification_error_e noti_err = NOTIFICATION_ERROR_NONE;
2013 ret = app_control_get_extra_data(request, "_AP_NAME_", &ap_name);
2015 if (ap_name == NULL || ret != APP_CONTROL_ERROR_NONE) {
2016 log_print(NET_POPUP, "Failed to retrieve connected AP name!!");
2021 log_print(NET_POPUP, "Successfully added notification");
2023 notification_get_detail_list(NET_POPUP_APPID, NOTIFICATION_GROUP_ID_NONE,
2024 NOTIFICATION_PRIV_ID_NONE, -1, ¬i_list);
2025 if (noti_list != NULL) {
2026 notification_free_list(noti_list);
2031 noti = notification_create(NOTIFICATION_TYPE_NOTI);
2033 log_print(NET_POPUP, "fail to create notification");
2038 noti_err = notification_set_time(noti, time(NULL));
2039 if (noti_err != NOTIFICATION_ERROR_NONE) {
2040 log_print(NET_POPUP, "fail to notification_set_time : %d", noti_err);
2044 noti_err = notification_set_image(noti, NOTIFICATION_IMAGE_TYPE_ICON,
2045 NETCONFIG_NOTIFICATION_WIFI_ICON);
2046 if (noti_err != NOTIFICATION_ERROR_NONE) {
2047 log_print(NET_POPUP, "fail to notification_set_image : %d", noti_err);
2051 g_snprintf(icon_path, sizeof(icon_path), "%s%s", QP_PRELOAD_NOTI_ICON_PATH, "/noti_wifi_in_range.png");
2052 noti_err = notification_set_image(noti, NOTIFICATION_IMAGE_TYPE_ICON, icon_path);
2053 if (noti_err != NOTIFICATION_ERROR_NONE) {
2054 log_print(NET_POPUP, "fail to notification_set_image : %d", noti_err);
2057 noti_err = notification_set_layout(noti, NOTIFICATION_LY_NOTI_EVENT_MULTIPLE);
2058 if (noti_err != NOTIFICATION_ERROR_NONE) {
2059 log_print(NET_POPUP, "fail to notification_set_layout : %d", noti_err);
2063 noti_err = notification_set_text_domain(noti, PACKAGE,
2065 if (noti_err != NOTIFICATION_ERROR_NONE) {
2066 log_print(NET_POPUP, "fail to notification_set_text_domain : %d", noti_err);
2070 noti_err = notification_set_text(noti, NOTIFICATION_TEXT_TYPE_TITLE,
2071 NETCONFIG_NOTIFICATION_WIFI_PORTAL_TITLE,
2072 "IDS_WIFI_HEADER_SIGN_IN_TO_WI_FI_NETWORK_ABB",
2073 NOTIFICATION_VARIABLE_TYPE_NONE);
2074 if (noti_err != NOTIFICATION_ERROR_NONE) {
2075 log_print(NET_POPUP, "fail to notification_set_title : %d", noti_err);
2079 noti_err = notification_set_text(noti, NOTIFICATION_TEXT_TYPE_CONTENT,
2080 NETCONFIG_NOTIFICATION_WIFI_PORTAL_CONTENT,
2081 NETCONFIG_NOTIFICATION_WIFI_PORTAL_CONTENT,
2082 NOTIFICATION_VARIABLE_TYPE_STRING, ap_name,
2083 NOTIFICATION_VARIABLE_TYPE_NONE);
2084 if (noti_err != NOTIFICATION_ERROR_NONE) {
2085 log_print(NET_POPUP, "fail to notification_set_content : %d", noti_err);
2089 noti_flags = NOTIFICATION_DISPLAY_APP_NOTIFICATION_TRAY | NOTIFICATION_DISPLAY_APP_INDICATOR;
2090 noti_err = notification_set_display_applist(noti, noti_flags);
2091 if (noti_err != NOTIFICATION_ERROR_NONE) {
2092 log_print(NET_POPUP, "fail to notification_set_display_applist : %d", noti_err);
2096 ret = app_control_create(&service_handle);
2097 log_print(NET_POPUP, "service create ret[%d]", ret);
2098 if (ret != APP_CONTROL_ERROR_NONE)
2101 ret = app_control_set_operation(service_handle, APP_CONTROL_OPERATION_VIEW);
2102 if (ret != APP_CONTROL_ERROR_NONE)
2105 log_print(NET_POPUP, "service set operation is successful");
2107 ret = app_control_set_uri(service_handle, "http://www.google.com");
2109 if (ret != APP_CONTROL_ERROR_NONE)
2112 noti_err = notification_set_launch_option(noti,
2113 NOTIFICATION_LAUNCH_OPTION_APP_CONTROL, service_handle);
2114 if (noti_err != NOTIFICATION_ERROR_NONE) {
2115 log_print(NET_POPUP, "fail to notification_set_launch_option");
2119 noti_err = notification_post(noti);
2120 if (noti_err != NOTIFICATION_ERROR_NONE) {
2121 log_print(NET_POPUP, "fail to notification_post");
2125 log_print(NET_POPUP, "Successfully added notification");
2130 notification_free(noti);
2132 if (service_handle != NULL)
2133 app_control_destroy(service_handle);
2136 static void __net_popup_del_ip_conflict_noti(void)
2138 log_print(NET_POPUP, "__net_popup_del_ip_conflict_noti()\n");
2140 notification_error_e noti_err = NOTIFICATION_ERROR_NONE;
2142 noti_err = notification_delete_all(NOTIFICATION_TYPE_NOTI);
2143 if (noti_err != NOTIFICATION_ERROR_NONE) {
2144 log_print(NET_POPUP, "fail to notification_delete_all");
2148 log_print(NET_POPUP, "Successfully deleted notification");
2151 static void __net_popup_del_portal_noti(void)
2153 log_print(NET_POPUP, "__net_popup_del_portal_noti()\n");
2155 notification_error_e noti_err = NOTIFICATION_ERROR_NONE;
2157 noti_err = notification_delete_all(NOTIFICATION_TYPE_NOTI);
2158 if (noti_err != NOTIFICATION_ERROR_NONE) {
2159 log_print(NET_POPUP, "fail to notification_delete_all");
2163 log_print(NET_POPUP, "Successfully deleted notification");
2166 EXPORT_API int main(int argc, char *argv[])
2168 log_print(NET_POPUP, "main()\n");
2170 __net_popup_get_tizen_profile();
2172 if (g_profile == TIZEN_PROFILE_MOBILE) {
2173 ui_app_lifecycle_callback_s app_callback = {
2174 .create = __net_popup_create,
2175 .terminate = __net_popup_terminate,
2176 .pause = __net_popup_pause,
2177 .resume = __net_popup_resume,
2178 .app_control = __net_popup_service_cb,
2181 return ui_app_main(argc, argv, &app_callback, NULL);
2182 } else if (g_profile == TIZEN_PROFILE_WEARABLE) {
2183 return net_popup_w_init(argc, argv);