OnSwipe redirect code

Showing posts with label GSoC. Show all posts
Showing posts with label GSoC. Show all posts

Thursday, October 25, 2007

First check-in of my code into Mozilla codebase

This was a long awaited post, not by the readers waiting to read this but by me, the author, waiting to write this. This is by far the most important blog post written by me, not for its content but for the moment it describes.
In a previous post titled "My GSoC 2007 Story" I wrote about how excited I was about this association with Mozilla and about the opportunity to fulfill my long lasting dream of contributing to open source and having credit for some notable software development. But that just the beginning of the fulfillment of the big dream. The way was just shown to me and I was given the map just having the end points of the journey. It was up to me to figure out the way and reach the destination after crossing all the hurdles. I am now proud that I could stand the journey and complete it. This post is the proof and the reward together.

The journey was of course not smooth as described in my "First Mozilla journey" post. But it was worth it. Now about the day I achieved it. It was 5th Sep 2007, yes Teacher's day here in India. (I guess I should really be thanking my teachers for their teachings as well as blessings). That was when Shawn(sdwilsh) checked in my patch, of course with certain changes to it from him. Here is the check-in comment.

The end was more tiring and hectic than I initially assumed. My feature was initially targeted for M7, but then due to delay from my side it was re-targeted to M8. Since this was considerably big thing and involved quite a bit of risk the drivers decided that this feature would be in only if it can come in by M8. Things were going pretty well with me working till 10 or 10:30 at the office due to lack of internet connection at home. I used to get a new patch every alternate day or at least hit a dead-end and wait for help from biesi/dmose/sdwilsh or some other person. I ended up adding more stuff to nsDownloadManager class than I thought I would be doing. Every week more than 2 or 3 times I used to discard some done stuff and redo it in different way. This was mainly because of my lack of XPCOM knowledge. Though I was very determined to get it in FF3 it was getting heavier and heavier for me. Thank God, I finally submitted a patch which addressed all the issues mentioned in the comments earlier.

It was all working and just a few hours (that was 10:30pm here and I had to go home - by bus) before the tree was to close for M8 I figured out that nsIFile.GetSize() was not returning the proper value because of which downlaods were getting corrupted and were of sizes more than the source files. The solution turned out that I had to clone the file to avoid the cached values. This required some effort and I postponed it to next day morning hoping to get it done before the tree closed. Though dmose told me to do it right away so that a review can be done that day itself and the patch would go in. But it was too late for me and I just left the office against all my wishes to stay overnight and work with those guys struggling in US. All the way to home I was cursing myself as I was not confident of getting it done in couple of hours and hence I might lead to this feature being dropped from FF3. That would have been like a big blow to me as I had widely publicized this among many of my friends.

The scene on the other end was also pretty similar. sdwilsh and Mardak spent almost the whole debugging my patch and figuring out what was happening. dmose had mentioned earlier itself that the management wanted this feature though it was not in the FF3 PRD. Lots of people had already blogged about this feature in FF3 and hence it was very critical. They finally figured out that the "http referrer" was also needed for resume to work properly and they added that also to the DB and sdwilsh came up with a new patch and probably got it reviewed by Mano.

When I came back in the morning the new patch was ready and the whole of mozilla team worldwide was active as lots of check-ins were to be done before midnight. sdwilsh finally got mconnor to review the patch. Since it was patch which was r+ by sdwilsh, mconnor could not find any flaw except for a comment about the file cloning to be made more clear. It was finally made and sdwilsh told me that he would be checking in that patch. I was very much excited and I had every right to be. After 3 months of work, several night outs discussing stuff with my US counterparts and much other effort had gone into bringing out the code in that patch. And finally when sdwilsh put the cvs check-in output on the bug I was so relieved. I knew that it would take an hour atleast for the new code to be picked up by mxr. After an hour I visited mxr to see my name in the contributors list. I copied the link to the line with my name in the nsDownloadManager.cpp and put it as my status message in GMail chat and Gtalk.

