diff --git a/source/Gui/BrowserWindow.cpp b/source/Gui/BrowserWindow.cpp index bba650b75..57a24dfab 100644 --- a/source/Gui/BrowserWindow.cpp +++ b/source/Gui/BrowserWindow.cpp @@ -1231,11 +1231,7 @@ void _BrowserWindow::processPendingRequestIds() auto criticalErrors = _persisterController->fetchAllErrorInfos(SenderId{BrowserSenderId}); if (!criticalErrors.empty()) { - std::vector errorMessages; - for (auto const& error : criticalErrors) { - errorMessages.emplace_back(error.message); - } - MessageDialog::getInstance().information("Error", boost::join(errorMessages, "\n\n")); + MessageDialog::getInstance().information("Error", criticalErrors); } } diff --git a/source/Gui/FileTransferController.cpp b/source/Gui/FileTransferController.cpp index a210797cf..a2a37fb5f 100644 --- a/source/Gui/FileTransferController.cpp +++ b/source/Gui/FileTransferController.cpp @@ -1,7 +1,5 @@ #include "FileTransferController.h" -#include - #include #include "EngineInterface/SimulationController.h" @@ -113,10 +111,6 @@ void FileTransferController::process() auto criticalErrors = _persisterController->fetchAllErrorInfos(SenderId{FileTransferSenderId}); if (!criticalErrors.empty()) { - std::vector errorMessages; - for (auto const& error : criticalErrors) { - errorMessages.emplace_back(error.message); - } - MessageDialog::getInstance().information("Error", boost::join(errorMessages, "\n\n")); + MessageDialog::getInstance().information("Error", criticalErrors); } } diff --git a/source/Gui/LoginController.cpp b/source/Gui/LoginController.cpp index a809b0cf2..fd0a4522c 100644 --- a/source/Gui/LoginController.cpp +++ b/source/Gui/LoginController.cpp @@ -6,6 +6,8 @@ #include "PersisterInterface/LoginRequestData.h" #include "PersisterInterface/SenderInfo.h" +#include "MessageDialog.h" + namespace { auto constexpr LoginSenderId = "Login"; @@ -32,14 +34,8 @@ void LoginController::init(SimulationController const& simController, PersisterC if (!userName.empty()) { persisterController->scheduleLogin( - SenderInfo{.senderId = LoginSenderId, .wishResultData = false, .wishErrorInfo = true}, + SenderInfo{.senderId = SenderId{LoginSenderId}, .wishResultData = false, .wishErrorInfo = true}, LoginRequestData{.userName = userName, .password = password, .userInfo = getUserInfo()}); - //LoginErrorCode errorCode; - //if (!NetworkService::login(errorCode, _userName, _password, getUserInfo())) { - // if (errorCode != LoginErrorCode_UnknownUser) { - // MessageDialog::getInstance().information("Error", "Login failed."); - // } - //} } } } @@ -49,6 +45,14 @@ void LoginController::shutdown() saveSettings(); } +void LoginController::process() +{ + auto criticalErrors = _persisterController->fetchAllErrorInfos(SenderId{LoginSenderId}); + if (!criticalErrors.empty()) { + MessageDialog::getInstance().information("Login failed", criticalErrors); + } +} + void LoginController::saveSettings() { auto& settings = GlobalSettings::getInstance(); diff --git a/source/Gui/LoginController.h b/source/Gui/LoginController.h index b027f4628..7b28221de 100644 --- a/source/Gui/LoginController.h +++ b/source/Gui/LoginController.h @@ -11,6 +11,8 @@ class LoginController void init(SimulationController const& simController, PersisterController const& persisterController); void shutdown(); + void process(); + void saveSettings(); bool shareGpuInfo() const; diff --git a/source/Gui/MainWindow.cpp b/source/Gui/MainWindow.cpp index d34f3fb08..42b07517b 100644 --- a/source/Gui/MainWindow.cpp +++ b/source/Gui/MainWindow.cpp @@ -763,6 +763,7 @@ void _MainWindow::processControllers() OverlayMessageController::get().process(); DelayedExecutionController::getInstance().process(); FileTransferController::get().process(); + LoginController::get().process(); } void _MainWindow::onRunSimulation() diff --git a/source/Gui/MessageDialog.cpp b/source/Gui/MessageDialog.cpp index 798ebd9b0..844548362 100644 --- a/source/Gui/MessageDialog.cpp +++ b/source/Gui/MessageDialog.cpp @@ -1,5 +1,7 @@ #include "MessageDialog.h" +#include + #include #include "Base/LoggingService.h" @@ -37,6 +39,15 @@ void MessageDialog::information(std::string const& title, std::string const& mes log(Priority::Important, "message dialog showing: '" + message + "'"); } +void MessageDialog::information(std::string const& title, std::vector const& errors) +{ + std::vector errorMessages; + for (auto const& error : errors) { + errorMessages.emplace_back(error.message); + } + MessageDialog::getInstance().information(title, boost::join(errorMessages, "\n\n")); +} + void MessageDialog::yesNo(std::string const& title, std::string const& message, std::function const& yesFunction) { _show = true; diff --git a/source/Gui/MessageDialog.h b/source/Gui/MessageDialog.h index 08627577e..4b66cdb01 100644 --- a/source/Gui/MessageDialog.h +++ b/source/Gui/MessageDialog.h @@ -1,6 +1,8 @@ #pragma once #include "EngineInterface/Definitions.h" +#include "PersisterInterface/PersisterErrorInfo.h" + #include "Definitions.h" class MessageDialog @@ -11,6 +13,7 @@ class MessageDialog void process(); void information(std::string const& title, std::string const& message); + void information(std::string const& title, std::vector const& errors); void yesNo(std::string const& title, std::string const& message, std::function const& yesFunction); private: