2007-02-12 09:23:43 +00:00
|
|
|
#include "nm-device.h"
|
|
|
|
|
#include "nm-device-private.h"
|
|
|
|
|
|
|
|
|
|
#include "nm-device-bindings.h"
|
|
|
|
|
|
2007-06-22 15:09:02 +00:00
|
|
|
G_DEFINE_TYPE (NMDevice, nm_device, 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_DEVICE_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), NM_TYPE_DEVICE, NMDevicePrivate))
|
|
|
|
|
|
|
|
|
|
typedef struct {
|
2007-03-16 09:37:53 +00:00
|
|
|
DBusGProxy *device_proxy;
|
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
|
|
|
NMDeviceState state;
|
2007-03-16 09:37:53 +00:00
|
|
|
|
2007-09-25 17:30:01 +00:00
|
|
|
gboolean carrier;
|
|
|
|
|
gboolean carrier_valid;
|
|
|
|
|
|
2007-03-16 09:37:53 +00:00
|
|
|
gboolean disposed;
|
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
|
|
|
} NMDevicePrivate;
|
|
|
|
|
|
2007-02-12 09:23:43 +00:00
|
|
|
enum {
|
|
|
|
|
STATE_CHANGED,
|
2007-09-25 17:30:01 +00:00
|
|
|
CARRIER_CHANGED,
|
2007-02-12 09:23:43 +00:00
|
|
|
|
|
|
|
|
LAST_SIGNAL
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
static guint signals[LAST_SIGNAL] = { 0 };
|
|
|
|
|
|
2007-03-16 09:37:53 +00:00
|
|
|
|
|
|
|
|
enum {
|
|
|
|
|
PROP_0,
|
|
|
|
|
PROP_CONNECTION,
|
|
|
|
|
PROP_PATH,
|
|
|
|
|
|
|
|
|
|
LAST_PROP
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
2007-02-12 09:23:43 +00:00
|
|
|
static void device_state_change_proxy (DBusGProxy *proxy, guint state, gpointer user_data);
|
2007-09-25 17:30:01 +00:00
|
|
|
static void device_carrier_changed_proxy (DBusGProxy *proxy, gboolean carrier, gpointer user_data);
|
2007-02-12 09:23:43 +00:00
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
nm_device_init (NMDevice *device)
|
|
|
|
|
{
|
2007-03-16 09:37:53 +00:00
|
|
|
NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE (device);
|
|
|
|
|
|
|
|
|
|
priv->state = NM_DEVICE_STATE_UNKNOWN;
|
2007-09-25 17:30:01 +00:00
|
|
|
priv->carrier = FALSE;
|
|
|
|
|
priv->carrier_valid = FALSE;
|
2007-03-16 09:37:53 +00:00
|
|
|
priv->disposed = FALSE;
|
2007-02-12 09:23:43 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static GObject*
|
|
|
|
|
constructor (GType type,
|
|
|
|
|
guint n_construct_params,
|
|
|
|
|
GObjectConstructParam *construct_params)
|
|
|
|
|
{
|
2007-06-22 15:09:02 +00:00
|
|
|
NMObject *object;
|
2007-03-16 09:37:53 +00:00
|
|
|
NMDevicePrivate *priv;
|
2007-02-12 09:23:43 +00:00
|
|
|
|
2007-06-22 15:09:02 +00:00
|
|
|
object = (NMObject *) G_OBJECT_CLASS (nm_device_parent_class)->constructor (type,
|
|
|
|
|
n_construct_params,
|
|
|
|
|
construct_params);
|
2007-02-12 09:23:43 +00:00
|
|
|
if (!object)
|
|
|
|
|
return NULL;
|
|
|
|
|
|
2007-03-16 09:37:53 +00:00
|
|
|
priv = NM_DEVICE_GET_PRIVATE (object);
|
|
|
|
|
|
2007-06-22 15:09:02 +00:00
|
|
|
priv->device_proxy = dbus_g_proxy_new_for_name (nm_object_get_connection (object),
|
2007-03-16 09:37:53 +00:00
|
|
|
NM_DBUS_SERVICE,
|
2007-06-22 15:09:02 +00:00
|
|
|
nm_object_get_path (object),
|
2007-03-16 09:37:53 +00:00
|
|
|
NM_DBUS_INTERFACE_DEVICE);
|
|
|
|
|
|
|
|
|
|
dbus_g_proxy_add_signal (priv->device_proxy, "StateChanged", G_TYPE_UINT, G_TYPE_INVALID);
|
|
|
|
|
dbus_g_proxy_connect_signal (priv->device_proxy, "StateChanged",
|
2007-02-12 09:23:43 +00:00
|
|
|
G_CALLBACK (device_state_change_proxy),
|
2007-03-16 09:37:53 +00:00
|
|
|
object, NULL);
|
2007-09-25 17:30:01 +00:00
|
|
|
|
|
|
|
|
dbus_g_proxy_add_signal (priv->device_proxy, "CarrierChanged", G_TYPE_BOOLEAN, G_TYPE_INVALID);
|
|
|
|
|
dbus_g_proxy_connect_signal (priv->device_proxy, "CarrierChanged",
|
|
|
|
|
G_CALLBACK (device_carrier_changed_proxy),
|
|
|
|
|
object, NULL);
|
2007-06-22 15:09:02 +00:00
|
|
|
return G_OBJECT (object);
|
2007-02-12 09:23:43 +00:00
|
|
|
}
|
|
|
|
|
|
2007-03-16 09:37:53 +00:00
|
|
|
static void
|
|
|
|
|
dispose (GObject *object)
|
|
|
|
|
{
|
|
|
|
|
NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE (object);
|
|
|
|
|
|
|
|
|
|
if (priv->disposed)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
priv->disposed = TRUE;
|
|
|
|
|
|
|
|
|
|
g_object_unref (priv->device_proxy);
|
|
|
|
|
|
|
|
|
|
G_OBJECT_CLASS (nm_device_parent_class)->dispose (object);
|
|
|
|
|
}
|
|
|
|
|
|
2007-02-12 09:23:43 +00:00
|
|
|
static void
|
|
|
|
|
nm_device_class_init (NMDeviceClass *device_class)
|
|
|
|
|
{
|
|
|
|
|
GObjectClass *object_class = G_OBJECT_CLASS (device_class);
|
|
|
|
|
|
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
|
|
|
g_type_class_add_private (device_class, sizeof (NMDevicePrivate));
|
|
|
|
|
|
2007-02-12 09:23:43 +00:00
|
|
|
/* virtual methods */
|
|
|
|
|
object_class->constructor = constructor;
|
2007-03-16 09:37:53 +00:00
|
|
|
object_class->dispose = dispose;
|
2007-02-12 09:23:43 +00:00
|
|
|
|
|
|
|
|
/* signals */
|
|
|
|
|
signals[STATE_CHANGED] =
|
|
|
|
|
g_signal_new ("state-changed",
|
|
|
|
|
G_OBJECT_CLASS_TYPE (object_class),
|
|
|
|
|
G_SIGNAL_RUN_FIRST,
|
|
|
|
|
G_STRUCT_OFFSET (NMDeviceClass, state_changed),
|
|
|
|
|
NULL, NULL,
|
|
|
|
|
g_cclosure_marshal_VOID__UINT,
|
|
|
|
|
G_TYPE_NONE, 1,
|
|
|
|
|
G_TYPE_UINT);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
device_state_change_proxy (DBusGProxy *proxy, guint state, gpointer user_data)
|
|
|
|
|
{
|
|
|
|
|
NMDevice *device = NM_DEVICE (user_data);
|
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
|
|
|
NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE (device);
|
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
|
|
|
if (priv->state != state) {
|
|
|
|
|
priv->state = state;
|
|
|
|
|
g_signal_emit (device, signals[STATE_CHANGED], 0, state);
|
|
|
|
|
}
|
2007-02-12 09:23:43 +00:00
|
|
|
}
|
|
|
|
|
|
2007-09-25 17:30:01 +00:00
|
|
|
static void
|
|
|
|
|
device_carrier_changed_proxy (DBusGProxy *proxy, gboolean carrier, gpointer user_data)
|
|
|
|
|
{
|
|
|
|
|
NMDevice *device = NM_DEVICE (user_data);
|
|
|
|
|
NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE (device);
|
|
|
|
|
|
|
|
|
|
if ((priv->carrier != carrier) || !priv->carrier_valid) {
|
|
|
|
|
priv->carrier_valid = TRUE;
|
|
|
|
|
priv->carrier = carrier;
|
|
|
|
|
g_signal_emit (device, signals[CARRIER_CHANGED], 0, carrier);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2007-02-12 09:23:43 +00:00
|
|
|
NMDevice *
|
|
|
|
|
nm_device_new (DBusGConnection *connection, const char *path)
|
|
|
|
|
{
|
|
|
|
|
return (NMDevice *) g_object_new (NM_TYPE_DEVICE,
|
2007-06-22 15:09:02 +00:00
|
|
|
NM_OBJECT_CONNECTION, connection,
|
|
|
|
|
NM_OBJECT_PATH, path,
|
2007-02-12 09:23:43 +00:00
|
|
|
NULL);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
nm_device_deactivate (NMDevice *device)
|
|
|
|
|
{
|
|
|
|
|
GError *err = NULL;
|
|
|
|
|
|
|
|
|
|
g_return_if_fail (NM_IS_DEVICE (device));
|
|
|
|
|
|
2007-03-16 09:37:53 +00:00
|
|
|
if (!org_freedesktop_NetworkManager_Device_deactivate (NM_DEVICE_GET_PRIVATE (device)->device_proxy, &err)) {
|
2007-02-12 09:23:43 +00:00
|
|
|
g_warning ("Cannot deactivate device: %s", err->message);
|
|
|
|
|
g_error_free (err);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
char *
|
|
|
|
|
nm_device_get_iface (NMDevice *device)
|
|
|
|
|
{
|
|
|
|
|
g_return_val_if_fail (NM_IS_DEVICE (device), NULL);
|
|
|
|
|
|
2007-06-22 15:09:02 +00:00
|
|
|
return nm_object_get_string_property (NM_OBJECT (device), NM_DBUS_INTERFACE_DEVICE, "Interface");
|
2007-02-12 09:23:43 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
char *
|
|
|
|
|
nm_device_get_udi (NMDevice *device)
|
|
|
|
|
{
|
|
|
|
|
g_return_val_if_fail (NM_IS_DEVICE (device), NULL);
|
|
|
|
|
|
2007-06-22 15:09:02 +00:00
|
|
|
return nm_object_get_string_property (NM_OBJECT (device), NM_DBUS_INTERFACE_DEVICE, "Udi");
|
2007-02-12 09:23:43 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
char *
|
|
|
|
|
nm_device_get_driver (NMDevice *device)
|
|
|
|
|
{
|
|
|
|
|
g_return_val_if_fail (NM_IS_DEVICE (device), NULL);
|
|
|
|
|
|
2007-06-22 15:09:02 +00:00
|
|
|
return nm_object_get_string_property (NM_OBJECT (device), NM_DBUS_INTERFACE_DEVICE, "Driver");
|
2007-02-12 09:23:43 +00:00
|
|
|
}
|
|
|
|
|
|
2007-03-05 08:49:30 +00:00
|
|
|
guint32
|
|
|
|
|
nm_device_get_capabilities (NMDevice *device)
|
|
|
|
|
{
|
|
|
|
|
g_return_val_if_fail (NM_IS_DEVICE (device), 0);
|
|
|
|
|
|
2007-06-22 15:09:02 +00:00
|
|
|
return nm_object_get_uint_property (NM_OBJECT (device), NM_DBUS_INTERFACE_DEVICE, "Capabilities");
|
2007-03-05 08:49:30 +00:00
|
|
|
}
|
|
|
|
|
|
2007-02-12 09:23:43 +00:00
|
|
|
guint32
|
|
|
|
|
nm_device_get_ip4_address (NMDevice *device)
|
|
|
|
|
{
|
|
|
|
|
g_return_val_if_fail (NM_IS_DEVICE (device), 0);
|
|
|
|
|
|
2007-06-22 15:09:02 +00:00
|
|
|
return nm_object_get_uint_property (NM_OBJECT (device), NM_DBUS_INTERFACE_DEVICE, "Ip4Address");
|
2007-02-12 09:23:43 +00:00
|
|
|
}
|
|
|
|
|
|
2007-02-16 11:23:49 +00:00
|
|
|
NMIP4Config *
|
|
|
|
|
nm_device_get_ip4_config (NMDevice *device)
|
|
|
|
|
{
|
2007-03-16 09:37:53 +00:00
|
|
|
char *path;
|
2007-02-16 11:23:49 +00:00
|
|
|
NMIP4Config *config = NULL;
|
|
|
|
|
|
2007-03-16 09:37:53 +00:00
|
|
|
g_return_val_if_fail (NM_IS_DEVICE (device), NULL);
|
2007-02-16 11:23:49 +00:00
|
|
|
|
2007-06-22 15:09:02 +00:00
|
|
|
path = nm_object_get_object_path_property (NM_OBJECT (device), NM_DBUS_INTERFACE_DEVICE, "Ip4Config");
|
|
|
|
|
|
2007-03-16 09:37:53 +00:00
|
|
|
if (path) {
|
2007-06-22 15:09:02 +00:00
|
|
|
config = nm_ip4_config_new (nm_object_get_connection (NM_OBJECT (device)), path);
|
2007-03-16 09:37:53 +00:00
|
|
|
g_free (path);
|
2007-02-16 11:23:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return config;
|
|
|
|
|
}
|
|
|
|
|
|
2007-02-12 09:23:43 +00:00
|
|
|
NMDeviceState
|
|
|
|
|
nm_device_get_state (NMDevice *device)
|
|
|
|
|
{
|
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
|
|
|
NMDevicePrivate *priv;
|
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
|
|
|
g_return_val_if_fail (NM_IS_DEVICE (device), NM_DEVICE_STATE_UNKNOWN);
|
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
|
|
|
priv = NM_DEVICE_GET_PRIVATE (device);
|
|
|
|
|
|
2007-03-16 09:37:53 +00:00
|
|
|
if (priv->state == NM_DEVICE_STATE_UNKNOWN)
|
2007-06-22 15:09:02 +00:00
|
|
|
priv->state = nm_object_get_uint_property (NM_OBJECT (device), NM_DBUS_INTERFACE_DEVICE, "State");
|
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->state;
|
2007-02-12 09:23:43 +00:00
|
|
|
}
|
|
|
|
|
|
2007-03-16 09:37:53 +00:00
|
|
|
char *
|
|
|
|
|
nm_device_get_description (NMDevice *device)
|
|
|
|
|
{
|
|
|
|
|
DBusGProxy *proxy;
|
|
|
|
|
GError *err = NULL;
|
|
|
|
|
char *udi;
|
|
|
|
|
char *physical_device_udi = NULL;
|
|
|
|
|
char *vendor = NULL;
|
|
|
|
|
char *product = NULL;
|
|
|
|
|
char *description = NULL;
|
|
|
|
|
|
|
|
|
|
g_return_val_if_fail (NM_IS_DEVICE (device), NULL);
|
|
|
|
|
|
|
|
|
|
/* First, get the physical device info */
|
|
|
|
|
|
|
|
|
|
udi = nm_device_get_udi (device);
|
2007-06-22 15:09:02 +00:00
|
|
|
proxy = dbus_g_proxy_new_for_name (nm_object_get_connection (NM_OBJECT (device)),
|
2007-03-16 09:37:53 +00:00
|
|
|
"org.freedesktop.Hal",
|
|
|
|
|
udi,
|
|
|
|
|
"org.freedesktop.Hal.Device");
|
|
|
|
|
g_free (udi);
|
|
|
|
|
|
|
|
|
|
if (!dbus_g_proxy_call (proxy, "GetPropertyString", &err,
|
|
|
|
|
G_TYPE_STRING, "net.physical_device",
|
|
|
|
|
G_TYPE_INVALID,
|
|
|
|
|
G_TYPE_STRING, &physical_device_udi,
|
|
|
|
|
G_TYPE_INVALID)) {
|
|
|
|
|
g_warning ("Error getting physical device info from HAL: %s", err->message);
|
|
|
|
|
g_error_free (err);
|
|
|
|
|
goto out;
|
|
|
|
|
}
|
|
|
|
|
g_object_unref (proxy);
|
|
|
|
|
|
|
|
|
|
/* Now get the vendor and product info from the physical device */
|
|
|
|
|
|
2007-06-22 15:09:02 +00:00
|
|
|
proxy = dbus_g_proxy_new_for_name (nm_object_get_connection (NM_OBJECT (device)),
|
2007-03-16 09:37:53 +00:00
|
|
|
"org.freedesktop.Hal",
|
|
|
|
|
physical_device_udi,
|
|
|
|
|
"org.freedesktop.Hal.Device");
|
|
|
|
|
|
|
|
|
|
if (!dbus_g_proxy_call (proxy, "GetPropertyString", &err,
|
|
|
|
|
G_TYPE_STRING, "info.vendor",
|
|
|
|
|
G_TYPE_INVALID,
|
|
|
|
|
G_TYPE_STRING, &vendor,
|
|
|
|
|
G_TYPE_INVALID)) {
|
|
|
|
|
g_warning ("Error getting vendor info from HAL: %s", err->message);
|
|
|
|
|
g_error_free (err);
|
|
|
|
|
goto out;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!dbus_g_proxy_call (proxy, "GetPropertyString", &err,
|
|
|
|
|
G_TYPE_STRING, "info.product",
|
|
|
|
|
G_TYPE_INVALID,
|
|
|
|
|
G_TYPE_STRING, &product,
|
|
|
|
|
G_TYPE_INVALID)) {
|
|
|
|
|
g_warning ("Error getting product info from HAL: %s", err->message);
|
|
|
|
|
g_error_free (err);
|
|
|
|
|
goto out;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
description = g_strdup_printf ("%s %s", vendor, product);
|
|
|
|
|
|
|
|
|
|
out:
|
|
|
|
|
g_object_unref (proxy);
|
|
|
|
|
g_free (physical_device_udi);
|
|
|
|
|
g_free (vendor);
|
|
|
|
|
g_free (product);
|
|
|
|
|
|
|
|
|
|
return description;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2007-09-25 17:30:01 +00:00
|
|
|
gboolean
|
|
|
|
|
nm_device_get_carrier (NMDevice *device)
|
|
|
|
|
{
|
|
|
|
|
NMDevicePrivate *priv;
|
|
|
|
|
|
|
|
|
|
g_return_val_if_fail (NM_IS_DEVICE (device), FALSE);
|
|
|
|
|
|
|
|
|
|
priv = NM_DEVICE_GET_PRIVATE (device);
|
|
|
|
|
|
|
|
|
|
if (!priv->carrier_valid) {
|
|
|
|
|
priv->carrier = nm_object_get_boolean_property (NM_OBJECT (device),
|
|
|
|
|
NM_DBUS_INTERFACE_DEVICE, "Carrier");
|
|
|
|
|
priv->carrier_valid = TRUE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return priv->carrier;
|
|
|
|
|
}
|
|
|
|
|
|
2007-02-12 09:23:43 +00:00
|
|
|
NMDeviceType
|
|
|
|
|
nm_device_type_for_path (DBusGConnection *connection,
|
|
|
|
|
const char *path)
|
|
|
|
|
{
|
|
|
|
|
DBusGProxy *proxy;
|
2007-06-22 15:09:02 +00:00
|
|
|
GError *err = NULL;
|
2007-02-12 09:23:43 +00:00
|
|
|
GValue value = {0,};
|
|
|
|
|
NMDeviceType type = DEVICE_TYPE_UNKNOWN;
|
|
|
|
|
|
|
|
|
|
g_return_val_if_fail (connection != NULL, type);
|
|
|
|
|
g_return_val_if_fail (path != NULL, type);
|
|
|
|
|
|
|
|
|
|
proxy = dbus_g_proxy_new_for_name (connection,
|
|
|
|
|
NM_DBUS_SERVICE,
|
|
|
|
|
path,
|
2007-06-22 15:09:02 +00:00
|
|
|
"org.freedesktop.DBus.Properties");
|
|
|
|
|
|
|
|
|
|
if (dbus_g_proxy_call (proxy,
|
|
|
|
|
"Get", &err,
|
|
|
|
|
G_TYPE_STRING, NM_DBUS_INTERFACE_DEVICE,
|
|
|
|
|
G_TYPE_STRING, "DeviceType",
|
|
|
|
|
G_TYPE_INVALID,
|
|
|
|
|
G_TYPE_VALUE, &value,
|
|
|
|
|
G_TYPE_INVALID)) {
|
2007-02-12 09:23:43 +00:00
|
|
|
type = (NMDeviceType) g_value_get_uint (&value);
|
2007-06-22 15:09:02 +00:00
|
|
|
} else {
|
|
|
|
|
g_warning ("Error in get_property: %s\n", err->message);
|
|
|
|
|
g_error_free (err);
|
|
|
|
|
}
|
2007-02-12 09:23:43 +00:00
|
|
|
|
|
|
|
|
g_object_unref (proxy);
|
|
|
|
|
|
|
|
|
|
return type;
|
|
|
|
|
}
|