You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: src/client.cpp
+23-9Lines changed: 23 additions & 9 deletions
Original file line number
Diff line number
Diff line change
@@ -1,3 +1,8 @@
1
+
/**
2
+
* \file
3
+
* \brief Chat client -- interacts with user, displays, sends and encrypts messages
4
+
**/
5
+
1
6
#include"client_lib.hpp"
2
7
#include<boost/asio.hpp>
3
8
#include<boost/asio/buffer.hpp>
@@ -22,6 +27,11 @@ using json = nlohmann::json;
22
27
23
28
voidprocess_step(User &user)
24
29
{
30
+
/**
31
+
This function provides UI:
32
+
draws screen and displays everything as well as performs navigation
33
+
\param user instance of User class
34
+
**/
25
35
system("clear");
26
36
std::string code;
27
37
@@ -31,12 +41,13 @@ void process_step(User &user)
31
41
32
42
if (user.logged_in)
33
43
{
34
-
fmt::print("Hi {}! \n\nSelect an option below:\n", user.username);
44
+
fmt::print("{}, welcome back! \n\nSelect an option below:\n", user.username);
35
45
fmt::print(" s | Sync\n");
36
46
fmt::print(" c | Chat List\n");
47
+
fmt::print("\nSync messages to get your inbox from the server. \nThen proceed to your Chat List.\n");
37
48
}
38
49
else {
39
-
fmt::print("Welcome to Chat client! \n\nSelect an option below:\n");
50
+
fmt::print("Welcome to Chat client! \n\nEnter s, if you don't have an account or enter l to log in:\n");
40
51
fmt::print(" u | Sign Up\n");
41
52
fmt::print(" l | Log In\n");
42
53
}
@@ -60,6 +71,7 @@ void process_step(User &user)
60
71
elseif (user.state == 1) // sign up
61
72
{
62
73
fmt::print("Sign Up \n\n");
74
+
fmt::print("Welcome here! You are about to create an account. \nJust take any free username and you are ready to rock. \nAfter creating an account, go to Chat List section and \nstart new dialog. Sync messages after that.\n\n");
63
75
64
76
while (!user.logged_in) // ещё не зарегестрировался
65
77
{
@@ -80,9 +92,10 @@ void process_step(User &user)
80
92
elseif (user.state == 2) // log in
81
93
{
82
94
fmt::print("Log in \n\n");
95
+
fmt::print("Now you have to enter your username. If you are not registered yet, please,\ngo back and select Sign up. \n\n");
83
96
while (!user.logged_in) // ещё не вошёл
84
97
{
85
-
fmt::print("Enter username (or b to go back): ");
98
+
fmt::print("Enter your username (or b to go back): ");
86
99
std::getline(std::cin >> std::ws, code);
87
100
if (code == std::string{'b'}) { user.state = 0; break;}
88
101
@@ -98,7 +111,7 @@ void process_step(User &user)
98
111
99
112
elseif (user.state == 3) // sync
100
113
{
101
-
fmt::print("Sync messages... \n\n");
114
+
fmt::print("Syncing messages... \n\n");
102
115
103
116
user.messages = get_messages(user);
104
117
user.state = 0;
@@ -115,7 +128,7 @@ void process_step(User &user)
115
128
[&](){
116
129
system("clear");
117
130
fmt::print("Chat List \n\nSelect from the list below: \n\n");
118
-
if (user.messages.empty()) fmt::print("Empty. Try to sync messages first. \n\n");
131
+
if (user.messages.empty()) fmt::print("Nothing's here. \nEnter n to start your first dialog! \nOr go back (b) and sync messages.\n\n");
fmt::print("Decrypt messages\n\nEnter the key from {} or b to go back: ", user.current_chat);
174
+
fmt::print("Decrypt messages\n\nIf you've just created chat, enter any word combination. \nYou will use it later to decrypt messages. \n\nEnter the key from {} or b to go back: ", user.current_chat);
0 commit comments