Tuesday, October 21, 2008

Tata Wimax keepalive

My tata wimax connection works well most of the time but it has a supremely annoying feature that to get connected, one is redirected to login in their login site (pretty much how the internet connection works in many hotels). If you are idle for sometime, it will auto logoff. Since my internet connection is not so fast, I usually download over the night and open a keepalive window.

This worked well up until a couple of months back. Now they seem to have decided to disconnect users at random times regardless of internet activity. Not to be deterred by the challenge, I started thinking of how to work around this. The login screen looks like this:



I needed something that keeps logging me in automatically. Qt/WebKit was the obvious choice. It would have been trivial had the post URL of the above form not been dynamic (i.e it has a magic session number in the POST url).

So, here's what I had to do:
1. Keep loading some website at periodic intervals. Check if I get redirected to their login page. It was a bit tricky to use Qt/WebKit to detect a redirect (in fact, there are two redirects); one has to resort to using timers and check if all the redirection has been done and the pages have been completely loaded.

2. Once the page is loaded I need to get the "dynamic" post URL of the form. I could do a grep in the html but that would be too simple :-) So, I tried evaluateJavaScript that will look in the DOM and return me the post url. Unfortunately, the QVariant returned by evaluateJavaScript() is always null. So, the next strategy was to fill the form details and submit the form entirely using JavaScript. And that worked like a charm :-)

You can find the git repo here (btw, Assembla rocks!).

It struck me later that I probably didn't need Qt WebKit at all. I think a html/js loading a website periodically in a separate frame and trying to logon if necessary could have worked as well.

Monday, October 6, 2008

KWord: ODF Lists

It's been a long busy month. With the impending 2.0 release, I have been hacking away polishing up ODF list support for KWord.

Here's a list of improvements coming up

  • Support for saving and loading ODF text:list. This was a lot of work. ODF lists are complex beasts. It was major help that Thomas Zander had done a lot of work in supporting lists and numbering of lists in the layout. We now support the important ODF 1.1 list attributes like space-after, min-label-distance, text-align, min-label-width
  • Support for editing lists and sublists, similar to OOo and MS Word. Press tab to increase the indentation level. Press Backtab to decrease the level
  • Support for loading and saving lists as numbered-paragarph. This means that documents written with KWord 1.x can be loaded up with 2.0. However, KWord does not save as numbered-paragraph because neither OOo nor KWord 1.x can load it correctly (KWord 1.x seems to use the optional text:number tag to determine numbering).
  • Support for list headers
  • Support for unnumbered paragraphs. In ODF, a list-item can contain multiple paragraphs. As a result, the first backspace that you press at the beginning of a list-item makes the paragraph an "unnumbered paragraph". The second backspace ends the list.
  • Quirks to make lists behave the save just like OOo. OOo seems to make a few assumptions that are not stated in the spec - Two disjoint text:lists that follow the same list style are considered to be one list (this affects numbering and that changing the style of one list changes the other). For better or worse, we go out of the way to mimic OOo here.


Here's a screenshot:



Non-list changes
  • Fixed whitespace normalization. See 853298 for details.
  • Switched the default template to odt!
  • Lots of refactoring, cleanup and redesign.