OrcaSlicer latest
OrcaSlicer
Loading...
Searching...
No Matches
Slic3r::GUI::ZUserLogin Class Reference

#include </home/runner/work/OrcaSlicer/OrcaSlicer/src/slic3r/GUI/WebUserLoginDialog.hpp>

Inheritance diagram for Slic3r::GUI::ZUserLogin:
Collaboration diagram for Slic3r::GUI::ZUserLogin:

Public Member Functions

 ZUserLogin (std::shared_ptr< ICloudServiceAgent > cloud_agent)
virtual ~ZUserLogin ()
void load_url (wxString &url)
std::string w2s (wxString sSrc)
void UpdateState ()
void OnIdle (wxIdleEvent &evt)
void OnNavigationRequest (wxWebViewEvent &evt)
void OnNavigationComplete (wxWebViewEvent &evt)
void OnDocumentLoaded (wxWebViewEvent &evt)
void OnNewWindow (wxWebViewEvent &evt)
void OnError (wxWebViewEvent &evt)
void OnTitleChanged (wxWebViewEvent &evt)
void OnFullScreenChanged (wxWebViewEvent &evt)
void OnScriptMessage (wxWebViewEvent &evt)
void OnScriptResponseMessage (wxCommandEvent &evt)
void RunScript (const wxString &javascript)
bool ShowErrorPage ()
bool run ()

Public Attributes

bool m_networkOk

Static Public Attributes

static int web_sequence_id = 20000

Private Member Functions

void OnTimer (wxTimerEvent &event)
int ensure_loopback_port ()

Private Attributes

wxTimer * m_timer { nullptr }
wxString TargetUrl
wxWebView * m_browser
std::string m_AutotestToken
int m_loopback_port { 0 }
wxString m_javascript
wxString m_response_js
wxString m_bbl_user_agent
std::shared_ptr< ICloudServiceAgent > m_cloud_agent

Detailed Description

Constructor & Destructor Documentation

◆ ZUserLogin()

