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