mirror of
https://git.mirrors.martin98.com/https://github.com/bambulab/BambuStudio.git
synced 2025-08-19 17:09:06 +08:00
FIX:fixed unable to download to hms file
jira:[hms] Change-Id: Idc06cf71a9156516f8237b42d470233edd44d4b4 (cherry picked from commit 06ccc46e067ccd4dc5fe51c27bbb3a2f7a925b3b)
This commit is contained in:
parent
c8ce030bd2
commit
b309109530
@ -6509,21 +6509,6 @@ bool DeviceManager::set_selected_machine(std::string dev_id, bool need_disconnec
|
||||
auto my_machine_list = get_my_machine_list();
|
||||
auto it = my_machine_list.find(dev_id);
|
||||
|
||||
/*update hms file*/
|
||||
try {
|
||||
Slic3r::GUI::wxGetApp().CallAfter([=] {
|
||||
if (Slic3r::GUI::wxGetApp().get_hms_query()) {
|
||||
std::string dev_type = dev_id.substr(0, 3);
|
||||
if (!Slic3r::GUI::wxGetApp().get_hms_query()->check_local_file(dev_type)) {
|
||||
Slic3r::GUI::wxGetApp().get_hms_query()->check_hms_info(dev_type);
|
||||
}
|
||||
else {
|
||||
Slic3r::GUI::wxGetApp().get_hms_query()->check_hms_info_from_local(dev_type);
|
||||
}
|
||||
};
|
||||
});
|
||||
} catch (...) {}
|
||||
|
||||
// disconnect last
|
||||
auto last_selected = my_machine_list.find(selected_machine);
|
||||
if (last_selected != my_machine_list.end()) {
|
||||
|
@ -53,12 +53,17 @@ int HMSQuery::download_hms_related(std::string hms_type, json* receive_json, std
|
||||
std::string query_params = HMSQuery::build_query_params(lang);
|
||||
std::string url;
|
||||
if (hms_type.compare(QUERY_HMS_INFO) == 0) {
|
||||
url = (boost::format("https://%1%/query.php?%2%&v=%3%&d=%4%") % hms_host % query_params % local_version % dev_type).str();
|
||||
url = (boost::format("https://%1%/query.php?%2%") % hms_host % query_params).str();
|
||||
}
|
||||
else if (hms_type.compare(QUERY_HMS_ACTION) == 0) {
|
||||
url = (boost::format("https://%1%/hms/GetActionImage.php?v=%2%&d=%3%") % hms_host % local_version % dev_type).str();
|
||||
url = (boost::format("https://%1%/hms/GetActionImage.php?") % hms_host).str();
|
||||
}
|
||||
|
||||
if (!local_version.empty()) { url += (url.find('?') != std::string::npos ? "&" : "?") + (boost::format("v=%1%") % local_version).str(); }
|
||||
|
||||
if (!dev_type.empty()) { url += (url.find('?') != std::string::npos ? "&" : "?") + (boost::format("d=%1%") % dev_type).str(); }
|
||||
|
||||
|
||||
BOOST_LOG_TRIVIAL(info) << "hms: download url = " << url;
|
||||
Slic3r::Http http = Slic3r::Http::get(url);
|
||||
http.on_complete([this, receive_json, hms_type](std::string body, unsigned status) {
|
||||
@ -359,21 +364,26 @@ wxString HMSQuery::query_print_error_url_action(int print_error, std::string dev
|
||||
|
||||
int HMSQuery::check_hms_info(std::string dev_type)
|
||||
{
|
||||
boost::thread check_thread = boost::thread([this, dev_type] {
|
||||
download_hms_related(QUERY_HMS_INFO, &m_hms_info_json, dev_type);
|
||||
download_hms_related(QUERY_HMS_ACTION, &m_hms_action_json, dev_type);
|
||||
std::vector<std::string> dev_sn;
|
||||
dev_sn.push_back("00M");
|
||||
dev_sn.push_back("00W");
|
||||
dev_sn.push_back("03W");
|
||||
dev_sn.push_back("01P");
|
||||
dev_sn.push_back("01S");
|
||||
dev_sn.push_back("030");
|
||||
dev_sn.push_back("039");
|
||||
dev_sn.push_back("094");
|
||||
|
||||
boost::thread check_thread = boost::thread([this, dev_type, dev_sn] {
|
||||
for (auto sn : dev_sn) {
|
||||
download_hms_related(QUERY_HMS_INFO, &m_hms_info_json, sn);
|
||||
download_hms_related(QUERY_HMS_ACTION, &m_hms_action_json, sn);
|
||||
}
|
||||
return 0;
|
||||
});
|
||||
return 0;
|
||||
}
|
||||
|
||||
void HMSQuery::check_hms_info_from_local(std::string dev_type)
|
||||
{
|
||||
std::string local_version = "0";
|
||||
load_from_local(local_version, QUERY_HMS_INFO, &m_hms_info_json, dev_type);
|
||||
load_from_local(local_version, QUERY_HMS_ACTION, &m_hms_action_json, dev_type);
|
||||
}
|
||||
|
||||
std::string get_hms_wiki_url(std::string error_code)
|
||||
{
|
||||
AppConfig* config = wxGetApp().app_config;
|
||||
|
@ -33,7 +33,6 @@ protected:
|
||||
public:
|
||||
HMSQuery() {}
|
||||
int check_hms_info(std::string dev_type = "00M");
|
||||
void check_hms_info_from_local(std::string dev_type);
|
||||
wxString query_hms_msg(std::string long_error_code);
|
||||
bool query_print_error_msg(int print_error, wxString &error_msg);
|
||||
wxString query_print_error_url_action(int print_error, std::string dev_id, std::vector<int>& button_action);
|
||||
|
Loading…
x
Reference in New Issue
Block a user