diff options
author | Dan Williams <dcbw@redhat.com> | 2008-04-22 00:28:02 +0000 |
---|---|---|
committer | Dan Williams <dcbw@redhat.com> | 2008-04-22 00:28:02 +0000 |
commit | 675d12263a43342a3d212c0827982bf2e8125386 (patch) | |
tree | 1716dd951faf95ef83580234dc88d4e853ce795e /libnm-glib/nm-active-connection.c | |
parent | c96148167795596b106b51cf0de5e838ac7edfc8 (diff) | |
download | NetworkManager-675d12263a43342a3d212c0827982bf2e8125386.tar.gz |
2008-04-21 Dan Williams <dcbw@redhat.com>
* include/NetworkManager.h
- Add NMActiveConnectionState enum
* introspection/nm-active-connection.xml
introspection/nm-vpn-connection.xml
- Add 'State' property for overall active connection state
- Add 'Default' property, when True means this active connection
has the default route
- Add PropertyChanged signals so changes actually go out over the bus
* src/nm-active-connection.h
- Add defines for State & Default properties
* src/nm-activation-request.c
- Add 'state' and 'default' properties, hook up to device 'state-changed'
signal to determine active connection state
* src/vpn-manager/nm-vpn-connection.c
src/vpn-manager/nm-vpn-connection.h
src/vpn-manager/nm-vpn-manager.c
src/vpn-manager/nm-vpn-service.c
- Rename old 'state' to 'vpn-state'
- Rename nm_vpn_connection_get_state() -> nm_vpn_connection_get_vpn_state()
- Add 'state' and 'default' properties, hook up to the vpn connection's
'vpn-state-changed' signal
* libnm-glib/nm-active-connection.c
libnm-glib/nm-active-connection.h
- Add new 'state' and 'default' properties and accessors
* libnm-glib/nm-vpn-connection.c
libnm-glib/nm-vpn-connection.h
- Rename old 'state' property to 'vpn-state'
- Add new 'state' and 'default' properties and accessors
git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@3582 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
Diffstat (limited to 'libnm-glib/nm-active-connection.c')
-rw-r--r-- | libnm-glib/nm-active-connection.c | 66 |
1 files changed, 66 insertions, 0 deletions
diff --git a/libnm-glib/nm-active-connection.c b/libnm-glib/nm-active-connection.c index e8296027e3..367b2cbf36 100644 --- a/libnm-glib/nm-active-connection.c +++ b/libnm-glib/nm-active-connection.c @@ -29,6 +29,8 @@ typedef struct { char *shared_service_name; char *shared_connection; GPtrArray *devices; + NMActiveConnectionState state; + gboolean is_default; } NMActiveConnectionPrivate; enum { @@ -39,6 +41,8 @@ enum { PROP_SHARED_SERVICE_NAME, PROP_SHARED_CONNECTION, PROP_DEVICES, + PROP_STATE, + PROP_DEFAULT, LAST_PROP }; @@ -49,6 +53,8 @@ enum { #define DBUS_PROP_SHARED_SERVICE_NAME "SharedServiceName" #define DBUS_PROP_SHARED_CONNECTION "SharedConnection" #define DBUS_PROP_DEVICES "Devices" +#define DBUS_PROP_STATE "State" +#define DBUS_PROP_DEFAULT "Default" GObject * nm_active_connection_new (DBusGConnection *connection, const char *path) @@ -194,6 +200,40 @@ nm_active_connection_get_devices (NMActiveConnection *connection) return handle_ptr_array_return (priv->devices); } +NMActiveConnectionState +nm_active_connection_get_state (NMActiveConnection *connection) +{ + NMActiveConnectionPrivate *priv; + + g_return_val_if_fail (NM_IS_ACTIVE_CONNECTION (connection), NM_ACTIVE_CONNECTION_STATE_UNKNOWN); + + priv = NM_ACTIVE_CONNECTION_GET_PRIVATE (connection); + if (!priv->state) { + priv->state = nm_object_get_uint_property (NM_OBJECT (connection), + NM_DBUS_INTERFACE_ACTIVE_CONNECTION, + DBUS_PROP_STATE); + } + + return priv->state; +} + +gboolean +nm_active_connection_get_default (NMActiveConnection *connection) +{ + NMActiveConnectionPrivate *priv; + + g_return_val_if_fail (NM_IS_ACTIVE_CONNECTION (connection), FALSE); + + priv = NM_ACTIVE_CONNECTION_GET_PRIVATE (connection); + if (!priv->is_default) { + priv->is_default = nm_object_get_boolean_property (NM_OBJECT (connection), + NM_DBUS_INTERFACE_ACTIVE_CONNECTION, + DBUS_PROP_DEFAULT); + } + + return priv->is_default; +} + static void nm_active_connection_init (NMActiveConnection *ap) { @@ -261,6 +301,12 @@ get_property (GObject *object, case PROP_DEVICES: g_value_set_boxed (value, nm_active_connection_get_devices (self)); break; + case PROP_STATE: + g_value_set_uint (value, nm_active_connection_get_state (self)); + break; + case PROP_DEFAULT: + g_value_set_boolean (value, nm_active_connection_get_default (self)); + break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); break; @@ -303,6 +349,8 @@ register_for_property_changed (NMActiveConnection *connection) { NM_ACTIVE_CONNECTION_SHARED_SERVICE_NAME, nm_object_demarshal_generic, &priv->shared_service_name }, { NM_ACTIVE_CONNECTION_SHARED_CONNECTION, nm_object_demarshal_generic, &priv->shared_connection }, { NM_ACTIVE_CONNECTION_DEVICES, demarshal_devices, &priv->devices }, + { NM_ACTIVE_CONNECTION_STATE, nm_object_demarshal_generic, &priv->state }, + { NM_ACTIVE_CONNECTION_DEFAULT, nm_object_demarshal_generic, &priv->is_default }, { NULL }, }; @@ -399,4 +447,22 @@ nm_active_connection_class_init (NMActiveConnectionClass *ap_class) "Devices", NM_TYPE_OBJECT_ARRAY, G_PARAM_READABLE)); + + g_object_class_install_property + (object_class, PROP_STATE, + g_param_spec_uint (NM_ACTIVE_CONNECTION_STATE, + "State", + "State", + NM_ACTIVE_CONNECTION_STATE_UNKNOWN, + NM_ACTIVE_CONNECTION_STATE_ACTIVATED, + NM_ACTIVE_CONNECTION_STATE_UNKNOWN, + G_PARAM_READABLE)); + + g_object_class_install_property + (object_class, PROP_DEFAULT, + g_param_spec_boolean (NM_ACTIVE_CONNECTION_DEFAULT, + "Default", + "Is the default active connection", + FALSE, + G_PARAM_READABLE)); } |