Add option to toggle between legacy and new network plugins

This commit is contained in:
Noisyfox
2025-05-01 16:23:56 +08:00
parent e4d8c2e440
commit 461d42635f
4 changed files with 26 additions and 0 deletions

View File

@@ -254,6 +254,9 @@ void AppConfig::set_defaults()
if (get("stealth_mode").empty()) {
set_bool("stealth_mode", false);
}
if (get("legacy_networking").empty()) {
set_bool("legacy_networking", true);
}
if(get("check_stable_update_only").empty()) {
set_bool("check_stable_update_only", false);

View File

@@ -2516,6 +2516,20 @@ bool GUI_App::on_init_inner()
std::map<std::string, std::string> extra_headers = get_extra_header();
Slic3r::Http::set_extra_headers(extra_headers);
// Orca: select network plugin version
NetworkAgent::use_legacy_network = app_config->get_bool("legacy_networking");
// Force legacy network plugin if debugger attached
// See https://github.com/bambulab/BambuStudio/issues/6726
if (!NetworkAgent::use_legacy_network) {
bool debugger_attached = false;
#ifdef __WINDOWS__
debugger_attached = IsDebuggerPresent();
#endif
if (debugger_attached) {
NetworkAgent::use_legacy_network = true;
wxMessageBox("Force using legacy bambu networking plugin because debugger is attached! If the app terminates itself immediately, please delete installed plugin and try again!");
}
}
copy_network_if_available();
on_init_network();

View File

@@ -804,6 +804,7 @@ wxBoxSizer *PreferencesDialog::create_item_checkbox(wxString title, wxWindow *pa
if (pbool) {
GUI::wxGetApp().CallAfter([] { GUI::wxGetApp().ShowDownNetPluginDlg(); });
}
if (m_legacy_networking_ckeckbox != nullptr) { m_legacy_networking_ckeckbox->Enable(pbool); }
}
#endif // __WXMSW__
@@ -834,6 +835,11 @@ wxBoxSizer *PreferencesDialog::create_item_checkbox(wxString title, wxWindow *pa
//// for debug mode
if (param == "developer_mode") { m_developer_mode_ckeckbox = checkbox; }
if (param == "internal_developer_mode") { m_internal_developer_mode_ckeckbox = checkbox; }
if (param == "legacy_networking") {
m_legacy_networking_ckeckbox = checkbox;
bool pbool = app_config->get_bool("installed_networking");
checkbox->Enable(pbool);
}
checkbox->SetToolTip(tooltip);
@@ -1199,6 +1205,7 @@ wxWindow* PreferencesDialog::create_general_page()
auto item_stealth_mode = create_item_checkbox(_L("Stealth Mode"), page, _L("This stops the transmission of data to Bambu's cloud services. Users who don't use BBL machines or use LAN mode only can safely turn on this function."), 50, "stealth_mode");
auto item_enable_plugin = create_item_checkbox(_L("Enable network plugin"), page, _L("Enable network plugin"), 50, "installed_networking");
auto item_legacy_network_plugin = create_item_checkbox(_L("Use legacy network plugin (Take effect after restarting Orca)"), page, _L("Disable to use latest network plugin that support new BambuLab firmwares."), 50, "legacy_networking");
auto item_check_stable_version_only = create_item_checkbox(_L("Check for stable updates only"), page, _L("Check for stable updates only"), 50, "check_stable_update_only");
std::vector<wxString> Units = {_L("Metric") + " (mm, g)", _L("Imperial") + " (in, oz)"};
@@ -1322,6 +1329,7 @@ wxWindow* PreferencesDialog::create_general_page()
sizer_page->Add(item_check_stable_version_only, 0, wxTOP, FromDIP(3));
sizer_page->Add(item_stealth_mode, 0, wxTOP, FromDIP(3));
sizer_page->Add(item_enable_plugin, 0, wxTOP, FromDIP(3));
sizer_page->Add(item_legacy_network_plugin, 0, wxTOP, FromDIP(3));
#ifdef _WIN32
sizer_page->Add(title_associate_file, 0, wxTOP| wxEXPAND, FromDIP(20));
sizer_page->Add(item_associate_3mf, 0, wxTOP, FromDIP(3));

View File

@@ -93,6 +93,7 @@ public:
::CheckBox * m_internal_developer_mode_ckeckbox = {nullptr};
::CheckBox * m_dark_mode_ckeckbox = {nullptr};
::TextInput *m_backup_interval_textinput = {nullptr};
::CheckBox * m_legacy_networking_ckeckbox = {nullptr};
wxString m_developer_mode_def;
wxString m_internal_developer_mode_def;