#26: GSoC with KDE Now – 4

Hey ! I’m making KDE Now, an application for the Plasma Desktop. It would help the user see important stuff from his email, on a plasmoid. It’s similar to what Google Now does on Android. To know more, click here


In the past week, I worked on the code reviews I got. Hence, I changed the classes’ design all over. The way it works now, is that there is a central dispatcher, the daemon, that handles all the jobs. I chose this design, since it was how originally KIMAP jobs, was supposed to be managed. My mentor and Daniel Vratil helped me in deciding this.

I previously said, that I’d change the update to a new thread. That might not have been entirely true 😉 . From what I know, IDLE is an async process, so there might be some actual lag there. I’ll add this in my TODO during the time I test everything and just move to other things on my list.

The IMAP client was looking good, so I started to implement a parser. Now I must say, this took more time than I expected. I was adamant at using Qt JSON library which is pretty good for parsing JSON. But to parse that JSON, the first thing is that I need JSON data. I looked through the docs. Nothing seemed good enough. QtWebKit seemed overkill. Of course, me and my mentor were against using it. There’s no GUI in our application, and using it would have been a waste of precious resources. I checked some other 3’rd party C++ libraries like SGML for Qt, Gumbo Parser by Google but nothing seemed appropriate. SGML was a bit (well more) on the slower side. Gumbo seemed good at first, but since it was 3rd party, I was worried. Maybe some things about license too. I didn’t feel like adding a dependency. Finally I settled for regex (No Wait. Whattt ? I know ? Before you all charge at me, I didn’t use it). Yeah, so I settled for regex. I contacted my mentor and Dan, and they were against it (Well me too, but what choice did I have ?). To those of you, who still think, it would have been okay to use regexes, read this. Dan told me to use QXmlStreamReader. My initial reaction was whattt ? How can I parse HTML with an XML parser ? Hence I never even googled about it. On a second thought though, HTML if formatted nicely, is just plain XML. (Now do you get it ? Just the tags !). I tested it with my IMAP client. Everything seemed good. It’s fast and reliable. It’s also in the QtCore module. So, Speed; check. Reliability; check. No added dependencies;check. What else could I have asked for (A tank ?). So, now I had data between those script tags in HTML, after I parsed it through QXmlStreamReader. Next I parsed this data using Qt JSON Library (QJsonDocument, QJsonArrayQJsonObject). I store the required data in Maps. With the power and consistency of QVariant(Map) things became quite easy.

I got code reviews from my mentor. We discussed some stuff for the next stages.In the next part, I’ll perfect the extractors I have written. Implement them as plugins and load these plugins in the client. This will make writing extractors for other schemas and hence adding support very easy. I’ll also be working with a database (SQLite) to cache the fetched emails. One of the things, I noticed just now, is that I’m using the Incremental methodology of Software Engineering. I am adding new features one by one. Building and testing at each step. Never thought, I’d see the impact of the course classes this early 😉

See you later.


#25: Summers !

I had my last exam on the 27th of May. And with that, I bid adieu to my sophomore year. Now when I look back, things seem to have flown past. Just the other day, I was excited about starting another year at college, and here I am writing about it’s end. Life sure moves fast, mate.

Last year (or academic session) was a mix bag. We had some good courses, and some not so good ones. (Yes, Microprocessors and Computer Arch, I’m referring to you). Well, in my opinion at least.

I’m happy that finally my exams came to an end. It goes on for a fucking month. Well roughly. We have our Minors – 2, that takes about  a week. Then practicals for another week. Then about 14-15 days for the University exams. I meant every word of it, when I posted the following on my Facebook wall when my exams ended.

Walk into your house like, when the semester ends!


My University exams went fine. No that I expect something like a 9 CGPA, but anything close to 8 will do.

I haven’t had much time to blog about anything except my updates with the Google Summer of Code this year. It has been keeping me busy lately. I wonder how things are gonna roll, when the next semester starts. Which reminds me, the last two semesters were awful in terms of schedules. All week, our classes used to end at 5 pm. That makes it kind of a 9-5 job 😛 . Last semester, our labs were 3 hours long. I mean, can you even believe it ? And all we had to do in those 3 hours, was perform just a single experiment. Terrible waste of time. An hour would have been more than enough. As a result, we were exhausted when finally reached hostel at about 6 pm. Then the assignments, lab work, etc took another couple of hours. No wonder, things seemed to have moved very fast ! I kind of cringe at the thought, that even now if it’s getting difficult to take out time for hobbies, what will happen when we’ll be working ?

I’m about 12-13 days in my summer vacations. I have a shitload of things going on. About a month more remains. I need to pull my socks up. And not sit around random subreddits !!! As expected, I’ve been keenly following Game of Thrones. It’s already 7 episodes down. (What ? 7 weeks ? How ?) Yeah. Just the other day, I bunked a lecture to watch the first episode with my friend. I will watch it all, one day when this season ends. 10 hours straight.

With that I end my blog(rant ?)

See you later

#24: GSoC with KDE Now – 3

Hey ! I’m making KDE Now, an application for the Plasma Desktop. It would help the user see important stuff from his email, on a plasmoid. It’s similar to what Google Now does on Android. To know more, click here


It’s been some time since the coding period started for this year’s Summer of Code. I had exams till 27th of May, so I started from 28th. My mentor knew about it already, so things went buttery smooth.

As the first part of my project, I had to implement an IMAP client for fetching emails from an IMAP server. I used KIMAP library in the process. With the help of my mentor and Daniel Vratil and Luca Beltrame, I implemented a working IMAP client. Daniel and Luca helped me with the API details, since the one available was lacking some of the details. Still, most of the methods were fine. The only minor issue related to the API was a specific function overloading in KIMAP::FetchJob. The new Qt signal/slot mechanism is good and all, but since it does static checking, we need to specify the exact methods. In this particular case, to resolve ambiguity, we need to cast it. Which looks not very beautiful. Hence, Qt recommends not to use function overloading.

There are a lot of details based  on how the whole thing runs. One can look at the commits, I made which are a lot more detailed. But the basic idea is: Start a client session, fetch relevant emails, and go into a laid back state. When the server receives a new email, it notifies our client that a new email has arrived. Our client then fetches the new emails. For future plans, I might as well incorporate information from these commits into docs.

For the coming few weeks, I plan to move the update procedure of the client to a different thread, as when I was writing a processor today, to process the newly fetched emails, I noticed some lag. For this, I will use QThread. I’m kinda amused that I didn’t think of this happening before !

Testing the client took time more than I expected. Actually, I tested the whole thing.I exchanged some 60 emails for this purpose. I plan to write unit tests later (in the final stages, which is like 2 months away).

This is the first time, I’m making a project like this from scratch and it has been a great learning experience till now. I plan to get my current code reviewed by some more people, before I am finally satisfied with it. I’d like to get tips on how to better refactor it, and any general tips for the code/classes design are welcome. Find the repo here.

Things are in pretty good shape. I plan to write extractors in the coming weeks and getting code reviews 🙂 I’m actually a bit ahead from my proposed timeline which was altered due to some changes. That gives me even more time later to work on docs and testing.

Catch you in the next one !