Commit 6b74d006 authored by Benjamin Berg's avatar Benjamin Berg Committed by Thomas Haller
Browse files

libnm: Add routines to start/stop a P2P find operation

parent dd0c59c4
......@@ -41,6 +41,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.
......
......@@ -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;
......
......@@ -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
......
......@@ -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
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment