diff --git a/deps_src/nlohmann/CMakeLists.txt b/deps_src/nlohmann/CMakeLists.txt index 5fb42165a3..c30ac1e4ca 100644 --- a/deps_src/nlohmann/CMakeLists.txt +++ b/deps_src/nlohmann/CMakeLists.txt @@ -6,7 +6,7 @@ add_library(nlohmann_json INTERFACE) target_include_directories(nlohmann_json SYSTEM INTERFACE - ${CMAKE_CURRENT_SOURCE_DIR} + ${CMAKE_CURRENT_SOURCE_DIR}/.. ) target_sources(nlohmann_json INTERFACE diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 4d0ea05baa..ac01610264 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -115,9 +115,9 @@ configure_file(${CMAKE_CURRENT_SOURCE_DIR}/dev-utils/platform/msw/Snapmaker_Orca configure_file(${CMAKE_CURRENT_SOURCE_DIR}/dev-utils/platform/msw/Snapmaker_Orca.manifest.in ${CMAKE_CURRENT_BINARY_DIR}/Snapmaker_Orca.manifest @ONLY) configure_file(${CMAKE_CURRENT_SOURCE_DIR}/dev-utils/platform/osx/Info.plist.in ${CMAKE_CURRENT_BINARY_DIR}/Info.plist @ONLY) if (WIN32) - add_library(Snapmaker_Orca SHARED Snapmaker_Orca.cpp Snapmaker_Orca.hpp dev-utils/BaseException.cpp dev-utils/BaseException.h dev-utils/StackWalker.cpp dev-utils/StackWalker.h sentry_wrapper/SentryWrapper.hpp sentry_wrapper/SentryWrapper.cpp bury_cfg/bury_point.hpp bury_cfg/bury_point.cpp) + add_library(Snapmaker_Orca SHARED Snapmaker_Orca.cpp Snapmaker_Orca.hpp dev-utils/BaseException.cpp dev-utils/BaseException.h dev-utils/StackWalker.cpp dev-utils/StackWalker.h sentry_wrapper/SentryWrapper.hpp sentry_wrapper/SentryWrapper.cpp bury_cfg/bury_point.hpp bury_cfg/bury_point.cpp common_func/common_func.hpp common_func/common_func.cpp) else () - add_executable(Snapmaker_Orca Snapmaker_Orca.cpp Snapmaker_Orca.hpp sentry_wrapper/SentryWrapper.hpp sentry_wrapper/SentryWrapper.cpp bury_cfg/bury_point.hpp bury_cfg/bury_point.cpp) + add_executable(Snapmaker_Orca Snapmaker_Orca.cpp Snapmaker_Orca.hpp sentry_wrapper/SentryWrapper.hpp sentry_wrapper/SentryWrapper.cpp bury_cfg/bury_point.hpp bury_cfg/bury_point.cpp common_func/common_func.hpp common_func/common_func.cpp) endif () if (MINGW) @@ -181,7 +181,7 @@ if (WIN32) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -municode") endif() - add_executable(Snapmaker_Orca_app_gui WIN32 Snapmaker_Orca_app_msvc.cpp sentry_wrapper/SentryWrapper.cpp bury_cfg/bury_point.cpp ${CMAKE_CURRENT_BINARY_DIR}/Snapmaker_Orca.rc) + add_executable(Snapmaker_Orca_app_gui WIN32 Snapmaker_Orca_app_msvc.cpp sentry_wrapper/SentryWrapper.cpp bury_cfg/bury_point.cpp common_func/common_func.cpp ${CMAKE_CURRENT_BINARY_DIR}/Snapmaker_Orca.rc) # Generate debug symbols even in release mode. if(MSVC) target_link_options(Snapmaker_Orca_app_gui PUBLIC "$<$:/DEBUG>") @@ -190,9 +190,9 @@ if (WIN32) add_dependencies(Snapmaker_Orca_app_gui Snapmaker_Orca) set_target_properties(Snapmaker_Orca_app_gui PROPERTIES OUTPUT_NAME "snapmaker-orca") if (SLIC3R_SENTRY) - target_link_libraries(Snapmaker_Orca_app_gui PRIVATE boost_headeronly sentry::sentry) + target_link_libraries(Snapmaker_Orca_app_gui PRIVATE boost_headeronly sentry::sentry nlohmann_json) else() - target_link_libraries(Snapmaker_Orca_app_gui PRIVATE boost_headeronly) + target_link_libraries(Snapmaker_Orca_app_gui PRIVATE boost_headeronly nlohmann_json) endif() if (SLIC3R_SENTRY) target_compile_definitions(Snapmaker_Orca_app_gui PRIVATE SLIC3R_SENTRY) diff --git a/src/common_func/common_func.cpp b/src/common_func/common_func.cpp new file mode 100644 index 0000000000..c2c7060fb4 --- /dev/null +++ b/src/common_func/common_func.cpp @@ -0,0 +1,59 @@ +#include "common_func.hpp" +#include + +#ifdef _WIN32 +#include +#include + +#elif __APPLE__ +#include +#endif + +#include +#include + +namespace common +{ + std::string get_pc_name() + { + return boost::asio::ip::host_name(); + } + + std::string get_flutter_version() + { + + std::string versionFilePath = ""; + +#ifdef _WIN32 + wchar_t appDataPath[MAX_PATH] = {0}; + auto hr = SHGetFolderPathW(NULL, CSIDL_APPDATA, NULL, SHGFP_TYPE_CURRENT, appDataPath); + char* path = new char[MAX_PATH]; + size_t pathLength; + wcstombs_s(&pathLength, path, MAX_PATH, appDataPath, MAX_PATH); + std::string filePath = path; + versionFilePath = filePath + "\\" + std::string("Snapmaker_Orca\\web\\flutter_web\\version.json"); +#elif __APPLE__ + const char* home_env = getenv("HOME"); + versionFilePath = home_env; + versionFilePath = versionFilePath + "/Library/Application Support/Snapmaker_Orca/web/flutter_web/version.json"; +#else + +#endif + + std::ifstream json_file(versionFilePath); + if (!json_file.is_open()) { + std::ifstream json_file(versionFilePath); + return ""; + } + nlohmann::json json_data; + json_file >> json_data; + std::string str_version = json_data["version"]; + std::string str_build_number = json_data["build_number"]; + + std::string flutter_version = std::string("flutter_version: ") + str_version + std::string(" ") + std::string("build_number: ") + + str_build_number; + + return flutter_version; + } + +} \ No newline at end of file diff --git a/src/common_func/common_func.hpp b/src/common_func/common_func.hpp new file mode 100644 index 0000000000..919e234fee --- /dev/null +++ b/src/common_func/common_func.hpp @@ -0,0 +1,27 @@ +#ifndef _common_func_hppp_ +#define _common_func_hppp_ +#include + + +#define SLIC3R_APP_NAME "Snapmaker Orca" +#define SLIC3R_APP_KEY "Snapmaker_Orca" +#define SLIC3R_VERSION "01.10.01.50" +#define Snapmaker_VERSION "2.2.0" +#define MIN_FIRM_VER "0.8.4" +#ifndef GIT_COMMIT_HASH +#define GIT_COMMIT_HASH "0000000" // 0000000 means uninitialized +#endif +#define SLIC3R_BUILD_ID "" +// #define SLIC3R_RC_VERSION "01.10.01.50" +#define BBL_RELEASE_TO_PUBLIC 1 +#define BBL_INTERNAL_TESTING 0 +#define ORCA_CHECK_GCODE_PLACEHOLDERS 0 + +namespace common +{ + std::string get_pc_name(); + + std::string get_flutter_version(); +} // namespace common + +#endif \ No newline at end of file diff --git a/src/libslic3r/PresetBundle.cpp b/src/libslic3r/PresetBundle.cpp index 79071cc061..407b6bf740 100644 --- a/src/libslic3r/PresetBundle.cpp +++ b/src/libslic3r/PresetBundle.cpp @@ -6,7 +6,7 @@ #include "Utils.hpp" #include "Model.hpp" #include "format.hpp" -#include "libslic3r_version.h" +#include "common_func/common_func.hpp" #include #include diff --git a/src/libslic3r/libslic3r.h b/src/libslic3r/libslic3r.h index 0364ac340e..8d0f779129 100644 --- a/src/libslic3r/libslic3r.h +++ b/src/libslic3r/libslic3r.h @@ -1,7 +1,7 @@ #ifndef _libslic3r_h_ #define _libslic3r_h_ -#include "libslic3r_version.h" +#include "common_func/common_func.hpp" #define SLIC3R_APP_FULL_NAME "Snapmaker Orca" #define GCODEVIEWER_APP_NAME "Snapmaker_Orca G-code Viewer" #define GCODEVIEWER_APP_KEY "Snapmaker_OrcaGcodeViewer" diff --git a/src/libslic3r/pchheader.hpp b/src/libslic3r/pchheader.hpp index 1bedfb482a..cc93b3b220 100644 --- a/src/libslic3r/pchheader.hpp +++ b/src/libslic3r/pchheader.hpp @@ -125,7 +125,7 @@ #include "SVG.hpp" #include "libslic3r.h" -#include "libslic3r_version.h" +#include "common_func/common_func.hpp" #include diff --git a/src/sentry_wrapper/SentryWrapper.cpp b/src/sentry_wrapper/SentryWrapper.cpp index 25982b9d46..6f72348634 100644 --- a/src/sentry_wrapper/SentryWrapper.cpp +++ b/src/sentry_wrapper/SentryWrapper.cpp @@ -27,6 +27,7 @@ #include #include #include +#include "common_func/common_func.hpp" namespace Slic3r { @@ -193,6 +194,7 @@ void initSentryEx() #endif sentry_options_set_environment(options, "develop"); + //sentry_options_set_environment(options, "Release"); sentry_options_set_auto_session_tracking(options, 0); sentry_options_set_symbolize_stacktraces(options, 1); @@ -202,6 +204,12 @@ void initSentryEx() sentry_options_set_sample_rate(options, 1.0); sentry_options_set_traces_sample_rate(options, 1.0); + sentry_set_tag("version", Snapmaker_VERSION); + + std::string flutterVersion = common::get_flutter_version(); + if (!flutterVersion.empty()) + set_sentry_tags("flutter_version", flutterVersion); + sentry_init(options); sentry_start_session(); diff --git a/src/slic3r/GUI/CreatePresetsDialog.cpp b/src/slic3r/GUI/CreatePresetsDialog.cpp index 36d572e1b9..78e14f1bed 100644 --- a/src/slic3r/GUI/CreatePresetsDialog.cpp +++ b/src/slic3r/GUI/CreatePresetsDialog.cpp @@ -16,7 +16,7 @@ #include "FileHelp.hpp" #include "Tab.hpp" #include "MainFrame.hpp" -#include "libslic3r_version.h" +#include "common_func/common_func.hpp" #define NAME_OPTION_COMBOBOX_SIZE wxSize(FromDIP(200), FromDIP(24)) #define FILAMENT_PRESET_COMBOBOX_SIZE wxSize(FromDIP(300), FromDIP(24)) diff --git a/src/slic3r/GUI/GUI_App.cpp b/src/slic3r/GUI/GUI_App.cpp index 06f24b848f..a7fe3e4a8d 100644 --- a/src/slic3r/GUI/GUI_App.cpp +++ b/src/slic3r/GUI/GUI_App.cpp @@ -6,7 +6,7 @@ #include "slic3r/GUI/UserManager.hpp" #include "slic3r/GUI/TaskManager.hpp" #include "format.hpp" -#include "libslic3r_version.h" +#include "common_func/common_func.hpp" #include "Downloader.hpp" #include "slic3r/GUI/WebUrlDialog.hpp" diff --git a/src/slic3r/GUI/MainFrame.cpp b/src/slic3r/GUI/MainFrame.cpp index 7120e6ef86..f6e67d1c0a 100644 --- a/src/slic3r/GUI/MainFrame.cpp +++ b/src/slic3r/GUI/MainFrame.cpp @@ -72,9 +72,9 @@ #include #include #include -#include "sentry_wrapper/SentryWrapper.hpp" #endif // _WIN32 #include +#include "sentry_wrapper/SentryWrapper.hpp" namespace Slic3r { @@ -1008,41 +1008,6 @@ void MainFrame::show_option(bool show) } } } -void MainFrame::get_local_webview_version() -{ - std::string versionFilePath = ""; - -#ifdef _WIN32 - wchar_t appDataPath[MAX_PATH] = {0}; - auto hr = SHGetFolderPathW(NULL, CSIDL_APPDATA, NULL, SHGFP_TYPE_CURRENT, appDataPath); - char* path = new char[MAX_PATH]; - size_t pathLength; - wcstombs_s(&pathLength, path, MAX_PATH, appDataPath, MAX_PATH); - std::string filePath = path; - versionFilePath = filePath + "\\" + std::string("Snapmaker_Orca\\web\\flutter_web\\version.json"); -#elif __APPLE__ - const char* home_env = getenv("HOME"); - versionFilePath = home_env; - versionFilePath = versionFilePath + "/Library/Application Support/Snapmaker_Orca/web/flutter_web/version.json"; -#else - -#endif - - std::ifstream json_file(versionFilePath); - if (!json_file.is_open()) { - std::ifstream json_file(versionFilePath); - BOOST_LOG_TRIVIAL(error) << "check flutter version error with file path:" << versionFilePath; - return; - } - nlohmann::json json_data; - json_file >> json_data; - std::string str_version = json_data["version"]; - std::string str_build_number = json_data["build_number"]; - - std::string tag = std::string("flutter_version: ") + str_version + std::string(" ") + std::string("build_number: ") + str_build_number; - set_sentry_tags("flutter_version", tag); - -} void MainFrame::init_tabpanel() { // wxNB_NOPAGETHEME: Disable Windows Vista theme for the Notebook background. The theme performance is terrible on @@ -1126,7 +1091,6 @@ void MainFrame::init_tabpanel() { m_param_panel = new ParamsPanel(m_tabpanel, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxBK_LEFT | wxTAB_TRAVERSAL); } - get_local_webview_version(); m_plater = new Plater(this, this); m_plater->SetBackgroundColour(*wxWHITE); m_plater->Hide(); diff --git a/src/slic3r/GUI/MainFrame.hpp b/src/slic3r/GUI/MainFrame.hpp index a3889ad91a..1bf719f73f 100644 --- a/src/slic3r/GUI/MainFrame.hpp +++ b/src/slic3r/GUI/MainFrame.hpp @@ -264,7 +264,6 @@ public: void update_title_colour_after_set_title(); void show_option(bool show); void init_tabpanel(); - void get_local_webview_version(); void create_preset_tabs(); //BBS: GUI refactor void add_created_tab(Tab* panel, const std::string& bmp_name = ""); diff --git a/src/slic3r/GUI/Plater.cpp b/src/slic3r/GUI/Plater.cpp index 69bcb84a26..edfeabd849 100644 --- a/src/slic3r/GUI/Plater.cpp +++ b/src/slic3r/GUI/Plater.cpp @@ -1,6 +1,6 @@ #include "Plater.hpp" #include "libslic3r/Config.hpp" -#include "libslic3r_version.h" +#include "common_func/common_func.hpp" #include #include diff --git a/src/slic3r/GUI/PrinterWebView.cpp b/src/slic3r/GUI/PrinterWebView.cpp index 322eb642a6..4a8c42edc6 100644 --- a/src/slic3r/GUI/PrinterWebView.cpp +++ b/src/slic3r/GUI/PrinterWebView.cpp @@ -5,7 +5,7 @@ #include "slic3r/GUI/wxExtensions.hpp" #include "slic3r/GUI/GUI_App.hpp" #include "slic3r/GUI/MainFrame.hpp" -#include "libslic3r_version.h" +#include "common_func/common_func.hpp" #include #include diff --git a/src/slic3r/GUI/SSWCP.cpp b/src/slic3r/GUI/SSWCP.cpp index c89aeeb758..6555fd53c8 100644 --- a/src/slic3r/GUI/SSWCP.cpp +++ b/src/slic3r/GUI/SSWCP.cpp @@ -91,7 +91,6 @@ bool WCP_Logger::set_level(wxString& level) } } -std::string WCP_Logger::get_pc_name() { return boost::asio::ip::host_name(); } // Add a log message to the queue void WCP_Logger::add_log(const wxString& content, bool is_web = false, wxString time = "", wxString module = "Default", wxString level = "debug") diff --git a/src/slic3r/GUI/WebDownPluginDlg.cpp b/src/slic3r/GUI/WebDownPluginDlg.cpp index 93a1a5959c..a1141ab48c 100644 --- a/src/slic3r/GUI/WebDownPluginDlg.cpp +++ b/src/slic3r/GUI/WebDownPluginDlg.cpp @@ -6,7 +6,7 @@ #include "libslic3r/AppConfig.hpp" #include "slic3r/GUI/wxExtensions.hpp" #include "slic3r/GUI/GUI_App.hpp" -#include "libslic3r_version.h" +#include "common_func/common_func.hpp" #include #include diff --git a/src/slic3r/GUI/WebGuideDialog.cpp b/src/slic3r/GUI/WebGuideDialog.cpp index 97fae75977..e30c1a6506 100644 --- a/src/slic3r/GUI/WebGuideDialog.cpp +++ b/src/slic3r/GUI/WebGuideDialog.cpp @@ -10,7 +10,7 @@ #include "libslic3r/PresetBundle.hpp" #include "slic3r/GUI/wxExtensions.hpp" #include "slic3r/GUI/GUI_App.hpp" -#include "libslic3r_version.h" +#include "common_func/common_func.hpp" #include #include diff --git a/src/slic3r/GUI/WebPresetDialog.cpp b/src/slic3r/GUI/WebPresetDialog.cpp index bbd45a1745..0f7771699a 100644 --- a/src/slic3r/GUI/WebPresetDialog.cpp +++ b/src/slic3r/GUI/WebPresetDialog.cpp @@ -6,7 +6,7 @@ #include "libslic3r/AppConfig.hpp" #include "slic3r/GUI/wxExtensions.hpp" #include "slic3r/GUI/GUI_App.hpp" -#include "libslic3r_version.h" +#include "common_func/common_func.hpp" #include #include diff --git a/src/slic3r/GUI/WebSMUserLoginDialog.cpp b/src/slic3r/GUI/WebSMUserLoginDialog.cpp index 2092f0d812..99773e3eb1 100644 --- a/src/slic3r/GUI/WebSMUserLoginDialog.cpp +++ b/src/slic3r/GUI/WebSMUserLoginDialog.cpp @@ -5,7 +5,7 @@ #include "libslic3r/AppConfig.hpp" #include "slic3r/GUI/wxExtensions.hpp" #include "slic3r/GUI/GUI_App.hpp" -#include "libslic3r_version.h" +#include "common_func/common_func.hpp" #include #include diff --git a/src/slic3r/GUI/WebUserLoginDialog.cpp b/src/slic3r/GUI/WebUserLoginDialog.cpp index 8bffe3e08b..5afc43568a 100644 --- a/src/slic3r/GUI/WebUserLoginDialog.cpp +++ b/src/slic3r/GUI/WebUserLoginDialog.cpp @@ -5,7 +5,7 @@ #include "libslic3r/AppConfig.hpp" #include "slic3r/GUI/wxExtensions.hpp" #include "slic3r/GUI/GUI_App.hpp" -#include "libslic3r_version.h" +#include "common_func/common_func.hpp" #include #include diff --git a/src/slic3r/GUI/WebViewDialog.cpp b/src/slic3r/GUI/WebViewDialog.cpp index a7f9b4801f..98aa42af2a 100644 --- a/src/slic3r/GUI/WebViewDialog.cpp +++ b/src/slic3r/GUI/WebViewDialog.cpp @@ -4,7 +4,7 @@ #include "slic3r/GUI/wxExtensions.hpp" #include "slic3r/GUI/GUI_App.hpp" #include "slic3r/GUI/MainFrame.hpp" -#include "libslic3r_version.h" +#include "common_func/common_func.hpp" #include "../Utils/Http.hpp" #include "SSWCP.hpp" diff --git a/src/slic3r/Utils/Http.hpp b/src/slic3r/Utils/Http.hpp index ef31a1127e..7b2c05b908 100644 --- a/src/slic3r/Utils/Http.hpp +++ b/src/slic3r/Utils/Http.hpp @@ -9,7 +9,7 @@ #include #include "libslic3r/Exception.hpp" -#include "libslic3r_version.h" +#include "common_func/common_func.hpp" #define MAX_SIZE_TO_FILE 3*1024 diff --git a/src/slic3r/Utils/PresetUpdater.cpp b/src/slic3r/Utils/PresetUpdater.cpp index c9f2de7517..b1321a2689 100644 --- a/src/slic3r/Utils/PresetUpdater.cpp +++ b/src/slic3r/Utils/PresetUpdater.cpp @@ -25,7 +25,7 @@ #include "libslic3r/format.hpp" #include "libslic3r/Utils.hpp" #include "libslic3r/PresetBundle.hpp" -#include "libslic3r_version.h" +#include "common_func/common_func.hpp" #include "slic3r/GUI/GUI.hpp" #include "slic3r/GUI/GUI_App.hpp" #include "slic3r/GUI/I18N.hpp"