dbus-metadata: make 'extra' available from NML_DBUS_META_PROPERTY_INIT_FCN()

Currently a NML_DBUS_META_PROPERTY_INIT_FCN() property does not have
'extra' field available. In order to be able to call
'nml_dbus_property_ao_notify()' from the callback, the 'extra' field
must be available.

The patch is also dropping 'use_notify_update_prop' field as it only
existed to differentiate the union.

Signed-off-by: Fernando Fernandez Mancera <ffmancera@riseup.net>
This commit is contained in:
Fernando Fernandez Mancera 2021-10-07 16:06:14 +02:00
parent 05c062fc80
commit cf867e8ff5
3 changed files with 12 additions and 19 deletions

View file

@ -2407,7 +2407,7 @@ _obj_handle_dbus_prop_changes(NMClient * self,
value = NULL;
}
if (meta_property->use_notify_update_prop) {
if (meta_property->notify_update_prop) {
notify_update_prop_flags =
meta_property->notify_update_prop(self, dbobj, meta_iface, dbus_property_idx, value);
if (notify_update_prop_flags == NML_DBUS_NOTIFY_UPDATE_PROP_FLAGS_NONE)

View file

@ -339,26 +339,22 @@ typedef struct {
const char * dbus_property_name;
const GVariantType *dbus_type;
NMLDBusNotifyUpdatePropFlags (*notify_update_prop)(NMClient * client,
NMLDBusObject * dbobj,
const NMLDBusMetaIface *meta_iface,
guint dbus_property_idx,
GVariant * value);
guint16 prop_struct_offset;
guint8 obj_properties_idx;
bool use_notify_update_prop : 1;
bool obj_property_no_reverse_idx : 1;
union {
union {
const NMLDBusPropertVTableO * property_vtable_o;
const NMLDBusPropertVTableAO *property_vtable_ao;
} extra;
NMLDBusNotifyUpdatePropFlags (*notify_update_prop)(NMClient * client,
NMLDBusObject * dbobj,
const NMLDBusMetaIface *meta_iface,
guint dbus_property_idx,
GVariant *value);
};
const NMLDBusPropertVTableO * property_vtable_o;
const NMLDBusPropertVTableAO *property_vtable_ao;
} extra;
} NMLDBusMetaProperty;
@ -411,7 +407,6 @@ typedef struct {
"o", \
v_obj_properties_idx, \
.prop_struct_offset = NM_STRUCT_OFFSET_ENSURE_TYPE(NMRefString *, v_container, v_field), \
.use_notify_update_prop = TRUE, \
.notify_update_prop = _nml_dbus_notify_update_prop_o)
#define NML_DBUS_META_PROPERTY_INIT_O_PROP(v_dbus_property_name, \
@ -452,7 +447,6 @@ typedef struct {
NML_DBUS_META_PROPERTY_INIT(v_dbus_property_name, \
v_dbus_type, \
v_obj_properties_idx, \
.use_notify_update_prop = TRUE, \
.notify_update_prop = (v_notify_update_prop), \
##__VA_ARGS__)
@ -460,7 +454,6 @@ typedef struct {
NML_DBUS_META_PROPERTY_INIT(v_dbus_property_name, \
v_dbus_type, \
0, \
.use_notify_update_prop = TRUE, \
.notify_update_prop = _nml_dbus_notify_update_prop_ignore)
/* "TODO" is like "IGNORE". The difference is that we don't plan to ever implement "IGNORE", but

View file

@ -3068,7 +3068,7 @@ check_dbus_properties:
pspec = mif->obj_properties[mpr->obj_properties_idx];
}
if (mpr->use_notify_update_prop) {
if (mpr->notify_update_prop) {
g_assert(mpr->notify_update_prop);
} else {
if (klass)
@ -3129,7 +3129,7 @@ check_dbus_properties:
g_assert_cmpstr(expected_property_name, ==, pspec->name);
if (!mpr->use_notify_update_prop) {
if (!mpr->notify_update_prop) {
for (p_expected_type_2 = &expected_types[0];
p_expected_type_2 < &expected_types[G_N_ELEMENTS(expected_types)];
p_expected_type_2++) {