Widget Anatomy – The Manifest

This is the first part of a new blog series that will describe, in detail, all major aspects of the widget framework available in Windows Mobile 6.5.

The widget manifest is an XML file that describes the corresponding widget in detail so that Windows Mobile can actually do something with it.  This is the first file we look at when the widget is being installed or executed so, even though it is simple, it is extremely important.

For Windows Mobile 6.5 we implemented widgets based on the W3C Widgets 1.0: Packaging and Configuration standard dated Dec-22-08. While the standard continues to evolve, our implementation remains backwards compatible with very few exceptions – notable exceptions will be called out in this blog series.  To save you some W3C reading time, in summary, the widget manifest has to be called config.xml and its presence is required in order for the widget to be considered valid.  Technically you could provide an empty widget manifest and thus get something installed, since all elements inside config.xml are optional.  That said, I recommend that at the very least you define the elements that are present in the following example:

<?xml version="1.0" encoding="utf-8" ?>

<widget xmlns="http://www.w3.org/ns/widgets"

        version="1.0"

        id="http://someSite.com/MyUniqueWidgetID">

  <name>My first widget</name>

  <content src="widget.htm" type="text/html" />

  <access network="true" />

  <icon src="icon.png"/>

  <icon src="icon.ico"/>

  <description>

    This is my first widget,

    it won't make a lot of money on the

    marketplace but at least is cute!

  </description>

  <author href="http://www.windowsphone.com/blog"

          email="jorgeperaza@hotmail.com">Jorge Peraza</author>

  <license>

    Example license (based on MIT License)

    Copyright (c) 2008 The Foo Bar Corp.

    THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS

    OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF

    MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.

    IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY

    CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,

    INSULT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE

    SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

  </license>

</widget>

The Widget Element: What Makes Me… Me?

The first element I would like to cover in detail is the <widget> element, the father of all other widget configuration elements.The document can have only one and, from the many attributes that can be specified, we only honor the following two in the current release:

  •  version="1.0" This attribute specifies the widget version number, we use this to check if, when trying to install a new widget with the same id it should be allowed as an upgrade or not.
  • id ="http://someSite.com/MyUniqueWidgetID" This attribute is actually extremely important, this is the unique per widget ID that the framework uses to identify installed widgets.This has to be a well-formed URI but it does not have to be valid.

Some of the child elements like <name>, <description>, <author> and <license> are self-explanatory so I won’t bore you with details for them. See? I’m nice sometimes :-).

Now, let’s talk about one of the most important child elements which happens to be <content src="widget.htm" type="text/html" />This element tells the widget framework which source file to load to execute the widget.You might also notice that the MIME type is also specified here… however on WM 6.5 we only support "text/html" so don’t get any ideas!!

The next group of interesting child elements are the set of <icon src="icon.png"/> which allow you to specify one or more icons for your widget. Icons are very important because they give your widget their unique personality.  Now, there are some important limitations widget writes should be aware of.  Windows Mobile Professional (touch screen) supports both PNGs and JPGs as image file formats to be used as widget icons, however, Windows Mobile Standard only supports ICOs (Please, don’t ask :-)) Soooo, in order for your widget to show best on both platforms I recommend having both and listing the PNG or JPG first.

Last but not least let’s talk about  <access network="true" />. This is an optional element that is required to be “true” if your widget accesses network resources, otherwise you can leave it out (but all cellular network calls will fail).

I went to all the effort for defining all fields in the manifest… can I at least access them from my widget?

Glad you asked, and the answer is… of course!  You can do this by using the widget metadata API available to you courtesy of the “widget” javascript object.  Below are the relevant properties that you can use to get information out of the manifest:

  • widget.version
  • widget.identifier
  • widget.name
  • widget.description
  • widget.authorEmail
  • widget.authorName
  • widget.authorURL
  • widget.height
  • widget.width
  • widget.locale

That’s it for now.  Please stay tuned for more information and happy widget writing!


Comments

  1. Posted on: August 19, 2009 at 4:07AM  

    Are the WM widgets compatible with the widgets that Vodafone have been promoting?

    www.betavine.net/.../widgets

    Or is it just a different thing with a similar name?

  2. Posted on: August 21, 2009 at 6:58PM  

    Hi,

    How working version?

    If I install the same widget, WM install a second widget.

    If I change the number version, WM install an another widget...

    And how uninstalling widget ?

  3. Posted on: August 24, 2009 at 12:39PM  

    dalelane they are different things with similar names.

    Jean-Michel

    The installer will prevent installing the same widget (That is, same ID and version) over and over again, only when the version number is different (does not matter if is higher or lower) then the installation will proceed as an "Upgrade" where all the persistent preferences will be preserved.

    Widgets can be uninstalled using the same "Remove Programs" control panel app that native applications use.

Trackbacks

  1. Posted by: Widget Anatomy ??? The Manifest | ASP Scribe on August 12, 2009 at 11:43AM

    Pingback from  Widget Anatomy ??? The Manifest | ASP Scribe

  2. Posted by: What is Windows Mobile 6.5 Widget ? « MobileTechWorld on August 12, 2009 at 1:41PM

    Pingback from  What is Windows Mobile 6.5 Widget ? « MobileTechWorld

  3. Posted by: Widget Anatomy ??? The Manifest | India Phone cards on August 12, 2009 at 8:58PM

    Pingback from  Widget Anatomy ??? The Manifest | India Phone cards

  4. Posted by: Teach News, Resources from Blogosphere – 13 August 09 (2) | Hostgator Hosting on August 13, 2009 at 12:48AM

    Pingback from  Teach News, Resources from Blogosphere – 13 August 09 (2) | Hostgator Hosting

  5. Posted by: Windows Mobile 6.5 “Widget Manifest” on August 13, 2009 at 10:17AM

    Pingback from  Windows Mobile 6.5 “Widget Manifest”

  6. Posted by: Widget Anatomy ??? The Keys for a Great User Experience | Windows Seven 7 on September 02, 2009 at 1:00PM

    Pingback from  Widget Anatomy ??? The Keys for a Great User Experience | Windows Seven 7

  7. Posted by: Widget Anatomy ??? The Keys for a Great User Experience | Windows 7 Information, News, Downloads, Support Forums on September 02, 2009 at 2:14PM

    Pingback from  Widget Anatomy ??? The Keys for a Great User Experience | Windows 7 Information, News, Downloads, Support Forums

  8. Posted by: You Get The . Info » Widget Anatomy ??? The Keys for a Great User Experience – 782th Edition on September 04, 2009 at 12:25AM

    Pingback from  You Get The . Info » Widget Anatomy ??? The Keys for a Great User Experience – 782th Edition

  9. Posted by: You Get The . Info » Widget Anatomy ??? The Keys for a Great User Experience – 807th Edition on September 07, 2009 at 12:31AM

    Pingback from  You Get The . Info » Widget Anatomy ??? The Keys for a Great User Experience – 807th Edition

  10. Posted by: innovation604 News Portal » Widget Anatomy ??? The Keys for a Great User Experience on September 07, 2009 at 8:30AM

    Pingback from  innovation604 News Portal » Widget Anatomy ??? The Keys for a Great User Experience

  11. Posted by: Mer om Marketplace « Peter Wissingers Mobilblogg on September 30, 2009 at 3:07PM

    Pingback from  Mer om Marketplace « Peter Wissingers Mobilblogg

  12. Posted by: Delving Into Dynamics on October 07, 2009 at 1:33PM

    Developing Widgets for Windows Mobile 6.5 is fun and in this series Jorge Peraza describes the widget

  13. Posted by: Все обо всем on January 14, 2010 at 6:27AM