Pi’s Blog

My blog about Thunderbird and GSoC 2008

gContactSync version 0.1.1 released

Version 0.1.1 of gContactSync is out and available for download here.  Right-click and hit Save Link As, then install it in Thunderbird.

New Features:

  • Greatly improved Preferences dialog (thanks to some help from Leszek(teo)Życzkowski)
  • Bug 19960 – Add a preference to enable/disable the toolbar button
  • An icon (again, thanks to some help from Leszek(teo)Życzkowski)
  • Verbose logging is disabled by default (should speed things up slightly)

Bug Fixes:

  • Bug 19964 – Log file window is too small in Thunderbird 3.0b1pre
  • Bug 20099 – gdata.makeAuthBody does not encode the e-mail address or password
  • Bug 19959 – the sync toolbar item got a wrong icon and can’t be removed from toolbar – UPDATE – this may not have been fixed according to the bug reporter.  Please let me know if this still happens.

Basic Features

  • Synchronizes contacts between Google Mail and Mozilla Thunderbird (2 or 3)
  • Can synchronize several accounts with their own address books
  • Adds attributes and “types” for phone numbers and screennames to Thunderbird
  • Customizable with a preferences dialog
  • en-US and es-ES locales

More Information

As always, feedback, feature requests, and bug reports are appreciated, but please be patient as I’ve been extremely busy with college, work, and co-op/internship hunting.  Thanks to everybody who has provided feedback up to this point.

TraceMonkey Note – if you are using Thunderbird 3.0b1pre, you can try enabling TraceMonkey.  It made the synchronization process faster for me.  Great job everbody who worked on it!

October 18, 2008 Posted by | GSOC | , , , , , | 5 Comments

New and Improved Postal Address Synchronization

When my extension was written about, the reviewers and commenters all mentioned the onerous task of editing every single contact in Google to reformat the addresses.  I have just finished some tweaking that will allow you to synchronize postal addresses exactly the way you want them formatted.

It will be included in a new release tomorrow.

Changes in Thunderbird

For now, I kept the original 6 fields for each type of address in Thunderbird: Address Line 1, Address Line 2, City, State, Zip Code, and Country.  But, I added a tab to the edit card dialog (what you seen when you edit a card) that contains three textboxes that allow multiple lines.  In the card view on the bottom, the normal address is still shown as normal, if present, but, if the new address is not empty or blank, it replaces the normal address and has its own Map It button.  The new address is automatically made from the old address when the card is converted to an XML representation.

If you use this extension, you will probably want to use the new address fields in the last tab of the edit card dialog.  You unfortunately cannot set any new properties when creating a new card without creating it and then editing it, but the addresses will be converted to the new format automatically.  The original 6 fields will then be cleared since, otherwise, you would be unable to remove an address from a contact.

Click here for a large screenshot (you can’t tell from the screenshot, but there are scrollbars on the right side of the address fields)

Changes in Gmail

You do not have to reformat addresses any more and you can put whatever you wish (as long as it is valid) in the addresses.

The new Postal Address Sync Process

The process of synchronizing postal addresses has changed, obviously.  When converting from a card to XML, the extension first looks for the new address.  If it cannot find that, it looks for the older address and creates a new address from it and sets the address attribute to that.  Then, it synchronizes the new address directly with Google’s address.

When converting from XML to a card, the extension ignores the 6 address fields and sets the value of the new address attribute to the value from Google.

Feedback

I tried not to do any too drastic before getting some feedback, so this feature is only partially complete.  Should these new textboxes then remove or disable the old textboxes?  Should the extension convert all addresses to the new format when it runs for the first time?

August 7, 2008 Posted by | GSOC | , , , | Leave a comment

gContactSync available for download

The first–and possibly only–alpha version of my extension is available for download.  You can watch a flash tutorial on basic use and download it herePlease watch the tutorial before using it or you might run into problems. Remember that it is an alpha version, so there might be bugs, and I might add more features.

You can read about the extension on my website.  I also have a mozdev project for it where you can view the source and download the extension.

Reporting Bugs and Suggesting Enhancements

I welcome any sort of feedback, enhancement request, or bug report.  If you encounter an error, please e-mail me with the details and the log file after removing any personal information from it.  There are several e-mail addresses you can use to do it.  gcontactsync at pirules.net is probably easiest.  You can also use the contact form on my blog or website.

If you encounter an error, you can find the log file in the extensions’s folder.  Read this to get to the profile directory, then go to the extensions folder and the folder named gcontactsync at pirules.net.  It is the file named log.txt, and you will probably want to remove any personal information in it before sending it.

