diff options
Diffstat (limited to 'libnm-core/nm-property-compare.c')
| -rw-r--r-- | libnm-core/nm-property-compare.c | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/libnm-core/nm-property-compare.c b/libnm-core/nm-property-compare.c index d13d019f..64ed663c 100644 --- a/libnm-core/nm-property-compare.c +++ b/libnm-core/nm-property-compare.c @@ -56,6 +56,38 @@ _nm_property_compare_collection (GVariant *value1, GVariant *value2) } static gint +_nm_property_compare_vardict (GVariant *value1, GVariant *value2) +{ + GVariantIter iter; + int len1, len2; + const char *key; + GVariant *val1, *val2; + + len1 = g_variant_n_children (value1); + len2 = g_variant_n_children (value2); + + if (len1 != len2) + return len1 < len2 ? -1 : 1; + + g_variant_iter_init (&iter, value1); + while (g_variant_iter_next (&iter, "{&sv}", &key, &val1)) { + if (!g_variant_lookup (value2, key, "v", &val2)) { + g_variant_unref (val1); + return -1; + } + if (!g_variant_equal (val1, val2)) { + g_variant_unref (val1); + g_variant_unref (val2); + return -1; + } + g_variant_unref (val1); + g_variant_unref (val2); + } + + return 0; +} + +static gint _nm_property_compare_strdict (GVariant *value1, GVariant *value2) { GVariantIter iter; @@ -106,6 +138,8 @@ nm_property_compare (GVariant *value1, GVariant *value2) ret = g_variant_compare (value1, value2); else if (g_variant_is_of_type (value1, G_VARIANT_TYPE ("a{ss}"))) ret = _nm_property_compare_strdict (value1, value2); + else if (g_variant_is_of_type (value1, G_VARIANT_TYPE ("a{sv}"))) + ret = _nm_property_compare_vardict (value1, value2); else if (g_variant_type_is_array (type1)) ret = _nm_property_compare_collection (value1, value2); else if (g_variant_type_is_tuple (type1)) |