core, citra_qt: Allow credentials update in multiplayer announce session
Allows updating the credentials of the announce session, thus allowing credentials changes to be reflected before citra restart. To avoid race conditions and web errors (you can only update the room that you created, i.e. changing credentials halfway will make it break), now you can only use the Citra Web Services settings when not hosting a public room.
This commit is contained in:
parent
d6b168d7ed
commit
4a9ea65e49
@ -10,10 +10,11 @@
|
||||
#include "core/settings.h"
|
||||
#include "ui_configure.h"
|
||||
|
||||
ConfigureDialog::ConfigureDialog(QWidget* parent, HotkeyRegistry& registry)
|
||||
ConfigureDialog::ConfigureDialog(QWidget* parent, HotkeyRegistry& registry, bool enable_web_config)
|
||||
: QDialog(parent), registry(registry), ui(new Ui::ConfigureDialog) {
|
||||
ui->setupUi(this);
|
||||
ui->hotkeysTab->Populate(registry);
|
||||
ui->webTab->SetWebServiceConfigEnabled(enable_web_config);
|
||||
|
||||
this->PopulateSelectionList();
|
||||
connect(ui->uiTab, &ConfigureUi::languageChanged, this, &ConfigureDialog::onLanguageChanged);
|
||||
|
@ -17,7 +17,8 @@ class ConfigureDialog : public QDialog {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit ConfigureDialog(QWidget* parent, HotkeyRegistry& registry);
|
||||
explicit ConfigureDialog(QWidget* parent, HotkeyRegistry& registry,
|
||||
bool enable_web_config = true);
|
||||
~ConfigureDialog() override;
|
||||
|
||||
void applyConfiguration();
|
||||
|
@ -118,3 +118,8 @@ void ConfigureWeb::OnLoginVerified() {
|
||||
void ConfigureWeb::retranslateUi() {
|
||||
ui->retranslateUi(this);
|
||||
}
|
||||
|
||||
void ConfigureWeb::SetWebServiceConfigEnabled(bool enabled) {
|
||||
ui->label_disable_info->setVisible(!enabled);
|
||||
ui->groupBoxWebConfig->setEnabled(enabled);
|
||||
}
|
||||
|
@ -22,6 +22,7 @@ public:
|
||||
void applyConfiguration();
|
||||
void retranslateUi();
|
||||
void setConfiguration();
|
||||
void SetWebServiceConfigEnabled(bool enabled);
|
||||
|
||||
private:
|
||||
void RefreshTelemetryID();
|
||||
|
@ -118,6 +118,16 @@
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="label_disable_info">
|
||||
<property name="text">
|
||||
<string>Web Service configuration can only be changed when a public room isn't being hosted.</string>
|
||||
</property>
|
||||
<property name="wordWrap">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QGroupBox" name="groupBox">
|
||||
<property name="title">
|
||||
|
@ -1335,7 +1335,8 @@ void GMainWindow::OnCheats() {
|
||||
}
|
||||
|
||||
void GMainWindow::OnConfigure() {
|
||||
ConfigureDialog configureDialog(this, hotkey_registry);
|
||||
ConfigureDialog configureDialog(this, hotkey_registry,
|
||||
!multiplayer_state->IsHostingPublicRoom());
|
||||
connect(&configureDialog, &ConfigureDialog::languageChanged, this,
|
||||
&GMainWindow::OnLanguageChanged);
|
||||
auto old_theme = UISettings::values.theme;
|
||||
@ -1350,6 +1351,8 @@ void GMainWindow::OnConfigure() {
|
||||
UpdateUITheme();
|
||||
if (UISettings::values.enable_discord_presence != old_discord_presence)
|
||||
SetDiscordEnabled(UISettings::values.enable_discord_presence);
|
||||
if (!multiplayer_state->IsHostingPublicRoom())
|
||||
multiplayer_state->UpdateCredentials();
|
||||
emit UpdateThemedIcons();
|
||||
SyncMenuUISettings();
|
||||
game_list->RefreshGameDirectory();
|
||||
|
@ -278,3 +278,11 @@ void MultiplayerState::OnDirectConnectToRoom() {
|
||||
}
|
||||
BringWidgetToFront(direct_connect);
|
||||
}
|
||||
|
||||
bool MultiplayerState::IsHostingPublicRoom() const {
|
||||
return announce_multiplayer_session->IsRunning();
|
||||
}
|
||||
|
||||
void MultiplayerState::UpdateCredentials() {
|
||||
announce_multiplayer_session->UpdateCredentials();
|
||||
}
|
||||
|
@ -38,6 +38,14 @@ public:
|
||||
|
||||
void retranslateUi();
|
||||
|
||||
/**
|
||||
* Whether a public room is being hosted or not.
|
||||
* When this is true, Web Services configuration should be disabled.
|
||||
*/
|
||||
bool IsHostingPublicRoom() const;
|
||||
|
||||
void UpdateCredentials();
|
||||
|
||||
public slots:
|
||||
void OnNetworkStateChanged(const Network::RoomMember::State& state);
|
||||
void OnNetworkError(const Network::RoomMember::Error& error);
|
||||
|
@ -146,4 +146,18 @@ AnnounceMultiplayerRoom::RoomList AnnounceMultiplayerSession::GetRoomList() {
|
||||
return backend->GetRoomList();
|
||||
}
|
||||
|
||||
bool AnnounceMultiplayerSession::IsRunning() const {
|
||||
return announce_multiplayer_thread != nullptr;
|
||||
}
|
||||
|
||||
void AnnounceMultiplayerSession::UpdateCredentials() {
|
||||
ASSERT_MSG(!IsRunning(), "Credentials can only be updated when session is not running");
|
||||
|
||||
#ifdef ENABLE_WEB_SERVICE
|
||||
backend = std::make_unique<WebService::RoomJson>(Settings::values.web_api_url,
|
||||
Settings::values.citra_username,
|
||||
Settings::values.citra_token);
|
||||
#endif
|
||||
}
|
||||
|
||||
} // namespace Core
|
||||
|
@ -67,6 +67,17 @@ public:
|
||||
*/
|
||||
AnnounceMultiplayerRoom::RoomList GetRoomList();
|
||||
|
||||
/**
|
||||
* Whether the announce session is still running
|
||||
*/
|
||||
bool IsRunning() const;
|
||||
|
||||
/**
|
||||
* Recreates the backend, updating the credentials.
|
||||
* This can only be used when the announce session is not running.
|
||||
*/
|
||||
void UpdateCredentials();
|
||||
|
||||
private:
|
||||
Common::Event shutdown_event;
|
||||
std::mutex callback_mutex;
|
||||
|
Loading…
Reference in New Issue
Block a user