+
+bool
+PluginManager::is_a_favorite_plugin (const PluginInfoPtr& pi)
+{
+ FavoritePlugin fp (pi->type, pi->unique_id);
+ return find (favorites.begin(), favorites.end(), fp) != favorites.end();
+}
+
+void
+PluginManager::save_favorites ()
+{
+ ofstream ofs;
+ sys::path path = user_config_directory();
+ path /= "favorite_plugins";
+
+ ofs.open (path.to_string().c_str(), ios_base::openmode (ios::out|ios::trunc));
+
+ if (!ofs) {
+ return;
+ }
+
+ for (FavoritePluginList::iterator i = favorites.begin(); i != favorites.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 << ' ' << (*i).unique_id << endl;
+ }
+
+ ofs.close ();
+}
+
+void
+PluginManager::load_favorites ()
+{
+ sys::path path = user_config_directory();
+ path /= "favorite_plugins";
+ ifstream ifs (path.to_string().c_str());
+
+ if (!ifs) {
+ return;
+ }
+
+ std::string stype;
+ std::string id;
+ PluginType type;
+
+ while (ifs) {
+
+ ifs >> stype;
+ if (!ifs) {
+ break;
+
+ }
+ ifs >> id;
+ if (!ifs) {
+ 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 favorite plugin type \"%1\" - ignored"), stype)
+ << endmsg;
+ continue;
+ }
+
+ add_favorite (type, id);
+ }
+
+ ifs.close ();
+}
+
+void
+PluginManager::add_favorite (PluginType t, string id)
+{
+ FavoritePlugin fp (t, id);
+ pair<FavoritePluginList::iterator,bool> res = favorites.insert (fp);
+ //cerr << "Added " << t << " " << id << " success ? " << res.second << endl;
+}
+
+void
+PluginManager::remove_favorite (PluginType t, string id)
+{
+ FavoritePlugin fp (t, id);
+ favorites.erase (fp);
+}