+
+PluginManager::PluginStatusType
+PluginManager::get_status (const PluginInfoPtr& pi)
+{
+ PluginStatus ps (pi->type, pi->unique_id);
+ PluginStatusList::const_iterator i = find (statuses.begin(), statuses.end(), ps);
+ if (i == statuses.end() ) {
+ return Normal;
+ } else {
+ return i->status;
+ }
+}
+
+void
+PluginManager::save_statuses ()
+{
+ ofstream ofs;
+ sys::path path = user_config_directory();
+ path /= "plugin_statuses";
+
+ ofs.open (path.to_string().c_str(), ios_base::openmode (ios::out|ios::trunc));
+
+ if (!ofs) {
+ return;
+ }
+
+ for (PluginStatusList::iterator i = statuses.begin(); i != statuses.end(); ++i) {
+ switch ((*i).type) {
+ case LADSPA:
+ ofs << "LADSPA";
+ break;
+ case AudioUnit:
+ ofs << "AudioUnit";
+ break;
+ case LV2:
+ ofs << "LV2";
+ break;
+ case VST:
+ ofs << "VST";
+ break;
+ }
+
+ ofs << ' ';
+
+ switch ((*i).status) {
+ case Normal:
+ ofs << "Normal";
+ break;
+ case Favorite:
+ ofs << "Favorite";
+ break;
+ case Hidden:
+ ofs << "Hidden";
+ break;
+ }
+
+ ofs << ' ';
+ ofs << (*i).unique_id;;
+ ofs << endl;
+ }
+
+ ofs.close ();
+}
+
+void
+PluginManager::load_statuses ()
+{
+ sys::path path = user_config_directory();
+ path /= "plugin_statuses";
+ ifstream ifs (path.to_string().c_str());
+
+ if (!ifs) {
+ return;
+ }
+
+ std::string stype;
+ std::string sstatus;
+ std::string id;
+ PluginType type;
+ PluginStatusType status;
+ char buf[1024];
+
+ while (ifs) {
+
+ ifs >> stype;
+ if (!ifs) {
+ break;
+
+ }
+
+ ifs >> sstatus;
+ if (!ifs) {
+ break;
+
+ }
+
+ /* rest of the line is the plugin ID */
+
+ ifs.getline (buf, sizeof (buf), '\n');
+ if (!ifs) {
+ break;
+ }
+
+ if (sstatus == "Normal") {
+ status = Normal;
+ } else if (sstatus == "Favorite") {
+ status = Favorite;
+ } else if (sstatus == "Hidden") {
+ status = Hidden;
+ } else {
+ error << string_compose (_("unknown plugin status type \"%1\" - all entries ignored"), sstatus)
+ << endmsg;
+ statuses.clear ();
+ break;
+ }
+
+ if (stype == "LADSPA") {
+ type = LADSPA;
+ } else if (stype == "AudioUnit") {
+ type = AudioUnit;
+ } else if (stype == "LV2") {
+ type = LV2;
+ } else if (stype == "VST") {
+ type = VST;
+ } else {
+ error << string_compose (_("unknown plugin type \"%1\" - ignored"), stype)
+ << endmsg;
+ continue;
+ }
+
+ id = buf;
+ strip_whitespace_edges (id);
+ set_status (type, id, status);
+ }
+
+ ifs.close ();
+}
+
+void
+PluginManager::set_status (PluginType t, string id, PluginStatusType status)
+{
+ PluginStatus ps (t, id, status);
+ statuses.erase (ps);
+
+ if (status == Normal) {
+ return;
+ }
+
+ pair<PluginStatusList::iterator, bool> res = statuses.insert (ps);
+ //cerr << "Added " << t << " " << id << " " << status << " success ? " << res.second << endl;
+}
+
+ARDOUR::PluginInfoList&
+PluginManager::vst_plugin_info ()
+{
+#ifdef VST_SUPPORT
+ if (!_vst_plugin_info)
+ vst_refresh();
+ return *_vst_plugin_info;
+#else
+ return _empty_plugin_info;
+#endif
+}
+
+ARDOUR::PluginInfoList&
+PluginManager::ladspa_plugin_info ()
+{
+ if (!_ladspa_plugin_info)
+ ladspa_refresh();
+ return *_ladspa_plugin_info;
+}
+
+ARDOUR::PluginInfoList&
+PluginManager::lv2_plugin_info ()
+{
+#ifdef HAVE_SLV2
+ if (!_lv2_plugin_info)
+ lv2_refresh();
+ return *_lv2_plugin_info;
+#else
+ return _empty_plugin_info;
+#endif
+}
+
+ARDOUR::PluginInfoList&
+PluginManager::au_plugin_info ()
+{
+#ifdef HAVE_AUDIOUNITS
+ if (!_au_plugin_info)
+ au_refresh();
+ return *_au_plugin_info;
+#else
+ return _empty_plugin_info;
+#endif
+}