Audacity 3.2.0
Classes | Public Types | Public Member Functions | Static Public Member Functions | Private Member Functions | Private Attributes | Static Private Attributes | List of all members
PluginManager Class Referencefinal

PluginManager maintains a list of all plug ins. That covers modules, effects, generators, analysis-effects, commands. It also has functions for shared and private configs - which need to move out. More...

#include <PluginManager.h>

Inheritance diagram for PluginManager:
[legend]
Collaboration diagram for PluginManager:
[legend]

Classes

class  Iterator
 
struct  Range
 

Public Types

using FileConfigFactory = std::function< std::unique_ptr< FileConfig >(const FilePath &localFilename) >
 
- Public Types inherited from PluginManagerInterface
using ConfigurationType = PluginSettings::ConfigurationType
 
using ConfigReference = PluginSettings::ConfigReference
 
using ConfigConstReference = PluginSettings::ConfigConstReference
 
- Public Types inherited from Observer::Publisher< PluginsChangedMessage >
using message_type = PluginsChangedMessage
 
using CallbackReturn = std::conditional_t< true, void, bool >
 
using Callback = std::function< CallbackReturn(const PluginsChangedMessage &) >
 Type of functions that can be connected to the Publisher. More...
 

Public Member Functions

RegistryPath GetPluginEnabledSetting (const PluginID &ID) const
 
RegistryPath GetPluginEnabledSetting (const PluginDescriptor &desc) const
 
bool IsPluginRegistered (const PluginPath &path, const TranslatableString *pSymbol) override
 Was the plugin registry already populated for a path (maybe from loading the config file)? More...
 
bool IsPluginLoaded (const wxString &ID) const
 
void RegisterPlugin (PluginDescriptor &&desc)
 
const PluginIDRegisterPlugin (PluginProvider *provider) override
 
const PluginIDRegisterPlugin (PluginProvider *provider, ComponentInterface *command)
 
const PluginIDRegisterPlugin (PluginProvider *provider, EffectDefinitionInterface *effect, int type) override
 
void FindFilesInPathList (const wxString &pattern, const FilePaths &pathList, FilePaths &files, bool directories=false) override
 
bool HasConfigGroup (ConfigurationType type, const PluginID &ID, const RegistryPath &group)
 
bool GetConfigSubgroups (ConfigurationType type, const PluginID &ID, const RegistryPath &group, RegistryPaths &subgroups) override
 
bool HasConfigValue (ConfigurationType type, const PluginID &ID, const RegistryPath &group, const RegistryPath &key) override
 
bool GetConfigValue (ConfigurationType type, const PluginID &ID, const RegistryPath &group, const RegistryPath &key, ConfigReference var, ConfigConstReference defval) override
 
bool SetConfigValue (ConfigurationType type, const PluginID &ID, const RegistryPath &group, const RegistryPath &key, ConfigConstReference value) override
 
bool RemoveConfigSubgroup (ConfigurationType type, const PluginID &ID, const RegistryPath &group) override
 
bool RemoveConfig (ConfigurationType type, const PluginID &ID, const RegistryPath &group, const RegistryPath &key) override
 
void Initialize (FileConfigFactory factory)
 
void Terminate ()
 
bool DropFile (const wxString &fileName)
 
int GetPluginCount (PluginType type)
 
const PluginDescriptorGetPlugin (const PluginID &ID) const
 
bool IsPluginEnabled (const PluginID &ID)
 
void EnablePlugin (const PluginID &ID, bool enable)
 
const ComponentInterfaceSymbolGetSymbol (const PluginID &ID)
 
ComponentInterfaceLoad (const PluginID &ID)
 
void ClearEffectPlugins ()
 
std::map< wxString, std::vector< wxString > > CheckPluginUpdates ()
 Ensures that all currently registered plugins still exist and scans for new ones. More...
 
const PluginIDRegisterPlugin (std::unique_ptr< EffectDefinitionInterface > effect, PluginType type)
 Used only by Nyquist Workbench module. More...
 
void UnregisterPlugin (const PluginID &ID)
 
void Load ()
 Load from preferences. More...
 
void Save ()
 Save to preferences. More...
 
void NotifyPluginsChanged ()
 
const PluginRegistryVersionGetRegistryVersion () const override
 
iteration over plugins of certain types, supporting range-for syntax
Range AllPlugins ()
 
Range PluginsOfType (int type)
 
Range EffectsOfType (EffectType type)
 
- Public Member Functions inherited from PluginManagerInterface
virtual ~PluginManagerInterface ()
 
virtual bool IsPluginRegistered (const PluginPath &path, const TranslatableString *pName=nullptr)=0
 Was the plugin registry already populated for a path (maybe from loading the config file)? More...
 
virtual const PluginIDRegisterPlugin (PluginProvider *provider)=0
 
virtual const PluginIDRegisterPlugin (PluginProvider *provider, EffectDefinitionInterface *effect, int type)=0
 
virtual void FindFilesInPathList (const wxString &pattern, const FilePaths &pathList, FilePaths &files, bool directories=false)=0
 
virtual bool GetConfigSubgroups (ConfigurationType type, const PluginID &ID, const RegistryPath &group, RegistryPaths &subgroups)=0
 
virtual bool HasConfigValue (ConfigurationType type, const PluginID &ID, const RegistryPath &group, const RegistryPath &key)=0
 
virtual bool GetConfigValue (ConfigurationType type, const PluginID &ID, const RegistryPath &group, const RegistryPath &key, ConfigReference var, ConfigConstReference defval)=0
 
virtual bool SetConfigValue (ConfigurationType type, const PluginID &ID, const RegistryPath &group, const RegistryPath &key, ConfigConstReference value)=0
 
virtual bool RemoveConfigSubgroup (ConfigurationType type, const PluginID &ID, const RegistryPath &group)=0
 
virtual bool RemoveConfig (ConfigurationType type, const PluginID &ID, const RegistryPath &group, const RegistryPath &key)=0
 
virtual const PluginRegistryVersionGetRegistryVersion () const =0
 What is the plugin registry version number now in the file? More...
 
- Public Member Functions inherited from Observer::Publisher< PluginsChangedMessage >
 Publisher (ExceptionPolicy *pPolicy=nullptr, Alloc a={})
 Constructor supporting type-erased custom allocation/deletion. More...
 
 Publisher (Publisher &&)=default
 
Publisheroperator= (Publisher &&)=default
 
Subscription Subscribe (Callback callback)
 Connect a callback to the Publisher; later-connected are called earlier. More...
 
Subscription Subscribe (Object &obj, Return(Object::*callback)(Args...))
 Overload of Subscribe takes an object and pointer-to-member-function. More...
 

Static Public Member Functions

static PluginManagerGet ()
 
static PluginID GetID (PluginProvider *provider)
 
static PluginID GetID (ComponentInterface *command)
 
static PluginID OldGetID (const EffectDefinitionInterface *effect)
 
static PluginID GetID (const EffectDefinitionInterface *effect)
 
static Identifier GetEffectNameFromID (const PluginID &ID)
 
static wxString GetPluginTypeString (PluginType type)
 
static bool IsPluginAvailable (const PluginDescriptor &plug)
 
- Static Public Member Functions inherited from PluginManagerInterface
static const PluginIDDefaultRegistrationCallback (PluginProvider *provider, ComponentInterface *ident)
 
static const PluginIDAudacityCommandRegistrationCallback (PluginProvider *provider, ComponentInterface *ident)
 

Private Member Functions

 PluginManager ()
 
 ~PluginManager ()
 
void InitializePlugins ()
 
void LoadGroup (FileConfig *pRegistry, PluginType type)
 
void SaveGroup (FileConfig *pRegistry, PluginType type)
 
PluginDescriptorCreatePlugin (const PluginID &id, ComponentInterface *ident, PluginType type)
 
FileConfigGetSettings ()
 
bool HasGroup (const RegistryPath &group)
 
bool GetSubgroups (const RegistryPath &group, RegistryPaths &subgroups)
 
bool HasConfigValue (const RegistryPath &key)
 
bool GetConfigValue (const RegistryPath &key, ConfigReference var, ConfigConstReference defval)
 
bool SetConfigValue (const RegistryPath &key, ConfigConstReference value)
 
RegistryPath SettingsPath (ConfigurationType type, const PluginID &ID)
 
RegistryPath Group (ConfigurationType type, const PluginID &ID, const RegistryPath &group)
 
RegistryPath Key (ConfigurationType type, const PluginID &ID, const RegistryPath &group, const RegistryPath &key)
 
wxString ConvertID (const PluginID &ID)
 
bool IsDirty ()
 
void SetDirty (bool dirty=true)
 

Private Attributes

std::unique_ptr< FileConfigmSettings
 
bool mDirty
 
int mCurrentIndex
 
PluginMap mRegisteredPlugins
 
std::map< PluginID, std::unique_ptr< ComponentInterface > > mLoadedInterfaces
 
std::vector< PluginDescriptormEffectPluginsCleared
 
PluginRegistryVersion mRegver
 

Static Private Attributes

static std::unique_ptr< PluginManagermInstance {}
 

Additional Inherited Members

- Static Public Attributes inherited from Observer::Publisher< PluginsChangedMessage >
static constexpr bool notifies_all
 
- Protected Member Functions inherited from Observer::Publisher< PluginsChangedMessage >
CallbackReturn Publish (const PluginsChangedMessage &message)
 Send a message to connected callbacks. More...
 

Detailed Description

PluginManager maintains a list of all plug ins. That covers modules, effects, generators, analysis-effects, commands. It also has functions for shared and private configs - which need to move out.

Definition at line 44 of file PluginManager.h.

Member Typedef Documentation

◆ FileConfigFactory

using PluginManager::FileConfigFactory = std::function< std::unique_ptr<FileConfig>(const FilePath &localFilename ) >

Definition at line 96 of file PluginManager.h.

Constructor & Destructor Documentation

◆ PluginManager()

PluginManager::PluginManager ( )
private

Definition at line 330 of file PluginManager.cpp.

331{
332 mSettings = NULL;
333}
std::unique_ptr< FileConfig > mSettings

References mSettings.

◆ ~PluginManager()

PluginManager::~PluginManager ( )
private

Definition at line 335 of file PluginManager.cpp.

336{
337 // Ensure termination (harmless if already done)
338 Terminate();
339}

References Terminate().

Here is the call graph for this function:

Member Function Documentation

◆ AllPlugins()

Range PluginManager::AllPlugins ( )
inline

Definition at line 153 of file PluginManager.h.

153{ return { Iterator{ *this } }; }

Referenced by PluginRegistrationDialog::PopulateItemsList().

Here is the caller graph for this function:

◆ CheckPluginUpdates()

std::map< wxString, std::vector< wxString > > PluginManager::CheckPluginUpdates ( )

Ensures that all currently registered plugins still exist and scans for new ones.

Returns
Map, where each module path(key) is associated with at least one provider id

Definition at line 1195 of file PluginManager.cpp.

1196{
1197 wxArrayString pathIndex;
1198 for (auto &pair : mRegisteredPlugins) {
1199 auto &plug = pair.second;
1200
1201 // Bypass 2.1.0 placeholders...remove this after a few releases past 2.1.0
1202 if (plug.GetPluginType() != PluginTypeNone)
1203 pathIndex.push_back(plug.GetPath().BeforeFirst(wxT(';')));
1204 }
1205
1206 // Scan for NEW ones.
1207 //
1208 // Because we use the plugins "path" as returned by the providers, we can actually
1209 // have multiple providers report the same path since, at this point, they only
1210 // know that the path might possibly be one supported by the provider.
1211 //
1212 // When the user enables the plugin, each provider that reported it will be asked
1213 // to register the plugin.
1214
1215 auto& moduleManager = ModuleManager::Get();
1216 std::map<wxString, std::vector<wxString>> newPaths;
1217 for(auto& [id, provider] : moduleManager.Providers())
1218 {
1219 const auto paths = provider->FindModulePaths(*this);
1220 for(const auto& path : paths)
1221 {
1222 const auto modulePath = path.BeforeFirst(';');
1223 if (!make_iterator_range(pathIndex).contains(modulePath) ||
1224 make_iterator_range(mEffectPluginsCleared).any_of([&modulePath](const PluginDescriptor& plug) {
1225 return plug.GetPath().BeforeFirst(wxT(';')) == modulePath;
1226 })
1227 )
1228 {
1229 newPaths[modulePath].push_back(id);
1230 }
1231 }
1232 }
1233
1234 return newPaths;
1235}
wxT("CloseDown"))
IteratorRange< Iterator > make_iterator_range(const Iterator &i1, const Iterator &i2)
Definition: MemoryX.h:448
@ PluginTypeNone
static ModuleManager & Get()
const PluginPath & GetPath() const
std::vector< PluginDescriptor > mEffectPluginsCleared
PluginMap mRegisteredPlugins

References ModuleManager::Get(), PluginDescriptor::GetPath(), make_iterator_range(), mEffectPluginsCleared, mRegisteredPlugins, PluginTypeNone, and wxT().

Referenced by AudacityApp::InitPart2(), and PluginRegistrationDialog::OnRescan().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ClearEffectPlugins()

void PluginManager::ClearEffectPlugins ( )

Definition at line 1160 of file PluginManager.cpp.

1161{
1162 mEffectPluginsCleared.clear();
1163
1164 for ( auto it = mRegisteredPlugins.cbegin(); it != mRegisteredPlugins.cend(); )
1165 {
1166 const auto& desc = it->second;
1167 const auto type = desc.GetPluginType();
1168
1169 if (type == PluginTypeEffect || type == PluginTypeStub)
1170 {
1171 mEffectPluginsCleared.push_back(desc);
1172 it = mRegisteredPlugins.erase(it);
1173 }
1174 else
1175 {
1176 ++it;
1177 }
1178 }
1179
1180 // Repeat what usually happens at startup
1181 // This prevents built-in plugins to appear in the plugin validation list
1182 for (auto& [_, provider] : ModuleManager::Get().Providers())
1183 provider->AutoRegisterPlugins(*this);
1184
1185 // Remove auto registered plugins from "cleared" list
1186 for ( auto it = mEffectPluginsCleared.begin(); it != mEffectPluginsCleared.end(); )
1187 {
1188 if ( mRegisteredPlugins.find(it->GetID()) != mRegisteredPlugins.end() )
1189 it = mEffectPluginsCleared.erase(it);
1190 else
1191 ++it;
1192 }
1193}
const TranslatableString desc
Definition: ExportPCM.cpp:55
#define _(s)
Definition: Internat.h:73
@ PluginTypeStub
@ PluginTypeEffect

References _, desc, ModuleManager::Get(), mEffectPluginsCleared, mRegisteredPlugins, PluginTypeEffect, and PluginTypeStub.

Here is the call graph for this function:

◆ ConvertID()

wxString PluginManager::ConvertID ( const PluginID ID)
private

Definition at line 1522 of file PluginManager.cpp.

1523{
1524 if (ID.StartsWith(wxT("base64:")))
1525 {
1526 wxString id = ID.Mid(7);
1527 ArrayOf<char> buf{ id.length() / 4 * 3 };
1528 id = wxString::FromUTF8(buf.get(), Base64::Decode(id, buf.get()));
1529 return id;
1530 }
1531
1532 const wxCharBuffer & buf = ID.ToUTF8();
1533 return wxT("base64:") + Base64::Encode(buf, strlen(buf));
1534}
int id
STRINGS_API wxString Encode(const void *in, int len)
Definition: Base64.cpp:27
STRINGS_API int Decode(const wxString &in, void *out)
Definition: Base64.cpp:67

References Base64::Decode(), Base64::Encode(), id, and wxT().

Referenced by LoadGroup(), SaveGroup(), and SettingsPath().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ CreatePlugin()

PluginDescriptor & PluginManager::CreatePlugin ( const PluginID id,
ComponentInterface ident,
PluginType  type 
)
private

Definition at line 1336 of file PluginManager.cpp.

1339{
1340 // This will either create a NEW entry or replace an existing entry
1342
1343 plug.SetPluginType(type);
1344
1345 plug.SetID(id);
1346 plug.SetPath(ident->GetPath());
1347 plug.SetSymbol(ident->GetSymbol());
1348 plug.SetVendor(ident->GetVendor().Internal());
1349 plug.SetVersion(ident->GetVersion());
1350
1351 return plug;
1352}
static CommandHandlerObject & ident(AudacityProject &project)
void SetVendor(const wxString &vendor)
void SetPath(const PluginPath &path)
void SetSymbol(const ComponentInterfaceSymbol &symbol)
void SetID(const PluginID &ID)
void SetPluginType(PluginType type)
void SetVersion(const wxString &version)

References id, ident(), mRegisteredPlugins, PluginDescriptor::SetID(), PluginDescriptor::SetPath(), PluginDescriptor::SetPluginType(), PluginDescriptor::SetSymbol(), PluginDescriptor::SetVendor(), and PluginDescriptor::SetVersion().

Referenced by RegisterPlugin().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ DropFile()

bool PluginManager::DropFile ( const wxString &  fileName)

Definition at line 425 of file PluginManager.cpp.

426{
427 using namespace BasicUI;
428 auto &mm = ModuleManager::Get();
429 const wxFileName src{ fileName };
430
431 for (auto &plug : PluginsOfType(PluginTypeModule)) {
432 auto module = static_cast<PluginProvider *>
433 (mm.CreateProviderInstance(plug.GetID(), plug.GetPath()));
434 if (! module)
435 continue;
436
437 const auto &ff = module->InstallPath();
438 const auto &extensions = module->GetFileExtensions();
439 if ( !ff.empty() &&
440 extensions.Index(src.GetExt(), false) != wxNOT_FOUND ) {
441 TranslatableString errMsg;
442 // Do dry-run test of the file format
443 unsigned nPlugIns =
444 module->DiscoverPluginsAtPath(fileName, errMsg, {});
445 if (nPlugIns) {
446 // File contents are good for this module, so check no others.
447 // All branches of this block return true, even in case of
448 // failure for other reasons, to signal that other drag-and-drop
449 // actions should not be tried.
450
451 // Find path to copy it
452 wxFileName dst;
453 dst.AssignDir( ff );
454 dst.SetFullName( src.GetFullName() );
455 if ( dst.Exists() ) {
456 // Query whether to overwrite
457 bool overwrite = (MessageBoxResult::Yes == ShowMessageBox(
458 XO("Overwrite the plug-in file %s?")
459 .Format( dst.GetFullPath() ),
461 .Caption(XO("Plug-in already exists"))
462 .ButtonStyle(Button::YesNo)));
463 if ( !overwrite )
464 return true;
465 }
466
467 // Move the file or subtree
468 bool copied = false;
469 auto dstPath = dst.GetFullPath();
470 if ( src.FileExists() )
471 // A simple one-file plug-in
472 copied = FileNames::DoCopyFile(
473 src.GetFullPath(), dstPath, true );
474 else {
475 // A sub-folder
476 // such as for some VST packages
477 // Recursive copy needed -- to do
478 return true;
479 }
480
481 if (!copied) {
483 XO("Plug-in file is in use. Failed to overwrite") );
484 return true;
485 }
486
487 // Register for real
488 std::vector<PluginID> ids;
489 std::vector<wxString> names;
490 nPlugIns = module->DiscoverPluginsAtPath(dstPath, errMsg,
492 -> const PluginID& {
493 // Register as by default, but also collecting the PluginIDs
494 // and names
496 provider, ident);
497 ids.push_back(id);
498 names.push_back( ident->GetSymbol().Translation() );
499 return id;
500 });
501 if ( ! nPlugIns ) {
502 // Unlikely after the dry run succeeded
504 XO("Failed to register:\n%s").Format( errMsg ) );
505 return true;
506 }
507
508 // Ask whether to enable the plug-ins
509 if (auto nIds = ids.size()) {
510 auto message = XPC(
511 /* i18n-hint A plug-in is an optional added program for a sound
512 effect, or generator, or analyzer */
513 "Enable this plug-in?\n",
514 "Enable these plug-ins?\n",
515 0,
516 "plug-ins"
517 )( nIds );
518 for (const auto &name : names)
519 message.Join( Verbatim( name ), wxT("\n") );
520 bool enable = (MessageBoxResult::Yes == ShowMessageBox(
521 message,
523 .Caption(XO("Enable new plug-ins"))
524 .ButtonStyle(Button::YesNo)));
525 for (const auto &id : ids)
526 mRegisteredPlugins[id].SetEnabled(enable);
527 // Make changes to enabled status persist:
528 this->Save();
529 this->NotifyPluginsChanged();
530 }
531
532 return true;
533 }
534 }
535 }
536
537 return false;
538}
const TranslatableString name
Definition: Distortion.cpp:76
wxString PluginID
Definition: EffectManager.h:30
XO("Cut/Copy/Paste")
#define XPC(sing, plur, n, c)
Definition: Internat.h:98
@ PluginTypeModule
static TranslatableStrings names
Definition: TagsEditor.cpp:152
TranslatableString Verbatim(wxString str)
Require calls to the one-argument constructor to go through this distinct global function name.
ComponentInterface provides name / vendor / version functions to identify plugins....
Abstract base class used in importing a file.
void Save()
Save to preferences.
Range PluginsOfType(int type)
void NotifyPluginsChanged()
static const PluginID & DefaultRegistrationCallback(PluginProvider *provider, ComponentInterface *ident)
virtual FilePath InstallPath()=0
Where plug-in files should be copied to install them.
Holds a msgid for the translation catalog; may also bind format arguments.
MessageBoxResult ShowMessageBox(const TranslatableString &message, MessageBoxOptions options={})
Show a modal message box with either Ok or Yes and No, and optionally Cancel.
Definition: BasicUI.h:274
FILES_API bool DoCopyFile(const FilePath &file1, const FilePath &file2, bool overwrite=true)
MessageBoxOptions && Caption(TranslatableString caption_) &&
Definition: BasicUI.h:100

References BasicUI::MessageBoxOptions::Caption(), PluginManagerInterface::DefaultRegistrationCallback(), FileNames::DoCopyFile(), ModuleManager::Get(), id, ident(), PluginProvider::InstallPath(), mRegisteredPlugins, name, names, NotifyPluginsChanged(), PluginsOfType(), PluginTypeModule, Save(), BasicUI::ShowMessageBox(), Verbatim(), wxT(), XO(), and XPC.

Here is the call graph for this function:

◆ EffectsOfType()

Range PluginManager::EffectsOfType ( EffectType  type)
inline

Definition at line 155 of file PluginManager.h.

155{ return { Iterator{ *this, type } }; }

Referenced by MenuHelper::PopulateEffectsMenu().

Here is the caller graph for this function:

◆ EnablePlugin()

void PluginManager::EnablePlugin ( const PluginID ID,
bool  enable 
)

Definition at line 1119 of file PluginManager.cpp.

1120{
1121 if (auto iter = mRegisteredPlugins.find(ID); iter == mRegisteredPlugins.end())
1122 return;
1123 else
1124 iter->second.SetEnabled(enable);
1125}

References mRegisteredPlugins.

Referenced by BuiltinEffectsModule::AutoRegisterPlugins().

Here is the caller graph for this function:

◆ FindFilesInPathList()

void PluginManager::FindFilesInPathList ( const wxString &  pattern,
const FilePaths pathList,
FilePaths files,
bool  directories = false 
)
overridevirtual

Implements PluginManagerInterface.

Definition at line 204 of file PluginManager.cpp.

208{
209
210 wxLogNull nolog;
211
212 // Why bother...
213 if (pattern.empty())
214 {
215 return;
216 }
217
218 // TODO: We REALLY need to figure out the "Audacity" plug-in path(s)
219
220 FilePaths paths;
221
222 // Add the "per-user" plug-ins directory
223 {
224 const wxFileName &ff = FileNames::PlugInDir();
225 paths.push_back(ff.GetFullPath());
226 }
227
228 // Add the "Audacity" plug-ins directory
230#if defined(__WXMAC__)
231 // Path ends for example in "Audacity.app/Contents/MacOSX"
232 //ff.RemoveLastDir();
233 //ff.RemoveLastDir();
234 // just remove the MacOSX part.
235 ff.RemoveLastDir();
236#endif
237 ff.AppendDir(wxT("plug-ins"));
238 paths.push_back(ff.GetPath());
239
240 // Weed out duplicates
241 for (const auto &filePath : pathList)
242 {
243 ff = filePath;
244 const wxString path{ ff.GetFullPath() };
245 if (paths.Index(path, wxFileName::IsCaseSensitive()) == wxNOT_FOUND)
246 {
247 paths.push_back(path);
248 }
249 }
250
251 // Find all matching files in each path
252 for (size_t i = 0, cnt = paths.size(); i < cnt; i++)
253 {
254 ff = paths[i] + wxFILE_SEP_PATH + pattern;
255 wxDir::GetAllFiles(ff.GetPath(), &files, ff.GetFullName(), directories ? wxDIR_DEFAULT : wxDIR_FILES);
256 }
257
258 return;
259}
static const FilePath & GetExecutablePath()
Extend wxArrayString with move operations and construction and insertion fromstd::initializer_list.
FILES_API FilePath PlugInDir()
The user plug-in directory (not a system one)

References PlatformCompatibility::GetExecutablePath(), FileNames::PlugInDir(), and wxT().

Here is the call graph for this function:

◆ Get()

PluginManager & PluginManager::Get ( )
static

Definition at line 379 of file PluginManager.cpp.

380{
381 if (!mInstance)
382 {
384 }
385
386 return *mInstance;
387}
#define safenew
Definition: MemoryX.h:10
PluginManager maintains a list of all plug ins. That covers modules, effects, generators,...
Definition: PluginManager.h:47
static std::unique_ptr< PluginManager > mInstance

References mInstance, and safenew.

Referenced by anonymous_namespace{MenuHelper.cpp}::AddEffectMenuItemGroup(), MacroCommands::ApplyEffectCommand(), PluginManagerInterface::AudacityCommandRegistrationCallback(), BuiltinEffectsModule::AutoRegisterPlugins(), PluginManagerInterface::DefaultRegistrationCallback(), anonymous_namespace{PluginHost.cpp}::Discover(), CommandDispatch::DoAudacityCommand(), EffectUI::DoEffect(), anonymous_namespace{PluginMenus.cpp}::DoManagePluginsMenu(), EffectManager::GetAudacityCommand(), EffectManager::GetCommandIdentifier(), EffectManager::GetCommandSymbol(), PluginSettings::GetConfigSubgroups(), PluginSettings::GetConfigValue(), EffectManager::GetEffectByIdentifier(), EffectManager::GetEffectFamilyName(), anonymous_namespace{RealtimeEffectPanel.cpp}::RealtimeEffectControl::GetPlugin(), EffectManager::GetVendorName(), CommandDispatch::HandleTextualCommand(), PluginSettings::HasConfigGroup(), PluginSettings::HasConfigValue(), AudacityApp::InitPart2(), anonymous_namespace{MenuHelper.cpp}::IsEnabledPlugin(), anonymous_namespace{EffectManager.cpp}::LoadComponent(), MacroCommandsCatalog::MacroCommandsCatalog(), RealtimeEffectListWindow::OnAddEffectClicked(), AudacityApp::OnExit(), PluginRegistrationDialog::OnOK(), anonymous_namespace{FileMenus.cpp}::OnOpen(), PluginStartupRegistration::OnPluginFound(), PluginRegistrationDialog::OnRescan(), PluginStartupRegistration::OnValidationFinished(), ProjectFileManager::OpenFile(), MenuHelper::PopulateEffectsMenu(), PluginRegistrationDialog::PopulateOrExchange(), RealtimeEffectListWindow::RealtimeEffectListWindow(), EffectManager::RegisterEffect(), PluginSettings::RemoveConfig(), PluginSettings::RemoveConfigSubgroup(), PluginStartupRegistration::Run(), GetInfoCommand::SendCommands(), PluginSettings::SetConfigValue(), EffectManager::SupportsAutomation(), anonymous_namespace{TrackMenus.cpp}::TracksMenu(), and EffectManager::UnregisterEffect().

Here is the caller graph for this function:

◆ GetConfigSubgroups()

bool PluginManager::GetConfigSubgroups ( ConfigurationType  type,
const PluginID ID,
const RegistryPath group,
RegistryPaths subgroups 
)
overridevirtual

Implements PluginManagerInterface.

Definition at line 267 of file PluginManager.cpp.

269{
270 return GetSubgroups(Group(type, ID, group), subgroups);
271}
RegistryPath Group(ConfigurationType type, const PluginID &ID, const RegistryPath &group)
bool GetSubgroups(const RegistryPath &group, RegistryPaths &subgroups)

References GetSubgroups(), and Group().

Here is the call graph for this function:

◆ GetConfigValue() [1/2]

bool PluginManager::GetConfigValue ( ConfigurationType  type,
const PluginID ID,
const RegistryPath group,
const RegistryPath key,
ConfigReference  var,
ConfigConstReference  defval 
)
overridevirtual
Precondition
var and defval wrap references to the same type (ignoring const)

Implements PluginManagerInterface.

Definition at line 279 of file PluginManager.cpp.

282{
283 return GetConfigValue(Key(type, ID, group, key), var, defval);
284}
static const AudacityProject::AttachedObjects::RegisteredFactory key
bool GetConfigValue(ConfigurationType type, const PluginID &ID, const RegistryPath &group, const RegistryPath &key, ConfigReference var, ConfigConstReference defval) override
RegistryPath Key(ConfigurationType type, const PluginID &ID, const RegistryPath &group, const RegistryPath &key)

References GetConfigValue(), Key(), and key.

Referenced by GetConfigValue().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GetConfigValue() [2/2]

bool PluginManager::GetConfigValue ( const RegistryPath key,
ConfigReference  var,
ConfigConstReference  defval 
)
private

Definition at line 1431 of file PluginManager.cpp.

1433{
1434 using namespace Variant;
1435 if (key.empty())
1436 return false;
1437 const auto visitor = [&](const auto var){
1438 const auto pVar = &var.get();
1439 // precondition is that defval wraps same type as var
1440 using Type = typename decltype(var)::type;
1441 const auto pDefval =
1442 std::get_if<std::reference_wrapper<const Type>>(&defval);
1443 return GetSettings()->Read(key, pVar, *pDefval);
1444 };
1445 return Visit(visitor, var);
1446}
FileConfig * GetSettings()
void Visit(Visitor &visitor, BaseItem *pTopItem, const GroupItemBase *pRegistry)
Definition: Registry.cpp:737

References GetSettings(), key, and Registry::Visit().

Here is the call graph for this function:

◆ GetEffectNameFromID()

Identifier PluginManager::GetEffectNameFromID ( const PluginID ID)
static

Parse English effect name from the result of GetID(const EffectDefinitionInterface*)

Definition at line 1273 of file PluginManager.cpp.

1274{
1275 auto strings = wxSplit(ID, '_');
1276 if (strings.size() == 5)
1277 return strings[3];
1278 return {};
1279}

Referenced by anonymous_namespace{RealtimeEffectPanel.cpp}::RealtimeEffectControl::GetEffectName().

Here is the caller graph for this function:

◆ GetID() [1/3]

PluginID PluginManager::GetID ( ComponentInterface command)
static

Definition at line 1242 of file PluginManager.cpp.

1243{
1244 return wxString::Format(wxT("%s_%s_%s_%s_%s"),
1246 wxEmptyString,
1247 command->GetVendor().Internal(),
1248 command->GetSymbol().Internal(),
1249 command->GetPath());
1250}
@ PluginTypeAudacityCommand
virtual PluginPath GetPath() const =0
virtual VendorSymbol GetVendor() const =0
virtual ComponentInterfaceSymbol GetSymbol() const =0
const wxString & Internal() const
static wxString GetPluginTypeString(PluginType type)

References ComponentInterface::GetPath(), GetPluginTypeString(), ComponentInterface::GetSymbol(), ComponentInterface::GetVendor(), ComponentInterfaceSymbol::Internal(), PluginTypeAudacityCommand, and wxT().

Here is the call graph for this function:

◆ GetID() [2/3]

PluginID PluginManager::GetID ( const EffectDefinitionInterface effect)
static

Definition at line 1262 of file PluginManager.cpp.

1263{
1264 return wxJoin(wxArrayStringEx{
1266 effect->GetFamily().Internal(),
1267 effect->GetVendor().Internal(),
1268 effect->GetSymbol().Internal(),
1269 effect->GetPath()
1270 }, '_');
1271}
virtual EffectFamilySymbol GetFamily() const =0
Report identifier and user-visible name of the effect protocol.

References EffectDefinitionInterface::GetFamily(), ComponentInterface::GetPath(), GetPluginTypeString(), ComponentInterface::GetSymbol(), ComponentInterface::GetVendor(), ComponentInterfaceSymbol::Internal(), and PluginTypeEffect.

Here is the call graph for this function:

◆ GetID() [3/3]

PluginID PluginManager::GetID ( PluginProvider provider)
static

Definition at line 1237 of file PluginManager.cpp.

1238{
1239 return ModuleManager::GetID(provider);
1240}
static PluginID GetID(PluginProvider *provider)

References ModuleManager::GetID().

Referenced by GetID(), RegisterPlugin(), and RealtimeEffectState::WriteXML().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GetPlugin()

const PluginDescriptor * PluginManager::GetPlugin ( const PluginID ID) const

Definition at line 1043 of file PluginManager.cpp.

1044{
1045 if (auto iter = mRegisteredPlugins.find(ID); iter != mRegisteredPlugins.end())
1046 return &iter->second;
1047
1049 .find_if([&ID](const PluginDescriptor& plug) {
1050 return plug.GetID() == ID;
1051 });
1052 if (iter2 != mEffectPluginsCleared.end())
1053 return &(*iter2);
1054
1055 return nullptr;
1056}
const wxString & GetID() const

References PluginDescriptor::GetID(), make_iterator_range(), mEffectPluginsCleared, and mRegisteredPlugins.

Referenced by anonymous_namespace{MenuHelper.cpp}::AddEffectMenuItemGroup(), MacroCommands::ApplyEffectCommand(), CommandDispatch::DoAudacityCommand(), EffectUI::DoEffect(), anonymous_namespace{RealtimeEffectPanel.cpp}::RealtimeEffectControl::GetPlugin(), GetPluginEnabledSetting(), RealtimeEffectListWindow::OnAddEffectClicked(), anonymous_namespace{FileMenus.cpp}::OnOpen(), EffectManager::SupportsAutomation(), and anonymous_namespace{TrackMenus.cpp}::TracksMenu().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GetPluginCount()

int PluginManager::GetPluginCount ( PluginType  type)

Definition at line 1037 of file PluginManager.cpp.

1038{
1039 return count_if(mRegisteredPlugins.begin(), mRegisteredPlugins.end(), [type](auto &pair){
1040 return pair.second.GetPluginType() == type; });
1041}

References mRegisteredPlugins.

◆ GetPluginEnabledSetting() [1/2]

RegistryPath PluginManager::GetPluginEnabledSetting ( const PluginDescriptor desc) const

Definition at line 112 of file PluginManager.cpp.

114{
115 switch ( desc.GetPluginType() ) {
116 case PluginTypeModule: {
117 // Retrieve optional family symbol that was recorded in
118 // RegisterPlugin() for the module
119 auto family = desc.GetEffectFamily();
120 if ( family.empty() ) // as for built-in effect and command modules
121 return {};
122 else
123 return wxT('/') + family + wxT("/Enable");
124 }
125 case PluginTypeEffect:
126 // do NOT use GetEffectFamily() for this descriptor, but instead,
127 // delegate to the plugin descriptor of the provider, which may
128 // be different (may be empty)
129 return GetPluginEnabledSetting( desc.GetProviderID() );
130 default:
131 return {};
132 }
133}
RegistryPath GetPluginEnabledSetting(const PluginID &ID) const

References desc, GetPluginEnabledSetting(), PluginTypeEffect, PluginTypeModule, and wxT().

Here is the call graph for this function:

◆ GetPluginEnabledSetting() [2/2]

RegistryPath PluginManager::GetPluginEnabledSetting ( const PluginID ID) const

Definition at line 104 of file PluginManager.cpp.

105{
106 auto pPlugin = GetPlugin( ID );
107 if ( pPlugin )
108 return GetPluginEnabledSetting( *pPlugin );
109 return {};
110}
const PluginDescriptor * GetPlugin(const PluginID &ID) const

References GetPlugin(), and GetPluginEnabledSetting().

Referenced by PluginManager::Iterator::Advance(), and GetPluginEnabledSetting().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GetPluginTypeString()

wxString PluginManager::GetPluginTypeString ( PluginType  type)
static

Definition at line 1283 of file PluginManager.cpp.

1284{
1285 wxString str;
1286
1287 switch (type)
1288 {
1289 default:
1290 case PluginTypeNone:
1291 str = wxT("Placeholder");
1292 break;
1293 case PluginTypeStub:
1294 str = wxT("Stub");
1295 break;
1296 case PluginTypeEffect:
1297 str = wxT("Effect");
1298 break;
1300 str = wxT("Generic");
1301 break;
1302 case PluginTypeExporter:
1303 str = wxT("Exporter");
1304 break;
1305 case PluginTypeImporter:
1306 str = wxT("Importer");
1307 break;
1308 case PluginTypeModule:
1310 break;
1311 }
1312
1313 return str;
1314}
#define str(a)
@ PluginTypeExporter
@ PluginTypeImporter
static wxString GetPluginTypeString()

References ModuleManager::GetPluginTypeString(), PluginTypeAudacityCommand, PluginTypeEffect, PluginTypeExporter, PluginTypeImporter, PluginTypeModule, PluginTypeNone, PluginTypeStub, str, and wxT().

Referenced by GetID(), Load(), LoadGroup(), OldGetID(), SaveGroup(), and SettingsPath().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GetRegistryVersion()

const PluginRegistryVersion & PluginManager::GetRegistryVersion ( ) const
overridevirtual

What is the plugin registry version number now in the file? (Save() updates it)

Implements PluginManagerInterface.

Definition at line 919 of file PluginManager.cpp.

920{
921 return mRegver;
922}
PluginRegistryVersion mRegver

References mRegver.

◆ GetSettings()

FileConfig * PluginManager::GetSettings ( )
private

Definition at line 1354 of file PluginManager.cpp.

1355{
1356 if (!mSettings)
1357 {
1359
1360 // Check for a settings version that we can understand
1361 if (mSettings->HasEntry(SETVERKEY))
1362 {
1363 wxString setver = mSettings->Read(SETVERKEY, SETVERKEY);
1364 if (setver < SETVERCUR )
1365 {
1366 // This is where we'd put in conversion code when the
1367 // settings version changes.
1368 //
1369 // Should also check for a settings file that is newer than
1370 // what we can understand.
1371 }
1372 }
1373 else
1374 {
1375 // Make sure is has a version string
1376 mSettings->Write(SETVERKEY, SETVERCUR);
1377 mSettings->Flush();
1378 }
1379 }
1380
1381 return mSettings.get();
1382}
#define SETVERKEY
#define SETVERCUR
static PluginManager::FileConfigFactory sFactory
FILES_API FilePath PluginSettings()

References mSettings, FileNames::PluginSettings(), SETVERCUR, SETVERKEY, and sFactory.

Referenced by GetConfigValue(), GetSubgroups(), HasConfigValue(), HasGroup(), Initialize(), RemoveConfig(), RemoveConfigSubgroup(), and SetConfigValue().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GetSubgroups()

bool PluginManager::GetSubgroups ( const RegistryPath group,
RegistryPaths subgroups 
)
private

Definition at line 1401 of file PluginManager.cpp.

1402{
1403 if (group.empty() || !HasGroup(group))
1404 {
1405 return false;
1406 }
1407
1408 wxString path = GetSettings()->GetPath();
1409 GetSettings()->SetPath(group);
1410
1411 wxString name;
1412 long index = 0;
1413 if (GetSettings()->GetFirstGroup(name, index))
1414 {
1415 do
1416 {
1417 subgroups.push_back(name);
1418 } while (GetSettings()->GetNextGroup(name, index));
1419 }
1420
1421 GetSettings()->SetPath(path);
1422
1423 return true;
1424}
virtual const wxString & GetPath() const wxOVERRIDE
Definition: FileConfig.cpp:98
virtual void SetPath(const wxString &strPath) wxOVERRIDE
Definition: FileConfig.cpp:93
bool HasGroup(const RegistryPath &group)

References FileConfig::GetPath(), GetSettings(), HasGroup(), name, and FileConfig::SetPath().

Referenced by GetConfigSubgroups().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GetSymbol()

const ComponentInterfaceSymbol & PluginManager::GetSymbol ( const PluginID ID)

Definition at line 1127 of file PluginManager.cpp.

1128{
1129 if (auto iter = mRegisteredPlugins.find(ID); iter == mRegisteredPlugins.end()) {
1130 static ComponentInterfaceSymbol empty;
1131 return empty;
1132 }
1133 else
1134 return iter->second.GetSymbol();
1135}
ComponentInterfaceSymbol pairs a persistent string identifier used internally with an optional,...

References mRegisteredPlugins.

Referenced by EffectManager::GetCommandIdentifier(), EffectManager::GetCommandSymbol(), and ComponentInterface::GetName().

Here is the caller graph for this function:

◆ Group()

RegistryPath PluginManager::Group ( ConfigurationType  type,
const PluginID ID,
const RegistryPath group 
)
private

Definition at line 1493 of file PluginManager.cpp.

1495{
1496 auto path = SettingsPath(type, ID);
1497
1498 wxFileName ff(group);
1499 if (!ff.GetName().empty())
1500 {
1501 path += ff.GetFullPath(wxPATH_UNIX) + wxCONFIG_PATH_SEPARATOR;
1502 }
1503
1504 return path;
1505}
RegistryPath SettingsPath(ConfigurationType type, const PluginID &ID)

References SettingsPath().

Referenced by GetConfigSubgroups(), HasConfigGroup(), Key(), and RemoveConfigSubgroup().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ HasConfigGroup()

bool PluginManager::HasConfigGroup ( ConfigurationType  type,
const PluginID ID,
const RegistryPath group 
)

Definition at line 261 of file PluginManager.cpp.

263{
264 return HasGroup(Group(type, ID, group));
265}

References Group(), and HasGroup().

Here is the call graph for this function:

◆ HasConfigValue() [1/2]

bool PluginManager::HasConfigValue ( ConfigurationType  type,
const PluginID ID,
const RegistryPath group,
const RegistryPath key 
)
overridevirtual

Implements PluginManagerInterface.

Definition at line 273 of file PluginManager.cpp.

275{
276 return HasConfigValue(Key(type, ID, group, key));
277}
bool HasConfigValue(ConfigurationType type, const PluginID &ID, const RegistryPath &group, const RegistryPath &key) override

References HasConfigValue(), Key(), and key.

Referenced by HasConfigValue().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ HasConfigValue() [2/2]

bool PluginManager::HasConfigValue ( const RegistryPath key)
private

Definition at line 1426 of file PluginManager.cpp.

1427{
1428 return GetSettings()->Exists(key);
1429}

References GetSettings(), and key.

Here is the call graph for this function:

◆ HasGroup()

bool PluginManager::HasGroup ( const RegistryPath group)
private

Definition at line 1384 of file PluginManager.cpp.

1385{
1386 auto settings = GetSettings();
1387
1388 bool res = settings->HasGroup(group);
1389 if (res)
1390 {
1391 // The group exists, but empty groups aren't considered valid
1392 wxString oldPath = settings->GetPath();
1393 settings->SetPath(group);
1394 res = settings->GetNumberOfEntries() || settings->GetNumberOfGroups();
1395 settings->SetPath(oldPath);
1396 }
1397
1398 return res;
1399}
static Settings & settings()
Definition: TrackInfo.cpp:83

References GetSettings(), and settings().

Referenced by GetSubgroups(), and HasConfigGroup().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ Initialize()

void PluginManager::Initialize ( FileConfigFactory  factory)
Precondition
factory != nullptr

Definition at line 389 of file PluginManager.cpp.

390{
391 sFactory = move(factory);
392
393 // Always load the registry first
394 Load();
395
396 // And force load of setting to verify it's accessible
397 GetSettings();
398
399 auto &mm = ModuleManager::Get();
400 mm.DiscoverProviders();
401 for (auto& [id, module] : mm.Providers()) {
402 RegisterPlugin(module.get());
403 // Allow the module to auto-register children
404 module->AutoRegisterPlugins(*this);
405 }
406
408}
void Load()
Load from preferences.
void RegisterPlugin(PluginDescriptor &&desc)
void InitializePlugins()
static RegisteredToolbarFactory factory

References cloud::factory, ModuleManager::Get(), GetSettings(), InitializePlugins(), Load(), RegisterPlugin(), and sFactory.

Referenced by AudacityApp::InitPart2().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ InitializePlugins()

void PluginManager::InitializePlugins ( )
private

Definition at line 341 of file PluginManager.cpp.

342{
343 ModuleManager & moduleManager = ModuleManager::Get();
344 //ModuleManager::DiscoverProviders was called earlier, so we
345 //can be sure that providers are already loaded
346
347 //Check all known plugins to ensure they are still valid.
348 for (auto it = mRegisteredPlugins.begin(); it != mRegisteredPlugins.end();) {
349 auto &pluginDesc = it->second;
350 const auto pluginType = pluginDesc.GetPluginType();
351 if(pluginType == PluginTypeNone || pluginType == PluginTypeModule)
352 {
353 ++it;
354 continue;
355 }
356
357 if(!moduleManager.CheckPluginExist(pluginDesc.GetProviderID(), pluginDesc.GetPath()))
358 it = mRegisteredPlugins.erase(it);
359 else
360 ++it;
361 }
362
363 Save();
364}
bool CheckPluginExist(const PluginID &providerId, const PluginPath &path)

References ModuleManager::CheckPluginExist(), ModuleManager::Get(), mRegisteredPlugins, PluginTypeModule, PluginTypeNone, and Save().

Referenced by Initialize().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ IsDirty()

bool PluginManager::IsDirty ( )
private

◆ IsPluginAvailable()

bool PluginManager::IsPluginAvailable ( const PluginDescriptor plug)
static

Definition at line 1316 of file PluginManager.cpp.

1317{
1318 const auto& providerID = plug.GetProviderID();
1319 auto provider = ModuleManager::Get().CreateProviderInstance(providerID, wxEmptyString);
1320
1321 if (provider == nullptr)
1322 {
1323 wxLogWarning("Unable to find a provider for '%s'", providerID);
1324 return false;
1325 }
1326
1327 if (provider->CheckPluginExist(plug.GetPath()) == false)
1328 {
1329 wxLogWarning("Plugin '%s' does not exist", plug.GetID());
1330 return false;
1331 }
1332
1333 return true;
1334}
PluginProvider * CreateProviderInstance(const PluginID &provider, const PluginPath &path)
const wxString & GetProviderID() const

References ModuleManager::CreateProviderInstance(), ModuleManager::Get(), PluginDescriptor::GetID(), PluginDescriptor::GetPath(), and PluginDescriptor::GetProviderID().

Referenced by EffectUI::DoEffect(), RealtimeEffectListWindow::OnAddEffectClicked(), and anonymous_namespace{FileMenus.cpp}::OnOpen().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ IsPluginEnabled()

bool PluginManager::IsPluginEnabled ( const PluginID ID)

Definition at line 1111 of file PluginManager.cpp.

1112{
1113 if (auto iter = mRegisteredPlugins.find(ID); iter == mRegisteredPlugins.end())
1114 return false;
1115 else
1116 return iter->second.IsEnabled();
1117}

References mRegisteredPlugins.

◆ IsPluginLoaded()

bool PluginManager::IsPluginLoaded ( const wxString &  ID) const

Definition at line 149 of file PluginManager.cpp.

150{
151 return mLoadedInterfaces.find(ID) != mLoadedInterfaces.end();
152}
std::map< PluginID, std::unique_ptr< ComponentInterface > > mLoadedInterfaces

References mLoadedInterfaces.

◆ IsPluginRegistered()

bool PluginManager::IsPluginRegistered ( const PluginPath path,
const TranslatableString pName 
)
overridevirtual

Was the plugin registry already populated for a path (maybe from loading the config file)?

Parameters
pathan identifier for the plug-in with meaning defined by provider; not always a file path
pNameif supplied, a correction for the user visible name associated with the plug-in, if it is registered already. (Needed because the configuration file only stores an internal name.)

Implements PluginManagerInterface.

Definition at line 135 of file PluginManager.cpp.

137{
138 for (auto &pair : mRegisteredPlugins) {
139 if (auto &descriptor = pair.second; descriptor.GetPath() == path) {
140 if (pName)
141 descriptor.SetSymbol(
142 { descriptor.GetSymbol().Internal(), *pName });
143 return true;
144 }
145 }
146 return false;
147}
@ Internal
Indicates internal failure from Audacity.

References Internal, and mRegisteredPlugins.

◆ Key()

RegistryPath PluginManager::Key ( ConfigurationType  type,
const PluginID ID,
const RegistryPath group,
const RegistryPath key 
)
private

Definition at line 1508 of file PluginManager.cpp.

1510{
1511 auto path = Group(type, ID, group);
1512 if (path.empty())
1513 {
1514 return path;
1515 }
1516
1517 return path + key;
1518}

References Group(), and key.

Referenced by GetConfigValue(), HasConfigValue(), RemoveConfig(), and SetConfigValue().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ Load() [1/2]

void PluginManager::Load ( )

Load from preferences.

Definition at line 540 of file PluginManager.cpp.

541{
542 // Create/Open the registry
543 auto pRegistry = sFactory(FileNames::PluginRegistry());
544 auto &registry = *pRegistry;
545
546 // If this group doesn't exist then we have something that's not a registry.
547 // We should probably warn the user, but it's pretty unlikely that this will happen.
548 if (!registry.HasGroup(REGROOT))
549 {
550 // Must start over
551 // This DeleteAll affects pluginregistry.cfg only, not audacity.cfg
552 // That is, the memory of on/off states of effect (and generator,
553 // analyzer, and tool) plug-ins
554 registry.DeleteAll();
555 registry.Flush();
556 return;
557 }
558
559 // Check for a registry version that we can understand
560 // TODO: Should also check for a registry file that is newer than
561 // what we can understand.
562 mRegver = registry.Read(REGVERKEY);
563 if (Regver_lt(mRegver, "1.1")) {
564 // Conversion code here, for when registry version changes.
565
566 // We iterate through the effects, possibly updating their info.
567 wxString groupName;
568 long groupIndex;
569 wxString group = GetPluginTypeString(PluginTypeEffect);
570 wxString cfgPath = REGROOT + group + wxCONFIG_PATH_SEPARATOR;
571 wxArrayString groupsToDelete;
572
573 registry.SetPath(cfgPath);
574 for (bool cont = registry.GetFirstGroup(groupName, groupIndex);
575 cont;
576 registry.SetPath(cfgPath),
577 cont = registry.GetNextGroup(groupName, groupIndex))
578 {
579 registry.SetPath(groupName);
580 wxString effectSymbol = registry.Read(KEY_SYMBOL, "");
581 wxString effectVersion = registry.Read(KEY_VERSION, "");
582
583
584 // For 2.3.0 the plugins we distribute have moved around.
585 // So we upped the registry version number to 1.1.
586 // These particular config edits were originally written to fix Bug 1914.
587 if (Regver_le(mRegver, "1.0")) {
588 // Nyquist prompt is a built-in that has moved to the tools menu.
589 if (effectSymbol == NYQUIST_PROMPT_ID) {
590 registry.Write(KEY_EFFECTTYPE, "Tool");
591 // Old version of SDE was in Analyze menu. Now it is in Tools.
592 // We don't want both the old and the new.
593 } else if ((effectSymbol == "Sample Data Export") && (effectVersion == "n/a")) {
594 groupsToDelete.push_back(cfgPath + groupName);
595 // Old version of SDI was in Generate menu. Now it is in Tools.
596 } else if ((effectSymbol == "Sample Data Import") && (effectVersion == "n/a")) {
597 groupsToDelete.push_back(cfgPath + groupName);
598 }
599 }
600
601 }
602 // Doing the deletion within the search loop risked skipping some items,
603 // hence the delayed delete.
604 for (unsigned int i = 0; i < groupsToDelete.size(); i++) {
605 registry.DeleteGroup(groupsToDelete[i]);
606 }
607 registry.SetPath("");
608 // Updates done. Make sure we read the updated data later.
609 registry.Flush();
610 }
611
612 // Load all provider plugins first
613 LoadGroup(&registry, PluginTypeModule);
614
615 // Now the rest
616 LoadGroup(&registry, PluginTypeEffect);
618 LoadGroup(&registry, PluginTypeExporter);
619 LoadGroup(&registry, PluginTypeImporter);
620
621 LoadGroup(&registry, PluginTypeStub);
622 return;
623}
bool Regver_lt(const PluginRegistryVersion &regver1, const PluginRegistryVersion &regver2)
bool Regver_le(const PluginRegistryVersion &regver1, const PluginRegistryVersion &regver2)
#define REGVERKEY
#define KEY_SYMBOL
#define REGROOT
#define KEY_VERSION
#define KEY_EFFECTTYPE
#define NYQUIST_PROMPT_ID
void LoadGroup(FileConfig *pRegistry, PluginType type)
FILES_API FilePath PluginRegistry()

References GetPluginTypeString(), KEY_EFFECTTYPE, KEY_SYMBOL, KEY_VERSION, LoadGroup(), mRegver, NYQUIST_PROMPT_ID, FileNames::PluginRegistry(), PluginTypeAudacityCommand, PluginTypeEffect, PluginTypeExporter, PluginTypeImporter, PluginTypeModule, PluginTypeStub, REGROOT, Regver_le(), Regver_lt(), REGVERKEY, and sFactory.

Referenced by Initialize().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ Load() [2/2]

ComponentInterface * PluginManager::Load ( const PluginID ID)

Definition at line 1137 of file PluginManager.cpp.

1138{
1139 if(auto it = mLoadedInterfaces.find(ID); it != mLoadedInterfaces.end())
1140 return it->second.get();
1141
1142 if(auto it = mRegisteredPlugins.find(ID); it != mRegisteredPlugins.end())
1143 {
1144 auto& desc = it->second;
1145 if(desc.GetPluginType() == PluginTypeModule)
1146 //it's very likely that this code path is not used
1147 return ModuleManager::Get().CreateProviderInstance(desc.GetID(), desc.GetPath());
1148
1149 if(auto provider = ModuleManager::Get().CreateProviderInstance(desc.GetProviderID(), wxEmptyString))
1150 {
1151 auto pluginInterface = provider->LoadPlugin(desc.GetPath());
1152 auto result = pluginInterface.get();
1153 mLoadedInterfaces[desc.GetID()] = std::move(pluginInterface);
1154 return result;
1155 }
1156 }
1157 return nullptr;
1158}
virtual std::unique_ptr< ComponentInterface > LoadPlugin(const PluginPath &path)=0
Load the plug-in at a path reported by DiscoverPluginsAtPath.

References ModuleManager::CreateProviderInstance(), desc, ModuleManager::Get(), PluginProvider::LoadPlugin(), mLoadedInterfaces, mRegisteredPlugins, and PluginTypeModule.

Referenced by EffectManager::GetAudacityCommand().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ LoadGroup()

