Commit 5afcee46 authored by Dan Winship's avatar Dan Winship Committed by Dan Williams

libnm-glib: simplify property getter methods

Rather than having every property getter method have code to fetch
that specific property's value, just call the new
_nm_object_ensure_inited() (which makes sure that we've read all the
property values on the object at least once), and then return the
cached value. (After we've read the initial property values, the
PropertiesChanged signal handler will ensure that the values are kept
up to date, so we can always just return cached property values after
that point.)

This then lets us get rid of _nm_object_get_property() and its
wrappers.
parent 2e48cc09
......@@ -113,19 +113,10 @@ nm_access_point_new (DBusGConnection *connection, const char *path)
NM80211ApFlags
nm_access_point_get_flags (NMAccessPoint *ap)
{
NMAccessPointPrivate *priv;
g_return_val_if_fail (NM_IS_ACCESS_POINT (ap), NM_802_11_AP_FLAGS_NONE);
priv = NM_ACCESS_POINT_GET_PRIVATE (ap);
if (!priv->flags) {
priv->flags = _nm_object_get_uint_property (NM_OBJECT (ap),
NM_DBUS_INTERFACE_ACCESS_POINT,
DBUS_PROP_FLAGS,
NULL);
}
return priv->flags;
_nm_object_ensure_inited (NM_OBJECT (ap));
return NM_ACCESS_POINT_GET_PRIVATE (ap)->flags;
}
/**
......@@ -139,19 +130,10 @@ nm_access_point_get_flags (NMAccessPoint *ap)
NM80211ApSecurityFlags
nm_access_point_get_wpa_flags (NMAccessPoint *ap)
{
NMAccessPointPrivate *priv;
g_return_val_if_fail (NM_IS_ACCESS_POINT (ap), NM_802_11_AP_SEC_NONE);
priv = NM_ACCESS_POINT_GET_PRIVATE (ap);
if (!priv->wpa_flags) {
priv->wpa_flags = _nm_object_get_uint_property (NM_OBJECT (ap),
NM_DBUS_INTERFACE_ACCESS_POINT,
DBUS_PROP_WPA_FLAGS,
NULL);
}
return priv->wpa_flags;
_nm_object_ensure_inited (NM_OBJECT (ap));
return NM_ACCESS_POINT_GET_PRIVATE (ap)->wpa_flags;
}
/**
......@@ -166,19 +148,10 @@ nm_access_point_get_wpa_flags (NMAccessPoint *ap)
NM80211ApSecurityFlags
nm_access_point_get_rsn_flags (NMAccessPoint *ap)
{
NMAccessPointPrivate *priv;
g_return_val_if_fail (NM_IS_ACCESS_POINT (ap), NM_802_11_AP_SEC_NONE);
priv = NM_ACCESS_POINT_GET_PRIVATE (ap);
if (!priv->rsn_flags) {
priv->rsn_flags = _nm_object_get_uint_property (NM_OBJECT (ap),
NM_DBUS_INTERFACE_ACCESS_POINT,
DBUS_PROP_RSN_FLAGS,
NULL);
}
return priv->rsn_flags;
_nm_object_ensure_inited (NM_OBJECT (ap));
return NM_ACCESS_POINT_GET_PRIVATE (ap)->rsn_flags;
}
/**
......@@ -193,19 +166,10 @@ nm_access_point_get_rsn_flags (NMAccessPoint *ap)
const GByteArray *
nm_access_point_get_ssid (NMAccessPoint *ap)
{
NMAccessPointPrivate *priv;
g_return_val_if_fail (NM_IS_ACCESS_POINT (ap), NULL);
priv = NM_ACCESS_POINT_GET_PRIVATE (ap);
if (!priv->ssid) {
priv->ssid = _nm_object_get_byte_array_property (NM_OBJECT (ap),
NM_DBUS_INTERFACE_ACCESS_POINT,
DBUS_PROP_SSID,
NULL);
}
return priv->ssid;
_nm_object_ensure_inited (NM_OBJECT (ap));
return NM_ACCESS_POINT_GET_PRIVATE (ap)->ssid;
}
/**
......@@ -219,19 +183,10 @@ nm_access_point_get_ssid (NMAccessPoint *ap)
guint32
nm_access_point_get_frequency (NMAccessPoint *ap)
{
NMAccessPointPrivate *priv;
g_return_val_if_fail (NM_IS_ACCESS_POINT (ap), 0);
priv = NM_ACCESS_POINT_GET_PRIVATE (ap);
if (!priv->frequency) {
priv->frequency = _nm_object_get_uint_property (NM_OBJECT (ap),
NM_DBUS_INTERFACE_ACCESS_POINT,
DBUS_PROP_FREQUENCY,
NULL);
}
return priv->frequency;
_nm_object_ensure_inited (NM_OBJECT (ap));
return NM_ACCESS_POINT_GET_PRIVATE (ap)->frequency;
}
/**
......@@ -246,19 +201,10 @@ nm_access_point_get_frequency (NMAccessPoint *ap)
const char *
nm_access_point_get_bssid (NMAccessPoint *ap)
{
NMAccessPointPrivate *priv;
g_return_val_if_fail (NM_IS_ACCESS_POINT (ap), NULL);
priv = NM_ACCESS_POINT_GET_PRIVATE (ap);
if (!priv->bssid) {
priv->bssid = _nm_object_get_string_property (NM_OBJECT (ap),
NM_DBUS_INTERFACE_ACCESS_POINT,
DBUS_PROP_HW_ADDRESS,
NULL);
}
return priv->bssid;
_nm_object_ensure_inited (NM_OBJECT (ap));
return NM_ACCESS_POINT_GET_PRIVATE (ap)->bssid;
}
/**
......@@ -289,19 +235,10 @@ nm_access_point_get_hw_address (NMAccessPoint *ap)
NM80211Mode
nm_access_point_get_mode (NMAccessPoint *ap)
{
NMAccessPointPrivate *priv;
g_return_val_if_fail (NM_IS_ACCESS_POINT (ap), 0);
priv = NM_ACCESS_POINT_GET_PRIVATE (ap);
if (!priv->mode) {
priv->mode = _nm_object_get_uint_property (NM_OBJECT (ap),
NM_DBUS_INTERFACE_ACCESS_POINT,
DBUS_PROP_MODE,
NULL);
}
return priv->mode;
_nm_object_ensure_inited (NM_OBJECT (ap));
return NM_ACCESS_POINT_GET_PRIVATE (ap)->mode;
}
/**
......@@ -315,19 +252,10 @@ nm_access_point_get_mode (NMAccessPoint *ap)
guint32
nm_access_point_get_max_bitrate (NMAccessPoint *ap)
{
NMAccessPointPrivate *priv;
g_return_val_if_fail (NM_IS_ACCESS_POINT (ap), 0);
priv = NM_ACCESS_POINT_GET_PRIVATE (ap);
if (!priv->max_bitrate) {
priv->max_bitrate = _nm_object_get_uint_property (NM_OBJECT (ap),
NM_DBUS_INTERFACE_ACCESS_POINT,
DBUS_PROP_MAX_BITRATE,
NULL);
}
return priv->max_bitrate;
_nm_object_ensure_inited (NM_OBJECT (ap));
return NM_ACCESS_POINT_GET_PRIVATE (ap)->max_bitrate;
}
/**
......@@ -341,19 +269,10 @@ nm_access_point_get_max_bitrate (NMAccessPoint *ap)
guint8
nm_access_point_get_strength (NMAccessPoint *ap)
{
NMAccessPointPrivate *priv;
g_return_val_if_fail (NM_IS_ACCESS_POINT (ap), 0);
priv = NM_ACCESS_POINT_GET_PRIVATE (ap);
if (!priv->strength) {
priv->strength = _nm_object_get_byte_property (NM_OBJECT (ap),
NM_DBUS_INTERFACE_ACCESS_POINT,
DBUS_PROP_STRENGTH,
NULL);
}
return priv->strength;
_nm_object_ensure_inited (NM_OBJECT (ap));
return NM_ACCESS_POINT_GET_PRIVATE (ap)->strength;
}
/**
......
......@@ -107,19 +107,10 @@ nm_active_connection_new (DBusGConnection *connection, const char *path)
const char *
nm_active_connection_get_connection (NMActiveConnection *connection)
{
NMActiveConnectionPrivate *priv;
g_return_val_if_fail (NM_IS_ACTIVE_CONNECTION (connection), NULL);
priv = NM_ACTIVE_CONNECTION_GET_PRIVATE (connection);
if (!priv->connection) {
priv->connection = _nm_object_get_string_property (NM_OBJECT (connection),
NM_DBUS_INTERFACE_ACTIVE_CONNECTION,
DBUS_PROP_CONNECTION,
NULL);
}
return priv->connection;
_nm_object_ensure_inited (NM_OBJECT (connection));
return NM_ACTIVE_CONNECTION_GET_PRIVATE (connection)->connection;
}
/**
......@@ -134,19 +125,10 @@ nm_active_connection_get_connection (NMActiveConnection *connection)
const char *
nm_active_connection_get_uuid (NMActiveConnection *connection)
{
NMActiveConnectionPrivate *priv;
g_return_val_if_fail (NM_IS_ACTIVE_CONNECTION (connection), NULL);
priv = NM_ACTIVE_CONNECTION_GET_PRIVATE (connection);
if (!priv->uuid) {
priv->uuid = _nm_object_get_string_property (NM_OBJECT (connection),
NM_DBUS_INTERFACE_ACTIVE_CONNECTION,
DBUS_PROP_UUID,
NULL);
}
return priv->uuid;
_nm_object_ensure_inited (NM_OBJECT (connection));
return NM_ACTIVE_CONNECTION_GET_PRIVATE (connection)->uuid;
}
/**
......@@ -161,19 +143,10 @@ nm_active_connection_get_uuid (NMActiveConnection *connection)
const char *
nm_active_connection_get_specific_object (NMActiveConnection *connection)
{
NMActiveConnectionPrivate *priv;
g_return_val_if_fail (NM_IS_ACTIVE_CONNECTION (connection), NULL);
priv = NM_ACTIVE_CONNECTION_GET_PRIVATE (connection);
if (!priv->specific_object) {
priv->specific_object = _nm_object_get_string_property (NM_OBJECT (connection),
NM_DBUS_INTERFACE_ACTIVE_CONNECTION,
DBUS_PROP_SPECIFIC_OBJECT,
NULL);
}
return priv->specific_object;
_nm_object_ensure_inited (NM_OBJECT (connection));
return NM_ACTIVE_CONNECTION_GET_PRIVATE (connection)->specific_object;
}
/**
......@@ -188,27 +161,10 @@ nm_active_connection_get_specific_object (NMActiveConnection *connection)
const GPtrArray *
nm_active_connection_get_devices (NMActiveConnection *connection)
{
NMActiveConnectionPrivate *priv;
GValue value = { 0, };
g_return_val_if_fail (NM_IS_ACTIVE_CONNECTION (connection), NULL);
priv = NM_ACTIVE_CONNECTION_GET_PRIVATE (connection);
if (priv->devices)
return handle_ptr_array_return (priv->devices);
if (!_nm_object_get_property (NM_OBJECT (connection),
NM_DBUS_INTERFACE_ACTIVE_CONNECTION,
DBUS_PROP_DEVICES,
&value,
NULL)) {
return NULL;
}
demarshal_devices (NM_OBJECT (connection), NULL, &value, &priv->devices);
g_value_unset (&value);
return handle_ptr_array_return (priv->devices);
_nm_object_ensure_inited (NM_OBJECT (connection));
return handle_ptr_array_return (NM_ACTIVE_CONNECTION_GET_PRIVATE (connection)->devices);
}
/**
......@@ -222,19 +178,10 @@ nm_active_connection_get_devices (NMActiveConnection *connection)
NMActiveConnectionState
nm_active_connection_get_state (NMActiveConnection *connection)
{
NMActiveConnectionPrivate *priv;
g_return_val_if_fail (NM_IS_ACTIVE_CONNECTION (connection), NM_ACTIVE_CONNECTION_STATE_UNKNOWN);
priv = NM_ACTIVE_CONNECTION_GET_PRIVATE (connection);
if (!priv->state) {
priv->state = _nm_object_get_uint_property (NM_OBJECT (connection),
NM_DBUS_INTERFACE_ACTIVE_CONNECTION,
DBUS_PROP_STATE,
NULL);
}
return priv->state;
_nm_object_ensure_inited (NM_OBJECT (connection));
return NM_ACTIVE_CONNECTION_GET_PRIVATE (connection)->state;
}
/**
......@@ -249,19 +196,10 @@ nm_active_connection_get_state (NMActiveConnection *connection)
gboolean
nm_active_connection_get_default (NMActiveConnection *connection)
{
NMActiveConnectionPrivate *priv;
g_return_val_if_fail (NM_IS_ACTIVE_CONNECTION (connection), FALSE);
priv = NM_ACTIVE_CONNECTION_GET_PRIVATE (connection);
if (!priv->is_default) {
priv->is_default = _nm_object_get_boolean_property (NM_OBJECT (connection),
NM_DBUS_INTERFACE_ACTIVE_CONNECTION,
DBUS_PROP_DEFAULT,
NULL);
}
return priv->is_default;
_nm_object_ensure_inited (NM_OBJECT (connection));
return NM_ACTIVE_CONNECTION_GET_PRIVATE (connection)->is_default;
}
/**
......@@ -276,19 +214,10 @@ nm_active_connection_get_default (NMActiveConnection *connection)
gboolean
nm_active_connection_get_default6 (NMActiveConnection *connection)
{
NMActiveConnectionPrivate *priv;
g_return_val_if_fail (NM_IS_ACTIVE_CONNECTION (connection), FALSE);
priv = NM_ACTIVE_CONNECTION_GET_PRIVATE (connection);
if (!priv->is_default6) {
priv->is_default6 = _nm_object_get_boolean_property (NM_OBJECT (connection),
NM_DBUS_INTERFACE_ACTIVE_CONNECTION,
DBUS_PROP_DEFAULT6,
NULL);
}
return priv->is_default6;
_nm_object_ensure_inited (NM_OBJECT (connection));
return NM_ACTIVE_CONNECTION_GET_PRIVATE (connection)->is_default6;
}
/**
......@@ -303,19 +232,10 @@ nm_active_connection_get_default6 (NMActiveConnection *connection)
const char *
nm_active_connection_get_master (NMActiveConnection *connection)
{
NMActiveConnectionPrivate *priv;
g_return_val_if_fail (NM_IS_ACTIVE_CONNECTION (connection), NULL);
priv = NM_ACTIVE_CONNECTION_GET_PRIVATE (connection);
if (!priv->master) {
priv->master = _nm_object_get_string_property (NM_OBJECT (connection),
NM_DBUS_INTERFACE_ACTIVE_CONNECTION,
DBUS_PROP_MASTER,
NULL);
}
return priv->master;
_nm_object_ensure_inited (NM_OBJECT (connection));
return NM_ACTIVE_CONNECTION_GET_PRIVATE (connection)->master;
}
static void
......
This diff is collapsed.
......@@ -42,7 +42,6 @@ typedef struct {
char *hw_address;
char *name;
guint32 bt_capabilities;
gboolean bt_capabilities_valid;
gboolean disposed;
} NMDeviceBtPrivate;
......@@ -93,19 +92,10 @@ nm_device_bt_new (DBusGConnection *connection, const char *path)
const char *
nm_device_bt_get_hw_address (NMDeviceBt *device)
{
NMDeviceBtPrivate *priv;
g_return_val_if_fail (NM_IS_DEVICE_BT (device), NULL);
priv = NM_DEVICE_BT_GET_PRIVATE (device);
if (!priv->hw_address) {
priv->hw_address = _nm_object_get_string_property (NM_OBJECT (device),
NM_DBUS_INTERFACE_DEVICE_BLUETOOTH,
DBUS_PROP_HW_ADDRESS,
NULL);
}
return priv->hw_address;
_nm_object_ensure_inited (NM_OBJECT (device));
return NM_DEVICE_BT_GET_PRIVATE (device)->hw_address;
}
/**
......@@ -119,19 +109,10 @@ nm_device_bt_get_hw_address (NMDeviceBt *device)
const char *
nm_device_bt_get_name (NMDeviceBt *device)
{
NMDeviceBtPrivate *priv;
g_return_val_if_fail (NM_IS_DEVICE_BT (device), NULL);
priv = NM_DEVICE_BT_GET_PRIVATE (device);
if (!priv->name) {
priv->name = _nm_object_get_string_property (NM_OBJECT (device),
NM_DBUS_INTERFACE_DEVICE_BLUETOOTH,
DBUS_PROP_NAME,
NULL);
}
return priv->name;
_nm_object_ensure_inited (NM_OBJECT (device));
return NM_DEVICE_BT_GET_PRIVATE (device)->name;
}
/**
......@@ -145,20 +126,10 @@ nm_device_bt_get_name (NMDeviceBt *device)
NMBluetoothCapabilities
nm_device_bt_get_capabilities (NMDeviceBt *device)
{
NMDeviceBtPrivate *priv;
g_return_val_if_fail (NM_IS_DEVICE_BT (device), NM_BT_CAPABILITY_NONE);
priv = NM_DEVICE_BT_GET_PRIVATE (device);
if (!priv->bt_capabilities_valid) {
priv->bt_capabilities = _nm_object_get_uint_property (NM_OBJECT (device),
NM_DBUS_INTERFACE_DEVICE_BLUETOOTH,
DBUS_PROP_BT_CAPABILITIES,
NULL);
priv->bt_capabilities_valid = TRUE;
}
return priv->bt_capabilities;
_nm_object_ensure_inited (NM_OBJECT (device));
return NM_DEVICE_BT_GET_PRIVATE (device)->bt_capabilities;
}
static NMBluetoothCapabilities
......
......@@ -44,7 +44,6 @@ typedef struct {
char *perm_hw_address;
guint32 speed;
gboolean carrier;
gboolean carrier_valid;
gboolean disposed;
} NMDeviceEthernetPrivate;
......@@ -97,19 +96,10 @@ nm_device_ethernet_new (DBusGConnection *connection, const char *path)
const char *
nm_device_ethernet_get_hw_address (NMDeviceEthernet *device)
{
NMDeviceEthernetPrivate *priv;
g_return_val_if_fail (NM_IS_DEVICE_ETHERNET (device), NULL);
priv = NM_DEVICE_ETHERNET_GET_PRIVATE (device);
if (!priv->hw_address) {
priv->hw_address = _nm_object_get_string_property (NM_OBJECT (device),
NM_DBUS_INTERFACE_DEVICE_WIRED,
DBUS_PROP_HW_ADDRESS,
NULL);
}
return priv->hw_address;
_nm_object_ensure_inited (NM_OBJECT (device));
return NM_DEVICE_ETHERNET_GET_PRIVATE (device)->hw_address;
}
/**
......@@ -124,19 +114,10 @@ nm_device_ethernet_get_hw_address (NMDeviceEthernet *device)
const char *
nm_device_ethernet_get_permanent_hw_address (NMDeviceEthernet *device)
{
NMDeviceEthernetPrivate *priv;
g_return_val_if_fail (NM_IS_DEVICE_ETHERNET (device), NULL);
priv = NM_DEVICE_ETHERNET_GET_PRIVATE (device);
if (!priv->perm_hw_address) {
priv->perm_hw_address = _nm_object_get_string_property (NM_OBJECT (device),
NM_DBUS_INTERFACE_DEVICE_WIRED,
DBUS_PROP_PERM_HW_ADDRESS,
NULL);
}
return priv->perm_hw_address;
_nm_object_ensure_inited (NM_OBJECT (device));
return NM_DEVICE_ETHERNET_GET_PRIVATE (device)->perm_hw_address;
}
/**
......@@ -150,19 +131,10 @@ nm_device_ethernet_get_permanent_hw_address (NMDeviceEthernet *device)
guint32
nm_device_ethernet_get_speed (NMDeviceEthernet *device)
{
NMDeviceEthernetPrivate *priv;
g_return_val_if_fail (NM_IS_DEVICE_ETHERNET (device), 0);
priv = NM_DEVICE_ETHERNET_GET_PRIVATE (device);
if (!priv->speed) {
priv->speed = _nm_object_get_uint_property (NM_OBJECT (device),
NM_DBUS_INTERFACE_DEVICE_WIRED,
DBUS_PROP_SPEED,
NULL);
}
return priv->speed;
_nm_object_ensure_inited (NM_OBJECT (device));
return NM_DEVICE_ETHERNET_GET_PRIVATE (device)->speed;
}
/**
......@@ -176,20 +148,10 @@ nm_device_ethernet_get_speed (NMDeviceEthernet *device)
gboolean
nm_device_ethernet_get_carrier (NMDeviceEthernet *device)
{
NMDeviceEthernetPrivate *priv;
g_return_val_if_fail (NM_IS_DEVICE_ETHERNET (device), FALSE);
priv = NM_DEVICE_ETHERNET_GET_PRIVATE (device);
if (!priv->carrier_valid) {
priv->carrier = _nm_object_get_boolean_property (NM_OBJECT (device),
NM_DBUS_INTERFACE_DEVICE_WIRED,
DBUS_PROP_CARRIER,
NULL);
priv->carrier_valid = TRUE;
}
return priv->carrier;
_nm_object_ensure_inited (NM_OBJECT (device));
return NM_DEVICE_ETHERNET_GET_PRIVATE (device)->carrier;
}
static gboolean
......@@ -243,7 +205,6 @@ nm_device_ethernet_init (NMDeviceEthernet *device)
priv->disposed = FALSE;
priv->carrier = FALSE;
priv->carrier_valid = FALSE;
}
static void
......
......@@ -43,7 +43,6 @@ typedef struct {
char *hw_address;
gboolean carrier;
gboolean carrier_valid;
} NMDeviceInfinibandPrivate;
enum {
......@@ -90,19 +89,10 @@ nm_device_infiniband_new (DBusGConnection *connection, const char *path)
const char *
nm_device_infiniband_get_hw_address (NMDeviceInfiniband *device)
{
NMDeviceInfinibandPrivate *priv;
g_return_val_if_fail (NM_IS_DEVICE_INFINIBAND (device), NULL);
priv = NM_DEVICE_INFINIBAND_GET_PRIVATE (device);
if (!priv->hw_address) {
priv->hw_address = _nm_object_get_string_property (NM_OBJECT (device),
NM_DBUS_INTERFACE_DEVICE_INFINIBAND,
DBUS_PROP_HW_ADDRESS,
NULL);
}
return priv->hw_address;
_nm_object_ensure_inited (NM_OBJECT (device));
return NM_DEVICE_INFINIBAND_GET_PRIVATE (device)->hw_address;
}
/**
......@@ -116,20 +106,10 @@ nm_device_infiniband_get_hw_address (NMDeviceInfiniband *device)
gboolean
nm_device_infiniband_get_carrier (NMDeviceInfiniband *device)
{
NMDeviceInfinibandPrivate *priv;
g_return_val_if_fail (NM_IS_DEVICE_INFINIBAND (device), FALSE);
priv = NM_DEVICE_INFINIBAND_GET_PRIVATE (device);
if (!priv->carrier_valid) {
priv->carrier = _nm_object_get_boolean_property (NM_OBJECT (device),
NM_DBUS_INTERFACE_DEVICE_INFINIBAND,
DBUS_PROP_CARRIER,
NULL);
priv->carrier_valid = TRUE;
}
return priv->carrier;
_nm_object_ensure_inited (NM_OBJECT (device));
return NM_DEVICE_INFINIBAND_GET_PRIVATE (device)->carrier;
}
static gboolean
......@@ -171,7 +151,6 @@ nm_device_infiniband_init (NMDeviceInfiniband *device)
NMDeviceInfinibandPrivate *priv = NM_DEVICE_INFINIBAND_GET_PRIVATE (device);
priv->carrier = FALSE;
priv->carrier_valid = FALSE;
}
static void
......
......@@ -71,20 +71,11 @@ enum {
NMDeviceModemCapabilities
nm_device_modem_get_modem_capabilities (NMDeviceModem *self)
{
NMDeviceModemPrivate *priv;
g_return_val_if_fail (self != NULL, NM_DEVICE_MODEM_CAPABILITY_NONE);
g_return_val_if_fail (NM_IS_DEVICE_MODEM (self), NM_DEVICE_MODEM_CAPABILITY_NONE);
priv = NM_DEVICE_MODEM_GET_PRIVATE (self);
if (!priv->caps) {
priv->caps = _nm_object_get_uint_property (NM_OBJECT (self),
NM_DBUS_INTERFACE_DEVICE_MODEM,
DBUS_PROP_MODEM_CAPS,
NULL);
}
return priv->caps;
_nm_object_ensure_inited (NM_OBJECT (self));
return NM_DEVICE_MODEM_GET_PRIVATE (self)->caps;
}
/**
......@@ -101,20 +92,11 @@ nm_device_modem_get_modem_capabilities (NMDeviceModem *self)
NMDeviceModemCapabilities
nm_device_modem_get_current_capabilities (NMDeviceModem *self)
{
NMDeviceModemPrivate *priv;
g_return_val_if_fail (self != NULL, NM_DEVICE_MODEM_CAPABILITY_NONE);
g_return_val_if_fail (NM_IS_DEVICE_MODEM (self), NM_DEVICE_MODEM_CAPABILITY_NONE);
priv = NM_DEVICE_MODEM_GET_PRIVATE (self);
if (!priv->current_caps) {
priv->current_caps = _nm_object_get_uint_property (NM_OBJECT (self),
NM_DBUS_INTERFACE_DEVICE_MODEM,
DBUS_PROP_CURRENT_CAPS,
NULL);
}
return priv->current_caps;
_nm_object_ensure_inited (NM_OBJECT (self));
return NM_DEVICE_MODEM_GET_PRIVATE (self)->current_caps;
}
static gboolean
......
......@@ -53,7 +53,6 @@ typedef struct {
NM80211Mode mode;
guint32 rate;
NMAccessPoint *active_ap;
gboolean got_active_ap;
NMDeviceWifiCapabilities wireless_caps;
GPtrArray *aps;
......@@ -121,19 +120,10 @@ nm_device_wifi_new (DBusGConnection *connection, const char *path)
const char *
nm_device_wifi_get_hw_address (NMDeviceWifi *device)
{
NMDeviceWifiPrivate *priv;
g_return_val_if_fail (NM_IS_DEVICE_WIFI (device), NULL);
priv = NM_DEVICE_WIFI_GET_PRIVATE (device);
if (!priv->hw_address) {
priv->hw_address = _nm_object_get_string_property (NM_OBJECT (device),
NM_DBUS_INTERFACE_DEVICE_WIRELESS,
DBUS_PROP_HW_ADDRESS,
NULL);
}
return priv->hw_address;
_nm_object_ensure_inited (NM_OBJECT (device));
return NM_DEVICE_WIFI_GET_PRIVATE (device)->hw_address;
}
/**
......@@ -148,19 +138,10 @@ nm_device_wifi_get_hw_address (NMDeviceWifi *device)
const char *
nm_device_wifi_get_permanent_hw_address (NMDeviceWifi *device)
{
NMDeviceWifiPrivate *priv;
g_return_val_if_fail (NM_IS_DEVICE_WIFI (device), NULL);
priv = NM_DEVICE_WIFI_GET_PRIVATE (device);
if (!priv->perm_hw_address) {
priv->perm_hw_address = _nm_object_get_string_property (NM_OBJECT (device),
NM_DBUS_INTERFACE_DEVICE_WIRELESS,
DBUS_PROP_PERM_HW_ADDRESS,
NULL);
}
return priv->perm_hw_address;
_nm_object_ensure_inited (NM_OBJECT (device));
return NM_DEVICE_WIFI_GET_PRIVATE (device)->perm_hw_address;
}
/**
......@@ -174,19 +155,10 @@ nm_device_wifi_get_permanent_hw_address (NMDeviceWifi *device)
NM80211Mode
nm_device_wifi_get_mode (NMDeviceWifi *device)
{
NMDeviceWifiPrivate *priv;
g_return_val_if_fail (NM_IS_DEVICE_WIFI (device), 0);
priv = NM_DEVICE_WIFI_GET_PRIVATE (device);
if (!priv->mode) {
priv->mode = _nm_object_get_uint_property (NM_OBJECT (device),
NM_DBUS_INTERFACE_DEVICE_WIRELESS,
DBUS_PROP_MODE,
NULL);
}
return priv->mode;
_nm_object_ensure_inited (NM_OBJECT (device));
return NM_DEVICE_WIFI_GET_PRIVATE (device)->mode;
}
/**
......@@ -200,7 +172,6 @@ nm_device_wifi_get_mode (NMDeviceWifi *device)
guint32
nm_device_wifi_get_bitrate (NMDeviceWifi *device)
{
NMDeviceWifiPrivate *priv;
NMDeviceState state;
g_return_val_if_fail (NM_IS_DEVICE_WIFI (device), 0);
......@@ -217,15 +188,8 @@ nm_device_wifi_get_bitrate (NMDeviceWifi *device)
return 0;