Friday, December 19, 2008

The Hyves Photo Uploader

A new desktop client for Hyves, the top social networker in The Netherlands, was out yesterday as beta (paid members only, for now). It's a chat client, blog/media/event notifier and photo uploader all rolled into one. Girish and self have been working on the photo uploader part of it for over a month now (half of that time in a cold, wet and absolutely charming place called Amsterdam), with oodles of help from Arend and Boud, and it's looking all neat and slick now. Works on Windows, Mac and Linux. Written using Qt/C++, Javascript and the public hyves api .
On the same topic: Boud's blog , Official blog (in english)

(Are we anti-social or what? Hyves is the first social networking site I joined, and only when we started working on this (same case with Girish, I bet), and I have a grand total of 5 friends (one of them being myself with another username). Another case Boris in the making? :D)

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.

Thursday, August 21, 2008

N810 is awesome

I have been using the N810 for a week now. It's plain awesome - its decently fast and most importantly things just work. The feel of the device is so good compared to my pricy 6110 S60 crap. I am really hoping Nokia will release a maemo based image for 6110 someday.

My previous experience with Nokia (device) development was with S60/Symbian which was just plain depressing. The Carbide would keep crapping out at the most inappropriate moments, the final product behaves differently than the simulator, the... Ah, I should stop here, I love bitching about S60 and Symbian. And I can do it forever :-)

So with some trepidation, yesterday I decided to get my N810 setup for development. It was so simple that I was sure I was missing something. Qt Hello World was up and running in short time. I wrote a small tutorial on how to get Qt installed on maemo.

Immediate thoughts: Maemo looks like a very hacker friendly platform. A big thing for me is that compared to the S60, I actually want to write apps for the N810.

Next Stop - Getting KOffice running.

Wednesday, August 6, 2008

Akademy


BESCOM willing, I hope to finish the slides for my talk by tomorrow night.

Tuesday, August 5, 2008

Looking for a maintainer for KDocker

Standard excuse - I have no time. I am looking for maintainer(s) for KDocker. Unlike it's name suggests, it's not a KDE application, it's plain Qt 3.

Over the years (literally), I have just ignored bugs, feature requests, patches from many (~100) people. Today, I got a mail from Peter Toushkov with updated bulgarian translations. IIRC, there are two new language translations archived somewhere in my gmail account. I feel very bad about all the effort put in by these people go waste. I should have written this maybe a year back, but better late than never.

Why would you want to work on it?
- You get to learn a lot of Qt and X11 . In fact, this knowledge is what helped me write QSystemTrayIcon at TT :). Some of the code in there is quite hard to get right on all WM.
- Actually, there is no maintanence work. The first task would probably be to rewrite everything in Qt4 using QSystemTrayIcon and still call the new code kdocker.
- Many people have mailed me with lots of innovative ideas which would be nice to implement.

Contact me, if you are interested.

Monday, July 7, 2008

ODF editing/saving in KWord

As promised in my previous blog post, I have written a couple of tutorials explaining how ODF document editing/saving works in KWord.

Editing ODF

Saving ODF

As before, please feel free to fix it, if you find something obviously wrong. I have to also point out that I wrote the articles primarily so I can help understand the code; I haven't put in a lot of effort into spell checking, grammar, structure. Feel free to fix the style/language too.

Exercise: Spot the bug in KoTextShapeData::saveOdf() . It is the reason why styles aren't saved when a ODF document is saved in KWord. I am fixing just that, btw :-)

Friday, July 4, 2008

KOffice Alpha 8

Thomas Zander pointed out to me sometime back that my name got mentioned in the link on Slashdot. I thought "Wow, that's so cool. My first time on the dot. I mean now that I am famous and all, I can sell signed merchandise at akademy :-)".

I read the techworld article and it said "Among the technology developments are improvements to the OpenDocument format, particularly the text shape that is the base of KWord thanks to the full-time work of the NLNet-sponsored Girish Ramakrishnan".

