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 :)

2 comments:

  1. Hi there. Just wanted to say big thank you to your contributions to the Amarok music player (my favorite one). And I would like to ask you 2 things. First, for scripts that load and stream internet radio stations, is it possible to add album art (either downloading it from their website, if they allow it, or making it custom and loading it from script's folder) ? And second, is there a chance of implementing some kind of .cue sheets splitter for Amarok or does that have something to do with licencing or codecs ? It's not hard to split them manually with Flacon, but it would be nice to have that already built in, like foobar2000, because Amarok is the most complete music player I know of. Keep up the good work.

    ReplyDelete
  2. It's
    About the album art, yes- you can set a coverurl in the streamitem.
    This link may help: http://community.kde.org/Amarok/Development/Scripted_Services_Tutorial_2.0

    And for the cue files- unfortunately, no. Amarok has rather limited cue support. Though you can use other tools.
    Mamarok suggested avconv- http://paste.kde.org/p79895e65/
    Btw, you can always create a qprocess in qtscript and call an external binary- though that might limit portability.

    ReplyDelete