diff options
| author | Michael Biebl <biebl@debian.org> | 2017-01-17 20:25:09 +0100 |
|---|---|---|
| committer | Michael Biebl <biebl@debian.org> | 2017-01-17 20:25:09 +0100 |
| commit | 58f8be580039b0575b197b9573a1c92745d96d30 (patch) | |
| tree | 2c226233f623a0dcb529be0eb8cdf97e4a2ae0c0 /src/nm-active-connection.c | |
| parent | 45cb5bb3c0e6edb887cf69b417fcaf7053814a9b (diff) | |
New upstream version 1.5.90 upstream/1.5.90
Diffstat (limited to 'src/nm-active-connection.c')
| -rw-r--r-- | src/nm-active-connection.c | 218 |
1 files changed, 120 insertions, 98 deletions
diff --git a/src/nm-active-connection.c b/src/nm-active-connection.c index 1844587c..17fb82e5 100644 --- a/src/nm-active-connection.c +++ b/src/nm-active-connection.c @@ -24,24 +24,17 @@ #include "nm-common-macros.h" #include "nm-dbus-interface.h" -#include "nm-device.h" -#include "nm-settings-connection.h" +#include "devices/nm-device.h" +#include "settings/nm-settings-connection.h" #include "nm-simple-connection.h" #include "nm-auth-utils.h" #include "nm-auth-subject.h" #include "NetworkManagerUtils.h" #include "nm-core-internal.h" -#include "nmdbus-active-connection.h" +#include "introspection/org.freedesktop.NetworkManager.Connection.Active.h" -/* Base class for anything implementing the Connection.Active D-Bus interface */ -G_DEFINE_ABSTRACT_TYPE (NMActiveConnection, nm_active_connection, NM_TYPE_EXPORTED_OBJECT) - -#define NM_ACTIVE_CONNECTION_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), \ - NM_TYPE_ACTIVE_CONNECTION, \ - NMActiveConnectionPrivate)) - -typedef struct { +typedef struct _NMActiveConnectionPrivate { NMSettingsConnection *settings_connection; NMConnection *applied_connection; char *specific_object; @@ -90,6 +83,7 @@ NM_GOBJECT_PROPERTIES_DEFINE (NMActiveConnection, PROP_MASTER, PROP_INT_SETTINGS_CONNECTION, + PROP_INT_APPLIED_CONNECTION, PROP_INT_DEVICE, PROP_INT_SUBJECT, PROP_INT_MASTER, @@ -104,10 +98,14 @@ enum { }; static guint signals[LAST_SIGNAL] = { 0 }; +G_DEFINE_ABSTRACT_TYPE (NMActiveConnection, nm_active_connection, NM_TYPE_EXPORTED_OBJECT) + +#define NM_ACTIVE_CONNECTION_GET_PRIVATE(self) _NM_GET_PRIVATE_PTR(self, NMActiveConnection, NM_IS_ACTIVE_CONNECTION) + static void check_master_ready (NMActiveConnection *self); static void _device_cleanup (NMActiveConnection *self); -/****************************************************************/ +/*****************************************************************************/ #define _NMLOG_DOMAIN LOGD_DEVICE #define _NMLOG_PREFIX_NAME "active-connection" @@ -122,7 +120,7 @@ static void _device_cleanup (NMActiveConnection *self); _NM_UTILS_MACRO_REST (__VA_ARGS__)); \ } G_STMT_END -/****************************************************************/ +/*****************************************************************************/ NM_UTILS_LOOKUP_STR_DEFINE_STATIC (_state_to_string, NMActiveConnectionState, NM_UTILS_LOOKUP_DEFAULT (NULL), @@ -134,7 +132,7 @@ NM_UTILS_LOOKUP_STR_DEFINE_STATIC (_state_to_string, NMActiveConnectionState, ); #define state_to_string(state) NM_UTILS_LOOKUP_STR (_state_to_string, state) -/****************************************************************/ +/*****************************************************************************/ static void _settings_connection_updated (NMSettingsConnection *connection, @@ -335,7 +333,7 @@ nm_active_connection_has_unmodified_applied_connection (NMActiveConnection *self compare_flags); } -/*******************************************************************/ +/*****************************************************************************/ void nm_active_connection_clear_secrets (NMActiveConnection *self) @@ -353,7 +351,7 @@ nm_active_connection_clear_secrets (NMActiveConnection *self) nm_connection_clear_secrets (priv->applied_connection); } -/*******************************************************************/ +/*****************************************************************************/ const char * nm_active_connection_get_specific_object (NMActiveConnection *self) @@ -717,7 +715,7 @@ nm_active_connection_get_assumed (NMActiveConnection *self) return NM_ACTIVE_CONNECTION_GET_PRIVATE (self)->assumed; } -/****************************************************************/ +/*****************************************************************************/ static void unwatch_parent (NMActiveConnection *self, gboolean unref); @@ -781,7 +779,7 @@ nm_active_connection_set_parent (NMActiveConnection *self, NMActiveConnection *p g_object_weak_ref ((GObject *) priv->parent, parent_destroyed, self); } -/****************************************************************/ +/*****************************************************************************/ static void auth_done (NMAuthChain *chain, @@ -900,7 +898,7 @@ nm_active_connection_authorize (NMActiveConnection *self, priv->user_data2 = user_data2; } -/****************************************************************/ +/*****************************************************************************/ static guint64 _version_id_new (void) @@ -931,88 +929,34 @@ nm_active_connection_version_id_bump (NMActiveConnection *self) return priv->version_id; } -/****************************************************************/ - -static void -nm_active_connection_init (NMActiveConnection *self) -{ - NMActiveConnectionPrivate *priv = NM_ACTIVE_CONNECTION_GET_PRIVATE (self); - - _LOGT ("creating"); - - priv->version_id = _version_id_new (); -} +/*****************************************************************************/ static void -constructed (GObject *object) +_device_cleanup (NMActiveConnection *self) { - NMActiveConnection *self = (NMActiveConnection *) object; NMActiveConnectionPrivate *priv = NM_ACTIVE_CONNECTION_GET_PRIVATE (self); - G_OBJECT_CLASS (nm_active_connection_parent_class)->constructed (object); + 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); + } - _LOGD ("constructed (%s, version-id %llu)", G_OBJECT_TYPE_NAME (self), (long long unsigned) priv->version_id); + if (priv->pending_activation_id) { + nm_device_remove_pending_action (priv->device, priv->pending_activation_id, TRUE); + g_clear_pointer (&priv->pending_activation_id, g_free); + } - g_return_if_fail (priv->subject); + g_clear_object (&priv->device); } -static void -set_property (GObject *object, guint prop_id, - const GValue *value, GParamSpec *pspec) -{ - NMActiveConnection *self = (NMActiveConnection *) object; - NMActiveConnectionPrivate *priv = NM_ACTIVE_CONNECTION_GET_PRIVATE (self); - const char *tmp; - NMSettingsConnection *con; - - switch (prop_id) { - case PROP_INT_SETTINGS_CONNECTION: - /* construct-only */ - con = g_value_get_object (value); - if (con) { - _set_settings_connection (self, con); - priv->applied_connection = nm_simple_connection_new_clone ((NMConnection *) priv->settings_connection); - nm_connection_clear_secrets (priv->applied_connection); - } - break; - case PROP_INT_DEVICE: - /* construct-only */ - nm_active_connection_set_device (self, g_value_get_object (value)); - break; - case PROP_INT_SUBJECT: - priv->subject = g_value_dup_object (value); - break; - case PROP_INT_MASTER: - nm_active_connection_set_master (self, g_value_get_object (value)); - break; - case PROP_SPECIFIC_OBJECT: - tmp = g_value_get_string (value); - /* NM uses "/" to mean NULL */ - if (g_strcmp0 (tmp, "/") != 0) - priv->specific_object = g_strdup (tmp); - break; - case PROP_DEFAULT: - priv->is_default = !!g_value_get_boolean (value); - break; - case PROP_DEFAULT6: - priv->is_default6 = !!g_value_get_boolean (value); - break; - case PROP_VPN: - priv->vpn = g_value_get_boolean (value); - break; - case PROP_MASTER: - break; - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); - break; - } -} +/*****************************************************************************/ static void get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec) { - NMActiveConnectionPrivate *priv = NM_ACTIVE_CONNECTION_GET_PRIVATE (object); + NMActiveConnectionPrivate *priv = NM_ACTIVE_CONNECTION_GET_PRIVATE ((NMActiveConnection *) object); GPtrArray *devices; NMDevice *master_device = NULL; @@ -1089,22 +1033,95 @@ get_property (GObject *object, guint prop_id, } static void -_device_cleanup (NMActiveConnection *self) +set_property (GObject *object, guint prop_id, + const GValue *value, GParamSpec *pspec) { + NMActiveConnection *self = (NMActiveConnection *) object; NMActiveConnectionPrivate *priv = NM_ACTIVE_CONNECTION_GET_PRIVATE (self); + const char *tmp; + NMSettingsConnection *con; + NMConnection *acon; - 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); + switch (prop_id) { + case PROP_INT_SETTINGS_CONNECTION: + /* construct-only */ + con = g_value_get_object (value); + if (con) + _set_settings_connection (self, con); + break; + case PROP_INT_APPLIED_CONNECTION: + /* construct-only */ + acon = g_value_get_object (value); + if (acon) + priv->applied_connection = g_object_ref (acon); + break; + case PROP_INT_DEVICE: + /* construct-only */ + nm_active_connection_set_device (self, g_value_get_object (value)); + break; + case PROP_INT_SUBJECT: + priv->subject = g_value_dup_object (value); + break; + case PROP_INT_MASTER: + nm_active_connection_set_master (self, g_value_get_object (value)); + break; + case PROP_SPECIFIC_OBJECT: + tmp = g_value_get_string (value); + /* NM uses "/" to mean NULL */ + if (g_strcmp0 (tmp, "/") != 0) + priv->specific_object = g_strdup (tmp); + break; + case PROP_DEFAULT: + priv->is_default = !!g_value_get_boolean (value); + break; + case PROP_DEFAULT6: + priv->is_default6 = !!g_value_get_boolean (value); + break; + case PROP_VPN: + priv->vpn = g_value_get_boolean (value); + break; + case PROP_MASTER: + break; + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); + break; } +} - if (priv->pending_activation_id) { - nm_device_remove_pending_action (priv->device, priv->pending_activation_id, TRUE); - g_clear_pointer (&priv->pending_activation_id, g_free); +/*****************************************************************************/ + +static void +nm_active_connection_init (NMActiveConnection *self) +{ + NMActiveConnectionPrivate *priv; + + priv = G_TYPE_INSTANCE_GET_PRIVATE (self, NM_TYPE_ACTIVE_CONNECTION, NMActiveConnectionPrivate); + self->_priv = priv; + + _LOGT ("creating"); + + priv->version_id = _version_id_new (); +} + +static void +constructed (GObject *object) +{ + NMActiveConnection *self = (NMActiveConnection *) object; + NMActiveConnectionPrivate *priv = NM_ACTIVE_CONNECTION_GET_PRIVATE (self); + + G_OBJECT_CLASS (nm_active_connection_parent_class)->constructed (object); + + if (!priv->applied_connection && priv->settings_connection) { + priv->applied_connection = + nm_simple_connection_new_clone ((NMConnection *) priv->settings_connection); } - g_clear_object (&priv->device); + if (priv->applied_connection) + nm_connection_clear_secrets (priv->applied_connection); + + _LOGD ("constructed (%s, version-id %llu)", G_OBJECT_TYPE_NAME (self), (long long unsigned) priv->version_id); + + g_return_if_fail (priv->subject); } static void @@ -1151,9 +1168,8 @@ nm_active_connection_class_init (NMActiveConnectionClass *ac_class) g_type_class_add_private (ac_class, sizeof (NMActiveConnectionPrivate)); - exported_object_class->export_path = NM_DBUS_PATH "/ActiveConnection/%u"; + exported_object_class->export_path = NM_EXPORT_PATH_NUMBERED (NM_DBUS_PATH"/ActiveConnection"); - /* virtual methods */ object_class->get_property = get_property; object_class->set_property = set_property; object_class->constructed = constructed; @@ -1259,6 +1275,12 @@ nm_active_connection_class_init (NMActiveConnectionClass *ac_class) G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY | G_PARAM_STATIC_STRINGS); + obj_properties[PROP_INT_APPLIED_CONNECTION] = + g_param_spec_object (NM_ACTIVE_CONNECTION_INT_APPLIED_CONNECTION, "", "", + NM_TYPE_CONNECTION, + G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY | + G_PARAM_STATIC_STRINGS); + obj_properties[PROP_INT_DEVICE] = g_param_spec_object (NM_ACTIVE_CONNECTION_INT_DEVICE, "", "", NM_TYPE_DEVICE, |