It's easy to misread that. I am sure glad that my contributions have been noticed but I wanted to put in a word for the others. It is indeed true that I made improvements but I have to point out that they are minor compared to huge (read: massive) chunk of code that was already there. I mean, hey, I just started 2 months ago and people have been working on this for years :-).

So, thanks and congrats to the entire team for KOffice Alpha 8!

Thursday, June 26, 2008

Getting started with KWord Development

About 2 months ago, I started working on KWord ODF support. Getting productive working on KWord is no mean task - apart from the mandatory C++/Qt knowledge, one need to know Scribe, KDE, KOffice libs and KWord. I knew only C++/Qt and basic Scribe.

Thankfully, to add small ODF features to KWord, one can conveniently ignore most of the code base and concentrate on 4-5 files. Which is what I have been doing - committing like crazy to 4-5 files :-) Of course, I have never been at ease with this, I usually don't develop this way but I wanted to have something up and running asap. Now that we (Roop and I) have most of the (supported) ODF test automated (63 in all), I took a 1 week break to read and understand the KWord/KOffice code.

If writing a word processor is not complex enough, KOffice/KWord code is extremely complex thanks to all the code sharing between the koffice applications, libraries, plugins/flake, kparts. So, I thought I should do something on my part to make KWord more approachable to a newbie. The result is:

http://wiki.koffice.org/index.php?title=KWord/Tutorials/LoadingOdf

It's a code walk through/very detailed introduction to how loading of ODF works in KWord. I have deliberately opted for simplicity over correctness in many places. Some information there might be outright wrong, in which case, please edit the document and fix it (hey, I am new to this stuff too). Also, this probably belongs in techbase.

Writing this document has made me realize that writing code is so much simpler than understanding existing code :-)

Anyhoo, Comments/Suggestions?

P.S: I am in the process of writing the SavingOdf document.

Saturday, June 7, 2008

Drop caps

Last week saw the introduction of a brand new feature in KWord: crap drops. Er, I mean, drop caps. You can specify how many lines it should span, how many characters to drop, and even the extent of horizontal gap between the dropped chars and the rest of the paragraph (all only through the odf file, for now). But if if you ask me, I just like the plain old three-line single character drop char (thanks, Thomas, for the screenshot).

dropcaps screeny

Compared to Word 2007 and OpenOffice 2.3, it works pretty much the same usual way in, er, usual circumstances. But in subnormal scenarios, like for example, when the paragraph doesn't have as many lines as how many lines the drop cap spans, or in the case where the paragraph has a mix of quirkily extreme font sizes, all three word processors behave differently, and somehow, I can't point to any of them and say that's outright wrong. So, if you have any inputs on how KWord's drop caps behaves or should behave in certain situations, please leave a comment or mail me.

Now for the how-stuff-works part. What I've done is, create a separate new line for the set of dropped characters (setNumColumns), and increase their font size on the layout by the number of vertical lines they should span (setAdditionalFormats). Then it's only a matter of shifting out a few subsequent lines horizontally without changing their vertical positioning (setPosition) and reducing their width to accommodate the dropped characters abreast of these lines. That, in brief, is about it. Mostly.
Sample odts: dropCapsLines.odt, dropCapsLength.odt, dropCapsDistance.odt

Friday, May 30, 2008

KOffice can strike out anything

We added a feature in KWord yesterday that lets you strike-out a text, like "wrong word" with any custom text, like "x" or "---x---" instead of the boring "wrong word" style (example odt). You can also use any custom text to fill the whitespace created by a tab (example odt). Rather advanced text editing, I'd say. And it turns out that it you can get it to create some rather funky patterns.


The one on the top is done with 'o's struck-out with with 'O's. And the next one has '/'s struck-out with '| - '. These strings can be specified in an ODT file and read in, but as yet there's no interface in KWord to create such a document directly.

Now that we have this, if there's any artist making ASCII art who wants an alpha channel in his "images", KWord will be his tool of choice. :)

Wednesday, May 21, 2008

Accessing QtScript arrays from C++

Roop was wondering how to access an (QScript) array from C++. I spent sometime trying to figure how to do that, so I thought I will let the world know.

A search on the QScriptValue documentation page yields QScriptValue::isArray(). We can use that to determine if the value is an array or not. Unfortunately, it doesn't really state there how to access contents of the array. My initial reaction was to just convert the value to a QVariant (using toVariant()) and then convert the variant to a QVariantList (toList()). That didn't quite work.

The answer lies in understanding arrays and objects in EcmaScript - Everything is an object. Every object is really a map from properties to values. What that means is that an EcmaScript array is just an object. And the values you put into it are just properties of the array. The [] syntax is EcmaScript is just to make us feel at home and make us believe you are working with arrays and not some fancy objects. So,

array[1] = "foo"; // creates property named "1" with value "foo"

With that revelation, you should be able to find QScriptValue::property(). Just pass the values 0, 1, 2 and so on as arrayIndex and you should receive the values. But, what about the length of the array? Remember, everything is a property in an object. The length is stored in the length property of the array which you can query using the other QScriptValue::property() overload.

P.S 1:
Note that, array indices are not limited to integers (it is a map). So, the below is perfectly fine.

array["one"] = "foo;

I can imagine it to be common to inspect all the properties of an object. You can use QScriptValueIterator for that.


P.S 2:
array[1] is the same thing as array["1"]. The keys in EcmaScript maps are strings.

Update
Roop found a much much easier way to process arrays: qScriptValueToSequence

Saturday, May 17, 2008

38

So, we are at 38 testcases now. After the initial burst, progress has been slow. This was expected because most of the remaining testcases are yet to be implemented in KWord.

Among other news, I made an announcement on the koffice-devel list about the progress. Pinaraf and dipesh who are actively working on adding other ODF features to KWord, had some trouble getting the tests up and running. As a result, I added a README and STATUS file to ease things up. If you are working on anything related to ODF support, give the test suite a shot. It is invaluable when it comes to regression testing.

Wednesday, May 14, 2008

KWord ODF Support

It's been over a month now since Roop and I started working on getting the ODF support in KWord upto shape (Our work is sponsored by the NLNet foundation). To give us direction in pursuit of that holy grail, we started out automating the test suite at OpenDocument Fellowship.

We decided that we would take the tests one by one, make them work in KWord and then commit the test to the KWord repository.

Writing each test is quite a tedious task:

  • Read the specification for the feature. As all specs go, it leaves some details to the imagination of the reader.
  • The test case itself is then analyzed for correctness.
  • We then run the test in KWord and check if it works as expected.
  • If it does not work as expected, we fix KWord. This is the fun part :-)
  • Once the functionality is added/fixed in KWord, we finally get around to automating the testcase. We have a framework that compares the document (QTextDocument) created by a script (QtScript) and the document created by KWord. So, all we have to do to automate the test case is to write a QtScript that generates the expected document.
As it stands, out of a total of 160 test cases, 33 have been automated. So, thats 33 completely working ODF text features in KWord! Not bad for a month, eh? We have been a bit low this month though thanks to my super flaky internet connection (Tata Wimax, a big rant on this later) and Roop being occupied with getting the website up and running.

You can browse the test suite online here: http://websvn.kde.org/trunk/koffice/libs/kotext/opendocument/tests/

Monday, May 5, 2008

And we're on

We launched our website today, a bit under three months since we founded ForwardBias Technologies. While that might be considered a rather long period of sitelessness, on the brighter side, we've been busy. We're onto the endgame of building Spambin, our spam-blocking software for mobile phones (you can register here for beta). And we're neck deep into improving ODF support for KWord 2.0, supported by NLNet Foundation. Girish has been involved in a slew of other Qt-related projects as well.

On the more mundane admin side, we're now, well, a company, officially speaking. One with a consulting agreement with Trolltech for offering Qt services and a developer certificate from Symbian for distributing S60 software.

So, there. We're on.
QED. :)