From f71218d70a2a3f8c256b3226a8a4b166cab3122c Mon Sep 17 00:00:00 2001 From: Dan Winship Date: Mon, 25 Aug 2014 10:51:26 -0400 Subject: [PATCH 1/7] libnm: simplify NMDevice:state-reason The NMDevice:state-reason property was awkward to work with since it was a tuple of two values (state and reason), and likewise, although we had nm_device_get_state() to return just the state, there was no corresponding function to get just the reason. Fix this; make the state-reason property contain just the NMDeviceStateReason, and make nm_device_get_state_reason() return just that. --- clients/cli/devices.c | 6 ++++-- libnm/nm-device.c | 47 +++++++++++++++++-------------------------- libnm/nm-device.h | 2 +- 3 files changed, 23 insertions(+), 32 deletions(-) diff --git a/clients/cli/devices.c b/clients/cli/devices.c index 11ed479706..7f5fbdd232 100644 --- a/clients/cli/devices.c +++ b/clients/cli/devices.c @@ -749,7 +749,8 @@ show_device_info (NMDevice *device, NmCli *nmc) /* Remove any previous data */ nmc_empty_output_fields (nmc); - state = nm_device_get_state_reason (device, &reason); + state = nm_device_get_state (device); + reason = nm_device_get_state_reason (device); /* section GENERAL */ if (!strcasecmp (nmc_fields_dev_show_sections[section_idx].name, nmc_fields_dev_show_sections[0].name)) { @@ -1921,7 +1922,7 @@ monitor_device_state_cb (NMDevice *device, GParamSpec *pspec, gpointer user_data NMDeviceState state; NMDeviceStateReason reason; - state = nm_device_get_state_reason (device, &reason); + state = nm_device_get_state (device); if (state == NM_DEVICE_STATE_ACTIVATED) { NMActiveConnection *active = nm_device_get_active_connection (device); @@ -1932,6 +1933,7 @@ monitor_device_state_cb (NMDevice *device, GParamSpec *pspec, gpointer user_data nm_active_connection_get_uuid (active), nm_device_get_iface (device)); quit (); } else if (state == NM_DEVICE_STATE_FAILED) { + reason = nm_device_get_state_reason (device); g_string_printf (nmc->return_text, _("Error: Connection activation failed: (%d) %s."), reason, nmc_device_reason_to_string (reason)); nmc->return_value = NMC_RESULT_ERROR_CON_ACTIVATION; diff --git a/libnm/nm-device.c b/libnm/nm-device.c index de6a679402..88d8514f4e 100644 --- a/libnm/nm-device.c +++ b/libnm/nm-device.c @@ -62,8 +62,6 @@ G_DEFINE_TYPE_WITH_CODE (NMDevice, nm_device, NM_TYPE_OBJECT, _nm_device_type_for_path_async); ) -#define DBUS_G_TYPE_UINT_STRUCT (dbus_g_type_get_struct ("GValueArray", G_TYPE_UINT, G_TYPE_UINT, G_TYPE_INVALID)) - #define NM_DEVICE_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), NM_TYPE_DEVICE, NMDevicePrivate)) typedef struct { @@ -164,19 +162,20 @@ nm_device_init (NMDevice *device) priv->reason = NM_DEVICE_STATE_REASON_NONE; } +#define DBUS_G_TYPE_UINT_STRUCT (dbus_g_type_get_struct ("GValueArray", G_TYPE_UINT, G_TYPE_UINT, G_TYPE_INVALID)) + static gboolean demarshal_state_reason (NMObject *object, GParamSpec *pspec, GValue *value, gpointer field) { - NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE (object); + guint32 *reason_field = field; if (!G_VALUE_HOLDS (value, DBUS_G_TYPE_UINT_STRUCT)) return FALSE; dbus_g_type_struct_get (value, - 0, &priv->state, - 1, &priv->reason, + 1, reason_field, G_MAXUINT); - + _nm_object_queue_notify (object, NM_DEVICE_STATE_REASON); return TRUE; } @@ -208,7 +207,7 @@ init_dbus (NMObject *object) { NM_DEVICE_IP6_CONFIG, &priv->ip6_config, NULL, NM_TYPE_IP6_CONFIG }, { NM_DEVICE_DHCP6_CONFIG, &priv->dhcp6_config, NULL, NM_TYPE_DHCP6_CONFIG }, { NM_DEVICE_STATE, &priv->state }, - { NM_DEVICE_STATE_REASON, &priv->state, demarshal_state_reason }, + { NM_DEVICE_STATE_REASON, &priv->reason, demarshal_state_reason }, { NM_DEVICE_ACTIVE_CONNECTION, &priv->active_connection, NULL, NM_TYPE_ACTIVE_CONNECTION }, { NM_DEVICE_AVAILABLE_CONNECTIONS, &priv->available_connections, NULL, NM_TYPE_REMOTE_CONNECTION }, { NM_DEVICE_PHYSICAL_PORT_ID, &priv->physical_port_id }, @@ -418,7 +417,6 @@ get_property (GObject *object, GParamSpec *pspec) { NMDevice *device = NM_DEVICE (object); - NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE (device); switch (prop_id) { case PROP_DEVICE_TYPE: @@ -470,12 +468,7 @@ get_property (GObject *object, g_value_set_uint (value, nm_device_get_state (device)); break; case PROP_STATE_REASON: - g_value_set_boxed (value, - dbus_g_type_specialized_construct (DBUS_G_TYPE_UINT_STRUCT)); - dbus_g_type_struct_set (value, - 0, priv->state, - 1, priv->reason, - G_MAXUINT); + g_value_set_uint (value, nm_device_get_state_reason (device)); break; case PROP_ACTIVE_CONNECTION: g_value_set_object (value, nm_device_get_active_connection (device)); @@ -749,14 +742,14 @@ nm_device_class_init (NMDeviceClass *device_class) /** * NMDevice:state-reason: * - * The state and reason of the device. + * The reason for the device state. **/ g_object_class_install_property (object_class, PROP_STATE_REASON, - g_param_spec_boxed (NM_DEVICE_STATE_REASON, "", "", - DBUS_G_TYPE_UINT_STRUCT, - G_PARAM_READABLE | - G_PARAM_STATIC_STRINGS)); + g_param_spec_uint (NM_DEVICE_STATE_REASON, "", "", + 0, G_MAXUINT32, 0, + G_PARAM_READABLE | + G_PARAM_STATIC_STRINGS)); /** * NMDevice:active-connection: @@ -1330,21 +1323,17 @@ nm_device_get_state (NMDevice *device) /** * nm_device_get_state_reason: * @device: a #NMDevice - * @reason: (out) (allow-none): location to store reason (#NMDeviceStateReason), or %NULL * - * Gets the current #NMDevice state (return value) and the reason for entering - * the state (@reason argument). + * Gets the reason for entering the current #NMDevice state. * - * Returns: the current device state + * Returns: the reason for entering the current device state **/ -NMDeviceState -nm_device_get_state_reason (NMDevice *device, NMDeviceStateReason *reason) +NMDeviceStateReason +nm_device_get_state_reason (NMDevice *device) { - g_return_val_if_fail (NM_IS_DEVICE (device), NM_DEVICE_STATE_UNKNOWN); + g_return_val_if_fail (NM_IS_DEVICE (device), NM_DEVICE_STATE_REASON_UNKNOWN); - if (reason) - *reason = NM_DEVICE_GET_PRIVATE (device)->reason; - return NM_DEVICE_GET_PRIVATE (device)->state; + return NM_DEVICE_GET_PRIVATE (device)->reason; } /** diff --git a/libnm/nm-device.h b/libnm/nm-device.h index d403d388c4..510589f732 100644 --- a/libnm/nm-device.h +++ b/libnm/nm-device.h @@ -132,7 +132,7 @@ NMDhcp4Config * nm_device_get_dhcp4_config (NMDevice *device); NMIP6Config * nm_device_get_ip6_config (NMDevice *device); NMDhcp6Config * nm_device_get_dhcp6_config (NMDevice *device); NMDeviceState nm_device_get_state (NMDevice *device); -NMDeviceState nm_device_get_state_reason (NMDevice *device, NMDeviceStateReason *reason); +NMDeviceStateReason nm_device_get_state_reason (NMDevice *device); NMActiveConnection * nm_device_get_active_connection(NMDevice *device); const GPtrArray * nm_device_get_available_connections(NMDevice *device); const char * nm_device_get_physical_port_id (NMDevice *device); From 4eb04dbcf81b231193704573f685c4055eefed79 Mon Sep 17 00:00:00 2001 From: Dan Winship Date: Wed, 2 Jul 2014 14:25:43 -0400 Subject: [PATCH 2/7] libnm: drop NM_TYPE_STRING_ARRAY, use G_TYPE_STRV Make NMIP4Config and NMIP6Config's array-of-string properties be G_TYPE_STRV, and update the corresponding APIs accordingly. --- clients/cli/common.c | 20 ++---------- libnm/libnm.ver | 1 - libnm/nm-ip4-config.c | 61 ++++++++++++++---------------------- libnm/nm-ip4-config.h | 14 ++++----- libnm/nm-ip6-config.c | 67 +++++++++++++--------------------------- libnm/nm-ip6-config.h | 4 +-- libnm/nm-object.c | 5 +++ libnm/nm-types-private.h | 1 - libnm/nm-types.c | 61 ------------------------------------ libnm/nm-types.h | 3 -- 10 files changed, 60 insertions(+), 177 deletions(-) diff --git a/clients/cli/common.c b/clients/cli/common.c index d860d6386d..76867047aa 100644 --- a/clients/cli/common.c +++ b/clients/cli/common.c @@ -81,7 +81,6 @@ print_ip4_config (NMIP4Config *cfg4, { GSList *list, *iter; const GArray *array; - const GPtrArray *ptr_array; char **addr_arr = NULL; char **route_arr = NULL; char **dns_arr = NULL; @@ -150,14 +149,7 @@ print_ip4_config (NMIP4Config *cfg4, } /* domains */ - ptr_array = nm_ip4_config_get_domains (cfg4); - if (ptr_array) { - domain_arr = g_new (char *, ptr_array->len + 1); - for (i = 0; i < ptr_array->len; i++) - domain_arr[i] = g_strdup (g_ptr_array_index (ptr_array, i)); - - domain_arr[i] = NULL; - } + domain_arr = g_strdupv ((char **) nm_ip4_config_get_domains (cfg4)); /* WINS */ array = nm_ip4_config_get_wins_servers (cfg4); @@ -193,7 +185,6 @@ print_ip6_config (NMIP6Config *cfg6, const char *one_field) { GSList *list, *iter; - const GPtrArray *ptr_array; char **addr_arr = NULL; char **route_arr = NULL; char **dns_arr = NULL; @@ -260,14 +251,7 @@ print_ip6_config (NMIP6Config *cfg6, dns_arr[i] = NULL; /* domains */ - ptr_array = nm_ip6_config_get_domains (cfg6); - if (ptr_array) { - domain_arr = g_new (char *, ptr_array->len + 1); - for (i = 0; i < ptr_array->len; i++) - domain_arr[i] = g_strdup (g_ptr_array_index (ptr_array, i)); - - domain_arr[i] = NULL; - } + domain_arr = g_strdupv ((char **) nm_ip6_config_get_domains (cfg6)); arr = nmc_dup_fields_array (tmpl, tmpl_len, NMC_OF_FLAG_SECTION_PREFIX); set_val_strc (arr, 0, group_prefix); diff --git a/libnm/libnm.ver b/libnm/libnm.ver index 326a6f15ad..7645af98dc 100644 --- a/libnm/libnm.ver +++ b/libnm/libnm.ver @@ -864,7 +864,6 @@ global: nm_simple_connection_new_from_dbus; nm_ssid_get_type; nm_state_get_type; - nm_string_array_get_type; nm_uint_array_get_type; nm_utils_ap_mode_security_valid; nm_utils_bin2hexstr; diff --git a/libnm/nm-ip4-config.c b/libnm/nm-ip4-config.c index 298a2198a2..8a545141dc 100644 --- a/libnm/nm-ip4-config.c +++ b/libnm/nm-ip4-config.c @@ -39,8 +39,8 @@ typedef struct { GSList *addresses; GSList *routes; GArray *nameservers; - GPtrArray *domains; - GPtrArray *searches; + char **domains; + char **searches; GArray *wins; } NMIP4ConfigPrivate; @@ -60,6 +60,10 @@ enum { static void nm_ip4_config_init (NMIP4Config *config) { + NMIP4ConfigPrivate *priv = NM_IP4_CONFIG_GET_PRIVATE (config); + + priv->domains = g_new0 (char *, 1); + priv->searches = g_new0 (char *, 1); } static gboolean @@ -90,16 +94,6 @@ demarshal_ip4_array (NMObject *object, GParamSpec *pspec, GValue *value, gpointe return TRUE; } -static gboolean -demarshal_string_array (NMObject *object, GParamSpec *pspec, GValue *value, gpointer field) -{ - if (!_nm_string_array_demarshal (value, (GPtrArray **) field)) - return FALSE; - - _nm_object_queue_notify (object, pspec->name); - return TRUE; -} - static gboolean demarshal_ip4_routes_array (NMObject *object, GParamSpec *pspec, GValue *value, gpointer field) { @@ -123,8 +117,8 @@ init_dbus (NMObject *object) { NM_IP4_CONFIG_ADDRESSES, &priv->addresses, demarshal_ip4_address_array }, { NM_IP4_CONFIG_ROUTES, &priv->routes, demarshal_ip4_routes_array }, { NM_IP4_CONFIG_NAMESERVERS, &priv->nameservers, demarshal_ip4_array }, - { NM_IP4_CONFIG_DOMAINS, &priv->domains, demarshal_string_array }, - { NM_IP4_CONFIG_SEARCHES, &priv->searches, demarshal_string_array }, + { NM_IP4_CONFIG_DOMAINS, &priv->domains, }, + { NM_IP4_CONFIG_SEARCHES, &priv->searches, }, { NM_IP4_CONFIG_WINS_SERVERS, &priv->wins, demarshal_ip4_array }, { NULL }, }; @@ -153,15 +147,8 @@ finalize (GObject *object) if (priv->wins) g_array_free (priv->wins, TRUE); - if (priv->domains) { - g_ptr_array_set_free_func (priv->domains, g_free); - g_ptr_array_free (priv->domains, TRUE); - } - - if (priv->searches) { - g_ptr_array_set_free_func (priv->searches, g_free); - g_ptr_array_free (priv->searches, TRUE); - } + g_strfreev (priv->domains); + g_strfreev (priv->searches); g_object_unref (priv->proxy); @@ -191,10 +178,10 @@ get_property (GObject *object, g_value_set_boxed (value, nm_ip4_config_get_nameservers (self)); break; case PROP_DOMAINS: - g_value_set_boxed (value, nm_ip4_config_get_domains (self)); + g_value_set_boxed (value, (char **) nm_ip4_config_get_domains (self)); break; case PROP_SEARCHES: - g_value_set_boxed (value, nm_ip4_config_get_searches (self)); + g_value_set_boxed (value, (char **) nm_ip4_config_get_searches (self)); break; case PROP_WINS_SERVERS: g_value_set_boxed (value, nm_ip4_config_get_wins_servers (self)); @@ -270,24 +257,24 @@ nm_ip4_config_class_init (NMIP4ConfigClass *config_class) /** * NMIP4Config:domains: * - * The #GPtrArray containing domain strings of the configuration. + * The array containing domain strings of the configuration. **/ g_object_class_install_property (object_class, PROP_DOMAINS, g_param_spec_boxed (NM_IP4_CONFIG_DOMAINS, "", "", - NM_TYPE_STRING_ARRAY, + G_TYPE_STRV, G_PARAM_READABLE | G_PARAM_STATIC_STRINGS)); /** * NMIP4Config:searches: * - * The #GPtrArray containing dns search strings of the configuration. + * The array containing DNS search strings of the configuration. **/ g_object_class_install_property (object_class, PROP_SEARCHES, g_param_spec_boxed (NM_IP4_CONFIG_SEARCHES, "", "", - NM_TYPE_STRING_ARRAY, + G_TYPE_STRV, G_PARAM_READABLE | G_PARAM_STATIC_STRINGS)); @@ -361,32 +348,30 @@ nm_ip4_config_get_nameservers (NMIP4Config *config) * * Gets the domain names. * - * Returns: (element-type utf8): the #GPtrArray containing domains as strings. This is the - * internal copy used by the configuration, and must not be modified. + * Returns: the array of domains. (This is never %NULL, though it may be 0-length). **/ -const GPtrArray * +const char * const * nm_ip4_config_get_domains (NMIP4Config *config) { g_return_val_if_fail (NM_IS_IP4_CONFIG (config), NULL); - return handle_ptr_array_return (NM_IP4_CONFIG_GET_PRIVATE (config)->domains); + return (const char * const *) NM_IP4_CONFIG_GET_PRIVATE (config)->domains; } /** * nm_ip4_config_get_searches: * @config: a #NMIP4Config * - * Gets the dns searches. + * Gets the DNS searches. * - * Returns: (element-type utf8): the #GPtrArray containing dns searches as strings. This is the - * internal copy used by the configuration, and must not be modified. + * Returns: the array of DNS search strings. (This is never %NULL, though it may be 0-length). **/ -const GPtrArray * +const char * const * nm_ip4_config_get_searches (NMIP4Config *config) { g_return_val_if_fail (NM_IS_IP4_CONFIG (config), NULL); - return handle_ptr_array_return (NM_IP4_CONFIG_GET_PRIVATE (config)->searches); + return (const char * const *) NM_IP4_CONFIG_GET_PRIVATE (config)->searches; } /** diff --git a/libnm/nm-ip4-config.h b/libnm/nm-ip4-config.h index 7c1f039345..1a04e912cc 100644 --- a/libnm/nm-ip4-config.h +++ b/libnm/nm-ip4-config.h @@ -60,13 +60,13 @@ typedef struct { GType nm_ip4_config_get_type (void); -const char * nm_ip4_config_get_gateway (NMIP4Config *config); -const GSList * nm_ip4_config_get_addresses (NMIP4Config *config); -const GSList * nm_ip4_config_get_routes (NMIP4Config *config); -const GArray * nm_ip4_config_get_nameservers (NMIP4Config *config); -const GPtrArray *nm_ip4_config_get_domains (NMIP4Config *config); -const GPtrArray *nm_ip4_config_get_searches (NMIP4Config *config); -const GArray * nm_ip4_config_get_wins_servers (NMIP4Config *config); +const char * nm_ip4_config_get_gateway (NMIP4Config *config); +const GSList * nm_ip4_config_get_addresses (NMIP4Config *config); +const GSList * nm_ip4_config_get_routes (NMIP4Config *config); +const GArray * nm_ip4_config_get_nameservers (NMIP4Config *config); +const char * const *nm_ip4_config_get_domains (NMIP4Config *config); +const char * const *nm_ip4_config_get_searches (NMIP4Config *config); +const GArray * nm_ip4_config_get_wins_servers (NMIP4Config *config); G_END_DECLS diff --git a/libnm/nm-ip6-config.c b/libnm/nm-ip6-config.c index 7d34171601..74dc2b909e 100644 --- a/libnm/nm-ip6-config.c +++ b/libnm/nm-ip6-config.c @@ -39,8 +39,8 @@ typedef struct { GSList *addresses; GSList *routes; GSList *nameservers; - GPtrArray *domains; - GPtrArray *searches; + char **domains; + char **searches; } NMIP6ConfigPrivate; enum { @@ -81,26 +81,6 @@ demarshal_ip6_nameserver_array (NMObject *object, GParamSpec *pspec, GValue *val return TRUE; } -static gboolean -demarshal_domains (NMObject *object, GParamSpec *pspec, GValue *value, gpointer field) -{ - if (!_nm_string_array_demarshal (value, (GPtrArray **) field)) - return FALSE; - - _nm_object_queue_notify (object, NM_IP6_CONFIG_DOMAINS); - return TRUE; -} - -static gboolean -demarshal_searches (NMObject *object, GParamSpec *pspec, GValue *value, gpointer field) -{ - if (!_nm_string_array_demarshal (value, (GPtrArray **) field)) - return FALSE; - - _nm_object_queue_notify (object, NM_IP6_CONFIG_SEARCHES); - return TRUE; -} - static gboolean demarshal_ip6_routes_array (NMObject *object, GParamSpec *pspec, GValue *value, gpointer field) { @@ -124,8 +104,8 @@ init_dbus (NMObject *object) { NM_IP6_CONFIG_ADDRESSES, &priv->addresses, demarshal_ip6_address_array }, { NM_IP6_CONFIG_ROUTES, &priv->routes, demarshal_ip6_routes_array }, { NM_IP6_CONFIG_NAMESERVERS, &priv->nameservers, demarshal_ip6_nameserver_array }, - { NM_IP6_CONFIG_DOMAINS, &priv->domains, demarshal_domains }, - { NM_IP6_CONFIG_SEARCHES, &priv->searches, demarshal_searches }, + { NM_IP6_CONFIG_DOMAINS, &priv->domains, }, + { NM_IP6_CONFIG_SEARCHES, &priv->searches, }, { NULL }, }; @@ -240,32 +220,30 @@ nm_ip6_config_get_nameservers (NMIP6Config *config) * * Gets the domain names. * - * Returns: (element-type utf8): the #GPtrArray containing domains as strings. - * This is the internal copy used by the configuration, and must not be modified. + * Returns: the array of domains. (This is never %NULL, though it may be 0-length). **/ -const GPtrArray * +const char * const * nm_ip6_config_get_domains (NMIP6Config *config) { g_return_val_if_fail (NM_IS_IP6_CONFIG (config), NULL); - return handle_ptr_array_return (NM_IP6_CONFIG_GET_PRIVATE (config)->domains); + return (const char * const *) NM_IP6_CONFIG_GET_PRIVATE (config)->domains; } /** * nm_ip6_config_get_searches: * @config: a #NMIP6Config * - * Gets the dns searches. + * Gets the DNS search strings. * - * Returns: (element-type utf8): the #GPtrArray containing dns searches as strings. - * This is the internal copy used by the configuration, and must not be modified. + * Returns: the array of DNS search strings. (This is never %NULL, though it may be 0-length). **/ -const GPtrArray * +const char * const * nm_ip6_config_get_searches (NMIP6Config *config) { g_return_val_if_fail (NM_IS_IP6_CONFIG (config), NULL); - return handle_ptr_array_return (NM_IP6_CONFIG_GET_PRIVATE (config)->searches); + return (const char * const *) NM_IP6_CONFIG_GET_PRIVATE (config)->searches; } /** @@ -297,15 +275,8 @@ finalize (GObject *object) g_slist_free_full (priv->routes, (GDestroyNotify) nm_ip6_route_unref); g_slist_free_full (priv->nameservers, g_free); - if (priv->domains) { - g_ptr_array_set_free_func (priv->domains, g_free); - g_ptr_array_free (priv->domains, TRUE); - } - - if (priv->searches) { - g_ptr_array_set_free_func (priv->searches, g_free); - g_ptr_array_free (priv->searches, TRUE); - } + g_strfreev (priv->domains); + g_strfreev (priv->searches); g_object_unref (priv->proxy); @@ -335,10 +306,10 @@ get_property (GObject *object, g_value_set_boxed (value, nm_ip6_config_get_nameservers (self)); break; case PROP_DOMAINS: - g_value_set_boxed (value, nm_ip6_config_get_domains (self)); + g_value_set_boxed (value, (char **) nm_ip6_config_get_domains (self)); break; case PROP_SEARCHES: - g_value_set_boxed (value, nm_ip6_config_get_searches (self)); + g_value_set_boxed (value, (char **) nm_ip6_config_get_searches (self)); break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); @@ -349,6 +320,10 @@ get_property (GObject *object, static void nm_ip6_config_init (NMIP6Config *config) { + NMIP6ConfigPrivate *priv = NM_IP6_CONFIG_GET_PRIVATE (config); + + priv->domains = g_new0 (char *, 1); + priv->searches = g_new0 (char *, 1); } static void @@ -428,7 +403,7 @@ nm_ip6_config_class_init (NMIP6ConfigClass *config_class) g_object_class_install_property (object_class, PROP_DOMAINS, g_param_spec_boxed (NM_IP6_CONFIG_DOMAINS, "", "", - NM_TYPE_STRING_ARRAY, + G_TYPE_STRV, G_PARAM_READABLE | G_PARAM_STATIC_STRINGS)); @@ -440,7 +415,7 @@ nm_ip6_config_class_init (NMIP6ConfigClass *config_class) g_object_class_install_property (object_class, PROP_SEARCHES, g_param_spec_boxed (NM_IP6_CONFIG_SEARCHES, "", "", - NM_TYPE_STRING_ARRAY, + G_TYPE_STRV, G_PARAM_READABLE | G_PARAM_STATIC_STRINGS)); diff --git a/libnm/nm-ip6-config.h b/libnm/nm-ip6-config.h index ed664b1010..467568cf6a 100644 --- a/libnm/nm-ip6-config.h +++ b/libnm/nm-ip6-config.h @@ -65,8 +65,8 @@ const GSList * nm_ip6_config_get_routes (NMIP6Config *config); guint32 nm_ip6_config_get_num_nameservers (NMIP6Config *config); const struct in6_addr *nm_ip6_config_get_nameserver (NMIP6Config *config, guint32 idx); const GSList * nm_ip6_config_get_nameservers (NMIP6Config *config); -const GPtrArray * nm_ip6_config_get_domains (NMIP6Config *config); -const GPtrArray * nm_ip6_config_get_searches (NMIP6Config *config); +const char * const * nm_ip6_config_get_domains (NMIP6Config *config); +const char * const * nm_ip6_config_get_searches (NMIP6Config *config); G_END_DECLS diff --git a/libnm/nm-object.c b/libnm/nm-object.c index a8544a1100..c48ce1d4ba 100644 --- a/libnm/nm-object.c +++ b/libnm/nm-object.c @@ -1142,6 +1142,11 @@ demarshal_generic (NMObject *object, success = FALSE; goto done; } + } else if (pspec->value_type == G_TYPE_STRV) { + char ***param = (char ***)field; + if (*param) + g_strfreev (*param); + *param = g_value_dup_boxed (value); HANDLE_TYPE(BOOLEAN, boolean, boolean) HANDLE_TYPE(CHAR, char, schar) HANDLE_TYPE(UCHAR, uchar, uchar) diff --git a/libnm/nm-types-private.h b/libnm/nm-types-private.h index 9979f6c9fd..8626e0d1f6 100644 --- a/libnm/nm-types-private.h +++ b/libnm/nm-types-private.h @@ -27,7 +27,6 @@ gboolean _nm_ssid_demarshal (GValue *value, GByteArray **dest); gboolean _nm_uint_array_demarshal (GValue *value, GArray **dest); -gboolean _nm_string_array_demarshal (GValue *value, GPtrArray **dest); gboolean _nm_object_array_demarshal (GValue *value, GPtrArray **dest, DBusGConnection *connection, diff --git a/libnm/nm-types.c b/libnm/nm-types.c index cb0ff8ba6c..5e482accc5 100644 --- a/libnm/nm-types.c +++ b/libnm/nm-types.c @@ -133,67 +133,6 @@ _nm_uint_array_demarshal (GValue *value, GArray **dest) /*****************************/ -static gpointer -_nm_string_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, g_strdup (g_ptr_array_index (src, i))); - return dest; -} - -static void -_nm_string_array_free (GPtrArray *array) -{ - int i; - - for (i = 0; i < array->len; i++) - g_free (g_ptr_array_index (array, i)); - g_ptr_array_free (array, TRUE); -} - -GType -nm_string_array_get_type (void) -{ - static GType our_type = 0; - - if (our_type == 0) - our_type = g_boxed_type_register_static (g_intern_static_string ("NMStringArray"), - (GBoxedCopyFunc) _nm_string_array_copy, - (GBoxedFreeFunc) _nm_string_array_free); - return our_type; -} - -gboolean -_nm_string_array_demarshal (GValue *value, GPtrArray **dest) -{ - char **array; - - if (!G_VALUE_HOLDS (value, G_TYPE_STRV)) - return FALSE; - - if (*dest) { - g_boxed_free (NM_TYPE_STRING_ARRAY, *dest); - *dest = NULL; - } - - array = (char **) g_value_get_boxed (value); - if (array && array[0]) { - int i; - - *dest = g_ptr_array_new (); - for (i = 0; array[i]; i++) - g_ptr_array_add (*dest, g_strdup (array[i])); - } - - return TRUE; -} - -/*****************************/ - static gpointer _nm_object_array_copy (GPtrArray *src) { diff --git a/libnm/nm-types.h b/libnm/nm-types.h index a50f83c7c7..3a71f879d4 100644 --- a/libnm/nm-types.h +++ b/libnm/nm-types.h @@ -38,9 +38,6 @@ GType nm_ssid_get_type (void) G_GNUC_CONST; #define NM_TYPE_UINT_ARRAY (nm_uint_array_get_type ()) GType nm_uint_array_get_type (void) G_GNUC_CONST; -#define NM_TYPE_STRING_ARRAY (nm_string_array_get_type ()) -GType nm_string_array_get_type (void) G_GNUC_CONST; - #define NM_TYPE_OBJECT_ARRAY (nm_object_array_get_type ()) GType nm_object_array_get_type (void) G_GNUC_CONST; From 20dc44bda9e07222e46675507731b1532b4b20f2 Mon Sep 17 00:00:00 2001 From: Dan Winship Date: Wed, 2 Jul 2014 14:25:43 -0400 Subject: [PATCH 3/7] libnm: drop NM_TYPE_SSID, use G_TYPE_BYTES Make NMAccessPoint:ssid be G_TYPE_BYTES and update the corresponding APIs accordingly. --- clients/cli/devices.c | 16 ++++--- clients/tui/nmt-connect-connection-list.c | 9 ++-- examples/C/glib/get-ap-info-libnm.c | 9 ++-- libnm/libnm.ver | 1 - libnm/nm-access-point.c | 33 ++++---------- libnm/nm-access-point.h | 2 +- libnm/nm-object.c | 7 +++ libnm/nm-types-private.h | 1 - libnm/nm-types.c | 53 ----------------------- libnm/nm-types.h | 3 -- 10 files changed, 36 insertions(+), 98 deletions(-) diff --git a/clients/cli/devices.c b/clients/cli/devices.c index 7f5fbdd232..da7fa178f2 100644 --- a/clients/cli/devices.c +++ b/clients/cli/devices.c @@ -495,7 +495,7 @@ fill_output_access_point (gpointer data, gpointer user_data) NM80211ApSecurityFlags wpa_flags, rsn_flags; guint32 freq, bitrate; guint8 strength; - const GByteArray *ssid; + GBytes *ssid; const char *bssid; NM80211Mode mode; char *channel_str, *freq_str, *ssid_str = NULL, *ssid_hex_str = NULL, @@ -528,8 +528,12 @@ fill_output_access_point (gpointer data, gpointer user_data) /* Convert to strings */ if (ssid) { - ssid_str = nm_utils_ssid_to_utf8 (ssid->data, ssid->len); - ssid_hex_str = ssid_to_hex ((const char *) ssid->data, ssid->len); + const guint8 *ssid_data; + gsize ssid_len; + + ssid_data = g_bytes_get_data (ssid, &ssid_len); + ssid_str = nm_utils_ssid_to_utf8 (ssid_data, ssid_len); + ssid_hex_str = ssid_to_hex ((const char *) ssid_data, ssid_len); } channel_str = g_strdup_printf ("%u", nm_utils_wifi_freq_to_channel (freq)); freq_str = g_strdup_printf (_("%u MHz"), freq); @@ -2050,12 +2054,12 @@ find_ap_on_device (NMDevice *device, GByteArray *bssid, const char *ssid) if (ssid) { /* Parameter is SSID */ - const GByteArray *candidate_ssid; + GBytes *candidate_ssid; candidate_ssid = nm_access_point_get_ssid (candidate_ap); if (candidate_ssid) { - char *ssid_tmp = nm_utils_ssid_to_utf8 (candidate_ssid->data, - candidate_ssid->len); + char *ssid_tmp = nm_utils_ssid_to_utf8 (g_bytes_get_data (candidate_ssid, NULL), + g_bytes_get_size (candidate_ssid)); /* Compare SSIDs */ if (strcmp (ssid, ssid_tmp) == 0) { diff --git a/clients/tui/nmt-connect-connection-list.c b/clients/tui/nmt-connect-connection-list.c index d7592b80b2..2f98fb7ef1 100644 --- a/clients/tui/nmt-connect-connection-list.c +++ b/clients/tui/nmt-connect-connection-list.c @@ -213,7 +213,7 @@ static char * hash_ap (NMAccessPoint *ap) { unsigned char input[66]; - const GByteArray *ssid; + GBytes *ssid; NM80211Mode mode; guint32 flags; guint32 wpa_flags; @@ -223,7 +223,7 @@ hash_ap (NMAccessPoint *ap) ssid = nm_access_point_get_ssid (ap); if (ssid) - memcpy (input, ssid->data, ssid->len); + memcpy (input, g_bytes_get_data (ssid, NULL), g_bytes_get_size (ssid)); mode = nm_access_point_get_mode (ap); if (mode == NM_802_11_MODE_INFRA) @@ -266,7 +266,7 @@ add_connections_for_aps (NmtConnectDevice *nmtdev, NMAccessPoint *ap; const GPtrArray *aps; GHashTable *seen_ssids; - const GByteArray *ssid; + GBytes *ssid; char *ap_hash; GSList *iter; int i; @@ -294,7 +294,8 @@ add_connections_for_aps (NmtConnectDevice *nmtdev, nmtconn->device = nmtdev->device; nmtconn->ap = g_object_ref (ap); ssid = nm_access_point_get_ssid (ap); - nmtconn->ssid = nm_utils_ssid_to_utf8 (ssid->data, ssid->len); + nmtconn->ssid = nm_utils_ssid_to_utf8 (g_bytes_get_data (ssid, NULL), + g_bytes_get_size (ssid)); for (iter = connections; iter; iter = iter->next) { conn = iter->data; diff --git a/examples/C/glib/get-ap-info-libnm.c b/examples/C/glib/get-ap-info-libnm.c index acd93f9ba7..c5e9b5b238 100644 --- a/examples/C/glib/get-ap-info-libnm.c +++ b/examples/C/glib/get-ap-info-libnm.c @@ -79,7 +79,7 @@ show_access_point_info (NMAccessPoint *ap) { guint32 flags, wpa_flags, rsn_flags, freq, bitrate; guint8 strength; - const GByteArray *ssid; + GBytes *ssid; const char *hwaddr; NM80211Mode mode; char *freq_str, *ssid_str, *bitrate_str, *strength_str, *wpa_flags_str, *rsn_flags_str; @@ -97,7 +97,7 @@ show_access_point_info (NMAccessPoint *ap) strength = nm_access_point_get_strength (ap); /* Convert to strings */ - ssid_str = nm_utils_ssid_to_utf8 (ssid->data, ssid->len); + ssid_str = nm_utils_ssid_to_utf8 (g_bytes_get_data (ssid, NULL), g_bytes_get_size (ssid)); freq_str = g_strdup_printf ("%u MHz", freq); bitrate_str = g_strdup_printf ("%u Mbit/s", bitrate/1000); strength_str = g_strdup_printf ("%u", strength); @@ -155,7 +155,7 @@ show_wifi_device_info (NMDevice *device) const char *iface; const char *driver; guint32 speed; - const GByteArray *active_ssid; + GBytes *active_ssid; char *active_ssid_str = NULL; int i; @@ -163,7 +163,8 @@ show_wifi_device_info (NMDevice *device) if (nm_device_get_state (device) == NM_DEVICE_STATE_ACTIVATED) { if ((active_ap = nm_device_wifi_get_active_access_point (NM_DEVICE_WIFI (device)))) { active_ssid = nm_access_point_get_ssid (active_ap); - active_ssid_str = nm_utils_ssid_to_utf8 (active_ssid->data, active_ssid->len); + active_ssid_str = nm_utils_ssid_to_utf8 (g_bytes_get_data (active_ssid, NULL), + g_bytes_get_size (active_ssid)); } } diff --git a/libnm/libnm.ver b/libnm/libnm.ver index 7645af98dc..948eb058fe 100644 --- a/libnm/libnm.ver +++ b/libnm/libnm.ver @@ -862,7 +862,6 @@ global: nm_simple_connection_new; nm_simple_connection_new_clone; nm_simple_connection_new_from_dbus; - nm_ssid_get_type; nm_state_get_type; nm_uint_array_get_type; nm_utils_ap_mode_security_valid; diff --git a/libnm/nm-access-point.c b/libnm/nm-access-point.c index 650a567c18..d0695f9197 100644 --- a/libnm/nm-access-point.c +++ b/libnm/nm-access-point.c @@ -32,7 +32,6 @@ #include "nm-access-point.h" #include "nm-dbus-interface.h" -#include "nm-types-private.h" #include "nm-object-private.h" G_DEFINE_TYPE (NMAccessPoint, nm_access_point, NM_TYPE_OBJECT) @@ -45,7 +44,7 @@ typedef struct { NM80211ApFlags flags; NM80211ApSecurityFlags wpa_flags; NM80211ApSecurityFlags rsn_flags; - GByteArray *ssid; + GBytes *ssid; guint32 frequency; char *bssid; NM80211Mode mode; @@ -124,10 +123,9 @@ nm_access_point_get_rsn_flags (NMAccessPoint *ap) * * Gets the SSID of the access point. * - * Returns: the #GByteArray containing the SSID. This is the internal copy used by the - * access point, and must not be modified. + * Returns: the #GBytes containing the SSID. **/ -const GByteArray * +GBytes * nm_access_point_get_ssid (NMAccessPoint *ap) { g_return_val_if_fail (NM_IS_ACCESS_POINT (ap), NULL); @@ -237,9 +235,7 @@ nm_access_point_connection_valid (NMAccessPoint *ap, NMConnection *connection) NMSettingWirelessSecurity *s_wsec; const char *ctype, *ap_bssid; GBytes *setting_ssid; - const guint8 *setting_ssid_data; - gsize setting_ssid_len; - const GByteArray *ap_ssid; + GBytes *ap_ssid; const char *setting_bssid; const char *setting_mode; NM80211Mode ap_mode; @@ -262,10 +258,7 @@ nm_access_point_connection_valid (NMAccessPoint *ap, NMConnection *connection) setting_ssid = nm_setting_wireless_get_ssid (s_wifi); if (!setting_ssid || !ap_ssid) return FALSE; - setting_ssid_data = g_bytes_get_data (setting_ssid, &setting_ssid_len); - if (setting_ssid_len != ap_ssid->len) - return FALSE; - if (memcmp (setting_ssid_data, ap_ssid->data, ap_ssid->len) != 0) + if (!g_bytes_equal (ap_ssid, setting_ssid)) return FALSE; /* BSSID checks */ @@ -384,7 +377,7 @@ finalize (GObject *object) NMAccessPointPrivate *priv = NM_ACCESS_POINT_GET_PRIVATE (object); if (priv->ssid) - g_byte_array_free (priv->ssid, TRUE); + g_bytes_unref (priv->ssid); g_free (priv->bssid); @@ -436,16 +429,6 @@ get_property (GObject *object, } } -static gboolean -demarshal_ssid (NMObject *object, GParamSpec *pspec, GValue *value, gpointer field) -{ - if (!_nm_ssid_demarshal (value, (GByteArray **) field)) - return FALSE; - - _nm_object_queue_notify (object, NM_ACCESS_POINT_SSID); - return TRUE; -} - static void init_dbus (NMObject *object) { @@ -454,7 +437,7 @@ init_dbus (NMObject *object) { NM_ACCESS_POINT_FLAGS, &priv->flags }, { NM_ACCESS_POINT_WPA_FLAGS, &priv->wpa_flags }, { NM_ACCESS_POINT_RSN_FLAGS, &priv->rsn_flags }, - { NM_ACCESS_POINT_SSID, &priv->ssid, demarshal_ssid }, + { NM_ACCESS_POINT_SSID, &priv->ssid }, { NM_ACCESS_POINT_FREQUENCY, &priv->frequency }, /* The D-Bus property is HwAddress, but the GObject property is "bssid" */ { NM_ACCESS_POINT_HW_ADDRESS, &priv->bssid }, @@ -536,7 +519,7 @@ nm_access_point_class_init (NMAccessPointClass *ap_class) g_object_class_install_property (object_class, PROP_SSID, g_param_spec_boxed (NM_ACCESS_POINT_SSID, "", "", - NM_TYPE_SSID, + G_TYPE_BYTES, G_PARAM_READABLE | G_PARAM_STATIC_STRINGS)); diff --git a/libnm/nm-access-point.h b/libnm/nm-access-point.h index 1792db4428..1062388d09 100644 --- a/libnm/nm-access-point.h +++ b/libnm/nm-access-point.h @@ -71,7 +71,7 @@ GType nm_access_point_get_type (void); NM80211ApFlags nm_access_point_get_flags (NMAccessPoint *ap); NM80211ApSecurityFlags nm_access_point_get_wpa_flags (NMAccessPoint *ap); NM80211ApSecurityFlags nm_access_point_get_rsn_flags (NMAccessPoint *ap); -const GByteArray * nm_access_point_get_ssid (NMAccessPoint *ap); +GBytes * nm_access_point_get_ssid (NMAccessPoint *ap); const char * nm_access_point_get_bssid (NMAccessPoint *ap); guint32 nm_access_point_get_frequency (NMAccessPoint *ap); NM80211Mode nm_access_point_get_mode (NMAccessPoint *ap); diff --git a/libnm/nm-object.c b/libnm/nm-object.c index c48ce1d4ba..842643910b 100644 --- a/libnm/nm-object.c +++ b/libnm/nm-object.c @@ -1147,6 +1147,13 @@ demarshal_generic (NMObject *object, if (*param) g_strfreev (*param); *param = g_value_dup_boxed (value); + } else if (pspec->value_type == G_TYPE_BYTES) { + GBytes **param = (GBytes **)field; + GByteArray *val; + if (*param) + g_bytes_unref (*param); + val = g_value_get_boxed (value); + *param = g_bytes_new (val->data, val->len); HANDLE_TYPE(BOOLEAN, boolean, boolean) HANDLE_TYPE(CHAR, char, schar) HANDLE_TYPE(UCHAR, uchar, uchar) diff --git a/libnm/nm-types-private.h b/libnm/nm-types-private.h index 8626e0d1f6..f95364c7ea 100644 --- a/libnm/nm-types-private.h +++ b/libnm/nm-types-private.h @@ -25,7 +25,6 @@ #include "nm-types.h" #include "nm-object-private.h" -gboolean _nm_ssid_demarshal (GValue *value, GByteArray **dest); gboolean _nm_uint_array_demarshal (GValue *value, GArray **dest); gboolean _nm_object_array_demarshal (GValue *value, GPtrArray **dest, diff --git a/libnm/nm-types.c b/libnm/nm-types.c index 5e482accc5..ad1a6c2f79 100644 --- a/libnm/nm-types.c +++ b/libnm/nm-types.c @@ -28,59 +28,6 @@ #include "nm-dbus-glib-types.h" #include "nm-setting-ip6-config.h" -static gpointer -_nm_ssid_copy (GByteArray *src) -{ - GByteArray *dest; - - dest = g_byte_array_sized_new (src->len); - g_byte_array_append (dest, src->data, src->len); - return dest; -} - -static void -_nm_ssid_free (GByteArray *ssid) -{ - g_byte_array_free (ssid, TRUE); -} - -GType -nm_ssid_get_type (void) -{ - static GType our_type = 0; - - if (our_type == 0) - our_type = g_boxed_type_register_static (g_intern_static_string ("NMSsid"), - (GBoxedCopyFunc) _nm_ssid_copy, - (GBoxedFreeFunc) _nm_ssid_free); - return our_type; -} - -gboolean -_nm_ssid_demarshal (GValue *value, GByteArray **dest) -{ - GByteArray *array; - - if (!G_VALUE_HOLDS (value, DBUS_TYPE_G_UCHAR_ARRAY)) - return FALSE; - - if (*dest) { - g_boxed_free (NM_TYPE_SSID, *dest); - *dest = NULL; - } - - array = (GByteArray *) g_value_get_boxed (value); - if (array && (array->len > 0)) { - *dest = g_byte_array_sized_new (array->len); - (*dest)->len = array->len; - memcpy ((*dest)->data, array->data, array->len); - } - - return TRUE; -} - -/*****************************/ - static gpointer _nm_uint_array_copy (GArray *src) { diff --git a/libnm/nm-types.h b/libnm/nm-types.h index 3a71f879d4..140bc451fd 100644 --- a/libnm/nm-types.h +++ b/libnm/nm-types.h @@ -32,9 +32,6 @@ G_BEGIN_DECLS -#define NM_TYPE_SSID (nm_ssid_get_type ()) -GType nm_ssid_get_type (void) G_GNUC_CONST; - #define NM_TYPE_UINT_ARRAY (nm_uint_array_get_type ()) GType nm_uint_array_get_type (void) G_GNUC_CONST; From 074c2093b6a733c3d5712a7c58386e1e652a8903 Mon Sep 17 00:00:00 2001 From: Dan Winship Date: Tue, 26 Aug 2014 08:31:04 -0400 Subject: [PATCH 4/7] libnm: drop NM_TYPE_OBJECT_ARRAY, use G_TYPE_PTR_ARRAY Use G_TYPE_PTR_ARRAY for GPtrArray-of-NMObject-valued properties, because it has better introspection/bindings support. As with the strdict change in libnm-core, we need to manually copy the array in get_property() implementations, to preserve the standard semantics that get_property() returns a copy, not the internal array. (This patch also changes those properties so that they are always non-NULL until dispose(); previously some of them could be either NULL or 0-length at different times.) --- libnm-core/nm-core-internal.h | 5 +++ libnm-core/nm-utils.c | 20 +++++++++ libnm/libnm.ver | 1 - libnm/nm-active-connection.c | 18 ++++---- libnm/nm-client.c | 54 +++++++++++++---------- libnm/nm-device-bond.c | 16 +++---- libnm/nm-device-bridge.c | 16 +++---- libnm/nm-device-team.c | 16 +++---- libnm/nm-device-wifi.c | 38 +++++++++------- libnm/nm-device-wimax.c | 26 ++++------- libnm/nm-device.c | 19 +++----- libnm/nm-object.c | 8 ++-- libnm/nm-remote-settings.c | 46 ++++++++------------ libnm/nm-types-private.h | 4 -- libnm/nm-types.c | 82 ----------------------------------- libnm/nm-types.h | 3 -- 16 files changed, 148 insertions(+), 224 deletions(-) diff --git a/libnm-core/nm-core-internal.h b/libnm-core/nm-core-internal.h index d5e85e1475..c7f31f1957 100644 --- a/libnm-core/nm-core-internal.h +++ b/libnm-core/nm-core-internal.h @@ -73,4 +73,9 @@ GPtrArray *_nm_utils_copy_slist_to_array (const GSList *list, GSList *_nm_utils_copy_array_to_slist (const GPtrArray *array, NMUtilsCopyFunc copy_func); +GPtrArray *_nm_utils_copy_array (const GPtrArray *array, + NMUtilsCopyFunc copy_func, + GDestroyNotify free_func); +GPtrArray *_nm_utils_copy_object_array (const GPtrArray *array); + #endif diff --git a/libnm-core/nm-utils.c b/libnm-core/nm-utils.c index 06261b0d25..591b1e1d52 100644 --- a/libnm-core/nm-utils.c +++ b/libnm-core/nm-utils.c @@ -626,6 +626,26 @@ _nm_utils_copy_array_to_slist (const GPtrArray *array, return g_slist_reverse (slist); } +GPtrArray * +_nm_utils_copy_array (const GPtrArray *array, + NMUtilsCopyFunc copy_func, + GDestroyNotify free_func) +{ + GPtrArray *copy; + int i; + + copy = g_ptr_array_new_full (array->len, free_func); + for (i = 0; i < array->len; i++) + g_ptr_array_add (copy, copy_func (array->pdata[i])); + return copy; +} + +GPtrArray * +_nm_utils_copy_object_array (const GPtrArray *array) +{ + return _nm_utils_copy_array (array, g_object_ref, g_object_unref); +} + void _nm_utils_bytes_to_dbus (const GValue *prop_value, GValue *dbus_value) diff --git a/libnm/libnm.ver b/libnm/libnm.ver index 948eb058fe..d2dd6b8e4a 100644 --- a/libnm/libnm.ver +++ b/libnm/libnm.ver @@ -337,7 +337,6 @@ global: nm_ip6_route_set_next_hop; nm_ip6_route_set_prefix; nm_ip6_route_unref; - nm_object_array_get_type; nm_object_error_get_type; nm_object_error_quark; nm_object_get_dbus_connection; diff --git a/libnm/nm-active-connection.c b/libnm/nm-active-connection.c index 6491cd2c8b..659b820d82 100644 --- a/libnm/nm-active-connection.c +++ b/libnm/nm-active-connection.c @@ -24,7 +24,7 @@ #include "nm-dbus-interface.h" #include "nm-active-connection.h" #include "nm-object-private.h" -#include "nm-types-private.h" +#include "nm-core-internal.h" #include "nm-device.h" #include "nm-device-private.h" #include "nm-connection.h" @@ -454,11 +454,7 @@ dispose (GObject *object) { NMActiveConnectionPrivate *priv = NM_ACTIVE_CONNECTION_GET_PRIVATE (object); - if (priv->devices) { - g_ptr_array_set_free_func (priv->devices, g_object_unref); - g_ptr_array_free (priv->devices, TRUE); - priv->devices = NULL; - } + g_clear_pointer (&priv->devices, g_ptr_array_unref); g_clear_object (&priv->ip4_config); g_clear_object (&priv->dhcp4_config); @@ -510,7 +506,7 @@ get_property (GObject *object, g_value_set_boxed (value, nm_active_connection_get_specific_object (self)); break; case PROP_DEVICES: - g_value_set_boxed (value, nm_active_connection_get_devices (self)); + g_value_take_boxed (value, _nm_utils_copy_object_array (nm_active_connection_get_devices (self))); break; case PROP_STATE: g_value_set_uint (value, nm_active_connection_get_state (self)); @@ -656,14 +652,16 @@ nm_active_connection_class_init (NMActiveConnectionClass *ap_class) G_PARAM_STATIC_STRINGS)); /** - * NMActiveConnection:device: + * NMActiveConnection:devices: * - * The devices (#NMDevice) of the active connection. + * The devices of the active connection. + * + * Element-type: NMDevice **/ g_object_class_install_property (object_class, PROP_DEVICES, g_param_spec_boxed (NM_ACTIVE_CONNECTION_DEVICES, "", "", - NM_TYPE_OBJECT_ARRAY, + G_TYPE_PTR_ARRAY, G_PARAM_READABLE | G_PARAM_STATIC_STRINGS)); diff --git a/libnm/nm-client.c b/libnm/nm-client.c index c7a61e76cc..fdbaed38b7 100644 --- a/libnm/nm-client.c +++ b/libnm/nm-client.c @@ -27,7 +27,7 @@ #include "nm-device-ethernet.h" #include "nm-device-wifi.h" #include "nm-device-private.h" -#include "nm-types-private.h" +#include "nm-core-internal.h" #include "nm-object-private.h" #include "nm-active-connection.h" #include "nm-vpn-connection.h" @@ -152,7 +152,7 @@ poke_wireless_devices_with_rf_status (NMClient *client) NMClientPrivate *priv = NM_CLIENT_GET_PRIVATE (client); int i; - for (i = 0; priv->devices && (i < priv->devices->len); i++) { + for (i = 0; i < priv->devices->len; i++) { NMDevice *device = g_ptr_array_index (priv->devices, i); if (NM_IS_DEVICE_WIFI (device)) @@ -1243,7 +1243,7 @@ nm_client_get_activating_connection (NMClient *client) /****************************************************************/ static void -free_devices (NMClient *client, gboolean emit_signals) +free_devices (NMClient *client, gboolean in_dispose) { NMClientPrivate *priv = NM_CLIENT_GET_PRIVATE (client); GPtrArray *devices; @@ -1254,18 +1254,23 @@ free_devices (NMClient *client, gboolean emit_signals) return; devices = priv->devices; - priv->devices = NULL; - for (i = 0; i < devices->len; i++) { - device = devices->pdata[i]; - if (emit_signals) + + if (in_dispose) + priv->devices = NULL; + else { + priv->devices = g_ptr_array_new (); + + for (i = 0; i < devices->len; i++) { + device = devices->pdata[i]; g_signal_emit (client, signals[DEVICE_REMOVED], 0, device); - g_object_unref (device); + } } - g_ptr_array_free (devices, TRUE); + + g_ptr_array_unref (devices); } static void -free_active_connections (NMClient *client, gboolean emit_signals) +free_active_connections (NMClient *client, gboolean in_dispose) { NMClientPrivate *priv = NM_CLIENT_GET_PRIVATE (client); GPtrArray *active_connections; @@ -1277,16 +1282,18 @@ free_active_connections (NMClient *client, gboolean emit_signals) active_connections = priv->active_connections; priv->active_connections = NULL; + for (i = 0; i < active_connections->len; i++) { active_connection = active_connections->pdata[i]; /* Break circular refs */ g_object_run_dispose (G_OBJECT (active_connection)); - g_object_unref (active_connection); } - g_ptr_array_free (active_connections, TRUE); + g_ptr_array_unref (active_connections); - if (emit_signals) + if (!in_dispose) { + priv->active_connections = g_ptr_array_new (); g_object_notify (G_OBJECT (client), NM_CLIENT_ACTIVE_CONNECTIONS); + } } static void @@ -1317,8 +1324,8 @@ nm_running_changed_cb (GObject *object, _nm_object_queue_notify (NM_OBJECT (client), NM_CLIENT_NM_RUNNING); _nm_object_suppress_property_updates (NM_OBJECT (client), TRUE); poke_wireless_devices_with_rf_status (client); - free_devices (client, TRUE); - free_active_connections (client, TRUE); + free_devices (client, FALSE); + free_active_connections (client, FALSE); update_permissions (client, NULL); priv->wireless_enabled = FALSE; priv->wireless_hw_enabled = FALSE; @@ -1817,8 +1824,8 @@ dispose (GObject *object) g_clear_object (&priv->client_proxy); - free_devices (client, FALSE); - free_active_connections (client, FALSE); + free_devices (client, TRUE); + free_active_connections (client, TRUE); g_clear_object (&priv->primary_connection); g_clear_object (&priv->activating_connection); @@ -1927,7 +1934,7 @@ get_property (GObject *object, g_value_set_boolean (value, priv->wimax_hw_enabled); break; case PROP_ACTIVE_CONNECTIONS: - g_value_set_boxed (value, nm_client_get_active_connections (self)); + g_value_take_boxed (value, _nm_utils_copy_object_array (nm_client_get_active_connections (self))); break; case PROP_CONNECTIVITY: g_value_set_uint (value, priv->connectivity); @@ -1939,7 +1946,7 @@ get_property (GObject *object, g_value_set_object (value, priv->activating_connection); break; case PROP_DEVICES: - g_value_set_boxed (value, nm_client_get_devices (self)); + g_value_take_boxed (value, _nm_utils_copy_object_array (nm_client_get_devices (self))); break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); @@ -2103,12 +2110,13 @@ nm_client_class_init (NMClientClass *client_class) * NMClient:active-connections: * * The active connections. - * Type: GLib.PtrArray + * + * Element-type: NMActiveConnection **/ g_object_class_install_property (object_class, PROP_ACTIVE_CONNECTIONS, g_param_spec_boxed (NM_CLIENT_ACTIVE_CONNECTIONS, "", "", - NM_TYPE_OBJECT_ARRAY, + G_TYPE_PTR_ARRAY, G_PARAM_READABLE | G_PARAM_STATIC_STRINGS)); @@ -2154,11 +2162,13 @@ nm_client_class_init (NMClientClass *client_class) * NMClient:devices: * * List of known network devices. + * + * Element-type: NMDevice **/ g_object_class_install_property (object_class, PROP_DEVICES, g_param_spec_boxed (NM_CLIENT_DEVICES, "", "", - NM_TYPE_OBJECT_ARRAY, + G_TYPE_PTR_ARRAY, G_PARAM_READABLE | G_PARAM_STATIC_STRINGS)); diff --git a/libnm/nm-device-bond.c b/libnm/nm-device-bond.c index 03eb4161ea..d0a3e94a82 100644 --- a/libnm/nm-device-bond.c +++ b/libnm/nm-device-bond.c @@ -30,7 +30,7 @@ #include "nm-device-bond.h" #include "nm-device-private.h" #include "nm-object-private.h" -#include "nm-types.h" +#include "nm-core-internal.h" G_DEFINE_TYPE (NMDeviceBond, nm_device_bond, NM_TYPE_DEVICE) @@ -204,11 +204,7 @@ dispose (GObject *object) g_clear_object (&priv->proxy); - if (priv->slaves) { - g_ptr_array_set_free_func (priv->slaves, g_object_unref); - g_ptr_array_free (priv->slaves, TRUE); - priv->slaves = NULL; - } + g_clear_pointer (&priv->slaves, g_ptr_array_unref); G_OBJECT_CLASS (nm_device_bond_parent_class)->dispose (object); } @@ -239,7 +235,7 @@ get_property (GObject *object, g_value_set_boolean (value, nm_device_bond_get_carrier (device)); break; case PROP_SLAVES: - g_value_set_boxed (value, nm_device_bond_get_slaves (device)); + g_value_take_boxed (value, _nm_utils_copy_object_array (nm_device_bond_get_slaves (device))); break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); @@ -296,12 +292,14 @@ nm_device_bond_class_init (NMDeviceBondClass *bond_class) /** * NMDeviceBond:slaves: * - * The devices (#NMDevice) slaved to the bond device. + * The devices slaved to the bond device. + * + * Element-type: NMDevice **/ g_object_class_install_property (object_class, PROP_SLAVES, g_param_spec_boxed (NM_DEVICE_BOND_SLAVES, "", "", - NM_TYPE_OBJECT_ARRAY, + G_TYPE_PTR_ARRAY, G_PARAM_READABLE | G_PARAM_STATIC_STRINGS)); } diff --git a/libnm/nm-device-bridge.c b/libnm/nm-device-bridge.c index d25a30a960..1a17196656 100644 --- a/libnm/nm-device-bridge.c +++ b/libnm/nm-device-bridge.c @@ -30,7 +30,7 @@ #include "nm-device-bridge.h" #include "nm-device-private.h" #include "nm-object-private.h" -#include "nm-types.h" +#include "nm-core-internal.h" G_DEFINE_TYPE (NMDeviceBridge, nm_device_bridge, NM_TYPE_DEVICE) @@ -204,11 +204,7 @@ dispose (GObject *object) g_clear_object (&priv->proxy); - if (priv->slaves) { - g_ptr_array_set_free_func (priv->slaves, g_object_unref); - g_ptr_array_free (priv->slaves, TRUE); - priv->slaves = NULL; - } + g_clear_pointer (&priv->slaves, g_ptr_array_unref); G_OBJECT_CLASS (nm_device_bridge_parent_class)->dispose (object); } @@ -239,7 +235,7 @@ get_property (GObject *object, g_value_set_boolean (value, nm_device_bridge_get_carrier (device)); break; case PROP_SLAVES: - g_value_set_boxed (value, nm_device_bridge_get_slaves (device)); + g_value_take_boxed (value, _nm_utils_copy_object_array (nm_device_bridge_get_slaves (device))); break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); @@ -296,12 +292,14 @@ nm_device_bridge_class_init (NMDeviceBridgeClass *bridge_class) /** * NMDeviceBridge:slaves: * - * The devices (#NMDevice) slaved to the bridge device. + * The devices slaved to the bridge device. + * + * Element-type: NMDevice **/ g_object_class_install_property (object_class, PROP_SLAVES, g_param_spec_boxed (NM_DEVICE_BRIDGE_SLAVES, "", "", - NM_TYPE_OBJECT_ARRAY, + G_TYPE_PTR_ARRAY, G_PARAM_READABLE | G_PARAM_STATIC_STRINGS)); } diff --git a/libnm/nm-device-team.c b/libnm/nm-device-team.c index 0a6fed379a..0aeda17039 100644 --- a/libnm/nm-device-team.c +++ b/libnm/nm-device-team.c @@ -30,7 +30,7 @@ #include "nm-device-team.h" #include "nm-device-private.h" #include "nm-object-private.h" -#include "nm-types.h" +#include "nm-core-internal.h" G_DEFINE_TYPE (NMDeviceTeam, nm_device_team, NM_TYPE_DEVICE) @@ -204,11 +204,7 @@ dispose (GObject *object) g_clear_object (&priv->proxy); - if (priv->slaves) { - g_ptr_array_set_free_func (priv->slaves, g_object_unref); - g_ptr_array_free (priv->slaves, TRUE); - priv->slaves = NULL; - } + g_clear_pointer (&priv->slaves, g_ptr_array_unref); G_OBJECT_CLASS (nm_device_team_parent_class)->dispose (object); } @@ -239,7 +235,7 @@ get_property (GObject *object, g_value_set_boolean (value, nm_device_team_get_carrier (device)); break; case PROP_SLAVES: - g_value_set_boxed (value, nm_device_team_get_slaves (device)); + g_value_take_boxed (value, _nm_utils_copy_object_array (nm_device_team_get_slaves (device))); break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); @@ -296,12 +292,14 @@ nm_device_team_class_init (NMDeviceTeamClass *team_class) /** * NMDeviceTeam:slaves: * - * The devices (#NMDevice) enslaved to the team device. + * The devices enslaved to the team device. + * + * Element-type: NMDevice **/ g_object_class_install_property (object_class, PROP_SLAVES, g_param_spec_boxed (NM_DEVICE_TEAM_SLAVES, "", "", - NM_TYPE_OBJECT_ARRAY, + G_TYPE_PTR_ARRAY, G_PARAM_READABLE | G_PARAM_STATIC_STRINGS)); } diff --git a/libnm/nm-device-wifi.c b/libnm/nm-device-wifi.c index f06232c374..6a41ccc218 100644 --- a/libnm/nm-device-wifi.c +++ b/libnm/nm-device-wifi.c @@ -34,7 +34,7 @@ #include "nm-object-private.h" #include "nm-object-cache.h" #include "nm-dbus-glib-types.h" -#include "nm-types-private.h" +#include "nm-core-internal.h" G_DEFINE_TYPE (NMDeviceWifi, nm_device_wifi, NM_TYPE_DEVICE) @@ -348,9 +348,11 @@ nm_device_wifi_request_scan_simple (NMDeviceWifi *device, } static void -clean_up_aps (NMDeviceWifi *self, gboolean notify) +clean_up_aps (NMDeviceWifi *self, gboolean in_dispose) { NMDeviceWifiPrivate *priv; + GPtrArray *aps; + int i; g_return_if_fail (NM_IS_DEVICE_WIFI (self)); @@ -361,18 +363,21 @@ clean_up_aps (NMDeviceWifi *self, gboolean notify) priv->active_ap = NULL; } - if (priv->aps) { - while (priv->aps->len) { - NMAccessPoint *ap = NM_ACCESS_POINT (g_ptr_array_index (priv->aps, 0)); + aps = priv->aps; - if (notify) - g_signal_emit (self, signals[ACCESS_POINT_REMOVED], 0, ap); - g_ptr_array_remove (priv->aps, ap); - g_object_unref (ap); - } - g_ptr_array_free (priv->aps, TRUE); + if (in_dispose) priv->aps = NULL; + else { + priv->aps = g_ptr_array_new (); + + for (i = 0; i < aps->len; i++) { + NMAccessPoint *ap = NM_ACCESS_POINT (g_ptr_array_index (aps, i)); + + g_signal_emit (self, signals[ACCESS_POINT_REMOVED], 0, ap); + } } + + g_ptr_array_unref (aps); } /** @@ -389,7 +394,7 @@ _nm_device_wifi_set_wireless_enabled (NMDeviceWifi *device, g_return_if_fail (NM_IS_DEVICE_WIFI (device)); if (!enabled) - clean_up_aps (device, TRUE); + clean_up_aps (device, FALSE); } #define WPA_CAPS (NM_WIFI_DEVICE_CAP_CIPHER_TKIP | \ @@ -538,7 +543,7 @@ get_property (GObject *object, g_value_set_uint (value, nm_device_wifi_get_capabilities (self)); break; case PROP_ACCESS_POINTS: - g_value_set_boxed (value, nm_device_wifi_get_access_points (self)); + g_value_take_boxed (value, _nm_utils_copy_object_array (nm_device_wifi_get_access_points (self))); break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); @@ -631,7 +636,8 @@ dispose (GObject *object) priv->scan_call = NULL; } - clean_up_aps (NM_DEVICE_WIFI (object), FALSE); + if (priv->aps) + clean_up_aps (NM_DEVICE_WIFI (object), TRUE); g_clear_object (&priv->proxy); G_OBJECT_CLASS (nm_device_wifi_parent_class)->dispose (object); @@ -748,11 +754,13 @@ nm_device_wifi_class_init (NMDeviceWifiClass *wifi_class) * NMDeviceWifi:access-points: * * List of all Wi-Fi access points the device can see. + * + * Element-type: NMAccessPoint **/ g_object_class_install_property (object_class, PROP_ACCESS_POINTS, g_param_spec_boxed (NM_DEVICE_WIFI_ACCESS_POINTS, "", "", - NM_TYPE_OBJECT_ARRAY, + G_TYPE_PTR_ARRAY, G_PARAM_READABLE | G_PARAM_STATIC_STRINGS)); diff --git a/libnm/nm-device-wimax.c b/libnm/nm-device-wimax.c index 72b25c2b6d..5f190ea3f0 100644 --- a/libnm/nm-device-wimax.c +++ b/libnm/nm-device-wimax.c @@ -32,7 +32,7 @@ #include "nm-object-private.h" #include "nm-object-cache.h" #include "nm-dbus-glib-types.h" -#include "nm-types-private.h" +#include "nm-core-internal.h" #include "nm-device-private.h" G_DEFINE_TYPE (NMDeviceWimax, nm_device_wimax, NM_TYPE_DEVICE) @@ -200,7 +200,7 @@ nm_device_wimax_get_nsp_by_path (NMDeviceWimax *wimax, } static void -clean_up_nsps (NMDeviceWimax *self, gboolean notify) +clean_up_nsps (NMDeviceWimax *self) { NMDeviceWimaxPrivate *priv; @@ -213,18 +213,7 @@ clean_up_nsps (NMDeviceWimax *self, gboolean notify) priv->active_nsp = NULL; } - if (priv->nsps) { - while (priv->nsps->len) { - NMWimaxNsp *nsp = NM_WIMAX_NSP (g_ptr_array_index (priv->nsps, 0)); - - if (notify) - g_signal_emit (self, signals[NSP_REMOVED], 0, nsp); - g_ptr_array_remove (priv->nsps, nsp); - g_object_unref (nsp); - } - g_ptr_array_free (priv->nsps, TRUE); - priv->nsps = NULL; - } + g_clear_pointer (&priv->nsps, g_ptr_array_unref); } /** @@ -416,7 +405,7 @@ get_property (GObject *object, g_value_set_string (value, nm_device_wimax_get_bsid (self)); break; case PROP_NSPS: - g_value_set_boxed (value, nm_device_wimax_get_nsps (self)); + g_value_take_boxed (value, _nm_utils_copy_object_array (nm_device_wimax_get_nsps (self))); break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); @@ -539,7 +528,8 @@ dispose (GObject *object) priv->bsid = NULL; } - clean_up_nsps (NM_DEVICE_WIMAX (object), FALSE); + if (priv->nsps) + clean_up_nsps (NM_DEVICE_WIMAX (object)); g_clear_object (&priv->proxy); G_OBJECT_CLASS (nm_device_wimax_parent_class)->dispose (object); @@ -666,11 +656,13 @@ nm_device_wimax_class_init (NMDeviceWimaxClass *wimax_class) * NMDeviceWimax:nsps: * * List of all WiMAX Network Service Providers the device can see. + * + * Element-type: NMWimaxNsp **/ g_object_class_install_property (object_class, PROP_NSPS, g_param_spec_boxed (NM_DEVICE_WIMAX_NSPS, "", "", - NM_TYPE_OBJECT_ARRAY, + G_TYPE_PTR_ARRAY, G_PARAM_READABLE | G_PARAM_STATIC_STRINGS)); diff --git a/libnm/nm-device.c b/libnm/nm-device.c index 88d8514f4e..3e67f09472 100644 --- a/libnm/nm-device.c +++ b/libnm/nm-device.c @@ -43,7 +43,7 @@ #include "nm-object-private.h" #include "nm-object-cache.h" #include "nm-remote-connection.h" -#include "nm-types.h" +#include "nm-core-internal.h" #include "nm-dbus-glib-types.h" #include "nm-glib-compat.h" #include "nm-utils.h" @@ -375,14 +375,7 @@ dispose (GObject *object) g_clear_object (&priv->client); g_clear_object (&priv->active_connection); - if (priv->available_connections) { - int i; - - for (i = 0; i < priv->available_connections->len; i++) - g_object_unref (priv->available_connections->pdata[i]); - g_ptr_array_free (priv->available_connections, TRUE); - priv->available_connections = NULL; - } + g_clear_pointer (&priv->available_connections, g_ptr_array_unref); G_OBJECT_CLASS (nm_device_parent_class)->dispose (object); } @@ -474,7 +467,7 @@ get_property (GObject *object, g_value_set_object (value, nm_device_get_active_connection (device)); break; case PROP_AVAILABLE_CONNECTIONS: - g_value_set_boxed (value, nm_device_get_available_connections (device)); + g_value_take_boxed (value, _nm_utils_copy_object_array (nm_device_get_available_connections (device))); break; case PROP_PRODUCT: g_value_set_string (value, nm_device_get_product (device)); @@ -766,12 +759,14 @@ nm_device_class_init (NMDeviceClass *device_class) /** * NMDevice:available-connections: * - * The available connections (#NMRemoteConnection) of the device + * The available connections of the device + * + * Element-type: NMRemoteConnection **/ g_object_class_install_property (object_class, PROP_AVAILABLE_CONNECTIONS, g_param_spec_boxed (NM_DEVICE_AVAILABLE_CONNECTIONS, "", "", - NM_TYPE_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 842643910b..4b08d95f9b 100644 --- a/libnm/nm-object.c +++ b/libnm/nm-object.c @@ -806,7 +806,7 @@ object_property_complete (ObjectCreatedData *odata) int i; /* Build up new array */ - new = g_ptr_array_sized_new (odata->length); + new = g_ptr_array_new_full (odata->length, g_object_unref); for (i = 0; i < odata->length; i++) add_to_object_array_unique (new, odata->objects[i]); @@ -843,8 +843,8 @@ object_property_complete (ObjectCreatedData *odata) } different = removed->len || added->len; - g_ptr_array_free (added, TRUE); - g_ptr_array_free (removed, TRUE); + g_ptr_array_unref (added); + g_ptr_array_unref (removed); } else { /* No added/removed signals to send, just replace the property with * the new values. @@ -857,7 +857,7 @@ object_property_complete (ObjectCreatedData *odata) * any objects in the 'removed' array. */ if (old) - g_boxed_free (NM_TYPE_OBJECT_ARRAY, old); + g_ptr_array_unref (old); } else { GObject **obj_p = pi->field; diff --git a/libnm/nm-remote-settings.c b/libnm/nm-remote-settings.c index 3a5810d35e..8c570f2062 100644 --- a/libnm/nm-remote-settings.c +++ b/libnm/nm-remote-settings.c @@ -30,7 +30,7 @@ #include "nm-dbus-helpers-private.h" #include "nm-glib-compat.h" #include "nm-object-private.h" -#include "nm-types.h" +#include "nm-core-internal.h" /** * SECTION:nm-remote-settings @@ -333,12 +333,10 @@ connection_removed (NMRemoteSettings *self, int i; /* Check if the connection was actually removed or if it just turned invisible. */ - if (priv->all_connections) { - for (i = 0; i < priv->all_connections->len; i++) { - if (remote == priv->all_connections->pdata[i]) { - still_exists = TRUE; - break; - } + for (i = 0; i < priv->all_connections->len; i++) { + if (remote == priv->all_connections->pdata[i]) { + still_exists = TRUE; + break; } } @@ -743,19 +741,15 @@ nm_running_changed (GObject *object, g_object_freeze_notify (object); if (!_nm_object_get_nm_running (NM_OBJECT (self))) { - if (priv->all_connections) { - GPtrArray *connections; - int i; + GPtrArray *connections; + int i; - connections = priv->all_connections; - priv->all_connections = NULL; - - for (i = 0; i < connections->len; i++) { - g_signal_emit (self, signals[CONNECTION_REMOVED], 0, connections->pdata[i]); - g_object_unref (connections->pdata[i]); - } - g_ptr_array_unref (connections); - } + /* Clear connections */ + connections = priv->all_connections; + priv->all_connections = g_ptr_array_new (); + for (i = 0; i < connections->len; i++) + g_signal_emit (self, signals[CONNECTION_REMOVED], 0, connections->pdata[i]); + g_ptr_array_unref (connections); /* Clear properties */ if (priv->hostname) { @@ -912,19 +906,17 @@ dispose (GObject *object) { NMRemoteSettings *self = NM_REMOTE_SETTINGS (object); NMRemoteSettingsPrivate *priv = NM_REMOTE_SETTINGS_GET_PRIVATE (self); + int i; while (g_slist_length (priv->add_list)) add_connection_info_dispose (self, (AddConnectionInfo *) priv->add_list->data); if (priv->all_connections) { - int i; - - for (i = 0; i < priv->all_connections->len; i++) { + for (i = 0; i < priv->all_connections->len; i++) cleanup_connection (self, priv->all_connections->pdata[i]); - g_object_unref (priv->all_connections->pdata[i]); - } g_clear_pointer (&priv->all_connections, g_ptr_array_unref); } + g_clear_pointer (&priv->visible_connections, g_ptr_array_unref); g_clear_pointer (&priv->hostname, g_free); g_clear_object (&priv->proxy); @@ -943,7 +935,7 @@ get_property (GObject *object, guint prop_id, g_value_set_boolean (value, _nm_object_get_nm_running (NM_OBJECT (object))); break; case PROP_CONNECTIONS: - g_value_set_boxed (value, priv->visible_connections); + g_value_take_boxed (value, _nm_utils_copy_object_array (priv->visible_connections)); break; case PROP_HOSTNAME: g_value_set_string (value, priv->hostname); @@ -998,12 +990,12 @@ nm_remote_settings_class_init (NMRemoteSettingsClass *class) * contain the object paths of connections that the user does not have * permission to read the details of.) * - * Type: GPtrArray + * Element-type: NMRemoteConnection */ g_object_class_install_property (object_class, PROP_CONNECTIONS, g_param_spec_boxed (NM_REMOTE_SETTINGS_CONNECTIONS, "", "", - NM_TYPE_OBJECT_ARRAY, + G_TYPE_PTR_ARRAY, G_PARAM_READABLE | G_PARAM_STATIC_STRINGS)); diff --git a/libnm/nm-types-private.h b/libnm/nm-types-private.h index f95364c7ea..72c41b6920 100644 --- a/libnm/nm-types-private.h +++ b/libnm/nm-types-private.h @@ -26,10 +26,6 @@ #include "nm-object-private.h" gboolean _nm_uint_array_demarshal (GValue *value, GArray **dest); -gboolean _nm_object_array_demarshal (GValue *value, - GPtrArray **dest, - DBusGConnection *connection, - NMObjectCreatorFunc func); 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 index ad1a6c2f79..6ca32b3b24 100644 --- a/libnm/nm-types.c +++ b/libnm/nm-types.c @@ -80,88 +80,6 @@ _nm_uint_array_demarshal (GValue *value, GArray **dest) /*****************************/ -static gpointer -_nm_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, g_object_ref (g_ptr_array_index (src, i))); - return dest; -} - -static void -_nm_object_array_free (GPtrArray *array) -{ - int i; - - for (i = 0; i < array->len; i++) - g_object_unref (g_ptr_array_index (array, i)); - g_ptr_array_free (array, TRUE); -} - -GType -nm_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 ("NMObjectArray"), - (GBoxedCopyFunc) _nm_object_array_copy, - (GBoxedFreeFunc) _nm_object_array_free); - return our_type; -} - -gboolean -_nm_object_array_demarshal (GValue *value, - GPtrArray **dest, - DBusGConnection *connection, - NMObjectCreatorFunc func) -{ - GPtrArray *temp = NULL; - GPtrArray *array; - - if (!G_VALUE_HOLDS (value, DBUS_TYPE_G_ARRAY_OF_OBJECT_PATH)) - return FALSE; - - array = (GPtrArray *) g_value_get_boxed (value); - if (array && array->len) { - int i; - - temp = g_ptr_array_sized_new (array->len); - for (i = 0; i < array->len; i++) { - const char *path; - GObject *object; - - path = g_ptr_array_index (array, i); - object = G_OBJECT (_nm_object_cache_get (path)); - if (object) - g_ptr_array_add (temp, object); - else { - object = (*func) (connection, path); - if (object) - g_ptr_array_add (temp, object); - else - g_warning ("%s: couldn't create object for %s", __func__, path); - } - } - } else - temp = g_ptr_array_new (); - - /* Deallocate after to ensure that an object that might already - * be in the array doesn't get destroyed due to refcounting. - */ - if (*dest) - g_boxed_free (NM_TYPE_OBJECT_ARRAY, *dest); - *dest = temp; - - return TRUE; -} - -/*****************************/ - static gpointer _nm_ip6_address_object_array_copy (GPtrArray *src) { diff --git a/libnm/nm-types.h b/libnm/nm-types.h index 140bc451fd..c55edf82be 100644 --- a/libnm/nm-types.h +++ b/libnm/nm-types.h @@ -35,9 +35,6 @@ G_BEGIN_DECLS #define NM_TYPE_UINT_ARRAY (nm_uint_array_get_type ()) GType nm_uint_array_get_type (void) G_GNUC_CONST; -#define NM_TYPE_OBJECT_ARRAY (nm_object_array_get_type ()) -GType nm_object_array_get_type (void) G_GNUC_CONST; - #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; From 3e5b3833aa4964f6d2224560f3ad8c7ffa1e8027 Mon Sep 17 00:00:00 2001 From: Dan Winship Date: Mon, 25 Aug 2014 10:33:53 -0400 Subject: [PATCH 5/7] libnm: change empty-GPtrArray-return semantics libnm functions that return GPtrArrays of objects had a rule that if the array was empty, they would return NULL rather than a 0-length array. As it turns out, this is just a nuisance to clients, since in most places the code for the non-empty case would end up doing the right thing for the empty case as well (and where it doesn't, we can check "array->len == 0" just as easily as "array == NULL"). So just return the 0-length array instead. --- clients/cli/connections.c | 28 +++++++------- clients/cli/devices.c | 45 ++++++++++------------- clients/tui/nmt-connect-connection-list.c | 14 +++---- clients/tui/nmt-device-entry.c | 6 --- examples/C/glib/get-ap-info-libnm.c | 4 +- libnm/nm-active-connection.c | 2 +- libnm/nm-client.c | 6 +-- libnm/nm-device-bond.c | 2 +- libnm/nm-device-bridge.c | 2 +- libnm/nm-device-team.c | 2 +- libnm/nm-device-wifi.c | 2 +- libnm/nm-device-wimax.c | 2 +- libnm/nm-device.c | 2 +- libnm/nm-object-private.h | 9 ----- libnm/tests/test-nm-client.c | 6 +-- 15 files changed, 55 insertions(+), 77 deletions(-) diff --git a/clients/cli/connections.c b/clients/cli/connections.c index 74279bec1c..e3a8e182a8 100644 --- a/clients/cli/connections.c +++ b/clients/cli/connections.c @@ -585,7 +585,7 @@ get_ac_device_string (NMActiveConnection *active) /* Get devices of the active connection */ dev_str = g_string_new (NULL); devices = nm_active_connection_get_devices (active); - for (i = 0; devices && (i < devices->len); i++) { + for (i = 0; i < devices->len; i++) { NMDevice *device = g_ptr_array_index (devices, i); const char *dev_iface = nm_device_get_iface (device); @@ -609,7 +609,7 @@ get_ac_for_connection (const GPtrArray *active_cons, NMConnection *connection) /* Is the connection active? */ con_path = nm_connection_get_path (connection); - for (i = 0; active_cons && i < active_cons->len; i++) { + for (i = 0; i < active_cons->len; i++) { NMActiveConnection *candidate = g_ptr_array_index (active_cons, i); if (!g_strcmp0 (nm_active_connection_get_connection (candidate), con_path)) { @@ -719,7 +719,7 @@ find_active_connection (const GPtrArray *active_cons, NMConnection *con; NMActiveConnection *found = NULL; - for (i = start; active_cons && (i < active_cons->len); i++) { + for (i = start; i < active_cons->len; i++) { NMActiveConnection *candidate = g_ptr_array_index (active_cons, i); path = nm_active_connection_get_connection (candidate); @@ -840,7 +840,7 @@ fill_output_active_connection (NMActiveConnection *active, /* Get devices of the active connection */ dev_str = g_string_new (NULL); devices = nm_active_connection_get_devices (active); - for (i = 0; devices && (i < devices->len); i++) { + for (i = 0; i < devices->len; i++) { NMDevice *device = g_ptr_array_index (devices, i); const char *dev_iface = nm_device_get_iface (device); @@ -1445,12 +1445,12 @@ get_default_active_connection (NmCli *nmc, NMDevice **device) g_return_val_if_fail (*device == NULL, NULL); connections = nm_client_get_active_connections (nmc->client); - for (i = 0; connections && (i < connections->len); i++) { + for (i = 0; i < connections->len; i++) { NMActiveConnection *candidate = g_ptr_array_index (connections, i); const GPtrArray *devices; devices = nm_active_connection_get_devices (candidate); - if (!devices || !devices->len) + if (!devices->len) continue; if (nm_active_connection_get_default (candidate)) { @@ -1536,7 +1536,7 @@ find_device_for_connection (NmCli *nmc, NMDevice *found_device = NULL; const GPtrArray *devices = nm_client_get_devices (nmc->client); - for (i = 0; devices && (i < devices->len) && !found_device; i++) { + for (i = 0; i < devices->len && !found_device; i++) { NMDevice *dev = g_ptr_array_index (devices, i); if (iface) { @@ -1556,7 +1556,7 @@ find_device_for_connection (NmCli *nmc, const GPtrArray *aps = nm_device_wifi_get_access_points (NM_DEVICE_WIFI (dev)); found_device = NULL; /* Mark as not found; set to the device again later, only if AP matches */ - for (j = 0; aps && (j < aps->len); j++) { + for (j = 0; j < aps->len; j++) { NMAccessPoint *candidate_ap = g_ptr_array_index (aps, j); const char *candidate_bssid = nm_access_point_get_bssid (candidate_ap); @@ -1577,7 +1577,7 @@ find_device_for_connection (NmCli *nmc, const GPtrArray *nsps = nm_device_wimax_get_nsps (NM_DEVICE_WIMAX (dev)); found_device = NULL; /* Mark as not found; set to the device again later, only if NSP matches */ - for (j = 0; nsps && (j < nsps->len); j++) { + for (j = 0; j < nsps->len; j++) { NMWimaxNsp *candidate_nsp = g_ptr_array_index (nsps, j); const char *candidate_name = nm_wimax_nsp_get_name (candidate_nsp); @@ -1699,7 +1699,7 @@ active_connection_state_cb (NMActiveConnection *active, GParamSpec *pspec, gpoin NMDevice *device; devices = nm_active_connection_get_devices (active); - device = devices && devices->len ? g_ptr_array_index (devices, 0) : NULL; + device = devices->len ? g_ptr_array_index (devices, 0) : NULL; if ( device && ( NM_IS_DEVICE_BOND (device) || NM_IS_DEVICE_TEAM (device) @@ -1820,7 +1820,7 @@ activate_connection_cb (NMClient *client, NMActiveConnection *active, GError *er if (!device) { /* device could be NULL for virtual devices. Fill it here. */ ac_devs = nm_active_connection_get_devices (active); - info->device = device = ac_devs && ac_devs->len > 0 ? g_ptr_array_index (ac_devs, 0) : NULL; + info->device = device = ac_devs->len > 0 ? g_ptr_array_index (ac_devs, 0) : NULL; } if (nmc->nowait_flag || state == NM_ACTIVE_CONNECTION_STATE_ACTIVATED) { @@ -5487,7 +5487,7 @@ gen_compat_devices (const char *text, int state) char *ret; devices = nm_client_get_devices (nmc_tab_completion.nmc->client); - if (!devices || devices->len < 1) + if (devices->len == 0) return NULL; compatible_devices = g_new (const char *, devices->len + 1); @@ -6402,7 +6402,7 @@ activate_connection_editor_cb (NMClient *client, if (!error) { if (!device) { ac_devs = nm_active_connection_get_devices (active); - device = ac_devs && ac_devs->len > 0 ? g_ptr_array_index (ac_devs, 0) : NULL; + device = ac_devs->len > 0 ? g_ptr_array_index (ac_devs, 0) : NULL; } if (device) { monitor_ac_info = g_malloc0 (sizeof (AddConnectionInfo)); @@ -7608,7 +7608,7 @@ get_ethernet_device_name (NmCli *nmc) nmc->get_client (nmc); devices = nm_client_get_devices (nmc->client); - for (i = 0; devices && (i < devices->len); i++) { + for (i = 0; i < devices->len; i++) { NMDevice *dev = g_ptr_array_index (devices, i); if (NM_IS_DEVICE_ETHERNET (dev)) return nm_device_get_iface (dev); diff --git a/clients/cli/devices.c b/clients/cli/devices.c index da7fa178f2..705838de4d 100644 --- a/clients/cli/devices.c +++ b/clients/cli/devices.c @@ -420,11 +420,6 @@ get_devices_sorted (NMClient *client) NMDevice **sorted; devs = nm_client_get_devices (client); - if (!devs) { - sorted = g_new (NMDevice *, 1); - sorted[0] = NULL; - return sorted; - } sorted = g_new (NMDevice *, devs->len + 1); memcpy (sorted, devs->pdata, devs->len * sizeof (NMDevice *)); @@ -680,7 +675,7 @@ get_active_connection_id (NMDevice *device) ac_uuid = nm_active_connection_get_uuid (ac); avail_cons = nm_device_get_available_connections (device); - for (i = 0; avail_cons && (i < avail_cons->len); i++) { + for (i = 0; i < avail_cons->len; i++) { NMRemoteConnection *candidate = g_ptr_array_index (avail_cons, i); const char *test_uuid = nm_connection_get_uuid (NM_CONNECTION (candidate)); @@ -886,8 +881,7 @@ show_device_info (NMDevice *device, NmCli *nmc) info->active_bssid = active_bssid; info->device = nm_device_get_iface (device); aps = nm_device_wifi_get_access_points (NM_DEVICE_WIFI (device)); - if (aps && aps->len) - g_ptr_array_foreach ((GPtrArray *) aps, fill_output_access_point, (gpointer) info); + g_ptr_array_foreach ((GPtrArray *) aps, fill_output_access_point, (gpointer) info); g_free (info); print_data (nmc); /* Print all data */ was_output = TRUE; @@ -974,7 +968,7 @@ show_device_info (NMDevice *device, NmCli *nmc) g_ptr_array_add (nmc->output_data, arr); nsps = nm_device_wimax_get_nsps (NM_DEVICE_WIMAX (device)); - for (g = 0; nsps && g < nsps->len; g++) { + for (g = 0; g < nsps->len; g++) { NMWimaxNsp *nsp = g_ptr_array_index (nsps, g); fill_output_wimax_nsp (nsp, nmc, device, idx++, NMC_OF_FLAG_SECTION_PREFIX); @@ -1016,7 +1010,7 @@ show_device_info (NMDevice *device, NmCli *nmc) bond_slaves_str = g_string_new (NULL); slaves = nm_device_bond_get_slaves (NM_DEVICE_BOND (device)); - for (idx = 0; slaves && idx < slaves->len; idx++) { + for (idx = 0; idx < slaves->len; idx++) { NMDevice *slave = g_ptr_array_index (slaves, idx); const char *iface = nm_device_get_iface (slave); @@ -1087,11 +1081,11 @@ show_device_info (NMDevice *device, NmCli *nmc) /* available-connections */ avail_cons = nm_device_get_available_connections (device); ac_paths_str = g_string_new (NULL); - if (avail_cons && avail_cons->len) { + if (avail_cons->len) { ac_arr = g_new (char *, avail_cons->len + 1); ac_arr[avail_cons->len] = NULL; } - for (i = 0; avail_cons && (i < avail_cons->len); i++) { + for (i = 0; i < avail_cons->len; i++) { NMRemoteConnection *avail_con = g_ptr_array_index (avail_cons, i); const char *ac_path = nm_connection_get_path (NM_CONNECTION (avail_con)); const char *ac_id = nm_connection_get_id (NM_CONNECTION (avail_con)); @@ -1335,7 +1329,7 @@ connect_device_cb (NMClient *client, NMActiveConnection *active, GError *error, } else { g_assert (active); devices = nm_active_connection_get_devices (active); - if (!devices || devices->len == 0) { + if (devices->len == 0) { g_string_printf (nmc->return_text, _("Error: Device activation failed: device was disconnected")); nmc->return_value = NMC_RESULT_ERROR_CON_ACTIVATION; quit (); @@ -1699,8 +1693,7 @@ show_access_point_info (NMDevice *device, NmCli *nmc) info->active_bssid = active_bssid; info->device = nm_device_get_iface (device); aps = nm_device_wifi_get_access_points (NM_DEVICE_WIFI (device)); - if (aps && aps->len) - g_ptr_array_foreach ((GPtrArray *) aps, fill_output_access_point, (gpointer) info); + g_ptr_array_foreach ((GPtrArray *) aps, fill_output_access_point, (gpointer) info); print_data (nmc); /* Print all data */ nmc_empty_output_fields (nmc); @@ -1804,7 +1797,7 @@ do_device_wifi_list (NmCli *nmc, int argc, char **argv) if (bssid_user) { /* Specific AP requested - list only that */ aps = nm_device_wifi_get_access_points (NM_DEVICE_WIFI (device)); - for (j = 0; aps && (j < aps->len); j++) { + for (j = 0; j < aps->len; j++) { char *bssid_up; NMAccessPoint *candidate_ap = g_ptr_array_index (aps, j); const char *candidate_bssid = nm_access_point_get_bssid (candidate_ap); @@ -1863,7 +1856,7 @@ do_device_wifi_list (NmCli *nmc, int argc, char **argv) g_ptr_array_add (nmc->output_data, arr); aps = nm_device_wifi_get_access_points (NM_DEVICE_WIFI (dev)); - for (j = 0; aps && (j < aps->len); j++) { + for (j = 0; j < aps->len; j++) { char *bssid_up; NMAccessPoint *candidate_ap = g_ptr_array_index (aps, j); const char *candidate_bssid = nm_access_point_get_bssid (candidate_ap); @@ -2010,7 +2003,7 @@ find_wifi_device_by_iface (const GPtrArray *devices, const char *iface, int *idx NMDevice *device = NULL; int i; - for (i = *idx; devices && (i < devices->len); i++) { + for (i = *idx; i < devices->len; i++) { NMDevice *candidate = g_ptr_array_index (devices, i); const char *dev_iface = nm_device_get_iface (candidate); @@ -2049,7 +2042,7 @@ find_ap_on_device (NMDevice *device, GByteArray *bssid, const char *ssid) g_return_val_if_fail ((bssid && !ssid) || (!bssid && ssid), NULL); aps = nm_device_wifi_get_access_points (NM_DEVICE_WIFI (device)); - for (i = 0; aps && (i < aps->len); i++) { + for (i = 0; i < aps->len; i++) { NMAccessPoint *candidate_ap = g_ptr_array_index (aps, i); if (ssid) { @@ -2457,7 +2450,7 @@ show_nsp_info (NMDevice *device, NmCli *nmc) g_ptr_array_add (nmc->output_data, arr); nsps = nm_device_wimax_get_nsps (NM_DEVICE_WIMAX (device)); - for (i = 0; nsps && i < nsps->len; i++) { + for (i = 0; i < nsps->len; i++) { NMWimaxNsp *nsp = g_ptr_array_index (nsps, i); fill_output_wimax_nsp (nsp, nmc, device, idx++, 0); @@ -2539,7 +2532,7 @@ do_device_wimax_list (NmCli *nmc, int argc, char **argv) devices = nm_client_get_devices (nmc->client); if (ifname) { /* Device specified - list only NSPs of this interface */ - for (i = 0; devices && (i < devices->len); i++) { + for (i = 0; i < devices->len; i++) { NMDevice *candidate = g_ptr_array_index (devices, i); const char *dev_iface = nm_device_get_iface (candidate); @@ -2562,7 +2555,7 @@ do_device_wimax_list (NmCli *nmc, int argc, char **argv) if (nsp_user) { /* Specific NSP requested - list only that */ nsps = nm_device_wimax_get_nsps (NM_DEVICE_WIMAX (device)); - for (j = 0, nsp = NULL; nsps && (j < nsps->len); j++) { + for (j = 0, nsp = NULL; j < nsps->len; j++) { NMWimaxNsp *candidate_nsp = g_ptr_array_index (nsps, j); const char *candidate_name = nm_wimax_nsp_get_name (candidate_nsp); char *nsp_up; @@ -2596,7 +2589,7 @@ do_device_wimax_list (NmCli *nmc, int argc, char **argv) /* List NSPs for all devices */ if (nsp_user) { /* Specific NSP requested - list only that */ - for (i = 0; devices && (i < devices->len); i++) { + for (i = 0; i < devices->len; i++) { NMDevice *dev = g_ptr_array_index (devices, i); int idx = 1; @@ -2611,7 +2604,7 @@ do_device_wimax_list (NmCli *nmc, int argc, char **argv) g_ptr_array_add (nmc->output_data, arr); nsps = nm_device_wimax_get_nsps (NM_DEVICE_WIMAX (dev)); - for (j = 0, nsp = NULL; nsps && (j < nsps->len); j++) { + for (j = 0, nsp = NULL; j < nsps->len; j++) { NMWimaxNsp *candidate_nsp = g_ptr_array_index (nsps, j); const char *candidate_name = nm_wimax_nsp_get_name (candidate_nsp); char *nsp_up; @@ -2635,7 +2628,7 @@ do_device_wimax_list (NmCli *nmc, int argc, char **argv) goto error; } } else { - for (i = 0; devices && (i < devices->len); i++) { + for (i = 0; i < devices->len; i++) { NMDevice *dev = g_ptr_array_index (devices, i); /* Main header name */ @@ -2704,7 +2697,7 @@ gen_func_ifnames (const char *text, int state) nm_cli.get_client (&nm_cli); devices = nm_client_get_devices (nm_cli.client); - if (!devices || devices->len < 1) + if (devices->len == 0) return NULL; ifnames = g_new (const char *, devices->len + 1); diff --git a/clients/tui/nmt-connect-connection-list.c b/clients/tui/nmt-connect-connection-list.c index 2f98fb7ef1..f3b02e99a7 100644 --- a/clients/tui/nmt-connect-connection-list.c +++ b/clients/tui/nmt-connect-connection-list.c @@ -272,7 +272,7 @@ add_connections_for_aps (NmtConnectDevice *nmtdev, int i; aps = nm_device_wifi_get_access_points (NM_DEVICE_WIFI (nmtdev->device)); - if (!aps) + if (!aps->len) return; seen_ssids = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, NULL); @@ -450,7 +450,7 @@ connection_find_ac (NMConnection *conn, int i; path = nm_connection_get_path (conn); - for (i = 0; acs && i < acs->len; i++) { + for (i = 0; i < acs->len; i++) { ac = acs->pdata[i]; ac_path = nm_active_connection_get_connection (ac); @@ -484,11 +484,11 @@ nmt_connect_connection_list_rebuild (NmtConnectConnectionList *list) connections = nm_remote_settings_list_connections (nm_settings); nmt_devices = NULL; - if (devices) { - names = nm_device_disambiguate_names ((NMDevice **) devices->pdata, devices->len); - nmt_devices = append_nmt_devices_for_devices (nmt_devices, devices, names, connections); - g_strfreev (names); - } + + names = nm_device_disambiguate_names ((NMDevice **) devices->pdata, devices->len); + nmt_devices = append_nmt_devices_for_devices (nmt_devices, devices, names, connections); + g_strfreev (names); + nmt_devices = append_nmt_devices_for_virtual_devices (nmt_devices, connections); nmt_devices = append_nmt_devices_for_vpns (nmt_devices, connections); diff --git a/clients/tui/nmt-device-entry.c b/clients/tui/nmt-device-entry.c index b8db86869f..184ed96ffc 100644 --- a/clients/tui/nmt-device-entry.c +++ b/clients/tui/nmt-device-entry.c @@ -187,9 +187,6 @@ find_device_by_interface_name (NmtDeviceEntry *deventry, int i; devices = nm_client_get_devices (nm_client); - if (!devices) - return NULL; - for (i = 0; i < devices->len && !device; i++) { NMDevice *candidate = devices->pdata[i]; @@ -218,9 +215,6 @@ find_device_by_mac_address (NmtDeviceEntry *deventry, int i; devices = nm_client_get_devices (nm_client); - if (!devices) - return NULL; - for (i = 0; i < devices->len && !device; i++) { NMDevice *candidate = devices->pdata[i]; char *hwaddr; diff --git a/examples/C/glib/get-ap-info-libnm.c b/examples/C/glib/get-ap-info-libnm.c index c5e9b5b238..044cec9c04 100644 --- a/examples/C/glib/get-ap-info-libnm.c +++ b/examples/C/glib/get-ap-info-libnm.c @@ -182,7 +182,7 @@ show_wifi_device_info (NMDevice *device) aps = nm_device_wifi_get_access_points (NM_DEVICE_WIFI (device)); /* Print AP details */ - for (i = 0; aps && (i < aps->len); i++) { + for (i = 0; i < aps->len; i++) { NMAccessPoint *ap = g_ptr_array_index (aps, i); show_access_point_info (ap); } @@ -212,7 +212,7 @@ int main (int argc, char *argv[]) devices = nm_client_get_devices (client); /* Go through the array and process Wi-Fi devices */ - for (i = 0; devices && (i < devices->len); i++) { + for (i = 0; i < devices->len; i++) { NMDevice *device = g_ptr_array_index (devices, i); if (NM_IS_DEVICE_WIFI (device)) show_wifi_device_info (device); diff --git a/libnm/nm-active-connection.c b/libnm/nm-active-connection.c index 659b820d82..7088e496a4 100644 --- a/libnm/nm-active-connection.c +++ b/libnm/nm-active-connection.c @@ -284,7 +284,7 @@ nm_active_connection_get_devices (NMActiveConnection *connection) { g_return_val_if_fail (NM_IS_ACTIVE_CONNECTION (connection), NULL); - return handle_ptr_array_return (NM_ACTIVE_CONNECTION_GET_PRIVATE (connection)->devices); + return NM_ACTIVE_CONNECTION_GET_PRIVATE (connection)->devices; } /** diff --git a/libnm/nm-client.c b/libnm/nm-client.c index fdbaed38b7..70c9c813ab 100644 --- a/libnm/nm-client.c +++ b/libnm/nm-client.c @@ -380,7 +380,7 @@ nm_client_get_devices (NMClient *client) { g_return_val_if_fail (NM_IS_CLIENT (client), NULL); - return handle_ptr_array_return (NM_CLIENT_GET_PRIVATE (client)->devices); + return NM_CLIENT_GET_PRIVATE (client)->devices; } /** @@ -522,7 +522,7 @@ recheck_pending_activations (NMClient *self, const char *failed_path, GError *er ainfo = info; } - for (i = 0; active_connections && i < active_connections->len; i++) { + for (i = 0; i < active_connections->len; i++) { NMActiveConnection *active = g_ptr_array_index (active_connections, i); const char *active_path = nm_object_get_path (NM_OBJECT (active)); @@ -803,7 +803,7 @@ nm_client_get_active_connections (NMClient *client) if (!nm_client_get_nm_running (client)) return NULL; - return handle_ptr_array_return (priv->active_connections); + return priv->active_connections; } /** diff --git a/libnm/nm-device-bond.c b/libnm/nm-device-bond.c index d0a3e94a82..e378c9cc31 100644 --- a/libnm/nm-device-bond.c +++ b/libnm/nm-device-bond.c @@ -118,7 +118,7 @@ nm_device_bond_get_slaves (NMDeviceBond *device) { g_return_val_if_fail (NM_IS_DEVICE_BOND (device), FALSE); - return handle_ptr_array_return (NM_DEVICE_BOND_GET_PRIVATE (device)->slaves); + return NM_DEVICE_BOND_GET_PRIVATE (device)->slaves; } static gboolean diff --git a/libnm/nm-device-bridge.c b/libnm/nm-device-bridge.c index 1a17196656..cb9cb2ad46 100644 --- a/libnm/nm-device-bridge.c +++ b/libnm/nm-device-bridge.c @@ -118,7 +118,7 @@ nm_device_bridge_get_slaves (NMDeviceBridge *device) { g_return_val_if_fail (NM_IS_DEVICE_BRIDGE (device), FALSE); - return handle_ptr_array_return (NM_DEVICE_BRIDGE_GET_PRIVATE (device)->slaves); + return NM_DEVICE_BRIDGE_GET_PRIVATE (device)->slaves; } static gboolean diff --git a/libnm/nm-device-team.c b/libnm/nm-device-team.c index 0aeda17039..27deda8a5a 100644 --- a/libnm/nm-device-team.c +++ b/libnm/nm-device-team.c @@ -118,7 +118,7 @@ nm_device_team_get_slaves (NMDeviceTeam *device) { g_return_val_if_fail (NM_IS_DEVICE_TEAM (device), FALSE); - return handle_ptr_array_return (NM_DEVICE_TEAM_GET_PRIVATE (device)->slaves); + return NM_DEVICE_TEAM_GET_PRIVATE (device)->slaves; } static const char * diff --git a/libnm/nm-device-wifi.c b/libnm/nm-device-wifi.c index 6a41ccc218..7252672f2d 100644 --- a/libnm/nm-device-wifi.c +++ b/libnm/nm-device-wifi.c @@ -247,7 +247,7 @@ nm_device_wifi_get_access_points (NMDeviceWifi *device) { g_return_val_if_fail (NM_IS_DEVICE_WIFI (device), NULL); - return handle_ptr_array_return (NM_DEVICE_WIFI_GET_PRIVATE (device)->aps); + return NM_DEVICE_WIFI_GET_PRIVATE (device)->aps; } /** diff --git a/libnm/nm-device-wimax.c b/libnm/nm-device-wimax.c index 5f190ea3f0..fc5793acb2 100644 --- a/libnm/nm-device-wimax.c +++ b/libnm/nm-device-wimax.c @@ -161,7 +161,7 @@ nm_device_wimax_get_nsps (NMDeviceWimax *wimax) { g_return_val_if_fail (NM_IS_DEVICE_WIMAX (wimax), NULL); - return handle_ptr_array_return (NM_DEVICE_WIMAX_GET_PRIVATE (wimax)->nsps); + return NM_DEVICE_WIMAX_GET_PRIVATE (wimax)->nsps; } /** diff --git a/libnm/nm-device.c b/libnm/nm-device.c index 3e67f09472..1eff7386d6 100644 --- a/libnm/nm-device.c +++ b/libnm/nm-device.c @@ -1364,7 +1364,7 @@ nm_device_get_available_connections (NMDevice *device) { g_return_val_if_fail (NM_IS_DEVICE (device), NULL); - return handle_ptr_array_return (NM_DEVICE_GET_PRIVATE (device)->available_connections); + return NM_DEVICE_GET_PRIVATE (device)->available_connections; } static char * diff --git a/libnm/nm-object-private.h b/libnm/nm-object-private.h index 4422883f8d..78764c8611 100644 --- a/libnm/nm-object-private.h +++ b/libnm/nm-object-private.h @@ -70,15 +70,6 @@ void _nm_object_set_property (NMObject *object, const char *prop_name, GValue *value); -static inline const GPtrArray * -handle_ptr_array_return (GPtrArray *array) -{ - /* zero-length is special-case; return NULL */ - if (!array || !array->len) - return NULL; - return array; -} - /* object demarshalling support */ typedef GType (*NMObjectTypeFunc) (DBusGConnection *, const char *); typedef void (*NMObjectTypeCallbackFunc) (GType, gpointer); diff --git a/libnm/tests/test-nm-client.c b/libnm/tests/test-nm-client.c index 5f0bcbffbf..5bf11e4aa7 100644 --- a/libnm/tests/test-nm-client.c +++ b/libnm/tests/test-nm-client.c @@ -156,7 +156,7 @@ test_device_added (void) client = test_client_new (); devices = nm_client_get_devices (client); - g_assert (devices == NULL); + g_assert (devices->len == 0); /* Tell the test service to add a new device */ add_device ("AddWiredDevice", "eth0", NULL); @@ -293,7 +293,7 @@ wifi_ap_remove_notify_cb (NMDeviceWifi *w, const GPtrArray *aps; aps = nm_device_wifi_get_access_points (w); - g_assert (aps == NULL); + g_assert (aps->len == 0); info->notified = TRUE; wifi_check_quit (info); @@ -516,7 +516,7 @@ wimax_nsp_remove_notify_cb (NMDeviceWimax *w, const GPtrArray *nsps; nsps = nm_device_wimax_get_nsps (w); - g_assert (nsps == NULL); + g_assert (nsps->len == 0); info->notified = TRUE; wimax_check_quit (info); From 356fb7d77eef522767312a9a9fd8e2d2a2f77fd4 Mon Sep 17 00:00:00 2001 From: Dan Winship Date: Wed, 2 Jul 2014 14:25:43 -0400 Subject: [PATCH 6/7] libnm: drop libnm IP-address-array types, use G_TYPE_STRV Make NMIP4Config:nameservers, NMIP4Config:wins-servers, and NMIP6Config:nameservers be G_TYPE_STRV, with stringified IP addresses, and update the APIs accordingly. --- clients/cli/common.c | 27 +-------- libnm/libnm.ver | 4 -- libnm/nm-ip4-config.c | 64 ++++++++++++-------- libnm/nm-ip4-config.h | 4 +- libnm/nm-ip6-config.c | 89 ++++++++++------------------ libnm/nm-ip6-config.h | 4 +- libnm/nm-types-private.h | 1 - libnm/nm-types.c | 124 --------------------------------------- libnm/nm-types.h | 6 -- 9 files changed, 75 insertions(+), 248 deletions(-) diff --git a/clients/cli/common.c b/clients/cli/common.c index 76867047aa..4472d4ac25 100644 --- a/clients/cli/common.c +++ b/clients/cli/common.c @@ -80,7 +80,6 @@ print_ip4_config (NMIP4Config *cfg4, const char *one_field) { GSList *list, *iter; - const GArray *array; char **addr_arr = NULL; char **route_arr = NULL; char **dns_arr = NULL; @@ -139,27 +138,13 @@ print_ip4_config (NMIP4Config *cfg4, route_arr[i] = NULL; /* DNS */ - array = nm_ip4_config_get_nameservers (cfg4); - if (array) { - dns_arr = g_new (char *, array->len + 1); - for (i = 0; i < array->len; i++) - dns_arr[i] = nmc_ip4_address_as_string (g_array_index (array, guint32, i), NULL); - - dns_arr[i] = NULL; - } + dns_arr = g_strdupv ((char **) nm_ip4_config_get_nameservers (cfg4)); /* domains */ domain_arr = g_strdupv ((char **) nm_ip4_config_get_domains (cfg4)); /* WINS */ - array = nm_ip4_config_get_wins_servers (cfg4); - if (array) { - wins_arr = g_new (char *, array->len + 1); - for (i = 0; i < array->len; i++) - wins_arr[i] = nmc_ip4_address_as_string (g_array_index (array, guint32, i), NULL); - - wins_arr[i] = NULL; - } + wins_arr = g_strdupv ((char **) nm_ip4_config_get_wins_servers (cfg4)); arr = nmc_dup_fields_array (tmpl, tmpl_len, NMC_OF_FLAG_SECTION_PREFIX); set_val_strc (arr, 0, group_prefix); @@ -242,13 +227,7 @@ print_ip6_config (NMIP6Config *cfg6, route_arr[i] = NULL; /* DNS */ - list = (GSList *) nm_ip6_config_get_nameservers (cfg6); - dns_arr = g_new (char *, g_slist_length (list) + 1); - i = 0; - for (iter = list; iter; iter = g_slist_next (iter)) - dns_arr[i++] = nmc_ip6_address_as_string (iter->data, NULL); - - dns_arr[i] = NULL; + dns_arr = g_strdupv ((char **) nm_ip6_config_get_nameservers (cfg6)); /* domains */ domain_arr = g_strdupv ((char **) nm_ip6_config_get_domains (cfg6)); diff --git a/libnm/libnm.ver b/libnm/libnm.ver index d2dd6b8e4a..8d2b7101b1 100644 --- a/libnm/libnm.ver +++ b/libnm/libnm.ver @@ -299,7 +299,6 @@ global: nm_ip4_route_set_next_hop; nm_ip4_route_set_prefix; nm_ip4_route_unref; - nm_ip6_address_array_get_type; nm_ip6_address_compare; nm_ip6_address_dup; nm_ip6_address_get_address; @@ -316,9 +315,7 @@ global: nm_ip6_config_get_addresses; nm_ip6_config_get_domains; nm_ip6_config_get_gateway; - nm_ip6_config_get_nameserver; nm_ip6_config_get_nameservers; - nm_ip6_config_get_num_nameservers; nm_ip6_config_get_routes; nm_ip6_config_get_searches; nm_ip6_config_get_type; @@ -862,7 +859,6 @@ global: nm_simple_connection_new_clone; nm_simple_connection_new_from_dbus; nm_state_get_type; - nm_uint_array_get_type; nm_utils_ap_mode_security_valid; nm_utils_bin2hexstr; nm_utils_check_virtual_device_compatibility; diff --git a/libnm/nm-ip4-config.c b/libnm/nm-ip4-config.c index 8a545141dc..39a9b6b4dc 100644 --- a/libnm/nm-ip4-config.c +++ b/libnm/nm-ip4-config.c @@ -38,10 +38,10 @@ typedef struct { char *gateway; GSList *addresses; GSList *routes; - GArray *nameservers; + char **nameservers; char **domains; char **searches; - GArray *wins; + char **wins; } NMIP4ConfigPrivate; enum { @@ -62,8 +62,10 @@ nm_ip4_config_init (NMIP4Config *config) { NMIP4ConfigPrivate *priv = NM_IP4_CONFIG_GET_PRIVATE (config); + priv->nameservers = g_new0 (char *, 1); priv->domains = g_new0 (char *, 1); priv->searches = g_new0 (char *, 1); + priv->wins = g_new0 (char *, 1); } static gboolean @@ -83,14 +85,30 @@ demarshal_ip4_address_array (NMObject *object, GParamSpec *pspec, GValue *value, static gboolean demarshal_ip4_array (NMObject *object, GParamSpec *pspec, GValue *value, gpointer field) { - if (!_nm_uint_array_demarshal (value, (GArray **) field)) + GArray *ip_array; + char ***obj_field; + int i; + + if (!G_VALUE_HOLDS (value, DBUS_TYPE_G_UINT_ARRAY)) return FALSE; - if (!strcmp (pspec->name, NM_IP4_CONFIG_NAMESERVERS)) - _nm_object_queue_notify (object, NM_IP4_CONFIG_NAMESERVERS); - else if (!strcmp (pspec->name, NM_IP4_CONFIG_WINS_SERVERS)) - _nm_object_queue_notify (object, NM_IP4_CONFIG_WINS_SERVERS); + ip_array = g_value_get_boxed (value); + obj_field = field; + if (*obj_field) + g_strfreev (*obj_field); + + *obj_field = g_new (char *, ip_array->len + 1); + for (i = 0; i < ip_array->len; i++) { + guint32 ip = g_array_index (ip_array, guint32, i); + const char *str; + + str = nm_utils_inet4_ntop (ip, NULL); + (*obj_field)[i] = g_strdup (str); + } + (*obj_field)[i] = NULL; + + _nm_object_queue_notify (object, pspec->name); return TRUE; } @@ -141,14 +159,10 @@ finalize (GObject *object) g_slist_free_full (priv->addresses, (GDestroyNotify) nm_ip4_address_unref); g_slist_free_full (priv->routes, (GDestroyNotify) nm_ip4_route_unref); - if (priv->nameservers) - g_array_free (priv->nameservers, TRUE); - - if (priv->wins) - g_array_free (priv->wins, TRUE); - + g_strfreev (priv->nameservers); g_strfreev (priv->domains); g_strfreev (priv->searches); + g_strfreev (priv->wins); g_object_unref (priv->proxy); @@ -175,7 +189,7 @@ get_property (GObject *object, nm_utils_ip4_routes_to_gvalue (priv->routes, value); break; case PROP_NAMESERVERS: - g_value_set_boxed (value, nm_ip4_config_get_nameservers (self)); + g_value_set_boxed (value, (char **) nm_ip4_config_get_nameservers (self)); break; case PROP_DOMAINS: g_value_set_boxed (value, (char **) nm_ip4_config_get_domains (self)); @@ -184,7 +198,7 @@ get_property (GObject *object, g_value_set_boxed (value, (char **) nm_ip4_config_get_searches (self)); break; case PROP_WINS_SERVERS: - g_value_set_boxed (value, nm_ip4_config_get_wins_servers (self)); + g_value_set_boxed (value, (char **) nm_ip4_config_get_wins_servers (self)); break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); @@ -245,12 +259,12 @@ nm_ip4_config_class_init (NMIP4ConfigClass *config_class) /** * NMIP4Config:nameservers: * - * The #GArray containing name servers (#guint32s) of the configuration. + * The array containing name server IP addresses of the configuration. **/ g_object_class_install_property (object_class, PROP_NAMESERVERS, g_param_spec_boxed (NM_IP4_CONFIG_NAMESERVERS, "", "", - NM_TYPE_UINT_ARRAY, + G_TYPE_STRV, G_PARAM_READABLE | G_PARAM_STATIC_STRINGS)); @@ -281,12 +295,12 @@ nm_ip4_config_class_init (NMIP4ConfigClass *config_class) /** * NMIP4Config:wins-servers: * - * The #GArray containing WINS servers (#guint32s) of the configuration. + * The array containing WINS server IP addresses of the configuration. **/ g_object_class_install_property (object_class, PROP_WINS_SERVERS, g_param_spec_boxed (NM_IP4_CONFIG_WINS_SERVERS, "", "", - NM_TYPE_UINT_ARRAY, + G_TYPE_STRV, G_PARAM_READABLE | G_PARAM_STATIC_STRINGS)); } @@ -330,16 +344,14 @@ nm_ip4_config_get_addresses (NMIP4Config *config) * * Gets the domain name servers (DNS). * - * Returns: (element-type guint32): the #GArray containing #guint32s. - * This is the internal copy used by the configuration and must not be - * modified. + * Returns: the array of nameserver IP addresses **/ -const GArray * +const char * const * nm_ip4_config_get_nameservers (NMIP4Config *config) { g_return_val_if_fail (NM_IS_IP4_CONFIG (config), NULL); - return NM_IP4_CONFIG_GET_PRIVATE (config)->nameservers; + return (const char * const *) NM_IP4_CONFIG_GET_PRIVATE (config)->nameservers; } /** @@ -384,12 +396,12 @@ nm_ip4_config_get_searches (NMIP4Config *config) * This is the internal copy used by the configuration and must not be * modified. **/ -const GArray * +const char * const * nm_ip4_config_get_wins_servers (NMIP4Config *config) { g_return_val_if_fail (NM_IS_IP4_CONFIG (config), NULL); - return NM_IP4_CONFIG_GET_PRIVATE (config)->wins; + return (const char * const *) NM_IP4_CONFIG_GET_PRIVATE (config)->wins; } /** diff --git a/libnm/nm-ip4-config.h b/libnm/nm-ip4-config.h index 1a04e912cc..c07ea7cc06 100644 --- a/libnm/nm-ip4-config.h +++ b/libnm/nm-ip4-config.h @@ -63,10 +63,10 @@ GType nm_ip4_config_get_type (void); const char * nm_ip4_config_get_gateway (NMIP4Config *config); const GSList * nm_ip4_config_get_addresses (NMIP4Config *config); const GSList * nm_ip4_config_get_routes (NMIP4Config *config); -const GArray * nm_ip4_config_get_nameservers (NMIP4Config *config); +const char * const *nm_ip4_config_get_nameservers (NMIP4Config *config); const char * const *nm_ip4_config_get_domains (NMIP4Config *config); const char * const *nm_ip4_config_get_searches (NMIP4Config *config); -const GArray * nm_ip4_config_get_wins_servers (NMIP4Config *config); +const char * const *nm_ip4_config_get_wins_servers (NMIP4Config *config); G_END_DECLS diff --git a/libnm/nm-ip6-config.c b/libnm/nm-ip6-config.c index 74dc2b909e..202c7fb349 100644 --- a/libnm/nm-ip6-config.c +++ b/libnm/nm-ip6-config.c @@ -27,6 +27,7 @@ #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) @@ -38,7 +39,7 @@ typedef struct { char *gateway; GSList *addresses; GSList *routes; - GSList *nameservers; + char **nameservers; char **domains; char **searches; } NMIP6ConfigPrivate; @@ -72,12 +73,30 @@ demarshal_ip6_address_array (NMObject *object, GParamSpec *pspec, GValue *value, static gboolean demarshal_ip6_nameserver_array (NMObject *object, GParamSpec *pspec, GValue *value, gpointer field) { - if (!_nm_ip6_address_array_demarshal (value, (GSList **) field)) + GPtrArray *ip_array; + char ***obj_field; + int i; + + if (!G_VALUE_HOLDS (value, DBUS_TYPE_G_ARRAY_OF_ARRAY_OF_UCHAR)) return FALSE; - if (pspec && !strcmp (pspec->name, NM_IP6_CONFIG_NAMESERVERS)) - _nm_object_queue_notify (object, NM_IP6_CONFIG_NAMESERVERS); + 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; + + _nm_object_queue_notify (object, pspec->name); return TRUE; } @@ -152,66 +171,19 @@ nm_ip6_config_get_addresses (NMIP6Config *config) } /** - * nm_ip6_config_get_num_nameservers: - * @config: a #NMIP6Config - * - * Gets the number of the domain name servers in the configuration. - * - * Returns: the number of domain name servers - **/ -guint32 -nm_ip6_config_get_num_nameservers (NMIP6Config *config) -{ - g_return_val_if_fail (NM_IS_IP6_CONFIG (config), 0); - - return g_slist_length (NM_IP6_CONFIG_GET_PRIVATE (config)->nameservers); -} - -/** - * nm_ip6_config_get_nameserver: - * @config: a #NMIP6Config - * @idx: index of the nameserver to return - * - * Gets the domain name server at index @idx in the configuration. - * - * Returns: (array fixed-size=16) (element-type guint8) (transfer none): - * the IPv6 address of domain name server at index @iidx - **/ -const struct in6_addr * -nm_ip6_config_get_nameserver (NMIP6Config *config, guint32 idx) -{ - NMIP6ConfigPrivate *priv; - GSList *item; - guint32 i = 0; - - g_return_val_if_fail (NM_IS_IP6_CONFIG (config), NULL); - - priv = NM_IP6_CONFIG_GET_PRIVATE (config); - - for (item = priv->nameservers; item && i < idx; i++) - item = item->next; - - g_return_val_if_fail (item, NULL); - return item ? (const struct in6_addr *) item->data : NULL; -} - -/* FIXME: like in libnm_util, in6_addr is not introspectable, so skipping here */ -/** - * nm_ip6_config_get_nameservers: (skip) + * nm_ip6_config_get_nameservers: * @config: a #NMIP6Config * * Gets the domain name servers (DNS). * - * Returns: a #GSList containing elements of type 'struct in6_addr' which - * contain the addresses of nameservers of the configuration. This is the - * internal copy used by the configuration and must not be modified. + * Returns: the array of nameserver IP addresses **/ -const GSList * +const char * const * nm_ip6_config_get_nameservers (NMIP6Config *config) { g_return_val_if_fail (NM_IS_IP6_CONFIG (config), NULL); - return NM_IP6_CONFIG_GET_PRIVATE (config)->nameservers; + return (const char * const *) NM_IP6_CONFIG_GET_PRIVATE (config)->nameservers; } /** @@ -273,8 +245,8 @@ finalize (GObject *object) g_slist_free_full (priv->addresses, (GDestroyNotify) nm_ip6_address_unref); g_slist_free_full (priv->routes, (GDestroyNotify) nm_ip6_route_unref); - g_slist_free_full (priv->nameservers, g_free); + g_strfreev (priv->nameservers); g_strfreev (priv->domains); g_strfreev (priv->searches); @@ -303,7 +275,7 @@ get_property (GObject *object, nm_utils_ip6_routes_to_gvalue (priv->routes, value); break; case PROP_NAMESERVERS: - g_value_set_boxed (value, nm_ip6_config_get_nameservers (self)); + g_value_set_boxed (value, (char **) nm_ip6_config_get_nameservers (self)); break; case PROP_DOMAINS: g_value_set_boxed (value, (char **) nm_ip6_config_get_domains (self)); @@ -322,6 +294,7 @@ nm_ip6_config_init (NMIP6Config *config) { NMIP6ConfigPrivate *priv = NM_IP6_CONFIG_GET_PRIVATE (config); + priv->nameservers = g_new0 (char *, 1); priv->domains = g_new0 (char *, 1); priv->searches = g_new0 (char *, 1); } @@ -391,7 +364,7 @@ nm_ip6_config_class_init (NMIP6ConfigClass *config_class) g_object_class_install_property (object_class, PROP_NAMESERVERS, g_param_spec_boxed (NM_IP6_CONFIG_NAMESERVERS, "", "", - NM_TYPE_IP6_ADDRESS_ARRAY, + G_TYPE_STRV, G_PARAM_READABLE | G_PARAM_STATIC_STRINGS)); diff --git a/libnm/nm-ip6-config.h b/libnm/nm-ip6-config.h index 467568cf6a..52320005fd 100644 --- a/libnm/nm-ip6-config.h +++ b/libnm/nm-ip6-config.h @@ -62,9 +62,7 @@ GType nm_ip6_config_get_type (void); const char * nm_ip6_config_get_gateway (NMIP6Config *config); const GSList * nm_ip6_config_get_addresses (NMIP6Config *config); const GSList * nm_ip6_config_get_routes (NMIP6Config *config); -guint32 nm_ip6_config_get_num_nameservers (NMIP6Config *config); -const struct in6_addr *nm_ip6_config_get_nameserver (NMIP6Config *config, guint32 idx); -const GSList * nm_ip6_config_get_nameservers (NMIP6Config *config); +const char * const * nm_ip6_config_get_nameservers (NMIP6Config *config); const char * const * nm_ip6_config_get_domains (NMIP6Config *config); const char * const * nm_ip6_config_get_searches (NMIP6Config *config); diff --git a/libnm/nm-types-private.h b/libnm/nm-types-private.h index 72c41b6920..50245d0a9d 100644 --- a/libnm/nm-types-private.h +++ b/libnm/nm-types-private.h @@ -25,7 +25,6 @@ #include "nm-types.h" #include "nm-object-private.h" -gboolean _nm_uint_array_demarshal (GValue *value, GArray **dest); 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 index 6ca32b3b24..bd09a12e72 100644 --- a/libnm/nm-types.c +++ b/libnm/nm-types.c @@ -28,58 +28,6 @@ #include "nm-dbus-glib-types.h" #include "nm-setting-ip6-config.h" -static gpointer -_nm_uint_array_copy (GArray *src) -{ - GArray *dest; - - dest = g_array_sized_new (FALSE, TRUE, sizeof (guint32), src->len); - g_array_append_vals (dest, src->data, src->len); - return dest; -} - -static void -_nm_uint_array_free (GArray *array) -{ - g_array_free (array, TRUE); -} - -GType -nm_uint_array_get_type (void) -{ - static GType our_type = 0; - - if (our_type == 0) - our_type = g_boxed_type_register_static (g_intern_static_string ("NMUintArray"), - (GBoxedCopyFunc) _nm_uint_array_copy, - (GBoxedFreeFunc) _nm_uint_array_free); - return our_type; -} - -gboolean -_nm_uint_array_demarshal (GValue *value, GArray **dest) -{ - GArray *array; - - if (!G_VALUE_HOLDS (value, DBUS_TYPE_G_UINT_ARRAY)) - return FALSE; - - if (*dest) { - g_boxed_free (NM_TYPE_UINT_ARRAY, *dest); - *dest = NULL; - } - - array = (GArray *) g_value_get_boxed (value); - if (array && (array->len > 0)) { - *dest = g_array_sized_new (FALSE, TRUE, sizeof (guint32), array->len); - g_array_append_vals (*dest, array->data, array->len); - } - - return TRUE; -} - -/*****************************/ - static gpointer _nm_ip6_address_object_array_copy (GPtrArray *src) { @@ -116,78 +64,6 @@ nm_ip6_address_object_array_get_type (void) /*****************************/ -static gpointer -_nm_ip6_address_array_copy (GPtrArray *src) -{ - GPtrArray *dest; - int i; - - dest = g_ptr_array_sized_new (src->len); - for (i = 0; i < src->len; i++) { - struct in6_addr *addr = g_ptr_array_index (src, i); - struct in6_addr *copy; - - copy = g_malloc0 (sizeof (struct in6_addr)); - memcpy (copy, addr, sizeof (struct in6_addr)); - g_ptr_array_add (dest, copy); - } - return dest; -} - -static void -_nm_ip6_address_array_free (GPtrArray *array) -{ - int i; - - for (i = 0; i < array->len; i++) - g_free (g_ptr_array_index (array, i)); - g_ptr_array_free (array, TRUE); -} - -GType -nm_ip6_address_array_get_type (void) -{ - static GType our_type = 0; - - if (our_type == 0) - our_type = g_boxed_type_register_static (g_intern_static_string ("NMIP6AddressArray"), - (GBoxedCopyFunc) _nm_ip6_address_array_copy, - (GBoxedFreeFunc) _nm_ip6_address_array_free); - return our_type; -} - -gboolean -_nm_ip6_address_array_demarshal (GValue *value, GSList **dest) -{ - GPtrArray *array; - - if (!G_VALUE_HOLDS (value, DBUS_TYPE_G_ARRAY_OF_ARRAY_OF_UCHAR)) - return FALSE; - - if (*dest) { - g_slist_free_full (*dest, g_free); - *dest = NULL; - } - - array = (GPtrArray *) g_value_get_boxed (value); - if (array && array->len) { - int i; - - for (i = 0; i < array->len; i++) { - GByteArray *bytearray = (GByteArray *) g_ptr_array_index (array, i); - struct in6_addr *addr; - - addr = g_malloc0 (sizeof (struct in6_addr)); - memcpy (addr->s6_addr, bytearray->data, bytearray->len); - *dest = g_slist_append (*dest, addr); - } - } - - return TRUE; -} - -/*****************************/ - static gpointer _nm_ip6_route_object_array_copy (GPtrArray *src) { diff --git a/libnm/nm-types.h b/libnm/nm-types.h index c55edf82be..3e22983248 100644 --- a/libnm/nm-types.h +++ b/libnm/nm-types.h @@ -32,15 +32,9 @@ G_BEGIN_DECLS -#define NM_TYPE_UINT_ARRAY (nm_uint_array_get_type ()) -GType nm_uint_array_get_type (void) G_GNUC_CONST; - #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_ADDRESS_ARRAY (nm_ip6_address_array_get_type ()) -GType nm_ip6_address_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; From 98959d5432abfbc1ff77f9b3952ead019cba936b Mon Sep 17 00:00:00 2001 From: Dan Winship Date: Mon, 25 Aug 2014 15:25:27 -0400 Subject: [PATCH 7/7] 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. --- docs/libnm/libnm-docs.xml | 1 - libnm/Makefile.am | 5 +- libnm/NetworkManager.h | 1 - libnm/libnm.ver | 2 - libnm/nm-dhcp4-config.c | 1 - libnm/nm-dhcp6-config.c | 1 - libnm/nm-ip4-config.c | 28 ++++++----- libnm/nm-ip6-config.c | 22 ++++----- libnm/nm-object.c | 1 - libnm/nm-types-private.h | 30 ------------ libnm/nm-types.c | 99 --------------------------------------- libnm/nm-types.h | 43 ----------------- libnm/nm-wimax-nsp.c | 1 - 13 files changed, 29 insertions(+), 206 deletions(-) delete mode 100644 libnm/nm-types-private.h delete mode 100644 libnm/nm-types.c delete mode 100644 libnm/nm-types.h diff --git a/docs/libnm/libnm-docs.xml b/docs/libnm/libnm-docs.xml index 64fbbc243b..3d1de81fe5 100644 --- a/docs/libnm/libnm-docs.xml +++ b/docs/libnm/libnm-docs.xml @@ -137,7 +137,6 @@ Utility API Reference - 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 #include #include -#include #include #include #include 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 #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 #NMIP4Addresses 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 #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 -#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 -#include -#include -#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 can be included directly." -#endif - -#include -#include - -#include - -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)