mirror of
https://git.mirrors.martin98.com/https://github.com/prusa3d/PrusaSlicer.git
synced 2025-08-16 22:26:01 +08:00
Login url with service. Changed code for registering custom url to not check downloader dest..
This commit is contained in:
parent
17300d7549
commit
02ddb36108
@ -1718,7 +1718,7 @@ bool PageDownloader::on_finish_downloader() const
|
|||||||
bool DownloaderUtils::Worker::perform_registration_linux = false;
|
bool DownloaderUtils::Worker::perform_registration_linux = false;
|
||||||
#endif // __linux__
|
#endif // __linux__
|
||||||
|
|
||||||
bool DownloaderUtils::Worker::perform_register(const std::string& path)
|
bool DownloaderUtils::Worker::perform_download_register(const std::string& path)
|
||||||
{
|
{
|
||||||
boost::filesystem::path aux_dest (path);
|
boost::filesystem::path aux_dest (path);
|
||||||
boost::system::error_code ec;
|
boost::system::error_code ec;
|
||||||
@ -1734,6 +1734,10 @@ bool DownloaderUtils::Worker::perform_register(const std::string& path)
|
|||||||
}
|
}
|
||||||
BOOST_LOG_TRIVIAL(info) << "Downloader registration: Directory for downloads: " << chosen_dest.string();
|
BOOST_LOG_TRIVIAL(info) << "Downloader registration: Directory for downloads: " << chosen_dest.string();
|
||||||
wxGetApp().app_config->set("url_downloader_dest", chosen_dest.string());
|
wxGetApp().app_config->set("url_downloader_dest", chosen_dest.string());
|
||||||
|
perform_url_register();
|
||||||
|
}
|
||||||
|
bool DownloaderUtils::Worker::perform_url_register()
|
||||||
|
{
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
// Registry key creation for "prusaslicer://" URL
|
// Registry key creation for "prusaslicer://" URL
|
||||||
|
|
||||||
@ -1793,12 +1797,12 @@ bool DownloaderUtils::Worker::on_finish() {
|
|||||||
BOOST_LOG_TRIVIAL(debug) << "PageDownloader::on_finish_downloader ac_value " << ac_value << " downloader_checked " << downloader_checked;
|
BOOST_LOG_TRIVIAL(debug) << "PageDownloader::on_finish_downloader ac_value " << ac_value << " downloader_checked " << downloader_checked;
|
||||||
if (ac_value && downloader_checked) {
|
if (ac_value && downloader_checked) {
|
||||||
// already registered but we need to do it again
|
// already registered but we need to do it again
|
||||||
if (!perform_register(GUI::into_u8(path_name())))
|
if (!perform_download_register(GUI::into_u8(path_name())))
|
||||||
return false;
|
return false;
|
||||||
app_config->set("downloader_url_registered", "1");
|
app_config->set("downloader_url_registered", "1");
|
||||||
} else if (!ac_value && downloader_checked) {
|
} else if (!ac_value && downloader_checked) {
|
||||||
// register
|
// register
|
||||||
if (!perform_register(GUI::into_u8(path_name())))
|
if (!perform_download_register(GUI::into_u8(path_name())))
|
||||||
return false;
|
return false;
|
||||||
app_config->set("downloader_url_registered", "1");
|
app_config->set("downloader_url_registered", "1");
|
||||||
} else if (ac_value && !downloader_checked) {
|
} else if (ac_value && !downloader_checked) {
|
||||||
|
@ -52,7 +52,8 @@ namespace DownloaderUtils {
|
|||||||
void set_path_name(const std::string& name);
|
void set_path_name(const std::string& name);
|
||||||
|
|
||||||
bool on_finish();
|
bool on_finish();
|
||||||
static bool perform_register(const std::string& path);
|
static bool perform_download_register(const std::string& path);
|
||||||
|
static bool perform_url_register();
|
||||||
#ifdef __linux__
|
#ifdef __linux__
|
||||||
static bool perform_registration_linux;
|
static bool perform_registration_linux;
|
||||||
#endif // __linux__
|
#endif // __linux__
|
||||||
|
@ -3337,7 +3337,7 @@ void GUI_App::show_downloader_registration_dialog()
|
|||||||
, true, wxYES_NO);
|
, true, wxYES_NO);
|
||||||
if (msg.ShowModal() == wxID_YES) {
|
if (msg.ShowModal() == wxID_YES) {
|
||||||
auto downloader_worker = new DownloaderUtils::Worker(nullptr);
|
auto downloader_worker = new DownloaderUtils::Worker(nullptr);
|
||||||
downloader_worker->perform_register(app_config->get("url_downloader_dest"));
|
downloader_worker->perform_download_register(app_config->get("url_downloader_dest"));
|
||||||
#if defined(__linux__) && defined(SLIC3R_DESKTOP_INTEGRATION)
|
#if defined(__linux__) && defined(SLIC3R_DESKTOP_INTEGRATION)
|
||||||
if (DownloaderUtils::Worker::perform_registration_linux)
|
if (DownloaderUtils::Worker::perform_registration_linux)
|
||||||
DesktopIntegrationDialog::perform_downloader_desktop_integration();
|
DesktopIntegrationDialog::perform_downloader_desktop_integration();
|
||||||
|
@ -891,7 +891,7 @@ Plater::priv::priv(Plater *q, MainFrame *main_frame)
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
this->q->Bind(EVT_OPEN_EXTERNAL_LOGIN, [this](wxCommandEvent& evt) {
|
this->q->Bind(EVT_OPEN_EXTERNAL_LOGIN, [this](wxCommandEvent& evt) {
|
||||||
DownloaderUtils::Worker::perform_register(wxGetApp().app_config->get("url_downloader_dest"));
|
DownloaderUtils::Worker::perform_url_register();
|
||||||
#if defined(__linux__)
|
#if defined(__linux__)
|
||||||
// Remove all desktop files registering prusaslicer:// url done by previous versions.
|
// Remove all desktop files registering prusaslicer:// url done by previous versions.
|
||||||
DesktopIntegrationDialog::undo_downloader_registration_rigid();
|
DesktopIntegrationDialog::undo_downloader_registration_rigid();
|
||||||
@ -900,7 +900,15 @@ Plater::priv::priv(Plater *q, MainFrame *main_frame)
|
|||||||
DesktopIntegrationDialog::perform_downloader_desktop_integration();
|
DesktopIntegrationDialog::perform_downloader_desktop_integration();
|
||||||
#endif // SLIC3R_DESKTOP_INTEGRATION
|
#endif // SLIC3R_DESKTOP_INTEGRATION
|
||||||
#endif // __linux__
|
#endif // __linux__
|
||||||
wxString url = user_account->get_login_redirect_url()+ L"&choose_account=1";
|
std::string service;
|
||||||
|
if (evt.GetString().Find("accounts.google.com") != wxString::npos) {
|
||||||
|
service = "google";
|
||||||
|
} else if (evt.GetString().Find("appleid.apple.com") != wxString::npos) {
|
||||||
|
service = "apple";
|
||||||
|
} else if (evt.GetString().Find("facebook.com") != wxString::npos) {
|
||||||
|
service = "facebook";
|
||||||
|
}
|
||||||
|
wxString url = user_account->get_login_redirect_url(service);
|
||||||
wxGetApp().open_login_browser_with_dialog(into_u8(url));
|
wxGetApp().open_login_browser_with_dialog(into_u8(url));
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -39,7 +39,7 @@ public:
|
|||||||
void do_login();
|
void do_login();
|
||||||
void do_logout();
|
void do_logout();
|
||||||
wxString generate_login_redirect_url() { return m_communication->generate_login_redirect_url(); }
|
wxString generate_login_redirect_url() { return m_communication->generate_login_redirect_url(); }
|
||||||
wxString get_login_redirect_url() { return m_communication->get_login_redirect_url(); }
|
wxString get_login_redirect_url(const std::string& service = std::string()) { return m_communication->get_login_redirect_url(service); }
|
||||||
|
|
||||||
void set_remember_session(bool remember);
|
void set_remember_session(bool remember);
|
||||||
void toggle_remember_session();
|
void toggle_remember_session();
|
||||||
|
@ -322,7 +322,7 @@ void UserAccountCommunication::on_uuid_map_success()
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Generates and stores Code Verifier - second call deletes previous one.
|
// Generates and stores Code Verifier - second call deletes previous one.
|
||||||
wxString UserAccountCommunication::generate_login_redirect_url()
|
wxString UserAccountCommunication::generate_login_redirect_url()
|
||||||
{
|
{
|
||||||
auto& sc = Utils::ServiceConfig::instance();
|
auto& sc = Utils::ServiceConfig::instance();
|
||||||
const std::string AUTH_HOST = sc.account_url();
|
const std::string AUTH_HOST = sc.account_url();
|
||||||
@ -339,7 +339,7 @@ wxString UserAccountCommunication::generate_login_redirect_url()
|
|||||||
wxString url = GUI::format_wxstr(L"%1%/o/authorize/?embed=1&client_id=%2%&response_type=code&code_challenge=%3%&code_challenge_method=S256&scope=basic_info&redirect_uri=%4%&language=%5%", AUTH_HOST, CLIENT_ID, code_challenge, REDIRECT_URI, language);
|
wxString url = GUI::format_wxstr(L"%1%/o/authorize/?embed=1&client_id=%2%&response_type=code&code_challenge=%3%&code_challenge_method=S256&scope=basic_info&redirect_uri=%4%&language=%5%", AUTH_HOST, CLIENT_ID, code_challenge, REDIRECT_URI, language);
|
||||||
return url;
|
return url;
|
||||||
}
|
}
|
||||||
wxString UserAccountCommunication::get_login_redirect_url() const
|
wxString UserAccountCommunication::get_login_redirect_url(const std::string& service/* = std::string()*/) const
|
||||||
{
|
{
|
||||||
auto& sc = Utils::ServiceConfig::instance();
|
auto& sc = Utils::ServiceConfig::instance();
|
||||||
const std::string AUTH_HOST = sc.account_url();
|
const std::string AUTH_HOST = sc.account_url();
|
||||||
@ -349,10 +349,10 @@ wxString UserAccountCommunication::get_login_redirect_url() const
|
|||||||
std::string code_challenge = ccg.generate_chalenge(m_code_verifier);
|
std::string code_challenge = ccg.generate_chalenge(m_code_verifier);
|
||||||
wxString language = GUI::wxGetApp().current_language_code();
|
wxString language = GUI::wxGetApp().current_language_code();
|
||||||
language = language.SubString(0, 1);
|
language = language.SubString(0, 1);
|
||||||
BOOST_LOG_TRIVIAL(info) << "code verifier: " << m_code_verifier;
|
|
||||||
BOOST_LOG_TRIVIAL(info) << "code challenge: " << code_challenge;
|
|
||||||
|
|
||||||
wxString url = GUI::format_wxstr(L"%1%/o/authorize/?embed=1&client_id=%2%&response_type=code&code_challenge=%3%&code_challenge_method=S256&scope=basic_info&redirect_uri=%4%&language=%5%", AUTH_HOST, CLIENT_ID, code_challenge, REDIRECT_URI, language);
|
std::string params = GUI::format("embed=1&client_id=%1%&response_type=code&code_challenge=%2%&code_challenge_method=S256&scope=basic_info&redirect_uri=%3%&language=%4%", CLIENT_ID, code_challenge, REDIRECT_URI, language);
|
||||||
|
params = Http::url_encode(params);
|
||||||
|
wxString url = GUI::format_wxstr(L"%1%/login/%2%?next=/o/authorize/?%3%", AUTH_HOST, service, params);
|
||||||
return url;
|
return url;
|
||||||
}
|
}
|
||||||
void UserAccountCommunication::login_redirect()
|
void UserAccountCommunication::login_redirect()
|
||||||
|
@ -45,7 +45,7 @@ public:
|
|||||||
// Generates and stores Code Verifier - second call deletes previous one.
|
// Generates and stores Code Verifier - second call deletes previous one.
|
||||||
wxString generate_login_redirect_url();
|
wxString generate_login_redirect_url();
|
||||||
// Only recreates the url with already existing url (if generate was not called before - url will be faulty)
|
// Only recreates the url with already existing url (if generate was not called before - url will be faulty)
|
||||||
wxString get_login_redirect_url() const;
|
wxString get_login_redirect_url(const std::string& service = std::string()) const;
|
||||||
// Trigger function starts various remote operations
|
// Trigger function starts various remote operations
|
||||||
void enqueue_connect_status_action();
|
void enqueue_connect_status_action();
|
||||||
void enqueue_connect_printer_models_action();
|
void enqueue_connect_printer_models_action();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user