connectivity: add connectivity-changed signal to NMDevice

NMManager very much cares about changes to the connectivity state
of the device and was therefore listening to notify::connectivity
signals. However, property changed signals can be suppressed by
g_object_freeze_notify(). That is something we even encourage for
NMDBusObject instances, because the D-Bus glue makes use of the
property changed notifications, and encourages to combine multiple
changes by freezing the signal.

Using the property changed notifications of NMDBusObject instances is
ugly. Don't do that and instead add a special signal.
This commit is contained in:
Thomas Haller 2018-04-11 11:31:39 +02:00
parent 8e8efbdc32
commit 8bb058386d
3 changed files with 12 additions and 2 deletions

View file

@ -180,6 +180,7 @@ enum {
REMOVED,
RECHECK_AUTO_ACTIVATE,
RECHECK_ASSUME,
CONNECTIVITY_CHANGED,
LAST_SIGNAL,
};
static guint signals[LAST_SIGNAL] = { 0 };
@ -2457,6 +2458,7 @@ concheck_update_state (NMDevice *self, NMConnectivityState state, gboolean is_pe
priv->connectivity_state = state;
_notify (self, PROP_CONNECTIVITY);
g_signal_emit (self, signals[CONNECTIVITY_CHANGED], 0);
if ( priv->state == NM_DEVICE_STATE_ACTIVATED
&& !nm_device_sys_iface_state_is_external (self)) {
@ -15744,4 +15746,12 @@ nm_device_class_init (NMDeviceClass *klass)
G_SIGNAL_RUN_FIRST,
0, NULL, NULL, NULL,
G_TYPE_NONE, 0);
signals[CONNECTIVITY_CHANGED] =
g_signal_new (NM_DEVICE_CONNECTIVITY_CHANGED,
G_OBJECT_CLASS_TYPE (object_class),
G_SIGNAL_RUN_FIRST,
0, NULL, NULL,
g_cclosure_marshal_VOID__VOID,
G_TYPE_NONE, 0);
}

View file

@ -135,6 +135,7 @@ nm_device_state_reason_check (NMDeviceStateReason reason)
#define NM_DEVICE_STATE_CHANGED "state-changed"
#define NM_DEVICE_LINK_INITIALIZED "link-initialized"
#define NM_DEVICE_AUTOCONNECT_ALLOWED "autoconnect-allowed"
#define NM_DEVICE_CONNECTIVITY_CHANGED "connectivity-changed"
#define NM_DEVICE_STATISTICS_REFRESH_RATE_MS "refresh-rate-ms"
#define NM_DEVICE_STATISTICS_TX_BYTES "tx-bytes"

View file

@ -2512,7 +2512,6 @@ device_realized (NMDevice *device,
static void
device_connectivity_changed (NMDevice *device,
GParamSpec *pspec,
NMManager *self)
{
NMManagerPrivate *priv = NM_MANAGER_GET_PRIVATE (self);
@ -2646,7 +2645,7 @@ add_device (NMManager *self, NMDevice *device, GError **error)
G_CALLBACK (device_realized),
self);
g_signal_connect (device, "notify::" NM_DEVICE_CONNECTIVITY,
g_signal_connect (device, NM_DEVICE_CONNECTIVITY_CHANGED,
G_CALLBACK (device_connectivity_changed),
self);