Password via SWkbd
This commit is contained in:
parent
486b30a856
commit
77e9344057
1 changed files with 13 additions and 1 deletions
14
src/main.cpp
14
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<char> otkrandom = std::make_unique<char>(len);
|
||||
|
|
Loading…
Reference in a new issue