core: expose accessors to NMManager in NMSettings, NMSettingsConnection, NMDevice

We should avoid using the NM_MANAGER_GET singleton. Everybody already
has a manager instance. Expose it and allow to use it.
This commit is contained in:
Thomas Haller 2023-01-31 12:15:50 +01:00 committed by Fernando Fernandez Mancera
parent b5e347b313
commit 20f791d8fe
6 changed files with 36 additions and 4 deletions

View file

@ -29,10 +29,6 @@ enum NMActStageReturn {
#define NM_DEVICE_CAP_INTERNAL_MASK 0xc0000000
NMSettings *nm_device_get_settings(NMDevice *self);
NMManager *nm_device_get_manager(NMDevice *self);
gboolean nm_device_set_ip_ifindex(NMDevice *self, int ifindex);
gboolean nm_device_set_ip_iface(NMDevice *self, const char *iface);

View file

@ -421,6 +421,10 @@ typedef struct _NMDeviceClass {
const char *(*get_dhcp_anycast_address)(NMDevice *self);
} NMDeviceClass;
NMSettings *nm_device_get_settings(NMDevice *self);
NMManager *nm_device_get_manager(NMDevice *self);
GType nm_device_get_type(void);
struct _NMDedupMultiIndex *nm_device_get_multi_index(NMDevice *self);

View file

@ -227,6 +227,22 @@ static guint _get_seen_bssids(NMSettingsConnection *self,
/*****************************************************************************/
NMSettings *
nm_settings_connection_get_settings(NMSettingsConnection *self)
{
g_return_val_if_fail(NM_IS_SETTINGS_CONNECTION(self), NULL);
return NM_SETTINGS_CONNECTION_GET_PRIVATE(self)->settings;
}
NMManager *
nm_settings_connection_get_manager(NMSettingsConnection *self)
{
return nm_settings_get_manager(nm_settings_connection_get_settings(self));
}
/*****************************************************************************/
NMDevice *
nm_settings_connection_default_wired_get_device(NMSettingsConnection *self)
{

View file

@ -217,6 +217,10 @@ GType nm_settings_connection_get_type(void);
NMSettingsConnection *nm_settings_connection_new(void);
NMSettings *nm_settings_connection_get_settings(NMSettingsConnection *self);
NMManager *nm_settings_connection_get_manager(NMSettingsConnection *self);
NMConnection *nm_settings_connection_get_connection(NMSettingsConnection *self);
void _nm_settings_connection_set_connection(NMSettingsConnection *self,

View file

@ -451,6 +451,16 @@ static void _startup_complete_check(NMSettings *self, gint64 now_msec);
/*****************************************************************************/
NMManager *
nm_settings_get_manager(NMSettings *self)
{
g_return_val_if_fail(NM_IS_SETTINGS(self), NULL);
return NM_SETTINGS_GET_PRIVATE(self)->manager;
}
/*****************************************************************************/
static void
_emit_connection_added(NMSettings *self, NMSettingsConnection *sett_conn)
{

View file

@ -58,6 +58,8 @@ NMSettings *nm_settings_get(void);
NMSettings *nm_settings_new(NMManager *manager);
NMManager *nm_settings_get_manager(NMSettings *self);
gboolean nm_settings_start(NMSettings *self, GError **error);
typedef void (*NMSettingsAddCallback)(NMSettings *settings,