3
0
mirror of https://git.kernel.org/pub/scm/network/wireless/iwd.git synced 2024-11-29 13:59:24 +01:00

station: Move dbus disconnection logic from device

This commit is contained in:
Denis Kenzior 2018-09-04 19:58:37 -05:00
parent 12ce9debec
commit 77b006b4e9
3 changed files with 34 additions and 19 deletions

View File

@ -526,27 +526,11 @@ static struct l_dbus_message *device_dbus_disconnect(struct l_dbus *dbus,
{ {
struct device *device = user_data; struct device *device = user_data;
struct station *station = device->station; struct station *station = device->station;
int result;
l_debug(""); if (!device->powered || !device->station)
return dbus_error_not_available(message);
/* return station_dbus_disconnect(dbus, message, station);
* Disconnect was triggered by the user, don't autoconnect. Wait for
* the user's explicit instructions to scan and connect to the network
*/
station_set_autoconnect(station, false);
if (station->state == STATION_STATE_AUTOCONNECT ||
station->state == STATION_STATE_DISCONNECTED)
return l_dbus_message_new_method_return(message);
result = station_disconnect(station);
if (result < 0)
return dbus_error_from_errno(result, message);
station->disconnect_pending = l_dbus_message_ref(message);
return NULL;
} }
static struct l_dbus_message *device_get_networks(struct l_dbus *dbus, static struct l_dbus_message *device_get_networks(struct l_dbus *dbus,

View File

@ -1436,6 +1436,34 @@ int station_disconnect(struct station *station)
return 0; return 0;
} }
struct l_dbus_message *station_dbus_disconnect(struct l_dbus *dbus,
struct l_dbus_message *message,
void *user_data)
{
struct station *station = user_data;
int result;
l_debug("");
/*
* Disconnect was triggered by the user, don't autoconnect. Wait for
* the user's explicit instructions to scan and connect to the network
*/
station_set_autoconnect(station, false);
if (station->state == STATION_STATE_AUTOCONNECT ||
station->state == STATION_STATE_DISCONNECTED)
return l_dbus_message_new_method_return(message);
result = station_disconnect(station);
if (result < 0)
return dbus_error_from_errno(result, message);
station->disconnect_pending = l_dbus_message_ref(message);
return NULL;
}
static void station_dbus_scan_triggered(int err, void *user_data) static void station_dbus_scan_triggered(int err, void *user_data)
{ {
struct station *station = user_data; struct station *station = user_data;

View File

@ -114,6 +114,9 @@ struct l_dbus_message *station_dbus_connect_hidden_network(
struct l_dbus *dbus, struct l_dbus *dbus,
struct l_dbus_message *message, struct l_dbus_message *message,
void *user_data); void *user_data);
struct l_dbus_message *station_dbus_disconnect(struct l_dbus *dbus,
struct l_dbus_message *message,
void *user_data);
struct l_dbus_message *station_dbus_scan(struct l_dbus *dbus, struct l_dbus_message *station_dbus_scan(struct l_dbus *dbus,
struct l_dbus_message *message, struct l_dbus_message *message,
void *user_data); void *user_data);