Added removeAllExceptions() function. And changed getExceptions() to return dates in a sorted order

This commit is contained in:
mostafah%oeone.com 2002-05-13 18:45:03 +00:00
parent 5c6e0a61a4
commit 986ba40fe3
3 changed files with 46 additions and 4 deletions

View File

@ -1010,6 +1010,15 @@ NS_IMETHODIMP oeICalEventImpl::AddException( PRTime exdate )
return NS_OK;
}
NS_IMETHODIMP oeICalEventImpl::RemoveAllExceptions()
{
#ifdef ICAL_DEBUG_ALL
printf( "oeICalEventImpl::RemoveAllExceptions()\n" );
#endif
m_exceptiondates.clear();
return NS_OK;
}
NS_IMETHODIMP
oeICalEventImpl::GetExceptions(nsISimpleEnumerator **datelist )
{
@ -1021,9 +1030,41 @@ oeICalEventImpl::GetExceptions(nsISimpleEnumerator **datelist )
if (!dateEnum)
return NS_ERROR_OUT_OF_MEMORY;
for( unsigned int i=0; i<m_exceptiondates.size(); i++ ) {
dateEnum->AddDate( m_exceptiondates[i] );
}
int count=0;
bool found;
PRTime current,lastadded,minimum;
do {
found = false;
for( unsigned int i=0; i<m_exceptiondates.size(); i++ ) {
current = m_exceptiondates[i];
if( !count ) {
if( i == 0 ) {
minimum = current;
found = true;
} else if ( LL_CMP( current, < , minimum ) ) {
minimum = current;
found = true;
}
} else if ( LL_CMP( current, >, 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);
}

View File

@ -1250,7 +1250,7 @@ oeICalImpl::GetEventsForRange( PRTime checkdateinms, PRTime checkenddateinms, ns
NS_IMETHODIMP
oeICalImpl::GetFirstEventsForRange( PRTime checkdateinms, PRTime checkenddateinms, nsISimpleEnumerator **eventlist ) {
#ifdef ICAL_DEBUG_ALL
printf( "oeICalImpl::GetEventsInRange()\n" );
printf( "oeICalImpl::GetFirstEventsForRange()\n" );
#endif
nsCOMPtr<oeEventEnumerator> eventEnum = new oeEventEnumerator( );

View File

@ -95,6 +95,7 @@ interface oeIICalEvent : nsISupports
boolean parseIcalString(in string icalstr);
void addException( in PRTime exdate );
nsISimpleEnumerator getExceptions();
void removeAllExceptions();
void setSnoozeTime( in PRTime exdate );
oeIICalEvent clone();
};