2008-02-24 Dan Williams <dcbw@redhat.com>

* libnm-util/nm-setting.c
	  libnm-util/nm-setting.h
		- (nm_setting_compare): fix 'fuzzy' compare logic; add IGNORE_ID bits;
			fix return value to match nm_connection_compare() meaning



git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@3340 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
This commit is contained in:
Dan Williams 2008-02-25 03:32:43 +00:00
parent 91eb286b27
commit 00a3dfbafa
3 changed files with 27 additions and 8 deletions

View file

@ -1,3 +1,10 @@
2008-02-24 Dan Williams <dcbw@redhat.com>
* libnm-util/nm-setting.c
libnm-util/nm-setting.h
- (nm_setting_compare): fix 'fuzzy' compare logic; add IGNORE_ID bits;
fix return value to match nm_connection_compare() meaning
2008-02-24 Dan Williams <dcbw@redhat.com>
* libnm-util/nm-setting-wireless.c

View file

@ -1,6 +1,9 @@
/* -*- Mode: C; tab-width: 5; indent-tabs-mode: t; c-basic-offset: 5 -*- */
#include <string.h>
#include "nm-setting.h"
#include "nm-setting-connection.h"
#include "nm-utils.h"
G_DEFINE_ABSTRACT_TYPE (NMSetting, nm_setting, G_TYPE_OBJECT)
@ -150,7 +153,7 @@ nm_setting_compare (NMSetting *setting,
{
GParamSpec **property_specs;
guint n_property_specs;
gboolean different;
gint different;
guint i;
g_return_val_if_fail (NM_IS_SETTING (setting), FALSE);
@ -169,12 +172,17 @@ nm_setting_compare (NMSetting *setting,
GValue value1 = { 0 };
GValue value2 = { 0 };
/* Fuzzy compare ignores properties defined with the FUZZY_IGNORE flag */
/* Fuzzy compare ignores secrets and properties defined with the
* FUZZY_IGNORE flag
*/
if ( (flags & COMPARE_FLAGS_FUZZY)
&& (prop_spec->flags & NM_SETTING_PARAM_FUZZY_IGNORE)) {
different = TRUE;
&& (prop_spec->flags & (NM_SETTING_PARAM_FUZZY_IGNORE | NM_SETTING_PARAM_SECRET)))
continue;
if ( (flags & COMPARE_FLAGS_IGNORE_ID)
&& !strcmp (setting->name, NM_SETTING_CONNECTION_SETTING_NAME)
&& !strcmp (prop_spec->name, NM_SETTING_CONNECTION_ID))
continue;
}
g_value_init (&value1, prop_spec->value_type);
g_object_get_property (G_OBJECT (setting), prop_spec->name, &value1);
@ -190,7 +198,7 @@ nm_setting_compare (NMSetting *setting,
g_free (property_specs);
return different;
return different == 0 ? TRUE : FALSE;
}
void

View file

@ -63,12 +63,16 @@ gboolean nm_setting_verify (NMSetting *setting,
typedef enum {
/* Match all attributes exactly */
COMPARE_FLAGS_EXACT = 0x00,
COMPARE_FLAGS_EXACT = 0x00000000,
/* Match only important attributes, like SSID, type, security settings, etc */
COMPARE_FLAGS_FUZZY = 0x01,
COMPARE_FLAGS_FUZZY = 0x00000001,
/* Ignore the connection ID */
COMPARE_FLAGS_IGNORE_ID = 0x00000002,
} NMSettingCompareFlags;
/* Returns TRUE if the connections are the same */
gboolean nm_setting_compare (NMSetting *setting,
NMSetting *other,
NMSettingCompareFlags flags);