Skip to content
Open
Show file tree
Hide file tree
Changes from 9 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 2 additions & 4 deletions src/slic3r/GUI/GUI_App.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5408,8 +5408,6 @@ std::string GUI_App::handle_web_request(std::string cmd)

boost::optional<std::string> sequence_id = root.get_optional<std::string>("sequence_id");
boost::optional<std::string> command = root.get_optional<std::string>("command");

wxString strInput = cmd;


if (command.has_value()) {
Expand Down Expand Up @@ -6221,7 +6219,7 @@ std::string GUI_App::handle_web_request(std::string cmd)
wxString strJS = wxString::Format("window.handleStudioCmd('%s');", commandJson.dump());
wxGetApp().CallAfter([this, strJS] { run_script(strJS.ToStdString()); });
} else if (command_str.compare("set_deviceAdd_end") == 0) {
json printersData = json::parse(strInput);
json printersData = json::parse(cmd);
json selectedPrintersJson = printersData["selected_printers"];

for (auto it = selectedPrintersJson.begin(); it != selectedPrintersJson.end(); ++it) {
Expand Down Expand Up @@ -6650,7 +6648,7 @@ void GUI_App::on_http_error(wxCommandEvent &evt)
wxString result;
if (status >= 400 && status < 500) {
try {
json j = json::parse(evt.GetString());
json j = json::parse(evt.GetString().ToStdString());
if (j.contains("code")) {
if (!j["code"].is_null())
code = j["code"].get<int>();
Expand Down
4 changes: 2 additions & 2 deletions src/slic3r/GUI/ModelMall.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -123,10 +123,10 @@ namespace GUI {
void ModelMallDialog::OnScriptMessage(wxWebViewEvent& evt)
{
try {
wxString strInput = evt.GetString();
std::string strInput = evt.GetString().toStdString();
json j = json::parse(strInput);

wxString strCmd = j["command"];
std::string strCmd = j["command"];

if(strCmd == "request_close_publish_window") {
this->Hide();
Expand Down
8 changes: 4 additions & 4 deletions src/slic3r/GUI/Project.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -237,16 +237,16 @@ void ProjectPanel::on_navigated(wxWebViewEvent& event)
void ProjectPanel::OnScriptMessage(wxWebViewEvent& evt)
{
try {
wxString strInput = evt.GetString();
std::string strInput = evt.GetString().ToStdString();
json j = json::parse(strInput);

wxString strCmd = j["command"];
std::string strCmd = j["command"];

if (strCmd == "open_3mf_accessory") {
wxString accessory_path = j["accessory_path"];
std::string accessory_path = j["accessory_path"];

if (!accessory_path.empty()) {
std::string decode_path = wxGetApp().url_decode(accessory_path.ToStdString());
std::string decode_path = wxGetApp().url_decode(accessory_path);
fs::path path(decode_path);

if (fs::exists(path)) {
Expand Down
4 changes: 2 additions & 2 deletions src/slic3r/GUI/WebDownPluginDlg.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -198,10 +198,10 @@ void DownPluginFrame::OnFullScreenChanged(wxWebViewEvent &evt)
void DownPluginFrame::OnScriptMessage(wxWebViewEvent &evt)
{
try {
wxString strInput = evt.GetString();
std::string strInput = evt.GetString().ToStdString();
json j = json::parse(strInput);

wxString strCmd = j["command"];
std::string strCmd = j["command"];

if (strCmd == "Begin_Download_network_plugin") {
wxGetApp().CallAfter([this] { DownloadPlugin(); });
Expand Down
8 changes: 4 additions & 4 deletions src/slic3r/GUI/WebGuideDialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -430,18 +430,18 @@ static std::vector<std::string> Loc_GetMaterials(const std::string& materials)
void GuideFrame::OnScriptMessage(wxWebViewEvent &evt)
{
try {
wxString strInput = evt.GetString();
std::string strInput = evt.GetString().ToStdString();
BOOST_LOG_TRIVIAL(trace) << "GuideFrame::OnScriptMessage;OnRecv:" << strInput.c_str();
json j = json::parse(strInput);

wxString strCmd = j["command"];
std::string strCmd = j["command"];
BOOST_LOG_TRIVIAL(trace) << "GuideFrame::OnScriptMessage;Command:" << strCmd;

if (strCmd == "close_page") {
this->EndModal(wxID_CANCEL);
}
if (strCmd == "user_clause") {
wxString strAction = j["data"]["action"];
std::string strAction = j["data"]["action"];

if (strAction == "refuse") {
// CloseTheApp
Expand All @@ -450,7 +450,7 @@ void GuideFrame::OnScriptMessage(wxWebViewEvent &evt)
m_MainPtr->mainframe->Close(); // Refuse Clause, App quit immediately
}
} else if (strCmd == "user_private_choice") {
wxString strAction = j["data"]["action"];
std::string strAction = j["data"]["action"];

if (strAction == "agree") {
PrivacyUse = true;
Expand Down
18 changes: 9 additions & 9 deletions src/slic3r/GUI/print_manage/App/PrinterMgrView.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -325,29 +325,29 @@ void PrinterMgrView::OnScriptMessage(wxWebViewEvent& evt)
return;
}

wxString strInput = evt.GetString();
std::string strInput = evt.GetString().ToStdString();
BOOST_LOG_TRIVIAL(trace) << "DeviceDialog::OnScriptMessage;OnRecv:" << strInput.c_str();
json j = json::parse(strInput);

wxString strCmd = j["command"];
std::string strCmd = j["command"];
BOOST_LOG_TRIVIAL(trace) << "DeviceDialog::OnScriptMessage;Command:" << strCmd;

if (strCmd == "send_gcode")
{
int plateIndex = j["plateIndex"];
wxString ipAddress = j["ipAddress"];
wxString uploadName = j["uploadName"];
std::string ipAddress = j["ipAddress"];
std::string uploadName = j["uploadName"];
bool oldPrinter = j["oldPrinter"];
int moonrakerPort = j["moonrakerPort"];

if (oldPrinter)
{
std::string strIpAddr = ipAddress.ToStdString();
std::string strIpAddr = ipAddress;
RemotePrint::RemotePrinterManager::getInstance().setOldPrinterMap(strIpAddr);
}
if (moonrakerPort > 0)
{
std::string strIpAddr = ipAddress.ToStdString();
std::string strIpAddr = ipAddress;
if (strIpAddr.find('(') != std::string::npos)
{
RemotePrint::RemotePrinterManager::getInstance().setKlipperPrinterMap(strIpAddr, moonrakerPort);
Expand All @@ -369,7 +369,7 @@ void PrinterMgrView::OnScriptMessage(wxWebViewEvent& evt)

}

RemotePrint::RemotePrinterManager::getInstance().pushUploadMultTasks(ipAddress.ToStdString(), uploadName.ToStdString(), gcodeFilePath,
RemotePrint::RemotePrinterManager::getInstance().pushUploadMultTasks(ipAddress, uploadName, gcodeFilePath,
[this](std::string ip, float progress, double speed) {
// BOOST_LOG_TRIVIAL(info) << "Progress: " << progress << "% for IP: " << ip;
//进度发送太快会导致浏览器卡死,所以这里限制一下
Expand Down Expand Up @@ -491,9 +491,9 @@ void PrinterMgrView::OnScriptMessage(wxWebViewEvent& evt)
scan_device();
}

else if (m_commandHandlers.find(strCmd.ToStdString()) != m_commandHandlers.end())
else if (m_commandHandlers.find(strCmd) != m_commandHandlers.end())
{
m_commandHandlers[strCmd.ToStdString()](j);
m_commandHandlers[strCmd](j);
}
else if (strCmd == "req_device_move_direction")
{
Expand Down
10 changes: 5 additions & 5 deletions src/slic3r/GUI/print_manage/App/SendToPrinter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -315,10 +315,10 @@ void CxSentToPrinterDialog::UnregisterHandler(const std::string& command)
void CxSentToPrinterDialog::OnScriptMessage(wxWebViewEvent& evt)
{
try {
wxString strInput = evt.GetString();
std::string strInput = evt.GetString().ToStdString();
BOOST_LOG_TRIVIAL(trace) << "DeviceDialog::OnScriptMessage;OnRecv:" << strInput.c_str();
json j = json::parse(strInput);
wxString strCmd = j["command"];
std::string strCmd = j["command"];
BOOST_LOG_TRIVIAL(trace) << "DeviceDialog::OnScriptMessage;Command:" << strCmd;
if(strCmd == "forward_device_detail"){
wxPostEvent(this, wxCloseEvent(wxEVT_CLOSE_WINDOW));
Expand All @@ -343,8 +343,8 @@ void CxSentToPrinterDialog::OnScriptMessage(wxWebViewEvent& evt)



if (m_commandHandlers.find(strCmd.ToStdString()) != m_commandHandlers.end()) {
m_commandHandlers[strCmd.ToStdString()](j);
if (m_commandHandlers.find(strCmd) != m_commandHandlers.end()) {
m_commandHandlers[strCmd](j);
} else {
BOOST_LOG_TRIVIAL(trace) << "CxSentToPrinterDialog::OnScriptMessage;Unknown Command:" << strCmd;
}
Expand Down Expand Up @@ -1738,4 +1738,4 @@ int CxSentToPrinterDialog::load_machine_preset_data()
}

} // namespace GUI
} // namespace Slic3r
} // namespace Slic3r