Commit 6a4127cf authored by Dan Winship's avatar Dan Winship

libnm-core: change list-of-string and array-of-string properties to G_TYPE_STRV

Change all DBUS_TYPE_G_LIST_OF_STRING and DBUS_TYPE_G_ARRAY_OF_STRING
properties to G_TYPE_STRV, and update everything accordingly.

(This doesn't actually require using
_nm_setting_class_transform_property(); dbus-glib is happy to transform
between 'as' and G_TYPE_STRV.)
parent 3a54d050
......@@ -388,6 +388,26 @@ setup_signals (void)
return TRUE;
}
static void
nmc_convert_strv_to_string (const GValue *src_value, GValue *dest_value)
{
char **strings;
strings = g_value_get_boxed (src_value);
if (strings)
g_value_take_string (dest_value, g_strjoinv (",", strings));
else
g_value_set_string (dest_value, "");
}
static void
nmc_value_transforms_register (void)
{
g_value_register_transform_func (G_TYPE_STRV,
G_TYPE_STRING,
nmc_convert_strv_to_string);
}
static NMClient *
nmc_get_client (NmCli *nmc)
{
......@@ -496,6 +516,8 @@ main (int argc, char *argv[])
*/
rl_set_keyboard_input_timeout (10000);
nmc_value_transforms_register ();
nmc_init (&nm_cli);
g_idle_add (start, &args_info);
......
......@@ -96,9 +96,9 @@ permissions_transform_to_allusers (GBinding *binding,
GValue *target_value,
gpointer user_data)
{
GSList *perms = g_value_get_boxed (source_value);
char **perms = g_value_get_boxed (source_value);
g_value_set_boolean (target_value, perms == NULL);
g_value_set_boolean (target_value, g_strv_length (perms) == 0);
return TRUE;
}
......@@ -109,12 +109,13 @@ permissions_transform_from_allusers (GBinding *binding,
gpointer user_data)
{
gboolean allusers = g_value_get_boolean (source_value);
GSList *perms = NULL;
char **perms = NULL;
if (allusers) {
char *perm = g_strdup_printf ("user:%s:", g_get_user_name ());
perms = g_new (char *, 2);
perms = g_slist_prepend (perms, perm);
perms[0] = g_strdup_printf ("user:%s:", g_get_user_name ());
perms[1] = NULL;
}
g_value_take_boxed (target_value, perms);
return TRUE;
......
......@@ -256,12 +256,11 @@ validate_permissions_type (GHashTable *hash, GError **error)
if (s_con) {
permissions = g_hash_table_lookup (s_con, NM_SETTING_CONNECTION_PERMISSIONS);
if (permissions) {
if ( !G_VALUE_HOLDS (permissions, G_TYPE_STRV)
&& !G_VALUE_HOLDS (permissions, DBUS_TYPE_G_LIST_OF_STRING)) {
if (!G_VALUE_HOLDS (permissions, G_TYPE_STRV)) {
g_set_error_literal (error,
NM_SETTING_ERROR,
NM_SETTING_ERROR_PROPERTY_TYPE_MISMATCH,
"Wrong permissions property type; should be a list of strings.");
"Wrong permissions property type; should be an array of strings.");
return FALSE;
}
}
......
......@@ -2819,7 +2819,7 @@ set_property (GObject *object, guint prop_id,
switch (prop_id) {
case PROP_EAP:
g_slist_free_full (priv->eap, g_free);
priv->eap = g_value_dup_boxed (value);
priv->eap = _nm_utils_strv_to_slist (g_value_get_boxed (value));
break;
case PROP_IDENTITY:
g_free (priv->identity);
......@@ -2855,7 +2855,7 @@ set_property (GObject *object, guint prop_id,
break;
case PROP_ALTSUBJECT_MATCHES:
g_slist_free_full (priv->altsubject_matches, g_free);
priv->altsubject_matches = g_value_dup_boxed (value);
priv->altsubject_matches = _nm_utils_strv_to_slist (g_value_get_boxed (value));
break;
case PROP_CLIENT_CERT:
if (priv->client_cert) {
......@@ -2911,7 +2911,7 @@ set_property (GObject *object, guint prop_id,
break;
case PROP_PHASE2_ALTSUBJECT_MATCHES:
g_slist_free_full (priv->phase2_altsubject_matches, g_free);
priv->phase2_altsubject_matches = g_value_dup_boxed (value);
priv->phase2_altsubject_matches = _nm_utils_strv_to_slist (g_value_get_boxed (value));
break;
case PROP_PHASE2_CLIENT_CERT:
if (priv->phase2_client_cert) {
......@@ -3003,7 +3003,7 @@ get_property (GObject *object, guint prop_id,
switch (prop_id) {
case PROP_EAP:
g_value_set_boxed (value, priv->eap);
g_value_take_boxed (value, _nm_utils_slist_to_strv (priv->eap));
break;
case PROP_IDENTITY:
g_value_set_string (value, priv->identity);
......@@ -3024,7 +3024,7 @@ get_property (GObject *object, guint prop_id,
g_value_set_string (value, priv->subject_match);
break;
case PROP_ALTSUBJECT_MATCHES:
g_value_set_boxed (value, priv->altsubject_matches);
g_value_take_boxed (value, _nm_utils_slist_to_strv (priv->altsubject_matches));
break;
case PROP_CLIENT_CERT:
g_value_set_boxed (value, priv->client_cert);
......@@ -3054,7 +3054,7 @@ get_property (GObject *object, guint prop_id,
g_value_set_string (value, priv->phase2_subject_match);
break;
case PROP_PHASE2_ALTSUBJECT_MATCHES:
g_value_set_boxed (value, priv->phase2_altsubject_matches);
g_value_take_boxed (value, _nm_utils_slist_to_strv (priv->phase2_altsubject_matches));
break;
case PROP_PHASE2_CLIENT_CERT:
g_value_set_boxed (value, priv->phase2_client_cert);
......@@ -3135,7 +3135,7 @@ nm_setting_802_1x_class_init (NMSetting8021xClass *setting_class)
g_object_class_install_property
(object_class, PROP_EAP,
g_param_spec_boxed (NM_SETTING_802_1X_EAP, "", "",
DBUS_TYPE_G_LIST_OF_STRING,
G_TYPE_STRV,
G_PARAM_READWRITE |
G_PARAM_STATIC_STRINGS));
......@@ -3241,7 +3241,7 @@ nm_setting_802_1x_class_init (NMSetting8021xClass *setting_class)
g_object_class_install_property
(object_class, PROP_ALTSUBJECT_MATCHES,
g_param_spec_boxed (NM_SETTING_802_1X_ALTSUBJECT_MATCHES, "", "",
DBUS_TYPE_G_LIST_OF_STRING,
G_TYPE_STRV,
G_PARAM_READWRITE |
G_PARAM_STATIC_STRINGS));
......@@ -3417,7 +3417,7 @@ nm_setting_802_1x_class_init (NMSetting8021xClass *setting_class)
g_object_class_install_property
(object_class, PROP_PHASE2_ALTSUBJECT_MATCHES,
g_param_spec_boxed (NM_SETTING_802_1X_PHASE2_ALTSUBJECT_MATCHES, "", "",
DBUS_TYPE_G_LIST_OF_STRING,
G_TYPE_STRV,
G_PARAM_READWRITE |
G_PARAM_STATIC_STRINGS));
......
......@@ -24,7 +24,7 @@
#include <glib/gi18n.h>
#include "nm-utils.h"
#include "nm-dbus-glib-types.h"
#include "nm-utils-private.h"
#include "nm-setting-connection.h"
#include "nm-setting-private.h"
......@@ -1033,14 +1033,15 @@ finalize (GObject *object)
}
static GSList *
perm_stringlist_to_permlist (GSList *strlist)
perm_strv_to_permlist (char **strv)
{
GSList *list = NULL, *iter;
GSList *list = NULL;
int i;
for (iter = strlist; iter; iter = g_slist_next (iter)) {
for (i = 0; strv[i]; i++) {
Permission *p;
p = permission_new_from_str ((const char *) iter->data);
p = permission_new_from_str (strv[i]);
if (p)
list = g_slist_append (list, p);
}
......@@ -1073,7 +1074,7 @@ set_property (GObject *object, guint prop_id,
break;
case PROP_PERMISSIONS:
g_slist_free_full (priv->permissions, (GDestroyNotify) permission_free);
priv->permissions = perm_stringlist_to_permlist (g_value_get_boxed (value));
priv->permissions = perm_strv_to_permlist (g_value_get_boxed (value));
break;
case PROP_AUTOCONNECT:
priv->autoconnect = g_value_get_boolean (value);
......@@ -1098,7 +1099,7 @@ set_property (GObject *object, guint prop_id,
break;
case PROP_SECONDARIES:
g_slist_free_full (priv->secondaries, g_free);
priv->secondaries = g_value_dup_boxed (value);
priv->secondaries = _nm_utils_strv_to_slist (g_value_get_boxed (value));
break;
case PROP_GATEWAY_PING_TIMEOUT:
priv->gateway_ping_timeout = g_value_get_uint (value);
......@@ -1109,14 +1110,18 @@ set_property (GObject *object, guint prop_id,
}
}
static GSList *
perm_permlist_to_stringlist (GSList *permlist)
static char **
perm_permlist_to_strv (GSList *permlist)
{
GSList *list = NULL, *iter;
GPtrArray *strings;
GSList *iter;
strings = g_ptr_array_new ();
for (iter = permlist; iter; iter = g_slist_next (iter))
list = g_slist_append (list, permission_to_string ((Permission *) iter->data));
return list;
g_ptr_array_add (strings, permission_to_string ((Permission *) iter->data));
g_ptr_array_add (strings, NULL);
return (char **) g_ptr_array_free (strings, FALSE);
}
static void
......@@ -1140,7 +1145,7 @@ get_property (GObject *object, guint prop_id,
g_value_set_string (value, nm_setting_connection_get_connection_type (setting));
break;
case PROP_PERMISSIONS:
g_value_take_boxed (value, perm_permlist_to_stringlist (priv->permissions));
g_value_take_boxed (value, perm_permlist_to_strv (priv->permissions));
break;
case PROP_AUTOCONNECT:
g_value_set_boolean (value, nm_setting_connection_get_autoconnect (setting));
......@@ -1161,7 +1166,7 @@ get_property (GObject *object, guint prop_id,
g_value_set_string (value, nm_setting_connection_get_slave_type (setting));
break;
case PROP_SECONDARIES:
g_value_set_boxed (value, priv->secondaries);
g_value_take_boxed (value, _nm_utils_slist_to_strv (priv->secondaries));
break;
case PROP_GATEWAY_PING_TIMEOUT:
g_value_set_uint (value, priv->gateway_ping_timeout);
......@@ -1289,7 +1294,7 @@ nm_setting_connection_class_init (NMSettingConnectionClass *setting_class)
g_object_class_install_property
(object_class, PROP_PERMISSIONS,
g_param_spec_boxed (NM_SETTING_CONNECTION_PERMISSIONS, "", "",
DBUS_TYPE_G_LIST_OF_STRING,
G_TYPE_STRV,
G_PARAM_READWRITE |
G_PARAM_STATIC_STRINGS));
......@@ -1403,7 +1408,7 @@ nm_setting_connection_class_init (NMSettingConnectionClass *setting_class)
g_object_class_install_property
(object_class, PROP_SECONDARIES,
g_param_spec_boxed (NM_SETTING_CONNECTION_SECONDARIES, "", "",
DBUS_TYPE_G_LIST_OF_STRING,
G_TYPE_STRV,
G_PARAM_READWRITE |
NM_SETTING_PARAM_FUZZY_IGNORE |
G_PARAM_STATIC_STRINGS));
......
......@@ -30,7 +30,7 @@
#include "nm-glib-compat.h"
#include "nm-setting-private.h"
#include "nm-core-internal.h"
#include "nm-utils-private.h"
/**
* SECTION:nm-setting-ip4-config
......@@ -459,7 +459,7 @@ gboolean
nm_setting_ip4_config_add_address (NMSettingIP4Config *setting,
NMIP4Address *address)
{
return _nm_setting_ip4_config_add_address_with_label (setting, address, NULL);
return _nm_setting_ip4_config_add_address_with_label (setting, address, "");
}
gboolean
......@@ -473,6 +473,7 @@ _nm_setting_ip4_config_add_address_with_label (NMSettingIP4Config *setting,
g_return_val_if_fail (NM_IS_SETTING_IP4_CONFIG (setting), FALSE);
g_return_val_if_fail (address != NULL, FALSE);
g_return_val_if_fail (label != NULL, FALSE);
priv = NM_SETTING_IP4_CONFIG_GET_PRIVATE (setting);
for (iter = priv->addresses; iter; iter = g_slist_next (iter)) {
......@@ -510,8 +511,7 @@ nm_setting_ip4_config_remove_address (NMSettingIP4Config *setting, guint32 i)
nm_ip4_address_unref ((NMIP4Address *) addr->data);
priv->addresses = g_slist_delete_link (priv->addresses, addr);
if (label->data)
g_free (label->data);
g_free (label->data);
priv->address_labels = g_slist_delete_link (priv->address_labels, label);
g_object_notify (G_OBJECT (setting), NM_SETTING_IP4_CONFIG_ADDRESSES);
......@@ -840,6 +840,9 @@ verify_label (const char *label)
const char *p;
char *iface;
if (!*label)
return TRUE;
p = strchr (label, ':');
if (!p)
return FALSE;
......@@ -976,7 +979,7 @@ verify (NMSetting *setting, GSList *all_settings, GError **error)
return FALSE;
}
if (label && !verify_label (label)) {
if (!verify_label (label)) {
g_set_error (error,
NM_SETTING_IP4_CONFIG_ERROR,
NM_SETTING_IP4_CONFIG_ERROR_INVALID_PROPERTY,
......@@ -1078,7 +1081,7 @@ set_property (GObject *object, guint prop_id,
break;
case PROP_DNS_SEARCH:
g_slist_free_full (priv->dns_search, g_free);
priv->dns_search = g_value_dup_boxed (value);
priv->dns_search = _nm_utils_strv_to_slist (g_value_get_boxed (value));
break;
case PROP_ADDRESSES:
g_slist_free_full (priv->addresses, (GDestroyNotify) nm_ip4_address_unref);
......@@ -1088,19 +1091,12 @@ set_property (GObject *object, guint prop_id,
g_slist_free_full (priv->address_labels, g_free);
priv->address_labels = NULL;
for (iter = priv->addresses; iter; iter = iter->next)
priv->address_labels = g_slist_prepend (priv->address_labels, NULL);
priv->address_labels = g_slist_prepend (priv->address_labels, g_strdup (""));
}
break;
case PROP_ADDRESS_LABELS:
g_slist_free_full (priv->address_labels, g_free);
priv->address_labels = g_value_dup_boxed (value);
/* NULLs get converted to "" when this is sent over D-Bus. */
for (iter = priv->address_labels; iter; iter = iter->next) {
if (!g_strcmp0 (iter->data, "")) {
g_free (iter->data);
iter->data = NULL;
}
}
priv->address_labels = _nm_utils_strv_to_slist (g_value_get_boxed (value));
break;
case PROP_ROUTES:
g_slist_free_full (priv->routes, (GDestroyNotify) nm_ip4_route_unref);
......@@ -1150,13 +1146,13 @@ get_property (GObject *object, guint prop_id,
g_value_set_boxed (value, priv->dns);
break;
case PROP_DNS_SEARCH:
g_value_set_boxed (value, priv->dns_search);
g_value_take_boxed (value, _nm_utils_slist_to_strv (priv->dns_search));
break;
case PROP_ADDRESSES:
nm_utils_ip4_addresses_to_gvalue (priv->addresses, value);
break;
case PROP_ADDRESS_LABELS:
g_value_set_boxed (value, priv->address_labels);
g_value_take_boxed (value, _nm_utils_slist_to_strv (priv->address_labels));
break;
case PROP_ROUTES:
nm_utils_ip4_routes_to_gvalue (priv->routes, value);
......@@ -1256,7 +1252,7 @@ nm_setting_ip4_config_class_init (NMSettingIP4ConfigClass *setting_class)
g_object_class_install_property
(object_class, PROP_DNS_SEARCH,
g_param_spec_boxed (NM_SETTING_IP4_CONFIG_DNS_SEARCH, "", "",
DBUS_TYPE_G_LIST_OF_STRING,
G_TYPE_STRV,
G_PARAM_READWRITE |
G_PARAM_STATIC_STRINGS));
......@@ -1288,7 +1284,7 @@ nm_setting_ip4_config_class_init (NMSettingIP4ConfigClass *setting_class)
g_object_class_install_property
(object_class, PROP_ADDRESS_LABELS,
g_param_spec_boxed ("address-labels", "", "",
DBUS_TYPE_G_LIST_OF_STRING,
G_TYPE_STRV,
G_PARAM_READWRITE |
NM_SETTING_PARAM_INFERRABLE |
G_PARAM_STATIC_STRINGS));
......
......@@ -25,6 +25,7 @@
#include "nm-setting-ip6-config.h"
#include "nm-utils.h"
#include "nm-utils-private.h"
#include "nm-dbus-glib-types.h"
#include "nm-glib-compat.h"
#include "nm-setting-private.h"
......@@ -902,7 +903,7 @@ set_property (GObject *object, guint prop_id,
break;
case PROP_DNS_SEARCH:
g_slist_free_full (priv->dns_search, g_free);
priv->dns_search = g_value_dup_boxed (value);
priv->dns_search = _nm_utils_strv_to_slist (g_value_get_boxed (value));
break;
case PROP_ADDRESSES:
g_slist_free_full (priv->addresses, g_free);
......@@ -951,7 +952,7 @@ get_property (GObject *object, guint prop_id,
nm_utils_ip6_dns_to_gvalue (priv->dns, value);
break;
case PROP_DNS_SEARCH:
g_value_set_boxed (value, priv->dns_search);
g_value_take_boxed (value, _nm_utils_slist_to_strv (priv->dns_search));
break;
case PROP_ADDRESSES:
nm_utils_ip6_addresses_to_gvalue (priv->addresses, value);
......@@ -1063,7 +1064,7 @@ nm_setting_ip6_config_class_init (NMSettingIP6ConfigClass *setting_class)
g_object_class_install_property
(object_class, PROP_DNS_SEARCH,
g_param_spec_boxed (NM_SETTING_IP6_CONFIG_DNS_SEARCH, "", "",
DBUS_TYPE_G_LIST_OF_STRING,
G_TYPE_STRV,
G_PARAM_READWRITE |
G_PARAM_STATIC_STRINGS));
......
......@@ -21,12 +21,10 @@
#include <stdlib.h>
#include <string.h>
#include <dbus/dbus-glib.h>
#include <glib/gi18n.h>
#include "nm-setting-vlan.h"
#include "nm-utils.h"
#include "nm-dbus-glib-types.h"
#include "nm-setting-connection.h"
#include "nm-setting-private.h"
......@@ -574,14 +572,15 @@ verify (NMSetting *setting, GSList *all_settings, GError **error)
}
static GSList *
priority_stringlist_to_maplist (NMVlanPriorityMap map, GSList *strlist)
priority_strv_to_maplist (NMVlanPriorityMap map, char **strv)
{
GSList *list = NULL, *iter;
GSList *list = NULL;
int i;
for (iter = strlist; iter; iter = g_slist_next (iter)) {
for (i = 0; strv[i]; i++) {
PriorityMap *item;
item = priority_map_new_from_str (map, (const char *) iter->data);
item = priority_map_new_from_str (map, strv[i]);
if (item)
list = g_slist_prepend (list, item);
}
......@@ -609,12 +608,12 @@ set_property (GObject *object, guint prop_id,
case PROP_INGRESS_PRIORITY_MAP:
g_slist_free_full (priv->ingress_priority_map, g_free);
priv->ingress_priority_map =
priority_stringlist_to_maplist (NM_VLAN_INGRESS_MAP, g_value_get_boxed (value));
priority_strv_to_maplist (NM_VLAN_INGRESS_MAP, g_value_get_boxed (value));
break;
case PROP_EGRESS_PRIORITY_MAP:
g_slist_free_full (priv->egress_priority_map, g_free);
priv->egress_priority_map =
priority_stringlist_to_maplist (NM_VLAN_EGRESS_MAP, g_value_get_boxed (value));
priority_strv_to_maplist (NM_VLAN_EGRESS_MAP, g_value_get_boxed (value));
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
......@@ -622,17 +621,22 @@ set_property (GObject *object, guint prop_id,
}
}
static GSList *
priority_maplist_to_stringlist (GSList *list)
static char **
priority_maplist_to_strv (GSList *list)
{
GSList *strlist = NULL, *iter;
GSList *iter;
GPtrArray *strv;
strv = g_ptr_array_new ();
for (iter = list; iter; iter = g_slist_next (iter)) {
PriorityMap *item = iter->data;
strlist = g_slist_prepend (strlist, g_strdup_printf ("%d:%d", item->from, item->to));
g_ptr_array_add (strv, g_strdup_printf ("%d:%d", item->from, item->to));
}
return g_slist_reverse (strlist);
g_ptr_array_add (strv, NULL);
return (char **) g_ptr_array_free (strv, FALSE);
}
static void
......@@ -653,10 +657,10 @@ get_property (GObject *object, guint prop_id,
g_value_set_uint (value, priv->flags);
break;
case PROP_INGRESS_PRIORITY_MAP:
g_value_take_boxed (value, priority_maplist_to_stringlist (priv->ingress_priority_map));
g_value_take_boxed (value, priority_maplist_to_strv (priv->ingress_priority_map));
break;
case PROP_EGRESS_PRIORITY_MAP:
g_value_take_boxed (value, priority_maplist_to_stringlist (priv->egress_priority_map));
g_value_take_boxed (value, priority_maplist_to_strv (priv->egress_priority_map));
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
......@@ -753,7 +757,7 @@ nm_setting_vlan_class_init (NMSettingVlanClass *setting_class)
g_object_class_install_property
(object_class, PROP_INGRESS_PRIORITY_MAP,
g_param_spec_boxed (NM_SETTING_VLAN_INGRESS_PRIORITY_MAP, "", "",
DBUS_TYPE_G_LIST_OF_STRING,
G_TYPE_STRV,
G_PARAM_READWRITE |
NM_SETTING_PARAM_INFERRABLE |
G_PARAM_STATIC_STRINGS));
......@@ -768,7 +772,7 @@ nm_setting_vlan_class_init (NMSettingVlanClass *setting_class)
g_object_class_install_property
(object_class, PROP_EGRESS_PRIORITY_MAP,
g_param_spec_boxed (NM_SETTING_VLAN_EGRESS_PRIORITY_MAP, "", "",
DBUS_TYPE_G_LIST_OF_STRING,
G_TYPE_STRV,
G_PARAM_READWRITE |
NM_SETTING_PARAM_INFERRABLE |
G_PARAM_STATIC_STRINGS));
......
......@@ -72,7 +72,7 @@ typedef struct {
char *cloned_mac_address;
GSList *mac_address_blacklist;
guint32 mtu;
GPtrArray *s390_subchannels;
char **s390_subchannels;
char *s390_nettype;
GHashTable *s390_options;
} NMSettingWiredPrivate;
......@@ -380,15 +380,15 @@ nm_setting_wired_get_mtu (NMSettingWired *setting)
* connection is applicable to. The connection should only be used in
* conjunction with that device.
*
* Returns: (element-type utf8): #GPtrArray of strings, each specifying one
* subchannel the s390 device uses to communicate to the host.
* Returns: (transfer none) (element-type utf8): array of strings, each specifying
* one subchannel the s390 device uses to communicate to the host.
**/
const GPtrArray *
const char * const *
nm_setting_wired_get_s390_subchannels (NMSettingWired *setting)
{
g_return_val_if_fail (NM_IS_SETTING_WIRED (setting), NULL);
return NM_SETTING_WIRED_GET_PRIVATE (setting)->s390_subchannels;
return (const char * const *) NM_SETTING_WIRED_GET_PRIVATE (setting)->s390_subchannels;
}
/**
......@@ -628,14 +628,17 @@ verify (NMSetting *setting, GSList *all_settings, GError **error)
}
}
if ( priv->s390_subchannels
&& !(priv->s390_subchannels->len == 3 || priv->s390_subchannels->len == 2)) {
g_set_error_literal (error,
NM_SETTING_WIRED_ERROR,
NM_SETTING_WIRED_ERROR_INVALID_PROPERTY,
_("property is invalid"));
g_prefix_error (error, "%s.%s: ", NM_SETTING_WIRED_SETTING_NAME, NM_SETTING_WIRED_S390_SUBCHANNELS);
return FALSE;
if (priv->s390_subchannels) {
int len = g_strv_length (priv->s390_subchannels);
if (len != 2 && len != 3) {
g_set_error_literal (error,
NM_SETTING_WIRED_ERROR,
NM_SETTING_WIRED_ERROR_INVALID_PROPERTY,
_("property is invalid"));
g_prefix_error (error, "%s.%s: ", NM_SETTING_WIRED_SETTING_NAME, NM_SETTING_WIRED_S390_SUBCHANNELS);
return FALSE;
}
}
if (priv->s390_nettype && !_nm_utils_string_in_list (priv->s390_nettype, valid_nettype)) {
......@@ -697,10 +700,8 @@ finalize (GObject *object)
g_free (priv->cloned_mac_address);
g_slist_free_full (priv->mac_address_blacklist, g_free);
if (priv->s390_subchannels) {
g_ptr_array_set_free_func (priv->s390_subchannels, g_free);
g_ptr_array_free (priv->s390_subchannels, TRUE);
}
if (priv->s390_subchannels)
g_strfreev (priv->s390_subchannels);
G_OBJECT_CLASS (nm_setting_wired_parent_class)->finalize (object);
}
......@@ -743,16 +744,14 @@ set_property (GObject *object, guint prop_id,
break;
case PROP_MAC_ADDRESS_BLACKLIST:
g_slist_free_full (priv->mac_address_blacklist, g_free);
priv->mac_address_blacklist = g_value_dup_boxed (value);
priv->mac_address_blacklist = _nm_utils_strv_to_slist (g_value_get_boxed (value));
break;
case PROP_MTU:
priv->mtu = g_value_get_uint (value);
break;
case PROP_S390_SUBCHANNELS:
if (priv->s390_subchannels) {
g_ptr_array_set_free_func (priv->s390_subchannels, g_free);
g_ptr_array_free (priv->s390_subchannels, TRUE);
}
if (priv->s390_subchannels)
g_strfreev (priv->s390_subchannels);
priv->s390_subchannels = g_value_dup_boxed (value);
break;
case PROP_S390_NETTYPE:
......@@ -799,13 +798,13 @@ get_property (GObject *object, guint prop_id,
g_value_set_string (value, nm_setting_wired_get_cloned_mac_address (setting));
break;
case PROP_MAC_ADDRESS_BLACKLIST:
g_value_set_boxed (value, nm_setting_wired_get_mac_address_blacklist (setting));
g_value_take_boxed (value, _nm_utils_slist_to_strv (priv->mac_address_blacklist));
break;
case PROP_MTU:
g_value_set_uint (value, nm_setting_wired_get_mtu (setting));
break;
case PROP_S390_SUBCHANNELS:
g_value_set_boxed (value, nm_setting_wired_get_s390_subchannels (setting));
g_value_set_boxed (value, priv->s390_subchannels);
break;
case PROP_S390_NETTYPE:
g_value_set_string (value, nm_setting_wired_get_s390_nettype (setting));
......@@ -939,7 +938,7 @@ nm_setting_wired_class_init (NMSettingWiredClass *setting_class)
g_object_class_install_property
(object_class, PROP_MAC_ADDRESS_BLACKLIST,
g_param_spec_boxed (NM_SETTING_WIRED_MAC_ADDRESS_BLACKLIST, "", "",
DBUS_TYPE_G_LIST_OF_STRING,
G_TYPE_STRV,
G_PARAM_READWRITE |
NM_SETTING_PARAM_FUZZY_IGNORE |
G_PARAM_STATIC_STRINGS));
......@@ -973,7 +972,7 @@ nm_setting_wired_class_init (NMSettingWiredClass *setting_class)
g_object_class_install_property
(object_class, PROP_S390_SUBCHANNELS,
g_param_spec_boxed (NM_SETTING_WIRED_S390_SUBCHANNELS, "", "",
DBUS_TYPE_G_ARRAY_OF_STRING,
G_TYPE_STRV,
G_PARAM_READWRITE |
NM_SETTING_PARAM_INFERRABLE |
G_PARAM_STATIC_STRINGS));
......
......@@ -103,7 +103,7 @@ void nm_setting_wired_clear_mac_blacklist_items (NMSettingWired *
guint32 nm_setting_wired_get_mtu (NMSettingWired *setting);
const GPtrArray * nm_setting_wired_get_s390_subchannels (NMSettingWired *setting);
const char * const *nm_setting_wired_get_s390_subchannels (NMSettingWired *setting);
const char * nm_setting_wired_get_s390_nettype (NMSettingWired *setting);
guint32 nm_setting_wired_get_num_s390_options (NMSettingWired *setting);
......
......@@ -22,13 +22,11 @@
#include <config.h>
#include <string.h>
#include <dbus/dbus-glib.h>
#include <glib/gi18n.h>
#include "nm-setting-wireless-security.h"
#include "nm-setting-8021x.h"
#include "nm-utils.h"
#include "nm-dbus-glib-types.h"
#include "nm-utils-private.h"
#include "nm-setting-private.h"
......@@ -1191,15 +1189,15 @@ set_property (GObject *object, guint prop_id,
break;
case PROP_PROTO:
g_slist_free_full (priv->proto, g_free);
priv->proto = g_value_dup_boxed (value);
priv->proto = _nm_utils_strv_to_slist (g_value_get_boxed (value));
break;
case PROP_PAIRWISE:
g_slist_free_full (priv->pairwise, g_free);
priv->pairwise = g_value_dup_boxed (value);
priv->pairwise = _nm_utils_strv_to_slist (g_value_get_boxed (value));
break;
case PROP_GROUP:
g_slist_free_full (priv->group, g_free);
priv->group = g_value_dup_boxed (value);
priv->group = _nm_utils_strv_to_slist (g_value_get_boxed (value));
break;
case PROP_LEAP_USERNAME:
g_free (priv->leap_username);
......@@ -1265,13 +1263,13 @@ get_property (GObject *object, guint prop_id,
g_value_set_string (value, priv->auth_alg);
break;
case PROP_PROTO:
g_value_set_boxed (value, priv->proto);
g_value_take_boxed (value, _nm_utils_slist_to_strv (priv->proto));
break;
case PROP_PAIRWISE:
g_value_set_boxed (value, priv->pairwise);
g_value_take_boxed (value, _nm_utils_slist_to_strv (priv->pairwise));
break;
case PROP_GROUP:
g_value_set_boxed (value, priv->group);
g_value_take_boxed (value, _nm_utils_slist_to_strv (priv->group));
break;
case PROP_LEAP_USERNAME:
g_value_set_string (value, priv->leap_username);
......@@ -1389,7 +1387,7 @@ nm_setting_wireless_security_class_init (NMSettingWirelessSecurityClass *setting
g_object_class_install_property
(object_class, PROP_PROTO,
g_param_spec_boxed (NM_SETTING_WIRELESS_SECURITY_PROTO, "", "",
DBUS_TYPE_G_LIST_OF_STRING,
G_TYPE_STRV,
G_PARAM_READWRITE |
G_PARAM_STATIC_STRINGS));
......@@ -1404,7 +1402,7 @@ nm_setting_wireless_security_class_init (NMSettingWirelessSecurityClass *setting
g_object_class_install_property
(object_class, PROP_PAIRWISE,
g_param_spec_boxed (NM_SETTING_WIRELESS_SECURITY_PAIRWISE, "", "",
DBUS_TYPE_G_LIST_OF_STRING,
G_TYPE_STRV,
G_PARAM_READWRITE |
G_PARAM_STATIC_STRINGS));
......@@ -1419,7 +1417,7 @@ nm_setting_wireless_security_class_init (NMSettingWirelessSecurityClass *setting
g_object_class_install_property
(object_class, PROP_GROUP,
g_param_spec_boxed (NM_SETTING_WIRELESS_SECURITY_GROUP, "", "",
DBUS_TYPE_G_LIST_OF_STRING,