NetworkManager r3336 - in trunk: . libnm-util src



Author: dcbw
Date: Thu Feb 21 04:34:34 2008
New Revision: 3336
URL: http://svn.gnome.org/viewvc/NetworkManager?rev=3336&view=rev

Log:
2008-02-20  Dan Williams  <dcbw redhat com>

	* libnm-util/nm-connection.c
	  libnm-util/nm-connection.h
		- (nm_connection_compare): accept compare flags and pass them to the
			setting compare function

	* libnm-util/nm-setting.c
	  libnm-util/nm-setting.h
		- (nm_setting_compare): accept compare flags; ignore properties that are
			marked fuzzy

	* libnm-util/nm-setting-connection.c
	  libnm-util/nm-setting-wireless.c
	  libnm-util/nm-setting-ppp.c
	  libnm-util/nm-setting-wired.c
		- Mark some setting properties as ignorable when doing a fuzzy compare

	* src/nm-device.c
		- (device_activation_precheck): use exact compare



Modified:
   trunk/ChangeLog
   trunk/libnm-util/nm-connection.c
   trunk/libnm-util/nm-connection.h
   trunk/libnm-util/nm-setting-connection.c
   trunk/libnm-util/nm-setting-ppp.c
   trunk/libnm-util/nm-setting-wired.c
   trunk/libnm-util/nm-setting-wireless.c
   trunk/libnm-util/nm-setting.c
   trunk/libnm-util/nm-setting.h
   trunk/src/nm-device.c

Modified: trunk/libnm-util/nm-connection.c
==============================================================================
--- trunk/libnm-util/nm-connection.c	(original)
+++ trunk/libnm-util/nm-connection.c	Thu Feb 21 04:34:34 2008
@@ -205,6 +205,7 @@
 typedef struct {
 	NMConnection *other;
 	gboolean failed;
+	NMSettingCompareFlags flags;
 } CompareConnectionInfo;
 
 static void
@@ -219,16 +220,18 @@
 
 	other_setting = nm_connection_get_setting (info->other, G_OBJECT_TYPE (setting));
 	if (other_setting)
-		info->failed = nm_setting_compare (setting, other_setting) ? FALSE : TRUE;
+		info->failed = nm_setting_compare (setting, other_setting, info->flags) ? FALSE : TRUE;
 	else
 		info->failed = TRUE;
 }
 
 gboolean
-nm_connection_compare (NMConnection *connection, NMConnection *other)
+nm_connection_compare (NMConnection *connection,
+                       NMConnection *other,
+                       NMSettingCompareFlags flags)
 {
 	NMConnectionPrivate *priv;
-	CompareConnectionInfo info = { other, FALSE };
+	CompareConnectionInfo info = { other, FALSE, flags };
 
 	if (!connection && !other)
 		return TRUE;

Modified: trunk/libnm-util/nm-connection.h
==============================================================================
--- trunk/libnm-util/nm-connection.h	(original)
+++ trunk/libnm-util/nm-connection.h	Thu Feb 21 04:34:34 2008
@@ -53,7 +53,8 @@
 									 GHashTable *new_settings);
 
 gboolean      nm_connection_compare       (NMConnection *connection,
-								   NMConnection *other);
+                                           NMConnection *other,
+                                           NMSettingCompareFlags flags);
 
 gboolean      nm_connection_verify        (NMConnection *connection);
 

Modified: trunk/libnm-util/nm-setting-connection.c
==============================================================================
--- trunk/libnm-util/nm-setting-connection.c	(original)
+++ trunk/libnm-util/nm-setting-connection.c	Thu Feb 21 04:34:34 2008
@@ -144,7 +144,7 @@
 						  "ID",
 						  "User-readable connection identifier/name",
 						  NULL,
