Merge remote branch 'origin/master' into rm-userset

This commit is contained in:
Dan Williams
2011-01-25 15:41:03 -06:00
20 changed files with 2756 additions and 2319 deletions

View File

@@ -14,7 +14,7 @@
* with this program; if not, write to the Free Software Foundation, Inc., * with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
* *
* (C) Copyright 2010 Red Hat, Inc. * (C) Copyright 2011 Red Hat, Inc.
*/ */
#include <glib.h> #include <glib.h>
@@ -883,6 +883,60 @@ check_wimax_compatible (NMDeviceWimax *device, NMConnection *connection, GError
return TRUE; return TRUE;
} }
static gboolean
check_gsm_compatible (NMGsmDevice *device, NMConnection *connection, GError **error)
{
NMSettingConnection *s_con;
NMSettingGsm *s_gsm;
g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
s_con = NM_SETTING_CONNECTION (nm_connection_get_setting (connection, NM_TYPE_SETTING_CONNECTION));
g_assert (s_con);
if (strcmp (nm_setting_connection_get_connection_type (s_con), NM_SETTING_GSM_SETTING_NAME)) {
g_set_error (error, 0, 0,
"The connection was not a GSM connection.");
return FALSE;
}
s_gsm = NM_SETTING_GSM (nm_connection_get_setting (connection, NM_TYPE_SETTING_GSM));
if (!s_gsm) {
g_set_error (error, 0, 0,
"The connection was not a valid GSM connection.");
return FALSE;
}
return TRUE;
}
static gboolean
check_cdma_compatible (NMCdmaDevice *device, NMConnection *connection, GError **error)
{
NMSettingConnection *s_con;
NMSettingCdma *s_cdma;
g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
s_con = NM_SETTING_CONNECTION (nm_connection_get_setting (connection, NM_TYPE_SETTING_CONNECTION));
g_assert (s_con);
if (strcmp (nm_setting_connection_get_connection_type (s_con), NM_SETTING_CDMA_SETTING_NAME)) {
g_set_error (error, 0, 0,
"The connection was not a CDMA connection.");
return FALSE;
}
s_cdma = NM_SETTING_CDMA (nm_connection_get_setting (connection, NM_TYPE_SETTING_CDMA));
if (!s_cdma) {
g_set_error (error, 0, 0,
"The connection was not a valid CDMA connection.");
return FALSE;
}
return TRUE;
}
static gboolean static gboolean
nm_device_is_connection_compatible (NMDevice *device, NMConnection *connection, GError **error) nm_device_is_connection_compatible (NMDevice *device, NMConnection *connection, GError **error)
{ {
@@ -899,6 +953,10 @@ nm_device_is_connection_compatible (NMDevice *device, NMConnection *connection,
// return check_olpc_mesh_compatible (NM_DEVICE_OLPC_MESH (device), connection, error); // return check_olpc_mesh_compatible (NM_DEVICE_OLPC_MESH (device), connection, error);
else if (NM_IS_DEVICE_WIMAX (device)) else if (NM_IS_DEVICE_WIMAX (device))
return check_wimax_compatible (NM_DEVICE_WIMAX (device), connection, error); return check_wimax_compatible (NM_DEVICE_WIMAX (device), connection, error);
else if (NM_IS_GSM_DEVICE (device))
return check_gsm_compatible (NM_GSM_DEVICE (device), connection, error);
else if (NM_IS_CDMA_DEVICE (device))
return check_cdma_compatible (NM_CDMA_DEVICE (device), connection, error);
g_set_error (error, 0, 0, "unhandled device type '%s'", G_OBJECT_TYPE_NAME (device)); g_set_error (error, 0, 0, "unhandled device type '%s'", G_OBJECT_TYPE_NAME (device));
return FALSE; return FALSE;

View File

@@ -79,5 +79,9 @@ GTKDOC_LIBS = $(top_builddir)/libnm-glib/libnm-glib.la
# include common portion ... # include common portion ...
include $(top_srcdir)/gtk-doc.make include $(top_srcdir)/gtk-doc.make
CLEANFILES += libnm-glib-sections.txt CLEANFILES += \
libnm-glib-sections.txt \
html/* \
tmpl/* \
xml/*

View File

@@ -60,5 +60,9 @@ GTKDOC_LIBS = $(top_builddir)/libnm-util/libnm-util.la
# include common portion ... # include common portion ...
include $(top_srcdir)/gtk-doc.make include $(top_srcdir)/gtk-doc.make
CLEANFILES += libnm-util-sections.txt CLEANFILES += \
libnm-util-sections.txt \
html/* \
tmpl/* \
xml/*

View File

@@ -1,35 +1,6 @@
<?xml version="1.0" encoding="UTF-8" ?> <?xml version="1.0" encoding="UTF-8" ?>
<node name="/" xmlns:tp="http://telepathy.freedesktop.org/wiki/DbusSpec#extensions-v0"> <node name="/" xmlns:tp="http://telepathy.freedesktop.org/wiki/DbusSpec#extensions-v0">
<interface name="org.freedesktop.NetworkManager.Connection.Active">
<property name="Connection" type="o" access="read">
<tp:docstring>The path of the connection.</tp:docstring>
</property>
<property name="SpecificObject" type="o" access="read">
<tp:docstring>A specific object associated with the active connection.</tp:docstring>
</property>
<property name="Devices" type="ao" access="read">
<tp:docstring>Array of object paths representing devices which are part of this active connection.</tp:docstring>
</property>
<property name="State" type="u" access="read" tp:type="NM_ACTIVE_CONNECTION_STATE">
<tp:docstring>The state of this active connection.</tp:docstring>
</property>
<property name="Default" type="b" access="read">
<tp:docstring>Whether this active connection is the default connection, i.e. whether it currently owns the default route.</tp:docstring>
</property>
<property name="Vpn" type="b" access="read">
<tp:docstring>Whether this active connection is also a VPN connection.</tp:docstring>
</property>
<signal name="PropertiesChanged">
<arg name="properties" type="a{sv}" tp:type="String_Variant_Map">
<tp:docstring>
A dictionary mapping property names to variant boxed values
</tp:docstring>
</arg>
</signal>
</interface>
<interface name="org.freedesktop.NetworkManager.VPN.Connection"> <interface name="org.freedesktop.NetworkManager.VPN.Connection">
<tp:docstring> <tp:docstring>
Represents an active connection to a Virtual Private Network. Represents an active connection to a Virtual Private Network.

View File

@@ -10,7 +10,7 @@ if test "$GCC" = "yes" -a "$set_more_warnings" != "no"; then
for option in -Wshadow -Wmissing-declarations -Wmissing-prototypes \ for option in -Wshadow -Wmissing-declarations -Wmissing-prototypes \
-Wdeclaration-after-statement -Wstrict-prototypes \ -Wdeclaration-after-statement -Wstrict-prototypes \
-Wfloat-equal -Wno-unused-parameter -Wno-sign-compare \ -Wfloat-equal -Wno-unused-parameter -Wno-sign-compare \
-fno-strict-aliasing; do -fno-strict-aliasing -Wno-unused-but-set-variable; do
SAVE_CFLAGS="$CFLAGS" SAVE_CFLAGS="$CFLAGS"
CFLAGS="$CFLAGS $option" CFLAGS="$CFLAGS $option"
AC_MSG_CHECKING([whether gcc understands $option]) AC_MSG_CHECKING([whether gcc understands $option])

1718
po/bg.po

File diff suppressed because it is too large Load Diff

2627
po/ca.po

File diff suppressed because it is too large Load Diff

View File

@@ -35,6 +35,7 @@
#include "nm-properties-changed-signal.h" #include "nm-properties-changed-signal.h"
#include "nm-active-connection.h" #include "nm-active-connection.h"
#include "nm-dbus-glib-types.h" #include "nm-dbus-glib-types.h"
#include "nm-active-connection-glue.h"
G_DEFINE_TYPE (NMActRequest, nm_act_request, G_TYPE_OBJECT) G_DEFINE_TYPE (NMActRequest, nm_act_request, G_TYPE_OBJECT)
@@ -594,63 +595,21 @@ nm_act_request_class_init (NMActRequestClass *req_class)
object_class->finalize = finalize; object_class->finalize = finalize;
/* properties */ /* properties */
g_object_class_install_property nm_active_connection_install_properties (object_class,
(object_class, PROP_CONNECTION, PROP_CONNECTION,
g_param_spec_boxed (NM_ACTIVE_CONNECTION_CONNECTION, PROP_SPECIFIC_OBJECT,
"Connection", PROP_DEVICES,
"Connection", PROP_STATE,
DBUS_TYPE_G_OBJECT_PATH, PROP_DEFAULT,
G_PARAM_READABLE)); PROP_DEFAULT6,
g_object_class_install_property PROP_VPN);
(object_class, PROP_SPECIFIC_OBJECT,
g_param_spec_boxed (NM_ACTIVE_CONNECTION_SPECIFIC_OBJECT,
"Specific object",
"Specific object",
DBUS_TYPE_G_OBJECT_PATH,
G_PARAM_READABLE));
g_object_class_install_property
(object_class, PROP_DEVICES,
g_param_spec_boxed (NM_ACTIVE_CONNECTION_DEVICES,
"Devices",
"Devices",
DBUS_TYPE_G_ARRAY_OF_OBJECT_PATH,
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 IPv4 active connection",
FALSE,
G_PARAM_READABLE));
g_object_class_install_property
(object_class, PROP_DEFAULT6,
g_param_spec_boolean (NM_ACTIVE_CONNECTION_DEFAULT6,
"Default6",
"Is the default IPv6 active connection",
FALSE,
G_PARAM_READABLE));
g_object_class_install_property
(object_class, PROP_VPN,
g_param_spec_boolean (NM_ACTIVE_CONNECTION_VPN,
"VPN",
"Is a VPN connection",
FALSE,
G_PARAM_READABLE));
/* Signals */ /* Signals */
signals[PROPERTIES_CHANGED] = signals[PROPERTIES_CHANGED] =
nm_properties_changed_signal_new (object_class, nm_properties_changed_signal_new (object_class,
G_STRUCT_OFFSET (NMActRequestClass, properties_changed)); G_STRUCT_OFFSET (NMActRequestClass, properties_changed));
nm_active_connection_install_type_info (object_class); dbus_g_object_type_install_info (G_TYPE_FROM_CLASS (req_class),
&dbus_glib_nm_active_connection_object_info);
} }

View File

@@ -21,8 +21,8 @@
#include <glib.h> #include <glib.h>
#include "nm-active-connection.h" #include "nm-active-connection.h"
#include "NetworkManager.h" #include "NetworkManager.h"
#include "nm-active-connection-glue.h"
#include "nm-logging.h" #include "nm-logging.h"
#include "nm-dbus-glib-types.h"
char * char *
nm_active_connection_get_next_object_path (void) nm_active_connection_get_next_object_path (void)
@@ -33,9 +33,64 @@ nm_active_connection_get_next_object_path (void)
} }
void void
nm_active_connection_install_type_info (GObjectClass *klass) nm_active_connection_install_properties (GObjectClass *object_class,
guint prop_connection,
guint prop_specific_object,
guint prop_devices,
guint prop_state,
guint prop_default,
guint prop_default6,
guint prop_vpn)
{ {
dbus_g_object_type_install_info (G_TYPE_FROM_CLASS (klass), g_object_class_install_property (object_class, prop_connection,
&dbus_glib_nm_active_connection_object_info); g_param_spec_boxed (NM_ACTIVE_CONNECTION_CONNECTION,
"Connection",
"Connection",
DBUS_TYPE_G_OBJECT_PATH,
G_PARAM_READABLE));
g_object_class_install_property (object_class, prop_specific_object,
g_param_spec_boxed (NM_ACTIVE_CONNECTION_SPECIFIC_OBJECT,
"Specific object",
"Specific object",
DBUS_TYPE_G_OBJECT_PATH,
G_PARAM_READABLE));
g_object_class_install_property (object_class, prop_devices,
g_param_spec_boxed (NM_ACTIVE_CONNECTION_DEVICES,
"Devices",
"Devices",
DBUS_TYPE_G_ARRAY_OF_OBJECT_PATH,
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 IPv4 active connection",
FALSE,
G_PARAM_READABLE));
g_object_class_install_property (object_class, prop_default6,
g_param_spec_boolean (NM_ACTIVE_CONNECTION_DEFAULT6,
"Default6",
"Is the default IPv6 active connection",
FALSE,
G_PARAM_READABLE));
g_object_class_install_property (object_class, prop_vpn,
g_param_spec_boolean (NM_ACTIVE_CONNECTION_VPN,
"VPN",
"Is a VPN connection",
FALSE,
G_PARAM_READABLE));
} }

