mirror of
https://git.mirrors.martin98.com/https://github.com/prusa3d/PrusaSlicer.git
synced 2025-08-01 10:02:01 +08:00
Get apikey from printer message and use it for upload.
Several compiler warning fixes Fix of MacOS SHA256 generator
This commit is contained in:
parent
e92304c6eb
commit
2309b66e02
@ -380,7 +380,6 @@ std::string CodeChalengeGenerator::sha256(const std::string& input)
|
|||||||
{
|
{
|
||||||
HCRYPTPROV prov_handle = NULL;
|
HCRYPTPROV prov_handle = NULL;
|
||||||
HCRYPTHASH hash_handle = NULL;
|
HCRYPTHASH hash_handle = NULL;
|
||||||
std::vector<BYTE> buffer(1024);
|
|
||||||
DWORD hash_size = 0;
|
DWORD hash_size = 0;
|
||||||
DWORD buffer_size = sizeof(DWORD);
|
DWORD buffer_size = sizeof(DWORD);
|
||||||
std::string output;
|
std::string output;
|
||||||
@ -423,13 +422,7 @@ std::string CodeChalengeGenerator::sha256(const std::string& input) {
|
|||||||
unsigned char digest[CC_SHA256_DIGEST_LENGTH];
|
unsigned char digest[CC_SHA256_DIGEST_LENGTH];
|
||||||
CC_SHA256_Final(digest, &sha256);
|
CC_SHA256_Final(digest, &sha256);
|
||||||
|
|
||||||
// Convert the result to a string
|
return std::string(reinterpret_cast<char*>(digest), CC_SHA256_DIGEST_LENGTH);
|
||||||
char hashString[CC_SHA256_DIGEST_LENGTH * 2 + 1];
|
|
||||||
for (int i = 0; i < CC_SHA256_DIGEST_LENGTH; i++) {
|
|
||||||
sprintf(&hashString[i * 2], "%02x", digest[i]);
|
|
||||||
}
|
|
||||||
|
|
||||||
return std::string(hashString);
|
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
std::string CodeChalengeGenerator::sha256(const std::string& input) {
|
std::string CodeChalengeGenerator::sha256(const std::string& input) {
|
||||||
|
@ -870,7 +870,7 @@ Plater::priv::priv(Plater *q, MainFrame *main_frame)
|
|||||||
bring_instance_forward();
|
bring_instance_forward();
|
||||||
});
|
});
|
||||||
|
|
||||||
this->q->Bind(EVT_OPEN_PRUSAAUTH, [this](OpenPrusaAuthEvent& evt) {
|
this->q->Bind(EVT_OPEN_PRUSAAUTH, [](OpenPrusaAuthEvent& evt) {
|
||||||
BOOST_LOG_TRIVIAL(info) << "open browser: " << evt.data;
|
BOOST_LOG_TRIVIAL(info) << "open browser: " << evt.data;
|
||||||
// first register url to be sure to get the code back
|
// first register url to be sure to get the code back
|
||||||
//auto downloader_worker = new DownloaderUtils::Worker(nullptr);
|
//auto downloader_worker = new DownloaderUtils::Worker(nullptr);
|
||||||
@ -5861,12 +5861,10 @@ void Plater::connect_gcode()
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: get api key from dialog_msg and upload the file
|
// TODO: break if printer not ready
|
||||||
// api key is not currently in the message
|
|
||||||
std::string api_key;
|
|
||||||
|
|
||||||
// This is private key for our printer "Loki" - DELETE!
|
// get api key from dialog_msg and upload the file
|
||||||
//api_key = "PAARWQ2Ibd69fdbf";
|
std::string api_key = p->user_account->get_apikey_from_json(dialog_msg);
|
||||||
if (api_key.empty())
|
if (api_key.empty())
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
|
@ -270,4 +270,21 @@ std::string UserAccount::get_nozzle_from_json(const std::string& message) const
|
|||||||
return out;
|
return out;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::string UserAccount::get_apikey_from_json(const std::string& message) const
|
||||||
|
{
|
||||||
|
std::string out;
|
||||||
|
try {
|
||||||
|
std::stringstream ss(message);
|
||||||
|
pt::ptree ptree;
|
||||||
|
pt::read_json(ss, ptree);
|
||||||
|
|
||||||
|
out = parse_tree_for_param(ptree, "prusaconnect_api_key");
|
||||||
|
//assert(!out.empty());
|
||||||
|
}
|
||||||
|
catch (const std::exception& e) {
|
||||||
|
BOOST_LOG_TRIVIAL(error) << "Could not parse prusaconnect message. " << e.what();
|
||||||
|
}
|
||||||
|
return out;
|
||||||
|
}
|
||||||
|
|
||||||
}} // namespace slic3r::GUI
|
}} // namespace slic3r::GUI
|
@ -60,6 +60,7 @@ public:
|
|||||||
// standalone utility methods
|
// standalone utility methods
|
||||||
std::string get_model_from_json(const std::string& message) const;
|
std::string get_model_from_json(const std::string& message) const;
|
||||||
std::string get_nozzle_from_json(const std::string& message) const;
|
std::string get_nozzle_from_json(const std::string& message) const;
|
||||||
|
std::string get_apikey_from_json(const std::string& message) const;
|
||||||
private:
|
private:
|
||||||
void set_username(const std::string& username, AppConfig* app_config);
|
void set_username(const std::string& username, AppConfig* app_config);
|
||||||
void reset(AppConfig* app_config);
|
void reset(AppConfig* app_config);
|
||||||
|
@ -154,7 +154,6 @@ bool WebView::run_script(wxWebView *webView, wxString const &javascript)
|
|||||||
return webView2->ExecuteScript(wrapJS.GetWrappedCode(), NULL) == 0;
|
return webView2->ExecuteScript(wrapJS.GetWrappedCode(), NULL) == 0;
|
||||||
#elif defined __WXMAC__
|
#elif defined __WXMAC__
|
||||||
WKWebView * wkWebView = (WKWebView *) webView->GetNativeBackend();
|
WKWebView * wkWebView = (WKWebView *) webView->GetNativeBackend();
|
||||||
int count = 0;
|
|
||||||
wxJSScriptWrapper wrapJS(javascript, wxJSScriptWrapper::OutputType::JS_OUTPUT_STRING);
|
wxJSScriptWrapper wrapJS(javascript, wxJSScriptWrapper::OutputType::JS_OUTPUT_STRING);
|
||||||
Slic3r::GUI::WKWebView_evaluateJavaScript(wkWebView, wrapJS.GetWrappedCode(), nullptr);
|
Slic3r::GUI::WKWebView_evaluateJavaScript(wkWebView, wrapJS.GetWrappedCode(), nullptr);
|
||||||
return true;
|
return true;
|
||||||
|
@ -463,7 +463,7 @@ void WebViewDialog::run_script(const wxString& javascript)
|
|||||||
{
|
{
|
||||||
if (!m_browser)
|
if (!m_browser)
|
||||||
return;
|
return;
|
||||||
bool res = WebView::run_script(m_browser, javascript);
|
//bool res = WebView::run_script(m_browser, javascript);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -208,7 +208,7 @@ void WifiConfigDialog::rescan_networks(bool select)
|
|||||||
std::string current = m_wifi_scanner->get_current_ssid();
|
std::string current = m_wifi_scanner->get_current_ssid();
|
||||||
const auto& map = m_wifi_scanner->get_map();
|
const auto& map = m_wifi_scanner->get_map();
|
||||||
m_ssid_combo->Clear();
|
m_ssid_combo->Clear();
|
||||||
for (const auto &pair : map) {
|
for (const auto& pair : map) {
|
||||||
m_ssid_combo->Append(pair.first);
|
m_ssid_combo->Append(pair.first);
|
||||||
// select ssid of current network (if connected)
|
// select ssid of current network (if connected)
|
||||||
if (current == pair.first)
|
if (current == pair.first)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user