iwd_agent: surface Cancel + stub EAP methods, expose cancel hook
iwd's Cancel(reason) now invokes a UI callback (registered via iwd_manager_set_cancel_handler) so the popup can tear down an open auth dialog. Stubbed RequestPrivateKeyPassphrase / RequestUserNameAndPassword / RequestUserPassword to return Canceled instead of leaving them unimplemented (which would unregister us). Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
7a55d1da5a
commit
9f2a9373aa
4 changed files with 57 additions and 1 deletions
|
|
@ -13,6 +13,8 @@ struct _Iwd_Agent
|
|||
Eldbus_Proxy *am_proxy;
|
||||
Iwd_Agent_Passphrase_Cb cb;
|
||||
void *data;
|
||||
Iwd_Agent_Cancel_Cb cancel_cb;
|
||||
void *cancel_data;
|
||||
};
|
||||
|
||||
struct _Iwd_Agent_Request
|
||||
|
|
@ -36,10 +38,26 @@ static Eldbus_Message *
|
|||
_cancel_cb(const Eldbus_Service_Interface *iface EINA_UNUSED,
|
||||
const Eldbus_Message *msg)
|
||||
{
|
||||
/* iwd dropped the auth attempt; we just ack. */
|
||||
/* iwd dropped the auth attempt; let the UI tear down its dialog. */
|
||||
const char *reason = NULL;
|
||||
if (!eldbus_message_arguments_get(msg, "s", &reason)) reason = NULL;
|
||||
if (_self && _self->cancel_cb)
|
||||
_self->cancel_cb(_self->cancel_data, reason);
|
||||
return eldbus_message_method_return_new(msg);
|
||||
}
|
||||
|
||||
/* iwd may also call these for EAP networks. We don't have UI for them yet,
|
||||
* so politely refuse — that just fails the connect attempt instead of
|
||||
* getting our agent unregistered. */
|
||||
static Eldbus_Message *
|
||||
_unsupported_cb(const Eldbus_Service_Interface *iface EINA_UNUSED,
|
||||
const Eldbus_Message *msg)
|
||||
{
|
||||
return eldbus_message_error_new(msg,
|
||||
"net.connman.iwd.Agent.Error.Canceled",
|
||||
"Method not supported by this agent");
|
||||
}
|
||||
|
||||
static Eldbus_Message *
|
||||
_request_passphrase_cb(const Eldbus_Service_Interface *iface EINA_UNUSED,
|
||||
const Eldbus_Message *msg)
|
||||
|
|
@ -70,6 +88,18 @@ static const Eldbus_Method _methods[] = {
|
|||
{ "Cancel",
|
||||
ELDBUS_ARGS({ "s", "reason" }),
|
||||
NULL, _cancel_cb, 0 },
|
||||
{ "RequestPrivateKeyPassphrase",
|
||||
ELDBUS_ARGS({ "o", "network" }),
|
||||
ELDBUS_ARGS({ "s", "passphrase" }),
|
||||
_unsupported_cb, 0 },
|
||||
{ "RequestUserNameAndPassword",
|
||||
ELDBUS_ARGS({ "o", "network" }),
|
||||
ELDBUS_ARGS({ "s", "user" }, { "s", "password" }),
|
||||
_unsupported_cb, 0 },
|
||||
{ "RequestUserPassword",
|
||||
ELDBUS_ARGS({ "o", "network" }, { "s", "user" }),
|
||||
ELDBUS_ARGS({ "s", "password" }),
|
||||
_unsupported_cb, 0 },
|
||||
{ NULL, NULL, NULL, NULL, 0 }
|
||||
};
|
||||
|
||||
|
|
@ -137,6 +167,14 @@ iwd_agent_new(Eldbus_Connection *conn, Iwd_Agent_Passphrase_Cb cb, void *data)
|
|||
return a;
|
||||
}
|
||||
|
||||
void
|
||||
iwd_agent_set_cancel_cb(Iwd_Agent *a, Iwd_Agent_Cancel_Cb cb, void *data)
|
||||
{
|
||||
if (!a) return;
|
||||
a->cancel_cb = cb;
|
||||
a->cancel_data = data;
|
||||
}
|
||||
|
||||
void
|
||||
iwd_agent_free(Iwd_Agent *a)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -13,8 +13,14 @@ typedef void (*Iwd_Agent_Passphrase_Cb)(void *data,
|
|||
Iwd_Agent_Request *req,
|
||||
const char *network_path);
|
||||
|
||||
/* Fired when iwd issues a Cancel(reason) for the in-flight passphrase
|
||||
* request — the UI should tear down any open auth dialog. */
|
||||
typedef void (*Iwd_Agent_Cancel_Cb)(void *data, const char *reason);
|
||||
|
||||
Iwd_Agent *iwd_agent_new (Eldbus_Connection *conn,
|
||||
Iwd_Agent_Passphrase_Cb cb, void *data);
|
||||
|
||||
void iwd_agent_set_cancel_cb(Iwd_Agent *a, Iwd_Agent_Cancel_Cb cb, void *data);
|
||||
void iwd_agent_free(Iwd_Agent *a);
|
||||
|
||||
void iwd_agent_reply (Iwd_Agent_Request *req, const char *passphrase);
|
||||
|
|
|
|||
|
|
@ -43,6 +43,13 @@ iwd_manager_set_passphrase_handler(Iwd_Manager *m, Iwd_Agent_Passphrase_Cb cb, v
|
|||
m->pass_data = data;
|
||||
}
|
||||
|
||||
void
|
||||
iwd_manager_set_cancel_handler(Iwd_Manager *m, Iwd_Agent_Cancel_Cb cb, void *data)
|
||||
{
|
||||
if (!m) return;
|
||||
iwd_agent_set_cancel_cb(m->agent, cb, data);
|
||||
}
|
||||
|
||||
static void _recompute_state(Iwd_Manager *m);
|
||||
|
||||
/* ----- listeners ------------------------------------------------------- */
|
||||
|
|
|
|||
|
|
@ -42,4 +42,9 @@ void iwd_manager_set_passphrase_handler(Iwd_Manager *m,
|
|||
Iwd_Agent_Passphrase_Cb cb,
|
||||
void *data);
|
||||
|
||||
/* Notified when iwd issues Agent.Cancel — UI should close any open prompt. */
|
||||
void iwd_manager_set_cancel_handler (Iwd_Manager *m,
|
||||
Iwd_Agent_Cancel_Cb cb,
|
||||
void *data);
|
||||
|
||||
#endif
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue