From bcdbf267fb9b8ca0ba8fd3962c7fc078cb947ece Mon Sep 17 00:00:00 2001 From: Stone Li Date: Thu, 19 Dec 2024 14:46:41 +0800 Subject: [PATCH] ENH: add more tips dialog JIRA: STUDIO-7801 Change-Id: I672082d97c5afa144f704959c0c56d70fddd3a6a Signed-off-by: Stone Li --- src/slic3r/GUI/DeviceManager.cpp | 2 - src/slic3r/GUI/GUI_App.cpp | 83 ++++++++++++++++++++++----- src/slic3r/GUI/GUI_App.hpp | 5 +- src/slic3r/GUI/Jobs/PrintJob.cpp | 6 +- src/slic3r/Utils/bambu_networking.hpp | 1 + 5 files changed, 78 insertions(+), 19 deletions(-) diff --git a/src/slic3r/GUI/DeviceManager.cpp b/src/slic3r/GUI/DeviceManager.cpp index 9b40ff95b..09ea5f84e 100644 --- a/src/slic3r/GUI/DeviceManager.cpp +++ b/src/slic3r/GUI/DeviceManager.cpp @@ -5511,8 +5511,6 @@ void DeviceManager::on_machine_alive(std::string json_str) Slic3r::GUI::wxGetApp().app_config->set_str("ip_address", obj->dev_id, obj->dev_ip); Slic3r::GUI::wxGetApp().app_config->save(); }*/ - - BOOST_LOG_TRIVIAL(info) << "SsdpDiscovery::New Machine, ip = " << Slic3r::GUI::wxGetApp().format_IP(dev_ip) << ", printer_name= " << dev_name << ", printer_type = " << printer_type_str << ", signal = " << printer_signal; } } diff --git a/src/slic3r/GUI/GUI_App.cpp b/src/slic3r/GUI/GUI_App.cpp index 4b9e350c3..b53086a3f 100644 --- a/src/slic3r/GUI/GUI_App.cpp +++ b/src/slic3r/GUI/GUI_App.cpp @@ -2031,6 +2031,8 @@ void GUI_App::init_networking_callbacks() obj->command_get_version(); obj->erase_user_access_code(); obj->command_get_access_code(); + if (m_agent) + m_agent->install_device_cert(obj->dev_id, obj->is_lan_mode_printer()); if (!is_enable_multi_machine()) { GUI::wxGetApp().sidebar().load_ams_list(obj->dev_id, obj); } @@ -2129,6 +2131,8 @@ void GUI_App::init_networking_callbacks() CallAfter([this, dev_id, msg] { if (m_is_closing) return; + this->process_network_msg(dev_id, msg); + MachineObject* obj = this->m_device_manager->get_user_machine(dev_id); if (obj) { obj->is_ams_need_update = false; @@ -2181,6 +2185,7 @@ void GUI_App::init_networking_callbacks() if (m_is_closing) return; + this->process_network_msg(dev_id, msg); MachineObject* obj = m_device_manager->get_my_machine(dev_id); if (!obj || !obj->is_lan_mode_printer()) { obj = m_device_manager->get_local_machine(dev_id); @@ -4491,14 +4496,12 @@ void GUI_App::on_http_error(wxCommandEvent &evt) // Version limit if (code == HttpErrorVersionLimited) { - if (!m_show_http_errpr_msgdlg) { + if (!m_show_error_msgdlg) { MessageDialog msg_dlg(nullptr, _L("The Bambu Studio version is too old to enable cloud service. Please download the latest version from Bambu Lab website."), "", wxAPPLY | wxOK); - m_show_http_errpr_msgdlg = true; + m_show_error_msgdlg = true; auto modal_result = msg_dlg.ShowModal(); - if (modal_result == wxOK || modal_result == wxCLOSE) { - m_show_http_errpr_msgdlg = false; - return; - } + m_show_error_msgdlg = false; + return; } } @@ -4508,15 +4511,12 @@ void GUI_App::on_http_error(wxCommandEvent &evt) if (m_agent) { if (m_agent->is_user_login()) { this->request_user_logout(); - - if (!m_show_http_errpr_msgdlg) { + if (!m_show_error_msgdlg) { MessageDialog msg_dlg(nullptr, _L("Login information expired. Please login again."), "", wxAPPLY | wxOK); - m_show_http_errpr_msgdlg = true; + m_show_error_msgdlg = true; auto modal_result = msg_dlg.ShowModal(); - if (modal_result == wxOK || modal_result == wxCLOSE) { - m_show_http_errpr_msgdlg = false; - return; - } + m_show_error_msgdlg = false; + return; } } } @@ -4826,6 +4826,63 @@ void GUI_App::check_cert() BOOST_LOG_TRIVIAL(info) << "check_cert"; } +void GUI_App::process_network_msg(std::string dev_id, std::string msg) +{ + if (dev_id.empty()) { + if (msg == "wait_info") { + BOOST_LOG_TRIVIAL(info) << "process_network_msg, wait_info"; + Slic3r::DeviceManager* dev = Slic3r::GUI::wxGetApp().getDeviceManager(); + if (!dev) + return; + MachineObject* obj = dev->get_selected_machine(); + if (obj) + m_agent->install_device_cert(obj->dev_id, obj->is_lan_mode_printer()); + if (!m_show_error_msgdlg) { + MessageDialog msg_dlg(nullptr, _L("Retrieving printer information, please try again later."), "", wxAPPLY | wxOK); + m_show_error_msgdlg = true; + auto modal_result = msg_dlg.ShowModal(); + m_show_error_msgdlg = false; + } + } + else if (msg == "update_studio") { + BOOST_LOG_TRIVIAL(info) << "process_network_msg, update_studio"; + if (!m_show_error_msgdlg) { + MessageDialog msg_dlg(nullptr, _L("Please try updating Bambu Studio and then try again."), "", wxAPPLY | wxOK); + m_show_error_msgdlg = true; + auto modal_result = msg_dlg.ShowModal(); + m_show_error_msgdlg = false; + } + } + else if (msg == "update_fixed_studio") { + BOOST_LOG_TRIVIAL(info) << "process_network_msg, update_fixed_studio"; + if (!m_show_error_msgdlg) { + MessageDialog msg_dlg(nullptr, _L("Please try updating Bambu Studio and then try again."), "", wxAPPLY | wxOK); + m_show_error_msgdlg = true; + auto modal_result = msg_dlg.ShowModal(); + m_show_error_msgdlg = false; + } + } + else if (msg == "cert_expired") { + BOOST_LOG_TRIVIAL(info) << "process_network_msg, cert_expired"; + if (!m_show_error_msgdlg) { + MessageDialog msg_dlg(nullptr, _L("The certificate has expired. Please check the time settings or update Bambu Studio and try again."), "", wxAPPLY | wxOK); + m_show_error_msgdlg = true; + auto modal_result = msg_dlg.ShowModal(); + m_show_error_msgdlg = false; + } + } + else if (msg == "cert_revoked") { + BOOST_LOG_TRIVIAL(info) << "process_network_msg, cert_revoked"; + if (!m_show_error_msgdlg) { + MessageDialog msg_dlg(nullptr, _L("The certificate has been revoked. Please check the time settings or update Bambu Studio and try again."), "", wxAPPLY | wxOK); + m_show_error_msgdlg = true; + auto modal_result = msg_dlg.ShowModal(); + m_show_error_msgdlg = false; + } + } + } +} + //BBS pop up a dialog and download files void GUI_App::request_new_version(int by_user) { diff --git a/src/slic3r/GUI/GUI_App.hpp b/src/slic3r/GUI/GUI_App.hpp index 589e94f62..842c2ab23 100644 --- a/src/slic3r/GUI/GUI_App.hpp +++ b/src/slic3r/GUI/GUI_App.hpp @@ -304,7 +304,7 @@ private: bool m_is_dark_mode{ false }; bool m_adding_script_handler { false }; bool m_side_popup_status{false}; - bool m_show_http_errpr_msgdlg{false}; + bool m_show_error_msgdlg{false}; wxString m_info_dialog_content; HttpServer m_http_server; @@ -457,8 +457,9 @@ public: void check_update(bool show_tips, int by_user); void check_new_version(bool show_tips = false, int by_user = 0); - void check_beta_version(); void check_cert(); + void process_network_msg(std::string dev_id, std::string msg); + void check_beta_version(); void request_new_version(int by_user); void enter_force_upgrade(); void set_skip_version(bool skip = true); diff --git a/src/slic3r/GUI/Jobs/PrintJob.cpp b/src/slic3r/GUI/Jobs/PrintJob.cpp index 6c50ca0c0..e6771685a 100644 --- a/src/slic3r/GUI/Jobs/PrintJob.cpp +++ b/src/slic3r/GUI/Jobs/PrintJob.cpp @@ -593,8 +593,10 @@ void PrintJob::process() if (result < 0) { curr_percent = -1; - - if (result == BAMBU_NETWORK_ERR_PRINT_WR_FILE_NOT_EXIST || result == BAMBU_NETWORK_ERR_PRINT_SP_FILE_NOT_EXIST) { + if (result == BAMBU_NETOWRK_ERR_PRINT_SP_ENC_FLAG_NOT_READY) { + msg_text = _L("Retrieving printer information, please try again later."); + } + else if (result == BAMBU_NETWORK_ERR_PRINT_WR_FILE_NOT_EXIST || result == BAMBU_NETWORK_ERR_PRINT_SP_FILE_NOT_EXIST) { msg_text = file_is_not_exists_str; } else if (result == BAMBU_NETWORK_ERR_PRINT_SP_FILE_OVER_SIZE || result == BAMBU_NETWORK_ERR_PRINT_WR_FILE_OVER_SIZE) { msg_text = file_over_size_str; diff --git a/src/slic3r/Utils/bambu_networking.hpp b/src/slic3r/Utils/bambu_networking.hpp index 0bd75a6a5..97856d644 100644 --- a/src/slic3r/Utils/bambu_networking.hpp +++ b/src/slic3r/Utils/bambu_networking.hpp @@ -78,6 +78,7 @@ namespace BBL { #define BAMBU_NETWORK_ERR_PRINT_SP_PATCH_PROJECT_FAILED -3110 //failed to patch project #define BAMBU_NETWORK_ERR_PRINT_SP_POST_TASK_FAILED -3120 //failed to post task #define BAMBU_NETWORK_ERR_PRINT_SP_WAIT_PRINTER_FAILED -3130 //failed to wait the ack from printer +#define BAMBU_NETOWRK_ERR_PRINT_SP_ENC_FLAG_NOT_READY -3140 //failed to get flag info //start_local_print error #define BAMBU_NETWORK_ERR_PRINT_LP_FILE_OVER_SIZE -4010 //the size of the uploaded file cannot exceed 1 GB