diff --git a/common/CMakeLists.txt b/common/CMakeLists.txt
index 947909576b..31934fa439 100644
--- a/common/CMakeLists.txt
+++ b/common/CMakeLists.txt
@@ -56,8 +56,7 @@ add_custom_target(
add_library( singletop STATIC EXCLUDE_FROM_ALL
eda_doc.cpp
kiway.cpp
- kiway_holder.cpp
- )
+ kiway_holder.cpp )
# A shared library used by multiple *.kiface files and one or two program
@@ -265,6 +264,8 @@ set( COMMON_DLG_SRCS
dialogs/panel_grid_settings_base.cpp
dialogs/panel_mouse_settings.cpp
dialogs/panel_mouse_settings_base.cpp
+ dialogs/panel_packages_and_updates.cpp
+ dialogs/panel_packages_and_updates_base.cpp
dialogs/panel_setup_netclasses.cpp
dialogs/panel_setup_netclasses_base.cpp
dialogs/panel_setup_severities.cpp
@@ -618,7 +619,6 @@ target_link_libraries( common
nlohmann_json
pybind11::embed
compoundfilereader
- pcm_settings
Boost::headers
# Database support needs these two
nanodbc # for now; maybe hoist out of common
diff --git a/common/dialogs/panel_common_settings_base.cpp b/common/dialogs/panel_common_settings_base.cpp
index 1696e70491..e25f64ca40 100644
--- a/common/dialogs/panel_common_settings_base.cpp
+++ b/common/dialogs/panel_common_settings_base.cpp
@@ -292,13 +292,35 @@ PANEL_COMMON_SETTINGS_BASE::PANEL_COMMON_SETTINGS_BASE( wxWindow* parent, wxWind
rightSizer->Add( 0, 15, 0, wxEXPAND, 5 );
- m_staticText24 = new wxStaticText( this, wxID_ANY, _("Session"), wxDefaultPosition, wxDefaultSize, 0 );
+ m_staticText24 = new wxStaticText( this, wxID_ANY, _("Update Check"), wxDefaultPosition, wxDefaultSize, 0 );
m_staticText24->Wrap( -1 );
rightSizer->Add( m_staticText24, 0, wxEXPAND|wxTOP|wxRIGHT|wxLEFT, 13 );
m_staticline5 = new wxStaticLine( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxLI_HORIZONTAL );
rightSizer->Add( m_staticline5, 0, wxEXPAND|wxBOTTOM, 5 );
+ wxBoxSizer* bUpdateSizer;
+ bUpdateSizer = new wxBoxSizer( wxVERTICAL );
+
+ m_cbUpdateCheck = new wxCheckBox( this, wxID_ANY, _("Check for KiCad updates on launch"), wxDefaultPosition, wxDefaultSize, 0 );
+ m_cbUpdateCheck->SetValue(true);
+ m_cbUpdateCheck->SetToolTip( _("If checked, launching a project will also launch tools such as the schematic and board editors with previously open files") );
+
+ bUpdateSizer->Add( m_cbUpdateCheck, 0, wxALL, 5 );
+
+
+ rightSizer->Add( bUpdateSizer, 0, wxEXPAND|wxLEFT|wxTOP, 5 );
+
+
+ rightSizer->Add( 0, 15, 0, wxEXPAND, 5 );
+
+ m_staticText241 = new wxStaticText( this, wxID_ANY, _("Session"), wxDefaultPosition, wxDefaultSize, 0 );
+ m_staticText241->Wrap( -1 );
+ rightSizer->Add( m_staticText241, 0, wxLEFT|wxRIGHT|wxTOP, 13 );
+
+ m_staticline51 = new wxStaticLine( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxLI_HORIZONTAL );
+ rightSizer->Add( m_staticline51, 0, wxBOTTOM|wxEXPAND, 5 );
+
wxBoxSizer* bSessionSizer;
bSessionSizer = new wxBoxSizer( wxVERTICAL );
diff --git a/common/dialogs/panel_common_settings_base.fbp b/common/dialogs/panel_common_settings_base.fbp
index 0ac075ada3..548f7bd6fb 100644
--- a/common/dialogs/panel_common_settings_base.fbp
+++ b/common/dialogs/panel_common_settings_base.fbp
@@ -2919,7 +2919,7 @@
0
0
wxID_ANY
- Session
+ Update Check
0
0
@@ -3006,6 +3006,210 @@
+
+
+ 5
+ wxEXPAND
+ 0
+
+ 15
+ protected
+ 0
+
+
+
+ 13
+ wxLEFT|wxRIGHT|wxTOP
+ 0
+
+ 1
+ 1
+ 1
+ 1
+
+
+
+
+
+
+
+ 1
+ 0
+ 1
+
+ 1
+ 0
+ Dock
+ 0
+ Left
+ 1
+
+ 1
+
+ 0
+ 0
+ wxID_ANY
+ Session
+ 0
+
+ 0
+
+
+ 0
+
+ 1
+ m_staticText241
+ 1
+
+
+ protected
+ 1
+
+ Resizable
+ 1
+
+
+ ; ; forward_declare
+ 0
+
+
+
+
+ -1
+
+
+
+ 5
+ wxBOTTOM|wxEXPAND
+ 0
+
+ 1
+ 1
+ 1
+ 1
+
+
+
+
+
+
+
+ 1
+ 0
+ 1
+
+ 1
+ 0
+ Dock
+ 0
+ Left
+ 1
+
+ 1
+
+ 0
+ 0
+ wxID_ANY
+
+ 0
+
+
+ 0
+
+ 1
+ m_staticline51
+ 1
+
+
+ protected
+ 1
+
+ Resizable
+ 1
+
+ wxLI_HORIZONTAL
+ ; ; forward_declare
+ 0
+
+
+
+
+
+
5
wxTOP|wxLEFT|wxEXPAND
diff --git a/common/dialogs/panel_common_settings_base.h b/common/dialogs/panel_common_settings_base.h
index 6a1aca6e9f..43d655525e 100644
--- a/common/dialogs/panel_common_settings_base.h
+++ b/common/dialogs/panel_common_settings_base.h
@@ -86,6 +86,9 @@ class PANEL_COMMON_SETTINGS_BASE : public RESETTABLE_PANEL
wxCheckBox* m_NonImmediateActions;
wxStaticText* m_staticText24;
wxStaticLine* m_staticline5;
+ wxCheckBox* m_cbUpdateCheck;
+ wxStaticText* m_staticText241;
+ wxStaticLine* m_staticline51;
wxCheckBox* m_cbRememberOpenFiles;
wxStaticText* m_staticTextautosave;
wxSpinCtrl* m_SaveTime;
diff --git a/kicad/pcm/dialogs/panel_pcm_settings.cpp b/common/dialogs/panel_packages_and_updates.cpp
similarity index 80%
rename from kicad/pcm/dialogs/panel_pcm_settings.cpp
rename to common/dialogs/panel_packages_and_updates.cpp
index 45ea0a63a1..0bf2062f7f 100644
--- a/kicad/pcm/dialogs/panel_pcm_settings.cpp
+++ b/common/dialogs/panel_packages_and_updates.cpp
@@ -22,14 +22,15 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
-#include "panel_pcm_settings.h"
+#include "panel_packages_and_updates.h"
#include
#include
#include
#include
-PANEL_PCM_SETTINGS::PANEL_PCM_SETTINGS( wxWindow* parent ) : PANEL_PCM_SETTINGS_BASE( parent )
+PANEL_PACKAGES_AND_UPDATES::PANEL_PACKAGES_AND_UPDATES( wxWindow* parent ) :
+ PANEL_PACKAGES_AND_UPDATES_BASE( parent )
{
wxSize minSize = m_libPrefix->GetMinSize();
int minWidth = m_libPrefix->GetTextExtent( wxT( "XXX.XXX" ) ).GetWidth();
@@ -38,12 +39,13 @@ PANEL_PCM_SETTINGS::PANEL_PCM_SETTINGS( wxWindow* parent ) : PANEL_PCM_SETTINGS_
}
-bool PANEL_PCM_SETTINGS::TransferDataToWindow()
+bool PANEL_PACKAGES_AND_UPDATES::TransferDataToWindow()
{
SETTINGS_MANAGER& mgr = Pgm().GetSettingsManager();
KICAD_SETTINGS* settings = mgr.GetAppSettings();
- m_updateCheck->SetValue( settings->m_PcmUpdateCheck );
+ m_cbKicadUpdate->SetValue( settings->m_KiCadUpdateCheck );
+ m_cbPcmUpdate->SetValue( settings->m_PcmUpdateCheck );
m_libAutoAdd->SetValue( settings->m_PcmLibAutoAdd );
m_libAutoRemove->SetValue( settings->m_PcmLibAutoRemove );
m_libPrefix->SetValue( settings->m_PcmLibPrefix );
@@ -52,12 +54,13 @@ bool PANEL_PCM_SETTINGS::TransferDataToWindow()
}
-bool PANEL_PCM_SETTINGS::TransferDataFromWindow()
+bool PANEL_PACKAGES_AND_UPDATES::TransferDataFromWindow()
{
SETTINGS_MANAGER& mgr = Pgm().GetSettingsManager();
KICAD_SETTINGS* settings = mgr.GetAppSettings();
- settings->m_PcmUpdateCheck = m_updateCheck->GetValue();
+ settings->m_KiCadUpdateCheck = m_cbKicadUpdate->GetValue();
+ settings->m_PcmUpdateCheck = m_cbPcmUpdate->GetValue();
settings->m_PcmLibAutoAdd = m_libAutoAdd->GetValue();
settings->m_PcmLibAutoRemove = m_libAutoRemove->GetValue();
settings->m_PcmLibPrefix = m_libPrefix->GetValue();
diff --git a/kicad/pcm/dialogs/panel_pcm_settings.h b/common/dialogs/panel_packages_and_updates.h
similarity index 80%
rename from kicad/pcm/dialogs/panel_pcm_settings.h
rename to common/dialogs/panel_packages_and_updates.h
index 7dcc50e093..cbf7647fe9 100644
--- a/kicad/pcm/dialogs/panel_pcm_settings.h
+++ b/common/dialogs/panel_packages_and_updates.h
@@ -22,18 +22,18 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
-#ifndef PANEL_PCM_SETTINGS_H_
-#define PANEL_PCM_SETTINGS_H_
+#ifndef PANEL_PACKAGES_AND_SETTINGS_H_
+#define PANEL_PACKAGES_AND_SETTINGS_H_
-#include "panel_pcm_settings_base.h"
+#include "panel_packages_and_updates_base.h"
-class PANEL_PCM_SETTINGS : public PANEL_PCM_SETTINGS_BASE
+class PANEL_PACKAGES_AND_UPDATES : public PANEL_PACKAGES_AND_UPDATES_BASE
{
public:
- PANEL_PCM_SETTINGS( wxWindow* parent );
+ PANEL_PACKAGES_AND_UPDATES( wxWindow* parent );
bool TransferDataToWindow() override;
bool TransferDataFromWindow() override;
};
-#endif // PANEL_PCM_SETTINGS_H_
+#endif // PANEL_PACKAGES_AND_SETTINGS_H_
diff --git a/kicad/pcm/dialogs/panel_pcm_settings_base.cpp b/common/dialogs/panel_packages_and_updates_base.cpp
similarity index 64%
rename from kicad/pcm/dialogs/panel_pcm_settings_base.cpp
rename to common/dialogs/panel_packages_and_updates_base.cpp
index 472d0dae46..4dcb6af781 100644
--- a/kicad/pcm/dialogs/panel_pcm_settings_base.cpp
+++ b/common/dialogs/panel_packages_and_updates_base.cpp
@@ -5,18 +5,41 @@
// PLEASE DO *NOT* EDIT THIS FILE!
///////////////////////////////////////////////////////////////////////////
-#include "panel_pcm_settings_base.h"
+#include "panel_packages_and_updates_base.h"
///////////////////////////////////////////////////////////////////////////
-PANEL_PCM_SETTINGS_BASE::PANEL_PCM_SETTINGS_BASE( wxWindow* parent, wxWindowID id, const wxPoint& pos, const wxSize& size, long style, const wxString& name ) : wxPanel( parent, id, pos, size, style, name )
+PANEL_PACKAGES_AND_UPDATES_BASE::PANEL_PACKAGES_AND_UPDATES_BASE( wxWindow* parent, wxWindowID id, const wxPoint& pos, const wxSize& size, long style, const wxString& name ) : wxPanel( parent, id, pos, size, style, name )
{
wxBoxSizer* bSizer1;
bSizer1 = new wxBoxSizer( wxVERTICAL );
m_generalLabel = new wxStaticText( this, wxID_ANY, _("General"), wxDefaultPosition, wxDefaultSize, 0 );
m_generalLabel->Wrap( -1 );
- bSizer1->Add( m_generalLabel, 0, wxTOP|wxRIGHT|wxLEFT, 13 );
+ bSizer1->Add( m_generalLabel, 0, wxLEFT|wxRIGHT|wxTOP, 13 );
+
+
+ bSizer1->Add( 0, 0, 0, wxEXPAND, 5 );
+
+ m_staticline3 = new wxStaticLine( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxLI_HORIZONTAL );
+ bSizer1->Add( m_staticline3, 0, wxEXPAND | wxALL, 5 );
+
+ wxBoxSizer* bSizer41;
+ bSizer41 = new wxBoxSizer( wxVERTICAL );
+
+ m_cbKicadUpdate = new wxCheckBox( this, wxID_ANY, _("Check for KiCad updates on startup"), wxDefaultPosition, wxDefaultSize, 0 );
+ m_cbKicadUpdate->SetValue(true);
+ bSizer41->Add( m_cbKicadUpdate, 0, wxLEFT, 5 );
+
+
+ bSizer1->Add( bSizer41, 0, wxEXPAND|wxLEFT|wxTOP, 5 );
+
+
+ bSizer1->Add( 0, 20, 0, wxEXPAND, 5 );
+
+ m_pcmLabel = new wxStaticText( this, wxID_ANY, _("Plugin and Content Manager"), wxDefaultPosition, wxDefaultSize, 0 );
+ m_pcmLabel->Wrap( -1 );
+ bSizer1->Add( m_pcmLabel, 0, wxTOP|wxRIGHT|wxLEFT, 13 );
bSizer1->Add( 0, 3, 0, wxEXPAND, 5 );
@@ -27,9 +50,9 @@ PANEL_PCM_SETTINGS_BASE::PANEL_PCM_SETTINGS_BASE( wxWindow* parent, wxWindowID i
wxBoxSizer* bSizer4;
bSizer4 = new wxBoxSizer( wxVERTICAL );
- m_updateCheck = new wxCheckBox( this, wxID_ANY, _("Check for package updates on startup"), wxDefaultPosition, wxDefaultSize, 0 );
- m_updateCheck->SetValue(true);
- bSizer4->Add( m_updateCheck, 0, wxLEFT, 5 );
+ m_cbPcmUpdate = new wxCheckBox( this, wxID_ANY, _("Check for package updates on startup"), wxDefaultPosition, wxDefaultSize, 0 );
+ m_cbPcmUpdate->SetValue(true);
+ bSizer4->Add( m_cbPcmUpdate, 0, wxLEFT, 5 );
bSizer1->Add( bSizer4, 0, wxEXPAND|wxTOP|wxLEFT, 5 );
@@ -39,7 +62,7 @@ PANEL_PCM_SETTINGS_BASE::PANEL_PCM_SETTINGS_BASE( wxWindow* parent, wxWindowID i
m_staticText4 = new wxStaticText( this, wxID_ANY, _("Library package handling"), wxDefaultPosition, wxDefaultSize, 0 );
m_staticText4->Wrap( -1 );
- bSizer1->Add( m_staticText4, 0, wxTOP|wxRIGHT|wxLEFT, 13 );
+ bSizer1->Add( m_staticText4, 0, wxLEFT|wxRIGHT|wxTOP, 13 );
bSizer1->Add( 0, 3, 0, wxEXPAND, 5 );
@@ -80,6 +103,6 @@ PANEL_PCM_SETTINGS_BASE::PANEL_PCM_SETTINGS_BASE( wxWindow* parent, wxWindowID i
bSizer1->Fit( this );
}
-PANEL_PCM_SETTINGS_BASE::~PANEL_PCM_SETTINGS_BASE()
+PANEL_PACKAGES_AND_UPDATES_BASE::~PANEL_PACKAGES_AND_UPDATES_BASE()
{
}
diff --git a/kicad/pcm/dialogs/panel_pcm_settings_base.fbp b/common/dialogs/panel_packages_and_updates_base.fbp
similarity index 75%
rename from kicad/pcm/dialogs/panel_pcm_settings_base.fbp
rename to common/dialogs/panel_packages_and_updates_base.fbp
index 7fc10d110b..ab605f00bb 100644
--- a/kicad/pcm/dialogs/panel_pcm_settings_base.fbp
+++ b/common/dialogs/panel_packages_and_updates_base.fbp
@@ -2,7 +2,7 @@
- ;
+
C++
1
source_name
@@ -11,13 +11,13 @@
res
UTF-8
connect
- panel_pcm_settings_base
+ panel_packages_and_updates_base
1000
none
1
- panel_pcm_settings_base
+ panel_packages_and_updates_base
.
@@ -44,7 +44,7 @@
wxID_ANY
- PANEL_PCM_SETTINGS_BASE
+ PANEL_PACKAGES_AND_UPDATES_BASE
-1,-1
; ; forward_declare
@@ -60,7 +60,7 @@
none
13
- wxTOP|wxRIGHT|wxLEFT
+ wxLEFT|wxRIGHT|wxTOP
0
1
@@ -120,6 +120,223 @@
-1
+
+ 5
+ wxEXPAND
+ 0
+
+ 0
+ protected
+ 0
+
+
+
+ 5
+ wxEXPAND | wxALL
+ 0
+
+ 1
+ 1
+ 1
+ 1
+
+
+
+
+
+
+
+ 1
+ 0
+ 1
+
+ 1
+ 0
+ Dock
+ 0
+ Left
+ 0
+ 1
+
+ 1
+
+ 0
+ 0
+ wxID_ANY
+
+ 0
+
+
+ 0
+
+ 1
+ m_staticline3
+ 1
+
+
+ protected
+ 1
+
+ Resizable
+ 1
+
+ wxLI_HORIZONTAL
+ ; ; forward_declare
+ 0
+
+
+
+
+
+
+
+ 5
+ wxEXPAND|wxLEFT|wxTOP
+ 0
+
+
+ bSizer41
+ wxVERTICAL
+ none
+
+ 5
+ wxLEFT
+ 0
+
+ 1
+ 1
+ 1
+ 1
+
+
+
+
+
+
+
+ 1
+ 0
+ 1
+ 1
+
+ 1
+ 0
+ Dock
+ 0
+ Left
+ 0
+ 1
+
+ 1
+
+ 0
+ 0
+ wxID_ANY
+ Check for KiCad updates on startup
+
+ 0
+
+
+ 0
+
+ 1
+ m_cbKicadUpdate
+ 1
+
+
+ protected
+ 1
+
+ Resizable
+ 1
+
+
+ ; ; forward_declare
+ 0
+
+
+ wxFILTER_NONE
+ wxDefaultValidator
+
+
+
+
+
+
+
+
+
+ 5
+ wxEXPAND
+ 0
+
+ 20
+ protected
+ 0
+
+
+
+ 13
+ wxTOP|wxRIGHT|wxLEFT
+ 0
+
+ 1
+ 1
+ 1
+ 1
+
+
+
+
+
+
+
+ 1
+ 0
+ 1
+
+ 1
+ 0
+ Dock
+ 0
+ Left
+ 0
+ 1
+
+ 1
+
+ 0
+ 0
+ wxID_ANY
+ Plugin and Content Manager
+ 0
+
+ 0
+
+
+ 0
+
+ 1
+ m_pcmLabel
+ 1
+
+
+ protected
+ 1
+
+ Resizable
+ 1
+
+
+ ; ; forward_declare
+ 0
+
+
+
+
+ -1
+
+
5
wxEXPAND
@@ -240,7 +457,7 @@
0
1
- m_updateCheck
+ m_cbPcmUpdate
1
@@ -277,7 +494,7 @@
13
- wxTOP|wxRIGHT|wxLEFT
+ wxLEFT|wxRIGHT|wxTOP
0
1
diff --git a/kicad/pcm/dialogs/panel_pcm_settings_base.h b/common/dialogs/panel_packages_and_updates_base.h
similarity index 70%
rename from kicad/pcm/dialogs/panel_pcm_settings_base.h
rename to common/dialogs/panel_packages_and_updates_base.h
index 9483fb894f..c53c09ccf2 100644
--- a/kicad/pcm/dialogs/panel_pcm_settings_base.h
+++ b/common/dialogs/panel_packages_and_updates_base.h
@@ -26,16 +26,19 @@
///////////////////////////////////////////////////////////////////////////////
-/// Class PANEL_PCM_SETTINGS_BASE
+/// Class PANEL_PACKAGES_AND_UPDATES_BASE
///////////////////////////////////////////////////////////////////////////////
-class PANEL_PCM_SETTINGS_BASE : public wxPanel
+class PANEL_PACKAGES_AND_UPDATES_BASE : public wxPanel
{
private:
protected:
wxStaticText* m_generalLabel;
+ wxStaticLine* m_staticline3;
+ wxCheckBox* m_cbKicadUpdate;
+ wxStaticText* m_pcmLabel;
wxStaticLine* m_staticline1;
- wxCheckBox* m_updateCheck;
+ wxCheckBox* m_cbPcmUpdate;
wxStaticText* m_staticText4;
wxStaticLine* m_staticline2;
wxCheckBox* m_libAutoAdd;
@@ -45,9 +48,9 @@ class PANEL_PCM_SETTINGS_BASE : public wxPanel
public:
- PANEL_PCM_SETTINGS_BASE( wxWindow* parent, wxWindowID id = wxID_ANY, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( -1,-1 ), long style = wxTAB_TRAVERSAL, const wxString& name = wxEmptyString );
+ PANEL_PACKAGES_AND_UPDATES_BASE( wxWindow* parent, wxWindowID id = wxID_ANY, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( -1,-1 ), long style = wxTAB_TRAVERSAL, const wxString& name = wxEmptyString );
- ~PANEL_PCM_SETTINGS_BASE();
+ ~PANEL_PACKAGES_AND_UPDATES_BASE();
};
diff --git a/common/eda_base_frame.cpp b/common/eda_base_frame.cpp
index cfe02383c9..5acefea522 100644
--- a/common/eda_base_frame.cpp
+++ b/common/eda_base_frame.cpp
@@ -40,7 +40,7 @@
#include
#include
#include
-#include
+#include
#include
#include
#include
@@ -1203,8 +1203,8 @@ if( ADVANCED_CFG::GetCfg().m_EnableGit && false )
book->AddLazyPage(
[]( wxWindow* aParent ) -> wxWindow*
{
- return new PANEL_PCM_SETTINGS( aParent );
- }, _( "Plugin and Content Manager" ) );
+ return new PANEL_PACKAGES_AND_UPDATES( aParent );
+ }, _( "Packages and Updates" ) );
}
catch( ... )
{
diff --git a/common/http_lib/http_lib_connection.cpp b/common/http_lib/http_lib_connection.cpp
index 02980ab48e..a478b33b55 100644
--- a/common/http_lib/http_lib_connection.cpp
+++ b/common/http_lib/http_lib_connection.cpp
@@ -362,15 +362,11 @@ bool HTTP_LIB_CONNECTION::SelectAll( const HTTP_LIB_CATEGORY& aCategory,
bool HTTP_LIB_CONNECTION::checkServerResponse( std::unique_ptr& aCurl )
{
-
- long http_code = 0;
-
- curl_easy_getinfo( aCurl->GetCurl(), CURLINFO_RESPONSE_CODE, &http_code );
-
- if( http_code != 200 )
+ int statusCode = aCurl->GetResponseStatusCode();
+ if( statusCode != 200 )
{
m_lastError += wxString::Format( _( "API responded with error code: %s" ) + "\n",
- httpErrorCodeDescription( http_code ) );
+ httpErrorCodeDescription( statusCode ) );
return false;
}
diff --git a/common/kicad_curl/kicad_curl_easy.cpp b/common/kicad_curl/kicad_curl_easy.cpp
index 0261a46057..9cc5a1b162 100644
--- a/common/kicad_curl/kicad_curl_easy.cpp
+++ b/common/kicad_curl/kicad_curl_easy.cpp
@@ -251,6 +251,15 @@ bool KICAD_CURL_EASY::SetPostFields(
}
+bool KICAD_CURL_EASY::SetPostFields( const std::string& aField )
+{
+ if( setOption( CURLOPT_COPYPOSTFIELDS, aField.c_str() ) != CURLE_OK )
+ return false;
+
+ return true;
+}
+
+
bool KICAD_CURL_EASY::SetURL( const std::string& aURL )
{
if( setOption( CURLOPT_URL, aURL.c_str() ) == CURLE_OK )
@@ -340,3 +349,12 @@ int KICAD_CURL_EASY::GetTransferTotal( uint64_t& aDownloadedBytes ) const
#endif
return result;
}
+
+
+int KICAD_CURL_EASY::GetResponseStatusCode()
+{
+ long http_code = 0;
+ curl_easy_getinfo( m_CURL, CURLINFO_RESPONSE_CODE, &http_code );
+
+ return static_cast( http_code );
+}
\ No newline at end of file
diff --git a/common/notifications_manager.cpp b/common/notifications_manager.cpp
index 08a6e57696..ea0a39b0f1 100644
--- a/common/notifications_manager.cpp
+++ b/common/notifications_manager.cpp
@@ -222,6 +222,10 @@ public:
panel->Destroy();
m_panelMap.erase( it );
+
+ // ensure the window contents get shifted as needed
+ m_scrolledWindow->Layout();
+ Layout();
}
if( m_panelMap.size() == 0 )
diff --git a/common/settings/common_settings.cpp b/common/settings/common_settings.cpp
index 802becefab..a5316e1565 100644
--- a/common/settings/common_settings.cpp
+++ b/common/settings/common_settings.cpp
@@ -324,6 +324,9 @@ COMMON_SETTINGS::COMMON_SETTINGS() :
m_params.emplace_back( new PARAM( "do_not_show_again.data_collection_prompt",
&m_DoNotShowAgain.data_collection_prompt, false ) );
+ m_params.emplace_back( new PARAM( "do_not_show_again.update_check_prompt",
+ &m_DoNotShowAgain.update_check_prompt, false ) );
+
m_params.emplace_back( new PARAM( "session.remember_open_files",
&m_Session.remember_open_files, false ) );
diff --git a/common/settings/kicad_settings.cpp b/common/settings/kicad_settings.cpp
index 2aaac76da8..3ed2e76f49 100644
--- a/common/settings/kicad_settings.cpp
+++ b/common/settings/kicad_settings.cpp
@@ -42,7 +42,13 @@ KICAD_SETTINGS::KICAD_SETTINGS() :
m_params.emplace_back(
new PARAM_LIST( "system.open_projects", &m_OpenProjects, {} ) );
- m_params.emplace_back( new PARAM( "system.check_for_updates", &m_updateCheck, 0 ) );
+ m_params.emplace_back(
+ new PARAM( "system.last_update_check_time", &m_lastUpdateCheckTime, "" ) );
+
+ m_params.emplace_back(
+ new PARAM( "system.last_received_update", &m_lastReceivedUpdate, "" ) );
+
+ m_params.emplace_back( new PARAM( "system.check_for_kicad_updates", &m_KiCadUpdateCheck, true ) );
m_params.emplace_back( new PARAM_LAMBDA(
"pcm.repositories",
diff --git a/include/kicad_curl/kicad_curl_easy.h b/include/kicad_curl/kicad_curl_easy.h
index 1548ad3681..ca052f7c6f 100644
--- a/include/kicad_curl/kicad_curl_easy.h
+++ b/include/kicad_curl/kicad_curl_easy.h
@@ -99,6 +99,14 @@ public:
*/
bool SetPostFields( const std::vector>& aFields );
+ /**
+ * Set the post content body to the string, usually used for json rather than the typical key/value pair
+ *
+ * @param aField is the string body to send
+ * @return True if successful, false if not.
+ */
+ bool SetPostFields( const std::string& aField );
+
/**
* Set the request URL.
*
@@ -140,6 +148,7 @@ public:
CURL* GetCurl() { return m_CURL; }
+ int GetResponseStatusCode();
private:
/**
diff --git a/include/settings/common_settings.h b/include/settings/common_settings.h
index 10d415342c..d19d98b68f 100644
--- a/include/settings/common_settings.h
+++ b/include/settings/common_settings.h
@@ -133,6 +133,7 @@ public:
bool env_var_overwrite_warning;
bool scaled_3d_models_warning;
bool data_collection_prompt;
+ bool update_check_prompt;
};
struct NETCLASS_PANEL
diff --git a/include/settings/kicad_settings.h b/include/settings/kicad_settings.h
index 16503f2b26..260d6e29f0 100644
--- a/include/settings/kicad_settings.h
+++ b/include/settings/kicad_settings.h
@@ -36,22 +36,6 @@ public:
int m_LeftWinWidth;
- /**
- * @brief General setting for various update checks
- *
- * A one time popup asks user to allow/disallow update checks on startup.
- * This is currently used by PCM.
- *
- * See enum below for meaning of values.
- */
- int m_updateCheck;
-
- enum UPDATE_CHECK
- {
- UNINITIALIZED = 0,
- NOT_ALLOWED = 1,
- ALLOWED = 2
- };
std::vector m_OpenProjects;
@@ -68,6 +52,10 @@ public:
// Generated library nickname prefix
wxString m_PcmLibPrefix;
+ bool m_KiCadUpdateCheck;
+ wxString m_lastUpdateCheckTime;
+ wxString m_lastReceivedUpdate;
+
protected:
virtual std::string getLegacyFrameName() const override { return "KicadFrame"; }
};
diff --git a/kicad/CMakeLists.txt b/kicad/CMakeLists.txt
index e61ba75bcd..127969190e 100644
--- a/kicad/CMakeLists.txt
+++ b/kicad/CMakeLists.txt
@@ -16,6 +16,8 @@ include_directories(
)
set( KICAD_SRCS
+ dialogs/dialog_update_check_prompt_base.cpp
+ dialogs/dialog_update_check_prompt.cpp
dialogs/dialog_template_selector_base.cpp
dialogs/dialog_template_selector.cpp
dialogs/panel_kicad_launcher_base.cpp
@@ -29,6 +31,7 @@ set( KICAD_SRCS
project_tree_pane.cpp
project_tree.cpp
project_tree_item.cpp
+ update_manager.cpp
tools/kicad_manager_actions.cpp
tools/kicad_manager_control.cpp
)
diff --git a/kicad/dialogs/dialog_update_check_prompt.cpp b/kicad/dialogs/dialog_update_check_prompt.cpp
new file mode 100644
index 0000000000..78c288cebf
--- /dev/null
+++ b/kicad/dialogs/dialog_update_check_prompt.cpp
@@ -0,0 +1,55 @@
+/*
+ * This program source code file is part of KiCad, a free EDA CAD application.
+ *
+ * Copyright (C) 2023 Mark Roszko
+ * Copyright (C) 2023 KiCad Developers, see AUTHORS.txt for contributors.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, you may find one here:
+ * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
+ * or you may search the http://www.gnu.org website for the version 2 license,
+ * or you may write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
+ */
+
+#include
+#include
+#include
+#include
+
+DIALOG_UPDATE_CHECK_PROMPT::DIALOG_UPDATE_CHECK_PROMPT( wxWindow* aWindow ) :
+ DIALOG_UPDATE_CHECK_PROMPT_BASE( aWindow )
+{
+}
+
+
+bool DIALOG_UPDATE_CHECK_PROMPT::TransferDataFromWindow()
+{
+ SETTINGS_MANAGER& mgr = Pgm().GetSettingsManager();
+ KICAD_SETTINGS* settings = mgr.GetAppSettings();
+
+ settings->m_PcmUpdateCheck = m_cbPCMUpdates->GetValue();
+ settings->m_KiCadUpdateCheck = m_cbKiCadUpdates->GetValue();
+
+ return true;
+}
+
+
+bool DIALOG_UPDATE_CHECK_PROMPT::TransferDataToWindow()
+{
+ // Since this is a first time start dialog, just default to both checks true
+ m_cbPCMUpdates->SetValue( true );
+ m_cbKiCadUpdates->SetValue( true );
+
+ return true;
+}
\ No newline at end of file
diff --git a/kicad/dialogs/dialog_update_check_prompt.h b/kicad/dialogs/dialog_update_check_prompt.h
new file mode 100644
index 0000000000..4712c6a7e4
--- /dev/null
+++ b/kicad/dialogs/dialog_update_check_prompt.h
@@ -0,0 +1,40 @@
+/*
+ * This program source code file is part of KiCad, a free EDA CAD application.
+ *
+ * Copyright (C) 2023 Mark Roszko
+ * Copyright (C) 2023 KiCad Developers, see AUTHORS.txt for contributors.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, you may find one here:
+ * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
+ * or you may search the http://www.gnu.org website for the version 2 license,
+ * or you may write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
+ */
+
+#ifndef DIALOG_UPDATE_CHECK_PROMPT_H
+#define DIALOG_UPDATE_CHECK_PROMPT_H
+
+#include
+
+class DIALOG_UPDATE_CHECK_PROMPT : public DIALOG_UPDATE_CHECK_PROMPT_BASE
+{
+public:
+ DIALOG_UPDATE_CHECK_PROMPT( wxWindow* aParent );
+
+protected:
+ bool TransferDataFromWindow() override;
+ bool TransferDataToWindow() override;
+};
+
+#endif
\ No newline at end of file
diff --git a/kicad/dialogs/dialog_update_check_prompt_base.cpp b/kicad/dialogs/dialog_update_check_prompt_base.cpp
new file mode 100644
index 0000000000..73330ef508
--- /dev/null
+++ b/kicad/dialogs/dialog_update_check_prompt_base.cpp
@@ -0,0 +1,65 @@
+///////////////////////////////////////////////////////////////////////////
+// C++ code generated with wxFormBuilder (version 3.10.1-0-g8feb16b3)
+// http://www.wxformbuilder.org/
+//
+// PLEASE DO *NOT* EDIT THIS FILE!
+///////////////////////////////////////////////////////////////////////////
+
+#include "dialog_update_check_prompt_base.h"
+
+///////////////////////////////////////////////////////////////////////////
+
+DIALOG_UPDATE_CHECK_PROMPT_BASE::DIALOG_UPDATE_CHECK_PROMPT_BASE( wxWindow* parent, wxWindowID id, const wxString& title, const wxPoint& pos, const wxSize& size, long style ) : DIALOG_SHIM( parent, id, title, pos, size, style )
+{
+ this->SetSizeHints( wxDefaultSize, wxDefaultSize );
+
+ wxBoxSizer* bSizerMain;
+ bSizerMain = new wxBoxSizer( wxVERTICAL );
+
+ wxFlexGridSizer* fgSizer4;
+ fgSizer4 = new wxFlexGridSizer( 0, 2, 10, 0 );
+ fgSizer4->SetFlexibleDirection( wxBOTH );
+ fgSizer4->SetNonFlexibleGrowMode( wxFLEX_GROWMODE_SPECIFIED );
+
+ wxBoxSizer* bSizer4;
+ bSizer4 = new wxBoxSizer( wxVERTICAL );
+
+ m_messageLine1 = new wxStaticText( this, wxID_ANY, _("Would you like to automatically check for updates on startup?"), wxDefaultPosition, wxDefaultSize, 0 );
+ m_messageLine1->Wrap( -1 );
+ bSizer4->Add( m_messageLine1, 0, wxALL, 5 );
+
+ m_cbKiCadUpdates = new wxCheckBox( this, wxID_ANY, _("KiCad"), wxDefaultPosition, wxDefaultSize, 0 );
+ bSizer4->Add( m_cbKiCadUpdates, 0, wxALL, 5 );
+
+ m_cbPCMUpdates = new wxCheckBox( this, wxID_ANY, _("Plugin and Content Manager"), wxDefaultPosition, wxDefaultSize, 0 );
+ bSizer4->Add( m_cbPCMUpdates, 0, wxALL, 5 );
+
+
+ fgSizer4->Add( bSizer4, 1, wxEXPAND|wxRIGHT, 5 );
+
+
+ fgSizer4->Add( 0, 0, 1, wxEXPAND, 5 );
+
+ m_sdbSizer = new wxStdDialogButtonSizer();
+ m_sdbSizerOK = new wxButton( this, wxID_OK );
+ m_sdbSizer->AddButton( m_sdbSizerOK );
+ m_sdbSizerCancel = new wxButton( this, wxID_CANCEL );
+ m_sdbSizer->AddButton( m_sdbSizerCancel );
+ m_sdbSizer->Realize();
+
+ fgSizer4->Add( m_sdbSizer, 1, wxEXPAND, 5 );
+
+
+ bSizerMain->Add( fgSizer4, 1, wxEXPAND|wxALL, 5 );
+
+
+ this->SetSizer( bSizerMain );
+ this->Layout();
+ bSizerMain->Fit( this );
+
+ this->Centre( wxBOTH );
+}
+
+DIALOG_UPDATE_CHECK_PROMPT_BASE::~DIALOG_UPDATE_CHECK_PROMPT_BASE()
+{
+}
diff --git a/kicad/dialogs/dialog_update_check_prompt_base.fbp b/kicad/dialogs/dialog_update_check_prompt_base.fbp
new file mode 100644
index 0000000000..68e3650e07
--- /dev/null
+++ b/kicad/dialogs/dialog_update_check_prompt_base.fbp
@@ -0,0 +1,313 @@
+
+
+
+
+
+ C++
+ 1
+ source_name
+ 0
+ 0
+ res
+ UTF-8
+ connect
+ dialog_update_check_prompt_base
+ 1000
+ none
+
+
+ 1
+ dialog_update_check_prompt_base
+
+ .
+
+ 1
+ 1
+ 1
+ 1
+ UI
+ 0
+ 0
+ 0
+
+ 0
+ wxAUI_MGR_DEFAULT
+
+ wxBOTH
+
+ 1
+ 1
+ impl_virtual
+
+
+
+ 0
+ wxID_ANY
+
+
+ DIALOG_UPDATE_CHECK_PROMPT_BASE
+
+ -1,-1
+ wxDEFAULT_DIALOG_STYLE
+ DIALOG_SHIM; dialog_shim.h
+ Check for Updates
+
+ 0
+
+
+
+
+
+ bSizerMain
+ wxVERTICAL
+ none
+
+ 5
+ wxEXPAND|wxALL
+ 1
+
+ 2
+ wxBOTH
+
+
+ 0
+
+ fgSizer4
+ wxFLEX_GROWMODE_SPECIFIED
+ none
+ 0
+ 10
+
+ 5
+ wxEXPAND|wxRIGHT
+ 1
+
+
+ bSizer4
+ wxVERTICAL
+ none
+
+ 5
+ wxALL
+ 0
+
+ 1
+ 1
+ 1
+ 1
+
+
+
+
+
+
+
+ 1
+ 0
+ 1
+
+ 1
+ 0
+ Dock
+ 0
+ Left
+ 1
+
+ 1
+
+ 0
+ 0
+ wxID_ANY
+ Would you like to automatically check for updates on startup?
+ 0
+
+ 0
+
+
+ 0
+
+ 1
+ m_messageLine1
+ 1
+
+
+ protected
+ 1
+
+ Resizable
+ 1
+
+
+ ; ; forward_declare
+ 0
+
+
+
+
+ -1
+
+
+
+ 5
+ wxALL
+ 0
+
+ 1
+ 1
+ 1
+ 1
+
+
+
+
+
+
+
+ 1
+ 0
+ 0
+ 1
+
+ 1
+ 0
+ Dock
+ 0
+ Left
+ 1
+
+ 1
+
+ 0
+ 0
+ wxID_ANY
+ KiCad
+
+ 0
+
+
+ 0
+
+ 1
+ m_cbKiCadUpdates
+ 1
+
+
+ protected
+ 1
+
+ Resizable
+ 1
+
+
+ ; ; forward_declare
+ 0
+
+
+ wxFILTER_NONE
+ wxDefaultValidator
+
+
+
+
+
+
+
+ 5
+ wxALL
+ 0
+
+ 1
+ 1
+ 1
+ 1
+
+
+
+
+
+
+
+ 1
+ 0
+ 0
+ 1
+
+ 1
+ 0
+ Dock
+ 0
+ Left
+ 1
+
+ 1
+
+ 0
+ 0
+ wxID_ANY
+ Plugin and Content Manager
+
+ 0
+
+
+ 0
+
+ 1
+ m_cbPCMUpdates
+ 1
+
+
+ protected
+ 1
+
+ Resizable
+ 1
+
+
+ ; ; forward_declare
+ 0
+
+
+ wxFILTER_NONE
+ wxDefaultValidator
+
+
+
+
+
+
+
+
+
+ 5
+ wxEXPAND
+ 1
+
+ 0
+ protected
+ 0
+
+
+
+ 5
+ wxEXPAND
+ 1
+
+ 0
+ 1
+ 0
+ 0
+ 0
+ 1
+ 0
+ 0
+
+ m_sdbSizer
+ protected
+
+
+
+
+
+
+
+
diff --git a/kicad/dialogs/dialog_update_check_prompt_base.h b/kicad/dialogs/dialog_update_check_prompt_base.h
new file mode 100644
index 0000000000..6c169a181c
--- /dev/null
+++ b/kicad/dialogs/dialog_update_check_prompt_base.h
@@ -0,0 +1,50 @@
+///////////////////////////////////////////////////////////////////////////
+// C++ code generated with wxFormBuilder (version 3.10.1-0-g8feb16b3)
+// http://www.wxformbuilder.org/
+//
+// PLEASE DO *NOT* EDIT THIS FILE!
+///////////////////////////////////////////////////////////////////////////
+
+#pragma once
+
+#include
+#include
+#include
+#include "dialog_shim.h"
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+
+///////////////////////////////////////////////////////////////////////////
+
+
+///////////////////////////////////////////////////////////////////////////////
+/// Class DIALOG_UPDATE_CHECK_PROMPT_BASE
+///////////////////////////////////////////////////////////////////////////////
+class DIALOG_UPDATE_CHECK_PROMPT_BASE : public DIALOG_SHIM
+{
+ private:
+
+ protected:
+ wxStaticText* m_messageLine1;
+ wxCheckBox* m_cbKiCadUpdates;
+ wxCheckBox* m_cbPCMUpdates;
+ wxStdDialogButtonSizer* m_sdbSizer;
+ wxButton* m_sdbSizerOK;
+ wxButton* m_sdbSizerCancel;
+
+ public:
+
+ DIALOG_UPDATE_CHECK_PROMPT_BASE( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = _("Check for Updates"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( -1,-1 ), long style = wxDEFAULT_DIALOG_STYLE );
+
+ ~DIALOG_UPDATE_CHECK_PROMPT_BASE();
+
+};
+
diff --git a/kicad/kicad_manager_frame.cpp b/kicad/kicad_manager_frame.cpp
index 59db177fb5..2afdd75546 100644
--- a/kicad/kicad_manager_frame.cpp
+++ b/kicad/kicad_manager_frame.cpp
@@ -34,6 +34,7 @@
#include
#include
#include
+#include
#include
#include
#include
@@ -66,6 +67,7 @@
#include
#include
#include
+#include
#include <../pcbnew/plugins/kicad/pcb_plugin.h> // for SEXPR_BOARD_FILE_VERSION def
@@ -944,20 +946,12 @@ void KICAD_MANAGER_FRAME::OnIdle( wxIdleEvent& aEvent )
KICAD_SETTINGS* settings = kicadSettings();
- if( settings->m_updateCheck == KICAD_SETTINGS::UPDATE_CHECK::UNINITIALIZED )
+ if( !Pgm().GetCommonSettings()->m_DoNotShowAgain.update_check_prompt )
{
- if( wxMessageBox( _( "Would you like to automatically check for plugin updates on startup?" ),
- _( "Check for updates" ), wxICON_QUESTION | wxYES_NO, this )
- == wxYES )
- {
- settings->m_updateCheck = KICAD_SETTINGS::UPDATE_CHECK::ALLOWED;
- settings->m_PcmUpdateCheck = true;
- }
- else
- {
- settings->m_updateCheck = KICAD_SETTINGS::UPDATE_CHECK::NOT_ALLOWED;
- settings->m_PcmUpdateCheck = false;
- }
+ auto prompt = new DIALOG_UPDATE_CHECK_PROMPT( this );
+ prompt->ShowModal();
+
+ Pgm().GetCommonSettings()->m_DoNotShowAgain.update_check_prompt = true;
}
if( KIPLATFORM::POLICY::GetPolicyBool( POLICY_KEY_PCM ) != KIPLATFORM::POLICY::PBOOL::DISABLED
@@ -968,6 +962,12 @@ void KICAD_MANAGER_FRAME::OnIdle( wxIdleEvent& aEvent )
m_pcm->RunBackgroundUpdate();
}
+
+ if( !m_updateManager && settings->m_KiCadUpdateCheck )
+ {
+ m_updateManager = std::make_unique();
+ m_updateManager->CheckForUpdate();
+ }
}
diff --git a/kicad/kicad_manager_frame.h b/kicad/kicad_manager_frame.h
index 8de88aec7b..60b448c0cd 100644
--- a/kicad/kicad_manager_frame.h
+++ b/kicad/kicad_manager_frame.h
@@ -35,6 +35,7 @@ class PANEL_KICAD_LAUNCHER;
class PLUGIN_CONTENT_MANAGER;
class PROJECT_TREE;
class PROJECT_TREE_PANE;
+class UPDATE_MANAGER;
/**
* The main KiCad project manager frame. It is not a KIWAY_PLAYER.
@@ -206,6 +207,7 @@ private:
std::shared_ptr m_pcm;
BITMAP_BUTTON* m_pcmButton;
int m_pcmUpdateCount;
+ std::unique_ptr m_updateManager;
};
diff --git a/kicad/pcm/CMakeLists.txt b/kicad/pcm/CMakeLists.txt
index 96dbaf5b74..4d56751046 100644
--- a/kicad/pcm/CMakeLists.txt
+++ b/kicad/pcm/CMakeLists.txt
@@ -8,11 +8,6 @@ include_directories( BEFORE ${INC_BEFORE} )
add_compile_definitions( PCM )
-set ( PCM_SETTINGS_SRCS
- dialogs/panel_pcm_settings_base.cpp
- dialogs/panel_pcm_settings.cpp
-)
-
set ( PCM_DLG_SRCS
dialogs/dialog_manage_repositories_base.cpp
dialogs/dialog_manage_repositories.cpp
@@ -48,24 +43,6 @@ target_link_libraries( pcm
nlohmann_json_schema_validator
)
-add_library( pcm_settings STATIC
- ${PCM_SETTINGS_SRCS}
-)
-
-# This is a circular dependency but it's not a problem for static libs.
-# Refactoring this would need separating kicad_settings, settings manager
-# and pgm_base out of common.
-target_link_libraries( pcm_settings
- common
- core
-)
-
-target_include_directories(
- pcm_settings
- PUBLIC dialogs
- PRIVATE $
-)
-
# Copy the schema to the build directory when building outside the source tree
# to allow for proper running of kicad from the build directory.
if( NOT (${CMAKE_CURRENT_SOURCE_DIR} STREQUAL ${CMAKE_CURRENT_BINARY_DIR} ) )
diff --git a/kicad/update_manager.cpp b/kicad/update_manager.cpp
new file mode 100644
index 0000000000..808f85cf49
--- /dev/null
+++ b/kicad/update_manager.cpp
@@ -0,0 +1,252 @@
+/*
+ * This program source code file is part of KiCad, a free EDA CAD application.
+ *
+ * Copyright (C) 2023 Mark Roszko
+ * Copyright (C) 2023 KiCad Developers, see AUTHORS.txt for contributors.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, you may find one here:
+ * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
+ * or you may search the http://www.gnu.org website for the version 2 license,
+ * or you may write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
+ */
+
+#include
+#include
+
+#include
+#include
+
+#include "settings/settings_manager.h"
+#include "settings/kicad_settings.h"
+#include
+
+#include
+#include
+#include
+
+#include
+#include
+
+#include
+#include
+#include
+#include
+#include
+
+#include
+
+#include
+
+#include
+
+
+struct UPDATE_REQUEST
+{
+ wxString platform;
+ wxString arch;
+ wxString current_version;
+ wxString lang;
+ wxString last_check;
+};
+
+
+NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE( UPDATE_REQUEST, platform, arch, current_version, lang,
+ last_check )
+
+struct UPDATE_RESPONSE
+{
+ wxString version;
+ wxString release_date;
+ wxString details_url;
+ wxString downloads_url;
+};
+
+NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE( UPDATE_RESPONSE, version, release_date, details_url,
+ downloads_url )
+
+#define UPDATE_QUERY_ENDPOINT wxS( "https://downloads.kicad.org/api/v1/update" )
+
+
+UPDATE_MANAGER::UPDATE_MANAGER() : m_working( false )
+{
+}
+
+
+int UPDATE_MANAGER::PostRequest( const wxString& aUrl, std::string aRequestBody,
+ std::ostream* aOutput, PROGRESS_REPORTER* aReporter,
+ const size_t aSizeLimit )
+{
+ bool size_exceeded = false;
+
+ TRANSFER_CALLBACK callback = [&]( size_t dltotal, size_t dlnow, size_t ultotal, size_t ulnow )
+ {
+ if( aSizeLimit > 0 && ( dltotal > aSizeLimit || dlnow > aSizeLimit ) )
+ {
+ size_exceeded = true;
+
+ // Non zero return means abort.
+ return true;
+ }
+
+ if( aReporter )
+ {
+ if( dltotal > 1000 )
+ {
+ aReporter->SetCurrentProgress( dlnow / (double) dltotal );
+ aReporter->Report( wxString::Format( _( "Downloading %lld/%lld kB" ), dlnow / 1000,
+ dltotal / 1000 ) );
+ }
+ else
+ {
+ if( aReporter )
+ aReporter->SetCurrentProgress( 0.0 );
+ }
+
+ return !aReporter->KeepRefreshing();
+ }
+ else
+ return false;
+ };
+
+ KICAD_CURL_EASY curl;
+ curl.SetHeader( "Accept", "application/json" );
+ curl.SetHeader( "Content-Type", "application/json" );
+ curl.SetHeader( "charset", "utf-8" );
+ curl.SetOutputStream( aOutput );
+ curl.SetURL( aUrl.ToUTF8().data() );
+ curl.SetPostFields( aRequestBody );
+ curl.SetFollowRedirects( true );
+ curl.SetTransferCallback( callback, 250000L );
+
+ int code = curl.Perform();
+
+ if( aReporter && !aReporter->IsCancelled() )
+ aReporter->SetCurrentProgress( 1.0 );
+
+ if( code != CURLE_OK )
+ {
+ if( aReporter )
+ {
+ if( code == CURLE_ABORTED_BY_CALLBACK && size_exceeded )
+ aReporter->Report( _( "Download is too large." ) );
+ else if( code != CURLE_ABORTED_BY_CALLBACK )
+ aReporter->Report( wxString( curl.GetErrorText( code ) ) );
+ }
+
+ return 0;
+ }
+
+ return curl.GetResponseStatusCode();
+}
+
+
+void UPDATE_MANAGER::CheckForUpdate()
+{
+ if( m_working )
+ return;
+
+ m_working = false;
+
+ m_updateBackgroundJob = Pgm().GetBackgroundJobMonitor().Create( _( "Update Check" ) );
+
+ auto update_check = [&]() -> void
+ {
+ std::stringstream update_json_stream;
+ std::stringstream request_json_stream;
+
+ wxString aUrl = UPDATE_QUERY_ENDPOINT;
+ m_updateBackgroundJob->m_reporter->SetNumPhases( 1 );
+ m_updateBackgroundJob->m_reporter->Report( _( "Requesting update info" ) );
+
+ UPDATE_REQUEST requestContent;
+
+
+ // These platform keys are specific to the downloads site
+#if defined( __WXWINDOWS__ )
+ requestContent.platform = "windows";
+
+ #if defined( KICAD_BUILD_ARCH_X64 )
+ requestContent.arch = "amd64";
+ #elif defined( KICAD_BUILD_ARCH_X86 )
+ requestContent.arch = "i686";
+ #elif defined( KICAD_BUILD_ARCH_ARM )
+ requestContent.arch = "arm";
+ #elif defined( KICAD_BUILD_ARCH_ARM64 )
+ requestContent.arch = "arm64";
+ #endif
+#elif defined( __WXOSX__ )
+ requestContent.platform = "macos";
+ requestContent.arch = "unified";
+#else
+ //everything else gets lumped as linux
+ requestContent.platform = "linux";
+ requestContent.arch = "";
+#endif
+ // requestContent.current_version = GetMajorMinorPatchVersion();
+ requestContent.current_version = "7.0.8";
+ requestContent.lang = Pgm().GetLanguageTag();
+
+ KICAD_SETTINGS* settings = Pgm().GetSettingsManager().GetAppSettings();
+
+ requestContent.last_check = settings->m_lastUpdateCheckTime;
+
+ nlohmann::json requestJson = nlohmann::json( requestContent );
+ request_json_stream << requestJson;
+
+ int responseCode =
+ PostRequest( aUrl, request_json_stream.str(), &update_json_stream, NULL, 20480 );
+
+ // Check that the response is 200 (content provided)
+ // We can also return 204 for no update
+ if( responseCode == 200 )
+ {
+ nlohmann::json update_json;
+ UPDATE_RESPONSE response;
+
+ try
+ {
+ update_json_stream >> update_json;
+ response = update_json.get();
+
+ if( response.version != settings->m_lastReceivedUpdate )
+ {
+ wxString notificationDesc =
+ wxString::Format( _( "KiCad %s was released on %s" ), response.version,
+ response.release_date );
+
+ Pgm().GetNotificationsManager().CreateOrUpdate(
+ wxS( "kicad_update" ), _( "Update Available" ), notificationDesc,
+ response.details_url );
+
+ settings->m_lastReceivedUpdate = response.version;
+ }
+ }
+ catch( const std::exception& e )
+ {
+ wxLogError( wxString::Format( _( "Unable to parse update response: %s" ),
+ e.what() ) );
+ }
+ }
+
+ settings->m_lastUpdateCheckTime = wxDateTime::Now().FormatISOCombined();
+
+ Pgm().GetBackgroundJobMonitor().Remove( m_updateBackgroundJob );
+ m_updateBackgroundJob = nullptr;
+ m_working = false;
+ };
+
+ thread_pool& tp = GetKiCadThreadPool();
+ tp.push_task( update_check );
+}
\ No newline at end of file
diff --git a/kicad/update_manager.h b/kicad/update_manager.h
new file mode 100644
index 0000000000..e255d304cc
--- /dev/null
+++ b/kicad/update_manager.h
@@ -0,0 +1,44 @@
+/*
+ * This program source code file is part of KiCad, a free EDA CAD application.
+ *
+ * Copyright (C) 2023 Mark Roszko
+ * Copyright (C) 2023 KiCad Developers, see AUTHORS.txt for contributors.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, you may find one here:
+ * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
+ * or you may search the http://www.gnu.org website for the version 2 license,
+ * or you may write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
+ */
+
+#include
+#include
+#include
+
+class PROGRESS_REPORTER;
+struct BACKGROUND_JOB;
+
+class UPDATE_MANAGER
+{
+public:
+ UPDATE_MANAGER();
+
+ void CheckForUpdate();
+ int PostRequest( const wxString& aUrl, std::string aRequestBody, std::ostream* aOutput,
+ PROGRESS_REPORTER* aReporter, const size_t aSizeLimit );
+
+private:
+ std::atomic m_working;
+ std::shared_ptr m_updateBackgroundJob;
+};
\ No newline at end of file