Commit 98959d54 authored by Dan Winship's avatar Dan Winship

libnm: fix NMIP4Config/NMIP6Config addresses/routes properties

The docs for NMIP4Config:addresses and NMIP4Config:routes claimed that
they were GPtrArrays of NMIP4Address/NMIP4Route, but get_property()
was actually trying to set them the D-Bus representation type, and it
was failing anyway because it used g_value_set_boxed() on a parameter
that was declared GParamSpecPointer. Fix it to use a GPtrArray-valued
property, and set it to the right thing.

NMIP6Config did the right thing with its :addresses and :routes
properties, but was using custom types (NM_TYPE_IP6_ADDRESS_OBJECT_ARRAY and
NM_TYPE_IP6_ROUTE_OBJECT_ARRAY). Make it use G_TYPE_PTR_ARRAY instead.

nm-types.c, nm-types.h, and nm-types-private.h are now empty, and so
can be dropped.
parent 356fb7d7
......@@ -137,7 +137,6 @@
<chapter>
<title>Utility API Reference</title>
<xi:include href="xml/nm-utils.xml"/>
<xi:include href="xml/nm-types.xml"/>
</chapter>
<chapter>
......
......@@ -54,7 +54,6 @@ libnminclude_HEADERS = \
nm-remote-connection.h \
nm-remote-settings.h \
nm-secret-agent.h \
nm-types.h \
nm-vpn-connection.h \
nm-wimax-nsp.h
......@@ -63,8 +62,7 @@ libnm_la_private_headers = \
nm-device-private.h \
nm-object-cache.h \
nm-object-private.h \
nm-remote-connection-private.h \
nm-types-private.h
nm-remote-connection-private.h
libnm_la_csources = \
nm-access-point.c \
......@@ -95,7 +93,6 @@ libnm_la_csources = \
nm-remote-connection.c \
nm-remote-settings.c \
nm-secret-agent.c \
nm-types.c \
nm-vpn-connection.c \
nm-wimax-nsp.c
......
......@@ -80,7 +80,6 @@
#include <nm-setting-wireless.h>
#include <nm-setting.h>
#include <nm-simple-connection.h>
#include <nm-types.h>
#include <nm-utils.h>
#include <nm-version.h>
#include <nm-vpn-connection.h>
......
......@@ -306,7 +306,6 @@ global:
nm_ip6_address_get_prefix;
nm_ip6_address_get_type;
nm_ip6_address_new;
nm_ip6_address_object_array_get_type;
nm_ip6_address_ref;
nm_ip6_address_set_address;
nm_ip6_address_set_gateway;
......@@ -327,7 +326,6 @@ global:
nm_ip6_route_get_prefix;
nm_ip6_route_get_type;
nm_ip6_route_new;
nm_ip6_route_object_array_get_type;
nm_ip6_route_ref;
nm_ip6_route_set_dest;
nm_ip6_route_set_metric;
......
......@@ -23,7 +23,6 @@
#include "nm-dhcp4-config.h"
#include "nm-dbus-interface.h"
#include "nm-types-private.h"
#include "nm-object-private.h"
#include "nm-utils.h"
......
......@@ -23,7 +23,6 @@
#include "nm-dhcp6-config.h"
#include "nm-dbus-interface.h"
#include "nm-types-private.h"
#include "nm-object-private.h"
#include "nm-utils.h"
......
......@@ -24,9 +24,9 @@
#include <nm-setting-ip4-config.h>
#include "nm-ip4-config.h"
#include "nm-dbus-interface.h"
#include "nm-types-private.h"
#include "nm-object-private.h"
#include "nm-utils.h"
#include "nm-core-internal.h"
G_DEFINE_TYPE (NMIP4Config, nm_ip4_config, NM_TYPE_OBJECT)
......@@ -183,10 +183,14 @@ get_property (GObject *object,
g_value_set_string (value, nm_ip4_config_get_gateway (self));
break;
case PROP_ADDRESSES:
nm_utils_ip4_addresses_to_gvalue (priv->addresses, value);
g_value_take_boxed (value, _nm_utils_copy_slist_to_array (priv->addresses,
(NMUtilsCopyFunc) nm_ip4_address_dup,
(GDestroyNotify) nm_ip4_address_unref));
break;
case PROP_ROUTES:
nm_utils_ip4_routes_to_gvalue (priv->routes, value);
g_value_take_boxed (value, _nm_utils_copy_slist_to_array (priv->routes,
(NMUtilsCopyFunc) nm_ip4_route_dup,
(GDestroyNotify) nm_ip4_route_unref));
break;
case PROP_NAMESERVERS:
g_value_set_boxed (value, (char **) nm_ip4_config_get_nameservers (self));
......@@ -237,24 +241,26 @@ nm_ip4_config_class_init (NMIP4ConfigClass *config_class)
/**
* NMIP4Config:addresses:
*
* The #GPtrArray containing #NMIP4Address<!-- -->es of the configuration.
* A #GPtrArray containing the addresses (#NMIP4Address) of the configuration.
**/
g_object_class_install_property
(object_class, PROP_ADDRESSES,
g_param_spec_pointer (NM_IP4_CONFIG_ADDRESSES, "", "",
G_PARAM_READABLE |
G_PARAM_STATIC_STRINGS));
g_param_spec_boxed (NM_IP4_CONFIG_ADDRESSES, "", "",
G_TYPE_PTR_ARRAY,
G_PARAM_READABLE |
G_PARAM_STATIC_STRINGS));
/**
* NMIP4Config:routes:
*
* The #GPtrArray containing #NMSettingIP4Routes of the configuration.
* A #GPtrArray containing the routes (#NMIP4Route) of the configuration.
**/
g_object_class_install_property
(object_class, PROP_ROUTES,
g_param_spec_pointer (NM_IP4_CONFIG_ROUTES, "", "",
G_PARAM_READABLE |
G_PARAM_STATIC_STRINGS));
g_param_spec_boxed (NM_IP4_CONFIG_ROUTES, "", "",
G_TYPE_PTR_ARRAY,
G_PARAM_READABLE |
G_PARAM_STATIC_STRINGS));
/**
* NMIP4Config:nameservers:
......
......@@ -24,10 +24,10 @@
#include <nm-setting-ip6-config.h>
#include "nm-ip6-config.h"
#include "nm-dbus-interface.h"
#include "nm-types-private.h"
#include "nm-object-private.h"
#include "nm-utils.h"
#include "nm-dbus-glib-types.h"
#include "nm-core-internal.h"
G_DEFINE_TYPE (NMIP6Config, nm_ip6_config, NM_TYPE_OBJECT)
......@@ -269,10 +269,14 @@ get_property (GObject *object,
g_value_set_string (value, nm_ip6_config_get_gateway (self));
break;
case PROP_ADDRESSES:
nm_utils_ip6_addresses_to_gvalue (priv->addresses, value);
g_value_take_boxed (value, _nm_utils_copy_slist_to_array (priv->addresses,
(NMUtilsCopyFunc) nm_ip6_address_dup,
(GDestroyNotify) nm_ip6_address_unref));
break;
case PROP_ROUTES:
nm_utils_ip6_routes_to_gvalue (priv->routes, value);
g_value_take_boxed (value, _nm_utils_copy_slist_to_array (priv->routes,
(NMUtilsCopyFunc) nm_ip6_route_dup,
(GDestroyNotify) nm_ip6_route_unref));
break;
case PROP_NAMESERVERS:
g_value_set_boxed (value, (char **) nm_ip6_config_get_nameservers (self));
......@@ -330,28 +334,24 @@ nm_ip6_config_class_init (NMIP6ConfigClass *config_class)
/**
* NMIP6Config:addresses:
*
* The #GPtrArray containing the IPv6 addresses; use
* nm_utils_ip6_addresses_from_gvalue() to return a #GSList of
* #NMSettingIP6Address objects that is more usable than the raw data.
* The #GPtrArray containing the IPv6 addresses (#NMIP6Address).
**/
g_object_class_install_property
(object_class, PROP_ADDRESSES,
g_param_spec_boxed (NM_IP6_CONFIG_ADDRESSES, "", "",
NM_TYPE_IP6_ADDRESS_OBJECT_ARRAY,
G_TYPE_PTR_ARRAY,
G_PARAM_READABLE |
G_PARAM_STATIC_STRINGS));
/**
* NMIP6Config:routes:
*
* The #GPtrArray containing the IPv6 routes; use
* nm_utils_ip6_routes_from_gvalue() to return a #GSList of
* #NMSettingIP6Address objects that is more usable than the raw data.
* The #GPtrArray containing the IPv6 routes (#NMIP6Route).
**/
g_object_class_install_property
(object_class, PROP_ROUTES,
g_param_spec_boxed (NM_IP6_CONFIG_ROUTES, "", "",
NM_TYPE_IP6_ROUTE_OBJECT_ARRAY,
G_TYPE_PTR_ARRAY,
G_PARAM_READABLE |
G_PARAM_STATIC_STRINGS));
......
......@@ -31,7 +31,6 @@
#include "nm-object-private.h"
#include "nm-dbus-glib-types.h"
#include "nm-glib-compat.h"
#include "nm-types.h"
#include "nm-dbus-helpers-private.h"
static gboolean debug = FALSE;
......
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */
/*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library 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
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301 USA.
*
* Copyright 2007 - 2008 Red Hat, Inc.
*/
#ifndef __NM_TYPES_PRIVATE_H__
#define __NM_TYPES_PRIVATE_H__
#include <dbus/dbus-glib.h>
#include "nm-types.h"
#include "nm-object-private.h"
gboolean _nm_ip6_address_array_demarshal (GValue *value, GSList **dest);
#endif /* __NM_TYPES_PRIVATE_H__ */
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */
/*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library 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
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301 USA.
*
* Copyright 2008 Red Hat, Inc.
*/
#include <glib.h>
#include <dbus/dbus-glib.h>
#include <string.h>
#include "nm-types.h"
#include "nm-types-private.h"
#include "nm-object-private.h"
#include "nm-object-cache.h"
#include "nm-dbus-glib-types.h"
#include "nm-setting-ip6-config.h"
static gpointer
_nm_ip6_address_object_array_copy (GPtrArray *src)
{
GPtrArray *dest;
int i;
dest = g_ptr_array_sized_new (src->len);
for (i = 0; i < src->len; i++)
g_ptr_array_add (dest, nm_ip6_address_dup (g_ptr_array_index (src, i)));
return dest;
}
static void
_nm_ip6_address_object_array_free (GPtrArray *array)
{
int i;
for (i = 0; i < array->len; i++)
nm_ip6_address_unref (g_ptr_array_index (array, i));
g_ptr_array_free (array, TRUE);
}
GType
nm_ip6_address_object_array_get_type (void)
{
static GType our_type = 0;
if (our_type == 0)
our_type = g_boxed_type_register_static (g_intern_static_string ("NMIP6AddressObjectArray"),
(GBoxedCopyFunc) _nm_ip6_address_object_array_copy,
(GBoxedFreeFunc) _nm_ip6_address_object_array_free);
return our_type;
}
/*****************************/
static gpointer
_nm_ip6_route_object_array_copy (GPtrArray *src)
{
GPtrArray *dest;
int i;
dest = g_ptr_array_sized_new (src->len);
for (i = 0; i < src->len; i++)
g_ptr_array_add (dest, nm_ip6_route_dup (g_ptr_array_index (src, i)));
return dest;
}
static void
_nm_ip6_route_object_array_free (GPtrArray *array)
{
int i;
for (i = 0; i < array->len; i++)
nm_ip6_route_unref (g_ptr_array_index (array, i));
g_ptr_array_free (array, TRUE);
}
GType
nm_ip6_route_object_array_get_type (void)
{
static GType our_type = 0;
if (our_type == 0)
our_type = g_boxed_type_register_static (g_intern_static_string ("NMIP6RouteObjectArray"),
(GBoxedCopyFunc) _nm_ip6_route_object_array_copy,
(GBoxedFreeFunc) _nm_ip6_route_object_array_free);
return our_type;
}
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */
/*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library 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
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301 USA.
*
* Copyright 2008 Red Hat, Inc.
*/
#ifndef __NM_TYPES_H__
#define __NM_TYPES_H__
#if !defined (__NETWORKMANAGER_H_INSIDE__) && !defined (NETWORKMANAGER_COMPILATION)
#error "Only <NetworkManager.h> can be included directly."
#endif
#include <glib.h>
#include <glib-object.h>
#include <nm-enum-types.h>
G_BEGIN_DECLS
#define NM_TYPE_IP6_ADDRESS_OBJECT_ARRAY (nm_ip6_address_object_array_get_type ())
GType nm_ip6_address_object_array_get_type (void) G_GNUC_CONST;
#define NM_TYPE_IP6_ROUTE_OBJECT_ARRAY (nm_ip6_route_object_array_get_type ())
GType nm_ip6_route_object_array_get_type (void) G_GNUC_CONST;
G_END_DECLS
#endif /* __NM_TYPES_H__ */
......@@ -29,7 +29,6 @@
#include "nm-wimax-nsp.h"
#include "nm-dbus-interface.h"
#include "nm-types-private.h"
#include "nm-object-private.h"
G_DEFINE_TYPE (NMWimaxNsp, nm_wimax_nsp, NM_TYPE_OBJECT)
......
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