void PluginManager::LoadGroup ( FileConfig pRegistry,
PluginType  type 
)
private

Definition at line 625 of file PluginManager.cpp.

626{
627#ifdef __WXMAC__
628 // Bug 1590: On Mac, we should purge the registry of Nyquist plug-ins
629 // bundled with other versions of Audacity, assuming both versions
630 // were properly installed in /Applications (or whatever it is called in
631 // your locale)
632
633 const auto fullExePath = PlatformCompatibility::GetExecutablePath();
634
635 // Strip rightmost path components up to *.app
636 wxFileName exeFn{ fullExePath };
637 exeFn.SetEmptyExt();
638 exeFn.SetName(wxString{});
639 while(exeFn.GetDirCount() && !exeFn.GetDirs().back().EndsWith(".app"))
640 exeFn.RemoveLastDir();
641
642 const auto goodPath = exeFn.GetPath();
643
644 if(exeFn.GetDirCount())
645 exeFn.RemoveLastDir();
646 const auto possiblyBadPath = exeFn.GetPath();
647
648 auto AcceptPath = [&](const wxString &path) {
649 if (!path.StartsWith(possiblyBadPath))
650 // Assume it's not under /Applications
651 return true;
652 if (path.StartsWith(goodPath))
653 // It's bundled with this executable
654 return true;
655 return false;
656 };
657#else
658 auto AcceptPath = [](const wxString&){ return true; };
659#endif
660
661 wxString strVal;
662 bool boolVal;
663 wxString groupName;
664 long groupIndex;
665 wxString group = GetPluginTypeString(type);
666 wxString cfgPath = REGROOT + group + wxCONFIG_PATH_SEPARATOR;
667
668 pRegistry->SetPath(cfgPath);
669 for (bool cont = pRegistry->GetFirstGroup(groupName, groupIndex);
670 cont;
671 pRegistry->SetPath(cfgPath),
672 cont = pRegistry->GetNextGroup(groupName, groupIndex))
673 {
674 PluginDescriptor plug;
675
676 pRegistry->SetPath(groupName);
677
678 groupName = ConvertID(groupName);
679
680 // Bypass group if the ID is already in use
681 if (mRegisteredPlugins.count(groupName))
682 continue;
683
684 // Set the ID and type
685 plug.SetID(groupName);
686 plug.SetPluginType(type);
687
688 // Get the provider ID and bypass group if not found
689 if (!pRegistry->Read(KEY_PROVIDERID, &strVal, wxEmptyString))
690 {
691 // Bypass group if the provider isn't valid
692 if (!strVal.empty() && !mRegisteredPlugins.count(strVal))
693 continue;
694 }
695 plug.SetProviderID(PluginID(strVal));
696
697 // Get the path (optional)
698 pRegistry->Read(KEY_PATH, &strVal, wxEmptyString);
699 if (!AcceptPath(strVal))
700 // Ignore the obsolete path in the config file, during session,
701 // but don't remove it from the file. Maybe you really want to
702 // switch back to the other version of Audacity and lose nothing.
703 continue;
704 plug.SetPath(strVal);
705
706 /*
707 // PRL: Ignore names written in configs before 2.3.0!
708 // use Internal string only! Let the present version of Audacity map
709 // that to a user-visible string.
710 // Get the name and bypass group if not found
711 if (!pRegistry->Read(KEY_NAME, &strVal))
712 {
713 continue;
714 }
715 plug.SetName(strVal);
716 */
717
718 // Get the symbol...Audacity 2.3.0 or later requires it
719 // bypass group if not found
720 // Note, KEY_SYMBOL started getting written to config files in 2.1.0.
721 // KEY_NAME (now ignored) was written before that, but only for VST
722 // effects.
723 if (!pRegistry->Read(KEY_SYMBOL, &strVal))
724 continue;
725
726 // Related to Bug2778: config file only remembered an internal name,
727 // so this symbol may not contain the correct TranslatableString.
728 // See calls to IsPluginRegistered which can correct that.
729 plug.SetSymbol(strVal);
730
731 // Get the version and bypass group if not found
732 if (!pRegistry->Read(KEY_VERSION, &strVal))
733 {
734 continue;
735 }
736 plug.SetVersion(strVal);
737
738 // Get the vendor and bypass group if not found
739 if (!pRegistry->Read(KEY_VENDOR, &strVal))
740 {
741 continue;
742 }
743 plug.SetVendor( strVal );
744
745#if 0
746 // This was done before version 2.2.2, but the value was not really used
747 // But absence of a value will cause early versions to skip the group
748 // Therefore we still write a blank to keep pluginregistry.cfg
749 // backwards-compatible
750
751 // Get the description and bypass group if not found
752 if (!pRegistry->Read(KEY_DESCRIPTION, &strVal))
753 {
754 continue;
755 }
756#endif
757
758 // Is it enabled...default to no if not found
759 pRegistry->Read(KEY_ENABLED, &boolVal, false);
760 plug.SetEnabled(boolVal);
761
762 // Is it valid...default to no if not found
763 pRegistry->Read(KEY_VALID, &boolVal, false);
764 plug.SetValid(boolVal);
765
766 switch (type)
767 {
768 case PluginTypeModule:
769 {
770 // Nothing to do here yet
771 }
772 break;
773
774 case PluginTypeEffect:
775 {
776 // Get the effect type and bypass group if not found
777 if (!pRegistry->Read(KEY_EFFECTTYPE, &strVal))
778 continue;
779
780 if (strVal == KEY_EFFECTTYPE_NONE)
782 else if (strVal == KEY_EFFECTTYPE_ANALYZE)
784 else if (strVal == KEY_EFFECTTYPE_GENERATE)
786 else if (strVal == KEY_EFFECTTYPE_PROCESS)
788 else if (strVal == KEY_EFFECTTYPE_TOOL)
790 else if (strVal == KEY_EFFECTTYPE_HIDDEN)
792 else
793 continue;
794
795 // Get the effect family and bypass group if not found
796 if (!pRegistry->Read(KEY_EFFECTFAMILY, &strVal))
797 {
798 continue;
799 }
800 plug.SetEffectFamily(strVal);
801
802 // Is it a default (above the line) effect and bypass group if not found
803 if (!pRegistry->Read(KEY_EFFECTDEFAULT, &boolVal))
804 {
805 continue;
806 }
807 plug.SetEffectDefault(boolVal);
808
809 // Is it an interactive effect and bypass group if not found
810 if (!pRegistry->Read(KEY_EFFECTINTERACTIVE, &boolVal))
811 {
812 continue;
813 }
814 plug.SetEffectInteractive(boolVal);
815
816 // Is it a realtime capable effect and bypass group if not found
817 if (!pRegistry->Read(KEY_EFFECTREALTIME, &strVal))
818 {
819 continue;
820 }
821 plug.DeserializeRealtimeSupport(strVal);
822
823 // Does the effect support automation...bypass group if not found
824 if (!pRegistry->Read(KEY_EFFECTAUTOMATABLE, &boolVal))
825 {
826 continue;
827 }
828 plug.SetEffectAutomatable(boolVal);
829 }
830 break;
831
833 {
834 // Get the importer identifier and bypass group if not found
835 if (!pRegistry->Read(KEY_IMPORTERIDENT, &strVal))
836 {
837 continue;
838 }
839 plug.SetImporterIdentifier(strVal);
840
841 // Get the importer extensions and bypass group if not found
842 if (!pRegistry->Read(KEY_IMPORTEREXTENSIONS, &strVal))
843 {
844 continue;
845 }
846 FileExtensions extensions;
847 wxStringTokenizer tkr(strVal, wxT(":"));
848 while (tkr.HasMoreTokens())
849 {
850 extensions.push_back(tkr.GetNextToken());
851 }
852 plug.SetImporterExtensions(extensions);
853 }
854 break;
855
856 case PluginTypeStub:
857 {
858 // Nothing additional for stubs
859 }
860 break;
861
862 // Not used by 2.1.1 or greater and should be removed after a few releases past 2.1.0.
863 case PluginTypeNone:
864 {
865 // Used for stub groups
866 }
867 break;
868
869 default:
870 {
871 continue;
872 }
873 }
874
875 // Everything checked out...accept the plugin
876 mRegisteredPlugins[groupName] = std::move(plug);
877 }
878
879 return;
880}
@ EffectTypeHidden
@ EffectTypeAnalyze
@ EffectTypeGenerate
@ EffectTypeNone
@ EffectTypeTool
@ EffectTypeProcess
#define KEY_EFFECTAUTOMATABLE
#define KEY_PROVIDERID
#define KEY_IMPORTEREXTENSIONS
#define KEY_EFFECTTYPE_TOOL
#define KEY_VENDOR
#define KEY_PATH
#define KEY_IMPORTERIDENT
#define KEY_EFFECTTYPE_GENERATE
#define KEY_EFFECTTYPE_PROCESS
#define KEY_EFFECTINTERACTIVE
#define KEY_EFFECTTYPE_HIDDEN
#define KEY_ENABLED
#define KEY_EFFECTREALTIME
#define KEY_EFFECTTYPE_NONE
#define KEY_EFFECTFAMILY
#define KEY_VALID
#define KEY_EFFECTTYPE_ANALYZE
#define KEY_DESCRIPTION
#define KEY_EFFECTDEFAULT
virtual bool GetNextGroup(wxString &str, long &lIndex) const wxOVERRIDE
Definition: FileConfig.cpp:108
virtual bool GetFirstGroup(wxString &str, long &lIndex) const wxOVERRIDE
Definition: FileConfig.cpp:103
void SetEnabled(bool enable)
void SetImporterExtensions(FileExtensions extensions)
void SetImporterIdentifier(const wxString &identifier)
void SetValid(bool valid)
void SetProviderID(const PluginID &providerID)
void SetEffectType(EffectType type)
void SetEffectFamily(const wxString &family)
void SetEffectAutomatable(bool automatable)
void SetEffectDefault(bool dflt)
void SetEffectInteractive(bool interactive)
void DeserializeRealtimeSupport(const wxString &value)
for deserialization
wxString ConvertID(const PluginID &ID)

References ConvertID(), PluginDescriptor::DeserializeRealtimeSupport(), EffectTypeAnalyze, EffectTypeGenerate, EffectTypeHidden, EffectTypeNone, EffectTypeProcess, EffectTypeTool, PlatformCompatibility::GetExecutablePath(), FileConfig::GetFirstGroup(), FileConfig::GetNextGroup(), GetPluginTypeString(), KEY_DESCRIPTION, KEY_EFFECTAUTOMATABLE, KEY_EFFECTDEFAULT, KEY_EFFECTFAMILY, KEY_EFFECTINTERACTIVE, KEY_EFFECTREALTIME, KEY_EFFECTTYPE, KEY_EFFECTTYPE_ANALYZE, KEY_EFFECTTYPE_GENERATE, KEY_EFFECTTYPE_HIDDEN, KEY_EFFECTTYPE_NONE, KEY_EFFECTTYPE_PROCESS, KEY_EFFECTTYPE_TOOL, KEY_ENABLED, KEY_IMPORTEREXTENSIONS, KEY_IMPORTERIDENT, KEY_PATH, KEY_PROVIDERID, KEY_SYMBOL, KEY_VALID, KEY_VENDOR, KEY_VERSION, mRegisteredPlugins, PluginTypeEffect, PluginTypeImporter, PluginTypeModule, PluginTypeNone, PluginTypeStub, REGROOT, PluginDescriptor::SetEffectAutomatable(), PluginDescriptor::SetEffectDefault(), PluginDescriptor::SetEffectFamily(), PluginDescriptor::SetEffectInteractive(), PluginDescriptor::SetEffectType(), PluginDescriptor::SetEnabled(), PluginDescriptor::SetID(), PluginDescriptor::SetImporterExtensions(), PluginDescriptor::SetImporterIdentifier(), PluginDescriptor::SetPath(), FileConfig::SetPath(), PluginDescriptor::SetPluginType(), PluginDescriptor::SetProviderID(), PluginDescriptor::SetSymbol(), PluginDescriptor::SetValid(), PluginDescriptor::SetVendor(), PluginDescriptor::SetVersion(), and wxT().

