Changed the Id attribute from long to string to follow standard

This commit is contained in:
mostafah%oeone.com 2002-04-04 22:41:14 +00:00
parent 80428863c6
commit 800a3e3f88
5 changed files with 138 additions and 126 deletions

View File

@ -142,7 +142,7 @@ oeICalEventImpl::oeICalEventImpl()
if( NS_FAILED( rv = NS_NewDateTime((oeIDateTime**) &m_recurend ))) {
m_recurend = nsnull;
}
m_id = 0;
m_id = nsnull;
m_title = nsnull;
m_description = nsnull;
m_location = nsnull;
@ -173,6 +173,8 @@ oeICalEventImpl::~oeICalEventImpl()
printf( "oeICalEventImpl::~oeICalEventImpl( %d )\n", mRefCnt );
#endif
/* destructor code */
if( m_id )
nsMemory::Free( m_id );
if( m_title )
nsMemory::Free( m_title );
if( m_description )
@ -200,28 +202,47 @@ oeICalEventImpl::~oeICalEventImpl()
m_recurend->Release();
}
/* attribute long Id; */
NS_IMETHODIMP oeICalEventImpl::GetId(PRUint32 *aRetVal)
/* attribute string Id; */
NS_IMETHODIMP oeICalEventImpl::GetId(char **aRetVal)
{
#ifdef ICAL_DEBUG_ALL
printf( "GetId() = " );
#endif
*aRetVal= m_id;
if( m_id ) {
*aRetVal= (char*) nsMemory::Clone( m_id, strlen(m_id)+1);
if( *aRetVal == nsnull )
return NS_ERROR_OUT_OF_MEMORY;
} else
*aRetVal= nsnull;
#ifdef ICAL_DEBUG_ALL
printf( "%lu\n", *aRetVal );
printf( "\"%s\"\n", *aRetVal );
#endif
return NS_OK;
}
NS_IMETHODIMP oeICalEventImpl::SetId(PRUint32 aNewVal)
NS_IMETHODIMP oeICalEventImpl::SetId(const char *aNewVal)
{
#ifdef ICAL_DEBUG_ALL
printf( "SetId( %lu )\n", aNewVal );
printf( "SetId( %s )\n", aNewVal );
#endif
m_id = aNewVal;
if( m_id )
nsMemory::Free( m_id );
if( aNewVal )
m_id= (char*) nsMemory::Clone( aNewVal, strlen(aNewVal)+1);
else
m_id = nsnull;
return NS_OK;
}
bool oeICalEventImpl::matchId( const char *id ) {
if( m_id )
return ( strcmp( m_id, id ) == 0 );
else
return false;
}
/* attribute string Title; */
NS_IMETHODIMP oeICalEventImpl::GetTitle(char **aRetVal)
{
@ -783,7 +804,7 @@ icaltimetype oeICalEventImpl::GetNextAlarmTime( icaltimetype begin ) {
result = CalculateAlarmTime( result );
} while ( icaltime_compare( starting, result ) >= 0 );
for( int i=0; i<m_snoozetimes.size(); i++ ) {
for( unsigned int i=0; i<m_snoozetimes.size(); i++ ) {
icaltimetype snoozetime = ConvertFromPrtime( m_snoozetimes[i] );
if( icaltime_is_null_time( result ) || icaltime_compare( snoozetime, result ) < 0 ) {
if ( icaltime_compare( snoozetime, starting ) > 0 ) {
@ -929,7 +950,7 @@ oeICalEventImpl::GetExceptions(nsISimpleEnumerator **datelist )
if (!dateEnum)
return NS_ERROR_OUT_OF_MEMORY;
for( int i=0; i<m_exceptiondates.size(); i++ ) {
for( unsigned int i=0; i<m_exceptiondates.size(); i++ ) {
dateEnum->AddDate( m_exceptiondates[i] );
}
// bump ref count
@ -947,7 +968,7 @@ bool oeICalEventImpl::IsExcepted( PRTime date ) {
date = ConvertToPrtime( tmpexdate );
bool result = false;
for( int i=0; i<m_exceptiondates.size(); i++ ) {
for( unsigned int i=0; i<m_exceptiondates.size(); i++ ) {
if( m_exceptiondates[i] == date ) {
result = true;
break;
@ -987,18 +1008,21 @@ void oeICalEventImpl::ParseIcalComponent( icalcomponent *vevent )
return;
}
const char *tmpstr;
//id
if( m_id )
nsMemory::Free( m_id );
icalproperty *prop = icalcomponent_get_first_property( vevent, ICAL_UID_PROPERTY );
if ( !prop ) {
if ( prop ) {
tmpstr = icalproperty_get_uid( prop );
SetId( tmpstr );
} else {
#ifdef ICAL_DEBUG
printf( "oeICalEventImpl::ParseIcalComponent() failed: UID not found!\n" );
#endif
return;
}
const char *tmpstr = icalproperty_get_uid( prop );
m_id = atol( tmpstr );
//title
if( m_title )
nsMemory::Free( m_title );
@ -1304,9 +1328,7 @@ icalcomponent* oeICalEventImpl::AsIcalComponent()
icalcomponent *vevent = icalcomponent_new_vevent();
//id
char tmpstr[20];
sprintf( tmpstr, "%lu", m_id );
prop = icalproperty_new_uid( tmpstr );
prop = icalproperty_new_uid( m_id );
icalcomponent_add_property( vevent, prop );
//title
@ -1390,6 +1412,7 @@ icalcomponent* oeICalEventImpl::AsIcalComponent()
icalcomponent_add_property( vevent, prop );
}
char tmpstr[20];
//alarmlength
if( m_alarmlength ) {
sprintf( tmpstr, "%lu", m_alarmlength );
@ -1548,7 +1571,7 @@ icalcomponent* oeICalEventImpl::AsIcalComponent()
}
//exceptions
for( int i=0; i<m_exceptiondates.size(); i++ ) {
for( unsigned int i=0; i<m_exceptiondates.size(); i++ ) {
icaltimetype exdate = ConvertFromPrtime( m_exceptiondates[i] );
prop = icalproperty_new_recurrenceid( exdate );
icalcomponent_add_property( vevent, prop );
@ -1574,7 +1597,7 @@ icalcomponent* oeICalEventImpl::AsIcalComponent()
//snoozetimes
icalcomponent *tmpcomp=NULL;
for( int i=0; i<m_snoozetimes.size(); i++ ) {
for( unsigned int i=0; i<m_snoozetimes.size(); i++ ) {
if( tmpcomp == NULL )
tmpcomp = icalcomponent_new( ICAL_X_COMPONENT );
icaltimetype snoozetime = ConvertFromPrtime( m_snoozetimes[i] );

View File

@ -33,6 +33,8 @@
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#ifndef _OEICALEVENTIMPL_H_
#define _OEICALEVENTIMPL_H_
#include "oeIICal.h"
#include "oeDateTimeImpl.h"
@ -67,23 +69,24 @@ oeDateEnumerator : public nsISimpleEnumerator
private:
PRUint32 mCurrentIndex;
std::vector<PRTime> mIdVector;
std::vector<PRTime> mDateVector;
};
/* oeIcalEvent Header file */
class oeICalEventImpl : public oeIICalEvent
{
public:
NS_DECL_ISUPPORTS
NS_DECL_OEIICALEVENT
oeICalEventImpl();
virtual ~oeICalEventImpl();
/* additional members */
void ParseIcalComponent( icalcomponent *vcalendar );
icalcomponent *AsIcalComponent();
icaltimetype GetNextAlarmTime( icaltimetype begin );
NS_DECL_ISUPPORTS
NS_DECL_OEIICALEVENT
oeICalEventImpl();
virtual ~oeICalEventImpl();
/* additional members */
void ParseIcalComponent( icalcomponent *vcalendar );
icalcomponent *AsIcalComponent();
icaltimetype GetNextAlarmTime( icaltimetype begin );
bool matchId( const char *id );
private:
unsigned long m_id;
char *m_id;
char *m_syncid;
char *m_title;
char *m_description;
@ -114,3 +117,4 @@ private:
bool IsExcepted( PRTime date );
};
#endif

View File

@ -70,13 +70,11 @@ oeEventEnumerator : public nsISimpleEnumerator
// nsISimpleEnumerator interface
NS_DECL_NSISIMPLEENUMERATOR
NS_IMETHOD Init( oeIICal* iCal );
NS_IMETHOD AddEventId( PRInt32 id );
NS_IMETHOD AddEvent( oeIICalEvent *event );
private:
PRUint32 mCurrentIndex;
std::vector<PRInt32> mIdVector;
nsCOMPtr<oeIICal> mICal;
std::vector<oeIICalEvent *> mEventVector;
};
oeEventEnumerator::oeEventEnumerator( )
@ -88,6 +86,7 @@ oeEventEnumerator::oeEventEnumerator( )
oeEventEnumerator::~oeEventEnumerator()
{
mEventVector.clear();
}
NS_IMPL_ISUPPORTS1(oeEventEnumerator, nsISimpleEnumerator)
@ -95,7 +94,7 @@ NS_IMPL_ISUPPORTS1(oeEventEnumerator, nsISimpleEnumerator)
NS_IMETHODIMP
oeEventEnumerator::HasMoreElements(PRBool *result)
{
if( mCurrentIndex >= mIdVector.size() )
if( mCurrentIndex >= mEventVector.size() )
{
*result = PR_FALSE;
}
@ -110,19 +109,14 @@ NS_IMETHODIMP
oeEventEnumerator::GetNext(nsISupports **_retval)
{
if( mCurrentIndex >= mIdVector.size() )
if( mCurrentIndex >= mEventVector.size() )
{
*_retval = nsnull;
}
else
{
PRInt32 eventId = mIdVector[ mCurrentIndex ];
oeIICalEvent* event;
nsresult rv = mICal->FetchEvent( eventId, &event);
if( NS_FAILED( rv ) )
return rv;
oeIICalEvent* event = mEventVector[ mCurrentIndex ];
event->AddRef();
*_retval = event;
++mCurrentIndex;
}
@ -132,20 +126,12 @@ oeEventEnumerator::GetNext(nsISupports **_retval)
NS_IMETHODIMP
oeEventEnumerator::AddEventId(PRInt32 id)
oeEventEnumerator::AddEvent(oeIICalEvent* event)
{
mIdVector.push_back( id );
mEventVector.push_back( event );
return NS_OK;
}
NS_IMETHODIMP
oeEventEnumerator::Init(oeIICal* iCal)
{
mICal = iCal;
return NS_OK;
}
/* date enumerator */
oeDateEnumerator::oeDateEnumerator( )
:
@ -156,6 +142,7 @@ oeDateEnumerator::oeDateEnumerator( )
oeDateEnumerator::~oeDateEnumerator()
{
mDateVector.clear();
}
NS_IMPL_ISUPPORTS1(oeDateEnumerator, nsISimpleEnumerator)
@ -163,7 +150,7 @@ NS_IMPL_ISUPPORTS1(oeDateEnumerator, nsISimpleEnumerator)
NS_IMETHODIMP
oeDateEnumerator::HasMoreElements(PRBool *result)
{
if( mCurrentIndex >= mIdVector.size() )
if( mCurrentIndex >= mDateVector.size() )
{
*result = PR_FALSE;
}
@ -178,7 +165,7 @@ NS_IMETHODIMP
oeDateEnumerator::GetNext(nsISupports **_retval)
{
if( mCurrentIndex >= mIdVector.size() )
if( mCurrentIndex >= mDateVector.size() )
{
*_retval = nsnull;
}
@ -197,7 +184,7 @@ oeDateEnumerator::GetNext(nsISupports **_retval)
return rv;
}
date->SetData( mIdVector[ mCurrentIndex ] );
date->SetData( mDateVector[ mCurrentIndex ] );
*_retval = date;
++mCurrentIndex;
}
@ -208,7 +195,7 @@ oeDateEnumerator::GetNext(nsISupports **_retval)
NS_IMETHODIMP
oeDateEnumerator::AddDate(PRTime date)
{
mIdVector.push_back( date );
mDateVector.push_back( date );
return NS_OK;
}
@ -254,7 +241,7 @@ oeICalImpl::~oeICalImpl()
#ifdef ICAL_DEBUG
printf( "oeICalImpl::~oeICalImpl()\n" );
#endif
for( int i=0; i<m_observerlist.size(); i++ ) {
for( unsigned int i=0; i<m_observerlist.size(); i++ ) {
m_observerlist[i]->Release();
}
if( m_alarmtimer ) {
@ -573,8 +560,8 @@ END:VCALENDAR\n\
for( tmpprop = icalcomponent_get_first_property( fetchedevent, ICAL_X_PROPERTY );
tmpprop != 0 ;
tmpprop = icalcomponent_get_next_property( fetchedevent, ICAL_X_PROPERTY ) ) {
icalparameter *tmppar = icalproperty_get_first_parameter( tmpprop, ICAL_MEMBER_PARAMETER );
#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
}
@ -680,7 +667,7 @@ oeICalImpl::SetServer( const char *str ) {
icalfileset_free(stream);
for( int i=0; i<m_observerlist.size(); i++ ) {
for( unsigned int i=0; i<m_observerlist.size(); i++ ) {
m_observerlist[i]->OnLoad();
}
@ -716,7 +703,7 @@ NS_IMETHODIMP oeICalImpl::SetBatchMode(PRBool aBatchMode)
// tell observers about the change
for( int i=0; i<m_observerlist.size(); i++ )
for( unsigned int i=0; i<m_observerlist.size(); i++ )
{
if( m_batchMode )
m_observerlist[i]->OnStartBatch();
@ -743,17 +730,14 @@ NS_IMETHODIMP oeICalImpl::SetBatchMode(PRBool aBatchMode)
* RETURN
* None
*/
NS_IMETHODIMP oeICalImpl::AddEvent(oeIICalEvent *icalevent, PRInt32 *retid)
NS_IMETHODIMP oeICalImpl::AddEvent(oeIICalEvent *icalevent,char **retid)
{
#ifdef ICAL_DEBUG
printf( "oeICalImpl::AddEvent()\n" );
#endif
unsigned long newid;
icalfileset *stream;
icalcomponent *vcalendar,*fetchedcal;
char uidstr[10];
*retid = 0;
stream = icalfileset_new(serveraddr);
if ( !stream ) {
#ifdef ICAL_DEBUG
@ -762,32 +746,42 @@ NS_IMETHODIMP oeICalImpl::AddEvent(oeIICalEvent *icalevent, PRInt32 *retid)
return NS_OK;
}
((oeICalEventImpl *)icalevent)->GetId( (PRUint32 *)&newid );
printf( "HERE1\n" );
((oeICalEventImpl *)icalevent)->GetId( retid );
printf( "HERE2: %s\n", *retid );
if( newid == 0 ) {
if( *retid == nsnull ) {
printf( "HERE3\n" );
char uidstr[10];
do {
unsigned long newid;
newid = 900000000 + ((rand()%0x4ff) << 16) + rand()%0xFFFF;
sprintf( uidstr, "%lu", newid );
} while ( (fetchedcal = icalfileset_fetch( stream, uidstr )) != 0 );
((oeICalEventImpl *)icalevent)->SetId( newid );
((oeICalEventImpl *)icalevent)->SetId( uidstr );
((oeICalEventImpl *)icalevent)->GetId( retid );
}
printf( "HERE4\n" );
vcalendar = ((oeICalEventImpl *)icalevent)->AsIcalComponent();
printf( "HERE5\n" );
icalfileset_add_component( stream, vcalendar );
*retid = newid;
printf( "HERE6\n" );
icalfileset_commit( stream );
icalfileset_free( stream );
printf( "HERE7\n" );
icalevent->AddRef();
m_eventlist.Add( icalevent );
for( int i=0; i<m_observerlist.size(); i++ ) {
for( unsigned int i=0; i<m_observerlist.size(); i++ ) {
m_observerlist[i]->OnAddItem( icalevent );
}
printf( "HERE8\n" );
SetupAlarmManager();
return NS_OK;
}
@ -805,17 +799,14 @@ NS_IMETHODIMP oeICalImpl::AddEvent(oeIICalEvent *icalevent, PRInt32 *retid)
* RETURN
* None
*/
NS_IMETHODIMP oeICalImpl::ModifyEvent(oeIICalEvent *icalevent, PRInt32 *retid)
NS_IMETHODIMP oeICalImpl::ModifyEvent(oeIICalEvent *icalevent, char **retid)
{
#ifdef ICAL_DEBUG
printf( "oeICalImpl::ModifyEvent()\n" );
#endif
unsigned long id;
icalfileset *stream;
icalcomponent *vcalendar;
char uidstr[10];
*retid = 0;
stream = icalfileset_new(serveraddr);
if ( !stream ) {
#ifdef ICAL_DEBUG
@ -824,17 +815,24 @@ NS_IMETHODIMP oeICalImpl::ModifyEvent(oeIICalEvent *icalevent, PRInt32 *retid)
return NS_OK;
}
((oeICalEventImpl *)icalevent)->GetId( (PRUint32 *)&id );
((oeICalEventImpl *)icalevent)->GetId( retid );
if( *retid == nsnull ) {
#ifdef ICAL_DEBUG
printf( "oeICalImpl::ModifyEvent() - Invalid Id.\n" );
#endif
icalfileset_free(stream);
return NS_OK;
}
sprintf( uidstr, "%lu", id );
icalcomponent *fetchedcal = icalfileset_fetch( stream, uidstr );
icalcomponent *fetchedcal = icalfileset_fetch( stream, *retid );
oeICalEventImpl *oldevent=nsnull;
if( fetchedcal ) {
icalfileset_remove_component( stream, fetchedcal );
nsresult rv;
if( NS_FAILED( rv = NS_NewICalEvent((oeIICalEvent**) &oldevent ))) {
nsMemory::Free( *retid );
*retid = nsnull;
icalfileset_free(stream);
return rv;
}
@ -842,8 +840,10 @@ NS_IMETHODIMP oeICalImpl::ModifyEvent(oeIICalEvent *icalevent, PRInt32 *retid)
icalcomponent_free( fetchedcal );
} else {
#ifdef ICAL_DEBUG
printf( "WARNING Event not found.\n" );
printf( "oeICalImpl::ModifyEvent() - WARNING Event not found.\n" );
#endif
nsMemory::Free( *retid );
*retid = nsnull;
icalfileset_free(stream);
return NS_OK;
}
@ -851,12 +851,10 @@ NS_IMETHODIMP oeICalImpl::ModifyEvent(oeIICalEvent *icalevent, PRInt32 *retid)
vcalendar = ((oeICalEventImpl *)icalevent)->AsIcalComponent();
icalfileset_add_component( stream, vcalendar );
*retid = id;
icalfileset_commit( stream );
icalfileset_free(stream);
for( int i=0; i<m_observerlist.size(); i++ ) {
for( unsigned int i=0; i<m_observerlist.size(); i++ ) {
m_observerlist[i]->OnModifyItem( icalevent, oldevent );
}
@ -880,7 +878,7 @@ NS_IMETHODIMP oeICalImpl::ModifyEvent(oeIICalEvent *icalevent, PRInt32 *retid)
* RETURN
* None
*/
NS_IMETHODIMP oeICalImpl::FetchEvent(PRInt32 id, oeIICalEvent **ev)
NS_IMETHODIMP oeICalImpl::FetchEvent( const char *id, oeIICalEvent **ev)
{
#ifdef ICAL_DEBUG_ALL
printf( "oeICalImpl::FetchEvent()\n" );
@ -906,13 +904,12 @@ NS_IMETHODIMP oeICalImpl::FetchEvent(PRInt32 id, oeIICalEvent **ev)
* None
*/
NS_IMETHODIMP
oeICalImpl::DeleteEvent( PRInt32 id )
oeICalImpl::DeleteEvent( const char *id )
{
#ifdef ICAL_DEBUG
printf( "oeICalImpl::DeleteEvent( %lu )\n", id );
printf( "oeICalImpl::DeleteEvent( %s )\n", id );
#endif
icalfileset *stream;
char uidstr[10];
stream = icalfileset_new(serveraddr);
if ( !stream ) {
@ -922,14 +919,20 @@ oeICalImpl::DeleteEvent( PRInt32 id )
return NS_OK;
}
sprintf( uidstr, "%lu", id );
if( id == nsnull ) {
#ifdef ICAL_DEBUG
printf( "oeICalImpl::DeleteEvent() - Invalid Id.\n" );
#endif
icalfileset_free(stream);
return NS_OK;
}
icalcomponent *fetchedcal = icalfileset_fetch( stream, uidstr );
icalcomponent *fetchedcal = icalfileset_fetch( stream, id );
if( fetchedcal == 0 ) {
icalfileset_free(stream);
#ifdef ICAL_DEBUG
printf( "WARNING Event not found.\n" );
printf( "oeICalImpl::DeleteEvent() - WARNING Event not found.\n" );
#endif
return NS_OK;
}
@ -945,7 +948,7 @@ oeICalImpl::DeleteEvent( PRInt32 id )
m_eventlist.Remove( id );
for( int i=0; i<m_observerlist.size(); i++ ) {
for( unsigned int i=0; i<m_observerlist.size(); i++ ) {
m_observerlist[i]->OnDeleteItem( icalevent );
}
@ -966,14 +969,10 @@ oeICalImpl::GetAllEvents(nsISimpleEnumerator **resultList )
if (!eventEnum)
return NS_ERROR_OUT_OF_MEMORY;
eventEnum->Init( this );
EventList *tmplistptr = &m_eventlist;
while( tmplistptr ) {
if( tmplistptr->event ) {
PRUint32 tmpid;
tmplistptr->event->GetId( &tmpid );
eventEnum->AddEventId( tmpid );
eventEnum->AddEvent( tmplistptr->event );
}
tmplistptr = tmplistptr->next;
}
@ -996,8 +995,6 @@ oeICalImpl::SearchBySQL( const char *sqlstr, nsISimpleEnumerator **resultList )
if (!eventEnum)
return NS_ERROR_OUT_OF_MEMORY;
eventEnum->Init( this );
stream = icalfileset_new(serveraddr);
if ( !stream ) {
#ifdef ICAL_DEBUG
@ -1036,7 +1033,10 @@ oeICalImpl::SearchBySQL( const char *sqlstr, nsISimpleEnumerator **resultList )
return NS_OK;
}
eventEnum->AddEventId( atol( icalproperty_get_uid( prop ) ) );
oeIICalEvent* event = m_eventlist.GetEventById( icalproperty_get_uid( prop ) );
if( event != nsnull ) {
eventEnum->AddEvent( event );
}
}
icalfileset_free(stream);
@ -1138,8 +1138,6 @@ oeICalImpl::GetEventsForRange( PRTime checkdateinms, PRTime checkenddateinms, ns
if (!dateEnum)
return NS_ERROR_OUT_OF_MEMORY;
eventEnum->Init( this );
EventList *tmplistptr = &m_eventlist;
int i=0;
while( tmplistptr ) {
@ -1149,9 +1147,7 @@ oeICalImpl::GetEventsForRange( PRTime checkdateinms, PRTime checkenddateinms, ns
PRTime checkdateloop = checkdateinms;
tmpevent->GetNextRecurrence( checkdateloop, &checkdateloop, &isvalid );
while( isvalid && LL_CMP( checkdateloop, <, checkenddateinms ) ) {
PRUint32 tmpid;
tmpevent->GetId( &tmpid );
eventEnum->AddEventId( tmpid );
eventEnum->AddEvent( tmpevent );
dateEnum->AddDate( checkdateloop );
tmpevent->GetNextRecurrence( checkdateloop, &checkdateloop, &isvalid );
}
@ -1181,8 +1177,6 @@ oeICalImpl::GetNextNEvents( PRTime datems, PRInt32 maxcount, nsISimpleEnumerator
if (!dateEnum)
return NS_ERROR_OUT_OF_MEMORY;
eventEnum->Init( this );
struct icaltimetype checkdate = ConvertFromPrtime( datems );
checkdate.hour = 0;
checkdate.minute = 0;
@ -1199,9 +1193,7 @@ oeICalImpl::GetNextNEvents( PRTime datems, PRInt32 maxcount, nsISimpleEnumerator
PRTime checkdateloop = checkdateinms;
tmpevent->GetNextRecurrence( checkdateloop, &checkdateloop, &isvalid );
while( isvalid ) {
PRUint32 tmpid;
tmpevent->GetId( &tmpid );
eventEnum->AddEventId( tmpid );
eventEnum->AddEvent( tmpevent );
dateEnum->AddDate( checkdateloop );
count++;
if( count == maxcount )
@ -1279,7 +1271,7 @@ void oeICalImpl::SetupAlarmManager() {
printf( "ALARM WENT OFF: %s\n", icaltime_as_ctime( alarmtime ) );
#endif
for( int i=0; i<m_observerlist.size(); i++ ) {
for( unsigned int i=0; i<m_observerlist.size(); i++ ) {
m_observerlist[i]->OnAlarm( event );
}
}

View File

@ -37,6 +37,7 @@
#include "oeIICal.h"
#include <vector>
#include "nsITimer.h"
#include "oeICalEventImpl.h"
#define OE_ICAL_CID \
{ 0x0a8c5de7, 0x0d19, 0x4b95, { 0x82, 0xf4, 0xe0, 0xaf, 0x92, 0x45, 0x32, 0x27 } }
@ -67,23 +68,19 @@ public:
next->Add( e );
}
}
oeIICalEvent* GetEventById( PRUint32 id ) {
oeIICalEvent* GetEventById( const char *id ) {
if( !event )
return nsnull;
PRUint32 eid=0;
event->GetId( &eid );
if( eid == id )
if( ((oeICalEventImpl *)event)->matchId( id ) )
return event;
if( next )
return next->GetEventById( id );
return nsnull;
}
void Remove( PRUint32 id ) {
void Remove( const char *id ) {
if( !event )
return;
PRUint32 eid=0;
event->GetId( &eid );
if( eid == id ) {
if( ((oeICalEventImpl *)event)->matchId( id ) ) {
event->Release();
if( next ) {
event = next->event;

View File

@ -68,7 +68,7 @@ interface oeIICalEvent : nsISupports
{
readonly attribute oeIDateTime start;
readonly attribute oeIDateTime end;
attribute unsigned long id;
attribute string id;
attribute string title;
attribute string description;
attribute string location;
@ -95,7 +95,6 @@ interface oeIICalEvent : nsISupports
void addException( in PRTime exdate );
nsISimpleEnumerator getExceptions();
void setSnoozeTime( in PRTime exdate );
// PRTime calculateAlarmTime();
};
[scriptable, uuid(b8584baa-1507-40d4-b542-5a2758e1c86d)]
@ -119,10 +118,10 @@ interface oeIICal : nsISupports
void setServer( in string str );
void addObserver( in oeIICalObserver observer );
long addEvent( in oeIICalEvent icalevent );
long modifyEvent( in oeIICalEvent icalevent );
void deleteEvent( in long id );
oeIICalEvent fetchEvent( in long id );
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 );
nsISimpleEnumerator getAllEvents();
nsISimpleEnumerator getEventsForMonth(in PRTime date, out nsISimpleEnumerator datelist );
@ -131,9 +130,6 @@ interface oeIICal : nsISupports
nsISimpleEnumerator getEventsForRange(in PRTime begindate, in PRTime enddate, out nsISimpleEnumerator datelist );
nsISimpleEnumerator getNextNEvents(in PRTime begindate, in long count, out nsISimpleEnumerator datelist );
// nsISimpleEnumerator searchAlarm( in short year, in short month, in short day,
// in short hour, in short min );
// void AckAlarm( in oeIICalEvent icalevent );
};