mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2026-02-06 23:20:34 +01:00
settings: add 'nm_generated' flag on NMSettingsConnection
Add 'nm_generated' flag on NMSettingsConnection, and have NMManager set it on generated connections that it assumes.
This commit is contained in:
parent
6fd76323e0
commit
14048089a1
3 changed files with 49 additions and 1 deletions
|
|
@ -1572,7 +1572,9 @@ get_existing_connection (NMManager *manager, NMDevice *device)
|
|||
nm_connection_get_id (connection));
|
||||
|
||||
added = nm_settings_add_connection (priv->settings, connection, FALSE, &error);
|
||||
if (!added) {
|
||||
if (added)
|
||||
nm_settings_connection_set_nm_generated (added);
|
||||
else {
|
||||
nm_log_warn (LOGD_SETTINGS, "(%s) Couldn't save generated connection '%s': %s",
|
||||
nm_device_get_iface (device),
|
||||
nm_connection_get_id (connection),
|
||||
|
|
|
|||
|
|
@ -100,6 +100,11 @@ typedef struct {
|
|||
*/
|
||||
gboolean unsaved;
|
||||
|
||||
/* TRUE if the connection was generated by NetworkManager and has
|
||||
* not been saved or modified by the user.
|
||||
*/
|
||||
gboolean nm_generated;
|
||||
|
||||
guint updated_idle_id;
|
||||
|
||||
GSList *pending_auths; /* List of pending authentication requests */
|
||||
|
|
@ -402,6 +407,9 @@ set_unsaved (NMSettingsConnection *self, gboolean now_unsaved)
|
|||
|
||||
if (priv->unsaved != now_unsaved) {
|
||||
priv->unsaved = now_unsaved;
|
||||
if (!priv->unsaved)
|
||||
priv->nm_generated = FALSE;
|
||||
|
||||
g_object_notify (G_OBJECT (self), NM_SETTINGS_CONNECTION_UNSAVED);
|
||||
}
|
||||
}
|
||||
|
|
@ -456,6 +464,8 @@ nm_settings_connection_replace_settings (NMSettingsConnection *self,
|
|||
if (nm_connection_replace_settings_from_connection (NM_CONNECTION (self),
|
||||
new_connection,
|
||||
error)) {
|
||||
priv->nm_generated = FALSE;
|
||||
|
||||
/* Cache the just-updated system secrets in case something calls
|
||||
* nm_connection_clear_secrets() and clears them.
|
||||
*/
|
||||
|
|
@ -1976,6 +1986,39 @@ nm_settings_connection_can_autoconnect (NMSettingsConnection *connection)
|
|||
return TRUE;
|
||||
}
|
||||
|
||||
/**
|
||||
* nm_settings_connection_get_nm_generated:
|
||||
* @connection: an #NMSettingsConnection
|
||||
*
|
||||
* Gets the "nm-generated" flag on @connection.
|
||||
*
|
||||
* A connection is "nm-generated" if it was generated by
|
||||
* nm_device_generate_connection() and then assumed by #NMManager, and
|
||||
* it has not been modified or saved by the user since then. In other
|
||||
* words, an "nm-generated" connection reflects state that is entirely
|
||||
* external to NetworkManager.
|
||||
*/
|
||||
gboolean
|
||||
nm_settings_connection_get_nm_generated (NMSettingsConnection *connection)
|
||||
{
|
||||
return NM_SETTINGS_CONNECTION_GET_PRIVATE (connection)->nm_generated;
|
||||
}
|
||||
|
||||
/**
|
||||
* nm_settings_connection_set_nm_generated:
|
||||
* @connection: an #NMSettingsConnection
|
||||
*
|
||||
* Sets the "nm-generated" flag on @connection; see
|
||||
* nm_settings_connection_get_nm_generated().
|
||||
*/
|
||||
void
|
||||
nm_settings_connection_set_nm_generated (NMSettingsConnection *connection)
|
||||
{
|
||||
NMSettingsConnectionPrivate *priv = NM_SETTINGS_CONNECTION_GET_PRIVATE (connection);
|
||||
|
||||
priv->nm_generated = TRUE;
|
||||
}
|
||||
|
||||
/**************************************************************/
|
||||
|
||||
static void
|
||||
|
|
|
|||
|
|
@ -162,6 +162,9 @@ void nm_settings_connection_set_autoconnect_blocked_reason (NMSettingsConnection
|
|||
|
||||
gboolean nm_settings_connection_can_autoconnect (NMSettingsConnection *connection);
|
||||
|
||||
void nm_settings_connection_set_nm_generated (NMSettingsConnection *connection);
|
||||
gboolean nm_settings_connection_get_nm_generated (NMSettingsConnection *connection);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* NM_SETTINGS_CONNECTION_H */
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue