From 4e7fa957510dd228e0ce83fe2af30009af26233f Mon Sep 17 00:00:00 2001 From: OpenSauce04 Date: Wed, 3 Apr 2024 21:49:28 +0100 Subject: [PATCH] Gutted Web tab code for Web Service and Telemetry options --- .../configuration/configure_dialog.cpp | 1 - src/lime_qt/configuration/configure_web.cpp | 129 -------------- src/lime_qt/configuration/configure_web.h | 1 - src/lime_qt/configuration/configure_web.ui | 161 ------------------ 4 files changed, 292 deletions(-) diff --git a/src/lime_qt/configuration/configure_dialog.cpp b/src/lime_qt/configuration/configure_dialog.cpp index 4e967ebb0..46e7c9bc4 100644 --- a/src/lime_qt/configuration/configure_dialog.cpp +++ b/src/lime_qt/configuration/configure_dialog.cpp @@ -57,7 +57,6 @@ ConfigureDialog::ConfigureDialog(QWidget* parent, HotkeyRegistry& registry_, Cor ui->tabWidget->addTab(ui_tab.get(), tr("UI")); hotkeys_tab->Populate(registry); - web_tab->SetWebServiceConfigEnabled(enable_web_config); PopulateSelectionList(); diff --git a/src/lime_qt/configuration/configure_web.cpp b/src/lime_qt/configuration/configure_web.cpp index da4796382..3413eaa23 100644 --- a/src/lime_qt/configuration/configure_web.cpp +++ b/src/lime_qt/configuration/configure_web.cpp @@ -11,38 +11,9 @@ #include "network/network_settings.h" #include "ui_configure_web.h" -static constexpr char token_delimiter{':'}; - -static std::string GenerateDisplayToken(const std::string& username, const std::string& token) { - if (username.empty() || token.empty()) { - return {}; - } - - const std::string unencoded_display_token{username + token_delimiter + token}; - QByteArray b{unencoded_display_token.c_str()}; - QByteArray b64 = b.toBase64(); - return b64.toStdString(); -} - -static std::string UsernameFromDisplayToken(const std::string& display_token) { - const std::string unencoded_display_token{ - QByteArray::fromBase64(display_token.c_str()).toStdString()}; - return unencoded_display_token.substr(0, unencoded_display_token.find(token_delimiter)); -} - -static std::string TokenFromDisplayToken(const std::string& display_token) { - const std::string unencoded_display_token{ - QByteArray::fromBase64(display_token.c_str()).toStdString()}; - return unencoded_display_token.substr(unencoded_display_token.find(token_delimiter) + 1); -} - ConfigureWeb::ConfigureWeb(QWidget* parent) : QWidget(parent), ui(std::make_unique()) { ui->setupUi(this); - connect(ui->button_regenerate_telemetry_id, &QPushButton::clicked, this, - &ConfigureWeb::RefreshTelemetryID); - connect(ui->button_verify_login, &QPushButton::clicked, this, &ConfigureWeb::VerifyLogin); - connect(&verify_watcher, &QFutureWatcher::finished, this, &ConfigureWeb::OnLoginVerified); #ifndef USE_DISCORD_PRESENCE ui->discord_group->setVisible(false); @@ -53,113 +24,13 @@ ConfigureWeb::ConfigureWeb(QWidget* parent) ConfigureWeb::~ConfigureWeb() = default; void ConfigureWeb::SetConfiguration() { - ui->web_credentials_disclaimer->setWordWrap(true); - ui->telemetry_learn_more->setOpenExternalLinks(true); - ui->telemetry_learn_more->setText(tr("Learn more")); - - ui->web_signup_link->setOpenExternalLinks(true); - ui->web_signup_link->setText( - tr("Sign up")); - ui->web_token_info_link->setOpenExternalLinks(true); - ui->web_token_info_link->setText( - tr("What is my token?")); - - ui->toggle_telemetry->setChecked(NetSettings::values.enable_telemetry); - - if (NetSettings::values.citra_username.empty()) { - ui->username->setText(tr("Unspecified")); - } else { - ui->username->setText(QString::fromStdString(NetSettings::values.citra_username)); - } - - ui->edit_token->setText(QString::fromStdString( - GenerateDisplayToken(NetSettings::values.citra_username, NetSettings::values.citra_token))); - - // Connect after setting the values, to avoid calling OnLoginChanged now - connect(ui->edit_token, &QLineEdit::textChanged, this, &ConfigureWeb::OnLoginChanged); - ui->label_telemetry_id->setText( - tr("Telemetry ID: 0x%1").arg(QString::number(Core::GetTelemetryId(), 16).toUpper())); - user_verified = true; - ui->toggle_discordrpc->setChecked(UISettings::values.enable_discord_presence.GetValue()); } void ConfigureWeb::ApplyConfiguration() { - NetSettings::values.enable_telemetry = ui->toggle_telemetry->isChecked(); UISettings::values.enable_discord_presence = ui->toggle_discordrpc->isChecked(); - if (user_verified) { - NetSettings::values.citra_username = - UsernameFromDisplayToken(ui->edit_token->text().toStdString()); - NetSettings::values.citra_token = - TokenFromDisplayToken(ui->edit_token->text().toStdString()); - } else { - QMessageBox::warning( - this, tr("Token not verified"), - tr("Token was not verified. The change to your token has not been saved.")); - } -} - -void ConfigureWeb::RefreshTelemetryID() { - const u64 new_telemetry_id{Core::RegenerateTelemetryId()}; - ui->label_telemetry_id->setText( - tr("Telemetry ID: 0x%1").arg(QString::number(new_telemetry_id, 16).toUpper())); -} - -void ConfigureWeb::OnLoginChanged() { - if (ui->edit_token->text().isEmpty()) { - user_verified = true; - - const QPixmap pixmap = QIcon::fromTheme(QStringLiteral("checked")).pixmap(16); - ui->label_token_verified->setPixmap(pixmap); - } else { - user_verified = false; - - const QPixmap pixmap = QIcon::fromTheme(QStringLiteral("failed")).pixmap(16); - ui->label_token_verified->setPixmap(pixmap); - } -} - -void ConfigureWeb::VerifyLogin() { - ui->button_verify_login->setDisabled(true); - ui->button_verify_login->setText(tr("Verifying...")); - verify_watcher.setFuture(QtConcurrent::run( - [username = UsernameFromDisplayToken(ui->edit_token->text().toStdString()), - token = TokenFromDisplayToken(ui->edit_token->text().toStdString())] { - return Core::VerifyLogin(username, token); - })); -} - -void ConfigureWeb::OnLoginVerified() { - ui->button_verify_login->setEnabled(true); - ui->button_verify_login->setText(tr("Verify")); - if (verify_watcher.result()) { - user_verified = true; - - const QPixmap pixmap = QIcon::fromTheme(QStringLiteral("checked")).pixmap(16); - ui->label_token_verified->setPixmap(pixmap); - ui->username->setText( - QString::fromStdString(UsernameFromDisplayToken(ui->edit_token->text().toStdString()))); - } else { - const QPixmap pixmap = QIcon::fromTheme(QStringLiteral("failed")).pixmap(16); - ui->label_token_verified->setPixmap(pixmap); - ui->username->setText(tr("Unspecified")); - QMessageBox::critical(this, tr("Verification failed"), - tr("Verification failed. Check that you have entered your token " - "correctly, and that your internet connection is working.")); - } } void ConfigureWeb::RetranslateUI() { ui->retranslateUi(this); } - -void ConfigureWeb::SetWebServiceConfigEnabled(bool enabled) { - ui->label_disable_info->setVisible(!enabled); - ui->groupBoxWebConfig->setEnabled(enabled); -} diff --git a/src/lime_qt/configuration/configure_web.h b/src/lime_qt/configuration/configure_web.h index a9b2566f8..46f29bd2c 100644 --- a/src/lime_qt/configuration/configure_web.h +++ b/src/lime_qt/configuration/configure_web.h @@ -22,7 +22,6 @@ public: void ApplyConfiguration(); void RetranslateUI(); void SetConfiguration(); - void SetWebServiceConfigEnabled(bool enabled); private: void RefreshTelemetryID(); diff --git a/src/lime_qt/configuration/configure_web.ui b/src/lime_qt/configuration/configure_web.ui index fdae590bf..a68936c59 100644 --- a/src/lime_qt/configuration/configure_web.ui +++ b/src/lime_qt/configuration/configure_web.ui @@ -14,163 +14,6 @@ Form - - - - - - Lime3DS Web Service - - - - - - Currently not supported by Lime. By providing your username and token, you agree to allow Citra to collect additional usage data, which may include user identifying information. - - - - - - - - - - 0 - 0 - - - - Qt::RightToLeft - - - Verify - - - - - - - Sign up - - - - - - - - - - Token: - - - - - - - - - - Username: - - - - - - - 80 - - - QLineEdit::Password - - - - - - - What is my token? - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - - - - - - Web Service configuration can only be changed when a public room isn't being hosted. - - - true - - - - - - - Telemetry - - - - - - Share anonymous usage data with the Lime3DS team - - - - - - - Learn more - - - - - - - - - Telemetry ID: - - - - - - - - 0 - 0 - - - - Qt::RightToLeft - - - Regenerate - - - - - - - - - - @@ -203,10 +46,6 @@ - edit_token - button_verify_login - toggle_telemetry - button_regenerate_telemetry_id toggle_discordrpc