Donnerstag, 28. Oktober 2010

MaePadWeb - A Web UI for MaePad running on your N900

One of the annoyances with task lists on mobile devices is that there is no easy way to view or edit your task list on your computer as well (there are some web services that allow for these things, but you have to trust your data to these services, and not all these services have a full-featured Maemo client app, and they mostly need to synchronize data between different clients).

So, what about having a simple HTTP server that you can start on your N900 and access from your computer's web browser to view and edit your MaePad checklists? Here's a short video of how it works at the moment:

Here's a screenshot of how the checklist view looks right now:

The MaePadWeb application will be available soon. On a related note, MaePad 1.8 is out now with live search support for the memo list - check it out and test it/vote for it!

Montag, 25. Oktober 2010

SSH agent forwarding in Scratchbox

I usually have the Maemo SDK running inside a VM - either completely remote or on the same machine (so I can have a 32-bit minimal Debian install containing Scratchbox independent of the host system). I can then SSH into the development VM from my working machine using public key authentication and the SSH agent. I also have agent forwarding set up, so that I can SSH from the SDK machine directly to the N900 (to deploy binaries and .debs) or to some server requiring SSH access (e.g. without having to generate lots of keys and distributing the key to all kinds of different machines.

Using -A (or ForwardAgent yes in .ssh/config) when SSHing into the SDK machine makes it possible to connect to other machines from it, utilizing your SSH key. This sadly does not work when starting scratchbox, because it opens a new environment, and the $SSH_AUTH_SOCK environment variable is lost. To fix this, I simply write the contents of this variable into a file accessible from Scratchbox and then export this variable in the Scratchbox login script. I usually also have a symlink in $HOME pointing to the SDK $HOME:

ln -s /scratchbox/users/$USER/home/$USER ~/sdk

With this in place, I can now edit the "normal" user's login script by adding the following line at the end of .bashrc:

echo $SSH_AUTH_SOCK >~/sdk/.ssh_auth_sock

Scratchbox has its own login script (also called .bashrc, but sitting in the Scratchbox home folder), so we edit this and add the following line:

export SSH_AUTH_SOCK=`cat .ssh_auth_sock`

After this, logout of Scratchbox, logout of the SSH session and then connect again with SSH forwarding:

ssh user@maemosdk -A
ssh-add -l

The last command should display the fingerprint of your SSH key. You can now connect to remote hosts from within your Scratchbox session while your SSH key still resides only on your local machine, loaded into the SSH agent.

Montag, 11. Oktober 2010

gPodder 2.9 for Maemo 5 in Testing

A new release of gPodder is out. Test it and vote! It has got some fine-tuning of the UI for Maemo 5 users that you will discover one by one. I just want to highlight two UI changes that should enhance the user experience, and compare them to what the previous version had.

The episode list

gPodder 2.8 introduced MAFW integration, and with it came the ability to save position and duration information for each episode. This was displayed in the episode action dialog, but not in the episode list. We now display the position and duration in the episode list, which allows you to quickly scan for an episode depending on its duration (or check how far you have come for a given episode). In the "All Episodes" list, we also display the podcast name for each episode so that it is clearer from which podcast an episode is coming (the content of the episode "Mini Book Reviews" is much more predictable if you know that it comes from "Python411").

Updating feeds

Previous versions of gPodder changed the "Check for updates" button into a combined progress indicator and cancel button. It was not really obvious to first-time users that you can cancel the feed update, and if you accidentally tapped the button twice, the feed update would be cancelled and you might be confused. gPodder 2.9 introduces a fancy new progress bar that appears (and even slides in and out thanks to hildon.AnimationActor) during the update and has a more obvious red cancel button. With the gained screen space (the progress bar is much bigger), we can also show more information about the update process, like the name of the updated podcast.

A detailed changelog can be found at Of course, the Maemo 4 (N800, N810) package has also been updated, and is available from Diablo Extras right now.

Mittwoch, 6. Oktober 2010

Modifying the Maemo 5 task switcher and launcher

This will be the last post for this week, I promise ;) After playing around with the MeeGo Handset launcher and task switcher, I decided to have a look at how this could be implemented in Fremantle, because the big previews and the paginated launcher are easier to use in some cases (you can also checkout the contents of a window while scrolling by without having to activate it). hildon-desktop manages the task switcher and launcher, among other things. The results of two days of hacking are two patches:

What I'm missing right now and did not succeed in implementing straight away is the "snapping" of TidyFingerScroll to page boundaries, so that whenever a scroll operation is finished, it automatically scrolls to center the icon page (for the launcher) or a preview window (for the task switcher). Obligatory demo video (.debs and patches are linked from the threads above if you want to try it out yourself) here:

If you happen to have experience in Clutter, why not give it a try? I suppose you would just need to implement another scroll mode in TidyFingerScroll and then request this mode in hd-task-navigator.c and hd-launcher-page.c. Who's up for the challenge? :)

Random observation: Hidden in hd-task-navigator.c one can find a geeky gem:

  xthumb = ythumb = 0xB002E;

A new gPodder release should be ready next week. And now back to some Uni stuff :)

Dienstag, 5. Oktober 2010

Fast MeeGo Handset UX on a N900 (Video)

I've had the chance to play around a bit more with the MeeGo Handset UX on the N900 yesterday ( Carsten provided experimental graphics drivers, which still crash at a few points, but for the first time provide acceptable performance in the UI. I also decided to build the gPodder MeeGo Touch Prototype UI against libmeegotouch. Unfortunately, there's no SDK yet, so I had to use zypper on the device (via SSH) to install libmeegotouch-devel, make and gcc-c++ and then take a long coffee break after entering qmake ; make. As it's using plain Qt, the TRG binary built from the Fremantle SDK worked fine on the device.

If you don't see the embedded video, click here: MeeGo Handset UX on a N900 (w/ TRG, gPodder UI test, HW-accelerated).

Montag, 4. Oktober 2010

Qt: Write once, #ifdef everywhere?

Despite what the title of this post might suggest, I really like Qt. But as a developer, I also know that "write once, run everywhere" isn't realistic without writing some special-cased platform-specific code. Qt does take care of many platform-specific things, and I think it's the closest you can get to "write once, run everywhere" right now.

This post should serve two purposes: To provide a real-world example of what needs to be done in the code for the app to work on both Maemo 5 and Symbian^3 (with example code), and to get suggestions on what parts I could rewrite in a more platform-agnostic manner with existing APIs (so please comment if you are in the know!).

Here's the story: In early September, I've rewritten my game "That Rabbit Game" to use QGraphicsView on the N900, and in the last weeks, I've ported it to Symbian^3. I use the macro Q_OS_SYMBIAN to check for Symbian and Q_WS_MAEMO_5 to check for Fremantle. Here's the current main menu on a N900 and N8 (different screen resolutions and aspect ratios):

Qt modules: In the qmake project file, I can use linux-g++-maemo5 to add Maemo-specific configuration, and symbian for Symbian-specific settings. I use D-Bus module on Maemo, but obviously not on Symbian, so my project file contains something like this:

