diff --git a/clients/cli/common.c b/clients/cli/common.c
index d860d6386d..4472d4ac25 100644
--- a/clients/cli/common.c
+++ b/clients/cli/common.c
@@ -80,8 +80,6 @@ print_ip4_config (NMIP4Config *cfg4,
const char *one_field)
{
GSList *list, *iter;
- const GArray *array;
- const GPtrArray *ptr_array;
char **addr_arr = NULL;
char **route_arr = NULL;
char **dns_arr = NULL;
@@ -140,34 +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 */
- 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);
- 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);
@@ -193,7 +170,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;
@@ -251,23 +227,10 @@ 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 */
- 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/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 11ed479706..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 *));
@@ -495,7 +490,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 +523,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);
@@ -676,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));
@@ -749,7 +748,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)) {
@@ -881,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;
@@ -969,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);
@@ -1011,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);
@@ -1082,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));
@@ -1330,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 ();
@@ -1694,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);
@@ -1799,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);
@@ -1858,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);
@@ -1921,7 +1919,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 +1930,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;
@@ -2004,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);
@@ -2043,17 +2042,17 @@ 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) {
/* 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) {
@@ -2451,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);
@@ -2533,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);
@@ -2556,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;
@@ -2590,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;
@@ -2605,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;
@@ -2629,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 */
@@ -2698,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 d7592b80b2..f3b02e99a7 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,13 +266,13 @@ 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;
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);
@@ -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;
@@ -449,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);
@@ -483,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/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/examples/C/glib/get-ap-info-libnm.c b/examples/C/glib/get-ap-info-libnm.c
index acd93f9ba7..044cec9c04 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));
}
}
@@ -181,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);
}
@@ -211,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-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/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 326a6f15ad..5617fb25f9 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;
@@ -307,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;
@@ -316,9 +314,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;
@@ -330,14 +326,12 @@ 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;
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;
@@ -862,10 +856,7 @@ 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_string_array_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-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-active-connection.c b/libnm/nm-active-connection.c
index 6491cd2c8b..7088e496a4 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"
@@ -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;
}
/**
@@ -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..70c9c813ab 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))
@@ -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;
}
/**
@@ -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..e378c9cc31 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)
@@ -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
@@ -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..cb9cb2ad46 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)
@@ -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
@@ -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..27deda8a5a 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)
@@ -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 *
@@ -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..7252672f2d 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)
@@ -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;
}
/**
@@ -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..fc5793acb2 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)
@@ -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;
}
/**
@@ -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 de6a679402..1eff7386d6 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"
@@ -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 },
@@ -376,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);
}
@@ -418,7 +410,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,18 +461,13 @@ 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));
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));
@@ -749,14 +735,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:
@@ -773,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));
@@ -1330,21 +1318,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;
}
/**
@@ -1380,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-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);
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 298a2198a2..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)
@@ -38,10 +38,10 @@ typedef struct {
char *gateway;
GSList *addresses;
GSList *routes;
- GArray *nameservers;
- GPtrArray *domains;
- GPtrArray *searches;
- GArray *wins;
+ char **nameservers;
+ char **domains;
+ char **searches;
+ char **wins;
} NMIP4ConfigPrivate;
enum {
@@ -60,6 +60,12 @@ enum {
static void
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
@@ -79,22 +85,28 @@ 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);
- return TRUE;
-}
+ obj_field = field;
+ if (*obj_field)
+ g_strfreev (*obj_field);
-static gboolean
-demarshal_string_array (NMObject *object, GParamSpec *pspec, GValue *value, gpointer field)
-{
- if (!_nm_string_array_demarshal (value, (GPtrArray **) field))
- return FALSE;
+ *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;
@@ -123,8 +135,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 },
};
@@ -147,21 +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);
-
- 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->nameservers);
+ g_strfreev (priv->domains);
+ g_strfreev (priv->searches);
+ g_strfreev (priv->wins);
g_object_unref (priv->proxy);
@@ -182,22 +183,26 @@ 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, 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, 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));
+ 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);
@@ -236,70 +241,72 @@ 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:
*
- * 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));
/**
* 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));
/**
* 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));
}
@@ -343,16 +350,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;
}
/**
@@ -361,32 +366,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;
}
/**
@@ -399,12 +402,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 7c1f039345..c07ea7cc06 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 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 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 7d34171601..91ca675e69 100644
--- a/libnm/nm-ip6-config.c
+++ b/libnm/nm-ip6-config.c
@@ -24,9 +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)
@@ -38,9 +39,9 @@ typedef struct {
char *gateway;
GSList *addresses;
GSList *routes;
- GSList *nameservers;
- GPtrArray *domains;
- GPtrArray *searches;
+ char **nameservers;
+ char **domains;
+ char **searches;
} NMIP6ConfigPrivate;
enum {
@@ -72,32 +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);
- return TRUE;
-}
+ obj_field = field;
+ if (*obj_field)
+ g_strfreev (*obj_field);
-static gboolean
-demarshal_domains (NMObject *object, GParamSpec *pspec, GValue *value, gpointer field)
-{
- if (!_nm_string_array_demarshal (value, (GPtrArray **) field))
- return FALSE;
+ *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;
- _nm_object_queue_notify (object, NM_IP6_CONFIG_DOMAINS);
- return TRUE;
-}
+ str = nm_utils_inet6_ntop ((struct in6_addr *) ip->data, NULL);
+ (*obj_field)[i] = g_strdup (str);
+ }
+ (*obj_field)[i] = NULL;
-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);
+ _nm_object_queue_notify (object, pspec->name);
return TRUE;
}
@@ -124,8 +123,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 },
};
@@ -172,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;
}
/**
@@ -240,32 +192,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;
}
/**
@@ -295,17 +245,10 @@ 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);
- 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->nameservers);
+ g_strfreev (priv->domains);
+ g_strfreev (priv->searches);
g_object_unref (priv->proxy);
@@ -326,19 +269,23 @@ 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, 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, 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 +296,11 @@ get_property (GObject *object,
static void
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);
}
static void
@@ -382,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));
@@ -416,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));
@@ -428,7 +376,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 +388,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..52320005fd 100644
--- a/libnm/nm-ip6-config.h
+++ b/libnm/nm-ip6-config.h
@@ -62,11 +62,9 @@ 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 GPtrArray * nm_ip6_config_get_domains (NMIP6Config *config);
-const GPtrArray * nm_ip6_config_get_searches (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);
G_END_DECLS
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/nm-object.c b/libnm/nm-object.c
index a8544a1100..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;
@@ -806,7 +805,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 +842,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 +856,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;
@@ -1142,6 +1141,18 @@ 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);
+ } 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-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
deleted file mode 100644
index 9979f6c9fd..0000000000
--- a/libnm/nm-types-private.h
+++ /dev/null
@@ -1,37 +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_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,
- 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
deleted file mode 100644
index cb0ff8ba6c..0000000000
--- a/libnm/nm-types.c
+++ /dev/null
@@ -1,419 +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_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)
-{
- 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_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)
-{
- 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)
-{
- 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_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)
-{
- 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 a50f83c7c7..0000000000
--- a/libnm/nm-types.h
+++ /dev/null
@@ -1,58 +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_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;
-
-#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;
-
-#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;
-
-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)
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);