-						  G_PARAM_READWRITE | NM_SETTING_PARAM_SERIALIZE));
+						  G_PARAM_READWRITE | NM_SETTING_PARAM_SERIALIZE | NM_SETTING_PARAM_FUZZY_IGNORE));
 
 	g_object_class_install_property
 		(object_class, PROP_TYPE,
@@ -160,7 +160,7 @@
 						   "Autoconnect",
 						   "Connection autoconnect",
 						   FALSE,
-						   G_PARAM_READWRITE | NM_SETTING_PARAM_SERIALIZE));
+						   G_PARAM_READWRITE | NM_SETTING_PARAM_SERIALIZE | NM_SETTING_PARAM_FUZZY_IGNORE));
 
 	g_object_class_install_property
 		(object_class, PROP_TIMESTAMP,
@@ -168,7 +168,7 @@
 						  "Timestamp",
 						  "Connection timestamp",
 						  0, G_MAXUINT64, 0,
-						  G_PARAM_READWRITE | NM_SETTING_PARAM_SERIALIZE));
+						  G_PARAM_READWRITE | NM_SETTING_PARAM_SERIALIZE | NM_SETTING_PARAM_FUZZY_IGNORE));
 
 	g_object_class_install_property
 		(object_class, PROP_LOCKDOWN,

Modified: trunk/libnm-util/nm-setting-ppp.c
==============================================================================
--- trunk/libnm-util/nm-setting-ppp.c	(original)
+++ trunk/libnm-util/nm-setting-ppp.c	Thu Feb 21 04:34:34 2008
@@ -226,7 +226,7 @@
 						   "No BSD compression",
 						   "No BSD compression",
 						   FALSE,
-						   G_PARAM_READWRITE | NM_SETTING_PARAM_SERIALIZE));
+						   G_PARAM_READWRITE | NM_SETTING_PARAM_SERIALIZE | NM_SETTING_PARAM_FUZZY_IGNORE));
 
 	g_object_class_install_property
 		(object_class, PROP_NODEFLATE,
@@ -234,7 +234,7 @@
 						   "No deflate",
 						   "No deflate",
 						   FALSE,
-						   G_PARAM_READWRITE | NM_SETTING_PARAM_SERIALIZE));
+						   G_PARAM_READWRITE | NM_SETTING_PARAM_SERIALIZE | NM_SETTING_PARAM_FUZZY_IGNORE));
 
 	g_object_class_install_property
 		(object_class, PROP_REQUIRE_MPPE,
@@ -290,7 +290,7 @@
 						"Baud",
 						"Baud",
 						0, G_MAXUINT32, 0,
-						G_PARAM_READWRITE | NM_SETTING_PARAM_SERIALIZE));
+						G_PARAM_READWRITE | NM_SETTING_PARAM_SERIALIZE | NM_SETTING_PARAM_FUZZY_IGNORE));
 
 	g_object_class_install_property
 		(object_class, PROP_MRU,
@@ -306,7 +306,7 @@
 						"MTU",
 						"MTU",
 						0, G_MAXUINT32, 0,
-						G_PARAM_READWRITE | NM_SETTING_PARAM_SERIALIZE));
+						G_PARAM_READWRITE | NM_SETTING_PARAM_SERIALIZE | NM_SETTING_PARAM_FUZZY_IGNORE));
 
 	g_object_class_install_property
 		(object_class, PROP_LCP_ECHO_FAILURE,
@@ -314,7 +314,7 @@
 						"LCP echo failure",
 						"LCP echo failure",
 						0, G_MAXUINT32, 0,
-						G_PARAM_READWRITE | NM_SETTING_PARAM_SERIALIZE));
+						G_PARAM_READWRITE | NM_SETTING_PARAM_SERIALIZE | NM_SETTING_PARAM_FUZZY_IGNORE));
 
 	g_object_class_install_property
 		(object_class, PROP_LCP_ECHO_INTERVAL,
@@ -322,5 +322,5 @@
 						"LCP echo interval",
 						"LCP echo interval",
 						0, G_MAXUINT32, 0,
-						G_PARAM_READWRITE | NM_SETTING_PARAM_SERIALIZE));
+						G_PARAM_READWRITE | NM_SETTING_PARAM_SERIALIZE | NM_SETTING_PARAM_FUZZY_IGNORE));
 }

Modified: trunk/libnm-util/nm-setting-wired.c
==============================================================================
--- trunk/libnm-util/nm-setting-wired.c	(original)
+++ trunk/libnm-util/nm-setting-wired.c	Thu Feb 21 04:34:34 2008
@@ -195,6 +195,6 @@
 						"MTU",
 						"MTU",
 						0, G_MAXUINT32, 0,
-						G_PARAM_READWRITE | NM_SETTING_PARAM_SERIALIZE | G_PARAM_CONSTRUCT));
+						G_PARAM_READWRITE | NM_SETTING_PARAM_SERIALIZE | G_PARAM_CONSTRUCT | NM_SETTING_PARAM_FUZZY_IGNORE));
 }
 

Modified: trunk/libnm-util/nm-setting-wireless.c
==============================================================================
--- trunk/libnm-util/nm-setting-wireless.c	(original)
+++ trunk/libnm-util/nm-setting-wireless.c	Thu Feb 21 04:34:34 2008
@@ -475,7 +475,7 @@
 						"Rate",
 						"Rate",
 						0, G_MAXUINT32, 0,
