diff --git a/calendar/libxpical/caltst.js b/calendar/libxpical/caltst.js index fd06113dcf84..557d4d5204da 100644 --- a/calendar/libxpical/caltst.js +++ b/calendar/libxpical/caltst.js @@ -97,8 +97,8 @@ Observer.prototype.onEndBatch = function() function Test() { + netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect"); if( iCalLib == null ) { - netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect"); var iCalLibComponent = Components.classes["@mozilla.org/ical;1"].createInstance(); iCalLib = iCalLibComponent.QueryInterface(Components.interfaces.oeIICal); } @@ -491,12 +491,11 @@ function TestRecurring() { var displayDates = new Object(); var checkdate = new Date( 2002, 0, 1, 0, 0, 0 ); - var eventList = iCalLib.getEventsForDay( checkdate, displayDates ); + var eventList = iCalLib.getEventsForDay( checkdate ); if( !eventList.hasMoreElements() ) alert( "Yearly Recur Test Failed" ); - var displayDate = new Date( displayDates.value.getNext().QueryInterface(Components.interfaces.nsISupportsPRTime).data ); iCalLib.deleteEvent( id ); } @@ -734,6 +733,81 @@ function TestFilterTodo() function TestIcalString() { + + var iCalEventComponent = Components.classes["@mozilla.org/icalevent;1"].createInstance(); + var iCalEvent = iCalEventComponent.QueryInterface(Components.interfaces.oeIICalEvent); + + iCalEvent.id = 999999999; + iCalEvent.title = DEFAULT_TITLE; + iCalEvent.description = DEFAULT_DESCRIPTION; + iCalEvent.location = DEFAULT_LOCATION; + iCalEvent.categories = DEFAULT_CATEGORY; + iCalEvent.privateEvent = DEFAULT_PRIVATE; + iCalEvent.allDay = DEFAULT_ALLDAY; + iCalEvent.alarm = DEFAULT_ALARM; + iCalEvent.alarmUnits = DEFAULT_ALARMUNITS; + iCalEvent.alarmLength = DEFAULT_ALARMLENGTH; + iCalEvent.alarmEmailAddress = DEFAULT_EMAIL; + iCalEvent.inviteEmailAddress = DEFAULT_EMAIL; + + iCalEvent.recur = DEFAULT_RECUR; + iCalEvent.recurInterval = DEFAULT_RECURINTERVAL; + iCalEvent.recurUnits = DEFAULT_RECURUNITS; + iCalEvent.recurForever = DEFAULT_RECURFOREVER; + + iCalEvent.start.year = 2001; + iCalEvent.start.month = 10; //November + iCalEvent.start.day = 1; + iCalEvent.start.hour = 12; + iCalEvent.start.minute = 24; + + iCalEvent.end.year = 2001; + iCalEvent.end.month = 10; //November + iCalEvent.end.day = 1; + iCalEvent.end.hour = 13; + iCalEvent.end.minute = 24; + + var snoozetime = new Date(); + iCalEvent.setSnoozeTime( snoozetime ); + + var sCalenderData = iCalEvent.getIcalString(); + var iCalEventComponent = Components.classes["@mozilla.org/icalevent;1"].createInstance(); + var iCalParseEvent = iCalEventComponent.QueryInterface(Components.interfaces.oeIICalEvent); + //alert(sCalenderData); + iCalParseEvent.parseIcalString( sCalenderData ); + //alert("2" + iCalParseEvent.description); + + if( iCalParseEvent.title != DEFAULT_TITLE ) + alert( "Invalid Title" ); + if( iCalParseEvent.description != DEFAULT_DESCRIPTION ) + alert( "Invalid Description" ); + if( iCalParseEvent.location != DEFAULT_LOCATION ) + alert( "Invalid Location" ); + if( iCalParseEvent.categories != DEFAULT_CATEGORY ) + alert( "Invalid Category" ); + if( iCalParseEvent.privateEvent != DEFAULT_PRIVATE ) + alert( "Invalid PrivateEvent Setting" ); + if( iCalParseEvent.allDay != DEFAULT_ALLDAY ) + alert( "Invalid AllDay Setting" ); + if( iCalParseEvent.alarm != DEFAULT_ALARM ) + alert( "Invalid Alarm Setting" ); + if( iCalParseEvent.alarmUnits != DEFAULT_ALARMUNITS ) + alert( "Invalid Alarm Units" ); + if( iCalParseEvent.alarmLength != DEFAULT_ALARMLENGTH ) + alert( "Invalid Alarm Length" ); + if( iCalParseEvent.alarmEmailAddress != DEFAULT_EMAIL ) + alert( "Invalid Alarm Email Address" ); + if( iCalParseEvent.inviteEmailAddress != DEFAULT_EMAIL ) + alert( "Invalid Invite Email Address" ); + if( iCalParseEvent.recur != DEFAULT_RECUR ) + alert( "Invalid Recur Setting" ); + if( iCalParseEvent.recurInterval != DEFAULT_RECURINTERVAL ) + alert( "Invalid Recur Interval" ); + if( iCalParseEvent.recurUnits != DEFAULT_RECURUNITS ) + alert( "Invalid Recur Units" ); + if( iCalParseEvent.recurForever != DEFAULT_RECURFOREVER ) + alert( "Invalid Recur Forever" ); + var iCalTodoComponent = Components.classes["@mozilla.org/icaltodo;1"].createInstance(); var iCalTodo = iCalTodoComponent.QueryInterface(Components.interfaces.oeIICalTodo); @@ -778,4 +852,3 @@ function TestIcalString() return true; } - diff --git a/calendar/libxpical/oeICalImpl.cpp b/calendar/libxpical/oeICalImpl.cpp index 441dd85bf3e4..208e37429b22 100644 --- a/calendar/libxpical/oeICalImpl.cpp +++ b/calendar/libxpical/oeICalImpl.cpp @@ -322,7 +322,6 @@ oeICalImpl::Test(void) char uidstr[10]="900000000"; char icalrawcalendarstr[] = "BEGIN:VCALENDAR\n\ BEGIN:VEVENT\n\ -UID:900000000\n\ END:VEVENT\n\ END:VCALENDAR\n\ "; @@ -332,7 +331,7 @@ END:VCALENDAR\n\ #ifdef ICAL_DEBUG printf( "oeICalImpl::Test() failed: Cannot open stream: %s!\n", serveraddr ); #endif - return NS_OK; + return NS_ERROR_FAILURE; } icalcalendar = icalparser_parse_string(icalrawcalendarstr); @@ -340,15 +339,15 @@ END:VCALENDAR\n\ #ifdef ICAL_DEBUG printf( "oeICalImpl::Test() failed: Cannot create VCALENDAR!\n" ); #endif - return NS_OK; + return NS_ERROR_FAILURE; } - + icalevent = icalcomponent_get_first_component(icalcalendar,ICAL_VEVENT_COMPONENT); if ( !icalevent ) { #ifdef ICAL_DEBUG printf( "oeICalImpl::Test() failed: VEVENT not found!\n" ); #endif - return NS_OK; + return NS_ERROR_FAILURE; } icalproperty *uid = icalproperty_new_uid( uidstr ); @@ -487,7 +486,7 @@ END:VCALENDAR\n\ #ifdef ICAL_DEBUG printf( "oeICalImpl::Test() failed: Cannot fetch event!\n" ); #endif - return NS_OK; + return NS_ERROR_FAILURE; } icalcomponent *fetchedevent = icalcomponent_get_first_component( fetchedcal,ICAL_VEVENT_COMPONENT); @@ -495,7 +494,7 @@ END:VCALENDAR\n\ #ifdef ICAL_DEBUG printf( "oeICalImpl::Test() failed: VEVENT not found!\n" ); #endif - return NS_OK; + return NS_ERROR_FAILURE; } #ifdef ICAL_DEBUG @@ -509,7 +508,7 @@ END:VCALENDAR\n\ #ifdef ICAL_DEBUG printf( "oeICalImpl::Test() failed: UID not found!\n" ); #endif - return NS_OK; + return NS_ERROR_FAILURE; } #ifdef ICAL_DEBUG printf("id: %s\n", icalproperty_get_uid( tmpprop ) ); @@ -520,7 +519,7 @@ END:VCALENDAR\n\ #ifdef ICAL_DEBUG printf( "oeICalImpl::Test() failed: SUMMARY not found!\n" ); #endif - return NS_OK; + return NS_ERROR_FAILURE; } #ifdef ICAL_DEBUG printf("Title: %s\n", icalproperty_get_summary( tmpprop ) ); @@ -531,7 +530,7 @@ END:VCALENDAR\n\ #ifdef ICAL_DEBUG printf( "oeICalImpl::Test() failed: CATEGORIES not found!\n" ); #endif - return NS_OK; + return NS_ERROR_FAILURE; } #ifdef ICAL_DEBUG printf("Category: %s\n", icalproperty_get_categories( tmpprop ) ); @@ -542,7 +541,7 @@ END:VCALENDAR\n\ #ifdef ICAL_DEBUG printf( "oeICalImpl::Test() failed: DESCRIPTION not found!\n" ); #endif - return NS_OK; + return NS_ERROR_FAILURE; } #ifdef ICAL_DEBUG printf("Description: %s\n", icalproperty_get_description( tmpprop ) ); @@ -553,7 +552,7 @@ END:VCALENDAR\n\ #ifdef ICAL_DEBUG printf( "oeICalImpl::Test() failed: LOCATION not found!\n" ); #endif - return NS_OK; + return NS_ERROR_FAILURE; } #ifdef ICAL_DEBUG printf("Location: %s\n", icalproperty_get_location( tmpprop ) ); @@ -564,7 +563,7 @@ END:VCALENDAR\n\ #ifdef ICAL_DEBUG printf( "oeICalImpl::Test() failed: CLASS not found!\n" ); #endif - return NS_OK; + return NS_ERROR_FAILURE; } #ifdef ICAL_DEBUG printf("Class: %s\n", (icalproperty_get_class( tmpprop ) == ICAL_CLASS_PUBLIC) ? "PUBLIC" : "PRIVATE" ); @@ -575,7 +574,7 @@ END:VCALENDAR\n\ #ifdef ICAL_DEBUG printf( "oeICalImpl::Test() failed: DTSTART not found!\n" ); #endif - return NS_OK; + return NS_ERROR_FAILURE; } start = icalproperty_get_dtstart( tmpprop ); #ifdef ICAL_DEBUG @@ -587,7 +586,7 @@ END:VCALENDAR\n\ #ifdef ICAL_DEBUG printf( "oeICalImpl::Test() failed: DTEND not found!\n" ); #endif - return NS_OK; + return NS_ERROR_FAILURE; } end = icalproperty_get_dtstart( tmpprop ); #ifdef ICAL_DEBUG @@ -608,21 +607,22 @@ END:VCALENDAR\n\ #ifdef ICAL_DEBUG printf( "oeICalImpl::Test() failed: Cannot clone event!\n" ); #endif - return NS_OK; + return NS_ERROR_FAILURE; } + icalcomponent *newevent = icalcomponent_get_first_component( newcomp, ICAL_VEVENT_COMPONENT ); - if ( !tmpprop ) { + if ( !newevent ) { #ifdef ICAL_DEBUG printf( "oeICalImpl::Test() failed: VEVENT not found!\n" ); #endif - return NS_OK; + return NS_ERROR_FAILURE; } tmpprop = icalcomponent_get_first_property( newevent, ICAL_SUMMARY_PROPERTY ); if ( !tmpprop ) { #ifdef ICAL_DEBUG printf( "oeICalImpl::Test() failed: SUMMARY not found!\n" ); #endif - return NS_OK; + return NS_ERROR_FAILURE; } icalproperty_set_summary( tmpprop, "LUNCH AND LEARN TIME" ); // icalfileset_modify( stream, fetchedcal, newcomp ); @@ -641,7 +641,7 @@ END:VCALENDAR\n\ #ifdef ICAL_DEBUG printf( "oeICalImpl::Test() failed: Cannot fetch event!\n" ); #endif - return NS_OK; + return NS_ERROR_FAILURE; } icalfileset_remove_component( stream, fetchedcal ); @@ -655,7 +655,7 @@ END:VCALENDAR\n\ #endif } icalfileset_free(stream); - return NS_OK; + return NS_OK; } NS_IMETHODIMP