mirror of
https://github.com/OrcaSlicer/OrcaSlicer.git
synced 2026-09-11 11:07:40 +00:00
Migrate legacy networking configuration to new network plugin versioning system. Remove legacy networking setting and update related GUI components to reflect the changes. Implement auto-migration for legacy libraries to ensure compatibility with the new versioning scheme.
This commit is contained in:
@@ -241,7 +241,17 @@ bool NetworkAgent::versioned_library_exists(const std::string& version)
|
||||
{
|
||||
if (version.empty()) return false;
|
||||
std::string path = get_versioned_library_path(version);
|
||||
return boost::filesystem::exists(path);
|
||||
|
||||
// Check if versioned library exists
|
||||
if (boost::filesystem::exists(path)) return true;
|
||||
|
||||
// For legacy version, also check if unversioned legacy library exists
|
||||
// (it will be auto-migrated to versioned format when loaded)
|
||||
if (version == BAMBU_NETWORK_AGENT_VERSION_LEGACY) {
|
||||
return legacy_library_exists();
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
bool NetworkAgent::legacy_library_exists()
|
||||
@@ -353,9 +363,50 @@ int NetworkAgent::initialize_network_module(bool using_backup, const std::string
|
||||
return -1;
|
||||
}
|
||||
|
||||
// Auto-migration: If loading legacy version and versioned library doesn't exist,
|
||||
// but unversioned legacy library does exist, rename it to versioned format
|
||||
if (version == BAMBU_NETWORK_AGENT_VERSION_LEGACY) {
|
||||
boost::filesystem::path versioned_path;
|
||||
boost::filesystem::path legacy_path;
|
||||
#if defined(_MSC_VER) || defined(_WIN32)
|
||||
versioned_path = plugin_folder / (std::string(BAMBU_NETWORK_LIBRARY) + "_" + version + ".dll");
|
||||
legacy_path = plugin_folder / (std::string(BAMBU_NETWORK_LIBRARY) + ".dll");
|
||||
#elif defined(__WXMAC__)
|
||||
versioned_path = plugin_folder / (std::string("lib") + std::string(BAMBU_NETWORK_LIBRARY) + "_" + version + ".dylib");
|
||||
legacy_path = plugin_folder / (std::string("lib") + std::string(BAMBU_NETWORK_LIBRARY) + ".dylib");
|
||||
#else
|
||||
versioned_path = plugin_folder / (std::string("lib") + std::string(BAMBU_NETWORK_LIBRARY) + "_" + version + ".so");
|
||||
legacy_path = plugin_folder / (std::string("lib") + std::string(BAMBU_NETWORK_LIBRARY) + ".so");
|
||||
#endif
|
||||
if (!boost::filesystem::exists(versioned_path) && boost::filesystem::exists(legacy_path)) {
|
||||
BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << ": auto-migrating unversioned legacy library to versioned format";
|
||||
|
||||
try {
|
||||
// Rename unversioned to versioned in the same folder (main or backup).
|
||||
boost::filesystem::rename(legacy_path, versioned_path);
|
||||
BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << ": successfully renamed " << legacy_path.string() << " to "
|
||||
<< versioned_path.string();
|
||||
} catch (const std::exception& e) {
|
||||
BOOST_LOG_TRIVIAL(error) << __FUNCTION__ << ": failed to rename legacy library: " << e.what();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Load versioned library
|
||||
#if defined(_MSC_VER) || defined(_WIN32)
|
||||
library = plugin_folder.string() + "\\" + std::string(BAMBU_NETWORK_LIBRARY) + "_" + version + ".dll";
|
||||
BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << ": loading versioned library at " << library;
|
||||
#else
|
||||
#if defined(__WXMAC__)
|
||||
std::string lib_ext = ".dylib";
|
||||
#else
|
||||
std::string lib_ext = ".so";
|
||||
#endif
|
||||
library = plugin_folder.string() + "/" + std::string("lib") + std::string(BAMBU_NETWORK_LIBRARY) + "_" + version + lib_ext;
|
||||
BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << ": loading versioned library at " << library;
|
||||
#endif
|
||||
|
||||
#if defined(_MSC_VER) || defined(_WIN32)
|
||||
wchar_t lib_wstr[256];
|
||||
memset(lib_wstr, 0, sizeof(lib_wstr));
|
||||
::MultiByteToWideChar(CP_UTF8, NULL, library.c_str(), strlen(library.c_str())+1, lib_wstr, sizeof(lib_wstr) / sizeof(lib_wstr[0]));
|
||||
@@ -378,15 +429,6 @@ int NetworkAgent::initialize_network_module(bool using_backup, const std::string
|
||||
netwoking_module = LoadLibrary(lib_wstr);
|
||||
}
|
||||
#else
|
||||
#if defined(__WXMAC__)
|
||||
std::string lib_ext = ".dylib";
|
||||
#else
|
||||
std::string lib_ext = ".so";
|
||||
#endif
|
||||
|
||||
library = plugin_folder.string() + "/" + std::string("lib") + std::string(BAMBU_NETWORK_LIBRARY) + "_" + version + lib_ext;
|
||||
BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << ": loading versioned library at " << library;
|
||||
|
||||
netwoking_module = dlopen(library.c_str(), RTLD_LAZY);
|
||||
if (!netwoking_module) {
|
||||
char* dll_error = dlerror();
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
#include <map>
|
||||
#include <vector>
|
||||
|
||||
#include "libslic3r/AppConfig.hpp"
|
||||
extern std::string g_log_folder;
|
||||
extern std::string g_log_start_time;
|
||||
|
||||
@@ -98,7 +99,6 @@ namespace BBL {
|
||||
#define BAMBU_NETWORK_LIBRARY "bambu_networking"
|
||||
#define BAMBU_NETWORK_AGENT_NAME "bambu_network_agent"
|
||||
|
||||
#define BAMBU_NETWORK_AGENT_VERSION_LEGACY "01.10.01.01"
|
||||
|
||||
//iot preset type strings
|
||||
#define IOT_PRINTER_TYPE_STRING "printer"
|
||||
@@ -318,6 +318,7 @@ static const NetworkLibraryVersion AVAILABLE_NETWORK_VERSIONS[] = {
|
||||
{"02.03.00.62", "02.03.00.62", nullptr, true, nullptr},
|
||||
{"02.01.01.52", "02.01.01.52", nullptr, false, nullptr},
|
||||
{"02.00.02.50", "02.00.02.50", nullptr, false, "This version may crash on startup due to Bambu Lab's signature verification."},
|
||||
{BAMBU_NETWORK_AGENT_VERSION_LEGACY, BAMBU_NETWORK_AGENT_VERSION_LEGACY " (legacy)", nullptr, false, "Legacy version - may not support newer firmware features. Only use if you have issues with modern versions."},
|
||||
};
|
||||
|
||||
static const size_t AVAILABLE_NETWORK_VERSIONS_COUNT = sizeof(AVAILABLE_NETWORK_VERSIONS) / sizeof(AVAILABLE_NETWORK_VERSIONS[0]);
|
||||
|
||||
Reference in New Issue
Block a user