3
0
mirror of https://git.kernel.org/pub/scm/network/wireless/iwd.git synced 2024-12-22 13:02:44 +01:00

agent: Add reason parameter to Cancel

Add a parameter the UI can use to show user an explanation of why a
password prompt is disappearing.
This commit is contained in:
Andrew Zaborowski 2016-06-10 11:49:34 +02:00 committed by Denis Kenzior
parent e30a2093ce
commit 99f99e0bc0
5 changed files with 44 additions and 14 deletions

View File

@ -83,11 +83,41 @@ static void send_request(struct agent *agent, const char *request)
l_dbus_send(dbus_get_bus(), message);
}
static void send_cancel_request(void *user_data)
static void send_cancel_request(void *user_data, int reason)
{
struct agent *agent = user_data;
struct l_dbus_message *message;
const char *reasonstr;
send_request(agent, "Cancel");
switch (reason) {
case -ECANCELED:
reasonstr = "user-canceled";
break;
case -ETIMEDOUT:
reasonstr = "timed-out";
break;
case -ERANGE:
reasonstr = "out-of-range";
break;
case -ESHUTDOWN:
reasonstr = "shutdown";
break;
default:
reasonstr = "unknown";
}
l_debug("send a Cancel(%s) to %s %s", reasonstr,
agent->owner, agent->path);
message = l_dbus_message_new_method_call(dbus_get_bus(),
agent->owner,
agent->path,
IWD_AGENT_INTERFACE,
"Cancel");
l_dbus_message_set_arguments(message, "s", reasonstr);
l_dbus_send(dbus_get_bus(), message);
}
static void agent_request_free(void *user_data)
@ -177,7 +207,7 @@ static void request_timeout(struct l_timeout *timeout, void *user_data)
l_dbus_cancel(dbus_get_bus(), agent->pending_id);
send_cancel_request(agent);
send_cancel_request(agent, -ETIMEDOUT);
agent_finalize_pending(agent, NULL);
@ -301,7 +331,7 @@ static bool find_request(const void *a, const void *b)
return request->id == id;
}
bool agent_request_cancel(unsigned int req_id)
bool agent_request_cancel(unsigned int req_id, int reason)
{
struct agent_request *request;
@ -314,7 +344,7 @@ bool agent_request_cancel(unsigned int req_id)
return false;
if (!request->message)
send_cancel_request(default_agent);
send_cancel_request(default_agent, reason);
agent_request_free(request);

View File

@ -40,4 +40,4 @@ unsigned int agent_request_passphrase(const char *path,
agent_request_passphrase_func_t callback,
struct l_dbus_message *message,
void *user_data);
bool agent_request_cancel(unsigned int req_id);
bool agent_request_cancel(unsigned int req_id, int reason);

View File

@ -645,11 +645,11 @@ bool network_register(struct network *network, const char *path)
return true;
}
static void network_unregister(struct network *network)
static void network_unregister(struct network *network, int reason)
{
struct l_dbus *dbus = dbus_get_bus();
agent_request_cancel(network->agent_request);
agent_request_cancel(network->agent_request, reason);
network_settings_close(network);
l_dbus_unregister_object(dbus, network->object_path);
@ -658,10 +658,10 @@ static void network_unregister(struct network *network)
network->object_path = NULL;
}
void network_remove(struct network *network)
void network_remove(struct network *network, int reason)
{
if (network->object_path)
network_unregister(network);
network_unregister(network, reason);
l_queue_destroy(network->bss_list, NULL);
l_free(network->psk);

View File

@ -54,7 +54,7 @@ void network_bss_list_clear(struct network *network);
bool network_register(struct network *network, const char *path);
void network_remove(struct network *network);
void network_remove(struct network *network, int reason);
void network_init();
void network_exit();

View File

@ -325,7 +325,7 @@ static void network_free(void *data)
{
struct network *network = data;
network_remove(network);
network_remove(network, -ESHUTDOWN);
}
const char *device_get_path(struct device *device)
@ -1176,7 +1176,7 @@ static bool network_remove_if_lost(const void *key, void *data, void *user_data)
l_debug("No remaining BSSs for SSID: %s -- Removing network",
network_get_ssid(network));
network_remove(network);
network_remove(network, -ERANGE);
return true;
}
@ -1253,7 +1253,7 @@ static void process_bss(struct device *device, struct scan_bss *bss)
security);
if (!network_register(network, path)) {
network_remove(network);
network_remove(network, -EINVAL);
return;
}