linux-g++-maemo5 {
QT += dbus

This is nice, because I only have to maintain one project file, and the block structure is very readable (and I can even use different Qt submodules for each platform).

Screen orientation: Symbian has auto-rotation for Qt apps by default, and Maemo 5 has landscape-only mode by default. For my game, portrait mode does not make sense, so I have to request landscape-only on Symbian (similarly, if I want auto-rotation everywhere, I have to request it on Maemo 5 and do nothing in Symbian). For this specific case, I need some libs in Symbian, so I add this to the project file:

symbian {
LIBS += -lcone -leikcore -lavkon

I also need to add this to the top of my main source file:

#include <AknAppUi.h>

And finally, I have to copy'n'paste a code block into my main() function before I create the first window:

CAknAppUi* appUi = dynamic_cast<CAknAppUi*> (CEikonEnv::Static()->AppUi());
if (appUi) {
// Lock application orientation into landscape

It would be nice if Qt (or Qt Mobility?) has some generic API for this, where I just need to do something along the lines of QRotation::setMode(QRotation::LandscapeOnly); and let it take care of the platform-specific stuff.

Accelerated QGraphicsView: On Symbian^3, QGraphicsView is automatically accelerated via OpenVG (I think), but on Maemo 5, it can use OpenGL for this (but does not by default), so in the code where I create my QGraphicsView, I have to have this at the top:

#ifdef Q_WS_MAEMO_5
# include <QGLWidget>

And then somewhere down that file where I create the QGraphicsView, this code goes there:

#ifdef Q_WS_MAEMO_5
QGLWidget *glw = new QGLWidget(QGLFormat(QGL::DoubleBuffer));

It's not that difficult, and is already cross-platform (on platforms where OpenGL is available), but maybe QGraphicsView can be OpenGL-accelerated on Maemo 5 by default. Maybe there is some non-obvious side effect that using an OpenGL viewport has that I'm not aware of, and that's why one has to do it manually.

Accelerometer readings: This might actually be a bug in Qt Mobility. For my game, I have to read the accelerometer's Y axis on Symbian, and its X axis on Maemo to determine the rotation for the same holding position of the device, so there's another platform-specific #ifdef there. Again, this will hopefully be fixed in a future release of Qt Mobility, and will most likely be fixed for MeeGo as well.

Task switcher: It's customary on Maemo to have a task switcher button in the upper left corner. There's no platform-agnostic way of going to the task switcher, so I needed to special-case it for Maemo 5, and have not bothered implementing it on Symbian^3 (suggestions welcome!). First, I need to include D-Bus headers for this (I've already mentioned how to request the D-Bus module in the qmake project file above) :

#if defined(Q_WS_MAEMO_5)
# include <QDBusConnection>
# include <QDBusMessage>

When I'm in the handler code where I need to do the actual task switching, I can utilize it to activate Maemo 5's task switcher:

#if defined(Q_WS_MAEMO_5)
QDBusConnection c = QDBusConnection::sessionBus();
QDBusMessage m = QDBusMessage::createSignal("/", "", "exit_app_view");

This is very much Maemo 5-specific, and will very likely not work on MeeGo Harmattan. Again, here it would be nice to have a cross-platform way of doing window management (in Qt or Qt Mobility?). I can imagine this being useful not only on handsets, but also on netbooks and tablets (from a MeeGo PoV). Again, trying to come up with pseudo-APIs here, QWindowManager::showTaskSwitcher(); could be a nice way to handle this in a cross-platform way, hiding platform-specific implementations. From what I've seen of MeeGo Touch, activating the task switcher there simply iconifies the window on the Desktop, so maybe if I would iconify my main window, it should activate the task switcher on Maemo 5 and Symbian. It does not work on Maemo 5 right now, though, and I haven't tested it on Symbian.

Screen resolution: This was (thanks to QGraphicsView) less of a problem than I thought it would be. Symbian^3 (or at least the N8) uses 640x360 as its resolution, and Maemo 5 uses 800x480. Maybe the MeeGo Harmattan device will use yet another resolution. I still configure my QGraphicsScene object manually via #ifdefs to get a good resolution, but the code could just measure the resolution and configure the scene as well. Here's what I use:

#if defined(Q_WS_MAEMO_5)
setSceneRect(0, 0, 800, 480);
#elif defined(Q_OS_SYMBIAN)
setSceneRect(0, 0, 640, 360);

I then use the sceneRect() of my scene to calculate a scale factor for all contents and call setScale() on all root items of the scene to scale the contents to the current screen size. You might have to take care of different aspect ratios on different devices, too - but it was unproblematic for my use case (the game) this time.