ENH: remove track files when privacyuse is false

JIRA: STUDIO-6288

Change-Id: I6d3d7a01f5ae6db815a9832b572056e1dceb686c
Signed-off-by: Stone Li <stone.li@bambulab.com>
This commit is contained in:
Stone Li 2024-02-19 11:43:49 +08:00 committed by Lane.Wei
parent dfeb1eba09
commit 0dfeb35c82
4 changed files with 28 additions and 0 deletions

View File

@ -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)

View File

@ -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 {

View File

@ -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<func_get_model_mall_detail_url>(get_network_function("bambu_network_get_model_mall_detail_url"));
get_my_profile_ptr = reinterpret_cast<func_get_my_profile>(get_network_function("bambu_network_get_my_profile"));
track_enable_ptr = reinterpret_cast<func_track_enable>(get_network_function("bambu_network_track_enable"));
track_remove_files_ptr = reinterpret_cast<func_track_remove_files>(get_network_function("bambu_network_track_remove_files"));
track_event_ptr = reinterpret_cast<func_track_event>(get_network_function("bambu_network_track_event"));
track_header_ptr = reinterpret_cast<func_track_header>(get_network_function("bambu_network_track_header"));
track_update_property_ptr = reinterpret_cast<func_track_update_property>(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)

View File

@ -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;