mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2026-05-08 13:38:43 +02:00
libnm/keyfile: add parser_full() hook for reading non GObject based properties
This commit is contained in:
parent
c02fadecec
commit
408d637930
1 changed files with 38 additions and 21 deletions
|
|
@ -2275,9 +2275,16 @@ cert_writer (KeyfileWriterInfo *info,
|
||||||
|
|
||||||
struct _ParseInfoProperty {
|
struct _ParseInfoProperty {
|
||||||
const char *property_name;
|
const char *property_name;
|
||||||
|
union {
|
||||||
void (*parser) (KeyfileReaderInfo *info,
|
void (*parser) (KeyfileReaderInfo *info,
|
||||||
NMSetting *setting,
|
NMSetting *setting,
|
||||||
const char *key);
|
const char *key);
|
||||||
|
void (*parser_full) (KeyfileReaderInfo *info,
|
||||||
|
const NMMetaSettingInfo *setting_info,
|
||||||
|
const NMSettInfoProperty *property_info,
|
||||||
|
const ParseInfoProperty *pip,
|
||||||
|
NMSetting *setting);
|
||||||
|
};
|
||||||
union {
|
union {
|
||||||
void (*writer) (KeyfileWriterInfo *info,
|
void (*writer) (KeyfileWriterInfo *info,
|
||||||
NMSetting *setting,
|
NMSetting *setting,
|
||||||
|
|
@ -2293,6 +2300,7 @@ struct _ParseInfoProperty {
|
||||||
bool parser_no_check_key:1;
|
bool parser_no_check_key:1;
|
||||||
bool writer_skip:1;
|
bool writer_skip:1;
|
||||||
bool has_writer_full:1;
|
bool has_writer_full:1;
|
||||||
|
bool has_parser_full:1;
|
||||||
|
|
||||||
/* usually, we skip to write values that have their
|
/* usually, we skip to write values that have their
|
||||||
* default value. By setting this flag to TRUE, also
|
* default value. By setting this flag to TRUE, also
|
||||||
|
|
@ -2742,23 +2750,33 @@ read_one_setting_value (KeyfileReaderInfo *info,
|
||||||
gint64 i64;
|
gint64 i64;
|
||||||
|
|
||||||
nm_assert (!info->error);
|
nm_assert (!info->error);
|
||||||
nm_assert (property_info->param_spec);
|
nm_assert ( !property_info->param_spec
|
||||||
|
|| nm_streq (property_info->param_spec->name, property_info->name));
|
||||||
|
|
||||||
if ((property_info->param_spec->flags & (G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY)) != G_PARAM_WRITABLE)
|
key = property_info->name;
|
||||||
return;
|
|
||||||
|
|
||||||
key = property_info->param_spec->name;
|
|
||||||
|
|
||||||
pip = _parse_info_find (setting, key, &setting_info);
|
pip = _parse_info_find (setting, key, &setting_info);
|
||||||
|
|
||||||
nm_assert (setting_info);
|
nm_assert (setting_info);
|
||||||
|
|
||||||
if ( !pip
|
if (!pip) {
|
||||||
&& nm_streq (key, NM_SETTING_NAME))
|
if (nm_streq (key, NM_SETTING_NAME))
|
||||||
return;
|
return;
|
||||||
|
if (!property_info->param_spec)
|
||||||
|
return;
|
||||||
|
if ((property_info->param_spec->flags & (G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY)) != G_PARAM_WRITABLE)
|
||||||
|
return;
|
||||||
|
} else {
|
||||||
|
if (pip->parser_skip)
|
||||||
|
return;
|
||||||
|
if (pip->has_parser_full) {
|
||||||
|
pip->parser_full (info, setting_info, property_info, pip, setting);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (pip && pip->parser_skip)
|
nm_assert (property_info->param_spec);
|
||||||
return;
|
nm_assert ((property_info->param_spec->flags & (G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY)) == G_PARAM_WRITABLE);
|
||||||
|
|
||||||
/* Check for the exact key in the GKeyFile if required. Most setting
|
/* Check for the exact key in the GKeyFile if required. Most setting
|
||||||
* properties map 1:1 to a key in the GKeyFile, but for those properties
|
* properties map 1:1 to a key in the GKeyFile, but for those properties
|
||||||
|
|
@ -2777,7 +2795,8 @@ read_one_setting_value (KeyfileReaderInfo *info,
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pip && pip->parser) {
|
if ( pip
|
||||||
|
&& pip->parser) {
|
||||||
pip->parser (info, setting, key);
|
pip->parser (info, setting, key);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
@ -3027,14 +3046,12 @@ _read_setting (KeyfileReaderInfo *info)
|
||||||
}
|
}
|
||||||
|
|
||||||
for (i = 0; i < sett_info->property_infos_len; i++) {
|
for (i = 0; i < sett_info->property_infos_len; i++) {
|
||||||
const NMSettInfoProperty *property_info = &sett_info->property_infos[i];
|
read_one_setting_value (info,
|
||||||
|
setting,
|
||||||
if (property_info->param_spec) {
|
&sett_info->property_infos[i]);
|
||||||
read_one_setting_value (info, setting, property_info);
|
|
||||||
if (info->error)
|
if (info->error)
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
out:
|
out:
|
||||||
info->setting = NULL;
|
info->setting = NULL;
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue