diff --git a/lib/libimhex/include/hex/helpers/net.hpp b/lib/libimhex/include/hex/helpers/net.hpp index 2c22c2b21..8c5df86ce 100644 --- a/lib/libimhex/include/hex/helpers/net.hpp +++ b/lib/libimhex/include/hex/helpers/net.hpp @@ -35,11 +35,13 @@ namespace hex { Net(); ~Net(); - std::future> getString(const std::string &url, u32 timeout = 2000); - std::future> getJson(const std::string &url, u32 timeout = 2000); + static constexpr u32 DefaultTimeout = 2'000; - std::future> uploadFile(const std::string &url, const fs::path &filePath, u32 timeout = 2000); - std::future> downloadFile(const std::string &url, const fs::path &filePath, u32 timeout = 2000); + std::future> getString(const std::string &url, u32 timeout = DefaultTimeout); + std::future> getJson(const std::string &url, u32 timeout = DefaultTimeout); + + std::future> uploadFile(const std::string &url, const fs::path &filePath, u32 timeout = DefaultTimeout); + std::future> downloadFile(const std::string &url, const fs::path &filePath, u32 timeout = DefaultTimeout); [[nodiscard]] std::string encode(const std::string &input); diff --git a/lib/libimhex/source/helpers/net.cpp b/lib/libimhex/source/helpers/net.cpp index ee4905a9f..3201f330b 100644 --- a/lib/libimhex/source/helpers/net.cpp +++ b/lib/libimhex/source/helpers/net.cpp @@ -121,7 +121,7 @@ namespace hex { std::optional Net::execute() { CURLcode result = curl_easy_perform(this->m_ctx); if (result != CURLE_OK) - log::error("Net request failed with error {}!", curl_easy_strerror(result)); + log::error("Net request failed with error {0}: '{1}'", result, curl_easy_strerror(result)); i32 responseCode = 0; curl_easy_getinfo(this->m_ctx, CURLINFO_RESPONSE_CODE, &responseCode); diff --git a/plugins/builtin/include/content/views/view_store.hpp b/plugins/builtin/include/content/views/view_store.hpp index 9b42fde1e..3b5e260d5 100644 --- a/plugins/builtin/include/content/views/view_store.hpp +++ b/plugins/builtin/include/content/views/view_store.hpp @@ -37,6 +37,9 @@ namespace hex::plugin::builtin { [[nodiscard]] bool isAvailable() const override { return true; } [[nodiscard]] bool hasViewMenuItemEntry() const override { return false; } + [[nodiscard]] ImVec2 getMinSize() const override { return { 500, 400 }; } + [[nodiscard]] ImVec2 getMaxSize() const override { return { 500, 400 }; } + private: Net m_net; std::future> m_apiRequest; diff --git a/plugins/builtin/source/content/views/view_store.cpp b/plugins/builtin/source/content/views/view_store.cpp index bd2a87f7a..b0b51ce0c 100644 --- a/plugins/builtin/source/content/views/view_store.cpp +++ b/plugins/builtin/source/content/views/view_store.cpp @@ -161,7 +161,7 @@ namespace hex::plugin::builtin { this->m_yara.clear(); this->m_encodings.clear(); - this->m_apiRequest = this->m_net.getString(ImHexApiURL + "/store"s); + this->m_apiRequest = this->m_net.getString(ImHexApiURL + "/store"s, 30'0000); } void ViewStore::parseResponse() { @@ -218,8 +218,7 @@ namespace hex::plugin::builtin { } void ViewStore::drawContent() { - ImGui::SetNextWindowSizeConstraints(scaled(ImVec2(600, 400)), ImVec2(FLT_MAX, FLT_MAX)); - if (ImGui::BeginPopupModal(View::toWindowName("hex.builtin.view.store.name").c_str(), &this->getWindowOpenState(), ImGuiWindowFlags_AlwaysAutoResize)) { + if (ImGui::BeginPopupModal(View::toWindowName("hex.builtin.view.store.name").c_str(), &this->getWindowOpenState())) { if (this->m_apiRequest.valid()) { if (this->m_apiRequest.wait_for(0s) != std::future_status::ready) ImGui::TextSpinner("hex.builtin.view.store.loading"_lang); @@ -242,7 +241,7 @@ namespace hex::plugin::builtin { if (!update || fs::exists(fullPath)) { downloading = true; this->m_downloadPath = fullPath; - this->m_download = this->m_net.downloadFile(url, fullPath); + this->m_download = this->m_net.downloadFile(url, fullPath, 30'0000); break; } }