From bd24c6722417dd5780cffa580bf0d9b4426c33db Mon Sep 17 00:00:00 2001 From: cy384 Date: Mon, 14 Sep 2020 18:51:29 -0400 Subject: [PATCH] add password/key radio buttons to connect dialog --- ssheven.c | 36 +++++++++++++++++++++++++++++++++++- ssheven.r | 8 +++++++- 2 files changed, 42 insertions(+), 2 deletions(-) diff --git a/ssheven.c b/ssheven.c index 714ae3b..722cbe9 100644 --- a/ssheven.c +++ b/ssheven.c @@ -573,6 +573,13 @@ int password_dialog(void) return ret; } +int key_dialog(void) +{ + // TODO: keys + printf_i("key authentication not implemented yet\r\n"); + return 0; +} + int intro_dialog(char* hostname, char* username, char* password) { // modal dialog setup @@ -605,11 +612,31 @@ int intro_dialog(char* hostname, char* username, char* password) GetDialogItem(dlg, 7, &type, &itemH, &box); username_text_box = (ControlHandle)itemH; + ControlHandle password_radio; + GetDialogItem(dlg, 9, &type, &itemH, &box); + password_radio = (ControlHandle)itemH; + SetControlValue(password_radio, 1); + + ControlHandle key_radio; + GetDialogItem(dlg, 10, &type, &itemH, &box); + key_radio = (ControlHandle)itemH; + SetControlValue(key_radio, 0); + // let the modalmanager do everything // stop when the connect button is hit short item; do { ModalDialog(NULL, &item); + if (item == 9) + { + SetControlValue(key_radio, 0); + SetControlValue(password_radio, 1); + } + else if (item == 10) + { + SetControlValue(key_radio, 1); + SetControlValue(password_radio, 0); + } } while(item != 1 && item != 8); // copy the text out of the boxes @@ -627,7 +654,14 @@ int intro_dialog(char* hostname, char* username, char* password) // if we hit cancel, 0 if (item == 8) return 0; - return password_dialog(); + if (GetControlValue(password_radio) == 1) + { + return password_dialog(); + } + else + { + return key_dialog(); + } } void* read_thread(void* arg) diff --git a/ssheven.r b/ssheven.r index 7031029..ef70ce5 100644 --- a/ssheven.r +++ b/ssheven.r @@ -60,11 +60,17 @@ resource 'DITL' (DITL_CONNECT) { { 60, 10, 80, 310 }, StaticText { enabled, "Username" }; - { 85, 15, 101, 305 }, + { 85, 15, 101, 150 }, EditText { enabled, "" }; { 115, 10, 135, 90 }, Button { enabled, "Cancel" }; + + { 85, 160, 101, 245 }, + RadioButton { enabled, "Password" }; + + { 85, 250, 101, 310 }, + RadioButton { enabled, "Key" }; } };