Metadata in kioslaves

David Faure faure at kde.org
Fri Jul 20 11:22:36 BST 2007


On Wednesday 18 July 2007, Jeff Mitchell wrote:
> After discussion with Kevin Ottens and some fellow Amarok developers, 
> I'm working on a Portable Media Player kioslave that uses Solid to 
> detect and load the appropriate backend, providing a generic and 
> standardized interface to music on a variety of devices.  However, there 
> is a need for some advanced functionality that the kioslave API does not 
> provide.  Mostly this is in terms of retrieving special data from 
> players (such as a play count for each song or podcasts that have been 
> listened to).
> 
> The metadata functions seem like they could be used for this using 
> specific keywords.  For example, doing a queryMetaData on a Job with the 
> key "Statistics" could cause statistic data to be returned.  Doing a 
> setMetaData with a key:value pair could perform special functions on a 
> device, so that when the slave has setMetaData called with specific 
> keys, it can call some library-specific function.
> 
> Because these queries and library calls would happen at known times, 
> throughput isn't too much of an issue (since simply copying files back 
> and forth would be handled by basic functions of the slave).  So I was 
> thinking that returning XML in the QString that is returned by 
> queryMetaData would be fine.  This is much more robust than defining 
> some sort of arbitrary method that would break anything using it 
> whenever it was changed if the scheme was found to be lacking; using XML 
> unsupported keys could simply be ignored.  So using XML would make it 
> far more likely that this one-does-it-all kioslave approach would work.
> 
> So, the questions:
> 1) KIO::Job::queryMetaData says "(Valid when first data is received 
> and/or slave is finished)"  Does this imply that I cannot, at any given 
> point, simply call queryMetaData with a specific key?
You can, but only once the slave has started to send something back to the 
application, not before, that's what this means.

> KIO::SlaveBase::metaData doesn't mention any such restriction.  If there 
> are restrictions on when queryMetaData could be called, what exactly are 
> they?  Because for what I'm doing I don't see the relevance to data() or 
> finished().
Right. Initially metadata was in TransferJob only (get and put), which is why the
outdated documentation refers to data(). Now that metadata is available to any
job, it should probably say "valid after the slave starts processing this job" or something.

> 2) Kevin thought it best to ask on this list regarding using XML as 
> proposed above because of possible performance limitations.  I don't 
> think it will be problematic due to the known nature of when this would 
> occur (plugging in a device and then having a progress bar while 
> informing the user "Please wait while we sync metadata" is an acceptable 
> scenario IMHO).
As long as this is kioslave-specific and application-specific I don't see much problem
with using XML.


-- 
David Faure, faure at kde.org, sponsored by Trolltech to work on KDE,
Konqueror (http://www.konqueror.org), and KOffice (http://www.koffice.org).




More information about the kde-core-devel mailing list