Reply to comment

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.

Reply

  • Web page addresses and e-mail addresses turn into links automatically.
  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd>
  • Lines and paragraphs break automatically.
  • You can enable syntax highlighting of source code with the following tags: <code>, <blockcode>, <c>, <cpp>, <drupal5>, <drupal6>, <java>, <javascript>, <php>, <python>, <ruby>. The supported tag styles are: <foo>, [foo].

More information about formatting options

CAPTCHA
This question is for testing whether you are a human visitor and to prevent automated spam submissions.
Image CAPTCHA
Enter the characters shown in the image.