From 323184e42c5f85c8738b03b890e5aaf3818e8858 Mon Sep 17 00:00:00 2001 From: "lane.wei" Date: Mon, 7 Apr 2025 20:09:51 +0800 Subject: [PATCH] ENH: GUI: add arm64 check logic for windows jira: no-jira Change-Id: Ic788d4ae9218b909eae5ce571d4436c39e77230a --- src/slic3r/GUI/GUI_App.cpp | 14 ++++++++++++++ src/slic3r/GUI/GUI_App.hpp | 7 +++++++ src/slic3r/Utils/Http.cpp | 8 +++++++- src/slic3r/Utils/Http.hpp | 1 + src/slic3r/Utils/PresetUpdater.cpp | 20 ++++++++++++++++++++ 5 files changed, 49 insertions(+), 1 deletion(-) diff --git a/src/slic3r/GUI/GUI_App.cpp b/src/slic3r/GUI/GUI_App.cpp index b66338376..bc3a08f01 100644 --- a/src/slic3r/GUI/GUI_App.cpp +++ b/src/slic3r/GUI/GUI_App.cpp @@ -1411,6 +1411,20 @@ GUI_App::GUI_App() this->init_download_path(); reset_to_active(); + +#if defined(__WINDOWS__) + SYSTEM_INFO sysInfo; + GetNativeSystemInfo(&sysInfo); + switch (sysInfo.wProcessorArchitecture) { + case PROCESSOR_ARCHITECTURE_ARM64: + m_is_arm64 = true; + break; + case PROCESSOR_ARCHITECTURE_AMD64: + default: + m_is_arm64 = false; + break; + } +#endif } void GUI_App::shutdown() diff --git a/src/slic3r/GUI/GUI_App.hpp b/src/slic3r/GUI/GUI_App.hpp index 17f11fda1..827afda5e 100644 --- a/src/slic3r/GUI/GUI_App.hpp +++ b/src/slic3r/GUI/GUI_App.hpp @@ -238,6 +238,9 @@ private: #ifdef __linux__ bool m_opengl_initialized{ false }; #endif +#if defined(__WINDOWS__) + bool m_is_arm64{false}; +#endif //import model from mall wxString m_download_file_url; @@ -577,6 +580,10 @@ public: std::string get_download_model_name() {return m_mall_model_download_name;} std::string get_remote_version_str() { return version_info.version_str; } +#if defined(__WINDOWS__) + bool is_running_on_arm64() { return m_is_arm64; } +#endif + void load_url(wxString url); void open_mall_page_dialog(); diff --git a/src/slic3r/Utils/Http.cpp b/src/slic3r/Utils/Http.cpp index a87cbd2c4..c9198c795 100644 --- a/src/slic3r/Utils/Http.cpp +++ b/src/slic3r/Utils/Http.cpp @@ -608,7 +608,7 @@ Http& Http::form_add_file(const std::string &name, const fs::path &path, const s } #ifdef WIN32 -// Tells libcurl to ignore certificate revocation checks in case of missing or offline distribution points for those SSL backends where such behavior is present. +// Tells libcurl to ignore certificate revocation checks in case of missing or offline distribution points for those SSL backends where such behavior is present. // This option is only supported for Schannel (the native Windows SSL library). Http& Http::ssl_revoke_best_effort(bool set) { @@ -746,6 +746,12 @@ void Http::set_extra_headers(std::map headers) extra_headers.swap(headers); } +std::map Http::get_extra_headers() +{ + std::lock_guard l(g_mutex); + return extra_headers; +} + bool Http::ca_file_supported() { ::CURL *curl = ::curl_easy_init(); diff --git a/src/slic3r/Utils/Http.hpp b/src/slic3r/Utils/Http.hpp index 5a6cabcc2..e3e388995 100644 --- a/src/slic3r/Utils/Http.hpp +++ b/src/slic3r/Utils/Http.hpp @@ -89,6 +89,7 @@ public: //BBS set global header for each http request static void set_extra_headers(std::map headers); + static std::map get_extra_headers(); ~Http(); diff --git a/src/slic3r/Utils/PresetUpdater.cpp b/src/slic3r/Utils/PresetUpdater.cpp index 51f20b4b4..676658aac 100644 --- a/src/slic3r/Utils/PresetUpdater.cpp +++ b/src/slic3r/Utils/PresetUpdater.cpp @@ -1168,6 +1168,16 @@ void PresetUpdater::priv::sync_plugins(std::string http_url, std::string plugin_ } } +#if defined(__WINDOWS__) + if (GUI::wxGetApp().is_running_on_arm64()) { + //set to arm64 for plugins + std::map current_headers = Slic3r::Http::get_extra_headers(); + current_headers["X-BBL-OS-Type"] = "win_arm64"; + + Slic3r::Http::set_extra_headers(current_headers); + BOOST_LOG_TRIVIAL(info) << boost::format("set X-BBL-OS-Type to win_arm64"); + } +#endif try { std::map resources { @@ -1178,6 +1188,16 @@ void PresetUpdater::priv::sync_plugins(std::string http_url, std::string plugin_ catch (std::exception& e) { BOOST_LOG_TRIVIAL(warning) << format("[BBL Updater] sync_plugins: %1%", e.what()); } +#if defined(__WINDOWS__) + if (GUI::wxGetApp().is_running_on_arm64()) { + //set back + std::map current_headers = Slic3r::Http::get_extra_headers(); + current_headers["X-BBL-OS-Type"] = "windows"; + + Slic3r::Http::set_extra_headers(current_headers); + BOOST_LOG_TRIVIAL(info) << boost::format("set X-BBL-OS-Type back to windows"); + } +#endif bool result = get_cached_plugins_version(cached_version, force_upgrade); if (result) {