From ebf9c19e653c0ed37ca7eeba26efdc4e6a7d0e07 Mon Sep 17 00:00:00 2001 From: Stone Li Date: Fri, 4 Aug 2023 14:22:56 +0800 Subject: [PATCH] ENH: remove check link state Change-Id: Iba16694299f92a89e63ea9c4829e3087a29bade1 Signed-off-by: Stone Li --- src/slic3r/GUI/GUI_App.cpp | 78 -------------------------------------- src/slic3r/GUI/GUI_App.hpp | 3 -- 2 files changed, 81 deletions(-) diff --git a/src/slic3r/GUI/GUI_App.cpp b/src/slic3r/GUI/GUI_App.cpp index 9e7d00e35..133ec8cbd 100644 --- a/src/slic3r/GUI/GUI_App.cpp +++ b/src/slic3r/GUI/GUI_App.cpp @@ -2774,9 +2774,6 @@ bool GUI_App::on_init_inner() } }); - BOOST_LOG_TRIVIAL(info) << "start_check_network_state..."; - start_check_network_state(); - m_initialized = true; flush_logs(); @@ -4142,81 +4139,6 @@ void GUI_App::on_user_login_handle(wxCommandEvent &evt) } } -void GUI_App::start_check_network_state() -{ - boost::thread* test_microsoft = new boost::thread([this] { - start_test_url("www.microsoft.com"); - }); - boost::thread* test_apple = new boost::thread([this] { - start_test_url("www.apple.com"); - }); - boost::thread* test_amazon = new boost::thread([this] { - start_test_url("www.amazon.com"); - }); - - m_check_network_thread = boost::thread([this] { - int sec_count = 1; - while (!m_is_closing) { - if (sec_count % 10 == 0) { - bool link_result = check_network_state(); - if (!link_result) { - BOOST_LOG_TRIVIAL(info) << "link_result = " << link_result; - } - } - boost::this_thread::sleep_for(boost::chrono::milliseconds(1000)); - sec_count++; - } - }); -} - -bool GUI_App::check_network_state() -{ - bool result = false; - for (auto link : test_url_state) { - result = result | link.second; - } - if (m_agent) { - if (result) - m_agent->track_update_property("link_state", "1"); - else - m_agent->track_update_property("link_state", "0"); - } - return result; -} - -void GUI_App::start_test_url(std::string url) -{ - int sec_count = 0; - while (!m_is_closing) { - if (sec_count % 10 == 0) { - Slic3r::Http http = Slic3r::Http::get(url); - int result = -1; - http.timeout_max(5) - .on_complete([&result](std::string body, unsigned status) { - try { - if (status == 200) { - result = 0; - } - } - catch (...) { - ; - } - }) - .on_error([](std::string body, std::string error, unsigned int status) { - ; - }).perform_sync(); - - if (result == 0) { - test_url_state[url] = true; - } else { - test_url_state[url] = false; - } - } - boost::this_thread::sleep_for(boost::chrono::milliseconds(1000)); - sec_count++; - } -} - void GUI_App::check_track_enable() { diff --git a/src/slic3r/GUI/GUI_App.hpp b/src/slic3r/GUI/GUI_App.hpp index 0a105061e..ff4b36e98 100644 --- a/src/slic3r/GUI/GUI_App.hpp +++ b/src/slic3r/GUI/GUI_App.hpp @@ -430,9 +430,6 @@ public: void on_set_selected_machine(wxCommandEvent& evt); void on_user_login(wxCommandEvent &evt); void on_user_login_handle(wxCommandEvent& evt); - void start_check_network_state(); - bool check_network_state(); - void start_test_url(std::string url); void enable_user_preset_folder(bool enable); // BBS