summary refs log tree commit diff
path: root/src/system-settings
diff options
context:
space:
mode:
Diffstat (limited to 'src/system-settings')
-rw-r--r--src/system-settings/Makefile.in5
-rw-r--r--src/system-settings/nm-default-wired-connection.c2
-rw-r--r--src/system-settings/nm-sysconfig-settings.c62
-rw-r--r--src/system-settings/nm-sysconfig-settings.h2
-rw-r--r--src/system-settings/nm-system-config-interface.c3
-rw-r--r--src/system-settings/nm-system-config-interface.h15
6 files changed, 75 insertions, 14 deletions
diff --git a/src/system-settings/Makefile.in b/src/system-settings/Makefile.in
index 1bc66bac..45f4a414 100644
--- a/src/system-settings/Makefile.in
+++ b/src/system-settings/Makefile.in
@@ -196,6 +196,10 @@ MSGFMT_OPTS = @MSGFMT_OPTS@
 MSGMERGE = @MSGMERGE@
 NM = @NM@
 NMEDIT = @NMEDIT@
+NM_MAJOR_VERSION = @NM_MAJOR_VERSION@
+NM_MICRO_VERSION = @NM_MICRO_VERSION@
+NM_MINOR_VERSION = @NM_MINOR_VERSION@
+NM_VERSION = @NM_VERSION@
 NSS_CFLAGS = @NSS_CFLAGS@
 NSS_LIBS = @NSS_LIBS@
 OBJDUMP = @OBJDUMP@
@@ -210,6 +214,7 @@ PACKAGE_TARNAME = @PACKAGE_TARNAME@
 PACKAGE_URL = @PACKAGE_URL@
 PACKAGE_VERSION = @PACKAGE_VERSION@
 PATH_SEPARATOR = @PATH_SEPARATOR@
+PKGCONFIG_PATH = @PKGCONFIG_PATH@
 PKG_CONFIG = @PKG_CONFIG@
 PKG_CONFIG_LIBDIR = @PKG_CONFIG_LIBDIR@
 PKG_CONFIG_PATH = @PKG_CONFIG_PATH@
diff --git a/src/system-settings/nm-default-wired-connection.c b/src/system-settings/nm-default-wired-connection.c
index 1cda3d9e..0d19dea0 100644
--- a/src/system-settings/nm-default-wired-connection.c
+++ b/src/system-settings/nm-default-wired-connection.c
@@ -163,7 +163,7 @@ constructor (GType type,
 		      NM_SETTING_CONNECTION_AUTOCONNECT, TRUE,
 		      NM_SETTING_CONNECTION_UUID, uuid,
 		      NM_SETTING_CONNECTION_READ_ONLY, priv->read_only,
-		      NM_SETTING_CONNECTION_TIMESTAMP, time (NULL),
+		      NM_SETTING_CONNECTION_TIMESTAMP, (guint64) time (NULL),
 		      NULL);
 
 	g_free (id);
diff --git a/src/system-settings/nm-sysconfig-settings.c b/src/system-settings/nm-sysconfig-settings.c
index d929813f..75ac9879 100644
--- a/src/system-settings/nm-sysconfig-settings.c
+++ b/src/system-settings/nm-sysconfig-settings.c
@@ -19,7 +19,7 @@
  * with this program; if not, write to the Free Software Foundation, Inc.,
  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
  *
- * (C) Copyright 2007 - 2010 Red Hat, Inc.
+ * (C) Copyright 2007 - 2011 Red Hat, Inc.
  * (C) Copyright 2008 Novell, Inc.
  */
 
@@ -480,8 +480,35 @@ connection_removed (NMSettingsConnectionInterface *connection,
                     gpointer user_data)
 {
 	NMSysconfigSettingsPrivate *priv = NM_SYSCONFIG_SETTINGS_GET_PRIVATE (user_data);
+	NMSettingConnection *s_con;
+	GKeyFile *timestamps_file;
+	const char *connection_uuid;
+	char *data;
+	gsize len;
+	GError *error = NULL;
 
+	/* Remove connection from the table */
 	g_hash_table_remove (priv->connections, connection);
+
+	/* Remove timestamp from timestamps database file */
+	s_con = NM_SETTING_CONNECTION (nm_connection_get_setting (NM_CONNECTION (connection), NM_TYPE_SETTING_CONNECTION));
+	g_assert (s_con);
+	connection_uuid = nm_setting_connection_get_uuid (s_con);
+
+	timestamps_file = g_key_file_new ();
+	if (g_key_file_load_from_file (timestamps_file, NM_SYSCONFIG_SETTINGS_TIMESTAMPS_FILE, G_KEY_FILE_KEEP_COMMENTS, NULL)) {
+		g_key_file_remove_key (timestamps_file, "timestamps", connection_uuid, NULL);
+		data = g_key_file_to_data (timestamps_file, &len, &error);
+		if (data) {
+			g_file_set_contents (NM_SYSCONFIG_SETTINGS_TIMESTAMPS_FILE, data, len, &error);
+			g_free (data);
+		}
+		if (error) {
+			nm_log_warn (LOGD_SYS_SET, "error writing timestamps file '%s': %s", NM_SYSCONFIG_SETTINGS_TIMESTAMPS_FILE, error->message);
+			g_error_free (error);
+		}
+	}
+	g_key_file_free (timestamps_file);
 }
 
 static void
