settings: get rid of callback arguments for nm_settings_connection_delete()

This commit is contained in:
Thomas Haller
2017-10-19 11:22:14 +02:00
parent bd66285b1c
commit 3ecb57fdc4
7 changed files with 26 additions and 54 deletions

View File

@@ -1219,7 +1219,7 @@ dispose (GObject *object)
if (to_delete) { if (to_delete) {
nm_log_dbg (LOGD_BT, "bluez[%s] removing Bluetooth connection for NAP device: '%s' (%s)", priv->path, nm_log_dbg (LOGD_BT, "bluez[%s] removing Bluetooth connection for NAP device: '%s' (%s)", priv->path,
nm_connection_get_id (to_delete), nm_connection_get_uuid (to_delete)); nm_connection_get_id (to_delete), nm_connection_get_uuid (to_delete));
nm_settings_connection_delete (NM_SETTINGS_CONNECTION (to_delete), NULL, NULL); nm_settings_connection_delete (NM_SETTINGS_CONNECTION (to_delete), NULL);
g_object_unref (to_delete); g_object_unref (to_delete);
} }

View File

@@ -342,7 +342,7 @@ next_dev:
nm_settings_connection_get_uuid (con))) { nm_settings_connection_get_uuid (con))) {
_LOGD ("rollback: deleting new connection %s", _LOGD ("rollback: deleting new connection %s",
nm_settings_connection_get_uuid (con)); nm_settings_connection_get_uuid (con));
nm_settings_connection_delete (con, NULL, NULL); nm_settings_connection_delete (con, NULL);
} }
} }
} }

View File

