############################# Check minimum CMake version #####################
CMAKE_MINIMUM_REQUIRED(VERSION 2.8.3)
-PROJECT(wifi-direct C)
+PROJECT(wifi-direct)
SET(PACKAGE_DESCRIPTION "Library and header files for Wi-Fi Direct Native API")
############################# cmake packages ##################################
SET(COMMON_DEPS "dlog glib-2.0 gio-2.0 vconf capi-system-info")
SET(PC_DEPS "capi-base-common")
+SET(TEST_DEPS "glib-2.0")
+SET(GTEST_DEPS "gmock")
SET(TARGET_WIFI_DIRECT "wifi-direct")
SET(TARGET_WIFI_DIRECT_TEST "wifi_direct_test")
+SET(TARGET_WIFI_DIRECT_GTEST "gtest-wifi-direct")
+
+ADD_DEFINITIONS("-DUSE_DLOG")
ADD_SUBDIRECTORY(include)
ADD_SUBDIRECTORY(pkgconfig)
ADD_SUBDIRECTORY(src)
-ADD_SUBDIRECTORY(test)
+ADD_SUBDIRECTORY(tests)
Name: capi-network-wifi-direct
Summary: Network WiFi-Direct Library
-Version: 1.2.104
+Version: 1.3.0
Release: 1
Group: Network & Connectivity/API
License: Apache-2.0
BuildRequires: lcov
BuildRequires: tar
%endif
-%if 0%{?gtest:1}
BuildRequires: pkgconfig(gmock)
-%endif
BuildRequires: cmake
BuildRequires: gettext-devel
Provides: %{name}-profile_wearable = %{version}-%{release}
tar xf %{name}-gcov.tar -C %{buildroot}%{_datadir}/gcov/obj
%endif
+%check
+tests/gtest-wifi-direct
+%if 0%{?gcov:1}
+lcov -c --ignore-errors graph --no-external -b . -d . -o %{name}.info
+genhtml %{name}.info -o out --legend --show-details
+%endif
+
ln -sf libwifi-direct.so.%{version} %{buildroot}/%{_libdir}/libwifi-direct.so.0
%post -p /sbin/ldconfig
%files tool
%{_bindir}/wifi_direct_test
+%{_bindir}/gtest-wifi-direct
%if 0%{?gcov:1}
%files gcov
wifi_direct_dbus_signal_map[i].function,
NULL,
NULL);
- WDC_LOGD("Subscribed dbus signals [%d]", wifi_direct_dbus_signal_map[i].sub_id);
}
}
ref_count++;
+++ /dev/null
-########################## search for packages ################################
-
-PKG_CHECK_MODULES(TARGET_WIFI_DIRECT_TEST_REQ_PKGS REQUIRED glib-2.0)
-
-############################# compiler flags ##################################
-
-SET(EXTRA_FLAGS "-Wall -Werror")
-SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS} ${CFLAGS} -fPIE")
-SET(CMAKE_EXE_LINKER_FLAGS "-Wl,--as-needed -pie")
-
-######################## directory configuration ############################
-
-INCLUDE_DIRECTORIES(${TARGET_WIFI_DIRECT_TEST_REQ_PKGS_INCLUDE_DIRS})
-LINK_DIRECTORIES(${TARGET_WIFI_DIRECT_TEST_REQ_PKGS_LIBRARY_DIRS})
-
-INCLUDE_DIRECTORIES(${PROJECT_SOURCE_DIR}/include)
-
-# Build
-ADD_EXECUTABLE(${TARGET_WIFI_DIRECT_TEST}
- ${CMAKE_CURRENT_SOURCE_DIR}/wifi_direct_test.c
-)
-
-TARGET_LINK_LIBRARIES(${TARGET_WIFI_DIRECT_TEST}
- ${TARGET_WIFI_DIRECT_TEST_REQ_PKGS_LIBRARIES} ${PROJECT_NAME})
-
-#Install
-INSTALL(TARGETS ${TARGET_WIFI_DIRECT_TEST} DESTINATION ${BIN_DIR})
-
--- /dev/null
+########################## search for packages ################################
+
+PKG_CHECK_MODULES(TARGET_WIFI_DIRECT_TEST_REQ_PKGS REQUIRED glib-2.0)
+
+############################# compiler flags ##################################
+
+SET(EXTRA_FLAGS "-Wall -Werror")
+SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS} ${CFLAGS} -fPIE")
+SET(CMAKE_EXE_LINKER_FLAGS "-Wl,--as-needed -pie")
+
+######################## directory configuration ############################
+
+INCLUDE_DIRECTORIES(${TARGET_WIFI_DIRECT_TEST_REQ_PKGS_INCLUDE_DIRS})
+LINK_DIRECTORIES(${TARGET_WIFI_DIRECT_TEST_REQ_PKGS_LIBRARY_DIRS})
+
+INCLUDE_DIRECTORIES(${PROJECT_SOURCE_DIR}/include)
+
+# Build
+ADD_EXECUTABLE(${TARGET_WIFI_DIRECT_TEST}
+ ${CMAKE_CURRENT_SOURCE_DIR}/wifi_direct_test.c
+)
+
+TARGET_LINK_LIBRARIES(${TARGET_WIFI_DIRECT_TEST}
+ ${TARGET_WIFI_DIRECT_TEST_REQ_PKGS_LIBRARIES} ${PROJECT_NAME})
+
+#Install
+INSTALL(TARGETS ${TARGET_WIFI_DIRECT_TEST} DESTINATION ${BIN_DIR})
+
+########################## search for packages ################################
+
+PKG_CHECK_MODULES(TARGET_WIFI_DIRECT_GTEST_REQ_PKGS REQUIRED ${GTEST_DEPS} ${COMMON_DEPS})
+
+############################# compiler flags ##################################
+
+SET(EXTRA_FLAGS "-Wall -Werror")
+SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS} ${CFLAGS} -fPIE")
+SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${EXTRA_FLAGS} -std=c++11")
+SET(CMAKE_EXE_LINKER_FLAGS "-Wl,--as-needed -pie")
+
+######################## directory configuration ############################
+
+INCLUDE_DIRECTORIES(${TARGET_WIFI_DIRECT_GTEST_REQ_PKGS_INCLUDE_DIRS})
+LINK_DIRECTORIES(${TARGET_WIFI_DIRECT_GTEST_REQ_PKGS_LIBRARY_DIRS})
+
+INCLUDE_DIRECTORIES(${PROJECT_SOURCE_DIR}/include)
+INCLUDE_DIRECTORIES(${PROJECT_SOURCE_DIR}/src/include)
+INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/include)
+
+FILE(GLOB GTEST_SRCS *.cpp mocks/*.cpp mocks/*.c mocks/WifiDirectManager/*.cpp ${CMAKE_SOURCE_DIR}/src/*.c)
+
+# Build
+ADD_EXECUTABLE(${TARGET_WIFI_DIRECT_GTEST} ${GTEST_SRCS})
+
+MESSAGE("${WIFI_DIRECT_DEPS_LIBRARIES}")
+TARGET_LINK_LIBRARIES(${TARGET_WIFI_DIRECT_GTEST}
+ ${TARGET_WIFI_DIRECT_GTEST_REQ_PKGS_LIBRARIES}
+ ${WIFI_DIRECT_DEPS_LIBRARIES})
+
+SET_TARGET_PROPERTIES(${TARGET_WIFI_DIRECT_GTEST} PROPERTIES
+ COMPILE_FLAGS "-fPIE"
+ #Never add any space for LINKFLAGS
+ LINK_FLAGS "-Wl,\
+--wrap=system_info_get_platform_bool")
+
+INSTALL(TARGETS ${TARGET_WIFI_DIRECT_GTEST} DESTINATION ${BIN_DIR})
--- /dev/null
+/*
+ * gtest-wifi-direct.cpp
+ *
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Sungsik Jang <sungsik.jang@samsung.com>, Dongwook Lee <dwmax.lee@samsung.com>
+ *
+ * Licensed under the Apache License, Version 2.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://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+/*****************************************************************************
+ * Standard headers
+ *****************************************************************************/
+
+/*****************************************************************************
+ * System headers
+ *****************************************************************************/
+#include <glib.h>
+#include <gtest/gtest.h>
+/*****************************************************************************
+ * Local headers
+ *****************************************************************************/
+#include "wifi-direct.h"
+#include "wifi-direct-internal.h"
+
+#include "mock_sysinfo.h"
+#include "mock_gdbus.h"
+#include "wifi_direct_manager_mock.h"
+/*****************************************************************************
+ * Macros and Typedefs
+ *****************************************************************************/
+/*****************************************************************************
+ * Global Variables
+ *****************************************************************************/
+/*****************************************************************************
+ * Local Functions Definition
+ *****************************************************************************/
+
+class WifiDirectInitTest : public ::testing::Test {
+protected:
+ void SetUp() override
+ {
+ //Setting up normal condition
+ mock_gdbus_gdbus_sync_enable(true);
+ mock_gdbus_gdbus_call_sync_enable(true);
+ wifi_direct_manager_mock_init();
+ }
+
+ void TearDown() override
+ {
+ wifi_direct_manager_mock_deinit();
+ }
+};
+
+TEST_F(WifiDirectInitTest, wifi_direct_initialize_Positive)
+{
+ int ret;
+
+ ret = wifi_direct_initialize();
+ ASSERT_EQ(WIFI_DIRECT_ERROR_NONE, ret);
+
+ ret = wifi_direct_deinitialize();
+ ASSERT_EQ(WIFI_DIRECT_ERROR_NONE, ret);
+}
+
+TEST_F(WifiDirectInitTest, wifi_direct_initialize_Negative1)
+{
+ int ret;
+
+ mock_sysinfo_set_up_wifi_direct(false);
+
+ ret = wifi_direct_initialize();
+ ASSERT_EQ(WIFI_DIRECT_ERROR_NOT_SUPPORTED, ret);
+
+ mock_sysinfo_set_up_wifi_direct(true);
+}
+
+TEST_F(WifiDirectInitTest, wifi_direct_initialize_Negative2)
+{
+ int ret;
+
+ ret = wifi_direct_initialize();
+ ASSERT_EQ(WIFI_DIRECT_ERROR_NONE, ret);
+
+ ret = wifi_direct_initialize();
+ ASSERT_EQ(WIFI_DIRECT_ERROR_ALREADY_INITIALIZED, ret);
+
+ ret = wifi_direct_deinitialize();
+ ASSERT_EQ(WIFI_DIRECT_ERROR_NONE, ret);
+}
+
+TEST_F(WifiDirectInitTest, wifi_direct_initialize_Negative3)
+{
+ int ret;
+
+ mock_gdbus_gdbus_sync_enable(false);
+
+ ret = wifi_direct_initialize();
+ ASSERT_EQ(WIFI_DIRECT_ERROR_OPERATION_FAILED, ret);
+
+ mock_gdbus_gdbus_sync_enable(true);
+}
+
+TEST_F(WifiDirectInitTest, wifi_direct_initialize_Negative4)
+{
+ int ret;
+
+ mock_gdbus_gdbus_call_sync_enable(false);
+
+ ret = wifi_direct_initialize();
+ ASSERT_EQ(WIFI_DIRECT_ERROR_OPERATION_FAILED, ret);
+
+ mock_gdbus_gdbus_call_sync_enable(true);
+}
+
+TEST_F(WifiDirectInitTest, wifi_direct_deinitialize_Negative)
+{
+ int ret;
+
+ ret = wifi_direct_deinitialize();
+ ASSERT_EQ(WIFI_DIRECT_ERROR_NOT_INITIALIZED, ret);
+}
+
+static void __device_state_changed_cb(int error_code,
+ wifi_direct_device_state_e device_state,
+ void *user_data)
+{
+ return;
+}
+
+TEST_F(WifiDirectInitTest, wifi_direct_set_device_state_changed_cb_Positive)
+{
+ int ret;
+
+ ret = wifi_direct_initialize();
+ ASSERT_EQ(WIFI_DIRECT_ERROR_NONE, ret);
+
+ ret = wifi_direct_set_device_state_changed_cb(__device_state_changed_cb, NULL);
+ ASSERT_EQ(WIFI_DIRECT_ERROR_NONE, ret);
+
+ ret = wifi_direct_unset_device_state_changed_cb();
+ ASSERT_EQ(WIFI_DIRECT_ERROR_NONE, ret);
+
+ ret = wifi_direct_deinitialize();
+ ASSERT_EQ(WIFI_DIRECT_ERROR_NONE, ret);
+}
+
+TEST_F(WifiDirectInitTest, wifi_direct_set_device_state_changed_cb_Negative)
+{
+ int ret;
+
+ ret = wifi_direct_initialize();
+ ASSERT_EQ(WIFI_DIRECT_ERROR_NONE, ret);
+
+ ret = wifi_direct_set_device_state_changed_cb(NULL, NULL);
+ ASSERT_EQ(WIFI_DIRECT_ERROR_INVALID_PARAMETER, ret);
+
+ ret = wifi_direct_deinitialize();
+ ASSERT_EQ(WIFI_DIRECT_ERROR_NONE, ret);
+}
+
+static void __discovery_state_chagned_cb (int error_code,
+ wifi_direct_discovery_state_e discovery_state,
+ void *user_data)
+{
+ return;
+}
+
+TEST_F(WifiDirectInitTest, wifi_direct_set_discovery_state_changed_cb_Positive)
+{
+ int ret;
+
+ ret = wifi_direct_initialize();
+ ASSERT_EQ(WIFI_DIRECT_ERROR_NONE, ret);
+
+ ret = wifi_direct_set_discovery_state_changed_cb(__discovery_state_chagned_cb, NULL);
+ ASSERT_EQ(WIFI_DIRECT_ERROR_NONE, ret);
+
+ ret = wifi_direct_unset_discovery_state_changed_cb();
+ ASSERT_EQ(WIFI_DIRECT_ERROR_NONE, ret);
+
+ ret = wifi_direct_deinitialize();
+ ASSERT_EQ(WIFI_DIRECT_ERROR_NONE, ret);
+}
+
+TEST_F(WifiDirectInitTest, wifi_direct_set_discovery_state_changed_cb_Negative)
+{
+ int ret;
+
+ ret = wifi_direct_initialize();
+ ASSERT_EQ(WIFI_DIRECT_ERROR_NONE, ret);
+
+ ret = wifi_direct_set_discovery_state_changed_cb(NULL, NULL);
+ ASSERT_EQ(WIFI_DIRECT_ERROR_INVALID_PARAMETER, ret);
+
+ ret = wifi_direct_deinitialize();
+ ASSERT_EQ(WIFI_DIRECT_ERROR_NONE, ret);
+}
+
+static void __peer_found_cb(int error_code,
+ wifi_direct_discovery_state_e discovery_state,
+ const char *mac_address,
+ void *user_data)
+{
+ return;
+}
+
+TEST_F(WifiDirectInitTest, wifi_direct_set_peer_found_cb_Positive)
+{
+ int ret;
+
+ ret = wifi_direct_initialize();
+ ASSERT_EQ(WIFI_DIRECT_ERROR_NONE, ret);
+
+ ret = wifi_direct_set_peer_found_cb(__peer_found_cb, NULL);
+ ASSERT_EQ(WIFI_DIRECT_ERROR_NONE, ret);
+
+ ret = wifi_direct_unset_peer_found_cb();
+ ASSERT_EQ(WIFI_DIRECT_ERROR_NONE, ret);
+
+ ret = wifi_direct_deinitialize();
+ ASSERT_EQ(WIFI_DIRECT_ERROR_NONE, ret);
+}
+
+TEST_F(WifiDirectInitTest, wifi_direct_set_peer_found_cb_Negative)
+{
+ int ret;
+
+ ret = wifi_direct_initialize();
+ ASSERT_EQ(WIFI_DIRECT_ERROR_NONE, ret);
+
+ ret = wifi_direct_set_peer_found_cb(NULL, NULL);
+ ASSERT_EQ(WIFI_DIRECT_ERROR_INVALID_PARAMETER, ret);
+
+ ret = wifi_direct_deinitialize();
+ ASSERT_EQ(WIFI_DIRECT_ERROR_NONE, ret);
+}
+
+static void __service_state_changed_cb (int error_code,
+ wifi_direct_service_discovery_state_e service_state,
+ wifi_direct_service_type_e service_type,
+ void *response_data,
+ const char *mac_address,
+ void *user_data)
+{
+ return;
+}
+
+TEST_F(WifiDirectInitTest, wifi_direct_set_service_state_changed_cb_Positive)
+{
+ int ret;
+
+ ret = wifi_direct_initialize();
+ ASSERT_EQ(WIFI_DIRECT_ERROR_NONE, ret);
+
+ ret = wifi_direct_set_service_state_changed_cb(__service_state_changed_cb, NULL);
+ ASSERT_EQ(WIFI_DIRECT_ERROR_NONE, ret);
+
+ ret = wifi_direct_unset_service_state_changed_cb();
+ ASSERT_EQ(WIFI_DIRECT_ERROR_NONE, ret);
+
+ ret = wifi_direct_deinitialize();
+ ASSERT_EQ(WIFI_DIRECT_ERROR_NONE, ret);
+}
+
+TEST_F(WifiDirectInitTest, wifi_direct_set_service_state_changed_cb_Negative)
+{
+ int ret;
+
+ ret = wifi_direct_initialize();
+ ASSERT_EQ(WIFI_DIRECT_ERROR_NONE, ret);
+
+ ret = wifi_direct_set_service_state_changed_cb(NULL, NULL);
+ ASSERT_EQ(WIFI_DIRECT_ERROR_INVALID_PARAMETER, ret);
+
+ ret = wifi_direct_deinitialize();
+ ASSERT_EQ(WIFI_DIRECT_ERROR_NONE, ret);
+}
+
+static void __connection_state_changed_cb(int error_code,
+ wifi_direct_connection_state_e connection_state,
+ const char *mac_address,
+ void *user_data)
+{
+ return;
+}
+
+TEST_F(WifiDirectInitTest, wifi_direct_set_connection_state_changed_cb_Positive)
+{
+ int ret;
+
+ ret = wifi_direct_initialize();
+ ASSERT_EQ(WIFI_DIRECT_ERROR_NONE, ret);
+
+ ret = wifi_direct_set_connection_state_changed_cb(__connection_state_changed_cb, NULL);
+ ASSERT_EQ(WIFI_DIRECT_ERROR_NONE, ret);
+
+ ret = wifi_direct_unset_connection_state_changed_cb();
+ ASSERT_EQ(WIFI_DIRECT_ERROR_NONE, ret);
+
+ ret = wifi_direct_deinitialize();
+ ASSERT_EQ(WIFI_DIRECT_ERROR_NONE, ret);
+}
+
+TEST_F(WifiDirectInitTest, wifi_direct_set_connection_state_changed_cb_Negative)
+{
+ int ret;
+
+ ret = wifi_direct_initialize();
+ ASSERT_EQ(WIFI_DIRECT_ERROR_NONE, ret);
+
+ ret = wifi_direct_set_connection_state_changed_cb(NULL, NULL);
+ ASSERT_EQ(WIFI_DIRECT_ERROR_INVALID_PARAMETER, ret);
+
+ ret = wifi_direct_deinitialize();
+ ASSERT_EQ(WIFI_DIRECT_ERROR_NONE, ret);
+}
+
+static void __peer_info_connection_state_changed_cb(wifi_direct_error_e error_code,
+ wifi_direct_connection_state_e connection_state,
+ wifi_direct_connection_state_cb_data_s data_s,
+ void *user_data)
+{
+ return;
+}
+
+TEST_F(WifiDirectInitTest, wifi_direct_set_peer_info_connection_state_changed_cb_Positive)
+{
+ int ret;
+
+ ret = wifi_direct_initialize();
+ ASSERT_EQ(WIFI_DIRECT_ERROR_NONE, ret);
+
+ ret = wifi_direct_set_peer_info_connection_state_changed_cb(__peer_info_connection_state_changed_cb, NULL);
+ ASSERT_EQ(WIFI_DIRECT_ERROR_NONE, ret);
+
+ ret = wifi_direct_unset_peer_info_connection_state_changed_cb();
+ ASSERT_EQ(WIFI_DIRECT_ERROR_NONE, ret);
+
+ ret = wifi_direct_deinitialize();
+ ASSERT_EQ(WIFI_DIRECT_ERROR_NONE, ret);
+}
+
+TEST_F(WifiDirectInitTest, wifi_direct_set_peer_info_connection_state_changed_cb_Negative)
+{
+ int ret;
+
+ ret = wifi_direct_initialize();
+ ASSERT_EQ(WIFI_DIRECT_ERROR_NONE, ret);
+
+ ret = wifi_direct_set_peer_info_connection_state_changed_cb(NULL, NULL);
+ ASSERT_EQ(WIFI_DIRECT_ERROR_INVALID_PARAMETER, ret);
+
+ ret = wifi_direct_deinitialize();
+ ASSERT_EQ(WIFI_DIRECT_ERROR_NONE, ret);
+}
+
+static void __client_ip_address_assigned_cb (const char *mac_address,
+ const char *ip_address,
+ const char *interface_address,
+ void *user_data)
+{
+ return;
+}
+
+TEST_F(WifiDirectInitTest, wifi_direct_set_client_ip_address_assigned_cb_Positive)
+{
+ int ret;
+
+ ret = wifi_direct_initialize();
+ ASSERT_EQ(WIFI_DIRECT_ERROR_NONE, ret);
+
+ ret = wifi_direct_set_client_ip_address_assigned_cb(__client_ip_address_assigned_cb, NULL);
+ ASSERT_EQ(WIFI_DIRECT_ERROR_NONE, ret);
+
+ ret = wifi_direct_unset_client_ip_address_assigned_cb();
+ ASSERT_EQ(WIFI_DIRECT_ERROR_NONE, ret);
+
+ ret = wifi_direct_deinitialize();
+ ASSERT_EQ(WIFI_DIRECT_ERROR_NONE, ret);
+}
+
+TEST_F(WifiDirectInitTest, wifi_direct_set_client_ip_address_assigned_cb_Negative)
+{
+ int ret;
+
+ ret = wifi_direct_initialize();
+ ASSERT_EQ(WIFI_DIRECT_ERROR_NONE, ret);
+
+ ret = wifi_direct_set_client_ip_address_assigned_cb(NULL, NULL);
+ ASSERT_EQ(WIFI_DIRECT_ERROR_INVALID_PARAMETER, ret);
+
+ ret = wifi_direct_deinitialize();
+ ASSERT_EQ(WIFI_DIRECT_ERROR_NONE, ret);
+}
+
+static void __state_changed_cb(wifi_direct_state_e state,
+ void *user_data)
+{
+ return;
+}
+
+TEST_F(WifiDirectInitTest, wifi_direct_set_state_changed_cb_Positive)
+{
+ int ret;
+
+ ret = wifi_direct_initialize();
+ ASSERT_EQ(WIFI_DIRECT_ERROR_NONE, ret);
+
+ ret = wifi_direct_set_state_changed_cb(__state_changed_cb, NULL);
+ ASSERT_EQ(WIFI_DIRECT_ERROR_NONE, ret);
+
+ ret = wifi_direct_unset_state_changed_cb();
+ ASSERT_EQ(WIFI_DIRECT_ERROR_NONE, ret);
+
+ ret = wifi_direct_deinitialize();
+ ASSERT_EQ(WIFI_DIRECT_ERROR_NONE, ret);
+}
+
+TEST_F(WifiDirectInitTest, wifi_direct_set_state_changed_cb_Negative)
+{
+ int ret;
+
+ ret = wifi_direct_initialize();
+ ASSERT_EQ(WIFI_DIRECT_ERROR_NONE, ret);
+
+ ret = wifi_direct_set_state_changed_cb(NULL, NULL);
+ ASSERT_EQ(WIFI_DIRECT_ERROR_INVALID_PARAMETER, ret);
+
+ ret = wifi_direct_deinitialize();
+ ASSERT_EQ(WIFI_DIRECT_ERROR_NONE, ret);
+}
+
+static void __check_activated_cb(int error_code,
+ wifi_direct_device_state_e device_state,
+ void *user_data)
+{
+ gboolean *activated = (gboolean *)user_data;
+ if (device_state == WIFI_DIRECT_DEVICE_STATE_ACTIVATED)
+ *activated = TRUE;
+ else
+ *activated = FALSE;
+
+ return;
+}
+
+TEST_F(WifiDirectInitTest, wifi_direct_activate_Positive)
+{
+ gboolean activated = FALSE;
+ int ret;
+
+ ret = wifi_direct_initialize();
+ ASSERT_EQ(WIFI_DIRECT_ERROR_NONE, ret);
+
+ ret = wifi_direct_set_device_state_changed_cb(__check_activated_cb, (gpointer)&activated);
+ ASSERT_EQ(WIFI_DIRECT_ERROR_NONE, ret);
+
+ ret = wifi_direct_activate();
+ ASSERT_EQ(WIFI_DIRECT_ERROR_NONE, ret);
+
+ wifi_direct_manager_mock_generate_activation_signal();
+
+ ASSERT_EQ(TRUE, activated);
+
+ ret = wifi_direct_deactivate();
+ ASSERT_EQ(WIFI_DIRECT_ERROR_NONE, ret);
+
+ wifi_direct_manager_mock_generate_deactivation_signal();
+
+ ASSERT_EQ(FALSE, activated);
+
+ ret = wifi_direct_unset_device_state_changed_cb();
+ ASSERT_EQ(WIFI_DIRECT_ERROR_NONE, ret);
+
+ ret = wifi_direct_deinitialize();
+ ASSERT_EQ(WIFI_DIRECT_ERROR_NONE, ret);
+}
+
+TEST_F(WifiDirectInitTest, wifi_direct_activate_Negative)
+{
+ int ret;
+
+ ret = wifi_direct_initialize();
+ ASSERT_EQ(WIFI_DIRECT_ERROR_NONE, ret);
+
+ mock_gdbus_gdbus_call_sync_enable(false);
+
+ ret = wifi_direct_activate();
+ ASSERT_EQ(WIFI_DIRECT_ERROR_OPERATION_FAILED, ret);
+
+ mock_gdbus_gdbus_call_sync_enable(true);
+
+ ret = wifi_direct_deinitialize();
+ ASSERT_EQ(WIFI_DIRECT_ERROR_NONE, ret);
+}
+
+TEST_F(WifiDirectInitTest, wifi_direct_deactivate_Negative)
+{
+ int ret;
+
+ ret = wifi_direct_initialize();
+ ASSERT_EQ(WIFI_DIRECT_ERROR_NONE, ret);
+
+ mock_gdbus_gdbus_call_sync_enable(false);
+
+ ret = wifi_direct_deactivate();
+ ASSERT_EQ(WIFI_DIRECT_ERROR_OPERATION_FAILED, ret);
+
+ mock_gdbus_gdbus_call_sync_enable(true);
+
+ ret = wifi_direct_deinitialize();
+ ASSERT_EQ(WIFI_DIRECT_ERROR_NONE, ret);
+}
+
+class WifiDirectDiscoveryTest : public ::testing::Test {
+protected:
+ void SetUp() override
+ {
+ //Setting up normal condition
+ mock_gdbus_gdbus_sync_enable(true);
+ mock_gdbus_gdbus_call_sync_enable(true);
+ wifi_direct_manager_mock_init();
+
+ int ret;
+ ret = wifi_direct_initialize();
+ ASSERT_EQ(WIFI_DIRECT_ERROR_NONE, ret);
+
+ ret = wifi_direct_activate();
+ ASSERT_EQ(WIFI_DIRECT_ERROR_NONE, ret);
+
+ wifi_direct_manager_mock_generate_activation_signal();
+ }
+
+ void TearDown() override
+ {
+ int ret;
+ ret = wifi_direct_deactivate();
+ ASSERT_EQ(WIFI_DIRECT_ERROR_NONE, ret);
+
+ wifi_direct_manager_mock_generate_deactivation_signal();
+
+ ret = wifi_direct_deinitialize();
+ ASSERT_EQ(WIFI_DIRECT_ERROR_NONE, ret);
+
+ wifi_direct_manager_mock_deinit();
+ }
+};
+
+TEST_F(WifiDirectDiscoveryTest, wifi_direct_start_discovery_listen_Positive)
+{
+ int ret;
+
+ ret = wifi_direct_set_discovery_state_changed_cb(__discovery_state_chagned_cb, NULL);
+ ASSERT_EQ(WIFI_DIRECT_ERROR_NONE, ret);
+
+ ret = wifi_direct_set_peer_found_cb(__peer_found_cb, NULL);
+ ASSERT_EQ(WIFI_DIRECT_ERROR_NONE, ret);
+
+ ret = wifi_direct_start_discovery(true, 0);
+ ASSERT_EQ(WIFI_DIRECT_ERROR_NONE, ret);
+
+ wifi_direct_manager_mock_generate_listen_started_signal();
+ wifi_direct_manager_mock_generate_discovery_finished_signal();
+
+ ret = wifi_direct_unset_discovery_state_changed_cb();
+ ASSERT_EQ(WIFI_DIRECT_ERROR_NONE, ret);
+
+ ret = wifi_direct_unset_peer_found_cb();
+ ASSERT_EQ(WIFI_DIRECT_ERROR_NONE, ret);
+}
+
+TEST_F(WifiDirectDiscoveryTest, wifi_direct_start_discovery_listen_Negative)
+{
+ int ret;
+ ret = wifi_direct_start_discovery(false, -1);
+ ASSERT_EQ(WIFI_DIRECT_ERROR_INVALID_PARAMETER, ret);
+}
+
+TEST_F(WifiDirectDiscoveryTest, wifi_direct_start_discovery_find_Positive)
+{
+ int ret;
+
+ ret = wifi_direct_set_discovery_state_changed_cb(__discovery_state_chagned_cb, NULL);
+ ASSERT_EQ(WIFI_DIRECT_ERROR_NONE, ret);
+
+ ret = wifi_direct_set_peer_found_cb(__peer_found_cb, NULL);
+ ASSERT_EQ(WIFI_DIRECT_ERROR_NONE, ret);
+
+ ret = wifi_direct_start_discovery(false, 0);
+ ASSERT_EQ(WIFI_DIRECT_ERROR_NONE, ret);
+
+ wifi_direct_manager_mock_generate_discovery_started_signal();
+ wifi_direct_manager_mock_generate_peer_found_signal();
+ wifi_direct_manager_mock_generate_peer_lost_signal();
+ wifi_direct_manager_mock_generate_discovery_finished_signal();
+
+ ret = wifi_direct_unset_discovery_state_changed_cb();
+ ASSERT_EQ(WIFI_DIRECT_ERROR_NONE, ret);
+
+ ret = wifi_direct_unset_peer_found_cb();
+ ASSERT_EQ(WIFI_DIRECT_ERROR_NONE, ret);
+}
+
+TEST_F(WifiDirectDiscoveryTest, wifi_direct_start_discovery_find_Negative)
+{
+ int ret;
+ ret = wifi_direct_start_discovery(false, -1);
+ ASSERT_EQ(WIFI_DIRECT_ERROR_INVALID_PARAMETER, ret);
+}
+
+TEST_F(WifiDirectDiscoveryTest, wifi_direct_start_discovery_specific_channel_Positive)
+{
+ int ret;
+ ret = wifi_direct_start_discovery_specific_channel(false, 0, WIFI_DIRECT_DISCOVERY_FULL_SCAN);
+
+ wifi_direct_manager_mock_generate_discovery_started_signal();
+ wifi_direct_manager_mock_generate_peer_found_signal();
+ wifi_direct_manager_mock_generate_peer_lost_signal();
+ wifi_direct_manager_mock_generate_discovery_finished_signal();
+
+ ASSERT_EQ(WIFI_DIRECT_ERROR_NONE, ret);
+}
+
+TEST_F(WifiDirectDiscoveryTest, wifi_direct_start_discovery_specific_channel_Negative)
+{
+ int ret;
+ ret = wifi_direct_start_discovery_specific_channel(false, -1, WIFI_DIRECT_DISCOVERY_FULL_SCAN);
+ ASSERT_EQ(WIFI_DIRECT_ERROR_INVALID_PARAMETER, ret);
+}
+
+TEST_F(WifiDirectDiscoveryTest, wifi_direct_start_discovery_specific_freq_Positive)
+{
+ int ret;
+ ret = wifi_direct_start_discovery_specific_freq(true, 0, 2412);
+ ASSERT_EQ(WIFI_DIRECT_ERROR_NONE, ret);
+
+ wifi_direct_manager_mock_generate_listen_started_signal();
+ wifi_direct_manager_mock_generate_discovery_finished_signal();
+}
+
+TEST_F(WifiDirectDiscoveryTest, wifi_direct_start_discovery_specific_freq_Negative)
+{
+ int ret;
+ ret = wifi_direct_start_discovery_specific_freq(false, -1, 2412);
+ ASSERT_EQ(WIFI_DIRECT_ERROR_INVALID_PARAMETER, ret);
+}
+
+TEST_F(WifiDirectDiscoveryTest, wifi_direct_cancel_discovery_Positive)
+{
+ int ret;
+
+ ret = wifi_direct_start_discovery(false, 0);
+ ASSERT_EQ(WIFI_DIRECT_ERROR_NONE, ret);
+
+ ret = wifi_direct_cancel_discovery();
+ ASSERT_EQ(WIFI_DIRECT_ERROR_NONE, ret);
+}
+
+TEST_F(WifiDirectDiscoveryTest, wifi_direct_cancel_discovery_Negative)
+{
+ int ret;
+
+ ret = wifi_direct_deactivate();
+ ASSERT_EQ(WIFI_DIRECT_ERROR_NONE, ret);
+
+ wifi_direct_manager_mock_generate_deactivation_signal();
+
+ ret = wifi_direct_cancel_discovery();
+ ASSERT_EQ(WIFI_DIRECT_ERROR_NOT_PERMITTED, ret);
+
+ ret = wifi_direct_activate();
+ ASSERT_EQ(WIFI_DIRECT_ERROR_NONE, ret);
+
+ wifi_direct_manager_mock_generate_activation_signal();
+}
+
+bool wifi_direct_foreach_discovered_peers_Positive_cb(wifi_direct_discovered_peer_info_s* peer, void* user_data)
+{
+ free(peer->device_name);
+ free(peer->mac_address);
+ free(peer->interface_address);
+ free(peer);
+ return true;
+}
+
+TEST_F(WifiDirectDiscoveryTest, wifi_direct_foreach_discovered_peers_Positive)
+{
+ int ret;
+ ret = wifi_direct_foreach_discovered_peers(wifi_direct_foreach_discovered_peers_Positive_cb, NULL);
+ ASSERT_EQ(WIFI_DIRECT_ERROR_NONE, ret);
+}
+
+TEST_F(WifiDirectDiscoveryTest, wifi_direct_foreach_discovered_peers_Negative)
+{
+ int ret;
+ ret = wifi_direct_foreach_discovered_peers(NULL, NULL);
+ ASSERT_EQ(WIFI_DIRECT_ERROR_INVALID_PARAMETER, ret);
+}
+
+TEST_F(WifiDirectDiscoveryTest, wifi_direct_start_service_discovery_Positive)
+{
+ int ret;
+ ret = wifi_direct_start_service_discovery(NULL, WIFI_DIRECT_SERVICE_TYPE_ALL);
+ ASSERT_EQ(WIFI_DIRECT_ERROR_NONE, ret);
+}
+
+TEST_F(WifiDirectDiscoveryTest, wifi_direct_start_service_discovery_Negative)
+{
+ int ret;
+
+ ret = wifi_direct_deactivate();
+ ASSERT_EQ(WIFI_DIRECT_ERROR_NONE, ret);
+
+ wifi_direct_manager_mock_generate_deactivation_signal();
+
+ ret = wifi_direct_start_service_discovery(NULL, WIFI_DIRECT_SERVICE_TYPE_ALL);
+ ASSERT_EQ(WIFI_DIRECT_ERROR_NOT_PERMITTED, ret);
+
+ ret = wifi_direct_activate();
+ ASSERT_EQ(WIFI_DIRECT_ERROR_NONE, ret);
+
+ wifi_direct_manager_mock_generate_activation_signal();
+}
+
+TEST_F(WifiDirectDiscoveryTest, wifi_direct_cancel_service_discovery_Positive)
+{
+ int ret;
+
+ ret = wifi_direct_start_service_discovery(NULL, WIFI_DIRECT_SERVICE_TYPE_ALL);
+ ASSERT_EQ(WIFI_DIRECT_ERROR_NONE, ret);
+
+ ret = wifi_direct_cancel_service_discovery(NULL, WIFI_DIRECT_SERVICE_TYPE_ALL);
+ ASSERT_EQ(WIFI_DIRECT_ERROR_NONE, ret);
+}
+
+TEST_F(WifiDirectDiscoveryTest, wifi_direct_cancel_service_discovery_Negative)
+{
+ int ret;
+
+ ret = wifi_direct_deactivate();
+ ASSERT_EQ(WIFI_DIRECT_ERROR_NONE, ret);
+
+ wifi_direct_manager_mock_generate_deactivation_signal();
+
+ ret = wifi_direct_cancel_service_discovery(NULL, WIFI_DIRECT_SERVICE_TYPE_ALL);
+ ASSERT_EQ(WIFI_DIRECT_ERROR_NOT_PERMITTED, ret);
+
+ ret = wifi_direct_activate();
+ ASSERT_EQ(WIFI_DIRECT_ERROR_NONE, ret);
+
+ wifi_direct_manager_mock_generate_activation_signal();
+}
+
+TEST_F(WifiDirectDiscoveryTest, wifi_direct_register_service_Positive)
+{
+ unsigned int service_id;
+ char service_info[] = "service_string";
+ int ret;
+
+ ret = wifi_direct_register_service(WIFI_DIRECT_SERVICE_TYPE_ALL, service_info, service_info, &service_id);
+ ASSERT_EQ(WIFI_DIRECT_ERROR_NONE, ret);
+}
+
+TEST_F(WifiDirectDiscoveryTest, wifi_direct_register_service_Negative1)
+{
+ unsigned int service_id;
+ int ret;
+
+ ret = wifi_direct_register_service(WIFI_DIRECT_SERVICE_TYPE_ALL, NULL, NULL, &service_id);
+ ASSERT_EQ(WIFI_DIRECT_ERROR_INVALID_PARAMETER, ret);
+}
+
+TEST_F(WifiDirectDiscoveryTest, wifi_direct_register_service_Negative2)
+{
+ unsigned int service_id;
+ char service_info[] = "service_string";
+ int ret;
+
+ ret = wifi_direct_deactivate();
+ ASSERT_EQ(WIFI_DIRECT_ERROR_NONE, ret);
+
+ wifi_direct_manager_mock_generate_deactivation_signal();
+
+ ret = wifi_direct_register_service(WIFI_DIRECT_SERVICE_TYPE_ALL, service_info, service_info, &service_id);
+ ASSERT_EQ(WIFI_DIRECT_ERROR_NOT_PERMITTED, ret);
+
+ ret = wifi_direct_activate();
+ ASSERT_EQ(WIFI_DIRECT_ERROR_NONE, ret);
+
+ wifi_direct_manager_mock_generate_activation_signal();
+}
+
+TEST_F(WifiDirectDiscoveryTest, wifi_direct_deregister_service_Positive)
+{
+ unsigned int service_id = 7;
+ int ret;
+
+ ret = wifi_direct_deregister_service(service_id);
+ ASSERT_EQ(WIFI_DIRECT_ERROR_NONE, ret);
+}
+
+TEST_F(WifiDirectDiscoveryTest, wifi_direct_deregister_service_Negative)
+{
+ unsigned int service_id = 7;
+ int ret;
+
+ ret = wifi_direct_deactivate();
+ ASSERT_EQ(WIFI_DIRECT_ERROR_NONE, ret);
+
+ wifi_direct_manager_mock_generate_deactivation_signal();
+
+ ret = wifi_direct_deregister_service(service_id);
+ ASSERT_EQ(WIFI_DIRECT_ERROR_NOT_PERMITTED, ret);
+
+ ret = wifi_direct_activate();
+ ASSERT_EQ(WIFI_DIRECT_ERROR_NONE, ret);
+
+ wifi_direct_manager_mock_generate_activation_signal();
+}
+
+TEST_F(WifiDirectDiscoveryTest, wifi_direct_get_peer_info_Positive)
+{
+ char test_mac[] = "aa:bb:cc:dd:ee:ff";
+ int ret;
+
+ wifi_direct_discovered_peer_info_s *peer_info = NULL;
+ ret = wifi_direct_get_peer_info(test_mac, &peer_info);
+ free(peer_info->device_name);
+ free(peer_info->mac_address);
+ free(peer_info->interface_address);
+ free(peer_info);
+ ASSERT_EQ(WIFI_DIRECT_ERROR_NONE, ret);
+}
+
+TEST_F(WifiDirectDiscoveryTest, wifi_direct_get_peer_info_Negative)
+{
+ int ret;
+
+ ret = wifi_direct_get_peer_info(NULL, NULL);
+ ASSERT_EQ(WIFI_DIRECT_ERROR_INVALID_PARAMETER, ret);
+}
+
+class WifiDirectGroupTest : public ::testing::Test {
+protected:
+ void SetUp() override
+ {
+ //Setting up normal condition
+ mock_gdbus_gdbus_sync_enable(true);
+ mock_gdbus_gdbus_call_sync_enable(true);
+ wifi_direct_manager_mock_init();
+
+ int ret;
+ ret = wifi_direct_initialize();
+ ASSERT_EQ(WIFI_DIRECT_ERROR_NONE, ret);
+
+ ret = wifi_direct_activate();
+ ASSERT_EQ(WIFI_DIRECT_ERROR_NONE, ret);
+
+ wifi_direct_manager_mock_generate_activation_signal();
+ }
+
+ void TearDown() override
+ {
+ int ret;
+ ret = wifi_direct_deactivate();
+ ASSERT_EQ(WIFI_DIRECT_ERROR_NONE, ret);
+
+ wifi_direct_manager_mock_generate_deactivation_signal();
+
+ ret = wifi_direct_deinitialize();
+ ASSERT_EQ(WIFI_DIRECT_ERROR_NONE, ret);
+
+ wifi_direct_manager_mock_deinit();
+ }
+};
+
+TEST_F(WifiDirectGroupTest, wifi_direct_create_group_Positive)
+{
+ int ret;
+ ret = wifi_direct_create_group();
+ ASSERT_EQ(WIFI_DIRECT_ERROR_NONE, ret);
+
+ wifi_direct_manager_mock_generate_created_signal();
+
+ ret = wifi_direct_destroy_group();
+ ASSERT_EQ(WIFI_DIRECT_ERROR_NONE, ret);
+
+ wifi_direct_manager_mock_generate_destroyed_signal();
+}
+
+TEST_F(WifiDirectGroupTest, wifi_direct_create_group_Negative)
+{
+ int ret;
+
+ ret = wifi_direct_deactivate();
+ ASSERT_EQ(WIFI_DIRECT_ERROR_NONE, ret);
+
+ wifi_direct_manager_mock_generate_deactivation_signal();
+
+ ret = wifi_direct_create_group();
+ ASSERT_EQ(WIFI_DIRECT_ERROR_NOT_PERMITTED, ret);
+
+ ret = wifi_direct_activate();
+ ASSERT_EQ(WIFI_DIRECT_ERROR_NONE, ret);
+
+ wifi_direct_manager_mock_generate_activation_signal();
+}
+
+TEST_F(WifiDirectGroupTest, wifi_direct_create_group_with_ssid_Positive)
+{
+ int ret;
+ ret = wifi_direct_create_group_with_ssid("TEST");
+ ASSERT_EQ(WIFI_DIRECT_ERROR_NONE, ret);
+}
+
+TEST_F(WifiDirectGroupTest, wifi_direct_create_group_with_ssid_Negative1)
+{
+ int ret;
+
+ ret = wifi_direct_create_group_with_ssid(NULL);
+ ASSERT_EQ(WIFI_DIRECT_ERROR_INVALID_PARAMETER, ret);
+}
+
+TEST_F(WifiDirectGroupTest, wifi_direct_create_group_with_ssid_Negative2)
+{
+ int ret;
+
+ ret = wifi_direct_deactivate();
+ ASSERT_EQ(WIFI_DIRECT_ERROR_NONE, ret);
+
+ wifi_direct_manager_mock_generate_deactivation_signal();
+
+ ret = wifi_direct_create_group_with_ssid("TEST");
+ ASSERT_EQ(WIFI_DIRECT_ERROR_NOT_PERMITTED, ret);
+
+ ret = wifi_direct_activate();
+ ASSERT_EQ(WIFI_DIRECT_ERROR_NONE, ret);
+
+ wifi_direct_manager_mock_generate_activation_signal();
+}
+
+TEST_F(WifiDirectGroupTest, wifi_direct_destroy_group_Positive)
+{
+ int ret;
+ ret = wifi_direct_set_connection_state_changed_cb(__connection_state_changed_cb, NULL);
+ ASSERT_EQ(WIFI_DIRECT_ERROR_NONE, ret);
+
+ ret = wifi_direct_create_group();
+ ASSERT_EQ(WIFI_DIRECT_ERROR_NONE, ret);
+
+ wifi_direct_manager_mock_generate_created_signal();
+
+ ret = wifi_direct_destroy_group();
+ ASSERT_EQ(WIFI_DIRECT_ERROR_NONE, ret);
+
+ wifi_direct_manager_mock_generate_destroyed_signal();
+
+ ret = wifi_direct_unset_connection_state_changed_cb();
+ ASSERT_EQ(WIFI_DIRECT_ERROR_NONE, ret);
+}
+
+TEST_F(WifiDirectGroupTest, wifi_direct_destroy_group_Negative)
+{
+ int ret;
+
+ ret = wifi_direct_deactivate();
+ ASSERT_EQ(WIFI_DIRECT_ERROR_NONE, ret);
+
+ wifi_direct_manager_mock_generate_deactivation_signal();
+
+ ret = wifi_direct_destroy_group();
+ ASSERT_EQ(WIFI_DIRECT_ERROR_NOT_PERMITTED, ret);
+
+ ret = wifi_direct_activate();
+ ASSERT_EQ(WIFI_DIRECT_ERROR_NONE, ret);
+
+ wifi_direct_manager_mock_generate_activation_signal();
+}
+
+TEST_F(WifiDirectGroupTest, wifi_direct_is_group_owner_Positive)
+{
+ bool owner;
+ int ret;
+
+ ret = wifi_direct_is_group_owner(&owner);
+ ASSERT_EQ(WIFI_DIRECT_ERROR_NONE, ret);
+}
+
+TEST_F(WifiDirectGroupTest, wifi_direct_is_group_owner_Negative)
+{
+ int ret;
+
+ ret = wifi_direct_is_group_owner(NULL);
+ ASSERT_EQ(WIFI_DIRECT_ERROR_INVALID_PARAMETER, ret);
+}
+
+TEST_F(WifiDirectGroupTest, wifi_direct_is_autonomous_group_Positive)
+{
+ bool is_autonomous;
+ int ret;
+
+ ret = wifi_direct_is_autonomous_group(&is_autonomous);
+ ASSERT_EQ(WIFI_DIRECT_ERROR_NONE, ret);
+}
+
+TEST_F(WifiDirectGroupTest, wifi_direct_is_autonomous_group_Negative)
+{
+ int ret;
+
+ ret = wifi_direct_is_autonomous_group(NULL);
+ ASSERT_EQ(WIFI_DIRECT_ERROR_INVALID_PARAMETER, ret);
+}
+
+class WifiDirectSettingTest : public ::testing::Test {
+protected:
+ void SetUp() override
+ {
+ //Setting up normal condition
+ mock_gdbus_gdbus_sync_enable(true);
+ mock_gdbus_gdbus_call_sync_enable(true);
+ wifi_direct_manager_mock_init();
+
+ int ret;
+ ret = wifi_direct_initialize();
+ ASSERT_EQ(WIFI_DIRECT_ERROR_NONE, ret);
+
+ ret = wifi_direct_activate();
+ ASSERT_EQ(WIFI_DIRECT_ERROR_NONE, ret);
+
+ wifi_direct_manager_mock_generate_activation_signal();
+ }
+
+ void TearDown() override
+ {
+ int ret;
+ ret = wifi_direct_deactivate();
+ ASSERT_EQ(WIFI_DIRECT_ERROR_NONE, ret);
+
+ wifi_direct_manager_mock_generate_deactivation_signal();
+
+ ret = wifi_direct_deinitialize();
+ ASSERT_EQ(WIFI_DIRECT_ERROR_NONE, ret);
+
+ wifi_direct_manager_mock_deinit();
+ }
+};
+
+TEST_F(WifiDirectSettingTest, wifi_direct_set_group_owner_intent_Positive)
+{
+ int ret;
+
+ ret = wifi_direct_set_group_owner_intent(7);
+ ASSERT_EQ(WIFI_DIRECT_ERROR_NONE, ret);
+}
+
+TEST_F(WifiDirectSettingTest, wifi_direct_set_group_owner_intent_Negative)
+{
+ int ret;
+
+ ret = wifi_direct_set_group_owner_intent(-1);
+ ASSERT_EQ(WIFI_DIRECT_ERROR_INVALID_PARAMETER, ret);
+}
+
+TEST_F(WifiDirectSettingTest, wifi_direct_get_group_owner_intent_Positive)
+{
+ int go_intent;
+ int ret;
+
+ ret = wifi_direct_get_group_owner_intent(&go_intent);
+ ASSERT_EQ(WIFI_DIRECT_ERROR_NONE, ret);
+}
+
+TEST_F(WifiDirectSettingTest, wifi_direct_get_group_owner_intent_Negative)
+{
+ int ret;
+
+ ret = wifi_direct_get_group_owner_intent(NULL);
+ ASSERT_EQ(WIFI_DIRECT_ERROR_INVALID_PARAMETER, ret);
+}
+
+TEST_F(WifiDirectSettingTest, wifi_direct_set_go_intent_per_type_Positive)
+{
+ int ret;
+
+ ret = wifi_direct_set_go_intent_per_type(4, 7);
+ ASSERT_EQ(WIFI_DIRECT_ERROR_NONE, ret);
+}
+
+TEST_F(WifiDirectSettingTest, wifi_direct_set_go_intent_per_type_Negative)
+{
+ int ret;
+
+ ret = wifi_direct_set_go_intent_per_type(-1, 7);
+ ASSERT_EQ(WIFI_DIRECT_ERROR_INVALID_PARAMETER, ret);
+
+ ret = wifi_direct_set_go_intent_per_type(4, -1);
+ ASSERT_EQ(WIFI_DIRECT_ERROR_INVALID_PARAMETER, ret);
+}
+
+TEST_F(WifiDirectSettingTest, wifi_direct_get_go_intent_per_type_Positive)
+{
+ int go_intent;
+ int ret;
+
+ ret = wifi_direct_get_go_intent_per_type(4, &go_intent);
+ ASSERT_EQ(WIFI_DIRECT_ERROR_NONE, ret);
+}
+
+TEST_F(WifiDirectSettingTest, wifi_direct_get_go_intent_per_type_Negative)
+{
+ int go_intent;
+ int ret;
+
+ ret = wifi_direct_get_go_intent_per_type(-1, &go_intent);
+ ASSERT_EQ(WIFI_DIRECT_ERROR_INVALID_PARAMETER, ret);
+
+ ret = wifi_direct_get_go_intent_per_type(4, NULL);
+ ASSERT_EQ(WIFI_DIRECT_ERROR_INVALID_PARAMETER, ret);
+}
+
+TEST_F(WifiDirectSettingTest, wifi_direct_set_max_clients_Positive)
+{
+ int ret;
+
+ ret = wifi_direct_set_max_clients(10);
+ ASSERT_EQ(WIFI_DIRECT_ERROR_NONE, ret);
+}
+
+TEST_F(WifiDirectSettingTest, wifi_direct_set_max_clients_Negative)
+{
+ int ret;
+
+ ret = wifi_direct_set_max_clients(-1);
+ ASSERT_EQ(WIFI_DIRECT_ERROR_OPERATION_FAILED, ret);
+}
+
+TEST_F(WifiDirectSettingTest, wifi_direct_get_max_clients_Positive)
+{
+ int client_num;
+ int ret;
+
+ ret = wifi_direct_get_max_clients(&client_num);
+ ASSERT_EQ(WIFI_DIRECT_ERROR_NONE, ret);
+}
+
+TEST_F(WifiDirectSettingTest, wifi_direct_get_max_clients_Negative)
+{
+ int ret;
+
+ ret = wifi_direct_get_max_clients(NULL);
+ ASSERT_EQ(WIFI_DIRECT_ERROR_INVALID_PARAMETER, ret);
+}
+
+TEST_F(WifiDirectSettingTest, wifi_direct_get_operating_channel_Positive)
+{
+ int channel;
+ int ret;
+
+ ret = wifi_direct_create_group();
+ ASSERT_EQ(WIFI_DIRECT_ERROR_NONE, ret);
+
+ ret = wifi_direct_get_operating_channel(&channel);
+ ASSERT_EQ(WIFI_DIRECT_ERROR_NONE, ret);
+
+ ret = wifi_direct_destroy_group();
+ ASSERT_EQ(WIFI_DIRECT_ERROR_NONE, ret);
+}
+
+TEST_F(WifiDirectSettingTest, wifi_direct_get_operating_channel_Negative1)
+{
+ int ret;
+
+ ret = wifi_direct_get_operating_channel(NULL);
+ ASSERT_EQ(WIFI_DIRECT_ERROR_INVALID_PARAMETER, ret);
+}
+
+TEST_F(WifiDirectSettingTest, wifi_direct_get_operating_channel_Negative2)
+{
+ int channel;
+ int ret;
+
+ ret = wifi_direct_get_operating_channel(&channel);
+ ASSERT_EQ(WIFI_DIRECT_ERROR_NOT_PERMITTED, ret);
+}
+
+TEST_F(WifiDirectSettingTest, wifi_direct_activate_pushbutton_Positive)
+{
+ int ret;
+
+ ret = wifi_direct_create_group();
+ ASSERT_EQ(WIFI_DIRECT_ERROR_NONE, ret);
+
+ ret = wifi_direct_activate_pushbutton();
+ ASSERT_EQ(WIFI_DIRECT_ERROR_NONE, ret);
+
+ ret = wifi_direct_destroy_group();
+ ASSERT_EQ(WIFI_DIRECT_ERROR_NONE, ret);
+}
+
+TEST_F(WifiDirectSettingTest, wifi_direct_activate_pushbutton_Negative)
+{
+ int ret;
+
+ ret = wifi_direct_activate_pushbutton();
+ ASSERT_EQ(WIFI_DIRECT_ERROR_NOT_PERMITTED, ret);
+}
+
+TEST_F(WifiDirectSettingTest, wifi_direct_get_supported_wps_mode_Positive)
+{
+ int supported_wps_mode;
+ int ret;
+
+ ret = wifi_direct_get_supported_wps_mode(&supported_wps_mode);
+ ASSERT_EQ(WIFI_DIRECT_ERROR_NONE, ret);
+}
+
+TEST_F(WifiDirectSettingTest, wifi_direct_get_supported_wps_mode_Negative)
+{
+ int ret;
+
+ ret = wifi_direct_get_supported_wps_mode(NULL);
+ ASSERT_EQ(WIFI_DIRECT_ERROR_INVALID_PARAMETER, ret);
+}
+
+bool wifi_direct_foreach_supported_wps_types_Positive_cb(wifi_direct_wps_type_e type, void *user_data)
+{
+ return true;
+}
+
+TEST_F(WifiDirectSettingTest, wifi_direct_foreach_supported_wps_types_Positive)
+{
+ int ret;
+
+ ret = wifi_direct_foreach_supported_wps_types(wifi_direct_foreach_supported_wps_types_Positive_cb, NULL);
+ ASSERT_EQ(WIFI_DIRECT_ERROR_NONE, ret);
+}
+
+TEST_F(WifiDirectSettingTest, wifi_direct_foreach_supported_wps_types_Negative)
+{
+ int ret;
+
+ ret = wifi_direct_foreach_supported_wps_types(NULL, NULL);
+ ASSERT_EQ(WIFI_DIRECT_ERROR_INVALID_PARAMETER, ret);
+}
+
+TEST_F(WifiDirectSettingTest, wifi_direct_get_local_wps_type_Positive)
+{
+ wifi_direct_wps_type_e type;
+ int ret;
+
+ ret = wifi_direct_get_local_wps_type(&type);
+ ASSERT_EQ(WIFI_DIRECT_ERROR_NONE, ret);
+}
+
+TEST_F(WifiDirectSettingTest, wifi_direct_get_local_wps_type_Negative)
+{
+ int ret;
+
+ ret = wifi_direct_get_local_wps_type(NULL);
+ ASSERT_EQ(WIFI_DIRECT_ERROR_INVALID_PARAMETER, ret);
+}
+
+TEST_F(WifiDirectSettingTest, wifi_direct_set_req_wps_type_Positive)
+{
+ int ret;
+
+ ret = wifi_direct_set_req_wps_type(WIFI_DIRECT_WPS_TYPE_PBC);
+ ASSERT_EQ(WIFI_DIRECT_ERROR_NONE, ret);
+}
+
+TEST_F(WifiDirectSettingTest, wifi_direct_set_req_wps_type_Negative)
+{
+ int ret;
+
+ ret = wifi_direct_set_req_wps_type((wifi_direct_wps_type_e)0);
+ ASSERT_EQ(WIFI_DIRECT_ERROR_INVALID_PARAMETER, ret);
+}
+
+TEST_F(WifiDirectSettingTest, wifi_direct_get_req_wps_type_Positive)
+{
+ wifi_direct_wps_type_e type;
+ int ret;
+
+ ret = wifi_direct_get_req_wps_type(&type);
+ ASSERT_EQ(WIFI_DIRECT_ERROR_NONE, ret);
+}
+
+TEST_F(WifiDirectSettingTest, wifi_direct_get_req_wps_type_Negative)
+{
+ int ret;
+
+ ret = wifi_direct_get_req_wps_type(NULL);
+ ASSERT_EQ(WIFI_DIRECT_ERROR_INVALID_PARAMETER, ret);
+}
+
+TEST_F(WifiDirectSettingTest, wifi_direct_get_ssid_Positive)
+{
+ char *ssid;
+ int ret;
+
+ ret = wifi_direct_get_ssid(&ssid);
+ free(ssid);
+ ASSERT_EQ(WIFI_DIRECT_ERROR_NONE, ret);
+}
+
+TEST_F(WifiDirectSettingTest, wifi_direct_get_ssid_Negative)
+{
+ int ret;
+
+ ret = wifi_direct_get_ssid(NULL);
+ ASSERT_EQ(WIFI_DIRECT_ERROR_INVALID_PARAMETER, ret);
+}
+
+TEST_F(WifiDirectSettingTest, wifi_direct_get_device_name_Positive)
+{
+ char *device_name;
+ int ret;
+
+ ret = wifi_direct_get_device_name(&device_name);
+ free(device_name);
+ ASSERT_EQ(WIFI_DIRECT_ERROR_NONE, ret);
+}
+
+TEST_F(WifiDirectSettingTest, wifi_direct_get_device_name_Negative)
+{
+ int ret;
+
+ ret = wifi_direct_get_device_name(NULL);
+ ASSERT_EQ(WIFI_DIRECT_ERROR_INVALID_PARAMETER, ret);
+}
+
+TEST_F(WifiDirectSettingTest, wifi_direct_set_device_name_Positive)
+{
+ int ret;
+
+ ret = wifi_direct_set_device_name("TEST_DEVICE");
+ ASSERT_EQ(WIFI_DIRECT_ERROR_NONE, ret);
+}
+
+TEST_F(WifiDirectSettingTest, wifi_direct_set_device_name_Negative)
+{
+ int ret;
+
+ ret = wifi_direct_set_device_name(NULL);
+ ASSERT_EQ(WIFI_DIRECT_ERROR_INVALID_PARAMETER, ret);
+}
+
+TEST_F(WifiDirectSettingTest, wifi_direct_get_state_Positive)
+{
+ wifi_direct_state_e state;
+ int ret;
+
+ ret = wifi_direct_get_state(&state);
+ ASSERT_EQ(WIFI_DIRECT_ERROR_NONE, ret);
+}
+
+TEST_F(WifiDirectSettingTest, wifi_direct_get_state_Negative)
+{
+ int ret;
+
+ ret = wifi_direct_get_state(NULL);
+ ASSERT_EQ(WIFI_DIRECT_ERROR_INVALID_PARAMETER, ret);
+}
+
+TEST_F(WifiDirectSettingTest, wifi_direct_get_mac_address_Positive)
+{
+ char *mac_address = NULL;
+ int ret;
+
+ ret = wifi_direct_get_mac_address(&mac_address);
+ free(mac_address);
+ ASSERT_EQ(WIFI_DIRECT_ERROR_NONE, ret);
+}
+
+TEST_F(WifiDirectSettingTest, wifi_direct_get_mac_address_Negative)
+{
+ int ret;
+
+ ret = wifi_direct_get_mac_address(NULL);
+ ASSERT_EQ(WIFI_DIRECT_ERROR_INVALID_PARAMETER, ret);
+}
+
+TEST_F(WifiDirectGroupTest, wifi_direct_get_network_interface_name_Positive)
+{
+ char *iface_name;
+ int ret;
+
+ ret = wifi_direct_create_group();
+ ASSERT_EQ(WIFI_DIRECT_ERROR_NONE, ret);
+
+ ret = wifi_direct_get_network_interface_name(&iface_name);
+ free(iface_name);
+ ASSERT_EQ(WIFI_DIRECT_ERROR_NONE, ret);
+
+ ret = wifi_direct_destroy_group();
+ ASSERT_EQ(WIFI_DIRECT_ERROR_NONE, ret);
+}
+
+TEST_F(WifiDirectGroupTest, wifi_direct_get_network_interface_name_Negative1)
+{
+ int ret;
+
+ ret = wifi_direct_get_network_interface_name(NULL);
+ ASSERT_EQ(WIFI_DIRECT_ERROR_INVALID_PARAMETER, ret);
+}
+
+TEST_F(WifiDirectGroupTest, wifi_direct_get_network_interface_name_Negative2)
+{
+ char *iface_name;
+ int ret;
+
+ ret = wifi_direct_get_network_interface_name(&iface_name);
+ ASSERT_EQ(WIFI_DIRECT_ERROR_NOT_PERMITTED, ret);
+}
+
+TEST_F(WifiDirectGroupTest, wifi_direct_get_ip_address_Positive)
+{
+ char *ip_address;
+ int ret;
+
+ ret = wifi_direct_create_group();
+ ASSERT_EQ(WIFI_DIRECT_ERROR_NONE, ret);
+
+ ret = wifi_direct_get_ip_address(&ip_address);
+ free(ip_address);
+ ASSERT_EQ(WIFI_DIRECT_ERROR_NONE, ret);
+
+ ret = wifi_direct_destroy_group();
+ ASSERT_EQ(WIFI_DIRECT_ERROR_NONE, ret);
+}
+
+TEST_F(WifiDirectGroupTest, wifi_direct_get_ip_address_Negative1)
+{
+ int ret;
+
+ ret = wifi_direct_get_ip_address(NULL);
+ ASSERT_EQ(WIFI_DIRECT_ERROR_INVALID_PARAMETER, ret);
+}
+
+TEST_F(WifiDirectGroupTest, wifi_direct_get_ip_address_Negative2)
+{
+ char *ip_address;
+ int ret;
+
+ ret = wifi_direct_get_ip_address(&ip_address);
+ ASSERT_EQ(WIFI_DIRECT_ERROR_NOT_PERMITTED, ret);
+}
+
+TEST_F(WifiDirectGroupTest, wifi_direct_get_subnet_mask_Positive)
+{
+ char *subnet_mask;
+ int ret;
+
+ ret = wifi_direct_create_group();
+ ASSERT_EQ(WIFI_DIRECT_ERROR_NONE, ret);
+
+ ret = wifi_direct_get_subnet_mask(&subnet_mask);
+ free(subnet_mask);
+ ASSERT_EQ(WIFI_DIRECT_ERROR_NONE, ret);
+
+ ret = wifi_direct_destroy_group();
+ ASSERT_EQ(WIFI_DIRECT_ERROR_NONE, ret);
+}
+
+TEST_F(WifiDirectGroupTest, wifi_direct_get_subnet_mask_Negative1)
+{
+ int ret;
+
+ ret = wifi_direct_get_subnet_mask(NULL);
+ ASSERT_EQ(WIFI_DIRECT_ERROR_INVALID_PARAMETER, ret);
+}
+
+TEST_F(WifiDirectGroupTest, wifi_direct_get_subnet_mask_Negative2)
+{
+ char *subnet_mask;
+ int ret;
+
+ ret = wifi_direct_get_subnet_mask(&subnet_mask);
+ ASSERT_EQ(WIFI_DIRECT_ERROR_NOT_PERMITTED, ret);
+}
+
+TEST_F(WifiDirectGroupTest, wifi_direct_get_gateway_address_Positive)
+{
+ char *gateway_address;
+ int ret;
+
+ ret = wifi_direct_create_group();
+ ASSERT_EQ(WIFI_DIRECT_ERROR_NONE, ret);
+
+ ret = wifi_direct_get_gateway_address(&gateway_address);
+ free(gateway_address);
+ ASSERT_EQ(WIFI_DIRECT_ERROR_NONE, ret);
+
+ ret = wifi_direct_destroy_group();
+ ASSERT_EQ(WIFI_DIRECT_ERROR_NONE, ret);
+}
+
+TEST_F(WifiDirectGroupTest, wifi_direct_get_gateway_address_Negative1)
+{
+ int ret;
+
+ ret = wifi_direct_get_gateway_address(NULL);
+ ASSERT_EQ(WIFI_DIRECT_ERROR_INVALID_PARAMETER, ret);
+}
+
+TEST_F(WifiDirectGroupTest, wifi_direct_get_gateway_address_Negative2)
+{
+ char *gateway_address;
+ int ret;
+
+ ret = wifi_direct_get_gateway_address(&gateway_address);
+ ASSERT_EQ(WIFI_DIRECT_ERROR_NOT_PERMITTED, ret);
+}
+
+TEST_F(WifiDirectSettingTest, wifi_direct_is_discoverable_Positive)
+{
+ bool is_discoverable;
+ int ret;
+
+ ret = wifi_direct_is_discoverable(&is_discoverable);
+ ASSERT_EQ(WIFI_DIRECT_ERROR_NONE, ret);
+}
+
+TEST_F(WifiDirectSettingTest, wifi_direct_is_discoverable_Negative)
+{
+ int ret;
+
+ ret = wifi_direct_is_discoverable(NULL);
+ ASSERT_EQ(WIFI_DIRECT_ERROR_INVALID_PARAMETER, ret);
+}
+
+TEST_F(WifiDirectSettingTest, wifi_direct_is_listening_only_Positive)
+{
+ bool is_listening_only;
+ int ret;
+
+ ret = wifi_direct_is_listening_only(&is_listening_only);
+ ASSERT_EQ(WIFI_DIRECT_ERROR_NONE, ret);
+}
+
+TEST_F(WifiDirectSettingTest, wifi_direct_is_listening_only_Negative)
+{
+ int ret;
+
+ ret = wifi_direct_is_listening_only(NULL);
+ ASSERT_EQ(WIFI_DIRECT_ERROR_INVALID_PARAMETER, ret);
+}
+
+TEST_F(WifiDirectSettingTest, wifi_direct_get_primary_device_type_Positive)
+{
+ wifi_direct_primary_device_type_e type;
+ int ret;
+
+ ret = wifi_direct_get_primary_device_type(&type);
+ ASSERT_EQ(WIFI_DIRECT_ERROR_NONE, ret);
+}
+
+TEST_F(WifiDirectSettingTest, wifi_direct_get_primary_device_type_Negative)
+{
+ int ret;
+
+ ret = wifi_direct_get_primary_device_type(NULL);
+ ASSERT_EQ(WIFI_DIRECT_ERROR_INVALID_PARAMETER, ret);
+}
+
+TEST_F(WifiDirectSettingTest, wifi_direct_get_secondary_device_type_Positive)
+{
+ wifi_direct_secondary_device_type_e type;
+ int ret;
+
+ ret = wifi_direct_get_secondary_device_type(&type);
+ ASSERT_EQ(WIFI_DIRECT_ERROR_NONE, ret);
+}
+
+TEST_F(WifiDirectSettingTest, wifi_direct_get_secondary_device_type_Negative)
+{
+ int ret;
+
+ ret = wifi_direct_get_secondary_device_type(NULL);
+ ASSERT_EQ(WIFI_DIRECT_ERROR_INVALID_PARAMETER, ret);
+}
+
+TEST_F(WifiDirectSettingTest, wifi_direct_set_autoconnection_mode_Positive)
+{
+ int ret;
+
+ ret = wifi_direct_set_autoconnection_mode(false);
+ ASSERT_EQ(WIFI_DIRECT_ERROR_NONE, ret);
+}
+
+TEST_F(WifiDirectSettingTest, wifi_direct_set_autoconnection_mode_Negative)
+{
+ int ret;
+
+ mock_gdbus_gdbus_call_sync_enable(false);
+
+ ret = wifi_direct_set_autoconnection_mode(false);
+ ASSERT_EQ(WIFI_DIRECT_ERROR_OPERATION_FAILED, ret);
+
+ mock_gdbus_gdbus_call_sync_enable(true);
+}
+
+TEST_F(WifiDirectSettingTest, wifi_direct_is_autoconnection_mode_Positive)
+{
+ bool auto_connection;
+ int ret;
+
+ ret = wifi_direct_is_autoconnection_mode(&auto_connection);
+ ASSERT_EQ(WIFI_DIRECT_ERROR_NONE, ret);
+}
+
+TEST_F(WifiDirectSettingTest, wifi_direct_is_autoconnection_mode_Negative)
+{
+ int ret;
+
+ ret = wifi_direct_is_autoconnection_mode(NULL);
+ ASSERT_EQ(WIFI_DIRECT_ERROR_INVALID_PARAMETER, ret);
+}
+
+TEST_F(WifiDirectSettingTest, wifi_direct_set_persistent_group_enabled_Positive)
+{
+ int ret;
+
+ ret = wifi_direct_set_persistent_group_enabled(true);
+ ASSERT_EQ(WIFI_DIRECT_ERROR_NONE, ret);
+}
+
+TEST_F(WifiDirectSettingTest, wifi_direct_set_persistent_group_enabled_Negative)
+{
+ int ret;
+
+ mock_gdbus_gdbus_call_sync_enable(false);
+
+ ret = wifi_direct_set_persistent_group_enabled(true);
+ ASSERT_EQ(WIFI_DIRECT_ERROR_OPERATION_FAILED, ret);
+
+ mock_gdbus_gdbus_call_sync_enable(true);
+}
+
+TEST_F(WifiDirectSettingTest, wifi_direct_is_persistent_group_enabled_Positive)
+{
+ bool is_enable;
+ int ret;
+
+ ret = wifi_direct_is_persistent_group_enabled(&is_enable);
+ ASSERT_EQ(WIFI_DIRECT_ERROR_NONE, ret);
+}
+
+TEST_F(WifiDirectSettingTest, wifi_direct_is_persistent_group_enabled_Negative)
+{
+ int ret;
+
+ ret = wifi_direct_is_persistent_group_enabled(NULL);
+ ASSERT_EQ(WIFI_DIRECT_ERROR_INVALID_PARAMETER, ret);
+}
+
+bool wifi_direct_wifi_direct_foreach_persistent_groups_Positive_cb(const char *mac_address, const char *ssid, void *user_data)
+{
+ return true;
+}
+
+TEST_F(WifiDirectSettingTest, wifi_direct_wifi_direct_foreach_persistent_groups_Positive)
+{
+ int ret;
+
+ ret = wifi_direct_foreach_persistent_groups(wifi_direct_wifi_direct_foreach_persistent_groups_Positive_cb, NULL);
+ ASSERT_EQ(WIFI_DIRECT_ERROR_NONE, ret);
+}
+
+TEST_F(WifiDirectSettingTest, wifi_direct_foreach_persistent_groups_Negative1)
+{
+ int ret;
+
+ ret = wifi_direct_foreach_persistent_groups(NULL, NULL);
+ ASSERT_EQ(WIFI_DIRECT_ERROR_INVALID_PARAMETER, ret);
+}
+
+TEST_F(WifiDirectSettingTest, wifi_direct_foreach_persistent_groups_Negative2)
+{
+ int ret;
+
+ ret = wifi_direct_deactivate();
+ ASSERT_EQ(WIFI_DIRECT_ERROR_NONE, ret);
+
+ wifi_direct_manager_mock_generate_deactivation_signal();
+
+ ret = wifi_direct_foreach_persistent_groups(wifi_direct_wifi_direct_foreach_persistent_groups_Positive_cb, NULL);
+ ASSERT_EQ(WIFI_DIRECT_ERROR_NOT_PERMITTED, ret);
+
+ ret = wifi_direct_activate();
+ ASSERT_EQ(WIFI_DIRECT_ERROR_NONE, ret);
+
+ wifi_direct_manager_mock_generate_activation_signal();
+}
+
+TEST_F(WifiDirectSettingTest, wifi_direct_remove_persistent_group_Positive)
+{
+ char mac_address[] = "dummy";
+ char ssid[] = "dummy";
+ int ret;
+
+ ret = wifi_direct_remove_persistent_group(mac_address, ssid);
+ ASSERT_EQ(WIFI_DIRECT_ERROR_NONE, ret);
+}
+
+TEST_F(WifiDirectSettingTest, wifi_direct_remove_persistent_group_Negative1)
+{
+ int ret;
+
+ ret = wifi_direct_remove_persistent_group(NULL, NULL);
+ ASSERT_EQ(WIFI_DIRECT_ERROR_INVALID_PARAMETER, ret);
+}
+
+TEST_F(WifiDirectSettingTest, wifi_direct_remove_persistent_group_Negative2)
+{
+ char mac_address[] = "dummy";
+ char ssid[] = "dummy";
+ int ret;
+
+ ret = wifi_direct_deactivate();
+ ASSERT_EQ(WIFI_DIRECT_ERROR_NONE, ret);
+
+ wifi_direct_manager_mock_generate_deactivation_signal();
+
+ ret = wifi_direct_remove_persistent_group(mac_address, ssid);
+ ASSERT_EQ(WIFI_DIRECT_ERROR_NOT_PERMITTED, ret);
+
+ ret = wifi_direct_activate();
+ ASSERT_EQ(WIFI_DIRECT_ERROR_NONE, ret);
+
+ wifi_direct_manager_mock_generate_activation_signal();
+}
+
+TEST_F(WifiDirectSettingTest, wifi_direct_set_passphrase_Positive)
+{
+ char passphrase[] = "ABCDEFGH";
+ int ret;
+
+ ret = wifi_direct_set_passphrase(passphrase);
+ ASSERT_EQ(WIFI_DIRECT_ERROR_NONE, ret);
+}
+
+TEST_F(WifiDirectSettingTest, wifi_direct_set_passphrase_Negative1)
+{
+ int ret;
+
+ ret = wifi_direct_set_passphrase(NULL);
+ ASSERT_EQ(WIFI_DIRECT_ERROR_INVALID_PARAMETER, ret);
+}
+
+TEST_F(WifiDirectSettingTest, wifi_direct_set_passphrase_Negative2)
+{
+ char passphrase[] = "ABCDEFGH";
+ int ret;
+
+ ret = wifi_direct_create_group();
+ ASSERT_EQ(WIFI_DIRECT_ERROR_NONE, ret);
+
+ ret = wifi_direct_set_passphrase(passphrase);
+ ASSERT_EQ(WIFI_DIRECT_ERROR_NOT_PERMITTED, ret);
+}
+
+TEST_F(WifiDirectSettingTest, wifi_direct_get_passphrase_Positive)
+{
+ char *passphrase;
+ int ret;
+
+ ret = wifi_direct_create_group();
+ ASSERT_EQ(WIFI_DIRECT_ERROR_NONE, ret);
+
+ ret = wifi_direct_get_passphrase(&passphrase);
+ free(passphrase);
+ ASSERT_EQ(WIFI_DIRECT_ERROR_NONE, ret);
+}
+
+TEST_F(WifiDirectSettingTest, wifi_direct_get_passphrase_Negative1)
+{
+ int ret;
+
+ ret = wifi_direct_get_passphrase(NULL);
+ ASSERT_EQ(WIFI_DIRECT_ERROR_INVALID_PARAMETER, ret);
+}
+
+TEST_F(WifiDirectSettingTest, wifi_direct_get_passphrase_Negative2)
+{
+ char *passphrase;
+ int ret;
+
+ ret = wifi_direct_get_passphrase(&passphrase);
+ ASSERT_EQ(WIFI_DIRECT_ERROR_NOT_PERMITTED, ret);
+}
+
+TEST_F(WifiDirectSettingTest, wifi_direct_set_autoconnection_peer_Positive)
+{
+ char test_mac[] = {"aa:bb:cc:dd:ee:ff"};
+ int ret;
+
+ ret = wifi_direct_set_autoconnection_peer(test_mac);
+ ASSERT_EQ(WIFI_DIRECT_ERROR_NONE, ret);
+}
+
+TEST_F(WifiDirectSettingTest, wifi_direct_set_autoconnection_peer_Negative1)
+{
+ int ret;
+
+ ret = wifi_direct_set_autoconnection_peer(NULL);
+ ASSERT_EQ(WIFI_DIRECT_ERROR_INVALID_PARAMETER, ret);
+}
+
+TEST_F(WifiDirectSettingTest, wifi_direct_init_display_Positive)
+{
+ int ret;
+
+ ret = wifi_direct_init_display();
+ ASSERT_EQ(WIFI_DIRECT_ERROR_NONE, ret);
+}
+
+TEST_F(WifiDirectSettingTest, wifi_direct_init_display_Negative)
+{
+ int ret;
+
+ ret = wifi_direct_deactivate();
+ ASSERT_EQ(WIFI_DIRECT_ERROR_NONE, ret);
+
+ wifi_direct_manager_mock_generate_deactivation_signal();
+
+ ret = wifi_direct_init_display();
+ ASSERT_EQ(WIFI_DIRECT_ERROR_NOT_PERMITTED, ret);
+
+ ret = wifi_direct_activate();
+ ASSERT_EQ(WIFI_DIRECT_ERROR_NONE, ret);
+
+ wifi_direct_manager_mock_generate_activation_signal();
+}
+
+TEST_F(WifiDirectSettingTest, wifi_direct_deinit_display_Positive)
+{
+ int ret;
+
+ ret = wifi_direct_deinit_display();
+ ASSERT_EQ(WIFI_DIRECT_ERROR_NONE, ret);
+}
+
+TEST_F(WifiDirectSettingTest, wifi_direct_deinit_display_Negative)
+{
+ int ret;
+
+ ret = wifi_direct_deactivate();
+ ASSERT_EQ(WIFI_DIRECT_ERROR_NONE, ret);
+
+ wifi_direct_manager_mock_generate_deactivation_signal();
+
+ ret = wifi_direct_deinit_display();
+ ASSERT_EQ(WIFI_DIRECT_ERROR_NOT_PERMITTED, ret);
+
+ ret = wifi_direct_activate();
+ ASSERT_EQ(WIFI_DIRECT_ERROR_NONE, ret);
+
+ wifi_direct_manager_mock_generate_activation_signal();
+}
+TEST_F(WifiDirectSettingTest, wifi_direct_set_display_Positive)
+{
+ int ret;
+
+ ret = wifi_direct_set_display(WIFI_DIRECT_DISPLAY_TYPE_DUAL, 554, 1);
+ ASSERT_EQ(WIFI_DIRECT_ERROR_NONE, ret);
+}
+
+TEST_F(WifiDirectSettingTest, wifi_direct_set_display_Negative1)
+{
+ int ret;
+
+ ret = wifi_direct_set_display(WIFI_DIRECT_DISPLAY_TYPE_DUAL, -1, -1);
+ ASSERT_EQ(WIFI_DIRECT_ERROR_INVALID_PARAMETER, ret);
+}
+
+TEST_F(WifiDirectSettingTest, wifi_direct_set_display_Negative2)
+{
+ int ret;
+
+ ret = wifi_direct_deactivate();
+ ASSERT_EQ(WIFI_DIRECT_ERROR_NONE, ret);
+
+ wifi_direct_manager_mock_generate_deactivation_signal();
+
+ ret = wifi_direct_set_display(WIFI_DIRECT_DISPLAY_TYPE_DUAL, 554, 1);
+ ASSERT_EQ(WIFI_DIRECT_ERROR_NOT_PERMITTED, ret);
+
+ ret = wifi_direct_activate();
+ ASSERT_EQ(WIFI_DIRECT_ERROR_NONE, ret);
+
+ wifi_direct_manager_mock_generate_activation_signal();
+}
+
+TEST_F(WifiDirectSettingTest, wifi_direct_set_display_availability_Positive)
+{
+ int ret;
+
+ ret = wifi_direct_set_display_availability(TRUE);
+ ASSERT_EQ(WIFI_DIRECT_ERROR_NONE, ret);
+}
+
+TEST_F(WifiDirectSettingTest, wifi_direct_set_display_availability_Negative)
+{
+ int ret;
+
+ ret = wifi_direct_deactivate();
+ ASSERT_EQ(WIFI_DIRECT_ERROR_NONE, ret);
+
+ wifi_direct_manager_mock_generate_deactivation_signal();
+
+ ret = wifi_direct_set_display_availability(TRUE);
+ ASSERT_EQ(WIFI_DIRECT_ERROR_NOT_PERMITTED, ret);
+
+ ret = wifi_direct_activate();
+ ASSERT_EQ(WIFI_DIRECT_ERROR_NONE, ret);
+
+ wifi_direct_manager_mock_generate_activation_signal();
+}
+
+TEST_F(WifiDirectSettingTest, wifi_direct_get_display_Positive)
+{
+ wifi_direct_display_type_e type;
+ int port;
+ int hdcp;
+ int ret;
+
+ ret = wifi_direct_get_display(&type, &port, &hdcp);
+ ASSERT_EQ(WIFI_DIRECT_ERROR_NONE, ret);
+}
+
+TEST_F(WifiDirectSettingTest, wifi_direct_get_display_Negative1)
+{
+ int ret;
+
+ ret = wifi_direct_get_display(NULL, NULL, NULL);
+ ASSERT_EQ(WIFI_DIRECT_ERROR_INVALID_PARAMETER, ret);
+}
+
+TEST_F(WifiDirectSettingTest, wifi_direct_get_display_Negative2)
+{
+ wifi_direct_display_type_e type;
+ int port;
+ int hdcp;
+ int ret;
+
+ ret = wifi_direct_deactivate();
+ ASSERT_EQ(WIFI_DIRECT_ERROR_NONE, ret);
+
+ wifi_direct_manager_mock_generate_deactivation_signal();
+
+ ret = wifi_direct_get_display(&type, &port, &hdcp);
+ ASSERT_EQ(WIFI_DIRECT_ERROR_NOT_PERMITTED, ret);
+
+ ret = wifi_direct_activate();
+ ASSERT_EQ(WIFI_DIRECT_ERROR_NONE, ret);
+
+ wifi_direct_manager_mock_generate_activation_signal();
+}
+
+TEST_F(WifiDirectSettingTest, wifi_direct_get_display_availability_Positive)
+{
+ bool availability;
+ int ret;
+
+ ret = wifi_direct_get_display_availability(&availability);
+ ASSERT_EQ(WIFI_DIRECT_ERROR_NONE, ret);
+}
+
+TEST_F(WifiDirectSettingTest, wifi_direct_get_display_availability_Negative1)
+{
+ int ret;
+
+ ret = wifi_direct_get_display_availability(NULL);
+ ASSERT_EQ(WIFI_DIRECT_ERROR_INVALID_PARAMETER, ret);
+}
+
+TEST_F(WifiDirectSettingTest, wifi_direct_get_display_availability_Negative2)
+{
+ bool availability;
+ int ret;
+
+ ret = wifi_direct_deactivate();
+ ASSERT_EQ(WIFI_DIRECT_ERROR_NONE, ret);
+
+ wifi_direct_manager_mock_generate_deactivation_signal();
+
+ ret = wifi_direct_get_display_availability(&availability);
+ ASSERT_EQ(WIFI_DIRECT_ERROR_NOT_PERMITTED, ret);
+
+ ret = wifi_direct_activate();
+ ASSERT_EQ(WIFI_DIRECT_ERROR_NONE, ret);
+
+ wifi_direct_manager_mock_generate_activation_signal();
+}
+
+TEST_F(WifiDirectSettingTest, wifi_direct_get_peer_display_type_Positive)
+{
+ char mac_address[] = "aa:bb:cc:dd:ee:ff";
+ wifi_direct_display_type_e type;
+ int ret;
+
+ ret = wifi_direct_get_peer_display_type(mac_address, &type);
+ ASSERT_EQ(WIFI_DIRECT_ERROR_NONE, ret);
+}
+
+TEST_F(WifiDirectSettingTest, wifi_direct_get_peer_display_type_Negative1)
+{
+ int ret;
+
+ ret = wifi_direct_get_peer_display_type(NULL, NULL);
+ ASSERT_EQ(WIFI_DIRECT_ERROR_INVALID_PARAMETER, ret);
+}
+
+TEST_F(WifiDirectSettingTest, wifi_direct_get_peer_display_type_Negative2)
+{
+ char mac_address[] = "aa:bb:cc:dd:ee:ff";
+ wifi_direct_display_type_e type;
+ int ret;
+
+ ret = wifi_direct_deactivate();
+ ASSERT_EQ(WIFI_DIRECT_ERROR_NONE, ret);
+
+ wifi_direct_manager_mock_generate_deactivation_signal();
+
+ ret = wifi_direct_get_peer_display_type(mac_address, &type);
+ ASSERT_EQ(WIFI_DIRECT_ERROR_NOT_PERMITTED, ret);
+
+ ret = wifi_direct_activate();
+ ASSERT_EQ(WIFI_DIRECT_ERROR_NONE, ret);
+
+ wifi_direct_manager_mock_generate_activation_signal();
+}
+
+TEST_F(WifiDirectSettingTest, wifi_direct_get_peer_display_availability_Positive)
+{
+ char mac_address[] = "aa:bb:cc:dd:ee:ff";
+ bool availability;
+ int ret;
+
+ ret = wifi_direct_get_peer_display_availability(mac_address, &availability);
+ ASSERT_EQ(WIFI_DIRECT_ERROR_NONE, ret);
+}
+
+TEST_F(WifiDirectSettingTest, wifi_direct_get_peer_display_availability_Negative1)
+{
+ int ret;
+
+ ret = wifi_direct_get_peer_display_availability(NULL, NULL);
+ ASSERT_EQ(WIFI_DIRECT_ERROR_INVALID_PARAMETER, ret);
+}
+
+TEST_F(WifiDirectSettingTest, wifi_direct_get_peer_display_availability_Negative2)
+{
+ char mac_address[] = "aa:bb:cc:dd:ee:ff";
+ bool availability;
+ int ret;
+
+ ret = wifi_direct_deactivate();
+ ASSERT_EQ(WIFI_DIRECT_ERROR_NONE, ret);
+
+ wifi_direct_manager_mock_generate_deactivation_signal();
+
+ ret = wifi_direct_get_peer_display_availability(mac_address, &availability);
+ ASSERT_EQ(WIFI_DIRECT_ERROR_NOT_PERMITTED, ret);
+
+ ret = wifi_direct_activate();
+ ASSERT_EQ(WIFI_DIRECT_ERROR_NONE, ret);
+
+ wifi_direct_manager_mock_generate_activation_signal();
+}
+
+TEST_F(WifiDirectSettingTest, wifi_direct_get_peer_display_hdcp_Positive)
+{
+ char mac_address[] = "aa:bb:cc:dd:ee:ff";
+ int hdcp;
+ int ret;
+
+ ret = wifi_direct_get_peer_display_hdcp(mac_address, &hdcp);
+ ASSERT_EQ(WIFI_DIRECT_ERROR_NONE, ret);
+}
+
+TEST_F(WifiDirectSettingTest, wifi_direct_get_peer_display_hdcp_Negative1)
+{
+ int ret;
+
+ ret = wifi_direct_get_peer_display_hdcp(NULL, NULL);
+ ASSERT_EQ(WIFI_DIRECT_ERROR_INVALID_PARAMETER, ret);
+}
+
+TEST_F(WifiDirectSettingTest, wifi_direct_get_peer_display_hdcp_Negative2)
+{
+ char mac_address[] = "aa:bb:cc:dd:ee:ff";
+ int hdcp;
+ int ret;
+
+ ret = wifi_direct_deactivate();
+ ASSERT_EQ(WIFI_DIRECT_ERROR_NONE, ret);
+
+ wifi_direct_manager_mock_generate_deactivation_signal();
+
+ ret = wifi_direct_get_peer_display_hdcp(mac_address, &hdcp);
+ ASSERT_EQ(WIFI_DIRECT_ERROR_NOT_PERMITTED, ret);
+
+ ret = wifi_direct_activate();
+ ASSERT_EQ(WIFI_DIRECT_ERROR_NONE, ret);
+
+ wifi_direct_manager_mock_generate_activation_signal();
+}
+
+TEST_F(WifiDirectSettingTest, wifi_direct_get_peer_display_port_Positive)
+{
+ char mac_address[] = "aa:bb:cc:dd:ee:ff";
+ int port;
+ int ret;
+
+ ret = wifi_direct_get_peer_display_port(mac_address, &port);
+ ASSERT_EQ(WIFI_DIRECT_ERROR_NONE, ret);
+}
+
+TEST_F(WifiDirectSettingTest, wifi_direct_get_peer_display_port_Negative1)
+{
+ int ret;
+
+ ret = wifi_direct_get_peer_display_port(NULL, NULL);
+ ASSERT_EQ(WIFI_DIRECT_ERROR_INVALID_PARAMETER, ret);
+}
+
+TEST_F(WifiDirectSettingTest, wifi_direct_get_peer_display_port_Negative2)
+{
+ char mac_address[] = "aa:bb:cc:dd:ee:ff";
+ int port;
+ int ret;
+
+ ret = wifi_direct_deactivate();
+ ASSERT_EQ(WIFI_DIRECT_ERROR_NONE, ret);
+
+ wifi_direct_manager_mock_generate_deactivation_signal();
+
+ ret = wifi_direct_get_peer_display_port(mac_address, &port);
+ ASSERT_EQ(WIFI_DIRECT_ERROR_NOT_PERMITTED, ret);
+
+ ret = wifi_direct_activate();
+ ASSERT_EQ(WIFI_DIRECT_ERROR_NONE, ret);
+
+ wifi_direct_manager_mock_generate_activation_signal();
+}
+
+TEST_F(WifiDirectSettingTest, wifi_direct_get_peer_display_throughput_Positive)
+{
+ char mac_address[] = "aa:bb:cc:dd:ee:ff";
+ int throughput;
+ int ret;
+
+ ret = wifi_direct_get_peer_display_throughput(mac_address, &throughput);
+ ASSERT_EQ(WIFI_DIRECT_ERROR_NONE, ret);
+}
+
+TEST_F(WifiDirectSettingTest, wifi_direct_get_peer_display_throughput_Negative1)
+{
+ int ret;
+
+ ret = wifi_direct_get_peer_display_throughput(NULL, NULL);
+ ASSERT_EQ(WIFI_DIRECT_ERROR_INVALID_PARAMETER, ret);
+}
+
+TEST_F(WifiDirectSettingTest, wifi_direct_get_peer_display_throughput_Negative2)
+{
+ char mac_address[] = "aa:bb:cc:dd:ee:ff";
+ int throughput;
+ int ret;
+
+ ret = wifi_direct_deactivate();
+ ASSERT_EQ(WIFI_DIRECT_ERROR_NONE, ret);
+
+ wifi_direct_manager_mock_generate_deactivation_signal();
+
+ ret = wifi_direct_get_peer_display_throughput(mac_address, &throughput);
+ ASSERT_EQ(WIFI_DIRECT_ERROR_NOT_PERMITTED, ret);
+
+ ret = wifi_direct_activate();
+ ASSERT_EQ(WIFI_DIRECT_ERROR_NONE, ret);
+
+ wifi_direct_manager_mock_generate_activation_signal();
+}
+
+TEST_F(WifiDirectSettingTest, wifi_direct_set_session_timer_Positive)
+{
+ int ret;
+
+ ret = wifi_direct_set_session_timer(120);
+ ASSERT_EQ(WIFI_DIRECT_ERROR_NONE, ret);
+}
+
+TEST_F(WifiDirectSettingTest, wifi_direct_set_session_timer_Negative)
+{
+ int ret;
+
+ ret = wifi_direct_set_session_timer(-1);
+ ASSERT_EQ(WIFI_DIRECT_ERROR_INVALID_PARAMETER, ret);
+}
+
+TEST_F(WifiDirectSettingTest, wifi_direct_get_session_timer_Positive)
+{
+ int second;
+ int ret;
+
+ ret = wifi_direct_get_session_timer(&second);
+ ASSERT_EQ(WIFI_DIRECT_ERROR_NONE, ret);
+}
+
+TEST_F(WifiDirectSettingTest, wifi_direct_get_session_timer_Negative)
+{
+ int ret;
+
+ ret = wifi_direct_get_session_timer(NULL);
+ ASSERT_EQ(WIFI_DIRECT_ERROR_INVALID_PARAMETER, ret);
+}
+
+TEST_F(WifiDirectSettingTest, wifi_direct_set_auto_group_removal_Positive)
+{
+ int ret;
+
+ ret = wifi_direct_set_auto_group_removal(true);
+ ASSERT_EQ(WIFI_DIRECT_ERROR_NONE, ret);
+}
+
+TEST_F(WifiDirectSettingTest, wifi_direct_set_auto_group_removal_Negative)
+{
+ int ret;
+
+ ret = wifi_direct_deactivate();
+ ASSERT_EQ(WIFI_DIRECT_ERROR_NONE, ret);
+
+ wifi_direct_manager_mock_generate_deactivation_signal();
+
+ ret = wifi_direct_set_auto_group_removal(true);
+ ASSERT_EQ(WIFI_DIRECT_ERROR_NOT_PERMITTED, ret);
+
+ ret = wifi_direct_activate();
+ ASSERT_EQ(WIFI_DIRECT_ERROR_NONE, ret);
+
+ wifi_direct_manager_mock_generate_activation_signal();
+}
+TEST_F(WifiDirectSettingTest,wifi_direct_get_peer_rssi_Positive)
+{
+ char mac_address[] = "aa:bb:cc:dd:ee:ff";
+ int rssi;
+ int ret;
+
+ ret = wifi_direct_get_peer_rssi(mac_address, &rssi);
+ ASSERT_EQ(WIFI_DIRECT_ERROR_NONE, ret);
+}
+
+TEST_F(WifiDirectSettingTest, wifi_direct_get_peer_rssi_Negative1)
+{
+ int ret;
+
+ ret = wifi_direct_get_peer_rssi(NULL, NULL);
+ ASSERT_EQ(WIFI_DIRECT_ERROR_INVALID_PARAMETER, ret);
+}
+
+TEST_F(WifiDirectSettingTest, wifi_direct_get_peer_rssi_Negative2)
+{
+ char mac_address[] = "aa:bb:cc:dd:ee:ff";
+ int rssi;
+ int ret;
+
+ ret = wifi_direct_deactivate();
+ ASSERT_EQ(WIFI_DIRECT_ERROR_NONE, ret);
+
+ wifi_direct_manager_mock_generate_deactivation_signal();
+
+ ret = wifi_direct_get_peer_rssi(mac_address, &rssi);
+ ASSERT_EQ(WIFI_DIRECT_ERROR_NOT_PERMITTED, ret);
+
+ ret = wifi_direct_activate();
+ ASSERT_EQ(WIFI_DIRECT_ERROR_NONE, ret);
+
+ wifi_direct_manager_mock_generate_activation_signal();
+}
+
+TEST_F(WifiDirectSettingTest, wifi_direct_add_vsie_Positive)
+{
+ char test_vsie[] = "TestVsieStr";
+ int ret;
+
+ ret = wifi_direct_add_vsie(WIFI_DIRECT_VSIE_FRAME_P2P_PROBE_REQ, test_vsie);
+ ASSERT_EQ(WIFI_DIRECT_ERROR_NONE, ret);
+}
+
+TEST_F(WifiDirectSettingTest, wifi_direct_add_vsie_Negative1)
+{
+ int ret;
+
+ ret = wifi_direct_add_vsie(WIFI_DIRECT_VSIE_FRAME_P2P_PROBE_REQ, NULL);
+ ASSERT_EQ(WIFI_DIRECT_ERROR_INVALID_PARAMETER, ret);
+}
+
+TEST_F(WifiDirectSettingTest, wifi_direct_add_vsie_Negative2)
+{
+ char test_vsie[] = "TestVsieStr";
+ int ret;
+
+ ret = wifi_direct_deactivate();
+ ASSERT_EQ(WIFI_DIRECT_ERROR_NONE, ret);
+
+ wifi_direct_manager_mock_generate_deactivation_signal();
+
+ ret = wifi_direct_add_vsie(WIFI_DIRECT_VSIE_FRAME_P2P_PROBE_REQ, test_vsie);
+ ASSERT_EQ(WIFI_DIRECT_ERROR_NOT_PERMITTED, ret);
+
+ ret = wifi_direct_activate();
+ ASSERT_EQ(WIFI_DIRECT_ERROR_NONE, ret);
+
+ wifi_direct_manager_mock_generate_activation_signal();
+}
+
+TEST_F(WifiDirectSettingTest, wifi_direct_get_vsie_Positive)
+{
+ char *test_vsie;
+ int ret;
+
+ ret = wifi_direct_get_vsie(WIFI_DIRECT_VSIE_FRAME_P2P_PROBE_REQ, &test_vsie);
+ free(test_vsie);
+ ASSERT_EQ(WIFI_DIRECT_ERROR_NONE, ret);
+}
+
+TEST_F(WifiDirectSettingTest, wifi_direct_get_vsie_Negative1)
+{
+ int ret;
+
+ ret = wifi_direct_get_vsie(WIFI_DIRECT_VSIE_FRAME_P2P_PROBE_REQ, NULL);
+ ASSERT_EQ(WIFI_DIRECT_ERROR_INVALID_PARAMETER, ret);
+}
+
+TEST_F(WifiDirectSettingTest, wifi_direct_get_vsie_Negative2)
+{
+ char *test_vsie;
+ int ret;
+
+ ret = wifi_direct_deactivate();
+ ASSERT_EQ(WIFI_DIRECT_ERROR_NONE, ret);
+
+ wifi_direct_manager_mock_generate_deactivation_signal();
+
+ ret = wifi_direct_get_vsie(WIFI_DIRECT_VSIE_FRAME_P2P_PROBE_REQ, &test_vsie);
+ ASSERT_EQ(WIFI_DIRECT_ERROR_NOT_PERMITTED, ret);
+
+ ret = wifi_direct_activate();
+ ASSERT_EQ(WIFI_DIRECT_ERROR_NONE, ret);
+
+ wifi_direct_manager_mock_generate_activation_signal();
+}
+
+TEST_F(WifiDirectSettingTest, wifi_direct_remove_vsie_Positive)
+{
+ char test_vsie[] = "TestVsieStr";
+ int ret;
+
+ ret = wifi_direct_remove_vsie(WIFI_DIRECT_VSIE_FRAME_P2P_PROBE_REQ, test_vsie);
+ ASSERT_EQ(WIFI_DIRECT_ERROR_NONE, ret);
+}
+
+TEST_F(WifiDirectSettingTest, wifi_direct_remove_vsie_Negative1)
+{
+ int ret;
+
+ ret = wifi_direct_remove_vsie(WIFI_DIRECT_VSIE_FRAME_P2P_PROBE_REQ, NULL);
+ ASSERT_EQ(WIFI_DIRECT_ERROR_INVALID_PARAMETER, ret);
+}
+
+TEST_F(WifiDirectSettingTest, wifi_direct_remove_vsie_Negative2)
+{
+ char test_vsie[] = "TestVsieStr";
+ int ret;
+
+ ret = wifi_direct_deactivate();
+ ASSERT_EQ(WIFI_DIRECT_ERROR_NONE, ret);
+
+ wifi_direct_manager_mock_generate_deactivation_signal();
+
+ ret = wifi_direct_remove_vsie(WIFI_DIRECT_VSIE_FRAME_P2P_PROBE_REQ, test_vsie);
+ ASSERT_EQ(WIFI_DIRECT_ERROR_NOT_PERMITTED, ret);
+
+ ret = wifi_direct_activate();
+ ASSERT_EQ(WIFI_DIRECT_ERROR_NONE, ret);
+
+ wifi_direct_manager_mock_generate_activation_signal();
+}
+
+TEST_F(WifiDirectSettingTest, wifi_direct_get_peer_vsie_Positive)
+{
+ char mac_address[] = "aa:bb:cc:dd:ee:ff";
+ char *vsie;
+ int ret;
+
+ ret = wifi_direct_get_peer_vsie(mac_address, &vsie);
+ free(vsie);
+ ASSERT_EQ(WIFI_DIRECT_ERROR_NONE, ret);
+}
+
+TEST_F(WifiDirectSettingTest, wifi_direct_get_peer_vsie_Negative1)
+{
+ int ret;
+
+ ret = wifi_direct_get_peer_vsie(NULL, NULL);
+ ASSERT_EQ(WIFI_DIRECT_ERROR_INVALID_PARAMETER, ret);
+}
+
+TEST_F(WifiDirectSettingTest, wifi_direct_get_peer_vsie_Negative2)
+{
+ char mac_address[] = "aa:bb:cc:dd:ee:ff";
+ char *vsie;
+ int ret;
+
+ ret = wifi_direct_deactivate();
+ ASSERT_EQ(WIFI_DIRECT_ERROR_NONE, ret);
+
+ wifi_direct_manager_mock_generate_deactivation_signal();
+
+ ret = wifi_direct_get_peer_vsie(mac_address, &vsie);
+ ASSERT_EQ(WIFI_DIRECT_ERROR_NOT_PERMITTED, ret);
+
+ ret = wifi_direct_activate();
+ ASSERT_EQ(WIFI_DIRECT_ERROR_NONE, ret);
+
+ wifi_direct_manager_mock_generate_activation_signal();
+}
+
+TEST_F(WifiDirectSettingTest, wifi_direct_set_wps_config_method_Positive)
+{
+ int ret;
+
+ ret = wifi_direct_set_wps_config_method(WIFI_DIRECT_CONFIG_METHOD_DEFAULT);
+ ASSERT_EQ(WIFI_DIRECT_ERROR_NONE, ret);
+}
+
+TEST_F(WifiDirectSettingTest, wifi_direct_set_wps_config_method_Negative1)
+{
+ int ret;
+
+ ret = wifi_direct_set_wps_config_method(-1);
+ ASSERT_EQ(WIFI_DIRECT_ERROR_INVALID_PARAMETER, ret);
+}
+
+TEST_F(WifiDirectSettingTest, wifi_direct_set_wps_config_method_Negative2)
+{
+ int ret;
+
+ ret = wifi_direct_deactivate();
+ ASSERT_EQ(WIFI_DIRECT_ERROR_NONE, ret);
+
+ wifi_direct_manager_mock_generate_deactivation_signal();
+
+ ret = wifi_direct_set_wps_config_method(WIFI_DIRECT_CONFIG_METHOD_DEFAULT);
+ ASSERT_EQ(WIFI_DIRECT_ERROR_NOT_PERMITTED, ret);
+
+ ret = wifi_direct_activate();
+ ASSERT_EQ(WIFI_DIRECT_ERROR_NONE, ret);
+
+ wifi_direct_manager_mock_generate_activation_signal();
+}
+
+TEST_F(WifiDirectSettingTest, wifi_direct_get_wps_config_method_Positive)
+{
+ int type;
+ int ret;
+
+ ret = wifi_direct_get_wps_config_method(&type);
+ ASSERT_EQ(WIFI_DIRECT_ERROR_NONE, ret);
+}
+
+TEST_F(WifiDirectSettingTest, wifi_direct_get_wps_config_method_Negative1)
+{
+ int ret;
+
+ ret = wifi_direct_get_wps_config_method(NULL);
+ ASSERT_EQ(WIFI_DIRECT_ERROR_INVALID_PARAMETER, ret);
+}
+
+TEST_F(WifiDirectSettingTest, wifi_direct_get_wps_config_method_Negative2)
+{
+ int type;
+ int ret;
+
+ ret = wifi_direct_deactivate();
+ ASSERT_EQ(WIFI_DIRECT_ERROR_NONE, ret);
+
+ wifi_direct_manager_mock_generate_deactivation_signal();
+
+ ret = wifi_direct_get_wps_config_method(&type);
+ ASSERT_EQ(WIFI_DIRECT_ERROR_NOT_PERMITTED, ret);
+
+ ret = wifi_direct_activate();
+ ASSERT_EQ(WIFI_DIRECT_ERROR_NONE, ret);
+
+ wifi_direct_manager_mock_generate_activation_signal();
+}
+
+TEST_F(WifiDirectSettingTest, wifi_direct_remove_persistent_device_Positive)
+{
+ char mac_address[] = "aa:bb:cc:dd:ee:ff";
+ int ret;
+
+ ret = wifi_direct_remove_persistent_device(mac_address);
+ ASSERT_EQ(WIFI_DIRECT_ERROR_NONE, ret);
+}
+
+TEST_F(WifiDirectSettingTest, wifi_direct_remove_persistent_device_Negative1)
+{
+ int ret;
+
+ ret = wifi_direct_remove_persistent_device(NULL);
+ ASSERT_EQ(WIFI_DIRECT_ERROR_INVALID_PARAMETER, ret);
+}
+
+TEST_F(WifiDirectSettingTest, wifi_direct_remove_persistent_device_Negative2)
+{
+ char mac_address[] = "aa:bb:cc:dd:ee:ff";
+ int ret;
+
+ ret = wifi_direct_deactivate();
+ ASSERT_EQ(WIFI_DIRECT_ERROR_NONE, ret);
+
+ wifi_direct_manager_mock_generate_deactivation_signal();
+
+ ret = wifi_direct_remove_persistent_device(mac_address);
+ ASSERT_EQ(WIFI_DIRECT_ERROR_NOT_PERMITTED, ret);
+
+ ret = wifi_direct_activate();
+ ASSERT_EQ(WIFI_DIRECT_ERROR_NONE, ret);
+
+ wifi_direct_manager_mock_generate_activation_signal();
+}
+
+TEST_F(WifiDirectSettingTest, wifi_direct_remove_all_persistent_devices_Positive)
+{
+ int ret;
+
+ ret = wifi_direct_remove_all_persistent_devices();
+ ASSERT_EQ(WIFI_DIRECT_ERROR_NONE, ret);
+}
+
+TEST_F(WifiDirectSettingTest, wifi_direct_remove_all_persistent_devices_Negative)
+{
+ int ret;
+
+ ret = wifi_direct_deactivate();
+ ASSERT_EQ(WIFI_DIRECT_ERROR_NONE, ret);
+
+ wifi_direct_manager_mock_generate_deactivation_signal();
+
+ ret = wifi_direct_remove_all_persistent_devices();
+ ASSERT_EQ(WIFI_DIRECT_ERROR_NOT_PERMITTED, ret);
+
+ ret = wifi_direct_activate();
+ ASSERT_EQ(WIFI_DIRECT_ERROR_NONE, ret);
+
+ wifi_direct_manager_mock_generate_activation_signal();
+}
+
+TEST_F(WifiDirectSettingTest, wifi_direct_init_miracast_Positive)
+{
+ int ret;
+
+ ret = wifi_direct_init_miracast(true);
+ ASSERT_EQ(WIFI_DIRECT_ERROR_NONE, ret);
+}
+
+TEST_F(WifiDirectSettingTest, wifi_direct_init_miracast_Negative)
+{
+ int ret;
+
+ ret = wifi_direct_deactivate();
+ ASSERT_EQ(WIFI_DIRECT_ERROR_NONE, ret);
+
+ wifi_direct_manager_mock_generate_deactivation_signal();
+
+ ret = wifi_direct_init_miracast(true);
+ ASSERT_EQ(WIFI_DIRECT_ERROR_NOT_PERMITTED, ret);
+
+ ret = wifi_direct_activate();
+ ASSERT_EQ(WIFI_DIRECT_ERROR_NONE, ret);
+
+ wifi_direct_manager_mock_generate_activation_signal();
+}
+
+class WifiDirectConnectTest : public ::testing::Test {
+protected:
+ void SetUp() override
+ {
+ //Setting up normal condition
+ mock_gdbus_gdbus_sync_enable(true);
+ mock_gdbus_gdbus_call_sync_enable(true);
+ wifi_direct_manager_mock_init();
+
+ int ret;
+ ret = wifi_direct_initialize();
+ ASSERT_EQ(WIFI_DIRECT_ERROR_NONE, ret);
+
+ ret = wifi_direct_activate();
+ ASSERT_EQ(WIFI_DIRECT_ERROR_NONE, ret);
+
+ wifi_direct_manager_mock_generate_activation_signal();
+ }
+
+ void TearDown() override
+ {
+ int ret;
+ ret = wifi_direct_deactivate();
+ ASSERT_EQ(WIFI_DIRECT_ERROR_NONE, ret);
+
+ wifi_direct_manager_mock_generate_deactivation_signal();
+
+ ret = wifi_direct_deinitialize();
+ ASSERT_EQ(WIFI_DIRECT_ERROR_NONE, ret);
+
+ wifi_direct_manager_mock_deinit();
+ }
+};
+
+TEST_F(WifiDirectConnectTest, wifi_direct_connect_positive)
+{
+ char mac_address[] = "aa:bb:cc:dd:ee:ff";
+ int ret;
+
+ ret = wifi_direct_set_connection_state_changed_cb(__connection_state_changed_cb, NULL);
+ ASSERT_EQ(WIFI_DIRECT_ERROR_NONE, ret);
+
+ ret = wifi_direct_set_client_ip_address_assigned_cb(__client_ip_address_assigned_cb, NULL);
+ ASSERT_EQ(WIFI_DIRECT_ERROR_NONE, ret);
+
+ ret = wifi_direct_connect(mac_address);
+ ASSERT_EQ(WIFI_DIRECT_ERROR_NONE, ret);
+
+ wifi_direct_manager_mock_generate_connection_in_progress_signal();
+ wifi_direct_manager_mock_generate_connection_rsp_with_no_error_go_signal();
+ wifi_direct_manager_mock_generate_peer_ip_assigned_signal();
+ wifi_direct_manager_mock_generate_disconnection_signal();
+
+ ret = wifi_direct_unset_connection_state_changed_cb();
+ ASSERT_EQ(WIFI_DIRECT_ERROR_NONE, ret);
+
+ ret = wifi_direct_unset_client_ip_address_assigned_cb();
+ ASSERT_EQ(WIFI_DIRECT_ERROR_NONE, ret);
+}
+
+TEST_F(WifiDirectConnectTest, wifi_direct_connect_Negative1)
+{
+ int ret;
+
+ ret = wifi_direct_connect(NULL);
+ ASSERT_EQ(WIFI_DIRECT_ERROR_INVALID_PARAMETER, ret);
+}
+
+TEST_F(WifiDirectConnectTest, wifi_direct_connect_Negative2)
+{
+ char mac_address[] = "aa:bb:cc:dd:ee:ff";
+ int ret;
+
+ ret = wifi_direct_deactivate();
+ ASSERT_EQ(WIFI_DIRECT_ERROR_NONE, ret);
+
+ wifi_direct_manager_mock_generate_deactivation_signal();
+
+ ret = wifi_direct_connect(mac_address);
+ ASSERT_EQ(WIFI_DIRECT_ERROR_NOT_PERMITTED, ret);
+
+ ret = wifi_direct_activate();
+ ASSERT_EQ(WIFI_DIRECT_ERROR_NONE, ret);
+
+ wifi_direct_manager_mock_generate_activation_signal();
+}
+
+TEST_F(WifiDirectConnectTest, wifi_direct_accept_connection_positive)
+{
+ char mac_address[] = "aa:bb:cc:dd:ee:ff";
+ int ret;
+
+ ret = wifi_direct_set_connection_state_changed_cb(__connection_state_changed_cb, NULL);
+ ASSERT_EQ(WIFI_DIRECT_ERROR_NONE, ret);
+
+ ret = wifi_direct_set_client_ip_address_assigned_cb(__client_ip_address_assigned_cb, NULL);
+ ASSERT_EQ(WIFI_DIRECT_ERROR_NONE, ret);
+
+ wifi_direct_manager_mock_generate_connection_request_pbc_signal();
+
+ ret = wifi_direct_accept_connection(mac_address);
+ ASSERT_EQ(WIFI_DIRECT_ERROR_NONE, ret);
+
+ wifi_direct_manager_mock_generate_connection_in_progress_signal();
+ wifi_direct_manager_mock_generate_connection_rsp_with_no_error_go_signal();
+ wifi_direct_manager_mock_generate_peer_ip_assigned_signal();
+ wifi_direct_manager_mock_generate_disconnection_signal();
+
+ ret = wifi_direct_unset_connection_state_changed_cb();
+ ASSERT_EQ(WIFI_DIRECT_ERROR_NONE, ret);
+
+ ret = wifi_direct_unset_client_ip_address_assigned_cb();
+ ASSERT_EQ(WIFI_DIRECT_ERROR_NONE, ret);
+}
+
+TEST_F(WifiDirectConnectTest, wifi_direct_accept_connection_Negative1)
+{
+ int ret;
+
+ ret = wifi_direct_accept_connection(NULL);
+ ASSERT_EQ(WIFI_DIRECT_ERROR_INVALID_PARAMETER, ret);
+}
+
+TEST_F(WifiDirectConnectTest, wifi_direct_accept_connection_Negative2)
+{
+ char mac_address[] = "aa:bb:cc:dd:ee:ff";
+ int ret;
+
+ ret = wifi_direct_deactivate();
+ ASSERT_EQ(WIFI_DIRECT_ERROR_NONE, ret);
+
+ wifi_direct_manager_mock_generate_deactivation_signal();
+
+ ret = wifi_direct_accept_connection(mac_address);
+ ASSERT_EQ(WIFI_DIRECT_ERROR_NOT_PERMITTED, ret);
+
+ ret = wifi_direct_activate();
+ ASSERT_EQ(WIFI_DIRECT_ERROR_NONE, ret);
+
+ wifi_direct_manager_mock_generate_activation_signal();
+}
+
+TEST_F(WifiDirectConnectTest, wifi_direct_cancel_connection_positive)
+{
+ char mac_address[] = "aa:bb:cc:dd:ee:ff";
+ int ret;
+
+
+ ret = wifi_direct_set_connection_state_changed_cb(__connection_state_changed_cb, NULL);
+ ASSERT_EQ(WIFI_DIRECT_ERROR_NONE, ret);
+
+ ret = wifi_direct_connect(mac_address);
+ ASSERT_EQ(WIFI_DIRECT_ERROR_NONE, ret);
+
+ wifi_direct_manager_mock_generate_connection_in_progress_signal();
+
+ ret = wifi_direct_cancel_connection(mac_address);
+ ASSERT_EQ(WIFI_DIRECT_ERROR_NONE, ret);
+
+ wifi_direct_manager_mock_generate_connection_canceled_signal();
+
+ ret = wifi_direct_unset_connection_state_changed_cb();
+ ASSERT_EQ(WIFI_DIRECT_ERROR_NONE, ret);
+
+ ret = wifi_direct_unset_client_ip_address_assigned_cb();
+ ASSERT_EQ(WIFI_DIRECT_ERROR_NONE, ret);
+}
+
+TEST_F(WifiDirectConnectTest, wifi_direct_cancel_connection_Negative1)
+{
+ int ret;
+
+ ret = wifi_direct_cancel_connection(NULL);
+ ASSERT_EQ(WIFI_DIRECT_ERROR_INVALID_PARAMETER, ret);
+}
+
+TEST_F(WifiDirectConnectTest, wifi_direct_cancel_connection_Negative2)
+{
+ char mac_address[] = "aa:bb:cc:dd:ee:ff";
+ int ret;
+
+ ret = wifi_direct_deactivate();
+ ASSERT_EQ(WIFI_DIRECT_ERROR_NONE, ret);
+
+ wifi_direct_manager_mock_generate_deactivation_signal();
+
+ ret = wifi_direct_cancel_connection(mac_address);
+ ASSERT_EQ(WIFI_DIRECT_ERROR_NOT_PERMITTED, ret);
+
+ ret = wifi_direct_activate();
+ ASSERT_EQ(WIFI_DIRECT_ERROR_NONE, ret);
+
+ wifi_direct_manager_mock_generate_activation_signal();
+}
+
+TEST_F(WifiDirectConnectTest, wifi_direct_reject_connection_positive)
+{
+ char mac_address[] = "aa:bb:cc:dd:ee:ff";
+ int ret;
+
+
+ ret = wifi_direct_set_connection_state_changed_cb(__connection_state_changed_cb, NULL);
+ ASSERT_EQ(WIFI_DIRECT_ERROR_NONE, ret);
+
+ wifi_direct_manager_mock_generate_connection_request_pbc_signal();
+
+ ret = wifi_direct_reject_connection(mac_address);
+ ASSERT_EQ(WIFI_DIRECT_ERROR_NONE, ret);
+
+ wifi_direct_manager_mock_generate_connection_canceled_signal();
+
+ ret = wifi_direct_unset_connection_state_changed_cb();
+ ASSERT_EQ(WIFI_DIRECT_ERROR_NONE, ret);
+
+ ret = wifi_direct_unset_client_ip_address_assigned_cb();
+ ASSERT_EQ(WIFI_DIRECT_ERROR_NONE, ret);
+}
+
+TEST_F(WifiDirectConnectTest, wifi_direct_reject_connection_Negative1)
+{
+ int ret;
+
+ ret = wifi_direct_reject_connection(NULL);
+ ASSERT_EQ(WIFI_DIRECT_ERROR_INVALID_PARAMETER, ret);
+}
+
+TEST_F(WifiDirectConnectTest, wifi_direct_reject_connection_Negative2)
+{
+ char mac_address[] = "aa:bb:cc:dd:ee:ff";
+ int ret;
+
+ ret = wifi_direct_deactivate();
+ ASSERT_EQ(WIFI_DIRECT_ERROR_NONE, ret);
+
+ wifi_direct_manager_mock_generate_deactivation_signal();
+
+ ret = wifi_direct_reject_connection(mac_address);
+ ASSERT_EQ(WIFI_DIRECT_ERROR_NOT_PERMITTED, ret);
+
+ ret = wifi_direct_activate();
+ ASSERT_EQ(WIFI_DIRECT_ERROR_NONE, ret);
+
+ wifi_direct_manager_mock_generate_activation_signal();
+}
+
+TEST_F(WifiDirectConnectTest, wifi_direct_disconnect_all_positive)
+{
+ char mac_address[] = "aa:bb:cc:dd:ee:ff";
+ int ret;
+
+ ret = wifi_direct_set_connection_state_changed_cb(__connection_state_changed_cb, NULL);
+ ASSERT_EQ(WIFI_DIRECT_ERROR_NONE, ret);
+
+ ret = wifi_direct_set_client_ip_address_assigned_cb(__client_ip_address_assigned_cb, NULL);
+ ASSERT_EQ(WIFI_DIRECT_ERROR_NONE, ret);
+
+ ret = wifi_direct_connect(mac_address);
+ ASSERT_EQ(WIFI_DIRECT_ERROR_NONE, ret);
+
+ wifi_direct_manager_mock_generate_connection_in_progress_signal();
+ wifi_direct_manager_mock_generate_connection_rsp_with_no_error_go_signal();
+ wifi_direct_manager_mock_generate_peer_ip_assigned_signal();
+
+ ret = wifi_direct_disconnect_all();
+ ASSERT_EQ(WIFI_DIRECT_ERROR_NONE, ret);
+
+ wifi_direct_manager_mock_generate_disconnection_signal();
+
+ ret = wifi_direct_unset_connection_state_changed_cb();
+ ASSERT_EQ(WIFI_DIRECT_ERROR_NONE, ret);
+
+ ret = wifi_direct_unset_client_ip_address_assigned_cb();
+ ASSERT_EQ(WIFI_DIRECT_ERROR_NONE, ret);
+}
+
+TEST_F(WifiDirectConnectTest, wifi_direct_disconnect_all_Negative)
+{
+ int ret;
+
+ ret = wifi_direct_deactivate();
+ ASSERT_EQ(WIFI_DIRECT_ERROR_NONE, ret);
+
+ wifi_direct_manager_mock_generate_deactivation_signal();
+
+ ret = wifi_direct_disconnect_all();
+ ASSERT_EQ(WIFI_DIRECT_ERROR_NOT_PERMITTED, ret);
+
+ ret = wifi_direct_activate();
+ ASSERT_EQ(WIFI_DIRECT_ERROR_NONE, ret);
+
+ wifi_direct_manager_mock_generate_activation_signal();
+}
+
+TEST_F(WifiDirectConnectTest, wifi_direct_disconnect_positive)
+{
+ char mac_address[] = "aa:bb:cc:dd:ee:ff";
+ int ret;
+
+ ret = wifi_direct_set_connection_state_changed_cb(__connection_state_changed_cb, NULL);
+ ASSERT_EQ(WIFI_DIRECT_ERROR_NONE, ret);
+
+ ret = wifi_direct_set_client_ip_address_assigned_cb(__client_ip_address_assigned_cb, NULL);
+ ASSERT_EQ(WIFI_DIRECT_ERROR_NONE, ret);
+
+ ret = wifi_direct_connect(mac_address);
+ ASSERT_EQ(WIFI_DIRECT_ERROR_NONE, ret);
+
+ wifi_direct_manager_mock_generate_connection_in_progress_signal();
+ wifi_direct_manager_mock_generate_connection_rsp_with_no_error_go_signal();
+ wifi_direct_manager_mock_generate_peer_ip_assigned_signal();
+
+ ret = wifi_direct_disconnect(mac_address);
+ ASSERT_EQ(WIFI_DIRECT_ERROR_NONE, ret);
+
+ wifi_direct_manager_mock_generate_disconnection_signal();
+
+ ret = wifi_direct_unset_connection_state_changed_cb();
+ ASSERT_EQ(WIFI_DIRECT_ERROR_NONE, ret);
+
+ ret = wifi_direct_unset_client_ip_address_assigned_cb();
+ ASSERT_EQ(WIFI_DIRECT_ERROR_NONE, ret);
+}
+
+TEST_F(WifiDirectConnectTest, wifi_direct_disconnect_Negative1)
+{
+ int ret;
+
+ ret = wifi_direct_disconnect(NULL);
+ ASSERT_EQ(WIFI_DIRECT_ERROR_INVALID_PARAMETER, ret);
+}
+
+TEST_F(WifiDirectConnectTest, wifi_direct_disconnect_Negative2)
+{
+ char mac_address[] = "aa:bb:cc:dd:ee:ff";
+ int ret;
+
+ ret = wifi_direct_deactivate();
+ ASSERT_EQ(WIFI_DIRECT_ERROR_NONE, ret);
+
+ wifi_direct_manager_mock_generate_deactivation_signal();
+
+ ret = wifi_direct_disconnect(mac_address);
+ ASSERT_EQ(WIFI_DIRECT_ERROR_NOT_PERMITTED, ret);
+
+ ret = wifi_direct_activate();
+ ASSERT_EQ(WIFI_DIRECT_ERROR_NONE, ret);
+
+ wifi_direct_manager_mock_generate_activation_signal();
+}
+
+bool wifi_direct_foreach_connected_peers_positive_cb(wifi_direct_connected_peer_info_s *peer, void *user_data)
+{
+ free(peer->device_name);
+ free(peer->mac_address);
+ free(peer->interface_address);
+ free(peer->ip_address);
+ free(peer);
+ return true;
+}
+
+TEST_F(WifiDirectConnectTest, wifi_direct_foreach_connected_peers_positive)
+{
+ char mac_address[] = "aa:bb:cc:dd:ee:ff";
+ int ret;
+
+ ret = wifi_direct_set_connection_state_changed_cb(__connection_state_changed_cb, NULL);
+ ASSERT_EQ(WIFI_DIRECT_ERROR_NONE, ret);
+
+ ret = wifi_direct_set_client_ip_address_assigned_cb(__client_ip_address_assigned_cb, NULL);
+ ASSERT_EQ(WIFI_DIRECT_ERROR_NONE, ret);
+
+ ret = wifi_direct_connect(mac_address);
+ ASSERT_EQ(WIFI_DIRECT_ERROR_NONE, ret);
+
+ wifi_direct_manager_mock_generate_connection_in_progress_signal();
+ wifi_direct_manager_mock_generate_connection_rsp_with_no_error_go_signal();
+ wifi_direct_manager_mock_generate_peer_ip_assigned_signal();
+
+ ret = wifi_direct_foreach_connected_peers(wifi_direct_foreach_connected_peers_positive_cb, NULL);
+ ASSERT_EQ(WIFI_DIRECT_ERROR_NONE, ret);
+
+ wifi_direct_manager_mock_generate_disconnection_signal();
+
+ ret = wifi_direct_unset_connection_state_changed_cb();
+ ASSERT_EQ(WIFI_DIRECT_ERROR_NONE, ret);
+
+ ret = wifi_direct_unset_client_ip_address_assigned_cb();
+ ASSERT_EQ(WIFI_DIRECT_ERROR_NONE, ret);
+}
+
+TEST_F(WifiDirectConnectTest, wifi_direct_foreach_connected_peers_Negative1)
+{
+ int ret;
+
+ ret = wifi_direct_foreach_connected_peers(NULL, NULL);
+ ASSERT_EQ(WIFI_DIRECT_ERROR_INVALID_PARAMETER, ret);
+}
+
+TEST_F(WifiDirectConnectTest, wifi_direct_foreach_connected_peers_Negative2)
+{
+ int ret;
+
+ ret = wifi_direct_deactivate();
+ ASSERT_EQ(WIFI_DIRECT_ERROR_NONE, ret);
+
+ wifi_direct_manager_mock_generate_deactivation_signal();
+
+ ret = wifi_direct_foreach_connected_peers(wifi_direct_foreach_connected_peers_positive_cb, NULL);
+ ASSERT_EQ(WIFI_DIRECT_ERROR_NOT_PERMITTED, ret);
+
+ ret = wifi_direct_activate();
+ ASSERT_EQ(WIFI_DIRECT_ERROR_NONE, ret);
+
+ wifi_direct_manager_mock_generate_activation_signal();
+}
+
+TEST_F(WifiDirectConnectTest, wifi_direct_get_connecting_peer_info_Positive)
+{
+ wifi_direct_discovered_peer_info_s *peer_info = NULL;
+ int ret;
+
+ ret = wifi_direct_set_connection_state_changed_cb(__connection_state_changed_cb, NULL);
+ ASSERT_EQ(WIFI_DIRECT_ERROR_NONE, ret);
+
+ wifi_direct_manager_mock_generate_connection_request_pbc_signal();
+
+ ret = wifi_direct_get_connecting_peer_info(&peer_info);
+ free(peer_info->device_name);
+ free(peer_info->mac_address);
+ free(peer_info->interface_address);
+ free(peer_info);
+ ASSERT_EQ(WIFI_DIRECT_ERROR_NONE, ret);
+
+
+ ret = wifi_direct_unset_connection_state_changed_cb();
+ ASSERT_EQ(WIFI_DIRECT_ERROR_NONE, ret);
+}
+
+TEST_F(WifiDirectConnectTest, wifi_direct_get_connecting_peer_info_Negative1)
+{
+ int ret;
+
+ ret = wifi_direct_get_connecting_peer_info(NULL);
+ ASSERT_EQ(WIFI_DIRECT_ERROR_INVALID_PARAMETER, ret);
+}
+
+TEST_F(WifiDirectConnectTest, wifi_direct_get_connecting_peer_info_Negative2)
+{
+ wifi_direct_discovered_peer_info_s *peer_info = NULL;
+ int ret;
+
+ ret = wifi_direct_deactivate();
+ ASSERT_EQ(WIFI_DIRECT_ERROR_NONE, ret);
+
+ wifi_direct_manager_mock_generate_deactivation_signal();
+
+ ret = wifi_direct_get_connecting_peer_info(&peer_info);
+ ASSERT_EQ(WIFI_DIRECT_ERROR_NOT_PERMITTED, ret);
+
+ ret = wifi_direct_activate();
+ ASSERT_EQ(WIFI_DIRECT_ERROR_NONE, ret);
+
+ wifi_direct_manager_mock_generate_activation_signal();
+}
+
+TEST_F(WifiDirectConnectTest, wifi_direct_set_wps_pin_Positive)
+{
+ char pin[] = {"12345678"};
+ int ret;
+
+ ret = wifi_direct_set_wps_pin(pin);
+ ASSERT_EQ(WIFI_DIRECT_ERROR_NONE, ret);
+}
+
+TEST_F(WifiDirectDiscoveryTest, wifi_direct_set_wps_pin_Negative)
+{
+ int ret;
+
+ ret = wifi_direct_set_wps_pin(NULL);
+ ASSERT_EQ(WIFI_DIRECT_ERROR_INVALID_PARAMETER, ret);
+}
+
+TEST_F(WifiDirectConnectTest, wifi_direct_get_wps_pin_Positive)
+{
+ char *pin = NULL;
+ int ret;
+
+ ret = wifi_direct_get_wps_pin(&pin);
+ free(pin);
+ ASSERT_EQ(WIFI_DIRECT_ERROR_NONE, ret);
+}
+
+TEST_F(WifiDirectConnectTest, wifi_direct_get_wps_pin_Negative)
+{
+ int ret;
+
+ ret = wifi_direct_get_wps_pin(NULL);
+ ASSERT_EQ(WIFI_DIRECT_ERROR_INVALID_PARAMETER, ret);
+}
+
+int main(int argc, char **argv)
+{
+ ::testing::InitGoogleTest(&argc, argv);
+ return RUN_ALL_TESTS();
+}
--- /dev/null
+/*
+ * Copyright (c) 2020 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.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://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef __WIFI_DIRECT_DISPLAY_H__
+#define __WIFI_DIRECT_DISPLAY_H__
+
+namespace WifiDirectManagerNamespace {
+
+class WifiDirectDisplay {
+public:
+ WifiDirectDisplay() :
+ type_(3),
+ port_(554),
+ availability_(1),
+ hdcp_(1),
+ throughput_(54)
+ {};
+ int getType() {return type_;};
+ void setType(int type) {type_ = type;};
+ int getPort() {return port_;};
+ void setPort(int port) {port_ = port;};
+ int getAvailability() {return availability_;};
+ void setAvailability(int availability) {availability_ = availability;};
+ int getHdcp() {return hdcp_;};
+ void setHdcp(int hdcp) {hdcp_ = hdcp;};
+ int getThroughput() {return throughput_;};
+ void setThroughput(int throughput) {throughput_ = throughput;};
+private:
+ int type_;
+ int port_;
+ int availability_;
+ int hdcp_;
+ int throughput_;
+};
+
+}
+
+#endif /* __WIFI_DIRECT_DISPLAY_H__ */
--- /dev/null
+/*
+ * Copyright (c) 2020 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.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://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef __WIFI_DIRECT_ERROR_H__
+#define __WIFI_DIRECT_ERROR_H__
+
+#include <glib.h>
+#include <gio/gio.h>
+
+namespace WifiDirectManagerNamespace {
+
+class WifiDirectError {
+public:
+ WifiDirectError();
+ ~WifiDirectError();
+ GError *InvaildParameter(void);
+ GError *NotPermitted(void);
+ GError *OperationFailed(void);
+};
+
+}
+
+#endif /* __WIFI_DIRECT_STATE_H__ */
--- /dev/null
+/*
+ * Copyright (c) 2020 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.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://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef __WIFI_DIRECT_GROUP_H__
+#define __WIFI_DIRECT_GROUP_H__
+
+namespace WifiDirectManagerNamespace {
+
+#define WFD_GROUP_FLAG_NONE 0
+#define WFD_GROUP_FLAG_PERSISTENT 1
+#define WFD_GROUP_FLAG_AUTONOMOUS 2
+
+#define WFD_DEV_ROLE_NONE 0
+#define WFD_DEV_ROLE_GC 1
+#define WFD_DEV_ROLE_GO 2
+
+class WifiDirectGroup {
+public:
+ WifiDirectGroup() :
+ flag_(WFD_GROUP_FLAG_NONE),
+ role_(0),
+ member_cnt_(0),
+ op_channel_(2412),
+ iface_name_("wlan0"),
+ ip_addr_("192.168.0.1"),
+ subnet_mask_("255.255.255.0"),
+ gateway_addr_("192.168.0.1"),
+ passphrase_("ABCDEFG")
+ {};
+ void setRole(int role) { role_ = role;};
+ int getRole() {return role_;};
+ void setFlag(int flag) {flag_ = flag_ | flag;};
+ int getFlag() {return flag_;};
+ int getOperatingChannel() {return op_channel_;};
+ std::string getIfaceName() {return this->iface_name_;}
+ std::string getIpAddr() {return this->ip_addr_;}
+ std::string getSubnetMask() {return this->subnet_mask_;}
+ std::string getGatewayAddr() {return this->gateway_addr_;}
+ std::string getPassphrase() {return this->passphrase_;}
+private:
+ int flag_;
+ int role_;
+ int member_cnt_;
+ int op_channel_;
+ std::string iface_name_;
+ std::string ip_addr_;
+ std::string subnet_mask_;
+ std::string gateway_addr_;
+ std::string passphrase_;
+};
+
+}
+
+#endif /* __WIFI_DIRECT_PEER_H__ */
--- /dev/null
+/*
+ * Copyright (c) 2020 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.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://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef __WIFI_DIRECT_MANAGER_H__
+#define __WIFI_DIRECT_MANAGER_H__
+
+#include <map>
+#include <string>
+
+#include <glib.h>
+#include <gio/gio.h>
+
+#include "WifiDirectDisplay.h"
+#include "WifiDirectService.h"
+#include "WifiDirectSetting.h"
+#include "WifiDirectPeer.h"
+#include "WifiDirectGroup.h"
+#include "WifiDirectError.h"
+#include "WifiDirectState.h"
+#include "WifiDirectMethod.h"
+
+#define WFD_WPS_MODE_PBC 0x1
+#define WFD_WPS_MODE_DISPLAY 0x2
+#define WFD_WPS_MODE_KEYPAD 0x4
+
+#define WFD_SCAN_MODE_NONE 0x0
+#define WFD_SCAN_MODE_ACTIVE 0x1
+#define WFD_SCAN_MODE_PASSIVE 0x2
+
+/**
+ * Wi-Fi Direct connection state
+ */
+typedef enum {
+ WFD_EVENT_CONNECTION_REQ, /**< Connection is requested */
+ WFD_EVENT_CONNECTION_WPS_REQ, /**< WPS is requested */
+ WFD_EVENT_CONNECTION_IN_PROGRESS, /**< Connection in progress */
+ WFD_EVENT_CONNECTION_RSP, /**< Connected */
+ WFD_EVENT_DISASSOCIATION_IND, /**< Disconnected by remote Group Client */
+ WFD_EVENT_DISCONNECTION_RSP, /**< Disconnected by local device */
+ WFD_EVENT_DISCONNECTION_IND, /**< Disconnected by remote Group Owner */
+ WFD_EVENT_GROUP_CREATED, /**< Group is created */
+ WFD_EVENT_GROUP_DESTROYED, /**< Group is destroyed */
+} wfd_connection_event_e;
+
+namespace WifiDirectManagerNamespace {
+
+class WifiDirectManager {
+public:
+ WifiDirectManager();
+ ~WifiDirectManager();
+ GVariant *callMethod(const gchar *method_name,
+ GVariant *parameters,
+ GError **error);
+ void setState(const WifiDirectState state);
+ WifiDirectState getState() {return state_;};
+ int getScanMode() {return scan_mode_;};
+
+ GError *startDiscovery(int mode, int timeout,
+ const char* type, int channel, int frequency);
+ GError *stopDiscovery();
+ GError *createGroup(const char *ssid);
+ GError *destroyGroup();
+ GError *isGroupOwner(gboolean *is_group_owner);
+ GError *isAutoGroup(gboolean *is_auto_group);
+
+ GError *getMacAddress(std::string &mac_addr);
+ GError *setGoIntent(int go_intent);
+ GError *getGoIntent(int *go_intent);
+ GError *setMaxClient(int max_client);
+ GError *getMaxClient(int *max_client);
+ GError *getOperatingChannel(int *channel);
+ GError *ActivatePushbutton();
+ GError *GetSupportedWpsMode(int *supported_wps_mode);
+ GError *GetLocalWpsMode(int *wps_mode);
+ GError *setRequestWpsMode(int wps_mode);
+ GError *GetRequestWpsMode(int *wps_mode);
+ GError *setDeviceName(std::string device_name);
+ GError *getDeviceName(std::string &device_name);
+ GError *getInterfaceName(std::string &iface_name);
+ GError *getIpAddr(std::string &ip_addr);
+ GError *getSubnetMask(std::string &subnet_mask);
+ GError *getGatewayAddr(std::string &gateway_addr);
+
+ GError *enablePersistentGroup(gboolean enable);
+ GError *isPersistentGruopEnabled(gboolean *enable);
+
+ GError *getPersistentGroup(GVariant **group);
+ GError *removePersistentGroup(void);
+
+ GError *registerService(int service_type, std::string &info, int *service_id);
+ GError *deregisterService(int service_id);
+ GError *setPassphrase(std::string &passphrase);
+ GError *getPassphrase(std::string &passphrase);
+ GError *initDisplay(void);
+ GError *deinitDisplay(void);
+ GError *setConfig(int type, int port, int hdcp);
+ GError *getConfig(int *type, int *port, int *hdcp);
+ GError *setAvailiability(int availability);
+ GError *getAvailiability(int &availability);
+ GError *getPeerType(std::string &mac_addr, int *type);
+ GError *getPeerAvailability(std::string &mac_addr, int *availability);
+ GError *getPeerHdcp(std::string &mac_addr, int *hdcp);
+ GError *getPeerPort(std::string &mac_addr, int *port);
+ GError *getPeerThroughput(std::string &mac_addr, int *throuput);
+ GError *getPeerRssi(std::string &mac_addr, int *rssi);
+ GError *setSessionTimer(int second);
+ GError *getSessionTimer(int *second);
+ GError *setAutoGruopRemove(bool remove);
+ GError *addVsie(int frame_id, std::string &vsie);
+ GError *getVsie(int frame_id, std::string &vsie);
+ GError *removeVsie(int frame_id, std::string &vsie);
+ GError *getPeerVsie(std::string &mac_addr, std::string &vsie);
+ GError *setWpsConfigMethod(int wps_method);
+ GError *getWpsConfigMethod(int &wps_method);
+ GError *removePersistentDevice(std::string &mac_addr);
+ GError *removeAllPersistentDevice(void);
+ GError *connect(std::string &mac_addr);
+ GError *acceptConnection(std::string &mac_addr);
+ GError *cancelConnection(std::string &mac_addr);
+ GError *rejectConnection(std::string &mac_addr);
+ GError *disconnectAll(void);
+ GError *disconnect(std::string &mac_addr);
+ GError *getConnectedPeers(GVariant **ret);
+ GError *GetConnectingPeer(GVariant **ret);
+
+ GVariant *getPeerInfoGvariant(void);
+ GVariant *getDiscoveredPeersGvariant(void);
+
+ GVariant *activated(void);
+ GVariant *deactivated(void);
+
+ GVariant *peerFound(void);
+ GVariant *peerLost(void);
+
+ GVariant *connectionInProgress(void);
+ GVariant *connectionRspWithNoErrorGO(void);
+ GVariant *peerIpAssigned(void);
+ GVariant *disconnection(void);
+ GVariant *connectionRequestPbc(void);
+ GVariant *connectionCanceled(void);
+
+private:
+ WifiDirectError error_handler_;
+ WifiDirectSetting setting_;
+ WifiDirectState state_;
+ WifiDirectPeer peer_;
+ WifiDirectGroup *group_;
+ WifiDirectDisplay display_info_;
+ int config_methods_;
+ int wps_mode_;
+ int req_wps_mode_;
+ int scan_mode_;
+ int session_timer_;
+ bool auto_group_remove_;
+ gboolean persistent_gruop_enabled_;
+ std::string mac_address_;
+ std::string passphrase_;
+ std::map<std::string , WifiDirectMethod *> method_map_;
+ std::map<int, WifiDirectService *> service_map_;
+ gboolean isNotDiscoverable();
+};
+
+}
+
+#endif /* __WIFI_DIRECT_MANAGER_H__ */
--- /dev/null
+/*
+ * Copyright (c) 2020 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.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://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef __WIFI_DIRECT_METHOD_H__
+#define __WIFI_DIRECT_METHOD_H__
+
+#include <string>
+
+#include <glib.h>
+#include <gio/gio.h>
+
+namespace WifiDirectManagerNamespace {
+
+class WifiDirectMethod {
+public:
+ virtual ~WifiDirectMethod() {};
+ virtual GVariant *handleMethod(GVariant *parameters, GError **error) = 0;
+};
+
+}
+
+#endif /* __WIFI_DIRECT_METHOD_H__ */
--- /dev/null
+/*
+ * Copyright (c) 2020 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.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://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef __WIFI_DIRECT_PEER_H__
+#define __WIFI_DIRECT_PEER_H__
+
+#include <stdbool.h>
+#include <string>
+#include <glib.h>
+
+#include "WifiDirectDisplay.h"
+
+
+#define WFD_OEM_WPS_MODE_PBC 0x1
+#define WFD_OEM_WPS_MODE_DISPLAY 0x2
+#define WFD_OEM_WPS_MODE_KEYPAD 0x4
+#define WFD_OEM_WPS_MODE_P2PS 0x8
+
+#define WFD_OEM_DEV_ROLE_NONE 0
+#define WFD_OEM_DEV_ROLE_GC 1
+#define WFD_OEM_DEV_ROLE_GO 2
+
+#define WFD_OEM_GROUP_FLAG_GROUP_OWNER 0x1
+#define WFD_OEM_GROUP_FLAG_PERSISTENT_GROUP 0x2
+
+#define MACADDR_LEN 6
+#define IPADDR_LEN 4
+
+namespace WifiDirectManagerNamespace {
+
+class WifiDirectPeer {
+public:
+ WifiDirectPeer() :
+ device_addr_{0xaa, 0xbb, 0xcc, 0xdd, 0xee, 0xff},
+ iface_addr_{0xaa, 0xbb, 0xcc, 0xdd, 0xef, 0xff},
+ go_addr_{0x11, 0x22, 0x33, 0x44, 0x55, 0x66},
+ config_methods_(WFD_OEM_WPS_MODE_PBC),
+ dev_flag_(0x25),
+ group_flag_(0x0),
+ dev_role_(WFD_OEM_DEV_ROLE_NONE),
+ pri_dev_type_(10),
+ sec_dev_type_(1),
+ ip_addr_{192, 168, 49, 100},
+ ip_addr_mask_{255, 255, 255, 0},
+ ip_addr_go_{192, 168, 49, 1},
+ channel_(81),
+ group_freq_(2412),
+ is_wfd_device_(true),
+ rssi_(-42),
+ vsie_("TestVsie")
+ {};
+
+ GVariant *getPeerGvariant();
+ GVariantBuilder *getPeerGvariantBuilder();
+ WifiDirectDisplay getDisplay_info() {return display_info_;};
+ int getRssi() {return rssi_;};
+ std::string getVsie() {return vsie_;};
+ std::string getAddress() {return address_;};
+
+private:
+ const std::string device_name_ = "Test";
+ const std::string address_ = "aa:bb:cc:dd:ee:ff";
+ const unsigned char device_addr_[MACADDR_LEN];
+ const unsigned char iface_addr_[MACADDR_LEN];
+ const unsigned char go_addr_[MACADDR_LEN];
+ const int config_methods_;
+ const int dev_flag_;
+ const int group_flag_;
+ const int dev_role_;
+ const unsigned char pri_dev_type_;
+ const unsigned char sec_dev_type_;
+ const unsigned char ip_addr_[IPADDR_LEN];
+ const unsigned char ip_addr_mask_[IPADDR_LEN];
+ const unsigned char ip_addr_go_[IPADDR_LEN];
+ const int channel_;
+ const int group_freq_;
+ const bool is_wfd_device_;
+ const int rssi_;
+ WifiDirectDisplay display_info_;
+ std::string vsie_;
+
+ GVariant* packGVariantAy(const unsigned char *src, int size);
+};
+
+}
+
+#endif /* __WIFI_DIRECT_PEER_H__ */
--- /dev/null
+/*
+ * Copyright (c) 2020 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.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://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef __WIFI_DIRECT_SERVICE_H__
+#define __WIFI_DIRECT_SERVICE_H__
+
+namespace WifiDirectManagerNamespace {
+
+class WifiDirectService {
+public:
+ WifiDirectService(std::string &info) :
+ id_(7),
+ info_(info)
+ {};
+ int getId() {return id_;};
+private:
+ int id_;
+ std::string info_;
+};
+
+}
+
+#endif /* __WIFI_DIRECT_SERVICE_H__ */
--- /dev/null
+/*
+ * Copyright (c) 2020 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.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://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef __WIFI_DIRECT_SETTING_H__
+#define __WIFI_DIRECT_SETTING_H__
+
+namespace WifiDirectManagerNamespace {
+
+class WifiDirectSetting {
+public:
+ WifiDirectSetting() :
+ go_intent_(7),
+ max_client_(10),
+ device_name_("TIZEN")
+ {};
+ void setGoIntent(int go_intent) { go_intent_ = go_intent;};
+ int getGoIntent() {return go_intent_;};
+ void setMaxClient(int max_client) { max_client_ = max_client;};
+ int getMaxClient() {return max_client_;};
+ void setDeviceName(std::string device_name) { device_name_ = device_name;};
+ std::string getDeviceName() {return device_name_;};
+private:
+ int go_intent_;
+ int max_client_;
+ std::string device_name_;
+};
+
+}
+
+#endif /* __WIFI_DIRECT_SETTING_H__ */
--- /dev/null
+/*
+ * Copyright (c) 2020 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.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://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef __WIFI_DIRECT_SIGNAL_GENERATOR_H__
+#define __WIFI_DIRECT_SIGNAL_GENERATOR_H__
+
+#include <string>
+
+#include <glib.h>
+#include <gio/gio.h>
+
+namespace WifiDirectManagerNamespace {
+
+class WifiDirectSignal {
+public:
+ WifiDirectSignal(guint id,
+ const gchar *member,
+ GDBusSignalCallback callback,
+ gpointer user_data) : id_(0), member_(std::string(member)), callback_(callback), user_data_(user_data) {}
+
+ std::string getName();
+ void generate(GVariant *parameters);
+private:
+ unsigned int id_;
+ std::string member_;
+ GDBusSignalCallback callback_;
+ gpointer user_data_;
+};
+
+}
+
+#endif /* __WIFI_DIRECT_SIGNAL_GENERATOR_H__ */
--- /dev/null
+/*
+ * Copyright (c) 2020 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.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://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef __WIFI_DIRECT_STATE_H__
+#define __WIFI_DIRECT_STATE_H__
+
+namespace WifiDirectManagerNamespace {
+
+enum class WifiDirectState {
+ kWifiDirectStateDeactivated, /**< Deactivated */
+ kWifiDirectStateDeactivating, /**< Deactivating */
+ kWifiDirectStateActivating, /**< Activating */
+ kWifiDirectStateActivated, /**< Activated */
+ kWifiDirectStateDiscovering, /**< Discovering */
+ kWifiDirectStateConnecting, /**< Connecting */
+ kWifiDirectStateDisconnecting, /**< Disconnecting */
+ kWifiDirectStateConnected, /**< Connected */
+ kWifiDirectStateGroupowner /**< Group owner */
+};
+
+}
+
+#endif /* __WIFI_DIRECT_STATE_H__ */
--- /dev/null
+/*
+ * Copyright (c) 2020 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.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://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef __MOCK_GDBUS_H__
+#define __MOCK_GDBUS_H__
+
+#include <stdbool.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+void mock_gdbus_gdbus_sync_enable(bool value);
+void mock_gdbus_gdbus_call_sync_enable(bool value);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __MOCK_GDBUS_H__ */
--- /dev/null
+/*
+ * Copyright (c) 2020 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.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://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef __MOCK_SYSINFO_H__
+#define __MOCK_SYSINFO_H__
+
+#include <stdbool.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+void mock_sysinfo_set_up_wifi_direct(bool value);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __MOCK_SYSINFO_H__ */
--- /dev/null
+/*
+ * Copyright (c) 2020 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.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://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef __WIFI_DIRECT_MANAGER_MOCK_H__
+#define __WIFI_DIRECT_MANAGER_MOCK_H__
+
+#include <glib.h>
+#include <gio/gio.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+void wifi_direct_manager_mock_init();
+void wifi_direct_manager_mock_deinit();
+
+GVariant *wifi_direct_manager_mock_gdbus_call_sync(const gchar *method_name,
+ GVariant *parameters,
+ GError **error);
+
+void wifi_direct_manager_mock_gdbus_signal_subscribe(
+ guint id,
+ const gchar *member,
+ GDBusSignalCallback callback,
+ gpointer user_data);
+
+void wifi_direct_manager_mock_gdbus_signal_unsubscribe(guint id);
+
+void wifi_direct_manager_mock_generate_activation_signal();
+void wifi_direct_manager_mock_generate_deactivation_signal();
+void wifi_direct_manager_mock_generate_listen_started_signal();
+void wifi_direct_manager_mock_generate_discovery_started_signal();
+void wifi_direct_manager_mock_generate_discovery_finished_signal();
+void wifi_direct_manager_mock_generate_peer_found_signal();
+void wifi_direct_manager_mock_generate_peer_lost_signal();
+void wifi_direct_manager_mock_generate_created_signal();
+void wifi_direct_manager_mock_generate_destroyed_signal();
+void wifi_direct_manager_mock_generate_connection_in_progress_signal();
+void wifi_direct_manager_mock_generate_connection_rsp_with_no_error_go_signal();
+void wifi_direct_manager_mock_generate_peer_ip_assigned_signal();
+void wifi_direct_manager_mock_generate_disconnection_signal();
+void wifi_direct_manager_mock_generate_connection_request_pbc_signal();
+void wifi_direct_manager_mock_generate_connection_canceled_signal();
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __WIFI_DIRECT_MANAGER_MOCK_H__ */
--- /dev/null
+/*
+ * Copyright (c) 2020 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.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://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "wifi-direct.h"
+#include "WifiDirectError.h"
+
+using namespace WifiDirectManagerNamespace;
+
+#define WFD_MANAGER_QUARK (g_quark_from_string("wifi-direct-error-quark"))
+
+WifiDirectError::WifiDirectError()
+{
+ g_dbus_error_register_error(WFD_MANAGER_QUARK,
+ WIFI_DIRECT_ERROR_INVALID_PARAMETER,
+ "net.wifidirect.Error.InvalidParameter");
+
+
+ g_dbus_error_register_error(WFD_MANAGER_QUARK,
+ WIFI_DIRECT_ERROR_NOT_PERMITTED,
+ "net.wifidirect.Error.NotPermitted");
+
+
+ g_dbus_error_register_error(WFD_MANAGER_QUARK,
+ WIFI_DIRECT_ERROR_OPERATION_FAILED,
+ "net.wifidirect.Error.OperationFailed");
+
+
+ g_dbus_error_register_error(WFD_MANAGER_QUARK,
+ WIFI_DIRECT_ERROR_TOO_MANY_CLIENT,
+ "net.wifidirect.Error.TooManyClient");
+}
+
+WifiDirectError::~WifiDirectError()
+{
+ g_dbus_error_unregister_error(WFD_MANAGER_QUARK,
+ WIFI_DIRECT_ERROR_INVALID_PARAMETER,
+ "net.wifidirect.Error.InvalidParameter");
+
+
+ g_dbus_error_unregister_error(WFD_MANAGER_QUARK,
+ WIFI_DIRECT_ERROR_NOT_PERMITTED,
+ "net.wifidirect.Error.NotPermitted");
+
+
+ g_dbus_error_unregister_error(WFD_MANAGER_QUARK,
+ WIFI_DIRECT_ERROR_OPERATION_FAILED,
+ "net.wifidirect.Error.OperationFailed");
+
+
+ g_dbus_error_unregister_error(WFD_MANAGER_QUARK,
+ WIFI_DIRECT_ERROR_TOO_MANY_CLIENT,
+ "net.wifidirect.Error.TooManyClient");
+}
+
+GError *WifiDirectError::InvaildParameter(void)
+{
+ return g_dbus_error_new_for_dbus_error(
+ "net.wifidirect.Error.InvalidParameter",
+ "net.wifidirect.Error.InvalidParameter");
+}
+
+GError *WifiDirectError::NotPermitted(void)
+{
+ return g_dbus_error_new_for_dbus_error(
+ "net.wifidirect.Error.NotPermitted",
+ "net.wifidirect.Error.NotPermitted");
+}
+
+GError *WifiDirectError::OperationFailed(void)
+{
+ return g_dbus_error_new_for_dbus_error(
+ "net.wifidirect.Error.OperationFailed",
+ "net.wifidirect.Error.OperationFailed");
+}
+
--- /dev/null
+/*
+ * Copyright (c) 2020 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.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://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <stdio.h>
+
+#include "wifi-direct.h"
+
+#include "WifiDirectManager.h"
+
+using namespace WifiDirectManagerNamespace;
+
+class AddClientHandler : WifiDirectMethod {
+public:
+ AddClientHandler(WifiDirectManager *mgr) : mgr_(mgr){};
+ ~AddClientHandler()
+ {
+ };
+ GVariant *handleMethod(GVariant *parameters, GError **error) override
+ {
+ *error = NULL;
+ return g_variant_new("(i)", WIFI_DIRECT_ERROR_NONE);
+ }
+ std::string getMethodName()
+ {
+ return method_name_;
+ }
+private:
+ const std::string method_name_ =
+ "AddClient";
+ WifiDirectManager *mgr_;
+};
+
+class ActivateHandler : WifiDirectMethod {
+public:
+ ActivateHandler(WifiDirectManager *mgr) : mgr_(mgr){};
+ ~ActivateHandler()
+ {
+ };
+ GVariant *handleMethod(GVariant *parameters, GError **error) override
+ {
+ *error = NULL;
+
+ return g_variant_new("(i)", WIFI_DIRECT_ERROR_NONE);
+ }
+ std::string getMethodName()
+ {
+ return method_name_;
+ }
+private:
+ const std::string method_name_ =
+ "Activate";
+ WifiDirectManager *mgr_;
+};
+
+class DeactivateHandler : WifiDirectMethod {
+public:
+ DeactivateHandler(WifiDirectManager *mgr) : mgr_(mgr){};
+ ~DeactivateHandler()
+ {
+ };
+ GVariant *handleMethod(GVariant *parameters, GError **error) override
+ {
+ *error = NULL;
+
+ return g_variant_new("(i)", WIFI_DIRECT_ERROR_NONE);
+ }
+ std::string getMethodName()
+ {
+ return method_name_;
+ }
+private:
+ const std::string method_name_ =
+ "Deactivate";
+ WifiDirectManager *mgr_;
+};
+
+class StartDiscoveryHandler : WifiDirectMethod {
+public:
+ StartDiscoveryHandler(WifiDirectManager *mgr) : mgr_(mgr){};
+ ~StartDiscoveryHandler()
+ {
+ };
+ GVariant *handleMethod(GVariant *parameters, GError **error) override
+ {
+ gboolean mode = FALSE;
+ gint32 timeout = 0;
+ gint32 channel = 0;
+ gint32 frequency = 0;
+ const gchar *type = NULL;
+ GVariantIter *iter = NULL;
+ gchar *key = NULL;
+ GVariant *var = NULL;
+ GVariant *ret = NULL;
+
+ if (g_strcmp0("(is)", g_variant_get_type_string(parameters)) != 0) {
+ g_variant_get(parameters, "(a{sv})", &iter);
+
+ while (g_variant_iter_loop(iter, "{sv}", &key, &var)) {
+ if (!g_strcmp0(key, "Mode"))
+ g_variant_get(var, "b", &mode);
+ else if (!g_strcmp0(key, "Timeout"))
+ g_variant_get(var, "i", &timeout);
+ else if (!g_strcmp0(key, "Type"))
+ g_variant_get(var, "&s", &type);
+ else if (!g_strcmp0(key, "Channel"))
+ g_variant_get(var, "i", &channel);
+ else if (!g_strcmp0(key, "Frequency"))
+ g_variant_get(var, "i", &frequency);
+ else
+ ;/* Do Nothing */
+ }
+
+ }
+ *error = mgr_->startDiscovery(mode, timeout, type, channel, frequency);
+ g_variant_iter_free(iter);
+
+ if (*error == NULL)
+ ret = g_variant_new("(i)", WIFI_DIRECT_ERROR_NONE);
+
+ return ret;
+ }
+ std::string getMethodName()
+ {
+ return method_name_;
+ }
+private:
+ const std::string method_name_ =
+ "StartDiscovery";
+ WifiDirectManager *mgr_;
+};
+
+class StopDiscoveryHandler : WifiDirectMethod {
+public:
+ StopDiscoveryHandler(WifiDirectManager *mgr) : mgr_(mgr){};
+ ~StopDiscoveryHandler()
+ {
+ };
+ GVariant *handleMethod(GVariant *parameters, GError **error) override
+ {
+ GVariant *ret = NULL;
+
+ *error = mgr_->stopDiscovery();
+ if (*error == NULL)
+ ret = g_variant_new("(i)", WIFI_DIRECT_ERROR_NONE);
+
+ return ret;
+ }
+ std::string getMethodName()
+ {
+ return method_name_;
+ }
+private:
+ const std::string method_name_ =
+ "StopDiscovery";
+ WifiDirectManager *mgr_;
+};
+
+class GetDiscoveredPeersHandler : WifiDirectMethod {
+public:
+ GetDiscoveredPeersHandler(WifiDirectManager *mgr) : mgr_(mgr){};
+ ~GetDiscoveredPeersHandler()
+ {
+ };
+ GVariant *handleMethod(GVariant *parameters, GError **error) override
+ {
+ return mgr_->getDiscoveredPeersGvariant();
+ }
+ std::string getMethodName()
+ {
+ return method_name_;
+ }
+private:
+ const std::string method_name_ =
+ "GetDiscoveredPeers";
+ WifiDirectManager *mgr_;
+};
+
+class CreateGroupHandler : WifiDirectMethod {
+public:
+ CreateGroupHandler(WifiDirectManager *mgr) : mgr_(mgr){};
+ ~CreateGroupHandler()
+ {
+ };
+ GVariant *handleMethod(GVariant *parameters, GError **error) override
+ {
+ GVariantIter *iter = NULL;
+ gchar *key = NULL;
+ GVariant *var = NULL;
+ GVariant *ret = NULL;
+ const char *ssid = NULL;
+
+ g_variant_get(parameters, "(a{sv})", &iter);
+
+ while (g_variant_iter_loop(iter, "{sv}", &key, &var)) {
+ if (!g_strcmp0(key, "ssid")) {
+ g_variant_get(var, "&s", &ssid);
+ }
+ }
+
+ *error = mgr_->createGroup(ssid);
+ if (*error == NULL)
+ ret = g_variant_new("(i)", WIFI_DIRECT_ERROR_NONE);
+
+ g_variant_iter_free(iter);
+ return ret;
+ }
+ std::string getMethodName()
+ {
+ return method_name_;
+ }
+private:
+ const std::string method_name_ =
+ "CreateGroup";
+ WifiDirectManager *mgr_;
+};
+
+class DestroyGroupHandler : WifiDirectMethod {
+public:
+ DestroyGroupHandler(WifiDirectManager *mgr) : mgr_(mgr){};
+ ~DestroyGroupHandler()
+ {
+ };
+ GVariant *handleMethod(GVariant *parameters, GError **error) override
+ {
+ GVariant *ret = NULL;
+
+ *error = mgr_->destroyGroup();
+ if (*error == NULL)
+ ret = g_variant_new("(i)", WIFI_DIRECT_ERROR_NONE);
+
+ return ret;
+ }
+ std::string getMethodName()
+ {
+ return method_name_;
+ }
+private:
+ const std::string method_name_ =
+ "DestroyGroup";
+ WifiDirectManager *mgr_;
+};
+
+class IsGroupOwnerHandler : WifiDirectMethod {
+public:
+ IsGroupOwnerHandler(WifiDirectManager *mgr) : mgr_(mgr){};
+ ~IsGroupOwnerHandler()
+ {
+ };
+ GVariant *handleMethod(GVariant *parameters, GError **error) override
+ {
+ gboolean is_group_owner;
+ GVariant *ret = NULL;
+
+ *error = mgr_->isGroupOwner(&is_group_owner);
+ if (*error == NULL)
+ ret = g_variant_new("(b)", is_group_owner);
+
+ return ret;
+ }
+ std::string getMethodName()
+ {
+ return method_name_;
+ }
+private:
+ const std::string method_name_ =
+ "IsGroupOwner";
+ WifiDirectManager *mgr_;
+};
+
+class GetMacAddressHandler : WifiDirectMethod {
+public:
+ GetMacAddressHandler(WifiDirectManager *mgr) : mgr_(mgr){};
+ ~GetMacAddressHandler()
+ {
+ };
+ GVariant *handleMethod(GVariant *parameters, GError **error) override
+ {
+ std::string mac_addr;
+ GVariant *ret = NULL;
+
+ *error = mgr_->getMacAddress(mac_addr);
+ if (*error == NULL)
+ ret = g_variant_new("(is)", WIFI_DIRECT_ERROR_NONE, mac_addr.c_str());
+
+ return ret;
+ }
+ std::string getMethodName()
+ {
+ return method_name_;
+ }
+private:
+ const std::string method_name_ =
+ "GetMacAddress";
+ WifiDirectManager *mgr_;
+};
+
+class IsAutoGroupHandler : WifiDirectMethod {
+public:
+ IsAutoGroupHandler(WifiDirectManager *mgr) : mgr_(mgr){};
+ ~IsAutoGroupHandler()
+ {
+ };
+ GVariant *handleMethod(GVariant *parameters, GError **error) override
+ {
+ gboolean is_auto_group;
+ GVariant *ret = NULL;
+
+ *error = mgr_->isGroupOwner(&is_auto_group);
+ if (*error == NULL)
+ ret = g_variant_new("(b)", is_auto_group);
+
+ return ret;
+ }
+ std::string getMethodName()
+ {
+ return method_name_;
+ }
+private:
+ const std::string method_name_ =
+ "IsAutoGroup";
+ WifiDirectManager *mgr_;
+};
+
+class SetGoIntentHandler : WifiDirectMethod {
+public:
+ SetGoIntentHandler(WifiDirectManager *mgr) : mgr_(mgr){};
+ ~SetGoIntentHandler()
+ {
+ };
+ GVariant *handleMethod(GVariant *parameters, GError **error) override
+ {
+ GVariant *ret = NULL;
+ int go_intent = 0;
+
+ g_variant_get(parameters, "(i)", &go_intent);
+
+ *error = mgr_->setGoIntent(go_intent);
+ if (*error == NULL)
+ ret = g_variant_new("(i)", WIFI_DIRECT_ERROR_NONE);
+
+ return ret;
+ }
+ std::string getMethodName()
+ {
+ return method_name_;
+ }
+private:
+ const std::string method_name_ =
+ "SetGoIntent";
+ WifiDirectManager *mgr_;
+};
+
+class GetGoIntentHandler : WifiDirectMethod {
+public:
+ GetGoIntentHandler(WifiDirectManager *mgr) : mgr_(mgr){};
+ ~GetGoIntentHandler()
+ {
+ };
+ GVariant *handleMethod(GVariant *parameters, GError **error) override
+ {
+ GVariant *ret = NULL;
+ int go_intent = 0;
+
+ *error = mgr_->getGoIntent(&go_intent);
+ if (*error == NULL)
+ ret = g_variant_new("(ii)", WIFI_DIRECT_ERROR_NONE, go_intent);
+
+ return ret;
+ }
+ std::string getMethodName()
+ {
+ return method_name_;
+ }
+private:
+ const std::string method_name_ =
+ "GetGoIntent";
+ WifiDirectManager *mgr_;
+};
+
+class SetGoIntentPerTypeHandler : WifiDirectMethod {
+public:
+ SetGoIntentPerTypeHandler(WifiDirectManager *mgr) : mgr_(mgr){};
+ ~SetGoIntentPerTypeHandler()
+ {
+ };
+ GVariant *handleMethod(GVariant *parameters, GError **error) override
+ {
+ return g_variant_new("(i)", WIFI_DIRECT_ERROR_NONE);
+ }
+ std::string getMethodName()
+ {
+ return method_name_;
+ }
+private:
+ const std::string method_name_ =
+ "SetGoIntentPerType";
+ WifiDirectManager *mgr_;
+};
+
+class GetGoIntentPerTypeHandler : WifiDirectMethod {
+public:
+ GetGoIntentPerTypeHandler(WifiDirectManager *mgr) : mgr_(mgr){};
+ ~GetGoIntentPerTypeHandler()
+ {
+ };
+ GVariant *handleMethod(GVariant *parameters, GError **error) override
+ {
+ return g_variant_new("(ii)", WIFI_DIRECT_ERROR_NONE, 7);
+ }
+ std::string getMethodName()
+ {
+ return method_name_;
+ }
+private:
+ const std::string method_name_ =
+ "GetGoIntentPerType";
+ WifiDirectManager *mgr_;
+};
+
+class SetMaxClientHandler : WifiDirectMethod {
+public:
+ SetMaxClientHandler(WifiDirectManager *mgr) : mgr_(mgr){};
+ ~SetMaxClientHandler()
+ {
+ };
+ GVariant *handleMethod(GVariant *parameters, GError **error) override
+ {
+ GVariant *ret = NULL;
+ int max_client;
+
+ g_variant_get(parameters, "(i)", &max_client);
+ *error = mgr_->setMaxClient(max_client);
+ if (*error == NULL)
+ ret = g_variant_new("(i)", WIFI_DIRECT_ERROR_NONE);
+
+ return ret;
+ }
+ std::string getMethodName()
+ {
+ return method_name_;
+ }
+private:
+ const std::string method_name_ =
+ "SetMaxClient";
+ WifiDirectManager *mgr_;
+};
+
+class GetMaxClientHandler : WifiDirectMethod {
+public:
+ GetMaxClientHandler(WifiDirectManager *mgr) : mgr_(mgr){};
+ ~GetMaxClientHandler()
+ {
+ };
+ GVariant *handleMethod(GVariant *parameters, GError **error) override
+ {
+ GVariant *ret = NULL;
+ int max_client;
+
+ *error = mgr_->getMaxClient(&max_client);
+ if (*error == NULL)
+ ret = g_variant_new("(ii)", WIFI_DIRECT_ERROR_NONE, max_client);
+
+ return ret;
+ }
+ std::string getMethodName()
+ {
+ return method_name_;
+ }
+private:
+ const std::string method_name_ =
+ "GetMaxClient";
+ WifiDirectManager *mgr_;
+};
+
+class GetOperatingChannelHandler : WifiDirectMethod {
+public:
+ GetOperatingChannelHandler(WifiDirectManager *mgr) : mgr_(mgr){};
+ ~GetOperatingChannelHandler()
+ {
+ };
+ GVariant *handleMethod(GVariant *parameters, GError **error) override
+ {
+ GVariant *ret = NULL;
+ int channel = 0;
+
+ *error = mgr_->getOperatingChannel(&channel);
+ if (*error == NULL)
+ ret = g_variant_new("(ii)", WIFI_DIRECT_ERROR_NONE, channel);
+
+ return ret;
+ }
+ std::string getMethodName()
+ {
+ return method_name_;
+ }
+private:
+ const std::string method_name_ =
+ "GetOperatingChannel";
+ WifiDirectManager *mgr_;
+};
+
+class ActivatePushButtonHandler : WifiDirectMethod {
+public:
+ ActivatePushButtonHandler(WifiDirectManager *mgr) : mgr_(mgr){};
+ ~ActivatePushButtonHandler()
+ {
+ };
+ GVariant *handleMethod(GVariant *parameters, GError **error) override
+ {
+ GVariant *ret = NULL;
+
+ *error = mgr_->ActivatePushbutton();
+ if (*error == NULL)
+ ret = g_variant_new("(i)", WIFI_DIRECT_ERROR_NONE);
+
+ return ret;
+ }
+ std::string getMethodName()
+ {
+ return method_name_;
+ }
+private:
+ const std::string method_name_ =
+ "ActivatePushButton";
+ WifiDirectManager *mgr_;
+};
+
+class GetSupportedWpsModeHandler : WifiDirectMethod {
+public:
+ GetSupportedWpsModeHandler(WifiDirectManager *mgr) : mgr_(mgr){};
+ ~GetSupportedWpsModeHandler()
+ {
+ };
+ GVariant *handleMethod(GVariant *parameters, GError **error) override
+ {
+ int supported_wps_mode;
+ mgr_->GetSupportedWpsMode(&supported_wps_mode);
+
+ return g_variant_new("(ii)", WIFI_DIRECT_ERROR_NONE, supported_wps_mode);
+ }
+ std::string getMethodName()
+ {
+ return method_name_;
+ }
+private:
+ const std::string method_name_ =
+ "GetSupportedWpsMode";
+ WifiDirectManager *mgr_;
+};
+
+class GetLocalWpsModeHandler : WifiDirectMethod {
+public:
+ GetLocalWpsModeHandler(WifiDirectManager *mgr) : mgr_(mgr){};
+ ~GetLocalWpsModeHandler()
+ {
+ };
+ GVariant *handleMethod(GVariant *parameters, GError **error) override
+ {
+ int wps_mode;
+ mgr_->GetLocalWpsMode(&wps_mode);
+
+ return g_variant_new("(ii)", WIFI_DIRECT_ERROR_NONE, wps_mode);
+ }
+ std::string getMethodName()
+ {
+ return method_name_;
+ }
+private:
+ const std::string method_name_ =
+ "GetLocalWpsMode";
+ WifiDirectManager *mgr_;
+};
+
+class SetReqWpsModeHandler : WifiDirectMethod {
+public:
+ SetReqWpsModeHandler(WifiDirectManager *mgr) : mgr_(mgr){};
+ ~SetReqWpsModeHandler()
+ {
+ };
+ GVariant *handleMethod(GVariant *parameters, GError **error) override
+ {
+ int wps_mode;
+
+ g_variant_get(parameters, "(i)", &wps_mode);
+
+ mgr_->setRequestWpsMode(wps_mode);
+
+ return g_variant_new("(i)", WIFI_DIRECT_ERROR_NONE);
+ }
+ std::string getMethodName()
+ {
+ return method_name_;
+ }
+private:
+ const std::string method_name_ =
+ "SetReqWpsMode";
+ WifiDirectManager *mgr_;
+};
+
+class GetReqWpsModeHandler : WifiDirectMethod {
+public:
+ GetReqWpsModeHandler(WifiDirectManager *mgr) : mgr_(mgr){};
+ ~GetReqWpsModeHandler()
+ {
+ };
+ GVariant *handleMethod(GVariant *parameters, GError **error) override
+ {
+ int wps_mode;
+
+ mgr_->GetRequestWpsMode(&wps_mode);
+
+ return g_variant_new("(ii)", WIFI_DIRECT_ERROR_NONE, wps_mode);
+ }
+ std::string getMethodName()
+ {
+ return method_name_;
+ }
+private:
+ const std::string method_name_ =
+ "GetReqWpsMode";
+ WifiDirectManager *mgr_;
+};
+
+class GetDeviceNameHandler : WifiDirectMethod {
+public:
+ GetDeviceNameHandler(WifiDirectManager *mgr) : mgr_(mgr){};
+ ~GetDeviceNameHandler()
+ {
+ };
+ GVariant *handleMethod(GVariant *parameters, GError **error) override
+ {
+ std::string device_name;
+
+ mgr_->getDeviceName(device_name);
+
+ return g_variant_new("(is)", WIFI_DIRECT_ERROR_NONE, device_name.c_str());
+ }
+ std::string getMethodName()
+ {
+ return method_name_;
+ }
+private:
+ const std::string method_name_ =
+ "GetDeviceName";
+ WifiDirectManager *mgr_;
+};
+
+class SetDeviceNameHandler : WifiDirectMethod {
+public:
+ SetDeviceNameHandler(WifiDirectManager *mgr) : mgr_(mgr){};
+ ~SetDeviceNameHandler()
+ {
+ };
+ GVariant *handleMethod(GVariant *parameters, GError **error) override
+ {
+ const char *device_name = NULL;
+
+ g_variant_get(parameters, "(&s)", &device_name);
+
+ mgr_->setDeviceName(std::string(device_name));
+
+ return g_variant_new("(i)", WIFI_DIRECT_ERROR_NONE);
+ }
+ std::string getMethodName()
+ {
+ return method_name_;
+ }
+private:
+ const std::string method_name_ =
+ "SetDeviceName";
+ WifiDirectManager *mgr_;
+};
+
+class GetInterfaceNameHandler : WifiDirectMethod {
+public:
+ GetInterfaceNameHandler(WifiDirectManager *mgr) : mgr_(mgr){};
+ ~GetInterfaceNameHandler()
+ {
+ };
+ GVariant *handleMethod(GVariant *parameters, GError **error) override
+ {
+ GVariant *ret = NULL;
+ std::string iface_name;
+
+ *error = mgr_->getInterfaceName(iface_name);
+ if (*error == NULL)
+ ret = g_variant_new("(is)", WIFI_DIRECT_ERROR_NONE, iface_name.c_str());
+
+ return ret;
+ }
+ std::string getMethodName()
+ {
+ return method_name_;
+ }
+private:
+ const std::string method_name_ =
+ "GetInterfaceName";
+ WifiDirectManager *mgr_;
+};
+
+class GetIPAddressHandler : WifiDirectMethod {
+public:
+ GetIPAddressHandler(WifiDirectManager *mgr) : mgr_(mgr){};
+ ~GetIPAddressHandler()
+ {
+ };
+ GVariant *handleMethod(GVariant *parameters, GError **error) override
+ {
+ GVariant *ret = NULL;
+ std::string ip_address;
+
+ *error = mgr_->getIpAddr(ip_address);
+ if (*error == NULL)
+ ret = g_variant_new("(is)", WIFI_DIRECT_ERROR_NONE, ip_address.c_str());
+
+ return ret;
+ }
+ std::string getMethodName()
+ {
+ return method_name_;
+ }
+private:
+ const std::string method_name_ =
+ "GetIPAddress";
+ WifiDirectManager *mgr_;
+};
+
+class GetSubnetMaskHandler : WifiDirectMethod {
+public:
+ GetSubnetMaskHandler(WifiDirectManager *mgr) : mgr_(mgr){};
+ ~GetSubnetMaskHandler()
+ {
+ };
+ GVariant *handleMethod(GVariant *parameters, GError **error) override
+ {
+ GVariant *ret = NULL;
+ std::string subnet_mask;
+
+ *error = mgr_->getSubnetMask(subnet_mask);
+ if (*error == NULL)
+ ret = g_variant_new("(is)", WIFI_DIRECT_ERROR_NONE, subnet_mask.c_str());
+
+ return ret;
+ }
+ std::string getMethodName()
+ {
+ return method_name_;
+ }
+private:
+ const std::string method_name_ =
+ "GetSubnetMask";
+ WifiDirectManager *mgr_;
+};
+
+class GetGatewayHandler : WifiDirectMethod {
+public:
+ GetGatewayHandler(WifiDirectManager *mgr) : mgr_(mgr){};
+ ~GetGatewayHandler()
+ {
+ };
+ GVariant *handleMethod(GVariant *parameters, GError **error) override
+ {
+ GVariant *ret = NULL;
+ std::string gateway_address;
+
+ *error = mgr_->getGatewayAddr(gateway_address);
+ if (*error == NULL)
+ ret = g_variant_new("(is)", WIFI_DIRECT_ERROR_NONE, gateway_address.c_str());
+
+ return ret;
+ }
+ std::string getMethodName()
+ {
+ return method_name_;
+ }
+private:
+ const std::string method_name_ =
+ "GetGateway";
+ WifiDirectManager *mgr_;
+};
+
+class IsDiscoverableHandler : WifiDirectMethod {
+public:
+ IsDiscoverableHandler(WifiDirectManager *mgr) : mgr_(mgr){};
+ ~IsDiscoverableHandler()
+ {
+ };
+ GVariant *handleMethod(GVariant *parameters, GError **error) override
+ {
+ gboolean is_auto_group;
+
+ mgr_->isAutoGroup(&is_auto_group);
+ *error = NULL;
+
+ return g_variant_new("(b)", (mgr_->getState() == WifiDirectState::kWifiDirectStateDiscovering ||
+ is_auto_group));
+ }
+ std::string getMethodName()
+ {
+ return method_name_;
+ }
+private:
+ const std::string method_name_ =
+ "IsDiscoverable";
+ WifiDirectManager *mgr_;
+};
+
+class IsListeningOnlyHandler : WifiDirectMethod {
+public:
+ IsListeningOnlyHandler(WifiDirectManager *mgr) : mgr_(mgr){};
+ ~IsListeningOnlyHandler()
+ {
+ };
+ GVariant *handleMethod(GVariant *parameters, GError **error) override
+ {
+ *error = NULL;
+
+ return g_variant_new("(b)", (mgr_->getScanMode() == WFD_SCAN_MODE_PASSIVE));
+ }
+ std::string getMethodName()
+ {
+ return method_name_;
+ }
+private:
+ const std::string method_name_ =
+ "IsListeningOnly";
+ WifiDirectManager *mgr_;
+};
+
+class GetPrimaryDevTypeHandler : WifiDirectMethod {
+public:
+ GetPrimaryDevTypeHandler(WifiDirectManager *mgr) : mgr_(mgr){};
+ ~GetPrimaryDevTypeHandler()
+ {
+ };
+ GVariant *handleMethod(GVariant *parameters, GError **error) override
+ {
+ *error = NULL;
+
+ return g_variant_new("(ii)", WIFI_DIRECT_ERROR_NONE, 10);
+ }
+ std::string getMethodName()
+ {
+ return method_name_;
+ }
+private:
+ const std::string method_name_ =
+ "GetPrimaryDevType";
+ WifiDirectManager *mgr_;
+};
+
+class GetSecondaryDevTypeHandler : WifiDirectMethod {
+public:
+ GetSecondaryDevTypeHandler(WifiDirectManager *mgr) : mgr_(mgr){};
+ ~GetSecondaryDevTypeHandler()
+ {
+ };
+ GVariant *handleMethod(GVariant *parameters, GError **error) override
+ {
+ *error = NULL;
+
+ return g_variant_new("(ii)", WIFI_DIRECT_ERROR_NONE, 5);
+ }
+ std::string getMethodName()
+ {
+ return method_name_;
+ }
+private:
+ const std::string method_name_ =
+ "GetSecondaryDevType";
+ WifiDirectManager *mgr_;
+};
+
+class SetAutoConnectionModeHandler : WifiDirectMethod {
+public:
+ SetAutoConnectionModeHandler(WifiDirectManager *mgr) : mgr_(mgr){};
+ ~SetAutoConnectionModeHandler()
+ {
+ };
+ GVariant *handleMethod(GVariant *parameters, GError **error) override
+ {
+ *error = NULL;
+
+ return g_variant_new("(i)", WIFI_DIRECT_ERROR_NONE);
+ }
+ std::string getMethodName()
+ {
+ return method_name_;
+ }
+private:
+ const std::string method_name_ =
+ "SetAutoConnectionMode";
+ WifiDirectManager *mgr_;
+};
+
+class IsAutoConnectionModeHandler : WifiDirectMethod {
+public:
+ IsAutoConnectionModeHandler(WifiDirectManager *mgr) : mgr_(mgr){};
+ ~IsAutoConnectionModeHandler()
+ {
+ };
+ GVariant *handleMethod(GVariant *parameters, GError **error) override
+ {
+ *error = NULL;
+
+ return g_variant_new("(ib)", WIFI_DIRECT_ERROR_NONE, TRUE);
+ }
+ std::string getMethodName()
+ {
+ return method_name_;
+ }
+private:
+ const std::string method_name_ =
+ "IsAutoConnectionMode";
+ WifiDirectManager *mgr_;
+};
+
+class SetPersistentGroupEnabledHandler : WifiDirectMethod {
+public:
+ SetPersistentGroupEnabledHandler(WifiDirectManager *mgr) : mgr_(mgr){};
+ ~SetPersistentGroupEnabledHandler()
+ {
+ };
+ GVariant *handleMethod(GVariant *parameters, GError **error) override
+ {
+ gboolean enable;
+
+ g_variant_get(parameters, "(b)", &enable);
+
+ *error = mgr_->enablePersistentGroup(enable);
+
+ return g_variant_new("(i)", WIFI_DIRECT_ERROR_NONE);
+ }
+ std::string getMethodName()
+ {
+ return method_name_;
+ }
+private:
+ const std::string method_name_ =
+ "SetPersistentGroupEnabled";
+ WifiDirectManager *mgr_;
+};
+
+class IsPersistentGroupEnabledHandler : WifiDirectMethod {
+public:
+ IsPersistentGroupEnabledHandler(WifiDirectManager *mgr) : mgr_(mgr){};
+ ~IsPersistentGroupEnabledHandler()
+ {
+ };
+ GVariant *handleMethod(GVariant *parameters, GError **error) override
+ {
+ gboolean enable;
+
+ *error = mgr_->isPersistentGruopEnabled(&enable);
+
+ return g_variant_new("(ib)", WIFI_DIRECT_ERROR_NONE, enable);
+ }
+ std::string getMethodName()
+ {
+ return method_name_;
+ }
+private:
+ const std::string method_name_ =
+ "IsPersistentGroupEnabled";
+ WifiDirectManager *mgr_;
+};
+
+class GetPersistentGroupsHandler : WifiDirectMethod {
+public:
+ GetPersistentGroupsHandler(WifiDirectManager *mgr) : mgr_(mgr){};
+ ~GetPersistentGroupsHandler()
+ {
+ };
+ GVariant *handleMethod(GVariant *parameters, GError **error) override
+ {
+ GVariant *ret = NULL;
+
+ *error = mgr_->getPersistentGroup(&ret);
+
+ return ret;
+ }
+ std::string getMethodName()
+ {
+ return method_name_;
+ }
+private:
+ const std::string method_name_ =
+ "GetPersistentGroups";
+ WifiDirectManager *mgr_;
+};
+
+class RemovePersistentGroupHandler : WifiDirectMethod {
+public:
+ RemovePersistentGroupHandler(WifiDirectManager *mgr) : mgr_(mgr){};
+ ~RemovePersistentGroupHandler()
+ {
+ };
+ GVariant *handleMethod(GVariant *parameters, GError **error) override
+ {
+ GVariant *ret = NULL;
+
+ *error = mgr_->removePersistentGroup();
+ if (*error == NULL)
+ ret = g_variant_new("(i)", WIFI_DIRECT_ERROR_NONE);
+
+ return ret;
+ }
+ std::string getMethodName()
+ {
+ return method_name_;
+ }
+private:
+ const std::string method_name_ =
+ "RemovePersistentGroup";
+ WifiDirectManager *mgr_;
+};
+
+class RegisterHandler : WifiDirectMethod {
+public:
+ RegisterHandler(WifiDirectManager *mgr) : mgr_(mgr){};
+ ~RegisterHandler()
+ {
+ };
+ GVariant *handleMethod(GVariant *parameters, GError **error) override
+ {
+ GVariant *ret = NULL;
+ int service_type;
+ const char *info_str = NULL;
+ int service_id;
+
+
+ g_variant_get(parameters, "(i&s)", &service_type, &info_str);
+ std::string info = std::string(info_str);
+ *error = mgr_->registerService(service_type, info, &service_id);
+ if (*error == NULL)
+ ret = g_variant_new("(ii)", WIFI_DIRECT_ERROR_NONE, service_id);
+
+ return ret;
+ }
+ std::string getMethodName()
+ {
+ return method_name_;
+ }
+private:
+ const std::string method_name_ =
+ "Register";
+ WifiDirectManager *mgr_;
+};
+
+class DeregisterHandler : WifiDirectMethod {
+public:
+ DeregisterHandler(WifiDirectManager *mgr) : mgr_(mgr){};
+ ~DeregisterHandler()
+ {
+ };
+ GVariant *handleMethod(GVariant *parameters, GError **error) override
+ {
+ GVariant *ret = NULL;
+ int service_id;
+
+ g_variant_get(parameters, "(i)", &service_id);
+ *error = mgr_->deregisterService(service_id);
+ if (*error == NULL)
+ ret = g_variant_new("(i)", WIFI_DIRECT_ERROR_NONE);
+
+ return ret;
+ }
+ std::string getMethodName()
+ {
+ return method_name_;
+ }
+private:
+ const std::string method_name_ =
+ "Deregister";
+ WifiDirectManager *mgr_;
+};
+
+class GetPeerInfoHandler : WifiDirectMethod {
+public:
+ GetPeerInfoHandler(WifiDirectManager *mgr) : mgr_(mgr){};
+ ~GetPeerInfoHandler()
+ {
+ };
+ GVariant *handleMethod(GVariant *parameters, GError **error) override
+ {
+ *error = NULL;
+ return mgr_->getPeerInfoGvariant();
+ }
+ std::string getMethodName()
+ {
+ return method_name_;
+ }
+private:
+ const std::string method_name_ =
+ "GetPeerInfo";
+ WifiDirectManager *mgr_;
+};
+
+class SetPassphraseHandler : WifiDirectMethod {
+public:
+ SetPassphraseHandler(WifiDirectManager *mgr) : mgr_(mgr){};
+ ~SetPassphraseHandler()
+ {
+ };
+ GVariant *handleMethod(GVariant *parameters, GError **error) override
+ {
+ GVariant *ret = NULL;
+ const char *passphrase_str = NULL;
+
+ g_variant_get(parameters, "(&s)", &passphrase_str);
+
+ std::string passphrase = std::string(passphrase_str);
+ *error = mgr_->setPassphrase(passphrase);
+ if (*error == NULL)
+ ret = g_variant_new("(i)", WIFI_DIRECT_ERROR_NONE);
+ return ret;
+ }
+ std::string getMethodName()
+ {
+ return method_name_;
+ }
+private:
+ const std::string method_name_ =
+ "SetPassphrase";
+ WifiDirectManager *mgr_;
+};
+
+class GetPassphraseHandler : WifiDirectMethod {
+public:
+ GetPassphraseHandler(WifiDirectManager *mgr) : mgr_(mgr){};
+ ~GetPassphraseHandler()
+ {
+ };
+ GVariant *handleMethod(GVariant *parameters, GError **error) override
+ {
+ GVariant *ret = NULL;
+
+ std::string passphrase;
+ *error = mgr_->getPassphrase(passphrase);
+ if (*error == NULL)
+ ret = g_variant_new("(is)", WIFI_DIRECT_ERROR_NONE, passphrase.c_str());
+
+ return ret;
+ }
+ std::string getMethodName()
+ {
+ return method_name_;
+ }
+private:
+ const std::string method_name_ =
+ "GetPassphrase";
+ WifiDirectManager *mgr_;
+};
+
+class SetAutoConnectionPeerHandler : WifiDirectMethod {
+public:
+ SetAutoConnectionPeerHandler(WifiDirectManager *mgr) : mgr_(mgr){};
+ ~SetAutoConnectionPeerHandler()
+ {
+ };
+ GVariant *handleMethod(GVariant *parameters, GError **error) override
+ {
+ return g_variant_new("(i)", WIFI_DIRECT_ERROR_NONE);
+ }
+ std::string getMethodName()
+ {
+ return method_name_;
+ }
+private:
+ const std::string method_name_ =
+ "SetAutoConnectionPeer";
+ WifiDirectManager *mgr_;
+};
+
+class InitHandler : WifiDirectMethod {
+public:
+ InitHandler(WifiDirectManager *mgr) : mgr_(mgr){};
+ ~InitHandler()
+ {
+ };
+ GVariant *handleMethod(GVariant *parameters, GError **error) override
+ {
+ GVariant *ret = NULL;
+
+ *error = mgr_->initDisplay();
+ if (*error == NULL)
+ ret = g_variant_new("(i)", WIFI_DIRECT_ERROR_NONE);
+
+ return ret;
+ }
+ std::string getMethodName()
+ {
+ return method_name_;
+ }
+private:
+ const std::string method_name_ =
+ "Init";
+ WifiDirectManager *mgr_;
+};
+
+class DeinitHandler : WifiDirectMethod {
+public:
+ DeinitHandler(WifiDirectManager *mgr) : mgr_(mgr){};
+ ~DeinitHandler()
+ {
+ };
+ GVariant *handleMethod(GVariant *parameters, GError **error) override
+ {
+ GVariant *ret = NULL;
+
+ *error = mgr_->deinitDisplay();
+ if (*error == NULL)
+ ret = g_variant_new("(i)", WIFI_DIRECT_ERROR_NONE);
+
+ return ret;
+ }
+ std::string getMethodName()
+ {
+ return method_name_;
+ }
+private:
+ const std::string method_name_ =
+ "Deinit";
+ WifiDirectManager *mgr_;
+};
+
+class SetConfigHandler : WifiDirectMethod {
+public:
+ SetConfigHandler(WifiDirectManager *mgr) : mgr_(mgr){};
+ ~SetConfigHandler()
+ {
+ };
+ GVariant *handleMethod(GVariant *parameters, GError **error) override
+ {
+ GVariant *ret = NULL;
+
+ int type, port, hdcp;
+ g_variant_get(parameters, "(iii)", &type, &port, &hdcp);
+
+ *error = mgr_->setConfig(type, port, hdcp);
+ if (*error == NULL)
+ ret = g_variant_new("(i)", WIFI_DIRECT_ERROR_NONE);
+
+ return ret;
+ }
+ std::string getMethodName()
+ {
+ return method_name_;
+ }
+private:
+ const std::string method_name_ =
+ "SetConfig";
+ WifiDirectManager *mgr_;
+};
+
+class SetAvailiabilityHandler : WifiDirectMethod {
+public:
+ SetAvailiabilityHandler(WifiDirectManager *mgr) : mgr_(mgr){};
+ ~SetAvailiabilityHandler()
+ {
+ };
+ GVariant *handleMethod(GVariant *parameters, GError **error) override
+ {
+ GVariant *ret = NULL;
+
+ int availability;
+ g_variant_get(parameters, "(i)", &availability);
+
+ *error = mgr_->setAvailiability(availability);
+ if (*error == NULL)
+ ret = g_variant_new("(i)", WIFI_DIRECT_ERROR_NONE);
+
+ return ret;
+ }
+ std::string getMethodName()
+ {
+ return method_name_;
+ }
+private:
+ const std::string method_name_ =
+ "SetAvailiability";
+ WifiDirectManager *mgr_;
+};
+
+class GetConfigHandler : WifiDirectMethod {
+public:
+ GetConfigHandler(WifiDirectManager *mgr) : mgr_(mgr){};
+ ~GetConfigHandler()
+ {
+ };
+ GVariant *handleMethod(GVariant *parameters, GError **error) override
+ {
+ GVariant *ret = NULL;
+
+ int type = 0;
+ int port = 0;
+ int hdcp = 0;
+
+ *error = mgr_->getConfig(&type, &port, &hdcp);
+ if (*error == NULL)
+ ret = g_variant_new("(iiii)", WIFI_DIRECT_ERROR_NONE, type, port, hdcp);
+
+ return ret;
+ }
+ std::string getMethodName()
+ {
+ return method_name_;
+ }
+private:
+ const std::string method_name_ =
+ "GetConfig";
+ WifiDirectManager *mgr_;
+};
+
+class GetAvailiabilityHandler : WifiDirectMethod {
+public:
+ GetAvailiabilityHandler(WifiDirectManager *mgr) : mgr_(mgr){};
+ ~GetAvailiabilityHandler()
+ {
+ };
+ GVariant *handleMethod(GVariant *parameters, GError **error) override
+ {
+ GVariant *ret = NULL;
+
+ int availability = 0;
+ *error = mgr_->getAvailiability(availability);
+ if (*error == NULL)
+ ret = g_variant_new("(ii)", WIFI_DIRECT_ERROR_NONE, availability);
+
+ return ret;
+ }
+ std::string getMethodName()
+ {
+ return method_name_;
+ }
+private:
+ const std::string method_name_ =
+ "GetAvailiability";
+ WifiDirectManager *mgr_;
+};
+
+class GetPeerTypeHandler : WifiDirectMethod {
+public:
+ GetPeerTypeHandler(WifiDirectManager *mgr) : mgr_(mgr){};
+ ~GetPeerTypeHandler()
+ {
+ };
+ GVariant *handleMethod(GVariant *parameters, GError **error) override
+ {
+ GVariant *ret = NULL;
+
+ const char *mac_addr_str;
+ int type = 0;
+ g_variant_get(parameters, "(&s)", &mac_addr_str);
+ std::string mac_addr = std::string(mac_addr_str);
+
+ *error = mgr_->getPeerType(mac_addr, &type);
+ if (*error == NULL)
+ ret = g_variant_new("(ii)", WIFI_DIRECT_ERROR_NONE, type);
+
+ return ret;
+ }
+ std::string getMethodName()
+ {
+ return method_name_;
+ }
+private:
+ const std::string method_name_ =
+ "GetPeerType";
+ WifiDirectManager *mgr_;
+};
+
+class GetPeerAvailabilityHandler : WifiDirectMethod {
+public:
+ GetPeerAvailabilityHandler(WifiDirectManager *mgr) : mgr_(mgr){};
+ ~GetPeerAvailabilityHandler()
+ {
+ };
+ GVariant *handleMethod(GVariant *parameters, GError **error) override
+ {
+ GVariant *ret = NULL;
+
+ const char *mac_addr_str;
+ int availability = 0;
+ g_variant_get(parameters, "(&s)", &mac_addr_str);
+ std::string mac_addr = std::string(mac_addr_str);
+
+ *error = mgr_->getPeerAvailability(mac_addr, &availability);
+ if (*error == NULL)
+ ret = g_variant_new("(ii)", WIFI_DIRECT_ERROR_NONE, availability);
+
+ return ret;
+ }
+ std::string getMethodName()
+ {
+ return method_name_;
+ }
+private:
+ const std::string method_name_ =
+ "GetPeerAvailability";
+ WifiDirectManager *mgr_;
+};
+
+class GetPeerHdcpHandler : WifiDirectMethod {
+public:
+ GetPeerHdcpHandler(WifiDirectManager *mgr) : mgr_(mgr){};
+ ~GetPeerHdcpHandler()
+ {
+ };
+ GVariant *handleMethod(GVariant *parameters, GError **error) override
+ {
+ GVariant *ret = NULL;
+
+ const char *mac_addr_str;
+ int hdcp = 0;
+ g_variant_get(parameters, "(&s)", &mac_addr_str);
+ std::string mac_addr = std::string(mac_addr_str);
+
+ *error = mgr_->getPeerHdcp(mac_addr, &hdcp);
+ if (*error == NULL)
+ ret = g_variant_new("(ii)", WIFI_DIRECT_ERROR_NONE, hdcp);
+
+ return ret;
+ }
+ std::string getMethodName()
+ {
+ return method_name_;
+ }
+private:
+ const std::string method_name_ =
+ "GetPeerHdcp";
+ WifiDirectManager *mgr_;
+};
+
+class GetPeerPortHandler : WifiDirectMethod {
+public:
+ GetPeerPortHandler(WifiDirectManager *mgr) : mgr_(mgr){};
+ ~GetPeerPortHandler()
+ {
+ };
+ GVariant *handleMethod(GVariant *parameters, GError **error) override
+ {
+ GVariant *ret = NULL;
+
+ const char *mac_addr_str;
+ int port = 0;
+ g_variant_get(parameters, "(&s)", &mac_addr_str);
+ std::string mac_addr = std::string(mac_addr_str);
+
+ *error = mgr_->getPeerPort(mac_addr, &port);
+ if (*error == NULL)
+ ret = g_variant_new("(ii)", WIFI_DIRECT_ERROR_NONE, port);
+
+ return ret;
+ }
+ std::string getMethodName()
+ {
+ return method_name_;
+ }
+private:
+ const std::string method_name_ =
+ "GetPeerPort";
+ WifiDirectManager *mgr_;
+};
+
+class GetPeerThroughputHandler : WifiDirectMethod {
+public:
+ GetPeerThroughputHandler(WifiDirectManager *mgr) : mgr_(mgr){};
+ ~GetPeerThroughputHandler()
+ {
+ };
+ GVariant *handleMethod(GVariant *parameters, GError **error) override
+ {
+ GVariant *ret = NULL;
+
+ const char *mac_addr_str;
+ int throughput = 0;
+ g_variant_get(parameters, "(&s)", &mac_addr_str);
+ std::string mac_addr = std::string(mac_addr_str);
+
+ *error = mgr_->getPeerThroughput(mac_addr, &throughput);
+ if (*error == NULL)
+ ret = g_variant_new("(ii)", WIFI_DIRECT_ERROR_NONE, throughput);
+
+ return ret;
+ }
+ std::string getMethodName()
+ {
+ return method_name_;
+ }
+private:
+ const std::string method_name_ =
+ "GetPeerThroughput";
+ WifiDirectManager *mgr_;
+};
+
+class SetSessionTimerHandler : WifiDirectMethod {
+public:
+ SetSessionTimerHandler(WifiDirectManager *mgr) : mgr_(mgr){};
+ ~SetSessionTimerHandler()
+ {
+ };
+ GVariant *handleMethod(GVariant *parameters, GError **error) override
+ {
+ GVariant *ret = NULL;
+
+ int second = 0;
+ g_variant_get(parameters, "(i)", &second);
+
+ *error = mgr_->setSessionTimer(second);
+ if (*error == NULL)
+ ret = g_variant_new("(i)", WIFI_DIRECT_ERROR_NONE);
+
+ return ret;
+ }
+ std::string getMethodName()
+ {
+ return method_name_;
+ }
+private:
+ const std::string method_name_ =
+ "SetSessionTimer";
+ WifiDirectManager *mgr_;
+};
+
+class GetSessionTimerHandler : WifiDirectMethod {
+public:
+ GetSessionTimerHandler(WifiDirectManager *mgr) : mgr_(mgr){};
+ ~GetSessionTimerHandler()
+ {
+ };
+ GVariant *handleMethod(GVariant *parameters, GError **error) override
+ {
+ GVariant *ret = NULL;
+
+ int second = 0;
+ *error = mgr_->getSessionTimer(&second);
+ if (*error == NULL)
+ ret = g_variant_new("(ii)", WIFI_DIRECT_ERROR_NONE, second);
+
+ return ret;
+ }
+ std::string getMethodName()
+ {
+ return method_name_;
+ }
+private:
+ const std::string method_name_ =
+ "GetSessionTimer";
+ WifiDirectManager *mgr_;
+};
+
+class SetAutoGroupRemovalHandler : WifiDirectMethod {
+public:
+ SetAutoGroupRemovalHandler(WifiDirectManager *mgr) : mgr_(mgr){};
+ ~SetAutoGroupRemovalHandler()
+ {
+ };
+ GVariant *handleMethod(GVariant *parameters, GError **error) override
+ {
+ GVariant *ret = NULL;
+ gboolean remove = FALSE;
+
+ g_variant_get(parameters, "(b)", &remove);
+
+ *error = mgr_->setAutoGruopRemove(remove);
+ if (*error == NULL)
+ ret = g_variant_new("(i)", WIFI_DIRECT_ERROR_NONE);
+
+ return ret;
+ }
+ std::string getMethodName()
+ {
+ return method_name_;
+ }
+private:
+ const std::string method_name_ =
+ "SetAutoGroupRemoval";
+ WifiDirectManager *mgr_;
+};
+
+class GetPeerRssiHandler : WifiDirectMethod {
+public:
+ GetPeerRssiHandler(WifiDirectManager *mgr) : mgr_(mgr){};
+ ~GetPeerRssiHandler()
+ {
+ };
+ GVariant *handleMethod(GVariant *parameters, GError **error) override
+ {
+ GVariant *ret = NULL;
+
+ const char *mac_addr_str;
+ int rssi = 0;
+ g_variant_get(parameters, "(&s)", &mac_addr_str);
+ std::string mac_addr = std::string(mac_addr_str);
+
+ *error = mgr_->getPeerRssi(mac_addr, &rssi);
+ if (*error == NULL)
+ ret = g_variant_new("(ii)", WIFI_DIRECT_ERROR_NONE, rssi);
+
+ return ret;
+ }
+ std::string getMethodName()
+ {
+ return method_name_;
+ }
+private:
+ const std::string method_name_ =
+ "GetPeerRssi";
+ WifiDirectManager *mgr_;
+};
+
+class AddVsieHandler : WifiDirectMethod {
+public:
+ AddVsieHandler(WifiDirectManager *mgr) : mgr_(mgr){};
+ ~AddVsieHandler()
+ {
+ };
+ GVariant *handleMethod(GVariant *parameters, GError **error) override
+ {
+ GVariant *ret = NULL;
+
+ const char *vsie_str = NULL;
+ int frame_id = 0;
+ g_variant_get(parameters, "(i&s)", &frame_id, &vsie_str);
+ std::string vsie = std::string(vsie_str);
+
+ *error = mgr_->addVsie(frame_id, vsie);
+ if (*error == NULL)
+ ret = g_variant_new("(i)", WIFI_DIRECT_ERROR_NONE);
+
+ return ret;
+ }
+ std::string getMethodName()
+ {
+ return method_name_;
+ }
+private:
+ const std::string method_name_ =
+ "AddVsie";
+ WifiDirectManager *mgr_;
+};
+
+class GetVsieHandler : WifiDirectMethod {
+public:
+ GetVsieHandler(WifiDirectManager *mgr) : mgr_(mgr){};
+ ~GetVsieHandler()
+ {
+ };
+ GVariant *handleMethod(GVariant *parameters, GError **error) override
+ {
+ GVariant *ret = NULL;
+ int frame_id = 0;
+ g_variant_get(parameters, "(i)", &frame_id);
+
+ std::string vsie = std::string("");
+ *error = mgr_->getVsie(frame_id, vsie);
+ if (*error == NULL)
+ ret = g_variant_new("(is)", WIFI_DIRECT_ERROR_NONE, vsie.c_str());
+
+ return ret;
+ }
+ std::string getMethodName()
+ {
+ return method_name_;
+ }
+private:
+ const std::string method_name_ =
+ "GetVsie";
+ WifiDirectManager *mgr_;
+};
+
+class RemoveVsieHandler : WifiDirectMethod {
+public:
+ RemoveVsieHandler(WifiDirectManager *mgr) : mgr_(mgr){};
+ ~RemoveVsieHandler()
+ {
+ };
+ GVariant *handleMethod(GVariant *parameters, GError **error) override
+ {
+ GVariant *ret = NULL;
+ const char *vsie_str = NULL;
+ int frame_id = 0;
+ g_variant_get(parameters, "(i&s)", &frame_id, &vsie_str);
+ std::string vsie = std::string(vsie_str);
+
+ *error = mgr_->removeVsie(frame_id, vsie);
+ if (*error == NULL)
+ ret = g_variant_new("(i)", WIFI_DIRECT_ERROR_NONE);
+
+ return ret;
+ }
+ std::string getMethodName()
+ {
+ return method_name_;
+ }
+private:
+ const std::string method_name_ =
+ "RemoveVsie";
+ WifiDirectManager *mgr_;
+};
+
+class GetPeerVsieHandler : WifiDirectMethod {
+public:
+ GetPeerVsieHandler(WifiDirectManager *mgr) : mgr_(mgr){};
+ ~GetPeerVsieHandler()
+ {
+ };
+ GVariant *handleMethod(GVariant *parameters, GError **error) override
+ {
+ GVariant *ret = NULL;
+ const char *mac_address_str = NULL;
+ g_variant_get(parameters, "(&s)", &mac_address_str);
+ std::string mac_addr = std::string(mac_address_str);
+ std::string vsie = std::string("");
+
+ *error = mgr_->getPeerVsie(mac_addr, vsie);
+ if (*error == NULL)
+ ret = g_variant_new("(is)", WIFI_DIRECT_ERROR_NONE, vsie.c_str());
+
+ return ret;
+ }
+ std::string getMethodName()
+ {
+ return method_name_;
+ }
+private:
+ const std::string method_name_ =
+ "GetPeerVsie";
+ WifiDirectManager *mgr_;
+};
+
+class SetWpsConfigMethodHandler : WifiDirectMethod {
+public:
+ SetWpsConfigMethodHandler(WifiDirectManager *mgr) : mgr_(mgr){};
+ ~SetWpsConfigMethodHandler()
+ {
+ };
+ GVariant *handleMethod(GVariant *parameters, GError **error) override
+ {
+ GVariant *ret = NULL;
+ int wps_mode;
+ g_variant_get(parameters, "(i)", &wps_mode);
+ *error = mgr_->setWpsConfigMethod(wps_mode);
+ if (*error == NULL)
+ ret = g_variant_new("(i)", WIFI_DIRECT_ERROR_NONE);
+
+ return ret;
+ }
+ std::string getMethodName()
+ {
+ return method_name_;
+ }
+private:
+ const std::string method_name_ =
+ "SetWpsConfigMethod";
+ WifiDirectManager *mgr_;
+};
+
+class GetWpsConfigMethodHandler : WifiDirectMethod {
+public:
+ GetWpsConfigMethodHandler(WifiDirectManager *mgr) : mgr_(mgr){};
+ ~GetWpsConfigMethodHandler()
+ {
+ };
+ GVariant *handleMethod(GVariant *parameters, GError **error) override
+ {
+ GVariant *ret = NULL;
+ int wps_mode;
+ *error = mgr_->getWpsConfigMethod(wps_mode);
+ if (*error == NULL)
+ ret = g_variant_new("(ii)", WIFI_DIRECT_ERROR_NONE, wps_mode);
+
+ return ret;
+ }
+ std::string getMethodName()
+ {
+ return method_name_;
+ }
+private:
+ const std::string method_name_ =
+ "GetWpsConfigMethod";
+ WifiDirectManager *mgr_;
+};
+
+class RemovePersistentDeviceHandler : WifiDirectMethod {
+public:
+ RemovePersistentDeviceHandler(WifiDirectManager *mgr) : mgr_(mgr){};
+ ~RemovePersistentDeviceHandler()
+ {
+ };
+ GVariant *handleMethod(GVariant *parameters, GError **error) override
+ {
+ GVariant *ret = NULL;
+ const char *mac_address_str = NULL;
+ g_variant_get(parameters, "(&s)", &mac_address_str);
+ std::string mac_addr = std::string(mac_address_str);
+
+ *error = mgr_->removePersistentDevice(mac_addr);
+ if (*error == NULL)
+ ret = g_variant_new("(i)", WIFI_DIRECT_ERROR_NONE);
+
+ return ret;
+ }
+ std::string getMethodName()
+ {
+ return method_name_;
+ }
+private:
+ const std::string method_name_ =
+ "RemovePersistentDevice";
+ WifiDirectManager *mgr_;
+};
+
+class RemoveAllPersistentDeviceHandler : WifiDirectMethod {
+public:
+ RemoveAllPersistentDeviceHandler(WifiDirectManager *mgr) : mgr_(mgr){};
+ ~RemoveAllPersistentDeviceHandler()
+ {
+ };
+ GVariant *handleMethod(GVariant *parameters, GError **error) override
+ {
+ GVariant *ret = NULL;
+
+ *error = mgr_->removeAllPersistentDevice();
+ if (*error == NULL)
+ ret = g_variant_new("(i)", WIFI_DIRECT_ERROR_NONE);
+
+ return ret;
+ }
+ std::string getMethodName()
+ {
+ return method_name_;
+ }
+private:
+ const std::string method_name_ =
+ "RemoveAllPersistentDevice";
+ WifiDirectManager *mgr_;
+};
+
+class ConnectHandler : WifiDirectMethod {
+public:
+ ConnectHandler(WifiDirectManager *mgr) : mgr_(mgr){};
+ ~ConnectHandler()
+ {
+ };
+ GVariant *handleMethod(GVariant *parameters, GError **error) override
+ {
+ GVariant *ret = NULL;
+ const char *mac_address_str = NULL;
+ g_variant_get(parameters, "(&s)", &mac_address_str);
+ std::string mac_addr = std::string(mac_address_str);
+
+ *error = mgr_->connect(mac_addr);
+ if (*error == NULL)
+ ret = g_variant_new("(i)", WIFI_DIRECT_ERROR_NONE);
+
+ return ret;
+ }
+ std::string getMethodName()
+ {
+ return method_name_;
+ }
+private:
+ const std::string method_name_ =
+ "Connect";
+ WifiDirectManager *mgr_;
+};
+
+class AcceptConnectionHandler : WifiDirectMethod {
+public:
+ AcceptConnectionHandler(WifiDirectManager *mgr) : mgr_(mgr){};
+ ~AcceptConnectionHandler()
+ {
+ };
+ GVariant *handleMethod(GVariant *parameters, GError **error) override
+ {
+ GVariant *ret = NULL;
+ const char *mac_address_str = NULL;
+ g_variant_get(parameters, "(&s)", &mac_address_str);
+ std::string mac_addr = std::string(mac_address_str);
+
+ *error = mgr_->acceptConnection(mac_addr);
+ if (*error == NULL)
+ ret = g_variant_new("(i)", WIFI_DIRECT_ERROR_NONE);
+
+ return ret;
+ }
+ std::string getMethodName()
+ {
+ return method_name_;
+ }
+private:
+ const std::string method_name_ =
+ "AcceptConnection";
+ WifiDirectManager *mgr_;
+};
+
+class CancelConnectionHandler : WifiDirectMethod {
+public:
+ CancelConnectionHandler(WifiDirectManager *mgr) : mgr_(mgr){};
+ ~CancelConnectionHandler()
+ {
+ };
+ GVariant *handleMethod(GVariant *parameters, GError **error) override
+ {
+ GVariant *ret = NULL;
+ const char *mac_address_str = NULL;
+ g_variant_get(parameters, "(&s)", &mac_address_str);
+ std::string mac_addr = std::string(mac_address_str);
+
+ *error = mgr_->cancelConnection(mac_addr);
+ if (*error == NULL)
+ ret = g_variant_new("(i)", WIFI_DIRECT_ERROR_NONE);
+
+ return ret;
+ }
+ std::string getMethodName()
+ {
+ return method_name_;
+ }
+private:
+ const std::string method_name_ =
+ "CancelConnection";
+ WifiDirectManager *mgr_;
+};
+
+class RejectConnectionHandler : WifiDirectMethod {
+public:
+ RejectConnectionHandler(WifiDirectManager *mgr) : mgr_(mgr){};
+ ~RejectConnectionHandler()
+ {
+ };
+ GVariant *handleMethod(GVariant *parameters, GError **error) override
+ {
+ GVariant *ret = NULL;
+ const char *mac_address_str = NULL;
+ g_variant_get(parameters, "(&s)", &mac_address_str);
+ std::string mac_addr = std::string(mac_address_str);
+
+ *error = mgr_->rejectConnection(mac_addr);
+ if (*error == NULL)
+ ret = g_variant_new("(i)", WIFI_DIRECT_ERROR_NONE);
+
+ return ret;
+ }
+ std::string getMethodName()
+ {
+ return method_name_;
+ }
+private:
+ const std::string method_name_ =
+ "RejectConnection";
+ WifiDirectManager *mgr_;
+};
+
+class DisconnectAllHandler : WifiDirectMethod {
+public:
+ DisconnectAllHandler(WifiDirectManager *mgr) : mgr_(mgr){};
+ ~DisconnectAllHandler()
+ {
+ };
+ GVariant *handleMethod(GVariant *parameters, GError **error) override
+ {
+ GVariant *ret = NULL;
+
+ *error = mgr_->disconnectAll();
+ if (*error == NULL)
+ ret = g_variant_new("(i)", WIFI_DIRECT_ERROR_NONE);
+
+ return ret;
+ }
+ std::string getMethodName()
+ {
+ return method_name_;
+ }
+private:
+ const std::string method_name_ =
+ "DisconnectAll";
+ WifiDirectManager *mgr_;
+};
+
+class DisconnectHandler : WifiDirectMethod {
+public:
+ DisconnectHandler(WifiDirectManager *mgr) : mgr_(mgr){};
+ ~DisconnectHandler()
+ {
+ };
+ GVariant *handleMethod(GVariant *parameters, GError **error) override
+ {
+ GVariant *ret = NULL;
+ const char *mac_address_str = NULL;
+ g_variant_get(parameters, "(&s)", &mac_address_str);
+ std::string mac_addr = std::string(mac_address_str);
+
+ *error = mgr_->disconnect(mac_addr);
+ if (*error == NULL)
+ ret = g_variant_new("(i)", WIFI_DIRECT_ERROR_NONE);
+
+ return ret;
+ }
+ std::string getMethodName()
+ {
+ return method_name_;
+ }
+private:
+ const std::string method_name_ =
+ "Disconnect";
+ WifiDirectManager *mgr_;
+};
+
+class GetConnectedPeersHandler : WifiDirectMethod {
+public:
+ GetConnectedPeersHandler(WifiDirectManager *mgr) : mgr_(mgr){};
+ ~GetConnectedPeersHandler()
+ {
+ };
+ GVariant *handleMethod(GVariant *parameters, GError **error) override
+ {
+ GVariant *ret = NULL;
+
+ *error = mgr_->getConnectedPeers(&ret);
+
+ return ret;
+ }
+ std::string getMethodName()
+ {
+ return method_name_;
+ }
+private:
+ const std::string method_name_ =
+ "GetConnectedPeers";
+ WifiDirectManager *mgr_;
+};
+
+class GetConnectingPeerHandler : WifiDirectMethod {
+public:
+ GetConnectingPeerHandler(WifiDirectManager *mgr) : mgr_(mgr){};
+ ~GetConnectingPeerHandler()
+ {
+ };
+ GVariant *handleMethod(GVariant *parameters, GError **error) override
+ {
+ GVariant *ret = NULL;
+
+ *error = mgr_->GetConnectingPeer(&ret);
+
+ return ret;
+ }
+ std::string getMethodName()
+ {
+ return method_name_;
+ }
+private:
+ const std::string method_name_ =
+ "GetConnectingPeer";
+ WifiDirectManager *mgr_;
+};
+
+class SetWpsPinHandler : WifiDirectMethod {
+public:
+ SetWpsPinHandler(WifiDirectManager *mgr) : mgr_(mgr){};
+ ~SetWpsPinHandler()
+ {
+ };
+ GVariant *handleMethod(GVariant *parameters, GError **error) override
+ {
+ const char *pin_str = NULL;
+ g_variant_get(parameters, "(&s)", &pin_str);
+
+ return g_variant_new("(i)", WIFI_DIRECT_ERROR_NONE);
+ }
+ std::string getMethodName()
+ {
+ return method_name_;
+ }
+private:
+ const std::string method_name_ =
+ "SetWpsPin";
+ WifiDirectManager *mgr_;
+};
+
+
+class GetWpsPinHandler : WifiDirectMethod {
+public:
+ GetWpsPinHandler(WifiDirectManager *mgr) : mgr_(mgr){};
+ ~GetWpsPinHandler()
+ {
+ };
+ GVariant *handleMethod(GVariant *parameters, GError **error) override
+ {
+ char pin_str[] = {"12345678"};
+
+ return g_variant_new("(is)", WIFI_DIRECT_ERROR_NONE, pin_str);
+ }
+ std::string getMethodName()
+ {
+ return method_name_;
+ }
+private:
+ const std::string method_name_ =
+ "GetWpsPin";
+ WifiDirectManager *mgr_;
+};
+WifiDirectManager::WifiDirectManager()
+{
+ this->group_ = nullptr;
+ this->state_ = WifiDirectState::kWifiDirectStateDeactivated;
+ this->config_methods_ = WFD_WPS_MODE_PBC | WFD_WPS_MODE_DISPLAY | WFD_WPS_MODE_KEYPAD;
+ this->wps_mode_ = WFD_WPS_MODE_PBC;
+ this->req_wps_mode_ = WFD_WPS_MODE_PBC;
+ this->scan_mode_ = WFD_SCAN_MODE_NONE;
+ this->persistent_gruop_enabled_ = FALSE;
+ this->session_timer_ = 120;
+ this->auto_group_remove_ = false;
+ this->mac_address_ = std::string("00:11:22:33:44:55");
+
+ AddClientHandler *add_client_handler = new AddClientHandler(this);
+ this->method_map_[add_client_handler->getMethodName()] = (WifiDirectMethod *)add_client_handler;
+
+ ActivateHandler *activate_handler = new ActivateHandler(this);
+ this->method_map_[activate_handler->getMethodName()] = (WifiDirectMethod *)activate_handler;
+
+ DeactivateHandler *deactivate_handler = new DeactivateHandler(this);
+ this->method_map_[deactivate_handler->getMethodName()] = (WifiDirectMethod *)deactivate_handler;
+
+ StartDiscoveryHandler *start_discovery_handler = new StartDiscoveryHandler(this);
+ this->method_map_[start_discovery_handler->getMethodName()] = (WifiDirectMethod *)start_discovery_handler;
+
+ StopDiscoveryHandler *stop_discovery_handler = new StopDiscoveryHandler(this);
+ this->method_map_[stop_discovery_handler->getMethodName()] = (WifiDirectMethod *)stop_discovery_handler;
+
+ GetDiscoveredPeersHandler *get_discovered_peers_handler = new GetDiscoveredPeersHandler(this);
+ this->method_map_[get_discovered_peers_handler->getMethodName()] = (WifiDirectMethod *)get_discovered_peers_handler;
+
+ CreateGroupHandler *create_group_handler = new CreateGroupHandler(this);
+ this->method_map_[create_group_handler->getMethodName()] = (WifiDirectMethod *)create_group_handler;
+
+ DestroyGroupHandler *destroy_group_handler = new DestroyGroupHandler(this);
+ this->method_map_[destroy_group_handler->getMethodName()] = (WifiDirectMethod *)destroy_group_handler;
+
+ IsGroupOwnerHandler *is_group_owner_handler = new IsGroupOwnerHandler(this);
+ this->method_map_[is_group_owner_handler->getMethodName()] = (WifiDirectMethod *)is_group_owner_handler;
+
+ GetMacAddressHandler *get_mac_address_handler = new GetMacAddressHandler(this);
+ this->method_map_[get_mac_address_handler->getMethodName()] = (WifiDirectMethod *)get_mac_address_handler;
+
+ IsAutoGroupHandler *is_auto_group_handler = new IsAutoGroupHandler(this);
+ this->method_map_[is_auto_group_handler->getMethodName()] = (WifiDirectMethod *)is_auto_group_handler;
+
+ SetGoIntentHandler *set_go_intent_handler = new SetGoIntentHandler(this);
+ this->method_map_[set_go_intent_handler->getMethodName()] = (WifiDirectMethod *)set_go_intent_handler;
+
+ GetGoIntentHandler *get_go_intent_handler = new GetGoIntentHandler(this);
+ this->method_map_[get_go_intent_handler->getMethodName()] = (WifiDirectMethod *)get_go_intent_handler;
+
+ SetGoIntentPerTypeHandler *set_go_intent_per_type_handler = new SetGoIntentPerTypeHandler(this);
+ this->method_map_[set_go_intent_per_type_handler->getMethodName()] = (WifiDirectMethod *)set_go_intent_per_type_handler;
+
+ GetGoIntentPerTypeHandler *get_go_intent_per_type_handler = new GetGoIntentPerTypeHandler(this);
+ this->method_map_[get_go_intent_per_type_handler->getMethodName()] = (WifiDirectMethod *)get_go_intent_per_type_handler;
+
+ SetMaxClientHandler *set_max_client_handler = new SetMaxClientHandler(this);
+ this->method_map_[set_max_client_handler->getMethodName()] = (WifiDirectMethod *)set_max_client_handler;
+
+ GetMaxClientHandler *get_max_client_handler = new GetMaxClientHandler(this);
+ this->method_map_[get_max_client_handler->getMethodName()] = (WifiDirectMethod *)get_max_client_handler;
+
+ GetOperatingChannelHandler *get_operating_channel_handler = new GetOperatingChannelHandler(this);
+ this->method_map_[get_operating_channel_handler->getMethodName()] = (WifiDirectMethod *)get_operating_channel_handler;
+
+ ActivatePushButtonHandler *activate_pushbutton_handler = new ActivatePushButtonHandler(this);
+ this->method_map_[activate_pushbutton_handler->getMethodName()] = (WifiDirectMethod *)activate_pushbutton_handler;
+
+ GetSupportedWpsModeHandler *get_supported_wps_mode_handler = new GetSupportedWpsModeHandler(this);
+ this->method_map_[get_supported_wps_mode_handler->getMethodName()] = (WifiDirectMethod *)get_supported_wps_mode_handler;
+
+ GetLocalWpsModeHandler *get_local_wps_mode_handler = new GetLocalWpsModeHandler(this);
+ this->method_map_[get_local_wps_mode_handler->getMethodName()] = (WifiDirectMethod *)get_local_wps_mode_handler;
+
+ SetReqWpsModeHandler *set_teq_wps_mode_handler = new SetReqWpsModeHandler(this);
+ this->method_map_[set_teq_wps_mode_handler->getMethodName()] = (WifiDirectMethod *)set_teq_wps_mode_handler;
+
+ GetReqWpsModeHandler *get_req_wps_mode_handler = new GetReqWpsModeHandler(this);
+ this->method_map_[get_req_wps_mode_handler->getMethodName()] = (WifiDirectMethod *)get_req_wps_mode_handler;
+
+ GetDeviceNameHandler *get_device_name_handler = new GetDeviceNameHandler(this);
+ this->method_map_[get_device_name_handler->getMethodName()] = (WifiDirectMethod *)get_device_name_handler;
+
+ SetDeviceNameHandler *set_device_name_handler = new SetDeviceNameHandler(this);
+ this->method_map_[set_device_name_handler->getMethodName()] = (WifiDirectMethod *)set_device_name_handler;
+
+ GetInterfaceNameHandler *get_interface_name_handler = new GetInterfaceNameHandler(this);
+ this->method_map_[get_interface_name_handler->getMethodName()] = (WifiDirectMethod *)get_interface_name_handler;
+
+ GetIPAddressHandler *get_ip_address_handler = new GetIPAddressHandler(this);
+ this->method_map_[get_ip_address_handler->getMethodName()] = (WifiDirectMethod *)get_ip_address_handler;
+
+ GetSubnetMaskHandler *get_subnet_mask_handler = new GetSubnetMaskHandler(this);
+ this->method_map_[get_subnet_mask_handler->getMethodName()] = (WifiDirectMethod *)get_subnet_mask_handler;
+
+ GetGatewayHandler *get_gateway_handler = new GetGatewayHandler(this);
+ this->method_map_[get_gateway_handler->getMethodName()] = (WifiDirectMethod *)get_gateway_handler;
+
+ IsDiscoverableHandler *is_discoverable_handler = new IsDiscoverableHandler(this);
+ this->method_map_[is_discoverable_handler->getMethodName()] = (WifiDirectMethod *)is_discoverable_handler;
+
+ IsListeningOnlyHandler *is_listening_only_handler = new IsListeningOnlyHandler(this);
+ this->method_map_[is_listening_only_handler->getMethodName()] = (WifiDirectMethod *)is_listening_only_handler;
+
+ GetPrimaryDevTypeHandler *get_primary_dev_type_handler = new GetPrimaryDevTypeHandler(this);
+ this->method_map_[get_primary_dev_type_handler->getMethodName()] = (WifiDirectMethod *)get_primary_dev_type_handler;
+
+ GetSecondaryDevTypeHandler *get_secondary_dev_type_handler = new GetSecondaryDevTypeHandler(this);
+ this->method_map_[get_secondary_dev_type_handler->getMethodName()] = (WifiDirectMethod *)get_secondary_dev_type_handler;
+
+ SetAutoConnectionModeHandler *set_auto_connection_mode_handler = new SetAutoConnectionModeHandler(this);
+ this->method_map_[set_auto_connection_mode_handler->getMethodName()] = (WifiDirectMethod *)set_auto_connection_mode_handler;
+
+ IsAutoConnectionModeHandler *is_auto_connection_mode_handler = new IsAutoConnectionModeHandler(this);
+ this->method_map_[is_auto_connection_mode_handler->getMethodName()] = (WifiDirectMethod *)is_auto_connection_mode_handler;
+
+ SetPersistentGroupEnabledHandler *set_persistent_group_enable_handler = new SetPersistentGroupEnabledHandler(this);
+ this->method_map_[set_persistent_group_enable_handler->getMethodName()] = (WifiDirectMethod *)set_persistent_group_enable_handler;
+
+ IsPersistentGroupEnabledHandler *is_persistent_group_enable_handler = new IsPersistentGroupEnabledHandler(this);
+ this->method_map_[is_persistent_group_enable_handler->getMethodName()] = (WifiDirectMethod *)is_persistent_group_enable_handler;
+
+ GetPersistentGroupsHandler *get_persistent_group_handler = new GetPersistentGroupsHandler(this);
+ this->method_map_[get_persistent_group_handler->getMethodName()] = (WifiDirectMethod *)get_persistent_group_handler;
+
+ RemovePersistentGroupHandler *remove_persistent_group_handler = new RemovePersistentGroupHandler(this);
+ this->method_map_[remove_persistent_group_handler->getMethodName()] = (WifiDirectMethod *)remove_persistent_group_handler;
+
+ RegisterHandler *register_handler = new RegisterHandler(this);
+ this->method_map_[register_handler->getMethodName()] = (WifiDirectMethod *)register_handler;
+
+ DeregisterHandler *deregister_handler = new DeregisterHandler(this);
+ this->method_map_[deregister_handler->getMethodName()] = (WifiDirectMethod *)deregister_handler;
+
+ GetPeerInfoHandler *get_peer_info_handler = new GetPeerInfoHandler(this);
+ this->method_map_[get_peer_info_handler->getMethodName()] = (WifiDirectMethod *)get_peer_info_handler;
+
+ SetPassphraseHandler *set_passphrase_handler = new SetPassphraseHandler(this);
+ this->method_map_[set_passphrase_handler->getMethodName()] = (WifiDirectMethod *)set_passphrase_handler;
+
+ GetPassphraseHandler *get_passphrase_handler = new GetPassphraseHandler(this);
+ this->method_map_[get_passphrase_handler->getMethodName()] = (WifiDirectMethod *)get_passphrase_handler;
+
+ SetAutoConnectionPeerHandler *set_auto_connection_peer_handler = new SetAutoConnectionPeerHandler(this);
+ this->method_map_[set_auto_connection_peer_handler->getMethodName()] = (WifiDirectMethod *)set_auto_connection_peer_handler;
+
+ InitHandler *init_handler = new InitHandler(this);
+ this->method_map_[init_handler->getMethodName()] = (WifiDirectMethod *)init_handler;
+
+ DeinitHandler *deinit_handler = new DeinitHandler(this);
+ this->method_map_[deinit_handler->getMethodName()] = (WifiDirectMethod *)deinit_handler;
+
+ SetConfigHandler *set_config_handler = new SetConfigHandler(this);
+ this->method_map_[set_config_handler->getMethodName()] = (WifiDirectMethod *)set_config_handler;
+
+ SetAvailiabilityHandler *set_availability_handler = new SetAvailiabilityHandler(this);
+ this->method_map_[set_availability_handler->getMethodName()] = (WifiDirectMethod *)set_availability_handler;
+
+ GetConfigHandler *get_config_handler = new GetConfigHandler(this);
+ this->method_map_[get_config_handler->getMethodName()] = (WifiDirectMethod *)get_config_handler;
+
+ GetAvailiabilityHandler *get_availability_handler = new GetAvailiabilityHandler(this);
+ this->method_map_[get_availability_handler->getMethodName()] = (WifiDirectMethod *)get_availability_handler;
+
+ GetPeerTypeHandler *get_peer_type_handler = new GetPeerTypeHandler(this);
+ this->method_map_[get_peer_type_handler->getMethodName()] = (WifiDirectMethod *)get_peer_type_handler;
+
+ GetPeerAvailabilityHandler *get_peer_availability_handler = new GetPeerAvailabilityHandler(this);
+ this->method_map_[get_peer_availability_handler->getMethodName()] = (WifiDirectMethod *)get_peer_availability_handler;
+
+ GetPeerHdcpHandler *get_peer_hdcp_handler = new GetPeerHdcpHandler(this);
+ this->method_map_[get_peer_hdcp_handler->getMethodName()] = (WifiDirectMethod *)get_peer_hdcp_handler;
+
+ GetPeerPortHandler *get_peer_port_handler = new GetPeerPortHandler(this);
+ this->method_map_[get_peer_port_handler->getMethodName()] = (WifiDirectMethod *)get_peer_port_handler;
+
+ GetPeerThroughputHandler *get_peer_throughput_handler = new GetPeerThroughputHandler(this);
+ this->method_map_[get_peer_throughput_handler->getMethodName()] = (WifiDirectMethod *)get_peer_throughput_handler;
+
+ GetPeerRssiHandler *get_peer_rssi_handler = new GetPeerRssiHandler(this);
+ this->method_map_[get_peer_rssi_handler->getMethodName()] = (WifiDirectMethod *)get_peer_rssi_handler;
+
+ SetSessionTimerHandler *set_session_timer_handler = new SetSessionTimerHandler(this);
+ this->method_map_[set_session_timer_handler->getMethodName()] = (WifiDirectMethod *)set_session_timer_handler;
+
+ GetSessionTimerHandler *get_session_timer_handler = new GetSessionTimerHandler(this);
+ this->method_map_[get_session_timer_handler->getMethodName()] = (WifiDirectMethod *)get_session_timer_handler;
+
+ SetAutoGroupRemovalHandler *set_auto_group_removal_handler = new SetAutoGroupRemovalHandler(this);
+ this->method_map_[set_auto_group_removal_handler->getMethodName()] = (WifiDirectMethod *)set_auto_group_removal_handler;
+
+ AddVsieHandler *add_vsie_handler = new AddVsieHandler(this);
+ this->method_map_[add_vsie_handler->getMethodName()] = (WifiDirectMethod *)add_vsie_handler;
+
+ GetVsieHandler *get_vsie_handler = new GetVsieHandler(this);
+ this->method_map_[get_vsie_handler->getMethodName()] = (WifiDirectMethod *)get_vsie_handler;
+
+ RemoveVsieHandler *remove_vsie_handler = new RemoveVsieHandler(this);
+ this->method_map_[remove_vsie_handler->getMethodName()] = (WifiDirectMethod *)remove_vsie_handler;
+
+ GetPeerVsieHandler *get_peer_vsie_handler = new GetPeerVsieHandler(this);
+ this->method_map_[get_peer_vsie_handler->getMethodName()] = (WifiDirectMethod *)get_peer_vsie_handler;
+
+ SetWpsConfigMethodHandler *set_wps_config_method_handler = new SetWpsConfigMethodHandler(this);
+ this->method_map_[set_wps_config_method_handler->getMethodName()] = (WifiDirectMethod *)set_wps_config_method_handler;
+
+ GetWpsConfigMethodHandler *get_wps_config_method_handler = new GetWpsConfigMethodHandler(this);
+ this->method_map_[get_wps_config_method_handler->getMethodName()] = (WifiDirectMethod *)get_wps_config_method_handler;
+
+ RemovePersistentDeviceHandler *remove_persistent_device_handler = new RemovePersistentDeviceHandler(this);
+ this->method_map_[remove_persistent_device_handler->getMethodName()] = (WifiDirectMethod *)remove_persistent_device_handler;
+
+ RemoveAllPersistentDeviceHandler *remove_all_persistent_device_handler = new RemoveAllPersistentDeviceHandler(this);
+ this->method_map_[remove_all_persistent_device_handler->getMethodName()] = (WifiDirectMethod *)remove_all_persistent_device_handler;
+
+ ConnectHandler *connect_handler = new ConnectHandler(this);
+ this->method_map_[connect_handler->getMethodName()] = (WifiDirectMethod *)connect_handler;
+
+ AcceptConnectionHandler *accept_connection_handler = new AcceptConnectionHandler(this);
+ this->method_map_[accept_connection_handler->getMethodName()] = (WifiDirectMethod *)accept_connection_handler;
+
+ CancelConnectionHandler *cancel_connection_handler = new CancelConnectionHandler(this);
+ this->method_map_[cancel_connection_handler->getMethodName()] = (WifiDirectMethod *)cancel_connection_handler;
+
+ RejectConnectionHandler *reject_connection_handler = new RejectConnectionHandler(this);
+ this->method_map_[reject_connection_handler->getMethodName()] = (WifiDirectMethod *)reject_connection_handler;
+
+ DisconnectAllHandler *disconnect_all_handler = new DisconnectAllHandler(this);
+ this->method_map_[disconnect_all_handler->getMethodName()] = (WifiDirectMethod *)disconnect_all_handler;
+
+ DisconnectHandler *disconnect_handler = new DisconnectHandler(this);
+ this->method_map_[disconnect_handler->getMethodName()] = (WifiDirectMethod *)disconnect_handler;
+
+ GetConnectedPeersHandler *get_connected_peers_handler = new GetConnectedPeersHandler(this);
+ this->method_map_[get_connected_peers_handler->getMethodName()] = (WifiDirectMethod *)get_connected_peers_handler;
+
+ GetConnectingPeerHandler *get_connecting_peer_handler = new GetConnectingPeerHandler(this);
+ this->method_map_[get_connecting_peer_handler->getMethodName()] = (WifiDirectMethod *)get_connecting_peer_handler;
+
+ SetWpsPinHandler *set_wps_pin_handler = new SetWpsPinHandler(this);
+ this->method_map_[set_wps_pin_handler->getMethodName()] = (WifiDirectMethod *)set_wps_pin_handler;
+
+ GetWpsPinHandler *get_wps_pin_handler = new GetWpsPinHandler(this);
+ this->method_map_[get_wps_pin_handler->getMethodName()] = (WifiDirectMethod *)get_wps_pin_handler;
+
+}
+
+WifiDirectManager::~WifiDirectManager()
+{
+ for(auto& elem : this->method_map_){
+ delete elem.second;
+ }
+ this->method_map_.clear();
+
+ for(auto& elem : this->service_map_){
+ delete elem.second;
+ }
+ this->method_map_.clear();
+
+ if (this->group_)
+ delete this->group_;
+}
+
+GVariant *WifiDirectManager::callMethod(const gchar *method_name,
+ GVariant *parameters,
+ GError **error)
+{
+ WifiDirectMethod *method_handler = this->method_map_[std::string(method_name)];
+ if (!method_handler)
+ return NULL;
+
+ return method_handler->handleMethod(parameters, error);
+}
+
+void WifiDirectManager::setState(const WifiDirectState state)
+{
+ this->state_ = state;
+
+ return;
+}
+
+GError *WifiDirectManager::startDiscovery(int mode, int timeout,
+ const char* type, int channel, int frequency)
+{
+ if (this->isNotDiscoverable())
+ return this->error_handler_.NotPermitted();
+
+
+ this->scan_mode_ = mode;
+ return NULL;
+}
+
+GError *WifiDirectManager::stopDiscovery()
+{
+ printf("state %d\n", static_cast<int>(this->state_));
+ if (this->state_ != WifiDirectState::kWifiDirectStateActivated &&
+ this->state_ != WifiDirectState::kWifiDirectStateDiscovering)
+ return this->error_handler_.NotPermitted();
+
+ this->scan_mode_ = WFD_SCAN_MODE_NONE;
+ return NULL;
+}
+
+GError *WifiDirectManager::createGroup(const char *ssid)
+{
+ if (this->group_ != nullptr || this->state_ < WifiDirectState::kWifiDirectStateActivated)
+ return this->error_handler_.NotPermitted();
+
+ this->group_ = new WifiDirectGroup();
+ this->group_->setFlag(WFD_GROUP_FLAG_AUTONOMOUS);
+ this->group_->setRole(WFD_DEV_ROLE_GO);
+
+ return NULL;
+}
+
+GError *WifiDirectManager::destroyGroup()
+{
+ if (this->group_ == nullptr)
+ return this->error_handler_.NotPermitted();
+
+ delete this->group_;
+ this->group_ = nullptr;
+
+ return NULL;
+}
+
+GError *WifiDirectManager::isGroupOwner(gboolean *is_group_owner)
+{
+ if (this->group_ == nullptr)
+ *is_group_owner = FALSE;
+ else
+ *is_group_owner = this->group_->getRole() == WFD_DEV_ROLE_GO;
+
+ return NULL;
+}
+
+GError *WifiDirectManager::isAutoGroup(gboolean *is_auto_group)
+{
+ if (this->group_ == nullptr)
+ *is_auto_group = FALSE;
+ else
+ *is_auto_group = (this->group_->getFlag() & WFD_GROUP_FLAG_AUTONOMOUS) != 0;
+
+ return NULL;
+}
+
+GError *WifiDirectManager::getMacAddress(std::string &mac_addr)
+{
+ mac_addr = this->mac_address_;
+
+ return NULL;
+}
+
+GError *WifiDirectManager::setGoIntent(int go_intent)
+{
+ this->setting_.setGoIntent(go_intent);
+ return NULL;
+}
+
+GError *WifiDirectManager::getGoIntent(int *go_intent)
+{
+ *go_intent = this->setting_.getGoIntent();
+ return NULL;
+}
+
+GError *WifiDirectManager::setMaxClient(int max_client)
+{
+ if (max_client < 1)
+ return this->error_handler_.OperationFailed();
+ this->setting_.setMaxClient(max_client);
+ return NULL;
+}
+
+GError *WifiDirectManager::getMaxClient(int *max_client)
+{
+ *max_client = this->setting_.getMaxClient();
+ return NULL;
+}
+
+GError *WifiDirectManager::getOperatingChannel(int *channel)
+{
+ if (this->group_ == nullptr)
+ return this->error_handler_.NotPermitted();
+
+ *channel = this->group_->getOperatingChannel();
+
+ return NULL;
+}
+
+GError *WifiDirectManager::ActivatePushbutton()
+{
+ if (this->group_ == nullptr || this->group_->getRole() != WFD_DEV_ROLE_GO)
+ return this->error_handler_.NotPermitted();
+
+ /* Dummy */
+
+ return NULL;
+}
+
+GError *WifiDirectManager::GetSupportedWpsMode(int *supported_wps_mode)
+{
+ *supported_wps_mode = this->config_methods_;
+
+ return NULL;
+}
+
+GError *WifiDirectManager::GetLocalWpsMode(int *wps_mode)
+{
+ *wps_mode = this->wps_mode_;
+
+ return NULL;
+}
+
+GError *WifiDirectManager::setRequestWpsMode(int wps_mode)
+{
+ this->req_wps_mode_ = wps_mode;
+
+ return NULL;
+}
+
+GError *WifiDirectManager::GetRequestWpsMode(int *wps_mode)
+{
+ *wps_mode = this->req_wps_mode_;
+
+ return NULL;
+}
+
+GError *WifiDirectManager::setDeviceName(std::string device_name)
+{
+ this->setting_.setDeviceName(device_name);
+
+ return NULL;
+}
+
+GError *WifiDirectManager::getDeviceName(std::string &device_name)
+{
+ device_name = this->setting_.getDeviceName();
+
+ return NULL;
+}
+
+GError *WifiDirectManager::getInterfaceName(std::string &iface_name)
+{
+ if (this->group_ == nullptr)
+ return this->error_handler_.NotPermitted();
+
+ iface_name = this->group_->getIfaceName();
+
+ return NULL;
+}
+
+GError *WifiDirectManager::getIpAddr(std::string &ip_addr)
+{
+ if (this->group_ == nullptr)
+ return this->error_handler_.NotPermitted();
+
+ ip_addr = this->group_->getIpAddr();
+
+ return NULL;
+}
+
+GError *WifiDirectManager::getSubnetMask(std::string &subnet_mask)
+{
+ if (this->group_ == nullptr)
+ return this->error_handler_.NotPermitted();
+
+ subnet_mask = this->group_->getSubnetMask();
+
+ return NULL;
+}
+
+GError *WifiDirectManager::getGatewayAddr(std::string &gateway_addr)
+{
+ if (this->group_ == nullptr)
+ return this->error_handler_.NotPermitted();
+
+ gateway_addr = this->group_->getGatewayAddr();
+
+ return NULL;
+}
+
+GError *WifiDirectManager::enablePersistentGroup(gboolean enable)
+{
+ this->persistent_gruop_enabled_ = enable;
+
+ return NULL;
+}
+
+GError *WifiDirectManager::isPersistentGruopEnabled(gboolean *enable)
+{
+ *enable = this->persistent_gruop_enabled_;
+
+ return NULL;
+}
+
+GVariant* __packGVariantAy(const unsigned char *src, int size)
+{
+ GVariantBuilder *builder = NULL;
+ GVariant *iter = NULL;
+ int i = 0;
+
+ if (!src) {
+ return NULL;
+ }
+
+ builder = g_variant_builder_new(G_VARIANT_TYPE("ay"));
+
+ for (i = 0; i < size; i++)
+ g_variant_builder_add(builder, "y", src[i]);
+
+ iter = g_variant_new("ay", builder);
+
+ g_variant_builder_unref(builder);
+ return iter;
+}
+
+GError *WifiDirectManager::getPersistentGroup(GVariant **group)
+{
+ GVariant *ret;
+ GVariantBuilder *builder_groups;
+ unsigned char default_addr[] = {0xaa, 0xbb, 0xcc, 0xdd, 0xee, 0xff};
+
+ if (this->state_ < WifiDirectState::kWifiDirectStateActivated)
+ return this->error_handler_.NotPermitted();
+
+ builder_groups = g_variant_builder_new(G_VARIANT_TYPE("aa{sv}"));
+ GVariantBuilder builder_group;
+ g_variant_builder_init(&builder_group, G_VARIANT_TYPE("a{sv}"));
+ g_variant_builder_add(&builder_group, "{sv}",
+ "NetworkID",
+ g_variant_new_uint32(1));
+ g_variant_builder_add(&builder_group, "{sv}",
+ "SSID",
+ g_variant_new_string("TIZEN"));
+ g_variant_builder_add(&builder_group, "{sv}",
+ "GOMacAddress",
+ __packGVariantAy(default_addr, MACADDR_LEN));
+ g_variant_builder_add_value(builder_groups, g_variant_builder_end(&builder_group));
+ ret = g_variant_new("(iaa{sv})", WIFI_DIRECT_ERROR_NONE, builder_groups);
+ g_variant_builder_unref(builder_groups);
+ *group = ret;
+
+ return NULL;
+}
+
+GError *WifiDirectManager::removePersistentGroup(void)
+{
+ if (this->state_ < WifiDirectState::kWifiDirectStateActivated)
+ return this->error_handler_.NotPermitted();
+
+ return NULL;
+}
+
+GError *WifiDirectManager::registerService(int service_type, std::string &info, int *service_id)
+{
+ if (this->state_ < WifiDirectState::kWifiDirectStateActivated)
+ return this->error_handler_.NotPermitted();
+
+ WifiDirectService *wfd_service = new WifiDirectService(info);
+ this->service_map_[wfd_service->getId()] = (WifiDirectService *)wfd_service;
+
+ *service_id = wfd_service->getId();
+
+ return NULL;
+}
+
+GError *WifiDirectManager::deregisterService(int service_id)
+{
+ if (this->state_ < WifiDirectState::kWifiDirectStateActivated)
+ return this->error_handler_.NotPermitted();
+
+ WifiDirectService *wfd_service = this->service_map_[service_id];
+ if (wfd_service != nullptr) {
+ this->service_map_.erase(service_id);
+ delete wfd_service;
+ }
+
+ return NULL;
+}
+
+GError *WifiDirectManager::setPassphrase(std::string &passphrase)
+{
+ if (this->group_ != nullptr)
+ return this->error_handler_.NotPermitted();
+
+ this->passphrase_ = passphrase;
+
+ return NULL;
+}
+
+GError *WifiDirectManager::getPassphrase(std::string &passphrase)
+{
+ if (this->group_ == nullptr)
+ return this->error_handler_.NotPermitted();
+
+ passphrase = this->group_->getPassphrase();
+
+ return NULL;
+}
+
+GError *WifiDirectManager::initDisplay(void)
+{
+ if (this->state_ < WifiDirectState::kWifiDirectStateActivated)
+ return this->error_handler_.NotPermitted();
+
+ return NULL;
+}
+
+GError *WifiDirectManager::deinitDisplay(void)
+{
+ if (this->state_ < WifiDirectState::kWifiDirectStateActivated)
+ return this->error_handler_.NotPermitted();
+
+ return NULL;
+}
+
+GError *WifiDirectManager::setConfig(int type, int port, int hdcp)
+{
+ if (this->state_ < WifiDirectState::kWifiDirectStateActivated)
+ return this->error_handler_.NotPermitted();
+
+ this->display_info_.setType(type);
+ this->display_info_.setPort(port);
+ this->display_info_.setHdcp(hdcp);
+
+ return NULL;
+}
+
+GError *WifiDirectManager::getConfig(int *type, int *port, int *hdcp)
+{
+ if (this->state_ < WifiDirectState::kWifiDirectStateActivated)
+ return this->error_handler_.NotPermitted();
+
+ *type = this->display_info_.getType();
+ *port = this->display_info_.getPort();
+ *hdcp = this->display_info_.getHdcp();
+
+ return NULL;
+}
+
+GError *WifiDirectManager::setAvailiability(int availability)
+{
+ if (this->state_ < WifiDirectState::kWifiDirectStateActivated)
+ return this->error_handler_.NotPermitted();
+
+ this->display_info_.setAvailability(availability);
+
+ return NULL;
+}
+
+GError *WifiDirectManager::getAvailiability(int &availability)
+{
+ if (this->state_ < WifiDirectState::kWifiDirectStateActivated)
+ return this->error_handler_.NotPermitted();
+
+ availability = this->display_info_.getAvailability();
+ return NULL;
+}
+
+GError *WifiDirectManager::getPeerType(std::string &mac_addr, int *type)
+{
+ if (this->state_ < WifiDirectState::kWifiDirectStateActivated)
+ return this->error_handler_.NotPermitted();
+
+ *type = this->peer_.getDisplay_info().getType();
+
+ return NULL;
+}
+
+GError *WifiDirectManager::getPeerAvailability(std::string &mac_addr, int *availability)
+{
+ if (this->state_ < WifiDirectState::kWifiDirectStateActivated)
+ return this->error_handler_.NotPermitted();
+
+ *availability = this->peer_.getDisplay_info().getAvailability();
+
+ return NULL;
+}
+
+GError *WifiDirectManager::getPeerHdcp(std::string &mac_addr, int *hdcp)
+{
+ if (this->state_ < WifiDirectState::kWifiDirectStateActivated)
+ return this->error_handler_.NotPermitted();
+
+ *hdcp = this->peer_.getDisplay_info().getHdcp();
+
+ return NULL;
+}
+
+GError *WifiDirectManager::getPeerPort(std::string &mac_addr, int *port)
+{
+ if (this->state_ < WifiDirectState::kWifiDirectStateActivated)
+ return this->error_handler_.NotPermitted();
+
+ *port = this->peer_.getDisplay_info().getPort();
+
+ return NULL;
+}
+
+GError *WifiDirectManager::getPeerThroughput(std::string &mac_addr, int *throuput)
+{
+ if (this->state_ < WifiDirectState::kWifiDirectStateActivated)
+ return this->error_handler_.NotPermitted();
+
+ *throuput = this->peer_.getDisplay_info().getThroughput();
+
+ return NULL;
+}
+
+GError *WifiDirectManager::getPeerRssi(std::string &mac_addr, int *rssi)
+{
+ if (this->state_ < WifiDirectState::kWifiDirectStateActivated)
+ return this->error_handler_.NotPermitted();
+
+ *rssi = this->peer_.getRssi();
+
+ return NULL;
+}
+
+GError *WifiDirectManager::addVsie(int frame_id, std::string &vsie)
+{
+ if (this->state_ < WifiDirectState::kWifiDirectStateActivated)
+ return this->error_handler_.NotPermitted();
+
+ return NULL;
+}
+
+GError *WifiDirectManager::getVsie(int frame_id, std::string &vsie)
+{
+ if (this->state_ < WifiDirectState::kWifiDirectStateActivated)
+ return this->error_handler_.NotPermitted();
+
+ vsie = std::string("TestVsie");
+ return NULL;
+}
+
+GError *WifiDirectManager::removeVsie(int frame_id, std::string &vsie)
+{
+ if (this->state_ < WifiDirectState::kWifiDirectStateActivated)
+ return this->error_handler_.NotPermitted();
+
+ return NULL;
+}
+
+GError *WifiDirectManager::getPeerVsie(std::string &mac_addr, std::string &vsie)
+{
+ if (this->state_ < WifiDirectState::kWifiDirectStateActivated)
+ return this->error_handler_.NotPermitted();
+
+ vsie = this->peer_.getVsie();
+
+ return NULL;
+}
+
+GError *WifiDirectManager::setWpsConfigMethod(int wps_method)
+{
+ if (this->state_ < WifiDirectState::kWifiDirectStateActivated)
+ return this->error_handler_.NotPermitted();
+
+ return NULL;
+}
+
+GError *WifiDirectManager::getWpsConfigMethod(int &wps_method)
+{
+ if (this->state_ < WifiDirectState::kWifiDirectStateActivated)
+ return this->error_handler_.NotPermitted();
+
+ wps_method = 0;
+
+ return NULL;
+}
+
+GError *WifiDirectManager::removePersistentDevice(std::string &mac_addr)
+{
+ if (this->state_ < WifiDirectState::kWifiDirectStateActivated)
+ return this->error_handler_.NotPermitted();
+
+ return NULL;
+}
+
+GError *WifiDirectManager::removeAllPersistentDevice(void)
+{
+ if (this->state_ < WifiDirectState::kWifiDirectStateActivated)
+ return this->error_handler_.NotPermitted();
+
+ return NULL;
+}
+
+static bool __is_discovery_available(WifiDirectManager *mgr)
+{
+ return mgr->getState() != WifiDirectState::kWifiDirectStateActivated &&
+ mgr->getState() != WifiDirectState::kWifiDirectStateDiscovering &&
+ mgr->getState() != WifiDirectState::kWifiDirectStateGroupowner;
+}
+
+GError *WifiDirectManager::connect(std::string &mac_addr)
+{
+ if (__is_discovery_available(this))
+ return this->error_handler_.NotPermitted();
+
+ /* Skipping connection session related operations
+ * such as comparing peer MAC address,
+ * setting WPS related operations,
+ * Checking Group creating process,
+ * and ETC.
+ */
+
+ return NULL;
+}
+
+GError *WifiDirectManager::acceptConnection(std::string &mac_addr)
+{
+ if (this->state_ != WifiDirectState::kWifiDirectStateConnecting)
+ return this->error_handler_.NotPermitted();
+
+ /* Skipping connection session related operations
+ * such as comparing peer MAC address,
+ * setting WPS related operations,
+ * Checking Group creating process,
+ * and ETC.
+ */
+
+ return NULL;
+}
+
+GError *WifiDirectManager::cancelConnection(std::string &mac_addr)
+{
+ if (this->state_ != WifiDirectState::kWifiDirectStateConnecting)
+ return this->error_handler_.NotPermitted();
+
+ /* Skipping connection session related operations
+ * such as comparing peer MAC address,
+ * setting WPS related operations,
+ * Checking Group creating process,
+ * and ETC.
+ */
+
+ return NULL;
+}
+
+GError *WifiDirectManager::rejectConnection(std::string &mac_addr)
+{
+ if (this->state_ != WifiDirectState::kWifiDirectStateConnecting)
+ return this->error_handler_.NotPermitted();
+
+ /* Skipping connection session related operations
+ * such as comparing peer MAC address,
+ * setting WPS related operations,
+ * Checking Group creating process,
+ * and ETC.
+ */
+
+ return NULL;
+}
+
+GError *WifiDirectManager::disconnectAll()
+{
+ if (this->group_ == nullptr || this->state_ < WifiDirectState::kWifiDirectStateConnected)
+ return this->error_handler_.NotPermitted();
+
+ /* Skipping connection session related operations
+ * such as comparing peer MAC address,
+ * setting WPS related operations,
+ * Checking Group creating process,
+ * and ETC.
+ */
+
+ return NULL;
+}
+
+GError *WifiDirectManager::disconnect(std::string &mac_addr)
+{
+ if (this->group_ == nullptr || this->state_ < WifiDirectState::kWifiDirectStateConnected)
+ return this->error_handler_.NotPermitted();
+
+ /* Skipping connection session related operations
+ * such as comparing peer MAC address,
+ * setting WPS related operations,
+ * Checking Group creating process,
+ * and ETC.
+ */
+
+ return NULL;
+}
+
+GError *WifiDirectManager::getConnectedPeers(GVariant **ret)
+{
+ if (this->group_ == nullptr || this->state_ < WifiDirectState::kWifiDirectStateConnected)
+ return this->error_handler_.NotPermitted();
+
+ /* Skipping connection session related operations
+ * such as comparing peer MAC address,
+ * setting WPS related operations,
+ * Checking Group creating process,
+ * and ETC.
+ */
+
+ *ret = this->getDiscoveredPeersGvariant();
+
+ return NULL;
+}
+
+GError *WifiDirectManager::GetConnectingPeer(GVariant **ret)
+{
+ if (this->state_ != WifiDirectState::kWifiDirectStateConnecting)
+ return this->error_handler_.NotPermitted();
+
+ /* Skipping connection session related operations
+ * such as comparing peer MAC address,
+ * setting WPS related operations,
+ * Checking Group creating process,
+ * and ETC.
+ */
+
+ *ret = this->getPeerInfoGvariant();
+
+ return NULL;
+}
+
+GError *WifiDirectManager::setSessionTimer(int second)
+{
+ this->session_timer_ = second;
+
+ return NULL;
+}
+GError *WifiDirectManager::getSessionTimer(int *second)
+{
+ *second = this->session_timer_;
+ return NULL;
+}
+
+GError *WifiDirectManager::setAutoGruopRemove(bool remove)
+{
+ if (this->state_ < WifiDirectState::kWifiDirectStateActivated)
+ return this->error_handler_.NotPermitted();
+
+ this->auto_group_remove_ = remove;
+
+ return NULL;
+}
+
+GVariant *WifiDirectManager::getPeerInfoGvariant(void)
+{
+ GVariant *ret;
+ GVariantBuilder *builder_peer;
+
+ builder_peer = this->peer_.getPeerGvariantBuilder();
+ ret = g_variant_new("(ia{sv})", WIFI_DIRECT_ERROR_NONE, builder_peer);
+ g_variant_builder_unref(builder_peer);
+
+ return ret;
+}
+
+GVariant *WifiDirectManager::getDiscoveredPeersGvariant(void)
+{
+ GVariantBuilder *builder_peers = g_variant_builder_new(G_VARIANT_TYPE("aa{sv}"));
+ GVariant *ret;
+
+ g_variant_builder_add_value(builder_peers, this->peer_.getPeerGvariant());
+ ret = g_variant_new("(iaa{sv})", WIFI_DIRECT_ERROR_NONE, builder_peers);
+ g_variant_builder_unref(builder_peers);
+
+ return ret;
+}
+
+GVariant *WifiDirectManager::activated(void)
+{
+ this->setState(WifiDirectState::kWifiDirectStateActivated);
+
+ return g_variant_new("(i)", WIFI_DIRECT_ERROR_NONE);
+}
+
+GVariant *WifiDirectManager::deactivated(void)
+{
+ this->setState(WifiDirectState::kWifiDirectStateDeactivated);
+
+ return g_variant_new("(i)", WIFI_DIRECT_ERROR_NONE);
+}
+
+GVariant *WifiDirectManager::peerFound(void)
+{
+ std::string address = this->peer_.getAddress();
+ return g_variant_new("(s)", address.c_str());
+}
+
+GVariant *WifiDirectManager::peerLost(void)
+{
+ std::string address = this->peer_.getAddress();
+ return g_variant_new("(s)", address.c_str());
+}
+
+GVariant *WifiDirectManager::connectionInProgress(void)
+{
+ this->setState(WifiDirectState::kWifiDirectStateConnecting);
+
+ std::string address = this->peer_.getAddress();
+ return g_variant_new("(iis)", WIFI_DIRECT_ERROR_NONE,
+ WFD_EVENT_CONNECTION_IN_PROGRESS,
+ address.c_str());
+}
+
+GVariant *WifiDirectManager::connectionRspWithNoErrorGO(void)
+{
+ this->group_ = new WifiDirectGroup();
+ this->group_->setRole(WFD_DEV_ROLE_GO);
+
+ std::string address = this->peer_.getAddress();
+ return g_variant_new("(iis)", WIFI_DIRECT_ERROR_NONE,
+ WFD_EVENT_CONNECTION_RSP,
+ address.c_str());
+}
+
+GVariant *WifiDirectManager::peerIpAssigned(void)
+{
+ this->setState(WifiDirectState::kWifiDirectStateConnected);
+
+ std::string address = this->peer_.getAddress();
+ char ip_str[] = "192.168.0.51";
+ return g_variant_new("(ss)", address.c_str(), ip_str);
+}
+
+GVariant *WifiDirectManager::disconnection(void)
+{
+ this->destroyGroup();
+
+ std::string address = this->peer_.getAddress();
+ return g_variant_new("(iis)", WIFI_DIRECT_ERROR_NONE,
+ WFD_EVENT_DISCONNECTION_RSP,
+ address.c_str());
+}
+
+GVariant *WifiDirectManager::connectionRequestPbc(void)
+{
+ this->setState(WifiDirectState::kWifiDirectStateConnecting);
+
+ std::string address = this->peer_.getAddress();
+ return g_variant_new("(iis)", WIFI_DIRECT_ERROR_NONE,
+ WFD_EVENT_CONNECTION_REQ,
+ address.c_str());
+}
+
+GVariant *WifiDirectManager::connectionCanceled(void)
+{
+ this->setState(WifiDirectState::kWifiDirectStateActivated);
+
+ std::string address = this->peer_.getAddress();
+ return g_variant_new("(iis)", WIFI_DIRECT_ERROR_CONNECTION_CANCELED,
+ WFD_EVENT_CONNECTION_RSP,
+ address.c_str());
+}
+
+gboolean WifiDirectManager::isNotDiscoverable()
+{
+ return this->state_ != WifiDirectState::kWifiDirectStateActivated &&
+ this->state_ != WifiDirectState::kWifiDirectStateDiscovering &&
+ this->state_ != WifiDirectState::kWifiDirectStateGroupowner;
+}
--- /dev/null
+/*
+ * Copyright (c) 2020 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.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://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+#include "WifiDirectPeer.h"
+
+using namespace WifiDirectManagerNamespace;
+
+GVariant* WifiDirectPeer::packGVariantAy(const unsigned char *src, int size)
+{
+ GVariantBuilder *builder = NULL;
+ GVariant *iter = NULL;
+ int i = 0;
+
+ if (!src) {
+ return NULL;
+ }
+
+ builder = g_variant_builder_new(G_VARIANT_TYPE("ay"));
+
+ for (i = 0; i < size; i++)
+ g_variant_builder_add(builder, "y", src[i]);
+
+ iter = g_variant_new("ay", builder);
+
+ g_variant_builder_unref(builder);
+ return iter;
+}
+
+GVariant *WifiDirectPeer::getPeerGvariant()
+{
+ GVariantBuilder builder_peer;
+
+ g_variant_builder_init(&builder_peer, G_VARIANT_TYPE("a{sv}"));
+
+ g_variant_builder_add(&builder_peer, "{sv}",
+ "DeviceName",
+ g_variant_new_string(this->device_name_.c_str()));
+ g_variant_builder_add(&builder_peer, "{sv}",
+ "DeviceAddress",
+ this->packGVariantAy(this->device_addr_, MACADDR_LEN));
+ g_variant_builder_add(&builder_peer, "{sv}",
+ "InterfaceAddress",
+ this->packGVariantAy(this->iface_addr_, MACADDR_LEN));
+ g_variant_builder_add(&builder_peer, "{sv}",
+ "IPAddress",
+ this->packGVariantAy(this->ip_addr_, IPADDR_LEN));
+ g_variant_builder_add(&builder_peer, "{sv}",
+ "Channel",
+ g_variant_new_uint16(this->channel_));
+
+ g_variant_builder_add(&builder_peer, "{sv}",
+ "IsGroupOwner",
+ g_variant_new_boolean(this->dev_role_ == WFD_OEM_DEV_ROLE_GO));
+ g_variant_builder_add(&builder_peer, "{sv}",
+ "IsPersistentGO",
+ g_variant_new_boolean(this->group_flag_ & WFD_OEM_GROUP_FLAG_PERSISTENT_GROUP));
+ g_variant_builder_add(&builder_peer, "{sv}",
+ "IsConnected",
+ g_variant_new_boolean(this->dev_role_ == WFD_OEM_DEV_ROLE_GC));
+ g_variant_builder_add(&builder_peer, "{sv}",
+ "WpsDevicePwdID",
+ g_variant_new_uint16(0));
+ g_variant_builder_add(&builder_peer, "{sv}",
+ "WpsCfgMethods",
+ g_variant_new_uint16(this->config_methods_));
+ g_variant_builder_add(&builder_peer, "{sv}",
+ "Category",
+ g_variant_new_uint16(this->pri_dev_type_));
+ g_variant_builder_add(&builder_peer, "{sv}",
+ "SubCategory",
+ g_variant_new_uint16(this->sec_dev_type_));
+ g_variant_builder_add(&builder_peer, "{sv}",
+ "IsWfdDevice",
+ g_variant_new_boolean(this->is_wfd_device_));
+
+ return g_variant_builder_end(&builder_peer);
+}
+
+GVariantBuilder *WifiDirectPeer::getPeerGvariantBuilder()
+{
+ GVariantBuilder *builder_peer = NULL;
+
+ builder_peer = g_variant_builder_new(G_VARIANT_TYPE("a{sv}"));
+ g_variant_builder_add(builder_peer, "{sv}",
+ "DeviceName",
+ g_variant_new_string(this->device_name_.c_str()));
+ g_variant_builder_add(builder_peer, "{sv}",
+ "DeviceAddress",
+ this->packGVariantAy(this->device_addr_, MACADDR_LEN));
+ g_variant_builder_add(builder_peer, "{sv}",
+ "InterfaceAddress",
+ this->packGVariantAy(this->iface_addr_, MACADDR_LEN));
+ g_variant_builder_add(builder_peer, "{sv}",
+ "IPAddress",
+ this->packGVariantAy(this->ip_addr_, IPADDR_LEN));
+ g_variant_builder_add(builder_peer, "{sv}",
+ "Channel",
+ g_variant_new_uint16(this->channel_));
+
+ g_variant_builder_add(builder_peer, "{sv}",
+ "IsGroupOwner",
+ g_variant_new_boolean(this->dev_role_ == WFD_OEM_DEV_ROLE_GO));
+ g_variant_builder_add(builder_peer, "{sv}",
+ "IsPersistentGO",
+ g_variant_new_boolean(this->group_flag_ & WFD_OEM_GROUP_FLAG_PERSISTENT_GROUP));
+ g_variant_builder_add(builder_peer, "{sv}",
+ "IsConnected",
+ g_variant_new_boolean(this->dev_role_ == WFD_OEM_DEV_ROLE_GC));
+ g_variant_builder_add(builder_peer, "{sv}",
+ "WpsDevicePwdID",
+ g_variant_new_uint16(0));
+ g_variant_builder_add(builder_peer, "{sv}",
+ "WpsCfgMethods",
+ g_variant_new_uint16(this->config_methods_));
+ g_variant_builder_add(builder_peer, "{sv}",
+ "Category",
+ g_variant_new_uint16(this->pri_dev_type_));
+ g_variant_builder_add(builder_peer, "{sv}",
+ "SubCategory",
+ g_variant_new_uint16(this->sec_dev_type_));
+ g_variant_builder_add(builder_peer, "{sv}",
+ "IsWfdDevice",
+ g_variant_new_boolean(this->is_wfd_device_));
+
+ return builder_peer;
+}
--- /dev/null
+/*
+ * Copyright (c) 2020 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.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://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "WifiDirectSignal.h"
+
+using namespace WifiDirectManagerNamespace;
+
+
+std::string WifiDirectSignal::getName()
+{
+ return this->member_;
+}
+
+void WifiDirectSignal::generate(GVariant *parameters)
+{
+ this->callback_(nullptr, nullptr, nullptr, nullptr, this->member_.c_str(), parameters, this->user_data_);
+ return;
+}
--- /dev/null
+//
+// Copyright (c) 2020 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.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://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+#include <stdio.h>
+#include <stdarg.h>
+
+#ifndef API
+#define API __attribute__ ((visibility("default")))
+#endif
+
+typedef enum {
+ LOG_ID_INVALID = -1,
+ LOG_ID_MAIN,
+ LOG_ID_RADIO,
+ LOG_ID_SYSTEM,
+ LOG_ID_APPS,
+ LOG_ID_KMSG,
+ LOG_ID_SYSLOG,
+ LOG_ID_MAX
+} log_id_t;
+
+API int __dlog_print(log_id_t log_id, int prio, const char *tag, const char *fmt, ...)
+{
+ va_list ap;
+ va_start(ap, fmt);
+ vprintf(fmt, ap);
+ va_end(ap);
+ printf("\n");
+
+ return 0;
+}
--- /dev/null
+//
+// Copyright (c) 2020 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.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://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+#include <glib.h>
+#include <gio/gio.h>
+
+#include "wifi-direct.h"
+
+#include "mock_gdbus.h"
+#include "wifi_direct_manager_mock.h"
+
+#ifndef API
+#define API __attribute__ ((visibility("default")))
+#endif
+
+static bool mock_gdbus_sync_result = true;
+static bool mock_gdbus_call_sync_result = true;
+
+static GHashTable *map_id_to_signal_data = NULL;
+
+static volatile guint _global_subscriber_id = 1;
+
+typedef struct
+{
+ GDBusSignalCallback callback;
+ gpointer user_data;
+ guint id;
+} SignalSubscriber;
+
+typedef struct
+{
+ gchar *sender;
+ gchar *interface_name;
+ gchar *member;
+ gchar *object_path;
+ gchar *arg0;
+ GDBusSignalFlags flags;
+ SignalSubscriber *subscriber;
+} SignalData;
+
+static void __signal_data_destroy(gpointer data)
+{
+ SignalData *signal_data = (SignalData *)data;
+ g_free(signal_data->sender);
+ g_free(signal_data->interface_name);
+ g_free(signal_data->member);
+ g_free(signal_data->object_path);
+ g_free(signal_data->arg0);
+ g_free(signal_data->subscriber);
+ g_free(signal_data);
+}
+
+static GDBusConnection *get_uninitialized_connection(GBusType bus_type,
+ GCancellable *cancellable,
+ GError **error)
+{
+ return g_object_new(G_TYPE_DBUS_CONNECTION,
+ "address", "temporal_address",
+ "flags", G_DBUS_CONNECTION_FLAGS_AUTHENTICATION_CLIENT |
+ G_DBUS_CONNECTION_FLAGS_MESSAGE_BUS_CONNECTION,
+ "exit-on-close", TRUE,
+ NULL);
+}
+
+void mock_gdbus_gdbus_sync_enable(bool value)
+{
+ mock_gdbus_sync_result = value;
+}
+
+API GDBusConnection *g_bus_get_sync(GBusType bus_type, GCancellable *cancellable, GError **error)
+{
+ if (!mock_gdbus_sync_result) {
+ g_set_error(error,
+ G_IO_ERROR,
+ G_IO_ERROR_FAILED,
+ "MOCK g_bus_get_sync Error");
+ return NULL;
+ }
+
+ map_id_to_signal_data = g_hash_table_new_full(g_direct_hash,
+ g_direct_equal, NULL, __signal_data_destroy);
+
+ return get_uninitialized_connection(bus_type, cancellable, error);
+}
+
+API guint
+g_dbus_connection_signal_subscribe (GDBusConnection *connection,
+ const gchar *sender,
+ const gchar *interface_name,
+ const gchar *member,
+ const gchar *object_path,
+ const gchar *arg0,
+ GDBusSignalFlags flags,
+ GDBusSignalCallback callback,
+ gpointer user_data,
+ GDestroyNotify user_data_free_func)
+{
+ SignalData *signal_data;
+ SignalSubscriber *subscriber;
+
+ subscriber = g_new0(SignalSubscriber, 1);
+ subscriber->callback = callback;
+ subscriber->user_data = user_data;
+ subscriber->id = g_atomic_int_add (&_global_subscriber_id, 1); /* TODO: overflow etc. */
+
+ signal_data = g_new0(SignalData, 1);
+ signal_data->sender = g_strdup (sender);
+ signal_data->interface_name = g_strdup (interface_name);
+ signal_data->member = g_strdup (member);
+ signal_data->object_path = g_strdup (object_path);
+ signal_data->arg0 = g_strdup (arg0);
+ signal_data->flags = flags;
+ signal_data->subscriber = subscriber;
+
+ g_hash_table_insert(map_id_to_signal_data,
+ GUINT_TO_POINTER (subscriber->id),
+ signal_data);
+
+ wifi_direct_manager_mock_gdbus_signal_subscribe(subscriber->id,
+ member,
+ callback,
+ user_data);
+
+ return subscriber->id;
+}
+
+API void
+g_dbus_connection_signal_unsubscribe (GDBusConnection *connection,
+ guint subscription_id)
+{
+ wifi_direct_manager_mock_gdbus_signal_unsubscribe(subscription_id);
+
+ g_hash_table_remove(map_id_to_signal_data,
+ GUINT_TO_POINTER (subscription_id));
+
+ if (g_hash_table_size(map_id_to_signal_data) == 0)
+ g_hash_table_destroy(map_id_to_signal_data);
+
+}
+
+void mock_gdbus_gdbus_call_sync_enable(bool value)
+{
+ mock_gdbus_call_sync_result = value;
+}
+
+API GVariant *g_dbus_connection_call_sync(GDBusConnection *connection,
+ const gchar *bus_name,
+ const gchar *object_path,
+ const gchar *interface_name,
+ const gchar *method_name,
+ GVariant *parameters,
+ const GVariantType *reply_type,
+ GDBusCallFlags flags,
+ gint timeout_msec,
+ GCancellable *cancellable,
+ GError **error)
+{
+ GVariant *ret;
+ if (!mock_gdbus_call_sync_result) {
+ if (parameters)
+ g_variant_unref(parameters);
+ g_set_error(error,
+ G_IO_ERROR,
+ G_IO_ERROR_FAILED,
+ "MOCK g_dbus_connection_call_sync Error");
+ return NULL;
+ }
+
+ ret = wifi_direct_manager_mock_gdbus_call_sync(method_name, parameters, error);
+ if (ret == NULL && *error == NULL) {
+ g_set_error(error,
+ G_DBUS_ERROR,
+ G_DBUS_ERROR_UNKNOWN_METHOD,
+ "org.freedesktop.DBus does not understand message %s", method_name);
+ return NULL;
+ }
+
+ return ret;
+}
--- /dev/null
+/*
+ * Copyright (c) 2020 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.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://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+#include <stdbool.h>
+#include <system_info.h>
+
+#include "mock_sysinfo.h"
+
+#ifndef API
+#define API __attribute__ ((visibility("default")))
+#endif
+
+static bool mock_sysinfo_result = true;
+
+void mock_sysinfo_set_up_wifi_direct(bool value)
+{
+ mock_sysinfo_result = value;
+}
+
+API int __wrap_system_info_get_platform_bool(const char *key, bool *value)
+{
+ *value = mock_sysinfo_result;
+ return SYSTEM_INFO_ERROR_NONE;
+}
--- /dev/null
+/*
+ * Copyright (c) 2020 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.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://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <vconf.h>
+
+#ifndef API
+#define API __attribute__ ((visibility("default")))
+#endif
+
+API int vconf_notify_key_changed(const char *key, vconf_callback_fn cb,
+ void *user_data)
+{
+ return 0;
+}
+
+API int vconf_ignore_key_changed(const char *key, vconf_callback_fn cb)
+{
+ return 0;
+}
+
+API int vconf_get_int(const char *key, int *intval)
+{
+ *intval = 0;
+ return 0;
+}
--- /dev/null
+/*
+ * Copyright (c) 2020 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.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://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "wifi-direct.h"
+
+#include "WifiDirectSignal.h"
+#include "WifiDirectManager.h"
+
+#include "wifi_direct_manager_mock.h"
+
+using namespace WifiDirectManagerNamespace;
+
+WifiDirectManager *p_wfd_mgr_mock;
+std::map<std::string, WifiDirectSignal *> signal_map_with_name;
+std::map<unsigned int, WifiDirectSignal *> signal_map_with_id;
+
+void wifi_direct_manager_mock_init()
+{
+ p_wfd_mgr_mock = new WifiDirectManager();
+}
+
+void wifi_direct_manager_mock_deinit()
+{
+ delete p_wfd_mgr_mock;
+}
+
+GVariant *wifi_direct_manager_mock_gdbus_call_sync(const gchar *method_name,
+ GVariant *parameters,
+ GError **error)
+{
+ GVariant *ret;
+
+ ret = p_wfd_mgr_mock->callMethod(method_name, parameters, error);
+ if (parameters)
+ g_variant_unref(parameters);
+
+ return ret;
+}
+
+void wifi_direct_manager_mock_gdbus_signal_subscribe(
+ guint id,
+ const gchar *member,
+ GDBusSignalCallback callback,
+ gpointer user_data)
+{
+ WifiDirectSignal *signal = new WifiDirectSignal(id, member, callback, user_data);
+
+ signal_map_with_name[signal->getName()] = signal;
+ signal_map_with_id[id] = signal;
+ return;
+}
+
+void wifi_direct_manager_mock_gdbus_signal_unsubscribe(guint id)
+{
+ WifiDirectSignal *signal = signal_map_with_id[id];
+ signal_map_with_id.erase(id);
+ signal_map_with_name.erase(signal->getName());
+ delete signal;
+
+ return;
+}
+
+void wifi_direct_manager_mock_generate_activation_signal()
+{
+ std::string signal_name = std::string("Activation");
+ WifiDirectSignal *signal = signal_map_with_name[signal_name];
+ GVariant *signal_parameter = p_wfd_mgr_mock->activated();
+
+ signal->generate(signal_parameter);
+
+ g_variant_unref(signal_parameter);
+
+ return;
+}
+
+void wifi_direct_manager_mock_generate_deactivation_signal()
+{
+ std::string signal_name = std::string("Deactivation");
+ WifiDirectSignal *signal = signal_map_with_name[signal_name];
+ GVariant *signal_parameter = p_wfd_mgr_mock->deactivated();
+
+ signal->generate(signal_parameter);
+
+ g_variant_unref(signal_parameter);
+}
+
+void wifi_direct_manager_mock_generate_listen_started_signal()
+{
+ std::string signal_name = std::string("ListenStarted");
+ WifiDirectSignal *signal = signal_map_with_name[signal_name];
+ signal->generate(NULL);
+}
+
+void wifi_direct_manager_mock_generate_discovery_started_signal()
+{
+ std::string signal_name = std::string("DiscoveryStarted");
+ WifiDirectSignal *signal = signal_map_with_name[signal_name];
+ signal->generate(NULL);
+}
+
+void wifi_direct_manager_mock_generate_discovery_finished_signal()
+{
+ std::string signal_name = std::string("DiscoveryFinished");
+ WifiDirectSignal *signal = signal_map_with_name[signal_name];
+ signal->generate(NULL);
+}
+
+void wifi_direct_manager_mock_generate_peer_found_signal()
+{
+ std::string signal_name = std::string("PeerFound");
+ WifiDirectSignal *signal = signal_map_with_name[signal_name];
+ GVariant *signal_parameter = p_wfd_mgr_mock->peerFound();
+
+ signal->generate(signal_parameter);
+
+ g_variant_unref(signal_parameter);
+
+ return;
+}
+
+void wifi_direct_manager_mock_generate_peer_lost_signal()
+{
+ std::string signal_name = std::string("PeerLost");
+ WifiDirectSignal *signal = signal_map_with_name[signal_name];
+ GVariant *signal_parameter = p_wfd_mgr_mock->peerLost();
+
+ signal->generate(signal_parameter);
+
+ g_variant_unref(signal_parameter);
+}
+
+void wifi_direct_manager_mock_generate_created_signal()
+{
+ std::string signal_name = std::string("Created");
+ WifiDirectSignal *signal = signal_map_with_name[signal_name];
+ signal->generate(NULL);
+}
+
+void wifi_direct_manager_mock_generate_destroyed_signal()
+{
+ std::string signal_name = std::string("Destroyed");
+ WifiDirectSignal *signal = signal_map_with_name[signal_name];
+ signal->generate(NULL);
+}
+
+void wifi_direct_manager_mock_generate_connection_in_progress_signal()
+{
+ std::string signal_name = std::string("Connection");
+ WifiDirectSignal *signal = signal_map_with_name[signal_name];
+ GVariant *signal_parameter = p_wfd_mgr_mock->connectionInProgress();
+
+ signal->generate(signal_parameter);
+
+ g_variant_unref(signal_parameter);
+}
+
+void wifi_direct_manager_mock_generate_connection_rsp_with_no_error_go_signal()
+{
+ std::string signal_name = std::string("Connection");
+ WifiDirectSignal *signal = signal_map_with_name[signal_name];
+ GVariant *signal_parameter = p_wfd_mgr_mock->connectionRspWithNoErrorGO();
+
+ signal->generate(signal_parameter);
+
+ g_variant_unref(signal_parameter);
+}
+
+void wifi_direct_manager_mock_generate_peer_ip_assigned_signal()
+{
+ std::string signal_name = std::string("PeerIPAssigned");
+ WifiDirectSignal *signal = signal_map_with_name[signal_name];
+ GVariant *signal_parameter = p_wfd_mgr_mock->peerIpAssigned();
+
+ signal->generate(signal_parameter);
+
+ g_variant_unref(signal_parameter);
+}
+
+void wifi_direct_manager_mock_generate_disconnection_signal()
+{
+ std::string signal_name = std::string("Disconnection");
+ WifiDirectSignal *signal = signal_map_with_name[signal_name];
+ GVariant *signal_parameter = p_wfd_mgr_mock->disconnection();
+
+ signal->generate(signal_parameter);
+
+ g_variant_unref(signal_parameter);
+}
+
+void wifi_direct_manager_mock_generate_connection_request_pbc_signal()
+{
+ std::string signal_name = std::string("Connection");
+ WifiDirectSignal *signal = signal_map_with_name[signal_name];
+ GVariant *signal_parameter = p_wfd_mgr_mock->connectionRequestPbc();
+
+ signal->generate(signal_parameter);
+
+ g_variant_unref(signal_parameter);
+}
+
+void wifi_direct_manager_mock_generate_connection_canceled_signal()
+{
+ std::string signal_name = std::string("Connection");
+ WifiDirectSignal *signal = signal_map_with_name[signal_name];
+ GVariant *signal_parameter = p_wfd_mgr_mock->connectionCanceled();
+
+ signal->generate(signal_parameter);
+
+ g_variant_unref(signal_parameter);
+}