2007-10-12 10:18:46 +00:00
|
|
|
/* -*- Mode: C; tab-width: 5; indent-tabs-mode: t; c-basic-offset: 5 -*- */
|
|
|
|
|
|
2007-09-19 20:44:37 +00:00
|
|
|
#include <iwlib.h>
|
|
|
|
|
|
2007-02-12 09:23:43 +00:00
|
|
|
#include "nm-access-point.h"
|
|
|
|
|
#include "NetworkManager.h"
|
|
|
|
|
|
|
|
|
|
#include "nm-access-point-bindings.h"
|
|
|
|
|
|
2007-06-22 15:09:02 +00:00
|
|
|
G_DEFINE_TYPE (NMAccessPoint, nm_access_point, NM_TYPE_OBJECT)
|
2007-02-12 09:23:43 +00:00
|
|
|
|
2007-03-02 Tambet Ingo <tambet@ximian.com>
* libnm-glib/nm-device-802-11-wireless.c: Cache networks (bssids) list.
We get signalled when it changes.
* libnm-glib/nm-client.c: Cache NMState and device list, we get signalled
when it changes.
* libnm-glib/nm-device.c: Cache the device state property.
* libnm-glib/nm-access-point.c: Cache the strength property.
* src/nm-device-802-11-wireless.c: Fix wireless device scanning scheduler.
The new algorithm is to start from SCAN_INTERVAL_MIN (currently defined as 0)
and add a SCAN_INTERVAL_STEP (currently 20 seconds) with each successful scan
until SCAN_INTERVAL_MAX (currently 120 seconds) is reached. Do not scan while
the device is down, activating, or activated (in case of A/B/G cards).
Remove some old dead ifdef'ed out code that used to configure wireless devices,
it's all done through supplicant now.
* src/supplicant-manager/nm-supplicant-interface.c: Fix the reference
counting issues with pending calls which caused leaks and crashes when
interface was removed (now that the interface actually gets removed).
* src/nm-call-store.c: Make a copy of data before running a foreach
with user callback on it - The most common usage pattern is to cancel
(and thus remove) all pending calls with foreach which would modify
the hash table we're iterating over.
* src/nm-manager.c: When a device is added, make sure it is "up". When
it's removed or disabled due to disabling wireless or networking, bring
it down.
* include/NetworkManager.h: Add new device state NM_DEVICE_STATE_DOWN.
* src/nm-device-802-11-wireless.c:
* src/nm-device-802-3-ethernet.c:
* src/nm-device.c:
- Remove "init" virtual function, all gobjects have a place for that
already (constructor).
- Replace "start" virtual function with "bring_up", devices can be
brought up and down more than just on startup now.
- Add "is_up" virtual function.
- Implement one way to bring a device down instead of previous 4 different
ways, each of witch did something different.
* src/NetworkManagerUtils.c (nm_dev_sock_open): This doesn't need an NMDevice,
all it needs is the device interface.
Get rid of NMData.dev_list (3 members to go).
Get rif of NMData in a lot of places.
* gnome/libnm_glib/libnm_glib.c: Make it compile again.
git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@2395 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
2007-03-02 09:30:48 +00:00
|
|
|
#define NM_ACCESS_POINT_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), NM_TYPE_ACCESS_POINT, NMAccessPointPrivate))
|
|
|
|
|
|
|
|
|
|
typedef struct {
|
2007-09-19 20:44:37 +00:00
|
|
|
gboolean disposed;
|
2007-06-22 15:09:02 +00:00
|
|
|
DBusGProxy *ap_proxy;
|
2007-09-19 20:44:37 +00:00
|
|
|
guint32 flags;
|
|
|
|
|
guint32 wpa_flags;
|
|
|
|
|
guint32 rsn_flags;
|
|
|
|
|
GByteArray *ssid;
|
|
|
|
|
guint32 frequency;
|
|
|
|
|
char *hw_address;
|
|
|
|
|
int mode;
|
|
|
|
|
guint32 rate;
|
2007-08-09 09:19:57 +00:00
|
|
|
gint8 strength;
|
2007-03-02 Tambet Ingo <tambet@ximian.com>
* libnm-glib/nm-device-802-11-wireless.c: Cache networks (bssids) list.
We get signalled when it changes.
* libnm-glib/nm-client.c: Cache NMState and device list, we get signalled
when it changes.
* libnm-glib/nm-device.c: Cache the device state property.
* libnm-glib/nm-access-point.c: Cache the strength property.
* src/nm-device-802-11-wireless.c: Fix wireless device scanning scheduler.
The new algorithm is to start from SCAN_INTERVAL_MIN (currently defined as 0)
and add a SCAN_INTERVAL_STEP (currently 20 seconds) with each successful scan
until SCAN_INTERVAL_MAX (currently 120 seconds) is reached. Do not scan while
the device is down, activating, or activated (in case of A/B/G cards).
Remove some old dead ifdef'ed out code that used to configure wireless devices,
it's all done through supplicant now.
* src/supplicant-manager/nm-supplicant-interface.c: Fix the reference
counting issues with pending calls which caused leaks and crashes when
interface was removed (now that the interface actually gets removed).
* src/nm-call-store.c: Make a copy of data before running a foreach
with user callback on it - The most common usage pattern is to cancel
(and thus remove) all pending calls with foreach which would modify
the hash table we're iterating over.
* src/nm-manager.c: When a device is added, make sure it is "up". When
it's removed or disabled due to disabling wireless or networking, bring
it down.
* include/NetworkManager.h: Add new device state NM_DEVICE_STATE_DOWN.
* src/nm-device-802-11-wireless.c:
* src/nm-device-802-3-ethernet.c:
* src/nm-device.c:
- Remove "init" virtual function, all gobjects have a place for that
already (constructor).
- Replace "start" virtual function with "bring_up", devices can be
brought up and down more than just on startup now.
- Add "is_up" virtual function.
- Implement one way to bring a device down instead of previous 4 different
ways, each of witch did something different.
* src/NetworkManagerUtils.c (nm_dev_sock_open): This doesn't need an NMDevice,
all it needs is the device interface.
Get rid of NMData.dev_list (3 members to go).
Get rif of NMData in a lot of places.
* gnome/libnm_glib/libnm_glib.c: Make it compile again.
git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@2395 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
2007-03-02 09:30:48 +00:00
|
|
|
} NMAccessPointPrivate;
|
|
|
|
|
|
2007-02-20 15:24:42 +00:00
|
|
|
enum {
|
2007-09-19 20:44:37 +00:00
|
|
|
PROP_0,
|
|
|
|
|
PROP_FLAGS,
|
|
|
|
|
PROP_WPA_FLAGS,
|
|
|
|
|
PROP_RSN_FLAGS,
|
|
|
|
|
PROP_SSID,
|
|
|
|
|
PROP_FREQUENCY,
|
|
|
|
|
PROP_HW_ADDRESS,
|
|
|
|
|
PROP_MODE,
|
|
|
|
|
PROP_RATE,
|
|
|
|
|
PROP_STRENGTH,
|
|
|
|
|
|
|
|
|
|
LAST_PROP
|
2007-02-20 15:24:42 +00:00
|
|
|
};
|
|
|
|
|
|
2007-09-19 20:44:37 +00:00
|
|
|
#define DBUS_PROP_FLAGS "Flags"
|
|
|
|
|
#define DBUS_PROP_WPA_FLAGS "WpaFlags"
|
|
|
|
|
#define DBUS_PROP_RSN_FLAGS "RsnFlags"
|
|
|
|
|
#define DBUS_PROP_SSID "Ssid"
|
|
|
|
|
#define DBUS_PROP_FREQUENCY "Frequency"
|
|
|
|
|
#define DBUS_PROP_HW_ADDRESS "HwAddress"
|
|
|
|
|
#define DBUS_PROP_MODE "Mode"
|
|
|
|
|
#define DBUS_PROP_RATE "Rate"
|
|
|
|
|
#define DBUS_PROP_STRENGTH "Strength"
|
2007-02-20 15:24:42 +00:00
|
|
|
|
2007-02-12 09:23:43 +00:00
|
|
|
NMAccessPoint *
|
|
|
|
|
nm_access_point_new (DBusGConnection *connection, const char *path)
|
|
|
|
|
{
|
2007-06-22 15:09:02 +00:00
|
|
|
return (NMAccessPoint *) g_object_new (NM_TYPE_ACCESS_POINT,
|
2007-10-12 10:18:46 +00:00
|
|
|
NM_OBJECT_CONNECTION, connection,
|
|
|
|
|
NM_OBJECT_PATH, path,
|
|
|
|
|
NULL);
|
2007-02-20 15:24:42 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
2007-10-12 10:18:46 +00:00
|
|
|
nm_access_point_set_flags (NMAccessPoint *ap, guint32 flags)
|
2007-02-20 15:24:42 +00:00
|
|
|
{
|
2007-03-02 Tambet Ingo <tambet@ximian.com>
* libnm-glib/nm-device-802-11-wireless.c: Cache networks (bssids) list.
We get signalled when it changes.
* libnm-glib/nm-client.c: Cache NMState and device list, we get signalled
when it changes.
* libnm-glib/nm-device.c: Cache the device state property.
* libnm-glib/nm-access-point.c: Cache the strength property.
* src/nm-device-802-11-wireless.c: Fix wireless device scanning scheduler.
The new algorithm is to start from SCAN_INTERVAL_MIN (currently defined as 0)
and add a SCAN_INTERVAL_STEP (currently 20 seconds) with each successful scan
until SCAN_INTERVAL_MAX (currently 120 seconds) is reached. Do not scan while
the device is down, activating, or activated (in case of A/B/G cards).
Remove some old dead ifdef'ed out code that used to configure wireless devices,
it's all done through supplicant now.
* src/supplicant-manager/nm-supplicant-interface.c: Fix the reference
counting issues with pending calls which caused leaks and crashes when
interface was removed (now that the interface actually gets removed).
* src/nm-call-store.c: Make a copy of data before running a foreach
with user callback on it - The most common usage pattern is to cancel
(and thus remove) all pending calls with foreach which would modify
the hash table we're iterating over.
* src/nm-manager.c: When a device is added, make sure it is "up". When
it's removed or disabled due to disabling wireless or networking, bring
it down.
* include/NetworkManager.h: Add new device state NM_DEVICE_STATE_DOWN.
* src/nm-device-802-11-wireless.c:
* src/nm-device-802-3-ethernet.c:
* src/nm-device.c:
- Remove "init" virtual function, all gobjects have a place for that
already (constructor).
- Replace "start" virtual function with "bring_up", devices can be
brought up and down more than just on startup now.
- Add "is_up" virtual function.
- Implement one way to bring a device down instead of previous 4 different
ways, each of witch did something different.
* src/NetworkManagerUtils.c (nm_dev_sock_open): This doesn't need an NMDevice,
all it needs is the device interface.
Get rid of NMData.dev_list (3 members to go).
Get rif of NMData in a lot of places.
* gnome/libnm_glib/libnm_glib.c: Make it compile again.
git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@2395 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
2007-03-02 09:30:48 +00:00
|
|
|
NMAccessPointPrivate *priv = NM_ACCESS_POINT_GET_PRIVATE (ap);
|
2007-09-19 20:44:37 +00:00
|
|
|
|
2007-10-12 10:18:46 +00:00
|
|
|
priv->flags = flags;
|
|
|
|
|
g_object_notify (G_OBJECT (ap), NM_ACCESS_POINT_FLAGS);
|
2007-09-19 20:44:37 +00:00
|
|
|
}
|
|
|
|
|
|
2007-02-16 11:23:49 +00:00
|
|
|
guint32
|
2007-08-28 14:47:31 +00:00
|
|
|
nm_access_point_get_flags (NMAccessPoint *ap)
|
2007-02-12 09:23:43 +00:00
|
|
|
{
|
2007-09-19 20:44:37 +00:00
|
|
|
NMAccessPointPrivate *priv;
|
|
|
|
|
|
2007-08-28 14:47:31 +00:00
|
|
|
g_return_val_if_fail (NM_IS_ACCESS_POINT (ap), NM_802_11_AP_FLAGS_NONE);
|
2007-02-12 09:23:43 +00:00
|
|
|
|
2007-09-19 20:44:37 +00:00
|
|
|
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);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return priv->flags;
|
2007-02-12 09:23:43 +00:00
|
|
|
}
|
|
|
|
|
|
2007-10-12 10:18:46 +00:00
|
|
|
static void
|
|
|
|
|
nm_access_point_set_wpa_flags (NMAccessPoint *ap, guint32 flags)
|
|
|
|
|
{
|
|
|
|
|
NMAccessPointPrivate *priv = NM_ACCESS_POINT_GET_PRIVATE (ap);
|
|
|
|
|
|
|
|
|
|
priv->wpa_flags = flags;
|
|
|
|
|
g_object_notify (G_OBJECT (ap), NM_ACCESS_POINT_WPA_FLAGS);
|
|
|
|
|
}
|
|
|
|
|
|
2007-08-28 14:47:31 +00:00
|
|
|
guint32
|
|
|
|
|
nm_access_point_get_wpa_flags (NMAccessPoint *ap)
|
|
|
|
|
{
|
2007-09-19 20:44:37 +00:00
|
|
|
NMAccessPointPrivate *priv;
|
|
|
|
|
|
2007-08-28 14:47:31 +00:00
|
|
|
g_return_val_if_fail (NM_IS_ACCESS_POINT (ap), NM_802_11_AP_SEC_NONE);
|
|
|
|
|
|
2007-09-19 20:44:37 +00:00
|
|
|
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);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return priv->wpa_flags;
|
2007-08-28 14:47:31 +00:00
|
|
|
}
|
|
|
|
|
|
2007-10-12 10:18:46 +00:00
|
|
|
static void
|
|
|
|
|
nm_access_point_set_rsn_flags (NMAccessPoint *ap, guint32 flags)
|
|
|
|
|
{
|
|
|
|
|
NMAccessPointPrivate *priv = NM_ACCESS_POINT_GET_PRIVATE (ap);
|
|
|
|
|
|
|
|
|
|
priv->rsn_flags = flags;
|
|
|
|
|
g_object_notify (G_OBJECT (ap), NM_ACCESS_POINT_RSN_FLAGS);
|
|
|
|
|
}
|
|
|
|
|
|
2007-08-28 14:47:31 +00:00
|
|
|
guint32
|
|
|
|
|
nm_access_point_get_rsn_flags (NMAccessPoint *ap)
|
2007-02-12 09:23:43 +00:00
|
|
|
{
|
2007-09-19 20:44:37 +00:00
|
|
|
NMAccessPointPrivate *priv;
|
|
|
|
|
|
2007-08-28 14:47:31 +00:00
|
|
|
g_return_val_if_fail (NM_IS_ACCESS_POINT (ap), NM_802_11_AP_SEC_NONE);
|
2007-02-12 09:23:43 +00:00
|
|
|
|
2007-09-19 20:44:37 +00:00
|
|
|
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);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return priv->rsn_flags;
|
2007-02-12 09:23:43 +00:00
|
|
|
}
|
|
|
|
|
|
2007-10-12 10:18:46 +00:00
|
|
|
static void
|
|
|
|
|
nm_access_point_set_ssid (NMAccessPoint *ap, GArray *ssid)
|
|
|
|
|
{
|
|
|
|
|
NMAccessPointPrivate *priv = NM_ACCESS_POINT_GET_PRIVATE (ap);
|
|
|
|
|
|
|
|
|
|
if (priv->ssid) {
|
|
|
|
|
g_byte_array_free (priv->ssid, TRUE);
|
|
|
|
|
priv->ssid = NULL;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (ssid && ssid->len > 0) {
|
|
|
|
|
priv->ssid = g_byte_array_sized_new (ssid->len);
|
|
|
|
|
priv->ssid->len = ssid->len;
|
|
|
|
|
memcpy (priv->ssid->data, ssid->data, ssid->len);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
g_object_notify (G_OBJECT (ap), NM_ACCESS_POINT_SSID);
|
|
|
|
|
}
|
|
|
|
|
|
2007-09-19 20:44:37 +00:00
|
|
|
const GByteArray *
|
2007-06-27 16:18:52 +00:00
|
|
|
nm_access_point_get_ssid (NMAccessPoint *ap)
|
2007-02-12 09:23:43 +00:00
|
|
|
{
|
2007-09-19 20:44:37 +00:00
|
|
|
NMAccessPointPrivate *priv;
|
|
|
|
|
|
2007-02-12 09:23:43 +00:00
|
|
|
g_return_val_if_fail (NM_IS_ACCESS_POINT (ap), NULL);
|
|
|
|
|
|
2007-09-19 20:44:37 +00:00
|
|
|
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);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return priv->ssid;
|
2007-02-12 09:23:43 +00:00
|
|
|
}
|
|
|
|
|
|
2007-10-12 10:18:46 +00:00
|
|
|
static void
|
|
|
|
|
nm_access_point_set_frequency (NMAccessPoint *ap, guint32 frequency)
|
|
|
|
|
{
|
|
|
|
|
NMAccessPointPrivate *priv = NM_ACCESS_POINT_GET_PRIVATE (ap);
|
|
|
|
|
|
|
|
|
|
priv->frequency = frequency;
|
|
|
|
|
g_object_notify (G_OBJECT (ap), NM_ACCESS_POINT_FREQUENCY);
|
|
|
|
|
}
|
|
|
|
|
|
2007-09-11 19:31:59 +00:00
|
|
|
guint32
|
2007-02-12 09:23:43 +00:00
|
|
|
nm_access_point_get_frequency (NMAccessPoint *ap)
|
|
|
|
|
{
|
2007-09-19 20:44:37 +00:00
|
|
|
NMAccessPointPrivate *priv;
|
|
|
|
|
|
2007-06-22 15:09:02 +00:00
|
|
|
g_return_val_if_fail (NM_IS_ACCESS_POINT (ap), 0);
|
2007-02-16 11:23:49 +00:00
|
|
|
|
2007-09-19 20:44:37 +00:00
|
|
|
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);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return priv->frequency;
|
2007-02-12 09:23:43 +00:00
|
|
|
}
|
|
|
|
|
|
2007-10-12 10:18:46 +00:00
|
|
|
static void
|
|
|
|
|
nm_access_point_set_hw_address (NMAccessPoint *ap, const char *address)
|
|
|
|
|
{
|
|
|
|
|
NMAccessPointPrivate *priv = NM_ACCESS_POINT_GET_PRIVATE (ap);
|
|
|
|
|
|
|
|
|
|
g_free (priv->hw_address);
|
|
|
|
|
priv->hw_address = address ? g_strdup (address) : NULL;
|
|
|
|
|
g_object_notify (G_OBJECT (ap), NM_ACCESS_POINT_HW_ADDRESS);
|
|
|
|
|
}
|
|
|
|
|
|
2007-10-05 16:00:06 +00:00
|
|
|
const char *
|
2007-02-12 09:23:43 +00:00
|
|
|
nm_access_point_get_hw_address (NMAccessPoint *ap)
|
|
|
|
|
{
|
2007-09-19 20:44:37 +00:00
|
|
|
NMAccessPointPrivate *priv;
|
|
|
|
|
|
2007-02-12 09:23:43 +00:00
|
|
|
g_return_val_if_fail (NM_IS_ACCESS_POINT (ap), NULL);
|
|
|
|
|
|
2007-09-19 20:44:37 +00:00
|
|
|
priv = NM_ACCESS_POINT_GET_PRIVATE (ap);
|
|
|
|
|
if (!priv->hw_address) {
|
|
|
|
|
priv->hw_address = nm_object_get_string_property (NM_OBJECT (ap),
|
|
|
|
|
NM_DBUS_INTERFACE_ACCESS_POINT,
|
|
|
|
|
DBUS_PROP_HW_ADDRESS);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return priv->hw_address;
|
2007-02-12 09:23:43 +00:00
|
|
|
}
|
|
|
|
|
|
2007-10-12 10:18:46 +00:00
|
|
|
static void
|
|
|
|
|
nm_access_point_set_mode (NMAccessPoint *ap, int mode)
|
|
|
|
|
{
|
|
|
|
|
NMAccessPointPrivate *priv = NM_ACCESS_POINT_GET_PRIVATE (ap);
|
|
|
|
|
|
|
|
|
|
priv->mode = mode;
|
|
|
|
|
g_object_notify (G_OBJECT (ap), NM_ACCESS_POINT_MODE);
|
|
|
|
|
}
|
|
|
|
|
|
2007-02-12 09:23:43 +00:00
|
|
|
int
|
|
|
|
|
nm_access_point_get_mode (NMAccessPoint *ap)
|
|
|
|
|
{
|
2007-09-19 20:44:37 +00:00
|
|
|
NMAccessPointPrivate *priv;
|
|
|
|
|
|
2007-02-12 09:23:43 +00:00
|
|
|
g_return_val_if_fail (NM_IS_ACCESS_POINT (ap), 0);
|
|
|
|
|
|
2007-09-19 20:44:37 +00:00
|
|
|
priv = NM_ACCESS_POINT_GET_PRIVATE (ap);
|
|
|
|
|
if (!priv->mode) {
|
|
|
|
|
priv->mode = nm_object_get_int_property (NM_OBJECT (ap),
|
|
|
|
|
NM_DBUS_INTERFACE_ACCESS_POINT,
|
|
|
|
|
DBUS_PROP_MODE);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return priv->mode;
|
2007-02-12 09:23:43 +00:00
|
|
|
}
|
|
|
|
|
|
2007-10-12 10:18:46 +00:00
|
|
|
static void
|
|
|
|
|
nm_access_point_set_rate (NMAccessPoint *ap, guint32 rate)
|
|
|
|
|
{
|
|
|
|
|
NMAccessPointPrivate *priv = NM_ACCESS_POINT_GET_PRIVATE (ap);
|
|
|
|
|
|
|
|
|
|
priv->rate = rate;
|
|
|
|
|
g_object_notify (G_OBJECT (ap), NM_ACCESS_POINT_RATE);
|
|
|
|
|
}
|
|
|
|
|
|
2007-02-16 11:23:49 +00:00
|
|
|
guint32
|
2007-02-12 09:23:43 +00:00
|
|
|
nm_access_point_get_rate (NMAccessPoint *ap)
|
|
|
|
|
{
|
2007-09-19 20:44:37 +00:00
|
|
|
NMAccessPointPrivate *priv;
|
|
|
|
|
|
2007-02-12 09:23:43 +00:00
|
|
|
g_return_val_if_fail (NM_IS_ACCESS_POINT (ap), 0);
|
|
|
|
|
|
2007-09-19 20:44:37 +00:00
|
|
|
priv = NM_ACCESS_POINT_GET_PRIVATE (ap);
|
|
|
|
|
if (!priv->rate) {
|
|
|
|
|
priv->rate = nm_object_get_uint_property (NM_OBJECT (ap),
|
|
|
|
|
NM_DBUS_INTERFACE_ACCESS_POINT,
|
|
|
|
|
DBUS_PROP_RATE);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return priv->rate;
|
2007-02-12 09:23:43 +00:00
|
|
|
}
|
|
|
|
|
|
2007-10-12 10:18:46 +00:00
|
|
|
static void
|
|
|
|
|
nm_access_point_set_strength (NMAccessPoint *ap, gint8 strength)
|
|
|
|
|
{
|
|
|
|
|
NMAccessPointPrivate *priv = NM_ACCESS_POINT_GET_PRIVATE (ap);
|
|
|
|
|
|
|
|
|
|
priv->strength = strength;
|
|
|
|
|
g_object_notify (G_OBJECT (ap), NM_ACCESS_POINT_STRENGTH);
|
|
|
|
|
}
|
|
|
|
|
|
2007-08-09 09:19:57 +00:00
|
|
|
gint8
|
2007-02-12 09:23:43 +00:00
|
|
|
nm_access_point_get_strength (NMAccessPoint *ap)
|
|
|
|
|
{
|
2007-03-02 Tambet Ingo <tambet@ximian.com>
* libnm-glib/nm-device-802-11-wireless.c: Cache networks (bssids) list.
We get signalled when it changes.
* libnm-glib/nm-client.c: Cache NMState and device list, we get signalled
when it changes.
* libnm-glib/nm-device.c: Cache the device state property.
* libnm-glib/nm-access-point.c: Cache the strength property.
* src/nm-device-802-11-wireless.c: Fix wireless device scanning scheduler.
The new algorithm is to start from SCAN_INTERVAL_MIN (currently defined as 0)
and add a SCAN_INTERVAL_STEP (currently 20 seconds) with each successful scan
until SCAN_INTERVAL_MAX (currently 120 seconds) is reached. Do not scan while
the device is down, activating, or activated (in case of A/B/G cards).
Remove some old dead ifdef'ed out code that used to configure wireless devices,
it's all done through supplicant now.
* src/supplicant-manager/nm-supplicant-interface.c: Fix the reference
counting issues with pending calls which caused leaks and crashes when
interface was removed (now that the interface actually gets removed).
* src/nm-call-store.c: Make a copy of data before running a foreach
with user callback on it - The most common usage pattern is to cancel
(and thus remove) all pending calls with foreach which would modify
the hash table we're iterating over.
* src/nm-manager.c: When a device is added, make sure it is "up". When
it's removed or disabled due to disabling wireless or networking, bring
it down.
* include/NetworkManager.h: Add new device state NM_DEVICE_STATE_DOWN.
* src/nm-device-802-11-wireless.c:
* src/nm-device-802-3-ethernet.c:
* src/nm-device.c:
- Remove "init" virtual function, all gobjects have a place for that
already (constructor).
- Replace "start" virtual function with "bring_up", devices can be
brought up and down more than just on startup now.
- Add "is_up" virtual function.
- Implement one way to bring a device down instead of previous 4 different
ways, each of witch did something different.
* src/NetworkManagerUtils.c (nm_dev_sock_open): This doesn't need an NMDevice,
all it needs is the device interface.
Get rid of NMData.dev_list (3 members to go).
Get rif of NMData in a lot of places.
* gnome/libnm_glib/libnm_glib.c: Make it compile again.
git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@2395 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
2007-03-02 09:30:48 +00:00
|
|
|
NMAccessPointPrivate *priv;
|
2007-02-12 09:23:43 +00:00
|
|
|
|
|
|
|
|
g_return_val_if_fail (NM_IS_ACCESS_POINT (ap), 0);
|
|
|
|
|
|
2007-03-02 Tambet Ingo <tambet@ximian.com>
* libnm-glib/nm-device-802-11-wireless.c: Cache networks (bssids) list.
We get signalled when it changes.
* libnm-glib/nm-client.c: Cache NMState and device list, we get signalled
when it changes.
* libnm-glib/nm-device.c: Cache the device state property.
* libnm-glib/nm-access-point.c: Cache the strength property.
* src/nm-device-802-11-wireless.c: Fix wireless device scanning scheduler.
The new algorithm is to start from SCAN_INTERVAL_MIN (currently defined as 0)
and add a SCAN_INTERVAL_STEP (currently 20 seconds) with each successful scan
until SCAN_INTERVAL_MAX (currently 120 seconds) is reached. Do not scan while
the device is down, activating, or activated (in case of A/B/G cards).
Remove some old dead ifdef'ed out code that used to configure wireless devices,
it's all done through supplicant now.
* src/supplicant-manager/nm-supplicant-interface.c: Fix the reference
counting issues with pending calls which caused leaks and crashes when
interface was removed (now that the interface actually gets removed).
* src/nm-call-store.c: Make a copy of data before running a foreach
with user callback on it - The most common usage pattern is to cancel
(and thus remove) all pending calls with foreach which would modify
the hash table we're iterating over.
* src/nm-manager.c: When a device is added, make sure it is "up". When
it's removed or disabled due to disabling wireless or networking, bring
it down.
* include/NetworkManager.h: Add new device state NM_DEVICE_STATE_DOWN.
* src/nm-device-802-11-wireless.c:
* src/nm-device-802-3-ethernet.c:
* src/nm-device.c:
- Remove "init" virtual function, all gobjects have a place for that
already (constructor).
- Replace "start" virtual function with "bring_up", devices can be
brought up and down more than just on startup now.
- Add "is_up" virtual function.
- Implement one way to bring a device down instead of previous 4 different
ways, each of witch did something different.
* src/NetworkManagerUtils.c (nm_dev_sock_open): This doesn't need an NMDevice,
all it needs is the device interface.
Get rid of NMData.dev_list (3 members to go).
Get rif of NMData in a lot of places.
* gnome/libnm_glib/libnm_glib.c: Make it compile again.
git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@2395 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
2007-03-02 09:30:48 +00:00
|
|
|
priv = NM_ACCESS_POINT_GET_PRIVATE (ap);
|
2007-09-19 20:44:37 +00:00
|
|
|
if (!priv->strength) {
|
|
|
|
|
priv->strength = nm_object_get_byte_property (NM_OBJECT (ap),
|
|
|
|
|
NM_DBUS_INTERFACE_ACCESS_POINT,
|
|
|
|
|
DBUS_PROP_STRENGTH);
|
|
|
|
|
}
|
2007-02-12 09:23:43 +00:00
|
|
|
|
2007-03-02 Tambet Ingo <tambet@ximian.com>
* libnm-glib/nm-device-802-11-wireless.c: Cache networks (bssids) list.
We get signalled when it changes.
* libnm-glib/nm-client.c: Cache NMState and device list, we get signalled
when it changes.
* libnm-glib/nm-device.c: Cache the device state property.
* libnm-glib/nm-access-point.c: Cache the strength property.
* src/nm-device-802-11-wireless.c: Fix wireless device scanning scheduler.
The new algorithm is to start from SCAN_INTERVAL_MIN (currently defined as 0)
and add a SCAN_INTERVAL_STEP (currently 20 seconds) with each successful scan
until SCAN_INTERVAL_MAX (currently 120 seconds) is reached. Do not scan while
the device is down, activating, or activated (in case of A/B/G cards).
Remove some old dead ifdef'ed out code that used to configure wireless devices,
it's all done through supplicant now.
* src/supplicant-manager/nm-supplicant-interface.c: Fix the reference
counting issues with pending calls which caused leaks and crashes when
interface was removed (now that the interface actually gets removed).
* src/nm-call-store.c: Make a copy of data before running a foreach
with user callback on it - The most common usage pattern is to cancel
(and thus remove) all pending calls with foreach which would modify
the hash table we're iterating over.
* src/nm-manager.c: When a device is added, make sure it is "up". When
it's removed or disabled due to disabling wireless or networking, bring
it down.
* include/NetworkManager.h: Add new device state NM_DEVICE_STATE_DOWN.
* src/nm-device-802-11-wireless.c:
* src/nm-device-802-3-ethernet.c:
* src/nm-device.c:
- Remove "init" virtual function, all gobjects have a place for that
already (constructor).
- Replace "start" virtual function with "bring_up", devices can be
brought up and down more than just on startup now.
- Add "is_up" virtual function.
- Implement one way to bring a device down instead of previous 4 different
ways, each of witch did something different.
* src/NetworkManagerUtils.c (nm_dev_sock_open): This doesn't need an NMDevice,
all it needs is the device interface.
Get rid of NMData.dev_list (3 members to go).
Get rif of NMData in a lot of places.
* gnome/libnm_glib/libnm_glib.c: Make it compile again.
git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@2395 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
2007-03-02 09:30:48 +00:00
|
|
|
return priv->strength;
|
2007-02-12 09:23:43 +00:00
|
|
|
}
|
2007-10-12 10:18:46 +00:00
|
|
|
|
|
|
|
|
/************************************************************/
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
nm_access_point_init (NMAccessPoint *ap)
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
dispose (GObject *object)
|
|
|
|
|
{
|
|
|
|
|
NMAccessPointPrivate *priv = NM_ACCESS_POINT_GET_PRIVATE (object);
|
|
|
|
|
|
|
|
|
|
if (priv->disposed)
|
|
|
|
|
return;
|
|
|
|
|
priv->disposed = TRUE;
|
|
|
|
|
|
|
|
|
|
g_object_unref (priv->ap_proxy);
|
|
|
|
|
|
|
|
|
|
G_OBJECT_CLASS (nm_access_point_parent_class)->dispose (object);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
finalize (GObject *object)
|
|
|
|
|
{
|
|
|
|
|
NMAccessPointPrivate *priv = NM_ACCESS_POINT_GET_PRIVATE (object);
|
|
|
|
|
|
|
|
|
|
if (priv->ssid)
|
|
|
|
|
g_byte_array_free (priv->ssid, TRUE);
|
|
|
|
|
|
|
|
|
|
if (priv->hw_address)
|
|
|
|
|
g_free (priv->hw_address);
|
|
|
|
|
|
|
|
|
|
G_OBJECT_CLASS (nm_access_point_parent_class)->finalize (object);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
set_property (GObject *object, guint prop_id,
|
|
|
|
|
const GValue *value, GParamSpec *pspec)
|
|
|
|
|
{
|
|
|
|
|
NMAccessPoint *ap = NM_ACCESS_POINT (object);
|
|
|
|
|
|
|
|
|
|
switch (prop_id) {
|
|
|
|
|
case PROP_FLAGS:
|
|
|
|
|
nm_access_point_set_flags (ap, g_value_get_uint (value));
|
|
|
|
|
break;
|
|
|
|
|
case PROP_WPA_FLAGS:
|
|
|
|
|
nm_access_point_set_wpa_flags (ap, g_value_get_uint (value));
|
|
|
|
|
break;
|
|
|
|
|
case PROP_RSN_FLAGS:
|
|
|
|
|
nm_access_point_set_rsn_flags (ap, g_value_get_uint (value));
|
|
|
|
|
break;
|
|
|
|
|
case PROP_SSID:
|
|
|
|
|
nm_access_point_set_ssid (ap, (GArray *) g_value_get_boxed (value));
|
|
|
|
|
break;
|
|
|
|
|
case PROP_FREQUENCY:
|
|
|
|
|
nm_access_point_set_frequency (ap, g_value_get_uint (value));
|
|
|
|
|
break;
|
|
|
|
|
case PROP_HW_ADDRESS:
|
|
|
|
|
nm_access_point_set_hw_address (ap, g_value_get_string (value));
|
|
|
|
|
break;
|
|
|
|
|
case PROP_MODE:
|
|
|
|
|
nm_access_point_set_mode (ap, g_value_get_int (value));
|
|
|
|
|
break;
|
|
|
|
|
case PROP_RATE:
|
|
|
|
|
nm_access_point_set_rate (ap, g_value_get_uint (value));
|
|
|
|
|
break;
|
|
|
|
|
case PROP_STRENGTH:
|
|
|
|
|
nm_access_point_set_strength (ap, g_value_get_char (value));
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
get_property (GObject *object,
|
|
|
|
|
guint prop_id,
|
|
|
|
|
GValue *value,
|
|
|
|
|
GParamSpec *pspec)
|
|
|
|
|
{
|
|
|
|
|
NMAccessPointPrivate *priv = NM_ACCESS_POINT_GET_PRIVATE (object);
|
|
|
|
|
GArray * ssid;
|
|
|
|
|
int len;
|
|
|
|
|
int i;
|
|
|
|
|
|
|
|
|
|
switch (prop_id) {
|
|
|
|
|
case PROP_FLAGS:
|
|
|
|
|
g_value_set_uint (value, priv->flags);
|
|
|
|
|
break;
|
|
|
|
|
case PROP_WPA_FLAGS:
|
|
|
|
|
g_value_set_uint (value, priv->wpa_flags);
|
|
|
|
|
break;
|
|
|
|
|
case PROP_RSN_FLAGS:
|
|
|
|
|
g_value_set_uint (value, priv->rsn_flags);
|
|
|
|
|
break;
|
|
|
|
|
case PROP_SSID:
|
|
|
|
|
len = priv->ssid ? priv->ssid->len : 0;
|
|
|
|
|
ssid = g_array_sized_new (FALSE, TRUE, sizeof (unsigned char), len);
|
|
|
|
|
for (i = 0; i < len; i++)
|
|
|
|
|
g_array_append_val (ssid, priv->ssid->data[i]);
|
|
|
|
|
g_value_set_boxed (value, ssid);
|
|
|
|
|
g_array_free (ssid, TRUE);
|
|
|
|
|
break;
|
|
|
|
|
case PROP_FREQUENCY:
|
|
|
|
|
g_value_set_uint (value, priv->frequency);
|
|
|
|
|
break;
|
|
|
|
|
case PROP_HW_ADDRESS:
|
|
|
|
|
g_value_set_string (value, priv->hw_address);
|
|
|
|
|
break;
|
|
|
|
|
case PROP_MODE:
|
|
|
|
|
g_value_set_int (value, priv->mode);
|
|
|
|
|
break;
|
|
|
|
|
case PROP_RATE:
|
|
|
|
|
g_value_set_uint (value, priv->rate);
|
|
|
|
|
break;
|
|
|
|
|
case PROP_STRENGTH:
|
|
|
|
|
g_value_set_char (value, priv->strength);
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static GObject*
|
|
|
|
|
constructor (GType type,
|
|
|
|
|
guint n_construct_params,
|
|
|
|
|
GObjectConstructParam *construct_params)
|
|
|
|
|
{
|
|
|
|
|
NMObject *object;
|
|
|
|
|
NMAccessPointPrivate *priv;
|
|
|
|
|
|
|
|
|
|
object = (NMObject *) G_OBJECT_CLASS (nm_access_point_parent_class)->constructor (type,
|
|
|
|
|
n_construct_params,
|
|
|
|
|
construct_params);
|
|
|
|
|
if (!object)
|
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
|
|
priv = NM_ACCESS_POINT_GET_PRIVATE (object);
|
|
|
|
|
|
|
|
|
|
priv->ap_proxy = dbus_g_proxy_new_for_name (nm_object_get_connection (object),
|
|
|
|
|
NM_DBUS_SERVICE,
|
|
|
|
|
nm_object_get_path (object),
|
|
|
|
|
NM_DBUS_INTERFACE_ACCESS_POINT);
|
|
|
|
|
|
|
|
|
|
nm_object_handle_properties_changed (NM_OBJECT (object), priv->ap_proxy);
|
|
|
|
|
|
|
|
|
|
return G_OBJECT (object);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
nm_access_point_class_init (NMAccessPointClass *ap_class)
|
|
|
|
|
{
|
|
|
|
|
GObjectClass *object_class = G_OBJECT_CLASS (ap_class);
|
|
|
|
|
|
|
|
|
|
g_type_class_add_private (ap_class, sizeof (NMAccessPointPrivate));
|
|
|
|
|
|
|
|
|
|
/* virtual methods */
|
|
|
|
|
object_class->constructor = constructor;
|
|
|
|
|
object_class->set_property = set_property;
|
|
|
|
|
object_class->get_property = get_property;
|
|
|
|
|
object_class->dispose = dispose;
|
|
|
|
|
object_class->finalize = finalize;
|
|
|
|
|
|
|
|
|
|
/* properties */
|
|
|
|
|
g_object_class_install_property
|
|
|
|
|
(object_class, PROP_FLAGS,
|
|
|
|
|
g_param_spec_uint (NM_ACCESS_POINT_FLAGS,
|
|
|
|
|
"Flags",
|
|
|
|
|
"Flags",
|
|
|
|
|
NM_802_11_AP_FLAGS_NONE,
|
|
|
|
|
NM_802_11_AP_FLAGS_PRIVACY,
|
|
|
|
|
NM_802_11_AP_FLAGS_NONE,
|
|
|
|
|
G_PARAM_READWRITE));
|
|
|
|
|
|
|
|
|
|
g_object_class_install_property
|
|
|
|
|
(object_class, PROP_WPA_FLAGS,
|
|
|
|
|
g_param_spec_uint (NM_ACCESS_POINT_WPA_FLAGS,
|
|
|
|
|
"WPA Flags",
|
|
|
|
|
"WPA Flags",
|
|
|
|
|
0, G_MAXUINT32, 0,
|
|
|
|
|
G_PARAM_READWRITE));
|
|
|
|
|
|
|
|
|
|
g_object_class_install_property
|
|
|
|
|
(object_class, PROP_RSN_FLAGS,
|
|
|
|
|
g_param_spec_uint (NM_ACCESS_POINT_RSN_FLAGS,
|
|
|
|
|
"RSN Flags",
|
|
|
|
|
"RSN Flags",
|
|
|
|
|
0, G_MAXUINT32, 0,
|
|
|
|
|
G_PARAM_READWRITE));
|
|
|
|
|
|
|
|
|
|
g_object_class_install_property
|
|
|
|
|
(object_class, PROP_SSID,
|
|
|
|
|
g_param_spec_boxed (NM_ACCESS_POINT_SSID,
|
|
|
|
|
"SSID",
|
|
|
|
|
"SSID",
|
|
|
|
|
DBUS_TYPE_G_UCHAR_ARRAY,
|
|
|
|
|
G_PARAM_READWRITE));
|
|
|
|
|
|
|
|
|
|
g_object_class_install_property
|
|
|
|
|
(object_class, PROP_FREQUENCY,
|
|
|
|
|
g_param_spec_uint (NM_ACCESS_POINT_FREQUENCY,
|
|
|
|
|
"Frequency",
|
|
|
|
|
"Frequency",
|
|
|
|
|
0, 10000, 0,
|
|
|
|
|
G_PARAM_READWRITE));
|
|
|
|
|
|
|
|
|
|
g_object_class_install_property
|
|
|
|
|
(object_class, PROP_HW_ADDRESS,
|
|
|
|
|
g_param_spec_string (NM_ACCESS_POINT_HW_ADDRESS,
|
|
|
|
|
"MAC Address",
|
|
|
|
|
"Hardware MAC address",
|
|
|
|
|
NULL,
|
|
|
|
|
G_PARAM_READWRITE));
|
|
|
|
|
|
|
|
|
|
g_object_class_install_property
|
|
|
|
|
(object_class, PROP_MODE,
|
|
|
|
|
g_param_spec_int (NM_ACCESS_POINT_MODE,
|
|
|
|
|
"Mode",
|
|
|
|
|
"Mode",
|
|
|
|
|
IW_MODE_ADHOC, IW_MODE_INFRA, IW_MODE_INFRA,
|
|
|
|
|
G_PARAM_READWRITE));
|
|
|
|
|
|
|
|
|
|
g_object_class_install_property
|
|
|
|
|
(object_class, PROP_RATE,
|
|
|
|
|
g_param_spec_uint (NM_ACCESS_POINT_RATE,
|
|
|
|
|
"Rate",
|
|
|
|
|
"Rate",
|
2007-10-27 02:58:32 +00:00
|
|
|
0, G_MAXUINT32, 0,
|
2007-10-12 10:18:46 +00:00
|
|
|
G_PARAM_READWRITE));
|
|
|
|
|
|
|
|
|
|
g_object_class_install_property
|
|
|
|
|
(object_class, PROP_STRENGTH,
|
|
|
|
|
g_param_spec_char (NM_ACCESS_POINT_STRENGTH,
|
|
|
|
|
"Strength",
|
|
|
|
|
"Strength",
|
|
|
|
|
G_MININT8, G_MAXINT8, 0,
|
|
|
|
|
G_PARAM_READWRITE));
|
|
|
|
|
}
|