From: Maneesh Jain Date: Thu, 12 May 2016 10:39:18 +0000 (+0530) Subject: [wfd-manager]: Add support of "InvitationReceived" Signal X-Git-Tag: accepted/tizen/common/20160517.174224~9 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=refs%2Fchanges%2F73%2F69273%2F3;p=platform%2Fcore%2Fconnectivity%2Fwifi-direct-manager.git [wfd-manager]: Add support of "InvitationReceived" Signal Change-Id: I3e4a8614343d8af7b6529fbd446599ab99984032 Signed-off-by: Maneesh Jain --- diff --git a/oem/wifi-direct-oem.h b/oem/wifi-direct-oem.h index 7cebff8..ab5a409 100755 --- a/oem/wifi-direct-oem.h +++ b/oem/wifi-direct-oem.h @@ -112,6 +112,7 @@ typedef enum { #endif /* TIZEN_FEATURE_SERVICE_DISCOVERY */ WFD_OEM_EVENT_GROUP_FORMATION_FAILURE, + WFD_OEM_EVENT_INVITATION_ACCEPTED, WFD_OEM_EVENT_MAX, } wfd_oem_event_e; diff --git a/plugin/wpasupplicant/ctrl_iface_dbus/wfd-plugin-wpasupplicant.c b/plugin/wpasupplicant/ctrl_iface_dbus/wfd-plugin-wpasupplicant.c index f8d043c..dfae789 100755 --- a/plugin/wpasupplicant/ctrl_iface_dbus/wfd-plugin-wpasupplicant.c +++ b/plugin/wpasupplicant/ctrl_iface_dbus/wfd-plugin-wpasupplicant.c @@ -1844,6 +1844,39 @@ static void _ws_process_group_formation_failure(GDBusConnection *connection, __WDP_LOG_FUNC_EXIT__; } +static void _ws_process_invitation_accepted(GDBusConnection *connection, + const gchar *object_path, GVariant *parameters) +{ + __WDP_LOG_FUNC_ENTER__; + GVariantIter *iter = NULL; + wfd_oem_event_s event; + + memset(&event, 0x0, sizeof(wfd_oem_event_s)); + + event.event_id = WFD_OEM_EVENT_INVITATION_ACCEPTED; + event.edata_type = WFD_OEM_EDATA_TYPE_NONE; + + if (parameters != NULL) { + g_variant_get(parameters, "(a{sv})", &iter); + + if (iter != NULL) { + gchar *key = NULL; + GVariant *value = NULL; + + while (g_variant_iter_loop(iter, "{sv}", &key, &value)) { + CHECK_KEY_VALUE(key, value); + if(g_strcmp0(key, "sa") == 0) + if (__ws_unpack_ay(event.dev_addr, value, WS_MACADDR_LEN)) + WDP_LOGI("[" MACSTR "]", MAC2STR(event.dev_addr)); + } + g_variant_iter_free(iter); + } + } + + g_pd->callback(g_pd->user_data, &event); + __WDP_LOG_FUNC_EXIT__; +} + static struct { const char *interface; const char *member; @@ -1963,6 +1996,11 @@ static struct { _ws_process_group_formation_failure }, { + SUPPLICANT_P2PDEVICE, + "InvitationAccepted", + _ws_process_invitation_accepted + }, + { NULL, NULL, NULL diff --git a/src/wifi-direct-event.c b/src/wifi-direct-event.c index 3b85065..ecf9106 100755 --- a/src/wifi-direct-event.c +++ b/src/wifi-direct-event.c @@ -1223,6 +1223,64 @@ static void __wfd_process_group_formation_failure(wfd_manager_s *manager, wfd_oe __WDS_LOG_FUNC_EXIT__; return; } + +/** + * This event is generated by supplicant when persitent invite is auto accepted + * so that wfd-manager can get indication that a peer will be connected in near future. + * session is started for that peer, so that it is not ignored when connected. + */ +static void __wfd_process_invitation_accepted(wfd_manager_s *manager, wfd_oem_event_s *event) +{ + + __WDS_LOG_FUNC_ENTER__; + + wfd_session_s *session = (wfd_session_s*) manager->session; + wfd_device_s *peer = NULL; + char peer_mac_address[MACSTR_LEN+1] = {0, }; + + peer = wfd_peer_find_by_dev_addr(manager, event->dev_addr); + if (!peer) { + WDS_LOGI("Invitation from unknown peer. Add new peer"); + peer = wfd_add_peer(manager, event->dev_addr, "DIRECT-"); + if (!peer) { + WDS_LOGE("Failed to add peer for invitation"); + __WDS_LOG_FUNC_EXIT__; + return; + } + } + /**By default, peer device information is complete but there's some exception + * if DEV-FOUND event was not preceding before connection start event. + */ + wfd_update_peer(manager, peer); + peer->dev_role = WFD_DEV_ROLE_GO; + + if (!session) { + session = wfd_create_session(manager, event->dev_addr, + event->wps_mode, SESSION_DIRECTION_INCOMING); + if (!session) { + WDS_LOGE("Failed to create session with peer [" MACSTR "]", + MAC2STR(event->dev_addr)); + __WDS_LOG_FUNC_EXIT__; + return; + } + } + + session->state = SESSION_STATE_WPS; + wfd_session_timer(session, 1); + + g_snprintf(peer_mac_address, MACSTR_LEN, MACSTR, MAC2STR(event->dev_addr)); + wfd_manager_dbus_emit_signal(WFD_MANAGER_MANAGE_INTERFACE, + "Connection", + g_variant_new("(iis)", WIFI_DIRECT_ERROR_NONE, + WFD_EVENT_CONNECTION_IN_PROGRESS, + peer_mac_address)); + + wfd_state_set(manager, WIFI_DIRECT_STATE_CONNECTING); + wfd_util_set_wifi_direct_state(WIFI_DIRECT_STATE_CONNECTING); + + __WDS_LOG_FUNC_EXIT__; +} + #ifdef TIZEN_FEATURE_SERVICE_DISCOVERY static void __wfd_process_serv_disc_resp(wfd_manager_s *manager, wfd_oem_event_s *event) { @@ -1414,6 +1472,10 @@ static struct { __wfd_process_group_formation_failure }, { + WFD_OEM_EVENT_INVITATION_ACCEPTED, + __wfd_process_invitation_accepted + }, + { WFD_OEM_EVENT_MAX, NULL }