1 //=========================================================
2 //  MusE
3 //  Linux Music Editor
4 //
5 //  plugin_cache_reader.h
6 //  (C) Copyright 2018 Tim E. Real (terminator356 on users dot sourceforge dot net)
7 //
8 //  This program is free software; you can redistribute it and/or
9 //  modify it under the terms of the GNU General Public License
10 //  as published by the Free Software Foundation; version 2 of
11 //  the License, or (at your option) any later version.
12 //
13 //  This program is distributed in the hope that it will be useful,
14 //  but WITHOUT ANY WARRANTY; without even the implied warranty of
15 //  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16 //  GNU General Public License for more details.
17 //
18 //  You should have received a copy of the GNU General Public License
19 //  along with this program; if not, write to the Free Software
20 //  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
21 //
22 //=========================================================
23 
24 #ifndef __PLUGIN_CACHE_READER_H__
25 #define __PLUGIN_CACHE_READER_H__
26 
27 #include <QString>
28 #include <QStringList>
29 
30 #include "config.h"
31 #include "plugin_scan.h"
32 #include "plugin_list.h"
33 
34 namespace MusECore {
35 class Xml;
36 }
37 
38 namespace MusEPlugin {
39 
40 //-----------------------------------------
41 // Public plugin cache functions
42 //-----------------------------------------
43 
44 void setPluginScanFileInfo(const QString& filename, PluginScanInfoStruct* info);
45 
46 // TODO Depending on our needs later, make some of these private static in the cpp file.
47 
48 // The museGlobalLib is where to find the application's installed libraries.
49 QStringList pluginGetLadspaDirectories(const QString& museGlobalLib);
50 QStringList pluginGetMessDirectories(const QString& museGlobalLib);
51 QStringList pluginGetDssiDirectories();
52 QStringList pluginGetLinuxVstDirectories();
53 QStringList pluginGetLv2Directories();
54 QStringList pluginGetVstDirectories();
55 QStringList pluginGetDirectories(const QString& museGlobalLib,
56                                  PluginScanInfoStruct::PluginType type = PluginScanInfoStruct::PluginTypeNone);
57 
58 // Returns the name of a cache file, without path.
59 const char* pluginCacheFilename(
60   // The type of plugin cache to check.
61   PluginScanInfoStruct::PluginType type = PluginScanInfoStruct::PluginTypeNone
62 );
63 
64 // Returns the given type parameter if the cache file for the given type exists.
65 PluginScanInfoStruct::PluginType pluginCacheFileExists(
66   // Path to the cache file directory (eg. config path + /scanner).
67   const QString& path,
68   // The type of plugin cache to check.
69   PluginScanInfoStruct::PluginType type = PluginScanInfoStruct::PluginTypeNone
70 );
71 
72 // Returns plugin type true if the cache file(s) for the given type(s) exist.
73 PluginScanInfoStruct::PluginType_t pluginCacheFilesExist(
74   // Path to the cache file directory (eg. config path + /scanner).
75   const QString& path,
76   // The types of plugin caches to check.
77   PluginScanInfoStruct::PluginType_t types = PluginScanInfoStruct::PluginTypeAll
78 );
79 
80 // Return true on error
81 bool readPluginScanInfoPortEnum(MusECore::Xml& xml, PluginPortInfo* port_info);
82 // Return true on error
83 bool readPluginScanInfoPort(MusECore::Xml& xml, PluginScanInfoStruct* info);
84 // Return true on error
85 bool readPluginScanInfo(MusECore::Xml& xml, PluginScanInfoStruct* info, bool readPorts = false, bool readEnums = false);
86 // Return true on error
87 bool readPluginScan(MusECore::Xml& xml, PluginScanList* list, bool readPorts = false, bool readEnums = false);
88 
89 // Read the plugin cache text file to a plugin list.
90 bool readPluginCacheFile(
91   // Path to the cache file directory (eg. config path + /scanner).
92   const QString& path,
93   // List to read into.
94   PluginScanList* list,
95   // Whether to read port information.
96   bool readPorts = false,
97   // Whether to read port value enumeration information.
98   bool readEnums = false,
99   // The type of plugin cache file to read.
100   PluginScanInfoStruct::PluginType type = PluginScanInfoStruct::PluginTypeNone
101 );
102 
103 // Read all plugin cache text files to a plugin list.
104 bool readPluginCacheFiles(
105   // Path to the cache file directory (eg. config path + /scanner).
106   const QString& path,
107   // List to read into.
108   PluginScanList* list,
109   // Whether to read port information.
110   bool readPorts = false,
111   // Whether to read port value enumeration information.
112   bool readEnums = false,
113   // The types of plugin cache files to read.
114   PluginScanInfoStruct::PluginType_t types = PluginScanInfoStruct::PluginTypeAll);
115 
116 
117 } // namespace MusEPlugin
118 
119 #endif
120 
121 
122 
123