Password via SWkbd

This commit is contained in:
timoreo 2023-12-09 15:15:10 +01:00
parent 486b30a856
commit 77e9344057
Signed by: timoreo
GPG key ID: 121A72C3512BA288

View file

@ -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<char> otkrandom = std::make_unique<char>(len);