libnm-util: deprecate 'security' property of '802-11-wireless' setting

'security' property is redundant, because the security restrictions are easily
recognized by the presence of '802-11-wireless-security' in a Wi-Fi connection.
The setting has to be present anyway, but we also had to set and check whether
the value in 'security' matches the security setting.
Following the KISS principle, it is best not to use the 'security' property
altogether.
This commit is contained in:
Jiří Klimeš 2013-08-27 16:11:30 +02:00
parent 284cce0405
commit 0185e8371f
2 changed files with 13 additions and 23 deletions

View file

@ -588,6 +588,9 @@ nm_setting_wireless_get_mtu (NMSettingWireless *setting)
* @setting: the #NMSettingWireless
*
* Returns: the #NMSettingWireless:security property of the setting
*
* Deprecated: 0.9.10: No longer used. Security rescrictions are recognized by
* the presence of NM_SETTING_WIRELESS_SECURITY_SETTING_NAME in the connection.
**/
const char *
nm_setting_wireless_get_security (NMSettingWireless *setting)
@ -687,15 +690,6 @@ nm_setting_wireless_get_seen_bssid (NMSettingWireless *setting,
return (const char *) g_slist_nth_data (NM_SETTING_WIRELESS_GET_PRIVATE (setting)->seen_bssids, i);
}
static gint
find_setting_by_name (gconstpointer a, gconstpointer b)
{
NMSetting *setting = NM_SETTING (a);
const char *str = (const char *) b;
return strcmp (nm_setting_get_name (setting), str);
}
static gboolean
verify (NMSetting *setting, GSList *all_settings, GError **error)
{
@ -819,17 +813,6 @@ verify (NMSetting *setting, GSList *all_settings, GError **error)
}
}
if ( priv->security
&& !g_slist_find_custom (all_settings, priv->security, find_setting_by_name)) {
g_set_error (error,
NM_SETTING_WIRELESS_ERROR,
NM_SETTING_WIRELESS_ERROR_MISSING_SECURITY_SETTING,
_("'%s' setting is required for the connection when the property is set"),
priv->security);
g_prefix_error (error, "%s.%s: ", NM_SETTING_WIRELESS_SETTING_NAME, NM_SETTING_WIRELESS_SEC);
return FALSE;
}
return TRUE;
}
@ -974,7 +957,7 @@ get_property (GObject *object, guint prop_id,
g_value_set_boxed (value, NM_SETTING_WIRELESS_GET_PRIVATE (setting)->seen_bssids);
break;
case PROP_SEC:
g_value_set_string (value, nm_setting_wireless_get_security (setting));
g_value_set_string (value, NM_SETTING_WIRELESS_GET_PRIVATE (setting)->security);
break;
case PROP_HIDDEN:
g_value_set_boolean (value, nm_setting_wireless_get_hidden (setting));
@ -1231,6 +1214,9 @@ nm_setting_wireless_class_init (NMSettingWirelessClass *setting_class)
* If the wireless connection has any security restrictions, like 802.1x,
* WEP, or WPA, set this property to '802-11-wireless-security' and ensure
* the connection contains a valid 802-11-wireless-security setting.
*
* Deprecated: 0.9.10: No longer used. Security rescrictions are recognized by
* the presence of NM_SETTING_WIRELESS_SECURITY_SETTING_NAME in the connection.
**/
g_object_class_install_property
(object_class, PROP_SEC,

View file

@ -75,9 +75,11 @@ GQuark nm_setting_wireless_error_quark (void);
#define NM_SETTING_WIRELESS_MAC_ADDRESS_BLACKLIST "mac-address-blacklist"
#define NM_SETTING_WIRELESS_MTU "mtu"
#define NM_SETTING_WIRELESS_SEEN_BSSIDS "seen-bssids"
#define NM_SETTING_WIRELESS_SEC "security"
#define NM_SETTING_WIRELESS_HIDDEN "hidden"
/* Deprecated */
#define NM_SETTING_WIRELESS_SEC "security"
/**
* NM_SETTING_WIRELESS_MODE_ADHOC:
*
@ -141,7 +143,6 @@ void nm_setting_wireless_remove_mac_blacklist_item (NMSettingWire
guint32 idx);
guint32 nm_setting_wireless_get_mtu (NMSettingWireless *setting);
const char *nm_setting_wireless_get_security (NMSettingWireless *setting);
gboolean nm_setting_wireless_get_hidden (NMSettingWireless *setting);
gboolean nm_setting_wireless_add_seen_bssid (NMSettingWireless *setting,
@ -158,6 +159,9 @@ gboolean nm_setting_wireless_ap_security_compatible (NMSettingWireless
NM80211ApSecurityFlags ap_rsn,
NM80211Mode ap_mode);
/* Deprecated */
G_DEPRECATED const char *nm_setting_wireless_get_security (NMSettingWireless *setting);
G_END_DECLS
#endif /* NM_SETTING_WIRELESS_H */