Commit c9653a9e authored by Dan Winship's avatar Dan Winship

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.
parent 98e4a2be
...@@ -308,7 +308,7 @@ hash_to_connection (NMConnection *connection, GHashTable *new, GError **error) ...@@ -308,7 +308,7 @@ hash_to_connection (NMConnection *connection, GHashTable *new, GError **error)
GType type = nm_setting_lookup_type (setting_name); GType type = nm_setting_lookup_type (setting_name);
if (type) { if (type) {
NMSetting *setting = nm_setting_new_from_hash (type, setting_hash); NMSetting *setting = _nm_setting_new_from_hash (type, setting_hash);
if (setting) { if (setting) {
_nm_connection_add_setting (connection, setting); _nm_connection_add_setting (connection, setting);
...@@ -1264,7 +1264,7 @@ nm_connection_to_hash (NMConnection *connection, NMSettingHashFlags flags) ...@@ -1264,7 +1264,7 @@ nm_connection_to_hash (NMConnection *connection, NMSettingHashFlags flags)
while (g_hash_table_iter_next (&iter, &key, &data)) { while (g_hash_table_iter_next (&iter, &key, &data)) {
NMSetting *setting = NM_SETTING (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) if (setting_hash)
g_hash_table_insert (ret, g_strdup (nm_setting_get_name (setting)), 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); ...@@ -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); 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); 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 */ #endif /* NM_SETTING_PRIVATE_H */
...@@ -380,7 +380,7 @@ destroy_gvalue (gpointer data) ...@@ -380,7 +380,7 @@ destroy_gvalue (gpointer data)
} }
/** /**
* nm_setting_to_hash: * _nm_setting_to_hash:
* @setting: the #NMSetting * @setting: the #NMSetting
* @flags: hash flags, e.g. %NM_SETTING_HASH_FLAG_ALL * @flags: hash flags, e.g. %NM_SETTING_HASH_FLAG_ALL
* *
...@@ -392,7 +392,7 @@ destroy_gvalue (gpointer data) ...@@ -392,7 +392,7 @@ destroy_gvalue (gpointer data)
* describing the setting's properties * describing the setting's properties
**/ **/
GHashTable * GHashTable *
nm_setting_to_hash (NMSetting *setting, NMSettingHashFlags flags) _nm_setting_to_hash (NMSetting *setting, NMSettingHashFlags flags)
{ {
GHashTable *hash; GHashTable *hash;
GParamSpec **property_specs; GParamSpec **property_specs;
...@@ -444,7 +444,7 @@ nm_setting_to_hash (NMSetting *setting, NMSettingHashFlags flags) ...@@ -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 * @setting_type: the #NMSetting type which the hash contains properties for
* @hash: (element-type utf8 GObject.Value): the #GHashTable containing a * @hash: (element-type utf8 GObject.Value): the #GHashTable containing a
* string to GValue mapping of properties that apply to the setting * string to GValue mapping of properties that apply to the setting
...@@ -460,7 +460,7 @@ nm_setting_to_hash (NMSetting *setting, NMSettingHashFlags flags) ...@@ -460,7 +460,7 @@ nm_setting_to_hash (NMSetting *setting, NMSettingHashFlags flags)
* hash table, or %NULL on failure * hash table, or %NULL on failure
**/ **/
NMSetting * NMSetting *
nm_setting_new_from_hash (GType setting_type, GHashTable *hash) _nm_setting_new_from_hash (GType setting_type, GHashTable *hash)
{ {
GHashTableIter iter; GHashTableIter iter;
NMSetting *setting; NMSetting *setting;
...@@ -1103,7 +1103,7 @@ update_one_secret (NMSetting *setting, const char *key, GValue *value, GError ** ...@@ -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 * @setting: the #NMSetting
* @secrets: (element-type utf8 GObject.Value): a #GHashTable mapping * @secrets: (element-type utf8 GObject.Value): a #GHashTable mapping
* string to #GValue of setting property names and secrets * string to #GValue of setting property names and secrets
...@@ -1112,15 +1112,9 @@ update_one_secret (NMSetting *setting, const char *key, GValue *value, GError ** ...@@ -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 * Update the setting's secrets, given a hash table of secrets intended for that
* setting (deserialized from D-Bus for example). * 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. * 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 NMSettingUpdateSecretResult
_nm_setting_update_secrets (NMSetting *setting, GHashTable *secrets, GError **error) _nm_setting_update_secrets (NMSetting *setting, GHashTable *secrets, GError **error)
{ {
......
...@@ -248,12 +248,6 @@ typedef enum { ...@@ -248,12 +248,6 @@ typedef enum {
NM_SETTING_HASH_FLAG_ONLY_SECRETS = 0x00000002, NM_SETTING_HASH_FLAG_ONLY_SECRETS = 0x00000002,
} NMSettingHashFlags; } 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); NMSetting *nm_setting_duplicate (NMSetting *setting);
const char *nm_setting_get_name (NMSetting *setting); const char *nm_setting_get_name (NMSetting *setting);
...@@ -300,9 +294,6 @@ void nm_setting_clear_secrets_with_flags (NMSetting *setting, ...@@ -300,9 +294,6 @@ void nm_setting_clear_secrets_with_flags (NMSetting *setting,
gpointer user_data); gpointer user_data);
GPtrArray *nm_setting_need_secrets (NMSetting *setting); 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, gboolean nm_setting_get_secret_flags (NMSetting *setting,
const char *secret_name, const char *secret_name,
......
...@@ -680,7 +680,7 @@ test_setting_to_hash_all (void) ...@@ -680,7 +680,7 @@ test_setting_to_hash_all (void)
s_wsec = make_test_wsec_setting ("setting-to-hash-all"); 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 */ /* Make sure all keys are there */
ASSERT (g_hash_table_lookup (hash, NM_SETTING_WIRELESS_SECURITY_KEY_MGMT), ASSERT (g_hash_table_lookup (hash, NM_SETTING_WIRELESS_SECURITY_KEY_MGMT),
...@@ -704,7 +704,7 @@ test_setting_to_hash_no_secrets (void) ...@@ -704,7 +704,7 @@ test_setting_to_hash_no_secrets (void)
s_wsec = make_test_wsec_setting ("setting-to-hash-no-secrets"); 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 */ /* Make sure non-secret keys are there */
ASSERT (g_hash_table_lookup (hash, NM_SETTING_WIRELESS_SECURITY_KEY_MGMT), ASSERT (g_hash_table_lookup (hash, NM_SETTING_WIRELESS_SECURITY_KEY_MGMT),
...@@ -730,7 +730,7 @@ test_setting_to_hash_only_secrets (void) ...@@ -730,7 +730,7 @@ test_setting_to_hash_only_secrets (void)
s_wsec = make_test_wsec_setting ("setting-to-hash-only-secrets"); 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 */ /* Make sure non-secret keys are there */
ASSERT (g_hash_table_lookup (hash, NM_SETTING_WIRELESS_SECURITY_KEY_MGMT) == NULL, ASSERT (g_hash_table_lookup (hash, NM_SETTING_WIRELESS_SECURITY_KEY_MGMT) == NULL,
...@@ -778,10 +778,10 @@ test_setting_new_from_hash (void) ...@@ -778,10 +778,10 @@ test_setting_new_from_hash (void)
GHashTable *hash; GHashTable *hash;
s_wsec = make_test_wsec_setting ("setting-to-hash-all"); 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); 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_hash_table_destroy (hash);
g_assert (s_wsec); g_assert (s_wsec);
......
...@@ -676,7 +676,6 @@ global: ...@@ -676,7 +676,6 @@ global:
nm_setting_lookup_type; nm_setting_lookup_type;
nm_setting_lookup_type_by_quark; nm_setting_lookup_type_by_quark;
nm_setting_need_secrets; nm_setting_need_secrets;
nm_setting_new_from_hash;
nm_setting_olpc_mesh_error_get_type; nm_setting_olpc_mesh_error_get_type;
nm_setting_olpc_mesh_error_quark; nm_setting_olpc_mesh_error_quark;
nm_setting_olpc_mesh_get_channel; nm_setting_olpc_mesh_get_channel;
...@@ -736,9 +735,7 @@ global: ...@@ -736,9 +735,7 @@ global:
nm_setting_team_port_get_config; nm_setting_team_port_get_config;
nm_setting_team_port_get_type; nm_setting_team_port_get_type;
nm_setting_team_port_new; nm_setting_team_port_new;
nm_setting_to_hash;
nm_setting_to_string; nm_setting_to_string;
nm_setting_update_secrets;
nm_setting_verify; nm_setting_verify;
nm_setting_vlan_add_priority; nm_setting_vlan_add_priority;
nm_setting_vlan_add_priority_str; nm_setting_vlan_add_priority_str;
......
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