[GSoC update] Distributed Collections: Week 1

Maximilian Kossick maximilian.kossick at googlemail.com
Sun Jun 13 14:24:36 CEST 2010


On Sat, Jun 12, 2010 at 8:58 AM, Varrun Ramani <varrunr at gmail.com> wrote:
> Hi Max
>
> On 29 May 2010 18:31, Maximilian Kossick <maximilian.kossick at googlemail.com>
> wrote:
>>
>> That approach is used quite successfully in Amarok's D-Bus API. There
>> is a D-BUS method that allows external applications to query Amarok's
>> collections (all collections, unlike earlier versions which had to use
>> SQL, and broke horribly when Amarok's SQL schema changed). Amarok
>> takes a XML string, and returns a list of maps continaing track
>> metadata.
>>
>
> Can you point me to the part of the source where the Amarok D-bus API is
> implemented. I read the source of the XmlQueryReader and XmlQueryWriter
> classes. I would like to make a small test implementation by converting a
> query to XML. Hence, I would like to refer to some code that already uses
> these classes, to get a better idea.
>
>>
>> Theoretically the XML format does already support queries for other
>> entities than tracks, it's just that the current D-BUS API does not
>> support this.
>
> What other entities? Do you mean album, genre etc.. ?
>
>>
>> I think I've got a draft for a XSD lying around on my harddrive
>> somewhere. I'll try to dig it up.
>>
>
> That would be helpful

Attached you'll find the (incomplete) XSD for Amarok's XML query
format. The schema itself is valid, but I'm not sure if it matches the
actual output of XmlQueryWriter yet.

>
> --
> Varrun
>
-------------- next part --------------
<?xml version="1.0"?>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<xsd:element name="query" type="QueryType"/>

<xsd:complexType name="QueryType">
	<xsd:sequence>
		<xsd:element name="filters" type="FiltersType" minOccurs="0"/>
		<xsd:element name="order" type="OrderType" minOccurs="0"/>
		<xsd:element name="includeCollection" type="CollectionType" minOccurs="0"/>
		<xsd:element name="excludeCollection" type="CollectionType" minOccurs="0"/>
		<xsd:element name="returnResultAsDataPtrs" minOccurs="0"/>
		<xsd:element name="limit" type="LimitType"/>
		<xsd:element name="returnValues" type="ReturnValuesType" minOccurs="0"/>  
		<xsd:choice minOccurs="0">
			<xsd:element name="onlyCompilations"/>
			<xsd:element name="onlyNormalAlbums"/>
			<xsd:element name="allALbums"/>
		</xsd:choice> 
	</xsd:sequence>
	<xsd:attribute name="version" type="xsd:decimal" use="required" fixed="1.0"/>
</xsd:complexType>

<xsd:complexType name="Filter">
	<xsd:attribute name="field" type="xsd:string"/>
	<xsd:attribute name="value" type="xsd:string"/>
	<xsd:attribute name="compare" type="Comparison" use="optional"/>
</xsd:complexType>

<xsd:complexType name="AndOrType">
	<xsd:sequence>
		<xsd:element name="filter" type="Filter" minOccurs="0" maxOccurs="unbounded"/>
		<xsd:element name="or" type="AndOrType" minOccurs="0" maxOccurs="unbounded"/>  
		<xsd:element name="and" type="AndOrType" minOccurs="0" maxOccurs="unbounded"/>
	</xsd:sequence>
</xsd:complexType>

<xsd:complexType name="FiltersType">
	<xsd:choice>
		<xsd:element name="filter" type="Filter"/>
		<xsd:choice>
			<xsd:element name="and" type="AndOrType"/>
			<xsd:element name="or" type="AndOrType"/>
		</xsd:choice>
	</xsd:choice>
</xsd:complexType>

<xsd:complexType name="CollectionType">  
	<xsd:attribute name="id" type="xsd:string"/>
</xsd:complexType>

<xsd:complexType name="LimitType">
	<xsd:attribute name="value" type="xsd:positiveInteger"/>
</xsd:complexType>

<xsd:complexType name="OrderType">
	<xsd:attribute name="field" type="xsd:string"/>
	<xsd:attribute name="value" type="ResultOrdering"/>
</xsd:complexType>

<xsd:complexType name="ReturnValuesType">
	<xsd:choice>
		<xsd:choice>
			<xsd:element name="tracks"/>
			<xsd:element name="artists"/>
			<xsd:element name="albums"/>
			<xsd:element name="genres"/>
			<xsd:element name="composers"/>
			<xsd:element name="years"/>
		</xsd:choice>
		<xsd:sequence>
			<xsd:element name="title" minOccurs="0"/>
			<xsd:element name="artist" minOccurs="0"/>
		</xsd:sequence>
	</xsd:choice>
</xsd:complexType>

<xsd:simpleType name="ResultOrdering">
	<xsd:restriction base="xsd:string">
		<xsd:enumeration value="ascending"/>
		<xsd:enumeration value="descending"/>
		<xsd:enumeration value="random"/>
	</xsd:restriction>
</xsd:simpleType>

<xsd:simpleType name="Comparison">
	<xsd:restriction base="xsd:string">
		<xsd:enumeration value="less"/>
		<xsd:enumeration value="greater"/>
		<xsd:enumeration value="equals"/>
	</xsd:restriction>
</xsd:simpleType>
</xsd:schema>


More information about the Amarok-devel mailing list