summaryrefslogtreecommitdiff
path: root/src/nm-active-connection.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/nm-active-connection.c')
-rw-r--r--src/nm-active-connection.c67
1 files changed, 57 insertions, 10 deletions
diff --git a/src/nm-active-connection.c b/src/nm-active-connection.c
index d40d571e8..3a8e6cf58 100644
--- a/src/nm-active-connection.c
+++ b/src/nm-active-connection.c
@@ -100,6 +100,7 @@ enum {
enum {
DEVICE_CHANGED,
+ DEVICE_METERED_CHANGED,
LAST_SIGNAL
};
static guint signals[LAST_SIGNAL] = { 0 };
@@ -109,6 +110,29 @@ static void _device_cleanup (NMActiveConnection *self);
/****************************************************************/
+#define _NMLOG_DOMAIN LOGD_DEVICE
+#define _NMLOG_PREFIX_NAME "active-connection"
+#define _NMLOG(level, ...) \
+ G_STMT_START { \
+ const NMLogLevel __level = (level); \
+ \
+ if (nm_logging_enabled (__level, _NMLOG_DOMAIN)) { \
+ char __prefix[128]; \
+ const char *__p_prefix = _NMLOG_PREFIX_NAME; \
+ const void *const __self = (self); \
+ \
+ if (__self) { \
+ g_snprintf (__prefix, sizeof (__prefix), "%s[%p]", _NMLOG_PREFIX_NAME, __self); \
+ __p_prefix = __prefix; \
+ } \
+ _nm_log (__level, _NMLOG_DOMAIN, 0, \
+ "%s: " _NM_UTILS_MACRO_FIRST (__VA_ARGS__), \
+ __p_prefix _NM_UTILS_MACRO_REST (__VA_ARGS__)); \
+ } \
+ } G_STMT_END
+
+/****************************************************************/
+
static const char *
state_to_string (NMActiveConnectionState state)
{
@@ -401,6 +425,18 @@ device_master_changed (GObject *object,
}
}
+static void
+device_metered_changed (GObject *object,
+ GParamSpec *pspec,
+ gpointer user_data)
+{
+ NMActiveConnection *self = (NMActiveConnection *) user_data;
+ NMDevice *device = NM_DEVICE (object);
+
+ g_return_if_fail (NM_IS_ACTIVE_CONNECTION (self));
+ g_signal_emit (self, signals[DEVICE_METERED_CHANGED], 0, nm_device_get_metered (device));
+}
+
gboolean
nm_active_connection_set_device (NMActiveConnection *self, NMDevice *device)
{
@@ -427,6 +463,8 @@ nm_active_connection_set_device (NMActiveConnection *self, NMDevice *device)
G_CALLBACK (device_state_changed), self);
g_signal_connect (device, "notify::master",
G_CALLBACK (device_master_changed), self);
+ g_signal_connect (device, "notify::" NM_DEVICE_METERED,
+ G_CALLBACK (device_metered_changed), self);
if (!priv->assumed) {
priv->pending_activation_id = g_strdup_printf ("activation::%p", (void *)self);
@@ -473,15 +511,15 @@ check_master_ready (NMActiveConnection *self)
NMActiveConnectionState master_state = NM_ACTIVE_CONNECTION_STATE_UNKNOWN;
if (priv->state != NM_ACTIVE_CONNECTION_STATE_ACTIVATING) {
- nm_log_dbg (LOGD_DEVICE, "(%p): not signalling master-ready (not activating)", self);
+ _LOGD ("not signalling master-ready (not activating)");
return;
}
if (!priv->master) {
- nm_log_dbg (LOGD_DEVICE, "(%p): not signalling master-ready (no master)", self);
+ _LOGD ("not signalling master-ready (no master)");
return;
}
if (priv->master_ready) {
- nm_log_dbg (LOGD_DEVICE, "(%p): not signalling master-ready (already signaled)", self);
+ _LOGD ("not signalling master-ready (already signaled)");
return;
}
@@ -491,12 +529,12 @@ check_master_ready (NMActiveConnection *self)
* or higher states.
*/
master_state = nm_active_connection_get_state (priv->master);
- nm_log_dbg (LOGD_DEVICE, "(%p): master ActiveConnection [%p] state now '%s' (%d)",
- self, priv->master, state_to_string (master_state), master_state);
+ _LOGD ("master ActiveConnection [%p] state now '%s' (%d)",
+ priv->master, state_to_string (master_state), master_state);
if ( master_state == NM_ACTIVE_CONNECTION_STATE_ACTIVATING
|| master_state == NM_ACTIVE_CONNECTION_STATE_ACTIVATED) {
- nm_log_dbg (LOGD_DEVICE, "(%p): signalling master-ready", self);
+ _LOGD ("signalling master-ready");
priv->master_ready = TRUE;
g_object_notify (G_OBJECT (self), NM_ACTIVE_CONNECTION_INT_MASTER_READY);
@@ -520,8 +558,8 @@ master_state_cb (NMActiveConnection *master,
check_master_ready (self);
- nm_log_dbg (LOGD_DEVICE, "(%p): master ActiveConnection [%p] state now '%s' (%d)",
- self, master, state_to_string (master_state), master_state);
+ _LOGD ("master ActiveConnection [%p] state now '%s' (%d)",
+ master, state_to_string (master_state), master_state);
if ( master_state >= NM_ACTIVE_CONNECTION_STATE_DEACTIVATING
&& !priv->master_ready) {
@@ -558,8 +596,8 @@ nm_active_connection_set_master (NMActiveConnection *self, NMActiveConnection *m
g_return_if_fail (priv->device != nm_active_connection_get_device (master));
}
- nm_log_dbg (LOGD_DEVICE, "(%p): master ActiveConnection is [%p] %s",
- self, master, nm_active_connection_get_id (master));
+ _LOGD ("master ActiveConnection is [%p] %s",
+ master, nm_active_connection_get_id (master));
priv->master = g_object_ref (master);
g_signal_connect (priv->master,
@@ -838,6 +876,7 @@ _device_cleanup (NMActiveConnection *self)
if (priv->device) {
g_signal_handlers_disconnect_by_func (priv->device, G_CALLBACK (device_state_changed), self);
g_signal_handlers_disconnect_by_func (priv->device, G_CALLBACK (device_master_changed), self);
+ g_signal_handlers_disconnect_by_func (priv->device, G_CALLBACK (device_metered_changed), self);
}
if (priv->pending_activation_id) {
@@ -1043,6 +1082,14 @@ nm_active_connection_class_init (NMActiveConnectionClass *ac_class)
NULL, NULL, NULL,
G_TYPE_NONE, 2, NM_TYPE_DEVICE, NM_TYPE_DEVICE);
+ signals[DEVICE_METERED_CHANGED] =
+ g_signal_new (NM_ACTIVE_CONNECTION_DEVICE_METERED_CHANGED,
+ G_OBJECT_CLASS_TYPE (object_class),
+ G_SIGNAL_RUN_FIRST,
+ G_STRUCT_OFFSET (NMActiveConnectionClass, device_metered_changed),
+ NULL, NULL, NULL,
+ G_TYPE_NONE, 1, G_TYPE_UINT);
+
nm_dbus_manager_register_exported_type (nm_dbus_manager_get (),
G_TYPE_FROM_CLASS (ac_class),
&dbus_glib_nm_active_connection_object_info);