summary refs log tree commit diff
path: root/src/settings/plugins/keyfile/nm-keyfile-connection.c
diff options
context:
space:
mode:
authorMichael Biebl <biebl@debian.org>2016-01-20 16:26:51 +0100
committerMichael Biebl <biebl@debian.org>2016-01-20 16:26:51 +0100
commit494f296a3baab08522617b24b1f126d8f9a17502 (patch)
treec8ef32fb0dd1c4ff35a0b38e787abb58692de0cd /src/settings/plugins/keyfile/nm-keyfile-connection.c
parent54f6333410ffd570e62717d9e77c5c987175e397 (diff)
Imported Upstream version 1.1.90 upstream/1.1.90
Diffstat (limited to 'src/settings/plugins/keyfile/nm-keyfile-connection.c')
-rw-r--r--src/settings/plugins/keyfile/nm-keyfile-connection.c30
1 files changed, 26 insertions, 4 deletions
diff --git a/src/settings/plugins/keyfile/nm-keyfile-connection.c b/src/settings/plugins/keyfile/nm-keyfile-connection.c
index 8fb94302..c217de68 100644
--- a/src/settings/plugins/keyfile/nm-keyfile-connection.c
+++ b/src/settings/plugins/keyfile/nm-keyfile-connection.c
@@ -27,12 +27,13 @@
 #include <nm-setting-connection.h>
 #include <nm-utils.h>
 
-#include "nm-system-config-interface.h"
-#include "nm-dbus-glib-types.h"
+#include "nm-default.h"
+#include "nm-settings-plugin.h"
 #include "nm-keyfile-connection.h"
 #include "reader.h"
 #include "writer.h"
-#include "common.h"
+#include "utils.h"
+#include "nm-logging.h"
 
 G_DEFINE_TYPE (NMKeyfileConnection, nm_keyfile_connection, NM_TYPE_SETTINGS_CONNECTION)
 
@@ -88,6 +89,7 @@ nm_keyfile_connection_new (NMConnection *source,
 
 static void
 commit_changes (NMSettingsConnection *connection,
+                NMSettingsConnectionCommitReason commit_reason,
                 NMSettingsConnectionCommitFunc callback,
                 gpointer user_data)
 {
@@ -96,6 +98,8 @@ commit_changes (NMSettingsConnection *connection,
 
 	if (!nm_keyfile_plugin_write_connection (NM_CONNECTION (connection),
 	                                         nm_settings_connection_get_filename (connection),
+	                                         NM_FLAGS_ALL (commit_reason,   NM_SETTINGS_CONNECTION_COMMIT_REASON_USER_ACTION
+	                                                                      | NM_SETTINGS_CONNECTION_COMMIT_REASON_ID_CHANGED),
 	                                         &path,
 	                                         &error)) {
 		callback (connection, error, user_data);
@@ -104,10 +108,28 @@ commit_changes (NMSettingsConnection *connection,
 	}
 
 	/* Update the filename if it changed */
-	if (path)
+	if (   path
+	    && g_strcmp0 (path, nm_settings_connection_get_filename (connection)) != 0) {
+		gs_free char *old_path = g_strdup (nm_settings_connection_get_filename (connection));
+
 		nm_settings_connection_set_filename (connection, path);
+		if (old_path) {
+			nm_log_info (LOGD_SETTINGS, "keyfile: update "NM_KEYFILE_CONNECTION_LOG_FMT" and rename from \"%s\"",
+			             NM_KEYFILE_CONNECTION_LOG_ARG (connection),
+			             old_path);
+		} else {
+			nm_log_info (LOGD_SETTINGS, "keyfile: update "NM_KEYFILE_CONNECTION_LOG_FMT" and persist connection",
+			             NM_KEYFILE_CONNECTION_LOG_ARG (connection));
+		}
+	} else {
+		nm_log_info (LOGD_SETTINGS, "keyfile: update "NM_KEYFILE_CONNECTION_LOG_FMT,
+		             NM_KEYFILE_CONNECTION_LOG_ARG (connection));
+	}
+
+	g_free (path);
 
 	NM_SETTINGS_CONNECTION_CLASS (nm_keyfile_connection_parent_class)->commit_changes (connection,
+	                                                                                   commit_reason,
 	                                                                                   callback,
 	                                                                                   user_data);
 }