Coding for Maemo devices with Qt
Write your own smartphone apps with Qt's toolkit for the Maemo platform.
Maemo, known as the "Internet Tablet OS," is a software platform developed by Nokia for their line of Internet tablets. The Maemo platform , with an operating system and the Maemo SDK, is based on Debian Linux and Gnome (Figure 1).
In 2008 Nokia announced the acquisition of Trolltech, makers of the Qt application framework. The easily extensible Qt provides all the necessary functionality for building applications with state-of-the-art graphical user interfaces, I/O, and networking. Applications written with Qt range from the KDE desktop, to computer softphones such as Skype, to the Opera web browser, to applications such as Google Earth and MythTV.
After the Trolltech acquisition, Nokia said that Qt would "accelerate its cross-platform software strategy for mobile devices and desktop applications and develop its Internet services business." In the beginning of 2009, Nokia released a set of packages enabling support for Qt in Maemo .
Another result of the acquisition was the recently announced Nokia N900, a fully Qt-supported Nokia device. Although only the Nokia N900 Internet Tablets provide native Maemo support, many applications are already written for the Maemo platform based on previous Nokia tablets, such as the N800 and N810. In addition, Qt provides some support for the Nokia Symbian platform. In both Maemo and Symbian, platform developers can implement Qt applications in C++ or Python. The latest stable version of Qt is 4.5.
In this article, I describe how to start developing Qt applications for the Maemo platform . First, I'll show you how to set up Qt with the Scratchbox embedded development toolkit on a Nokia N810, then I'll take you through some examples, starting with a simple Hello World application and ending with an app that displays city maps using the Qt WebKit and the Google Maps API.
Qt in Maemo
The latest versions of Qt provide a complete mobile and embedded development platform based on the open source Qt toolkit. The modular Qt architecture offers building blocks for assembling a Linux-based software stack for various embedded devices, ranging from phones to set-top boxes. The Qt Extended platform comprises 19 separate components that span a broad range of functionality, including messaging, multimedia, and productivity.
The underlying telephony stack of the Qt Extended architecture (Figure 2) supports GSM, GPRS, and VoIP and supplies reference implementations that hardware makers can replace or extend. These pieces are wrapped with an abstraction layer that gives developers access that is consistent across Qt Extended devices. The Qt Extended messaging component spans the full range of mobile communication technologies, including SMS, MMS, email, and instant messaging. It is built on top of Telepathy, a modular communication framework that is also used on the Maemo platform and is increasingly being adopted on the Linux desktop. The platform includes a messaging library that provides developers with a high-level API for composing messages and manipulating the system's message data store. It also exposes Telepathy-based services, including XMPP communication, via Telepathy's Gabble connection manager.
In addition to including an audio and video playback infrastructure, the multimedia framework in Qt Extended also offers a set of common widgets for building multimedia applications. The top layer of the multimedia stack is the Phonon abstraction library. Qt Extended supports Helix and GStreamer back ends for Phonon, but adopters can also make their own back ends to plug into the stack. The multimedia stack also supports a DRM implementation that is compatible with the Open Mobile Alliance DRM standard.
The platform's built-in personal information management (PIM) layer, constructed on top of the SQLite database library, is fully extensible and can be accessed by multiple applications simultaneously. The toolkit includes synchronization APIs and widgets you can use to develop new PIM applications. The platform even comes with a reference implementation of a very basic PIM suite.
The user interface is, of course, built with the Qt widget toolkit. The layout and design of the menu system, dialer, and window manager can be customized with XML-based theming descriptions. It also includes an extensible input method system that supports basic handwriting recognition, standard phone numerical pads (with predictive text), and qwerty keyboards.
Qt Extended comes with a lot of other useful things, including the QWebKit widget for building mobile browsers and rich Internet applications, support for Bluetooth and WiFi, and some important architectural components, like a policy-based security system for sandboxing applications and an interprocess communication layer that leverages Qt's signal and slot model.
Qt Extended is distributed under the same kind of dual-licensing model as the desktop toolkit – that is, with a commercial and an open source licence under GPL. For more information about Qt in the Maemo platform, check out the Maemo Qt4 website .
Installing Qt in Scratchbox
Scratchbox is a cross-compilation toolkit designed to simplify embedded Linux application development. The Scratchbox toolkit also provides a full set of tools to integrate and cross-compile an entire Linux distribution. Nokia has adopted Scratchbox to facilitate the process of developing those applications in the desktop and to compile it for the ARM architecture that is used in Maemo devices.
First, you need to install Scratchbox and the Maemo Diablo SDK on your host machine   . After installing Scratchbox, there are two possible targets: ARMEL, used to emulate applications for Armel-based platforms, and X86-based platforms. For both cases, Qt4 development support is not installed by default, so you must install Qt4 as well as the libraries for both targets. To start, you need to add the extra and extra devel repositories to Scratchbox apt-get sources and install the Qt libraries. See the box titled "Installing the Qt Environment."
Installing the Qt Environment
To install, open a terminal and type the following command to enter in the Scratchbox environment:
Then open the /etc/apt/sources.list file with vi.
sudo vi /etc/apt/sources.list
Use the directions keys to go to the end of the file, and press the Insert or i key to enter the follwing commands for enabling the extra and extra-devel packages in Apt:
deb http://repository.maemo.org/extras/ diablo free non-free deb-src http://repository.maemo.org/extras/ diablo free deb http://repository.maemo.org/extras-devel/ diablo free non-free deb-src http://repository.maemo.org/extras-devel/ diablo free
Press Esc when you are finished, and type the command :x plus the Enter key to save the changes and quit vi.
The next step is to install the Qt4 programming environment with the following commands:
apt-get update fakeroot apt-get install libqt4-core fakeroot apt-get install libqt4-gui fakeroot apt-get install libqt4-dev
Now you are ready to developing Qt applications for the Maemo platform.
Qt4 on a Maemo Device
Next, you need to install Qt4 and PyQt4 on a Nokia N810 Internet Tablet. Although I will use the N810 for this example, you should also be able to follow these steps using a Nokia N800 device. PyQt is a set of bindings that allows programmers to access a Qt library through Python. To install Qt4 and PyQt4 on an N810, you must be running the Maemo OS2008 system with the Python environment installed on your device.
The first step is to enable the extras-devel repository in your N810. Open the web browser on the N810 and go to http://qt4.garage.maemo.org. Scroll down the page until find something similar to Figure 3, and click on the link Click to install DEVEL, which will open the File Download dialog box.
Click on the Open button to open the file after it downloads. This will launch the maemo application manager application. You will be asked if you want to add the Qt4 repository in the sources.list file. Click on the OK button to add the Qt repository.
Clicking on the Browse installable applications option and typing Qt4, as shown in Figure 4, lets you search for the Qt packages available in the Maemo Application manager. A list of the Qt4 packages will appear. Install all the Qt4 packages you consider important, but at the very least, install the packages libqt-core, libqt-gui, python2.5-qt4-core, and python2.5qt4-gui.
Kernel king admits his tone has alienated volunteers, but says the demands of the process require directness.
New flaw in an old encryption scheme leaves the experts scrambling to disable SSL 3
Lennart Poettering wants to change the way Linux developers talk to each other.
Enterprise giant frees itself from ink and home PCs (and visa versa).
Mozilla’s product think tank sinks silently into history.
TODO group will focus on open source tools in large-scale environments.
New tool will look like GParted but support a wider range of storage technologies.
New public key pinning feature will help prevent man-in-the-middle attacks.
Carnegie Mellon researchers say 3 million pages could fall down the phishing hole in the next year.
The US government rolls new best-practice rules for protecting SSH.