blob: 69606664cf524e0e70f2854eb33cad35d7207353 [file] [log] [blame]
Edric Milaret627500d2015-03-27 16:41:40 -04001/***************************************************************************
Anthony Léonard2fde81d2017-04-17 10:06:55 -04002 * Copyright (C) 2015-2017 by Savoir-faire Linux *
Edric Milaret627500d2015-03-27 16:41:40 -04003 * Author: Edric Ladent Milaret <edric.ladent-milaret@savoirfairelinux.com>*
4 * *
5 * This program is free software; you can redistribute it and/or modify *
6 * it under the terms of the GNU General Public License as published by *
7 * the Free Software Foundation; either version 3 of the License, or *
8 * (at your option) any later version. *
9 * *
10 * This program is distributed in the hope that it will be useful, *
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
13 * GNU General Public License for more details. *
14 * *
15 * You should have received a copy of the GNU General Public License *
16 * along with this program. If not, see <http://www.gnu.org/licenses/>. *
17 **************************************************************************/
18
19#include "accountdetails.h"
20#include "ui_accountdetails.h"
21
22#include <QSortFilterProxyModel>
Edric Milaret3e6aefe2015-06-05 16:07:26 -040023#include <QFileDialog>
24#include <QPushButton>
Anthony Léonardaa90e1a2016-10-12 11:24:17 -040025#include <QMessageBox>
Edric Milaret627500d2015-03-27 16:41:40 -040026
Edric Milarete82782e2016-03-21 12:14:17 -040027#include "codecmodel.h"
Edric Milaret3e6aefe2015-06-05 16:07:26 -040028#include "protocolmodel.h"
29#include "certificate.h"
30#include "ciphermodel.h"
Edric Milaretb1b00ce2016-02-03 14:10:05 -050031#include "ringtonemodel.h"
Edric Milaret627500d2015-03-27 16:41:40 -040032
33AccountDetails::AccountDetails(QWidget *parent) :
34 QWidget(parent),
35 ui(new Ui::AccountDetails),
36 codecModel_(nullptr),
Edric Milaret2d03da42015-07-15 15:36:43 -040037 currentAccount_(nullptr)
Edric Milaret627500d2015-03-27 16:41:40 -040038{
39 ui->setupUi(this);
40
Edric Milaretc9d3e412015-08-11 15:43:04 -040041 setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding);
42
Nicolas Jager584a80e2016-03-18 16:10:00 -040043 connect(ui->lrcfg_tlsCaListCertificate, &RingButton::clicked, this, &AccountDetails::onCertButtonClicked);
44 connect(ui->lrcfg_tlsCertificate, &RingButton::clicked, this, &AccountDetails::onCertButtonClicked);
45 connect(ui->lrcfg_tlsPrivateKeyCertificate, &RingButton::clicked, this, &AccountDetails::onCertButtonClicked);
Edric Milaretdda49b62016-02-05 14:27:38 -050046
47 connect(&RingtoneModel::instance(),
48 &RingtoneModel::dataChanged,
49 [=](const QModelIndex& topLeft, const QModelIndex& bottomRight) {
50 Q_UNUSED(topLeft)
51 Q_UNUSED(bottomRight)
52 if (not currentAccount_)
53 return;
54 if (RingtoneModel::instance().isPlaying())
55 ui->playButton->setText(tr("Pause"));
56 else
57 ui->playButton->setText(tr("Play"));
58
59 });
Nicolas Jagere6384052016-03-10 13:13:24 -050060
61 connect(ui->lrcfg_tlsEnabled, &QCheckBox::stateChanged, [=] (int state) {
62 if(state == Qt::Checked) {
63 ui->negoEncry_1->setVisible(currentAccount_->protocol() != Account::Protocol::RING);
64 ui->negoEncry_2->setVisible(true);
65 ui->defaultCipherCheckBox->setVisible(currentAccount_->protocol() != Account::Protocol::RING);
66 ui->cipherListView->setVisible(!ui->defaultCipherCheckBox->isChecked()
67 && currentAccount_->protocol() != Account::Protocol::RING);
68 } else {
69 ui->negoEncry_1->setVisible(false);
70 ui->negoEncry_2->setVisible(false);
71 ui->defaultCipherCheckBox->setVisible(false);
72 ui->cipherListView->setVisible(false);
73 }
74 });
75
76 connect(ui->defaultCipherCheckBox, &QCheckBox::stateChanged, [=] (int state) {
77 if (state == Qt::Checked) {
78 ui->cipherListView->setVisible(false);
79 currentAccount_->cipherModel()->setUseDefault(true);
80 } else {
81 ui->cipherListView->setVisible(true);
82 currentAccount_->cipherModel()->setUseDefault(false);
83 }
84 });
Edric Milaret13438312016-03-18 13:27:46 -040085
86 connect(ui->lrcfg_alias, &QLineEdit::textEdited, [=](const QString& newAlias) {
87 if (currentAccount_ && currentAccount_->protocol() == Account::Protocol::RING)
88 currentAccount_->setDisplayName(newAlias);
89 });
Anthony Léonard5107a692016-11-04 13:20:37 -040090
91 connect(ui->lrcfg_nameServiceURL, &QLineEdit::textEdited, [=](const QString& newNSURL) {
92 if (currentAccount_ && currentAccount_->protocol() == Account::Protocol::RING)
93 currentAccount_->setNameServiceURL(newNSURL);
94 });
Edric Milaret627500d2015-03-27 16:41:40 -040095}
96
97AccountDetails::~AccountDetails()
98{
99 delete ui;
100}
101
102void
Edric Milaret627500d2015-03-27 16:41:40 -0400103AccountDetails::setAccount(Account* currentAccount) {
104
Edric Milaret3e6aefe2015-06-05 16:07:26 -0400105 if (currentAccount_) {
Edric Milaretdda49b62016-02-05 14:27:38 -0500106 stopRingtone();
107 save();
Edric Milaret3e6aefe2015-06-05 16:07:26 -0400108 }
109
Edric Milaret627500d2015-03-27 16:41:40 -0400110 currentAccount_ = currentAccount;
111
Edric Milaretce0ea472016-04-12 10:16:56 -0400112 if (currentAccount_ == nullptr)
113 return;
114
Anthony Léonardaa90e1a2016-10-12 11:24:17 -0400115 if (currentAccount_->protocol() == Account::Protocol::RING) {
Anthony Léonard44338762016-11-15 11:22:27 -0500116 ui->usernameLabel->setText(tr("RingID"));
117 ui->lrcfg_username->setReadOnly(true);
Anthony Léonardaa90e1a2016-10-12 11:24:17 -0400118 if (currentAccount_->registeredName().isEmpty() ){ // If our user isn't registered on the blockhain
119 ui->lrcfg_registeredName->clear();
120 ui->lrcfg_registeredName->setReadOnly(false);
121 ui->registerButton->setText(tr("Register on blockchain"));
122 ui->registerButton->show();
123 ui->registerButton->setEnabled(true);
124 } else {
125 ui->lrcfg_registeredName->setText(currentAccount_->registeredName());
126 ui->lrcfg_registeredName->setReadOnly(true);
127 ui->registerButton->hide();
128 }
Anthony Léonard44338762016-11-15 11:22:27 -0500129 } else { // If currentAccount_ is of type SIP
130 ui->usernameLabel->setText(tr("Username"));
131 ui->lrcfg_username->setReadOnly(false);
Anthony Léonardaa90e1a2016-10-12 11:24:17 -0400132 }
Edric Milareted0b2802015-10-01 15:10:02 -0400133
Edric Milaret627500d2015-03-27 16:41:40 -0400134 codecModel_ = currentAccount->codecModel();
Edric Milarete5313852015-11-09 13:06:00 -0500135 ui->audioCodecView->setModel(codecModel_->audioCodecs());
136 ui->videoCodecView->setModel(codecModel_->videoCodecs());
Edric Milaret25236d92016-03-28 09:40:58 -0400137
Edric Milarete5313852015-11-09 13:06:00 -0500138 connect(ui->audioCodecView->selectionModel(), SIGNAL(selectionChanged(QItemSelection,QItemSelection)),
139 this, SLOT(audioCodecSelectionChanged(QItemSelection,QItemSelection)));
140 connect(ui->videoCodecView->selectionModel(), SIGNAL(selectionChanged(QItemSelection,QItemSelection)),
141 this, SLOT(videoCodecSelectionChanged(QItemSelection,QItemSelection)));
Edric Milaret627500d2015-03-27 16:41:40 -0400142
Edric Milaret3e6aefe2015-06-05 16:07:26 -0400143 ui->typeValueLabel->setText(currentAccount_->protocolModel()->
144 selectionModel()->currentIndex().data().value<QString>());
Edric Milaret627500d2015-03-27 16:41:40 -0400145
Edric Milaret3e6aefe2015-06-05 16:07:26 -0400146 ui->publishGroup->disconnect();
Edric Milaret627500d2015-03-27 16:41:40 -0400147
Edric Milaret3e6aefe2015-06-05 16:07:26 -0400148 if (currentAccount_->isPublishedSameAsLocal())
149 ui->puslishedSameAsLocalRadio->setChecked(true);
150 else
151 ui->customPublishedRadio->setChecked(true);
152
153 ui->publishGroup->setId(ui->puslishedSameAsLocalRadio, 1);
154 ui->publishGroup->setId(ui->customPublishedRadio, 0);
155 ui->lrcfg_publishedAddress->setEnabled(!currentAccount_->isPublishedSameAsLocal());
156 ui->lrcfg_publishedPort->setEnabled(!currentAccount_->isPublishedSameAsLocal());
157
Nicolas Jagere6384052016-03-10 13:13:24 -0500158 connect(ui->publishGroup,
159 static_cast<void(QButtonGroup::*)(int)>(&QButtonGroup::buttonClicked),
160 [=](int id) {
Edric Milaret3e6aefe2015-06-05 16:07:26 -0400161 currentAccount_->setPublishedSameAsLocal(static_cast<bool>(id));
162 });
163
164 switch (currentAccount_->DTMFType()) {
165 case DtmfType::OverRtp:
166 ui->rtpRadio->setChecked(true);
Edric Milaret627500d2015-03-27 16:41:40 -0400167 break;
Edric Milaret3e6aefe2015-06-05 16:07:26 -0400168 case DtmfType::OverSip:
169 ui->sipRadio->setChecked(true);
Edric Milaret627500d2015-03-27 16:41:40 -0400170 break;
171 }
172
Edric Milaret3e6aefe2015-06-05 16:07:26 -0400173 ui->dtmfGroup->disconnect();
174 ui->dtmfGroup->setId(ui->rtpRadio, DtmfType::OverRtp);
175 ui->dtmfGroup->setId(ui->sipRadio, DtmfType::OverSip);
Edric Milaret627500d2015-03-27 16:41:40 -0400176
Edric Milaret3e6aefe2015-06-05 16:07:26 -0400177 connect(ui->dtmfGroup, static_cast<void(QButtonGroup::*)(int)>(&QButtonGroup::buttonClicked),
Nicolas Jagere6384052016-03-10 13:13:24 -0500178 [=](int id){ currentAccount_->setDTMFType(static_cast<DtmfType>(id)); });
Edric Milaret3e6aefe2015-06-05 16:07:26 -0400179
180 if (currentAccount_->tlsCaListCertificate())
Edric Milaret4f0b02c2015-08-14 11:40:58 -0400181 ui->lrcfg_tlsCaListCertificate->setText(currentAccount_->tlsCaListCertificate()->path());
Edric Milaret3e6aefe2015-06-05 16:07:26 -0400182 if (currentAccount_->tlsCertificate())
Edric Milaret4f0b02c2015-08-14 11:40:58 -0400183 ui->lrcfg_tlsCertificate->setText(currentAccount_->tlsCertificate()->path());
184 if (not currentAccount_->tlsPrivateKey().isEmpty())
185 ui->lrcfg_tlsPrivateKeyCertificate->setText(currentAccount_->tlsPrivateKey());
Edric Milaret3e6aefe2015-06-05 16:07:26 -0400186
Edric Milaret36587362016-02-04 12:30:52 -0500187#ifdef Q_OS_WIN
Edric Milaret3e6aefe2015-06-05 16:07:26 -0400188 certMap_[ui->lrcfg_tlsCaListCertificate->objectName()] = &currentAccount_->setTlsCaListCertificate;
189 certMap_[ui->lrcfg_tlsCertificate->objectName()] = &currentAccount_->setTlsCertificate;
Edric Milaret4f0b02c2015-08-14 11:40:58 -0400190 certMap_[ui->lrcfg_tlsPrivateKeyCertificate->objectName()] = &currentAccount_->setTlsPrivateKey;
Edric Milaretb37aa1f2015-07-09 16:39:04 -0400191#endif
Edric Milaret3e6aefe2015-06-05 16:07:26 -0400192
193 ui->srtpEnabled->disconnect();
194 connect(ui->srtpEnabled, &QCheckBox::toggled, [=](bool checked) {
195 currentAccount_->setSrtpEnabled(checked);
Edric Milaret3e6aefe2015-06-05 16:07:26 -0400196 });
197
198 ui->srtpEnabled->setChecked(currentAccount_->isSrtpEnabled());
199
200 if (currentAccount_->cipherModel()->useDefault())
Nicolas Jagere6384052016-03-10 13:13:24 -0500201 ui->defaultCipherCheckBox->setChecked(true);
Edric Milaret3e6aefe2015-06-05 16:07:26 -0400202 else
Nicolas Jagere6384052016-03-10 13:13:24 -0500203 ui->defaultCipherCheckBox->setChecked(false);
Edric Milaret3e6aefe2015-06-05 16:07:26 -0400204
205 ui->cipherListView->setModel(currentAccount_->cipherModel());
Edric Milaretb1b00ce2016-02-03 14:10:05 -0500206
207 disconnect(ui->ringtonesBox);
208 ui->ringtonesBox->setModel(&RingtoneModel::instance());
209 ui->ringtonesBox->setCurrentIndex(RingtoneModel::instance().selectionModel(currentAccount_)->currentIndex().row());
210 connect(ui->ringtonesBox, SIGNAL(currentIndexChanged(int)), this, SLOT(ringtonesBoxCurrentIndexChanged(int)));
Nicolas Jagere6384052016-03-10 13:13:24 -0500211
212 auto accountProtocol = currentAccount_->protocol();
213 if (accountProtocol == Account::Protocol::RING) {
214 ui->medStreaEncry->setVisible(false);
215 ui->lrcfg_tlsEnabled->setVisible(false);
Anthony Léonard5107a692016-11-04 13:20:37 -0400216
217 ui->nameServiceURLLabel->show();
218 ui->lrcfg_nameServiceURL->show();
219 ui->lrcfg_nameServiceURL->setText(currentAccount_->nameServiceURL());
Nicolas Jagere6384052016-03-10 13:13:24 -0500220 } else if (accountProtocol == Account::Protocol::SIP) {
221 ui->medStreaEncry->setVisible(true);
222 ui->lrcfg_tlsEnabled->setVisible(true);
Anthony Léonard5107a692016-11-04 13:20:37 -0400223
224 ui->nameServiceURLLabel->hide();
225 ui->lrcfg_nameServiceURL->hide();
Nicolas Jagere6384052016-03-10 13:13:24 -0500226 }
227
228 if (ui->lrcfg_tlsEnabled->checkState() == Qt::Checked) {
229 ui->negoEncry_1->setVisible(true);
230 ui->negoEncry_2->setVisible(true);
231 ui->defaultCipherCheckBox->setVisible(currentAccount_->protocol() != Account::Protocol::RING);
232 } else {
233 ui->negoEncry_1->setVisible(false);
234 ui->negoEncry_2->setVisible(false);
235 ui->defaultCipherCheckBox->setVisible(false);
236 ui->cipherListView->setVisible(false);
237 }
238
239 if (ui->defaultCipherCheckBox->checkState() == Qt::Checked)
240 ui->cipherListView->setVisible(false);
241 else
242 ui->cipherListView->setVisible(true);
Edric Milaret57467842016-08-30 13:06:11 -0400243
244 ui->tableView->setModel((QAbstractItemModel*)currentAccount_->ringDeviceModel());
Edric Milaret627500d2015-03-27 16:41:40 -0400245}
246
247void
Edric Milarete5313852015-11-09 13:06:00 -0500248AccountDetails::on_upAudioButton_clicked() {
Edric Milaret627500d2015-03-27 16:41:40 -0400249 codecModel_->moveUp();
Edric Milaret627500d2015-03-27 16:41:40 -0400250}
251
252void
Edric Milarete5313852015-11-09 13:06:00 -0500253AccountDetails::on_downAudioButton_clicked() {
Edric Milaret627500d2015-03-27 16:41:40 -0400254 codecModel_->moveDown();
Edric Milaret627500d2015-03-27 16:41:40 -0400255}
256
257void
Edric Milarete5313852015-11-09 13:06:00 -0500258AccountDetails::on_upVideoButton_clicked() {
Edric Milaret627500d2015-03-27 16:41:40 -0400259 codecModel_->moveUp();
Edric Milaret627500d2015-03-27 16:41:40 -0400260}
261
262void
Edric Milarete5313852015-11-09 13:06:00 -0500263AccountDetails::on_downVideoButton_clicked() {
Edric Milaret627500d2015-03-27 16:41:40 -0400264 codecModel_->moveDown();
Edric Milaret627500d2015-03-27 16:41:40 -0400265}
266
267void
268AccountDetails::save() {
Edric Milaret2d03da42015-07-15 15:36:43 -0400269 codecModel_->performAction(CodecModel::EditAction::SAVE);
Edric Milaret627500d2015-03-27 16:41:40 -0400270}
271
272void
Edric Milarete5313852015-11-09 13:06:00 -0500273AccountDetails::onCertButtonClicked() {
Edric Milaret3e6aefe2015-06-05 16:07:26 -0400274 QString fileName = QFileDialog::getOpenFileName(this, tr("Choose File"),
Nicolas Jagere6384052016-03-10 13:13:24 -0500275 "",
276 tr("Files (*)"));
Edric Milaret3e6aefe2015-06-05 16:07:26 -0400277
278 auto sender = QObject::sender();
279
280 (currentAccount_->*certMap_[sender->objectName()])(fileName);
Edric Milaret9f6b5192016-02-02 15:14:27 -0500281 if (not fileName.isEmpty())
282 static_cast<QPushButton*>(sender)->setText(fileName);
Edric Milarete6538792015-05-08 11:51:01 -0400283}
Edric Milarete5313852015-11-09 13:06:00 -0500284
285void
286AccountDetails::audioCodecSelectionChanged(const QItemSelection& selected,
287 const QItemSelection& deselected) {
288 Q_UNUSED(deselected)
289 if (not codecModel_ || selected.empty())
290 return;
291 auto idx = codecModel_->audioCodecs()->mapToSource(selected.indexes().at(0));
292 codecModel_->selectionModel()->setCurrentIndex(idx, QItemSelectionModel::ClearAndSelect);
293}
294
295void
296AccountDetails::videoCodecSelectionChanged(const QItemSelection& selected,
297 const QItemSelection& deselected) {
298 Q_UNUSED(deselected)
299 if (not codecModel_ || selected.empty())
300 return;
301 auto idx = codecModel_->videoCodecs()->mapToSource(selected.indexes().at(0));
302 codecModel_->selectionModel()->setCurrentIndex(idx, QItemSelectionModel::ClearAndSelect);
303}
Edric Milaretb1b00ce2016-02-03 14:10:05 -0500304
305void
306AccountDetails::ringtonesBoxCurrentIndexChanged(int index)
307{
308 RingtoneModel::instance().selectionModel(currentAccount_)->setCurrentIndex(
309 RingtoneModel::instance().index(index, 0), QItemSelectionModel::ClearAndSelect);
310}
311
312void
313AccountDetails::on_playButton_clicked()
314{
315 RingtoneModel::instance().play(RingtoneModel::instance().index(
316 ui->ringtonesBox->currentIndex(), 0));
317}
Edric Milaretdda49b62016-02-05 14:27:38 -0500318
319void
320AccountDetails::stopRingtone() {
321 if (not currentAccount_)
322 return;
323 auto idx = RingtoneModel::instance().selectionModel(currentAccount_)->currentIndex();
324 if (RingtoneModel::instance().isPlaying())
325 RingtoneModel::instance().play(idx);
326}
Nicolas Jager74fe46f2016-02-29 14:55:09 -0500327
328QPushButton*
329AccountDetails::getDeleteAccountButton()
330{
331 return ui->deleteAccountButton;
332}
Edric Milaret57467842016-08-30 13:06:11 -0400333
334void
335AccountDetails::on_addDeviceButton_clicked()
336{
337 ui->devicesStackedWidget->setCurrentIndex(1);
338}
339
340void
341AccountDetails::on_cancelButton_clicked()
342{
343 ui->devicesStackedWidget->setCurrentIndex(0);
344}
345
346void
347AccountDetails::on_exportOnRingButton_clicked()
348{
349 if (ui->passwordArchiveEdit->text().isEmpty())
350 return;
351
352 connect(currentAccount_, SIGNAL(exportOnRingEnded(Account::ExportOnRingStatus,QString)), this, SLOT(exportOnRingEnded(Account::ExportOnRingStatus,QString)));
353 currentAccount_->exportOnRing(ui->passwordArchiveEdit->text());
354 ui->devicesStackedWidget->setCurrentIndex(2);
355 ui->pinLabel->setText(tr("Please wait while your PIN is generated."));
356}
357
358void
359AccountDetails::exportOnRingEnded(Account::ExportOnRingStatus state, const QString& pin) {
360
361 ui->devicesStackedWidget->setCurrentIndex(2);
362
363 ui->pinLabel->clear();
364
365 switch (state) {
366 case Account::ExportOnRingStatus::SUCCESS:
367 {
368 ui->pinLabel->setText(pin);
Anthony Léonard39374992016-10-21 13:39:55 -0400369 ui->pinLabel->setTextInteractionFlags(Qt::TextSelectableByMouse);
Edric Milaret57467842016-08-30 13:06:11 -0400370 break;
371 }
372 case Account::ExportOnRingStatus::NETWORK_ERROR:
373 {
374 ui->pinLabel->setText(tr("Network Error. Please try again later."));
375 break;
376 }
377 case Account::ExportOnRingStatus::WRONG_PASSWORD:
378 ui->pinLabel->setText(tr("Wrong password."));
379 break;
380 }
381}
382
383void
384AccountDetails::on_exportEndedOkButton_clicked()
385{
386 ui->devicesStackedWidget->setCurrentIndex(0);
387}
388
389void
390AccountDetails::on_cancelAddButton_clicked()
391{
392 ui->devicesStackedWidget->setCurrentIndex(0);
393}
Anthony Léonard59db8ce2016-10-19 10:54:11 -0400394
395void AccountDetails::on_devicesStackedWidget_currentChanged(int pageNum)
396{
397 // We clear the password textEdit each time we leave its page
398 if (pageNum != ui->devicesStackedWidget->indexOf(ui->passwordAskingPage))
399 ui->passwordArchiveEdit->clear();
400}
Anthony Léonardaa90e1a2016-10-12 11:24:17 -0400401
402void AccountDetails::on_registerButton_clicked()
403{
404 ui->registerButton->setEnabled(false);
405 ui->registerButton->setText(tr("Registering... It may take some time"));
406 bool regSuccess = currentAccount_->registerName(ui->lrcfg_password->text(), ui->lrcfg_registeredName->text());
407 if (!regSuccess) {
408 QMessageBox::warning(this, "Username not registered", "Username registration failed, try again later.");
409 ui->registerButton->setEnabled(true);
410 ui->registerButton->setText(tr("Register on blockchain"));
411 return;
412 }
413
414 connect(currentAccount_, SIGNAL(nameRegistrationEnded(NameDirectory::RegisterNameStatus,QString)),
415 this, SLOT(handle_nameRegistrationEnded(NameDirectory::RegisterNameStatus,QString)));
416}
417
418
419void AccountDetails::handle_nameRegistrationEnded(NameDirectory::RegisterNameStatus status, const QString& name)
420{
421 disconnect(currentAccount_, SIGNAL(nameRegistrationEnded(NameDirectory::RegisterNameStatus,QString)),
422 this, SLOT(handle_nameRegistrationEnded(NameDirectory::RegisterNameStatus,QString)));
423 switch(status) {
424 case NameDirectory::RegisterNameStatus::ALREADY_TAKEN:
425 QMessageBox::warning(this, "Username not registered", "This username is already taken, try another one.");
426 ui->registerButton->setEnabled(true);
427 ui->registerButton->setText(tr("Register on blockchain"));
428 break;
429 case NameDirectory::RegisterNameStatus::INVALID_NAME:
430 QMessageBox::warning(this, "Username not registered", "This username is invalid, try another one.");
431 ui->registerButton->setEnabled(true);
432 ui->registerButton->setText(tr("Register on blockchain"));
433 break;
434 case NameDirectory::RegisterNameStatus::WRONG_PASSWORD:
435 QMessageBox::warning(this, "Username not registered", "Wrong password, try again.");
436 ui->registerButton->setEnabled(true);
437 ui->registerButton->setText(tr("Register on blockchain"));
438 break;
439 case NameDirectory::RegisterNameStatus::NETWORK_ERROR:
440 QMessageBox::warning(this, "Username not registered", "Network error. Try again later.");
441 ui->registerButton->setEnabled(true);
442 ui->registerButton->setText(tr("Register on blockchain"));
443 break;
444 case NameDirectory::RegisterNameStatus::SUCCESS:
445 ui->lrcfg_registeredName->setReadOnly(true);
446 ui->registerButton->hide();
447 QMessageBox::information(this, "Username registered", name + " is registered, you can now share this name.");
448 break;
449 }
450
451}