Phase 3: popup UI with network list and passphrase dialog
e_gadcon_popup hosts a status label, a scrollable list of networks (snapshotted from iwd_manager and sorted: connected → known → alpha), and Rescan/Enable/Disable action buttons. Clicking a network calls Network.Connect; iwd then asks our Agent for a passphrase, which is routed to a modal elm_popup via iwd_manager_set_passphrase_handler. The passphrase handler is installed at module init so iwd-initiated auth works even when the popup is closed. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
fcd4427de1
commit
e66a3effa6
6 changed files with 365 additions and 18 deletions
|
|
@ -1,12 +1,86 @@
|
|||
#include "wifi_auth.h"
|
||||
#include <stdlib.h>
|
||||
|
||||
/* TODO: modal dialog with password entry + "remember" checkbox.
|
||||
* Bound to the iwd Agent's RequestPassphrase reply. */
|
||||
typedef struct _Auth_Ctx
|
||||
{
|
||||
Evas_Object *popup;
|
||||
Evas_Object *entry;
|
||||
Wifi_Auth_Cb cb;
|
||||
void *data;
|
||||
Eina_Bool fired;
|
||||
} Auth_Ctx;
|
||||
|
||||
static void
|
||||
_finish(Auth_Ctx *c, Eina_Bool ok, const char *pass)
|
||||
{
|
||||
if (c->fired) return;
|
||||
c->fired = EINA_TRUE;
|
||||
if (c->cb) c->cb(c->data, pass, ok);
|
||||
evas_object_del(c->popup);
|
||||
free(c);
|
||||
}
|
||||
|
||||
static void
|
||||
_on_ok(void *data, Evas_Object *o EINA_UNUSED, void *ev EINA_UNUSED)
|
||||
{
|
||||
Auth_Ctx *c = data;
|
||||
_finish(c, EINA_TRUE, elm_entry_entry_get(c->entry));
|
||||
}
|
||||
|
||||
static void
|
||||
_on_cancel(void *data, Evas_Object *o EINA_UNUSED, void *ev EINA_UNUSED)
|
||||
{
|
||||
_finish(data, EINA_FALSE, NULL);
|
||||
}
|
||||
|
||||
static void
|
||||
_on_del(void *data, Evas *e EINA_UNUSED, Evas_Object *o EINA_UNUSED, void *ev EINA_UNUSED)
|
||||
{
|
||||
/* Window closed without cancel/ok — treat as cancel. */
|
||||
_finish(data, EINA_FALSE, NULL);
|
||||
}
|
||||
|
||||
void
|
||||
wifi_auth_prompt(Evas_Object *parent EINA_UNUSED,
|
||||
const char *ssid EINA_UNUSED,
|
||||
Wifi_Auth_Cb cb EINA_UNUSED,
|
||||
void *data EINA_UNUSED)
|
||||
wifi_auth_prompt(Evas_Object *parent, const char *ssid,
|
||||
Wifi_Auth_Cb cb, void *data)
|
||||
{
|
||||
Auth_Ctx *c = calloc(1, sizeof(*c));
|
||||
c->cb = cb; c->data = data;
|
||||
|
||||
Evas_Object *p = elm_popup_add(parent);
|
||||
c->popup = p;
|
||||
char title[256];
|
||||
snprintf(title, sizeof(title), "Connect to %s", ssid ? ssid : "network");
|
||||
elm_object_part_text_set(p, "title,text", title);
|
||||
|
||||
Evas_Object *box = elm_box_add(p);
|
||||
elm_box_padding_set(box, 0, 6);
|
||||
|
||||
Evas_Object *entry = elm_entry_add(box);
|
||||
elm_entry_single_line_set(entry, EINA_TRUE);
|
||||
elm_entry_password_set(entry, EINA_TRUE);
|
||||
elm_entry_scrollable_set(entry, EINA_TRUE);
|
||||
evas_object_size_hint_weight_set(entry, EVAS_HINT_EXPAND, 0);
|
||||
evas_object_size_hint_align_set(entry, EVAS_HINT_FILL, 0);
|
||||
elm_box_pack_end(box, entry);
|
||||
evas_object_show(entry);
|
||||
c->entry = entry;
|
||||
|
||||
evas_object_show(box);
|
||||
elm_object_content_set(p, box);
|
||||
|
||||
Evas_Object *bcancel = elm_button_add(p);
|
||||
elm_object_text_set(bcancel, "Cancel");
|
||||
elm_object_part_content_set(p, "button1", bcancel);
|
||||
evas_object_smart_callback_add(bcancel, "clicked", _on_cancel, c);
|
||||
|
||||
Evas_Object *bok = elm_button_add(p);
|
||||
elm_object_text_set(bok, "Connect");
|
||||
elm_object_part_content_set(p, "button2", bok);
|
||||
evas_object_smart_callback_add(bok, "clicked", _on_ok, c);
|
||||
|
||||
evas_object_event_callback_add(p, EVAS_CALLBACK_DEL, _on_del, c);
|
||||
|
||||
evas_object_show(p);
|
||||
elm_object_focus_set(entry, EINA_TRUE);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue