blob: 9000d64e2c2ca91a46c952a8d87acb2540b44e39 [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());
Olivier SOLDANO5d4a1ff2017-05-08 13:12:47 -0400245 ui->bannedContactsWidget->setAccount(currentAccount_);
Edric Milaret627500d2015-03-27 16:41:40 -0400246}
247
248void
Edric Milarete5313852015-11-09 13:06:00 -0500249AccountDetails::on_upAudioButton_clicked() {
Edric Milaret627500d2015-03-27 16:41:40 -0400250 codecModel_->moveUp();
Edric Milaret627500d2015-03-27 16:41:40 -0400251}
252
253void
Edric Milarete5313852015-11-09 13:06:00 -0500254AccountDetails::on_downAudioButton_clicked() {
Edric Milaret627500d2015-03-27 16:41:40 -0400255 codecModel_->moveDown();
Edric Milaret627500d2015-03-27 16:41:40 -0400256}
257
258void
Edric Milarete5313852015-11-09 13:06:00 -0500259AccountDetails::on_upVideoButton_clicked() {
Edric Milaret627500d2015-03-27 16:41:40 -0400260 codecModel_->moveUp();
Edric Milaret627500d2015-03-27 16:41:40 -0400261}
262
263void
Edric Milarete5313852015-11-09 13:06:00 -0500264AccountDetails::on_downVideoButton_clicked() {
Edric Milaret627500d2015-03-27 16:41:40 -0400265 codecModel_->moveDown();
Edric Milaret627500d2015-03-27 16:41:40 -0400266}
267
268void
269AccountDetails::save() {
Edric Milaret2d03da42015-07-15 15:36:43 -0400270 codecModel_->performAction(CodecModel::EditAction::SAVE);
Edric Milaret627500d2015-03-27 16:41:40 -0400271}
272
273void
Edric Milarete5313852015-11-09 13:06:00 -0500274AccountDetails::onCertButtonClicked() {
Edric Milaret3e6aefe2015-06-05 16:07:26 -0400275 QString fileName = QFileDialog::getOpenFileName(this, tr("Choose File"),
Nicolas Jagere6384052016-03-10 13:13:24 -0500276 "",
277 tr("Files (*)"));
Edric Milaret3e6aefe2015-06-05 16:07:26 -0400278
279 auto sender = QObject::sender();
280
281 (currentAccount_->*certMap_[sender->objectName()])(fileName);
Edric Milaret9f6b5192016-02-02 15:14:27 -0500282 if (not fileName.isEmpty())
283 static_cast<QPushButton*>(sender)->setText(fileName);
Edric Milarete6538792015-05-08 11:51:01 -0400284}
Edric Milarete5313852015-11-09 13:06:00 -0500285
286void
287AccountDetails::audioCodecSelectionChanged(const QItemSelection& selected,
288 const QItemSelection& deselected) {
289 Q_UNUSED(deselected)
290 if (not codecModel_ || selected.empty())
291 return;
292 auto idx = codecModel_->audioCodecs()->mapToSource(selected.indexes().at(0));
293 codecModel_->selectionModel()->setCurrentIndex(idx, QItemSelectionModel::ClearAndSelect);
294}
295
296void
297AccountDetails::videoCodecSelectionChanged(const QItemSelection& selected,
298 const QItemSelection& deselected) {
299 Q_UNUSED(deselected)
300 if (not codecModel_ || selected.empty())
301 return;
302 auto idx = codecModel_->videoCodecs()->mapToSource(selected.indexes().at(0));
303 codecModel_->selectionModel()->setCurrentIndex(idx, QItemSelectionModel::ClearAndSelect);
304}
Edric Milaretb1b00ce2016-02-03 14:10:05 -0500305
306void
307AccountDetails::ringtonesBoxCurrentIndexChanged(int index)
308{
309 RingtoneModel::instance().selectionModel(currentAccount_)->setCurrentIndex(
310 RingtoneModel::instance().index(index, 0), QItemSelectionModel::ClearAndSelect);
311}
312
313void
314AccountDetails::on_playButton_clicked()
315{
316 RingtoneModel::instance().play(RingtoneModel::instance().index(
317 ui->ringtonesBox->currentIndex(), 0));
318}
Edric Milaretdda49b62016-02-05 14:27:38 -0500319
320void
321AccountDetails::stopRingtone() {
322 if (not currentAccount_)
323 return;
324 auto idx = RingtoneModel::instance().selectionModel(currentAccount_)->currentIndex();
325 if (RingtoneModel::instance().isPlaying())
326 RingtoneModel::instance().play(idx);
327}
Nicolas Jager74fe46f2016-02-29 14:55:09 -0500328
Edric Milaret57467842016-08-30 13:06:11 -0400329void
330AccountDetails::on_addDeviceButton_clicked()
331{
332 ui->devicesStackedWidget->setCurrentIndex(1);
333}
334
335void
336AccountDetails::on_cancelButton_clicked()
337{
338 ui->devicesStackedWidget->setCurrentIndex(0);
339}
340
341void
342AccountDetails::on_exportOnRingButton_clicked()
343{
344 if (ui->passwordArchiveEdit->text().isEmpty())
345 return;
346
347 connect(currentAccount_, SIGNAL(exportOnRingEnded(Account::ExportOnRingStatus,QString)), this, SLOT(exportOnRingEnded(Account::ExportOnRingStatus,QString)));
348 currentAccount_->exportOnRing(ui->passwordArchiveEdit->text());
349 ui->devicesStackedWidget->setCurrentIndex(2);
350 ui->pinLabel->setText(tr("Please wait while your PIN is generated."));
351}
352
353void
354AccountDetails::exportOnRingEnded(Account::ExportOnRingStatus state, const QString& pin) {
355
356 ui->devicesStackedWidget->setCurrentIndex(2);
357
358 ui->pinLabel->clear();
359
360 switch (state) {
361 case Account::ExportOnRingStatus::SUCCESS:
362 {
363 ui->pinLabel->setText(pin);
Anthony Léonard39374992016-10-21 13:39:55 -0400364 ui->pinLabel->setTextInteractionFlags(Qt::TextSelectableByMouse);
Edric Milaret57467842016-08-30 13:06:11 -0400365 break;
366 }
367 case Account::ExportOnRingStatus::NETWORK_ERROR:
368 {
369 ui->pinLabel->setText(tr("Network Error. Please try again later."));
370 break;
371 }
372 case Account::ExportOnRingStatus::WRONG_PASSWORD:
373 ui->pinLabel->setText(tr("Wrong password."));
374 break;
375 }
376}
377
378void
379AccountDetails::on_exportEndedOkButton_clicked()
380{
381 ui->devicesStackedWidget->setCurrentIndex(0);
382}
383
384void
385AccountDetails::on_cancelAddButton_clicked()
386{
387 ui->devicesStackedWidget->setCurrentIndex(0);
388}
Anthony Léonard59db8ce2016-10-19 10:54:11 -0400389
390void AccountDetails::on_devicesStackedWidget_currentChanged(int pageNum)
391{
392 // We clear the password textEdit each time we leave its page
393 if (pageNum != ui->devicesStackedWidget->indexOf(ui->passwordAskingPage))
394 ui->passwordArchiveEdit->clear();
395}
Anthony Léonardaa90e1a2016-10-12 11:24:17 -0400396
397void AccountDetails::on_registerButton_clicked()
398{
399 ui->registerButton->setEnabled(false);
400 ui->registerButton->setText(tr("Registering... It may take some time"));
401 bool regSuccess = currentAccount_->registerName(ui->lrcfg_password->text(), ui->lrcfg_registeredName->text());
402 if (!regSuccess) {
403 QMessageBox::warning(this, "Username not registered", "Username registration failed, try again later.");
404 ui->registerButton->setEnabled(true);
405 ui->registerButton->setText(tr("Register on blockchain"));
406 return;
407 }
408
409 connect(currentAccount_, SIGNAL(nameRegistrationEnded(NameDirectory::RegisterNameStatus,QString)),
410 this, SLOT(handle_nameRegistrationEnded(NameDirectory::RegisterNameStatus,QString)));
411}
412
413
414void AccountDetails::handle_nameRegistrationEnded(NameDirectory::RegisterNameStatus status, const QString& name)
415{
416 disconnect(currentAccount_, SIGNAL(nameRegistrationEnded(NameDirectory::RegisterNameStatus,QString)),
417 this, SLOT(handle_nameRegistrationEnded(NameDirectory::RegisterNameStatus,QString)));
418 switch(status) {
419 case NameDirectory::RegisterNameStatus::ALREADY_TAKEN:
420 QMessageBox::warning(this, "Username not registered", "This username is already taken, try another one.");
421 ui->registerButton->setEnabled(true);
422 ui->registerButton->setText(tr("Register on blockchain"));
423 break;
424 case NameDirectory::RegisterNameStatus::INVALID_NAME:
425 QMessageBox::warning(this, "Username not registered", "This username is invalid, try another one.");
426 ui->registerButton->setEnabled(true);
427 ui->registerButton->setText(tr("Register on blockchain"));
428 break;
429 case NameDirectory::RegisterNameStatus::WRONG_PASSWORD:
430 QMessageBox::warning(this, "Username not registered", "Wrong password, try again.");
431 ui->registerButton->setEnabled(true);
432 ui->registerButton->setText(tr("Register on blockchain"));
433 break;
434 case NameDirectory::RegisterNameStatus::NETWORK_ERROR:
435 QMessageBox::warning(this, "Username not registered", "Network error. Try again later.");
436 ui->registerButton->setEnabled(true);
437 ui->registerButton->setText(tr("Register on blockchain"));
438 break;
439 case NameDirectory::RegisterNameStatus::SUCCESS:
440 ui->lrcfg_registeredName->setReadOnly(true);
441 ui->registerButton->hide();
442 QMessageBox::information(this, "Username registered", name + " is registered, you can now share this name.");
443 break;
444 }
445
446}