FIX: hide_id_middle_string
Change-Id: I28f32ec526b443d31d7992971b80ab1cb737deb6 Github: STUDIO-5825
This commit is contained in:
parent
d5b950a902
commit
a193169a76
|
@ -199,7 +199,9 @@ MediaFilePanel::~MediaFilePanel()
|
|||
SetMachineObject(nullptr);
|
||||
}
|
||||
|
||||
void MediaFilePanel::SetMachineObject(MachineObject* obj)
|
||||
wxString hide_id_middle_string(wxString const &str, size_t offset = 0, size_t length = -1);
|
||||
|
||||
void MediaFilePanel::SetMachineObject(MachineObject* obj)
|
||||
{
|
||||
std::string machine = obj ? obj->dev_id : "";
|
||||
if (obj) {
|
||||
|
@ -461,7 +463,7 @@ void MediaFilePanel::fetchUrl(boost::weak_ptr<PrinterFileSystem> wfs)
|
|||
if (agent) {
|
||||
agent->get_camera_url(m_machine,
|
||||
[this, wfs, m = m_machine, v = m_dev_ver](std::string url) {
|
||||
BOOST_LOG_TRIVIAL(info) << "MediaFilePanel::fetchUrl: camera_url: " << hide_passwd(url, {"authkey=", "passwd="});
|
||||
BOOST_LOG_TRIVIAL(info) << "MediaFilePanel::fetchUrl: camera_url: " << hide_id_middle_string(hide_passwd(url, {"authkey=", "passwd="}), 9, 20);
|
||||
CallAfter([=] {
|
||||
boost::shared_ptr fs(wfs.lock());
|
||||
if (!fs || fs != m_image_grid->GetFileSystem()) return;
|
||||
|
|
|
@ -107,6 +107,15 @@ MediaPlayCtrl::~MediaPlayCtrl()
|
|||
m_thread.join();
|
||||
}
|
||||
|
||||
wxString hide_id_middle_string(wxString const &str, size_t offset = 0, size_t length = -1)
|
||||
{
|
||||
if (length == size_t(-1))
|
||||
length = str.Length() - offset;
|
||||
if (length <= 8)
|
||||
return str;
|
||||
return str.Left(offset + 4) + wxString(length - 8, '*') + str.Mid(offset + length - 4);
|
||||
}
|
||||
|
||||
void MediaPlayCtrl::SetMachineObject(MachineObject* obj)
|
||||
{
|
||||
std::string machine = obj ? obj->dev_id : "";
|
||||
|
@ -138,7 +147,7 @@ void MediaPlayCtrl::SetMachineObject(MachineObject* obj)
|
|||
return;
|
||||
}
|
||||
m_machine = machine;
|
||||
BOOST_LOG_TRIVIAL(info) << "MediaPlayCtrl switch machine: " << m_machine;
|
||||
BOOST_LOG_TRIVIAL(info) << "MediaPlayCtrl switch machine: " << hide_id_middle_string(m_machine);
|
||||
m_disable_lan = false;
|
||||
m_failed_retry = 0;
|
||||
m_last_failed_codes.clear();
|
||||
|
@ -172,8 +181,7 @@ wxString hide_passwd(wxString url, std::vector<wxString> const &passwords)
|
|||
if (p[p.length() - 1] == '=') {
|
||||
i = j;
|
||||
j = url.find('&', i);
|
||||
if (j == wxString::npos)
|
||||
j = url.length();
|
||||
if (j == wxString::npos) j = url.length();
|
||||
}
|
||||
auto l = size_t(j - i);
|
||||
if (j == url.length() || url[j] == '@' || url[j] == '&')
|
||||
|
@ -222,7 +230,7 @@ void MediaPlayCtrl::Play()
|
|||
m_url = "bambu:///rtsps___" + m_lan_user + ":" + m_lan_passwd + "@" + m_lan_ip + "/streaming/live/1?proto=rtsps";
|
||||
else if (m_lan_proto == MachineObject::LVL_Rtsp)
|
||||
m_url = "bambu:///rtsp___" + m_lan_user + ":" + m_lan_passwd + "@" + m_lan_ip + "/streaming/live/1?proto=rtsp";
|
||||
m_url += "&device=" + m_machine;
|
||||
m_url += "&device=" + hide_id_middle_string(m_machine);
|
||||
m_url += "&version=" + agent_version;
|
||||
m_url += "&dev_ver=" + m_dev_ver;
|
||||
BOOST_LOG_TRIVIAL(info) << "MediaPlayCtrl: " << hide_passwd(m_url, {m_lan_passwd} );
|
||||
|
@ -254,11 +262,11 @@ void MediaPlayCtrl::Play()
|
|||
if (agent) {
|
||||
agent->get_camera_url(m_machine, [this, m = m_machine, v = agent_version, dv = m_dev_ver](std::string url) {
|
||||
if (boost::algorithm::starts_with(url, "bambu:///")) {
|
||||
url += "&device=" + m;
|
||||
url += "&device=" + into_u8(hide_id_middle_string(m));
|
||||
url += "&version=" + v;
|
||||
url += "&dev_ver=" + dv;
|
||||
}
|
||||
BOOST_LOG_TRIVIAL(info) << "MediaPlayCtrl: " << hide_passwd(url, {"authkey=", "passwd="}) << ", machine: " << m_machine;
|
||||
BOOST_LOG_TRIVIAL(info) << "MediaPlayCtrl: " << hide_id_middle_string(hide_passwd(url, {"authkey=", "passwd="}), 9, 20);
|
||||
CallAfter([this, m, url] {
|
||||
if (m != m_machine) {
|
||||
BOOST_LOG_TRIVIAL(info) << "MediaPlayCtrl drop late ttcode for machine: " << m;
|
||||
|
@ -430,7 +438,7 @@ void MediaPlayCtrl::ToggleStream()
|
|||
url = "bambu:///rtsps___" + m_lan_user + ":" + m_lan_passwd + "@" + m_lan_ip + "/streaming/live/1?proto=rtsps";
|
||||
else if (m_lan_proto == MachineObject::LVL_Rtsp)
|
||||
url = "bambu:///rtsp___" + m_lan_user + ":" + m_lan_passwd + "@" + m_lan_ip + "/streaming/live/1?proto=rtsp";
|
||||
url += "&device=" + m_machine;
|
||||
url += "&device=" + into_u8(hide_id_middle_string(m_machine));
|
||||
url += "&dev_ver=" + m_dev_ver;
|
||||
BOOST_LOG_TRIVIAL(info) << "MediaPlayCtrl::ToggleStream: " << hide_passwd(url, {m_lan_passwd});
|
||||
std::string file_url = data_dir() + "/cameratools/url.txt";
|
||||
|
@ -449,7 +457,7 @@ void MediaPlayCtrl::ToggleStream()
|
|||
url += "&version=" + v;
|
||||
url += "&dev_ver=" + dv;
|
||||
}
|
||||
BOOST_LOG_TRIVIAL(info) << "MediaPlayCtrl::ToggleStream: " << hide_passwd(url, {"authkey=", "passwd="});
|
||||
BOOST_LOG_TRIVIAL(info) << "MediaPlayCtrl::ToggleStream: " << hide_id_middle_string(hide_passwd(url, {"authkey=", "passwd="}), 9, 20);
|
||||
CallAfter([this, m, url] {
|
||||
if (m != m_machine) return;
|
||||
if (url.empty() || !boost::algorithm::starts_with(url, "bambu:///")) {
|
||||
|
@ -585,7 +593,7 @@ void MediaPlayCtrl::media_proc()
|
|||
}
|
||||
wxString url = m_tasks.front();
|
||||
if (m_tasks.size() >= 2 && !url.IsEmpty() && url[0] != '<' && m_tasks[1] == "<stop>") {
|
||||
BOOST_LOG_TRIVIAL(info) << "MediaPlayCtrl: busy skip url: " << hide_passwd(url, {"authkey=", "passwd=", m_lan_passwd});
|
||||
BOOST_LOG_TRIVIAL(info) << "MediaPlayCtrl: busy skip url: " << hide_id_middle_string(hide_passwd(url, {"authkey=", "passwd=", m_lan_passwd}), 9, 20);
|
||||
m_tasks.pop_front();
|
||||
m_tasks.pop_front();
|
||||
continue;
|
||||
|
|
|
@ -473,29 +473,6 @@ PrinterFileSystem::File const &PrinterFileSystem::GetFile(size_t index, bool &se
|
|||
return m_file_list[m_group_month[index]];
|
||||
}
|
||||
|
||||
int PrinterFileSystem::RecvData(std::function<int(Bambu_Sample& sample)> const & callback)
|
||||
{
|
||||
int result = 0;
|
||||
while (true) {
|
||||
Bambu_Sample sample;
|
||||
result = Bambu_ReadSample(m_session.tunnel, &sample);
|
||||
if (result == Bambu_success) {
|
||||
result = callback(sample);
|
||||
if (result == 1)
|
||||
continue;
|
||||
} else if (result == Bambu_would_block) {
|
||||
boost::this_thread::sleep(boost::posix_time::seconds(1));
|
||||
continue;
|
||||
} else if (result == Bambu_stream_end) {
|
||||
result = 0;
|
||||
} else {
|
||||
result = ERROR_PIPE;
|
||||
}
|
||||
break;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
void PrinterFileSystem::Attached()
|
||||
{
|
||||
boost::unique_lock lock(m_mutex);
|
||||
|
|
|
@ -281,8 +281,6 @@ private:
|
|||
|
||||
void Reconnect(boost::unique_lock<boost::mutex> & l, int result);
|
||||
|
||||
int RecvData(std::function<int(Bambu_Sample & sample)> const & callback);
|
||||
|
||||
template <typename T>
|
||||
void PostCallback(Callback<T> const& callback, int result, T const& resp)
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue