2007-02-12 09:23:43 +00:00
|
|
|
#include <dbus/dbus-glib.h>
|
2007-03-16 09:37:53 +00:00
|
|
|
#include <string.h>
|
2007-02-12 09:23:43 +00:00
|
|
|
#include "nm-client.h"
|
|
|
|
|
#include "nm-device-802-3-ethernet.h"
|
|
|
|
|
#include "nm-device-802-11-wireless.h"
|
|
|
|
|
#include "nm-utils.h"
|
2007-03-26 12:42:29 +00:00
|
|
|
#include "nm-device-private.h"
|
|
|
|
|
#include "nm-marshal.h"
|
2007-02-12 09:23:43 +00:00
|
|
|
|
|
|
|
|
#include "nm-client-bindings.h"
|
|
|
|
|
|
|
|
|
|
G_DEFINE_TYPE (NMClient, nm_client, DBUS_TYPE_G_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
|
|
|
#define NM_CLIENT_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), NM_TYPE_CLIENT, NMClientPrivate))
|
|
|
|
|
|
|
|
|
|
typedef struct {
|
2007-03-16 09:37:53 +00:00
|
|
|
DBusGProxy *bus_proxy;
|
|
|
|
|
gboolean manager_running;
|
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
|
|
|
NMState state;
|
|
|
|
|
gboolean have_device_list;
|
|
|
|
|
GHashTable *devices;
|
2007-03-26 12:42:29 +00:00
|
|
|
|
|
|
|
|
DBusGProxy *vpn_proxy;
|
|
|
|
|
NMVPNActStage vpn_state;
|
|
|
|
|
gboolean have_vpn_connection_list;
|
|
|
|
|
GSList *vpn_connection_list;
|
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
|
|
|
} NMClientPrivate;
|
|
|
|
|
|
2007-02-12 09:23:43 +00:00
|
|
|
enum {
|
2007-03-16 09:37:53 +00:00
|
|
|
MANAGER_RUNNING,
|
2007-02-12 09:23:43 +00:00
|
|
|
DEVICE_ADDED,
|
|
|
|
|
DEVICE_REMOVED,
|
|
|
|
|
STATE_CHANGE,
|
|
|
|
|
|
2007-03-26 12:42:29 +00:00
|
|
|
VPN_CONNECTION_ADDED,
|
|
|
|
|
VPN_CONNECTION_REMOVED,
|
|
|
|
|
VPN_STATE_CHANGE,
|
|
|
|
|
|
2007-02-12 09:23:43 +00:00
|
|
|
LAST_SIGNAL
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
static guint signals[LAST_SIGNAL] = { 0 };
|
|
|
|
|
|
2007-03-16 09:37:53 +00:00
|
|
|
static void proxy_name_owner_changed (DBusGProxy *proxy,
|
|
|
|
|
const char *name,
|
|
|
|
|
const char *old_owner,
|
|
|
|
|
const char *new_owner,
|
|
|
|
|
gpointer user_data);
|
|
|
|
|
|
2007-02-12 09:23:43 +00:00
|
|
|
static void client_state_change_proxy (DBusGProxy *proxy, guint state, gpointer user_data);
|
|
|
|
|
static void client_device_added_proxy (DBusGProxy *proxy, char *path, gpointer user_data);
|
|
|
|
|
static void client_device_removed_proxy (DBusGProxy *proxy, char *path, gpointer user_data);
|
|
|
|
|
|
2007-03-26 12:42:29 +00:00
|
|
|
static void setup_vpn_proxy (NMClient *client, DBusGConnection *connection);
|
|
|
|
|
|
2007-02-12 09:23:43 +00:00
|
|
|
static void
|
|
|
|
|
nm_client_init (NMClient *client)
|
|
|
|
|
{
|
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
|
|
|
NMClientPrivate *priv = NM_CLIENT_GET_PRIVATE (client);
|
|
|
|
|
|
|
|
|
|
priv->state = NM_STATE_UNKNOWN;
|
|
|
|
|
priv->devices = g_hash_table_new_full (g_str_hash, g_str_equal,
|
|
|
|
|
(GDestroyNotify) g_free,
|
|
|
|
|
(GDestroyNotify) g_object_unref);
|
2007-03-26 12:42:29 +00:00
|
|
|
|
|
|
|
|
priv->vpn_state = NM_VPN_ACT_STAGE_UNKNOWN;
|
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
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
finalize (GObject *object)
|
|
|
|
|
{
|
|
|
|
|
NMClientPrivate *priv = NM_CLIENT_GET_PRIVATE (object);
|
|
|
|
|
|
2007-03-16 09:37:53 +00:00
|
|
|
g_object_unref (priv->bus_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
|
|
|
g_hash_table_destroy (priv->devices);
|
2007-02-12 09:23:43 +00:00
|
|
|
}
|
|
|
|
|
|
2007-03-16 09:37:53 +00:00
|
|
|
static void
|
|
|
|
|
manager_running (NMClient *client, gboolean running)
|
|
|
|
|
{
|
|
|
|
|
if (!running) {
|
|
|
|
|
NMClientPrivate *priv = NM_CLIENT_GET_PRIVATE (client);
|
|
|
|
|
|
|
|
|
|
priv->state = NM_STATE_UNKNOWN;
|
|
|
|
|
g_hash_table_remove_all (priv->devices);
|
|
|
|
|
priv->have_device_list = FALSE;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2007-02-12 09:23:43 +00:00
|
|
|
static void
|
|
|
|
|
nm_client_class_init (NMClientClass *client_class)
|
|
|
|
|
{
|
|
|
|
|
GObjectClass *object_class = G_OBJECT_CLASS (client_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 (client_class, sizeof (NMClientPrivate));
|
|
|
|
|
|
|
|
|
|
/* virtual methods */
|
|
|
|
|
object_class->finalize = finalize;
|
|
|
|
|
|
2007-03-16 09:37:53 +00:00
|
|
|
client_class->manager_running = manager_running;
|
|
|
|
|
|
2007-02-12 09:23:43 +00:00
|
|
|
/* signals */
|
2007-03-16 09:37:53 +00:00
|
|
|
signals[MANAGER_RUNNING] =
|
|
|
|
|
g_signal_new ("manager-running",
|
|
|
|
|
G_OBJECT_CLASS_TYPE (object_class),
|
|
|
|
|
G_SIGNAL_RUN_FIRST,
|
|
|
|
|
G_STRUCT_OFFSET (NMClientClass, manager_running),
|
|
|
|
|
NULL, NULL,
|
|
|
|
|
g_cclosure_marshal_VOID__BOOLEAN,
|
|
|
|
|
G_TYPE_NONE, 1,
|
|
|
|
|
G_TYPE_BOOLEAN);
|
2007-02-12 09:23:43 +00:00
|
|
|
signals[DEVICE_ADDED] =
|
|
|
|
|
g_signal_new ("device-added",
|
|
|
|
|
G_OBJECT_CLASS_TYPE (object_class),
|
|
|
|
|
G_SIGNAL_RUN_FIRST,
|
|
|
|
|
G_STRUCT_OFFSET (NMClientClass, device_added),
|
|
|
|
|
NULL, NULL,
|
|
|
|
|
g_cclosure_marshal_VOID__OBJECT,
|
|
|
|
|
G_TYPE_NONE, 1,
|
|
|
|
|
G_TYPE_OBJECT);
|
|
|
|
|
|
|
|
|
|
signals[DEVICE_REMOVED] =
|
|
|
|
|
g_signal_new ("device-removed",
|
|
|
|
|
G_OBJECT_CLASS_TYPE (object_class),
|
|
|
|
|
G_SIGNAL_RUN_FIRST,
|
|
|
|
|
G_STRUCT_OFFSET (NMClientClass, device_removed),
|
|
|
|
|
NULL, NULL,
|
|
|
|
|
g_cclosure_marshal_VOID__OBJECT,
|
|
|
|
|
G_TYPE_NONE, 1,
|
|
|
|
|
G_TYPE_OBJECT);
|
|
|
|
|
|
|
|
|
|
signals[STATE_CHANGE] =
|
|
|
|
|
g_signal_new ("state-change",
|
|
|
|
|
G_OBJECT_CLASS_TYPE (object_class),
|
|
|
|
|
G_SIGNAL_RUN_FIRST,
|
|
|
|
|
G_STRUCT_OFFSET (NMClientClass, state_change),
|
|
|
|
|
NULL, NULL,
|
|
|
|
|
g_cclosure_marshal_VOID__UINT,
|
|
|
|
|
G_TYPE_NONE, 1,
|
|
|
|
|
G_TYPE_UINT);
|
|
|
|
|
|
2007-03-26 12:42:29 +00:00
|
|
|
signals[VPN_CONNECTION_ADDED] =
|
|
|
|
|
g_signal_new ("vpn-connection-added",
|
|
|
|
|
G_OBJECT_CLASS_TYPE (object_class),
|
|
|
|
|
G_SIGNAL_RUN_FIRST,
|
|
|
|
|
G_STRUCT_OFFSET (NMClientClass, vpn_connection_added),
|
|
|
|
|
NULL, NULL,
|
|
|
|
|
g_cclosure_marshal_VOID__OBJECT,
|
|
|
|
|
G_TYPE_NONE, 1,
|
|
|
|
|
G_TYPE_OBJECT);
|
|
|
|
|
|
|
|
|
|
signals[VPN_CONNECTION_REMOVED] =
|
|
|
|
|
g_signal_new ("vpn-connection-removed",
|
|
|
|
|
G_OBJECT_CLASS_TYPE (object_class),
|
|
|
|
|
G_SIGNAL_RUN_FIRST,
|
|
|
|
|
G_STRUCT_OFFSET (NMClientClass, vpn_connection_removed),
|
|
|
|
|
NULL, NULL,
|
|
|
|
|
g_cclosure_marshal_VOID__OBJECT,
|
|
|
|
|
G_TYPE_NONE, 1,
|
|
|
|
|
G_TYPE_OBJECT);
|
|
|
|
|
|
|
|
|
|
signals[VPN_STATE_CHANGE] =
|
|
|
|
|
g_signal_new ("vpn-state-change",
|
|
|
|
|
G_OBJECT_CLASS_TYPE (object_class),
|
|
|
|
|
G_SIGNAL_RUN_FIRST,
|
|
|
|
|
G_STRUCT_OFFSET (NMClientClass, state_change),
|
|
|
|
|
NULL, NULL,
|
|
|
|
|
g_cclosure_marshal_VOID__UINT,
|
|
|
|
|
G_TYPE_NONE, 1,
|
|
|
|
|
G_TYPE_UINT);
|
2007-02-12 09:23:43 +00:00
|
|
|
}
|
|
|
|
|
|
2007-03-16 09:37:53 +00:00
|
|
|
static void
|
|
|
|
|
setup_bus_listener (NMClient *client, DBusGConnection *connection)
|
|
|
|
|
{
|
|
|
|
|
NMClientPrivate *priv = NM_CLIENT_GET_PRIVATE (client);
|
|
|
|
|
GError *err = NULL;
|
|
|
|
|
|
|
|
|
|
priv->bus_proxy = dbus_g_proxy_new_for_name (connection,
|
|
|
|
|
"org.freedesktop.DBus",
|
|
|
|
|
"/org/freedesktop/DBus",
|
|
|
|
|
"org.freedesktop.DBus");
|
|
|
|
|
|
|
|
|
|
dbus_g_proxy_add_signal (priv->bus_proxy, "NameOwnerChanged",
|
|
|
|
|
G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING,
|
|
|
|
|
G_TYPE_INVALID);
|
|
|
|
|
dbus_g_proxy_connect_signal (priv->bus_proxy,
|
|
|
|
|
"NameOwnerChanged",
|
|
|
|
|
G_CALLBACK (proxy_name_owner_changed),
|
|
|
|
|
client, NULL);
|
|
|
|
|
|
|
|
|
|
if (!dbus_g_proxy_call (priv->bus_proxy,
|
|
|
|
|
"NameHasOwner", &err,
|
|
|
|
|
G_TYPE_STRING, NM_DBUS_SERVICE,
|
|
|
|
|
G_TYPE_INVALID,
|
|
|
|
|
G_TYPE_BOOLEAN, &priv->manager_running,
|
|
|
|
|
G_TYPE_INVALID)) {
|
|
|
|
|
g_warning ("Error on NameHasOwner DBUS call: %s", err->message);
|
|
|
|
|
g_error_free (err);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2007-02-12 09:23:43 +00:00
|
|
|
NMClient *
|
|
|
|
|
nm_client_new (void)
|
|
|
|
|
{
|
|
|
|
|
DBusGConnection *connection;
|
|
|
|
|
DBusGProxy *proxy;
|
|
|
|
|
NMClient *client;
|
|
|
|
|
GError *err = NULL;
|
|
|
|
|
|
|
|
|
|
connection = dbus_g_bus_get (DBUS_BUS_SYSTEM, &err);
|
|
|
|
|
if (!connection) {
|
2007-02-16 11:23:49 +00:00
|
|
|
g_warning ("Couldn't connect to system bus: %s", err->message);
|
2007-02-12 09:23:43 +00:00
|
|
|
g_error_free (err);
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
client = (NMClient *) g_object_new (NM_TYPE_CLIENT,
|
|
|
|
|
"name", NM_DBUS_SERVICE,
|
|
|
|
|
"path", NM_DBUS_PATH,
|
|
|
|
|
"interface", NM_DBUS_INTERFACE,
|
|
|
|
|
"connection", connection,
|
|
|
|
|
NULL);
|
|
|
|
|
|
|
|
|
|
proxy = DBUS_G_PROXY (client);
|
|
|
|
|
|
|
|
|
|
dbus_g_proxy_add_signal (proxy, "StateChange", G_TYPE_UINT, G_TYPE_INVALID);
|
|
|
|
|
dbus_g_proxy_connect_signal (proxy,
|
|
|
|
|
"StateChange",
|
|
|
|
|
G_CALLBACK (client_state_change_proxy),
|
2007-02-20 15:24:42 +00:00
|
|
|
NULL,
|
2007-02-12 09:23:43 +00:00
|
|
|
NULL);
|
|
|
|
|
|
|
|
|
|
dbus_g_proxy_add_signal (proxy, "DeviceAdded", DBUS_TYPE_G_OBJECT_PATH, G_TYPE_INVALID);
|
|
|
|
|
dbus_g_proxy_connect_signal (proxy,
|
|
|
|
|
"DeviceAdded",
|
|
|
|
|
G_CALLBACK (client_device_added_proxy),
|
2007-02-20 15:24:42 +00:00
|
|
|
NULL,
|
2007-02-12 09:23:43 +00:00
|
|
|
NULL);
|
|
|
|
|
|
|
|
|
|
dbus_g_proxy_add_signal (proxy, "DeviceRemoved", DBUS_TYPE_G_OBJECT_PATH, G_TYPE_INVALID);
|
|
|
|
|
dbus_g_proxy_connect_signal (proxy,
|
|
|
|
|
"DeviceRemoved",
|
|
|
|
|
G_CALLBACK (client_device_removed_proxy),
|
2007-02-20 15:24:42 +00:00
|
|
|
NULL,
|
2007-02-12 09:23:43 +00:00
|
|
|
NULL);
|
|
|
|
|
|
2007-03-26 12:42:29 +00:00
|
|
|
setup_vpn_proxy (client, connection);
|
2007-03-16 09:37:53 +00:00
|
|
|
setup_bus_listener (client, connection);
|
|
|
|
|
|
2007-02-12 09:23:43 +00:00
|
|
|
return client;
|
|
|
|
|
}
|
|
|
|
|
|
2007-03-16 09:37:53 +00:00
|
|
|
static void
|
|
|
|
|
proxy_name_owner_changed (DBusGProxy *proxy,
|
|
|
|
|
const char *name,
|
|
|
|
|
const char *old_owner,
|
|
|
|
|
const char *new_owner,
|
|
|
|
|
gpointer user_data)
|
|
|
|
|
{
|
|
|
|
|
if (name && !strcmp (name, NM_DBUS_SERVICE)) {
|
|
|
|
|
NMClientPrivate *priv = NM_CLIENT_GET_PRIVATE (user_data);
|
|
|
|
|
|
|
|
|
|
if (new_owner && strlen (new_owner) > 0)
|
|
|
|
|
priv->manager_running = TRUE;
|
|
|
|
|
else
|
|
|
|
|
priv->manager_running = FALSE;
|
|
|
|
|
|
|
|
|
|
g_signal_emit (NM_CLIENT (user_data), signals[MANAGER_RUNNING], 0, priv->manager_running);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2007-02-12 09:23:43 +00:00
|
|
|
static void
|
|
|
|
|
client_state_change_proxy (DBusGProxy *proxy, guint state, gpointer user_data)
|
|
|
|
|
{
|
2007-02-20 15:24:42 +00:00
|
|
|
NMClient *client = NM_CLIENT (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
|
|
|
NMClientPrivate *priv = NM_CLIENT_GET_PRIVATE (client);
|
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 (client, signals[STATE_CHANGE], 0, state);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static NMDevice *
|
|
|
|
|
get_device (NMClient *client, const char *path, gboolean create_if_not_found)
|
|
|
|
|
{
|
|
|
|
|
NMClientPrivate *priv = NM_CLIENT_GET_PRIVATE (client);
|
|
|
|
|
NMDevice *device;
|
|
|
|
|
|
|
|
|
|
device = g_hash_table_lookup (priv->devices, path);
|
|
|
|
|
if (!device && create_if_not_found) {
|
|
|
|
|
DBusGConnection *connection = NULL;
|
|
|
|
|
NMDeviceType type;
|
|
|
|
|
|
|
|
|
|
g_object_get (client, "connection", &connection, NULL);
|
|
|
|
|
type = nm_device_type_for_path (connection, path);
|
|
|
|
|
|
|
|
|
|
switch (type) {
|
|
|
|
|
case DEVICE_TYPE_802_3_ETHERNET:
|
|
|
|
|
device = NM_DEVICE (nm_device_802_3_ethernet_new (connection, path));
|
|
|
|
|
break;
|
|
|
|
|
case DEVICE_TYPE_802_11_WIRELESS:
|
|
|
|
|
device = NM_DEVICE (nm_device_802_11_wireless_new (connection, path));
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
device = nm_device_new (connection, path);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (device)
|
|
|
|
|
g_hash_table_insert (priv->devices, g_strdup (path), device);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return device;
|
2007-02-12 09:23:43 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
client_device_added_proxy (DBusGProxy *proxy, char *path, gpointer user_data)
|
|
|
|
|
{
|
2007-02-20 15:24:42 +00:00
|
|
|
NMClient *client = NM_CLIENT (proxy);
|
2007-02-12 09:23:43 +00:00
|
|
|
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
|
|
|
device = get_device (client, path, TRUE);
|
|
|
|
|
if (device)
|
|
|
|
|
g_signal_emit (client, signals[DEVICE_ADDED], 0, device);
|
2007-02-12 09:23:43 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
client_device_removed_proxy (DBusGProxy *proxy, char *path, gpointer user_data)
|
|
|
|
|
{
|
2007-02-20 15:24:42 +00:00
|
|
|
NMClient *client = NM_CLIENT (proxy);
|
2007-02-12 09:23:43 +00:00
|
|
|
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
|
|
|
device = get_device (client, path, FALSE);
|
|
|
|
|
if (device) {
|
|
|
|
|
g_signal_emit (client, signals[DEVICE_REMOVED], 0, device);
|
|
|
|
|
g_hash_table_remove (NM_CLIENT_GET_PRIVATE (client)->devices, path);
|
|
|
|
|
}
|
2007-02-12 09:23:43 +00:00
|
|
|
}
|
|
|
|
|
|
2007-03-16 09:37:53 +00:00
|
|
|
gboolean
|
|
|
|
|
nm_client_manager_is_running (NMClient *client)
|
|
|
|
|
{
|
|
|
|
|
g_return_val_if_fail (NM_IS_CLIENT (client), FALSE);
|
|
|
|
|
|
|
|
|
|
return NM_CLIENT_GET_PRIVATE (client)->manager_running;
|
|
|
|
|
}
|
|
|
|
|
|
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
|
|
|
static void
|
|
|
|
|
devices_to_slist (gpointer key, gpointer value, gpointer user_data)
|
|
|
|
|
{
|
|
|
|
|
GSList **list = (GSList **) user_data;
|
|
|
|
|
|
|
|
|
|
*list = g_slist_prepend (*list, value);
|
|
|
|
|
}
|
2007-02-12 09:23:43 +00:00
|
|
|
|
|
|
|
|
GSList *
|
|
|
|
|
nm_client_get_devices (NMClient *client)
|
|
|
|
|
{
|
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
|
|
|
NMClientPrivate *priv;
|
2007-02-12 09:23:43 +00:00
|
|
|
GSList *list = NULL;
|
|
|
|
|
GPtrArray *array = NULL;
|
|
|
|
|
GError *err = NULL;
|
|
|
|
|
|
|
|
|
|
g_return_val_if_fail (NM_IS_CLIENT (client), NULL);
|
|
|
|
|
|
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_CLIENT_GET_PRIVATE (client);
|
|
|
|
|
|
|
|
|
|
if (priv->have_device_list) {
|
|
|
|
|
g_hash_table_foreach (priv->devices, devices_to_slist, &list);
|
|
|
|
|
return list;
|
|
|
|
|
}
|
|
|
|
|
|
2007-02-12 09:23:43 +00:00
|
|
|
if (!org_freedesktop_NetworkManager_get_devices (DBUS_G_PROXY (client), &array, &err)) {
|
|
|
|
|
g_warning ("Error in get_devices: %s", err->message);
|
|
|
|
|
g_error_free (err);
|
|
|
|
|
} else {
|
|
|
|
|
int i;
|
|
|
|
|
|
|
|
|
|
for (i = 0; i < array->len; i++) {
|
|
|
|
|
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
|
|
|
|
|
|
|
|
device = get_device (client, (const char *) g_ptr_array_index (array, i), TRUE);
|
|
|
|
|
if (device)
|
|
|
|
|
list = g_slist_append (list, device);
|
2007-02-12 09:23:43 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
g_ptr_array_free (array, TRUE);
|
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->have_device_list = TRUE;
|
2007-02-12 09:23:43 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return list;
|
|
|
|
|
}
|
|
|
|
|
|
2007-03-26 12:42:29 +00:00
|
|
|
NMDevice *
|
|
|
|
|
nm_client_get_device_by_path (NMClient *client, const char *object_path)
|
|
|
|
|
{
|
|
|
|
|
GSList *devices;
|
|
|
|
|
GSList *iter;
|
|
|
|
|
NMDevice *device = NULL;
|
|
|
|
|
|
|
|
|
|
g_return_val_if_fail (NM_IS_CLIENT (client), NULL);
|
|
|
|
|
g_return_val_if_fail (object_path, NULL);
|
|
|
|
|
|
|
|
|
|
devices = nm_client_get_devices (client);
|
|
|
|
|
for (iter = devices; iter; iter = iter->next) {
|
|
|
|
|
if (!strcmp (nm_device_get_path (NM_DEVICE (iter->data)), object_path)) {
|
|
|
|
|
device = NM_DEVICE (iter->data);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
g_slist_free (devices);
|
|
|
|
|
|
|
|
|
|
return device;
|
|
|
|
|
}
|
|
|
|
|
|
2007-02-12 09:23:43 +00:00
|
|
|
gboolean
|
|
|
|
|
nm_client_wireless_get_enabled (NMClient *client)
|
|
|
|
|
{
|
|
|
|
|
GValue value = {0,};
|
|
|
|
|
gboolean enabled = FALSE;
|
|
|
|
|
|
|
|
|
|
g_return_val_if_fail (NM_IS_CLIENT (client), enabled);
|
|
|
|
|
|
|
|
|
|
if (nm_dbus_get_property (DBUS_G_PROXY (client),
|
|
|
|
|
NM_DBUS_INTERFACE,
|
|
|
|
|
"WirelessEnabled",
|
|
|
|
|
&value))
|
|
|
|
|
enabled = g_value_get_boolean (&value);
|
|
|
|
|
|
|
|
|
|
return enabled;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
nm_client_wireless_set_enabled (NMClient *client, gboolean enabled)
|
|
|
|
|
{
|
|
|
|
|
GValue value = {0,};
|
|
|
|
|
|
|
|
|
|
g_return_if_fail (NM_IS_CLIENT (client));
|
|
|
|
|
|
|
|
|
|
g_value_init (&value, G_TYPE_BOOLEAN);
|
|
|
|
|
g_value_set_boolean (&value, enabled);
|
|
|
|
|
nm_dbus_set_property (DBUS_G_PROXY (client),
|
|
|
|
|
NM_DBUS_INTERFACE,
|
|
|
|
|
"WirelessEnabled",
|
|
|
|
|
&value);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
NMState
|
|
|
|
|
nm_client_get_state (NMClient *client)
|
|
|
|
|
{
|
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
|
|
|
NMClientPrivate *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_CLIENT (client), NM_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_CLIENT_GET_PRIVATE (client);
|
|
|
|
|
|
|
|
|
|
if (priv->state == NM_STATE_UNKNOWN) {
|
|
|
|
|
GValue value = {0,};
|
|
|
|
|
|
|
|
|
|
if (nm_dbus_get_property (DBUS_G_PROXY (client),
|
|
|
|
|
NM_DBUS_INTERFACE,
|
|
|
|
|
"State",
|
|
|
|
|
&value))
|
|
|
|
|
priv->state = g_value_get_uint (&value);
|
|
|
|
|
}
|
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
|
|
|
|
|
|
|
|
void
|
|
|
|
|
nm_client_sleep (NMClient *client, gboolean sleep)
|
|
|
|
|
{
|
|
|
|
|
GError *err = NULL;
|
|
|
|
|
|
|
|
|
|
g_return_if_fail (NM_IS_CLIENT (client));
|
|
|
|
|
|
|
|
|
|
if (!org_freedesktop_NetworkManager_sleep (DBUS_G_PROXY (client), sleep, &err)) {
|
|
|
|
|
g_warning ("Error in sleep: %s", err->message);
|
|
|
|
|
g_error_free (err);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2007-03-26 12:42:29 +00:00
|
|
|
/* VPN */
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* This "best" state is the summary of all states from all connections and
|
|
|
|
|
* available for convenience.
|
|
|
|
|
* For the exact state, each connection has it's own state which' changes
|
|
|
|
|
* are also signalled.
|
|
|
|
|
*/
|
|
|
|
|
static NMVPNActStage
|
|
|
|
|
nm_client_get_best_vpn_state (NMClient *client)
|
|
|
|
|
{
|
|
|
|
|
GSList *iter;
|
|
|
|
|
NMVPNActStage state;
|
|
|
|
|
NMVPNActStage best_state = NM_VPN_ACT_STAGE_UNKNOWN;
|
|
|
|
|
|
|
|
|
|
for (iter = nm_client_get_vpn_connections (client); iter; iter = iter->next) {
|
|
|
|
|
state = nm_vpn_connection_get_state (NM_VPN_CONNECTION (iter->data));
|
|
|
|
|
if (state > best_state && state < NM_VPN_ACT_STAGE_FAILED)
|
|
|
|
|
best_state = state;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return best_state;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
proxy_vpn_state_change (DBusGProxy *proxy, char *connection_name, NMVPNActStage state, gpointer user_data)
|
|
|
|
|
{
|
|
|
|
|
NMClient *client = NM_CLIENT (user_data);
|
|
|
|
|
NMClientPrivate *priv = NM_CLIENT_GET_PRIVATE (client);
|
|
|
|
|
NMVPNConnection *connection;
|
|
|
|
|
NMVPNActStage best_state;
|
|
|
|
|
|
|
|
|
|
connection = nm_client_get_vpn_connection_by_name (client, connection_name);
|
|
|
|
|
if (connection)
|
|
|
|
|
nm_vpn_connection_set_state (connection, state);
|
|
|
|
|
|
|
|
|
|
best_state = nm_client_get_best_vpn_state (client);
|
|
|
|
|
if (best_state != priv->vpn_state) {
|
|
|
|
|
priv->vpn_state = state;
|
|
|
|
|
g_signal_emit (client, signals[VPN_STATE_CHANGE], 0, best_state);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
proxy_vpn_connection_added (DBusGProxy *proxy, char *name, gpointer user_data)
|
|
|
|
|
{
|
|
|
|
|
NMClient *client = NM_CLIENT (user_data);
|
|
|
|
|
NMClientPrivate *priv = NM_CLIENT_GET_PRIVATE (client);
|
|
|
|
|
NMVPNConnection *connection;
|
|
|
|
|
|
|
|
|
|
connection = nm_vpn_connection_new (proxy, name);
|
|
|
|
|
if (connection) {
|
|
|
|
|
priv->vpn_connection_list = g_slist_append (priv->vpn_connection_list, connection);
|
|
|
|
|
g_signal_emit (client, signals[VPN_CONNECTION_ADDED], 0, connection);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
proxy_vpn_connection_removed (DBusGProxy *proxy, char *name, gpointer user_data)
|
|
|
|
|
{
|
|
|
|
|
NMClient *client = NM_CLIENT (user_data);
|
|
|
|
|
NMVPNConnection *connection;
|
|
|
|
|
|
|
|
|
|
connection = nm_client_get_vpn_connection_by_name (client, name);
|
|
|
|
|
if (connection)
|
|
|
|
|
nm_client_remove_vpn_connection (client, connection);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
proxy_vpn_connection_update (DBusGProxy *proxy, char *name, gpointer user_data)
|
|
|
|
|
{
|
|
|
|
|
NMClient *client = NM_CLIENT (user_data);
|
|
|
|
|
NMVPNConnection *connection;
|
|
|
|
|
|
|
|
|
|
connection = nm_client_get_vpn_connection_by_name (client, name);
|
|
|
|
|
if (connection)
|
|
|
|
|
nm_vpn_connection_update (connection);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
setup_vpn_proxy (NMClient *client, DBusGConnection *connection)
|
|
|
|
|
{
|
|
|
|
|
DBusGProxy *proxy;
|
|
|
|
|
|
|
|
|
|
proxy = dbus_g_proxy_new_for_name (connection,
|
|
|
|
|
NM_DBUS_SERVICE,
|
|
|
|
|
NM_DBUS_PATH_VPN,
|
|
|
|
|
NM_DBUS_INTERFACE_VPN);
|
|
|
|
|
|
|
|
|
|
dbus_g_object_register_marshaller (nm_marshal_VOID__STRING_INT,
|
|
|
|
|
G_TYPE_NONE, G_TYPE_STRING, G_TYPE_UINT, G_TYPE_INVALID);
|
|
|
|
|
|
|
|
|
|
dbus_g_proxy_add_signal (proxy, "VPNConnectionStateChange", G_TYPE_STRING, G_TYPE_UINT, G_TYPE_INVALID);
|
|
|
|
|
dbus_g_proxy_connect_signal (proxy, "VPNConnectionStateChange",
|
|
|
|
|
G_CALLBACK (proxy_vpn_state_change),
|
|
|
|
|
client, NULL);
|
|
|
|
|
|
|
|
|
|
dbus_g_proxy_add_signal (proxy, "VPNConnectionAdded", G_TYPE_STRING, G_TYPE_INVALID);
|
|
|
|
|
dbus_g_proxy_connect_signal (proxy, "VPNConnectionAdded",
|
|
|
|
|
G_CALLBACK (proxy_vpn_connection_added),
|
|
|
|
|
client, NULL);
|
|
|
|
|
|
|
|
|
|
dbus_g_proxy_add_signal (proxy, "VPNConnectionRemoved", G_TYPE_STRING, G_TYPE_INVALID);
|
|
|
|
|
dbus_g_proxy_connect_signal (proxy, "VPNConnectionRemoved",
|
|
|
|
|
G_CALLBACK (proxy_vpn_connection_removed),
|
|
|
|
|
client, NULL);
|
|
|
|
|
|
|
|
|
|
dbus_g_proxy_add_signal (proxy, "VPNConnectionUpdate", G_TYPE_STRING, G_TYPE_INVALID);
|
|
|
|
|
dbus_g_proxy_connect_signal (proxy, "VPNConnectionUpdate",
|
|
|
|
|
G_CALLBACK (proxy_vpn_connection_update),
|
|
|
|
|
client, NULL);
|
|
|
|
|
|
|
|
|
|
NM_CLIENT_GET_PRIVATE (client)->vpn_proxy = proxy;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
get_connections (NMClient *client)
|
|
|
|
|
{
|
|
|
|
|
NMClientPrivate *priv = NM_CLIENT_GET_PRIVATE (client);
|
|
|
|
|
char **name;
|
|
|
|
|
char **vpn_names = NULL;
|
|
|
|
|
GError *err = NULL;
|
|
|
|
|
|
|
|
|
|
if (!dbus_g_proxy_call (priv->vpn_proxy, "getVPNConnections", &err,
|
|
|
|
|
G_TYPE_INVALID,
|
|
|
|
|
G_TYPE_STRV, &vpn_names,
|
|
|
|
|
G_TYPE_INVALID)) {
|
|
|
|
|
g_warning ("Error while getting VPN connections: %s", err->message);
|
|
|
|
|
g_error_free (err);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
for (name = vpn_names; *name; name++)
|
|
|
|
|
proxy_vpn_connection_added (priv->vpn_proxy, *name, client);
|
|
|
|
|
g_strfreev (vpn_names);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
GSList *
|
|
|
|
|
nm_client_get_vpn_connections (NMClient *client)
|
|
|
|
|
{
|
|
|
|
|
NMClientPrivate *priv;
|
|
|
|
|
|
|
|
|
|
g_return_val_if_fail (NM_IS_CLIENT (client), NULL);
|
|
|
|
|
|
|
|
|
|
priv = NM_CLIENT_GET_PRIVATE (client);
|
|
|
|
|
|
|
|
|
|
if (!priv->have_vpn_connection_list) {
|
|
|
|
|
get_connections (client);
|
|
|
|
|
priv->have_vpn_connection_list = TRUE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return priv->vpn_connection_list;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
NMVPNConnection *
|
|
|
|
|
nm_client_get_vpn_connection_by_name (NMClient *client, const char *name)
|
|
|
|
|
{
|
|
|
|
|
GSList *iter;
|
|
|
|
|
|
|
|
|
|
for (iter = nm_client_get_vpn_connections (client); iter; iter = iter->next) {
|
|
|
|
|
NMVPNConnection *connection = NM_VPN_CONNECTION (iter->data);
|
|
|
|
|
|
|
|
|
|
if (!strcmp (nm_vpn_connection_get_name (connection), name))
|
|
|
|
|
return connection;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
nm_client_remove_vpn_connection (NMClient *client, NMVPNConnection *connection)
|
|
|
|
|
{
|
|
|
|
|
NMClientPrivate *priv;
|
|
|
|
|
|
|
|
|
|
g_return_if_fail (NM_IS_CLIENT (client));
|
|
|
|
|
g_return_if_fail (NM_IS_VPN_CONNECTION (connection));
|
|
|
|
|
|
|
|
|
|
/* Note that the connection isn't removed from NetworkManager, it's
|
|
|
|
|
because it doesn't have DBUS API for that right now. */
|
|
|
|
|
|
|
|
|
|
priv = NM_CLIENT_GET_PRIVATE (client);
|
|
|
|
|
|
|
|
|
|
priv->vpn_connection_list = g_slist_remove (priv->vpn_connection_list, connection);
|
|
|
|
|
g_signal_emit (client, signals[VPN_CONNECTION_REMOVED], 0, connection);
|
|
|
|
|
g_object_unref (connection);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
NMVPNActStage
|
|
|
|
|
nm_client_get_vpn_state (NMClient *client)
|
|
|
|
|
{
|
|
|
|
|
NMClientPrivate *priv;
|
|
|
|
|
|
|
|
|
|
g_return_val_if_fail (NM_IS_CLIENT (client), NM_VPN_ACT_STAGE_UNKNOWN);
|
|
|
|
|
|
|
|
|
|
priv = NM_CLIENT_GET_PRIVATE (client);
|
|
|
|
|
|
|
|
|
|
if (priv->vpn_state == NM_VPN_ACT_STAGE_UNKNOWN)
|
|
|
|
|
priv->vpn_state = nm_client_get_best_vpn_state (client);
|
|
|
|
|
|
|
|
|
|
return priv->vpn_state;
|
|
|
|
|
}
|