diff --git a/ChangeLog b/ChangeLog index fb036574ad..de5ddfdb1d 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2008-02-24 Dan Williams + + * 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 * libnm-util/nm-setting-wireless.c diff --git a/libnm-util/nm-setting.c b/libnm-util/nm-setting.c index c327c305e2..6d090fd6a6 100644 --- a/libnm-util/nm-setting.c +++ b/libnm-util/nm-setting.c @@ -1,6 +1,9 @@ /* -*- Mode: C; tab-width: 5; indent-tabs-mode: t; c-basic-offset: 5 -*- */ +#include + #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 diff --git a/libnm-util/nm-setting.h b/libnm-util/nm-setting.h index c127b4ddda..91af208a8d 100644 --- a/libnm-util/nm-setting.h +++ b/libnm-util/nm-setting.h @@ -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);