From c05aa3b309835b4789ffbe502be82c087a3e4ef9 Mon Sep 17 00:00:00 2001 From: Benjamin Berg Date: Wed, 10 Oct 2018 23:14:08 +0200 Subject: supplicant: Add API to join/cancel/disconnect a P2P Group --- src/supplicant/nm-supplicant-interface.c | 89 ++++++++++++++++++++++++++++++++ src/supplicant/nm-supplicant-interface.h | 7 +++ 2 files changed, 96 insertions(+) diff --git a/src/supplicant/nm-supplicant-interface.c b/src/supplicant/nm-supplicant-interface.c index e09c7814f7..6e29df60bd 100644 --- a/src/supplicant/nm-supplicant-interface.c +++ b/src/supplicant/nm-supplicant-interface.c @@ -2436,6 +2436,95 @@ nm_supplicant_interface_get_max_scan_ssids (NMSupplicantInterface *self) /*****************************************************************************/ +void +nm_supplicant_interface_p2p_connect (NMSupplicantInterface * self, + const char * peer, + const char * wps_method, + const char * wps_pin) +{ + NMSupplicantInterfacePrivate *priv; + GVariantBuilder builder; + + g_return_if_fail (NM_IS_SUPPLICANT_INTERFACE (self)); + + priv = NM_SUPPLICANT_INTERFACE_GET_PRIVATE (self); + + /* Don't do anything if there is no connection to the supplicant yet. */ + if (!priv->p2p_proxy || !priv->object_path) + return; + + /* Connect parameters */ + g_variant_builder_init (&builder, G_VARIANT_TYPE_VARDICT); + + g_variant_builder_add (&builder, "{sv}", "wps_method", g_variant_new_string (wps_method)); + + if (wps_pin) + g_variant_builder_add (&builder, "{sv}", "pin", g_variant_new_string (wps_pin)); + + g_variant_builder_add (&builder, "{sv}", "peer", g_variant_new_object_path (peer)); + + g_variant_builder_add (&builder, "{sv}", "join", g_variant_new_boolean (FALSE)); + g_variant_builder_add (&builder, "{sv}", "persistent", g_variant_new_boolean (FALSE)); + g_variant_builder_add (&builder, "{sv}", "go_intent", g_variant_new_int32 (7)); + + g_dbus_proxy_call (priv->p2p_proxy, + "Connect", + g_variant_new ("(a{sv})", &builder), + G_DBUS_CALL_FLAGS_NONE, + -1, + priv->other_cancellable, + (GAsyncReadyCallback) log_result_cb, + "p2p connect"); +} + +void +nm_supplicant_interface_p2p_cancel_connect (NMSupplicantInterface * self) +{ + NMSupplicantInterfacePrivate *priv; + + g_return_if_fail (NM_IS_SUPPLICANT_INTERFACE (self)); + + priv = NM_SUPPLICANT_INTERFACE_GET_PRIVATE (self); + + /* Don't do anything if there is no connection to the supplicant yet. */ + if (!priv->p2p_proxy || !priv->object_path) + return; + + g_dbus_proxy_call (priv->p2p_proxy, + "Cancel", + NULL, + G_DBUS_CALL_FLAGS_NONE, + -1, + priv->other_cancellable, + (GAsyncReadyCallback) log_result_cb, + "cancel p2p connect"); +} + +void +nm_supplicant_interface_p2p_disconnect (NMSupplicantInterface * self) +{ + NMSupplicantInterfacePrivate *priv; + + g_return_if_fail (NM_IS_SUPPLICANT_INTERFACE (self)); + + priv = NM_SUPPLICANT_INTERFACE_GET_PRIVATE (self); + + /* Don't do anything if there is no connection to the supplicant. */ + if (!priv->p2p_proxy || !priv->object_path) + return; + + g_dbus_proxy_call (priv->p2p_proxy, + "Disconnect", + NULL, + G_DBUS_CALL_FLAGS_NONE, + -1, + priv->other_cancellable, + (GAsyncReadyCallback) log_result_cb, + "p2p disconnect"); +} + +/*****************************************************************************/ + static void get_property (GObject *object, guint prop_id, diff --git a/src/supplicant/nm-supplicant-interface.h b/src/supplicant/nm-supplicant-interface.h index d44c002179..b9d1b28393 100644 --- a/src/supplicant/nm-supplicant-interface.h +++ b/src/supplicant/nm-supplicant-interface.h @@ -146,6 +146,13 @@ gboolean nm_supplicant_interface_credentials_reply (NMSupplicantInterface *self, const char *value, GError **error); +void nm_supplicant_interface_p2p_connect (NMSupplicantInterface * self, + const char * peer, + const char * wps_method, + const char * wps_pin); +void nm_supplicant_interface_p2p_cancel_connect (NMSupplicantInterface * self); +void nm_supplicant_interface_p2p_disconnect (NMSupplicantInterface * self); + NMSupplicantFeature nm_supplicant_interface_get_ap_support (NMSupplicantInterface *self); NMSupplicantFeature nm_supplicant_interface_get_pmf_support (NMSupplicantInterface *self); NMSupplicantFeature nm_supplicant_interface_get_fils_support (NMSupplicantInterface *self); -- cgit v1.2.1