Friday, November 27, 2009

My summer of code journey [part4]

The final evaluation!

Assuming that i was done with my history plugin, i told my mentor to review it, and also mailed the kopete-devel community so that if there are any developers with some spare time can review it as well, and went to prepare for my exams. I tried to make sure that during my exams that i stay in touch with my mentor and and project doesn't suffer because of it.
I got a reply from Oliver Goffart(author of the history plugin of kopete) stating that, 1) i have used lots of kdebugs, 2) my error checking was not proper 3) and most of the jobs i had used were synchronous job->exec() and it would be a good idea to redesign the plugin and use asynchronous jobs where ever possible.
Later that day krake also told me about his experience that he had lots of crashes while he was writing a plugin because of job->exec() and it is always a good idea to use asynchronous jobs, So i added a new todo in my list which was to make all jobs asynchronous. This job turned out to me more than what i had imagined. The history plugin uses QDomDocument and every method in there had sequential execution so i had to split a method in two parts(some method like readMessage into 4-5 parts) and introduce new variable, make them member of class so that they can be used in other parts of methods as well, overall it was very hard for me to change all akonadi related things into asynchronous jobs. The toughest thing i faced in my Google summer of code. 
The design of the plugin is something like this. Kopete has a messageHandler chain, so whenever a new message arrives, the messages flows through the message handler chain, so when history plugins message handler method gets invoked, the history plugin object creates a historylogger object. Two important functions of historylogger are the appendMessages and readMessages. When a new message arrives and the appendmessage method is called which saves that chat into akonadi. In the constructor of the HistoryPlugin we also connect a slot to slotViewCreated so whenever a new windows is created the readMessage method is called which reads a specified number of lines from the chat history and appends it to your chat windows.
So basically all the tough work was about making the readMessages and appendMessages asynchronous.

That took me some 20 days! :-( I was almost like doing everything again. 
But i got it working somehow! :) and trust me it was a nightmare. But the good thing was that I had my holidays and i was able to devote all time to it! :-)
After doing with my history plugin, I started with my telepathyWatcher application. The telepathy watcher is an Telepathy client application(basically an telepathy observer) that logs all the text chats that you do using the Telepahy Protocol into Akonadi, using the same collections that are used by kopete.
I cleared my final evaluation, but I am not satisfied with the history plugin. I want to make the kopete history plugin better in terms of searching through logs, and give it a better UI and looks.

If you are interested in knowing more about telepathy you can find a good tutorial about telepathy here
I will blog about the Telepathy-Watcher later, let me first put forward some of my confusions.
1)When kopete starts, I need to fetch collections from the akonadi, so that they can be made available to plugin.
At the moment when the plugins starts, i do a fetch job that fetches all the collections from Akonadi server. 
--> what pings me is that, I am fetching collection everytime kopete starts. No doubt it works but Is this the right approach??
2)When the plugin initializes, a good idea is to fetchItem with headers, so that in order to get information about a particular contact, we dont need to fetch items from akonadi. This looks like a good approach to me. 
But my doubt is, i have some 150 people in my contact list(with just 1 email id) and i dont talk to all of them everytime i start kopete, and I assume many all around the globe at one point of time, use more than one Account to log into kopete, so suppose they have 4 accounts, then i will be fetching some 500(approximated) item Headers from Akonadi. Will that be okay ???
Or a better idea can be something like, as soon as they come online i fetch their item headers?

3) Will it be better that kopete and the kopete-akonadi-history resource share a config, so that it improves performance?

1 comment:

  1. If you could write it in english, maybe i can understand something!