mirror of
				https://github.com/PabloMK7/citra.git
				synced 2025-10-31 05:40:04 +00:00 
			
		
		
		
	Move webservice settings to own file
This commit is contained in:
		
							parent
							
								
									88a4759702
								
							
						
					
					
						commit
						fa0cb52a5d
					
				
					 14 changed files with 104 additions and 76 deletions
				
			
		|  | @ -15,6 +15,7 @@ | |||
| #include "input_common/main.h" | ||||
| #include "input_common/udp/client.h" | ||||
| #include "network/network.h" | ||||
| #include "network/network_settings.h" | ||||
| 
 | ||||
| Config::Config() { | ||||
|     // TODO: Don't hardcode the path; let the frontend decide where to put the config files.
 | ||||
|  | @ -702,15 +703,15 @@ void Config::ReadUpdaterValues() { | |||
| void Config::ReadWebServiceValues() { | ||||
|     qt_config->beginGroup(QStringLiteral("WebService")); | ||||
| 
 | ||||
|     Settings::values.enable_telemetry = | ||||
|     NetSettings::values.enable_telemetry = | ||||
|         ReadSetting(QStringLiteral("enable_telemetry"), true).toBool(); | ||||
|     Settings::values.web_api_url = | ||||
|     NetSettings::values.web_api_url = | ||||
|         ReadSetting(QStringLiteral("web_api_url"), QStringLiteral("https://api.citra-emu.org")) | ||||
|             .toString() | ||||
|             .toStdString(); | ||||
|     Settings::values.citra_username = | ||||
|     NetSettings::values.citra_username = | ||||
|         ReadSetting(QStringLiteral("citra_username")).toString().toStdString(); | ||||
|     Settings::values.citra_token = | ||||
|     NetSettings::values.citra_token = | ||||
|         ReadSetting(QStringLiteral("citra_token")).toString().toStdString(); | ||||
| 
 | ||||
|     qt_config->endGroup(); | ||||
|  | @ -1160,14 +1161,14 @@ void Config::SaveUpdaterValues() { | |||
| void Config::SaveWebServiceValues() { | ||||
|     qt_config->beginGroup(QStringLiteral("WebService")); | ||||
| 
 | ||||
|     WriteSetting(QStringLiteral("enable_telemetry"), Settings::values.enable_telemetry, true); | ||||
|     WriteSetting(QStringLiteral("enable_telemetry"), NetSettings::values.enable_telemetry, true); | ||||
|     WriteSetting(QStringLiteral("web_api_url"), | ||||
|                  QString::fromStdString(Settings::values.web_api_url), | ||||
|                  QString::fromStdString(NetSettings::values.web_api_url), | ||||
|                  QStringLiteral("https://api.citra-emu.org")); | ||||
|     WriteSetting(QStringLiteral("citra_username"), | ||||
|                  QString::fromStdString(Settings::values.citra_username)); | ||||
|                  QString::fromStdString(NetSettings::values.citra_username)); | ||||
|     WriteSetting(QStringLiteral("citra_token"), | ||||
|                  QString::fromStdString(Settings::values.citra_token)); | ||||
|                  QString::fromStdString(NetSettings::values.citra_token)); | ||||
| 
 | ||||
|     qt_config->endGroup(); | ||||
| } | ||||
|  |  | |||
|  | @ -7,8 +7,8 @@ | |||
| #include <QtConcurrent/QtConcurrentRun> | ||||
| #include "citra_qt/configuration/configure_web.h" | ||||
| #include "citra_qt/uisettings.h" | ||||
| #include "core/settings.h" | ||||
| #include "core/telemetry_session.h" | ||||
| #include "network/network_settings.h" | ||||
| #include "ui_configure_web.h" | ||||
| 
 | ||||
| static constexpr char token_delimiter{':'}; | ||||
|  | @ -70,16 +70,16 @@ void ConfigureWeb::SetConfiguration() { | |||
|         tr("<a href='https://citra-emu.org/wiki/citra-web-service/'><span style=\"text-decoration: " | ||||
|            "underline; color:#039be5;\">What is my token?</span></a>")); | ||||
| 
 | ||||
|     ui->toggle_telemetry->setChecked(Settings::values.enable_telemetry); | ||||
|     ui->toggle_telemetry->setChecked(NetSettings::values.enable_telemetry); | ||||
| 
 | ||||
|     if (Settings::values.citra_username.empty()) { | ||||
|     if (NetSettings::values.citra_username.empty()) { | ||||
|         ui->username->setText(tr("Unspecified")); | ||||
|     } else { | ||||
|         ui->username->setText(QString::fromStdString(Settings::values.citra_username)); | ||||
|         ui->username->setText(QString::fromStdString(NetSettings::values.citra_username)); | ||||
|     } | ||||
| 
 | ||||
|     ui->edit_token->setText(QString::fromStdString( | ||||
|         GenerateDisplayToken(Settings::values.citra_username, Settings::values.citra_token))); | ||||
|         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); | ||||
|  | @ -91,12 +91,13 @@ void ConfigureWeb::SetConfiguration() { | |||
| } | ||||
| 
 | ||||
| void ConfigureWeb::ApplyConfiguration() { | ||||
|     Settings::values.enable_telemetry = ui->toggle_telemetry->isChecked(); | ||||
|     NetSettings::values.enable_telemetry = ui->toggle_telemetry->isChecked(); | ||||
|     UISettings::values.enable_discord_presence = ui->toggle_discordrpc->isChecked(); | ||||
|     if (user_verified) { | ||||
|         Settings::values.citra_username = | ||||
|         NetSettings::values.citra_username = | ||||
|             UsernameFromDisplayToken(ui->edit_token->text().toStdString()); | ||||
|         Settings::values.citra_token = TokenFromDisplayToken(ui->edit_token->text().toStdString()); | ||||
|         NetSettings::values.citra_token = | ||||
|             TokenFromDisplayToken(ui->edit_token->text().toStdString()); | ||||
|     } else { | ||||
|         QMessageBox::warning( | ||||
|             this, tr("Token not verified"), | ||||
|  |  | |||
|  | @ -85,6 +85,7 @@ | |||
| #include "core/savestate.h" | ||||
| #include "core/settings.h" | ||||
| #include "game_list_p.h" | ||||
| #include "network/network_settings.h" | ||||
| #include "ui_main.h" | ||||
| #include "video_core/renderer_base.h" | ||||
| #include "video_core/video_core.h" | ||||
|  | @ -130,7 +131,7 @@ void GMainWindow::ShowTelemetryCallout() { | |||
|            "data is collected</a> to help improve Citra. " | ||||
|            "<br/><br/>Would you like to share your usage data with us?"); | ||||
|     if (QMessageBox::question(this, tr("Telemetry"), telemetry_message) != QMessageBox::Yes) { | ||||
|         Settings::values.enable_telemetry = false; | ||||
|         NetSettings::values.enable_telemetry = false; | ||||
|         Settings::Apply(); | ||||
|     } | ||||
| } | ||||
|  | @ -1623,7 +1624,7 @@ void GMainWindow::OnLoadComplete() { | |||
| } | ||||
| 
 | ||||
| void GMainWindow::OnMenuReportCompatibility() { | ||||
|     if (!Settings::values.citra_token.empty() && !Settings::values.citra_username.empty()) { | ||||
|     if (!NetSettings::values.citra_token.empty() && !NetSettings::values.citra_username.empty()) { | ||||
|         CompatDB compatdb{this}; | ||||
|         compatdb.exec(); | ||||
|     } else { | ||||
|  |  | |||
|  | @ -16,8 +16,8 @@ | |||
| #include "citra_qt/multiplayer/validation.h" | ||||
| #include "citra_qt/uisettings.h" | ||||
| #include "core/hle/service/cfg/cfg.h" | ||||
| #include "core/settings.h" | ||||
| #include "network/network.h" | ||||
| #include "network/network_settings.h" | ||||
| #include "ui_direct_connect.h" | ||||
| 
 | ||||
| enum class ConnectionType : u8 { TraversalServer, IP }; | ||||
|  | @ -34,9 +34,9 @@ DirectConnectWindow::DirectConnectWindow(QWidget* parent) | |||
| 
 | ||||
|     ui->nickname->setValidator(validation.GetNickname()); | ||||
|     ui->nickname->setText(UISettings::values.nickname); | ||||
|     if (ui->nickname->text().isEmpty() && !Settings::values.citra_username.empty()) { | ||||
|     if (ui->nickname->text().isEmpty() && !NetSettings::values.citra_username.empty()) { | ||||
|         // Use Citra Web Service user name as nickname by default
 | ||||
|         ui->nickname->setText(QString::fromStdString(Settings::values.citra_username)); | ||||
|         ui->nickname->setText(QString::fromStdString(NetSettings::values.citra_username)); | ||||
|     } | ||||
|     ui->ip->setValidator(validation.GetIP()); | ||||
|     ui->ip->setText(UISettings::values.ip); | ||||
|  | @ -92,7 +92,6 @@ void DirectConnectWindow::Connect() { | |||
|     UISettings::values.port = (ui->port->isModified() && !ui->port->text().isEmpty()) | ||||
|                                   ? ui->port->text() | ||||
|                                   : UISettings::values.port; | ||||
|     Settings::Apply(); | ||||
| 
 | ||||
|     // attempt to connect in a different thread
 | ||||
|     QFuture<void> f = QtConcurrent::run([&] { | ||||
|  |  | |||
|  | @ -21,7 +21,7 @@ | |||
| #include "common/logging/log.h" | ||||
| #include "core/announce_multiplayer_session.h" | ||||
| #include "core/hle/service/cfg/cfg.h" | ||||
| #include "core/settings.h" | ||||
| #include "network/network_settings.h" | ||||
| #include "ui_host_room.h" | ||||
| #ifdef ENABLE_WEB_SERVICE | ||||
| #include "web_service/verify_user_jwt.h" | ||||
|  | @ -53,9 +53,9 @@ HostRoomWindow::HostRoomWindow(QWidget* parent, QStandardItemModel* list, | |||
| 
 | ||||
|     // Restore the settings:
 | ||||
|     ui->username->setText(UISettings::values.room_nickname); | ||||
|     if (ui->username->text().isEmpty() && !Settings::values.citra_username.empty()) { | ||||
|     if (ui->username->text().isEmpty() && !NetSettings::values.citra_username.empty()) { | ||||
|         // Use Citra Web Service user name as nickname by default
 | ||||
|         ui->username->setText(QString::fromStdString(Settings::values.citra_username)); | ||||
|         ui->username->setText(QString::fromStdString(NetSettings::values.citra_username)); | ||||
|     } | ||||
|     ui->room_name->setText(UISettings::values.room_name); | ||||
|     ui->port->setText(UISettings::values.room_port); | ||||
|  | @ -92,7 +92,8 @@ std::unique_ptr<Network::VerifyUser::Backend> HostRoomWindow::CreateVerifyBacken | |||
|     std::unique_ptr<Network::VerifyUser::Backend> verify_backend; | ||||
|     if (use_validation) { | ||||
| #ifdef ENABLE_WEB_SERVICE | ||||
|         verify_backend = std::make_unique<WebService::VerifyUserJWT>(Settings::values.web_api_url); | ||||
|         verify_backend = | ||||
|             std::make_unique<WebService::VerifyUserJWT>(NetSettings::values.web_api_url); | ||||
| #else | ||||
|         verify_backend = std::make_unique<Network::VerifyUser::NullBackend>(); | ||||
| #endif | ||||
|  | @ -144,7 +145,7 @@ void HostRoomWindow::Host() { | |||
|             bool created = room->Create(ui->room_name->text().toStdString(), | ||||
|                                         ui->room_description->toPlainText().toStdString(), "", port, | ||||
|                                         password, ui->max_player->value(), | ||||
|                                         Settings::values.citra_username, game_name.toStdString(), | ||||
|                                         NetSettings::values.citra_username, game_name.toStdString(), | ||||
|                                         game_id, CreateVerifyBackend(is_public), ban_list); | ||||
|             if (!created) { | ||||
|                 NetworkMessage::ErrorManager::ShowError( | ||||
|  | @ -182,8 +183,9 @@ void HostRoomWindow::Host() { | |||
|         std::string token; | ||||
| #ifdef ENABLE_WEB_SERVICE | ||||
|         if (is_public) { | ||||
|             WebService::Client client(Settings::values.web_api_url, Settings::values.citra_username, | ||||
|                                       Settings::values.citra_token); | ||||
|             WebService::Client client(NetSettings::values.web_api_url, | ||||
|                                       NetSettings::values.citra_username, | ||||
|                                       NetSettings::values.citra_token); | ||||
|             if (auto room = Network::GetRoom().lock()) { | ||||
|                 token = client.GetExternalJWT(room->GetVerifyUID()).returned_data; | ||||
|             } | ||||
|  | @ -210,7 +212,6 @@ void HostRoomWindow::Host() { | |||
|                                            ? ui->port->text() | ||||
|                                            : QString::number(Network::DefaultRoomPort); | ||||
|         UISettings::values.room_description = ui->room_description->toPlainText(); | ||||
|         Settings::Apply(); | ||||
|         ui->host->setEnabled(true); | ||||
|         close(); | ||||
|     } | ||||
|  |  | |||
|  | @ -16,8 +16,8 @@ | |||
| #include "citra_qt/uisettings.h" | ||||
| #include "common/logging/log.h" | ||||
| #include "core/hle/service/cfg/cfg.h" | ||||
| #include "core/settings.h" | ||||
| #include "network/network.h" | ||||
| #include "network/network_settings.h" | ||||
| #include "ui_lobby.h" | ||||
| #ifdef ENABLE_WEB_SERVICE | ||||
| #include "web_service/web_backend.h" | ||||
|  | @ -58,9 +58,9 @@ Lobby::Lobby(QWidget* parent, QStandardItemModel* list, | |||
| 
 | ||||
|     ui->nickname->setValidator(validation.GetNickname()); | ||||
|     ui->nickname->setText(UISettings::values.nickname); | ||||
|     if (ui->nickname->text().isEmpty() && !Settings::values.citra_username.empty()) { | ||||
|     if (ui->nickname->text().isEmpty() && !NetSettings::values.citra_username.empty()) { | ||||
|         // Use Citra Web Service user name as nickname by default
 | ||||
|         ui->nickname->setText(QString::fromStdString(Settings::values.citra_username)); | ||||
|         ui->nickname->setText(QString::fromStdString(NetSettings::values.citra_username)); | ||||
|     } | ||||
| 
 | ||||
|     // UI Buttons
 | ||||
|  | @ -155,9 +155,11 @@ void Lobby::OnJoinRoom(const QModelIndex& source) { | |||
|     QFuture<void> f = QtConcurrent::run([nickname, ip, port, password, verify_UID] { | ||||
|         std::string token; | ||||
| #ifdef ENABLE_WEB_SERVICE | ||||
|         if (!Settings::values.citra_username.empty() && !Settings::values.citra_token.empty()) { | ||||
|             WebService::Client client(Settings::values.web_api_url, Settings::values.citra_username, | ||||
|                                       Settings::values.citra_token); | ||||
|         if (!NetSettings::values.citra_username.empty() && | ||||
|             !NetSettings::values.citra_token.empty()) { | ||||
|             WebService::Client client(NetSettings::values.web_api_url, | ||||
|                                       NetSettings::values.citra_username, | ||||
|                                       NetSettings::values.citra_token); | ||||
|             token = client.GetExternalJWT(verify_UID).returned_data; | ||||
|             if (token.empty()) { | ||||
|                 LOG_ERROR(WebService, "Could not get external JWT, verification may fail"); | ||||
|  | @ -179,7 +181,6 @@ void Lobby::OnJoinRoom(const QModelIndex& source) { | |||
|     UISettings::values.nickname = ui->nickname->text(); | ||||
|     UISettings::values.ip = proxy->data(connection_index, LobbyItemHost::HostIPRole).toString(); | ||||
|     UISettings::values.port = proxy->data(connection_index, LobbyItemHost::HostPortRole).toString(); | ||||
|     Settings::Apply(); | ||||
| } | ||||
| 
 | ||||
| void Lobby::ResetModel() { | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue