Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: improved stealth in stealth mode #6110

Open
wants to merge 9 commits into
base: main
Choose a base branch
from
Open
3 changes: 3 additions & 0 deletions resources/web/data/text.js
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,9 @@ var LangText = {
orca3: "Stealth Mode",
orca4: "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.",
orca5: "Enable Stealth Mode.",
orca6: "Sync on start",
orca7: "OrcaSlicer will check for the latest Bambu Network plug-in version and latest Bambu printer configuration on application start. Uncheck the following option if you do not want this. Users who don't use BBL machines can safely turn this off",
orca8: "Sync latest Bambu Network plug-in and printer configuration on application start",
},
ca_ES: {
t1: "Benvingut a Orca Slicer",
Expand Down
2 changes: 1 addition & 1 deletion resources/web/guide/5/5.css
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
line-height: 30px;
}

#InstallCheck
#InstallCheck, #SyncCheck
{
width: 30px;
}
Expand Down
8 changes: 8 additions & 0 deletions resources/web/guide/5/5.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,17 @@ function SendInstallPluginCheck()
tSend['data']['action']=nVal;

SendWXMessage( JSON.stringify(tSend) );

return true;
}

function GotoNextPluginPage()
{
let bRet=SendInstallPluginCheck();

if(bRet)
window.location.href="../7orca/index.html";
}

function FinishGuide()
{
Expand Down
4 changes: 2 additions & 2 deletions resources/web/guide/5/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,11 @@

<div id="CheckArea"><input id="InstallCheck" onClick="SendInstallPluginCheck()" type="checkbox"><a tid="t69" class="trans TextS1">Install Bambu Network Plug-in. </a></div>
<div id="RestartText" tid="t70" class="trans" ></div>

</div>
<div id="AcceptArea">
<div class="GrayBtn trans" tid="t8" id="PreBtn" onclick="window.history.back()">Back</div>
<div class="NormalBtn trans" tid="t25" id="AcceptBtn" onclick="FinishGuide()">Finish</div>
<div class="NormalBtn trans" tid="t9" id="AcceptBtn" onclick="GotoNextPluginPage()">Next</div>
</div>
</body>
</html>
33 changes: 33 additions & 0 deletions resources/web/guide/7orca/7orca.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@

#Content
{
padding:0% 15%;
}

#FeatureText
{
line-height: 30px;
margin-top: 10mm;
}


#CheckArea
{
margin-top:10mm;
line-height: 30px;
}

#SyncCheck
{
width: 30px;
}

#RestartText
{
padding-left:30px;
}

.TextPoint
{
font-size:14px;
}
47 changes: 47 additions & 0 deletions resources/web/guide/7orca/7orca.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@

function OnInit()
{
TranslatePage();

SendStealthModeCheck();
}



function SendSyncOnStartCheck()
{
let nVal="no";
if( $('#SyncCheck').is(':checked') )
nVal="yes";

var tSend={};
tSend['sequence_id']=Math.round(new Date() / 1000);
tSend['command']="save_sync_on_start";
tSend['data']={};
tSend['data']['action']=nVal;

SendWXMessage( JSON.stringify(tSend) );

return true;
}

function GotoNetPluginPage()
{
let bRet=SendStealthModeCheck();

if(bRet)
window.location.href="../5/index.html";
}

function FinishGuide()
{
var tSend={};
tSend['sequence_id']=Math.round(new Date() / 1000);
tSend['command']="user_guide_finish";
tSend['data']={};
tSend['data']['action']="finish";

SendWXMessage( JSON.stringify(tSend) );

//window.location.href="../6/index.html";
}
36 changes: 36 additions & 0 deletions resources/web/guide/7orca/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="Cache-Control" content="max-age=7200" />
<title>引导_P1</title>
<link rel="stylesheet" type="text/css" href="../css/common.css" />
<link rel="stylesheet" type="text/css" href="../css/dark.css" />
<link rel="stylesheet" type="text/css" href="7orca.css" />
<script type="text/javascript" src="../js/jquery-2.1.1.min.js"></script>
<script type="text/javascript" src="../js/json2.js"></script>
<script type="text/javascript" src="../../data/text.js"></script>
<script type="text/javascript" src="../js/globalapi.js"></script>
<script type="text/javascript" src="../js/common.js"></script>
<script type="text/javascript" src="7orca.js"></script>
</head>
<body onLoad="OnInit()">
<div id="Title">
<div class="trans" tid="orca6">Sync on start</div>
</div>
<div id="Content">

<div id="FeatureText">
<div tid="orca7" class="trans">OrcaSlicer will check for the latest Bambu Network plug-in version and latest Bambu printer configuration on application start. Uncheck the following option if you do not want this. Users who don't use BBL machines can safely turn this off</div>
</div>

<label id="CheckArea"><input id="SyncCheck" onClick="SendSyncOnStartCheck()" type="checkbox" checked><a tid="orca8" class="trans TextS1">Sync latest Bambu Network plug-in and printer configuration on application start</a></label>
<div id="RestartText" tid="t70" class="trans" ></div>

</div>
<div id="AcceptArea">
<div class="GrayBtn trans" tid="t8" id="PreBtn" onclick="window.history.back()">Back</div>
<div class="NormalBtn trans" tid="t25" id="AcceptBtn" onclick="FinishGuide()">Finish</div>
</div>
</body>
</html>
5 changes: 5 additions & 0 deletions src/libslic3r/AppConfig.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -255,6 +255,11 @@ void AppConfig::set_defaults()
set_bool("stealth_mode", false);
}

