summaryrefslogtreecommitdiff
path: root/src/supplicant
diff options
context:
space:
mode:
authorBenjamin Berg <bberg@redhat.com>2018-10-10 23:14:08 +0200
committerThomas Haller <thaller@redhat.com>2018-12-13 09:20:55 +0100
commitc05aa3b309835b4789ffbe502be82c087a3e4ef9 (patch)
tree3c52f8f2d9595702c41283a7c91e7e3f8bd70d3f /src/supplicant
parent6352213e160e764da766f471f2f21097614b925a (diff)
supplicant: Add API to join/cancel/disconnect a P2P Group
Diffstat (limited to 'src/supplicant')
-rw-r--r--src/supplicant/nm-supplicant-interface.c89
-rw-r--r--src/supplicant/nm-supplicant-interface.h7
2 files changed, 96 insertions, 0 deletions
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);