mirror of
https://github.com/OrcaSlicer/OrcaSlicer.git
synced 2026-09-12 11:37:42 +00:00
feature add sub for privacy update flags for web control.
This commit is contained in:
@@ -7063,7 +7063,7 @@ bool GUI_App::run_wizard(ConfigWizard::RunReason reason, ConfigWizard::StartPage
|
|||||||
}
|
}
|
||||||
auto isAgree = wxGetApp().app_config->get("app", "privacy_policy_isagree");
|
auto isAgree = wxGetApp().app_config->get("app", "privacy_policy_isagree");
|
||||||
|
|
||||||
set_privacy_policy(isAgree == "true");
|
user_update_privacy_notify(isAgree == "true");
|
||||||
BOOST_LOG_TRIVIAL(warning) << "run_wizard changed the privacy policy with: " << (isAgree);
|
BOOST_LOG_TRIVIAL(warning) << "run_wizard changed the privacy policy with: " << (isAgree);
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
@@ -7268,6 +7268,23 @@ void GUI_App::cache_notify(const std::string& key, const json& res)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void GUI_App::user_update_privacy_notify(const bool& res)
|
||||||
|
{
|
||||||
|
set_privacy_policy(res);
|
||||||
|
|
||||||
|
json data;
|
||||||
|
|
||||||
|
data["privacy_policy_isagree"] = res;
|
||||||
|
|
||||||
|
for (const auto& instance : m_user_update_privacy_subscribers) {
|
||||||
|
auto ptr = instance.second.lock();
|
||||||
|
if (ptr) {
|
||||||
|
ptr->m_res_data = data;
|
||||||
|
ptr->send_to_js();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
void GUI_App::user_login_notify(const json& res)
|
void GUI_App::user_login_notify(const json& res)
|
||||||
{
|
{
|
||||||
@@ -7283,7 +7300,7 @@ void GUI_App::user_login_notify(const json& res)
|
|||||||
bool GUI_App::config_wizard_startup()
|
bool GUI_App::config_wizard_startup()
|
||||||
{
|
{
|
||||||
auto isAgree = wxGetApp().app_config->get("app", "privacy_policy_isagree");
|
auto isAgree = wxGetApp().app_config->get("app", "privacy_policy_isagree");
|
||||||
set_privacy_policy(isAgree == "true");
|
user_update_privacy_notify(isAgree == "true");
|
||||||
BOOST_LOG_TRIVIAL(warning) << "config_wizard_startup changed the privacy policy with: " << (isAgree);
|
BOOST_LOG_TRIVIAL(warning) << "config_wizard_startup changed the privacy policy with: " << (isAgree);
|
||||||
if (!m_app_conf_exists || preset_bundle->printers.only_default_printers()) {
|
if (!m_app_conf_exists || preset_bundle->printers.only_default_printers()) {
|
||||||
BOOST_LOG_TRIVIAL(info) << "run wizard...";
|
BOOST_LOG_TRIVIAL(info) << "run wizard...";
|
||||||
|
|||||||
@@ -834,7 +834,7 @@ public:
|
|||||||
std::unordered_map<void*, std::weak_ptr<SSWCP_Instance>> m_user_login_subscribers;
|
std::unordered_map<void*, std::weak_ptr<SSWCP_Instance>> m_user_login_subscribers;
|
||||||
std::unordered_map<void*, std::weak_ptr<SSWCP_Instance>> m_device_card_subscribers;
|
std::unordered_map<void*, std::weak_ptr<SSWCP_Instance>> m_device_card_subscribers;
|
||||||
std::unordered_map<void*, std::weak_ptr<SSWCP_Instance>> m_page_state_subscribers;
|
std::unordered_map<void*, std::weak_ptr<SSWCP_Instance>> m_page_state_subscribers;
|
||||||
|
std::unordered_map<void*, std::weak_ptr<SSWCP_Instance>> m_user_update_privacy_subscribers;
|
||||||
struct CachePairCompare
|
struct CachePairCompare
|
||||||
{
|
{
|
||||||
bool operator()(const std::pair<void*, std::weak_ptr<SSWCP_Instance>>& lhs,
|
bool operator()(const std::pair<void*, std::weak_ptr<SSWCP_Instance>>& lhs,
|
||||||
@@ -850,7 +850,7 @@ public:
|
|||||||
void device_card_notify(const json& res);
|
void device_card_notify(const json& res);
|
||||||
void page_state_notify_webview(wxWebView* webview, const std::string& state);
|
void page_state_notify_webview(wxWebView* webview, const std::string& state);
|
||||||
void cache_notify(const std::string& key, const json& res);
|
void cache_notify(const std::string& key, const json& res);
|
||||||
|
void user_update_privacy_notify(const bool& res);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
bool sm_disconnect_current_machine(bool need_reload_printerview = true);
|
bool sm_disconnect_current_machine(bool need_reload_printerview = true);
|
||||||
|
|||||||
@@ -752,7 +752,7 @@ wxBoxSizer *PreferencesDialog::create_item_checkbox(wxString title, wxWindow *pa
|
|||||||
{
|
{
|
||||||
app_config->set("app", "privacy_policy_isagree", checkbox->GetValue());
|
app_config->set("app", "privacy_policy_isagree", checkbox->GetValue());
|
||||||
BOOST_LOG_TRIVIAL(warning) <<"create_item_checkbox changed the privacy policy with: "<<(checkbox->GetValue()?"true" : "false");
|
BOOST_LOG_TRIVIAL(warning) <<"create_item_checkbox changed the privacy policy with: "<<(checkbox->GetValue()?"true" : "false");
|
||||||
set_privacy_policy(checkbox->GetValue());
|
wxGetApp().user_update_privacy_notify(checkbox->GetValue());
|
||||||
}
|
}
|
||||||
// if (param == "staff_pick_switch") {
|
// if (param == "staff_pick_switch") {
|
||||||
// bool pbool = app_config->get("staff_pick_switch") == "true";
|
// bool pbool = app_config->get("staff_pick_switch") == "true";
|
||||||
|
|||||||
@@ -1175,6 +1175,7 @@ void SSWCP_Instance::sw_UnsubscribeAll() {
|
|||||||
wxGetApp().m_recent_file_subscribers.clear();
|
wxGetApp().m_recent_file_subscribers.clear();
|
||||||
wxGetApp().m_user_login_subscribers.clear();
|
wxGetApp().m_user_login_subscribers.clear();
|
||||||
wxGetApp().m_cache_subscribers.clear();
|
wxGetApp().m_cache_subscribers.clear();
|
||||||
|
wxGetApp().m_user_update_privacy_subscribers.clear();
|
||||||
|
|
||||||
send_to_js();
|
send_to_js();
|
||||||
finish_job();
|
finish_job();
|
||||||
@@ -1217,6 +1218,15 @@ void SSWCP_Instance::sw_Webview_Unsubscribe() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
auto& privacy_map = wxGetApp().m_user_update_privacy_subscribers;
|
||||||
|
for (auto iter = privacy_map.begin(); iter != privacy_map.end();) {
|
||||||
|
if (iter->first == m_webview) {
|
||||||
|
iter = privacy_map.erase(iter);
|
||||||
|
} else {
|
||||||
|
iter++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
send_to_js();
|
send_to_js();
|
||||||
finish_job();
|
finish_job();
|
||||||
}
|
}
|
||||||
@@ -1233,6 +1243,7 @@ void SSWCP_Instance::sw_Unsubscribe_Filter() {
|
|||||||
|
|
||||||
auto& device_map = wxGetApp().m_device_card_subscribers;
|
auto& device_map = wxGetApp().m_device_card_subscribers;
|
||||||
auto& login_map = wxGetApp().m_user_login_subscribers;
|
auto& login_map = wxGetApp().m_user_login_subscribers;
|
||||||
|
auto& privacy_map = wxGetApp().m_user_update_privacy_subscribers;
|
||||||
auto& recent_file_map = wxGetApp().m_recent_file_subscribers;
|
auto& recent_file_map = wxGetApp().m_recent_file_subscribers;
|
||||||
auto& cache_map = wxGetApp().m_cache_subscribers;
|
auto& cache_map = wxGetApp().m_cache_subscribers;
|
||||||
|
|
||||||
@@ -1271,6 +1282,23 @@ void SSWCP_Instance::sw_Unsubscribe_Filter() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for (auto iter = privacy_map.begin(); iter != privacy_map.end();) {
|
||||||
|
if (iter->first == m_webview) {
|
||||||
|
auto ptr = iter->second.lock();
|
||||||
|
if (ptr) {
|
||||||
|
if (ptr->m_event_id == event_id) {
|
||||||
|
iter = privacy_map.erase(iter);
|
||||||
|
} else {
|
||||||
|
iter++;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
iter = privacy_map.erase(iter);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
iter++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
for (auto iter = recent_file_map.begin(); iter != recent_file_map.end();) {
|
for (auto iter = recent_file_map.begin(); iter != recent_file_map.end();) {
|
||||||
if (iter->first == m_webview) {
|
if (iter->first == m_webview) {
|
||||||
auto ptr = iter->second.lock();
|
auto ptr = iter->second.lock();
|
||||||
@@ -1339,7 +1367,26 @@ void SSWCP_Instance::sw_Unsubscribe_Filter() {
|
|||||||
iter++;
|
iter++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if (cmd == "sw_SubscribeLocalDevices") {
|
} else if (cmd == UPDATE_PRIVACY_STATUS) {
|
||||||
|
|
||||||
|
for (auto iter = privacy_map.begin(); iter != privacy_map.end();) {
|
||||||
|
if (iter->first == m_webview) {
|
||||||
|
auto ptr = iter->second.lock();
|
||||||
|
if (ptr) {
|
||||||
|
if (event_id == "" || (event_id != "" && event_id == ptr->m_event_id)) {
|
||||||
|
iter = privacy_map.erase(iter);
|
||||||
|
} else {
|
||||||
|
iter++;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
iter = privacy_map.erase(iter);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
iter++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}else if (cmd == "sw_SubscribeLocalDevices") {
|
||||||
for (auto iter = device_map.begin(); iter != device_map.end();) {
|
for (auto iter = device_map.begin(); iter != device_map.end();) {
|
||||||
if (iter->first == m_webview) {
|
if (iter->first == m_webview) {
|
||||||
auto ptr = iter->second.lock();
|
auto ptr = iter->second.lock();
|
||||||
@@ -5941,6 +5988,15 @@ void SSWCP::on_webview_delete(wxWebView* view)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
auto& privacy_map = wxGetApp().m_user_update_privacy_subscribers;
|
||||||
|
for (auto iter = privacy_map.begin(); iter != privacy_map.end();) {
|
||||||
|
if (iter->first == view) {
|
||||||
|
iter = privacy_map.erase(iter);
|
||||||
|
} else {
|
||||||
|
iter++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
auto& recent_file_map = wxGetApp().m_recent_file_subscribers;
|
auto& recent_file_map = wxGetApp().m_recent_file_subscribers;
|
||||||
for (auto iter = recent_file_map.begin(); iter != recent_file_map.end();) {
|
for (auto iter = recent_file_map.begin(); iter != recent_file_map.end();) {
|
||||||
if (iter->first == view) {
|
if (iter->first == view) {
|
||||||
|
|||||||
@@ -23,6 +23,8 @@ using namespace nlohmann;
|
|||||||
namespace asio = boost::asio;
|
namespace asio = boost::asio;
|
||||||
using tcp = asio::ip::tcp;
|
using tcp = asio::ip::tcp;
|
||||||
|
|
||||||
|
#define UPDATE_PRIVACY_STATUS "sw_SubUserUpdatePrivacy"
|
||||||
|
|
||||||
namespace Slic3r { namespace GUI {
|
namespace Slic3r { namespace GUI {
|
||||||
|
|
||||||
class WCP_Logger
|
class WCP_Logger
|
||||||
@@ -525,6 +527,8 @@ private:
|
|||||||
|
|
||||||
void sw_SubscribeUserLoginState();
|
void sw_SubscribeUserLoginState();
|
||||||
|
|
||||||
|
void sw_SubUserUpdatePrivacy();
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
// Instance class for homepage business
|
// Instance class for homepage business
|
||||||
|
|||||||
@@ -651,7 +651,7 @@ int GuideFrame::SaveProfile()
|
|||||||
// m_MainPtr->app_config->set(std::string(m_SectionName.mb_str()), "privacyuse", "0");
|
// m_MainPtr->app_config->set(std::string(m_SectionName.mb_str()), "privacyuse", "0");
|
||||||
m_MainPtr->app_config->set("app", "privacy_policy_isagree", PrivacyUse);
|
m_MainPtr->app_config->set("app", "privacy_policy_isagree", PrivacyUse);
|
||||||
BOOST_LOG_TRIVIAL(warning) << "SaveProfile changed the privacy policy with: " << (PrivacyUse ? "true" : "false");
|
BOOST_LOG_TRIVIAL(warning) << "SaveProfile changed the privacy policy with: " << (PrivacyUse ? "true" : "false");
|
||||||
set_privacy_policy(PrivacyUse);
|
wxGetApp().user_update_privacy_notify(PrivacyUse);
|
||||||
m_MainPtr->app_config->set("region", m_Region);
|
m_MainPtr->app_config->set("region", m_Region);
|
||||||
m_MainPtr->app_config->set_bool("stealth_mode", StealthMode);
|
m_MainPtr->app_config->set_bool("stealth_mode", StealthMode);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user