From 5d6a6ca2b6b3a513d67c1521a5a13278a8c88bb3 Mon Sep 17 00:00:00 2001 From: alves Date: Thu, 22 Jan 2026 11:11:09 +0800 Subject: [PATCH] feature privacy flags throw protocol to web. --- src/slic3r/GUI/GUI_App.cpp | 14 +++++--------- src/slic3r/GUI/GUI_App.hpp | 2 ++ src/slic3r/GUI/Preferences.cpp | 6 +++--- src/slic3r/GUI/SSWCP.cpp | 25 +++++++++++++++++++++---- src/slic3r/GUI/SSWCP.hpp | 3 +++ src/slic3r/GUI/WebGuideDialog.cpp | 2 +- 6 files changed, 35 insertions(+), 17 deletions(-) diff --git a/src/slic3r/GUI/GUI_App.cpp b/src/slic3r/GUI/GUI_App.cpp index 75feacd820..ea8aca89f8 100644 --- a/src/slic3r/GUI/GUI_App.cpp +++ b/src/slic3r/GUI/GUI_App.cpp @@ -4045,18 +4045,14 @@ wxString GUI_App::get_international_url(const wxString& origin_url) { string dark_mode = wxGetApp().app_config->get("dark_color_mode"); - auto isAgree = wxGetApp().app_config->get("app", "privacy_policy_isagree"); - std::string useAgree = (isAgree == "true" ? "1" : "0"); - if (baseUrl.find("?") != std::string::npos) { return baseUrl + wxString::FromUTF8("&locale=") + lang + wxString::FromUTF8("-") + region + - wxString::FromUTF8("&dark_mode=" + dark_mode) + wxString::FromUTF8("&privacy_policy_isagree=" + useAgree); + wxString::FromUTF8("&dark_mode=" + dark_mode); } else { return baseUrl + wxString::FromUTF8("?locale=") + lang + wxString::FromUTF8("-") + region + - wxString::FromUTF8("&dark_mode=" + dark_mode) + wxString::FromUTF8("&privacy_policy_isagree=" + useAgree); + wxString::FromUTF8("&dark_mode=" + dark_mode); } - } bool GUI_App::is_user_login() @@ -6719,7 +6715,7 @@ bool GUI_App::run_wizard(ConfigWizard::RunReason reason, ConfigWizard::StartPage mainframe->refresh_plugin_tips(); // BBS: remove SLA related message } - auto isAgree = wxGetApp().app_config->get("app", "privacy_policy_isagree"); + auto isAgree = wxGetApp().app_config->get("app", PRIVACY_POLICY_FLAGS); user_update_privacy_notify(isAgree == "true"); BOOST_LOG_TRIVIAL(warning) << "run_wizard changed the privacy policy with: " << (isAgree); @@ -6932,7 +6928,7 @@ void GUI_App::user_update_privacy_notify(const bool& res) json data; - data["privacy_policy_isagree"] = res; + data[PRIVACY_POLICY_FLAGS] = res; for (const auto& instance : m_user_update_privacy_subscribers) { auto ptr = instance.second.lock(); @@ -6957,7 +6953,7 @@ void GUI_App::user_login_notify(const json& res) bool GUI_App::config_wizard_startup() { - auto isAgree = wxGetApp().app_config->get("app", "privacy_policy_isagree"); + auto isAgree = wxGetApp().app_config->get("app", PRIVACY_POLICY_FLAGS); user_update_privacy_notify(isAgree == "true"); BOOST_LOG_TRIVIAL(warning) << "config_wizard_startup changed the privacy policy with: " << (isAgree); if (!m_app_conf_exists || preset_bundle->printers.only_default_printers()) { diff --git a/src/slic3r/GUI/GUI_App.hpp b/src/slic3r/GUI/GUI_App.hpp index 02b1721ecf..6052f68401 100644 --- a/src/slic3r/GUI/GUI_App.hpp +++ b/src/slic3r/GUI/GUI_App.hpp @@ -46,6 +46,8 @@ #define _MSW_DARK_MODE 1 #endif // _MSW_DARK_MODE +#define PRIVACY_POLICY_FLAGS "privacy_policy_isagree" + class wxMenuItem; class wxMenuBar; class wxTopLevelWindow; diff --git a/src/slic3r/GUI/Preferences.cpp b/src/slic3r/GUI/Preferences.cpp index 41c7e34a93..45725d4b70 100644 --- a/src/slic3r/GUI/Preferences.cpp +++ b/src/slic3r/GUI/Preferences.cpp @@ -748,9 +748,9 @@ wxBoxSizer *PreferencesDialog::create_item_checkbox(wxString title, wxWindow *pa app_config->set_bool(param, checkbox->GetValue()); app_config->save(); - if (param == "privacy_policy_isagree") + if (param == PRIVACY_POLICY_FLAGS) { - app_config->set("app", "privacy_policy_isagree", checkbox->GetValue()); + app_config->set("app", PRIVACY_POLICY_FLAGS, checkbox->GetValue()); BOOST_LOG_TRIVIAL(warning) <<"create_item_checkbox changed the privacy policy with: "<<(checkbox->GetValue()?"true" : "false"); wxGetApp().user_update_privacy_notify(checkbox->GetValue()); } @@ -1300,7 +1300,7 @@ wxWindow* PreferencesDialog::create_general_page() std::string region = app_config->get("language"); auto title_user_experience = create_item_title(_L("User Experience"), page, _L("User Experience")); - auto item_priv_policy = create_item_checkbox(_L("Join Customer Experience Improvement Program."), page, _L(""), 50, "privacy_policy_isagree"); + auto item_priv_policy = create_item_checkbox(_L("Join Customer Experience Improvement Program."), page, _L(""), 50,PRIVACY_POLICY_FLAGS); wxHyperlinkCtrl* hyperlink = nullptr; if (region.empty() || region != "zh_CN") hyperlink = new wxHyperlinkCtrl(page, wxID_ANY, _L("What data would be collected?"), enUrl); diff --git a/src/slic3r/GUI/SSWCP.cpp b/src/slic3r/GUI/SSWCP.cpp index dde47f36ff..4de740574b 100644 --- a/src/slic3r/GUI/SSWCP.cpp +++ b/src/slic3r/GUI/SSWCP.cpp @@ -4273,9 +4273,10 @@ void SSWCP_UserLogin_Instance::process() } else if (m_cmd == "sw_SubscribeUserLoginState") { sw_SubscribeUserLoginState(); } - else if (m_cmd == UPDATE_PRIVACY_STATUS) - { + else if (m_cmd == UPDATE_PRIVACY_STATUS) { sw_SubUserUpdatePrivacy(); + } else if (m_cmd == GET_PRIVACY_STATUS) { + sw_GetUserUpdatePrivacy(); } else { handle_general_fail(); @@ -4341,6 +4342,22 @@ void SSWCP_UserLogin_Instance::sw_GetUserLoginState() handle_general_fail(); } } +void SSWCP_UserLogin_Instance::sw_GetUserUpdatePrivacy() +{ + json data; + auto isAgree = wxGetApp().app_config->get("app", PRIVACY_POLICY_FLAGS); + bool isUserAgree = false; + + if (isAgree == "true") + isUserAgree = true; + + data[PRIVACY_POLICY_FLAGS] = isUserAgree; + + m_res_data = data; + send_to_js(); + finish_job(); + +} void SSWCP_UserLogin_Instance::sw_SubUserUpdatePrivacy() { @@ -5844,8 +5861,8 @@ std::unordered_set SSWCP::m_project_cmd_list = { "sw_NewProject", "sw_OpenProject", "sw_GetRecentProjects", "sw_OpenRecentFile", "sw_DeleteRecentFiles", "sw_SubscribeRecentFiles", }; -std::unordered_set SSWCP::m_login_cmd_list = {"sw_UserLogin", "sw_UserLogout", "sw_GetUserLoginState", - "sw_SubscribeUserLoginState", UPDATE_PRIVACY_STATUS}; +std::unordered_set SSWCP::m_login_cmd_list = {"sw_UserLogin", "sw_UserLogout", "sw_GetUserLoginState", "sw_SubscribeUserLoginState", + UPDATE_PRIVACY_STATUS, GET_PRIVACY_STATUS}; std::unordered_set SSWCP::m_machine_manage_cmd_list = { "sw_GetLocalDevices", "sw_AddDevice", "sw_SubscribeLocalDevices", "sw_RenameDevice", "sw_SwitchModel", "sw_DeleteDevices" diff --git a/src/slic3r/GUI/SSWCP.hpp b/src/slic3r/GUI/SSWCP.hpp index cc82c52b3a..5e4182a0f3 100644 --- a/src/slic3r/GUI/SSWCP.hpp +++ b/src/slic3r/GUI/SSWCP.hpp @@ -26,6 +26,7 @@ using tcp = asio::ip::tcp; //WCP Interface definition #define UPDATE_PRIVACY_STATUS "sw_SubUserUpdatePrivacy" +#define GET_PRIVACY_STATUS "sw_GetUserUpdatePrivacy" #define UPLOAD_CAMERA_TIMELAPSE "sw_UploadCameraTimelapse" #define DELETE_CAMERA_TIMELAPSE "sw_DeleteCameraTimelapse" #define GETCAMERA_TIMELAPSE_INSTANCE "sw_GetCameraTimelapseInstance" @@ -531,6 +532,8 @@ private: void sw_SubscribeUserLoginState(); + void sw_GetUserUpdatePrivacy(); + void sw_SubUserUpdatePrivacy(); }; diff --git a/src/slic3r/GUI/WebGuideDialog.cpp b/src/slic3r/GUI/WebGuideDialog.cpp index e688e0ed82..9f3cfb3e32 100644 --- a/src/slic3r/GUI/WebGuideDialog.cpp +++ b/src/slic3r/GUI/WebGuideDialog.cpp @@ -639,7 +639,7 @@ int GuideFrame::SaveProfile() // m_MainPtr->app_config->set(std::string(m_SectionName.mb_str()), "privacyuse", "1"); // } else // m_MainPtr->app_config->set(std::string(m_SectionName.mb_str()), "privacyuse", "0"); - m_MainPtr->app_config->set("app", "privacy_policy_isagree", PrivacyUse); + m_MainPtr->app_config->set("app", PRIVACY_POLICY_FLAGS, PrivacyUse); BOOST_LOG_TRIVIAL(warning) << "SaveProfile changed the privacy policy with: " << (PrivacyUse ? "true" : "false"); wxGetApp().user_update_privacy_notify(PrivacyUse); m_MainPtr->app_config->set("region", m_Region);