View File

@@ -34,6 +34,13 @@
char *nm_active_connection_get_next_object_path (void); char *nm_active_connection_get_next_object_path (void);
void nm_active_connection_install_type_info (GObjectClass *klass); void nm_active_connection_install_properties (GObjectClass *object_class,
guint prop_connection,
guint prop_specific_object,
guint prop_devices,
guint prop_state,
guint prop_default,
guint prop_default6,
guint prop_vpn);
#endif /* NM_ACTIVE_CONNECTION_H */ #endif /* NM_ACTIVE_CONNECTION_H */

View File

@@ -473,9 +473,43 @@ constructor (GType type,
return object; return object;
} }
static void
clear_secrets_tries (NMDevice *device)
{
NMActRequest *req;
NMConnection *connection;
req = nm_device_get_act_request (device);
if (req) {
connection = nm_act_request_get_connection (req);
/* Clear wired secrets tries on success, failure, or when deactivating */
g_object_set_data (G_OBJECT (connection), WIRED_SECRETS_TRIES, NULL);
}
}
static void
device_state_changed (NMDevice *device,
NMDeviceState new_state,
NMDeviceState old_state,
NMDeviceStateReason reason,
gpointer user_data)
{
switch (new_state) {
case NM_DEVICE_STATE_ACTIVATED:
case NM_DEVICE_STATE_FAILED:
case NM_DEVICE_STATE_DISCONNECTED:
clear_secrets_tries (device);
break;
default:
break;
}
}
static void static void
nm_device_ethernet_init (NMDeviceEthernet * self) nm_device_ethernet_init (NMDeviceEthernet * self)
{ {
g_signal_connect (self, "state-changed", G_CALLBACK (device_state_changed), NULL);
} }
static gboolean static gboolean
@@ -1550,6 +1584,9 @@ real_deactivate_quickly (NMDevice *device)
NMDeviceEthernet *self = NM_DEVICE_ETHERNET (device); NMDeviceEthernet *self = NM_DEVICE_ETHERNET (device);
NMDeviceEthernetPrivate *priv = NM_DEVICE_ETHERNET_GET_PRIVATE (self); NMDeviceEthernetPrivate *priv = NM_DEVICE_ETHERNET_GET_PRIVATE (self);
/* Clear wired secrets tries when deactivating */
clear_secrets_tries (device);
if (priv->pending_ip4_config) { if (priv->pending_ip4_config) {
g_object_unref (priv->pending_ip4_config); g_object_unref (priv->pending_ip4_config);
priv->pending_ip4_config = NULL; priv->pending_ip4_config = NULL;

View File

@@ -1255,6 +1255,15 @@ real_deactivate_quickly (NMDevice *dev)
NMDeviceWifi *self = NM_DEVICE_WIFI (dev); NMDeviceWifi *self = NM_DEVICE_WIFI (dev);
NMDeviceWifiPrivate *priv = NM_DEVICE_WIFI_GET_PRIVATE (self); NMDeviceWifiPrivate *priv = NM_DEVICE_WIFI_GET_PRIVATE (self);
NMAccessPoint *orig_ap = nm_device_wifi_get_activation_ap (self); NMAccessPoint *orig_ap = nm_device_wifi_get_activation_ap (self);
NMActRequest *req;
NMConnection *connection;
req = nm_device_get_act_request (dev);
if (req) {
connection = nm_act_request_get_connection (req);
/* Clear wireless secrets tries when deactivating */
g_object_set_data (G_OBJECT (connection), WIRELESS_SECRETS_TRIES, NULL);
}
cleanup_association_attempt (self, TRUE); cleanup_association_attempt (self, TRUE);

View File

@@ -3354,7 +3354,7 @@ dispose (GObject *object)
if ( nm_device_interface_can_assume_connections (NM_DEVICE_INTERFACE (self)) if ( nm_device_interface_can_assume_connections (NM_DEVICE_INTERFACE (self))
&& (nm_device_get_state (self) == NM_DEVICE_STATE_ACTIVATED)) { && (nm_device_get_state (self) == NM_DEVICE_STATE_ACTIVATED)) {
NMConnection *connection; NMConnection *connection;
NMSettingIP4Config *s_ip4; NMSettingIP4Config *s_ip4 = NULL;
const char *method = NULL; const char *method = NULL;
connection = nm_act_request_get_connection (priv->act_request); connection = nm_act_request_get_connection (priv->act_request);
@@ -3365,9 +3365,8 @@ dispose (GObject *object)
* to check that. * to check that.
*/ */
s_ip4 = (NMSettingIP4Config *) nm_connection_get_setting (connection, NM_TYPE_SETTING_IP4_CONFIG); s_ip4 = (NMSettingIP4Config *) nm_connection_get_setting (connection, NM_TYPE_SETTING_IP4_CONFIG);
g_assert (s_ip4); if (s_ip4)
method = nm_setting_ip4_config_get_method (s_ip4);
method = nm_setting_ip4_config_get_method (s_ip4);
if ( !method if ( !method
|| !strcmp (method, NM_SETTING_IP4_CONFIG_METHOD_AUTO) || !strcmp (method, NM_SETTING_IP4_CONFIG_METHOD_AUTO)
|| !strcmp (method, NM_SETTING_IP4_CONFIG_METHOD_MANUAL)) || !strcmp (method, NM_SETTING_IP4_CONFIG_METHOD_MANUAL))

View File

@@ -11,12 +11,14 @@ INCLUDES = \
noinst_LTLIBRARIES = libvpn-manager.la noinst_LTLIBRARIES = libvpn-manager.la
libvpn_manager_la_SOURCES = \ libvpn_manager_la_SOURCES = \
nm-vpn-manager.c \ nm-vpn-manager.c \
nm-vpn-manager.h \ nm-vpn-manager.h \
nm-vpn-service.c \ nm-vpn-service.c \
nm-vpn-service.h \ nm-vpn-service.h \
nm-vpn-connection.c \ nm-vpn-connection-base.c \
nm-vpn-connection-base.h \
nm-vpn-connection.c \
nm-vpn-connection.h nm-vpn-connection.h
libvpn_manager_la_CPPFLAGS = \ libvpn_manager_la_CPPFLAGS = \
@@ -31,6 +33,9 @@ libvpn_manager_la_LIBADD = \
$(DBUS_LIBS) \ $(DBUS_LIBS) \
$(GLIB_LIBS) $(GLIB_LIBS)
nm-vpn-connection-base-glue.h: $(top_srcdir)/introspection/nm-active-connection.xml
$(AM_V_GEN) dbus-binding-tool --prefix=nm_vpn_connection_base --mode=glib-server --output=$@ $<
nm-vpn-connection-glue.h: $(top_srcdir)/introspection/nm-vpn-connection.xml nm-vpn-connection-glue.h: $(top_srcdir)/introspection/nm-vpn-connection.xml
$(AM_V_GEN) dbus-binding-tool --prefix=nm_vpn_connection --mode=glib-server --output=$@ $< $(AM_V_GEN) dbus-binding-tool --prefix=nm_vpn_connection --mode=glib-server --output=$@ $<
@@ -39,6 +44,7 @@ nm-vpn-plugin-bindings.h: $(top_srcdir)/introspection/nm-vpn-plugin.xml
BUILT_SOURCES = \ BUILT_SOURCES = \
nm-vpn-connection-base-glue.h \
nm-vpn-connection-glue.h \ nm-vpn-connection-glue.h \
nm-vpn-plugin-bindings.h nm-vpn-plugin-bindings.h

View File

@@ -0,0 +1,194 @@
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */
/* NetworkManager -- Network link manager
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Copyright (C) 2005 - 2011 Red Hat, Inc.
* Copyright (C) 2007 - 2008 Novell, Inc.
*/
#include "NetworkManager.h"
#include "nm-vpn-connection-base.h"
#include "nm-active-connection.h"
#include "nm-vpn-connection-base-glue.h"
#include "nm-dbus-manager.h"
G_DEFINE_ABSTRACT_TYPE (NMVpnConnectionBase, nm_vpn_connection_base, G_TYPE_OBJECT)
#define NM_VPN_CONNECTION_BASE_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), \
NM_TYPE_VPN_CONNECTION_BASE, \
NMVpnConnectionBasePrivate))
typedef struct {
gboolean disposed;
NMConnection *connection;
char *ac_path;
gboolean is_default;
gboolean is_default6;
NMActiveConnectionState state;
} NMVpnConnectionBasePrivate;
enum {
PROP_0,
PROP_CONNECTION,
PROP_SPECIFIC_OBJECT,
PROP_DEVICES,
PROP_STATE,
PROP_DEFAULT,
PROP_DEFAULT6,
PROP_VPN,
LAST_PROP
};
/****************************************************************/
void
nm_vpn_connection_base_set_state (NMVpnConnectionBase *self,
NMVPNConnectionState vpn_state)
{
NMVpnConnectionBasePrivate *priv = NM_VPN_CONNECTION_BASE_GET_PRIVATE (self);
NMActiveConnectionState new_ac_state = NM_ACTIVE_CONNECTION_STATE_UNKNOWN;
/* Set the NMActiveConnection state based on VPN state */
switch (vpn_state) {
case NM_VPN_CONNECTION_STATE_PREPARE:
case NM_VPN_CONNECTION_STATE_NEED_AUTH:
case NM_VPN_CONNECTION_STATE_CONNECT:
case NM_VPN_CONNECTION_STATE_IP_CONFIG_GET:
new_ac_state = NM_ACTIVE_CONNECTION_STATE_ACTIVATING;
break;
case NM_VPN_CONNECTION_STATE_ACTIVATED:
new_ac_state = NM_ACTIVE_CONNECTION_STATE_ACTIVATED;
break;
default:
break;
}
if (new_ac_state != priv->state) {
priv->state = new_ac_state;
g_object_notify (G_OBJECT (self), NM_ACTIVE_CONNECTION_STATE);
}
}
const char *
nm_vpn_connection_base_get_ac_path (NMVpnConnectionBase *self)
{
return NM_VPN_CONNECTION_BASE_GET_PRIVATE (self)->ac_path;
}
void
nm_vpn_connection_base_export (NMVpnConnectionBase *self,
NMConnection *connection)
{
NMVpnConnectionBasePrivate *priv = NM_VPN_CONNECTION_BASE_GET_PRIVATE (self);
NMDBusManager *dbus_mgr;
g_return_if_fail (priv->connection == NULL);
priv->connection = g_object_ref (connection);
dbus_mgr = nm_dbus_manager_get ();
dbus_g_connection_register_g_object (nm_dbus_manager_get_connection (dbus_mgr),
priv->ac_path, G_OBJECT (self));
g_object_unref (dbus_mgr);
}
/****************************************************************/
static void
nm_vpn_connection_base_init (NMVpnConnectionBase *self)
{
NMVpnConnectionBasePrivate *priv = NM_VPN_CONNECTION_BASE_GET_PRIVATE (self);
priv->state = NM_ACTIVE_CONNECTION_STATE_UNKNOWN;
priv->ac_path = nm_active_connection_get_next_object_path ();
}
static void
dispose (GObject *object)
{
NMVpnConnectionBasePrivate *priv = NM_VPN_CONNECTION_BASE_GET_PRIVATE (object);
if (!priv->disposed) {
priv->disposed = TRUE;
g_free (priv->ac_path);
g_object_unref (priv->connection);
}
G_OBJECT_CLASS (nm_vpn_connection_base_parent_class)->dispose (object);
}
static void
get_property (GObject *object, guint prop_id,
GValue *value, GParamSpec *pspec)
{
NMVpnConnectionBasePrivate *priv = NM_VPN_CONNECTION_BASE_GET_PRIVATE (object);
switch (prop_id) {
case PROP_CONNECTION:
g_value_set_boxed (value, nm_connection_get_path (priv->connection));
break;
case PROP_SPECIFIC_OBJECT:
g_value_set_boxed (value, priv->ac_path);
break;
case PROP_DEVICES:
g_value_take_boxed (value, g_ptr_array_new ());
break;
case PROP_STATE:
g_value_set_uint (value, priv->state);
break;
case PROP_DEFAULT:
g_value_set_boolean (value, priv->is_default);
break;
case PROP_DEFAULT6:
g_value_set_boolean (value, priv->is_default6);
break;
case PROP_VPN:
g_value_set_boolean (value, TRUE);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
}
}
static void
nm_vpn_connection_base_class_init (NMVpnConnectionBaseClass *vpn_class)
{
GObjectClass *object_class = G_OBJECT_CLASS (vpn_class);
g_type_class_add_private (vpn_class, sizeof (NMVpnConnectionBasePrivate));
/* virtual methods */
object_class->get_property = get_property;
object_class->dispose = dispose;
/* properties */
nm_active_connection_install_properties (object_class,
PROP_CONNECTION,
PROP_SPECIFIC_OBJECT,
PROP_DEVICES,
PROP_STATE,
PROP_DEFAULT,
PROP_DEFAULT6,
PROP_VPN);
dbus_g_object_type_install_info (G_TYPE_FROM_CLASS (vpn_class),
&dbus_glib_nm_vpn_connection_base_object_info);
}

View File

@@ -0,0 +1,54 @@
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */
/* NetworkManager -- Network link manager
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*
* (C) Copyright 2005 - 2011 Red Hat, Inc.
*/
#ifndef NM_VPN_CONNECTION_BASE_H
#define NM_VPN_CONNECTION_BASE_H
#include <glib-object.h>
#include "NetworkManagerVPN.h"
#include "nm-connection.h"
#define NM_TYPE_VPN_CONNECTION_BASE (nm_vpn_connection_base_get_type ())
#define NM_VPN_CONNECTION_BASE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), NM_TYPE_VPN_CONNECTION_BASE, NMVpnConnectionBase))
#define NM_VPN_CONNECTION_BASE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), NM_TYPE_VPN_CONNECTION_BASE, NMVpnConnectionBaseClass))
#define NM_IS_VPN_CONNECTION_BASE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), NM_TYPE_VPN_CONNECTION_BASE))
#define NM_IS_VPN_CONNECTION_BASE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((obj), NM_TYPE_VPN_CONNECTION_BASE))
#define NM_VPN_CONNECTION_BASE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), NM_TYPE_VPN_CONNECTION_BASE, NMVpnConnectionBaseClass))
typedef struct {
GObject parent;
} NMVpnConnectionBase;
typedef struct {
GObjectClass parent;
} NMVpnConnectionBaseClass;
GType nm_vpn_connection_base_get_type (void);
const char *nm_vpn_connection_base_get_ac_path (NMVpnConnectionBase *self);
void nm_vpn_connection_base_export (NMVpnConnectionBase *self,
NMConnection *connection);
void nm_vpn_connection_base_set_state (NMVpnConnectionBase *self,
NMVPNConnectionState vpn_state);
#endif /* NM_VPN_CONNECTION_BASE_H */

View File

@@ -50,7 +50,7 @@
#include "nm-vpn-connection-glue.h" #include "nm-vpn-connection-glue.h"
G_DEFINE_TYPE (NMVPNConnection, nm_vpn_connection, G_TYPE_OBJECT) G_DEFINE_TYPE (NMVPNConnection, nm_vpn_connection, NM_TYPE_VPN_CONNECTION_BASE)
typedef struct { typedef struct {
gboolean disposed; gboolean disposed;
@@ -58,17 +58,12 @@ typedef struct {
NMConnection *connection; NMConnection *connection;
NMActRequest *act_request; NMActRequest *act_request;
char *ac_path;
guint32 secrets_id; guint32 secrets_id;
NMDevice *parent_dev; NMDevice *parent_dev;
gulong device_monitor; gulong device_monitor;
gulong device_ip4; gulong device_ip4;
gboolean is_default;
gboolean is_default6;
NMActiveConnectionState state;
NMVPNConnectionState vpn_state; NMVPNConnectionState vpn_state;
NMVPNConnectionStateReason failure_reason; NMVPNConnectionStateReason failure_reason;
DBusGProxy *proxy; DBusGProxy *proxy;
@@ -94,13 +89,6 @@ static guint signals[LAST_SIGNAL] = { 0 };
enum { enum {
PROP_0, PROP_0,
PROP_CONNECTION,
PROP_SPECIFIC_OBJECT,
PROP_DEVICES,
PROP_STATE,
PROP_DEFAULT,
PROP_DEFAULT6,
PROP_VPN,
PROP_VPN_STATE, PROP_VPN_STATE,
PROP_BANNER, PROP_BANNER,
@@ -113,7 +101,6 @@ nm_vpn_connection_set_vpn_state (NMVPNConnection *connection,
NMVPNConnectionStateReason reason) NMVPNConnectionStateReason reason)
{ {
NMVPNConnectionPrivate *priv; NMVPNConnectionPrivate *priv;
NMActiveConnectionState new_ac_state;
NMVPNConnectionState old_vpn_state; NMVPNConnectionState old_vpn_state;
char *ip_iface; char *ip_iface;
@@ -127,32 +114,14 @@ nm_vpn_connection_set_vpn_state (NMVPNConnection *connection,
old_vpn_state = priv->vpn_state; old_vpn_state = priv->vpn_state;
priv->vpn_state = vpn_state; priv->vpn_state = vpn_state;
/* Update active connection base class state */
nm_vpn_connection_base_set_state (NM_VPN_CONNECTION_BASE (connection), vpn_state);
/* Save ip_iface since when the VPN goes down it may get freed /* Save ip_iface since when the VPN goes down it may get freed
* before we're done with it. * before we're done with it.
*/ */
ip_iface = g_strdup (priv->ip_iface); ip_iface = g_strdup (priv->ip_iface);
/* Set the NMActiveConnection state based on VPN state */
switch (vpn_state) {
case NM_VPN_CONNECTION_STATE_PREPARE:
case NM_VPN_CONNECTION_STATE_NEED_AUTH:
case NM_VPN_CONNECTION_STATE_CONNECT:
case NM_VPN_CONNECTION_STATE_IP_CONFIG_GET:
new_ac_state = NM_ACTIVE_CONNECTION_STATE_ACTIVATING;
break;
case NM_VPN_CONNECTION_STATE_ACTIVATED:
new_ac_state = NM_ACTIVE_CONNECTION_STATE_ACTIVATED;
break;
default:
new_ac_state = NM_ACTIVE_CONNECTION_STATE_UNKNOWN;
break;
}
if (new_ac_state != priv->state) {
priv->state = new_ac_state;
g_object_notify (G_OBJECT (connection), NM_ACTIVE_CONNECTION_STATE);
}
/* The connection gets destroyed by the VPN manager when it enters the /* The connection gets destroyed by the VPN manager when it enters the
* disconnected/failed state, but we need to keep it around for a bit * disconnected/failed state, but we need to keep it around for a bit
* to send out signals and handle the dispatcher. So ref it. * to send out signals and handle the dispatcher. So ref it.
@@ -255,6 +224,9 @@ nm_vpn_connection_new (NMConnection *connection,
priv->device_ip4 = g_signal_connect (parent_device, "notify::" NM_DEVICE_INTERFACE_IP4_CONFIG, priv->device_ip4 = g_signal_connect (parent_device, "notify::" NM_DEVICE_INTERFACE_IP4_CONFIG,
G_CALLBACK (device_ip4_config_changed), G_CALLBACK (device_ip4_config_changed),
self); self);
nm_vpn_connection_base_export (NM_VPN_CONNECTION_BASE (self), connection);
return self; return self;
} }
@@ -684,7 +656,7 @@ nm_vpn_connection_get_active_connection_path (NMVPNConnection *connection)
{ {
g_return_val_if_fail (NM_IS_VPN_CONNECTION (connection), NULL); g_return_val_if_fail (NM_IS_VPN_CONNECTION (connection), NULL);
return NM_VPN_CONNECTION_GET_PRIVATE (connection)->ac_path; return nm_vpn_connection_base_get_ac_path (NM_VPN_CONNECTION_BASE (connection));
} }
const char * const char *
@@ -956,20 +928,9 @@ connection_state_changed (NMVPNConnection *self,
} }
static void static void
nm_vpn_connection_init (NMVPNConnection *connection) nm_vpn_connection_init (NMVPNConnection *self)
{ {
NMVPNConnectionPrivate *priv = NM_VPN_CONNECTION_GET_PRIVATE (connection); NM_VPN_CONNECTION_GET_PRIVATE (self)->vpn_state = NM_VPN_CONNECTION_STATE_PREPARE;
NMDBusManager *dbus_mgr;
priv->state = NM_ACTIVE_CONNECTION_STATE_UNKNOWN;
priv->vpn_state = NM_VPN_CONNECTION_STATE_PREPARE;
priv->ac_path = nm_active_connection_get_next_object_path ();
dbus_mgr = nm_dbus_manager_get ();
dbus_g_connection_register_g_object (nm_dbus_manager_get_connection (dbus_mgr),
priv->ac_path,
G_OBJECT (connection));
g_object_unref (dbus_mgr);
} }
static void static void
@@ -1019,7 +980,6 @@ finalize (GObject *object)
g_free (priv->banner); g_free (priv->banner);
g_free (priv->ip_iface); g_free (priv->ip_iface);
g_free (priv->ac_path);
G_OBJECT_CLASS (nm_vpn_connection_parent_class)->finalize (object); G_OBJECT_CLASS (nm_vpn_connection_parent_class)->finalize (object);
} }
@@ -1031,27 +991,6 @@ get_property (GObject *object, guint prop_id,
NMVPNConnectionPrivate *priv = NM_VPN_CONNECTION_GET_PRIVATE (object); NMVPNConnectionPrivate *priv = NM_VPN_CONNECTION_GET_PRIVATE (object);
switch (prop_id) { switch (prop_id) {
case PROP_CONNECTION:
g_value_set_boxed (value, nm_connection_get_path (priv->connection));
break;
case PROP_SPECIFIC_OBJECT:
g_value_set_boxed (value, nm_act_request_get_active_connection_path (priv->act_request));
break;
case PROP_DEVICES:
g_value_take_boxed (value, g_ptr_array_new ());
break;
case PROP_STATE:
g_value_set_uint (value, priv->state);
break;
case PROP_DEFAULT:
g_value_set_boolean (value, priv->is_default);
break;
case PROP_DEFAULT6:
g_value_set_boolean (value, priv->is_default6);
break;
case PROP_VPN:
g_value_set_boolean (value, TRUE);
break;
case PROP_VPN_STATE: case PROP_VPN_STATE:
g_value_set_uint (value, priv->vpn_state); g_value_set_uint (value, priv->vpn_state);
break; break;
@@ -1078,75 +1017,21 @@ nm_vpn_connection_class_init (NMVPNConnectionClass *connection_class)
object_class->finalize = finalize; object_class->finalize = finalize;
/* properties */ /* properties */
g_object_class_install_property g_object_class_install_property (object_class, PROP_VPN_STATE,
(object_class, PROP_CONNECTION, g_param_spec_uint (NM_VPN_CONNECTION_VPN_STATE,
g_param_spec_boxed (NM_ACTIVE_CONNECTION_CONNECTION, "VpnState",
"Connection", "Current VPN state",
"Connection", NM_VPN_CONNECTION_STATE_UNKNOWN,
DBUS_TYPE_G_OBJECT_PATH, NM_VPN_CONNECTION_STATE_DISCONNECTED,
G_PARAM_READABLE)); NM_VPN_CONNECTION_STATE_UNKNOWN,
g_object_class_install_property G_PARAM_READABLE));
(object_class, PROP_SPECIFIC_OBJECT,
g_param_spec_boxed (NM_ACTIVE_CONNECTION_SPECIFIC_OBJECT,
"Specific object",
"Specific object",
DBUS_TYPE_G_OBJECT_PATH,
G_PARAM_READABLE));
g_object_class_install_property
(object_class, PROP_DEVICES,
g_param_spec_boxed (NM_ACTIVE_CONNECTION_DEVICES,
"Devices",
"Devices",
DBUS_TYPE_G_ARRAY_OF_OBJECT_PATH,
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 IPv4 active connection",
FALSE,
G_PARAM_READABLE));
g_object_class_install_property
(object_class, PROP_DEFAULT6,
g_param_spec_boolean (NM_ACTIVE_CONNECTION_DEFAULT6,
"Default6",
"Is the default IPv6 active connection",
FALSE,
G_PARAM_READABLE));
g_object_class_install_property
(object_class, PROP_VPN,
g_param_spec_boolean (NM_ACTIVE_CONNECTION_VPN,
"VPN",
"Is a VPN connection",
TRUE,
G_PARAM_READABLE));
g_object_class_install_property g_object_class_install_property (object_class, PROP_BANNER,
(object_class, PROP_VPN_STATE, g_param_spec_string (NM_VPN_CONNECTION_BANNER,
g_param_spec_uint (NM_VPN_CONNECTION_VPN_STATE, "Banner",
"VpnState", "Login Banner",
"Current VPN state", NULL,
NM_VPN_CONNECTION_STATE_UNKNOWN, G_PARAM_READABLE));
NM_VPN_CONNECTION_STATE_DISCONNECTED,
NM_VPN_CONNECTION_STATE_UNKNOWN,
G_PARAM_READABLE));
g_object_class_install_property
(object_class, PROP_BANNER,
g_param_spec_string (NM_VPN_CONNECTION_BANNER,
"Banner",
"Login Banner",
NULL,
G_PARAM_READABLE));
/* signals */ /* signals */
signals[VPN_STATE_CHANGED] = signals[VPN_STATE_CHANGED] =

View File

@@ -27,6 +27,7 @@
#include "NetworkManagerVPN.h" #include "NetworkManagerVPN.h"
#include "nm-device.h" #include "nm-device.h"
#include "nm-activation-request.h" #include "nm-activation-request.h"
#include "nm-vpn-connection-base.h"
#define NM_TYPE_VPN_CONNECTION (nm_vpn_connection_get_type ()) #define NM_TYPE_VPN_CONNECTION (nm_vpn_connection_get_type ())
#define NM_VPN_CONNECTION(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), NM_TYPE_VPN_CONNECTION, NMVPNConnection)) #define NM_VPN_CONNECTION(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), NM_TYPE_VPN_CONNECTION, NMVPNConnection))
@@ -39,11 +40,11 @@
#define NM_VPN_CONNECTION_BANNER "banner" #define NM_VPN_CONNECTION_BANNER "banner"
typedef struct { typedef struct {
GObject parent; NMVpnConnectionBase parent;
} NMVPNConnection; } NMVPNConnection;
typedef struct { typedef struct {
GObjectClass parent; NMVpnConnectionBaseClass parent;
/* Signals */ /* Signals */
void (*vpn_state_changed) (NMVPNConnection *connection, void (*vpn_state_changed) (NMVPNConnection *connection,

View File

@@ -888,7 +888,7 @@ error:
static NMIP6Address * static NMIP6Address *
parse_full_ip6_address (const char *addr_str, GError **error) parse_full_ip6_address (const char *addr_str, GError **error)
{ {
NMIP6Address *addr; NMIP6Address *addr = NULL;
char **list; char **list;
char *ip_tag, *prefix_tag; char *ip_tag, *prefix_tag;
struct in6_addr tmp = IN6ADDR_ANY_INIT; struct in6_addr tmp = IN6ADDR_ANY_INIT;

View File

@@ -884,6 +884,7 @@ write_wired_setting (NMConnection *connection, shvarFile *ifcfg, GError **error)
svSetValue (ifcfg, "SUBCHANNELS", NULL, FALSE); svSetValue (ifcfg, "SUBCHANNELS", NULL, FALSE);
s390_subchannels = nm_setting_wired_get_s390_subchannels (s_wired); s390_subchannels = nm_setting_wired_get_s390_subchannels (s_wired);
if (s390_subchannels) { if (s390_subchannels) {
tmp = NULL;
if (s390_subchannels->len == 2) { if (s390_subchannels->len == 2) {
tmp = g_strdup_printf ("%s,%s", tmp = g_strdup_printf ("%s,%s",
(const char *) g_ptr_array_index (s390_subchannels, 0), (const char *) g_ptr_array_index (s390_subchannels, 0),