Slic3r::GUI::ZUserLogin::ZUserLogin ( std::shared_ptr< ICloudServiceAgent > cloud_agent)
explicit
111 : wxDialog((wxWindow*) (wxGetApp().mainframe), wxID_ANY, "OrcaSlicer"), m_cloud_agent(cloud_agent)
112{
113 SetBackgroundColour(*wxWHITE);
114
115 if (!m_cloud_agent) {
116 wxBoxSizer* m_sizer_main = new wxBoxSizer(wxVERTICAL);
117 auto m_line_top = new wxPanel(this, wxID_ANY, wxDefaultPosition, wxSize(-1, 1));
118 m_line_top->SetBackgroundColour(wxColour(166, 169, 170));
119 m_sizer_main->Add(m_line_top, 0, wxEXPAND, 0);
120
121 auto* m_message = new wxStaticText(this, wxID_ANY,
122 _L("Cloud agent is not available. Please restart OrcaSlicer and try again."),
123 wxDefaultPosition, wxDefaultSize, 0);
124 m_message->SetForegroundColour(*wxBLACK);
125 m_message->Wrap(FromDIP(360));
126 m_sizer_main->Add(m_message, 0, wxALIGN_CENTER | wxALL, FromDIP(15));
127
128 m_sizer_main->Add(0, 0, 1, wxBOTTOM, 10);
129 SetSizer(m_sizer_main);
130 m_sizer_main->SetSizeHints(this);
131 Layout();
132 Fit();
133 CentreOnParent();
134 wxGetApp().UpdateDlgDarkUI(this);
135 return;
136 }
137
138 const auto bblnetwork_enabled = wxGetApp().app_config->get_bool("installed_networking");
139 if (m_cloud_agent->get_id() == BBL_CLOUD_PROVIDER && !bblnetwork_enabled) {
140
141 SetBackgroundColour(*wxWHITE);
142
143 wxBoxSizer* m_sizer_main = new wxBoxSizer(wxVERTICAL);
144 auto m_line_top = new wxPanel(this, wxID_ANY, wxDefaultPosition, wxSize(-1, 1));
145 m_line_top->SetBackgroundColour(wxColour(166, 169, 170));
146 m_sizer_main->Add(m_line_top, 0, wxEXPAND, 0);
147
148 auto* m_message = new wxStaticText(this, wxID_ANY, _L("Bambu Network plug-in not detected."), wxDefaultPosition, wxDefaultSize, 0);
149 m_message->SetForegroundColour(*wxBLACK);
150 m_message->Wrap(FromDIP(360));
151
152 // ORCA standardized HyperLink
153 auto m_download_hyperlink = new HyperLink(this, _L("Click here to download it."));
154 m_download_hyperlink->Bind(wxEVT_LEFT_DOWN, [this](wxMouseEvent& event) {
155 this->Close();
156 wxGetApp().ShowDownNetPluginDlg();
157 });
158 m_sizer_main->Add(m_message, 0, wxALIGN_CENTER | wxALL, FromDIP(15));
159 m_sizer_main->Add(m_download_hyperlink, 0, wxALIGN_CENTER | wxALL, FromDIP(10));
160 m_sizer_main->Add(0, 0, 1, wxBOTTOM, 10);
161
162 SetSizer(m_sizer_main);
163 m_sizer_main->SetSizeHints(this);
164 Layout();
165 Fit();
166 CentreOnParent();
167 } else {
168 // Get the login URL from the injected cloud service agent
169 wxString strlang = wxGetApp().current_language_code_safe();
170 strlang.Replace("_", "-");
171 TargetUrl = wxString::FromUTF8(m_cloud_agent->get_cloud_login_url(strlang.ToStdString()));
172
173 BOOST_LOG_TRIVIAL(info) << "login url = " << TargetUrl.ToStdString();
174
175 m_bbl_user_agent = wxString::Format("BBL-Slicer/v%s", wxGetApp().get_bbl_client_version());
176
177 // Create the webview
179 if (m_browser == nullptr) {
180 wxLogError("Could not init m_browser");
181 return;
182 }
183 m_browser->Hide();
184 m_browser->SetSize(0, 0);
185
186 // Connect the webview events
187 Bind(wxEVT_WEBVIEW_NAVIGATING, &ZUserLogin::OnNavigationRequest, this, m_browser->GetId());
188 Bind(wxEVT_WEBVIEW_NAVIGATED, &ZUserLogin::OnNavigationComplete, this, m_browser->GetId());
189 Bind(wxEVT_WEBVIEW_LOADED, &ZUserLogin::OnDocumentLoaded, this, m_browser->GetId());
190 Bind(wxEVT_WEBVIEW_ERROR, &ZUserLogin::OnError, this, m_browser->GetId());
191 Bind(wxEVT_WEBVIEW_NEWWINDOW, &ZUserLogin::OnNewWindow, this, m_browser->GetId());
192 Bind(wxEVT_WEBVIEW_TITLE_CHANGED, &ZUserLogin::OnTitleChanged, this, m_browser->GetId());
193 Bind(wxEVT_WEBVIEW_FULLSCREEN_CHANGED, &ZUserLogin::OnFullScreenChanged, this, m_browser->GetId());
194 Bind(wxEVT_WEBVIEW_SCRIPT_MESSAGE_RECEIVED, &ZUserLogin::OnScriptMessage, this, m_browser->GetId());
195
196 // UI
197 SetTitle(_L("Login"));
198 // Set a more sensible size for web browsing
199 wxSize pSize = FromDIP(wxSize(650, 840));
200 SetSize(pSize);
201
202 CentreOnParent();
203 }
204 wxGetApp().UpdateDlgDarkUI(this);
205}
#define _L(s)
Definition OBJ.cpp:34
class WXDLLIMPEXP_FWD_CORE wxStaticText
Definition ProgressDialog.hpp:30
wxString m_bbl_user_agent
Definition WebUserLoginDialog.hpp:92
void OnFullScreenChanged(wxWebViewEvent &evt)
Definition WebUserLoginDialog.cpp:330
void OnTitleChanged(wxWebViewEvent &evt)
Definition WebUserLoginDialog.cpp:324
void OnError(wxWebViewEvent &evt)
Definition WebUserLoginDialog.cpp:575
void OnScriptMessage(wxWebViewEvent &evt)
Definition WebUserLoginDialog.cpp:336
std::shared_ptr< ICloudServiceAgent > m_cloud_agent
Definition WebUserLoginDialog.hpp:94
wxString TargetUrl
Definition WebUserLoginDialog.hpp:77
void OnDocumentLoaded(wxWebViewEvent &evt)
Definition WebUserLoginDialog.cpp:292
void OnNewWindow(wxWebViewEvent &evt)
Definition WebUserLoginDialog.cpp:309
wxWebView * m_browser
Definition WebUserLoginDialog.hpp:78
void OnNavigationRequest(wxWebViewEvent &evt)
Definition WebUserLoginDialog.cpp:271
void OnNavigationComplete(wxWebViewEvent &evt)
Definition WebUserLoginDialog.cpp:281
static wxWebView * CreateWebView(wxWindow *parent, wxString const &url)
Definition WebView.cpp:313
wxMouseEvent
Definition CameraPopup.cpp:47
static const std::string BBL_CLOUD_PROVIDER("bbl")

