core: add and use NM_MANAGER_GET macro
For our singleton getters we usually have such a macro. See NM_PLATFORM_GET and NM_SETTINGS_GET. Add such a macro for NMManager and use it.
This commit is contained in:
@@ -81,7 +81,7 @@ ppp_ifindex_set (NMPPPManager *ppp_manager,
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (old_name)
|
if (old_name)
|
||||||
nm_manager_remove_device (nm_manager_get (), old_name, NM_DEVICE_TYPE_PPP);
|
nm_manager_remove_device (NM_MANAGER_GET, old_name, NM_DEVICE_TYPE_PPP);
|
||||||
|
|
||||||
nm_device_activate_schedule_stage3_ip_config_start (device);
|
nm_device_activate_schedule_stage3_ip_config_start (device);
|
||||||
}
|
}
|
||||||
|
@@ -145,7 +145,7 @@ act_stage1_prepare (NMDevice *device, NMDeviceStateReason *out_failure_reason)
|
|||||||
hwaddr_len);
|
hwaddr_len);
|
||||||
if ( lowpan_plink
|
if ( lowpan_plink
|
||||||
&& NM_FLAGS_HAS (lowpan_plink->n_ifi_flags, IFF_UP)) {
|
&& NM_FLAGS_HAS (lowpan_plink->n_ifi_flags, IFF_UP)) {
|
||||||
lowpan_device = nm_manager_get_device_by_ifindex (nm_manager_get (),
|
lowpan_device = nm_manager_get_device_by_ifindex (NM_MANAGER_GET,
|
||||||
lowpan_plink->ifindex);
|
lowpan_plink->ifindex);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -1717,7 +1717,7 @@ _parent_set_ifindex (NMDevice *self,
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (parent_ifindex > 0) {
|
if (parent_ifindex > 0) {
|
||||||
parent_device = nm_manager_get_device_by_ifindex (nm_manager_get (), parent_ifindex);
|
parent_device = nm_manager_get_device_by_ifindex (NM_MANAGER_GET, parent_ifindex);
|
||||||
if (parent_device == self)
|
if (parent_device == self)
|
||||||
parent_device = NULL;
|
parent_device = NULL;
|
||||||
} else
|
} else
|
||||||
@@ -2210,7 +2210,7 @@ nm_device_get_route_metric (NMDevice *self,
|
|||||||
if (route_metric >= 0)
|
if (route_metric >= 0)
|
||||||
goto out;
|
goto out;
|
||||||
|
|
||||||
route_metric = nm_manager_device_route_metric_reserve (nm_manager_get (),
|
route_metric = nm_manager_device_route_metric_reserve (NM_MANAGER_GET,
|
||||||
nm_device_get_ip_ifindex (self),
|
nm_device_get_ip_ifindex (self),
|
||||||
nm_device_get_device_type (self));
|
nm_device_get_device_type (self));
|
||||||
out:
|
out:
|
||||||
@@ -3676,7 +3676,7 @@ device_recheck_slave_status (NMDevice *self, const NMPlatformLink *plink)
|
|||||||
if (plink->master <= 0)
|
if (plink->master <= 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
master = nm_manager_get_device_by_ifindex (nm_manager_get (), plink->master);
|
master = nm_manager_get_device_by_ifindex (NM_MANAGER_GET, plink->master);
|
||||||
plink_master = nm_platform_link_get (nm_device_get_platform (self), plink->master);
|
plink_master = nm_platform_link_get (nm_device_get_platform (self), plink->master);
|
||||||
plink_master_keep_alive = nmp_object_ref (NMP_OBJECT_UP_CAST (plink_master));
|
plink_master_keep_alive = nmp_object_ref (NMP_OBJECT_UP_CAST (plink_master));
|
||||||
|
|
||||||
@@ -5895,7 +5895,7 @@ check_connection_compatible (NMDevice *self, NMConnection *connection, GError **
|
|||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
conn_iface = nm_manager_get_connection_iface (nm_manager_get (),
|
conn_iface = nm_manager_get_connection_iface (NM_MANAGER_GET,
|
||||||
connection,
|
connection,
|
||||||
NULL,
|
NULL,
|
||||||
&local);
|
&local);
|
||||||
@@ -10658,7 +10658,7 @@ start_sharing (NMDevice *self, NMIP4Config *config, GError **error)
|
|||||||
* the announced setting without restarting dnsmasq. That means, if the default
|
* the announced setting without restarting dnsmasq. That means, if the default
|
||||||
* route changes w.r.t. being metered, then the shared connection does not get
|
* route changes w.r.t. being metered, then the shared connection does not get
|
||||||
* updated before reactivating. */
|
* updated before reactivating. */
|
||||||
announce_android_metered = NM_IN_SET (nm_manager_get_metered (nm_manager_get ()),
|
announce_android_metered = NM_IN_SET (nm_manager_get_metered (NM_MANAGER_GET),
|
||||||
NM_METERED_YES,
|
NM_METERED_YES,
|
||||||
NM_METERED_GUESS_YES);
|
NM_METERED_GUESS_YES);
|
||||||
break;
|
break;
|
||||||
@@ -14668,7 +14668,7 @@ _cleanup_generic_pre (NMDevice *self, CleanupType cleanup_type)
|
|||||||
priv->stage1_sriov_state = NM_DEVICE_STAGE_STATE_INIT;
|
priv->stage1_sriov_state = NM_DEVICE_STAGE_STATE_INIT;
|
||||||
|
|
||||||
if (cleanup_type != CLEANUP_TYPE_KEEP) {
|
if (cleanup_type != CLEANUP_TYPE_KEEP) {
|
||||||
nm_manager_device_route_metric_clear (nm_manager_get (),
|
nm_manager_device_route_metric_clear (NM_MANAGER_GET,
|
||||||
nm_device_get_ip_ifindex (self));
|
nm_device_get_ip_ifindex (self));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -70,7 +70,7 @@ new_device_from_type (const char *name, NMDeviceType device_type)
|
|||||||
const char *type_desc;
|
const char *type_desc;
|
||||||
NMLinkType link_type = NM_LINK_TYPE_NONE;
|
NMLinkType link_type = NM_LINK_TYPE_NONE;
|
||||||
|
|
||||||
if (nm_manager_get_device (nm_manager_get (), name, device_type))
|
if (nm_manager_get_device (NM_MANAGER_GET, name, device_type))
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
if (device_type == NM_DEVICE_TYPE_OVS_INTERFACE) {
|
if (device_type == NM_DEVICE_TYPE_OVS_INTERFACE) {
|
||||||
@@ -117,7 +117,7 @@ ovsdb_device_removed (NMOvsdb *ovsdb, const char *name, NMDeviceType device_type
|
|||||||
NMDevice *device;
|
NMDevice *device;
|
||||||
NMDeviceState device_state;
|
NMDeviceState device_state;
|
||||||
|
|
||||||
device = nm_manager_get_device (nm_manager_get (), name, device_type);
|
device = nm_manager_get_device (NM_MANAGER_GET, name, device_type);
|
||||||
if (!device)
|
if (!device)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@@ -145,7 +145,7 @@ ovsdb_interface_failed (NMOvsdb *ovsdb,
|
|||||||
|
|
||||||
_LOGI (name, connection_uuid, "ovs interface \"%s\" (%s) failed: %s", name, connection_uuid, error);
|
_LOGI (name, connection_uuid, "ovs interface \"%s\" (%s) failed: %s", name, connection_uuid, error);
|
||||||
|
|
||||||
device = nm_manager_get_device (nm_manager_get (), name, NM_DEVICE_TYPE_OVS_INTERFACE);
|
device = nm_manager_get_device (NM_MANAGER_GET, name, NM_DEVICE_TYPE_OVS_INTERFACE);
|
||||||
if (!device)
|
if (!device)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
@@ -45,7 +45,7 @@ NM_DEVICE_FACTORY_DECLARE_TYPES (
|
|||||||
G_MODULE_EXPORT NMDeviceFactory *
|
G_MODULE_EXPORT NMDeviceFactory *
|
||||||
nm_device_factory_create (GError **error)
|
nm_device_factory_create (GError **error)
|
||||||
{
|
{
|
||||||
nm_manager_set_capability (nm_manager_get (), NM_CAPABILITY_TEAM);
|
nm_manager_set_capability (NM_MANAGER_GET, NM_CAPABILITY_TEAM);
|
||||||
return (NMDeviceFactory *) g_object_new (NM_TYPE_TEAM_FACTORY, NULL);
|
return (NMDeviceFactory *) g_object_new (NM_TYPE_TEAM_FACTORY, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -451,7 +451,7 @@ constructed (GObject *object)
|
|||||||
|
|
||||||
G_OBJECT_CLASS (nm_device_olpc_mesh_parent_class)->constructed (object);
|
G_OBJECT_CLASS (nm_device_olpc_mesh_parent_class)->constructed (object);
|
||||||
|
|
||||||
priv->manager = g_object_ref (nm_manager_get ());
|
priv->manager = g_object_ref (NM_MANAGER_GET);
|
||||||
|
|
||||||
g_signal_connect (priv->manager, NM_MANAGER_DEVICE_ADDED, G_CALLBACK (device_added_cb), self);
|
g_signal_connect (priv->manager, NM_MANAGER_DEVICE_ADDED, G_CALLBACK (device_added_cb), self);
|
||||||
g_signal_connect (priv->manager, NM_MANAGER_DEVICE_REMOVED, G_CALLBACK (device_removed_cb), self);
|
g_signal_connect (priv->manager, NM_MANAGER_DEVICE_REMOVED, G_CALLBACK (device_removed_cb), self);
|
||||||
|
@@ -881,7 +881,7 @@ nm_iwd_manager_init (NMIwdManager *self)
|
|||||||
{
|
{
|
||||||
NMIwdManagerPrivate *priv = NM_IWD_MANAGER_GET_PRIVATE (self);
|
NMIwdManagerPrivate *priv = NM_IWD_MANAGER_GET_PRIVATE (self);
|
||||||
|
|
||||||
priv->manager = g_object_ref (nm_manager_get ());
|
priv->manager = g_object_ref (NM_MANAGER_GET);
|
||||||
g_signal_connect (priv->manager, NM_MANAGER_DEVICE_ADDED,
|
g_signal_connect (priv->manager, NM_MANAGER_DEVICE_ADDED,
|
||||||
G_CALLBACK (device_added), self);
|
G_CALLBACK (device_added), self);
|
||||||
|
|
||||||
|
@@ -64,6 +64,7 @@ GType nm_manager_get_type (void);
|
|||||||
NMManager * nm_manager_setup (void);
|
NMManager * nm_manager_setup (void);
|
||||||
|
|
||||||
NMManager * nm_manager_get (void);
|
NMManager * nm_manager_get (void);
|
||||||
|
#define NM_MANAGER_GET (nm_manager_get ())
|
||||||
|
|
||||||
gboolean nm_manager_start (NMManager *manager,
|
gboolean nm_manager_start (NMManager *manager,
|
||||||
GError **error);
|
GError **error);
|
||||||
|
@@ -166,7 +166,7 @@ static void
|
|||||||
_clear_ip6_subnet (gpointer key, gpointer value, gpointer user_data)
|
_clear_ip6_subnet (gpointer key, gpointer value, gpointer user_data)
|
||||||
{
|
{
|
||||||
NMPlatformIP6Address *subnet = value;
|
NMPlatformIP6Address *subnet = value;
|
||||||
NMDevice *device = nm_manager_get_device_by_ifindex (nm_manager_get (),
|
NMDevice *device = nm_manager_get_device_by_ifindex (NM_MANAGER_GET,
|
||||||
GPOINTER_TO_INT (key));
|
GPOINTER_TO_INT (key));
|
||||||
|
|
||||||
if (device) {
|
if (device) {
|
||||||
|
@@ -1925,7 +1925,7 @@ write_connection_setting (NMSettingConnection *s_con, shvarFile *ifcfg)
|
|||||||
* it into an interface name, so that legacy tooling is not confused. */
|
* it into an interface name, so that legacy tooling is not confused. */
|
||||||
if (!nm_utils_get_testing ()) {
|
if (!nm_utils_get_testing ()) {
|
||||||
/* This is conditional for easier testing. */
|
/* This is conditional for easier testing. */
|
||||||
master_iface = nm_manager_iface_for_uuid (nm_manager_get (), master);
|
master_iface = nm_manager_iface_for_uuid (NM_MANAGER_GET, master);
|
||||||
}
|
}
|
||||||
if (!master_iface) {
|
if (!master_iface) {
|
||||||
master_iface = master;
|
master_iface = master;
|
||||||
|
Reference in New Issue
Block a user