Keep you eyes open for updates.  I’ll try to get a new version out soon after I receive some feedback.  Updates will have to be done manually, for now.

July 31, 2008 Posted by | GSOC | , , , , , | Leave a comment

Synchronizing Addresses

Introduction

Thunderbird stores addresses using 6 fields:  2 lines for the address, the city, the state, the zip code, and the country.  Google stores addresses in one field (supports multiple lines).  Since these two differ so greatly, it is difficult to synchronize addresses properly.

Possible Solution(s):

Splitting the address with newline characters in Google

Example:
Address Line 1
Address Line 2
City
State
Zip
Country

Any empty fields in Thunderbird would mean an empty line in Google.  Google’s mapping feature worked perfectly with the method listed above.

Splitting the address with semicolons

Another possibility is using semicolons instead of newlines to split the address.  Google was also able to map an address formatting in this fashion.  Example:
Address Line 1;Address Line 2;City;State;Zip;Country

Separating using newlines seems to be the most readable (to me), but Google only shows up to 4 lines in the address field and makes you scroll to see beyond that.

Any other ideas or thoughts?

June 28, 2008 Posted by | GSOC | , , , | 1 Comment

An overview of my extension

The extension that I am working on for GSoC synchronizes an Address Book in Mozilla Thunderbird with Google Contacts. This is going to be a quick overview of how it works so far. This post assumes some basic knowledge of the Hypertext Transfer Protocol (HTTP), Thunderbird, and programming.

Basically, my extension adds an overlay to the Thunderbird Address Book, so when the Address Book opens, it starts going.

Authentication Check

When it starts, it registers a preferences observer (so it can modify behavior as preferences change) and obtains the current preferences. I will explain preferences in more detail later. It then checks to see if there is a valid authentication token in the extension directory. If not, it shows a login prompt. When OK is pressed, it attempts to authenticate the user using Google’s Client Login method of authentication. So, it sends an HTTPS POST request to Google which then returns an authentication token that can be used repeatedly and does not expire. This token (not the username and password) is stored in a textfile in the extension directory.

Initialization

Once it gets or finds a valid authentication token, adds a listener (nsIAbListener) to the Address Book Manager (nsIAbManager), sets up the file that stores the date and time of the last synchronization, and begins the synchronization process.

Preparing for Synchronization

The sync process is the longest and the one that I change most often. Right now, it gets the Address Book first (does this every time in case it was deleted, changed, etc.). Then, it gets the time of the last sync (if any) to be used later and sends an HTTP GET request to Google using the authentication token to obtain all of the user’s contacts. Once it has these, it also obtains all contacts in the specified Address Book.

Synchronization

Right now this process is costly in terms of asymptotic analysis (or Big O notation) with a nested for loop.

The outer for loop iterates through every contact from Google while the inner for loop iterates through every unmatched card in the address book. When it finds two cards that it considers “identical,” if the current card from Google hasn’t been matched then it sets the TB card to null (so the loop knows it was ‘matched’ and calls a method that checks the cards’ last modified date to see if any of them is new since the last sync.  If so, it replaces the old card with the new one.

If the card from Google was already matched, however, that means that the card from the Address Book is a duplicate and my current implementation removes the card. In the future I may add a prompt asking the user what to do about it.

Once the inner loop is finished, if the card from Google wasn’t matched it means one of two things. Either the card is new and should be added to Thunderbird (the card’s last modified date is more recent than the last sync) or it was deleted from Thunderbird and should be removed from Google.

Once that is done, it checks any unmatched cards from Thunderbird and figures out if they should be deleted from TB or added to Google, and then does that. Due to some timing issues with HTTP Requests, there are three helper methods. There are three global arrays treated as queues for cards to delete, update, and remove.  The sync method adds cards to the arrays as necessary.  When the sync method is done, it calls the delete method, which then calls the add method, which in turn calls the update method.

Finishing up the sync

When the hard part is over, it writes the current date/time to a file (the last sync time), schedules another sync after the preferred interval and sets a synced boolean to true (which is checked by the listener to make sure it doesn’t act during synchronization)

Address Book Listener

Since TB 3 doesn’t have the lastModifiedDate property, I made my own rough version with an Address Book Listener. The address book listener updates the card’s ‘custom2’ property whenver a contact is modified or added to the Google Contacts address book. Using this approach, my extension should work offline.  I am working on adding last modified date to Thunderbird 3, so soon an address book listener and some of the booleans required by it may become unnecessary.

May 26, 2008 Posted by | GSOC | , , , , , , , | Leave a comment