shared,core: rename and move function to nm_utils_strdict_to_variant_asv()

This commit is contained in:
Thomas Haller 2020-06-07 00:04:52 +02:00
parent 91d6461761
commit cdb38df7e5
No known key found for this signature in database
GPG key ID: 29C2366E4DFC5728
5 changed files with 29 additions and 30 deletions

View file

@ -527,6 +527,33 @@ out:
/*****************************************************************************/
GVariant *
nm_utils_strdict_to_variant_asv (GHashTable *strdict)
{
gs_free NMUtilsNamedValue *values_free = NULL;
NMUtilsNamedValue values_prepared[20];
const NMUtilsNamedValue *values;
GVariantBuilder builder;
guint i;
guint n;
values = nm_utils_named_values_from_strdict (strdict,
&n,
values_prepared,
&values_free);
g_variant_builder_init (&builder, G_VARIANT_TYPE ("a{sv}"));
for (i = 0; i < n; i++) {
g_variant_builder_add (&builder,
"{sv}",
values[i].name,
g_variant_new_string (values[i].value_str));
}
return g_variant_builder_end (&builder);
}
/*****************************************************************************/
/**
* nm_strquote:
* @buf: the output buffer of where to write the quoted @str argument.

View file

@ -422,6 +422,7 @@ gboolean nm_utils_gbytes_equal_mem (GBytes *bytes,
GVariant *nm_utils_gbytes_to_variant_ay (GBytes *bytes);
GVariant *nm_utils_strdict_to_variant_ass (GHashTable *strdict);
GVariant *nm_utils_strdict_to_variant_asv (GHashTable *strdict);
/*****************************************************************************/

View file

@ -4108,33 +4108,6 @@ nm_utils_parse_dns_domain (const char *domain, gboolean *is_routing)
/*****************************************************************************/
GVariant *
nm_utils_strdict_to_variant (GHashTable *options)
{
gs_free NMUtilsNamedValue *values_free = NULL;
NMUtilsNamedValue values_prepared[20];
const NMUtilsNamedValue *values;
GVariantBuilder builder;
guint i;
guint n;
values = nm_utils_named_values_from_strdict (options,
&n,
values_prepared,
&values_free);
g_variant_builder_init (&builder, G_VARIANT_TYPE ("a{sv}"));
for (i = 0; i < n; i++) {
g_variant_builder_add (&builder,
"{sv}",
values[i].name,
g_variant_new_string (values[i].value_str));
}
return g_variant_builder_end (&builder);
}
/*****************************************************************************/
static guint32
get_max_rate_ht_20 (int mcs)
{

View file

@ -449,8 +449,6 @@ gboolean nm_utils_validate_plugin (const char *path, struct stat *stat, GError *
char **nm_utils_read_plugin_paths (const char *dirname, const char *prefix);
char *nm_utils_format_con_diff_for_audit (GHashTable *diff);
GVariant *nm_utils_strdict_to_variant (GHashTable *options);
/*****************************************************************************/
/* this enum is compatible with ICMPV6_ROUTER_PREF_* (from <linux/icmpv6.h>,

View file

@ -75,7 +75,7 @@ nm_dhcp_config_set_options (NMDhcpConfig *self,
priv = NM_DHCP_CONFIG_GET_PRIVATE (self);
nm_g_variant_unref (priv->options);
priv->options = g_variant_ref_sink (nm_utils_strdict_to_variant (options));
priv->options = g_variant_ref_sink (nm_utils_strdict_to_variant_asv (options));
_notify (self, PROP_OPTIONS);
}