From 0dfeb35c82da65ca2d8ab54a0bfc4f1c1748a288 Mon Sep 17 00:00:00 2001 From: Stone Li Date: Mon, 19 Feb 2024 11:43:49 +0800 Subject: [PATCH] ENH: remove track files when privacyuse is false JIRA: STUDIO-6288 Change-Id: I6d3d7a01f5ae6db815a9832b572056e1dceb686c Signed-off-by: Stone Li --- src/slic3r/GUI/GUI_App.cpp | 5 +++++ src/slic3r/GUI/Preferences.cpp | 7 +++++++ src/slic3r/Utils/NetworkAgent.cpp | 13 +++++++++++++ src/slic3r/Utils/NetworkAgent.hpp | 3 +++ 4 files changed, 28 insertions(+) diff --git a/src/slic3r/GUI/GUI_App.cpp b/src/slic3r/GUI/GUI_App.cpp index b0ec314bd..549090e53 100644 --- a/src/slic3r/GUI/GUI_App.cpp +++ b/src/slic3r/GUI/GUI_App.cpp @@ -4248,6 +4248,11 @@ void GUI_App::check_track_enable() m_agent->track_event("studio_launch", j.dump()); } } + else { + if (m_agent) { + m_agent->track_remove_files(); + } + } } void GUI_App::on_user_login(wxCommandEvent &evt) diff --git a/src/slic3r/GUI/Preferences.cpp b/src/slic3r/GUI/Preferences.cpp index 0438c7959..ea55a76e0 100644 --- a/src/slic3r/GUI/Preferences.cpp +++ b/src/slic3r/GUI/Preferences.cpp @@ -646,6 +646,13 @@ wxBoxSizer *PreferencesDialog::create_item_checkbox(wxString title, wxWindow *pa checkbox->Bind(wxEVT_TOGGLEBUTTON, [this, checkbox, param](wxCommandEvent &e) { if (param == "privacyuse") { app_config->set("firstguide", param, checkbox->GetValue()); + NetworkAgent* agent = GUI::wxGetApp().getAgent(); + if (!checkbox->GetValue()) { + if (agent) { + agent->track_enable(false); + agent->track_remove_files(); + } + } app_config->save(); } else { diff --git a/src/slic3r/Utils/NetworkAgent.cpp b/src/slic3r/Utils/NetworkAgent.cpp index 764d2c1fa..bfea0180b 100644 --- a/src/slic3r/Utils/NetworkAgent.cpp +++ b/src/slic3r/Utils/NetworkAgent.cpp @@ -105,6 +105,7 @@ func_get_model_mall_detail_url NetworkAgent::get_model_mall_detail_url_ptr func_get_subtask NetworkAgent::get_subtask_ptr = nullptr; func_get_my_profile NetworkAgent::get_my_profile_ptr = nullptr; func_track_enable NetworkAgent::track_enable_ptr = nullptr; +func_track_remove_files NetworkAgent::track_remove_files_ptr = nullptr; func_track_event NetworkAgent::track_event_ptr = nullptr; func_track_header NetworkAgent::track_header_ptr = nullptr; func_track_update_property NetworkAgent::track_update_property_ptr = nullptr; @@ -264,6 +265,7 @@ int NetworkAgent::initialize_network_module(bool using_backup) get_model_mall_detail_url_ptr = reinterpret_cast(get_network_function("bambu_network_get_model_mall_detail_url")); get_my_profile_ptr = reinterpret_cast(get_network_function("bambu_network_get_my_profile")); track_enable_ptr = reinterpret_cast(get_network_function("bambu_network_track_enable")); + track_remove_files_ptr = reinterpret_cast(get_network_function("bambu_network_track_remove_files")); track_event_ptr = reinterpret_cast(get_network_function("bambu_network_track_event")); track_header_ptr = reinterpret_cast(get_network_function("bambu_network_track_header")); track_update_property_ptr = reinterpret_cast(get_network_function("bambu_network_track_update_property")); @@ -376,6 +378,7 @@ int NetworkAgent::unload_network_module() get_model_mall_detail_url_ptr = nullptr; get_my_profile_ptr = nullptr; track_enable_ptr = nullptr; + track_remove_files_ptr = nullptr; track_event_ptr = nullptr; track_header_ptr = nullptr; track_update_property_ptr = nullptr; @@ -1268,6 +1271,16 @@ int NetworkAgent::track_enable(bool enable) return ret; } +int NetworkAgent::track_remove_files() +{ + int ret = 0; + if (network_agent && track_remove_files_ptr) { + ret = track_remove_files_ptr(network_agent); + if (ret) BOOST_LOG_TRIVIAL(error) << __FUNCTION__ << boost::format("error network_agnet=%1%, ret = %2%") % network_agent % ret; + } + return ret; +} + int NetworkAgent::track_event(std::string evt_key, std::string content) { if (!this->enable_track) diff --git a/src/slic3r/Utils/NetworkAgent.hpp b/src/slic3r/Utils/NetworkAgent.hpp index 60998c773..bbeb395b8 100644 --- a/src/slic3r/Utils/NetworkAgent.hpp +++ b/src/slic3r/Utils/NetworkAgent.hpp @@ -85,6 +85,7 @@ typedef int (*func_get_model_mall_home_url)(void *agent, std::string* url); typedef int (*func_get_model_mall_detail_url)(void *agent, std::string* url, std::string id); typedef int (*func_get_my_profile)(void *agent, std::string token, unsigned int *http_code, std::string *http_body); typedef int (*func_track_enable)(void *agent, bool enable); +typedef int (*func_track_remove_files)(void *agent); typedef int (*func_track_event)(void *agent, std::string evt_key, std::string content); typedef int (*func_track_header)(void *agent, std::string header); typedef int (*func_track_update_property)(void *agent, std::string name, std::string value, std::string type); @@ -188,6 +189,7 @@ public: int get_model_mall_detail_url(std::string* url, std::string id); int get_my_profile(std::string token, unsigned int* http_code, std::string* http_body); int track_enable(bool enable); + int track_remove_files(); int track_event(std::string evt_key, std::string content); int track_header(std::string header); int track_update_property(std::string name, std::string value, std::string type = "string"); @@ -279,6 +281,7 @@ private: static func_get_model_mall_detail_url get_model_mall_detail_url_ptr; static func_get_my_profile get_my_profile_ptr; static func_track_enable track_enable_ptr; + static func_track_remove_files track_remove_files_ptr; static func_track_event track_event_ptr; static func_track_header track_header_ptr; static func_track_update_property track_update_property_ptr;