diff options
| author | Michael Biebl <biebl@debian.org> | 2017-05-11 14:55:55 +0200 |
|---|---|---|
| committer | Michael Biebl <biebl@debian.org> | 2017-05-11 14:55:55 +0200 |
| commit | c333f062ddcba9b35330647bf6cbd0a07f2d786e (patch) | |
| tree | 257c3a0c74c09f4ad2328eab5b932806405f0c1c /libnm/nm-active-connection.c | |
| parent | a222e56e103f949b148a6942e385ccca2c26d9f3 (diff) | |
New upstream version 1.8.0 upstream/1.8.0
Diffstat (limited to 'libnm/nm-active-connection.c')
| -rw-r--r-- | libnm/nm-active-connection.c | 74 |
1 files changed, 74 insertions, 0 deletions
diff --git a/libnm/nm-active-connection.c b/libnm/nm-active-connection.c index 6a823403..412cb3ba 100644 --- a/libnm/nm-active-connection.c +++ b/libnm/nm-active-connection.c @@ -37,6 +37,8 @@ #include "nm-ip6-config.h" #include "nm-remote-connection.h" +#include "introspection/org.freedesktop.NetworkManager.Connection.Active.h" + G_DEFINE_TYPE (NMActiveConnection, nm_active_connection, NM_TYPE_OBJECT); #define NM_ACTIVE_CONNECTION_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), NM_TYPE_ACTIVE_CONNECTION, NMActiveConnectionPrivate)) @@ -57,6 +59,7 @@ typedef struct { NMDhcpConfig *dhcp6_config; gboolean is_vpn; NMDevice *master; + NMActiveConnectionStateReason reason; } NMActiveConnectionPrivate; enum { @@ -80,6 +83,14 @@ enum { LAST_PROP }; +enum { + STATE_CHANGED, + + LAST_SIGNAL +}; + +static guint signals[LAST_SIGNAL] = { 0 }; + /** * nm_active_connection_get_connection: * @connection: a #NMActiveConnection @@ -205,6 +216,24 @@ nm_active_connection_get_state (NMActiveConnection *connection) } /** + * nm_active_connection_get_state_reason: + * @connection: a #NMActiveConnection + * + * Gets the reason for active connection's state. + * + * Returns: the reason + * + * Since: 1.8 + **/ +NMActiveConnectionStateReason +nm_active_connection_get_state_reason (NMActiveConnection *connection) +{ + g_return_val_if_fail (NM_IS_ACTIVE_CONNECTION (connection), NM_ACTIVE_CONNECTION_STATE_REASON_UNKNOWN); + + return NM_ACTIVE_CONNECTION_GET_PRIVATE (connection)->reason; +} + +/** * nm_active_connection_get_default: * @connection: a #NMActiveConnection * @@ -351,9 +380,38 @@ nm_active_connection_init (NMActiveConnection *connection) } static void +state_changed_proxy (NMDBusActiveConnectionProxy *proxy, + NMActiveConnectionState state, + NMActiveConnectionStateReason reason, + gpointer user_data) +{ + NMActiveConnection *connection = NM_ACTIVE_CONNECTION (user_data); + NMActiveConnectionPrivate *priv = NM_ACTIVE_CONNECTION_GET_PRIVATE (connection); + + priv->state = state; + priv->reason = reason; + g_signal_emit (connection, signals[STATE_CHANGED], 0, state, reason); + g_object_notify (G_OBJECT (connection), NM_ACTIVE_CONNECTION_STATE); +} + +static void +constructed (GObject *object) +{ + GDBusProxy *proxy; + + proxy = _nm_object_get_proxy (NM_OBJECT (object), NM_DBUS_INTERFACE_ACTIVE_CONNECTION); + g_signal_connect (proxy, "state-changed", + G_CALLBACK (state_changed_proxy), object); + g_object_unref (proxy); + + G_OBJECT_CLASS (nm_active_connection_parent_class)->constructed (object); +} + +static void dispose (GObject *object) { NMActiveConnectionPrivate *priv = NM_ACTIVE_CONNECTION_GET_PRIVATE (object); + GDBusProxy *proxy; g_clear_pointer (&priv->devices, g_ptr_array_unref); @@ -364,6 +422,12 @@ dispose (GObject *object) g_clear_object (&priv->ip6_config); g_clear_object (&priv->dhcp6_config); + proxy = _nm_object_get_proxy (NM_OBJECT (object), NM_DBUS_INTERFACE_ACTIVE_CONNECTION); + if (proxy) { + g_signal_handlers_disconnect_by_data (proxy, object); + g_object_unref (proxy); + } + G_OBJECT_CLASS (nm_active_connection_parent_class)->dispose (object); } @@ -503,6 +567,7 @@ nm_active_connection_class_init (NMActiveConnectionClass *ap_class) /* virtual methods */ object_class->get_property = get_property; + object_class->constructed = constructed; object_class->dispose = dispose; object_class->finalize = finalize; @@ -693,4 +758,13 @@ nm_active_connection_class_init (NMActiveConnectionClass *ap_class) NM_TYPE_DEVICE, G_PARAM_READABLE | G_PARAM_STATIC_STRINGS)); + + /* signals */ + signals[STATE_CHANGED] = + g_signal_new ("state-changed", + G_OBJECT_CLASS_TYPE (object_class), + G_SIGNAL_RUN_FIRST, + 0, NULL, NULL, NULL, + G_TYPE_NONE, 2, + G_TYPE_UINT, G_TYPE_UINT); } |