mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager
synced 2024-10-15 12:34:55 +00:00
libnm-glib: implement nm_device_delete() for D-Bus device' Delete() method
This commit is contained in:
parent
3ff1477349
commit
576c82049b
|
@ -104,6 +104,7 @@ global:
|
||||||
nm_device_bt_new;
|
nm_device_bt_new;
|
||||||
nm_device_connection_compatible;
|
nm_device_connection_compatible;
|
||||||
nm_device_connection_valid;
|
nm_device_connection_valid;
|
||||||
|
nm_device_delete;
|
||||||
nm_device_disambiguate_names;
|
nm_device_disambiguate_names;
|
||||||
nm_device_disconnect;
|
nm_device_disconnect;
|
||||||
nm_device_error_get_type;
|
nm_device_error_get_type;
|
||||||
|
|
|
@ -2086,16 +2086,17 @@ nm_device_is_software (NMDevice *device)
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
NMDevice *device;
|
NMDevice *device;
|
||||||
NMDeviceDeactivateFn fn;
|
NMDeviceCallbackFn fn;
|
||||||
gpointer user_data;
|
gpointer user_data;
|
||||||
} DeactivateInfo;
|
const char *method;
|
||||||
|
} DeviceCallbackInfo;
|
||||||
|
|
||||||
static void
|
static void
|
||||||
deactivate_cb (DBusGProxy *proxy,
|
device_operation_cb (DBusGProxy *proxy,
|
||||||
DBusGProxyCall *call,
|
DBusGProxyCall *call,
|
||||||
gpointer user_data)
|
gpointer user_data)
|
||||||
{
|
{
|
||||||
DeactivateInfo *info = user_data;
|
DeviceCallbackInfo *info = user_data;
|
||||||
GError *error = NULL;
|
GError *error = NULL;
|
||||||
|
|
||||||
dbus_g_proxy_end_call (proxy, call, &error,
|
dbus_g_proxy_end_call (proxy, call, &error,
|
||||||
|
@ -2103,16 +2104,17 @@ deactivate_cb (DBusGProxy *proxy,
|
||||||
if (info->fn)
|
if (info->fn)
|
||||||
info->fn (info->device, error, info->user_data);
|
info->fn (info->device, error, info->user_data);
|
||||||
else if (error) {
|
else if (error) {
|
||||||
g_warning ("%s: device %s deactivation failed: (%d) %s",
|
g_warning ("%s: device %s %s failed: (%d) %s",
|
||||||
__func__,
|
__func__,
|
||||||
nm_object_get_path (NM_OBJECT (info->device)),
|
nm_object_get_path (NM_OBJECT (info->device)),
|
||||||
|
info->method,
|
||||||
error ? error->code : -1,
|
error ? error->code : -1,
|
||||||
error && error->message ? error->message : "(unknown)");
|
error && error->message ? error->message : "(unknown)");
|
||||||
}
|
}
|
||||||
g_clear_error (&error);
|
g_clear_error (&error);
|
||||||
|
|
||||||
g_object_unref (info->device);
|
g_object_unref (info->device);
|
||||||
g_slice_free (DeactivateInfo, info);
|
g_slice_free (DeviceCallbackInfo, info);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -2128,20 +2130,52 @@ deactivate_cb (DBusGProxy *proxy,
|
||||||
**/
|
**/
|
||||||
void
|
void
|
||||||
nm_device_disconnect (NMDevice *device,
|
nm_device_disconnect (NMDevice *device,
|
||||||
NMDeviceDeactivateFn callback,
|
NMDeviceCallbackFn callback,
|
||||||
gpointer user_data)
|
gpointer user_data)
|
||||||
{
|
{
|
||||||
DeactivateInfo *info;
|
DeviceCallbackInfo *info;
|
||||||
|
|
||||||
g_return_if_fail (NM_IS_DEVICE (device));
|
g_return_if_fail (NM_IS_DEVICE (device));
|
||||||
|
|
||||||
info = g_slice_new (DeactivateInfo);
|
info = g_slice_new (DeviceCallbackInfo);
|
||||||
info->fn = callback;
|
info->fn = callback;
|
||||||
info->user_data = user_data;
|
info->user_data = user_data;
|
||||||
|
info->method = "Disconnect";
|
||||||
info->device = g_object_ref (device);
|
info->device = g_object_ref (device);
|
||||||
|
|
||||||
dbus_g_proxy_begin_call (NM_DEVICE_GET_PRIVATE (device)->proxy, "Disconnect",
|
dbus_g_proxy_begin_call (NM_DEVICE_GET_PRIVATE (device)->proxy, "Disconnect",
|
||||||
deactivate_cb, info, NULL,
|
device_operation_cb, info, NULL,
|
||||||
|
G_TYPE_INVALID);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* nm_device_delete:
|
||||||
|
* @device: a #NMDevice
|
||||||
|
* @callback: (scope async) (allow-none): callback to be called when delete
|
||||||
|
* operation completes
|
||||||
|
* @user_data: (closure): caller-specific data passed to @callback
|
||||||
|
*
|
||||||
|
* Deletes the software device. Hardware devices can't be deleted.
|
||||||
|
*
|
||||||
|
* Since: 1.0
|
||||||
|
**/
|
||||||
|
void
|
||||||
|
nm_device_delete (NMDevice *device,
|
||||||
|
NMDeviceCallbackFn callback,
|
||||||
|
gpointer user_data)
|
||||||
|
{
|
||||||
|
DeviceCallbackInfo *info;
|
||||||
|
|
||||||
|
g_return_if_fail (NM_IS_DEVICE (device));
|
||||||
|
|
||||||
|
info = g_slice_new (DeviceCallbackInfo);
|
||||||
|
info->fn = callback;
|
||||||
|
info->user_data = user_data;
|
||||||
|
info->method = "Delete";
|
||||||
|
info->device = g_object_ref (device);
|
||||||
|
|
||||||
|
dbus_g_proxy_begin_call (NM_DEVICE_GET_PRIVATE (device)->proxy, "Delete",
|
||||||
|
device_operation_cb, info, NULL,
|
||||||
G_TYPE_INVALID);
|
G_TYPE_INVALID);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -153,10 +153,15 @@ NM_AVAILABLE_IN_0_9_10
|
||||||
char ** nm_device_disambiguate_names (NMDevice **devices,
|
char ** nm_device_disambiguate_names (NMDevice **devices,
|
||||||
int num_devices);
|
int num_devices);
|
||||||
|
|
||||||
typedef void (*NMDeviceDeactivateFn) (NMDevice *device, GError *error, gpointer user_data);
|
typedef void (*NMDeviceCallbackFn) (NMDevice *device, GError *error, gpointer user_data);
|
||||||
|
|
||||||
void nm_device_disconnect (NMDevice *device,
|
void nm_device_disconnect (NMDevice *device,
|
||||||
NMDeviceDeactivateFn callback,
|
NMDeviceCallbackFn callback,
|
||||||
|
gpointer user_data);
|
||||||
|
|
||||||
|
NM_AVAILABLE_IN_1_0
|
||||||
|
void nm_device_delete (NMDevice *device,
|
||||||
|
NMDeviceCallbackFn callback,
|
||||||
gpointer user_data);
|
gpointer user_data);
|
||||||
|
|
||||||
GSList * nm_device_filter_connections (NMDevice *device,
|
GSList * nm_device_filter_connections (NMDevice *device,
|
||||||
|
@ -172,6 +177,10 @@ gboolean nm_device_connection_compatible (NMDevice *device,
|
||||||
NM_AVAILABLE_IN_0_9_10
|
NM_AVAILABLE_IN_0_9_10
|
||||||
GType nm_device_get_setting_type (NMDevice *device);
|
GType nm_device_get_setting_type (NMDevice *device);
|
||||||
|
|
||||||
|
/* Deprecated */
|
||||||
|
NM_DEPRECATED_IN_1_0
|
||||||
|
typedef void (*NMDeviceDeactivateFn) (NMDevice *device, GError *error, gpointer user_data);
|
||||||
|
|
||||||
G_END_DECLS
|
G_END_DECLS
|
||||||
|
|
||||||
#endif /* NM_DEVICE_H */
|
#endif /* NM_DEVICE_H */
|
||||||
|
|
Loading…
Reference in a new issue