Toying with maemo and rotating apps

February 1st, 2010

I have been playing a bit around with Maemo and writing Qt apps for n900. I ended up needing a rotation aware QMainWindow a couple of times, so I ended up abstracting it away in my own MaemoMainWindow, which I just wanted to share. It has enough ifdefs to also build against ‘normal’ Qt, outside Maemo.

Have fun. Available under any license.

maemomainwindow.h:

#ifndef MAEMOMAINWINDOW_H
#define MAEMOMAINWINDOW_H                                          

#include <QMainWindow>

class MaemoMainWindow : public QMainWindow
{
  Q_OBJECT
  public:
    MaemoMainWindow (QWidget* parent = 0, Qt::WindowFlags flags = 0);
    virtual ~MaemoMainWindow();
  protected:
    virtual bool event (QEvent* event);
  Q_SIGNALS:
    void orientationChanged(Qt::Orientation newOrientation);
  private Q_SLOTS:
    void orientationChangedSlot(const QString& newOrientation);
  private:
    Qt::Orientation m_orientation;
};                                                                   

#endif // MAEMOMAINWINDOW_H

maemomainwindow.cpp:

#include "maemomainwindow.h"                                         

#ifdef Q_WS_MAEMO_5
#include <mce/mode-names.h>
#include <mce/dbus-names.h>
#endif                     

#ifdef Q_WS_MAEMO_5
#include <QDBusConnection>
#include <QDBusMessage>
#include <QEvent>
#endif

MaemoMainWindow::MaemoMainWindow (QWidget* parent, Qt::WindowFlags flags) : QMainWindow (parent, flags) {
#ifdef Q_WS_MAEMO_5
  QDBusConnection::systemBus().connect(QString(), MCE_SIGNAL_PATH, MCE_SIGNAL_IF,
                                       MCE_DEVICE_ORIENTATION_SIG,
                                       this,
                                       SLOT(orientationChangedSlot(QString)));
#endif
}

MaemoMainWindow::~MaemoMainWindow() {

}

void MaemoMainWindow::orientationChangedSlot (const QString& newOrientation) {
#ifdef Q_WS_MAEMO_5
  if (newOrientation == QLatin1String(MCE_ORIENTATION_PORTRAIT)) {
    setAttribute(Qt::WA_Maemo5ForcePortraitOrientation, true);
    emit orientationChanged(Qt::Vertical);
  } else {
    setAttribute(Qt::WA_Maemo5ForceLandscapeOrientation, true);
    emit orientationChanged(Qt::Horizontal);
  }
#else
Q_UNUSED(newOrientation);
#endif

}

bool MaemoMainWindow::event (QEvent* event) {
#ifdef Q_WS_MAEMO_5
  switch (event->type()) {
    case QEvent::WindowActivate:
      QDBusConnection::systemBus().call(
           QDBusMessage::createMethodCall(MCE_SERVICE, MCE_REQUEST_PATH,
                                          MCE_REQUEST_IF,
                                          MCE_ACCELEROMETER_ENABLE_REQ));
      break;
    case QEvent::WindowDeactivate:
      QDBusConnection::systemBus().call(
           QDBusMessage::createMethodCall(MCE_SERVICE, MCE_REQUEST_PATH,
                                          MCE_REQUEST_IF,
                                          MCE_ACCELEROMETER_DISABLE_REQ));
      break;
    default:
      break;
  }
#endif
  return QMainWindow::event (event);
}

Update: reformatted code. Thought wordpres and <code> was smart. Thanks Ken.

Maemo-udvikling og nokiakonkurrencer

January 27th, 2010

Nokia har startet en konkurrence i at lave gode maemo-applikationer, hvor man kan vinde op til 15000 kroner. Mere herom på http://NokiaOpen2010.RockingMaemo.dk. Det ser ganske interessant ud.

