-
Notifications
You must be signed in to change notification settings - Fork 1
/
usermessage.cpp
286 lines (260 loc) · 11.4 KB
/
usermessage.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
//Copyright (C) 2020 Illotros GmbH
//This program is free software: you can redistribute it and/or modify
//it under the terms of the GNU General Public License as published by
//the Free Software Foundation, either version 3 of the License.
//This program is distributed in the hope that it will be useful,
//but WITHOUT ANY WARRANTY; without even the implied warranty of
//MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
//GNU General Public License for more details.
//You should have received a copy of the GNU General Public License
//along with this program. If not, see <https://www.gnu.org/licenses/>.
#include "usermessage.h"
UserMessage::UserMessage()
{
}
void UserMessage::userMasterSecretError(int status_code)
{
QMessageBox msgBox;
switch (status_code) {
case 1:
msgBox.setText(QCoreApplication::translate("msgBox user set master secret error title", "Invalid master secret"));
msgBox.setInformativeText(QCoreApplication::translate("msgBox user set master secret error text", "The entered master secret has an incorrect length."));
break;
case 2:
msgBox.setText(QCoreApplication::translate("msgBox user set master secret error title", "Invalid master secret"));
msgBox.setInformativeText(QCoreApplication::translate("msgBox user set master secret error text", "The entered master secret has an unsupported version."));
break;
case 3:
msgBox.setText(QCoreApplication::translate("msgBox user set master secret error title", "Invalid master secret"));
msgBox.setInformativeText(QCoreApplication::translate("msgBox user set master secret error text", "Please enter a valid master secret."));
break;
default:
msgBox.setText(QCoreApplication::translate("msgBox user set master secret error title", "Invalid master secret"));
msgBox.setInformativeText(QCoreApplication::translate("msgBox user set master secret error text", "Please enter a valid master secret."));
break;
}
msgBox.setIcon(QMessageBox::Warning);
msgBox.setStandardButtons(QMessageBox::Ok);
int ret = msgBox.exec();
switch (ret) {
case QMessageBox::Ok:
emit goToLoginPage();
break;
default:
emit goToLoginPage();
break;
}
}
void UserMessage::invalidSubscription()
{
QMessageBox msgBox;
msgBox.setText(QCoreApplication::translate("msgBox invalide subscription title", "Invalid subscription"));
msgBox.setInformativeText(QCoreApplication::translate("msgBox invalide subscription text", "This account has no valid subscription."));
msgBox.setIcon(QMessageBox::Warning);
QPushButton *getSubscriptionButton = msgBox.addButton(QCoreApplication::translate("msg invalid subscription getSubscription button", "Get subscription"), QMessageBox::ActionRole);
msgBox.exec();
if (msgBox.clickedButton() == getSubscriptionButton) {
QDesktopServices::openUrl(QUrl(QString(SNOWHAZE_DASHBOARD_URL) + "en/select_plan.html"));
emit requestLogout();
} else {
emit requestLogout();
}
}
void UserMessage::publicKeyNotRegistered()
{
QMessageBox msgBox;
msgBox.setText(QCoreApplication::translate("msgBox publickey not registered title", "Public key not registered"));
msgBox.setInformativeText(QCoreApplication::translate("msgBox publickey not registered text", "Log into your dashboard for more information."));
msgBox.setIcon(QMessageBox::Warning);
QPushButton *getSubscriptionButton = msgBox.addButton(QCoreApplication::translate("msgpublickey not registered button", "Go to dashboard"), QMessageBox::ActionRole);
msgBox.exec();
if (msgBox.clickedButton() == getSubscriptionButton) {
QDesktopServices::openUrl(QUrl(QString(SNOWHAZE_DASHBOARD_URL) + "en/login.html"));
emit requestLogout();
} else {
emit requestLogout();
}
}
void UserMessage::processError(QString process)
{
QMessageBox msgBox;
if (process == "python"){
msgBox.setText(QCoreApplication::translate("msgBox python process failed", "Unable to run Python process"));
} else if(process == "openvpn"){
msgBox.setText(QCoreApplication::translate("msgBox openvpn process failed", "Unable to run OpenVPN process"));
} else {
msgBox.setText(QCoreApplication::translate("msgBox default process failed", "Unable to run process"));
}
msgBox.setInformativeText(QCoreApplication::translate("msgBox python process failed text", "SnowHaze VPN was not able to start the verification process. Try to reinstall SnowHaze VPN to solve this problem. If this error message perists reach out to the SnowHaze support."));
msgBox.setIcon(QMessageBox::Warning);
msgBox.setStandardButtons(QMessageBox::Ok);
QPushButton *contactSupportButton = msgBox.addButton(QCoreApplication::translate("msgBox process failed contact-button", "Contact support"), QMessageBox::ActionRole);
msgBox.exec();
if (msgBox.clickedButton() == contactSupportButton) {
QDesktopServices::openUrl(QUrl(QString(SNOWHAZE_WEBSITE_URL) + "en/support-contact.html"));
} else {
}
}
void UserMessage::vpnProcessTimeoutError()
{
QMessageBox msgBox;
msgBox.setText(QCoreApplication::translate("msgBox ovpnProcess timeout error title", "SnowHaze VPN is unable to detect a successful VPN connection. Make sure you have an active internet connection."));
msgBox.setIcon(QMessageBox::Warning);
msgBox.setStandardButtons(QMessageBox::Ok);
int ret = msgBox.exec();
switch (ret) {
case QMessageBox::Ok:
break;
default:
break;
}
}
void UserMessage::loadVPNProfilesFailed()
{
QMessageBox msgBox;
msgBox.setText(QCoreApplication::translate("msgBox load VPN profiles failed", "SnowHaze VPN was unable to load the localy stored profiles."));
msgBox.setIcon(QMessageBox::Warning);
msgBox.setStandardButtons(QMessageBox::Ok);
int ret = msgBox.exec();
switch (ret) {
case QMessageBox::Ok:
emit requestLogout();
break;
default:
break;
}
}
void UserMessage::logoutWarning()
{
QMessageBox msgBox;
msgBox.setText(QCoreApplication::translate("msgBox logout warning", "Do you want to logout from SnowHaze VPN? This will delete all user specific data on your device."));
msgBox.setIcon(QMessageBox::Warning);
msgBox.addButton(QMessageBox::No);
msgBox.addButton(QMessageBox::Yes);
msgBox.setDefaultButton(QMessageBox::No);
int ret = msgBox.exec();
switch (ret) {
case QMessageBox::Yes:
emit requestLogout();
break;
case QMessageBox::No:
break;
default:
break;
}
}
void UserMessage::encryptionFailure(QString error)
{
QMessageBox msgBox;
msgBox.setText(QCoreApplication::translate("msgBox libsodium failure", "An encryption failure occured"));
msgBox.setInformativeText(QCoreApplication::translate("msgBox libsodium failure text", "Libsodium error message: ") + error);
msgBox.setIcon(QMessageBox::Critical);
msgBox.setStandardButtons(QMessageBox::Ok);
int ret = msgBox.exec();
switch (ret) {
case QMessageBox::Ok:
break;
default:
break;
}
}
void UserMessage::overusedTokensWarning()
{
QMessageBox msgBox;
msgBox.setText(QCoreApplication::translate("msgBox oversued tokens warning", "Overused tokens"));
msgBox.setInformativeText(QCoreApplication::translate("msgBox oversued tokens warning text", "Every subscription has a certain number of tokens which can be used to get the VPN profiles. If all these tokens were used too many times to recieve the VPN profiles they become invalid. This prevents abuse of the subscription. In a few days your tokens renew and you will be able to download the VPN profiles again."));
msgBox.setIcon(QMessageBox::Warning);
msgBox.setStandardButtons(QMessageBox::Ok);
int ret = msgBox.exec();
switch (ret) {
case QMessageBox::Ok:
emit requestLogout();
break;
default:
emit requestLogout();
break;
}
}
bool UserMessage::missingDependecyWarning(QString dependency)
{
QMessageBox msgbox;
msgbox.setText(QCoreApplication::translate("msg missing Dependency text 1", "SnowHaze VPN depends on ") + dependency + QCoreApplication::translate("msg missing Dependency text 2", ". If ") + dependency + QCoreApplication::translate("msg missing Dependency text 3", " is not installed, SnowHaze VPN will not be able to establish a VPN connection."));
msgbox.setIcon(QMessageBox::Icon::Information);
QPushButton *getButton = msgbox.addButton(QCoreApplication::translate("msg missing Dependency get dependency button", "Get " ) + dependency, QMessageBox::ActionRole);
QPushButton *alreadyHaveButton = msgbox.addButton(dependency + QCoreApplication::translate("msg missing Dependency get dependency button", " is installed" ) , QMessageBox::ActionRole);
msgbox.setDefaultButton(alreadyHaveButton);
msgbox.exec();
if( msgbox.clickedButton() == getButton){
if(dependency == "OpenVPN Gui"){
QDesktopServices::openUrl(QUrl(OPENVPN_DOWNLOADS_URL));
}
return false;
} else if( msgbox.clickedButton() == alreadyHaveButton) {
return false;
}
return true;
}
void UserMessage::memLockErrorWarning()
{
QMessageBox msgBox;
msgBox.setText(QCoreApplication::translate("msgBox wrong memLock error warning title", "Memory lock error"));
msgBox.setInformativeText(QCoreApplication::translate("msgBox wrong memLock error warning text", "SnowHaze VPN was not able to lock the memory. Therefore, sensitive data might be swaped to the disk."));
msgBox.setIcon(QMessageBox::Warning);
msgBox.setStandardButtons(QMessageBox::Ok);
int ret = msgBox.exec();
switch (ret) {
case QMessageBox::Ok:
break;
default:
break;
}
}
void UserMessage::wrongCredentials()
{
QMessageBox msgBox;
msgBox.setText(QCoreApplication::translate("msgBox wrong login credentials title", "Wrong login credentials"));
msgBox.setInformativeText(QCoreApplication::translate("msgBox wrong login credentials text", "Your email and/or password is wrong."));
msgBox.setIcon(QMessageBox::Warning);
msgBox.setStandardButtons(QMessageBox::Ok);
int ret = msgBox.exec();
switch (ret) {
case QMessageBox::Ok:
emit goToLoginPage();
break;
default:
emit goToLoginPage();
break;
}
}
void UserMessage::networkError(int status_code)
{
QMessageBox msgBox;
msgBox.setText(QCoreApplication::translate("msgBox network error title", "Network error ") + QString::number(status_code));
msgBox.setInformativeText(QCoreApplication::translate("msgBox network error text", "Connecting to server failed. Please check your internet connection."));
msgBox.setIcon(QMessageBox::Warning);
msgBox.setStandardButtons(QMessageBox::Ok);
int ret = msgBox.exec();
switch (ret) {
case QMessageBox::Ok:
emit requestLogout();
break;
default:
emit requestLogout();
}
}
void UserMessage::QKeychainError()
{
QMessageBox msgBox;
msgBox.setText(QCoreApplication::translate("msgBox QKeychain error title", "Local storage error"));
msgBox.setInformativeText(QCoreApplication::translate("msgBox QKeychain text", "SnowHaze VPN failed to securely store data on your device."));
msgBox.setIcon(QMessageBox::Warning);
msgBox.setStandardButtons(QMessageBox::Ok);
int ret = msgBox.exec();
switch (ret) {
case QMessageBox::Ok:
emit requestLogout();
break;
default:
emit requestLogout();
}
}