References _L, Slic3r::BBL_CLOUD_PROVIDER(), WebView::CreateWebView(), m_bbl_user_agent, m_browser, m_cloud_agent, OnDocumentLoaded(), OnError(), OnFullScreenChanged(), OnNavigationComplete(), OnNavigationRequest(), OnNewWindow(), OnScriptMessage(), OnTitleChanged(), TargetUrl, Slic3r::GUI::wxMouseEvent, and wxStaticText.

Here is the call graph for this function:

◆ ~ZUserLogin()

Slic3r::GUI::ZUserLogin::~ZUserLogin ( )
virtual
207 {
208 if (m_timer != NULL) {
209 m_timer->Stop();
210 delete m_timer;
211 m_timer = NULL;
212 }
213}
wxTimer * m_timer
Definition WebUserLoginDialog.hpp:73

References m_timer.

Member Function Documentation

◆ ensure_loopback_port()

int Slic3r::GUI::ZUserLogin::ensure_loopback_port ( )
private
101{
102 if (m_loopback_port <= 0) {
104 }
106 wxGetApp().start_http_server(port, m_cloud_agent->get_id());
107 return port;
108}
#define LOCALHOST_PORT
Definition HttpServer.hpp:25
int m_loopback_port
Definition WebUserLoginDialog.hpp:81
int reserve_loopback_port()
Definition WebUserLoginDialog.cpp:70

References LOCALHOST_PORT, m_cloud_agent, and m_loopback_port.

Referenced by OnScriptMessage().

Here is the caller graph for this function:

◆ load_url()

void Slic3r::GUI::ZUserLogin::load_url ( wxString & url)
237{
238 m_browser->LoadURL(url);
239 m_browser->SetFocus();
240 UpdateState();
241}
void UpdateState()
Definition WebUserLoginDialog.cpp:248

References m_browser, and UpdateState().

Referenced by ShowErrorPage().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ OnDocumentLoaded()

void Slic3r::GUI::ZUserLogin::OnDocumentLoaded ( wxWebViewEvent & evt)

Callback invoked when a page is finished loading

293{
294 // Only notify if the document is the main frame, not a subframe
295 wxString tmpUrl = evt.GetURL();
296 std::string strHost = m_cloud_agent->get_cloud_service_host();
297
298 if (tmpUrl.StartsWith("file://") || tmpUrl.Contains(strHost)) {
299 m_networkOk = true;
300 // wxLogMessage("%s", "Document loaded; url='" + evt.GetURL() + "'");
301 }
302
303 UpdateState();
304}
bool m_networkOk
Definition WebUserLoginDialog.hpp:66

References m_cloud_agent, m_networkOk, and UpdateState().

Referenced by ZUserLogin().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ OnError()

void Slic3r::GUI::ZUserLogin::OnError ( wxWebViewEvent & evt)

Callback invoked when a loading error occurs

576{
577#define WX_ERROR_CASE(type) \
578 case type: category = #type; break;
579
580 wxString category;
581 switch (evt.GetInt()) {
582 WX_ERROR_CASE(wxWEBVIEW_NAV_ERR_CONNECTION);
583 WX_ERROR_CASE(wxWEBVIEW_NAV_ERR_CERTIFICATE);
584 WX_ERROR_CASE(wxWEBVIEW_NAV_ERR_AUTH);
585 WX_ERROR_CASE(wxWEBVIEW_NAV_ERR_SECURITY);
586 WX_ERROR_CASE(wxWEBVIEW_NAV_ERR_NOT_FOUND);
587 WX_ERROR_CASE(wxWEBVIEW_NAV_ERR_REQUEST);
588 WX_ERROR_CASE(wxWEBVIEW_NAV_ERR_USER_CANCELLED);
589 WX_ERROR_CASE(wxWEBVIEW_NAV_ERR_OTHER);
590 }
591
592 if( evt.GetInt()==wxWEBVIEW_NAV_ERR_CONNECTION )
593 {
594 if(m_timer!=NULL)
595 m_timer->Stop();
596
597 if (m_networkOk==false)
599 }
600
601 // wxLogMessage("%s", "Error; url='" + evt.GetURL() + "', error='" +
602 // category + " (" + evt.GetString() + ")'");
603
604 // Show the info bar with an error
605 // m_info->ShowMessage(_L("An error occurred loading ") + evt.GetURL() +
606 // "\n" + "'" + category + "'", wxICON_ERROR);
607
608 UpdateState();
609}
#define WX_ERROR_CASE(type)
bool ShowErrorPage()
Definition WebUserLoginDialog.cpp:622

References m_networkOk, m_timer, ShowErrorPage(), UpdateState(), and WX_ERROR_CASE.

Referenced by ZUserLogin().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ OnFullScreenChanged()

void Slic3r::GUI::ZUserLogin::OnFullScreenChanged ( wxWebViewEvent & evt)
331{
332 // wxLogMessage("Full screen changed; status = %d", evt.GetInt());
333 ShowFullScreen(evt.GetInt() != 0);
334}

Referenced by ZUserLogin().

Here is the caller graph for this function:

◆ OnIdle()

void Slic3r::GUI::ZUserLogin::OnIdle ( wxIdleEvent & evt)
254{
255 if (m_browser->IsBusy()) {
256 wxSetCursor(wxCURSOR_ARROWWAIT);
257 } else {
258 wxSetCursor(wxNullCursor);
259 }
260}

References m_browser.

◆ OnNavigationComplete()

void Slic3r::GUI::ZUserLogin::OnNavigationComplete ( wxWebViewEvent & evt)

Callback invoked when a navigation request was accepted

282{
283 // wxLogMessage("%s", "Navigation complete; url='" + evt.GetURL() + "'");
284 m_browser->Show();
285 Layout();
286 UpdateState();
287}

References m_browser, and UpdateState().

Referenced by ZUserLogin().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ OnNavigationRequest()

void Slic3r::GUI::ZUserLogin::OnNavigationRequest ( wxWebViewEvent & evt)

Callback invoked when there is a request to load a new page (for instance when the user clicks a link)

272{
273 //wxLogMessage("%s", "Navigation request to '" + evt.GetURL() + "'(target='" + evt.GetTarget() + "')");
274
275 UpdateState();
276}

References UpdateState().

Referenced by ZUserLogin().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ OnNewWindow()

void Slic3r::GUI::ZUserLogin::OnNewWindow ( wxWebViewEvent & evt)

On new window, we veto to stop extra windows appearing

310{
311 wxString flag = " (other)";
312
313 if (evt.GetNavigationAction() == wxWEBVIEW_NAV_ACTION_USER) { flag = " (user)"; }
314
315 // wxLogMessage("%s", "New window; url='" + evt.GetURL() + "'" + flag);
316
317 // If we handle new window events then just load them in this window as we
318 // are a single window browser
319 m_browser->LoadURL(evt.GetURL());
320
321 UpdateState();
322}

References m_browser, and UpdateState().

Referenced by ZUserLogin().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ OnScriptMessage()

void Slic3r::GUI::ZUserLogin::OnScriptMessage ( wxWebViewEvent & evt)
337{
338 wxString str_input = evt.GetString();
339
340 try {
341 json j = json::parse(into_u8(str_input));
342 wxString strCmd = j["command"];
343
344 if (m_cloud_agent && strCmd == "get_login_cmd") {
345 // Return login config (backend_url, apikey, pkce)
346 // WebView handles provider selection internally
347 std::string login_cmd = m_cloud_agent->build_login_cmd();
348 m_loopback_port = 0;
349 try {
350 json cfg = json::parse(login_cmd);
351 if (cfg.contains("pkce")) {
352 const auto& pkce = cfg["pkce"];
353 if (pkce.contains("loopback_port")) {
354 if (pkce["loopback_port"].is_number_integer()) {
355 m_loopback_port = pkce["loopback_port"].get<int>();
356 } else if (pkce["loopback_port"].is_string()) {
357 m_loopback_port = std::stoi(pkce["loopback_port"].get<std::string>());
358 }
359 }
360
361 if (m_loopback_port <= 0 && pkce.contains("redirect_uri") && pkce["redirect_uri"].is_string()) {
362 const std::string redirect_uri = pkce["redirect_uri"].get<std::string>();
363 const char* prefixes[] = {"localhost:", "127.0.0.1:"};
364 for (const char* prefix : prefixes) {
365 auto start = redirect_uri.find(prefix);
366 if (start == std::string::npos)
367 continue;
368 start += strlen(prefix);
369 auto end = redirect_uri.find('/', start);
370 std::string port_str = redirect_uri.substr(start, end - start);
371 try {
372 m_loopback_port = std::stoi(port_str);
373 } catch (...) {
374 m_loopback_port = 0;
375 }
376 break;
377 }
378 }
379 }
380 } catch (...) {
381 m_loopback_port = 0;
382 }
383 wxString str_js = wxString::FromUTF8("window.postMessage(") + wxString::FromUTF8(login_cmd.c_str()) +
384 wxString::FromUTF8(", '*')");
385 this->RunScript(str_js);
386 return;
387 }
388
389 if (strCmd == "autotest_token")
390 {
391 m_AutotestToken = j["data"]["token"];
392 }
393 if (strCmd == "user_ticket_login") {
394 auto* agent = wxGetApp().getAgent();
395 if (!agent || !m_cloud_agent || !j.contains("data") || !j["data"].is_object() || !j["data"].contains("ticket")) {
396 wxMessageBox(_L("Login failed. Please try again."), _L("Login"), wxICON_WARNING);
397 return;
398 }
399
400 const auto provider = m_cloud_agent->get_id();
401 std::string ticket = j["data"]["ticket"].get<std::string>();
402
403 unsigned int token_http_code = 0;
404 std::string token_body;
405 int token_result = agent->get_my_token(ticket, &token_http_code, &token_body, provider);
406 if (token_result != 0) {
407 BOOST_LOG_TRIVIAL(warning) << "embedded_login: get_my_token failed, http_code=" << token_http_code;
408 wxMessageBox(_L("Login failed. Please try again."), _L("Login"), wxICON_WARNING);
409 return;
410 }
411
412 std::string access_token;
413 std::string refresh_token;
414 std::string expires_in_str;
415 std::string refresh_expires_in_str;
416 try {
417 json token_j = json::parse(token_body);
418 if (token_j.contains("accessToken"))
419 access_token = token_j["accessToken"].get<std::string>();
420 if (token_j.contains("refreshToken"))
421 refresh_token = token_j["refreshToken"].get<std::string>();
422 if (token_j.contains("expiresIn"))
423 expires_in_str = std::to_string(token_j["expiresIn"].get<double>());
424 if (token_j.contains("refreshExpiresIn"))
425 refresh_expires_in_str = std::to_string(token_j["refreshExpiresIn"].get<double>());
426 } catch (...) {
427 wxMessageBox(_L("Login failed. Please try again."), _L("Login"), wxICON_WARNING);
428 return;
429 }
430
431 if (access_token.empty()) {
432 wxMessageBox(_L("Login failed. Please try again."), _L("Login"), wxICON_WARNING);
433 return;
434 }
435
436 unsigned int profile_http_code = 0;
437 std::string profile_body;
438 int profile_result = agent->get_my_profile(access_token, &profile_http_code, &profile_body, provider);
439 if (profile_result != 0) {
440 BOOST_LOG_TRIVIAL(warning) << "embedded_login: get_my_profile failed, http_code=" << profile_http_code;
441 wxMessageBox(_L("Login failed. Please try again."), _L("Login"), wxICON_WARNING);
442 return;
443 }
444
445 std::string user_id;
446 std::string user_name;
447 std::string user_account;
448 std::string user_avatar;
449 try {
450 json user_j = json::parse(profile_body);
451 if (user_j.contains("uidStr"))
452 user_id = user_j["uidStr"].get<std::string>();
453 if (user_j.contains("name"))
454 user_name = user_j["name"].get<std::string>();
455 if (user_j.contains("avatar"))
456 user_avatar = user_j["avatar"].get<std::string>();
457 if (user_j.contains("account"))
458 user_account = user_j["account"].get<std::string>();
459 } catch (...) {
460 BOOST_LOG_TRIVIAL(warning) << "embedded_login: profile JSON parse failed";
461 }
462
463 json login_j;
464 login_j["command"] = "user_login";
465 login_j["data"]["autotest_token"] = m_AutotestToken;
466 login_j["data"]["refresh_token"] = refresh_token;
467 login_j["data"]["token"] = access_token;
468 login_j["data"]["expires_in"] = expires_in_str;
469 login_j["data"]["refresh_expires_in"] = refresh_expires_in_str;
470 login_j["data"]["user"]["uid"] = user_id;
471 login_j["data"]["user"]["name"] = user_name;
472 login_j["data"]["user"]["account"] = user_account;
473 login_j["data"]["user"]["avatar"] = user_avatar;
474 std::string message_json = login_j.dump();
475
476 // End modal dialog first to unblock event loop before processing callbacks
477 EndModal(wxID_OK);
478
479 // Handle message after modal dialog ends to avoid deadlock
480 // Use wxTheApp->CallAfter to ensure it runs after modal loop exits
481 wxTheApp->CallAfter([message_json, provider]() { wxGetApp().handle_script_message(message_json, provider); });
482 }
483 else if (strCmd == "user_login") {
484 j["data"]["autotest_token"] = m_AutotestToken;
485 std::string message_json = j.dump();
486
487 // End modal dialog first to unblock event loop before processing callbacks
488 EndModal(wxID_OK);
489
490 // Handle message after modal dialog ends to avoid deadlock
491 // Use wxTheApp->CallAfter to ensure it runs after modal loop exits
492 const auto provider = m_cloud_agent->get_id();
493 wxTheApp->CallAfter([message_json, provider]() { wxGetApp().handle_script_message(message_json, provider); });
494 }
495 else if (strCmd == "get_localhost_url") {
496 int loopback_port = ensure_loopback_port();
497 std::string sequence_id = j["sequence_id"].get<std::string>();
498 CallAfter([this, sequence_id] {
499 json ack_j;
500 ack_j["command"] = "get_localhost_url";
501 int loopback_port = m_loopback_port > 0 ? m_loopback_port : LOCALHOST_PORT;
502 ack_j["response"]["base_url"] = std::string(LOCALHOST_URL) + std::to_string(loopback_port);
503 ack_j["response"]["result"] = "success";
504 ack_j["sequence_id"] = sequence_id;
505 wxString str_js = wxString::Format("window.postMessage(%s)", ack_j.dump());
506 this->RunScript(str_js);
507 });
508 }
509 else if (strCmd == "thirdparty_login") {
510 if (j["data"].contains("url")) {
511 std::string jump_url = j["data"]["url"].get<std::string>();
512 int loopback_port = ensure_loopback_port();
513 jump_url = rewrite_loopback_url(jump_url, loopback_port);
514 CallAfter([jump_url] {
515 wxString url = wxString::FromUTF8(jump_url);
516 wxLaunchDefaultBrowser(url);
517 });
518 }
519 }
520 else if (strCmd == "new_webpage") {
521 if (j["data"].contains("url")) {
522 std::string jump_url = j["data"]["url"].get<std::string>();
523 CallAfter([jump_url] {
524 wxString url = wxString::FromUTF8(jump_url);
525 wxLaunchDefaultBrowser(url);
526 });
527 }
528 return;
529 }
530 } catch (std::exception &e) {
531 wxMessageBox(e.what(), _L("parse json failed"), wxICON_WARNING);
532 Close();
533 }
534}
#define LOCALHOST_URL
Definition HttpServer.hpp:26
int ensure_loopback_port()
Definition WebUserLoginDialog.cpp:100
std::string m_AutotestToken
Definition WebUserLoginDialog.hpp:80
void RunScript(const wxString &javascript)
Definition WebUserLoginDialog.cpp:536
T * end(Slic3r::Mat< N, M, T > &mat)
Definition Point.hpp:841
std::string rewrite_loopback_url(std::string url, int port)
Definition WebUserLoginDialog.cpp:81
std::string into_u8(const wxString &str)
Definition GUI.cpp:549
bool contains(const std::vector< T > &vector, const Point &point)
Definition Geometry.cpp:55
nlohmann::json json
Definition AssembleList.cpp:42

References _L, Slic3r::Geometry::contains(), ensure_loopback_port(), Slic3r::GUI::into_u8(), LOCALHOST_PORT, LOCALHOST_URL, m_AutotestToken, m_cloud_agent, m_loopback_port, and RunScript().

Referenced by ZUserLogin().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ OnScriptResponseMessage()

void Slic3r::GUI::ZUserLogin::OnScriptResponseMessage ( wxCommandEvent & evt)
612{
613 // if (!m_response_js.empty())
614 //{
615 // RunScript(m_response_js);
616 //}
617
618 // RunScript("This is a message to Web!");
619 // RunScript("postMessage(\"AABBCCDD\");");
620}

◆ OnTimer()

void Slic3r::GUI::ZUserLogin::OnTimer ( wxTimerEvent & event)
private
215 {
216 m_timer->Stop();
217
218 if (m_networkOk == false)
219 {
221 }
222}

References m_networkOk, m_timer, and ShowErrorPage().

Here is the call graph for this function:

◆ OnTitleChanged()

void Slic3r::GUI::ZUserLogin::OnTitleChanged ( wxWebViewEvent & evt)
325{
326 // SetTitle(evt.GetString());
327 // wxLogMessage("%s", "Title changed; title='" + evt.GetString() + "'");
328}

