diff options
-rw-r--r-- | libs/ardour/ardour/audio_library.h | 41 | ||||
-rw-r--r-- | libs/ardour/audio_library.cc | 283 | ||||
-rw-r--r-- | libs/ardour/ladspa_plugin.cc | 2 | ||||
-rw-r--r-- | libs/ardour/session_state.cc | 2 | ||||
-rw-r--r-- | libs/gtkmm2ext/tearoff.cc | 1 | ||||
-rw-r--r-- | libs/libglademm/INSTALL | 182 | ||||
-rw-r--r-- | libs/libglademm/README | 0 | ||||
-rw-r--r-- | libs/libglademm/TODO | 0 |
8 files changed, 126 insertions, 385 deletions
diff --git a/libs/ardour/ardour/audio_library.h b/libs/ardour/ardour/audio_library.h index 00c833a6c8..2f9e84551b 100644 --- a/libs/ardour/ardour/audio_library.h +++ b/libs/ardour/ardour/audio_library.h @@ -22,66 +22,61 @@ #ifndef __ardour_audio_library_h__ #define __ardour_audio_library_h__ -#include <list> #include <string> #include <map> +#include <vector> #include <sigc++/signal.h> -using std::list; +using std::vector; using std::string; using std::map; namespace ARDOUR { -class AudioLibrary +class AudioLibrary { public: AudioLibrary (); ~AudioLibrary (); - - // add_group returns the URI of the created group - string add_group (string group, string parent_uri = ""); - void remove_group (string uri); - void get_groups (list<string>& groups, string parent_uri = ""); - - // add_member returns the URI of the created group - string add_member (string member, string parent_uri = ""); + + void set_paths (vector<string> paths); + vector<string> get_paths (); + void scan_paths (); + + void add_member (string member); void remove_member (string uri); - void get_members (list<string>& members, string parent_uri = ""); - string get_member_filename (string uri); - void search_members_and (list<string>& results, + void search_members_and (vector<string>& results, const map<string,string>& fields); - void search_members_or (list<string>& results, + void search_members_or (vector<string>& results, const map<string,string>& fields); void add_field (string field); - void get_fields (list<string>& fields); + void get_fields (vector<string>& fields); void remove_field (string field); string get_field (string uri, string field); void set_field (string uri, string field, string literal); - string get_label (string uri); - void set_label (string uri, string label); + void set_label (string uri, string name); void save_changes(); - sigc::signal<void, string, string> added_group; // group, parent - sigc::signal<void, string, string> added_member;// member, parent - sigc::signal<void, string> removed_group; - sigc::signal<void, string> removed_member; sigc::signal<void> fields_changed; private: + vector<string> sfdb_paths; + string field_uri (string name); bool is_rdf_type (string uri, string type); void remove_uri (string uri); - string src; + string src; void initialize_db(); + void compact_vector (vector<string>& vec); + bool safe_file_extension (string); }; extern AudioLibrary* Library; diff --git a/libs/ardour/audio_library.cc b/libs/ardour/audio_library.cc index 03bde67459..37f558445b 100644 --- a/libs/ardour/audio_library.cc +++ b/libs/ardour/audio_library.cc @@ -20,10 +20,15 @@ */ #include <cstdio> // Needed so that libraptor (included in lrdf) won't complain +#include <cerrno> #include <iostream> #include <sstream> #include <cctype> +#include <sys/types.h> +#include <sys/stat.h> +#include <fts.h> + #include <lrdf.h> #include <pbd/compose.h> @@ -38,22 +43,12 @@ using namespace std; using namespace ARDOUR; -namespace std { -struct UriSorter { - bool operator() (string a, string b) const { - return cmp_nocase(Library->get_label(a), Library->get_label(b)) == -1; - } -}; -}; - -static char* GROUP = "http://ardour.org/ontology/Group"; static char* SOUNDFILE = "http://ardour.org/ontology/Soundfile"; -static char* hasFile = "http://ardour.org/ontology/hasFile"; -static char* memberOf = "http://ardour.org/ontology/memberOf"; -static char* subGroupOf = "http://ardour.org/ontology/subGroupOf"; AudioLibrary::AudioLibrary () { +// sfdb_paths.push_back("/Users/taybin/sounds"); + src = "file:" + Config->get_user_ardour_path() + "sfdb"; // workaround for possible bug in raptor that crashes when saving to a @@ -64,7 +59,7 @@ AudioLibrary::AudioLibrary () lrdf_statement pattern; - pattern.subject = GROUP; + pattern.subject = SOUNDFILE; pattern.predicate = RDF_TYPE; pattern.object = RDFS_CLASS; pattern.object_type = lrdf_uri; @@ -78,6 +73,8 @@ AudioLibrary::AudioLibrary () } lrdf_free_statements(matches); + + scan_paths(); } AudioLibrary::~AudioLibrary () @@ -87,8 +84,6 @@ AudioLibrary::~AudioLibrary () void AudioLibrary::initialize_db () { - // define ardour:Group - lrdf_add_triple(src.c_str(), GROUP, RDF_TYPE, RDFS_CLASS, lrdf_uri); // define ardour:Soundfile lrdf_add_triple(src.c_str(), SOUNDFILE, RDF_TYPE, RDFS_CLASS, lrdf_uri); @@ -107,148 +102,23 @@ AudioLibrary::save_changes () } } -string -AudioLibrary::add_group (string group, string parent_uri) -{ - string local_group(string_compose("file:sfbd/group/%1", get_uid())); - - lrdf_add_triple(src.c_str(), local_group.c_str(), - RDFS_BASE "label", group.c_str(), lrdf_literal); - - if (parent_uri == ""){ - lrdf_add_triple(src.c_str(), local_group.c_str(), - subGroupOf, GROUP, lrdf_uri); - } else { - lrdf_add_triple(src.c_str(), local_group.c_str(), - subGroupOf, parent_uri.c_str(), lrdf_uri); - } - - added_group(local_group, parent_uri); /* EMIT SIGNAL */ - - return local_group; -} - -void -AudioLibrary::remove_group (string uri) -{ - list<string> items; - list<string>::iterator i; - - get_members(items, uri); - for (i = items.begin(); i != items.end(); ++i) { - remove_member(*i); - } - - items.clear(); - - get_groups(items, uri); - for (i = items.begin(); i != items.end(); ++i) { - remove_group(*i); - } - - lrdf_remove_uri_matches(uri.c_str()); - - removed_group(uri); /* EMIT SIGNAL */ -} - void -AudioLibrary::get_groups (list<string>& groups, string parent_uri) -{ - lrdf_statement pattern; - - pattern.subject = 0; - pattern.predicate = subGroupOf; - if (parent_uri == ""){ - pattern.object = strdup(GROUP); - } else { - pattern.object = strdup(parent_uri.c_str()); - } - - lrdf_statement* matches = lrdf_matches(&pattern); - - lrdf_statement* current = matches; - while (current != 0) { - groups.push_back(current->subject); - current = current->next; - } - - lrdf_free_statements(matches); - free (pattern.object); - - UriSorter cmp; - groups.sort(cmp); - groups.unique(); -} - -string -AudioLibrary::add_member (string member, string parent_uri) +AudioLibrary::add_member (string member) { - string local_member(string_compose("file:sfdb/soundfile/%1", get_uid())); string file_uri(string_compose("file:%1", member)); - lrdf_add_triple(src.c_str(), local_member.c_str(), RDF_TYPE, + lrdf_add_triple(src.c_str(), file_uri.c_str(), RDF_TYPE, SOUNDFILE, lrdf_uri); - lrdf_add_triple(src.c_str(), local_member.c_str(), hasFile, - file_uri.c_str(), lrdf_uri); - - string::size_type size = member.find_last_of('/'); - string label = member.substr(++size); - - lrdf_add_triple(src.c_str(), local_member.c_str(), RDFS_BASE "label", - label.c_str(), lrdf_literal); - - if (parent_uri == ""){ - lrdf_add_triple(src.c_str(), local_member.c_str(), memberOf, - GROUP, lrdf_uri); - } else { - lrdf_add_triple(src.c_str(), local_member.c_str(), memberOf, - parent_uri.c_str(), lrdf_uri); - } - - added_member (local_member, parent_uri); /* EMIT SIGNAL */ - - return local_member; } void AudioLibrary::remove_member (string uri) { lrdf_remove_uri_matches (uri.c_str()); - - removed_member(uri); /* EMIT SIGNAL */ } void -AudioLibrary::get_members (list<string>& members, string parent_uri) -{ - lrdf_statement pattern; - - pattern.subject = 0; - pattern.predicate = memberOf; - if (parent_uri == ""){ - pattern.object = strdup(GROUP); - } else { - pattern.object = strdup(parent_uri.c_str()); - } - - lrdf_statement* matches = lrdf_matches(&pattern); - - lrdf_statement* current = matches; - while (current != 0) { - members.push_back(current->subject); - current = current->next; - } - - lrdf_free_statements(matches); - free (pattern.object); - - UriSorter cmp; - members.sort(cmp); - members.unique(); -} - -void -AudioLibrary::search_members_and (list<string>& members, +AudioLibrary::search_members_and (vector<string>& members, const map<string,string>& fields) { lrdf_statement **head; @@ -275,9 +145,7 @@ AudioLibrary::search_members_and (list<string>& members, } lrdf_free_uris(ulist); - UriSorter cmp; - members.sort(cmp); - members.unique(); + compact_vector(members); } // memory clean up @@ -292,7 +160,7 @@ AudioLibrary::search_members_and (list<string>& members, } void -AudioLibrary::search_members_or (list<string>& members, +AudioLibrary::search_members_or (vector<string>& members, const map<string,string>& fields) { map<string,string>::const_iterator i; @@ -318,31 +186,7 @@ AudioLibrary::search_members_or (list<string>& members, lrdf_free_statements (old); } - UriSorter cmp; - members.sort(cmp); - members.unique(); -} - -string -AudioLibrary::get_member_filename (string uri) -{ - lrdf_statement pattern; - pattern.subject = strdup(uri.c_str()); - pattern.predicate = hasFile; - pattern.object = 0; - pattern.object_type = lrdf_uri; - - lrdf_statement* matches = lrdf_matches(&pattern); - if (matches) { - string file = matches->object; - lrdf_free_statements(matches); - - string::size_type pos = file.find(":"); - return file.substr(++pos); - } else { - warning << _("Could not find member filename") << endmsg; - return "-Unknown-"; - } + compact_vector(members); } void @@ -371,11 +215,11 @@ AudioLibrary::add_field (string name) set_label (local_field, name); - fields_changed(); /* EMIT SIGNAL */ + fields_changed(); /* EMIT SIGNAL */ } void -AudioLibrary::get_fields (list<string>& fields) +AudioLibrary::get_fields (vector<string>& fields) { lrdf_statement pattern; @@ -395,15 +239,14 @@ AudioLibrary::get_fields (list<string>& fields) lrdf_free_statements(matches); - fields.sort(); - fields.unique(); + compact_vector(fields); } void AudioLibrary::remove_field (string name) { lrdf_remove_uri_matches(field_uri(name).c_str()); - fields_changed (); /* EMIT SIGNAL */ + fields_changed (); /* EMIT SIGNAL */ } string @@ -501,3 +344,89 @@ AudioLibrary::set_label (string uri, string label) label.c_str(), lrdf_literal); } +void +AudioLibrary::compact_vector(vector<string>& vec) +{ + sort(vec.begin(), vec.end()); + unique(vec.begin(), vec.end()); +} + +void +AudioLibrary::set_paths (vector<string> paths) +{ + sfdb_paths = paths; +} + +vector<string> +AudioLibrary::get_paths () +{ + return sfdb_paths; +} + +void +AudioLibrary::scan_paths () +{ + if (sfdb_paths.size() < 1) { + return; + } + + vector<char *> pathv(sfdb_paths.size()); + unsigned int i; + for (i = 0; i < sfdb_paths.size(); ++i) { + pathv[i] = new char[sfdb_paths[i].length() +1]; + sfdb_paths[i].copy(pathv[i], string::npos); + pathv[i][sfdb_paths[i].length()] = 0; + } + pathv[i] = 0; + + FTS* ft = fts_open(&pathv[0], FTS_LOGICAL|FTS_NOSTAT|FTS_PHYSICAL|FTS_XDEV, 0); + if (errno) { + error << strerror(errno) << endmsg; + return; + } + + lrdf_statement s; + s.predicate = RDF_TYPE; + s.object = SOUNDFILE; + s.object_type = lrdf_uri; + string filename; + while (FTSENT* file = fts_read(ft)) { + if ((file->fts_info & FTS_F) && (safe_file_extension(file->fts_name))) { + filename = "file:"; + filename.append(file->fts_accpath); + s.subject = strdup(filename.c_str()); + if (lrdf_exists_match(&s)) { + continue; + } else { + add_member(file->fts_accpath); + cout << file->fts_accpath << endl; + } + free(s.subject); + } + } + fts_close(ft); + + for (i = 0; i < pathv.size(); ++i) { + delete[] pathv[i]; + } + + save_changes(); +} + +bool +AudioLibrary::safe_file_extension(string file) +{ + return !(file.rfind(".wav") == string::npos && + file.rfind(".aiff")== string::npos && + file.rfind(".aif") == string::npos && + file.rfind(".snd") == string::npos && + file.rfind(".au") == string::npos && + file.rfind(".raw") == string::npos && + file.rfind(".sf") == string::npos && + file.rfind(".cdr") == string::npos && + file.rfind(".smp") == string::npos && + file.rfind(".maud")== string::npos && + file.rfind(".vwe") == string::npos && + file.rfind(".paf") == string::npos && + file.rfind(".voc") == string::npos); +} diff --git a/libs/ardour/ladspa_plugin.cc b/libs/ardour/ladspa_plugin.cc index 18a9dd3e95..2c72eb6b12 100644 --- a/libs/ardour/ladspa_plugin.cc +++ b/libs/ardour/ladspa_plugin.cc @@ -426,7 +426,7 @@ LadspaPlugin::set_state(const XMLNode& node) LocaleGuard lg (X_("POSIX")); if (node.name() != state_node_name()) { - error << _("Bad node send to LadspaPlugin::set_state") << endmsg; + error << _("Bad node sent to LadspaPlugin::set_state") << endmsg; return -1; } diff --git a/libs/ardour/session_state.cc b/libs/ardour/session_state.cc index 7bc325c912..98a48fb44a 100644 --- a/libs/ardour/session_state.cc +++ b/libs/ardour/session_state.cc @@ -1810,7 +1810,7 @@ Session::load_sources (const XMLNode& node) Source * Session::XMLSourceFactory (const XMLNode& node) { - Source *src; + Source *src = 0; if (node.name() != "Source") { return 0; diff --git a/libs/gtkmm2ext/tearoff.cc b/libs/gtkmm2ext/tearoff.cc index d74a98cb3d..07c24dc0d5 100644 --- a/libs/gtkmm2ext/tearoff.cc +++ b/libs/gtkmm2ext/tearoff.cc @@ -85,7 +85,6 @@ TearOff::tearoff_click (GdkEventButton* ev) own_window.set_name (get_name()); close_event_box.set_name (get_name()); own_window.show_all (); -// own_window.realize (); hide (); Detach (); return TRUE; diff --git a/libs/libglademm/INSTALL b/libs/libglademm/INSTALL deleted file mode 100644 index b42a17ac46..0000000000 --- a/libs/libglademm/INSTALL +++ /dev/null @@ -1,182 +0,0 @@ -Basic Installation -================== - - These are generic installation instructions. - - The `configure' shell script attempts to guess correct values for -various system-dependent variables used during compilation. It uses -those values to create a `Makefile' in each directory of the package. -It may also create one or more `.h' files containing system-dependent -definitions. Finally, it creates a shell script `config.status' that -you can run in the future to recreate the current configuration, a file -`config.cache' that saves the results of its tests to speed up -reconfiguring, and a file `config.log' containing compiler output -(useful mainly for debugging `configure'). - - If you need to do unusual things to compile the package, please try -to figure out how `configure' could check whether to do them, and mail -diffs or instructions to the address given in the `README' so they can -be considered for the next release. If at some point `config.cache' -contains results you don't want to keep, you may remove or edit it. - - The file `configure.in' is used to create `configure' by a program -called `autoconf'. You only need `configure.in' if you want to change -it or regenerate `configure' using a newer version of `autoconf'. - -The simplest way to compile this package is: - - 1. `cd' to the directory containing the package's source code and type - `./configure' to configure the package for your system. If you're - using `csh' on an old version of System V, you might need to type - `sh ./configure' instead to prevent `csh' from trying to execute - `configure' itself. - - Running `configure' takes awhile. While running, it prints some - messages telling which features it is checking for. - - 2. Type `make' to compile the package. - - 3. Optionally, type `make check' to run any self-tests that come with - the package. - - 4. Type `make install' to install the programs and any data files and - documentation. - - 5. You can remove the program binaries and object files from the - source code directory by typing `make clean'. To also remove the - files that `configure' created (so you can compile the package for - a different kind of computer), type `make distclean'. There is - also a `make maintainer-clean' target, but that is intended mainly - for the package's developers. If you use it, you may have to get - all sorts of other programs in order to regenerate files that came - with the distribution. - -Compilers and Options -===================== - - Some systems require unusual options for compilation or linking that -the `configure' script does not know about. You can give `configure' -initial values for variables by setting them in the environment. Using -a Bourne-compatible shell, you can do that on the command line like -this: - CC=c89 CFLAGS=-O2 LIBS=-lposix ./configure - -Or on systems that have the `env' program, you can do it like this: - env CPPFLAGS=-I/usr/local/include LDFLAGS=-s ./configure - -Compiling For Multiple Architectures -==================================== - - You can compile the package for more than one kind of computer at the -same time, by placing the object files for each architecture in their -own directory. To do this, you must use a version of `make' that -supports the `VPATH' variable, such as GNU `make'. `cd' to the -directory where you want the object files and executables to go and run -the `configure' script. `configure' automatically checks for the -source code in the directory that `configure' is in and in `..'. - - If you have to use a `make' that does not supports the `VPATH' -variable, you have to compile the package for one architecture at a time -in the source code directory. After you have installed the package for -one architecture, use `make distclean' before reconfiguring for another -architecture. - -Installation Names -================== - - By default, `make install' will install the package's files in -`/usr/local/bin', `/usr/local/man', etc. You can specify an -installation prefix other than `/usr/local' by giving `configure' the -option `--prefix=PATH'. - - You can specify separate installation prefixes for -architecture-specific files and architecture-independent files. If you -give `configure' the option `--exec-prefix=PATH', the package will use -PATH as the prefix for installing programs and libraries. -Documentation and other data files will still use the regular prefix. - - In addition, if you use an unusual directory layout you can give -options like `--bindir=PATH' to specify different values for particular -kinds of files. Run `configure --help' for a list of the directories -you can set and what kinds of files go in them. - - If the package supports it, you can cause programs to be installed -with an extra prefix or suffix on their names by giving `configure' the -option `--program-prefix=PREFIX' or `--program-suffix=SUFFIX'. - -Optional Features -================= - - Some packages pay attention to `--enable-FEATURE' options to -`configure', where FEATURE indicates an optional part of the package. -They may also pay attention to `--with-PACKAGE' options, where PACKAGE -is something like `gnu-as' or `x' (for the X Window System). The -`README' should mention any `--enable-' and `--with-' options that the -package recognizes. - - For packages that use the X Window System, `configure' can usually -find the X include and library files automatically, but if it doesn't, -you can use the `configure' options `--x-includes=DIR' and -`--x-libraries=DIR' to specify their locations. - -Specifying the System Type -========================== - - There may be some features `configure' can not figure out -automatically, but needs to determine by the type of host the package -will run on. Usually `configure' can figure that out, but if it prints -a message saying it can not guess the host type, give it the -`--host=TYPE' option. TYPE can either be a short name for the system -type, such as `sun4', or a canonical name with three fields: - CPU-COMPANY-SYSTEM - -See the file `config.sub' for the possible values of each field. If -`config.sub' isn't included in this package, then this package doesn't -need to know the host type. - - If you are building compiler tools for cross-compiling, you can also -use the `--target=TYPE' option to select the type of system they will -produce code for and the `--build=TYPE' option to select the type of -system on which you are compiling the package. - -Sharing Defaults -================ - - If you want to set default values for `configure' scripts to share, -you can create a site shell script called `config.site' that gives -default values for variables like `CC', `cache_file', and `prefix'. -`configure' looks for `PREFIX/share/config.site' if it exists, then -`PREFIX/etc/config.site' if it exists. Or, you can set the -`CONFIG_SITE' environment variable to the location of the site script. -A warning: not all `configure' scripts look for a site script. - -Operation Controls -================== - - `configure' recognizes the following options to control how it -operates. - -`--cache-file=FILE' - Use and save the results of the tests in FILE instead of - `./config.cache'. Set FILE to `/dev/null' to disable caching, for - debugging `configure'. - -`--help' - Print a summary of the options to `configure', and exit. - -`--quiet' -`--silent' -`-q' - Do not print messages saying which checks are being made. To - suppress all normal output, redirect it to `/dev/null' (any error - messages will still be shown). - -`--srcdir=DIR' - Look for the package's source code in directory DIR. Usually - `configure' can determine that directory automatically. - -`--version' - Print the version of Autoconf used to generate the `configure' - script, and exit. - -`configure' also accepts some other, not widely useful, options. diff --git a/libs/libglademm/README b/libs/libglademm/README deleted file mode 100644 index e69de29bb2..0000000000 --- a/libs/libglademm/README +++ /dev/null diff --git a/libs/libglademm/TODO b/libs/libglademm/TODO deleted file mode 100644 index e69de29bb2..0000000000 --- a/libs/libglademm/TODO +++ /dev/null |