void wfd_manager_dbus_deinit(void);
-guint wfd_manager_dbus_iface_register(const gchar* iface_name,
- const gchar* iface_path,
- GDBusNodeInfo *node_info,
- const GDBusInterfaceVTable *interface_vtable);
-
gboolean wfd_manager_dbus_iface_unregister(guint reg_id);
gboolean wfd_manager_dbus_emit_signal(const gchar *interface_name,
const gchar *signal_name,
GVariant *parameters);
-
+void wfd_manager_dbus_return_err(int ret, GDBusMethodInvocation *invocation);
+void wfd_manager_dbus_reply_error_none(GDBusMethodInvocation *invocation);
+void wfd_manager_dbus_reply_params(GDBusMethodInvocation *invocation, GVariant *parameters);
GVariant* wfd_manager_dbus_pack_ay(const unsigned char *src, int size);
void wfd_manager_dbus_unregister_nameowner_signal(void);
+void wfd_manager_dbus_unregister(void);
+
#ifdef __cplusplus
}
#endif
extern "C" {
#endif
-gboolean wfd_manager_dbus_register(void);
-void wfd_manager_dbus_unregister(void);
+#include <gio/gio.h>
+int wfd_manager_iface_init();
+void wfd_manager_iface_deinit();
+
+void wfd_manager_iface_manage_handler(const char *method,
+ GVariant *parameters,
+ GDBusMethodInvocation *invocation);
+void wfd_manager_iface_group_handler(const char *method,
+ GVariant *parameters,
+ GDBusMethodInvocation *invocation);
+void wfd_manager_iface_config_handler(const char *method,
+ GVariant *parameters,
+ GDBusMethodInvocation *invocation);
+void wfd_manager_iface_service_handler(const char *method,
+ GVariant *parameters,
+ GDBusMethodInvocation *invocation);
+void wfd_manager_iface_display_handler(const char *method,
+ GVariant *parameters,
+ GDBusMethodInvocation *invocation);
+void wfd_manager_iface_asp_handler(const char *method,
+ GVariant *parameters,
+ GDBusMethodInvocation *invocation);
#ifdef __cplusplus
}
--- /dev/null
+/*
+ * Network Configuration Module
+ *
+ * Copyright (c) 2017 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.
+ *
+ */
+
+/**
+ * This file implements wifi direct manager method functions.
+ *
+ * @file wifi-direct-method.c
+ * @author Jiung Yu (jiung.yu@samsung.com)
+ * @version 0.1
+ */
+
+#ifndef __WIFI_DIRECT_METHOD_H__
+#define __WIFI_DIRECT_METHOD_H__
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+void activate_handler(GVariant *parameters, void *dest);
+void add_client_handler(GVariant *parameters, void *dest);
+void deactivate_handler(GVariant *parameters, void *dest);
+void start_discovery_handler(GVariant *parameters, void *dest);
+void stop_discovery_handler(GVariant *parameters, void *dest);
+void get_discovered_peer_handler(GVariant *parameters, void *dest);
+void connect_handler(GVariant *parameters, void *dest);
+void disconnect_handler(GVariant *parameters, void *dest);
+void cancel_connection_handler(GVariant *parameters, void *dest);
+void accept_connection_handler(GVariant *parameters, void *dest);
+void reject_connection_handler(GVariant *parameters, void *dest);
+void disconnect_all_handler(GVariant *parameters, void *dest);
+void get_connected_peers_handler(GVariant *parameters, void *dest);
+void get_connecting_peer_handler(GVariant *parameters, void *dest);
+void is_discoverable_handler(GVariant *parameters, void *dest);
+void is_listening_only_handler(GVariant *parameters, void *dest);
+void get_peer_info_handler(GVariant *parameters, void *dest);
+void get_state_handler(GVariant *parameters, void *dest);
+void create_group_handler(GVariant *parameters, void *dest);
+void destroy_group_handler(GVariant *parameters, void *dest);
+void is_group_owner_handler(GVariant *parameters, void *dest);
+void is_auto_group_handler(GVariant *parameters, void *dest);
+void activate_pushbutton_handler(GVariant *parameters, void *dest);
+void get_persistent_group_handler(GVariant *parameters, void *dest);
+void remove_persistent_group_handler(GVariant *parameters, void *dest);
+void set_passphrase_handler(GVariant *parameters, void *dest);
+void get_passphrase_handler(GVariant *parameters, void *dest);
+void set_persistent_group_handler(GVariant *parameters, void *dest);
+void is_persistent_group_enabled_handler(GVariant *parameters, void *dest);
+void get_device_name_handler(GVariant *parameters, void *dest);
+void set_device_name_handler(GVariant *parameters, void *dest);
+void get_wps_pin_handler(GVariant *parameters, void *dest);
+void set_wps_pin_handler(GVariant *parameters, void *dest);
+void generate_wps_pin_handler(GVariant *parameters, void *dest);
+void get_supported_wps_mode_handler(GVariant *parameters, void *dest);
+void get_req_wps_mode_handler(GVariant *parameters, void *dest);
+void set_req_wps_mode_handler(GVariant *parameters, void *dest);
+void get_local_wps_mode_handler(GVariant *parameters, void *dest);
+void get_ip_address_handler(GVariant *parameters, void *dest);
+void get_mac_address_handler(GVariant *parameters, void *dest);
+void get_go_intent_handler(GVariant *parameters, void *dest);
+void set_go_intent_handler(GVariant *parameters, void *dest);
+void get_max_client_handler(GVariant *parameters, void *dest);
+void set_max_client_handler(GVariant *parameters, void *dest);
+void set_autoconnection_mode_handler(GVariant *parameters, void *dest);
+void is_autoconnection_mode_handler(GVariant *parameters, void *dest);
+void get_operating_channel_handler(GVariant *parameters, void *dest);
+void set_autoconnection_peer_handler(GVariant *parameters, void *dest);
+void get_interface_name_handler(GVariant *parameters, void *dest);
+void get_subnet_mask_handler(GVariant *parameters, void *dest);
+void get_gateway_handler(GVariant *parameters, void *dest);
+void get_session_timer_handler(GVariant *parameters, void *dest);
+void set_session_timer_handler(GVariant *parameters, void *dest);
+void get_auto_group_removal_handler(GVariant *parameters, void *dest);
+void get_primary_dev_type_handler(GVariant *parameters, void *dest);
+void get_secondary_dev_type_handler(GVariant *parameters, void *dest);
+void get_peer_rssi_handler(GVariant *parameters, void *dest);
+void add_vsie_handler(GVariant *parameters, void *dest);
+void get_vsie_handler(GVariant *parameters, void *dest);
+void remove_vsie_handler(GVariant *parameters, void *dest);
+void srv_start_discovery_handler(GVariant *parameters, void *dest);
+void srv_stop_discovery_handler(GVariant *parameters, void *dest);
+void srv_register_handler(GVariant *parameters, void *dest);
+void srv_deregister_handler(GVariant *parameters, void *dest);
+void display_init_handler(GVariant *parameters, void *dest);
+void display_deinit_handler(GVariant *parameters, void *dest);
+void display_set_config_handler(GVariant *parameters, void *dest);
+void display_set_avail_handler(GVariant *parameters, void *dest);
+void display_get_peer_type_handler(GVariant *parameters, void *dest);
+void display_get_peer_avail_handler(GVariant *parameters, void *dest);
+void display_get_peer_hdcp_handler(GVariant *parameters, void *dest);
+void display_get_peer_port_handler(GVariant *parameters, void *dest);
+void display_get_peer_throughput_handler(GVariant *parameters, void *dest);
+void advertise_service_handler(GVariant *parameters, void *dest);
+void cancel_advertise_service_handler(GVariant *parameters, void *dest);
+void seek_service_handler(GVariant *parameters, void *dest);
+void cancel_seek_service_handler(GVariant *parameters, void *dest);
+void connect_sessoin_handler(GVariant *parameters, void *dest);
+void confirm_sessoin_handler(GVariant *parameters, void *dest);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __WIFI_DIRECT_METHOD_H__ */
Name: wifi-direct-manager
Summary: Wi-Fi Direct manger
-Version: 1.2.259
+Version: 1.2.260
Release: 1
Group: Network & Connectivity/Wireless
License: Apache-2.0
#include "wifi-direct-ipc.h"
#include "wifi-direct-manager.h"
+/* introspection xml to register interfaces */
+const gchar wfd_manager_introspection_xml[] = {
+ "<node name='/net/wifidirect'>"
+ "<interface name='net.wifidirect'>"
+ "<method name='Activate'>"
+ "<arg type='i' name='error_code' direction='out'/>"
+ "</method>"
+ "<method name='AddClient'>"
+ "<arg type='i' name='result' direction='out'/>"
+ "</method>"
+ "<method name='Deactivate'>"
+ "<arg type='i' name='error_code' direction='out'/>"
+ "</method>"
+ "<method name='StartDiscovery'>"
+ "<arg type='a{sv}' name='parameters' direction='in'/>"
+ "<arg type='i' name='error_code' direction='out'/>"
+ "</method>"
+ "<method name='StopDiscovery'>"
+ "<arg type='i' name='error_code' direction='out'/>"
+ "</method>"
+ "<method name='GetDiscoveredPeers'>"
+ "<arg type='i' name='error_code' direction='out'/>"
+ "<arg type='aa{sv}' name='peer_details_list' direction='out'/>"
+ "</method>"
+ "<method name='Connect'>"
+ "<arg type='s' name='mac_address' direction='in'/>"
+ "<arg type='i' name='error_code' direction='out'/>"
+ "</method>"
+ "<method name='Disconnect'>"
+ "<arg type='s' name='mac_address' direction='in'/>"
+ "<arg type='i' name='error_code' direction='out'/>"
+ "</method>"
+ "<method name='CancelConnection'>"
+ "<arg type='s' name='mac_address' direction='in'/>"
+ "<arg type='i' name='error_code' direction='out'/>"
+ "</method>"
+ "<method name='AcceptConnection'>"
+ "<arg type='s' name='mac_address' direction='in'/>"
+ "<arg type='i' name='error_code' direction='out'/>"
+ "</method>"
+ "<method name='RejectConnection'>"
+ "<arg type='s' name='mac_address' direction='in'/>"
+ "<arg type='i' name='error_code' direction='out'/>"
+ "</method>"
+ "<method name='DisconnectAll'>"
+ "<arg type='i' name='error_code' direction='out'/>"
+ "</method>"
+ "<method name='GetConnectedPeers'>"
+ "<arg type='i' name='error_code' direction='out'/>"
+ "<arg type='aa{sv}' name='peer_details_list' direction='out'/>"
+ "</method>"
+ "<method name='GetConnectingPeer'>"
+ "<arg type='i' name='error_code' direction='out'/>"
+ "<arg type='a{sv}' name='peer_details' direction='out'/>"
+ "</method>"
+ "<method name='IsDiscoverable'>"
+ "<arg type='b' name='result' direction='out'/>"
+ "</method>"
+ "<method name='IsListeningOnly'>"
+ "<arg type='b' name='result' direction='out'/>"
+ "</method>"
+ "<method name='GetPeerInfo'>"
+ "<arg type='s' name='mac_address' direction='in'/>"
+ "<arg type='i' name='error_code' direction='out'/>"
+ "<arg type='a{sv}' name='peer_details' direction='out'/>"
+ "</method>"
+ "<method name='GetState'>"
+ "<arg type='i' name='error_code' direction='out'/>"
+ "<arg type='i' name='state' direction='out'/>"
+ "</method>"
+ "<signal name='Activation'>"
+ "<arg type='i' name='error_code'/>"
+ "</signal>"
+ "<signal name='Deactivation'>"
+ "<arg type='i' name='error_code'/>"
+ "</signal>"
+ "<signal name='Connection'>"
+ "<arg type='i' name='error_code'/>"
+ "<arg type='i' name='connection_state'/>"
+ "<arg type='s' name='peer_mac_address'/>"
+ "</signal>"
+ "<signal name='Disconnection'>"
+ "<arg type='i' name='error_code'/>"
+ "<arg type='i' name='connection_state'/>"
+ "<arg type='s' name='peer_mac_address'/>"
+ "</signal>"
+ "<signal name='ListenStarted'>"
+ "</signal>"
+ "<signal name='DiscoveryStarted'>"
+ "</signal>"
+ "<signal name='DiscoveryFinished'>"
+ "</signal>"
+ "<signal name='PeerFound'>"
+ "<arg type='s' name='peer_mac_address'/>"
+ "</signal>"
+ "<signal name='PeerLost'>"
+ "<arg type='s' name='peer_mac_address'/>"
+ "</signal>"
+ "<signal name='PeerIPAssigned'>"
+ "<arg type='s' name='peer_mac_address'/>"
+ "<arg type='s' name='assigned_ip_address'/>"
+ "</signal>"
+ "</interface>"
+ "<interface name='net.wifidirect.group'>"
+ "<method name='CreateGroup'>"
+ "<arg type='a{sv}' name='parameters' direction='in'/>"
+ "<arg type='i' name='error_code' direction='out'/>"
+ "</method>"
+ "<method name='DestroyGroup'>"
+ "<arg type='i' name='error_code' direction='out'/>"
+ "</method>"
+ "<method name='IsGroupOwner'>"
+ "<arg type='b' name='result' direction='out'/>"
+ "</method>"
+ "<method name='IsAutoGroup'>"
+ "<arg type='b' name='result' direction='out'/>"
+ "</method>"
+ "<method name='ActivatePushButton'>"
+ "<arg type='i' name='error_code' direction='out'/>"
+ "</method>"
+ "<method name='GetPersistentGroups'>"
+ "<arg type='i' name='error_code' direction='out'/>"
+ "<arg type='aa{sv}' name='result' direction='out'/>"
+ "</method>"
+ "<method name='RemovePersistentGroup'>"
+ "<arg type='s' name='mac_address' direction='in'/>"
+ "<arg type='s' name='ssid' direction='in'/>"
+ "<arg type='i' name='error_code' direction='out'/>"
+ "</method>"
+ "<method name='SetPassphrase'>"
+ "<arg type='s' name='passphrase' direction='in'/>"
+ "<arg type='i' name='error_code' direction='out'/>"
+ "</method>"
+ "<method name='GetPassphrase'>"
+ "<arg type='i' name='error_code' direction='out'/>"
+ "<arg type='s' name='passphrase' direction='out'/>"
+ "</method>"
+ "<method name='SetPersistentGroupEnabled'>"
+ "<arg type='b' name='enable' direction='in'/>"
+ "<arg type='i' name='error_code' direction='out'/>"
+ "</method>"
+ "<method name='IsPersistentGroupEnabled'>"
+ "<arg type='b' name='result' direction='out'/>"
+ "</method>"
+ "<signal name='Created'>"
+ "</signal>"
+ "<signal name='Destroyed'>"
+ "</signal>"
+ "</interface>"
+ "<interface name='net.wifidirect.config'>"
+ "<method name='GetDeviceName'>"
+ "<arg type='i' name='error_code' direction='out'/>"
+ "<arg type='s' name='device_name' direction='out'/>"
+ "</method>"
+ "<method name='SetDeviceName'>"
+ "<arg type='s' name='device_name' direction='in'/>"
+ "<arg type='i' name='error_code' direction='out'/>"
+ "</method>"
+ "<method name='SetWpsPin'>"
+ "<arg type='s' name='wps_pin' direction='in'/>"
+ "<arg type='i' name='error_code' direction='out'/>"
+ "</method>"
+ "<method name='GetWpsPin'>"
+ "<arg type='i' name='error_code' direction='out'/>"
+ "<arg type='s' name='wps_pin' direction='out'/>"
+ "</method>"
+ "<method name='GenerateWpsPin'>"
+ "<arg type='i' name='error_code' direction='out'/>"
+ "<arg type='s' name='wps_pin' direction='out'/>"
+ "</method>"
+ "<method name='GetSupportedWpsMode'>"
+ "<arg type='i' name='error_code' direction='out'/>"
+ "<arg type='i' name='config_methods' direction='out'/>"
+ "</method>"
+ "<method name='GetReqWpsMode'>"
+ "<arg type='i' name='error_code' direction='out'/>"
+ "<arg type='i' name='req_wps_mode' direction='out'/>"
+ "</method>"
+ "<method name='SetReqWpsMode'>"
+ "<arg type='i' name='req_wps_mode' direction='in'/>"
+ "<arg type='i' name='error_code' direction='out'/>"
+ "</method>"
+ "<method name='GetLocalWpsMode'>"
+ "<arg type='i' name='error_code' direction='out'/>"
+ "<arg type='i' name='local_wps_mode' direction='out'/>"
+ "</method>"
+ "<method name='GetIPAddress'>"
+ "<arg type='i' name='error_code' direction='out'/>"
+ "<arg type='s' name='local_ip_address' direction='out'/>"
+ "</method>"
+ "<method name='GetMacAddress'>"
+ "<arg type='i' name='error_code' direction='out'/>"
+ "<arg type='s' name='local_mac_address' direction='out'/>"
+ "</method>"
+ "<method name='GetGoIntent'>"
+ "<arg type='i' name='error_code' direction='out'/>"
+ "<arg type='i' name='go_intent' direction='out'/>"
+ "</method>"
+ "<method name='SetGoIntent'>"
+ "<arg type='i' name='go_intent' direction='in'/>"
+ "<arg type='i' name='error_code' direction='out'/>"
+ "</method>"
+ "<method name='GetMaxClient'>"
+ "<arg type='i' name='error_code' direction='out'/>"
+ "<arg type='i' name='max_client' direction='out'/>"
+ "</method>"
+ "<method name='SetMaxClient'>"
+ "<arg type='i' name='max_client' direction='in'/>"
+ "<arg type='i' name='error_code' direction='out'/>"
+ "</method>"
+ "<method name='SetAutoConnectionMode'>"
+ "<arg type='b' name='auto_connection_mode' direction='in'/>"
+ "<arg type='i' name='error_code' direction='out'/>"
+ "</method>"
+ "<method name='IsAutoConnectionMode'>"
+ "<arg type='i' name='error_code' direction='out'/>"
+ "<arg type='b' name='result' direction='out'/>"
+ "</method>"
+ "<method name='GetOperatingChannel'>"
+ "<arg type='i' name='error_code' direction='out'/>"
+ "<arg type='i' name='operating_channel' direction='out'/>"
+ "</method>"
+ "<method name='SetAutoConnectionPeer'>"
+ "<arg type='s' name='peer_mac_address' direction='in'/>"
+ "<arg type='i' name='error_code' direction='out'/>"
+ "</method>"
+ "<method name='GetConnectingPeer'>"
+ "<arg type='i' name='error_code' direction='out'/>"
+ "<arg type='s' name='local_mac_address' direction='out'/>"
+ "</method>"
+ "<method name='GetInterfaceName'>"
+ "<arg type='i' name='error_code' direction='out'/>"
+ "<arg type='s' name='ifname' direction='out'/>"
+ "</method>"
+ "<method name='GetSubnetMask'>"
+ "<arg type='i' name='error_code' direction='out'/>"
+ "<arg type='s' name='subnet_mask' direction='out'/>"
+ "</method>"
+ "<method name='GetGateway'>"
+ "<arg type='i' name='error_code' direction='out'/>"
+ "<arg type='s' name='gateway_address' direction='out'/>"
+ "</method>"
+ "<method name='GetSessionTimer'>"
+ "<arg type='i' name='error_code' direction='out'/>"
+ "<arg type='i' name='session_timer' direction='out'/>"
+ "</method>"
+ "<method name='SetSessionTimer'>"
+ "<arg type='i' name='session_timer' direction='in'/>"
+ "<arg type='i' name='error_code' direction='out'/>"
+ "</method>"
+ "<method name='SetAutoGroupRemoval'>"
+ "<arg type='b' name='enable' direction='in'/>"
+ "<arg type='i' name='error_code' direction='out'/>"
+ "</method>"
+ "<method name='GetPrimaryDevType'>"
+ "<arg type='i' name='pri_dev_type' direction='out'/>"
+ "<arg type='i' name='error_code' direction='out'/>"
+ "</method>"
+ "<method name='GetSecondaryDevType'>"
+ "<arg type='i' name='sec_dev_type' direction='out'/>"
+ "<arg type='i' name='error_code' direction='out'/>"
+ "</method>"
+ "<method name='GetPeerRssi'>"
+ "<arg type='s' name='peer_mac_addr' direction='in'/>"
+ "<arg type='i' name='error_code' direction='out'/>"
+ "<arg type='i' name='rssi' direction='out'/>"
+ "</method>"
+ "<method name='AddVsie'>"
+ "<arg type='i' name='frame_id' direction='in'/>"
+ "<arg type='s' name='vsie' direction='in'/>"
+ "<arg type='i' name='error_code' direction='out'/>"
+ "</method>"
+ "<method name='GetVsie'>"
+ "<arg type='i' name='frame_id' direction='in'/>"
+ "<arg type='i' name='error_code' direction='out'/>"
+ "<arg type='s' name='vsie' direction='out'/>"
+ "</method>"
+ "<method name='RemoveVsie'>"
+ "<arg type='i' name='frame_id' direction='in'/>"
+ "<arg type='s' name='vsie' direction='in'/>"
+ "<arg type='i' name='error_code' direction='out'/>"
+ "</method>"
+ "</interface>"
+ "<interface name='net.wifidirect.service'>"
+ "<method name='StartDiscovery'>"
+ "<arg type='i' name='service_type' direction='in'/>"
+ "<arg type='s' name='mac_addr' direction='in'/>"
+ "<arg type='i' name='error_code' direction='out'/>"
+ "</method>"
+ "<method name='StopDiscovery'>"
+ "<arg type='i' name='service_type' direction='in'/>"
+ "<arg type='s' name='mac_addr' direction='in'/>"
+ "<arg type='i' name='error_code' direction='out'/>"
+ "</method>"
+ "<method name='Register'>"
+ "<arg type='i' name='service_type' direction='in'/>"
+ "<arg type='s' name='info_string' direction='in'/>"
+ "<arg type='i' name='error_code' direction='out'/>"
+ "<arg type='i' name='service_id' direction='out'/>"
+ "</method>"
+ "<method name='Deregister'>"
+ "<arg type='i' name='service_id' direction='in'/>"
+ "<arg type='i' name='error_code' direction='out'/>"
+ "</method>"
+ "<signal name='DiscoveryStarted'>"
+ "</signal>"
+ "<signal name='DiscoveryFound'>"
+ "<arg type='i' name='service_type'/>"
+ "<arg type='s' name='response_data'/>"
+ "<arg type='s' name='peer_mac_address'/>"
+ "</signal>"
+ "<signal name='DiscoveryFinished'>"
+ "</signal>"
+ "</interface>"
+ "<interface name='net.wifidirect.display'>"
+ "<method name='Init'>"
+ "<arg type='i' name='error_code' direction='out'/>"
+ "</method>"
+ "<method name='Deinit'>"
+ "<arg type='i' name='error_code' direction='out'/>"
+ "</method>"
+ "<method name='SetConfig'>"
+ "<arg type='i' name='type' direction='in'/>"
+ "<arg type='i' name='port' direction='in'/>"
+ "<arg type='i' name='hdcp' direction='in'/>"
+ "<arg type='i' name='error_code' direction='out'/>"
+ "</method>"
+ "<method name='SetAvailiability'>"
+ "<arg type='i' name='availability' direction='in'/>"
+ "<arg type='i' name='error_code' direction='out'/>"
+ "</method>"
+ "<method name='GetPeerType'>"
+ "<arg type='s' name='peer_mac_addr' direction='in'/>"
+ "<arg type='i' name='error_code' direction='out'/>"
+ "<arg type='i' name='result' direction='out'/>"
+ "</method>"
+ "<method name='GetPeerAvailability'>"
+ "<arg type='s' name='peer_mac_addr' direction='in'/>"
+ "<arg type='i' name='error_code' direction='out'/>"
+ "<arg type='i' name='result' direction='out'/>"
+ "</method>"
+ "<method name='GetPeerHdcp'>"
+ "<arg type='s' name='peer_mac_addr' direction='in'/>"
+ "<arg type='i' name='error_code' direction='out'/>"
+ "<arg type='i' name='result' direction='out'/>"
+ "</method>"
+ "<method name='GetPeerPort'>"
+ "<arg type='s' name='peer_mac_addr' direction='in'/>"
+ "<arg type='i' name='error_code' direction='out'/>"
+ "<arg type='i' name='result' direction='out'/>"
+ "</method>"
+ "<method name='GetPeerThroughput'>"
+ "<arg type='s' name='peer_mac_addr' direction='in'/>"
+ "<arg type='i' name='error_code' direction='out'/>"
+ "<arg type='i' name='result' direction='out'/>"
+ "</method>"
+ "</interface>"
+ "<interface name='net.wifidirect.asp'>"
+ "<method name='AdvertiseService'>"
+ "<arg type='a{sv}' name='parameters' direction='in'/>"
+ "<arg type='i' name='result' direction='out'/>"
+ "</method>"
+ "<method name='CancelAdvertiseService'>"
+ "<arg type='u' name='adv_id' direction='in'/>"
+ "<arg type='i' name='result' direction='out'/>"
+ "</method>"
+ "<method name='SeekService'>"
+ "<arg type='a{sv}' name='parameters' direction='in'/>"
+ "<arg type='i' name='result' direction='out'/>"
+ "</method>"
+ "<method name='CancelSeekService'>"
+ "<arg type='t' name='search_id' direction='in'/>"
+ "<arg type='i' name='result' direction='out'/>"
+ "</method>"
+ "<method name='ConnectSession'>"
+ "<arg type='a{sv}' name='parameters' direction='in'/>"
+ "<arg type='i' name='result' direction='out'/>"
+ "</method>"
+ "<method name='ConfirmSession'>"
+ "<arg type='a{sv}' name='parameters' direction='in'/>"
+ "<arg type='i' name='result' direction='out'/>"
+ "</method>"
+ "<signal name='SearchResult'>"
+ "<arg type='a{sv}' name='parameters'/>"
+ "</signal>"
+ "<signal name='SessionRequest'>"
+ "<arg type='a{sv}' name='parameters'/>"
+ "</signal>"
+ "<signal name='SessionConfigRequest'>"
+ "<arg type='a{sv}' name='parameters'/>"
+ "</signal>"
+ "<signal name='ConnectStatus'>"
+ "<arg type='a{sv}' name='parameters'/>"
+ "</signal>"
+ "<signal name='SessionStatus'>"
+ "<arg type='a{sv}' name='parameters'/>"
+ "</signal>"
+ "<signal name='SessionPeerIPAssigned'>"
+ "<arg type='a{sv}' name='parameters'/>"
+ "</signal>"
+ "</interface>"
+ "</node>"
+};
+
static GDBusConnection *g_connection = NULL;
static guint g_owner_id = 0; /* Name Owner ID */
static int nameowner_changed_sub_id = 0;
+
static void wfd_manager_dbus_register_nameowner_signal(void);
static GDBusConnection *__dbus_get_gdbus_conn(void)
return g_connection;
}
-static void __on_bus_acquired(GDBusConnection *connection,
- const gchar *name,
- gpointer user_data)
+static void wfd_manger_dbus_manage_iface_handler(
+ GDBusConnection *connection,
+ const gchar *sender,
+ const gchar *object_path,
+ const gchar *interface_name,
+ const gchar *method_name,
+ GVariant *parameters,
+ GDBusMethodInvocation *invocation,
+ gpointer user_data)
{
- WDS_LOGD("on_bus_acquired: %s", name);
- wfd_manager_dbus_register_nameowner_signal();
- wfd_manager_dbus_register();
+ if (!g_strcmp0(method_name, "AddClient"))
+ wfd_manager_add_active_client(sender);
+
+ /* Method Call */
+ WDS_LOGD("interface : [%s], method : [%s]", interface_name, method_name);
+ DBUS_DEBUG_VARIANT(parameters);
+
+ wfd_manager_iface_manage_handler(method_name, parameters, invocation);
+
+ return;
}
-static void __on_name_acquired(GDBusConnection *connection,
- const gchar *name,
- gpointer user_data)
+static void wfd_manger_dbus_group_iface_handler(
+ GDBusConnection *connection,
+ const gchar *sender,
+ const gchar *object_path,
+ const gchar *interface_name,
+ const gchar *method_name,
+ GVariant *parameters,
+ GDBusMethodInvocation *invocation,
+ gpointer user_data)
{
- WDS_LOGD("on_name_acquired: %s", name);
+ /* Method Call */
+ WDS_LOGD("interface : [%s], method : [%s]", interface_name, method_name);
+ DBUS_DEBUG_VARIANT(parameters);
+
+ wfd_manager_iface_group_handler(method_name, parameters, invocation);
+ return;
}
-static void __on_name_lost(GDBusConnection *connection,
- const gchar *name,
- gpointer user_data)
+static void wfd_manger_dbus_config_iface_handler(
+ GDBusConnection *connection,
+ const gchar *sender,
+ const gchar *object_path,
+ const gchar *interface_name,
+ const gchar *method_name,
+ GVariant *parameters,
+ GDBusMethodInvocation *invocation,
+ gpointer user_data)
{
- WDS_LOGD("on_name_lost: %s", name);
+ /* Method Call */
+ WDS_LOGD("interface : [%s], method : [%s]", interface_name, method_name);
+ DBUS_DEBUG_VARIANT(parameters);
+
+ wfd_manager_iface_config_handler(method_name, parameters, invocation);
+ return;
+}
+
+static void wfd_manger_dbus_service_iface_handler(
+ GDBusConnection *connection,
+ const gchar *sender,
+ const gchar *object_path,
+ const gchar *interface_name,
+ const gchar *method_name,
+ GVariant *parameters,
+ GDBusMethodInvocation *invocation,
+ gpointer user_data)
+{
+ /* Method Call */
+ WDS_LOGD("interface : [%s], method : [%s]", interface_name, method_name);
+ DBUS_DEBUG_VARIANT(parameters);
+
+ wfd_manager_iface_service_handler(method_name, parameters, invocation);
+ return;
+}
+
+static void wfd_manger_dbus_display_iface_handler(
+ GDBusConnection *connection,
+ const gchar *sender,
+ const gchar *object_path,
+ const gchar *interface_name,
+ const gchar *method_name,
+ GVariant *parameters,
+ GDBusMethodInvocation *invocation,
+ gpointer user_data)
+{
+ /* Method Call */
+ WDS_LOGD("interface : [%s], method : [%s]", interface_name, method_name);
+ DBUS_DEBUG_VARIANT(parameters);
+
+ wfd_manager_iface_display_handler(method_name, parameters, invocation);
+ return;
+}
+
+static void wfd_manger_dbus_asp_iface_handler(
+ GDBusConnection *connection,
+ const gchar *sender,
+ const gchar *object_path,
+ const gchar *interface_name,
+ const gchar *method_name,
+ GVariant *parameters,
+ GDBusMethodInvocation *invocation,
+ gpointer user_data)
+{
+ /* Method Call */
+ WDS_LOGD("interface : [%s], method : [%s]", interface_name, method_name);
+ DBUS_DEBUG_VARIANT(parameters);
+
+ wfd_manager_iface_asp_handler(method_name, parameters, invocation);
+ return;
+}
+
+/* GDBus method handler */
+
+static const GDBusInterfaceVTable wfd_manager_dbus_manage_iface_vtable = {
+ wfd_manger_dbus_manage_iface_handler, NULL, NULL};
+
+static const GDBusInterfaceVTable wfd_manager_dbus_group_iface_vtable = {
+ wfd_manger_dbus_group_iface_handler, NULL, NULL};
+
+static const GDBusInterfaceVTable wfd_manager_dbus_config_iface_vtable = {
+ wfd_manger_dbus_config_iface_handler, NULL, NULL};
+
+static const GDBusInterfaceVTable wfd_manager_dbus_service_iface_vtable = {
+ wfd_manger_dbus_service_iface_handler, NULL, NULL};
+
+static const GDBusInterfaceVTable wfd_manager_dbus_display_iface_vtable = {
+ wfd_manger_dbus_display_iface_handler, NULL, NULL};
+
+static const GDBusInterfaceVTable wfd_manager_dbus_asp_iface_vtable = {
+ wfd_manger_dbus_asp_iface_handler, NULL, NULL};
+
+
+static struct {
+ guint reg_id;
+ const gchar *iface_name;
+ const GDBusInterfaceVTable *vtbl;
+} wfd_manager_iface_map[] = {
+ {
+ 0,
+ WFD_MANAGER_MANAGE_INTERFACE,
+ &wfd_manager_dbus_manage_iface_vtable
+ },
+ {
+ 0,
+ WFD_MANAGER_GROUP_INTERFACE,
+ &wfd_manager_dbus_group_iface_vtable
+ },
+ {
+ 0,
+ WFD_MANAGER_CONFIG_INTERFACE,
+ &wfd_manager_dbus_config_iface_vtable
+ },
+ {
+ 0,
+ WFD_MANAGER_SERVICE_INTERFACE,
+ &wfd_manager_dbus_service_iface_vtable
+ },
+ {
+ 0,
+ WFD_MANAGER_DISPLAY_INTERFACE,
+ &wfd_manager_dbus_display_iface_vtable
+ },
+ {
+ 0,
+ WFD_MANAGER_ASP_INTERFACE,
+ &wfd_manager_dbus_asp_iface_vtable
+ },
+ {
+ 0,
+ NULL,
+ NULL
+ }
+};
+
+static guint wfd_manager_dbus_iface_register(const gchar* iface_name,
+ const gchar* iface_path,
+ GDBusNodeInfo *node_info,
+ const GDBusInterfaceVTable *interface_vtable)
+{
+ GDBusInterfaceInfo *interface_info = NULL;
+ GError *Error = NULL;
+ guint reg_id = 0;
+ GDBusConnection *connection = NULL;
+
+ connection = __dbus_get_gdbus_conn();
+ if (connection == NULL) {
+ WDS_LOGE("Dbus connection not yet initiated");
+ return 0;
+ }
+
+ if (!iface_name || !iface_path || !node_info || !interface_vtable) {
+ WDS_LOGE("Invalid Parameters");
+ return 0;
+ }
+
+ /* Register interface */
+ interface_info = g_dbus_node_info_lookup_interface(node_info, iface_name);
+ if (interface_info == NULL) {
+ WDS_LOGE("Failed to get interface info");
+ g_dbus_node_info_unref(node_info);
+ return 0;
+ }
+
+ reg_id = g_dbus_connection_register_object(connection, iface_path,
+ interface_info, interface_vtable,
+ NULL, NULL, &Error);
+ if (reg_id == 0) {
+ WDS_LOGE("Failed to register: %s", Error->message);
+ g_clear_error(&Error);
+ g_dbus_node_info_unref(node_info);
+ return 0;
+ }
+
+ WDS_LOGD("Interface Registration ID [%d], Interface Name [%s]", reg_id, iface_name);
+
+ return reg_id;
+}
+
+static gboolean wfd_manager_dbus_register(void)
+{
+ GDBusNodeInfo *node_info = NULL;
+ GError *Error = NULL;
+ int count = 0;
+
+ wfd_error_register();
+
+ node_info = g_dbus_node_info_new_for_xml(wfd_manager_introspection_xml, &Error);
+ if (node_info == NULL) {
+ WDS_LOGE("Failed to get node info, Error: %s", Error->message);
+ g_clear_error(&Error);
+ return FALSE;
+ }
+
+ while (wfd_manager_iface_map[count].iface_name != NULL) {
+ wfd_manager_iface_map[count].reg_id =
+ wfd_manager_dbus_iface_register(wfd_manager_iface_map[count].iface_name,
+ WFD_MANAGER_PATH,
+ node_info,
+ wfd_manager_iface_map[count].vtbl);
+
+ WDS_LOGD("Registered Interface [%d, %s]",
+ wfd_manager_iface_map[count].reg_id,
+ wfd_manager_iface_map[count].iface_name);
+
+ count++;
+ }
+
+ g_dbus_node_info_unref(node_info);
+ return TRUE;
}
static void nameowner_signal_handler(GDBusConnection *connection,
WDS_LOGD("Subscribed successfully for NameOwnerChanged signals");
}
+static void __on_bus_acquired(GDBusConnection *connection,
+ const gchar *name,
+ gpointer user_data)
+{
+ WDS_LOGD("on_bus_acquired: %s", name);
+ wfd_manager_dbus_register_nameowner_signal();
+ wfd_manager_dbus_register();
+}
+
+static void __on_name_acquired(GDBusConnection *connection,
+ const gchar *name,
+ gpointer user_data)
+{
+ WDS_LOGD("on_name_acquired: %s", name);
+}
+
+static void __on_name_lost(GDBusConnection *connection,
+ const gchar *name,
+ gpointer user_data)
+{
+ WDS_LOGD("on_name_lost: %s", name);
+}
+
void wfd_manager_dbus_unregister_nameowner_signal(void)
{
GDBusConnection *connection = NULL;
WDS_LOGD("Unsubscribed successfully for NameOwnerChanged signals");
}
-guint wfd_manager_dbus_iface_register(const gchar* iface_name,
- const gchar* iface_path,
- GDBusNodeInfo *node_info,
- const GDBusInterfaceVTable *interface_vtable)
-{
- GDBusInterfaceInfo *interface_info = NULL;
- GError *Error = NULL;
- guint reg_id = 0;
- GDBusConnection *connection = NULL;
-
- connection = __dbus_get_gdbus_conn();
- if (connection == NULL) {
- WDS_LOGE("Dbus connection not yet initiated");
- return 0;
- }
-
- if (!iface_name || !iface_path || !node_info || !interface_vtable) {
- WDS_LOGE("Invalid Parameters");
- return 0;
- }
-
- /* Register interface */
- interface_info = g_dbus_node_info_lookup_interface(node_info, iface_name);
- if (interface_info == NULL) {
- WDS_LOGE("Failed to get interface info");
- g_dbus_node_info_unref(node_info);
- return 0;
- }
-
- reg_id = g_dbus_connection_register_object(connection, iface_path,
- interface_info, interface_vtable,
- NULL, NULL, &Error);
- if (reg_id == 0) {
- WDS_LOGE("Failed to register: %s", Error->message);
- g_clear_error(&Error);
- g_dbus_node_info_unref(node_info);
- return 0;
- }
-
- WDS_LOGD("Interface Registration ID [%d], Interface Name [%s]", reg_id, iface_name);
-
- return reg_id;
-}
-
gboolean wfd_manager_dbus_iface_unregister(guint reg_id)
{
GDBusConnection *connection = NULL;
return TRUE;
}
+void wfd_manager_dbus_unregister(void)
+{
+ int count = 0;
+
+ wfd_error_deregister();
+
+ while (wfd_manager_iface_map[count].iface_name != NULL) {
+ wfd_manager_dbus_iface_unregister(wfd_manager_iface_map[count].reg_id);
+ count++;
+ }
+}
+
gboolean wfd_manager_dbus_init(void)
{
GError *Error = NULL;
return rv;
}
+void wfd_manager_dbus_return_err(int ret, GDBusMethodInvocation *invocation)
+{
+ GError *err = NULL;
+ gchar* dbus_error_name = NULL;
+
+ if (!invocation)
+ return;
+
+ wfd_error_set_gerror(ret, &err);
+ dbus_error_name = g_dbus_error_encode_gerror(err);
+ WDS_LOGD("g_dbus_method_invocation_return_gerror with [%s]", dbus_error_name);
+ g_free(dbus_error_name);
+ g_dbus_method_invocation_return_gerror(invocation, err);
+ g_clear_error(&err);
+ return;
+}
+
+void wfd_manager_dbus_reply_error_none(GDBusMethodInvocation *invocation)
+{
+ if (!invocation)
+ return;
+
+ g_dbus_method_invocation_return_value(invocation,
+ g_variant_new("(i)", WIFI_DIRECT_ERROR_NONE));
+
+ return;
+}
+
+void wfd_manager_dbus_reply_params(GDBusMethodInvocation *invocation, GVariant *parameters)
+{
+ if (!invocation)
+ return;
+
+ g_dbus_method_invocation_return_value(invocation, parameters);
+
+ return;
+}
+
GVariant* wfd_manager_dbus_pack_ay(const unsigned char *src, int size)
{
GVariantBuilder *builder = NULL;
#include "wifi-direct-dbus.h"
#include "wifi-direct-iface.h"
+#include "wifi-direct-method.h"
#include "wifi-direct-ipc.h"
#include "wifi-direct-error.h"
#include "wifi-direct-log.h"
#include "wifi-direct-service.h"
#include "wifi-direct-asp.h"
-#define WFD_DBUS_REPLY_ERROR_NONE(invocation) \
- g_dbus_method_invocation_return_value((invocation), g_variant_new("(i)", WIFI_DIRECT_ERROR_NONE))
-
-#define WFD_DBUS_REPLY_PARAMS(invocation, params) \
- g_dbus_method_invocation_return_value((invocation), (params))
-
-static int macaddr_atoe(const char *p, unsigned char mac[])
-{
- int i = 0;
-
- for (;;) {
- mac[i++] = (char) strtoul(p, (char **) &p, 16);
- if (!*p++ || i == 6)
- break;
- }
-
- return (i == 6);
-}
-
-/* introspection xml to register interfaces */
-const gchar wfd_manager_introspection_xml[] = {
- "<node name='/net/wifidirect'>"
- "<interface name='net.wifidirect'>"
- "<method name='Activate'>"
- "<arg type='i' name='error_code' direction='out'/>"
- "</method>"
- "<method name='AddClient'>"
- "<arg type='i' name='result' direction='out'/>"
- "</method>"
- "<method name='Deactivate'>"
- "<arg type='i' name='error_code' direction='out'/>"
- "</method>"
- "<method name='StartDiscovery'>"
- "<arg type='a{sv}' name='parameters' direction='in'/>"
- "<arg type='i' name='error_code' direction='out'/>"
- "</method>"
- "<method name='StopDiscovery'>"
- "<arg type='i' name='error_code' direction='out'/>"
- "</method>"
- "<method name='GetDiscoveredPeers'>"
- "<arg type='i' name='error_code' direction='out'/>"
- "<arg type='aa{sv}' name='peer_details_list' direction='out'/>"
- "</method>"
- "<method name='Connect'>"
- "<arg type='s' name='mac_address' direction='in'/>"
- "<arg type='i' name='error_code' direction='out'/>"
- "</method>"
- "<method name='Disconnect'>"
- "<arg type='s' name='mac_address' direction='in'/>"
- "<arg type='i' name='error_code' direction='out'/>"
- "</method>"
- "<method name='CancelConnection'>"
- "<arg type='s' name='mac_address' direction='in'/>"
- "<arg type='i' name='error_code' direction='out'/>"
- "</method>"
- "<method name='AcceptConnection'>"
- "<arg type='s' name='mac_address' direction='in'/>"
- "<arg type='i' name='error_code' direction='out'/>"
- "</method>"
- "<method name='RejectConnection'>"
- "<arg type='s' name='mac_address' direction='in'/>"
- "<arg type='i' name='error_code' direction='out'/>"
- "</method>"
- "<method name='DisconnectAll'>"
- "<arg type='i' name='error_code' direction='out'/>"
- "</method>"
- "<method name='GetConnectedPeers'>"
- "<arg type='i' name='error_code' direction='out'/>"
- "<arg type='aa{sv}' name='peer_details_list' direction='out'/>"
- "</method>"
- "<method name='GetConnectingPeer'>"
- "<arg type='i' name='error_code' direction='out'/>"
- "<arg type='a{sv}' name='peer_details' direction='out'/>"
- "</method>"
- "<method name='IsDiscoverable'>"
- "<arg type='b' name='result' direction='out'/>"
- "</method>"
- "<method name='IsListeningOnly'>"
- "<arg type='b' name='result' direction='out'/>"
- "</method>"
- "<method name='GetPeerInfo'>"
- "<arg type='s' name='mac_address' direction='in'/>"
- "<arg type='i' name='error_code' direction='out'/>"
- "<arg type='a{sv}' name='peer_details' direction='out'/>"
- "</method>"
- "<method name='GetState'>"
- "<arg type='i' name='error_code' direction='out'/>"
- "<arg type='i' name='state' direction='out'/>"
- "</method>"
- "<signal name='Activation'>"
- "<arg type='i' name='error_code'/>"
- "</signal>"
- "<signal name='Deactivation'>"
- "<arg type='i' name='error_code'/>"
- "</signal>"
- "<signal name='Connection'>"
- "<arg type='i' name='error_code'/>"
- "<arg type='i' name='connection_state'/>"
- "<arg type='s' name='peer_mac_address'/>"
- "</signal>"
- "<signal name='Disconnection'>"
- "<arg type='i' name='error_code'/>"
- "<arg type='i' name='connection_state'/>"
- "<arg type='s' name='peer_mac_address'/>"
- "</signal>"
- "<signal name='ListenStarted'>"
- "</signal>"
- "<signal name='DiscoveryStarted'>"
- "</signal>"
- "<signal name='DiscoveryFinished'>"
- "</signal>"
- "<signal name='PeerFound'>"
- "<arg type='s' name='peer_mac_address'/>"
- "</signal>"
- "<signal name='PeerLost'>"
- "<arg type='s' name='peer_mac_address'/>"
- "</signal>"
- "<signal name='PeerIPAssigned'>"
- "<arg type='s' name='peer_mac_address'/>"
- "<arg type='s' name='assigned_ip_address'/>"
- "</signal>"
- "</interface>"
- "<interface name='net.wifidirect.group'>"
- "<method name='CreateGroup'>"
- "<arg type='a{sv}' name='parameters' direction='in'/>"
- "<arg type='i' name='error_code' direction='out'/>"
- "</method>"
- "<method name='DestroyGroup'>"
- "<arg type='i' name='error_code' direction='out'/>"
- "</method>"
- "<method name='IsGroupOwner'>"
- "<arg type='b' name='result' direction='out'/>"
- "</method>"
- "<method name='IsAutoGroup'>"
- "<arg type='b' name='result' direction='out'/>"
- "</method>"
- "<method name='ActivatePushButton'>"
- "<arg type='i' name='error_code' direction='out'/>"
- "</method>"
- "<method name='GetPersistentGroups'>"
- "<arg type='i' name='error_code' direction='out'/>"
- "<arg type='aa{sv}' name='result' direction='out'/>"
- "</method>"
- "<method name='RemovePersistentGroup'>"
- "<arg type='s' name='mac_address' direction='in'/>"
- "<arg type='s' name='ssid' direction='in'/>"
- "<arg type='i' name='error_code' direction='out'/>"
- "</method>"
- "<method name='SetPassphrase'>"
- "<arg type='s' name='passphrase' direction='in'/>"
- "<arg type='i' name='error_code' direction='out'/>"
- "</method>"
- "<method name='GetPassphrase'>"
- "<arg type='i' name='error_code' direction='out'/>"
- "<arg type='s' name='passphrase' direction='out'/>"
- "</method>"
- "<method name='SetPersistentGroupEnabled'>"
- "<arg type='b' name='enable' direction='in'/>"
- "<arg type='i' name='error_code' direction='out'/>"
- "</method>"
- "<method name='IsPersistentGroupEnabled'>"
- "<arg type='b' name='result' direction='out'/>"
- "</method>"
- "<signal name='Created'>"
- "</signal>"
- "<signal name='Destroyed'>"
- "</signal>"
- "</interface>"
- "<interface name='net.wifidirect.config'>"
- "<method name='GetDeviceName'>"
- "<arg type='i' name='error_code' direction='out'/>"
- "<arg type='s' name='device_name' direction='out'/>"
- "</method>"
- "<method name='SetDeviceName'>"
- "<arg type='s' name='device_name' direction='in'/>"
- "<arg type='i' name='error_code' direction='out'/>"
- "</method>"
- "<method name='SetWpsPin'>"
- "<arg type='s' name='wps_pin' direction='in'/>"
- "<arg type='i' name='error_code' direction='out'/>"
- "</method>"
- "<method name='GetWpsPin'>"
- "<arg type='i' name='error_code' direction='out'/>"
- "<arg type='s' name='wps_pin' direction='out'/>"
- "</method>"
- "<method name='GenerateWpsPin'>"
- "<arg type='i' name='error_code' direction='out'/>"
- "<arg type='s' name='wps_pin' direction='out'/>"
- "</method>"
- "<method name='GetSupportedWpsMode'>"
- "<arg type='i' name='error_code' direction='out'/>"
- "<arg type='i' name='config_methods' direction='out'/>"
- "</method>"
- "<method name='GetReqWpsMode'>"
- "<arg type='i' name='error_code' direction='out'/>"
- "<arg type='i' name='req_wps_mode' direction='out'/>"
- "</method>"
- "<method name='SetReqWpsMode'>"
- "<arg type='i' name='req_wps_mode' direction='in'/>"
- "<arg type='i' name='error_code' direction='out'/>"
- "</method>"
- "<method name='GetLocalWpsMode'>"
- "<arg type='i' name='error_code' direction='out'/>"
- "<arg type='i' name='local_wps_mode' direction='out'/>"
- "</method>"
- "<method name='GetIPAddress'>"
- "<arg type='i' name='error_code' direction='out'/>"
- "<arg type='s' name='local_ip_address' direction='out'/>"
- "</method>"
- "<method name='GetMacAddress'>"
- "<arg type='i' name='error_code' direction='out'/>"
- "<arg type='s' name='local_mac_address' direction='out'/>"
- "</method>"
- "<method name='GetGoIntent'>"
- "<arg type='i' name='error_code' direction='out'/>"
- "<arg type='i' name='go_intent' direction='out'/>"
- "</method>"
- "<method name='SetGoIntent'>"
- "<arg type='i' name='go_intent' direction='in'/>"
- "<arg type='i' name='error_code' direction='out'/>"
- "</method>"
- "<method name='GetMaxClient'>"
- "<arg type='i' name='error_code' direction='out'/>"
- "<arg type='i' name='max_client' direction='out'/>"
- "</method>"
- "<method name='SetMaxClient'>"
- "<arg type='i' name='max_client' direction='in'/>"
- "<arg type='i' name='error_code' direction='out'/>"
- "</method>"
- "<method name='SetAutoConnectionMode'>"
- "<arg type='b' name='auto_connection_mode' direction='in'/>"
- "<arg type='i' name='error_code' direction='out'/>"
- "</method>"
- "<method name='IsAutoConnectionMode'>"
- "<arg type='i' name='error_code' direction='out'/>"
- "<arg type='b' name='result' direction='out'/>"
- "</method>"
- "<method name='GetOperatingChannel'>"
- "<arg type='i' name='error_code' direction='out'/>"
- "<arg type='i' name='operating_channel' direction='out'/>"
- "</method>"
- "<method name='SetAutoConnectionPeer'>"
- "<arg type='s' name='peer_mac_address' direction='in'/>"
- "<arg type='i' name='error_code' direction='out'/>"
- "</method>"
- "<method name='GetConnectingPeer'>"
- "<arg type='i' name='error_code' direction='out'/>"
- "<arg type='s' name='local_mac_address' direction='out'/>"
- "</method>"
- "<method name='GetInterfaceName'>"
- "<arg type='i' name='error_code' direction='out'/>"
- "<arg type='s' name='ifname' direction='out'/>"
- "</method>"
- "<method name='GetSubnetMask'>"
- "<arg type='i' name='error_code' direction='out'/>"
- "<arg type='s' name='subnet_mask' direction='out'/>"
- "</method>"
- "<method name='GetGateway'>"
- "<arg type='i' name='error_code' direction='out'/>"
- "<arg type='s' name='gateway_address' direction='out'/>"
- "</method>"
- "<method name='GetSessionTimer'>"
- "<arg type='i' name='error_code' direction='out'/>"
- "<arg type='i' name='session_timer' direction='out'/>"
- "</method>"
- "<method name='SetSessionTimer'>"
- "<arg type='i' name='session_timer' direction='in'/>"
- "<arg type='i' name='error_code' direction='out'/>"
- "</method>"
- "<method name='SetAutoGroupRemoval'>"
- "<arg type='b' name='enable' direction='in'/>"
- "<arg type='i' name='error_code' direction='out'/>"
- "</method>"
- "<method name='GetPrimaryDevType'>"
- "<arg type='i' name='pri_dev_type' direction='out'/>"
- "<arg type='i' name='error_code' direction='out'/>"
- "</method>"
- "<method name='GetSecondaryDevType'>"
- "<arg type='i' name='sec_dev_type' direction='out'/>"
- "<arg type='i' name='error_code' direction='out'/>"
- "</method>"
- "<method name='GetPeerRssi'>"
- "<arg type='s' name='peer_mac_addr' direction='in'/>"
- "<arg type='i' name='error_code' direction='out'/>"
- "<arg type='i' name='rssi' direction='out'/>"
- "</method>"
- "<method name='AddVsie'>"
- "<arg type='i' name='frame_id' direction='in'/>"
- "<arg type='s' name='vsie' direction='in'/>"
- "<arg type='i' name='error_code' direction='out'/>"
- "</method>"
- "<method name='GetVsie'>"
- "<arg type='i' name='frame_id' direction='in'/>"
- "<arg type='i' name='error_code' direction='out'/>"
- "<arg type='s' name='vsie' direction='out'/>"
- "</method>"
- "<method name='RemoveVsie'>"
- "<arg type='i' name='frame_id' direction='in'/>"
- "<arg type='s' name='vsie' direction='in'/>"
- "<arg type='i' name='error_code' direction='out'/>"
- "</method>"
- "</interface>"
- "<interface name='net.wifidirect.service'>"
- "<method name='StartDiscovery'>"
- "<arg type='i' name='service_type' direction='in'/>"
- "<arg type='s' name='mac_addr' direction='in'/>"
- "<arg type='i' name='error_code' direction='out'/>"
- "</method>"
- "<method name='StopDiscovery'>"
- "<arg type='i' name='service_type' direction='in'/>"
- "<arg type='s' name='mac_addr' direction='in'/>"
- "<arg type='i' name='error_code' direction='out'/>"
- "</method>"
- "<method name='Register'>"
- "<arg type='i' name='service_type' direction='in'/>"
- "<arg type='s' name='info_string' direction='in'/>"
- "<arg type='i' name='error_code' direction='out'/>"
- "<arg type='i' name='service_id' direction='out'/>"
- "</method>"
- "<method name='Deregister'>"
- "<arg type='i' name='service_id' direction='in'/>"
- "<arg type='i' name='error_code' direction='out'/>"
- "</method>"
- "<signal name='DiscoveryStarted'>"
- "</signal>"
- "<signal name='DiscoveryFound'>"
- "<arg type='i' name='service_type'/>"
- "<arg type='s' name='response_data'/>"
- "<arg type='s' name='peer_mac_address'/>"
- "</signal>"
- "<signal name='DiscoveryFinished'>"
- "</signal>"
- "</interface>"
- "<interface name='net.wifidirect.display'>"
- "<method name='Init'>"
- "<arg type='i' name='error_code' direction='out'/>"
- "</method>"
- "<method name='Deinit'>"
- "<arg type='i' name='error_code' direction='out'/>"
- "</method>"
- "<method name='SetConfig'>"
- "<arg type='i' name='type' direction='in'/>"
- "<arg type='i' name='port' direction='in'/>"
- "<arg type='i' name='hdcp' direction='in'/>"
- "<arg type='i' name='error_code' direction='out'/>"
- "</method>"
- "<method name='SetAvailiability'>"
- "<arg type='i' name='availability' direction='in'/>"
- "<arg type='i' name='error_code' direction='out'/>"
- "</method>"
- "<method name='GetPeerType'>"
- "<arg type='s' name='peer_mac_addr' direction='in'/>"
- "<arg type='i' name='error_code' direction='out'/>"
- "<arg type='i' name='result' direction='out'/>"
- "</method>"
- "<method name='GetPeerAvailability'>"
- "<arg type='s' name='peer_mac_addr' direction='in'/>"
- "<arg type='i' name='error_code' direction='out'/>"
- "<arg type='i' name='result' direction='out'/>"
- "</method>"
- "<method name='GetPeerHdcp'>"
- "<arg type='s' name='peer_mac_addr' direction='in'/>"
- "<arg type='i' name='error_code' direction='out'/>"
- "<arg type='i' name='result' direction='out'/>"
- "</method>"
- "<method name='GetPeerPort'>"
- "<arg type='s' name='peer_mac_addr' direction='in'/>"
- "<arg type='i' name='error_code' direction='out'/>"
- "<arg type='i' name='result' direction='out'/>"
- "</method>"
- "<method name='GetPeerThroughput'>"
- "<arg type='s' name='peer_mac_addr' direction='in'/>"
- "<arg type='i' name='error_code' direction='out'/>"
- "<arg type='i' name='result' direction='out'/>"
- "</method>"
- "</interface>"
- "<interface name='net.wifidirect.asp'>"
- "<method name='AdvertiseService'>"
- "<arg type='a{sv}' name='parameters' direction='in'/>"
- "<arg type='i' name='result' direction='out'/>"
- "</method>"
- "<method name='CancelAdvertiseService'>"
- "<arg type='u' name='adv_id' direction='in'/>"
- "<arg type='i' name='result' direction='out'/>"
- "</method>"
- "<method name='SeekService'>"
- "<arg type='a{sv}' name='parameters' direction='in'/>"
- "<arg type='i' name='result' direction='out'/>"
- "</method>"
- "<method name='CancelSeekService'>"
- "<arg type='t' name='search_id' direction='in'/>"
- "<arg type='i' name='result' direction='out'/>"
- "</method>"
- "<method name='ConnectSession'>"
- "<arg type='a{sv}' name='parameters' direction='in'/>"
- "<arg type='i' name='result' direction='out'/>"
- "</method>"
- "<method name='ConfirmSession'>"
- "<arg type='a{sv}' name='parameters' direction='in'/>"
- "<arg type='i' name='result' direction='out'/>"
- "</method>"
- "<signal name='SearchResult'>"
- "<arg type='a{sv}' name='parameters'/>"
- "</signal>"
- "<signal name='SessionRequest'>"
- "<arg type='a{sv}' name='parameters'/>"
- "</signal>"
- "<signal name='SessionConfigRequest'>"
- "<arg type='a{sv}' name='parameters'/>"
- "</signal>"
- "<signal name='ConnectStatus'>"
- "<arg type='a{sv}' name='parameters'/>"
- "</signal>"
- "<signal name='SessionStatus'>"
- "<arg type='a{sv}' name='parameters'/>"
- "</signal>"
- "<signal name='SessionPeerIPAssigned'>"
- "<arg type='a{sv}' name='parameters'/>"
- "</signal>"
- "</interface>"
- "</node>"
+typedef enum {
+ WFD_IFACE_MANAGE,
+ WFD_IFACE_GROUP,
+ WFD_IFACE_CONFIG,
+ WFD_IFACE_SERVICE,
+ WFD_IFACE_DISPLAY,
+ WFD_IFACE_ASP,
+ WFD_IFACE_MAX,
+} iface_type_e;
+
+typedef void (*method_handler)(GVariant *parameters, void *dest);
+
+typedef struct {
+ const char *method_str;
+ method_handler handler;
+} wfd_manager_iface_method_handler;
+
+static wfd_manager_iface_method_handler wfd_manager_iface_manage[] = {
+ {"Activate", activate_handler},
+ {"AddClient", add_client_handler},
+ {"Deactivate", deactivate_handler},
+ {"StartDiscovery", start_discovery_handler},
+ {"StopDiscovery", stop_discovery_handler},
+ {"GetDiscoveredPeers", get_discovered_peer_handler},
+ {"Connect", connect_handler},
+ {"Disconnect", disconnect_handler},
+ {"CancelConnection", cancel_connection_handler},
+ {"AcceptConnection", accept_connection_handler},
+ {"RejectConnection", reject_connection_handler},
+ {"DisconnectAll", disconnect_all_handler},
+ {"GetConnectedPeers", get_connected_peers_handler},
+ {"GetConnectingPeer", get_connecting_peer_handler},
+ {"IsDiscoverable", is_discoverable_handler},
+ {"IsListeningOnly", is_listening_only_handler},
+ {"GetPeerInfo", get_peer_info_handler},
+ {"GetState", get_state_handler},
+ {NULL, NULL},
};
-static bool __is_discovery_available(wfd_manager_s *manager)
-{
- return manager->state != WIFI_DIRECT_STATE_ACTIVATED &&
- manager->state != WIFI_DIRECT_STATE_DISCOVERING &&
- manager->state != WIFI_DIRECT_STATE_GROUP_OWNER;
-}
-
-static void __wfd_manager_manage_iface_handler(const gchar *method_name,
- GVariant *parameters,
- GDBusMethodInvocation *invocation)
-{
- int ret = WIFI_DIRECT_ERROR_OPERATION_FAILED;
- wfd_manager_s *manager = wfd_get_manager();
- GVariant *return_parameters = NULL;
- GError *err = NULL;
- gchar* dbus_error_name = NULL;
- WDS_LOGD("%s", method_name);
-
- if (!g_strcmp0(method_name, "Activate")) {
-
- WFD_DBUS_REPLY_ERROR_NONE(invocation);
-
- ret = wfd_manager_activate(manager);
- wfd_manager_dbus_emit_signal(WFD_MANAGER_MANAGE_INTERFACE,
- "Activation",
- g_variant_new("(i)", ret));
- return;
- } else if (!g_strcmp0(method_name, "AddClient")) {
- return_parameters = g_variant_new("(i)", WIFI_DIRECT_ERROR_NONE);
- goto done;
- } else if (!g_strcmp0(method_name, "Deactivate")) {
-
- ret = wfd_util_check_p2p_hotspot_state();
- if (ret > 0) {
- ret = WIFI_DIRECT_ERROR_NOT_PERMITTED;
- goto failed;
- }
-
- if (manager->state < WIFI_DIRECT_STATE_ACTIVATED) {
- WDS_LOGE("Already deactivated");
- ret = WIFI_DIRECT_ERROR_NOT_PERMITTED;
- goto failed;
- }
-
- WFD_DBUS_REPLY_ERROR_NONE(invocation);
-
- ret = wfd_manager_deactivate(manager);
- wfd_manager_dbus_emit_signal(WFD_MANAGER_MANAGE_INTERFACE,
- "Deactivation",
- g_variant_new("(i)", ret));
- return;
-
- } else if (!g_strcmp0(method_name, "StartDiscovery")) {
- 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;
-
- g_variant_get(parameters, "(a{sv})", &iter);
- if (!iter) {
- ret = WIFI_DIRECT_ERROR_INVALID_PARAMETER;
- goto failed;
- }
-
- 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 */
- }
- g_variant_iter_free(iter);
-
- if (__is_discovery_available(manager)) {
- WDS_LOGE("Wi-Fi Direct is not available status for scanning.");
- ret = WIFI_DIRECT_ERROR_NOT_PERMITTED;
- goto failed;
- }
-
- if (mode && (manager->local->dev_role == WFD_DEV_ROLE_GO)) {
- WDS_LOGW("Wi-Fi Direct device is already visible, do not start listen");
- ret = WIFI_DIRECT_ERROR_NONE;
- return_parameters = g_variant_new("(i)", ret);
- goto done;
- }
-
- WFD_DBUS_REPLY_ERROR_NONE(invocation);
-
- ret = wfd_manager_start_discovery(manager, mode, timeout, type,
- channel, frequency);
- if (ret == WIFI_DIRECT_ERROR_NONE) {
- if (mode == WFD_OEM_SCAN_MODE_PASSIVE) {
- wfd_manager_dbus_emit_signal(WFD_MANAGER_MANAGE_INTERFACE,
- "ListenStarted",
- NULL);
- } else {
- wfd_manager_dbus_emit_signal(WFD_MANAGER_MANAGE_INTERFACE,
- "DiscoveryStarted",
- NULL);
- }
- }
- return;
-
- } else if (!g_strcmp0(method_name, "StopDiscovery")) {
- int mode = manager->scan_mode;
- if (manager->state != WIFI_DIRECT_STATE_ACTIVATED &&
- manager->state != WIFI_DIRECT_STATE_DISCOVERING) {
- ret = WIFI_DIRECT_ERROR_NOT_PERMITTED;
- goto failed;
- }
-
- WFD_DBUS_REPLY_ERROR_NONE(invocation);
-
- ret = wfd_manager_cancel_discovery(manager);
- if (ret == WIFI_DIRECT_ERROR_NONE && mode == WFD_SCAN_MODE_PASSIVE)
- wfd_manager_dbus_emit_signal(WFD_MANAGER_MANAGE_INTERFACE,
- "DiscoveryFinished", NULL);
- return;
-
- } else if (!g_strcmp0(method_name, "GetDiscoveredPeers")) {
- wfd_discovery_entry_s *peers = NULL;
- GVariantBuilder *builder_peers = NULL;
- int peer_cnt = 0;
- int i = 0;
-
- builder_peers = g_variant_builder_new(G_VARIANT_TYPE("aa{sv}"));
-
- peer_cnt = wfd_manager_get_peers(manager, &peers);
- WDS_LOGD("Peer count [%d], Peer list [%p]", peer_cnt, peers);
- if (peer_cnt < 0) {
- WDS_LOGE("Failed to get scan result");
- ret = WIFI_DIRECT_ERROR_OPERATION_FAILED;
- goto failed;
- }
-
- if (peer_cnt > 255)
- peer_cnt = 255;
-
- for (i = 0; i < peer_cnt; i++) {
- 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(peers[i].device_name));
- g_variant_builder_add(&builder_peer, "{sv}",
- "DeviceAddress",
- wfd_manager_dbus_pack_ay(peers[i].mac_address, MACADDR_LEN));
- g_variant_builder_add(&builder_peer, "{sv}",
- "InterfaceAddress",
- wfd_manager_dbus_pack_ay(peers[i].intf_address, MACADDR_LEN));
- g_variant_builder_add(&builder_peer, "{sv}",
- "Channel",
- g_variant_new_uint16(peers[i].channel));
-
- if (manager->is_service_discovery_supported) {
- g_variant_builder_add(&builder_peer, "{sv}",
- "Services",
- g_variant_new_uint16(peers[i].services));
- }
- g_variant_builder_add(&builder_peer, "{sv}",
- "IsGroupOwner",
- g_variant_new_boolean(peers[i].is_group_owner));
- g_variant_builder_add(&builder_peer, "{sv}",
- "IsPersistentGO",
- g_variant_new_boolean(peers[i].is_persistent_go));
- g_variant_builder_add(&builder_peer, "{sv}",
- "IsConnected",
- g_variant_new_boolean(peers[i].is_connected));
- g_variant_builder_add(&builder_peer, "{sv}",
- "WpsDevicePwdID",
- g_variant_new_uint16(peers[i].wps_device_pwd_id));
- g_variant_builder_add(&builder_peer, "{sv}",
- "WpsCfgMethods",
- g_variant_new_uint16(peers[i].wps_cfg_methods));
- g_variant_builder_add(&builder_peer, "{sv}",
- "Category",
- g_variant_new_uint16(peers[i].category));
- g_variant_builder_add(&builder_peer, "{sv}",
- "SubCategory",
- g_variant_new_uint16(peers[i].subcategory));
-
- if (manager->is_wifi_display_supported)
- g_variant_builder_add(&builder_peer, "{sv}",
- "IsWfdDevice",
- g_variant_new_boolean(peers[i].is_wfd_device));
-
- WDS_LOGD("%dth peer [%s]", i, peers[i].device_name);
- g_variant_builder_add_value(builder_peers, g_variant_builder_end(&builder_peer));
- }
-
- ret = WIFI_DIRECT_ERROR_NONE;
- return_parameters = g_variant_new("(iaa{sv})", ret, builder_peers);
- g_variant_builder_unref(builder_peers);
- goto done;
-
- } else if (!g_strcmp0(method_name, "Connect")) {
- const char *peer_mac_address = NULL;
- unsigned char mac_addr[MACADDR_LEN] = {0, };
-
- if (__is_discovery_available(manager)) {
- ret = WIFI_DIRECT_ERROR_NOT_PERMITTED;
- goto failed;
- }
-
- wfd_group_s *group = (wfd_group_s*) manager->group;
- if (group && group->member_count >= manager->max_station) {
- ret = WIFI_DIRECT_ERROR_TOO_MANY_CLIENT;
- goto failed;
- }
-
- g_variant_get(parameters, "(&s)", &peer_mac_address);
- if (peer_mac_address == NULL) {
- ret = WIFI_DIRECT_ERROR_INVALID_PARAMETER;
- goto failed;
- }
-
- WFD_DBUS_REPLY_ERROR_NONE(invocation);
-
- macaddr_atoe(peer_mac_address, mac_addr);
- ret = wfd_manager_connect(manager, mac_addr);
- if (ret == WIFI_DIRECT_ERROR_NONE)
- wfd_manager_dbus_emit_signal(WFD_MANAGER_MANAGE_INTERFACE,
- "Connection",
- g_variant_new("(iis)", WIFI_DIRECT_ERROR_NONE,
- WFD_EVENT_CONNECTION_IN_PROGRESS,
- peer_mac_address));
- return;
-
- } else if (!g_strcmp0(method_name, "Disconnect")) {
- const char *peer_mac_address = NULL;
- unsigned char mac_addr[MACADDR_LEN] = {0, };
-
- if (!manager->group || manager->state < WIFI_DIRECT_STATE_CONNECTED) {
- if (WIFI_DIRECT_STATE_DISCOVERING == manager->state) {
- ret = wfd_oem_stop_scan(manager->oem_ops);
- if (ret < 0) {
- WDS_LOGE("Failed to stop scan");
- ret = WIFI_DIRECT_ERROR_OPERATION_FAILED;
- goto failed;
- }
- WDS_LOGI("Succeeded to stop scan");
- if (WFD_DEV_ROLE_GO == manager->local->dev_role) {
- wfd_state_set(manager, WIFI_DIRECT_STATE_GROUP_OWNER);
- wfd_util_set_wifi_direct_state(WIFI_DIRECT_STATE_GROUP_OWNER);
- } else {
- wfd_state_set(manager, WIFI_DIRECT_STATE_ACTIVATED);
- wfd_util_set_wifi_direct_state(WIFI_DIRECT_STATE_ACTIVATED);
- }
- } else {
- ret = WIFI_DIRECT_ERROR_NOT_PERMITTED;
- goto failed;
- }
- }
-
- g_variant_get(parameters, "(&s)", &peer_mac_address);
- if (peer_mac_address == NULL) {
- ret = WIFI_DIRECT_ERROR_INVALID_PARAMETER;
- goto failed;
- }
-
- WFD_DBUS_REPLY_ERROR_NONE(invocation);
-
- macaddr_atoe(peer_mac_address, mac_addr);
- ret = wfd_manager_disconnect(manager, mac_addr);
- if (ret == WIFI_DIRECT_ERROR_NONE)
- wfd_manager_dbus_emit_signal(WFD_MANAGER_MANAGE_INTERFACE,
- "Disconnection",
- g_variant_new("(iis)", WIFI_DIRECT_ERROR_NONE,
- WFD_EVENT_DISCONNECTION_RSP,
- peer_mac_address));
- return;
-
- } else if (!g_strcmp0(method_name, "CancelConnection")) {
- const char *peer_mac_address = NULL;
- unsigned char mac_addr[MACADDR_LEN] = {0, };
-
- if (!manager->session && manager->state != WIFI_DIRECT_STATE_CONNECTING) {
- WDS_LOGE("It's not CONNECTING state");
- ret = WIFI_DIRECT_ERROR_NOT_PERMITTED;
- goto failed;
- }
-
- g_variant_get(parameters, "(&s)", &peer_mac_address);
- if (peer_mac_address == NULL) {
- ret = WIFI_DIRECT_ERROR_INVALID_PARAMETER;
- goto failed;
- }
-
- WFD_DBUS_REPLY_ERROR_NONE(invocation);
-
- macaddr_atoe(peer_mac_address, mac_addr);
- ret = wfd_manager_cancel_connection(manager, mac_addr);
- if (ret == WIFI_DIRECT_ERROR_NONE)
- wfd_manager_dbus_emit_signal(WFD_MANAGER_MANAGE_INTERFACE,
- "Connection",
- g_variant_new("(iis)", WIFI_DIRECT_ERROR_CONNECTION_CANCELED,
- WFD_EVENT_CONNECTION_RSP,
- peer_mac_address));
- return;
-
- } else if (!g_strcmp0(method_name, "AcceptConnection")) {
- const char *peer_mac_address = NULL;
- unsigned char mac_addr[MACADDR_LEN] = {0, };
-
- if (manager->state != WIFI_DIRECT_STATE_CONNECTING) {
- ret = WIFI_DIRECT_ERROR_NOT_PERMITTED;
- goto failed;
- }
-
- wfd_group_s *group = (wfd_group_s*) manager->group;
- if (group && group->member_count >= manager->max_station) {
- ret = WIFI_DIRECT_ERROR_NOT_PERMITTED;
- goto failed;
- }
-
- g_variant_get(parameters, "(&s)", &peer_mac_address);
- if (peer_mac_address == NULL) {
- ret = WIFI_DIRECT_ERROR_INVALID_PARAMETER;
- goto failed;
- }
-
- WFD_DBUS_REPLY_ERROR_NONE(invocation);
-
- macaddr_atoe(peer_mac_address, mac_addr);
- ret = wfd_manager_accept_connection(manager, mac_addr);
- if (ret == WIFI_DIRECT_ERROR_NONE) {
- wfd_manager_dbus_emit_signal(WFD_MANAGER_MANAGE_INTERFACE,
- "Connection",
- g_variant_new("(iis)", WIFI_DIRECT_ERROR_NONE,
- WFD_EVENT_CONNECTION_IN_PROGRESS,
- peer_mac_address));
- } else {
- wfd_manager_dbus_emit_signal(WFD_MANAGER_MANAGE_INTERFACE,
- "Connection",
- g_variant_new("(iis)", WIFI_DIRECT_ERROR_OPERATION_FAILED,
- WFD_EVENT_CONNECTION_RSP,
- peer_mac_address));
- }
- return;
-
- } else if (!g_strcmp0(method_name, "RejectConnection")) {
- wfd_session_s *session = manager->session;
- const char *peer_mac_address = NULL;
- unsigned char mac_addr[MACADDR_LEN] = {0, };
-
- if (!session || manager->state != WIFI_DIRECT_STATE_CONNECTING) {
- WDS_LOGE("It's not permitted with this state [%d]", manager->state);
- ret = WIFI_DIRECT_ERROR_NOT_PERMITTED;
- goto failed;
- }
-
- if (session->direction != SESSION_DIRECTION_INCOMING) {
- WDS_LOGE("Only incomming session can be rejected");
- ret = WIFI_DIRECT_ERROR_NOT_PERMITTED;
- goto failed;
- }
-
- g_variant_get(parameters, "(&s)", &peer_mac_address);
- if (peer_mac_address == NULL) {
- ret = WIFI_DIRECT_ERROR_INVALID_PARAMETER;
- goto failed;
- }
-
- WFD_DBUS_REPLY_ERROR_NONE(invocation);
-
- macaddr_atoe(peer_mac_address, mac_addr);
- ret = wfd_manager_reject_connection(manager, mac_addr);
- if (ret == WIFI_DIRECT_ERROR_NONE)
- wfd_manager_dbus_emit_signal(WFD_MANAGER_MANAGE_INTERFACE,
- "Connection",
- g_variant_new("(iis)", WIFI_DIRECT_ERROR_CONNECTION_CANCELED,
- WFD_EVENT_CONNECTION_RSP,
- peer_mac_address));
- return;
-
- } else if (!g_strcmp0(method_name, "DisconnectAll")) {
-
- if (!manager->group || manager->state < WIFI_DIRECT_STATE_CONNECTED) {
- if (WIFI_DIRECT_STATE_DISCOVERING == manager->state) {
- ret = wfd_oem_stop_scan(manager->oem_ops);
- if (ret < 0) {
- WDS_LOGE("Failed to stop scan");
- ret = WIFI_DIRECT_ERROR_OPERATION_FAILED;
- goto failed;
- }
- WDS_LOGI("Succeeded to stop scan");
- if (WFD_DEV_ROLE_GO == manager->local->dev_role) {
- wfd_state_set(manager, WIFI_DIRECT_STATE_GROUP_OWNER);
- wfd_util_set_wifi_direct_state(WIFI_DIRECT_STATE_GROUP_OWNER);
- } else {
- wfd_state_set(manager, WIFI_DIRECT_STATE_ACTIVATED);
- wfd_util_set_wifi_direct_state(WIFI_DIRECT_STATE_ACTIVATED);
- }
- } else {
- ret = WIFI_DIRECT_ERROR_NOT_PERMITTED;
- goto failed;
- }
- }
-
- WFD_DBUS_REPLY_ERROR_NONE(invocation);
-
- ret = wfd_manager_disconnect_all(manager);
- if (ret == WIFI_DIRECT_ERROR_NONE)
- wfd_manager_dbus_emit_signal(WFD_MANAGER_MANAGE_INTERFACE,
- "Disconnection",
- g_variant_new("(iis)", ret,
- WFD_EVENT_DISCONNECTION_RSP,
- ""));
- return;
-
- } else if (!g_strcmp0(method_name, "GetConnectedPeers")) {
- wfd_connected_peer_info_s *peers = NULL;
- GVariantBuilder *builder_peers = NULL;
- int peer_cnt = 0;
- int i = 0;
-
- /* even though status is not CONNECTED,
- * this command can be excuted only when group exist */
- if (!manager->group && manager->state < WIFI_DIRECT_STATE_CONNECTED) {
- WDS_LOGD("It's not connected state [%d]", manager->state);
- ret = WIFI_DIRECT_ERROR_NOT_PERMITTED;
- goto failed;
- }
-
- peer_cnt = wfd_manager_get_connected_peers(manager, &peers);
- WDS_LOGD("Peer count [%d], Peer list [%x]", peer_cnt, peers);
- if (peer_cnt < 0) {
- WDS_LOGE("Failed to get scan result");
- ret = WIFI_DIRECT_ERROR_NOT_PERMITTED;
- goto failed;
- }
-
- builder_peers = g_variant_builder_new(G_VARIANT_TYPE("aa{sv}"));
- for (i = 0; i < peer_cnt; i++) {
- 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(peers[i].device_name));
- g_variant_builder_add(&builder_peer, "{sv}",
- "DeviceAddress",
- wfd_manager_dbus_pack_ay(peers[i].mac_address, MACADDR_LEN));
- g_variant_builder_add(&builder_peer, "{sv}",
- "InterfaceAddress",
- wfd_manager_dbus_pack_ay(peers[i].intf_address, MACADDR_LEN));
- g_variant_builder_add(&builder_peer, "{sv}",
- "IPAddress",
- wfd_manager_dbus_pack_ay(peers[i].ip_address, IPADDR_LEN));
- g_variant_builder_add(&builder_peer, "{sv}",
- "Channel",
- g_variant_new_uint16(peers[i].channel));
- if (manager->is_service_discovery_supported) {
- g_variant_builder_add(&builder_peer, "{sv}",
- "Services",
- g_variant_new_uint16(peers[i].services));
- }
- g_variant_builder_add(&builder_peer, "{sv}",
- "Category",
- g_variant_new_uint16(peers[i].category));
- g_variant_builder_add(&builder_peer, "{sv}",
- "SubCategory",
- g_variant_new_uint16(peers[i].subcategory));
- g_variant_builder_add(&builder_peer, "{sv}",
- "IsP2P",
- g_variant_new_boolean(peers[i].is_p2p));
-
- if (manager->is_wifi_display_supported)
- g_variant_builder_add(&builder_peer, "{sv}",
- "IsWfdDevice",
- g_variant_new_boolean(peers[i].is_wfd_device));
-
- WDS_LOGD("%dth peer [%s]", i, peers[i].device_name);
- g_variant_builder_add_value(builder_peers, g_variant_builder_end(&builder_peer));
- }
-
- ret = WIFI_DIRECT_ERROR_NONE;
- return_parameters = g_variant_new("(iaa{sv})", ret, builder_peers);
- g_variant_builder_unref(builder_peers);
- g_free(peers);
- goto done;
-
- } else if (!g_strcmp0(method_name, "GetConnectingPeer")) {
- wfd_session_s *session;
- wfd_device_s *peer = NULL;
- wfd_discovery_entry_s *connecting_peer = NULL;
- GVariantBuilder *builder_peer = NULL;
-
- if (!manager->session ||
- manager->state != WIFI_DIRECT_STATE_CONNECTING) {
- ret = WIFI_DIRECT_ERROR_NOT_PERMITTED;
- goto failed;
- }
-
- session = manager->session;
- if (!session->peer) {
- ret = WIFI_DIRECT_ERROR_OPERATION_FAILED;
- goto failed;
- }
- peer = session->peer;
-
- connecting_peer = (wfd_discovery_entry_s *)
- g_try_malloc0(sizeof(wfd_discovery_entry_s));
- if (!connecting_peer) {
- WDS_LOGF("Failed to allocate memory for peer data.");
- ret = WIFI_DIRECT_ERROR_OUT_OF_MEMORY;
- goto failed;
- }
-
- builder_peer = g_variant_builder_new(G_VARIANT_TYPE("a{sv}"));
-
- g_variant_builder_add(builder_peer, "{sv}",
- "DeviceName",
- g_variant_new_string(peer->dev_name));
- g_variant_builder_add(builder_peer, "{sv}",
- "DeviceAddress",
- wfd_manager_dbus_pack_ay(peer->dev_addr,
- MACADDR_LEN));
- g_variant_builder_add(builder_peer, "{sv}",
- "InterfaceAddress",
- wfd_manager_dbus_pack_ay(peer->intf_addr,
- MACADDR_LEN));
- g_variant_builder_add(builder_peer, "{sv}",
- "Channel",
- g_variant_new_uint16(peer->channel));
- g_variant_builder_add(builder_peer, "{sv}",
- "IsConnected",
- g_variant_new_boolean(peer->dev_role == WFD_DEV_ROLE_GC));
- g_variant_builder_add(builder_peer, "{sv}",
- "IsGroupOwner",
- g_variant_new_boolean(peer->dev_role == WFD_OEM_DEV_ROLE_GO));
- g_variant_builder_add(builder_peer, "{sv}",
- "IsPersistentGO",
- g_variant_new_boolean(peer->group_flags & WFD_OEM_GROUP_FLAG_PERSISTENT_GROUP));
- g_variant_builder_add(builder_peer, "{sv}",
- "Category",
- g_variant_new_uint16(peer->pri_dev_type));
- g_variant_builder_add(builder_peer, "{sv}",
- "SubCategory",
- g_variant_new_uint16(peer->sec_dev_type));
- g_variant_builder_add(builder_peer, "{sv}",
- "WpsCfgMethods",
- g_variant_new_uint16(peer->config_methods));
-
- if (manager->is_wifi_display_supported)
- g_variant_builder_add(builder_peer, "{sv}",
- "IsWfdDevice",
- g_variant_new_boolean(false));
-
- ret = WIFI_DIRECT_ERROR_NONE;
- return_parameters = g_variant_new("(ia{sv})", ret,
- builder_peer);
- g_variant_builder_unref(builder_peer);
- g_free(connecting_peer);
- goto done;
-
- } else if (!g_strcmp0(method_name, "IsDiscoverable")) {
- ret = WIFI_DIRECT_ERROR_NONE;
- return_parameters = g_variant_new("(b)",
- (manager->state == WIFI_DIRECT_STATE_DISCOVERING ||
- wfd_group_is_autonomous(manager->group) == TRUE));
- goto done;
-
- } else if (!g_strcmp0(method_name, "IsListeningOnly")) {
- ret = WIFI_DIRECT_ERROR_NONE;
- return_parameters = g_variant_new("(b)", (manager->scan_mode == WFD_SCAN_MODE_PASSIVE));
- goto done;
-
- } else if (!g_strcmp0(method_name, "GetPeerInfo")) {
- wfd_discovery_entry_s *peer = NULL;
- GVariantBuilder *builder_peer = NULL;
- const char *peer_mac_address = NULL;
- unsigned char mac_addr[MACADDR_LEN] = {0, };
-
- g_variant_get(parameters, "(&s)", &peer_mac_address);
- if (peer_mac_address == NULL) {
- ret = WIFI_DIRECT_ERROR_INVALID_PARAMETER;
- goto failed;
- }
-
- macaddr_atoe(peer_mac_address, mac_addr);
- ret = wfd_manager_get_peer_info(manager, mac_addr, &peer);
- if (ret < 0 || !peer) {
- WDS_LOGE("Failed to get peer info");
- g_free(peer);
- ret = WIFI_DIRECT_ERROR_OPERATION_FAILED;
- goto failed;
- }
-
- builder_peer = g_variant_builder_new(G_VARIANT_TYPE("a{sv}"));
- g_variant_builder_add(builder_peer, "{sv}",
- "DeviceName",
- g_variant_new_string(peer->device_name));
- g_variant_builder_add(builder_peer, "{sv}",
- "DeviceAddress",
- wfd_manager_dbus_pack_ay(peer->mac_address, MACADDR_LEN));
- g_variant_builder_add(builder_peer, "{sv}",
- "InterfaceAddress",
- wfd_manager_dbus_pack_ay(peer->intf_address, MACADDR_LEN));
- g_variant_builder_add(builder_peer, "{sv}",
- "Channel",
- g_variant_new_uint16(peer->channel));
- if (manager->is_service_discovery_supported) {
- g_variant_builder_add(builder_peer, "{sv}",
- "Services",
- g_variant_new_uint16(peer->services));
- }
- g_variant_builder_add(builder_peer, "{sv}",
- "IsGroupOwner",
- g_variant_new_boolean(peer->is_group_owner));
- g_variant_builder_add(builder_peer, "{sv}",
- "IsPersistentGO",
- g_variant_new_boolean(peer->is_persistent_go));
- g_variant_builder_add(builder_peer, "{sv}",
- "IsConnected",
- g_variant_new_boolean(peer->is_connected));
- g_variant_builder_add(builder_peer, "{sv}",
- "WpsDevicePwdID",
- g_variant_new_uint16(peer->wps_device_pwd_id));
- g_variant_builder_add(builder_peer, "{sv}",
- "WpsCfgMethods",
- g_variant_new_uint16(peer->wps_cfg_methods));
- g_variant_builder_add(builder_peer, "{sv}",
- "Category",
- g_variant_new_uint16(peer->category));
- g_variant_builder_add(builder_peer, "{sv}",
- "SubCategory",
- g_variant_new_uint16(peer->subcategory));
-
- if (manager->is_wifi_display_supported)
- g_variant_builder_add(builder_peer, "{sv}",
- "IsWfdDevice",
- g_variant_new_boolean(peer->is_wfd_device));
-
- wfd_device_s *connected_peer = NULL;
- connected_peer = wfd_group_find_member_by_addr(manager->group, mac_addr);
- if (connected_peer) {
- g_variant_builder_add(builder_peer, "{sv}",
- "IsInGroup",
- g_variant_new_boolean(true));
- g_variant_builder_add(builder_peer, "{sv}",
- "IPAddress",
- wfd_manager_dbus_pack_ay(connected_peer->ip_addr, IPADDR_LEN));
- }
-
- ret = WIFI_DIRECT_ERROR_NONE;
- return_parameters = g_variant_new("(ia{sv})", ret, builder_peer);
- g_variant_builder_unref(builder_peer);
- g_free(peer);
- goto done;
-
- } else if (!g_strcmp0(method_name, "GetState")) {
- ret = WIFI_DIRECT_ERROR_NONE;
- return_parameters = g_variant_new("(ii)", ret, manager->state);
- goto done;
-
- } else {
- WDS_LOGD("method not handled");
- ret = WIFI_DIRECT_ERROR_NOT_PERMITTED;
- goto failed;
- }
-
-done:
- WFD_DBUS_REPLY_PARAMS(invocation, return_parameters);
- return;
-
-failed:
-
-/*g_dbus_method_invocation_return_dbus_error
- * (invocation, WFD_MANAGER_SERVICE ".Error", ".OperationFailed"); */
-
- wfd_error_set_gerror(ret, &err);
- dbus_error_name = g_dbus_error_encode_gerror(err);
- WDS_LOGD("g_dbus_method_invocation_return_gerror with [%s]", dbus_error_name);
- g_free(dbus_error_name);
- g_dbus_method_invocation_return_gerror(invocation, err);
- g_clear_error(&err);
- return;
-}
-
-static void __wfd_manager_group_iface_handler(const gchar *method_name,
- GVariant *parameters,
- GDBusMethodInvocation *invocation)
-{
- int ret = WIFI_DIRECT_ERROR_OPERATION_FAILED;
- wfd_manager_s *manager = wfd_get_manager();
- GVariant *return_parameters = NULL;
- GError *err = NULL;
- WDS_LOGD("%s", method_name);
-
- if (!g_strcmp0(method_name, "CreateGroup")) {
- wfd_group_s *group = manager->group;
- wfd_oem_group_param_s param;
- wfd_oem_config_s *oem_conf = (wfd_oem_config_s *) manager->wfd_oem_conf;
- GVariantIter *iter = NULL;
- gchar *key = NULL;
- GVariant *var = NULL;
- const char *ssid = NULL;
-
- g_variant_get(parameters, "(a{sv})", &iter);
- if (!iter) {
- ret = WIFI_DIRECT_ERROR_INVALID_PARAMETER;
- goto failed;
- }
-
- while (g_variant_iter_loop(iter, "{sv}", &key, &var)) {
- if (!g_strcmp0(key, "ssid")) {
- g_variant_get(var, "&s", &ssid);
- if (ssid == NULL) {
- ret = WIFI_DIRECT_ERROR_INVALID_PARAMETER;
- g_variant_iter_free(iter);
- goto failed;
- }
- WDS_LOGD("SSID received [%s]", ssid);
- }
- }
-
- if (group || manager->state < WIFI_DIRECT_STATE_ACTIVATED) {
- WDS_LOGE("Group already exist or not a proper state");
- ret = WIFI_DIRECT_ERROR_NOT_PERMITTED;
- g_variant_iter_free(iter);
- goto failed;
- }
-
- group = wfd_create_pending_group(manager, manager->local->intf_addr);
- if (!group) {
- WDS_LOGE("Failed to create pending group");
- ret = WIFI_DIRECT_ERROR_OPERATION_FAILED;
- g_variant_iter_free(iter);
- goto failed;
- }
- group->flags |= WFD_GROUP_FLAG_AUTONOMOUS;
- manager->group = group;
-
- memset(¶m, 0x0, sizeof(param));
-
- param.persistent = (manager->local->group_flags &
- WFD_GROUP_FLAG_PERSISTENT);
- memcpy(&(param.passphrase), manager->local->passphrase,
- sizeof(param.passphrase));
-
- if (oem_conf && oem_conf->group_operating_freq != 0)
- param.freq = oem_conf->group_operating_freq;
-
- if (ssid != NULL)
- g_strlcpy(param.ssid, ssid, WIFI_DIRECT_MAX_DEVICE_NAME_LEN+1);
-
- g_variant_iter_free(iter);
-
- ret = wfd_oem_create_group(manager->oem_ops, ¶m);
- if (ret < 0) {
- WDS_LOGE("Failed to create group");
- wfd_destroy_group(manager);
- ret = WIFI_DIRECT_ERROR_NOT_PERMITTED;
- goto failed;
- }
-
- WDS_LOGD("Succeeded to create pending group");
- memset(manager->local->passphrase, 0x0, PASSPHRASE_LEN_MAX + 1);
- ret = WIFI_DIRECT_ERROR_NONE;
- return_parameters = g_variant_new("(i)", ret);
- goto done;
-
- } else if (!g_strcmp0(method_name, "DestroyGroup")) {
- wfd_group_s *group = manager->group;
- if (!group) {
- WDS_LOGE("Group not exist");
- ret = WIFI_DIRECT_ERROR_NOT_PERMITTED;
- goto failed;
- }
-
- ret = wfd_util_check_p2p_hotspot_state();
- if (ret > 0) {
- ret = WIFI_DIRECT_ERROR_NOT_PERMITTED;
- goto failed;
- }
-
- if (group->pending == FALSE) {
- ret = wfd_oem_destroy_group(manager->oem_ops, group->ifname);
- if (ret < 0) {
- WDS_LOGE("Failed to destroy group");
- ret = WIFI_DIRECT_ERROR_OPERATION_FAILED;
- goto failed;
- }
- }
-
- ret = wfd_destroy_group(manager);
- if (ret < 0)
- WDS_LOGE("Failed to destroy group");
-
- wfd_state_set(manager, WIFI_DIRECT_STATE_ACTIVATED);
- wfd_util_set_wifi_direct_state(WIFI_DIRECT_STATE_ACTIVATED);
-
- WFD_DBUS_REPLY_ERROR_NONE(invocation);
-
- wfd_manager_dbus_emit_signal(WFD_MANAGER_GROUP_INTERFACE,
- "Destroyed", NULL);
- return;
-
- } else if (!g_strcmp0(method_name, "IsGroupOwner")) {
- gboolean result;
- wfd_device_s *local = manager->local;
- result = local->dev_role == WFD_DEV_ROLE_GO;
- WDS_LOGI("Is group owner : [%s]", result ? "Yes" : "No");
- return_parameters = g_variant_new("(b)", result);
- goto done;
-
- } else if (!g_strcmp0(method_name, "IsAutoGroup")) {
- int result;
- if ((result = wfd_group_is_autonomous(manager->group)) < 0)
- result = 0;
-
- WDS_LOGI("Is autonomous group : [%s]", result ? "Yes" : "No");
- return_parameters = g_variant_new("(b)", result);
- goto done;
-
- } else if (!g_strcmp0(method_name, "ActivatePushButton")) {
- if (manager->local->dev_role != WFD_DEV_ROLE_GO) {
- WDS_LOGE("Wi-Fi Direct is not Group Owner.");
- ret = WIFI_DIRECT_ERROR_NOT_PERMITTED;
- goto failed;
- }
-
- ret = wfd_oem_wps_start(manager->oem_ops, NULL,
- WFD_WPS_MODE_PBC, NULL);
- if (ret < 0) {
- WDS_LOGE("Failed to start wps");
- ret = WIFI_DIRECT_ERROR_OPERATION_FAILED;
- goto failed;
- }
- return_parameters = g_variant_new("(i)", ret);
- goto done;
-
- } else if (!g_strcmp0(method_name, "GetPersistentGroups")) {
- int persistent_group_count = 0;
- wfd_persistent_group_info_s *plist;
- GVariantBuilder *builder_groups = NULL;
- int i = 0;
-
- if (manager->state < WIFI_DIRECT_STATE_ACTIVATED) {
- WDS_LOGE("Wi-Fi Direct is not activated.");
- ret = WIFI_DIRECT_ERROR_NOT_PERMITTED;
- goto failed;
- }
-
-
- ret = wfd_oem_get_persistent_groups(manager->oem_ops,
- (wfd_oem_persistent_group_s**) &plist, &persistent_group_count);
- if (ret < 0) {
- WDS_LOGE("Error!! wfd_oem_get_persistent_group_info() failed..");
- ret = WIFI_DIRECT_ERROR_OPERATION_FAILED;
- goto failed;
- }
-
- builder_groups = g_variant_builder_new(G_VARIANT_TYPE("aa{sv}"));
-
- for (i = 0; i < persistent_group_count; i++) {
- 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(plist[i].network_id));
- g_variant_builder_add(&builder_group, "{sv}",
- "SSID",
- g_variant_new_string(plist[i].ssid));
- g_variant_builder_add(&builder_group, "{sv}",
- "GOMacAddress",
- wfd_manager_dbus_pack_ay(plist[i].go_mac_address, MACADDR_LEN));
-
- WDS_LOGD("%dth peer [%s]", i, plist[i].ssid);
- g_variant_builder_add_value(builder_groups, g_variant_builder_end(&builder_group));
- }
-
- ret = WIFI_DIRECT_ERROR_NONE;
- return_parameters = g_variant_new("(iaa{sv})", ret, builder_groups);
- g_variant_builder_unref(builder_groups);
- goto done;
-
- } else if (!g_strcmp0(method_name, "RemovePersistentGroup")) {
- gchar *ssid;
- gchar *mac_address;
- unsigned char go_mac_address[6];
- if (manager->state < WIFI_DIRECT_STATE_ACTIVATED) {
- WDS_LOGE("Wi-Fi Direct is not activated.");
- ret = WIFI_DIRECT_ERROR_NOT_PERMITTED;
- goto failed;
- }
-
- g_variant_get(parameters, "(&s&s)", &mac_address, &ssid);
- if (mac_address == NULL || ssid == NULL) {
- ret = WIFI_DIRECT_ERROR_INVALID_PARAMETER;
- goto failed;
- }
-
- macaddr_atoe(mac_address, go_mac_address);
- WDS_LOGD("Remove persistent group [%s][" MACSTR "]", ssid, MAC2STR(go_mac_address));
-
- ret = wfd_oem_remove_persistent_group(manager->oem_ops, ssid,
- go_mac_address);
- if (ret < 0) {
- WDS_LOGE("Failed to remove persistent group");
- ret = WIFI_DIRECT_ERROR_OPERATION_FAILED;
- goto failed;
- }
- return_parameters = g_variant_new("(i)", ret);
- goto done;
-
- } else if (!g_strcmp0(method_name, "SetPassphrase")) {
- gchar *passphrase;
- int passphrase_len = 0;
- wfd_group_s *group = manager->group;
-
- if (group) {
- WDS_LOGE("Group already exists");
- ret = WIFI_DIRECT_ERROR_NOT_PERMITTED;
- goto failed;
- }
-
- g_variant_get(parameters, "(&s)", &passphrase);
- if (passphrase == NULL) {
- ret = WIFI_DIRECT_ERROR_INVALID_PARAMETER;
- goto failed;
- }
-
- passphrase_len = strlen(passphrase);
-
- if (passphrase_len < PASSPHRASE_LEN_MIN ||
- passphrase_len > PASSPHRASE_LEN_MAX) {
- WDS_LOGE("Passphrase length incorrect [%s]:[%d]",
- passphrase, passphrase_len);
- ret = WIFI_DIRECT_ERROR_NOT_PERMITTED;
- goto failed;
- }
-
- g_strlcpy(manager->local->passphrase, passphrase, PASSPHRASE_LEN_MAX + 1);
- WDS_LOGI("Passphrase string [%s]", manager->local->passphrase);
-
- ret = WIFI_DIRECT_ERROR_NONE;
- return_parameters = g_variant_new("(i)", ret);
- goto done;
-
- } else if (!g_strcmp0(method_name, "GetPassphrase")) {
- wfd_group_s *group = manager->group;
- if (!group) {
- WDS_LOGE("Group not exist");
- ret = WIFI_DIRECT_ERROR_NOT_PERMITTED;
- goto failed;
- }
-
- if (group->role == WFD_DEV_ROLE_GC) {
- WDS_LOGE("Device is not GO");
- ret = WIFI_DIRECT_ERROR_NOT_PERMITTED;
- goto failed;
- }
-
- ret = WIFI_DIRECT_ERROR_NONE;
- return_parameters = g_variant_new("(is)", ret, group->passphrase);
- WDS_LOGI("group->pass : [%s]", group->passphrase);
- goto done;
-
-
- } else if (!g_strcmp0(method_name, "SetPersistentGroupEnabled")) {
- gboolean enabled;
+static wfd_manager_iface_method_handler wfd_manager_iface_group[] = {
+ {"CreateGroup", create_group_handler},
+ {"DestroyGroup", destroy_group_handler},
+ {"IsGroupOwner", is_group_owner_handler},
+ {"IsAutoGroup", is_auto_group_handler},
+ {"ActivatePushButton", activate_pushbutton_handler},
+ {"GetPersistentGroups", get_persistent_group_handler},
+ {"RemovePersistentGroup", remove_persistent_group_handler},
+ {"SetPassphrase", set_passphrase_handler},
+ {"GetPassphrase", get_passphrase_handler},
+ {"SetPersistentGroupEnabled", set_persistent_group_handler},
+ {"IsPersistentGroupEnabled", is_persistent_group_enabled_handler},
+ {NULL, NULL},
+};
- g_variant_get(parameters, "(b)", &enabled);
- WDS_LOGI("Activate Persistent Group : [%s]",
- enabled ? "True" : "False");
- if (enabled)
- manager->local->group_flags |= WFD_GROUP_FLAG_PERSISTENT;
- else
- manager->local->group_flags &= ~(WFD_GROUP_FLAG_PERSISTENT);
- ret = WIFI_DIRECT_ERROR_NONE;
- return_parameters = g_variant_new("(i)", ret);
- goto done;
+static wfd_manager_iface_method_handler wfd_manager_iface_config[] = {
+ {"GetDeviceName", get_device_name_handler},
+ {"SetDeviceName", set_device_name_handler},
+ {"SetWpsPin", set_wps_pin_handler},
+ {"GetWpsPin", get_wps_pin_handler},
+ {"GenerateWpsPin", generate_wps_pin_handler},
+ {"GetSupportedWpsMode", get_supported_wps_mode_handler},
+ {"GetReqWpsMode", get_req_wps_mode_handler},
+ {"SetReqWpsMode", set_req_wps_mode_handler},
+ {"GetLocalWpsMode", get_local_wps_mode_handler},
+ {"GetIPAddress", get_ip_address_handler},
+ {"GetMacAddress", get_mac_address_handler},
+ {"GetGoIntent", get_go_intent_handler},
+ {"SetGoIntent", set_go_intent_handler},
+ {"GetMaxClient", get_max_client_handler},
+ {"SetMaxClient", set_max_client_handler},
+ {"SetAutoConnectionMode", set_autoconnection_mode_handler},
+ {"IsAutoConnectionMode", is_autoconnection_mode_handler},
+ {"GetOperatingChannel", get_operating_channel_handler},
+ {"SetAutoConnectionPeer", set_autoconnection_peer_handler},
+ {"GetConnectingPeer", get_connecting_peer_handler},
+ {"GetInterfaceName", get_interface_name_handler},
+ {"GetSubnetMask", get_subnet_mask_handler},
+ {"GetGateway", get_gateway_handler},
+ {"GetSessionTimer", get_session_timer_handler},
+ {"SetSessionTimer", set_session_timer_handler},
+ {"SetAutoGroupRemoval", get_auto_group_removal_handler},
+ {"GetPrimaryDevType", get_primary_dev_type_handler},
+ {"GetSecondaryDevType", get_secondary_dev_type_handler},
+ {"GetPeerRssi", get_peer_rssi_handler},
+ {"AddVsie", add_vsie_handler},
+ {"GetVsie", get_vsie_handler},
+ {"RemoveVsie", remove_vsie_handler},
+ {NULL, NULL},
+};
- } else if (!g_strcmp0(method_name, "IsPersistentGroupEnabled")) {
- gboolean result;
- result = ((manager->local->group_flags &
- WFD_GROUP_FLAG_PERSISTENT)
- == WFD_GROUP_FLAG_PERSISTENT);
- WDS_LOGI("Is persistent group : [%s]", result ? "Yes" : "No");
- return_parameters = g_variant_new("(b)", result);
- goto done;
+static wfd_manager_iface_method_handler wfd_manager_iface_service[] = {
+ {"StartDiscovery", srv_start_discovery_handler},
+ {"StopDiscovery", srv_stop_discovery_handler},
+ {"Register", srv_register_handler},
+ {"Deregister", srv_deregister_handler},
+ {NULL, NULL},
+};
- } else {
- ret = WIFI_DIRECT_ERROR_NOT_PERMITTED;
- goto failed;
- }
+static wfd_manager_iface_method_handler wfd_manager_iface_display[] = {
+ {"Init", display_init_handler},
+ {"Deinit", display_deinit_handler},
+ {"SetConfig", display_set_config_handler},
+ {"SetAvailiability", display_set_avail_handler},
+ {"GetPeerType", display_get_peer_type_handler},
+ {"GetPeerAvailability", display_get_peer_avail_handler},
+ {"GetPeerHdcp", display_get_peer_hdcp_handler},
+ {"GetPeerPort", display_get_peer_port_handler},
+ {"GetPeerThroughput", display_get_peer_throughput_handler},
+ {NULL, NULL},
+};
-done:
- WFD_DBUS_REPLY_PARAMS(invocation, return_parameters);
- return;
+static wfd_manager_iface_method_handler wfd_manager_iface_asp[] = {
+ {"AdvertiseService", advertise_service_handler},
+ {"CancelAdvertiseService", cancel_advertise_service_handler},
+ {"SeekService", seek_service_handler},
+ {"CancelSeekService", cancel_seek_service_handler},
+ {"ConnectSession", connect_sessoin_handler},
+ {"ConfirmSession", confirm_sessoin_handler},
+ {NULL, NULL},
+};
-failed:
- wfd_error_set_gerror(ret, &err);
- g_dbus_method_invocation_return_gerror(invocation, err);
- g_clear_error(&err);
- return;
-}
+static GHashTable *wfd_manager_iface_tbl[WFD_IFACE_MAX];
-static void __wfd_manager_config_iface_handler(const gchar *method_name,
- GVariant *parameters,
- GDBusMethodInvocation *invocation)
+static int set_iface_hash(wfd_manager_iface_method_handler handler[], int idx)
{
- int ret = WIFI_DIRECT_ERROR_OPERATION_FAILED;
- wfd_manager_s *manager = wfd_get_manager();
- GVariant *return_parameters = NULL;
- GError *err = NULL;
- WDS_LOGD("%s", method_name);
-
- if (!g_strcmp0(method_name, "GetDeviceName")) {
- char device_name[WIFI_DIRECT_MAX_DEVICE_NAME_LEN+1] = {0, };
-
- ret = wfd_local_get_dev_name(device_name);
- if (ret < 0) {
- WDS_LOGE("Failed to get device name");
- ret = WIFI_DIRECT_ERROR_OPERATION_FAILED;
- goto failed;
- } else {
-
- ret = WIFI_DIRECT_ERROR_NONE;
- return_parameters = g_variant_new("(is)", ret, device_name);
- }
- goto done;
-
- } else if (!g_strcmp0(method_name, "SetDeviceName")) {
- const char *device_name = NULL;
- g_variant_get(parameters, "(&s)", &device_name);
- if (device_name == NULL) {
- ret = WIFI_DIRECT_ERROR_INVALID_PARAMETER;
- goto failed;
- }
-
- ret = wfd_local_set_dev_name((char *)device_name);
- if (ret < 0) {
- WDS_LOGE("Failed to set device name");
- ret = WIFI_DIRECT_ERROR_OPERATION_FAILED;
- goto failed;
- }
-
- ret = WIFI_DIRECT_ERROR_NONE;
- return_parameters = g_variant_new("(i)", ret);
- goto done;
-
- } else if (!g_strcmp0(method_name, "GetWpsPin")) {
- wfd_session_s *session = (wfd_session_s*) manager->session;
- if (!session || manager->auto_pin[0] != 0) {
- WDS_LOGE("Session not exist");
- ret = WIFI_DIRECT_ERROR_NOT_PERMITTED;
- goto failed;
- }
-
- if (session->wps_pin[0] == '\0') {
- WDS_LOGE("WPS PIN is not set");
- ret = WIFI_DIRECT_ERROR_OPERATION_FAILED;
- goto failed;
- }
-
- ret = WIFI_DIRECT_ERROR_NONE;
- return_parameters = g_variant_new("(is)", ret, session->wps_pin);
- goto done;
-
- } else if (!g_strcmp0(method_name, "SetWpsPin")) {
- const char *pin = NULL;
- wfd_session_s *session = (wfd_session_s*) manager->session;
-
- g_variant_get(parameters, "(&s)", &pin);
- if (pin == NULL) {
- ret = WIFI_DIRECT_ERROR_INVALID_PARAMETER;
- goto failed;
- }
-
- if (!session) {
- WDS_LOGE("Session not exist");
- g_strlcpy(manager->auto_pin, pin, strlen(pin) + 1);
- } else {
- g_strlcpy(session->wps_pin, pin, strlen(pin) + 1);
- }
-
- ret = WIFI_DIRECT_ERROR_NONE;
- return_parameters = g_variant_new("(i)", ret);
- goto done;
-
- } else if (!g_strcmp0(method_name, "GetSupportedWpsMode")) {
- int config_methods = 0;
-
- ret = wfd_local_get_supported_wps_mode(&config_methods);
- if (ret < 0) {
- WDS_LOGE("Failed to get supported wps mode");
- ret = WIFI_DIRECT_ERROR_OPERATION_FAILED;
- goto failed;
- }
-
- ret = WIFI_DIRECT_ERROR_NONE;
- return_parameters = g_variant_new("(ii)", ret, config_methods);
- goto done;
-
- } else if (!g_strcmp0(method_name, "GetReqWpsMode")) {
- int wps_mode = 0;
-
- ret = wfd_manager_get_req_wps_mode(&wps_mode);
- if (ret < 0) {
- WDS_LOGE("Failed to get request wps mode");
- ret = WIFI_DIRECT_ERROR_OPERATION_FAILED;
- goto failed;
- }
-
- ret = WIFI_DIRECT_ERROR_NONE;
- return_parameters = g_variant_new("(ii)", ret, wps_mode);
- goto done;
-
- } else if (!g_strcmp0(method_name, "SetReqWpsMode")) {
- int type = 0;
-
- g_variant_get(parameters, "(i)", &type);
- ret = wfd_manager_set_req_wps_mode(type);
- if (ret < 0) {
- WDS_LOGE("Failed to set request wps mode");
- ret = WIFI_DIRECT_ERROR_OPERATION_FAILED;
- goto failed;
- }
-
- ret = WIFI_DIRECT_ERROR_NONE;
- return_parameters = g_variant_new("(i)", ret);
- goto done;
-
- } else if (!g_strcmp0(method_name, "GetLocalWpsMode")) {
- int wps_mode = 0;
-
- ret = wfd_local_get_wps_mode(&wps_mode);
- if (ret < 0) {
- WDS_LOGE("Failed to get request wps mode");
- ret = WIFI_DIRECT_ERROR_OPERATION_FAILED;
- goto failed;
- }
-
- ret = WIFI_DIRECT_ERROR_NONE;
- return_parameters = g_variant_new("(ii)", ret, wps_mode);
- goto done;
-
- } else if (!g_strcmp0(method_name, "GetIPAddress")) {
- char ip_addr_str[IPSTR_LEN+1] = {0, };
-
- if (manager->state < WIFI_DIRECT_STATE_CONNECTED) {
- WDS_LOGE("Device is not connected yet");
- ret = WIFI_DIRECT_ERROR_NOT_PERMITTED;
- goto failed;
- }
-
- ret = wfd_local_get_ip_addr((char *)ip_addr_str);
- if (ret < 0) {
- WDS_LOGE("Failed to get local IP address");
- ret = WIFI_DIRECT_ERROR_OPERATION_FAILED;
- goto failed;
- }
-
- return_parameters = g_variant_new("(is)", ret, ip_addr_str);
- WDS_LOGI("IP addr : [%s]", ip_addr_str);
- goto done;
-
- } else if (!g_strcmp0(method_name, "GetMacAddress")) {
- char device_mac[MACSTR_LEN+1] = {0, };
-
- ret = wfd_local_get_dev_mac(device_mac);
- if (ret < 0) {
- WDS_LOGE("Failed to get device mac");
- ret = WIFI_DIRECT_ERROR_OPERATION_FAILED;
- goto failed;
- }
-
- ret = WIFI_DIRECT_ERROR_NONE;
- return_parameters = g_variant_new("(is)", ret, device_mac);
- goto done;
-
- } else if (!g_strcmp0(method_name, "GetGoIntent")) {
- int go_intent = 0;
-
- ret = wfd_manager_get_go_intent(&go_intent);
- if (ret < 0) {
- WDS_LOGE("Failed to get GO intent");
- ret = WIFI_DIRECT_ERROR_OPERATION_FAILED;
- goto failed;
- }
-
- ret = WIFI_DIRECT_ERROR_NONE;
- return_parameters = g_variant_new("(ii)", ret, go_intent);
- goto done;
-
- } else if (!g_strcmp0(method_name, "SetGoIntent")) {
- int go_intent = 0;
-
- g_variant_get(parameters, "(i)", &go_intent);
- ret = wfd_manager_set_go_intent(go_intent);
- if (ret < 0) {
- WDS_LOGE("Failed to set GO intent");
- ret = WIFI_DIRECT_ERROR_OPERATION_FAILED;
- goto failed;
- }
-
- ret = WIFI_DIRECT_ERROR_NONE;
- return_parameters = g_variant_new("(i)", ret);
- goto done;
-
- } else if (!g_strcmp0(method_name, "GetMaxClient")) {
- int max_client = 0;
-
- ret = wfd_manager_get_max_station(&max_client);
- if (ret < 0) {
- WDS_LOGE("Failed to get max station");
- ret = WIFI_DIRECT_ERROR_OPERATION_FAILED;
- goto failed;
- }
-
- ret = WIFI_DIRECT_ERROR_NONE;
- return_parameters = g_variant_new("(ii)", ret, max_client);
- goto done;
-
- } else if (!g_strcmp0(method_name, "SetMaxClient")) {
- int max_client = 0;
- g_variant_get(parameters, "(i)", &max_client);
-
- ret = wfd_manager_set_max_station(max_client);
- if (ret < 0) {
- WDS_LOGE("Failed to set max station");
- ret = WIFI_DIRECT_ERROR_OPERATION_FAILED;
- goto failed;
- }
-
- ret = WIFI_DIRECT_ERROR_NONE;
- return_parameters = g_variant_new("(i)", ret);
- goto done;
-
- } else if (!g_strcmp0(method_name, "SetAutoConnectionMode")) {
- gboolean mode = FALSE;
-
- g_variant_get(parameters, "(b)", &mode);
- ret = wfd_manager_set_autoconnection(mode);
- if (ret < 0) {
- WDS_LOGE("Failed to set autoconnection");
- ret = WIFI_DIRECT_ERROR_OPERATION_FAILED;
- goto failed;
- }
-
- ret = WIFI_DIRECT_ERROR_NONE;
- return_parameters = g_variant_new("(i)", ret);
- goto done;
-
- } else if (!g_strcmp0(method_name, "IsAutoConnectionMode")) {
- int mode = 0;
-
- ret = wfd_manager_get_autoconnection(&mode);
- if (ret < 0) {
- WDS_LOGE("Failed to get autoconnection");
- ret = WIFI_DIRECT_ERROR_OPERATION_FAILED;
- goto failed;
- }
-
- ret = WIFI_DIRECT_ERROR_NONE;
- return_parameters = g_variant_new("(ib)", ret, mode);
- goto done;
-
- } else if (!g_strcmp0(method_name, "GetOperatingChannel")) {
- int channel = 0;
-
- wfd_group_s *group = manager->group;
- if (!group) {
- WDS_LOGE("Group not exist");
- ret = WIFI_DIRECT_ERROR_NOT_PERMITTED;
- goto failed;
- }
-
- channel = wfd_util_freq_to_channel(group->freq);
- if (channel < 0) {
- ret = WIFI_DIRECT_ERROR_OPERATION_FAILED;
- goto failed;
- }
-
- ret = WIFI_DIRECT_ERROR_NONE;
- return_parameters = g_variant_new("(ii)", ret, channel);
- goto done;
-
- } else if (!g_strcmp0(method_name, "SetAutoConnectionPeer")) {
- ret = WIFI_DIRECT_ERROR_NONE;
- return_parameters = g_variant_new("(i)", ret);
- goto done;
-
- } else if (!g_strcmp0(method_name, "GetInterfaceName")) {
- wfd_group_s *group = (wfd_group_s *)manager->group;
- if (!group) {
- ret = WIFI_DIRECT_ERROR_NOT_PERMITTED;
- goto failed;
- }
- ret = WIFI_DIRECT_ERROR_NONE;
- return_parameters = g_variant_new("(is)", ret, group->ifname);
- goto done;
-
- } else if (!g_strcmp0(method_name, "GetSubnetMask")) {
- char *get_str = NULL;
- char subnet_mask[IPSTR_LEN+1] = {0, };
-
- get_str = vconf_get_str(VCONFKEY_WIFI_DIRECT_P2P_SUBNET_MASK);
- if (!get_str) {
- WDS_LOGE("Get Subnet Mask failed");
- ret = WIFI_DIRECT_ERROR_NOT_PERMITTED;
- goto failed;
- }
- WDS_LOGD("VCONFKEY_WIFI_DIRECT_P2P_SUBNET_MASK(%s) : %s", VCONFKEY_WIFI_DIRECT_P2P_SUBNET_MASK,
- get_str);
- ret = WIFI_DIRECT_ERROR_NONE;
- g_strlcpy(subnet_mask, get_str, IPSTR_LEN + 1);
- return_parameters = g_variant_new("(is)", ret, subnet_mask);
- free(get_str);
- goto done;
-
- } else if (!g_strcmp0(method_name, "GetGateway")) {
- char *get_str = NULL;
- char gateway_addr[IPSTR_LEN+1] = {0, };
- get_str = vconf_get_str(VCONFKEY_WIFI_DIRECT_P2P_GATEWAY);
- if (!get_str) {
- WDS_LOGE("Get Gateway failed");
- ret = WIFI_DIRECT_ERROR_NOT_PERMITTED;
- goto failed;
- }
- WDS_LOGD("VCONFKEY_WIFI_DIRECT_P2P_GATEWAY_ADDR(%s) : %s", VCONFKEY_WIFI_DIRECT_P2P_GATEWAY,
- get_str);
- ret = WIFI_DIRECT_ERROR_NONE;
- g_strlcpy(gateway_addr, get_str, IPSTR_LEN + 1);
- return_parameters = g_variant_new("(is)", ret, gateway_addr);
- free(get_str);
- goto done;
-
- } else if (!g_strcmp0(method_name, "GetSessionTimer")) {
-
- int session_timer = 0;
- ret = WIFI_DIRECT_ERROR_NONE;
- session_timer = manager->session_timer;
- WDS_LOGD("Get Session Timer value is %d", session_timer);
- return_parameters = g_variant_new("(ii)", ret, session_timer);
- goto done;
-
- } else if (!g_strcmp0(method_name, "SetSessionTimer")) {
-
- int session_timer = 0;
- g_variant_get(parameters, "(i)", &session_timer);
- WDS_LOGD("Set Session Timer value is %d", session_timer);
- manager->session_timer = session_timer;
- ret = WIFI_DIRECT_ERROR_NONE;
- return_parameters = g_variant_new("(i)", ret);
- goto done;
-
- } else if (!g_strcmp0(method_name, "SetAutoGroupRemoval")) {
- gboolean enable;
-
- g_variant_get(parameters, "(b)", &enable);
- WDS_LOGE("Activate Auto Group Removal Mode : [%s]",
- enable ? "True" : "False");
-
- if (manager->state < WIFI_DIRECT_STATE_ACTIVATED) {
- WDS_LOGE("Wi-Fi Direct is not activated.");
- ret = WIFI_DIRECT_ERROR_NOT_PERMITTED;
- goto failed;
- }
-
- if (enable) {
- manager->auto_group_remove_enable = TRUE;
-
- /* Enable Group destroy only if state is connecting */
- if (manager->state == WIFI_DIRECT_STATE_CONNECTING) {
- WDS_LOGE("Wi-Fi Direct state is CONNECTING");
- ret = WIFI_DIRECT_ERROR_NONE;
- return_parameters = g_variant_new("(i)", ret);
- goto done;
- }
- /* Remove group immediately if no connected peer found */
- if (manager->local->dev_role == WFD_DEV_ROLE_GO) {
- wfd_group_s *group = (wfd_group_s*) manager->group;
- if (group && !group->member_count
- && wfd_util_is_remove_group_allowed())
- wfd_oem_destroy_group(manager->oem_ops, group->ifname);
- }
-
- } else
- manager->auto_group_remove_enable = FALSE;
-
-
- ret = WIFI_DIRECT_ERROR_NONE;
- return_parameters = g_variant_new("(i)", ret);
- goto done;
-
- } else if (!g_strcmp0(method_name, "GetPrimaryDevType")) {
-
- int pri_dev_type = 0;
- ret = WIFI_DIRECT_ERROR_NONE;
- pri_dev_type = DEFAULT_PRIMARY_DEVICE_TYPE;
- WDS_LOGD("Get primary dev type value is %d", pri_dev_type);
- return_parameters = g_variant_new("(ii)", ret, pri_dev_type);
- goto done;
-
- } else if (!g_strcmp0(method_name, "GetSecondaryDevType")) {
-
- int sec_dev_type = 0;
- ret = WIFI_DIRECT_ERROR_NONE;
- sec_dev_type = DEFAULT_SECONDARY_DEVICE_TYPE;
- WDS_LOGD("Get secondary dev type value is %d", sec_dev_type);
- return_parameters = g_variant_new("(ii)", ret, sec_dev_type);
- goto done;
-
- } else if (!g_strcmp0(method_name, "GetPeerRssi")) {
- wfd_device_s *peer = NULL;
- const char *mac_address = NULL;
- unsigned char mac_addr[MACADDR_LEN] = {0, };
-
- g_variant_get(parameters, "(&s)", &mac_address);
- macaddr_atoe(mac_address, mac_addr);
-
- if (manager->state < WIFI_DIRECT_STATE_ACTIVATED) {
- ret = WIFI_DIRECT_ERROR_NOT_PERMITTED;
- goto failed;
- }
-
- peer = wfd_manager_get_peer_by_addr(manager, mac_addr);
- if (!peer) {
- WDS_LOGE("Failed to get peer");
- ret = WIFI_DIRECT_ERROR_INVALID_PARAMETER;
- goto failed;
- }
-
- ret = WIFI_DIRECT_ERROR_NONE;
- return_parameters = g_variant_new("(ii)", ret, peer->rssi);
- goto done;
-
- } else if (!g_strcmp0(method_name, "AddVsie")) {
- const char *vsie = NULL;
- int frame_id = 0;
-
- g_variant_get(parameters, "(i&s)", &frame_id, &vsie);
-
- if (manager->state < WIFI_DIRECT_STATE_ACTIVATED) {
- ret = WIFI_DIRECT_ERROR_NOT_PERMITTED;
- goto failed;
- }
-
- if (wfd_oem_add_vsie(manager->oem_ops, frame_id, vsie) < 0) {
- WDS_LOGE("Failed to add vsie");
- ret = WIFI_DIRECT_ERROR_OPERATION_FAILED;
- goto failed;
- }
-
- ret = WIFI_DIRECT_ERROR_NONE;
- return_parameters = g_variant_new("(i)", ret);
- goto done;
-
- } else if (!g_strcmp0(method_name, "GetVsie")) {
- char *vsie = NULL;
- int frame_id = 0;
-
- g_variant_get(parameters, "(i)", &frame_id);
-
- if (manager->state < WIFI_DIRECT_STATE_ACTIVATED) {
- ret = WIFI_DIRECT_ERROR_NOT_PERMITTED;
- goto failed;
- }
-
- if (wfd_oem_get_vsie(manager->oem_ops, frame_id, &vsie) < 0) {
- WDS_LOGE("Failed to get vsie");
- ret = WIFI_DIRECT_ERROR_OPERATION_FAILED;
- goto failed;
- }
-
- WDS_LOGD("Received VSIE [%s]", vsie);
-
- ret = WIFI_DIRECT_ERROR_NONE;
- return_parameters = g_variant_new("(is)", ret, vsie);
-
- g_free(vsie);
- goto done;
-
- } else if (!g_strcmp0(method_name, "RemoveVsie")) {
- const char *vsie = NULL;
- int frame_id = 0;
-
- g_variant_get(parameters, "(i&s)", &frame_id, &vsie);
-
- if (manager->state < WIFI_DIRECT_STATE_ACTIVATED) {
- ret = WIFI_DIRECT_ERROR_NOT_PERMITTED;
- goto failed;
- }
-
- if (wfd_oem_remove_vsie(manager->oem_ops, frame_id, vsie) < 0) {
- WDS_LOGE("Failed to remove vsie");
- ret = WIFI_DIRECT_ERROR_OPERATION_FAILED;
- goto failed;
- }
-
- ret = WIFI_DIRECT_ERROR_NONE;
- return_parameters = g_variant_new("(i)", ret);
- goto done;
+ __WDS_LOG_FUNC_ENTER__;
+ GHashTable *new_hash_tbl;
+ int cnt;
+ int ret = -1;
- } else {
- WDS_LOGE("method not handled");
- ret = WIFI_DIRECT_ERROR_OPERATION_FAILED;
- goto failed;
+ new_hash_tbl = NULL;
+ new_hash_tbl = g_hash_table_new(g_str_hash, g_str_equal);
+ if (!new_hash_tbl) {
+ __WDS_LOG_FUNC_EXIT__;
+ return ret;
}
-done:
- WFD_DBUS_REPLY_PARAMS(invocation, return_parameters);
- return;
-
-failed:
- wfd_error_set_gerror(ret, &err);
- g_dbus_method_invocation_return_gerror(invocation, err);
- g_clear_error(&err);
- return;
-}
-
-static void __wfd_manager_service_iface_handler(const gchar *method_name,
- GVariant *parameters,
- GDBusMethodInvocation *invocation)
-{
- int ret = WIFI_DIRECT_ERROR_OPERATION_FAILED;
- wfd_manager_s *manager = wfd_get_manager();
- GVariant *return_parameters = NULL;
- GError *err = NULL;
- WDS_LOGD("%s", method_name);
-
- if (!g_strcmp0(method_name, "StartDiscovery")) {
- const char *mac_address = NULL;
- int service_type;
- unsigned char mac_addr[MACADDR_LEN] = {0, };
-
- if (!manager->is_service_discovery_supported) {
- WDS_LOGE("Wi-Fi Direct service discovery is not supported.");
- ret = WIFI_DIRECT_ERROR_NOT_SUPPORTED;
- goto failed;
- }
-
- if (manager->state < WIFI_DIRECT_STATE_ACTIVATED) {
- WDS_LOGE("Wi-Fi Direct is not activated.");
- ret = WIFI_DIRECT_ERROR_NOT_PERMITTED;
- goto failed;
- }
-
- g_variant_get(parameters, "(i&s)", &service_type, &mac_address);
- if (mac_address == NULL) {
- ret = WIFI_DIRECT_ERROR_INVALID_PARAMETER;
- goto failed;
- }
-
- WDS_LOGD("Service type [%d]", service_type);
- macaddr_atoe(mac_address, mac_addr);
-
- ret = wfd_oem_start_service_discovery(manager->oem_ops,
- mac_addr, service_type);
- if (ret < 0) {
- WDS_LOGE("Failed to start service discovery");
- ret = WIFI_DIRECT_ERROR_OPERATION_FAILED;
- goto failed;
- }
-
- WFD_DBUS_REPLY_ERROR_NONE(invocation);
-
- wfd_manager_dbus_emit_signal(WFD_MANAGER_SERVICE_INTERFACE,
- "DiscoveryStarted", NULL);
- return;
-
- } else if (!g_strcmp0(method_name, "StopDiscovery")) {
- const char *mac_address = NULL;
- int service_type;
- unsigned char mac_addr[MACADDR_LEN] = {0, };
-
- if (!manager->is_service_discovery_supported) {
- WDS_LOGE("Wi-Fi Direct service discovery is not supported.");
- ret = WIFI_DIRECT_ERROR_NOT_SUPPORTED;
- goto failed;
- }
-
- if (manager->state < WIFI_DIRECT_STATE_ACTIVATED) {
- WDS_LOGE("Wi-Fi Direct is not activated.");
- ret = WIFI_DIRECT_ERROR_NOT_PERMITTED;
- goto failed;
- }
-
- g_variant_get(parameters, "(i&s)", &service_type, &mac_address);
- if (mac_address == NULL) {
- ret = WIFI_DIRECT_ERROR_INVALID_PARAMETER;
- goto failed;
- }
-
- WDS_LOGD("Service type [%d]", service_type);
- macaddr_atoe(mac_address, mac_addr);
-
- ret = wfd_oem_cancel_service_discovery(manager->oem_ops,
- mac_addr, service_type);
- if (ret < 0) {
- WDS_LOGE("Failed to cancel service discovery");
- ret = WIFI_DIRECT_ERROR_OPERATION_FAILED;
- goto failed;
- }
- ret = WIFI_DIRECT_ERROR_NONE;
- return_parameters = g_variant_new("(i)", ret);
- goto done;
-
- } else if (!g_strcmp0(method_name, "Register")) {
- int service_type;
- int service_id = 0;
- const char *info_str = NULL;
-
- if (!manager->is_service_discovery_supported) {
- WDS_LOGE("Wi-Fi Direct service discovery is not supported.");
- ret = WIFI_DIRECT_ERROR_NOT_SUPPORTED;
- goto failed;
- }
-
- if (manager->state < WIFI_DIRECT_STATE_ACTIVATED) {
- WDS_LOGE("Wi-Fi Direct is not activated.");
- ret = WIFI_DIRECT_ERROR_NOT_PERMITTED;
- goto failed;
- }
-
- g_variant_get(parameters, "(i&s)", &service_type, &info_str);
- WDS_LOGD("Register service [%d: %s]", service_type, info_str);
-
- ret = wfd_service_add(service_type, (char *)info_str, &service_id);
- if (ret < 0) {
- WDS_LOGE("Failed to add service");
- ret = WIFI_DIRECT_ERROR_OPERATION_FAILED;
- goto failed;
- }
-
- ret = WIFI_DIRECT_ERROR_NONE;
- return_parameters = g_variant_new("(ii)", ret, service_id);
- goto done;
-
- } else if (!g_strcmp0(method_name, "Deregister")) {
- int service_id = 0;
-
- if (!manager->is_service_discovery_supported) {
- WDS_LOGE("Wi-Fi Direct service discovery is not supported.");
- ret = WIFI_DIRECT_ERROR_NOT_SUPPORTED;
- goto failed;
- }
-
- if (manager->state < WIFI_DIRECT_STATE_ACTIVATED) {
- WDS_LOGE("Wi-Fi Direct is not activated.");
- ret = WIFI_DIRECT_ERROR_NOT_PERMITTED;
- goto failed;
- }
-
- g_variant_get(parameters, "(i)", &service_id);
- WDS_LOGD("Service id [%d]", service_id);
-
- ret = wfd_service_del(service_id);
- if (ret < 0) {
- WDS_LOGE("Failed to delete service");
- ret = WIFI_DIRECT_ERROR_OPERATION_FAILED;
- goto failed;
- }
-
- ret = WIFI_DIRECT_ERROR_NONE;
- return_parameters = g_variant_new("(i)", ret);
- goto done;
-
- } else {
- WDS_LOGD("method not handled");
- ret = WIFI_DIRECT_ERROR_OPERATION_FAILED;
- goto failed;
+ cnt = 0;
+ while (handler[cnt].method_str != NULL) {
+ g_hash_table_insert(new_hash_tbl,
+ (gpointer)handler[cnt].method_str,
+ (gpointer)handler[cnt].handler);
+ cnt++;
}
+ wfd_manager_iface_tbl[idx] = new_hash_tbl;
-done:
- WFD_DBUS_REPLY_PARAMS(invocation, return_parameters);
- return;
-
-failed:
- wfd_error_set_gerror(ret, &err);
- g_dbus_method_invocation_return_gerror(invocation, err);
- g_clear_error(&err);
- return;
+ __WDS_LOG_FUNC_EXIT__;
+ return 0;
}
-static void __wfd_manager_display_iface_handler(const gchar *method_name,
- GVariant *parameters,
- GDBusMethodInvocation *invocation)
+int wfd_manager_iface_init()
{
- int ret = WIFI_DIRECT_ERROR_OPERATION_FAILED;
- wfd_manager_s *manager = wfd_get_manager();
- GVariant *return_parameters = NULL;
- GError *err = NULL;
- WDS_LOGD("%s", method_name);
-
- if (!g_strcmp0(method_name, "Init")) {
- if (!manager->is_wifi_display_supported) {
- ret = WIFI_DIRECT_ERROR_NOT_SUPPORTED;
- goto failed;
- }
-
- if (manager->state < WIFI_DIRECT_STATE_ACTIVATED) {
- ret = WIFI_DIRECT_ERROR_NOT_PERMITTED;
- goto failed;
- }
-
- wfd_device_s * device = manager->local;
-
- ret = wfd_oem_miracast_init(manager->oem_ops, TRUE);
- if (ret < 0) {
- WDS_LOGE("Failed to initialize display");
- ret = WIFI_DIRECT_ERROR_OPERATION_FAILED;
- goto failed;
- }
-
- device->display.type = WIFI_DISPLAY_DEFAULT_TYPE;
- device->display.port = WIFI_DISPLAY_DEFAULT_PORT;
- device->display.availability = WIFI_DISPLAY_DEFAULT_AVAIL;
- device->display.hdcp_support = WIFI_DISPLAY_DEFAULT_HDCP;
-
- ret = WIFI_DIRECT_ERROR_NONE;
- return_parameters = g_variant_new("(i)", ret);
- goto done;
-
- } else if (!g_strcmp0(method_name, "Deinit")) {
- if (!manager->is_wifi_display_supported) {
- ret = WIFI_DIRECT_ERROR_NOT_SUPPORTED;
- goto failed;
- }
-
- if (manager->state < WIFI_DIRECT_STATE_ACTIVATED) {
- ret = WIFI_DIRECT_ERROR_NOT_PERMITTED;
- goto failed;
- }
-
- wfd_device_s * device = manager->local;
-
- ret = wfd_oem_miracast_init(manager->oem_ops, FALSE);
- if (ret < 0) {
- WDS_LOGE("Failed to deinitialize display");
- ret = WIFI_DIRECT_ERROR_OPERATION_FAILED;
- goto failed;
- }
-
- memset(&(device->display), 0x0, sizeof(wfd_display_type_e));
-
- ret = WIFI_DIRECT_ERROR_NONE;
- return_parameters = g_variant_new("(i)", ret);
- goto done;
-
- } else if (!g_strcmp0(method_name, "SetConfig")) {
- int type, port, hdcp;
-
- if (!manager->is_wifi_display_supported) {
- ret = WIFI_DIRECT_ERROR_NOT_SUPPORTED;
- goto failed;
- }
-
- if (manager->state < WIFI_DIRECT_STATE_ACTIVATED) {
- ret = WIFI_DIRECT_ERROR_NOT_PERMITTED;
- goto failed;
- }
-
- g_variant_get(parameters, "(iii)", &type, &port, &hdcp);
- WDS_LOGD("type %d port %d hdcp %d", type, port, hdcp);
-
- ret = wfd_manager_set_display_device(type, port, hdcp);
- if (ret < 0) {
- WDS_LOGE("Failed to set display device settings");
- ret = WIFI_DIRECT_ERROR_OPERATION_FAILED;
- goto failed;
- }
-
- ret = WIFI_DIRECT_ERROR_NONE;
- return_parameters = g_variant_new("(i)", ret);
- goto done;
-
- } else if (!g_strcmp0(method_name, "SetAvailiability")) {
- int availability;
-
- if (!manager->is_wifi_display_supported) {
- ret = WIFI_DIRECT_ERROR_NOT_SUPPORTED;
- goto failed;
- }
-
- if (manager->state < WIFI_DIRECT_STATE_ACTIVATED) {
- ret = WIFI_DIRECT_ERROR_NOT_PERMITTED;
- goto failed;
- }
-
- g_variant_get(parameters, "(i)", &availability);
- ret = wfd_manager_set_session_availability(availability);
- if (ret < 0) {
- WDS_LOGE("Failed to set session availability");
- ret = WIFI_DIRECT_ERROR_OPERATION_FAILED;
- goto failed;
- }
-
- ret = WIFI_DIRECT_ERROR_NONE;
- return_parameters = g_variant_new("(i)", ret);
- goto done;
-
- } else if (!g_strcmp0(method_name, "GetPeerType")) {
- wfd_device_s *peer = NULL;
- const char *mac_address = NULL;
- unsigned char mac_addr[MACADDR_LEN] = {0, };
-
- if (!manager->is_wifi_display_supported) {
- ret = WIFI_DIRECT_ERROR_NOT_SUPPORTED;
- goto failed;
- }
-
- if (manager->state < WIFI_DIRECT_STATE_ACTIVATED) {
- ret = WIFI_DIRECT_ERROR_NOT_PERMITTED;
- goto failed;
- }
-
- g_variant_get(parameters, "(&s)", &mac_address);
- if (mac_address == NULL) {
- ret = WIFI_DIRECT_ERROR_INVALID_PARAMETER;
- goto failed;
- }
-
- macaddr_atoe(mac_address, mac_addr);
- peer = wfd_manager_get_peer_by_addr(manager, mac_addr);
- if (!peer) {
- WDS_LOGE("Failed to get peer");
- ret = WIFI_DIRECT_ERROR_INVALID_PARAMETER;
- goto failed;
- }
-
- ret = WIFI_DIRECT_ERROR_NONE;
- return_parameters = g_variant_new("(ii)", ret, peer->display.type);
- goto done;
-
- } else if (!g_strcmp0(method_name, "GetPeerAvailability")) {
- wfd_device_s *peer = NULL;
- const char *mac_address = NULL;
- unsigned char mac_addr[MACADDR_LEN] = {0, };
-
- if (!manager->is_wifi_display_supported) {
- ret = WIFI_DIRECT_ERROR_NOT_SUPPORTED;
- goto failed;
- }
-
- if (manager->state < WIFI_DIRECT_STATE_ACTIVATED) {
- ret = WIFI_DIRECT_ERROR_NOT_PERMITTED;
- goto failed;
- }
-
- g_variant_get(parameters, "(&s)", &mac_address);
- if (mac_address == NULL) {
- ret = WIFI_DIRECT_ERROR_INVALID_PARAMETER;
- goto failed;
- }
-
- macaddr_atoe(mac_address, mac_addr);
- peer = wfd_manager_get_peer_by_addr(manager, mac_addr);
- if (!peer) {
- WDS_LOGE("Failed to get peer");
- ret = WIFI_DIRECT_ERROR_INVALID_PARAMETER;
- goto failed;
- }
-
- ret = WIFI_DIRECT_ERROR_NONE;
- return_parameters = g_variant_new("(ii)", ret, peer->display.availability);
- goto done;
-
- } else if (!g_strcmp0(method_name, "GetPeerHdcp")) {
- wfd_device_s *peer = NULL;
- const char *mac_address = NULL;
- unsigned char mac_addr[MACADDR_LEN] = {0, };
-
- if (!manager->is_wifi_display_supported) {
- ret = WIFI_DIRECT_ERROR_NOT_SUPPORTED;
- goto failed;
- }
-
- if (manager->state < WIFI_DIRECT_STATE_ACTIVATED) {
- ret = WIFI_DIRECT_ERROR_NOT_PERMITTED;
- goto failed;
- }
-
- g_variant_get(parameters, "(&s)", &mac_address);
- if (mac_address == NULL) {
- ret = WIFI_DIRECT_ERROR_INVALID_PARAMETER;
- goto failed;
- }
-
- macaddr_atoe(mac_address, mac_addr);
- peer = wfd_manager_get_peer_by_addr(manager, mac_addr);
- if (!peer) {
- WDS_LOGE("Failed to get peer");
- ret = WIFI_DIRECT_ERROR_INVALID_PARAMETER;
- goto failed;
- }
-
- ret = WIFI_DIRECT_ERROR_NONE;
- return_parameters = g_variant_new("(ii)", ret, peer->display.hdcp_support);
- goto done;
-
- } else if (!g_strcmp0(method_name, "GetPeerPort")) {
- wfd_device_s *peer = NULL;
- const char *mac_address = NULL;
- unsigned char mac_addr[MACADDR_LEN] = {0, };
-
- if (!manager->is_wifi_display_supported) {
- ret = WIFI_DIRECT_ERROR_NOT_SUPPORTED;
- goto failed;
- }
-
- if (manager->state < WIFI_DIRECT_STATE_ACTIVATED) {
- ret = WIFI_DIRECT_ERROR_NOT_PERMITTED;
- goto failed;
- }
-
- g_variant_get(parameters, "(&s)", &mac_address);
- if (mac_address == NULL) {
- ret = WIFI_DIRECT_ERROR_INVALID_PARAMETER;
- goto failed;
- }
-
- macaddr_atoe(mac_address, mac_addr);
- peer = wfd_manager_get_peer_by_addr(manager, mac_addr);
- if (!peer) {
- WDS_LOGE("Failed to get peer");
- ret = WIFI_DIRECT_ERROR_INVALID_PARAMETER;
- goto failed;
- }
-
- ret = WIFI_DIRECT_ERROR_NONE;
- return_parameters = g_variant_new("(ii)", ret, peer->display.port);
- goto done;
-
- } else if (!g_strcmp0(method_name, "GetPeerThroughput")) {
- wfd_device_s *peer = NULL;
- const char *mac_address = NULL;
- unsigned char mac_addr[MACADDR_LEN] = {0, };
-
- if (!manager->is_wifi_display_supported) {
- ret = WIFI_DIRECT_ERROR_NOT_SUPPORTED;
- goto failed;
- }
-
- if (manager->state < WIFI_DIRECT_STATE_ACTIVATED) {
- ret = WIFI_DIRECT_ERROR_NOT_PERMITTED;
- goto failed;
- }
-
- g_variant_get(parameters, "(&s)", &mac_address);
- if (mac_address == NULL) {
- ret = WIFI_DIRECT_ERROR_INVALID_PARAMETER;
- goto failed;
- }
+ __WDS_LOG_FUNC_ENTER__;
+ /*test manage iface */
+ int ret = -1;
+ int cnt;
- macaddr_atoe(mac_address, mac_addr);
- peer = wfd_manager_get_peer_by_addr(manager, mac_addr);
- if (!peer) {
- WDS_LOGE("Failed to get peer");
- ret = WIFI_DIRECT_ERROR_INVALID_PARAMETER;
- goto failed;
- }
+ for (cnt = 0; cnt < WFD_IFACE_MAX; cnt++)
+ wfd_manager_iface_tbl[cnt] = NULL;
- ret = WIFI_DIRECT_ERROR_NONE;
- return_parameters = g_variant_new("(ii)", ret, peer->display.max_tput);
- goto done;
- } else {
- WDS_LOGD("method not handled");
- ret = WIFI_DIRECT_ERROR_OPERATION_FAILED;
- goto failed;
+ if (set_iface_hash(wfd_manager_iface_manage, WFD_IFACE_MANAGE) != 0) {
+ wfd_manager_iface_deinit();
+ __WDS_LOG_FUNC_EXIT__;
+ return ret;
}
-done:
- WFD_DBUS_REPLY_PARAMS(invocation, return_parameters);
- return;
-
-failed:
- wfd_error_set_gerror(ret, &err);
- g_dbus_method_invocation_return_gerror(invocation, err);
- g_clear_error(&err);
- return;
-}
-
-static void __g_variant_to_txt_record(GVariant *variant, char **txt_record)
-{
- GVariantIter *iter = NULL;
- gchar *key = NULL;
- GVariant *value = NULL;
- char *buff = NULL;
- const char *str = NULL;
- char *pos = NULL;
- int txt_length = 0;
- int key_length = 0;
- gsize value_length = 0;
- __WDS_LOG_FUNC_ENTER__;
-
- DBUS_DEBUG_VARIANT(variant);
-
- g_variant_get(variant, "a{sv}", &iter);
- if (!iter) {
+ if (set_iface_hash(wfd_manager_iface_group, WFD_IFACE_GROUP) != 0) {
+ wfd_manager_iface_deinit();
__WDS_LOG_FUNC_EXIT__;
- return;
+ return ret;
}
- while (g_variant_iter_loop(iter, "{sv}", &key, &value)) {
- WDS_LOGD("%s %s", key, g_variant_get_string(value, &value_length));
- txt_length += strlen(key);
- str = g_variant_get_string(value, &value_length);
- txt_length += (int)value_length;
- txt_length += 2;
+ if (set_iface_hash(wfd_manager_iface_config, WFD_IFACE_CONFIG) != 0) {
+ wfd_manager_iface_deinit();
+ __WDS_LOG_FUNC_EXIT__;
+ return ret;
}
- g_variant_iter_free(iter);
- if (txt_length == 0) {
+ if (set_iface_hash(wfd_manager_iface_service, WFD_IFACE_SERVICE) != 0) {
+ wfd_manager_iface_deinit();
__WDS_LOG_FUNC_EXIT__;
- return;
+ return ret;
}
- buff = g_try_malloc0(txt_length);
- if (buff == NULL) {
- WDS_LOGE("g_try_malloc0 failed");
+ if (set_iface_hash(wfd_manager_iface_display, WFD_IFACE_DISPLAY) != 0) {
+ wfd_manager_iface_deinit();
__WDS_LOG_FUNC_EXIT__;
- return;
+ return ret;
}
- pos = buff;
- g_variant_get(variant, "a{sv}", &iter);
- while (g_variant_iter_loop(iter, "{sv}", &key, &value)) {
- key_length = strlen(key);
- str = g_variant_get_string(value, &value_length);
-
- g_strlcpy(pos, key, key_length + 1);
- pos += key_length;
- pos[0] = '=';
- pos++;
- g_strlcpy(pos, str, value_length + 1);
- pos += (int)value_length;
- pos[0] = ',';
- pos++;
+ if (set_iface_hash(wfd_manager_iface_asp, WFD_IFACE_ASP) != 0) {
+ wfd_manager_iface_deinit();
+ __WDS_LOG_FUNC_EXIT__;
+ return ret;
}
- buff[txt_length -1] = '\0';
-
- g_variant_iter_free(iter);
- *txt_record = buff;
__WDS_LOG_FUNC_EXIT__;
- return;
+ return 0;
}
-static void __g_variant_to_seek_info(GVariant *variant, char **seek_info)
+void wfd_manager_iface_deinit()
{
- GVariantIter *iter = NULL;
- gchar *key = NULL;
- char *buff = NULL;
- char *pos = NULL;
- int seek_length = 0;
- int key_length = 0;
-
- DBUS_DEBUG_VARIANT(variant);
- g_variant_get(variant, "as", &iter);
-
- if (!iter)
- return;
-
- while (g_variant_iter_loop(iter, "s", &key)) {
- seek_length += strlen(key);
- seek_length += 1;
- }
-
- g_variant_iter_free(iter);
- if (seek_length == 0)
- return;
-
- buff = g_try_malloc0(seek_length);
- if (buff == NULL) {
- WDS_LOGE("g_try_malloc0 failed");
- return;
- }
- pos = buff;
- g_variant_get(variant, "as", &iter);
- while (g_variant_iter_loop(iter, "s", &key)) {
- key_length = strlen(key);
-
- g_strlcpy(pos, key, key_length + 1);
- pos += key_length;
- pos[0] = ',';
- pos++;
+ __WDS_LOG_FUNC_ENTER__;
+ int cnt;
+ for (cnt = 0; cnt < WFD_IFACE_MAX; cnt++) {
+ if (wfd_manager_iface_tbl[cnt])
+ g_hash_table_destroy(wfd_manager_iface_tbl[cnt]);
+ wfd_manager_iface_tbl[cnt] = NULL;
}
- buff[seek_length -1] = '\0';
-
- g_variant_iter_free(iter);
- *seek_info = buff;
-
+ __WDS_LOG_FUNC_EXIT__;
return;
}
-static void __get_asp_advertise_params(GVariantIter *iter, wfd_oem_asp_service_s *service, int *replace)
+void wfd_manager_iface_manage_handler(const char *method,
+ GVariant *parameters,
+ GDBusMethodInvocation *invocation)
{
- gchar *key = NULL;
- GVariant *var = NULL;
-
- if (!iter)
- return;
+ __WDS_LOG_FUNC_ENTER__;
+ method_handler handler;
+ handler = (method_handler)g_hash_table_lookup
+ (wfd_manager_iface_tbl[WFD_IFACE_MANAGE], method);
- while (g_variant_iter_loop(iter, "{sv}", &key, &var)) {
- if (!g_strcmp0(key, "adv_id"))
- g_variant_get(var, "u", &(service->adv_id));
- else if (!g_strcmp0(key, "discovery_tech"))
- g_variant_get(var, "i", &(service->discovery_tech));
- else if (!g_strcmp0(key, "preferred_connection"))
- g_variant_get(var, "y", &(service->preferred_connection));
- else if (!g_strcmp0(key, "auto_accept"))
- g_variant_get(var, "i", &(service->auto_accept));
- else if (!g_strcmp0(key, "status"))
- g_variant_get(var, "y", &(service->status));
- else if (!g_strcmp0(key, "role"))
- g_variant_get(var, "y", &(service->role));
- else if (!g_strcmp0(key, "replace"))
- g_variant_get(var, "i", replace);
- else if (!g_strcmp0(key, "config_method"))
- g_variant_get(var, "u", &(service->config_method));
- else if (!g_strcmp0(key, "instance_name"))
- g_variant_get(var, "&s", &(service->instance_name));
- else if (!g_strcmp0(key, "service_type"))
- g_variant_get(var, "&s", &(service->service_type));
- else if (!g_strcmp0(key, "service_info"))
- __g_variant_to_txt_record(var, &(service->service_info));
- else if (!g_strcmp0(key, "rsp_info"))
- g_variant_get(var, "&s", &(service->rsp_info));
- else
- ;/* Do Nothing */
- }
+ if (handler)
+ handler(parameters, invocation);
return;
}
-
-static void __get_asp_seek_params(GVariantIter *iter, wfd_oem_asp_service_s *service)
+void wfd_manager_iface_group_handler(const char *method,
+ GVariant *parameters,
+ GDBusMethodInvocation *invocation)
{
- gchar *key = NULL;
- GVariant *var = NULL;
+ __WDS_LOG_FUNC_ENTER__;
+ method_handler handler;
- if (!iter)
- return;
+ handler = (method_handler)g_hash_table_lookup
+ (wfd_manager_iface_tbl[WFD_IFACE_GROUP], method);
- while (g_variant_iter_loop(iter, "{sv}", &key, &var)) {
- if (!g_strcmp0(key, "discovery_tech"))
- g_variant_get(var, "i", &(service->discovery_tech));
- else if (!g_strcmp0(key, "search_id"))
- g_variant_get(var, "t", &(service->asp_search_id));
- else if (!g_strcmp0(key, "preferred_connection"))
- g_variant_get(var, "y", &(service->preferred_connection));
- else if (!g_strcmp0(key, "service_type"))
- g_variant_get(var, "&s", &(service->service_type));
- else if (!g_strcmp0(key, "service_info"))
- __g_variant_to_seek_info(var, &(service->service_info));
- else
- ;/* Do Nothing */
- }
+ if (handler)
+ handler(parameters, invocation);
+ __WDS_LOG_FUNC_EXIT__;
return;
}
-static void __get_asp_connect_params(GVariantIter *iter, wfd_oem_asp_prov_s *prov_params)
+void wfd_manager_iface_config_handler(const char *method,
+ GVariant *parameters,
+ GDBusMethodInvocation *invocation)
{
- gchar *key = NULL;
- GVariant *var = NULL;
- const char *mac_str = NULL;
- unsigned char role = 0;
- unsigned int config = 0;
-
- if (!iter)
- return;
-
- while (g_variant_iter_loop(iter, "{sv}", &key, &var)) {
-
- if (!g_strcmp0(key, "service_mac")) {
- g_variant_get(var, "&s", &mac_str);
- if (mac_str == NULL)
- memset(prov_params->service_mac, 0, sizeof(prov_params->service_mac));
- else
- macaddr_atoe(mac_str, prov_params->service_mac);
- } else if (!g_strcmp0(key, "adv_id")) {
- g_variant_get(var, "u", &(prov_params->adv_id));
- } else if (!g_strcmp0(key, "session_mac")) {
- g_variant_get(var, "&s", &mac_str);
- if (mac_str == NULL)
- memset(prov_params->session_mac, 0, sizeof(prov_params->session_mac));
- else
- macaddr_atoe(mac_str, prov_params->session_mac);
- } else if (!g_strcmp0(key, "session_id")) {
- g_variant_get(var, "u", &(prov_params->session_id));
- } else if (!g_strcmp0(key, "role")) {
- g_variant_get(var, "y", &(role));
- prov_params->network_role = (int)role;
- } else if (!g_strcmp0(key, "config_method")) {
- g_variant_get(var, "u", &(config));
- prov_params->network_config = (int)config;
- } else if (!g_strcmp0(key, "session_info")) {
- g_variant_get(var, "&s", &(prov_params->session_information));
- } else {
- ;/* Do Nothing */
- }
- }
+ __WDS_LOG_FUNC_ENTER__;
+ method_handler handler;
+ handler = (method_handler)g_hash_table_lookup
+ (wfd_manager_iface_tbl[WFD_IFACE_CONFIG], method);
+ if (handler)
+ handler(parameters, invocation);
+ __WDS_LOG_FUNC_EXIT__;
return;
}
-
-static void __get_asp_confirm_params(GVariantIter *iter, wfd_oem_asp_prov_s *prov_params, int *confirmed)
+void wfd_manager_iface_service_handler(const char *method,
+ GVariant *parameters,
+ GDBusMethodInvocation *invocation)
{
- gchar *key = NULL;
- GVariant *var = NULL;
- const char *mac_str = NULL;
- const char *pin = NULL;
-
- if (!iter)
- return;
-
- while (g_variant_iter_loop(iter, "{sv}", &key, &var)) {
-
- if (!g_strcmp0(key, "service_mac")) {
- g_variant_get(var, "&s", &mac_str);
- if (mac_str == NULL)
- memset(prov_params->service_mac, 0, sizeof(prov_params->service_mac));
- else
- macaddr_atoe(mac_str, prov_params->service_mac);
- } else if (!g_strcmp0(key, "adv_id")) {
- g_variant_get(var, "u", &(prov_params->adv_id));
- } else if (!g_strcmp0(key, "session_mac")) {
- g_variant_get(var, "&s", &mac_str);
- if (mac_str == NULL)
- memset(prov_params->session_mac, 0, sizeof(prov_params->session_mac));
- else
- macaddr_atoe(mac_str, prov_params->session_mac);
- } else if (!g_strcmp0(key, "session_id")) {
- g_variant_get(var, "u", &(prov_params->session_id));
- } else if (!g_strcmp0(key, "confirm")) {
- g_variant_get(var, "i", confirmed);
- } else if (!g_strcmp0(key, "pin")) {
- g_variant_get(var, "&s", &(pin));
- g_strlcpy(prov_params->wps_pin, pin, PINSTR_LEN);
- } else {
- ;/* Do Nothing */
- }
- }
+ __WDS_LOG_FUNC_ENTER__;
+ method_handler handler;
+ handler = (method_handler)g_hash_table_lookup
+ (wfd_manager_iface_tbl[WFD_IFACE_SERVICE], method);
+ if (handler)
+ handler(parameters, invocation);
+ __WDS_LOG_FUNC_EXIT__;
return;
}
-static void __wfd_manager_asp_iface_handler(const gchar *method_name,
- GVariant *parameters,
- GDBusMethodInvocation *invocation)
+void wfd_manager_iface_display_handler(const char *method,
+ GVariant *parameters,
+ GDBusMethodInvocation *invocation)
{
- int ret = WIFI_DIRECT_ERROR_OPERATION_FAILED;
- wfd_manager_s *manager = wfd_get_manager();
- GVariant *return_parameters = NULL;
- GVariantIter *iter = NULL;
- GError *err = NULL;
- WDS_LOGD("%s", method_name);
-
- if (!manager) {
- WDS_LOGD("manager is not initialized.");
- ret = WIFI_DIRECT_ERROR_OPERATION_FAILED;
- goto failed;
- }
-
- if (!g_strcmp0(method_name, "AdvertiseService")) {
-
- wfd_oem_asp_service_s service;
- int replace = 0;
-
- if (!manager->is_asp_supported) {
- WDS_LOGD("ASP is not supported.");
- ret = WIFI_DIRECT_ERROR_NOT_SUPPORTED;
- goto failed;
- }
-
- if (manager->state != WIFI_DIRECT_STATE_ACTIVATED &&
- manager->state != WIFI_DIRECT_STATE_DISCOVERING &&
- manager->state >= WIFI_DIRECT_STATE_CONNECTED) {
- WDS_LOGE("Wi-Fi Direct is not available status for Advertising.");
- ret = WIFI_DIRECT_ERROR_NOT_PERMITTED;
- goto failed;
- }
-
- g_variant_get(parameters, "(a{sv})", &iter);
- if (!iter) {
- ret = WIFI_DIRECT_ERROR_INVALID_PARAMETER;
- goto failed;
- }
-
- memset(&service, 0, sizeof(wfd_oem_asp_service_s));
- __get_asp_advertise_params(iter, &service, &replace);
- ret = wfd_oem_advertise_service(manager->oem_ops, &service, replace);
- if (ret < 0) {
- WDS_LOGE("Failed to add service");
- g_free(service.service_info);
- g_variant_iter_free(iter);
- ret = WIFI_DIRECT_ERROR_OPERATION_FAILED;
- goto failed;
- }
- g_free(service.service_info);
- g_variant_iter_free(iter);
-
- if (manager->local->dev_role == WFD_DEV_ROLE_GO) {
- WDS_LOGW("Wi-Fi Direct device is already visible, do not start listen");
- goto done;
- }
-
- ret = wfd_manager_start_discovery(manager,
- WFD_OEM_SCAN_MODE_PASSIVE, 0,
- 0, 0, 0);
- if (ret == WIFI_DIRECT_ERROR_NONE) {
- wfd_manager_dbus_emit_signal(WFD_MANAGER_MANAGE_INTERFACE,
- "ListenStarted",
- NULL);
- } else {
- wfd_oem_cancel_advertise_service(manager->oem_ops, &service);
- ret = WIFI_DIRECT_ERROR_OPERATION_FAILED;
- goto failed;
- }
-
- ret = WIFI_DIRECT_ERROR_NONE;
- return_parameters = g_variant_new("(i)", ret);
- goto done;
-
- } else if (!g_strcmp0(method_name, "CancelAdvertiseService")) {
-
- wfd_oem_asp_service_s service;
- memset(&service, 0, sizeof(wfd_oem_asp_service_s));
-
- if (!manager->is_asp_supported) {
- WDS_LOGD("ASP is not supported.");
- ret = WIFI_DIRECT_ERROR_NOT_SUPPORTED;
- goto failed;
- }
-
- if (manager->state < WIFI_DIRECT_STATE_ACTIVATED) {
- ret = WIFI_DIRECT_ERROR_NOT_PERMITTED;
- goto failed;
- }
-
- g_variant_get(parameters, "(u)", &(service.adv_id));
- ret = wfd_oem_cancel_advertise_service(manager->oem_ops, &service);
- if (ret < 0) {
- WDS_LOGE("Failed to del service");
- ret = WIFI_DIRECT_ERROR_OPERATION_FAILED;
- goto failed;
- }
-
- ret = WIFI_DIRECT_ERROR_NONE;
- return_parameters = g_variant_new("(i)", ret);
- goto done;
-
- } else if (!g_strcmp0(method_name, "SeekService")) {
-
- wfd_oem_asp_service_s service;
- GVariantIter *iter = NULL;
-
- if (!manager->is_asp_supported) {
- WDS_LOGD("ASP is not supported.");
- ret = WIFI_DIRECT_ERROR_NOT_SUPPORTED;
- goto failed;
- }
-
- if (manager->state != WIFI_DIRECT_STATE_ACTIVATED &&
- manager->state != WIFI_DIRECT_STATE_DISCOVERING &&
- manager->state >= WIFI_DIRECT_STATE_CONNECTED) {
- WDS_LOGE("Wi-Fi Direct is not available status to Seek.");
- ret = WIFI_DIRECT_ERROR_NOT_PERMITTED;
- goto failed;
- }
-
- g_variant_get(parameters, "(a{sv})", &iter);
- if (!iter) {
- ret = WIFI_DIRECT_ERROR_INVALID_PARAMETER;
- goto failed;
- }
-
- memset(&service, 0, sizeof(wfd_oem_asp_service_s));
- __get_asp_seek_params(iter, &service);
- ret = wfd_oem_seek_service(manager->oem_ops, &service);
- if (ret < 0) {
- WDS_LOGE("Failed to seek service");
- g_free(service.service_info);
- g_variant_iter_free(iter);
- ret = WIFI_DIRECT_ERROR_OPERATION_FAILED;
- goto failed;
- }
- g_free(service.service_info);
- g_variant_iter_free(iter);
-
- WDS_LOGD("search_id [%x]", service.search_id);
-
- ret = wfd_manager_start_discovery(manager,
- WFD_OEM_SCAN_MODE_ACTIVE, 0,
- 0, 0, 0);
- if (ret == WIFI_DIRECT_ERROR_NONE) {
- wfd_manager_dbus_emit_signal(WFD_MANAGER_MANAGE_INTERFACE,
- "DiscoveryStarted",
- NULL);
- } else {
- wfd_oem_cancel_seek_service(manager->oem_ops, &service);
- ret = WIFI_DIRECT_ERROR_OPERATION_FAILED;
- goto failed;
- }
-
- ret = WIFI_DIRECT_ERROR_NONE;
- return_parameters = g_variant_new("(i)", ret);
- goto done;
-
- } else if (!g_strcmp0(method_name, "CancelSeekService")) {
-
- wfd_oem_asp_service_s service;
- memset(&service, 0, sizeof(wfd_oem_asp_service_s));
-
- if (!manager->is_asp_supported) {
- WDS_LOGD("ASP is not supported.");
- ret = WIFI_DIRECT_ERROR_NOT_SUPPORTED;
- goto failed;
- }
-
- if (manager->state < WIFI_DIRECT_STATE_ACTIVATED) {
- WDS_LOGE("Wi-Fi Direct is not activated.");
- ret = WIFI_DIRECT_ERROR_NOT_PERMITTED;
- goto failed;
- }
-
- g_variant_get(parameters, "(t)", &(service.asp_search_id));
- ret = wfd_oem_cancel_seek_service(manager->oem_ops, &service);
- if (ret < 0) {
- WDS_LOGE("Failed to cancel seek service");
- ret = WIFI_DIRECT_ERROR_OPERATION_FAILED;
- goto failed;
- }
-
- ret = WIFI_DIRECT_ERROR_NONE;
- return_parameters = g_variant_new("(i)", ret);
- goto done;
- } else if (!g_strcmp0(method_name, "ConnectSession")) {
-
- GVariantIter *iter = NULL;
- wfd_oem_asp_prov_s prov_params;
-
- if (manager && !manager->is_asp_supported) {
- WDS_LOGD("ASP is not supported.");
- ret = WIFI_DIRECT_ERROR_NOT_SUPPORTED;
- goto failed;
- }
-
- if (__is_discovery_available(manager)) {
- ret = WIFI_DIRECT_ERROR_NOT_PERMITTED;
- goto failed;
- }
-
- g_variant_get(parameters, "(a{sv})", &iter);
- if (!iter) {
- ret = WIFI_DIRECT_ERROR_INVALID_PARAMETER;
- goto failed;
- }
-
- memset(&prov_params, 0, sizeof(wfd_oem_asp_prov_s));
- __get_asp_connect_params(iter, &prov_params);
-
- if (ISZEROMACADDR(prov_params.service_mac) ||
- ISZEROMACADDR(prov_params.session_mac)) {
- ret = WIFI_DIRECT_ERROR_INVALID_PARAMETER;
- g_variant_iter_free(iter);
- goto failed;
- }
-
- WFD_DBUS_REPLY_ERROR_NONE(invocation);
-
- wfd_asp_connect_status(prov_params.session_mac,
- prov_params.session_id,
- ASP_CONNECT_STATUS_REQUEST_SENT,
- NULL);
-
- wfd_group_s *group = (wfd_group_s*) manager->group;
- if (group && group->member_count >= manager->max_station) {
-
- wfd_asp_connect_status(prov_params.session_mac,
- prov_params.session_id,
- ASP_CONNECT_STATUS_NOMORE_CONNECT,
- NULL);
- g_variant_iter_free(iter);
- __WDS_LOG_FUNC_EXIT__;
- return;
- }
-
- ret = wfd_manager_asp_connect_session(manager, &prov_params);
- if (ret == WIFI_DIRECT_ERROR_NONE) {
- char peer_mac_address[MACSTR_LEN] = {0,};
- g_snprintf(peer_mac_address, MACSTR_LEN, MACSTR, MAC2STR(prov_params.service_mac));
- wfd_manager_dbus_emit_signal(WFD_MANAGER_MANAGE_INTERFACE,
- "Connection",
- g_variant_new("(iis)", WIFI_DIRECT_ERROR_NONE,
- WFD_EVENT_CONNECTION_IN_PROGRESS,
- peer_mac_address));
- } else {
- wfd_asp_connect_status(prov_params.session_mac,
- prov_params.session_id,
- ASP_CONNECT_STATUS_REQUEST_FAILED,
- NULL);
- }
- g_variant_iter_free(iter);
- __WDS_LOG_FUNC_EXIT__;
- return;
-
- } else if (!g_strcmp0(method_name, "ConfirmSession")) {
-
- GVariantIter *iter = NULL;
- wfd_oem_asp_prov_s prov_params;
- int confirmed = 0;
-
- if (manager && !manager->is_asp_supported) {
- WDS_LOGD("ASP is not supported.");
- ret = WIFI_DIRECT_ERROR_NOT_SUPPORTED;
- goto failed;
- }
-
- if (manager->state != WIFI_DIRECT_STATE_CONNECTING) {
- ret = WIFI_DIRECT_ERROR_NOT_PERMITTED;
- goto failed;
- }
-
- g_variant_get(parameters, "(a{sv})", &iter);
- if (!iter) {
- ret = WIFI_DIRECT_ERROR_INVALID_PARAMETER;
- goto failed;
- }
-
- memset(&prov_params, 0, sizeof(wfd_oem_asp_prov_s));
- __get_asp_confirm_params(iter, &prov_params, &confirmed);
-
- if (ISZEROMACADDR(prov_params.session_mac)) {
- ret = WIFI_DIRECT_ERROR_INVALID_PARAMETER;
- g_variant_iter_free(iter);
- goto failed;
- }
-
- WFD_DBUS_REPLY_ERROR_NONE(invocation);
-
- ret = wfd_manager_asp_confirm_session(manager, &prov_params, confirmed);
- if (ret == WIFI_DIRECT_ERROR_NONE && confirmed > 0) {
- char peer_mac_address[MACSTR_LEN] = {0,};
- g_snprintf(peer_mac_address, MACSTR_LEN, MACSTR, MAC2STR(prov_params.service_mac));
- wfd_manager_dbus_emit_signal(WFD_MANAGER_MANAGE_INTERFACE,
- "Connection",
- g_variant_new("(iis)", WIFI_DIRECT_ERROR_NONE,
- WFD_EVENT_CONNECTION_IN_PROGRESS,
- peer_mac_address));
- wfd_asp_connect_status(prov_params.session_mac,
- prov_params.session_id,
- ASP_CONNECT_STATUS_REQUEST_ACCEPTED,
- NULL);
- } else {
- wfd_asp_connect_status(prov_params.session_mac,
- prov_params.session_id,
- ASP_CONNECT_STATUS_REQUEST_FAILED,
- NULL);
- }
- g_variant_iter_free(iter);
- __WDS_LOG_FUNC_EXIT__;
- return;
- }
-
-done:
- WFD_DBUS_REPLY_PARAMS(invocation, return_parameters);
- __WDS_LOG_FUNC_EXIT__;
- return;
+ __WDS_LOG_FUNC_ENTER__;
+ method_handler handler;
-failed:
- wfd_error_set_gerror(ret, &err);
- g_dbus_method_invocation_return_gerror(invocation, err);
- g_clear_error(&err);
+ handler = (method_handler)g_hash_table_lookup
+ (wfd_manager_iface_tbl[WFD_IFACE_DISPLAY], method);
+ if (handler)
+ handler(parameters, invocation);
__WDS_LOG_FUNC_EXIT__;
return;
}
-static struct {
- guint reg_id;
- const gchar *iface_name;
- void (*function) (const gchar *method_name,
- GVariant *parameters,
- GDBusMethodInvocation *invocation);
-} wfd_manager_iface_map[] = {
- {
- 0,
- WFD_MANAGER_MANAGE_INTERFACE,
- __wfd_manager_manage_iface_handler
- },
- {
- 0,
- WFD_MANAGER_GROUP_INTERFACE,
- __wfd_manager_group_iface_handler
- },
- {
- 0,
- WFD_MANAGER_CONFIG_INTERFACE,
- __wfd_manager_config_iface_handler
- },
- {
- 0,
- WFD_MANAGER_SERVICE_INTERFACE,
- __wfd_manager_service_iface_handler
- },
- {
- 0,
- WFD_MANAGER_DISPLAY_INTERFACE,
- __wfd_manager_display_iface_handler
- },
- {
- 0,
- WFD_MANAGER_ASP_INTERFACE,
- __wfd_manager_asp_iface_handler
- },
- {
- 0,
- NULL,
- NULL
- }
-};
-
-/* GDBus method handler */
-static void wfd_manager_method_call_handler (GDBusConnection *connection,
- const gchar *sender,
- const gchar *object_path,
- const gchar *interface_name,
- const gchar *method_name,
- GVariant *parameters,
- GDBusMethodInvocation *invocation,
- gpointer user_data)
-{
- int count = 0;
-
- if (!g_strcmp0(method_name, "AddClient"))
- wfd_manager_add_active_client(sender);
-
- /* Method Call */
- WDS_LOGD("interface : [%s], method : [%s]", interface_name, method_name);
- DBUS_DEBUG_VARIANT(parameters);
-
- while (wfd_manager_iface_map[count].iface_name != NULL) {
- if (!g_strcmp0(interface_name, wfd_manager_iface_map[count].iface_name)) {
-
- wfd_manager_iface_map[count].function(method_name,
- parameters,
- invocation);
- break;
- }
- count++;
- }
-}
-
-static const GDBusInterfaceVTable wfd_manager_interface_vtable = {
- wfd_manager_method_call_handler, NULL, NULL};
-
-void wfd_manager_dbus_unregister(void)
-{
- int count = 0;
-
- wfd_error_deregister();
-
- while (wfd_manager_iface_map[count].iface_name != NULL) {
- wfd_manager_dbus_iface_unregister(wfd_manager_iface_map[count].reg_id);
- count++;
- }
-}
-
-gboolean wfd_manager_dbus_register(void)
+void wfd_manager_iface_asp_handler(const char *method,
+ GVariant *parameters,
+ GDBusMethodInvocation *invocation)
{
- GDBusNodeInfo *node_info = NULL;
- GError *Error = NULL;
- int count = 0;
-
- wfd_error_register();
-
- node_info = g_dbus_node_info_new_for_xml(wfd_manager_introspection_xml, &Error);
- if (node_info == NULL) {
- WDS_LOGE("Failed to get node info, Error: %s", Error->message);
- g_clear_error(&Error);
- return FALSE;
- }
-
- while (wfd_manager_iface_map[count].iface_name != NULL) {
- wfd_manager_iface_map[count].reg_id =
- wfd_manager_dbus_iface_register(wfd_manager_iface_map[count].iface_name,
- WFD_MANAGER_PATH,
- node_info,
- &wfd_manager_interface_vtable);
-
- WDS_LOGD("Registered Interface [%d, %s]",
- wfd_manager_iface_map[count].reg_id,
- wfd_manager_iface_map[count].iface_name);
-
- count++;
- }
+ __WDS_LOG_FUNC_ENTER__;
+ method_handler handler;
- g_dbus_node_info_unref(node_info);
- return TRUE;
+ handler = (method_handler)g_hash_table_lookup
+ (wfd_manager_iface_tbl[WFD_IFACE_ASP], method);
+ if (handler)
+ handler(parameters, invocation);
+ __WDS_LOG_FUNC_EXIT__;
+ return;
}
}
WDS_LOGD("Succeeded to load plugin");
+ if (wfd_manager_iface_init() != 0) {
+ WDS_LOGE("Failed to initialize iface");
+ wfd_manager_deinit(g_manager);
+ __WDS_LOG_FUNC_EXIT__;
+ return -1;
+ }
+ WDS_LOGD("Succeeded to load iface");
#if defined TIZEN_ENABLE_PRD
/**
* wfd_manager_prd_plugin initialization
wfd_prd_plugin_deinit(g_manager);
#endif /* TIZEN_ENABLE_PRD */
+ wfd_manager_iface_deinit();
wfd_plugin_deinit(g_manager);
wfd_manager_deinit(g_manager);
__WDS_LOG_FUNC_EXIT__;
--- /dev/null
+/*
+ * Network Configuration Module
+ *
+ * Copyright (c) 2017 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.
+ *
+ */
+
+/**
+ * This file implements wifi direct manager method functions.
+ *
+ * @file wifi-direct-method.c
+ * @author Jiung Yu (jiung.yu@samsung.com)
+ * @version 0.1
+ */
+
+#include <stdlib.h>
+#include <string.h>
+
+#include <wifi-direct.h>
+
+#include "wifi-direct-dbus.h"
+#include "wifi-direct-iface.h"
+#include "wifi-direct-method.h"
+#include "wifi-direct-ipc.h"
+#include "wifi-direct-error.h"
+#include "wifi-direct-log.h"
+#include "wifi-direct-manager.h"
+#include "wifi-direct-oem.h"
+#include "wifi-direct-session.h"
+#include "wifi-direct-util.h"
+#include "wifi-direct-group.h"
+#include "wifi-direct-state.h"
+#include <vconf.h>
+#include "wifi-direct-service.h"
+#include "wifi-direct-asp.h"
+
+static int macaddr_atoe(const char *p, unsigned char mac[])
+{
+ int i = 0;
+
+ for (;;) {
+ mac[i++] = (char) strtoul(p, (char **) &p, 16);
+ if (!*p++ || i == 6)
+ break;
+ }
+
+ return (i == 6);
+}
+
+static bool __is_discovery_available(wfd_manager_s *manager)
+{
+ return manager->state != WIFI_DIRECT_STATE_ACTIVATED &&
+ manager->state != WIFI_DIRECT_STATE_DISCOVERING &&
+ manager->state != WIFI_DIRECT_STATE_GROUP_OWNER;
+}
+
+void activate_handler(GVariant *parameters, void *dest)
+{
+ __WDS_LOG_FUNC_ENTER__;
+ wfd_manager_s *manager = wfd_get_manager();
+ if (!manager) {
+ WDS_LOGE("manager is not initialized");
+ __WDS_LOG_FUNC_EXIT__;
+ return;
+ }
+
+ int ret;
+
+ wfd_manager_dbus_reply_error_none((GDBusMethodInvocation *)dest);
+
+ ret = wfd_manager_activate(manager);
+ wfd_manager_dbus_emit_signal(WFD_MANAGER_MANAGE_INTERFACE,
+ "Activation",
+ g_variant_new("(i)", ret));
+ __WDS_LOG_FUNC_EXIT__;
+ return;
+}
+
+void add_client_handler(GVariant *parameters, void *dest)
+{
+ __WDS_LOG_FUNC_ENTER__;
+
+ wfd_manager_dbus_reply_error_none((GDBusMethodInvocation *)dest);
+
+ __WDS_LOG_FUNC_EXIT__;
+ return;
+}
+
+void deactivate_handler(GVariant *parameters, void *dest)
+{
+ __WDS_LOG_FUNC_ENTER__;
+ wfd_manager_s *manager = wfd_get_manager();
+ if (!manager) {
+ WDS_LOGE("manager is not initialized");
+ __WDS_LOG_FUNC_EXIT__;
+ return;
+ }
+ int ret = WIFI_DIRECT_ERROR_OPERATION_FAILED;
+
+ ret = wfd_util_check_p2p_hotspot_state();
+ if (ret > 0) {
+ ret = WIFI_DIRECT_ERROR_NOT_PERMITTED;
+ wfd_manager_dbus_return_err(ret, (GDBusMethodInvocation *)dest);
+ __WDS_LOG_FUNC_EXIT__;
+ return;
+ }
+
+ if (manager->state < WIFI_DIRECT_STATE_ACTIVATED) {
+ WDS_LOGE("Already deactivated");
+ ret = WIFI_DIRECT_ERROR_NOT_PERMITTED;
+ wfd_manager_dbus_return_err(ret, (GDBusMethodInvocation *)dest);
+ __WDS_LOG_FUNC_EXIT__;
+ return;
+ }
+
+ wfd_manager_dbus_reply_error_none((GDBusMethodInvocation *)dest);
+
+ ret = wfd_manager_deactivate(manager);
+ wfd_manager_dbus_emit_signal(WFD_MANAGER_MANAGE_INTERFACE,
+ "Deactivation",
+ g_variant_new("(i)", ret));
+
+ __WDS_LOG_FUNC_EXIT__;
+ return;
+}
+
+void start_discovery_handler(GVariant *parameters, void *dest)
+{
+ __WDS_LOG_FUNC_ENTER__;
+ wfd_manager_s *manager = wfd_get_manager();
+ if (!manager) {
+ WDS_LOGE("manager is not initialized");
+ __WDS_LOG_FUNC_EXIT__;
+ return;
+ }
+
+ 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;
+ int ret = WIFI_DIRECT_ERROR_OPERATION_FAILED;
+
+ g_variant_get(parameters, "(a{sv})", &iter);
+ if (!iter) {
+ ret = WIFI_DIRECT_ERROR_INVALID_PARAMETER;
+ wfd_manager_dbus_return_err(ret, (GDBusMethodInvocation *)dest);
+ __WDS_LOG_FUNC_EXIT__;
+ return;
+ }
+
+ 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 */
+ }
+ g_variant_iter_free(iter);
+
+ if (__is_discovery_available(manager)) {
+ WDS_LOGE("Wi-Fi Direct is not available status for scanning.");
+ ret = WIFI_DIRECT_ERROR_NOT_PERMITTED;
+ wfd_manager_dbus_return_err(ret, (GDBusMethodInvocation *)dest);
+ __WDS_LOG_FUNC_EXIT__;
+ return;
+ }
+
+ if (mode && (manager->local->dev_role == WFD_DEV_ROLE_GO)) {
+ WDS_LOGW("Wi-Fi Direct device is already visible, do not start listen");
+ wfd_manager_dbus_reply_error_none((GDBusMethodInvocation *)dest);
+ __WDS_LOG_FUNC_EXIT__;
+ return;
+ }
+
+ wfd_manager_dbus_reply_error_none((GDBusMethodInvocation *)dest);
+
+ ret = wfd_manager_start_discovery(manager, mode, timeout, type,
+ channel, frequency);
+ if (ret == WIFI_DIRECT_ERROR_NONE) {
+ if (mode == WFD_OEM_SCAN_MODE_PASSIVE) {
+ wfd_manager_dbus_emit_signal(WFD_MANAGER_MANAGE_INTERFACE,
+ "ListenStarted",
+ NULL);
+ } else {
+ wfd_manager_dbus_emit_signal(WFD_MANAGER_MANAGE_INTERFACE,
+ "DiscoveryStarted",
+ NULL);
+ }
+ }
+
+ __WDS_LOG_FUNC_EXIT__;
+ return;
+}
+
+void stop_discovery_handler(GVariant *parameters, void *dest)
+{
+ __WDS_LOG_FUNC_ENTER__;
+ wfd_manager_s *manager = wfd_get_manager();
+ if (!manager) {
+ WDS_LOGE("manager is not initialized");
+ __WDS_LOG_FUNC_EXIT__;
+ return;
+ }
+ int mode = manager->scan_mode;
+ int ret;
+
+ if (manager->state != WIFI_DIRECT_STATE_ACTIVATED &&
+ manager->state != WIFI_DIRECT_STATE_DISCOVERING) {
+ ret = WIFI_DIRECT_ERROR_NOT_PERMITTED;
+ wfd_manager_dbus_return_err(ret, (GDBusMethodInvocation *)dest);
+ __WDS_LOG_FUNC_EXIT__;
+ return;
+ }
+
+ wfd_manager_dbus_reply_error_none((GDBusMethodInvocation *)dest);
+
+ ret = wfd_manager_cancel_discovery(manager);
+ if (ret == WIFI_DIRECT_ERROR_NONE && mode == WFD_SCAN_MODE_PASSIVE)
+ wfd_manager_dbus_emit_signal(WFD_MANAGER_MANAGE_INTERFACE,
+ "DiscoveryFinished", NULL);
+
+ __WDS_LOG_FUNC_EXIT__;
+ return;
+}
+
+void get_discovered_peer_handler(GVariant *parameters, void *dest)
+{
+ __WDS_LOG_FUNC_ENTER__;
+ wfd_manager_s *manager = wfd_get_manager();
+ if (!manager) {
+ WDS_LOGE("manager is not initialized");
+ __WDS_LOG_FUNC_EXIT__;
+ return;
+ }
+ GVariant *return_parameters = NULL;
+ wfd_discovery_entry_s *peers = NULL;
+ GVariantBuilder *builder_peers = NULL;
+ int peer_cnt = 0;
+ int i = 0;
+ int ret;
+
+ builder_peers = g_variant_builder_new(G_VARIANT_TYPE("aa{sv}"));
+
+ peer_cnt = wfd_manager_get_peers(manager, &peers);
+ WDS_LOGD("Peer count [%d], Peer list [%p]", peer_cnt, peers);
+ if (peer_cnt < 0) {
+ WDS_LOGE("Failed to get scan result");
+ ret = WIFI_DIRECT_ERROR_OPERATION_FAILED;
+ wfd_manager_dbus_return_err(ret, (GDBusMethodInvocation *)dest);
+ __WDS_LOG_FUNC_EXIT__;
+ return;
+ }
+
+ if (peer_cnt > 255)
+ peer_cnt = 255;
+
+ for (i = 0; i < peer_cnt; i++) {
+ 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(peers[i].device_name));
+ g_variant_builder_add(&builder_peer, "{sv}",
+ "DeviceAddress",
+ wfd_manager_dbus_pack_ay(peers[i].mac_address, MACADDR_LEN));
+ g_variant_builder_add(&builder_peer, "{sv}",
+ "InterfaceAddress",
+ wfd_manager_dbus_pack_ay(peers[i].intf_address, MACADDR_LEN));
+ g_variant_builder_add(&builder_peer, "{sv}",
+ "Channel",
+ g_variant_new_uint16(peers[i].channel));
+
+ if (manager->is_service_discovery_supported) {
+ g_variant_builder_add(&builder_peer, "{sv}",
+ "Services",
+ g_variant_new_uint16(peers[i].services));
+ }
+ g_variant_builder_add(&builder_peer, "{sv}",
+ "IsGroupOwner",
+ g_variant_new_boolean(peers[i].is_group_owner));
+ g_variant_builder_add(&builder_peer, "{sv}",
+ "IsPersistentGO",
+ g_variant_new_boolean(peers[i].is_persistent_go));
+ g_variant_builder_add(&builder_peer, "{sv}",
+ "IsConnected",
+ g_variant_new_boolean(peers[i].is_connected));
+ g_variant_builder_add(&builder_peer, "{sv}",
+ "WpsDevicePwdID",
+ g_variant_new_uint16(peers[i].wps_device_pwd_id));
+ g_variant_builder_add(&builder_peer, "{sv}",
+ "WpsCfgMethods",
+ g_variant_new_uint16(peers[i].wps_cfg_methods));
+ g_variant_builder_add(&builder_peer, "{sv}",
+ "Category",
+ g_variant_new_uint16(peers[i].category));
+ g_variant_builder_add(&builder_peer, "{sv}",
+ "SubCategory",
+ g_variant_new_uint16(peers[i].subcategory));
+
+ if (manager->is_wifi_display_supported)
+ g_variant_builder_add(&builder_peer, "{sv}",
+ "IsWfdDevice",
+ g_variant_new_boolean(peers[i].is_wfd_device));
+
+ WDS_LOGD("%dth peer [%s]", i, peers[i].device_name);
+ g_variant_builder_add_value(builder_peers, g_variant_builder_end(&builder_peer));
+ }
+
+ ret = WIFI_DIRECT_ERROR_NONE;
+ return_parameters = g_variant_new("(iaa{sv})", ret, builder_peers);
+ g_variant_builder_unref(builder_peers);
+ wfd_manager_dbus_reply_params((GDBusMethodInvocation *)dest, return_parameters);
+
+ __WDS_LOG_FUNC_EXIT__;
+ return;
+}
+void connect_handler(GVariant *parameters, void *dest)
+{
+ __WDS_LOG_FUNC_ENTER__;
+ wfd_manager_s *manager = wfd_get_manager();
+ if (!manager) {
+ WDS_LOGE("manager is not initialized");
+ __WDS_LOG_FUNC_EXIT__;
+ return;
+ }
+ const char *peer_mac_address = NULL;
+ unsigned char mac_addr[MACADDR_LEN] = {0, };
+ int ret;
+
+ if (__is_discovery_available(manager)) {
+ ret = WIFI_DIRECT_ERROR_NOT_PERMITTED;
+ wfd_manager_dbus_return_err(ret, (GDBusMethodInvocation *)dest);
+ __WDS_LOG_FUNC_EXIT__;
+ return;
+ }
+
+ wfd_group_s *group = (wfd_group_s*) manager->group;
+ if (group && group->member_count >= manager->max_station) {
+ ret = WIFI_DIRECT_ERROR_TOO_MANY_CLIENT;
+ wfd_manager_dbus_return_err(ret, (GDBusMethodInvocation *)dest);
+ __WDS_LOG_FUNC_EXIT__;
+ return;
+ }
+
+ g_variant_get(parameters, "(&s)", &peer_mac_address);
+ if (peer_mac_address == NULL) {
+ ret = WIFI_DIRECT_ERROR_INVALID_PARAMETER;
+ wfd_manager_dbus_return_err(ret, (GDBusMethodInvocation *)dest);
+ __WDS_LOG_FUNC_EXIT__;
+ return;
+ }
+
+ wfd_manager_dbus_reply_error_none((GDBusMethodInvocation *)dest);
+
+ macaddr_atoe(peer_mac_address, mac_addr);
+ ret = wfd_manager_connect(manager, mac_addr);
+ if (ret == WIFI_DIRECT_ERROR_NONE)
+ wfd_manager_dbus_emit_signal(WFD_MANAGER_MANAGE_INTERFACE,
+ "Connection",
+ g_variant_new("(iis)", WIFI_DIRECT_ERROR_NONE,
+ WFD_EVENT_CONNECTION_IN_PROGRESS,
+ peer_mac_address));
+
+ __WDS_LOG_FUNC_EXIT__;
+ return;
+}
+
+void disconnect_handler(GVariant *parameters, void *dest)
+{
+ __WDS_LOG_FUNC_ENTER__;
+ wfd_manager_s *manager = wfd_get_manager();
+ if (!manager) {
+ WDS_LOGE("manager is not initialized");
+ __WDS_LOG_FUNC_EXIT__;
+ return;
+ }
+ const char *peer_mac_address = NULL;
+ unsigned char mac_addr[MACADDR_LEN] = {0, };
+ int ret;
+
+ if (!manager->group || manager->state < WIFI_DIRECT_STATE_CONNECTED) {
+ if (WIFI_DIRECT_STATE_DISCOVERING == manager->state) {
+ ret = wfd_oem_stop_scan(manager->oem_ops);
+ if (ret < 0) {
+ WDS_LOGE("Failed to stop scan");
+ ret = WIFI_DIRECT_ERROR_OPERATION_FAILED;
+ wfd_manager_dbus_return_err(ret, (GDBusMethodInvocation *)dest);
+ __WDS_LOG_FUNC_EXIT__;
+ return;
+ }
+ WDS_LOGI("Succeeded to stop scan");
+ if (WFD_DEV_ROLE_GO == manager->local->dev_role) {
+ wfd_state_set(manager, WIFI_DIRECT_STATE_GROUP_OWNER);
+ wfd_util_set_wifi_direct_state(WIFI_DIRECT_STATE_GROUP_OWNER);
+ } else {
+ wfd_state_set(manager, WIFI_DIRECT_STATE_ACTIVATED);
+ wfd_util_set_wifi_direct_state(WIFI_DIRECT_STATE_ACTIVATED);
+ }
+ } else {
+ ret = WIFI_DIRECT_ERROR_NOT_PERMITTED;
+ wfd_manager_dbus_return_err(ret, (GDBusMethodInvocation *)dest);
+ __WDS_LOG_FUNC_EXIT__;
+ return;
+ }
+ }
+
+ g_variant_get(parameters, "(&s)", &peer_mac_address);
+ if (peer_mac_address == NULL) {
+ ret = WIFI_DIRECT_ERROR_INVALID_PARAMETER;
+ wfd_manager_dbus_return_err(ret, (GDBusMethodInvocation *)dest);
+ return;
+ }
+
+ wfd_manager_dbus_reply_error_none((GDBusMethodInvocation *)dest);
+
+ macaddr_atoe(peer_mac_address, mac_addr);
+ ret = wfd_manager_disconnect(manager, mac_addr);
+ if (ret == WIFI_DIRECT_ERROR_NONE)
+ wfd_manager_dbus_emit_signal(WFD_MANAGER_MANAGE_INTERFACE,
+ "Disconnection",
+ g_variant_new("(iis)", WIFI_DIRECT_ERROR_NONE,
+ WFD_EVENT_DISCONNECTION_RSP,
+ peer_mac_address));
+ __WDS_LOG_FUNC_EXIT__;
+ return;
+}
+
+void cancel_connection_handler(GVariant *parameters, void *dest)
+{
+ __WDS_LOG_FUNC_ENTER__;
+ wfd_manager_s *manager = wfd_get_manager();
+ if (!manager) {
+ WDS_LOGE("manager is not initialized");
+ __WDS_LOG_FUNC_EXIT__;
+ return;
+ }
+ const char *peer_mac_address = NULL;
+ unsigned char mac_addr[MACADDR_LEN] = {0, };
+ int ret;
+
+ if (!manager->session && manager->state != WIFI_DIRECT_STATE_CONNECTING) {
+ WDS_LOGE("It's not CONNECTING state");
+ ret = WIFI_DIRECT_ERROR_NOT_PERMITTED;
+ wfd_manager_dbus_return_err(ret, (GDBusMethodInvocation *)dest);
+ __WDS_LOG_FUNC_EXIT__;
+ return;
+ }
+
+ g_variant_get(parameters, "(&s)", &peer_mac_address);
+ if (peer_mac_address == NULL) {
+ ret = WIFI_DIRECT_ERROR_INVALID_PARAMETER;
+ wfd_manager_dbus_return_err(ret, (GDBusMethodInvocation *)dest);
+ __WDS_LOG_FUNC_EXIT__;
+ return;
+ }
+
+ wfd_manager_dbus_reply_error_none((GDBusMethodInvocation *)dest);
+
+ macaddr_atoe(peer_mac_address, mac_addr);
+ ret = wfd_manager_cancel_connection(manager, mac_addr);
+ if (ret == WIFI_DIRECT_ERROR_NONE)
+ wfd_manager_dbus_emit_signal(WFD_MANAGER_MANAGE_INTERFACE,
+ "Connection",
+ g_variant_new("(iis)", WIFI_DIRECT_ERROR_CONNECTION_CANCELED,
+ WFD_EVENT_CONNECTION_RSP,
+ peer_mac_address));
+ __WDS_LOG_FUNC_EXIT__;
+ return;
+}
+
+void accept_connection_handler(GVariant *parameters, void *dest)
+{
+ __WDS_LOG_FUNC_ENTER__;
+ wfd_manager_s *manager = wfd_get_manager();
+ if (!manager) {
+ WDS_LOGE("manager is not initialized");
+ __WDS_LOG_FUNC_EXIT__;
+ return;
+ }
+ const char *peer_mac_address = NULL;
+ unsigned char mac_addr[MACADDR_LEN] = {0, };
+ int ret;
+
+ if (manager->state != WIFI_DIRECT_STATE_CONNECTING) {
+ ret = WIFI_DIRECT_ERROR_NOT_PERMITTED;
+ wfd_manager_dbus_return_err(ret, (GDBusMethodInvocation *)dest);
+ __WDS_LOG_FUNC_EXIT__;
+ return;
+ }
+
+ wfd_group_s *group = (wfd_group_s*) manager->group;
+ if (group && group->member_count >= manager->max_station) {
+ ret = WIFI_DIRECT_ERROR_NOT_PERMITTED;
+ wfd_manager_dbus_return_err(ret, (GDBusMethodInvocation *)dest);
+ __WDS_LOG_FUNC_EXIT__;
+ return;
+ }
+
+ g_variant_get(parameters, "(&s)", &peer_mac_address);
+ if (peer_mac_address == NULL) {
+ ret = WIFI_DIRECT_ERROR_INVALID_PARAMETER;
+ wfd_manager_dbus_return_err(ret, (GDBusMethodInvocation *)dest);
+ __WDS_LOG_FUNC_EXIT__;
+ return;
+ }
+
+ wfd_manager_dbus_reply_error_none((GDBusMethodInvocation *)dest);
+
+ macaddr_atoe(peer_mac_address, mac_addr);
+ ret = wfd_manager_accept_connection(manager, mac_addr);
+ if (ret == WIFI_DIRECT_ERROR_NONE) {
+ wfd_manager_dbus_emit_signal(WFD_MANAGER_MANAGE_INTERFACE,
+ "Connection",
+ g_variant_new("(iis)", WIFI_DIRECT_ERROR_NONE,
+ WFD_EVENT_CONNECTION_IN_PROGRESS,
+ peer_mac_address));
+ } else {
+ wfd_manager_dbus_emit_signal(WFD_MANAGER_MANAGE_INTERFACE,
+ "Connection",
+ g_variant_new("(iis)", WIFI_DIRECT_ERROR_OPERATION_FAILED,
+ WFD_EVENT_CONNECTION_RSP,
+ peer_mac_address));
+ }
+
+ __WDS_LOG_FUNC_EXIT__;
+ return;
+}
+
+void reject_connection_handler(GVariant *parameters, void *dest)
+{
+ __WDS_LOG_FUNC_ENTER__;
+ wfd_manager_s *manager = wfd_get_manager();
+ if (!manager) {
+ WDS_LOGE("manager is not initialized");
+ __WDS_LOG_FUNC_EXIT__;
+ return;
+ }
+
+ wfd_session_s *session = manager->session;
+ const char *peer_mac_address = NULL;
+ unsigned char mac_addr[MACADDR_LEN] = {0, };
+ int ret;
+
+ if (!session || manager->state != WIFI_DIRECT_STATE_CONNECTING) {
+ WDS_LOGE("It's not permitted with this state [%d]", manager->state);
+ ret = WIFI_DIRECT_ERROR_NOT_PERMITTED;
+ wfd_manager_dbus_return_err(ret, (GDBusMethodInvocation *)dest);
+ __WDS_LOG_FUNC_EXIT__;
+ return;
+ }
+
+ if (session->direction != SESSION_DIRECTION_INCOMING) {
+ WDS_LOGE("Only incomming session can be rejected");
+ ret = WIFI_DIRECT_ERROR_NOT_PERMITTED;
+ wfd_manager_dbus_return_err(ret, (GDBusMethodInvocation *)dest);
+ __WDS_LOG_FUNC_EXIT__;
+ return;
+ }
+
+ g_variant_get(parameters, "(&s)", &peer_mac_address);
+ if (peer_mac_address == NULL) {
+ ret = WIFI_DIRECT_ERROR_INVALID_PARAMETER;
+ wfd_manager_dbus_return_err(ret, (GDBusMethodInvocation *)dest);
+ __WDS_LOG_FUNC_EXIT__;
+ return;
+ }
+
+ wfd_manager_dbus_reply_error_none((GDBusMethodInvocation *)dest);
+
+ macaddr_atoe(peer_mac_address, mac_addr);
+ ret = wfd_manager_reject_connection(manager, mac_addr);
+ if (ret == WIFI_DIRECT_ERROR_NONE)
+ wfd_manager_dbus_emit_signal(WFD_MANAGER_MANAGE_INTERFACE,
+ "Connection",
+ g_variant_new("(iis)", WIFI_DIRECT_ERROR_CONNECTION_CANCELED,
+ WFD_EVENT_CONNECTION_RSP,
+ peer_mac_address));
+
+ __WDS_LOG_FUNC_EXIT__;
+ return;
+}
+
+void disconnect_all_handler(GVariant *parameters, void *dest)
+{
+ __WDS_LOG_FUNC_ENTER__;
+ wfd_manager_s *manager = wfd_get_manager();
+ if (!manager) {
+ WDS_LOGE("manager is not initialized");
+ __WDS_LOG_FUNC_EXIT__;
+ return;
+ }
+ int ret;
+
+ if (!manager->group || manager->state < WIFI_DIRECT_STATE_CONNECTED) {
+ if (WIFI_DIRECT_STATE_DISCOVERING == manager->state) {
+ ret = wfd_oem_stop_scan(manager->oem_ops);
+ if (ret < 0) {
+ WDS_LOGE("Failed to stop scan");
+ ret = WIFI_DIRECT_ERROR_OPERATION_FAILED;
+ wfd_manager_dbus_return_err(ret, (GDBusMethodInvocation *)dest);
+ __WDS_LOG_FUNC_EXIT__;
+ return;
+ }
+ WDS_LOGI("Succeeded to stop scan");
+ if (WFD_DEV_ROLE_GO == manager->local->dev_role) {
+ wfd_state_set(manager, WIFI_DIRECT_STATE_GROUP_OWNER);
+ wfd_util_set_wifi_direct_state(WIFI_DIRECT_STATE_GROUP_OWNER);
+ } else {
+ wfd_state_set(manager, WIFI_DIRECT_STATE_ACTIVATED);
+ wfd_util_set_wifi_direct_state(WIFI_DIRECT_STATE_ACTIVATED);
+ }
+ } else {
+ ret = WIFI_DIRECT_ERROR_NOT_PERMITTED;
+ wfd_manager_dbus_return_err(ret, (GDBusMethodInvocation *)dest);
+ __WDS_LOG_FUNC_EXIT__;
+ return;
+ }
+ }
+
+ wfd_manager_dbus_reply_error_none((GDBusMethodInvocation *)dest);
+
+ ret = wfd_manager_disconnect_all(manager);
+ if (ret == WIFI_DIRECT_ERROR_NONE)
+ wfd_manager_dbus_emit_signal(WFD_MANAGER_MANAGE_INTERFACE,
+ "Disconnection",
+ g_variant_new("(iis)", ret,
+ WFD_EVENT_DISCONNECTION_RSP,
+ ""));
+
+ __WDS_LOG_FUNC_EXIT__;
+ return;
+}
+
+void get_connected_peers_handler(GVariant *parameters, void *dest)
+{
+ __WDS_LOG_FUNC_ENTER__;
+ wfd_manager_s *manager = wfd_get_manager();
+ if (!manager) {
+ WDS_LOGE("manager is not initialized");
+ __WDS_LOG_FUNC_EXIT__;
+ return;
+ }
+ GVariant *return_parameters = NULL;
+ wfd_connected_peer_info_s *peers = NULL;
+ GVariantBuilder *builder_peers = NULL;
+ int peer_cnt = 0;
+ int i = 0;
+ int ret;
+
+ /* even though status is not CONNECTED,
+ * this command can be excuted only when group exist */
+ if (!manager->group && manager->state < WIFI_DIRECT_STATE_CONNECTED) {
+ WDS_LOGD("It's not connected state [%d]", manager->state);
+ ret = WIFI_DIRECT_ERROR_NOT_PERMITTED;
+ wfd_manager_dbus_return_err(ret, (GDBusMethodInvocation *)dest);
+ __WDS_LOG_FUNC_EXIT__;
+ return;
+ }
+
+ peer_cnt = wfd_manager_get_connected_peers(manager, &peers);
+ WDS_LOGD("Peer count [%d], Peer list [%x]", peer_cnt, peers);
+ if (peer_cnt < 0) {
+ WDS_LOGE("Failed to get scan result");
+ ret = WIFI_DIRECT_ERROR_NOT_PERMITTED;
+ wfd_manager_dbus_return_err(ret, (GDBusMethodInvocation *)dest);
+ __WDS_LOG_FUNC_EXIT__;
+ return;
+ }
+
+ builder_peers = g_variant_builder_new(G_VARIANT_TYPE("aa{sv}"));
+ for (i = 0; i < peer_cnt; i++) {
+ 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(peers[i].device_name));
+ g_variant_builder_add(&builder_peer, "{sv}",
+ "DeviceAddress",
+ wfd_manager_dbus_pack_ay(peers[i].mac_address, MACADDR_LEN));
+ g_variant_builder_add(&builder_peer, "{sv}",
+ "InterfaceAddress",
+ wfd_manager_dbus_pack_ay(peers[i].intf_address, MACADDR_LEN));
+ g_variant_builder_add(&builder_peer, "{sv}",
+ "IPAddress",
+ wfd_manager_dbus_pack_ay(peers[i].ip_address, IPADDR_LEN));
+ g_variant_builder_add(&builder_peer, "{sv}",
+ "Channel",
+ g_variant_new_uint16(peers[i].channel));
+ if (manager->is_service_discovery_supported) {
+ g_variant_builder_add(&builder_peer, "{sv}",
+ "Services",
+ g_variant_new_uint16(peers[i].services));
+ }
+ g_variant_builder_add(&builder_peer, "{sv}",
+ "Category",
+ g_variant_new_uint16(peers[i].category));
+ g_variant_builder_add(&builder_peer, "{sv}",
+ "SubCategory",
+ g_variant_new_uint16(peers[i].subcategory));
+ g_variant_builder_add(&builder_peer, "{sv}",
+ "IsP2P",
+ g_variant_new_boolean(peers[i].is_p2p));
+
+ if (manager->is_wifi_display_supported)
+ g_variant_builder_add(&builder_peer, "{sv}",
+ "IsWfdDevice",
+ g_variant_new_boolean(peers[i].is_wfd_device));
+
+ WDS_LOGD("%dth peer [%s]", i, peers[i].device_name);
+ g_variant_builder_add_value(builder_peers, g_variant_builder_end(&builder_peer));
+ }
+
+ ret = WIFI_DIRECT_ERROR_NONE;
+ return_parameters = g_variant_new("(iaa{sv})", ret, builder_peers);
+ g_variant_builder_unref(builder_peers);
+ g_free(peers);
+ wfd_manager_dbus_reply_params((GDBusMethodInvocation *)dest, return_parameters);
+
+ __WDS_LOG_FUNC_EXIT__;
+ return;
+}
+
+void get_connecting_peer_handler(GVariant *parameters, void *dest)
+{
+ __WDS_LOG_FUNC_ENTER__;
+ wfd_manager_s *manager = wfd_get_manager();
+ if (!manager) {
+ WDS_LOGE("manager is not initialized");
+ __WDS_LOG_FUNC_EXIT__;
+ return;
+ }
+ wfd_session_s *session;
+ wfd_device_s *peer = NULL;
+ wfd_discovery_entry_s *connecting_peer = NULL;
+ GVariantBuilder *builder_peer = NULL;
+ GVariant *return_parameters = NULL;
+ int ret;
+
+ if (!manager->session ||
+ manager->state != WIFI_DIRECT_STATE_CONNECTING) {
+ ret = WIFI_DIRECT_ERROR_NOT_PERMITTED;
+ wfd_manager_dbus_return_err(ret, (GDBusMethodInvocation *)dest);
+ __WDS_LOG_FUNC_EXIT__;
+ return;
+ }
+
+ session = manager->session;
+ if (!session->peer) {
+ ret = WIFI_DIRECT_ERROR_OPERATION_FAILED;
+ wfd_manager_dbus_return_err(ret, (GDBusMethodInvocation *)dest);
+ __WDS_LOG_FUNC_EXIT__;
+ return;
+ }
+ peer = session->peer;
+
+ connecting_peer = (wfd_discovery_entry_s *)
+ g_try_malloc0(sizeof(wfd_discovery_entry_s));
+ if (!connecting_peer) {
+ WDS_LOGF("Failed to allocate memory for peer data.");
+ ret = WIFI_DIRECT_ERROR_OUT_OF_MEMORY;
+ wfd_manager_dbus_return_err(ret, (GDBusMethodInvocation *)dest);
+ __WDS_LOG_FUNC_EXIT__;
+ return;
+ }
+
+ builder_peer = g_variant_builder_new(G_VARIANT_TYPE("a{sv}"));
+
+ g_variant_builder_add(builder_peer, "{sv}",
+ "DeviceName",
+ g_variant_new_string(peer->dev_name));
+ g_variant_builder_add(builder_peer, "{sv}",
+ "DeviceAddress",
+ wfd_manager_dbus_pack_ay(peer->dev_addr,
+ MACADDR_LEN));
+ g_variant_builder_add(builder_peer, "{sv}",
+ "InterfaceAddress",
+ wfd_manager_dbus_pack_ay(peer->intf_addr,
+ MACADDR_LEN));
+ g_variant_builder_add(builder_peer, "{sv}",
+ "Channel",
+ g_variant_new_uint16(peer->channel));
+ g_variant_builder_add(builder_peer, "{sv}",
+ "IsConnected",
+ g_variant_new_boolean(peer->dev_role == WFD_DEV_ROLE_GC));
+ g_variant_builder_add(builder_peer, "{sv}",
+ "IsGroupOwner",
+ g_variant_new_boolean(peer->dev_role == WFD_OEM_DEV_ROLE_GO));
+ g_variant_builder_add(builder_peer, "{sv}",
+ "IsPersistentGO",
+ g_variant_new_boolean(peer->group_flags & WFD_OEM_GROUP_FLAG_PERSISTENT_GROUP));
+ g_variant_builder_add(builder_peer, "{sv}",
+ "Category",
+ g_variant_new_uint16(peer->pri_dev_type));
+ g_variant_builder_add(builder_peer, "{sv}",
+ "SubCategory",
+ g_variant_new_uint16(peer->sec_dev_type));
+ g_variant_builder_add(builder_peer, "{sv}",
+ "WpsCfgMethods",
+ g_variant_new_uint16(peer->config_methods));
+
+ if (manager->is_wifi_display_supported)
+ g_variant_builder_add(builder_peer, "{sv}",
+ "IsWfdDevice",
+ g_variant_new_boolean(false));
+
+ ret = WIFI_DIRECT_ERROR_NONE;
+ return_parameters = g_variant_new("(ia{sv})", ret,
+ builder_peer);
+ g_variant_builder_unref(builder_peer);
+ g_free(connecting_peer);
+ wfd_manager_dbus_reply_params((GDBusMethodInvocation *)dest, return_parameters);
+
+ __WDS_LOG_FUNC_EXIT__;
+ return;
+}
+
+void is_discoverable_handler(GVariant *parameters, void *dest)
+{
+ __WDS_LOG_FUNC_ENTER__;
+ wfd_manager_s *manager = wfd_get_manager();
+ if (!manager) {
+ WDS_LOGE("manager is not initialized");
+ __WDS_LOG_FUNC_EXIT__;
+ return;
+ }
+ GVariant *return_parameters = NULL;
+
+ return_parameters = g_variant_new("(b)",
+ (manager->state == WIFI_DIRECT_STATE_DISCOVERING ||
+ wfd_group_is_autonomous(manager->group) == TRUE));
+ wfd_manager_dbus_reply_params((GDBusMethodInvocation *)dest, return_parameters);
+
+ __WDS_LOG_FUNC_EXIT__;
+ return;
+}
+
+void is_listening_only_handler(GVariant *parameters, void *dest)
+{
+ __WDS_LOG_FUNC_ENTER__;
+ wfd_manager_s *manager = wfd_get_manager();
+ if (!manager) {
+ WDS_LOGE("manager is not initialized");
+ __WDS_LOG_FUNC_EXIT__;
+ return;
+ }
+ GVariant *return_parameters = NULL;
+
+ return_parameters = g_variant_new("(b)", (manager->scan_mode == WFD_SCAN_MODE_PASSIVE));
+ wfd_manager_dbus_reply_params((GDBusMethodInvocation *)dest, return_parameters);
+
+ __WDS_LOG_FUNC_EXIT__;
+ return;
+}
+
+void get_peer_info_handler(GVariant *parameters, void *dest)
+{
+ __WDS_LOG_FUNC_ENTER__;
+ wfd_manager_s *manager = wfd_get_manager();
+ if (!manager) {
+ WDS_LOGE("manager is not initialized");
+ __WDS_LOG_FUNC_EXIT__;
+ return;
+ }
+ wfd_discovery_entry_s *peer = NULL;
+ GVariantBuilder *builder_peer = NULL;
+ const char *peer_mac_address = NULL;
+ unsigned char mac_addr[MACADDR_LEN] = {0, };
+ GVariant *return_parameters = NULL;
+ int ret;
+
+ g_variant_get(parameters, "(&s)", &peer_mac_address);
+ if (peer_mac_address == NULL) {
+ ret = WIFI_DIRECT_ERROR_INVALID_PARAMETER;
+ wfd_manager_dbus_return_err(ret, (GDBusMethodInvocation *)dest);
+ __WDS_LOG_FUNC_EXIT__;
+ return;
+ }
+
+ macaddr_atoe(peer_mac_address, mac_addr);
+ ret = wfd_manager_get_peer_info(manager, mac_addr, &peer);
+ if (ret < 0 || !peer) {
+ WDS_LOGE("Failed to get peer info");
+ g_free(peer);
+ ret = WIFI_DIRECT_ERROR_OPERATION_FAILED;
+ wfd_manager_dbus_return_err(ret, (GDBusMethodInvocation *)dest);
+ __WDS_LOG_FUNC_EXIT__;
+ return;
+ }
+
+ builder_peer = g_variant_builder_new(G_VARIANT_TYPE("a{sv}"));
+ g_variant_builder_add(builder_peer, "{sv}",
+ "DeviceName",
+ g_variant_new_string(peer->device_name));
+ g_variant_builder_add(builder_peer, "{sv}",
+ "DeviceAddress",
+ wfd_manager_dbus_pack_ay(peer->mac_address, MACADDR_LEN));
+ g_variant_builder_add(builder_peer, "{sv}",
+ "InterfaceAddress",
+ wfd_manager_dbus_pack_ay(peer->intf_address, MACADDR_LEN));
+ g_variant_builder_add(builder_peer, "{sv}",
+ "Channel",
+ g_variant_new_uint16(peer->channel));
+ if (manager->is_service_discovery_supported) {
+ g_variant_builder_add(builder_peer, "{sv}",
+ "Services",
+ g_variant_new_uint16(peer->services));
+ }
+ g_variant_builder_add(builder_peer, "{sv}",
+ "IsGroupOwner",
+ g_variant_new_boolean(peer->is_group_owner));
+ g_variant_builder_add(builder_peer, "{sv}",
+ "IsPersistentGO",
+ g_variant_new_boolean(peer->is_persistent_go));
+ g_variant_builder_add(builder_peer, "{sv}",
+ "IsConnected",
+ g_variant_new_boolean(peer->is_connected));
+ g_variant_builder_add(builder_peer, "{sv}",
+ "WpsDevicePwdID",
+ g_variant_new_uint16(peer->wps_device_pwd_id));
+ g_variant_builder_add(builder_peer, "{sv}",
+ "WpsCfgMethods",
+ g_variant_new_uint16(peer->wps_cfg_methods));
+ g_variant_builder_add(builder_peer, "{sv}",
+ "Category",
+ g_variant_new_uint16(peer->category));
+ g_variant_builder_add(builder_peer, "{sv}",
+ "SubCategory",
+ g_variant_new_uint16(peer->subcategory));
+
+ if (manager->is_wifi_display_supported)
+ g_variant_builder_add(builder_peer, "{sv}",
+ "IsWfdDevice",
+ g_variant_new_boolean(peer->is_wfd_device));
+
+ wfd_device_s *connected_peer = NULL;
+ connected_peer = wfd_group_find_member_by_addr(manager->group, mac_addr);
+ if (connected_peer) {
+ g_variant_builder_add(builder_peer, "{sv}",
+ "IsInGroup",
+ g_variant_new_boolean(true));
+ g_variant_builder_add(builder_peer, "{sv}",
+ "IPAddress",
+ wfd_manager_dbus_pack_ay(connected_peer->ip_addr, IPADDR_LEN));
+ }
+
+ ret = WIFI_DIRECT_ERROR_NONE;
+ return_parameters = g_variant_new("(ia{sv})", ret, builder_peer);
+ g_variant_builder_unref(builder_peer);
+ g_free(peer);
+ wfd_manager_dbus_reply_params((GDBusMethodInvocation *)dest, return_parameters);
+
+ __WDS_LOG_FUNC_EXIT__;
+ return;
+}
+
+void get_state_handler(GVariant *parameters, void *dest)
+{
+ __WDS_LOG_FUNC_ENTER__;
+ wfd_manager_s *manager = wfd_get_manager();
+ if (!manager) {
+ WDS_LOGE("manager is not initialized");
+ __WDS_LOG_FUNC_EXIT__;
+ return;
+ }
+ GVariant *return_parameters = NULL;
+ int ret;
+
+ ret = WIFI_DIRECT_ERROR_NONE;
+ return_parameters = g_variant_new("(ii)", ret, manager->state);
+ wfd_manager_dbus_reply_params((GDBusMethodInvocation *)dest, return_parameters);
+
+ __WDS_LOG_FUNC_EXIT__;
+ return;
+}
+
+void create_group_handler(GVariant *parameters, void *dest)
+{
+ __WDS_LOG_FUNC_ENTER__;
+ wfd_manager_s *manager = wfd_get_manager();
+ if (!manager) {
+ WDS_LOGE("manager is not initialized");
+ __WDS_LOG_FUNC_EXIT__;
+ return;
+ }
+ wfd_group_s *group = manager->group;
+ wfd_oem_group_param_s param;
+ wfd_oem_config_s *oem_conf = (wfd_oem_config_s *) manager->wfd_oem_conf;
+ GVariantIter *iter = NULL;
+ gchar *key = NULL;
+ GVariant *var = NULL;
+ const char *ssid = NULL;
+ GVariant *return_parameters = NULL;
+ int ret;
+
+ g_variant_get(parameters, "(a{sv})", &iter);
+ if (!iter) {
+ ret = WIFI_DIRECT_ERROR_INVALID_PARAMETER;
+ wfd_manager_dbus_return_err(ret, (GDBusMethodInvocation *)dest);
+ __WDS_LOG_FUNC_EXIT__;
+ return;
+ }
+
+ while (g_variant_iter_loop(iter, "{sv}", &key, &var)) {
+ if (!g_strcmp0(key, "ssid")) {
+ g_variant_get(var, "&s", &ssid);
+ if (ssid == NULL) {
+ ret = WIFI_DIRECT_ERROR_INVALID_PARAMETER;
+ g_variant_iter_free(iter);
+ wfd_manager_dbus_return_err(ret, (GDBusMethodInvocation *)dest);
+ __WDS_LOG_FUNC_EXIT__;
+ return;
+ }
+ WDS_LOGD("SSID received [%s]", ssid);
+ }
+ }
+
+ if (group || manager->state < WIFI_DIRECT_STATE_ACTIVATED) {
+ WDS_LOGE("Group already exist or not a proper state");
+ ret = WIFI_DIRECT_ERROR_NOT_PERMITTED;
+ g_variant_iter_free(iter);
+ wfd_manager_dbus_return_err(ret, (GDBusMethodInvocation *)dest);
+ __WDS_LOG_FUNC_EXIT__;
+ return;
+ }
+
+ group = wfd_create_pending_group(manager, manager->local->intf_addr);
+ if (!group) {
+ WDS_LOGE("Failed to create pending group");
+ ret = WIFI_DIRECT_ERROR_OPERATION_FAILED;
+ g_variant_iter_free(iter);
+ wfd_manager_dbus_return_err(ret, (GDBusMethodInvocation *)dest);
+ return;
+ }
+ group->flags |= WFD_GROUP_FLAG_AUTONOMOUS;
+ manager->group = group;
+
+ memset(¶m, 0x0, sizeof(param));
+
+ param.persistent = (manager->local->group_flags &
+ WFD_GROUP_FLAG_PERSISTENT);
+ memcpy(&(param.passphrase), manager->local->passphrase,
+ sizeof(param.passphrase));
+
+ if (oem_conf && oem_conf->group_operating_freq != 0)
+ param.freq = oem_conf->group_operating_freq;
+
+ if (ssid != NULL)
+ g_strlcpy(param.ssid, ssid, WIFI_DIRECT_MAX_DEVICE_NAME_LEN+1);
+
+ g_variant_iter_free(iter);
+
+ ret = wfd_oem_create_group(manager->oem_ops, ¶m);
+ if (ret < 0) {
+ WDS_LOGE("Failed to create group");
+ wfd_destroy_group(manager);
+ ret = WIFI_DIRECT_ERROR_NOT_PERMITTED;
+ wfd_manager_dbus_return_err(ret, (GDBusMethodInvocation *)dest);
+ __WDS_LOG_FUNC_EXIT__;
+ return;
+ }
+
+ WDS_LOGD("Succeeded to create pending group");
+ memset(manager->local->passphrase, 0x0, PASSPHRASE_LEN_MAX + 1);
+ ret = WIFI_DIRECT_ERROR_NONE;
+ return_parameters = g_variant_new("(i)", ret);
+ wfd_manager_dbus_reply_params((GDBusMethodInvocation *)dest, return_parameters);
+
+ __WDS_LOG_FUNC_EXIT__;
+ return;
+}
+
+void destroy_group_handler(GVariant *parameters, void *dest)
+{
+ __WDS_LOG_FUNC_ENTER__;
+ wfd_manager_s *manager = wfd_get_manager();
+ if (!manager) {
+ WDS_LOGE("manager is not initialized");
+ __WDS_LOG_FUNC_EXIT__;
+ return;
+ }
+ wfd_group_s *group = manager->group;
+ int ret;
+
+ if (!group) {
+ WDS_LOGE("Group not exist");
+ ret = WIFI_DIRECT_ERROR_NOT_PERMITTED;
+ wfd_manager_dbus_return_err(ret, (GDBusMethodInvocation *)dest);
+ __WDS_LOG_FUNC_EXIT__;
+ return;
+ }
+
+ ret = wfd_util_check_p2p_hotspot_state();
+ if (ret > 0) {
+ ret = WIFI_DIRECT_ERROR_NOT_PERMITTED;
+ wfd_manager_dbus_return_err(ret, (GDBusMethodInvocation *)dest);
+ __WDS_LOG_FUNC_EXIT__;
+ return;
+ }
+
+ if (group->pending == FALSE) {
+ ret = wfd_oem_destroy_group(manager->oem_ops, group->ifname);
+ if (ret < 0) {
+ WDS_LOGE("Failed to destroy group");
+ ret = WIFI_DIRECT_ERROR_OPERATION_FAILED;
+ wfd_manager_dbus_return_err(ret, (GDBusMethodInvocation *)dest);
+ __WDS_LOG_FUNC_EXIT__;
+ return;
+ }
+ }
+
+ ret = wfd_destroy_group(manager);
+ if (ret < 0)
+ WDS_LOGE("Failed to destroy group");
+
+ wfd_state_set(manager, WIFI_DIRECT_STATE_ACTIVATED);
+ wfd_util_set_wifi_direct_state(WIFI_DIRECT_STATE_ACTIVATED);
+
+ wfd_manager_dbus_reply_error_none((GDBusMethodInvocation *)dest);
+
+ wfd_manager_dbus_emit_signal(WFD_MANAGER_GROUP_INTERFACE,
+ "Destroyed", NULL);
+
+ __WDS_LOG_FUNC_EXIT__;
+ return;
+}
+
+void is_group_owner_handler(GVariant *parameters, void *dest)
+{
+ __WDS_LOG_FUNC_ENTER__;
+ wfd_manager_s *manager = wfd_get_manager();
+ if (!manager) {
+ WDS_LOGE("manager is not initialized");
+ __WDS_LOG_FUNC_EXIT__;
+ return;
+ }
+ GVariant *return_parameters = NULL;
+ gboolean result;
+ wfd_device_s *local = manager->local;
+
+ result = local->dev_role == WFD_DEV_ROLE_GO;
+ WDS_LOGI("Is group owner : [%s]", result ? "Yes" : "No");
+ return_parameters = g_variant_new("(b)", result);
+ wfd_manager_dbus_reply_params((GDBusMethodInvocation *)dest, return_parameters);
+
+ __WDS_LOG_FUNC_EXIT__;
+ return;
+}
+
+void is_auto_group_handler(GVariant *parameters, void *dest)
+{
+ __WDS_LOG_FUNC_ENTER__;
+ wfd_manager_s *manager = wfd_get_manager();
+ if (!manager) {
+ WDS_LOGE("manager is not initialized");
+ __WDS_LOG_FUNC_EXIT__;
+ return;
+ }
+ GVariant *return_parameters = NULL;
+ int result;
+ if ((result = wfd_group_is_autonomous(manager->group)) < 0)
+ result = 0;
+
+ WDS_LOGI("Is autonomous group : [%s]", result ? "Yes" : "No");
+ return_parameters = g_variant_new("(b)", result);
+ wfd_manager_dbus_reply_params((GDBusMethodInvocation *)dest, return_parameters);
+
+ __WDS_LOG_FUNC_EXIT__;
+ return;
+}
+
+void activate_pushbutton_handler(GVariant *parameters, void *dest)
+{
+ __WDS_LOG_FUNC_ENTER__;
+ wfd_manager_s *manager = wfd_get_manager();
+ if (!manager) {
+ WDS_LOGE("manager is not initialized");
+ __WDS_LOG_FUNC_EXIT__;
+ return;
+ }
+ GVariant *return_parameters = NULL;
+ int ret;
+
+ if (manager->local->dev_role != WFD_DEV_ROLE_GO) {
+ WDS_LOGE("Wi-Fi Direct is not Group Owner.");
+ ret = WIFI_DIRECT_ERROR_NOT_PERMITTED;
+ wfd_manager_dbus_return_err(ret, (GDBusMethodInvocation *)dest);
+ __WDS_LOG_FUNC_EXIT__;
+ return;
+ }
+
+ ret = wfd_oem_wps_start(manager->oem_ops, NULL,
+ WFD_WPS_MODE_PBC, NULL);
+ if (ret < 0) {
+ WDS_LOGE("Failed to start wps");
+ ret = WIFI_DIRECT_ERROR_OPERATION_FAILED;
+ wfd_manager_dbus_return_err(ret, (GDBusMethodInvocation *)dest);
+ __WDS_LOG_FUNC_EXIT__;
+ return;
+ }
+ return_parameters = g_variant_new("(i)", ret);
+ wfd_manager_dbus_reply_params((GDBusMethodInvocation *)dest, return_parameters);
+
+ __WDS_LOG_FUNC_EXIT__;
+ return;
+}
+
+void get_persistent_group_handler(GVariant *parameters, void *dest)
+{
+ __WDS_LOG_FUNC_ENTER__;
+ wfd_manager_s *manager = wfd_get_manager();
+ if (!manager) {
+ WDS_LOGE("manager is not initialized");
+ __WDS_LOG_FUNC_EXIT__;
+ return;
+ }
+ GVariant *return_parameters = NULL;
+ int persistent_group_count = 0;
+ wfd_persistent_group_info_s *plist;
+ GVariantBuilder *builder_groups = NULL;
+ int ret;
+ int i = 0;
+
+ if (manager->state < WIFI_DIRECT_STATE_ACTIVATED) {
+ WDS_LOGE("Wi-Fi Direct is not activated.");
+ ret = WIFI_DIRECT_ERROR_NOT_PERMITTED;
+ wfd_manager_dbus_return_err(ret, (GDBusMethodInvocation *)dest);
+ __WDS_LOG_FUNC_EXIT__;
+ return;
+ }
+
+
+ ret = wfd_oem_get_persistent_groups(manager->oem_ops,
+ (wfd_oem_persistent_group_s**) &plist, &persistent_group_count);
+ if (ret < 0) {
+ WDS_LOGE("Error!! wfd_oem_get_persistent_group_info() failed..");
+ ret = WIFI_DIRECT_ERROR_OPERATION_FAILED;
+ wfd_manager_dbus_return_err(ret, (GDBusMethodInvocation *)dest);
+ __WDS_LOG_FUNC_EXIT__;
+ return;
+ }
+
+ builder_groups = g_variant_builder_new(G_VARIANT_TYPE("aa{sv}"));
+
+ for (i = 0; i < persistent_group_count; i++) {
+ 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(plist[i].network_id));
+ g_variant_builder_add(&builder_group, "{sv}",
+ "SSID",
+ g_variant_new_string(plist[i].ssid));
+ g_variant_builder_add(&builder_group, "{sv}",
+ "GOMacAddress",
+ wfd_manager_dbus_pack_ay(plist[i].go_mac_address, MACADDR_LEN));
+
+ WDS_LOGD("%dth peer [%s]", i, plist[i].ssid);
+ g_variant_builder_add_value(builder_groups, g_variant_builder_end(&builder_group));
+ }
+
+ ret = WIFI_DIRECT_ERROR_NONE;
+ return_parameters = g_variant_new("(iaa{sv})", ret, builder_groups);
+ wfd_manager_dbus_reply_params((GDBusMethodInvocation *)dest, return_parameters);
+
+ __WDS_LOG_FUNC_EXIT__;
+ return;
+}
+
+void remove_persistent_group_handler(GVariant *parameters, void *dest)
+{
+ __WDS_LOG_FUNC_ENTER__;
+ wfd_manager_s *manager = wfd_get_manager();
+ if (!manager) {
+ WDS_LOGE("manager is not initialized");
+ __WDS_LOG_FUNC_EXIT__;
+ return;
+ }
+ GVariant *return_parameters = NULL;
+ gchar *ssid;
+ gchar *mac_address;
+ unsigned char go_mac_address[6];
+ int ret;
+
+ if (manager->state < WIFI_DIRECT_STATE_ACTIVATED) {
+ WDS_LOGE("Wi-Fi Direct is not activated.");
+ ret = WIFI_DIRECT_ERROR_NOT_PERMITTED;
+ wfd_manager_dbus_return_err(ret, (GDBusMethodInvocation *)dest);
+ __WDS_LOG_FUNC_EXIT__;
+ return;
+ }
+
+ g_variant_get(parameters, "(&s&s)", &mac_address, &ssid);
+ if (mac_address == NULL || ssid == NULL) {
+ ret = WIFI_DIRECT_ERROR_INVALID_PARAMETER;
+ wfd_manager_dbus_return_err(ret, (GDBusMethodInvocation *)dest);
+ __WDS_LOG_FUNC_EXIT__;
+ return;
+ }
+
+ macaddr_atoe(mac_address, go_mac_address);
+ WDS_LOGD("Remove persistent group [%s][" MACSTR "]", ssid, MAC2STR(go_mac_address));
+
+ ret = wfd_oem_remove_persistent_group(manager->oem_ops, ssid,
+ go_mac_address);
+ if (ret < 0) {
+ WDS_LOGE("Failed to remove persistent group");
+ ret = WIFI_DIRECT_ERROR_OPERATION_FAILED;
+ wfd_manager_dbus_return_err(ret, (GDBusMethodInvocation *)dest);
+ __WDS_LOG_FUNC_EXIT__;
+ return;
+ }
+ return_parameters = g_variant_new("(i)", ret);
+ wfd_manager_dbus_reply_params((GDBusMethodInvocation *)dest, return_parameters);
+
+ __WDS_LOG_FUNC_EXIT__;
+ return;
+}
+
+void set_passphrase_handler(GVariant *parameters, void *dest)
+{
+ __WDS_LOG_FUNC_ENTER__;
+ wfd_manager_s *manager = wfd_get_manager();
+ if (!manager) {
+ WDS_LOGE("manager is not initialized");
+ __WDS_LOG_FUNC_EXIT__;
+ return;
+ }
+ GVariant *return_parameters = NULL;
+ gchar *passphrase;
+ int passphrase_len = 0;
+ int ret;
+ wfd_group_s *group = manager->group;
+
+ if (group) {
+ WDS_LOGE("Group already exists");
+ ret = WIFI_DIRECT_ERROR_NOT_PERMITTED;
+ wfd_manager_dbus_return_err(ret, (GDBusMethodInvocation *)dest);
+ __WDS_LOG_FUNC_EXIT__;
+ return;
+ }
+
+ g_variant_get(parameters, "(&s)", &passphrase);
+ if (passphrase == NULL) {
+ ret = WIFI_DIRECT_ERROR_INVALID_PARAMETER;
+ wfd_manager_dbus_return_err(ret, (GDBusMethodInvocation *)dest);
+ __WDS_LOG_FUNC_EXIT__;
+ return;
+ }
+
+ passphrase_len = strlen(passphrase);
+
+ if (passphrase_len < PASSPHRASE_LEN_MIN ||
+ passphrase_len > PASSPHRASE_LEN_MAX) {
+ WDS_LOGE("Passphrase length incorrect [%s]:[%d]",
+ passphrase, passphrase_len);
+ ret = WIFI_DIRECT_ERROR_NOT_PERMITTED;
+ wfd_manager_dbus_return_err(ret, (GDBusMethodInvocation *)dest);
+ __WDS_LOG_FUNC_EXIT__;
+ return;
+ }
+
+ g_strlcpy(manager->local->passphrase, passphrase, PASSPHRASE_LEN_MAX + 1);
+ WDS_LOGI("Passphrase string [%s]", manager->local->passphrase);
+
+ ret = WIFI_DIRECT_ERROR_NONE;
+ return_parameters = g_variant_new("(i)", ret);
+ wfd_manager_dbus_reply_params((GDBusMethodInvocation *)dest, return_parameters);
+
+ __WDS_LOG_FUNC_EXIT__;
+ return;
+}
+
+void get_passphrase_handler(GVariant *parameters, void *dest)
+{
+ __WDS_LOG_FUNC_ENTER__;
+ wfd_manager_s *manager = wfd_get_manager();
+ if (!manager) {
+ WDS_LOGE("manager is not initialized");
+ __WDS_LOG_FUNC_EXIT__;
+ return;
+ }
+ GVariant *return_parameters = NULL;
+ wfd_group_s *group = manager->group;
+ int ret;
+
+ if (!group) {
+ WDS_LOGE("Group not exist");
+ ret = WIFI_DIRECT_ERROR_NOT_PERMITTED;
+ wfd_manager_dbus_return_err(ret, (GDBusMethodInvocation *)dest);
+ __WDS_LOG_FUNC_EXIT__;
+ return;
+ }
+
+ if (group->role == WFD_DEV_ROLE_GC) {
+ WDS_LOGE("Device is not GO");
+ ret = WIFI_DIRECT_ERROR_NOT_PERMITTED;
+ wfd_manager_dbus_return_err(ret, (GDBusMethodInvocation *)dest);
+ __WDS_LOG_FUNC_EXIT__;
+ return;
+ }
+
+ ret = WIFI_DIRECT_ERROR_NONE;
+ return_parameters = g_variant_new("(is)", ret, group->passphrase);
+ WDS_LOGI("group->pass : [%s]", group->passphrase);
+ wfd_manager_dbus_reply_params((GDBusMethodInvocation *)dest, return_parameters);
+
+ __WDS_LOG_FUNC_EXIT__;
+ return;
+}
+
+void set_persistent_group_handler(GVariant *parameters, void *dest)
+{
+ __WDS_LOG_FUNC_ENTER__;
+ wfd_manager_s *manager = wfd_get_manager();
+ if (!manager) {
+ WDS_LOGE("manager is not initialized");
+ __WDS_LOG_FUNC_EXIT__;
+ return;
+ }
+ GVariant *return_parameters = NULL;
+ gboolean enabled;
+ int ret;
+
+ g_variant_get(parameters, "(b)", &enabled);
+ WDS_LOGI("Activate Persistent Group : [%s]",
+ enabled ? "True" : "False");
+ if (enabled)
+ manager->local->group_flags |= WFD_GROUP_FLAG_PERSISTENT;
+ else
+ manager->local->group_flags &= ~(WFD_GROUP_FLAG_PERSISTENT);
+ ret = WIFI_DIRECT_ERROR_NONE;
+ return_parameters = g_variant_new("(i)", ret);
+ wfd_manager_dbus_reply_params((GDBusMethodInvocation *)dest, return_parameters);
+
+ __WDS_LOG_FUNC_EXIT__;
+ return;
+}
+
+void is_persistent_group_enabled_handler(GVariant *parameters, void *dest)
+{
+ __WDS_LOG_FUNC_ENTER__;
+ wfd_manager_s *manager = wfd_get_manager();
+ if (!manager) {
+ WDS_LOGE("manager is not initialized");
+ __WDS_LOG_FUNC_EXIT__;
+ return;
+ }
+ GVariant *return_parameters = NULL;
+ gboolean result;
+ result = ((manager->local->group_flags &
+ WFD_GROUP_FLAG_PERSISTENT)
+ == WFD_GROUP_FLAG_PERSISTENT);
+ WDS_LOGI("Is persistent group : [%s]", result ? "Yes" : "No");
+ return_parameters = g_variant_new("(b)", result);
+ wfd_manager_dbus_reply_params((GDBusMethodInvocation *)dest, return_parameters);
+
+ __WDS_LOG_FUNC_EXIT__;
+ return;
+}
+
+void get_device_name_handler(GVariant *parameters, void *dest)
+{
+ __WDS_LOG_FUNC_ENTER__;
+ GVariant *return_parameters = NULL;
+ char device_name[WIFI_DIRECT_MAX_DEVICE_NAME_LEN+1] = {0, };
+ int ret;
+
+ ret = wfd_local_get_dev_name(device_name);
+ if (ret < 0) {
+ WDS_LOGE("Failed to get device name");
+ wfd_manager_dbus_return_err(ret, (GDBusMethodInvocation *)dest);
+ __WDS_LOG_FUNC_EXIT__;
+ return;
+ } else {
+
+ ret = WIFI_DIRECT_ERROR_NONE;
+ return_parameters = g_variant_new("(is)", ret, device_name);
+ }
+ wfd_manager_dbus_reply_params((GDBusMethodInvocation *)dest, return_parameters);
+
+ __WDS_LOG_FUNC_EXIT__;
+ return;
+}
+
+void set_device_name_handler(GVariant *parameters, void *dest)
+{
+ __WDS_LOG_FUNC_ENTER__;
+ GVariant *return_parameters = NULL;
+ const char *device_name = NULL;
+ int ret;
+
+ g_variant_get(parameters, "(&s)", &device_name);
+ if (device_name == NULL) {
+ ret = WIFI_DIRECT_ERROR_INVALID_PARAMETER;
+ wfd_manager_dbus_return_err(ret, (GDBusMethodInvocation *)dest);
+ __WDS_LOG_FUNC_EXIT__;
+ return;
+ }
+
+ ret = wfd_local_set_dev_name((char *)device_name);
+ if (ret < 0) {
+ WDS_LOGE("Failed to set device name");
+ ret = WIFI_DIRECT_ERROR_OPERATION_FAILED;
+ wfd_manager_dbus_return_err(ret, (GDBusMethodInvocation *)dest);
+ __WDS_LOG_FUNC_EXIT__;
+ return;
+ }
+
+ ret = WIFI_DIRECT_ERROR_NONE;
+ return_parameters = g_variant_new("(i)", ret);
+ wfd_manager_dbus_reply_params((GDBusMethodInvocation *)dest, return_parameters);
+
+ __WDS_LOG_FUNC_EXIT__;
+ return;
+}
+
+void get_wps_pin_handler(GVariant *parameters, void *dest)
+{
+ __WDS_LOG_FUNC_ENTER__;
+ wfd_manager_s *manager = wfd_get_manager();
+ if (!manager) {
+ WDS_LOGE("manager is not initialized");
+ __WDS_LOG_FUNC_EXIT__;
+ return;
+ }
+ GVariant *return_parameters = NULL;
+ wfd_session_s *session = (wfd_session_s*) manager->session;
+ int ret;
+
+ if (!session || manager->auto_pin[0] != 0) {
+ WDS_LOGE("Session not exist");
+ ret = WIFI_DIRECT_ERROR_NOT_PERMITTED;
+ wfd_manager_dbus_return_err(ret, (GDBusMethodInvocation *)dest);
+ __WDS_LOG_FUNC_EXIT__;
+ return;
+ }
+
+ if (session->wps_pin[0] == '\0') {
+ WDS_LOGE("WPS PIN is not set");
+ ret = WIFI_DIRECT_ERROR_OPERATION_FAILED;
+ wfd_manager_dbus_return_err(ret, (GDBusMethodInvocation *)dest);
+ __WDS_LOG_FUNC_EXIT__;
+ return;
+ }
+
+ ret = WIFI_DIRECT_ERROR_NONE;
+ return_parameters = g_variant_new("(is)", ret, session->wps_pin);
+ wfd_manager_dbus_reply_params((GDBusMethodInvocation *)dest, return_parameters);
+
+ __WDS_LOG_FUNC_EXIT__;
+ return;
+}
+
+void set_wps_pin_handler(GVariant *parameters, void *dest)
+{
+ __WDS_LOG_FUNC_ENTER__;
+ wfd_manager_s *manager = wfd_get_manager();
+ if (!manager) {
+ WDS_LOGE("manager is not initialized");
+ __WDS_LOG_FUNC_EXIT__;
+ return;
+ }
+ GVariant *return_parameters = NULL;
+ const char *pin = NULL;
+ wfd_session_s *session = (wfd_session_s*) manager->session;
+ int ret;
+
+ g_variant_get(parameters, "(&s)", &pin);
+ if (pin == NULL) {
+ ret = WIFI_DIRECT_ERROR_INVALID_PARAMETER;
+ wfd_manager_dbus_return_err(ret, (GDBusMethodInvocation *)dest);
+ __WDS_LOG_FUNC_EXIT__;
+ return;
+ }
+
+ if (!session) {
+ WDS_LOGE("Session not exist");
+ g_strlcpy(manager->auto_pin, pin, strlen(pin) + 1);
+ } else {
+ g_strlcpy(session->wps_pin, pin, strlen(pin) + 1);
+ }
+
+ ret = WIFI_DIRECT_ERROR_NONE;
+ return_parameters = g_variant_new("(i)", ret);
+ wfd_manager_dbus_reply_params((GDBusMethodInvocation *)dest, return_parameters);
+
+ __WDS_LOG_FUNC_EXIT__;
+ return;
+}
+
+void generate_wps_pin_handler(GVariant *parameters, void *dest)
+{
+ __WDS_LOG_FUNC_ENTER__;
+
+ wfd_manager_dbus_reply_error_none((GDBusMethodInvocation *)dest);
+
+ __WDS_LOG_FUNC_EXIT__;
+ return;
+}
+
+void get_supported_wps_mode_handler(GVariant *parameters, void *dest)
+{
+ __WDS_LOG_FUNC_ENTER__;
+ GVariant *return_parameters = NULL;
+ int config_methods = 0;
+ int ret;
+
+ ret = wfd_local_get_supported_wps_mode(&config_methods);
+ if (ret < 0) {
+ WDS_LOGE("Failed to get supported wps mode");
+ ret = WIFI_DIRECT_ERROR_OPERATION_FAILED;
+ wfd_manager_dbus_return_err(ret, (GDBusMethodInvocation *)dest);
+ __WDS_LOG_FUNC_EXIT__;
+ return;
+ }
+
+ ret = WIFI_DIRECT_ERROR_NONE;
+ return_parameters = g_variant_new("(ii)", ret, config_methods);
+ wfd_manager_dbus_reply_params((GDBusMethodInvocation *)dest, return_parameters);
+
+ __WDS_LOG_FUNC_EXIT__;
+ return;
+}
+
+void get_req_wps_mode_handler(GVariant *parameters, void *dest)
+{
+ __WDS_LOG_FUNC_ENTER__;
+ GVariant *return_parameters = NULL;
+ int wps_mode = 0;
+ int ret;
+
+ ret = wfd_manager_get_req_wps_mode(&wps_mode);
+ if (ret < 0) {
+ WDS_LOGE("Failed to get request wps mode");
+ ret = WIFI_DIRECT_ERROR_OPERATION_FAILED;
+ wfd_manager_dbus_return_err(ret, (GDBusMethodInvocation *)dest);
+ __WDS_LOG_FUNC_EXIT__;
+ return;
+ }
+
+ ret = WIFI_DIRECT_ERROR_NONE;
+ return_parameters = g_variant_new("(ii)", ret, wps_mode);
+ wfd_manager_dbus_reply_params((GDBusMethodInvocation *)dest, return_parameters);
+
+ __WDS_LOG_FUNC_EXIT__;
+ return;
+}
+
+void set_req_wps_mode_handler(GVariant *parameters, void *dest)
+{
+ __WDS_LOG_FUNC_ENTER__;
+ GVariant *return_parameters = NULL;
+ int type = 0;
+ int ret;
+
+ g_variant_get(parameters, "(i)", &type);
+ ret = wfd_manager_set_req_wps_mode(type);
+ if (ret < 0) {
+ WDS_LOGE("Failed to set request wps mode");
+ ret = WIFI_DIRECT_ERROR_OPERATION_FAILED;
+ wfd_manager_dbus_return_err(ret, (GDBusMethodInvocation *)dest);
+ __WDS_LOG_FUNC_EXIT__;
+ return;
+ }
+
+ ret = WIFI_DIRECT_ERROR_NONE;
+ return_parameters = g_variant_new("(i)", ret);
+ wfd_manager_dbus_reply_params((GDBusMethodInvocation *)dest, return_parameters);
+
+ __WDS_LOG_FUNC_EXIT__;
+ return;
+}
+
+void get_local_wps_mode_handler(GVariant *parameters, void *dest)
+{
+ __WDS_LOG_FUNC_ENTER__;
+ GVariant *return_parameters = NULL;
+ int wps_mode = 0;
+ int ret;
+
+ ret = wfd_local_get_wps_mode(&wps_mode);
+ if (ret < 0) {
+ WDS_LOGE("Failed to get request wps mode");
+ ret = WIFI_DIRECT_ERROR_OPERATION_FAILED;
+ wfd_manager_dbus_return_err(ret, (GDBusMethodInvocation *)dest);
+ __WDS_LOG_FUNC_EXIT__;
+ return;
+ }
+
+ ret = WIFI_DIRECT_ERROR_NONE;
+ return_parameters = g_variant_new("(ii)", ret, wps_mode);
+ wfd_manager_dbus_reply_params((GDBusMethodInvocation *)dest, return_parameters);
+
+ __WDS_LOG_FUNC_EXIT__;
+ return;
+}
+
+void get_ip_address_handler(GVariant *parameters, void *dest)
+{
+ __WDS_LOG_FUNC_ENTER__;
+ wfd_manager_s *manager = wfd_get_manager();
+ if (!manager) {
+ WDS_LOGE("manager is not initialized");
+ __WDS_LOG_FUNC_EXIT__;
+ return;
+ }
+ GVariant *return_parameters = NULL;
+ char ip_addr_str[IPSTR_LEN+1] = {0, };
+ int ret;
+
+ if (manager->state < WIFI_DIRECT_STATE_CONNECTED) {
+ WDS_LOGE("Device is not connected yet");
+ ret = WIFI_DIRECT_ERROR_NOT_PERMITTED;
+ wfd_manager_dbus_return_err(ret, (GDBusMethodInvocation *)dest);
+ __WDS_LOG_FUNC_EXIT__;
+ return;
+ }
+
+ ret = wfd_local_get_ip_addr((char *)ip_addr_str);
+ if (ret < 0) {
+ WDS_LOGE("Failed to get local IP address");
+ ret = WIFI_DIRECT_ERROR_OPERATION_FAILED;
+ wfd_manager_dbus_return_err(ret, (GDBusMethodInvocation *)dest);
+ __WDS_LOG_FUNC_EXIT__;
+ return;
+ }
+
+ return_parameters = g_variant_new("(is)", ret, ip_addr_str);
+ WDS_LOGI("IP addr : [%s]", ip_addr_str);
+ wfd_manager_dbus_reply_params((GDBusMethodInvocation *)dest, return_parameters);
+
+ __WDS_LOG_FUNC_EXIT__;
+ return;
+}
+
+void get_mac_address_handler(GVariant *parameters, void *dest)
+{
+ __WDS_LOG_FUNC_ENTER__;
+ GVariant *return_parameters = NULL;
+ char device_mac[MACSTR_LEN+1] = {0, };
+ int ret;
+
+ ret = wfd_local_get_dev_mac(device_mac);
+ if (ret < 0) {
+ WDS_LOGE("Failed to get device mac");
+ ret = WIFI_DIRECT_ERROR_OPERATION_FAILED;
+ wfd_manager_dbus_return_err(ret, (GDBusMethodInvocation *)dest);
+ __WDS_LOG_FUNC_EXIT__;
+ return;
+ }
+
+ ret = WIFI_DIRECT_ERROR_NONE;
+ return_parameters = g_variant_new("(is)", ret, device_mac);
+ wfd_manager_dbus_reply_params((GDBusMethodInvocation *)dest, return_parameters);
+
+ __WDS_LOG_FUNC_EXIT__;
+ return;
+}
+
+void get_go_intent_handler(GVariant *parameters, void *dest)
+{
+ __WDS_LOG_FUNC_ENTER__;
+ GVariant *return_parameters = NULL;
+ int go_intent = 0;
+ int ret;
+
+ ret = wfd_manager_get_go_intent(&go_intent);
+ if (ret < 0) {
+ WDS_LOGE("Failed to get GO intent");
+ ret = WIFI_DIRECT_ERROR_OPERATION_FAILED;
+ wfd_manager_dbus_return_err(ret, (GDBusMethodInvocation *)dest);
+ __WDS_LOG_FUNC_EXIT__;
+ return;
+ }
+
+ ret = WIFI_DIRECT_ERROR_NONE;
+ return_parameters = g_variant_new("(ii)", ret, go_intent);
+ wfd_manager_dbus_reply_params((GDBusMethodInvocation *)dest, return_parameters);
+
+ __WDS_LOG_FUNC_EXIT__;
+ return;
+}
+
+void set_go_intent_handler(GVariant *parameters, void *dest)
+{
+ __WDS_LOG_FUNC_ENTER__;
+ GVariant *return_parameters = NULL;
+ int go_intent = 0;
+ int ret;
+
+ g_variant_get(parameters, "(i)", &go_intent);
+ ret = wfd_manager_set_go_intent(go_intent);
+ if (ret < 0) {
+ WDS_LOGE("Failed to set GO intent");
+ ret = WIFI_DIRECT_ERROR_OPERATION_FAILED;
+ wfd_manager_dbus_return_err(ret, (GDBusMethodInvocation *)dest);
+ __WDS_LOG_FUNC_EXIT__;
+ return;
+ }
+
+ ret = WIFI_DIRECT_ERROR_NONE;
+ return_parameters = g_variant_new("(i)", ret);
+ wfd_manager_dbus_reply_params((GDBusMethodInvocation *)dest, return_parameters);
+
+ __WDS_LOG_FUNC_EXIT__;
+ return;
+}
+
+void get_max_client_handler(GVariant *parameters, void *dest)
+{
+ __WDS_LOG_FUNC_ENTER__;
+ GVariant *return_parameters = NULL;
+ int max_client = 0;
+ int ret;
+
+ ret = wfd_manager_get_max_station(&max_client);
+ if (ret < 0) {
+ WDS_LOGE("Failed to get max station");
+ ret = WIFI_DIRECT_ERROR_OPERATION_FAILED;
+ wfd_manager_dbus_return_err(ret, (GDBusMethodInvocation *)dest);
+ __WDS_LOG_FUNC_EXIT__;
+ return;
+ }
+
+ ret = WIFI_DIRECT_ERROR_NONE;
+ return_parameters = g_variant_new("(ii)", ret, max_client);
+ wfd_manager_dbus_reply_params((GDBusMethodInvocation *)dest, return_parameters);
+
+ __WDS_LOG_FUNC_EXIT__;
+ return;
+}
+
+void set_max_client_handler(GVariant *parameters, void *dest)
+{
+ __WDS_LOG_FUNC_ENTER__;
+ GVariant *return_parameters = NULL;
+ int max_client = 0;
+ int ret;
+
+ g_variant_get(parameters, "(i)", &max_client);
+
+ ret = wfd_manager_set_max_station(max_client);
+ if (ret < 0) {
+ WDS_LOGE("Failed to set max station");
+ ret = WIFI_DIRECT_ERROR_OPERATION_FAILED;
+ wfd_manager_dbus_return_err(ret, (GDBusMethodInvocation *)dest);
+ __WDS_LOG_FUNC_EXIT__;
+ return;
+ }
+
+ ret = WIFI_DIRECT_ERROR_NONE;
+ return_parameters = g_variant_new("(i)", ret);
+ wfd_manager_dbus_reply_params((GDBusMethodInvocation *)dest, return_parameters);
+
+ __WDS_LOG_FUNC_EXIT__;
+ return;
+}
+
+void set_autoconnection_mode_handler(GVariant *parameters, void *dest)
+{
+ __WDS_LOG_FUNC_ENTER__;
+ GVariant *return_parameters = NULL;
+ gboolean mode = FALSE;
+ int ret;
+
+ g_variant_get(parameters, "(b)", &mode);
+ ret = wfd_manager_set_autoconnection(mode);
+ if (ret < 0) {
+ WDS_LOGE("Failed to set autoconnection");
+ ret = WIFI_DIRECT_ERROR_OPERATION_FAILED;
+ wfd_manager_dbus_return_err(ret, (GDBusMethodInvocation *)dest);
+ __WDS_LOG_FUNC_EXIT__;
+ return;
+ }
+
+ ret = WIFI_DIRECT_ERROR_NONE;
+ return_parameters = g_variant_new("(i)", ret);
+ wfd_manager_dbus_reply_params((GDBusMethodInvocation *)dest, return_parameters);
+
+ __WDS_LOG_FUNC_EXIT__;
+ return;
+}
+
+void is_autoconnection_mode_handler(GVariant *parameters, void *dest)
+{
+ __WDS_LOG_FUNC_ENTER__;
+ GVariant *return_parameters = NULL;
+ int mode = 0;
+ int ret;
+
+ ret = wfd_manager_get_autoconnection(&mode);
+ if (ret < 0) {
+ WDS_LOGE("Failed to get autoconnection");
+ ret = WIFI_DIRECT_ERROR_OPERATION_FAILED;
+ wfd_manager_dbus_return_err(ret, (GDBusMethodInvocation *)dest);
+ __WDS_LOG_FUNC_EXIT__;
+ return;
+ }
+
+ ret = WIFI_DIRECT_ERROR_NONE;
+ return_parameters = g_variant_new("(ib)", ret, mode);
+ wfd_manager_dbus_reply_params((GDBusMethodInvocation *)dest, return_parameters);
+
+ __WDS_LOG_FUNC_EXIT__;
+ return;
+}
+
+void get_operating_channel_handler(GVariant *parameters, void *dest)
+{
+ __WDS_LOG_FUNC_ENTER__;
+ wfd_manager_s *manager = wfd_get_manager();
+ if (!manager) {
+ WDS_LOGE("manager is not initialized");
+ __WDS_LOG_FUNC_EXIT__;
+ return;
+ }
+ GVariant *return_parameters = NULL;
+ int channel = 0;
+ int ret;
+
+ wfd_group_s *group = manager->group;
+ if (!group) {
+ WDS_LOGE("Group not exist");
+ ret = WIFI_DIRECT_ERROR_NOT_PERMITTED;
+ wfd_manager_dbus_return_err(ret, (GDBusMethodInvocation *)dest);
+ __WDS_LOG_FUNC_EXIT__;
+ return;
+ }
+
+ channel = wfd_util_freq_to_channel(group->freq);
+ if (channel < 0) {
+ ret = WIFI_DIRECT_ERROR_OPERATION_FAILED;
+ wfd_manager_dbus_return_err(ret, (GDBusMethodInvocation *)dest);
+ __WDS_LOG_FUNC_EXIT__;
+ return;
+ }
+
+ ret = WIFI_DIRECT_ERROR_NONE;
+ return_parameters = g_variant_new("(ii)", ret, channel);
+ wfd_manager_dbus_reply_params((GDBusMethodInvocation *)dest, return_parameters);
+
+ __WDS_LOG_FUNC_EXIT__;
+ return;
+}
+
+void set_autoconnection_peer_handler(GVariant *parameters, void *dest)
+{
+ __WDS_LOG_FUNC_ENTER__;
+ GVariant *return_parameters = NULL;
+ int ret;
+
+ ret = WIFI_DIRECT_ERROR_NONE;
+ return_parameters = g_variant_new("(i)", ret);
+ wfd_manager_dbus_reply_params((GDBusMethodInvocation *)dest, return_parameters);
+
+ __WDS_LOG_FUNC_EXIT__;
+ return;
+}
+
+void get_interface_name_handler(GVariant *parameters, void *dest)
+{
+ __WDS_LOG_FUNC_ENTER__;
+ wfd_manager_s *manager = wfd_get_manager();
+ if (!manager) {
+ WDS_LOGE("manager is not initialized");
+ __WDS_LOG_FUNC_EXIT__;
+ return;
+ }
+ GVariant *return_parameters = NULL;
+ wfd_group_s *group = (wfd_group_s *)manager->group;
+ int ret;
+
+ if (!group) {
+ ret = WIFI_DIRECT_ERROR_NOT_PERMITTED;
+ wfd_manager_dbus_return_err(ret, (GDBusMethodInvocation *)dest);
+ __WDS_LOG_FUNC_EXIT__;
+ return;
+ }
+ ret = WIFI_DIRECT_ERROR_NONE;
+ return_parameters = g_variant_new("(is)", ret, group->ifname);
+ wfd_manager_dbus_reply_params((GDBusMethodInvocation *)dest, return_parameters);
+
+ __WDS_LOG_FUNC_EXIT__;
+ return;
+}
+
+void get_subnet_mask_handler(GVariant *parameters, void *dest)
+{
+ __WDS_LOG_FUNC_ENTER__;
+ GVariant *return_parameters = NULL;
+ char *get_str = NULL;
+ char subnet_mask[IPSTR_LEN+1] = {0, };
+ int ret;
+
+ get_str = vconf_get_str(VCONFKEY_WIFI_DIRECT_P2P_SUBNET_MASK);
+ if (!get_str) {
+ WDS_LOGE("Get Subnet Mask failed");
+ ret = WIFI_DIRECT_ERROR_NOT_PERMITTED;
+ wfd_manager_dbus_return_err(ret, (GDBusMethodInvocation *)dest);
+ __WDS_LOG_FUNC_EXIT__;
+ return;
+ }
+ WDS_LOGD("VCONFKEY_WIFI_DIRECT_P2P_SUBNET_MASK(%s) : %s", VCONFKEY_WIFI_DIRECT_P2P_SUBNET_MASK,
+ get_str);
+ ret = WIFI_DIRECT_ERROR_NONE;
+ g_strlcpy(subnet_mask, get_str, IPSTR_LEN + 1);
+ return_parameters = g_variant_new("(is)", ret, subnet_mask);
+ free(get_str);
+ wfd_manager_dbus_reply_params((GDBusMethodInvocation *)dest, return_parameters);
+
+ __WDS_LOG_FUNC_EXIT__;
+ return;
+}
+
+void get_gateway_handler(GVariant *parameters, void *dest)
+{
+ __WDS_LOG_FUNC_ENTER__;
+ GVariant *return_parameters = NULL;
+ char *get_str = NULL;
+ char gateway_addr[IPSTR_LEN+1] = {0, };
+ int ret;
+
+ get_str = vconf_get_str(VCONFKEY_WIFI_DIRECT_P2P_GATEWAY);
+ if (!get_str) {
+ WDS_LOGE("Get Gateway failed");
+ ret = WIFI_DIRECT_ERROR_NOT_PERMITTED;
+ wfd_manager_dbus_return_err(ret, (GDBusMethodInvocation *)dest);
+ __WDS_LOG_FUNC_EXIT__;
+ return;
+ }
+ WDS_LOGD("VCONFKEY_WIFI_DIRECT_P2P_GATEWAY_ADDR(%s) : %s", VCONFKEY_WIFI_DIRECT_P2P_GATEWAY,
+ get_str);
+ ret = WIFI_DIRECT_ERROR_NONE;
+ g_strlcpy(gateway_addr, get_str, IPSTR_LEN + 1);
+ return_parameters = g_variant_new("(is)", ret, gateway_addr);
+ free(get_str);
+ wfd_manager_dbus_reply_params((GDBusMethodInvocation *)dest, return_parameters);
+
+ __WDS_LOG_FUNC_EXIT__;
+ return;
+}
+
+void get_session_timer_handler(GVariant *parameters, void *dest)
+{
+ __WDS_LOG_FUNC_ENTER__;
+ wfd_manager_s *manager = wfd_get_manager();
+ if (!manager) {
+ WDS_LOGE("manager is not initialized");
+ __WDS_LOG_FUNC_EXIT__;
+ return;
+ }
+ GVariant *return_parameters = NULL;
+ int session_timer = 0;
+ int ret;
+
+ ret = WIFI_DIRECT_ERROR_NONE;
+ session_timer = manager->session_timer;
+ WDS_LOGD("Get Session Timer value is %d", session_timer);
+ return_parameters = g_variant_new("(ii)", ret, session_timer);
+ wfd_manager_dbus_reply_params((GDBusMethodInvocation *)dest, return_parameters);
+
+ __WDS_LOG_FUNC_EXIT__;
+ return;
+}
+
+void set_session_timer_handler(GVariant *parameters, void *dest)
+{
+ __WDS_LOG_FUNC_ENTER__;
+ wfd_manager_s *manager = wfd_get_manager();
+ if (!manager) {
+ WDS_LOGE("manager is not initialized");
+ __WDS_LOG_FUNC_EXIT__;
+ return;
+ }
+ GVariant *return_parameters = NULL;
+ int session_timer = 0;
+ int ret;
+
+ g_variant_get(parameters, "(i)", &session_timer);
+ WDS_LOGD("Set Session Timer value is %d", session_timer);
+ manager->session_timer = session_timer;
+ ret = WIFI_DIRECT_ERROR_NONE;
+ return_parameters = g_variant_new("(i)", ret);
+ wfd_manager_dbus_reply_params((GDBusMethodInvocation *)dest, return_parameters);
+
+ __WDS_LOG_FUNC_EXIT__;
+ return;
+}
+
+void get_auto_group_removal_handler(GVariant *parameters, void *dest)
+{
+ __WDS_LOG_FUNC_ENTER__;
+ wfd_manager_s *manager = wfd_get_manager();
+ if (!manager) {
+ WDS_LOGE("manager is not initialized");
+ __WDS_LOG_FUNC_EXIT__;
+ return;
+ }
+ GVariant *return_parameters = NULL;
+ gboolean enable;
+ int ret;
+
+ g_variant_get(parameters, "(b)", &enable);
+ WDS_LOGE("Activate Auto Group Removal Mode : [%s]",
+ enable ? "True" : "False");
+
+ if (manager->state < WIFI_DIRECT_STATE_ACTIVATED) {
+ WDS_LOGE("Wi-Fi Direct is not activated.");
+ ret = WIFI_DIRECT_ERROR_NOT_PERMITTED;
+ wfd_manager_dbus_return_err(ret, (GDBusMethodInvocation *)dest);
+ __WDS_LOG_FUNC_EXIT__;
+ return;
+ }
+
+ if (enable) {
+ manager->auto_group_remove_enable = TRUE;
+
+ /* Enable Group destroy only if state is connecting */
+ if (manager->state == WIFI_DIRECT_STATE_CONNECTING) {
+ WDS_LOGE("Wi-Fi Direct state is CONNECTING");
+ ret = WIFI_DIRECT_ERROR_NONE;
+ return_parameters = g_variant_new("(i)", ret);
+ wfd_manager_dbus_reply_params((GDBusMethodInvocation *)dest, return_parameters);
+
+ __WDS_LOG_FUNC_EXIT__;
+ return;
+ }
+ /* Remove group immediately if no connected peer found */
+ if (manager->local->dev_role == WFD_DEV_ROLE_GO) {
+ wfd_group_s *group = (wfd_group_s*) manager->group;
+ if (group && !group->member_count
+ && wfd_util_is_remove_group_allowed())
+ wfd_oem_destroy_group(manager->oem_ops, group->ifname);
+ }
+
+ } else
+ manager->auto_group_remove_enable = FALSE;
+
+
+ ret = WIFI_DIRECT_ERROR_NONE;
+ return_parameters = g_variant_new("(i)", ret);
+ wfd_manager_dbus_reply_params((GDBusMethodInvocation *)dest, return_parameters);
+
+ __WDS_LOG_FUNC_EXIT__;
+ return;
+}
+
+void get_primary_dev_type_handler(GVariant *parameters, void *dest)
+{
+ __WDS_LOG_FUNC_ENTER__;
+ GVariant *return_parameters = NULL;
+ int pri_dev_type = 0;
+ int ret;
+
+ ret = WIFI_DIRECT_ERROR_NONE;
+ pri_dev_type = DEFAULT_PRIMARY_DEVICE_TYPE;
+ WDS_LOGD("Get primary dev type value is %d", pri_dev_type);
+ return_parameters = g_variant_new("(ii)", ret, pri_dev_type);
+ wfd_manager_dbus_reply_params((GDBusMethodInvocation *)dest, return_parameters);
+
+ __WDS_LOG_FUNC_EXIT__;
+ return;
+}
+
+void get_secondary_dev_type_handler(GVariant *parameters, void *dest)
+{
+ __WDS_LOG_FUNC_ENTER__;
+ GVariant *return_parameters = NULL;
+ int sec_dev_type = 0;
+ int ret;
+
+ ret = WIFI_DIRECT_ERROR_NONE;
+ sec_dev_type = DEFAULT_SECONDARY_DEVICE_TYPE;
+ WDS_LOGD("Get secondary dev type value is %d", sec_dev_type);
+ return_parameters = g_variant_new("(ii)", ret, sec_dev_type);
+ wfd_manager_dbus_reply_params((GDBusMethodInvocation *)dest, return_parameters);
+
+ __WDS_LOG_FUNC_EXIT__;
+ return;
+}
+
+void get_peer_rssi_handler(GVariant *parameters, void *dest)
+{
+ __WDS_LOG_FUNC_ENTER__;
+ wfd_manager_s *manager = wfd_get_manager();
+ if (!manager) {
+ WDS_LOGE("manager is not initialized");
+ __WDS_LOG_FUNC_EXIT__;
+ return;
+ }
+ GVariant *return_parameters = NULL;
+ wfd_device_s *peer = NULL;
+ const char *mac_address = NULL;
+ unsigned char mac_addr[MACADDR_LEN] = {0, };
+ int ret;
+
+ g_variant_get(parameters, "(&s)", &mac_address);
+ macaddr_atoe(mac_address, mac_addr);
+
+ if (manager->state < WIFI_DIRECT_STATE_ACTIVATED) {
+ ret = WIFI_DIRECT_ERROR_NOT_PERMITTED;
+ wfd_manager_dbus_return_err(ret, (GDBusMethodInvocation *)dest);
+ __WDS_LOG_FUNC_EXIT__;
+ return;
+ }
+
+ peer = wfd_manager_get_peer_by_addr(manager, mac_addr);
+ if (!peer) {
+ WDS_LOGE("Failed to get peer");
+ ret = WIFI_DIRECT_ERROR_INVALID_PARAMETER;
+ wfd_manager_dbus_return_err(ret, (GDBusMethodInvocation *)dest);
+ __WDS_LOG_FUNC_EXIT__;
+ return;
+ }
+
+ ret = WIFI_DIRECT_ERROR_NONE;
+ return_parameters = g_variant_new("(ii)", ret, peer->rssi);
+ wfd_manager_dbus_reply_params((GDBusMethodInvocation *)dest, return_parameters);
+
+ __WDS_LOG_FUNC_EXIT__;
+ return;
+}
+
+void add_vsie_handler(GVariant *parameters, void *dest)
+{
+ __WDS_LOG_FUNC_ENTER__;
+ wfd_manager_s *manager = wfd_get_manager();
+ if (!manager) {
+ WDS_LOGE("manager is not initialized");
+ __WDS_LOG_FUNC_EXIT__;
+ return;
+ }
+ GVariant *return_parameters = NULL;
+ const char *vsie = NULL;
+ int frame_id = 0;
+ int ret;
+
+ g_variant_get(parameters, "(i&s)", &frame_id, &vsie);
+
+ if (manager->state < WIFI_DIRECT_STATE_ACTIVATED) {
+ ret = WIFI_DIRECT_ERROR_NOT_PERMITTED;
+ wfd_manager_dbus_return_err(ret, (GDBusMethodInvocation *)dest);
+ __WDS_LOG_FUNC_EXIT__;
+ return;
+ }
+
+ if (wfd_oem_add_vsie(manager->oem_ops, frame_id, vsie) < 0) {
+ WDS_LOGE("Failed to add vsie");
+ ret = WIFI_DIRECT_ERROR_OPERATION_FAILED;
+ wfd_manager_dbus_return_err(ret, (GDBusMethodInvocation *)dest);
+ __WDS_LOG_FUNC_EXIT__;
+ return;
+ }
+
+ ret = WIFI_DIRECT_ERROR_NONE;
+ return_parameters = g_variant_new("(i)", ret);
+ wfd_manager_dbus_reply_params((GDBusMethodInvocation *)dest, return_parameters);
+
+ __WDS_LOG_FUNC_EXIT__;
+ return;
+}
+
+void get_vsie_handler(GVariant *parameters, void *dest)
+{
+ __WDS_LOG_FUNC_ENTER__;
+ wfd_manager_s *manager = wfd_get_manager();
+ if (!manager) {
+ WDS_LOGE("manager is not initialized");
+ __WDS_LOG_FUNC_EXIT__;
+ return;
+ }
+ GVariant *return_parameters = NULL;
+ char *vsie = NULL;
+ int frame_id = 0;
+ int ret;
+
+ g_variant_get(parameters, "(i)", &frame_id);
+
+ if (manager->state < WIFI_DIRECT_STATE_ACTIVATED) {
+ ret = WIFI_DIRECT_ERROR_NOT_PERMITTED;
+ wfd_manager_dbus_return_err(ret, (GDBusMethodInvocation *)dest);
+ return;
+ }
+
+ if (wfd_oem_get_vsie(manager->oem_ops, frame_id, &vsie) < 0) {
+ WDS_LOGE("Failed to get vsie");
+ ret = WIFI_DIRECT_ERROR_OPERATION_FAILED;
+ wfd_manager_dbus_return_err(ret, (GDBusMethodInvocation *)dest);
+ __WDS_LOG_FUNC_EXIT__;
+ return;
+ }
+
+ WDS_LOGD("Received VSIE [%s]", vsie);
+
+ ret = WIFI_DIRECT_ERROR_NONE;
+ return_parameters = g_variant_new("(is)", ret, vsie);
+
+ g_free(vsie);
+ wfd_manager_dbus_reply_params((GDBusMethodInvocation *)dest, return_parameters);
+
+ __WDS_LOG_FUNC_EXIT__;
+ return;
+}
+
+void remove_vsie_handler(GVariant *parameters, void *dest)
+{
+ __WDS_LOG_FUNC_ENTER__;
+ wfd_manager_s *manager = wfd_get_manager();
+ if (!manager) {
+ WDS_LOGE("manager is not initialized");
+ __WDS_LOG_FUNC_EXIT__;
+ return;
+ }
+ GVariant *return_parameters = NULL;
+ const char *vsie = NULL;
+ int frame_id = 0;
+ int ret;
+
+ g_variant_get(parameters, "(i&s)", &frame_id, &vsie);
+
+ if (manager->state < WIFI_DIRECT_STATE_ACTIVATED) {
+ ret = WIFI_DIRECT_ERROR_NOT_PERMITTED;
+ wfd_manager_dbus_return_err(ret, (GDBusMethodInvocation *)dest);
+ __WDS_LOG_FUNC_EXIT__;
+ return;
+ }
+
+ if (wfd_oem_remove_vsie(manager->oem_ops, frame_id, vsie) < 0) {
+ WDS_LOGE("Failed to remove vsie");
+ ret = WIFI_DIRECT_ERROR_OPERATION_FAILED;
+ wfd_manager_dbus_return_err(ret, (GDBusMethodInvocation *)dest);
+ __WDS_LOG_FUNC_EXIT__;
+ return;
+ }
+
+ ret = WIFI_DIRECT_ERROR_NONE;
+ return_parameters = g_variant_new("(i)", ret);
+ wfd_manager_dbus_reply_params((GDBusMethodInvocation *)dest, return_parameters);
+
+ __WDS_LOG_FUNC_EXIT__;
+ return;
+}
+
+void srv_start_discovery_handler(GVariant *parameters, void *dest)
+{
+ __WDS_LOG_FUNC_ENTER__;
+ wfd_manager_s *manager = wfd_get_manager();
+ if (!manager) {
+ WDS_LOGE("manager is not initialized");
+ __WDS_LOG_FUNC_EXIT__;
+ return;
+ }
+ const char *mac_address = NULL;
+ int service_type;
+ unsigned char mac_addr[MACADDR_LEN] = {0, };
+ int ret;
+
+ if (!manager->is_service_discovery_supported) {
+ WDS_LOGE("Wi-Fi Direct service discovery is not supported.");
+ ret = WIFI_DIRECT_ERROR_NOT_SUPPORTED;
+ wfd_manager_dbus_return_err(ret, (GDBusMethodInvocation *)dest);
+ __WDS_LOG_FUNC_EXIT__;
+ return;
+ }
+
+ if (manager->state < WIFI_DIRECT_STATE_ACTIVATED) {
+ WDS_LOGE("Wi-Fi Direct is not activated.");
+ ret = WIFI_DIRECT_ERROR_NOT_PERMITTED;
+ wfd_manager_dbus_return_err(ret, (GDBusMethodInvocation *)dest);
+ __WDS_LOG_FUNC_EXIT__;
+ return;
+ }
+
+ g_variant_get(parameters, "(i&s)", &service_type, &mac_address);
+ if (mac_address == NULL) {
+ ret = WIFI_DIRECT_ERROR_INVALID_PARAMETER;
+ wfd_manager_dbus_return_err(ret, (GDBusMethodInvocation *)dest);
+ __WDS_LOG_FUNC_EXIT__;
+ return;
+ }
+
+ WDS_LOGD("Service type [%d]", service_type);
+ macaddr_atoe(mac_address, mac_addr);
+
+ ret = wfd_oem_start_service_discovery(manager->oem_ops,
+ mac_addr, service_type);
+ if (ret < 0) {
+ WDS_LOGE("Failed to start service discovery");
+ ret = WIFI_DIRECT_ERROR_OPERATION_FAILED;
+ wfd_manager_dbus_return_err(ret, (GDBusMethodInvocation *)dest);
+ __WDS_LOG_FUNC_EXIT__;
+ return;
+ }
+
+ wfd_manager_dbus_reply_error_none((GDBusMethodInvocation *)dest);
+
+ wfd_manager_dbus_emit_signal(WFD_MANAGER_SERVICE_INTERFACE,
+ "DiscoveryStarted", NULL);
+
+ __WDS_LOG_FUNC_EXIT__;
+ return;
+}
+
+void srv_stop_discovery_handler(GVariant *parameters, void *dest)
+{
+ __WDS_LOG_FUNC_ENTER__;
+ wfd_manager_s *manager = wfd_get_manager();
+ if (!manager) {
+ WDS_LOGE("manager is not initialized");
+ __WDS_LOG_FUNC_EXIT__;
+ return;
+ }
+ GVariant *return_parameters = NULL;
+ const char *mac_address = NULL;
+ int service_type;
+ unsigned char mac_addr[MACADDR_LEN] = {0, };
+ int ret;
+
+ if (!manager->is_service_discovery_supported) {
+ WDS_LOGE("Wi-Fi Direct service discovery is not supported.");
+ ret = WIFI_DIRECT_ERROR_NOT_SUPPORTED;
+ wfd_manager_dbus_return_err(ret, (GDBusMethodInvocation *)dest);
+ __WDS_LOG_FUNC_EXIT__;
+ return;
+ }
+
+ if (manager->state < WIFI_DIRECT_STATE_ACTIVATED) {
+ WDS_LOGE("Wi-Fi Direct is not activated.");
+ ret = WIFI_DIRECT_ERROR_NOT_PERMITTED;
+ wfd_manager_dbus_return_err(ret, (GDBusMethodInvocation *)dest);
+ __WDS_LOG_FUNC_EXIT__;
+ return;
+ }
+
+ g_variant_get(parameters, "(i&s)", &service_type, &mac_address);
+ if (mac_address == NULL) {
+ ret = WIFI_DIRECT_ERROR_INVALID_PARAMETER;
+ wfd_manager_dbus_return_err(ret, (GDBusMethodInvocation *)dest);
+ __WDS_LOG_FUNC_EXIT__;
+ return;
+ }
+
+ WDS_LOGD("Service type [%d]", service_type);
+ macaddr_atoe(mac_address, mac_addr);
+
+ ret = wfd_oem_cancel_service_discovery(manager->oem_ops,
+ mac_addr, service_type);
+ if (ret < 0) {
+ WDS_LOGE("Failed to cancel service discovery");
+ ret = WIFI_DIRECT_ERROR_OPERATION_FAILED;
+ wfd_manager_dbus_return_err(ret, (GDBusMethodInvocation *)dest);
+ __WDS_LOG_FUNC_EXIT__;
+ return;
+ }
+ ret = WIFI_DIRECT_ERROR_NONE;
+ return_parameters = g_variant_new("(i)", ret);
+ wfd_manager_dbus_reply_params((GDBusMethodInvocation *)dest, return_parameters);
+
+ __WDS_LOG_FUNC_EXIT__;
+ return;
+}
+
+void srv_register_handler(GVariant *parameters, void *dest)
+{
+ __WDS_LOG_FUNC_ENTER__;
+ wfd_manager_s *manager = wfd_get_manager();
+ if (!manager) {
+ WDS_LOGE("manager is not initialized");
+ __WDS_LOG_FUNC_EXIT__;
+ return;
+ }
+ GVariant *return_parameters = NULL;
+ int service_type;
+ int service_id = 0;
+ const char *info_str = NULL;
+ int ret;
+
+ if (!manager->is_service_discovery_supported) {
+ WDS_LOGE("Wi-Fi Direct service discovery is not supported.");
+ ret = WIFI_DIRECT_ERROR_NOT_SUPPORTED;
+ wfd_manager_dbus_return_err(ret, (GDBusMethodInvocation *)dest);
+ __WDS_LOG_FUNC_EXIT__;
+ return;
+ }
+
+ if (manager->state < WIFI_DIRECT_STATE_ACTIVATED) {
+ WDS_LOGE("Wi-Fi Direct is not activated.");
+ ret = WIFI_DIRECT_ERROR_NOT_PERMITTED;
+ wfd_manager_dbus_return_err(ret, (GDBusMethodInvocation *)dest);
+ __WDS_LOG_FUNC_EXIT__;
+ return;
+ }
+
+ g_variant_get(parameters, "(i&s)", &service_type, &info_str);
+ WDS_LOGD("Register service [%d: %s]", service_type, info_str);
+
+ ret = wfd_service_add(service_type, (char *)info_str, &service_id);
+ if (ret < 0) {
+ WDS_LOGE("Failed to add service");
+ ret = WIFI_DIRECT_ERROR_OPERATION_FAILED;
+ wfd_manager_dbus_return_err(ret, (GDBusMethodInvocation *)dest);
+ __WDS_LOG_FUNC_EXIT__;
+ return;
+ }
+
+ ret = WIFI_DIRECT_ERROR_NONE;
+ return_parameters = g_variant_new("(ii)", ret, service_id);
+ wfd_manager_dbus_reply_params((GDBusMethodInvocation *)dest, return_parameters);
+
+
+ __WDS_LOG_FUNC_EXIT__;
+ return;
+}
+
+void srv_deregister_handler(GVariant *parameters, void *dest)
+{
+ __WDS_LOG_FUNC_ENTER__;
+ wfd_manager_s *manager = wfd_get_manager();
+ if (!manager) {
+ WDS_LOGE("manager is not initialized");
+ __WDS_LOG_FUNC_EXIT__;
+ return;
+ }
+ GVariant *return_parameters = NULL;
+ int service_id = 0;
+ int ret;
+
+ if (!manager->is_service_discovery_supported) {
+ WDS_LOGE("Wi-Fi Direct service discovery is not supported.");
+ ret = WIFI_DIRECT_ERROR_NOT_SUPPORTED;
+ wfd_manager_dbus_return_err(ret, (GDBusMethodInvocation *)dest);
+ __WDS_LOG_FUNC_EXIT__;
+ return;
+ }
+
+ if (manager->state < WIFI_DIRECT_STATE_ACTIVATED) {
+ WDS_LOGE("Wi-Fi Direct is not activated.");
+ ret = WIFI_DIRECT_ERROR_NOT_PERMITTED;
+ wfd_manager_dbus_return_err(ret, (GDBusMethodInvocation *)dest);
+ __WDS_LOG_FUNC_EXIT__;
+ return;
+ }
+
+ g_variant_get(parameters, "(i)", &service_id);
+ WDS_LOGD("Service id [%d]", service_id);
+
+ ret = wfd_service_del(service_id);
+ if (ret < 0) {
+ WDS_LOGE("Failed to delete service");
+ ret = WIFI_DIRECT_ERROR_OPERATION_FAILED;
+ wfd_manager_dbus_return_err(ret, (GDBusMethodInvocation *)dest);
+ __WDS_LOG_FUNC_EXIT__;
+ return;
+ }
+
+ ret = WIFI_DIRECT_ERROR_NONE;
+ return_parameters = g_variant_new("(i)", ret);
+ wfd_manager_dbus_reply_params((GDBusMethodInvocation *)dest, return_parameters);
+
+ __WDS_LOG_FUNC_EXIT__;
+ return;
+}
+
+void display_init_handler(GVariant *parameters, void *dest)
+{
+ __WDS_LOG_FUNC_ENTER__;
+ wfd_manager_s *manager = wfd_get_manager();
+ if (!manager) {
+ WDS_LOGE("manager is not initialized");
+ __WDS_LOG_FUNC_EXIT__;
+ return;
+ }
+ GVariant *return_parameters = NULL;
+ int ret;
+
+ if (!manager->is_wifi_display_supported) {
+ ret = WIFI_DIRECT_ERROR_NOT_SUPPORTED;
+ wfd_manager_dbus_return_err(ret, (GDBusMethodInvocation *)dest);
+ __WDS_LOG_FUNC_EXIT__;
+ return;
+ }
+
+ if (manager->state < WIFI_DIRECT_STATE_ACTIVATED) {
+ ret = WIFI_DIRECT_ERROR_NOT_PERMITTED;
+ wfd_manager_dbus_return_err(ret, (GDBusMethodInvocation *)dest);
+ __WDS_LOG_FUNC_EXIT__;
+ return;
+ }
+
+ wfd_device_s * device = manager->local;
+
+ ret = wfd_oem_miracast_init(manager->oem_ops, TRUE);
+ if (ret < 0) {
+ WDS_LOGE("Failed to initialize display");
+ ret = WIFI_DIRECT_ERROR_OPERATION_FAILED;
+ wfd_manager_dbus_return_err(ret, (GDBusMethodInvocation *)dest);
+ __WDS_LOG_FUNC_EXIT__;
+ return;
+ }
+
+ device->display.type = WIFI_DISPLAY_DEFAULT_TYPE;
+ device->display.port = WIFI_DISPLAY_DEFAULT_PORT;
+ device->display.availability = WIFI_DISPLAY_DEFAULT_AVAIL;
+ device->display.hdcp_support = WIFI_DISPLAY_DEFAULT_HDCP;
+
+ ret = WIFI_DIRECT_ERROR_NONE;
+ return_parameters = g_variant_new("(i)", ret);
+ wfd_manager_dbus_reply_params((GDBusMethodInvocation *)dest, return_parameters);
+
+ __WDS_LOG_FUNC_EXIT__;
+ return;
+}
+
+void display_deinit_handler(GVariant *parameters, void *dest)
+{
+ __WDS_LOG_FUNC_ENTER__;
+ wfd_manager_s *manager = wfd_get_manager();
+ if (!manager) {
+ WDS_LOGE("manager is not initialized");
+ __WDS_LOG_FUNC_EXIT__;
+ return;
+ }
+ GVariant *return_parameters = NULL;
+ int ret;
+
+ if (!manager->is_wifi_display_supported) {
+ ret = WIFI_DIRECT_ERROR_NOT_SUPPORTED;
+ wfd_manager_dbus_return_err(ret, (GDBusMethodInvocation *)dest);
+ __WDS_LOG_FUNC_EXIT__;
+ return;
+ }
+
+ if (manager->state < WIFI_DIRECT_STATE_ACTIVATED) {
+ ret = WIFI_DIRECT_ERROR_NOT_PERMITTED;
+ wfd_manager_dbus_return_err(ret, (GDBusMethodInvocation *)dest);
+ __WDS_LOG_FUNC_EXIT__;
+ return;
+ }
+
+ wfd_device_s * device = manager->local;
+
+ ret = wfd_oem_miracast_init(manager->oem_ops, FALSE);
+ if (ret < 0) {
+ WDS_LOGE("Failed to deinitialize display");
+ ret = WIFI_DIRECT_ERROR_OPERATION_FAILED;
+ wfd_manager_dbus_return_err(ret, (GDBusMethodInvocation *)dest);
+ __WDS_LOG_FUNC_EXIT__;
+ return;
+ }
+
+ memset(&(device->display), 0x0, sizeof(wfd_display_type_e));
+
+ ret = WIFI_DIRECT_ERROR_NONE;
+ return_parameters = g_variant_new("(i)", ret);
+ wfd_manager_dbus_reply_params((GDBusMethodInvocation *)dest, return_parameters);
+
+ __WDS_LOG_FUNC_EXIT__;
+ return;
+}
+
+void display_set_config_handler(GVariant *parameters, void *dest)
+{
+ __WDS_LOG_FUNC_ENTER__;
+ wfd_manager_s *manager = wfd_get_manager();
+ if (!manager) {
+ WDS_LOGE("manager is not initialized");
+ __WDS_LOG_FUNC_EXIT__;
+ return;
+ }
+ GVariant *return_parameters = NULL;
+ int type, port, hdcp;
+ int ret;
+
+ if (!manager->is_wifi_display_supported) {
+ ret = WIFI_DIRECT_ERROR_NOT_SUPPORTED;
+ wfd_manager_dbus_return_err(ret, (GDBusMethodInvocation *)dest);
+ __WDS_LOG_FUNC_EXIT__;
+ return;
+ }
+
+ if (manager->state < WIFI_DIRECT_STATE_ACTIVATED) {
+ ret = WIFI_DIRECT_ERROR_NOT_PERMITTED;
+ wfd_manager_dbus_return_err(ret, (GDBusMethodInvocation *)dest);
+ __WDS_LOG_FUNC_EXIT__;
+ return;
+ }
+
+ g_variant_get(parameters, "(iii)", &type, &port, &hdcp);
+ WDS_LOGD("type %d port %d hdcp %d", type, port, hdcp);
+
+ ret = wfd_manager_set_display_device(type, port, hdcp);
+ if (ret < 0) {
+ WDS_LOGE("Failed to set display device settings");
+ ret = WIFI_DIRECT_ERROR_OPERATION_FAILED;
+ wfd_manager_dbus_return_err(ret, (GDBusMethodInvocation *)dest);
+ __WDS_LOG_FUNC_EXIT__;
+ return;
+ }
+
+ ret = WIFI_DIRECT_ERROR_NONE;
+ return_parameters = g_variant_new("(i)", ret);
+ wfd_manager_dbus_reply_params((GDBusMethodInvocation *)dest, return_parameters);
+
+ __WDS_LOG_FUNC_EXIT__;
+ return;
+}
+
+void display_set_avail_handler(GVariant *parameters, void *dest)
+{
+ __WDS_LOG_FUNC_ENTER__;
+ wfd_manager_s *manager = wfd_get_manager();
+ if (!manager) {
+ WDS_LOGE("manager is not initialized");
+ __WDS_LOG_FUNC_EXIT__;
+ return;
+ }
+ GVariant *return_parameters = NULL;
+ int availability;
+ int ret;
+
+ if (!manager->is_wifi_display_supported) {
+ ret = WIFI_DIRECT_ERROR_NOT_SUPPORTED;
+ wfd_manager_dbus_return_err(ret, (GDBusMethodInvocation *)dest);
+ __WDS_LOG_FUNC_EXIT__;
+ return;
+ }
+
+ if (manager->state < WIFI_DIRECT_STATE_ACTIVATED) {
+ ret = WIFI_DIRECT_ERROR_NOT_PERMITTED;
+ wfd_manager_dbus_return_err(ret, (GDBusMethodInvocation *)dest);
+ __WDS_LOG_FUNC_EXIT__;
+ return;
+ }
+
+ g_variant_get(parameters, "(i)", &availability);
+ ret = wfd_manager_set_session_availability(availability);
+ if (ret < 0) {
+ WDS_LOGE("Failed to set session availability");
+ ret = WIFI_DIRECT_ERROR_OPERATION_FAILED;
+ wfd_manager_dbus_return_err(ret, (GDBusMethodInvocation *)dest);
+ __WDS_LOG_FUNC_EXIT__;
+ return;
+ }
+
+ ret = WIFI_DIRECT_ERROR_NONE;
+ return_parameters = g_variant_new("(i)", ret);
+ wfd_manager_dbus_reply_params((GDBusMethodInvocation *)dest, return_parameters);
+
+ __WDS_LOG_FUNC_EXIT__;
+ return;
+}
+
+void display_get_peer_type_handler(GVariant *parameters, void *dest)
+{
+ __WDS_LOG_FUNC_ENTER__;
+ wfd_manager_s *manager = wfd_get_manager();
+ if (!manager) {
+ WDS_LOGE("manager is not initialized");
+ __WDS_LOG_FUNC_EXIT__;
+ return;
+ }
+ GVariant *return_parameters = NULL;
+ wfd_device_s *peer = NULL;
+ const char *mac_address = NULL;
+ unsigned char mac_addr[MACADDR_LEN] = {0, };
+ int ret;
+
+ if (!manager->is_wifi_display_supported) {
+ ret = WIFI_DIRECT_ERROR_NOT_SUPPORTED;
+ wfd_manager_dbus_return_err(ret, (GDBusMethodInvocation *)dest);
+ __WDS_LOG_FUNC_EXIT__;
+ return;
+ }
+
+ if (manager->state < WIFI_DIRECT_STATE_ACTIVATED) {
+ ret = WIFI_DIRECT_ERROR_NOT_PERMITTED;
+ wfd_manager_dbus_return_err(ret, (GDBusMethodInvocation *)dest);
+ __WDS_LOG_FUNC_EXIT__;
+ return;
+ }
+
+ g_variant_get(parameters, "(&s)", &mac_address);
+ if (mac_address == NULL) {
+ ret = WIFI_DIRECT_ERROR_INVALID_PARAMETER;
+ wfd_manager_dbus_return_err(ret, (GDBusMethodInvocation *)dest);
+ __WDS_LOG_FUNC_EXIT__;
+ return;
+ }
+
+ macaddr_atoe(mac_address, mac_addr);
+ peer = wfd_manager_get_peer_by_addr(manager, mac_addr);
+ if (!peer) {
+ WDS_LOGE("Failed to get peer");
+ ret = WIFI_DIRECT_ERROR_INVALID_PARAMETER;
+ wfd_manager_dbus_return_err(ret, (GDBusMethodInvocation *)dest);
+ __WDS_LOG_FUNC_EXIT__;
+ return;
+ }
+
+ ret = WIFI_DIRECT_ERROR_NONE;
+ return_parameters = g_variant_new("(ii)", ret, peer->display.type);
+ wfd_manager_dbus_reply_params((GDBusMethodInvocation *)dest, return_parameters);
+
+ __WDS_LOG_FUNC_EXIT__;
+ return;
+}
+
+void display_get_peer_avail_handler(GVariant *parameters, void *dest)
+{
+ __WDS_LOG_FUNC_ENTER__;
+ wfd_manager_s *manager = wfd_get_manager();
+ if (!manager) {
+ WDS_LOGE("manager is not initialized");
+ __WDS_LOG_FUNC_EXIT__;
+ return;
+ }
+ GVariant *return_parameters = NULL;
+ wfd_device_s *peer = NULL;
+ const char *mac_address = NULL;
+ unsigned char mac_addr[MACADDR_LEN] = {0, };
+ int ret;
+
+ if (!manager->is_wifi_display_supported) {
+ ret = WIFI_DIRECT_ERROR_NOT_SUPPORTED;
+ wfd_manager_dbus_return_err(ret, (GDBusMethodInvocation *)dest);
+ __WDS_LOG_FUNC_EXIT__;
+ return;
+ }
+
+ if (manager->state < WIFI_DIRECT_STATE_ACTIVATED) {
+ ret = WIFI_DIRECT_ERROR_NOT_PERMITTED;
+ wfd_manager_dbus_return_err(ret, (GDBusMethodInvocation *)dest);
+ __WDS_LOG_FUNC_EXIT__;
+ return;
+ }
+
+ g_variant_get(parameters, "(&s)", &mac_address);
+ if (mac_address == NULL) {
+ ret = WIFI_DIRECT_ERROR_INVALID_PARAMETER;
+ wfd_manager_dbus_return_err(ret, (GDBusMethodInvocation *)dest);
+ __WDS_LOG_FUNC_EXIT__;
+ return;
+ }
+
+ macaddr_atoe(mac_address, mac_addr);
+ peer = wfd_manager_get_peer_by_addr(manager, mac_addr);
+ if (!peer) {
+ WDS_LOGE("Failed to get peer");
+ ret = WIFI_DIRECT_ERROR_INVALID_PARAMETER;
+ wfd_manager_dbus_return_err(ret, (GDBusMethodInvocation *)dest);
+ __WDS_LOG_FUNC_EXIT__;
+ return;
+ }
+
+ ret = WIFI_DIRECT_ERROR_NONE;
+ return_parameters = g_variant_new("(ii)", ret, peer->display.availability);
+ wfd_manager_dbus_reply_params((GDBusMethodInvocation *)dest, return_parameters);
+
+ __WDS_LOG_FUNC_EXIT__;
+ return;
+}
+
+void display_get_peer_hdcp_handler(GVariant *parameters, void *dest)
+{
+ __WDS_LOG_FUNC_ENTER__;
+ wfd_manager_s *manager = wfd_get_manager();
+ if (!manager) {
+ WDS_LOGE("manager is not initialized");
+ __WDS_LOG_FUNC_EXIT__;
+ return;
+ }
+ GVariant *return_parameters = NULL;
+ wfd_device_s *peer = NULL;
+ const char *mac_address = NULL;
+ unsigned char mac_addr[MACADDR_LEN] = {0, };
+ int ret;
+
+ if (!manager->is_wifi_display_supported) {
+ ret = WIFI_DIRECT_ERROR_NOT_SUPPORTED;
+ wfd_manager_dbus_return_err(ret, (GDBusMethodInvocation *)dest);
+ __WDS_LOG_FUNC_EXIT__;
+ return;
+ }
+
+ if (manager->state < WIFI_DIRECT_STATE_ACTIVATED) {
+ ret = WIFI_DIRECT_ERROR_NOT_PERMITTED;
+ wfd_manager_dbus_return_err(ret, (GDBusMethodInvocation *)dest);
+ __WDS_LOG_FUNC_EXIT__;
+ return;
+ }
+
+ g_variant_get(parameters, "(&s)", &mac_address);
+ if (mac_address == NULL) {
+ ret = WIFI_DIRECT_ERROR_INVALID_PARAMETER;
+ wfd_manager_dbus_return_err(ret, (GDBusMethodInvocation *)dest);
+ __WDS_LOG_FUNC_EXIT__;
+ return;
+ }
+
+ macaddr_atoe(mac_address, mac_addr);
+ peer = wfd_manager_get_peer_by_addr(manager, mac_addr);
+ if (!peer) {
+ WDS_LOGE("Failed to get peer");
+ ret = WIFI_DIRECT_ERROR_INVALID_PARAMETER;
+ wfd_manager_dbus_return_err(ret, (GDBusMethodInvocation *)dest);
+ __WDS_LOG_FUNC_EXIT__;
+ return;
+ }
+
+ ret = WIFI_DIRECT_ERROR_NONE;
+ return_parameters = g_variant_new("(ii)", ret, peer->display.hdcp_support);
+ wfd_manager_dbus_reply_params((GDBusMethodInvocation *)dest, return_parameters);
+
+ __WDS_LOG_FUNC_EXIT__;
+ return;
+}
+
+void display_get_peer_port_handler(GVariant *parameters, void *dest)
+{
+ __WDS_LOG_FUNC_ENTER__;
+ wfd_manager_s *manager = wfd_get_manager();
+ if (!manager) {
+ WDS_LOGE("manager is not initialized");
+ __WDS_LOG_FUNC_EXIT__;
+ return;
+ }
+ GVariant *return_parameters = NULL;
+ wfd_device_s *peer = NULL;
+ const char *mac_address = NULL;
+ unsigned char mac_addr[MACADDR_LEN] = {0, };
+ int ret;
+
+ if (!manager->is_wifi_display_supported) {
+ ret = WIFI_DIRECT_ERROR_NOT_SUPPORTED;
+ wfd_manager_dbus_return_err(ret, (GDBusMethodInvocation *)dest);
+ __WDS_LOG_FUNC_EXIT__;
+ return;
+ }
+
+ if (manager->state < WIFI_DIRECT_STATE_ACTIVATED) {
+ ret = WIFI_DIRECT_ERROR_NOT_PERMITTED;
+ wfd_manager_dbus_return_err(ret, (GDBusMethodInvocation *)dest);
+ __WDS_LOG_FUNC_EXIT__;
+ return;
+ }
+
+ g_variant_get(parameters, "(&s)", &mac_address);
+ if (mac_address == NULL) {
+ ret = WIFI_DIRECT_ERROR_INVALID_PARAMETER;
+ wfd_manager_dbus_return_err(ret, (GDBusMethodInvocation *)dest);
+ __WDS_LOG_FUNC_EXIT__;
+ return;
+ }
+
+ macaddr_atoe(mac_address, mac_addr);
+ peer = wfd_manager_get_peer_by_addr(manager, mac_addr);
+ if (!peer) {
+ WDS_LOGE("Failed to get peer");
+ ret = WIFI_DIRECT_ERROR_INVALID_PARAMETER;
+ wfd_manager_dbus_return_err(ret, (GDBusMethodInvocation *)dest);
+ __WDS_LOG_FUNC_EXIT__;
+ return;
+ }
+
+ ret = WIFI_DIRECT_ERROR_NONE;
+ return_parameters = g_variant_new("(ii)", ret, peer->display.port);
+ wfd_manager_dbus_reply_params((GDBusMethodInvocation *)dest, return_parameters);
+
+ __WDS_LOG_FUNC_EXIT__;
+ return;
+}
+
+void display_get_peer_throughput_handler(GVariant *parameters, void *dest)
+{
+ __WDS_LOG_FUNC_ENTER__;
+ wfd_manager_s *manager = wfd_get_manager();
+ if (!manager) {
+ WDS_LOGE("manager is not initialized");
+ __WDS_LOG_FUNC_EXIT__;
+ return;
+ }
+ GVariant *return_parameters = NULL;
+ wfd_device_s *peer = NULL;
+ const char *mac_address = NULL;
+ unsigned char mac_addr[MACADDR_LEN] = {0, };
+ int ret;
+
+ if (!manager->is_wifi_display_supported) {
+ ret = WIFI_DIRECT_ERROR_NOT_SUPPORTED;
+ wfd_manager_dbus_return_err(ret, (GDBusMethodInvocation *)dest);
+ __WDS_LOG_FUNC_EXIT__;
+ return;
+ }
+
+ if (manager->state < WIFI_DIRECT_STATE_ACTIVATED) {
+ ret = WIFI_DIRECT_ERROR_NOT_PERMITTED;
+ wfd_manager_dbus_return_err(ret, (GDBusMethodInvocation *)dest);
+ __WDS_LOG_FUNC_EXIT__;
+ return;
+ }
+
+ g_variant_get(parameters, "(&s)", &mac_address);
+ if (mac_address == NULL) {
+ ret = WIFI_DIRECT_ERROR_INVALID_PARAMETER;
+ wfd_manager_dbus_return_err(ret, (GDBusMethodInvocation *)dest);
+ __WDS_LOG_FUNC_EXIT__;
+ return;
+ }
+
+ macaddr_atoe(mac_address, mac_addr);
+ peer = wfd_manager_get_peer_by_addr(manager, mac_addr);
+ if (!peer) {
+ WDS_LOGE("Failed to get peer");
+ ret = WIFI_DIRECT_ERROR_INVALID_PARAMETER;
+ wfd_manager_dbus_return_err(ret, (GDBusMethodInvocation *)dest);
+ __WDS_LOG_FUNC_EXIT__;
+ return;
+ }
+
+ ret = WIFI_DIRECT_ERROR_NONE;
+ return_parameters = g_variant_new("(ii)", ret, peer->display.max_tput);
+ wfd_manager_dbus_reply_params((GDBusMethodInvocation *)dest, return_parameters);
+
+ __WDS_LOG_FUNC_EXIT__;
+ return;
+}
+
+
+static void __g_variant_to_txt_record(GVariant *variant, char **txt_record)
+{
+ GVariantIter *iter = NULL;
+ gchar *key = NULL;
+ GVariant *value = NULL;
+ char *buff = NULL;
+ const char *str = NULL;
+ char *pos = NULL;
+ int txt_length = 0;
+ int key_length = 0;
+ gsize value_length = 0;
+ __WDS_LOG_FUNC_ENTER__;
+
+ DBUS_DEBUG_VARIANT(variant);
+
+ g_variant_get(variant, "a{sv}", &iter);
+ if (!iter) {
+ __WDS_LOG_FUNC_EXIT__;
+ return;
+ }
+
+ while (g_variant_iter_loop(iter, "{sv}", &key, &value)) {
+ WDS_LOGD("%s %s", key, g_variant_get_string(value, &value_length));
+ txt_length += strlen(key);
+ str = g_variant_get_string(value, &value_length);
+ txt_length += (int)value_length;
+ txt_length += 2;
+ }
+
+ g_variant_iter_free(iter);
+ if (txt_length == 0) {
+ __WDS_LOG_FUNC_EXIT__;
+ return;
+ }
+
+ buff = g_try_malloc0(txt_length);
+ if (buff == NULL) {
+ WDS_LOGE("g_try_malloc0 failed");
+ __WDS_LOG_FUNC_EXIT__;
+ return;
+ }
+ pos = buff;
+ g_variant_get(variant, "a{sv}", &iter);
+ while (g_variant_iter_loop(iter, "{sv}", &key, &value)) {
+ key_length = strlen(key);
+ str = g_variant_get_string(value, &value_length);
+
+ g_strlcpy(pos, key, key_length + 1);
+ pos += key_length;
+ pos[0] = '=';
+ pos++;
+
+ g_strlcpy(pos, str, value_length + 1);
+ pos += (int)value_length;
+ pos[0] = ',';
+ pos++;
+ }
+ buff[txt_length -1] = '\0';
+
+ g_variant_iter_free(iter);
+ *txt_record = buff;
+
+ __WDS_LOG_FUNC_EXIT__;
+ return;
+}
+
+static void __g_variant_to_seek_info(GVariant *variant, char **seek_info)
+{
+ GVariantIter *iter = NULL;
+ gchar *key = NULL;
+ char *buff = NULL;
+ char *pos = NULL;
+ int seek_length = 0;
+ int key_length = 0;
+
+ DBUS_DEBUG_VARIANT(variant);
+ g_variant_get(variant, "as", &iter);
+
+ if (!iter)
+ return;
+
+ while (g_variant_iter_loop(iter, "s", &key)) {
+ seek_length += strlen(key);
+ seek_length += 1;
+ }
+
+ g_variant_iter_free(iter);
+ if (seek_length == 0)
+ return;
+
+ buff = g_try_malloc0(seek_length);
+ if (buff == NULL) {
+ WDS_LOGE("g_try_malloc0 failed");
+ return;
+ }
+ pos = buff;
+ g_variant_get(variant, "as", &iter);
+ while (g_variant_iter_loop(iter, "s", &key)) {
+ key_length = strlen(key);
+
+ g_strlcpy(pos, key, key_length + 1);
+ pos += key_length;
+ pos[0] = ',';
+ pos++;
+ }
+ buff[seek_length -1] = '\0';
+
+ g_variant_iter_free(iter);
+ *seek_info = buff;
+
+ return;
+}
+
+static void __get_asp_advertise_params(GVariantIter *iter, wfd_oem_asp_service_s *service, int *replace)
+{
+ gchar *key = NULL;
+ GVariant *var = NULL;
+
+ if (!iter)
+ return;
+
+
+ while (g_variant_iter_loop(iter, "{sv}", &key, &var)) {
+ if (!g_strcmp0(key, "adv_id"))
+ g_variant_get(var, "u", &(service->adv_id));
+ else if (!g_strcmp0(key, "discovery_tech"))
+ g_variant_get(var, "i", &(service->discovery_tech));
+ else if (!g_strcmp0(key, "preferred_connection"))
+ g_variant_get(var, "y", &(service->preferred_connection));
+ else if (!g_strcmp0(key, "auto_accept"))
+ g_variant_get(var, "i", &(service->auto_accept));
+ else if (!g_strcmp0(key, "status"))
+ g_variant_get(var, "y", &(service->status));
+ else if (!g_strcmp0(key, "role"))
+ g_variant_get(var, "y", &(service->role));
+ else if (!g_strcmp0(key, "replace"))
+ g_variant_get(var, "i", replace);
+ else if (!g_strcmp0(key, "config_method"))
+ g_variant_get(var, "u", &(service->config_method));
+ else if (!g_strcmp0(key, "instance_name"))
+ g_variant_get(var, "&s", &(service->instance_name));
+ else if (!g_strcmp0(key, "service_type"))
+ g_variant_get(var, "&s", &(service->service_type));
+ else if (!g_strcmp0(key, "service_info"))
+ __g_variant_to_txt_record(var, &(service->service_info));
+ else if (!g_strcmp0(key, "rsp_info"))
+ g_variant_get(var, "&s", &(service->rsp_info));
+ else
+ ;/* Do Nothing */
+ }
+ return;
+}
+
+
+static void __get_asp_seek_params(GVariantIter *iter, wfd_oem_asp_service_s *service)
+{
+ gchar *key = NULL;
+ GVariant *var = NULL;
+
+ if (!iter)
+ return;
+
+ while (g_variant_iter_loop(iter, "{sv}", &key, &var)) {
+ if (!g_strcmp0(key, "discovery_tech"))
+ g_variant_get(var, "i", &(service->discovery_tech));
+ else if (!g_strcmp0(key, "search_id"))
+ g_variant_get(var, "t", &(service->asp_search_id));
+ else if (!g_strcmp0(key, "preferred_connection"))
+ g_variant_get(var, "y", &(service->preferred_connection));
+ else if (!g_strcmp0(key, "service_type"))
+ g_variant_get(var, "&s", &(service->service_type));
+ else if (!g_strcmp0(key, "service_info"))
+ __g_variant_to_seek_info(var, &(service->service_info));
+ else
+ ;/* Do Nothing */
+ }
+ return;
+}
+
+static void __get_asp_connect_params(GVariantIter *iter, wfd_oem_asp_prov_s *prov_params)
+{
+ gchar *key = NULL;
+ GVariant *var = NULL;
+ const char *mac_str = NULL;
+ unsigned char role = 0;
+ unsigned int config = 0;
+
+ if (!iter)
+ return;
+
+ while (g_variant_iter_loop(iter, "{sv}", &key, &var)) {
+
+ if (!g_strcmp0(key, "service_mac")) {
+ g_variant_get(var, "&s", &mac_str);
+ if (mac_str == NULL)
+ memset(prov_params->service_mac, 0, sizeof(prov_params->service_mac));
+ else
+ macaddr_atoe(mac_str, prov_params->service_mac);
+ } else if (!g_strcmp0(key, "adv_id")) {
+ g_variant_get(var, "u", &(prov_params->adv_id));
+ } else if (!g_strcmp0(key, "session_mac")) {
+ g_variant_get(var, "&s", &mac_str);
+ if (mac_str == NULL)
+ memset(prov_params->session_mac, 0, sizeof(prov_params->session_mac));
+ else
+ macaddr_atoe(mac_str, prov_params->session_mac);
+ } else if (!g_strcmp0(key, "session_id")) {
+ g_variant_get(var, "u", &(prov_params->session_id));
+ } else if (!g_strcmp0(key, "role")) {
+ g_variant_get(var, "y", &(role));
+ prov_params->network_role = (int)role;
+ } else if (!g_strcmp0(key, "config_method")) {
+ g_variant_get(var, "u", &(config));
+ prov_params->network_config = (int)config;
+ } else if (!g_strcmp0(key, "session_info")) {
+ g_variant_get(var, "&s", &(prov_params->session_information));
+ } else {
+ ;/* Do Nothing */
+ }
+ }
+
+ return;
+}
+
+static void __get_asp_confirm_params(GVariantIter *iter, wfd_oem_asp_prov_s *prov_params, int *confirmed)
+{
+ gchar *key = NULL;
+ GVariant *var = NULL;
+ const char *mac_str = NULL;
+ const char *pin = NULL;
+
+ if (!iter)
+ return;
+
+ while (g_variant_iter_loop(iter, "{sv}", &key, &var)) {
+
+ if (!g_strcmp0(key, "service_mac")) {
+ g_variant_get(var, "&s", &mac_str);
+ if (mac_str == NULL)
+ memset(prov_params->service_mac, 0, sizeof(prov_params->service_mac));
+ else
+ macaddr_atoe(mac_str, prov_params->service_mac);
+ } else if (!g_strcmp0(key, "adv_id")) {
+ g_variant_get(var, "u", &(prov_params->adv_id));
+ } else if (!g_strcmp0(key, "session_mac")) {
+ g_variant_get(var, "&s", &mac_str);
+ if (mac_str == NULL)
+ memset(prov_params->session_mac, 0, sizeof(prov_params->session_mac));
+ else
+ macaddr_atoe(mac_str, prov_params->session_mac);
+ } else if (!g_strcmp0(key, "session_id")) {
+ g_variant_get(var, "u", &(prov_params->session_id));
+ } else if (!g_strcmp0(key, "confirm")) {
+ g_variant_get(var, "i", confirmed);
+ } else if (!g_strcmp0(key, "pin")) {
+ g_variant_get(var, "&s", &(pin));
+ g_strlcpy(prov_params->wps_pin, pin, PINSTR_LEN);
+ } else {
+ ;/* Do Nothing */
+ }
+ }
+
+ return;
+}
+
+void advertise_service_handler(GVariant *parameters, void *dest)
+{
+ __WDS_LOG_FUNC_ENTER__;
+ wfd_manager_s *manager = wfd_get_manager();
+ if (!manager) {
+ WDS_LOGE("manager is not initialized");
+ __WDS_LOG_FUNC_EXIT__;
+ return;
+ }
+
+ GVariant *return_parameters = NULL;
+ GVariantIter *iter = NULL;
+ wfd_oem_asp_service_s service;
+ int replace = 0;
+ int ret;
+
+ if (!manager->is_asp_supported) {
+ WDS_LOGD("ASP is not supported.");
+ ret = WIFI_DIRECT_ERROR_NOT_SUPPORTED;
+ wfd_manager_dbus_return_err(ret, (GDBusMethodInvocation *)dest);
+ __WDS_LOG_FUNC_EXIT__;
+ return;
+ }
+
+ if (manager->state != WIFI_DIRECT_STATE_ACTIVATED &&
+ manager->state != WIFI_DIRECT_STATE_DISCOVERING &&
+ manager->state >= WIFI_DIRECT_STATE_CONNECTED) {
+ WDS_LOGE("Wi-Fi Direct is not available status for Advertising.");
+ ret = WIFI_DIRECT_ERROR_NOT_PERMITTED;
+ wfd_manager_dbus_return_err(ret, (GDBusMethodInvocation *)dest);
+ __WDS_LOG_FUNC_EXIT__;
+ return;
+ }
+
+ g_variant_get(parameters, "(a{sv})", &iter);
+ if (!iter) {
+ ret = WIFI_DIRECT_ERROR_INVALID_PARAMETER;
+ wfd_manager_dbus_return_err(ret, (GDBusMethodInvocation *)dest);
+ __WDS_LOG_FUNC_EXIT__;
+ return;
+ }
+
+ memset(&service, 0, sizeof(wfd_oem_asp_service_s));
+ __get_asp_advertise_params(iter, &service, &replace);
+ ret = wfd_oem_advertise_service(manager->oem_ops, &service, replace);
+ if (ret < 0) {
+ WDS_LOGE("Failed to add service");
+ g_free(service.service_info);
+ g_variant_iter_free(iter);
+ ret = WIFI_DIRECT_ERROR_OPERATION_FAILED;
+ wfd_manager_dbus_return_err(ret, (GDBusMethodInvocation *)dest);
+ __WDS_LOG_FUNC_EXIT__;
+ return;
+ }
+ g_free(service.service_info);
+ g_variant_iter_free(iter);
+
+ if (manager->local->dev_role == WFD_DEV_ROLE_GO) {
+ WDS_LOGW("Wi-Fi Direct device is already visible, do not start listen");
+ wfd_manager_dbus_reply_params((GDBusMethodInvocation *)dest, return_parameters);
+ __WDS_LOG_FUNC_EXIT__;
+ return;
+ }
+
+ ret = wfd_manager_start_discovery(manager,
+ WFD_OEM_SCAN_MODE_PASSIVE, 0,
+ 0, 0, 0);
+ if (ret == WIFI_DIRECT_ERROR_NONE) {
+ wfd_manager_dbus_emit_signal(WFD_MANAGER_MANAGE_INTERFACE,
+ "ListenStarted",
+ NULL);
+ } else {
+ wfd_oem_cancel_advertise_service(manager->oem_ops, &service);
+ ret = WIFI_DIRECT_ERROR_OPERATION_FAILED;
+ wfd_manager_dbus_return_err(ret, (GDBusMethodInvocation *)dest);
+ __WDS_LOG_FUNC_EXIT__;
+ return;
+ }
+
+ ret = WIFI_DIRECT_ERROR_NONE;
+ return_parameters = g_variant_new("(i)", ret);
+ wfd_manager_dbus_reply_params((GDBusMethodInvocation *)dest, return_parameters);
+
+
+ __WDS_LOG_FUNC_EXIT__;
+ return;
+}
+
+void cancel_advertise_service_handler(GVariant *parameters, void *dest)
+{
+ __WDS_LOG_FUNC_ENTER__;
+ wfd_manager_s *manager = wfd_get_manager();
+ if (!manager) {
+ WDS_LOGE("manager is not initialized");
+ __WDS_LOG_FUNC_EXIT__;
+ return;
+ }
+ GVariant *return_parameters = NULL;
+ wfd_oem_asp_service_s service;
+ int ret;
+
+ memset(&service, 0, sizeof(wfd_oem_asp_service_s));
+
+ if (!manager->is_asp_supported) {
+ WDS_LOGD("ASP is not supported.");
+ ret = WIFI_DIRECT_ERROR_NOT_SUPPORTED;
+ wfd_manager_dbus_return_err(ret, (GDBusMethodInvocation *)dest);
+ __WDS_LOG_FUNC_EXIT__;
+ return;
+ }
+
+ if (manager->state < WIFI_DIRECT_STATE_ACTIVATED) {
+ ret = WIFI_DIRECT_ERROR_NOT_PERMITTED;
+ wfd_manager_dbus_return_err(ret, (GDBusMethodInvocation *)dest);
+ __WDS_LOG_FUNC_EXIT__;
+ return;
+ }
+
+ g_variant_get(parameters, "(u)", &(service.adv_id));
+ ret = wfd_oem_cancel_advertise_service(manager->oem_ops, &service);
+ if (ret < 0) {
+ WDS_LOGE("Failed to del service");
+ ret = WIFI_DIRECT_ERROR_OPERATION_FAILED;
+ wfd_manager_dbus_return_err(ret, (GDBusMethodInvocation *)dest);
+ __WDS_LOG_FUNC_EXIT__;
+ return;
+ }
+
+ ret = WIFI_DIRECT_ERROR_NONE;
+ return_parameters = g_variant_new("(i)", ret);
+ wfd_manager_dbus_reply_params((GDBusMethodInvocation *)dest, return_parameters);
+
+ __WDS_LOG_FUNC_EXIT__;
+ return;
+}
+
+void seek_service_handler(GVariant *parameters, void *dest)
+{
+ __WDS_LOG_FUNC_ENTER__;
+ wfd_manager_s *manager = wfd_get_manager();
+ if (!manager) {
+ WDS_LOGE("manager is not initialized");
+ __WDS_LOG_FUNC_EXIT__;
+ return;
+ }
+
+ GVariant *return_parameters = NULL;
+ wfd_oem_asp_service_s service;
+ GVariantIter *iter = NULL;
+ int ret;
+
+ if (!manager->is_asp_supported) {
+ WDS_LOGD("ASP is not supported.");
+ ret = WIFI_DIRECT_ERROR_NOT_SUPPORTED;
+ wfd_manager_dbus_return_err(ret, (GDBusMethodInvocation *)dest);
+ __WDS_LOG_FUNC_EXIT__;
+ return;
+ }
+
+ if (manager->state != WIFI_DIRECT_STATE_ACTIVATED &&
+ manager->state != WIFI_DIRECT_STATE_DISCOVERING &&
+ manager->state >= WIFI_DIRECT_STATE_CONNECTED) {
+ WDS_LOGE("Wi-Fi Direct is not available status to Seek.");
+ ret = WIFI_DIRECT_ERROR_NOT_PERMITTED;
+ wfd_manager_dbus_return_err(ret, (GDBusMethodInvocation *)dest);
+ __WDS_LOG_FUNC_EXIT__;
+ return;
+ }
+
+ g_variant_get(parameters, "(a{sv})", &iter);
+ if (!iter) {
+ ret = WIFI_DIRECT_ERROR_INVALID_PARAMETER;
+ wfd_manager_dbus_return_err(ret, (GDBusMethodInvocation *)dest);
+ __WDS_LOG_FUNC_EXIT__;
+ return;
+ }
+
+ memset(&service, 0, sizeof(wfd_oem_asp_service_s));
+ __get_asp_seek_params(iter, &service);
+ ret = wfd_oem_seek_service(manager->oem_ops, &service);
+ if (ret < 0) {
+ WDS_LOGE("Failed to seek service");
+ g_free(service.service_info);
+ g_variant_iter_free(iter);
+ ret = WIFI_DIRECT_ERROR_OPERATION_FAILED;
+ wfd_manager_dbus_return_err(ret, (GDBusMethodInvocation *)dest);
+ __WDS_LOG_FUNC_EXIT__;
+ return;
+ }
+ g_free(service.service_info);
+ g_variant_iter_free(iter);
+
+ WDS_LOGD("search_id [%x]", service.search_id);
+
+ ret = wfd_manager_start_discovery(manager,
+ WFD_OEM_SCAN_MODE_ACTIVE, 0,
+ 0, 0, 0);
+ if (ret == WIFI_DIRECT_ERROR_NONE) {
+ wfd_manager_dbus_emit_signal(WFD_MANAGER_MANAGE_INTERFACE,
+ "DiscoveryStarted",
+ NULL);
+ } else {
+ wfd_oem_cancel_seek_service(manager->oem_ops, &service);
+ ret = WIFI_DIRECT_ERROR_OPERATION_FAILED;
+ wfd_manager_dbus_return_err(ret, (GDBusMethodInvocation *)dest);
+ __WDS_LOG_FUNC_EXIT__;
+ return;
+ }
+
+ ret = WIFI_DIRECT_ERROR_NONE;
+ return_parameters = g_variant_new("(i)", ret);
+ wfd_manager_dbus_reply_params((GDBusMethodInvocation *)dest, return_parameters);
+
+ __WDS_LOG_FUNC_EXIT__;
+ return;
+}
+
+void cancel_seek_service_handler(GVariant *parameters, void *dest)
+{
+ __WDS_LOG_FUNC_ENTER__;
+ wfd_manager_s *manager = wfd_get_manager();
+ if (!manager) {
+ WDS_LOGE("manager is not initialized");
+ __WDS_LOG_FUNC_EXIT__;
+ return;
+ }
+
+ GVariant *return_parameters = NULL;
+ wfd_oem_asp_service_s service;
+ int ret;
+
+ memset(&service, 0, sizeof(wfd_oem_asp_service_s));
+
+ if (!manager->is_asp_supported) {
+ WDS_LOGD("ASP is not supported.");
+ ret = WIFI_DIRECT_ERROR_NOT_SUPPORTED;
+ wfd_manager_dbus_return_err(ret, (GDBusMethodInvocation *)dest);
+ __WDS_LOG_FUNC_EXIT__;
+ return;
+ }
+
+ if (manager->state < WIFI_DIRECT_STATE_ACTIVATED) {
+ WDS_LOGE("Wi-Fi Direct is not activated.");
+ ret = WIFI_DIRECT_ERROR_NOT_PERMITTED;
+ wfd_manager_dbus_return_err(ret, (GDBusMethodInvocation *)dest);
+ __WDS_LOG_FUNC_EXIT__;
+ return;
+ }
+
+ g_variant_get(parameters, "(t)", &(service.asp_search_id));
+ ret = wfd_oem_cancel_seek_service(manager->oem_ops, &service);
+ if (ret < 0) {
+ WDS_LOGE("Failed to cancel seek service");
+ ret = WIFI_DIRECT_ERROR_OPERATION_FAILED;
+ wfd_manager_dbus_return_err(ret, (GDBusMethodInvocation *)dest);
+ __WDS_LOG_FUNC_EXIT__;
+ return;
+ }
+
+ ret = WIFI_DIRECT_ERROR_NONE;
+ return_parameters = g_variant_new("(i)", ret);
+ wfd_manager_dbus_reply_params((GDBusMethodInvocation *)dest, return_parameters);
+
+ __WDS_LOG_FUNC_EXIT__;
+ return;
+}
+
+void connect_sessoin_handler(GVariant *parameters, void *dest)
+{
+ __WDS_LOG_FUNC_ENTER__;
+ wfd_manager_s *manager = wfd_get_manager();
+ if (!manager) {
+ WDS_LOGE("manager is not initialized");
+ __WDS_LOG_FUNC_EXIT__;
+ return;
+ }
+
+ GVariantIter *iter = NULL;
+ wfd_oem_asp_prov_s prov_params;
+ int ret;
+
+ if (manager && !manager->is_asp_supported) {
+ WDS_LOGD("ASP is not supported.");
+ ret = WIFI_DIRECT_ERROR_NOT_SUPPORTED;
+ wfd_manager_dbus_return_err(ret, (GDBusMethodInvocation *)dest);
+ __WDS_LOG_FUNC_EXIT__;
+ return;
+ }
+
+ if (__is_discovery_available(manager)) {
+ ret = WIFI_DIRECT_ERROR_NOT_PERMITTED;
+ wfd_manager_dbus_return_err(ret, (GDBusMethodInvocation *)dest);
+ __WDS_LOG_FUNC_EXIT__;
+ return;
+ }
+
+ g_variant_get(parameters, "(a{sv})", &iter);
+ if (!iter) {
+ ret = WIFI_DIRECT_ERROR_INVALID_PARAMETER;
+ wfd_manager_dbus_return_err(ret, (GDBusMethodInvocation *)dest);
+ __WDS_LOG_FUNC_EXIT__;
+ return;
+ }
+
+ memset(&prov_params, 0, sizeof(wfd_oem_asp_prov_s));
+ __get_asp_connect_params(iter, &prov_params);
+
+ if (ISZEROMACADDR(prov_params.service_mac) ||
+ ISZEROMACADDR(prov_params.session_mac)) {
+ ret = WIFI_DIRECT_ERROR_INVALID_PARAMETER;
+ g_variant_iter_free(iter);
+ wfd_manager_dbus_return_err(ret, (GDBusMethodInvocation *)dest);
+ __WDS_LOG_FUNC_EXIT__;
+ return;
+ }
+
+ wfd_manager_dbus_reply_error_none((GDBusMethodInvocation *)dest);
+
+ wfd_asp_connect_status(prov_params.session_mac,
+ prov_params.session_id,
+ ASP_CONNECT_STATUS_REQUEST_SENT,
+ NULL);
+
+ wfd_group_s *group = (wfd_group_s*) manager->group;
+ if (group && group->member_count >= manager->max_station) {
+
+ wfd_asp_connect_status(prov_params.session_mac,
+ prov_params.session_id,
+ ASP_CONNECT_STATUS_NOMORE_CONNECT,
+ NULL);
+ g_variant_iter_free(iter);
+ __WDS_LOG_FUNC_EXIT__;
+ return;
+ }
+
+ ret = wfd_manager_asp_connect_session(manager, &prov_params);
+ if (ret == WIFI_DIRECT_ERROR_NONE) {
+ char peer_mac_address[MACSTR_LEN] = {0,};
+ g_snprintf(peer_mac_address, MACSTR_LEN, MACSTR, MAC2STR(prov_params.service_mac));
+ wfd_manager_dbus_emit_signal(WFD_MANAGER_MANAGE_INTERFACE,
+ "Connection",
+ g_variant_new("(iis)", WIFI_DIRECT_ERROR_NONE,
+ WFD_EVENT_CONNECTION_IN_PROGRESS,
+ peer_mac_address));
+ } else {
+ wfd_asp_connect_status(prov_params.session_mac,
+ prov_params.session_id,
+ ASP_CONNECT_STATUS_REQUEST_FAILED,
+ NULL);
+ }
+ g_variant_iter_free(iter);
+
+ __WDS_LOG_FUNC_EXIT__;
+ return;
+}
+
+void confirm_sessoin_handler(GVariant *parameters, void *dest)
+{
+ __WDS_LOG_FUNC_ENTER__;
+ wfd_manager_s *manager = wfd_get_manager();
+ if (!manager) {
+ WDS_LOGE("manager is not initialized");
+ __WDS_LOG_FUNC_EXIT__;
+ return;
+ }
+
+ GVariantIter *iter = NULL;
+ wfd_oem_asp_prov_s prov_params;
+ int confirmed = 0;
+ int ret;
+
+ if (manager && !manager->is_asp_supported) {
+ WDS_LOGD("ASP is not supported.");
+ ret = WIFI_DIRECT_ERROR_NOT_SUPPORTED;
+ wfd_manager_dbus_return_err(ret, (GDBusMethodInvocation *)dest);
+ __WDS_LOG_FUNC_EXIT__;
+ return;
+ }
+
+ if (manager->state != WIFI_DIRECT_STATE_CONNECTING) {
+ ret = WIFI_DIRECT_ERROR_NOT_PERMITTED;
+ wfd_manager_dbus_return_err(ret, (GDBusMethodInvocation *)dest);
+ __WDS_LOG_FUNC_EXIT__;
+ return;
+ }
+
+ g_variant_get(parameters, "(a{sv})", &iter);
+ if (!iter) {
+ ret = WIFI_DIRECT_ERROR_INVALID_PARAMETER;
+ wfd_manager_dbus_return_err(ret, (GDBusMethodInvocation *)dest);
+ __WDS_LOG_FUNC_EXIT__;
+ return;
+ }
+
+ memset(&prov_params, 0, sizeof(wfd_oem_asp_prov_s));
+ __get_asp_confirm_params(iter, &prov_params, &confirmed);
+
+ if (ISZEROMACADDR(prov_params.session_mac)) {
+ ret = WIFI_DIRECT_ERROR_INVALID_PARAMETER;
+ g_variant_iter_free(iter);
+ wfd_manager_dbus_return_err(ret, (GDBusMethodInvocation *)dest);
+ __WDS_LOG_FUNC_EXIT__;
+ return;
+ }
+
+ wfd_manager_dbus_reply_error_none((GDBusMethodInvocation *)dest);
+
+ ret = wfd_manager_asp_confirm_session(manager, &prov_params, confirmed);
+ if (ret == WIFI_DIRECT_ERROR_NONE && confirmed > 0) {
+ char peer_mac_address[MACSTR_LEN] = {0,};
+ g_snprintf(peer_mac_address, MACSTR_LEN, MACSTR, MAC2STR(prov_params.service_mac));
+ wfd_manager_dbus_emit_signal(WFD_MANAGER_MANAGE_INTERFACE,
+ "Connection",
+ g_variant_new("(iis)", WIFI_DIRECT_ERROR_NONE,
+ WFD_EVENT_CONNECTION_IN_PROGRESS,
+ peer_mac_address));
+ wfd_asp_connect_status(prov_params.session_mac,
+ prov_params.session_id,
+ ASP_CONNECT_STATUS_REQUEST_ACCEPTED,
+ NULL);
+ } else {
+ wfd_asp_connect_status(prov_params.session_mac,
+ prov_params.session_id,
+ ASP_CONNECT_STATUS_REQUEST_FAILED,
+ NULL);
+ }
+ g_variant_iter_free(iter);
+
+ __WDS_LOG_FUNC_EXIT__;
+ return;
+}