Jeg har lige for sjovs skyld leget lidt med at skrive en medieafspillerapplikation til min n900. Bare for at lege lidt med Phonon og for at se hvordan det var at arbejde med. Kildeteksten kan findes her: maemoplayer-0.1.
En prekompileret eksekverbar (ikke en pakke) kan findes her: player. Den kræver at libqt4-maemo5-maemo5 og libqt4-maemo5-phonon er installeret. Og vær opmærksom på at store dele af /home/user er mounted noexec.
Og det er mest interessant at bruge ‘run-standalone.sh‘ til at starte den med. Så bliver den Maemo-temaet. Ellers kører applikationen med Qt’s standardtema.

Min medieafspiller er primitiv, men virker. Den bruger også Maemo’s banner-funktionalitet, ligesom den er i vandret modus når telefonen er på siden, og i lodret modus når telefonen er på højkant. Derudover bruger den også Qt’s multimedieframework, phonon, og Qt’s model-view framework.

Hvis man ønsker sit eget udviklingsmiljø, så har jeg fundet det lettest at følge denne
guide på KDE’s wiki.

Dog måtte jeg lige i gennem et par ændringer.

  1. Når installationen af alarmd fejler, så åbn /var/lib/dpkg/info/alarmd.postinst inde i scratchbox og tilføj ||true til den fejlende linje (linje 47).
  2. Når en masse gconf-ting fejler, så inde i scratchbox, så kan man lige køre dpkg-divert --rename --divert /usr/sbin/gconf-schemas.real --add /usr/sbin/gconf-schemas og oprette en ny /usr/sbin/gconf-schemas fil med følgende indhold:
    #! /bin/sh
    /usr/sbin/gconf-schemas.real $@ || true

    (husk x-bit)
  3. og sidst men ikke mindst, resolv.conf inde i scratchbox skal fixes

Disse trin skal gennemføres både for ARMEL og X86-udgaverne.

Til NokiaOpen2010 kan man også vinde n900-telefoner og få gratis deltagelse i et OpenSource event i starten af marts.

Jeg håber på at rigtig mange deltager i NokiaOpen2010 og generelt skriver endnu flere gode programmer til n900.

Subclassing QMutex considered harmful

November 23rd, 2009

If you are using QMutex, you are probably writing threaded applications, and thus want to use helgrind (part of valgrind).

helgrind has some support for threading and mutexes in Qt, but not fully.

If you try to run a app using a QMutex subclass in helgrind, it fails with


<appname>: hg_intercepts.c:2124: _vgwZU_libQtCoreZdsoZa__ZN6QMutexC2ENS_13RecursionModeE: Assertion `0' failed.

Basically, it is the handler for the _ZN6QMutexC2ENS_13RecursionModeE symbol that is implemented as assert(0);. The demangled symbol is QMutex::QMutex(QMutex::RecursionMode), which looks very much like the constructor for QMutex:

$ objdump -T /usr/lib/libQtCore.so | grep _ZN6QMutexC
00068840 g DF .text 0000005b Base _ZN6QMutexC2ENS_13RecursionModeE
000687e0 g DF .text 0000005b Base _ZN6QMutexC1ENS_13RecursionModeE

which both demangles into the same QMutex::QMutex(QMutex::RecursionMode)

The important difference is the C1 vs C2 in the mangled symbol name. The C1 symbol is used for creating QMutex objects (complete object constructor), wheras the C2 symbol is used for creating subclasses of QMutex (base object constructor).

And the C2 handler in helgrind is as said implemented as assert(0);.
So until helgrind is fixed here, please be careful to not subclass QMutex. (the destructor handler for subclasses is also implemented the same way)

QMutex has no virtual base class, so even in case of subclassing, I think the helgrind handlers should be implemented the same way in the base object constructor as in the base complete object constructor.

I guess I should file a bug against helgrind.

A test app if anyone is curious:

#include <QtCore>

class mymutex : public QMutex {
public:
mymutex(QMutex::RecursionMode=QMutex::NonRecursive);
};
mymutex::mymutex(QMutex::RecursionMode mode) : QMutex(mode) {
}

int main(int, char**) {
mymutex m;
QMutexLocker lock(&m);
return 0;
}

Update 1: Bug filed.
Update 2: Better understanding of virtual base classes. Thanks Thiago

Dizzy

September 20th, 2009

I dag stod jeg tidligt op, satte Rotator på og ventede på at klokken blev 9. Klokken 9.01 var der udsolgt uden billet til mig :/

Matthew Rosewarne

September 11th, 2009

Over the last months, I have been asking people in KDE irc channels and in Debian KDE channels wether they have heard from Matthew Rosewarne, on irc known as Mukidohime. No one had.

Very recently, I uploaded one of his packages with the following changelog entry:

* Switch Maintainer field to krap team and remove Matthew, he seems absent.
We hope he comes back.

Apparantly he was absent. Permanently. Elizabeth Krumbach writes some nice words in his memory.

I remember Matthew for his work on several KDE related packages in Debian, always doing a job that was better than I expected. And I especially remember him at Akademy 2008 where he to much joy brought a black horse whip for the chairman of a talkroom. And he even brouht a spare pink horse whip for when the black one broke. Especially Adriaan had a good use of that.

And at last, I will bring a image of Matthew showing off his equipment to Aaron Seigo.

Matthew Rosewarne

Matthew Rosewarne

Condolences to his family. Matthew will be missed.

kde4.3 rc2

July 14th, 2009

Most of it now available in a debian/experimental near you.
Special thanks to George Kiagiadakis for doing much of the hard work. Also thanks to Martin Alfke.

I do now also claim that we have the best packaged and best working CLI bindings for Qt and KDE. Thanks to Mirco for polishing it.

KDE4.3 seems to have a bit more bling than kde 4.2, but there isn’t anything major I have noticed yet.

Some parts of kde4.3 is not yet packaged though, and might not happen until 4.3 final. Those vacation things you know.

Det er BLÅ SOMMER og vi ved her kommer alle med og dyrker et venskab der vil bestå

Linuxtag

June 24th, 2009

So. Now I’m almost prepared for linuxtag

  • Location: Berlin – check
  • Found a couch – check (thanks andreas)
  • Ticket – check
  • put in the debian booth schedule – check
  • Seen the venue – missing

That’s for tomorrow. see you there

Debian/KDE status

May 17th, 2009

So. Finally, we got KDE 4 series in Debian/Testing, more accurate, KDE4.2.2.
Thanks to the rest of the Debian/KDE team for working on this, including sitting on their hands when wanting to fix bugs, and a special thanks to the Debian Release team for making this happen.

(PS.: and we beat gnome 2.26 in making it first to testing)

Debian KDE bugs

April 21st, 2009

So. On Sunday, we worked through some of the bugs filed against KDE in Debian. Mostly, we cleaned up in old cruft, and a few bugs got forwarded.

A bunch of the Debian KDE people participated, and some KDE Bugsquad people also dropped by. And a special thanks goes to the apparant newcomer, Karl Ferdinand Ebert, for doing a fantastic work, and I also succeeded in getting Anne-Marie Mahfouf to take a look at the kdeedu reports.

We cleaned up in kdegraphics, kdeedu, kdeadmin and akregator reports, and did quite some work on the bug magnets of konqueror, kmail and kopete.

Total result was around 100 bugs down, and we discovered a few bugs that had hidden in between the others, that is actually packaging issues.
All in all a success, that definately should be repeated in a month or two.

playing with debian kde bugs – anyone up for it ?

April 17th, 2009

This sunday, the 19th of april, at 11 CEST, I will start work my way thru many open filed against KDE in the Debian Bug Tracking System that really belongs at bugs.kde.org – or just doesn’t apply anymore.

Feel free to join in in #debian-kde on irc.debian.org aka oftc.

See you there.