This application play sound and vibrate when new information is available. In this blog I will share code required to enable vibration support in Maemo application and I am using Qt framework to implement my application.
In Maemo, Vibration API is based on DBUS call, with proper DBUS call you can enable disable vibration and apply certain vibration pattern.
To be able to use DBUS api, Qt required to enable DBUS support, which can be done by putting this line "Qt += dbus" in to .pro file.
Now we can use DBUS API to enable and apply vibration. API are from following headers.
#include <QtDBus> #ifdef Q_WS_MAEMO_5 #include <mce mode-names.h> #include <mce dbus-names.h> #endifby sending MCE_ENABLE_VIBRATOR dbus call, we tell OS to enable vibration support.
void Sample::enableVibration() { #ifdef Q_WS_MAEMO_5 mDbusInterface = new QDBusInterface(MCE_SERVICE, MCE_REQUEST_PATH, MCE_REQUEST_IF, QDBusConnection::systemBus(), this); mDbusInterface->call(MCE_ENABLE_VIBRATOR); #endif }
Now that, vibration is enabled, we can apply certain vibration pattern. For my application is am enabling "PatternIncomingCall", After this call vibration will be on until we deactivate applied vibration patter.
void Sample::vibrate(int aTimeout) { #ifdef Q_WS_MAEMO_5 mDbusInterface->call(MCE_ACTIVATE_VIBRATOR_PATTERN, "PatternIncomingCall"); QTimer::singleShot(aTimeout,this,SLOT(stopVibration())); #endif }
And finally "MCE_DEACTIVATE_VIBRATOR_PATTERN" dbus call will deactivate vibration patter.
void Sample::stopVibration() { #ifdef Q_WS_MAEMO_5 mDbusInterface->call(MCE_DEACTIVATE_VIBRATOR_PATTERN, "PatternIncomingCall"); #endif }
So this was all that required to enable vibration support for Maemo application.