Referenced by Load().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ NotifyPluginsChanged()

void PluginManager::NotifyPluginsChanged ( )

Definition at line 914 of file PluginManager.cpp.

915{
917}
CallbackReturn Publish(const PluginsChangedMessage &message)
Send a message to connected callbacks.
Definition: Observer.h:207

References Observer::Publisher< PluginsChangedMessage >::Publish().

Referenced by DropFile(), PluginRegistrationDialog::OnOK(), and PluginStartupRegistration::Run().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ OldGetID()

PluginID PluginManager::OldGetID ( const EffectDefinitionInterface effect)
static

Definition at line 1252 of file PluginManager.cpp.

1253{
1254 return wxString::Format(wxT("%s_%s_%s_%s_%s"),
1256 effect->GetFamily().Internal(),
1257 effect->GetVendor().Internal(),
1258 effect->GetSymbol().Internal(),
1259 effect->GetPath());
1260}

References EffectDefinitionInterface::GetFamily(), ComponentInterface::GetPath(), GetPluginTypeString(), ComponentInterface::GetSymbol(), ComponentInterface::GetVendor(), ComponentInterfaceSymbol::Internal(), PluginTypeEffect, and wxT().

Here is the call graph for this function:

◆ PluginsOfType()

Range PluginManager::PluginsOfType ( int  type)
inline

Definition at line 154 of file PluginManager.h.

154{ return { Iterator{ *this, type } }; }

Referenced by DropFile(), EffectManager::GetEffectByIdentifier(), MacroCommandsCatalog::MacroCommandsCatalog(), and GetInfoCommand::SendCommands().

Here is the caller graph for this function:

◆ RegisterPlugin() [1/5]

void PluginManager::RegisterPlugin ( PluginDescriptor &&  desc)

Definition at line 154 of file PluginManager.cpp.

155{
156 mRegisteredPlugins[desc.GetID()] = std::move(desc);
157}

References desc, and mRegisteredPlugins.

Referenced by PluginManagerInterface::AudacityCommandRegistrationCallback(), PluginManagerInterface::DefaultRegistrationCallback(), Initialize(), PluginStartupRegistration::OnPluginFound(), PluginStartupRegistration::OnValidationFinished(), and EffectManager::RegisterEffect().

Here is the caller graph for this function:

◆ RegisterPlugin() [2/5]

const PluginID & PluginManager::RegisterPlugin ( PluginProvider provider)
overridevirtual

Implements PluginManagerInterface.

Definition at line 159 of file PluginManager.cpp.

160{
161 PluginDescriptor & plug =
162 CreatePlugin(GetID(provider), provider, PluginTypeModule);
164
165 plug.SetEnabled(true);
166 plug.SetValid(true);
167
168 return plug.GetID();
169}
static PluginID GetID(PluginProvider *provider)
PluginDescriptor & CreatePlugin(const PluginID &id, ComponentInterface *ident, PluginType type)
virtual EffectFamilySymbol GetOptionalFamilySymbol()=0
A symbol identifying the family of plug-ins provided by this.

References CreatePlugin(), PluginDescriptor::GetID(), GetID(), PluginProvider::GetOptionalFamilySymbol(), ComponentInterfaceSymbol::Internal(), PluginTypeModule, PluginDescriptor::SetEffectFamily(), PluginDescriptor::SetEnabled(), and PluginDescriptor::SetValid().

Here is the call graph for this function:

◆ RegisterPlugin() [3/5]

const PluginID & PluginManager::RegisterPlugin ( PluginProvider provider,
ComponentInterface command 
)

Definition at line 171 of file PluginManager.cpp.

173{
175
176 plug.SetProviderID(PluginManager::GetID(provider));
177
178 plug.SetEnabled(true);
179 plug.SetValid(true);
180
181 return plug.GetID();
182}
PluginType

References CreatePlugin(), PluginDescriptor::GetID(), GetID(), PluginTypeAudacityCommand, PluginDescriptor::SetEnabled(), PluginDescriptor::SetProviderID(), and PluginDescriptor::SetValid().

Here is the call graph for this function:

◆ RegisterPlugin() [4/5]

const PluginID & PluginManager::RegisterPlugin ( PluginProvider provider,
EffectDefinitionInterface effect,
int  type 
)
overridevirtual

Implements PluginManagerInterface.

Definition at line 184 of file PluginManager.cpp.

186{
187 PluginDescriptor & plug = CreatePlugin(GetID(effect), effect, (PluginType)type);
188
189 plug.SetProviderID(PluginManager::GetID(provider));
190
191 plug.SetEffectType(effect->GetClassification());
192 plug.SetEffectFamily(effect->GetFamily().Internal());
193 plug.SetEffectInteractive(effect->IsInteractive());
194 plug.SetEffectDefault(effect->IsDefault());
195 plug.SetRealtimeSupport(effect->RealtimeSupport());
197
198 plug.SetEnabled(true);
199 plug.SetValid(true);
200
201 return plug.GetID();
202}
virtual EffectType GetClassification() const
Determines which menu it appears in; default same as GetType().
virtual bool IsDefault() const =0
Whether the effect sorts "above the line" in the menus.
virtual bool IsInteractive() const =0
Whether the effect needs a dialog for entry of settings.
virtual bool SupportsAutomation() const =0
Whether the effect has any automatable controls.
virtual RealtimeSince RealtimeSupport() const =0
Since which version of Audacity has the effect supported realtime?
void SetRealtimeSupport(EffectDefinitionInterface::RealtimeSince realtime)

References CreatePlugin(), EffectDefinitionInterface::GetClassification(), EffectDefinitionInterface::GetFamily(), PluginDescriptor::GetID(), GetID(), ComponentInterfaceSymbol::Internal(), EffectDefinitionInterface::IsDefault(), EffectDefinitionInterface::IsInteractive(), EffectDefinitionInterface::RealtimeSupport(), PluginDescriptor::SetEffectAutomatable(), PluginDescriptor::SetEffectDefault(), PluginDescriptor::SetEffectFamily(), PluginDescriptor::SetEffectInteractive(), PluginDescriptor::SetEffectType(), PluginDescriptor::SetEnabled(), PluginDescriptor::SetProviderID(), PluginDescriptor::SetRealtimeSupport(), PluginDescriptor::SetValid(), and EffectDefinitionInterface::SupportsAutomation().

Here is the call graph for this function:

◆ RegisterPlugin() [5/5]

const PluginID & PluginManager::RegisterPlugin ( std::unique_ptr< EffectDefinitionInterface effect,
PluginType  type 
)

Used only by Nyquist Workbench module.

Definition at line 1009 of file PluginManager.cpp.

1011{
1012 PluginDescriptor & plug =
1013 CreatePlugin(GetID(effect.get()), effect.get(), type);
1014
1015 plug.SetEffectType(effect->GetType());
1016 plug.SetEffectFamily(effect->GetFamily().Internal());
1017 plug.SetEffectInteractive(effect->IsInteractive());
1018 plug.SetEffectDefault(effect->IsDefault());
1019 plug.SetRealtimeSupport(effect->RealtimeSupport());
1020 plug.SetEffectAutomatable(effect->SupportsAutomation());
1021
1022 plug.SetEffectLegacy(true);
1023 plug.SetEnabled(true);
1024 plug.SetValid(true);
1025
1026 mLoadedInterfaces[plug.GetID()] = std::move(effect);
1027
1028 return plug.GetID();
1029}
void SetEffectLegacy(bool legacy)

References CreatePlugin(), PluginDescriptor::GetID(), GetID(), mLoadedInterfaces, PluginDescriptor::SetEffectAutomatable(), PluginDescriptor::SetEffectDefault(), PluginDescriptor::SetEffectFamily(), PluginDescriptor::SetEffectInteractive(), PluginDescriptor::SetEffectLegacy(), PluginDescriptor::SetEffectType(), PluginDescriptor::SetEnabled(), PluginDescriptor::SetRealtimeSupport(), and PluginDescriptor::SetValid().

Here is the call graph for this function:

◆ RemoveConfig()

bool PluginManager::RemoveConfig ( ConfigurationType  type,
const PluginID ID,
const RegistryPath group,
const RegistryPath key 
)
overridevirtual

Implements PluginManagerInterface.

Definition at line 305 of file PluginManager.cpp.

307{
308 bool result = GetSettings()->DeleteEntry(Key(type, ID, group, key));
309 if (result)
310 {
311 GetSettings()->Flush();
312 }
313
314 return result;
315}
virtual bool DeleteEntry(const wxString &key, bool bDeleteGroupIfEmpty=true) wxOVERRIDE
Definition: FileConfig.cpp:209
virtual bool Flush(bool bCurrentOnly=false) wxOVERRIDE
Definition: FileConfig.cpp:143

References FileConfig::DeleteEntry(), FileConfig::Flush(), GetSettings(), Key(), and key.

Here is the call graph for this function:

◆ RemoveConfigSubgroup()

bool PluginManager::RemoveConfigSubgroup ( ConfigurationType  type,
const PluginID ID,
const RegistryPath group 
)
overridevirtual

Implements PluginManagerInterface.

Definition at line 293 of file PluginManager.cpp.

295{
296 bool result = GetSettings()->DeleteGroup(Group(type, ID, group));
297 if (result)
298 {
299 GetSettings()->Flush();
300 }
301
302 return result;
303}
virtual bool DeleteGroup(const wxString &key) wxOVERRIDE
Definition: FileConfig.cpp:219

References FileConfig::DeleteGroup(), FileConfig::Flush(), GetSettings(), and Group().

Here is the call graph for this function:

◆ Save()

void PluginManager::Save ( )

Save to preferences.

Definition at line 882 of file PluginManager.cpp.

883{
884 // Create/Open the registry
885 auto pRegistry = sFactory(FileNames::PluginRegistry());
886 auto &registry = *pRegistry;
887
888 // Clear pluginregistry.cfg (not audacity.cfg)
889 registry.DeleteAll();
890
891 // Save the individual groups
892 SaveGroup(&registry, PluginTypeEffect);
893 SaveGroup(&registry, PluginTypeExporter);
895 SaveGroup(&registry, PluginTypeImporter);
896 SaveGroup(&registry, PluginTypeStub);
897
898 // Not used by 2.1.1 or greater, but must save to allow users to switch between 2.1.0
899 // and 2.1.1+. This should be removed after a few releases past 2.1.0.
900 //SaveGroup(&registry, PluginTypeNone);
901
902 // And now the providers
903 SaveGroup(&registry, PluginTypeModule);
904
905 // Write the version string
906 registry.Write(REGVERKEY, REGVERCUR);
907
908 // Just to be safe
909 registry.Flush();
910
912}
constexpr auto REGVERCUR
void SaveGroup(FileConfig *pRegistry, PluginType type)

