diff --git a/scripts/Server/replacesimulation.php b/scripts/Server/replacesimulation.php new file mode 100644 index 000000000..e9b76486a --- /dev/null +++ b/scripts/Server/replacesimulation.php @@ -0,0 +1,68 @@ +false]); + $db->close(); + exit; + } + + + $db = connectToDB(); + $db->begin_transaction(); + + $userName = $_POST["userName"]; + $pw = $_POST["password"]; + + if (!checkPw($db, $userName, $pw)) { + echo json_encode(["result"=>false]); + $db->close(); + exit; + } + + $obj = $db->query("SELECT u.ID as id FROM user u WHERE u.NAME='".addslashes($userName)."'")->fetch_object(); + if (!$obj) { + echo json_encode(["result"=>false]); + $db->close(); + exit; + } + + $success = false; + $particles = (int)$_POST['particles']; + $version = $_POST['version']; + $content = $_POST['content']; + $settings = $_POST['settings']; + $simId = $_POST['simId']; + $size = strlen($content); + $type = array_key_exists('type', $_POST) ? $_POST['type'] : 0; + $workspace = array_key_exists('workspace', $_POST) ? $_POST['workspace'] : 0; + $statistics = array_key_exists('statistics', $_POST) ? $_POST['statistics'] : ""; + + if ($userName != 'alien-project' && $workspace == 1) { + closeAndExit($db); + } + + $stmt = $db->prepare("UPDATE simulation SET PARTICLES=?, VERSION=?, CONTENT=?, WIDTH=?, HEIGHT=?, SETTINGS=?, SIZE=?, STATISTICS=?, CONTENT2=?, CONTENT3=?, CONTENT4=?, CONTENT5=?, CONTENT6=? WHERE ID=?"); + if (!$stmt) { + closeAndExit($db); + } + + $emptyString = ''; + $stmt->bind_param("issiisissssssi", $particles, $version, $content, $width, $height, $settings, $size, $statistics, $emptyString, $emptyString, $emptyString, $emptyString, $emptyString, $simId); + + if (!$stmt->execute()) { + closeAndExit($db); + } + + // create Discord message + //if ($workspace != PRIVATE_WORKSPACE_TYPE) { + // $discordPayload = createAddResourceMessage($type, $simName, $userName, $simDesc, $width, $height, $particles); + // sendDiscordMessage($discordPayload); + //} + + echo json_encode(["result"=>true]); + + $db->commit(); + $db->close(); +?> \ No newline at end of file diff --git a/source/Base/Cache.h b/source/Base/Cache.h index db75d0bc6..d3797474b 100644 --- a/source/Base/Cache.h +++ b/source/Base/Cache.h @@ -8,7 +8,7 @@ template class Cache { public: - void insert(Key const& key, Value const& value); + void insertOrAssign(Key const& key, Value const& value); std::optional find(Key const& key); @@ -21,7 +21,7 @@ class Cache /* Implementation */ /************************************************************************/ template -void Cache::insert(Key const& key, Value const& value) +void Cache::insertOrAssign(Key const& key, Value const& value) { if (_cacheMap.size() >= MaxEntries) { _cacheMap.erase(_usedKeys.front()); diff --git a/source/Gui/BrowserWindow.cpp b/source/Gui/BrowserWindow.cpp index 7b0b952d6..060248ac3 100644 --- a/source/Gui/BrowserWindow.cpp +++ b/source/Gui/BrowserWindow.cpp @@ -41,6 +41,7 @@ #include "OverlayMessageController.h" #include "GenomeEditorWindow.h" #include "HelpStrings.h" +#include "SerializationHelperService.h" namespace { @@ -110,17 +111,19 @@ _BrowserWindow::~_BrowserWindow() + workspaceTypeToString.at(workspaceId.workspaceType), NetworkResourceService::convertFolderNamesToSettings(workspace.collapsedFolderNames)); } - settings.setStringVector("windows.browser.simulation ids", getAllSimulationIds()); + _lastSessionData.save(getAllRawTOs()); } void _BrowserWindow::registerCyclicReferences( LoginDialogWeakPtr const& loginDialog, UploadSimulationDialogWeakPtr const& uploadSimulationDialog, - EditSimulationDialogWeakPtr const& editSimulationDialog) + EditSimulationDialogWeakPtr const& editSimulationDialog, + GenomeEditorWindowWeakPtr const& genomeEditorWindow) { _loginDialog = loginDialog; _uploadSimulationDialog = uploadSimulationDialog; _editSimulationDialog = editSimulationDialog; + _genomeEditorWindow = genomeEditorWindow; auto firstStart = GlobalSettings::getInstance().getBool("windows.browser.first start", true); refreshIntern(firstStart); @@ -136,8 +139,7 @@ void _BrowserWindow::registerCyclicReferences( createTreeTOs(workspace); } - auto simIds = GlobalSettings::getInstance().getStringVector("windows.browser.simulation ids", getAllSimulationIds()); - _simIdsFromLastSession = std::unordered_set(simIds.begin(), simIds.end()); + _lastSessionData.load(getAllRawTOs()); } void _BrowserWindow::onRefresh() @@ -155,11 +157,6 @@ BrowserCache& _BrowserWindow::getSimulationCache() return _simulationCache; } -void _BrowserWindow::registerUploadedSimulation(std::string const& id) -{ - _simIdsFromLastSession.insert(id); -} - void _BrowserWindow::refreshIntern(bool withRetry) { try { @@ -291,6 +288,14 @@ void _BrowserWindow::processToolbar() + " to the server and made visible in the browser. You can choose whether you want to share it with other users or whether it should only be visible " "in your private workspace.\nIf you have already selected a folder, your " + resourceTypeString + " will be uploaded there."); + //replace button + ImGui::SameLine(); + ImGui::BeginDisabled(!isOwnerForSelectedItem || !_selectedTreeTO->isLeaf()); + if (AlienImGui::ToolbarButton(ICON_FA_EXCHANGE_ALT)) { + onReplaceResource(_selectedTreeTO->getLeaf()); + } + ImGui::EndDisabled(); + //edit button ImGui::SameLine(); ImGui::BeginDisabled(!isOwnerForSelectedItem); @@ -769,7 +774,7 @@ bool _BrowserWindow::processResourceNameField(NetworkResourceTreeTO const& treeT } ImGui::SameLine(); - if (!_simIdsFromLastSession.contains(leaf.rawTO->id)) { + if (!isOwner(treeTO) && _lastSessionData.isNew(leaf.rawTO)) { auto font = StyleRepository::getInstance().getSmallBoldFont(); auto origSize = font->Scale; font->Scale *= 0.65f; @@ -1234,7 +1239,7 @@ void _BrowserWindow::onDownloadResource(BrowserLeaf const& leaf) MessageDialog::getInstance().information("Error", "Failed to load simulation. Your program version may not match."); return; } - _simulationCache.insert(leaf.rawTO->id, deserializedSim); + _simulationCache.insertOrAssign(leaf.rawTO->id, deserializedSim); } else { log(Priority::Important, "browser: get resource with id=" + leaf.rawTO->id + " from simulation cache"); std::swap(deserializedSim, *cachedSimulation); @@ -1286,6 +1291,62 @@ void _BrowserWindow::onDownloadResource(BrowserLeaf const& leaf) }); } +void _BrowserWindow::onReplaceResource(BrowserLeaf const& leaf) +{ + printOverlayMessage("Replacing ..."); + + delayedExecution([=, this] { + std::string mainData; + std::string settings; + std::string statistics; + IntVector2D worldSize; + int numObjects = 0; + + DeserializedSimulation deserializedSim; + if (leaf.rawTO->resourceType == NetworkResourceType_Simulation) { + deserializedSim = SerializationHelperService::getDeserializedSerialization(_simController); + + SerializedSimulation serializedSim; + if (!SerializerService::serializeSimulationToStrings(serializedSim, deserializedSim)) { + MessageDialog::getInstance().information("Replace simulation", "The simulation could not be serialized for replacing."); + return; + } + mainData = serializedSim.mainData; + settings = serializedSim.auxiliaryData; + statistics = serializedSim.statistics; + worldSize = {deserializedSim.auxiliaryData.generalSettings.worldSizeX, deserializedSim.auxiliaryData.generalSettings.worldSizeY}; + numObjects = deserializedSim.mainData.getNumberOfCellAndParticles(); + } else { + auto genome = _genomeEditorWindow.lock()->getCurrentGenome(); + if (genome.cells.empty()) { + showMessage("Replace genome", "The is no valid genome in the genome editor selected."); + return; + } + auto genomeData = GenomeDescriptionService::convertDescriptionToBytes(genome); + numObjects = GenomeDescriptionService::getNumNodesRecursively(genomeData, true); + + if (!SerializerService::serializeGenomeToString(mainData, genomeData)) { + showMessage("Replace genome", "The genome could not be serialized for replacing."); + return; + } + } + + if (!NetworkService::replaceResource(leaf.rawTO->id, worldSize, numObjects, mainData, settings, statistics)) { + std::string type = leaf.rawTO->resourceType == NetworkResourceType_Simulation ? "simulation" : "genome"; + showMessage( + "Error", + "Failed to replace " + type + ".\n\n" + "Possible reasons:\n\n" ICON_FA_CHEVRON_RIGHT " The server is not reachable.\n\n" ICON_FA_CHEVRON_RIGHT + " The total size of your uploads exceeds the allowed storage limit."); + return; + } + if (leaf.rawTO->resourceType == NetworkResourceType_Simulation) { + getSimulationCache().insertOrAssign(leaf.rawTO->id, deserializedSim); + } + onRefresh(); + }); +} + void _BrowserWindow::onEditResource(NetworkResourceTreeTO const& treeTO) { if (treeTO->isLeaf()) { @@ -1455,15 +1516,13 @@ std::string _BrowserWindow::getUserNamesToEmojiType(std::string const& resourceI return boost::algorithm::join(userNames, ", "); } -std::vector _BrowserWindow::getAllSimulationIds() const +std::unordered_set _BrowserWindow::getAllRawTOs() const { - std::unordered_set result; + std::unordered_set result; for (auto const& workspace : _workspaces | std::views::values) { - for(auto const& rawTO : workspace.rawTOs) { - result.insert(rawTO->id); - } + result.insert(workspace.rawTOs.begin(), workspace.rawTOs.end()); } - return std::vector(result.begin(), result.end()); + return result; } void _BrowserWindow::pushTextColor(NetworkResourceTreeTO const& to) diff --git a/source/Gui/BrowserWindow.h b/source/Gui/BrowserWindow.h index 77facd09e..074d0394d 100644 --- a/source/Gui/BrowserWindow.h +++ b/source/Gui/BrowserWindow.h @@ -12,6 +12,7 @@ #include "AlienWindow.h" #include "Definitions.h" +#include "LastSessionBrowserData.h" struct ImGuiTableColumnSortSpecs; @@ -30,13 +31,13 @@ class _BrowserWindow : public _AlienWindow void registerCyclicReferences( LoginDialogWeakPtr const& loginDialog, UploadSimulationDialogWeakPtr const& uploadSimulationDialog, - EditSimulationDialogWeakPtr const& editSimulationDialog); + EditSimulationDialogWeakPtr const& editSimulationDialog, + GenomeEditorWindowWeakPtr const& genomeEditorWindow); void onRefresh(); WorkspaceType getCurrentWorkspaceType() const; BrowserCache& getSimulationCache(); - void registerUploadedSimulation(std::string const& id); private: struct WorkspaceId @@ -96,6 +97,7 @@ class _BrowserWindow : public _AlienWindow void sortUserList(); void onDownloadResource(BrowserLeaf const& leaf); + void onReplaceResource(BrowserLeaf const& leaf); void onEditResource(NetworkResourceTreeTO const& treeTO); void onMoveResource(NetworkResourceTreeTO const& treeTO); void onDeleteResource(NetworkResourceTreeTO const& treeTO); @@ -107,7 +109,7 @@ class _BrowserWindow : public _AlienWindow bool isOwner(NetworkResourceTreeTO const& treeTO) const; std::string getUserNamesToEmojiType(std::string const& resourceId, int emojiType); - std::vector getAllSimulationIds() const; + std::unordered_set getAllRawTOs() const; void pushTextColor(NetworkResourceTreeTO const& to); void popTextColor(); @@ -120,7 +122,7 @@ class _BrowserWindow : public _AlienWindow std::vector _userTOs; WorkspaceId _currentWorkspace = {NetworkResourceType_Simulation, WorkspaceType_AlienProject}; std::map _workspaces; - std::unordered_set _simIdsFromLastSession; + LastSessionBrowserData _lastSessionData; NetworkResourceTreeTO _selectedTreeTO; @@ -140,4 +142,5 @@ class _BrowserWindow : public _AlienWindow EditorController _editorController; UploadSimulationDialogWeakPtr _uploadSimulationDialog; EditSimulationDialogWeakPtr _editSimulationDialog; + GenomeEditorWindowWeakPtr _genomeEditorWindow; }; diff --git a/source/Gui/CMakeLists.txt b/source/Gui/CMakeLists.txt index 840c07f59..1aa6ec8ec 100644 --- a/source/Gui/CMakeLists.txt +++ b/source/Gui/CMakeLists.txt @@ -54,6 +54,8 @@ PUBLIC ImageToPatternDialog.h InspectorWindow.cpp InspectorWindow.h + LastSessionBrowserData.cpp + LastSessionBrowserData.h LoginDialog.cpp LoginDialog.h LogWindow.cpp @@ -91,6 +93,8 @@ PUBLIC ResizeWorldDialog.h SelectionWindow.cpp SelectionWindow.h + SerializationHelperService.cpp + SerializationHelperService.h Shader.cpp Shader.h ShaderWindow.cpp diff --git a/source/Gui/Definitions.h b/source/Gui/Definitions.h index ac0600d4c..b8b4cdda2 100644 --- a/source/Gui/Definitions.h +++ b/source/Gui/Definitions.h @@ -150,6 +150,7 @@ using ImageToPatternDialog = std::shared_ptr<_ImageToPatternDialog>; class _GenomeEditorWindow; using GenomeEditorWindow = std::shared_ptr<_GenomeEditorWindow>; +using GenomeEditorWindowWeakPtr = std::weak_ptr<_GenomeEditorWindow>; class _RadiationSourcesWindow; using RadiationSourcesWindow = std::shared_ptr<_RadiationSourcesWindow>; diff --git a/source/Gui/LastSessionBrowserData.cpp b/source/Gui/LastSessionBrowserData.cpp new file mode 100644 index 000000000..7a0a6a8ae --- /dev/null +++ b/source/Gui/LastSessionBrowserData.cpp @@ -0,0 +1,38 @@ +#include "LastSessionBrowserData.h" + +#include "Base/GlobalSettings.h" +#include "Network/NetworkResourceRawTO.h" + +void LastSessionBrowserData::load(std::unordered_set const& rawTOs) +{ + auto currentIdentifiers = convertToIdentifiers(rawTOs); + auto lastIdentifiers = GlobalSettings::getInstance().getStringVector( + "windows.browser.last session.simulation ids", std::vector(currentIdentifiers.begin(), currentIdentifiers.end())); + _identifiers = std::unordered_set(lastIdentifiers.begin(), lastIdentifiers.end()); +} + +void LastSessionBrowserData::save(std::unordered_set const& rawTOs) +{ + auto currentIdentifiers = convertToIdentifiers(rawTOs); + GlobalSettings::getInstance().setStringVector( + "windows.browser.last session.simulation ids", std::vector(currentIdentifiers.begin(), currentIdentifiers.end())); +} + +bool LastSessionBrowserData::isNew(NetworkResourceRawTO const& rawTO) const +{ + return !_identifiers.count(convertToIdentifier(rawTO)); +} + +std::unordered_set LastSessionBrowserData::convertToIdentifiers(std::unordered_set const& rawTOs) const +{ + std::unordered_set result; + for (auto const& rawTO : rawTOs) { + result.insert(convertToIdentifier(rawTO)); + } + return result; +} + +std::string LastSessionBrowserData::convertToIdentifier(NetworkResourceRawTO const& rawTO) const +{ + return rawTO->id + "/" + rawTO->timestamp; +} diff --git a/source/Gui/LastSessionBrowserData.h b/source/Gui/LastSessionBrowserData.h new file mode 100644 index 000000000..daca23171 --- /dev/null +++ b/source/Gui/LastSessionBrowserData.h @@ -0,0 +1,20 @@ +#pragma once + +#include +#include + +#include "Network/Definitions.h" + +class LastSessionBrowserData +{ +public: + void load(std::unordered_set const& rawTOs); + void save(std::unordered_set const& rawTOs); + bool isNew(NetworkResourceRawTO const& rawTO) const; + +private: + std::unordered_set convertToIdentifiers(std::unordered_set const& rawTOs) const; + std::string convertToIdentifier(NetworkResourceRawTO const& rawTO) const; + + std::unordered_set _identifiers; +}; diff --git a/source/Gui/MainWindow.cpp b/source/Gui/MainWindow.cpp index 6ee9e35db..931762ce1 100644 --- a/source/Gui/MainWindow.cpp +++ b/source/Gui/MainWindow.cpp @@ -158,7 +158,7 @@ _MainWindow::_MainWindow(SimulationController const& simController, GuiLogger co _shaderWindow = std::make_shared<_ShaderWindow>(_simulationView); //cyclic references - _browserWindow->registerCyclicReferences(_loginDialog, _uploadSimulationDialog, _editSimulationDialog); + _browserWindow->registerCyclicReferences(_loginDialog, _uploadSimulationDialog, _editSimulationDialog, _editorController->getGenomeEditorWindow()); _activateUserDialog->registerCyclicReferences(_createUserDialog); _editorController->registerCyclicReferences(_uploadSimulationDialog); diff --git a/source/Gui/SerializationHelperService.cpp b/source/Gui/SerializationHelperService.cpp new file mode 100644 index 000000000..56dc4f79c --- /dev/null +++ b/source/Gui/SerializationHelperService.cpp @@ -0,0 +1,19 @@ +#include "SerializationHelperService.h" +#include "EngineInterface/SimulationController.h" + +#include "Viewport.h" + + +DeserializedSimulation SerializationHelperService::getDeserializedSerialization(SimulationController const& simController) +{ + DeserializedSimulation result; + result.auxiliaryData.timestep = static_cast(simController->getCurrentTimestep()); + result.auxiliaryData.realTime = simController->getRealTime(); + result.auxiliaryData.zoom = Viewport::getZoomFactor(); + result.auxiliaryData.center = Viewport::getCenterInWorldPos(); + result.auxiliaryData.generalSettings = simController->getGeneralSettings(); + result.auxiliaryData.simulationParameters = simController->getSimulationParameters(); + result.statistics = simController->getStatisticsHistory().getCopiedData(); + result.mainData = simController->getClusteredSimulationData(); + return result; +} diff --git a/source/Gui/SerializationHelperService.h b/source/Gui/SerializationHelperService.h new file mode 100644 index 000000000..432ee6a3c --- /dev/null +++ b/source/Gui/SerializationHelperService.h @@ -0,0 +1,11 @@ +#pragma once + +#include + +#include "EngineInterface/SerializerService.h" + +class SerializationHelperService +{ +public: + static DeserializedSimulation getDeserializedSerialization(SimulationController const& simController); +}; diff --git a/source/Gui/UploadSimulationDialog.cpp b/source/Gui/UploadSimulationDialog.cpp index 1c5a476dd..dc43cc179 100644 --- a/source/Gui/UploadSimulationDialog.cpp +++ b/source/Gui/UploadSimulationDialog.cpp @@ -20,6 +20,7 @@ #include "GenomeEditorWindow.h" #include "HelpStrings.h" #include "LoginDialog.h" +#include "SerializationHelperService.h" namespace { @@ -151,14 +152,7 @@ void _UploadSimulationDialog::onUpload() DeserializedSimulation deserializedSim; if (_resourceType == NetworkResourceType_Simulation) { - deserializedSim.auxiliaryData.timestep = static_cast(_simController->getCurrentTimestep()); - deserializedSim.auxiliaryData.realTime = _simController->getRealTime(); - deserializedSim.auxiliaryData.zoom = Viewport::getZoomFactor(); - deserializedSim.auxiliaryData.center = Viewport::getCenterInWorldPos(); - deserializedSim.auxiliaryData.generalSettings = _simController->getGeneralSettings(); - deserializedSim.auxiliaryData.simulationParameters = _simController->getSimulationParameters(); - deserializedSim.statistics = _simController->getStatisticsHistory().getCopiedData(); - deserializedSim.mainData = _simController->getClusteredSimulationData(); + deserializedSim = SerializationHelperService::getDeserializedSerialization(_simController); SerializedSimulation serializedSim; if (!SerializerService::serializeSimulationToStrings(serializedSim, deserializedSim)) { @@ -197,9 +191,8 @@ void _UploadSimulationDialog::onUpload() return; } if (_resourceType == NetworkResourceType_Simulation) { - _browserWindow->getSimulationCache().insert(resourceId, deserializedSim); + _browserWindow->getSimulationCache().insertOrAssign(resourceId, deserializedSim); } _browserWindow->onRefresh(); - _browserWindow->registerUploadedSimulation(resourceId); }); } diff --git a/source/Network/NetworkService.cpp b/source/Network/NetworkService.cpp index 6fbfe2567..e5d11b5d9 100644 --- a/source/Network/NetworkService.cpp +++ b/source/Network/NetworkService.cpp @@ -436,8 +436,8 @@ bool NetworkService::uploadResource( std::string& resourceId, std::string const& resourceName, std::string const& description, - IntVector2D const& size, - int particles, + IntVector2D const& worldSize, + int numParticles, std::string const& mainData, std::string const& settings, std::string const& statistics, @@ -461,9 +461,9 @@ bool NetworkService::uploadResource( {"password", *_password, "", ""}, {"simName", resourceName, "", ""}, {"simDesc", description, "", ""}, - {"width", std::to_string(size.x), "", ""}, - {"height", std::to_string(size.y), "", ""}, - {"particles", std::to_string(particles), "", ""}, + {"width", std::to_string(worldSize.x), "", ""}, + {"height", std::to_string(worldSize.y), "", ""}, + {"particles", std::to_string(numParticles), "", ""}, {"version", Const::ProgramVersion, "", ""}, {"content", chunks.front(), "", "application/octet-stream"}, {"settings", settings, "", ""}, @@ -493,7 +493,63 @@ bool NetworkService::uploadResource( } ++index; } - _downloadCache.insert(resourceId, ResourceData{mainData, settings, statistics}); + _downloadCache.insertOrAssign(resourceId, ResourceData{mainData, settings, statistics}); + + return true; +} + +bool NetworkService::replaceResource( + std::string const& resourceId, + IntVector2D const& worldSize, + int numParticles, + std::string const& mainData, + std::string const& settings, + std::string const& statistics) +{ + log(Priority::Important, "network: replace resource with id='" + resourceId + "'"); + + std::vector chunks; + for (size_t i = 0; i < mainData.length(); i += MaxChunkSize) { + std::string chunk = mainData.substr(i, MaxChunkSize); + chunks.emplace_back(chunk); + } + + httplib::SSLClient client(_serverAddress); + configureClient(client); + + httplib::MultipartFormDataItems items = { + {"userName", *_loggedInUserName, "", ""}, + {"password", *_password, "", ""}, + {"simId", resourceId, "", ""}, + {"width", std::to_string(worldSize.x), "", ""}, + {"height", std::to_string(worldSize.y), "", ""}, + {"particles", std::to_string(numParticles), "", ""}, + {"version", Const::ProgramVersion, "", ""}, + {"content", chunks.front(), "", "application/octet-stream"}, + {"settings", settings, "", ""}, + {"symbolMap", "", "", ""}, + {"statistics", statistics, "", ""}, + }; + + try { + auto result = executeRequest([&] { return client.Post("/alien-server/replacesimulation.php", items); }); + if (!parseBoolResult(result->body)) { + return false; + } + } catch (...) { + logNetworkError(); + return false; + } + + int index = 1; + for (auto const& chunk : chunks | std::views::drop(1)) { + if (!appendResourceData(resourceId, chunk, toInt(index))) { + deleteResource(resourceId); + return false; + } + ++index; + } + _downloadCache.insertOrAssign(resourceId, ResourceData{mainData, settings, statistics}); return true; } @@ -536,7 +592,7 @@ bool NetworkService::downloadResource(std::string& mainData, std::string& auxili auto result = executeRequest([&] { return client.Get("/alien-server/downloadstatistics.php", params, {}); }); statistics = result->body; } - _downloadCache.insert(simId, ResourceData{mainData, auxiliaryData, statistics}); + _downloadCache.insertOrAssign(simId, ResourceData{mainData, auxiliaryData, statistics}); return true; } } catch (...) { @@ -628,7 +684,7 @@ bool NetworkService::deleteResource(std::string const& simId) } } -bool NetworkService::appendResourceData(std::string& resourceId, std::string const& data, int chunkIndex) +bool NetworkService::appendResourceData(std::string const& resourceId, std::string const& data, int chunkIndex) { httplib::SSLClient client(_serverAddress); configureClient(client); diff --git a/source/Network/NetworkService.h b/source/Network/NetworkService.h index 08b51de86..6600573ea 100644 --- a/source/Network/NetworkService.h +++ b/source/Network/NetworkService.h @@ -52,21 +52,28 @@ class NetworkService std::string& resourceId, std::string const& resourceName, std::string const& description, - IntVector2D const& size, - int particles, + IntVector2D const& worldSize, + int numParticles, std::string const& data, std::string const& settings, std::string const& statistics, NetworkResourceType resourceType, WorkspaceType workspaceType); + static bool replaceResource( + std::string const& resourceId, + IntVector2D const& worldSize, + int numParticles, + std::string const& data, + std::string const& settings, + std::string const& statistics); static bool downloadResource(std::string& mainData, std::string& auxiliaryData, std::string& statistics, std::string const& simId); - static void incDownloadCounter(std::string const& simId); + static void incDownloadCounter(std::string const& simId); static bool editResource(std::string const& simId, std::string const& newName, std::string const& newDescription); static bool moveResource(std::string const& simId, WorkspaceType targetWorkspace); static bool deleteResource(std::string const& simId); private: - static bool appendResourceData(std::string& resourceId, std::string const& data, int chunkIndex); + static bool appendResourceData(std::string const& resourceId, std::string const& data, int chunkIndex); static std::string _serverAddress; static std::optional _loggedInUserName;