From 77e93440579c1fb5ea4696c713df1fe86a04e95f Mon Sep 17 00:00:00 2001 From: timoreo Date: Sat, 9 Dec 2023 15:15:10 +0100 Subject: [PATCH] Password via SWkbd --- src/main.cpp | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/main.cpp b/src/main.cpp index a13428a..7a9d016 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -21,6 +21,7 @@ class Store : public Matrix::Store { void setFilterId(std::string filterId) override {} std::string getFilterId() override { return ""; } }; +std::string ask_for_pass(); PrintConsole* bottom = new PrintConsole; int main() { fsInit(); @@ -45,7 +46,8 @@ int main() { if(!stream.is_open()){ // File dosn't exist, log in client = new Matrix::Client("https://matrix.timoreo.fr", "", nullptr); // &s - if (client->login("timoreo-3ds", "", DEVICE_ID)) { + + if (client->login("timoreo-3ds", ask_for_pass(), DEVICE_ID)) { // logged in puts("Logged in !!"); std::ofstream ostr{TOKEN_FILENAME, std::fstream::out}; @@ -90,6 +92,16 @@ int main() { gfxExit(); fsExit(); } +std::string ask_for_pass() { + SwkbdState swkbd; + swkbdInit(&swkbd, SWKBD_TYPE_WESTERN, 1, -1); + swkbdSetValidation(&swkbd, SWKBD_NOTEMPTY_NOTBLANK, 0, 0); + swkbdSetPasswordMode(&swkbd, SWKBD_PASSWORD_HIDE_DELAY); + swkbdSetHintText(&swkbd, "Enter password"); + char buf[256]; + swkbdInputText(&swkbd, buf, sizeof(buf)); + return buf; +} void generate_otk(OlmAccount* acc, size_t otkcount) { size_t len = olm_account_generate_one_time_keys_random_length(acc, otkcount); std::unique_ptr otkrandom = std::make_unique(len);