mirror of
https://github.com/OrcaSlicer/OrcaSlicer.git
synced 2026-09-27 10:51:22 +00:00
fix: defer filesystem and camera abstractions
This commit is contained in:
@@ -207,6 +207,8 @@ MediaFilePanel::MediaFilePanel(wxWindow * parent)
|
||||
Bind(wxEVT_SHOW, onShowHide);
|
||||
parent->GetParent()->Bind(wxEVT_SHOW, onShowHide);
|
||||
|
||||
m_lan_user = "bblp";
|
||||
|
||||
}
|
||||
|
||||
MediaFilePanel::~MediaFilePanel()
|
||||
@@ -465,19 +467,15 @@ void MediaFilePanel::fetchUrl(boost::weak_ptr<PrinterFileSystem> wfs)
|
||||
BOOST_LOG_TRIVIAL(info) << "MediaFilePanel::fetchUrl: " << m_local_proto << m_remote_proto;
|
||||
m_waiting_support = false;
|
||||
NetworkAgent *agent = wxGetApp().getAgent();
|
||||
if (agent && (m_lan_mode || !m_remote_proto) && m_local_proto && !m_lan_ip.empty()) {
|
||||
agent->get_file_transfer_url(
|
||||
m_machine,
|
||||
[this, wfs](FileTransferURLResult result) {
|
||||
CallAfter([this, wfs, result = std::move(result)] {
|
||||
auto fs = wfs.lock();
|
||||
if (!fs || fs != m_image_grid->GetFileSystem())
|
||||
return;
|
||||
fs->SetUrl(result.is_success ? result.url : std::to_string(result.error_code));
|
||||
});
|
||||
},
|
||||
{URL_TCP, m_lan_ip, agent->default_lan_username(), m_lan_passwd,
|
||||
m_machine, agent->get_version(), m_dev_ver, "", wxGetApp().app_config->get("slicer_uuid"), SLIC3R_VERSION});
|
||||
std::string agent_version = agent ? agent->get_version() : "";
|
||||
if ((m_lan_mode || !m_remote_proto) && m_local_proto && !m_lan_ip.empty()) {
|
||||
std::string url = "bambu:///local/" + m_lan_ip + ".?port=6000&user=" + m_lan_user + "&passwd=" + m_lan_passwd;
|
||||
url += "&device=" + m_machine;
|
||||
url += "&net_ver=" + agent_version;
|
||||
url += "&dev_ver=" + m_dev_ver;
|
||||
url += "&cli_id=" + wxGetApp().app_config->get("slicer_uuid");
|
||||
url += "&cli_ver=" + std::string(SLIC3R_VERSION);
|
||||
fs->SetUrl(url);
|
||||
return;
|
||||
}
|
||||
if (!m_remote_proto && m_local_proto) { // not support tutk
|
||||
@@ -496,15 +494,15 @@ void MediaFilePanel::fetchUrl(boost::weak_ptr<PrinterFileSystem> wfs)
|
||||
return;
|
||||
}
|
||||
if (agent) {
|
||||
agent->get_file_transfer_url(
|
||||
m_machine,
|
||||
[this, wfs, m = m_machine](FileTransferURLResult result) {
|
||||
std::string protocols[] = {"", "\"tutk\"", "\"agora\"", "\"tutk\",\"agora\""};
|
||||
agent->get_camera_url(m_machine + "|" + m_dev_ver + "|" + protocols[m_remote_proto],
|
||||
[this, wfs](CameraURLResult result) {
|
||||
std::string url = std::move(result.url);
|
||||
BOOST_LOG_TRIVIAL(info) << "MediaFilePanel::fetchUrl: file_system_url: " << hide_passwd(url, {"?uid=", "authkey=", "passwd="});
|
||||
BOOST_LOG_TRIVIAL(info) << "MediaFilePanel::fetchUrl: camera_url: " << hide_passwd(url, {"?uid=", "authkey=", "passwd="});
|
||||
CallAfter([=] {
|
||||
boost::shared_ptr fs(wfs.lock());
|
||||
if (!fs || fs != m_image_grid->GetFileSystem()) return;
|
||||
if (result.is_success) {
|
||||
if (result.is_success && boost::algorithm::starts_with(url, "bambu:///")) {
|
||||
fs->SetUrl(url);
|
||||
} else {
|
||||
m_image_grid->SetStatus(m_bmp_failed, _L("Connection Failed. Please check the network and try again"));
|
||||
@@ -512,9 +510,9 @@ void MediaFilePanel::fetchUrl(boost::weak_ptr<PrinterFileSystem> wfs)
|
||||
fs->SetUrl(res);
|
||||
}
|
||||
});
|
||||
},
|
||||
{URL_TUTK, "", "", "", m_machine, agent->get_version(), m_dev_ver,
|
||||
boost::lexical_cast<std::string>(&refresh_agora_url), wxGetApp().app_config->get("slicer_uuid"), SLIC3R_VERSION});
|
||||
}, wxGetApp().get_printer_cloud_provider(),
|
||||
CameraURLParams{"", "", "", LVL_None, m_machine, agent->get_version(), m_dev_ver,
|
||||
boost::lexical_cast<std::string>(&refresh_agora_url), wxGetApp().app_config->get("slicer_uuid"), SLIC3R_VERSION, true});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -80,6 +80,7 @@ private:
|
||||
|
||||
std::string m_machine;
|
||||
std::string m_lan_ip;
|
||||
std::string m_lan_user;
|
||||
std::string m_lan_passwd;
|
||||
std::string m_dev_ver;
|
||||
bool m_lan_mode = false;
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
#include "I18N.hpp"
|
||||
#include "MsgDialog.hpp"
|
||||
#include "DownloadProgressDialog.hpp"
|
||||
#include "slic3r/Utils/BBLNetworkPlugin.hpp"
|
||||
|
||||
|
||||
#include <boost/lexical_cast.hpp>
|
||||
@@ -126,6 +127,9 @@ MediaPlayCtrl::MediaPlayCtrl(wxWindow *parent, wxMediaCtrl2 *media_ctrl, const w
|
||||
parent->Bind(wxEVT_SHOW, &MediaPlayCtrl::on_show_hide, this);
|
||||
parent->GetParent()->GetParent()->Bind(wxEVT_SHOW, &MediaPlayCtrl::on_show_hide, this);
|
||||
|
||||
m_lan_user = "bblp";
|
||||
m_lan_passwd = "bblp";
|
||||
|
||||
}
|
||||
|
||||
MediaPlayCtrl::~MediaPlayCtrl()
|
||||
@@ -156,10 +160,8 @@ void MediaPlayCtrl::SetMachineObject(MachineObject* obj)
|
||||
m_device_busy = obj->is_camera_busy_off();
|
||||
m_tutk_state = obj->tutk_state;
|
||||
|
||||
auto *agent = wxGetApp().getAgent();
|
||||
if (agent && !agent->supports_remote_liveview(obj->printer_type)) {
|
||||
// The selected printer agent may force local mode for incompatible
|
||||
// plugin/printer combinations.
|
||||
if (DevPrinterConfigUtil::get_printer_series_str(obj->printer_type) == "series_o" && BBLNetworkPlugin::instance().use_legacy_network()) {
|
||||
// Legacy plugin cannot support remote play for H2D, force using local mode
|
||||
m_remote_proto = LiveviewRemote::LVR_None;
|
||||
}
|
||||
} else {
|
||||
@@ -287,21 +289,20 @@ void MediaPlayCtrl::Play()
|
||||
return;
|
||||
}
|
||||
std::string agent_version = agent->get_version();
|
||||
const std::string lan_user = agent->default_lan_username();
|
||||
if (m_lan_proto > LiveviewLocal::LVL_Disable && (m_lan_mode || !m_remote_proto) && !m_disable_lan && !m_lan_ip.empty()) {
|
||||
m_disable_lan = m_remote_proto && !m_lan_mode; // try remote next time
|
||||
std::string url = agent->get_local_camera_url({
|
||||
m_lan_ip,
|
||||
lan_user,
|
||||
m_lan_passwd,
|
||||
LiveviewLocal(m_lan_proto),
|
||||
into_u8(m_machine),
|
||||
agent_version,
|
||||
m_dev_ver,
|
||||
"",
|
||||
wxGetApp().app_config->get("slicer_uuid"),
|
||||
SLIC3R_VERSION
|
||||
});
|
||||
std::string url;
|
||||
if (m_lan_proto == LiveviewLocal::LVL_Local)
|
||||
url = "bambu:///local/" + m_lan_ip + ".?port=6000&user=" + m_lan_user + "&passwd=" + m_lan_passwd;
|
||||
else if (m_lan_proto == LiveviewLocal::LVL_Rtsps)
|
||||
url = "bambu:///rtsps___" + m_lan_user + ":" + m_lan_passwd + "@" + m_lan_ip + "/streaming/live/1?proto=rtsps";
|
||||
else if (m_lan_proto == LiveviewLocal::LVL_Rtsp)
|
||||
url = "bambu:///rtsp___" + m_lan_user + ":" + m_lan_passwd + "@" + m_lan_ip + "/streaming/live/1?proto=rtsp";
|
||||
url += "&device=" + m_machine;
|
||||
url += "&net_ver=" + agent_version;
|
||||
url += "&dev_ver=" + m_dev_ver;
|
||||
url += "&cli_id=" + wxGetApp().app_config->get("slicer_uuid");
|
||||
url += "&cli_ver=" + std::string(SLIC3R_VERSION);
|
||||
BOOST_LOG_TRIVIAL(info) << "MediaPlayCtrl: " << hide_passwd(hide_id_middle_string(url, url.find(m_lan_ip), m_lan_ip.length()), {m_lan_passwd});
|
||||
m_url = url;
|
||||
load();
|
||||
@@ -527,10 +528,15 @@ void MediaPlayCtrl::ToggleStream()
|
||||
if (res == wxID_CANCEL) return;
|
||||
}
|
||||
if (m_lan_proto > LiveviewLocal::LVL_Disable && (m_lan_mode || !m_remote_proto) && !m_disable_lan && !m_lan_ip.empty()) {
|
||||
NetworkAgent *agent = wxGetApp().getAgent();
|
||||
if (!agent) return;
|
||||
std::string url = agent->get_local_camera_url({m_lan_ip, agent->default_lan_username(), m_lan_passwd, LiveviewLocal(m_lan_proto),
|
||||
into_u8(m_machine), agent->get_version(), m_dev_ver, "", wxGetApp().app_config->get("slicer_uuid"), SLIC3R_VERSION});
|
||||
std::string url;
|
||||
if (m_lan_proto == LiveviewLocal::LVL_Local)
|
||||
url = "bambu:///local/" + m_lan_ip + ".?port=6000&user=" + m_lan_user + "&passwd=" + m_lan_passwd;
|
||||
else if (m_lan_proto == LiveviewLocal::LVL_Rtsps)
|
||||
url = "bambu:///rtsps___" + m_lan_user + ":" + m_lan_passwd + "@" + m_lan_ip + "/streaming/live/1?proto=rtsps";
|
||||
else if (m_lan_proto == LiveviewLocal::LVL_Rtsp)
|
||||
url = "bambu:///rtsp___" + m_lan_user + ":" + m_lan_passwd + "@" + m_lan_ip + "/streaming/live/1?proto=rtsp";
|
||||
url += "&device=" + into_u8(m_machine);
|
||||
url += "&dev_ver=" + m_dev_ver;
|
||||
BOOST_LOG_TRIVIAL(info) << "MediaPlayCtrl::ToggleStream: " << hide_passwd(hide_id_middle_string(url, url.find(m_lan_ip), m_lan_ip.length()), {m_lan_passwd});
|
||||
std::string file_url = data_dir() + "/cameratools/url.txt";
|
||||
boost::nowide::ofstream file(file_url);
|
||||
|
||||
@@ -80,6 +80,7 @@ private:
|
||||
std::string m_machine;
|
||||
int m_lan_proto = 0;
|
||||
std::string m_lan_ip;
|
||||
std::string m_lan_user;
|
||||
std::string m_lan_passwd;
|
||||
std::string m_dev_ver;
|
||||
std::string m_tutk_state;
|
||||
|
||||
@@ -27,6 +27,7 @@
|
||||
#include "PartSkipDialog.hpp"
|
||||
#include "SkipPartCanvas.hpp"
|
||||
#include "MediaPlayCtrl.h"
|
||||
#include "slic3r/Utils/NetworkAgent.hpp"
|
||||
|
||||
#include "DeviceCore/DevManager.h"
|
||||
|
||||
@@ -434,37 +435,41 @@ void PartSkipDialog::fetchUrl(boost::weak_ptr<PrinterFileSystem> wfs)
|
||||
std::string dev_ver = obj->get_ota_version();
|
||||
std::string dev_id = obj->get_dev_id();
|
||||
|
||||
auto url_state = m_url_state;
|
||||
if (obj->is_lan_mode_printer()) { url_state = URL_TCP; }
|
||||
|
||||
NetworkAgent *agent = wxGetApp().getAgent();
|
||||
if (!agent) {
|
||||
fs->SetUrl("3");
|
||||
return;
|
||||
}
|
||||
|
||||
auto url_state = m_url_state;
|
||||
if (obj->is_lan_mode_printer()) { url_state = URL_TCP; }
|
||||
|
||||
FileTransferURLParams params;
|
||||
params.url_state = url_state;
|
||||
params.ip_address = obj->get_dev_ip();
|
||||
params.username = agent->default_lan_username();
|
||||
params.password = obj->get_access_code();
|
||||
params.device_id = dev_id;
|
||||
params.network_version = agent->get_version();
|
||||
params.device_version = dev_ver;
|
||||
params.refresh_url = boost::lexical_cast<std::string>(&refresh_agora_url);
|
||||
params.client_id = wxGetApp().app_config->get("slicer_uuid");
|
||||
params.client_version = SLIC3R_VERSION;
|
||||
|
||||
agent->get_file_transfer_url(
|
||||
dev_id,
|
||||
[this, wfs](FileTransferURLResult result) {
|
||||
switch (url_state) {
|
||||
case URL_TCP: {
|
||||
std::string tcp_url = "bambu:///local/" + obj->get_dev_ip() + "?port=6000&user=bblp&passwd=" + obj->get_access_code();
|
||||
CallAfter([wfs, tcp_url = std::move(tcp_url)] {
|
||||
if (auto fs = wfs.lock())
|
||||
fs->SetUrl(boost::algorithm::starts_with(tcp_url, "bambu:///") ? tcp_url : "3");
|
||||
});
|
||||
break;
|
||||
}
|
||||
case URL_TUTK: {
|
||||
std::string protocols[] = {"", "\"tutk\"", "\"agora\"", "\"tutk\",\"agora\""};
|
||||
agent->get_camera_url(dev_id + "|" + dev_ver + "|" + protocols[3],
|
||||
[this, wfs](CameraURLResult result) {
|
||||
CallAfter([wfs, result = std::move(result)]() mutable {
|
||||
boost::shared_ptr fs(wfs.lock());
|
||||
if (!fs) return;
|
||||
fs->SetUrl(result.is_success ? result.url : "3");
|
||||
fs->SetUrl(result.is_success && boost::algorithm::starts_with(result.url, "bambu:///") ? result.url : "3");
|
||||
});
|
||||
},
|
||||
std::move(params));
|
||||
}, wxGetApp().get_printer_cloud_provider(),
|
||||
CameraURLParams{"", "", "", LVL_None, dev_id, agent->get_version(), dev_ver,
|
||||
boost::lexical_cast<std::string>(&refresh_agora_url), wxGetApp().app_config->get("slicer_uuid"), SLIC3R_VERSION, true});
|
||||
break;
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
// controller
|
||||
void PartSkipDialog::OnFileSystemEvent(wxCommandEvent &e)
|
||||
|
||||
@@ -14,7 +14,6 @@
|
||||
#include <wx/dcgraph.h>
|
||||
#include <wx/simplebook.h>
|
||||
|
||||
#include "NetworkAgent.hpp"
|
||||
#include "Widgets/Label.hpp"
|
||||
#include "Widgets/CheckBox.hpp"
|
||||
#include "Widgets/Button.hpp"
|
||||
@@ -30,6 +29,11 @@ namespace Slic3r { namespace GUI {
|
||||
|
||||
class SkipPartCanvas;
|
||||
|
||||
enum URL_STATE {
|
||||
URL_TCP,
|
||||
URL_TUTK,
|
||||
};
|
||||
|
||||
class PartSkipConfirmDialog : public DPIDialog
|
||||
{
|
||||
private:
|
||||
@@ -118,7 +122,7 @@ private:
|
||||
std::map<uint32_t, std::string> m_parts_name;
|
||||
std::vector<int> m_partskip_ids;
|
||||
|
||||
URL_STATE m_url_state = URL_STATE::URL_TCP;
|
||||
enum URL_STATE m_url_state = URL_STATE::URL_TCP;
|
||||
|
||||
PartsInfo GetPartsInfo();
|
||||
bool is_drag_mode();
|
||||
@@ -156,4 +160,4 @@ private:
|
||||
void OnApplyDialog(wxCommandEvent &event);
|
||||
};
|
||||
|
||||
}} // namespace Slic3r::GUI
|
||||
}} // namespace Slic3r::GUI
|
||||
|
||||
Reference in New Issue
Block a user