Introducing Orca Cloud: https://cloud.orcaslicer.com (#13414)
* Add OrcaCloud sync platform and preset bundle sharing system Introduce OrcaCloud, a cloud sync platform for user presets, alongside a preset bundle system that enables sharing printer/filament/process profiles as local exportable bundles or subscribed cloud bundles. OrcaCloud platform: - Auth to Orca Cloud - Encrypted token storage (file-based or system keychain) - User preset sync with - Profile migration from default/bambu folders on first login - Homepage integration with entrance to cloud.orcaslicer.com Preset bundles: - Local bundle import/export with bundle_structure.json metadata - Subscribed cloud bundles with version-based update checking - Thread-safe concurrent bundle access with read-write mutex - Canonical bundle preset naming (_local/<id>/... and _subscribed/<id>/...) - Bundle presets are read-only; grouped under subheaders in combo boxes - PresetBundleDialog with auto-sync toggle, refresh, update notifications - Hyperlinked bundle names to cloud bundle pages Co-authored-by: Sabriel Koh <sabrielkcr@gmail.com> Co-authored-by: Derrick <derrick992110@gmail.com> Co-authored-by: Mykola Nahirnyi <mnahirnyi@amcbridge.com> Co-authored-by: Ian Chua <iancrb00@gmail.com> Co-authored-by: Draginraptor <draginraptor@gmail.com> Co-authored-by: ExPikaPaka <112851715+ExPikaPaka@users.noreply.github.com> Co-authored-by: Ian Bassi <ian.bassi@outlook.com> Co-authored-by: Ocraftyone <Ocraftyone@users.noreply.github.com> Co-authored-by: yw4z <ywsyildiz@gmail.com> Co-authored-by: peterm-m <101202951+peterm-m@users.noreply.github.com> * Fixed an issue on Windows it failed to login Orca Cloud with Google account
This commit is contained in:
@@ -61,7 +61,7 @@ void session::read_body()
|
||||
int nbuffer = 1000;
|
||||
std::shared_ptr<std::vector<char>> bufptr = std::make_shared<std::vector<char>>(nbuffer);
|
||||
async_read(socket, boost::asio::buffer(*bufptr, nbuffer),
|
||||
[this, self](const boost::beast::error_code& e, std::size_t s) { server.stop(self); });
|
||||
[this, self, bufptr](const boost::beast::error_code& e, std::size_t s) { server.stop(self); });
|
||||
}
|
||||
|
||||
void session::read_next_line()
|
||||
@@ -146,18 +146,27 @@ void HttpServer::IOServer::stop_all()
|
||||
|
||||
HttpServer::HttpServer(boost::asio::ip::port_type port) : port(port) {}
|
||||
|
||||
HttpServer::~HttpServer()
|
||||
{
|
||||
stop();
|
||||
}
|
||||
|
||||
void HttpServer::start()
|
||||
{
|
||||
if (start_http_server)
|
||||
return;
|
||||
|
||||
BOOST_LOG_TRIVIAL(info) << "start_http_service...";
|
||||
start_http_server = true;
|
||||
m_http_server_thread = create_thread([this] {
|
||||
server_ = std::make_unique<IOServer>(*this);
|
||||
IOServer* io_server = server_.get();
|
||||
start_http_server = true;
|
||||
m_http_server_thread = create_thread([io_server] {
|
||||
set_current_thread_name("http_server");
|
||||
server_ = std::make_unique<IOServer>(*this);
|
||||
server_->acceptor.listen();
|
||||
io_server->acceptor.listen();
|
||||
|
||||
server_->do_accept();
|
||||
io_server->do_accept();
|
||||
|
||||
server_->io_service.run();
|
||||
io_server->io_service.run();
|
||||
});
|
||||
}
|
||||
|
||||
@@ -165,9 +174,14 @@ void HttpServer::stop()
|
||||
{
|
||||
start_http_server = false;
|
||||
if (server_) {
|
||||
server_->acceptor.close();
|
||||
server_->stop_all();
|
||||
server_->io_service.stop();
|
||||
IOServer* io_server = server_.get();
|
||||
boost::asio::post(io_server->io_service, [io_server] {
|
||||
boost::system::error_code ec;
|
||||
io_server->acceptor.cancel(ec);
|
||||
io_server->acceptor.close(ec);
|
||||
io_server->stop_all();
|
||||
io_server->io_service.stop();
|
||||
});
|
||||
}
|
||||
if (m_http_server_thread.joinable())
|
||||
m_http_server_thread.join();
|
||||
@@ -180,12 +194,20 @@ void HttpServer::set_request_handler(const std::function<std::shared_ptr<Respons
|
||||
}
|
||||
|
||||
std::shared_ptr<HttpServer::Response> HttpServer::bbl_auth_handle_request(const std::string& url)
|
||||
{
|
||||
return auth_handle_request(url, BBL_CLOUD_PROVIDER);
|
||||
}
|
||||
|
||||
std::shared_ptr<HttpServer::Response> HttpServer::auth_handle_request(const std::string& url, const std::string& provider)
|
||||
{
|
||||
BOOST_LOG_TRIVIAL(info) << "thirdparty_login: get_response";
|
||||
|
||||
const std::string auth_code = url_get_param(url, "code");
|
||||
if (!auth_code.empty()) {
|
||||
std::string state = url_get_param(url, "state");
|
||||
std::string state = url_get_param(url, "orca_state");
|
||||
if (state.empty()) {
|
||||
state = url_get_param(url, "state"); // fallback
|
||||
}
|
||||
NetworkAgent* agent = wxGetApp().getAgent();
|
||||
if (!agent) {
|
||||
return std::make_shared<ResponseNotFound>();
|
||||
@@ -196,10 +218,10 @@ std::shared_ptr<HttpServer::Response> HttpServer::bbl_auth_handle_request(const
|
||||
payload["data"]["code"] = auth_code;
|
||||
payload["data"]["state"] = state;
|
||||
|
||||
agent->change_user(payload.dump());
|
||||
const bool login_ok = agent->is_user_login();
|
||||
agent->change_user(payload.dump(), provider);
|
||||
const bool login_ok = agent->is_user_login(provider);
|
||||
if (login_ok) {
|
||||
wxGetApp().request_user_login(1);
|
||||
wxGetApp().request_user_login(1, provider);
|
||||
GUI::wxGetApp().CallAfter([] { wxGetApp().ShowUserLogin(false); });
|
||||
}
|
||||
|
||||
@@ -229,7 +251,7 @@ std::shared_ptr<HttpServer::Response> HttpServer::bbl_auth_handle_request(const
|
||||
|
||||
unsigned int http_code;
|
||||
std::string http_body;
|
||||
int result = agent->get_my_profile(access_token, &http_code, &http_body);
|
||||
int result = agent->get_my_profile(access_token, &http_code, &http_body, provider);
|
||||
if (result == 0) {
|
||||
std::string user_id;
|
||||
std::string user_name;
|
||||
@@ -257,9 +279,9 @@ std::shared_ptr<HttpServer::Response> HttpServer::bbl_auth_handle_request(const
|
||||
j["data"]["user"]["name"] = user_name;
|
||||
j["data"]["user"]["account"] = user_account;
|
||||
j["data"]["user"]["avatar"] = user_avatar;
|
||||
agent->change_user(j.dump());
|
||||
if (agent->is_user_login()) {
|
||||
wxGetApp().request_user_login(1);
|
||||
agent->change_user(j.dump(), provider);
|
||||
if (agent->is_user_login(provider)) {
|
||||
wxGetApp().request_user_login(1, provider);
|
||||
}
|
||||
GUI::wxGetApp().CallAfter([] { wxGetApp().ShowUserLogin(false); });
|
||||
std::string location_str = (boost::format("%1%?result=success") % redirect_url).str();
|
||||
@@ -296,7 +318,7 @@ std::shared_ptr<HttpServer::Response> HttpServer::bbl_auth_handle_request(const
|
||||
|
||||
unsigned int token_http_code = 0;
|
||||
std::string token_body;
|
||||
int token_result = agent->get_my_token(ticket, &token_http_code, &token_body);
|
||||
int token_result = agent->get_my_token(ticket, &token_http_code, &token_body, provider);
|
||||
if (token_result != 0) {
|
||||
BOOST_LOG_TRIVIAL(warning) << "thirdparty_login: get_my_token failed, http_code=" << token_http_code;
|
||||
return fail_redirect("get_my_token_error_" + std::to_string(token_result));
|
||||
@@ -326,7 +348,7 @@ std::shared_ptr<HttpServer::Response> HttpServer::bbl_auth_handle_request(const
|
||||
|
||||
unsigned int profile_http_code = 0;
|
||||
std::string profile_body;
|
||||
int profile_result = agent->get_my_profile(access_token, &profile_http_code, &profile_body);
|
||||
int profile_result = agent->get_my_profile(access_token, &profile_http_code, &profile_body, provider);
|
||||
if (profile_result != 0) {
|
||||
BOOST_LOG_TRIVIAL(warning) << "thirdparty_login: get_my_profile failed, http_code=" << profile_http_code;
|
||||
return fail_redirect("get_user_profile_error_" + std::to_string(profile_result));
|
||||
@@ -359,9 +381,9 @@ std::shared_ptr<HttpServer::Response> HttpServer::bbl_auth_handle_request(const
|
||||
j["data"]["user"]["name"] = user_name;
|
||||
j["data"]["user"]["account"] = user_account;
|
||||
j["data"]["user"]["avatar"] = user_avatar;
|
||||
agent->change_user(j.dump());
|
||||
if (agent->is_user_login()) {
|
||||
wxGetApp().request_user_login(1);
|
||||
agent->change_user(j.dump(), provider);
|
||||
if (agent->is_user_login(provider)) {
|
||||
wxGetApp().request_user_login(1, provider);
|
||||
}
|
||||
GUI::wxGetApp().CallAfter([] { wxGetApp().ShowUserLogin(false); });
|
||||
std::string location_str = (boost::format("%1%?result=success") % ticket_redirect_url).str();
|
||||
|
||||
Reference in New Issue
Block a user