ENH: refine GetVersion for HMS query

JIRA: STUDIO-5763

Change-Id: Ia3ccc07d79cc0736eb12e9782da50211abb74772
Signed-off-by: Stone Li <stone.li@bambulab.com>
This commit is contained in:
Stone Li 2024-01-03 08:59:34 +08:00 committed by Lane.Wei
parent 825b0886cb
commit bc8c8d8d07
2 changed files with 12 additions and 3 deletions

View File

@ -17,7 +17,8 @@ int get_hms_info_version(std::string& version)
}
int result = -1;
version = "";
std::string url = (boost::format("https://%1%/GetVersion.php") % hms_host).str();
std::string query_params = HMSQuery::build_query_params();
std::string url = (boost::format("https://%1%/GetVersion.php?%2%") % hms_host % query_params).str();
Slic3r::Http http = Slic3r::Http::get(url);
http.timeout_max(10)
.on_complete([&result, &version](std::string body, unsigned status){
@ -44,8 +45,8 @@ int HMSQuery::download_hms_info()
if (!config) return -1;
std::string hms_host = wxGetApp().app_config->get_hms_host();
std::string lang_code = HMSQuery::hms_language_code();
std::string url = (boost::format("https://%1%/query.php?lang=%2%") % hms_host % lang_code).str();
std::string query_params = HMSQuery::build_query_params();
std::string url = (boost::format("https://%1%/query.php?%2%") % hms_host % query_params).str();
BOOST_LOG_TRIVIAL(info) << "hms: download url = " << url;
@ -152,6 +153,13 @@ std::string HMSQuery::hms_language_code()
return lang_code;
}
std::string HMSQuery::build_query_params()
{
std::string lang_code = HMSQuery::hms_language_code();
std::string query_params = (boost::format("lang=%1%") % lang_code).str();
return query_params;
}
std::string HMSQuery::get_hms_file()
{
std::string lang_code = HMSQuery::hms_language_code();

View File

@ -32,6 +32,7 @@ public:
wxString query_hms_msg(std::string long_error_code);
wxString query_print_error_msg(int print_error);
static std::string hms_language_code();
static std::string build_query_params();
};
int get_hms_info_version(std::string &version);