core: add "nm-generated-assumed" flag to NMSettingsConnection

NM_SETTINGS_CONNECTION_FLAGS_NM_GENERATED_ASSUMED is a special kind of
NM_SETTINGS_CONNECTION_FLAGS_NM_GENERATED, that was generated for
connection assumption.

At the moment, the flag is used identical to NM_GENERATED. Later,
NM_GENERATED will get a slightly different meaning.

Signed-off-by: Thomas Haller <thaller@redhat.com>
This commit is contained in:
Thomas Haller 2014-08-18 21:20:56 +02:00
parent e5c719c0c0
commit 87739dbdf4
3 changed files with 31 additions and 5 deletions

View file

@ -1561,9 +1561,12 @@ get_existing_connection (NMManager *manager, NMDevice *device)
nm_connection_get_id (connection));
added = nm_settings_add_connection (priv->settings, connection, FALSE, &error);
if (added)
nm_settings_connection_set_flags (NM_SETTINGS_CONNECTION (added), NM_SETTINGS_CONNECTION_FLAGS_NM_GENERATED, TRUE);
else {
if (added) {
nm_settings_connection_set_flags (NM_SETTINGS_CONNECTION (added),
NM_SETTINGS_CONNECTION_FLAGS_NM_GENERATED |
NM_SETTINGS_CONNECTION_FLAGS_NM_GENERATED_ASSUMED,
TRUE);
} else {
nm_log_warn (LOGD_SETTINGS, "(%s) Couldn't save generated connection '%s': %s",
nm_device_get_iface (device),
nm_connection_get_id (connection),

View file

@ -405,7 +405,8 @@ set_unsaved (NMSettingsConnection *self, gboolean now_unsaved)
flags |= NM_SETTINGS_CONNECTION_FLAGS_UNSAVED;
else {
flags &= ~(NM_SETTINGS_CONNECTION_FLAGS_UNSAVED |
NM_SETTINGS_CONNECTION_FLAGS_NM_GENERATED);
NM_SETTINGS_CONNECTION_FLAGS_NM_GENERATED |
NM_SETTINGS_CONNECTION_FLAGS_NM_GENERATED_ASSUMED);
}
nm_settings_connection_set_flags_all (self, flags);
}
@ -457,7 +458,9 @@ nm_settings_connection_replace_settings (NMSettingsConnection *self,
g_signal_handlers_block_by_func (self, G_CALLBACK (changed_cb), GUINT_TO_POINTER (TRUE));
nm_connection_replace_settings_from_connection (NM_CONNECTION (self), new_connection);
nm_settings_connection_set_flags (self, NM_SETTINGS_CONNECTION_FLAGS_NM_GENERATED, FALSE);
nm_settings_connection_set_flags (self,
NM_SETTINGS_CONNECTION_FLAGS_NM_GENERATED | NM_SETTINGS_CONNECTION_FLAGS_NM_GENERATED_ASSUMED,
FALSE);
/* Cache the just-updated system secrets in case something calls
* nm_connection_clear_secrets() and clears them.
@ -2012,6 +2015,21 @@ nm_settings_connection_get_nm_generated (NMSettingsConnection *connection)
return NM_FLAGS_HAS (nm_settings_connection_get_flags (connection), NM_SETTINGS_CONNECTION_FLAGS_NM_GENERATED);
}
/**
* nm_settings_connection_get_nm_generated_assumed:
* @connection: an #NMSettingsConnection
*
* Gets the "nm-generated-assumed" flag on @connection.
*
* The connection is a generated connection especially
* generated for connection assumption.
*/
gboolean
nm_settings_connection_get_nm_generated_assumed (NMSettingsConnection *connection)
{
return NM_FLAGS_HAS (nm_settings_connection_get_flags (connection), NM_SETTINGS_CONNECTION_FLAGS_NM_GENERATED_ASSUMED);
}
/**************************************************************/
static void

View file

@ -58,6 +58,9 @@ G_BEGIN_DECLS
* @NM_SETTINGS_CONNECTION_FLAGS_NM_GENERATED: A connection is "nm-generated" if
* it was generated by NetworkManger. If the connection gets modified or saved
* by the user, the flag gets cleared. A nm-generated is implicitly unsaved.
* @NM_SETTINGS_CONNECTION_FLAGS_NM_GENERATED_ASSUMED: A special kind of "nm-generated"
* connection that was specifically created for connection assumption. "nm-generated-assumed"
* implies "nm-generated".
* @NM_SETTINGS_CONNECTION_FLAGS_ALL: special mask, for all known flags
*
* #NMSettingsConnection flags.
@ -67,6 +70,7 @@ typedef enum
NM_SETTINGS_CONNECTION_FLAGS_NONE = 0x00,
NM_SETTINGS_CONNECTION_FLAGS_UNSAVED = 0x01,
NM_SETTINGS_CONNECTION_FLAGS_NM_GENERATED = 0x02,
NM_SETTINGS_CONNECTION_FLAGS_NM_GENERATED_ASSUMED = 0x04,
__NM_SETTINGS_CONNECTION_FLAGS_LAST,
NM_SETTINGS_CONNECTION_FLAGS_ALL = ((__NM_SETTINGS_CONNECTION_FLAGS_LAST - 1) << 1) - 1,
@ -190,6 +194,7 @@ void nm_settings_connection_set_autoconnect_blocked_reason (NMSettingsConnection
gboolean nm_settings_connection_can_autoconnect (NMSettingsConnection *connection);
gboolean nm_settings_connection_get_nm_generated (NMSettingsConnection *connection);
gboolean nm_settings_connection_get_nm_generated_assumed (NMSettingsConnection *connection);
G_END_DECLS