@@ -339,7 +339,7 @@ active_connection_remove (NMManager *self, NMActiveConnection *active)
if (nm_settings_has_connection (priv->settings, connection)) { if (nm_settings_has_connection (priv->settings, connection)) {
_LOGD (LOGD_DEVICE, "assumed connection disconnected. Deleting generated connection '%s' (%s)", _LOGD (LOGD_DEVICE, "assumed connection disconnected. Deleting generated connection '%s' (%s)",
nm_settings_connection_get_id (connection), nm_settings_connection_get_uuid (connection)); nm_settings_connection_get_id (connection), nm_settings_connection_get_uuid (connection));
nm_settings_connection_delete (connection, NULL, NULL); nm_settings_connection_delete (connection, NULL);
} }
g_object_unref (connection); g_object_unref (connection);
} }
@@ -1990,7 +1990,7 @@ recheck_assume_connection (NMManager *self,
if (generated) { if (generated) {
_LOG2D (LOGD_DEVICE, device, "assume: deleting generated connection after assuming failed"); _LOG2D (LOGD_DEVICE, device, "assume: deleting generated connection after assuming failed");
nm_settings_connection_delete (connection, NULL, NULL); nm_settings_connection_delete (connection, NULL);
} else { } else {
if (nm_device_sys_iface_state_get (device) == NM_DEVICE_SYS_IFACE_STATE_ASSUME) if (nm_device_sys_iface_state_get (device) == NM_DEVICE_SYS_IFACE_STATE_ASSUME)
nm_device_sys_iface_state_set (device, NM_DEVICE_SYS_IFACE_STATE_EXTERNAL); nm_device_sys_iface_state_set (device, NM_DEVICE_SYS_IFACE_STATE_EXTERNAL);
@@ -4056,7 +4056,7 @@ activation_add_done (NMSettings *settings,
g_assert (error); g_assert (error);
_internal_activation_failed (self, active, error->message); _internal_activation_failed (self, active, error->message);
if (new_connection) if (new_connection)
nm_settings_connection_delete (new_connection, NULL, NULL); nm_settings_connection_delete (new_connection, NULL);
g_dbus_method_invocation_return_gerror (context, error); g_dbus_method_invocation_return_gerror (context, error);
nm_audit_log_connection_op (NM_AUDIT_OP_CONN_ADD_ACTIVATE, nm_audit_log_connection_op (NM_AUDIT_OP_CONN_ADD_ACTIVATE,
NULL, NULL,

View File

@@ -663,33 +663,31 @@ remove_entry_from_db (NMSettingsConnection *self, const char* db_name)
g_key_file_free (key_file); g_key_file_free (key_file);
} }
void gboolean
nm_settings_connection_delete (NMSettingsConnection *self, nm_settings_connection_delete (NMSettingsConnection *self,
NMSettingsConnectionDeleteFunc callback, GError **error)
gpointer user_data)
{ {
gs_unref_object NMSettingsConnection *self_keep_alive = NULL; gs_unref_object NMSettingsConnection *self_keep_alive = NULL;
gs_free_error GError *error = NULL;
NMSettingsConnectionClass *klass; NMSettingsConnectionClass *klass;
NMSettingsConnectionPrivate *priv = NM_SETTINGS_CONNECTION_GET_PRIVATE (self); NMSettingsConnectionPrivate *priv = NM_SETTINGS_CONNECTION_GET_PRIVATE (self);
NMConnection *for_agents; NMConnection *for_agents;
g_return_if_fail (NM_IS_SETTINGS_CONNECTION (self)); g_return_val_if_fail (NM_IS_SETTINGS_CONNECTION (self), FALSE);
klass = NM_SETTINGS_CONNECTION_GET_CLASS (self); klass = NM_SETTINGS_CONNECTION_GET_CLASS (self);
self_keep_alive = g_object_ref (self); self_keep_alive = g_object_ref (self);
if (!klass->delete) { if (!klass->delete) {
g_set_error (&error, g_set_error (error,
NM_SETTINGS_ERROR, NM_SETTINGS_ERROR,
NM_SETTINGS_ERROR_FAILED, NM_SETTINGS_ERROR_FAILED,
"delete not supported"); "delete not supported");
goto out; return FALSE;
} }
if (!klass->delete (self, if (!klass->delete (self,
&error)) error))
goto out; return FALSE;
set_visible (self, FALSE); set_visible (self, FALSE);
@@ -708,10 +706,7 @@ nm_settings_connection_delete (NMSettingsConnection *self,
remove_entry_from_db (self, "seen-bssids"); remove_entry_from_db (self, "seen-bssids");
nm_settings_connection_signal_remove (self, FALSE); nm_settings_connection_signal_remove (self, FALSE);
return TRUE;
out:
if (callback)
callback (self, error, user_data);
} }
@@ -1514,11 +1509,6 @@ typedef struct {
char *audit_args; char *audit_args;
} UpdateInfo; } UpdateInfo;
typedef struct {
GDBusMethodInvocation *context;
NMAuthSubject *subject;
} CallbackInfo;
static void static void
has_some_secrets_cb (NMSetting *setting, has_some_secrets_cb (NMSetting *setting,
const char *key, const char *key,
@@ -1812,23 +1802,6 @@ impl_settings_connection_save (NMSettingsConnection *self,
settings_connection_update_helper (self, context, NULL, TRUE); settings_connection_update_helper (self, context, NULL, TRUE);
} }
static void
con_delete_cb (NMSettingsConnection *self,
GError *error,
gpointer user_data)
{
CallbackInfo *info = user_data;
if (error)
g_dbus_method_invocation_return_gerror (info->context, error);
else
g_dbus_method_invocation_return_value (info->context, NULL);
nm_audit_log_connection_op (NM_AUDIT_OP_CONN_DELETE, self,
!error, NULL, info->subject, error ? error->message : NULL);
g_free (info);
}
static void static void
delete_auth_cb (NMSettingsConnection *self, delete_auth_cb (NMSettingsConnection *self,
GDBusMethodInvocation *context, GDBusMethodInvocation *context,
@@ -1836,7 +1809,7 @@ delete_auth_cb (NMSettingsConnection *self,
GError *error, GError *error,
gpointer data) gpointer data)
{ {
CallbackInfo *info; gs_free_error GError *local = NULL;
if (error) { if (error) {
nm_audit_log_connection_op (NM_AUDIT_OP_CONN_DELETE, self, FALSE, NULL, subject, nm_audit_log_connection_op (NM_AUDIT_OP_CONN_DELETE, self, FALSE, NULL, subject,
@@ -1845,11 +1818,15 @@ delete_auth_cb (NMSettingsConnection *self,
return; return;
} }
info = g_malloc0 (sizeof (*info)); nm_settings_connection_delete (self, &local);
info->context = context;
info->subject = subject;
nm_settings_connection_delete (self, con_delete_cb, info); nm_audit_log_connection_op (NM_AUDIT_OP_CONN_DELETE, self,
!local, NULL, subject, local ? local->message : NULL);
if (local)
g_dbus_method_invocation_return_gerror (context, local);
else
g_dbus_method_invocation_return_value (context, NULL);
} }
static const char * static const char *

View File

@@ -94,10 +94,6 @@ typedef struct _NMSettingsConnectionCallId *NMSettingsConnectionCallId;
typedef struct _NMSettingsConnectionClass NMSettingsConnectionClass; typedef struct _NMSettingsConnectionClass NMSettingsConnectionClass;
typedef void (*NMSettingsConnectionDeleteFunc) (NMSettingsConnection *self,
GError *error,
gpointer user_data);
struct _NMSettingsConnectionPrivate; struct _NMSettingsConnectionPrivate;
struct _NMSettingsConnection { struct _NMSettingsConnection {
@@ -138,9 +134,8 @@ gboolean nm_settings_connection_replace_settings (NMSettingsConnection *self,
const char *log_diff_name, const char *log_diff_name,
GError **error); GError **error);
void nm_settings_connection_delete (NMSettingsConnection *self, gboolean nm_settings_connection_delete (NMSettingsConnection *self,
NMSettingsConnectionDeleteFunc callback, GError **error);
gpointer user_data);
typedef void (*NMSettingsConnectionSecretsFunc) (NMSettingsConnection *self, typedef void (*NMSettingsConnectionSecretsFunc) (NMSettingsConnection *self,
NMSettingsConnectionCallId call_id, NMSettingsConnectionCallId call_id,

View File

@@ -1773,7 +1773,7 @@ nm_settings_device_removed (NMSettings *self, NMDevice *device, gboolean quittin
* remains up and can be assumed if NM starts again. * remains up and can be assumed if NM starts again.
*/ */
if (quitting == FALSE) if (quitting == FALSE)
nm_settings_connection_delete (connection, NULL, NULL); nm_settings_connection_delete (connection, NULL);
} }
} }

View File

@@ -411,7 +411,7 @@ init (NMSettingsPlugin *config)
exported = g_hash_table_lookup (priv->connections, block->name); exported = g_hash_table_lookup (priv->connections, block->name);
if (exported) { if (exported) {
nm_log_info (LOGD_SETTINGS, "deleting %s from connections", block->name); nm_log_info (LOGD_SETTINGS, "deleting %s from connections", block->name);
nm_settings_connection_delete (NM_SETTINGS_CONNECTION (exported), NULL, NULL); nm_settings_connection_delete (NM_SETTINGS_CONNECTION (exported), NULL);
g_hash_table_remove (priv->connections, block->name); g_hash_table_remove (priv->connections, block->name);
} }