summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDan Williams <dcbw@redhat.com>2014-02-24 18:10:18 -0600
committerDan Williams <dcbw@redhat.com>2014-03-03 09:32:41 -0600
commit493bbbeb4a98a43c7f13cd89db4b14142fbecb7d (patch)
treeb7d1c859ed3fe6378951bd9a426cf63fd07fc555
parentaeb1e103d809210c4fffb719e72f3b9fb1c8fb90 (diff)
downloadNetworkManager-493bbbeb4a98a43c7f13cd89db4b14142fbecb7d.tar.gz
core: consolidate auto-activation recheck signals
Add a generic signal that devices can use to indicate that something material in the network situation changed, and that auto-activation may now be possible. This reduces specific knowledge of device types in the policy.
-rw-r--r--src/devices/nm-device-private.h2
-rw-r--r--src/devices/nm-device-wifi.c28
-rw-r--r--src/devices/nm-device.c14
-rw-r--r--src/devices/nm-device.h9
-rw-r--r--src/devices/wimax/nm-device-wimax.c22
-rw-r--r--src/devices/wwan/nm-device-modem.c1
-rw-r--r--src/nm-policy.c33
7 files changed, 59 insertions, 50 deletions
diff --git a/src/devices/nm-device-private.h b/src/devices/nm-device-private.h
index e4e5a4dbca..e5c9942b36 100644
--- a/src/devices/nm-device-private.h
+++ b/src/devices/nm-device-private.h
@@ -95,4 +95,6 @@ void nm_device_master_check_slave_physical_port (NMDevice *dev, NMDevice *slave,
void nm_device_set_carrier (NMDevice *device, gboolean carrier);
+void nm_device_emit_recheck_auto_activate (NMDevice *device);
+
#endif /* NM_DEVICE_PRIVATE_H */
diff --git a/src/devices/nm-device-wifi.c b/src/devices/nm-device-wifi.c
index f9c77d1409..df90671ed9 100644
--- a/src/devices/nm-device-wifi.c
+++ b/src/devices/nm-device-wifi.c
@@ -804,18 +804,31 @@ bring_up (NMDevice *device, gboolean *no_firmware)
}
static void
+emit_ap_added_removed (NMDeviceWifi *self,
+ guint signum,
+ NMAccessPoint *ap,
+ gboolean recheck_available_connections)
+{
+ g_signal_emit (self, signals[signum], 0, ap);
+ g_object_notify (G_OBJECT (self), NM_DEVICE_WIFI_ACCESS_POINTS);
+ nm_device_emit_recheck_auto_activate (NM_DEVICE (self));
+ if (recheck_available_connections)
+ nm_device_recheck_available_connections (NM_DEVICE (self));
+}
+
+static void
remove_access_point (NMDeviceWifi *device,
NMAccessPoint *ap)
{
- NMDeviceWifiPrivate *priv = NM_DEVICE_WIFI_GET_PRIVATE (device);
+ NMDeviceWifi *self = NM_DEVICE_WIFI (device);
+ NMDeviceWifiPrivate *priv = NM_DEVICE_WIFI_GET_PRIVATE (self);
g_return_if_fail (ap);
g_return_if_fail (ap != priv->current_ap);
g_return_if_fail (g_slist_find (priv->ap_list, ap));
priv->ap_list = g_slist_remove (priv->ap_list, ap);
- g_signal_emit (device, signals[ACCESS_POINT_REMOVED], 0, ap);
- g_object_notify (G_OBJECT (device), NM_DEVICE_WIFI_ACCESS_POINTS);
+ emit_ap_added_removed (self, ACCESS_POINT_REMOVED, ap, FALSE);
g_object_unref (ap);
}
@@ -1788,7 +1801,6 @@ supplicant_iface_scan_done_cb (NMSupplicantInterface *iface,
}
}
-
/****************************************************************************
* WPA Supplicant control stuff
*
@@ -1887,9 +1899,7 @@ merge_scanned_ap (NMDeviceWifi *self,
g_object_ref (merge_ap);
priv->ap_list = g_slist_prepend (priv->ap_list, merge_ap);
nm_ap_export_to_dbus (merge_ap);
- g_signal_emit (self, signals[ACCESS_POINT_ADDED], 0, merge_ap);
- g_object_notify (G_OBJECT (self), NM_DEVICE_WIFI_ACCESS_POINTS);
- nm_device_recheck_available_connections (NM_DEVICE (self));
+ emit_ap_added_removed (self, ACCESS_POINT_ADDED, merge_ap, TRUE);
}
}
@@ -2900,10 +2910,8 @@ act_stage1_prepare (NMDevice *dev, NMDeviceStateReason *reason)
nm_ap_export_to_dbus (ap);
g_object_freeze_notify (G_OBJECT (self));
set_current_ap (self, ap, FALSE, FALSE);
- g_signal_emit (self, signals[ACCESS_POINT_ADDED], 0, ap);
- g_object_notify (G_OBJECT (self), NM_DEVICE_WIFI_ACCESS_POINTS);
+ emit_ap_added_removed (self, ACCESS_POINT_ADDED, ap, TRUE);
g_object_thaw_notify (G_OBJECT (self));
- nm_device_recheck_available_connections (NM_DEVICE (self));
nm_active_connection_set_specific_object (NM_ACTIVE_CONNECTION (req), nm_ap_get_dbus_path (ap));
return NM_ACT_STAGE_RETURN_SUCCESS;
diff --git a/src/devices/nm-device.c b/src/devices/nm-device.c
index d4f16a62e7..3c069e04f8 100644
--- a/src/devices/nm-device.c
+++ b/src/devices/nm-device.c
@@ -113,6 +113,7 @@ enum {
IP4_CONFIG_CHANGED,
IP6_CONFIG_CHANGED,
REMOVED,
+ RECHECK_AUTO_ACTIVATE,
LAST_SIGNAL,
};
static guint signals[LAST_SIGNAL] = { 0 };
@@ -1964,6 +1965,12 @@ nm_device_can_assume_connections (NMDevice *device)
return !!NM_DEVICE_GET_CLASS (device)->update_connection;
}
+void
+nm_device_emit_recheck_auto_activate (NMDevice *self)
+{
+ g_signal_emit (self, signals[RECHECK_AUTO_ACTIVATE], 0);
+}
+
static void
dnsmasq_state_changed_cb (NMDnsMasqManager *manager, guint32 status, gpointer user_data)
{
@@ -6167,6 +6174,13 @@ nm_device_class_init (NMDeviceClass *klass)
0, NULL, NULL, NULL,
G_TYPE_NONE, 0);
+ signals[RECHECK_AUTO_ACTIVATE] =
+ g_signal_new (NM_DEVICE_RECHECK_AUTO_ACTIVATE,
+ G_OBJECT_CLASS_TYPE (object_class),
+ G_SIGNAL_RUN_FIRST,
+ 0, NULL, NULL, NULL,
+ G_TYPE_NONE, 0);
+
nm_dbus_manager_register_exported_type (nm_dbus_manager_get (),
G_TYPE_FROM_CLASS (klass),
&dbus_glib_nm_device_object_info);
diff --git a/src/devices/nm-device.h b/src/devices/nm-device.h
index 03e3b87ed0..48f7a3a00f 100644
--- a/src/devices/nm-device.h
+++ b/src/devices/nm-device.h
@@ -71,10 +71,11 @@
#define NM_DEVICE_HAS_PENDING_ACTION "has-pending-action" /* Internal only */
/* Internal signals */
-#define NM_DEVICE_AUTH_REQUEST "auth-request"
-#define NM_DEVICE_IP4_CONFIG_CHANGED "ip4-config-changed"
-#define NM_DEVICE_IP6_CONFIG_CHANGED "ip6-config-changed"
-#define NM_DEVICE_REMOVED "removed"
+#define NM_DEVICE_AUTH_REQUEST "auth-request"
+#define NM_DEVICE_IP4_CONFIG_CHANGED "ip4-config-changed"
+#define NM_DEVICE_IP6_CONFIG_CHANGED "ip6-config-changed"
+#define NM_DEVICE_REMOVED "removed"
+#define NM_DEVICE_RECHECK_AUTO_ACTIVATE "recheck-auto-activate"
G_BEGIN_DECLS
diff --git a/src/devices/wimax/nm-device-wimax.c b/src/devices/wimax/nm-device-wimax.c
index 995d3cf01b..bdf7d9d6e8 100644
--- a/src/devices/wimax/nm-device-wimax.c
+++ b/src/devices/wimax/nm-device-wimax.c
@@ -222,6 +222,19 @@ activation_timed_out (gpointer data)
}
static void
+emit_nsp_added_removed (NMDeviceWimax *self,
+ guint signum,
+ NMWimaxNsp *nsp,
+ gboolean recheck_available_connections)
+{
+ g_signal_emit (self, signals[signum], 0, nsp);
+ g_object_notify (G_OBJECT (self), NM_DEVICE_WIMAX_NSPS);
+ nm_device_emit_recheck_auto_activate (NM_DEVICE (self));
+ if (recheck_available_connections)
+ nm_device_recheck_available_connections (NM_DEVICE (self));
+}
+
+static void
remove_all_nsps (NMDeviceWimax *self)
{
NMDeviceWimaxPrivate *priv = NM_DEVICE_WIMAX_GET_PRIVATE (self);
@@ -232,8 +245,7 @@ remove_all_nsps (NMDeviceWimax *self)
NMWimaxNsp *nsp = NM_WIMAX_NSP (priv->nsp_list->data);
priv->nsp_list = g_slist_remove (priv->nsp_list, nsp);
- g_signal_emit (self, signals[NSP_REMOVED], 0, nsp);
- g_object_notify (G_OBJECT (self), NM_DEVICE_WIMAX_NSPS);
+ emit_nsp_added_removed (self, NSP_REMOVED, nsp, FALSE);
g_object_unref (nsp);
}
@@ -971,7 +983,7 @@ remove_outdated_nsps (NMDeviceWimax *self,
for (iter = to_remove; iter; iter = iter->next) {
NMWimaxNsp *nsp = NM_WIMAX_NSP (iter->data);
- g_signal_emit (self, signals[NSP_REMOVED], 0, nsp);
+ emit_nsp_added_removed (self, NSP_REMOVED, nsp, FALSE);
priv->nsp_list = g_slist_remove (priv->nsp_list, nsp);
g_object_unref (nsp);
}
@@ -1025,9 +1037,7 @@ wmx_scan_result_cb (struct wmxsdk *wmxsdk,
if (new_nsp) {
priv->nsp_list = g_slist_append (priv->nsp_list, nsp);
nm_wimax_nsp_export_to_dbus (nsp);
- g_signal_emit (self, signals[NSP_ADDED], 0, nsp);
- g_object_notify (G_OBJECT (self), NM_DEVICE_WIMAX_NSPS);
- nm_device_recheck_available_connections (NM_DEVICE (self));
+ emit_nsp_added_removed (self, NSP_ADDED, nsp, TRUE);
}
}
}
diff --git a/src/devices/wwan/nm-device-modem.c b/src/devices/wwan/nm-device-modem.c
index 723f86e4dd..d731c809a9 100644
--- a/src/devices/wwan/nm-device-modem.c
+++ b/src/devices/wwan/nm-device-modem.c
@@ -181,6 +181,7 @@ modem_enabled_cb (NMModem *modem, GParamSpec *pspec, gpointer user_data)
set_enabled (NM_DEVICE (self), nm_modem_get_mm_enabled (priv->modem));
g_signal_emit (G_OBJECT (self), signals[ENABLE_CHANGED], 0);
+ nm_device_emit_recheck_auto_activate (NM_DEVICE (self));
}
static void
diff --git a/src/nm-policy.c b/src/nm-policy.c
index 0eac715251..9fef8ff75b 100644
--- a/src/nm-policy.c
+++ b/src/nm-policy.c
@@ -1602,21 +1602,9 @@ device_autoconnect_changed (NMDevice *device,
}
static void
-wireless_networks_changed (NMDevice *device, GObject *ap, gpointer user_data)
+device_recheck_auto_activate (NMDevice *device, gpointer user_data)
{
- schedule_activate_check ((NMPolicy *) user_data, device);
-}
-
-static void
-nsps_changed (NMDevice *device, GObject *nsp, gpointer user_data)
-{
- schedule_activate_check ((NMPolicy *) user_data, device);
-}
-
-static void
-modem_enabled_changed (NMDevice *device, gpointer user_data)
-{
- schedule_activate_check ((NMPolicy *) (user_data), device);
+ schedule_activate_check (NM_POLICY (user_data), device);
}
typedef struct {
@@ -1654,22 +1642,7 @@ device_added (NMManager *manager, NMDevice *device, gpointer user_data)
_connect_device_signal (policy, device, NM_DEVICE_IP4_CONFIG_CHANGED, device_ip4_config_changed, FALSE);
_connect_device_signal (policy, device, NM_DEVICE_IP6_CONFIG_CHANGED, device_ip6_config_changed, FALSE);
_connect_device_signal (policy, device, "notify::" NM_DEVICE_AUTOCONNECT, device_autoconnect_changed, FALSE);
-
- switch (nm_device_get_device_type (device)) {
- case NM_DEVICE_TYPE_WIFI:
- _connect_device_signal (policy, device, "access-point-added", wireless_networks_changed, FALSE);
- _connect_device_signal (policy, device, "access-point-removed", wireless_networks_changed, FALSE);
- break;
- case NM_DEVICE_TYPE_WIMAX:
- _connect_device_signal (policy, device, "nsp-added", nsps_changed, FALSE);
- _connect_device_signal (policy, device, "nsp-removed", nsps_changed, FALSE);
- break;
- case NM_DEVICE_TYPE_MODEM:
- _connect_device_signal (policy, device, "enable-changed", modem_enabled_changed, FALSE);
- break;
- default:
- break;
- }
+ _connect_device_signal (policy, device, NM_DEVICE_RECHECK_AUTO_ACTIVATE, device_recheck_auto_activate, FALSE);
}
static void