diff options
author | Dan Winship <danw@gnome.org> | 2014-08-25 15:25:27 -0400 |
---|---|---|
committer | Dan Winship <danw@gnome.org> | 2014-09-03 16:46:25 -0400 |
commit | 79d56375a4773820ffb0e439f1dad94124262a72 (patch) | |
tree | e33f6807f067607ecaaa19c6071f0bfbaaa8fa88 | |
parent | bb6a2e6e645c964bce76bad9b8a1bd991a9eb1f7 (diff) | |
download | NetworkManager-danw/libnm-props-4.tar.gz |
libnm: fix NMIP4Config/NMIP6Config addresses/routes propertiesdanw/libnm-props-4
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.
-rw-r--r-- | libnm/Makefile.am | 5 | ||||
-rw-r--r-- | libnm/NetworkManager.h | 1 | ||||
-rw-r--r-- | libnm/libnm.ver | 2 | ||||
-rw-r--r-- | libnm/nm-dhcp4-config.c | 1 | ||||
-rw-r--r-- | libnm/nm-dhcp6-config.c | 1 | ||||
-rw-r--r-- | libnm/nm-ip4-config.c | 28 | ||||
-rw-r--r-- | libnm/nm-ip6-config.c | 22 | ||||
-rw-r--r-- | libnm/nm-object.c | 1 | ||||
-rw-r--r-- | libnm/nm-types-private.h | 30 | ||||
-rw-r--r-- | libnm/nm-types.c | 99 | ||||
-rw-r--r-- | libnm/nm-types.h | 43 | ||||
-rw-r--r-- | libnm/nm-wimax-nsp.c | 1 |
12 files changed, 29 insertions, 205 deletions
diff --git a/libnm/Makefile.am b/libnm/Makefile.am index 1838d30904..e703f376bc 100644 --- a/libnm/Makefile.am +++ b/libnm/Makefile.am @@ -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 diff --git a/libnm/NetworkManager.h b/libnm/NetworkManager.h index f473fea1cb..d7414101ce 100644 --- a/libnm/NetworkManager.h +++ b/libnm/NetworkManager.h @@ -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> diff --git a/libnm/libnm.ver b/libnm/libnm.ver index 8d2b7101b1..5617fb25f9 100644 --- a/libnm/libnm.ver +++ b/libnm/libnm.ver @@ -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; diff --git a/libnm/nm-dhcp4-config.c b/libnm/nm-dhcp4-config.c index d77f86697e..0782b23736 100644 --- a/libnm/nm-dhcp4-config.c +++ b/libnm/nm-dhcp4-config.c @@ -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" diff --git a/libnm/nm-dhcp6-config.c b/libnm/nm-dhcp6-config.c index 63d766f075..ffabb809e0 100644 --- a/libnm/nm-dhcp6-config.c +++ b/libnm/nm-dhcp6-config.c @@ -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" diff --git a/libnm/nm-ip4-config.c b/libnm/nm-ip4-config.c index 39a9b6b4dc..b469a63bfc 100644 --- a/libnm/nm-ip4-config.c +++ b/libnm/nm-ip4-config.c @@ -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: diff --git a/libnm/nm-ip6-config.c b/libnm/nm-ip6-config.c index 202c7fb349..91ca675e69 100644 --- a/libnm/nm-ip6-config.c +++ b/libnm/nm-ip6-config.c @@ -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)); diff --git a/libnm/nm-object.c b/libnm/nm-object.c index 4b08d95f9b..bab2a8a1ba 100644 --- a/libnm/nm-object.c +++ b/libnm/nm-object.c @@ -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; diff --git a/libnm/nm-types-private.h b/libnm/nm-types-private.h deleted file mode 100644 index 50245d0a9d..0000000000 --- a/libnm/nm-types-private.h +++ /dev/null @@ -1,30 +0,0 @@ -/* -*- 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__ */ diff --git a/libnm/nm-types.c b/libnm/nm-types.c deleted file mode 100644 index bd09a12e72..0000000000 --- a/libnm/nm-types.c +++ /dev/null @@ -1,99 +0,0 @@ -/* -*- 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; -} diff --git a/libnm/nm-types.h b/libnm/nm-types.h deleted file mode 100644 index 3e22983248..0000000000 --- a/libnm/nm-types.h +++ /dev/null @@ -1,43 +0,0 @@ -/* -*- 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__ */ diff --git a/libnm/nm-wimax-nsp.c b/libnm/nm-wimax-nsp.c index da0155462d..e4617ad677 100644 --- a/libnm/nm-wimax-nsp.c +++ b/libnm/nm-wimax-nsp.c @@ -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) |