Monday, September 27, 2010

Playing around with Funambol web demo app

I was involved working with asset management database for the first 2 weeks and it was very educational. I was given a lookup feature to be included in the database front end which I completed in 1 week. I also tested the same by adding up more than 40 devices into the database through the lookup feature. I hope my lead was impressed by this feat. He seemed satisfied. When delivering him the final package I asked if he wants me to look into something else. There was not much to do in the database part so he included me into the blackberry apps group which is also handled by him.
It was then that I came to know about Funambol, my first assignment.
Funambol is an open source mobile sync feature for various mobile devices. The concept is simple. Users can download and install it in their mobile. Then specify the email address from which you want to sync your device with. If I give my yahoo mail address, it copies the contacts, calender etc from that account and the Funambol-Email will also display(sync) the inbox into your device. This helps people access their account on the go. Just open the application, choose the server sync option, when its done, you can see the new changes (if any) like new mails, new tasks etc that has been added into your email account. Through Funambol you can also set new task, contact, send email to others, upload pictures into facebook on the go etc.
How does it work? I haven't researched it well but I believe the funambol data server communicates with regularly with your yahoo account and stores the email, contacts etc from their and when u select the device sync option, it actually loads data from the funambol server. The same happens when you want something to go out from your device, like uploading a picture.
More detail information can be found at Funambol site,
I installed the funambol data server application (free!). Through this you can make your own PC act as the Funambol data server, and the device will contact your PC for updates. Once it is installed, start the funambol data server (start->all programs->funambol->funambol data server->start server). It will take some time to be up. The open the browser and type http://localhost:8080/funambol/ds and you can see the web demo client. By default the admin username is included (username: admin password: sa). You can also open the funambol administration tool. Play around with funambol for a while. Get yourself comfortable about its working. The settings for web demo is in the C:\Program Files\Funambol\tools\tomcat\conf\server.xml file. You can change the default port 8080 to something else like 8181, which I did. The documentatio for funambol can be downloaded from this site,

My Task: When we login into the web demo client (say using admin account), and create a new account, the common fields are First Name, Last Name etc. What if I want to add more fields like (Nickname) on top of the exisiting ones. This is necessary because in a blackberry when we create a new account, we have all sorts of extra fields and we need to map Funambol's server contact fields with BlackBerry's so that when sync-ing, all fields in BB gets populated. Investigate.

Initial Approach: I could see that the web demo client front end is bunch of jsp pages. When I populate the contact fields and click Add, some jsp page is called passing the values. The jsp pages are in C:\Program Files\Funambol\tools\tomcat\webapps\webdemo and main.jsp, add.jsp, view.jsp and list.jsp handles the contact part. Looking into the source code isn't much of a help. But I know that parameters are being sent/received from somewhere, parameters like operation=ADD, type=contact etc.
Next approach is to find the source code. Browsing in the Funambol folder, there is no .java files, only .class files (in C:\Program Files\Funambol\tools\tomcat\webapps\webdemo\WEB-INF\classes). If its open source application, where is it?
As it turns out, the source code doesn't come with the installation package. One can download the source code separately, modify, rebuild the package the replace the .class files with the one thats in the installation package and you get your new modified funambol.
Okay. Next thing to do is download the source code, from using the command "svn checkout encore --username kundan " in the command prompt(win)/terminal(linux). I recommend one should register at the funambol site. One can also use the anonymous username (no password) to download the source. This will copy the source code into the encore folder. Next step, how to build it?
I followed the instruction mentioned in to build the whole funambol bundle. I did all the package settings as it asked me to. Building the whole package is a feat in itself. When I tried "ant forge-bundle-win", I faced lots of errors. These may arise because of fault in settings etc. Bottom line is, debugging the build error is out of my reach.

