Pages

Sunday, August 15, 2010

Porting a simple Opera widget to Maemo using QtWRT

With the release of Qt Web Run Time to Maemo's extras-devel repository, it is now possible to create W3C-compliant widgets for Nokia N900. Creating a widget from scratch is very easy. It is discussed in detail here.

However, porting an existing widget from Opera to Maemo can be slightly tricky. The configuration file (config.xml) in Opera's widgets do not follow the latest W3C widget specification. By changing this XML file to the W3C-compliant format, you can easily port an Opera widget to Maemo. I assume that you already have installed QtWRT on your device.

Here is the template followed by Opera widgets for configuration document.


<?xml version="1.0" encoding="utf-8"?>
<widget>
<widgetname>Template Widget</widgetname>
<description>Basic Template for all widgets</description>
<id>
<host>my.opera.com</host>
<name>Template Type 1</name>
<revised>2006-02</revised>
</id>
<width>350</width>
<height>350</height>
<author>
<name>Opera widgets</name>
<link>http://my.opera.com/community/customize/widgets/</link>
<organization>Opera Software ASA</organization>
</author>
</widget>


To make it compliant with latest W3C format, we need to make few changes.
  1. Add xmlns attribute to widget tag.
  2. Change the tag name widgetname to name.
  3. Convert the id details as an attribute to widget.
  4. Convert widget and height as attributes to widget.
  5. Convert link into href attribute for author tag.
  6. Remove the tags for author name.
  7. Merge author's organization into author name (Optional)
  8. Remove the organization node.


This is how the updated configuration file should look like. Note that I added the additional email attribute to the author tag.


<?xml version="1.0" encoding="utf-8"?>
<widget xmlns="http://www.w3.org/ns/widgets" id="my.opera.com/Widget_Name" width="350" height="350">
<name>Template Widget</name>
<description>Basic Template for all widgets</description>
<author href="http://my.opera.com/community/customize/widgets/" email="xyz@yahoo.com">
Opera widgets from Opera Software ASA
</author>
</widget>


You may also want to add additional tags based on the widget you are porting. Typically you need content and icon to indicate the start page and application icon for Maemo.



<content src="index.html" />
<icon src="widget_icon.png" />


Installation of web application failed - not supported

If you get this dreaded error, there are two possible reasons.
  1. The zip format you used to compress your widget is incorrect.
  2. The syntax in config.xml file is incorrect.


As per the W3C Widget packaging specification, you need to compress the files using deflate or compress methods. Ubuntu's default Archive Manager does not seem to follow these methods whenever I compress the files as zip from nautilus. I got the error not supported in Maemo. So finally I tried the command line utility zip and it worked perfectly.


cd widget_100
zip widget_100.wgt *


In the later case, Maemo's Hildon Application Manager does not give you any additional information about the error. If you use the command line tool widgetinstaller to install the widget, it gives you more detailed error that caused installation to fail. Sometimes it will indicate the line number in config.xml which caused the error.

So that's it, hopefully you are now ready to create and port your widgets to Maemo.

Here is my take on Chuck Noris Facts widget from Opera. All the credits for the widget go to the original author. Here is the link to the widget hosted on Opera.



References
Getting started with QtWRT
How to create simple W3C widget
W3C Widget Specifications

No comments:

Post a Comment