It was a great learning experience for me and a much greater sense of achievement.
Thanks again, Google and Mozilla.

I now continue to be a part of this awesome community and contribute whenever I can. After this success I took up the job of providing resume support for "Open With" kind of downloads. More about that in another post.

Shree Yalaguresh Prasanna.
Hari Om.

Tuesday, October 16, 2007

Mozilla - Bookmarks' keywords & Quick Searches

This world is really full of amazing things. How much ever we discover and find out, there will be something interesting just right next to us which we would not have figured out. This post is about one such thing, which was right here from such a long time and I had not figured it out.

The first hints for this came to me when I saw one of my colleagues, Pramod S, at NI using shortforms for Google(g) and Wikipedia(wp) when searching. I thought he had come across some hack and tweaked his browser. But just today I realized that it is infact a feature in Firefox.

For any URL or webpage that we bookmark we can assign a keyword, a shortform, which can be entered in the URL bar to visit that bookmarked page. This is really a very useful things if we visit certain pages over and over again. In my case http://mxr.mozilla.org/seamonkey/ is one site that I cannot live without. So I have keywords for the 3 different searches available at this page, viz:
  • mxrf - for file search(find)
  • mxri - for identifier search
  • mxrt - for free form text search

This feature is really handy and increases the brwosing speed to a great extent.

How to get this working? or how to assign the keywords?. This again is really simple. For existing bookmarks just go to the Bookmark properties by Right-Clicking on that and you get a small dialog with a text field for Keyword. Key in whatever you want and click on OK. Thats it you are ready to fire the internet with your keywords. For new bookmarks it is still easier. When you are creating a bookmard with the helper dialog you get the keyword field which you can key in or leave it blank (either to be filled later or not to be filled at all).

This is not the end. There is yet another enhancement to this. Certain bookmarked urls have query strings, as in case of search urls. The google url: http://www.google.com/ is followed by a query string of the form "search?hl=en&q=search string" which carries the search string entered. Such strings work with the keywords also. Meaning you can search for something on google using the keyword, 'g' like this:

"g any-search-string" . This will be converted to appropriate URL with a proper query string as specified in the bookmark properties. As it appears this of course requires a little bit of extra work. When saving an URL as bookmark, for instance when saving http://www.google.com/ you can save it along with the query string, but the search string being substituted by "%s" and whatever string you specify with the keyword will replace every occurance of %s in the URL. So this is how the bookmark URL will look like:

http://www.google.com/search?hl=en&q=%s ---- with g as the keyword. Now when using this bookmark, if you enter something like this in the URL bar:

"g bookmarks " -- this becomes-- http://www.google.com/search?hl=en&q=bookmarks -- and finally giving you search results for bookmarks.

Now this is how I have arranged my mxr bookmarks:

Now does this method appear too complex and cumbersome? Well mozillians come to your rescue yet again. You can save such enhanced search bookmarks called "Quick Search" bookmarks very easily like this:

Go to the search page and Right-Click on the search bar, and click on: "Add a keyword for this search" . That will give you the small bookmarking dialog, with a field for keyword. All that you have to do is to just enter the keyword that you want and click on OK. All the URL, query string and %s headache is taken care by Mozilla.

Well mozilla is here just to make your browsing experience easier, safer and worthwhile., isn't it?

And I am proud to be associated with this awesome community. ;-)

Happy and Fast Browsing.

Tuesday, June 5, 2007

My GSoC 2007 Story

