commit - d6cd2fc18acd63daadbc6bd251be02fcc2f14341
commit + 5d1bac73bfa4fb96ce36495b0480d5f7ba5df8a2
blob - 18cd4bd46af8e7dbb703c81fa0dcff90c64f24a5
blob + 6459d502e21aaa62b46950634fa9708805486cf3
--- telescope.c
+++ telescope.c
static struct tab *tab_by_id(uint32_t);
static void handle_imsg_err(struct imsg*, size_t);
static void handle_imsg_check_cert(struct imsg*, size_t);
+static void handle_check_cert_user_choice(int, unsigned int);
static void handle_imsg_got_code(struct imsg*, size_t);
static void handle_imsg_got_meta(struct imsg*, size_t);
static void handle_imsg_buf(struct imsg*, size_t);
} else
tofu_res = !strcmp(hash, e->hash);
- if (tofu_res)
+ if (tofu_res) {
tab->trust = e->verified ? TS_VERIFIED : TS_TRUSTED;
- else {
+ imsg_compose(netibuf, IMSG_CERT_STATUS, imsg->hdr.peerid, 0, -1,
+ &tofu_res, sizeof(tofu_res));
+ imsg_flush(netibuf);
+ } else {
tab->trust = TS_UNTRUSTED;
load_page_from_str(tab, "# Certificate mismatch\n");
+ ui_yornp("Certificate mismatch. Proceed?",
+ handle_check_cert_user_choice);
}
- imsg_compose(netibuf, IMSG_CERT_STATUS, imsg->hdr.peerid, 0, -1,
- &tofu_res, sizeof(tofu_res));
+}
+
+static void
+handle_check_cert_user_choice(int accept, unsigned int tabid)
+{
+ imsg_compose(netibuf, IMSG_CERT_STATUS, tabid, 0, -1,
+ &accept, sizeof(accept));
imsg_flush(netibuf);
}
blob - d67ae95d13693918cc02720e02c7374c8695b685
blob + a96c2291c4d5e5c7a0c2cd4b7827e7a9e0330e58
--- telescope.h
+++ telescope.h
void ui_on_tab_loaded(struct tab*);
void ui_on_tab_refresh(struct tab*);
void ui_require_input(struct tab*, int);
+void ui_yornp(const char*, void (*)(int, unsigned int));
void ui_notify(const char*, ...) __attribute__((format(printf, 1, 2)));
void ui_end(void);
blob - cf5bdd939764a01767120aa57356e7b9af7b4d1b
blob + c0d355c32a5456c87e2489c00b87eee85d3de27f
--- ui.c
+++ ui.c
static void lu_self_insert(void);
static void lu_select(void);
static void bp_select(void);
+static void yornp_self_insert(void);
+static void yornp_abort(void);
static struct vline *nth_line(struct window*, size_t);
static struct tab *current_tab(void);
static char keybuf[64];
+static void (*yornp_cb)(int, unsigned int);
+
struct kmap global_map,
minibuffer_map,
*current_map,
static struct {
char *curmesg;
- char prompt[32];
+ char prompt[64];
void (*donefn)(void);
void (*abortfn)(void);
add_to_bookmarks(ministate.buf);
else
message("Abort.");
+}
+
+static void
+yornp_self_insert(void)
+{
+ if (thiskey.key != 'y' && thiskey.key != 'n') {
+ message("Please answer y or n");
+ return;
+ }
+
+ yornp_cb(thiskey.key == 'y', current_tab()->id);
+ exit_minibuffer();
+}
+
+static void
+yornp_abort(void)
+{
+ yornp_cb(0, current_tab()->id);
+ exit_minibuffer();
}
static struct vline *
}
void
+ui_yornp(const char *prompt, void (*fn)(int, unsigned int))
+{
+ size_t len;
+
+ yornp_cb = fn;
+ enter_minibuffer(yornp_self_insert, yornp_self_insert,
+ yornp_abort, NULL);
+
+ len = sizeof(ministate.prompt);
+ strlcpy(ministate.prompt, prompt, len);
+ strlcat(ministate.prompt, " (y or n) ", len);
+ redraw_tab(current_tab());
+}
+
+void
ui_notify(const char *fmt, ...)
{
va_list ap;