Referenced by ZUserLogin().

Here is the caller graph for this function:

◆ run()

bool Slic3r::GUI::ZUserLogin::run ( )
224 {
225 m_timer = new wxTimer(this, NETWORK_OFFLINE_TIMER_ID);
226 m_timer->Start(8000);
227
228 if (this->ShowModal() == wxID_OK) {
229 return true;
230 } else {
231 return false;
232 }
233}
#define NETWORK_OFFLINE_TIMER_ID
Definition WebUserLoginDialog.cpp:60

References m_timer, and NETWORK_OFFLINE_TIMER_ID.

◆ RunScript()

void Slic3r::GUI::ZUserLogin::RunScript ( const wxString & javascript)
537{
538 // Remember the script we run in any case, so the next time the user opens
539 // the "Run Script" dialog box, it is shown there for convenient updating.
540 m_javascript = javascript;
541
542 if (!m_browser) return;
543
544 WebView::RunScript(m_browser, javascript);
545}
wxString m_javascript
Definition WebUserLoginDialog.hpp:89
static bool RunScript(wxWebView *webView, wxString const &msg)
Definition WebView.cpp:491

References m_browser, m_javascript, and WebView::RunScript().

Referenced by OnScriptMessage().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ShowErrorPage()

bool Slic3r::GUI::ZUserLogin::ShowErrorPage ( )
623{
624 wxString ErrortUrl = file_url_from_path(boost::filesystem::path(resources_dir()) / "web/login/error.html");
625 load_url(ErrortUrl);
626
627 return true;
628}
void load_url(wxString &url)
Definition WebUserLoginDialog.cpp:236
wxString file_url_from_path(const boost::filesystem::path &path)
Definition GUI.cpp:569
const std::string & resources_dir()
Definition utils.cpp:296

