summaryrefslogtreecommitdiff
path: root/popup-wifidirect/src
diff options
context:
space:
mode:
authorjk7744.park <jk7744.park@samsung.com>2015-02-01 13:06:20 +0900
committerjk7744.park <jk7744.park@samsung.com>2015-02-01 13:06:20 +0900
commit8a886ccac3b73a153c98d17268bcb0ae2fe1f9b3 (patch)
treeb02f6951a6b653c42ac28c0403449b1ce3de0b59 /popup-wifidirect/src
parenta402629db83b7934e670d43973f81682fd168413 (diff)
downloadug-wifi-direct-tizen_2.3.tar.gz
ug-wifi-direct-tizen_2.3.tar.bz2
ug-wifi-direct-tizen_2.3.zip
Diffstat (limited to 'popup-wifidirect/src')
-rw-r--r--[-rwxr-xr-x]popup-wifidirect/src/wfd-app-client.c986
-rw-r--r--[-rwxr-xr-x]popup-wifidirect/src/wfd-app-main.c295
-rwxr-xr-xpopup-wifidirect/src/wfd-app-popup-view.c1263
-rw-r--r--popup-wifidirect/src/wfd-app-util.c911
4 files changed, 2484 insertions, 971 deletions
diff --git a/popup-wifidirect/src/wfd-app-client.c b/popup-wifidirect/src/wfd-app-client.c
index b4b6f74..f867fbd 100755..100644
--- a/popup-wifidirect/src/wfd-app-client.c
+++ b/popup-wifidirect/src/wfd-app-client.c
@@ -1,13 +1,13 @@
/*
* WiFi-Direct UG
*
-* Copyright 2012 Samsung Electronics Co., Ltd
+* Copyright 2012 Samsung Electronics Co., Ltd
-* Licensed under the Flora License, Version 1.1 (the "License");
+* Licensed under the Flora License, Version 1.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
-* http://floralicense.org/license
+* http://www.tizenopensource.org/license
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
@@ -24,17 +24,25 @@
* @author Sungsik Jang (sungsik.jang@samsung.com)
* @version 0.1
*/
-
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
-#include <notification.h>
+#include <Elementary.h>
+#include <app_control.h>
#include <vconf.h>
+#include <notification.h>
+#ifdef WFD_HOSTAPD_ENABLER
+#include <tethering.h>
+#include <network-cm-intf.h>
+#include <network-wifi-intf.h>
+#endif
+#include <dd-display.h>
#include "wfd-app.h"
#include "wfd-app-util.h"
#include "wfd-app-strings.h"
+#include "wfd-app-popup-view.h"
/**
* This function let the app make a callback for connected peer
@@ -44,29 +52,26 @@
*/
bool _wfd_connected_peer_cb(wifi_direct_connected_peer_info_s *peer, void *user_data)
{
- __WDPOP_LOG_FUNC_ENTER__;
+ __WFD_APP_FUNC_ENTER__;
wfd_appdata_t *ad = (wfd_appdata_t *) user_data;
+
if (NULL == ad || NULL == peer || NULL == peer->device_name || NULL == peer->mac_address) {
- WDPOP_LOGD( "NULL parameters.\n");
+ WFD_APP_LOG(WFD_APP_LOG_ERROR, "NULL parameters.\n");
return FALSE;
}
int peer_cnt = ad->raw_connected_peer_cnt;
- WDPOP_LOGD( "%dth connected peer. [%s]\n", peer_cnt, peer->device_name);
+ strncpy(ad->raw_connected_peers[peer_cnt].ssid, peer->device_name, sizeof(ad->raw_connected_peers[peer_cnt].ssid) - 1);
+ strncpy(ad->raw_connected_peers[peer_cnt].mac_address, peer->mac_address, WFD_MAC_ADDRESS_SIZE - 1);
- strncpy(ad->raw_connected_peers[peer_cnt].ssid, peer->device_name, sizeof(ad->raw_connected_peers[peer_cnt].ssid));
- ad->raw_connected_peers[peer_cnt].ssid[31] = '\0';
- strncpy(ad->raw_connected_peers[peer_cnt].mac_address, peer->mac_address, WFD_MAC_ADDRESS_SIZE);
- ad->raw_connected_peers[peer_cnt].mac_address[17] = '\0';
- WDPOP_LOGD( "\tSSID: [%s]\n", ad->raw_connected_peers[peer_cnt].ssid);
ad->raw_connected_peer_cnt++;
free(peer->device_name);
free(peer->mac_address);
free(peer);
- __WDPOP_LOG_FUNC_EXIT__;
+ __WFD_APP_FUNC_EXIT__;
return TRUE;
}
@@ -75,13 +80,13 @@ bool _wfd_connected_peer_cb(wifi_direct_connected_peer_info_s *peer, void *user_
* @return If success, return 0, else return -1
* @param[in] ugd the pointer to the main data structure
*/
-int _wfd_app_get_connected_peers(void *user_data)
+int wfd_app_get_connected_peers(void *user_data)
{
- __WDPOP_LOG_FUNC_ENTER__;
+ __WFD_APP_FUNC_ENTER__;
wfd_appdata_t *ad = (wfd_appdata_t *) user_data;
if (NULL == ad) {
- WDPOP_LOGD( "NULL parameters.\n");
+ WFD_APP_LOG(WFD_APP_LOG_ERROR, "NULL parameters.\n");
return -1;
}
@@ -91,165 +96,28 @@ int _wfd_app_get_connected_peers(void *user_data)
res = wifi_direct_foreach_connected_peers(_wfd_connected_peer_cb, (void *)ad);
if (res != WIFI_DIRECT_ERROR_NONE) {
ad->raw_connected_peer_cnt = 0;
- WDPOP_LOGD( "Get connected peer failed: %d\n", res);
+ WFD_APP_LOG(WFD_APP_LOG_ERROR, "Get connected peer failed: %d\n", res);
}
- __WDPOP_LOG_FUNC_EXIT__;
+ __WFD_APP_FUNC_EXIT__;
return 0;
}
/**
- * This function let the app delete the notification
- * @return void
- */
-void _del_wfd_notification()
-{
- __WDPOP_LOG_FUNC_ENTER__;
-
- /* delete the notification */
- notification_error_e noti_err = NOTIFICATION_ERROR_NONE;
- noti_err = notification_delete_all_by_type(NULL, NOTIFICATION_TYPE_NOTI);
- if (noti_err != NOTIFICATION_ERROR_NONE) {
- WDPOP_LOGD( "Fail to notification_delete_all_by_type.(%d)\n", noti_err);
- return;
- }
-
- __WDPOP_LOG_FUNC_EXIT__;
-}
-
-/**
- * This function let the app add the notification when it is connected
- * @return void
- * @param[in] user_data the pointer to the main data structure
- */
-void _add_wfd_peers_connected_notification(void *user_data)
-{
- __WDPOP_LOG_FUNC_ENTER__;
-
- wfd_appdata_t *ad = (wfd_appdata_t *) user_data;
- if (NULL == ad || NULL == ad->noti) {
- WDPOP_LOGD( "NULL parameters.\n");
- return;
- }
-
- char msg[WFD_MAX_SIZE] = {0};
- notification_error_e noti_err = NOTIFICATION_ERROR_NONE;
-
- /* delete all notifications */
- _del_wfd_notification();
-
- /* set the icon */
- noti_err = notification_set_image(ad->noti, NOTIFICATION_IMAGE_TYPE_ICON, RESDIR"/images/A09_notification_icon.png");
- if (noti_err != NOTIFICATION_ERROR_NONE) {
- WDPOP_LOGD( "Fail to notification_set_image. (%d)\n", noti_err);
- return;
- }
-
- /* set the title and content */
- _wfd_app_get_connected_peers(ad);
- snprintf(msg, WFD_MAX_SIZE, "Connected with %d devices via Wi-Fi Direct", ad->raw_connected_peer_cnt);
- noti_err = notification_set_text(ad->noti, NOTIFICATION_TEXT_TYPE_TITLE, msg, NULL, NOTIFICATION_VARIABLE_TYPE_NONE);
- if (noti_err != NOTIFICATION_ERROR_NONE) {
- WDPOP_LOGD( "Fail to notification_set_text. (%d)\n", noti_err);
- return;
- }
-
- /* notify the quick panel */
- noti_err = notification_insert(ad->noti, NULL);
- if (noti_err != NOTIFICATION_ERROR_NONE) {
- WDPOP_LOGD( "Fail to notification_insert.(%d)\n", noti_err);
- return;
- }
-
- __WDPOP_LOG_FUNC_EXIT__;
-}
-
-/**
- * This function let the app add the notification when it shoule be turned off
- * @return void
- * @param[in] user_data the pointer to the main data structure
- */
-void _add_wfd_turn_off_notification(void *user_data)
-{
- __WDPOP_LOG_FUNC_ENTER__;
-
- wfd_appdata_t *ad = (wfd_appdata_t *) user_data;
- if (NULL == ad || NULL == ad->noti) {
- WDPOP_LOGD( "NULL parameters.\n");
- return;
- }
-
- notification_error_e noti_err = NOTIFICATION_ERROR_NONE;
-
- /* delete all notifications */
- _del_wfd_notification();
-
- /* set the icon */
- noti_err = notification_set_image(ad->noti, NOTIFICATION_IMAGE_TYPE_ICON, RESDIR"/images/A09_notification_icon.png");
- if (noti_err != NOTIFICATION_ERROR_NONE) {
- WDPOP_LOGD( "Fail to notification_set_image. (%d)\n", noti_err);
- return;
- }
-
- /* set the title and content */
- noti_err = notification_set_text(ad->noti, NOTIFICATION_TEXT_TYPE_TITLE,
- "Disable Wi-Fi Direct after use", NULL, NOTIFICATION_VARIABLE_TYPE_NONE);
- if (noti_err != NOTIFICATION_ERROR_NONE) {
- WDPOP_LOGD( "Fail to notification_set_text. (%d)\n", noti_err);
- return;
- }
-
- noti_err = notification_set_text(ad->noti, NOTIFICATION_TEXT_TYPE_CONTENT,
- "Disable Wi-Fi Direct after use to save battery", NULL, NOTIFICATION_VARIABLE_TYPE_NONE);
- if (noti_err != NOTIFICATION_ERROR_NONE) {
- WDPOP_LOGD( "Fail to notification_set_text. (%d)\n", noti_err);
- return;
- }
-
- bundle *b = NULL;
- b = bundle_create();
- appsvc_set_pkgname(b, PACKAGE);
- appsvc_add_data(b, NOTIFICATION_BUNDLE_PARAM, NOTIFICATION_BUNDLE_VALUE);
-
- int res = NOTIFICATION_ERROR_NONE;
- res = notification_set_execute_option(ad->noti, NOTIFICATION_EXECUTE_TYPE_SINGLE_LAUNCH, /*Button Text*/NULL, NULL, b);
- if (res != NOTIFICATION_ERROR_NONE) {
- WDPOP_LOGD( "Failed to notification_set_execute_option. [%d]", res);
- bundle_free(b);
- return;
- }
- bundle_free(b);
-
- /* set display application list */
- noti_err = notification_set_display_applist(ad->noti, NOTIFICATION_DISPLAY_APP_NOTIFICATION_TRAY);
- if (noti_err != NOTIFICATION_ERROR_NONE) {
- WDPOP_LOGD( "Fail to notification_set_display_applist : %d\n", noti_err);
- return;
- }
-
- /* notify the quick panel */
- noti_err = notification_insert(ad->noti, NULL);
- if (noti_err != NOTIFICATION_ERROR_NONE) {
- WDPOP_LOGD( "Fail to notification_insert.(%d)\n", noti_err);
- return;
- }
-
- __WDPOP_LOG_FUNC_EXIT__;
-}
-
-/**
* This function let the app make a callback for deactivating wfd automatically when connected
* @return if stop the timer, return ECORE_CALLBACK_CANCEL, else return ECORE_CALLBACK_RENEW
* @param[in] user_data the pointer to the main data structure
*/
-static Eina_Bool _wfd_automatic_deactivated_for_connection_cb(void *user_data)
+Eina_Bool wfd_automatic_deactivated_for_connection_cb(void *user_data)
{
+ __WFD_APP_FUNC_ENTER__;
int interval = 0;
int wfd_transfer_state = 0;
+ int res = 0;
wfd_appdata_t *ad = (wfd_appdata_t *)user_data;
if (NULL == ad) {
- WDPOP_LOGD( "NULL parameters.\n");
+ WFD_APP_LOG(WFD_APP_LOG_ERROR, "NULL parameters.\n");
return ECORE_CALLBACK_CANCEL;
}
@@ -261,176 +129,195 @@ static Eina_Bool _wfd_automatic_deactivated_for_connection_cb(void *user_data)
/* get transfer state */
if (vconf_get_int(VCONFKEY_WIFI_DIRECT_TRANSFER_STATE, &wfd_transfer_state) < 0) {
- WDPOP_LOGD( "Error reading vconf (%s)\n",
+ WFD_APP_LOG(WFD_APP_LOG_ERROR, "Error reading vconf (%s)\n",
VCONFKEY_WIFI_DIRECT_TRANSFER_STATE);
return ECORE_CALLBACK_CANCEL;
}
+ res = wifi_direct_get_state(&ad->wfd_status);
+ if (res != WIFI_DIRECT_ERROR_NONE) {
+ return ECORE_CALLBACK_CANCEL;
+ }
+
+ if (ad->wfd_status < WIFI_DIRECT_STATE_CONNECTED) {
+ WFD_APP_LOG(WFD_APP_LOG_ERROR, "Wi-Fi Direct is unconnected!");
+ return ECORE_CALLBACK_CANCEL;
+ }
+
/* show tickernoti*/
if (wfd_transfer_state > VCONFKEY_WIFI_DIRECT_TRANSFER_START) {
- WDPOP_LOGD( "No RX/TX packet, turn off WFD automatically.\n");
- _add_wfd_turn_off_notification(ad);
+ WFD_APP_LOG(WFD_APP_LOG_LOW, "Display Toast popup.\n");
+ notification_status_message_post(_("IDS_WIFI_BODY_TO_SAVE_BATTERY_POWER_DISABLE_WI_FI_DIRECT_AFTER_USE"));
+ WFD_APP_LOG(WFD_APP_LOG_LOW, "No RX/TX packet, turn off WFD automatically.\n");
+ wfd_app_util_add_wfd_turn_off_notification(ad);
} else {
- WDPOP_LOGD( "Has RX/TX packet, restart.\n");
+ WFD_APP_LOG(WFD_APP_LOG_LOW, "Has RX/TX packet, restart.\n");
ad->last_wfd_transmit_time = time(NULL);
return ECORE_CALLBACK_RENEW;
}
+ ad->transmit_timer = NULL;
+ __WFD_APP_FUNC_EXIT__;
return ECORE_CALLBACK_CANCEL;
}
-/**
- * This function let the app make a callback for registering activation event
- * @return void
- * @param[in] error_code the returned error code
- * @param[in] device_state the state of device
- * @param[in] user_data the pointer to the main data structure
- */
-void _cb_activation(int error_code, wifi_direct_device_state_e device_state, void *user_data)
+int wfd_app_client_switch_off(void *data)
{
- __WDPOP_LOG_FUNC_ENTER__;
- wfd_appdata_t *ad = (wfd_appdata_t *)user_data;
-
- switch (device_state) {
- case WIFI_DIRECT_DEVICE_STATE_ACTIVATED:
- WDPOP_LOGD( "event ------------------ WIFI_DIRECT_DEVICE_STATE_ACTIVATED\n");
- break;
-
- case WIFI_DIRECT_DEVICE_STATE_DEACTIVATED:
- WDPOP_LOGD( "event ------------------ WIFI_DIRECT_DEVICE_STATE_DEACTIVATED\n");
- WDPOP_LOGD( "Termination process of wifi-direct popup begins...\n");
+ wfd_appdata_t *ad = (wfd_appdata_t *)data;
+ int res;
+ if(NULL == ad) {
+ WFD_APP_LOG(WFD_APP_LOG_ERROR, "NULL == ad!\n");
+ return -1;
+ }
+ res = wifi_direct_get_state(&ad->wfd_status);
+ if (res != WIFI_DIRECT_ERROR_NONE) {
+ return ECORE_CALLBACK_CANCEL;
+ }
- /* when deactivated, stop the timer */
- if (ad->transmit_timer) {
- ecore_timer_del(ad->transmit_timer);
- ad->transmit_timer = NULL;
+ if (ad->wfd_status >= WIFI_DIRECT_STATE_ACTIVATING) {
+ /*if connected, disconnect all devices*/
+ if (WIFI_DIRECT_STATE_CONNECTED == ad->wfd_status) {
+ res = wifi_direct_disconnect_all();
+ if (res != WIFI_DIRECT_ERROR_NONE) {
+ return -1;
+ }
+ }
+ res = wifi_direct_deactivate();
+ if (res != WIFI_DIRECT_ERROR_NONE) {
+ WFD_APP_LOG(WFD_APP_LOG_ERROR, "Failed to deactivate Wi-Fi Direct. error code = [%d]\n", res);
+ return -1;
}
-
- elm_exit();
- break;
-
- default:
- break;
}
- __WDPOP_LOG_FUNC_EXIT__;
+ return 0;
}
+#ifdef WFD_FIVE_MIN_IDLE_DEACTIVATION
/**
- * This function let the app find the peer by mac address
- * @return the found peer
- * @param[in] data the pointer to the main data structure
- * @param[in] mac_address the pointer to mac address
+ * This function let the ug make a callback for deactivating wfd automatically
+ * @return if stop the timer, return ECORE_CALLBACK_CANCEL, else return ECORE_CALLBACK_RENEW
+ * @param[in] user_data the pointer to the main data structure
*/
-static wfd_device_info_t *_wfd_app_find_peer_by_mac_address(void *data, const char *mac_address)
+static Eina_Bool _wfd_automatic_deactivated_for_no_connection_cb(void *user_data)
{
- __WDPOP_LOG_FUNC_ENTER__;
- wfd_appdata_t *ad = (wfd_appdata_t *) data;
- int i;
+ int res = -1;
+ int interval = 0;
+ wfd_appdata_t *ad = (wfd_appdata_t *)user_data;
+#ifdef WFD_SCREEN_MIRRORING_ENABLED
+ int screen_mirroring_status = 0;
+#endif
- if (ad == NULL) {
- WDPOP_LOGD( "Incorrect parameter(NULL)\n");
- return NULL;
+ if (NULL == ad) {
+ return ECORE_CALLBACK_CANCEL;
}
- WDPOP_LOGD( "find peer by MAC [%s] \n", mac_address);
-
- for (i = 0; i < ad->discovered_peer_count; i++) {
- WDPOP_LOGD( "check %dth peer\n", i);
-
- if (!strncmp(mac_address, (const char *) ad->discovered_peers[i].mac_address, 18)) {
- WDPOP_LOGD( "found peer. [%d]\n", i);
- __WDPOP_LOG_FUNC_EXIT__;
- return &ad->discovered_peers[i];
- }
+ /* check the action, if action is exist, keep the cb */
+ res = wifi_direct_get_state(&ad->wfd_status);
+ if (res != WIFI_DIRECT_ERROR_NONE) {
+ WFD_APP_LOG(WFD_APP_LOG_ERROR, "Get wifi-direct status WIFI_DIRECT_ERROR_NONE!\n");
+ return ECORE_CALLBACK_CANCEL;
}
- __WDPOP_LOG_FUNC_EXIT__;
- return NULL;
-}
-
-/**
- * This function let the app make a callback for discovering peer
- * @return TRUE
- * @param[in] peer the pointer to the discovered peer
- * @param[in] user_data the pointer to the main data structure
- */
-bool _wfd_app_discoverd_peer_cb(wifi_direct_discovered_peer_info_s *peer, void *user_data)
-{
- __WDPOP_LOG_FUNC_ENTER__;
- wfd_appdata_t *ad = (wfd_appdata_t *) user_data;
+ if (ad->last_wfd_status != ad->wfd_status) {
+ ad->last_wfd_status = ad->wfd_status;
+ ad->last_wfd_time = time(NULL);
+ return ECORE_CALLBACK_RENEW;
+ }
- if (NULL != peer->device_name) {
- WDPOP_LOGD( "discovered peer ssid[%s]\n", peer->device_name);
- strncpy(ad->discovered_peers[ad->discovered_peer_count].ssid, peer->device_name, 32);
- ad->discovered_peers[ad->discovered_peer_count].ssid[31] = '\0';
- } else {
- WDPOP_LOGD( "peer's device name is NULL\n");
+ /* check the timeout, if not timeout, keep the cb */
+ interval = time(NULL) - ad->last_wfd_time;
+ if (interval < MAX_NO_ACTION_TIME_OUT) {
+ return ECORE_CALLBACK_RENEW;
}
- if (NULL != peer->mac_address) {
- WDPOP_LOGD( "discovered peer mac[%s]\n", peer->mac_address);
- strncpy(ad->discovered_peers[ad->discovered_peer_count].mac_address, peer->mac_address, 18);
- ad->discovered_peers[ad->discovered_peer_count].mac_address[17] = '\0';
+ /* turn off the Wi-Fi Direct */
+ wifi_direct_get_state(&ad->wfd_status);
+ if (ad->wfd_status < WIFI_DIRECT_STATE_ACTIVATING) {
+ WFD_APP_LOG(WFD_APP_LOG_LOW, "wfd_status < WIFI_DIRECT_STATE_ACTIVATING!\n");
} else {
- WDPOP_LOGD( "peer's mac is NULL\n");
- }
+#ifdef WFD_SCREEN_MIRRORING_ENABLED
+ if (vconf_get_int(VCONFKEY_SCREEN_MIRRORING_STATE, &screen_mirroring_status) < 0)
+ {
+ WFD_APP_LOG(WFD_APP_LOG_ERROR, "Failed to get vconf VCONFKEY_SCREEN_MIRRORING_STATE\n");
+ }
- ad->discovered_peer_count++;
+ if (screen_mirroring_status == VCONFKEY_SCREEN_MIRRORING_ACTIVATED) {
+ ad->last_wfd_time = time(NULL);
+ return ECORE_CALLBACK_RENEW;
+ } else {
+ /* turn off the Wi-Fi Direct */
+ wfd_app_client_switch_off(ad);
+ ad->popup = wfd_draw_pop_type_auto_deactivation(ad->win, user_data);
+ }
+#endif
+ }
- __WDPOP_LOG_FUNC_EXIT__;
- return TRUE;
+ /* reset monitor timer */
+ if (ad->monitor_timer) {
+ ad->monitor_timer = NULL; //ECORE_CALLBACK_CANCEL will release timer.
+ }
+ return ECORE_CALLBACK_CANCEL;
}
+#endif
/**
- * This function let the app make a callback for registering discover event
+ * This function let the app make a callback for registering activation event
* @return void
* @param[in] error_code the returned error code
- * @param[in] discovery_state the state of discover
+ * @param[in] device_state the state of device
* @param[in] user_data the pointer to the main data structure
*/
-void _cb_discover(int error_code, wifi_direct_discovery_state_e discovery_state, void *user_data)
+void _cb_activation(int error_code, wifi_direct_device_state_e device_state, void *user_data)
{
- __WDPOP_LOG_FUNC_ENTER__;
+ __WFD_APP_FUNC_ENTER__;
wfd_appdata_t *ad = (wfd_appdata_t *)user_data;
- int ret;
-
- switch (discovery_state) {
- case WIFI_DIRECT_DISCOVERY_STARTED:
- WDPOP_LOGD( "event ------------------ WIFI_DIRECT_DISCOVERY_STARTED\n");
- break;
-
- case WIFI_DIRECT_ONLY_LISTEN_STARTED:
- WDPOP_LOGD( "event ------------------ WIFI_DIRECT_ONLY_LISTEN_STARTED\n");
- break;
- case WIFI_DIRECT_DISCOVERY_FINISHED:
- WDPOP_LOGD( "event ------------------ WIFI_DIRECT_DISCOVERY_FINISHED\n");
- break;
-
- case WIFI_DIRECT_DISCOVERY_FOUND:
- WDPOP_LOGD( "event ------------------ WIFI_DIRECT_DISCOVERY_FOUND\n");
-
- if (NULL != ad->discovered_peers) {
- free(ad->discovered_peers);
- ad->discovered_peers = NULL;
+ switch (device_state) {
+ case WIFI_DIRECT_DEVICE_STATE_ACTIVATED:
+ {
+ WFD_APP_LOG(WFD_APP_LOG_ERROR, "---------------WIFI_DIRECT_DEVICE_STATE_ACTIVATED\n");
+#ifdef NOT_CONNECTED_INDICATOR_ICON
+ wfd_app_util_add_indicator_icon(ad);
+#endif
+#ifdef WFD_FIVE_MIN_IDLE_DEACTIVATION
+ if (NULL == ad->monitor_timer) {
+ ad->last_wfd_time = time(NULL);
+ ad->monitor_timer = ecore_timer_add(5.0,
+ (Ecore_Task_Cb)_wfd_automatic_deactivated_for_no_connection_cb, ad);
}
+#endif
+ }
+ break;
- ad->discovered_peers = calloc(10, sizeof(wfd_device_info_t));
- ad->discovered_peer_count = 0;
+ case WIFI_DIRECT_DEVICE_STATE_DEACTIVATED:
+ {
+ WFD_APP_LOG(WFD_APP_LOG_ERROR, "---------------WIFI_DIRECT_DEVICE_STATE_DEACTIVATED\n");
+ /* when deactivated, stop the timer */
+ if (ad->transmit_timer) {
+ ecore_timer_del(ad->transmit_timer);
+ ad->transmit_timer = NULL;
+ }
- ret = wifi_direct_foreach_discovered_peers(_wfd_app_discoverd_peer_cb, (void *) ad);
- if (ret != WIFI_DIRECT_ERROR_NONE) {
- WDPOP_LOGD( "get discovery result failed: %d\n", ret);
+#ifdef WFD_FIVE_MIN_IDLE_DEACTIVATION
+ /* when deactivated, stop the timer */
+ if (ad->monitor_timer) {
+ ecore_timer_del(ad->monitor_timer);
+ ad->monitor_timer = NULL;
}
- break;
+#endif
+ wfd_app_util_del_notification(ad);
+#ifdef WFD_SCREEN_MIRRORING_ENABLED
+ wfd_app_util_set_screen_mirroring_deactivated(ad);
+#endif
+ }
+ break;
default:
break;
}
- __WDPOP_LOG_FUNC_EXIT__;
+ __WFD_APP_FUNC_EXIT__;
}
/**
@@ -443,285 +330,330 @@ void _cb_discover(int error_code, wifi_direct_discovery_state_e discovery_state,
*/
void _cb_connection(int error_code, wifi_direct_connection_state_e connection_state, const char *mac_address, void *user_data)
{
- __WDPOP_LOG_FUNC_ENTER__;
+ __WFD_APP_FUNC_ENTER__;
wfd_appdata_t *ad = (wfd_appdata_t *)user_data;
int result = -1;
- char msg[WFD_POP_STR_MAX_LEN] = {0};
- wfd_device_info_t *peer_info = NULL;
+ int wfd_state = -1;
+#ifdef WFD_SCREEN_MIRRORING_ENABLED
+ int screen_mirroring_status = 0;
+#endif
+ wifi_direct_discovered_peer_info_s *peer_info = NULL;
+ wfd_connection_info_s *connection = ad->connection;
+#ifdef NOT_CONNECTED_INDICATOR_ICON
+ notification_error_e noti_err = NOTIFICATION_ERROR_NONE;
+#endif
+ char popup_text[MAX_POPUP_TEXT_SIZE] = {0, };
/* find the peer's name by the mac address */
- if (NULL == mac_address) {
- WDPOP_LOGE("ERROR : mac address is NULL !!\n");
- return;
- }
+ WFD_RET_IF(NULL == mac_address, "ERROR : mac address is NULL !!\n");
+
+ WFD_APP_LOG(WFD_APP_LOG_ERROR, "-------------------error_code:%d connection_state:%d \n",
+ error_code, connection_state);
/* when disconnection, mac_address is empty */
- if (connection_state <= WIFI_DIRECT_CONNECTION_RSP ||
- connection_state == WIFI_DIRECT_INVITATION_REQ) {
- memset(ad->peer_mac, 0, sizeof(ad->peer_mac));
- memset(ad->peer_name, 0, sizeof(ad->peer_name));
- strncpy(ad->peer_mac, mac_address, strlen(mac_address));
- ad->peer_mac[17] = '\0';
- peer_info = _wfd_app_find_peer_by_mac_address(ad, mac_address);
-
- if (NULL == peer_info) {
- WDPOP_LOGD( "peer_info is NULL !!\n");
- } else if (0 == strlen(peer_info->ssid)) {
- WDPOP_LOGD( "SSID from connection is invalid !!\n");
+ if (connection_state <= WIFI_DIRECT_DISASSOCIATION_IND) {
+ if (connection) {
+ result = strncmp(connection->peer_addr, mac_address, MACSTR_LENGTH);
+ if (result) {
+ WFD_APP_LOG(WFD_APP_LOG_ERROR, "Connection event from unknown peer");
+ return;
+ }
} else {
- WDPOP_LOGD( "SSID from connection is %s.\n", peer_info->ssid);
- strncpy(ad->peer_name, peer_info->ssid, strlen(peer_info->ssid));
- ad->peer_name[31] = '\0';
- }
+ result = wifi_direct_get_peer_info((char *)mac_address, &peer_info);
+ if (result < 0 || !peer_info) {
+ WFD_APP_LOG(WFD_APP_LOG_ERROR, "Unknown peer");
+ if (NULL != peer_info)
+ free(peer_info);
+ return;
+ }
+
+ connection = (wfd_connection_info_s*) calloc(1, sizeof(wfd_connection_info_s));
+ if (!connection) {
+ WFD_APP_LOG(WFD_APP_LOG_ERROR, "Failed to allocate memory for peer");
+ free(peer_info);
+ return;
+ }
+
+ if (TRUE != dbus_validate_utf8(peer_info->device_name, NULL)) {
+ memcpy(connection->peer_name, peer_info->device_name, DEV_NAME_LENGTH-2);
+ connection->peer_name[DEV_NAME_LENGTH-2] = '\0';
+ } else {
+ memcpy(connection->peer_name, peer_info->device_name, DEV_NAME_LENGTH);
+ connection->peer_name[DEV_NAME_LENGTH] = '\0';
+ }
- if (0 == strlen(ad->peer_name)) {
- strncpy(ad->peer_name, ad->peer_mac, strlen(ad->peer_mac));
- ad->peer_name[31] = '\0';
+ strncpy(connection->peer_addr, mac_address, MACSTR_LENGTH);
+ connection->peer_addr[MACSTR_LENGTH] = '\0';
+ connection->device_type = peer_info->primary_device_type;
+ connection->wifi_display = peer_info->is_miracast_device;
+ wifi_direct_get_local_wps_type(&connection->wps_type);
+ wifi_direct_is_autoconnection_mode(&connection->auto_conn);
+
+ ad->connection = connection;
+ free(peer_info);
}
}
switch (connection_state) {
- case WIFI_DIRECT_CONNECTION_RSP:
+ case WIFI_DIRECT_CONNECTION_REQ:
{
- WDPOP_LOGD( "event ------------------ WIFI_DIRECT_CONNECTION_RSP\n");
- wfd_destroy_popup();
-
- if (error_code == WIFI_DIRECT_ERROR_NONE) {
- WDPOP_LOGD( "Link Complete!\n");
-
- /* add connected notification */
- _add_wfd_peers_connected_notification(ad);
+ WFD_APP_LOG(WFD_APP_LOG_LOW, "event ------------------ WIFI_DIRECT_CONNECTION_REQ\n");
+
+ memcpy((char*)ad->mac_addr_connecting, connection->peer_addr, MACSTR_LENGTH);
+
+ wfd_app_get_connected_peers(ad);
+ WFD_APP_LOG(WFD_APP_LOG_LOW, "No of connected peers = %d", ad->raw_connected_peer_cnt);
+ if (ad->raw_connected_peer_cnt >= WFD_MAX_CONNECTED_PEER) {
+ result = wifi_direct_reject_connection(connection->peer_addr);
+ if (result != WIFI_DIRECT_ERROR_NONE)
+ WFD_APP_LOG(WFD_APP_LOG_ERROR, "Failed to reject connection(%d)", result);
+ snprintf(popup_text, MAX_POPUP_TEXT_SIZE,
+ _("IDS_ST_POP_YOU_CAN_CONNECT_UP_TO_PD_DEVICES_AT_THE_SAME_TIME"),
+ WFD_MAX_CONNECTED_PEER);
+ notification_status_message_post(popup_text);
+ break;
+ }
- /* tickernoti popup */
- snprintf(msg, WFD_POP_STR_MAX_LEN, IDS_WFD_POP_CONNECTED, ad->peer_name);
- notification_status_message_post(msg);
- } else if (error_code == WIFI_DIRECT_ERROR_AUTH_FAILED) {
- WDPOP_LOGD(
- "Error Code - WIFI_DIRECT_ERROR_AUTH_FAILED\n");
- notification_status_message_post(_("IDS_WFD_POP_PIN_INVALID"));
+ if (connection->auto_conn) {
+ usleep(200);
+ result = wifi_direct_accept_connection(connection->peer_addr);
+ if (result < 0) {
+ WFD_APP_LOG(WFD_APP_LOG_ERROR, "Failed to accept connection");
+ break;
+ }
+ WFD_APP_LOG(WFD_APP_LOG_HIGH, "Succeeded to accept connection");
} else {
- if (error_code == WIFI_DIRECT_ERROR_CONNECTION_TIME_OUT) {
- WDPOP_LOGD(
- "Error Code - WIFI_DIRECT_ERROR_CONNECTION_TIME_OUT\n");
- } else if (error_code == WIFI_DIRECT_ERROR_CONNECTION_FAILED) {
- WDPOP_LOGD(
- "Error Code - WIFI_DIRECT_ERROR_CONNECTION_FAILED\n");
+ if (connection->wps_type == WIFI_DIRECT_WPS_TYPE_PBC) {
+ WFD_APP_LOG(WFD_APP_LOG_LOW, "WPS type: WIFI_DIRECT_WPS_TYPE_PBC\n");
+ wfd_prepare_popup(WFD_POP_APRV_CONNECTION_WPS_PUSHBUTTON_REQ, NULL);
+ } else if (connection->wps_type == WIFI_DIRECT_WPS_TYPE_PIN_DISPLAY) {
+ char *pin;
+ WFD_APP_LOG(WFD_APP_LOG_LOW, "WPS type: WIFI_DIRECT_WPS_TYPE_PIN_DISPLAY");
+ if (wifi_direct_get_wps_pin(&pin) != WIFI_DIRECT_ERROR_NONE) {
+ WFD_APP_LOG(WFD_APP_LOG_ERROR, "Failed to get WPS pin");
+ return;
+ }
+ strncpy(connection->wps_pin, pin, PIN_LENGTH);
+ WFD_IF_FREE_MEM(pin);
+ wfd_prepare_popup(WFD_POP_APRV_CONNECTION_WPS_DISPLAY_REQ, NULL);
+ } else if (connection->wps_type == WIFI_DIRECT_WPS_TYPE_PIN_KEYPAD) {
+ WFD_APP_LOG(WFD_APP_LOG_LOW, "WPS type: WIFI_DIRECT_WPS_TYPE_PIN_KEYPAD");
+ wfd_prepare_popup(WFD_POP_APRV_CONNECTION_WPS_KEYPAD_REQ, NULL);
+ } else {
+ WFD_APP_LOG(WFD_APP_LOG_ERROR, "wps_config is unkown!\n");
+ break;
}
-
- /* tickernoti popup */
- snprintf(msg, WFD_POP_STR_MAX_LEN, IDS_WFD_POP_CONNECT_FAILED, ad->peer_name);
- notification_status_message_post(msg);
+ int res = display_change_state(LCD_NORMAL);
+ if(res < 0)
+ WFD_APP_LOG(WFD_APP_LOG_ERROR, "Failed to change PM state(%d)", res);
}
}
break;
case WIFI_DIRECT_CONNECTION_WPS_REQ:
{
- wifi_direct_wps_type_e wps_mode;
-
- memcpy(ad->peer_mac, mac_address, sizeof(ad->peer_mac));
-
- WDPOP_LOGD(
- "event ------------------ WIFI_DIRECT_CONNECTION_WPS_REQ\n");
- result = wifi_direct_get_wps_type(&wps_mode);
- WDPOP_LOGD(
- "wifi_direct_get_wps_type() result=[%d]\n", result);
-
- if (wps_mode == WIFI_DIRECT_WPS_TYPE_PBC) {
- WDPOP_LOGD(
- "wps_config is WIFI_DIRECT_WPS_TYPE_PBC. Ignore it..\n");
- } else if (wps_mode == WIFI_DIRECT_WPS_TYPE_PIN_DISPLAY) {
+ WFD_APP_LOG(WFD_APP_LOG_LOW, "event ------------------ WIFI_DIRECT_CONNECTION_WPS_REQ\n");
+ if (connection->wps_type == WIFI_DIRECT_WPS_TYPE_PIN_KEYPAD) {
+ WFD_APP_LOG(WFD_APP_LOG_LOW, "WPS type: WIFI_DIRECT_WPS_TYPE_PIN_KEYPAD\n");
+ wfd_prepare_popup(WFD_POP_PROG_CONNECT_WITH_KEYPAD, NULL);
+ } else if (connection->wps_type == WIFI_DIRECT_WPS_TYPE_PIN_DISPLAY) {
char *pin;
- WDPOP_LOGD( "wps_config is WIFI_DIRECT_WPS_TYPE_PIN_DISPLAY\n");
-
- if (wifi_direct_generate_wps_pin() != WIFI_DIRECT_ERROR_NONE) {
- WDPOP_LOGD( "wifi_direct_generate_wps_pin() is failed\n");
- return;
- }
+ WFD_APP_LOG(WFD_APP_LOG_LOW, "WPS type: WIFI_DIRECT_WPS_TYPE_PIN_DISPLAY\n");
if (wifi_direct_get_wps_pin(&pin) != WIFI_DIRECT_ERROR_NONE) {
- WDPOP_LOGD( "wifi_direct_generate_wps_pin() is failed\n");
+ WFD_APP_LOG(WFD_APP_LOG_ERROR, "Failed to get WPS pin");
return;
}
- strncpy(ad->pin_number, pin, 64);
- ad->pin_number[63] = '\0';
- free(pin);
- pin = NULL;
-
- WDPOP_LOGD( "pin=[%s]\n", ad->pin_number);
+ strncpy(connection->wps_pin, pin, PIN_LENGTH);
+ WFD_IF_FREE_MEM(pin);
wfd_prepare_popup(WFD_POP_PROG_CONNECT_WITH_PIN, NULL);
- } else if (wps_mode == WIFI_DIRECT_WPS_TYPE_PIN_KEYPAD) {
- WDPOP_LOGD( "wps_config is WIFI_DIRECT_WPS_TYPE_PIN_KEYPAD\n");
- wfd_prepare_popup(WFD_POP_PROG_CONNECT_WITH_KEYPAD, (void *) NULL);
} else {
- WDPOP_LOGD( "wps_config is unkown!\n");
-
+ WFD_APP_LOG(WFD_APP_LOG_ERROR, "WPS type: %d", connection->wps_type);
}
}
break;
- case WIFI_DIRECT_CONNECTION_REQ:
+ case WIFI_DIRECT_CONNECTION_IN_PROGRESS:
{
- WDPOP_LOGD( "event ------------------ WIFI_DIRECT_CONNECTION_REQ\n");
-
- wifi_direct_wps_type_e wps_mode;
- bool auto_connection_mode;
+ WFD_APP_LOG(WFD_APP_LOG_LOW, "event ------------------ WIFI_DIRECT_CONNECTION_IN_PROGRESS\n");
+ }
+ break;
- result = wifi_direct_get_wps_type(&wps_mode);
- WDPOP_LOGD( "wifi_direct_get_wps_type() result=[%d]\n", result);
+ case WIFI_DIRECT_CONNECTION_RSP:
+ {
+ char *msg = NULL;
+ char txt[WFD_POP_STR_MAX_LEN] = {0};
+ wfd_destroy_popup();
- result = wifi_direct_is_autoconnection_mode(&auto_connection_mode);
- WDPOP_LOGD( "wifi_direct_is_autoconnection_mode() result=[%d]\n", result);
+ memset(ad->mac_addr_connecting, 0x00, MACSTR_LENGTH);
- if (auto_connection_mode == TRUE) {
- result = wifi_direct_accept_connection(ad->peer_mac);
- WDPOP_LOGD("wifi_direct_accept_connection() result=[%d]\n", result);
+ if (error_code != WIFI_DIRECT_ERROR_NONE) {
+ WFD_APP_LOG(WFD_APP_LOG_ERROR, "Failed to connect with peer[%s] -(%d)",
+ connection->peer_name, error_code);
+ snprintf(txt, WFD_POP_STR_MAX_LEN, _("IDS_WIFI_POP_FAILED_TO_CONNECT_TO_PS"),
+ connection->peer_name);
} else {
- if (wps_mode == WIFI_DIRECT_WPS_TYPE_PBC) {
- WDPOP_LOGD( "wps_config is WIFI_DIRECT_WPS_TYPE_PBC\n");
- wfd_prepare_popup(WFD_POP_APRV_CONNECTION_WPS_PUSHBUTTON_REQ, NULL);
- } else if (wps_mode == WIFI_DIRECT_WPS_TYPE_PIN_DISPLAY) {
- WDPOP_LOGD( "wps_config is WIFI_DIRECT_WPS_TYPE_PIN_DISPLAY\n");
- wfd_prepare_popup(WFD_POP_APRV_CONNECTION_WPS_DISPLAY_REQ, NULL);
- } else if (wps_mode == WIFI_DIRECT_WPS_TYPE_PIN_KEYPAD) {
- WDPOP_LOGD( "wps_config is WIFI_DIRECT_WPS_TYPE_PIN_KEYPAD\n");
- wfd_prepare_popup(WFD_POP_APRV_CONNECTION_WPS_KEYPAD_REQ, (void *) NULL);
- } else {
- WDPOP_LOGD( "wps_config is unkown!\n");
+ WFD_APP_LOG(WFD_APP_LOG_LOW, "Succeeded to connect with peer[%s] -(%d)",
+ connection->peer_name, error_code);
+ snprintf(txt, WFD_POP_STR_MAX_LEN, _("IDS_WIFI_BODY_CONNECTED_TO_PS"),
+ connection->peer_name);
+#ifdef WFD_SCREEN_MIRRORING_ENABLED
+ result = vconf_get_int(VCONFKEY_SCREEN_MIRRORING_STATE, &screen_mirroring_status);
+ if (result < 0)
+ WFD_APP_LOG(WFD_APP_LOG_ERROR, "Failed to get VCONFKEY_SCREEN_MIRRORING_STATE");
+
+ if (screen_mirroring_status == VCONFKEY_SCREEN_MIRRORING_DEACTIVATED)
+ snprintf(txt, WFD_POP_STR_MAX_LEN, _("IDS_WIFI_BODY_CONNECTED_TO_PS"),
+ connection->peer_name);
+#endif
+ }
+ if (connection)
+ free(ad->connection);
+ ad->connection = NULL;
+
+ wfd_app_get_connected_peers(ad);
+ WFD_APP_LOG(WFD_APP_LOG_LOW, "No of connected peers = %d", ad->raw_connected_peer_cnt);
+ /* tickernoti popup */
+ if (ad->raw_connected_peer_cnt < WFD_MAX_CONNECTED_PEER) {
+ if (strlen(txt) > 0) {
+ msg = elm_entry_utf8_to_markup(txt);
+ WFD_RET_IF(!msg, "Failed to elm_entry_markup_to_utf8()!");
+ notification_status_message_post(msg);
+ WFD_IF_FREE_MEM(msg);
}
}
}
break;
- case WIFI_DIRECT_DISCONNECTION_IND:
+ case WIFI_DIRECT_DISASSOCIATION_IND:
{
- _del_wfd_notification();
- WDPOP_LOGD( "event ------------------ WIFI_DIRECT_DISCONNECTION_IND\n");
+ WFD_APP_LOG(WFD_APP_LOG_LOW, "event ------------------ WIFI_DIRECT_DISASSOCIATION_IND\n");
+ wfd_app_util_del_wfd_connected_notification(ad);
- result = wifi_direct_set_autoconnection_mode(false);
- WDPOP_LOGD( "wifi_direct_set_autoconnection_mode() result=[%d]\n", result);
+#ifdef WFD_SCREEN_MIRRORING_ENABLED
+ if (connection && connection->wifi_display)
+ wfd_app_util_set_screen_mirroring_deactivated(ad);
+#endif
+ if (connection)
+ free(ad->connection);
+ ad->connection = NULL;
- /* tickernoti popup */
- snprintf(msg, WFD_POP_STR_MAX_LEN, IDS_WFD_POP_DISCONNECTED, ad->peer_name);
- notification_status_message_post(msg);
+ }
+ break;
+
+ case WIFI_DIRECT_DISCONNECTION_IND:
+ {
+#if 0 // changed to show notification only when allshare cast device is connected.
+ _del_wfd_notification();
+#endif
+ WFD_APP_LOG(WFD_APP_LOG_LOW, "event ------------------ WIFI_DIRECT_DISCONNECTION_IND\n");
+#ifdef WFD_SCREEN_MIRRORING_ENABLED
+ wfd_app_util_set_screen_mirroring_deactivated(ad);
+#endif
+ notification_status_message_post(_("IDS_WIFI_BODY_THE_WI_FI_DIRECT_CONNECTION_HAS_BEEN_LOST"));
+ wfd_app_util_del_wfd_connected_notification(ad);
}
break;
case WIFI_DIRECT_DISCONNECTION_RSP:
{
+#if 0 // changed to show notification only when allshare cast device is connected.
_del_wfd_notification();
+#endif
+ WFD_APP_LOG(WFD_APP_LOG_LOW, "event ------------------ WIFI_DIRECT_DISCONNECTION_RSP\n");
+
+ wfd_app_util_del_wfd_connected_notification(ad);
+
+#ifdef WFD_SCREEN_MIRRORING_ENABLED
+ wfd_app_util_set_screen_mirroring_deactivated(ad);
+#endif
wfd_destroy_popup();
result = wifi_direct_set_autoconnection_mode(false);
- WDPOP_LOGD( "wifi_direct_set_autoconnection_mode() result=[%d]\n", result);
-
- /* tickernoti popup */
- snprintf(msg, WFD_POP_STR_MAX_LEN, IDS_WFD_POP_DISCONNECTED, ad->peer_name);
- notification_status_message_post(msg);
+ WFD_APP_LOG(WFD_APP_LOG_LOW, "wifi_direct_set_autoconnection_mode() result=[%d]\n", result);
}
break;
- case WIFI_DIRECT_CONNECTION_IN_PROGRESS:
+
+ case WIFI_DIRECT_GROUP_DESTROYED:
{
- WDPOP_LOGD( "event ------------------ WIFI_DIRECT_CONNECTION_IN_PROGRESS\n");
- /* tickernoti popup */
- notification_status_message_post(_("IDS_WFD_POP_CONNECTING"));
+ WFD_APP_LOG(WFD_APP_LOG_LOW, "event ------------------ WIFI_DIRECT_GROUP_DESTROYED\n");
+ notification_status_message_post(_("IDS_WIFI_BODY_THE_WI_FI_DIRECT_CONNECTION_HAS_BEEN_LOST"));
}
break;
- case WIFI_DIRECT_INVITATION_REQ:
- {
- WDPOP_LOGD( "event ------------------ WIFI_DIRECT_INVITATION_REQ\n");
- bool auto_connection_mode = FALSE;
- wifi_direct_is_autoconnection_mode(&auto_connection_mode);
- if (auto_connection_mode == TRUE) {
- result = wifi_direct_connect(ad->peer_mac);
- WDPOP_LOGD("wifi_direct_accept_connection() result=[%d]\n", result);
- } else {
- wfd_prepare_popup(WFD_POP_APRV_CONNECTION_INVITATION_REQ, NULL);
- }
- }
- break;
default:
break;
}
- /* if connected, start the transmit timer */
- wifi_direct_get_state(&ad->wfd_status);
- WDPOP_LOGD( "status: %d", ad->wfd_status);
+ /*
+ * To support ON DEMAND popup destroy. API request blocks and popup destroy
+ * fails.
+ */
+ /* wifi_direct_get_state(&ad->wfd_status); */
- if (ad->wfd_status < WIFI_DIRECT_STATE_CONNECTED) {
+ if (vconf_get_int(VCONFKEY_WIFI_DIRECT_STATE, &wfd_state) < 0) {
+ WFD_APP_LOG(WFD_APP_LOG_ERROR, "Error reading vconf (%s)\n", VCONFKEY_WIFI_DIRECT_STATE);
+ }
+ WFD_APP_LOG(WFD_APP_LOG_LOW, "wfd state: %d", wfd_state);
+
+ if (wfd_state == VCONFKEY_WIFI_DIRECT_DEACTIVATED) {
+ wfd_app_util_del_notification(ad);
+ }
+
+#ifdef NOT_CONNECTED_INDICATOR_ICON
+ if (wfd_state >= VCONFKEY_WIFI_DIRECT_CONNECTED) {
+ noti_err = notification_delete(ad->noti_wifi_direct_on);
+ if (noti_err != NOTIFICATION_ERROR_NONE) {
+ WFD_APP_LOG(WFD_APP_LOG_ERROR, "Fail to notification_delete.(%d)\n", noti_err);
+ } else {
+ noti_err = notification_free(ad->noti_wifi_direct_on);
+ ad->noti_wifi_direct_on = NULL;
+ if (noti_err != NOTIFICATION_ERROR_NONE) {
+ WFD_APP_LOG(WFD_APP_LOG_ERROR, "Fail to notification_free.(%d)\n", noti_err);
+ }
+ }
+ }
+#endif
+
+ if (wfd_state < VCONFKEY_WIFI_DIRECT_CONNECTED) {
if (ad->transmit_timer) {
ecore_timer_del(ad->transmit_timer);
ad->transmit_timer = NULL;
}
} else {
if (NULL == ad->transmit_timer) {
- WDPOP_LOGD( "start the transmit timer\n");
+ WFD_APP_LOG(WFD_APP_LOG_LOW, "start the transmit timer\n");
ad->last_wfd_transmit_time = time(NULL);
ad->transmit_timer = ecore_timer_add(5.0,
- (Ecore_Task_Cb)_wfd_automatic_deactivated_for_connection_cb, ad);
+ (Ecore_Task_Cb)wfd_automatic_deactivated_for_connection_cb, ad);
}
}
- __WDPOP_LOG_FUNC_EXIT__;
-}
-
-/**
- * This function let the app make a change callback for flight mode
- * @return void
- * @param[in] key the pointer to the key
- * @param[in] user_data the pointer to the main data structure
- */
-static void _wfd_flight_mode_changed(keynode_t *node, void *user_data)
-{
- __WDPOP_LOG_FUNC_ENTER__;
- int res = -1;
- int flight_mode = 0;
- wfd_appdata_t *ad = (wfd_appdata_t *)user_data;
-
- if (NULL == ad) {
- WDPOP_LOGE("NULL parameters.\n");
- return;
- }
-
- res = vconf_get_bool(VCONFKEY_SETAPPL_FLIGHT_MODE_BOOL, &flight_mode);
- if (res != 0) {
- WDPOP_LOGE("Failed to get flight state from vconf. [%d]\n", res);
- return;
- }
-
- if (flight_mode == FALSE) {
- WDPOP_LOGD( "Flight mode is off\n");
- return;
- }
-
- /* If flight mode is on, turn off WFD */
- wifi_direct_get_state(&ad->wfd_status);
- if (WIFI_DIRECT_STATE_DEACTIVATED == ad->wfd_status) {
- WDPOP_LOGD( "Wi-Fi Direct is deactivated.\n");
- return;
- }
-
- /*if connected, disconnect all devices*/
- if (WIFI_DIRECT_STATE_CONNECTED == ad->wfd_status) {
- res = wifi_direct_disconnect_all();
- if (res != WIFI_DIRECT_ERROR_NONE) {
- WDPOP_LOGE("Failed to send disconnection request to all. [%d]\n", res);
- return;
+ if (wfd_state >= VCONFKEY_WIFI_DIRECT_CONNECTED) {
+#ifdef WFD_FIVE_MIN_IDLE_DEACTIVATION
+ if (ad->monitor_timer) {
+ ecore_timer_del(ad->monitor_timer);
+ ad->monitor_timer = NULL;
}
+#endif
+ } else {
+#ifdef NOT_CONNECTED_INDICATOR_ICON
+ wfd_app_util_add_indicator_icon(ad);
+#endif
+#ifdef WFD_FIVE_MIN_IDLE_DEACTIVATION
+ if (NULL == ad->monitor_timer) {
+ ad->last_wfd_time = time(NULL);
+ ad->monitor_timer = ecore_timer_add(5.0,
+ (Ecore_Task_Cb)_wfd_automatic_deactivated_for_no_connection_cb, ad);
+ }
+#endif
}
- res = wifi_direct_deactivate();
- if (res != WIFI_DIRECT_ERROR_NONE) {
- WDPOP_LOGE("Failed to deactivate Wi-Fi Direct. error code = [%d]\n", res);
- return;
- }
-
- __WDPOP_LOG_FUNC_EXIT__;
+ __WFD_APP_FUNC_EXIT__;
}
/**
@@ -729,57 +661,48 @@ static void _wfd_flight_mode_changed(keynode_t *node, void *user_data)
* @return If success, return TRUE, else return FALSE
* @param[in] ad the pointer to the main data structure
*/
-int init_wfd_popup_client(wfd_appdata_t *ad)
+bool init_wfd_client(wfd_appdata_t *ad)
{
- __WDPOP_LOG_FUNC_ENTER__;
-
- if (NULL == ad) {
- WDPOP_LOGD( "NULL parameters.\n");
- return FALSE;
- }
-
+ __WFD_APP_FUNC_ENTER__;
+ WFD_RETV_IF(NULL == ad, FALSE, "NULL parameters.\n");
int ret = -1;
+ int retrys = 3;
- ret = wifi_direct_initialize();
- if (ret != WIFI_DIRECT_ERROR_NONE) {
- WDPOP_LOGE("Failed to initialize Wi-Fi Direct. error code = [%d]\n", ret);
- return FALSE;
- }
+ ad->last_wfd_status = WIFI_DIRECT_STATE_DEACTIVATED;
- ret = wifi_direct_set_device_state_changed_cb(_cb_activation, (void *)ad);
- if (ret != WIFI_DIRECT_ERROR_NONE) {
- WDPOP_LOGE("Failed to register _cb_activation. error code = [%d]\n", ret);
- return FALSE;
- }
+ while (retrys > 0) {
+ ret = wifi_direct_initialize();
+ if (ret == WIFI_DIRECT_ERROR_NONE ||
+ ret == WIFI_DIRECT_ERROR_ALREADY_INITIALIZED)
+ break;
+ WFD_APP_LOG(WFD_APP_LOG_ERROR, "Failed to initialize Wi-Fi Direct(%d)\n", ret);
- ret = wifi_direct_set_discovery_state_changed_cb(_cb_discover, (void *)ad);
- if (ret != WIFI_DIRECT_ERROR_NONE) {
- WDPOP_LOGE("Failed to register _cb_discover. error code = [%d]\n", ret);
- return FALSE;
+ retrys--;
+ if (retrys == 0)
+ return FALSE;
+ usleep(100*1000);
}
- ret = wifi_direct_set_connection_state_changed_cb(_cb_connection, (void *)ad);
+ ret = wifi_direct_set_device_state_changed_cb(_cb_activation, (void*) ad);
if (ret != WIFI_DIRECT_ERROR_NONE) {
- WDPOP_LOGE("Failed to register _cb_connection. error code = [%d]\n", ret);
+ WFD_APP_LOG(WFD_APP_LOG_ERROR, "Failed to register _cb_activation(%d)\n", ret);
return FALSE;
}
- /* initialize notification */
- ad->noti = notification_new(NOTIFICATION_TYPE_NOTI, NOTIFICATION_GROUP_ID_NONE, NOTIFICATION_PRIV_ID_NONE);
- if (NULL == ad->noti) {
- WDPOP_LOGD( "notification_new failed.\n");
+ ret = wifi_direct_set_connection_state_changed_cb(_cb_connection, (void*) ad);
+ if (ret != WIFI_DIRECT_ERROR_NONE) {
+ WFD_APP_LOG(WFD_APP_LOG_ERROR, "Failed to register _cb_connection(%d)\n", ret);
return FALSE;
}
- /* register flight mode */
- int result = -1;
- result = vconf_notify_key_changed(VCONFKEY_SETAPPL_FLIGHT_MODE_BOOL, _wfd_flight_mode_changed, ad);
- if (result == -1) {
- WDPOP_LOGE("Failed to register vconf callback for flight mode\n");
- return FALSE;
+#ifdef WFD_FIVE_MIN_IDLE_DEACTIVATION
+ if (NULL == ad->monitor_timer) {
+ ad->last_wfd_time = time(NULL);
+ ad->monitor_timer = ecore_timer_add(5.0,
+ (Ecore_Task_Cb)_wfd_automatic_deactivated_for_no_connection_cb, ad);
}
-
- __WDPOP_LOG_FUNC_EXIT__;
+#endif
+ __WFD_APP_FUNC_EXIT__;
return TRUE;
}
@@ -788,43 +711,38 @@ int init_wfd_popup_client(wfd_appdata_t *ad)
* @return If success, return TRUE, else return FALSE
* @param[in] ad the pointer to the main data structure
*/
-int deinit_wfd_popup_client(wfd_appdata_t *ad)
+int deinit_wfd_client(wfd_appdata_t *ad)
{
- __WDPOP_LOG_FUNC_ENTER__;
-
- if (NULL == ad || NULL == ad->noti) {
- WDPOP_LOGD( "NULL parameters.\n");
- return FALSE;
- }
-
+ __WFD_APP_FUNC_ENTER__;
int ret = -1;
- ret = wifi_direct_deinitialize();
+ if (NULL == ad) {
+ WFD_APP_LOG(WFD_APP_LOG_LOW, "NULL parameter\n");
+ return -1;
+ }
- _del_wfd_notification(ad);
- notification_error_e noti_err = NOTIFICATION_ERROR_NONE;
- noti_err = notification_free(ad->noti);
- if (noti_err != NOTIFICATION_ERROR_NONE) {
- WDPOP_LOGD( "Fail to notification_free.(%d)\n", noti_err);
- ret = WIFI_DIRECT_ERROR_RESOURCE_BUSY;
+#ifdef WFD_FIVE_MIN_IDLE_DEACTIVATION
+ if (ad->monitor_timer) {
+ ecore_timer_del(ad->monitor_timer);
+ ad->monitor_timer = NULL;
}
+#endif
- /* remove callback for flight mode */
- int result = -1;
- result = vconf_ignore_key_changed(VCONFKEY_WIFI_STATE, _wfd_flight_mode_changed);
- if (result == -1) {
- WDPOP_LOGE("Failed to ignore vconf key callback for flight mode\n");
+ ret = wifi_direct_unset_device_state_changed_cb();
+ if (ret != WIFI_DIRECT_ERROR_NONE) {
+ WFD_APP_LOG(WFD_APP_LOG_ERROR, "Failed to deregister _cb_activation(%d)\n", ret);
}
- if (ad->transmit_timer) {
- ecore_timer_del(ad->transmit_timer);
- ad->transmit_timer = NULL;
+ ret = wifi_direct_unset_connection_state_changed_cb();
+ if (ret != WIFI_DIRECT_ERROR_NONE) {
+ WFD_APP_LOG(WFD_APP_LOG_ERROR, "Failed to deregister _cb_connection(%d)\n", ret);
}
- __WDPOP_LOG_FUNC_EXIT__;
- if (ret == WIFI_DIRECT_ERROR_NONE) {
- return TRUE;
- } else {
- return FALSE;
+ ret = wifi_direct_deinitialize();
+ if (ret != WIFI_DIRECT_ERROR_NONE) {
+ WFD_APP_LOG(WFD_APP_LOG_ERROR, "Failed to deinitialize Wi-Fi Direct. error code = [%d]\n", ret);
}
+
+ __WFD_APP_FUNC_EXIT__;
+ return 0;
}
diff --git a/popup-wifidirect/src/wfd-app-main.c b/popup-wifidirect/src/wfd-app-main.c
index 5c73670..89c1aac 100755..100644
--- a/popup-wifidirect/src/wfd-app-main.c
+++ b/popup-wifidirect/src/wfd-app-main.c
@@ -1,13 +1,13 @@
/*
* WiFi-Direct UG
*
-* Copyright 2012 Samsung Electronics Co., Ltd
+* Copyright 2012 Samsung Electronics Co., Ltd
-* Licensed under the Flora License, Version 1.1 (the "License");
+* Licensed under the Flora License, Version 1.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
-* http://floralicense.org/license
+* http://www.tizenopensource.org/license
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
@@ -26,15 +26,50 @@
*/
#include <libintl.h>
-#include <appcore-efl.h>
-#include <appsvc.h>
-#include <app_service.h>
+#include <Elementary.h>
+#include <Ecore_X.h>
+#include <notification.h>
+#include <ui-gadget-module.h>
+#include <app_control.h>
+#include <feedback.h>
+#include <wifi-direct.h>
+#include <efl_util.h>
+#include <efl_assist.h>
+#include <linux/unistd.h>
+#include <utilX.h>
+#include <vconf.h>
#include "wfd-app.h"
#include "wfd-app-util.h"
wfd_appdata_t *g_wfd_ad;
+#ifdef WFD_HOSTAPD_ENABLER
+static void __wfd_hotspot_mode_popup_vconf_change_cb(keynode_t *key, void *data)
+{
+ WFD_APP_LOG(WFD_APP_LOG_HIGH, "__wfd_hotspot_mode_vconf_change_cb\n");
+
+ if (NULL == key || NULL == data) {
+ WFD_APP_LOG(WFD_APP_LOG_ERROR, "Invalid parameters \n");
+ return;
+ }
+ int hotspot_mode = 0;
+ int res = 0;
+
+ res = vconf_get_int(VCONFKEY_MOBILE_HOTSPOT_MODE, &hotspot_mode);
+ if (res) {
+ WFD_APP_LOG(WFD_APP_LOG_ERROR, "Failed to get vconf value for PLMN(%d)", res);
+ return;
+ }
+ WFD_APP_LOG(WFD_APP_LOG_HIGH, "Hotspot mode %d",
+ hotspot_mode);
+
+ if (hotspot_mode == VCONFKEY_MOBILE_HOTSPOT_MODE_WIFI ||
+ hotspot_mode == VCONFKEY_MOBILE_HOTSPOT_MODE_WIFI_AP) {
+ wfd_destroy_popup();
+ }
+}
+#endif
wfd_appdata_t *wfd_get_appdata()
{
@@ -59,6 +94,7 @@ static Evas_Object *_create_win(Evas_Object *parent, const char *name)
elm_win_alpha_set(eo, EINA_TRUE);
evas_object_smart_callback_add(eo, "delete,request", _win_del, NULL);
ecore_x_window_size_get(ecore_x_window_root_first_get(), &w, &h);
+ efl_util_set_notification_window_level(eo, EFL_UTIL_NOTIFICATION_LEVEL_1);
evas_object_resize(eo, w, h);
evas_object_raise(eo);
}
@@ -66,142 +102,237 @@ static Evas_Object *_create_win(Evas_Object *parent, const char *name)
return eo;
}
-static int _app_create(void *data)
+static bool _app_create(void *data)
{
- __WDPOP_LOG_FUNC_ENTER__;
+ __WFD_APP_FUNC_ENTER__;
wfd_appdata_t *ad = wfd_get_appdata();
+ int ret = 0;
if (data == NULL) {
- WDPOP_LOGD( "Incorrect parameter\n");
- return -1;
+ WFD_APP_LOG(WFD_APP_LOG_ERROR, "Incorrect parameter\n");
+ return FALSE;
}
bindtextdomain(LOCALE_FILE_NAME, LOCALEDIR);
ad->popup_data = (wfd_popup_t *) malloc(sizeof(wfd_popup_t));
if (!ad->popup_data) {
- WDPOP_LOGE("malloc failed\n");
- return -1;
+ WFD_APP_LOG(WFD_APP_LOG_ERROR, "malloc failed\n");
+ return FALSE;
}
memset(ad->popup_data, 0x0, sizeof(wfd_popup_t));
ad->win = _create_win(NULL, PACKAGE);
- elm_win_indicator_mode_set(ad->win, ELM_WIN_INDICATOR_SHOW);
- int r;
+ if (elm_win_wm_rotation_supported_get(ad->win)) {
+ int rots[4] = { 0, 90, 180, 270 };
+ elm_win_wm_rotation_available_rotations_set(ad->win, rots, 1);
+ }
- if (!ecore_x_display_get()) {
- return -1;
+ ad->conformant = elm_conformant_add(ad->win);
+ assertm_if(NULL == ad->conformant, "conformant is NULL!!");
+ elm_win_conformant_set(ad->win, EINA_TRUE);
+ elm_win_resize_object_add(ad->win, ad->conformant);
+ evas_object_size_hint_weight_set(ad->conformant, EVAS_HINT_EXPAND, 0.0);
+ evas_object_size_hint_align_set(ad->conformant, EVAS_HINT_FILL, 0.0);
+ evas_object_show(ad->conformant);
+
+
+ ad->back_grnd = elm_bg_add(ad->conformant);
+ if (NULL == ad->back_grnd) {
+ WFD_APP_LOG(WFD_APP_LOG_LOW, "Create background failed\n");
+ return FALSE;
}
+ elm_object_signal_emit(ad->conformant, "elm,state,indicator,nooverlap", "elm");
+ elm_object_style_set(ad->back_grnd, "indicator/headerbg");
+ elm_object_part_content_set(ad->conformant, "elm.swallow.indicator_bg", ad->back_grnd);
+ evas_object_size_hint_weight_set(ad->back_grnd,
+ EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
+ evas_object_show(ad->back_grnd);
+
+ ad->layout = elm_layout_add(ad->conformant);
+ elm_object_content_set(ad->conformant, ad->layout);
- r = appcore_set_i18n(PACKAGE, NULL);
- if (r != 0) {
- WDPOP_LOGD( "appcore_set_i18n error\n");
- return -1;
+ if (!ecore_x_display_get()) {
+ return FALSE;
}
- if (init_wfd_popup_client(ad) == FALSE) {
- WDPOP_LOGE("init_wfd_popup_client error\n");
+ ret = init_wfd_client(ad);
+ if (!ret) {
+ WFD_APP_LOG(WFD_APP_LOG_ERROR, "init_wfd_popup_client error\n");
wfd_prepare_popup(WFD_POP_FAIL_INIT, NULL);
+ __WFD_APP_FUNC_EXIT__;
+ return FALSE;
}
- __WDPOP_LOG_FUNC_EXIT__;
- return 0;
+ ret = wfd_app_util_register_vconf_callbacks(ad);
+ if (ret < 0) {
+ WFD_APP_LOG(WFD_APP_LOG_ERROR, "Failed to register vconf notification");
+ return FALSE;
+ }
+
+ /* Enable Changeable UI feature */
+ ea_theme_changeable_ui_enabled_set(EINA_TRUE);
+
+ /* Register Hard Key Press CB */
+ wfd_app_util_register_hard_key_down_cb(ad);
+
+ /* Initializes feedback API */
+ ret = feedback_initialize();
+ if (ret != FEEDBACK_ERROR_NONE) {
+ WFD_APP_LOG(WFD_APP_LOG_ERROR, "feedback_initialize error : %d\n", ret);
+ return FALSE;
+ }
+ __WFD_APP_FUNC_EXIT__;
+ return TRUE;
}
-static int _app_terminate(void *data)
+static void _app_terminate(void *data)
{
- __WDPOP_LOG_FUNC_ENTER__;
+ __WFD_APP_FUNC_ENTER__;
+ wfd_appdata_t *ad = (wfd_appdata_t *) data;
+ int ret = 0;
if (data == NULL) {
- WDPOP_LOGE("Incorrect parameter\n");
- return -1;
+ WFD_APP_LOG(WFD_APP_LOG_ERROR, "Incorrect parameter\n");
+ return;
}
- wfd_appdata_t *ad = (wfd_appdata_t *) data;
+ wfd_app_util_del_notification(ad);
- if (deinit_wfd_popup_client(ad) == FALSE) {
- WDPOP_LOGE("deinit_wfd_popup_client error\n");
- } else {
- if (ad->popup) {
- evas_object_del(ad->popup);
- ad->popup = NULL;
- }
- if (ad->win) {
- evas_object_del(ad->win);
- ad->win = NULL;
- }
- if (ad->discovered_peers) {
- free(ad->discovered_peers);
- ad->discovered_peers = NULL;
- }
+ ret = wfd_app_util_deregister_vconf_callbacks(ad);
+ if (ret < 0) {
+ WFD_APP_LOG(WFD_APP_LOG_ERROR, "Failed to register vconf notification");
+ }
+
+ /* Deregister Hardkey CB */
+ wfd_app_util_deregister_hard_key_down_cb(ad);
+
+ /* Deinitializes feedback API */
+ ret = feedback_deinitialize();
+ if (ret != FEEDBACK_ERROR_NONE) {
+ WFD_APP_LOG(WFD_APP_LOG_ERROR, "feedback_deinitialize error : %d\n", ret);
+ }
+ if (ad->transmit_timer) {
+ ecore_timer_del(ad->transmit_timer);
+ ad->transmit_timer = NULL;
+ }
+
+ wfd_destroy_popup();
+
+ ret = deinit_wfd_client(ad);
+ if (ret < 0) {
+ WFD_APP_LOG(WFD_APP_LOG_ERROR, "deinit_wfd_client error\n");
+ }
+
+ if (ad->back_grnd) {
+ evas_object_del(ad->back_grnd);
+ ad->back_grnd = NULL;
}
- __WDPOP_LOG_FUNC_EXIT__;
- return 0;
+ if (ad->win) {
+ evas_object_del(ad->win);
+ ad->win = NULL;
+ }
+
+ if (ad->popup_data) {
+ free(ad->popup_data);
+ ad->popup_data = NULL;
+ }
+
+ __WFD_APP_FUNC_EXIT__;
+ return;
}
-static int _app_pause(void *data)
+static void _app_pause(void *data)
{
- __WDPOP_LOG_FUNC_ENTER__;
- __WDPOP_LOG_FUNC_EXIT__;
- return 0;
+ __WFD_APP_FUNC_ENTER__;
+ __WFD_APP_FUNC_EXIT__;
+ return;
}
-static int _app_resume(void *data)
+static void _app_resume(void *data)
{
- __WDPOP_LOG_FUNC_ENTER__;
- __WDPOP_LOG_FUNC_EXIT__;
- return 0;
+ __WFD_APP_FUNC_ENTER__;
+ __WFD_APP_FUNC_EXIT__;
+ return;
}
-static int _app_reset(bundle *b, void *data)
+static void _app_reset(app_control_h control, void *data)
{
- __WDPOP_LOG_FUNC_ENTER__;
+ __WFD_APP_FUNC_ENTER__;
- if (b == NULL) {
- WDPOP_LOGD( "Bundle is NULL");
- return -1;
+ int ret;
+ wfd_appdata_t *ad = (wfd_appdata_t *) data;
+ if (ad == NULL) {
+ WFD_APP_LOG(WFD_APP_LOG_ERROR, "Incorrect parameter\n");
+ return;
+ }
+ if (control == NULL) {
+ WFD_APP_LOG(WFD_APP_LOG_ERROR, "Service is NULL");
+ return;
}
// From Notification
char *noti_type = NULL;
- noti_type = (char *)appsvc_get_data(b, NOTIFICATION_BUNDLE_PARAM);
+ app_control_get_extra_data(control, NOTIFICATION_BUNDLE_PARAM, &noti_type);
if (noti_type == NULL) {
- WDPOP_LOGD( "Notification type is wrong.");
- return -1;
+ WFD_APP_LOG(WFD_APP_LOG_ERROR, "Notification type is wrong.");
+ return;
}
- WDPOP_LOGD( "Notification type is [%s]", noti_type);
+ WFD_APP_LOG(WFD_APP_LOG_LOW, "Notification type is [%s]", noti_type);
if (strncmp(noti_type, NOTIFICATION_BUNDLE_VALUE, strlen(NOTIFICATION_BUNDLE_PARAM)) == 0) {
- WDPOP_LOGD( "Launch wifidirect-ugapp");
- service_h service;
- service_create(&service);
- service_set_operation(service, SERVICE_OPERATION_DEFAULT);
- service_set_package(service, "org.tizen.wifi-direct-ugapp");
- service_send_launch_request(service, NULL, NULL);
- service_destroy(service);
- }
+ WFD_APP_LOG(WFD_APP_LOG_LOW, "Launch wifidirect-ug");
+ wifi_direct_get_state(&ad->wfd_status);
+ WFD_APP_LOG(WFD_APP_LOG_LOW, "State: %d", ad->wfd_status);
+ if (ad->wfd_status == WIFI_DIRECT_STATE_CONNECTED) {
+ WFD_APP_LOG(WFD_APP_LOG_LOW, "Connected");
+ if (ad->transmit_timer) {
+ ecore_timer_del(ad->transmit_timer);
+ ad->transmit_timer = NULL;
+ }
+ WFD_APP_LOG(WFD_APP_LOG_LOW, "start the transmit timer again\n");
+ ad->last_wfd_transmit_time = time(NULL);
+ ad->transmit_timer = ecore_timer_add(5.0,
+ (Ecore_Task_Cb)wfd_automatic_deactivated_for_connection_cb, ad);
+ }
+ app_control_h ug_control;
+ WFD_APP_LOG(WFD_APP_LOG_LOW, "Launching Settings EFL from notification\n");
+ app_control_create(&ug_control);
+ app_control_set_operation(ug_control, APP_CONTROL_OPERATION_DEFAULT);
+ app_control_set_window(ug_control, elm_win_xwindow_get(ug_get_window()));
+ app_control_set_app_id(ug_control, "setting-wifidirect-efl");
+
+ ret = app_control_send_launch_request(ug_control, NULL, NULL);
+ if(ret == APP_CONTROL_ERROR_NONE) {
+ WFD_APP_LOG(WFD_APP_LOG_LOW, "Launch Wi-Fi Direct successful");
+ } else {
+ WFD_APP_LOG(WFD_APP_LOG_ERROR, "Fail to launch Wi-Fi Direct");
+ }
+ app_control_destroy(ug_control);
- __WDPOP_LOG_FUNC_EXIT__;
- return 0;
+ }
+ WFD_IF_FREE_MEM(noti_type);
+ __WFD_APP_FUNC_EXIT__;
+ return;
}
int main(int argc, char *argv[])
{
wfd_appdata_t ad;
- struct appcore_ops ops = {
- .create = _app_create,
- .terminate = _app_terminate,
- .pause = _app_pause,
- .resume = _app_resume,
- .reset = _app_reset,
- };
+ app_event_callback_s event_callback;
+ memset(&event_callback, 0x0, sizeof(app_event_callback_s));
+
+ event_callback.create = _app_create;
+ event_callback.terminate = _app_terminate;
+ event_callback.pause = _app_pause;
+ event_callback.resume = _app_resume;
+ event_callback.app_control = _app_reset;
memset(&ad, 0x0, sizeof(wfd_appdata_t));
- ops.data = &ad;
g_wfd_ad = &ad;
- return appcore_efl_main(PACKAGE, &argc, &argv, &ops);
+ return app_efl_main(&argc, &argv, &event_callback, &ad);
}
diff --git a/popup-wifidirect/src/wfd-app-popup-view.c b/popup-wifidirect/src/wfd-app-popup-view.c
index d6dd497..5682dbf 100755
--- a/popup-wifidirect/src/wfd-app-popup-view.c
+++ b/popup-wifidirect/src/wfd-app-popup-view.c
@@ -1,13 +1,13 @@
/*
* WiFi-Direct UG
*
-* Copyright 2012 Samsung Electronics Co., Ltd
+* Copyright 2012 Samsung Electronics Co., Ltd
-* Licensed under the Flora License, Version 1.1 (the "License");
+* Licensed under the Flora License, Version 1.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
-* http://floralicense.org/license
+* http://www.tizenopensource.org/license
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
@@ -28,20 +28,67 @@
#include <libintl.h>
#include <glib.h>
+#include <Elementary.h>
+#include <efl-assist/efl_assist.h>
+#include <vconf.h>
+#include <X11/Xatom.h>
+#include <X11/Xutil.h>
+#include <Ecore_X.h>
+#include <utilX.h>
#include <notification.h>
-#include <efl_assist.h>
+#include <feedback.h>
+#include <wifi-direct.h>
-#include "wifi-direct.h"
#include "wfd-app.h"
#include "wfd-app-strings.h"
#include "wfd-app-util.h"
+#include "wfd-app-popup-view.h"
extern wfd_appdata_t *g_wfd_ad;
extern wfd_popup_t *g_wfd_pop;
extern unsigned char g_wfd_peer_mac[6];
extern unsigned char g_wfd_peer_name[32];
static Ecore_Timer *pb_timer = NULL;
+static Ecore_Timer *keypad_popup_timer = NULL;
+static int keypad_popup_timeout = 0;
+void _replace_1PS_2PD(char *buf, int buf_len, char *format_str, char* SD_1, int PD_2);
+
+static void mouseup_cb(void *data, Evas *e, Evas_Object *obj, void *event_info)
+{
+ Evas_Event_Mouse_Up *ev = event_info;
+ if (ev->button == 3) {
+ evas_object_del(obj);
+ }
+}
+
+/*static void keydown_cb(void *data, Evas *e, Evas_Object *obj, void *event_info)
+{
+ Evas_Event_Key_Down *ev = event_info;
+ if (!strcmp(ev->keyname, KEY_BACK)) {
+ evas_object_del(obj);
+ }
+}*/
+static Eina_Bool __rotate(void *data, int type, void *event)
+{
+ __WFD_APP_FUNC_ENTER__;
+ wfd_appdata_t *ad = (wfd_appdata_t *)data;
+ Ecore_X_Event_Client_Message *ev = event;
+ int rots[4] = {0, 90, 180, 270};
+
+ if (ad == NULL || ad->win == NULL) {
+ WFD_APP_LOG(WFD_APP_LOG_ERROR, "Parameter NULL");
+ return EINA_FALSE;
+ }
+
+ if (ev->message_type == ECORE_X_ATOM_E_ILLUME_ROTATE_ROOT_ANGLE) {
+ WFD_APP_LOG(WFD_APP_LOG_LOW, "ev->message_type: [%d]\n", ev->message_type);
+ elm_win_wm_rotation_available_rotations_set(ad->win, rots, 1);
+ }
+
+ __WFD_APP_FUNC_EXIT__;
+ return EINA_FALSE;
+}
/**
* This function let the ug make a callback for click the button in popup
@@ -52,151 +99,108 @@ static Ecore_Timer *pb_timer = NULL;
*/
static void __popup_resp_cb(void *data, Evas_Object * obj, void *event_info)
{
- __WDPOP_LOG_FUNC_ENTER__;
+ __WFD_APP_FUNC_ENTER__;
wfd_appdata_t *ad = wfd_get_appdata();
+ wfd_connection_info_s *connection = ad->connection;
int result = -1;
int resp = (int) data;
char msg[WFD_POP_STR_MAX_LEN] = {0};
- WDPOP_LOGI( "popup resp : %d\n", resp);
+ WFD_APP_LOG(WFD_APP_LOG_HIGH, "popup resp : %d\n", resp);
+
+ if (ad->rotate_event_handler) {
+ ecore_event_handler_del(ad->rotate_event_handler);
+ ad->rotate_event_handler = NULL;
+ }
switch (resp) {
case /* MT */ WFD_POP_RESP_APRV_CONNECT_PBC_YES:
{
- WDPOP_LOGI(
+ WFD_APP_LOG(WFD_APP_LOG_HIGH,
"WFD_POP_RESP_APRV_CONNECT_PBC_YES\n");
wfd_destroy_popup();
- result = wifi_direct_accept_connection(ad->peer_mac);
- WDPOP_LOGD(
- "wifi_direct_accept_connection() result=[%d]\n",
- result);
- if (result == WIFI_DIRECT_ERROR_NONE) {
- /* tickernoti popup */
- notification_status_message_post(_("IDS_WFD_POP_CONNECTING"));
- } else {
- WDPOP_LOGE(
- "wifi_direct_accept_connection() FAILED!!\n");
+ result = wifi_direct_accept_connection(connection->peer_addr);
+ if (result != WIFI_DIRECT_ERROR_NONE) {
+ WFD_APP_LOG(WFD_APP_LOG_ERROR, "Failed to accept connection(%d)", result);
evas_object_hide(ad->win);
/* tickernoti popup */
- snprintf(msg, WFD_POP_STR_MAX_LEN, IDS_WFD_POP_CONNECT_FAILED, ad->peer_name);
+ snprintf(msg, WFD_POP_STR_MAX_LEN, _("IDS_WIFI_POP_FAILED_TO_CONNECT_TO_PS"),
+ connection->peer_name);
notification_status_message_post(msg);
}
+ WFD_APP_LOG(WFD_APP_LOG_LOW, "Succeeded to accept connection");
}
break;
- case WFD_POP_RESP_APRV_CONNECT_INVITATION_YES:
- WDPOP_LOGI(
- "WFD_POP_RESP_APRV_CONNECT_INVITATION_YES [" MACSTR "]\n", MAC2STR(ad->peer_mac));
- wfd_destroy_popup();
-
- result = wifi_direct_connect(ad->peer_mac);
- WDPOP_LOGD(
- "wifi_direct_connect() result=[%d]\n",
- result);
- if (result == WIFI_DIRECT_ERROR_NONE) {
- /* tickernoti popup */
- notification_status_message_post(_("IDS_WFD_POP_CONNECTING"));
- } else {
- WDPOP_LOGE(
- "wifi_direct_connect() FAILED!!\n");
- evas_object_hide(ad->win);
-
- /* tickernoti popup */
- snprintf(msg, WFD_POP_STR_MAX_LEN, IDS_WFD_POP_CONNECT_FAILED, ad->peer_name);
- notification_status_message_post(msg);
- }
-
- break;
-
case /* MT */ WFD_POP_RESP_APRV_CONNECT_DISPLAY_OK:
{
- char *pin = NULL;
-
- WDPOP_LOGI(
+ WFD_APP_LOG(WFD_APP_LOG_HIGH,
"WFD_POP_RESP_APRV_CONNECT_DISPLAY_OK\n");
wfd_destroy_popup();
- if (wifi_direct_generate_wps_pin() != WIFI_DIRECT_ERROR_NONE) {
- WDPOP_LOGD( "wifi_direct_generate_wps_pin() is failed\n");
- return;
- }
-
- if (wifi_direct_get_wps_pin(&pin) != WIFI_DIRECT_ERROR_NONE) {
- WDPOP_LOGD( "wifi_direct_generate_wps_pin() is failed\n");
- return;
- }
-
- strncpy(ad->pin_number, pin, 64);
- ad->pin_number[63] = '\0';
- free(pin);
- pin = NULL;
- WDPOP_LOGD( "button ok: pin [%s]", ad->pin_number);
-
- result = wifi_direct_accept_connection(ad->peer_mac);
+ result = wifi_direct_accept_connection(connection->peer_addr);
if (result == WIFI_DIRECT_ERROR_NONE) {
wfd_prepare_popup(WFD_POP_PROG_CONNECT_WITH_PIN, NULL);
} else {
- WDPOP_LOGD(
+ WFD_APP_LOG(WFD_APP_LOG_LOW,
"wifi_direct_accept_connection() failed. result=[%d]\n", result);
/* tickernoti popup */
- snprintf(msg, WFD_POP_STR_MAX_LEN, IDS_WFD_POP_CONNECT_FAILED, ad->peer_name);
- notification_status_message_post(msg);
+ notification_status_message_post(_("IDS_WIFI_POP_FAILED_TO_CONNECT_TO_PS"));
}
}
break;
case /* MO */ WFD_POP_RESP_PROG_CONNECT_KEYPAD_OK:
{
- WDPOP_LOGI(
+ int result = 0;
+ WFD_APP_LOG(WFD_APP_LOG_HIGH,
"WFD_POP_RESP_PROG_CONNECT_KEYPAD_OK\n");
wfd_destroy_popup();
- int len = strlen(ad->pin_number);
- WDPOP_LOGD( "button ok: pin [%s]", ad->pin_number);
+ int len = strlen(connection->wps_pin);
+ WFD_APP_LOGSECURE(WFD_APP_LOG_LOW, "PIN [%s]", connection->wps_pin);
- if (len != 8) {
- if (len > 8)
- notification_status_message_post(_("IDS_CST_BODY_PASSWORD_TOO_LONG"));
- else
- notification_status_message_post(_("IDS_ST_BODY_PASSWORD_TOO_SHORT"));
+ if (len < 8 || len > 64) {
+ WFD_APP_LOG(WFD_APP_LOG_ERROR, "Error, Incorrect PIN!!\n");
+ keypad_popup_timeout--;
+ /* tickernoti popup */
+ notification_status_message_post(_("IDS_COM_BODY_PINS_DO_NOT_MATCH"));
+
+ /* redraw the popup */
wfd_prepare_popup(WFD_POP_PROG_CONNECT_WITH_KEYPAD, (void *) NULL);
- return;
+ break;
}
+ keypad_popup_timeout = 0;
- int result = 0;
- WDPOP_LOGD( "pin=[%s]\n", ad->pin_number);
-
- result = wifi_direct_set_wps_pin(ad->pin_number);
+ result = wifi_direct_set_wps_pin(connection->wps_pin);
if (result != WIFI_DIRECT_ERROR_NONE) {
/* tickernoti popup */
- snprintf(msg, WFD_POP_STR_MAX_LEN, IDS_WFD_POP_CONNECT_FAILED, ad->peer_name);
+ snprintf(msg, WFD_POP_STR_MAX_LEN, _("IDS_WIFI_POP_FAILED_TO_CONNECT_TO_PS"),
+ connection->peer_name);
notification_status_message_post(msg);
return;
}
- //result = wifi_direct_activate_pushbutton();
- result = wifi_direct_accept_connection(ad->peer_mac);
- WDPOP_LOGD(
- "wifi_direct_accept_connection(%s) result=[%d]\n",
- ad->peer_mac, result);
+ result = wifi_direct_accept_connection(connection->peer_addr);
if (result != WIFI_DIRECT_ERROR_NONE) {
- WDPOP_LOGE(
- "wifi_direct_accept_connection() FAILED!!\n");
+ WFD_APP_LOG(WFD_APP_LOG_ERROR, "Failed to accept connection(%d)", result);
evas_object_hide(ad->win);
/* tickernoti popup */
- snprintf(msg, WFD_POP_STR_MAX_LEN, IDS_WFD_POP_CONNECT_FAILED, ad->peer_name);
+ snprintf(msg, WFD_POP_STR_MAX_LEN, _("IDS_WIFI_POP_FAILED_TO_CONNECT_TO_PS"),
+ connection->peer_name);
notification_status_message_post(msg);
}
+ WFD_APP_LOG(WFD_APP_LOG_LOW, "Succeeded to connect with [%s]", connection->peer_addr);
}
break;
case /* MT */ WFD_POP_RESP_APRV_CONNECT_KEYPAD_YES:
{
- WDPOP_LOGI(
+ WFD_APP_LOG(WFD_APP_LOG_HIGH,
"WFD_POP_RESP_APRV_CONNECT_KEYPAD_YES\n");
wfd_destroy_popup();
if (pb_timer) {
@@ -210,31 +214,36 @@ static void __popup_resp_cb(void *data, Evas_Object * obj, void *event_info)
case /* MT */ WFD_POP_RESP_APRV_CONNECT_NO:
{
- WDPOP_LOGI(
+ WFD_APP_LOG(WFD_APP_LOG_HIGH,
"WFD_POP_RESP_APRV_CONNECT_NO: destroy_popup...\n");
- wfd_destroy_popup();
+ if (connection->peer_addr[0] != '\0') {
+ result = wifi_direct_reject_connection(connection->peer_addr);
+ if (result != WIFI_DIRECT_ERROR_NONE)
+ WFD_APP_LOG(WFD_APP_LOG_ERROR, "Failed to reject connection(%d)", result);
+ } else {
+ WFD_APP_LOG(WFD_APP_LOG_ERROR, "Peer's address is Zero MAC");
+ }
+
if (pb_timer) {
ecore_timer_del(pb_timer);
pb_timer = NULL;
}
- result = wifi_direct_disconnect(ad->peer_mac);
- WDPOP_LOGD(
- "wifi_direct_disconnect[%s] result=[%d]\n",
- ad->peer_mac, result);
+ wfd_destroy_popup();
+ keypad_popup_timeout = 0;
}
break;
default:
{
- WDPOP_LOGE( "Unknown respone\n");
- evas_object_hide(ad->win);
+ WFD_APP_LOG(WFD_APP_LOG_ERROR, "Unknown respone\n");
+ wfd_destroy_popup();
}
break;
}
- __WDPOP_LOG_FUNC_EXIT__;
+ __WFD_APP_FUNC_EXIT__;
}
/**
@@ -244,14 +253,19 @@ static void __popup_resp_cb(void *data, Evas_Object * obj, void *event_info)
*/
void wfd_destroy_popup()
{
- __WDPOP_LOG_FUNC_ENTER__;
+ __WFD_APP_FUNC_ENTER__;
wfd_appdata_t *ad = wfd_get_appdata();
if (ad == NULL) {
- WDPOP_LOGE( "ad is NULL\n");
+ WFD_APP_LOG(WFD_APP_LOG_ERROR, "ad is NULL\n");
return;
}
+ if (keypad_popup_timer) {
+ ecore_timer_del(keypad_popup_timer);
+ keypad_popup_timer = NULL;
+ }
+
if (ad->popup) {
evas_object_del(ad->popup);
ad->popup = NULL;
@@ -262,9 +276,121 @@ void wfd_destroy_popup()
ad->popup_timeout_handle = 0;
}
- evas_object_hide(ad->win);
+ if (ad->win) {
+ evas_object_hide(ad->win);
+ }
- __WDPOP_LOG_FUNC_EXIT__;
+ if (pb_timer) {
+ ecore_timer_del(pb_timer);
+ pb_timer = NULL;
+ }
+ __WFD_APP_FUNC_EXIT__;
+ return;
+}
+
+static int __get_window_property(Display *dpy, Window win, Atom atom,
+ Atom type, unsigned int *val, unsigned int len)
+{
+ __WFD_APP_FUNC_ENTER__;
+ unsigned char *prop_ret = NULL;
+ Atom type_ret = -1;
+ unsigned long bytes_after = 0;
+ unsigned long num_ret = -1;
+ int format_ret = -1;
+ unsigned int i = 0;
+ int num = 0;
+
+ prop_ret = NULL;
+ if (XGetWindowProperty(dpy, win, atom, 0, 0x7fffffff, False,
+ type, &type_ret, &format_ret, &num_ret,
+ &bytes_after, &prop_ret) != Success) {
+ return -1;
+ }
+
+ if (type_ret != type || format_ret != 32) {
+ num = -1;
+ } else if (num_ret == 0 || !prop_ret) {
+ num = 0;
+ } else {
+ if (num_ret < len) {
+ len = num_ret;
+ }
+ for (i = 0; i < len; i++) {
+ val[i] = ((unsigned long *)prop_ret)[i];
+ }
+ num = len;
+ }
+
+ if (prop_ret) {
+ XFree(prop_ret);
+ }
+
+ __WFD_APP_FUNC_EXIT__;
+ return num;
+}
+
+static int __x_rotation_get(Display *dpy, void* win)
+{
+ __WFD_APP_FUNC_ENTER__;
+ Window active_win = 0;
+ Window root_win = 0;
+ int rotation = -1;
+ int ret = -1;
+
+ Atom atom_active_win;
+ Atom atom_win_rotate_angle;
+
+ root_win = XDefaultRootWindow(dpy);
+
+ atom_active_win = XInternAtom(dpy, "_NET_ACTIVE_WINDOW", False);
+ ret = __get_window_property(dpy, root_win, atom_active_win,
+ XA_WINDOW, (unsigned int *)&active_win, 1);
+
+ if (ret != 1) {
+ return 0;
+ }
+
+ atom_win_rotate_angle =
+ XInternAtom(dpy, "_E_ILLUME_ROTATE_WINDOW_ANGLE", False);
+ ret = __get_window_property(dpy, active_win ,
+ atom_win_rotate_angle, XA_CARDINAL,
+ (unsigned int *)&rotation, 1);
+
+ __WFD_APP_FUNC_EXIT__;
+
+ if (ret == 1) {
+ return rotation;
+ } else {
+ return 0;
+ }
+}
+void __set_parent_rotate_angle(wfd_appdata_t *ad)
+{
+ __WFD_APP_FUNC_ENTER__;
+
+ int rotate_angle = 0;
+ int rots1[1] = {0};
+ int rots2[4] = {0, 90, 180, 270};
+
+ if (ad == NULL || ad->win == NULL) {
+ WFD_APP_LOG(WFD_APP_LOG_ERROR, "Parameter NULL");
+ return;
+ }
+
+ rotate_angle = __x_rotation_get(ecore_x_display_get(), NULL);
+ WFD_APP_LOG(WFD_APP_LOG_LOW, "rotate_angle: [%d]\n", rotate_angle);
+
+ if (rotate_angle < 0) {
+ rotate_angle = 0;
+ }
+
+ if (rotate_angle == 0) {
+ elm_win_wm_rotation_available_rotations_set(ad->win, rots1, 1);
+ } else {
+ elm_win_wm_rotation_available_rotations_set(ad->win, rots2, 1);
+ }
+
+ __WFD_APP_FUNC_EXIT__;
return;
}
@@ -276,18 +402,24 @@ void wfd_destroy_popup()
*/
static Evas_Object *wfd_draw_pop_type_a(Evas_Object * win, wfd_popup_t * pop)
{
- __WDPOP_LOG_FUNC_ENTER__;
+ __WFD_APP_FUNC_ENTER__;
+
+ wfd_appdata_t *ad = wfd_get_appdata();
Evas_Object *popup;
popup = elm_popup_add(win);
- ea_object_event_callback_add(popup, EA_CALLBACK_BACK, ea_popup_back_cb, NULL);
+ ea_object_event_callback_add(popup, EA_CALLBACK_BACK, __popup_resp_cb, NULL);
+ evas_object_event_callback_add(popup, EVAS_CALLBACK_MOUSE_UP, mouseup_cb, ad);
+// evas_object_event_callback_add(popup, EVAS_CALLBACK_KEY_DOWN, keydown_cb, ad);
evas_object_size_hint_weight_set(popup, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
- elm_object_text_set(popup, pop->text);
+ elm_object_domain_translatable_text_set(popup, PACKAGE, pop->text);
elm_popup_timeout_set(popup, pop->timeout);
+ __set_parent_rotate_angle(ad);
evas_object_show(popup);
evas_object_show(win);
+ ad->rotate_event_handler = ecore_event_handler_add(ECORE_X_EVENT_CLIENT_MESSAGE, __rotate, ad);
- __WDPOP_LOG_FUNC_EXIT__;
+ __WFD_APP_FUNC_EXIT__;
return popup;
}
@@ -299,25 +431,30 @@ static Evas_Object *wfd_draw_pop_type_a(Evas_Object * win, wfd_popup_t * pop)
*/
static Evas_Object *wfd_draw_pop_type_b(Evas_Object * win, wfd_popup_t * pop)
{
- __WDPOP_LOG_FUNC_ENTER__;
+ __WFD_APP_FUNC_ENTER__;
Evas_Object *popup = NULL;
Evas_Object *btn = NULL;
+ wfd_appdata_t *ad = wfd_get_appdata();
popup = elm_popup_add(win);
+ ea_object_event_callback_add(popup, EA_CALLBACK_BACK, __popup_resp_cb, (void *) pop->resp_data1);
+ evas_object_event_callback_add(popup, EVAS_CALLBACK_MOUSE_UP, mouseup_cb, ad);
+// evas_object_event_callback_add(popup, EVAS_CALLBACK_KEY_DOWN, keydown_cb, ad);
evas_object_size_hint_weight_set(popup, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
- elm_object_text_set(popup, pop->text);
+ elm_object_domain_translatable_text_set(popup, PACKAGE, pop->text);
btn = elm_button_add(popup);
- elm_object_style_set(btn, "popup_button/default");
- elm_object_text_set(btn, pop->label1);
+ elm_object_style_set(btn, "popup");
+ elm_object_domain_translatable_text_set(btn, PACKAGE, pop->label1);
elm_object_part_content_set(popup, "button1", btn);
evas_object_smart_callback_add(btn, "clicked", __popup_resp_cb, (void *) pop->resp_data1);
- ea_object_event_callback_add(popup, EA_CALLBACK_BACK, __popup_resp_cb, (void*) pop->resp_data1);
+ __set_parent_rotate_angle(ad);
evas_object_show(popup);
evas_object_show(win);
+ ad->rotate_event_handler = ecore_event_handler_add(ECORE_X_EVENT_CLIENT_MESSAGE, __rotate, ad);
- __WDPOP_LOG_FUNC_EXIT__;
+ __WFD_APP_FUNC_EXIT__;
return popup;
}
@@ -329,88 +466,132 @@ static Evas_Object *wfd_draw_pop_type_b(Evas_Object * win, wfd_popup_t * pop)
*/
static Evas_Object *wfd_draw_pop_type_c(Evas_Object * win, wfd_popup_t * pop)
{
- __WDPOP_LOG_FUNC_ENTER__;
+ __WFD_APP_FUNC_ENTER__;
Evas_Object *popup = NULL;
Evas_Object *btn1 = NULL, *btn2 = NULL;
+ wfd_appdata_t *ad = wfd_get_appdata();
popup = elm_popup_add(win);
+ ea_object_event_callback_add(popup, EA_CALLBACK_BACK, __popup_resp_cb, (void *) pop->resp_data2);
+ evas_object_event_callback_add(popup, EVAS_CALLBACK_MOUSE_UP, mouseup_cb, ad);
+// evas_object_event_callback_add(popup, EVAS_CALLBACK_KEY_DOWN, keydown_cb, ad);
evas_object_size_hint_weight_set(popup, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
- elm_object_text_set(popup, pop->text);
+ elm_object_domain_translatable_part_text_set(popup, "title,text",
+ PACKAGE, _("IDS_WIFI_HEADER_WI_FI_DIRECT_CONNECTION_ABB"));
+ elm_object_domain_translatable_text_set(popup, PACKAGE, pop->text);
btn1 = elm_button_add(popup);
- elm_object_style_set(btn1, "popup_button/default");
- elm_object_text_set(btn1, pop->label1);
+ elm_object_style_set(btn1, "popup");
+ elm_object_domain_translatable_text_set(btn1, PACKAGE, pop->label2);
elm_object_part_content_set(popup, "button1", btn1);
evas_object_smart_callback_add(btn1, "clicked", __popup_resp_cb,
- (void*) pop->resp_data1);
- ea_object_event_callback_add(popup, EA_CALLBACK_BACK, __popup_resp_cb,
- (void*) pop->resp_data1);
+ (void *) pop->resp_data2);
btn2 = elm_button_add(popup);
- elm_object_style_set(btn2, "popup_button/default");
- elm_object_text_set(btn2, pop->label2);
+ elm_object_style_set(btn2, "popup");
+ elm_object_domain_translatable_text_set(btn2, PACKAGE, pop->label1);
elm_object_part_content_set(popup, "button2", btn2);
evas_object_smart_callback_add(btn2, "clicked", __popup_resp_cb,
- (void*) pop->resp_data2);
+ (void *) pop->resp_data1);
+
+ __set_parent_rotate_angle(ad);
evas_object_show(popup);
evas_object_show(win);
+ ad->rotate_event_handler = ecore_event_handler_add(ECORE_X_EVENT_CLIENT_MESSAGE, __rotate, ad);
- __WDPOP_LOG_FUNC_EXIT__;
+ __WFD_APP_FUNC_EXIT__;
return popup;
}
-/**
- * This function let the ug make a change callback for password input
- * @return void
- * @param[in] data the pointer to the main data structure
- * @param[in] obj the pointer to the evas object
- * @param[in] event_info the pointer to the event information
- */
-static void _smart_ime_cb(void *data, Evas_Object * obj, void *event_info)
+static void _wfd_ug_automatic_turn_off_popup_cb(void *data, Evas_Object *obj, void *event_info)
{
- __WDPOP_LOG_FUNC_ENTER__;
+ __WFD_APP_FUNC_ENTER__;
wfd_appdata_t *ad = wfd_get_appdata();
- Ecore_IMF_Context *imf_context = NULL;
- imf_context = (Ecore_IMF_Context *) ad->pin_entry;
+ if (ad->popup) {
+ evas_object_del(ad->popup);
+ ad->popup = NULL;
+ }
- if (NULL == imf_context) {
- WDPOP_LOGE( "Error!!! Ecore_IMF_Context is NULL!!");
- return;
+ if (ad->rotate_event_handler) {
+ ecore_event_handler_del(ad->rotate_event_handler);
+ ad->rotate_event_handler = NULL;
}
- const char *txt = elm_entry_markup_to_utf8(elm_entry_entry_get((const Evas_Object *) imf_context));
- if (NULL != txt) {
- WDPOP_LOGD( "* text [%s], len=[%d]", txt, strlen(txt));
- strncpy(ad->pin_number, txt, 64);
- ad->pin_number[63] = '\0';
- free(txt);
- } else {
- WDPOP_LOGD( "Err!");
+ if (ad->win) {
+ evas_object_hide(ad->win);
}
- __WDPOP_LOG_FUNC_EXIT__;
+ __WFD_APP_FUNC_EXIT__;
+}
+
+Evas_Object *wfd_draw_pop_type_auto_deactivation(Evas_Object *win, void *userdata)
+{
+ __WFD_APP_FUNC_ENTER__;
+
+ Evas_Object *popup = NULL;
+ Evas_Object *btn = NULL;
+ char popup_text[MAX_POPUP_TEXT_SIZE] = {0};
+ wfd_appdata_t *ad = wfd_get_appdata();
+
+ popup = elm_popup_add(win);
+ ea_object_event_callback_add(popup, EA_CALLBACK_BACK, _wfd_ug_automatic_turn_off_popup_cb, userdata);
+ evas_object_event_callback_add(popup, EVAS_CALLBACK_MOUSE_UP, mouseup_cb, ad);
+// evas_object_event_callback_add(popup, EVAS_CALLBACK_KEY_DOWN, keydown_cb, ad);
+ evas_object_size_hint_weight_set(popup, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
+ elm_object_domain_translatable_part_text_set(popup, "title,text",
+ PACKAGE, "IDS_WIFI_BODY_WI_FI_DIRECT_ABB");
+ snprintf(popup_text, MAX_POPUP_TEXT_SIZE,
+ "IDS_WIFI_POP_THERE_HAS_BEEN_NO_ACTIVITY_FOR_PD_MINUTES_SINCE_WI_FI_DIRECT_WAS_ENABLED_MSG", 5);
+ elm_object_domain_translatable_text_set(popup, PACKAGE, popup_text);
+
+ btn = elm_button_add(popup);
+ elm_object_style_set(btn, "popup");
+ elm_object_domain_translatable_text_set(btn, PACKAGE, "IDS_BR_SK_OK");
+ elm_object_part_content_set(popup, "button1", btn);
+ evas_object_smart_callback_add(btn, "clicked", _wfd_ug_automatic_turn_off_popup_cb, userdata);
+
+ __set_parent_rotate_angle(ad);
+ evas_object_show(popup);
+ evas_object_show(win);
+ ad->rotate_event_handler = ecore_event_handler_add(ECORE_X_EVENT_CLIENT_MESSAGE, __rotate, ad);
+
+ __WFD_APP_FUNC_EXIT__;
+ return popup;
}
/**
- * This function let the app make a change callback for password checkbox
+ * This function let the ug make a change callback for password input
* @return void
* @param[in] data the pointer to the main data structure
* @param[in] obj the pointer to the evas object
* @param[in] event_info the pointer to the event information
*/
-static void _check_changed_cb(void *data, Evas_Object * obj, void *event_info)
+static void _smart_ime_cb(void *data, Evas_Object * obj, void *event_info)
{
+ __WFD_APP_FUNC_ENTER__;
wfd_appdata_t *ad = wfd_get_appdata();
+ wfd_connection_info_s *connection = ad->connection;
+
+ Ecore_IMF_Context *imf_context = NULL;
+ imf_context = (Ecore_IMF_Context *) ad->pin_entry;
- if (obj == NULL) {
+ if (NULL == imf_context) {
+ WFD_APP_LOG(WFD_APP_LOG_ERROR, "Error!!! Ecore_IMF_Context is NULL!!");
return;
}
- Eina_Bool state = elm_check_state_get(obj);
- elm_entry_password_set(ad->pin_entry, !state);
- elm_entry_autocapital_type_set(ad->pin_entry, ELM_AUTOCAPITAL_TYPE_NONE);
+ char *txt = elm_entry_markup_to_utf8(elm_entry_entry_get((const Evas_Object *) imf_context));
+ if (NULL != txt) {
+ WFD_APP_LOG(WFD_APP_LOG_LOW, "* text [%s], len=[%d]", txt, strlen(txt));
+ strncpy(connection->wps_pin, txt, sizeof(connection->wps_pin) - 1);
+ WFD_IF_FREE_MEM(txt);
+ } else {
+ WFD_APP_LOG(WFD_APP_LOG_LOW, "Err!");
+ }
+
+ __WFD_APP_FUNC_EXIT__;
}
/**
@@ -426,7 +607,7 @@ static Eina_Bool _fn_pb_timer(void *data)
wfd_wps_display_popup_t *wps_display_popup = (wfd_wps_display_popup_t *) data;
if (NULL == wps_display_popup) {
- WDPOP_LOGE( "Param is NULL.\n");
+ WFD_APP_LOG(WFD_APP_LOG_ERROR, "Param is NULL.\n");
return ECORE_CALLBACK_CANCEL;
}
@@ -437,8 +618,12 @@ static Eina_Bool _fn_pb_timer(void *data)
time = wps_display_popup->time;
value = elm_progressbar_value_get(progressbar);
+ wps_display_popup->step++;
+ step = wps_display_popup->step;
+ value = ((double)step) / WFD_POP_TIMER_120;
+
if (value >= 1.0) {
- WDPOP_LOGE( "Progress end.\n");
+ WFD_APP_LOG(WFD_APP_LOG_LOW, "Progress end.\n");
if (pb_timer) {
ecore_timer_del(pb_timer);
pb_timer = NULL;
@@ -447,11 +632,8 @@ static Eina_Bool _fn_pb_timer(void *data)
return ECORE_CALLBACK_CANCEL;
}
- wps_display_popup->step++;
- step = wps_display_popup->step;
- value = ((double)step) / WFD_POP_TIMER_120;
elm_progressbar_value_set(progressbar, value);
- WDPOP_LOGD( "step: %d, value: %f\n", wps_display_popup->step, value);
+ WFD_APP_LOG(WFD_APP_LOG_LOW, "step: %d, value: %f\n", wps_display_popup->step, value);
/* show the time label */
if (step < 60) {
@@ -468,11 +650,90 @@ static Eina_Bool _fn_pb_timer(void *data)
}
}
- elm_object_text_set(time, time_label);
+ char *remaining_time_str = g_strdup_printf(
+ "<font_size=40><align=center>%s</align></font_size>", time_label);
+ elm_object_text_set(time, remaining_time_str);
+ g_free(remaining_time_str);
+
+ return ECORE_CALLBACK_RENEW;
+}
+
+static Eina_Bool _keypad_popup_timer_cb(void *data)
+{
+ __WFD_APP_FUNC_ENTER__;
+
+ char msg1[WFD_POP_STR_MAX_LEN] = {0};
+ char msg2[WFD_POP_STR_MAX_LEN] = {0};
+
+ Evas_Object *label = (Evas_Object*) data;
+ wfd_appdata_t *ad = wfd_get_appdata();
+ wfd_connection_info_s *connection = ad->connection;
+ WFD_RETV_IF(NULL == ad, FALSE, "NULL parameters(ad)\n");
+ WFD_RETV_IF(NULL == label, FALSE, "NULL parameters(label)\n");
+ if (NULL == ad->popup) {
+ keypad_popup_timeout = 0;
+ return ECORE_CALLBACK_CANCEL;
+ }
+
+ keypad_popup_timeout --;
+
+ if (keypad_popup_timeout > 0) {
+ _replace_1PS_2PD((char *)msg1, sizeof(msg1),
+ _("IDS_ST_BODY_CONNECT_WITH_PS_IN_PD_SECS_ABB"),
+ connection->peer_name, keypad_popup_timeout);
+
+ strcat(msg1, " ");
+ snprintf(msg2, sizeof(msg2), _("IDS_WIFI_POP_ENTER_PIN_TO_CONNECT_TO_PS"),
+ connection->peer_name);
+ strcat(msg1, msg2);
+ elm_object_domain_translatable_text_set(label, PACKAGE, msg1);
+ }
+
+ if (keypad_popup_timeout <= 0) {
+ wfd_destroy_popup();
+ keypad_popup_timeout = 0;
+ __WFD_APP_FUNC_EXIT__;
+ return ECORE_CALLBACK_CANCEL;
+ }
+
+ __WFD_APP_FUNC_EXIT__;
return ECORE_CALLBACK_RENEW;
}
+/* This callback is for showing(hiding) X marked button. */
+/*static void _changed_cb(void *data, Evas_Object *obj, void *event_info)
+{
+ if (elm_object_focus_get(obj)) {
+ if (elm_entry_is_empty(obj))
+ elm_object_signal_emit(data, "elm,state,eraser,hide", "");
+ else
+ elm_object_signal_emit(data, "elm,state,eraser,show", "");
+ }
+}*/
+
+/* Focused callback will show X marked button and hide guidetext. */
+/*static void _focused_cb(void *data, Evas_Object *obj, void *event_info)
+{
+ if (!elm_entry_is_empty(obj))
+ elm_object_signal_emit(data, "elm,state,eraser,show", "");
+ elm_object_signal_emit(data, "elm,state,rename,hide", "");
+}*/
+
+/* Unfocused callback will show guidetext and hide X marked button. */
+/*static void _unfocused_cb(void *data, Evas_Object *obj, void *event_info)
+{
+ elm_object_signal_emit(data, "elm,state,eraser,hide", "");
+ elm_object_signal_emit(data, "elm,state,rename,show", "");
+}*/
+
+/* When X marked button clicked, make string as empty. */
+/*static void _eraser_btn_clicked_cb(void *data, Evas_Object *obj, void *event_info)
+{
+ elm_object_focus_set(data, EINA_TRUE);
+ elm_entry_entry_set(data, "");
+}*/
+
/**
* This function let the app create a edit filed
* @return edit filed
@@ -482,7 +743,7 @@ static Eina_Bool _fn_pb_timer(void *data)
* @param[in] single_line whether it can support single line
* @param[in] is_editable whether it is avaliable to edit
*/
-static Evas_Object *_add_edit_field(Evas_Object *parent, const char *title, const char *guide, Eina_Bool single_line, Eina_Bool is_editable)
+/*static Evas_Object *_add_edit_field(Evas_Object *parent, const char *title, const char *guide, Eina_Bool single_line, Eina_Bool is_editable)
{
assertm_if(NULL == parent, "parent is NULL!!");
@@ -490,30 +751,36 @@ static Evas_Object *_add_edit_field(Evas_Object *parent, const char *title, cons
assertm_if(NULL == layout, "layout is NULL!!");
if (title && title[0] != '\0') {
- elm_layout_theme_set(layout, "layout", "editfield", "title");
+ elm_layout_theme_set(layout, "layout", "dialogue/editfield/title", "default");
elm_object_part_text_set(layout, "elm.text", title);
} else {
- elm_layout_theme_set(layout, "layout", "editfield", "default");
+ elm_layout_theme_set(layout, "layout", "dialogue/editfield", "default");
}
- Evas_Object *entry = elm_entry_add(parent);
+ Evas_Object *entry = elm_entry_add(layout);
assertm_if(NULL == entry, "entry is NULL!!");
- elm_object_part_content_set(layout, "elm.swallow.content", entry);
- evas_object_size_hint_weight_set(layout, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
-
if (guide && guide[0] != '\0') {
elm_object_part_text_set(layout, "elm.guidetext", guide);
}
+ evas_object_smart_callback_add(entry, "changed", _changed_cb, layout);
+ evas_object_smart_callback_add(entry, "focused", _focused_cb, layout);
+ evas_object_smart_callback_add(entry, "unfocused", _unfocused_cb, layout);
+
+ elm_object_part_content_set(layout, "elm.icon.entry", entry);
+ evas_object_size_hint_weight_set(layout, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
+ evas_object_size_hint_align_set(layout, EVAS_HINT_FILL, EVAS_HINT_FILL);
+
elm_entry_single_line_set(entry, single_line);
elm_entry_scrollable_set(entry, single_line);
- elm_entry_editable_set(entry, is_editable);
- elm_object_signal_emit(layout, "elm,state,eraser,hide", "elm");
- evas_object_show(layout);
+ Evas_Object *button = elm_button_add(parent);
+ elm_object_style_set(button, "editfield_clear");
+ elm_object_part_content_set(layout, "elm.icon.eraser", button);
+ evas_object_smart_callback_add(button, "clicked", _eraser_btn_clicked_cb, entry);
return layout;
-}
+}*/
/**
* This function let the app create a display popup
@@ -523,221 +790,502 @@ static Evas_Object *_add_edit_field(Evas_Object *parent, const char *title, cons
*/
Evas_Object *wfd_draw_pop_type_display(Evas_Object * win, wfd_popup_t * pop)
{
- __WDPOP_LOG_FUNC_ENTER__;
+ __WFD_APP_FUNC_ENTER__;
+ WFD_APP_LOG(WFD_APP_LOG_LOW, "wfd_draw_pop_type_display\n");
Evas_Object *popup = NULL;
- Evas_Object *label = NULL;
Evas_Object *progressbar = NULL;
Evas_Object *time = NULL;
+ Evas_Object *layout;
static wfd_wps_display_popup_t wps_display_popup;
+ wfd_appdata_t *ad = wfd_get_appdata();
popup = elm_popup_add(win);
+ evas_object_event_callback_add(popup, EVAS_CALLBACK_MOUSE_UP, mouseup_cb, ad);
+// evas_object_event_callback_add(popup, EVAS_CALLBACK_KEY_DOWN, keydown_cb, ad);
evas_object_size_hint_weight_set(popup, EVAS_HINT_EXPAND, 0.0);
+ elm_object_domain_translatable_part_text_set(popup, "title,text",
+ PACKAGE, _("IDS_WIFI_HEADER_WI_FI_DIRECT_CONNECTION_ABB"));
- Evas_Object *box = elm_box_add(popup);
- if (!box) {
- evas_object_del(popup);
- popup = NULL;
+ layout = elm_layout_add(popup);
+ if (layout == NULL) {
+ WFD_APP_LOG(WFD_APP_LOG_LOW, "Layout failed so returning !!");
return NULL;
}
- evas_object_size_hint_weight_set(box, EVAS_HINT_EXPAND, 0.0);
- evas_object_size_hint_align_set(box, EVAS_HINT_FILL, 0.0);
- elm_object_part_content_set(popup, NULL, box);
- evas_object_show(box);
-
- /* add label */
- label = elm_label_add(box);
- elm_object_style_set(label, "popup/default");
- elm_label_line_wrap_set(label, ELM_WRAP_MIXED);
- elm_object_text_set(label, pop->text);
- evas_object_size_hint_weight_set(label, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
- evas_object_size_hint_align_set(label, EVAS_HINT_FILL, EVAS_HINT_FILL);
- elm_box_pack_end(box, label);
- evas_object_show(label);
+ elm_layout_file_set(layout, WFD_EDJ_POPUP_PATH, "popup_wps_pin_layout");
+ elm_object_domain_translatable_part_text_set(layout, "elm.text.description",
+ PACKAGE, pop->text);
+ evas_object_size_hint_weight_set(layout, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
/* add progressbar */
- progressbar = elm_progressbar_add(box);
+ progressbar = elm_progressbar_add(layout);
elm_object_style_set(progressbar, "list_progress");
elm_progressbar_horizontal_set(progressbar, EINA_TRUE);
- evas_object_size_hint_align_set(progressbar, EVAS_HINT_FILL, 0.0);
- evas_object_size_hint_weight_set(progressbar, EVAS_HINT_EXPAND, 0.0);
+ evas_object_size_hint_align_set(progressbar, EVAS_HINT_FILL, EVAS_HINT_FILL);
+ evas_object_size_hint_weight_set(progressbar, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
elm_progressbar_value_set(progressbar, 0.0);
- elm_box_pack_end(box, progressbar);
evas_object_show(progressbar);
/* add time */
- time = elm_label_add(box);
- elm_object_style_set(time, "popup/default");
- elm_object_text_set(time, "00:00");
+ time = elm_label_add(layout);
+ elm_object_style_set(time, "label3");
+ elm_label_line_wrap_set(time, ELM_WRAP_MIXED);
+ elm_object_text_set(time, _("<font_size=40><align=center>00:00</align></font_size>"));
evas_object_size_hint_weight_set(time, EVAS_HINT_EXPAND, 0.0);
- evas_object_size_hint_align_set(time, EVAS_HINT_FILL, 0.0);
- elm_box_pack_end(box, time);
+ evas_object_size_hint_align_set(time, EVAS_HINT_FILL, EVAS_HINT_FILL);
evas_object_show(time);
+ elm_object_part_content_set(layout, "slider", progressbar);
+ elm_object_part_content_set(layout, "timer_label", time);
+
+
/* start progressbar timer */
wps_display_popup.step = 0;
wps_display_popup.progressbar = progressbar;
wps_display_popup.time = time;
- if(pb_timer)
- ecore_timer_del(pb_timer);
pb_timer = ecore_timer_add(1, _fn_pb_timer, &wps_display_popup);
/* add buttons */
- if (pop->resp_data1 == WFD_POP_RESP_APRV_CONNECT_KEYPAD_YES ||
- pop->resp_data1 == WFD_POP_RESP_APRV_CONNECT_NO) {
- Evas_Object *btn1 = NULL;
- btn1 = elm_button_add(popup);
- elm_object_style_set(btn1, "popup_button/default");
- elm_object_text_set(btn1, pop->label1);
- elm_object_part_content_set(popup, "button1", btn1);
- evas_object_smart_callback_add(btn1, "clicked", __popup_resp_cb,
- (void*) pop->resp_data1);
- ea_object_event_callback_add(popup, EA_CALLBACK_BACK, __popup_resp_cb,
- (void*) pop->resp_data1);
- }
-
if (pop->resp_data2 == WFD_POP_RESP_APRV_CONNECT_NO) {
Evas_Object *btn2 = NULL;
btn2 = elm_button_add(popup);
- elm_object_style_set(btn2, "popup_button/default");
- elm_object_text_set(btn2, pop->label2);
- elm_object_part_content_set(popup, "button2", btn2);
+ elm_object_style_set(btn2, "popup");
+ elm_object_domain_translatable_text_set(btn2, PACKAGE, pop->label2);
+ elm_object_part_content_set(popup, "button1", btn2);
evas_object_smart_callback_add(btn2, "clicked", __popup_resp_cb,
- (void*) pop->resp_data2);
+ (void *) pop->resp_data2);
+ ea_object_event_callback_add(popup, EA_CALLBACK_BACK, __popup_resp_cb, (void *) pop->resp_data2);
+ }
+
+ if (pop->resp_data1 == WFD_POP_RESP_APRV_CONNECT_KEYPAD_YES || pop->resp_data1 == WFD_POP_RESP_APRV_CONNECT_PBC_YES ) {
+ Evas_Object *btn1 = NULL;
+ btn1 = elm_button_add(popup);
+ elm_object_style_set(btn1, "popup");
+ elm_object_domain_translatable_text_set(btn1, PACKAGE, pop->label1);
+ elm_object_part_content_set(popup, "button2", btn1);
+ evas_object_smart_callback_add(btn1, "clicked", __popup_resp_cb,
+ (void *) pop->resp_data1);
+ ea_object_event_callback_add(popup, EA_CALLBACK_BACK, __popup_resp_cb, (void *) pop->resp_data1);
}
- elm_object_content_set(popup, box);
+ elm_object_content_set(popup, layout);
+ __set_parent_rotate_angle(ad);
evas_object_show(popup);
evas_object_show(win);
+ ad->rotate_event_handler = ecore_event_handler_add(ECORE_X_EVENT_CLIENT_MESSAGE, __rotate, ad);
- __WDPOP_LOG_FUNC_EXIT__;
+ __WFD_APP_FUNC_EXIT__;
return popup;
}
-/**
- * This function let the app create a keypad popup
- * @return keypad popup
- * @param[in] win the window object
- * @param[in] pop the pointer to the prepared popup
- */
-Evas_Object *wfd_draw_pop_type_keypad(Evas_Object * win, wfd_popup_t * pop)
+static void __popup_eraser_clicked_cb(void *data, Evas_Object *obj, void *event_info)
+{
+ __WFD_APP_FUNC_ENTER__;
+ elm_entry_entry_set(data, "");
+ __WFD_APP_FUNC_EXIT__;
+}
+
+static void _entry_changed_cb(void *data, Evas_Object *obj, void *event_info)
+{
+ __WFD_APP_FUNC_ENTER__;
+ if (elm_object_part_content_get(obj, "elm.swallow.clear")) {
+ if (elm_object_focus_get(obj)) {
+ if (elm_entry_is_empty(obj))
+ elm_object_signal_emit(obj, "elm,state,clear,hidden", "");
+ else
+ elm_object_signal_emit(obj, "elm,state,clear,visible", "");
+ }
+ }
+ __WFD_APP_FUNC_EXIT__;
+}
+
+static void _entry_focused_cb(void *data, Evas_Object *obj, void *event_info)
+{
+ __WFD_APP_FUNC_ENTER__;
+
+ if (elm_object_part_content_get(obj, "elm.swallow.clear")) {
+ if (!elm_entry_is_empty(obj))
+ elm_object_signal_emit(obj, "elm,state,clear,visible", "");
+ else
+ elm_object_signal_emit(obj, "elm,state,clear,hidden", "");
+ }
+ elm_object_signal_emit(obj, "elm,state,focus,on", "");
+ __WFD_APP_FUNC_EXIT__;
+}
+
+static void _entry_keydown_cb(void *data, Evas *e, Evas_Object *obj,
+ void *event_info)
{
- __WDPOP_LOG_FUNC_ENTER__;
+ __WFD_APP_FUNC_ENTER__;
+
+ Evas_Event_Key_Down *ev;
+ Evas_Object *entry = obj;
+
+ WFD_RET_IF(data == NULL, "Incorrect parameter data(NULL)\n");
+ WFD_RET_IF(event_info == NULL, "Incorrect parameter event_info(NULL)\n");
+ WFD_RET_IF(entry == NULL, "Incorrect parameter entry(NULL)\n");
+
+ ev = (Evas_Event_Key_Down *)event_info;
+
+ if (g_strcmp0(ev->key, "KP_Enter") == 0 || g_strcmp0(ev->key, "Return") == 0) {
+ Ecore_IMF_Context *imf_context;
+
+ imf_context = (Ecore_IMF_Context*)elm_entry_imf_context_get(entry);
+ if (imf_context) {
+ ecore_imf_context_input_panel_hide(imf_context);
+ }
+
+ elm_object_focus_set(entry, EINA_FALSE);
+ }
+}
+
+static char *__wfd_main_desc_label_get(void *data, Evas_Object *obj,
+ const char *part)
+{
+ __WFD_APP_FUNC_ENTER__;
+ if (obj == NULL || part == NULL) {
+ return NULL;
+ }
+ WFD_APP_LOG(WFD_APP_LOG_LOW, "wfd_rename desc\n");
+ char msg1[WFD_POP_STR_MAX_LEN] = {0, };
+ char msg2[WFD_POP_STR_MAX_LEN] = {0, };
wfd_appdata_t *ad = wfd_get_appdata();
+ WFD_RETV_IF(ad == NULL, NULL, "Incorrect parameter(NULL)\n");
+ wfd_connection_info_s *connection = ad->connection;
+ WFD_RETV_IF(connection == NULL, NULL, "Incorrect parameter(NULL)\n");
- Evas_Object *conformant = NULL;
- Evas_Object *layout = NULL;
- Evas_Object *pinpopup = NULL;
- Evas_Object *label = NULL;
- Evas_Object *btn1 = NULL, *btn2 = NULL;
+ if (!g_strcmp0(part, "elm.text.multiline")) {
+ if (keypad_popup_timeout > 0) {
+ ad->timeout = keypad_popup_timeout;
+ }
+ _replace_1PS_2PD((char *)msg1, sizeof(msg1),
+ _("IDS_ST_BODY_CONNECT_WITH_PS_IN_PD_SECS_ABB"),
+ connection->peer_name, ad->timeout);
+
+ strcat(msg1, " ");
+ snprintf(msg2, sizeof(msg2),
+ _("IDS_WIFI_POP_ENTER_PIN_TO_CONNECT_TO_PS"),
+ connection->peer_name);
+ strcat(msg1, msg2);
+ WFD_APP_LOG(WFD_APP_LOG_LOW, "string %s", msg1);
+ __WFD_APP_FUNC_EXIT__;
+ return g_strdup(msg1);
+ }
+ __WFD_APP_FUNC_EXIT__;
+ return NULL;
+}
- conformant = elm_conformant_add(win);
- assertm_if(NULL == conformant, "conformant is NULL!!");
- elm_win_conformant_set(win, EINA_TRUE);
- elm_win_resize_object_add(win, conformant);
- evas_object_size_hint_weight_set(conformant, EVAS_HINT_EXPAND, 0.0);
- evas_object_size_hint_align_set(conformant, EVAS_HINT_FILL, 0.0);
- evas_object_show(conformant);
-
- layout = elm_layout_add(conformant);
- elm_object_content_set(conformant, layout);
-
- pinpopup = elm_popup_add(layout);
- assertm_if(NULL == pinpopup, "pinpopup is NULL!!");
- evas_object_size_hint_weight_set(pinpopup, EVAS_HINT_EXPAND, 0.0);
- elm_object_part_text_set(pinpopup, "title,text", _("IDS_WFD_POP_TITILE_CONNECTION"));
-
- Evas_Object *box = elm_box_add(pinpopup);
- if (!box) {
- evas_object_del(pinpopup);
- pinpopup = NULL;
+static Evas_Object *__wfd_pin_entry_icon_get(void *data, Evas_Object *obj,
+ const char *part)
+{
+ __WFD_APP_FUNC_ENTER__;
+ if (obj == NULL || part == NULL) {
return NULL;
}
+ wfd_appdata_t *ad = wfd_get_appdata();
+ WFD_RETV_IF(ad == NULL, NULL, "Incorrect parameter(NULL)\n");
+ Evas_Object *entry = NULL;
+ Evas_Object *button = NULL;
+ Ecore_IMF_Context *imf_context;
+ if (g_strcmp0(part, "elm.icon.entry")) {
+ __WFD_APP_FUNC_EXIT__;
+ return NULL;
+ }
+ static Elm_Entry_Filter_Accept_Set accept_set = {"0123456789", NULL};
+ entry = ea_editfield_add(obj, EA_EDITFIELD_SCROLL_SINGLELINE_PASSWORD);
+ ea_entry_selection_back_event_allow_set(entry, EINA_TRUE);
+ evas_object_size_hint_weight_set(entry, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
+ evas_object_size_hint_align_set(entry, EVAS_HINT_FILL, EVAS_HINT_FILL);
+ elm_entry_cnp_mode_set(entry, ELM_CNP_MODE_PLAINTEXT);
+ elm_entry_password_set(entry, EINA_TRUE);
+ elm_entry_prediction_allow_set(entry, EINA_FALSE);
+
+ elm_entry_markup_filter_append(entry,
+ elm_entry_filter_accept_set,&accept_set);
+ elm_entry_input_panel_layout_set(entry,
+ ELM_INPUT_PANEL_LAYOUT_DATETIME);
+ elm_object_signal_emit(entry, "elm,action,hide,search_icon", "");
+ elm_object_domain_translatable_part_text_set(entry, "elm.guide",
+ PACKAGE, _("IDS_WIFI_POP_PIN"));
+ elm_entry_input_panel_return_key_autoenabled_set(entry,EINA_TRUE);
+ elm_entry_input_panel_return_key_type_set(entry,
+ ELM_INPUT_PANEL_RETURN_KEY_TYPE_DONE);
+
+ ad->pin_entry = entry;
+ imf_context = (Ecore_IMF_Context*)elm_entry_imf_context_get(entry);
+ if (imf_context) {
+ ecore_imf_context_input_panel_return_key_type_set(imf_context,
+ ECORE_IMF_INPUT_PANEL_RETURN_KEY_TYPE_DONE);
+ }
+
+ button = elm_button_add(obj);
+ elm_object_style_set(button, "search_clear");
+ elm_object_focus_allow_set(button, EINA_FALSE);
+ elm_object_part_content_set(entry, "elm.swallow.clear", button);
+ evas_object_smart_callback_add(button, "clicked",
+ __popup_eraser_clicked_cb, entry);
+
+ elm_object_signal_emit (entry, "elm,action,hide,search_icon", "");
+ evas_object_smart_callback_add(entry, "changed",
+ _entry_changed_cb, NULL);
+ evas_object_smart_callback_add(entry, "preedit,changed",
+ _entry_changed_cb, NULL);
+ evas_object_smart_callback_add(entry, "focused",
+ _entry_focused_cb, NULL);
+ evas_object_event_callback_add(entry, EVAS_CALLBACK_KEY_DOWN,
+ _entry_keydown_cb, ad);
+
+ elm_object_content_set(obj,entry);
+ evas_object_show(entry);
+ evas_object_smart_callback_add(entry, "changed", _smart_ime_cb, NULL);
+ elm_object_focus_set(entry, EINA_TRUE);
+ __WFD_APP_FUNC_EXIT__;
+ return entry;
+}
+
+static void _chk_changed_cb(void *data, Evas_Object *obj, void *ei)
+{
+ __WFD_APP_FUNC_ENTER__;
+ if (obj == NULL || data == NULL) {
+ return;
+ }
+ Eina_Bool state = elm_check_state_get(obj);
+ if (state) {
+ elm_entry_password_set((Evas_Object *)data, EINA_FALSE);
+ } else {
+ elm_entry_password_set((Evas_Object *)data, EINA_TRUE);
+ }
+ __WFD_APP_FUNC_EXIT__;
+}
+
+static void _gl_pswd_check_box_sel(void *data, Evas_Object *obj, void *ei)
+{
+ __WFD_APP_FUNC_ENTER__;
+ Elm_Object_Item *item = NULL;
+ item = (Elm_Object_Item *)ei;
+ if (item == NULL) {
+ return;
+ }
+ wfd_appdata_t *ad = wfd_get_appdata();
+ if (ad == NULL) {
+ WFD_APP_LOG(WFD_APP_LOG_LOW, "Incorrect parameter(NULL)\n");
+ return;
+ }
+ Evas_Object *ck = elm_object_item_part_content_get(ei, "elm.icon.left");
+ elm_genlist_item_selected_set(item, EINA_FALSE);
+ Eina_Bool state = elm_check_state_get(ck);
+ elm_check_state_set(ck, !state);
+ if (ad) {
+ _chk_changed_cb(ad->pin_entry, ck, NULL);
+ }
+ __WFD_APP_FUNC_EXIT__;
+}
+
+static char *__wfd_password_label(void *data, Evas_Object *obj, const char *part)
+{
+ __WFD_APP_FUNC_ENTER__;
- evas_object_size_hint_weight_set(box, EVAS_HINT_EXPAND, 0.0);
- evas_object_size_hint_align_set(box, EVAS_HINT_FILL, 0.0);
- elm_object_part_content_set(pinpopup, NULL, box);
- evas_object_show(box);
-
- /* add label */
- label = elm_label_add(box);
- elm_object_style_set(label, "popup/default");
- elm_label_line_wrap_set(label, ELM_WRAP_MIXED);
- elm_object_text_set(label, pop->text);
- evas_object_size_hint_weight_set(label, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
- evas_object_size_hint_align_set(label, EVAS_HINT_FILL, EVAS_HINT_FILL);
- elm_box_pack_end(box, label);
- evas_object_show(label);
-
- /* add password */
- Evas_Object *body = elm_layout_add(box);
- if (!body) {
- evas_object_del(pinpopup);
- pinpopup = NULL;
+ if (data == NULL || part == NULL) {
return NULL;
}
+ WFD_APP_LOG(WFD_APP_LOG_LOW, "Part %s", part);
- elm_layout_theme_set(body, "layout", "dialogue", "1icon");
- evas_object_size_hint_weight_set(body, EVAS_HINT_EXPAND, 0.0);
- evas_object_size_hint_align_set(body, EVAS_HINT_FILL, 0.0);
+ if (!g_strcmp0(part, "elm.text.main.right")) {
+ __WFD_APP_FUNC_EXIT__;
+ return g_strdup(" Show password");
+ }
+ __WFD_APP_FUNC_EXIT__;
+ return NULL;
+}
- Evas_Object *editfield_pin = _add_edit_field(body, NULL, NULL, EINA_TRUE, EINA_TRUE);
- Evas_Object *entry_pin = elm_object_part_content_get(editfield_pin, "elm.swallow.content");
- ad->pin_entry = entry_pin;
- evas_object_smart_callback_add(ad->pin_entry, "changed", _smart_ime_cb, NULL);
- elm_object_part_content_set(body, "elm.icon", editfield_pin);
- elm_box_pack_end(box, body);
- evas_object_show(body);
+static Evas_Object *__wfd_password_check(void *data, Evas_Object *obj,
+ const char *part)
+{
+ __WFD_APP_FUNC_ENTER__;
+ if (obj == NULL || part == NULL) {
+ return NULL;
+ }
+ wfd_appdata_t *ad = wfd_get_appdata();
+ WFD_RETV_IF(ad == NULL, NULL, "Incorrect parameter(NULL)\n");
+ Evas_Object *check = NULL;
+
+ WFD_APP_LOG(WFD_APP_LOG_LOW, "Part %s", part);
+
+ if (!g_strcmp0(part, "elm.icon.left")) {
+ check = elm_check_add(obj);
+ evas_object_propagate_events_set(check, EINA_FALSE);
+ evas_object_size_hint_align_set(check, EVAS_HINT_FILL, EVAS_HINT_FILL);
+ evas_object_size_hint_weight_set(check,
+ EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
+ evas_object_smart_callback_add(check, "changed",
+ _chk_changed_cb, ad->pin_entry);
+ elm_object_focus_allow_set(check, EINA_FALSE);
+ __WFD_APP_FUNC_EXIT__;
+ return check;
+ }
+ __WFD_APP_FUNC_EXIT__;
+ return check;
+}
- elm_entry_password_set(ad->pin_entry, TRUE);
- Evas_Object *check = elm_check_add(box);
- elm_object_text_set(check, _("Show password"));
- elm_object_focus_allow_set(check, EINA_FALSE);
- evas_object_size_hint_weight_set(check, EVAS_HINT_EXPAND, 0.0);
- evas_object_size_hint_align_set(check, EVAS_HINT_FILL, 0.0);
- evas_object_smart_callback_add(check, "changed", _check_changed_cb, NULL);
- evas_object_show(check);
- elm_box_pack_end(box, check);
+/**
+ * This function let the app create a keypad popup
+ * @return keypad popup
+ * @param[in] win the window object
+ * @param[in] pop the pointer to the prepared popup
+ */
+Evas_Object *wfd_draw_pop_type_keypad(Evas_Object * win, wfd_popup_t * pop)
+{
+ __WFD_APP_FUNC_ENTER__;
+ wfd_appdata_t *ad = wfd_get_appdata();
+ WFD_RETV_IF(ad == NULL, NULL, "Incorrect parameter(NULL)\n");
+ wfd_connection_info_s *connection = ad->connection;
+ WFD_RETV_IF(connection == NULL, NULL, "Incorrect parameter(NULL)\n");
+
+ Evas_Object *pinpopup = NULL;
+ Evas_Object *btn1 = NULL, *btn2 = NULL;
+ Evas_Object *genlist = NULL;
+ Elm_Object_Item *git = NULL;
+
+ ad->timeout = pop->timeout;
+
+ pinpopup = elm_popup_add(ad->layout);
+ ea_object_event_callback_add(pinpopup, EA_CALLBACK_BACK, ea_popup_back_cb,
+ NULL);
+ evas_object_size_hint_weight_set(pinpopup, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
+ elm_object_domain_translatable_part_text_set(pinpopup, "title,text",
+ PACKAGE, _("IDS_WIFI_HEADER_WI_FI_DIRECT_CONNECTION_ABB"));
+
+ genlist = elm_genlist_add(pinpopup);
+ elm_genlist_homogeneous_set(genlist, EINA_TRUE);
+ evas_object_size_hint_weight_set(genlist,
+ EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
+ evas_object_size_hint_align_set(genlist, EVAS_HINT_FILL, EVAS_HINT_FILL);
+ elm_genlist_mode_set(genlist, ELM_LIST_COMPRESS);
+ elm_scroller_content_min_limit(genlist, EINA_FALSE, EINA_TRUE);
+
+ /* Entry genlist item */
+ ad->pin_desc_itc = elm_genlist_item_class_new();
+ ad->pin_desc_itc->item_style = "multiline_main";
+ ad->pin_desc_itc->func.text_get = __wfd_main_desc_label_get;
+ ad->pin_desc_itc->func.content_get = NULL;
+ ad->pin_desc_itc->func.state_get = NULL;
+ ad->pin_desc_itc->func.del = NULL;
+
+ git = elm_genlist_item_append(genlist, ad->pin_desc_itc, ad, NULL,
+ ELM_GENLIST_ITEM_NONE, NULL, NULL);
+ elm_genlist_item_select_mode_set(git,
+ ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY);
+
+ ad->pin_entry_itc = elm_genlist_item_class_new();
+ ad->pin_entry_itc->item_style = "entry";
+ ad->pin_entry_itc->func.text_get = NULL;
+ ad->pin_entry_itc->func.content_get = __wfd_pin_entry_icon_get;
+ ad->pin_entry_itc->func.state_get = NULL;
+ ad->pin_entry_itc->func.del = NULL;
+
+ elm_genlist_item_append(genlist, ad->pin_entry_itc, pinpopup,
+ NULL, ELM_GENLIST_ITEM_NONE, NULL, NULL);
+
+ keypad_popup_timeout = pop->timeout;
+ keypad_popup_timer = ecore_timer_add(1, _keypad_popup_timer_cb,
+ ad->pin_desc_itc);
+
+ ad->paswd_itc = elm_genlist_item_class_new();
+ ad->paswd_itc->item_style = "1line";
+ ad->paswd_itc->func.text_get = __wfd_password_label;
+ ad->paswd_itc->func.content_get = __wfd_password_check;
+ ad->paswd_itc->func.state_get = NULL;
+ ad->paswd_itc->func.del = NULL;
+
+ elm_genlist_item_append(genlist, ad->paswd_itc, pinpopup,
+ NULL, ELM_GENLIST_ITEM_NONE, _gl_pswd_check_box_sel, (void *)ad );
- /* add buttons */
btn1 = elm_button_add(pinpopup);
- elm_object_style_set(btn1, "popup_button/default");
- elm_object_text_set(btn1, pop->label1);
+ elm_object_style_set(btn1, "popup");
+ elm_object_domain_translatable_text_set(btn1, PACKAGE, pop->label2);
elm_object_part_content_set(pinpopup, "button1", btn1);
- evas_object_smart_callback_add(btn1, "clicked", __popup_resp_cb, (void *)pop->resp_data1);
- ea_object_event_callback_add(pinpopup, EA_CALLBACK_BACK, __popup_resp_cb,
- (void*) pop->resp_data1);
+ evas_object_smart_callback_add(btn1, "clicked", __popup_resp_cb,
+ (void *)pop->resp_data2);
btn2 = elm_button_add(pinpopup);
- elm_object_style_set(btn2, "popup_button/default");
- elm_object_text_set(btn2, pop->label2);
+ elm_object_style_set(btn2, "popup");
+ elm_object_domain_translatable_text_set(btn2, PACKAGE, pop->label1);
elm_object_part_content_set(pinpopup, "button2", btn2);
- evas_object_smart_callback_add(btn2, "clicked", __popup_resp_cb, (void *)pop->resp_data2);
+ evas_object_smart_callback_add(btn2, "clicked", __popup_resp_cb,
+ (void *)pop->resp_data1);
- elm_object_content_set(pinpopup, box);
+ elm_genlist_realization_mode_set(genlist, EINA_TRUE);
+ evas_object_show(genlist);
+ elm_object_content_set(pinpopup, genlist);
+
+ __set_parent_rotate_angle(ad);
evas_object_show(pinpopup);
evas_object_show(win);
elm_object_focus_set(ad->pin_entry, EINA_TRUE);
+ ad->rotate_event_handler = ecore_event_handler_add(ECORE_X_EVENT_CLIENT_MESSAGE,
+ __rotate, ad);
- __WDPOP_LOG_FUNC_EXIT__;
+ __WFD_APP_FUNC_EXIT__;
return pinpopup;
}
+
+void _replace_int(char *haystack, int size, char *niddle, int value)
+{
+ __WFD_APP_FUNC_ENTER__;
+ char*buf = NULL;
+ char *p = NULL;
+ char *q = NULL;
+
+ if (haystack == NULL || niddle == NULL || size <= 1)
+ return;
+
+ buf = g_strdup(haystack);
+ p = strstr(buf, niddle);
+ if (p==NULL) {
+ free(buf);
+ return;
+ }
+ q = p + strlen(niddle);
+ *p = '\0';
+
+ snprintf(haystack, size-1, "%s%d%s", buf, value, q);
+ free(buf);
+ __WFD_APP_FUNC_EXIT__;
+}
+
+void _replace_1PS_2PD(char *buf, int buf_len, char *format_str, char* SD_1, int PD_2)
+{
+ __WFD_APP_FUNC_ENTER__;
+ char text[WFD_POP_STR_MAX_LEN] = {0, };
+
+ strncpy(text, format_str, WFD_POP_STR_MAX_LEN-1);
+ _replace_int(text, WFD_POP_STR_MAX_LEN, "%d", PD_2);
+ _replace_int(text, WFD_POP_STR_MAX_LEN, "%2$d", PD_2);
+ snprintf(buf, buf_len-1, text, SD_1);
+ __WFD_APP_FUNC_EXIT__;
+}
+
+
/**
* This function let the app create a popup
* @return void
* @param[in] type the type of popup
* @param[in] userdata the pointer to the data which will be used
*/
-void wfd_prepare_popup(int type, void *userdata)
+void wfd_prepare_popup(int type, void *user_data)
{
- __WDPOP_LOG_FUNC_ENTER__;
+ __WFD_APP_FUNC_ENTER__;
wfd_appdata_t *ad = wfd_get_appdata();
wfd_popup_t *pop = ad->popup_data;
-
+ wfd_connection_info_s *connection = ad->connection;
+ char text[WFD_POP_STR_MAX_LEN+1] = {0, };
+ char text1[WFD_POP_STR_MAX_LEN+1] = {0, };
wfd_destroy_popup();
+ char *peer_name;
+ peer_name = elm_entry_utf8_to_markup(connection->peer_name);
memset(pop, 0, sizeof(wfd_popup_t));
@@ -745,54 +1293,49 @@ void wfd_prepare_popup(int type, void *userdata)
switch (pop->type) {
case /* MT */ WFD_POP_APRV_CONNECTION_WPS_PUSHBUTTON_REQ:
- snprintf(pop->text, sizeof(pop->text), IDS_WFD_POP_CONNECT_Q,
- ad->peer_name);
- snprintf(pop->label1, sizeof(pop->label1), "%s", dgettext("sys_string", "IDS_COM_SK_NO"));
- snprintf(pop->label2, sizeof(pop->label2), "%s", dgettext("sys_string", "IDS_COM_SK_YES"));
- pop->resp_data1 = WFD_POP_RESP_APRV_CONNECT_NO;
- pop->resp_data2 = WFD_POP_RESP_APRV_CONNECT_PBC_YES;
- ad->popup = wfd_draw_pop_type_c(ad->win, pop);
- break;
+ _replace_1PS_2PD((char *)pop->text, sizeof(pop->text),
+ _("IDS_WIFI_POP_CONNECT_TO_PS_IN_PD_SECONDS"),
+ peer_name, WFD_POP_TIMER_120);
- case WFD_POP_APRV_CONNECTION_INVITATION_REQ:
- snprintf(pop->text, sizeof(pop->text), IDS_WFD_POP_CONNECT_Q,
- ad->peer_name);
- snprintf(pop->label1, sizeof(pop->label1), "%s", dgettext("sys_string", "IDS_COM_SK_NO"));
- snprintf(pop->label2, sizeof(pop->label2), "%s", dgettext("sys_string", "IDS_COM_SK_YES"));
- pop->resp_data1 = WFD_POP_RESP_APRV_CONNECT_NO;
- pop->resp_data2 = WFD_POP_RESP_APRV_CONNECT_INVITATION_YES;
+ snprintf(pop->label1, sizeof(pop->label1), "%s", _("IDS_WIFI_SK2_OK"));
+ snprintf(pop->label2, sizeof(pop->label2), "%s", _("IDS_WIFI_SK_CANCEL"));
+ pop->timeout = WFD_POP_TIMER_120;
+ pop->resp_data1 = WFD_POP_RESP_APRV_CONNECT_PBC_YES;
+ pop->resp_data2 = WFD_POP_RESP_APRV_CONNECT_NO;
- ad->popup = wfd_draw_pop_type_c(ad->win, pop);
+ ad->popup = wfd_draw_pop_type_display(ad->win, pop);
break;
case /* MT */ WFD_POP_APRV_CONNECTION_WPS_DISPLAY_REQ:
- snprintf(pop->text, sizeof(pop->text), IDS_WFD_POP_ENTER_PIN_WITH_KEYPAD,
- ad->peer_name);
- snprintf(pop->label1, sizeof(pop->label1), "%s", dgettext("sys_string", "IDS_COM_POP_CANCEL"));
- snprintf(pop->label2, sizeof(pop->label2), "%s", dgettext("sys_string", "IDS_COM_SK_OK"));
+ snprintf(pop->text, sizeof(pop->text),
+ _("IDS_WIFI_BODY_PS_IS_REQUESTING_A_WI_FI_DIRECT_CONNECTION_ALLOW_Q"),
+ peer_name);
+ snprintf(pop->label1, sizeof(pop->label1), "%s", _("IDS_WIFI_BUTTON_ALLOW"));
+ snprintf(pop->label2, sizeof(pop->label2), "%s", _("IDS_BR_SK_CANCEL"));
pop->timeout = WFD_POP_TIMER_120;
- pop->resp_data1 = WFD_POP_RESP_APRV_CONNECT_NO;
- pop->resp_data2 = WFD_POP_RESP_APRV_CONNECT_DISPLAY_OK;
+ pop->resp_data1 = WFD_POP_RESP_APRV_CONNECT_DISPLAY_OK;
+ pop->resp_data2 = WFD_POP_RESP_APRV_CONNECT_NO;
ad->popup = wfd_draw_pop_type_c(ad->win, pop);
break;
case /* MT */ WFD_POP_APRV_CONNECTION_WPS_KEYPAD_REQ:
- snprintf(pop->text, sizeof(pop->text), IDS_WFD_POP_ENTER_PIN,
- ad->peer_name, WFD_POP_TIMER_120);
- snprintf(pop->label1, sizeof(pop->label1), "%s", dgettext("sys_string", "IDS_COM_POP_CANCEL"));
- snprintf(pop->label2, sizeof(pop->label2), "%s", dgettext("sys_string", "IDS_COM_SK_OK"));
+ _replace_1PS_2PD((char *)pop->text, sizeof(pop->text),
+ _("IDS_WIFI_POP_CONNECT_TO_PS_IN_PD_SECONDS"),
+ peer_name, WFD_POP_TIMER_120);
+ snprintf(pop->label1, sizeof(pop->label1), "%s", _("IDS_BR_SK_OK"));
+ snprintf(pop->label2, sizeof(pop->label2), "%s", _("IDS_BR_SK_CANCEL"));
pop->timeout = WFD_POP_TIMER_120;
- pop->resp_data1 = WFD_POP_RESP_APRV_CONNECT_NO;
- pop->resp_data2 = WFD_POP_RESP_APRV_CONNECT_KEYPAD_YES;
+ pop->resp_data1 = WFD_POP_RESP_APRV_CONNECT_KEYPAD_YES;
+ pop->resp_data2 = WFD_POP_RESP_APRV_CONNECT_NO;
- ad->popup = wfd_draw_pop_type_c(ad->win, pop);
+ ad->popup = wfd_draw_pop_type_display(ad->win, pop);
break;
case /* MT */ WFD_POP_PROG_CONNECT:
- snprintf(pop->text, sizeof(pop->text), "%s", _("IDS_WFD_POP_CONNECTING"));
- snprintf(pop->label1, sizeof(pop->label1), "%s", dgettext("sys_string", "IDS_COM_POP_CANCEL"));
+ snprintf(pop->text, sizeof(pop->text), "%s", _("IDS_WIFI_BODY_CONNECTING_ING"));
+ snprintf(pop->label1, sizeof(pop->label1), "%s", _("IDS_BR_SK_CANCEL"));
pop->timeout = WFD_POP_TIMER_120;
pop->resp_data1 = WFD_POP_RESP_APRV_CONNECT_NO;
@@ -800,29 +1343,44 @@ void wfd_prepare_popup(int type, void *userdata)
break;
case /* MO */ WFD_POP_PROG_CONNECT_WITH_KEYPAD:
- snprintf(pop->text, sizeof(pop->text), IDS_WFD_POP_CONNECTING_WITH_KEYPAD,
- ad->peer_name, WFD_POP_TIMER_120, ad->peer_name);
- snprintf(pop->label1, sizeof(pop->label1), "%s", dgettext("sys_string", "IDS_COM_POP_CANCEL"));
- snprintf(pop->label2, sizeof(pop->label2), "%s", dgettext("sys_string", "IDS_COM_SK_OK"));
+ _replace_1PS_2PD((char *)text, sizeof(text),
+ _("IDS_WIFI_POP_CONNECT_TO_PS_IN_PD_SECONDS"),
+ peer_name, WFD_POP_TIMER_120);
+
+ snprintf(text1, WFD_POP_STR_MAX_LEN, "%s %s",
+ text, _("IDS_WIFI_POP_ENTER_PIN_TO_CONNECT_TO_PS"));
+
+ snprintf(pop->text, sizeof(pop->text), text1, connection->peer_name);
+
+ snprintf(pop->label1, sizeof(pop->label1), "%s", _("IDS_WIFI_SK_CONNECT"));
+ snprintf(pop->label2, sizeof(pop->label2), "%s", _("IDS_BR_SK_CANCEL"));
pop->timeout = WFD_POP_TIMER_120;
- pop->resp_data1 = WFD_POP_RESP_APRV_CONNECT_NO;
- pop->resp_data2 = WFD_POP_RESP_PROG_CONNECT_KEYPAD_OK;
+ pop->resp_data1 = WFD_POP_RESP_PROG_CONNECT_KEYPAD_OK;
+ pop->resp_data2 = WFD_POP_RESP_APRV_CONNECT_NO;
ad->popup = wfd_draw_pop_type_keypad(ad->win, pop);
break;
case /* MO/MT */ WFD_POP_PROG_CONNECT_WITH_PIN:
- snprintf(pop->text, sizeof(pop->text), IDS_WFD_POP_CONNECTING_WITH_PIN,
- ad->peer_name, WFD_POP_TIMER_120, ad->pin_number);
- snprintf(pop->label1, sizeof(pop->label1), "%s", dgettext("sys_string", "IDS_COM_POP_CANCEL"));
+ _replace_1PS_2PD((char *)text, sizeof(text),
+ _("IDS_WIFI_POP_CONNECT_TO_PS_IN_PD_SECONDS"),
+ peer_name, WFD_POP_TIMER_120);
+
+ snprintf(text1, WFD_POP_STR_MAX_LEN, "%s %s %s",
+ text,
+ "<br>",
+ _("IDS_WIFI_POP_PIN_CODE_PS"));
+ snprintf(pop->text, sizeof(pop->text), text1, connection->wps_pin);
+
+ snprintf(pop->label2, sizeof(pop->label2), "%s", _("IDS_BR_SK_CANCEL"));
pop->timeout = WFD_POP_TIMER_120;
- pop->resp_data1 = WFD_POP_RESP_APRV_CONNECT_NO;
+ pop->resp_data2 = WFD_POP_RESP_APRV_CONNECT_NO;
ad->popup = wfd_draw_pop_type_display(ad->win, pop);
break;
case WFD_POP_PROG_CONNECT_CANCEL:
- snprintf(pop->text, sizeof(pop->text), "%s", dgettext("sys_string", "IDS_COM_POP_CANCEL"));
+ snprintf(pop->text, sizeof(pop->text), "%s", _("IDS_BR_SK_CANCEL"));
pop->timeout = WFD_POP_TIMER_120;
ad->popup = wfd_draw_pop_type_a(ad->win, pop);
break;
@@ -831,6 +1389,13 @@ void wfd_prepare_popup(int type, void *userdata)
break;
}
- __WDPOP_LOG_FUNC_EXIT__;
+ /* feedback play */
+ int ret = -1;
+ ret = feedback_play(FEEDBACK_PATTERN_GENERAL);
+ if (ret != FEEDBACK_ERROR_NONE) {
+ WFD_APP_LOG(WFD_APP_LOG_ERROR,"feedback_play error : %d\n", ret);
+ }
+ WFD_IF_FREE_MEM(peer_name);
+ __WFD_APP_FUNC_EXIT__;
return;
}
diff --git a/popup-wifidirect/src/wfd-app-util.c b/popup-wifidirect/src/wfd-app-util.c
index 7231757..a60e22c 100644
--- a/popup-wifidirect/src/wfd-app-util.c
+++ b/popup-wifidirect/src/wfd-app-util.c
@@ -1,13 +1,13 @@
/*
* WiFi-Direct UG
*
-* Copyright 2012 Samsung Electronics Co., Ltd
+* Copyright 2012 Samsung Electronics Co., Ltd
-* Licensed under the Flora License, Version 1.1 (the "License");
+* Licensed under the Flora License, Version 1.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
-* http://floralicense.org/license
+* http://www.tizenopensource.org/license
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
@@ -25,11 +25,21 @@
* @version 0.1
*/
-
+#include <linux/unistd.h>
#include <stdio.h>
#include <string.h>
-#include "wfd-app-util.h"
+#include <Elementary.h>
+#include <utilX.h>
+#include <vconf.h>
+#include <app_control.h>
+#include <notification.h>
+#include <notification_internal.h>
+
+#include <wifi-direct.h>
+
+#include "wfd-app.h"
+#include "wfd-app-util.h"
char *wfd_app_trim_path(const char *filewithpath)
{
@@ -67,7 +77,896 @@ int wfd_app_gettid()
#ifdef __NR_gettid
return syscall(__NR_gettid);
#else
- WDPOP_LOGE("__NR_gettid is not defined, please include linux/unistd.h ");
+ fprintf(stderr, "__NR_gettid is not defined, please include linux/unistd.h ");
return -1;
#endif
}
+
+static void __launch_app_result_cb(app_control_h request, app_control_h reply, app_control_result_e result, void *data)
+{
+ __WFD_APP_FUNC_ENTER__;
+
+ if(result == APP_CONTROL_RESULT_FAILED) {
+ WFD_APP_LOG(WFD_APP_LOG_ERROR, "User cancel to reconnect screen mirroring\n");
+#ifdef WFD_SCREEN_MIRRORING_ENABLED
+ ad->screen_mirroring_state = WFD_POP_SCREEN_MIRROR_NONE;
+#endif
+ } else {
+ WFD_APP_LOG(WFD_APP_LOG_ERROR, "app_control launch result: [%d]\n", result);
+ }
+
+ __WFD_APP_FUNC_EXIT__;
+}
+
+static void _move_data_to_app_control(const char *key, const char *val, void *data)
+{
+ __WFD_APP_FUNC_ENTER__;
+
+ WFD_RET_IF(data == NULL || key == NULL || val == NULL, , "Invialid parameter!");
+
+ app_control_h control = data;
+ app_control_add_extra_data(control, key, val);
+
+ __WFD_APP_FUNC_EXIT__;
+}
+
+static void _launch_app(char *app_id, void *data)
+{
+ __WFD_APP_FUNC_ENTER__;
+ WFD_RET_IF(app_id == NULL || data == NULL, "Invialid parameter!");
+
+ int ret = APP_CONTROL_ERROR_NONE;
+ app_control_h control = NULL;
+ ret = app_control_create(&control);
+ if (ret != APP_CONTROL_ERROR_NONE) {
+ WFD_APP_LOG(WFD_APP_LOG_ERROR, "app_control_create() return error : %d", ret);
+ return;
+ }
+ WFD_RET_IF(control == NULL, "Failed to create app_control handle!");
+
+ app_control_set_operation(control, APP_CONTROL_OPERATION_DEFAULT);
+ app_control_set_app_id(control, app_id);
+ bundle_iterate((bundle *)data, _move_data_to_app_control, control);
+
+ char *launch_type = (char*)bundle_get_val(data, "-t");
+ if (!strcmp(launch_type, "reconnect_by_connecting_wifi_ap")) {
+ ret = app_control_send_launch_request(control, __launch_app_result_cb, NULL);
+ } else {
+ ret = app_control_send_launch_request(control, NULL, NULL);
+ }
+
+ if (ret != APP_CONTROL_ERROR_NONE) {
+ WFD_APP_LOG(WFD_APP_LOG_ERROR, "app_control_send_launch_request() is failed : %d", ret);
+ app_control_destroy(control);
+ return;
+ }
+ app_control_destroy(control);
+
+ __WFD_APP_FUNC_EXIT__;
+ return;
+}
+
+#ifdef WFD_SCREEN_MIRRORING_ENABLED
+void _add_screen_mirroring_activated_indicator(void *user_data)
+{
+ __WFD_APP_FUNC_ENTER__;
+ wfd_appdata_t *ad = (wfd_appdata_t *) user_data;
+ notification_error_e noti_err = NOTIFICATION_ERROR_NONE;
+ WFD_RET_IF(ad->noti_screen_mirroring_on, "Indicator noti_screen_mirroring_on already exists");
+
+ if (ad->noti_screen_mirroring_play) {
+ notification_delete(ad->noti_screen_mirroring_play);
+ notification_free(ad->noti_screen_mirroring_play);
+ ad->noti_screen_mirroring_play = NULL;
+ }
+
+ if(ad->noti_screen_mirroring_on != NULL) {
+ noti_err = notification_free(ad->noti_screen_mirroring_on);
+ WFD_RET_IF(noti_err != NOTIFICATION_ERROR_NONE, "Failed to notification_free. [%d]", noti_err);
+ }
+
+ ad->noti_screen_mirroring_on = notification_new(NOTIFICATION_TYPE_ONGOING, NOTIFICATION_GROUP_ID_NONE, NOTIFICATION_PRIV_ID_NONE);
+ WFD_RET_IF(NULL == ad->noti_screen_mirroring_on, "NULL parameters.\n");
+
+ noti_err = notification_set_image(ad->noti_screen_mirroring_on, NOTIFICATION_IMAGE_TYPE_ICON_FOR_INDICATOR, SCREEN_MIRRIONG_INDICATOR_ICON_PATH);
+ WFD_RET_IF(noti_err != NOTIFICATION_ERROR_NONE, "Failed to notification_set_image. [%d]", noti_err);
+
+ noti_err = notification_set_property(ad->noti_screen_mirroring_on, NOTIFICATION_PROP_DISABLE_TICKERNOTI);
+ WFD_RET_IF(noti_err != NOTIFICATION_ERROR_NONE, "Unable to notification_set_property. [%d]", noti_err);
+
+ noti_err = notification_set_display_applist(ad->noti_screen_mirroring_on, NOTIFICATION_DISPLAY_APP_INDICATOR);
+ WFD_RET_IF(noti_err != NOTIFICATION_ERROR_NONE, "Unable to notification_set_display_applist. [%d]", noti_err);
+
+ /* notify the quick panel */
+ noti_err = notification_insert(ad->noti_screen_mirroring_on, NULL);
+ WFD_RET_IF(noti_err != NOTIFICATION_ERROR_NONE, "Failed to notification_insert. [%d]", noti_err);
+
+ __WFD_APP_FUNC_EXIT__;
+ return;
+}
+#endif
+
+
+#ifdef WFD_SCREEN_MIRRORING_ENABLED
+/**
+ * This function let the app add the notification when it is connected
+ * @return void
+ * @param[in] user_data the pointer to the main data structure
+ */
+void _add_wfd_peers_connected_notification(void *user_data, char* package_name)
+{
+ __WFD_APP_FUNC_ENTER__;
+
+ int res = NOTIFICATION_ERROR_NONE;
+ wfd_appdata_t *ad = (wfd_appdata_t *) user_data;
+ notification_error_e noti_err = NOTIFICATION_ERROR_NONE;
+
+ WFD_RET_IF(NULL == ad || NULL == package_name, "NULL parameters.\n");
+
+ if (ad->noti_screen_mirroring_on) {
+ notification_delete(ad->noti_screen_mirroring_on);
+ notification_free(ad->noti_screen_mirroring_on);
+ ad->noti_screen_mirroring_on = NULL;
+ }
+
+ if(ad->noti_screen_mirroring_play != NULL) {
+ noti_err = notification_free(ad->noti_screen_mirroring_play);
+ WFD_RET_IF(noti_err != NOTIFICATION_ERROR_NONE, "Failed to notification_free. [%d]", noti_err);
+ }
+
+ ad->noti_screen_mirroring_play = notification_new(NOTIFICATION_TYPE_ONGOING, NOTIFICATION_GROUP_ID_NONE, NOTIFICATION_PRIV_ID_NONE);
+ WFD_RET_IF(NULL == ad->noti_screen_mirroring_play, "NULL parameters.\n");
+
+ char msg[WFD_MAX_SIZE] = {0};
+
+ bundle *b = NULL;
+ app_control_h control;
+ res = app_control_create(&control);
+ WFD_RET_IF(res != APP_CONTROL_ERROR_NONE, "app_control_create() return error : %d", res);
+
+ app_control_set_package(control, package_name);
+ app_control_add_extra_data(control, "-t", "notification");
+ res = app_control_to_bundle(control, &b);
+ if (res != APP_CONTROL_ERROR_NONE) {
+ WFD_APP_LOG(WFD_APP_LOG_ERROR, "app_control_to_bundle() return error : %d", res);
+ app_control_destroy(control);
+ return;
+ }
+
+ res = notification_set_execute_option(ad->noti_screen_mirroring_play, NOTIFICATION_EXECUTE_TYPE_SINGLE_LAUNCH, /*Button Text*/NULL, NULL, b);
+ if (res != NOTIFICATION_ERROR_NONE) {
+ WFD_APP_LOG(WFD_APP_LOG_ERROR, "Failed to notification_set_execute_option. [%d]", res);
+ app_control_destroy(control);
+ return;
+ }
+
+ app_control_destroy(control);
+
+ noti_err = notification_set_layout(ad->noti_screen_mirroring_play, NOTIFICATION_LY_ONGOING_EVENT);
+ WFD_RET_IF(noti_err != NOTIFICATION_ERROR_NONE, "Failed to notification_set_layout. [%d]", noti_err);
+
+ /* set the icon */
+ noti_err = notification_set_image(ad->noti_screen_mirroring_play, NOTIFICATION_IMAGE_TYPE_ICON, SCREEN_MIRRIONG_NOTI_ICON_PATH);
+ WFD_RET_IF(noti_err != NOTIFICATION_ERROR_NONE, "Failed to notification_set_image. [%d]", noti_err);
+
+ noti_err = notification_set_image(ad->noti_screen_mirroring_play, NOTIFICATION_IMAGE_TYPE_ICON_FOR_INDICATOR, SCREEN_MIRRIONG_INDICATOR_PLAY_ICON_PATH);
+ WFD_RET_IF(noti_err != NOTIFICATION_ERROR_NONE, "Failed to notification_set_image. [%d]", noti_err);
+
+ /* set the title and content */
+ wfd_app_get_connected_peers(ad);
+ noti_err = notification_set_text(ad->noti_screen_mirroring_play, NOTIFICATION_TEXT_TYPE_TITLE, _("IDS_SMR_BODY_SCREEN_MIRRORING_IS_ENABLED"),
+ NULL, NOTIFICATION_VARIABLE_TYPE_NONE);
+ WFD_RET_IF(noti_err != NOTIFICATION_ERROR_NONE, "Failed to notification_set_text. [%d]", noti_err);
+
+ snprintf(msg, WFD_MAX_SIZE, _("IDS_WIFI_BODY_CONNECTED_TO_PS"), ad->raw_connected_peers[0].ssid);
+ noti_err = notification_set_text(ad->noti_screen_mirroring_play, NOTIFICATION_TEXT_TYPE_CONTENT,
+ msg, NULL, NOTIFICATION_VARIABLE_TYPE_NONE);
+ WFD_RET_IF(noti_err != NOTIFICATION_ERROR_NONE, "Failed to notification_set_text. [%d]", noti_err);
+
+
+ notification_set_property(ad->noti_screen_mirroring_play, NOTIFICATION_PROP_DISABLE_TICKERNOTI);
+
+ /* notify the quick panel */
+ noti_err = notification_insert(ad->noti_screen_mirroring_play, NULL);
+ WFD_RET_IF(noti_err != NOTIFICATION_ERROR_NONE, "Failed to notification_insert. [%d]", noti_err);
+
+ __WFD_APP_FUNC_EXIT__;
+ return;
+}
+#endif
+
+#ifdef WFD_FLIGHT_MODE_SUPPORT
+/**
+ * This function let the app make a change callback for flight mode
+ * @return void
+ * @param[in] key the pointer to the key
+ * @param[in] user_data the pointer to the main data structure
+ */
+static void _wfd_flight_mode_changed(keynode_t *node, void *user_data)
+{
+ __WFD_APP_FUNC_ENTER__;
+ int res = -1;
+ int flight_mode = 0;
+#ifdef WFD_SCREEN_MIRRORING_ENABLED
+ int screen_mirroring_status = 0;
+#endif
+ wfd_appdata_t *ad = (wfd_appdata_t *)user_data;
+ WFD_RET_IF(NULL == ad, "NULL parameters.\n");
+
+ res = vconf_get_bool(VCONFKEY_TELEPHONY_FLIGHT_MODE, &flight_mode);
+ if (res != 0) {
+ WFD_APP_LOG(WFD_APP_LOG_ERROR, "Failed to get flight state from vconf. [%d]\n", res);
+ return;
+ }
+
+ if (flight_mode == FALSE) {
+ WFD_APP_LOG(WFD_APP_LOG_LOW, "Flight mode is off\n");
+ return;
+ }
+
+ /* If flight mode is on, turn off WFD */
+ wifi_direct_get_state(&ad->wfd_status);
+ if (WIFI_DIRECT_STATE_DEACTIVATED == ad->wfd_status) {
+ WFD_APP_LOG(WFD_APP_LOG_LOW, "Wi-Fi Direct is deactivated.\n");
+ return;
+ }
+
+ /* If connected, disconnect all devices*/
+ if (WIFI_DIRECT_STATE_CONNECTED == ad->wfd_status) {
+ res = wifi_direct_disconnect_all();
+ if (res != WIFI_DIRECT_ERROR_NONE) {
+ WFD_APP_LOG(WFD_APP_LOG_ERROR, "Failed to send disconnection request to all. [%d]\n", res);
+ return;
+ }
+ }
+
+ WFD_APP_LOG(WFD_APP_LOG_HIGH, "Deactivating WiFi DIrect..."
+ "Due to Flight Mode is Enabled\n");
+ res = wifi_direct_deactivate();
+ if (res != WIFI_DIRECT_ERROR_NONE) {
+ WFD_APP_LOG(WFD_APP_LOG_ERROR, "Failed to deactivate Wi-Fi Direct. error code = [%d]\n", res);
+ return;
+ }
+
+#ifdef WFD_SCREEN_MIRRORING_ENABLED
+ /* checking Screen Mirroring */
+ if (vconf_get_int(VCONFKEY_SCREEN_MIRRORING_STATE, &screen_mirroring_status) < 0)
+ {
+ WFD_APP_LOG(WFD_APP_LOG_ERROR, "Failed to get vconf VCONFKEY_SCREEN_MIRRORING_STATE\n");
+ }
+ WFD_APP_LOG(WFD_APP_LOG_LOW, "screen_mirroring_status: %d\n", screen_mirroring_status);
+
+ if(screen_mirroring_status > VCONFKEY_SCREEN_MIRRORING_DEACTIVATED) {
+ res = vconf_set_int(VCONFKEY_SCREEN_MIRRORING_STATE, VCONFKEY_SCREEN_MIRRORING_DEACTIVATED);
+ if (res < 0) {
+ WFD_APP_LOG(WFD_APP_LOG_ERROR, "Failed to set vconf VCONFKEY_SCREEN_MIRRORING_STATE\n");
+ }
+ }
+#endif
+
+ __WFD_APP_FUNC_EXIT__;
+}
+#endif
+
+static void _wfd_cpu_limit_mode_changed(keynode_t *node, void *user_data)
+{
+ __WFD_APP_FUNC_ENTER__;
+ wfd_appdata_t *ad = (wfd_appdata_t *)user_data;
+ WFD_RET_IF(NULL == ad, "NULL parameters.\n");
+ int power_mode = 0;
+ int screen_mirroring_status = 0;
+ int cup_limit_mode = 0;
+
+ if (vconf_get_int(VCONFKEY_SCREEN_MIRRORING_STATE, &screen_mirroring_status) < 0) {
+ WFD_APP_LOG(WFD_APP_LOG_ERROR, "Failed to get vconf VCONFKEY_SCREEN_MIRRORING_STATE\n");
+ return;
+ }
+
+ if (screen_mirroring_status != VCONFKEY_SCREEN_MIRRORING_CONNECTED) {
+ WFD_APP_LOG(WFD_APP_LOG_LOW, "Allshare cast is not connected\n");
+ return;
+ }
+
+ if(vconf_get_bool(VCONFKEY_SETAPPL_PWRSV_CUSTMODE_CPU, &cup_limit_mode) < 0) {
+ WFD_APP_LOG(WFD_APP_LOG_ERROR, "Failed to get vconf VCONFKEY_SETAPPL_PWRSV_CUSTMODE_CPU\n");
+ return;
+ }
+
+ if (vconf_get_int(VCONFKEY_SETAPPL_PSMODE, &power_mode) < 0)
+ {
+ WFD_APP_LOG(WFD_APP_LOG_ERROR, "Failed to get vconf VCONFKEY_SETAPPL_PSMODE\n");
+ return;
+ }
+
+ if ((power_mode == SETTING_PSMODE_POWERFUL || power_mode == SETTING_PSMODE_ADVISOR) &&
+ cup_limit_mode){
+ bundle *b = NULL;
+ b = bundle_create();
+ bundle_add(b, "-t", "notification_power_saving_on");
+ _launch_app(PACKAGE_ALLSHARE_CAST, b);
+ bundle_free(b);
+ }
+
+ __WFD_APP_FUNC_EXIT__;
+ return;
+}
+
+static void _wfd_power_saving_mode_changed(keynode_t *node, void *user_data)
+{
+ __WFD_APP_FUNC_ENTER__;
+ wfd_appdata_t *ad = (wfd_appdata_t *)user_data;
+ WFD_RET_IF(NULL == ad, "NULL parameters.\n");
+ int power_mode = 0;
+ int screen_mirroring_status = 0;
+ int cup_limit_mode = 0;
+
+ if (vconf_get_int(VCONFKEY_SCREEN_MIRRORING_STATE, &screen_mirroring_status) < 0) {
+ WFD_APP_LOG(WFD_APP_LOG_ERROR, "Failed to get vconf VCONFKEY_SCREEN_MIRRORING_STATE\n");
+ return;
+ }
+
+ if (screen_mirroring_status != VCONFKEY_SCREEN_MIRRORING_CONNECTED) {
+ WFD_APP_LOG(WFD_APP_LOG_LOW, "Allshare cast is not connected\n");
+ return;
+ }
+
+ if (vconf_get_int(VCONFKEY_SETAPPL_PSMODE, &power_mode) < 0)
+ {
+ WFD_APP_LOG(WFD_APP_LOG_ERROR, "Failed to get vconf VCONFKEY_SETAPPL_PSMODE\n");
+ return;
+ }
+
+ if (power_mode == SETTING_PSMODE_SURVIVAL ||
+ power_mode == SETTING_PSMODE_EMERGENCY) {
+ WFD_APP_LOG(WFD_APP_LOG_LOW, "Ultra power saving mode on\n");
+ bundle *b = NULL;
+ b = bundle_create();
+ bundle_add(b, "-t", "quit_by_ultra_power_saving_on");
+
+ _launch_app(PACKAGE_ALLSHARE_CAST, b);
+ bundle_free(b);
+ } else if (power_mode == SETTING_PSMODE_POWERFUL ||
+ power_mode == SETTING_PSMODE_ADVISOR){
+ if(vconf_get_bool(VCONFKEY_SETAPPL_PWRSV_CUSTMODE_CPU, &cup_limit_mode) < 0) {
+ WFD_APP_LOG(WFD_APP_LOG_ERROR, "Failed to get vconf VCONFKEY_SETAPPL_PWRSV_CUSTMODE_CPU\n");
+ return;
+ }
+
+ if (cup_limit_mode) {
+ bundle *b = NULL;
+ b = bundle_create();
+ bundle_add(b, "-t", "notification_power_saving_on");
+ _launch_app(PACKAGE_ALLSHARE_CAST, b);
+ bundle_free(b);
+ }
+ }
+
+ __WFD_APP_FUNC_EXIT__;
+ return;
+}
+
+static void _wfd_wifi_status_changed(keynode_t *node, void *user_data)
+{
+ __WFD_APP_FUNC_ENTER__;
+ wfd_appdata_t *ad = (wfd_appdata_t *)user_data;
+ WFD_RET_IF(NULL == ad, "NULL parameters.\n");
+ int wifi_status = 0;
+#ifdef WFD_SCREEN_MIRRORING_ENABLED
+ int screen_mirroring_status = 0;
+
+ if (vconf_get_int(VCONFKEY_SCREEN_MIRRORING_STATE, &screen_mirroring_status) < 0) {
+ WFD_APP_LOG(WFD_APP_LOG_ERROR, "Failed to get vconf VCONFKEY_SCREEN_MIRRORING_STATE\n");
+ return;
+ }
+
+ if (screen_mirroring_status != VCONFKEY_SCREEN_MIRRORING_CONNECTED) {
+ WFD_APP_LOG(WFD_APP_LOG_LOW, "Allshare cast is not connected\n");
+ return;
+ }
+#endif
+
+ if (vconf_get_int(VCONFKEY_WIFI_STATE, &wifi_status) < 0)
+ {
+ WFD_APP_LOG(WFD_APP_LOG_ERROR, "Failed to get vconf VCONFKEY_WIFI_STATE\n");
+ return;
+ }
+
+ WFD_APP_LOG(WFD_APP_LOG_LOW, "Wi-Fi state is [%d]\n", wifi_status);
+ if (wifi_status == VCONFKEY_WIFI_CONNECTED) {
+ WFD_APP_LOG(WFD_APP_LOG_LOW, "Wi-Fi is connected\n");
+#ifdef WFD_SCREEN_MIRRORING_ENABLED
+ ad->screen_mirroring_state = WFD_POP_SCREEN_MIRROR_DISCONNECT_BY_RECONNECT_WIFI_AP;
+ bundle *b = NULL;
+ b = bundle_create();
+ bundle_add(b, "-t", "reconnect_by_connecting_wifi_ap");
+
+ _launch_app(PACKAGE_ALLSHARE_CAST, b);
+ bundle_free(b);
+#endif
+ } else if (VCONFKEY_WIFI_OFF == wifi_status) {
+ /* Deactivate WiFi Direct */
+ WFD_APP_LOG(WFD_APP_LOG_LOW, "Deactivate WiFi Direct...");
+ wfd_destroy_popup();
+ /*
+ * Currently, WiFi Direct OFF is handled at net-config.
+ * Also, this patch is added to support ON-DEMAND launch destroy popup.
+ * This patch will handle 5sec deadlock of popup destory from
+ * wfd-manager.
+ */
+ /* wfd_app_client_switch_off(ad); */
+ } else {
+ WFD_APP_LOG(WFD_APP_LOG_LOW, "Wi-Fi state is [%d]\n", wifi_status);
+ }
+
+ __WFD_APP_FUNC_EXIT__;
+ return;
+}
+
+#ifdef WFD_SCREEN_MIRRORING_ENABLED
+/**
+ * This function let the app make a change callback for allshare cast
+ * @return void
+ * @param[in] key the pointer to the key
+ * @param[in] user_data the pointer to the main data structure
+ */
+static void _wfd_allshare_cast_status_changed(keynode_t *node, void *user_data)
+{
+ __WFD_APP_FUNC_ENTER__;
+
+ int screen_mirroring_status = 0;
+ wfd_appdata_t *ad = (wfd_appdata_t *)user_data;
+ WFD_RET_IF(NULL == ad, "NULL parameters.\n");
+
+ if (vconf_get_int(VCONFKEY_SCREEN_MIRRORING_STATE, &screen_mirroring_status) < 0)
+ {
+ WFD_APP_LOG(WFD_APP_LOG_ERROR, "Failed to get vconf VCONFKEY_SCREEN_MIRRORING_STATE\n");
+ }
+
+ WFD_APP_LOG(WFD_APP_LOG_ERROR, "VCONFKEY_SCREEN_MIRRORING_STATE:%d\n", screen_mirroring_status);
+
+ if (screen_mirroring_status == VCONFKEY_SCREEN_MIRRORING_CONNECTED) {
+ WFD_APP_LOG(WFD_APP_LOG_LOW, "Allshare cast is connected\n");
+ if (ad->transmit_timer) {
+ ecore_timer_del(ad->transmit_timer);
+ ad->transmit_timer = NULL;
+ }
+ /* add connected notification */
+ _add_wfd_peers_connected_notification(ad, PACKAGE_ALLSHARE_CAST);
+ } else if (screen_mirroring_status == VCONFKEY_SCREEN_MIRRORING_ACTIVATED) {
+ WFD_APP_LOG(WFD_APP_LOG_LOW, "Allshare cast is ACTIVATED\n");
+ _add_screen_mirroring_activated_indicator(ad);
+ } else {
+ WFD_APP_LOG(WFD_APP_LOG_LOW, "Allshare cast is not connected\n");
+ if (ad->noti_screen_mirroring_on) {
+ notification_delete(ad->noti_screen_mirroring_on);
+ notification_free(ad->noti_screen_mirroring_on);
+ ad->noti_screen_mirroring_on = NULL;
+ }
+
+ if (ad->noti_screen_mirroring_play) {
+ notification_delete(ad->noti_screen_mirroring_play);
+ notification_free(ad->noti_screen_mirroring_play);
+ ad->noti_screen_mirroring_play = NULL;
+ }
+ }
+
+ return;
+
+ __WFD_APP_FUNC_EXIT__;
+}
+#endif
+
+static Eina_Bool _wfd_hard_key_down_cb(void *data, int type, void *event)
+{
+ wfd_appdata_t *ad = (wfd_appdata_t *)data;
+ Ecore_Event_Key *ev = (Ecore_Event_Key *)event;
+ int res = 0;
+
+ WFD_APP_LOG(WFD_APP_LOG_HIGH, "Hard Key Pressed CB...");
+ if (NULL == ad || NULL == ev) {
+ WFD_APP_LOG(WFD_APP_LOG_ERROR, "Invalid AppData parameter");
+ return EINA_FALSE;
+ }
+
+ if (!strcmp(ev->keyname, KEY_SELECT)) {
+ WFD_APP_LOG(WFD_APP_LOG_HIGH, "[KEY]KEY_SELECT pressed");
+ WFD_APP_LOG(WFD_APP_LOG_HIGH, "Mac : %s", ad->mac_addr_connecting);
+
+ if (strnlen(ad->mac_addr_connecting, MACSTR_LENGTH) > 0) {
+ res = wifi_direct_reject_connection(ad->mac_addr_connecting);
+ if (res != WIFI_DIRECT_ERROR_NONE) {
+ WFD_APP_LOG(WFD_APP_LOG_ERROR, "Failed to reject connection(%d)", res);
+ }
+ }
+ memset(ad->mac_addr_connecting, 0x00, MACSTR_LENGTH);
+ wfd_destroy_popup();
+ } else {
+ WFD_APP_LOG(WFD_APP_LOG_HIGH, "[KEY][%s] pressed not Handled",
+ ev->keyname);
+ }
+
+ return EINA_FALSE;
+}
+
+int wfd_app_util_register_hard_key_down_cb(void *data)
+{
+ wfd_appdata_t *ad = (wfd_appdata_t *)data;
+
+ if (NULL == ad) {
+ WFD_APP_LOG(WFD_APP_LOG_ERROR, "Invalid AppData parameter");
+ return -1;
+ }
+
+ WFD_APP_LOG(WFD_APP_LOG_HIGH, "Register hard key down press CB !!!");
+ if (NULL == ad->downkey_handler)
+ ad->downkey_handler = ecore_event_handler_add(ECORE_EVENT_KEY_DOWN,
+ _wfd_hard_key_down_cb, ad);
+
+ return 0;
+}
+
+int wfd_app_util_deregister_hard_key_down_cb(void *data)
+{
+ wfd_appdata_t *ad = (wfd_appdata_t *)data;
+
+ if (NULL == ad) {
+ WFD_APP_LOG(WFD_APP_LOG_ERROR, "Invalid AppData parameter");
+ return -1;
+ }
+ WFD_APP_LOG(WFD_APP_LOG_HIGH, "Deregister hard key down press CB !!!");
+ if (NULL != ad->downkey_handler) {
+ ecore_event_handler_del(ad->downkey_handler);
+ ad->downkey_handler = NULL;
+ }
+ return 0;
+}
+
+int wfd_app_util_register_vconf_callbacks(void *data)
+{
+ wfd_appdata_t *ad = NULL;
+ int ret = 0;
+
+ if (!data) {
+ WFD_APP_LOG(WFD_APP_LOG_ERROR, "Invalid parameter");
+ return -1;
+ }
+
+ ad = data;
+
+#ifdef WFD_FLIGHT_MODE_SUPPORT
+ /* register flight mode */
+ ret = vconf_notify_key_changed(VCONFKEY_TELEPHONY_FLIGHT_MODE,
+ _wfd_flight_mode_changed, ad);
+ if (ret < 0) {
+ WFD_APP_LOG(WFD_APP_LOG_ERROR, "Failed to register vconf callback for flight mode\n");
+ return -1;
+ }
+#endif
+
+#ifdef WFD_SCREEN_MIRRORING_ENABLED
+ /* allshare cast */
+ /* TODO: Make proper changes for vconfkey */
+ ret = vconf_notify_key_changed(VCONFKEY_SCREEN_MIRRORING_STATE,
+ _wfd_allshare_cast_status_changed, ad);
+ if (ret < 0) {
+ WFD_APP_LOG(WFD_APP_LOG_ERROR, "Failed to register vconf callback for allshare cast\n");
+ return -1;
+ }
+#endif
+
+ /* wifi */
+ ret = vconf_notify_key_changed(VCONFKEY_WIFI_STATE, _wfd_wifi_status_changed, ad);
+ if (ret < 0) {
+ WFD_APP_LOG(WFD_APP_LOG_ERROR, "Failed to register vconf callback for wifi\n");
+ return -1;
+ }
+
+ /* power mode */
+ ret = vconf_notify_key_changed(VCONFKEY_SETAPPL_PSMODE, _wfd_power_saving_mode_changed, ad);
+ if (ret < 0) {
+ WFD_APP_LOG(WFD_APP_LOG_ERROR, "Failed to register vconf callback for power mode\n");
+ return -1;
+ }
+
+ /* cpu limit mode */
+ ret = vconf_notify_key_changed(VCONFKEY_SETAPPL_PWRSV_CUSTMODE_CPU, _wfd_cpu_limit_mode_changed, ad);
+ if (ret < 0) {
+ WFD_APP_LOG(WFD_APP_LOG_ERROR, "Failed to register vconf callback for cpu limit mode\n");
+ return -1;
+ }
+
+#ifdef WFD_HOSTAPD_ENABLER
+ /*Register call back for Tethering status change */
+ ret = vconf_notify_key_changed(VCONFKEY_MOBILE_HOTSPOT_MODE,
+ __wfd_hotspot_mode_popup_vconf_change_cb, ad);
+ if (ret) {
+ WFD_APP_LOG(WFD_APP_LOG_HIGH,
+ "Failed to set vconf notification callback(MOBILE_HOTSPOT_MODE: %d", ret);
+ return FALSE;
+ }
+#endif
+
+ return 0;
+}
+
+int wfd_app_util_deregister_vconf_callbacks(void *data)
+{
+ int ret = 0;
+
+#ifdef WFD_FLIGHT_MODE_SUPPORT
+ /* remove callback for flight mode */
+ ret = vconf_ignore_key_changed(VCONFKEY_TELEPHONY_FLIGHT_MODE, _wfd_flight_mode_changed);
+ if (ret == -1) {
+ WFD_APP_LOG(WFD_APP_LOG_ERROR, "Failed to ignore vconf key callback for flight mode\n");
+ }
+#endif
+
+#ifdef WFD_SCREEN_MIRRORING_ENABLED
+ /* remove callback for allshare cast */
+ ret = vconf_ignore_key_changed(VCONFKEY_SCREEN_MIRRORING_STATE, _wfd_allshare_cast_status_changed);
+ if (ret == -1) {
+ WFD_APP_LOG(WFD_APP_LOG_ERROR, "Failed to ignore vconf key callback for allshare cast\n");
+ }
+#endif
+
+ /* remove callback for wifi */
+ ret = vconf_ignore_key_changed(VCONFKEY_WIFI_STATE, _wfd_wifi_status_changed);
+ if (ret == -1) {
+ WFD_APP_LOG(WFD_APP_LOG_ERROR, "Failed to ignore vconf key callback for wifi\n");
+ }
+
+ /* remove callback for power mode */
+ ret = vconf_ignore_key_changed(VCONFKEY_SETAPPL_PSMODE, _wfd_power_saving_mode_changed);
+ if (ret == -1) {
+ WFD_APP_LOG(WFD_APP_LOG_ERROR, "Failed to ignore vconf key callback for power mode\n");
+ }
+
+ /* remove callback for cpu limit mode */
+ ret = vconf_ignore_key_changed(VCONFKEY_SETAPPL_PWRSV_CUSTMODE_CPU, _wfd_cpu_limit_mode_changed);
+ if (ret == -1) {
+ WFD_APP_LOG(WFD_APP_LOG_ERROR, "Failed to ignore vconf key callback for cpu limit mode\n");
+ }
+
+ return 0;
+}
+
+/**
+ * This function let the app delete the notification
+ * @return void
+ */
+void wfd_app_util_del_notification(wfd_appdata_t *ad)
+{
+ __WFD_APP_FUNC_ENTER__;
+ WFD_RET_IF(NULL == ad, "NULL parameters.\n");
+
+ /* delete the notification */
+ notification_error_e noti_err = NOTIFICATION_ERROR_NONE;
+
+ noti_err = notification_delete_all_by_type(NULL, NOTIFICATION_TYPE_ONGOING);
+ if (noti_err != NOTIFICATION_ERROR_NONE) {
+ WFD_APP_LOG(WFD_APP_LOG_ERROR, "Fail to notification_delete_all_by_type.(%d)\n", noti_err);
+ return;
+ }
+
+#ifdef WFD_SCREEN_MIRRORING_ENABLED
+ if (ad->noti_screen_mirroring_on) {
+ noti_err = notification_free(ad->noti_screen_mirroring_on);
+ ad->noti_screen_mirroring_on = NULL;
+ if (noti_err != NOTIFICATION_ERROR_NONE) {
+ WFD_APP_LOG(WFD_APP_LOG_ERROR, "Fail to notification_free.(%d)\n", noti_err);
+ }
+ }
+
+ if (ad->noti_screen_mirroring_play) {
+ noti_err = notification_free(ad->noti_screen_mirroring_play);
+ ad->noti_screen_mirroring_play = NULL;
+ if (noti_err != NOTIFICATION_ERROR_NONE) {
+ WFD_APP_LOG(WFD_APP_LOG_ERROR, "Fail to notification_free.(%d)\n", noti_err);
+ }
+ }
+#endif
+
+#ifdef NOT_CONNECTED_INDICATOR_ICON
+ if (ad->noti_wifi_direct_on) {
+ noti_err = notification_free(ad->noti_wifi_direct_on);
+ ad->noti_wifi_direct_on = NULL;
+ if (noti_err != NOTIFICATION_ERROR_NONE) {
+ WFD_APP_LOG(WFD_APP_LOG_ERROR, "Fail to notification_free.(%d)\n", noti_err);
+ }
+ }
+#endif
+
+ if (ad->noti_wifi_direct_connected) {
+ noti_err = notification_free(ad->noti_wifi_direct_connected);
+ ad->noti_wifi_direct_connected = NULL;
+ if (noti_err != NOTIFICATION_ERROR_NONE) {
+ WFD_APP_LOG(WFD_APP_LOG_ERROR, "Fail to notification_free.(%d)\n", noti_err);
+ }
+ }
+
+ __WFD_APP_FUNC_EXIT__;
+ return;
+}
+
+#ifdef NOT_CONNECTED_INDICATOR_ICON
+/**
+ * This function let the app add the indicator icon when wfd is activated
+ * @return void
+ * @param[in] user_data the pointer to the main data structure
+ */
+void wfd_app_util_add_indicator_icon(void *user_data)
+{
+ __WFD_APP_FUNC_ENTER__;
+ wfd_appdata_t *ad = (wfd_appdata_t *) user_data;
+ notification_error_e noti_err = NOTIFICATION_ERROR_NONE;
+ WFD_RET_IF(ad->noti_wifi_direct_on, "Indicator already exists");
+
+ if(ad->noti_wifi_direct_on != NULL) {
+ noti_err = notification_free(ad->noti_wifi_direct_on);
+ WFD_RET_IF(noti_err != NOTIFICATION_ERROR_NONE, "Failed to notification_free. [%d]", noti_err);
+ }
+
+ ad->noti_wifi_direct_on = notification_new(NOTIFICATION_TYPE_ONGOING, NOTIFICATION_GROUP_ID_NONE, NOTIFICATION_PRIV_ID_NONE);
+ WFD_RET_IF(NULL == ad->noti_wifi_direct_on, "NULL parameters.\n");
+
+ noti_err = notification_set_image(ad->noti_wifi_direct_on, NOTIFICATION_IMAGE_TYPE_ICON_FOR_INDICATOR, WFD_ACTIVATED_NOTI_ICON_PATH);
+ WFD_RET_IF(noti_err != NOTIFICATION_ERROR_NONE, "Failed to notification_set_image. [%d]", noti_err);
+
+ noti_err = notification_set_property(ad->noti_wifi_direct_on, NOTIFICATION_PROP_DISABLE_TICKERNOTI);
+ WFD_RET_IF(noti_err != NOTIFICATION_ERROR_NONE, "Unable to notification_set_property. [%d]", noti_err);
+
+ noti_err = notification_set_display_applist(ad->noti_wifi_direct_on, NOTIFICATION_DISPLAY_APP_INDICATOR);
+ WFD_RET_IF(noti_err != NOTIFICATION_ERROR_NONE, "Unable to notification_set_display_applist. [%d]", noti_err);
+
+ /* notify the quick panel */
+ noti_err = notification_insert(ad->noti_wifi_direct_on, NULL);
+ WFD_RET_IF(noti_err != NOTIFICATION_ERROR_NONE, "Failed to notification_insert. [%d]", noti_err);
+
+ __WFD_APP_FUNC_EXIT__;
+ return;
+}
+#endif
+
+#ifdef WFD_SCREEN_MIRRORING_ENABLED
+/**
+ * This function let the app set VCONFKEY_SCREEN_MIRRORING_STATE to be DEACTIVATED
+*/
+void wfd_app_util_set_screen_mirroring_deactivated(wfd_appdata_t *ad)
+{
+ __WFD_APP_FUNC_ENTER__;
+ WFD_RET_IF(NULL == ad, "NULL == ad!\n");
+ int screen_mirroring_status = -1;
+ int result = -1;
+
+ /* Reconnect by ap connected, no need to set vconf to DEACTIVATED, allshare cast itself will set ACTIVATED*/
+ if (ad->screen_mirroring_state == WFD_POP_SCREEN_MIRROR_DISCONNECT_BY_RECONNECT_WIFI_AP) {
+ ad->screen_mirroring_state = WFD_POP_SCREEN_MIRROR_NONE;
+ WFD_APP_LOG(WFD_APP_LOG_ERROR, "Reconnect screen mirroring by app connected.\n");
+ return;
+ }
+
+ if (vconf_get_int(VCONFKEY_SCREEN_MIRRORING_STATE, &screen_mirroring_status) < 0) {
+ WFD_APP_LOG(WFD_APP_LOG_ERROR, "Failed to get vconf VCONFKEY_SCREEN_MIRRORING_STATE\n");
+ }
+
+ WFD_APP_LOG(WFD_APP_LOG_LOW, "screen_mirroring_status: %d\n", screen_mirroring_status);
+ /* Set the vconf value to DEACTIVATED only when the previous vconf value is CONNECTED.
+ If the previous vconf value is ACTIVATED, it means that the Screen Mirroring UG changed that key already. So no need to change it. */
+ if(screen_mirroring_status == VCONFKEY_SCREEN_MIRRORING_CONNECTED) {
+ result = vconf_set_int(VCONFKEY_SCREEN_MIRRORING_STATE, VCONFKEY_SCREEN_MIRRORING_DEACTIVATED);
+ if (result < 0) {
+ WFD_APP_LOG(WFD_APP_LOG_ERROR, "Failed to set vconf VCONFKEY_SCREEN_MIRRORING_STATE\n");
+ }
+ notification_status_message_post(_("IDS_SMR_POP_SCREEN_MIRRORING_HAS_BEEN_DISABLED"));
+ }
+
+ __WFD_APP_FUNC_EXIT__;
+}
+#endif
+/**
+ * This function let the app add the notification when it shoule be turned off
+ * @return void
+ * @param[in] user_data the pointer to the main data structure
+ */
+void wfd_app_util_add_wfd_turn_off_notification(void *user_data)
+{
+ __WFD_APP_FUNC_ENTER__;
+
+ int res = NOTIFICATION_ERROR_NONE;
+ wfd_appdata_t *ad = (wfd_appdata_t *) user_data;
+ notification_error_e noti_err = NOTIFICATION_ERROR_NONE;
+
+ WFD_RET_IF(NULL == ad, "NULL parameters.\n");
+
+ /* delete all notifications */
+ wfd_app_util_del_notification(ad);
+
+ if(ad->noti_wifi_direct_connected!= NULL) {
+ noti_err = notification_free(ad->noti_wifi_direct_connected);
+ WFD_RET_IF(noti_err != NOTIFICATION_ERROR_NONE, "Failed to notification_free. [%d]", noti_err);
+ }
+
+ ad->noti_wifi_direct_connected = (notification_h) notification_new(NOTIFICATION_TYPE_ONGOING, NOTIFICATION_GROUP_ID_NONE, NOTIFICATION_PRIV_ID_NONE);
+ WFD_RET_IF(NULL == ad->noti_wifi_direct_connected, "NULL parameters.\n");
+
+ bundle *b = NULL;
+ app_control_h control;
+ res = app_control_create(&control);
+ WFD_RET_IF(res != APP_CONTROL_ERROR_NONE, "app_control_create() return error : %d", res);
+
+ app_control_set_package(control, PACKAGE);
+ app_control_add_extra_data(control, NOTIFICATION_BUNDLE_PARAM, NOTIFICATION_BUNDLE_VALUE);
+ res = app_control_to_bundle(control, &b);
+ if (res != APP_CONTROL_ERROR_NONE) {
+ WFD_APP_LOG(WFD_APP_LOG_ERROR, "app_control_to_bundle() return error : %d", res);
+ app_control_destroy(control);
+ return;
+ }
+
+ noti_err = notification_set_execute_option(ad->noti_wifi_direct_connected, NOTIFICATION_EXECUTE_TYPE_SINGLE_LAUNCH, /*Button Text*/NULL, NULL, b);
+ if (noti_err != NOTIFICATION_ERROR_NONE) {
+ WFD_APP_LOG(WFD_APP_LOG_ERROR, "Failed to notification_set_execute_option. [%d]", noti_err);
+ app_control_destroy(control);
+ return;
+ }
+
+ app_control_destroy(control);
+
+ noti_err = notification_set_layout(ad->noti_wifi_direct_connected, NOTIFICATION_LY_ONGOING_EVENT);
+ WFD_RET_IF(noti_err != NOTIFICATION_ERROR_NONE, "Failed to notification_set_layout. [%d]", noti_err);
+
+ /* set the icon */
+ WFD_APP_LOG(WFD_APP_LOG_ERROR, "Icon Path: %s\n", WFD_NOTI_ICON_PATH);
+ noti_err = notification_set_image(ad->noti_wifi_direct_connected, NOTIFICATION_IMAGE_TYPE_ICON, WFD_NOTI_ICON_PATH);
+ WFD_RET_IF(noti_err != NOTIFICATION_ERROR_NONE, "Failed to notification_set_image. [%d]", noti_err);
+
+ noti_err = notification_set_display_applist(ad->noti_wifi_direct_connected, NOTIFICATION_DISPLAY_APP_TICKER | NOTIFICATION_DISPLAY_APP_NOTIFICATION_TRAY);
+ WFD_RET_IF(noti_err != NOTIFICATION_ERROR_NONE, "Unable to notification_set_display_applist. [%d]", noti_err);
+
+ noti_err = notification_set_text_domain(ad->noti_wifi_direct_connected, LOCALE_FILE_NAME, LOCALEDIR);
+ WFD_RET_IF(noti_err != NOTIFICATION_ERROR_NONE, "Failed to notification_set_text_domain. [%d]", noti_err);
+
+ /* set the title and content */
+ noti_err = notification_set_text(ad->noti_wifi_direct_connected, NOTIFICATION_TEXT_TYPE_TITLE,
+ _("IDS_WIFI_BODY_WI_FI_DIRECT_ABB"), "IDS_WIFI_BODY_WI_FI_DIRECT_ABB", NOTIFICATION_VARIABLE_TYPE_NONE);
+ WFD_RET_IF(noti_err != NOTIFICATION_ERROR_NONE, "Failed to notification_set_text. [%d]", noti_err);
+
+ noti_err = notification_set_text(ad->noti_wifi_direct_connected, NOTIFICATION_TEXT_TYPE_CONTENT,
+ _("IDS_WIFI_BODY_DISABLE_WI_FI_DIRECT_AFTER_USE_ABB"),
+ "IDS_WIFI_BODY_DISABLE_WI_FI_DIRECT_AFTER_USE_ABB", NOTIFICATION_VARIABLE_TYPE_NONE);
+ WFD_RET_IF(noti_err != NOTIFICATION_ERROR_NONE, "Failed to notification_set_text. [%d]", noti_err);
+
+ /* notify the quick panel */
+ noti_err = notification_insert(ad->noti_wifi_direct_connected, NULL);
+ WFD_RET_IF(noti_err != NOTIFICATION_ERROR_NONE, "Failed to notification_insert. [%d]", noti_err);
+
+ __WFD_APP_FUNC_EXIT__;
+ return;
+
+}
+
+void wfd_app_util_del_wfd_connected_notification(wfd_appdata_t *ad)
+{
+ __WFD_APP_FUNC_ENTER__;
+ WFD_RET_IF(NULL == ad, "NULL parameters.\n");
+
+ /* delete the notification */
+ notification_error_e noti_err = NOTIFICATION_ERROR_NONE;
+
+ noti_err = notification_delete(ad->noti_wifi_direct_connected);
+ if (noti_err != NOTIFICATION_ERROR_NONE) {
+ WFD_APP_LOG(WFD_APP_LOG_ERROR, "Fail to notification_delete.(%d)\n", noti_err);
+ return;
+ }
+
+ if (ad->noti_wifi_direct_connected) {
+ noti_err = notification_free(ad->noti_wifi_direct_connected);
+ ad->noti_wifi_direct_connected = NULL;
+ if (noti_err != NOTIFICATION_ERROR_NONE) {
+ WFD_APP_LOG(WFD_APP_LOG_ERROR, "Fail to notification_free.(%d)\n", noti_err);
+ }
+ }
+
+ __WFD_APP_FUNC_EXIT__;
+ return;
+}