|
@@ -19,7 +19,9 @@
|
|
|
|
|
|
|
|
#define MAX_DEVS 8
|
|
#define MAX_DEVS 8
|
|
|
#define MAX_BSS 32
|
|
#define MAX_BSS 32
|
|
|
-#define ROW_H 24
|
|
|
|
|
|
|
+#define DEV_ROW_H 32
|
|
|
|
|
+#define WIFI_ROW_H 38
|
|
|
|
|
+#define SAVED_ROW_H 34
|
|
|
#define LOG_MAX 2048
|
|
#define LOG_MAX 2048
|
|
|
|
|
|
|
|
#define ID_REFRESH 1
|
|
#define ID_REFRESH 1
|
|
@@ -34,6 +36,8 @@
|
|
|
#define ID_DEV_BASE 100
|
|
#define ID_DEV_BASE 100
|
|
|
#define ID_BSS_BASE 200
|
|
#define ID_BSS_BASE 200
|
|
|
#define ID_SAVED_BASE 300
|
|
#define ID_SAVED_BASE 300
|
|
|
|
|
+#define ID_INFO_BASE 400
|
|
|
|
|
+#define ID_SAVED_ROW_BASE 500
|
|
|
|
|
|
|
|
#define ACT_REFRESH (1u << 0)
|
|
#define ACT_REFRESH (1u << 0)
|
|
|
#define ACT_SCAN (1u << 1)
|
|
#define ACT_SCAN (1u << 1)
|
|
@@ -46,8 +50,9 @@
|
|
|
enum { VIEW_MAIN, VIEW_PASS, VIEW_CONNECT, VIEW_SAVED };
|
|
enum { VIEW_MAIN, VIEW_PASS, VIEW_CONNECT, VIEW_SAVED };
|
|
|
|
|
|
|
|
static struct ngui ui;
|
|
static struct ngui ui;
|
|
|
|
|
+static struct ngui_popover pop;
|
|
|
static struct ngui_input pass_in;
|
|
static struct ngui_input pass_in;
|
|
|
-static struct ngui_scroll wifi_scroll;
|
|
|
|
|
|
|
+static struct ngui_scroll main_scroll;
|
|
|
static struct ngui_scroll saved_scroll;
|
|
static struct ngui_scroll saved_scroll;
|
|
|
|
|
|
|
|
static struct sys_netdev devs[MAX_DEVS];
|
|
static struct sys_netdev devs[MAX_DEVS];
|
|
@@ -146,6 +151,25 @@ static char *put_ip(char *p, const unsigned char ip[4])
|
|
|
return p;
|
|
return p;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+static char *put_mac(char *p, const unsigned char mac[6])
|
|
|
|
|
+{
|
|
|
|
|
+ static const char hex[] = "0123456789abcdef";
|
|
|
|
|
+ int i;
|
|
|
|
|
+
|
|
|
|
|
+ for (i = 0; i < 6; i++) {
|
|
|
|
|
+ *p++ = hex[mac[i] >> 4];
|
|
|
|
|
+ *p++ = hex[mac[i] & 15];
|
|
|
|
|
+ if (i != 5)
|
|
|
|
|
+ *p++ = ':';
|
|
|
|
|
+ }
|
|
|
|
|
+ return p;
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+static int ip_any(const unsigned char ip[4])
|
|
|
|
|
+{
|
|
|
|
|
+ return ip[0] || ip[1] || ip[2] || ip[3];
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
static void ssid_name(const struct sys_wifi_bss *b, char out[33])
|
|
static void ssid_name(const struct sys_wifi_bss *b, char out[33])
|
|
|
{
|
|
{
|
|
|
unsigned int i, n = b->ssid_len;
|
|
unsigned int i, n = b->ssid_len;
|
|
@@ -370,7 +394,7 @@ static void start_scan(void)
|
|
|
scanning = 1;
|
|
scanning = 1;
|
|
|
scan_start = u_ticks_ms();
|
|
scan_start = u_ticks_ms();
|
|
|
nbss = 0;
|
|
nbss = 0;
|
|
|
- wifi_scroll.offset = 0;
|
|
|
|
|
|
|
+ main_scroll.offset = 0;
|
|
|
ngui_invalidate(&ui);
|
|
ngui_invalidate(&ui);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -686,305 +710,387 @@ static void handle_actions(void)
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-static void draw_bars(int x, int y, int bars, unsigned short color)
|
|
|
|
|
-{
|
|
|
|
|
- int i;
|
|
|
|
|
-
|
|
|
|
|
- for (i = 0; i < 4; i++) {
|
|
|
|
|
- int h = 3 + i * 3;
|
|
|
|
|
- struct ngui_rect r;
|
|
|
|
|
-
|
|
|
|
|
- r.x = x + i * 5;
|
|
|
|
|
- r.y = y + 12 - h;
|
|
|
|
|
- r.w = 3;
|
|
|
|
|
- r.h = h;
|
|
|
|
|
- ngui_fill_rect(&ui, r, i < bars ? color : ui.theme.border);
|
|
|
|
|
- }
|
|
|
|
|
-}
|
|
|
|
|
-
|
|
|
|
|
static void draw_status(void)
|
|
static void draw_status(void)
|
|
|
{
|
|
{
|
|
|
if (status[0] && status_until &&
|
|
if (status[0] && status_until &&
|
|
|
(int)(u_ticks_ms() - status_until) < 0)
|
|
(int)(u_ticks_ms() - status_until) < 0)
|
|
|
- ngui_text_utf8(&ui, 10, ui.h - 22, status,
|
|
|
|
|
- status_error ? ui.theme.error : ui.theme.accent);
|
|
|
|
|
|
|
+ ngui_popover_footer(&ui, &pop, status,
|
|
|
|
|
+ status_error ? ui.theme.error : ui.theme.success);
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+/* The active connection at the top of the panel: a status dot, the link
|
|
|
|
|
+ * state and the device address (plus the SSID and RSSI on Wi-Fi). */
|
|
|
|
|
+static void draw_status_card(struct ngui_rect r)
|
|
|
|
|
+{
|
|
|
|
|
+ struct ngui_rect line_r = { r.x + 34, r.y + 34, r.w - 44, 16 };
|
|
|
|
|
+ struct ngui_rect dot = { r.x + 14, r.y + 25, 10, 10 };
|
|
|
|
|
+ char line[160], *p;
|
|
|
|
|
+ unsigned short dot_color;
|
|
|
|
|
+ int i, have_ip = 0;
|
|
|
|
|
+
|
|
|
|
|
+ for (i = 0; i < 4; i++)
|
|
|
|
|
+ if (net.ip[i])
|
|
|
|
|
+ have_ip = 1;
|
|
|
|
|
+ if (!net_present)
|
|
|
|
|
+ dot_color = ui.theme.error;
|
|
|
|
|
+ else if (!have_ip ||
|
|
|
|
|
+ (seq(net.name, "wifi") && wst.state < SYS_WIFI_ST_LINK))
|
|
|
|
|
+ dot_color = ui.theme.warning;
|
|
|
|
|
+ else
|
|
|
|
|
+ dot_color = ui.theme.success;
|
|
|
|
|
+
|
|
|
|
|
+ ngui_fill_round_rect(&ui, r, 8, 8, 8, 8, ui.theme.panel);
|
|
|
|
|
+ ngui_frame_round(&ui, r, 8, 8, 8, 8, 1, ui.theme.panel_alt);
|
|
|
|
|
+ ngui_fill_round_rect(&ui, dot, 5, 5, 5, 5, dot_color);
|
|
|
|
|
+
|
|
|
|
|
+ p = line;
|
|
|
|
|
+ if (!net_present)
|
|
|
|
|
+ p = sput(p, "Offline");
|
|
|
|
|
+ else if (seq(net.name, "wifi"))
|
|
|
|
|
+ p = sput(p, wst.state >= SYS_WIFI_ST_LINK ?
|
|
|
|
|
+ "Wi-Fi connected" : "Wi-Fi");
|
|
|
|
|
+ else if (seq(net.name, "rndis"))
|
|
|
|
|
+ p = sput(p, "USB tethering");
|
|
|
|
|
+ else
|
|
|
|
|
+ p = sput(p, "Wired network");
|
|
|
|
|
+ *p = '\0';
|
|
|
|
|
+ ngui_text_px(&ui, r.x + 34, r.y + 10, line, slen(line),
|
|
|
|
|
+ ui.theme.text, 16, 1, 0, 0);
|
|
|
|
|
+
|
|
|
|
|
+ p = line;
|
|
|
|
|
+ if (net_present) {
|
|
|
|
|
+ p = sput(p, net.name);
|
|
|
|
|
+ p = sput(p, " \xC2\xB7 ");
|
|
|
|
|
+ if (have_ip)
|
|
|
|
|
+ p = put_ip(p, net.ip);
|
|
|
|
|
+ else
|
|
|
|
|
+ p = sput(p, "no IP");
|
|
|
|
|
+ if (seq(net.name, "wifi") && wst.state >= SYS_WIFI_ST_ASSOC) {
|
|
|
|
|
+ p = sput(p, " \xC2\xB7 ");
|
|
|
|
|
+ for (i = 0; i < wst.ssid_len && i < 32; i++)
|
|
|
|
|
+ *p++ = (char)wst.ssid[i];
|
|
|
|
|
+ p = sput(p, " ");
|
|
|
|
|
+ p = put_signed(p, wst.rssi);
|
|
|
|
|
+ p = sput(p, " dBm");
|
|
|
|
|
+ }
|
|
|
|
|
+ } else {
|
|
|
|
|
+ p = sput(p, "No network device active");
|
|
|
|
|
+ }
|
|
|
|
|
+ *p = '\0';
|
|
|
|
|
+ ngui_text_ellipsis_utf8(&ui, line_r, line_r.x, line_r.y, line,
|
|
|
|
|
+ ui.theme.text_dim);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-static void draw_wifi_list(struct ngui_rect area)
|
|
|
|
|
|
|
+static void draw_wifi_list(struct ngui_rect area, int *y)
|
|
|
{
|
|
{
|
|
|
- char label[40], shortcut[20];
|
|
|
|
|
|
|
+ struct ngui_row row;
|
|
|
|
|
+ char ssid[33], sub[72], *p;
|
|
|
int i;
|
|
int i;
|
|
|
|
|
|
|
|
if (!wifi_present) {
|
|
if (!wifi_present) {
|
|
|
- ngui_text(&ui, area.x + 2, area.y + 4,
|
|
|
|
|
- "No WiFi card detected", ui.theme.text_dim);
|
|
|
|
|
|
|
+ ngui_text_px(&ui, area.x + 12, *y + 10,
|
|
|
|
|
+ "No Wi-Fi card detected", 22,
|
|
|
|
|
+ ui.theme.text_dim, 11, 0, 0, 0);
|
|
|
|
|
+ *y += WIFI_ROW_H;
|
|
|
return;
|
|
return;
|
|
|
}
|
|
}
|
|
|
if (scanning) {
|
|
if (scanning) {
|
|
|
- ngui_text(&ui, area.x + 2, area.y + 4,
|
|
|
|
|
- "Scanning...", ui.theme.text_dim);
|
|
|
|
|
|
|
+ ngui_text_px(&ui, area.x + 12, *y + 10,
|
|
|
|
|
+ "Scanning for networks...", 24,
|
|
|
|
|
+ ui.theme.accent, 11, 0, 0, 0);
|
|
|
|
|
+ *y += WIFI_ROW_H;
|
|
|
return;
|
|
return;
|
|
|
}
|
|
}
|
|
|
if (nbss == 0) {
|
|
if (nbss == 0) {
|
|
|
- ngui_text(&ui, area.x + 2, area.y + 4,
|
|
|
|
|
- wst.state >= SYS_WIFI_ST_ASSOC ?
|
|
|
|
|
- "Connected - Disconnect to scan for other networks" :
|
|
|
|
|
- "Press Scan to list WiFi networks",
|
|
|
|
|
- ui.theme.text_dim);
|
|
|
|
|
|
|
+ const char *msg = wst.state >= SYS_WIFI_ST_ASSOC ?
|
|
|
|
|
+ "Connected - disconnect to scan for other networks" :
|
|
|
|
|
+ "Press Scan to list Wi-Fi networks";
|
|
|
|
|
+
|
|
|
|
|
+ ngui_text_px(&ui, area.x + 12, *y + 10, msg, slen(msg),
|
|
|
|
|
+ ui.theme.text_dim, 11, 0, 0, 0);
|
|
|
|
|
+ *y += WIFI_ROW_H;
|
|
|
return;
|
|
return;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- wifi_scroll.content_h = nbss * ROW_H;
|
|
|
|
|
- ngui_scroll_begin(&ui, area, &wifi_scroll);
|
|
|
|
|
- ngui_scroll_wheel(&ui, area, &wifi_scroll);
|
|
|
|
|
- ngui_scroll_keys(&ui, &wifi_scroll);
|
|
|
|
|
for (i = 0; i < nbss; i++) {
|
|
for (i = 0; i < nbss; i++) {
|
|
|
- struct ngui_rect rr;
|
|
|
|
|
struct sys_wifi_bss *b = &bss[i];
|
|
struct sys_wifi_bss *b = &bss[i];
|
|
|
- char ssid[33];
|
|
|
|
|
- int sw, bx, clicked;
|
|
|
|
|
- unsigned short signal;
|
|
|
|
|
-
|
|
|
|
|
- rr.x = area.x;
|
|
|
|
|
- rr.y = area.y - wifi_scroll.offset + i * ROW_H;
|
|
|
|
|
- rr.w = area.w - 16;
|
|
|
|
|
- rr.h = ROW_H - 2;
|
|
|
|
|
- if (rr.y + rr.h <= area.y || rr.y >= area.y + area.h)
|
|
|
|
|
- continue;
|
|
|
|
|
|
|
+ struct ngui_rect r = { area.x, *y, area.w - 18, WIFI_ROW_H };
|
|
|
|
|
+
|
|
|
|
|
+ if (r.y + r.h > area.y && r.y < area.y + area.h) {
|
|
|
|
|
+ ssid_name(b, ssid);
|
|
|
|
|
+ p = sub;
|
|
|
|
|
+ p = sput(p, security_name(b->security));
|
|
|
|
|
+ if (bss_saved(b) >= 0)
|
|
|
|
|
+ p = sput(p, " \xC2\xB7 saved");
|
|
|
|
|
+ if (bss_is_active(b))
|
|
|
|
|
+ p = sput(p, " \xC2\xB7 connected");
|
|
|
|
|
+ *p = '\0';
|
|
|
|
|
|
|
|
- ssid_name(b, ssid);
|
|
|
|
|
- sput(label, ssid);
|
|
|
|
|
- sput(shortcut, security_name(b->security));
|
|
|
|
|
- if (bss_saved(b) >= 0)
|
|
|
|
|
- sput(shortcut + slen(shortcut), " saved");
|
|
|
|
|
- clicked = ngui_menu_item_utf8(&ui, ID_BSS_BASE + i, rr, label,
|
|
|
|
|
- shortcut, bss_is_active(b));
|
|
|
|
|
-
|
|
|
|
|
- sw = (int)ngui_text_width_ui(&ui, shortcut);
|
|
|
|
|
- bx = rr.x + rr.w - 8 - sw - 30;
|
|
|
|
|
- if (b->security == SYS_WIFI_SEC_OTHER)
|
|
|
|
|
- signal = ui.theme.error;
|
|
|
|
|
- else
|
|
|
|
|
- signal = rssi_bars(b->rssi) >= 3 ? ui.theme.accent :
|
|
|
|
|
- ui.theme.text_dim;
|
|
|
|
|
- draw_bars(bx, rr.y + 3, rssi_bars(b->rssi), signal);
|
|
|
|
|
- if (clicked) {
|
|
|
|
|
- action_bss = i;
|
|
|
|
|
|
|
+ row.title = ssid;
|
|
|
|
|
+ row.subtitle = sub;
|
|
|
|
|
+ row.trailing = 0;
|
|
|
|
|
+ row.bars = b->security == SYS_WIFI_SEC_OTHER ? -1 :
|
|
|
|
|
+ rssi_bars(b->rssi);
|
|
|
|
|
+ row.selected = bss_is_active(b);
|
|
|
|
|
+ if (ngui_list_row_utf8(&ui, ID_BSS_BASE + i, r,
|
|
|
|
|
+ &row))
|
|
|
|
|
+ action_bss = i;
|
|
|
}
|
|
}
|
|
|
|
|
+ *y += WIFI_ROW_H;
|
|
|
}
|
|
}
|
|
|
- ngui_scroll_end(&ui, area, &wifi_scroll);
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
static void draw_main(void)
|
|
static void draw_main(void)
|
|
|
{
|
|
{
|
|
|
- struct ngui_rect body = { 10, 8, ui.w - 20, ui.h - 34 };
|
|
|
|
|
- struct ngui_rect r, rb;
|
|
|
|
|
- char line[128], *p;
|
|
|
|
|
- int i, shown;
|
|
|
|
|
|
|
+ struct ngui_rect body = pop.body;
|
|
|
|
|
+ struct ngui_rect card, area, r;
|
|
|
|
|
+ struct ngui_row row;
|
|
|
|
|
+ char line[48], *p;
|
|
|
|
|
+ int i, y, content_h, shown, more;
|
|
|
|
|
|
|
|
- /* Active connection summary. */
|
|
|
|
|
- r = ngui_cut_top(&body, 20);
|
|
|
|
|
- p = line;
|
|
|
|
|
- if (!net_present) {
|
|
|
|
|
- p = sput(p, "No active network device");
|
|
|
|
|
- } else {
|
|
|
|
|
- p = sput(p, "Active: ");
|
|
|
|
|
- p = sput(p, net.name);
|
|
|
|
|
- p = sput(p, " (");
|
|
|
|
|
- p = sput(p, net.chip);
|
|
|
|
|
- p = sput(p, ")");
|
|
|
|
|
- if (seq(net.name, "wifi") && wst.state >= SYS_WIFI_ST_ASSOC) {
|
|
|
|
|
- p = sput(p, " ");
|
|
|
|
|
- for (i = 0; i < wst.ssid_len && i < 32; i++)
|
|
|
|
|
- *p++ = (char)wst.ssid[i];
|
|
|
|
|
- p = sput(p, " ");
|
|
|
|
|
- p = put_signed(p, wst.rssi);
|
|
|
|
|
- p = sput(p, " dBm");
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
- *p = '\0';
|
|
|
|
|
- ngui_text_ellipsis_utf8(&ui, r, r.x, r.y, line, ui.theme.text);
|
|
|
|
|
|
|
+ card = ngui_cut_top(&body, 64);
|
|
|
|
|
+ draw_status_card(card);
|
|
|
|
|
+ body.y += 8;
|
|
|
|
|
+ body.h -= 8;
|
|
|
|
|
|
|
|
- r = ngui_cut_top(&body, 20);
|
|
|
|
|
- p = line;
|
|
|
|
|
- if (net_present) {
|
|
|
|
|
- p = sput(p, "IP ");
|
|
|
|
|
- if (net.ip[0] || net.ip[1] || net.ip[2] || net.ip[3])
|
|
|
|
|
- p = put_ip(p, net.ip);
|
|
|
|
|
- else
|
|
|
|
|
- p = sput(p, "not configured");
|
|
|
|
|
- if (seq(net.name, "wifi"))
|
|
|
|
|
- p = sput(p, wst.state >= SYS_WIFI_ST_LINK ?
|
|
|
|
|
- " link up" : " link down");
|
|
|
|
|
- } else if (wifi_present) {
|
|
|
|
|
- p = sput(p, "WiFi card present - scan to join a network");
|
|
|
|
|
- } else {
|
|
|
|
|
- p = sput(p, "Plug in Ethernet or USB tethering, then Refresh");
|
|
|
|
|
- }
|
|
|
|
|
- *p = '\0';
|
|
|
|
|
- ngui_text_ellipsis_utf8(&ui, r, r.x, r.y, line, ui.theme.text_dim);
|
|
|
|
|
- body.y += 4;
|
|
|
|
|
- body.h -= 4;
|
|
|
|
|
-
|
|
|
|
|
- /* Devices. */
|
|
|
|
|
- r = ngui_cut_top(&body, 26);
|
|
|
|
|
- ngui_text(&ui, r.x, r.y + 3, "Network devices", ui.theme.text_dim);
|
|
|
|
|
- rb = r;
|
|
|
|
|
- rb.x = r.x + r.w - 78;
|
|
|
|
|
- rb.w = 78;
|
|
|
|
|
- rb.h = 22;
|
|
|
|
|
- if (ngui_button(&ui, ID_REFRESH, rb, "Refresh"))
|
|
|
|
|
|
|
+ shown = 0;
|
|
|
|
|
+ for (i = 0; i < ndev; i++)
|
|
|
|
|
+ if (devs[i].kind != SYS_NETDEV_WIFI)
|
|
|
|
|
+ shown++;
|
|
|
|
|
+ more = shown > 4 ? shown - 4 : 0;
|
|
|
|
|
+ if (shown > 4)
|
|
|
|
|
+ shown = 4;
|
|
|
|
|
+
|
|
|
|
|
+ content_h = 26 + (shown ? shown * DEV_ROW_H : DEV_ROW_H) +
|
|
|
|
|
+ (more ? 18 : 0) + 10 + 26;
|
|
|
|
|
+ if (!wifi_present || scanning || nbss == 0)
|
|
|
|
|
+ content_h += WIFI_ROW_H;
|
|
|
|
|
+ else
|
|
|
|
|
+ content_h += nbss * WIFI_ROW_H;
|
|
|
|
|
+ if (net_present)
|
|
|
|
|
+ content_h += 10 + 26 + 4 * 26;
|
|
|
|
|
+ if (nsaved)
|
|
|
|
|
+ content_h += SAVED_ROW_H + 8;
|
|
|
|
|
+
|
|
|
|
|
+ main_scroll.content_h = content_h;
|
|
|
|
|
+ area = body;
|
|
|
|
|
+ ngui_scroll_begin(&ui, area, &main_scroll);
|
|
|
|
|
+ ngui_scroll_wheel(&ui, area, &main_scroll);
|
|
|
|
|
+ ngui_scroll_keys(&ui, &main_scroll);
|
|
|
|
|
+
|
|
|
|
|
+ y = area.y - main_scroll.offset;
|
|
|
|
|
+ r = (struct ngui_rect){ area.x, y, area.w - 18, 26 };
|
|
|
|
|
+ if (ngui_section(&ui, r, "Devices", ID_REFRESH, "Refresh"))
|
|
|
actions |= ACT_REFRESH;
|
|
actions |= ACT_REFRESH;
|
|
|
|
|
+ y += 26;
|
|
|
|
|
|
|
|
- shown = 0;
|
|
|
|
|
- for (i = 0; i < ndev && shown < 6; i++) {
|
|
|
|
|
- if (devs[i].kind == SYS_NETDEV_WIFI)
|
|
|
|
|
- continue;
|
|
|
|
|
|
|
+ {
|
|
|
|
|
+ int n = 0;
|
|
|
|
|
+
|
|
|
|
|
+ for (i = 0; i < ndev && n < shown; i++) {
|
|
|
|
|
+ if (devs[i].kind == SYS_NETDEV_WIFI)
|
|
|
|
|
+ continue;
|
|
|
|
|
+ r = (struct ngui_rect){ area.x, y, area.w - 18,
|
|
|
|
|
+ DEV_ROW_H };
|
|
|
|
|
+ if (r.y + r.h > area.y && r.y < area.y + area.h) {
|
|
|
|
|
+ row.title = devs[i].name;
|
|
|
|
|
+ row.subtitle = devs[i].chip;
|
|
|
|
|
+ row.trailing = devs[i].active ? "Connected" :
|
|
|
|
|
+ (devs[i].link ? "link" : 0);
|
|
|
|
|
+ row.bars = -1;
|
|
|
|
|
+ row.selected = devs[i].active;
|
|
|
|
|
+ if (ngui_list_row(&ui, ID_DEV_BASE + i, r,
|
|
|
|
|
+ &row))
|
|
|
|
|
+ action_dev = i;
|
|
|
|
|
+ }
|
|
|
|
|
+ y += DEV_ROW_H;
|
|
|
|
|
+ n++;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ if (!shown) {
|
|
|
|
|
+ const char *msg = wifi_present ?
|
|
|
|
|
+ "No wired or USB device" :
|
|
|
|
|
+ "No device found - plug one in and Refresh";
|
|
|
|
|
+
|
|
|
|
|
+ ngui_text_px(&ui, area.x + 12, y + 8, msg, slen(msg),
|
|
|
|
|
+ ui.theme.text_dim, 11, 0, 0, 0);
|
|
|
|
|
+ y += DEV_ROW_H;
|
|
|
|
|
+ } else if (more) {
|
|
|
p = line;
|
|
p = line;
|
|
|
- p = sput(p, devs[i].name);
|
|
|
|
|
- p = sput(p, " ");
|
|
|
|
|
- p = sput(p, devs[i].chip);
|
|
|
|
|
|
|
+ p = sput(p, "+");
|
|
|
|
|
+ p = put_dec(p, (unsigned int)more);
|
|
|
|
|
+ p = sput(p, " more devices");
|
|
|
*p = '\0';
|
|
*p = '\0';
|
|
|
- r = ngui_cut_top(&body, ROW_H);
|
|
|
|
|
- if (ngui_menu_item(&ui, ID_DEV_BASE + i, r, line,
|
|
|
|
|
- devs[i].active ? "active" :
|
|
|
|
|
- (devs[i].link ? "link" : ""),
|
|
|
|
|
- devs[i].active))
|
|
|
|
|
- action_dev = i;
|
|
|
|
|
- shown++;
|
|
|
|
|
|
|
+ ngui_text_px(&ui, area.x + 12, y + 2, line, slen(line),
|
|
|
|
|
+ ui.theme.text_dim, 11, 0, 0, 0);
|
|
|
|
|
+ y += 18;
|
|
|
}
|
|
}
|
|
|
- if (!shown) {
|
|
|
|
|
- r = ngui_cut_top(&body, ROW_H);
|
|
|
|
|
- ngui_text(&ui, r.x + 2, r.y + 3,
|
|
|
|
|
- wifi_present ?
|
|
|
|
|
- "No wired or USB device - use the WiFi list" :
|
|
|
|
|
- "None found - Refresh after plugging a device in",
|
|
|
|
|
- ui.theme.text_dim);
|
|
|
|
|
|
|
+
|
|
|
|
|
+ y += 10;
|
|
|
|
|
+ r = (struct ngui_rect){ area.x, y, area.w - 18, 26 };
|
|
|
|
|
+ if (wifi_present && wst.state >= SYS_WIFI_ST_ASSOC) {
|
|
|
|
|
+ if (ngui_section(&ui, r, "Wi-Fi", ID_DISCONNECT,
|
|
|
|
|
+ "Disconnect"))
|
|
|
|
|
+ actions |= ACT_DISCONNECT;
|
|
|
|
|
+ } else if (wifi_present && !scanning) {
|
|
|
|
|
+ if (ngui_section(&ui, r, "Wi-Fi", ID_SCAN, "Scan"))
|
|
|
|
|
+ actions |= ACT_SCAN;
|
|
|
|
|
+ } else {
|
|
|
|
|
+ ngui_section(&ui, r, "Wi-Fi", 0, 0);
|
|
|
}
|
|
}
|
|
|
- body.y += 6;
|
|
|
|
|
- body.h -= 6;
|
|
|
|
|
-
|
|
|
|
|
- /* WiFi networks. */
|
|
|
|
|
- r = ngui_cut_top(&body, 26);
|
|
|
|
|
- ngui_text(&ui, r.x, r.y + 3, "WiFi networks", ui.theme.text_dim);
|
|
|
|
|
- rb = r;
|
|
|
|
|
- rb.x = r.x + r.w - 96;
|
|
|
|
|
- rb.w = 96;
|
|
|
|
|
- rb.h = 22;
|
|
|
|
|
- if (nsaved > 0) {
|
|
|
|
|
- struct ngui_rect sb = rb;
|
|
|
|
|
-
|
|
|
|
|
- sb.x = rb.x - 68;
|
|
|
|
|
- sb.w = 64;
|
|
|
|
|
- if (ngui_button(&ui, ID_SAVED, sb, "Saved"))
|
|
|
|
|
- actions |= ACT_SAVED;
|
|
|
|
|
|
|
+ y += 26;
|
|
|
|
|
+
|
|
|
|
|
+ draw_wifi_list(area, &y);
|
|
|
|
|
+
|
|
|
|
|
+ if (net_present) {
|
|
|
|
|
+ static const char *labels[4] = {
|
|
|
|
|
+ "IP address", "Gateway", "DNS", "MAC address"
|
|
|
|
|
+ };
|
|
|
|
|
+ char value[40];
|
|
|
|
|
+ int di;
|
|
|
|
|
+
|
|
|
|
|
+ y += 10;
|
|
|
|
|
+ r = (struct ngui_rect){ area.x, y, area.w - 18, 26 };
|
|
|
|
|
+ ngui_section(&ui, r, "Connection", 0, 0);
|
|
|
|
|
+ y += 26;
|
|
|
|
|
+ for (di = 0; di < 4; di++) {
|
|
|
|
|
+ char *vp = value;
|
|
|
|
|
+
|
|
|
|
|
+ if (di == 0)
|
|
|
|
|
+ vp = ip_any(net.ip) ? put_ip(vp, net.ip) :
|
|
|
|
|
+ sput(vp, "not configured");
|
|
|
|
|
+ else if (di == 1)
|
|
|
|
|
+ vp = ip_any(net.gw) ? put_ip(vp, net.gw) :
|
|
|
|
|
+ sput(vp, "-");
|
|
|
|
|
+ else if (di == 2)
|
|
|
|
|
+ vp = ip_any(net.dns) ? put_ip(vp, net.dns) :
|
|
|
|
|
+ sput(vp, "-");
|
|
|
|
|
+ else
|
|
|
|
|
+ vp = put_mac(vp, net.mac);
|
|
|
|
|
+ *vp = '\0';
|
|
|
|
|
+
|
|
|
|
|
+ r = (struct ngui_rect){ area.x, y, area.w - 18, 26 };
|
|
|
|
|
+ if (r.y + r.h > area.y && r.y < area.y + area.h) {
|
|
|
|
|
+ row.title = labels[di];
|
|
|
|
|
+ row.subtitle = 0;
|
|
|
|
|
+ row.trailing = value;
|
|
|
|
|
+ row.bars = -1;
|
|
|
|
|
+ row.selected = 0;
|
|
|
|
|
+ ngui_list_row(&ui, ID_INFO_BASE + di, r, &row);
|
|
|
|
|
+ }
|
|
|
|
|
+ y += 26;
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
- if (wifi_present) {
|
|
|
|
|
- if (wst.state >= SYS_WIFI_ST_ASSOC) {
|
|
|
|
|
- if (ngui_button(&ui, ID_DISCONNECT, rb, "Disconnect"))
|
|
|
|
|
- actions |= ACT_DISCONNECT;
|
|
|
|
|
- } else if (scanning) {
|
|
|
|
|
- ngui_text(&ui, rb.x + 10, rb.y + 3, "Scanning...",
|
|
|
|
|
- ui.theme.text_dim);
|
|
|
|
|
- } else {
|
|
|
|
|
- if (ngui_button(&ui, ID_SCAN, rb, "Scan"))
|
|
|
|
|
- actions |= ACT_SCAN;
|
|
|
|
|
|
|
+
|
|
|
|
|
+ if (nsaved) {
|
|
|
|
|
+ char nbuf[12], *np = nbuf;
|
|
|
|
|
+
|
|
|
|
|
+ y += 8;
|
|
|
|
|
+ r = (struct ngui_rect){ area.x, y, area.w - 18, SAVED_ROW_H };
|
|
|
|
|
+ if (r.y + r.h > area.y && r.y < area.y + area.h) {
|
|
|
|
|
+ np = put_dec(np, (unsigned int)nsaved);
|
|
|
|
|
+ *np = '\0';
|
|
|
|
|
+ row.title = "Saved networks";
|
|
|
|
|
+ row.subtitle = "Join again without the passphrase";
|
|
|
|
|
+ row.trailing = nbuf;
|
|
|
|
|
+ row.bars = -1;
|
|
|
|
|
+ row.selected = 0;
|
|
|
|
|
+ if (ngui_list_row(&ui, ID_SAVED, r, &row))
|
|
|
|
|
+ actions |= ACT_SAVED;
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
- draw_wifi_list(body);
|
|
|
|
|
|
|
+ ngui_scroll_end(&ui, area, &main_scroll);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
static void draw_pass(void)
|
|
static void draw_pass(void)
|
|
|
{
|
|
{
|
|
|
- struct ngui_rect body = { 10, 10, ui.w - 20, ui.h - 40 };
|
|
|
|
|
|
|
+ struct ngui_rect body = pop.body;
|
|
|
struct ngui_rect r, b1, b2;
|
|
struct ngui_rect r, b1, b2;
|
|
|
char line[80], *p;
|
|
char line[80], *p;
|
|
|
int ev;
|
|
int ev;
|
|
|
|
|
|
|
|
r = ngui_cut_top(&body, 24);
|
|
r = ngui_cut_top(&body, 24);
|
|
|
- p = sput(line, "Join WiFi network \"");
|
|
|
|
|
|
|
+ p = sput(line, "Join \"");
|
|
|
p = sput(p, sel_ssid);
|
|
p = sput(p, sel_ssid);
|
|
|
p = sput(p, "\"");
|
|
p = sput(p, "\"");
|
|
|
*p = '\0';
|
|
*p = '\0';
|
|
|
ngui_text_ellipsis_utf8(&ui, r, r.x, r.y, line, ui.theme.text);
|
|
ngui_text_ellipsis_utf8(&ui, r, r.x, r.y, line, ui.theme.text);
|
|
|
|
|
|
|
|
r = ngui_cut_top(&body, 22);
|
|
r = ngui_cut_top(&body, 22);
|
|
|
- ngui_text(&ui, r.x, r.y, "WPA2-PSK passphrase", ui.theme.text_dim);
|
|
|
|
|
|
|
+ ngui_text_px(&ui, r.x, r.y, "WPA2-PSK passphrase", 19,
|
|
|
|
|
+ ui.theme.text_dim, 11, 1, 0, 0);
|
|
|
|
|
|
|
|
- r = ngui_cut_top(&body, 30);
|
|
|
|
|
|
|
+ r = ngui_cut_top(&body, 34);
|
|
|
ev = ngui_text_input(&ui, ID_PASS, r, &pass_in);
|
|
ev = ngui_text_input(&ui, ID_PASS, r, &pass_in);
|
|
|
if (ev & NGUI_INPUT_SUBMIT)
|
|
if (ev & NGUI_INPUT_SUBMIT)
|
|
|
actions |= ACT_CONNECT;
|
|
actions |= ACT_CONNECT;
|
|
|
if (ev & NGUI_INPUT_CANCEL)
|
|
if (ev & NGUI_INPUT_CANCEL)
|
|
|
actions |= ACT_BACK;
|
|
actions |= ACT_BACK;
|
|
|
- body.y += 6;
|
|
|
|
|
- body.h -= 6;
|
|
|
|
|
|
|
+ body.y += 8;
|
|
|
|
|
+ body.h -= 8;
|
|
|
|
|
+
|
|
|
|
|
+ r = ngui_cut_top(&body, 20);
|
|
|
|
|
+ ngui_text_px(&ui, r.x, r.y,
|
|
|
|
|
+ "8-63 characters, or 64 hex digits for a raw PSK.",
|
|
|
|
|
+ 48, ui.theme.text_dim, 11, 0, 0, 0);
|
|
|
|
|
+ body.y += 12;
|
|
|
|
|
+ body.h -= 12;
|
|
|
|
|
|
|
|
r = ngui_cut_top(&body, 30);
|
|
r = ngui_cut_top(&body, 30);
|
|
|
b1 = r;
|
|
b1 = r;
|
|
|
- b1.w = 100;
|
|
|
|
|
|
|
+ b1.w = 110;
|
|
|
b2 = r;
|
|
b2 = r;
|
|
|
- b2.x = r.x + 110;
|
|
|
|
|
- b2.w = 100;
|
|
|
|
|
|
|
+ b2.x = r.x + 120;
|
|
|
|
|
+ b2.w = 110;
|
|
|
if (ngui_button(&ui, ID_PASS_OK, b1, "Connect"))
|
|
if (ngui_button(&ui, ID_PASS_OK, b1, "Connect"))
|
|
|
actions |= ACT_CONNECT;
|
|
actions |= ACT_CONNECT;
|
|
|
if (ngui_button(&ui, ID_PASS_CANCEL, b2, "Cancel"))
|
|
if (ngui_button(&ui, ID_PASS_CANCEL, b2, "Cancel"))
|
|
|
actions |= ACT_BACK;
|
|
actions |= ACT_BACK;
|
|
|
-
|
|
|
|
|
- r = ngui_cut_top(&body, 22);
|
|
|
|
|
- ngui_text(&ui, r.x, r.y,
|
|
|
|
|
- "8-63 characters, or 64 hex digits for a raw PSK.",
|
|
|
|
|
- ui.theme.text_dim);
|
|
|
|
|
- draw_status();
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
static void draw_connect(void)
|
|
static void draw_connect(void)
|
|
|
{
|
|
{
|
|
|
- struct ngui_rect body = { 10, 10, ui.w - 20, ui.h - 40 };
|
|
|
|
|
- struct ngui_rect r, b;
|
|
|
|
|
|
|
+ struct ngui_rect body = pop.body;
|
|
|
|
|
+ struct ngui_rect log, b, r;
|
|
|
char line[96], *p;
|
|
char line[96], *p;
|
|
|
unsigned int start = 0, lines = 0, i;
|
|
unsigned int start = 0, lines = 0, i;
|
|
|
- int y, line_y;
|
|
|
|
|
|
|
+ int y, line_y = 0;
|
|
|
|
|
|
|
|
- r = ngui_cut_top(&body, 24);
|
|
|
|
|
- p = line;
|
|
|
|
|
- if (connect_pid > 0) {
|
|
|
|
|
- p = sput(p, "Connecting to \"");
|
|
|
|
|
- p = sput(p, sel_ssid);
|
|
|
|
|
- p = sput(p, "\"...");
|
|
|
|
|
- } else {
|
|
|
|
|
- p = sput(p, "WiFi connection \"");
|
|
|
|
|
- p = sput(p, sel_ssid);
|
|
|
|
|
- p = sput(p, "\"");
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ r = ngui_cut_top(&body, 22);
|
|
|
|
|
+ p = sput(line, connect_pid > 0 ? "Connecting to \"" :
|
|
|
|
|
+ "Connection to \"");
|
|
|
|
|
+ p = sput(p, sel_ssid);
|
|
|
|
|
+ p = sput(p, "\"");
|
|
|
*p = '\0';
|
|
*p = '\0';
|
|
|
ngui_text_ellipsis_utf8(&ui, r, r.x, r.y, line, ui.theme.text);
|
|
ngui_text_ellipsis_utf8(&ui, r, r.x, r.y, line, ui.theme.text);
|
|
|
|
|
|
|
|
- r = ngui_cut_top(&body, 22);
|
|
|
|
|
- if (status[0])
|
|
|
|
|
- ngui_text_utf8(&ui, r.x, r.y, status,
|
|
|
|
|
- status_error ? ui.theme.error : ui.theme.accent);
|
|
|
|
|
- body.y += 4;
|
|
|
|
|
- body.h -= 4;
|
|
|
|
|
|
|
+ /* The supplicant trail in a recessed card; the connection state is in
|
|
|
|
|
+ * the popover footer. */
|
|
|
|
|
+ log = body;
|
|
|
|
|
+ log.h -= 38;
|
|
|
|
|
+ ngui_fill_round_rect(&ui, log, 6, 6, 6, 6, ui.theme.panel);
|
|
|
|
|
+ ngui_push_clip(&ui, (struct ngui_rect){ log.x + 8, log.y + 8,
|
|
|
|
|
+ log.w - 16, log.h - 16 });
|
|
|
|
|
|
|
|
- /* Last ~12 lines of the helper's terminal output. */
|
|
|
|
|
for (i = conn_log_len; i > 0; i--) {
|
|
for (i = conn_log_len; i > 0; i--) {
|
|
|
if (conn_log[i - 1] == '\n' && ++lines > 12) {
|
|
if (conn_log[i - 1] == '\n' && ++lines > 12) {
|
|
|
start = i;
|
|
start = i;
|
|
|
break;
|
|
break;
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
- y = body.y;
|
|
|
|
|
- line_y = 0;
|
|
|
|
|
- for (i = start; i < conn_log_len && y + 16 <= body.y + body.h - 34; i++) {
|
|
|
|
|
|
|
+ y = log.y + 10;
|
|
|
|
|
+ for (i = start; i < conn_log_len && y + 14 <= log.y + log.h - 8; i++) {
|
|
|
char c = conn_log[i];
|
|
char c = conn_log[i];
|
|
|
|
|
|
|
|
if (c == '\r')
|
|
if (c == '\r')
|
|
|
continue;
|
|
continue;
|
|
|
if (c == '\n') {
|
|
if (c == '\n') {
|
|
|
line[line_y] = '\0';
|
|
line[line_y] = '\0';
|
|
|
- ngui_text_utf8(&ui, body.x, y, line, ui.theme.text_dim);
|
|
|
|
|
- y += 16;
|
|
|
|
|
|
|
+ if (line_y)
|
|
|
|
|
+ ngui_text_px(&ui, log.x + 10, y, line,
|
|
|
|
|
+ (unsigned int)line_y,
|
|
|
|
|
+ ui.theme.text_dim, 11, 0, 0, 1);
|
|
|
|
|
+ y += 14;
|
|
|
line_y = 0;
|
|
line_y = 0;
|
|
|
continue;
|
|
continue;
|
|
|
}
|
|
}
|
|
@@ -993,14 +1099,15 @@ static void draw_connect(void)
|
|
|
}
|
|
}
|
|
|
if (line_y) {
|
|
if (line_y) {
|
|
|
line[line_y] = '\0';
|
|
line[line_y] = '\0';
|
|
|
- ngui_text_utf8(&ui, body.x, y, line, ui.theme.text_dim);
|
|
|
|
|
|
|
+ ngui_text_px(&ui, log.x + 10, y, line, (unsigned int)line_y,
|
|
|
|
|
+ ui.theme.text_dim, 11, 0, 0, 1);
|
|
|
}
|
|
}
|
|
|
|
|
+ ngui_pop_clip(&ui);
|
|
|
|
|
|
|
|
- /* Cancel at the bottom. */
|
|
|
|
|
b.x = body.x;
|
|
b.x = body.x;
|
|
|
b.y = body.y + body.h - 28;
|
|
b.y = body.y + body.h - 28;
|
|
|
- b.w = 100;
|
|
|
|
|
- b.h = 24;
|
|
|
|
|
|
|
+ b.w = 110;
|
|
|
|
|
+ b.h = 26;
|
|
|
if (ngui_button(&ui, ID_CONN_CANCEL, b,
|
|
if (ngui_button(&ui, ID_CONN_CANCEL, b,
|
|
|
connect_pid > 0 ? "Cancel" : "Back"))
|
|
connect_pid > 0 ? "Cancel" : "Back"))
|
|
|
actions |= ACT_BACK;
|
|
actions |= ACT_BACK;
|
|
@@ -1008,67 +1115,71 @@ static void draw_connect(void)
|
|
|
|
|
|
|
|
static void draw_saved(void)
|
|
static void draw_saved(void)
|
|
|
{
|
|
{
|
|
|
- struct ngui_rect body = { 10, 10, ui.w - 20, ui.h - 40 };
|
|
|
|
|
- struct ngui_rect r, b, row, bt;
|
|
|
|
|
- char line[96], *p;
|
|
|
|
|
|
|
+ struct ngui_rect body = pop.body;
|
|
|
|
|
+ struct ngui_rect back, row, bt, list, r;
|
|
|
|
|
+ struct ngui_row desc;
|
|
|
|
|
+ char ssid[33];
|
|
|
int i;
|
|
int i;
|
|
|
|
|
|
|
|
- r = ngui_cut_top(&body, 24);
|
|
|
|
|
- ngui_text(&ui, r.x, r.y, "Saved WiFi networks", ui.theme.text);
|
|
|
|
|
- body.y += 4;
|
|
|
|
|
- body.h -= 4;
|
|
|
|
|
- body.h -= 34; /* room for the Back button */
|
|
|
|
|
|
|
+ r = ngui_cut_top(&body, 22);
|
|
|
|
|
+ ngui_text_px(&ui, r.x, r.y, "Saved Wi-Fi networks", 20,
|
|
|
|
|
+ ui.theme.text, 16, 1, 0, 0);
|
|
|
|
|
|
|
|
if (!nsaved) {
|
|
if (!nsaved) {
|
|
|
- ngui_text(&ui, body.x + 2, body.y + 4,
|
|
|
|
|
- "No saved networks", ui.theme.text_dim);
|
|
|
|
|
|
|
+ ngui_text_px(&ui, body.x + 2, body.y + 4,
|
|
|
|
|
+ "No saved networks", 17,
|
|
|
|
|
+ ui.theme.text_dim, 11, 0, 0, 0);
|
|
|
} else {
|
|
} else {
|
|
|
- saved_scroll.content_h = nsaved * 28;
|
|
|
|
|
- ngui_scroll_begin(&ui, body, &saved_scroll);
|
|
|
|
|
- ngui_scroll_wheel(&ui, body, &saved_scroll);
|
|
|
|
|
|
|
+ list = body;
|
|
|
|
|
+ list.h -= 38;
|
|
|
|
|
+ saved_scroll.content_h = nsaved * 40;
|
|
|
|
|
+ ngui_scroll_begin(&ui, list, &saved_scroll);
|
|
|
|
|
+ ngui_scroll_wheel(&ui, list, &saved_scroll);
|
|
|
ngui_scroll_keys(&ui, &saved_scroll);
|
|
ngui_scroll_keys(&ui, &saved_scroll);
|
|
|
for (i = 0; i < nsaved; i++) {
|
|
for (i = 0; i < nsaved; i++) {
|
|
|
- char ssid[33];
|
|
|
|
|
-
|
|
|
|
|
- row.x = body.x;
|
|
|
|
|
- row.y = body.y - saved_scroll.offset + i * 28;
|
|
|
|
|
- row.w = body.w - 16;
|
|
|
|
|
- row.h = 26;
|
|
|
|
|
- if (row.y + row.h <= body.y ||
|
|
|
|
|
- row.y >= body.y + body.h)
|
|
|
|
|
|
|
+ row.x = list.x;
|
|
|
|
|
+ row.y = list.y - saved_scroll.offset + i * 40;
|
|
|
|
|
+ row.w = list.w - 16;
|
|
|
|
|
+ row.h = 38;
|
|
|
|
|
+ if (row.y + row.h <= list.y ||
|
|
|
|
|
+ row.y >= list.y + list.h)
|
|
|
continue;
|
|
continue;
|
|
|
cfg_ssid_name(&saved[i], ssid);
|
|
cfg_ssid_name(&saved[i], ssid);
|
|
|
bt = row;
|
|
bt = row;
|
|
|
bt.x = row.x + row.w - 64;
|
|
bt.x = row.x + row.w - 64;
|
|
|
bt.w = 60;
|
|
bt.w = 60;
|
|
|
- bt.h = 22;
|
|
|
|
|
- row.w -= 70;
|
|
|
|
|
- p = sput(line, ssid);
|
|
|
|
|
- p = sput(p, saved[i].pass_len ? " WPA2" : " open");
|
|
|
|
|
- *p = '\0';
|
|
|
|
|
- ngui_text_ellipsis_utf8(&ui, row, row.x, row.y + 3,
|
|
|
|
|
- line, ui.theme.text);
|
|
|
|
|
|
|
+ bt.h = 28;
|
|
|
|
|
+ bt.y = row.y + 5;
|
|
|
|
|
+ row.w -= 76;
|
|
|
|
|
+
|
|
|
|
|
+ desc.title = ssid;
|
|
|
|
|
+ desc.subtitle = saved[i].pass_len ? "WPA2-PSK" : "Open";
|
|
|
|
|
+ desc.trailing = 0;
|
|
|
|
|
+ desc.bars = -1;
|
|
|
|
|
+ desc.selected = 0;
|
|
|
|
|
+ ngui_list_row_utf8(&ui, ID_SAVED_ROW_BASE + i, row,
|
|
|
|
|
+ &desc);
|
|
|
|
|
+
|
|
|
if (ngui_button(&ui, ID_SAVED_BASE + i, bt,
|
|
if (ngui_button(&ui, ID_SAVED_BASE + i, bt,
|
|
|
"Forget")) {
|
|
"Forget")) {
|
|
|
action_saved = i;
|
|
action_saved = i;
|
|
|
actions |= ACT_FORGET;
|
|
actions |= ACT_FORGET;
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
- ngui_scroll_end(&ui, body, &saved_scroll);
|
|
|
|
|
|
|
+ ngui_scroll_end(&ui, list, &saved_scroll);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- b.x = body.x;
|
|
|
|
|
- b.y = body.y + body.h + 6;
|
|
|
|
|
- b.w = 100;
|
|
|
|
|
- b.h = 24;
|
|
|
|
|
- if (ngui_button(&ui, ID_SAVED_BACK, b, "Back"))
|
|
|
|
|
|
|
+ back.x = body.x;
|
|
|
|
|
+ back.y = body.y + body.h - 28;
|
|
|
|
|
+ back.w = 100;
|
|
|
|
|
+ back.h = 26;
|
|
|
|
|
+ if (ngui_button(&ui, ID_SAVED_BACK, back, "Back"))
|
|
|
actions |= ACT_BACK;
|
|
actions |= ACT_BACK;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
static void draw(void)
|
|
static void draw(void)
|
|
|
{
|
|
{
|
|
|
- ngui_fill_rect(&ui, (struct ngui_rect){ 0, 0, ui.w, ui.h },
|
|
|
|
|
- ui.theme.bg);
|
|
|
|
|
|
|
+ ngui_popover_begin(&ui, &pop);
|
|
|
if (view == VIEW_PASS)
|
|
if (view == VIEW_PASS)
|
|
|
draw_pass();
|
|
draw_pass();
|
|
|
else if (view == VIEW_CONNECT)
|
|
else if (view == VIEW_CONNECT)
|
|
@@ -1077,8 +1188,7 @@ static void draw(void)
|
|
|
draw_saved();
|
|
draw_saved();
|
|
|
else
|
|
else
|
|
|
draw_main();
|
|
draw_main();
|
|
|
- if (view != VIEW_PASS && view != VIEW_CONNECT)
|
|
|
|
|
- draw_status();
|
|
|
|
|
|
|
+ draw_status();
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
static void paint_frame(void)
|
|
static void paint_frame(void)
|
|
@@ -1099,9 +1209,9 @@ void _start(const char *arg)
|
|
|
unsigned int last_status = 0;
|
|
unsigned int last_status = 0;
|
|
|
|
|
|
|
|
(void)arg;
|
|
(void)arg;
|
|
|
- if (u_win_create(460, 500, "Network", &wi) != 0 &&
|
|
|
|
|
- u_win_create(400, 420, "Network", &wi) != 0 &&
|
|
|
|
|
- u_win_create(340, 360, "Network", &wi) != 0) {
|
|
|
|
|
|
|
+ if (u_win_create_popover(404, 520, "Network", &wi) != 0 &&
|
|
|
|
|
+ u_win_create_popover(380, 440, "Network", &wi) != 0 &&
|
|
|
|
|
+ u_win_create_popover(340, 360, "Network", &wi) != 0) {
|
|
|
u_exit(1);
|
|
u_exit(1);
|
|
|
}
|
|
}
|
|
|
ngui_init(&ui, (unsigned short *)wi.fb, (int)wi.width, (int)wi.height);
|
|
ngui_init(&ui, (unsigned short *)wi.fb, (int)wi.width, (int)wi.height);
|
|
@@ -1109,6 +1219,7 @@ void _start(const char *arg)
|
|
|
pass_in.secret = 1;
|
|
pass_in.secret = 1;
|
|
|
pass_in.placeholder = "WPA2 passphrase";
|
|
pass_in.placeholder = "WPA2 passphrase";
|
|
|
view = VIEW_MAIN;
|
|
view = VIEW_MAIN;
|
|
|
|
|
+ main_scroll.offset = 0;
|
|
|
|
|
|
|
|
load_devices();
|
|
load_devices();
|
|
|
load_status();
|
|
load_status();
|
|
@@ -1120,6 +1231,7 @@ void _start(const char *arg)
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
for (;;) {
|
|
for (;;) {
|
|
|
|
|
+ static int first_frame = 1;
|
|
|
unsigned int now = u_ticks_ms();
|
|
unsigned int now = u_ticks_ms();
|
|
|
|
|
|
|
|
drain_tty();
|
|
drain_tty();
|
|
@@ -1139,6 +1251,14 @@ void _start(const char *arg)
|
|
|
if (ngui_begin(&ui)) {
|
|
if (ngui_begin(&ui)) {
|
|
|
draw();
|
|
draw();
|
|
|
ngui_end(&ui);
|
|
ngui_end(&ui);
|
|
|
|
|
+ if (first_frame) {
|
|
|
|
|
+ /* The first present can race the WM's initial
|
|
|
|
|
+ * mapping of the popover canvas; paint a second
|
|
|
|
|
+ * frame once so the panel never shows a black
|
|
|
|
|
+ * tail. */
|
|
|
|
|
+ first_frame = 0;
|
|
|
|
|
+ ngui_invalidate(&ui);
|
|
|
|
|
+ }
|
|
|
handle_actions();
|
|
handle_actions();
|
|
|
}
|
|
}
|
|
|
|
|
|