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 LOCALEDIR "/usr/share/locale"
42 #define NETPOPUP_EDJ tzplatform_mkpath(TZ_SYS_RO_UG, "/res/edje/net-popup/netpopup-custom.edj")
43 #define QP_PRELOAD_NOTI_ICON_PATH tzplatform_mkpath(TZ_SYS_RO_APP, "/org.tizen.quickpanel/shared/res/noti_icons/Wi-Fi")
45 #define NETCONFIG_NOTIFICATION_WIFI_ICON \
46 tzplatform_mkpath(TZ_SYS_RO_ICONS, "/noti_wifi_in_range.png")
47 #define NETCONFIG_NOTIFICATION_WIFI_ICON_LITE \
48 tzplatform_mkpath(TZ_SYS_RO_ICONS, "/noti_wifi_in_range_ongoing.png")
49 #define NETCONFIG_NOTIFICATION_WIFI_CAPTIVE_ICON \
50 tzplatform_mkpath(TZ_SYS_RO_ICONS, "/B03_notify_Wi-fi_range.png")
51 #define NETCONFIG_NOTIFICATION_WIFI_IN_RANGE_ICON \
52 tzplatform_mkpath(TZ_SYS_RO_ICONS, "/Q02_Notification_wifi_in_range.png")
53 #define NETCONFIG_NOTIFICATION_WIFI_IN_RANGE_ICON_LITE \
54 tzplatform_mkpath(TZ_SYS_RO_ICONS, "/noti_wifi_in_range.png")
55 #define NETCONFIG_NOTIFICATION_WIFI_FOUND_TITLE \
56 dgettext(PACKAGE, "IDS_COM_BODY_WI_FI_NETWORKS_AVAILABLE")
57 #define NETCONFIG_NOTIFICATION_WIFI_FOUND_CONTENT \
58 dgettext(PACKAGE, "IDS_WIFI_SBODY_TAP_HERE_TO_CONNECT")
59 #define NETCONFIG_NOTIFICATION_WIFI_PORTAL_TITLE \
60 dgettext(PACKAGE, "IDS_WIFI_HEADER_SIGN_IN_TO_WI_FI_NETWORK_ABB")
61 #define NETCONFIG_NOTIFICATION_WIFI_PORTAL_CONTENT "\"%s\""
63 #define USER_RESP_LEN 30
64 #define ICON_PATH_LEN 128
65 #define RESP_REMAIN_CONNECTED "RESP_REMAIN_CONNECTED"
66 #define RESP_WIFI_TETHERING_OFF "RESP_TETHERING_TYPE_WIFI_OFF"
67 #define RESP_WIFI_AP_TETHERING_OFF "RESP_TETHERING_TYPE_WIFI_AP_OFF"
68 #define RESP_TETHERING_ON "RESP_TETHERING_ON"
69 #define CAPTIVE_PORTAL_LOGIN "Login required to access Internet"
70 #define CAPTIVE_PORTAL_LOGIN_ERROR "Login not completed. Disconnected active Wifi"
72 static Ecore_Event_Handler *ecore_event_evas_handler;
73 static Ecore_Event_Handler *ecore_event_evas_quick_panel_handler;
76 long sizes[] = {1073741824, 1048576, 1024, 0};
77 char *units[] = {"GB", "MB", "KB", "B"};
79 static app_control_h g_req_handle = NULL;
80 static char * resp_popup_mode = NULL;
82 static GDBusConnection *conn = NULL;
83 static GDBusProxy *proxy = NULL;
85 static int __net_popup_show_notification(app_control_h request, void *data);
86 static int __toast_popup_show(app_control_h request, void *data);
87 static int __net_popup_show_popup(app_control_h request, void *data);
88 static void __net_popup_add_found_ap_noti(void);
89 static void __net_popup_del_found_ap_noti(void);
90 static void __net_popup_add_portal_noti(app_control_h request);
91 static void __net_popup_del_portal_noti(void);
92 static void __net_popup_show_popup_with_user_resp(app_control_h request, void *data);
93 static int _net_popup_send_user_resp(char *resp, Eina_Bool state);
96 GDBusProxy *__net_popup_init_dbus(void)
100 conn = g_bus_get_sync(G_BUS_TYPE_SYSTEM, NULL, &err);
106 proxy = g_dbus_proxy_new_sync(conn, G_DBUS_PROXY_FLAGS_NONE, NULL,
113 g_object_unref(conn);
120 void __net_popup_deinit_dbus(void)
123 g_object_unref(proxy);
128 g_object_unref(conn);
135 int __net_popup_send_dbus_msg(const char *resp)
137 if (conn == NULL || resp == NULL) {
141 GDBusConnection *gconn = NULL;
142 GVariant *msg = NULL;
143 char *module = "wifi";
146 gconn = g_bus_get_sync(DBUS_BUS_SYSTEM, NULL, &err);
153 msg = g_variant_new("(ss)", module, resp);
154 g_dbus_connection_emit_signal(gconn, NULL, "/Org/Tizen/Quickpanel",
155 "org.tizen.quickpanel", "ACTIVITY", msg, &err);
161 g_variant_unref(msg);
164 g_object_unref(gconn);
170 static bool __net_popup_create(void *data)
172 log_print(NET_POPUP, "__net_popup_create()\n");
174 bindtextdomain(PACKAGE, LOCALEDIR);
179 static void __net_popup_terminate(void *data)
181 if (ecore_event_evas_handler) {
182 ecore_event_handler_del(ecore_event_evas_handler);
183 ecore_event_evas_handler = NULL;
185 if (ecore_event_evas_quick_panel_handler) {
186 ecore_event_handler_del(ecore_event_evas_quick_panel_handler);
187 ecore_event_evas_quick_panel_handler = NULL;
193 static void __net_popup_pause(void *data)
195 log_print(NET_POPUP, "__net_popup_pause()");
198 static void __net_popup_resume(void *data)
203 static Eina_Bool __key_release_event_cb(void *data, int type,
206 Evas_Event_Key_Down *ev = (Evas_Event_Key_Down *) event;
209 return ECORE_CALLBACK_RENEW;
213 return ECORE_CALLBACK_RENEW;
216 log_print(NET_POPUP, "key_release : %s", ev->keyname);
217 if (g_strcmp0(ev->keyname, "XF86Phone") == 0 ||
218 g_strcmp0(ev->keyname, "XF86Stop") == 0) {
222 return ECORE_CALLBACK_DONE;
226 static Eina_Bool _ecore_event_client_message_cb(void *data, int type,
229 Ecore_X_Event_Client_Message *ev = event;
231 if (ev->message_type == ECORE_X_ATOM_E_ILLUME_QUICKPANEL_STATE) {
232 if (ev->data.l[0] == ECORE_X_ATOM_E_ILLUME_QUICKPANEL_OFF) {
233 log_print(NET_POPUP, "ECORE_X_ATOM_E_ILLUME_QUICKPANEL_OFF");
234 } else if (ev->data.l[0] == ECORE_X_ATOM_E_ILLUME_QUICKPANEL_ON) {
235 log_print(NET_POPUP, "ECORE_X_ATOM_E_ILLUME_QUICKPANEL_ON");
238 return ECORE_CALLBACK_RENEW;
242 static void __net_popup_service_cb(app_control_h request, void *data)
244 log_print(NET_POPUP, "__net_popup_service_cb()\n");
249 if (ecore_event_evas_handler == NULL) {
250 ecore_event_evas_handler = ecore_event_handler_add(ECORE_EVENT_KEY_UP,
251 __key_release_event_cb, NULL);
255 if (ecore_event_evas_quick_panel_handler == NULL) {
256 ecore_event_evas_quick_panel_handler = ecore_event_handler_add(
257 ECORE_X_EVENT_CLIENT_MESSAGE, _ecore_event_client_message_cb, NULL);
261 ret = app_control_get_extra_data(request, "_SYSPOPUP_TYPE_", &type);
263 if (APP_CONTROL_ERROR_NONE != ret) {
264 log_print(NET_POPUP, "Failed to get _SYSPOPUP_TYPE_ ret = %d", ret);
270 log_print(NET_POPUP, "type = %s\n", type);
272 if (g_str_equal(type, "notification")) {
273 __net_popup_show_notification(request, data);
275 } else if (g_str_equal(type, "toast_popup")) {
276 __toast_popup_show(request, data);
277 } else if (g_str_equal(type, "popup")) {
278 __net_popup_show_popup(request, data);
279 } else if (g_str_equal(type, "add_found_ap_noti")) {
280 __net_popup_add_found_ap_noti();
282 } else if (g_str_equal(type, "del_found_ap_noti")) {
283 __net_popup_del_found_ap_noti();
285 } else if (g_str_equal(type, "add_portal_noti")) {
286 __net_popup_add_portal_noti(request);
288 } else if (g_str_equal(type, "del_portal_noti")) {
289 __net_popup_del_portal_noti();
291 } else if (g_str_equal(type, "popup_user_resp")) {
292 app_control_clone(&g_req_handle, request);
293 __net_popup_show_popup_with_user_resp(request, data);
295 __net_popup_show_notification(request, data);
303 static void __net_popup_set_orientation(Evas_Object *win)
305 int rots[4] = { 0, 90, 180, 270 };
307 if (!elm_win_wm_rotation_supported_get(win)) {
311 elm_win_wm_rotation_available_rotations_set(win, rots, 4);
314 static Evas_Object* __net_popup_create_win(void)
316 Evas_Object *win = NULL;
318 Ecore_Evas *ee = NULL;
323 win = elm_win_add(NULL, PACKAGE, ELM_WIN_NOTIFICATION);
325 e = evas_object_evas_get(win);
326 ee = ecore_evas_ecore_evas_get(e);
327 ecore_evas_name_class_set(ee,"APP_POPUP","APP_POPUP");
329 elm_win_alpha_set(win, EINA_TRUE);
330 elm_win_borderless_set(win, EINA_TRUE);
332 ecore_x_window_size_get(ecore_x_window_root_first_get(), &w, &h);
333 evas_object_resize(win, w, h);
334 utilx_set_system_notification_level (ecore_x_display_get(),
335 elm_win_xwindow_get(win),
336 UTILX_NOTIFICATION_LEVEL_LOW);
339 __net_popup_set_orientation(win);
344 static void _ok_button_clicked_cb(void *data, Evas_Object *obj, void *event_info)
347 evas_object_del(data);
351 static void _timeout_cb(void *data, Evas_Object *obj, void *event_info)
353 evas_object_del(obj);
358 static int __toast_popup_show(app_control_h request, void *data)
360 char buf[ALERT_STR_LEN_MAX] = "";
363 Evas_Object *twin = NULL;
364 Evas_Object *tpop = NULL;
366 ret = app_control_get_extra_data(request, "_SYSPOPUP_CONTENT_", &mode);
367 if (ret != APP_CONTROL_ERROR_NONE) {
368 log_print(NET_POPUP, "Failed to get _SYSPOPUP_CONTENT_ ret = %d", ret);
374 log_print(NET_POPUP, "_SYSPOPUP_CONTENT_ = %s\n", mode);
376 twin = __net_popup_create_win();
377 tpop = elm_popup_add(twin);
378 elm_object_style_set(tpop, "toast");
379 evas_object_size_hint_weight_set(tpop, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
381 elm_popup_timeout_set(tpop, 2.0);
383 evas_object_smart_callback_add(tpop, "timeout", _timeout_cb, twin);
384 if (strcmp(mode, "wrong password") == 0) {
385 log_print(NET_POPUP, "alert wrong password\n");
387 g_snprintf(buf, ALERT_STR_LEN_MAX, ALERT_STR_ERR_WRONG_PASSWORD);
388 } else if (strcmp(mode, "no ap found") == 0) {
389 log_print(NET_POPUP, "alert no ap found\n");
391 g_snprintf(buf, ALERT_STR_LEN_MAX, ALERT_STR_NO_AP_FOUND);
392 } else if (strcmp(mode, "unable to connect") == 0) {
393 log_print(NET_POPUP, "alert no ap found\n");
395 g_snprintf(buf, ALERT_STR_LEN_MAX, ALERT_STR_ERR_CONNECT);
397 log_print(NET_POPUP, "%s\n", mode);
399 elm_object_text_set(tpop, buf);
400 evas_object_show(tpop);
401 evas_object_show(twin);
407 static int __net_popup_show_notification(app_control_h request, void *data)
411 char buf[ALERT_STR_LEN_MAX] = "";
412 char *ap_name = NULL;
414 ret = app_control_get_extra_data(request, "_SYSPOPUP_CONTENT_", &mode);
416 if (APP_CONTROL_ERROR_NONE != ret) {
417 log_print(NET_POPUP, "Failed to get _SYSPOPUP_CONTENT_");
421 secure_log_print(NET_POPUP, "_SYSPOPUP_CONTENT_ = %s\n", mode);
423 if (strcmp(mode, "connected") == 0) {
424 notification_status_message_post(ALERT_STR_MOBILE_NETWORKS_CHARGE);
425 log_print(NET_POPUP, "alert 3g\n");
426 } else if (strcmp(mode, "fail to connect") == 0) {
427 notification_status_message_post(ALERT_STR_ERR_UNAVAILABLE);
428 log_print(NET_POPUP, "alert err\n");
429 } else if (strcmp(mode, "unable to connect") == 0) {
430 notification_status_message_post(ALERT_STR_ERR_CONNECT);
431 log_print(NET_POPUP, "alert unable to connect\n");
432 } else if (strcmp(mode, "wrong password") == 0) {
433 notification_status_message_post(ALERT_STR_ERR_WRONG_PASSWORD);
434 log_print(NET_POPUP, "alert wrong password\n");
435 } else if (strcmp(mode, "not support") == 0) {
436 notification_status_message_post(ALERT_STR_ERR_NOT_SUPPORT);
437 log_print(NET_POPUP, "alert not support\n");
438 } else if (strcmp(mode, "wifi restricted") == 0) {
439 notification_status_message_post(ALERT_STR_RESTRICTED_USE_WIFI);
440 log_print(NET_POPUP, "alert wifi restricted\n");
441 } else if (strcmp(mode, "no ap found") == 0) {
442 notification_status_message_post(ALERT_STR_NO_AP_FOUND);
443 log_print(NET_POPUP, "alert no ap found\n");
444 } else if (strcmp(mode, "Lengthy Password") == 0) {
445 notification_status_message_post(ALERT_STR_LENGHTY_PASSWORD);
446 log_print(NET_POPUP, "Password entered crosses 64 bytes\n");
447 } else if (strcmp(mode, "Portal Login") == 0) {
448 notification_status_message_post(CAPTIVE_PORTAL_LOGIN);
449 log_print(NET_POPUP, "Please login to access Internet\n");
450 } else if (strcmp(mode, "Portal Login Error") == 0) {
451 notification_status_message_post(CAPTIVE_PORTAL_LOGIN_ERROR);
452 log_print(NET_POPUP, "Login not completed. Disconnected Wifi\n");
453 } else if (strcmp(mode, "wifi connected") == 0) {
454 ret = app_control_get_extra_data(request, "_AP_NAME_", &ap_name);
456 if (APP_CONTROL_ERROR_NONE != ret) {
457 log_print(NET_POPUP, "Failed to get _AP_NAME_ ret = %d", ret);
463 g_snprintf(buf, ALERT_STR_LEN_MAX, ALERT_STR_WIFI_CONNECTED, ap_name);
465 g_snprintf(buf, ALERT_STR_LEN_MAX, ALERT_STR_WIFI_CONNECTED, "");
467 notification_status_message_post(buf);
469 log_print(NET_POPUP, "alert wifi connected\n");
472 notification_status_message_post(mode);
473 log_print(NET_POPUP, "%s\n", mode);
480 static int _net_popup_send_user_resp(char *resp, Eina_Bool state)
483 app_control_h reply = NULL;
484 char checkbox_str[USER_RESP_LEN] = { '\0', };
486 log_print(NET_POPUP, "Send the user response to the caller");
487 ret = app_control_create(&reply);
488 if (APP_CONTROL_ERROR_NONE != ret) {
489 log_print(NET_POPUP, "Failed to create service ret = %d", ret);
490 app_control_destroy(g_req_handle);
497 g_strlcpy(checkbox_str, "TRUE", USER_RESP_LEN);
499 g_strlcpy(checkbox_str, "FALSE", USER_RESP_LEN);
501 log_print(NET_POPUP, "Checkbox_str[%s]", checkbox_str);
503 ret = app_control_add_extra_data(reply, "_SYSPOPUP_RESP_", resp);
504 if (APP_CONTROL_ERROR_NONE == ret) {
505 ret = app_control_add_extra_data(reply, "_SYSPOPUP_CHECKBOX_RESP_",
507 if (APP_CONTROL_ERROR_NONE == ret) {
508 ret = app_control_reply_to_launch_request(reply, g_req_handle,
509 APP_CONTROL_RESULT_SUCCEEDED);
510 if (APP_CONTROL_ERROR_NONE == ret) {
511 log_print(NET_POPUP, "Service reply success");
514 log_print(NET_POPUP, "Service reply failed ret = %d", ret);
517 log_print(NET_POPUP, "Service data addition failed ret = %d", ret);
520 log_print(NET_POPUP, "Service data addition failed ret = %d", ret);
523 app_control_destroy(reply);
524 app_control_destroy(g_req_handle);
530 void _tethering_wifi_btn_yes_cb(void *data, Evas_Object *obj, void *event_info)
532 log_print(NET_POPUP, "_tethering_wifi_btn_yes_cb");
535 Evas_Object *popup = (Evas_Object *)data;
537 __net_popup_init_dbus();
538 __net_popup_send_dbus_msg("progress_off");
539 __net_popup_deinit_dbus();
541 result = _net_popup_send_user_resp(RESP_WIFI_TETHERING_OFF, FALSE);
543 log_print(NET_POPUP, "Failed to send user response ");
546 evas_object_del(popup);
551 void _tethering_wifi_ap_btn_yes_cb(void *data, Evas_Object *obj, void *event_info)
553 log_print(NET_POPUP, "_tethering_wifi_ap_btn_yes_cb");
556 Evas_Object *popup = (Evas_Object *)data;
558 __net_popup_init_dbus();
559 __net_popup_send_dbus_msg("progress_off");
560 __net_popup_deinit_dbus();
562 result = _net_popup_send_user_resp(RESP_WIFI_AP_TETHERING_OFF, FALSE);
564 log_print(NET_POPUP, "Failed to send user response ");
567 evas_object_del(popup);
572 void _btn_no_cb(void *data, Evas_Object *obj, void *event_info)
574 log_print(NET_POPUP, "_btn_no_cb");
577 Evas_Object *popup = (Evas_Object *)data;
579 result = _net_popup_send_user_resp(RESP_TETHERING_ON, FALSE);
581 log_print(NET_POPUP, "Failed to send user response ");
584 evas_object_del(popup);
589 static void __net_popup_show_popup_with_user_resp(app_control_h request,
600 ret = app_control_get_extra_data(request, "_SYSPOPUP_CONTENT_", &resp_popup_mode);
601 if (APP_CONTROL_ERROR_NONE != ret)
602 log_print(NET_POPUP, "Failed to get _SYSPOPUP_CONTENT_ ret = %d", ret);
604 secure_log_print(NET_POPUP, "_SYSPOPUP_CONTENT_ = %s\n", resp_popup_mode);
606 win = __net_popup_create_win();
607 evas_object_show(win);
609 popup = elm_popup_add(win);
610 evas_object_size_hint_weight_set(popup, EVAS_HINT_EXPAND,
613 if (g_strcmp0(resp_popup_mode, "TETHERING_TYPE_WIFI") == 0 ||
614 g_strcmp0(resp_popup_mode, "TETHERING_TYPE_WIFI_AP") == 0) {
615 log_print(NET_POPUP, "Drawing Wi-Fi Tethering OFF popup");
617 __net_popup_init_dbus();
618 elm_object_part_text_set(popup, "title,text", ALERT_STR_WIFI);
620 layout = elm_layout_add(popup);
621 elm_layout_file_set(layout, NETPOPUP_EDJ, "popup");
622 evas_object_size_hint_weight_set(layout, EVAS_HINT_EXPAND,
625 __net_popup_send_dbus_msg("progress_on");
626 label = elm_label_add(popup);
627 elm_label_line_wrap_set(label, ELM_WRAP_MIXED);
628 elm_object_text_set(label, ALERT_STR_WIFI_MOBILE_AP_ON);
629 evas_object_size_hint_weight_set(label, EVAS_HINT_EXPAND,
631 evas_object_size_hint_align_set(label, EVAS_HINT_FILL, EVAS_HINT_FILL);
632 evas_object_show(label);
634 elm_object_part_content_set(layout, "elm.swallow.content", label);
635 evas_object_show(layout);
636 elm_object_style_set(label, "popup/default");
637 eext_object_event_callback_add(popup, EEXT_CALLBACK_BACK, _btn_no_cb, popup);
638 elm_object_content_set(popup, label);
640 btn1 = elm_button_add(popup);
641 elm_object_style_set(btn1, "popup");
642 elm_object_text_set(btn1, ALERT_STR_CANCEL);
643 elm_object_part_content_set(popup, "button1", btn1);
644 evas_object_smart_callback_add(btn1, "clicked",
647 btn2 = elm_button_add(popup);
648 elm_object_style_set(btn2, "popup");
649 elm_object_text_set(btn2, ALERT_STR_OK);
650 elm_object_part_content_set(popup, "button2", btn2);
652 if (g_strcmp0(resp_popup_mode, "TETHERING_TYPE_WIFI") == 0)
653 evas_object_smart_callback_add(btn2, "clicked",
654 _tethering_wifi_btn_yes_cb, popup);
655 else if (g_strcmp0(resp_popup_mode, "TETHERING_TYPE_WIFI_AP") == 0)
656 evas_object_smart_callback_add(btn2, "clicked",
657 _tethering_wifi_ap_btn_yes_cb, popup);
659 evas_object_show(popup);
660 evas_object_show(win);
661 __net_popup_deinit_dbus();
665 static int __net_popup_show_popup(app_control_h request, void *data)
673 ret = app_control_get_extra_data(request, "_SYSPOPUP_CONTENT_", &mode);
674 if (APP_CONTROL_ERROR_NONE != ret) {
675 log_print(NET_POPUP, "Failed to get _SYSPOPUP_CONTENT_ ret = %d", ret);
681 secure_log_print(NET_POPUP, "_SYSPOPUP_CONTENT_ = %s\n", mode);
683 win = __net_popup_create_win();
685 popup = elm_popup_add(win);
686 evas_object_size_hint_weight_set(popup, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
687 if (strcmp(mode, "connected") == 0) {
688 elm_object_text_set(popup, ALERT_STR_MOBILE_NETWORKS_CHARGE);
689 log_print(NET_POPUP, "alert 3g\n");
690 } else if (strcmp(mode, "fail to connect") == 0) {
691 elm_object_text_set(popup, ALERT_STR_ERR_UNAVAILABLE);
692 log_print(NET_POPUP, "alert err\n");
693 } else if (strcmp(mode, "unable to connect") == 0) {
694 elm_object_text_set(popup, ALERT_STR_ERR_CONNECT);
695 log_print(NET_POPUP, "alert unable to connect\n");
696 } else if (strcmp(mode, "wrong password") == 0) {
697 elm_object_text_set(popup, ALERT_STR_ERR_WRONG_PASSWORD);
698 log_print(NET_POPUP, "alert wrong password\n");
699 } else if (strcmp(mode, "not support") == 0) {
700 elm_object_text_set(popup, ALERT_STR_ERR_NOT_SUPPORT);
701 log_print(NET_POPUP, "alert not support\n");
702 } else if (strcmp(mode, "wifi restricted") == 0) {
703 elm_object_text_set(popup, ALERT_STR_RESTRICTED_USE_WIFI);
704 log_print(NET_POPUP, "alert wifi restricted\n");
705 } else if (strcmp(mode, "no ap found") == 0) {
706 elm_object_text_set(popup, ALERT_STR_NO_AP_FOUND);
707 log_print(NET_POPUP, "alert no ap found\n");
708 } else if (strcmp(mode, "wifi connected") == 0) {
709 char buf[ALERT_STR_LEN_MAX] = "";
710 char *ap_name = NULL;
712 ret = app_control_get_extra_data(request, "_AP_NAME_", &ap_name);
715 g_snprintf(buf, ALERT_STR_LEN_MAX, ALERT_STR_WIFI_CONNECTED, ap_name);
717 g_snprintf(buf, ALERT_STR_LEN_MAX, ALERT_STR_WIFI_CONNECTED, "");
719 elm_object_text_set(popup, buf);
721 log_print(NET_POPUP, "alert wifi connected\n");
724 elm_object_text_set(popup, mode);
725 log_print(NET_POPUP, "%s\n", mode);
728 button = elm_button_add(popup);
729 elm_object_style_set(button, "popup");
730 elm_object_text_set(button, ALERT_STR_OK);
731 elm_object_part_content_set(popup, "button1", button);
732 evas_object_smart_callback_add(button, "clicked", _ok_button_clicked_cb, popup);
733 evas_object_show(popup);
734 evas_object_show(win);
740 static void __net_popup_add_found_ap_noti(void)
742 int ret = 0, noti_flags = 0;
743 char icon_path[ICON_PATH_LEN];
744 notification_h noti = NULL;
745 notification_list_h noti_list = NULL;
746 notification_error_e noti_err = NOTIFICATION_ERROR_NONE;
747 app_control_h service_handle = NULL;
749 notification_get_detail_list("net.netpopup", NOTIFICATION_GROUP_ID_NONE,
750 NOTIFICATION_PRIV_ID_NONE, -1, ¬i_list);
751 if (noti_list != NULL) {
752 notification_free_list(noti_list);
756 noti = notification_create(NOTIFICATION_TYPE_ONGOING);
758 log_print(NET_POPUP, "Failed to create notification");
762 noti_err = notification_set_time(noti, time(NULL));
763 if(noti_err != NOTIFICATION_ERROR_NONE) {
764 log_print(NET_POPUP, "Failed to notification_set_time : %d", noti_err);
768 g_snprintf(icon_path, sizeof(icon_path), "%s%s", QP_PRELOAD_NOTI_ICON_PATH, "/noti_wifi_in_range.png");
769 noti_err = notification_set_image(noti, NOTIFICATION_IMAGE_TYPE_ICON, icon_path);
770 if(noti_err != NOTIFICATION_ERROR_NONE) {
771 log_print(NET_POPUP, "Failed to notification_set_image : %d", noti_err);
775 noti_err = notification_set_layout(noti, NOTIFICATION_LY_ONGOING_EVENT);
776 if (noti_err != NOTIFICATION_ERROR_NONE) {
777 log_print(NET_POPUP, "Failed to notification_set_layout : %d", noti_err);
781 noti_err = notification_set_text_domain(noti, PACKAGE,
783 if(noti_err != NOTIFICATION_ERROR_NONE) {
784 log_print(NET_POPUP, "Failed to notification_set_text_domain : %d", noti_err);
788 noti_err = notification_set_text(noti, NOTIFICATION_TEXT_TYPE_TITLE,
789 NETCONFIG_NOTIFICATION_WIFI_FOUND_TITLE,
790 "IDS_COM_BODY_WI_FI_NETWORKS_AVAILABLE",
791 NOTIFICATION_VARIABLE_TYPE_NONE);
792 if (noti_err != NOTIFICATION_ERROR_NONE) {
793 log_print(NET_POPUP, "Failed to notification_set_title : %d", noti_err);
797 noti_err = notification_set_text(noti, NOTIFICATION_TEXT_TYPE_CONTENT,
798 NETCONFIG_NOTIFICATION_WIFI_FOUND_CONTENT,
799 "IDS_WIFI_SBODY_TAP_HERE_TO_CONNECT",
800 NOTIFICATION_VARIABLE_TYPE_NONE);
801 if (noti_err != NOTIFICATION_ERROR_NONE) {
802 log_print(NET_POPUP, "Failed to notification_set_content: %d", noti_err);
806 noti_flags = NOTIFICATION_DISPLAY_APP_NOTIFICATION_TRAY | NOTIFICATION_DISPLAY_APP_INDICATOR;
807 noti_err = notification_set_display_applist(noti, noti_flags);
808 if(noti_err != NOTIFICATION_ERROR_NONE) {
809 log_print(NET_POPUP, "Failed to notification_set_display_applist: %d", noti_err);
813 ret = app_control_create(&service_handle);
814 log_print(NET_POPUP, "service create ret[%d]", ret);
815 if(ret != APP_CONTROL_ERROR_NONE)
818 ret = app_control_add_extra_data(service_handle, "caller", "notification");
819 log_print(NET_POPUP, "Service data addition ret = %d", ret);
820 if(ret != APP_CONTROL_ERROR_NONE)
823 noti_err = notification_set_launch_option(noti,
824 NOTIFICATION_LAUNCH_OPTION_APP_CONTROL, service_handle);
825 if (noti_err != NOTIFICATION_ERROR_NONE) {
826 log_print(NET_POPUP, "Failed to notification_set_launch_option");
830 noti_err = notification_post(noti);
831 if (noti_err != NOTIFICATION_ERROR_NONE) {
832 log_print(NET_POPUP, "Failed to insert notification");
836 log_print(NET_POPUP, "Successfully added notification");
841 notification_free(noti);
844 static void __net_popup_del_found_ap_noti(void)
846 notification_error_e noti_err = NOTIFICATION_ERROR_NONE;
848 noti_err = notification_delete_all(NOTIFICATION_TYPE_ONGOING);
849 if (noti_err != NOTIFICATION_ERROR_NONE) {
850 log_print(NET_POPUP, "fail to notification_delete_by_priv_id");
854 log_print(NET_POPUP, "Successfully deleted notification");
857 static void __net_popup_add_portal_noti(app_control_h request)
861 char *ap_name = NULL;
862 char icon_path[ICON_PATH_LEN];
863 notification_h noti = NULL;
864 app_control_h service_handle = NULL;
865 notification_list_h noti_list = NULL;
866 notification_error_e noti_err = NOTIFICATION_ERROR_NONE;
868 ret = app_control_get_extra_data(request, "_AP_NAME_", &ap_name);
870 if (ap_name == NULL || ret != APP_CONTROL_ERROR_NONE) {
871 log_print(NET_POPUP, "Failed to retrieve connected AP name!!");
876 log_print(NET_POPUP, "Successfully added notification");
878 notification_get_detail_list("net.netpopup", NOTIFICATION_GROUP_ID_NONE,
879 NOTIFICATION_PRIV_ID_NONE, -1, ¬i_list);
880 if (noti_list != NULL) {
881 notification_free_list(noti_list);
886 noti = notification_create(NOTIFICATION_TYPE_NOTI);
888 log_print(NET_POPUP, "fail to create notification");
893 noti_err = notification_set_time(noti, time(NULL));
894 if(noti_err != NOTIFICATION_ERROR_NONE) {
895 log_print(NET_POPUP, "fail to notification_set_time : %d", noti_err);
899 noti_err = notification_set_image(noti, NOTIFICATION_IMAGE_TYPE_ICON,
900 NETCONFIG_NOTIFICATION_WIFI_ICON);
901 if(noti_err != NOTIFICATION_ERROR_NONE) {
902 log_print(NET_POPUP, "fail to notification_set_image : %d", noti_err);
906 g_snprintf(icon_path, sizeof(icon_path), "%s%s", QP_PRELOAD_NOTI_ICON_PATH, "/noti_wifi_in_range.png");
907 noti_err = notification_set_image(noti, NOTIFICATION_IMAGE_TYPE_ICON, icon_path);
908 if(noti_err != NOTIFICATION_ERROR_NONE) {
909 log_print(NET_POPUP, "fail to notification_set_image : %d", noti_err);
912 noti_err = notification_set_layout(noti, NOTIFICATION_LY_NOTI_EVENT_MULTIPLE);
913 if (noti_err != NOTIFICATION_ERROR_NONE) {
914 log_print(NET_POPUP, "fail to notification_set_layout : %d", noti_err);
918 noti_err = notification_set_text_domain(noti, PACKAGE,
920 if(noti_err != NOTIFICATION_ERROR_NONE) {
921 log_print(NET_POPUP, "fail to notification_set_text_domain : %d", noti_err);
925 noti_err = notification_set_text(noti, NOTIFICATION_TEXT_TYPE_TITLE,
926 NETCONFIG_NOTIFICATION_WIFI_PORTAL_TITLE,
927 "IDS_WIFI_HEADER_SIGN_IN_TO_WI_FI_NETWORK_ABB",
928 NOTIFICATION_VARIABLE_TYPE_NONE);
929 if (noti_err != NOTIFICATION_ERROR_NONE) {
930 log_print(NET_POPUP, "fail to notification_set_title : %d", noti_err);
934 noti_err = notification_set_text(noti, NOTIFICATION_TEXT_TYPE_CONTENT,
935 NETCONFIG_NOTIFICATION_WIFI_PORTAL_CONTENT,
936 NETCONFIG_NOTIFICATION_WIFI_PORTAL_CONTENT,
937 NOTIFICATION_VARIABLE_TYPE_STRING, ap_name,
938 NOTIFICATION_VARIABLE_TYPE_NONE);
939 if (noti_err != NOTIFICATION_ERROR_NONE) {
940 log_print(NET_POPUP, "fail to notification_set_content : %d", noti_err);
944 noti_flags = NOTIFICATION_DISPLAY_APP_NOTIFICATION_TRAY | NOTIFICATION_DISPLAY_APP_INDICATOR;
945 noti_err = notification_set_display_applist(noti, noti_flags);
946 if(noti_err != NOTIFICATION_ERROR_NONE) {
947 log_print(NET_POPUP, "fail to notification_set_display_applist : %d", noti_err);
951 ret = app_control_create(&service_handle);
952 log_print(NET_POPUP, "service create ret[%d]", ret);
953 if(ret != APP_CONTROL_ERROR_NONE)
956 ret = app_control_set_operation(service_handle, APP_CONTROL_OPERATION_VIEW);
957 if(ret != APP_CONTROL_ERROR_NONE)
960 log_print(NET_POPUP, "service set operation is successful");
962 ret = app_control_set_uri(service_handle, "http://www.google.com");
964 if(ret != APP_CONTROL_ERROR_NONE)
967 noti_err = notification_set_launch_option(noti,
968 NOTIFICATION_LAUNCH_OPTION_APP_CONTROL, service_handle);
969 if (noti_err != NOTIFICATION_ERROR_NONE) {
970 log_print(NET_POPUP, "fail to notification_set_launch_option");
974 noti_err = notification_post(noti);
975 if (noti_err != NOTIFICATION_ERROR_NONE) {
976 log_print(NET_POPUP, "fail to notification_post");
980 log_print(NET_POPUP, "Successfully added notification");
985 notification_free(noti);
987 if (service_handle != NULL)
988 app_control_destroy(service_handle);
991 static void __net_popup_del_portal_noti(void)
993 notification_error_e noti_err = NOTIFICATION_ERROR_NONE;
995 noti_err = notification_delete_all(NOTIFICATION_TYPE_NOTI);
996 if (noti_err != NOTIFICATION_ERROR_NONE) {
997 log_print(NET_POPUP, "fail to notification_delete_all");
1001 log_print(NET_POPUP, "Successfully deleted notification");
1004 EXPORT_API int main(int argc, char *argv[])
1006 ui_app_lifecycle_callback_s app_callback = {
1007 .create = __net_popup_create,
1008 .terminate = __net_popup_terminate,
1009 .pause = __net_popup_pause,
1010 .resume = __net_popup_resume,
1011 .app_control = __net_popup_service_cb,
1014 return ui_app_main(argc, argv, &app_callback, NULL);