ENH: request lan ip if liveview failed with lan tunnel (2)

Change-Id: Ie40c31b8c3600dc30228d931013cc0e12a6b1a78
This commit is contained in:
chunmao.guo 2023-01-11 18:04:49 +08:00 committed by Lane.Wei
parent f28c9198a7
commit 143f9cfe99
3 changed files with 22 additions and 19 deletions

View file

@ -3835,6 +3835,7 @@ void DeviceManager::parse_user_print_info(std::string body)
if (m_agent) { if (m_agent) {
obj->set_bind_status(m_agent->get_user_name()); obj->set_bind_status(m_agent->get_user_name());
} }
obj->dev_ip = Slic3r::GUI::wxGetApp().app_config->get("ip_address", dev_id);
userMachineList.insert(std::make_pair(dev_id, obj)); userMachineList.insert(std::make_pair(dev_id, obj));
} }

View file

@ -125,14 +125,13 @@ void MediaPlayCtrl::Play()
if (m_last_state != MEDIASTATE_IDLE) { if (m_last_state != MEDIASTATE_IDLE) {
return; return;
} }
m_failed_code = 0;
if (m_machine.empty()) { if (m_machine.empty()) {
Stop(); Stop(_L("Initialize failed (No Device)!"));
SetStatus(_L("Initialize failed (No Device)!"), false);
return; return;
} }
if (!m_camera_exists) { if (!m_camera_exists) {
Stop(); Stop(_L("Initialize failed (No Camera Device)!"));
SetStatus(_L("Initialize failed (No Camera Device)!"), false);
return; return;
} }
@ -163,16 +162,16 @@ void MediaPlayCtrl::Play()
} }
if (m_lan_mode) { if (m_lan_mode) {
Stop(); m_failed_code = 1;
SetStatus(m_lan_passwd.empty() Stop(m_lan_passwd.empty()
? _L("Initialize failed (Not supported with LAN-only mode)!") ? _L("Initialize failed (Not supported with LAN-only mode)!")
: _L("Initialize failed (Not accessible in LAN-only mode)!")); : _L("Initialize failed (Not accessible in LAN-only mode)!"));
return; return;
} }
if (!m_tutk_support) { // not support tutk if (!m_tutk_support) { // not support tutk
Stop(); m_failed_code = 1;
SetStatus(m_lan_ip.empty() Stop(m_lan_ip.empty()
? _L("Initialize failed (Missing LAN ip of printer)!") ? _L("Initialize failed (Missing LAN ip of printer)!")
: _L("Initialize failed (Not supported by printer)!")); : _L("Initialize failed (Not supported by printer)!"));
return; return;
@ -211,7 +210,7 @@ void MediaPlayCtrl::Play()
} }
} }
void MediaPlayCtrl::Stop() void MediaPlayCtrl::Stop(wxString const &msg)
{ {
if (m_last_state != MEDIASTATE_IDLE) { if (m_last_state != MEDIASTATE_IDLE) {
m_media_ctrl->InvalidateBestSize(); m_media_ctrl->InvalidateBestSize();
@ -220,14 +219,25 @@ void MediaPlayCtrl::Stop()
m_tasks.push_back("<stop>"); m_tasks.push_back("<stop>");
m_cond.notify_all(); m_cond.notify_all();
m_last_state = MEDIASTATE_IDLE; m_last_state = MEDIASTATE_IDLE;
if (m_failed_code) if (!msg.IsEmpty())
SetStatus(msg, false);
else if (m_failed_code)
SetStatus(_L("Stopped [%d]!"), true); SetStatus(_L("Stopped [%d]!"), true);
else else
SetStatus(_L("Stopped."), false); SetStatus(_L("Stopped."), false);
if (m_failed_code >= 100) // not keep retry on local error if (m_failed_code >= 100) // not keep retry on local error
m_next_retry = wxDateTime(); m_next_retry = wxDateTime();
} else if (!msg.IsEmpty()) {
SetStatus(msg, false);
} }
++m_failed_retry; ++m_failed_retry;
if (m_failed_code != 0 && !m_tutk_support) {
m_next_retry = wxDateTime(); // stop retry
if (wxGetApp().show_ip_address_enter_dialog()) {
m_failed_retry = 0;
m_next_retry = wxDateTime::Now();
}
}
if (m_next_retry.IsValid()) if (m_next_retry.IsValid())
m_next_retry = wxDateTime::Now() + wxTimeSpan::Seconds(5 * m_failed_retry); m_next_retry = wxDateTime::Now() + wxTimeSpan::Seconds(5 * m_failed_retry);
} }
@ -385,14 +395,6 @@ void MediaPlayCtrl::SetStatus(wxString const &msg2, bool hyperlink)
m_label_status->SetWindowStyle(style); m_label_status->SetWindowStyle(style);
m_label_status->InvalidateBestSize(); m_label_status->InvalidateBestSize();
Layout(); Layout();
if (hyperlink && !m_tutk_support) {
m_next_retry = wxDateTime(); // stop retry
if (wxGetApp().show_ip_address_enter_dialog()) {
m_failed_retry = 0;
m_next_retry = wxDateTime::Now();
}
}
} }
bool MediaPlayCtrl::IsStreaming() const { return m_streaming; } bool MediaPlayCtrl::IsStreaming() const { return m_streaming; }

View file

@ -44,7 +44,7 @@ protected:
void Play(); void Play();
void Stop(); void Stop(wxString const &msg = {});
void TogglePlay(); void TogglePlay();