Commit 1078935c authored by Thomas Haller's avatar Thomas Haller
Browse files

policy: merge branch 'th/policy-cleanup-v2'

parents 2716c7f1 f7729751
......@@ -9980,7 +9980,6 @@ static void
_cleanup_generic_post (NMDevice *self, CleanupType cleanup_type)
{
NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE (self);
NMDeviceStateReason ignored = NM_DEVICE_STATE_REASON_NONE;
priv->default_route.v4_has = FALSE;
priv->default_route.v6_has = FALSE;
......@@ -10005,8 +10004,8 @@ _cleanup_generic_post (NMDevice *self, CleanupType cleanup_type)
/* Clean up IP configs; this does not actually deconfigure the
* interface; the caller must flush routes and addresses explicitly.
*/
nm_device_set_ip4_config (self, NULL, 0, TRUE, TRUE, &ignored);
nm_device_set_ip6_config (self, NULL, TRUE, TRUE, &ignored);
nm_device_set_ip4_config (self, NULL, 0, TRUE, TRUE, NULL);
nm_device_set_ip6_config (self, NULL, TRUE, TRUE, NULL);
g_clear_object (&priv->con_ip4_config);
g_clear_object (&priv->dev_ip4_config);
g_clear_object (&priv->ext_ip4_config);
......
......@@ -86,12 +86,12 @@
G_BEGIN_DECLS
#define NM_TYPE_DEVICE (nm_device_get_type ())
#define NM_DEVICE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), NM_TYPE_DEVICE, NMDevice))
#define NM_DEVICE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), NM_TYPE_DEVICE, NMDeviceClass))
#define NM_IS_DEVICE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), NM_TYPE_DEVICE))
#define NM_IS_DEVICE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), NM_TYPE_DEVICE))
#define NM_DEVICE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), NM_TYPE_DEVICE, NMDeviceClass))
#define NM_TYPE_DEVICE (nm_device_get_type ())
#define NM_DEVICE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), NM_TYPE_DEVICE, NMDevice))
#define NM_DEVICE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), NM_TYPE_DEVICE, NMDeviceClass))
#define NM_IS_DEVICE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), NM_TYPE_DEVICE))
#define NM_IS_DEVICE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), NM_TYPE_DEVICE))
#define NM_DEVICE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), NM_TYPE_DEVICE, NMDeviceClass))
typedef enum NMActStageReturn NMActStageReturn;
......@@ -201,7 +201,7 @@ typedef struct {
NMDeviceCapabilities (* get_generic_capabilities) (NMDevice *self);
gboolean (* is_available) (NMDevice *self, NMDeviceCheckDevAvailableFlags flags);
gboolean (* is_available) (NMDevice *self, NMDeviceCheckDevAvailableFlags flags);
gboolean (* get_enabled) (NMDevice *self);
......@@ -239,19 +239,19 @@ typedef struct {
const GSList *existing_connections,
GError **error);
NMActStageReturn (* act_stage1_prepare) (NMDevice *self,
NMActStageReturn (* act_stage1_prepare) (NMDevice *self,
NMDeviceStateReason *reason);
NMActStageReturn (* act_stage2_config) (NMDevice *self,
NMActStageReturn (* act_stage2_config) (NMDevice *self,
NMDeviceStateReason *reason);
NMActStageReturn (* act_stage3_ip4_config_start) (NMDevice *self,
NMActStageReturn (* act_stage3_ip4_config_start) (NMDevice *self,
NMIP4Config **out_config,
NMDeviceStateReason *reason);
NMActStageReturn (* act_stage3_ip6_config_start) (NMDevice *self,
NMActStageReturn (* act_stage3_ip6_config_start) (NMDevice *self,
NMIP6Config **out_config,
NMDeviceStateReason *reason);
NMActStageReturn (* act_stage4_ip4_config_timeout) (NMDevice *self,
NMActStageReturn (* act_stage4_ip4_config_timeout) (NMDevice *self,
NMDeviceStateReason *reason);
NMActStageReturn (* act_stage4_ip6_config_timeout) (NMDevice *self,
NMActStageReturn (* act_stage4_ip6_config_timeout) (NMDevice *self,
NMDeviceStateReason *reason);
/* Called right before IP config is set; use for setting MTU etc */
......@@ -268,7 +268,7 @@ typedef struct {
GError **error);
/* Sync deactivating (in the DISCONNECTED phase) */
void (* deactivate) (NMDevice *self);
void (* deactivate) (NMDevice *self);
const char *(*get_type_description) (NMDevice *self);
......@@ -326,38 +326,38 @@ typedef void (*NMDeviceAuthRequestFunc) (NMDevice *device,
GType nm_device_get_type (void);
const char * nm_device_get_udi (NMDevice *dev);
const char * nm_device_get_iface (NMDevice *dev);
int nm_device_get_ifindex (NMDevice *dev);
gboolean nm_device_is_software (NMDevice *dev);
gboolean nm_device_is_real (NMDevice *dev);
const char * nm_device_get_ip_iface (NMDevice *dev);
int nm_device_get_ip_ifindex(NMDevice *dev);
const char * nm_device_get_driver (NMDevice *dev);
const char * nm_device_get_driver_version (NMDevice *dev);
const char * nm_device_get_type_desc (NMDevice *dev);
const char * nm_device_get_type_description (NMDevice *dev);
NMDeviceType nm_device_get_device_type (NMDevice *dev);
NMLinkType nm_device_get_link_type (NMDevice *dev);
NMMetered nm_device_get_metered (NMDevice *dev);
int nm_device_get_priority (NMDevice *dev);
guint32 nm_device_get_ip4_route_metric (NMDevice *dev);
guint32 nm_device_get_ip6_route_metric (NMDevice *dev);
const char * nm_device_get_hw_address (NMDevice *dev);
const char * nm_device_get_udi (NMDevice *dev);
const char * nm_device_get_iface (NMDevice *dev);
int nm_device_get_ifindex (NMDevice *dev);
gboolean nm_device_is_software (NMDevice *dev);
gboolean nm_device_is_real (NMDevice *dev);
const char * nm_device_get_ip_iface (NMDevice *dev);
int nm_device_get_ip_ifindex (NMDevice *dev);
const char * nm_device_get_driver (NMDevice *dev);
const char * nm_device_get_driver_version (NMDevice *dev);
const char * nm_device_get_type_desc (NMDevice *dev);
const char * nm_device_get_type_description (NMDevice *dev);
NMDeviceType nm_device_get_device_type (NMDevice *dev);
NMLinkType nm_device_get_link_type (NMDevice *dev);
NMMetered nm_device_get_metered (NMDevice *dev);
int nm_device_get_priority (NMDevice *dev);
guint32 nm_device_get_ip4_route_metric (NMDevice *dev);
guint32 nm_device_get_ip6_route_metric (NMDevice *dev);
const char * nm_device_get_hw_address (NMDevice *dev);
const char * nm_device_get_permanent_hw_address (NMDevice *dev);
const char * nm_device_get_initial_hw_address (NMDevice *dev);
const char * nm_device_get_initial_hw_address (NMDevice *dev);
NMDhcp4Config * nm_device_get_dhcp4_config (NMDevice *dev);
NMDhcp6Config * nm_device_get_dhcp6_config (NMDevice *dev);
NMDhcp4Config * nm_device_get_dhcp4_config (NMDevice *dev);
NMDhcp6Config * nm_device_get_dhcp6_config (NMDevice *dev);
NMIP4Config * nm_device_get_ip4_config (NMDevice *dev);
NMIP4Config * nm_device_get_ip4_config (NMDevice *dev);
void nm_device_replace_vpn4_config (NMDevice *dev,
NMIP4Config *old,
NMIP4Config *config);
NMIP6Config * nm_device_get_ip6_config (NMDevice *dev);
NMIP6Config * nm_device_get_ip6_config (NMDevice *dev);
void nm_device_replace_vpn6_config (NMDevice *dev,
NMIP6Config *old,
NMIP6Config *config);
......@@ -365,22 +365,22 @@ void nm_device_replace_vpn6_config (NMDevice *dev,
void nm_device_capture_initial_config (NMDevice *dev);
/* Master */
gboolean nm_device_is_master (NMDevice *dev);
gboolean nm_device_is_master (NMDevice *dev);
/* Slave */
NMDevice * nm_device_get_master (NMDevice *dev);
NMDevice * nm_device_get_master (NMDevice *dev);
NMActRequest * nm_device_get_act_request (NMDevice *dev);
NMSettingsConnection * nm_device_get_settings_connection (NMDevice *dev);
NMConnection * nm_device_get_applied_connection (NMDevice *dev);
gboolean nm_device_has_unmodified_applied_connection (NMDevice *self,
NMSettingCompareFlags compare_flags);
NMSetting * nm_device_get_applied_setting (NMDevice *dev, GType setting_type);
NMActRequest * nm_device_get_act_request (NMDevice *dev);
NMSettingsConnection *nm_device_get_settings_connection (NMDevice *dev);
NMConnection * nm_device_get_applied_connection (NMDevice *dev);
gboolean nm_device_has_unmodified_applied_connection (NMDevice *self,
NMSettingCompareFlags compare_flags);
NMSetting * nm_device_get_applied_setting (NMDevice *dev, GType setting_type);
void nm_device_removed (NMDevice *dev);
void nm_device_removed (NMDevice *dev);
gboolean nm_device_is_available (NMDevice *dev, NMDeviceCheckDevAvailableFlags flags);
gboolean nm_device_has_carrier (NMDevice *dev);
gboolean nm_device_is_available (NMDevice *dev, NMDeviceCheckDevAvailableFlags flags);
gboolean nm_device_has_carrier (NMDevice *dev);
NMConnection * nm_device_generate_connection (NMDevice *self, NMDevice *master);
......@@ -408,8 +408,8 @@ gboolean nm_device_can_assume_active_connection (NMDevice *device);
gboolean nm_device_spec_match_list (NMDevice *device, const GSList *specs);
gboolean nm_device_is_activating (NMDevice *dev);
gboolean nm_device_autoconnect_allowed (NMDevice *self);
gboolean nm_device_is_activating (NMDevice *dev);
gboolean nm_device_autoconnect_allowed (NMDevice *self);
NMDeviceState nm_device_get_state (NMDevice *device);
......@@ -568,4 +568,4 @@ void nm_device_update_dynamic_ip_setup (NMDevice *self);
G_END_DECLS
#endif /* NM_DEVICE_H */
#endif /* NM_DEVICE_H */
......@@ -1599,12 +1599,12 @@ nm_dns_manager_class_init (NMDnsManagerClass *klass)
/* signals */
signals[CONFIG_CHANGED] =
g_signal_new ("config-changed",
G_OBJECT_CLASS_TYPE (object_class),
G_SIGNAL_RUN_FIRST,
G_STRUCT_OFFSET (NMDnsManagerClass, config_changed),
NULL, NULL,
g_cclosure_marshal_VOID__VOID,
G_TYPE_NONE, 0);
g_signal_new (NM_DNS_MANAGER_CONFIG_CHANGED,
G_OBJECT_CLASS_TYPE (object_class),
G_SIGNAL_RUN_FIRST,
G_STRUCT_OFFSET (NMDnsManagerClass, config_changed),
NULL, NULL,
g_cclosure_marshal_VOID__VOID,
G_TYPE_NONE, 0);
}
......@@ -43,6 +43,8 @@ G_BEGIN_DECLS
#define NM_IS_DNS_MANAGER_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), NM_TYPE_DNS_MANAGER))
#define NM_DNS_MANAGER_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), NM_TYPE_DNS_MANAGER, NMDnsManagerClass))
#define NM_DNS_MANAGER_CONFIG_CHANGED "config-changed"
typedef struct {
GObject parent;
} NMDnsManager;
......
......@@ -520,7 +520,7 @@ nm_firewall_manager_class_init (NMFirewallManagerClass *klass)
G_PARAM_STATIC_STRINGS));
signals[STARTED] =
g_signal_new ("started",
g_signal_new (NM_FIREWALL_MANAGER_STARTED,
G_OBJECT_CLASS_TYPE (object_class),
G_SIGNAL_RUN_FIRST,
G_STRUCT_OFFSET (NMFirewallManagerClass, started),
......
......@@ -40,6 +40,8 @@ G_BEGIN_DECLS
#define NM_FIREWALL_MANAGER_AVAILABLE "available"
#define NM_FIREWALL_MANAGER_STARTED "started"
struct _NMFirewallManagerCallId;
typedef struct _NMFirewallManagerCallId *NMFirewallManagerCallId;
......
......@@ -154,7 +154,6 @@ enum {
INTERNAL_DEVICE_REMOVED,
STATE_CHANGED,
CHECK_PERMISSIONS,
USER_PERMISSIONS_CHANGED,
ACTIVE_CONNECTION_ADDED,
ACTIVE_CONNECTION_REMOVED,
CONFIGURE_QUIT,
......@@ -5706,7 +5705,7 @@ nm_manager_class_init (NMManagerClass *manager_class)
/* D-Bus exported; emitted only for realized devices */
signals[DEVICE_ADDED] =
g_signal_new ("device-added",
g_signal_new (NM_MANAGER_DEVICE_ADDED,
G_OBJECT_CLASS_TYPE (object_class),
G_SIGNAL_RUN_FIRST,
G_STRUCT_OFFSET (NMManagerClass, device_added),
......@@ -5715,7 +5714,7 @@ nm_manager_class_init (NMManagerClass *manager_class)
/* Emitted for both realized devices and placeholder devices */
signals[INTERNAL_DEVICE_ADDED] =
g_signal_new ("internal-device-added",
g_signal_new (NM_MANAGER_INTERNAL_DEVICE_ADDED,
G_OBJECT_CLASS_TYPE (object_class),
G_SIGNAL_RUN_FIRST, 0,
NULL, NULL, NULL,
......@@ -5723,7 +5722,7 @@ nm_manager_class_init (NMManagerClass *manager_class)
/* D-Bus exported; emitted only for realized devices */
signals[DEVICE_REMOVED] =
g_signal_new ("device-removed",
g_signal_new (NM_MANAGER_DEVICE_REMOVED,
G_OBJECT_CLASS_TYPE (object_class),
G_SIGNAL_RUN_FIRST,
G_STRUCT_OFFSET (NMManagerClass, device_removed),
......@@ -5732,7 +5731,7 @@ nm_manager_class_init (NMManagerClass *manager_class)
/* Emitted for both realized devices and placeholder devices */
signals[INTERNAL_DEVICE_REMOVED] =
g_signal_new ("internal-device-removed",
g_signal_new (NM_MANAGER_INTERNAL_DEVICE_REMOVED,
G_OBJECT_CLASS_TYPE (object_class),
G_SIGNAL_RUN_FIRST, 0,
NULL, NULL, NULL,
......@@ -5747,14 +5746,7 @@ nm_manager_class_init (NMManagerClass *manager_class)
G_TYPE_NONE, 1, G_TYPE_UINT);
signals[CHECK_PERMISSIONS] =
g_signal_new ("check-permissions",
G_OBJECT_CLASS_TYPE (object_class),
G_SIGNAL_RUN_FIRST,
0, NULL, NULL, NULL,
G_TYPE_NONE, 0);
signals[USER_PERMISSIONS_CHANGED] =
g_signal_new ("user-permissions-changed",
g_signal_new (NM_MANAGER_CHECK_PERMISSIONS,
G_OBJECT_CLASS_TYPE (object_class),
G_SIGNAL_RUN_FIRST,
0, NULL, NULL, NULL,
......
......@@ -57,11 +57,19 @@
#define NM_MANAGER_SLEEPING "sleeping"
#define NM_MANAGER_STATE_FILE "state-file"
/* signals */
#define NM_MANAGER_CHECK_PERMISSIONS "check-permissions"
#define NM_MANAGER_DEVICE_ADDED "device-added"
#define NM_MANAGER_DEVICE_REMOVED "device-removed"
#define NM_MANAGER_STATE_CHANGED "state-changed"
#define NM_MANAGER_USER_PERMISSIONS_CHANGED "user-permissions-changed"
/* Internal signals */
#define NM_MANAGER_ACTIVE_CONNECTION_ADDED "active-connection-added"
#define NM_MANAGER_ACTIVE_CONNECTION_REMOVED "active-connection-removed"
#define NM_MANAGER_CONFIGURE_QUIT "configure-quit"
#define NM_MANAGER_STATE_CHANGED "state-changed"
#define NM_MANAGER_INTERNAL_DEVICE_ADDED "internal-device-added"
#define NM_MANAGER_INTERNAL_DEVICE_REMOVED "internal-device-removed"
struct _NMManager {
......
......@@ -56,13 +56,15 @@
_NM_UTILS_MACRO_REST (__VA_ARGS__)); \
} G_STMT_END
typedef struct {
typedef struct _NMPolicyPrivate NMPolicyPrivate;
struct _NMPolicyPrivate {
NMPolicy *self;
NMManager *manager;
NMFirewallManager *firewall_manager;
GSList *pending_activation_checks;
GSList *manager_ids;
GSList *settings_ids;
GSList *dev_ids;
GHashTable *devices;
GSList *pending_secondaries;
......@@ -84,9 +86,14 @@ typedef struct {
char *orig_hostname; /* hostname at NM start time */
char *cur_hostname; /* hostname we want to assign */
gboolean hostname_changed; /* TRUE if NM ever set the hostname */
} NMPolicyPrivate;
};
#define NM_POLICY_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), NM_TYPE_POLICY, NMPolicyPrivate))
static NMPolicyPrivate *
NM_POLICY_GET_PRIVATE(NMPolicy *self)
{
nm_assert (NM_IS_POLICY (self));
return self->priv;
}
G_DEFINE_TYPE (NMPolicy, nm_policy, G_TYPE_OBJECT)
......@@ -832,15 +839,13 @@ process_secondaries (NMPolicy *self,
}
}
static void
global_state_changed (NMManager *manager, NMState state, gpointer user_data)
{
}
static void
hostname_changed (NMManager *manager, GParamSpec *pspec, gpointer user_data)
{
update_system_hostname ((NMPolicy *) user_data, NULL, NULL);
NMPolicyPrivate *priv = user_data;
NMPolicy *self = priv->self;
update_system_hostname (self, NULL, NULL);
}
static void
......@@ -913,7 +918,8 @@ block_autoconnect_for_device (NMPolicy *self, NMDevice *device)
static void
sleeping_changed (NMManager *manager, GParamSpec *pspec, gpointer user_data)
{
NMPolicy *self = user_data;
NMPolicyPrivate *priv = user_data;
NMPolicy *self = priv->self;
gboolean sleeping = FALSE, enabled = FALSE;
g_object_get (G_OBJECT (manager), NM_MANAGER_SLEEPING, &sleeping, NULL);
......@@ -1140,8 +1146,8 @@ device_state_changed (NMDevice *device,
NMDeviceStateReason reason,
gpointer user_data)
{
NMPolicy *self = (NMPolicy *) user_data;
NMPolicyPrivate *priv = NM_POLICY_GET_PRIVATE (self);
NMPolicyPrivate *priv = user_data;
NMPolicy *self = priv->self;
NMSettingsConnection *connection = nm_device_get_settings_connection (device);
......@@ -1286,8 +1292,8 @@ device_ip4_config_changed (NMDevice *device,
NMIP4Config *old_config,
gpointer user_data)
{
NMPolicy *self = user_data;
NMPolicyPrivate *priv = NM_POLICY_GET_PRIVATE (self);
NMPolicyPrivate *priv = user_data;
NMPolicy *self = priv->self;
const char *ip_iface = nm_device_get_ip_iface (device);
nm_dns_manager_begin_updates (priv->dns_manager, __func__);
......@@ -1320,8 +1326,8 @@ device_ip6_config_changed (NMDevice *device,
NMIP6Config *old_config,
gpointer user_data)
{
NMPolicy *self = user_data;
NMPolicyPrivate *priv = NM_POLICY_GET_PRIVATE (self);
NMPolicyPrivate *priv = user_data;
NMPolicy *self = priv->self;
const char *ip_iface = nm_device_get_ip_iface (device);
nm_dns_manager_begin_updates (priv->dns_manager, __func__);
......@@ -1353,77 +1359,70 @@ device_autoconnect_changed (NMDevice *device,
GParamSpec *pspec,
gpointer user_data)
{
NMPolicyPrivate *priv = user_data;
NMPolicy *self = priv->self;
if (nm_device_autoconnect_allowed (device))
schedule_activate_check ((NMPolicy *) user_data, device);
schedule_activate_check (self, device);
}
static void
device_recheck_auto_activate (NMDevice *device, gpointer user_data)
{
schedule_activate_check (NM_POLICY (user_data), device);
NMPolicyPrivate *priv = user_data;
NMPolicy *self = priv->self;
schedule_activate_check (self, device);
}
typedef struct {
gulong id;
NMDevice *device;
} DeviceSignalId;
static void
devices_list_unregister (NMPolicy *self, NMDevice *device)
{
NMPolicyPrivate *priv = NM_POLICY_GET_PRIVATE (self);
g_signal_handlers_disconnect_by_data ((GObject *) device, priv);
}
static void
_connect_device_signal (NMPolicy *self,
NMDevice *device,
const char *name,
gpointer callback,
gboolean after)
devices_list_register (NMPolicy *self, NMDevice *device)
{
NMPolicyPrivate *priv = NM_POLICY_GET_PRIVATE (self);
DeviceSignalId *data;
data = g_slice_new0 (DeviceSignalId);
g_assert (data);
if (after)
data->id = g_signal_connect_after (device, name, callback, self);
else
data->id = g_signal_connect (device, name, callback, self);
data->device = device;
priv->dev_ids = g_slist_prepend (priv->dev_ids, data);
/* Connect state-changed with _after, so that the handler is invoked after other handlers. */
g_signal_connect_after (device, NM_DEVICE_STATE_CHANGED, (GCallback) device_state_changed, priv);
g_signal_connect (device, NM_DEVICE_IP4_CONFIG_CHANGED, (GCallback) device_ip4_config_changed, priv);
g_signal_connect (device, NM_DEVICE_IP6_CONFIG_CHANGED, (GCallback) device_ip6_config_changed, priv);
g_signal_connect (device, "notify::" NM_DEVICE_AUTOCONNECT, (GCallback) device_autoconnect_changed, priv);
g_signal_connect (device, NM_DEVICE_RECHECK_AUTO_ACTIVATE, (GCallback) device_recheck_auto_activate, priv);
}
static void
device_added (NMManager *manager, NMDevice *device, gpointer user_data)
{
NMPolicy *self = (NMPolicy *) user_data;
NMPolicyPrivate *priv = user_data;
NMPolicy *self = priv->self;
/* Connect state-changed with _after, so that the handler is invoked after other handlers. */
_connect_device_signal (self, device, NM_DEVICE_STATE_CHANGED, device_state_changed, TRUE);
_connect_device_signal (self, device, NM_DEVICE_IP4_CONFIG_CHANGED, device_ip4_config_changed, FALSE);
_connect_device_signal (self, device, NM_DEVICE_IP6_CONFIG_CHANGED, device_ip6_config_changed, FALSE);
_connect_device_signal (self, device, "notify::" NM_DEVICE_AUTOCONNECT, device_autoconnect_changed, FALSE);
_connect_device_signal (self, device, NM_DEVICE_RECHECK_AUTO_ACTIVATE, device_recheck_auto_activate, FALSE);
g_return_if_fail (NM_IS_POLICY (self));
priv = NM_POLICY_GET_PRIVATE (self);
if (!nm_g_hash_table_add (priv->devices, device))
g_return_if_reached ();
devices_list_register (self, device);
}
static void
device_removed (NMManager *manager, NMDevice *device, gpointer user_data)
{
NMPolicy *self = (NMPolicy *) user_data;
NMPolicyPrivate *priv = NM_POLICY_GET_PRIVATE (self);
GSList *iter;
NMPolicyPrivate *priv = user_data;
NMPolicy *self = priv->self;
/* Clear any idle callbacks for this device */
clear_pending_activate_check (self, device);
/* Clear any signal handlers for this device */
iter = priv->dev_ids;
while (iter) {
DeviceSignalId *data = iter->data;
GSList *next = g_slist_next (iter);
if (data->device == device) {
g_signal_handler_disconnect (data->device, data->id);
g_slice_free (DeviceSignalId, data);
priv->dev_ids = g_slist_delete_link (priv->dev_ids, iter);
}
iter = next;
}
if (g_hash_table_remove (priv->devices, device))
devices_list_unregister (self, device);
/* Don't update routing and DNS here as we've already handled that
* for devices that need it when the device's state changed to UNMANAGED.
......@@ -1542,7 +1541,8 @@ active_connection_added (NMManager *manager,
NMActiveConnection *active,
gpointer user_data)
{
NMPolicy *self = NM_POLICY (user_data);
NMPolicyPrivate *priv = user_data;
NMPolicy *self = priv->self;
if (NM_IS_VPN_CONNECTION (active)) {
g_signal_connect (active, NM_VPN_CONNECTION_INTERNAL_STATE_CHANGED,
......@@ -1563,7 +1563,8 @@ active_connection_removed (NMManager *manager,
NMActiveConnection *active,
gpointer user_data)
{
NMPolicy *self = NM_POLICY (user_data);
NMPolicyPrivate *priv = user_data;
NMPolicy *self = priv->self;
g_signal_handlers_disconnect_by_func (active,
vpn_connection_state_changed,
......@@ -1593,7 +1594,8 @@ connection_added (NMSettings *settings,
NMSettingsConnection *connection,
gpointer user_data)
{
NMPolicy *self = NM_POLICY (user_data);
NMPolicyPrivate *priv = user_data;
NMPolicy *self = priv->self;
schedule_activate_all (self);
}
......@@ -1649,7 +1651,10 @@ connection_updated (NMSettings *settings,
NMConnection *connection,
gpointer user_data)
{
schedule_activate_all ((NMPolicy *) user_data);
NMPolicyPrivate *priv = user_data;
NMPolicy *self = priv->self;
schedule_activate_all (self);
}
static void
......@@ -1657,8 +1662,7 @@ connection_updated_by_user (NMSettings *settings,
NMSettingsConnection *connection,
gpointer user_data)
{
NMPolicy *self = (NMPolicy *) user_data;
NMPolicyPrivate *priv = NM_POLICY_GET_PRIVATE (self);
NMPolicyPrivate *priv = user_data;
const GSList *iter;
NMDevice *device = NULL;
......@@ -1711,8 +1715,7 @@ connection_removed (NMSettings *settings,
NMSettingsConnection *connection,
gpointer user_data)
{
NMPolicy *self = user_data;
NMPolicyPrivate *priv = NM_POLICY_GET_PRIVATE (self);
NMPolicyPrivate *priv = user_data;
_deactivate_if_active (priv->manager, connection);
}
......@@ -1722,8 +1725,8 @@ connection_visibility_changed (NMSettings *settings,
NMSettingsConnection *connection,
gpointer user_data)
{
NMPolicy *self = user_data;
NMPolicyPrivate *priv = NM_POLICY_GET_PRIVATE (self);
NMPolicyPrivate *priv = user_data;
NMPolicy *self = priv->self;
if (nm_settings_connection_is_visible (connection))
schedule_activate_all (self);
......@@ -1736,7 +1739,8 @@ secret_agent_registered (NMSettings *settings,
NMSecretAgent *agent,
gpointer user_data)
{
NMPolicy *self = NM_POLICY (user_data);
NMPolicyPrivate *priv = user_data;
NMPolicy *self = priv->self;
/* The registered secret agent may provide some missing secrets. Thus we
* reset retries count here and schedule activation, so that the
......@@ -1825,28 +1829,14 @@ set_property (GObject *object, guint prop_id,
/*****************************************************************************/
static void
_connect_manager_signal (NMPolicy *self,