NEW:the model mall is opened using the default browser
Change-Id: I9f855288486196b2a7c72c51bee8cfcf408ceab8
This commit is contained in:
parent
7eb3aa8104
commit
311d9c3481
|
@ -1296,6 +1296,32 @@ std::string GUI_App::get_http_url(std::string country_code)
|
|||
return url;
|
||||
}
|
||||
|
||||
std::string GUI_App::get_model_http_url(std::string country_code)
|
||||
{
|
||||
std::string url;
|
||||
if (country_code == "US") {
|
||||
url = "https://makerhub.bambu-lab.com/";
|
||||
}
|
||||
else if (country_code == "CN") {
|
||||
url = "https://makerhub.bambu-lab.com/zh/";
|
||||
}
|
||||
else if (country_code == "ENV_CN_DEV") {
|
||||
url = "https://makerhub-dev.bambu-lab.com/";
|
||||
}
|
||||
else if (country_code == "ENV_CN_QA") {
|
||||
url = "https://makerhub-qa.bambu-lab.com/";
|
||||
}
|
||||
else if (country_code == "ENV_CN_PRE") {
|
||||
url = "https://makerhub-pre.bambu-lab.com/";
|
||||
}
|
||||
else {
|
||||
url = "https://makerhub.bambu-lab.com/";
|
||||
}
|
||||
|
||||
return url;
|
||||
}
|
||||
|
||||
|
||||
std::string GUI_App::get_plugin_url(std::string name, std::string country_code)
|
||||
{
|
||||
std::string url = get_http_url(country_code);
|
||||
|
@ -5409,45 +5435,94 @@ void GUI_App::load_url(wxString url)
|
|||
|
||||
void GUI_App::open_mall_page_dialog()
|
||||
{
|
||||
std::string url;
|
||||
std::string host_url;
|
||||
std::string model_url;
|
||||
std::string link_url;
|
||||
|
||||
int result = -1;
|
||||
|
||||
//model api url
|
||||
host_url = get_model_http_url(app_config->get_country_code());
|
||||
|
||||
//model url
|
||||
|
||||
wxString language_code = this->current_language_code().BeforeFirst('_');
|
||||
model_url += (language_code.ToStdString() + "/models");
|
||||
|
||||
if (getAgent() && mainframe) {
|
||||
getAgent()->get_model_mall_home_url(&url);
|
||||
|
||||
if (!m_mall_home_dialog) {
|
||||
m_mall_home_dialog = new ModelMallDialog();
|
||||
m_mall_home_dialog->go_to_mall(url);
|
||||
}
|
||||
else {
|
||||
if (m_mall_home_dialog->IsIconized())
|
||||
m_mall_home_dialog->Iconize(false);
|
||||
//login already
|
||||
if (getAgent()->is_user_login()) {
|
||||
std::string ticket;
|
||||
result = getAgent()->request_bind_ticket(&ticket);
|
||||
|
||||
//m_mall_home_dialog->go_to_mall(url);
|
||||
}
|
||||
m_mall_home_dialog->Raise();
|
||||
m_mall_home_dialog->Show();
|
||||
if(result == 0){
|
||||
link_url = host_url + "api/sign-in/ticket?to=" + host_url + url_encode(model_url) + "&ticket=" + ticket;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (result < 0) {
|
||||
link_url = host_url + model_url;
|
||||
}
|
||||
|
||||
wxLaunchDefaultBrowser(link_url);
|
||||
}
|
||||
|
||||
void GUI_App::open_publish_page_dialog()
|
||||
{
|
||||
std::string url;
|
||||
std::string host_url;
|
||||
std::string model_url;
|
||||
std::string link_url;
|
||||
|
||||
int result = -1;
|
||||
|
||||
//model api url
|
||||
host_url = get_model_http_url(app_config->get_country_code());
|
||||
|
||||
//publish url
|
||||
wxString language_code = this->current_language_code().BeforeFirst('_');
|
||||
model_url += (language_code.ToStdString() + "/my/models/publish");
|
||||
|
||||
if (getAgent() && mainframe) {
|
||||
getAgent()->get_model_publish_url(&url);
|
||||
|
||||
if (!m_mall_publish_dialog) {
|
||||
m_mall_publish_dialog = new ModelMallDialog();
|
||||
m_mall_publish_dialog->go_to_mall(url);
|
||||
}
|
||||
else {
|
||||
if (m_mall_publish_dialog->IsIconized())
|
||||
m_mall_publish_dialog->Iconize(false);
|
||||
//login already
|
||||
if (getAgent()->is_user_login()) {
|
||||
std::string ticket;
|
||||
result = getAgent()->request_bind_ticket(&ticket);
|
||||
|
||||
//m_mall_publish_dialog->go_to_publish(url);
|
||||
if (result == 0) {
|
||||
link_url = host_url + "api/sign-in/ticket?to=" + host_url + url_encode(model_url) + "&ticket=" + ticket;
|
||||
}
|
||||
}
|
||||
m_mall_publish_dialog->Raise();
|
||||
m_mall_publish_dialog->Show();
|
||||
}
|
||||
|
||||
if (result < 0) {
|
||||
link_url = host_url + model_url;
|
||||
}
|
||||
|
||||
wxLaunchDefaultBrowser(link_url);
|
||||
}
|
||||
|
||||
std::string GUI_App::url_encode(const std::string& value) {
|
||||
std::ostringstream escaped;
|
||||
escaped.fill('0');
|
||||
escaped << std::hex;
|
||||
for (std::string::const_iterator i = value.begin(), n = value.end(); i != n; ++i) {
|
||||
std::string::value_type c = (*i);
|
||||
|
||||
// Keep alphanumeric and other accepted characters intact
|
||||
if (isalnum(c) || c == '-' || c == '_' || c == '.' || c == '~') {
|
||||
escaped << c;
|
||||
continue;
|
||||
}
|
||||
|
||||
// Any other characters are percent-encoded
|
||||
escaped << std::uppercase;
|
||||
escaped << '%' << std::setw(2) << int((unsigned char)c);
|
||||
escaped << std::nouppercase;
|
||||
}
|
||||
return escaped.str();
|
||||
}
|
||||
|
||||
void GUI_App::remove_mall_system_dialog()
|
||||
|
@ -5456,12 +5531,6 @@ void GUI_App::remove_mall_system_dialog()
|
|||
m_mall_publish_dialog->Destroy();
|
||||
delete m_mall_publish_dialog;
|
||||
}
|
||||
|
||||
|
||||
if (m_mall_home_dialog != nullptr) {
|
||||
m_mall_home_dialog->Destroy();
|
||||
delete m_mall_home_dialog;
|
||||
}
|
||||
}
|
||||
|
||||
void GUI_App::run_script(wxString js)
|
||||
|
|
|
@ -509,7 +509,6 @@ public:
|
|||
|
||||
std::string m_mall_model_download_url;
|
||||
std::string m_mall_model_download_name;
|
||||
ModelMallDialog* m_mall_home_dialog{ nullptr };
|
||||
ModelMallDialog* m_mall_publish_dialog{ nullptr };
|
||||
|
||||
void set_download_model_url(std::string url) {m_mall_model_download_url = url;}
|
||||
|
@ -519,6 +518,7 @@ public:
|
|||
|
||||
void load_url(wxString url);
|
||||
void open_mall_page_dialog();
|
||||
std::string url_encode(const std::string& value);
|
||||
void open_publish_page_dialog();
|
||||
void remove_mall_system_dialog();
|
||||
void run_script(wxString js);
|
||||
|
@ -586,6 +586,7 @@ public:
|
|||
int download_plugin(std::string name, std::string package_name, InstallProgressFn pro_fn = nullptr, WasCancelledFn cancel_fn = nullptr);
|
||||
int install_plugin(std::string name, std::string package_name, InstallProgressFn pro_fn = nullptr, WasCancelledFn cancel_fn = nullptr);
|
||||
std::string get_http_url(std::string country_code);
|
||||
std::string get_model_http_url(std::string country_code);
|
||||
bool is_compatibility_version();
|
||||
bool check_networking_version();
|
||||
void cancel_networking_install();
|
||||
|
|
|
@ -113,10 +113,10 @@ void ProjectPanel::on_reload(wxCommandEvent& evt)
|
|||
|
||||
json j;
|
||||
j["model"]["license"] = license;
|
||||
j["model"]["name"] = url_encode(model_name);
|
||||
j["model"]["author"] = url_encode(model_author);;
|
||||
j["model"]["cover_img"] = url_encode(cover_file);
|
||||
j["model"]["description"] = url_encode(description);
|
||||
j["model"]["name"] = wxGetApp().url_encode(model_name);
|
||||
j["model"]["author"] = wxGetApp().url_encode(model_author);;
|
||||
j["model"]["cover_img"] = wxGetApp().url_encode(cover_file);
|
||||
j["model"]["description"] = wxGetApp().url_encode(description);
|
||||
j["model"]["preview_img"] = files["Model Pictures"];
|
||||
j["model"]["upload_type"] = update_type;
|
||||
|
||||
|
@ -124,10 +124,10 @@ void ProjectPanel::on_reload(wxCommandEvent& evt)
|
|||
j["file"]["Assembly"] = files["Assembly Guide"];
|
||||
j["file"]["Other"] = files["Others"];
|
||||
|
||||
j["profile"]["name"] = url_encode(p_name);
|
||||
j["profile"]["author"] = url_encode(p_author);
|
||||
j["profile"]["description"] = url_encode(p_description);
|
||||
j["profile"]["cover_img"] = url_encode(p_cover_file);
|
||||
j["profile"]["name"] = wxGetApp().url_encode(p_name);
|
||||
j["profile"]["author"] = wxGetApp().url_encode(p_author);
|
||||
j["profile"]["description"] = wxGetApp().url_encode(p_description);
|
||||
j["profile"]["cover_img"] = wxGetApp().url_encode(p_cover_file);
|
||||
j["profile"]["preview_img"] = files["Profile Pictures"];
|
||||
|
||||
json m_Res = json::object();
|
||||
|
@ -287,7 +287,7 @@ std::map<std::string, std::vector<json>> ProjectPanel::Reload(wxString aux_path)
|
|||
wxStat(file_name, &strucStat);
|
||||
wxFileOffset filelen = strucStat.st_size;
|
||||
|
||||
pfile_obj["filename"] = url_encode(file_path_obj.filename().string().c_str());
|
||||
pfile_obj["filename"] = wxGetApp().url_encode(file_path_obj.filename().string().c_str());
|
||||
pfile_obj["size"] = formatBytes((unsigned long)filelen);
|
||||
|
||||
//image
|
||||
|
@ -303,7 +303,7 @@ std::map<std::string, std::vector<json>> ProjectPanel::Reload(wxString aux_path)
|
|||
break;
|
||||
}
|
||||
else {
|
||||
pfile_obj["filepath"] = url_encode(file_path);
|
||||
pfile_obj["filepath"] = wxGetApp().url_encode(file_path);
|
||||
m_paths_list[folder.ToStdString()].push_back(pfile_obj);
|
||||
break;
|
||||
}
|
||||
|
@ -382,27 +382,6 @@ std::string ProjectPanel::url_decode(string text) {
|
|||
return escaped.str();
|
||||
}
|
||||
|
||||
std::string ProjectPanel::url_encode(const std::string& value) {
|
||||
std::ostringstream escaped;
|
||||
escaped.fill('0');
|
||||
escaped << std::hex;
|
||||
for (std::string::const_iterator i = value.begin(), n = value.end(); i != n; ++i) {
|
||||
std::string::value_type c = (*i);
|
||||
|
||||
// Keep alphanumeric and other accepted characters intact
|
||||
if (isalnum(c) || c == '-' || c == '_' || c == '.' || c == '~') {
|
||||
escaped << c;
|
||||
continue;
|
||||
}
|
||||
|
||||
// Any other characters are percent-encoded
|
||||
escaped << std::uppercase;
|
||||
escaped << '%' << std::setw(2) << int((unsigned char)c);
|
||||
escaped << std::nouppercase;
|
||||
}
|
||||
return escaped.str();
|
||||
}
|
||||
|
||||
bool ProjectPanel::Show(bool show)
|
||||
{
|
||||
if (show) update_model_data();
|
||||
|
|
|
@ -87,6 +87,7 @@ func_get_user_print_info NetworkAgent::get_user_print_info_ptr = null
|
|||
func_get_printer_firmware NetworkAgent::get_printer_firmware_ptr = nullptr;
|
||||
func_get_task_plate_index NetworkAgent::get_task_plate_index_ptr = nullptr;
|
||||
func_get_user_info NetworkAgent::get_user_info_ptr = nullptr;
|
||||
func_request_bind_ticket NetworkAgent::request_bind_ticket_ptr = nullptr;
|
||||
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;
|
||||
|
@ -229,6 +230,7 @@ int NetworkAgent::initialize_network_module(bool using_backup)
|
|||
get_printer_firmware_ptr = reinterpret_cast<func_get_printer_firmware>(get_network_function("bambu_network_get_printer_firmware"));
|
||||
get_task_plate_index_ptr = reinterpret_cast<func_get_task_plate_index>(get_network_function("bambu_network_get_task_plate_index"));
|
||||
get_user_info_ptr = reinterpret_cast<func_get_user_info>(get_network_function("bambu_network_get_user_info"));
|
||||
request_bind_ticket_ptr = reinterpret_cast<func_request_bind_ticket>(get_network_function("bambu_network_request_bind_ticket"));
|
||||
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"));
|
||||
|
@ -1019,6 +1021,17 @@ int NetworkAgent::get_user_info(int* identifier)
|
|||
return ret;
|
||||
}
|
||||
|
||||
int NetworkAgent::request_bind_ticket(std::string* ticket)
|
||||
{
|
||||
int ret = 0;
|
||||
if (network_agent && request_bind_ticket_ptr) {
|
||||
ret = request_bind_ticket_ptr(network_agent, ticket);
|
||||
if (ret)
|
||||
BOOST_LOG_TRIVIAL(error) << __FUNCTION__ << boost::format(" error: network_agent=%1%, ret=%2%") % network_agent % ret;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
int NetworkAgent::get_slice_info(std::string project_id, std::string profile_id, int plate_index, std::string* slice_json)
|
||||
{
|
||||
int ret;
|
||||
|
|
|
@ -67,6 +67,7 @@ typedef int (*func_get_user_print_info)(void *agent, unsigned int* http_code, st
|
|||
typedef int (*func_get_printer_firmware)(void *agent, std::string dev_id, unsigned* http_code, std::string* http_body);
|
||||
typedef int (*func_get_task_plate_index)(void *agent, std::string task_id, int* plate_index);
|
||||
typedef int (*func_get_user_info)(void *agent, int* identifier);
|
||||
typedef int (*func_request_bind_ticket)(void *agent, std::string* ticket);
|
||||
typedef int (*func_get_slice_info)(void *agent, std::string project_id, std::string profile_id, int plate_index, std::string* slice_json);
|
||||
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);
|
||||
|
@ -151,6 +152,7 @@ public:
|
|||
int get_printer_firmware(std::string dev_id, unsigned* http_code, std::string* http_body);
|
||||
int get_task_plate_index(std::string task_id, int* plate_index);
|
||||
int get_user_info(int* identifier);
|
||||
int request_bind_ticket(std::string* ticket);
|
||||
int get_slice_info(std::string project_id, std::string profile_id, int plate_index, std::string* slice_json);
|
||||
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);
|
||||
|
@ -225,6 +227,7 @@ private:
|
|||
static func_get_printer_firmware get_printer_firmware_ptr;
|
||||
static func_get_task_plate_index get_task_plate_index_ptr;
|
||||
static func_get_user_info get_user_info_ptr;
|
||||
static func_request_bind_ticket request_bind_ticket_ptr;
|
||||
static func_get_slice_info get_slice_info_ptr;
|
||||
static func_query_bind_status query_bind_status_ptr;
|
||||
static func_modify_printer_name modify_printer_name_ptr;
|
||||
|
|
Loading…
Reference in New Issue