feedbacks needed for scripting interface
Ian Monroe
ian at monroe.nu
Mon Jul 7 07:28:55 CEST 2008
On Sun, Jul 6, 2008 at 2:52 PM, Peter Zhou <peterzhoulei at gmail.com> wrote:
> Hi Amarok folks,
>
> I have already implemented some of the useful functions for our new
> scripting interface. I admit the new interface is not well structured.
> Since I have no experience of designing API before, I'd like to get
> some feedback from you guys, and hopefully we could make everything
> nice before it's too late :)
I re-wrote the QtScript Cool Stream using a hypothetical API. I mean,
I didn't try to implement so its very likely that I'm missing some
needed details.
But basically for stuff like the Service Framework the C++ API is
probably a better guide then D-Bus, JavaScript can use normal OOP
style programming after all.
function CoolStream()
{
ScriptableServiceManager.call( this )
this.serviceName = "Cool Streams";
this.levels = 2;
this.shortDescription = "List of some really cool radio streams";
this.rootHtml = = "Some really cool radio streams, hand picked for
your listening pleasure by your friendly Amarok developers";
}
CoolStream.prototype.populate = function( parent_id )
{
if (parent_id == -1)
{
print( "Populating main level..." );
//add top level item
coolParent = StreamItem.new();
coolParent.id = 1;
coolParent.parentId = -1;
coolParent.name = "The Amarok Crew\'s Top Streams";
coolParent.htmlInfo = "Just a parent item to show how nesting works";
coolParent.url = "";
this.insertItem( coolParent );
print( "... done" );
}
else if ( parent_id == 1 )
{
print( " Populating station level..." );
//add the station streams as leaf nodes
for (i = 0; i < stationUrl.length; i++)
{
coolStream = CoolStream.new();
coolStream.url = stationURL[i];
coolStream.name = stationName[i];
coolStream.parentId = parent_id;
coolStream.htmlInfo = "A cool stream called " + stationName[i];
this.insertItem( coolStream );
}
}
}
CoolStream.prototype.onConfigure = function()
{
Amarok.Statusbar.longMessageThreadSafe( "This script does not
require any configuration." );
}
CoolStream.new()
More information about the Amarok-devel
mailing list