This commit is contained in:
PJarczak 2026-04-22 01:21:28 +02:00
parent a625e1acfc
commit c27c6a9a88
6 changed files with 67 additions and 19 deletions

View file

@ -2390,7 +2390,7 @@ std::map<std::string, std::string> GUI_App::get_extra_header()
extra_headers.insert(std::make_pair("X-BBL-Client-Type", "slicer"));
bool use_bambustudio_identity = false;
#if defined(__WINDOWS__)
#if defined(__WINDOWS__) || defined(__APPLE__)
use_bambustudio_identity = Slic3r::PJarczakLinuxBridge::enabled();
#elif defined(__LINUX__)
use_bambustudio_identity = true;
@ -2417,7 +2417,11 @@ std::map<std::string, std::string> GUI_App::get_extra_header()
}
#endif
#elif defined(__APPLE__)
extra_headers.insert(std::make_pair("X-BBL-OS-Type", "macos"));
if (Slic3r::PJarczakLinuxBridge::enabled()) {
extra_headers.insert(std::make_pair("X-BBL-OS-Type", Slic3r::PJarczakLinuxBridge::forced_download_os_type()));
} else {
extra_headers.insert(std::make_pair("X-BBL-OS-Type", "macos"));
}
#elif defined(__LINUX__)
extra_headers.insert(std::make_pair("X-BBL-OS-Type", "linux"));
#endif

View file

@ -5413,6 +5413,8 @@ Plater::priv::priv(Plater *q, MainFrame *main_frame)
Plater::priv::~priv()
{
partplate_list.clear(true, true);
if (config != nullptr)
delete config;
// Saves the database of visited (already shown) hints into hints.ini.

View file

@ -28,24 +28,46 @@ void set_bridge_preflight_reason(std::string* detail, const std::string& value)
bool bridge_payload_preflight(const boost::filesystem::path& plugin_folder, std::string* detail)
{
const std::string required_files[] = {
const std::string common_required_files[] = {
Slic3r::PJarczakLinuxBridge::bridge_network_current_dir_name(),
Slic3r::PJarczakLinuxBridge::host_executable_file_name(),
"pjarczak_bambu_linux_host_abi1",
"pjarczak_bambu_linux_host_abi0",
Slic3r::PJarczakLinuxBridge::windows_wsl_distro_file_name(),
Slic3r::PJarczakLinuxBridge::windows_wsl_import_script_file_name(),
Slic3r::PJarczakLinuxBridge::windows_wsl_validate_script_file_name(),
Slic3r::PJarczakLinuxBridge::windows_wsl_bootstrap_script_file_name(),
Slic3r::PJarczakLinuxBridge::windows_wsl_rootfs_file_name(),
Slic3r::PJarczakLinuxBridge::windows_plugin_cache_subdir_file_name(),
Slic3r::PJarczakLinuxBridge::linux_network_library_name(),
Slic3r::PJarczakLinuxBridge::linux_source_library_name(),
"ca-certificates.crt",
"slicer_base64.cer"
};
for (const auto& file_name : required_files) {
for (const auto& file_name : common_required_files) {
const auto candidate = plugin_folder / file_name;
if (!boost::filesystem::exists(candidate) || boost::filesystem::is_directory(candidate)) {
set_bridge_preflight_reason(detail, "missing required bridge runtime file: " + file_name);
return false;
}
}
#if defined(_MSC_VER) || defined(_WIN32)
const std::string platform_required_files[] = {
Slic3r::PJarczakLinuxBridge::windows_wsl_distro_file_name(),
Slic3r::PJarczakLinuxBridge::windows_wsl_import_script_file_name(),
Slic3r::PJarczakLinuxBridge::windows_wsl_validate_script_file_name(),
Slic3r::PJarczakLinuxBridge::windows_wsl_bootstrap_script_file_name(),
Slic3r::PJarczakLinuxBridge::windows_wsl_rootfs_file_name(),
Slic3r::PJarczakLinuxBridge::windows_plugin_cache_subdir_file_name()
};
#elif defined(__WXMAC__) || defined(__APPLE__)
const std::string platform_required_files[] = {
Slic3r::PJarczakLinuxBridge::mac_host_wrapper_file_name(),
Slic3r::PJarczakLinuxBridge::mac_runtime_install_script_file_name(),
Slic3r::PJarczakLinuxBridge::mac_runtime_verify_script_file_name(),
Slic3r::PJarczakLinuxBridge::mac_lima_instance_file_name()
};
#else
const std::string platform_required_files[] = {};
#endif
for (const auto& file_name : platform_required_files) {
const auto candidate = plugin_folder / file_name;
if (!boost::filesystem::exists(candidate) || boost::filesystem::is_directory(candidate)) {
set_bridge_preflight_reason(detail, "missing required bridge runtime file: " + file_name);

View file

@ -191,7 +191,7 @@ Http::priv::priv(const std::string &url)
::curl_easy_setopt(curl, CURLOPT_DEBUGFUNCTION, log_trace);
::curl_easy_setopt(curl, CURLOPT_URL, url.c_str()); // curl makes a copy internally
std::string pjarczak_user_agent = SLIC3R_APP_NAME "/" SoftFever_VERSION;
#if defined(__WINDOWS__)
#if defined(__WINDOWS__) || defined(__APPLE__)
if (Slic3r::PJarczakLinuxBridge::enabled())
pjarczak_user_agent = std::string("BambuStudio/") + Slic3r::PJarczakLinuxBridge::forced_client_version();
#elif defined(__LINUX__)

View file

@ -945,10 +945,11 @@ void PresetUpdater::priv::sync_plugins(std::string http_url, std::string plugin_
}
}
#if defined(__WINDOWS__)
#if defined(__WINDOWS__) || defined(__APPLE__)
std::map<std::string, std::string> previous_headers = Slic3r::Http::get_extra_headers();
bool plugin_headers_overridden = false;
#if defined(__WINDOWS__)
if (Slic3r::PJarczakLinuxBridge::enabled()) {
std::map<std::string, std::string> current_headers = previous_headers;
current_headers["X-BBL-OS-Type"] = Slic3r::PJarczakLinuxBridge::forced_download_os_type();
@ -963,6 +964,16 @@ void PresetUpdater::priv::sync_plugins(std::string http_url, std::string plugin_
BOOST_LOG_TRIVIAL(info) << boost::format("set X-BBL-OS-Type to windows_arm");
plugin_headers_overridden = true;
}
#else
if (Slic3r::PJarczakLinuxBridge::enabled()) {
std::map<std::string, std::string> current_headers = previous_headers;
current_headers["X-BBL-OS-Type"] = Slic3r::PJarczakLinuxBridge::forced_download_os_type();
current_headers["X-BBL-Client-Name"] = "BambuStudio";
Slic3r::Http::set_extra_headers(current_headers);
BOOST_LOG_TRIVIAL(info) << boost::format("set X-BBL-OS-Type to %1% for bridge plugin sync") % Slic3r::PJarczakLinuxBridge::forced_download_os_type();
plugin_headers_overridden = true;
}
#endif
#endif
try {
std::map<std::string, Resource> resources
@ -974,7 +985,7 @@ void PresetUpdater::priv::sync_plugins(std::string http_url, std::string plugin_
catch (std::exception& e) {
BOOST_LOG_TRIVIAL(warning) << format("[Orca Updater] sync_plugins: %1%", e.what());
}
#if defined(__WINDOWS__)
#if defined(__WINDOWS__) || defined(__APPLE__)
if (plugin_headers_overridden) {
Slic3r::Http::set_extra_headers(previous_headers);
BOOST_LOG_TRIVIAL(info) << "restored plugin sync headers";

View file

@ -50,8 +50,7 @@ trim_file() {
if [[ ! -f "$path" ]]; then
return 1
fi
LC_ALL=C tr -d '
' < "$path" | head -n 1 | sed 's/^[[:space:]]*//;s/[[:space:]]*$//'
LC_ALL=C tr -d ' ' < "$path" | head -n 1 | sed 's/^[[:space:]]*//;s/[[:space:]]*$//'
}
find_limactl() {
@ -79,9 +78,19 @@ find_limactl() {
return 1
}
resolve_lima_version() {
if [[ -n "${PJARCZAK_LIMA_VERSION:-}" ]]; then
printf '%s
' "$PJARCZAK_LIMA_VERSION"
return 0
fi
curl -fsSL https://api.github.com/repos/lima-vm/lima/releases/latest | awk -F'"' '/"tag_name"[[:space:]]*:/ { print $4; exit }'
}
install_lima_binary_locally() {
local version
version=$(curl -fsSL https://api.github.com/repos/lima-vm/lima/releases/latest | sed -n 's/.*"tag_name"[[:space:]]*:[[:space:]]*"\([^"]*\)".*//p' | head -n 1)
version=$(resolve_lima_version)
if [[ -z "$version" ]]; then
echo "failed to resolve latest Lima version from GitHub API" >&2
return 1
@ -110,10 +119,10 @@ install_lima_binary_locally() {
tmpdir=$(mktemp -d)
trap 'rm -rf "$tmpdir"' RETURN
curl -fL "$base_url/$main_archive" -o "$tmpdir/$main_archive"
curl -fL --retry 3 --retry-delay 2 "$base_url/$main_archive" -o "$tmpdir/$main_archive"
tar -xzf "$tmpdir/$main_archive" -C "$LOCAL_LIMA_ROOT"
if curl -fL "$base_url/$guest_archive" -o "$tmpdir/$guest_archive"; then
if curl -fL --retry 3 --retry-delay 2 "$base_url/$guest_archive" -o "$tmpdir/$guest_archive"; then
tar -xzf "$tmpdir/$guest_archive" -C "$LOCAL_LIMA_ROOT"
fi
@ -188,9 +197,9 @@ if [[ -z "$INSTANCE" ]]; then
INSTANCE="orcaslicer-bambu-network"
fi
copy_runtime_payload "$PLUGIN_DIR" "$RUNTIME_DIR"
ensure_lima_installed
maybe_install_rosetta
copy_runtime_payload "$PLUGIN_DIR" "$RUNTIME_DIR"
START_ARGS=(start "--name=${INSTANCE}" --tty=false --mount-writable)
MACOS_MAJOR=$(sw_vers -productVersion | awk -F. '{print $1}')