USSD widget

One of most annoying things in N900 is lack of USSD queries. They are mostly used for activating different services and displaying information, for example about balance, minutes or text messages left. In Russia most part of contracts are prepaid, so balance information is essential. Ability to see your balance on desktop can be useful in such case. USSD widget was developed to solve this problem.

What does it look like

Feature list:
  • Multiple instances support
  • Customizable colors and fonts
  • Allows to preprocess operators replies
  • Non-blocking queries
  • Localization support (russian localization available)
  • Scheduled renew and retry on error support
  • Automatic resizing
You can get this widgets from extras-devel repository.

Workflow

Widget may be triggered by finger tapping, renew timer or by retry timer. USSD query is sent to operator and then two thing can happen:
  • You are lucky and operator responded to you. Then reply would be parsed by regular expression (if specified) and matched part would be used further. This part is being sent to parsers and chain. This are programs, which can somehow react to USSD response
    • Parser should process reply and print to stdout string, that should be shown. You can use it for custom reply processing. There are two parsers: one for text, shown on widget, another for text shown on banner (yellow strip across the screen)
    • Chain can do anything you want. My intention is to use it for logging and statistics gathering, but I hadn't written appropriate programs yet.
  • An error happened during the query. Widget would show "Error" for 5 seconds, border would turn red and retry timer would be launched (if retry pattern is specified).

Settings

USSD-widget has many settings because I wanted to make it universal. This means, that for basic usage you won't need to change most of them. You definitely have to enter USSD number, you may need to enter regular expression. You may wish to enter retry pattern and renew interval. Anyway, all settings have self-explanatory names or big button with "?" sign, which would bring help dialog.

How to cut of SPAM, how regexsps can help?

Many operators append SPAM to required information. There are two ways for cutting SPAM: simple and universal. The simple way is to use regular expression to describe useful part of the reply. For example
(.+?[\\d\\,\\.]+)
means everything before first occurrence of a number (with optional decimal part). Suits in most of cases for balance reports. Other examples (provided by users, I didn't check them):
Russia, Megafon: (Баланс \d+\.\d+руб\.)
Italy, Wind: .*(\d+\.\d+).*euro.*
Ewerything before letter б (from word "руб", Russian currency) and a dot after it: (.+?б\.)
Vodafone: .+?([0-9\.]+EUR)
When composing expression don't forget, that balance can be negative. My operator adds word "minus" before sum. If your expression takes only digits you won't be able to distinguish negative balance from positive.

How to show widget name all the time?

Use parser command. For example using
echo "1st number"
as a parser would show "1st number" string on widget.
echo "name: %"
would show "name: ".
Parsers for widget and for banner are defined separately, so you can show different strings on them. If widget is used for service activation you can show service name on the widget and operators reply on banner. Or you may wish add widget name to banner to know, that information on it origins from your mobile operator.

How to execute several commands in parser

Widget itself can execute only one command. But you can write bash (or any other) script which will execute several commands and configure widget to launch the script.

What should I do if the widget doesn't work?

Open X-terminal and launch it from there:
python /usr/lib/hildon-desktop/ussd-widget.py
Now all debug information would go to console. But you have to configure new instance of widget. If you want to use settings from existing widget you should specify it's nimber at the end of the command. For example:
python /usr/lib/hildon-desktop/ussd-widget.py 0
would take settings from the first widget, added to desktop in usual way.

SMS handling and usage of regular expressions with handlers

Theese features were added in 0.1.6 and are described in changelog.

Comments

Size wrong

using it with PR1.2 (didn't use before) and the size is "wrong". the widget spans over a big rectangular area (to the right) and is transparent there (besides two or sometimes one vertical line that has the color of the widgets border). it is clickable in the transparent area.

As far as I know, all

As far as I know, all resizeable widgets behave like this. I'm not sure, that there is an easy solution for this.

Problem starting widget

Hi,
When trying to add widget to desktop nothing happens.
When tried to launch from terminal with: python /usr/lib/hildon-desktop/ussd-widget.py
I got the following messages:
Translation file for your language not found
IO error while reading config
Sintax error in USSD number.
What should I do?

I think, that this is related

I think, that this is related to this issue:
http://maemo.org/community/maemo-developers/hildon-desktop-added_widget_...
So try rebooting your device. And search for widget on all desktops.

not working

i flashed my phone using the flasher, before flashing everything was ok ussd was working, but after the new installation i cannot see the ussd widget on desktop. i tried to restart, re-install the ussd widget and the OS but still i can't use it

any ideas?

Search for "What should I do

Search for "What should I do if the widget doesn't work?" on this page.

I rebooted the device (for

I rebooted the device (for some other reason) and the widget appeared (even around 7 (how many times I tried "add widget") instances of it on my desktop :) )
So - the reboot was needed. Now it is working fine.
Thanks

Germany, Tschibo / O2:

Germany, Tschibo / O2: (.+?[\d\.]+)

What if I need to dial *556#

Thats all i need to do. dial *556# to check my credit level
and *555*123456789012# to load credit

i have loaded the widget and i see it on my desktop.

Im expecting to define or send some parameters to the widget so as to access these features from my network

Any advice......

--if we dont solve this , then we cant use our N900 in south africa during world cup ") ------

Tope

You can configure it as any

You can configure it as any other widget. Go to layout mode (click on spare space on desktop, then gear in right top corner), click on wrench icon on widget. You would get configure dialog.

Tried the python commands and

Tried the python commands and the also dont work.:

import dbus
Import Error: No module named dbus

Please help.

i get thesame error message

i get thesame error message as above. can u help with detailed steps of how to resolve this.

Do you have the latest

Do you have the latest version installed?

There is unmet dependency,

There is unmet dependency, which I've forgot to add to package. You have to install it manually:
sudo gainroot
apt-get install python-dbus