diff options
Diffstat (limited to 'libnm')
-rw-r--r-- | libnm/libnm.ver | 4 | ||||
-rw-r--r-- | libnm/nm-device-wifi-p2p.c | 144 | ||||
-rw-r--r-- | libnm/nm-device-wifi-p2p.h | 21 |
3 files changed, 169 insertions, 0 deletions
diff --git a/libnm/libnm.ver b/libnm/libnm.ver index edef0b6298..ab22017bd2 100644 --- a/libnm/libnm.ver +++ b/libnm/libnm.ver @@ -1454,6 +1454,10 @@ global: nm_device_wifi_p2p_get_hw_address; nm_device_wifi_p2p_get_peers; nm_device_wifi_p2p_get_type; + nm_device_wifi_p2p_start_find; + nm_device_wifi_p2p_start_find_finish; + nm_device_wifi_p2p_stop_find; + nm_device_wifi_p2p_stop_find_finish; nm_setting_wifi_p2p_get_peer; nm_setting_wifi_p2p_get_type; nm_setting_wifi_p2p_get_wps_method; diff --git a/libnm/nm-device-wifi-p2p.c b/libnm/nm-device-wifi-p2p.c index 0c90bd89ab..039a8684cb 100644 --- a/libnm/nm-device-wifi-p2p.c +++ b/libnm/nm-device-wifi-p2p.c @@ -184,6 +184,150 @@ nm_device_wifi_p2p_get_peer_by_path (NMDeviceWifiP2P *device, } static void +start_find_finished_cb (GObject *obj, + GAsyncResult *res, + gpointer user_data) +{ + NMDBusDeviceWifiP2P *proxy = (NMDBusDeviceWifiP2P*) obj; + gs_unref_object GTask *task = G_TASK (user_data); + GError *error = NULL; + gboolean success; + + success = nmdbus_device_wifi_p2p_call_start_find_finish (proxy, res, &error); + if (!success) + g_task_return_error (task, error); + else + g_task_return_boolean (task, TRUE); +} + +/** + * nm_device_wifi_p2p_start_find: + * @device: a #NMDeviceWifiP2P + * @options: (allow-none): optional options passed to StartFind. + * @cancellable: a #GCancellable, or %NULL + * @callback: a #GAsyncReadyCallback, or %NULL + * @user_data: user_data for @callback + * + * Request NM to search for Wi-Fi P2P peers on @device. Note that the call + * 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(). + * + * Since: 1.16 + **/ +void +nm_device_wifi_p2p_start_find (NMDeviceWifiP2P *device, + GVariant *options, + GCancellable *cancellable, + GAsyncReadyCallback callback, + gpointer user_data) +{ + NMDeviceWifiP2PPrivate *priv = NM_DEVICE_WIFI_P2P_GET_PRIVATE (device); + GTask *task; + + g_return_if_fail (NM_IS_DEVICE_WIFI_P2P (device)); + + task = g_task_new (device, cancellable, callback, user_data); + + if (!options) + options = g_variant_new_array (G_VARIANT_TYPE ("{sv}"), NULL, 0); + nmdbus_device_wifi_p2p_call_start_find (priv->proxy, + options, + cancellable, + start_find_finished_cb, + task); +} + +/** + * nm_device_wifi_p2p_start_find_finish: + * @device: a #NMDeviceWifiP2P + * @result: the #GAsyncResult + * @error: #GError return address + * + * Finish an operation started by nm_device_wifi_p2p_start_find(). + * + * Returns: %TRUE if the call was successful + * + * Since: 1.16 + **/ +gboolean +nm_device_wifi_p2p_start_find_finish (NMDeviceWifiP2P *device, + GAsyncResult *result, + GError **error) +{ + return g_task_propagate_boolean (G_TASK (result), error); +} + +static void +stop_find_finished_cb (GObject *obj, + GAsyncResult *res, + gpointer user_data) +{ + NMDBusDeviceWifiP2P *proxy = (NMDBusDeviceWifiP2P*) obj; + gs_unref_object GTask *task = G_TASK (user_data); + GError *error = NULL; + gboolean success; + + success = nmdbus_device_wifi_p2p_call_stop_find_finish (proxy, res, &error); + if (!success) + g_task_return_error (task, error); + else + g_task_return_boolean (task, TRUE); +} + +/** + * nm_device_wifi_p2p_stop_find: + * @device: a #NMDeviceWifiP2P + * @cancellable: a #GCancellable, or %NULL + * @callback: a #GAsyncReadyCallback, or %NULL + * @user_data: user_data for @callback + * + * Request NM to stop any ongoing find operation for Wi-Fi P2P peers on @device. + * + * Since: 1.16 + **/ +void +nm_device_wifi_p2p_stop_find (NMDeviceWifiP2P *device, + GCancellable *cancellable, + GAsyncReadyCallback callback, + gpointer user_data) +{ + NMDeviceWifiP2PPrivate *priv = NM_DEVICE_WIFI_P2P_GET_PRIVATE (device); + GTask *task; + + g_return_if_fail (NM_IS_DEVICE_WIFI_P2P (device)); + + task = g_task_new (device, cancellable, callback, user_data); + + nmdbus_device_wifi_p2p_call_stop_find (priv->proxy, + cancellable, + stop_find_finished_cb, + task); +} + +/** + * nm_device_wifi_p2p_stop_find_finish: + * @device: a #NMDeviceWifiP2P + * @result: the #GAsyncResult + * @error: #GError return address + * + * Finish an operation started by nm_device_wifi_p2p_stop_find(). + * + * Returns: %TRUE if the call was successful + * + * Since: 1.16 + **/ +gboolean +nm_device_wifi_p2p_stop_find_finish (NMDeviceWifiP2P *device, + GAsyncResult *result, + GError **error) +{ + return g_task_propagate_boolean (G_TASK (result), error); +} + +static void clean_up_peers (NMDeviceWifiP2P *self) { NMDeviceWifiP2PPrivate *priv = NM_DEVICE_WIFI_P2P_GET_PRIVATE (self); diff --git a/libnm/nm-device-wifi-p2p.h b/libnm/nm-device-wifi-p2p.h index 4ff4d03842..a4e22562cd 100644 --- a/libnm/nm-device-wifi-p2p.h +++ b/libnm/nm-device-wifi-p2p.h @@ -58,6 +58,27 @@ NMWifiP2PPeer * nm_device_wifi_p2p_get_peer_by_path (NMDeviceWifiP2P *d NM_AVAILABLE_IN_1_16 const GPtrArray * nm_device_wifi_p2p_get_peers (NMDeviceWifiP2P *device); +NM_AVAILABLE_IN_1_16 +void nm_device_wifi_p2p_start_find (NMDeviceWifiP2P *device, + GVariant *options, + GCancellable *cancellable, + GAsyncReadyCallback callback, + gpointer user_data); +NM_AVAILABLE_IN_1_16 +gboolean nm_device_wifi_p2p_start_find_finish (NMDeviceWifiP2P *device, + GAsyncResult *result, + GError **error); + +NM_AVAILABLE_IN_1_16 +void nm_device_wifi_p2p_stop_find (NMDeviceWifiP2P *device, + GCancellable *cancellable, + GAsyncReadyCallback callback, + gpointer user_data); +NM_AVAILABLE_IN_1_16 +gboolean nm_device_wifi_p2p_stop_find_finish (NMDeviceWifiP2P *device, + GAsyncResult *result, + GError **error); + G_END_DECLS #endif /* __NM_DEVICE_WIFI_P2P_H__ */ |