mirror of
https://github.com/OrcaSlicer/OrcaSlicer.git
synced 2026-09-11 19:17:33 +00:00
Don't keep a separate use_legacy_network which is error-prone. Always infer from installed plugin version. (OrcaSlicer/OrcaSlicer#14441)
This commit is contained in:
@@ -1174,7 +1174,7 @@ std::string GUI_App::get_plugin_url(std::string name, std::string country_code)
|
|||||||
std::string url = get_http_url(country_code);
|
std::string url = get_http_url(country_code);
|
||||||
|
|
||||||
std::string curr_version;
|
std::string curr_version;
|
||||||
if (NetworkAgent::use_legacy_network) {
|
if (use_legacy_network_plugin()) {
|
||||||
curr_version = BAMBU_NETWORK_AGENT_VERSION_LEGACY;
|
curr_version = BAMBU_NETWORK_AGENT_VERSION_LEGACY;
|
||||||
} else if (name == "plugins" && app_config) {
|
} else if (name == "plugins" && app_config) {
|
||||||
std::string user_version = app_config->get_network_plugin_version();
|
std::string user_version = app_config->get_network_plugin_version();
|
||||||
@@ -1229,7 +1229,7 @@ int GUI_App::download_plugin(std::string name, std::string package_name, Install
|
|||||||
// Determine OS type for plugin download (must be set per-request since global
|
// Determine OS type for plugin download (must be set per-request since global
|
||||||
// extra headers are no longer initialised on this branch).
|
// extra headers are no longer initialised on this branch).
|
||||||
#if defined(__WINDOWS__)
|
#if defined(__WINDOWS__)
|
||||||
std::string os_type = (is_running_on_arm64() && !NetworkAgent::use_legacy_network) ? "windows_arm" : "windows";
|
std::string os_type = (is_running_on_arm64() && !use_legacy_network_plugin()) ? "windows_arm" : "windows";
|
||||||
#elif defined(__APPLE__)
|
#elif defined(__APPLE__)
|
||||||
std::string os_type = "macos";
|
std::string os_type = "macos";
|
||||||
#elif defined(__linux__)
|
#elif defined(__linux__)
|
||||||
@@ -1908,7 +1908,7 @@ bool GUI_App::check_networking_version()
|
|||||||
}
|
}
|
||||||
|
|
||||||
std::string studio_ver;
|
std::string studio_ver;
|
||||||
if (NetworkAgent::use_legacy_network) {
|
if (use_legacy_network_plugin()) {
|
||||||
studio_ver = BAMBU_NETWORK_AGENT_VERSION_LEGACY;
|
studio_ver = BAMBU_NETWORK_AGENT_VERSION_LEGACY;
|
||||||
} else if (app_config) {
|
} else if (app_config) {
|
||||||
std::string user_version = app_config->get_network_plugin_version();
|
std::string user_version = app_config->get_network_plugin_version();
|
||||||
@@ -1930,6 +1930,11 @@ bool GUI_App::check_networking_version()
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool GUI_App::use_legacy_network_plugin() const
|
||||||
|
{
|
||||||
|
return app_config && BBLNetworkPlugin::is_legacy_version(app_config->get_network_plugin_version());
|
||||||
|
}
|
||||||
|
|
||||||
bool GUI_App::is_compatibility_version()
|
bool GUI_App::is_compatibility_version()
|
||||||
{
|
{
|
||||||
BOOST_LOG_TRIVIAL(info) << __FUNCTION__<< boost::format(": m_networking_compatible=%1%")%m_networking_compatible;
|
BOOST_LOG_TRIVIAL(info) << __FUNCTION__<< boost::format(": m_networking_compatible=%1%")%m_networking_compatible;
|
||||||
@@ -3024,9 +3029,8 @@ bool GUI_App::on_init_inner()
|
|||||||
|
|
||||||
// Orca: select network plugin version based on configured version string
|
// Orca: select network plugin version based on configured version string
|
||||||
std::string configured_version = app_config->get_network_plugin_version();
|
std::string configured_version = app_config->get_network_plugin_version();
|
||||||
NetworkAgent::use_legacy_network = (configured_version == BAMBU_NETWORK_AGENT_VERSION_LEGACY);
|
|
||||||
BOOST_LOG_TRIVIAL(info) << "Network plugin mode: "
|
BOOST_LOG_TRIVIAL(info) << "Network plugin mode: "
|
||||||
<< (NetworkAgent::use_legacy_network ? ("legacy (version: " + std::string(BAMBU_NETWORK_AGENT_VERSION_LEGACY) + ")") : ("modern (version: " + configured_version + ")"));
|
<< (use_legacy_network_plugin() ? ("legacy (version: " + std::string(BAMBU_NETWORK_AGENT_VERSION_LEGACY) + ")") : ("modern (version: " + configured_version + ")"));
|
||||||
// Force legacy network plugin if debugger attached
|
// Force legacy network plugin if debugger attached
|
||||||
// See https://github.com/bambulab/BambuStudio/issues/6726
|
// See https://github.com/bambulab/BambuStudio/issues/6726
|
||||||
/* if (!NetworkAgent::use_legacy_network) {
|
/* if (!NetworkAgent::use_legacy_network) {
|
||||||
@@ -3305,7 +3309,7 @@ void GUI_App::copy_network_if_available()
|
|||||||
fs::remove(network_library);
|
fs::remove(network_library);
|
||||||
BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << ": Copying network library from " << network_library << " to " << network_library_dst << " successfully.";
|
BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << ": Copying network library from " << network_library << " to " << network_library_dst << " successfully.";
|
||||||
|
|
||||||
app_config->set(SETTING_NETWORK_PLUGIN_VERSION, cached_version);
|
app_config->set_network_plugin_version(cached_version);
|
||||||
app_config->save();
|
app_config->save();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -3370,7 +3374,7 @@ bool GUI_App::on_init_network(bool try_backup)
|
|||||||
if (config_base != loaded_version) {
|
if (config_base != loaded_version) {
|
||||||
BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << ": syncing config version from " << config_version << " to loaded "
|
BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << ": syncing config version from " << config_version << " to loaded "
|
||||||
<< loaded_version;
|
<< loaded_version;
|
||||||
app_config->set(SETTING_NETWORK_PLUGIN_VERSION, loaded_version);
|
app_config->set_network_plugin_version(loaded_version);
|
||||||
app_config->save();
|
app_config->save();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -3496,7 +3500,7 @@ bool GUI_App::on_init_network(bool try_backup)
|
|||||||
m_user_manager = new Slic3r::UserManager();
|
m_user_manager = new Slic3r::UserManager();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (should_load_networking_plugin && m_networking_compatible && !NetworkAgent::use_legacy_network) {
|
if (should_load_networking_plugin && m_networking_compatible && !use_legacy_network_plugin()) {
|
||||||
app_config->clear_remind_network_update_later();
|
app_config->clear_remind_network_update_later();
|
||||||
|
|
||||||
if (has_network_update_available()) {
|
if (has_network_update_available()) {
|
||||||
|
|||||||
@@ -742,6 +742,7 @@ public:
|
|||||||
int install_plugin(std::string name, std::string package_name, InstallProgressFn pro_fn = nullptr, WasCancelledFn cancel_fn = nullptr);
|
int install_plugin(std::string name, std::string package_name, InstallProgressFn pro_fn = nullptr, WasCancelledFn cancel_fn = nullptr);
|
||||||
std::string get_http_url(std::string country_code, std::string path = {});
|
std::string get_http_url(std::string country_code, std::string path = {});
|
||||||
std::string get_model_http_url(std::string country_code);
|
std::string get_model_http_url(std::string country_code);
|
||||||
|
bool use_legacy_network_plugin() const;
|
||||||
bool is_compatibility_version();
|
bool is_compatibility_version();
|
||||||
bool check_networking_version();
|
bool check_networking_version();
|
||||||
void cancel_networking_install();
|
void cancel_networking_install();
|
||||||
|
|||||||
@@ -1251,26 +1251,17 @@ wxBoxSizer *PreferencesDialog::create_item_network_plugin_version(wxString title
|
|||||||
old_version = get_latest_network_version();
|
old_version = get_latest_network_version();
|
||||||
}
|
}
|
||||||
|
|
||||||
app_config->set(SETTING_NETWORK_PLUGIN_VERSION, new_version);
|
app_config->set_network_plugin_version(new_version);
|
||||||
app_config->save();
|
app_config->save();
|
||||||
|
|
||||||
if (new_version != old_version) {
|
if (new_version != old_version) {
|
||||||
BOOST_LOG_TRIVIAL(info) << "Network plugin version changed from " << old_version << " to " << new_version;
|
BOOST_LOG_TRIVIAL(info) << "Network plugin version changed from " << old_version << " to " << new_version;
|
||||||
|
|
||||||
// Update the use_legacy_network flag immediately
|
|
||||||
bool is_legacy = (new_version == BAMBU_NETWORK_AGENT_VERSION_LEGACY);
|
|
||||||
bool was_legacy = (old_version == BAMBU_NETWORK_AGENT_VERSION_LEGACY);
|
|
||||||
if (is_legacy != was_legacy) {
|
|
||||||
Slic3r::NetworkAgent::use_legacy_network = is_legacy;
|
|
||||||
BOOST_LOG_TRIVIAL(info) << "Updated use_legacy_network flag to " << is_legacy;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!selected_ver.warning.empty()) {
|
if (!selected_ver.warning.empty()) {
|
||||||
MessageDialog warn_dlg(this, wxString::FromUTF8(selected_ver.warning), _L("Warning"), wxOK | wxCANCEL | wxICON_WARNING);
|
MessageDialog warn_dlg(this, wxString::FromUTF8(selected_ver.warning), _L("Warning"), wxOK | wxCANCEL | wxICON_WARNING);
|
||||||
if (warn_dlg.ShowModal() != wxID_OK) {
|
if (warn_dlg.ShowModal() != wxID_OK) {
|
||||||
app_config->set(SETTING_NETWORK_PLUGIN_VERSION, old_version);
|
app_config->set_network_plugin_version(old_version);
|
||||||
app_config->save();
|
app_config->save();
|
||||||
Slic3r::NetworkAgent::use_legacy_network = was_legacy;
|
|
||||||
e.Skip();
|
e.Skip();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -32,8 +32,6 @@ int invoke_on_all_cloud_agents(const std::map<std::string, std::shared_ptr<IClou
|
|||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
bool NetworkAgent::use_legacy_network = true;
|
|
||||||
|
|
||||||
// ============================================================================
|
// ============================================================================
|
||||||
// Static methods - delegate to BBLNetworkPlugin
|
// Static methods - delegate to BBLNetworkPlugin
|
||||||
// ============================================================================
|
// ============================================================================
|
||||||
|
|||||||
@@ -36,7 +36,6 @@ public:
|
|||||||
#endif
|
#endif
|
||||||
static std::string get_version();
|
static std::string get_version();
|
||||||
static void* get_network_function(const char* name);
|
static void* get_network_function(const char* name);
|
||||||
static bool use_legacy_network;
|
|
||||||
|
|
||||||
static NetworkLibraryLoadError get_load_error();
|
static NetworkLibraryLoadError get_load_error();
|
||||||
static void clear_load_error();
|
static void clear_load_error();
|
||||||
|
|||||||
@@ -836,7 +836,7 @@ void PresetUpdater::priv::sync_plugins(std::string http_url, std::string plugin_
|
|||||||
BOOST_LOG_TRIVIAL(info) << "non need to sync plugins for there is no plugins currently.";
|
BOOST_LOG_TRIVIAL(info) << "non need to sync plugins for there is no plugins currently.";
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
std::string curr_version = NetworkAgent::use_legacy_network ? BAMBU_NETWORK_AGENT_VERSION_LEGACY : get_latest_network_version();
|
std::string curr_version = GUI::wxGetApp().use_legacy_network_plugin() ? BAMBU_NETWORK_AGENT_VERSION_LEGACY : get_latest_network_version();
|
||||||
std::string using_version = curr_version.substr(0, 9) + "00";
|
std::string using_version = curr_version.substr(0, 9) + "00";
|
||||||
|
|
||||||
std::string cached_version;
|
std::string cached_version;
|
||||||
@@ -931,7 +931,7 @@ void PresetUpdater::priv::sync_plugins(std::string http_url, std::string plugin_
|
|||||||
}
|
}
|
||||||
|
|
||||||
#if defined(__WINDOWS__)
|
#if defined(__WINDOWS__)
|
||||||
if (GUI::wxGetApp().is_running_on_arm64() && !NetworkAgent::use_legacy_network) {
|
if (GUI::wxGetApp().is_running_on_arm64() && !GUI::wxGetApp().use_legacy_network_plugin()) {
|
||||||
//set to arm64 for plugins
|
//set to arm64 for plugins
|
||||||
std::map<std::string, std::string> current_headers = Slic3r::Http::get_extra_headers();
|
std::map<std::string, std::string> current_headers = Slic3r::Http::get_extra_headers();
|
||||||
current_headers["X-BBL-OS-Type"] = "windows_arm";
|
current_headers["X-BBL-OS-Type"] = "windows_arm";
|
||||||
@@ -951,7 +951,7 @@ void PresetUpdater::priv::sync_plugins(std::string http_url, std::string plugin_
|
|||||||
BOOST_LOG_TRIVIAL(warning) << format("[Orca Updater] sync_plugins: %1%", e.what());
|
BOOST_LOG_TRIVIAL(warning) << format("[Orca Updater] sync_plugins: %1%", e.what());
|
||||||
}
|
}
|
||||||
#if defined(__WINDOWS__)
|
#if defined(__WINDOWS__)
|
||||||
if (GUI::wxGetApp().is_running_on_arm64() && !NetworkAgent::use_legacy_network) {
|
if (GUI::wxGetApp().is_running_on_arm64() && !GUI::wxGetApp().use_legacy_network_plugin()) {
|
||||||
//set back
|
//set back
|
||||||
std::map<std::string, std::string> current_headers = Slic3r::Http::get_extra_headers();
|
std::map<std::string, std::string> current_headers = Slic3r::Http::get_extra_headers();
|
||||||
current_headers["X-BBL-OS-Type"] = "windows";
|
current_headers["X-BBL-OS-Type"] = "windows";
|
||||||
|
|||||||
Reference in New Issue
Block a user