ip[46]-config/trivial: move code around

Move the GObject related functions to the end of the source file.
Similar to how it's done for most other implementations.
This commit is contained in:
Thomas Haller
2017-01-15 12:15:58 +01:00
parent 175ef8f611
commit 0bb1e9a116
9 changed files with 141 additions and 127 deletions

View File

@@ -577,7 +577,7 @@ set_property (GObject *object, guint prop_id,
{
switch (prop_id) {
case PROP_ATM_INDEX:
/* construct only */
/* construct-only */
NM_DEVICE_ADSL_GET_PRIVATE ((NMDeviceAdsl *) object)->atm_index = g_value_get_int (value);
break;
default:

View File

@@ -1077,7 +1077,7 @@ set_property (GObject *object, guint prop_id,
switch (prop_id) {
case PROP_PATH:
/* construct only */
/* construct-only */
priv->path = g_value_dup_string (value);
break;
default:

View File

@@ -281,7 +281,7 @@ set_property (GObject *object, guint prop_id,
switch (prop_id) {
case PROP_PATH:
/* construct only */
/* construct-only */
priv->path = g_value_dup_string (value);
break;
default:

View File

@@ -851,7 +851,7 @@ set_property (GObject *object, guint prop_id,
g_warn_if_fail (priv->ifindex > 0);
break;
case PROP_HWADDR:
/* construct only */
/* construct-only */
priv->hwaddr = g_value_dup_boxed (value);
break;
case PROP_IPV6:

View File

@@ -509,7 +509,7 @@ set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *p
switch (prop_id) {
case PROP_POLKIT_ENABLED:
/* construct only */
/* construct-only */
priv->polkit_enabled = !!g_value_get_boolean (value);
break;
default:

View File

@@ -2232,7 +2232,7 @@ set_property (GObject *object, guint prop_id,
switch (prop_id) {
case PROP_CMD_LINE_OPTIONS:
/* construct only */
/* construct-only */
cli = g_value_get_pointer (value);
if (!cli)
_nm_config_cmd_line_options_clear (&priv->cli);
@@ -2240,7 +2240,7 @@ set_property (GObject *object, guint prop_id,
_nm_config_cmd_line_options_copy (cli, &priv->cli);
break;
case PROP_ATOMIC_SECTION_PREFIXES:
/* construct only */
/* construct-only */
priv->atomic_section_prefixes = g_strdupv (g_value_get_boxed (value));
break;
default:

View File

@@ -35,6 +35,29 @@
#include "introspection/org.freedesktop.NetworkManager.IP4Config.h"
/*****************************************************************************/
/* internal guint32 are assigned to gobject properties of type uint. Ensure, that uint is large enough */
G_STATIC_ASSERT (sizeof (uint) >= sizeof (guint32));
G_STATIC_ASSERT (G_MAXUINT >= 0xFFFFFFFF);
/*****************************************************************************/
NM_GOBJECT_PROPERTIES_DEFINE (NMIP4Config,
PROP_IFINDEX,
PROP_ADDRESS_DATA,
PROP_ADDRESSES,
PROP_ROUTE_DATA,
PROP_ROUTES,
PROP_GATEWAY,
PROP_NAMESERVERS,
PROP_DOMAINS,
PROP_SEARCHES,
PROP_DNS_OPTIONS,
PROP_WINS_SERVERS,
PROP_DNS_PRIORITY,
);
typedef struct {
gboolean never_default;
guint32 gateway;
@@ -72,33 +95,7 @@ G_DEFINE_TYPE (NMIP4Config, nm_ip4_config, NM_TYPE_EXPORTED_OBJECT)
#define NM_IP4_CONFIG_GET_PRIVATE(self) _NM_GET_PRIVATE(self, NMIP4Config, NM_IS_IP4_CONFIG)
/* internal guint32 are assigned to gobject properties of type uint. Ensure, that uint is large enough */
G_STATIC_ASSERT (sizeof (uint) >= sizeof (guint32));
G_STATIC_ASSERT (G_MAXUINT >= 0xFFFFFFFF);
NM_GOBJECT_PROPERTIES_DEFINE (NMIP4Config,
PROP_IFINDEX,
PROP_ADDRESS_DATA,
PROP_ADDRESSES,
PROP_ROUTE_DATA,
PROP_ROUTES,
PROP_GATEWAY,
PROP_NAMESERVERS,
PROP_DOMAINS,
PROP_SEARCHES,
PROP_DNS_OPTIONS,
PROP_WINS_SERVERS,
PROP_DNS_PRIORITY,
);
NMIP4Config *
nm_ip4_config_new (int ifindex)
{
g_return_val_if_fail (ifindex >= -1, NULL);
return (NMIP4Config *) g_object_new (NM_TYPE_IP4_CONFIG,
NM_IP4_CONFIG_IFINDEX, ifindex,
NULL);
}
/*****************************************************************************/
int
nm_ip4_config_get_ifindex (const NMIP4Config *config)
@@ -2233,43 +2230,6 @@ nm_ip4_config_equal (const NMIP4Config *a, const NMIP4Config *b)
/*****************************************************************************/
static void
nm_ip4_config_init (NMIP4Config *config)
{
NMIP4ConfigPrivate *priv = NM_IP4_CONFIG_GET_PRIVATE (config);
priv->addresses = g_array_new (FALSE, FALSE, sizeof (NMPlatformIP4Address));
priv->routes = g_array_new (FALSE, FALSE, sizeof (NMPlatformIP4Route));
priv->nameservers = g_array_new (FALSE, FALSE, sizeof (guint32));
priv->domains = g_ptr_array_new_with_free_func (g_free);
priv->searches = g_ptr_array_new_with_free_func (g_free);
priv->dns_options = g_ptr_array_new_with_free_func (g_free);
priv->nis = g_array_new (FALSE, TRUE, sizeof (guint32));
priv->wins = g_array_new (FALSE, TRUE, sizeof (guint32));
priv->route_metric = -1;
}
static void
finalize (GObject *object)
{
NMIP4Config *self = NM_IP4_CONFIG (object);
NMIP4ConfigPrivate *priv = NM_IP4_CONFIG_GET_PRIVATE (self);
nm_clear_g_variant (&priv->address_data_variant);
nm_clear_g_variant (&priv->addresses_variant);
g_array_unref (priv->addresses);
g_array_unref (priv->routes);
g_array_unref (priv->nameservers);
g_ptr_array_unref (priv->domains);
g_ptr_array_unref (priv->searches);
g_ptr_array_unref (priv->dns_options);
g_array_unref (priv->nis);
g_free (priv->nis_domain);
g_array_unref (priv->wins);
G_OBJECT_CLASS (nm_ip4_config_parent_class)->finalize (object);
}
static void
get_property (GObject *object, guint prop_id,
GValue *value, GParamSpec *pspec)
@@ -2459,6 +2419,7 @@ set_property (GObject *object,
switch (prop_id) {
case PROP_IFINDEX:
/* construct-only */
priv->ifindex = g_value_get_int (value);
break;
default:
@@ -2467,6 +2428,54 @@ set_property (GObject *object,
}
}
/*****************************************************************************/
static void
nm_ip4_config_init (NMIP4Config *config)
{
NMIP4ConfigPrivate *priv = NM_IP4_CONFIG_GET_PRIVATE (config);
priv->addresses = g_array_new (FALSE, FALSE, sizeof (NMPlatformIP4Address));
priv->routes = g_array_new (FALSE, FALSE, sizeof (NMPlatformIP4Route));
priv->nameservers = g_array_new (FALSE, FALSE, sizeof (guint32));
priv->domains = g_ptr_array_new_with_free_func (g_free);
priv->searches = g_ptr_array_new_with_free_func (g_free);
priv->dns_options = g_ptr_array_new_with_free_func (g_free);
priv->nis = g_array_new (FALSE, TRUE, sizeof (guint32));
priv->wins = g_array_new (FALSE, TRUE, sizeof (guint32));
priv->route_metric = -1;
}
NMIP4Config *
nm_ip4_config_new (int ifindex)
{
g_return_val_if_fail (ifindex >= -1, NULL);
return (NMIP4Config *) g_object_new (NM_TYPE_IP4_CONFIG,
NM_IP4_CONFIG_IFINDEX, ifindex,
NULL);
}
static void
finalize (GObject *object)
{
NMIP4Config *self = NM_IP4_CONFIG (object);
NMIP4ConfigPrivate *priv = NM_IP4_CONFIG_GET_PRIVATE (self);
nm_clear_g_variant (&priv->address_data_variant);
nm_clear_g_variant (&priv->addresses_variant);
g_array_unref (priv->addresses);
g_array_unref (priv->routes);
g_array_unref (priv->nameservers);
g_ptr_array_unref (priv->domains);
g_ptr_array_unref (priv->searches);
g_ptr_array_unref (priv->dns_options);
g_array_unref (priv->nis);
g_free (priv->nis_domain);
g_array_unref (priv->wins);
G_OBJECT_CLASS (nm_ip4_config_parent_class)->finalize (object);
}
static void
nm_ip4_config_class_init (NMIP4ConfigClass *config_class)
{

View File

@@ -35,6 +35,8 @@
#include "introspection/org.freedesktop.NetworkManager.IP6Config.h"
/*****************************************************************************/
typedef struct {
gboolean never_default;
struct in6_addr gateway;
@@ -80,26 +82,7 @@ NM_GOBJECT_PROPERTIES_DEFINE (NMIP6Config,
PROP_DNS_PRIORITY,
);
NMIP6Config *
nm_ip6_config_new (int ifindex)
{
g_return_val_if_fail (ifindex >= -1, NULL);
return (NMIP6Config *) g_object_new (NM_TYPE_IP6_CONFIG,
NM_IP6_CONFIG_IFINDEX, ifindex,
NULL);
}
NMIP6Config *
nm_ip6_config_new_cloned (const NMIP6Config *src)
{
NMIP6Config *new;
g_return_val_if_fail (NM_IS_IP6_CONFIG (src), NULL);
new = nm_ip6_config_new (nm_ip6_config_get_ifindex (src));
nm_ip6_config_replace (new, src, NULL);
return new;
}
/*****************************************************************************/
int
nm_ip6_config_get_ifindex (const NMIP6Config *config)
@@ -1999,38 +1982,6 @@ nm_ip6_config_equal (const NMIP6Config *a, const NMIP6Config *b)
/*****************************************************************************/
static void
nm_ip6_config_init (NMIP6Config *config)
{
NMIP6ConfigPrivate *priv = NM_IP6_CONFIG_GET_PRIVATE (config);
priv->addresses = g_array_new (FALSE, TRUE, sizeof (NMPlatformIP6Address));
priv->routes = g_array_new (FALSE, TRUE, sizeof (NMPlatformIP6Route));
priv->nameservers = g_array_new (FALSE, TRUE, sizeof (struct in6_addr));
priv->domains = g_ptr_array_new_with_free_func (g_free);
priv->searches = g_ptr_array_new_with_free_func (g_free);
priv->dns_options = g_ptr_array_new_with_free_func (g_free);
priv->route_metric = -1;
}
static void
finalize (GObject *object)
{
NMIP6Config *self = NM_IP6_CONFIG (object);
NMIP6ConfigPrivate *priv = NM_IP6_CONFIG_GET_PRIVATE (self);
g_array_unref (priv->addresses);
g_array_unref (priv->routes);
g_array_unref (priv->nameservers);
g_ptr_array_unref (priv->domains);
g_ptr_array_unref (priv->searches);
g_ptr_array_unref (priv->dns_options);
nm_clear_g_variant (&priv->address_data_variant);
nm_clear_g_variant (&priv->addresses_variant);
G_OBJECT_CLASS (nm_ip6_config_parent_class)->finalize (object);
}
static void
nameservers_to_gvalue (GArray *array, GValue *value)
{
@@ -2223,6 +2174,7 @@ set_property (GObject *object,
switch (prop_id) {
case PROP_IFINDEX:
/* construct-only */
priv->ifindex = g_value_get_int (value);
break;
default:
@@ -2231,6 +2183,61 @@ set_property (GObject *object,
}
}
/*****************************************************************************/
static void
nm_ip6_config_init (NMIP6Config *config)
{
NMIP6ConfigPrivate *priv = NM_IP6_CONFIG_GET_PRIVATE (config);
priv->addresses = g_array_new (FALSE, TRUE, sizeof (NMPlatformIP6Address));
priv->routes = g_array_new (FALSE, TRUE, sizeof (NMPlatformIP6Route));
priv->nameservers = g_array_new (FALSE, TRUE, sizeof (struct in6_addr));
priv->domains = g_ptr_array_new_with_free_func (g_free);
priv->searches = g_ptr_array_new_with_free_func (g_free);
priv->dns_options = g_ptr_array_new_with_free_func (g_free);
priv->route_metric = -1;
}
NMIP6Config *
nm_ip6_config_new (int ifindex)
{
g_return_val_if_fail (ifindex >= -1, NULL);
return (NMIP6Config *) g_object_new (NM_TYPE_IP6_CONFIG,
NM_IP6_CONFIG_IFINDEX, ifindex,
NULL);
}
NMIP6Config *
nm_ip6_config_new_cloned (const NMIP6Config *src)
{
NMIP6Config *new;
g_return_val_if_fail (NM_IS_IP6_CONFIG (src), NULL);
new = nm_ip6_config_new (nm_ip6_config_get_ifindex (src));
nm_ip6_config_replace (new, src, NULL);
return new;
}
static void
finalize (GObject *object)
{
NMIP6Config *self = NM_IP6_CONFIG (object);
NMIP6ConfigPrivate *priv = NM_IP6_CONFIG_GET_PRIVATE (self);
g_array_unref (priv->addresses);
g_array_unref (priv->routes);
g_array_unref (priv->nameservers);
g_ptr_array_unref (priv->domains);
g_ptr_array_unref (priv->searches);
g_ptr_array_unref (priv->dns_options);
nm_clear_g_variant (&priv->address_data_variant);
nm_clear_g_variant (&priv->addresses_variant);
G_OBJECT_CLASS (nm_ip6_config_parent_class)->finalize (object);
}
static void
nm_ip6_config_class_init (NMIP6ConfigClass *config_class)
{
@@ -2239,12 +2246,10 @@ nm_ip6_config_class_init (NMIP6ConfigClass *config_class)
exported_object_class->export_path = NM_EXPORT_PATH_NUMBERED (NM_DBUS_PATH"/IP6Config");
/* virtual methods */
object_class->get_property = get_property;
object_class->set_property = set_property;
object_class->finalize = finalize;
/* properties */
obj_properties[PROP_IFINDEX] =
g_param_spec_int (NM_IP6_CONFIG_IFINDEX, "", "",
-1, G_MAXINT, -1,

View File

@@ -676,12 +676,12 @@ set_property (GObject *object, guint prop_id,
switch (prop_id) {
case PROP_FD_NET:
/* construct only */
/* construct-only */
priv->fd_net = g_value_get_int (value);
g_return_if_fail (priv->fd_net > 0);
break;
case PROP_FD_MNT:
/* construct only */
/* construct-only */
priv->fd_mnt = g_value_get_int (value);
g_return_if_fail (priv->fd_mnt > 0);
break;