4 * Copyright 2012 Samsung Electronics Co., Ltd
6 * Licensed under the Flora License, Version 1.0 (the "License");
7 * you may not use this file except in compliance with the License.
8 * You may obtain a copy of the License at
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>
32 #include <vconf-keys.h>
34 #include <dbus/dbus.h>
35 #include <efl_extension.h>
36 #include <tzplatform_config.h>
38 #include "net-popup.h"
39 #include "net-popup-strings.h"
41 #define NET_WIFIQS_APPID "net.wifi-qs"
43 #define LOCALEDIR "/usr/share/locale"
44 #define NETPOPUP_EDJ tzplatform_mkpath(TZ_SYS_RO_UG, "/res/edje/net-popup/netpopup-custom.edj")
45 #define QP_PRELOAD_NOTI_ICON_PATH tzplatform_mkpath(TZ_SYS_RO_APP, "/org.tizen.quickpanel/shared/res/noti_icons/Wi-Fi")
47 #define NETCONFIG_NOTIFICATION_WIFI_ICON \
48 tzplatform_mkpath(TZ_SYS_RO_ICONS, "/noti_wifi_in_range.png")
49 #define NETCONFIG_NOTIFICATION_WIFI_ICON_LITE \
50 tzplatform_mkpath(TZ_SYS_RO_ICONS, "/noti_wifi_in_range_ongoing.png")
51 #define NETCONFIG_NOTIFICATION_WIFI_CAPTIVE_ICON \
52 tzplatform_mkpath(TZ_SYS_RO_ICONS, "/B03_notify_Wi-fi_range.png")
53 #define NETCONFIG_NOTIFICATION_WIFI_IN_RANGE_ICON \
54 tzplatform_mkpath(TZ_SYS_RO_ICONS, "/Q02_Notification_wifi_in_range.png")
55 #define NETCONFIG_NOTIFICATION_WIFI_IN_RANGE_ICON_LITE \
56 tzplatform_mkpath(TZ_SYS_RO_ICONS, "/noti_wifi_in_range.png")
57 #define NETCONFIG_NOTIFICATION_WIFI_FOUND_TITLE \
58 dgettext(PACKAGE, "IDS_COM_BODY_WI_FI_NETWORKS_AVAILABLE")
59 #define NETCONFIG_NOTIFICATION_WIFI_FOUND_CONTENT \
60 dgettext(PACKAGE, "IDS_WIFI_SBODY_TAP_HERE_TO_CONNECT")
61 #define NETCONFIG_NOTIFICATION_WIFI_PORTAL_TITLE \
62 dgettext(PACKAGE, "IDS_WIFI_HEADER_SIGN_IN_TO_WI_FI_NETWORK_ABB")
63 #define NETCONFIG_NOTIFICATION_WIFI_PORTAL_CONTENT "\"%s\""
65 #define USER_RESP_LEN 30
66 #define ICON_PATH_LEN 128
67 #define RESP_REMAIN_CONNECTED "RESP_REMAIN_CONNECTED"
68 #define RESP_WIFI_TETHERING_OFF "RESP_TETHERING_TYPE_WIFI_OFF"
69 #define RESP_WIFI_AP_TETHERING_OFF "RESP_TETHERING_TYPE_WIFI_AP_OFF"
70 #define RESP_TETHERING_ON "RESP_TETHERING_ON"
71 #define CAPTIVE_PORTAL_LOGIN "Login required to access Internet"
72 #define CAPTIVE_PORTAL_LOGIN_ERROR "Login not completed. Disconnected active Wifi"
74 static Ecore_Event_Handler *ecore_event_evas_handler;
75 static Ecore_Event_Handler *ecore_event_evas_quick_panel_handler;
78 long sizes[] = {1073741824, 1048576, 1024, 0};
79 char *units[] = {"GB", "MB", "KB", "B"};
81 static app_control_h g_req_handle = NULL;
82 static char * resp_popup_mode = NULL;
84 static GDBusConnection *conn = NULL;
85 static GDBusProxy *proxy = NULL;
87 static int __net_popup_show_notification(app_control_h request, void *data);
88 static int __toast_popup_show(app_control_h request, void *data);
89 static int __net_popup_show_popup(app_control_h request, void *data);
90 static void __net_popup_add_found_ap_noti(void);
91 static void __net_popup_del_found_ap_noti(void);
92 static void __net_popup_add_portal_noti(app_control_h request);
93 static void __net_popup_del_portal_noti(void);
94 static void __net_popup_show_popup_with_user_resp(app_control_h request, void *data);
95 static int _net_popup_send_user_resp(char *resp, Eina_Bool state);
98 GDBusProxy *__net_popup_init_dbus(void)
100 log_print(NET_POPUP, "__net_popup_init_dbus()\n");
104 conn = g_bus_get_sync(G_BUS_TYPE_SYSTEM, NULL, &err);
110 proxy = g_dbus_proxy_new_sync(conn, G_DBUS_PROXY_FLAGS_NONE, NULL,
117 g_object_unref(conn);
124 void __net_popup_deinit_dbus(void)
126 log_print(NET_POPUP, "__net_popup_deinit_dbus()\n");
129 g_object_unref(proxy);
134 g_object_unref(conn);
141 int __net_popup_send_dbus_msg(const char *resp)
143 log_print(NET_POPUP, "__net_popup_send_dbus_msg()\n");
145 if (conn == NULL || resp == NULL) {
149 GDBusConnection *gconn = NULL;
150 GVariant *msg = NULL;
151 char *module = "wifi";
154 gconn = g_bus_get_sync(DBUS_BUS_SYSTEM, NULL, &err);
161 msg = g_variant_new("(ss)", module, resp);
162 g_dbus_connection_emit_signal(gconn, NULL, "/Org/Tizen/Quickpanel",
163 "org.tizen.quickpanel", "ACTIVITY", msg, &err);
169 g_variant_unref(msg);
172 g_object_unref(gconn);
178 static bool __net_popup_create(void *data)
180 log_print(NET_POPUP, "__net_popup_create()\n");
182 bindtextdomain(PACKAGE, LOCALEDIR);
187 static void __net_popup_terminate(void *data)
189 log_print(NET_POPUP, "__net_popup_terminate()\n");
191 if (ecore_event_evas_handler) {
192 ecore_event_handler_del(ecore_event_evas_handler);
193 ecore_event_evas_handler = NULL;
195 if (ecore_event_evas_quick_panel_handler) {
196 ecore_event_handler_del(ecore_event_evas_quick_panel_handler);
197 ecore_event_evas_quick_panel_handler = NULL;
203 static void __net_popup_pause(void *data)
205 log_print(NET_POPUP, "__net_popup_pause()\n");
208 static void __net_popup_resume(void *data)
213 static Eina_Bool __key_release_event_cb(void *data, int type,
216 log_print(NET_POPUP, "__key_release_event_cb()\n");
218 Evas_Event_Key_Down *ev = (Evas_Event_Key_Down *) event;
221 return ECORE_CALLBACK_RENEW;
225 return ECORE_CALLBACK_RENEW;
228 log_print(NET_POPUP, "key_release : %s", ev->keyname);
229 if (g_strcmp0(ev->keyname, "XF86Phone") == 0 ||
230 g_strcmp0(ev->keyname, "XF86Stop") == 0) {
234 return ECORE_CALLBACK_DONE;
238 static Eina_Bool _ecore_event_client_message_cb(void *data, int type,
241 Ecore_X_Event_Client_Message *ev = event;
243 if (ev->message_type == ECORE_X_ATOM_E_ILLUME_QUICKPANEL_STATE) {
244 if (ev->data.l[0] == ECORE_X_ATOM_E_ILLUME_QUICKPANEL_OFF) {
245 log_print(NET_POPUP, "ECORE_X_ATOM_E_ILLUME_QUICKPANEL_OFF");
246 } else if (ev->data.l[0] == ECORE_X_ATOM_E_ILLUME_QUICKPANEL_ON) {
247 log_print(NET_POPUP, "ECORE_X_ATOM_E_ILLUME_QUICKPANEL_ON");
250 return ECORE_CALLBACK_RENEW;
254 static void __net_popup_service_cb(app_control_h request, void *data)
256 log_print(NET_POPUP, "__net_popup_service_cb()\n");
261 if (ecore_event_evas_handler == NULL) {
262 ecore_event_evas_handler = ecore_event_handler_add(ECORE_EVENT_KEY_UP,
263 __key_release_event_cb, NULL);
267 if (ecore_event_evas_quick_panel_handler == NULL) {
268 ecore_event_evas_quick_panel_handler = ecore_event_handler_add(
269 ECORE_X_EVENT_CLIENT_MESSAGE, _ecore_event_client_message_cb, NULL);
273 ret = app_control_get_extra_data(request, "_SYSPOPUP_TYPE_", &type);
275 if (APP_CONTROL_ERROR_NONE != ret) {
276 log_print(NET_POPUP, "Failed to get _SYSPOPUP_TYPE_ ret = %d", ret);
282 log_print(NET_POPUP, "type = %s\n", type);
284 if (g_str_equal(type, "notification")) {
285 __net_popup_show_notification(request, data);
287 } else if (g_str_equal(type, "toast_popup")) {
288 __toast_popup_show(request, data);
289 } else if (g_str_equal(type, "popup")) {
290 __net_popup_show_popup(request, data);
291 } else if (g_str_equal(type, "add_found_ap_noti")) {
292 __net_popup_add_found_ap_noti();
294 } else if (g_str_equal(type, "del_found_ap_noti")) {
295 __net_popup_del_found_ap_noti();
297 } else if (g_str_equal(type, "add_portal_noti")) {
298 __net_popup_add_portal_noti(request);
300 } else if (g_str_equal(type, "del_portal_noti")) {
301 __net_popup_del_portal_noti();
303 } else if (g_str_equal(type, "popup_user_resp")) {
304 app_control_clone(&g_req_handle, request);
305 __net_popup_show_popup_with_user_resp(request, data);
307 __net_popup_show_notification(request, data);
315 static void __net_popup_set_orientation(Evas_Object *win)
317 log_print(NET_POPUP, "__net_popup_set_orientation()\n");
319 int rots[4] = { 0, 90, 180, 270 };
321 if (!elm_win_wm_rotation_supported_get(win)) {
325 elm_win_wm_rotation_available_rotations_set(win, rots, 4);
328 static Evas_Object* __net_popup_create_win(void)
330 log_print(NET_POPUP, "__net_popup_create_win()\n");
332 Evas_Object *win = NULL;
334 Ecore_Evas *ee = NULL;
339 win = elm_win_add(NULL, PACKAGE, ELM_WIN_NOTIFICATION);
341 e = evas_object_evas_get(win);
342 ee = ecore_evas_ecore_evas_get(e);
343 ecore_evas_name_class_set(ee,"APP_POPUP","APP_POPUP");
345 elm_win_alpha_set(win, EINA_TRUE);
346 elm_win_borderless_set(win, EINA_TRUE);
348 ecore_x_window_size_get(ecore_x_window_root_first_get(), &w, &h);
349 evas_object_resize(win, w, h);
350 utilx_set_system_notification_level (ecore_x_display_get(),
351 elm_win_xwindow_get(win),
352 UTILX_NOTIFICATION_LEVEL_LOW);
355 __net_popup_set_orientation(win);
360 static void _ok_button_clicked_cb(void *data, Evas_Object *obj, void *event_info)
362 log_print(NET_POPUP, "_ok_button_clicked_cb()\n");
365 evas_object_del(data);
369 static void _timeout_cb(void *data, Evas_Object *obj, void *event_info)
371 log_print(NET_POPUP, "_timeout_cb()\n");
373 evas_object_del(obj);
378 static int __toast_popup_show(app_control_h request, void *data)
380 log_print(NET_POPUP, "__toast_popup_show()\n");
382 char buf[ALERT_STR_LEN_MAX] = "";
385 Evas_Object *twin = NULL;
386 Evas_Object *tpop = NULL;
387 char *ap_name = NULL;
388 char *restricted_type = NULL;
390 ret = app_control_get_extra_data(request, "_SYSPOPUP_CONTENT_", &mode);
391 if (ret != APP_CONTROL_ERROR_NONE) {
392 log_print(NET_POPUP, "Failed to get _SYSPOPUP_CONTENT_ ret = %d", ret);
398 log_print(NET_POPUP, "_SYSPOPUP_CONTENT_ = %s\n", mode);
400 twin = __net_popup_create_win();
401 tpop = elm_popup_add(twin);
402 elm_object_style_set(tpop, "toast");
403 evas_object_size_hint_weight_set(tpop, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
405 elm_popup_timeout_set(tpop, 2.0);
407 evas_object_smart_callback_add(tpop, "timeout", _timeout_cb, twin);
408 if (strcmp(mode, "wrong password") == 0) {
409 log_print(NET_POPUP, "alert wrong password\n");
411 g_snprintf(buf, ALERT_STR_LEN_MAX, ALERT_STR_ERR_WRONG_PASSWORD);
412 } else if (strcmp(mode, "no ap found") == 0) {
413 log_print(NET_POPUP, "alert no ap found\n");
415 g_snprintf(buf, ALERT_STR_LEN_MAX, ALERT_STR_NO_AP_FOUND);
416 } else if (strcmp(mode, "unable to connect") == 0) {
417 log_print(NET_POPUP, "alert no ap found\n");
419 g_snprintf(buf, ALERT_STR_LEN_MAX, ALERT_STR_ERR_CONNECT);
420 } else if (strcmp(mode, "wifi connected") == 0) {
421 ret = app_control_get_extra_data(request, "_AP_NAME_", &ap_name);
423 if (APP_CONTROL_ERROR_NONE != ret) {
424 log_print(NET_POPUP, "Failed to get _AP_NAME_ ret = %d", ret);
430 g_snprintf(buf, ALERT_STR_LEN_MAX, ALERT_STR_WIFI_CONNECTED, ap_name);
432 g_snprintf(buf, ALERT_STR_LEN_MAX, ALERT_STR_WIFI_CONNECTED, "");
433 log_print(NET_POPUP, "alert wifi connected\n");
435 } else if (strcmp(mode, "security restriction") == 0) {
436 ret = app_control_get_extra_data(request, "_RESTRICTED_TYPE_", &restricted_type);
437 if (APP_CONTROL_ERROR_NONE != ret) {
438 log_print(NET_POPUP, "Failed to get _RESTRICTED_TYPE_ ret = %d", ret);
443 if (strcmp(restricted_type, "wifi") == 0)
444 g_snprintf(buf, ALERT_STR_LEN_MAX, ALERT_STR_RESTRICTED_USE_WIFI);
445 else if (strcmp(restricted_type, "wifi tethering") == 0)
446 g_snprintf(buf, ALERT_STR_LEN_MAX, ALERT_STR_SECURITY_RESTRICTION, ALERT_STR_WIFI_TETHERING);
447 else if (strcmp(restricted_type, "bt tethering") == 0)
448 g_snprintf(buf, ALERT_STR_LEN_MAX, ALERT_STR_SECURITY_RESTRICTION, ALERT_STR_BT_TETHERING);
449 else if (strcmp(restricted_type, "usb tethering") == 0)
450 g_snprintf(buf, ALERT_STR_LEN_MAX, ALERT_STR_SECURITY_RESTRICTION, ALERT_STR_USB_TETHERING);
452 log_print(NET_POPUP, "alert security restriction\n");
453 g_free(restricted_type);
455 log_print(NET_POPUP, "%s\n", mode);
457 elm_object_text_set(tpop, buf);
458 evas_object_show(tpop);
459 evas_object_show(twin);
465 static int __net_popup_show_notification(app_control_h request, void *data)
467 log_print(NET_POPUP, "__net_popup_show_notification()\n");
471 char buf[ALERT_STR_LEN_MAX] = "";
472 char *ap_name = NULL;
474 ret = app_control_get_extra_data(request, "_SYSPOPUP_CONTENT_", &mode);
476 if (APP_CONTROL_ERROR_NONE != ret) {
477 log_print(NET_POPUP, "Failed to get _SYSPOPUP_CONTENT_");
481 secure_log_print(NET_POPUP, "_SYSPOPUP_CONTENT_ = %s\n", mode);
483 if (strcmp(mode, "connected") == 0) {
484 notification_status_message_post(ALERT_STR_MOBILE_NETWORKS_CHARGE);
485 log_print(NET_POPUP, "alert 3g\n");
486 } else if (strcmp(mode, "fail to connect") == 0) {
487 notification_status_message_post(ALERT_STR_ERR_UNAVAILABLE);
488 log_print(NET_POPUP, "alert err\n");
489 } else if (strcmp(mode, "unable to connect") == 0) {
490 notification_status_message_post(ALERT_STR_ERR_CONNECT);
491 log_print(NET_POPUP, "alert unable to connect\n");
492 } else if (strcmp(mode, "wrong password") == 0) {
493 notification_status_message_post(ALERT_STR_ERR_WRONG_PASSWORD);
494 log_print(NET_POPUP, "alert wrong password\n");
495 } else if (strcmp(mode, "not support") == 0) {
496 notification_status_message_post(ALERT_STR_ERR_NOT_SUPPORT);
497 log_print(NET_POPUP, "alert not support\n");
498 } else if (strcmp(mode, "wifi restricted") == 0) {
499 notification_status_message_post(ALERT_STR_RESTRICTED_USE_WIFI);
500 log_print(NET_POPUP, "alert wifi restricted\n");
501 } else if (strcmp(mode, "no ap found") == 0) {
502 notification_status_message_post(ALERT_STR_NO_AP_FOUND);
503 log_print(NET_POPUP, "alert no ap found\n");
504 } else if (strcmp(mode, "Lengthy Password") == 0) {
505 notification_status_message_post(ALERT_STR_LENGHTY_PASSWORD);
506 log_print(NET_POPUP, "Password entered crosses 64 bytes\n");
507 } else if (strcmp(mode, "Portal Login") == 0) {
508 notification_status_message_post(CAPTIVE_PORTAL_LOGIN);
509 log_print(NET_POPUP, "Please login to access Internet\n");
510 } else if (strcmp(mode, "Portal Login Error") == 0) {
511 notification_status_message_post(CAPTIVE_PORTAL_LOGIN_ERROR);
512 log_print(NET_POPUP, "Login not completed. Disconnected Wifi\n");
513 } else if (strcmp(mode, "wifi connected") == 0) {
514 ret = app_control_get_extra_data(request, "_AP_NAME_", &ap_name);
516 if (APP_CONTROL_ERROR_NONE != ret) {
517 log_print(NET_POPUP, "Failed to get _AP_NAME_ ret = %d", ret);
523 g_snprintf(buf, ALERT_STR_LEN_MAX, ALERT_STR_WIFI_CONNECTED, ap_name);
525 g_snprintf(buf, ALERT_STR_LEN_MAX, ALERT_STR_WIFI_CONNECTED, "");
527 notification_status_message_post(buf);
529 log_print(NET_POPUP, "alert wifi connected\n");
532 notification_status_message_post(mode);
533 log_print(NET_POPUP, "%s\n", mode);
540 static int _net_popup_send_user_resp(char *resp, Eina_Bool state)
542 log_print(NET_POPUP, "_net_popup_send_user_resp()\n");
545 app_control_h reply = NULL;
546 char checkbox_str[USER_RESP_LEN] = { '\0', };
548 log_print(NET_POPUP, "Send the user response to the caller");
549 ret = app_control_create(&reply);
550 if (APP_CONTROL_ERROR_NONE != ret) {
551 log_print(NET_POPUP, "Failed to create service ret = %d", ret);
552 app_control_destroy(g_req_handle);
559 g_strlcpy(checkbox_str, "TRUE", USER_RESP_LEN);
561 g_strlcpy(checkbox_str, "FALSE", USER_RESP_LEN);
563 log_print(NET_POPUP, "Checkbox_str[%s]", checkbox_str);
565 ret = app_control_add_extra_data(reply, "_SYSPOPUP_RESP_", resp);
566 if (APP_CONTROL_ERROR_NONE == ret) {
567 ret = app_control_add_extra_data(reply, "_SYSPOPUP_CHECKBOX_RESP_",
569 if (APP_CONTROL_ERROR_NONE == ret) {
570 ret = app_control_reply_to_launch_request(reply, g_req_handle,
571 APP_CONTROL_RESULT_SUCCEEDED);
572 if (APP_CONTROL_ERROR_NONE == ret) {
573 log_print(NET_POPUP, "Service reply success");
576 log_print(NET_POPUP, "Service reply failed ret = %d", ret);
579 log_print(NET_POPUP, "Service data addition failed ret = %d", ret);
582 log_print(NET_POPUP, "Service data addition failed ret = %d", ret);
585 app_control_destroy(reply);
586 app_control_destroy(g_req_handle);
592 void _tethering_wifi_btn_yes_cb(void *data, Evas_Object *obj, void *event_info)
594 log_print(NET_POPUP, "_tethering_wifi_btn_yes_cb()\n");
597 Evas_Object *popup = (Evas_Object *)data;
599 __net_popup_init_dbus();
600 __net_popup_send_dbus_msg("progress_off");
601 __net_popup_deinit_dbus();
603 result = _net_popup_send_user_resp(RESP_WIFI_TETHERING_OFF, FALSE);
605 log_print(NET_POPUP, "Failed to send user response ");
608 evas_object_del(popup);
613 void _tethering_wifi_ap_btn_yes_cb(void *data, Evas_Object *obj, void *event_info)
615 log_print(NET_POPUP, "_tethering_wifi_ap_btn_yes_cb()\n");
618 Evas_Object *popup = (Evas_Object *)data;
620 __net_popup_init_dbus();
621 __net_popup_send_dbus_msg("progress_off");
622 __net_popup_deinit_dbus();
624 result = _net_popup_send_user_resp(RESP_WIFI_AP_TETHERING_OFF, FALSE);
626 log_print(NET_POPUP, "Failed to send user response ");
629 evas_object_del(popup);
634 void _btn_no_cb(void *data, Evas_Object *obj, void *event_info)
636 log_print(NET_POPUP, "_btn_no_cb()\n");
639 Evas_Object *popup = (Evas_Object *)data;
641 result = _net_popup_send_user_resp(RESP_TETHERING_ON, FALSE);
643 log_print(NET_POPUP, "Failed to send user response ");
646 evas_object_del(popup);
651 static void __net_popup_show_popup_with_user_resp(app_control_h request,
654 log_print(NET_POPUP, "__net_popup_show_popup_with_user_resp()\n");
664 ret = app_control_get_extra_data(request, "_SYSPOPUP_CONTENT_", &resp_popup_mode);
665 if (APP_CONTROL_ERROR_NONE != ret)
666 log_print(NET_POPUP, "Failed to get _SYSPOPUP_CONTENT_ ret = %d", ret);
668 secure_log_print(NET_POPUP, "_SYSPOPUP_CONTENT_ = %s\n", resp_popup_mode);
670 win = __net_popup_create_win();
671 evas_object_show(win);
673 popup = elm_popup_add(win);
674 evas_object_size_hint_weight_set(popup, EVAS_HINT_EXPAND,
677 if (g_strcmp0(resp_popup_mode, "TETHERING_TYPE_WIFI") == 0 ||
678 g_strcmp0(resp_popup_mode, "TETHERING_TYPE_WIFI_AP") == 0) {
679 log_print(NET_POPUP, "Drawing Wi-Fi Tethering OFF popup");
681 __net_popup_init_dbus();
682 elm_object_part_text_set(popup, "title,text", ALERT_STR_WIFI);
684 layout = elm_layout_add(popup);
685 elm_layout_file_set(layout, NETPOPUP_EDJ, "popup");
686 evas_object_size_hint_weight_set(layout, EVAS_HINT_EXPAND,
689 __net_popup_send_dbus_msg("progress_on");
690 label = elm_label_add(popup);
691 elm_label_line_wrap_set(label, ELM_WRAP_MIXED);
692 elm_object_text_set(label, ALERT_STR_WIFI_MOBILE_AP_ON);
693 evas_object_size_hint_weight_set(label, EVAS_HINT_EXPAND,
695 evas_object_size_hint_align_set(label, EVAS_HINT_FILL, EVAS_HINT_FILL);
696 evas_object_show(label);
698 elm_object_part_content_set(layout, "elm.swallow.content", label);
699 evas_object_show(layout);
700 elm_object_style_set(label, "popup/default");
701 eext_object_event_callback_add(popup, EEXT_CALLBACK_BACK, _btn_no_cb, popup);
702 elm_object_content_set(popup, label);
704 btn1 = elm_button_add(popup);
705 elm_object_style_set(btn1, "popup");
706 elm_object_text_set(btn1, ALERT_STR_CANCEL);
707 elm_object_part_content_set(popup, "button1", btn1);
708 evas_object_smart_callback_add(btn1, "clicked",
711 btn2 = elm_button_add(popup);
712 elm_object_style_set(btn2, "popup");
713 elm_object_text_set(btn2, ALERT_STR_OK);
714 elm_object_part_content_set(popup, "button2", btn2);
716 if (g_strcmp0(resp_popup_mode, "TETHERING_TYPE_WIFI") == 0)
717 evas_object_smart_callback_add(btn2, "clicked",
718 _tethering_wifi_btn_yes_cb, popup);
719 else if (g_strcmp0(resp_popup_mode, "TETHERING_TYPE_WIFI_AP") == 0)
720 evas_object_smart_callback_add(btn2, "clicked",
721 _tethering_wifi_ap_btn_yes_cb, popup);
723 evas_object_show(popup);
724 evas_object_show(win);
725 __net_popup_deinit_dbus();
729 static int __net_popup_show_popup(app_control_h request, void *data)
731 log_print(NET_POPUP, "__net_popup_show_popup()\n");
739 ret = app_control_get_extra_data(request, "_SYSPOPUP_CONTENT_", &mode);
740 if (APP_CONTROL_ERROR_NONE != ret) {
741 log_print(NET_POPUP, "Failed to get _SYSPOPUP_CONTENT_ ret = %d", ret);
747 secure_log_print(NET_POPUP, "_SYSPOPUP_CONTENT_ = %s\n", mode);
749 win = __net_popup_create_win();
751 popup = elm_popup_add(win);
752 evas_object_size_hint_weight_set(popup, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
753 if (strcmp(mode, "connected") == 0) {
754 elm_object_text_set(popup, ALERT_STR_MOBILE_NETWORKS_CHARGE);
755 log_print(NET_POPUP, "alert 3g\n");
756 } else if (strcmp(mode, "fail to connect") == 0) {
757 elm_object_text_set(popup, ALERT_STR_ERR_UNAVAILABLE);
758 log_print(NET_POPUP, "alert err\n");
759 } else if (strcmp(mode, "unable to connect") == 0) {
760 elm_object_text_set(popup, ALERT_STR_ERR_CONNECT);
761 log_print(NET_POPUP, "alert unable to connect\n");
762 } else if (strcmp(mode, "wrong password") == 0) {
763 elm_object_text_set(popup, ALERT_STR_ERR_WRONG_PASSWORD);
764 log_print(NET_POPUP, "alert wrong password\n");
765 } else if (strcmp(mode, "not support") == 0) {
766 elm_object_text_set(popup, ALERT_STR_ERR_NOT_SUPPORT);
767 log_print(NET_POPUP, "alert not support\n");
768 } else if (strcmp(mode, "wifi restricted") == 0) {
769 elm_object_text_set(popup, ALERT_STR_RESTRICTED_USE_WIFI);
770 log_print(NET_POPUP, "alert wifi restricted\n");
771 } else if (strcmp(mode, "no ap found") == 0) {
772 elm_object_text_set(popup, ALERT_STR_NO_AP_FOUND);
773 log_print(NET_POPUP, "alert no ap found\n");
774 } else if (strcmp(mode, "wifi connected") == 0) {
775 char buf[ALERT_STR_LEN_MAX] = "";
776 char *ap_name = NULL;
778 ret = app_control_get_extra_data(request, "_AP_NAME_", &ap_name);
781 g_snprintf(buf, ALERT_STR_LEN_MAX, ALERT_STR_WIFI_CONNECTED, ap_name);
783 g_snprintf(buf, ALERT_STR_LEN_MAX, ALERT_STR_WIFI_CONNECTED, "");
785 elm_object_text_set(popup, buf);
787 log_print(NET_POPUP, "alert wifi connected\n");
790 elm_object_text_set(popup, mode);
791 log_print(NET_POPUP, "%s\n", mode);
794 button = elm_button_add(popup);
795 elm_object_style_set(button, "popup");
796 elm_object_text_set(button, ALERT_STR_OK);
797 elm_object_part_content_set(popup, "button1", button);
798 evas_object_smart_callback_add(button, "clicked", _ok_button_clicked_cb, popup);
799 evas_object_show(popup);
800 evas_object_show(win);
806 static void __net_popup_add_found_ap_noti(void)
808 log_print(NET_POPUP, "__net_popup_add_found_ap_noti()\n");
810 int ret = 0, noti_flags = 0;
811 char icon_path[ICON_PATH_LEN];
812 notification_h noti = NULL;
813 notification_list_h noti_list = NULL;
814 notification_error_e noti_err = NOTIFICATION_ERROR_NONE;
815 app_control_h service_handle = NULL;
817 notification_get_detail_list("net.netpopup", NOTIFICATION_GROUP_ID_NONE,
818 NOTIFICATION_PRIV_ID_NONE, -1, ¬i_list);
819 if (noti_list != NULL) {
820 notification_free_list(noti_list);
824 noti = notification_create(NOTIFICATION_TYPE_ONGOING);
826 log_print(NET_POPUP, "Failed to create notification");
830 noti_err = notification_set_time(noti, time(NULL));
831 if(noti_err != NOTIFICATION_ERROR_NONE) {
832 log_print(NET_POPUP, "Failed to notification_set_time : %d", noti_err);
836 g_snprintf(icon_path, sizeof(icon_path), "%s%s", QP_PRELOAD_NOTI_ICON_PATH, "/noti_wifi_in_range.png");
837 noti_err = notification_set_image(noti, NOTIFICATION_IMAGE_TYPE_ICON, icon_path);
838 if(noti_err != NOTIFICATION_ERROR_NONE) {
839 log_print(NET_POPUP, "Failed to notification_set_image : %d", noti_err);
843 noti_err = notification_set_layout(noti, NOTIFICATION_LY_ONGOING_EVENT);
844 if (noti_err != NOTIFICATION_ERROR_NONE) {
845 log_print(NET_POPUP, "Failed to notification_set_layout : %d", noti_err);
849 noti_err = notification_set_text_domain(noti, PACKAGE,
851 if(noti_err != NOTIFICATION_ERROR_NONE) {
852 log_print(NET_POPUP, "Failed to notification_set_text_domain : %d", noti_err);
856 noti_err = notification_set_text(noti, NOTIFICATION_TEXT_TYPE_TITLE,
857 NETCONFIG_NOTIFICATION_WIFI_FOUND_TITLE,
858 "IDS_COM_BODY_WI_FI_NETWORKS_AVAILABLE",
859 NOTIFICATION_VARIABLE_TYPE_NONE);
860 if (noti_err != NOTIFICATION_ERROR_NONE) {
861 log_print(NET_POPUP, "Failed to notification_set_title : %d", noti_err);
865 noti_err = notification_set_text(noti, NOTIFICATION_TEXT_TYPE_CONTENT,
866 NETCONFIG_NOTIFICATION_WIFI_FOUND_CONTENT,
867 "IDS_WIFI_SBODY_TAP_HERE_TO_CONNECT",
868 NOTIFICATION_VARIABLE_TYPE_NONE);
869 if (noti_err != NOTIFICATION_ERROR_NONE) {
870 log_print(NET_POPUP, "Failed to notification_set_content: %d", noti_err);
874 noti_flags = NOTIFICATION_DISPLAY_APP_NOTIFICATION_TRAY | NOTIFICATION_DISPLAY_APP_INDICATOR;
875 noti_err = notification_set_display_applist(noti, noti_flags);
876 if(noti_err != NOTIFICATION_ERROR_NONE) {
877 log_print(NET_POPUP, "Failed to notification_set_display_applist: %d", noti_err);
881 ret = app_control_create(&service_handle);
882 log_print(NET_POPUP, "Service create ret[%d]", ret);
883 if(ret != APP_CONTROL_ERROR_NONE)
886 ret = app_control_set_app_id(service_handle, NET_WIFIQS_APPID);
887 log_print(NET_POPUP, "Service set app id ret = %d", ret);
888 if(ret != APP_CONTROL_ERROR_NONE)
891 ret = app_control_add_extra_data(service_handle, "caller", "notification");
892 log_print(NET_POPUP, "Service data addition ret = %d", ret);
893 if(ret != APP_CONTROL_ERROR_NONE)
896 noti_err = notification_set_launch_option(noti,
897 NOTIFICATION_LAUNCH_OPTION_APP_CONTROL, service_handle);
898 if (noti_err != NOTIFICATION_ERROR_NONE) {
899 log_print(NET_POPUP, "Failed to notification_set_launch_option");
903 noti_err = notification_post(noti);
904 if (noti_err != NOTIFICATION_ERROR_NONE) {
905 log_print(NET_POPUP, "Failed to insert notification[error# is %d]", noti_err);
909 log_print(NET_POPUP, "Successfully added notification");
914 notification_free(noti);
917 static void __net_popup_del_found_ap_noti(void)
919 log_print(NET_POPUP, "__net_popup_del_found_ap_noti()\n");
921 notification_error_e noti_err = NOTIFICATION_ERROR_NONE;
923 noti_err = notification_delete_all(NOTIFICATION_TYPE_ONGOING);
924 if (noti_err != NOTIFICATION_ERROR_NONE) {
925 log_print(NET_POPUP, "fail to notification_delete_by_priv_id");
929 log_print(NET_POPUP, "Successfully deleted notification");
932 static void __net_popup_add_portal_noti(app_control_h request)
934 log_print(NET_POPUP, "__net_popup_add_portal_noti()\n");
938 char *ap_name = NULL;
939 char icon_path[ICON_PATH_LEN];
940 notification_h noti = NULL;
941 app_control_h service_handle = NULL;
942 notification_list_h noti_list = NULL;
943 notification_error_e noti_err = NOTIFICATION_ERROR_NONE;
945 ret = app_control_get_extra_data(request, "_AP_NAME_", &ap_name);
947 if (ap_name == NULL || ret != APP_CONTROL_ERROR_NONE) {
948 log_print(NET_POPUP, "Failed to retrieve connected AP name!!");
953 log_print(NET_POPUP, "Successfully added notification");
955 notification_get_detail_list("net.netpopup", NOTIFICATION_GROUP_ID_NONE,
956 NOTIFICATION_PRIV_ID_NONE, -1, ¬i_list);
957 if (noti_list != NULL) {
958 notification_free_list(noti_list);
963 noti = notification_create(NOTIFICATION_TYPE_NOTI);
965 log_print(NET_POPUP, "fail to create notification");
970 noti_err = notification_set_time(noti, time(NULL));
971 if(noti_err != NOTIFICATION_ERROR_NONE) {
972 log_print(NET_POPUP, "fail to notification_set_time : %d", noti_err);
976 noti_err = notification_set_image(noti, NOTIFICATION_IMAGE_TYPE_ICON,
977 NETCONFIG_NOTIFICATION_WIFI_ICON);
978 if(noti_err != NOTIFICATION_ERROR_NONE) {
979 log_print(NET_POPUP, "fail to notification_set_image : %d", noti_err);
983 g_snprintf(icon_path, sizeof(icon_path), "%s%s", QP_PRELOAD_NOTI_ICON_PATH, "/noti_wifi_in_range.png");
984 noti_err = notification_set_image(noti, NOTIFICATION_IMAGE_TYPE_ICON, icon_path);
985 if(noti_err != NOTIFICATION_ERROR_NONE) {
986 log_print(NET_POPUP, "fail to notification_set_image : %d", noti_err);
989 noti_err = notification_set_layout(noti, NOTIFICATION_LY_NOTI_EVENT_MULTIPLE);
990 if (noti_err != NOTIFICATION_ERROR_NONE) {
991 log_print(NET_POPUP, "fail to notification_set_layout : %d", noti_err);
995 noti_err = notification_set_text_domain(noti, PACKAGE,
997 if(noti_err != NOTIFICATION_ERROR_NONE) {
998 log_print(NET_POPUP, "fail to notification_set_text_domain : %d", noti_err);
1002 noti_err = notification_set_text(noti, NOTIFICATION_TEXT_TYPE_TITLE,
1003 NETCONFIG_NOTIFICATION_WIFI_PORTAL_TITLE,
1004 "IDS_WIFI_HEADER_SIGN_IN_TO_WI_FI_NETWORK_ABB",
1005 NOTIFICATION_VARIABLE_TYPE_NONE);
1006 if (noti_err != NOTIFICATION_ERROR_NONE) {
1007 log_print(NET_POPUP, "fail to notification_set_title : %d", noti_err);
1011 noti_err = notification_set_text(noti, NOTIFICATION_TEXT_TYPE_CONTENT,
1012 NETCONFIG_NOTIFICATION_WIFI_PORTAL_CONTENT,
1013 NETCONFIG_NOTIFICATION_WIFI_PORTAL_CONTENT,
1014 NOTIFICATION_VARIABLE_TYPE_STRING, ap_name,
1015 NOTIFICATION_VARIABLE_TYPE_NONE);
1016 if (noti_err != NOTIFICATION_ERROR_NONE) {
1017 log_print(NET_POPUP, "fail to notification_set_content : %d", noti_err);
1021 noti_flags = NOTIFICATION_DISPLAY_APP_NOTIFICATION_TRAY | NOTIFICATION_DISPLAY_APP_INDICATOR;
1022 noti_err = notification_set_display_applist(noti, noti_flags);
1023 if(noti_err != NOTIFICATION_ERROR_NONE) {
1024 log_print(NET_POPUP, "fail to notification_set_display_applist : %d", noti_err);
1028 ret = app_control_create(&service_handle);
1029 log_print(NET_POPUP, "service create ret[%d]", ret);
1030 if(ret != APP_CONTROL_ERROR_NONE)
1033 ret = app_control_set_operation(service_handle, APP_CONTROL_OPERATION_VIEW);
1034 if(ret != APP_CONTROL_ERROR_NONE)
1037 log_print(NET_POPUP, "service set operation is successful");
1039 ret = app_control_set_uri(service_handle, "http://www.google.com");
1041 if(ret != APP_CONTROL_ERROR_NONE)
1044 noti_err = notification_set_launch_option(noti,
1045 NOTIFICATION_LAUNCH_OPTION_APP_CONTROL, service_handle);
1046 if (noti_err != NOTIFICATION_ERROR_NONE) {
1047 log_print(NET_POPUP, "fail to notification_set_launch_option");
1051 noti_err = notification_post(noti);
1052 if (noti_err != NOTIFICATION_ERROR_NONE) {
1053 log_print(NET_POPUP, "fail to notification_post");
1057 log_print(NET_POPUP, "Successfully added notification");
1062 notification_free(noti);
1064 if (service_handle != NULL)
1065 app_control_destroy(service_handle);
1068 static void __net_popup_del_portal_noti(void)
1070 log_print(NET_POPUP, "__net_popup_del_portal_noti()\n");
1072 notification_error_e noti_err = NOTIFICATION_ERROR_NONE;
1074 noti_err = notification_delete_all(NOTIFICATION_TYPE_NOTI);
1075 if (noti_err != NOTIFICATION_ERROR_NONE) {
1076 log_print(NET_POPUP, "fail to notification_delete_all");
1080 log_print(NET_POPUP, "Successfully deleted notification");
1083 EXPORT_API int main(int argc, char *argv[])
1085 log_print(NET_POPUP, "main()\n");
1087 ui_app_lifecycle_callback_s app_callback = {
1088 .create = __net_popup_create,
1089 .terminate = __net_popup_terminate,
1090 .pause = __net_popup_pause,
1091 .resume = __net_popup_resume,
1092 .app_control = __net_popup_service_cb,
1095 return ui_app_main(argc, argv, &app_callback, NULL);