comparison plugin/LADSPAPluginFactory.cpp @ 165:5ae5885d6ce3

* Add support for plugin classification using category files. Add separate menus listing plugins by category, maker, and plugin name.
author Chris Cannam
date Thu, 21 Sep 2006 16:43:50 +0000
parents 4b2ea82fd0ed
children 702fc936e6a6
comparison
equal deleted inserted replaced
164:da3701a3953e 165:5ae5885d6ce3
78 list.push_back(descriptor->Label); 78 list.push_back(descriptor->Label);
79 list.push_back(descriptor->Maker); 79 list.push_back(descriptor->Maker);
80 list.push_back(descriptor->Copyright); 80 list.push_back(descriptor->Copyright);
81 list.push_back("false"); // is synth 81 list.push_back("false"); // is synth
82 list.push_back("false"); // is grouped 82 list.push_back("false"); // is grouped
83 83
84 if (m_taxonomy.find(descriptor->UniqueID) != m_taxonomy.end() && 84 if (m_taxonomy.find(*i) != m_taxonomy.end() && m_taxonomy[*i] != "") {
85 m_taxonomy[descriptor->UniqueID] != "") {
86 // std::cerr << "LADSPAPluginFactory: cat for " << i->toStdString()<< " found in taxonomy as " << m_taxonomy[descriptor->UniqueID] << std::endl; 85 // std::cerr << "LADSPAPluginFactory: cat for " << i->toStdString()<< " found in taxonomy as " << m_taxonomy[descriptor->UniqueID] << std::endl;
87 list.push_back(m_taxonomy[descriptor->UniqueID]); 86 list.push_back(m_taxonomy[*i]);
88
89 } else if (m_fallbackCategories.find(*i) !=
90 m_fallbackCategories.end()) {
91 list.push_back(m_fallbackCategories[*i]);
92 // std::cerr << "LADSPAPluginFactory: cat for " << i->toStdString() <<" found in fallbacks as " << m_fallbackCategories[*i] << std::endl;
93 87
94 } else { 88 } else {
95 list.push_back(""); 89 list.push_back("");
96 // std::cerr << "LADSPAPluginFactory: cat for " << i->toStdString() << " not found (despite having " << m_fallbackCategories.size() << " fallbacks)" << std::endl; 90 // std::cerr << "LADSPAPluginFactory: cat for " << i->toStdString() << " not found (despite having " << m_fallbackCategories.size() << " fallbacks)" << std::endl;
97 91
653 rtd->isSynth = false; 647 rtd->isSynth = false;
654 rtd->parameterCount = 0; 648 rtd->parameterCount = 0;
655 rtd->audioInputPortCount = 0; 649 rtd->audioInputPortCount = 0;
656 rtd->controlOutputPortCount = 0; 650 rtd->controlOutputPortCount = 0;
657 651
652 QString identifier = PluginIdentifier::createIdentifier
653 ("ladspa", soname, descriptor->Label);
654
658 #ifdef HAVE_LRDF 655 #ifdef HAVE_LRDF
659 char *def_uri = 0; 656 char *def_uri = 0;
660 lrdf_defaults *defs = 0; 657 lrdf_defaults *defs = 0;
661 658
662 QString category = m_taxonomy[descriptor->UniqueID]; 659 if (m_lrdfTaxonomy[descriptor->UniqueID] != "") {
660 m_taxonomy[identifier] = m_lrdfTaxonomy[descriptor->UniqueID];
661 // std::cerr << "set id \"" << identifier.toStdString() << "\" to cat \"" << m_taxonomy[identifier].toStdString() << "\" from LRDF" << std::endl;
662 }
663
664 QString category = m_taxonomy[identifier];
663 665
664 if (category == "" && descriptor->Name != 0) { 666 if (category == "" && descriptor->Name != 0) {
665 std::string name = descriptor->Name; 667 std::string name = descriptor->Name;
666 if (name.length() > 4 && 668 if (name.length() > 4 &&
667 name.substr(name.length() - 4) == " VST") { 669 name.substr(name.length() - 4) == " VST") {
668 category = "VST effects"; 670 category = "VST effects";
669 m_taxonomy[descriptor->UniqueID] = category; 671 m_taxonomy[identifier] = category;
670 } 672 }
671 } 673 }
672 674
673 rtd->category = category.toStdString(); 675 rtd->category = category.toStdString();
674 676
722 ++rtd->audioInputPortCount; 724 ++rtd->audioInputPortCount;
723 } 725 }
724 } 726 }
725 } 727 }
726 728
727 QString identifier = PluginIdentifier::createIdentifier
728 ("ladspa", soname, descriptor->Label);
729 m_identifiers.push_back(identifier); 729 m_identifiers.push_back(identifier);
730 730
731 m_rtDescriptors[identifier] = rtd; 731 m_rtDescriptors[identifier] = rtd;
732 732
733 ++index; 733 ++index;
746 std::vector<QString> path; 746 std::vector<QString> path;
747 747
748 for (size_t i = 0; i < pluginPath.size(); ++i) { 748 for (size_t i = 0; i < pluginPath.size(); ++i) {
749 if (pluginPath[i].contains("/lib/")) { 749 if (pluginPath[i].contains("/lib/")) {
750 QString p(pluginPath[i]); 750 QString p(pluginPath[i]);
751 path.push_back(p);
751 p.replace("/lib/", "/share/"); 752 p.replace("/lib/", "/share/");
752 path.push_back(p); 753 path.push_back(p);
753 // std::cerr << "LADSPAPluginFactory::generateFallbackCategories: path element " << p << std::endl; 754 // std::cerr << "LADSPAPluginFactory::generateFallbackCategories: path element " << p.toStdString() << std::endl;
754 } 755 }
755 path.push_back(pluginPath[i]); 756 path.push_back(pluginPath[i]);
756 // std::cerr << "LADSPAPluginFactory::generateFallbackCategories: path element " << pluginPath[i] << std::endl; 757 // std::cerr << "LADSPAPluginFactory::generateFallbackCategories: path element " << pluginPath[i].toStdString() << std::endl;
757 } 758 }
758 759
759 for (size_t i = 0; i < path.size(); ++i) { 760 for (size_t i = 0; i < path.size(); ++i) {
760 761
761 QDir dir(path[i], "*.cat"); 762 QDir dir(path[i], "*.cat");
762 763
763 // std::cerr << "LADSPAPluginFactory::generateFallbackCategories: directory " << path[i] << " has " << dir.count() << " .cat files" << std::endl; 764 // std::cerr << "LADSPAPluginFactory::generateFallbackCategories: directory " << path[i].toStdString() << " has " << dir.count() << " .cat files" << std::endl;
764 for (unsigned int j = 0; j < dir.count(); ++j) { 765 for (unsigned int j = 0; j < dir.count(); ++j) {
765 766
766 QFile file(path[i] + "/" + dir[j]); 767 QFile file(path[i] + "/" + dir[j]);
767 768
768 // std::cerr << "LADSPAPluginFactory::generateFallbackCategories: about to open " << (path[i] + "/" + dir[j]) << std::endl; 769 // std::cerr << "LADSPAPluginFactory::generateFallbackCategories: about to open " << (path[i].toStdString() + "/" + dir[j].toStdString()) << std::endl;
769 770
770 if (file.open(QIODevice::ReadOnly)) { 771 if (file.open(QIODevice::ReadOnly)) {
771 // std::cerr << "...opened" << std::endl; 772 // std::cerr << "...opened" << std::endl;
772 QTextStream stream(&file); 773 QTextStream stream(&file);
773 QString line; 774 QString line;
774 775
775 while (!stream.atEnd()) { 776 while (!stream.atEnd()) {
776 line = stream.readLine(); 777 line = stream.readLine();
777 // std::cerr << "line is: \"" << line << "\"" << std::endl; 778 // std::cerr << "line is: \"" << line.toStdString() << "\"" << std::endl;
778 QString id = line.section("::", 0, 0); 779 QString id = PluginIdentifier::canonicalise
780 (line.section("::", 0, 0));
779 QString cat = line.section("::", 1, 1); 781 QString cat = line.section("::", 1, 1);
780 m_fallbackCategories[id] = cat; 782 m_taxonomy[id] = cat;
781 // std::cerr << "set id \"" << id << "\" to cat \"" << cat << "\"" << std::endl; 783 // std::cerr << "set id \"" << id.toStdString() << "\" to cat \"" << cat.toStdString() << "\"" << std::endl;
782 } 784 }
783 } 785 }
784 } 786 }
785 } 787 }
786 } 788 }
791 #ifdef HAVE_LRDF 793 #ifdef HAVE_LRDF
792 lrdf_uris *uris = lrdf_get_instances(uri.toStdString().c_str()); 794 lrdf_uris *uris = lrdf_get_instances(uri.toStdString().c_str());
793 795
794 if (uris != NULL) { 796 if (uris != NULL) {
795 for (int i = 0; i < uris->count; ++i) { 797 for (int i = 0; i < uris->count; ++i) {
796 m_taxonomy[lrdf_get_uid(uris->items[i])] = base; 798 m_lrdfTaxonomy[lrdf_get_uid(uris->items[i])] = base;
797 } 799 }
798 lrdf_free_uris(uris); 800 lrdf_free_uris(uris);
799 } 801 }
800 802
801 uris = lrdf_get_subclasses(uri.toStdString().c_str()); 803 uris = lrdf_get_subclasses(uri.toStdString().c_str());
809 lrdf_free_uris(uris); 811 lrdf_free_uris(uris);
810 } 812 }
811 #endif 813 #endif
812 } 814 }
813 815
814 816 QString
817 LADSPAPluginFactory::getPluginCategory(QString identifier)
818 {
819 return m_taxonomy[identifier];
820 }
821