Commit a5ac95ca authored by Dan Winship's avatar Dan Winship

libnm-core: drop previously-deprecated NMSetting properties

Drop the NMSetting properties that were marked deprecated in
libnm-util in 0.9.10, but use nm_setting_class_add_dbus_property() to
deal with them appropriately when serializing/deserializing.
parent 002b19f4
......@@ -71,8 +71,6 @@ typedef struct {
char *apn; /* NULL for dynamic */
char *network_id; /* for manual registration or NULL for automatic */
int network_type; /* One of the NM_SETTING_GSM_NETWORK_TYPE_* */
guint32 allowed_bands; /* A bitfield of NM_SETTING_GSM_BAND_* */
char *pin;
NMSettingSecretFlags pin_flags;
......@@ -88,10 +86,8 @@ enum {
PROP_PASSWORD_FLAGS,
PROP_APN,
PROP_NETWORK_ID,
PROP_NETWORK_TYPE,
PROP_PIN,
PROP_PIN_FLAGS,
PROP_ALLOWED_BANDS,
PROP_HOME_ONLY,
LAST_PROP
......@@ -423,12 +419,6 @@ set_property (GObject *object, guint prop_id,
if (tmp)
priv->network_id = g_strstrip (tmp);
break;
case PROP_NETWORK_TYPE:
priv->network_type = g_value_get_int (value);
break;
case PROP_ALLOWED_BANDS:
priv->allowed_bands = g_value_get_uint (value);
break;
case PROP_PIN:
g_free (priv->pin);
priv->pin = g_value_dup_string (value);
......@@ -470,12 +460,6 @@ get_property (GObject *object, guint prop_id,
case PROP_NETWORK_ID:
g_value_set_string (value, nm_setting_gsm_get_network_id (setting));
break;
case PROP_NETWORK_TYPE:
g_value_set_int (value, NM_SETTING_GSM_GET_PRIVATE (setting)->network_type);
break;
case PROP_ALLOWED_BANDS:
g_value_set_uint (value, NM_SETTING_GSM_GET_PRIVATE (setting)->allowed_bands);
break;
case PROP_PIN:
g_value_set_string (value, nm_setting_gsm_get_pin (setting));
break;
......@@ -600,42 +584,6 @@ nm_setting_gsm_class_init (NMSettingGsmClass *setting_class)
G_PARAM_READWRITE |
G_PARAM_STATIC_STRINGS));
/**
* NMSettingGsm:network-type:
*
* (Unused)
*
* Deprecated: 0.9.10: No longer used. Network type setting should be done
* by talking to ModemManager directly.
**/
g_object_class_install_property
(object_class, PROP_NETWORK_TYPE,
g_param_spec_int (NM_SETTING_GSM_NETWORK_TYPE, "", "",
-1 /* NM_SETTING_GSM_NETWORK_TYPE_ANY */,
5 /* NM_SETTING_GSM_NETWORK_TYPE_4G */,
-1 /* NM_SETTING_GSM_NETWORK_TYPE_ANY */,
G_PARAM_READWRITE |
G_PARAM_CONSTRUCT |
G_PARAM_STATIC_STRINGS));
/**
* NMSettingGsm:allowed-bands:
*
* (Unused)
*
* Deprecated: 0.9.10: No longer used. Band setting should be done by
* talking to ModemManager directly.
**/
g_object_class_install_property
(object_class, PROP_ALLOWED_BANDS,
g_param_spec_uint (NM_SETTING_GSM_ALLOWED_BANDS, "", "",
0 /* NM_SETTING_GSM_BAND_UNKNOWN */,
0x3fff /* NM_SETTING_GSM_BANDS_MAX */,
1 /* NM_SETTING_GSM_BAND_ANY */,
G_PARAM_READWRITE |
G_PARAM_CONSTRUCT |
G_PARAM_STATIC_STRINGS));
/**
* NMSettingGsm:pin:
*
......@@ -677,4 +625,12 @@ nm_setting_gsm_class_init (NMSettingGsmClass *setting_class)
FALSE,
G_PARAM_READWRITE |
G_PARAM_STATIC_STRINGS));
/* Ignore incoming deprecated properties */
_nm_setting_class_add_dbus_only_property (parent_class, "allowed-bands",
G_TYPE_UINT,
NULL, NULL);
_nm_setting_class_add_dbus_only_property (parent_class, "network-type",
G_TYPE_INT,
NULL, NULL);
}
......@@ -69,10 +69,6 @@ GQuark nm_setting_gsm_error_quark (void);
#define NM_SETTING_GSM_PIN_FLAGS "pin-flags"
#define NM_SETTING_GSM_HOME_ONLY "home-only"
/* Deprecated */
#define NM_SETTING_GSM_ALLOWED_BANDS "allowed-bands"
#define NM_SETTING_GSM_NETWORK_TYPE "network-type"
typedef struct {
NMSetting parent;
} NMSettingGsm;
......
......@@ -81,7 +81,6 @@ typedef struct {
GSList *mac_address_blacklist;
guint32 mtu;
GSList *seen_bssids;
char *security;
gboolean hidden;
} NMSettingWirelessPrivate;
......@@ -99,7 +98,6 @@ enum {
PROP_MAC_ADDRESS_BLACKLIST,
PROP_MTU,
PROP_SEEN_BSSIDS,
PROP_SEC,
PROP_HIDDEN,
LAST_PROP
......@@ -824,6 +822,19 @@ verify (NMSetting *setting, GSList *all_settings, GError **error)
return TRUE;
}
static gboolean
nm_setting_wireless_get_security (NMSetting *setting,
NMConnection *connection,
const char *property_name,
GValue *value)
{
if (nm_connection_get_setting_wireless_security (connection)) {
g_value_set_string (value, NM_SETTING_WIRELESS_SECURITY_SETTING_NAME);
return TRUE;
} else
return FALSE;
}
static void
nm_setting_wireless_init (NMSettingWireless *setting)
{
......@@ -836,7 +847,6 @@ finalize (GObject *object)
g_free (priv->mode);
g_free (priv->band);
g_free (priv->security);
if (priv->ssid)
g_byte_array_free (priv->ssid, TRUE);
......@@ -907,10 +917,6 @@ set_property (GObject *object, guint prop_id,
g_slist_free_full (priv->seen_bssids, g_free);
priv->seen_bssids = g_value_dup_boxed (value);
break;
case PROP_SEC:
g_free (priv->security);
priv->security = g_value_dup_string (value);
break;
case PROP_HIDDEN:
priv->hidden = g_value_get_boolean (value);
break;
......@@ -963,9 +969,6 @@ get_property (GObject *object, guint prop_id,
case PROP_SEEN_BSSIDS:
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_PRIVATE (setting)->security);
break;
case PROP_HIDDEN:
g_value_set_boolean (value, nm_setting_wireless_get_hidden (setting));
break;
......@@ -1171,22 +1174,6 @@ nm_setting_wireless_class_init (NMSettingWirelessClass *setting_class)
NM_SETTING_PARAM_FUZZY_IGNORE |
G_PARAM_STATIC_STRINGS));
/**
* NMSettingWireless:security:
*
* (Unused)
*
* Deprecated: 0.9.10: No longer used. Security restrictions are recognized
* by the presence of a #NMSettingWirelessSecurity setting in the
* connection.
**/
g_object_class_install_property
(object_class, PROP_SEC,
g_param_spec_string (NM_SETTING_WIRELESS_SEC, "", "",
NULL,
G_PARAM_READWRITE |
G_PARAM_STATIC_STRINGS));
/**
* NMSettingWireless:hidden:
*
......@@ -1202,4 +1189,8 @@ nm_setting_wireless_class_init (NMSettingWirelessClass *setting_class)
FALSE,
G_PARAM_READWRITE |
G_PARAM_STATIC_STRINGS));
/* Compatibility for deprecated property */
_nm_setting_class_add_dbus_only_property (parent_class, "security", G_TYPE_STRING,
nm_setting_wireless_get_security, NULL);
}
......@@ -78,9 +78,6 @@ GQuark nm_setting_wireless_error_quark (void);
#define NM_SETTING_WIRELESS_SEEN_BSSIDS "seen-bssids"
#define NM_SETTING_WIRELESS_HIDDEN "hidden"
/* Deprecated */
#define NM_SETTING_WIRELESS_SEC "security"
/**
* NM_SETTING_WIRELESS_MODE_ADHOC:
*
......
......@@ -771,6 +771,60 @@ test_connection_to_dbus_setting_name (void)
g_object_unref (connection);
}
static void
test_connection_to_dbus_deprecated_props (void)
{
NMConnection *connection;
NMSetting *s_wireless;
GByteArray *ssid;
NMSettingWirelessSecurity *s_wsec;
GHashTable *hash, *wireless_hash;
GValue *sec_val;
connection = nmtst_create_minimal_connection ("test-connection-to-dbus-deprecated-props",
NULL,
NM_SETTING_WIRELESS_SETTING_NAME,
NULL);
s_wireless = nm_setting_wireless_new ();
ssid = g_byte_array_new ();
g_byte_array_append (ssid, (const guint8 *) "1234567", 7);
g_object_set (s_wireless,
NM_SETTING_WIRELESS_SSID, ssid,
NULL);
g_byte_array_unref (ssid);
nm_connection_add_setting (connection, s_wireless);
/* Hash should not have an 802-11-wireless.security property */
hash = nm_connection_to_dbus (connection, NM_CONNECTION_SERIALIZE_ALL);
g_assert (hash != NULL);
wireless_hash = g_hash_table_lookup (hash, NM_SETTING_WIRELESS_SETTING_NAME);
g_assert (wireless_hash != NULL);
sec_val = g_hash_table_lookup (wireless_hash, "security");
g_assert (sec_val == NULL);
g_hash_table_destroy (hash);
/* Now add an NMSettingWirelessSecurity and try again */
s_wsec = make_test_wsec_setting ("test-connection-to-dbus-deprecated-props");
nm_connection_add_setting (connection, NM_SETTING (s_wsec));
hash = nm_connection_to_dbus (connection, NM_CONNECTION_SERIALIZE_ALL);
g_assert (hash != NULL);
wireless_hash = g_hash_table_lookup (hash, NM_SETTING_WIRELESS_SETTING_NAME);
g_assert (wireless_hash != NULL);
sec_val = g_hash_table_lookup (wireless_hash, "security");
g_assert (G_VALUE_HOLDS_STRING (sec_val));
g_assert_cmpstr (g_value_get_string (sec_val), ==, NM_SETTING_WIRELESS_SECURITY_SETTING_NAME);
g_hash_table_destroy (hash);
g_object_unref (connection);
}
static void
test_setting_new_from_dbus (void)
{
......@@ -3167,6 +3221,7 @@ int main (int argc, char **argv)
g_test_add_func ("/core/general/test_setting_old_uuid", test_setting_old_uuid);
g_test_add_func ("/core/general/test_connection_to_dbus_setting_name", test_connection_to_dbus_setting_name);
g_test_add_func ("/core/general/test_connection_to_dbus_deprecated_props", test_connection_to_dbus_deprecated_props);
g_test_add_func ("/core/general/test_setting_new_from_dbus", test_setting_new_from_dbus);
g_test_add_func ("/core/general/test_connection_replace_settings", test_connection_replace_settings);
g_test_add_func ("/core/general/test_connection_replace_settings_from_connection", test_connection_replace_settings_from_connection);
......
......@@ -1165,18 +1165,6 @@ get_settings_auth_cb (NMSettingsConnection *self,
g_object_set (s_wifi, NM_SETTING_WIRELESS_SEEN_BSSIDS, bssid_list, NULL);
g_slist_free (bssid_list);
/* 802-11-wireless.security property is deprecated. But we set it here so that
* we don't disturb old clients that might expect it being properly set for
* secured Wi-Fi connections.
*/
if (nm_connection_get_setting_wireless_security (NM_CONNECTION (dupl_con))) {
s_wifi = nm_connection_get_setting_wireless (NM_CONNECTION (dupl_con));
g_assert (s_wifi);
g_object_set (s_wifi,
NM_SETTING_WIRELESS_SEC, NM_SETTING_WIRELESS_SECURITY_SETTING_NAME,
NULL);
}
/* Secrets should *never* be returned by the GetSettings method, they
* get returned by the GetSecrets method which can be better
* protected against leakage of secrets to unprivileged callers.
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment