From 29e4fbbb630d8c3722e19211df6e2b58274a33ef Mon Sep 17 00:00:00 2001 From: David Robillard Date: Tue, 17 Apr 2012 21:16:18 +0000 Subject: Add lilv_plugin_get_project() and get author information from project if it is not given directly on the plugin. git-svn-id: http://svn.drobilla.net/lad/trunk/lilv@4189 a436a847-0d15-0410-975c-d299462d15a1 --- ChangeLog | 2 ++ lilv/lilv.h | 10 ++++++++++ src/plugin.c | 40 ++++++++++++++++++++++++++++++++++++++++ 3 files changed, 52 insertions(+) diff --git a/ChangeLog b/ChangeLog index 6f115b4..2660cd6 100644 --- a/ChangeLog +++ b/ChangeLog @@ -24,6 +24,8 @@ lilv (UNRELEASED) unstable; urgency=low * Remove use of wordexp. * Add lilv_plugin_get_port_by_designation() and lilv_port_get_index() as an improved generic alternative to lilv_plugin_get_latency_port_index(). + * Add lilv_plugin_get_project() and get author information from project if + it is not given directly on the plugin. -- David Robillard (UNRELEASED) diff --git a/lilv/lilv.h b/lilv/lilv.h index 80bf23c..893d1ad 100644 --- a/lilv/lilv.h +++ b/lilv/lilv.h @@ -913,6 +913,16 @@ lilv_plugin_get_port_by_designation(const LilvPlugin* plugin, const LilvNode* port_class, const LilvNode* designation); +/** + Get the project the plugin is a part of. + + More information about the project can be read via lilv_world_find_nodes(), + typically using properties from DOAP (e.g. doap:name). +*/ +LILV_API +LilvNode* +lilv_plugin_get_project(const LilvPlugin* plugin); + /** Get the full name of the plugin's author. Returns NULL if author name is not present. diff --git a/src/plugin.c b/src/plugin.c index b4a2f0b..8e91f80 100644 --- a/src/plugin.c +++ b/src/plugin.c @@ -762,6 +762,33 @@ lilv_plugin_get_port_by_symbol(const LilvPlugin* p, return NULL; } +LILV_API +LilvNode* +lilv_plugin_get_project(const LilvPlugin* p) +{ + lilv_plugin_load_if_necessary(p); + + SordNode* lv2_project = sord_new_uri(p->world->world, + (const uint8_t*)LV2_CORE__project); + + SordIter* projects = lilv_world_query_internal( + p->world, + p->plugin_uri->val.uri_val, + lv2_project, + NULL); + + sord_node_free(p->world->world, lv2_project); + + if (sord_iter_end(projects)) { + return NULL; + } + + const SordNode* project = sord_iter_get_node(projects, SORD_OBJECT); + + sord_iter_free(projects); + return lilv_node_new_from_node(p->world, project); +} + static const SordNode* lilv_plugin_get_author(const LilvPlugin* p) { @@ -778,6 +805,19 @@ lilv_plugin_get_author(const LilvPlugin* p) sord_node_free(p->world->world, doap_maintainer); + if (sord_iter_end(maintainers)) { + LilvNode* project = lilv_plugin_get_project(p); + if (!project) { + return NULL; + } + + maintainers = lilv_world_query_internal( + p->world, + project->val.uri_val, + doap_maintainer, + NULL); + } + if (sord_iter_end(maintainers)) { return NULL; } -- cgit v1.2.1