core: add NMDBusTrackObjPath helper

When one D-Bus object exposes (the path of) another D-Bus object,
we want that the path property gets cleared before the other
object gets unexported(). That essentially requires to register
to the "exported-changed" signal.

Add a helper struct NMDBusTrackObjPath to help with this.
This commit is contained in:
Thomas Haller
2018-04-03 16:37:20 +02:00
parent 4127f1234f
commit 86229a669b
2 changed files with 129 additions and 0 deletions

View File

@@ -179,4 +179,34 @@ void nm_dbus_utils_g_value_set_object_path_from_hash (GValue *value,
GHashTable *hash,
gboolean expect_all_exported);
/*****************************************************************************/
typedef struct {
union {
gpointer const obj;
gpointer _obj;
};
GObject *_notify_target;
const GParamSpec *_notify_pspec;
gulong _notify_signal_id;
union {
const bool visible;
bool _visible;
};
} NMDBusTrackObjPath;
void nm_dbus_track_obj_path_init (NMDBusTrackObjPath *track,
GObject *target,
const GParamSpec *pspec);
void nm_dbus_track_obj_path_deinit (NMDBusTrackObjPath *track);
void nm_dbus_track_obj_path_notify (const NMDBusTrackObjPath *track);
const char *nm_dbus_track_obj_path_get (const NMDBusTrackObjPath *track);
void nm_dbus_track_obj_path_set (NMDBusTrackObjPath *track,
gpointer obj,
gboolean visible);
#endif /* __NM_DBUS_UTILS_H__ */