diff --git a/lib/wp/properties.c b/lib/wp/properties.c index b8d783462838d71d325a1b4140f2d520c3d64b35..e06b69fc94b57252e5e202c4e646998a51891c08 100644 --- a/lib/wp/properties.c +++ b/lib/wp/properties.c @@ -178,6 +178,32 @@ wp_properties_update_from_dict (WpProperties * self, return pw_properties_update (self->props, dict); } +gint +wp_properties_copy_keys (WpProperties * src, WpProperties * dst, + const gchar *key1, ...) +{ + gint ret; + va_list args; + va_start (args, key1); + ret = wp_properties_copy_keys_valist (src, dst, key1, args); + va_end (args); + return ret; +} + +gint +wp_properties_copy_keys_valist (WpProperties * src, WpProperties * dst, + const gchar *key1, va_list args) +{ + gint changed = 0; + const gchar *value; + + for (; key1; key1 = va_arg (args, const gchar *)) { + if ((value = wp_properties_get (src, key1)) != NULL) + changed += wp_properties_set (dst, key1, value); + } + return changed; +} + const gchar * wp_properties_get (WpProperties * self, const gchar * key) { diff --git a/lib/wp/properties.h b/lib/wp/properties.h index 3479f36aa98a1a76670baf24f914954a9be362cf..553f937acd669745eea2c3f555b0202603b0ead1 100644 --- a/lib/wp/properties.h +++ b/lib/wp/properties.h @@ -41,6 +41,11 @@ void wp_properties_unref (WpProperties * self); gint wp_properties_update_from_dict (WpProperties * self, const struct spa_dict * dict); +gint wp_properties_copy_keys (WpProperties * src, WpProperties * dst, + const gchar *key1, ...) G_GNUC_NULL_TERMINATED; +gint wp_properties_copy_keys_valist (WpProperties * src, WpProperties * dst, + const gchar *key1, va_list args); + const gchar * wp_properties_get (WpProperties * self, const gchar * key); gint wp_properties_set (WpProperties * self, const gchar * key,