diff --git a/mozilla/calendar/libxpical/Makefile.in b/mozilla/calendar/libxpical/Makefile.in
deleted file mode 100644
index 41058c076b6..00000000000
--- a/mozilla/calendar/libxpical/Makefile.in
+++ /dev/null
@@ -1,100 +0,0 @@
-# ***** BEGIN LICENSE BLOCK *****
-# Version: MPL 1.1/GPL 2.0/LGPL 2.1
-#
-# The contents of this file are subject to the Mozilla Public License Version
-# 1.1 (the "License"); you may not use this file except in compliance with
-# the License. You may obtain a copy of the License at
-# http://www.mozilla.org/MPL/
-#
-# Software distributed under the License is distributed on an "AS IS" basis,
-# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
-# for the specific language governing rights and limitations under the
-# License.
-#
-# The Original Code is mozilla.org code.
-#
-# The Initial Developer of the Original Code is
-# Netscape Communications Corporation.
-# Portions created by the Initial Developer are Copyright (C) 2001
-# the Initial Developer. All Rights Reserved.
-#
-# Contributor(s):
-#
-# Alternatively, the contents of this file may be used under the terms of
-# either the GNU General Public License Version 2 or later (the "GPL"), or
-# the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
-# in which case the provisions of the GPL or the LGPL are applicable instead
-# of those above. If you wish to allow use of your version of this file only
-# under the terms of either the GPL or the LGPL, and not to allow others to
-# use your version of this file under the terms of the MPL, indicate your
-# decision by deleting the provisions above and replace them with the notice
-# and other provisions required by the GPL or the LGPL. If you do not delete
-# the provisions above, a recipient may use your version of this file under
-# the terms of any one of the MPL, the GPL or the LGPL.
-#
-# ***** END LICENSE BLOCK *****
-
-DEPTH = ../..
-topsrcdir = @top_srcdir@
-srcdir = @srcdir@
-VPATH = @srcdir@
-
-include $(DEPTH)/config/autoconf.mk
-
-MODULE = calendar
-LIBRARY_NAME = xpical
-EXPORT_LIBRARY = 1
-IS_COMPONENT = 1
-MODULE_NAME = oeICalModule
-MOZILLA_INTERNAL_API = 1
-
-REQUIRES = xpcom \
- appshell \
- string \
- timer \
- necko \
- msgcompose \
- addrbook \
- dom \
- pref \
- ical \
- icalss \
- $(NULL)
-
-XPIDLSRCS = oeIICal.idl
-
-CPPSRCS = \
- oeICalEventImpl.cpp \
- oeICalTodoImpl.cpp \
- oeICalFactory.cpp \
- oeICalImpl.cpp \
- oeICalContainerImpl.cpp \
- oeDateTimeImpl.cpp \
- $(NULL)
-
-CSRCS = \
- token.c \
- md5.c \
- $(NULL)
-
-EXTRA_DSO_LIBS = mozicalss mozical
-
-EXTRA_DSO_LDOPTS += \
- $(LIBS_DIR) \
- $(EXTRA_DSO_LIBS) \
- $(MOZ_COMPONENT_LIBS) \
- $(NULL)
-
-ifdef MOZ_MAIL_NEWS
-DEFINES += -DMOZ_MAIL_NEWS
-endif
-
-#DEFINES += -DICAL_DEBUG
-#-DICAL_DEBUG_ALL
-
-#ifdef ENABLE_TESTS
-DIRS += tests
-#endif
-
-include $(topsrcdir)/config/rules.mk
-
diff --git a/mozilla/calendar/libxpical/caltst.js b/mozilla/calendar/libxpical/caltst.js
deleted file mode 100644
index 151307be888..00000000000
--- a/mozilla/calendar/libxpical/caltst.js
+++ /dev/null
@@ -1,854 +0,0 @@
-/* ***** BEGIN LICENSE BLOCK *****
- * Version: MPL 1.1/GPL 2.0/LGPL 2.1
- *
- * The contents of this file are subject to the Mozilla Public License Version
- * 1.1 (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * Software distributed under the License is distributed on an "AS IS" basis,
- * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
- * for the specific language governing rights and limitations under the
- * License.
- *
- * The Original Code is OEone Corporation.
- *
- * The Initial Developer of the Original Code is
- * OEone Corporation.
- * Portions created by the Initial Developer are Copyright (C) 2001
- * the Initial Developer. All Rights Reserved.
- *
- * Contributor(s):
- * Mostafa Hosseini (mostafah@oeone.com)
- *
- * Alternatively, the contents of this file may be used under the terms of
- * either the GNU General Public License Version 2 or later (the "GPL"), or
- * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
- * in which case the provisions of the GPL or the LGPL are applicable instead
- * of those above. If you wish to allow use of your version of this file only
- * under the terms of either the GPL or the LGPL, and not to allow others to
- * use your version of this file under the terms of the MPL, indicate your
- * decision by deleting the provisions above and replace them with the notice
- * and other provisions required by the GPL or the LGPL. If you do not delete
- * the provisions above, a recipient may use your version of this file under
- * the terms of any one of the MPL, the GPL or the LGPL.
- *
- * ***** END LICENSE BLOCK ***** */
-
-const DEFAULT_SERVER="file:///tmp/.oecalendar";
-const DEFAULT_TITLE="Lunch Time";
-const DEFAULT_DESCRIPTION = "Will be out for one hour";
-const DEFAULT_LOCATION = "Restaurant";
-const DEFAULT_CATEGORY = "Personal";
-const DEFAULT_EMAIL = "mostafah@oeone.com";
-const DEFAULT_PRIVATE = false;
-const DEFAULT_ALLDAY = false;
-const DEFAULT_ALARM = true;
-const DEFAULT_ALARMUNITS = "minutes";
-const DEFAULT_ALARMLENGTH = 5;
-const DEFAULT_RECUR = true;
-const DEFAULT_RECURINTERVAL = 7;
-const DEFAULT_RECURUNITS = "days";
-const DEFAULT_RECURFOREVER = true;
-const DEFAULT_ATTACHMENT = DEFAULT_SERVER;
-
-var iCalLib = null;
-var gObserver = null;
-var gTodoObserver = null;
-
-function Observer()
-{
-}
-
-Observer.prototype.onAddItem = function( icalevent )
-{
- dump( "Observer.prototype.onAddItem\n" );
-}
-
-Observer.prototype.onModifyItem = function( icalevent, oldevent )
-{
- dump( "Observer.prototype.onModifyItem\n" );
-}
-
-Observer.prototype.onDeleteItem = function( icalevent )
-{
- dump( "Observer.prototype.onDeleteItem\n" );
-}
-
-Observer.prototype.onAlarm = function( icalevent )
-{
- dump( "Observer.prototype.onAlarm\n" );
-}
-
-Observer.prototype.onLoad = function()
-{
- dump( "Observer.prototype.onLoad\n" );
-}
-
-Observer.prototype.onStartBatch = function()
-{
- dump( "Observer.prototype.onStartBatch\n" );
-}
-
-Observer.prototype.onEndBatch = function()
-{
- dump( "Observer.prototype.onEndBatch\n" );
-}
-
-function Test()
-{
- netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
- if( iCalLib == null ) {
- var iCalLibComponent = Components.classes["@mozilla.org/ical;1"].createInstance();
- iCalLib = iCalLibComponent.QueryInterface(Components.interfaces.oeIICal);
- }
-
- iCalLib.server = DEFAULT_SERVER;
- iCalLib.Test();
- alert( "Finished Test" );
-}
-
-function TestAll()
-{
- netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
- if( iCalLib == null ) {
- var iCalLibComponent = Components.classes["@mozilla.org/ical;1"].createInstance();
- iCalLib = iCalLibComponent.QueryInterface(Components.interfaces.oeIICal);
- }
- if( gObserver == null ) {
- gObserver = new Observer();
- iCalLib.addObserver( gObserver );
- }
- if( gTodoObserver == null ) {
- gTodoObserver = new Observer();
- iCalLib.addTodoObserver( gTodoObserver );
- }
- if( !TestTimeConversion() ) {
- alert( "Stopped Test" );
- return;
- }
-
- iCalLib.server = DEFAULT_SERVER;
- var id = TestAddEvent();
- if( id == 0 ) {
- alert( "Stopped Test" );
- return;
- }
- var iCalEvent = TestFetchEvent( id );
- if( iCalEvent == null ) {
- alert( "Stopped Test" );
- return;
- }
- id = TestUpdateEvent( iCalEvent );
-// TestSearchEvent();
- TestDeleteEvent( id );
- TestRecurring();
-
- //Todo tests
- var id = TestAddTodo();
- var iCalTodo = TestFetchTodo( id );
- id = TestUpdateTodo( iCalTodo );
- TestDeleteTodo( id );
- TestFilterTodo( id );
- TestIcalString();
- alert( "Finished Test" );
-}
-
-function TestTimeConversion() {
- netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
- var dateTimeComponent = Components.classes["@mozilla.org/oedatetime;1"].createInstance();
- dateTime = dateTimeComponent.QueryInterface(Components.interfaces.oeIDateTime);
- var date1 = new Date();
- dateTime.setTime( date1 );
- var date1inms = parseInt( date1.getTime()/1000 );
- if( (dateTime.getTime()/1000) != date1inms ) {
- alert( "TestTimeConversion(): Step1 failed" );
- return false;
- }
- date1 = new Date( 1970, 0, 1, 0, 0, 0 );
- dateTime.setTime( date1 );
- date1inms = parseInt( date1.getTime()/1000 );
- if( (dateTime.getTime()/1000) != date1inms ) {
- alert( "TestTimeConversion(): Step2 failed" );
- return false;
- }
- date1 = new Date( 1969, 11, 31, 23, 59, 59 );
- dateTime.setTime( date1 );
- date1inms = parseInt( date1.getTime()/1000 );
- if( (dateTime.getTime()/1000) != date1inms ) {
- alert( "TestTimeConversion(): Step3 failed" );
- return false;
- }
- date1 = new Date( 1969, 11, 31, 19, 0, 0 );
- dateTime.setTime( date1 );
- date1inms = parseInt( date1.getTime()/1000 );
- if( (dateTime.getTime()/1000) != date1inms ) {
- alert( "TestTimeConversion(): Step4 failed" );
- return false;
- }
- date1 = new Date( 1962, 7, 03, 0, 0, 0 );
- dateTime.setTime( date1 );
- date1inms = parseInt( date1.getTime()/1000 );
- if( (dateTime.getTime()/1000) != date1inms ) {
- alert( "TestTimeConversion(): Step5 failed" );
- return false;
- }
- if( dateTime.hour != date1.getHours() ) {
- alert( "TestTimeConversion(): Step6 failed" );
- return false;
- }
- return true;
-}
-
-function TestAddEvent()
-{
- var iCalEventComponent = Components.classes["@mozilla.org/icalevent;1"].createInstance();
-
- var iCalEvent = iCalEventComponent.QueryInterface(Components.interfaces.oeIICalEvent);
-
- 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 );
-
- Attachment = Components.classes["@mozilla.org/messengercompose/attachment;1"].createInstance( Components.interfaces.nsIMsgAttachment );
- Attachment.url = DEFAULT_ATTACHMENT;
- iCalEvent.addAttachment( Attachment );
-
- Contact = Components.classes["@mozilla.org/addressbook/cardproperty;1"].createInstance( Components.interfaces.nsIAbCard );
- Contact.primaryEmail = DEFAULT_EMAIL;
- iCalEvent.addContact( Contact );
-
- var id = iCalLib.addEvent( iCalEvent );
-
- if( id == null ){
- alert( "TestAddEvent(): Invalid Id" );
- return 0;
- }
- if( iCalEvent.title != DEFAULT_TITLE ){
- alert( "TestAddEvent(): Invalid Title" );
- return 0;
- }
- if( iCalEvent.description != DEFAULT_DESCRIPTION ){
- alert( "TestAddEvent(): Invalid Description" );
- return 0;
- }
- if( iCalEvent.location != DEFAULT_LOCATION ){
- alert( "TestAddEvent(): Invalid Location" );
- return 0;
- }
- if( iCalEvent.categories != DEFAULT_CATEGORY ){
- alert( "TestAddEvent(): Invalid Category" );
- return 0;
- }
- if( iCalEvent.privateEvent != DEFAULT_PRIVATE ){
- alert( "TestAddEvent(): Invalid PrivateEvent Setting" );
- return 0;
- }
- if( iCalEvent.allDay != DEFAULT_ALLDAY ){
- alert( "TestAddEvent(): Invalid AllDay Setting" );
- return 0;
- }
- if( iCalEvent.alarm != DEFAULT_ALARM ){
- alert( "TestAddEvent(): Invalid Alarm Setting" );
- return 0;
- }
- if( iCalEvent.alarmUnits != DEFAULT_ALARMUNITS ){
- alert( "TestAddEvent(): Invalid Alarm Units" );
- return 0;
- }
- if( iCalEvent.alarmLength != DEFAULT_ALARMLENGTH ){
- alert( "TestAddEvent(): Invalid Alarm Length" );
- return 0;
- }
- if( iCalEvent.alarmEmailAddress != DEFAULT_EMAIL ){
- alert( "TestAddEvent(): Invalid Alarm Email Address" );
- return 0;
- }
- if( iCalEvent.inviteEmailAddress != DEFAULT_EMAIL ){
- alert( "TestAddEvent(): Invalid Invite Email Address" );
- return 0;
- }
- if( iCalEvent.recur != DEFAULT_RECUR ){
- alert( "TestAddEvent(): Invalid Recur Setting" );
- return 0;
- }
- if( iCalEvent.recurInterval != DEFAULT_RECURINTERVAL ){
- alert( "TestAddEvent(): Invalid Recur Interval" );
- return 0;
- }
- if( iCalEvent.recurUnits != DEFAULT_RECURUNITS ){
- alert( "TestAddEvent(): Invalid Recur Units" );
- return 0;
- }
- if( iCalEvent.recurForever != DEFAULT_RECURFOREVER ){
- alert( "TestAddEvent(): Invalid Recur Forever" );
- return 0;
- }
-
- //TODO: Check for start and end date
-
- return id;
-}
-
-function TestFetchEvent( id )
-{
- var iCalEvent = iCalLib.fetchEvent( id );
- if( id == null ){
- alert( "TestFetchEvent(): Invalid Id" );
- return null;
- }
- if( iCalEvent.title != DEFAULT_TITLE ){
- alert( "TestFetchEvent(): Invalid Title" );
- return null;
- }
- if( iCalEvent.description != DEFAULT_DESCRIPTION ){
- alert( "TestFetchEvent(): Invalid Description" );
- return null;
- }
- if( iCalEvent.location != DEFAULT_LOCATION ){
- alert( "TestFetchEvent(): Invalid Location" );
- return null;
- }
- if( iCalEvent.categories != DEFAULT_CATEGORY ){
- alert( "TestFetchEvent(): Invalid Category" );
- return null;
- }
- if( iCalEvent.privateEvent != DEFAULT_PRIVATE ){
- alert( "TestFetchEvent(): Invalid PrivateEvent Setting" );
- return null;
- }
- if( iCalEvent.allDay != DEFAULT_ALLDAY ){
- alert( "TestFetchEvent(): Invalid AllDay Setting" );
- return null;
- }
- if( iCalEvent.alarm != DEFAULT_ALARM ){
- alert( "TestFetchEvent(): Invalid Alarm Setting" );
- return null;
- }
- if( iCalEvent.alarmUnits != DEFAULT_ALARMUNITS ){
- alert( "TestFetchEvent(): Invalid Alarm Units" );
- return null;
- }
- if( iCalEvent.alarmLength != DEFAULT_ALARMLENGTH ){
- alert( "TestFetchEvent(): Invalid Alarm Length" );
- return null;
- }
- if( iCalEvent.alarmEmailAddress != DEFAULT_EMAIL ){
- alert( "TestFetchEvent(): Invalid Alarm Email Address" );
- return null;
- }
- if( iCalEvent.inviteEmailAddress != DEFAULT_EMAIL ){
- alert( "TestFetchEvent(): Invalid Invite Email Address" );
- return null;
- }
- if( iCalEvent.recur != DEFAULT_RECUR ){
- alert( "TestFetchEvent(): Invalid Recur Setting" );
- return null;
- }
- if( iCalEvent.recurInterval != DEFAULT_RECURINTERVAL ){
- alert( "TestFetchEvent(): Invalid Recur Interval" );
- return null;
- }
- if( iCalEvent.recurUnits != DEFAULT_RECURUNITS ){
- alert( "TestFetchEvent(): Invalid Recur Units" );
- return null;
- }
- if( iCalEvent.recurForever != DEFAULT_RECURFOREVER ){
- alert( "TestFetchEvent(): Invalid Recur Forever" );
- return null;
- }
- if( !iCalEvent.attachmentsArray.Count() ) {
- alert( "TestFetchEvent(): No attachment found" );
- return null;
- }
- attachment = iCalEvent.attachmentsArray.QueryElementAt( 0, Components.interfaces.nsIMsgAttachment );
- if ( attachment.url != DEFAULT_ATTACHMENT ) {
- alert( "TestFetchEvent(): Invalid attachment" );
- return null;
- }
- //TODO: Check for start and end date
-
- return iCalEvent;
-}
-
-function TestUpdateEvent( iCalEvent )
-{
- iCalEvent.title = DEFAULT_TITLE+"*NEW*";
- iCalEvent.description = DEFAULT_DESCRIPTION+"*NEW*";
- iCalEvent.location = DEFAULT_LOCATION+"*NEW*";
- iCalEvent.categories = DEFAULT_CATEGORY+"*NEW*";
- iCalEvent.privateEvent = !DEFAULT_PRIVATE;
- iCalEvent.allDay = !DEFAULT_ALLDAY;
- iCalEvent.alarm = !DEFAULT_ALARM;
-
- iCalEvent.recur = !DEFAULT_RECUR;
-
- iCalEvent.start.year = 2002;
- iCalEvent.start.month = 11; //December
- iCalEvent.start.day = 2;
- iCalEvent.start.hour = 13;
- iCalEvent.start.minute = 25;
-
- iCalEvent.end.year = 2002;
- iCalEvent.end.month = 11; //December
- iCalEvent.end.day = 2;
- iCalEvent.end.hour = 14;
- iCalEvent.end.minute = 25;
-
- var id = iCalLib.modifyEvent( iCalEvent );
-
- if( id == null )
- alert( "TestUpdateEvent(): Invalid Id" );
- if( iCalEvent.title != DEFAULT_TITLE+"*NEW*" )
- alert( "TestUpdateEvent(): Invalid Title" );
- if( iCalEvent.description != DEFAULT_DESCRIPTION+"*NEW*" )
- alert( "TestUpdateEvent(): Invalid Description" );
- if( iCalEvent.location != DEFAULT_LOCATION+"*NEW*" )
- alert( "TestUpdateEvent(): Invalid Location" );
- if( iCalEvent.categories != DEFAULT_CATEGORY+"*NEW*" )
- alert( "TestUpdateEvent(): Invalid Category" );
- if( iCalEvent.privateEvent != !DEFAULT_PRIVATE )
- alert( "TestUpdateEvent(): Invalid PrivateEvent Setting" );
- if( iCalEvent.allDay != !DEFAULT_ALLDAY )
- alert( "TestUpdateEvent(): Invalid AllDay Setting" );
- if( iCalEvent.alarm != !DEFAULT_ALARM )
- alert( "TestUpdateEvent(): Invalid Alarm Setting" );
- if( iCalEvent.recur != !DEFAULT_RECUR )
- alert( "TestUpdateEvent(): Invalid Recur Setting" );
-
- //TODO check start and end dates
-
- return id;
-}
-/*
-function TestSearchEvent()
-{
- result = iCalLib.SearchBySQL( "SELECT * FROM VEVENT WHERE CATEGORIES = 'Personal'" );
- alert( "Result : " + result );
-}*/
-
-function TestDeleteEvent( id )
-{
- iCalLib.deleteEvent( id );
-
- var iCalEvent = iCalLib.fetchEvent( id );
-
- if( iCalEvent != null )
- alert( "Delete failed" );
-}
-
-function TestRecurring() {
- var iCalEventComponent = Components.classes["@mozilla.org/icalevent;1"].createInstance();
- this.iCalEvent = iCalEventComponent.QueryInterface(Components.interfaces.oeIICalEvent);
-
- iCalEvent.allDay = true;
- iCalEvent.recur = true;
- iCalEvent.recurInterval = 1;
- iCalEvent.recurUnits = "years";
- iCalEvent.recurForever = true;
-
- iCalEvent.start.year = 2001;
- iCalEvent.start.month = 0;
- iCalEvent.start.day = 1;
- iCalEvent.start.hour = 0;
- iCalEvent.start.minute = 0;
-
- iCalEvent.end.year = 2001;
- iCalEvent.end.month = 0;
- iCalEvent.end.day = 1;
- iCalEvent.end.hour = 23;
- iCalEvent.end.minute = 59;
-
- var id = iCalLib.addEvent( iCalEvent );
-
- var displayDates = new Object();
- var checkdate = new Date( 2002, 0, 1, 0, 0, 0 );
- var eventList = iCalLib.getEventsForDay( checkdate );
-
- if( !eventList.hasMoreElements() )
- alert( "Yearly Recur Test Failed" );
-
- iCalLib.deleteEvent( id );
-}
-
-function TestAddTodo()
-{
- var iCalTodoComponent = Components.classes["@mozilla.org/icaltodo;1"].createInstance();
-
- var iCalTodo = iCalTodoComponent.QueryInterface(Components.interfaces.oeIICalTodo);
-
- iCalTodo.title = DEFAULT_TITLE;
- iCalTodo.description = DEFAULT_DESCRIPTION;
- iCalTodo.location = DEFAULT_LOCATION;
- iCalTodo.categories = DEFAULT_CATEGORY;
- iCalTodo.privateEvent = DEFAULT_PRIVATE;
- iCalTodo.allDay = DEFAULT_ALLDAY;
- iCalTodo.alarm = DEFAULT_ALARM;
- iCalTodo.alarmUnits = DEFAULT_ALARMUNITS;
- iCalTodo.alarmLength = DEFAULT_ALARMLENGTH;
- iCalTodo.alarmEmailAddress = DEFAULT_EMAIL;
- iCalTodo.inviteEmailAddress = DEFAULT_EMAIL;
-
- iCalTodo.recur = DEFAULT_RECUR;
- iCalTodo.recurInterval = DEFAULT_RECURINTERVAL;
- iCalTodo.recurUnits = DEFAULT_RECURUNITS;
- iCalTodo.recurForever = DEFAULT_RECURFOREVER;
-
- iCalTodo.start.year = 2001;
- iCalTodo.start.month = 10; //November
- iCalTodo.start.day = 1;
- iCalTodo.start.hour = 12;
- iCalTodo.start.minute = 24;
-
- iCalTodo.due.year = 2001;
- iCalTodo.due.month = 11; //December
- iCalTodo.due.day = 1;
- iCalTodo.due.hour = 23;
- iCalTodo.due.minute = 59;
-
- var id = iCalLib.addTodo( iCalTodo );
-
- if( id == null )
- alert( "TestAddTodo(): Invalid Id" );
- if( iCalTodo.title != DEFAULT_TITLE )
- alert( "TestAddTodo(): Invalid Title" );
- if( iCalTodo.description != DEFAULT_DESCRIPTION )
- alert( "TestAddTodo(): Invalid Description" );
- if( iCalTodo.location != DEFAULT_LOCATION )
- alert( "TestAddTodo(): Invalid Location" );
- if( iCalTodo.categories != DEFAULT_CATEGORY )
- alert( "TestAddTodo(): Invalid Category" );
- if( iCalTodo.privateEvent != DEFAULT_PRIVATE )
- alert( "TestAddTodo(): Invalid PrivateEvent Setting" );
- if( iCalTodo.allDay != DEFAULT_ALLDAY )
- alert( "TestAddTodo(): Invalid AllDay Setting" );
- if( iCalTodo.alarm != DEFAULT_ALARM )
- alert( "TestAddTodo(): Invalid Alarm Setting" );
- if( iCalTodo.alarmUnits != DEFAULT_ALARMUNITS )
- alert( "TestAddTodo(): Invalid Alarm Units" );
- if( iCalTodo.alarmLength != DEFAULT_ALARMLENGTH )
- alert( "TestAddTodo(): Invalid Alarm Length" );
- if( iCalTodo.alarmEmailAddress != DEFAULT_EMAIL )
- alert( "TestAddTodo(): Invalid Alarm Email Address" );
- if( iCalTodo.inviteEmailAddress != DEFAULT_EMAIL )
- alert( "TestAddTodo(): Invalid Invite Email Address" );
- if( iCalTodo.recur != DEFAULT_RECUR )
- alert( "TestAddTodo(): Invalid Recur Setting" );
- if( iCalTodo.recurInterval != DEFAULT_RECURINTERVAL )
- alert( "TestAddTodo(): Invalid Recur Interval" );
- if( iCalTodo.recurUnits != DEFAULT_RECURUNITS )
- alert( "TestAddTodo(): Invalid Recur Units" );
- if( iCalTodo.recurForever != DEFAULT_RECURFOREVER )
- alert( "TestAddTodo(): Invalid Recur Forever" );
-
- //TODO: Check for start and end date
-
- return id;
-}
-
-function TestFetchTodo( id )
-{
- var iCalEvent = iCalLib.fetchTodo( id );
- if( id == null )
- alert( "TestFetchTodo(): Invalid Id" );
- if( iCalEvent.title != DEFAULT_TITLE )
- alert( "TestFetchTodo(): Invalid Title" );
- if( iCalEvent.description != DEFAULT_DESCRIPTION )
- alert( "TestFetchTodo(): Invalid Description" );
- if( iCalEvent.location != DEFAULT_LOCATION )
- alert( "TestFetchTodo(): Invalid Location" );
- if( iCalEvent.categories != DEFAULT_CATEGORY )
- alert( "TestFetchTodo(): Invalid Category" );
- if( iCalEvent.privateEvent != DEFAULT_PRIVATE )
- alert( "TestFetchTodo(): Invalid PrivateEvent Setting" );
- if( iCalEvent.allDay != DEFAULT_ALLDAY )
- alert( "TestFetchTodo(): Invalid AllDay Setting" );
- if( iCalEvent.alarm != DEFAULT_ALARM )
- alert( "TestFetchTodo(): Invalid Alarm Setting" );
- if( iCalEvent.alarmUnits != DEFAULT_ALARMUNITS )
- alert( "TestFetchTodo(): Invalid Alarm Units" );
- if( iCalEvent.alarmLength != DEFAULT_ALARMLENGTH )
- alert( "TestFetchTodo(): Invalid Alarm Length" );
- if( iCalEvent.alarmEmailAddress != DEFAULT_EMAIL )
- alert( "TestFetchTodo(): Invalid Alarm Email Address" );
- if( iCalEvent.inviteEmailAddress != DEFAULT_EMAIL )
- alert( "TestFetchTodo(): Invalid Invite Email Address" );
- if( iCalEvent.recur != DEFAULT_RECUR )
- alert( "TestFetchTodo(): Invalid Recur Setting" );
- if( iCalEvent.recurInterval != DEFAULT_RECURINTERVAL )
- alert( "TestFetchTodo(): Invalid Recur Interval" );
- if( iCalEvent.recurUnits != DEFAULT_RECURUNITS )
- alert( "TestFetchTodo(): Invalid Recur Units" );
- if( iCalEvent.recurForever != DEFAULT_RECURFOREVER )
- alert( "TestFetchTodo(): Invalid Recur Forever" );
-
- //TODO: Check for start and end date
-
- return iCalEvent;
-}
-
-function TestUpdateTodo( iCalTodo )
-{
- iCalTodo.title = DEFAULT_TITLE+"*NEW*";
- iCalTodo.description = DEFAULT_DESCRIPTION+"*NEW*";
- iCalTodo.location = DEFAULT_LOCATION+"*NEW*";
- iCalTodo.categories = DEFAULT_CATEGORY+"*NEW*";
- iCalTodo.privateEvent = !DEFAULT_PRIVATE;
- iCalTodo.allDay = !DEFAULT_ALLDAY;
- iCalTodo.alarm = !DEFAULT_ALARM;
-
- iCalTodo.recur = !DEFAULT_RECUR;
-
- iCalTodo.start.year = 2002;
- iCalTodo.start.month = 0; //January
- iCalTodo.start.day = 2;
- iCalTodo.start.hour = 13;
- iCalTodo.start.minute = 25;
-
- var id = iCalLib.modifyTodo( iCalTodo );
-
- if( id == null )
- alert( "TestUpdateTodo(): Invalid Id" );
- if( iCalTodo.title != DEFAULT_TITLE+"*NEW*" )
- alert( "TestUpdateTodo(): Invalid Title" );
- if( iCalTodo.description != DEFAULT_DESCRIPTION+"*NEW*" )
- alert( "TestUpdateTodo(): Invalid Description" );
- if( iCalTodo.location != DEFAULT_LOCATION+"*NEW*" )
- alert( "TestUpdateTodo(): Invalid Location" );
- if( iCalTodo.categories != DEFAULT_CATEGORY+"*NEW*" )
- alert( "TestUpdateTodo(): Invalid Category" );
- if( iCalTodo.privateEvent != !DEFAULT_PRIVATE )
- alert( "TestUpdateTodo(): Invalid PrivateEvent Setting" );
- if( iCalTodo.allDay != !DEFAULT_ALLDAY )
- alert( "TestUpdateTodo(): Invalid AllDay Setting" );
- if( iCalTodo.alarm != !DEFAULT_ALARM )
- alert( "TestUpdateTodo(): Invalid Alarm Setting" );
- if( iCalTodo.recur != !DEFAULT_RECUR )
- alert( "TestUpdateTodo(): Invalid Recur Setting" );
-
- //TODO check start and end dates
-
- return id;
-}
-
-function TestDeleteTodo( id )
-{
- iCalLib.deleteTodo( id );
-
- var iCalEvent = iCalLib.fetchTodo( id );
-
- if( iCalEvent != null )
- alert( "Delete failed" );
-}
-
-function TestFilterTodo()
-{
- var iCalTodoComponent = Components.classes["@mozilla.org/icaltodo;1"].createInstance();
-
- var iCalTodo = iCalTodoComponent.QueryInterface(Components.interfaces.oeIICalTodo);
-
- iCalTodo.start.year = 2002;
- iCalTodo.start.month = 0;
- iCalTodo.start.day = 1;
- iCalTodo.start.hour = 0;
- iCalTodo.start.minute = 0;
-
- iCalTodo.due.year = 2003;
- iCalTodo.due.month = 0;
- iCalTodo.due.day = 1;
- iCalTodo.due.hour = 0;
- iCalTodo.due.minute = 0;
-
- var id = iCalLib.addTodo( iCalTodo );
-
- var todoList = this.iCalLib.getAllTodos();
-
- if ( !todoList.hasMoreElements() ) {
- alert( "TestFilterTodo-Step1: failed" );
- return;
- }
-
- var now = Date();
-
- iCalLib.filter.completed.setTime( now );
-
- todoList = this.iCalLib.getAllTodos();
-
- if ( !todoList.hasMoreElements() ) {
- alert( "TestFilterTodo-Step2: failed" );
- return;
- }
-
- iCalTodo.completed.setTime( now );
-
- now = Date();
- iCalLib.filter.completed.setTime( now );
-
- todoList = this.iCalLib.getAllTodos();
-
- if ( todoList.hasMoreElements() ) {
- alert( "TestFilterTodo-Step3: failed" );
- return;
- }
-
- iCalTodo.completed.clear();
-
- todoList = this.iCalLib.getAllTodos();
-
- if ( !todoList.hasMoreElements() ) {
- alert( "TestFilterTodo-Step4: failed" );
- return;
- }
-
- iCalLib.deleteTodo( id );
-}
-
-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);
-
- iCalTodo.title = DEFAULT_TITLE;
- iCalTodo.description = DEFAULT_DESCRIPTION;
- iCalTodo.location = DEFAULT_LOCATION;
- iCalTodo.categories = DEFAULT_CATEGORY;
- iCalTodo.privateEvent = DEFAULT_PRIVATE;
-
- iCalTodo.start.year = 2001;
- iCalTodo.start.month = 10; //November
- iCalTodo.start.day = 1;
- iCalTodo.start.hour = 12;
- iCalTodo.start.minute = 24;
-
- iCalTodo.due.year = 2001;
- iCalTodo.due.month = 11; //December
- iCalTodo.due.day = 1;
- iCalTodo.due.hour = 23;
- iCalTodo.due.minute = 59;
-
- iCalTodo.id = 999999999;
-
- var icalstring = iCalTodo.getTodoIcalString();
- iCalTodo.parseTodoIcalString( icalstring );
-
- if( iCalTodo.id == null )
- alert( "TestAddTodo(): Invalid Id" );
- if( iCalTodo.title != DEFAULT_TITLE )
- alert( "TestAddTodo(): Invalid Title" );
- if( iCalTodo.description != DEFAULT_DESCRIPTION )
- alert( "TestAddTodo(): Invalid Description" );
- if( iCalTodo.location != DEFAULT_LOCATION )
- alert( "TestAddTodo(): Invalid Location" );
- if( iCalTodo.categories != DEFAULT_CATEGORY )
- alert( "TestAddTodo(): Invalid Category" );
- if( iCalTodo.privateEvent != DEFAULT_PRIVATE )
- alert( "TestAddTodo(): Invalid PrivateEvent Setting" );
-
- //TODO: Check for start and end date
-
- return true;
-}
diff --git a/mozilla/calendar/libxpical/caltst.xul b/mozilla/calendar/libxpical/caltst.xul
deleted file mode 100644
index 5172856e0c0..00000000000
--- a/mozilla/calendar/libxpical/caltst.xul
+++ /dev/null
@@ -1,61 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/mozilla/calendar/libxpical/md5.c b/mozilla/calendar/libxpical/md5.c
deleted file mode 100644
index fe27c4539a5..00000000000
--- a/mozilla/calendar/libxpical/md5.c
+++ /dev/null
@@ -1,263 +0,0 @@
-/*
- * This code implements the MD5 message-digest algorithm.
- * The algorithm is due to Ron Rivest. This code was
- * written by Colin Plumb in 1993, no copyright is claimed.
- * This code is in the public domain; do with it what you wish.
- *
- * Equivalent code is available from RSA Data Security, Inc.
- * This code has been tested against that, and is equivalent,
- * except that you don't need to include two pages of legalese
- * with every copy.
- *
- * To compute the message digest of a chunk of bytes, declare an
- * MD5Context structure, pass it to MD5Init, call MD5Update as
- * needed on buffers full of bytes, and then call MD5Final, which
- * will fill a supplied 16-byte array with the digest.
- */
-
-/* Brutally hacked by John Walker back from ANSI C to K&R (no
- prototypes) to maintain the tradition that Netfone will compile
- with Sun's original "cc". */
-
-#include /* for memcpy() */
-#include "md5.h"
-
-#ifdef sgi
-#define HIGHFIRST
-#endif
-
-#ifdef sun
-#define HIGHFIRST
-#endif
-
-#ifndef HIGHFIRST
-#define byteReverse(buf, len) /* Nothing */
-#else
-/*
- * Note: this code is harmless on little-endian machines.
- */
-void byteReverse(buf, longs)
- unsigned char *buf; unsigned longs;
-{
- uint32 t;
- do {
- t = (uint32) ((unsigned) buf[3] << 8 | buf[2]) << 16 |
- ((unsigned) buf[1] << 8 | buf[0]);
- *(uint32 *) buf = t;
- buf += 4;
- } while (--longs);
-}
-#endif
-
-/*
- * Start MD5 accumulation. Set bit count to 0 and buffer to mysterious
- * initialization constants.
- */
-void MD5Init(ctx)
- struct MD5Context *ctx;
-{
- ctx->buf[0] = 0x67452301;
- ctx->buf[1] = 0xefcdab89;
- ctx->buf[2] = 0x98badcfe;
- ctx->buf[3] = 0x10325476;
-
- ctx->bits[0] = 0;
- ctx->bits[1] = 0;
-}
-
-/*
- * Update context to reflect the concatenation of another buffer full
- * of bytes.
- */
-void MD5Update(ctx, buf, len)
- struct MD5Context *ctx; unsigned char *buf; unsigned len;
-{
- uint32 t;
-
- /* Update bitcount */
-
- t = ctx->bits[0];
- if ((ctx->bits[0] = t + ((uint32) len << 3)) < t)
- ctx->bits[1]++; /* Carry from low to high */
- ctx->bits[1] += len >> 29;
-
- t = (t >> 3) & 0x3f; /* Bytes already in shsInfo->data */
-
- /* Handle any leading odd-sized chunks */
-
- if (t) {
- unsigned char *p = (unsigned char *) ctx->in + t;
-
- t = 64 - t;
- if (len < t) {
- memcpy(p, buf, len);
- return;
- }
- memcpy(p, buf, t);
- byteReverse(ctx->in, 16);
- MD5Transform(ctx->buf, (uint32 *) ctx->in);
- buf += t;
- len -= t;
- }
- /* Process data in 64-byte chunks */
-
- while (len >= 64) {
- memcpy(ctx->in, buf, 64);
- byteReverse(ctx->in, 16);
- MD5Transform(ctx->buf, (uint32 *) ctx->in);
- buf += 64;
- len -= 64;
- }
-
- /* Handle any remaining bytes of data. */
-
- memcpy(ctx->in, buf, len);
-}
-
-/*
- * Final wrapup - pad to 64-byte boundary with the bit pattern
- * 1 0* (64-bit count of bits processed, MSB-first)
- */
-void MD5Final(digest, ctx)
- unsigned char digest[16]; struct MD5Context *ctx;
-{
- unsigned count;
- unsigned char *p;
-
- /* Compute number of bytes mod 64 */
- count = (ctx->bits[0] >> 3) & 0x3F;
-
- /* Set the first char of padding to 0x80. This is safe since there is
- always at least one byte free */
- p = ctx->in + count;
- *p++ = 0x80;
-
- /* Bytes of padding needed to make 64 bytes */
- count = 64 - 1 - count;
-
- /* Pad out to 56 mod 64 */
- if (count < 8) {
- /* Two lots of padding: Pad the first block to 64 bytes */
- memset(p, 0, count);
- byteReverse(ctx->in, 16);
- MD5Transform(ctx->buf, (uint32 *) ctx->in);
-
- /* Now fill the next block with 56 bytes */
- memset(ctx->in, 0, 56);
- } else {
- /* Pad block to 56 bytes */
- memset(p, 0, count - 8);
- }
- byteReverse(ctx->in, 14);
-
- /* Append length in bits and transform */
- ((uint32 *) ctx->in)[14] = ctx->bits[0];
- ((uint32 *) ctx->in)[15] = ctx->bits[1];
-
- MD5Transform(ctx->buf, (uint32 *) ctx->in);
- byteReverse((unsigned char *) ctx->buf, 4);
- memcpy(digest, ctx->buf, 16);
- memset(ctx, 0, sizeof(ctx)); /* In case it's sensitive */
-}
-
-
-/* The four core functions - F1 is optimized somewhat */
-
-/* #define F1(x, y, z) (x & y | ~x & z) */
-#define F1(x, y, z) (z ^ (x & (y ^ z)))
-#define F2(x, y, z) F1(z, x, y)
-#define F3(x, y, z) (x ^ y ^ z)
-#define F4(x, y, z) (y ^ (x | ~z))
-
-/* This is the central step in the MD5 algorithm. */
-#define MD5STEP(f, w, x, y, z, data, s) \
- ( w += f(x, y, z) + data, w = w<>(32-s), w += x )
-
-/*
- * The core of the MD5 algorithm, this alters an existing MD5 hash to
- * reflect the addition of 16 longwords of new data. MD5Update blocks
- * the data and converts bytes into longwords for this routine.
- */
-void MD5Transform(buf, in)
- uint32 buf[4]; uint32 in[16];
-{
- register uint32 a, b, c, d;
-
- a = buf[0];
- b = buf[1];
- c = buf[2];
- d = buf[3];
-
- MD5STEP(F1, a, b, c, d, in[0] + 0xd76aa478, 7);
- MD5STEP(F1, d, a, b, c, in[1] + 0xe8c7b756, 12);
- MD5STEP(F1, c, d, a, b, in[2] + 0x242070db, 17);
- MD5STEP(F1, b, c, d, a, in[3] + 0xc1bdceee, 22);
- MD5STEP(F1, a, b, c, d, in[4] + 0xf57c0faf, 7);
- MD5STEP(F1, d, a, b, c, in[5] + 0x4787c62a, 12);
- MD5STEP(F1, c, d, a, b, in[6] + 0xa8304613, 17);
- MD5STEP(F1, b, c, d, a, in[7] + 0xfd469501, 22);
- MD5STEP(F1, a, b, c, d, in[8] + 0x698098d8, 7);
- MD5STEP(F1, d, a, b, c, in[9] + 0x8b44f7af, 12);
- MD5STEP(F1, c, d, a, b, in[10] + 0xffff5bb1, 17);
- MD5STEP(F1, b, c, d, a, in[11] + 0x895cd7be, 22);
- MD5STEP(F1, a, b, c, d, in[12] + 0x6b901122, 7);
- MD5STEP(F1, d, a, b, c, in[13] + 0xfd987193, 12);
- MD5STEP(F1, c, d, a, b, in[14] + 0xa679438e, 17);
- MD5STEP(F1, b, c, d, a, in[15] + 0x49b40821, 22);
-
- MD5STEP(F2, a, b, c, d, in[1] + 0xf61e2562, 5);
- MD5STEP(F2, d, a, b, c, in[6] + 0xc040b340, 9);
- MD5STEP(F2, c, d, a, b, in[11] + 0x265e5a51, 14);
- MD5STEP(F2, b, c, d, a, in[0] + 0xe9b6c7aa, 20);
- MD5STEP(F2, a, b, c, d, in[5] + 0xd62f105d, 5);
- MD5STEP(F2, d, a, b, c, in[10] + 0x02441453, 9);
- MD5STEP(F2, c, d, a, b, in[15] + 0xd8a1e681, 14);
- MD5STEP(F2, b, c, d, a, in[4] + 0xe7d3fbc8, 20);
- MD5STEP(F2, a, b, c, d, in[9] + 0x21e1cde6, 5);
- MD5STEP(F2, d, a, b, c, in[14] + 0xc33707d6, 9);
- MD5STEP(F2, c, d, a, b, in[3] + 0xf4d50d87, 14);
- MD5STEP(F2, b, c, d, a, in[8] + 0x455a14ed, 20);
- MD5STEP(F2, a, b, c, d, in[13] + 0xa9e3e905, 5);
- MD5STEP(F2, d, a, b, c, in[2] + 0xfcefa3f8, 9);
- MD5STEP(F2, c, d, a, b, in[7] + 0x676f02d9, 14);
- MD5STEP(F2, b, c, d, a, in[12] + 0x8d2a4c8a, 20);
-
- MD5STEP(F3, a, b, c, d, in[5] + 0xfffa3942, 4);
- MD5STEP(F3, d, a, b, c, in[8] + 0x8771f681, 11);
- MD5STEP(F3, c, d, a, b, in[11] + 0x6d9d6122, 16);
- MD5STEP(F3, b, c, d, a, in[14] + 0xfde5380c, 23);
- MD5STEP(F3, a, b, c, d, in[1] + 0xa4beea44, 4);
- MD5STEP(F3, d, a, b, c, in[4] + 0x4bdecfa9, 11);
- MD5STEP(F3, c, d, a, b, in[7] + 0xf6bb4b60, 16);
- MD5STEP(F3, b, c, d, a, in[10] + 0xbebfbc70, 23);
- MD5STEP(F3, a, b, c, d, in[13] + 0x289b7ec6, 4);
- MD5STEP(F3, d, a, b, c, in[0] + 0xeaa127fa, 11);
- MD5STEP(F3, c, d, a, b, in[3] + 0xd4ef3085, 16);
- MD5STEP(F3, b, c, d, a, in[6] + 0x04881d05, 23);
- MD5STEP(F3, a, b, c, d, in[9] + 0xd9d4d039, 4);
- MD5STEP(F3, d, a, b, c, in[12] + 0xe6db99e5, 11);
- MD5STEP(F3, c, d, a, b, in[15] + 0x1fa27cf8, 16);
- MD5STEP(F3, b, c, d, a, in[2] + 0xc4ac5665, 23);
-
- MD5STEP(F4, a, b, c, d, in[0] + 0xf4292244, 6);
- MD5STEP(F4, d, a, b, c, in[7] + 0x432aff97, 10);
- MD5STEP(F4, c, d, a, b, in[14] + 0xab9423a7, 15);
- MD5STEP(F4, b, c, d, a, in[5] + 0xfc93a039, 21);
- MD5STEP(F4, a, b, c, d, in[12] + 0x655b59c3, 6);
- MD5STEP(F4, d, a, b, c, in[3] + 0x8f0ccc92, 10);
- MD5STEP(F4, c, d, a, b, in[10] + 0xffeff47d, 15);
- MD5STEP(F4, b, c, d, a, in[1] + 0x85845dd1, 21);
- MD5STEP(F4, a, b, c, d, in[8] + 0x6fa87e4f, 6);
- MD5STEP(F4, d, a, b, c, in[15] + 0xfe2ce6e0, 10);
- MD5STEP(F4, c, d, a, b, in[6] + 0xa3014314, 15);
- MD5STEP(F4, b, c, d, a, in[13] + 0x4e0811a1, 21);
- MD5STEP(F4, a, b, c, d, in[4] + 0xf7537e82, 6);
- MD5STEP(F4, d, a, b, c, in[11] + 0xbd3af235, 10);
- MD5STEP(F4, c, d, a, b, in[2] + 0x2ad7d2bb, 15);
- MD5STEP(F4, b, c, d, a, in[9] + 0xeb86d391, 21);
-
- buf[0] += a;
- buf[1] += b;
- buf[2] += c;
- buf[3] += d;
-}
diff --git a/mozilla/calendar/libxpical/md5.h b/mozilla/calendar/libxpical/md5.h
deleted file mode 100644
index 2f7be9dea65..00000000000
--- a/mozilla/calendar/libxpical/md5.h
+++ /dev/null
@@ -1,26 +0,0 @@
-#ifndef MD5_H
-#define MD5_H
-
-#if defined(__alpha) || defined(__x86_64)
-typedef unsigned int uint32;
-#else
-typedef unsigned long uint32;
-#endif
-
-struct MD5Context {
- uint32 buf[4];
- uint32 bits[2];
- unsigned char in[64];
-};
-
-extern void MD5Init(struct MD5Context *ctx);
-extern void MD5Update(struct MD5Context *ctx, unsigned char *buf, unsigned len);
-extern void MD5Final(unsigned char digest[16], struct MD5Context *ctx);
-extern void MD5Transform();
-
-/*
- * This is needed to make RSAREF happy on some MS-DOS compilers.
- */
-typedef struct MD5Context MD5_CTX;
-
-#endif /* !MD5_H */
diff --git a/mozilla/calendar/libxpical/oeDateTimeImpl.cpp b/mozilla/calendar/libxpical/oeDateTimeImpl.cpp
deleted file mode 100644
index 508c7c2d2ad..00000000000
--- a/mozilla/calendar/libxpical/oeDateTimeImpl.cpp
+++ /dev/null
@@ -1,274 +0,0 @@
-/* ***** BEGIN LICENSE BLOCK *****
- * Version: MPL 1.1/GPL 2.0/LGPL 2.1
- *
- * The contents of this file are subject to the Mozilla Public License Version
- * 1.1 (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * Software distributed under the License is distributed on an "AS IS" basis,
- * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
- * for the specific language governing rights and limitations under the
- * License.
- *
- * The Original Code is OEone Corporation.
- *
- * The Initial Developer of the Original Code is
- * OEone Corporation.
- * Portions created by the Initial Developer are Copyright (C) 2001
- * the Initial Developer. All Rights Reserved.
- *
- * Contributor(s):
- * Mostafa Hosseini (mostafah@oeone.com)
- *
- * Alternatively, the contents of this file may be used under the terms of
- * either the GNU General Public License Version 2 or later (the "GPL"), or
- * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
- * in which case the provisions of the GPL or the LGPL are applicable instead
- * of those above. If you wish to allow use of your version of this file only
- * under the terms of either the GPL or the LGPL, and not to allow others to
- * use your version of this file under the terms of the MPL, indicate your
- * decision by deleting the provisions above and replace them with the notice
- * and other provisions required by the GPL or the LGPL. If you do not delete
- * the provisions above, a recipient may use your version of this file under
- * the terms of any one of the MPL, the GPL or the LGPL.
- *
- * ***** END LICENSE BLOCK ***** */
-
-/* This file implements a date-time XPCOM object used to pass date-time values between the frontend and the
-backend. It provides access to individual date-time fields from javascript and translates that data to a
-icaltimetype structure for the backend.*/
-
-#ifndef WIN32
-#include
-#endif
-
-#include "oeDateTimeImpl.h"
-#include "nsMemory.h"
-#include "stdlib.h"
-
-icaltimetype ConvertFromPrtime( PRTime indate );
-PRTime ConvertToPrtime ( icaltimetype indate );
-icaltimezone *currenttimezone = nsnull;
-
-/* Implementation file */
-NS_IMPL_ISUPPORTS1(oeDateTimeImpl, oeIDateTime)
-
-nsresult
-NS_NewDateTime( oeIDateTime** inst )
-{
- NS_PRECONDITION(inst != nsnull, "null ptr");
- if (! inst)
- return NS_ERROR_NULL_POINTER;
-
- *inst = new oeDateTimeImpl();
- if (! *inst)
- return NS_ERROR_OUT_OF_MEMORY;
-
- NS_ADDREF(*inst);
- return NS_OK;
-}
-
-oeDateTimeImpl::oeDateTimeImpl()
-{
- /* member initializers and constructor code */
- m_datetime = icaltime_null_time();
- m_tzid = nsnull;
-}
-
-oeDateTimeImpl::~oeDateTimeImpl()
-{
- if( m_tzid )
- nsMemory::Free( m_tzid );
-}
-
-/* attribute short year; */
-NS_IMETHODIMP oeDateTimeImpl::GetYear(PRInt16 *retval)
-{
- *retval = m_datetime.year;
- return NS_OK;
-}
-NS_IMETHODIMP oeDateTimeImpl::SetYear(PRInt16 newval)
-{
- m_datetime.year = newval;
- return NS_OK;
-}
-
-/* attribute short month; */
-NS_IMETHODIMP oeDateTimeImpl::GetMonth(PRInt16 *retval)
-{
- *retval = m_datetime.month - 1;
- return NS_OK;
-}
-NS_IMETHODIMP oeDateTimeImpl::SetMonth(PRInt16 newval)
-{
- m_datetime.month = newval + 1;
- if( m_datetime.month < 1 || m_datetime.month > 12 )
- m_datetime = icaltime_normalize( m_datetime );
- return NS_OK;
-}
-
-/* attribute short day; */
-NS_IMETHODIMP oeDateTimeImpl::GetDay(PRInt16 *retval)
-{
- *retval = m_datetime.day;
- return NS_OK;
-}
-NS_IMETHODIMP oeDateTimeImpl::SetDay(PRInt16 newval)
-{
- m_datetime.day = newval;
- if( newval < 1 || newval > 31 )
- m_datetime = icaltime_normalize( m_datetime );
- return NS_OK;
-}
-
-/* attribute short hour; */
-NS_IMETHODIMP oeDateTimeImpl::GetHour(PRInt16 *retval)
-{
- *retval = m_datetime.hour;
- return NS_OK;
-}
-NS_IMETHODIMP oeDateTimeImpl::SetHour(PRInt16 newval)
-{
- m_datetime.hour = newval;
- if( newval < 0 || newval > 23 )
- m_datetime = icaltime_normalize( m_datetime );
- return NS_OK;
-}
-
-/* attribute short minute; */
-NS_IMETHODIMP oeDateTimeImpl::GetMinute(PRInt16 *retval)
-{
- *retval = m_datetime.minute;
- return NS_OK;
-}
-NS_IMETHODIMP oeDateTimeImpl::SetMinute(PRInt16 newval)
-{
- m_datetime.minute = newval;
- if( newval < 0 || newval > 59 )
- m_datetime = icaltime_normalize( m_datetime );
- return NS_OK;
-}
-
-NS_IMETHODIMP oeDateTimeImpl::GetTime(PRTime *retval)
-{
- *retval = ConvertToPrtime( m_datetime );
- return NS_OK;
-}
-
-NS_IMETHODIMP oeDateTimeImpl::ToString(char **retval)
-{
- char tmp[20];
- sprintf( tmp, "%04d/%02d/%02d %02d:%02d:%02d" , m_datetime.year, m_datetime.month, m_datetime.day, m_datetime.hour, m_datetime.minute, m_datetime.second );
- *retval= (char*) nsMemory::Clone( tmp, strlen(tmp)+1);
- return NS_OK;
-}
-
-NS_IMETHODIMP oeDateTimeImpl::SetTime( PRTime ms )
-{
- m_datetime = ConvertFromPrtime( ms );
- return NS_OK;
-}
-
-NS_IMETHODIMP oeDateTimeImpl::SetTimeInTimezone( PRTime ms, const char *tzid )
-{
-#ifdef ICAL_DEBUG_ALL
- printf( "SetTimeInTimezone( %s )\n", tzid );
-#endif
- if( m_tzid )
- nsMemory::Free( m_tzid );
-
- if( tzid )
- m_tzid= (char*) nsMemory::Clone( tzid, strlen(tzid)+1);
- else
- m_tzid = nsnull;
-
- icaltimetype newdatetime = ConvertFromPrtime( ms );
-
- icaltimezone *from_zone = icaltimezone_get_builtin_timezone_from_tzid ( tzid );
- if( from_zone )
- icaltimezone_convert_time ( &newdatetime, from_zone, currenttimezone );
- else {
- if( m_tzid )
- nsMemory::Free( m_tzid );
- m_tzid = nsnull;
- }
-
- m_datetime = newdatetime;
-
- return NS_OK;
-}
-
-NS_IMETHODIMP oeDateTimeImpl::Clear()
-{
- m_datetime = icaltime_null_time();
- return NS_OK;
-}
-
-NS_IMETHODIMP oeDateTimeImpl::GetIsSet(PRBool *retval)
-{
- *retval = ! icaltime_is_null_time(m_datetime);
- return NS_OK;
-}
-
-NS_IMETHODIMP oeDateTimeImpl::GetUtc(PRBool *retval)
-{
- *retval = m_datetime.is_utc;
- return NS_OK;
-}
-
-NS_IMETHODIMP oeDateTimeImpl::SetUtc(PRBool newval)
-{
- m_datetime.is_utc = newval;
- return NS_OK;
-}
-
-void oeDateTimeImpl::AdjustToWeekday( short weekday ) {
- short currentday = icaltime_day_of_week( m_datetime );
- while( currentday != weekday ) {
- m_datetime.day++;
- m_datetime = icaltime_normalize( m_datetime );
- currentday = icaltime_day_of_week( m_datetime );
- }
-}
-
-/* readonly attribute string tzid; */
-NS_IMETHODIMP oeDateTimeImpl::GetTzID(char **aRetVal)
-{
-#ifdef ICAL_DEBUG_ALL
- printf( "GetTzID() = " );
-#endif
- if( m_tzid ) {
- *aRetVal= (char*) nsMemory::Clone( m_tzid, strlen(m_tzid)+1);
- if( *aRetVal == nsnull )
- return NS_ERROR_OUT_OF_MEMORY;
- } else
- *aRetVal= nsnull;
-#ifdef ICAL_DEBUG_ALL
- printf( "\"%s\"\n", *aRetVal );
-#endif
- return NS_OK;
-}
-
-void oeDateTimeImpl::SetTzID(const char *aNewVal)
-{
-#ifdef ICAL_DEBUG_ALL
- printf( "SetTzID( %s )\n", aNewVal );
-#endif
- if( m_tzid )
- nsMemory::Free( m_tzid );
-
- if( aNewVal )
- m_tzid= (char*) nsMemory::Clone( aNewVal, strlen(aNewVal)+1);
- else
- m_tzid = nsnull;
-}
-
-int oeDateTimeImpl::CompareDate( oeDateTimeImpl *anotherdt ) {
- if( m_datetime.year == anotherdt->m_datetime.year &&
- m_datetime.month == anotherdt->m_datetime.month &&
- m_datetime.day == anotherdt->m_datetime.day )
- return 0;
- return 1;
-}
-
diff --git a/mozilla/calendar/libxpical/oeDateTimeImpl.h b/mozilla/calendar/libxpical/oeDateTimeImpl.h
deleted file mode 100644
index 2289e47b800..00000000000
--- a/mozilla/calendar/libxpical/oeDateTimeImpl.h
+++ /dev/null
@@ -1,73 +0,0 @@
-/* ***** BEGIN LICENSE BLOCK *****
- * Version: MPL 1.1/GPL 2.0/LGPL 2.1
- *
- * The contents of this file are subject to the Mozilla Public License Version
- * 1.1 (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * Software distributed under the License is distributed on an "AS IS" basis,
- * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
- * for the specific language governing rights and limitations under the
- * License.
- *
- * The Original Code is OEone Corporation.
- *
- * The Initial Developer of the Original Code is
- * OEone Corporation.
- * Portions created by the Initial Developer are Copyright (C) 2001
- * the Initial Developer. All Rights Reserved.
- *
- * Contributor(s):
- * Mostafa Hosseini (mostafah@oeone.com)
- *
- * Alternatively, the contents of this file may be used under the terms of
- * either the GNU General Public License Version 2 or later (the "GPL"), or
- * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
- * in which case the provisions of the GPL or the LGPL are applicable instead
- * of those above. If you wish to allow use of your version of this file only
- * under the terms of either the GPL or the LGPL, and not to allow others to
- * use your version of this file under the terms of the MPL, indicate your
- * decision by deleting the provisions above and replace them with the notice
- * and other provisions required by the GPL or the LGPL. If you do not delete
- * the provisions above, a recipient may use your version of this file under
- * the terms of any one of the MPL, the GPL or the LGPL.
- *
- * ***** END LICENSE BLOCK ***** */
-
-/* Header file for oeDateTimeImpl.cpp containing its CID and CONTRACTID.*/
-
-#ifndef __OE_DATETIMEIMPL_H__
-#define __OE_DATETIMEIMPL_H__
-
-#include "oeIICal.h"
-extern "C" {
- #include "ical.h"
- int icaltimezone_get_vtimezone_properties (icaltimezone *zone,
- icalcomponent *component);
-}
-
-extern icaltimezone *currenttimezone;
-
-#define OE_DATETIME_CID \
-{ 0x78b5b255, 0x7450, 0x47c0, { 0xba, 0x16, 0x0a, 0x6e, 0x7e, 0x80, 0x6e, 0x5d } }
-
-#define OE_DATETIME_CONTRACTID "@mozilla.org/oedatetime;1"
-
-class oeDateTimeImpl : public oeIDateTime
-{
-public:
- NS_DECL_ISUPPORTS
- NS_DECL_OEIDATETIME
- oeDateTimeImpl();
- virtual ~oeDateTimeImpl();
- void AdjustToWeekday( short weekday );
- int CompareDate( oeDateTimeImpl *anotherdt );
- void SetTzID(const char *aNewVal);
- /* additional members */
- struct icaltimetype m_datetime;
-private:
- char *m_tzid;
-};
-
-#endif
diff --git a/mozilla/calendar/libxpical/oeICalContainerImpl.cpp b/mozilla/calendar/libxpical/oeICalContainerImpl.cpp
deleted file mode 100644
index 64ad22b0180..00000000000
--- a/mozilla/calendar/libxpical/oeICalContainerImpl.cpp
+++ /dev/null
@@ -1,1751 +0,0 @@
-/* ***** BEGIN LICENSE BLOCK *****
- * Version: MPL 1.1/GPL 2.0/LGPL 2.1
- *
- * The contents of this file are subject to the Mozilla Public License Version
- * 1.1 (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * Software distributed under the License is distributed on an "AS IS" basis,
- * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
- * for the specific language governing rights and limitations under the
- * License.
- *
- * The Original Code is OEone Calendar Code, released October 31st, 2001.
- *
- * The Initial Developer of the Original Code is
- * OEone Corporation.
- * Portions created by the Initial Developer are Copyright (C) 2001
- * the Initial Developer. All Rights Reserved.
- *
- * Contributor(s): Mostafa Hosseini
- *
- * Alternatively, the contents of this file may be used under the terms of
- * either the GNU General Public License Version 2 or later (the "GPL"), or
- * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
- * in which case the provisions of the GPL or the LGPL are applicable instead
- * of those above. If you wish to allow use of your version of this file only
- * under the terms of either the GPL or the LGPL, and not to allow others to
- * use your version of this file under the terms of the MPL, indicate your
- * decision by deleting the provisions above and replace them with the notice
- * and other provisions required by the GPL or the LGPL. If you do not delete
- * the provisions above, a recipient may use your version of this file under
- * the terms of any one of the MPL, the GPL or the LGPL.
- *
- * ***** END LICENSE BLOCK ***** */
-
-/* This file implements the Container object for calendars. The container is the topmost object in
-the backend and contains and interact with all calendar objects. It acts as a distributor of global
-commands to individual calendars and a collector of calculated data for global queries.
-*/
-
-#include "oeICalContainerImpl.h"
-#include "nsISupportsArray.h"
-#include "nsComponentManagerUtils.h"
-#include "nsCOMArray.h"
-#include "nsISimpleEnumerator.h"
-
-/**
- * This enumerator collects items from an array of other enumerators, and
- * returns it as a single one.
- */
-class oeCollectedEventEnumerator : public nsISimpleEnumerator
-{
- public:
- NS_DECL_ISUPPORTS
-
- oeCollectedEventEnumerator(nsCOMArray& aListOfEnums)
- : mListOfEnums(aListOfEnums),
- mEnumIndex(0)
- {
- }
-
- NS_IMETHOD HasMoreElements(PRBool *aResult)
- {
- *aResult = PR_FALSE;
- if( mEnumIndex >= mListOfEnums.Count() )
- return NS_OK;
- mListOfEnums[mEnumIndex]->HasMoreElements(aResult);
- while (!*aResult && (++mEnumIndex < mListOfEnums.Count())) {
- mListOfEnums[mEnumIndex]->HasMoreElements(aResult);
- }
- return NS_OK;
- }
-
- NS_IMETHOD GetNext(nsISupports **aResult)
- {
- return mListOfEnums[mEnumIndex]->GetNext(aResult);
- }
-
- virtual ~oeCollectedEventEnumerator()
- {
- }
-
- protected:
- nsCOMArray mListOfEnums;
- PRInt32 mEnumIndex;
-};
-
-NS_IMPL_ISUPPORTS1(oeCollectedEventEnumerator, nsISimpleEnumerator)
-
-
-icaltimetype ConvertFromPrtime( PRTime indate );
-PRTime ConvertToPrtime ( icaltimetype indate );
-extern "C" {
-extern icalarray *builtin_timezones;
-extern char *gDefaultTzidPrefix;
-struct _icaltimezone {//from icaltimezone.h
- char *tzid;
- char *location;
- char *tznames;
- double latitude;
- double longitude;
- icalcomponent *component;
- icaltimezone *builtin_timezone;
- int end_year;
- icalarray *changes;
- };
-}
-
-oeIICalContainer *gContainer=nsnull;
-
-//icaltimetype ConvertFromPrtime( PRTime indate );
-void icaltimezone_init_mozilla_zones (void)
-{
- gDefaultTzidPrefix="/Mozilla.org/";
-
- char timezonecalstr[] = \
-"BEGIN:VCALENDAR\n\
-PRODID:-//Mozilla.org/NONSGML Mozilla Calendar Timezone Table V1.0//EN\n\
-VERSION:2.0\n\
-END:VCALENDAR\n\
-";
-
- char *timezoneformatstr = "BEGIN:VTIMEZONE\n\
-TZID:/Mozilla.org/BasicTimezones/NH-GMT%c%02d:%02d\n\
-LOCATION:NH-GMT%c%02d:%02d\n\
-BEGIN:STANDARD\n\
-TZOFFSETFROM:%c%02d%02d\n\
-TZOFFSETTO:%c%02d%02d\n\
-TZNAME:NHS-GMT%c%02d:%02d\n\
-DTSTART:19991031T020000\n\
-RRULE:FREQ=YEARLY;BYMONTH=10;BYDAY=-1SU\n\
-END:STANDARD\n\
-BEGIN:DAYLIGHT\n\
-TZOFFSETFROM:%c%02d%02d\n\
-TZOFFSETTO:%c%02d%02d\n\
-TZNAME:NHD-GMT%c%02d:%02d\n\
-DTSTART:20000402T020000\n\
-RRULE:FREQ=YEARLY;BYMONTH=4;BYMONTHDAY=1,2,3,4,5,6,7;BYDAY=SU\n\
-END:DAYLIGHT\n\
-END:VTIMEZONE\n";
-
- char *zulutimezonestr = "BEGIN:VTIMEZONE\n\
-TZID:/Mozilla.org/BasicTimezones/GMT\n\
-LOCATION:GMT\n\
-END:VTIMEZONE\n";
-
- char timezonestr[1024];
-
- if( builtin_timezones )
- return;
-
- builtin_timezones = icalarray_new ( sizeof(icaltimezone), 32);
-
- icalcomponent *vcalendar = icalparser_parse_string(timezonecalstr);
- icalcomponent *vtimezone;
-
- //first add the UTC timezone
- vtimezone = icalcomponent_new_from_string( zulutimezonestr );
- icalcomponent_add_component( vcalendar, vtimezone );
-
- //Components should be sorted by location
- //+00:00 to +12:00
- int i;
- for( i=0; i<25; i++ ) {
- char sign = '+';
- int hour = i/2;
- int minute = i%2==0 ? 00 : 30;
- int hour2 = (i+2)/2;
- sprintf( timezonestr, timezoneformatstr
- , sign, hour, minute
- , sign, hour, minute
- , sign, hour2, minute
- , sign, hour, minute
- , sign, hour, minute
- , sign, hour, minute
- , sign, hour2, minute
- , sign, hour, minute );
- vtimezone = icalcomponent_new_from_string( timezonestr );
- icalcomponent_add_component( vcalendar, vtimezone );
- }
- //-00:30 to -12:00
- for( i=-1; i>-25; i-- ) {
- char sign = '-';
- int hour = -1*i/2;
- int minute = i%2==0 ? 00 : 30;
- char sign2 = (i+2)<0 ? '-' : '+';
- int hour2 = (i+2)<0 ? -1*(i+2)/2 : (i+2)/2;
- sprintf( timezonestr, timezoneformatstr
- , sign, hour, minute
- , sign, hour, minute
- , sign2, hour2, minute
- , sign, hour, minute
- , sign, hour, minute
- , sign, hour, minute
- , sign2, hour2, minute
- , sign, hour, minute );
- vtimezone = icalcomponent_new_from_string( timezonestr );
- icalcomponent_add_component( vcalendar, vtimezone );
- }
-
- for( vtimezone = icalcomponent_get_first_component( vcalendar, ICAL_VTIMEZONE_COMPONENT );
- vtimezone != NULL;
- vtimezone = icalcomponent_get_next_component( vcalendar, ICAL_VTIMEZONE_COMPONENT ) ) {
- icaltimezone *zone=icaltimezone_new();
- icaltimezone_get_vtimezone_properties ( zone, vtimezone );
- icalarray_append (builtin_timezones, zone);
- }
-
- PRExplodedTime ext;
- PR_ExplodeTime( PR_Now(), PR_LocalTimeParameters, &ext);
- int gmtoffsethour = ext.tm_params.tp_gmt_offset < 0 ? -1*ext.tm_params.tp_gmt_offset / 3600 : ext.tm_params.tp_gmt_offset / 3600;
- int gmtoffsetminute = ext.tm_params.tp_gmt_offset%3600 ? 30 : 00;
- char zone_location[20];
- sprintf( zone_location, "NH-GMT%c%02d:%02d", ext.tm_params.tp_gmt_offset < 0 ? '-' : '+'
- , gmtoffsethour, gmtoffsetminute );
-
- currenttimezone = icaltimezone_get_builtin_timezone ( zone_location );
-}
-
-oeICalContainerImpl::oeICalContainerImpl()
-{
-#ifdef ICAL_DEBUG
- printf( "oeICalContainerImpl::oeICalContainerImpl()\n" );
-#endif
-
- m_batchMode = false;
- m_suppressAlarmsByDefault = false;
-
- NS_NewISupportsArray(getter_AddRefs(m_calendarArray));
- if ( m_calendarArray == nsnull ) {
- #ifdef ICAL_DEBUG
- printf( "oeICalContainerImpl::oeICalContainerImpl() - Warning : Can't create calendar array!\n" );
- #endif
- }
-
- NS_NewISupportsArray(getter_AddRefs(m_observerArray));
- if ( m_observerArray == nsnull ) {
- #ifdef ICAL_DEBUG
- printf( "oeICalContainerImpl::oeICalContainerImpl() - Warning : Can't create observer array!\n" );
- #endif
- }
-
- NS_NewISupportsArray(getter_AddRefs(m_todoobserverArray));
- if ( m_todoobserverArray == nsnull ) {
- #ifdef ICAL_DEBUG
- printf( "oeICalContainerImpl::oeICalContainerImpl() - Warning : Can't create todo observer array!\n" );
- #endif
- }
-
- m_filter = new oeICalContainerFilter();
- NS_ADDREF( m_filter );
- m_filter->m_calendarArray = m_calendarArray;
-
- icaltimezone_init_mozilla_zones ();
-
- gContainer = this;
-}
-
-oeICalContainerImpl::~oeICalContainerImpl()
-{
-#ifdef ICAL_DEBUG
- printf( "oeICalContainerImpl::~oeICalContainerImpl()\n" );
-#endif
-
- m_calendarArray->Clear();
- m_calendarArray = nsnull;
- m_observerArray = nsnull;
- m_todoobserverArray = nsnull;
-
- NS_RELEASE( m_filter );
- gContainer = nsnull;
-}
-
-/**
- * NS_IMPL_ISUPPORTS1 expands to a simple implementation of the nsISupports
- * interface. This includes a proper implementation of AddRef, Release,
- * and QueryInterface. If this class supported more interfaces than just
- * nsISupports,
- * you could use NS_IMPL_ADDREF() and NS_IMPL_RELEASE() to take care of the
- * simple stuff, but you would have to create QueryInterface on your own.
- * nsSampleFactory.cpp is an example of this approach.
- * Notice that the second parameter to the macro is the static IID accessor
- * method, and NOT the #defined IID.
- */
-NS_IMPL_ISUPPORTS1(oeICalContainerImpl, oeIICalContainer)
-
-NS_IMETHODIMP
-oeICalContainerImpl::AddCalendar( const nsACString &aServer, const char *type ) {
-#ifdef ICAL_DEBUG
- printf( "oeICalContainerImpl::AddCalendar(%s, %s)\n", PromiseFlatCString(aServer).get(), type?type:"" );
-#endif
-
- nsresult rv;
-
- nsCOMPtr calendar;
- GetCalendar( aServer , getter_AddRefs(calendar) );
- if( calendar ) {
- #ifdef ICAL_DEBUG_ALL
- printf( "oeICalContainerImpl::AddCalendar()-Warning: Calendar already exists\n" );
- #endif
- return NS_OK;
- }
-
- nsCAutoString contractid;
- contractid.Assign(NS_LITERAL_CSTRING("@mozilla.org/ical;1"));
- if (type && strlen(type)) {
- contractid.Append(NS_LITERAL_CSTRING("?type="));
- contractid.Append(type);
- }
- calendar = do_CreateInstance(contractid.get(), &rv);
- if (NS_FAILED(rv)) {
- return NS_ERROR_FAILURE;
- }
-
- m_calendarArray->AppendElement( calendar );
-
- PRUint32 num;
- unsigned int i;
- m_observerArray->Count( &num );
- for ( i=0; iGetElementAt( i, (nsISupports **)&tmpobserver );
- calendar->AddObserver( tmpobserver );
- }
-
- m_todoobserverArray->Count( &num );
- for ( i=0; iGetElementAt( i, (nsISupports **)&tmpobserver );
- calendar->AddTodoObserver( tmpobserver );
- }
-
- calendar->SetBatchMode( m_batchMode ); //Make sure the current batchmode value is inherited
-
- calendar->SetSuppressAlarms( m_suppressAlarmsByDefault );
-
- calendar->SetServer( aServer );
-
- return NS_OK;
-}
-
-NS_IMETHODIMP
-oeICalContainerImpl::GetCalendar( const nsACString &aServer, oeIICal **calendar ) {
-#ifdef ICAL_DEBUG
- printf( "oeICalContainerImpl::GetCalendar(%s)\n", server );
-#endif
-
- PRUint32 num;
- unsigned int i;
-
- m_calendarArray->Count( &num );
- for( i=0; i tmpcalendar;
- nsCAutoString tmpserver;
- m_calendarArray->GetElementAt( i, getter_AddRefs( tmpcalendar ) );
- tmpcalendar->GetServer( tmpserver );
- if( tmpserver.Equals(aServer) ) {
- *calendar = tmpcalendar;
- NS_ADDREF( *calendar );
- return NS_OK;
- }
- }
- *calendar = nsnull;
- return NS_OK;
-}
-
-NS_IMETHODIMP
-oeICalContainerImpl::RemoveCalendar( const nsACString &aServer ) {
-#ifdef ICAL_DEBUG
- printf( "oeICalContainerImpl::RemoveCalendar(%s)\n", server );
-#endif
- PRUint32 num;
- unsigned int i;
-
- m_calendarArray->Count( &num );
- for( i=0; i tmpcalendar;
- nsCAutoString tmpserver;
- m_calendarArray->GetElementAt( i, getter_AddRefs( tmpcalendar ) );
- tmpcalendar->GetServer( tmpserver );
- if( tmpserver.Equals(aServer) ) {
- m_calendarArray->RemoveElementAt( i );
- return NS_OK;
- }
- }
- return NS_OK;
-}
-
-NS_IMETHODIMP
-oeICalContainerImpl::AddCalendars( PRUint32 serverCount, const PRUnichar **servers ) {
-#ifdef ICAL_DEBUG
- printf( "oeICalContainerImpl::AddCalendars( %d, [Array] )\n", serverCount );
-#endif
- nsresult rv=NS_OK;
- for( unsigned int i=0; iCount( &num );
- for( i=0; i calendar;
- m_calendarArray->GetElementAt( i, getter_AddRefs(calendar) );
- calendar->SetBatchMode( aBatchMode );
- }
-
- m_observerArray->Count( &num );
- for( i=0; iGetElementAt( i, (nsISupports **)&tmpobserver );
- if( m_batchMode ) {
- rv = tmpobserver->OnStartBatch();
- #ifdef ICAL_DEBUG
- if( NS_FAILED( rv ) ) {
- printf( "oeICalContainerImpl::SetBatchMode() : WARNING Call to observer's onStartBatch() unsuccessful: %x\n", rv );
- }
- #endif
- }
- else {
- rv = tmpobserver->OnEndBatch();
- #ifdef ICAL_DEBUG
- if( NS_FAILED( rv ) ) {
- printf( "oeICalContainerImpl::SetBatchMode() : WARNING Call to observer's onEndBatch() unsuccessful: %x\n", rv );
- }
- #endif
- }
-
- }
- m_todoobserverArray->Count( &num );
- for( i=0; iGetElementAt( i, (nsISupports **)&tmpobserver );
- if( m_batchMode ) {
- rv = tmpobserver->OnStartBatch();
- #ifdef ICAL_DEBUG
- if( NS_FAILED( rv ) ) {
- printf( "oeICalContainerImpl::SetBatchMode() : WARNING Call to observer's onStartBatch() unsuccessful: %x\n", rv );
- }
- #endif
- }
- else {
- rv = tmpobserver->OnEndBatch();
- #ifdef ICAL_DEBUG
- if( NS_FAILED( rv ) ) {
- printf( "oeICalContainerImpl::SetBatchMode() : WARNING Call to observer's onEndBatch() unsuccessful: %x\n", rv );
- }
- #endif
- }
-
- }
- }
-
- return NS_OK;
-}
-
-/* attribute boolean suppressAlarmsByDefault; */
-NS_IMETHODIMP oeICalContainerImpl::GetSuppressAlarmsByDefault(PRBool *aRetVal)
-{
- *aRetVal = m_suppressAlarmsByDefault;
- return NS_OK;
-}
-
-NS_IMETHODIMP oeICalContainerImpl::SetSuppressAlarmsByDefault(PRBool aNewVal)
-{
- m_suppressAlarmsByDefault = aNewVal;
- return NS_OK;
-}
-
-NS_IMETHODIMP oeICalContainerImpl::AddEvent( oeIICalEvent *icalevent, const nsACString &aServer, char **retid )
-{
-#ifdef ICAL_DEBUG
- printf( "oeICalContainerImpl::AddEvent()\n" );
-#endif
- nsresult rv;
- nsCOMPtr calendar;
- GetCalendar( aServer , getter_AddRefs(calendar) );
- if( !calendar ) {
- AddCalendar( aServer, "" );
- GetCalendar( aServer , getter_AddRefs(calendar) );
- if( !calendar ) {
- #ifdef ICAL_DEBUG
- printf( "oeICalContainerImpl::AddEvent()-Error cannot find or create calendar\n" );
- #endif
- return NS_ERROR_FAILURE;
- } else {
- rv = calendar->AddEvent( icalevent, retid );
- RemoveCalendar( aServer );
- }
- } else {
- rv = calendar->AddEvent( icalevent, retid );
- }
- return rv;
-}
-
-NS_IMETHODIMP oeICalContainerImpl::ModifyEvent( oeIICalEvent *icalevent, char **retid )
-{
-#ifdef ICAL_DEBUG
- printf( "oeICalContainerImpl::ModifyEvent()\n" );
-#endif
- oeIICal *calendar;
- icalevent->GetParent( &calendar );
- if( !calendar ) {
- #ifdef ICAL_DEBUG
- printf( "oeICalContainerImpl::ModifyEvent()-Error: Event does not have a parent calendar\n" );
- #endif
- return NS_ERROR_FAILURE;
- }
- nsresult rv = calendar->ModifyEvent( icalevent, retid );
- NS_RELEASE( calendar );
- return rv;
-}
-
-NS_IMETHODIMP oeICalContainerImpl::FetchEvent( const char *id, oeIICalEvent **ev )
-{
-#ifdef ICAL_DEBUG_ALL
- printf( "oeICalContainerImpl::FetchEvent()\n" );
-#endif
-
- if( id == nsnull ) {
- #ifdef ICAL_DEBUG
- printf( "oeICalContainerImpl::FetchEvent() - Invalid Id.\n" );
- #endif
- *ev = nsnull;
- return NS_ERROR_FAILURE;
- }
-
- PRUint32 num;
- unsigned int i;
-
- *ev = nsnull;
- m_calendarArray->Count( &num );
- for( i=0; i calendar;
- m_calendarArray->GetElementAt( i, getter_AddRefs(calendar) );
- calendar->FetchEvent( id, ev );
- if( *ev )
- break;
- }
-
- return NS_OK;
-}
-
-NS_IMETHODIMP
-oeICalContainerImpl::DeleteEvent( const char *id )
-{
-#ifdef ICAL_DEBUG
- printf( "oeICalContainerImpl::DeleteEvent( %s )\n", id );
-#endif
- if( id == nsnull ) {
- #ifdef ICAL_DEBUG
- printf( "oeICalContainerImpl::DeleteEvent() - Invalid Id.\n" );
- #endif
- return NS_ERROR_FAILURE;
- }
- oeIICalEvent *event;
- FetchEvent( id , &event );
- if( !event ) {
- #ifdef ICAL_DEBUG
- printf( "oeICalContainerImpl::DeleteEvent() - Event Not Found.\n" );
- #endif
- return NS_ERROR_FAILURE;
- }
- oeIICal *calendar;
- event->GetParent( &calendar );
- NS_RELEASE( event );
- if( !calendar ) {
- #ifdef ICAL_DEBUG
- printf( "oeICalContainerImpl::DeleteEvent()-Error: Event does not have a parent calendar\n" );
- #endif
- return NS_ERROR_FAILURE;
- }
- nsresult rv = calendar->DeleteEvent( id );
- NS_RELEASE( calendar );
-
- return rv;
-}
-
-NS_IMETHODIMP
-oeICalContainerImpl::GetAllEvents(nsISimpleEnumerator **eventlist )
-{
-#ifdef ICAL_DEBUG
- printf( "oeICalContainerImpl::GetAllEvents()\n" );
-#endif
-
- PRUint32 num;
- unsigned int i;
- nsCOMArray listOfEnums;
-
- m_calendarArray->Count( &num );
- for( i=0; i calendar;
- m_calendarArray->GetElementAt( i, getter_AddRefs(calendar) );
- nsCOMPtr eventEnum;
- calendar->GetAllEvents( getter_AddRefs(eventEnum) );
- listOfEnums.AppendObject(eventEnum);
- }
-
- *eventlist = new oeCollectedEventEnumerator(listOfEnums);
- if (!*eventlist)
- return NS_ERROR_OUT_OF_MEMORY;
-
- NS_ADDREF(*eventlist);
- return NS_OK;
-}
-
-NS_IMETHODIMP
-oeICalContainerImpl::GetEventsForMonth( PRTime datems, nsISimpleEnumerator **eventlist ) {
-#ifdef ICAL_DEBUG
- printf( "oeICalContainerImpl::GetEventsForMonth()\n" );
-#endif
-
- PRUint32 num;
- unsigned int i;
- nsCOMArray listOfEnums;
-
- m_calendarArray->Count( &num );
- for( i=0; i calendar;
- m_calendarArray->GetElementAt( i, getter_AddRefs(calendar) );
- nsCOMPtr eventEnum;
- calendar->GetEventsForMonth( datems, getter_AddRefs(eventEnum) );
- listOfEnums.AppendObject(eventEnum);
- }
-
- *eventlist = new oeCollectedEventEnumerator(listOfEnums);
- if (!*eventlist)
- return NS_ERROR_OUT_OF_MEMORY;
-
- NS_ADDREF(*eventlist);
- return NS_OK;
-}
-
-NS_IMETHODIMP
-oeICalContainerImpl::GetEventsForWeek( PRTime datems, nsISimpleEnumerator **eventlist ) {
-#ifdef ICAL_DEBUG
- printf( "oeICalContainerImpl::GetEventsForWeek()\n" );
-#endif
-
- PRUint32 num;
- unsigned int i;
- nsCOMArray listOfEnums;
-
- m_calendarArray->Count( &num );
- for( i=0; i calendar;
- m_calendarArray->GetElementAt( i, getter_AddRefs(calendar) );
- nsCOMPtr eventEnum;
- calendar->GetEventsForWeek( datems, getter_AddRefs(eventEnum) );
- listOfEnums.AppendObject(eventEnum);
- }
-
- *eventlist = new oeCollectedEventEnumerator(listOfEnums);
- if (!*eventlist)
- return NS_ERROR_OUT_OF_MEMORY;
-
- NS_ADDREF(*eventlist);
- return NS_OK;
-}
-
-NS_IMETHODIMP
-oeICalContainerImpl::GetEventsForDay( PRTime datems, nsISimpleEnumerator **eventlist ) {
-#ifdef ICAL_DEBUG
- printf( "oeICalContainerImpl::GetEventsForDay()\n" );
-#endif
-
- PRUint32 num;
- unsigned int i;
- nsCOMArray listOfEnums;
-
- m_calendarArray->Count( &num );
- for( i=0; i calendar;
- m_calendarArray->GetElementAt( i, getter_AddRefs(calendar) );
- nsCOMPtr eventEnum;
- calendar->GetEventsForDay( datems, getter_AddRefs(eventEnum) );
- listOfEnums.AppendObject(eventEnum);
- }
-
- *eventlist = new oeCollectedEventEnumerator(listOfEnums);
- if (!*eventlist)
- return NS_ERROR_OUT_OF_MEMORY;
-
- NS_ADDREF(*eventlist);
- return NS_OK;
-}
-
-NS_IMETHODIMP
-oeICalContainerImpl::GetEventsForRange( PRTime checkdateinms, PRTime checkenddateinms, nsISimpleEnumerator **eventlist ) {
-#ifdef ICAL_DEBUG_ALL
- printf( "oeICalContainerImpl::GetEventsForRange()\n" );
-#endif
-
- PRUint32 num;
- unsigned int i;
- nsCOMArray listOfEnums;
-
- m_calendarArray->Count( &num );
- for( i=0; i calendar;
- m_calendarArray->GetElementAt( i, getter_AddRefs(calendar) );
- nsCOMPtr eventEnum;
- calendar->GetEventsForRange( checkdateinms, checkenddateinms, getter_AddRefs(eventEnum) );
- listOfEnums.AppendObject(eventEnum);
- }
-
- *eventlist = new oeCollectedEventEnumerator(listOfEnums);
- if (!*eventlist)
- return NS_ERROR_OUT_OF_MEMORY;
-
- NS_ADDREF(*eventlist);
- return NS_OK;
-}
-
-NS_IMETHODIMP
-oeICalContainerImpl::GetFirstEventsForRange( PRTime checkdateinms, PRTime checkenddateinms, nsISimpleEnumerator **eventlist ) {
-//NOTE: checkenddateinms is being ignored for now
-#ifdef ICAL_DEBUG_ALL
- printf( "oeICalContainerImpl::GetFirstEventsForRange()\n" );
-#endif
-
- PRUint32 num;
- unsigned int i;
- nsCOMArray listOfEnums;
-
- m_calendarArray->Count( &num );
- for( i=0; i calendar;
- m_calendarArray->GetElementAt( i, getter_AddRefs(calendar) );
- nsCOMPtr eventEnum;
- calendar->GetFirstEventsForRange( checkdateinms, checkenddateinms, getter_AddRefs(eventEnum) );
- listOfEnums.AppendObject(eventEnum);
- }
-
- *eventlist = new oeCollectedEventEnumerator(listOfEnums);
- if (!*eventlist)
- return NS_ERROR_OUT_OF_MEMORY;
-
- NS_ADDREF(*eventlist);
- return NS_OK;
-}
-
-icaltimetype oeICalContainerImpl::GetNextEvent( icaltimetype starting ) {
-#ifdef ICAL_DEBUG_ALL
- printf( "oeICalContainerImpl::GetNextEvent()\n" );
-#endif
- icaltimetype soonest = icaltime_null_time();
-
- PRUint32 num;
- unsigned int i;
-
- m_calendarArray->Count( &num );
- for( i=0; i tmpcalendar;
- m_calendarArray->GetElementAt( i, getter_AddRefs(tmpcalendar) );
- oeICalImpl *calendar = (oeICalImpl *)(&tmpcalendar);
- icaltimetype next = calendar->GetNextEvent( starting );
- if( !icaltime_is_null_time( next ) && ( icaltime_is_null_time( soonest ) || (icaltime_compare( soonest, next ) > 0) ) ) {
- soonest = next;
- }
- }
-
- return soonest;
-}
-
-NS_IMETHODIMP
-oeICalContainerImpl::GetNextNEvents( PRTime datems, PRInt32 maxcount, nsISimpleEnumerator **eventlist ) {
-#ifdef ICAL_DEBUG
- printf( "oeICalContainerImpl::GetNextNEvents( %d )\n", maxcount );
-#endif
-
- nsCOMPtr eventEnum = new oeEventEnumerator( );
-
- if (!eventEnum)
- return NS_ERROR_OUT_OF_MEMORY;
-
- eventEnum->QueryInterface(NS_GET_IID(nsISimpleEnumerator), (void **)eventlist);
-
- struct icaltimetype checkdate = ConvertFromPrtime( datems );
- icaltime_adjust( &checkdate, 0, 0, 0, -1 );
-
- int count = 0;
- icaltimetype nextcheckdate;
- do {
- nextcheckdate = GetNextEvent( checkdate );
- if( !icaltime_is_null_time( nextcheckdate )) {
-
- PRUint32 num;
- unsigned int i;
- m_calendarArray->Count( &num );
- for( i=0; i tmpcalendar;
- m_calendarArray->GetElementAt( i, getter_AddRefs(tmpcalendar) );
- oeICalImpl *calendar = (oeICalImpl *)(&tmpcalendar);
- nsVoidArray *tmplistptr = calendar->GetEventList();
- oeIICalEvent *tmpevent;
- for ( PRInt32 j = 0 ; (count < maxcount) && (j < tmplistptr->Count()); ++j) {
- bool isbeginning,isallday;
- tmpevent = NS_STATIC_CAST(oeIICalEvent*, tmplistptr->ElementAt(j));
- icaltimetype next = ((oeICalEventImpl *)tmpevent)->GetNextRecurrence( checkdate, &isbeginning );
- isallday = next.is_date;
- next.is_date = false;
- if( !icaltime_is_null_time( next ) && (icaltime_compare( nextcheckdate, next ) == 0) ) {
- ((oeICalEventImpl *)tmpevent)->ChopAndAddEventToEnum( nextcheckdate, eventlist, isallday, isbeginning );
- count++;
- }
- }
- }
- checkdate = nextcheckdate;
- }
- } while ( !icaltime_is_null_time( nextcheckdate ) && (count < maxcount) );
-
- return NS_OK;
-}
-
-NS_IMETHODIMP
-oeICalContainerImpl::AddObserver(oeIICalObserver *observer)
-{
-#ifdef ICAL_DEBUG_ALL
- printf( "oeICalContainerImpl::AddObserver()\n" );
-#endif
- if( observer ) {
- NS_ADDREF( observer );
- m_observerArray->AppendElement( observer );
-
- PRUint32 num;
- unsigned int i;
- m_calendarArray->Count( &num );
- for( i=0; i calendar;
- m_calendarArray->GetElementAt( i, getter_AddRefs( calendar ) );
- calendar->AddObserver( observer );
- }
- observer->OnLoad();
- }
- return NS_OK;
-}
-
-NS_IMETHODIMP
-oeICalContainerImpl::RemoveObserver(oeIICalObserver *observer)
-{
-#ifdef ICAL_DEBUG_ALL
- printf( "oeICalContainerImpl::RemoveObserver()\n" );
-#endif
- if( observer ) {
- PRUint32 num;
- unsigned int i;
- m_calendarArray->Count( &num );
- for( i=0; i calendar;
- m_calendarArray->GetElementAt( i, getter_AddRefs( calendar ) );
- calendar->RemoveObserver( observer );
- }
- m_observerArray->RemoveElement( observer );
- NS_RELEASE( observer );
- }
- return NS_OK;
-}
-
-NS_IMETHODIMP
-oeICalContainerImpl::AddTodoObserver(oeIICalTodoObserver *observer)
-{
-#ifdef ICAL_DEBUG_ALL
- printf( "oeICalContainerImpl::AddTodoObserver()\n" );
-#endif
- if( observer ) {
- NS_ADDREF( observer );
- m_todoobserverArray->AppendElement( observer );
-
- PRUint32 num;
- unsigned int i;
- m_calendarArray->Count( &num );
- for( i=0; i calendar;
- m_calendarArray->GetElementAt( i, getter_AddRefs( calendar ) );
- calendar->AddTodoObserver( observer );
- }
- observer->OnLoad();
- }
- return NS_OK;
-}
-
-NS_IMETHODIMP
-oeICalContainerImpl::RemoveTodoObserver(oeIICalTodoObserver *observer)
-{
-#ifdef ICAL_DEBUG_ALL
- printf( "oeICalContainerImpl::RemoveTodoObserver()\n" );
-#endif
- if( observer ) {
- PRUint32 num;
- unsigned int i;
- m_calendarArray->Count( &num );
- for( i=0; i calendar;
- m_calendarArray->GetElementAt( i, getter_AddRefs( calendar ) );
- calendar->RemoveTodoObserver( observer );
- }
- m_todoobserverArray->RemoveElement( observer );
- NS_RELEASE( observer );
- }
- return NS_OK;
-}
-
-NS_IMETHODIMP oeICalContainerImpl::AddTodo(oeIICalTodo *icaltodo, const nsACString &aServer, char **retid)
-{
-#ifdef ICAL_DEBUG
- printf( "oeICalContainerImpl::AddTodo()\n" );
-#endif
- nsresult rv;
- nsCOMPtr calendar;
- GetCalendar( aServer , getter_AddRefs(calendar) );
- if( !calendar ) {
- AddCalendar( aServer, "" );
- GetCalendar( aServer , getter_AddRefs(calendar) );
- if( !calendar ) {
- #ifdef ICAL_DEBUG
- printf( "oeICalContainerImpl::AddTodo()-Error cannot find or create calendar\n" );
- #endif
- return NS_ERROR_FAILURE;
- } else {
- rv = calendar->AddTodo( icaltodo, retid );
- RemoveCalendar( aServer );
- }
- } else {
- rv = calendar->AddTodo( icaltodo, retid );
- }
- return rv;
-}
-
-NS_IMETHODIMP
-oeICalContainerImpl::DeleteTodo( const char *id )
-{
-#ifdef ICAL_DEBUG
- printf( "oeICalContainerImpl::DeleteTodo( %s )\n", id );
-#endif
- if( id == nsnull ) {
- #ifdef ICAL_DEBUG
- printf( "oeICalContainerImpl::DeleteTodo() - Invalid Id.\n" );
- #endif
- return NS_ERROR_FAILURE;
- }
- oeIICalTodo *todo;
- FetchTodo( id , &todo );
- if( !todo ) {
- #ifdef ICAL_DEBUG
- printf( "oeICalContainerImpl::DeleteTodo() - Todo Not Found.\n" );
- #endif
- return NS_ERROR_FAILURE;
- }
- oeIICal *calendar;
- todo->GetParent( &calendar );
- NS_RELEASE( todo );
- if( !calendar ) {
- #ifdef ICAL_DEBUG
- printf( "oeICalContainerImpl::DeleteTodo()-Error: Todo does not have a parent calendar\n" );
- #endif
- return NS_ERROR_FAILURE;
- }
- nsresult rv = calendar->DeleteTodo( id );
- NS_RELEASE( calendar );
-
- return rv;
-}
-
-NS_IMETHODIMP oeICalContainerImpl::FetchTodo( const char *id, oeIICalTodo **ev)
-{
-#ifdef ICAL_DEBUG_ALL
- printf( "oeICalContainerImpl::FetchTodo()\n" );
-#endif
-
- if( id == nsnull ) {
- #ifdef ICAL_DEBUG
- printf( "oeICalContainerImpl::FetchTodo() - Invalid Id.\n" );
- #endif
- *ev = nsnull;
- return NS_ERROR_FAILURE;
- }
-
- PRUint32 num;
- unsigned int i;
-
- *ev = nsnull;
- m_calendarArray->Count( &num );
- for( i=0; i calendar;
- m_calendarArray->GetElementAt( i, getter_AddRefs(calendar) );
- calendar->FetchTodo( id, ev );
- if( *ev )
- break;
- }
-
- return NS_OK;
-}
-
-NS_IMETHODIMP oeICalContainerImpl::ModifyTodo(oeIICalTodo *icalevent, char **retid)
-{
-#ifdef ICAL_DEBUG
- printf( "oeICalContainerImpl::ModifyEvent()\n" );
-#endif
- oeIICal *calendar;
- icalevent->GetParent( &calendar );
- if( !calendar ) {
- #ifdef ICAL_DEBUG
- printf( "oeICalContainerImpl::ModifyEvent()-Error: ToDo does not have a parent calendar\n" );
- #endif
- return NS_ERROR_FAILURE;
- }
- nsresult rv = calendar->ModifyTodo( icalevent, retid );
- NS_RELEASE( calendar );
- return rv;
-}
-
-NS_IMETHODIMP
-oeICalContainerImpl::GetAllTodos(nsISimpleEnumerator **resultList )
-{
-#ifdef ICAL_DEBUG
- printf( "oeICalContainerImpl::GetAllTodos()\n" );
-#endif
- PRUint32 num;
- unsigned int i;
- nsCOMArray listOfEnums;
-
- m_calendarArray->Count( &num );
- for( i=0; i calendar;
- m_calendarArray->GetElementAt( i, getter_AddRefs( calendar ) );
- nsCOMPtr eventEnum;
- calendar->GetAllTodos( getter_AddRefs(eventEnum) );
- listOfEnums.AppendObject(eventEnum);
- }
-
- *resultList = new oeCollectedEventEnumerator(listOfEnums);
- if (!*resultList)
- return NS_ERROR_OUT_OF_MEMORY;
-
- NS_ADDREF(*resultList);
- return NS_OK;
-}
-
-NS_IMETHODIMP oeICalContainerImpl::ReportError( PRInt16 severity, PRUint32 errorid, const char *errorstring ) {
- PRUint32 num;
- unsigned int i;
- m_observerArray->Count( &num );
- for ( i=0; iGetElementAt( i, (nsISupports **)&tmpobserver );
- tmpobserver->OnError( severity, errorid, errorstring );
- }
-
- m_todoobserverArray->Count( &num );
- for ( i=0; iGetElementAt( i, (nsISupports **)&tmpobserver );
- tmpobserver->OnError( severity, errorid, errorstring );
- }
- return NS_OK;
-}
-
-/*************************************************************************************************************/
-/*************************************************************************************************************/
-/*************************************************************************************************************/
-/* Filter stuff here */
-/*************************************************************************************************************/
-/*************************************************************************************************************/
-
-NS_IMETHODIMP oeICalContainerImpl::GetFilter( oeIICalTodo **retval )
-{
- *retval = m_filter;
- NS_ADDREF(*retval);
- return NS_OK;
-}
-
-NS_IMETHODIMP oeICalContainerImpl::ResetFilter()
-{
- PRUint32 num;
- unsigned int i;
-
- m_calendarArray->Count( &num );
- for( i=0; i calendar;
- m_calendarArray->GetElementAt( i, getter_AddRefs(calendar) );
- calendar->ResetFilter();
- }
- oeIDateTime *completed;
- m_filter->GetCompleted( &completed );
- completed->Clear();
- return NS_OK;
-}
-
-NS_IMPL_ISUPPORTS1(oeICalContainerFilter, oeIICalTodo)
-
-oeICalContainerFilter::oeICalContainerFilter()
-{
- m_completed = new oeFilterDateTime();
- m_completed->SetFieldType( ICAL_COMPLETED_PROPERTY );
- m_completed->m_parent = this;
- NS_ADDREF( m_completed );
-}
-
-oeICalContainerFilter::~oeICalContainerFilter()
-{
- NS_RELEASE( m_completed );
-}
-
-NS_IMETHODIMP oeICalContainerFilter::GetType(Componenttype *aRetVal)
-{
- return NS_ERROR_NOT_IMPLEMENTED;
-}
-
-NS_IMETHODIMP oeICalContainerFilter::GetId(char **aRetVal)
-{
- return NS_ERROR_NOT_IMPLEMENTED;
-}
-
-NS_IMETHODIMP oeICalContainerFilter::SetId(const char *aNewVal)
-{
- return NS_ERROR_NOT_IMPLEMENTED;
-}
-
-NS_IMETHODIMP oeICalContainerFilter::GetTitle(nsACString& aRetVal)
-{
- return NS_ERROR_NOT_IMPLEMENTED;
-}
-
-NS_IMETHODIMP oeICalContainerFilter::SetTitle(const nsACString& aNewVal)
-{
- return NS_ERROR_NOT_IMPLEMENTED;
-}
-
-NS_IMETHODIMP oeICalContainerFilter::GetDescription(nsACString& aRetVal)
-{
- return NS_ERROR_NOT_IMPLEMENTED;
-}
-
-NS_IMETHODIMP oeICalContainerFilter::SetDescription(const nsACString& aNewVal)
-{
- return NS_ERROR_NOT_IMPLEMENTED;
-}
-
-NS_IMETHODIMP oeICalContainerFilter::GetLocation(nsACString& aRetVal)
-{
- return NS_ERROR_NOT_IMPLEMENTED;
-}
-
-NS_IMETHODIMP oeICalContainerFilter::SetLocation(const nsACString& aNewVal)
-{
- return NS_ERROR_NOT_IMPLEMENTED;
-}
-
-NS_IMETHODIMP oeICalContainerFilter::GetCategories(nsACString& aRetVal)
-{
- return NS_ERROR_NOT_IMPLEMENTED;
-}
-
-NS_IMETHODIMP oeICalContainerFilter::SetCategories(const nsACString& aNewVal)
-{
- return NS_ERROR_NOT_IMPLEMENTED;
-}
-
-NS_IMETHODIMP oeICalContainerFilter::GetUrl(nsACString& aRetVal)
-{
- return NS_ERROR_NOT_IMPLEMENTED;
-}
-
-NS_IMETHODIMP oeICalContainerFilter::SetUrl(const nsACString& aNewVal)
-{
- return NS_ERROR_NOT_IMPLEMENTED;
-}
-
-NS_IMETHODIMP oeICalContainerFilter::GetPrivateEvent(PRBool *aRetVal)
-{
- return NS_ERROR_NOT_IMPLEMENTED;
-}
-
-NS_IMETHODIMP oeICalContainerFilter::SetPrivateEvent(PRBool aNewVal)
-{
- return NS_ERROR_NOT_IMPLEMENTED;
-}
-
-NS_IMETHODIMP oeICalContainerFilter::GetMethod(eventMethodProperty *aRetVal)
-{
- return NS_ERROR_NOT_IMPLEMENTED;
-}
-
-NS_IMETHODIMP oeICalContainerFilter::SetMethod(eventMethodProperty aNewVal)
-{
- return NS_ERROR_NOT_IMPLEMENTED;
-}
-
-NS_IMETHODIMP oeICalContainerFilter::GetStatus(eventStatusProperty *aRetVal)
-{
- return NS_ERROR_NOT_IMPLEMENTED;
-}
-
-NS_IMETHODIMP oeICalContainerFilter::SetStatus(eventStatusProperty aNewVal)
-{
- return NS_ERROR_NOT_IMPLEMENTED;
-}
-
-NS_IMETHODIMP oeICalContainerFilter::GetPriority(PRInt16 *aRetVal)
-{
- return NS_ERROR_NOT_IMPLEMENTED;
-}
-
-NS_IMETHODIMP oeICalContainerFilter::SetPriority(PRInt16 aNewVal)
-{
- return NS_ERROR_NOT_IMPLEMENTED;
-}
-
-NS_IMETHODIMP oeICalContainerFilter::GetSyncId(char * *aRetVal)
-{
- return NS_ERROR_NOT_IMPLEMENTED;
-}
-
-NS_IMETHODIMP oeICalContainerFilter::SetSyncId(const char * aNewVal)
-{
- return NS_ERROR_NOT_IMPLEMENTED;
-}
-
-NS_IMETHODIMP oeICalContainerFilter::GetAllDay(PRBool *aRetVal)
-{
- return NS_ERROR_NOT_IMPLEMENTED;
-}
-NS_IMETHODIMP oeICalContainerFilter::SetAllDay(PRBool aNewVal)
-{
- return NS_ERROR_NOT_IMPLEMENTED;
-}
-
-NS_IMETHODIMP oeICalContainerFilter::GetAlarm(PRBool *aRetVal)
-{
- return NS_ERROR_NOT_IMPLEMENTED;
-}
-
-NS_IMETHODIMP oeICalContainerFilter::SetAlarm(PRBool aNewVal)
-{
- return NS_ERROR_NOT_IMPLEMENTED;
-}
-
-NS_IMETHODIMP oeICalContainerFilter::GetAlarmUnits(char * *aRetVal)
-{
- return NS_ERROR_NOT_IMPLEMENTED;
-}
-
-NS_IMETHODIMP oeICalContainerFilter::SetAlarmUnits(const char * aNewVal)
-{
- return NS_ERROR_NOT_IMPLEMENTED;
-}
-
-NS_IMETHODIMP oeICalContainerFilter::GetAlarmLength(PRUint32 *aRetVal)
-{
- return NS_ERROR_NOT_IMPLEMENTED;
-}
-
-NS_IMETHODIMP oeICalContainerFilter::SetAlarmLength(PRUint32 aNewVal)
-{
- return NS_ERROR_NOT_IMPLEMENTED;
-}
-
-NS_IMETHODIMP oeICalContainerFilter::GetAlarmEmailAddress(char * *aRetVal)
-{
- return NS_ERROR_NOT_IMPLEMENTED;
-}
-
-NS_IMETHODIMP oeICalContainerFilter::SetAlarmEmailAddress(const char * aNewVal)
-{
- return NS_ERROR_NOT_IMPLEMENTED;
-}
-
-NS_IMETHODIMP oeICalContainerFilter::GetInviteEmailAddress(char * *aRetVal)
-{
- return NS_ERROR_NOT_IMPLEMENTED;
-}
-
-NS_IMETHODIMP oeICalContainerFilter::SetInviteEmailAddress(const char * aNewVal)
-{
- return NS_ERROR_NOT_IMPLEMENTED;
-}
-
-NS_IMETHODIMP oeICalContainerFilter::GetRecurInterval(PRUint32 *aRetVal)
-{
- return NS_ERROR_NOT_IMPLEMENTED;
-}
-
-NS_IMETHODIMP oeICalContainerFilter::SetRecurInterval(PRUint32 aNewVal )
-{
- return NS_ERROR_NOT_IMPLEMENTED;
-}
-
-NS_IMETHODIMP oeICalContainerFilter::GetRecurCount(PRUint32 *aRetVal)
-{
- return NS_ERROR_NOT_IMPLEMENTED;
-}
-
-NS_IMETHODIMP oeICalContainerFilter::SetRecurCount(PRUint32 aNewVal )
-{
- return NS_ERROR_NOT_IMPLEMENTED;
-}
-
-NS_IMETHODIMP oeICalContainerFilter::GetRecurUnits(char **aRetVal)
-{
- return NS_ERROR_NOT_IMPLEMENTED;
-}
-
-NS_IMETHODIMP oeICalContainerFilter::SetRecurUnits(const char * aNewVal)
-{
- return NS_ERROR_NOT_IMPLEMENTED;
-}
-
-NS_IMETHODIMP oeICalContainerFilter::GetRecur(PRBool *aRetVal)
-{
- return NS_ERROR_NOT_IMPLEMENTED;
-}
-
-NS_IMETHODIMP oeICalContainerFilter::SetRecur(PRBool aNewVal)
-{
- return NS_ERROR_NOT_IMPLEMENTED;
-}
-
-NS_IMETHODIMP oeICalContainerFilter::GetRecurForever(PRBool *aRetVal)
-{
- return NS_ERROR_NOT_IMPLEMENTED;
-}
-NS_IMETHODIMP oeICalContainerFilter::SetRecurForever(PRBool aNewVal)
-{
- return NS_ERROR_NOT_IMPLEMENTED;
-}
-
-NS_IMETHODIMP oeICalContainerFilter::GetLastModified(PRTime *aRetVal)
-{
- return NS_ERROR_NOT_IMPLEMENTED;
-}
-
-NS_IMETHODIMP oeICalContainerFilter::UpdateLastModified()
-{
- return NS_ERROR_NOT_IMPLEMENTED;
-}
-
-NS_IMETHODIMP oeICalContainerFilter::GetLastAlarmAck(PRTime *aNewVal)
-{
- return NS_ERROR_NOT_IMPLEMENTED;
-}
-
-NS_IMETHODIMP oeICalContainerFilter::SetLastAlarmAck(PRTime aNewVal)
-{
- return NS_ERROR_NOT_IMPLEMENTED;
-}
-
-NS_IMETHODIMP oeICalContainerFilter::GetNextRecurrence( PRTime begin, PRTime *retval, PRBool *isvalid ) {
- return NS_ERROR_NOT_IMPLEMENTED;
-}
-
-NS_IMETHODIMP oeICalContainerFilter::GetPreviousOccurrence( PRTime beforethis, PRTime *retval, PRBool *isvalid ) {
- return NS_ERROR_NOT_IMPLEMENTED;
-}
-
-NS_IMETHODIMP oeICalContainerFilter::GetStart(oeIDateTime * *start)
-{
- return NS_ERROR_NOT_IMPLEMENTED;
-}
-
-NS_IMETHODIMP oeICalContainerFilter::GetEnd(oeIDateTime * *end)
-{
- return NS_ERROR_NOT_IMPLEMENTED;
-}
-
-NS_IMETHODIMP oeICalContainerFilter::GetStamp(oeIDateTime * *stamp)
-{
- return NS_ERROR_NOT_IMPLEMENTED;
-}
-
-NS_IMETHODIMP oeICalContainerFilter::GetRecurEnd(oeIDateTime * *recurend)
-{
- return NS_ERROR_NOT_IMPLEMENTED;
-}
-
-NS_IMETHODIMP oeICalContainerFilter::GetRecurWeekdays(PRInt16 *aRetVal)
-{
- return NS_ERROR_NOT_IMPLEMENTED;
-}
-NS_IMETHODIMP oeICalContainerFilter::SetRecurWeekdays(PRInt16 aNewVal)
-{
- return NS_ERROR_NOT_IMPLEMENTED;
-}
-
-NS_IMETHODIMP oeICalContainerFilter::GetRecurWeekNumber(PRInt16 *aRetVal)
-{
- return NS_ERROR_NOT_IMPLEMENTED;
-}
-
-NS_IMETHODIMP oeICalContainerFilter::SetRecurWeekNumber(PRInt16 aNewVal)
-{
- return NS_ERROR_NOT_IMPLEMENTED;
-}
-
-NS_IMETHODIMP oeICalContainerFilter::GetIcalString(nsACString& aRetVal)
-{
- return NS_ERROR_NOT_IMPLEMENTED;
-}
-
- NS_IMETHODIMP oeICalContainerFilter::ParseIcalString(const nsACString& aNewVal, PRBool *aRetVal)
-{
- return NS_ERROR_NOT_IMPLEMENTED;
-}
-
-NS_IMETHODIMP oeICalContainerFilter::AddException( PRTime exdate )
-{
- return NS_ERROR_NOT_IMPLEMENTED;
-}
-
-NS_IMETHODIMP oeICalContainerFilter::RemoveAllExceptions()
-{
- return NS_ERROR_NOT_IMPLEMENTED;
-}
-
-NS_IMETHODIMP oeICalContainerFilter::GetExceptions(nsISimpleEnumerator **datelist )
-{
- return NS_ERROR_NOT_IMPLEMENTED;
-}
-
-NS_IMETHODIMP oeICalContainerFilter::SetSnoozeTime( PRTime snoozetime )
-{
- return NS_ERROR_NOT_IMPLEMENTED;
-}
-
-NS_IMETHODIMP oeICalContainerFilter::Clone( oeIICalEvent **ev )
-{
- return NS_ERROR_NOT_IMPLEMENTED;
-}
-
-NS_IMETHODIMP oeICalContainerFilter::GetDue(oeIDateTime * *due)
-{
- return NS_ERROR_NOT_IMPLEMENTED;
-}
-
-NS_IMETHODIMP oeICalContainerFilter::GetCompleted(oeIDateTime * *completed)
-{
- *completed = m_completed;
- NS_ADDREF(*completed);
- return NS_OK;
-}
-
-NS_IMETHODIMP oeICalContainerFilter::GetPercent(PRInt16 *aRetVal)
-{
- return NS_ERROR_NOT_IMPLEMENTED;
-}
-
-NS_IMETHODIMP oeICalContainerFilter::SetPercent(PRInt16 aNewVal)
-{
- return NS_ERROR_NOT_IMPLEMENTED;
-}
-
-NS_IMETHODIMP oeICalContainerFilter::AddAttachment(nsIMsgAttachment *attachment)
-{
- return NS_ERROR_NOT_IMPLEMENTED;
-}
-
-NS_IMETHODIMP oeICalContainerFilter::RemoveAttachment(nsIMsgAttachment *attachment)
-{
- return NS_ERROR_NOT_IMPLEMENTED;
-}
-
-NS_IMETHODIMP oeICalContainerFilter::RemoveAttachments()
-{
- return NS_ERROR_NOT_IMPLEMENTED;
-}
-
-NS_IMETHODIMP oeICalContainerFilter::GetAttachmentsArray(nsISupportsArray * *aAttachmentsArray)
-{
- return NS_ERROR_NOT_IMPLEMENTED;
-}
-
-NS_IMETHODIMP oeICalContainerFilter::AddContact(nsIAbCard *contact)
-{
- return NS_ERROR_NOT_IMPLEMENTED;
-}
-
-NS_IMETHODIMP oeICalContainerFilter::RemoveContact(nsIAbCard *contact)
-{
- return NS_ERROR_NOT_IMPLEMENTED;
-}
-
-NS_IMETHODIMP oeICalContainerFilter::RemoveContacts()
-{
- return NS_ERROR_NOT_IMPLEMENTED;
-}
-
-NS_IMETHODIMP oeICalContainerFilter::GetContactsArray(nsISupportsArray * *aContactsArray)
-{
- return NS_ERROR_NOT_IMPLEMENTED;
-}
-
-NS_IMETHODIMP oeICalContainerFilter::SetParent( oeIICal *parent)
-{
- return NS_ERROR_NOT_IMPLEMENTED;
-}
-
-NS_IMETHODIMP oeICalContainerFilter::GetParent( oeIICal **parent)
-{
- return NS_ERROR_NOT_IMPLEMENTED;
-}
-
-NS_IMETHODIMP oeICalContainerFilter::GetTodoIcalString(nsACString& aRetVal)
-{
- return NS_ERROR_NOT_IMPLEMENTED;
-}
-
-NS_IMETHODIMP oeICalContainerFilter::ParseTodoIcalString(const nsACString& aNewVal, PRBool *aRetVal)
-{
- return NS_ERROR_NOT_IMPLEMENTED;
-}
-
-NS_IMETHODIMP oeICalContainerFilter::SetDuration(PRBool is_negative, PRUint16 weeks, PRUint16 days, PRUint16 hours, PRUint16 minutes, PRUint16 seconds)
-{
- return NS_ERROR_NOT_IMPLEMENTED;
-}
-
-NS_IMETHODIMP oeICalContainerFilter::GetDuration(PRBool *is_negative, PRUint16 *weeks, PRUint16 *days, PRUint16 *hours, PRUint16 *minutes, PRUint16 *seconds)
-{
- return NS_ERROR_NOT_IMPLEMENTED;
-}
-
-void oeICalContainerFilter::UpdateAllFilters( PRInt32 icaltype )
-{
- switch ( icaltype ) {
- case ICAL_COMPLETED_PROPERTY:
- PRTime completedvalue;
- m_completed->GetTime( &completedvalue );
-
- PRUint32 num;
- unsigned int i;
-
- m_calendarArray->Count( &num );
- for( i=0; i calendar;
- m_calendarArray->GetElementAt( i, getter_AddRefs(calendar) );
- oeIICalTodo *filter;
- //XXX comptr? getter_AddRefs?
- calendar->GetFilter( &filter );
- if (filter) {
- oeIDateTime *completed;
- filter->GetCompleted( &completed );
- completed->SetTime( completedvalue );
- }
- }
-
- break;
- default:
- break;
- }
-}
-
-NS_IMETHODIMP oeICalContainerFilter::ReportError( PRInt16 severity, PRUint32 errorid, const char *errorstring ) {
- return NS_ERROR_NOT_IMPLEMENTED;
-}
-
-NS_IMETHODIMP oeICalContainerFilter::SetParameter( const char *name, const char *value ) {
- return NS_ERROR_NOT_IMPLEMENTED;
-}
-
-NS_IMETHODIMP oeICalContainerFilter::GetParameter( const char *name, char **value ) {
- return NS_ERROR_NOT_IMPLEMENTED;
-}
-
-///////////////////////////////////////////////////
-// FilterDateTime
-//////////////////////////////////////////////////
-
-NS_IMPL_ISUPPORTS1(oeFilterDateTime, oeIDateTime)
-
-oeFilterDateTime::oeFilterDateTime()
-{
- m_datetime = icaltime_null_time();
-}
-
-oeFilterDateTime::~oeFilterDateTime()
-{
-}
-
-NS_IMETHODIMP oeFilterDateTime::GetYear(PRInt16 *retval)
-{
- *retval = m_datetime.year;
- return NS_OK;
-}
-NS_IMETHODIMP oeFilterDateTime::SetYear(PRInt16 newval)
-{
- m_datetime.year = newval;
- m_parent->UpdateAllFilters( m_icaltype );
- return NS_OK;
-}
-
-NS_IMETHODIMP oeFilterDateTime::GetMonth(PRInt16 *retval)
-{
- *retval = m_datetime.month - 1;
- return NS_OK;
-}
-NS_IMETHODIMP oeFilterDateTime::SetMonth(PRInt16 newval)
-{
- m_datetime.month = newval + 1;
- if( m_datetime.month < 1 || m_datetime.month > 12 )
- m_datetime = icaltime_normalize( m_datetime );
- m_parent->UpdateAllFilters( m_icaltype );
- return NS_OK;
-}
-
-NS_IMETHODIMP oeFilterDateTime::GetDay(PRInt16 *retval)
-{
- *retval = m_datetime.day;
- return NS_OK;
-}
-NS_IMETHODIMP oeFilterDateTime::SetDay(PRInt16 newval)
-{
- m_datetime.day = newval;
- if( newval < 1 || newval > 31 )
- m_datetime = icaltime_normalize( m_datetime );
- m_parent->UpdateAllFilters( m_icaltype );
- return NS_OK;
-}
-
-NS_IMETHODIMP oeFilterDateTime::GetHour(PRInt16 *retval)
-{
- *retval = m_datetime.hour;
- return NS_OK;
-}
-NS_IMETHODIMP oeFilterDateTime::SetHour(PRInt16 newval)
-{
- m_datetime.hour = newval;
- if( newval < 0 || newval > 23 )
- m_datetime = icaltime_normalize( m_datetime );
- m_parent->UpdateAllFilters( m_icaltype );
- return NS_OK;
-}
-
-NS_IMETHODIMP oeFilterDateTime::GetMinute(PRInt16 *retval)
-{
- *retval = m_datetime.minute;
- return NS_OK;
-}
-NS_IMETHODIMP oeFilterDateTime::SetMinute(PRInt16 newval)
-{
- m_datetime.minute = newval;
- if( newval < 0 || newval > 59 )
- m_datetime = icaltime_normalize( m_datetime );
- m_parent->UpdateAllFilters( m_icaltype );
- return NS_OK;
-}
-
-NS_IMETHODIMP oeFilterDateTime::GetTime(PRTime *retval)
-{
- *retval = ConvertToPrtime( m_datetime );
- return NS_OK;
-}
-
-NS_IMETHODIMP oeFilterDateTime::ToString(char **retval)
-{
- char tmp[20];
- sprintf( tmp, "%04d/%02d/%02d %02d:%02d:%02d" , m_datetime.year, m_datetime.month, m_datetime.day, m_datetime.hour, m_datetime.minute, m_datetime.second );
- *retval= (char*) nsMemory::Clone( tmp, strlen(tmp)+1);
- return NS_OK;
-}
-
-NS_IMETHODIMP oeFilterDateTime::SetTime( PRTime ms )
-{
- m_datetime = ConvertFromPrtime( ms );
- m_parent->UpdateAllFilters( m_icaltype );
- return NS_OK;
-}
-
-NS_IMETHODIMP oeFilterDateTime::Clear()
-{
- m_datetime = icaltime_null_time();
- m_parent->UpdateAllFilters( m_icaltype );
- return NS_OK;
-}
-
-NS_IMETHODIMP oeFilterDateTime::GetIsSet(PRBool *retval)
-{
- *retval = ! icaltime_is_null_time(m_datetime);
- return NS_OK;
-}
-
-NS_IMETHODIMP oeFilterDateTime::GetUtc(PRBool *retval)
-{
- *retval = m_datetime.is_utc;
- return NS_OK;
-}
-
-NS_IMETHODIMP oeFilterDateTime::SetUtc(PRBool newval)
-{
- m_datetime.is_utc = newval;
- m_parent->UpdateAllFilters( m_icaltype );
- return NS_OK;
-}
-
-void oeFilterDateTime::SetFieldType( PRInt32 icaltype )
-{
- m_icaltype = icaltype;
-}
-
-NS_IMETHODIMP oeFilterDateTime::GetTzID(char **aRetVal)
-{
- return NS_ERROR_NOT_IMPLEMENTED;
-}
-
-NS_IMETHODIMP oeFilterDateTime::SetTimeInTimezone( PRTime ms, const char *tzid )
-{
- return NS_ERROR_NOT_IMPLEMENTED;
-}
diff --git a/mozilla/calendar/libxpical/oeICalContainerImpl.h b/mozilla/calendar/libxpical/oeICalContainerImpl.h
deleted file mode 100644
index b37467214ed..00000000000
--- a/mozilla/calendar/libxpical/oeICalContainerImpl.h
+++ /dev/null
@@ -1,114 +0,0 @@
-/* ***** BEGIN LICENSE BLOCK *****
- * Version: MPL 1.1/GPL 2.0/LGPL 2.1
- *
- * The contents of this file are subject to the Mozilla Public License Version
- * 1.1 (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * Software distributed under the License is distributed on an "AS IS" basis,
- * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
- * for the specific language governing rights and limitations under the
- * License.
- *
- * The Original Code is OEone Calendar Code, released October 31st, 2001.
- *
- * The Initial Developer of the Original Code is
- * OEone Corporation.
- * Portions created by the Initial Developer are Copyright (C) 2001
- * the Initial Developer. All Rights Reserved.
- *
- * Contributor(s): Mostafa Hosseini
- *
- * Alternatively, the contents of this file may be used under the terms of
- * either the GNU General Public License Version 2 or later (the "GPL"), or
- * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
- * in which case the provisions of the GPL or the LGPL are applicable instead
- * of those above. If you wish to allow use of your version of this file only
- * under the terms of either the GPL or the LGPL, and not to allow others to
- * use your version of this file under the terms of the MPL, indicate your
- * decision by deleting the provisions above and replace them with the notice
- * and other provisions required by the GPL or the LGPL. If you do not delete
- * the provisions above, a recipient may use your version of this file under
- * the terms of any one of the MPL, the GPL or the LGPL.
- *
- * ***** END LICENSE BLOCK ***** */
-
-/* Header file for oeICalContainerImpl.cpp containing its CID and CONTRACTID.*/
-
-#include "oeIICal.h"
-#include "oeICalImpl.h"
-#include "oeICalEventImpl.h"
-#include "oeICalTodoImpl.h"
-#include "nsISupportsArray.h"
-
-#define OE_ICALCONTAINER_CID \
-{ 0x10697055, 0x4199, 0x4c2a, { 0x89, 0xf4, 0x60, 0x24, 0x3a, 0x8c, 0x76, 0xca } }
-
-#define OE_ICALCONTAINER_CONTRACTID "@mozilla.org/ical-container;1"
-
-class oeFilterDateTime : public oeIDateTime
-{
-public:
- NS_DECL_ISUPPORTS
- NS_DECL_OEIDATETIME
- oeFilterDateTime();
- virtual ~oeFilterDateTime();
- void SetFieldType( PRInt32 type );
- class oeICalContainerFilter *m_parent;
-private:
- struct icaltimetype m_datetime;
- PRInt32 m_icaltype;
-};
-
-class oeICalContainerFilter : public oeIICalTodo
-{
-public:
- NS_DECL_ISUPPORTS
- NS_DECL_OEIICALEVENT
- NS_DECL_OEIICALTODO
-
- oeICalContainerFilter();
- virtual ~oeICalContainerFilter();
- nsCOMPtr m_calendarArray;
- void UpdateAllFilters( PRInt32 icaltype );
-private:
- oeFilterDateTime *m_completed;
-};
-
-class oeICalContainerImpl : public oeIICalContainer
-{
-public:
- oeICalContainerImpl();
- virtual ~oeICalContainerImpl();
-
- /**
- * This macro expands into a declaration of the nsISupports interface.
- * Every XPCOM component needs to implement nsISupports, as it acts
- * as the gateway to other interfaces this component implements. You
- * could manually declare QueryInterface, AddRef, and Release instead
- * of using this macro, but why?
- */
- // nsISupports interface
- NS_DECL_ISUPPORTS
-
- /**
- * This macro is defined in the nsISample.h file, and is generated
- * automatically by the xpidl compiler. It expands to
- * declarations of all of the methods required to implement the
- * interface. xpidl will generate a NS_DECL_[INTERFACENAME] macro
- * for each interface that it processes.
- *
- * The methods of nsISample are discussed individually below, but
- * commented out (because this macro already defines them.)
- */
- NS_DECL_OEIICALCONTAINER
- icaltimetype GetNextEvent( icaltimetype starting );
-private:
- bool m_batchMode;
- bool m_suppressAlarmsByDefault;
- nsCOMPtr m_calendarArray;
- nsCOMPtr m_observerArray;
- nsCOMPtr m_todoobserverArray;
- oeICalContainerFilter *m_filter;
-};
diff --git a/mozilla/calendar/libxpical/oeICalEventImpl.cpp b/mozilla/calendar/libxpical/oeICalEventImpl.cpp
deleted file mode 100644
index e1b42fdf146..00000000000
--- a/mozilla/calendar/libxpical/oeICalEventImpl.cpp
+++ /dev/null
@@ -1,3010 +0,0 @@
-/* ***** BEGIN LICENSE BLOCK *****
- * Version: MPL 1.1/GPL 2.0/LGPL 2.1
- *
- * The contents of this file are subject to the Mozilla Public License Version
- * 1.1 (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * Software distributed under the License is distributed on an "AS IS" basis,
- * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
- * for the specific language governing rights and limitations under the
- * License.
- *
- * The Original Code is OEone Calendar Code, released October 31st, 2001.
- *
- * The Initial Developer of the Original Code is
- * OEone Corporation.
- * Portions created by the Initial Developer are Copyright (C) 2001
- * the Initial Developer. All Rights Reserved.
- *
- * Contributor(s): Mostafa Hosseini
- * Gary Frederick
- * ArentJan Banck
- * Alexandre Pauzies
- *
- * Alternatively, the contents of this file may be used under the terms of
- * either the GNU General Public License Version 2 or later (the "GPL"), or
- * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
- * in which case the provisions of the GPL or the LGPL are applicable instead
- * of those above. If you wish to allow use of your version of this file only
- * under the terms of either the GPL or the LGPL, and not to allow others to
- * use your version of this file under the terms of the MPL, indicate your
- * decision by deleting the provisions above and replace them with the notice
- * and other provisions required by the GPL or the LGPL. If you do not delete
- * the provisions above, a recipient may use your version of this file under
- * the terms of any one of the MPL, the GPL or the LGPL.
- *
- * ***** END LICENSE BLOCK ***** */
-
-/* This file implements an XPCOM object which represents a calendar event. It provides access to individual
-fields of an event and performs calculations concerning its behaviour. The code for the eventDisplay object
-which is an event with display information added to it is included here as well.
-*/
-
-#include // for atol
-
-#include "oeICalEventImpl.h"
-#include "nsMemory.h"
-#include "nsCOMPtr.h"
-#include "plbase64.h"
-#include "nsComponentManagerUtils.h"
-#ifdef MOZ_MAIL_NEWS
-#include "nsIAbCard.h"
-#include "nsIMsgAttachment.h"
-#endif
-#include "nsIPrefBranch.h"
-#include "nsIPrefService.h"
-#include "nsIServiceManager.h"
-
-#define strcasecmp strcmp
-
-#define RECUR_NONE 0
-#define RECUR_DAILY 1
-#define RECUR_WEEKLY 2
-#define RECUR_MONTHLY_MDAY 3
-#define RECUR_MONTHLY_WDAY 4
-#define RECUR_YEARLY 5
-
-#define XPROP_SYNCID "X-MOZILLA-SYNCID"
-#define XPROP_LASTALARMACK "X-MOZILLA-LASTALARMACK"
-#define XPROP_RECURUNITS "X-MOZILLA-RECUR-DEFAULT-UNITS"
-#define XPROP_RECURINTERVAL "X-MOZILLA-RECUR-DEFAULT-INTERVAL"
-#define XPROP_ALARMUNITS "X-MOZILLA-ALARM-DEFAULT-UNITS"
-#define XPROP_ALARMLENGTH "X-MOZILLA-ALARM-DEFAULT-LENGTH"
-
-#define DEFAULT_ALARM_UNITS "minutes"
-#define DEFAULT_ALARM_LENGTH 15
-#define DEFAULT_RECUR_UNITS "weeks"
-#define DEFAULT_ALARMTRIGGER_RELATION ICAL_RELATED_START
-
-extern oeIICalContainer *gContainer;
-
-char *EmptyReturn() {
- return (char*) nsMemory::Clone( "", 1 );
-}
-
-icaltimetype ConvertFromPrtime( PRTime indate ) {
- icaltimetype outdate = icaltime_null_time();
-
- PRExplodedTime ext;
- PRInt64 indateinusec, usecpermsec;
- LL_I2L( usecpermsec, PR_USEC_PER_MSEC );
- LL_MUL( indateinusec, indate, usecpermsec );
- PR_ExplodeTime( indateinusec, PR_LocalTimeParameters, &ext);
-
- outdate.year = ext.tm_year;
- outdate.month = ext.tm_month + 1;
- outdate.day = ext.tm_mday;
- outdate.hour = ext.tm_hour;
- outdate.minute = ext.tm_min;
- outdate.second = ext.tm_sec;
- if( ext.tm_year <= 1969 && ext.tm_params.tp_dst_offset == 3600 )//Assume that daylight time saving was not in effect before 1970
- icaltime_adjust( &outdate, 0, -1, 0, 0 );
-
- return outdate;
-}
-
-PRTime ConvertToPrtime ( icaltimetype indate ) {
- PRExplodedTime ext;
- ext.tm_year = indate.year;
- ext.tm_month = indate.month - 1;
- ext.tm_mday = indate.day;
- ext.tm_hour = indate.hour;
- ext.tm_min = indate.minute;
- ext.tm_sec = indate.second;
- ext.tm_usec = 0;
- ext.tm_params.tp_gmt_offset = 0;
- ext.tm_params.tp_dst_offset = 0;
-
- PRTime result = PR_ImplodeTime( &ext );
- PR_ExplodeTime( result, PR_LocalTimeParameters, &ext);
- if( ext.tm_year <= 1969 && ext.tm_params.tp_dst_offset == 3600 ) //Assume that daylight time saving was not in effect before 1970
- ext.tm_params.tp_dst_offset = 0;
- ext.tm_year = indate.year;
- ext.tm_month = indate.month - 1;
- ext.tm_mday = indate.day;
- ext.tm_hour = indate.hour;
- ext.tm_min = indate.minute;
- ext.tm_sec = indate.second;
- ext.tm_usec = 0;
- result = PR_ImplodeTime( &ext );
- PRInt64 usecpermsec;
- LL_I2L( usecpermsec, PR_USEC_PER_MSEC );
- LL_DIV( result, result, usecpermsec );
- return result;
-}
-
-extern "C" {
-#include "token.h"
-}
-
-void GenerateUUID(char *output) {
- uuid_state state;
- uuid_t uuid;
-
- create_uuid_state(&state);
- create_token(&state, &uuid);
- format_token(output, &uuid);
-}
-
-//////////////////////////////////////////////////
-// UTF-8 functions
-//////////////////////////////////////////////////
-
-// IsValidUTF scans a string and checks if it is UTF-compliant
-// Most problems seem to come from 8-bit characters that are not ASCII with a value > 0x80
-PRBool
-IsValidUTF8(const char* aBuffer)
-{
- const char *c = aBuffer;
- const char *end = aBuffer + strlen(aBuffer);
- const char *lastchar = c; // pre-initialize in case of 0-length buffer
- PRUint32 ucs2bytes = 0;
- PRUint32 utf8bytes = 0;
- while (c < end && *c) {
- lastchar = c;
- ucs2bytes++;
-
- if ( (*c & 0x80) == 0x00 ) // ASCII
- c++;
- else if ( (*c & 0xE0) == 0xC0 ) // 2 byte
- c += 2;
- else if ( (*c & 0xF0) == 0xE0 ) // 3 byte
- c += 3;
- else if ( (*c & 0xF8) == 0xF0 ) // 4 byte
- c += 4;
- else if ( (*c & 0xFC) == 0xF8 ) // 5 byte
- c += 5;
- else if ( (*c & 0xFE) == 0xFC ) // 6 byte
- c += 6;
- else {
- break; // Otherwise we go into an infinite loop. But what happens now?
- }
- }
- if (c != end) {
- #ifdef ICAL_DEBUG_ALL
- printf( "IsValidUTF8 Invalid UTF-8 string \"%s\"\n", aBuffer );
- #endif
- utf8bytes = 0;
- return false;
- }
-
- utf8bytes = c - aBuffer;
- return true;
-}
-
-// strForceUTF8 checks if a string is UTF-8 encoded, and if not assumes it made from 8-bit characters.
-// If not UTF-8, all non-ASCII characters are replaced with '?'
-// TODO: write or hook a converter to convert non-ASCII to UTF-8
-const char* strForceUTF8(const char * str)
-{
-#define CHAR_INVALID '?'
- const char* result = str;
- if (!IsValidUTF8( result ) ) {
- // make sure there are only ASCII chars in the string
- char *p = (char *)result;
- for( int i=0; '\0' != p[i]; i++ )
- if(!( (p[i] & 0x80) == 0x00) )
- p[i] = CHAR_INVALID;
- }
- return result;
-}
-
-
-#ifdef ICAL_DEBUG
-int gEventCount = 0;
-int gEventDisplayCount = 0;
-#endif
-
-//////////////////////////////////////////////////
-// ICalEvent Factory
-//////////////////////////////////////////////////
-
-/* Implementation file */
-NS_IMPL_ISUPPORTS1(oeICalEventImpl, oeIICalEvent)
-
-nsresult
-NS_NewICalEvent( oeIICalEvent** inst )
-{
- NS_PRECONDITION(inst != nsnull, "null ptr");
- if (! inst)
- return NS_ERROR_NULL_POINTER;
-
- *inst = new oeICalEventImpl();
- if (! *inst)
- return NS_ERROR_OUT_OF_MEMORY;
-
- NS_ADDREF(*inst);
- return NS_OK;
-}
-
-oeICalEventImpl::oeICalEventImpl()
-{
-#ifdef ICAL_DEBUG
- printf( "oeICalEventImpl::oeICalEventImpl(): %d\n", ++gEventCount );
-#endif
- /* member initializers and constructor code */
- nsresult rv;
- if( NS_FAILED( rv = NS_NewDateTime((oeIDateTime**) &m_start ))) {
- m_start = nsnull;
- }
- if( NS_FAILED( rv = NS_NewDateTime((oeIDateTime**) &m_end ))) {
- m_end = nsnull;
- }
- if( NS_FAILED( rv = NS_NewDateTime((oeIDateTime**) &m_stamp ))) {
- m_stamp = nsnull;
- }
- if( NS_FAILED( rv = NS_NewDateTime((oeIDateTime**) &m_recurend ))) {
- m_recurend = nsnull;
- }
- if( m_stamp ) {
- PRInt64 nowinusec = PR_Now();
- PRExplodedTime ext;
- PR_ExplodeTime( nowinusec, PR_GMTParameters, &ext);
- m_stamp->m_datetime.year = ext.tm_year;
- m_stamp->m_datetime.month = ext.tm_month + 1;
- m_stamp->m_datetime.day = ext.tm_mday;
- m_stamp->m_datetime.hour = ext.tm_hour;
- m_stamp->m_datetime.minute = ext.tm_min;
- m_stamp->m_datetime.second = ext.tm_sec;
- m_stamp->m_datetime.is_utc = true;
- }
- m_type = ICAL_VEVENT_COMPONENT;
- m_id = nsnull;
- m_title.SetIsVoid(true);
- m_description.SetIsVoid(true);
- m_location.SetIsVoid(true);
- m_category.SetIsVoid(true);
- m_url.SetIsVoid(true);
- m_priority = 0;
- m_method = 0;
- m_status = 0;
- m_isprivate = true;
- m_syncid = nsnull;
- m_allday = false;
- m_hasalarm = false;
- m_storeingmt = false;
- m_alarmlength = DEFAULT_ALARM_LENGTH;
- m_alarmtriggerrelation = DEFAULT_ALARMTRIGGER_RELATION;
- m_alarmemail = nsnull;
- m_inviteemail = nsnull;
- m_recurinterval = 1;
- m_recurcount = 0;
- m_recur = false;
- m_recurforever = true;
- m_alarmunits = nsnull;
- m_recurunits = nsnull;
- m_recurweekdays = 0;
- m_recurweeknumber = 0;
- m_lastalarmack = icaltime_null_time();
- m_lastmodified = icaltime_null_time();
- m_duration = icaldurationtype_null_duration();
- SetAlarmUnits( DEFAULT_ALARM_UNITS );
- SetRecurUnits( DEFAULT_RECUR_UNITS );
- SetSyncId( "" );
- NS_NewISupportsArray(getter_AddRefs(m_attachments));
- NS_NewISupportsArray(getter_AddRefs(m_contacts));
- m_calendar=nsnull;
-
- //Some defaults may have been changed in the prefs
- nsCOMPtr prefBranch = do_GetService(NS_PREFSERVICE_CONTRACTID, &rv);
- if ( NS_SUCCEEDED(rv) && prefBranch ) {
- nsXPIDLCString tmpstr;
- PRInt32 tmpint;
- rv = prefBranch->GetIntPref("calendar.alarms.onforevents", &tmpint);
- if (NS_SUCCEEDED(rv))
- m_hasalarm = tmpint;
- rv = prefBranch->GetBoolPref("calendar.dateformat.storeingmt", &tmpint);
- if (NS_SUCCEEDED(rv))
- m_storeingmt = tmpint;
- rv = prefBranch->GetIntPref("calendar.alarms.eventalarmlen", &tmpint);
- if (NS_SUCCEEDED(rv))
- m_alarmlength = tmpint;
- rv = prefBranch->GetCharPref("calendar.alarms.eventalarmunit", getter_Copies(tmpstr));
- if (NS_SUCCEEDED(rv))
- SetAlarmUnits( PromiseFlatCString( tmpstr ).get() );
- rv = prefBranch->GetCharPref("calendar.alarms.emailaddress", getter_Copies(tmpstr));
- if (NS_SUCCEEDED(rv)) {
- SetAlarmEmailAddress( PromiseFlatCString( tmpstr ).get() );
- }
- }
-}
-
-oeICalEventImpl::~oeICalEventImpl()
-{
-#ifdef ICAL_DEBUG
- printf( "oeICalEventImpl::~oeICalEventImpl(): %d\n", --gEventCount );
-#endif
- /* destructor code */
- if( m_id )
- nsMemory::Free( m_id );
- if( m_alarmunits )
- nsMemory::Free( m_alarmunits );
- if( m_alarmemail )
- nsMemory::Free( m_alarmemail );
- if( m_inviteemail )
- nsMemory::Free( m_inviteemail );
- if( m_recurunits )
- nsMemory::Free( m_recurunits );
- if( m_syncid )
- nsMemory::Free( m_syncid );
-
- if( m_start )
- m_start->Release();
- if( m_end )
- m_end->Release();
- if( m_stamp )
- m_stamp->Release();
- if( m_recurend )
- m_recurend->Release();
- for( int i=0; im_datetime, before ) < 0 ) {
- *retval = ConvertToPrtime( m_start->m_datetime );
- *isvalid = true;
- }
- return NS_OK;
- }
-
- //for recurring events
- icalcomponent *vcalendar = AsIcalComponent();
- if ( !vcalendar ) {
- #ifdef ICAL_DEBUG
- printf( "oeICalEventImpl::GetPreviousOccurrence() failed!\n" );
- #endif
- return NS_OK;
- }
-
- icalcomponent *vevent = icalcomponent_get_first_component( vcalendar, ICAL_VEVENT_COMPONENT );
-
- icalproperty *prop = icalcomponent_get_first_property( vevent, ICAL_RRULE_PROPERTY );
- if ( prop != 0) {
- struct icalrecurrencetype recur = icalproperty_get_rrule(prop);
-// printf("#### %s\n",icalrecurrencetype_as_string(&recur));
- icalrecur_iterator* ritr = icalrecur_iterator_new(recur,m_start->m_datetime);
- struct icaltimetype next;
- for(next = icalrecur_iterator_next(ritr);
- !icaltime_is_null_time(next);
- next = icalrecur_iterator_next(ritr)){
-
- next.is_date = false;
- next = icaltime_normalize( next );
-
-// printf( "recur: %d-%d-%d %d:%d:%d\n" , next.year, next.month, next.day, next.hour, next.minute, next.second );
-
- //quick fix for the recurrence getting out of the end of the month into the next month
- //like 31st of each month but when you get February
- if( recur.freq == ICAL_MONTHLY_RECURRENCE && !m_recurweeknumber && next.day != m_start->m_datetime.day) {
-//#ifdef ICAL_DEBUG
-// printf( "Wrong day in month\n" );
-//#endif
-// continue;
- next.day = 0;
- next = icaltime_normalize( next );
- }
- PRTime nextinms = ConvertToPrtime( next );
- if( LL_CMP(nextinms, < ,beforethis) && !IsExcepted( nextinms ) ) {
-// printf( "Result: %d-%d-%d %d:%d\n" , next.year, next.month, next.day, next.hour, next.minute );
- *retval = nextinms;
- *isvalid = true;
- }
- if( LL_CMP(nextinms, >= ,beforethis) ) {
- break;
- }
- }
- icalrecur_iterator_free(ritr);
- }
-
- icalcomponent_free( vcalendar );
- return NS_OK;
-}
-
-icaltimetype oeICalEventImpl::GetNextRecurrence( icaltimetype begin, bool *isbeginning ) {
- icaltimetype result = icaltime_null_time();
-
- if( isbeginning ) {
- *isbeginning = true;
- }
-
- if( icaltime_compare( m_start->m_datetime , begin ) > 0 ) {
- if( !m_recur )
- return m_start->m_datetime;
- PRTime nextinms = ConvertToPrtime( m_start->m_datetime );
- if( !IsExcepted( nextinms ) )
- return m_start->m_datetime;
- }
-
- //for non recurring events
- if( !m_recur ) {
-
- if( icaltime_compare( m_end->m_datetime , begin ) <= 0 )
- return result;
-
- struct icaltimetype nextday = begin;
- nextday.hour = 0; nextday.minute = 0; nextday.second = 0;
- icaltime_adjust( &nextday, 1, 0, 0, 0 );
- if( icaltime_compare( nextday, m_end->m_datetime ) < 0 ) {
- struct icaltimetype afternextday = nextday;
- icaltime_adjust( &afternextday, 1, 0, 0, 0 );
- if( icaltime_compare( afternextday, m_end->m_datetime ) < 0 ) {
- nextday.is_date = true;
- }
- if( isbeginning ) {
- *isbeginning = false;
- }
- return nextday;
- }
- return result;
- }
-
- //for recurring events
- icalcomponent *vcalendar = AsIcalComponent();
- if ( !vcalendar ) {
- #ifdef ICAL_DEBUG
- printf( "oeICalEventImpl::GetNextRecurrence() failed!\n" );
- #endif
- return result;
- }
-
- icalcomponent *vevent = icalcomponent_get_first_component( vcalendar, ICAL_VEVENT_COMPONENT );
-
- icalproperty *prop = icalcomponent_get_first_property( vevent, ICAL_RRULE_PROPERTY );
- if ( prop != 0) {
- struct icaltimetype next,nextpropagation=icaltime_null_time();
- struct icalrecurrencetype recur = icalproperty_get_rrule(prop);
- //printf("#### %s\n",icalrecurrencetype_as_string(&recur));
- icalrecur_iterator* ritr = icalrecur_iterator_new(recur,m_start->m_datetime);
- bool nextpropagationisdate = false;
- for(next = icalrecur_iterator_next(ritr);
- !icaltime_is_null_time(next);
- next = icalrecur_iterator_next(ritr)){
-
- next.is_date = false;
- next = icaltime_normalize( next );
-
- //printf( "recur: %d-%d-%d %d:%d:%d\n" , next.year, next.month, next.day, next.hour, next.minute, next.second );
-
- //quick fix for the recurrence getting out of the end of the month into the next month
- //like 31st of each month but when you get February
- if( recur.freq == ICAL_MONTHLY_RECURRENCE && !m_recurweeknumber && next.day != m_start->m_datetime.day) {
- //#ifdef ICAL_DEBUG
- //printf( "Wrong day in month\n" );
- //#endif
- //continue;
- next.day = 0;
- next = icaltime_normalize( next );
- }
-
- if( icaltime_compare( next, begin ) > 0 ) {
- PRTime nextinms = ConvertToPrtime( next );
- if( !IsExcepted( nextinms ) ) {
- //printf( "Result: %d-%d-%d %d:%d\n" , next.year, next.month, next.day, next.hour, next.minute );
- result = next;
- break;
- }
- }
-
- if( icaltime_is_null_time( nextpropagation ) ) {
- struct icaldurationtype eventlength = GetLength();
- struct icaltimetype end = icaltime_add( next, eventlength );
-
- if( icaltime_compare( end , begin ) <= 0 )
- continue;
-
- struct icaltimetype nextday = next;
- nextday.hour = 0; nextday.minute = 0; nextday.second = 0;
- icaltime_adjust( &nextday, 1, 0, 0, 0 );
- if( icaltime_compare( nextday , begin ) > 0 && icaltime_compare( nextday, end ) < 0 ) {
- PRTime nextdayinms = ConvertToPrtime( nextday );
- if( !IsExcepted( nextdayinms ) ) {
- nextpropagation = nextday;
- struct icaltimetype afternextday = nextday;
- icaltime_adjust( &afternextday, 1, 0, 0, 0 );
- if( icaltime_compare( afternextday, end ) < 0 ) {
- nextpropagationisdate = true;
- }
- }
- }
- }
- }
- icalrecur_iterator_free(ritr);
- if( !icaltime_is_null_time( result ) ) {
- if( !icaltime_is_null_time( nextpropagation ) ) {
- if( icaltime_compare( nextpropagation , result ) < 0 ) {
- result = nextpropagation;
- result.is_date = nextpropagationisdate;
- if( isbeginning ) {
- *isbeginning = false;
- }
- }
- }
- } else if( !icaltime_is_null_time( nextpropagation ) ) {
- result = nextpropagation;
- result.is_date = nextpropagationisdate;
- if( isbeginning ) {
- *isbeginning = false;
- }
- }
- }
-
- icalcomponent_free( vcalendar );
-
- return result;
-}
-
-icaltimetype oeICalEventImpl::GetPreviousOccurrence( icaltimetype beforethis ) {
- icaltimetype result = icaltime_null_time();
- PRTime beforethisinms = ConvertToPrtime( beforethis );
- PRTime resultinms;
- PRBool isvalid;
- GetPreviousOccurrence( beforethisinms ,&resultinms, &isvalid );
- if( !isvalid )
- return result;
-
- result = ConvertFromPrtime( resultinms );
- return result;
-}
-
-icaltimetype oeICalEventImpl::GetNextAlarmTime( icaltimetype begin ) {
-#ifdef ICAL_DEBUG_ALL
- printf( "oeICalEventImpl::GetNextAlarmTime()\n" );
-#endif
- icaltimetype result = icaltime_null_time();
-
- if( !m_hasalarm )
- return result;
-
- // Check for related to the start, and no start set
- // or a start year set to -1, which might occur for invalid start times
- // due to timezone weirdness
- PRBool isSet = PR_FALSE;
- m_start->GetIsSet(&isSet);
- PRInt16 year;
- m_start->GetYear(&year);
- if( m_alarmtriggerrelation == ICAL_RELATED_START && (!isSet || year == -1) )
- return result;
-
- icaltimetype starting = begin;
-
- if( !icaltime_is_null_time( m_lastalarmack ) && icaltime_compare( begin, m_lastalarmack ) < 0 )
- starting = m_lastalarmack;
-
- icaltimetype checkloop = starting;
- do {
- checkloop = GetNextRecurrence( checkloop, nsnull );
- checkloop.is_date = false;
- result = checkloop;
- if( icaltime_is_null_time( checkloop ) ) {
- break;
- }
- result = CalculateAlarmTime( result );
- } while ( icaltime_compare( starting, result ) >= 0 );
-
- for( int i=0; i 0 ) {
- result = snoozetime;
- }
- }
- }
- return result;
-}
-
-icaltimetype oeICalEventImpl::CalculateAlarmTime( icaltimetype date ) {
- icaltimetype result = date;
- if( strcasecmp( m_alarmunits, "days" ) == 0 )
- icaltime_adjust( &result, -(signed long)m_alarmlength, 0, 0, 0 );
- else if( strcasecmp( m_alarmunits, "hours" ) == 0 )
- icaltime_adjust( &result, 0, -(signed long)m_alarmlength, 0, 0 );
- else
- icaltime_adjust( &result, 0, 0, -(signed long)m_alarmlength, 0 );
-
- //Add the length to the final result if alarm trigger is relative to end of event
- if( m_alarmtriggerrelation == ICAL_RELATED_END )
- result = icaltime_add( result, GetLength() );
-
- return result;
-}
-
-icaltimetype oeICalEventImpl::CalculateEventTime( icaltimetype alarmtime ) {
- icaltimetype result = alarmtime;
- if( strcasecmp( m_alarmunits, "days" ) == 0 )
- icaltime_adjust( &result, (signed long)m_alarmlength, 0, 0, 0 );
- else if( strcasecmp( m_alarmunits, "hours" ) == 0 )
- icaltime_adjust( &result, 0, (signed long)m_alarmlength, 0, 0 );
- else
- icaltime_adjust( &result, 0, 0, (signed long)m_alarmlength, 0 );
-
- return result;
-}
-
-icaldurationtype oeICalEventImpl::GetLength() {
-
- if( !icaldurationtype_is_null_duration( m_duration ) )
- return m_duration;
-
- return icaltime_subtract( m_end->m_datetime, m_start->m_datetime );;
-}
-
-NS_IMETHODIMP oeICalEventImpl::GetStart(oeIDateTime * *start)
-{
- *start = m_start;
- NS_ADDREF(*start);
- return NS_OK;
-}
-
-NS_IMETHODIMP oeICalEventImpl::GetEnd(oeIDateTime * *end)
-{
- *end = m_end;
- NS_ADDREF(*end);
- return NS_OK;
-}
-
-NS_IMETHODIMP oeICalEventImpl::GetStamp(oeIDateTime * *stamp)
-{
- *stamp = m_stamp;
- NS_ADDREF(*stamp);
- return NS_OK;
-}
-
-NS_IMETHODIMP oeICalEventImpl::GetRecurEnd(oeIDateTime * *recurend)
-{
- *recurend = m_recurend;
- NS_ADDREF(*recurend);
- return NS_OK;
-}
-
-NS_IMETHODIMP oeICalEventImpl::GetRecurWeekdays(PRInt16 *aRetVal)
-{
-#ifdef ICAL_DEBUG_ALL
- printf( "GetRecurWeekdays()\n" );
-#endif
- *aRetVal = m_recurweekdays;
- return NS_OK;
-}
-NS_IMETHODIMP oeICalEventImpl::SetRecurWeekdays(PRInt16 aNewVal)
-{
-#ifdef ICAL_DEBUG_ALL
- printf( "SetRecurWeekdays()\n" );
-#endif
- m_recurweekdays = aNewVal;
- return NS_OK;
-}
-
-NS_IMETHODIMP oeICalEventImpl::GetRecurWeekNumber(PRInt16 *aRetVal)
-{
-#ifdef ICAL_DEBUG_ALL
- printf( "GetRecurWeekNumber()\n" );
-#endif
- *aRetVal = m_recurweeknumber;
- return NS_OK;
-}
-NS_IMETHODIMP oeICalEventImpl::SetRecurWeekNumber(PRInt16 aNewVal)
-{
-#ifdef ICAL_DEBUG_ALL
- printf( "SetRecurWeekNumber()\n" );
-#endif
- m_recurweeknumber = aNewVal;
- return NS_OK;
-}
-
-NS_IMETHODIMP oeICalEventImpl::GetIcalString(nsACString& aRetVal)
-{
-#ifdef ICAL_DEBUG_ALL
- printf( "GetIcalString() = " );
-#endif
-
- icalcomponent *vcalendar = AsIcalComponent();
- if ( !vcalendar ) {
- #ifdef ICAL_DEBUG
- printf( "oeICalEventImpl::GetIcalString() failed!\n" );
- #endif
- return NS_OK;
- }
-
- char *str = icalcomponent_as_ical_string( vcalendar );
- if( str ) {
- aRetVal = str;
-// *aRetVal= (char*) nsMemory::Clone( str, strlen(str)+1);
- } else
- aRetVal.Truncate();
- icalcomponent_free( vcalendar );
-
-#ifdef ICAL_DEBUG_ALL
- printf( "\"%s\"\n", PromiseFlatCString( aRetVal ).get() );
-#endif
- return NS_OK;
-}
-
-NS_IMETHODIMP oeICalEventImpl::ParseIcalString(const nsACString& aNewVal, PRBool *aRetVal)
-{
-#ifdef ICAL_DEBUG_ALL
- printf( "ParseIcalString( %s )\n", PromiseFlatCString( aNewVal ).get() );
-#endif
-
- *aRetVal = false;
- icalcomponent *comp = icalparser_parse_string( PromiseFlatCString( aNewVal ).get() );
- if( comp ) {
- if( ParseIcalComponent( comp ) )
- *aRetVal = true;
- icalcomponent_free( comp );
- }
- return NS_OK;
-}
-
-NS_IMETHODIMP oeICalEventImpl::AddException( PRTime exdate )
-{
-#ifdef ICAL_DEBUG_ALL
- printf( "oeICalEventImpl::AddException()\n" );
-#endif
- icaltimetype tmpexdate = ConvertFromPrtime( exdate );
- tmpexdate.hour = 0;
- tmpexdate.minute = 0;
- tmpexdate.second = 0;
- exdate = ConvertToPrtime( tmpexdate );
- PRTime *newexdate = new PRTime;
- if (!newexdate)
- return NS_ERROR_OUT_OF_MEMORY;
- *newexdate = exdate;
- m_exceptiondates.AppendElement( newexdate );
- return NS_OK;
-}
-
-NS_IMETHODIMP oeICalEventImpl::RemoveAllExceptions()
-{
-#ifdef ICAL_DEBUG_ALL
- printf( "oeICalEventImpl::RemoveAllExceptions()\n" );
-#endif
- for( int i=0; i dateEnum = new oeDateEnumerator();
-
- if (!dateEnum)
- return NS_ERROR_OUT_OF_MEMORY;
-
- int count=0;
- bool found;
- PRTime current,lastadded,minimum;
-
- do {
- found = false;
- for( int i=0; i, lastadded ) ) {
- if( LL_CMP( minimum, ==, lastadded ) ) {
- minimum = current;
- found = true;
- }
- else if( LL_CMP( current, <, minimum ) ) {
- minimum = current;
- found = true;
- }
- }
- }
-
- if( found ) {
- dateEnum->AddDate( minimum );
- count++;
- lastadded = minimum;
- }
- } while ( found );
-
- // bump ref count
- return dateEnum->QueryInterface(NS_GET_IID(nsISimpleEnumerator), (void **)datelist);
-}
-
-bool oeICalEventImpl::IsExcepted( PRTime date ) {
-#ifdef ICAL_DEBUG_ALL
- printf( "oeICalEventImpl::IsExcepted() = " );
-#endif
- icaltimetype tmpexdate = ConvertFromPrtime( date );
- tmpexdate.hour = 0;
- tmpexdate.minute = 0;
- tmpexdate.second = 0;
- date = ConvertToPrtime( tmpexdate );
-
- bool result = false;
- for( int i=0; iRelease();
- return NS_OK;
- }
- icalcomponent *vevent = icalcomponent_get_first_component( vcalendar, ICAL_VEVENT_COMPONENT );
- if( !(icalevent->ParseIcalComponent( vevent )) ) {
- #ifdef ICAL_DEBUG
- printf( "oeICalEventImpl::Clone() failed.\n" );
- #endif
- icalevent->Release();
- return NS_OK;
- }
- *ev = icalevent;
- return NS_OK;
-}
-
-NS_IMETHODIMP oeICalEventImpl::GetAttachmentsArray(nsISupportsArray * *aAttachmentsArray)
-{
- NS_ENSURE_ARG_POINTER(aAttachmentsArray);
- *aAttachmentsArray = m_attachments;
- NS_IF_ADDREF(*aAttachmentsArray);
- return NS_OK;
-}
-
-NS_IMETHODIMP oeICalEventImpl::AddAttachment(nsIMsgAttachment *attachment)
-{
-#ifdef ICAL_DEBUG
- printf( "oeICalEventImpl::AddAttachment()\n" );
-#endif
-#ifdef MOZ_MAIL_NEWS
- PRUint32 i;
- PRUint32 attachmentCount = 0;
- m_attachments->Count(&attachmentCount);
-
- //Don't add twice the same attachment.
- nsCOMPtr element;
- PRBool sameUrl;
- for (i = 0; i < attachmentCount; i ++)
- {
- m_attachments->QueryElementAt(i, NS_GET_IID(nsIMsgAttachment), getter_AddRefs(element));
- if (element)
- {
- element->EqualsUrl(attachment, &sameUrl);
- if (sameUrl)
- return NS_OK;
- }
- }
-
- return m_attachments->InsertElementAt(attachment, attachmentCount);
-#else
- return NS_ERROR_NOT_IMPLEMENTED;
-#endif
-}
-
-NS_IMETHODIMP oeICalEventImpl::RemoveAttachment(nsIMsgAttachment *attachment)
-{
-#ifdef ICAL_DEBUG
- printf( "oeICalEventImpl::RemoveAttachment()\n" );
-#endif
-#ifdef MOZ_MAIL_NEWS
- PRUint32 i;
- PRUint32 attachmentCount = 0;
- m_attachments->Count(&attachmentCount);
-
- nsCOMPtr element;
- PRBool sameUrl;
- for (i = 0; i < attachmentCount; i ++)
- {
- m_attachments->QueryElementAt(i, NS_GET_IID(nsIMsgAttachment), getter_AddRefs(element));
- if (element)
- {
- element->EqualsUrl(attachment, &sameUrl);
- if (sameUrl)
- {
- m_attachments->DeleteElementAt(i);
- break;
- }
- }
- }
-
- return NS_OK;
-#else
- return NS_ERROR_NOT_IMPLEMENTED;
-#endif
-}
-
-NS_IMETHODIMP oeICalEventImpl::RemoveAttachments()
-{
-#ifdef ICAL_DEBUG
- printf( "oeICalEventImpl::RemoveAttachments()\n" );
-#endif
- PRUint32 i;
- PRUint32 attachmentCount = 0;
- m_attachments->Count(&attachmentCount);
-
- for (i = 0; i < attachmentCount; i ++)
- m_attachments->DeleteElementAt(0);
-
- return NS_OK;
-}
-
-NS_IMETHODIMP oeICalEventImpl::GetContactsArray(nsISupportsArray * *aContactsArray)
-{
- NS_ENSURE_ARG_POINTER(aContactsArray);
- *aContactsArray = m_contacts;
- NS_IF_ADDREF(*aContactsArray);
- return NS_OK;
-}
-
-NS_IMETHODIMP oeICalEventImpl::AddContact(nsIAbCard *contact)
-{
-#ifdef ICAL_DEBUG
- printf( "oeICalEventImpl::AddContact()\n" );
-#endif
-#ifdef MOZ_MAIL_NEWS
- PRUint32 i;
- PRUint32 contactCount = 0;
- m_contacts->Count(&contactCount);
-
- //Don't add twice the same contact.
- nsCOMPtr element;
- PRBool samecontact;
- for (i = 0; i < contactCount; i ++)
- {
- m_contacts->QueryElementAt(i, NS_GET_IID(nsIAbCard), getter_AddRefs(element));
- if (element)
- {
- element->Equals(contact, &samecontact);
- if (samecontact)
- return NS_OK;
- }
- }
-
- return m_contacts->InsertElementAt(contact, contactCount);
-#else
- return NS_ERROR_NOT_IMPLEMENTED;
-#endif
-}
-
-NS_IMETHODIMP oeICalEventImpl::RemoveContact(nsIAbCard *contact)
-{
-#ifdef ICAL_DEBUG
- printf( "oeICalEventImpl::RemoveContact()\n" );
-#endif
-#ifdef MOZ_MAIL_NEWS
- PRUint32 i;
- PRUint32 contactCount = 0;
- m_contacts->Count(&contactCount);
-
- nsCOMPtr element;
- PRBool samecontact;
- for (i = 0; i < contactCount; i ++)
- {
- m_contacts->QueryElementAt(i, NS_GET_IID(nsIAbCard), getter_AddRefs(element));
- if (element)
- {
- element->Equals(contact, &samecontact);
- if (samecontact)
- {
- m_contacts->DeleteElementAt(i);
- break;
- }
- }
- }
-
- return NS_OK;
-#else
- return NS_ERROR_NOT_IMPLEMENTED;
-#endif
-}
-
-NS_IMETHODIMP oeICalEventImpl::RemoveContacts()
-{
-#ifdef ICAL_DEBUG
- printf( "oeICalEventImpl::RemoveContacts()\n" );
-#endif
-#ifdef MOZ_MAIL_NEWS
- PRUint32 i;
- PRUint32 contactCount = 0;
- m_contacts->Count(&contactCount);
-
- for (i = 0; i < contactCount; i ++)
- m_contacts->DeleteElementAt(0);
-
- return NS_OK;
-#else
- return NS_ERROR_NOT_IMPLEMENTED;
-#endif
-}
-
-NS_IMETHODIMP oeICalEventImpl::SetDuration(PRBool is_negative, PRUint16 weeks, PRUint16 days, PRUint16 hours, PRUint16 minutes, PRUint16 seconds)
-{
-#ifdef ICAL_DEBUG_ALL
- printf( "oeICalEventImpl::SetDuration()\n" );
-#endif
- return NS_ERROR_NOT_IMPLEMENTED;
-}
-
-NS_IMETHODIMP oeICalEventImpl::GetDuration(PRBool *is_negative, PRUint16 *weeks, PRUint16 *days, PRUint16 *hours, PRUint16 *minutes, PRUint16 *seconds)
-{
-#ifdef ICAL_DEBUG_ALL
- printf( "oeICalEventImpl::GetDuration()\n" );
-#endif
- return NS_ERROR_NOT_IMPLEMENTED;
-}
-
-void oeICalEventImpl::ChopAndAddEventToEnum( struct icaltimetype startdate, nsISimpleEnumerator **eventlist,
- bool isallday, bool isbeginning ) {
-
- nsCOMPtr eventEnum;
- eventEnum = (oeEventEnumerator *)*eventlist;
-
- oeIICalEventDisplay* eventDisplay;
- nsresult rv = NS_NewICalEventDisplay( this, &eventDisplay );
- if( NS_FAILED( rv ) ) {
- #ifdef ICAL_DEBUG
- printf( "oeICalEventImpl::ChopAndAddEventToEnum() : WARNING Cannot create oeIICalEventDisplay instance: %x\n", rv );
- #endif
- return;
- }
- eventEnum->AddEvent( eventDisplay );
-
- PRTime startdateinms = ConvertToPrtime( startdate );
- eventDisplay->SetDisplayDate( startdateinms );
-
- struct icaltimetype endofday = startdate;
- endofday.hour = 23; endofday.minute = 59; endofday.second = 59;
-
- PRTime enddateinms;
- if( isallday ) {
- enddateinms = ConvertToPrtime( endofday );
- eventDisplay->SetDisplayEndDate( enddateinms );
- } else {
- if( isbeginning ) {
- struct icaldurationtype eventlength = GetLength();
- struct icaltimetype eventenddate = icaltime_add( startdate, eventlength );
-
- if( icaltime_compare( endofday, eventenddate ) < 0 ) {
- enddateinms = ConvertToPrtime( endofday );
- } else {
- enddateinms = ConvertToPrtime( eventenddate );
- }
- } else {
- struct icaltimetype eventenddate = endofday;
- eventenddate.hour = m_end->m_datetime.hour;
- eventenddate.minute = m_end->m_datetime.minute;
- eventenddate.second = m_end->m_datetime.second;
- enddateinms = ConvertToPrtime( eventenddate );
- }
- eventDisplay->SetDisplayEndDate( enddateinms );
- }
- NS_RELEASE( eventDisplay );
-}
-
-bool oeICalEventImpl::ParseIcalComponent( icalcomponent *comp )
-{
-#ifdef ICAL_DEBUG_ALL
- printf( "ParseIcalComponent()\n" );
-#endif
-
- icalcomponent *vevent=nsnull;
- icalcomponent_kind kind = icalcomponent_isa( comp );
-
- if( kind == ICAL_VCALENDAR_COMPONENT ) {
- vevent = icalcomponent_get_first_component( comp , ICAL_VEVENT_COMPONENT );
- if ( !vevent ) {
- icalcomponent_get_first_component( comp , ICAL_VTODO_COMPONENT );
- }
- }
- else if( kind == ICAL_VEVENT_COMPONENT )
- vevent = comp;
- else if( kind == ICAL_VTODO_COMPONENT )
- vevent = comp;
-
- if ( !vevent ) {
- #ifdef ICAL_DEBUG
- printf( "oeICalEventImpl::ParseIcalComponent() failed: vevent is NULL!\n" );
- #endif
- return false;
- }
-
- m_type = icalcomponent_isa( vevent );
-
- const char *tmpstr;
- //id
- icalproperty *prop = icalcomponent_get_first_property( vevent, ICAL_UID_PROPERTY );
- if ( prop ) {
- tmpstr = icalproperty_get_uid( prop );
- SetId( tmpstr );
- } else {
- ReportError( oeIICalError::CAL_WARN, oeIICalError::UID_NOT_FOUND, "oeICalEventImpl::ParseIcalComponent() : Warning UID not found! Assigning new one." );
- char uidstr[40];
- GenerateUUID( uidstr );
- SetId( uidstr );
- prop = icalproperty_new_uid( uidstr );
- icalcomponent_add_property( vevent, prop );
- }
-
- //method
- if( kind == ICAL_VCALENDAR_COMPONENT ) {
- prop = icalcomponent_get_first_property( comp, ICAL_METHOD_PROPERTY );
- if ( prop != 0) {
- eventMethodProperty tmpMethodProp;
- tmpMethodProp = icalproperty_get_method( prop );
- SetMethod( tmpMethodProp );
- } else if ( m_method ) {
- m_method = 0;
- }
- }
-
- //status
- prop = icalcomponent_get_first_property( vevent, ICAL_STATUS_PROPERTY );
- if ( prop != 0) {
- eventStatusProperty tmpStatusProp;
- tmpStatusProp = icalproperty_get_status( prop );
- SetStatus( tmpStatusProp );
- } else if ( m_status ) {
- m_status = 0;
- }
-
- //title
- prop = icalcomponent_get_first_property( vevent, ICAL_SUMMARY_PROPERTY );
- if ( prop != 0 && (tmpstr = icalproperty_get_summary( prop ) ) ) {
- SetTitle( nsDependentCString( strForceUTF8( tmpstr ) ) );
- } else if( !m_title.IsEmpty() ) {
- m_title.Truncate();
- }
-
- //description
- prop = icalcomponent_get_first_property( vevent, ICAL_DESCRIPTION_PROPERTY );
- if ( prop != 0 && (tmpstr = icalproperty_get_description( prop ) ) ) {
- SetDescription( nsDependentCString( strForceUTF8( tmpstr ) ) );
- } else if( !m_description.IsEmpty() ) {
- m_description.Truncate();
- }
-
- //location
- prop = icalcomponent_get_first_property( vevent, ICAL_LOCATION_PROPERTY );
- if ( prop != 0) {
- tmpstr = icalproperty_get_location( prop );
- SetLocation( nsDependentCString( strForceUTF8( tmpstr ) ) );
- } else if( !m_location.IsEmpty() ) {
- m_location.Truncate();
- }
-
- //category
- prop = icalcomponent_get_first_property( vevent, ICAL_CATEGORIES_PROPERTY );
- if ( prop != 0) {
- tmpstr = (char *)icalproperty_get_categories( prop );
- SetCategories( nsDependentCString( strForceUTF8( tmpstr ) ) );
- } else if( !m_category.IsEmpty() ) {
- m_category.Truncate();
- }
-
- //url
- prop = icalcomponent_get_first_property( vevent, ICAL_URL_PROPERTY );
- if ( prop != 0) {
- tmpstr = (char *)icalproperty_get_url( prop );
- SetUrl( nsDependentCString( strForceUTF8( tmpstr ) ) );
- } else if( !m_url.IsEmpty() ) {
- m_url.Truncate();
- }
-
- //priority
- prop = icalcomponent_get_first_property( vevent, ICAL_PRIORITY_PROPERTY );
- if ( prop != 0) {
- m_priority = icalproperty_get_priority( prop );
- } else {
- m_priority = 0;
- }
-
- //isprivate
- prop = icalcomponent_get_first_property( vevent, ICAL_CLASS_PROPERTY );
- if ( prop != 0) {
- icalproperty_class tmpcls = icalproperty_get_class( prop );
- if( tmpcls == ICAL_CLASS_PUBLIC )
- m_isprivate= false;
- else
- m_isprivate= true;
- } else
- m_isprivate= false;
-
- //syncid
- for( prop = icalcomponent_get_first_property( vevent, ICAL_X_PROPERTY );
- prop != 0 ;
- prop = icalcomponent_get_next_property( vevent, ICAL_X_PROPERTY ) ) {
- icalparameter *tmppar = icalproperty_get_first_parameter( prop, ICAL_MEMBER_PARAMETER );
- if ( tmppar != 0 ) {
- tmpstr = icalparameter_get_member( tmppar );
- if( strcmp( tmpstr, "SyncId" ) == 0 )
- break;
- }
- }
-
- if ( prop != 0) {
- tmpstr = icalproperty_get_value_as_string( prop );
- SetSyncId( tmpstr );
- } else
- SetSyncId( "" );
-
- //allday
- for( prop = icalcomponent_get_first_property( vevent, ICAL_X_PROPERTY );
- prop != 0 ;
- prop = icalcomponent_get_next_property( vevent, ICAL_X_PROPERTY ) ) {
- icalparameter *tmppar = icalproperty_get_first_parameter( prop, ICAL_MEMBER_PARAMETER );
- if ( tmppar != 0 ) {
- tmpstr = icalparameter_get_member( tmppar );
- if( strcmp( tmpstr, "AllDay" ) == 0 )
- break;
- }
- }
-
- if ( prop != 0) {
- tmpstr = (char *)icalproperty_get_value_as_string( prop );
- if( strcmp( tmpstr, "TRUE" ) == 0 )
- m_allday= true;
- else
- m_allday= false;
- } else
- m_allday= false;
-
- //alarm
- icalcomponent *valarm = icalcomponent_get_first_component( vevent, ICAL_VALARM_COMPONENT );
-
- if ( valarm != 0) {
- m_hasalarm= true;
- prop = icalcomponent_get_first_property( valarm, ICAL_TRIGGER_PROPERTY );
- if( prop ) {
- icalparameter *tmppar = icalproperty_get_first_parameter( prop, ICAL_RELATED_PARAMETER );
- if( tmppar ) {
- m_alarmtriggerrelation = icalparameter_get_related( tmppar );
- } else
- m_alarmtriggerrelation = ICAL_RELATED_START;
- }
- }
- else
- m_hasalarm= false;
-
- //alarmunits
- for( prop = icalcomponent_get_first_property( vevent, ICAL_X_PROPERTY );
- prop != 0 ;
- prop = icalcomponent_get_next_property( vevent, ICAL_X_PROPERTY ) ) {
- icalparameter *tmppar = icalproperty_get_first_parameter( prop, ICAL_MEMBER_PARAMETER );
- if ( tmppar != 0 ) {
- tmpstr = icalparameter_get_member( tmppar );
- if( strcmp( tmpstr, "AlarmUnits" ) == 0 )
- break;
- }
- }
-
- if ( prop != 0) {
- tmpstr = icalproperty_get_value_as_string( prop );
- SetAlarmUnits( tmpstr );
- } else
- SetAlarmUnits( DEFAULT_ALARM_UNITS );
- //alarmlength
- for( prop = icalcomponent_get_first_property( vevent, ICAL_X_PROPERTY );
- prop != 0 ;
- prop = icalcomponent_get_next_property( vevent, ICAL_X_PROPERTY ) ) {
- icalparameter *tmppar = icalproperty_get_first_parameter( prop, ICAL_MEMBER_PARAMETER );
- if ( tmppar != 0 ) {
- tmpstr = (char *)icalparameter_get_member( tmppar );
- if( strcmp( tmpstr, "AlarmLength" ) == 0 )
- break;
- }
- }
-
- if ( prop != 0) {
- tmpstr = (char *)icalproperty_get_value_as_string( prop );
- m_alarmlength= atol( tmpstr );
- } else
- m_alarmlength = DEFAULT_ALARM_LENGTH;
-
- //alarmemail
- for( prop = icalcomponent_get_first_property( vevent, ICAL_X_PROPERTY );
- prop != 0 ;
- prop = icalcomponent_get_next_property( vevent, ICAL_X_PROPERTY ) ) {
- icalparameter *tmppar = icalproperty_get_first_parameter( prop, ICAL_MEMBER_PARAMETER );
- if ( tmppar != 0 ) {
- tmpstr = (char *)icalparameter_get_member( tmppar );
- if( strcmp( tmpstr, "AlarmEmailAddress" ) == 0 )
- break;
- }
- }
-
- if ( prop != 0) {
- tmpstr = icalproperty_get_value_as_string( prop );
- SetAlarmEmailAddress( tmpstr );
- } else if( m_alarmemail ) {
- nsMemory::Free( m_alarmemail );
- m_alarmemail= nsnull;
- }
-
- //inviteemail
- for( prop = icalcomponent_get_first_property( vevent, ICAL_X_PROPERTY );
- prop != 0 ;
- prop = icalcomponent_get_next_property( vevent, ICAL_X_PROPERTY ) ) {
- icalparameter *tmppar = icalproperty_get_first_parameter( prop, ICAL_MEMBER_PARAMETER );
- if ( tmppar != 0 ) {
- tmpstr = icalparameter_get_member( tmppar );
- if( strcmp( tmpstr, "InviteEmailAddress" ) == 0 )
- break;
- }
- }
-
- if ( prop != 0) {
- tmpstr = (char *)icalproperty_get_value_as_string( prop );
- SetInviteEmailAddress( tmpstr );
- } else if( m_inviteemail ) {
- nsMemory::Free( m_inviteemail );
- m_inviteemail= nsnull;
- }
-
- //recurinterval
- for( prop = icalcomponent_get_first_property( vevent, ICAL_X_PROPERTY );
- prop != 0 ;
- prop = icalcomponent_get_next_property( vevent, ICAL_X_PROPERTY ) ) {
- icalparameter *tmppar = icalproperty_get_first_parameter( prop, ICAL_MEMBER_PARAMETER );
- if ( tmppar != 0 ) {
- tmpstr = icalparameter_get_member( tmppar );
- if( strcmp( tmpstr, "RecurInterval" ) == 0 )
- break;
- }
- }
-
- if ( prop != 0) {
- tmpstr = (char *)icalproperty_get_value_as_string( prop );
- m_recurinterval= atol( tmpstr );
- } else
- m_recurinterval= 0;
-
- //recurunits
- for( prop = icalcomponent_get_first_property( vevent, ICAL_X_PROPERTY );
- prop != 0 ;
- prop = icalcomponent_get_next_property( vevent, ICAL_X_PROPERTY ) ) {
- icalparameter *tmppar = icalproperty_get_first_parameter( prop, ICAL_MEMBER_PARAMETER );
- if ( tmppar != 0 ) {
- tmpstr = icalparameter_get_member( tmppar );
- if( strcmp( tmpstr, "RecurUnits" ) == 0 )
- break;
- }
- }
-
- if ( prop != 0) {
- tmpstr = (char *)icalproperty_get_value_as_string( prop );
- SetRecurUnits( tmpstr );
- } else
- SetRecurUnits( DEFAULT_RECUR_UNITS );
-
- //startdate
- prop = icalcomponent_get_first_property( vevent, ICAL_DTSTART_PROPERTY );
- if ( prop != 0) {
- m_start->m_datetime = icalproperty_get_dtstart( prop );
- bool datevalue=m_start->m_datetime.is_date;
- m_start->m_datetime.is_date = false; //Because currently we depend on m_datetime being a complete datetime value.
- const char *tzid=nsnull;
- if( m_start->m_datetime.is_utc && !datevalue )
- tzid="/Mozilla.org/BasicTimezones/GMT";
- m_start->m_datetime.is_utc = false;
- if( datevalue ) {
- m_allday = true;
- m_start->SetHour( 0 );
- m_start->SetMinute( 0 );
- m_start->m_datetime.is_date = false; //Because currently we depend on m_datetime being a complete datetime value.
- }
- icalparameter *tmppar = icalproperty_get_first_parameter( prop, ICAL_TZID_PARAMETER );
- if( tmppar )
- tzid = icalparameter_get_tzid( tmppar );
- if( tzid ) {
- if( !datevalue ) {
- PRTime timeinms;
- m_start->GetTime( &timeinms );
- m_start->SetTimeInTimezone( timeinms, tzid );
- } else {
- m_start->SetTzID( tzid );
- }
- }
- } else {
- m_start->m_datetime = icaltime_null_time();
- }
-
- //duration
- prop = icalcomponent_get_first_property( vevent, ICAL_DURATION_PROPERTY );
- if ( prop != 0) {
- m_duration = icalproperty_get_duration( prop );
- } else {
- m_duration = icaldurationtype_null_duration();
- }
-
- //enddate
- if( icaldurationtype_is_null_duration( m_duration ) ) {
- prop = icalcomponent_get_first_property( vevent, ICAL_DTEND_PROPERTY );
- if ( prop != 0) {
- m_end->m_datetime = icalproperty_get_dtend( prop );
- bool datevalue=m_end->m_datetime.is_date;
- m_end->m_datetime.is_date = false; //Because currently we depend on m_datetime being a complete datetime value.
- const char *tzid=nsnull;
- if( m_end->m_datetime.is_utc && !datevalue )
- tzid="/Mozilla.org/BasicTimezones/GMT";
- m_end->m_datetime.is_utc = false;
- if( datevalue ) {
- m_end->SetHour( 0 );
- m_end->SetMinute( 0 );
- }
- icalparameter *tmppar = icalproperty_get_first_parameter( prop, ICAL_TZID_PARAMETER );
- if( tmppar )
- tzid = icalparameter_get_tzid( tmppar );
- if( tzid ) {
- if( !datevalue ) {
- PRTime timeinms;
- m_end->GetTime( &timeinms );
- m_end->SetTimeInTimezone( timeinms, tzid );
- } else {
- m_end->SetTzID( tzid );
- }
- }
- } else {
- prop = icalcomponent_get_first_property( vevent, ICAL_DUE_PROPERTY );
- if ( prop != 0) {
- m_end->m_datetime = icalproperty_get_due( prop );
- bool datevalue=m_end->m_datetime.is_date;
- m_end->m_datetime.is_date = false; //Because currently we depend on m_datetime being a complete datetime value.
- const char *tzid=nsnull;
- if( m_end->m_datetime.is_utc && !datevalue )
- tzid="/Mozilla.org/BasicTimezones/GMT";
- m_end->m_datetime.is_utc = false;
- if( datevalue ) {
- m_end->SetHour( 0 );
- m_end->SetMinute( 0 );
- }
- icalparameter *tmppar = icalproperty_get_first_parameter( prop, ICAL_TZID_PARAMETER );
- if( tmppar )
- tzid = icalparameter_get_tzid( tmppar );
- if( tzid ) {
- if( !datevalue ) {
- PRTime timeinms;
- m_end->GetTime( &timeinms );
- m_end->SetTimeInTimezone( timeinms, tzid );
- } else {
- m_end->SetTzID( tzid );
- }
- }
- } else {
- if( m_type == ICAL_VEVENT_COMPONENT && !icaltime_is_null_time( m_start->m_datetime ) ) {
- m_end->m_datetime = m_start->m_datetime;
- } else {
- m_end->m_datetime = icaltime_null_time();
- }
- }
- }
- } else {
- if( !icaltime_is_null_time( m_start->m_datetime ) ) {
- m_end->m_datetime = icaltime_add( m_start->m_datetime, m_duration );
- } else {
- m_end->m_datetime = icaltime_null_time();
- }
- }
-
- //stampdate
- prop = icalcomponent_get_first_property( vevent, ICAL_DTSTAMP_PROPERTY );
- if ( prop != 0) {
- m_stamp->m_datetime = icalproperty_get_dtstamp( prop );
- }
-
- //lastmodifed
- prop = icalcomponent_get_first_property( vevent, ICAL_LASTMODIFIED_PROPERTY );
- if ( prop != 0) {
- m_lastmodified = icalproperty_get_dtstamp( prop );
- } else {
- m_lastmodified = icaltime_null_time();
- }
-
- // scan for X- properties
-
- // first set the defaults
- m_lastalarmack = icaltime_null_time();
-
- const char *propvalue;
- const char *x_name;
-
- for( prop = icalcomponent_get_first_property( vevent, ICAL_X_PROPERTY );
- prop != 0;
- prop = icalcomponent_get_next_property( vevent, ICAL_X_PROPERTY ) ) {
-
- x_name = icalproperty_get_x_name ( prop );
- if( !x_name )
- continue;
-
- propvalue = icalproperty_get_value_as_string( prop );
- //lastalarmack
- if ( strcmp( x_name, XPROP_LASTALARMACK ) == 0) {
- m_lastalarmack = icaltime_from_string( propvalue );
- }
- //syncid
- else if ( strcmp( x_name, XPROP_SYNCID ) == 0) {
- SetSyncId( propvalue );
- }
- //alarmunits
- else if ( strcmp( x_name, XPROP_ALARMUNITS ) == 0) {
- SetAlarmUnits( propvalue );
- }
- //alarmlength
- else if ( strcmp( x_name, XPROP_ALARMLENGTH ) == 0) {
- m_alarmlength= atol( propvalue );
- }
- //recurunits
- else if ( strcmp( x_name, XPROP_RECURUNITS ) == 0) {
- SetRecurUnits( propvalue );
- }
- //recurinterval
- else if ( strcmp( x_name, XPROP_RECURINTERVAL ) == 0) {
- m_recurinterval= atol( propvalue );
- }
- }
-
- //recurend & recurforever & recur & recurweekday & recurweeknumber
- m_recur = false;
- m_recurforever = true;
- m_recurweekdays = 0;
- m_recurweeknumber = 0;
- prop = icalcomponent_get_first_property( vevent, ICAL_RRULE_PROPERTY );
- if ( prop != 0) {
- m_recur = true;
- struct icalrecurrencetype recur;
- recur = icalproperty_get_rrule(prop);
- m_recurend->m_datetime = recur.until;
- m_recurend->m_datetime.is_date = false;
- m_recurend->m_datetime.is_utc = false;
- m_recurinterval = recur.interval;
- m_recurcount = recur.count;
- if( !icaltime_is_null_time( recur.until ) )
- m_recurforever = false;
- if( recur.freq == ICAL_DAILY_RECURRENCE ) {
- SetRecurUnits( "days" );
- } else if( recur.freq == ICAL_WEEKLY_RECURRENCE ) {
- int k=0;
- SetRecurUnits( "weeks" );
- while( recur.by_day[k] != ICAL_RECURRENCE_ARRAY_MAX ) {
- m_recurweekdays += 1 << (recur.by_day[k]-1);
- k++;
- }
- } else if( recur.freq == ICAL_MONTHLY_RECURRENCE ) {
- SetRecurUnits( "months" );
- if( recur.by_day[0] != ICAL_RECURRENCE_ARRAY_MAX )
- m_recurweeknumber = icalrecurrencetype_day_position(recur.by_day[0]);
- if( m_recurweeknumber < 0 )
- m_recurweeknumber = 5;
- }
- else if( recur.freq == ICAL_YEARLY_RECURRENCE ) {
- SetRecurUnits( "years" );
- }
- }
-
- //recur exceptions
- RemoveAllExceptions();
- for( prop = icalcomponent_get_first_property( vevent, ICAL_EXDATE_PROPERTY );
- prop != 0 ;
- prop = icalcomponent_get_next_property( vevent, ICAL_EXDATE_PROPERTY ) ) {
- icaltimetype exdate = icalproperty_get_exdate( prop );
- PRTime *exdateinms = new PRTime;
- if (!exdateinms)
- return NS_ERROR_OUT_OF_MEMORY;
- *exdateinms = ConvertToPrtime( exdate );
- m_exceptiondates.AppendElement( exdateinms );
- }
-
- for( int i=0; i= 0 )
- continue;
- PRTime *snoozetimeinms = new PRTime;
- if (!snoozetimeinms)
- return NS_ERROR_OUT_OF_MEMORY;
- *snoozetimeinms = icaltime_as_timet( snoozetime );
- *snoozetimeinms = *snoozetimeinms * 1000;
- m_snoozetimes.AppendElement( snoozetimeinms );
- }
- }
-
-#ifdef MOZ_MAIL_NEWS
- //attachments
- for( prop = icalcomponent_get_first_property( vevent, ICAL_X_PROPERTY );
- prop != 0 ;
- prop = icalcomponent_get_next_property( vevent, ICAL_X_PROPERTY ) ) {
- icalparameter *tmppar = icalproperty_get_first_parameter( prop, ICAL_MEMBER_PARAMETER );
- if ( tmppar != 0 ) {
- tmpstr = icalparameter_get_member( tmppar );
- if( strcmp( tmpstr, "Attachment" ) == 0 ) {
- nsresult rv;
- tmpstr = (char *)icalproperty_get_value_as_string( prop );
- nsCOMPtr attachment = do_CreateInstance( "@mozilla.org/messengercompose/attachment;1", &rv);
- if ( NS_SUCCEEDED(rv) && attachment ) {
- attachment->SetUrl( tmpstr );
- AddAttachment( attachment );
- }
- }
- }
- }
-#endif
-
-#ifdef MOZ_MAIL_NEWS
- //contacts
- for(prop = icalcomponent_get_first_property( vevent, ICAL_CONTACT_PROPERTY );
- prop != 0 ;
- prop = icalcomponent_get_next_property( vevent, ICAL_CONTACT_PROPERTY ) ) {
- tmpstr = icalproperty_get_contact( prop );
- nsresult rv;
- nsCOMPtr contact = do_CreateInstance( "@mozilla.org/addressbook/cardproperty;1", &rv);
- if ( NS_SUCCEEDED(rv) && contact ) {
- nsAutoString email;
- email.AssignWithConversion( tmpstr );
- contact->SetPrimaryEmail( email.get() );
- AddContact( contact );
- }
- }
-#endif
-
- return true;
-}
-
-icalcomponent* oeICalEventImpl::AsIcalComponent()
-{
-#ifdef ICAL_DEBUG_ALL
- printf( "AsIcalComponent()\n" );
-#endif
- icalcomponent *newcalendar;
-
- newcalendar = icalcomponent_new_vcalendar();
- if ( !newcalendar ) {
- #ifdef ICAL_DEBUG
- printf( "oeICalEventImpl::AsIcalComponent() failed: Cannot create VCALENDAR!\n" );
- #endif
- return nsnull;
- }
-
- //version
- icalproperty *prop = icalproperty_new_version( ICALEVENT_VERSION );
- icalcomponent_add_property( newcalendar, prop );
-
- //prodid
- prop = icalproperty_new_prodid( ICALEVENT_PRODID );
- icalcomponent_add_property( newcalendar, prop );
-
- //method
- if( m_method != 0 ){
- prop = icalproperty_new_method( (icalproperty_method) m_method );
- icalcomponent_add_property( newcalendar, prop );
- }
-
- icalcomponent *vevent = icalcomponent_new_vevent();
-
- //id
- prop = icalproperty_new_uid( m_id );
- icalcomponent_add_property( vevent, prop );
-
- //title
- if( !m_title.IsEmpty() ) {
- prop = icalproperty_new_summary( PromiseFlatCString( m_title ).get() );
- icalcomponent_add_property( vevent, prop );
- }
- //description
- if( !m_description.IsEmpty() ) {
- prop = icalproperty_new_description( PromiseFlatCString( m_description ).get() );
- icalcomponent_add_property( vevent, prop );
- }
-
- //location
- if( !m_location.IsEmpty() ) {
- prop = icalproperty_new_location( PromiseFlatCString( m_location ).get() );
- icalcomponent_add_property( vevent, prop );
- }
-
- //category
- if( !m_category.IsEmpty() ) {
- prop = icalproperty_new_categories( PromiseFlatCString( m_category ).get() );
- icalcomponent_add_property( vevent, prop );
- }
-
- //url
- if( !m_url.IsEmpty() ) {
- prop = icalproperty_new_url( PromiseFlatCString( m_url ).get() );
- icalcomponent_add_property( vevent, prop );
- }
-
- //priority
- if( m_priority != 0) {
- prop = icalproperty_new_priority( m_priority );
- icalcomponent_add_property( vevent, prop );
- }
-
- //status
- if( m_status != 0 ){
- prop = icalproperty_new_status( (icalproperty_status) m_status );
- icalcomponent_add_property( vevent, prop );
- }
-
- //isprivate
- if( m_isprivate )
- prop = icalproperty_new_class( ICAL_CLASS_PRIVATE );
- else
- prop = icalproperty_new_class( ICAL_CLASS_PUBLIC );
- icalcomponent_add_property( vevent, prop );
-
- //syncId
- if( m_syncid && strlen( m_syncid ) != 0 ){
- prop = icalproperty_new_x( m_syncid );
- icalproperty_set_x_name( prop, XPROP_SYNCID);
- icalcomponent_add_property( vevent, prop );
- }
-
- //alarm
- if( m_hasalarm ) {
- struct icaltriggertype trig;
- icalcomponent *valarm = icalcomponent_new_valarm();
- trig.time.year = trig.time.month = trig.time.day = trig.time.hour = trig.time.minute = trig.time.second = 0;
- trig.duration.is_neg = true;
- trig.duration.days = trig.duration.weeks = trig.duration.hours = trig.duration.minutes = trig.duration.seconds = 0;
- if( m_alarmunits ) {
- if( strcasecmp( m_alarmunits, "days" ) == 0 )
- trig.duration.days = m_alarmlength;
- else if( strcasecmp( m_alarmunits, "hours" ) == 0 )
- trig.duration.hours = m_alarmlength;
- else
- trig.duration.minutes = m_alarmlength;
- } else
- trig.duration.minutes = m_alarmlength;
-
- if( m_alarmlength == 0 )
- trig.duration.seconds = 1;
-
- prop = icalproperty_new_trigger( trig );
-
- if( m_alarmtriggerrelation != DEFAULT_ALARMTRIGGER_RELATION ) {
- icalparameter *tmppar = icalparameter_new_related( m_alarmtriggerrelation );
- icalproperty_add_parameter( prop, tmppar );
- }
-
- icalcomponent_add_property( valarm, prop );
- icalcomponent_add_component( vevent, valarm );
- }
-
- //alarmunits
- if( m_alarmunits && strlen( m_alarmunits ) != 0 && strcasecmp( m_alarmunits, DEFAULT_ALARM_UNITS ) != 0 ){
- prop = icalproperty_new_x( m_alarmunits );
- icalproperty_set_x_name( prop, XPROP_ALARMUNITS);
- icalcomponent_add_property( vevent, prop );
- }
-
- char tmpstr[20];
- //alarmlength
- if( m_alarmlength != DEFAULT_ALARM_LENGTH ) {
- sprintf( tmpstr, "%lu", m_alarmlength );
- prop = icalproperty_new_x( tmpstr );
- icalproperty_set_x_name( prop, XPROP_ALARMLENGTH);
- icalcomponent_add_property( vevent, prop );
- }
-
- //alarmemail
- if( m_alarmemail && strlen( m_alarmemail ) != 0 ){
- icalparameter *tmppar = icalparameter_new_member( "AlarmEmailAddress" );
- prop = icalproperty_new_x( m_alarmemail );
- icalproperty_add_parameter( prop, tmppar );
- icalcomponent_add_property( vevent, prop );
- }
- //lastalarmack
- if( !icaltime_is_null_time( m_lastalarmack ) ) {
- prop = icalproperty_new_x( icaltime_as_ical_string(m_lastalarmack ));
- icalproperty_set_x_name( prop, XPROP_LASTALARMACK);
- icalcomponent_add_property( vevent, prop );
- }
-
- //inviteemail
- if( m_inviteemail && strlen( m_inviteemail ) != 0 ){
- icalparameter *tmppar = icalparameter_new_member( "InviteEmailAddress" );
- prop = icalproperty_new_x( m_inviteemail );
- icalproperty_add_parameter( prop, tmppar );
- icalcomponent_add_property( vevent, prop );
- }
-
- //Create enddate if does not exist
- if( icaltime_is_null_time( m_end->m_datetime ) && !icaltime_is_null_time( m_start->m_datetime ) ) {
- //Set to the same as start date
- m_end->m_datetime = m_start->m_datetime;
- }
-
- //recurunits
- if( m_recurunits && strlen( m_recurunits ) != 0 && strcasecmp( m_recurunits, DEFAULT_RECUR_UNITS ) != 0 ){
- prop = icalproperty_new_x( m_recurunits );
- icalproperty_set_x_name( prop, XPROP_RECURUNITS);
- icalcomponent_add_property( vevent, prop );
- }
-
- //recurinterval
- if( m_recurinterval != 1 ){
- sprintf( tmpstr, "%lu", m_recurinterval );
- prop = icalproperty_new_x( tmpstr );
- icalproperty_set_x_name( prop, XPROP_RECURINTERVAL);
- icalcomponent_add_property( vevent, prop );
- }
-
- //recurrence
-
- if( m_recur ) {
- int recurtype = RECUR_NONE;
- int interval = m_recurinterval;
- if( interval == 0 )
- interval = 1;
- if( m_recurunits ) {
- if( strcasecmp( m_recurunits , "days" ) == 0 ) {
- recurtype = RECUR_DAILY;
- } else if( strcasecmp( m_recurunits , "weeks" ) == 0 ) {
- recurtype = RECUR_WEEKLY;
- } else if( strcasecmp( m_recurunits , "months" ) == 0 ) {
- recurtype = RECUR_MONTHLY_MDAY;
- } else if( strcasecmp( m_recurunits, "months_day" ) == 0 ) {
- recurtype = RECUR_MONTHLY_WDAY;
- } else if( strcasecmp( m_recurunits , "years" ) == 0 ) {
- recurtype = RECUR_YEARLY;
- }
- }
-
- struct icalrecurrencetype recur;
- icalrecurrencetype_clear( &recur );
- // for( int i=0; im_datetime.year;
- recur.until.month = m_recurend->m_datetime.month;
- recur.until.day = m_recurend->m_datetime.day;
- recur.until.hour = 23;
- recur.until.minute = 59;
- recur.until.second = 59;
- } else {
- recur.count = m_recurcount;
- }
- }
-
- switch ( recurtype ) {
- case RECUR_NONE:
- break;
- case RECUR_DAILY:
- recur.freq = ICAL_DAILY_RECURRENCE;
- prop = icalproperty_new_rrule( recur );
- icalcomponent_add_property( vevent, prop );
- break;
- case RECUR_WEEKLY:{
- recur.freq = ICAL_WEEKLY_RECURRENCE;
- //if the recur rule is weekly make sure a weekdaymask exists
- if( m_recurweekdays == 0 ) {
- m_recurweekdays = 1 << (icaltime_day_of_week( m_start->m_datetime )-1);
- }
- short weekdaymask = m_recurweekdays;
- int k=0;
-// bool weekdaymatchesstartdate=false;
- for( int i=0; i<7; i++ ) {
- if( weekdaymask & 1 ) {
- recur.by_day[k++]=i+1;
-// if( !weekdaymatchesstartdate ) {
-// m_start->AdjustToWeekday( i+1 );
-// m_end->AdjustToWeekday( i+1 );
-// weekdaymatchesstartdate=true;
-// }
- }
- weekdaymask >>= 1;
- }
- prop = icalproperty_new_rrule( recur );
- icalcomponent_add_property( vevent, prop );
- break;
- }
- case RECUR_MONTHLY_MDAY:
- recur.freq = ICAL_MONTHLY_RECURRENCE;
- if( m_recurweeknumber ) {
-// printf( "DAY: %d\n" , icaltime_day_of_week( m_start->m_datetime ) );
-// printf( "WEEKNUMBER: %d\n" , m_recurweeknumber );
- if( m_recurweeknumber != 5 )
- recur.by_day[0] = icaltime_day_of_week( m_start->m_datetime ) + m_recurweeknumber*8;
- else
- recur.by_day[0] = - icaltime_day_of_week( m_start->m_datetime ) - 8 ;
- }
- prop = icalproperty_new_rrule( recur );
- icalcomponent_add_property( vevent, prop );
- break;
- case RECUR_MONTHLY_WDAY:
- recur.freq = ICAL_MONTHLY_RECURRENCE;
- prop = icalproperty_new_rrule( recur );
- icalcomponent_add_property( vevent, prop );
- break;
- case RECUR_YEARLY:
- recur.by_month[0] = m_start->m_datetime.month;
- recur.freq = ICAL_YEARLY_RECURRENCE;
- prop = icalproperty_new_rrule( recur );
- icalcomponent_add_property( vevent, prop );
- break;
- }
-
- //exceptions
- for( int i=0; im_datetime ) ) {
- m_start->GetTzID( &starttzid );
- if( !starttzid && m_storeingmt ) {
- m_start->SetTzID( "/Mozilla.org/BasicTimezones/GMT" );
- m_start->GetTzID( &starttzid );
- }
-
- if( m_allday ) {
- m_start->SetHour( 0 );
- m_start->SetMinute( 0 );
- m_start->m_datetime.is_date = true; //This will reflect the event being an all-day event
- prop = icalproperty_new_dtstart( m_start->m_datetime );
- if( starttzid ) {
- icaltimezone *timezone = icaltimezone_get_builtin_timezone_from_tzid (starttzid);
- icalparameter *tmppar = icalparameter_new_tzid( starttzid );
- icalproperty_add_parameter( prop, tmppar );
- icalcomponent_add_component( newcalendar, icalcomponent_new_clone( icaltimezone_get_component ( timezone ) ) );
- }
- m_start->m_datetime.is_date = false; //Because currently we depend on m_datetime being a complete datetime value.
- } else {
- if( starttzid ) {
- icaltimezone *timezone = icaltimezone_get_builtin_timezone_from_tzid (starttzid);
- icaltimetype convertedtime = m_start->m_datetime;
- icaltimezone_convert_time ( &convertedtime, currenttimezone, timezone );
- if( strcmp( starttzid, "/Mozilla.org/BasicTimezones/GMT" )==0 ) {
- convertedtime.is_utc = true;
- prop = icalproperty_new_dtstart( convertedtime );
- } else {
- prop = icalproperty_new_dtstart( convertedtime );
- icalparameter *tmppar = icalparameter_new_tzid( starttzid );
- icalproperty_add_parameter( prop, tmppar );
- icalcomponent_add_component( newcalendar, icalcomponent_new_clone( icaltimezone_get_component ( timezone ) ) );
- }
- } else
- prop = icalproperty_new_dtstart( m_start->m_datetime );
- }
- icalcomponent_add_property( vevent, prop );
- }
-
- //enddate
- if( m_end && !icaltime_is_null_time( m_end->m_datetime ) ) {
- char *tzid=nsnull;
- m_end->GetTzID( &tzid );
- if( !tzid && m_storeingmt ) {
- m_end->SetTzID( "/Mozilla.org/BasicTimezones/GMT" );
- m_end->GetTzID( &tzid );
- }
- if( m_allday ) {
- if( m_end->CompareDate( m_start )==0 ) {
- m_end->m_datetime = m_start->m_datetime;
- icaltime_adjust( &(m_end->m_datetime), 1, 0, 0, 0 );
- } else {
- m_end->SetHour( 0 );
- m_end->SetMinute( 0 );
- }
- m_end->m_datetime.is_date = true;
- prop = icalproperty_new_dtend( m_end->m_datetime );
- if( tzid ) {
- icaltimezone *timezone = icaltimezone_get_builtin_timezone_from_tzid (tzid);
- icalparameter *tmppar = icalparameter_new_tzid( tzid );
- icalproperty_add_parameter( prop, tmppar );
- if( !starttzid || strcmp( starttzid, tzid ) != 0 )
- icalcomponent_add_component( newcalendar, icalcomponent_new_clone( icaltimezone_get_component ( timezone ) ) );
- nsMemory::Free( tzid );
- }
- m_end->m_datetime.is_date = false; //Because currently we depend on m_datetime being a complete datetime value.
- } else {
- if( tzid ) {
- icaltimezone *timezone = icaltimezone_get_builtin_timezone_from_tzid (tzid);
- icaltimetype convertedtime = m_end->m_datetime;
- icaltimezone_convert_time ( &convertedtime, currenttimezone, timezone );
- if( strcmp( tzid, "/Mozilla.org/BasicTimezones/GMT" )==0 ) {
- convertedtime.is_utc = true;
- prop = icalproperty_new_dtend( convertedtime );
- } else {
- prop = icalproperty_new_dtend( convertedtime );
- icalparameter *tmppar = icalparameter_new_tzid( tzid );
- icalproperty_add_parameter( prop, tmppar );
- if( !starttzid || strcmp( starttzid, tzid ) != 0 )
- icalcomponent_add_component( newcalendar, icalcomponent_new_clone( icaltimezone_get_component ( timezone ) ) );
- }
- nsMemory::Free( tzid );
- } else
- prop = icalproperty_new_dtend( m_end->m_datetime );
- }
- icalcomponent_add_property( vevent, prop );
- }
-
- if( starttzid )
- nsMemory::Free( starttzid );
-
- //stampdate
- if( m_stamp && !icaltime_is_null_time( m_stamp->m_datetime ) ) {
- prop = icalproperty_new_dtstamp( m_stamp->m_datetime );
- icalcomponent_add_property( vevent, prop );
- }
-
- //lastmodified
- if( !icaltime_is_null_time( m_lastmodified ) ) {
- prop = icalproperty_new_lastmodified( m_lastmodified );
- icalcomponent_add_property( vevent, prop );
- }
-
- //snoozetimes
- icalcomponent *tmpcomp=NULL;
- int j;
- for( j=0; jCount(&attachmentCount);
- nsCOMPtr element;
- unsigned int i;
- for (i = 0; i < attachmentCount; i ++) {
- m_attachments->QueryElementAt(i, NS_GET_IID(nsIMsgAttachment), getter_AddRefs(element));
- if (element)
- {
- char *url;
- element->GetUrl( &url );
- icalparameter *tmppar = icalparameter_new_member( "Attachment" );
- prop = icalproperty_new_x( url );
- icalproperty_add_parameter( prop, tmppar );
- icalcomponent_add_property( vevent, prop );
-/* icalattach *attach= icalattach_new_from_url( url );
- if( attach ) {
- char tst[100]= "testing";
- char *buffer;
- buffer = PL_Base64Encode( tst, strlen(tst), nsnull );
-
-// strcpy( buffer, "salam" );
-// icalattachtype_set_base64( attachtype, buffer, 0 );
- prop = icalproperty_new_attach( attach );
-
-// tmppar = icalparameter_new_fmttype( url );
-// icalproperty_add_parameter( prop, tmppar );
-// tmppar = icalparameter_new_encoding( ICAL_ENCODING_BASE64 );
-// icalproperty_add_parameter( prop, tmppar );
-
- icalcomponent_add_property( vevent, prop );
- }*/
- nsMemory::Free( url );
- }
- }
-
- PRUint32 contactCount = 0;
- m_contacts->Count(&contactCount);
- nsCOMPtr contact;
- for (i = 0; i < contactCount; i ++) {
- m_contacts->QueryElementAt(i, NS_GET_IID(nsIAbCard), getter_AddRefs(contact));
- if (contact)
- {
- nsXPIDLString email;
- contact->GetPrimaryEmail( getter_Copies( email ) );
- NS_ConvertUCS2toUTF8 aUtf8Str(email);
- prop = icalproperty_new_contact( aUtf8Str.get() );
- icalcomponent_add_property( vevent, prop );
- }
- }
-#endif
-
- //add event to newcalendar
- icalcomponent_add_component( newcalendar, vevent );
- return newcalendar;
-}
-
-NS_IMETHODIMP oeICalEventImpl::ReportError( PRInt16 severity, PRUint32 errorid, const char *errorstring ) {
- if( m_calendar ) {
- m_calendar->ReportError( severity, errorid, errorstring );
- } else if( gContainer ) {
- gContainer->ReportError( severity, errorid, errorstring );
- }
- return NS_OK;
-}
-
-NS_IMETHODIMP oeICalEventImpl::SetParameter( const char *name, const char *value ) {
- if( strcmp( name, "ICAL_RELATED_PARAMETER" ) == 0 ) {
- if( strcmp( value, "ICAL_RELATED_START" ) == 0 )
- m_alarmtriggerrelation = ICAL_RELATED_START;
- else if( strcmp( value, "ICAL_RELATED_END" ) == 0 )
- m_alarmtriggerrelation = ICAL_RELATED_END;
- else
- return NS_ERROR_ILLEGAL_VALUE;
-
- return NS_OK;
- }
- return NS_ERROR_NOT_IMPLEMENTED;
-}
-
-NS_IMETHODIMP oeICalEventImpl::GetParameter( const char *name, char **value ) {
- *value = nsnull;
- if( strcmp( name, "ICAL_RELATED_PARAMETER" ) == 0 ) {
- char *tmpstr=nsnull;
- switch ( m_alarmtriggerrelation ) {
- case ICAL_RELATED_START:
- tmpstr = "ICAL_RELATED_START";
- break;
- case ICAL_RELATED_END:
- tmpstr = "ICAL_RELATED_END";
- break;
- }
- if( tmpstr ) {
- *value = (char*) nsMemory::Clone( tmpstr, strlen( tmpstr )+1);
- return NS_OK;
- }
- else
- return NS_ERROR_UNEXPECTED;
- }
- return NS_ERROR_NOT_AVAILABLE;
-}
-
-/********************************************************************************************/
-#include "nsIServiceManager.h"
-
-NS_IMPL_ADDREF(oeICalEventDisplayImpl)
-NS_IMPL_RELEASE(oeICalEventDisplayImpl)
-//NS_IMPL_ISUPPORTS1(oeICalEventDisplayImpl, oeIICalEventDisplay)
-
-nsresult
-NS_NewICalEventDisplay( oeIICalEvent* event, oeIICalEventDisplay** inst )
-{
- NS_PRECONDITION(inst != nsnull, "null ptr");
- if (! inst)
- return NS_ERROR_NULL_POINTER;
-
- *inst = new oeICalEventDisplayImpl( event );
- if (! *inst)
- return NS_ERROR_OUT_OF_MEMORY;
-
- NS_ADDREF(*inst);
- return NS_OK;
-}
-
-oeICalEventDisplayImpl::oeICalEventDisplayImpl( oeIICalEvent* event )
-{
-#ifdef ICAL_DEBUG_ALL
- printf( "oeICalEventDisplayImpl::oeICalEventDisplayImpl(): %d\n", ++gEventDisplayCount );
-#endif
- nsresult rv;
- if( event == nsnull ) {
- mEvent = do_CreateInstance(OE_ICALEVENTDISPLAY_CONTRACTID, &rv);
- } else {
- mEvent = event;
- }
-
- /* member initializers and constructor code */
- m_displaydate = icaltime_null_time();
-}
-
-oeICalEventDisplayImpl::~oeICalEventDisplayImpl()
-{
-#ifdef ICAL_DEBUG_ALL
- printf( "oeICalEventDisplayImpl::~oeICalEventDisplayImpl(): %d\n", --gEventDisplayCount );
-#endif
- /* destructor code */
- mEvent = nsnull;
-}
-
-NS_IMETHODIMP
-oeICalEventDisplayImpl::QueryInterface(REFNSIID aIID, void** aInstancePtr)
-{
- if (nsnull == aInstancePtr) {
- return NS_ERROR_NULL_POINTER;
- }
- if (aIID.Equals(NS_GET_IID(nsISupports))) {
- *aInstancePtr = (void*)(oeIICalEventDisplay*)this;
- *aInstancePtr = (nsISupports*)*aInstancePtr;
- NS_ADDREF_THIS();
- return NS_OK;
- }
- if (aIID.Equals(NS_GET_IID(oeIICalEventDisplay))) {
- *aInstancePtr = (void*)(oeIICalEventDisplay*)this;
- NS_ADDREF_THIS();
- return NS_OK;
- }
- if (aIID.Equals(NS_GET_IID(oeIICalEvent))) {
- return mEvent->QueryInterface( aIID, aInstancePtr );
- }
- if (aIID.Equals(NS_GET_IID(oeIICalTodo))) {
- return mEvent->QueryInterface( aIID, aInstancePtr );
- }
- return NS_NOINTERFACE;
-}
-
-NS_IMETHODIMP oeICalEventDisplayImpl::GetDisplayDate( PRTime *aRetVal )
-{
-#ifdef ICAL_DEBUG_ALL
- printf( "oeICalEventDisplayImpl::GetDisplayDate()\n" );
-#endif
- *aRetVal = ConvertToPrtime( m_displaydate );
- return NS_OK;
-}
-
-
-NS_IMETHODIMP oeICalEventDisplayImpl::SetDisplayDate( PRTime aNewVal )
-{
-#ifdef ICAL_DEBUG_ALL
- printf( "oeICalEventDisplayImpl::SetDisplayDate()\n" );
-#endif
- m_displaydate = ConvertFromPrtime( aNewVal );
- return NS_OK;
-}
-
-NS_IMETHODIMP oeICalEventDisplayImpl::GetDisplayEndDate( PRTime *aRetVal )
-{
-#ifdef ICAL_DEBUG_ALL
- printf( "oeICalEventDisplayImpl::GetDisplayEndDate()\n" );
-#endif
- *aRetVal = ConvertToPrtime( m_displaydateend );
- return NS_OK;
-}
-
-
-NS_IMETHODIMP oeICalEventDisplayImpl::SetDisplayEndDate( PRTime aNewVal )
-{
-#ifdef ICAL_DEBUG_ALL
- printf( "oeICalEventDisplayImpl::SetDisplayEndDate()\n" );
-#endif
- m_displaydateend = ConvertFromPrtime( aNewVal );
- return NS_OK;
-}
-
-NS_IMETHODIMP oeICalEventDisplayImpl::GetEvent( oeIICalEvent **ev )
-{
-#ifdef ICAL_DEBUG_ALL
- printf( "oeICalEventDisplayImpl::GetEvent()\n" );
-#endif
-#ifdef ICAL_DEBUG_ALL
- printf( "WARNING: .event is no longer needed to access event fields\n" );
-#endif
- *ev = mEvent;
- NS_ADDREF(*ev);
- return NS_OK;
-}
diff --git a/mozilla/calendar/libxpical/oeICalEventImpl.h b/mozilla/calendar/libxpical/oeICalEventImpl.h
deleted file mode 100644
index 42dcd42eafa..00000000000
--- a/mozilla/calendar/libxpical/oeICalEventImpl.h
+++ /dev/null
@@ -1,188 +0,0 @@
-/* ***** BEGIN LICENSE BLOCK *****
- * Version: MPL 1.1/GPL 2.0/LGPL 2.1
- *
- * The contents of this file are subject to the Mozilla Public License Version
- * 1.1 (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * Software distributed under the License is distributed on an "AS IS" basis,
- * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
- * for the specific language governing rights and limitations under the
- * License.
- *
- * The Original Code is OEone Calendar Code, released October 31st, 2001.
- *
- * The Initial Developer of the Original Code is
- * OEone Corporation.
- * Portions created by the Initial Developer are Copyright (C) 2001
- * the Initial Developer. All Rights Reserved.
- *
- * Contributor(s): Mostafa Hosseini
- * ArentJan Banck
- *
- * Alternatively, the contents of this file may be used under the terms of
- * either the GNU General Public License Version 2 or later (the "GPL"), or
- * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
- * in which case the provisions of the GPL or the LGPL are applicable instead
- * of those above. If you wish to allow use of your version of this file only
- * under the terms of either the GPL or the LGPL, and not to allow others to
- * use your version of this file under the terms of the MPL, indicate your
- * decision by deleting the provisions above and replace them with the notice
- * and other provisions required by the GPL or the LGPL. If you do not delete
- * the provisions above, a recipient may use your version of this file under
- * the terms of any one of the MPL, the GPL or the LGPL.
- *
- * ***** END LICENSE BLOCK ***** */
-
- /* Header file for oeICalEventImpl.cpp containing its CID and CONTRACTID.*/
-
-#ifndef _OEICALEVENTIMPL_H_
-#define _OEICALEVENTIMPL_H_
-
-#include "oeIICal.h"
-#include "oeDateTimeImpl.h"
-#include "nsISimpleEnumerator.h"
-#include "nsISupportsPrimitives.h"
-#include "nsSupportsPrimitives.h"
-#include "nsISupportsArray.h"
-#include "nsString.h"
-#include "nsVoidArray.h"
-
-extern "C" {
- #include "ical.h"
-}
-
-#define OE_ICALEVENT_CID \
-{ 0x31bda500, 0xee5e, 0x4a4a, { 0x9a, 0xb4, 0x7b, 0x4b, 0x3e, 0x87, 0x40, 0x05 } }
-
-#define OE_ICALEVENT_CONTRACTID "@mozilla.org/icalevent;1"
-
-#define ICALEVENT_VERSION "2.0"
-#define ICALEVENT_PRODID "-//Mozilla.org/NONSGML Mozilla Calendar V1.0//EN"
-
-/* event enumerator */
-class
-oeEventEnumerator : public nsISimpleEnumerator
-{
- public:
- oeEventEnumerator();
- virtual ~oeEventEnumerator();
-
- // nsISupports interface
- NS_DECL_ISUPPORTS
-
- // nsISimpleEnumerator interface
- NS_DECL_NSISIMPLEENUMERATOR
-
- NS_IMETHOD AddEvent( nsISupports *event );
-
- private:
- PRUint32 mCurrentIndex;
- nsCOMPtr mEventVector;
-};
-
-class
-oeDateEnumerator : public nsISimpleEnumerator
-{
- public:
- oeDateEnumerator();
- virtual ~oeDateEnumerator();
-
- // nsISupports interface
- NS_DECL_ISUPPORTS
-
- // nsISimpleEnumerator interface
- NS_DECL_NSISIMPLEENUMERATOR
-
- NS_IMETHOD AddDate( PRTime date );
-
- private:
- PRInt32 mCurrentIndex;
- nsVoidArray mDateVector;
-};
-
-/* oeIcalEvent Header file */
-class oeICalEventImpl : public oeIICalEvent
-{
-public:
- NS_DECL_ISUPPORTS
- NS_DECL_OEIICALEVENT
- oeICalEventImpl();
- virtual ~oeICalEventImpl();
- /* additional members */
- bool ParseIcalComponent( icalcomponent *vcalendar );
- icalcomponent *AsIcalComponent();
- icaltimetype GetNextAlarmTime( icaltimetype begin );
- bool matchId( const char *id );
- icaltimetype GetNextRecurrence( icaltimetype begin, bool *isbeginning );
- icaltimetype GetPreviousOccurrence( icaltimetype beforethis );
- icaltimetype CalculateEventTime( icaltimetype alarmtime );
- void ChopAndAddEventToEnum( struct icaltimetype startdate, nsISimpleEnumerator **eventlist,
- bool isallday, bool isbeginning );
- void SetType( Componenttype type );
-
-private:
- Componenttype m_type;
- char *m_id;
- char *m_syncid;
- nsCString m_title;
- nsCString m_description;
- nsCString m_location;
- nsCString m_category;
- nsCString m_url;
- short m_priority;
- eventMethodProperty m_method;
- eventStatusProperty m_status;
- bool m_isprivate;
- bool m_allday;
- bool m_hasalarm;
- unsigned long m_alarmlength;
- icalparameter_related m_alarmtriggerrelation;
- char *m_alarmunits;
- char *m_alarmemail;
- char *m_inviteemail;
- short m_recurtype;
- unsigned long m_recurinterval;
- unsigned long m_recurcount;
- bool m_recur;
- bool m_recurforever;
- char *m_recurunits;
- short m_recurweekdays;
- short m_recurweeknumber;
- icaldurationtype m_duration;
- oeDateTimeImpl *m_start;
- oeDateTimeImpl *m_end;
- oeDateTimeImpl *m_stamp;
- oeDateTimeImpl *m_recurend;
- bool m_storeingmt;
- icaltimetype m_lastalarmack;
- icaltimetype m_lastmodified;
- nsVoidArray m_exceptiondates;
- nsVoidArray m_snoozetimes;
- icaltimetype CalculateAlarmTime( icaltimetype date );
- bool IsExcepted( PRTime date );
- icaldurationtype GetLength();
- nsCOMPtr m_attachments;
- nsCOMPtr m_contacts;
- nsCOMPtr m_calendar;
-};
-
-/*******************************************************************************************/
-#define OE_ICALEVENTDISPLAY_CONTRACTID "@mozilla.org/icaleventdisplay;1"
-
-class oeICalEventDisplayImpl : public oeIICalEventDisplay
-{
-public:
- NS_DECL_ISUPPORTS
- NS_FORWARD_OEIICALEVENT(mEvent->)
- NS_DECL_OEIICALEVENTDISPLAY
- oeICalEventDisplayImpl( oeIICalEvent *event );
- virtual ~oeICalEventDisplayImpl();
-private:
- icaltimetype m_displaydate;
- icaltimetype m_displaydateend;
- nsCOMPtr mEvent;
-};
-
-#endif
diff --git a/mozilla/calendar/libxpical/oeICalFactory.cpp b/mozilla/calendar/libxpical/oeICalFactory.cpp
deleted file mode 100644
index 2b92f57a2f1..00000000000
--- a/mozilla/calendar/libxpical/oeICalFactory.cpp
+++ /dev/null
@@ -1,84 +0,0 @@
-/* ***** BEGIN LICENSE BLOCK *****
- * Version: MPL 1.1/GPL 2.0/LGPL 2.1
- *
- * The contents of this file are subject to the Mozilla Public License Version
- * 1.1 (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * Software distributed under the License is distributed on an "AS IS" basis,
- * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
- * for the specific language governing rights and limitations under the
- * License.
- *
- * The Original Code is OEone Calendar Code, released October 31st, 2001.
- *
- * The Initial Developer of the Original Code is
- * OEone Corporation.
- * Portions created by the Initial Developer are Copyright (C) 2001
- * the Initial Developer. All Rights Reserved.
- *
- * Contributor(s): Mostafa Hosseini
- *
- * Alternatively, the contents of this file may be used under the terms of
- * either the GNU General Public License Version 2 or later (the "GPL"), or
- * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
- * in which case the provisions of the GPL or the LGPL are applicable instead
- * of those above. If you wish to allow use of your version of this file only
- * under the terms of either the GPL or the LGPL, and not to allow others to
- * use your version of this file under the terms of the MPL, indicate your
- * decision by deleting the provisions above and replace them with the notice
- * and other provisions required by the GPL or the LGPL. If you do not delete
- * the provisions above, a recipient may use your version of this file under
- * the terms of any one of the MPL, the GPL or the LGPL.
- *
- * ***** END LICENSE BLOCK ***** */
-
-/* Factory implementation of various calendar objects */
-
-#include "oeICalImpl.h"
-#include "oeICalContainerImpl.h"
-#include "oeICalEventImpl.h"
-#include "oeDateTimeImpl.h"
-
-#include "nsIGenericFactory.h"
-
-
-
-NS_GENERIC_FACTORY_CONSTRUCTOR(oeICalImpl)
-NS_GENERIC_FACTORY_CONSTRUCTOR(oeICalContainerImpl)
-NS_GENERIC_FACTORY_CONSTRUCTOR(oeICalEventImpl)
-NS_GENERIC_FACTORY_CONSTRUCTOR(oeICalTodoImpl)
-NS_GENERIC_FACTORY_CONSTRUCTOR(oeDateTimeImpl)
-
-static const nsModuleComponentInfo pModuleInfo[] =
-{
- { "ICal Service",
- OE_ICAL_CID,
- OE_ICAL_CONTRACTID,
- oeICalImplConstructor,
- },
- { "ICal Container",
- OE_ICALCONTAINER_CID,
- OE_ICALCONTAINER_CONTRACTID,
- oeICalContainerImplConstructor,
- },
- { "ICal Event",
- OE_ICALEVENT_CID,
- OE_ICALEVENT_CONTRACTID,
- oeICalEventImplConstructor,
- },
- { "ICal DateTime",
- OE_DATETIME_CID,
- OE_DATETIME_CONTRACTID,
- oeDateTimeImplConstructor,
- },
- { "ICal Todo",
- OE_ICALTODO_CID,
- OE_ICALTODO_CONTRACTID,
- oeICalTodoImplConstructor,
- }
-};
-
-NS_IMPL_NSGETMODULE( oeICalModule, pModuleInfo)
-
diff --git a/mozilla/calendar/libxpical/oeICalImpl.cpp b/mozilla/calendar/libxpical/oeICalImpl.cpp
deleted file mode 100644
index 04b62885c99..00000000000
--- a/mozilla/calendar/libxpical/oeICalImpl.cpp
+++ /dev/null
@@ -1,2874 +0,0 @@
-/* ***** BEGIN LICENSE BLOCK *****
- * Version: MPL 1.1/GPL 2.0/LGPL 2.1
- *
- * The contents of this file are subject to the Mozilla Public License Version
- * 1.1 (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * Software distributed under the License is distributed on an "AS IS" basis,
- * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
- * for the specific language governing rights and limitations under the
- * License.
- *
- * The Original Code is OEone Calendar Code, released
- * October 31st, 2001.
- *
- * The Initial Developer of the Original Code is
- * OEone Corporation.
- * Portions created by the Initial Developer are Copyright (C) 2001
- * the Initial Developer. All Rights Reserved.
- *
- * Contributor(s):
- * Mostafa Hosseini
- * Cristian Tapus
- *
- * Alternatively, the contents of this file may be used under the terms of
- * either the GNU General Public License Version 2 or later (the "GPL"), or
- * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
- * in which case the provisions of the GPL or the LGPL are applicable instead
- * of those above. If you wish to allow use of your version of this file only
- * under the terms of either the GPL or the LGPL, and not to allow others to
- * use your version of this file under the terms of the MPL, indicate your
- * decision by deleting the provisions above and replace them with the notice
- * and other provisions required by the GPL or the LGPL. If you do not delete
- * the provisions above, a recipient may use your version of this file under
- * the terms of any one of the MPL, the GPL or the LGPL.
- *
- * ***** END LICENSE BLOCK ***** */
-
- /* This file implements an XPCOM object which represents a calendar object. It is a container
- of events and prepares responses for queries made upon the calendar in whole. The task of reading from
- and writing to the calendar data storage is currently performed by this object */
-
-#ifndef WIN32
-#include
-#endif
-
-#define __cplusplus__ 1
-
-#include "oeICalImpl.h"
-#include "oeICalEventImpl.h"
-#include "nsMemory.h"
-#include "stdlib.h"
-#include "nsCOMPtr.h"
-#include "nsISimpleEnumerator.h"
-#include "nsString.h"
-#include "nsIURL.h"
-#include "nsNetCID.h"
-#include "nsEscape.h"
-#include "nsISupportsArray.h"
-#include "nsXPCOM.h"
-#include "nsComponentManagerUtils.h"
-#include "nsIWindowMediator.h"
-#include "nsIServiceManager.h"
-#include "nsIDOMWindowInternal.h"
-#include "nsIDOMDocument.h"
-#include "nsIDOMElement.h"
-#include "nsIPrefBranch.h"
-#include "nsIPrefService.h"
-#include "nsNativeCharsetUtils.h"
-
-
-extern "C" {
- #include "icalss.h"
-}
-
-icaltimetype ConvertFromPrtime( PRTime indate );
-PRTime ConvertToPrtime ( icaltimetype indate );
-void AlarmTimerCallback(nsITimer *aTimer, void *aClosure);
-void GenerateUUID(char *output);
-
-icalcomponent* icalcomponent_fetch( icalcomponent* parent,const char* uid )
-{
- icalcomponent *inner;
- icalproperty *prop;
- const char *this_uid;
-
- for(inner = icalcomponent_get_first_component( parent , ICAL_ANY_COMPONENT );
- inner != 0;
- inner = icalcomponent_get_next_component( parent , ICAL_ANY_COMPONENT ) ){
-
- prop = icalcomponent_get_first_property(inner,ICAL_UID_PROPERTY);
- if ( prop ) {
- this_uid = icalproperty_get_uid( prop );
-
- if(this_uid==0){
- icalerror_warn("icalcomponent_fetch found a component with no UID");
- continue;
- }
- if (strcmp(uid,this_uid)==0){
- return inner;
- }
- } else {
- icalerror_warn("icalcomponent_fetch found a component with no UID");
- }
- }
- return nsnull;
-}
-
-/*
- * This function adds the first component of the child component to the
- * first component of the parent icalfileset (which is a icalfileset_impl)
- *
- * This is used in the following member functions: AddEvent, ModifyEvent,
- * AddTodo, ModifyTodo
- *
- */
-icalerrorenum icalfileset_add_first_to_first_component(icalfileset *parent,
- icalcomponent* child)
-{
-
-#ifdef ICAL_DEBUG
- printf("icalfileset_add_first_to_first_component()::\n");
-#endif
-
- struct icalfileset_impl* impl = (struct icalfileset_impl*)parent;
-
- icalerror_check_arg_re((parent!=0),"parent", ICAL_BADARG_ERROR);
- icalerror_check_arg_re((child!=0),"child",ICAL_BADARG_ERROR);
-
- // get the first component of the child which is either a vevent or a vtodo
- icalcomponent* vfirst = icalcomponent_get_first_component(child, ICAL_VEVENT_COMPONENT);
- if (vfirst==0) {
- vfirst = icalcomponent_get_first_component(child, ICAL_VTODO_COMPONENT);
- }
- if (vfirst==0) return ICAL_INTERNAL_ERROR;
-
- // extract the first (presumably) vcalendar component of the parent stream
- struct icalfileset_impl* firstc = (struct icalfileset_impl*)icalfileset_get_first_component(impl);
-
- icalcomponent_kind kind_firstc;
-
- if (firstc!=0)
- kind_firstc = icalcomponent_isa (firstc);
- else
- // the check below will fail due to firstc==0
- kind_firstc = ICAL_VCALENDAR_COMPONENT;
-
- if ( (firstc==0) || (kind_firstc != ICAL_VCALENDAR_COMPONENT) ) {
- // if parent stream is empty or first component is not a VCALENDAR
- // then create a new vcalendar component
- firstc = (struct icalfileset_impl*)icalcomponent_new(ICAL_VCALENDAR_COMPONENT);
-
- if (firstc==0) {
-#ifdef ICAL_DEBUG
- printf("icalfileset_add_first_to_first_component():: firstc is still NULL\n");
-#endif
- return ICAL_INTERNAL_ERROR;
- }
-
- // add component to parent stream
- icalfileset_add_component(parent, firstc);
- } else {
- // I need to remove the version and the prodid
-
- //version
- icalproperty *prop = icalcomponent_get_first_property(firstc, ICAL_VERSION_PROPERTY );
- icalcomponent_remove_property( firstc, prop );
-
- //prodid
- prop = icalcomponent_get_first_property( firstc, ICAL_PRODID_PROPERTY );
- icalcomponent_remove_property( firstc, prop );
- }
-
-
- //version
- icalproperty *prop = icalproperty_new_version( ICALEVENT_VERSION );
- icalcomponent_add_property( firstc, prop );
-
- //prodid
- prop = icalproperty_new_prodid( ICALEVENT_PRODID );
- icalcomponent_add_property( firstc, prop );
-
- // get the timezone component if any
- icalcomponent* timezone = icalcomponent_get_first_component(child, ICAL_VTIMEZONE_COMPONENT);
-
- // we know that we have at most one timezone component inside the child component
- if (timezone!=0) icalcomponent_add_component(firstc, timezone);
-
- // add first component of child into the first component of stream
- icalcomponent_add_component(firstc, vfirst);
-
- icalfileset_mark(parent);
-
- return ICAL_NO_ERROR;
-
-}
-
-
-oeEventEnumerator::oeEventEnumerator( )
-:
- mCurrentIndex( 0 )
-{
- NS_NewISupportsArray(getter_AddRefs(mEventVector));
-}
-
-oeEventEnumerator::~oeEventEnumerator()
-{
-}
-
-NS_IMPL_ISUPPORTS1(oeEventEnumerator, nsISimpleEnumerator)
-
-NS_IMETHODIMP
-oeEventEnumerator::HasMoreElements(PRBool *result)
-{
- PRUint32 count = 0;
- mEventVector->Count(&count);
- if( mCurrentIndex >= count )
- {
- *result = PR_FALSE;
- }
- else
- {
- *result = PR_TRUE;
- }
- return NS_OK;
-}
-
-NS_IMETHODIMP
-oeEventEnumerator::GetNext(nsISupports **_retval)
-{
-
- PRUint32 count = 0;
- mEventVector->Count(&count);
- if( mCurrentIndex >= count )
- {
- *_retval = nsnull;
- }
- else
- {
- nsCOMPtr event;
- mEventVector->QueryElementAt( mCurrentIndex, NS_GET_IID(nsISupports), getter_AddRefs(event));
- *_retval = event;
- NS_ADDREF( *_retval );
- ++mCurrentIndex;
- }
-
- return NS_OK;
-}
-
-
-NS_IMETHODIMP
-oeEventEnumerator::AddEvent( nsISupports* event)
-{
- PRUint32 count = 0;
- mEventVector->Count( &count );
- mEventVector->InsertElementAt( event, count );
- return NS_OK;
-}
-
-/* date enumerator */
-oeDateEnumerator::oeDateEnumerator( )
-:
- mCurrentIndex( 0 )
-{
-}
-
-oeDateEnumerator::~oeDateEnumerator()
-{
- for( int i=0; i= mDateVector.Count() )
- {
- *result = PR_FALSE;
- }
- else
- {
- *result = PR_TRUE;
- }
- return NS_OK;
-}
-
-NS_IMETHODIMP
-oeDateEnumerator::GetNext(nsISupports **_retval)
-{
-
- if( mCurrentIndex >= mDateVector.Count() )
- {
- *_retval = nsnull;
- }
- else
- {
- nsresult rv;
- nsCOMPtr nsPRTime = do_CreateInstance( NS_SUPPORTS_PRTIME_CONTRACTID , &rv);
- if( NS_FAILED( rv ) ) {
- *_retval = nsnull;
- return rv;
- }
- nsISupportsPRTime* date;
- rv = nsPRTime->QueryInterface(NS_GET_IID(nsISupportsPRTime), (void **)&date);
- if( NS_FAILED( rv ) ) {
- *_retval = nsnull;
- return rv;
- }
-
- date->SetData( *(PRTime *)(mDateVector[ mCurrentIndex ]) );
- *_retval = date;
- ++mCurrentIndex;
- }
-
- return NS_OK;
-}
-
-NS_IMETHODIMP
-oeDateEnumerator::AddDate(PRTime date)
-{
- PRTime *newdate = new PRTime;
- if (!newdate)
- return NS_ERROR_OUT_OF_MEMORY;
- *newdate = date;
- mDateVector.AppendElement( newdate );
- return NS_OK;
-}
-
-//////////////////////////////////////////////////
-// ICal Factory
-//////////////////////////////////////////////////
-
-nsresult
-NS_NewICal( oeIICal** inst )
-{
- NS_PRECONDITION(inst != nsnull, "null ptr");
- if (! inst)
- return NS_ERROR_NULL_POINTER;
-
- *inst = new oeICalImpl();
- if (! *inst)
- return NS_ERROR_OUT_OF_MEMORY;
-
- NS_ADDREF(*inst);
- return NS_OK;
-}
-
-oeICalImpl::oeICalImpl()
-{
-#ifdef ICAL_DEBUG
- printf( "oeICalImpl::oeICalImpl()\n" );
-#endif
-
- m_batchMode = false;
- m_suppressAlarms = false;
-
- m_alarmtimer = nsnull;
-
- m_filter = new oeICalFilter();
- NS_ADDREF( m_filter );
-
- NS_NewISupportsArray(getter_AddRefs(m_observerlist));
- NS_NewISupportsArray(getter_AddRefs(m_todoobserverlist));
-}
-
-oeICalImpl::~oeICalImpl()
-{
-#ifdef ICAL_DEBUG
- printf( "oeICalImpl::~oeICalImpl()\n" );
-#endif
- CancelAlarmTimer();
-
- NS_RELEASE( m_filter );
-}
-
-/**
- * NS_IMPL_ISUPPORTS1 expands to a simple implementation of the nsISupports
- * interface. This includes a proper implementation of AddRef, Release,
- * and QueryInterface. If this class supported more interfaces than just
- * nsISupports,
- * you could use NS_IMPL_ADDREF() and NS_IMPL_RELEASE() to take care of the
- * simple stuff, but you would have to create QueryInterface on your own.
- * nsSampleFactory.cpp is an example of this approach.
- * Notice that the second parameter to the macro is the static IID accessor
- * method, and NOT the #defined IID.
- */
-NS_IMPL_ISUPPORTS1(oeICalImpl, oeIICal)
-
-nsVoidArray *oeICalImpl::GetEventList()
-{
- return &m_eventlist;
-}
-
-/**
-*
-* Test
-*
-* DESCRIPTION: An exported XPCOM function used by the tester program to make sure
-* all main internal functions are working properly
-* PARAMETERS:
-* None
-*
-* RETURN
-* None
-*/
-NS_IMETHODIMP
-oeICalImpl::Test(void)
-{
-#ifdef ICAL_DEBUG
- printf( "oeICalImpl::Test()\n" );
-#endif
- icalset *stream;
- icalcomponent *icalcalendar,*icalevent;
- struct icaltimetype start, end;
- char uidstr[10]="900000000";
- char icalrawcalendarstr[] = "BEGIN:VCALENDAR\n\
-BEGIN:VEVENT\n\
-END:VEVENT\n\
-END:VCALENDAR\n\
-";
-
- nsCAutoString nativeServeraddr;
- nsresult rv = NS_CopyUnicodeToNative(NS_ConvertUTF8toUTF16(m_serveraddr),
- nativeServeraddr);
- NS_ENSURE_SUCCESS(rv, rv);
-
- stream = icalfileset_new(nativeServeraddr.get());
- if ( !stream ) {
- #ifdef ICAL_DEBUG
- printf( "oeICalImpl::Test() failed: Cannot open stream: %s!\n", m_serveraddr.get() );
- #endif
- return NS_ERROR_FAILURE;
- }
-
- icalcalendar = icalparser_parse_string(icalrawcalendarstr);
- if ( !icalcalendar ) {
- #ifdef ICAL_DEBUG
- printf( "oeICalImpl::Test() failed: Cannot create VCALENDAR!\n" );
- #endif
- 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_ERROR_FAILURE;
- }
-
- icalproperty *uid = icalproperty_new_uid( uidstr );
- icalcomponent_add_property( icalevent, uid );
-
- icalproperty *title = icalproperty_new_summary( "Lunch time" );
- icalcomponent_add_property( icalevent, title );
-
- icalproperty *description = icalproperty_new_description( "Will be out for one hour" );
- icalcomponent_add_property( icalevent, description );
-
- icalproperty *location = icalproperty_new_location( "Restaurant" );
- icalcomponent_add_property( icalevent, location );
-
- icalproperty *category = icalproperty_new_categories( "Personal" );
- icalcomponent_add_property( icalevent, category );
-
- icalproperty *classp = icalproperty_new_class( ICAL_CLASS_PRIVATE );
- icalcomponent_add_property( icalevent, classp );
-
- start.year = 2001; start.month = 8; start.day = 15;
- start.hour = 12; start.minute = 24; start.second = 0;
- start.is_utc = false; start.is_date = false;
-
- end.year = 2001; end.month = 8; end.day = 15;
- end.hour = 13; end.minute = 24; end.second = 0;
- end.is_utc = false; end.is_date = false;
-
- icalproperty *dtstart = icalproperty_new_dtstart( start );
- icalproperty *dtend = icalproperty_new_dtend( end );
-
- icalcomponent_add_property( icalevent, dtstart );
- icalcomponent_add_property( icalevent, dtend );
- //
- icalproperty *xprop = icalproperty_new_x( "TRUE" );
- icalparameter *xpar = icalparameter_new_member( "AllDay" ); //NOTE: new_member is used because new_x didn't work
- // Better to be changed to new_x when problem is solved
- icalproperty_add_parameter( xprop, xpar );
-
- icalcomponent_add_property( icalevent, xprop );
- //
- xprop = icalproperty_new_x( "FALSE" );
- xpar = icalparameter_new_member( "Alarm" );
-
- icalproperty_add_parameter( xprop, xpar );
-
- icalcomponent_add_property( icalevent, xprop );
- //
- xprop = icalproperty_new_x( "FALSE" );
- xpar = icalparameter_new_member( "AlarmWentOff" );
-
- icalproperty_add_parameter( xprop, xpar );
-
- icalcomponent_add_property( icalevent, xprop );
- //
- xprop = icalproperty_new_x( "5" );
- xpar = icalparameter_new_member( "AlarmLength" );
-
- icalproperty_add_parameter( xprop, xpar );
-
- icalcomponent_add_property( icalevent, xprop );
- //
- xprop = icalproperty_new_x( "mostafah@oeone.com" );
- xpar = icalparameter_new_member( "AlarmEmailAddres" );
-
- icalproperty_add_parameter( xprop, xpar );
-
- icalcomponent_add_property( icalevent, xprop );
- //
- xprop = icalproperty_new_x( "mostafah@oeone.com" );
- xpar = icalparameter_new_member( "InviteEmailAddres" );
-
- icalproperty_add_parameter( xprop, xpar );
-
- icalcomponent_add_property( icalevent, xprop );
- //
- xprop = icalproperty_new_x( "5" );
- xpar = icalparameter_new_member( "SnoozeTime" );
-
- icalproperty_add_parameter( xprop, xpar );
-
- icalcomponent_add_property( icalevent, xprop );
- //
- xprop = icalproperty_new_x( "0" );
- xpar = icalparameter_new_member( "RecurType" );
-
- icalproperty_add_parameter( xprop, xpar );
-
- icalcomponent_add_property( icalevent, xprop );
- //
- xprop = icalproperty_new_x( "0" );
- xpar = icalparameter_new_member( "RecurInterval" );
-
- icalproperty_add_parameter( xprop, xpar );
-
- icalcomponent_add_property( icalevent, xprop );
- //
- xprop = icalproperty_new_x( "days" );
- xpar = icalparameter_new_member( "RepeatUnits" );
-
- icalproperty_add_parameter( xprop, xpar );
-
- icalcomponent_add_property( icalevent, xprop );
- //
- xprop = icalproperty_new_x( "FALSE" );
- xpar = icalparameter_new_member( "RepeatForever" );
-
- icalproperty_add_parameter( xprop, xpar );
-
- icalcomponent_add_property( icalevent, xprop );
- //
-
- struct icaltriggertype trig;
- icalcomponent *valarm = icalcomponent_new_valarm();
- trig.time.year = trig.time.month = trig.time.day = trig.time.hour = trig.time.minute = trig.time.second = 0;
- trig.duration.is_neg = true;
- trig.duration.days = trig.duration.weeks = trig.duration.hours = trig.duration.seconds = 0;
- trig.duration.minutes = 1;
- xprop = icalproperty_new_trigger( trig );
- icalcomponent_add_property( valarm, xprop );
- icalcomponent_add_component( icalevent, valarm );
-
- icalfileset_add_component(stream,icalcalendar);
-
- if( icalfileset_commit(stream) != ICAL_NO_ERROR ) {
- #ifdef ICAL_DEBUG
- printf( "oeICalImpl::Test() : WARNING icalfileset_commit() unsuccessful\n" );
- #endif
- }
-#ifdef ICAL_DEBUG
- printf("Appended Event\n");
-#endif
-
- icalcomponent *fetchedcal = icalfileset_fetch( stream, uidstr );
- if ( !fetchedcal ) {
- #ifdef ICAL_DEBUG
- printf( "oeICalImpl::Test() failed: Cannot fetch event!\n" );
- #endif
- return NS_ERROR_FAILURE;
- }
-
- icalcomponent *fetchedevent = icalcomponent_get_first_component( fetchedcal,ICAL_VEVENT_COMPONENT);
- if ( !fetchedevent ) {
- #ifdef ICAL_DEBUG
- printf( "oeICalImpl::Test() failed: VEVENT not found!\n" );
- #endif
- return NS_ERROR_FAILURE;
- }
-
-#ifdef ICAL_DEBUG
- printf("Fetched Event\n");
-#endif
-
- icalproperty *tmpprop;
- //
- tmpprop = icalcomponent_get_first_property( fetchedevent, ICAL_UID_PROPERTY );
- if ( !tmpprop ) {
- #ifdef ICAL_DEBUG
- printf( "oeICalImpl::Test() failed: UID not found!\n" );
- #endif
- return NS_ERROR_FAILURE;
- }
-#ifdef ICAL_DEBUG
- printf("id: %s\n", icalproperty_get_uid( tmpprop ) );
-#endif
- //
- tmpprop = icalcomponent_get_first_property( fetchedevent, ICAL_SUMMARY_PROPERTY );
- if ( !tmpprop ) {
- #ifdef ICAL_DEBUG
- printf( "oeICalImpl::Test() failed: SUMMARY not found!\n" );
- #endif
- return NS_ERROR_FAILURE;
- }
-#ifdef ICAL_DEBUG
- printf("Title: %s\n", icalproperty_get_summary( tmpprop ) );
-#endif
- //
- tmpprop = icalcomponent_get_first_property( fetchedevent, ICAL_CATEGORIES_PROPERTY );
- if ( !tmpprop ) {
- #ifdef ICAL_DEBUG
- printf( "oeICalImpl::Test() failed: CATEGORIES not found!\n" );
- #endif
- return NS_ERROR_FAILURE;
- }
-#ifdef ICAL_DEBUG
- printf("Category: %s\n", icalproperty_get_categories( tmpprop ) );
-#endif
- //
- tmpprop = icalcomponent_get_first_property( fetchedevent, ICAL_DESCRIPTION_PROPERTY );
- if ( !tmpprop ) {
- #ifdef ICAL_DEBUG
- printf( "oeICalImpl::Test() failed: DESCRIPTION not found!\n" );
- #endif
- return NS_ERROR_FAILURE;
- }
-#ifdef ICAL_DEBUG
- printf("Description: %s\n", icalproperty_get_description( tmpprop ) );
-#endif
- //
- tmpprop = icalcomponent_get_first_property( fetchedevent, ICAL_LOCATION_PROPERTY );
- if ( !tmpprop ) {
- #ifdef ICAL_DEBUG
- printf( "oeICalImpl::Test() failed: LOCATION not found!\n" );
- #endif
- return NS_ERROR_FAILURE;
- }
-#ifdef ICAL_DEBUG
- printf("Location: %s\n", icalproperty_get_location( tmpprop ) );
-#endif
- //
- tmpprop = icalcomponent_get_first_property( fetchedevent, ICAL_CLASS_PROPERTY );
- if ( !tmpprop ) {
- #ifdef ICAL_DEBUG
- printf( "oeICalImpl::Test() failed: CLASS not found!\n" );
- #endif
- return NS_ERROR_FAILURE;
- }
-#ifdef ICAL_DEBUG
- printf("Class: %s\n", (icalproperty_get_class( tmpprop ) == ICAL_CLASS_PUBLIC) ? "PUBLIC" : "PRIVATE" );
-#endif
- //
- tmpprop = icalcomponent_get_first_property( fetchedevent, ICAL_DTSTART_PROPERTY );
- if ( !tmpprop ) {
- #ifdef ICAL_DEBUG
- printf( "oeICalImpl::Test() failed: DTSTART not found!\n" );
- #endif
- return NS_ERROR_FAILURE;
- }
- start = icalproperty_get_dtstart( tmpprop );
-#ifdef ICAL_DEBUG
- printf("Start: %d-%d-%d %d:%d\n", start.year, start.month, start.day, start.hour, start.minute );
-#endif
- //
- tmpprop = icalcomponent_get_first_property( fetchedevent, ICAL_DTEND_PROPERTY );
- if ( !tmpprop ) {
- #ifdef ICAL_DEBUG
- printf( "oeICalImpl::Test() failed: DTEND not found!\n" );
- #endif
- return NS_ERROR_FAILURE;
- }
- end = icalproperty_get_dtstart( tmpprop );
-#ifdef ICAL_DEBUG
- printf("End: %d-%d-%d %d:%d\n", end.year, end.month, end.day, end.hour, end.minute );
-#endif
- //
- for( tmpprop = icalcomponent_get_first_property( fetchedevent, ICAL_X_PROPERTY );
- tmpprop != 0 ;
- tmpprop = icalcomponent_get_next_property( fetchedevent, ICAL_X_PROPERTY ) ) {
-#ifdef ICAL_DEBUG
- icalparameter *tmppar = icalproperty_get_first_parameter( tmpprop, ICAL_MEMBER_PARAMETER );
- printf("%s: %s\n", icalparameter_get_member( tmppar ), icalproperty_get_value_as_string( tmpprop ) );
-#endif
- }
-
- icalcomponent *newcomp = icalcomponent_new_clone( fetchedcal );
- if ( !newcomp ) {
- #ifdef ICAL_DEBUG
- printf( "oeICalImpl::Test() failed: Cannot clone event!\n" );
- #endif
- return NS_ERROR_FAILURE;
- }
-
- icalcomponent *newevent = icalcomponent_get_first_component( newcomp, ICAL_VEVENT_COMPONENT );
- if ( !newevent ) {
- #ifdef ICAL_DEBUG
- printf( "oeICalImpl::Test() failed: VEVENT not found!\n" );
- #endif
- 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_ERROR_FAILURE;
- }
- icalproperty_set_summary( tmpprop, "LUNCH AND LEARN TIME" );
-// icalfileset_modify( stream, fetchedcal, newcomp );
- icalfileset_remove_component( stream, fetchedcal );
- icalfileset_add_component( stream, newcomp );
- icalcomponent_free( fetchedcal );
- //
-
-#ifdef ICAL_DEBUG
- printf("Event updated\n");
- printf( "New Title: %s\n", icalproperty_get_summary( tmpprop ) );
-#endif
-
- fetchedcal = icalfileset_fetch( stream, uidstr );
- if ( !fetchedcal ) {
- #ifdef ICAL_DEBUG
- printf( "oeICalImpl::Test() failed: Cannot fetch event!\n" );
- #endif
- return NS_ERROR_FAILURE;
- }
- icalfileset_remove_component( stream, fetchedcal );
-
-#ifdef ICAL_DEBUG
- printf("Removed Event\n");
-#endif
-
- if( icalfileset_commit(stream) != ICAL_NO_ERROR ) {
- #ifdef ICAL_DEBUG
- printf( "oeICalImpl::Test() : WARNING icalfileset_commit() unsuccessful\n" );
- #endif
- }
- icalfileset_free(stream);
- return NS_OK;
-}
-
-NS_IMETHODIMP
-oeICalImpl::SetServer( const nsACString &aServer ) {
-#ifdef ICAL_DEBUG
- printf( "oeICalImpl::SetServer(%s)\n", PromiseFlatCString(aServer).get() );
-#endif
-
- if( StringBeginsWith(aServer, NS_LITERAL_CSTRING("file:///") ) ) {
- nsCOMPtr url( do_CreateInstance(NS_STANDARDURL_CONTRACTID) );
- nsCString filePath;
- url->SetSpec( aServer );
- url->GetFilePath( filePath );
- m_serveraddr = filePath;
- NS_UnescapeURL( m_serveraddr );
- } else
- m_serveraddr = aServer;
-
- icalset *stream;
-
- //UGLY HACK TO ADD DEPENDANCY TO stat() in libc. ( -lc didn't work )
- int dummy=0;
- if( dummy )
- stat(NULL,NULL);
-
- nsCAutoString nativeServeraddr;
- nsresult rv = NS_CopyUnicodeToNative(NS_ConvertUTF8toUTF16(m_serveraddr),
- nativeServeraddr);
- NS_ENSURE_SUCCESS(rv, rv);
-
- stream = icalfileset_new(nativeServeraddr.get());
- if ( !stream ) {
- #ifdef ICAL_DEBUG
- printf( "oeICalImpl::SetServer() failed: Cannot open stream: %s!\n", m_serveraddr.get() );
- #endif
- return NS_OK;
- }
-
- icalcomponent *vcalendar;
- icalcomponent *vevent,*vtodo;
- oeICalEventImpl *icalevent;
- oeICalTodoImpl *icaltodo;
- for( vcalendar = icalfileset_get_first_component( stream );
- vcalendar != 0;
- vcalendar = icalfileset_get_next_component( stream ) ) {
-
- for( vevent = icalcomponent_get_first_component( vcalendar, ICAL_VEVENT_COMPONENT );
- vevent != 0;
- vevent = icalcomponent_get_next_component( vcalendar, ICAL_VEVENT_COMPONENT ) ) {
-
- if( NS_FAILED( rv = NS_NewICalEvent((oeIICalEvent**) &icalevent ))) {
- return rv;
- }
- if( icalevent->ParseIcalComponent( vevent ) ) {
- m_eventlist.AppendElement( icalevent );
- icalevent->SetParent( this );
- } else {
- icalevent->Release();
- }
- }
- for( vtodo = icalcomponent_get_first_component( vcalendar, ICAL_VTODO_COMPONENT );
- vtodo != 0;
- vtodo = icalcomponent_get_next_component( vcalendar, ICAL_VTODO_COMPONENT ) ) {
-
- if( NS_FAILED( rv = NS_NewICalTodo((oeIICalTodo**) &icaltodo ))) {
- return rv;
- }
- if( icaltodo->ParseIcalComponent( vtodo ) ) {
- m_todolist.Add( icaltodo );
- icaltodo->SetParent( this );
- } else {
- icaltodo->Release();
- }
- }
- }
-
- icalfileset_free(stream);
-
- unsigned int i;
- PRUint32 observercount;
- m_observerlist->Count(&observercount);
- for( i=0; iobserver;
- m_observerlist->QueryElementAt( i, NS_GET_IID(oeIICalObserver), getter_AddRefs(observer));
- nsresult rv;
- rv = observer->OnLoad();
- #ifdef ICAL_DEBUG
- if( NS_FAILED( rv ) ) {
- printf( "oeICalImpl::SetServer() : WARNING Call to observer's onLoad() unsuccessful: %x\n", rv );
- }
- #endif
- }
- m_todoobserverlist->Count(&observercount);
- for( i=0; iobserver;
- m_todoobserverlist->QueryElementAt( i, NS_GET_IID(oeIICalTodoObserver), getter_AddRefs(observer));
- nsresult rv;
- rv = observer->OnLoad();
- #ifdef ICAL_DEBUG
- if( NS_FAILED( rv ) ) {
- printf( "oeICalImpl::SetServer() : WARNING Call to observer's onLoad() unsuccessful: %x\n", rv );
- }
- #endif
- }
-
- SetupAlarmManager();
-
- return NS_OK;
-}
-
-NS_IMETHODIMP
-oeICalImpl::GetServer( nsACString &aServer ) {
-#ifdef ICAL_DEBUG
- printf( "oeICalImpl::GetServer()\n" );
-#endif
- aServer = m_serveraddr;
- return NS_OK;
-}
-
-/* attribute boolean batchMode; */
-NS_IMETHODIMP oeICalImpl::GetBatchMode(PRBool *aBatchMode)
-{
- *aBatchMode = m_batchMode;
-
- return NS_OK;
-}
-
-
-NS_IMETHODIMP oeICalImpl::SetBatchMode(PRBool aBatchMode)
-{
- bool newBatchMode = aBatchMode;
-
- if( m_batchMode != newBatchMode )
- {
- m_batchMode = aBatchMode;
-
- // if batch mode changed to off, call set up alarm mamnager
-
- if( !m_batchMode )
- {
- SetupAlarmManager();
- }
-
- // tell observers about the change
-
-//The container will take care of this for now
-/*
- unsigned int i;
- for( i=0; iOnStartBatch();
- #ifdef ICAL_DEBUG
- if( NS_FAILED( rv ) ) {
- printf( "oeICalImpl::SetBatchMode() : WARNING Call to observer's onStartBatch() unsuccessful: %x\n", rv );
- }
- #endif
- }
- else {
- nsresult rv;
- rv = m_observerlist[i]->OnEndBatch();
- #ifdef ICAL_DEBUG
- if( NS_FAILED( rv ) ) {
- printf( "oeICalImpl::SetBatchMode() : WARNING Call to observer's onEndBatch() unsuccessful: %x\n", rv );
- }
- #endif
- }
-
- }
- for( i=0; iOnStartBatch();
- #ifdef ICAL_DEBUG
- if( NS_FAILED( rv ) ) {
- printf( "oeICalImpl::SetBatchMode() : WARNING Call to observer's onStartBatch() unsuccessful: %x\n", rv );
- }
- #endif
- }
- else {
- nsresult rv;
- rv = m_todoobserverlist[i]->OnEndBatch();
- #ifdef ICAL_DEBUG
- if( NS_FAILED( rv ) ) {
- printf( "oeICalImpl::SetBatchMode() : WARNING Call to observer's onEndBatch() unsuccessful: %x\n", rv );
- }
- #endif
- }
-
- }*/
- }
-
- return NS_OK;
-}
-
-/* attribute boolean suppressAlarms; */
-NS_IMETHODIMP oeICalImpl::GetSuppressAlarms(PRBool *aRetVal)
-{
- *aRetVal = m_suppressAlarms;
-
- return NS_OK;
-}
-
-
-NS_IMETHODIMP oeICalImpl::SetSuppressAlarms(PRBool aNewVal)
-{
- if( m_suppressAlarms ) {
- if( !aNewVal ) {
- m_suppressAlarms = PR_FALSE;
- SetupAlarmManager();
- }
- } else {
- if( aNewVal ) {
- m_suppressAlarms = PR_TRUE;
- CancelAlarmTimer();
- }
- }
- return NS_OK;
-}
-
-/**
-*
-* AddEvent
-*
-* DESCRIPTION: Adds an event
-*
-* PARAMETERS:
-* icalcalendar - The XPCOM component representing an event
-* retid - Place to store the returned id
-*
-* RETURN
-* None
-*/
-NS_IMETHODIMP oeICalImpl::AddEvent(oeIICalEvent *icalevent,char **retid)
-{
-#ifdef ICAL_DEBUG
- printf( "oeICalImpl::AddEvent()\n" );
-#endif
- icalset *stream;
- icalcomponent *vcalendar;
-
- nsCAutoString nativeServeraddr;
- nsresult rv = NS_CopyUnicodeToNative(NS_ConvertUTF8toUTF16(m_serveraddr),
- nativeServeraddr);
- NS_ENSURE_SUCCESS(rv, rv);
-
- stream = icalfileset_new(nativeServeraddr.get());
- if ( !stream ) {
- #ifdef ICAL_DEBUG
- printf( "oeICalImpl::AddEvent() failed: Cannot open stream: %s!\n", serveraddr );
- #endif
- return NS_OK;
- }
-
- ((oeICalEventImpl *)icalevent)->GetId( retid );
-
- if( *retid == nsnull ) {
- char uidstr[40];
- GenerateUUID( uidstr );
- ((oeICalEventImpl *)icalevent)->SetId( uidstr );
- ((oeICalEventImpl *)icalevent)->GetId( retid );
- }
-
- vcalendar = ((oeICalEventImpl *)icalevent)->AsIcalComponent();
- icalfileset_add_first_to_first_component( stream, vcalendar );
-
- if( icalfileset_commit(stream) != ICAL_NO_ERROR ) {
- #ifdef ICAL_DEBUG
- printf( "oeICalImpl::AddEvent() : WARNING icalfileset_commit() unsuccessful\n" );
- #endif
- }
- icalfileset_free( stream );
-
- icalevent->AddRef();
- m_eventlist.AppendElement( icalevent );
- ((oeICalEventImpl *)icalevent)->SetParent( this );
-
- PRUint32 observercount;
- m_observerlist->Count(&observercount);
- for( unsigned int i=0; iobserver;
- m_observerlist->QueryElementAt( i, NS_GET_IID(oeIICalObserver), getter_AddRefs(observer));
- nsresult rv;
- rv = observer->OnAddItem( icalevent );
- #ifdef ICAL_DEBUG
- if( NS_FAILED( rv ) ) {
- printf( "oeICalImpl::AddEvent() : WARNING Call to observer's onAddItem() unsuccessful: %x\n", rv );
- }
- #endif
- }
-
- SetupAlarmManager();
- return NS_OK;
-}
-
-/**
-*
-* ModifyEvent
-*
-* DESCRIPTION: Updates an event
-*
-* PARAMETERS:
-* icalcalendar - The XPCOM component representing an event
-* retid - Place to store the returned id
-*
-* RETURN
-* None
-*/
-NS_IMETHODIMP oeICalImpl::ModifyEvent(oeIICalEvent *icalevent, char **retid)
-{
-#ifdef ICAL_DEBUG
- printf( "oeICalImpl::ModifyEvent()\n" );
-#endif
- icalset *stream;
- icalcomponent *vcalendar;
- nsresult rv;
-
- //This might be a TODO object. If so then call the appropriate function.
- nsCOMPtr icaltodo;
- rv = icalevent->QueryInterface(NS_GET_IID(oeIICalTodo), (void **)&icaltodo);
- if( NS_SUCCEEDED( rv ) ) {
- return ModifyTodo( icaltodo, retid );
- }
-
- nsCAutoString nativeServeraddr;
- rv = NS_CopyUnicodeToNative(NS_ConvertUTF8toUTF16(m_serveraddr),
- nativeServeraddr);
- NS_ENSURE_SUCCESS(rv, rv);
-
- stream = icalfileset_new(nativeServeraddr.get());
- if ( !stream ) {
- #ifdef ICAL_DEBUG
- printf( "oeICalImpl::ModifyEvent() failed: Cannot open stream: %s!\n", serveraddr );
- #endif
- return NS_OK;
- }
-
- icalevent->GetId( retid );
- if( *retid == nsnull ) {
- #ifdef ICAL_DEBUG
- printf( "oeICalImpl::ModifyEvent() - Invalid Id.\n" );
- #endif
- icalfileset_free(stream);
- return NS_OK;
- }
-
- icalcomponent *fetchedvcal = icalfileset_fetch( stream, *retid );
-
- oeICalEventImpl *oldevent=nsnull;
- if( fetchedvcal ) {
- icalcomponent *fetchedvevent = icalcomponent_fetch( fetchedvcal, *retid );
- if( fetchedvevent ) {
- icalcomponent_remove_component( fetchedvcal, fetchedvevent );
- if ( !icalcomponent_get_first_real_component( fetchedvcal ) ) {
- icalfileset_remove_component( stream, fetchedvcal );
- icalcomponent_free( fetchedvcal );
- }
- if( NS_FAILED( rv = NS_NewICalEvent((oeIICalEvent**) &oldevent ))) {
- nsMemory::Free( *retid );
- *retid = nsnull;
- icalfileset_free(stream);
- return rv;
- }
- oldevent->ParseIcalComponent( fetchedvevent );
- icalcomponent_free( fetchedvevent );
- } else {
- #ifdef ICAL_DEBUG
- printf( "oeICalImpl::ModifyEvent() - WARNING Event not found.\n" );
- #endif
- nsMemory::Free( *retid );
- *retid = nsnull;
- icalfileset_free(stream);
- return NS_OK;
- }
- } else {
- #ifdef ICAL_DEBUG
- printf( "oeICalImpl::ModifyEvent() - WARNING Event not found.\n" );
- #endif
- nsMemory::Free( *retid );
- *retid = nsnull;
- icalfileset_free(stream);
- return NS_OK;
- }
-
- //Update Last-Modified
- icalevent->UpdateLastModified();
-
- vcalendar = ((oeICalEventImpl *)icalevent)->AsIcalComponent();
- icalfileset_add_first_to_first_component( stream, vcalendar );
-
- if( icalfileset_commit(stream) != ICAL_NO_ERROR ) {
- #ifdef ICAL_DEBUG
- printf( "oeICalImpl::ModifyEvent() : WARNING icalfileset_commit() unsuccessful\n" );
- #endif
- }
- icalfileset_free(stream);
-
- PRUint32 observercount;
- m_observerlist->Count(&observercount);
- for( unsigned int i=0; iobserver;
- m_observerlist->QueryElementAt( i, NS_GET_IID(oeIICalObserver), getter_AddRefs(observer));
- rv = observer->OnModifyItem( icalevent, oldevent );
- #ifdef ICAL_DEBUG
- if( NS_FAILED( rv ) ) {
- printf( "oeICalImpl::ModifyEvent() : WARNING Call to observer's onModifyItem() unsuccessful: %x\n", rv );
- }
- #endif
- }
-
- oldevent->Release();
-
- SetupAlarmManager();
- return NS_OK;
-}
-
-
-/**
-*
-* FetchEvent
-*
-* DESCRIPTION: Fetches an event
-*
-* PARAMETERS:
-* ev - Place to store the XPCOM representation of the fetched event
-* id - Id of the event to fetch
-*
-* RETURN
-* None
-*/
-NS_IMETHODIMP oeICalImpl::FetchEvent( const char *id, oeIICalEvent **ev)
-{
-#ifdef ICAL_DEBUG_ALL
- printf( "oeICalImpl::FetchEvent()\n" );
-#endif
-
- if( id == nsnull ) {
- #ifdef ICAL_DEBUG
- printf( "oeICalImpl::FetchEvent() - Invalid Id.\n" );
- #endif
- *ev = nsnull;
- return NS_OK;
- }
-
- *ev = nsnull; //initialize to null
-
- oeIICalEvent *event;
- for (PRInt32 i = 0 ; i < m_eventlist.Count(); ++i) {
- event = NS_STATIC_CAST(oeIICalEvent*, m_eventlist[i]);
- // XXX Evil cast
- if (event && ((oeICalEventImpl *)event)->matchId(id)) {
- *ev = event;
- NS_ADDREF(*ev);
- break;
- }
- }
- return NS_OK;
-}
-
-/**
-*
-* DeleteEvent
-*
-* DESCRIPTION: Deletes an event
-*
-* PARAMETERS:
-* id - Id of the event to delete
-*
-* RETURN
-* None
-*/
-NS_IMETHODIMP
-oeICalImpl::DeleteEvent( const char *id )
-{
-#ifdef ICAL_DEBUG
- printf( "oeICalImpl::DeleteEvent( %s )\n", id );
-#endif
- icalset *stream;
-
- nsCAutoString nativeServeraddr;
- nsresult rv = NS_CopyUnicodeToNative(NS_ConvertUTF8toUTF16(m_serveraddr),
- nativeServeraddr);
- NS_ENSURE_SUCCESS(rv, rv);
-
- stream = icalfileset_new(nativeServeraddr.get());
- if ( !stream ) {
- #ifdef ICAL_DEBUG
- printf( "oeICalImpl::DeleteEvent() failed: Cannot open stream: %s!\n", serveraddr );
- #endif
- return NS_OK;
- }
-
- if( id == nsnull ) {
- #ifdef ICAL_DEBUG
- printf( "oeICalImpl::DeleteEvent() - Invalid Id.\n" );
- #endif
- icalfileset_free(stream);
- return NS_OK;
- }
-
- icalcomponent *fetchedvcal = icalfileset_fetch( stream, id );
-
- if( !fetchedvcal ) {
- icalfileset_free(stream);
- #ifdef ICAL_DEBUG
- printf( "oeICalImpl::DeleteEvent() - WARNING Event not found.\n" );
- #endif
- return NS_OK;
- }
-
- icalcomponent *fetchedvevent = icalcomponent_fetch( fetchedvcal, id );
-
- if( !fetchedvevent ) {
- icalfileset_free(stream);
- #ifdef ICAL_DEBUG
- printf( "oeICalImpl::DeleteEvent() - WARNING Event not found.\n" );
- #endif
- return NS_OK;
- }
-
- icalcomponent_remove_component( fetchedvcal, fetchedvevent );
- icalcomponent_free( fetchedvevent );
- if ( !icalcomponent_get_first_real_component( fetchedvcal ) ) {
- icalfileset_remove_component( stream, fetchedvcal );
- icalcomponent_free( fetchedvcal );
- }
-
- icalfileset_mark( stream ); //Make sure stream is marked as dirty
- if( icalfileset_commit(stream) != ICAL_NO_ERROR ) {
- #ifdef ICAL_DEBUG
- printf( "oeICalImpl::DeleteEvent() : WARNING icalfileset_commit() unsuccessful\n" );
- #endif
- }
- icalfileset_free(stream);
-
- oeIICalEvent *icalevent;
- FetchEvent( id , &icalevent );
-
- m_eventlist.RemoveElement(icalevent);
-
- PRUint32 observercount;
- m_observerlist->Count(&observercount);
- for( unsigned int i=0; iobserver;
- m_observerlist->QueryElementAt( i, NS_GET_IID(oeIICalObserver), getter_AddRefs(observer));
- nsresult rv;
- rv = observer->OnDeleteItem( icalevent );
- #ifdef ICAL_DEBUG
- if( NS_FAILED( rv ) ) {
- printf( "oeICalImpl::DeleteEvent() : WARNING Call to observer's onDeleteItem() unsuccessful: %x\n", rv );
- }
- #endif
- }
-
- icalevent->Release();
-
- SetupAlarmManager();
- return NS_OK;
-}
-
-/**
- * recurCompareFunc
- *
- * helper for GetAllEvents, compares two events by either the next recurrance,
- * or the previous if no next
- */
-int
-recurCompareFunc(const void* aElement1, const void* aElement2, void* aData)
-{
- oeICalEventImpl* event1 = (oeICalEventImpl *)aElement1;
- oeICalEventImpl* event2 = (oeICalEventImpl *)aElement2;
- icaltimetype* now = (icaltimetype *)aData;
-
- icaltimetype time1 = event1->GetNextRecurrence(*now, nsnull);
- if (icaltime_is_null_time(time1)) {
- time1 = event1->GetPreviousOccurrence(*now);
- }
-
- icaltimetype time2 = event2->GetNextRecurrence(*now, nsnull);
- if (icaltime_is_null_time(time2)) {
- time2 = event2->GetPreviousOccurrence(*now);
- }
- return icaltime_compare(time1, time2);
-}
-
-/**
-*
-* GetAllEvents
-*
-* DESCRIPTION: Returns a list of all the events in this calendar in an enumerator.
-* The events are sorted based on the order of their next occurence if they recur in
-* the future or their last occurence in the past otherwise.
-* Here's a presentation of the sort criteria using the time axis:
-* -----(Last occurence of Event1)---(Last occurence of Event2)----(Now)----(Next occurence of Event3)---->
-* (Note that Event1 and Event2 will not recur in the future.)
-*/
-NS_IMETHODIMP
-oeICalImpl::GetAllEvents(nsISimpleEnumerator **resultList )
-{
-#ifdef ICAL_DEBUG
- printf( "oeICalImpl::GetAllEvents()\n" );
-#endif
-
- //Create a new enumerator to be returned
- oeEventEnumerator *eventEnum = new oeEventEnumerator();
- if (!eventEnum)
- return NS_ERROR_OUT_OF_MEMORY;
-
- nsVoidArray eventlist;
- eventlist = m_eventlist;
-
- //Calculate the present time in milliseconds
- PRTime nowinms = PR_Now();
- PRInt64 usecpermsec;
- LL_I2L( usecpermsec, PR_USEC_PER_MSEC );
- LL_DIV( nowinms, nowinms, usecpermsec );
-
- struct icaltimetype now = ConvertFromPrtime( nowinms );
- struct icaltimetype checkdate = now;
- //use Now-1 so we ensure we consider Now in the calculation
- icaltime_adjust( &now, 0, 0, 0, -1 );
-
- // Sort the eventlist
- eventlist.Sort(recurCompareFunc, &now);
-
- PRUint32 num2;
- num2 = eventlist.Count();
- for (PRUint32 j = 0; j < num2; ++j) {
- eventEnum->AddEvent((oeICalEventImpl *)(eventlist[j]));
- }
-
- *resultList = eventEnum;
- // bump ref count
- NS_ADDREF(*resultList);
- return NS_OK;
-}
-
-NS_IMETHODIMP
-oeICalImpl::GetEventsForMonth( PRTime datems, nsISimpleEnumerator **eventlist ) {
-#ifdef ICAL_DEBUG
- printf( "oeICalImpl::GetEventsForMonth()\n" );
-#endif
- struct icaltimetype checkdate = ConvertFromPrtime( datems );
- checkdate.day = 1;
- checkdate.hour = 0;
- checkdate.minute = 0;
- checkdate.second = 0;
- icaltime_adjust( &checkdate, 0, 0 , 0, -1 );
-#ifdef ICAL_DEBUG_ALL
- printf( "CHECKDATE: %s\n" , icaltime_as_ctime( checkdate ) );
-#endif
- PRTime checkdateinms = ConvertToPrtime( checkdate );
-
- struct icaltimetype checkenddate = ConvertFromPrtime( datems );
- checkenddate.month++;
- checkenddate.day = 1;
- checkenddate.hour = 0;
- checkenddate.minute = 0;
- checkenddate.second = 0;
- checkenddate = icaltime_normalize( checkenddate );
-#ifdef ICAL_DEBUG_ALL
- printf( "CHECKENDDATE: %s\n" , icaltime_as_ctime( checkenddate ) );
-#endif
- PRTime checkenddateinms = ConvertToPrtime( checkenddate );
-
- return GetEventsForRange(checkdateinms ,checkenddateinms, eventlist );
-}
-
-NS_IMETHODIMP
-oeICalImpl::GetEventsForWeek( PRTime datems, nsISimpleEnumerator **eventlist ) {
-#ifdef ICAL_DEBUG
- printf( "oeICalImpl::GetEventsForWeek()\n" );
-#endif
-
- struct icaltimetype checkdate = ConvertFromPrtime( datems );
- checkdate.hour = 0;
- checkdate.minute = 0;
- checkdate.second = 0;
- icaltime_adjust( &checkdate, 0, 0 , 0, -1 );
- PRTime checkdateinms = ConvertToPrtime( checkdate );
-
- struct icaltimetype checkenddate = ConvertFromPrtime( datems );
- checkenddate.hour = 0;
- checkenddate.minute = 0;
- checkenddate.second = 0;
- icaltime_adjust( &checkenddate, 7, 0 , 0, 0 );
- PRTime checkenddateinms = ConvertToPrtime( checkenddate );
-
- return GetEventsForRange(checkdateinms ,checkenddateinms, eventlist );
-}
-
-NS_IMETHODIMP
-oeICalImpl::GetEventsForDay( PRTime datems, nsISimpleEnumerator **eventlist ) {
-#ifdef ICAL_DEBUG
- printf( "oeICalImpl::GetEventsForDay()\n" );
-#endif
-
- struct icaltimetype checkdate = ConvertFromPrtime( datems );
- checkdate.hour = 0;
- checkdate.minute = 0;
- checkdate.second = 0;
- icaltime_adjust( &checkdate, 0, 0, 0, -1 );
- PRTime checkdateinms = ConvertToPrtime( checkdate );
-
- struct icaltimetype checkenddate = ConvertFromPrtime( datems );
- checkenddate.hour = 0;
- checkenddate.minute = 0;
- checkenddate.second = 0;
- icaltime_adjust( &checkenddate, 1, 0, 0, 0 );
- PRTime checkenddateinms = ConvertToPrtime( checkenddate );
-
- return GetEventsForRange(checkdateinms ,checkenddateinms, eventlist );
-}
-
-
-class eventOccurence {
-public:
- PRTime start;
- nsCOMPtr event;
- bool isbeginning;
- bool isallday;
-};
-
-int
-occurCompareFunc(const void* aElement1, const void* aElement2, void* aData)
-{
- eventOccurence* occur1 = (eventOccurence *)aElement1;
- eventOccurence* occur2 = (eventOccurence *)aElement2;
-
- return (occur1->start - occur2->start);
-}
-
-
-NS_IMETHODIMP
-oeICalImpl::GetEventsForRange(PRTime aBeginDate, PRTime aEndDate, nsISimpleEnumerator **aResult)
-{
-#ifdef ICAL_DEBUG_ALL
- printf( "oeICalImpl::GetEventsForRange()\n" );
-#endif
-
- oeEventEnumerator *eventEnum = new oeEventEnumerator();
- if (!eventEnum)
- return NS_ERROR_OUT_OF_MEMORY;
- *aResult = eventEnum;
- NS_ADDREF(*aResult);
-
- struct icaltimetype checkdate = ConvertFromPrtime(aBeginDate);
- icaltime_adjust(&checkdate, 0, 0, 0, -1);
- struct icaltimetype checkenddate = ConvertFromPrtime(aEndDate);
-
- nsVoidArray occurList;
- oeIICalEvent *tmpevent;
- PRInt32 i;
- for (i = 0 ; i < m_eventlist.Count(); ++i) {
- tmpevent = NS_STATIC_CAST(oeIICalEvent*, m_eventlist[i]);
- struct icaltimetype check = checkdate;
- bool isbeginning;
- check = ((oeICalEventImpl *)tmpevent)->GetNextRecurrence(check, &isbeginning);
- while (!icaltime_is_null_time(check) && (icaltime_compare(check, checkenddate) < 0)) {
- eventOccurence *occur = new eventOccurence();
- if (!occur) {
- // I whish i knew a better way to do this cleanup stuff..
- for (PRInt32 j = 0 ; j < occurList.Count(); ++j) {
- eventOccurence *occur = NS_STATIC_CAST(eventOccurence*, occurList[j]);
- delete occur;
- }
- return NS_ERROR_OUT_OF_MEMORY;
- }
- occur->start = ConvertToPrtime(check);
- occur->event = tmpevent;
- occur->isbeginning = isbeginning;
- occur->isallday = check.is_date;
- occurList.AppendElement(occur);
- check = ((oeICalEventImpl *)tmpevent)->GetNextRecurrence(check, &isbeginning);
- }
- }
- occurList.Sort(occurCompareFunc, nsnull);
-
- for (i = 0 ; i < occurList.Count(); ++i) {
- eventOccurence *occur = NS_STATIC_CAST(eventOccurence*, occurList[i]);
- tmpevent = NS_STATIC_CAST(oeIICalEvent*, occur->event);
- ((oeICalEventImpl *)tmpevent)->
- ChopAndAddEventToEnum(ConvertFromPrtime(occur->start), aResult,
- occur->isallday, occur->isbeginning );
- delete occur;
- }
-
- return NS_OK;
-}
-
-NS_IMETHODIMP
-oeICalImpl::GetFirstEventsForRange(PRTime aBeginDate, PRTime aEndDate, nsISimpleEnumerator **aResult)
-{
-#ifdef ICAL_DEBUG
- printf( "oeICalImpl::GetFirstEventsForRange()\n" );
-#endif
- oeEventEnumerator *eventEnum = new oeEventEnumerator();
- if (!eventEnum)
- return NS_ERROR_OUT_OF_MEMORY;
- *aResult = eventEnum;
- NS_ADDREF(*aResult);
-
- nsCOMPtr eventArray;
- NS_NewISupportsArray(getter_AddRefs(eventArray));
- if (eventArray == nsnull)
- return NS_ERROR_OUT_OF_MEMORY;
-
- oeIICalEvent *event;
- PRInt32 i;
- for (i = 0 ; i < m_eventlist.Count(); ++i) {
- event = NS_STATIC_CAST(oeIICalEvent*, m_eventlist[i]);
- eventArray->AppendElement(event);
- }
-
- struct icaltimetype checkdate = ConvertFromPrtime(aBeginDate);
- icaltime_adjust(&checkdate, 0, 0, 0, -1);
-
- struct icaltimetype checkenddate = ConvertFromPrtime(aEndDate);
-
- nsVoidArray occurList;
- oeIICalEvent *tmpevent;
- for (i = 0 ; i < m_eventlist.Count(); ++i) {
- tmpevent = NS_STATIC_CAST(oeIICalEvent*, m_eventlist[i]);
- struct icaltimetype check = checkdate;
- bool isbeginning;
- check = ((oeICalEventImpl *)tmpevent)->GetNextRecurrence(check, &isbeginning);
- if (!icaltime_is_null_time(check) && (icaltime_compare(check, checkenddate) < 0)) {
- eventOccurence *occur = new eventOccurence();
- if (!occur) {
- // I whish i knew a better way to do this cleanup stuff..
- for (PRInt32 j = 0 ; i < occurList.Count(); ++j) {
- eventOccurence *occur = NS_STATIC_CAST(eventOccurence*, occurList[j]);
- delete occur;
- }
- return NS_ERROR_OUT_OF_MEMORY;
- }
- occur->start = ConvertToPrtime(check);
- occur->event = tmpevent;
- occur->isbeginning = isbeginning;
- occur->isallday = check.is_date;
- occurList.AppendElement(occur);
- check = ((oeICalEventImpl *)tmpevent)->GetNextRecurrence(check, &isbeginning);
- }
- }
- occurList.Sort(occurCompareFunc, nsnull);
-
- for (i = 0 ; i < occurList.Count(); ++i) {
- eventOccurence *occur = NS_STATIC_CAST(eventOccurence*, occurList[i]);
- tmpevent = NS_STATIC_CAST(oeIICalEvent*, occur->event);
- ((oeICalEventImpl *)tmpevent)->
- ChopAndAddEventToEnum(ConvertFromPrtime(occur->start), aResult,
- occur->isallday, occur->isbeginning );
- delete occur;
- }
-
- return NS_OK;
-}
-
-icaltimetype oeICalImpl::GetNextEvent( icaltimetype starting ) {
-#ifdef ICAL_DEBUG_ALL
- printf( "oeICalImpl::GetNextEvent()\n" );
-#endif
- icaltimetype soonest = icaltime_null_time();
-
- oeIICalEvent *tmpevent;
- for (PRInt32 i = 0 ; i < m_eventlist.Count(); ++i) {
- tmpevent = NS_STATIC_CAST(oeIICalEvent*, m_eventlist[i]);
- icaltimetype next = ((oeICalEventImpl *)tmpevent)->GetNextRecurrence( starting, nsnull );
- next.is_date = false;
- if( !icaltime_is_null_time( next ) && ( icaltime_is_null_time( soonest ) || (icaltime_compare( soonest, next ) > 0) ) ) {
- soonest = next;
- }
- }
- return soonest;
-}
-
-NS_IMETHODIMP
-oeICalImpl::GetNextNEvents( PRTime datems, PRInt32 maxcount, nsISimpleEnumerator **eventlist ) {
-#ifdef ICAL_DEBUG
- printf( "oeICalImpl::GetNextNEvents( %d )\n", maxcount );
-#endif
-
- oeEventEnumerator *eventEnum = new oeEventEnumerator();
- if (!eventEnum)
- return NS_ERROR_OUT_OF_MEMORY;
- *eventlist = eventEnum;
- NS_ADDREF(*eventlist);
-
- struct icaltimetype checkdate = ConvertFromPrtime( datems );
- icaltime_adjust( &checkdate, 0, 0, 0, -1 );
-
- int count = 0;
- icaltimetype nextcheckdate;
- do {
- nextcheckdate = GetNextEvent( checkdate );
- if( !icaltime_is_null_time( nextcheckdate )) {
- oeIICalEvent *tmpevent;
- for (PRInt32 i = 0 ; (count < maxcount) && (i < m_eventlist.Count()); ++i) {
- bool isbeginning,isallday;
- tmpevent = NS_STATIC_CAST(oeIICalEvent*, m_eventlist[i]);
- icaltimetype next = ((oeICalEventImpl *)tmpevent)->GetNextRecurrence( checkdate, &isbeginning );
- isallday = next.is_date;
- next.is_date = false;
- if( !icaltime_is_null_time( next ) && (icaltime_compare( nextcheckdate, next ) == 0) ) {
- ((oeICalEventImpl *)tmpevent)->ChopAndAddEventToEnum( nextcheckdate, eventlist, isallday, isbeginning );
- count++;
- }
- }
- checkdate = nextcheckdate;
- }
- } while ( !icaltime_is_null_time( nextcheckdate ) && (count < maxcount) );
-
- return NS_OK;
-}
-
-#ifdef ICAL_DEBUG_ALL
-int gObservercount=0;
-#endif
-
-NS_IMETHODIMP
-oeICalImpl::AddObserver(oeIICalObserver *observer)
-{
-#ifdef ICAL_DEBUG_ALL
- gObservercount++;
- printf( "oeICalImpl::AddObserver(): %d\n", gObservercount );
-#endif
- if( observer ) {
- observer->AddRef();
- PRUint32 observercount;
- m_observerlist->Count( &observercount );
- m_observerlist->InsertElementAt( observer, observercount );
-// observer->OnLoad();
- }
- return NS_OK;
-}
-
-NS_IMETHODIMP
-oeICalImpl::RemoveObserver(oeIICalObserver *observer)
-{
-#ifdef ICAL_DEBUG_ALL
- gObservercount--;
- printf( "oeICalImpl::RemoveObserver(): %d\n", gObservercount );
-#endif
- if( observer ) {
- PRUint32 observercount;
- m_observerlist->Count( &observercount );
- for( unsigned int i=0; itmpobserver;
- m_observerlist->QueryElementAt( i, NS_GET_IID(oeIICalObserver), getter_AddRefs(tmpobserver));
- if( observer == tmpobserver ) {
- m_observerlist->RemoveElementAt( i );
- observer->Release();
- break;
- }
- }
- }
- return NS_OK;
-}
-
-NS_IMETHODIMP
-oeICalImpl::AddTodoObserver(oeIICalTodoObserver *observer)
-{
-#ifdef ICAL_DEBUG_ALL
- printf( "oeICalImpl::AddTodoObserver()\n" );
-#endif
- if( observer ) {
- observer->AddRef();
- PRUint32 observercount;
- m_todoobserverlist->Count( &observercount );
- m_todoobserverlist->InsertElementAt( observer, observercount );
-// observer->OnLoad();
- }
- return NS_OK;
-}
-
-NS_IMETHODIMP
-oeICalImpl::RemoveTodoObserver(oeIICalTodoObserver *observer)
-{
-#ifdef ICAL_DEBUG_ALL
- printf( "oeICalImpl::RemoveTodoObserver()\n" );
-#endif
- if( observer ) {
- PRUint32 observercount;
- m_todoobserverlist->Count( &observercount );
- for( unsigned int i=0; itmpobserver;
- m_todoobserverlist->QueryElementAt( i, NS_GET_IID(oeIICalTodoObserver), getter_AddRefs(tmpobserver));
- if( observer == tmpobserver ) {
- m_todoobserverlist->RemoveElementAt( i );
- observer->Release();
- break;
- }
- }
- }
- return NS_OK;
-}
-
-void AlarmTimerCallback(nsITimer *aTimer, void *aClosure)
-{
-#ifdef ICAL_DEBUG
- printf( "AlarmTimerCallback\n" );
-#endif
- oeICalImpl *icallib = (oeICalImpl *)aClosure;
- icallib->SetupAlarmManager();
-}
-
-NS_IMETHODIMP UpdateCalendarIcon( PRBool hasAlarm )
-{
- nsresult rv;
- nsCOMPtr windowMediator =
- do_GetService(NS_WINDOWMEDIATOR_CONTRACTID, &rv);
- NS_ENSURE_SUCCESS(rv,rv);
- static PRBool lastTimeHadAlarm = false;
-
- if( lastTimeHadAlarm == hasAlarm )
- return NS_OK;
-
- lastTimeHadAlarm = hasAlarm;
- nsCOMPtr windowEnumerator;
-
- // why use DOM window enumerator instead of XUL window...????
- if (NS_SUCCEEDED(windowMediator->GetEnumerator(nsnull, getter_AddRefs(windowEnumerator))))
- {
- PRBool more;
-
- windowEnumerator->HasMoreElements(&more);
-
- while(more)
- {
- nsCOMPtr nextWindow = nsnull;
- windowEnumerator->GetNext(getter_AddRefs(nextWindow));
- nsCOMPtr domWindow(do_QueryInterface(nextWindow));
-
- if( domWindow ) {
- nsCOMPtr domDocument;
- domWindow->GetDocument(getter_AddRefs(domDocument));
-
- if(domDocument)
- {
- nsCOMPtr domElement;
- domDocument->GetElementById(NS_LITERAL_STRING("mini-cal"), getter_AddRefs(domElement));
-
- if (domElement) {
- if ( hasAlarm ) {
- domElement->SetAttribute(NS_LITERAL_STRING("BiffState"), NS_LITERAL_STRING("Alarm"));
- }
- else {
- domElement->RemoveAttribute(NS_LITERAL_STRING("BiffState"));
- }
- }
- }
- }
-
- windowEnumerator->HasMoreElements(&more);
- }
- }
- return NS_OK;
-}
-
-void oeICalImpl::SetupAlarmManager() {
-#ifdef ICAL_DEBUG
- printf( "oeICalImpl::SetupAlarmManager()\n" );
-#endif
- if( m_suppressAlarms )
- return;
- if( m_batchMode )
- {
- #ifdef ICAL_DEBUG
- printf( "oeICalImpl::SetupAlarmManager() - defering alarms while in batch mode\n" );
- #endif
-
- return;
- }
-
- static icaltimetype lastcheck = icaltime_null_time();
-
- UpdateCalendarIcon( false );
-
- PRTime todayinms = PR_Now();
- PRInt64 usecpermsec;
- LL_I2L( usecpermsec, PR_USEC_PER_MSEC );
- LL_DIV( todayinms, todayinms, usecpermsec );
-
- icaltimetype now = ConvertFromPrtime( todayinms );
-
- icaltimetype nextalarm = icaltime_null_time();
-
- int processmissed = -1; // -1 means the value has not been read from the preferences. 0 or 1 are valid values.
-
- oeICalEventImpl *event;
- for (PRInt32 i = 0 ; i < m_eventlist.Count(); ++i) {
- event = NS_STATIC_CAST(oeICalEventImpl*, m_eventlist[i]);
- icaltimetype begin=icaltime_null_time();
- begin.year = 1970; begin.month=1; begin.day=1;
- icaltimetype alarmtime = begin;
- do {
- alarmtime = event->GetNextAlarmTime( alarmtime );
- if( icaltime_is_null_time( alarmtime ) )
- break;
- if( icaltime_compare( alarmtime, now ) <= 0 ) {
- #ifdef ICAL_DEBUG
- printf( "ALARM WENT OFF: %s\n", icaltime_as_ical_string( alarmtime ) );
- #endif
-
- nsresult rv;
- if( processmissed == -1 ) {
- nsCOMPtr prefBranch = do_GetService(NS_PREFSERVICE_CONTRACTID, &rv);
- if ( NS_SUCCEEDED(rv) && prefBranch ) {
- rv = prefBranch->GetBoolPref("calendar.alarms.showmissed", &processmissed);
- } else {
- processmissed = true; //if anything goes wrong just consider the default setting
- }
- }
-
- if( !processmissed ) {
- time_t timediff = icaltime_as_timet( now ) - icaltime_as_timet( alarmtime );
- if( timediff > 30 ) //if alarmtime is older than 30 seconds it won't be processed.
- continue;
- }
-
- UpdateCalendarIcon( true );
-
- oeIICalEventDisplay* eventDisplay;
- rv = NS_NewICalEventDisplay( event, &eventDisplay );
- #ifdef ICAL_DEBUG
- if( NS_FAILED( rv ) ) {
- printf( "oeICalImpl::SetupAlarmManager() : WARNING Cannot create oeIICalEventDisplay instance: %x\n", rv );
- }
- #endif
- icaltimetype eventtime = event->CalculateEventTime( alarmtime );
- eventDisplay->SetDisplayDate( ConvertToPrtime( eventtime ) );
- PRUint32 observercount;
- m_observerlist->Count( &observercount );
- for( unsigned int i=0; iobserver;
- m_observerlist->QueryElementAt( i, NS_GET_IID(oeIICalObserver), getter_AddRefs(observer));
- rv = observer->OnAlarm( eventDisplay );
- #ifdef ICAL_DEBUG
- if( NS_FAILED( rv ) ) {
- printf( "oeICalImpl::SetupAlarmManager() : WARNING Call to observer's onAlarm() unsuccessful: %x\n", rv );
- }
- #endif
- }
- NS_RELEASE( eventDisplay );
- }
- else {
- if( icaltime_is_null_time( nextalarm ) )
- nextalarm = alarmtime;
- else if( icaltime_compare( nextalarm, alarmtime ) > 0 )
- nextalarm = alarmtime;
- break;
- }
- } while ( 1 );
- }
-
- TodoList *tmptodolistptr = &m_todolist;
- while( tmptodolistptr ) {
- oeIICalTodo *todo = tmptodolistptr->todo;
- if( todo ) {
- oeICalEventImpl *event = ((oeICalTodoImpl *)todo)->GetBaseEvent();
- icaltimetype begin=icaltime_null_time();
- begin.year = 1970; begin.month=1; begin.day=1;
- icaltimetype alarmtime = begin;
- do {
- alarmtime = event->GetNextAlarmTime( alarmtime );
- if( icaltime_is_null_time( alarmtime ) )
- break;
- if( icaltime_compare( alarmtime, now ) <= 0 ) {
- #ifdef ICAL_DEBUG
- printf( "ALARM WENT OFF: %s\n", icaltime_as_ical_string( alarmtime ) );
- #endif
-
- nsresult rv;
- if( processmissed == -1 ) {
- nsCOMPtr prefBranch = do_GetService(NS_PREFSERVICE_CONTRACTID, &rv);
- if ( NS_SUCCEEDED(rv) && prefBranch ) {
- rv = prefBranch->GetBoolPref("calendar.alarms.showmissed", &processmissed);
- } else {
- processmissed = true; //if anything goes wrong just consider the default setting
- }
- }
-
- if( !processmissed ) {
- time_t timediff = icaltime_as_timet( now ) - icaltime_as_timet( alarmtime );
- if( timediff > 30 ) //if alarmtime is older than 30 seconds it won't be processed.
- continue;
- }
-
- UpdateCalendarIcon( true );
-
- oeIICalEventDisplay* eventDisplay;
- rv = NS_NewICalEventDisplay( todo, &eventDisplay );
- #ifdef ICAL_DEBUG
- if( NS_FAILED( rv ) ) {
- printf( "oeICalImpl::SetupAlarmManager() : WARNING Cannot create oeIICalEventDisplay instance: %x\n", rv );
- }
- #endif
- icaltimetype eventtime = event->CalculateEventTime( alarmtime );
- eventDisplay->SetDisplayDate( ConvertToPrtime( eventtime ) );
- PRUint32 observercount;
- //Here we should be using the todo observer list but nothing implements
- //alarm handling for todos yet so we'll just use the one for events
- m_observerlist->Count( &observercount );
- for( unsigned int i=0; iobserver;
- m_observerlist->QueryElementAt( i, NS_GET_IID(oeIICalObserver), getter_AddRefs(observer));
- rv = observer->OnAlarm( eventDisplay );
- #ifdef ICAL_DEBUG
- if( NS_FAILED( rv ) ) {
- printf( "oeICalImpl::SetupAlarmManager() : WARNING Call to observer's onAlarm() unsuccessful: %x\n", rv );
- }
- #endif
- }
- NS_RELEASE( eventDisplay );
- }
- else {
- if( icaltime_is_null_time( nextalarm ) )
- nextalarm = alarmtime;
- else if( icaltime_compare( nextalarm, alarmtime ) > 0 )
- nextalarm = alarmtime;
- break;
- }
- } while ( 1 );
- }
- tmptodolistptr = tmptodolistptr->next;
- }
-
-
- lastcheck = now;
-
- CancelAlarmTimer(); //cancel the current alarm timer if any
-
- if( !icaltime_is_null_time( nextalarm ) ) {
- #ifdef ICAL_DEBUG
- printf( "NEXT ALARM IS: %s\n", icaltime_as_ical_string( nextalarm ) );
- #endif
- time_t timediff = icaltime_as_timet( nextalarm ) - icaltime_as_timet( now );
-
- nsresult rv;
- nsCOMPtr alarmtimer = do_CreateInstance("@mozilla.org/timer;1", &rv);
- alarmtimer->QueryInterface(NS_GET_IID(nsITimer), (void **)&m_alarmtimer);
- if( NS_FAILED( rv ) )
- m_alarmtimer = nsnull;
- else
- #ifdef NS_INIT_REFCNT //A temporary way of keeping backward compatibility with Mozilla 1.0 source compile
- m_alarmtimer->Init( AlarmTimerCallback, this, timediff*1000, PR_TRUE, NS_TYPE_ONE_SHOT );
- #else
- m_alarmtimer->InitWithFuncCallback( AlarmTimerCallback, this, timediff*1000, nsITimer::TYPE_ONE_SHOT );
- #endif
- }
-}
-
-void oeICalImpl::CancelAlarmTimer() {
- if( m_alarmtimer ) {
- PRUint32 delay = 0;
- #ifdef NS_INIT_REFCNT //A temporary way of keeping backward compatibility with Mozilla 1.0 source compile
- delay = m_alarmtimer->GetDelay();
- #else
- m_alarmtimer->GetDelay( &delay );
- #endif
- if ( delay != 0 )
- m_alarmtimer->Cancel();
- m_alarmtimer->Release();
- m_alarmtimer = nsnull;
- }
-}
-
-/**
-*
-* AddTodo
-*
-* DESCRIPTION: Adds a TODO component
-*
-* PARAMETERS:
-* icaltodo - The XPCOM component representing a TODO
-* retid - Place to store the returned id
-*
-*/
-NS_IMETHODIMP oeICalImpl::AddTodo(oeIICalTodo *icaltodo,char **retid)
-{
-#ifdef ICAL_DEBUG
- printf( "oeICalImpl::AddTodo()\n" );
-#endif
- icalset *stream;
- icalcomponent *vcalendar;
-
- nsCAutoString nativeServeraddr;
- nsresult rv = NS_CopyUnicodeToNative(NS_ConvertUTF8toUTF16(m_serveraddr),
- nativeServeraddr);
- NS_ENSURE_SUCCESS(rv, rv);
-
- stream = icalfileset_new(nativeServeraddr.get());
- if ( !stream ) {
- #ifdef ICAL_DEBUG
- printf( "oeICalImpl::AddTodo() failed: Cannot open stream: %s!\n", serveraddr );
- #endif
- return NS_OK;
- }
-
- ((oeICalTodoImpl *)icaltodo)->GetId( retid );
-
- if( *retid == nsnull ) {
- char uidstr[40];
- GenerateUUID( uidstr );
-
- ((oeICalTodoImpl *)icaltodo)->SetId( uidstr );
- ((oeICalTodoImpl *)icaltodo)->GetId( retid );
- }
-
- vcalendar = ((oeICalTodoImpl *)icaltodo)->AsIcalComponent();
-
- icalfileset_add_first_to_first_component( stream, vcalendar );
-
- if( icalfileset_commit(stream) != ICAL_NO_ERROR ) {
- #ifdef ICAL_DEBUG
- printf( "oeICalImpl::AddTodo() : WARNING icalfileset_commit() unsuccessful\n" );
- #endif
- }
- icalfileset_free( stream );
-
- icaltodo->AddRef();
- m_todolist.Add( icaltodo );
- ((oeICalTodoImpl *)icaltodo)->SetParent( this );
-
- PRUint32 observercount;
- m_todoobserverlist->Count( &observercount );
- for( unsigned int i=0; iobserver;
- m_todoobserverlist->QueryElementAt( i, NS_GET_IID(oeIICalTodoObserver), getter_AddRefs(observer));
- nsresult rv;
- rv = observer->OnAddItem( icaltodo );
- #ifdef ICAL_DEBUG
- if( NS_FAILED( rv ) ) {
- printf( "oeICalImpl::AddTodo() : WARNING Call to observer's onAddItem() unsuccessful: %x\n", rv );
- }
- #endif
- }
-
- SetupAlarmManager();
- return NS_OK;
-}
-
-NS_IMETHODIMP
-oeICalImpl::DeleteTodo( const char *id )
-{
-#ifdef ICAL_DEBUG
- printf( "oeICalImpl::DeleteTodo( %s )\n", id );
-#endif
- icalset *stream;
-
- nsCAutoString nativeServeraddr;
- nsresult rv = NS_CopyUnicodeToNative(NS_ConvertUTF8toUTF16(m_serveraddr),
- nativeServeraddr);
- NS_ENSURE_SUCCESS(rv, rv);
-
- stream = icalfileset_new(nativeServeraddr.get());
- if ( !stream ) {
- #ifdef ICAL_DEBUG
- printf( "oeICalImpl::DeleteTodo() failed: Cannot open stream: %s!\n", serveraddr );
- #endif
- return NS_OK;
- }
-
- if( id == nsnull ) {
- #ifdef ICAL_DEBUG
- printf( "oeICalImpl::DeleteTodo() - Invalid Id.\n" );
- #endif
- icalfileset_free(stream);
- return NS_OK;
- }
-
- icalcomponent *fetchedvcal = icalfileset_fetch( stream, id );
-
- if( !fetchedvcal ) {
- icalfileset_free(stream);
- #ifdef ICAL_DEBUG
- printf( "oeICalImpl::DeleteTodo() - WARNING Event not found.\n" );
- #endif
- return NS_OK;
- }
- icalcomponent *fetchedvevent = icalcomponent_fetch( fetchedvcal, id );
-
- if( !fetchedvevent ) {
- icalfileset_free(stream);
- #ifdef ICAL_DEBUG
- printf( "oeICalImpl::DeleteTodo() - WARNING Event not found.\n" );
- #endif
- return NS_OK;
- }
-
- icalcomponent_remove_component( fetchedvcal, fetchedvevent );
- icalcomponent_free( fetchedvevent );
- if ( !icalcomponent_get_first_real_component( fetchedvcal ) ) {
- icalfileset_remove_component( stream, fetchedvcal );
- icalcomponent_free( fetchedvcal );
- }
-
- icalfileset_mark( stream ); //Make sure stream is marked as dirty
- if( icalfileset_commit(stream) != ICAL_NO_ERROR ) {
- #ifdef ICAL_DEBUG
- printf( "oeICalImpl::DeleteTodo() : WARNING icalfileset_commit() unsuccessful\n" );
- #endif
- }
- icalfileset_free(stream);
-
- oeIICalTodo *icalevent;
- FetchTodo( id , &icalevent );
-
- m_todolist.Remove( id );
-
- PRUint32 observercount;
- m_todoobserverlist->Count( &observercount );
- for( unsigned int i=0; iobserver;
- m_todoobserverlist->QueryElementAt( i, NS_GET_IID(oeIICalTodoObserver), getter_AddRefs(observer));
- nsresult rv;
- rv = observer->OnDeleteItem( icalevent );
- #ifdef ICAL_DEBUG
- if( NS_FAILED( rv ) ) {
- printf( "oeICalImpl::DeleteTodo() : WARNING Call to observer's onDeleteItem() unsuccessful: %x\n", rv );
- }
- #endif
- }
-
- icalevent->Release();
-
- SetupAlarmManager();
- return NS_OK;
-}
-
-NS_IMETHODIMP oeICalImpl::FetchTodo( const char *id, oeIICalTodo **ev)
-{
-#ifdef ICAL_DEBUG_ALL
- printf( "oeICalImpl::FetchTodo()\n" );
-#endif
-
- if( id == nsnull ) {
- #ifdef ICAL_DEBUG
- printf( "oeICalImpl::FetchTodo() - Invalid Id.\n" );
- #endif
- *ev = nsnull;
- return NS_OK;
- }
-
- oeIICalTodo* event = m_todolist.GetTodoById( id );
- if( event != nsnull ) {
- event->AddRef();
- }
- *ev = event;
- return NS_OK;
-}
-
-NS_IMETHODIMP oeICalImpl::ModifyTodo(oeIICalTodo *icalevent, char **retid)
-{
-#ifdef ICAL_DEBUG
- printf( "oeICalImpl::ModifyTodo()\n" );
-#endif
- icalset *stream;
- icalcomponent *vcalendar;
-
- nsCAutoString nativeServeraddr;
- nsresult rv = NS_CopyUnicodeToNative(NS_ConvertUTF8toUTF16(m_serveraddr),
- nativeServeraddr);
- NS_ENSURE_SUCCESS(rv, rv);
-
- stream = icalfileset_new(nativeServeraddr.get());
- if ( !stream ) {
- #ifdef ICAL_DEBUG
- printf( "oeICalImpl::ModifyTodo() failed: Cannot open stream: %s!\n", serveraddr );
- #endif
- return NS_OK;
- }
-
- icalevent->GetId( retid );
- if( *retid == nsnull ) {
- #ifdef ICAL_DEBUG
- printf( "oeICalImpl::ModifyTodo() - Invalid Id.\n" );
- #endif
- icalfileset_free(stream);
- return NS_OK;
- }
-
- icalcomponent *fetchedvcal = icalfileset_fetch( stream, *retid );
-
- oeICalTodoImpl *oldevent=nsnull;
- if( fetchedvcal ) {
- icalcomponent *fetchedvevent = icalcomponent_fetch( fetchedvcal, *retid );
- if( fetchedvevent ) {
- icalcomponent_remove_component( fetchedvcal, fetchedvevent );
- if ( !icalcomponent_get_first_real_component( fetchedvcal ) ) {
- icalfileset_remove_component( stream, fetchedvcal );
- icalcomponent_free( fetchedvcal );
- }
- nsresult rv;
- if( NS_FAILED( rv = NS_NewICalTodo((oeIICalTodo**) &oldevent ))) {
- nsMemory::Free( *retid );
- *retid = nsnull;
- icalfileset_free(stream);
- return rv;
- }
- oldevent->ParseIcalComponent( fetchedvevent );
- icalcomponent_free( fetchedvevent );
- } else {
- #ifdef ICAL_DEBUG
- printf( "oeICalImpl::ModifyTodo() - WARNING Event not found.\n" );
- #endif
- nsMemory::Free( *retid );
- *retid = nsnull;
- icalfileset_free(stream);
- return NS_OK;
- }
- } else {
- #ifdef ICAL_DEBUG
- printf( "oeICalImpl::ModifyTodo() - WARNING Event not found.\n" );
- #endif
- nsMemory::Free( *retid );
- *retid = nsnull;
- icalfileset_free(stream);
- return NS_OK;
- }
-
- //Update Last-Modified
- icalevent->UpdateLastModified();
-
- vcalendar = ((oeICalTodoImpl *)icalevent)->AsIcalComponent();
-
- icalfileset_add_first_to_first_component( stream, vcalendar );
-
- if( icalfileset_commit(stream) != ICAL_NO_ERROR ) {
- #ifdef ICAL_DEBUG
- printf( "oeICalImpl::ModifyTodo() : WARNING icalfileset_commit() unsuccessful\n" );
- #endif
- }
- icalfileset_free(stream);
-
- PRUint32 observercount;
- m_todoobserverlist->Count( &observercount );
- for( unsigned int i=0; iobserver;
- m_todoobserverlist->QueryElementAt( i, NS_GET_IID(oeIICalTodoObserver), getter_AddRefs(observer));
- nsresult rv;
- rv = observer->OnModifyItem( icalevent, oldevent );
- #ifdef ICAL_DEBUG
- if( NS_FAILED( rv ) ) {
- printf( "oeICalImpl::ModifyTodo() : WARNING Call to observer's onModifyItem() unsuccessful: %x\n", rv );
- }
- #endif
- }
-
- oldevent->Release();
-
- SetupAlarmManager();
- return NS_OK;
-}
-
-NS_IMETHODIMP
-oeICalImpl::GetAllTodos(nsISimpleEnumerator **resultList )
-{
-#ifdef ICAL_DEBUG
- printf( "oeICalImpl::GetAllTodos()\n" );
-#endif
-
- oeEventEnumerator *todoEnum = new oeEventEnumerator();
- if (!todoEnum)
- return NS_ERROR_OUT_OF_MEMORY;
- *resultList = todoEnum;
- NS_ADDREF(*resultList);
-
- TodoList *tmplistptr = &m_todolist;
- while( tmplistptr ) {
- if( tmplistptr->todo ) {
- if( SatisfiesFilter( tmplistptr->todo ) )
- todoEnum->AddEvent( tmplistptr->todo );
- }
- tmplistptr = tmplistptr->next;
- }
-
- // bump ref count
-// return todoEnum->QueryInterface(NS_GET_IID(nsISimpleEnumerator), (void **)resultList);
- return NS_OK;
-}
-
-NS_IMETHODIMP oeICalImpl::ReportError( PRInt16 severity, PRUint32 errorid, const char *errorstring ) {
-
- if( severity >= oeIICalError::CAL_PROBLEM ) {
- #ifdef ICAL_DEBUG
- printf( "oeICalImpl::ReportError(%d,%x) : %s\n", severity, errorid, errorstring );
- #endif
- } else {
- #ifdef ICAL_DEBUG_ALL
- printf( "oeICalImpl::ReportError(%d,%x) : %s\n", severity, errorid, errorstring );
- #endif
- }
-
- unsigned int i;
- PRUint32 observercount;
- m_observerlist->Count(&observercount);
- for( i=0; iobserver;
- m_observerlist->QueryElementAt( i, NS_GET_IID(oeIICalObserver), getter_AddRefs(observer));
- nsresult rv;
- rv = observer->OnError( severity, errorid, errorstring );
- #ifdef ICAL_DEBUG
- if( NS_FAILED( rv ) ) {
- printf( "oeICalImpl::ReportError() : WARNING Call to observer's onError() unsuccessful: %x\n", rv );
- }
- #endif
- }
- m_todoobserverlist->Count(&observercount);
- for( i=0; iobserver;
- m_todoobserverlist->QueryElementAt( i, NS_GET_IID(oeIICalTodoObserver), getter_AddRefs(observer));
- nsresult rv;
- rv = observer->OnError( severity, errorid, errorstring );
- #ifdef ICAL_DEBUG
- if( NS_FAILED( rv ) ) {
- printf( "oeICalImpl::ReportError() : WARNING Call to observer's onError() unsuccessful: %x\n", rv );
- }
- #endif
- }
- return NS_OK;
-}
-
-/*************************************************************************************************************/
-/*************************************************************************************************************/
-/*************************************************************************************************************/
-/* Filter stuff here */
-/*************************************************************************************************************/
-/*************************************************************************************************************/
-
-bool oeICalImpl::SatisfiesFilter( oeIICalTodo *comp )
-{
- bool result=false;
- if( m_filter && m_filter->m_completed ) {
- if( icaltime_is_null_time( m_filter->m_completed->m_datetime ) )
- return true;
- }
- oeDateTimeImpl *completed;
- nsresult rv;
- rv = comp->GetCompleted( (oeIDateTime **)&completed );
- if( NS_FAILED( rv ) ) {
- #ifdef ICAL_DEBUG
- printf( "oeICalImpl::SatisfiesFilter() : WARNING GetCompleted() unsuccessful\n" );
- #endif
- return false;
- }
- if( icaltime_is_null_time( completed->m_datetime ) )
- result = true;
- if( icaltime_compare( completed->m_datetime , m_filter->m_completed->m_datetime ) > 0 )
- result = true;
- NS_RELEASE( completed );
- return result;
-}
-
-NS_IMETHODIMP oeICalImpl::GetFilter( oeIICalTodo **retval )
-{
- *retval = m_filter;
- NS_ADDREF(*retval);
- return NS_OK;
-}
-
-NS_IMETHODIMP oeICalImpl::ResetFilter()
-{
- if( m_filter && m_filter->m_completed )
- m_filter->m_completed->m_datetime = icaltime_null_time();
- return NS_OK;
-}
-
-NS_IMPL_ISUPPORTS1(oeICalFilter, oeIICalTodo)
-
-oeICalFilter::oeICalFilter()
-{
-
- nsresult rv;
- if( NS_FAILED( rv = NS_NewDateTime((oeIDateTime**) &m_completed ))) {
- m_completed = nsnull;
- }
-}
-
-oeICalFilter::~oeICalFilter()
-{
- if( m_completed )
- m_completed->Release();
-}
-
-NS_IMETHODIMP oeICalFilter::GetType(Componenttype *aRetVal)
-{
- return NS_ERROR_NOT_IMPLEMENTED;
-}
-
-NS_IMETHODIMP oeICalFilter::GetId(char **aRetVal)
-{
- return NS_ERROR_NOT_IMPLEMENTED;
-}
-
-NS_IMETHODIMP oeICalFilter::SetId(const char *aNewVal)
-{
- return NS_ERROR_NOT_IMPLEMENTED;
-}
-
-NS_IMETHODIMP oeICalFilter::GetTitle(nsACString& aRetVal)
-{
- return NS_ERROR_NOT_IMPLEMENTED;
-}
-
-NS_IMETHODIMP oeICalFilter::SetTitle(const nsACString& aNewVal)
-{
- return NS_ERROR_NOT_IMPLEMENTED;
-}
-
-NS_IMETHODIMP oeICalFilter::GetDescription(nsACString& aRetVal)
-{
- return NS_ERROR_NOT_IMPLEMENTED;
-}
-
-NS_IMETHODIMP oeICalFilter::SetDescription(const nsACString& aNewVal)
-{
- return NS_ERROR_NOT_IMPLEMENTED;
-}
-
-NS_IMETHODIMP oeICalFilter::GetLocation(nsACString& aRetVal)
-{
- return NS_ERROR_NOT_IMPLEMENTED;
-}
-
-NS_IMETHODIMP oeICalFilter::SetLocation(const nsACString& aNewVal)
-{
- return NS_ERROR_NOT_IMPLEMENTED;
-}
-
-NS_IMETHODIMP oeICalFilter::GetCategories(nsACString& aRetVal)
-{
- return NS_ERROR_NOT_IMPLEMENTED;
-}
-
-NS_IMETHODIMP oeICalFilter::SetCategories(const nsACString& aNewVal)
-{
- return NS_ERROR_NOT_IMPLEMENTED;
-}
-
-NS_IMETHODIMP oeICalFilter::GetUrl(nsACString& aRetVal)
-{
- return NS_ERROR_NOT_IMPLEMENTED;
-}
-
-NS_IMETHODIMP oeICalFilter::SetUrl(const nsACString& aNewVal)
-{
- return NS_ERROR_NOT_IMPLEMENTED;
-}
-
-NS_IMETHODIMP oeICalFilter::GetPrivateEvent(PRBool *aRetVal)
-{
- return NS_ERROR_NOT_IMPLEMENTED;
-}
-
-NS_IMETHODIMP oeICalFilter::SetPrivateEvent(PRBool aNewVal)
-{
- return NS_ERROR_NOT_IMPLEMENTED;
-}
-
-NS_IMETHODIMP oeICalFilter::GetMethod(eventMethodProperty *aRetVal)
-{
- return NS_ERROR_NOT_IMPLEMENTED;
-}
-
-NS_IMETHODIMP oeICalFilter::SetMethod(eventMethodProperty aNewVal)
-{
- return NS_ERROR_NOT_IMPLEMENTED;
-}
-
-NS_IMETHODIMP oeICalFilter::GetStatus(eventStatusProperty *aRetVal)
-{
- return NS_ERROR_NOT_IMPLEMENTED;
-}
-
-NS_IMETHODIMP oeICalFilter::SetStatus(eventStatusProperty aNewVal)
-{
- return NS_ERROR_NOT_IMPLEMENTED;
-}
-
-NS_IMETHODIMP oeICalFilter::GetPriority(PRInt16 *aRetVal)
-{
- return NS_ERROR_NOT_IMPLEMENTED;
-}
-
-NS_IMETHODIMP oeICalFilter::SetPriority(PRInt16 aNewVal)
-{
- return NS_ERROR_NOT_IMPLEMENTED;
-}
-
-NS_IMETHODIMP oeICalFilter::GetSyncId(char * *aRetVal)
-{
- return NS_ERROR_NOT_IMPLEMENTED;
-}
-
-NS_IMETHODIMP oeICalFilter::SetSyncId(const char * aNewVal)
-{
- return NS_ERROR_NOT_IMPLEMENTED;
-}
-
-NS_IMETHODIMP oeICalFilter::GetAllDay(PRBool *aRetVal)
-{
- return NS_ERROR_NOT_IMPLEMENTED;
-}
-NS_IMETHODIMP oeICalFilter::SetAllDay(PRBool aNewVal)
-{
- return NS_ERROR_NOT_IMPLEMENTED;
-}
-
-NS_IMETHODIMP oeICalFilter::GetAlarm(PRBool *aRetVal)
-{
- return NS_ERROR_NOT_IMPLEMENTED;
-}
-
-NS_IMETHODIMP oeICalFilter::SetAlarm(PRBool aNewVal)
-{
- return NS_ERROR_NOT_IMPLEMENTED;
-}
-
-NS_IMETHODIMP oeICalFilter::GetAlarmUnits(char * *aRetVal)
-{
- return NS_ERROR_NOT_IMPLEMENTED;
-}
-
-NS_IMETHODIMP oeICalFilter::SetAlarmUnits(const char * aNewVal)
-{
- return NS_ERROR_NOT_IMPLEMENTED;
-}
-
-NS_IMETHODIMP oeICalFilter::GetAlarmLength(PRUint32 *aRetVal)
-{
- return NS_ERROR_NOT_IMPLEMENTED;
-}
-
-NS_IMETHODIMP oeICalFilter::SetAlarmLength(PRUint32 aNewVal)
-{
- return NS_ERROR_NOT_IMPLEMENTED;
-}
-
-NS_IMETHODIMP oeICalFilter::GetAlarmEmailAddress(char * *aRetVal)
-{
- return NS_ERROR_NOT_IMPLEMENTED;
-}
-
-NS_IMETHODIMP oeICalFilter::SetAlarmEmailAddress(const char * aNewVal)
-{
- return NS_ERROR_NOT_IMPLEMENTED;
-}
-
-NS_IMETHODIMP oeICalFilter::GetInviteEmailAddress(char * *aRetVal)
-{
- return NS_ERROR_NOT_IMPLEMENTED;
-}
-
-NS_IMETHODIMP oeICalFilter::SetInviteEmailAddress(const char * aNewVal)
-{
- return NS_ERROR_NOT_IMPLEMENTED;
-}
-
-NS_IMETHODIMP oeICalFilter::GetRecurInterval(PRUint32 *aRetVal)
-{
- return NS_ERROR_NOT_IMPLEMENTED;
-}
-
-NS_IMETHODIMP oeICalFilter::SetRecurInterval(PRUint32 aNewVal )
-{
- return NS_ERROR_NOT_IMPLEMENTED;
-}
-
-NS_IMETHODIMP oeICalFilter::GetRecurCount(PRUint32 *aRetVal)
-{
- return NS_ERROR_NOT_IMPLEMENTED;
-}
-
-NS_IMETHODIMP oeICalFilter::SetRecurCount(PRUint32 aNewVal )
-{
- return NS_ERROR_NOT_IMPLEMENTED;
-}
-
-NS_IMETHODIMP oeICalFilter::GetRecurUnits(char **aRetVal)
-{
- return NS_ERROR_NOT_IMPLEMENTED;
-}
-
-NS_IMETHODIMP oeICalFilter::SetRecurUnits(const char * aNewVal)
-{
- return NS_ERROR_NOT_IMPLEMENTED;
-}
-
-NS_IMETHODIMP oeICalFilter::GetRecur(PRBool *aRetVal)
-{
- return NS_ERROR_NOT_IMPLEMENTED;
-}
-
-NS_IMETHODIMP oeICalFilter::SetRecur(PRBool aNewVal)
-{
- return NS_ERROR_NOT_IMPLEMENTED;
-}
-
-NS_IMETHODIMP oeICalFilter::GetRecurForever(PRBool *aRetVal)
-{
- return NS_ERROR_NOT_IMPLEMENTED;
-}
-NS_IMETHODIMP oeICalFilter::SetRecurForever(PRBool aNewVal)
-{
- return NS_ERROR_NOT_IMPLEMENTED;
-}
-
-NS_IMETHODIMP oeICalFilter::GetLastModified(PRTime *aRetVal)
-{
- return NS_ERROR_NOT_IMPLEMENTED;
-}
-NS_IMETHODIMP oeICalFilter::UpdateLastModified()
-{
- return NS_ERROR_NOT_IMPLEMENTED;
-}
-
-NS_IMETHODIMP oeICalFilter::GetLastAlarmAck(PRTime *aRetVal)
-{
- return NS_ERROR_NOT_IMPLEMENTED;
-}
-NS_IMETHODIMP oeICalFilter::SetLastAlarmAck(PRTime aNewVal)
-{
- return NS_ERROR_NOT_IMPLEMENTED;
-}
-
-NS_IMETHODIMP oeICalFilter::GetNextRecurrence( PRTime begin, PRTime *retval, PRBool *isvalid ) {
- return NS_ERROR_NOT_IMPLEMENTED;
-}
-
-NS_IMETHODIMP oeICalFilter::GetPreviousOccurrence( PRTime beforethis, PRTime *retval, PRBool *isvalid ) {
- return NS_ERROR_NOT_IMPLEMENTED;
-}
-
-NS_IMETHODIMP oeICalFilter::GetStart(oeIDateTime * *start)
-{
- return NS_ERROR_NOT_IMPLEMENTED;
-}
-
-NS_IMETHODIMP oeICalFilter::GetEnd(oeIDateTime * *end)
-{
- return NS_ERROR_NOT_IMPLEMENTED;
-}
-
-NS_IMETHODIMP oeICalFilter::GetStamp(oeIDateTime * *stamp)
-{
- return NS_ERROR_NOT_IMPLEMENTED;
-}
-
-NS_IMETHODIMP oeICalFilter::GetRecurEnd(oeIDateTime * *recurend)
-{
- return NS_ERROR_NOT_IMPLEMENTED;
-}
-
-NS_IMETHODIMP oeICalFilter::GetRecurWeekdays(PRInt16 *aRetVal)
-{
- return NS_ERROR_NOT_IMPLEMENTED;
-}
-NS_IMETHODIMP oeICalFilter::SetRecurWeekdays(PRInt16 aNewVal)
-{
- return NS_ERROR_NOT_IMPLEMENTED;
-}
-
-NS_IMETHODIMP oeICalFilter::GetRecurWeekNumber(PRInt16 *aRetVal)
-{
- return NS_ERROR_NOT_IMPLEMENTED;
-}
-
-NS_IMETHODIMP oeICalFilter::SetRecurWeekNumber(PRInt16 aNewVal)
-{
- return NS_ERROR_NOT_IMPLEMENTED;
-}
-
-NS_IMETHODIMP oeICalFilter::GetIcalString(nsACString& aRetVal)
-{
- return NS_ERROR_NOT_IMPLEMENTED;
-}
-
- NS_IMETHODIMP oeICalFilter::ParseIcalString(const nsACString& aNewVal, PRBool *aRetVal)
-{
- return NS_ERROR_NOT_IMPLEMENTED;
-}
-
-NS_IMETHODIMP oeICalFilter::AddException( PRTime exdate )
-{
- return NS_ERROR_NOT_IMPLEMENTED;
-}
-
-NS_IMETHODIMP oeICalFilter::RemoveAllExceptions()
-{
- return NS_ERROR_NOT_IMPLEMENTED;
-}
-
-NS_IMETHODIMP oeICalFilter::GetExceptions(nsISimpleEnumerator **datelist )
-{
- return NS_ERROR_NOT_IMPLEMENTED;
-}
-
-NS_IMETHODIMP oeICalFilter::SetSnoozeTime( PRTime snoozetime )
-{
- return NS_ERROR_NOT_IMPLEMENTED;
-}
-
-NS_IMETHODIMP oeICalFilter::Clone( oeIICalEvent **ev )
-{
- return NS_ERROR_NOT_IMPLEMENTED;
-}
-
-NS_IMETHODIMP oeICalFilter::GetDue(oeIDateTime * *due)
-{
- return NS_ERROR_NOT_IMPLEMENTED;
-}
-
-NS_IMETHODIMP oeICalFilter::GetCompleted(oeIDateTime * *completed)
-{
- *completed = m_completed;
- NS_ADDREF(*completed);
- return NS_OK;
-}
-
-NS_IMETHODIMP oeICalFilter::GetPercent(PRInt16 *aRetVal)
-{
- return NS_ERROR_NOT_IMPLEMENTED;
-}
-
-NS_IMETHODIMP oeICalFilter::SetPercent(PRInt16 aNewVal)
-{
- return NS_ERROR_NOT_IMPLEMENTED;
-}
-
-NS_IMETHODIMP oeICalFilter::AddAttachment(nsIMsgAttachment *attachment)
-{
- return NS_ERROR_NOT_IMPLEMENTED;
-}
-
-NS_IMETHODIMP oeICalFilter::RemoveAttachment(nsIMsgAttachment *attachment)
-{
- return NS_ERROR_NOT_IMPLEMENTED;
-}
-
-NS_IMETHODIMP oeICalFilter::RemoveAttachments()
-{
- return NS_ERROR_NOT_IMPLEMENTED;
-}
-
-NS_IMETHODIMP oeICalFilter::GetAttachmentsArray(nsISupportsArray * *aAttachmentsArray)
-{
- return NS_ERROR_NOT_IMPLEMENTED;
-}
-
-NS_IMETHODIMP oeICalFilter::AddContact(nsIAbCard *contact)
-{
- return NS_ERROR_NOT_IMPLEMENTED;
-}
-
-NS_IMETHODIMP oeICalFilter::RemoveContact(nsIAbCard *contact)
-{
- return NS_ERROR_NOT_IMPLEMENTED;
-}
-
-NS_IMETHODIMP oeICalFilter::RemoveContacts()
-{
- return NS_ERROR_NOT_IMPLEMENTED;
-}
-
-NS_IMETHODIMP oeICalFilter::GetContactsArray(nsISupportsArray * *aContactsArray)
-{
- return NS_ERROR_NOT_IMPLEMENTED;
-}
-
-NS_IMETHODIMP oeICalFilter::SetParent( oeIICal *parent)
-{
- return NS_ERROR_NOT_IMPLEMENTED;
-}
-
-NS_IMETHODIMP oeICalFilter::GetParent( oeIICal **parent)
-{
- return NS_ERROR_NOT_IMPLEMENTED;
-}
-
-NS_IMETHODIMP oeICalFilter::GetTodoIcalString(nsACString& aRetVal)
-{
- return NS_ERROR_NOT_IMPLEMENTED;
-}
-
-NS_IMETHODIMP oeICalFilter::ParseTodoIcalString(const nsACString& aNewVal, PRBool *aRetVal)
-{
- return NS_ERROR_NOT_IMPLEMENTED;
-}
-NS_IMETHODIMP oeICalFilter::SetDuration(PRBool is_negative, PRUint16 weeks, PRUint16 days, PRUint16 hours, PRUint16 minutes, PRUint16 seconds)
-{
- return NS_ERROR_NOT_IMPLEMENTED;
-}
-
-NS_IMETHODIMP oeICalFilter::GetDuration(PRBool *is_negative, PRUint16 *weeks, PRUint16 *days, PRUint16 *hours, PRUint16 *minutes, PRUint16 *seconds)
-{
- return NS_ERROR_NOT_IMPLEMENTED;
-}
-
-NS_IMETHODIMP oeICalFilter::ReportError( PRInt16 severity, PRUint32 errorid, const char *errorstring ) {
- return NS_ERROR_NOT_IMPLEMENTED;
-}
-
-NS_IMETHODIMP oeICalFilter::SetParameter( const char *name, const char *value ) {
- return NS_ERROR_NOT_IMPLEMENTED;
-}
-
-NS_IMETHODIMP oeICalFilter::GetParameter( const char *name, char **value ) {
- return NS_ERROR_NOT_IMPLEMENTED;
-}
diff --git a/mozilla/calendar/libxpical/oeICalImpl.h b/mozilla/calendar/libxpical/oeICalImpl.h
deleted file mode 100644
index e5eda54d873..00000000000
--- a/mozilla/calendar/libxpical/oeICalImpl.h
+++ /dev/null
@@ -1,199 +0,0 @@
-/* ***** BEGIN LICENSE BLOCK *****
- * Version: MPL 1.1/GPL 2.0/LGPL 2.1
- *
- * The contents of this file are subject to the Mozilla Public License Version
- * 1.1 (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * Software distributed under the License is distributed on an "AS IS" basis,
- * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
- * for the specific language governing rights and limitations under the
- * License.
- *
- * The Original Code is OEone Calendar Code, released October 31st, 2001.
- *
- * The Initial Developer of the Original Code is
- * OEone Corporation.
- * Portions created by the Initial Developer are Copyright (C) 2001
- * the Initial Developer. All Rights Reserved.
- *
- * Contributor(s): Mostafa Hosseini
- *
- * Alternatively, the contents of this file may be used under the terms of
- * either the GNU General Public License Version 2 or later (the "GPL"), or
- * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
- * in which case the provisions of the GPL or the LGPL are applicable instead
- * of those above. If you wish to allow use of your version of this file only
- * under the terms of either the GPL or the LGPL, and not to allow others to
- * use your version of this file under the terms of the MPL, indicate your
- * decision by deleting the provisions above and replace them with the notice
- * and other provisions required by the GPL or the LGPL. If you do not delete
- * the provisions above, a recipient may use your version of this file under
- * the terms of any one of the MPL, the GPL or the LGPL.
- *
- * ***** END LICENSE BLOCK ***** */
-
- /* Header file for oeICalImpl.cpp containing its CID and CONTRACTID. It also includes
- the implementation for an event linked-list used throughout the code */
-
-#ifndef _OEICALIMPL_H_
-#define _OEICALIMPL_H_
-
-#include "oeIICal.h"
-#include "nsITimer.h"
-#include "oeICalEventImpl.h"
-#include "oeICalTodoImpl.h"
-#include "nsVoidArray.h"
-
-#define OE_ICAL_CID \
-{ 0x0a8c5de7, 0x0d19, 0x4b95, { 0x82, 0xf4, 0xe0, 0xaf, 0x92, 0x45, 0x32, 0x27 } }
-
-#define OE_ICAL_CONTRACTID "@mozilla.org/ical;1"
-
-extern "C" {
- #include "ical.h"
-}
-
-
-class TodoList {
-public:
- oeIICalTodo* todo;
- TodoList* next;
- TodoList() {
- todo = nsnull;
- next = nsnull;
- }
- ~TodoList() {
- if( todo )
- todo->Release();
- if( next )
- delete next;
- }
- void Add( oeIICalTodo* e) {
- if( !todo ) {
- todo = e;
- } else {
- if( !next ) {
- next = new TodoList();
- }
- next->Add( e );
- }
- }
- oeIICalTodo* GetTodoById( const char *id ) {
- if( !todo )
- return nsnull;
- if( ((oeICalTodoImpl *)todo)->matchId( id ) )
- return todo;
- if( next )
- return next->GetTodoById( id );
- return nsnull;
- }
- void Remove( const char *id ) {
- if( !todo )
- return;
- if( ((oeICalTodoImpl *)todo)->matchId( id ) ) {
- todo->Release();
- if( next ) {
- todo = next->todo;
- TodoList *tmp = next;
- next = next->next;
- tmp->next = nsnull;
- tmp->todo = nsnull;
- delete tmp;
- } else {
- todo = nsnull;
- }
- } else {
- if( next )
- next->Remove( id );
- }
- }
-};
-
-class oeICalFilter : public oeIICalTodo
-{
-public:
- NS_DECL_ISUPPORTS
- NS_DECL_OEIICALEVENT
- NS_DECL_OEIICALTODO
-
- oeICalFilter();
- virtual ~oeICalFilter();
- oeDateTimeImpl *m_completed;
-private:
-/* char *m_id;
- char *m_syncid;
- char *m_title;
- char *m_description;
- char *m_location;
- char *m_category;
- bool m_isprivate;
- bool m_allday;
- bool m_hasalarm;
- unsigned long m_alarmlength;
- char *m_alarmunits;
- char *m_alarmemail;
- char *m_inviteemail;
- short m_recurtype;
- unsigned long m_recurinterval;
- bool m_recur;
- bool m_recurforever;
- char *m_recurunits;
- short m_recurweekdays;
- short m_recurweeknumber;
- oeDateTimeImpl *m_start;
- oeDateTimeImpl *m_end;
- oeDateTimeImpl *m_recurend;
- icaltimetype m_lastalarmack;
- int m_percent;
- oeDateTimeImpl *m_due;*/
-};
-
-class oeICalImpl : public oeIICal
-{
- public:
- oeICalImpl();
- virtual ~oeICalImpl();
-
- /**
- * This macro expands into a declaration of the nsISupports interface.
- * Every XPCOM component needs to implement nsISupports, as it acts
- * as the gateway to other interfaces this component implements. You
- * could manually declare QueryInterface, AddRef, and Release instead
- * of using this macro, but why?
- */
- // nsISupports interface
- NS_DECL_ISUPPORTS
-
- /**
- * This macro is defined in the nsISample.h file, and is generated
- * automatically by the xpidl compiler. It expands to
- * declarations of all of the methods required to implement the
- * interface. xpidl will generate a NS_DECL_[INTERFACENAME] macro
- * for each interface that it processes.
- *
- * The methods of nsISample are discussed individually below, but
- * commented out (because this macro already defines them.)
- */
- NS_DECL_OEIICAL
- void SetupAlarmManager();
- icaltimetype GetNextEvent( icaltimetype starting );
- nsVoidArray *GetEventList();
-private:
- nsCOMPtr m_observerlist;
- nsCOMPtr m_todoobserverlist;
- bool m_batchMode;
- bool m_suppressAlarms;
- nsVoidArray m_eventlist;
- TodoList m_todolist;
- nsITimer *m_alarmtimer;
- nsCString m_serveraddr;
- oeICalFilter *m_filter;
- bool SatisfiesFilter( oeIICalTodo *comp );
- void ChopAndAddEventToEnum( struct icaltimetype startdate,
- nsISimpleEnumerator **eventlist, oeICalEventImpl* event, bool isallday, bool isbeginning );
- void CancelAlarmTimer();
-};
-
-#endif
diff --git a/mozilla/calendar/libxpical/oeICalTodoImpl.cpp b/mozilla/calendar/libxpical/oeICalTodoImpl.cpp
deleted file mode 100644
index 98d21866191..00000000000
--- a/mozilla/calendar/libxpical/oeICalTodoImpl.cpp
+++ /dev/null
@@ -1,376 +0,0 @@
-/* ***** BEGIN LICENSE BLOCK *****
- * Version: MPL 1.1/GPL 2.0/LGPL 2.1
- *
- * The contents of this file are subject to the Mozilla Public License Version
- * 1.1 (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * Software distributed under the License is distributed on an "AS IS" basis,
- * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
- * for the specific language governing rights and limitations under the
- * License.
- *
- * The Original Code is Mozilla Calendar Code.
- *
- * The Initial Developer of the Original Code is
- * Chris Charabaruk .
- * Portions created by the Initial Developer are Copyright (C) 2001
- * the Initial Developer. All Rights Reserved.
- *
- * Contributor(s): Chris Charabaruk
- * Mostafa Hosseini
- *
- * Alternatively, the contents of this file may be used under the terms of
- * either the GNU General Public License Version 2 or later (the "GPL"), or
- * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
- * in which case the provisions of the GPL or the LGPL are applicable instead
- * of those above. If you wish to allow use of your version of this file only
- * under the terms of either the GPL or the LGPL, and not to allow others to
- * use your version of this file under the terms of the MPL, indicate your
- * decision by deleting the provisions above and replace them with the notice
- * and other provisions required by the GPL or the LGPL. If you do not delete
- * the provisions above, a recipient may use your version of this file under
- * the terms of any one of the MPL, the GPL or the LGPL.
- *
- * ***** END LICENSE BLOCK ***** */
-
-/* This file implements an XPCOM object which represents a calendar task(todo) object. It is a derivation
-of the event object which adds fields exclusive to tasks.
-*/
-
-#ifndef WIN32
-#include
-#endif
-
-#include "oeICalEventImpl.h"
-#include "oeICalTodoImpl.h"
-#include "nsMemory.h"
-#include "nsCOMPtr.h"
-#include "nsIPrefBranch.h"
-#include "nsIPrefService.h"
-#include "nsIServiceManager.h"
-
-#define strcasecmp strcmp
-
-#define RECUR_NONE 0
-#define RECUR_DAILY 1
-#define RECUR_WEEKLY 2
-#define RECUR_MONTHLY_MDAY 3
-#define RECUR_MONTHLY_WDAY 4
-#define RECUR_YEARLY 5
-
-/* Implementation file */
-NS_IMPL_ISUPPORTS2(oeICalTodoImpl, oeIICalTodo, oeIICalEvent)
-
-icaltimetype ConvertFromPrtime( PRTime indate );
-PRTime ConvertToPrtime ( icaltimetype indate );
-
-nsresult
-NS_NewICalTodo( oeIICalTodo** inst )
-{
- NS_PRECONDITION(inst != nsnull, "null ptr");
- if (! inst)
- return NS_ERROR_NULL_POINTER;
-
- *inst = new oeICalTodoImpl();
- if (! *inst)
- return NS_ERROR_OUT_OF_MEMORY;
-
- NS_ADDREF(*inst);
- return NS_OK;
-}
-
-oeICalTodoImpl::oeICalTodoImpl()
-{
-#ifdef ICAL_DEBUG
- printf( "oeICalTodoImpl::oeICalTodoImpl()\n" );
-#endif
-
- mEvent = new oeICalEventImpl();
- NS_ADDREF( mEvent );
-
- mEvent->SetType( XPICAL_VTODO_COMPONENT );
-
- /* member initializers and constructor code */
- nsresult rv;
- if( NS_FAILED( rv = NS_NewDateTime((oeIDateTime**) &m_completed ))) {
- m_completed = nsnull;
- }
- m_percent = 0;
-
- //Some defaults are different for todos, apply them
- nsCOMPtr prefBranch = do_GetService(NS_PREFSERVICE_CONTRACTID, &rv);
- if ( NS_SUCCEEDED(rv) && prefBranch ) {
- nsXPIDLCString tmpstr;
- PRInt32 tmpint;
- rv = prefBranch->GetIntPref("calendar.alarms.onfortodos", &tmpint);
- if (NS_SUCCEEDED(rv))
- SetAlarm( tmpint );
- rv = prefBranch->GetIntPref("calendar.alarms.todoalarmlen", &tmpint);
- if (NS_SUCCEEDED(rv))
- SetAlarmLength( tmpint );
- rv = prefBranch->GetCharPref("calendar.alarms.todoalarmunit", getter_Copies(tmpstr));
- if (NS_SUCCEEDED(rv))
- SetAlarmUnits( PromiseFlatCString( tmpstr ).get() );
- }
-}
-
-oeICalTodoImpl::~oeICalTodoImpl()
-{
-#ifdef ICAL_DEBUG_ALL
- printf( "oeICalTodoImpl::~oeICalTodoImpl()\n");
-#endif
- /* destructor code */
- if( m_completed )
- m_completed->Release();
- mEvent->Release();
-}
-
-bool oeICalTodoImpl::matchId( const char *id ) {
- return mEvent->matchId( id );
-}
-
-/* readonly attribute oeIDateTime due; */
-NS_IMETHODIMP oeICalTodoImpl::GetDue(oeIDateTime * *due)
-{
- return mEvent->GetEnd( due );
-}
-
-/* areadonly attribute oeIDateTime completed; */
-NS_IMETHODIMP oeICalTodoImpl::GetCompleted(oeIDateTime * *completed)
-{
- *completed = m_completed;
- NS_ADDREF(*completed);
- return NS_OK;
-}
-
-/* attribute short percent; */
-NS_IMETHODIMP oeICalTodoImpl::GetPercent(PRInt16 *aRetVal)
-{
-#ifdef ICAL_DEBUG_ALL
- printf( "GetPercent() = " );
-#endif
-
- *aRetVal = m_percent;
-
-#ifdef ICAL_DEBUG_ALL
- printf( "%d\n", *aRetVal );
-#endif
- return NS_OK;
-}
-NS_IMETHODIMP oeICalTodoImpl::SetPercent(PRInt16 aNewVal)
-{
-#ifdef ICAL_DEBUG_ALL
- printf( "SetPercent( %d )\n", aNewVal );
-#endif
- m_percent = aNewVal;
- return NS_OK;
-}
-
-NS_IMETHODIMP oeICalTodoImpl::Clone( oeIICalTodo **ev )
-{
-#ifdef ICAL_DEBUG_ALL
- printf( "oeICalTodoImpl::Clone()\n" );
-#endif
- nsresult rv;
- oeICalTodoImpl *icaltodo =nsnull;
- if( NS_FAILED( rv = NS_NewICalTodo( (oeIICalTodo**) &icaltodo ) ) ) {
- return rv;
- }
- icalcomponent *vcalendar = AsIcalComponent();
- if ( !vcalendar ) {
- #ifdef ICAL_DEBUG
- printf( "oeICalTodoImpl::Clone() failed!\n" );
- #endif
- icaltodo->Release();
- return NS_OK;
- }
- icalcomponent *vtodo = icalcomponent_get_first_component( vcalendar, ICAL_VTODO_COMPONENT );
- if( !(icaltodo->ParseIcalComponent( vtodo )) ) {
- #ifdef ICAL_DEBUG
- printf( "oeICalTodoImpl::Clone() failed.\n" );
- #endif
- icaltodo->Release();
- return NS_OK;
- }
- *ev = icaltodo;
- return NS_OK;
-}
-
-NS_IMETHODIMP oeICalTodoImpl::GetTodoIcalString(nsACString& aRetVal)
-{
-#ifdef ICAL_DEBUG_ALL
- printf( "oeICalTodoImpl::GetTodoIcalString() = " );
-#endif
-
- icalcomponent *vcalendar = AsIcalComponent();
- if ( !vcalendar ) {
- #ifdef ICAL_DEBUG
- printf( "oeICalTodoImpl::GetTodoIcalString() failed!\n" );
- #endif
- return NS_OK;
- }
-
- char *str = icalcomponent_as_ical_string( vcalendar );
- if( str ) {
- aRetVal = str;
- } else
- aRetVal.Truncate();
- icalcomponent_free( vcalendar );
-
-#ifdef ICAL_DEBUG_ALL
- printf( "\"%s\"\n", PromiseFlatCString( aRetVal ).get() );
-#endif
- return NS_OK;
-}
-
-NS_IMETHODIMP oeICalTodoImpl::ParseTodoIcalString(const nsACString& aNewVal, PRBool *aRetVal)
-{
-#ifdef ICAL_DEBUG_ALL
- printf( "oeICalTodoImpl::ParseTodoIcalString( %s )\n", PromiseFlatCString( aNewVal ).get() );
-#endif
-
- *aRetVal = false;
- icalcomponent *comp = icalparser_parse_string( PromiseFlatCString( aNewVal ).get() );
- if( comp ) {
- if( ParseIcalComponent( comp ) )
- *aRetVal = true;
- icalcomponent_free( comp );
- }
- return NS_OK;
-}
-
-bool oeICalTodoImpl::ParseIcalComponent( icalcomponent *comp )
-{
-#ifdef ICAL_DEBUG_ALL
- printf( "ParseIcalComponent()\n" );
-#endif
-
- icalcomponent *vtodo=nsnull;
- icalcomponent_kind kind = icalcomponent_isa( comp );
-
- if( kind == ICAL_VCALENDAR_COMPONENT )
- vtodo = icalcomponent_get_first_component( comp , ICAL_VTODO_COMPONENT );
- else if( kind == ICAL_VTODO_COMPONENT )
- vtodo = comp;
-
- if ( !vtodo ) {
- #ifdef ICAL_DEBUG
- printf( "oeICalTodoImpl::ParseIcalComponent() failed: vtodo is NULL!\n" );
- #endif
- return false;
- }
-
- //First parse all basic properties
- ((oeICalEventImpl *)mEvent)->ParseIcalComponent( vtodo );
-
- //then go on with the extra properties
-
- //percent
- icalproperty *prop = icalcomponent_get_first_property( vtodo, ICAL_PERCENTCOMPLETE_PROPERTY );
- if ( prop != 0) {
- m_percent = icalproperty_get_percentcomplete( prop );
- } else {
- m_percent = 0;
- }
-
- //completed
- prop = icalcomponent_get_first_property( vtodo, ICAL_COMPLETED_PROPERTY );
- if (prop != 0) {
- icaltimetype completed;
- completed = icalproperty_get_completed( prop );
- m_completed->m_datetime = completed;
- } else {
- m_completed->m_datetime = icaltime_null_time();
- }
-
- return true;
-}
-
-icalcomponent* oeICalTodoImpl::AsIcalComponent()
-{
-#ifdef ICAL_DEBUG_ALL
- printf( "AsIcalComponent()\n" );
-#endif
- icalcomponent *newcalendar;
-
- newcalendar = icalcomponent_new_vcalendar();
- if ( !newcalendar ) {
- #ifdef ICAL_DEBUG
- printf( "oeICalTodoImpl::AsIcalComponent() failed: Cannot create VCALENDAR!\n" );
- #endif
- return nsnull;
- }
- icalcomponent *basevcal = ((oeICalEventImpl *)mEvent)->AsIcalComponent();
- if ( !basevcal ) {
- #ifdef ICAL_DEBUG
- printf( "oeICalTodoImpl::AsIcalComponent() failed: Cannot create ical component from mEvent!\n" );
- #endif
- icalcomponent_free( newcalendar );
- return nsnull;
- }
-
- //version
- icalproperty *prop = icalproperty_new_version( ICALEVENT_VERSION );
- icalcomponent_add_property( newcalendar, prop );
-
- //prodid
- prop = icalproperty_new_prodid( ICALEVENT_PRODID );
- icalcomponent_add_property( newcalendar, prop );
- icalcomponent *vtodo = icalcomponent_new_vtodo();
- icalcomponent *vevent = icalcomponent_get_first_component( basevcal, ICAL_VEVENT_COMPONENT );
- for( prop = icalcomponent_get_first_property( vevent, ICAL_ANY_PROPERTY );
- prop != 0 ;
- prop = icalcomponent_get_next_property( vevent, ICAL_ANY_PROPERTY ) ) {
- icalproperty *newprop;
- icalproperty_kind propkind = icalproperty_isa( prop );
- if( propkind == ICAL_X_PROPERTY ) {
- newprop = icalproperty_new_x( icalproperty_get_value_as_string( prop ) );
- icalproperty_set_x_name( newprop, icalproperty_get_x_name( prop ));
- icalparameter *oldpar = icalproperty_get_first_parameter( prop, ICAL_MEMBER_PARAMETER );
- icalparameter *newpar = icalparameter_new_member( icalparameter_get_member( oldpar ) );
- icalproperty_add_parameter( newprop, newpar );
- } else if( propkind == ICAL_DTEND_PROPERTY ) {
- //Change DTEND to DUE
- newprop = icalproperty_new_due( icalproperty_get_dtend( prop ) );
- icalparameter *oldpar = icalproperty_get_first_parameter( prop, ICAL_TZID_PARAMETER );
- if( oldpar ) {
- icalparameter *newpar = icalparameter_new_tzid( icalparameter_get_tzid( oldpar ) );
- icalproperty_add_parameter( newprop, newpar );
- }
- } else {
- newprop = icalproperty_new_clone( prop );
- }
- icalcomponent_add_property( vtodo, newprop );
- }
- icalcomponent *nestedcomp;
- for( nestedcomp = icalcomponent_get_first_component( vevent, ICAL_ANY_COMPONENT );
- nestedcomp != 0 ;
- nestedcomp = icalcomponent_get_next_component( vevent, ICAL_ANY_COMPONENT ) ) {
- icalcomponent_add_component( vtodo, icalcomponent_new_clone(nestedcomp) );
- }
- icalcomponent_free( basevcal );
- //percent
- if( m_percent != 0) {
- prop = icalproperty_new_percentcomplete( m_percent );
- icalcomponent_add_property( vtodo, prop );
- }
-
- //completed
- if( m_completed && !icaltime_is_null_time( m_completed->m_datetime ) ) {
- prop = icalproperty_new_completed( m_completed->m_datetime );
- icalcomponent_add_property( vtodo, prop );
- }
-
- //add event to newcalendar
- icalcomponent_add_component( newcalendar, vtodo );
-
- return newcalendar;
-}
-
-oeICalEventImpl *oeICalTodoImpl::GetBaseEvent() {
- return mEvent;
-}
-
-/* End of implementation class template. */
diff --git a/mozilla/calendar/libxpical/oeICalTodoImpl.h b/mozilla/calendar/libxpical/oeICalTodoImpl.h
deleted file mode 100644
index 99185af9d6e..00000000000
--- a/mozilla/calendar/libxpical/oeICalTodoImpl.h
+++ /dev/null
@@ -1,79 +0,0 @@
-/* ***** BEGIN LICENSE BLOCK *****
- * Version: MPL 1.1/GPL 2.0/LGPL 2.1
- *
- * The contents of this file are subject to the Mozilla Public License Version
- * 1.1 (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * Software distributed under the License is distributed on an "AS IS" basis,
- * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
- * for the specific language governing rights and limitations under the
- * License.
- *
- * The Original Code is Mozilla Calendar Code.
- *
- * The Initial Developer of the Original Code is
- * Chris Charabaruk .
- * Portions created by the Initial Developer are Copyright (C) 2001
- * the Initial Developer. All Rights Reserved.
- *
- * Contributor(s): Chris Charabaruk
- * Mostafa Hosseini
- *
- * Alternatively, the contents of this file may be used under the terms of
- * either the GNU General Public License Version 2 or later (the "GPL"), or
- * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
- * in which case the provisions of the GPL or the LGPL are applicable instead
- * of those above. If you wish to allow use of your version of this file only
- * under the terms of either the GPL or the LGPL, and not to allow others to
- * use your version of this file under the terms of the MPL, indicate your
- * decision by deleting the provisions above and replace them with the notice
- * and other provisions required by the GPL or the LGPL. If you do not delete
- * the provisions above, a recipient may use your version of this file under
- * the terms of any one of the MPL, the GPL or the LGPL.
- *
- * ***** END LICENSE BLOCK ***** */
-
- /* Header file for oeICalTodoImpl.cpp containing its CID and CONTRACTID.*/
-
-#ifndef _OEICALTODOIMPL_H_
-#define _OEICALTODOIMPL_H_
-
-#include "oeIICal.h"
-#include "oeDateTimeImpl.h"
-#include "nsISimpleEnumerator.h"
-#include "nsISupportsPrimitives.h"
-#include "nsSupportsPrimitives.h"
-
-extern "C" {
- #include "ical.h"
-}
-
-#define OE_ICALTODO_CID { 0x0c06905a, 0x1dd2, 0x11b2, { 0xba, 0x61, 0xc9, 0x5d, 0x84, 0x0b, 0x01, 0xef } }
-
-#define OE_ICALTODO_CONTRACTID "@mozilla.org/icaltodo;1"
-
-/* oeICalTodo Header file */
-class oeICalTodoImpl : public oeIICalTodo
-{
-public:
- NS_DECL_ISUPPORTS
- NS_FORWARD_OEIICALEVENT(mEvent->)
- NS_DECL_OEIICALTODO
-
- oeICalTodoImpl();
- virtual ~oeICalTodoImpl();
- /* additional members */
- bool ParseIcalComponent( icalcomponent *vcalendar );
- icalcomponent *AsIcalComponent();
- NS_IMETHOD Clone(oeIICalTodo **_retval);
- bool matchId( const char *id );
- oeICalEventImpl *GetBaseEvent();
-private:
- int m_percent;
- oeDateTimeImpl *m_completed;
- oeICalEventImpl *mEvent;
-};
-
-#endif
diff --git a/mozilla/calendar/libxpical/oeIICal.idl b/mozilla/calendar/libxpical/oeIICal.idl
deleted file mode 100644
index 7d4d8e270a1..00000000000
--- a/mozilla/calendar/libxpical/oeIICal.idl
+++ /dev/null
@@ -1,362 +0,0 @@
-/* ***** BEGIN LICENSE BLOCK *****
- * Version: MPL 1.1/GPL 2.0/LGPL 2.1
- *
- * The contents of this file are subject to the Mozilla Public License Version
- * 1.1 (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * Software distributed under the License is distributed on an "AS IS" basis,
- * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
- * for the specific language governing rights and limitations under the
- * License.
- *
- * The Original Code is OEone Calendar Code, released October 31st, 2001.
- *
- * The Initial Developer of the Original Code is
- * OEone Corporation.
- * Portions created by the Initial Developer are Copyright (C) 2001
- * the Initial Developer. All Rights Reserved.
- *
- * Contributor(s): Mostafa Hosseini
- * Chris Charabaruk
- * ArentJan Banck
- *
- * Alternatively, the contents of this file may be used under the terms of
- * either the GNU General Public License Version 2 or later (the "GPL"), or
- * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
- * in which case the provisions of the GPL or the LGPL are applicable instead
- * of those above. If you wish to allow use of your version of this file only
- * under the terms of either the GPL or the LGPL, and not to allow others to
- * use your version of this file under the terms of the MPL, indicate your
- * decision by deleting the provisions above and replace them with the notice
- * and other provisions required by the GPL or the LGPL. If you do not delete
- * the provisions above, a recipient may use your version of this file under
- * the terms of any one of the MPL, the GPL or the LGPL.
- *
- * ***** END LICENSE BLOCK ***** */
-
-/* The Interface Description of all calendar objects listing various fields and methods of each */
-
-#include "nsISupports.idl"
-#include "nsISupportsArray.idl"
-
-interface nsIAbCard;
-interface nsIMsgAttachment;
-interface nsISimpleEnumerator;
-
-/**
- * The uuid is a unique number identifying the interface normally
- * called IID. It can be generated as follows:
- *
- * Windows: guidgen.exe
- * Unix: uuidgen which comes with e2fsprogs package
- * Mac: ???
- * All platform: Using irc, connect to irc.mozilla.org and type in
- * /join #mozilla
- * /msg mozbot uuid
- *
- */
-
-typedef long eventMethodProperty;
-typedef long eventStatusProperty;
-typedef long Componenttype;
-
-interface oeIICal;
-
-[scriptable, uuid(db180127-cc56-40c6-a8ef-7e329e1c4142)]
-interface oeIDateTime : nsISupports
-{
- attribute short year;
- attribute short month;
- attribute short day;
- attribute short hour;
- attribute short minute;
- attribute boolean utc;
- readonly attribute string tzID;
- readonly attribute boolean isSet;
- PRTime getTime();
- void setTime( in PRTime ms );
- void setTimeInTimezone( in PRTime ms, in string tzID );
- string toString();
- void clear();
-};
-
-[scriptable, uuid(89c5cd5a-af2d-45e6-83c7-2f2420a13626)]
-interface oeIICalEvent : nsISupports
-{
- const eventMethodProperty ICAL_METHOD_X = 10011;
- const eventMethodProperty ICAL_METHOD_PUBLISH = 10012;
- const eventMethodProperty ICAL_METHOD_REQUEST = 10013;
- const eventStatusProperty ICAL_STATUS_X = 10028;
- const eventStatusProperty ICAL_STATUS_TENTATIVE = 10029;
- const eventStatusProperty ICAL_STATUS_CONFIRMED = 10030;
- const eventStatusProperty ICAL_STATUS_COMPLETED = 10031;
- const eventStatusProperty ICAL_STATUS_NEEDSACTION = 10032;
- const eventStatusProperty ICAL_STATUS_CANCELLED = 10033;
- const eventStatusProperty ICAL_STATUS_INPROCESS = 10034;
- const eventStatusProperty ICAL_STATUS_DRAFT = 10035;
- const eventStatusProperty ICAL_STATUS_FINAL = 10036;
- const eventStatusProperty ICAL_STATUS_NONE = 10037;
-
- const Componenttype XPICAL_VEVENT_COMPONENT = 4;
- const Componenttype XPICAL_VTODO_COMPONENT = 5;
-
- readonly attribute oeIDateTime start;
- readonly attribute oeIDateTime end;
- readonly attribute oeIDateTime stamp;
- attribute oeIICal parent;
- readonly attribute Componenttype type;
- readonly attribute PRTime lastModified;
-
- attribute string id;
- attribute AUTF8String title;
- attribute AUTF8String description;
- attribute AUTF8String location;
- attribute AUTF8String categories;
- attribute boolean privateEvent;
- attribute string syncId;
- attribute boolean allDay;
- attribute boolean alarm;
- attribute string alarmUnits;
- attribute unsigned long alarmLength;
- attribute string alarmEmailAddress;
- attribute string inviteEmailAddress;
- attribute unsigned long recurInterval;
- attribute unsigned long recurCount;
- readonly attribute oeIDateTime recurEnd;
- attribute boolean recur;
- attribute string recurUnits;
- attribute boolean recurForever;
- attribute short recurWeekdays;
- attribute short recurWeekNumber;
- attribute PRTime lastAlarmAck;
- attribute AUTF8String url;
- attribute short priority;
- attribute eventMethodProperty method;
- attribute eventStatusProperty status;
- void setDuration( in boolean is_negative, in unsigned short weeks, in unsigned short days, in unsigned short hours,
- in unsigned short minutes, in unsigned short seconds );
- void getDuration( out boolean is_negative, out unsigned short weeks, out unsigned short days, out unsigned short hours,
- out unsigned short minutes, out unsigned short seconds );
- boolean getNextRecurrence( in PRTime begin, out PRTime result);
- boolean getPreviousOccurrence( in PRTime beforethis, out PRTime result);
- AUTF8String getIcalString();
- boolean parseIcalString(in AUTF8String icalstr);
- void addException( in PRTime exdate );
- nsISimpleEnumerator getExceptions();
- void removeAllExceptions();
- void setSnoozeTime( in PRTime exdate );
- oeIICalEvent clone();
-
- //attachments
- readonly attribute nsISupportsArray attachmentsArray;
- void addAttachment(in nsIMsgAttachment attachment);
- void removeAttachment(in nsIMsgAttachment attachment);
- void removeAttachments();
-
- //contacts
- readonly attribute nsISupportsArray contactsArray;
- void addContact(in nsIAbCard contact);
- void removeContact(in nsIAbCard contact);
- void removeContacts();
-
- void reportError( in short severity, in unsigned long errorid, in string errorstring );
- void setParameter( in string name, in string value );
- string getParameter( in string name );
-
- void updateLastModified();
-};
-
-[scriptable, uuid(f95df40e-0d5f-49ec-9ba8-4b88d3eb53e0)]
-interface oeIICalEventDisplay : oeIICalEvent
-{
- readonly attribute oeIICalEvent event;
- attribute PRTime displayDate;
- attribute PRTime displayEndDate;
-};
-
-[scriptable, uuid(d44987b4-1dd1-11b2-9783-8a78ed685caf)]
-interface oeIICalTodo : oeIICalEvent
-{
- readonly attribute oeIDateTime due;
- readonly attribute oeIDateTime completed;
- attribute short percent;
- AUTF8String getTodoIcalString();
- boolean parseTodoIcalString(in AUTF8String icalstr);
-};
-
-[scriptable, uuid(b8584baa-1507-40d4-b542-5a2758e1c86d)]
-interface oeIICalObserver : nsISupports
-{
- void onStartBatch();
- void onEndBatch();
- void onLoad();
- void onAddItem( in oeIICalEvent e);
- void onModifyItem( in oeIICalEvent e, in oeIICalEvent olde );
- void onDeleteItem( in oeIICalEvent e);
- void onAlarm( in oeIICalEventDisplay e);
- void onError( in short severity, in unsigned long errorid, in string errorstring );
-};
-
-[scriptable, uuid(7a4fd625-69a8-4008-932e-cccc227b402c)]
-interface oeIICalTodoObserver : nsISupports
-{
- void onStartBatch();
- void onEndBatch();
- void onLoad();
- void onAddItem( in oeIICalTodo e);
- void onModifyItem( in oeIICalTodo e, in oeIICalTodo olde );
- void onDeleteItem( in oeIICalTodo e);
- void onAlarm( in oeIICalEventDisplay e);
- void onError( in short severity, in unsigned long errorid, in string errorstring );
-};
-
-[scriptable, uuid(981ab93d-ad51-45bb-a4a2-e158c2cfdeb4)]
-interface oeIICal : nsISupports
-{
- void Test();
-
- attribute boolean batchMode;
- readonly attribute oeIICalTodo filter;
- attribute AUTF8String server;
- attribute boolean suppressAlarms;
-
- void addObserver( in oeIICalObserver observer );
- void removeObserver( in oeIICalObserver observer );
- void addTodoObserver( in oeIICalTodoObserver observer );
- void removeTodoObserver( in oeIICalTodoObserver observer );
- string addEvent( in oeIICalEvent icalevent );
- string modifyEvent( in oeIICalEvent icalevent );
- void deleteEvent( in string id );
- oeIICalEvent fetchEvent( in string id );
-// nsISimpleEnumerator searchBySQL( in string sqlstr );
-
- /**
- *
- * GetAllEvents
- *
- * DESCRIPTION: Returns a list of all the events in this calendar in an enumerator.
- * The events are sorted based on the order of their next occurence if they recur in
- * the future or their last occurence in the past otherwise.
- * Here's a presentation of the sort criteria using the time axis:
- * -----(Last occurence of Event1)---(Last occurence of Event2)----(Now)----(Next occurence of Event3)---->
- * (Note that Event1 and Event2 will not recur in the future.)
- */
- nsISimpleEnumerator getAllEvents();
-
- /**
- * For all the getEvents* and get*EventForRange methods:
- * Get events for a certain range. items are oeIICalEventDisplay
- */
- nsISimpleEnumerator getEventsForMonth( in PRTime date );
- nsISimpleEnumerator getEventsForWeek( in PRTime date );
- nsISimpleEnumerator getEventsForDay( in PRTime date );
- nsISimpleEnumerator getEventsForRange( in PRTime begindate, in PRTime enddate );
-
- nsISimpleEnumerator getNextNEvents( in PRTime begindate, in long count );
- nsISimpleEnumerator getFirstEventsForRange( in PRTime begindate, in PRTime enddate );
-
- string addTodo( in oeIICalTodo icaltodo );
- string modifyTodo( in oeIICalTodo icaltodo );
- void deleteTodo( in string id );
- oeIICalTodo fetchTodo( in string id );
- nsISimpleEnumerator getAllTodos();
-
- void resetFilter();
- void reportError( in short severity, in unsigned long errorid, in string errorstring );
-};
-
-[scriptable, uuid(c89ec938-f690-4f62-a4b3-11e962ba2314)]
-interface oeIICalContainer : nsISupports
-{
- attribute boolean batchMode;
- attribute boolean suppressAlarmsByDefault;
- readonly attribute oeIICalTodo filter;
-
-
- /**
- * Add a calendar to the container.
- * @param server
- * a string indicating the server url
- * @param type
- * a string idicating which type of calendar to add.
- * an object with contractid of @mozilla.org/ical;1?type=
- * will be created and added. The object should implement
- * oeIICal.
- * When empty, @mozilla.org/ical;1 will be used
- */
- void addCalendar( in AUTF8String server, in string type );
-
- void removeCalendar( in AUTF8String server );
- oeIICal getCalendar( in AUTF8String server );
- void addCalendars( in unsigned long serverCount, [array, size_is(serverCount)] in wstring servers );
- void addObserver( in oeIICalObserver observer );
- void removeObserver( in oeIICalObserver observer );
- void addTodoObserver( in oeIICalTodoObserver observer );
- void removeTodoObserver( in oeIICalTodoObserver observer );
- string addEvent( in oeIICalEvent icalevent, in AUTF8String server );
- string modifyEvent( in oeIICalEvent icalevent );
- void deleteEvent( in string id );
- oeIICalEvent fetchEvent( in string id );
-
- nsISimpleEnumerator getAllEvents();
- /**
- * For all the getEvents* and get*EventForRange methods:
- * Get events for a certain range. items are oeIICalEventDisplay
- */
- nsISimpleEnumerator getEventsForMonth( in PRTime date );
- /**
- * Get the events starting at the beginning of |date|
- * until 7 days later
- */
- nsISimpleEnumerator getEventsForWeek( in PRTime date );
- nsISimpleEnumerator getEventsForDay( in PRTime date );
- nsISimpleEnumerator getEventsForRange( in PRTime begindate, in PRTime enddate );
- nsISimpleEnumerator getNextNEvents( in PRTime begindate, in long count );
-
- /**
- * Get the first occurence of the events in the given time range
- */
- nsISimpleEnumerator getFirstEventsForRange( in PRTime begindate, in PRTime enddate );
-
- string addTodo( in oeIICalTodo icaltodo, in AUTF8String server );
- string modifyTodo( in oeIICalTodo icaltodo );
- void deleteTodo( in string id );
- oeIICalTodo fetchTodo( in string id );
- nsISimpleEnumerator getAllTodos();
-
- void resetFilter();
- void reportError( in short severity, in unsigned long errorid, in string errorstring );
-};
-
-[scriptable, uuid(0d42d962-e5fd-428b-b622-867928c9b669)]
-interface oeIICalError : nsISupports
-{
- //severity codes
- const long CAL_DEBUG = 0;
- const long CAL_WARN = 1;
- const long CAL_PROBLEM = 2;
- const long CAL_CRITICAL = 3;
-
- //error codes
- const long UID_NOT_FOUND = 1001;
-};
-
-%{ C++
-extern nsresult
-NS_NewICal(oeIICal** inst);
-extern nsresult
-NS_NewICalEvent(oeIICalEvent** inst);
-extern nsresult
-NS_NewICalTodo(oeIICalTodo** inst);
-extern nsresult
-NS_NewDateTime(oeIDateTime** inst);
-extern nsresult
-NS_NewICalEventDisplay( oeIICalEvent* event, oeIICalEventDisplay** inst );
-
-#define GENERATE_CAL_FAILURE(x) \
- (NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_CALENDAR,x))
-#define NS_ERROR_CAL_UID_NOT_FOUND \
- GENERATE_CAL_FAILURE(oeIICalError::UID_NOT_FOUND)
-%}
diff --git a/mozilla/calendar/libxpical/tests/Makefile.in b/mozilla/calendar/libxpical/tests/Makefile.in
deleted file mode 100644
index c17c225dfde..00000000000
--- a/mozilla/calendar/libxpical/tests/Makefile.in
+++ /dev/null
@@ -1,58 +0,0 @@
-#
-# ***** BEGIN LICENSE BLOCK *****
-# Version: MPL 1.1/GPL 2.0/LGPL 2.1
-#
-# The contents of this file are subject to the Mozilla Public License Version
-# 1.1 (the "License"); you may not use this file except in compliance with
-# the License. You may obtain a copy of the License at
-# http://www.mozilla.org/MPL/
-#
-# Software distributed under the License is distributed on an "AS IS" basis,
-# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
-# for the specific language governing rights and limitations under the
-# License.
-#
-# The Original Code is mozilla.org code.
-#
-# The Initial Developer of the Original Code is
-# Netscape Communications Corporation.
-# Portions created by the Initial Developer are Copyright (C) 1998
-# the Initial Developer. All Rights Reserved.
-#
-# Contributor(s):
-#
-# Alternatively, the contents of this file may be used under the terms of
-# either of the GNU General Public License Version 2 or later (the "GPL"),
-# or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
-# in which case the provisions of the GPL or the LGPL are applicable instead
-# of those above. If you wish to allow use of your version of this file only
-# under the terms of either the GPL or the LGPL, and not to allow others to
-# use your version of this file under the terms of the MPL, indicate your
-# decision by deleting the provisions above and replace them with the notice
-# and other provisions required by the GPL or the LGPL. If you do not delete
-# the provisions above, a recipient may use your version of this file under
-# the terms of any one of the MPL, the GPL or the LGPL.
-#
-# ***** END LICENSE BLOCK *****
-
-DEPTH = ../../..
-topsrcdir = @top_srcdir@
-srcdir = @srcdir@
-VPATH = @srcdir@
-
-include $(DEPTH)/config/autoconf.mk
-
-MOZILLA_INTERNAL_API = 1
-
-REQUIRES = xpcom \
- calendar \
- string \
- $(NULL)
-
-PROGRAM = TestIcal$(BIN_SUFFIX)
-
-CPPSRCS = TestIcal.cpp
-
-LIBS = $(MOZ_COMPONENT_LIBS)
-
-include $(topsrcdir)/config/rules.mk
diff --git a/mozilla/calendar/libxpical/tests/TestIcal.cpp b/mozilla/calendar/libxpical/tests/TestIcal.cpp
deleted file mode 100644
index e0544076266..00000000000
--- a/mozilla/calendar/libxpical/tests/TestIcal.cpp
+++ /dev/null
@@ -1,86 +0,0 @@
-/* ***** BEGIN LICENSE BLOCK *****
- * Version: MPL 1.1/GPL 2.0/LGPL 2.1
- *
- * The contents of this file are subject to the Mozilla Public License Version
- * 1.1 (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * Software distributed under the License is distributed on an "AS IS" basis,
- * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
- * for the specific language governing rights and limitations under the
- * License.
- *
- * The Original Code is OEone Calendar Code, released October 31st, 2001.
- *
- * The Initial Developer of the Original Code is
- * OEone Corporation.
- * Portions created by the Initial Developer are Copyright (C) 2001
- * the Initial Developer. All Rights Reserved.
- *
- * Contributor(s): Mostafa Hosseini
- *
- * Alternatively, the contents of this file may be used under the terms of
- * either the GNU General Public License Version 2 or later (the "GPL"), or
- * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
- * in which case the provisions of the GPL or the LGPL are applicable instead
- * of those above. If you wish to allow use of your version of this file only
- * under the terms of either the GPL or the LGPL, and not to allow others to
- * use your version of this file under the terms of the MPL, indicate your
- * decision by deleting the provisions above and replace them with the notice
- * and other provisions required by the GPL or the LGPL. If you do not delete
- * the provisions above, a recipient may use your version of this file under
- * the terms of any one of the MPL, the GPL or the LGPL.
- *
- * ***** END LICENSE BLOCK ***** */
-
-
-#include
-#include
-#include "nsString.h"
-#include "nsIComponentRegistrar.h"
-
-#include "stdio.h"
-
-#define OE_ICAL_CONTRACTID "@mozilla.org/ical;1"
-
-int
-main(PRInt32 argc, char *argv[])
-{
- nsresult rv;
-
- nsCOMPtr servMan;
- NS_InitXPCOM2(getter_AddRefs(servMan), nsnull, nsnull);
- nsCOMPtr registrar = do_QueryInterface(servMan);
- NS_ASSERTION(registrar, "Null nsIComponentRegistrar");
- registrar->AutoRegister(nsnull);
-
- // Create an instance of our component
- nsCOMPtr mysample = do_CreateInstance(OE_ICAL_CONTRACTID, &rv);
- if (NS_FAILED(rv))
- {
- printf("ERROR: Cannot create instance of component " OE_ICAL_CONTRACTID " [%x].\n"
- "Debugging hint:\n"
- "\tsetenv NSPR_LOG_MODULES nsComponentManager:5\n"
- "\tsetenv NSPR_LOG_FILE xpcom.log\n"
- "\t./TestICal\n"
- "\t.\n",
- rv);
- return -2;
- }
-
- mysample->SetServer( NS_LITERAL_CSTRING("/tmp/.oecalendar") );
- rv = mysample->Test();
-
- if ( NS_FAILED(rv) )
- {
- printf("ERROR: Calling oeIICal::Test()\n");
- return 0;
- }
-
- printf("Test finished\n");
-
- // Shutdown XPCOM
- NS_ShutdownXPCOM(nsnull);
- return 0;
-}
diff --git a/mozilla/calendar/libxpical/token.c b/mozilla/calendar/libxpical/token.c
deleted file mode 100644
index 5b9a07adc0f..00000000000
--- a/mozilla/calendar/libxpical/token.c
+++ /dev/null
@@ -1,360 +0,0 @@
-/*
-** Copyright (C) 1998-1999 Greg Stein. All Rights Reserved.
-**
-** By using this file, you agree to the terms and conditions set forth in
-** the LICENSE.html file which can be found at the top level of the mod_dav
-** distribution or at http://www.webdav.org/mod_dav/license-1.html.
-**
-** Contact information:
-** Greg Stein, PO Box 3151, Redmond, WA, 98073
-** gstein@lyra.org, http://www.webdav.org/mod_dav/
-*/
-
-/*
-** DAV opaquelocktoken scheme implementation
-**
-** Written 5/99 by Keith Wannamaker, wannamak@us.ibm.com
-** Adapted from ISO/DCE RPC spec and a former Internet Draft
-** by Leach and Salz:
-** http://www.ics.uci.edu/pub/ietf/webdav/uuid-guid/draft-leach-uuids-guids-01
-**
-** Portions of the code are covered by the following license:
-**
-** Copyright (c) 1990- 1993, 1996 Open Software Foundation, Inc.
-** Copyright (c) 1989 by Hewlett-Packard Company, Palo Alto, Ca. &
-** Digital Equipment Corporation, Maynard, Mass.
-** Copyright (c) 1998 Microsoft.
-** To anyone who acknowledges that this file is provided "AS IS"
-** without any express or implied warranty: permission to use, copy,
-** modify, and distribute this file for any purpose is hereby
-** granted without fee, provided that the above copyright notices and
-** this notice appears in all source code copies, and that none of
-** the names of Open Software Foundation, Inc., Hewlett-Packard
-** Company, or Digital Equipment Corporation be used in advertising
-** or publicity pertaining to distribution of the software without
-** specific, written prior permission. Neither Open Software
-** Foundation, Inc., Hewlett-Packard Company, Microsoft, nor Digital Equipment
-** Corporation makes any representations about the suitability of
-** this software for any purpose.
-*/
-
-/*This file was stolen from webtools/mozbot/uuidgen/token.c */
-
-#include
-#include
-#include
-#include
-#include
-
-#include "md5.h"
-#include "token.h"
-
-#ifdef WIN32
-#include
-#else
-#include
-#include
-#include
-#ifdef XP_BEOS
-#include
-#endif
-#endif
-
-/* set the following to the number of 100ns ticks of the actual resolution of
- your system's clock */
-#define UUIDS_PER_TICK 1024
-
-/* Set this to what your compiler uses for 64 bit data type */
-#ifdef WIN32
-#define unsigned64_t unsigned __int64
-#define I64(C) C
-#else
-#define unsigned64_t unsigned long long
-#define I64(C) C##LL
-#endif
-
-typedef unsigned64_t uuid_time_t;
-
-static void format_uuid_v1(uuid_t * uuid, unsigned16 clockseq, uuid_time_t timestamp, uuid_node_t node);
-static void get_current_time(uuid_time_t * timestamp);
-static unsigned16 true_random(void);
-static void get_pseudo_node_identifier(uuid_node_t *node);
-static void get_system_time(uuid_time_t *uuid_time);
-static void get_random_info(unsigned char seed[16]);
-
-
-/* dav_create_opaquelocktoken - generates a UUID version 1 token.
- * Clock_sequence and node_address set to pseudo-random
- * numbers during init.
- *
- * Should postpend pid to account for non-seralized creation?
- */
-int create_token(uuid_state *st, uuid_t *u)
-{
- uuid_time_t timestamp;
-
- get_current_time(×tamp);
- format_uuid_v1(u, st->cs, timestamp, st->node);
-
- return 1;
-}
-
-/*
- * dav_create_uuid_state - seed UUID state with pseudorandom data
- */
-void create_uuid_state(uuid_state *st)
-{
- st->cs = true_random();
- get_pseudo_node_identifier(&st->node);
-}
-
-/*
- * dav_format_opaquelocktoken - generates a text representation
- * of an opaquelocktoken
- */
-void format_token(char *target, const uuid_t *u)
-{
- sprintf(target, "%08lx-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x",
- u->time_low, u->time_mid, u->time_hi_and_version,
- u->clock_seq_hi_and_reserved, u->clock_seq_low,
- u->node[0], u->node[1], u->node[2],
- u->node[3], u->node[4], u->node[5]);
-}
-
-/* convert a pair of hex digits to an integer value [0,255] */
-static int dav_parse_hexpair(const char *s)
-{
- int result;
- int temp;
-
- result = s[0] - '0';
- if (result > 48)
- result = (result - 39) << 4;
- else if (result > 16)
- result = (result - 7) << 4;
- else
- result = result << 4;
-
- temp = s[1] - '0';
- if (temp > 48)
- result |= temp - 39;
- else if (temp > 16)
- result |= temp - 7;
- else
- result |= temp;
-
- return result;
-}
-
-/* dav_parse_locktoken: Parses string produced from
- * dav_format_opaquelocktoken back into a uuid_t
- * structure. On failure, return DAV_IF_ERROR_PARSE,
- * else DAV_IF_ERROR_NONE.
- */
-int parse_token(const char *char_token, uuid_t *bin_token)
-{
- int i;
-
- for (i = 0; i < 36; ++i) {
- char c = char_token[i];
- if (!isxdigit(c) &&
- !(c == '-' && (i == 8 || i == 13 || i == 18 || i == 23)))
- return -1;
- }
- if (char_token[36] != '\0')
- return -1;
-
- bin_token->time_low =
- (dav_parse_hexpair(&char_token[0]) << 24) |
- (dav_parse_hexpair(&char_token[2]) << 16) |
- (dav_parse_hexpair(&char_token[4]) << 8) |
- dav_parse_hexpair(&char_token[6]);
-
- bin_token->time_mid =
- (dav_parse_hexpair(&char_token[9]) << 8) |
- dav_parse_hexpair(&char_token[11]);
-
- bin_token->time_hi_and_version =
- (dav_parse_hexpair(&char_token[14]) << 8) |
- dav_parse_hexpair(&char_token[16]);
-
- bin_token->clock_seq_hi_and_reserved = dav_parse_hexpair(&char_token[19]);
- bin_token->clock_seq_low = dav_parse_hexpair(&char_token[21]);
-
- for (i = 6; i--;)
- bin_token->node[i] = dav_parse_hexpair(&char_token[i*2+24]);
-
- return -1;
-}
-
-/* dav_compare_opaquelocktoken:
- * < 0 : a < b
- * == 0 : a = b
- * > 0 : a > b
- */
-int compare_token(const uuid_t a, const uuid_t b)
-{
- return memcmp(&a, &b, sizeof(uuid_t));
-}
-
-/* format_uuid_v1 -- make a UUID from the timestamp, clockseq, and node ID */
-static void format_uuid_v1(uuid_t * uuid, unsigned16 clock_seq,
- uuid_time_t timestamp, uuid_node_t node)
-{
- /* Construct a version 1 uuid with the information we've gathered
- * plus a few constants. */
- uuid->time_low = (unsigned long)(timestamp & 0xFFFFFFFF);
- uuid->time_mid = (unsigned short)((timestamp >> 32) & 0xFFFF);
- uuid->time_hi_and_version = (unsigned short)((timestamp >> 48) & 0x0FFF);
- uuid->time_hi_and_version |= (1 << 12);
- uuid->clock_seq_low = clock_seq & 0xFF;
- uuid->clock_seq_hi_and_reserved = (clock_seq & 0x3F00) >> 8;
- uuid->clock_seq_hi_and_reserved |= 0x80;
- memcpy(&uuid->node, &node, sizeof uuid->node);
-}
-
-/* get-current_time -- get time as 60 bit 100ns ticks since whenever.
- Compensate for the fact that real clock resolution is less than 100ns. */
-static void get_current_time(uuid_time_t * timestamp)
-{
- uuid_time_t time_now;
- static uuid_time_t time_last;
- static unsigned16 uuids_this_tick;
- static int inited = 0;
-
- if (!inited) {
- get_system_time(&time_now);
- uuids_this_tick = UUIDS_PER_TICK;
- inited = 1;
- };
-
- while (1) {
- get_system_time(&time_now);
-
- /* if clock reading changed since last UUID generated... */
- if (time_last != time_now) {
- /* reset count of uuids gen'd with this clock reading */
- uuids_this_tick = 0;
- break;
- };
- if (uuids_this_tick < UUIDS_PER_TICK) {
- uuids_this_tick++;
- break;
- }; /* going too fast for our clock; spin */
- }; /* add the count of uuids to low order bits of the clock reading */
-
- *timestamp = time_now + uuids_this_tick;
-}
-
-/* true_random -- generate a crypto-quality random number.
- This sample doesn't do that. */
-static unsigned16 true_random(void)
-{
- uuid_time_t time_now;
-
- get_system_time(&time_now);
- time_now = time_now/UUIDS_PER_TICK;
- srand((unsigned int)(((time_now >> 32) ^ time_now)&0xffffffff));
-
- return rand();
-}
-
-/* This sample implementation generates a random node ID *
- * in lieu of a system dependent call to get IEEE node ID. */
-static void get_pseudo_node_identifier(uuid_node_t *node)
-{
- unsigned char seed[16];
-
- get_random_info(seed);
- seed[0] |= 0x80;
- memcpy(node, seed, sizeof(*node));
-}
-
-/* system dependent call to get the current system time.
- Returned as 100ns ticks since Oct 15, 1582, but resolution may be
- less than 100ns. */
-
-#ifdef WIN32
-
-static void get_system_time(uuid_time_t *uuid_time)
-{
- ULARGE_INTEGER time;
-
- GetSystemTimeAsFileTime((FILETIME *)&time);
-
- /* NT keeps time in FILETIME format which is 100ns ticks since
- Jan 1, 1601. UUIDs use time in 100ns ticks since Oct 15, 1582.
- The difference is 17 Days in Oct + 30 (Nov) + 31 (Dec)
- + 18 years and 5 leap days. */
-
- time.QuadPart +=
- (unsigned __int64) (1000*1000*10)
- * (unsigned __int64) (60 * 60 * 24)
- * (unsigned __int64) (17+30+31+365*18+5);
- *uuid_time = time.QuadPart;
-}
-
-static void get_random_info(unsigned char seed[16])
-{
- MD5_CTX c;
- struct {
- MEMORYSTATUS m;
- SYSTEM_INFO s;
- FILETIME t;
- LARGE_INTEGER pc;
- DWORD tc;
- DWORD l;
- char hostname[MAX_COMPUTERNAME_LENGTH + 1];
-
- } r;
-
- MD5Init(&c); /* memory usage stats */
- GlobalMemoryStatus(&r.m); /* random system stats */
- GetSystemInfo(&r.s); /* 100ns resolution (nominally) time of day */
- GetSystemTimeAsFileTime(&r.t); /* high resolution performance counter */
- QueryPerformanceCounter(&r.pc); /* milliseconds since last boot */
- r.tc = GetTickCount();
- r.l = MAX_COMPUTERNAME_LENGTH + 1;
-
- GetComputerName(r.hostname, &r.l );
- MD5Update(&c, (const unsigned char *) &r, sizeof(r));
- MD5Final(seed, &c);
-}
-
-#else /* WIN32 */
-
-static void get_system_time(uuid_time_t *uuid_time)
-{
- struct timeval tp;
-
- gettimeofday(&tp, (struct timezone *)0);
-
- /* Offset between UUID formatted times and Unix formatted times.
- UUID UTC base time is October 15, 1582.
- Unix base time is January 1, 1970. */
- *uuid_time = (tp.tv_sec * 10000000) + (tp.tv_usec * 10) +
- I64(0x01B21DD213814000);
-}
-
-static void get_random_info(unsigned char seed[16])
-{
- MD5_CTX c;
- /* Leech & Salz use Linux-specific struct sysinfo;
- * replace with pid/tid for portability (in the spirit of mod_unique_id) */
- struct {
- /* Add thread id here, if applicable, when we get to pthread or apr */
- pid_t pid;
- struct timeval t;
- char hostname[257];
-
- } r;
-
- MD5Init(&c);
- r.pid = getpid();
- gettimeofday(&r.t, (struct timezone *)0);
- gethostname(r.hostname, 256);
- MD5Update(&c, (unsigned char *)&r, sizeof(r));
- MD5Final(seed, &c);
-}
-
-#endif /* WIN32 */
diff --git a/mozilla/calendar/libxpical/token.h b/mozilla/calendar/libxpical/token.h
deleted file mode 100644
index 07bdc07d9cf..00000000000
--- a/mozilla/calendar/libxpical/token.h
+++ /dev/null
@@ -1,82 +0,0 @@
-/*
-** Copyright (C) 1998-1999 Greg Stein. All Rights Reserved.
-**
-** By using this file, you agree to the terms and conditions set forth in
-** the LICENSE.html file which can be found at the top level of the mod_dav
-** distribution or at http://www.webdav.org/mod_dav/license-1.html.
-**
-** Contact information:
-** Greg Stein, PO Box 3151, Redmond, WA, 98073
-** gstein@lyra.org, http://www.webdav.org/mod_dav/
-*/
-
-/*
-** DAV opaquelocktoken scheme implementation
-**
-** Written 5/99 by Keith Wannamaker, wannamak@us.ibm.com
-** Adapted from ISO/DCE RPC spec and a former Internet Draft
-** by Leach and Salz:
-** http://www.ics.uci.edu/pub/ietf/webdav/uuid-guid/draft-leach-uuids-guids-01
-**
-** Portions of the code are covered by the following license:
-**
-** Copyright (c) 1990- 1993, 1996 Open Software Foundation, Inc.
-** Copyright (c) 1989 by Hewlett-Packard Company, Palo Alto, Ca. &
-** Digital Equipment Corporation, Maynard, Mass.
-** Copyright (c) 1998 Microsoft.
-** To anyone who acknowledges that this file is provided "AS IS"
-** without any express or implied warranty: permission to use, copy,
-** modify, and distribute this file for any purpose is hereby
-** granted without fee, provided that the above copyright notices and
-** this notice appears in all source code copies, and that none of
-** the names of Open Software Foundation, Inc., Hewlett-Packard
-** Company, or Digital Equipment Corporation be used in advertising
-** or publicity pertaining to distribution of the software without
-** specific, written prior permission. Neither Open Software
-** Foundation, Inc., Hewlett-Packard Company, Microsoft, nor Digital Equipment
-** Corporation makes any representations about the suitability of
-** this software for any purpose.
-*/
-
-/*This file was stolen from webtools/mozbot/uuidgen/token.h */
-
-#ifndef _TOKEN_H_
-#define _TOKEN_H_
-
-typedef unsigned long unsigned32;
-typedef unsigned short unsigned16;
-typedef unsigned char unsigned8;
-
-typedef struct {
- char nodeID[6];
-} uuid_node_t;
-
-#undef uuid_t
-
-typedef struct _uuid_t
-{
- unsigned32 time_low;
- unsigned16 time_mid;
- unsigned16 time_hi_and_version;
- unsigned8 clock_seq_hi_and_reserved;
- unsigned8 clock_seq_low;
- unsigned8 node[6];
-} uuid_t;
-
-/* data type for UUID generator persistent state */
-
-typedef struct {
- uuid_node_t node; /* saved node ID */
- unsigned16 cs; /* saved clock sequence */
-} uuid_state;
-
-extern const uuid_t null_locktoken;
-
-/* in dav_opaquelock.c */
-int create_token(uuid_state *st, uuid_t *u);
-void create_uuid_state(uuid_state *st);
-void format_token(char *target, const uuid_t *u);
-int compare_token(const uuid_t a, const uuid_t b);
-int parse_token(const char *char_token, uuid_t *bin_token);
-
-#endif /* _TOKEN_H_ */