ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/cvsroot/cf.schmorp.de/dclient/src/frontend/tclient/tquery_handler.cpp
Revision: 1.2
Committed: Sun Oct 24 22:41:36 2010 UTC (16 years ago) by sf-pippijn
Branch: MAIN
CVS Tags: HEAD
Changes since 1.1: +16 -15 lines
Log Message:
fixed bug causing queries to be hidden if the user supplied a username on the cmdline

File Contents

# Content
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 }