NEW: add get_my_message interface

Change-Id: If904d6b5692a12bdbca7732002d5bf4e83a85932
Signed-off-by: Stone Li <stone.li@bambulab.com>
This commit is contained in:
Stone Li 2022-09-15 16:55:56 +08:00 committed by Lane.Wei
parent de5f9dfb12
commit 497be311db
3 changed files with 36 additions and 1 deletions

View file

@ -333,6 +333,7 @@ public:
int export_config_3mf(int plate_idx = -1, Export3mfProgressFn proFn = nullptr);
//BBS jump to nonitor after print job finished
void print_job_finished(wxCommandEvent &evt);
void publish_job_finished(wxCommandEvent &evt);
void eject_drive();
void take_snapshot(const std::string &snapshot_name);

View file

@ -80,6 +80,7 @@ func_get_setting_list NetworkAgent::get_setting_list_ptr = nullptr
func_delete_setting NetworkAgent::delete_setting_ptr = nullptr;
func_get_studio_info_url NetworkAgent::get_studio_info_url_ptr = nullptr;
func_set_extra_http_header NetworkAgent::set_extra_http_header_ptr = nullptr;
func_get_my_message NetworkAgent::get_my_message_ptr = nullptr;
func_check_user_task_report NetworkAgent::check_user_task_report_ptr = nullptr;
func_get_user_print_info NetworkAgent::get_user_print_info_ptr = nullptr;
func_get_printer_firmware NetworkAgent::get_printer_firmware_ptr = nullptr;
@ -88,6 +89,7 @@ func_get_slice_info NetworkAgent::get_slice_info_ptr = nullptr;
func_query_bind_status NetworkAgent::query_bind_status_ptr = nullptr;
func_modify_printer_name NetworkAgent::modify_printer_name_ptr = nullptr;
func_get_camera_url NetworkAgent::get_camera_url_ptr = nullptr;
func_start_pubilsh NetworkAgent::start_publish_ptr = nullptr;
NetworkAgent::NetworkAgent()
@ -214,6 +216,7 @@ int NetworkAgent::initialize_network_module(bool using_backup)
delete_setting_ptr = reinterpret_cast<func_delete_setting>(get_network_function("bambu_network_delete_setting"));
get_studio_info_url_ptr = reinterpret_cast<func_get_studio_info_url>(get_network_function("bambu_network_get_studio_info_url"));
set_extra_http_header_ptr = reinterpret_cast<func_set_extra_http_header>(get_network_function("bambu_network_set_extra_http_header"));
get_my_message_ptr = reinterpret_cast<func_get_my_message>(get_network_function("bambu_network_get_my_message"));
check_user_task_report_ptr = reinterpret_cast<func_check_user_task_report>(get_network_function("bambu_network_check_user_task_report"));
get_user_print_info_ptr = reinterpret_cast<func_get_user_print_info>(get_network_function("bambu_network_get_user_print_info"));
get_printer_firmware_ptr = reinterpret_cast<func_get_printer_firmware>(get_network_function("bambu_network_get_printer_firmware"));
@ -222,6 +225,7 @@ int NetworkAgent::initialize_network_module(bool using_backup)
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"));
start_publish_ptr = reinterpret_cast<func_start_pubilsh>(get_network_function("bambu_network_start_publish"));
return 0;
}
@ -302,6 +306,7 @@ int NetworkAgent::unload_network_module()
delete_setting_ptr = nullptr;
get_studio_info_url_ptr = nullptr;
set_extra_http_header_ptr = nullptr;
get_my_message_ptr = nullptr;
check_user_task_report_ptr = nullptr;
get_user_print_info_ptr = nullptr;
get_printer_firmware_ptr = nullptr;
@ -310,6 +315,7 @@ int NetworkAgent::unload_network_module()
query_bind_status_ptr = nullptr;
modify_printer_name_ptr = nullptr;
get_camera_url_ptr = nullptr;
start_publish_ptr = nullptr;
return 0;
}
@ -920,6 +926,17 @@ int NetworkAgent::set_extra_http_header(std::map<std::string, std::string> extra
return ret;
}
int NetworkAgent::get_my_message(int type, int after, int limit, unsigned int* http_code, std::string* http_body)
{
int ret = 0;
if (network_agent && get_my_message_ptr) {
ret = get_my_message_ptr(network_agent, type, after, limit, http_code, http_body);
if (ret)
BOOST_LOG_TRIVIAL(error) << __FUNCTION__ << boost::format(" error: network_agent=%1%, ret=%2%") % network_agent % ret;
}
return ret;
}
int NetworkAgent::check_user_task_report(int* task_id, bool* printable)
{
int ret = 0;
@ -1006,5 +1023,16 @@ int NetworkAgent::get_camera_url(std::string dev_id, std::function<void(std::str
return ret;
}
int NetworkAgent::start_publish(PublishParams params, OnUpdateStatusFn update_fn, WasCancelledFn cancel_fn, std::string *out)
{
int ret = 0;
if (network_agent && start_publish_ptr) {
ret = start_publish_ptr(network_agent, params, update_fn, cancel_fn, out);
if (ret)
BOOST_LOG_TRIVIAL(error) << __FUNCTION__ << boost::format(" error: network_agent=%1%, ret=%2%") % network_agent % ret;
}
return ret;
}
} //namespace

View file

@ -59,6 +59,7 @@ typedef int (*func_get_setting_list)(void *agent, std::string bundle_version, Pr
typedef int (*func_delete_setting)(void *agent, std::string setting_id);
typedef std::string (*func_get_studio_info_url)(void *agent);
typedef int (*func_set_extra_http_header)(void *agent, std::map<std::string, std::string> extra_headers);
typedef int (*func_get_my_message)(void *agent, int type, int after, int limit, unsigned int* http_code, std::string* http_body);
typedef int (*func_check_user_task_report)(void *agent, int* task_id, bool* printable);
typedef int (*func_get_user_print_info)(void *agent, unsigned int* http_code, std::string* http_body);
typedef int (*func_get_printer_firmware)(void *agent, std::string dev_id, unsigned* http_code, std::string* http_body);
@ -67,6 +68,7 @@ typedef int (*func_get_slice_info)(void *agent, std::string project_id, std::str
typedef int (*func_query_bind_status)(void *agent, std::vector<std::string> query_list, unsigned int* http_code, std::string* http_body);
typedef int (*func_modify_printer_name)(void *agent, std::string dev_id, std::string dev_name);
typedef int (*func_get_camera_url)(void *agent, std::string dev_id, std::function<void(std::string)> callback);
typedef int (*func_start_pubilsh)(void *agent, PublishParams params, OnUpdateStatusFn update_fn, WasCancelledFn cancel_fn, std::string* out);
@ -136,6 +138,7 @@ public:
int delete_setting(std::string setting_id);
std::string get_studio_info_url();
int set_extra_http_header(std::map<std::string, std::string> extra_headers);
int get_my_message(int type, int after, int limit, unsigned int* http_code, std::string* http_body);
int check_user_task_report(int* task_id, bool* printable);
int get_user_print_info(unsigned int* http_code, std::string* http_body);
int get_printer_firmware(std::string dev_id, unsigned* http_code, std::string* http_body);
@ -144,6 +147,7 @@ public:
int query_bind_status(std::vector<std::string> query_list, unsigned int* http_code, std::string* http_body);
int modify_printer_name(std::string dev_id, std::string dev_name);
int get_camera_url(std::string dev_id, std::function<void(std::string)> callback);
int start_publish(PublishParams params, OnUpdateStatusFn update_fn, WasCancelledFn cancel_fn, std::string* out);
private:
@ -202,6 +206,7 @@ private:
static func_delete_setting delete_setting_ptr;
static func_get_studio_info_url get_studio_info_url_ptr;
static func_set_extra_http_header set_extra_http_header_ptr;
static func_get_my_message get_my_message_ptr;
static func_check_user_task_report check_user_task_report_ptr;
static func_get_user_print_info get_user_print_info_ptr;
static func_get_printer_firmware get_printer_firmware_ptr;
@ -210,6 +215,7 @@ private:
static func_query_bind_status query_bind_status_ptr;
static func_modify_printer_name modify_printer_name_ptr;
static func_get_camera_url get_camera_url_ptr;
static func_start_pubilsh start_publish_ptr;
};
}