mirror of
https://gitlab.freedesktop.org/pipewire/wireplumber.git
synced 2026-05-09 07:28:41 +02:00
settings: remove wp_settings_get_all() API
Not used anymore. It is better to use parse_object_safe() Lua API instead.
This commit is contained in:
parent
61fe102c28
commit
d0e27ac82e
5 changed files with 0 additions and 84 deletions
|
|
@ -185,44 +185,6 @@ wp_settings_get (WpSettings *self, const gchar *setting)
|
|||
return value ? wp_spa_json_new_from_string (value) : NULL;
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Gets all the settings with their name matching the given pattern.
|
||||
* \ingroup wpsettings
|
||||
* \param self the settings object
|
||||
* \param pattern (nullable) the pattern to match all the settings. A NULL value
|
||||
* has the same behavior as the "*" pattern.
|
||||
* \returns (transfer full) (nullable): A JSON object with all the setting
|
||||
* values matching the pattern, or NULL if the settings object is not activated.
|
||||
*/
|
||||
WpSpaJson *
|
||||
wp_settings_get_all (WpSettings *self, const gchar *pattern)
|
||||
{
|
||||
g_autoptr (WpSpaJsonBuilder) b = NULL;
|
||||
g_autoptr (WpIterator) it = NULL;
|
||||
g_auto (GValue) item = G_VALUE_INIT;
|
||||
|
||||
g_return_val_if_fail (WP_IS_SETTINGS (self), NULL);
|
||||
|
||||
if (!(wp_object_get_active_features (WP_OBJECT (self)) &
|
||||
WP_OBJECT_FEATURES_ALL))
|
||||
return NULL;
|
||||
|
||||
b = wp_spa_json_builder_new_object ();
|
||||
for (it = wp_properties_new_iterator (self->settings);
|
||||
wp_iterator_next (it, &item);
|
||||
g_value_unset (&item)) {
|
||||
WpPropertiesItem *pi = g_value_get_boxed (&item);
|
||||
const gchar *key = wp_properties_item_get_key (pi);
|
||||
const gchar *val = wp_properties_item_get_value (pi);
|
||||
if (key && val && (!pattern || g_pattern_match_simple (pattern, key))) {
|
||||
wp_spa_json_builder_add_property (b, key);
|
||||
wp_spa_json_builder_add_from_string (b, val);
|
||||
}
|
||||
}
|
||||
|
||||
return wp_spa_json_builder_end (b);
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Safely parses a boolean setting, using the fallback value if the
|
||||
* setting does not exist, or the setting cannot be parsed. A warning is also
|
||||
|
|
|
|||
|
|
@ -64,9 +64,6 @@ gboolean wp_settings_unsubscribe (WpSettings *self,
|
|||
WP_API
|
||||
WpSpaJson * wp_settings_get (WpSettings *self, const gchar *setting);
|
||||
|
||||
WP_API
|
||||
WpSpaJson * wp_settings_get_all (WpSettings *self, const gchar *pattern);
|
||||
|
||||
WP_API
|
||||
gboolean wp_settings_parse_boolean_safe (WpSettings *self, const gchar *setting,
|
||||
gboolean value);
|
||||
|
|
|
|||
|
|
@ -1495,28 +1495,6 @@ settings_get (lua_State *L)
|
|||
return 1;
|
||||
}
|
||||
|
||||
static int
|
||||
settings_get_all (lua_State *L)
|
||||
{
|
||||
const char *pattern = luaL_checkstring (L, 1);
|
||||
const char *m = NULL;
|
||||
|
||||
if (lua_type (L, 2) == LUA_TSTRING)
|
||||
m = luaL_checkstring (L, 2);
|
||||
|
||||
g_autoptr (WpSettings) s = wp_settings_get_instance (get_wp_core (L), m);
|
||||
|
||||
if (s) {
|
||||
WpSpaJson *j = wp_settings_get_all (s, pattern);
|
||||
if (j)
|
||||
wplua_pushboxed (L, WP_TYPE_SPA_JSON, j);
|
||||
else
|
||||
lua_pushnil (L);
|
||||
} else
|
||||
lua_pushnil (L);
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int
|
||||
settings_parse_boolean_safe (lua_State *L)
|
||||
{
|
||||
|
|
@ -1712,7 +1690,6 @@ settings_unsubscribe (lua_State *L)
|
|||
|
||||
static const luaL_Reg settings_methods[] = {
|
||||
{ "get", settings_get },
|
||||
{ "get_all", settings_get_all },
|
||||
{ "parse_boolean_safe", settings_parse_boolean_safe },
|
||||
{ "parse_int_safe", settings_parse_int_safe },
|
||||
{ "parse_float_safe", settings_parse_float_safe },
|
||||
|
|
|
|||
|
|
@ -435,16 +435,6 @@ test_wpsettings (TestSettingsFixture *self, gconstpointer data)
|
|||
}
|
||||
}
|
||||
|
||||
{
|
||||
/* _get_all () */
|
||||
g_autoptr (WpSpaJson) value = NULL;
|
||||
value = wp_settings_get_all (s, "*string*");
|
||||
g_assert_nonnull (value);
|
||||
g_assert_true (wp_spa_json_is_object (value));
|
||||
g_assert_cmpstr (wp_spa_json_get_data (value), ==,
|
||||
"{\"test-setting4-string\":\"blahblah\", \"test-setting5-string-with-quotes\":\"a string with \\\"quotes\\\"\"}");
|
||||
}
|
||||
|
||||
{
|
||||
g_autoptr (WpSettings) s4 =
|
||||
wp_settings_get_instance (self->base.core, NULL);
|
||||
|
|
|
|||
|
|
@ -119,16 +119,6 @@ value = Settings.parse_object_safe ("test-setting-undefined", "test-settings")
|
|||
assert (value ~= nil)
|
||||
assert (#value == 0)
|
||||
|
||||
-- test settings _get_all ()
|
||||
value = Settings.get_all ("*string*", "test-settings")
|
||||
assert (value ~= nil)
|
||||
assert (value:is_object())
|
||||
assert (value:get_data() ==
|
||||
"{\"test-setting4-string\":\"blahblah\", \"test-setting5-string-with-quotes\":\"a string with \\\"quotes\\\"\"}")
|
||||
val = value:parse ()
|
||||
assert (val["test-setting4-string"] == "blahblah")
|
||||
assert (val["test-setting5-string-with-quotes"] == "a string with \"quotes\"")
|
||||
|
||||
-- test rules
|
||||
-- test #1
|
||||
local cp = {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue