Revert "libnm-core: don't serialize synthetic properties in nm_setting_to_string()"

We shall not shortcut the synth function. If the synth function is
unhappy about a missing NMConnection argument, then that needs to be
fixed.

So, revert 395c385b9 and fix the issue in nm_setting_wireless_get_security()
differently. I presume that is the only place that caused problems,
since the history of the patch does not clealy show what the problem
was.

This reverts commit 395c385b9b.
This commit is contained in:
Thomas Haller 2019-01-02 15:24:35 +01:00
parent 33bf73f252
commit 1b361aaea9
4 changed files with 7 additions and 19 deletions

View file

@ -121,8 +121,6 @@ typedef enum { /*< flags >*/
NM_CONNECTION_SERIALIZE_ALL = 0x00000000,
NM_CONNECTION_SERIALIZE_NO_SECRETS = 0x00000001,
NM_CONNECTION_SERIALIZE_ONLY_SECRETS = 0x00000002,
/* 0x80000000 is used for a private flag */
} NMConnectionSerializationFlags;
GVariant *nm_connection_to_dbus (NMConnection *connection,

View file

@ -174,13 +174,6 @@ NMSettingPriority _nm_setting_get_setting_priority (NMSetting *setting);
gboolean _nm_setting_get_property (NMSetting *setting, const char *name, GValue *value);
/* NM_CONNECTION_SERIALIZE_NO_SYNTH: This flag is passed to _nm_setting_to_dbus()
* by nm_setting_to_string() to let it know that it shouldn't serialize the
* synthetic properties. It wouldn't be able to do so, since the full connection
* is not available, only the setting alone.
*/
#define NM_CONNECTION_SERIALIZE_NO_SYNTH ((NMConnectionSerializationFlags) 0x80000000)
/*****************************************************************************/
GHashTable *_nm_setting_gendata_hash (NMSetting *setting,

View file

@ -953,6 +953,9 @@ nm_setting_wireless_get_security (NMSetting *setting,
NMConnection *connection,
const char *property_name)
{
if (!connection)
return NULL;
if (nm_connection_get_setting_wireless_security (connection))
return g_variant_new_string (NM_SETTING_WIRELESS_SECURITY_SETTING_NAME);
else

View file

@ -685,15 +685,10 @@ _nm_setting_to_dbus (NMSetting *setting, NMConnection *connection, NMConnectionS
continue;
}
if (property->synth_func) {
if (!(flags & NM_CONNECTION_SERIALIZE_NO_SYNTH))
dbus_value = property->synth_func (setting, connection, property->name);
else
dbus_value = NULL;
} else {
if (property->synth_func)
dbus_value = property->synth_func (setting, connection, property->name);
else
dbus_value = get_property_for_dbus (setting, property, TRUE);
}
if (dbus_value) {
/* Allow dbus_value to be either floating or not. */
g_variant_take_ref (dbus_value);
@ -2018,8 +2013,7 @@ nm_setting_to_string (NMSetting *setting)
string = g_string_new (nm_setting_get_name (setting));
g_string_append_c (string, '\n');
variant = _nm_setting_to_dbus (setting, NULL, NM_CONNECTION_SERIALIZE_ALL
| NM_CONNECTION_SERIALIZE_NO_SYNTH);
variant = _nm_setting_to_dbus (setting, NULL, NM_CONNECTION_SERIALIZE_ALL);
g_variant_iter_init (&iter, variant);
while ((child = g_variant_iter_next_value (&iter))) {