@@ -491,6 +518,13 @@ claim_connection (NMSysconfigSettings *self,
 {
 	NMSysconfigSettingsPrivate *priv = NM_SYSCONFIG_SETTINGS_GET_PRIVATE (self);
 
+	NMSettingConnection *s_con;
+	const char *connection_uuid;
+	guint64 timestamp = 0;
+	GKeyFile *timestamps_file;
+	GError *err = NULL;
+	char *tmp_str;
+
 	g_return_if_fail (NM_IS_SYSCONFIG_SETTINGS (self));
 	g_return_if_fail (NM_IS_SETTINGS_CONNECTION_INTERFACE (connection));
 
@@ -498,6 +532,32 @@ claim_connection (NMSysconfigSettings *self,
 		/* A plugin is lying to us. */
 		return;
 
+	/* Read timestamp from database file and store it into connection's object data */
+	s_con = NM_SETTING_CONNECTION (nm_connection_get_setting (NM_CONNECTION (connection), NM_TYPE_SETTING_CONNECTION));
+	g_assert (s_con);
+	connection_uuid = nm_setting_connection_get_uuid (s_con);
+
+	timestamps_file = g_key_file_new ();
+	g_key_file_load_from_file (timestamps_file, NM_SYSCONFIG_SETTINGS_TIMESTAMPS_FILE, G_KEY_FILE_KEEP_COMMENTS, NULL);
+	tmp_str = g_key_file_get_value (timestamps_file, "timestamps", connection_uuid, &err);
+	if (tmp_str) {
+		timestamp = g_ascii_strtoull (tmp_str, NULL, 10);
+		g_free (tmp_str);
+	}
+
+	/* Update connection's timestamp */
+	if (!err) {
+		guint64 *ts_ptr = g_new (guint64, 1);
+
+		*ts_ptr = timestamp;
+		g_object_set_data_full (G_OBJECT (connection), NM_SYSCONFIG_SETTINGS_TIMESTAMP_TAG, ts_ptr, g_free);
+	} else {
+		nm_log_dbg (LOGD_SYS_SET, "failed to read connection timestamp for '%s': (%d) %s",
+		            connection_uuid, err->code, err->message);
+		g_clear_error (&err);
+	}
+	g_key_file_free (timestamps_file);
+
 	g_hash_table_insert (priv->connections, g_object_ref (connection), GINT_TO_POINTER (1));
 	g_signal_connect (connection,
 	                  NM_SETTINGS_CONNECTION_INTERFACE_REMOVED,
diff --git a/src/system-settings/nm-sysconfig-settings.h b/src/system-settings/nm-sysconfig-settings.h
index ae2ba683..8b2622a7 100644
--- a/src/system-settings/nm-sysconfig-settings.h
+++ b/src/system-settings/nm-sysconfig-settings.h
@@ -41,6 +41,8 @@
 #define NM_SYSCONFIG_SETTINGS_GET_CLASS(obj)  (G_TYPE_INSTANCE_GET_CLASS ((obj),  NM_TYPE_SYSCONFIG_SETTINGS, NMSysconfigSettingsClass))
 
 #define NM_SYSCONFIG_SETTINGS_UNMANAGED_SPECS "unmanaged-specs"
+#define NM_SYSCONFIG_SETTINGS_TIMESTAMPS_FILE LOCALSTATEDIR"/lib/NetworkManager/timestamps"
+#define NM_SYSCONFIG_SETTINGS_TIMESTAMP_TAG   "timestamp-tag"
 
 typedef struct {
 	NMSettingsService parent_instance;
diff --git a/src/system-settings/nm-system-config-interface.c b/src/system-settings/nm-system-config-interface.c
index 90fd93ba..9fb34278 100644
--- a/src/system-settings/nm-system-config-interface.c
+++ b/src/system-settings/nm-system-config-interface.c
@@ -53,7 +53,8 @@ interface_init (gpointer g_iface)
 							  "Capabilities",
 							  "Plugin capabilties",
 							  NM_SYSTEM_CONFIG_INTERFACE_CAP_NONE,
-							  NM_SYSTEM_CONFIG_INTERFACE_CAP_LAST - 1,
+							  (  NM_SYSTEM_CONFIG_INTERFACE_CAP_MODIFY_CONNECTIONS
+							   | NM_SYSTEM_CONFIG_INTERFACE_CAP_MODIFY_HOSTNAME),
 							  NM_SYSTEM_CONFIG_INTERFACE_CAP_NONE,
 							  G_PARAM_READABLE));
 
diff --git a/src/system-settings/nm-system-config-interface.h b/src/system-settings/nm-system-config-interface.h
index 3daceb89..d5634aa6 100644
--- a/src/system-settings/nm-system-config-interface.h
+++ b/src/system-settings/nm-system-config-interface.h
@@ -41,15 +41,6 @@ G_BEGIN_DECLS
  */
 GObject * nm_system_config_factory (void);
 
-/* NOTE:
- *   When passing NMConnection objects to NetworkManager, any properties
- * of that NMConnection's NMSetting objects that are secrets must be set as
- * GObject data items on the NMSetting object, _not_ inside the NMSetting
- * object itself.  This is to ensure that the secrets are only given to
- * NetworkManager itself and not exposed to clients like nm-applet that need
- * connection details, but not secrets.
- */
-
 #define NM_TYPE_SYSTEM_CONFIG_INTERFACE      (nm_system_config_interface_get_type ())
 #define NM_SYSTEM_CONFIG_INTERFACE(obj)      (G_TYPE_CHECK_INSTANCE_CAST ((obj), NM_TYPE_SYSTEM_CONFIG_INTERFACE, NMSystemConfigInterface))
 #define NM_IS_SYSTEM_CONFIG_INTERFACE(obj)   (G_TYPE_CHECK_INSTANCE_TYPE ((obj), NM_TYPE_SYSTEM_CONFIG_INTERFACE))
@@ -67,9 +58,11 @@ GObject * nm_system_config_factory (void);
 typedef enum {
 	NM_SYSTEM_CONFIG_INTERFACE_CAP_NONE = 0x00000000,
 	NM_SYSTEM_CONFIG_INTERFACE_CAP_MODIFY_CONNECTIONS = 0x00000001,
-	NM_SYSTEM_CONFIG_INTERFACE_CAP_MODIFY_HOSTNAME = 0x00000002,
+	NM_SYSTEM_CONFIG_INTERFACE_CAP_MODIFY_HOSTNAME = 0x00000002
 
-	NM_SYSTEM_CONFIG_INTERFACE_CAP_LAST = NM_SYSTEM_CONFIG_INTERFACE_CAP_MODIFY_HOSTNAME
+	/* When adding more capabilities, be sure to update the "Capabilities"
+	 * property max value in nm-system-config-interface.c.
+	 */
 } NMSystemConfigInterfaceCapabilities;
 
 typedef enum {