manager: surface D-Bus call errors to the user

Connect / Forget / Set(Powered) / Scan / Disconnect / RegisterAgent /
ConnectHidden previously discarded reply errors with NULL callbacks, so
"Connecting…" could hang forever after a refused call (rfkill, busy
adapter, another agent already registered, bad credentials on a known
network). The user had no way to see the failure.

Add iwd_manager_{report,last,clear}_error and wire reply callbacks in
adapter / device / network / agent. The popup status line now appends
the latest error to the state label, and user actions (rescan, toggle,
connect, disconnect) clear it.

Scan errors that mean "already in flight" are filtered out — they're
the normal race when two scan triggers fire close together.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
nemunaire 2026-04-29 11:29:59 +07:00
commit 0418e8bab9
7 changed files with 165 additions and 24 deletions

View file

@ -36,6 +36,15 @@ void iwd_manager_listener_del (Iwd_Manager *m, Iwd_Manager_Cb cb, void *data);
/* Internal: invoked by sub-objects when their state changes. */
void iwd_manager_notify (Iwd_Manager *m);
/* Latest user-facing error string, or NULL. Owned by the manager.
* Cleared on next successful state change or by iwd_manager_clear_error. */
const char *iwd_manager_last_error (const Iwd_Manager *m);
void iwd_manager_clear_error(Iwd_Manager *m);
/* Stash a one-shot error message and notify listeners. Used by D-Bus reply
* callbacks when iwd refuses a Connect/Forget/Set(Powered)/etc. */
void iwd_manager_report_error(Iwd_Manager *m, const char *fmt, ...);
/* The UI installs its passphrase prompt here. The handler must
* eventually call iwd_agent_reply()/iwd_agent_cancel() with the request. */
void iwd_manager_set_passphrase_handler(Iwd_Manager *m,