if (get("sync_on_start").empty()) {
// set default value as true to avoid breaking change for existing users
set_bool("sync_on_start", true);
}

if(get("check_stable_update_only").empty()) {
set_bool("check_stable_update_only", false);
}
Expand Down
20 changes: 16 additions & 4 deletions src/slic3r/GUI/GUI_App.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -965,11 +965,12 @@ void GUI_App::post_init()
CallAfter([this] {
bool cw_showed = this->config_wizard_startup();

std::string http_url = get_http_url(app_config->get_country_code());
std::string http_url = get_http_url(app_config->get_country_code(), {}, true);
std::string language = GUI::into_u8(current_language_code());
std::string network_ver = Slic3r::NetworkAgent::get_version();
bool sys_preset = app_config->get("sync_system_preset") == "true";
this->preset_updater->sync(http_url, language, network_ver, sys_preset ? preset_bundle : nullptr);
bool sys_preset = app_config->get_bool("sync_system_preset");
bool sync_on_start = app_config->get_bool("sync_on_start");
this->preset_updater->sync(http_url, language, network_ver, sys_preset ? preset_bundle : nullptr, sync_on_start);

this->check_new_version_sf();
if (is_user_login() && !app_config->get_stealth_mode()) {
Expand Down Expand Up @@ -1104,8 +1105,12 @@ void GUI_App::shutdown()
}


std::string GUI_App::get_http_url(std::string country_code, std::string path)
std::string GUI_App::get_http_url(std::string country_code, std::string path, bool override_stealth_mode)
{
if (app_config->get_stealth_mode() && !override_stealth_mode) {
return "";
}

std::string url;
if (country_code == "US") {
url = "https://api.bambulab.com/";
Expand Down Expand Up @@ -1198,6 +1203,12 @@ int GUI_App::download_plugin(std::string name, std::string package_name, Install
return -1;
}

if (app_config->get_stealth_mode()) {
j["result"] = "failed";
j["error_msg"] = "stealth_mode is enabled";
return -2;
}

BOOST_LOG_TRIVIAL(info) << "[download_plugin]: enter";
m_networking_cancel_update = false;
// get temp path
Expand Down Expand Up @@ -4422,6 +4433,7 @@ void GUI_App::on_check_privacy_update(wxCommandEvent& evt)

void GUI_App::check_privacy_version(int online_login)
{
return; // orca: not used
update_http_extra_header();
std::string query_params = "?policy/privacy=00.00.00.00";
std::string url = get_http_url(app_config->get_country_code()) + query_params;
Expand Down
2 changes: 1 addition & 1 deletion src/slic3r/GUI/GUI_App.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -661,7 +661,7 @@ class GUI_App : public wxApp
std::string get_plugin_url(std::string name, std::string country_code);
int download_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 = {}, bool override_stealth_mode = false);
std::string get_model_http_url(std::string country_code);
bool is_compatibility_version();
bool check_networking_version();
Expand Down
2 changes: 2 additions & 0 deletions src/slic3r/GUI/Preferences.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1104,6 +1104,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_sync_on_start = create_item_checkbox(_L("Sync network and printer config on start"), page, _L("Check for latest version of Bambu's network plugin and your Bambu's printer config on start"), 50, "sync_on_start");
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)"};
Expand Down Expand Up @@ -1218,6 +1219,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_sync_on_start, 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));
Expand Down
11 changes: 11 additions & 0 deletions src/slic3r/GUI/WebGuideDialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ GuideFrame::GuideFrame(GUI_App *pGUI, long style)
PrivacyUse = false;
StealthMode = false;
InstallNetplugin = false;
SyncOnStart = false;

m_MainPtr = pGUI;

Expand Down Expand Up @@ -496,6 +497,15 @@ void GuideFrame::OnScriptMessage(wxWebViewEvent &evt)
StealthMode = false;
}
}
else if (strCmd == "save_sync_on_start") {
wxString strAction = j["data"]["action"];

if (strAction == "yes") {
SyncOnStart = true;
} else {
SyncOnStart = false;
}
}
} catch (std::exception &e) {
// wxMessageBox(e.what(), "json Exception", MB_OK);
BOOST_LOG_TRIVIAL(trace) << "GuideFrame::OnScriptMessage;Error:" << e.what();
Expand Down Expand Up @@ -627,6 +637,7 @@ int GuideFrame::SaveProfile()

m_MainPtr->app_config->set("region", m_Region);
m_MainPtr->app_config->set_bool("stealth_mode", StealthMode);
m_MainPtr->app_config->set_bool("sync_on_start", SyncOnStart);

//finish
m_MainPtr->app_config->set(std::string(m_SectionName.mb_str()), "finish", "1");
Expand Down
1 change: 1 addition & 0 deletions src/slic3r/GUI/WebGuideDialog.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ class GuideFrame : public DPIDialog
// User Config
bool PrivacyUse;
bool StealthMode;
bool SyncOnStart;
std::string m_Region;

bool InstallNetplugin;
Expand Down
12 changes: 8 additions & 4 deletions src/slic3r/Utils/PresetUpdater.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1332,7 +1332,7 @@ PresetUpdater::~PresetUpdater()

//BBS: change directories by design
//BBS: refine the preset updater logic
void PresetUpdater::sync(std::string http_url, std::string language, std::string plugin_version, PresetBundle *preset_bundle)
void PresetUpdater::sync(std::string http_url, std::string language, std::string plugin_version, PresetBundle *preset_bundle, bool sync_on_start)
{
//p->set_download_prefs(GUI::wxGetApp().app_config);
if (!p->enabled_version_check && !p->enabled_config_update) { return; }
Expand All @@ -1342,7 +1342,7 @@ void PresetUpdater::sync(std::string http_url, std::string language, std::string
// into the closure (but perhaps the compiler can elide this).
VendorMap vendors = preset_bundle ? preset_bundle->vendors : VendorMap{};

p->thread = std::thread([this, vendors, http_url, language, plugin_version]() {
p->thread = std::thread([this, vendors, http_url, language, plugin_version, sync_on_start]() {
this->p->prune_tmps();
if (p->cancel)
return;
Expand All @@ -1359,8 +1359,12 @@ void PresetUpdater::sync(std::string http_url, std::string language, std::string
}
if (p->cancel)
return;
this->p->sync_plugins(http_url, plugin_version);
this->p->sync_printer_config(http_url);

// orca: sync network plugin & printer config from bambu if needed
if (sync_on_start) {
this->p->sync_plugins(http_url, plugin_version);
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Currently plugin is no controlled by stealth flag, it's enabled networking option that controls it.
I'm afraid disabling plugin downloading will confuse user.
Better don't do it.

Stealth flag mainly disable HMS

Copy link
Contributor Author

@pimlie pimlie Aug 2, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah ok.

Wdyt about renaming stealth mode to something clearer then? Maybe:

  • rename stealth_mode to enable_bambulab_hms not implemented
  • add sync_on_start flag so users can toggle whether sync_plugins & sync_printer_config should be called on application start

See screenshots in OP for added checks

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To clarify, the Sync on start wizard option comes after the Propietary Plugins step and is now the last wizard step

this->p->sync_printer_config(http_url);
}
//if (p->cancel)
// return;
//remove the tooltip currently
Expand Down
2 changes: 1 addition & 1 deletion src/slic3r/Utils/PresetUpdater.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class PresetUpdater
~PresetUpdater();

// If either version check or config updating is enabled, get the appropriate data in the background and cache it.
void sync(std::string http_url, std::string language, std::string plugin_version, PresetBundle *preset_bundle);
void sync(std::string http_url, std::string language, std::string plugin_version, PresetBundle *preset_bundle, bool sync_on_start);

// If version check is enabled, check if chaced online slic3r version is newer, notify if so.
void slic3r_update_notify();
Expand Down