Extending the life of your N8x0: Update for Automatic Skype Launcher

I’ve just released the 0.0.2 version of Applications Fullscreener and Automatic Skype Launcher.

As I was already commenting in my previous post Extending the life of your N8x0: Automatic Skype Launcher, just download them and install them in your N8x0 for making it become a good 24/7 Skype phone.

The most important change for Applications Fullscreener is:

  • I’ve added a helper to launch a certain application and send the fullscreen key event some time afterwards.
    This is specially useful for launching an application through the DSME watchdog daemon in Maemo4.x. Using this helper as a wrapper, the application will receive the fullscreen event some time after being launched while the watchdog keeps track of the helper. In this case, if either the helper or the application dies, both die and, hence, the DSME will relaunch them both.

You can, also, check the complete ChangeLog for Applications Fullscreener.

The most important changes for Automatic Skype Launcher are:

  • I’ve added a Control Panel plugin for setting several behaviors of the application: starting an init service, using a watchdog for keeping it alive, trying to fullscreen Skype after launching it as a service and the time at which the service will be restarted, if so.

Automatic Skype Launcher Control Panel plugin snapshot

  • I’ve added a Home Desktop applet for making it easier to launch manually Skype, not having to get into the applications menu.

Automatic Skype Launcher Home Desktop applet snapshot

  • The Automatic Skype Launcher service was not stopping when the N8x0 was turned off while charging. Now this is corrected.
  • In the previous version, I added a cron.daily script to restart Skype (and the service). Actually, the N8x0 doesn’t have a cron daemon, by default. This is now corrected through the usage of an alarm triggered by the alarmd daemon.

You can, also, check the complete ChangeLog for Automatic Skype Launcher.

That’s it. Comments and patches are welcomed!

Extending the life of your N8x0: Automatic Skype Launcher

Leading quickly to the “ham”, just install Applications Fullscreener and Automatic Skype Launcher in your N8x0 and turn it into a Skype phone. Now, the long explanation 🙂

After working in Maemo and MeeGo for the last 5 years I’ve become the proud owner of a N810, a N900, a N950 (by now) and a N9. Obviosly, my old and beloved first maemo device, the N810, has been pushed into the background.

Thinking about how to still keep doing a good use of it, came to my mind the idea of turning it into a Skype phone. Nokia’s hardware is superb and the sound quality of the N810 makes it a good choice for this.

Still, I didn’t need another Skype phone myself but my parents, who have a lot of troubles for making use of Skype’s software in the computer, were the perfect candidates. Also, placing the N810 24/7 online side by side to their land line phone would let them receive and check at any moment for the availability of their regular Skype contacts. That’s it, my oldest’s brother family, who lives in Germany, and myself, who have already spent the last year and half in Finland and will be there, at least, for another six months.

Therefore, I copied all the remaining data out of the N810, cleaned the internal MMC and re-flashed the device with the latest available image and the needed flasher. Afterwards, and for having an easy way for maintaining the device, I upgraded to the OS2008 Feature upgrade and installed Skype, openssh and x11vnc packages. Also, I set the “Red Pill” mode in the Application Manager and added the following repositories:

~# cat /etc/apt/sources.list.d/hildon-application-manager.list
deb http://repository.maemo.org/extras-devel/ diablo free non-free
deb http://repository.maemo.org/ diablo/tools free
deb http://catalogue.tableteer.nokia.com/certified/ diablo user
deb http://catalogue.tableteer.nokia.com/non-certified/ diablo user
deb http://catalogue.tableteer.nokia.com/updates/diablo-2/ ./

In addition, after being able to ssh into the device, I installed the screen package.

Then, I set the connection manager to be connected to my parents WiFi automatically, without energy saving, with the smallest searching intervals, in case it would lose connection, and with unlimited inactivity time.

I modified the display settings for having the bright level, the bright timeout and the timeout for turning it off to the maximum, unchecked the option for blocking the display and keyboard on turning the display off, and set the display to not being permanently on ever. In the LEDs settings I left everything checked but when the device is on.

Because of the possibility of connecting with a bluetooth headset, I also set the bluetooth to be always on and visible.

Finally, I launched Skype and configured a new account for my parents.

The only thing left was to be able to launch Skype automatically at boot time and in fullscreen mode. As I said before, my parents are not really skilled on technology or gadgets use so the simplest approach would be to have a fully working Skype client just after booting and with no more distractions that the contacts list and the button for calling.

Automatic Skype Launcher Icon

I’ve developed the package skype-autolauncher for this task. This package would launch Skype automatically on boot time through a init script. Yes, I know it is not the cleanest way but it just works™ and other strategies are not much cleaner. The init script makes use of dsmetool to monitor the Skype instance so, if it crashes, or is closed by mistake, the application is relaunched. Also, this package adds a cron.daily task which will restart the service so it will also shut down and re-launch Skype for having fresh memory and a healthier running environment.

Automatic Skype Launcher’s code is kept in gitorious. For downloading the code, just type in a terminal:

$ git clone https://git.gitorious.org/skype-autolauncher/skype-autolauncher.git

Applications Fullscreener Icon

For the matter of automatically turning the launched Skype instance into fullscreen mode, I’ve also developed the package apps-fullscreener. This package sends a fake fullscreen hard key event to a XWindow by its process name.

Applications Fullscreener’s code is also kept in gitorious. For downloading the code, just type in a terminal:

$ git clone https://git.gitorious.org/apps-fullscreener/apps-fullscreener.git

That’s it. Comments and patches are welcomed!

Spam en el móvil

Web maligna www.visacarta.com

Esta no es la típica entrada alertando de cualquier chorrada en cadena, tal y como aconsejaba no propagar en «Netiquette en tu mail«. Esta es una entrada por un aviso real.

Tampoco es la primera vez que me llega un mensaje de este tipo, pero si es la primera vez que me decido a escribir sobre ello.

Hace un par de días me llegó un SMS a mi móvil español (Vodafone).

El remitente aparecía como «Importante». No sé como lo hicieron, pero ocultaron el número y aparecía como si ese fuera mi contacto en la libreta de direcciones.

El texto del mensaje era:

«Estimado cliente, su tarjeta visa ha sido bloqueada por su seguridad. Para desbloquear su tarjeta visite porfavor www.visacarta.com y complete los pasos

Es bastante obvio que era spam. De hecho, si visitas esa web, FireFox ya te avisa de que es una web maligna.

En resumen, si os llega un SMS de este tipo, ya sabéis que tenéis que borrarlo directamente y no hacerle caso.

QUrl (mis)usage: appendix, avoid automatic cast from QString

As I was introducing in the former entry QUrl (mis)usage, the direct creation of a QUrl from a QString should be avoided in any software that is not trying to smartly guess what a user input should lead to.

So, going directly to the ham, to avoid mistakes due to automatic conversions from QString to QUrl, I encourage the usage of the QT_NO_URL_CAST_FROM_STRING macro. The only thing you have to do is adding a line to your qmake project file like this:

# Avoid automatic casts from QString to QUrl. Dangerous!!!
DEFINES += QT_NO_URL_CAST_FROM_STRING

Or add it directly to the compilation line, like this

g++ ... -DQT_NO_URL_CAST_FROM_STRING ...

As I was pointing in my previous post, the usage of QUrl::fromLocalFile(QString) and QUrl::fromEncoded(QByteArray, QUrl::StrictMode) is recommended when dealing with QString and QUrl, but committing mistakes is a human condition so it is pretty easy to end passing a QString as a parameter to some API expecting a QUrl, or assigning a QString to a QUrl with the «=» operator through the C++ automatic cast mechanism which is implemented in the QUrl class. That’s why forbidding these automatic casts in our code is of such importantance.

QUrl (mis)usage

Lately, I’ve been developing some software which makes an intensive usage of QUrls as resource locators for local files. Nothing wrong here. QUrl is a powerful way of sharing the locations of those in an universal way. The problem is when you construct those QUrls from QStrings and you actually forget that QUrls are meant for much more than representing local file locations.

Authority chunks on an URL

Authority chunks on an URL

At the moment of writing this, QUrl documentation, although quite complete, could be much more explanatory. For example, it says that the recommended way for creating a QUrl from a QString is:


* When creating an URL QString from a QByteArray or a char*,
always use QString::fromUtf8().
* Favor the use of QUrl::fromEncoded() and QUrl::toEncoded()
instead of QUrl(string) and QUrl::toString() when converting
QUrl to/from string.

But this is explained in the documentation for QUrl::fromUserInput(), instead of in the Detailed Description [ 1 ].

What is important from this explanation is that it is not a matter of favor the use of QUrl::from/toEncoded() over QUrl::(from)toString() but, I would say, a must if you don’t want to end up with bogus corner cases.

Why would this happen? Well, as I was saying, QUrl is meant for much more than universally representing the location of a file so, here go the big tips:

  1. If you want to get the QUrl from a local file represented with a QString, use always QUrl::fromLocalFile ( const QString & localFile ) . Don’t use QUrl::QUrl ( const QString & url ) if you don’t want to end up with some problems. In the same way, get the path to the local file always with QUrl::toLocalFile().
  2. If you want to get a QUrl from a QString representing an URL, be sure that the QString is actually representing a percent encoded URL, as it should to be a valid URL, and always use QUrl::fromEncoded ( const QByteArray & input, ParsingMode parsingMode ), with QUrl::StrictMode as the QUrl::ParsingMode.
  3. If you want to get a QString representation of an URL from a QUrl use always QUrl::toEncoded ().

Bogus examples for each case:

Local file

/mypath/my#file.jpg

Correct:

QUrl myUrl = QUrl::fromLocalFile("/mypath/my#file.jpg")

Incorrect:

QUrl myUrl = QUrl("file:///mypath/my#file.jpg")

The problem here is the way QUrl will treat the «#» character in the second example. It will think, as it actually doesn’t have a way of guessing, that the character is delimiting the fragment part of the URL.

Fragment part on an URL

Fragment part on an URL

As a result, calling to:

myUrl.toLocalFile()

in the first case will result to:

/mypath/my#file.jpg

while in the second will be:

/mypath/my

Parsing mode

/mypath/my#file.jpg

(encoded) url representation:

file:///mypath/my%23file.jpg

Correct:

QUrl myUrl = QUrl::fromEncoded("file:///mypath/my%23file.jpg", QUrl::StrictMode)

Incorrect:

QUrl myUrl = QUrl::fromEncoded("file:///mypath/my%23file.jpg")

The problem here is the way QUrl will treat the «%23» encoding in the second example. Although it is not explicitly explained in the documentation [ 2 ], QUrl will use QUrl::TolerantMode as ParsingMode by default. Therefore, it will think that the input comes from an ignorant user which was actually trying to pass «file:///mypath/my#file.jpg». Again, it will understand after converting back «%23» to «#», that the character is delimiting the fragment part of the URL.

As a result, calling to:

myUrl.toLocalFile()

in the first case will result to:

/mypath/my#file.jpg

while in the second will be:

/mypath/my

Encoded usage

/mypath/my#file.jpg

(encoded) url representation:

file:///mypath/my%23file.jpg

(unencoded and wrong) url representation:

file:///mypath/my#file.jpg

Correct:

QUrl myUrl = QUrl::fromEncoded("file:///mypath/my%23file.jpg", QUrl::StrictMode)

Incorrect:

QUrl myUrl = QUrl("file:///mypath/my#file.jpg")

Here, we have another incarnation of the very same problem than the two examples above. QUrl will think, again, as it actually doesn’t have a way of guessing, that the character is delimiting the fragment part of the URL.

As a result, calling to:

myUrl.toLocalFile()

in the first case will result to:

/mypath/my#file.jpg

while in the second will be:

/mypath/my

Corollary:

The default behavior of QUrl is to provide an easy handling of URLs to the user of our programs, the end user, but not the user of QUrl, the developers. I find this quite awkward but, still, it is a decision of Qt people and, as developers, we only have to take this into account when writing our code.

These bogus URLs, which are to be corrected with the usage of the QUrl::TolerantMode ParsingMode, usually come from a text entry box «à là» browser location bar, but this use case is, actually, not so common when talking from the developer’s point of view. When dealing with URLs in our code we have to take into account what an URL is and how it should be formatted/encoded to be valid. Therefore, if I’m receiving a wrongly encoded URL I should go to the source code providing this URL and fix the problem there rather than trying to smartly guess which should be the proper URL. For example, in my software currently in development we use Tracker and I rely on it to feed my code with properly formatted URLs. If for some reason Tracker gives me a wrongly encoded one, the place for solving it is, actually, Tracker, and not my software. I should not and must not interpret what Tracker may have wanted to pass me, but open a bug in its bugzilla and provide as accurate information as I can to help them solve this issue.

Just so my friend Iván Frade doesn’t kill me, make notice that Tracker is, so far, perfectly dealing with URLs 🙂

«maemizing» GUADEMY

This weekend GUAdemy, a mixed conference between GUADEC and Akademy, lands in Coruña. As in most of Gnome related events, Igalia is going to be there.

For me, I’m going to give a talk about maemo on Saturday afternoon, as Miguel, Chema, Susana, Iago and Sergio are going to give other talks about several Gnome related issues.

If you want to learn about the Gtk based environment for embedded devices created by Nokia, come and join us.

See you soon!