summary refs log tree commit diff
path: root/src/libnm-client-impl/nm-libnm-utils.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/libnm-client-impl/nm-libnm-utils.h')
-rw-r--r--src/libnm-client-impl/nm-libnm-utils.h125
1 files changed, 73 insertions, 52 deletions
diff --git a/src/libnm-client-impl/nm-libnm-utils.h b/src/libnm-client-impl/nm-libnm-utils.h
index 3fd3b679..75e87064 100644
--- a/src/libnm-client-impl/nm-libnm-utils.h
+++ b/src/libnm-client-impl/nm-libnm-utils.h
@@ -303,7 +303,7 @@ const GPtrArray *nml_dbus_property_ao_get_objs_as_ptrarray(NMLDBusPropertyAO *pr
 
 gboolean nml_dbus_property_ao_is_ready(const NMLDBusPropertyAO *pr_ao);
 
-void nml_dbus_property_ao_clear(NMLDBusPropertyAO *pr_ao, NMClient *client);
+gboolean nml_dbus_property_ao_clear(NMLDBusPropertyAO *pr_ao, NMClient *client);
 
 void nml_dbus_property_ao_clear_many(NMLDBusPropertyAO *pr_ao, guint len, NMClient *self);
 
@@ -328,30 +328,33 @@ NMLDBusNotifyUpdatePropFlags _nml_dbus_notify_update_prop_o(NMClient *
                                                             guint     dbus_property_idx,
                                                             GVariant *value);
 
+NMLDBusNotifyUpdatePropFlags nml_dbus_property_ao_notify(NMClient *              self,
+                                                         NMLDBusPropertyAO *     pr_ao,
+                                                         NMLDBusObject *         dbobj,
+                                                         const NMLDBusMetaIface *meta_iface,
+                                                         guint                   dbus_property_idx,
+                                                         GVariant *              value);
+
 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;
 
@@ -395,17 +398,16 @@ typedef struct {
 #define NML_DBUS_META_PROPERTY_INIT_AY(...) \
     _NML_DBUS_META_PROPERTY_INIT_DEFAULT("ay", GBytes *, __VA_ARGS__)
 
-#define NML_DBUS_META_PROPERTY_INIT_O(v_dbus_property_name,                                          \
-                                      v_obj_properties_idx,                                          \
-                                      v_container,                                                   \
-                                      v_field)                                                       \
-    NML_DBUS_META_PROPERTY_INIT(                                                                     \
-        v_dbus_property_name,                                                                        \
-        "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(v_dbus_property_name,                                      \
+                                      v_obj_properties_idx,                                      \
+                                      v_container,                                               \
+                                      v_field)                                                   \
+    NML_DBUS_META_PROPERTY_INIT(                                                                 \
+        v_dbus_property_name,                                                                    \
+        "o",                                                                                     \
+        v_obj_properties_idx,                                                                    \
+        .prop_struct_offset = NM_STRUCT_OFFSET_ENSURE_TYPE(NMRefString *, v_container, v_field), \
+        .notify_update_prop = _nml_dbus_notify_update_prop_o)
 
 #define NML_DBUS_META_PROPERTY_INIT_O_PROP(v_dbus_property_name,                  \
                                            v_obj_properties_idx,                  \
@@ -437,24 +439,22 @@ typedef struct {
         .extra.property_vtable_ao = &(                                             \
             (const NMLDBusPropertVTableAO){.get_o_type_fcn = (v_get_o_type_fcn), ##__VA_ARGS__}))
 
-#define NML_DBUS_META_PROPERTY_INIT_FCN(v_dbus_property_name,                     \
-                                        v_obj_properties_idx,                     \
-                                        v_dbus_type,                              \
-                                        v_notify_update_prop,                     \
-                                        ...)                                      \
-    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), \
+#define NML_DBUS_META_PROPERTY_INIT_FCN(v_dbus_property_name,                 \
+                                        v_obj_properties_idx,                 \
+                                        v_dbus_type,                          \
+                                        v_notify_update_prop,                 \
+                                        ...)                                  \
+    NML_DBUS_META_PROPERTY_INIT(v_dbus_property_name,                         \
+                                v_dbus_type,                                  \
+                                v_obj_properties_idx,                         \
+                                .notify_update_prop = (v_notify_update_prop), \
                                 ##__VA_ARGS__)
 
 #define NML_DBUS_META_PROPERTY_INIT_IGNORE(v_dbus_property_name, v_dbus_type) \
     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)
+                                .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
  * "TODO" is something we should add support for. */
@@ -758,21 +758,29 @@ struct _NMObjectClass {
     }                                                                             \
     G_STMT_END
 
-#define _NM_OBJECT_CLASS_INIT_FIELD_INFO(_nm_object_class, _field_name, _offset, _num) \
-    G_STMT_START                                                                       \
-    {                                                                                  \
-        (_nm_object_class)->_field_name = ({                                           \
-            static _NMObjectClassFieldInfo _f;                                         \
-                                                                                       \
-            _f = (_NMObjectClassFieldInfo){                                            \
-                .parent = (_nm_object_class)->_field_name,                             \
-                .klass  = (_nm_object_class),                                          \
-                .offset = _offset,                                                     \
-                .num    = _num,                                                        \
-            };                                                                         \
-            &_f;                                                                       \
-        });                                                                            \
-    }                                                                                  \
+#define _NM_OBJECT_CLASS_INIT_FIELD_INFO(nm_object_class, field_name, _offset, _num) \
+    G_STMT_START                                                                     \
+    {                                                                                \
+        NMObjectClass *const _klass = (nm_object_class);                             \
+                                                                                     \
+        _klass->field_name = ({                                                      \
+            static _NMObjectClassFieldInfo _f;                                       \
+                                                                                     \
+            /* this code is called inside a _class_init() function, it thus
+             * is only executed once, so we are fine to initialize a static
+             * variable here. */          \
+            nm_assert(!_f.klass);                                                    \
+                                                                                     \
+            _f = (_NMObjectClassFieldInfo){                                          \
+                .parent = _klass->field_name,                                        \
+                .klass  = _klass,                                                    \
+                .offset = (_offset),                                                 \
+                .num    = (_num),                                                    \
+            };                                                                       \
+                                                                                     \
+            &_f;                                                                     \
+        });                                                                          \
+    }                                                                                \
     G_STMT_END
 
 #define _NM_OBJECT_CLASS_INIT_PROPERTY_O_FIELDS_1(nm_object_class, type_name, field_name) \
@@ -820,8 +828,15 @@ struct _NMDeviceClass {
     const char *(*get_type_description)(NMDevice *device);
 
     GType (*get_setting_type)(NMDevice *device);
+
+    /* Slaves was originally part of some subtypes of NMDevice. It was deprecated and
+    * a new NMDevice::ports property was added. When that property changes, we need
+    * to notify about the subclass' respective property. This is the property. */
+    const GParamSpec *slaves_param_spec;
 };
 
+#define _NML_DEVICE_META_PROPERTY_INDEX_PORTS 27
+
 /*****************************************************************************/
 
 struct _NMDeviceEthernetPrivate;
@@ -1025,6 +1040,12 @@ _nm_device_notify_update_prop_hw_address(NMClient *              client,
                                          guint                   dbus_property_idx,
                                          GVariant *              value);
 
+NMLDBusNotifyUpdatePropFlags _nm_device_notify_update_prop_ports(NMClient *              client,
+                                                                 NMLDBusObject *         dbobj,
+                                                                 const NMLDBusMetaIface *meta_iface,
+                                                                 guint     dbus_property_idx,
+                                                                 GVariant *value);
+
 /*****************************************************************************/
 
 #endif /* __NM_LIBNM_UTILS_H__ */