mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2026-01-07 06:40:18 +01:00
settings: split nm_settings_connection_replace_settings() function
Extract two function "replace_prepare" and "replace", so that they can be used independently.
This commit is contained in:
parent
3ecb57fdc4
commit
edc7503569
2 changed files with 57 additions and 11 deletions
|
|
@ -510,18 +510,12 @@ connection_changed_cb (NMSettingsConnection *self, gpointer unused)
|
|||
_emit_updated (self, FALSE);
|
||||
}
|
||||
|
||||
/* Update the settings of this connection to match that of 'new_connection',
|
||||
* taking care to make a private copy of secrets.
|
||||
*/
|
||||
gboolean
|
||||
nm_settings_connection_replace_settings (NMSettingsConnection *self,
|
||||
NMConnection *new_connection,
|
||||
gboolean update_unsaved,
|
||||
const char *log_diff_name,
|
||||
GError **error)
|
||||
nm_settings_connection_replace_settings_prepare (NMSettingsConnection *self,
|
||||
NMConnection *new_connection,
|
||||
GError **error)
|
||||
{
|
||||
NMSettingsConnectionPrivate *priv;
|
||||
gboolean success = FALSE;
|
||||
|
||||
g_return_val_if_fail (NM_IS_SETTINGS_CONNECTION (self), FALSE);
|
||||
g_return_val_if_fail (NM_IS_CONNECTION (new_connection), FALSE);
|
||||
|
|
@ -540,6 +534,30 @@ nm_settings_connection_replace_settings (NMSettingsConnection *self,
|
|||
return FALSE;
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
gboolean
|
||||
nm_settings_connection_replace_settings_full (NMSettingsConnection *self,
|
||||
NMConnection *new_connection,
|
||||
gboolean prepare_new_connection,
|
||||
gboolean update_unsaved,
|
||||
const char *log_diff_name,
|
||||
GError **error)
|
||||
{
|
||||
NMSettingsConnectionPrivate *priv;
|
||||
|
||||
g_return_val_if_fail (NM_IS_SETTINGS_CONNECTION (self), FALSE);
|
||||
g_return_val_if_fail (NM_IS_CONNECTION (new_connection), FALSE);
|
||||
|
||||
priv = NM_SETTINGS_CONNECTION_GET_PRIVATE (self);
|
||||
|
||||
if ( prepare_new_connection
|
||||
&& !nm_settings_connection_replace_settings_prepare (self,
|
||||
new_connection,
|
||||
error))
|
||||
return FALSE;
|
||||
|
||||
/* Do nothing if there's nothing to update */
|
||||
if (nm_connection_compare (NM_CONNECTION (self),
|
||||
new_connection,
|
||||
|
|
@ -567,7 +585,6 @@ nm_settings_connection_replace_settings (NMSettingsConnection *self,
|
|||
* nm_connection_clear_secrets() and clears them.
|
||||
*/
|
||||
update_system_secrets_cache (self);
|
||||
success = TRUE;
|
||||
|
||||
/* Add agent and always-ask secrets back; they won't necessarily be
|
||||
* in the replacement connection data if it was eg reread from disk.
|
||||
|
|
@ -594,7 +611,25 @@ nm_settings_connection_replace_settings (NMSettingsConnection *self,
|
|||
|
||||
_emit_updated (self, TRUE);
|
||||
|
||||
return success;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/* Update the settings of this connection to match that of 'new_connection',
|
||||
* taking care to make a private copy of secrets.
|
||||
*/
|
||||
gboolean
|
||||
nm_settings_connection_replace_settings (NMSettingsConnection *self,
|
||||
NMConnection *new_connection,
|
||||
gboolean update_unsaved,
|
||||
const char *log_diff_name,
|
||||
GError **error)
|
||||
{
|
||||
return nm_settings_connection_replace_settings_full (self,
|
||||
new_connection,
|
||||
TRUE,
|
||||
update_unsaved,
|
||||
log_diff_name,
|
||||
error);
|
||||
}
|
||||
|
||||
gboolean
|
||||
|
|
|
|||
|
|
@ -128,12 +128,23 @@ gboolean nm_settings_connection_commit_changes (NMSettingsConnection *self,
|
|||
NMSettingsConnectionCommitReason commit_reason,
|
||||
GError **error);
|
||||
|
||||
gboolean nm_settings_connection_replace_settings_prepare (NMSettingsConnection *self,
|
||||
NMConnection *new_connection,
|
||||
GError **error);
|
||||
|
||||
gboolean nm_settings_connection_replace_settings (NMSettingsConnection *self,
|
||||
NMConnection *new_connection,
|
||||
gboolean update_unsaved,
|
||||
const char *log_diff_name,
|
||||
GError **error);
|
||||
|
||||
gboolean nm_settings_connection_replace_settings_full (NMSettingsConnection *self,
|
||||
NMConnection *new_connection,
|
||||
gboolean prepare_new_connection,
|
||||
gboolean update_unsaved,
|
||||
const char *log_diff_name,
|
||||
GError **error);
|
||||
|
||||
gboolean nm_settings_connection_delete (NMSettingsConnection *self,
|
||||
GError **error);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue