API: Add a preferred plugin settings path

Fixes https://gitlab.com/kicad/code/kicad/-/issues/9054
This commit is contained in:
Jon Evans
2024-12-28 16:21:05 -05:00
parent 6e437fe3d6
commit 2c94684f9f
5 changed files with 71 additions and 4 deletions
+9 -4
View File
@@ -115,10 +115,7 @@ API_PLUGIN_CONFIG::API_PLUGIN_CONFIG( API_PLUGIN& aParent, const wxFileName& aCo
return;
}
// At minimum, we need a reverse-DNS style identifier with two dots and a 2+ character TLD
wxRegEx identifierRegex( wxS( "[\\w\\d]{2,}\\.[\\w\\d]+\\.[\\w\\d]+" ) );
if( !identifierRegex.Matches( identifier ) )
if( !API_PLUGIN::IsValidIdentifier( identifier ) )
{
wxLogTrace( traceApi, wxString::Format( "Plugin: identifier %s does not meet requirements",
identifier ) );
@@ -172,6 +169,14 @@ bool API_PLUGIN::IsOk() const
}
bool API_PLUGIN::IsValidIdentifier( const wxString& aIdentifier )
{
// At minimum, we need a reverse-DNS style identifier with two dots and a 2+ character TLD
wxRegEx identifierRegex( wxS( "[\\w\\d]{2,}\\.[\\w\\d]+\\.[\\w\\d]+" ) );
return identifierRegex.Matches( aIdentifier );
}
const wxString& API_PLUGIN::Identifier() const
{
return m_config->identifier;