diff --git a/src/slic3r/GUI/GUI_App.cpp b/src/slic3r/GUI/GUI_App.cpp index 03a85e9f34..befd26dc89 100644 --- a/src/slic3r/GUI/GUI_App.cpp +++ b/src/slic3r/GUI/GUI_App.cpp @@ -4099,27 +4099,9 @@ void GUI_App::on_user_login_handle(wxCommandEvent &evt) void GUI_App::check_track_enable() { // Orca: alaways disable track event - return; - if (app_config && app_config->get("firstguide", "privacyuse") == "true") { - //enable track event - json header_json; - header_json["ver"] = SLIC3R_VERSION; - wxString os_desc = wxGetOsDescription(); - int major = 0, minor = 0, micro = 0; - header_json["os"] = std::string(os_desc.ToUTF8()); - header_json["name"] = std::string(SLIC3R_APP_NAME); - header_json["uuid"] = app_config->get("slicer_uuid"); - if (m_agent) { - m_agent->track_enable(true); - m_agent->track_header(header_json.dump()); - } - /* record studio start event */ - json j; - j["user_mode"] = this->get_mode_str(); - j["open_method"] = m_open_method; - if (m_agent) { - m_agent->track_event("studio_launch", j.dump()); - } + if (m_agent) { + m_agent->track_enable(false); + m_agent->track_remove_files(); } } diff --git a/src/slic3r/Utils/NetworkAgent.cpp b/src/slic3r/Utils/NetworkAgent.cpp index 9d2f0d82f1..57f3b02877 100644 --- a/src/slic3r/Utils/NetworkAgent.cpp +++ b/src/slic3r/Utils/NetworkAgent.cpp @@ -9,7 +9,6 @@ #include #include "libslic3r/Utils.hpp" #include "NetworkAgent.hpp" -#include @@ -115,6 +114,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; @@ -124,6 +124,8 @@ func_get_oss_config NetworkAgent::get_oss_config_ptr = nullptr; func_put_rating_picture_oss NetworkAgent::put_rating_picture_oss_ptr = nullptr; func_get_model_mall_rating_result NetworkAgent::get_model_mall_rating_result_ptr = nullptr; +func_get_mw_user_preference NetworkAgent::get_mw_user_preference_ptr = nullptr; +func_get_mw_user_4ulist NetworkAgent::get_mw_user_4ulist_ptr = nullptr; NetworkAgent::NetworkAgent(std::string log_dir) { @@ -273,8 +275,8 @@ int NetworkAgent::initialize_network_module(bool using_backup) get_slice_info_ptr = reinterpret_cast(get_network_function("bambu_network_get_slice_info")); query_bind_status_ptr = reinterpret_cast(get_network_function("bambu_network_query_bind_status")); modify_printer_name_ptr = reinterpret_cast(get_network_function("bambu_network_modify_printer_name")); - get_camera_url_ptr = reinterpret_cast(get_network_function("bambu_network_get_camera_url")); - get_design_staffpick_ptr = reinterpret_cast(get_network_function("bambu_network_get_design_staffpick")); + get_camera_url_ptr = reinterpret_cast(get_network_function("bambu_network_get_camera_url")); + get_design_staffpick_ptr = reinterpret_cast(get_network_function("bambu_network_get_design_staffpick")); start_publish_ptr = reinterpret_cast(get_network_function("bambu_network_start_publish")); get_profile_3mf_ptr = reinterpret_cast(get_network_function("bambu_network_get_profile_3mf")); get_model_publish_url_ptr = reinterpret_cast(get_network_function("bambu_network_get_model_publish_url")); @@ -283,6 +285,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")); @@ -292,6 +295,9 @@ int NetworkAgent::initialize_network_module(bool using_backup) put_rating_picture_oss_ptr = reinterpret_cast(get_network_function("bambu_network_put_rating_picture_oss")); get_model_mall_rating_result_ptr = reinterpret_cast(get_network_function("bambu_network_get_model_mall_rating")); + get_mw_user_preference_ptr = reinterpret_cast(get_network_function("bambu_network_get_mw_user_preference")); + get_mw_user_4ulist_ptr = reinterpret_cast(get_network_function("bambu_network_get_mw_user_4ulist")); + return 0; } @@ -399,6 +405,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; @@ -407,6 +414,9 @@ int NetworkAgent::unload_network_module() put_rating_picture_oss_ptr = nullptr; put_model_mall_rating_url_ptr = nullptr; get_model_mall_rating_result_ptr = nullptr; + + get_mw_user_preference_ptr = nullptr; + get_mw_user_4ulist_ptr = nullptr; return 0; } @@ -1298,6 +1308,27 @@ int NetworkAgent::get_design_staffpick(int offset, int limit, std::function callback) +{ + int ret = 0; + if (network_agent && get_mw_user_preference_ptr) { + ret = get_mw_user_preference_ptr(network_agent,callback); + if (ret) BOOST_LOG_TRIVIAL(error) << __FUNCTION__ << boost::format(" error: network_agent=%1%, ret=%2%") % network_agent % ret; + } + return ret; +} + + +int NetworkAgent::get_mw_user_4ulist(int seed, int limit, std::function callback) +{ + int ret = 0; + if (network_agent && get_mw_user_4ulist_ptr) { + ret = get_mw_user_4ulist_ptr(network_agent,seed, limit, callback); + if (ret) BOOST_LOG_TRIVIAL(error) << __FUNCTION__ << boost::format(" error: network_agent=%1%, ret=%2%") % network_agent % ret; + } + return ret; +} + int NetworkAgent::start_publish(PublishParams params, OnUpdateStatusFn update_fn, WasCancelledFn cancel_fn, std::string *out) { int ret = 0; @@ -1387,9 +1418,18 @@ 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) { - // Orca: disable track return 0; if (!this->enable_track) return 0; diff --git a/src/slic3r/Utils/NetworkAgent.hpp b/src/slic3r/Utils/NetworkAgent.hpp index d8f8e604b4..d62fa1a7a5 100644 --- a/src/slic3r/Utils/NetworkAgent.hpp +++ b/src/slic3r/Utils/NetworkAgent.hpp @@ -94,6 +94,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); @@ -105,6 +106,8 @@ typedef int (*func_put_rating_picture_oss)( void *agent, std::string &config, std::string &pic_oss_path, std::string model_id, int profile_id, unsigned int &http_code, std::string &http_error); typedef int (*func_get_model_mall_rating_result)(void *agent, int job_id, std::string &rating_result, unsigned int &http_code, std::string &http_error); +typedef int (*func_get_mw_user_preference)(void *agent, std::function callback); +typedef int (*func_get_mw_user_4ulist)(void *agent, int seed, int limit, std::function callback); //the NetworkAgent class class NetworkAgent @@ -206,6 +209,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"); @@ -215,6 +219,10 @@ public: int put_rating_picture_oss(std::string &config, std::string &pic_oss_path, std::string model_id, int profile_id, unsigned int &http_code, std::string &http_error); int get_model_mall_rating_result(int job_id, std::string &rating_result, unsigned int &http_code, std::string &http_error); bool get_track_enable() { return enable_track; } + + int get_mw_user_preference(std::function callback); + int get_mw_user_4ulist(int seed, int limit, std::function callback); + private: bool enable_track = false; void* network_agent { nullptr }; @@ -306,6 +314,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; @@ -314,6 +323,9 @@ private: static func_get_oss_config get_oss_config_ptr; static func_put_rating_picture_oss put_rating_picture_oss_ptr; static func_get_model_mall_rating_result get_model_mall_rating_result_ptr; + + static func_get_mw_user_preference get_mw_user_preference_ptr; + static func_get_mw_user_4ulist get_mw_user_4ulist_ptr; }; }