ENH:add the function of using FTP only

Change-Id: If2dc3d1c9d913d1aacd426640a01a714d45a6774
This commit is contained in:
tao wang 2023-02-03 18:05:33 +08:00 committed by Lane.Wei
parent 59f7c4595c
commit 1fc0a752db
2 changed files with 47 additions and 23 deletions

View File

@ -277,32 +277,56 @@ void PrintJob::process()
else if (params.password.empty()) else if (params.password.empty())
params.comments = "no_password"; params.comments = "no_password";
if (!this->cloud_print_only
&& !params.password.empty() //use ftp only
&& !params.dev_ip.empty() if (!wxGetApp().app_config->get("lan_mode_only").empty() && wxGetApp().app_config->get("lan_mode_only") == "1") {
&& this->has_sdcard) {
// try to send local with record if (params.password.empty() || params.dev_ip.empty()) {
BOOST_LOG_TRIVIAL(info) << "print_job: try to start local print with record"; error_text = wxString::Format("Access code:%s Ip address:%s", params.password, params.dev_ip);
this->update_status(curr_percent, _L("Sending print job over LAN")); result = BAMBU_NETWORK_ERR_FTP_UPLOAD_FAILED;
result = m_agent->start_local_print_with_record(params, update_fn, cancel_fn);
if (result == BAMBU_NETWORK_ERR_FTP_LOGIN_DENIED) {
params.comments = "wrong_code";
} else if (result == BAMBU_NETWORK_ERR_FTP_UPLOAD_FAILED) {
params.comments = "upload_failed";
} else {
params.comments = (boost::format("failed(%1%)") % result).str();
} }
if (result < 0) { else {
// try to send with cloud BOOST_LOG_TRIVIAL(info) << "print_job: use ftp send print only";
BOOST_LOG_TRIVIAL(warning) << "print_job: try to send with cloud"; this->update_status(curr_percent, _L("Sending print job over LAN"));
result = m_agent->start_local_print_with_record(params, update_fn, cancel_fn);
if (result < 0) {
error_text = wxString::Format("Access code:%s Ip address:%s", params.password, params.dev_ip);
// try to send with cloud
BOOST_LOG_TRIVIAL(warning) << "print_job: use ftp send print failed";
}
}
}
else {
if (!this->cloud_print_only
&& !params.password.empty()
&& !params.dev_ip.empty()
&& this->has_sdcard) {
// try to send local with record
BOOST_LOG_TRIVIAL(info) << "print_job: try to start local print with record";
this->update_status(curr_percent, _L("Sending print job over LAN"));
result = m_agent->start_local_print_with_record(params, update_fn, cancel_fn);
if (result == BAMBU_NETWORK_ERR_FTP_LOGIN_DENIED) {
params.comments = "wrong_code";
}
else if (result == BAMBU_NETWORK_ERR_FTP_UPLOAD_FAILED) {
params.comments = "upload_failed";
}
else {
params.comments = (boost::format("failed(%1%)") % result).str();
}
if (result < 0) {
// try to send with cloud
BOOST_LOG_TRIVIAL(warning) << "print_job: try to send with cloud";
this->update_status(curr_percent, _L("Sending print job through cloud service"));
result = m_agent->start_print(params, update_fn, cancel_fn);
}
}
else {
BOOST_LOG_TRIVIAL(info) << "print_job: send with cloud";
this->update_status(curr_percent, _L("Sending print job through cloud service")); this->update_status(curr_percent, _L("Sending print job through cloud service"));
result = m_agent->start_print(params, update_fn, cancel_fn); result = m_agent->start_print(params, update_fn, cancel_fn);
} }
} else { }
BOOST_LOG_TRIVIAL(info) << "print_job: send with cloud";
this->update_status(curr_percent, _L("Sending print job through cloud service"));
result = m_agent->start_print(params, update_fn, cancel_fn);
}
} else { } else {
if (this->has_sdcard) { if (this->has_sdcard) {
this->update_status(curr_percent, _L("Sending print job over LAN")); this->update_status(curr_percent, _L("Sending print job over LAN"));

View File

@ -1236,7 +1236,7 @@ SelectMachineDialog::SelectMachineDialog(Plater *plater)
if (e.GetInt() == 1) { if (e.GetInt() == 1) {
DeviceManager* dev = Slic3r::GUI::wxGetApp().getDeviceManager(); DeviceManager* dev = Slic3r::GUI::wxGetApp().getDeviceManager();
if (!dev) return; if (!dev) return;
m_comboBox_printer->SetValue(dev->get_selected_machine()->dev_name); m_comboBox_printer->SetValue(dev->get_selected_machine()->dev_name + "(LAN)");
} }
}); });