mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2026-01-04 16:50:17 +01:00
libnm: add some missing sync/async method variants
Add the missing variant in most places in the API where previously there was either only a synchronous version or only an asynchronous version. There is not yet a synchronous nm_client_activate_connection(), nm_client_add_and_activate_connection(), or nm_remote_settings_add_connection(), because the existing async code depends on waiting for other asynchronous events, so making them run synchronously is slightly more complicated. But these APIs can be added later.
This commit is contained in:
parent
2237ea3ddb
commit
41eca3ea49
11 changed files with 569 additions and 12 deletions
|
|
@ -41,6 +41,8 @@ global:
|
|||
nm_client_check_connectivity_async;
|
||||
nm_client_check_connectivity_finish;
|
||||
nm_client_deactivate_connection;
|
||||
nm_client_deactivate_connection_async;
|
||||
nm_client_deactivate_connection_finish;
|
||||
nm_client_error_get_type;
|
||||
nm_client_error_quark;
|
||||
nm_client_get_activating_connection;
|
||||
|
|
@ -157,9 +159,11 @@ global:
|
|||
nm_device_capabilities_get_type;
|
||||
nm_device_connection_compatible;
|
||||
nm_device_connection_valid;
|
||||
nm_device_delete;
|
||||
nm_device_delete_async;
|
||||
nm_device_delete_finish;
|
||||
nm_device_disambiguate_names;
|
||||
nm_device_disconnect;
|
||||
nm_device_disconnect_async;
|
||||
nm_device_disconnect_finish;
|
||||
nm_device_error_get_type;
|
||||
|
|
@ -250,6 +254,7 @@ global:
|
|||
nm_device_wifi_get_mode;
|
||||
nm_device_wifi_get_permanent_hw_address;
|
||||
nm_device_wifi_get_type;
|
||||
nm_device_wifi_request_scan;
|
||||
nm_device_wifi_request_scan_async;
|
||||
nm_device_wifi_request_scan_finish;
|
||||
nm_device_wimax_error_get_type;
|
||||
|
|
@ -341,17 +346,21 @@ global:
|
|||
nm_object_error_quark;
|
||||
nm_object_get_path;
|
||||
nm_object_get_type;
|
||||
nm_remote_connection_commit_changes;
|
||||
nm_remote_connection_commit_changes_async;
|
||||
nm_remote_connection_commit_changes_finish;
|
||||
nm_remote_connection_delete;
|
||||
nm_remote_connection_delete_async;
|
||||
nm_remote_connection_delete_finish;
|
||||
nm_remote_connection_error_get_type;
|
||||
nm_remote_connection_error_quark;
|
||||
nm_remote_connection_get_secrets;
|
||||
nm_remote_connection_get_secrets_async;
|
||||
nm_remote_connection_get_secrets_finish;
|
||||
nm_remote_connection_get_type;
|
||||
nm_remote_connection_get_unsaved;
|
||||
nm_remote_connection_get_visible;
|
||||
nm_remote_connection_save;
|
||||
nm_remote_connection_save_async;
|
||||
nm_remote_connection_save_finish;
|
||||
nm_remote_settings_add_connection_async;
|
||||
|
|
@ -364,10 +373,15 @@ global:
|
|||
nm_remote_settings_get_type;
|
||||
nm_remote_settings_list_connections;
|
||||
nm_remote_settings_load_connections;
|
||||
nm_remote_settings_load_connections_async;
|
||||
nm_remote_settings_load_connections_finish;
|
||||
nm_remote_settings_new;
|
||||
nm_remote_settings_new_async;
|
||||
nm_remote_settings_new_finish;
|
||||
nm_remote_settings_reload_connections;
|
||||
nm_remote_settings_reload_connections_async;
|
||||
nm_remote_settings_reload_connections_finish;
|
||||
nm_remote_settings_save_hostname;
|
||||
nm_remote_settings_save_hostname_async;
|
||||
nm_remote_settings_save_hostname_finish;
|
||||
nm_secret_agent_capabilities_get_type;
|
||||
|
|
|
|||
|
|
@ -874,6 +874,91 @@ nm_client_deactivate_connection (NMClient *client,
|
|||
cancellable, error);
|
||||
}
|
||||
|
||||
static void
|
||||
deactivated_cb (GObject *object,
|
||||
GAsyncResult *result,
|
||||
gpointer user_data)
|
||||
{
|
||||
GSimpleAsyncResult *simple = user_data;
|
||||
GError *error = NULL;
|
||||
|
||||
if (nmdbus_manager_call_deactivate_connection_finish (NMDBUS_MANAGER (object),
|
||||
result, &error))
|
||||
g_simple_async_result_set_op_res_gboolean (simple, TRUE);
|
||||
else
|
||||
g_simple_async_result_take_error (simple, error);
|
||||
g_simple_async_result_complete (simple);
|
||||
g_object_unref (simple);
|
||||
}
|
||||
|
||||
/**
|
||||
* nm_client_deactivate_connection_async:
|
||||
* @client: a #NMClient
|
||||
* @active: the #NMActiveConnection to deactivate
|
||||
* @cancellable: a #GCancellable, or %NULL
|
||||
* @callback: callback to be called when the deactivation has completed
|
||||
* @user_data: caller-specific data passed to @callback
|
||||
*
|
||||
* Asynchronously deactivates an active #NMActiveConnection.
|
||||
**/
|
||||
void
|
||||
nm_client_deactivate_connection_async (NMClient *client,
|
||||
NMActiveConnection *active,
|
||||
GCancellable *cancellable,
|
||||
GAsyncReadyCallback callback,
|
||||
gpointer user_data)
|
||||
{
|
||||
NMClientPrivate *priv;
|
||||
const char *path;
|
||||
GSimpleAsyncResult *simple;
|
||||
|
||||
g_return_if_fail (NM_IS_CLIENT (client));
|
||||
g_return_if_fail (NM_IS_ACTIVE_CONNECTION (active));
|
||||
|
||||
simple = g_simple_async_result_new (G_OBJECT (client), callback, user_data,
|
||||
nm_client_deactivate_connection_async);
|
||||
|
||||
priv = NM_CLIENT_GET_PRIVATE (client);
|
||||
if (!nm_client_get_nm_running (client)) {
|
||||
g_simple_async_result_set_op_res_gboolean (simple, TRUE);
|
||||
g_simple_async_result_complete_in_idle (simple);
|
||||
g_object_unref (simple);
|
||||
return;
|
||||
}
|
||||
|
||||
path = nm_object_get_path (NM_OBJECT (active));
|
||||
nmdbus_manager_call_deactivate_connection (priv->manager_proxy,
|
||||
path,
|
||||
cancellable,
|
||||
deactivated_cb, simple);
|
||||
}
|
||||
|
||||
/**
|
||||
* nm_client_deactivate_connection_finish:
|
||||
* @client: a #NMClient
|
||||
* @result: the result passed to the #GAsyncReadyCallback
|
||||
* @error: location for a #GError, or %NULL
|
||||
*
|
||||
* Gets the result of a call to nm_client_deactivate_connection_async().
|
||||
*
|
||||
* Returns: success or failure
|
||||
**/
|
||||
gboolean
|
||||
nm_client_deactivate_connection_finish (NMClient *client,
|
||||
GAsyncResult *result,
|
||||
GError **error)
|
||||
{
|
||||
GSimpleAsyncResult *simple;
|
||||
|
||||
g_return_val_if_fail (g_simple_async_result_is_valid (result, G_OBJECT (client), nm_client_deactivate_connection_async), FALSE);
|
||||
|
||||
simple = G_SIMPLE_ASYNC_RESULT (result);
|
||||
if (g_simple_async_result_propagate_error (simple, error))
|
||||
return FALSE;
|
||||
else
|
||||
return g_simple_async_result_get_op_res_gboolean (simple);
|
||||
}
|
||||
|
||||
/**
|
||||
* nm_client_get_active_connections:
|
||||
* @client: a #NMClient
|
||||
|
|
|
|||
|
|
@ -198,10 +198,18 @@ NMActiveConnection *nm_client_add_and_activate_connection_finish (NMClient *clie
|
|||
GAsyncResult *result,
|
||||
GError **error);
|
||||
|
||||
gboolean nm_client_deactivate_connection (NMClient *client,
|
||||
NMActiveConnection *active,
|
||||
GCancellable *cancellable,
|
||||
GError **error);
|
||||
gboolean nm_client_deactivate_connection (NMClient *client,
|
||||
NMActiveConnection *active,
|
||||
GCancellable *cancellable,
|
||||
GError **error);
|
||||
void nm_client_deactivate_connection_async (NMClient *client,
|
||||
NMActiveConnection *active,
|
||||
GCancellable *cancellable,
|
||||
GAsyncReadyCallback callback,
|
||||
gpointer user_data);
|
||||
gboolean nm_client_deactivate_connection_finish (NMClient *client,
|
||||
GAsyncResult *result,
|
||||
GError **error);
|
||||
|
||||
gboolean nm_client_networking_get_enabled (NMClient *client);
|
||||
void nm_client_networking_set_enabled (NMClient *client, gboolean enabled);
|
||||
|
|
|
|||
|
|
@ -285,6 +285,32 @@ nm_device_wifi_get_access_point_by_path (NMDeviceWifi *device,
|
|||
return ap;
|
||||
}
|
||||
|
||||
/**
|
||||
* nm_device_wifi_request_scan:
|
||||
* @device: a #NMDeviceWifi
|
||||
* @cancellable: a #GCancellable, or %NULL
|
||||
* @error: location for a #GError, or %NULL
|
||||
*
|
||||
* Request NM to scan for access points on @device. Note that the function
|
||||
* returns immediately after requesting the scan, and it may take some time
|
||||
* after that for the scan to complete.
|
||||
*
|
||||
* Returns: %TRUE on success, %FALSE on error, in which case @error will be
|
||||
* set.
|
||||
**/
|
||||
gboolean
|
||||
nm_device_wifi_request_scan (NMDeviceWifi *device,
|
||||
GCancellable *cancellable,
|
||||
GError **error)
|
||||
{
|
||||
g_return_val_if_fail (NM_IS_DEVICE_WIFI (device), FALSE);
|
||||
|
||||
return nmdbus_device_wifi_call_request_scan_sync (NM_DEVICE_WIFI_GET_PRIVATE (device)->proxy,
|
||||
g_variant_new_array (G_VARIANT_TYPE_VARDICT,
|
||||
NULL, 0),
|
||||
cancellable, error);
|
||||
}
|
||||
|
||||
static void
|
||||
request_scan_cb (GObject *source,
|
||||
GAsyncResult *result,
|
||||
|
|
|
|||
|
|
@ -100,6 +100,10 @@ NMAccessPoint * nm_device_wifi_get_access_point_by_path (NMDeviceWifi *
|
|||
|
||||
const GPtrArray * nm_device_wifi_get_access_points (NMDeviceWifi *device);
|
||||
|
||||
gboolean nm_device_wifi_request_scan (NMDeviceWifi *device,
|
||||
GCancellable *cancellable,
|
||||
GError **error);
|
||||
|
||||
void nm_device_wifi_request_scan_async (NMDeviceWifi *device,
|
||||
GCancellable *cancellable,
|
||||
GAsyncReadyCallback callback,
|
||||
|
|
|
|||
|
|
@ -1892,6 +1892,29 @@ nm_device_is_software (NMDevice *device)
|
|||
return !!(NM_DEVICE_GET_PRIVATE (device)->capabilities & NM_DEVICE_CAP_IS_SOFTWARE);
|
||||
}
|
||||
|
||||
/**
|
||||
* nm_device_disconnect:
|
||||
* @device: a #NMDevice
|
||||
* @cancellable: a #GCancellable, or %NULL
|
||||
* @error: location for a #GError, or %NULL
|
||||
*
|
||||
* Disconnects the device if currently connected, and prevents the device from
|
||||
* automatically connecting to networks until the next manual network connection
|
||||
* request.
|
||||
*
|
||||
* Returns: %TRUE on success, %FALSE on error, in which case @error will be set.
|
||||
**/
|
||||
gboolean
|
||||
nm_device_disconnect (NMDevice *device,
|
||||
GCancellable *cancellable,
|
||||
GError **error)
|
||||
{
|
||||
g_return_val_if_fail (NM_IS_DEVICE (device), FALSE);
|
||||
|
||||
return nmdbus_device_call_disconnect_sync (NM_DEVICE_GET_PRIVATE (device)->proxy,
|
||||
cancellable, error);
|
||||
}
|
||||
|
||||
static void
|
||||
device_disconnect_cb (GObject *proxy,
|
||||
GAsyncResult *result,
|
||||
|
|
@ -1965,6 +1988,28 @@ nm_device_disconnect_finish (NMDevice *device,
|
|||
return g_simple_async_result_get_op_res_gboolean (simple);
|
||||
}
|
||||
|
||||
/**
|
||||
* nm_device_delete:
|
||||
* @device: a #NMDevice
|
||||
* @cancellable: a #GCancellable, or %NULL
|
||||
* @error: location for a #GError, or %NULL
|
||||
*
|
||||
* Deletes the software device. Hardware devices can't be deleted.
|
||||
*
|
||||
* Returns: %TRUE on success, %FALSE on error, in which case @error
|
||||
* will be set.
|
||||
**/
|
||||
gboolean
|
||||
nm_device_delete (NMDevice *device,
|
||||
GCancellable *cancellable,
|
||||
GError **error)
|
||||
{
|
||||
g_return_val_if_fail (NM_IS_DEVICE (device), FALSE);
|
||||
|
||||
return nmdbus_device_call_delete_sync (NM_DEVICE_GET_PRIVATE (device)->proxy,
|
||||
cancellable, error);
|
||||
}
|
||||
|
||||
static void
|
||||
device_delete_cb (GObject *proxy,
|
||||
GAsyncResult *result,
|
||||
|
|
|
|||
|
|
@ -145,6 +145,9 @@ const char * nm_device_get_description (NMDevice *device);
|
|||
char ** nm_device_disambiguate_names (NMDevice **devices,
|
||||
int num_devices);
|
||||
|
||||
gboolean nm_device_disconnect (NMDevice *device,
|
||||
GCancellable *cancellable,
|
||||
GError **error);
|
||||
void nm_device_disconnect_async (NMDevice *device,
|
||||
GCancellable *cancellable,
|
||||
GAsyncReadyCallback callback,
|
||||
|
|
@ -153,6 +156,9 @@ gboolean nm_device_disconnect_finish (NMDevice *device,
|
|||
GAsyncResult *result,
|
||||
GError **error);
|
||||
|
||||
gboolean nm_device_delete (NMDevice *device,
|
||||
GCancellable *cancellable,
|
||||
GError **error);
|
||||
void nm_device_delete_async (NMDevice *device,
|
||||
GCancellable *cancellable,
|
||||
GAsyncReadyCallback callback,
|
||||
|
|
|
|||
|
|
@ -83,6 +83,44 @@ nm_remote_connection_error_quark (void)
|
|||
|
||||
/****************************************************************/
|
||||
|
||||
/**
|
||||
* nm_remote_connection_commit_changes:
|
||||
* @connection: the #NMRemoteConnection
|
||||
* @save_to_disk: whether to persist the changes to disk
|
||||
* @cancellable: a #GCancellable, or %NULL
|
||||
* @error: location for a #GError, or %NULL
|
||||
*
|
||||
* Send any local changes to the settings and properties of @connection to
|
||||
* NetworkManager. If @save_to_disk is %TRUE, the updated connection will be saved to
|
||||
* disk; if %FALSE, then only the in-memory representation will be changed.
|
||||
*
|
||||
* Returns: %TRUE on success, %FALSE on error, in which case @error will be set.
|
||||
**/
|
||||
gboolean
|
||||
nm_remote_connection_commit_changes (NMRemoteConnection *connection,
|
||||
gboolean save_to_disk,
|
||||
GCancellable *cancellable,
|
||||
GError **error)
|
||||
{
|
||||
NMRemoteConnectionPrivate *priv;
|
||||
GVariant *settings;
|
||||
|
||||
g_return_val_if_fail (NM_IS_REMOTE_CONNECTION (connection), FALSE);
|
||||
|
||||
priv = NM_REMOTE_CONNECTION_GET_PRIVATE (connection);
|
||||
|
||||
settings = nm_connection_to_dbus (NM_CONNECTION (connection), NM_CONNECTION_SERIALIZE_ALL);
|
||||
if (save_to_disk) {
|
||||
return nmdbus_settings_connection_call_update_sync (priv->proxy,
|
||||
settings,
|
||||
cancellable, error);
|
||||
} else {
|
||||
return nmdbus_settings_connection_call_update_unsaved_sync (priv->proxy,
|
||||
settings,
|
||||
cancellable, error);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
update_cb (GObject *proxy, GAsyncResult *result, gpointer user_data)
|
||||
{
|
||||
|
|
@ -174,6 +212,31 @@ nm_remote_connection_commit_changes_finish (NMRemoteConnection *connection,
|
|||
return g_simple_async_result_get_op_res_gboolean (simple);
|
||||
}
|
||||
|
||||
/**
|
||||
* nm_remote_connection_save:
|
||||
* @connection: the #NMRemoteConnection
|
||||
* @cancellable: a #GCancellable, or %NULL
|
||||
* @error: location for a #GError, or %NULL
|
||||
*
|
||||
* Saves the connection to disk if the connection has changes that have not yet
|
||||
* been written to disk, or if the connection has never been saved.
|
||||
*
|
||||
* Returns: %TRUE on success, %FALSE on error, in which case @error will be set.
|
||||
**/
|
||||
gboolean
|
||||
nm_remote_connection_save (NMRemoteConnection *connection,
|
||||
GCancellable *cancellable,
|
||||
GError **error)
|
||||
{
|
||||
NMRemoteConnectionPrivate *priv;
|
||||
|
||||
g_return_val_if_fail (NM_IS_REMOTE_CONNECTION (connection), FALSE);
|
||||
|
||||
priv = NM_REMOTE_CONNECTION_GET_PRIVATE (connection);
|
||||
|
||||
return nmdbus_settings_connection_call_save_sync (priv->proxy, cancellable, error);
|
||||
}
|
||||
|
||||
static void
|
||||
save_cb (GObject *proxy, GAsyncResult *result, gpointer user_data)
|
||||
{
|
||||
|
|
@ -243,6 +306,30 @@ nm_remote_connection_save_finish (NMRemoteConnection *connection,
|
|||
return g_simple_async_result_get_op_res_gboolean (simple);
|
||||
}
|
||||
|
||||
/**
|
||||
* nm_remote_connection_delete:
|
||||
* @connection: the #NMRemoteConnection
|
||||
* @cancellable: a #GCancellable, or %NULL
|
||||
* @error: location for a #GError, or %NULL
|
||||
*
|
||||
* Deletes the connection.
|
||||
*
|
||||
* Returns: %TRUE on success, %FALSE on error, in which case @error will be set.
|
||||
**/
|
||||
gboolean
|
||||
nm_remote_connection_delete (NMRemoteConnection *connection,
|
||||
GCancellable *cancellable,
|
||||
GError **error)
|
||||
{
|
||||
NMRemoteConnectionPrivate *priv;
|
||||
|
||||
g_return_if_fail (NM_IS_REMOTE_CONNECTION (connection));
|
||||
|
||||
priv = NM_REMOTE_CONNECTION_GET_PRIVATE (connection);
|
||||
|
||||
return nmdbus_settings_connection_call_delete_sync (priv->proxy, cancellable, error);
|
||||
}
|
||||
|
||||
static void
|
||||
delete_cb (GObject *proxy, GAsyncResult *result, gpointer user_data)
|
||||
{
|
||||
|
|
@ -311,6 +398,41 @@ nm_remote_connection_delete_finish (NMRemoteConnection *connection,
|
|||
return g_simple_async_result_get_op_res_gboolean (simple);
|
||||
}
|
||||
|
||||
/**
|
||||
* nm_remote_connection_get_secrets:
|
||||
* @connection: the #NMRemoteConnection
|
||||
* @setting_name: the #NMSetting object name to get secrets for
|
||||
* @cancellable: a #GCancellable, or %NULL
|
||||
* @error: location for a #GError, or %NULL
|
||||
*
|
||||
* Request the connection's secrets. Note that this is a blocking D-Bus call,
|
||||
* not a simple property accessor.
|
||||
*
|
||||
* Returns: a #GVariant of type %NM_VARIANT_TYPE_CONNECTION containing
|
||||
* @connection's secrets, or %NULL on error.
|
||||
**/
|
||||
GVariant *
|
||||
nm_remote_connection_get_secrets (NMRemoteConnection *connection,
|
||||
const char *setting_name,
|
||||
GCancellable *cancellable,
|
||||
GError **error)
|
||||
{
|
||||
NMRemoteConnectionPrivate *priv;
|
||||
GVariant *secrets;
|
||||
|
||||
g_return_val_if_fail (NM_IS_REMOTE_CONNECTION (connection), NULL);
|
||||
|
||||
priv = NM_REMOTE_CONNECTION_GET_PRIVATE (connection);
|
||||
|
||||
if (nmdbus_settings_connection_call_get_secrets_sync (priv->proxy,
|
||||
setting_name,
|
||||
&secrets,
|
||||
cancellable, error))
|
||||
return secrets;
|
||||
else
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static void
|
||||
get_secrets_cb (GObject *proxy, GAsyncResult *result, gpointer user_data)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -71,6 +71,10 @@ typedef struct {
|
|||
|
||||
GType nm_remote_connection_get_type (void);
|
||||
|
||||
gboolean nm_remote_connection_commit_changes (NMRemoteConnection *connection,
|
||||
gboolean save_to_disk,
|
||||
GCancellable *cancellable,
|
||||
GError **error);
|
||||
void nm_remote_connection_commit_changes_async (NMRemoteConnection *connection,
|
||||
gboolean save_to_disk,
|
||||
GCancellable *cancellable,
|
||||
|
|
@ -80,6 +84,9 @@ gboolean nm_remote_connection_commit_changes_finish (NMRemoteConnection *connect
|
|||
GAsyncResult *result,
|
||||
GError **error);
|
||||
|
||||
gboolean nm_remote_connection_save (NMRemoteConnection *connection,
|
||||
GCancellable *cancellable,
|
||||
GError **error);
|
||||
void nm_remote_connection_save_async (NMRemoteConnection *connection,
|
||||
GCancellable *cancellable,
|
||||
GAsyncReadyCallback callback,
|
||||
|
|
@ -88,6 +95,9 @@ gboolean nm_remote_connection_save_finish (NMRemoteConnection *connection,
|
|||
GAsyncResult *result,
|
||||
GError **error);
|
||||
|
||||
gboolean nm_remote_connection_delete (NMRemoteConnection *connection,
|
||||
GCancellable *cancellable,
|
||||
GError **error);
|
||||
void nm_remote_connection_delete_async (NMRemoteConnection *connection,
|
||||
GCancellable *cancellable,
|
||||
GAsyncReadyCallback callback,
|
||||
|
|
@ -96,6 +106,10 @@ gboolean nm_remote_connection_delete_finish (NMRemoteConnection *connection,
|
|||
GAsyncResult *result,
|
||||
GError **error);
|
||||
|
||||
GVariant *nm_remote_connection_get_secrets (NMRemoteConnection *connection,
|
||||
const char *setting_name,
|
||||
GCancellable *cancellable,
|
||||
GError **error);
|
||||
void nm_remote_connection_get_secrets_async (NMRemoteConnection *connection,
|
||||
const char *setting_name,
|
||||
GCancellable *cancellable,
|
||||
|
|
|
|||
|
|
@ -620,6 +620,103 @@ nm_remote_settings_load_connections (NMRemoteSettings *settings,
|
|||
return success;
|
||||
}
|
||||
|
||||
static void
|
||||
load_connections_cb (GObject *proxy, GAsyncResult *result, gpointer user_data)
|
||||
{
|
||||
GSimpleAsyncResult *simple = user_data;
|
||||
GError *error = NULL;
|
||||
gboolean success;
|
||||
char **failures = NULL;
|
||||
|
||||
if (nmdbus_settings_call_load_connections_finish (NMDBUS_SETTINGS (proxy),
|
||||
&success, &failures,
|
||||
result, &error))
|
||||
g_simple_async_result_set_op_res_gpointer (simple, failures, (GDestroyNotify) g_strfreev);
|
||||
else
|
||||
g_simple_async_result_take_error (simple, error);
|
||||
|
||||
g_simple_async_result_complete (simple);
|
||||
g_object_unref (simple);
|
||||
}
|
||||
|
||||
/**
|
||||
* nm_remote_settings_load_connections_async:
|
||||
* @settings: the %NMRemoteSettings
|
||||
* @filenames: %NULL-terminated array of filenames to load
|
||||
* @cancellable: a #GCancellable, or %NULL
|
||||
* @callback: (scope async): callback to be called when the operation completes
|
||||
* @user_data: (closure): caller-specific data passed to @callback
|
||||
*
|
||||
* Requests that the remote settings service asynchronously load or reload the
|
||||
* given files, adding or updating the connections described within.
|
||||
*
|
||||
* See nm_remote_settings_load_connections() for more details.
|
||||
**/
|
||||
void
|
||||
nm_remote_settings_load_connections_async (NMRemoteSettings *settings,
|
||||
char **filenames,
|
||||
GCancellable *cancellable,
|
||||
GAsyncReadyCallback callback,
|
||||
gpointer user_data)
|
||||
{
|
||||
NMRemoteSettingsPrivate *priv;
|
||||
GSimpleAsyncResult *simple;
|
||||
GError *error = NULL;
|
||||
|
||||
g_return_val_if_fail (NM_IS_REMOTE_SETTINGS (settings), FALSE);
|
||||
g_return_val_if_fail (filenames != NULL, FALSE);
|
||||
|
||||
priv = NM_REMOTE_SETTINGS_GET_PRIVATE (settings);
|
||||
|
||||
simple = g_simple_async_result_new (G_OBJECT (settings), callback, user_data,
|
||||
nm_remote_settings_load_connections_async);
|
||||
|
||||
if (!settings_service_is_running (settings, &error)) {
|
||||
g_simple_async_result_take_error (simple, error);
|
||||
g_simple_async_result_complete_in_idle (simple);
|
||||
g_object_unref (simple);
|
||||
return;
|
||||
}
|
||||
|
||||
nmdbus_settings_call_load_connections (priv->proxy,
|
||||
(const char * const *) filenames,
|
||||
cancellable, load_connections_cb, simple);
|
||||
}
|
||||
|
||||
/**
|
||||
* nm_remote_settings_load_connections_finish:
|
||||
* @settings: the %NMRemoteSettings
|
||||
* @failures: (out) (transfer full): on return, a %NULL-terminated array of
|
||||
* filenames that failed to load
|
||||
* @result: the result passed to the #GAsyncReadyCallback
|
||||
* @error: location for a #GError, or %NULL
|
||||
*
|
||||
* Gets the result of an nm_remote_settings_load_connections_async() call.
|
||||
|
||||
* See nm_remote_settings_load_connections() for more details.
|
||||
*
|
||||
* Returns: %TRUE if NetworkManager at least tried to load @filenames,
|
||||
* %FALSE if an error occurred (eg, permission denied).
|
||||
**/
|
||||
gboolean
|
||||
nm_remote_settings_load_connections_finish (NMRemoteSettings *settings,
|
||||
char ***failures,
|
||||
GAsyncResult *result,
|
||||
GError **error)
|
||||
{
|
||||
GSimpleAsyncResult *simple;
|
||||
|
||||
g_return_val_if_fail (g_simple_async_result_is_valid (result, G_OBJECT (settings), nm_remote_settings_load_connections_async), FALSE);
|
||||
|
||||
simple = G_SIMPLE_ASYNC_RESULT (result);
|
||||
if (g_simple_async_result_propagate_error (simple, error))
|
||||
return FALSE;
|
||||
else {
|
||||
*failures = g_strdupv (g_simple_async_result_get_op_res_gpointer (simple));
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* nm_remote_settings_reload_connections:
|
||||
* @settings: the #NMRemoteSettings
|
||||
|
|
@ -654,6 +751,122 @@ nm_remote_settings_reload_connections (NMRemoteSettings *settings,
|
|||
return success;
|
||||
}
|
||||
|
||||
static void
|
||||
reload_connections_cb (GObject *proxy, GAsyncResult *result, gpointer user_data)
|
||||
{
|
||||
GSimpleAsyncResult *simple = user_data;
|
||||
gboolean success;
|
||||
GError *error = NULL;
|
||||
|
||||
if (nmdbus_settings_call_reload_connections_finish (NMDBUS_SETTINGS (proxy),
|
||||
&success,
|
||||
result, &error))
|
||||
g_simple_async_result_set_op_res_gboolean (simple, success);
|
||||
else
|
||||
g_simple_async_result_take_error (simple, error);
|
||||
|
||||
g_simple_async_result_complete (simple);
|
||||
g_object_unref (simple);
|
||||
}
|
||||
|
||||
/**
|
||||
* nm_remote_settings_reload_connections_async:
|
||||
* @settings: the #NMRemoteSettings
|
||||
* @cancellable: a #GCancellable, or %NULL
|
||||
* @callback: (scope async): callback to be called when the reload operation completes
|
||||
* @user_data: (closure): caller-specific data passed to @callback
|
||||
*
|
||||
* Requests that the remote settings service begin reloading all connection
|
||||
* files from disk, adding, updating, and removing connections until the
|
||||
* in-memory state matches the on-disk state.
|
||||
**/
|
||||
void
|
||||
nm_remote_settings_reload_connections_async (NMRemoteSettings *settings,
|
||||
GCancellable *cancellable,
|
||||
GAsyncReadyCallback callback,
|
||||
gpointer user_data)
|
||||
{
|
||||
NMRemoteSettingsPrivate *priv;
|
||||
GSimpleAsyncResult *simple;
|
||||
GError *error = NULL;
|
||||
|
||||
g_return_val_if_fail (NM_IS_REMOTE_SETTINGS (settings), FALSE);
|
||||
|
||||
priv = NM_REMOTE_SETTINGS_GET_PRIVATE (settings);
|
||||
|
||||
simple = g_simple_async_result_new (G_OBJECT (settings), callback, user_data,
|
||||
nm_remote_settings_reload_connections_async);
|
||||
|
||||
if (!settings_service_is_running (settings, &error)) {
|
||||
g_simple_async_result_take_error (simple, error);
|
||||
g_simple_async_result_complete_in_idle (simple);
|
||||
g_object_unref (simple);
|
||||
return;
|
||||
}
|
||||
|
||||
nmdbus_settings_call_reload_connections (priv->proxy, cancellable,
|
||||
reload_connections_cb, simple);
|
||||
}
|
||||
|
||||
/**
|
||||
* nm_remote_settings_reload_connections_finish:
|
||||
* @settings: the #NMRemoteSettings
|
||||
* @result: the result passed to the #GAsyncReadyCallback
|
||||
* @error: return location for #GError
|
||||
*
|
||||
* Gets the result of an nm_remote_settings_reload_connections_async() call.
|
||||
*
|
||||
* Return value: %TRUE on success, %FALSE on failure
|
||||
**/
|
||||
gboolean
|
||||
nm_remote_settings_reload_connections_finish (NMRemoteSettings *settings,
|
||||
GAsyncResult *result,
|
||||
GError **error)
|
||||
{
|
||||
GSimpleAsyncResult *simple;
|
||||
|
||||
g_return_val_if_fail (g_simple_async_result_is_valid (result, G_OBJECT (settings), nm_remote_settings_reload_connections_async), FALSE);
|
||||
|
||||
simple = G_SIMPLE_ASYNC_RESULT (result);
|
||||
if (g_simple_async_result_propagate_error (simple, error))
|
||||
return FALSE;
|
||||
else
|
||||
return g_simple_async_result_get_op_res_gboolean (simple);
|
||||
}
|
||||
|
||||
/**
|
||||
* nm_remote_settings_save_hostname:
|
||||
* @settings: the %NMRemoteSettings
|
||||
* @hostname: (allow-none): the new persistent hostname to set, or %NULL to
|
||||
* clear any existing persistent hostname
|
||||
* @cancellable: a #GCancellable, or %NULL
|
||||
* @error: return location for #GError
|
||||
*
|
||||
* Requests that the machine's persistent hostname be set to the specified value
|
||||
* or cleared.
|
||||
*
|
||||
* Returns: %TRUE if the request was successful, %FALSE if it failed
|
||||
**/
|
||||
gboolean
|
||||
nm_remote_settings_save_hostname (NMRemoteSettings *settings,
|
||||
const char *hostname,
|
||||
GCancellable *cancellable,
|
||||
GError **error)
|
||||
{
|
||||
NMRemoteSettingsPrivate *priv;
|
||||
|
||||
g_return_val_if_fail (NM_IS_REMOTE_SETTINGS (settings), FALSE);
|
||||
|
||||
priv = NM_REMOTE_SETTINGS_GET_PRIVATE (settings);
|
||||
|
||||
if (!settings_service_is_running (settings, error))
|
||||
return FALSE;
|
||||
|
||||
return nmdbus_settings_call_save_hostname_sync (priv->proxy,
|
||||
hostname ? hostname : "",
|
||||
cancellable, error);
|
||||
}
|
||||
|
||||
static void
|
||||
save_hostname_cb (GObject *proxy,
|
||||
GAsyncResult *result,
|
||||
|
|
|
|||
|
|
@ -123,16 +123,36 @@ NMRemoteConnection *nm_remote_settings_add_connection_finish (NMRemoteSettings *
|
|||
GAsyncResult *result,
|
||||
GError **error);
|
||||
|
||||
gboolean nm_remote_settings_load_connections (NMRemoteSettings *settings,
|
||||
char **filenames,
|
||||
char ***failures,
|
||||
GCancellable *cancellable,
|
||||
GError **error);
|
||||
gboolean nm_remote_settings_load_connections (NMRemoteSettings *settings,
|
||||
char **filenames,
|
||||
char ***failures,
|
||||
GCancellable *cancellable,
|
||||
GError **error);
|
||||
void nm_remote_settings_load_connections_async (NMRemoteSettings *settings,
|
||||
char **filenames,
|
||||
GCancellable *cancellable,
|
||||
GAsyncReadyCallback callback,
|
||||
gpointer user_data);
|
||||
gboolean nm_remote_settings_load_connections_finish (NMRemoteSettings *settings,
|
||||
char ***failures,
|
||||
GAsyncResult *result,
|
||||
GError **error);
|
||||
|
||||
gboolean nm_remote_settings_reload_connections (NMRemoteSettings *settings,
|
||||
GCancellable *cancellable,
|
||||
GError **error);
|
||||
gboolean nm_remote_settings_reload_connections (NMRemoteSettings *settings,
|
||||
GCancellable *cancellable,
|
||||
GError **error);
|
||||
void nm_remote_settings_reload_connections_async (NMRemoteSettings *settings,
|
||||
GCancellable *cancellable,
|
||||
GAsyncReadyCallback callback,
|
||||
gpointer user_data);
|
||||
gboolean nm_remote_settings_reload_connections_finish (NMRemoteSettings *settings,
|
||||
GAsyncResult *result,
|
||||
GError **error);
|
||||
|
||||
gboolean nm_remote_settings_save_hostname (NMRemoteSettings *settings,
|
||||
const char *hostname,
|
||||
GCancellable *cancellable,
|
||||
GError **error);
|
||||
void nm_remote_settings_save_hostname_async (NMRemoteSettings *settings,
|
||||
const char *hostname,
|
||||
GCancellable *cancellable,
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue