mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager
synced 2024-11-02 21:09:05 +00:00
libnm: add nm_client_dbus_set_property() API
Similar to nm_client_dbus_call(), but useful for setting a D-Bus property on NetworkManager's D-Bus interface. Note that we currently have various synchronous API for setting D-Bus properties (like nm_client_networking_set_enabled()). Synchronous API does not play well with the content of NMClient's cache, and was thus deprecated. However, until now no async variant exists. Instead of adding multiple async operations, I think it should be sufficient to only add one nm_client_dbus_set_property() property. It's still reasonably convenient to use for setting a property.
This commit is contained in:
parent
1a36bdbb2c
commit
a7b8c82ee2
3 changed files with 100 additions and 0 deletions
|
@ -1667,6 +1667,8 @@ libnm_1_24_0 {
|
|||
global:
|
||||
nm_client_dbus_call;
|
||||
nm_client_dbus_call_finish;
|
||||
nm_client_dbus_set_property;
|
||||
nm_client_dbus_set_property_finish;
|
||||
nm_client_get_instance_flags;
|
||||
nm_client_get_object_by_path;
|
||||
nm_client_get_permissions_state;
|
||||
|
|
|
@ -6735,6 +6735,88 @@ nm_client_dbus_call_finish (NMClient *client,
|
|||
|
||||
/*****************************************************************************/
|
||||
|
||||
/**
|
||||
* nm_client_dbus_set_property:
|
||||
* @client: the #NMClient
|
||||
* @object_path: path of remote object
|
||||
* @interface_name: D-Bus interface to invoke method on
|
||||
* @property_name: the name of the property to set
|
||||
* @value: a #GVariant tuple with the value to set
|
||||
* @timeout_msec: the timeout in milliseconds, -1 to use the default
|
||||
* timeout or %G_MAXINT for no timeout
|
||||
* @cancellable: (nullable): a #GCancellable or %NULL
|
||||
* @callback: (nullable): a #GAsyncReadyCallback to call when the request
|
||||
* is satisfied or %NULL if you don't care about the result of the
|
||||
* method invocation
|
||||
* @user_data: the data to pass to @callback
|
||||
*
|
||||
* Like nm_client_dbus_call() but calls "Set" on the standard "org.freedesktop.DBus.Properties"
|
||||
* D-Bus interface.
|
||||
*
|
||||
* Since: 1.24
|
||||
**/
|
||||
void
|
||||
nm_client_dbus_set_property (NMClient *client,
|
||||
const char *object_path,
|
||||
const char *interface_name,
|
||||
const char *property_name,
|
||||
GVariant *value,
|
||||
int timeout_msec,
|
||||
GCancellable *cancellable,
|
||||
GAsyncReadyCallback callback,
|
||||
gpointer user_data)
|
||||
{
|
||||
g_return_if_fail (NM_IS_CLIENT (client));
|
||||
g_return_if_fail (interface_name);
|
||||
g_return_if_fail (property_name);
|
||||
g_return_if_fail (value);
|
||||
|
||||
_nm_client_dbus_call (client,
|
||||
client,
|
||||
nm_client_dbus_set_property,
|
||||
cancellable,
|
||||
callback,
|
||||
user_data,
|
||||
object_path,
|
||||
DBUS_INTERFACE_PROPERTIES,
|
||||
"Set",
|
||||
g_variant_new ("(ssv)",
|
||||
interface_name,
|
||||
property_name,
|
||||
value),
|
||||
G_VARIANT_TYPE ("()"),
|
||||
G_DBUS_CALL_FLAGS_NONE,
|
||||
timeout_msec == -1
|
||||
? NM_DBUS_DEFAULT_TIMEOUT_MSEC
|
||||
: timeout_msec,
|
||||
nm_dbus_connection_call_finish_void_cb);
|
||||
}
|
||||
|
||||
/**
|
||||
* nm_client_dbus_set_property_finish:
|
||||
* @client: the #NMClient instance
|
||||
* @result: the result passed to the #GAsyncReadyCallback
|
||||
* @error: location for a #GError, or %NULL
|
||||
*
|
||||
* Gets the result of a call to nm_client_dbus_set_property().
|
||||
*
|
||||
* Returns: %TRUE on success or %FALSE on failure.
|
||||
*
|
||||
* Since: 1.24
|
||||
**/
|
||||
gboolean
|
||||
nm_client_dbus_set_property_finish (NMClient *client,
|
||||
GAsyncResult *result,
|
||||
GError **error)
|
||||
{
|
||||
g_return_val_if_fail (NM_IS_CLIENT (client), FALSE);
|
||||
g_return_val_if_fail (nm_g_task_is_valid (result, client, nm_client_dbus_set_property), FALSE);
|
||||
|
||||
return g_task_propagate_boolean (G_TASK (result), error);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
static void
|
||||
_init_fetch_all (NMClient *self)
|
||||
{
|
||||
|
|
|
@ -497,6 +497,22 @@ GVariant *nm_client_dbus_call_finish (NMClient *client,
|
|||
GAsyncResult *result,
|
||||
GError **error);
|
||||
|
||||
NM_AVAILABLE_IN_1_24
|
||||
void nm_client_dbus_set_property (NMClient *client,
|
||||
const char *object_path,
|
||||
const char *interface_name,
|
||||
const char *property_name,
|
||||
GVariant *value,
|
||||
int timeout_msec,
|
||||
GCancellable *cancellable,
|
||||
GAsyncReadyCallback callback,
|
||||
gpointer user_data);
|
||||
|
||||
NM_AVAILABLE_IN_1_24
|
||||
gboolean nm_client_dbus_set_property_finish (NMClient *client,
|
||||
GAsyncResult *result,
|
||||
GError **error);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* __NM_CLIENT_H__ */
|
||||
|
|
Loading…
Reference in a new issue