-						G_PARAM_READWRITE | NM_SETTING_PARAM_SERIALIZE));
+						G_PARAM_READWRITE | NM_SETTING_PARAM_SERIALIZE | NM_SETTING_PARAM_FUZZY_IGNORE));
 
 	g_object_class_install_property
 		(object_class, PROP_TX_POWER,
@@ -483,7 +483,7 @@
 						"TX Power",
 						"TX Power",
 						0, G_MAXUINT32, 0,
-						G_PARAM_READWRITE | NM_SETTING_PARAM_SERIALIZE));
+						G_PARAM_READWRITE | NM_SETTING_PARAM_SERIALIZE | NM_SETTING_PARAM_FUZZY_IGNORE));
 
 	g_object_class_install_property
 		(object_class, PROP_MAC_ADDRESS,
@@ -507,7 +507,7 @@
 						"MTU",
 						"MTU",
 						0, G_MAXUINT32, 0,
-						G_PARAM_READWRITE | NM_SETTING_PARAM_SERIALIZE));
+						G_PARAM_READWRITE | NM_SETTING_PARAM_SERIALIZE | NM_SETTING_PARAM_FUZZY_IGNORE));
 
 	g_object_class_install_property
 		(object_class, PROP_SEC,

Modified: trunk/libnm-util/nm-setting.c
==============================================================================
--- trunk/libnm-util/nm-setting.c	(original)
+++ trunk/libnm-util/nm-setting.c	Thu Feb 21 04:34:34 2008
@@ -144,7 +144,9 @@
 }
 
 gboolean
-nm_setting_compare (NMSetting *setting, NMSetting *other)
+nm_setting_compare (NMSetting *setting,
+                    NMSetting *other,
+                    NMSettingCompareFlags flags)
 {
 	GParamSpec **property_specs;
 	guint n_property_specs;
@@ -167,6 +169,13 @@
 		GValue value1 = { 0 };
 		GValue value2 = { 0 };
 
+		/* Fuzzy compare ignores properties defined with the FUZZY_IGNORE flag */
+		if (   (flags & COMPARE_FLAGS_FUZZY)
+		    && (prop_spec->flags & NM_SETTING_PARAM_FUZZY_IGNORE)) {
+			different = TRUE;
+			continue;
+		}
+
 		g_value_init (&value1, prop_spec->value_type);
 		g_object_get_property (G_OBJECT (setting), prop_spec->name, &value1);
 

Modified: trunk/libnm-util/nm-setting.h
==============================================================================
--- trunk/libnm-util/nm-setting.h	(original)
+++ trunk/libnm-util/nm-setting.h	Thu Feb 21 04:34:34 2008
@@ -15,9 +15,10 @@
 #define NM_IS_SETTING_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((obj), NM_TYPE_SETTING))
 #define NM_SETTING_GET_CLASS(obj)  (G_TYPE_INSTANCE_GET_CLASS ((obj), NM_TYPE_SETTING, NMSettingClass))
 
-#define NM_SETTING_PARAM_SERIALIZE (1 << (0 + G_PARAM_USER_SHIFT))
-#define NM_SETTING_PARAM_REQUIRED  (1 << (1 + G_PARAM_USER_SHIFT))
-#define NM_SETTING_PARAM_SECRET    (1 << (2 + G_PARAM_USER_SHIFT))
+#define NM_SETTING_PARAM_SERIALIZE    (1 << (0 + G_PARAM_USER_SHIFT))
+#define NM_SETTING_PARAM_REQUIRED     (1 << (1 + G_PARAM_USER_SHIFT))
+#define NM_SETTING_PARAM_SECRET       (1 << (2 + G_PARAM_USER_SHIFT))
+#define NM_SETTING_PARAM_FUZZY_IGNORE (1 << (3 + G_PARAM_USER_SHIFT))
 
 #define NM_SETTING_NAME "name"
 
@@ -59,8 +60,18 @@
 gboolean    nm_setting_verify        (NMSetting *setting,
 							   GSList    *all_settings);
 
+
+typedef enum {
+	/* Match all attributes exactly */
+	COMPARE_FLAGS_EXACT = 0x00,
+
+	/* Match only important attributes, like SSID, type, security settings, etc */
+	COMPARE_FLAGS_FUZZY = 0x01,
+} NMSettingCompareFlags;
+
 gboolean    nm_setting_compare       (NMSetting *setting,
-							   NMSetting *other);
+                                      NMSetting *other,
+                                      NMSettingCompareFlags flags);
 
 void        nm_setting_enumerate_values (NMSetting *setting,
                                          NMSettingValueIterFn func,

Modified: trunk/src/nm-device.c
==============================================================================
--- trunk/src/nm-device.c	(original)
+++ trunk/src/nm-device.c	Thu Feb 21 04:34:34 2008
@@ -1154,8 +1154,9 @@
 	if (!nm_device_is_activating (self))
 		return TRUE;
 
+	// FIXME: why not just check connection path & service?
 	current_connection = nm_act_request_get_connection (nm_device_get_act_request (self));
-	if (nm_connection_compare (connection, current_connection)) {
+	if (nm_connection_compare (connection, current_connection, COMPARE_FLAGS_EXACT)) {
 		/* Already activating or activated with the same connection */
 		g_set_error (error,
 		             NM_DEVICE_INTERFACE_ERROR,



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]