mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2026-05-05 06:28:05 +02:00
libnm-core: make the NMSetting hash methods private
Make nm_setting_to_hash() and nm_setting_new_from_hash() private, and remove the public nm_setting_update_secrets() wrapper around the existing private _nm_setting_update_secrets(). These functions should really only be called from the corresponding NMConnection-level methods, and in particular, with certain compatibility properties in the future, we will need to consider the entire connection all at once when setting properties, so it won't make sense to serialize/deserialize a single setting in isolation.
This commit is contained in:
parent
98e4a2be30
commit
c9653a9e67
6 changed files with 19 additions and 31 deletions
|
|
@ -308,7 +308,7 @@ hash_to_connection (NMConnection *connection, GHashTable *new, GError **error)
|
|||
GType type = nm_setting_lookup_type (setting_name);
|
||||
|
||||
if (type) {
|
||||
NMSetting *setting = nm_setting_new_from_hash (type, setting_hash);
|
||||
NMSetting *setting = _nm_setting_new_from_hash (type, setting_hash);
|
||||
|
||||
if (setting) {
|
||||
_nm_connection_add_setting (connection, setting);
|
||||
|
|
@ -1264,7 +1264,7 @@ nm_connection_to_hash (NMConnection *connection, NMSettingHashFlags flags)
|
|||
while (g_hash_table_iter_next (&iter, &key, &data)) {
|
||||
NMSetting *setting = NM_SETTING (data);
|
||||
|
||||
setting_hash = nm_setting_to_hash (setting, flags);
|
||||
setting_hash = _nm_setting_to_hash (setting, flags);
|
||||
if (setting_hash)
|
||||
g_hash_table_insert (ret, g_strdup (nm_setting_get_name (setting)), setting_hash);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -114,4 +114,10 @@ NMSetting *_nm_setting_find_in_list_base_type (GSList *all_settings);
|
|||
gboolean _nm_setting_slave_type_is_valid (const char *slave_type, const char **out_port_type);
|
||||
const char * _nm_setting_slave_type_detect_from_settings (GSList *all_settings, NMSetting **out_s_port);
|
||||
|
||||
GHashTable *_nm_setting_to_hash (NMSetting *setting,
|
||||
NMSettingHashFlags flags);
|
||||
|
||||
NMSetting *_nm_setting_new_from_hash (GType setting_type,
|
||||
GHashTable *hash);
|
||||
|
||||
#endif /* NM_SETTING_PRIVATE_H */
|
||||
|
|
|
|||
|
|
@ -380,7 +380,7 @@ destroy_gvalue (gpointer data)
|
|||
}
|
||||
|
||||
/**
|
||||
* nm_setting_to_hash:
|
||||
* _nm_setting_to_hash:
|
||||
* @setting: the #NMSetting
|
||||
* @flags: hash flags, e.g. %NM_SETTING_HASH_FLAG_ALL
|
||||
*
|
||||
|
|
@ -392,7 +392,7 @@ destroy_gvalue (gpointer data)
|
|||
* describing the setting's properties
|
||||
**/
|
||||
GHashTable *
|
||||
nm_setting_to_hash (NMSetting *setting, NMSettingHashFlags flags)
|
||||
_nm_setting_to_hash (NMSetting *setting, NMSettingHashFlags flags)
|
||||
{
|
||||
GHashTable *hash;
|
||||
GParamSpec **property_specs;
|
||||
|
|
@ -444,7 +444,7 @@ nm_setting_to_hash (NMSetting *setting, NMSettingHashFlags flags)
|
|||
}
|
||||
|
||||
/**
|
||||
* nm_setting_new_from_hash:
|
||||
* _nm_setting_new_from_hash:
|
||||
* @setting_type: the #NMSetting type which the hash contains properties for
|
||||
* @hash: (element-type utf8 GObject.Value): the #GHashTable containing a
|
||||
* string to GValue mapping of properties that apply to the setting
|
||||
|
|
@ -460,7 +460,7 @@ nm_setting_to_hash (NMSetting *setting, NMSettingHashFlags flags)
|
|||
* hash table, or %NULL on failure
|
||||
**/
|
||||
NMSetting *
|
||||
nm_setting_new_from_hash (GType setting_type, GHashTable *hash)
|
||||
_nm_setting_new_from_hash (GType setting_type, GHashTable *hash)
|
||||
{
|
||||
GHashTableIter iter;
|
||||
NMSetting *setting;
|
||||
|
|
@ -1103,7 +1103,7 @@ update_one_secret (NMSetting *setting, const char *key, GValue *value, GError **
|
|||
}
|
||||
|
||||
/**
|
||||
* nm_setting_update_secrets:
|
||||
* _nm_setting_update_secrets:
|
||||
* @setting: the #NMSetting
|
||||
* @secrets: (element-type utf8 GObject.Value): a #GHashTable mapping
|
||||
* string to #GValue of setting property names and secrets
|
||||
|
|
@ -1112,15 +1112,9 @@ update_one_secret (NMSetting *setting, const char *key, GValue *value, GError **
|
|||
* Update the setting's secrets, given a hash table of secrets intended for that
|
||||
* setting (deserialized from D-Bus for example).
|
||||
*
|
||||
* Returns: %TRUE if the secrets were successfully updated, %FALSE on failure to
|
||||
* Returns: an #NMSettingUpdateSecretResult
|
||||
* update one or more of the secrets.
|
||||
**/
|
||||
gboolean
|
||||
nm_setting_update_secrets (NMSetting *setting, GHashTable *secrets, GError **error)
|
||||
{
|
||||
return _nm_setting_update_secrets (setting, secrets, error) != NM_SETTING_UPDATE_SECRET_ERROR;
|
||||
}
|
||||
|
||||
NMSettingUpdateSecretResult
|
||||
_nm_setting_update_secrets (NMSetting *setting, GHashTable *secrets, GError **error)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -248,12 +248,6 @@ typedef enum {
|
|||
NM_SETTING_HASH_FLAG_ONLY_SECRETS = 0x00000002,
|
||||
} NMSettingHashFlags;
|
||||
|
||||
GHashTable *nm_setting_to_hash (NMSetting *setting,
|
||||
NMSettingHashFlags flags);
|
||||
|
||||
NMSetting *nm_setting_new_from_hash (GType setting_type,
|
||||
GHashTable *hash);
|
||||
|
||||
NMSetting *nm_setting_duplicate (NMSetting *setting);
|
||||
|
||||
const char *nm_setting_get_name (NMSetting *setting);
|
||||
|
|
@ -300,9 +294,6 @@ void nm_setting_clear_secrets_with_flags (NMSetting *setting,
|
|||
gpointer user_data);
|
||||
|
||||
GPtrArray *nm_setting_need_secrets (NMSetting *setting);
|
||||
gboolean nm_setting_update_secrets (NMSetting *setting,
|
||||
GHashTable *secrets,
|
||||
GError **error);
|
||||
|
||||
gboolean nm_setting_get_secret_flags (NMSetting *setting,
|
||||
const char *secret_name,
|
||||
|
|
|
|||
|
|
@ -680,7 +680,7 @@ test_setting_to_hash_all (void)
|
|||
|
||||
s_wsec = make_test_wsec_setting ("setting-to-hash-all");
|
||||
|
||||
hash = nm_setting_to_hash (NM_SETTING (s_wsec), NM_SETTING_HASH_FLAG_ALL);
|
||||
hash = _nm_setting_to_hash (NM_SETTING (s_wsec), NM_SETTING_HASH_FLAG_ALL);
|
||||
|
||||
/* Make sure all keys are there */
|
||||
ASSERT (g_hash_table_lookup (hash, NM_SETTING_WIRELESS_SECURITY_KEY_MGMT),
|
||||
|
|
@ -704,7 +704,7 @@ test_setting_to_hash_no_secrets (void)
|
|||
|
||||
s_wsec = make_test_wsec_setting ("setting-to-hash-no-secrets");
|
||||
|
||||
hash = nm_setting_to_hash (NM_SETTING (s_wsec), NM_SETTING_HASH_FLAG_NO_SECRETS);
|
||||
hash = _nm_setting_to_hash (NM_SETTING (s_wsec), NM_SETTING_HASH_FLAG_NO_SECRETS);
|
||||
|
||||
/* Make sure non-secret keys are there */
|
||||
ASSERT (g_hash_table_lookup (hash, NM_SETTING_WIRELESS_SECURITY_KEY_MGMT),
|
||||
|
|
@ -730,7 +730,7 @@ test_setting_to_hash_only_secrets (void)
|
|||
|
||||
s_wsec = make_test_wsec_setting ("setting-to-hash-only-secrets");
|
||||
|
||||
hash = nm_setting_to_hash (NM_SETTING (s_wsec), NM_SETTING_HASH_FLAG_ONLY_SECRETS);
|
||||
hash = _nm_setting_to_hash (NM_SETTING (s_wsec), NM_SETTING_HASH_FLAG_ONLY_SECRETS);
|
||||
|
||||
/* Make sure non-secret keys are there */
|
||||
ASSERT (g_hash_table_lookup (hash, NM_SETTING_WIRELESS_SECURITY_KEY_MGMT) == NULL,
|
||||
|
|
@ -778,10 +778,10 @@ test_setting_new_from_hash (void)
|
|||
GHashTable *hash;
|
||||
|
||||
s_wsec = make_test_wsec_setting ("setting-to-hash-all");
|
||||
hash = nm_setting_to_hash (NM_SETTING (s_wsec), NM_SETTING_HASH_FLAG_ALL);
|
||||
hash = _nm_setting_to_hash (NM_SETTING (s_wsec), NM_SETTING_HASH_FLAG_ALL);
|
||||
g_object_unref (s_wsec);
|
||||
|
||||
s_wsec = (NMSettingWirelessSecurity *) nm_setting_new_from_hash (NM_TYPE_SETTING_WIRELESS_SECURITY, hash);
|
||||
s_wsec = (NMSettingWirelessSecurity *) _nm_setting_new_from_hash (NM_TYPE_SETTING_WIRELESS_SECURITY, hash);
|
||||
g_hash_table_destroy (hash);
|
||||
|
||||
g_assert (s_wsec);
|
||||
|
|
|
|||
|
|
@ -676,7 +676,6 @@ global:
|
|||
nm_setting_lookup_type;
|
||||
nm_setting_lookup_type_by_quark;
|
||||
nm_setting_need_secrets;
|
||||
nm_setting_new_from_hash;
|
||||
nm_setting_olpc_mesh_error_get_type;
|
||||
nm_setting_olpc_mesh_error_quark;
|
||||
nm_setting_olpc_mesh_get_channel;
|
||||
|
|
@ -736,9 +735,7 @@ global:
|
|||
nm_setting_team_port_get_config;
|
||||
nm_setting_team_port_get_type;
|
||||
nm_setting_team_port_new;
|
||||
nm_setting_to_hash;
|
||||
nm_setting_to_string;
|
||||
nm_setting_update_secrets;
|
||||
nm_setting_verify;
|
||||
nm_setting_vlan_add_priority;
|
||||
nm_setting_vlan_add_priority_str;
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue