diff options
author | Benjamin Berg <bberg@redhat.com> | 2018-10-18 11:14:09 +0200 |
---|---|---|
committer | Thomas Haller <thaller@redhat.com> | 2019-01-27 23:45:12 +0100 |
commit | 6b74d006e6b7d11eadaeb072378fd0b181f649f8 (patch) | |
tree | 86b5745de4a674591105e27ade19e802823cb4bc | |
parent | dd0c59c468fb8bf8b728dec1592be1589e9a04eb (diff) | |
download | NetworkManager-6b74d006e6b7d11eadaeb072378fd0b181f649f8.tar.gz |
libnm: Add routines to start/stop a P2P find operation
-rw-r--r-- | introspection/org.freedesktop.NetworkManager.Device.P2PWireless.xml | 20 | ||||
-rw-r--r-- | libnm/libnm.ver | 2 | ||||
-rw-r--r-- | libnm/nm-device-p2p-wifi.c | 70 | ||||
-rw-r--r-- | libnm/nm-device-p2p-wifi.h | 6 |
4 files changed, 98 insertions, 0 deletions
diff --git a/introspection/org.freedesktop.NetworkManager.Device.P2PWireless.xml b/introspection/org.freedesktop.NetworkManager.Device.P2PWireless.xml index fa85b83f9d..6f7bdeaeb6 100644 --- a/introspection/org.freedesktop.NetworkManager.Device.P2PWireless.xml +++ b/introspection/org.freedesktop.NetworkManager.Device.P2PWireless.xml @@ -42,6 +42,26 @@ <property name="Peers" type="ao" access="read"/> <!-- + StartFind: + @options: Options of find. Currently 'timeout' option with value of "i" + in the range of 1-600 seconds is supported. The default is + 30 seconds. + + Start a find operation for P2P peers. + --> + <method name="StartFind"> + <arg name="options" type="a{sv}" direction="in"/> + </method> + + <!-- + StopFind: + + Stop an ongoing find operation again. + --> + <method name="StopFind"> + </method> + + <!-- PeerAdded: @peer: The object path of the newly found access point. diff --git a/libnm/libnm.ver b/libnm/libnm.ver index e2ff5f37fe..9bbcabda86 100644 --- a/libnm/libnm.ver +++ b/libnm/libnm.ver @@ -1454,6 +1454,8 @@ global: nm_device_p2p_wifi_get_hw_address; nm_device_p2p_wifi_get_peers; nm_device_p2p_wifi_get_type; + nm_device_p2p_wifi_start_find; + nm_device_p2p_wifi_stop_find; nm_p2p_peer_connection_valid; nm_p2p_peer_filter_connections; nm_p2p_peer_get_flags; diff --git a/libnm/nm-device-p2p-wifi.c b/libnm/nm-device-p2p-wifi.c index d4f54335eb..4d740fafec 100644 --- a/libnm/nm-device-p2p-wifi.c +++ b/libnm/nm-device-p2p-wifi.c @@ -237,6 +237,76 @@ nm_device_p2p_wifi_get_wfdies_as_variant (const NMDeviceP2PWifi *self) return g_variant_new_array (G_VARIANT_TYPE_BYTE, NULL, 0); } +/** + * nm_device_p2p_wifi_start_find: + * @device: a #NMDeviceP2PWifi + * @cancellable: a #GCancellable, or %NULL + * @error: location for a #GError, or %NULL + * + * Request NM to search for P2P peers on @device. Note that the function + * returns immediately after requesting the find, and it may take some time + * after that for peers to be found. + * + * The find operation will run for 30s by default. You can stop it earlier + * using nm_device_p2p_wifi_stop_find(). + * + * Returns: %TRUE on success, %FALSE on error, in which case @error will be + * set. + * + * Since: 1.16 + **/ +gboolean +nm_device_p2p_wifi_start_find (NMDeviceP2PWifi *device, + GCancellable *cancellable, + GError **error) +{ + NMDeviceP2PWifiPrivate *priv = NM_DEVICE_P2P_WIFI_GET_PRIVATE (device); + GVariant *options = g_variant_new_array (G_VARIANT_TYPE ("{sv}"), NULL, 0); + gboolean ret; + + g_return_val_if_fail (NM_IS_DEVICE_P2P_WIFI (device), FALSE); + + ret = nmdbus_device_p2p_wifi_call_start_find_sync (priv->proxy, + options, + cancellable, error); + + if (error && *error) + g_dbus_error_strip_remote_error (*error); + + return ret; +} + +/** + * nm_device_p2p_wifi_stop_find: + * @device: a #NMDeviceP2PWifi + * @cancellable: a #GCancellable, or %NULL + * @error: location for a #GError, or %NULL + * + * Request NM to stop searching for P2P peers on @device. + * + * Returns: %TRUE on success, %FALSE on error, in which case @error will be + * set. + * + * Since: 1.16 + **/ +gboolean +nm_device_p2p_wifi_stop_find (NMDeviceP2PWifi *device, + GCancellable *cancellable, + GError **error) +{ + NMDeviceP2PWifiPrivate *priv = NM_DEVICE_P2P_WIFI_GET_PRIVATE (device); + gboolean ret; + + g_return_val_if_fail (NM_IS_DEVICE_P2P_WIFI (device), FALSE); + + ret = nmdbus_device_p2p_wifi_call_stop_find_sync (priv->proxy, + cancellable, error); + if (error && *error) + g_dbus_error_strip_remote_error (*error); + + return ret; +} + /*****************************************************************************/ static void diff --git a/libnm/nm-device-p2p-wifi.h b/libnm/nm-device-p2p-wifi.h index 74779f2097..90a7242489 100644 --- a/libnm/nm-device-p2p-wifi.h +++ b/libnm/nm-device-p2p-wifi.h @@ -73,6 +73,12 @@ NMP2PPeer * nm_device_p2p_wifi_get_peer_by_path (NMDeviceP2PWifi *d const GPtrArray * nm_device_p2p_wifi_get_peers (NMDeviceP2PWifi *device); +gboolean nm_device_p2p_wifi_start_find (NMDeviceP2PWifi *device, + GCancellable *cancellable, + GError **error); +gboolean nm_device_p2p_wifi_stop_find (NMDeviceP2PWifi *device, + GCancellable *cancellable, + GError **error); G_END_DECLS |