36 if (! types.isEmpty())
60 if (d.pluginFormatName == format.getName())
70 for (
auto& desc : types)
71 if (desc.fileOrIdentifier == fileOrIdentifier)
72 return std::make_unique<PluginDescription> (desc);
81 for (
auto& desc : types)
83 return std::make_unique<PluginDescription> (desc);
93 for (
auto& desc : types)
95 if (desc.isDuplicateOf (type))
106 types.insert (0, type);
118 for (
int i = types.size(); --i >= 0;)
119 if (types.getUnchecked (i).isDuplicateOf (type))
134 for (
auto& d : types)
135 if (d.fileOrIdentifier == fileOrIdentifier &&
formatToUse.pluginNeedsRescanning (d))
161 for (
auto& d : types)
163 if (d.fileOrIdentifier == fileOrIdentifier && d.pluginFormatName == format.getName())
165 if (format.pluginNeedsRescanning (d))
176 if (blacklist.
contains (fileOrIdentifier))
184 if (scanner !=
nullptr)
186 if (! scanner->findPluginTypesFor (format, found, fileOrIdentifier))
191 format.findAllTypesForFile (found, fileOrIdentifier);
195 for (
auto* desc : found)
218 for (
auto format : formatManager.
getFormats())
220 if (format->fileMightContainThisPluginType (
filenameOrID)
249 if (scanner !=
nullptr)
250 scanner->scanFinished();
280 if (blacklist.
size() > 0)
291 : method (
sortMethod), direction (forwards ? 1 : -1) {}
304 case KnownPluginList::sortAlphabetically:
305 case KnownPluginList::defaultOrder:
312 return diff * direction < 0;
321 static int compare (
Time a,
Time b)
noexcept
323 if (a < b)
return -1;
335 if (method != defaultOrder)
349 for (
int i = 0; i <
oldOrder.size(); ++i)
364 auto e = std::make_unique<XmlElement> (
"KNOWNPLUGINS");
369 for (
int i = types.size(); --i >= 0;)
370 e->prependChildElement (types.getUnchecked (i).createXml().release());
373 for (
auto& b : blacklist)
374 e->createNewChildElement (
"BLACKLISTED")->setAttribute (
"id", b);
390 if (e->hasTagName (
"BLACKLISTED"))
391 blacklist.
add (e->getStringAttribute (
"id"));
401 enum { menuIdBase = 0x324503f4 };
407 auto path =
pd.fileOrIdentifier.replaceCharacter (
'\\',
'/')
408 .upToLastOccurrenceOf (
"/",
false,
false);
410 if (path.substring (1, 2) ==
":")
411 path = path.substring (2);
413 addPlugin (tree,
pd, path);
416 optimiseFolders (tree,
false);
421 for (
int i = tree.subFolders.size(); --i >= 0;)
423 auto& sub = *tree.subFolders.getUnchecked (i);
424 optimiseFolders (sub,
concatenateName || (tree.subFolders.size() > 1));
426 if (sub.plugins.isEmpty())
428 for (
auto* s : sub.subFolders)
431 s->folder = sub.folder +
"/" + s->folder;
433 tree.subFolders.add (s);
436 sub.subFolders.clear (
false);
437 tree.subFolders.remove (i);
447 auto current = std::make_unique<KnownPluginList::PluginTree>();
452 :
pd.manufacturerName);
454 if (!
thisType.containsNonWhitespaceChars())
459 if (current->plugins.size() + current->subFolders.size() > 0)
462 tree.subFolders.add (std::move (current));
463 current = std::make_unique<KnownPluginList::PluginTree>();
469 current->plugins.add (
pd);
472 if (current->plugins.size() + current->subFolders.size() > 0)
475 tree.subFolders.add (std::move (current));
488 tree.plugins.add (
pd);
495 for (
int i = tree.subFolders.size(); --i >= 0;)
497 auto&
subFolder = *tree.subFolders.getUnchecked (i);
517 for (
auto& p : plugins)
518 if (p.name == name && ++matches > 1)
528 bool isTicked =
false;
530 for (
auto* sub : tree.subFolders)
545 if (p.isDuplicateOf (d))
546 return i + menuIdBase;
554 for (
auto&
plugin : tree.plugins)
558 if (containsDuplicateNames (tree.plugins, name))
559 name <<
" (" <<
plugin.pluginFormatName <<
')';
578 auto tree = std::make_unique<PluginTree>();
584 else if (
sortMethod == sortByFileSystemLocation)
586 PluginTreeUtils::buildTreeByFolder (*tree,
sorted);
591 tree->plugins.add (p);
612KnownPluginList::CustomScanner::CustomScanner() {}
613KnownPluginList::CustomScanner::~CustomScanner() {}
620 return job->shouldExit();
Holds a resizable array of primitive or copy-by-value objects.
void addArray(const Type *elementsToAdd, int numElementsToAdd)
Adds elements from an array to the end of this array.
int size() const noexcept
Returns the current number of elements in the array.
void add(const ElementType &newElement)
Appends a new element at the end of the array.
void sendChangeMessage()
Causes an asynchronous change message to be sent to all the registered listeners.
Represents a local file or directory.
bool isDirectory() const
Checks whether the file is a directory that exists.
Array< File > findChildFiles(int whatToLookFor, bool searchRecursively, const String &wildCardPattern="*", FollowSymlinks followSymlinks=FollowSymlinks::yes) const
Searches this directory for files matching a wildcard pattern.
@ findFilesAndDirectories
Use this flag to indicate that you want to find both files and directories.
Automatically locks and unlocks a mutex object.
Automatically unlocks and re-locks a mutex object.
bool shouldExit() const noexcept
Returns true if the current scan should be abandoned.
virtual void scanFinished()
Called when a scan has finished, to allow clean-up of resources.
bool isListingUpToDate(const String &possiblePluginFileOrIdentifier, AudioPluginFormat &formatToUse) const
Returns true if the specified file is already known about and if it hasn't been modified since our en...
void clearBlacklistedFiles()
Clears all the blacklisted files.
std::unique_ptr< PluginDescription > getTypeForIdentifierString(const String &identifierString) const
Looks for a type in the list which matches a plugin type ID.
void recreateFromXml(const XmlElement &xml)
Recreates the state of this list from its stored XML format.
SortMethod
Sort methods used to change the order of the plugins in the list.
void sort(SortMethod method, bool forwards)
Sorts the list.
void clear()
Clears the list.
int getNumTypes() const noexcept
Returns the number of types currently in the list.
bool scanAndAddFile(const String &possiblePluginFileOrIdentifier, bool dontRescanIfAlreadyInList, OwnedArray< PluginDescription > &typesFound, AudioPluginFormat &formatToUse)
Looks for all types that can be loaded from a given file, and adds them to the list.
std::unique_ptr< PluginDescription > getTypeForFile(const String &fileOrIdentifier) const
Looks for a type in the list which comes from this file.
std::unique_ptr< XmlElement > createXml() const
Creates some XML that can be used to store the state of this list.
void removeType(const PluginDescription &type)
Removes a type.
const StringArray & getBlacklistedFiles() const
Returns the list of blacklisted files.
void removeFromBlacklist(const String &pluginID)
Removes a plugin ID from the black-list.
void scanAndAddDragAndDroppedFiles(AudioPluginFormatManager &formatManager, const StringArray &filenames, OwnedArray< PluginDescription > &typesFound)
Scans and adds a bunch of files that might have been dragged-and-dropped.
Array< PluginDescription > getTypesForFormat(AudioPluginFormat &) const
Returns the subset of plugin types for a given format.
void scanFinished()
Tells a custom scanner that a scan has finished, and it can release any resources.
static int getIndexChosenByMenu(const Array< PluginDescription > &types, int menuResultCode)
Converts a menu item index that has been chosen into its index in the list.
static void addToMenu(PopupMenu &menu, const Array< PluginDescription > &types, SortMethod sortMethod, const String ¤tlyTickedPluginID={})
Adds the plug-in types to a popup menu so that the user can select one.
void addToBlacklist(const String &pluginID)
Adds a plugin ID to the black-list.
KnownPluginList()
Creates an empty list.
static std::unique_ptr< PluginTree > createTree(const Array< PluginDescription > &types, SortMethod sortMethod)
Creates a PluginTree object representing the list of plug-ins.
bool addType(const PluginDescription &type)
Adds a type manually from its description.
Array< PluginDescription > getTypes() const
Returns a copy of the current list.
void setCustomScanner(std::unique_ptr< CustomScanner > newScanner)
Supplies a custom scanner to be used in future scans.
~KnownPluginList() override
Destructor.
A structure that recursively holds a tree of plugins.
An array designed for holding objects.
bool isEmpty() const noexcept
Returns true if the array is empty, false otherwise.
A small class to represent some facts about a particular type of plug-in.
String pluginFormatName
The plug-in format, e.g.
bool loadFromXml(const XmlElement &xml)
Reloads the info in this structure from an XML record that was previously saved with createXML().
bool isInstrument
True if the plug-in identifies itself as a synthesiser.
String category
A category, such as "Dynamics", "Reverbs", etc.
String name
The name of the plug-in.
String manufacturerName
The manufacturer.
String fileOrIdentifier
Either the file containing the plug-in module, or some other unique way of identifying it.
Time lastInfoUpdateTime
The last time that this information was updated.
A special array for holding a list of strings.
int indexOf(StringRef stringToLookFor, bool ignoreCase=false, int startIndex=0) const
Searches for a string in the array.
bool contains(StringRef stringToLookFor, bool ignoreCase=false) const
Searches for a string in the array.
void clear()
Removes all elements from the array.
int size() const noexcept
Returns the number of strings in the array.
void add(String stringToAdd)
Appends a string at the end of the array.
void remove(int index)
Removes a string from the array.
String upToFirstOccurrenceOf(StringRef substringToEndWith, bool includeSubStringInResult, bool ignoreCase) const
Returns the start of this string, up to the first occurrence of a substring.
int compareNatural(StringRef other, bool isCaseSensitive=false) const noexcept
Compares two strings, taking into account textual characteristics like numbers and spaces.
bool isEmpty() const noexcept
Returns true if the string contains no characters.
bool containsChar(juce_wchar character) const noexcept
Tests whether the string contains a particular character.
String upToLastOccurrenceOf(StringRef substringToFind, bool includeSubStringInResult, bool ignoreCase) const
Returns the start of this string, up to the last occurrence of a substring.
String replaceCharacter(juce_wchar characterToReplace, juce_wchar characterToInsertInstead) const
Returns a string with all occurrences of a character replaced with a different one.
int compare(const String &other) const noexcept
Case-sensitive comparison with another string.
String fromFirstOccurrenceOf(StringRef substringToStartFrom, bool includeSubStringInResult, bool ignoreCase) const
Returns a section of the string starting from a given substring.
static ThreadPoolJob * getCurrentThreadPoolJob()
If the calling thread is being invoked inside a runJob() method, this will return the ThreadPoolJob t...
Holds an absolute date and time.
Used to build a tree of elements representing an XML document.
bool hasTagName(StringRef possibleTagName) const noexcept
Tests whether this element has a particular tag name.
Iterator< GetNextElement > getChildIterator() const
Allows iterating the children of an XmlElement using range-for syntax.
Type unalignedPointerCast(void *ptr) noexcept
Casts a pointer to another type via void*, which suppresses the cast-align warning which sometimes ar...
bool isPositiveAndBelow(Type1 valueToTest, Type2 upperLimit) noexcept
Returns true if a value is at least zero, and also below a specified upper limit.