Removed using seperate object for getting display dates. Using EventDisplay object instead.

This commit is contained in:
mostafah%oeone.com 2002-12-06 20:31:20 +00:00
parent 31487cb0c9
commit 22c287e6fc
6 changed files with 101 additions and 163 deletions

View File

@ -418,7 +418,7 @@ oeICalContainerImpl::GetAllEvents(nsISimpleEnumerator **resultList )
} }
NS_IMETHODIMP NS_IMETHODIMP
oeICalContainerImpl::GetEventsForMonth( PRTime datems, nsISimpleEnumerator **datelist, nsISimpleEnumerator **eventlist ) { oeICalContainerImpl::GetEventsForMonth( PRTime datems, nsISimpleEnumerator **eventlist ) {
#ifdef ICAL_DEBUG #ifdef ICAL_DEBUG
printf( "oeICalContainerImpl::GetEventsForMonth()\n" ); printf( "oeICalContainerImpl::GetEventsForMonth()\n" );
#endif #endif
@ -427,13 +427,7 @@ oeICalContainerImpl::GetEventsForMonth( PRTime datems, nsISimpleEnumerator **dat
if (!eventEnum) if (!eventEnum)
return NS_ERROR_OUT_OF_MEMORY; return NS_ERROR_OUT_OF_MEMORY;
nsCOMPtr<oeDateEnumerator> dateEnum = new oeDateEnumerator( );
if (!dateEnum)
return NS_ERROR_OUT_OF_MEMORY;
eventEnum->QueryInterface(NS_GET_IID(nsISimpleEnumerator), (void **)eventlist); eventEnum->QueryInterface(NS_GET_IID(nsISimpleEnumerator), (void **)eventlist);
dateEnum->QueryInterface(NS_GET_IID(nsISimpleEnumerator), (void **)datelist);
PRUint32 num; PRUint32 num;
unsigned int i; unsigned int i;
@ -443,14 +437,14 @@ oeICalContainerImpl::GetEventsForMonth( PRTime datems, nsISimpleEnumerator **dat
{ {
oeIICal* calendar; oeIICal* calendar;
m_calendarArray->GetElementAt( i, (nsISupports **)&calendar ); m_calendarArray->GetElementAt( i, (nsISupports **)&calendar );
calendar->GetEventsForMonth( datems, (nsISimpleEnumerator **)&dateEnum, (nsISimpleEnumerator **)&eventEnum ); calendar->GetEventsForMonth( datems, (nsISimpleEnumerator **)&eventEnum );
} }
return NS_OK; return NS_OK;
} }
NS_IMETHODIMP NS_IMETHODIMP
oeICalContainerImpl::GetEventsForWeek( PRTime datems, nsISimpleEnumerator **datelist, nsISimpleEnumerator **eventlist ) { oeICalContainerImpl::GetEventsForWeek( PRTime datems, nsISimpleEnumerator **eventlist ) {
#ifdef ICAL_DEBUG #ifdef ICAL_DEBUG
printf( "oeICalContainerImpl::GetEventsForWeek()\n" ); printf( "oeICalContainerImpl::GetEventsForWeek()\n" );
#endif #endif
@ -459,13 +453,7 @@ oeICalContainerImpl::GetEventsForWeek( PRTime datems, nsISimpleEnumerator **date
if (!eventEnum) if (!eventEnum)
return NS_ERROR_OUT_OF_MEMORY; return NS_ERROR_OUT_OF_MEMORY;
nsCOMPtr<oeDateEnumerator> dateEnum = new oeDateEnumerator( );
if (!dateEnum)
return NS_ERROR_OUT_OF_MEMORY;
eventEnum->QueryInterface(NS_GET_IID(nsISimpleEnumerator), (void **)eventlist); eventEnum->QueryInterface(NS_GET_IID(nsISimpleEnumerator), (void **)eventlist);
dateEnum->QueryInterface(NS_GET_IID(nsISimpleEnumerator), (void **)datelist);
PRUint32 num; PRUint32 num;
unsigned int i; unsigned int i;
@ -475,13 +463,13 @@ oeICalContainerImpl::GetEventsForWeek( PRTime datems, nsISimpleEnumerator **date
{ {
oeIICal* calendar; oeIICal* calendar;
m_calendarArray->GetElementAt( i, (nsISupports **)&calendar ); m_calendarArray->GetElementAt( i, (nsISupports **)&calendar );
calendar->GetEventsForWeek( datems, (nsISimpleEnumerator **)&dateEnum, (nsISimpleEnumerator **)&eventEnum ); calendar->GetEventsForWeek( datems, (nsISimpleEnumerator **)&eventEnum );
} }
return NS_OK; return NS_OK;
} }
NS_IMETHODIMP NS_IMETHODIMP
oeICalContainerImpl::GetEventsForDay( PRTime datems, nsISimpleEnumerator **datelist, nsISimpleEnumerator **eventlist ) { oeICalContainerImpl::GetEventsForDay( PRTime datems, nsISimpleEnumerator **eventlist ) {
#ifdef ICAL_DEBUG #ifdef ICAL_DEBUG
printf( "oeICalContainerImpl::GetEventsForDay()\n" ); printf( "oeICalContainerImpl::GetEventsForDay()\n" );
#endif #endif
@ -491,13 +479,7 @@ oeICalContainerImpl::GetEventsForDay( PRTime datems, nsISimpleEnumerator **datel
if (!eventEnum) if (!eventEnum)
return NS_ERROR_OUT_OF_MEMORY; return NS_ERROR_OUT_OF_MEMORY;
nsCOMPtr<oeDateEnumerator> dateEnum = new oeDateEnumerator( );
if (!dateEnum)
return NS_ERROR_OUT_OF_MEMORY;
eventEnum->QueryInterface(NS_GET_IID(nsISimpleEnumerator), (void **)eventlist); eventEnum->QueryInterface(NS_GET_IID(nsISimpleEnumerator), (void **)eventlist);
dateEnum->QueryInterface(NS_GET_IID(nsISimpleEnumerator), (void **)datelist);
PRUint32 num; PRUint32 num;
unsigned int i; unsigned int i;
@ -507,13 +489,13 @@ oeICalContainerImpl::GetEventsForDay( PRTime datems, nsISimpleEnumerator **datel
{ {
oeIICal* calendar; oeIICal* calendar;
m_calendarArray->GetElementAt( i, (nsISupports **)&calendar ); m_calendarArray->GetElementAt( i, (nsISupports **)&calendar );
calendar->GetEventsForDay( datems, (nsISimpleEnumerator **)&dateEnum, (nsISimpleEnumerator **)&eventEnum ); calendar->GetEventsForDay( datems, (nsISimpleEnumerator **)&eventEnum );
} }
return NS_OK; return NS_OK;
} }
NS_IMETHODIMP NS_IMETHODIMP
oeICalContainerImpl::GetEventsForRange( PRTime checkdateinms, PRTime checkenddateinms, nsISimpleEnumerator **datelist, nsISimpleEnumerator **eventlist ) { oeICalContainerImpl::GetEventsForRange( PRTime checkdateinms, PRTime checkenddateinms, nsISimpleEnumerator **eventlist ) {
#ifdef ICAL_DEBUG_ALL #ifdef ICAL_DEBUG_ALL
printf( "oeICalContainerImpl::GetEventsForRange()\n" ); printf( "oeICalContainerImpl::GetEventsForRange()\n" );
#endif #endif
@ -523,13 +505,7 @@ oeICalContainerImpl::GetEventsForRange( PRTime checkdateinms, PRTime checkenddat
if (!eventEnum) if (!eventEnum)
return NS_ERROR_OUT_OF_MEMORY; return NS_ERROR_OUT_OF_MEMORY;
nsCOMPtr<oeDateEnumerator> dateEnum = new oeDateEnumerator( );
if (!dateEnum)
return NS_ERROR_OUT_OF_MEMORY;
eventEnum->QueryInterface(NS_GET_IID(nsISimpleEnumerator), (void **)eventlist); eventEnum->QueryInterface(NS_GET_IID(nsISimpleEnumerator), (void **)eventlist);
dateEnum->QueryInterface(NS_GET_IID(nsISimpleEnumerator), (void **)datelist);
PRUint32 num; PRUint32 num;
unsigned int i; unsigned int i;
@ -539,7 +515,7 @@ oeICalContainerImpl::GetEventsForRange( PRTime checkdateinms, PRTime checkenddat
{ {
oeIICal* calendar; oeIICal* calendar;
m_calendarArray->GetElementAt( i, (nsISupports **)&calendar ); m_calendarArray->GetElementAt( i, (nsISupports **)&calendar );
calendar->GetEventsForRange( checkdateinms, checkenddateinms, (nsISimpleEnumerator **)&dateEnum, (nsISimpleEnumerator **)&eventEnum ); calendar->GetEventsForRange( checkdateinms, checkenddateinms, (nsISimpleEnumerator **)&eventEnum );
} }
return NS_OK; return NS_OK;
@ -596,7 +572,7 @@ icaltimetype oeICalContainerImpl::GetNextEvent( icaltimetype starting ) {
} }
NS_IMETHODIMP NS_IMETHODIMP
oeICalContainerImpl::GetNextNEvents( PRTime datems, PRInt32 maxcount, nsISimpleEnumerator **datelist, nsISimpleEnumerator **eventlist ) { oeICalContainerImpl::GetNextNEvents( PRTime datems, PRInt32 maxcount, nsISimpleEnumerator **eventlist ) {
#ifdef ICAL_DEBUG #ifdef ICAL_DEBUG
printf( "oeICalContainerImpl::GetNextNEvents( %d )\n", maxcount ); printf( "oeICalContainerImpl::GetNextNEvents( %d )\n", maxcount );
#endif #endif
@ -606,13 +582,7 @@ oeICalContainerImpl::GetNextNEvents( PRTime datems, PRInt32 maxcount, nsISimpleE
if (!eventEnum) if (!eventEnum)
return NS_ERROR_OUT_OF_MEMORY; return NS_ERROR_OUT_OF_MEMORY;
nsCOMPtr<oeDateEnumerator> dateEnum = new oeDateEnumerator( );
if (!dateEnum)
return NS_ERROR_OUT_OF_MEMORY;
eventEnum->QueryInterface(NS_GET_IID(nsISimpleEnumerator), (void **)eventlist); eventEnum->QueryInterface(NS_GET_IID(nsISimpleEnumerator), (void **)eventlist);
dateEnum->QueryInterface(NS_GET_IID(nsISimpleEnumerator), (void **)datelist);
struct icaltimetype checkdate = ConvertFromPrtime( datems ); struct icaltimetype checkdate = ConvertFromPrtime( datems );
icaltime_adjust( &checkdate, 0, 0, 0, -1 ); icaltime_adjust( &checkdate, 0, 0, 0, -1 );
@ -633,13 +603,13 @@ oeICalContainerImpl::GetNextNEvents( PRTime datems, PRInt32 maxcount, nsISimpleE
EventList *tmplistptr = calendar->GetEventList(); EventList *tmplistptr = calendar->GetEventList();
while( tmplistptr && count<maxcount ) { while( tmplistptr && count<maxcount ) {
if( tmplistptr->event ) { if( tmplistptr->event ) {
bool isbeginning,isallday;
oeIICalEvent* tmpevent = tmplistptr->event; oeIICalEvent* tmpevent = tmplistptr->event;
icaltimetype next = ((oeICalEventImpl *)tmpevent)->GetNextRecurrence( checkdate, nsnull ); icaltimetype next = ((oeICalEventImpl *)tmpevent)->GetNextRecurrence( checkdate, &isbeginning );
isallday = next.is_date;
next.is_date = false; next.is_date = false;
if( !icaltime_is_null_time( next ) && (icaltime_compare( nextcheckdate, next ) == 0) ) { if( !icaltime_is_null_time( next ) && (icaltime_compare( nextcheckdate, next ) == 0) ) {
eventEnum->AddEvent( tmpevent ); ((oeICalEventImpl *)tmpevent)->ChopAndAddEventToEnum( nextcheckdate, eventlist, isallday, isbeginning );
PRTime nextdateinms = ConvertToPrtime( nextcheckdate );
dateEnum->AddDate( nextdateinms );
count++; count++;
} }
} }

View File

@ -1584,6 +1584,53 @@ NS_IMETHODIMP oeICalEventImpl::GetDuration(PRBool *is_negative, PRUint16 *weeks,
return NS_ERROR_NOT_IMPLEMENTED; return NS_ERROR_NOT_IMPLEMENTED;
} }
void oeICalEventImpl::ChopAndAddEventToEnum( struct icaltimetype startdate, nsISimpleEnumerator **eventlist,
bool isallday, bool isbeginning ) {
nsCOMPtr<oeEventEnumerator> 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 = icaltime_subtract( m_end->m_datetime, m_start->m_datetime );
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 );
}
}
bool oeICalEventImpl::ParseIcalComponent( icalcomponent *comp ) bool oeICalEventImpl::ParseIcalComponent( icalcomponent *comp )
{ {
#ifdef ICAL_DEBUG_ALL #ifdef ICAL_DEBUG_ALL

View File

@ -116,6 +116,8 @@ public:
icaltimetype GetPreviousOccurrence( icaltimetype beforethis ); icaltimetype GetPreviousOccurrence( icaltimetype beforethis );
NS_IMETHODIMP SetParent( oeIICal *parent ); NS_IMETHODIMP SetParent( oeIICal *parent );
icaltimetype CalculateEventTime( icaltimetype alarmtime ); icaltimetype CalculateEventTime( icaltimetype alarmtime );
void ChopAndAddEventToEnum( struct icaltimetype startdate, nsISimpleEnumerator **eventlist,
bool isallday, bool isbeginning );
private: private:
char *m_id; char *m_id;
char *m_syncid; char *m_syncid;

View File

@ -1268,7 +1268,7 @@ oeICalImpl::GetAllEvents(nsISimpleEnumerator **resultList )
} }
NS_IMETHODIMP NS_IMETHODIMP
oeICalImpl::GetEventsForMonth( PRTime datems, nsISimpleEnumerator **datelist, nsISimpleEnumerator **eventlist ) { oeICalImpl::GetEventsForMonth( PRTime datems, nsISimpleEnumerator **eventlist ) {
#ifdef ICAL_DEBUG #ifdef ICAL_DEBUG
printf( "oeICalImpl::GetEventsForMonth()\n" ); printf( "oeICalImpl::GetEventsForMonth()\n" );
#endif #endif
@ -1295,11 +1295,11 @@ oeICalImpl::GetEventsForMonth( PRTime datems, nsISimpleEnumerator **datelist, ns
#endif #endif
PRTime checkenddateinms = ConvertToPrtime( checkenddate ); PRTime checkenddateinms = ConvertToPrtime( checkenddate );
return GetEventsForRange(checkdateinms ,checkenddateinms ,datelist ,eventlist ); return GetEventsForRange(checkdateinms ,checkenddateinms, eventlist );
} }
NS_IMETHODIMP NS_IMETHODIMP
oeICalImpl::GetEventsForWeek( PRTime datems, nsISimpleEnumerator **datelist, nsISimpleEnumerator **eventlist ) { oeICalImpl::GetEventsForWeek( PRTime datems, nsISimpleEnumerator **eventlist ) {
#ifdef ICAL_DEBUG #ifdef ICAL_DEBUG
printf( "oeICalImpl::GetEventsForWeek()\n" ); printf( "oeICalImpl::GetEventsForWeek()\n" );
#endif #endif
@ -1318,11 +1318,11 @@ oeICalImpl::GetEventsForWeek( PRTime datems, nsISimpleEnumerator **datelist, nsI
icaltime_adjust( &checkenddate, 7, 0 , 0, 0 ); icaltime_adjust( &checkenddate, 7, 0 , 0, 0 );
PRTime checkenddateinms = ConvertToPrtime( checkenddate ); PRTime checkenddateinms = ConvertToPrtime( checkenddate );
return GetEventsForRange(checkdateinms ,checkenddateinms ,datelist ,eventlist ); return GetEventsForRange(checkdateinms ,checkenddateinms, eventlist );
} }
NS_IMETHODIMP NS_IMETHODIMP
oeICalImpl::GetEventsForDay( PRTime datems, nsISimpleEnumerator **datelist, nsISimpleEnumerator **eventlist ) { oeICalImpl::GetEventsForDay( PRTime datems, nsISimpleEnumerator **eventlist ) {
#ifdef ICAL_DEBUG #ifdef ICAL_DEBUG
printf( "oeICalImpl::GetEventsForDay()\n" ); printf( "oeICalImpl::GetEventsForDay()\n" );
#endif #endif
@ -1341,63 +1341,11 @@ oeICalImpl::GetEventsForDay( PRTime datems, nsISimpleEnumerator **datelist, nsIS
icaltime_adjust( &checkenddate, 1, 0, 0, 0 ); icaltime_adjust( &checkenddate, 1, 0, 0, 0 );
PRTime checkenddateinms = ConvertToPrtime( checkenddate ); PRTime checkenddateinms = ConvertToPrtime( checkenddate );
return GetEventsForRange(checkdateinms ,checkenddateinms ,datelist ,eventlist ); return GetEventsForRange(checkdateinms ,checkenddateinms, eventlist );
}
void oeICalImpl::ChopAndAddEventToEnum( struct icaltimetype startdate,
nsISimpleEnumerator **eventlist, oeICalEventImpl* event, bool isallday, bool isbeginning ) {
nsCOMPtr<oeEventEnumerator> eventEnum;
eventEnum = (oeEventEnumerator *)*eventlist;
oeIICalEventDisplay* eventDisplay;
nsresult rv = NS_NewICalEventDisplay( event, &eventDisplay );
if( NS_FAILED( rv ) ) {
#ifdef ICAL_DEBUG
printf( "oeICalImpl::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 {
oeIDateTime *end;
event->GetEnd( &end );
if( isbeginning ) {
oeIDateTime *start;
event->GetStart( &start );
struct icaldurationtype eventlength = icaltime_subtract( ((oeDateTimeImpl *)end)->m_datetime, ((oeDateTimeImpl *)start)->m_datetime );
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 = ((oeDateTimeImpl *)end)->m_datetime.hour;
eventenddate.minute = ((oeDateTimeImpl *)end)->m_datetime.minute;
eventenddate.second = ((oeDateTimeImpl *)end)->m_datetime.second;
enddateinms = ConvertToPrtime( eventenddate );
}
eventDisplay->SetDisplayEndDate( enddateinms );
}
} }
NS_IMETHODIMP NS_IMETHODIMP
oeICalImpl::GetEventsForRange( PRTime checkdateinms, PRTime checkenddateinms, nsISimpleEnumerator **datelist, nsISimpleEnumerator **eventlist ) { oeICalImpl::GetEventsForRange( PRTime checkdateinms, PRTime checkenddateinms, nsISimpleEnumerator **eventlist ) {
#ifdef ICAL_DEBUG_ALL #ifdef ICAL_DEBUG_ALL
printf( "oeICalImpl::GetEventsForRange()\n" ); printf( "oeICalImpl::GetEventsForRange()\n" );
#endif #endif
@ -1411,15 +1359,6 @@ oeICalImpl::GetEventsForRange( PRTime checkdateinms, PRTime checkenddateinms, ns
} else } else
eventEnum = (oeEventEnumerator *)*eventlist; eventEnum = (oeEventEnumerator *)*eventlist;
nsCOMPtr<oeDateEnumerator> dateEnum;
if( !*datelist ) {
dateEnum = new oeDateEnumerator( );
if (!dateEnum)
return NS_ERROR_OUT_OF_MEMORY;
dateEnum->QueryInterface(NS_GET_IID(nsISimpleEnumerator), (void **)datelist);
} else
dateEnum = (oeDateEnumerator *)*datelist;
struct icaltimetype checkdate = ConvertFromPrtime( checkdateinms ); struct icaltimetype checkdate = ConvertFromPrtime( checkdateinms );
icaltime_adjust( &checkdate, 0, 0, 0, -1 ); icaltime_adjust( &checkdate, 0, 0, 0, -1 );
@ -1440,9 +1379,7 @@ oeICalImpl::GetEventsForRange( PRTime checkdateinms, PRTime checkenddateinms, ns
bool isallday = next.is_date; bool isallday = next.is_date;
next.is_date = false; next.is_date = false;
if( !icaltime_is_null_time( next ) && (icaltime_compare( nextcheckdate, next ) == 0) ) { if( !icaltime_is_null_time( next ) && (icaltime_compare( nextcheckdate, next ) == 0) ) {
ChopAndAddEventToEnum( nextcheckdate, eventlist, (oeICalEventImpl *)tmpevent, isallday, isbeginning ); ((oeICalEventImpl *)tmpevent)->ChopAndAddEventToEnum( nextcheckdate, eventlist, isallday, isbeginning );
PRTime nextdateinms = ConvertToPrtime( nextcheckdate );
dateEnum->AddDate( nextdateinms );
} }
} }
tmplistptr = tmplistptr->next; tmplistptr = tmplistptr->next;
@ -1451,8 +1388,6 @@ oeICalImpl::GetEventsForRange( PRTime checkdateinms, PRTime checkenddateinms, ns
} }
} while ( !icaltime_is_null_time( nextcheckdate ) ); } while ( !icaltime_is_null_time( nextcheckdate ) );
// eventEnum->QueryInterface(NS_GET_IID(nsISimpleEnumerator), (void **)eventlist);
// dateEnum->QueryInterface(NS_GET_IID(nsISimpleEnumerator), (void **)datelist);
return NS_OK; return NS_OK;
} }
@ -1517,10 +1452,9 @@ oeICalImpl::GetFirstEventsForRange( PRTime checkdateinms, PRTime checkenddateinm
next.is_date = false; next.is_date = false;
if( !icaltime_is_null_time( next ) && (icaltime_compare( nextcheckdate, next ) == 0) ) { if( !icaltime_is_null_time( next ) && (icaltime_compare( nextcheckdate, next ) == 0) ) {
eventEnum->AddEvent( tmpevent ); eventEnum->AddEvent( tmpevent );
// PRTime nextdateinms = ConvertToPrtime( nextcheckdate );
// dateEnum->AddDate( nextdateinms );
eventArray->RemoveElementAt( i ); eventArray->RemoveElementAt( i );
icaltime_adjust( &nextcheckdate, 0, 0, 0, -1 ); icaltime_adjust( &nextcheckdate, 0, 0, 0, -1 );
//TODO Create an eventdisplay object and asd displaydate & displayenddate to it
break; break;
} }
} }
@ -1529,8 +1463,6 @@ oeICalImpl::GetFirstEventsForRange( PRTime checkdateinms, PRTime checkenddateinm
} while ( !icaltime_is_null_time( nextcheckdate ) ); } while ( !icaltime_is_null_time( nextcheckdate ) );
eventArray->Clear(); eventArray->Clear();
// bump ref count
// return eventEnum->QueryInterface(NS_GET_IID(nsISimpleEnumerator), (void **)eventlist);
return NS_OK; return NS_OK;
} }
@ -1556,20 +1488,19 @@ icaltimetype oeICalImpl::GetNextEvent( icaltimetype starting ) {
} }
NS_IMETHODIMP NS_IMETHODIMP
oeICalImpl::GetNextNEvents( PRTime datems, PRInt32 maxcount, nsISimpleEnumerator **datelist, nsISimpleEnumerator **eventlist ) { oeICalImpl::GetNextNEvents( PRTime datems, PRInt32 maxcount, nsISimpleEnumerator **eventlist ) {
#ifdef ICAL_DEBUG #ifdef ICAL_DEBUG
printf( "oeICalImpl::GetNextNEvents( %d )\n", maxcount ); printf( "oeICalImpl::GetNextNEvents( %d )\n", maxcount );
#endif #endif
nsCOMPtr<oeEventEnumerator> eventEnum = new oeEventEnumerator( ); nsCOMPtr<oeEventEnumerator> eventEnum;
if( !*eventlist ) {
eventEnum = new oeEventEnumerator();
if (!eventEnum) if (!eventEnum)
return NS_ERROR_OUT_OF_MEMORY; return NS_ERROR_OUT_OF_MEMORY;
eventEnum->QueryInterface(NS_GET_IID(nsISimpleEnumerator), (void **)eventlist);
nsCOMPtr<oeDateEnumerator> dateEnum = new oeDateEnumerator( ); } else
eventEnum = (oeEventEnumerator *)*eventlist;
if (!dateEnum)
return NS_ERROR_OUT_OF_MEMORY;
struct icaltimetype checkdate = ConvertFromPrtime( datems ); struct icaltimetype checkdate = ConvertFromPrtime( datems );
icaltime_adjust( &checkdate, 0, 0, 0, -1 ); icaltime_adjust( &checkdate, 0, 0, 0, -1 );
@ -1582,13 +1513,13 @@ oeICalImpl::GetNextNEvents( PRTime datems, PRInt32 maxcount, nsISimpleEnumerator
EventList *tmplistptr = &m_eventlist; EventList *tmplistptr = &m_eventlist;
while( tmplistptr && count<maxcount ) { while( tmplistptr && count<maxcount ) {
if( tmplistptr->event ) { if( tmplistptr->event ) {
bool isbeginning,isallday;
oeIICalEvent* tmpevent = tmplistptr->event; oeIICalEvent* tmpevent = tmplistptr->event;
icaltimetype next = ((oeICalEventImpl *)tmpevent)->GetNextRecurrence( checkdate, nsnull ); icaltimetype next = ((oeICalEventImpl *)tmpevent)->GetNextRecurrence( checkdate, &isbeginning );
isallday = next.is_date;
next.is_date = false; next.is_date = false;
if( !icaltime_is_null_time( next ) && (icaltime_compare( nextcheckdate, next ) == 0) ) { if( !icaltime_is_null_time( next ) && (icaltime_compare( nextcheckdate, next ) == 0) ) {
eventEnum->AddEvent( tmpevent ); ((oeICalEventImpl *)tmpevent)->ChopAndAddEventToEnum( nextcheckdate, eventlist, isallday, isbeginning );
PRTime nextdateinms = ConvertToPrtime( nextcheckdate );
dateEnum->AddDate( nextdateinms );
count++; count++;
} }
} }
@ -1598,8 +1529,6 @@ oeICalImpl::GetNextNEvents( PRTime datems, PRInt32 maxcount, nsISimpleEnumerator
} }
} while ( !icaltime_is_null_time( nextcheckdate ) && (count < maxcount) ); } while ( !icaltime_is_null_time( nextcheckdate ) && (count < maxcount) );
eventEnum->QueryInterface(NS_GET_IID(nsISimpleEnumerator), (void **)eventlist);
dateEnum->QueryInterface(NS_GET_IID(nsISimpleEnumerator), (void **)datelist);
return NS_OK; return NS_OK;
} }

View File

@ -211,12 +211,12 @@ interface oeIICal : nsISupports
oeIICalEvent fetchEvent( in string id ); oeIICalEvent fetchEvent( in string id );
// nsISimpleEnumerator searchBySQL( in string sqlstr ); // nsISimpleEnumerator searchBySQL( in string sqlstr );
nsISimpleEnumerator getAllEvents(); nsISimpleEnumerator getAllEvents();
nsISimpleEnumerator getEventsForMonth(in PRTime date, out nsISimpleEnumerator datelist ); nsISimpleEnumerator getEventsForMonth( in PRTime date );
nsISimpleEnumerator getEventsForWeek(in PRTime date, out nsISimpleEnumerator datelist ); nsISimpleEnumerator getEventsForWeek( in PRTime date );
nsISimpleEnumerator getEventsForDay(in PRTime date, out nsISimpleEnumerator datelist ); nsISimpleEnumerator getEventsForDay( in PRTime date );
nsISimpleEnumerator getEventsForRange(in PRTime begindate, in PRTime enddate, out nsISimpleEnumerator datelist ); nsISimpleEnumerator getEventsForRange( in PRTime begindate, in PRTime enddate );
nsISimpleEnumerator getNextNEvents(in PRTime begindate, in long count, out nsISimpleEnumerator datelist ); nsISimpleEnumerator getNextNEvents( in PRTime begindate, in long count );
nsISimpleEnumerator getFirstEventsForRange(in PRTime begindate, in PRTime enddate ); nsISimpleEnumerator getFirstEventsForRange( in PRTime begindate, in PRTime enddate );
string addTodo( in oeIICalTodo icaltodo ); string addTodo( in oeIICalTodo icaltodo );
string modifyTodo( in oeIICalTodo icaltodo ); string modifyTodo( in oeIICalTodo icaltodo );
@ -246,12 +246,12 @@ interface oeIICalContainer : nsISupports
void deleteEvent( in string id ); void deleteEvent( in string id );
oeIICalEvent fetchEvent( in string id ); oeIICalEvent fetchEvent( in string id );
nsISimpleEnumerator getAllEvents(); nsISimpleEnumerator getAllEvents();
nsISimpleEnumerator getEventsForMonth(in PRTime date, out nsISimpleEnumerator datelist ); nsISimpleEnumerator getEventsForMonth( in PRTime date );
nsISimpleEnumerator getEventsForWeek(in PRTime date, out nsISimpleEnumerator datelist ); nsISimpleEnumerator getEventsForWeek( in PRTime date );
nsISimpleEnumerator getEventsForDay(in PRTime date, out nsISimpleEnumerator datelist ); nsISimpleEnumerator getEventsForDay( in PRTime date );
nsISimpleEnumerator getEventsForRange(in PRTime begindate, in PRTime enddate, out nsISimpleEnumerator datelist ); nsISimpleEnumerator getEventsForRange( in PRTime begindate, in PRTime enddate );
nsISimpleEnumerator getNextNEvents(in PRTime begindate, in long count, out nsISimpleEnumerator datelist ); nsISimpleEnumerator getNextNEvents( in PRTime begindate, in long count );
nsISimpleEnumerator getFirstEventsForRange(in PRTime begindate, in PRTime enddate ); nsISimpleEnumerator getFirstEventsForRange( in PRTime begindate, in PRTime enddate );
string addTodo( in oeIICalTodo icaltodo, in string server ); string addTodo( in oeIICalTodo icaltodo, in string server );
string modifyTodo( in oeIICalTodo icaltodo ); string modifyTodo( in oeIICalTodo icaltodo );

View File

@ -262,9 +262,7 @@ CalendarEventDataSource.prototype.getEventsForDay = function calEvent_getEventsF
{ {
var eventDisplays = new Array(); var eventDisplays = new Array();
var displayDates = new Object(); var eventList = this.gICalLib.getEventsForDay( date );
var eventList = this.gICalLib.getEventsForDay( date, displayDates );
while( eventList.hasMoreElements() ) while( eventList.hasMoreElements() )
{ {
@ -302,21 +300,17 @@ CalendarEventDataSource.prototype.getEventsForWeek = function calEvent_getEvents
{ {
var eventDisplays = new Array(); var eventDisplays = new Array();
var displayDates = new Object(); var eventList = this.gICalLib.getEventsForWeek( date );
var eventList = this.gICalLib.getEventsForWeek( date, displayDates );
while( eventList.hasMoreElements() ) while( eventList.hasMoreElements() )
{ {
var tmpevent = eventList.getNext().QueryInterface(Components.interfaces.oeIICalEventDisplay); var tmpevent = eventList.getNext().QueryInterface(Components.interfaces.oeIICalEventDisplay);
var displayDate = new Date( displayDates.value.getNext().QueryInterface(Components.interfaces.nsISupportsPRTime).data );
var EventObject = new Object; var EventObject = new Object;
EventObject.event = tmpevent.event; EventObject.event = tmpevent.event;
EventObject.displayDate = displayDate; EventObject.displayDate = new Date( tmpevent.displayDate );
EventObject.displayEndDate = new Date( tmpevent.displayEndDate ); EventObject.displayEndDate = new Date( tmpevent.displayEndDate );
eventDisplays[ eventDisplays.length ] = EventObject; eventDisplays[ eventDisplays.length ] = EventObject;
@ -342,9 +336,7 @@ CalendarEventDataSource.prototype.getEventsForMonth = function calEvent_getEvent
{ {
var eventDisplays = new Array(); var eventDisplays = new Array();
var displayDates = new Object(); var eventList = this.gICalLib.getEventsForMonth( date );
var eventList = this.gICalLib.getEventsForMonth( date, displayDates );
while( eventList.hasMoreElements() ) while( eventList.hasMoreElements() )
{ {
@ -372,9 +364,7 @@ CalendarEventDataSource.prototype.getNextEvents = function calEvent_getNextEvent
var today = new Date(); var today = new Date();
var displayDates = new Object(); var eventList = this.gICalLib.getNextNEvents( today, EventsToGet );
var eventList = this.gICalLib.getNextNEvents( today, EventsToGet, displayDates );
while( eventList.hasMoreElements() ) while( eventList.hasMoreElements() )
{ {