ENH: hide tuck did

Change-Id: I9021d3f51c9a73bc9208b479f96b1ddbe7a2f8f8
Jira: none
This commit is contained in:
chunmao.guo 2024-02-06 13:24:37 +08:00 committed by Lane.Wei
parent 507345deb1
commit b9061b6fb6
3 changed files with 22 additions and 26 deletions

View File

@ -71,13 +71,14 @@ CameraPopup::CameraPopup(wxWindow *parent)
m_text_liveview_retry->SetFont(Label::Head_14); m_text_liveview_retry->SetFont(Label::Head_14);
m_text_liveview_retry->SetForegroundColour(TEXT_COL); m_text_liveview_retry->SetForegroundColour(TEXT_COL);
m_switch_liveview_retry = new SwitchButton(m_panel); m_switch_liveview_retry = new SwitchButton(m_panel);
m_switch_liveview_retry->SetValue(true); bool auto_retry = wxGetApp().app_config->get("liveview", "auto_retry") != "false";
m_switch_liveview_retry->SetValue(auto_retry);
top_sizer->Add(m_text_liveview_retry, 0, wxALIGN_CENTER_VERTICAL | wxALIGN_LEFT | wxALL, FromDIP(5)); top_sizer->Add(m_text_liveview_retry, 0, wxALIGN_CENTER_VERTICAL | wxALIGN_LEFT | wxALL, FromDIP(5));
top_sizer->Add(m_switch_liveview_retry, 0, wxALIGN_CENTER_VERTICAL | wxALIGN_RIGHT | wxALL, FromDIP(5)); top_sizer->Add(m_switch_liveview_retry, 0, wxALIGN_CENTER_VERTICAL | wxALIGN_RIGHT | wxALL, FromDIP(5));
m_switch_liveview_retry->Bind(wxEVT_TOGGLEBUTTON, [this](wxCommandEvent &e) { m_switch_liveview_retry->Bind(wxEVT_TOGGLEBUTTON, [this](wxCommandEvent &e) {
dynamic_cast<MediaPlayCtrl *>(GetParent()->FindWindowByLabel("MediaPlayCtrl"))->SetAutoRetry(e.IsChecked()); wxGetApp().app_config->set("liveview", "auto_retry", e.IsChecked());
e.Skip(); e.Skip();
}); });
#endif #endif

View File