I always had this desire to do something big and noticeable in my life as an engineering student. Right from the day I was introduced to C programming I have enjoyed programming like anything and I was pretty sure that if at all I had to do that 'something big' it will be in terms of a major software project. This desire never actually got me to work on or do something. Meaning it never materialized. Around me, I saw many people(seniors and batch mates alike) who were pretty complacent. (There were indeed exceptions). So the desire gradually was subdued by fun, until 6th semester when a friend of mine, Ashwin(Setu), forced me into coming up with a technical paper. We did come up with one on search engines which was not really that technical and hence was not what I actually desired. Then almost at the same time a few people started asking me:
" Hey are you not participating in a coding competition called Google Summer of Code? Vikas GP(A very big open source freak and a real good coder - a big shot in the college)is doing that. He is getting a lot of money for that".

At that time I thought it was just another 2 days or 3 days contest for people with ultimate coding skills who can work out magic, because of which the money appeared inaccessible, and I did not even bother to find out what the program actually was. It was eventually forgotten.

Again in March 2007, few days before the mentoring organizations started registering for SoC 2007, a talk was organized by IBM on open source software, in which it was mentioned that some Google APIs are available out there on the net. I started checking it out at http://code.google.com/ and there I saw this link to Summer of Code and the last year's scenario instantly came back to me. So I started having a look at that as to what this program is all about. When I read the program details completely I was baffled at the magnitude of the program and its quality. (The $5000 really stunned me for some time). At that moment I decided that I need to get into this program and this will be the fulfillment of my long standing desire.

I started looking into various organizations where I can poke my nose and hope to get noticed and eventually be selected. There were very few avenues for me as my open source utilization was very less and  open sourcedevelopment experience was close to nil. The organizations that I shortlisted for me were:

1) KDE - I am big fan of that and I have been using only KDE (no GNOME) for a few years now.

The following because my internship at IBM dealt with these things.

2) Mozilla Foundation (MoFo)
3) Dojo Foundation
4) Eclipse

Of all these places, the only place where I knew a few developers and where I was also a little known was in the Mozilla Foundation and that was the strongest contender.

Then I talked to Vikas GP and told him about my plans to participate in this. He gave me this fantastic idea which he had used. The plan was to catch hold of a mentor outside the program realms and impress him with your idea/code, so that when the applications go for review, we will have already mentioned a mentor's name and that person will pitch in for us. If our mentor is well known and popular in the community then we will surely be selected. :). GP had done this by catching hold of a college senior, an identified GNU developer, whom he knew personally. Now there was only one guy whom I knew properly in the MoFo and that was Mook. Then again I did not have any ideas either and the ones listed on the brainstorming page of the Mozilla wiki were all Greek and Latin to me.

Still I started looking at the ideas proposed at the brainstorming page and there was an idea to implement metalink support for the Firefox Download Manager. I thought of taking it up. In that proposal I found a link to the Firefox feature request page. The list was obviously too long, and metalinks was also listed there. But two other things caught my attention (as I had felt a dire need for those):

1) Implementing download resume across different sessions
2) Reducing the memory consumption for Firefox.

I did not find any material for metalinks and memory reduction, but found a MDC page related to resumable downloads by a person named biesi. I read that and got a small idea as to what all things are involved in implementing resumable downloads.

With this I entered the #mozilla on irc.mozilla.org from where I was directed to #developers by one nice fellow. I put up this proposal of metalinks in #developers and got bad response. Only a couple of people replied and also told me that the actual person who had mentioned it was not known to them. I was surprised and so happy to see biesi amongst the people replying. I was like - "Oh man he is the author of that MDC page and here he is talking to me directly.."
Then with the metalinks idea failing to impress I proposed the download resume idea. This got some good response, but nobody was ready to mentor me. I was pestering biesi but he told me that he is not free and does not have time to mentor me. Then when I was searching for Mook or Mossop (whom I had pestered previously about extension development) amongst the nicknames, when dmose pinged me saying "brahamana, if you are going ahead with download resume then I can mentor you". I was only partly happy as I was not aware of the credibility and popularity of dmose (With all due regards my Master, now I do know), but at least I had someone who was interested in mentoring me. But I was still hoping for biesi, (he was the author of page on MDC man)

Then dmose asked me what were the requirements for a mentor and I told him that he needs to be a respected member of the mozilla developer community and at that point biesi told me that dmose suits that description very much. dmose then told me that he will talk to his boss, mconnor, The Firefox project lead. (Wow man..) I was taken aback. I was like, "Whom was I doubting??!!! This guy talks to Firefox project lead directly in person and he is speaking for me in front of him". I thought this was my Jackpot ;-). But again dmose told me that he still can't promise me anything and will have to find out with mconnor. Well that much was sufficient for me at that time and I was literally jumping in my room (It was around 4 a.m in the morning. Yes, as usual a night out).

Then the killer waiting period started. I pinged dmose the very next night(starting of the day for him). He told me that he has mentioned the idea to mconnor and he is awaiting his response. I was growing very impatient. The last date for submitting the application to google was approaching and there was no response or growth here. I was stuck with two options, submit the application without any reference and prior approval and compete with several others as a normal application or wait for the reply till the last moment and submit it with prior approval so that there will be no competition. But the problem with waiting was that last moment applications are given less value. So that was a risk again. Meanwhile I had read many blogs, previous year's applications and several articles on "How to write a proper SoC application" and even things on "How not to write an application" and "What the mentors actually look for in the application". So with all this gyan I had realized that application has to be sent quickly or it should have a solid reference.

I pinged dmose again few hours later and this time I pissed him off and got scolded. He told me to be a little patient and wait. I was afraid of screwing this up and hence did not bother him anymore. I just hung around at #developers and made my presence felt whenever dmose was active in some discussions. I was reading that MDC page again and again and trying figure out what those terms meant so that I can talk something sensible in the channel. In that course I had discovered quite a few resources and gained some know how on Mozilla and download resume feature. I got impatient again the next day and this time to be safe I emailed dmose. His reply seemed to be calm and I was positive that I am on the right track. He had written that there was no reply from mconnor yet. This process of hanging around at IRC for a major part of the day continued for another day also. Then 3 days after the initial proposal, when I was having a discussion with dmose, biesi and probably Gijs, dmose said this as a very matter of fact thing: "brahmana, BTW mconnor has agreed for the SoC idea and you can go ahead with the project". I was very happy and started immediately asking him what is to be done, so that I could start immediately and make my position still safer. He then asked me to send any of my previous projects so that he can have a look at my coding skills. I did not have any project expect for the two academic ones. The IBM internship carried a lot of weight but no code was available as it was a proprietary thing. But the code was essential for him. And for my bad luck I was not able to find my IDE for C on Linux project anywhere. The computer on which it was stored was formatted and it was gone. It was 7 a.m and I told dmose that the project is in a repository on the college server and that I will get it to him later. Luckily he agreed. Then I was checking my cd collections to find this project and instead found another project which I had submitted. It was 2D Graphics Editor, a paint brush kind of an application written in C. It was a very big one and also a good one, but the problem was that it was not entirely written by me. We(me and my project partner Vikas Patil) had flicked it from a senior. Since I had no other option I sent that one to dmose. I do not know what he actually thought. All that he told me was: "yes, its fine. But here at mozilla you will have to write a lot of comments". Well man, that was not a problem at all. And dmose confirmed my slot. (Thank you dmose very much).

And luckily google had extended the last date for application submission. I built up a nice application from various sources, put in Dan Mosedale (dmose) twice and in a prominent way and submitted it. I was a lot relieved and very happy that the desire is indeed going to be fulfilled and something solid will materialize.

UUUuUOOoooffff... That was one herculean task man and I finally did it.

I told GP and others that a MoCo employee has agreed to mentor me. I showed them Dan's name in about:credits and told them this is the guy who will be mentoring me. It was a matter of pride for me.

Then with Dan's name in the application I did not have any problem in getting selected. No questions asked, no comments. The only notification was when I was selected.

This whole experience was awesome.

Thank you Google for conducting this program.
Thank you Mozilla Community for the guidance.(and also fun)