Browse Source
ADDED: KiCad update check
ADDED: KiCad update check
Fixes https://gitlab.com/kicad/code/kicad/-/issues/15026newinvert
29 changed files with 1401 additions and 100 deletions
-
6common/CMakeLists.txt
-
24common/dialogs/panel_common_settings_base.cpp
-
206common/dialogs/panel_common_settings_base.fbp
-
3common/dialogs/panel_common_settings_base.h
-
15common/dialogs/panel_packages_and_updates.cpp
-
12common/dialogs/panel_packages_and_updates.h
-
39common/dialogs/panel_packages_and_updates_base.cpp
-
231common/dialogs/panel_packages_and_updates_base.fbp
-
13common/dialogs/panel_packages_and_updates_base.h
-
6common/eda_base_frame.cpp
-
10common/http_lib/http_lib_connection.cpp
-
18common/kicad_curl/kicad_curl_easy.cpp
-
4common/notifications_manager.cpp
-
3common/settings/common_settings.cpp
-
8common/settings/kicad_settings.cpp
-
9include/kicad_curl/kicad_curl_easy.h
-
1include/settings/common_settings.h
-
20include/settings/kicad_settings.h
-
3kicad/CMakeLists.txt
-
55kicad/dialogs/dialog_update_check_prompt.cpp
-
40kicad/dialogs/dialog_update_check_prompt.h
-
65kicad/dialogs/dialog_update_check_prompt_base.cpp
-
313kicad/dialogs/dialog_update_check_prompt_base.fbp
-
50kicad/dialogs/dialog_update_check_prompt_base.h
-
26kicad/kicad_manager_frame.cpp
-
2kicad/kicad_manager_frame.h
-
23kicad/pcm/CMakeLists.txt
-
252kicad/update_manager.cpp
-
44kicad/update_manager.h
@ -0,0 +1,55 @@ |
|||
/*
|
|||
* This program source code file is part of KiCad, a free EDA CAD application. |
|||
* |
|||
* Copyright (C) 2023 Mark Roszko <mark.roszko@gmail.com> |
|||
* 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 <dialogs/dialog_update_check_prompt.h>
|
|||
#include <settings/settings_manager.h>
|
|||
#include <settings/kicad_settings.h>
|
|||
#include <pgm_base.h>
|
|||
|
|||
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<KICAD_SETTINGS>(); |
|||
|
|||
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; |
|||
} |
@ -0,0 +1,40 @@ |
|||
/* |
|||
* This program source code file is part of KiCad, a free EDA CAD application. |
|||
* |
|||
* Copyright (C) 2023 Mark Roszko <mark.roszko@gmail.com> |
|||
* 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 <dialogs/dialog_update_check_prompt_base.h> |
|||
|
|||
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 |
@ -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() |
|||
{ |
|||
} |
@ -0,0 +1,313 @@ |
|||
<?xml version="1.0" encoding="UTF-8" standalone="yes" ?> |
|||
<wxFormBuilder_Project> |
|||
<FileVersion major="1" minor="16" /> |
|||
<object class="Project" expanded="1"> |
|||
<property name="class_decoration"></property> |
|||
<property name="code_generation">C++</property> |
|||
<property name="disconnect_events">1</property> |
|||
<property name="disconnect_mode">source_name</property> |
|||
<property name="disconnect_php_events">0</property> |
|||
<property name="disconnect_python_events">0</property> |
|||
<property name="embedded_files_path">res</property> |
|||
<property name="encoding">UTF-8</property> |
|||
<property name="event_generation">connect</property> |
|||
<property name="file">dialog_update_check_prompt_base</property> |
|||
<property name="first_id">1000</property> |
|||
<property name="help_provider">none</property> |
|||
<property name="image_path_wrapper_function_name"></property> |
|||
<property name="indent_with_spaces"></property> |
|||
<property name="internationalize">1</property> |
|||
<property name="name">dialog_update_check_prompt_base</property> |
|||
<property name="namespace"></property> |
|||
<property name="path">.</property> |
|||
<property name="precompiled_header"></property> |
|||
<property name="relative_path">1</property> |
|||
<property name="skip_lua_events">1</property> |
|||
<property name="skip_php_events">1</property> |
|||
<property name="skip_python_events">1</property> |
|||
<property name="ui_table">UI</property> |
|||
<property name="use_array_enum">0</property> |
|||
<property name="use_enum">0</property> |
|||
<property name="use_microsoft_bom">0</property> |
|||
<object class="Dialog" expanded="1"> |
|||
<property name="aui_managed">0</property> |
|||
<property name="aui_manager_style">wxAUI_MGR_DEFAULT</property> |
|||
<property name="bg"></property> |
|||
<property name="center">wxBOTH</property> |
|||
<property name="context_help"></property> |
|||
<property name="context_menu">1</property> |
|||
<property name="enabled">1</property> |
|||
<property name="event_handler">impl_virtual</property> |
|||
<property name="extra_style"></property> |
|||
<property name="fg"></property> |
|||
<property name="font"></property> |
|||
<property name="hidden">0</property> |
|||
<property name="id">wxID_ANY</property> |
|||
<property name="maximum_size"></property> |
|||
<property name="minimum_size"></property> |
|||
<property name="name">DIALOG_UPDATE_CHECK_PROMPT_BASE</property> |
|||
<property name="pos"></property> |
|||
<property name="size">-1,-1</property> |
|||
<property name="style">wxDEFAULT_DIALOG_STYLE</property> |
|||
<property name="subclass">DIALOG_SHIM; dialog_shim.h</property> |
|||
<property name="title">Check for Updates</property> |
|||
<property name="tooltip"></property> |
|||
<property name="two_step_creation">0</property> |
|||
<property name="window_extra_style"></property> |
|||
<property name="window_name"></property> |
|||
<property name="window_style"></property> |
|||
<object class="wxBoxSizer" expanded="1"> |
|||
<property name="minimum_size"></property> |
|||
<property name="name">bSizerMain</property> |
|||
<property name="orient">wxVERTICAL</property> |
|||
<property name="permission">none</property> |
|||
<object class="sizeritem" expanded="1"> |
|||
<property name="border">5</property> |
|||
<property name="flag">wxEXPAND|wxALL</property> |
|||
<property name="proportion">1</property> |
|||
<object class="wxFlexGridSizer" expanded="1"> |
|||
<property name="cols">2</property> |
|||
<property name="flexible_direction">wxBOTH</property> |
|||
<property name="growablecols"></property> |
|||
<property name="growablerows"></property> |
|||
<property name="hgap">0</property> |
|||
<property name="minimum_size"></property> |
|||
<property name="name">fgSizer4</property> |
|||
<property name="non_flexible_grow_mode">wxFLEX_GROWMODE_SPECIFIED</property> |
|||
<property name="permission">none</property> |
|||
<property name="rows">0</property> |
|||
<property name="vgap">10</property> |
|||
<object class="sizeritem" expanded="1"> |
|||
<property name="border">5</property> |
|||
<property name="flag">wxEXPAND|wxRIGHT</property> |
|||
<property name="proportion">1</property> |
|||
<object class="wxBoxSizer" expanded="1"> |
|||
<property name="minimum_size"></property> |
|||
<property name="name">bSizer4</property> |
|||
<property name="orient">wxVERTICAL</property> |
|||
<property name="permission">none</property> |
|||
<object class="sizeritem" expanded="1"> |
|||
<property name="border">5</property> |
|||
<property name="flag">wxALL</property> |
|||
<property name="proportion">0</property> |
|||
<object class="wxStaticText" expanded="1"> |
|||
<property name="BottomDockable">1</property> |
|||
<property name="LeftDockable">1</property> |
|||
<property name="RightDockable">1</property> |
|||
<property name="TopDockable">1</property> |
|||
<property name="aui_layer"></property> |
|||
<property name="aui_name"></property> |
|||
<property name="aui_position"></property> |
|||
<property name="aui_row"></property> |
|||
<property name="best_size"></property> |
|||
<property name="bg"></property> |
|||
<property name="caption"></property> |
|||
<property name="caption_visible">1</property> |
|||
<property name="center_pane">0</property> |
|||
<property name="close_button">1</property> |
|||
<property name="context_help"></property> |
|||
<property name="context_menu">1</property> |
|||
<property name="default_pane">0</property> |
|||
<property name="dock">Dock</property> |
|||
<property name="dock_fixed">0</property> |
|||
<property name="docking">Left</property> |
|||
<property name="enabled">1</property> |
|||
<property name="fg"></property> |
|||
<property name="floatable">1</property> |
|||
<property name="font"></property> |
|||
<property name="gripper">0</property> |
|||
<property name="hidden">0</property> |
|||
<property name="id">wxID_ANY</property> |
|||
<property name="label">Would you like to automatically check for updates on startup?</property> |
|||
<property name="markup">0</property> |
|||
<property name="max_size"></property> |
|||
<property name="maximize_button">0</property> |
|||
<property name="maximum_size"></property> |
|||
<property name="min_size"></property> |
|||
<property name="minimize_button">0</property> |
|||
<property name="minimum_size"></property> |
|||
<property name="moveable">1</property> |
|||
<property name="name">m_messageLine1</property> |
|||
<property name="pane_border">1</property> |
|||
<property name="pane_position"></property> |
|||
<property name="pane_size"></property> |
|||
<property name="permission">protected</property> |
|||
<property name="pin_button">1</property> |
|||
<property name="pos"></property> |
|||
<property name="resize">Resizable</property> |
|||
<property name="show">1</property> |
|||
<property name="size"></property> |
|||
<property name="style"></property> |
|||
<property name="subclass">; ; forward_declare</property> |
|||
<property name="toolbar_pane">0</property> |
|||
<property name="tooltip"></property> |
|||
<property name="window_extra_style"></property> |
|||
<property name="window_name"></property> |
|||
<property name="window_style"></property> |
|||
<property name="wrap">-1</property> |
|||
</object> |
|||
</object> |
|||
<object class="sizeritem" expanded="1"> |
|||
<property name="border">5</property> |
|||
<property name="flag">wxALL</property> |
|||
<property name="proportion">0</property> |
|||
<object class="wxCheckBox" expanded="1"> |
|||
<property name="BottomDockable">1</property> |
|||
<property name="LeftDockable">1</property> |
|||
<property name="RightDockable">1</property> |
|||
<property name="TopDockable">1</property> |
|||
<property name="aui_layer"></property> |
|||
<property name="aui_name"></property> |
|||
<property name="aui_position"></property> |
|||
<property name="aui_row"></property> |
|||
<property name="best_size"></property> |
|||
<property name="bg"></property> |
|||
<property name="caption"></property> |
|||
<property name="caption_visible">1</property> |
|||
<property name="center_pane">0</property> |
|||
<property name="checked">0</property> |
|||
<property name="close_button">1</property> |
|||
<property name="context_help"></property> |
|||
<property name="context_menu">1</property> |
|||
<property name="default_pane">0</property> |
|||
<property name="dock">Dock</property> |
|||
<property name="dock_fixed">0</property> |
|||
<property name="docking">Left</property> |
|||
<property name="enabled">1</property> |
|||
<property name="fg"></property> |
|||
<property name="floatable">1</property> |
|||
<property name="font"></property> |
|||
<property name="gripper">0</property> |
|||
<property name="hidden">0</property> |
|||
<property name="id">wxID_ANY</property> |
|||
<property name="label">KiCad</property> |
|||
<property name="max_size"></property> |
|||
<property name="maximize_button">0</property> |
|||
<property name="maximum_size"></property> |
|||
<property name="min_size"></property> |
|||
<property name="minimize_button">0</property> |
|||
<property name="minimum_size"></property> |
|||
<property name="moveable">1</property> |
|||
<property name="name">m_cbKiCadUpdates</property> |
|||
<property name="pane_border">1</property> |
|||
<property name="pane_position"></property> |
|||
<property name="pane_size"></property> |
|||
<property name="permission">protected</property> |
|||
<property name="pin_button">1</property> |
|||
<property name="pos"></property> |
|||
<property name="resize">Resizable</property> |
|||
<property name="show">1</property> |
|||
<property name="size"></property> |
|||
<property name="style"></property> |
|||
<property name="subclass">; ; forward_declare</property> |
|||
<property name="toolbar_pane">0</property> |
|||
<property name="tooltip"></property> |
|||
<property name="validator_data_type"></property> |
|||
<property name="validator_style">wxFILTER_NONE</property> |
|||
<property name="validator_type">wxDefaultValidator</property> |
|||
<property name="validator_variable"></property> |
|||
<property name="window_extra_style"></property> |
|||
<property name="window_name"></property> |
|||
<property name="window_style"></property> |
|||
</object> |
|||
</object> |
|||
<object class="sizeritem" expanded="1"> |
|||
<property name="border">5</property> |
|||
<property name="flag">wxALL</property> |
|||
<property name="proportion">0</property> |
|||
<object class="wxCheckBox" expanded="1"> |
|||
<property name="BottomDockable">1</property> |
|||
<property name="LeftDockable">1</property> |
|||
<property name="RightDockable">1</property> |
|||
<property name="TopDockable">1</property> |
|||
<property name="aui_layer"></property> |
|||
<property name="aui_name"></property> |
|||
<property name="aui_position"></property> |
|||
<property name="aui_row"></property> |
|||
<property name="best_size"></property> |
|||
<property name="bg"></property> |
|||
<property name="caption"></property> |
|||
<property name="caption_visible">1</property> |
|||
<property name="center_pane">0</property> |
|||
<property name="checked">0</property> |
|||
<property name="close_button">1</property> |
|||
<property name="context_help"></property> |
|||
<property name="context_menu">1</property> |
|||
<property name="default_pane">0</property> |
|||
<property name="dock">Dock</property> |
|||
<property name="dock_fixed">0</property> |
|||
<property name="docking">Left</property> |
|||
<property name="enabled">1</property> |
|||
<property name="fg"></property> |
|||
<property name="floatable">1</property> |
|||
<property name="font"></property> |
|||
<property name="gripper">0</property> |
|||
<property name="hidden">0</property> |
|||
<property name="id">wxID_ANY</property> |
|||
<property name="label">Plugin and Content Manager</property> |
|||
<property name="max_size"></property> |
|||
<property name="maximize_button">0</property> |
|||
<property name="maximum_size"></property> |
|||
<property name="min_size"></property> |
|||
<property name="minimize_button">0</property> |
|||
<property name="minimum_size"></property> |
|||
<property name="moveable">1</property> |
|||
<property name="name">m_cbPCMUpdates</property> |
|||
<property name="pane_border">1</property> |
|||
<property name="pane_position"></property> |
|||
<property name="pane_size"></property> |
|||
<property name="permission">protected</property> |
|||
<property name="pin_button">1</property> |
|||
<property name="pos"></property> |
|||
<property name="resize">Resizable</property> |
|||
<property name="show">1</property> |
|||
<property name="size"></property> |
|||
<property name="style"></property> |
|||
<property name="subclass">; ; forward_declare</property> |
|||
<property name="toolbar_pane">0</property> |
|||
<property name="tooltip"></property> |
|||
<property name="validator_data_type"></property> |
|||
<property name="validator_style">wxFILTER_NONE</property> |
|||
<property name="validator_type">wxDefaultValidator</property> |
|||
<property name="validator_variable"></property> |
|||
<property name="window_extra_style"></property> |
|||
<property name="window_name"></property> |
|||
<property name="window_style"></property> |
|||
</object> |
|||
</object> |
|||
</object> |
|||
</object> |
|||
<object class="sizeritem" expanded="1"> |
|||
<property name="border">5</property> |
|||
<property name="flag">wxEXPAND</property> |
|||
<property name="proportion">1</property> |
|||
<object class="spacer" expanded="1"> |
|||
<property name="height">0</property> |
|||
<property name="permission">protected</property> |
|||
<property name="width">0</property> |
|||
</object> |
|||
</object> |
|||
<object class="sizeritem" expanded="1"> |
|||
<property name="border">5</property> |
|||
<property name="flag">wxEXPAND</property> |
|||
<property name="proportion">1</property> |
|||
<object class="wxStdDialogButtonSizer" expanded="1"> |
|||
<property name="Apply">0</property> |
|||
<property name="Cancel">1</property> |
|||
<property name="ContextHelp">0</property> |
|||
<property name="Help">0</property> |
|||
<property name="No">0</property> |
|||
<property name="OK">1</property> |
|||
<property name="Save">0</property> |
|||
<property name="Yes">0</property> |
|||
<property name="minimum_size"></property> |
|||
<property name="name">m_sdbSizer</property> |
|||
<property name="permission">protected</property> |
|||
</object> |
|||
</object> |
|||
</object> |
|||
</object> |
|||
</object> |
|||
</object> |
|||
</object> |
|||
</wxFormBuilder_Project> |
@ -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 <wx/artprov.h> |
|||
#include <wx/xrc/xmlres.h> |
|||
#include <wx/intl.h> |
|||
#include "dialog_shim.h" |
|||
#include <wx/string.h> |
|||
#include <wx/stattext.h> |
|||
#include <wx/gdicmn.h> |
|||
#include <wx/font.h> |
|||
#include <wx/colour.h> |
|||
#include <wx/settings.h> |
|||
#include <wx/checkbox.h> |
|||
#include <wx/sizer.h> |
|||
#include <wx/button.h> |
|||
#include <wx/dialog.h> |
|||
|
|||
/////////////////////////////////////////////////////////////////////////// |
|||
|
|||
|
|||
/////////////////////////////////////////////////////////////////////////////// |
|||
/// 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(); |
|||
|
|||
}; |
|||
|
@ -0,0 +1,252 @@ |
|||
/*
|
|||
* This program source code file is part of KiCad, a free EDA CAD application. |
|||
* |
|||
* Copyright (C) 2023 Mark Roszko <mark.roszko@gmail.com> |
|||
* 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 <update_manager.h>
|
|||
#include <pgm_base.h>
|
|||
|
|||
#include <string>
|
|||
#include <sstream>
|
|||
|
|||
#include "settings/settings_manager.h"
|
|||
#include "settings/kicad_settings.h"
|
|||
#include <notifications_manager.h>
|
|||
|
|||
#include <kicad_curl/kicad_curl.h>
|
|||
#include <kicad_curl/kicad_curl_easy.h>
|
|||
#include <progress_reporter.h>
|
|||
|
|||
#include <nlohmann_json/nlohmann/json.hpp>
|
|||
#include <core/json_serializers.h>
|
|||
|
|||
#include <wx/log.h>
|
|||
#include <wx/event.h>
|
|||
#include <wx/filefn.h>
|
|||
#include <wx/translation.h>
|
|||
#include <wx/notifmsg.h>
|
|||
|
|||
#include <background_jobs_monitor.h>
|
|||
|
|||
#include <core/thread_pool.h>
|
|||
|
|||
#include <build_version.h>
|
|||
|
|||
|
|||
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<KICAD_SETTINGS>(); |
|||
|
|||
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<UPDATE_RESPONSE>(); |
|||
|
|||
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 ); |
|||
} |
@ -0,0 +1,44 @@ |
|||
/* |
|||
* This program source code file is part of KiCad, a free EDA CAD application. |
|||
* |
|||
* Copyright (C) 2023 Mark Roszko <mark.roszko@gmail.com> |
|||
* 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 <wx/string.h> |
|||
#include <atomic> |
|||
#include <memory> |
|||
|
|||
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<bool> m_working; |
|||
std::shared_ptr<BACKGROUND_JOB> m_updateBackgroundJob; |
|||
}; |
Write
Preview
Loading…
Cancel
Save
Reference in new issue