@ -143,19 +143,6 @@ MediaPlayCtrl::~MediaPlayCtrl()
} }
} }
wxString hide_id_middle_string(wxString const &str, size_t offset = 0, size_t length = -1)
{
#if BBL_RELEASE_TO_PUBLIC
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);
#else
return str;
#endif
}
void MediaPlayCtrl::SetMachineObject(MachineObject* obj) void MediaPlayCtrl::SetMachineObject(MachineObject* obj)
{ {
std::string machine = obj ? obj->dev_id : ""; std::string machine = obj ? obj->dev_id : "";
@ -213,9 +200,15 @@ void MediaPlayCtrl::SetMachineObject(MachineObject* obj)
SetStatus("", false); SetStatus("", false);
} }
void MediaPlayCtrl::SetAutoRetry(bool b) wxString hide_id_middle_string(wxString const &str, size_t offset = 0, size_t length = -1)
{ {
m_auto_retry = b; #if BBL_RELEASE_TO_PUBLIC
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);
#else
return str;
#endif
} }
wxString hide_passwd(wxString url, std::vector<wxString> const &passwords) wxString hide_passwd(wxString url, std::vector<wxString> const &passwords)
@ -232,7 +225,9 @@ wxString hide_passwd(wxString url, std::vector<wxString> const &passwords)
if (j == wxString::npos) j = url.length(); if (j == wxString::npos) j = url.length();
} }
auto l = size_t(j - i); auto l = size_t(j - i);
if (j == url.length() || url[j] == '@' || url[j] == '&') if (p[0] == '?' || p[0] == '&')
url = hide_id_middle_string(url, i, l);
else if (j == url.length() || url[j] == '@' || url[j] == '&')
url.replace(i, l, l, wxUniChar('*')); url.replace(i, l, l, wxUniChar('*'));
} }
#endif #endif
@ -328,7 +323,8 @@ void MediaPlayCtrl::Play()
url += "&cli_id=" + wxGetApp().app_config->get("slicer_uuid"); url += "&cli_id=" + wxGetApp().app_config->get("slicer_uuid");
url += "&cli_ver=" + std::string(SLIC3R_VERSION); url += "&cli_ver=" + std::string(SLIC3R_VERSION);
} }
BOOST_LOG_TRIVIAL(info) << "MediaPlayCtrl: " << hide_id_middle_string(hide_passwd(url, {"authkey=", "passwd="}), 9, 20) << "tutk_state: " << m_tutk_state; BOOST_LOG_TRIVIAL(info) << "MediaPlayCtrl: " << hide_passwd(url,
{"?uid=", "authkey=", "passwd=", "license=", "token="});
CallAfter([this, m, url] { CallAfter([this, m, url] {
if (m != m_machine) { if (m != m_machine) {
BOOST_LOG_TRIVIAL(info) << "MediaPlayCtrl drop late ttcode for machine: " << m; BOOST_LOG_TRIVIAL(info) << "MediaPlayCtrl drop late ttcode for machine: " << m;
@ -383,7 +379,8 @@ void MediaPlayCtrl::Stop(wxString const &msg)
} else } else
SetStatus(_L("Stopped."), false); SetStatus(_L("Stopped."), false);
m_last_state = MEDIASTATE_IDLE; m_last_state = MEDIASTATE_IDLE;
if (!m_auto_retry || m_failed_code >= 100 || m_failed_code == 1) // not keep retry on local error or EOS bool auto_retry = wxGetApp().app_config->get("liveview", "auto_retry") != "false";
if (!auto_retry || m_failed_code >= 100 || m_failed_code == 1) // not keep retry on local error or EOS
m_next_retry = wxDateTime(); m_next_retry = wxDateTime();
} else if (!msg.IsEmpty()) { } else if (!msg.IsEmpty()) {
SetStatus(msg, false); SetStatus(msg, false);
@ -561,7 +558,8 @@ void MediaPlayCtrl::ToggleStream()
url += "&cli_id=" + wxGetApp().app_config->get("slicer_uuid"); url += "&cli_id=" + wxGetApp().app_config->get("slicer_uuid");
url += "&cli_ver=" + std::string(SLIC3R_VERSION); url += "&cli_ver=" + std::string(SLIC3R_VERSION);
} }
BOOST_LOG_TRIVIAL(info) << "MediaPlayCtrl::ToggleStream: " << hide_id_middle_string(hide_passwd(url, {"authkey=", "passwd="}), 9, 20); BOOST_LOG_TRIVIAL(info) << "MediaPlayCtrl::ToggleStream: " << hide_passwd(url,
{"?uid=", "authkey=", "passwd=", "license=", "token="});
CallAfter([this, m, url] { CallAfter([this, m, url] {
if (m != m_machine) return; if (m != m_machine) return;
if (url.empty() || !boost::algorithm::starts_with(url, "bambu:///")) { if (url.empty() || !boost::algorithm::starts_with(url, "bambu:///")) {
@ -655,14 +653,14 @@ void MediaPlayCtrl::SetStatus(wxString const &msg2, bool hyperlink)
m_last_state + MEDIASTATE_BUFFERING - MEDIASTATE_IDLE; m_last_state + MEDIASTATE_BUFFERING - MEDIASTATE_IDLE;
msg += wxString::Format(" [%d:%d]", state2, m_failed_code); msg += wxString::Format(" [%d:%d]", state2, m_failed_code);
} }
BOOST_LOG_TRIVIAL(info) << "MediaPlayCtrl::SetStatus: " << msg.ToUTF8().data() << m_tutk_state; BOOST_LOG_TRIVIAL(info) << "MediaPlayCtrl::SetStatus: " << msg.ToUTF8().data() << " tutk_state: " << m_tutk_state;
#ifdef __WXMSW__ #ifdef __WXMSW__
OutputDebugStringA("MediaPlayCtrl::SetStatus: "); OutputDebugStringA("MediaPlayCtrl::SetStatus: ");
OutputDebugStringA(msg.ToUTF8().data()); OutputDebugStringA(msg.ToUTF8().data());
OutputDebugStringA("\n"); OutputDebugStringA("\n");
#endif // __WXMSW__ #endif // __WXMSW__
m_label_status->SetLabel(msg); m_label_status->SetLabel(msg);
m_label_status->Wrap(GetSize().GetWidth() - 120); m_label_status->Wrap(GetSize().GetWidth() - 120 - m_label_stat->GetSize().GetWidth());
long style = m_label_status->GetWindowStyle() & ~LB_HYPERLINK; long style = m_label_status->GetWindowStyle() & ~LB_HYPERLINK;
if (hyperlink) { if (hyperlink) {
style |= LB_HYPERLINK; style |= LB_HYPERLINK;

View File

@ -36,8 +36,6 @@ public:
void SetMachineObject(MachineObject * obj); void SetMachineObject(MachineObject * obj);
void SetAutoRetry(bool b);
bool IsStreaming() const; bool IsStreaming() const;
void ToggleStream(); void ToggleStream();
@ -86,7 +84,6 @@ private:
bool m_remote_support = false; bool m_remote_support = false;
bool m_device_busy = false; bool m_device_busy = false;
bool m_disable_lan = false; bool m_disable_lan = false;
bool m_auto_retry = true;
wxString m_url; wxString m_url;
std::deque<wxString> m_tasks; std::deque<wxString> m_tasks;