Tuesday, 24 September 2013

GSoC: Final Report

After three months of coding, this year's Google Summer of Code has finally ended. And it's been quite the experience :)

Last week's unfortunately been more exams than code, but there's also bug fixes (like those script console crashes), improvements (mostly to the collectionview api) and some new features. For instance, Amarok Script is now tagging aware.

The bundled lyrics script can now read embedded lyrics and optionally embed downloaded ones too (though it's more of a workaround until the rest of Amarok is lyrics tag aware).

Wrapping up, here's what was (or was not) accomplished from my proposal.

1. Added new scripting APIs for various parts of Amarok.
2. The following wishes were granted:
  • Bug 187957 - Create submenus from the Scripting interface
  • Bug 176663 - Installing a new script requires a restart of amarok
  • Bug 23271   - Provide scripting interface to customize collection display
  • Bug 279701 - Scripting support for the equalizer
  • Bug 243096 - Load a saved playlist in database from script
  • Bug 313283 - Amarok Scripting API lacks documentation
  • Bug 245647 - Programmatic access to data objects in QtScript
And partly:
  • Bug 150610 - Add Dynamic Playlist API for scripts
  • Bug 183497 - Scripting API to add a context menu to everything representing a song or file
3. The existing interface was cleaned up and some bugs fixed.
4. Added a new script console. 5. Added a script for automated documentation generation, though there's still the issue of getting it to run every time something changes in the scripting/ folder, and actually hosting the generated documentation somewhere. Also, doesn't (yet) document static functions and enums.
From my original proposal, the following still need work:
1. Podcasts

1. Dynamic playlists and automatic playlist generator- There didn't seem to be much of a use case for exposing them. ( You do, however, have scriptable biases. )
2. Transcoding- Deemed not worth the effort.

Looking Ahead
There's still the planned scriptable context view, and the scriptable service needs work too. And then there's some more polishing before my branch is ready for a merge.

It's been really nice working with the Amarok community, and hopefully there's more Amarok hacking ahead!

Wednesday, 11 September 2013

GSoC: Weeks 10 and 11

So here's what you can do with Amarok scripting now:

Theming Scripts :)
You can now theme Amarok with stylesheets and QPalettes ( it should have been possible with the existing API too, via QCoreApplication.instance(), but hey )
Perhaps not the best my Amarok has looked, but you get the idea

New Script Console
Here's the new scripting console with QtScriptDebugger components, though I'm yet to diagnose a nasty crash...

Some GUI Access
You now have scripted access to the collection view and the main window, so you can add collection view actions, scripted docks etc.

There's other random stuff, like a convenient setTimeout function with the option of specifying this object and arguments, a mode which lists object names (and copies them to clipboard) for stylesheeting, and a random experiment with a QScriptEngine hooked to a the code completion model (not too useful for now), and some fixes.

Plus, there's a new script in the works, but more on that later.

Sorry, I've been irregular again, but I've had a lot going on these past two weeks :|

This week though there are more serious plans: script access to the context view, tags and podcasts (I seem to have missed this :/).

You can find all of this on my gsocScripting2 branch on quickgit.kde.org. Thanks for reading :)

Tuesday, 20 August 2013

GSoC Week 9 + Amarok 2.8 "Return to The Origin" out NOW!

First off, version 2.8 "Return To The Origin" of your favorite music player has just been released! There's tons of new features and bugfixes, so go and update if you haven't already :)

Now on to my scripting revamp: It's nearly done. I know, I said something along the same lines last week, but this week was polishing the existing stuff [and fixing some nasty bugs]. There's also new scripting access to Amarok's bookmarking.

As for what remains, it's mostly UI interaction- like adding context menus, perhaps scriptable docks and stuff. Providers still need some work too. Personally though, I can't wait to get got working on those new scripts I'm going to write with the new API.

Thanks for reading :)

Tuesday, 13 August 2013

GSoC - Week 8

Here's a short summary of this week.

You now have scriptable biases, you can set callbacks similar to scriptable services and have a your very own dynamic playlist biases.
Also added is the new Amarok.Engine.Equalizer object for script access to Amarok's equalizer.
By next week, I should be able to finish the scripting interface as detailed in my proposal, which means I get to work on other stuff, like writing new scripts leveraging the API, and maybe some tests for the scripting interface.

The C++ script console is also undergoing a revamp to use components from the QtScriptDebugger, which means much leaner code with much more functionality.

Thanks for reading, things should get more interesting from next week!

Monday, 5 August 2013

GSoC - Week 7

This week, I've been working on exposing Amarok's playlist management and dynamic playlists.
The playlist interface pretty much mirrors the internal Amarok hierarchy, exposing three components- the playlist manager, playlist-providers and the playlist objects themselves.
No synced playlists for now though.

The dynamic playlist is, however, a whole different beast. What I want for the dynamic playlists is to have a scriptable bias, besides exposing the existing biases. As far as the existing biases are concerned, I was able to expose them via a single class using some Qt meta-magic:

  const QString command = QString(
                                "function %1( a, b, c, d  )"
                                "    return new Bias( %2, a, b, c, d );"
                                .arg( biasEnum.valueToKey( type ) )
                                .arg( type );
  engine->evaluate( command );

The dynamic playlists bits are still underway, but feel free to try the other stuff on my personal branch on quickgit.kde.org.

Yeah, no pretty pictures this week- very little of my current work directly affects the UI, though I could probably throw in some class diagrams or lolcats the next time round depending on popular demand [read weekly view-stats].

On a related note, I'm embarrassed to admit I didn't know about the QtScript debugger. It's pretty modular too, so the script console is about to go an overhaul ( which would probably render quite a bit of the existing code redundant ).

Monday, 29 July 2013

GSoC - Week 6

Hey :)
I'm Anmol, and this is the report for week 6 of my work on revamping Amarok's scripting interface. This week has been mostly been about polishing existing functionality and documenting code.

A major problem I faced this week was with the KPluginSelector widget and the KNewStuff plugin installation. KDELibs provides a DownloadDialog for easy downloading of plugins from kde.org, and uses a .knsregistry file for storing a list of files installed as part of the plugin, used by the download dialog when uninstalling files.

But annoyingly,  these installation, removal and updation methods don't seem to be exposed in any way besides the download dialog, which explains  the way we handle updation in Amarok. ( Which also means that uninstallation via the download dialog of scripts updated through amarok will leave behind newly introduced files ). The KPluginSelector, likewise, is pretty inflexible.

So what I ended up settling on is re-creating our KPluginSelector [derivative] everytime the scripts are modified, with some other workarounds to keep everything sane, like having to sort entries before insertion and having to keep a map of script names to their indices in the KPluginSelector.

For the uninstall, instead of parsing the knsregistry file, I'm just recursively deleting the script's base folder in amarok/scripts/, so here's hoping nobody bundles multiple scripts into one folder, atleast until this is improved.

Another problem was the deprecation framework- I couldn't detect an object call. For example, Amarok.Collection is now deprecated, and Amarok.CollectionManager should be used instead ( though we could possibly just keep both indefinitely ), so I had to be able to detect it. I needed dynamic getters, and fortunately stumbled upon Object.defineProperty introduced in ECMAScript5.
So I subclassed QScriptEngine and introduced a setDeprecatedProperty function:
So with this, most of what remains of my revamp are the actual APIs I am to  expose, and I still have to explore SMOKE! Hopefully I can automate those interfaces instead of having to manually write a bunch of wrappers, there are better things to do for Amarok :)

Tuesday, 23 July 2013

Weeks 4 and 5

Hey, as mentioned in my previous posts, I'm working on revamping Amarok's Scripting Interface as part of this year's Google Summer of Code. For those of you who've been living under a rock, Amarok is the best thing in music players since the phonograph.

So here's what I've been upto:

  • Scripting documentation
One of the biggest gripes about Amarok's scripting API has been the lack of documentation. There's mostly just a manually created [read error-prone] list of exposed interfaces on the wiki.

Auto-magic documentation of the scripting API posed a different challenge, as the scripting API does not resemble the standard Amarok C++ code.
After procrastinating it for a good three weeks ( how many of us follow their proposals, anyway? ), I settled on this python script to generate a pseudo-header, and also an auto-completion list, but more on that later.

Here's the resulting doxygen output.

It's not perfect yet, but the results look pretty decent. Please do comment though if you know of a better way of going about this!

  • Autocomplete
The script console's auto-complete is working now. Because nobody likes looking up the documentation too often ( or retrying, or introspecting, or whatever ),  just to get the syntax of an arbitrarily named interface right.

Sadly, no contextual information, but anything more would probably require me to move to kdevplatform. Any katepart/ ktexteditor guys willing to correct me?

  • Deprecation Notification

This might be one of the more controversial additions, but hey, it's all for the greater good.

Users running scripts accessing deprecated API calls see a popup of the sort on the left, so they can bug script writers into updating their scripts.

What are your views on this, Amarok Script Writers?

  • No restarts
That's right, you no longer have to restart on installing a new script in Amarok, so you can right down to listening to your Google Music content after installing the script ( well, as soon as streamitem's fixed in my branch actually ).

There's more changes under the hood, and still lots more to cleanup and document, but I have new leads - Markey just pointed me Richard Dale's SMOKE, which might hopefully help get things done better.