References Slic3r::GUI::file_url_from_path(), load_url(), and Slic3r::resources_dir().

Referenced by OnError(), and OnTimer().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ UpdateState()

void Slic3r::GUI::ZUserLogin::UpdateState ( )

Method that retrieves the current state from the web control and updates the GUI the reflect this current state.

249{
250 // SetTitle(m_browser->GetCurrentTitle());
251}

Referenced by load_url(), OnDocumentLoaded(), OnError(), OnNavigationComplete(), OnNavigationRequest(), and OnNewWindow().

Here is the caller graph for this function:

◆ w2s()

std::string Slic3r::GUI::ZUserLogin::w2s ( wxString sSrc)

Member Data Documentation

◆ m_AutotestToken

std::string Slic3r::GUI::ZUserLogin::m_AutotestToken
private

Referenced by OnScriptMessage().

◆ m_bbl_user_agent

wxString Slic3r::GUI::ZUserLogin::m_bbl_user_agent
private

Referenced by ZUserLogin().

◆ m_browser

wxWebView* Slic3r::GUI::ZUserLogin::m_browser
private

◆ m_cloud_agent

std::shared_ptr<ICloudServiceAgent> Slic3r::GUI::ZUserLogin::m_cloud_agent
private

◆ m_javascript

wxString Slic3r::GUI::ZUserLogin::m_javascript
private

Referenced by RunScript().

◆ m_loopback_port

int Slic3r::GUI::ZUserLogin::m_loopback_port { 0 }
private
81{ 0 };

Referenced by ensure_loopback_port(), and OnScriptMessage().

◆ m_networkOk

bool Slic3r::GUI::ZUserLogin::m_networkOk

Referenced by OnDocumentLoaded(), OnError(), and OnTimer().

◆ m_response_js

wxString Slic3r::GUI::ZUserLogin::m_response_js
private

◆ m_timer

wxTimer* Slic3r::GUI::ZUserLogin::m_timer { nullptr }
private
73{ nullptr };

Referenced by ~ZUserLogin(), OnError(), OnTimer(), and run().

◆ TargetUrl

wxString Slic3r::GUI::ZUserLogin::TargetUrl
private

Referenced by ZUserLogin().

◆ web_sequence_id

int Slic3r::GUI::ZUserLogin::web_sequence_id = 20000
static

The documentation for this class was generated from the following files: