mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2025-12-29 19:40:12 +01:00
core: add nm_utils_strdict_to_variant() helper
This commit is contained in:
parent
9329844929
commit
86b54a65e6
2 changed files with 28 additions and 0 deletions
|
|
@ -4171,6 +4171,32 @@ nm_utils_parse_dns_domain (const char *domain, gboolean *is_routing)
|
|||
return domain;
|
||||
}
|
||||
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
GVariant *
|
||||
nm_utils_strdict_to_variant (GHashTable *options)
|
||||
{
|
||||
GVariantBuilder builder;
|
||||
gs_free const char **keys = NULL;
|
||||
guint i;
|
||||
guint nkeys = 0;
|
||||
|
||||
if (options) {
|
||||
keys = (const char **) g_hash_table_get_keys_as_array (options, &nkeys);
|
||||
nm_utils_strv_sort (keys, nkeys);
|
||||
}
|
||||
|
||||
g_variant_builder_init (&builder, G_VARIANT_TYPE ("a{sv}"));
|
||||
for (i = 0; i < nkeys; i++) {
|
||||
g_variant_builder_add (&builder,
|
||||
"{sv}",
|
||||
keys[i],
|
||||
g_variant_new_string (g_hash_table_lookup (options, keys[i])));
|
||||
}
|
||||
return g_variant_builder_end (&builder);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
NM_UTILS_ENUM2STR_DEFINE (nm_icmpv6_router_pref_to_string, NMIcmpv6RouterPref,
|
||||
|
|
|
|||
|
|
@ -432,6 +432,8 @@ 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>,
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue