2007-02-20 Tambet Ingo <tambet@ximian.com>
* libnm-glib/nm-device-802-11-wireless.c: Add "network-added" and "network-removed" signals. * libnm-glib/libnm-glib.pc.in: Require NetworkManager >= 0.7.0. * libnm-glib/nm-access-point.c: Add "strength-changed" signal, emit it when receiving the signal from dbus. * src/nm-device-802-11-wireless.c (get_property): Fix PROP_ACTIVE_NETWORK property. * src/NetworkManagerPolicy.c (state_changed): Fix a typo to make the deactivation of the previously activated device working again. * src/nm-activation-request.c: Remove NMActStage property and it's getter and setter. * src/nm-device.c (nm_device_is_activated): Remove. state == NM_DEVICE_STATE_ACTIVATED is just as easy to use. * include/NetworkManager.h: Remove NM_DBUS_NO_DEVICES_ERROR, NM_DBUS_NO_DIALUP_ERROR, NM_DBUS_NO_NETWORKS_ERROR, NM_DBUS_NO_ACTIVE_DEVICE_ERROR, NM_DBUS_NO_ACTIVE_NET_ERROR errors and NM_DBUS_SIGNAL_STATE_CHANGE signal. Remove NMNetworkStatus and NMActStage enums. git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@2345 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
This commit is contained in:
@@ -41,12 +41,6 @@
|
||||
#include "nm-dhcp-manager.h"
|
||||
#include "nm-dbus-manager.h"
|
||||
|
||||
#if 0
|
||||
static char *get_nmi_match_string (const char *owner);
|
||||
|
||||
static gpointer nm_dbus_reinit (gpointer user_data);
|
||||
#endif
|
||||
|
||||
/*
|
||||
* nm_dbus_create_error_message
|
||||
*
|
||||
@@ -132,50 +126,6 @@ char * nm_dbus_get_object_path_for_network (NMDevice *dev, NMAccessPoint *ap)
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* nm_dbus_get_device_from_escaped_object_path
|
||||
*
|
||||
* Returns the device associated with an _escaped_ dbus object path
|
||||
*
|
||||
*/
|
||||
NMDevice *nm_dbus_get_device_from_escaped_object_path (NMData *data, const char *path)
|
||||
{
|
||||
NMDevice *dev = NULL;
|
||||
GSList * elt;
|
||||
|
||||
g_return_val_if_fail (path != NULL, NULL);
|
||||
g_return_val_if_fail (data != NULL, NULL);
|
||||
|
||||
/* Iterate over the device list looking for the device with the matching object path. */
|
||||
for (elt = data->dev_list; elt; elt = g_slist_next (elt)) {
|
||||
char *compare_path;
|
||||
char *escaped_compare_path;
|
||||
int len;
|
||||
|
||||
if (!(dev = NM_DEVICE (elt->data)))
|
||||
continue;
|
||||
|
||||
compare_path = g_strdup_printf ("%s/%s", NM_DBUS_PATH_DEVICE, nm_device_get_iface (dev));
|
||||
escaped_compare_path = nm_dbus_escape_object_path (compare_path);
|
||||
g_free (compare_path);
|
||||
len = strlen (escaped_compare_path);
|
||||
|
||||
/* Compare against our constructed path, but ignore any trailing elements */
|
||||
if ( (strncmp (path, escaped_compare_path, len) == 0)
|
||||
&& ((path[len] == '\0' || path[len] == '/')))
|
||||
{
|
||||
g_free (escaped_compare_path);
|
||||
g_object_ref (G_OBJECT (dev));
|
||||
break;
|
||||
}
|
||||
g_free (escaped_compare_path);
|
||||
dev = NULL;
|
||||
}
|
||||
|
||||
return dev;
|
||||
}
|
||||
|
||||
|
||||
/*-------------------------------------------------------------*/
|
||||
/* Handler code */
|
||||
/*-------------------------------------------------------------*/
|
||||
|
@@ -41,7 +41,6 @@ static inline gboolean message_is_error (DBusMessage *msg)
|
||||
|
||||
char * nm_dbus_get_object_path_for_device (NMDevice *dev);
|
||||
char * nm_dbus_get_object_path_for_network (NMDevice *dev, NMAccessPoint *ap);
|
||||
NMDevice * nm_dbus_get_device_from_escaped_object_path (NMData *data, const char *path);
|
||||
|
||||
DBusMessage * nm_dbus_create_error_message (DBusMessage *message, const char *exception_namespace, const char *exception, const char *format, ...);
|
||||
|
||||
|
@@ -539,7 +539,7 @@ state_changed (NMManager *manager, NMState state, gpointer user_data)
|
||||
{
|
||||
NMPolicy *policy = (NMPolicy *) user_data;
|
||||
|
||||
if (state == NM_ACT_STAGE_DEVICE_PREPARE) {
|
||||
if (state == NM_STATE_CONNECTING) {
|
||||
/* A device starts activation, bring all devices down
|
||||
* Remove this when we support multiple active devices.
|
||||
*/
|
||||
|
@@ -40,7 +40,6 @@ struct NMActRequest
|
||||
|
||||
gboolean user_requested;
|
||||
|
||||
NMActStage stage;
|
||||
DBusPendingCall * user_key_pcall;
|
||||
};
|
||||
|
||||
@@ -143,57 +142,6 @@ void nm_act_request_set_ip4_config (NMActRequest *req, NMIP4Config *ip4_config)
|
||||
req->ip4_config = g_object_ref (ip4_config);
|
||||
}
|
||||
|
||||
NMActStage nm_act_request_get_stage (NMActRequest *req)
|
||||
{
|
||||
g_return_val_if_fail (req != NULL, NM_ACT_STAGE_UNKNOWN);
|
||||
|
||||
return req->stage;
|
||||
}
|
||||
|
||||
void nm_act_request_set_stage (NMActRequest *req, NMActStage stage)
|
||||
{
|
||||
DBusMessage * message;
|
||||
char * dev_path = NULL;
|
||||
NMDBusManager * dbus_mgr = NULL;
|
||||
DBusConnection *dbus_connection;
|
||||
|
||||
g_return_if_fail (req != NULL);
|
||||
|
||||
req->stage = stage;
|
||||
|
||||
g_return_if_fail (req->data);
|
||||
g_return_if_fail (req->dev);
|
||||
|
||||
dbus_mgr = nm_dbus_manager_get ();
|
||||
dbus_connection = nm_dbus_manager_get_dbus_connection (dbus_mgr);
|
||||
if (!dbus_connection) {
|
||||
nm_warning ("couldn't get the dbus connection.");
|
||||
goto out;
|
||||
}
|
||||
|
||||
if (!(dev_path = nm_dbus_get_object_path_for_device (req->dev)))
|
||||
goto out;
|
||||
|
||||
message = dbus_message_new_signal (NM_DBUS_PATH,
|
||||
NM_DBUS_INTERFACE,
|
||||
"DeviceActivationStage");
|
||||
if (!message) {
|
||||
nm_warning ("couldn't allocate the dbus message.");
|
||||
goto out;
|
||||
}
|
||||
|
||||
dbus_message_append_args (message,
|
||||
DBUS_TYPE_OBJECT_PATH, &dev_path,
|
||||
DBUS_TYPE_UINT32, &stage,
|
||||
DBUS_TYPE_INVALID);
|
||||
dbus_connection_send (dbus_connection, message, NULL);
|
||||
dbus_message_unref (message);
|
||||
|
||||
out:
|
||||
g_free (dev_path);
|
||||
g_object_unref (dbus_mgr);
|
||||
}
|
||||
|
||||
DBusPendingCall * nm_act_request_get_user_key_pending_call (NMActRequest *req)
|
||||
{
|
||||
g_return_val_if_fail (req != NULL, NULL);
|
||||
|
@@ -44,9 +44,6 @@ gboolean nm_act_request_get_user_requested (NMActRequest *req);
|
||||
NMIP4Config * nm_act_request_get_ip4_config (NMActRequest *req);
|
||||
void nm_act_request_set_ip4_config (NMActRequest *req, NMIP4Config *ip4_config);
|
||||
|
||||
NMActStage nm_act_request_get_stage (NMActRequest *req);
|
||||
void nm_act_request_set_stage (NMActRequest *req, NMActStage stage);
|
||||
|
||||
DBusPendingCall * nm_act_request_get_user_key_pending_call (NMActRequest *req);
|
||||
void nm_act_request_set_user_key_pending_call (NMActRequest *req, DBusPendingCall *pcall);
|
||||
|
||||
|
@@ -185,7 +185,6 @@ nm_dbus_get_user_key_for_network (NMActRequest *req,
|
||||
__func__);
|
||||
if (pcall) {
|
||||
nm_act_request_ref (req);
|
||||
nm_act_request_set_stage (req, NM_ACT_STAGE_NEED_USER_KEY);
|
||||
nm_act_request_set_user_key_pending_call (req, pcall);
|
||||
}
|
||||
} else {
|
||||
|
@@ -1916,7 +1916,7 @@ request_wireless_scan (gpointer user_data)
|
||||
* for the case we lose this connection shortly, it will reach this point and then
|
||||
* nm_device_is_activated will return FALSE, letting the scan proceed.
|
||||
*/
|
||||
if ((self->priv->num_freqs > 14) && nm_device_is_activated (NM_DEVICE (self)) == TRUE)
|
||||
if (self->priv->num_freqs > 14 && nm_device_get_state (NM_DEVICE (self)) == NM_DEVICE_STATE_ACTIVATED)
|
||||
{
|
||||
nm_device_802_11_wireless_set_scan_interval (app_data, self, NM_WIRELESS_SCAN_INTERVAL_ACTIVE);
|
||||
schedule_scan (self);
|
||||
@@ -2471,7 +2471,7 @@ link_timeout_cb (gpointer user_data)
|
||||
* ARE checked - we are likely to have wrong key. Ask the user for
|
||||
* another one.
|
||||
*/
|
||||
if ( (nm_act_request_get_stage (req) == NM_ACT_STAGE_DEVICE_CONFIG)
|
||||
if ((nm_device_get_state (dev) == NM_DEVICE_STATE_CONFIG)
|
||||
&& (ap_is_auth_required (ap, &has_key) && has_key)) {
|
||||
/* Association/authentication failed, we must have bad encryption key */
|
||||
nm_info ("Activation (%s/wireless): disconnected during association,"
|
||||
@@ -2607,7 +2607,7 @@ supplicant_iface_connection_state_cb_handler (gpointer user_data)
|
||||
/* If this is the initial association during device activation,
|
||||
* schedule the next activation stage.
|
||||
*/
|
||||
if (nm_act_request_get_stage (req) == NM_ACT_STAGE_DEVICE_CONFIG) {
|
||||
if (nm_device_get_state (dev) == NM_DEVICE_STATE_CONFIG) {
|
||||
NMAccessPoint * ap = nm_act_request_get_ap (req);
|
||||
|
||||
nm_info ("Activation (%s/wireless) Stage 2 of 5 (Device Configure) "
|
||||
@@ -2617,7 +2617,7 @@ supplicant_iface_connection_state_cb_handler (gpointer user_data)
|
||||
nm_device_activate_schedule_stage3_ip_config_start (req);
|
||||
}
|
||||
} else if (new_state == NM_SUPPLICANT_INTERFACE_CON_STATE_DISCONNECTED) {
|
||||
if (nm_device_is_activated (dev) || nm_device_is_activating (dev)) {
|
||||
if (nm_device_get_state (dev) == NM_DEVICE_STATE_ACTIVATED || nm_device_is_activating (dev)) {
|
||||
gboolean has_link = nm_device_has_active_link (NM_DEVICE (self));
|
||||
|
||||
/* Start the link timeout so we allow some time for reauthentication */
|
||||
@@ -3263,7 +3263,7 @@ real_activation_cancel_handler (NMDevice *dev,
|
||||
parent_class = NM_DEVICE_CLASS (g_type_class_peek_parent (klass));
|
||||
parent_class->activation_cancel_handler (dev, req);
|
||||
|
||||
if (nm_act_request_get_stage (req) == NM_ACT_STAGE_NEED_USER_KEY)
|
||||
if (nm_device_get_state (dev) == NM_DEVICE_STATE_NEED_AUTH)
|
||||
nm_dbus_cancel_get_user_key_for_network (req);
|
||||
|
||||
cleanup_association_attempt (self, TRUE);
|
||||
@@ -3273,15 +3273,10 @@ real_activation_cancel_handler (NMDevice *dev,
|
||||
static gboolean
|
||||
real_can_interrupt_activation (NMDevice *dev)
|
||||
{
|
||||
NMActRequest * req;
|
||||
gboolean interrupt = FALSE;
|
||||
if (nm_device_get_state (dev) == NM_DEVICE_STATE_NEED_AUTH)
|
||||
return TRUE;
|
||||
|
||||
if ( (req = nm_device_get_act_request (dev))
|
||||
&& (nm_act_request_get_stage (req) == NM_ACT_STAGE_NEED_USER_KEY))
|
||||
{
|
||||
interrupt = TRUE;
|
||||
}
|
||||
return interrupt;
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
|
||||
@@ -3360,6 +3355,8 @@ get_property (GObject *object, guint prop_id,
|
||||
NMDevice80211Wireless *device = NM_DEVICE_802_11_WIRELESS (object);
|
||||
struct ether_addr hw_addr;
|
||||
char hw_addr_buf[20];
|
||||
NMAccessPoint *ap;
|
||||
NMActRequest *req;
|
||||
|
||||
switch (prop_id) {
|
||||
case PROP_HW_ADDRESS:
|
||||
@@ -3375,16 +3372,13 @@ get_property (GObject *object, guint prop_id,
|
||||
g_value_set_int (value, nm_device_802_11_wireless_get_bitrate (device));
|
||||
break;
|
||||
case PROP_ACTIVE_NETWORK:
|
||||
/* FIXME: */
|
||||
#if 0
|
||||
req = nm_device_get_act_request (NM_DEVICE (device));
|
||||
if (req && ap = nm_act_request_get_ap (req)) {
|
||||
if (req && (ap = nm_act_request_get_ap (req))) {
|
||||
NMAccessPoint *tmp_ap;
|
||||
|
||||
if ((tmp_ap = nm_device_802_11_wireless_ap_list_get_ap_by_essid (device, nm_ap_get_essid (ap))))
|
||||
g_value_set_object (value, tmp_ap);
|
||||
}
|
||||
#endif
|
||||
break;
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
||||
|
@@ -34,8 +34,6 @@ typedef struct NMDbusCBData {
|
||||
|
||||
void nm_device_set_device_type (NMDevice *dev, NMDeviceType type);
|
||||
|
||||
gboolean nm_device_is_activated (NMDevice *dev);
|
||||
|
||||
NMIP4Config * nm_device_new_ip4_autoip_config (NMDevice *self);
|
||||
|
||||
void nm_device_activate_schedule_stage3_ip_config_start (struct NMActRequest *req);
|
||||
|
@@ -402,7 +402,6 @@ nm_device_activate (NMDevice *device,
|
||||
nm_act_request_ref (req);
|
||||
priv->act_request = req;
|
||||
|
||||
nm_act_request_set_stage (req, NM_ACT_STAGE_DEVICE_PREPARE);
|
||||
nm_device_activate_schedule_stage1_device_prepare (req);
|
||||
}
|
||||
|
||||
@@ -472,7 +471,6 @@ nm_device_activate_schedule_stage1_device_prepare (NMActRequest *req)
|
||||
self = nm_act_request_get_dev (req);
|
||||
g_assert (self);
|
||||
|
||||
nm_act_request_set_stage (req, NM_ACT_STAGE_DEVICE_PREPARE);
|
||||
id = g_idle_add (nm_device_activate_stage1_device_prepare, req);
|
||||
self->priv->act_source_id = id;
|
||||
|
||||
@@ -567,7 +565,6 @@ nm_device_activate_schedule_stage2_device_config (NMActRequest *req)
|
||||
self = nm_act_request_get_dev (req);
|
||||
g_assert (self);
|
||||
|
||||
nm_act_request_set_stage (req, NM_ACT_STAGE_DEVICE_CONFIG);
|
||||
id = g_idle_add (nm_device_activate_stage2_device_config, req);
|
||||
self->priv->act_source_id = id;
|
||||
|
||||
@@ -680,7 +677,6 @@ nm_device_activate_schedule_stage3_ip_config_start (NMActRequest *req)
|
||||
self = nm_act_request_get_dev (req);
|
||||
g_assert (self);
|
||||
|
||||
nm_act_request_set_stage (req, NM_ACT_STAGE_IP_CONFIG_START);
|
||||
id = g_idle_add (nm_device_activate_stage3_ip_config_start, req);
|
||||
self->priv->act_source_id = id;
|
||||
|
||||
@@ -827,7 +823,6 @@ nm_device_activate_schedule_stage4_ip_config_get (NMActRequest *req)
|
||||
self = nm_act_request_get_dev (req);
|
||||
g_assert (self);
|
||||
|
||||
nm_act_request_set_stage (req, NM_ACT_STAGE_IP_CONFIG_GET);
|
||||
id = g_idle_add (nm_device_activate_stage4_ip_config_get, req);
|
||||
self->priv->act_source_id = id;
|
||||
|
||||
@@ -921,7 +916,6 @@ nm_device_activate_schedule_stage4_ip_config_timeout (NMActRequest *req)
|
||||
self = nm_act_request_get_dev (req);
|
||||
g_assert (self);
|
||||
|
||||
nm_act_request_set_stage (req, NM_ACT_STAGE_IP_CONFIG_GET);
|
||||
id = g_idle_add (nm_device_activate_stage4_ip_config_timeout, req);
|
||||
self->priv->act_source_id = id;
|
||||
|
||||
@@ -1003,7 +997,6 @@ nm_device_activate_schedule_stage5_ip_config_commit (NMActRequest *req)
|
||||
self = nm_act_request_get_dev (req);
|
||||
g_assert (self);
|
||||
|
||||
nm_act_request_set_stage (req, NM_ACT_STAGE_IP_CONFIG_COMMIT);
|
||||
id = g_idle_add (nm_device_activate_stage5_ip_config_commit, req);
|
||||
self->priv->act_source_id = id;
|
||||
|
||||
@@ -1170,48 +1163,6 @@ nm_device_is_activating (NMDevice *device)
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* nm_device_is_activated
|
||||
*
|
||||
* Return whether or not the device is successfully activated.
|
||||
*
|
||||
*/
|
||||
gboolean
|
||||
nm_device_is_activated (NMDevice *dev)
|
||||
{
|
||||
NMActRequest * req;
|
||||
NMActStage stage;
|
||||
gboolean activated = FALSE;
|
||||
|
||||
g_return_val_if_fail (dev != NULL, FALSE);
|
||||
|
||||
if (!(req = nm_device_get_act_request (dev)))
|
||||
return FALSE;
|
||||
|
||||
stage = nm_act_request_get_stage (req);
|
||||
switch (stage)
|
||||
{
|
||||
case NM_ACT_STAGE_ACTIVATED:
|
||||
activated = TRUE;
|
||||
break;
|
||||
|
||||
case NM_ACT_STAGE_DEVICE_PREPARE:
|
||||
case NM_ACT_STAGE_DEVICE_CONFIG:
|
||||
case NM_ACT_STAGE_NEED_USER_KEY:
|
||||
case NM_ACT_STAGE_IP_CONFIG_START:
|
||||
case NM_ACT_STAGE_IP_CONFIG_GET:
|
||||
case NM_ACT_STAGE_IP_CONFIG_COMMIT:
|
||||
case NM_ACT_STAGE_FAILED:
|
||||
case NM_ACT_STAGE_CANCELLED:
|
||||
case NM_ACT_STAGE_UNKNOWN:
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return activated;
|
||||
}
|
||||
|
||||
|
||||
gboolean
|
||||
nm_device_can_interrupt_activation (NMDevice *self)
|
||||
{
|
||||
@@ -1239,8 +1190,7 @@ dhcp_state_changed (NMDHCPManager *dhcp_manager,
|
||||
if (!req)
|
||||
return;
|
||||
|
||||
if (!strcmp (nm_device_get_iface (device), iface) &&
|
||||
nm_act_request_get_stage (req) == NM_ACT_STAGE_IP_CONFIG_START) {
|
||||
if (!strcmp (nm_device_get_iface (device), iface) && nm_device_get_state (device) == NM_DEVICE_STATE_IP_CONFIG) {
|
||||
switch (state) {
|
||||
case DHCDBD_BOUND: /* lease obtained */
|
||||
case DHCDBD_RENEW: /* lease renewed */
|
||||
|
Reference in New Issue
Block a user