tweak no tracking

This commit is contained in:
SoftFever
2024-05-27 22:02:49 +08:00
parent 206a9608ad
commit 9f73c01821
3 changed files with 59 additions and 25 deletions

View File

@@ -9,7 +9,6 @@
#include <boost/log/trivial.hpp>
#include "libslic3r/Utils.hpp"
#include "NetworkAgent.hpp"
#include <type_traits>
@@ -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<func_get_slice_info>(get_network_function("bambu_network_get_slice_info"));
query_bind_status_ptr = reinterpret_cast<func_query_bind_status>(get_network_function("bambu_network_query_bind_status"));
modify_printer_name_ptr = reinterpret_cast<func_modify_printer_name>(get_network_function("bambu_network_modify_printer_name"));
get_camera_url_ptr = reinterpret_cast<func_get_camera_url>(get_network_function("bambu_network_get_camera_url"));
get_design_staffpick_ptr = reinterpret_cast<func_get_design_staffpick>(get_network_function("bambu_network_get_design_staffpick"));
get_camera_url_ptr = reinterpret_cast<func_get_camera_url>(get_network_function("bambu_network_get_camera_url"));
get_design_staffpick_ptr = reinterpret_cast<func_get_design_staffpick>(get_network_function("bambu_network_get_design_staffpick"));
start_publish_ptr = reinterpret_cast<func_start_pubilsh>(get_network_function("bambu_network_start_publish"));
get_profile_3mf_ptr = reinterpret_cast<func_get_profile_3mf>(get_network_function("bambu_network_get_profile_3mf"));
get_model_publish_url_ptr = reinterpret_cast<func_get_model_publish_url>(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<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"));
@@ -292,6 +295,9 @@ int NetworkAgent::initialize_network_module(bool using_backup)
put_rating_picture_oss_ptr = reinterpret_cast<func_put_rating_picture_oss>(get_network_function("bambu_network_put_rating_picture_oss"));
get_model_mall_rating_result_ptr = reinterpret_cast<func_get_model_mall_rating_result>(get_network_function("bambu_network_get_model_mall_rating"));
get_mw_user_preference_ptr = reinterpret_cast<func_get_mw_user_preference>(get_network_function("bambu_network_get_mw_user_preference"));
get_mw_user_4ulist_ptr = reinterpret_cast<func_get_mw_user_4ulist>(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<void
return ret;
}
int NetworkAgent::get_mw_user_preference(std::function<void(std::string)> 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<void(std::string)> 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;