diff options
author | Dan Winship <danw@gnome.org> | 2014-07-17 09:09:47 -0400 |
---|---|---|
committer | Dan Winship <danw@gnome.org> | 2014-07-22 17:35:11 -0400 |
commit | c8813ca1ce955c500e690d0c78ccd44dc29674f5 (patch) | |
tree | 064b16a01fa454ee9174defbb5a0274997723ad7 /libnm/nm-ip6-config.c | |
parent | 58ab466553bae2a0c8168f6e8d569deac2b44cc4 (diff) | |
download | NetworkManager-c8813ca1ce955c500e690d0c78ccd44dc29674f5.tar.gz |
libnm: port to gdbus [WIP]danw/wip/libnm
Diffstat (limited to 'libnm/nm-ip6-config.c')
-rw-r--r-- | libnm/nm-ip6-config.c | 78 |
1 files changed, 29 insertions, 49 deletions
diff --git a/libnm/nm-ip6-config.c b/libnm/nm-ip6-config.c index c4872126d6..68c6bcdcf3 100644 --- a/libnm/nm-ip6-config.c +++ b/libnm/nm-ip6-config.c @@ -24,21 +24,19 @@ #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" G_DEFINE_TYPE (NMIP6Config, nm_ip6_config, NM_TYPE_OBJECT) #define NM_IP6_CONFIG_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), NM_TYPE_IP6_CONFIG, NMIP6ConfigPrivate)) typedef struct { - DBusGProxy *proxy; + GDBusProxy *proxy; char *gateway; - GSList *addresses; - GSList *routes; + GPtrArray *addresses; + GPtrArray *routes; char **nameservers; char **domains; char **searches; @@ -57,58 +55,39 @@ enum { }; static gboolean -demarshal_ip6_address_array (NMObject *object, GParamSpec *pspec, GValue *value, gpointer field) +demarshal_ip6_address_array (NMObject *object, GParamSpec *pspec, GVariant *value, gpointer field) { NMIP6ConfigPrivate *priv = NM_IP6_CONFIG_GET_PRIVATE (object); - g_slist_free_full (priv->addresses, (GDestroyNotify) nm_ip6_address_unref); - priv->addresses = NULL; - - priv->addresses = nm_utils_ip6_addresses_from_gvalue (value); + g_ptr_array_unref (priv->addresses); + priv->addresses = nm_utils_ip6_addresses_from_variant (value); _nm_object_queue_notify (object, NM_IP6_CONFIG_ADDRESSES); return TRUE; } static gboolean -demarshal_ip6_nameserver_array (NMObject *object, GParamSpec *pspec, GValue *value, gpointer field) +demarshal_ip6_nameserver_array (NMObject *object, GParamSpec *pspec, GVariant *value, gpointer field) { - GPtrArray *ip_array; char ***obj_field; - int i; - - if (!G_VALUE_HOLDS (value, DBUS_TYPE_G_ARRAY_OF_ARRAY_OF_UCHAR)) - return FALSE; - - ip_array = g_value_get_boxed (value); obj_field = field; if (*obj_field) g_strfreev (*obj_field); - *obj_field = g_new (char *, ip_array ? ip_array->len + 1 : 1); - for (i = 0; ip_array && i < ip_array->len; i++) { - GByteArray *ip = g_ptr_array_index (ip_array, i); - const char *str; - - str = nm_utils_inet6_ntop ((struct in6_addr *) ip->data, NULL); - (*obj_field)[i] = g_strdup (str); - } - (*obj_field)[i] = NULL; + *obj_field = nm_utils_ip6_dns_from_variant (value); _nm_object_queue_notify (object, pspec->name); return TRUE; } static gboolean -demarshal_ip6_routes_array (NMObject *object, GParamSpec *pspec, GValue *value, gpointer field) +demarshal_ip6_routes_array (NMObject *object, GParamSpec *pspec, GVariant *value, gpointer field) { NMIP6ConfigPrivate *priv = NM_IP6_CONFIG_GET_PRIVATE (object); - g_slist_free_full (priv->routes, (GDestroyNotify) nm_ip6_route_unref); - priv->routes = NULL; - - priv->routes = nm_utils_ip6_routes_from_gvalue (value); + g_ptr_array_unref (priv->routes); + priv->routes = nm_utils_ip6_routes_from_variant (value); _nm_object_queue_notify (object, NM_IP6_CONFIG_ROUTES); return TRUE; @@ -158,11 +137,11 @@ nm_ip6_config_get_gateway (NMIP6Config *config) * * Gets the IP6 addresses (containing the address, prefix, and gateway). * - * Returns: (element-type NMIP6Address): the #GSList containing + * Returns: (element-type NMIP6Address): the #GPtrArray containing * #NMIP6Address<!-- -->es. This is the internal copy used by the configuration * and must not be modified. **/ -const GSList * +GPtrArray * nm_ip6_config_get_addresses (NMIP6Config *config) { g_return_val_if_fail (NM_IS_IP6_CONFIG (config), NULL); @@ -224,11 +203,11 @@ nm_ip6_config_get_searches (NMIP6Config *config) * * Gets the routes. * - * Returns: (element-type NMIP6Route): the #GSList containing + * Returns: (element-type NMIP6Route): the #GPtrArray containing * #NMIP6Routes. This is the internal copy used by the configuration, * and must not be modified. **/ -const GSList * +GPtrArray * nm_ip6_config_get_routes (NMIP6Config *config) { g_return_val_if_fail (NM_IS_IP6_CONFIG (config), NULL); @@ -243,8 +222,8 @@ finalize (GObject *object) g_free (priv->gateway); - g_slist_free_full (priv->addresses, (GDestroyNotify) nm_ip6_address_unref); - g_slist_free_full (priv->routes, (GDestroyNotify) nm_ip6_route_unref); + g_ptr_array_unref (priv->addresses); + g_ptr_array_unref (priv->routes); g_strfreev (priv->nameservers); g_strfreev (priv->domains); @@ -262,17 +241,16 @@ get_property (GObject *object, GParamSpec *pspec) { NMIP6Config *self = NM_IP6_CONFIG (object); - NMIP6ConfigPrivate *priv = NM_IP6_CONFIG_GET_PRIVATE (self); switch (prop_id) { case PROP_GATEWAY: 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_set_boxed (value, nm_ip6_config_get_addresses (self)); break; case PROP_ROUTES: - nm_utils_ip6_routes_to_gvalue (priv->routes, value); + g_value_set_boxed (value, nm_ip6_config_get_routes (self)); break; case PROP_NAMESERVERS: g_value_set_boxed (value, (char **) nm_ip6_config_get_nameservers (self)); @@ -294,6 +272,8 @@ nm_ip6_config_init (NMIP6Config *config) { NMIP6ConfigPrivate *priv = NM_IP6_CONFIG_GET_PRIVATE (config); + priv->addresses = g_ptr_array_new (); + priv->routes = g_ptr_array_new (); priv->nameservers = g_new0 (char *, 1); priv->domains = g_new0 (char *, 1); priv->searches = g_new0 (char *, 1); @@ -330,28 +310,28 @@ 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. + * + * Element-type: 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. + * + * Element-type: 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)); |