mirror of
https://github.com/QIDITECH/QIDIStudio.git
synced 2026-02-01 17:38:42 +03:00
Updated to 1.9.5, and optimize calibration and device
This commit is contained in:
@@ -15,6 +15,8 @@
|
||||
|
||||
#include <curl/curl.h>
|
||||
|
||||
#include "../GUI/PrinterWebView.hpp"
|
||||
|
||||
#ifdef OPENSSL_CERT_OVERRIDE
|
||||
#include <openssl/x509.h>
|
||||
#endif
|
||||
@@ -232,6 +234,9 @@ int Http::priv::xfercb(void *userp, curl_off_t dltotal, curl_off_t dlnow, curl_o
|
||||
{
|
||||
auto self = static_cast<priv*>(userp);
|
||||
bool cb_cancel = false;
|
||||
//y36
|
||||
if (PrintHost::GetStop())
|
||||
cb_cancel = true;
|
||||
|
||||
if (self->progressfn) {
|
||||
double speed;
|
||||
|
||||
@@ -145,6 +145,31 @@ NetworkAgent::~NetworkAgent()
|
||||
BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << boost::format(", this %1%, network_agent=%2%, destroy_agent_ptr=%3%, ret %4%")%this %network_agent %destroy_agent_ptr %ret;
|
||||
}
|
||||
|
||||
//1.9.5
|
||||
std::string NetworkAgent::get_libpath_in_current_directory(std::string library_name)
|
||||
{
|
||||
std::string lib_path;
|
||||
#if defined(_MSC_VER) || defined(_WIN32)
|
||||
wchar_t file_name[512];
|
||||
DWORD ret = GetModuleFileNameW(NULL, file_name, 512);
|
||||
if (!ret) {
|
||||
BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << boost::format(", GetModuleFileNameW return error, can not Load Library for %1%") % library_name;
|
||||
return lib_path;
|
||||
}
|
||||
int size_needed = ::WideCharToMultiByte(0, 0, file_name, wcslen(file_name), nullptr, 0, nullptr, nullptr);
|
||||
std::string file_name_string(size_needed, 0);
|
||||
::WideCharToMultiByte(0, 0, file_name, wcslen(file_name), file_name_string.data(), size_needed, nullptr, nullptr);
|
||||
|
||||
std::size_t found = file_name_string.find("qidi-studio.exe");
|
||||
if (found == (file_name_string.size() - 16)) {
|
||||
lib_path = library_name + ".dll";
|
||||
lib_path = file_name_string.replace(found, 16, lib_path);
|
||||
}
|
||||
#else
|
||||
#endif
|
||||
return lib_path;
|
||||
}
|
||||
|
||||
int NetworkAgent::initialize_network_module(bool using_backup)
|
||||
{
|
||||
//int ret = -1;
|
||||
@@ -159,7 +184,7 @@ int NetworkAgent::initialize_network_module(bool using_backup)
|
||||
|
||||
//first load the library
|
||||
#if defined(_MSC_VER) || defined(_WIN32)
|
||||
library = plugin_folder.string() + "/" + std::string(QIDI_NETWORK_LIBRARY) + ".dll";
|
||||
library = plugin_folder.string() + "\\" + std::string(QIDI_NETWORK_LIBRARY) + ".dll"; //1.9.5
|
||||
wchar_t lib_wstr[128];
|
||||
memset(lib_wstr, 0, sizeof(lib_wstr));
|
||||
::MultiByteToWideChar(CP_UTF8, NULL, library.c_str(), strlen(library.c_str())+1, lib_wstr, sizeof(lib_wstr) / sizeof(lib_wstr[0]));
|
||||
@@ -170,6 +195,20 @@ int NetworkAgent::initialize_network_module(bool using_backup)
|
||||
::MultiByteToWideChar(CP_UTF8, NULL, library.c_str(), strlen(library.c_str()) + 1, lib_wstr, sizeof(lib_wstr) / sizeof(lib_wstr[0]));
|
||||
netwoking_module = LoadLibrary(lib_wstr);
|
||||
}*/
|
||||
//1.9.5
|
||||
if (!netwoking_module) {
|
||||
BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << boost::format(", try load library directly from current directory");
|
||||
|
||||
std::string library_path = get_libpath_in_current_directory(std::string(QIDI_NETWORK_LIBRARY));
|
||||
if (library_path.empty()) {
|
||||
BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << boost::format(", can not get path in current directory for %1%") % QIDI_NETWORK_LIBRARY;
|
||||
return -1;
|
||||
}
|
||||
BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << boost::format(", current path %1%")%library_path;
|
||||
memset(lib_wstr, 0, sizeof(lib_wstr));
|
||||
::MultiByteToWideChar(CP_UTF8, NULL, library_path.c_str(), strlen(library_path.c_str())+1, lib_wstr, sizeof(lib_wstr) / sizeof(lib_wstr[0]));
|
||||
netwoking_module = LoadLibrary(lib_wstr);
|
||||
}
|
||||
#else
|
||||
#if defined(__WXMAC__)
|
||||
library = plugin_folder.string() + "/" + std::string("lib") + std::string(QIDI_NETWORK_LIBRARY) + ".dylib";
|
||||
@@ -298,7 +337,7 @@ int NetworkAgent::initialize_network_module(bool using_backup)
|
||||
get_model_mall_rating_result_ptr = reinterpret_cast<func_get_model_mall_rating_result>(get_network_function("qidi_network_get_model_mall_rating"));
|
||||
|
||||
get_mw_user_preference_ptr = reinterpret_cast<func_get_mw_user_preference>(get_network_function("qidi_network_get_mw_user_preference"));
|
||||
get_mw_user_4ulist_ptr = reinterpret_cast<func_get_mw_user_4ulist>(get_network_function("qidi_network_get_mw_user_4ulist"));
|
||||
get_mw_user_4ulist_ptr = reinterpret_cast<func_get_mw_user_4ulist>(get_network_function("qidi_network_get_mw_user_4ulist")); //1.9.5
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -446,12 +485,19 @@ void* NetworkAgent::get_qidi_source_entry()
|
||||
memset(lib_wstr, 0, sizeof(lib_wstr));
|
||||
::MultiByteToWideChar(CP_UTF8, NULL, library.c_str(), strlen(library.c_str())+1, lib_wstr, sizeof(lib_wstr) / sizeof(lib_wstr[0]));
|
||||
source_module = LoadLibrary(lib_wstr);
|
||||
/*if (!source_module) {
|
||||
library = std::string(QIDI_SOURCE_LIBRARY) + ".dll";
|
||||
//1.9.5
|
||||
if (!source_module) {
|
||||
BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << boost::format(", try load QIDISource directly from current directory");
|
||||
std::string library_path = get_libpath_in_current_directory(std::string(QIDI_SOURCE_LIBRARY));
|
||||
if (library_path.empty()) {
|
||||
BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << boost::format(", can not get path in current directory for %1%") % QIDI_SOURCE_LIBRARY;
|
||||
return source_module;
|
||||
}
|
||||
BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << boost::format(", current path %1%")%library_path;
|
||||
memset(lib_wstr, 0, sizeof(lib_wstr));
|
||||
::MultiByteToWideChar(CP_UTF8, NULL, library.c_str(), strlen(library.c_str()) + 1, lib_wstr, sizeof(lib_wstr) / sizeof(lib_wstr[0]));
|
||||
::MultiByteToWideChar(CP_UTF8, NULL, library_path.c_str(), strlen(library_path.c_str()) + 1, lib_wstr, sizeof(lib_wstr) / sizeof(lib_wstr[0])); //1.9.5
|
||||
source_module = LoadLibrary(lib_wstr);
|
||||
}*/
|
||||
}
|
||||
#else
|
||||
#if defined(__WXMAC__)
|
||||
library = plugin_folder.string() + "/" + std::string("lib") + std::string(QIDI_SOURCE_LIBRARY) + ".dylib";
|
||||
|
||||
@@ -115,6 +115,7 @@ class NetworkAgent
|
||||
{
|
||||
|
||||
public:
|
||||
static std::string get_libpath_in_current_directory(std::string library_name); //1.9.5
|
||||
static int initialize_network_module(bool using_backup = false);
|
||||
static int unload_network_module();
|
||||
#if defined(_MSC_VER) || defined(_WIN32)
|
||||
|
||||
@@ -1202,7 +1202,7 @@ void PresetUpdater::priv::check_installed_vendor_profiles() const
|
||||
bool version_match = ((resource_ver.maj() == vendor_ver.maj()) && (resource_ver.min() == vendor_ver.min()));
|
||||
|
||||
if (!version_match || (vendor_ver < resource_ver)) {
|
||||
BOOST_LOG_TRIVIAL(info) << "[QDT Updater]:found vendor "<<vendor_name<<" newer version "<<resource_ver.to_string() <<" from resource, old version "<<vendor_ver.to_string();
|
||||
BOOST_LOG_TRIVIAL(info) << "[QDT Updater]:found vendor "<<vendor_name<<" different version "<<resource_ver.to_string() <<" from resource, old version "<<vendor_ver.to_string()<<", will copy from resource";
|
||||
bundles.push_back(vendor_name);
|
||||
}
|
||||
}
|
||||
@@ -1257,7 +1257,7 @@ Updates PresetUpdater::priv::get_printer_config_updates(bool update) const
|
||||
bool version_match = ((resc_ver.maj() == curr_ver.maj()) && (resc_ver.min() == curr_ver.min()));
|
||||
|
||||
if (!version_match || (curr_ver < resc_ver)) {
|
||||
BOOST_LOG_TRIVIAL(info) << "[QDT Updater]:found newer version " << resc_version << " from resource, old version " << curr_version;
|
||||
BOOST_LOG_TRIVIAL(info) << "[QDT Updater]:found different version " << resc_version << " from resource, old version " << curr_version<<", will copy from resource";
|
||||
} else {
|
||||
return {};
|
||||
}
|
||||
|
||||
@@ -27,7 +27,8 @@ using boost::optional;
|
||||
using Slic3r::GUI::PrintHostQueueDialog;
|
||||
|
||||
namespace Slic3r {
|
||||
|
||||
//y36
|
||||
bool PrintHost::m_isStop = false;
|
||||
|
||||
PrintHost::~PrintHost() {}
|
||||
|
||||
@@ -95,7 +96,6 @@ std::string PrintHost::get_status(wxString &msg, const wxString &buttonText, con
|
||||
// Since the request is performed synchronously here,
|
||||
// it is ok to refer to `msg` from within the closure
|
||||
const std::string name = buttonText.ToStdString();
|
||||
|
||||
bool res = true;
|
||||
std::string print_state = "standby";
|
||||
std::string m_host = ip.ToStdString();
|
||||
@@ -105,7 +105,9 @@ std::string PrintHost::get_status(wxString &msg, const wxString &buttonText, con
|
||||
|
||||
auto http = Http::get(std::move(url));
|
||||
// set_auth(http);
|
||||
http.on_error([&](std::string body, std::string error, unsigned status) {
|
||||
//y36
|
||||
http.timeout_connect(4)
|
||||
.on_error([&](std::string body, std::string error, unsigned status) {
|
||||
BOOST_LOG_TRIVIAL(error) << boost::format("%1%: Error getting version: %2%, HTTP %3%, body: `%4%`") % name % error % status %
|
||||
body;
|
||||
print_state = "offline";
|
||||
@@ -166,7 +168,8 @@ float PrintHost::get_progress(wxString &msg, const wxString &buttonText, const w
|
||||
|
||||
auto http = Http::get(std::move(url));
|
||||
// set_auth(http);
|
||||
http.on_error([&](std::string body, std::string error, unsigned status) {
|
||||
http.timeout_connect(4)
|
||||
.on_error([&](std::string body, std::string error, unsigned status) {
|
||||
BOOST_LOG_TRIVIAL(error) << boost::format("%1%: Error getting version: %2%, HTTP %3%, body: `%4%`") % name % error % status %
|
||||
body;
|
||||
res = false;
|
||||
|
||||
@@ -72,6 +72,10 @@ public:
|
||||
virtual bool get_storage(wxArrayString& /*storage_path*/, wxArrayString& /*storage_name*/) const { return false; }
|
||||
static PrintHost *get_print_host_url(std::string url, std::string local_ip);
|
||||
static PrintHost* get_print_host(DynamicPrintConfig *config);
|
||||
//y36
|
||||
static void SetStop(bool isStop) { m_isStop = isStop; };
|
||||
static bool GetStop() { return m_isStop; };
|
||||
static bool m_isStop;
|
||||
|
||||
protected:
|
||||
virtual wxString format_error(const std::string &body, const std::string &error, unsigned status) const;
|
||||
|
||||
Reference in New Issue
Block a user