References mRegver, FileNames::PluginRegistry(), PluginTypeAudacityCommand, PluginTypeEffect, PluginTypeExporter, PluginTypeImporter, PluginTypeModule, PluginTypeStub, REGVERCUR, REGVERKEY, SaveGroup(), and sFactory.

Referenced by DropFile(), InitializePlugins(), PluginRegistrationDialog::OnOK(), and PluginStartupRegistration::Run().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ SaveGroup()

void PluginManager::SaveGroup ( FileConfig pRegistry,
PluginType  type 
)
private

Definition at line 924 of file PluginManager.cpp.

925{
926 wxString group = GetPluginTypeString(type);
927 for (auto &pair : mRegisteredPlugins) {
928 auto & plug = pair.second;
929
930 if (plug.GetPluginType() != type)
931 {
932 continue;
933 }
934
935 pRegistry->SetPath(REGROOT + group + wxCONFIG_PATH_SEPARATOR + ConvertID(plug.GetID()));
936
937 pRegistry->Write(KEY_PATH, plug.GetPath());
938
939 // See comments with the corresponding load-time call to SetSymbol().
940 pRegistry->Write(KEY_SYMBOL, plug.GetSymbol().Internal());
941
942 // PRL: Writing KEY_NAME which is no longer read, but older Audacity
943 // versions expect to find it.
944 pRegistry->Write(KEY_NAME, plug.GetSymbol().Msgid().MSGID());
945
946 pRegistry->Write(KEY_VERSION, plug.GetUntranslatedVersion());
947 pRegistry->Write(KEY_VENDOR, plug.GetVendor());
948 // Write a blank -- see comments in LoadGroup:
949 pRegistry->Write(KEY_DESCRIPTION, wxString{});
950 pRegistry->Write(KEY_PROVIDERID, plug.GetProviderID());
951 pRegistry->Write(KEY_ENABLED, plug.IsEnabled());
952 pRegistry->Write(KEY_VALID, plug.IsValid());
953
954 switch (type)
955 {
956 case PluginTypeModule:
957 break;
958
959 case PluginTypeEffect:
960 {
961 EffectType etype = plug.GetEffectType();
962 wxString stype;
963 if (etype == EffectTypeNone)
964 stype = KEY_EFFECTTYPE_NONE;
965 else if (etype == EffectTypeAnalyze)
967 else if (etype == EffectTypeGenerate)
969 else if (etype == EffectTypeProcess)
971 else if (etype == EffectTypeTool)
972 stype = KEY_EFFECTTYPE_TOOL;
973 else if (etype == EffectTypeHidden)
974 stype = KEY_EFFECTTYPE_HIDDEN;
975
976 pRegistry->Write(KEY_EFFECTTYPE, stype);
977 pRegistry->Write(KEY_EFFECTFAMILY, plug.GetEffectFamily());
978 pRegistry->Write(KEY_EFFECTDEFAULT, plug.IsEffectDefault());
979 pRegistry->Write(KEY_EFFECTINTERACTIVE, plug.IsEffectInteractive());
980 pRegistry->Write(KEY_EFFECTREALTIME, plug.SerializeRealtimeSupport());
981 pRegistry->Write(KEY_EFFECTAUTOMATABLE, plug.IsEffectAutomatable());
982 }
983 break;
984
986 {
987 pRegistry->Write(KEY_IMPORTERIDENT, plug.GetImporterIdentifier());
988 const auto & extensions = plug.GetImporterExtensions();
989 wxString strExt;
990 for (size_t i = 0, cnt = extensions.size(); i < cnt; i++)
991 {
992 strExt += extensions[i] + wxT(":");
993 }
994 strExt.RemoveLast(1);
995 pRegistry->Write(KEY_IMPORTEREXTENSIONS, strExt);
996 }
997 break;
998
999 default:
1000 break;
1001 }
1002 }
1003
1004 return;
1005}
EffectType
#define KEY_NAME

References ConvertID(), EffectTypeAnalyze, EffectTypeGenerate, EffectTypeHidden, EffectTypeNone, EffectTypeProcess, EffectTypeTool, GetPluginTypeString(), KEY_DESCRIPTION, KEY_EFFECTAUTOMATABLE, KEY_EFFECTDEFAULT, KEY_EFFECTFAMILY, KEY_EFFECTINTERACTIVE, KEY_EFFECTREALTIME, KEY_EFFECTTYPE, KEY_EFFECTTYPE_ANALYZE, KEY_EFFECTTYPE_GENERATE, KEY_EFFECTTYPE_HIDDEN, KEY_EFFECTTYPE_NONE, KEY_EFFECTTYPE_PROCESS, KEY_EFFECTTYPE_TOOL, KEY_ENABLED, KEY_IMPORTEREXTENSIONS, KEY_IMPORTERIDENT, KEY_NAME, KEY_PATH, KEY_PROVIDERID, KEY_SYMBOL, KEY_VALID, KEY_VENDOR, KEY_VERSION, mRegisteredPlugins, PluginTypeEffect, PluginTypeImporter, PluginTypeModule, REGROOT, FileConfig::SetPath(), and wxT().

Referenced by Save().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ SetConfigValue() [1/2]

bool PluginManager::SetConfigValue ( ConfigurationType  type,
const PluginID ID,
const RegistryPath group,
const RegistryPath key,
ConfigConstReference  value 
)
overridevirtual

Implements PluginManagerInterface.

Definition at line 286 of file PluginManager.cpp.

289{
290 return SetConfigValue(Key(type, ID, group, key), value);
291}
bool SetConfigValue(ConfigurationType type, const PluginID &ID, const RegistryPath &group, const RegistryPath &key, ConfigConstReference value) override

References Key(), key, and SetConfigValue().

Referenced by SetConfigValue().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ SetConfigValue() [2/2]

bool PluginManager::SetConfigValue ( const RegistryPath key,
ConfigConstReference  value 
)
private

Definition at line 1448 of file PluginManager.cpp.

1450{
1451 using namespace Variant;
1452 if (key.empty())
1453 return false;
1454 const auto visitor = [&](const auto value){
1455 return GetSettings()->Write(key, value.get()) && GetSettings()->Flush();
1456 };
1457 return Visit(visitor, value);
1458}

References FileConfig::Flush(), GetSettings(), key, and Registry::Visit().

Here is the call graph for this function:

◆ SetDirty()

void PluginManager::SetDirty ( bool  dirty = true)
private

◆ SettingsPath()

RegistryPath PluginManager::SettingsPath ( ConfigurationType  type,
const PluginID ID 
)
private

Definition at line 1461 of file PluginManager.cpp.

1463{
1464 bool shared = (type == ConfigurationType::Shared);
1465
1466 // All the strings reported by PluginDescriptor and used in this function
1467 // persist in the plugin settings configuration file, so they should not
1468 // be changed across Audacity versions, or else compatibility of the
1469 // configuration files will break.
1470
1471 if (auto iter = mRegisteredPlugins.find(ID); iter == mRegisteredPlugins.end())
1472 return {};
1473 else {
1474 const PluginDescriptor & plug = iter->second;
1475
1476 wxString id = GetPluginTypeString(plug.GetPluginType()) +
1477 wxT("_") +
1478 plug.GetEffectFamily() + // is empty for non-Effects
1479 wxT("_") +
1480 plug.GetVendor() +
1481 wxT("_") +
1482 (shared ? wxString{} : plug.GetSymbol().Internal());
1483
1484 return SETROOT +
1485 ConvertID(id) +
1486 wxCONFIG_PATH_SEPARATOR +
1487 (shared ? wxT("shared") : wxT("private")) +
1488 wxCONFIG_PATH_SEPARATOR;
1489 }
1490}
#define SETROOT
const ComponentInterfaceSymbol & GetSymbol() const
PluginType GetPluginType() const
wxString GetEffectFamily() const
const wxString & GetVendor() const

References ConvertID(), PluginDescriptor::GetEffectFamily(), PluginDescriptor::GetPluginType(), GetPluginTypeString(), PluginDescriptor::GetSymbol(), PluginDescriptor::GetVendor(), ComponentInterfaceSymbol::Internal(), mRegisteredPlugins, SETROOT, PluginSettings::Shared, and wxT().

Referenced by Group().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ Terminate()

void PluginManager::Terminate ( )

Definition at line 410 of file PluginManager.cpp.

411{
412 // Get rid of all non-module(effects?) plugins first
413 for(auto& p : mRegisteredPlugins)
414 {
415 auto& desc = p.second;
416 if(desc.GetPluginType() == PluginTypeEffect)
417 mLoadedInterfaces.erase(desc.GetID());
418 }
419
420 // Now get rid of others
421 mRegisteredPlugins.clear();
422 mLoadedInterfaces.clear();
423}

References desc, mLoadedInterfaces, mRegisteredPlugins, and PluginTypeEffect.

Referenced by AudacityApp::OnExit(), and ~PluginManager().

Here is the caller graph for this function:

◆ UnregisterPlugin()

void PluginManager::UnregisterPlugin ( const PluginID ID)

Definition at line 1031 of file PluginManager.cpp.

1032{
1033 mRegisteredPlugins.erase(ID);
1034 mLoadedInterfaces.erase(ID);
1035}

References mLoadedInterfaces, and mRegisteredPlugins.

Referenced by PluginRegistrationDialog::OnOK(), and EffectManager::UnregisterEffect().

Here is the caller graph for this function:

Member Data Documentation

◆ mCurrentIndex

int PluginManager::mCurrentIndex
private

Definition at line 231 of file PluginManager.h.

◆ mDirty

bool PluginManager::mDirty
private

Definition at line 230 of file PluginManager.h.

◆ mEffectPluginsCleared

std::vector<PluginDescriptor> PluginManager::mEffectPluginsCleared
private

Definition at line 235 of file PluginManager.h.

Referenced by CheckPluginUpdates(), ClearEffectPlugins(), and GetPlugin().

◆ mInstance

std::unique_ptr< PluginManager > PluginManager::mInstance {}
staticprivate

Definition at line 224 of file PluginManager.h.

Referenced by Get().

◆ mLoadedInterfaces

std::map<PluginID, std::unique_ptr<ComponentInterface> > PluginManager::mLoadedInterfaces
private

Definition at line 234 of file PluginManager.h.

Referenced by IsPluginLoaded(), Load(), RegisterPlugin(), Terminate(), and UnregisterPlugin().

◆ mRegisteredPlugins

PluginMap PluginManager::mRegisteredPlugins
private

◆ mRegver

PluginRegistryVersion PluginManager::mRegver
private

Definition at line 237 of file PluginManager.h.

Referenced by GetRegistryVersion(), Load(), and Save().

◆ mSettings

std::unique_ptr<FileConfig> PluginManager::mSettings
private

Definition at line 228 of file PluginManager.h.

Referenced by GetSettings(), and PluginManager().


The documentation for this class was generated from the following files: