diff options
author | Thomas Haller <thaller@redhat.com> | 2016-05-17 13:08:09 +0200 |
---|---|---|
committer | Thomas Haller <thaller@redhat.com> | 2016-05-17 13:24:51 +0200 |
commit | 1ad00095a1b0853917efe9d9aa69f14dfa7fe07b (patch) | |
tree | 031654a4cabe5503b7c63cccc39efc07f2219fee | |
parent | 5586ae80d1a8f802bc865d8cd9f03e8e6cb04193 (diff) | |
download | NetworkManager-1ad00095a1b0853917efe9d9aa69f14dfa7fe07b.tar.gz |
wifi: refactor private data for NMAccessPoint
- make NMAccessPoint and NMAccessPointClass internal structs. This means,
they cannot be subclassed anymore, but we also don't want that.
- This way, we can safely embed the private data directly in the now
private access-point instance.
- change type of boolean fields from gboolean to bool.
- some whitespace fixes
-rw-r--r-- | src/devices/wifi/nm-wifi-ap.c | 48 | ||||
-rw-r--r-- | src/devices/wifi/nm-wifi-ap.h | 10 |
2 files changed, 35 insertions, 23 deletions
diff --git a/src/devices/wifi/nm-wifi-ap.c b/src/devices/wifi/nm-wifi-ap.c index 8d968c96a8..f44ad42f29 100644 --- a/src/devices/wifi/nm-wifi-ap.c +++ b/src/devices/wifi/nm-wifi-ap.c @@ -42,24 +42,44 @@ typedef struct char *supplicant_path; /* D-Bus object path of this AP from wpa_supplicant */ /* Scanned or cached values */ - GByteArray * ssid; - char * address; - NM80211Mode mode; - guint8 strength; - guint32 freq; /* Frequency in MHz; ie 2412 (== 2.412 GHz) */ - guint32 max_bitrate;/* Maximum bitrate of the AP in Kbit/s (ie 54000 Kb/s == 54Mbit/s) */ + GByteArray * ssid; + char * address; + NM80211Mode mode; + guint8 strength; + guint32 freq; /* Frequency in MHz; ie 2412 (== 2.412 GHz) */ + guint32 max_bitrate; /* Maximum bitrate of the AP in Kbit/s (ie 54000 Kb/s == 54Mbit/s) */ NM80211ApFlags flags; /* General flags */ NM80211ApSecurityFlags wpa_flags; /* WPA-related flags */ NM80211ApSecurityFlags rsn_flags; /* RSN (WPA2) -related flags */ /* Non-scanned attributes */ - gboolean fake; /* Whether or not the AP is from a scan */ - gboolean hotspot; /* Whether the AP is a local device's hotspot network */ + bool fake; /* Whether or not the AP is from a scan */ + bool hotspot; /* Whether the AP is a local device's hotspot network */ gint32 last_seen; /* Timestamp when the AP was seen lastly (obtained via nm_utils_get_monotonic_timestamp_s()) */ } NMAccessPointPrivate; -#define NM_AP_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), NM_TYPE_AP, NMAccessPointPrivate)) +struct _NMAccessPoint { + NMExportedObject parent; + NMAccessPointPrivate _priv; +}; + +struct _NMAccessPointClass{ + NMExportedObjectClass parent; +}; + +#define NM_AP_GET_PRIVATE(self) \ + ({ \ + /* preserve the const-ness of self. Unfortunately, that + * way, @self cannot be a void pointer */ \ + typeof (self) _self = (self); \ + \ + /* Get compiler error if variable is of wrong type */ \ + _nm_unused const NMAccessPoint *_self2 = (_self); \ + \ + nm_assert (NM_IS_AP (_self)); \ + &_self->_priv; \ + }) G_DEFINE_TYPE (NMAccessPoint, nm_ap, NM_TYPE_EXPORTED_OBJECT) @@ -877,7 +897,7 @@ nm_ap_init (NMAccessPoint *ap) static void finalize (GObject *object) { - NMAccessPointPrivate *priv = NM_AP_GET_PRIVATE (object); + NMAccessPointPrivate *priv = NM_AP_GET_PRIVATE ((NMAccessPoint *) object); g_free (priv->supplicant_path); if (priv->ssid) @@ -889,16 +909,16 @@ finalize (GObject *object) static void set_property (GObject *object, guint prop_id, - const GValue *value, GParamSpec *pspec) + const GValue *value, GParamSpec *pspec) { G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); } static void get_property (GObject *object, guint prop_id, - GValue *value, GParamSpec *pspec) + GValue *value, GParamSpec *pspec) { - NMAccessPointPrivate *priv = NM_AP_GET_PRIVATE (object); + NMAccessPointPrivate *priv = NM_AP_GET_PRIVATE ((NMAccessPoint *) object); GVariant *ssid; switch (prop_id) { @@ -963,8 +983,6 @@ nm_ap_class_init (NMAccessPointClass *ap_class) | NM_802_11_AP_SEC_KEY_MGMT_PSK | NM_802_11_AP_SEC_KEY_MGMT_802_1X; - g_type_class_add_private (ap_class, sizeof (NMAccessPointPrivate)); - exported_object_class->export_path = NM_DBUS_PATH_ACCESS_POINT "/%u"; /* virtual methods */ diff --git a/src/devices/wifi/nm-wifi-ap.h b/src/devices/wifi/nm-wifi-ap.h index 84aff983c2..035d1b5e57 100644 --- a/src/devices/wifi/nm-wifi-ap.h +++ b/src/devices/wifi/nm-wifi-ap.h @@ -44,14 +44,8 @@ #define NM_AP_STRENGTH "strength" #define NM_AP_LAST_SEEN "last-seen" -typedef struct { - NMExportedObject parent; -} NMAccessPoint; - -typedef struct { - NMExportedObjectClass parent; - -} NMAccessPointClass; +typedef struct _NMAccessPoint NMAccessPoint; +typedef struct _NMAccessPointClass NMAccessPointClass; GType nm_ap_get_type (void); |