Commit f642e88a authored by Dan Winship's avatar Dan Winship

core: add IP/DHCP config properties to o.fd.NM.Connection.Active

Add IP and DHCP config properties to the D-Bus ActiveConnection
objects.

For device connections, this is redundant with the properties already
on the Device object, but for VPN connections, this information was
not previously available.
parent fe2fb713
......@@ -45,12 +45,42 @@
whether it currently owns the default IPv4 route.
</tp:docstring>
</property>
<property name="Ip4Config" type="o" access="read">
<tp:docstring>
Object path of the Ip4Config object describing the configuration of the
connection. Only valid when the connection is in the
NM_ACTIVE_CONNECTION_STATE_ACTIVATED state.
</tp:docstring>
</property>
<property name="Dhcp4Config" type="o" access="read">
<tp:docstring>
Object path of the Dhcp4Config object describing the DHCP options
returned by the DHCP server (assuming the connection used DHCP). Only
valid when the connection is in the NM_ACTIVE_CONNECTION_STATE_ACTIVATED
state.
</tp:docstring>
</property>
<property name="Default6" type="b" access="read">
<tp:docstring>
Whether this active connection is the default IPv6 connection, i.e.
whether it currently owns the default IPv6 route.
</tp:docstring>
</property>
<property name="Ip6Config" type="o" access="read">
<tp:docstring>
Object path of the Ip6Config object describing the configuration of the
connection. Only valid when the connection is in the
NM_ACTIVE_CONNECTION_STATE_ACTIVATED state.
</tp:docstring>
</property>
<property name="Dhcp6Config" type="o" access="read">
<tp:docstring>
Object path of the Dhcp6Config object describing the DHCP options
returned by the DHCP server (assuming the connection used DHCP). Only
valid when the connection is in the NM_ACTIVE_CONNECTION_STATE_ACTIVATED
state.
</tp:docstring>
</property>
<property name="Vpn" type="b" access="read">
<tp:docstring>
Whether this active connection is also a VPN connection.
......
......@@ -56,6 +56,16 @@ typedef struct {
GSList *share_rules;
} NMActRequestPrivate;
enum {
PROP_0,
PROP_IP4_CONFIG,
PROP_DHCP4_CONFIG,
PROP_IP6_CONFIG,
PROP_DHCP6_CONFIG,
LAST_PROP
};
/*******************************************************************/
NMConnection *
......@@ -281,6 +291,14 @@ nm_act_request_add_share_rule (NMActRequest *req,
/********************************************************************/
static void
device_notify (GObject *object,
GParamSpec *pspec,
gpointer self)
{
g_object_notify (self, pspec->name);
}
static void
device_state_changed (NMActiveConnection *active,
NMDevice *device,
......@@ -301,6 +319,15 @@ device_state_changed (NMActiveConnection *active,
break;
case NM_DEVICE_STATE_ACTIVATED:
ac_state = NM_ACTIVE_CONNECTION_STATE_ACTIVATED;
g_signal_connect (device, "notify::" NM_DEVICE_IP4_CONFIG,
G_CALLBACK (device_notify), active);
g_signal_connect (device, "notify::" NM_DEVICE_DHCP4_CONFIG,
G_CALLBACK (device_notify), active);
g_signal_connect (device, "notify::" NM_DEVICE_IP6_CONFIG,
G_CALLBACK (device_notify), active);
g_signal_connect (device, "notify::" NM_DEVICE_DHCP6_CONFIG,
G_CALLBACK (device_notify), active);
break;
case NM_DEVICE_STATE_DEACTIVATING:
ac_state = NM_ACTIVE_CONNECTION_STATE_DEACTIVATING;
......@@ -310,6 +337,8 @@ device_state_changed (NMActiveConnection *active,
case NM_DEVICE_STATE_UNMANAGED:
case NM_DEVICE_STATE_UNAVAILABLE:
ac_state = NM_ACTIVE_CONNECTION_STATE_DEACTIVATED;
g_signal_handlers_disconnect_by_func (device, G_CALLBACK (device_notify), active);
break;
default:
break;
......@@ -413,6 +442,37 @@ dispose (GObject *object)
G_OBJECT_CLASS (nm_act_request_parent_class)->dispose (object);
}
static void
get_property (GObject *object, guint prop_id,
GValue *value, GParamSpec *pspec)
{
NMDevice *device;
device = nm_active_connection_get_device (NM_ACTIVE_CONNECTION (object));
if (!device) {
g_value_set_boxed (value, "/");
return;
}
switch (prop_id) {
case PROP_IP4_CONFIG:
g_object_get_property (G_OBJECT (device), NM_DEVICE_IP4_CONFIG, value);
break;
case PROP_DHCP4_CONFIG:
g_object_get_property (G_OBJECT (device), NM_DEVICE_DHCP4_CONFIG, value);
break;
case PROP_IP6_CONFIG:
g_object_get_property (G_OBJECT (device), NM_DEVICE_IP6_CONFIG, value);
break;
case PROP_DHCP6_CONFIG:
g_object_get_property (G_OBJECT (device), NM_DEVICE_DHCP6_CONFIG, value);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
}
}
static void
nm_act_request_class_init (NMActRequestClass *req_class)
{
......@@ -423,7 +483,18 @@ nm_act_request_class_init (NMActRequestClass *req_class)
/* virtual methods */
object_class->dispose = dispose;
object_class->get_property = get_property;
active_class->master_failed = master_failed;
active_class->device_state_changed = device_state_changed;
/* properties */
g_object_class_override_property (object_class, PROP_IP4_CONFIG,
NM_ACTIVE_CONNECTION_IP4_CONFIG);
g_object_class_override_property (object_class, PROP_DHCP4_CONFIG,
NM_ACTIVE_CONNECTION_DHCP4_CONFIG);
g_object_class_override_property (object_class, PROP_IP6_CONFIG,
NM_ACTIVE_CONNECTION_IP6_CONFIG);
g_object_class_override_property (object_class, PROP_DHCP6_CONFIG,
NM_ACTIVE_CONNECTION_DHCP6_CONFIG);
}
......@@ -74,7 +74,11 @@ enum {
PROP_DEVICES,
PROP_STATE,
PROP_DEFAULT,
PROP_IP4_CONFIG,
PROP_DHCP4_CONFIG,
PROP_DEFAULT6,
PROP_IP6_CONFIG,
PROP_DHCP6_CONFIG,
PROP_VPN,
PROP_MASTER,
......@@ -152,6 +156,14 @@ nm_active_connection_set_state (NMActiveConnection *self,
}
}
if ( new_state == NM_ACTIVE_CONNECTION_STATE_ACTIVATED
|| old_state == NM_ACTIVE_CONNECTION_STATE_ACTIVATED) {
g_object_notify (G_OBJECT (self), NM_ACTIVE_CONNECTION_IP4_CONFIG);
g_object_notify (G_OBJECT (self), NM_ACTIVE_CONNECTION_DHCP4_CONFIG);
g_object_notify (G_OBJECT (self), NM_ACTIVE_CONNECTION_IP6_CONFIG);
g_object_notify (G_OBJECT (self), NM_ACTIVE_CONNECTION_DHCP6_CONFIG);
}
if (priv->state == NM_ACTIVE_CONNECTION_STATE_DEACTIVATED) {
/* Device is no longer relevant when deactivated. So remove it and
* emit property change notification so clients re-read the value,
......@@ -712,9 +724,22 @@ get_property (GObject *object, guint prop_id,
case PROP_DEFAULT:
g_value_set_boolean (value, priv->is_default);
break;
case PROP_IP4_CONFIG:
/* The IP and DHCP config properties may be overridden by a subclass */
g_value_set_boxed (value, "/");
break;
case PROP_DHCP4_CONFIG:
g_value_set_boxed (value, "/");
break;
case PROP_DEFAULT6:
g_value_set_boolean (value, priv->is_default6);
break;
case PROP_IP6_CONFIG:
g_value_set_boxed (value, "/");
break;
case PROP_DHCP6_CONFIG:
g_value_set_boxed (value, "/");
break;
case PROP_VPN:
g_value_set_boolean (value, priv->vpn);
break;
......@@ -838,6 +863,20 @@ nm_active_connection_class_init (NMActiveConnectionClass *ac_class)
FALSE,
G_PARAM_READWRITE));
g_object_class_install_property (object_class, PROP_IP4_CONFIG,
g_param_spec_boxed (NM_ACTIVE_CONNECTION_IP4_CONFIG,
"IP4 Config",
"IP4 Config",
DBUS_TYPE_G_OBJECT_PATH,
G_PARAM_READABLE));
g_object_class_install_property (object_class, PROP_DHCP4_CONFIG,
g_param_spec_boxed (NM_ACTIVE_CONNECTION_DHCP4_CONFIG,
"DHCP4 Config",
"DHCP4 Config",
DBUS_TYPE_G_OBJECT_PATH,
G_PARAM_READABLE));
g_object_class_install_property (object_class, PROP_DEFAULT6,
g_param_spec_boolean (NM_ACTIVE_CONNECTION_DEFAULT6,
"Default6",
......@@ -845,6 +884,20 @@ nm_active_connection_class_init (NMActiveConnectionClass *ac_class)
FALSE,
G_PARAM_READWRITE));
g_object_class_install_property (object_class, PROP_IP6_CONFIG,
g_param_spec_boxed (NM_ACTIVE_CONNECTION_IP6_CONFIG,
"IP6 Config",
"IP6 Config",
DBUS_TYPE_G_OBJECT_PATH,
G_PARAM_READABLE));
g_object_class_install_property (object_class, PROP_DHCP6_CONFIG,
g_param_spec_boxed (NM_ACTIVE_CONNECTION_DHCP6_CONFIG,
"DHCP6 Config",
"DHCP6 Config",
DBUS_TYPE_G_OBJECT_PATH,
G_PARAM_READABLE));
g_object_class_install_property (object_class, PROP_VPN,
g_param_spec_boolean (NM_ACTIVE_CONNECTION_VPN,
"VPN",
......
......@@ -40,7 +40,11 @@
#define NM_ACTIVE_CONNECTION_DEVICES "devices"
#define NM_ACTIVE_CONNECTION_STATE "state"
#define NM_ACTIVE_CONNECTION_DEFAULT "default"
#define NM_ACTIVE_CONNECTION_IP4_CONFIG "ip4-config"
#define NM_ACTIVE_CONNECTION_DHCP4_CONFIG "dhcp4-config"
#define NM_ACTIVE_CONNECTION_DEFAULT6 "default6"
#define NM_ACTIVE_CONNECTION_IP6_CONFIG "ip6-config"
#define NM_ACTIVE_CONNECTION_DHCP6_CONFIG "dhcp6-config"
#define NM_ACTIVE_CONNECTION_VPN "vpn"
#define NM_ACTIVE_CONNECTION_MASTER "master"
......
......@@ -105,6 +105,8 @@ enum {
PROP_0,
PROP_VPN_STATE,
PROP_BANNER,
PROP_IP4_CONFIG,
PROP_IP6_CONFIG,
PROP_MASTER = 2000,
LAST_PROP
......@@ -1011,6 +1013,8 @@ nm_vpn_connection_ip4_config_get (DBusGProxy *proxy,
nm_ip4_config_merge_setting (config, nm_connection_get_setting_ip4_config (priv->connection));
priv->ip4_config = config;
nm_ip4_config_export (config);
g_object_notify (G_OBJECT (connection), NM_ACTIVE_CONNECTION_IP4_CONFIG);
nm_vpn_connection_config_maybe_complete (connection, TRUE);
}
......@@ -1152,6 +1156,8 @@ nm_vpn_connection_ip6_config_get (DBusGProxy *proxy,
nm_ip6_config_merge_setting (config, nm_connection_get_setting_ip6_config (priv->connection));
priv->ip6_config = config;
nm_ip6_config_export (config);
g_object_notify (G_OBJECT (connection), NM_ACTIVE_CONNECTION_IP6_CONFIG);
nm_vpn_connection_config_maybe_complete (connection, TRUE);
}
......@@ -1787,6 +1793,18 @@ get_property (GObject *object, guint prop_id,
case PROP_BANNER:
g_value_set_string (value, priv->banner ? priv->banner : "");
break;
case PROP_IP4_CONFIG:
if (priv->vpn_state == NM_VPN_CONNECTION_STATE_ACTIVATED && priv->ip4_config)
g_value_set_boxed (value, nm_ip4_config_get_dbus_path (priv->ip4_config));
else
g_value_set_boxed (value, "/");
break;
case PROP_IP6_CONFIG:
if (priv->vpn_state == NM_VPN_CONNECTION_STATE_ACTIVATED && priv->ip6_config)
g_value_set_boxed (value, nm_ip6_config_get_dbus_path (priv->ip6_config));
else
g_value_set_boxed (value, "/");
break;
case PROP_MASTER:
parent_dev = nm_active_connection_get_device (NM_ACTIVE_CONNECTION (object));
g_value_set_boxed (value, parent_dev ? nm_device_get_path (parent_dev) : "/");
......@@ -1832,6 +1850,11 @@ nm_vpn_connection_class_init (NMVPNConnectionClass *connection_class)
NULL,
G_PARAM_READABLE));
g_object_class_override_property (object_class, PROP_IP4_CONFIG,
NM_ACTIVE_CONNECTION_IP4_CONFIG);
g_object_class_override_property (object_class, PROP_IP6_CONFIG,
NM_ACTIVE_CONNECTION_IP6_CONFIG);
/* signals */
signals[VPN_STATE_CHANGED] =
g_signal_new ("vpn-state-changed",
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment