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, QJsonArray, QJsonObject). 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.