On further reading the how to build wiki page(above), I could see that we can build individual sections separately. I am concerned with webdemo part only, why not build webdemo only? So, I went into "encore\funambol\modules\webdemo-module\webdemo-webapp" and ran "mvn package". result: BUILD SUCCESSFUL. A target folder is created containing the new class files. Now its time to edit the souce code.
Open the encore\funambol\modules\webdemo-module\webdemo-webapp\src\main\java location and edit the file. Study the source code. You have to add parameters for nickname going by the same format as name, surname etc in the java file. The main contact class is in https://core.forge.f​​rowse/core/trunk/fun​ambol/common/pim-fra​mework/src/main/java​/com/funambol/common​/pim/contact/ and the servlet file calls functions of this file to read/write contact properties. One can see that Name.Java file indeed has fields for nickname, suffix, initials etc. These are the fields that are already supported by Funambol but for some reason they do not show up in the web demo. We are closer on our way to displaying them. Build the package again after modifying. target folder is created. Copy the .class files into the funambol install dir i.e at C:\Program Files\Funambol\tools\tomcat\webapps\webdemo\WEB-INF\classes.
Finally we need to modify the corresponding jsp files to display text boxes for those fields. Modify the view.jsp and add.jsp to display field for Nickname in the same manner as Name and Surname etc are being displayed there.
We are done!

Open the web demo portal(you might need to restart server for changes to take effect), login using any (admin/guest/user) account. Click on new contact and see the Nickname field. Test the modification by adding a new contact and then displaying the same. The nickname field is saved.
Through this we are now able to write nickname field into database whose value previously being written was null.
Another interesting thing to check. One can confirm that the nickname field is being written into the database by looking into the funambol.log file.Since I have used the default db i.e hypersonic, so if I open \hyper​sonic\data\funambo​l.log file, at the bottom I can see the sql script being invoked to insert data into db and there is one less NULL data being written because we have now enabled the nickname field. :)

That summarizes my first funambol experience. A further look into, etc will tell us what are the funambol supported contact fields.
Next task I think is to know how to add a new field, the one that is not even supported by funambol. May be next time I'll reflect on this.

Useful reads:


Stumble Upon Toolbar

Saturday, September 11, 2010

2 weeks into Chicago

I am in Chicago right now, dreading the oncoming winter. Yeah, I hate winter. Boo You. I hate it because it makes me lazy. I don't like to be in bed till 11 am and still not in mood of coming out of the blanket because you worked so hard over night to make the interior this warm, cozy. In the midst of this paradise, who would like to think that you have a class starting in 30 mins or the project manager waiting for you. Less spoken the better about the everything turning stone cold, literally. Water is cold, kitchen utensils are cold, damn it the toilet seats are cold. You would hate to come out of the hot shower for the same reason. Why go out and say hello to cold air, invite them to touch you, give you a tingling shiver.

I can go on for more but in the midst of my harangue I forgot the main thing.

I am in Chicago for my internship, at RIM, the creator of BlackBerry, in case you didn't know that. Its been 2 weeks here. The place is nice, people are nice, facilities are awesome (I meant free unlimited coffee of course), work i seven more interesting and the best part, no fixed committment when to be in office and when to come out etc. If one may remember the one thing I used to hate the most while employed at Samsung is the punch-in punch-out system. One has to be in office at best by 10am and one canno tleave office before 4pm with maximum of 1 hr break in betwen. What is this, a jail?

Anyways, that being said I'll try to put in some things that I learned during these 2 weeks. In simple words, my work pertains to developing application in VBA (Visual Basic for Applications) for a database in MS Access. What does the database contain? Well, nothin but which guy has which device with him, who is responsible for the device etc etc.

My first order of business was to resolve the size difference between the front end and back end. It is a common observation that when you open the modules, forms etc for changing in their codes and close the application after the updates you'd notice that the size of the front end has increased. My thought process was to separate each of the forms, macros, queries etc from the application and analyze their size individually. This didn't work. After some research on the web, I found out the solution.

The automatic compaction feature of Access is not enabled by default. If not done so, Access front end would incorporate the back end wholly which is unnecessary. The checkbox to enable the automatic compaction can be found in the Access Options. Initial side effects would involve slowing down of opening or closing of application but that would settl edown soon. One doesn't even need to tell the Access to compact everytime the application is closed. It can be invoked periodically at a predefined time stamp or you can set the size beyond which Access will automatically compact and repair the database.

Among many other itsy bitsy things I learned this was something I thought worth putting into a blog. May be in my next post after 2 weeks I'll have something more interesting than this.

Goldy Blank

Stumble Upon Toolbar