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.
24 #include <notification.h>
25 #include <efl_assist.h>
26 #include <notification_internal.h>
29 #include <app_control.h>
31 #include <vconf-keys.h>
32 #include <dbus/dbus.h>
33 #include <dbus/dbus-glib.h>
34 #include <dbus/dbus-glib-lowlevel.h>
36 #include "net-popup.h"
37 #include "net-popup-strings.h"
39 #define LOCALEDIR "/usr/share/locale"
40 #define NETPOPUP_EDJ "/usr/ug/res/edje/net-popup/netpopup-custom.edj"
41 #define QP_PRELOAD_NOTI_ICON_PATH "/usr/apps/org.tizen.quickpanel/shared/res/noti_icons"
43 #define NETCONFIG_NOTIFICATION_WIFI_ICON \
44 "/usr/share/icons/noti_wifi_in_range.png"
45 #define NETCONFIG_NOTIFICATION_WIFI_ICON_LITE \
46 "/usr/share/icons/noti_wifi_in_range_ongoing.png"
47 #define NETCONFIG_NOTIFICATION_WIFI_CAPTIVE_ICON \
48 "/usr/share/icons/B03_notify_Wi-fi_range.png"
49 #define NETCONFIG_NOTIFICATION_WIFI_IN_RANGE_ICON \
50 "/usr/share/icons/Q02_Notification_wifi_in_range.png"
51 #define NETCONFIG_NOTIFICATION_WIFI_IN_RANGE_ICON_LITE \
52 "/usr/share/icons/noti_wifi_in_range.png"
53 #define NETCONFIG_NOTIFICATION_WIFI_FOUND_TITLE \
54 dgettext(PACKAGE, "IDS_COM_BODY_WI_FI_NETWORKS_AVAILABLE")
55 #define NETCONFIG_NOTIFICATION_WIFI_FOUND_CONTENT \
56 dgettext(PACKAGE, "IDS_WIFI_SBODY_TAP_HERE_TO_CONNECT")
57 #define NETCONFIG_NOTIFICATION_WIFI_PORTAL_TITLE \
58 dgettext(PACKAGE, "IDS_WIFI_HEADER_SIGN_IN_TO_WI_FI_NETWORK_ABB")
59 #define NETCONFIG_NOTIFICATION_WIFI_PORTAL_CONTENT "\"%s\""
61 #define USER_RESP_LEN 30
62 #define RESP_REMAIN_CONNECTED "RESP_REMAIN_CONNECTED"
63 #define RESP_WIFI_TETHERING_OFF "RESP_TETHERING_TYPE_WIFI_OFF"
64 #define RESP_WIFI_AP_TETHERING_OFF "RESP_TETHERING_TYPE_WIFI_AP_OFF"
65 #define RESP_TETHERING_ON "RESP_TETHERING_ON"
66 #define CAPTIVE_PORTAL_LOGIN "Login required to access Internet"
67 #define CAPTIVE_PORTAL_LOGIN_ERROR "Login not completed. Disconnected active Wifi"
69 static Ecore_Event_Handler *ecore_event_evas_handler;
70 static Ecore_Event_Handler *ecore_event_evas_quick_panel_handler;
73 long sizes[] = {1073741824, 1048576, 1024, 0};
74 char *units[] = {"GB", "MB", "KB", "B"};
76 static app_control_h g_req_handle = NULL;
77 static char * resp_popup_mode = NULL;
79 static DBusGConnection *conn = NULL;
80 static DBusGProxy *proxy = NULL;
82 static int __net_popup_show_notification(app_control_h request, void *data);
83 static int __toast_popup_show(app_control_h request, void *data);
84 static int __net_popup_show_popup(app_control_h request, void *data);
85 static void __net_popup_add_found_ap_noti(void);
86 static void __net_popup_del_found_ap_noti(void);
87 static void __net_popup_add_portal_noti(app_control_h request);
88 static void __net_popup_del_portal_noti(void);
89 static void __net_popup_show_popup_with_user_resp(app_control_h request, void *data);
90 static int _net_popup_send_user_resp(char *resp, Eina_Bool state);
93 DBusGProxy *__net_popup_init_dbus(void)
97 conn = dbus_g_bus_get(DBUS_BUS_SYSTEM, &err);
103 proxy = dbus_g_proxy_new_for_name(conn, "net.netpopup",
104 "/Netpopup", "net.netpopup");
106 dbus_g_connection_unref(conn);
113 void __net_popup_deinit_dbus(void)
116 g_object_unref(proxy);
121 dbus_g_connection_unref(conn);
128 int __net_popup_send_dbus_msg(const char *resp)
130 if (conn == NULL || resp == NULL) {
134 DBusConnection *gconn = NULL;
135 DBusMessage *msg = NULL;
136 char *module = "wifi";
138 gconn = dbus_g_connection_get_connection(conn);
143 msg = dbus_message_new_signal("/Org/Tizen/Quickpanel",
144 "org.tizen.quickpanel",
150 if (!dbus_message_append_args(msg,
151 DBUS_TYPE_STRING, &module,
152 DBUS_TYPE_STRING, &resp,
153 DBUS_TYPE_INVALID)) {
154 dbus_message_unref(msg);
158 dbus_connection_send(gconn, msg, NULL);
159 dbus_message_unref(msg);
164 static bool __net_popup_create(void *data)
166 log_print(NET_POPUP, "__net_popup_create()\n");
168 bindtextdomain(PACKAGE, LOCALEDIR);
173 static void __net_popup_terminate(void *data)
175 if (ecore_event_evas_handler) {
176 ecore_event_handler_del(ecore_event_evas_handler);
177 ecore_event_evas_handler = NULL;
179 if (ecore_event_evas_quick_panel_handler) {
180 ecore_event_handler_del(ecore_event_evas_quick_panel_handler);
181 ecore_event_evas_quick_panel_handler = NULL;
187 static void __net_popup_pause(void *data)
189 log_print(NET_POPUP, "__net_popup_pause()");
192 static void __net_popup_resume(void *data)
197 static Eina_Bool __key_release_event_cb(void *data, int type,
200 Evas_Event_Key_Down *ev = (Evas_Event_Key_Down *) event;
203 return ECORE_CALLBACK_RENEW;
207 return ECORE_CALLBACK_RENEW;
210 log_print(NET_POPUP, "key_release : %s", ev->keyname);
211 if (g_strcmp0(ev->keyname, "XF86Phone") == 0 ||
212 g_strcmp0(ev->keyname, "XF86Stop") == 0) {
216 return ECORE_CALLBACK_DONE;
219 static Eina_Bool _ecore_event_client_message_cb(void *data, int type,
222 Ecore_X_Event_Client_Message *ev = event;
224 if (ev->message_type == ECORE_X_ATOM_E_ILLUME_QUICKPANEL_STATE) {
225 if (ev->data.l[0] == ECORE_X_ATOM_E_ILLUME_QUICKPANEL_OFF) {
226 log_print(NET_POPUP, "ECORE_X_ATOM_E_ILLUME_QUICKPANEL_OFF");
227 } else if (ev->data.l[0] == ECORE_X_ATOM_E_ILLUME_QUICKPANEL_ON) {
228 log_print(NET_POPUP, "ECORE_X_ATOM_E_ILLUME_QUICKPANEL_ON");
231 return ECORE_CALLBACK_RENEW;
234 static void __net_popup_service_cb(app_control_h request, void *data)
236 log_print(NET_POPUP, "__net_popup_service_cb()\n");
241 if (ecore_event_evas_handler == NULL) {
242 ecore_event_evas_handler = ecore_event_handler_add(ECORE_EVENT_KEY_UP,
243 __key_release_event_cb, NULL);
246 if (ecore_event_evas_quick_panel_handler == NULL) {
247 ecore_event_evas_quick_panel_handler = ecore_event_handler_add(
248 ECORE_X_EVENT_CLIENT_MESSAGE, _ecore_event_client_message_cb, NULL);
251 ret = app_control_get_extra_data(request, "_SYSPOPUP_TYPE_", &type);
253 ea_theme_changeable_ui_enabled_set(EINA_TRUE);
255 if (APP_CONTROL_ERROR_NONE != ret) {
256 log_print(NET_POPUP, "Failed to get _SYSPOPUP_TYPE_ ret = %d", ret);
262 log_print(NET_POPUP, "type = %s\n", type);
264 if (g_str_equal(type, "notification")) {
265 __net_popup_show_notification(request, data);
267 } else if (g_str_equal(type, "toast_popup")) {
268 __toast_popup_show(request, data);
269 } else if (g_str_equal(type, "popup")) {
270 __net_popup_show_popup(request, data);
271 } else if (g_str_equal(type, "add_found_ap_noti")) {
272 __net_popup_add_found_ap_noti();
274 } else if (g_str_equal(type, "del_found_ap_noti")) {
275 __net_popup_del_found_ap_noti();
277 } else if (g_str_equal(type, "add_portal_noti")) {
278 __net_popup_add_portal_noti(request);
280 } else if (g_str_equal(type, "del_portal_noti")) {
281 __net_popup_del_portal_noti();
283 } else if (g_str_equal(type, "popup_user_resp")) {
284 app_control_clone(&g_req_handle, request);
285 __net_popup_show_popup_with_user_resp(request, data);
287 __net_popup_show_notification(request, data);
295 static void __net_popup_set_orientation(Evas_Object *win)
297 int rots[4] = { 0, 90, 180, 270 };
299 if (!elm_win_wm_rotation_supported_get(win)) {
303 elm_win_wm_rotation_available_rotations_set(win, rots, 4);
306 static Evas_Object* __net_popup_create_win(void)
308 Evas_Object *win = NULL;
310 Ecore_Evas *ee = NULL;
313 win = elm_win_add(NULL, PACKAGE, ELM_WIN_NOTIFICATION);
315 e = evas_object_evas_get(win);
316 ee = ecore_evas_ecore_evas_get(e);
317 ecore_evas_name_class_set(ee,"APP_POPUP","APP_POPUP");
319 elm_win_alpha_set(win, EINA_TRUE);
320 elm_win_borderless_set(win, EINA_TRUE);
321 ecore_x_window_size_get(ecore_x_window_root_first_get(), &w, &h);
322 evas_object_resize(win, w, h);
323 utilx_set_system_notification_level (ecore_x_display_get(),
324 elm_win_xwindow_get(win),
325 UTILX_NOTIFICATION_LEVEL_LOW);
327 __net_popup_set_orientation(win);
332 static void _ok_button_clicked_cb(void *data, Evas_Object *obj, void *event_info)
335 evas_object_del(data);
339 static void _timeout_cb(void *data, Evas_Object *obj, void *event_info)
341 evas_object_del(obj);
346 static int __toast_popup_show(app_control_h request, void *data)
348 char buf[ALERT_STR_LEN_MAX] = "";
351 Evas_Object *twin = NULL;
352 Evas_Object *tpop = NULL;
354 ret = app_control_get_extra_data(request, "_SYSPOPUP_CONTENT_", &mode);
355 if (ret != APP_CONTROL_ERROR_NONE) {
356 log_print(NET_POPUP, "Failed to get _SYSPOPUP_CONTENT_ ret = %d", ret);
362 log_print(NET_POPUP, "_SYSPOPUP_CONTENT_ = %s\n", mode);
364 twin = __net_popup_create_win();
365 tpop = elm_popup_add(twin);
366 elm_object_style_set(tpop, "toast");
367 evas_object_size_hint_weight_set(tpop, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
369 elm_popup_timeout_set(tpop, 2.0);
371 evas_object_smart_callback_add(tpop, "timeout", _timeout_cb, twin);
372 if (strcmp(mode, "wrong password") == 0) {
373 log_print(NET_POPUP, "alert wrong password\n");
375 g_snprintf(buf, ALERT_STR_LEN_MAX, ALERT_STR_ERR_WRONG_PASSWORD);
376 } else if (strcmp(mode, "no ap found") == 0) {
377 log_print(NET_POPUP, "alert no ap found\n");
379 g_snprintf(buf, ALERT_STR_LEN_MAX, ALERT_STR_NO_AP_FOUND);
381 log_print(NET_POPUP, "%s\n", mode);
383 elm_object_part_text_set(tpop,"elm.text", buf);
384 evas_object_show(tpop);
385 evas_object_show(twin);
391 static int __net_popup_show_notification(app_control_h request, void *data)
395 char buf[ALERT_STR_LEN_MAX] = "";
396 char *ap_name = NULL;
398 ret = app_control_get_extra_data(request, "_SYSPOPUP_CONTENT_", &mode);
400 if (APP_CONTROL_ERROR_NONE != ret) {
401 log_print(NET_POPUP, "Failed to get _SYSPOPUP_CONTENT_");
405 secure_log_print(NET_POPUP, "_SYSPOPUP_CONTENT_ = %s\n", mode);
407 if (strcmp(mode, "connected") == 0) {
408 notification_status_message_post(ALERT_STR_MOBILE_NETWORKS_CHARGE);
409 log_print(NET_POPUP, "alert 3g\n");
410 } else if (strcmp(mode, "fail to connect") == 0) {
411 notification_status_message_post(ALERT_STR_ERR_UNAVAILABLE);
412 log_print(NET_POPUP, "alert err\n");
413 } else if (strcmp(mode, "unable to connect") == 0) {
414 notification_status_message_post(ALERT_STR_ERR_CONNECT);
415 log_print(NET_POPUP, "alert unable to connect\n");
416 } else if (strcmp(mode, "wrong password") == 0) {
417 notification_status_message_post(ALERT_STR_ERR_WRONG_PASSWORD);
418 log_print(NET_POPUP, "alert wrong password\n");
419 } else if (strcmp(mode, "not support") == 0) {
420 notification_status_message_post(ALERT_STR_ERR_NOT_SUPPORT);
421 log_print(NET_POPUP, "alert not support\n");
422 } else if (strcmp(mode, "wifi restricted") == 0) {
423 notification_status_message_post(ALERT_STR_RESTRICTED_USE_WIFI);
424 log_print(NET_POPUP, "alert wifi restricted\n");
425 } else if (strcmp(mode, "no ap found") == 0) {
426 notification_status_message_post(ALERT_STR_NO_AP_FOUND);
427 log_print(NET_POPUP, "alert no ap found\n");
428 } else if (strcmp(mode, "Lengthy Password") == 0) {
429 notification_status_message_post(ALERT_STR_LENGHTY_PASSWORD);
430 log_print(NET_POPUP, "Password entered crosses 64 bytes\n");
431 } else if (strcmp(mode, "Portal Login") == 0) {
432 notification_status_message_post(CAPTIVE_PORTAL_LOGIN);
433 log_print(NET_POPUP, "Please login to access Internet\n");
434 } else if (strcmp(mode, "Portal Login Error") == 0) {
435 notification_status_message_post(CAPTIVE_PORTAL_LOGIN_ERROR);
436 log_print(NET_POPUP, "Login not completed. Disconnected Wifi\n");
437 } else if (strcmp(mode, "wifi connected") == 0) {
438 ret = app_control_get_extra_data(request, "_AP_NAME_", &ap_name);
440 if (APP_CONTROL_ERROR_NONE != ret) {
441 log_print(NET_POPUP, "Failed to get _AP_NAME_ ret = %d", ret);
447 g_snprintf(buf, ALERT_STR_LEN_MAX, ALERT_STR_WIFI_CONNECTED, ap_name);
449 g_snprintf(buf, ALERT_STR_LEN_MAX, ALERT_STR_WIFI_CONNECTED, "");
451 notification_status_message_post(buf);
453 log_print(NET_POPUP, "alert wifi connected\n");
456 notification_status_message_post(mode);
457 log_print(NET_POPUP, "%s\n", mode);
464 static int _net_popup_send_user_resp(char *resp, Eina_Bool state)
467 app_control_h reply = NULL;
468 char checkbox_str[USER_RESP_LEN] = { '\0', };
470 log_print(NET_POPUP, "Send the user response to the caller");
471 ret = app_control_create(&reply);
472 if (APP_CONTROL_ERROR_NONE != ret) {
473 log_print(NET_POPUP, "Failed to create service ret = %d", ret);
474 app_control_destroy(g_req_handle);
481 g_strlcpy(checkbox_str, "TRUE", USER_RESP_LEN);
483 g_strlcpy(checkbox_str, "FALSE", USER_RESP_LEN);
485 log_print(NET_POPUP, "Checkbox_str[%s]", checkbox_str);
487 ret = app_control_add_extra_data(reply, "_SYSPOPUP_RESP_", resp);
488 if (APP_CONTROL_ERROR_NONE == ret) {
489 ret = app_control_add_extra_data(reply, "_SYSPOPUP_CHECKBOX_RESP_",
491 if (APP_CONTROL_ERROR_NONE == ret) {
492 ret = app_control_reply_to_launch_request(reply, g_req_handle,
493 APP_CONTROL_RESULT_SUCCEEDED);
494 if (APP_CONTROL_ERROR_NONE == ret) {
495 log_print(NET_POPUP, "Service reply success");
498 log_print(NET_POPUP, "Service reply failed ret = %d", ret);
501 log_print(NET_POPUP, "Service data addition failed ret = %d", ret);
504 log_print(NET_POPUP, "Service data addition failed ret = %d", ret);
507 app_control_destroy(reply);
508 app_control_destroy(g_req_handle);
514 void _tethering_wifi_btn_yes_cb(void *data, Evas_Object *obj, void *event_info)
516 log_print(NET_POPUP, "_tethering_wifi_btn_yes_cb");
519 Evas_Object *popup = (Evas_Object *)data;
521 __net_popup_init_dbus();
522 __net_popup_send_dbus_msg("progress_off");
523 __net_popup_deinit_dbus();
525 result = _net_popup_send_user_resp(RESP_WIFI_TETHERING_OFF, FALSE);
527 log_print(NET_POPUP, "Failed to send user response ");
530 evas_object_del(popup);
535 void _tethering_wifi_ap_btn_yes_cb(void *data, Evas_Object *obj, void *event_info)
537 log_print(NET_POPUP, "_tethering_wifi_ap_btn_yes_cb");
540 Evas_Object *popup = (Evas_Object *)data;
542 __net_popup_init_dbus();
543 __net_popup_send_dbus_msg("progress_off");
544 __net_popup_deinit_dbus();
546 result = _net_popup_send_user_resp(RESP_WIFI_AP_TETHERING_OFF, FALSE);
548 log_print(NET_POPUP, "Failed to send user response ");
551 evas_object_del(popup);
556 void _btn_no_cb(void *data, Evas_Object *obj, void *event_info)
558 log_print(NET_POPUP, "_btn_no_cb");
561 Evas_Object *popup = (Evas_Object *)data;
563 result = _net_popup_send_user_resp(RESP_TETHERING_ON, FALSE);
565 log_print(NET_POPUP, "Failed to send user response ");
568 evas_object_del(popup);
573 static void __net_popup_show_popup_with_user_resp(app_control_h request,
584 ret = app_control_get_extra_data(request, "_SYSPOPUP_CONTENT_", &resp_popup_mode);
585 if (APP_CONTROL_ERROR_NONE != ret)
586 log_print(NET_POPUP, "Failed to get _SYSPOPUP_CONTENT_ ret = %d", ret);
588 secure_log_print(NET_POPUP, "_SYSPOPUP_CONTENT_ = %s\n", resp_popup_mode);
590 win = __net_popup_create_win();
591 evas_object_show(win);
593 popup = elm_popup_add(win);
594 evas_object_size_hint_weight_set(popup, EVAS_HINT_EXPAND,
597 if (g_strcmp0(resp_popup_mode, "TETHERING_TYPE_WIFI") == 0 ||
598 g_strcmp0(resp_popup_mode, "TETHERING_TYPE_WIFI_AP") == 0) {
599 log_print(NET_POPUP, "Drawing Wi-Fi Tethering OFF popup");
601 __net_popup_init_dbus();
602 elm_object_part_text_set(popup, "title,text", ALERT_STR_WIFI);
604 layout = elm_layout_add(popup);
605 elm_layout_file_set(layout, NETPOPUP_EDJ, "popup");
606 evas_object_size_hint_weight_set(layout, EVAS_HINT_EXPAND,
609 __net_popup_send_dbus_msg("progress_on");
610 label = elm_label_add(popup);
611 elm_label_line_wrap_set(label, ELM_WRAP_MIXED);
612 elm_object_text_set(label, ALERT_STR_WIFI_MOBILE_AP_ON);
613 evas_object_size_hint_weight_set(label, EVAS_HINT_EXPAND,
615 evas_object_size_hint_align_set(label, EVAS_HINT_FILL, EVAS_HINT_FILL);
616 evas_object_show(label);
618 elm_object_part_content_set(layout, "elm.swallow.content", label);
619 evas_object_show(layout);
620 elm_object_style_set(label, "popup/default");
621 ea_object_event_callback_add(popup, EA_CALLBACK_BACK, _btn_no_cb, popup);
622 elm_object_content_set(popup, label);
624 btn1 = elm_button_add(popup);
625 elm_object_style_set(btn1, "popup");
626 elm_object_text_set(btn1, ALERT_STR_CANCEL);
627 elm_object_part_content_set(popup, "button1", btn1);
628 evas_object_smart_callback_add(btn1, "clicked",
631 btn2 = elm_button_add(popup);
632 elm_object_style_set(btn2, "popup");
633 elm_object_text_set(btn2, ALERT_STR_OK);
634 elm_object_part_content_set(popup, "button2", btn2);
636 if (g_strcmp0(resp_popup_mode, "TETHERING_TYPE_WIFI") == 0)
637 evas_object_smart_callback_add(btn2, "clicked",
638 _tethering_wifi_btn_yes_cb, popup);
639 else if (g_strcmp0(resp_popup_mode, "TETHERING_TYPE_WIFI_AP") == 0)
640 evas_object_smart_callback_add(btn2, "clicked",
641 _tethering_wifi_ap_btn_yes_cb, popup);
643 evas_object_show(popup);
644 evas_object_show(win);
645 __net_popup_deinit_dbus();
649 static int __net_popup_show_popup(app_control_h request, void *data)
657 ret = app_control_get_extra_data(request, "_SYSPOPUP_CONTENT_", &mode);
658 if (APP_CONTROL_ERROR_NONE != ret) {
659 log_print(NET_POPUP, "Failed to get _SYSPOPUP_CONTENT_ ret = %d", ret);
665 secure_log_print(NET_POPUP, "_SYSPOPUP_CONTENT_ = %s\n", mode);
667 win = __net_popup_create_win();
669 popup = elm_popup_add(win);
670 evas_object_size_hint_weight_set(popup, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
671 if (strcmp(mode, "connected") == 0) {
672 elm_object_text_set(popup, ALERT_STR_MOBILE_NETWORKS_CHARGE);
673 log_print(NET_POPUP, "alert 3g\n");
674 } else if (strcmp(mode, "fail to connect") == 0) {
675 elm_object_text_set(popup, ALERT_STR_ERR_UNAVAILABLE);
676 log_print(NET_POPUP, "alert err\n");
677 } else if (strcmp(mode, "unable to connect") == 0) {
678 elm_object_text_set(popup, ALERT_STR_ERR_CONNECT);
679 log_print(NET_POPUP, "alert unable to connect\n");
680 } else if (strcmp(mode, "wrong password") == 0) {
681 elm_object_text_set(popup, ALERT_STR_ERR_WRONG_PASSWORD);
682 log_print(NET_POPUP, "alert wrong password\n");
683 } else if (strcmp(mode, "not support") == 0) {
684 elm_object_text_set(popup, ALERT_STR_ERR_NOT_SUPPORT);
685 log_print(NET_POPUP, "alert not support\n");
686 } else if (strcmp(mode, "wifi restricted") == 0) {
687 elm_object_text_set(popup, ALERT_STR_RESTRICTED_USE_WIFI);
688 log_print(NET_POPUP, "alert wifi restricted\n");
689 } else if (strcmp(mode, "no ap found") == 0) {
690 elm_object_text_set(popup, ALERT_STR_NO_AP_FOUND);
691 log_print(NET_POPUP, "alert no ap found\n");
692 } else if (strcmp(mode, "wifi connected") == 0) {
693 char buf[ALERT_STR_LEN_MAX] = "";
694 char *ap_name = NULL;
696 ret = app_control_get_extra_data(request, "_AP_NAME_", &ap_name);
699 g_snprintf(buf, ALERT_STR_LEN_MAX, ALERT_STR_WIFI_CONNECTED, ap_name);
701 g_snprintf(buf, ALERT_STR_LEN_MAX, ALERT_STR_WIFI_CONNECTED, "");
703 elm_object_text_set(popup, buf);
705 log_print(NET_POPUP, "alert wifi connected\n");
708 elm_object_text_set(popup, mode);
709 log_print(NET_POPUP, "%s\n", mode);
712 button = elm_button_add(popup);
713 elm_object_style_set(button, "popup");
714 elm_object_text_set(button, ALERT_STR_OK);
715 elm_object_part_content_set(popup, "button1", button);
716 evas_object_smart_callback_add(button, "clicked", _ok_button_clicked_cb, popup);
717 evas_object_show(popup);
718 evas_object_show(win);
724 static void __net_popup_add_found_ap_noti(void)
727 notification_h noti = NULL;
728 notification_list_h noti_list = NULL;
729 notification_error_e noti_err = NOTIFICATION_ERROR_NONE;
732 notification_get_detail_list("net.netpopup", NOTIFICATION_GROUP_ID_NONE,
733 NOTIFICATION_PRIV_ID_NONE, -1, ¬i_list);
734 if (noti_list != NULL) {
735 notification_free_list(noti_list);
739 noti = notification_new(NOTIFICATION_TYPE_ONGOING, NOTIFICATION_GROUP_ID_NONE,
740 NOTIFICATION_PRIV_ID_NONE);
742 log_print(NET_POPUP, "Failed to create notification");
746 noti_err = notification_set_time(noti, time(NULL));
747 if(noti_err != NOTIFICATION_ERROR_NONE) {
748 log_print(NET_POPUP, "Failed to notification_set_time : %d", noti_err);
752 noti_err = notification_set_image(noti, NOTIFICATION_IMAGE_TYPE_ICON,
753 QP_PRELOAD_NOTI_ICON_PATH"/noti_wifi_in_range.png");
754 if(noti_err != NOTIFICATION_ERROR_NONE) {
755 log_print(NET_POPUP, "Failed to notification_set_image : %d", noti_err);
759 noti_err = notification_set_layout(noti, NOTIFICATION_LY_ONGOING_EVENT);
760 if (noti_err != NOTIFICATION_ERROR_NONE) {
761 log_print(NET_POPUP, "Failed to notification_set_layout : %d", noti_err);
765 noti_err = notification_set_text_domain(noti, PACKAGE,
767 if(noti_err != NOTIFICATION_ERROR_NONE) {
768 log_print(NET_POPUP, "Failed to notification_set_text_domain : %d", noti_err);
772 noti_err = notification_set_text(noti, NOTIFICATION_TEXT_TYPE_TITLE,
773 NETCONFIG_NOTIFICATION_WIFI_FOUND_TITLE,
774 "IDS_COM_BODY_WI_FI_NETWORKS_AVAILABLE",
775 NOTIFICATION_VARIABLE_TYPE_NONE);
776 if (noti_err != NOTIFICATION_ERROR_NONE) {
777 log_print(NET_POPUP, "Failed to notification_set_title : %d", noti_err);
781 noti_err = notification_set_text(noti, NOTIFICATION_TEXT_TYPE_CONTENT,
782 NETCONFIG_NOTIFICATION_WIFI_FOUND_CONTENT,
783 "IDS_WIFI_SBODY_TAP_HERE_TO_CONNECT",
784 NOTIFICATION_VARIABLE_TYPE_NONE);
785 if (noti_err != NOTIFICATION_ERROR_NONE) {
786 log_print(NET_POPUP, "Failed to notification_set_content: %d", noti_err);
790 noti_flags = NOTIFICATION_DISPLAY_APP_NOTIFICATION_TRAY | NOTIFICATION_DISPLAY_APP_INDICATOR;
791 noti_err = notification_set_display_applist(noti, noti_flags);
792 if(noti_err != NOTIFICATION_ERROR_NONE) {
793 log_print(NET_POPUP, "Failed to notification_set_display_applist: %d", noti_err);
798 bundle_add(b, "caller", "notification");
800 appsvc_set_pkgname(b, "net.wifi-qs");
802 noti_err = notification_set_execute_option(noti,
803 NOTIFICATION_EXECUTE_TYPE_SINGLE_LAUNCH, "Launch", NULL, b);
804 if (noti_err != NOTIFICATION_ERROR_NONE) {
805 log_print(NET_POPUP, "Failed to notification_set_execute_option");
809 noti_err = notification_insert(noti, NULL);
810 if (noti_err != NOTIFICATION_ERROR_NONE) {
811 log_print(NET_POPUP, "Failed to insert notification");
815 log_print(NET_POPUP, "Successfully added notification");
822 notification_free(noti);
825 static void __net_popup_del_found_ap_noti(void)
827 notification_error_e noti_err = NOTIFICATION_ERROR_NONE;
829 noti_err = notification_delete_all_by_type("net.netpopup",
830 NOTIFICATION_TYPE_ONGOING);
831 if (noti_err != NOTIFICATION_ERROR_NONE) {
832 log_print(NET_POPUP, "fail to notification_delete_by_priv_id");
836 log_print(NET_POPUP, "Successfully deleted notification");
839 static void __net_popup_add_portal_noti(app_control_h request)
844 char *ap_name = NULL;
845 notification_h noti = NULL;
846 app_control_h service_handle = NULL;
847 notification_list_h noti_list = NULL;
848 notification_error_e noti_err = NOTIFICATION_ERROR_NONE;
850 ret = app_control_get_extra_data(request, "_AP_NAME_", &ap_name);
852 if (ap_name == NULL || ret != APP_CONTROL_ERROR_NONE) {
853 log_print(NET_POPUP, "Failed to retrieve connected AP name!!");
858 log_print(NET_POPUP, "Successfully added notification");
860 notification_get_detail_list("net.netpopup", NOTIFICATION_GROUP_ID_NONE,
861 NOTIFICATION_PRIV_ID_NONE, -1, ¬i_list);
862 if (noti_list != NULL) {
863 notification_free_list(noti_list);
868 noti = notification_new(NOTIFICATION_TYPE_NOTI, NOTIFICATION_GROUP_ID_NONE,
869 NOTIFICATION_PRIV_ID_NONE);
871 log_print(NET_POPUP, "fail to create notification");
876 noti_err = notification_set_time(noti, time(NULL));
877 if(noti_err != NOTIFICATION_ERROR_NONE) {
878 log_print(NET_POPUP, "fail to notification_set_time : %d", noti_err);
882 noti_err = notification_set_image(noti, NOTIFICATION_IMAGE_TYPE_ICON,
883 NETCONFIG_NOTIFICATION_WIFI_ICON);
884 if(noti_err != NOTIFICATION_ERROR_NONE) {
885 log_print(NET_POPUP, "fail to notification_set_image : %d", noti_err);
889 noti_err = notification_set_image(noti, NOTIFICATION_IMAGE_TYPE_ICON,
890 QP_PRELOAD_NOTI_ICON_PATH"/noti_wifi_in_range.png");
891 if(noti_err != NOTIFICATION_ERROR_NONE) {
892 log_print(NET_POPUP, "fail to notification_set_image : %d", noti_err);
895 noti_err = notification_set_layout(noti, NOTIFICATION_LY_NOTI_EVENT_MULTIPLE);
896 if (noti_err != NOTIFICATION_ERROR_NONE) {
897 log_print(NET_POPUP, "fail to notification_set_layout : %d", noti_err);
901 noti_err = notification_set_text_domain(noti, PACKAGE,
903 if(noti_err != NOTIFICATION_ERROR_NONE) {
904 log_print(NET_POPUP, "fail to notification_set_text_domain : %d", noti_err);
908 noti_err = notification_set_text(noti, NOTIFICATION_TEXT_TYPE_TITLE,
909 NETCONFIG_NOTIFICATION_WIFI_PORTAL_TITLE,
910 "IDS_WIFI_HEADER_SIGN_IN_TO_WI_FI_NETWORK_ABB",
911 NOTIFICATION_VARIABLE_TYPE_NONE);
912 if (noti_err != NOTIFICATION_ERROR_NONE) {
913 log_print(NET_POPUP, "fail to notification_set_title : %d", noti_err);
917 noti_err = notification_set_text(noti, NOTIFICATION_TEXT_TYPE_CONTENT,
918 NETCONFIG_NOTIFICATION_WIFI_PORTAL_CONTENT,
919 NETCONFIG_NOTIFICATION_WIFI_PORTAL_CONTENT,
920 NOTIFICATION_VARIABLE_TYPE_STRING, ap_name,
921 NOTIFICATION_VARIABLE_TYPE_NONE);
922 if (noti_err != NOTIFICATION_ERROR_NONE) {
923 log_print(NET_POPUP, "fail to notification_set_content : %d", noti_err);
927 noti_flags = NOTIFICATION_DISPLAY_APP_NOTIFICATION_TRAY | NOTIFICATION_DISPLAY_APP_INDICATOR;
928 noti_err = notification_set_display_applist(noti, noti_flags);
929 if(noti_err != NOTIFICATION_ERROR_NONE) {
930 log_print(NET_POPUP, "fail to notification_set_display_applist : %d", noti_err);
934 ret = app_control_create(&service_handle);
935 log_print(NET_POPUP, "service create ret[%d]", ret);
936 if(ret != APP_CONTROL_ERROR_NONE)
939 ret = app_control_set_operation(service_handle, APP_CONTROL_OPERATION_VIEW);
940 if(ret != APP_CONTROL_ERROR_NONE)
943 log_print(NET_POPUP, "service set operation is successful");
945 ret = app_control_set_uri(service_handle, "http://www.google.com");
947 app_control_to_bundle (service_handle, &b);
948 if(ret != APP_CONTROL_ERROR_NONE)
951 noti_err = notification_set_execute_option(noti,
952 NOTIFICATION_EXECUTE_TYPE_SINGLE_LAUNCH, "Launch", NULL, b);
953 if (noti_err != NOTIFICATION_ERROR_NONE) {
954 log_print(NET_POPUP, "fail to notification_set_execute_option");
958 noti_err = notification_insert(noti, NULL);
959 if (noti_err != NOTIFICATION_ERROR_NONE) {
960 log_print(NET_POPUP, "fail to notification_insert");
964 log_print(NET_POPUP, "Successfully added notification");
969 notification_free(noti);
971 if (service_handle != NULL)
972 app_control_destroy(service_handle);
975 static void __net_popup_del_portal_noti(void)
977 notification_error_e noti_err = NOTIFICATION_ERROR_NONE;
979 noti_err = notification_delete_all_by_type("net.netpopup", NOTIFICATION_TYPE_NOTI);
980 if (noti_err != NOTIFICATION_ERROR_NONE) {
981 log_print(NET_POPUP, "fail to notification_delete_all_by_type");
985 log_print(NET_POPUP, "Successfully deleted notification");
988 EXPORT_API int main(int argc, char *argv[])
990 app_event_callback_s app_callback = {
991 .create = __net_popup_create,
992 .terminate = __net_popup_terminate,
993 .pause = __net_popup_pause,
994 .resume = __net_popup_resume,
995 .app_control = __net_popup_service_cb,
998 .device_orientation = NULL,
999 .language_changed =NULL,
1000 .region_format_changed =NULL,
1003 return app_efl_main(&argc, &argv, &app_callback, NULL);