Synchronization with Ericsson T68i

For discussing the Mozilla Calendar, Sunbird and Lightning projects.
Post Reply
User avatar
zippie
Posts: 1
Joined: May 30th, 2004, 9:27 am

Synchronization with Ericsson T68i

Post by zippie »

I made a "something-lika-a-patch" for Sunbird in order to be able to somehow sync your calendar in Sunbird with the calendar in the Ericsson T68i. This also works in the Calendar plugin for Thunderbird, Firefox, etc. This is not a real synchronization it is just a modification which will enable you to export the events in a format understandable by your mobile phone.

The original vCal save-as-type option in Sunbird, is not a vCal understandable by the mobile phone and wont work. First, it seems that it is not vCal at all, but iCal, and second - the Ericsson T68i uses UTF-7 format - so other-than ANSI letters wont work at all. I'm posting this, and not doing it via CVS because it is way too complicated for anyone wanting just a small hack and I don't know how to do it with CVS, nor do I have the tools. The code mentioned in this post is partly copy-pasted from the original Mozilla Calendar (so the Mozilla licences apply) and partly made out of my head (and for that parts I guess also the Mozilla license applies - I don't care).

If anyone is interested, then the modification procedure is the following.

1. Open the file: content/calendar/importExport.js inside the chrome/Calendar.jar (for this you will probably have to unzip the Calendar.jar)

2. Edit the file in the following way:

2a. Inside the function saveEventsToFile( calendarEventArray ) find the line:
<blockquote><code>
fp.appendFilter( filtervCalendar, "*" + extensionvCalendar );
</code></blockquote>
and after that insert:
<blockquote><code>
fp.appendFilter( "Ericsson T68i vCal", "*" + extensionvCalendar );
</code></blockquote>
2b. Next, find the lines
<blockquote><code>
case 6 : // vcs
aDataStream = eventArrayToICalString( calendarEventArray, true );
extension = extensionvCalendar;
charset = "UTF-8";
break;
</code></blockquote>
and after them insert
<blockquote><code>
case 7 : // vcs-mobile
aDataStream = eventArrayToVCalString( calendarEventArray, true );
extension = extensionvCalendar;
charset = "UTF-7";
break;
</code></blockquote>
2c. Next, find the line:
<blockquote><code>
/**** patchICalStringForExport
</code></blockquote>
and then, just before that line insert a new line and paste the whole following function:
<blockquote><code>
/**** eventArrayToVCalString MADE AS A MODIFICATION OF THE ORIGINAL eventArrayToICalString
* Converts a array of events to iCalendar text
* Option to add events needed in other applications
*/

function eventArrayToVCalString( calendarEventArray, doPatchForExport )
{
var checkDate = function ( dt, isDate )
{
var dateObj = new Date( dt.getTime() );
var result = "";

if( isDate ) {
result += dateObj.getFullYear();
if( dateObj.getMonth() + 1 < 10 ) result += "0";
result += dateObj.getMonth() + 1;
if( dateObj.getDate() < 10 ) result += "0";
result += dateObj.getDate();
}
else {
result += dateObj.getUTCFullYear();

if( dateObj.getUTCMonth() + 1 < 10 ) result += "0";
result += dateObj.getUTCMonth() + 1;

if( dateObj.getUTCDate() < 10 ) result += "0";
result += dateObj.getUTCDate();
result += "T"

if( dateObj.getUTCHours() < 10 ) result += "0";
result += dateObj.getUTCHours();

if( dateObj.getUTCMinutes() < 10 ) result += "0";
result += dateObj.getUTCMinutes();

if( dateObj.getUTCSeconds() < 10 ) result += "0";
result += dateObj.getUTCSeconds();
result += "Z";
}
return result;
}

if( !calendarEventArray) calendarEventArray = gCalendarWindow.EventSelection.selectedEvents;

var sTextiCalendar = "";
for( var eventArrayIndex = 0; eventArrayIndex < calendarEventArray.length; ++eventArrayIndex )
{
try {
var calendarEvent = calendarEventArray[ eventArrayIndex ].clone();
} catch( e ){
alert( "Caught an exception in eventArrayToICalString, while trying to clone the event, it was: \n"+e );
}

if (calendarEvent.alarmUnits=="hours") multi=3600*1000;
else if (calendarEvent.alarmUnits=="minutes") multi=60*1000;
else if (calendarEvent.alarmUnits=="days") multi=24*3600*1000;

var aco=new Date(calendarEvent.start.getTime());
aco.setTime(aco.getTime()-(multi*calendarEvent.alarmLength));

if ( doPatchForExport )
sTextiCalendar += patchICalStringForExport(
"VERSION:1.0"+"\n"+
"BEGIN:VEVENT"+"\n"+
"SUMMARY;CHARSET=UTF-7:"+calendarEvent.title+"\n"+
"LOCATION;CHARSET=UTF-7:"+calendarEvent.location+"\n"+
"DTSTART:"+checkDate(calendarEvent.start)+"\n"+
"DTEND:"+checkDate(calendarEvent.end)+"\n"+
"AALARM:"+checkDate(aco)+"\n"+
"CATEGORIES:"+calendarEvent.categories+"\n"+
"END:VEVENT"+"\n"
);
else
sTextiCalendar +=
"VERSION:1.0"+"\n"+
"BEGIN:VEVENT"+"\n"+
"SUMMARY:"+calendarEvent.title+"\n"+
"LOCATION:"+calendarEvent.location+"\n"+
"DTSTART:"+checkDate(calendarEvent.start)+"\n"+
"DTEND:"+checkDate(calendarEvent.end)+"\n"+
"AALARM:"+checkDate(aco)+"\n"+
"CATEGORIES:"+calendarEvent.categories+"\n"+
"END:VEVENT"+"\n"
;
}

sTextiCalendar= "BEGIN:VCALENDAR"+"\n"+ sTextiCalendar + "END:VCALENDAR"+"\n"

return sTextiCalendar;
}
</code></blockquote>
4. Save the importExport.js file, back inside the calendar.jar in the proper folder.

5. Restart Sunbird

---------

So from now on, you will be able to do the following:

1. In the event list select the events you want to export

2. Select Export selected events from the Tools menu

3. Choose type "Ericsson T68 vCal" and save the file in some filename.

4. Delete all events in the mobile phone (since it will not find out duplicates)

5. Right click the saved file and choose send via infrared or bluetooth (depending what you have)

6. Accept the sent events on your mobile phone.

That's it, if you forget number 4., and had an import previously all already existing events will be duplicated, because this is not synchronization procedure.
bobby555
Posts: 2
Joined: April 28th, 2004, 4:18 am

Post by bobby555 »

Found this just now.

This is the feature I'm waiting for to let me leave Outlook. Too bad this solution isn't very smooth.

AM
Post Reply