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>
37 #include "net-popup.h"
38 #include "net-popup-strings.h"
40 #define LOCALEDIR "/usr/share/locale"
41 #define NETPOPUP_EDJ "/usr/ug/res/edje/net-popup/netpopup-custom.edj"
42 #define QP_PRELOAD_NOTI_ICON_PATH "/usr/apps/org.tizen.quickpanel/shared/res/noti_icons/Wi-Fi"
44 #define NETCONFIG_NOTIFICATION_WIFI_ICON \
45 "/usr/share/icons/noti_wifi_in_range.png"
46 #define NETCONFIG_NOTIFICATION_WIFI_ICON_LITE \
47 "/usr/share/icons/noti_wifi_in_range_ongoing.png"
48 #define NETCONFIG_NOTIFICATION_WIFI_CAPTIVE_ICON \
49 "/usr/share/icons/B03_notify_Wi-fi_range.png"
50 #define NETCONFIG_NOTIFICATION_WIFI_IN_RANGE_ICON \
51 "/usr/share/icons/Q02_Notification_wifi_in_range.png"
52 #define NETCONFIG_NOTIFICATION_WIFI_IN_RANGE_ICON_LITE \
53 "/usr/share/icons/noti_wifi_in_range.png"
54 #define NETCONFIG_NOTIFICATION_WIFI_FOUND_TITLE \
55 dgettext(PACKAGE, "IDS_COM_BODY_WI_FI_NETWORKS_AVAILABLE")
56 #define NETCONFIG_NOTIFICATION_WIFI_FOUND_CONTENT \
57 dgettext(PACKAGE, "IDS_WIFI_SBODY_TAP_HERE_TO_CONNECT")
58 #define NETCONFIG_NOTIFICATION_WIFI_PORTAL_TITLE \
59 dgettext(PACKAGE, "IDS_WIFI_HEADER_SIGN_IN_TO_WI_FI_NETWORK_ABB")
60 #define NETCONFIG_NOTIFICATION_WIFI_PORTAL_CONTENT "\"%s\""
62 #define USER_RESP_LEN 30
63 #define RESP_REMAIN_CONNECTED "RESP_REMAIN_CONNECTED"
64 #define RESP_WIFI_TETHERING_OFF "RESP_TETHERING_TYPE_WIFI_OFF"
65 #define RESP_WIFI_AP_TETHERING_OFF "RESP_TETHERING_TYPE_WIFI_AP_OFF"
66 #define RESP_TETHERING_ON "RESP_TETHERING_ON"
67 #define CAPTIVE_PORTAL_LOGIN "Login required to access Internet"
68 #define CAPTIVE_PORTAL_LOGIN_ERROR "Login not completed. Disconnected active Wifi"
70 static Ecore_Event_Handler *ecore_event_evas_handler;
71 static Ecore_Event_Handler *ecore_event_evas_quick_panel_handler;
74 long sizes[] = {1073741824, 1048576, 1024, 0};
75 char *units[] = {"GB", "MB", "KB", "B"};
77 static app_control_h g_req_handle = NULL;
78 static char * resp_popup_mode = NULL;
80 static GDBusConnection *conn = NULL;
81 static GDBusProxy *proxy = NULL;
83 static int __net_popup_show_notification(app_control_h request, void *data);
84 static int __toast_popup_show(app_control_h request, void *data);
85 static int __net_popup_show_popup(app_control_h request, void *data);
86 static void __net_popup_add_found_ap_noti(void);
87 static void __net_popup_del_found_ap_noti(void);
88 static void __net_popup_add_portal_noti(app_control_h request);
89 static void __net_popup_del_portal_noti(void);
90 static void __net_popup_show_popup_with_user_resp(app_control_h request, void *data);
91 static int _net_popup_send_user_resp(char *resp, Eina_Bool state);
94 GDBusProxy *__net_popup_init_dbus(void)
98 conn = g_bus_get_sync(G_BUS_TYPE_SYSTEM, NULL, &err);
104 proxy = g_dbus_proxy_new_sync(conn, G_DBUS_PROXY_FLAGS_NONE, NULL,
111 g_object_unref(conn);
118 void __net_popup_deinit_dbus(void)
121 g_object_unref(proxy);
126 g_object_unref(conn);
133 int __net_popup_send_dbus_msg(const char *resp)
135 if (conn == NULL || resp == NULL) {
139 GDBusConnection *gconn = NULL;
140 GVariant *msg = NULL;
141 char *module = "wifi";
144 gconn = g_bus_get_sync(DBUS_BUS_SYSTEM, NULL, &err);
151 msg = g_variant_new("(ss)", module, resp);
152 g_dbus_connection_emit_signal(gconn, NULL, "/Org/Tizen/Quickpanel",
153 "org.tizen.quickpanel", "ACTIVITY", msg, &err);
159 g_variant_unref(msg);
162 g_object_unref(gconn);
168 static bool __net_popup_create(void *data)
170 log_print(NET_POPUP, "__net_popup_create()\n");
172 bindtextdomain(PACKAGE, LOCALEDIR);
177 static void __net_popup_terminate(void *data)
179 if (ecore_event_evas_handler) {
180 ecore_event_handler_del(ecore_event_evas_handler);
181 ecore_event_evas_handler = NULL;
183 if (ecore_event_evas_quick_panel_handler) {
184 ecore_event_handler_del(ecore_event_evas_quick_panel_handler);
185 ecore_event_evas_quick_panel_handler = NULL;
191 static void __net_popup_pause(void *data)
193 log_print(NET_POPUP, "__net_popup_pause()");
196 static void __net_popup_resume(void *data)
201 static Eina_Bool __key_release_event_cb(void *data, int type,
204 Evas_Event_Key_Down *ev = (Evas_Event_Key_Down *) event;
207 return ECORE_CALLBACK_RENEW;
211 return ECORE_CALLBACK_RENEW;
214 log_print(NET_POPUP, "key_release : %s", ev->keyname);
215 if (g_strcmp0(ev->keyname, "XF86Phone") == 0 ||
216 g_strcmp0(ev->keyname, "XF86Stop") == 0) {
220 return ECORE_CALLBACK_DONE;
224 static Eina_Bool _ecore_event_client_message_cb(void *data, int type,
227 Ecore_X_Event_Client_Message *ev = event;
229 if (ev->message_type == ECORE_X_ATOM_E_ILLUME_QUICKPANEL_STATE) {
230 if (ev->data.l[0] == ECORE_X_ATOM_E_ILLUME_QUICKPANEL_OFF) {
231 log_print(NET_POPUP, "ECORE_X_ATOM_E_ILLUME_QUICKPANEL_OFF");
232 } else if (ev->data.l[0] == ECORE_X_ATOM_E_ILLUME_QUICKPANEL_ON) {
233 log_print(NET_POPUP, "ECORE_X_ATOM_E_ILLUME_QUICKPANEL_ON");
236 return ECORE_CALLBACK_RENEW;
240 static void __net_popup_service_cb(app_control_h request, void *data)
242 log_print(NET_POPUP, "__net_popup_service_cb()\n");
247 if (ecore_event_evas_handler == NULL) {
248 ecore_event_evas_handler = ecore_event_handler_add(ECORE_EVENT_KEY_UP,
249 __key_release_event_cb, NULL);
253 if (ecore_event_evas_quick_panel_handler == NULL) {
254 ecore_event_evas_quick_panel_handler = ecore_event_handler_add(
255 ECORE_X_EVENT_CLIENT_MESSAGE, _ecore_event_client_message_cb, NULL);
259 ret = app_control_get_extra_data(request, "_SYSPOPUP_TYPE_", &type);
261 if (APP_CONTROL_ERROR_NONE != ret) {
262 log_print(NET_POPUP, "Failed to get _SYSPOPUP_TYPE_ ret = %d", ret);
268 log_print(NET_POPUP, "type = %s\n", type);
270 if (g_str_equal(type, "notification")) {
271 __net_popup_show_notification(request, data);
273 } else if (g_str_equal(type, "toast_popup")) {
274 __toast_popup_show(request, data);
275 } else if (g_str_equal(type, "popup")) {
276 __net_popup_show_popup(request, data);
277 } else if (g_str_equal(type, "add_found_ap_noti")) {
278 __net_popup_add_found_ap_noti();
280 } else if (g_str_equal(type, "del_found_ap_noti")) {
281 __net_popup_del_found_ap_noti();
283 } else if (g_str_equal(type, "add_portal_noti")) {
284 __net_popup_add_portal_noti(request);
286 } else if (g_str_equal(type, "del_portal_noti")) {
287 __net_popup_del_portal_noti();
289 } else if (g_str_equal(type, "popup_user_resp")) {
290 app_control_clone(&g_req_handle, request);
291 __net_popup_show_popup_with_user_resp(request, data);
293 __net_popup_show_notification(request, data);
301 static void __net_popup_set_orientation(Evas_Object *win)
303 int rots[4] = { 0, 90, 180, 270 };
305 if (!elm_win_wm_rotation_supported_get(win)) {
309 elm_win_wm_rotation_available_rotations_set(win, rots, 4);
312 static Evas_Object* __net_popup_create_win(void)
314 Evas_Object *win = NULL;
316 Ecore_Evas *ee = NULL;
321 win = elm_win_add(NULL, PACKAGE, ELM_WIN_NOTIFICATION);
323 e = evas_object_evas_get(win);
324 ee = ecore_evas_ecore_evas_get(e);
325 ecore_evas_name_class_set(ee,"APP_POPUP","APP_POPUP");
327 elm_win_alpha_set(win, EINA_TRUE);
328 elm_win_borderless_set(win, EINA_TRUE);
330 ecore_x_window_size_get(ecore_x_window_root_first_get(), &w, &h);
331 evas_object_resize(win, w, h);
332 utilx_set_system_notification_level (ecore_x_display_get(),
333 elm_win_xwindow_get(win),
334 UTILX_NOTIFICATION_LEVEL_LOW);
337 __net_popup_set_orientation(win);
342 static void _ok_button_clicked_cb(void *data, Evas_Object *obj, void *event_info)
345 evas_object_del(data);
349 static void _timeout_cb(void *data, Evas_Object *obj, void *event_info)
351 evas_object_del(obj);
356 static int __toast_popup_show(app_control_h request, void *data)
358 char buf[ALERT_STR_LEN_MAX] = "";
361 Evas_Object *twin = NULL;
362 Evas_Object *tpop = NULL;
364 ret = app_control_get_extra_data(request, "_SYSPOPUP_CONTENT_", &mode);
365 if (ret != APP_CONTROL_ERROR_NONE) {
366 log_print(NET_POPUP, "Failed to get _SYSPOPUP_CONTENT_ ret = %d", ret);
372 log_print(NET_POPUP, "_SYSPOPUP_CONTENT_ = %s\n", mode);
374 twin = __net_popup_create_win();
375 tpop = elm_popup_add(twin);
376 elm_object_style_set(tpop, "toast");
377 evas_object_size_hint_weight_set(tpop, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
379 elm_popup_timeout_set(tpop, 2.0);
381 evas_object_smart_callback_add(tpop, "timeout", _timeout_cb, twin);
382 if (strcmp(mode, "wrong password") == 0) {
383 log_print(NET_POPUP, "alert wrong password\n");
385 g_snprintf(buf, ALERT_STR_LEN_MAX, ALERT_STR_ERR_WRONG_PASSWORD);
386 } else if (strcmp(mode, "no ap found") == 0) {
387 log_print(NET_POPUP, "alert no ap found\n");
389 g_snprintf(buf, ALERT_STR_LEN_MAX, ALERT_STR_NO_AP_FOUND);
390 } else if (strcmp(mode, "unable to connect") == 0) {
391 log_print(NET_POPUP, "alert no ap found\n");
393 g_snprintf(buf, ALERT_STR_LEN_MAX, ALERT_STR_ERR_CONNECT);
395 log_print(NET_POPUP, "%s\n", mode);
397 elm_object_text_set(tpop, buf);
398 evas_object_show(tpop);
399 evas_object_show(twin);
405 static int __net_popup_show_notification(app_control_h request, void *data)
409 char buf[ALERT_STR_LEN_MAX] = "";
410 char *ap_name = NULL;
412 ret = app_control_get_extra_data(request, "_SYSPOPUP_CONTENT_", &mode);
414 if (APP_CONTROL_ERROR_NONE != ret) {
415 log_print(NET_POPUP, "Failed to get _SYSPOPUP_CONTENT_");
419 secure_log_print(NET_POPUP, "_SYSPOPUP_CONTENT_ = %s\n", mode);
421 if (strcmp(mode, "connected") == 0) {
422 notification_status_message_post(ALERT_STR_MOBILE_NETWORKS_CHARGE);
423 log_print(NET_POPUP, "alert 3g\n");
424 } else if (strcmp(mode, "fail to connect") == 0) {
425 notification_status_message_post(ALERT_STR_ERR_UNAVAILABLE);
426 log_print(NET_POPUP, "alert err\n");
427 } else if (strcmp(mode, "unable to connect") == 0) {
428 notification_status_message_post(ALERT_STR_ERR_CONNECT);
429 log_print(NET_POPUP, "alert unable to connect\n");
430 } else if (strcmp(mode, "wrong password") == 0) {
431 notification_status_message_post(ALERT_STR_ERR_WRONG_PASSWORD);
432 log_print(NET_POPUP, "alert wrong password\n");
433 } else if (strcmp(mode, "not support") == 0) {
434 notification_status_message_post(ALERT_STR_ERR_NOT_SUPPORT);
435 log_print(NET_POPUP, "alert not support\n");
436 } else if (strcmp(mode, "wifi restricted") == 0) {
437 notification_status_message_post(ALERT_STR_RESTRICTED_USE_WIFI);
438 log_print(NET_POPUP, "alert wifi restricted\n");
439 } else if (strcmp(mode, "no ap found") == 0) {
440 notification_status_message_post(ALERT_STR_NO_AP_FOUND);
441 log_print(NET_POPUP, "alert no ap found\n");
442 } else if (strcmp(mode, "Lengthy Password") == 0) {
443 notification_status_message_post(ALERT_STR_LENGHTY_PASSWORD);
444 log_print(NET_POPUP, "Password entered crosses 64 bytes\n");
445 } else if (strcmp(mode, "Portal Login") == 0) {
446 notification_status_message_post(CAPTIVE_PORTAL_LOGIN);
447 log_print(NET_POPUP, "Please login to access Internet\n");
448 } else if (strcmp(mode, "Portal Login Error") == 0) {
449 notification_status_message_post(CAPTIVE_PORTAL_LOGIN_ERROR);
450 log_print(NET_POPUP, "Login not completed. Disconnected Wifi\n");
451 } else if (strcmp(mode, "wifi connected") == 0) {
452 ret = app_control_get_extra_data(request, "_AP_NAME_", &ap_name);
454 if (APP_CONTROL_ERROR_NONE != ret) {
455 log_print(NET_POPUP, "Failed to get _AP_NAME_ ret = %d", ret);
461 g_snprintf(buf, ALERT_STR_LEN_MAX, ALERT_STR_WIFI_CONNECTED, ap_name);
463 g_snprintf(buf, ALERT_STR_LEN_MAX, ALERT_STR_WIFI_CONNECTED, "");
465 notification_status_message_post(buf);
467 log_print(NET_POPUP, "alert wifi connected\n");
470 notification_status_message_post(mode);
471 log_print(NET_POPUP, "%s\n", mode);
478 static int _net_popup_send_user_resp(char *resp, Eina_Bool state)
481 app_control_h reply = NULL;
482 char checkbox_str[USER_RESP_LEN] = { '\0', };
484 log_print(NET_POPUP, "Send the user response to the caller");
485 ret = app_control_create(&reply);
486 if (APP_CONTROL_ERROR_NONE != ret) {
487 log_print(NET_POPUP, "Failed to create service ret = %d", ret);
488 app_control_destroy(g_req_handle);
495 g_strlcpy(checkbox_str, "TRUE", USER_RESP_LEN);
497 g_strlcpy(checkbox_str, "FALSE", USER_RESP_LEN);
499 log_print(NET_POPUP, "Checkbox_str[%s]", checkbox_str);
501 ret = app_control_add_extra_data(reply, "_SYSPOPUP_RESP_", resp);
502 if (APP_CONTROL_ERROR_NONE == ret) {
503 ret = app_control_add_extra_data(reply, "_SYSPOPUP_CHECKBOX_RESP_",
505 if (APP_CONTROL_ERROR_NONE == ret) {
506 ret = app_control_reply_to_launch_request(reply, g_req_handle,
507 APP_CONTROL_RESULT_SUCCEEDED);
508 if (APP_CONTROL_ERROR_NONE == ret) {
509 log_print(NET_POPUP, "Service reply success");
512 log_print(NET_POPUP, "Service reply failed ret = %d", ret);
515 log_print(NET_POPUP, "Service data addition failed ret = %d", ret);
518 log_print(NET_POPUP, "Service data addition failed ret = %d", ret);
521 app_control_destroy(reply);
522 app_control_destroy(g_req_handle);
528 void _tethering_wifi_btn_yes_cb(void *data, Evas_Object *obj, void *event_info)
530 log_print(NET_POPUP, "_tethering_wifi_btn_yes_cb");
533 Evas_Object *popup = (Evas_Object *)data;
535 __net_popup_init_dbus();
536 __net_popup_send_dbus_msg("progress_off");
537 __net_popup_deinit_dbus();
539 result = _net_popup_send_user_resp(RESP_WIFI_TETHERING_OFF, FALSE);
541 log_print(NET_POPUP, "Failed to send user response ");
544 evas_object_del(popup);
549 void _tethering_wifi_ap_btn_yes_cb(void *data, Evas_Object *obj, void *event_info)
551 log_print(NET_POPUP, "_tethering_wifi_ap_btn_yes_cb");
554 Evas_Object *popup = (Evas_Object *)data;
556 __net_popup_init_dbus();
557 __net_popup_send_dbus_msg("progress_off");
558 __net_popup_deinit_dbus();
560 result = _net_popup_send_user_resp(RESP_WIFI_AP_TETHERING_OFF, FALSE);
562 log_print(NET_POPUP, "Failed to send user response ");
565 evas_object_del(popup);
570 void _btn_no_cb(void *data, Evas_Object *obj, void *event_info)
572 log_print(NET_POPUP, "_btn_no_cb");
575 Evas_Object *popup = (Evas_Object *)data;
577 result = _net_popup_send_user_resp(RESP_TETHERING_ON, FALSE);
579 log_print(NET_POPUP, "Failed to send user response ");
582 evas_object_del(popup);
587 static void __net_popup_show_popup_with_user_resp(app_control_h request,
598 ret = app_control_get_extra_data(request, "_SYSPOPUP_CONTENT_", &resp_popup_mode);
599 if (APP_CONTROL_ERROR_NONE != ret)
600 log_print(NET_POPUP, "Failed to get _SYSPOPUP_CONTENT_ ret = %d", ret);
602 secure_log_print(NET_POPUP, "_SYSPOPUP_CONTENT_ = %s\n", resp_popup_mode);
604 win = __net_popup_create_win();
605 evas_object_show(win);
607 popup = elm_popup_add(win);
608 evas_object_size_hint_weight_set(popup, EVAS_HINT_EXPAND,
611 if (g_strcmp0(resp_popup_mode, "TETHERING_TYPE_WIFI") == 0 ||
612 g_strcmp0(resp_popup_mode, "TETHERING_TYPE_WIFI_AP") == 0) {
613 log_print(NET_POPUP, "Drawing Wi-Fi Tethering OFF popup");
615 __net_popup_init_dbus();
616 elm_object_part_text_set(popup, "title,text", ALERT_STR_WIFI);
618 layout = elm_layout_add(popup);
619 elm_layout_file_set(layout, NETPOPUP_EDJ, "popup");
620 evas_object_size_hint_weight_set(layout, EVAS_HINT_EXPAND,
623 __net_popup_send_dbus_msg("progress_on");
624 label = elm_label_add(popup);
625 elm_label_line_wrap_set(label, ELM_WRAP_MIXED);
626 elm_object_text_set(label, ALERT_STR_WIFI_MOBILE_AP_ON);
627 evas_object_size_hint_weight_set(label, EVAS_HINT_EXPAND,
629 evas_object_size_hint_align_set(label, EVAS_HINT_FILL, EVAS_HINT_FILL);
630 evas_object_show(label);
632 elm_object_part_content_set(layout, "elm.swallow.content", label);
633 evas_object_show(layout);
634 elm_object_style_set(label, "popup/default");
635 eext_object_event_callback_add(popup, EEXT_CALLBACK_BACK, _btn_no_cb, popup);
636 elm_object_content_set(popup, label);
638 btn1 = elm_button_add(popup);
639 elm_object_style_set(btn1, "popup");
640 elm_object_text_set(btn1, ALERT_STR_CANCEL);
641 elm_object_part_content_set(popup, "button1", btn1);
642 evas_object_smart_callback_add(btn1, "clicked",
645 btn2 = elm_button_add(popup);
646 elm_object_style_set(btn2, "popup");
647 elm_object_text_set(btn2, ALERT_STR_OK);
648 elm_object_part_content_set(popup, "button2", btn2);
650 if (g_strcmp0(resp_popup_mode, "TETHERING_TYPE_WIFI") == 0)
651 evas_object_smart_callback_add(btn2, "clicked",
652 _tethering_wifi_btn_yes_cb, popup);
653 else if (g_strcmp0(resp_popup_mode, "TETHERING_TYPE_WIFI_AP") == 0)
654 evas_object_smart_callback_add(btn2, "clicked",
655 _tethering_wifi_ap_btn_yes_cb, popup);
657 evas_object_show(popup);
658 evas_object_show(win);
659 __net_popup_deinit_dbus();
663 static int __net_popup_show_popup(app_control_h request, void *data)
671 ret = app_control_get_extra_data(request, "_SYSPOPUP_CONTENT_", &mode);
672 if (APP_CONTROL_ERROR_NONE != ret) {
673 log_print(NET_POPUP, "Failed to get _SYSPOPUP_CONTENT_ ret = %d", ret);
679 secure_log_print(NET_POPUP, "_SYSPOPUP_CONTENT_ = %s\n", mode);
681 win = __net_popup_create_win();
683 popup = elm_popup_add(win);
684 evas_object_size_hint_weight_set(popup, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
685 if (strcmp(mode, "connected") == 0) {
686 elm_object_text_set(popup, ALERT_STR_MOBILE_NETWORKS_CHARGE);
687 log_print(NET_POPUP, "alert 3g\n");
688 } else if (strcmp(mode, "fail to connect") == 0) {
689 elm_object_text_set(popup, ALERT_STR_ERR_UNAVAILABLE);
690 log_print(NET_POPUP, "alert err\n");
691 } else if (strcmp(mode, "unable to connect") == 0) {
692 elm_object_text_set(popup, ALERT_STR_ERR_CONNECT);
693 log_print(NET_POPUP, "alert unable to connect\n");
694 } else if (strcmp(mode, "wrong password") == 0) {
695 elm_object_text_set(popup, ALERT_STR_ERR_WRONG_PASSWORD);
696 log_print(NET_POPUP, "alert wrong password\n");
697 } else if (strcmp(mode, "not support") == 0) {
698 elm_object_text_set(popup, ALERT_STR_ERR_NOT_SUPPORT);
699 log_print(NET_POPUP, "alert not support\n");
700 } else if (strcmp(mode, "wifi restricted") == 0) {
701 elm_object_text_set(popup, ALERT_STR_RESTRICTED_USE_WIFI);
702 log_print(NET_POPUP, "alert wifi restricted\n");
703 } else if (strcmp(mode, "no ap found") == 0) {
704 elm_object_text_set(popup, ALERT_STR_NO_AP_FOUND);
705 log_print(NET_POPUP, "alert no ap found\n");
706 } else if (strcmp(mode, "wifi connected") == 0) {
707 char buf[ALERT_STR_LEN_MAX] = "";
708 char *ap_name = NULL;
710 ret = app_control_get_extra_data(request, "_AP_NAME_", &ap_name);
713 g_snprintf(buf, ALERT_STR_LEN_MAX, ALERT_STR_WIFI_CONNECTED, ap_name);
715 g_snprintf(buf, ALERT_STR_LEN_MAX, ALERT_STR_WIFI_CONNECTED, "");
717 elm_object_text_set(popup, buf);
719 log_print(NET_POPUP, "alert wifi connected\n");
722 elm_object_text_set(popup, mode);
723 log_print(NET_POPUP, "%s\n", mode);
726 button = elm_button_add(popup);
727 elm_object_style_set(button, "popup");
728 elm_object_text_set(button, ALERT_STR_OK);
729 elm_object_part_content_set(popup, "button1", button);
730 evas_object_smart_callback_add(button, "clicked", _ok_button_clicked_cb, popup);
731 evas_object_show(popup);
732 evas_object_show(win);
738 static void __net_popup_add_found_ap_noti(void)
740 int ret = 0, noti_flags = 0;
741 notification_h noti = NULL;
742 notification_list_h noti_list = NULL;
743 notification_error_e noti_err = NOTIFICATION_ERROR_NONE;
744 app_control_h service_handle = NULL;
746 notification_get_detail_list("net.netpopup", NOTIFICATION_GROUP_ID_NONE,
747 NOTIFICATION_PRIV_ID_NONE, -1, ¬i_list);
748 if (noti_list != NULL) {
749 notification_free_list(noti_list);
753 noti = notification_create(NOTIFICATION_TYPE_ONGOING);
755 log_print(NET_POPUP, "Failed to create notification");
759 noti_err = notification_set_time(noti, time(NULL));
760 if(noti_err != NOTIFICATION_ERROR_NONE) {
761 log_print(NET_POPUP, "Failed to notification_set_time : %d", noti_err);
765 noti_err = notification_set_image(noti, NOTIFICATION_IMAGE_TYPE_ICON,
766 QP_PRELOAD_NOTI_ICON_PATH"/noti_wifi_in_range.png");
767 if(noti_err != NOTIFICATION_ERROR_NONE) {
768 log_print(NET_POPUP, "Failed to notification_set_image : %d", noti_err);
772 noti_err = notification_set_layout(noti, NOTIFICATION_LY_ONGOING_EVENT);
773 if (noti_err != NOTIFICATION_ERROR_NONE) {
774 log_print(NET_POPUP, "Failed to notification_set_layout : %d", noti_err);
778 noti_err = notification_set_text_domain(noti, PACKAGE,
780 if(noti_err != NOTIFICATION_ERROR_NONE) {
781 log_print(NET_POPUP, "Failed to notification_set_text_domain : %d", noti_err);
785 noti_err = notification_set_text(noti, NOTIFICATION_TEXT_TYPE_TITLE,
786 NETCONFIG_NOTIFICATION_WIFI_FOUND_TITLE,
787 "IDS_COM_BODY_WI_FI_NETWORKS_AVAILABLE",
788 NOTIFICATION_VARIABLE_TYPE_NONE);
789 if (noti_err != NOTIFICATION_ERROR_NONE) {
790 log_print(NET_POPUP, "Failed to notification_set_title : %d", noti_err);
794 noti_err = notification_set_text(noti, NOTIFICATION_TEXT_TYPE_CONTENT,
795 NETCONFIG_NOTIFICATION_WIFI_FOUND_CONTENT,
796 "IDS_WIFI_SBODY_TAP_HERE_TO_CONNECT",
797 NOTIFICATION_VARIABLE_TYPE_NONE);
798 if (noti_err != NOTIFICATION_ERROR_NONE) {
799 log_print(NET_POPUP, "Failed to notification_set_content: %d", noti_err);
803 noti_flags = NOTIFICATION_DISPLAY_APP_NOTIFICATION_TRAY | NOTIFICATION_DISPLAY_APP_INDICATOR;
804 noti_err = notification_set_display_applist(noti, noti_flags);
805 if(noti_err != NOTIFICATION_ERROR_NONE) {
806 log_print(NET_POPUP, "Failed to notification_set_display_applist: %d", noti_err);
810 ret = app_control_create(&service_handle);
811 log_print(NET_POPUP, "service create ret[%d]", ret);
812 if(ret != APP_CONTROL_ERROR_NONE)
815 ret = app_control_add_extra_data(service_handle, "caller", "notification");
816 log_print(NET_POPUP, "Service data addition ret = %d", ret);
817 if(ret != APP_CONTROL_ERROR_NONE)
820 noti_err = notification_set_launch_option(noti,
821 NOTIFICATION_LAUNCH_OPTION_APP_CONTROL, service_handle);
822 if (noti_err != NOTIFICATION_ERROR_NONE) {
823 log_print(NET_POPUP, "Failed to notification_set_launch_option");
827 noti_err = notification_post(noti);
828 if (noti_err != NOTIFICATION_ERROR_NONE) {
829 log_print(NET_POPUP, "Failed to insert notification");
833 log_print(NET_POPUP, "Successfully added notification");
838 notification_free(noti);
841 static void __net_popup_del_found_ap_noti(void)
843 notification_error_e noti_err = NOTIFICATION_ERROR_NONE;
845 noti_err = notification_delete_all(NOTIFICATION_TYPE_ONGOING);
846 if (noti_err != NOTIFICATION_ERROR_NONE) {
847 log_print(NET_POPUP, "fail to notification_delete_by_priv_id");
851 log_print(NET_POPUP, "Successfully deleted notification");
854 static void __net_popup_add_portal_noti(app_control_h request)
858 char *ap_name = NULL;
859 notification_h noti = NULL;
860 app_control_h service_handle = NULL;
861 notification_list_h noti_list = NULL;
862 notification_error_e noti_err = NOTIFICATION_ERROR_NONE;
864 ret = app_control_get_extra_data(request, "_AP_NAME_", &ap_name);
866 if (ap_name == NULL || ret != APP_CONTROL_ERROR_NONE) {
867 log_print(NET_POPUP, "Failed to retrieve connected AP name!!");
872 log_print(NET_POPUP, "Successfully added notification");
874 notification_get_detail_list("net.netpopup", NOTIFICATION_GROUP_ID_NONE,
875 NOTIFICATION_PRIV_ID_NONE, -1, ¬i_list);
876 if (noti_list != NULL) {
877 notification_free_list(noti_list);
882 noti = notification_create(NOTIFICATION_TYPE_NOTI);
884 log_print(NET_POPUP, "fail to create notification");
889 noti_err = notification_set_time(noti, time(NULL));
890 if(noti_err != NOTIFICATION_ERROR_NONE) {
891 log_print(NET_POPUP, "fail to notification_set_time : %d", noti_err);
895 noti_err = notification_set_image(noti, NOTIFICATION_IMAGE_TYPE_ICON,
896 NETCONFIG_NOTIFICATION_WIFI_ICON);
897 if(noti_err != NOTIFICATION_ERROR_NONE) {
898 log_print(NET_POPUP, "fail to notification_set_image : %d", noti_err);
902 noti_err = notification_set_image(noti, NOTIFICATION_IMAGE_TYPE_ICON,
903 QP_PRELOAD_NOTI_ICON_PATH"/noti_wifi_in_range.png");
904 if(noti_err != NOTIFICATION_ERROR_NONE) {
905 log_print(NET_POPUP, "fail to notification_set_image : %d", noti_err);
908 noti_err = notification_set_layout(noti, NOTIFICATION_LY_NOTI_EVENT_MULTIPLE);
909 if (noti_err != NOTIFICATION_ERROR_NONE) {
910 log_print(NET_POPUP, "fail to notification_set_layout : %d", noti_err);
914 noti_err = notification_set_text_domain(noti, PACKAGE,
916 if(noti_err != NOTIFICATION_ERROR_NONE) {
917 log_print(NET_POPUP, "fail to notification_set_text_domain : %d", noti_err);
921 noti_err = notification_set_text(noti, NOTIFICATION_TEXT_TYPE_TITLE,
922 NETCONFIG_NOTIFICATION_WIFI_PORTAL_TITLE,
923 "IDS_WIFI_HEADER_SIGN_IN_TO_WI_FI_NETWORK_ABB",
924 NOTIFICATION_VARIABLE_TYPE_NONE);
925 if (noti_err != NOTIFICATION_ERROR_NONE) {
926 log_print(NET_POPUP, "fail to notification_set_title : %d", noti_err);
930 noti_err = notification_set_text(noti, NOTIFICATION_TEXT_TYPE_CONTENT,
931 NETCONFIG_NOTIFICATION_WIFI_PORTAL_CONTENT,
932 NETCONFIG_NOTIFICATION_WIFI_PORTAL_CONTENT,
933 NOTIFICATION_VARIABLE_TYPE_STRING, ap_name,
934 NOTIFICATION_VARIABLE_TYPE_NONE);
935 if (noti_err != NOTIFICATION_ERROR_NONE) {
936 log_print(NET_POPUP, "fail to notification_set_content : %d", noti_err);
940 noti_flags = NOTIFICATION_DISPLAY_APP_NOTIFICATION_TRAY | NOTIFICATION_DISPLAY_APP_INDICATOR;
941 noti_err = notification_set_display_applist(noti, noti_flags);
942 if(noti_err != NOTIFICATION_ERROR_NONE) {
943 log_print(NET_POPUP, "fail to notification_set_display_applist : %d", noti_err);
947 ret = app_control_create(&service_handle);
948 log_print(NET_POPUP, "service create ret[%d]", ret);
949 if(ret != APP_CONTROL_ERROR_NONE)
952 ret = app_control_set_operation(service_handle, APP_CONTROL_OPERATION_VIEW);
953 if(ret != APP_CONTROL_ERROR_NONE)
956 log_print(NET_POPUP, "service set operation is successful");
958 ret = app_control_set_uri(service_handle, "http://www.google.com");
960 if(ret != APP_CONTROL_ERROR_NONE)
963 noti_err = notification_set_launch_option(noti,
964 NOTIFICATION_LAUNCH_OPTION_APP_CONTROL, service_handle);
965 if (noti_err != NOTIFICATION_ERROR_NONE) {
966 log_print(NET_POPUP, "fail to notification_set_launch_option");
970 noti_err = notification_post(noti);
971 if (noti_err != NOTIFICATION_ERROR_NONE) {
972 log_print(NET_POPUP, "fail to notification_post");
976 log_print(NET_POPUP, "Successfully added notification");
981 notification_free(noti);
983 if (service_handle != NULL)
984 app_control_destroy(service_handle);
987 static void __net_popup_del_portal_noti(void)
989 notification_error_e noti_err = NOTIFICATION_ERROR_NONE;
991 noti_err = notification_delete_all(NOTIFICATION_TYPE_NOTI);
992 if (noti_err != NOTIFICATION_ERROR_NONE) {
993 log_print(NET_POPUP, "fail to notification_delete_all");
997 log_print(NET_POPUP, "Successfully deleted notification");
1000 EXPORT_API int main(int argc, char *argv[])
1002 ui_app_lifecycle_callback_s app_callback = {
1003 .create = __net_popup_create,
1004 .terminate = __net_popup_terminate,
1005 .pause = __net_popup_pause,
1006 .resume = __net_popup_resume,
1007 .app_control = __net_popup_service_cb,
1010 return ui_app_main(argc, argv, &app_callback, NULL);