From 232fc30db1bcde98120d11f72d02236f051825c1 Mon Sep 17 00:00:00 2001 From: Ian Chua Date: Mon, 18 May 2026 15:18:31 +0800 Subject: [PATCH 1/2] log: add logs surrounding logout to potentially catch any unwanted logouts or errors --- src/slic3r/GUI/GUI_App.cpp | 21 +++++++++++++++------ src/slic3r/GUI/WebGuideDialog.cpp | 5 ++++- src/slic3r/Utils/OrcaCloudServiceAgent.cpp | 1 + 3 files changed, 20 insertions(+), 7 deletions(-) diff --git a/src/slic3r/GUI/GUI_App.cpp b/src/slic3r/GUI/GUI_App.cpp index 3169e53eee..889cccde0f 100644 --- a/src/slic3r/GUI/GUI_App.cpp +++ b/src/slic3r/GUI/GUI_App.cpp @@ -1900,6 +1900,7 @@ void GUI_App::init_networking_callbacks() } if (return_code == 5) { GUI::wxGetApp().CallAfter([this, provider = event.provider] { + BOOST_LOG_TRIVIAL(info) << "logout: login expired"; this->request_user_logout(provider); MessageDialog msg_dlg(nullptr, _L("Login information expired. Please login again."), "", wxAPPLY | wxOK); if (msg_dlg.ShowModal() == wxOK) { @@ -4526,7 +4527,8 @@ std::string GUI_App::handle_web_request(std::string cmd) } else if (command_str.compare("homepage_logout") == 0) { CallAfter([this] { - wxGetApp().request_user_logout(); + BOOST_LOG_TRIVIAL(info) << "logout: homepage_logout"; + request_user_logout(); }); } else if (command_str.compare("get_orca_login_info") == 0) { @@ -4539,18 +4541,22 @@ std::string GUI_App::handle_web_request(std::string cmd) CallAfter([this] { request_login(true, BBL_CLOUD_PROVIDER); }); } else if (command_str.compare("homepage_bambu_logout") == 0) { - CallAfter([this] { request_user_logout(BBL_CLOUD_PROVIDER); }); + CallAfter([this] { + BOOST_LOG_TRIVIAL(info) << "logout: homepage_bambu_logout"; + request_user_logout(BBL_CLOUD_PROVIDER); + }); } else if (command_str.compare("homepage_orca_login_or_register") == 0) { CallAfter([this] { request_login(true, ORCA_CLOUD_PROVIDER); }); } else if (command_str.compare("homepage_orca_logout") == 0) { - CallAfter([this] { request_user_logout(ORCA_CLOUD_PROVIDER); }); + CallAfter([this] { + BOOST_LOG_TRIVIAL(info) << "logout: homepage_orca_logout"; + request_user_logout(ORCA_CLOUD_PROVIDER); + }); } else if (command_str.compare("homepage_modeldepot") == 0) { - CallAfter([this] { - wxGetApp().open_mall_page_dialog(); - }); + CallAfter([this] { open_mall_page_dialog(); }); } else if (command_str.compare("homepage_newproject") == 0) { this->request_open_project(""); @@ -4826,6 +4832,7 @@ void GUI_App::on_http_error(wxCommandEvent &evt) if (status == 401) { if (m_agent) { if (m_agent->is_user_login(provider)) { + BOOST_LOG_TRIVIAL(warning) << "logout: http error 401."; this->request_user_logout(provider); if (!m_show_http_errpr_msgdlg) { @@ -5599,6 +5606,7 @@ void GUI_App::show_check_privacy_dlg(wxCommandEvent& evt) privacy_dlg.Bind(EVT_PRIVACY_UPDATE_CANCEL, [this, provider](wxCommandEvent &e) { app_config->set_bool("privacy_update_checked", false); if (m_agent) { + BOOST_LOG_TRIVIAL(info) << "logout: Privacy update dialog cancelled."; m_agent->user_logout(false, provider); post_logout_to_webview(provider); } @@ -6766,6 +6774,7 @@ void GUI_App::stop_sync_user_preset() void GUI_App::on_stealth_mode_enter() { stop_sync_user_preset(); + BOOST_LOG_TRIVIAL(info) << "logout: on_stealth_mode_enter"; request_user_logout(ORCA_CLOUD_PROVIDER); request_user_logout(BBL_CLOUD_PROVIDER); if (mainframe && mainframe->m_webview) { diff --git a/src/slic3r/GUI/WebGuideDialog.cpp b/src/slic3r/GUI/WebGuideDialog.cpp index 575748fce0..f68c00ff40 100644 --- a/src/slic3r/GUI/WebGuideDialog.cpp +++ b/src/slic3r/GUI/WebGuideDialog.cpp @@ -4,6 +4,7 @@ #include #include #include +#include #include #include "I18N.hpp" #include "libslic3r/AppConfig.hpp" @@ -516,7 +517,9 @@ void GuideFrame::OnScriptMessage(wxWebViewEvent &evt) if (agent) { agent->set_country_code(country_code); if (wxGetApp().is_user_login()) { - agent->user_logout(); + BOOST_LOG_TRIVIAL(info) << "logout: user_logout on user_guide_finish"; + // agent->user_logout(); + wxGetApp().request_user_logout(); } } } diff --git a/src/slic3r/Utils/OrcaCloudServiceAgent.cpp b/src/slic3r/Utils/OrcaCloudServiceAgent.cpp index 4298f9616c..2b32b428ea 100644 --- a/src/slic3r/Utils/OrcaCloudServiceAgent.cpp +++ b/src/slic3r/Utils/OrcaCloudServiceAgent.cpp @@ -1465,6 +1465,7 @@ bool OrcaCloudServiceAgent::load_refresh_token(std::string& out_token) if (payload.rfind("v2:", 0) == 0) { auto delim = payload.find(':', 3); if (delim == std::string::npos) { + BOOST_LOG_TRIVIAL(warning) << "payload missing delim ':'."; integrity_ok = false; } else { std::string stored_hmac = payload.substr(3, delim - 3); From 6a06b63d6fcabd90445ca5e6cfb668aa7af9a34f Mon Sep 17 00:00:00 2001 From: Ian Chua Date: Mon, 18 May 2026 16:12:03 +0800 Subject: [PATCH 2/2] add logs to http_get/post/put/delete --- src/slic3r/Utils/OrcaCloudServiceAgent.cpp | 27 +++++++++++++--------- 1 file changed, 16 insertions(+), 11 deletions(-) diff --git a/src/slic3r/Utils/OrcaCloudServiceAgent.cpp b/src/slic3r/Utils/OrcaCloudServiceAgent.cpp index 2b32b428ea..0e1027cd46 100644 --- a/src/slic3r/Utils/OrcaCloudServiceAgent.cpp +++ b/src/slic3r/Utils/OrcaCloudServiceAgent.cpp @@ -1784,7 +1784,8 @@ int OrcaCloudServiceAgent::http_get(const std::string& path, std::string* respon std::string url = api_base_url + path; BOOST_LOG_TRIVIAL(trace) << "OrcaCloudServiceAgent: GET " << url; - ensure_token_fresh("http_get_" + path); + if (!ensure_token_fresh("http_get_" + path)) + BOOST_LOG_TRIVIAL(warning) << "ensure_token_fresh returned false"; struct HttpResult { bool success{false}; @@ -1816,8 +1817,9 @@ int OrcaCloudServiceAgent::http_get(const std::string& path, std::string* respon }) .on_error([&](std::string body, std::string error, unsigned resp_status) { result.success = false; - result.status = resp_status; - result.body = body; + result.status = resp_status == 0 ? 404 : resp_status; + result.body = body; + BOOST_LOG_TRIVIAL(error) << "OrcaCloudServiceAgent: HTTP error - " << error; }) .timeout_max(30) .perform_sync(); @@ -1885,8 +1887,9 @@ int OrcaCloudServiceAgent::http_post(const std::string& path, const std::string& }) .on_error([&](std::string resp_body, std::string error, unsigned resp_status) { result.success = false; - result.status = resp_status; - result.body = resp_body; + result.status = resp_status == 0 ? 404 : resp_status; + result.body = body; + BOOST_LOG_TRIVIAL(error) << "OrcaCloudServiceAgent: HTTP error - " << error; }) .timeout_max(30) .perform_sync(); @@ -1954,8 +1957,9 @@ int OrcaCloudServiceAgent::http_put(const std::string& path, const std::string& }) .on_error([&](std::string resp_body, std::string error, unsigned resp_status) { result.success = false; - result.status = resp_status; - result.body = resp_body; + result.status = resp_status == 0 ? 404 : resp_status; + result.body = body; + BOOST_LOG_TRIVIAL(error) << "OrcaCloudServiceAgent: HTTP error - " << error; }) .timeout_max(30) .perform_sync(); @@ -2020,8 +2024,9 @@ int OrcaCloudServiceAgent::http_delete(const std::string& path, std::string* res }) .on_error([&](std::string resp_body, std::string error, unsigned resp_status) { result.success = false; - result.status = resp_status; - result.body = resp_body; + result.status = resp_status == 0 ? 404 : resp_status; + result.body = resp_body; + BOOST_LOG_TRIVIAL(error) << "OrcaCloudServiceAgent: HTTP error - " << error; }) .timeout_max(30) .perform_sync(); @@ -2102,7 +2107,7 @@ bool OrcaCloudServiceAgent::http_post_token(const std::string& body, std::string }) .on_error([&](std::string body, std::string error, unsigned resp_status) { success = false; - status = resp_status; + status = resp_status == 0 ? 404 : resp_status; resp_body = body; BOOST_LOG_TRIVIAL(error) << "OrcaCloudServiceAgent: HTTP error - " << error; }) @@ -2172,7 +2177,7 @@ bool OrcaCloudServiceAgent::http_post_auth(const std::string& path, const std::s }) .on_error([&](std::string body, std::string error, unsigned resp_status) { success = false; - status = resp_status; + status = resp_status == 0 ? 404 : resp_status; resp_body = body; BOOST_LOG_TRIVIAL(error) << "OrcaCloudServiceAgent: HTTP (auth) error - " << error; })