| 1 |
#include "tquery_handler.h" |
| 2 |
|
| 3 |
#include "adt/string.h" |
| 4 |
|
| 5 |
#include <boost/algorithm/string/split.hpp> |
| 6 |
|
| 7 |
#include <iostream> |
| 8 |
|
| 9 |
query_handler::query_handler ( communicator &comm |
| 10 |
, std::string const &username |
| 11 |
, std::string const &password |
| 12 |
) |
| 13 |
: sender (comm) |
| 14 |
, username (username) |
| 15 |
, password (password) |
| 16 |
{ |
| 17 |
} |
| 18 |
|
| 19 |
void |
| 20 |
query_handler::query (int flags, std::string const &prompt) |
| 21 |
{ |
| 22 |
if (!username.empty ()) |
| 23 |
{ |
| 24 |
if (flags == 0 && !strncmp (prompt, "What is your name?")) |
| 25 |
{ |
| 26 |
send ("reply", username); |
| 27 |
return; |
| 28 |
} |
| 29 |
else if (flags == 4 && !strncmp (prompt, "What is your password?")) |
| 30 |
{ |
| 31 |
send ("reply", password); |
| 32 |
return; |
| 33 |
} |
| 34 |
else if (flags == 4 && !strncmp (prompt, "Please type your password again.")) |
| 35 |
{ |
| 36 |
send ("reply", password); |
| 37 |
return; |
| 38 |
} |
| 39 |
} |
| 40 |
|
| 41 |
std::cout << "query: " << prompt << '\n'; |
| 42 |
} |