KiCad PCB EDA Suite
Loading...
Searching...
No Matches
pcm.cpp
Go to the documentation of this file.
1/*
2 * This program source code file is part of KiCad, a free EDA CAD application.
3 *
4 * Copyright (C) 2021 Andrew Lutsenko, anlutsenko at gmail dot com
5 * Copyright The KiCad Developers, see AUTHORS.txt for contributors.
6 *
7 * This program is free software: you can redistribute it and/or modify it
8 * under the terms of the GNU General Public License as published by the
9 * Free Software Foundation, either version 3 of the License, or (at your
10 * option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License along
18 * with this program. If not, see <http://www.gnu.org/licenses/>.
19 */
20
21// kicad_curl.h *must be* included before any wxWidgets header to avoid conflicts
22// at least on Windows/msys2
25
26#include "core/wx_stl_compat.h"
27#include <env_vars.h>
30#include "build_version.h"
31#include "paths.h"
32#include "pcm.h"
33#include "pgm_base.h"
34#include "picosha2.h"
36#include <wx_filename.h>
37
38#include <fstream>
39#include <iomanip>
40#include <memory>
41#include <wx/dir.h>
42#include <wx/filefn.h>
43#include <wx/image.h>
44#include <wx/mstream.h>
45#include <wx/tokenzr.h>
46#include <wx/wfstream.h>
47#include <wx/zipstrm.h>
48
49
55static const wxChar tracePcm[] = wxT( "KICAD_PCM" );
56
57
58const std::tuple<int, int, int> PLUGIN_CONTENT_MANAGER::m_kicad_version =
60
61
62class THROWING_ERROR_HANDLER : public nlohmann::json_schema::error_handler
63{
64 void error( const json::json_pointer& ptr, const json& instance,
65 const std::string& message ) override
66 {
67 throw std::invalid_argument( std::string( "At " ) + ptr.to_string() + ", value:\n"
68 + instance.dump() + "\n" + message + "\n" );
69 }
70};
71
72#include <locale_io.h>
74 std::function<void( int )> aAvailableUpdateCallback ) :
75 m_dialog( nullptr ),
76 m_availableUpdateCallback( aAvailableUpdateCallback )
77{
78 ReadEnvVar();
79
80 // Read and store pcm schema
81 wxFileName schema_file( PATHS::GetStockDataPath( true ), wxS( "pcm.v1.schema.json" ) );
82 schema_file.Normalize( FN_NORMALIZE_FLAGS | wxPATH_NORM_ENV_VARS );
83 schema_file.AppendDir( wxS( "schemas" ) );
84
85 m_schema_validator = std::make_unique<JSON_SCHEMA_VALIDATOR>( schema_file );
86
87 // Load currently installed packages
88 wxFileName f( PATHS::GetUserSettingsPath(), wxT( "installed_packages.json" ) );
89
90 if( f.FileExists() )
91 {
92 std::ifstream installed_stream( f.GetFullPath().fn_str() );
93 nlohmann::json installed;
94
95 try
96 {
97 installed_stream >> installed;
98
99 if( installed.contains( "packages" ) && installed["packages"].is_array() )
100 {
101 for( const auto& js_entry : installed["packages"] )
102 {
103 PCM_INSTALLATION_ENTRY entry = js_entry.get<PCM_INSTALLATION_ENTRY>();
104 m_installed.emplace( entry.package.identifier, entry );
105 }
106 }
107 }
108 catch( std::exception& e )
109 {
110 wxLogError( wxString::Format( _( "Error loading installed packages list: %s" ),
111 e.what() ) );
112 }
113 }
114
115 // As a fall back populate installed from names of directories
116
117 for( const wxString& dir : PCM_PACKAGE_DIRECTORIES )
118 {
119 wxFileName d( m_3rdparty_path, wxEmptyString );
120 d.AppendDir( dir );
121
122 if( d.DirExists() )
123 {
124 wxDir package_dir( d.GetPath() );
125
126 if( !package_dir.IsOpened() )
127 continue;
128
129 wxString subdir;
130 bool more = package_dir.GetFirst( &subdir, "", wxDIR_DIRS | wxDIR_HIDDEN );
131
132 while( more )
133 {
134 wxString actual_package_id = subdir;
135 actual_package_id.Replace( '_', '.' );
136
137 if( m_installed.find( actual_package_id ) == m_installed.end() )
138 {
140 wxFileName subdir_file( d.GetPath(), subdir );
141
142 // wxFileModificationTime bugs out on windows for directories
143 wxStructStat stat;
144 int stat_code = wxStat( subdir_file.GetFullPath(), &stat );
145
146 entry.package.name = subdir;
147 entry.package.identifier = actual_package_id;
148 entry.current_version = "0.0";
149 entry.repository_name = wxT( "<unknown>" );
150
151 if( stat_code == 0 )
152 entry.install_timestamp = stat.st_mtime;
153
154 PACKAGE_VERSION version;
155 version.version = "0.0";
156 version.status = PVS_STABLE;
158
159 entry.package.versions.emplace_back( version );
160
161 m_installed.emplace( actual_package_id, entry );
162 }
163
164 more = package_dir.GetNext( &subdir );
165 }
166 }
167 }
168
169 // Calculate package compatibility
170 std::for_each( m_installed.begin(), m_installed.end(),
171 [&]( std::pair<const wxString, PCM_INSTALLATION_ENTRY>& entry )
172 {
173 PreparePackage( entry.second.package );
174 } );
175}
176
177
179{
180 // Get 3rd party path
181 const ENV_VAR_MAP& env = Pgm().GetLocalEnvVariables();
182
183 if( std::optional<wxString> v = ENV_VAR::GetVersionedEnvVarValue( env, wxT( "3RD_PARTY" ) ) )
184 m_3rdparty_path = *v;
185 else
187}
188
189
190bool PLUGIN_CONTENT_MANAGER::DownloadToStream( const wxString& aUrl, std::ostream* aOutput,
191 PROGRESS_REPORTER* aReporter,
192 const size_t aSizeLimit )
193{
194 bool size_exceeded = false;
195
196 TRANSFER_CALLBACK callback = [&]( size_t dltotal, size_t dlnow, size_t ultotal, size_t ulnow )
197 {
198 if( aSizeLimit > 0 && ( dltotal > aSizeLimit || dlnow > aSizeLimit ) )
199 {
200 size_exceeded = true;
201
202 // Non zero return means abort.
203 return true;
204 }
205
206 if( dltotal > 1000 )
207 {
208 aReporter->SetCurrentProgress( dlnow / (double) dltotal );
209 aReporter->Report( wxString::Format( _( "Downloading %lld/%lld kB" ), dlnow / 1000,
210 dltotal / 1000 ) );
211 }
212 else
213 {
214 aReporter->SetCurrentProgress( 0.0 );
215 }
216
217 return !aReporter->KeepRefreshing();
218 };
219
220 KICAD_CURL_EASY curl;
221 curl.SetOutputStream( aOutput );
222 curl.SetURL( aUrl.ToUTF8().data() );
223 curl.SetFollowRedirects( true );
224 curl.SetTransferCallback( callback, 250000L );
225
226 int code = curl.Perform();
227
228 if( !aReporter->IsCancelled() )
229 aReporter->SetCurrentProgress( 1.0 );
230
231 if( code != CURLE_OK )
232 {
233 if( m_dialog )
234 {
235 if( code == CURLE_ABORTED_BY_CALLBACK && size_exceeded )
236 wxMessageBox( _( "Download is too large." ) );
237 else if( code != CURLE_ABORTED_BY_CALLBACK )
238 wxLogError( wxString( curl.GetErrorText( code ) ) );
239 }
240
241 return false;
242 }
243
244 return true;
245}
246
247
248bool PLUGIN_CONTENT_MANAGER::FetchRepository( const wxString& aUrl, PCM_REPOSITORY& aRepository,
249 PROGRESS_REPORTER* aReporter )
250{
251 std::stringstream repository_stream;
252
253 aReporter->SetTitle( _( "Fetching repository" ) );
254
255 if( !DownloadToStream( aUrl, &repository_stream, aReporter, 20480 ) )
256 return false;
257
258 nlohmann::json repository_json;
259
260 try
261 {
262 repository_stream >> repository_json;
263
264 ValidateJson( repository_json, nlohmann::json_uri( "#/definitions/Repository" ) );
265
266 aRepository = repository_json.get<PCM_REPOSITORY>();
267 }
268 catch( const std::exception& e )
269 {
270 if( m_dialog )
271 {
272 wxLogError( _( "Unable to parse repository: %s" ), e.what() );
273 wxLogError( _( "The given repository URL does not look like a valid KiCad package "
274 "repository. Please double check the URL." ) );
275 }
276
277 return false;
278 }
279
280 return true;
281}
282
283
284void PLUGIN_CONTENT_MANAGER::ValidateJson( const nlohmann::json& aJson,
285 const nlohmann::json_uri& aUri ) const
286{
287 THROWING_ERROR_HANDLER error_handler;
288 m_schema_validator->Validate( aJson, error_handler, aUri );
289}
290
291
292bool PLUGIN_CONTENT_MANAGER::fetchPackages( const wxString& aUrl,
293 const std::optional<wxString>& aHash,
294 std::vector<PCM_PACKAGE>& aPackages,
295 PROGRESS_REPORTER* aReporter )
296{
297 std::stringstream packages_stream;
298
299 aReporter->SetTitle( _( "Fetching repository packages" ) );
300
301 if( !DownloadToStream( aUrl, &packages_stream, aReporter ) )
302 {
303 if( m_dialog )
304 wxLogError( _( "Unable to load repository packages url." ) );
305
306 return false;
307 }
308
309 std::istringstream isstream( packages_stream.str() );
310
311 if( aHash && !VerifyHash( isstream, *aHash ) )
312 {
313 if( m_dialog )
314 wxLogError( _( "Packages hash doesn't match. Repository may be corrupted." ) );
315
316 return false;
317 }
318
319 try
320 {
321 nlohmann::json packages_json = nlohmann::json::parse( packages_stream.str() );
322 ValidateJson( packages_json, nlohmann::json_uri( "#/definitions/PackageArray" ) );
323
324 aPackages = packages_json["packages"].get<std::vector<PCM_PACKAGE>>();
325 }
326 catch( std::exception& e )
327 {
328 if( m_dialog )
329 {
330 wxLogError( wxString::Format( _( "Unable to parse packages metadata:\n\n%s" ),
331 e.what() ) );
332 }
333
334 return false;
335 }
336
337 return true;
338}
339
340
341bool PLUGIN_CONTENT_MANAGER::VerifyHash( std::istream& aStream, const wxString& aHash ) const
342{
343 std::vector<unsigned char> bytes( picosha2::k_digest_size );
344
345 picosha2::hash256( std::istreambuf_iterator<char>( aStream ), std::istreambuf_iterator<char>(),
346 bytes.begin(), bytes.end() );
347 std::string hex_str = picosha2::bytes_to_hex_string( bytes.begin(), bytes.end() );
348
349 return aHash.compare( hex_str ) == 0;
350}
351
352
353const PCM_REPOSITORY&
354PLUGIN_CONTENT_MANAGER::getCachedRepository( const wxString& aRepositoryId ) const
355{
356 wxASSERT_MSG( m_repository_cache.find( aRepositoryId ) != m_repository_cache.end(),
357 wxT( "Repository is not cached." ) );
358
359 return m_repository_cache.at( aRepositoryId );
360}
361
362
363bool PLUGIN_CONTENT_MANAGER::CacheRepository( const wxString& aRepositoryId )
364{
365 if( m_repository_cache.find( aRepositoryId ) != m_repository_cache.end() )
366 return true;
367
368 const auto repository_tuple =
369 std::find_if( m_repository_list.begin(), m_repository_list.end(),
370 [&aRepositoryId]( const std::tuple<wxString, wxString, wxString>& t )
371 {
372 return std::get<0>( t ) == aRepositoryId;
373 } );
374
375 if( repository_tuple == m_repository_list.end() )
376 return false;
377
378 wxString url = std::get<2>( *repository_tuple );
379
380 nlohmann::json js;
381 PCM_REPOSITORY current_repo;
382 PCM_REPOSITORY& current_repo_ref = current_repo;
383
384 std::shared_ptr<PROGRESS_REPORTER> reporter;
385
386 if( m_dialog )
387 reporter = std::make_shared<WX_PROGRESS_REPORTER>( m_dialog, wxEmptyString, 1 );
388 else
389 reporter = m_updateBackgroundJob->m_reporter;
390
391 if( !FetchRepository( url, current_repo, reporter.get() ) )
392 return false;
393
394 bool packages_cache_exists = false;
395
396 // First load repository data from local filesystem if available.
397 wxFileName repo_cache = wxFileName( PATHS::GetUserCachePath(), wxT( "repository.json" ) );
398 repo_cache.AppendDir( wxT( "pcm" ) );
399 repo_cache.AppendDir( aRepositoryId );
400 wxFileName packages_cache( repo_cache.GetPath(), wxT( "packages.json" ) );
401
402 if( repo_cache.FileExists() && packages_cache.FileExists() )
403 {
404 std::ifstream repo_stream( repo_cache.GetFullPath().fn_str() );
405 PCM_REPOSITORY saved_repo;
406 try
407 {
408 repo_stream >> js;
409 saved_repo = js.get<PCM_REPOSITORY>();
410 }
411 catch( ... )
412 {
413 if( m_dialog )
414 wxLogError( _( "Failed to parse locally stored repository.json." ) );
415 }
416
417 if( saved_repo.packages.update_timestamp == current_repo.packages.update_timestamp )
418 {
419 // Cached repo is up to date, use data on disk
420 js.clear();
421 std::ifstream packages_cache_stream( packages_cache.GetFullPath().fn_str() );
422
423 try
424 {
425 packages_cache_stream >> js;
426 saved_repo.package_list = js["packages"].get<std::vector<PCM_PACKAGE>>();
427
428 for( size_t i = 0; i < saved_repo.package_list.size(); i++ )
429 {
430 PreparePackage( saved_repo.package_list[i] );
431 saved_repo.package_map[saved_repo.package_list[i].identifier] = i;
432 }
433
434 m_repository_cache[aRepositoryId] = std::move( saved_repo );
435
436 packages_cache_exists = true;
437 }
438 catch( ... )
439 {
440 if( m_dialog )
441 {
442 wxLogError( _( "Packages cache for current repository is corrupted, it will "
443 "be redownloaded." ) );
444 }
445 }
446 }
447 }
448
449 if( !packages_cache_exists )
450 {
451 // Cache doesn't exist or is out of date
452 if( !fetchPackages( current_repo.packages.url, current_repo.packages.sha256,
453 current_repo.package_list, reporter.get() ) )
454 {
455 return false;
456 }
457
458 for( size_t i = 0; i < current_repo.package_list.size(); i++ )
459 {
460 PreparePackage( current_repo.package_list[i] );
461 current_repo.package_map[current_repo.package_list[i].identifier] = i;
462 }
463
464 repo_cache.Mkdir( wxS_DIR_DEFAULT, wxPATH_MKDIR_FULL );
465
466 std::ofstream repo_cache_stream( repo_cache.GetFullPath().fn_str() );
467 repo_cache_stream << std::setw( 4 ) << nlohmann::json( current_repo ) << std::endl;
468
469 std::ofstream packages_cache_stream( packages_cache.GetFullPath().fn_str() );
470 js.clear();
471 js["packages"] = nlohmann::json( current_repo.package_list );
472 packages_cache_stream << std::setw( 4 ) << js << std::endl;
473
474 m_repository_cache[aRepositoryId] = std::move( current_repo );
475 current_repo_ref = m_repository_cache[aRepositoryId];
476 }
477
478 if( current_repo_ref.resources )
479 {
480 // Check resources file date, redownload if needed
481 PCM_RESOURCE_REFERENCE& resources = *current_repo_ref.resources;
482
483 wxFileName resource_file( repo_cache.GetPath(), wxT( "resources.zip" ) );
484
485 time_t mtime = 0;
486
487 if( resource_file.FileExists() )
488 mtime = wxFileModificationTime( resource_file.GetFullPath() );
489
490 if( mtime + 600 < getCurrentTimestamp() && mtime < (time_t) resources.update_timestamp )
491 {
492 std::ofstream resources_stream( resource_file.GetFullPath().fn_str(),
493 std::ios_base::binary );
494
495 reporter->SetTitle( _( "Downloading resources" ) );
496
497 // 100 Mb resource file limit
498 bool success = DownloadToStream( resources.url, &resources_stream, reporter.get(),
499 100 * 1024 * 1024 );
500
501 resources_stream.close();
502
503 if( success )
504 {
505 std::ifstream read_stream( resource_file.GetFullPath().fn_str(),
506 std::ios_base::binary );
507
508
509 if( resources.sha256 && !VerifyHash( read_stream, *resources.sha256 ) )
510 {
511 read_stream.close();
512
513 if( m_dialog )
514 {
515 wxLogError( _( "Resources file hash doesn't match and will not be used. "
516 "Repository may be corrupted." ) );
517 }
518
519 wxRemoveFile( resource_file.GetFullPath() );
520 }
521 }
522 else
523 {
524 // Not critical, just clean up the file
525 wxRemoveFile( resource_file.GetFullPath() );
526 }
527 }
528 }
529
530 updateInstalledPackagesMetadata( aRepositoryId );
531
532 return true;
533}
534
535
537{
538 const PCM_REPOSITORY* repository;
539
540 try
541 {
542 repository = &getCachedRepository( aRepositoryId );
543 }
544 catch( ... )
545 {
546 wxLogTrace( tracePcm, wxS( "Invalid/Missing repository " ) + aRepositoryId );
547 return;
548 }
549
550 for( std::pair<const wxString, PCM_INSTALLATION_ENTRY>& pair : m_installed )
551 {
552 PCM_INSTALLATION_ENTRY& entry = pair.second;
553
554 // If current package is not from this repository, skip it
555 if( entry.repository_id != aRepositoryId )
556 continue;
557
558 // If current package is no longer in this repository, keep it as is
559 if( repository->package_map.count( entry.package.identifier ) == 0 )
560 continue;
561
562 std::optional<PACKAGE_VERSION> current_version;
563
564 auto current_version_it =
565 std::find_if( entry.package.versions.begin(), entry.package.versions.end(),
566 [&]( const PACKAGE_VERSION& version )
567 {
568 return version.version == entry.current_version;
569 } );
570
571 if( current_version_it != entry.package.versions.end() )
572 current_version = *current_version_it; // copy
573
574 // Copy repository metadata into installation entry
575 entry.package = repository->package_list[repository->package_map.at( entry.package.identifier )];
576
577 // Insert current version if it's missing from repository metadata
578 current_version_it =
579 std::find_if( entry.package.versions.begin(), entry.package.versions.end(),
580 [&]( const PACKAGE_VERSION& version )
581 {
582 return version.version == entry.current_version;
583 } );
584
585 if( current_version_it == entry.package.versions.end() )
586 {
587 entry.package.versions.emplace_back( *current_version );
588
589 // Re-sort the versions by descending version
590 std::sort( entry.package.versions.begin(), entry.package.versions.end(),
591 []( const PACKAGE_VERSION& a, const PACKAGE_VERSION& b )
592 {
593 return a.parsed_version > b.parsed_version;
594 } );
595 }
596 }
597}
598
599
601{
602 // Parse package version strings
603 for( PACKAGE_VERSION& ver : aPackage.versions )
604 {
605 int epoch = 0, major = 0, minor = 0, patch = 0;
606
607 if( ver.version_epoch )
608 epoch = *ver.version_epoch;
609
610 wxStringTokenizer version_tokenizer( ver.version, wxT( "." ) );
611
612 major = wxAtoi( version_tokenizer.GetNextToken() );
613
614 if( version_tokenizer.HasMoreTokens() )
615 minor = wxAtoi( version_tokenizer.GetNextToken() );
616
617 if( version_tokenizer.HasMoreTokens() )
618 patch = wxAtoi( version_tokenizer.GetNextToken() );
619
620 ver.parsed_version = std::make_tuple( epoch, major, minor, patch );
621
622 // Determine compatibility
623 ver.compatible = true;
624
625 auto parse_version_tuple =
626 []( const wxString& version, int deflt )
627 {
628 int ver_major = deflt;
629 int ver_minor = deflt;
630 int ver_patch = deflt;
631
632 wxStringTokenizer tokenizer( version, wxT( "." ) );
633
634 ver_major = wxAtoi( tokenizer.GetNextToken() );
635
636 if( tokenizer.HasMoreTokens() )
637 ver_minor = wxAtoi( tokenizer.GetNextToken() );
638
639 if( tokenizer.HasMoreTokens() )
640 ver_patch = wxAtoi( tokenizer.GetNextToken() );
641
642 return std::tuple<int, int, int>( ver_major, ver_minor, ver_patch );
643 };
644
645 if( parse_version_tuple( ver.kicad_version, 0 ) > m_kicad_version )
646 ver.compatible = false;
647
648 if( ver.kicad_version_max
649 && parse_version_tuple( *ver.kicad_version_max, 999 ) < m_kicad_version )
650 ver.compatible = false;
651
652#if defined( _WIN32 )
653 wxString platform = wxT( "windows" );
654#elif defined( __APPLE__ )
655 wxString platform = wxT( "macos" );
656#else
657 wxString platform = wxT( "linux" );
658#endif
659
660 if( ver.platforms.size() > 0
661 && std::find( ver.platforms.begin(), ver.platforms.end(), platform )
662 == ver.platforms.end() )
663 {
664 ver.compatible = false;
665 }
666 }
667
668 // Sort by descending version
669 std::sort( aPackage.versions.begin(), aPackage.versions.end(),
670 []( const PACKAGE_VERSION& a, const PACKAGE_VERSION& b )
671 {
672 return a.parsed_version > b.parsed_version;
673 } );
674}
675
676
677const std::vector<PCM_PACKAGE>&
678PLUGIN_CONTENT_MANAGER::GetRepositoryPackages( const wxString& aRepositoryId ) const
679{
680 static std::vector<PCM_PACKAGE> empty{};
681
682 try
683 {
684 return getCachedRepository( aRepositoryId ).package_list;
685 }
686 catch( ... )
687 {
688 return empty;
689 }
690}
691
692
694{
695 // Clean up cache folder if repository is not in new list
696 for( const std::tuple<wxString, wxString, wxString>& entry : m_repository_list )
697 {
698 auto it = std::find_if( aRepositories.begin(), aRepositories.end(),
699 [&]( const auto& new_entry )
700 {
701 return new_entry.first == std::get<1>( entry );
702 } );
703
704 if( it == aRepositories.end() )
705 {
706 DiscardRepositoryCache( std::get<0>( entry ) );
707 }
708 }
709
710 m_repository_list.clear();
711 m_repository_cache.clear();
712
713 for( const std::pair<wxString, wxString>& repo : aRepositories )
714 {
715 std::string url_sha = picosha2::hash256_hex_string( repo.second );
716 m_repository_list.push_back( std::make_tuple( url_sha.substr( 0, 16 ), repo.first,
717 repo.second ) );
718 }
719}
720
721
722void PLUGIN_CONTENT_MANAGER::DiscardRepositoryCache( const wxString& aRepositoryId )
723{
724 if( m_repository_cache.count( aRepositoryId ) > 0 )
725 m_repository_cache.erase( aRepositoryId );
726
727 wxFileName repo_cache = wxFileName( PATHS::GetUserCachePath(), "" );
728 repo_cache.AppendDir( wxT( "pcm" ) );
729 repo_cache.AppendDir( aRepositoryId );
730
731 if( repo_cache.DirExists() )
732 repo_cache.Rmdir( wxPATH_RMDIR_RECURSIVE );
733}
734
735
736void PLUGIN_CONTENT_MANAGER::MarkInstalled( const PCM_PACKAGE& aPackage, const wxString& aVersion,
737 const wxString& aRepositoryId )
738{
739 // In case of package update remove old data but keep pinned state
740 bool pinned = false;
741
742 if( m_installed.count( aPackage.identifier ) )
743 {
744 pinned = m_installed.at( aPackage.identifier ).pinned;
745 MarkUninstalled( aPackage );
746 }
747
749 entry.package = aPackage;
750 entry.current_version = aVersion;
751 entry.repository_id = aRepositoryId;
752
753 try
754 {
755 if( !aRepositoryId.IsEmpty() )
756 entry.repository_name = getCachedRepository( aRepositoryId ).name;
757 else
758 entry.repository_name = _( "Local file" );
759 }
760 catch( ... )
761 {
762 entry.repository_name = _( "Unknown" );
763 }
764
766 entry.pinned = pinned;
767
768 m_installed.emplace( aPackage.identifier, entry );
769}
770
771
773{
774 m_installed.erase( aPackage.identifier );
775}
776
777
779 const wxString& aPackageId )
780{
781 bool installed = m_installed.find( aPackageId ) != m_installed.end();
782
783 if( aRepositoryId.IsEmpty() || !CacheRepository( aRepositoryId ) )
784 return installed ? PPS_INSTALLED : PPS_UNAVAILABLE;
785
786 const PCM_REPOSITORY* repo;
787
788 try
789 {
790 repo = &getCachedRepository( aRepositoryId );
791 }
792 catch( ... )
793 {
794 return installed ? PPS_INSTALLED : PPS_UNAVAILABLE;
795 }
796
797 if( repo->package_map.count( aPackageId ) == 0 )
798 return installed ? PPS_INSTALLED : PPS_UNAVAILABLE;
799
800 const PCM_PACKAGE& pkg = repo->package_list[repo->package_map.at( aPackageId )];
801
802 if( installed )
803 {
804 // Package is installed, check for available updates at the same or
805 // higher (numerically lower) version stability level
806 wxString update_version = GetPackageUpdateVersion( pkg );
807
808 return update_version.IsEmpty() ? PPS_INSTALLED : PPS_UPDATE_AVAILABLE;
809 }
810 else
811 {
812 // Find any compatible version
813 auto ver_it = std::find_if( pkg.versions.begin(), pkg.versions.end(),
814 []( const PACKAGE_VERSION& ver )
815 {
816 return ver.compatible;
817 } );
818
819 return ver_it == pkg.versions.end() ? PPS_UNAVAILABLE : PPS_AVAILABLE;
820 }
821}
822
823
825{
826 wxASSERT_MSG( m_installed.find( aPackage.identifier ) != m_installed.end(),
827 wxT( "GetPackageUpdateVersion called on a not installed package" ) );
828
829 const PCM_INSTALLATION_ENTRY& entry = m_installed.at( aPackage.identifier );
830
831 auto installed_ver_it = std::find_if(
832 entry.package.versions.begin(), entry.package.versions.end(),
833 [&]( const PACKAGE_VERSION& ver )
834 {
835 return ver.version == entry.current_version;
836 } );
837
838 wxASSERT_MSG( installed_ver_it != entry.package.versions.end(),
839 wxT( "Installed package version not found" ) );
840
841 auto ver_it = std::find_if( aPackage.versions.begin(), aPackage.versions.end(),
842 [&]( const PACKAGE_VERSION& ver )
843 {
844 return ver.compatible
845 && installed_ver_it->status >= ver.status
846 && installed_ver_it->parsed_version < ver.parsed_version;
847 } );
848
849 return ver_it == aPackage.versions.end() ? wxString( wxT( "" ) ) : ver_it->version;
850}
851
853{
854 return std::chrono::duration_cast<std::chrono::seconds>(
855 std::chrono::system_clock::now().time_since_epoch() ).count();
856}
857
858
860{
861 try
862 {
863 nlohmann::json js;
864 js["packages"] = nlohmann::json::array();
865
866 for( std::pair<const wxString, PCM_INSTALLATION_ENTRY>& pair : m_installed )
867 {
868 js["packages"].emplace_back( pair.second );
869 }
870
871 wxFileName f( PATHS::GetUserSettingsPath(), wxT( "installed_packages.json" ) );
872 std::ofstream stream( f.GetFullPath().fn_str() );
873
874 stream << std::setw( 4 ) << js << std::endl;
875 }
876 catch( nlohmann::detail::exception& )
877 {
878 // Ignore
879 }
880}
881
882
883const std::vector<PCM_INSTALLATION_ENTRY> PLUGIN_CONTENT_MANAGER::GetInstalledPackages() const
884{
885 std::vector<PCM_INSTALLATION_ENTRY> v;
886
887 std::for_each( m_installed.begin(), m_installed.end(),
888 [&v]( const std::pair<const wxString, PCM_INSTALLATION_ENTRY>& entry )
889 {
890 v.push_back( entry.second );
891 } );
892
893 std::sort( v.begin(), v.end(),
894 []( const PCM_INSTALLATION_ENTRY& a, const PCM_INSTALLATION_ENTRY& b )
895 {
896 return ( a.install_timestamp < b.install_timestamp )
897 || ( a.install_timestamp == b.install_timestamp
898 && a.package.identifier < b.package.identifier );
899 } );
900
901 return v;
902}
903
904
905const wxString&
906PLUGIN_CONTENT_MANAGER::GetInstalledPackageVersion( const wxString& aPackageId ) const
907{
908 wxASSERT_MSG( m_installed.find( aPackageId ) != m_installed.end(),
909 wxT( "Installed package not found." ) );
910
911 return m_installed.at( aPackageId ).current_version;
912}
913
914
915bool PLUGIN_CONTENT_MANAGER::IsPackagePinned( const wxString& aPackageId ) const
916{
917 if( m_installed.find( aPackageId ) == m_installed.end() )
918 return false;
919
920 return m_installed.at( aPackageId ).pinned;
921}
922
923
924void PLUGIN_CONTENT_MANAGER::SetPinned( const wxString& aPackageId, const bool aPinned )
925{
926 if( m_installed.find( aPackageId ) == m_installed.end() )
927 return;
928
929 m_installed.at( aPackageId ).pinned = aPinned;
930}
931
932
934 const wxString& aSearchTerm )
935{
936 wxArrayString terms = wxStringTokenize( aSearchTerm.Lower(), wxS( " " ), wxTOKEN_STRTOK );
937 int rank = 0;
938
939 const auto find_term_matches =
940 [&]( const wxString& str )
941 {
942 int result = 0;
943 wxString lower = str.Lower();
944
945 for( const wxString& term : terms )
946 {
947 if( lower.Find( term ) != wxNOT_FOUND )
948 result += 1;
949 }
950
951 return result;
952 };
953
954 // Match on package id
955 if( terms.size() == 1 && terms[0] == aPackage.identifier )
956 rank += 10000;
957
958 if( terms.size() == 1 && find_term_matches( aPackage.identifier ) )
959 rank += 1000;
960
961 // Match on package name
962 rank += 500 * find_term_matches( aPackage.name );
963
964 // Match on tags
965 for( const std::string& tag : aPackage.tags )
966 rank += 100 * find_term_matches( wxString( tag ) );
967
968 // Match on package description
969 rank += 10 * find_term_matches( aPackage.description );
970 rank += 10 * find_term_matches( aPackage.description_full );
971
972 // Match on author/maintainer
973 rank += find_term_matches( aPackage.author.name );
974
975 if( aPackage.maintainer )
976 rank += 3 * find_term_matches( aPackage.maintainer->name );
977
978 // Match on resources
979 for( const std::pair<const std::string, wxString>& entry : aPackage.resources )
980 {
981 rank += find_term_matches( entry.first );
982 rank += find_term_matches( entry.second );
983 }
984
985 // Match on license
986 if( terms.size() == 1 && terms[0] == aPackage.license )
987 rank += 1;
988
989 return rank;
990}
991
992
993std::unordered_map<wxString, wxBitmap>
995{
996 std::unordered_map<wxString, wxBitmap> bitmaps;
997
998 wxFileName resources_file = wxFileName( PATHS::GetUserCachePath(), wxT( "resources.zip" ) );
999 resources_file.AppendDir( wxT( "pcm" ) );
1000 resources_file.AppendDir( aRepositoryId );
1001
1002 if( !resources_file.FileExists() )
1003 return bitmaps;
1004
1005 wxFFileInputStream stream( resources_file.GetFullPath() );
1006 wxZipInputStream zip( stream );
1007
1008 if( !zip.IsOk() || zip.GetTotalEntries() == 0 )
1009 return bitmaps;
1010
1011 for( wxArchiveEntry* entry = zip.GetNextEntry(); entry; entry = zip.GetNextEntry() )
1012 {
1013 wxArrayString path_parts = wxSplit( entry->GetName(), wxFileName::GetPathSeparator(),
1014 (wxChar) 0 );
1015
1016 if( path_parts.size() != 2 || path_parts[1] != wxT( "icon.png" ) )
1017 continue;
1018
1019 try
1020 {
1021 wxMemoryInputStream image_stream( zip, entry->GetSize() );
1022 wxImage image( image_stream, wxBITMAP_TYPE_PNG );
1023 bitmaps.emplace( path_parts[0], wxBitmap( image ) );
1024 }
1025 catch( ... )
1026 {
1027 // Log and ignore
1028 wxLogTrace( wxT( "Error loading png bitmap for entry %s from %s" ), entry->GetName(),
1029 resources_file.GetFullPath() );
1030 }
1031 }
1032
1033 return bitmaps;
1034}
1035
1036
1037std::unordered_map<wxString, wxBitmap> PLUGIN_CONTENT_MANAGER::GetInstalledPackageBitmaps()
1038{
1039 std::unordered_map<wxString, wxBitmap> bitmaps;
1040
1041 wxFileName resources_dir_fn( m_3rdparty_path, wxEmptyString );
1042 resources_dir_fn.AppendDir( wxT( "resources" ) );
1043 wxDir resources_dir( resources_dir_fn.GetPath() );
1044
1045 if( !resources_dir.IsOpened() )
1046 return bitmaps;
1047
1048 wxString subdir;
1049 bool more = resources_dir.GetFirst( &subdir, wxEmptyString, wxDIR_DIRS | wxDIR_HIDDEN );
1050
1051 while( more )
1052 {
1053 wxFileName icon( resources_dir_fn.GetPath(), wxT( "icon.png" ) );
1054 icon.AppendDir( subdir );
1055
1056 if( icon.FileExists() )
1057 {
1058 wxString actual_package_id = subdir;
1059 actual_package_id.Replace( '_', '.' );
1060
1061 try
1062 {
1063 wxBitmap bitmap( icon.GetFullPath(), wxBITMAP_TYPE_PNG );
1064 bitmaps.emplace( actual_package_id, bitmap );
1065 }
1066 catch( ... )
1067 {
1068 // Log and ignore
1069 wxLogTrace( wxT( "Error loading png bitmap from %s" ), icon.GetFullPath() );
1070 }
1071 }
1072
1073 more = resources_dir.GetNext( &subdir );
1074 }
1075
1076 return bitmaps;
1077}
1078
1079
1081{
1082 UPDATE_CANCELLER( std::shared_ptr<BACKGROUND_JOB>& aJob ) : m_jobToCancel( aJob ) {};
1084 {
1085 if( m_jobToCancel )
1086 {
1088 m_jobToCancel.reset();
1089 }
1090 }
1091
1092 std::shared_ptr<BACKGROUND_JOB>& m_jobToCancel;
1093};
1094
1095
1097{
1098 // If the thread is already running don't create it again
1099 if( m_updateThread.joinable() )
1100 return;
1101
1102 m_updateBackgroundJob = Pgm().GetBackgroundJobMonitor().Create( _( "PCM Update" ) );
1103
1104 m_updateThread = std::thread(
1105 [this]()
1106 {
1108
1109 if( m_installed.size() == 0 )
1110 return;
1111
1112 int maxProgress = m_repository_list.size() + m_installed.size();
1113 m_updateBackgroundJob->m_reporter->SetNumPhases( maxProgress );
1114 m_updateBackgroundJob->m_reporter->Report( _( "Preparing to fetch repositories" ) );
1115
1116 // Only fetch repositories that have installed not pinned packages
1117 std::unordered_set<wxString> repo_ids;
1118
1119 for( std::pair<const wxString, PCM_INSTALLATION_ENTRY>& pair : m_installed )
1120 {
1121 if( !pair.second.pinned )
1122 repo_ids.insert( pair.second.repository_id );
1123 }
1124
1125 for( const auto& [ repository_id, name, url ] : m_repository_list )
1126 {
1127 m_updateBackgroundJob->m_reporter->AdvancePhase();
1128 if( repo_ids.count( repository_id ) == 0 )
1129 continue;
1130
1131 m_updateBackgroundJob->m_reporter->Report(
1132 _( "Fetching repository..." ) );
1133 CacheRepository( repository_id );
1134
1135 if( m_updateBackgroundJob->m_reporter->IsCancelled() )
1136 break;
1137 }
1138
1139 if( m_updateBackgroundJob->m_reporter->IsCancelled() )
1140 return;
1141
1142 // Count packages with updates
1143 int availableUpdateCount = 0;
1144
1145 m_updateBackgroundJob->m_reporter->Report( _( "Reviewing packages..." ) );
1146 for( std::pair<const wxString, PCM_INSTALLATION_ENTRY>& pair : m_installed )
1147 {
1148 PCM_INSTALLATION_ENTRY& entry = pair.second;
1149
1150 m_updateBackgroundJob->m_reporter->AdvancePhase();
1151
1152 if( m_repository_cache.find( entry.repository_id ) != m_repository_cache.end() )
1153 {
1155 entry.package.identifier );
1156
1157 if( state == PPS_UPDATE_AVAILABLE && !entry.pinned )
1158 availableUpdateCount++;
1159 }
1160
1161 if( m_updateBackgroundJob->m_reporter->IsCancelled() )
1162 return;
1163 }
1164
1165 // Update the badge on PCM button
1166 m_availableUpdateCallback( availableUpdateCount );
1167 } );
1168}
1169
1170
1172{
1173 if( m_updateThread.joinable() )
1174 {
1176 m_updateBackgroundJob->m_reporter->Cancel();
1177
1178 m_updateThread.join();
1179 }
1180}
1181
1182
1184{
1185 // By the time object is being destroyed the thread should be
1186 // stopped already but just in case do it here too.
1188}
const char * name
Definition: DXF_plotter.cpp:59
wxString GetMajorMinorVersion()
Get only the major and minor version in a string major.minor.
const std::tuple< int, int, int > & GetMajorMinorPatchTuple()
Get the build version numbers as a tuple.
std::shared_ptr< BACKGROUND_JOB > Create(const wxString &aName)
Creates a background job with the given name.
void Remove(std::shared_ptr< BACKGROUND_JOB > job)
Removes the given background job from any lists and frees it.
int Perform()
Equivalent to curl_easy_perform.
bool SetTransferCallback(const TRANSFER_CALLBACK &aCallback, size_t aInterval)
bool SetURL(const std::string &aURL)
Set the request URL.
bool SetFollowRedirects(bool aFollow)
Enable the following of HTTP(s) and other redirects, by default curl does not follow redirects.
bool SetOutputStream(const std::ostream *aOutput)
const std::string GetErrorText(int aCode)
Fetch CURL's "friendly" error string for a given error code.
static wxString GetDefault3rdPartyPath()
Gets the default path for PCM packages.
Definition: paths.cpp:132
static wxString GetStockDataPath(bool aRespectRunFromBuildDir=true)
Gets the stock (install) data path, which is the base path for things like scripting,...
Definition: paths.cpp:196
static wxString GetUserCachePath()
Gets the stock (install) 3d viewer plugins path.
Definition: paths.cpp:409
static wxString GetUserSettingsPath()
Return the user configuration path used to store KiCad's configuration files.
Definition: paths.cpp:582
virtual ENV_VAR_MAP & GetLocalEnvVariables() const
Definition: pgm_base.cpp:935
virtual BACKGROUND_JOBS_MONITOR & GetBackgroundJobMonitor() const
Definition: pgm_base.h:129
time_t getCurrentTimestamp() const
Definition: pcm.cpp:852
const std::vector< PCM_PACKAGE > & GetRepositoryPackages(const wxString &aRepositoryId) const
Get the packages metadata from a previously cached repository.
Definition: pcm.cpp:678
void SetRepositoryList(const STRING_PAIR_LIST &aRepositories)
Set list of repositories.
Definition: pcm.cpp:693
std::unique_ptr< JSON_SCHEMA_VALIDATOR > m_schema_validator
Definition: pcm.h:396
void ValidateJson(const nlohmann::json &aJson, const nlohmann::json_uri &aUri=nlohmann::json_uri("#")) const
Validates json against a specific definition in the PCM schema.
Definition: pcm.cpp:284
wxWindow * m_dialog
Definition: pcm.h:395
std::unordered_map< wxString, PCM_REPOSITORY > m_repository_cache
Definition: pcm.h:399
const PCM_REPOSITORY & getCachedRepository(const wxString &aRepositoryId) const
Get the cached repository metadata.
Definition: pcm.cpp:354
int GetPackageSearchRank(const PCM_PACKAGE &aPackage, const wxString &aSearchTerm)
Get the approximate measure of how much given package matches the search term.
Definition: pcm.cpp:933
void MarkUninstalled(const PCM_PACKAGE &aPackage)
Mark package as uninstalled.
Definition: pcm.cpp:772
bool CacheRepository(const wxString &aRepositoryId)
Cache specified repository packages and other metadata.
Definition: pcm.cpp:363
void SaveInstalledPackages()
Saves metadata of installed packages to disk.
Definition: pcm.cpp:859
const std::vector< PCM_INSTALLATION_ENTRY > GetInstalledPackages() const
Get list of installed packages.
Definition: pcm.cpp:883
wxString m_3rdparty_path
Definition: pcm.h:397
void SetPinned(const wxString &aPackageId, const bool aPinned)
Set the pinned status of a package.
Definition: pcm.cpp:924
static void PreparePackage(PCM_PACKAGE &aPackage)
Parses version strings and calculates compatibility.
Definition: pcm.cpp:600
PLUGIN_CONTENT_MANAGER(std::function< void(int)> aAvailableUpdateCallbac)
Definition: pcm.cpp:73
bool DownloadToStream(const wxString &aUrl, std::ostream *aOutput, PROGRESS_REPORTER *aReporter, const size_t aSizeLimit=DEFAULT_DOWNLOAD_MEM_LIMIT)
Downloads url to an output stream.
Definition: pcm.cpp:190
std::thread m_updateThread
Definition: pcm.h:405
PCM_PACKAGE_STATE GetPackageState(const wxString &aRepositoryId, const wxString &aPackageId)
Get current state of the package.
Definition: pcm.cpp:778
std::map< wxString, PCM_INSTALLATION_ENTRY > m_installed
Definition: pcm.h:402
void RunBackgroundUpdate()
Runs a background update thread that checks for new package versions.
Definition: pcm.cpp:1096
std::unordered_map< wxString, wxBitmap > GetRepositoryPackageBitmaps(const wxString &aRepositoryId)
Get the icon bitmaps for repository packages.
Definition: pcm.cpp:994
const wxString GetPackageUpdateVersion(const PCM_PACKAGE &aPackage)
Get the preferred package update version or empty string if there is none.
Definition: pcm.cpp:824
void MarkInstalled(const PCM_PACKAGE &aPackage, const wxString &aVersion, const wxString &aRepositoryId)
Mark package as installed.
Definition: pcm.cpp:736
std::unordered_map< wxString, wxBitmap > GetInstalledPackageBitmaps()
Get the icon bitmaps for installed packages.
Definition: pcm.cpp:1037
const wxString & GetInstalledPackageVersion(const wxString &aPackageId) const
Get the current version of an installed package.
Definition: pcm.cpp:906
void updateInstalledPackagesMetadata(const wxString &aRepositoryId)
Updates metadata of installed packages from freshly fetched repo.
Definition: pcm.cpp:536
bool IsPackagePinned(const wxString &aPackageId) const
Returns pinned status of a package.
Definition: pcm.cpp:915
static const std::tuple< int, int, int > m_kicad_version
Definition: pcm.h:403
std::shared_ptr< BACKGROUND_JOB > m_updateBackgroundJob
Definition: pcm.h:407
void StopBackgroundUpdate()
Interrupts and joins() the update thread.
Definition: pcm.cpp:1171
STRING_TUPLE_LIST m_repository_list
Definition: pcm.h:400
bool fetchPackages(const wxString &aUrl, const std::optional< wxString > &aHash, std::vector< PCM_PACKAGE > &aPackages, PROGRESS_REPORTER *aReporter)
Downloads packages metadata to in memory stream, verifies hash and attempts to parse it.
Definition: pcm.cpp:292
std::function< void(int)> m_availableUpdateCallback
Definition: pcm.h:404
bool FetchRepository(const wxString &aUrl, PCM_REPOSITORY &aRepository, PROGRESS_REPORTER *aReporter)
Fetches repository metadata from given url.
Definition: pcm.cpp:248
void DiscardRepositoryCache(const wxString &aRepositoryId)
Discard in-memory and on-disk cache of a repository.
Definition: pcm.cpp:722
bool VerifyHash(std::istream &aStream, const wxString &aHash) const
Verifies SHA256 hash of a binary stream.
Definition: pcm.cpp:341
void ReadEnvVar()
Stores 3rdparty path from environment variables.
Definition: pcm.cpp:178
A progress reporter interface for use in multi-threaded environments.
virtual bool IsCancelled() const =0
virtual bool KeepRefreshing(bool aWait=false)=0
Update the UI (if any).
virtual void Report(const wxString &aMessage)=0
Display aMessage in the progress bar dialog.
virtual void SetTitle(const wxString &aTitle)=0
Change the title displayed on the window caption.
virtual void SetCurrentProgress(double aProgress)=0
Set the progress value to aProgress (0..1).
void error(const json::json_pointer &ptr, const json &instance, const std::string &message) override
Definition: pcm.cpp:64
static bool empty(const wxTextEntryBase *aCtrl)
#define _(s)
Functions related to environment variables, including help functions.
nlohmann::json json
Definition: gerbview.cpp:47
static const wxChar tracePcm[]
Flag to enable PCM debugging output.
Definition: pcm.cpp:55
std::map< wxString, ENV_VAR_ITEM > ENV_VAR_MAP
std::function< int(size_t, size_t, size_t, size_t)> TRANSFER_CALLBACK
Wrapper interface around the curl_easy API/.
KICOMMON_API std::optional< wxString > GetVersionedEnvVarValue(const std::map< wxString, ENV_VAR_ITEM > &aMap, const wxString &aBaseName)
Attempt to retrieve the value of a versioned environment variable, such as KICAD8_TEMPLATE_DIR.
Definition: env_vars.cpp:83
std::vector< std::pair< wxString, wxString > > STRING_PAIR_LIST
Definition: pcm.h:78
PCM_PACKAGE_STATE
Definition: pcm.h:58
@ PPS_INSTALLED
Definition: pcm.h:61
@ PPS_UNAVAILABLE
Definition: pcm.h:60
@ PPS_UPDATE_AVAILABLE
Definition: pcm.h:64
@ PPS_AVAILABLE
Definition: pcm.h:59
const std::unordered_set< wxString > PCM_PACKAGE_DIRECTORIES({ "plugins", "footprints", "3dmodels", "symbols", "resources", "colors", "templates", "scripts" })
< Contains list of all valid directories that get extracted from a package archive
@ PVS_STABLE
Definition: pcm_data.h:63
PGM_BASE & Pgm()
The global program "get" accessor.
Definition: pgm_base.cpp:1073
see class PGM_BASE
< Package version metadata Package metadata
Definition: pcm_data.h:84
bool compatible
Definition: pcm_data.h:99
wxString version
Definition: pcm_data.h:85
PCM_PACKAGE_VERSION_STATUS status
Definition: pcm_data.h:91
std::optional< wxString > kicad_version_max
Definition: pcm_data.h:94
std::optional< int > version_epoch
Definition: pcm_data.h:86
std::vector< std::string > platforms
Definition: pcm_data.h:92
wxString kicad_version
Definition: pcm_data.h:93
std::tuple< int, int, int, int > parsed_version
Definition: pcm_data.h:98
wxString name
Definition: pcm_data.h:73
Definition: pcm_data.h:149
wxString repository_name
Definition: pcm_data.h:153
PCM_PACKAGE package
Definition: pcm_data.h:150
uint64_t install_timestamp
Definition: pcm_data.h:154
wxString repository_id
Definition: pcm_data.h:152
wxString current_version
Definition: pcm_data.h:151
bool pinned
Definition: pcm_data.h:155
Repository reference to a resource.
Definition: pcm_data.h:105
wxString description
Definition: pcm_data.h:107
wxString description_full
Definition: pcm_data.h:108
wxString identifier
Definition: pcm_data.h:109
wxString license
Definition: pcm_data.h:114
std::vector< std::string > tags
Definition: pcm_data.h:116
STRING_MAP resources
Definition: pcm_data.h:115
std::optional< PCM_CONTACT > maintainer
Definition: pcm_data.h:113
wxString name
Definition: pcm_data.h:106
std::vector< PACKAGE_VERSION > versions
Definition: pcm_data.h:118
PCM_CONTACT author
Definition: pcm_data.h:112
Package installation entry.
Definition: pcm_data.h:133
PCM_RESOURCE_REFERENCE packages
Definition: pcm_data.h:135
std::vector< PCM_PACKAGE > package_list
Definition: pcm_data.h:141
wxString name
Definition: pcm_data.h:134
std::optional< PCM_RESOURCE_REFERENCE > resources
Definition: pcm_data.h:136
std::unordered_map< wxString, size_t > package_map
Definition: pcm_data.h:143
Repository metadata.
Definition: pcm_data.h:124
std::optional< wxString > sha256
Definition: pcm_data.h:126
uint64_t update_timestamp
Definition: pcm_data.h:127
UPDATE_CANCELLER(std::shared_ptr< BACKGROUND_JOB > &aJob)
Definition: pcm.cpp:1082
std::shared_ptr< BACKGROUND_JOB > & m_jobToCancel
Definition: pcm.cpp:1092
#define FN_NORMALIZE_FLAGS
Default flags to pass to wxFileName::Normalize().
Definition: wx_filename.h:39