Fixed bug 234069: Add a Last-Modified attribute to oeIICalEvent

git-svn-id: svn://10.0.0.236/trunk@152734 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
mostafah%oeone.com 2004-02-12 22:42:32 +00:00
parent 7392fae737
commit cfecb5d07f
5 changed files with 79 additions and 23 deletions

View File

@ -1281,10 +1281,21 @@ NS_IMETHODIMP oeICalContainerFilter::SetRecurForever(PRBool aNewVal)
return NS_ERROR_NOT_IMPLEMENTED;
}
NS_IMETHODIMP oeICalContainerFilter::GetLastAlarmAck(PRTime *aRetVal)
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;

View File

@ -293,6 +293,7 @@ oeICalEventImpl::oeICalEventImpl()
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 );
@ -908,6 +909,38 @@ NS_IMETHODIMP oeICalEventImpl::SetRecurForever(PRBool aNewVal)
return NS_OK;
}
NS_IMETHODIMP oeICalEventImpl::GetLastModified(PRTime *aRetVal)
{
#ifdef ICAL_DEBUG_ALL
printf( "GetLastModified()\n" );
#endif
if( icaltime_is_null_time( m_lastmodified ) )
return NS_ERROR_NOT_INITIALIZED;
*aRetVal = ConvertToPrtime( m_lastmodified );
return NS_OK;
}
NS_IMETHODIMP oeICalEventImpl::UpdateLastModified()
{
#ifdef ICAL_DEBUG_ALL
printf( "UpdateLastModified()\n" );
#endif
PRInt64 nowinusec = PR_Now();
PRExplodedTime ext;
PR_ExplodeTime( nowinusec, PR_GMTParameters, &ext);
m_lastmodified = icaltime_null_time();
m_lastmodified.year = ext.tm_year;
m_lastmodified.month = ext.tm_month + 1;
m_lastmodified.day = ext.tm_mday;
m_lastmodified.hour = ext.tm_hour;
m_lastmodified.minute = ext.tm_min;
m_lastmodified.second = ext.tm_sec;
m_lastmodified.is_utc = true;
return NS_OK;
}
NS_IMETHODIMP oeICalEventImpl::GetLastAlarmAck(PRTime *aRetVal)
{
#ifdef ICAL_DEBUG_ALL
@ -2130,10 +2163,15 @@ bool oeICalEventImpl::ParseIcalComponent( icalcomponent *comp )
prop = icalcomponent_get_first_property( vevent, ICAL_DTSTAMP_PROPERTY );
if ( prop != 0) {
m_stamp->m_datetime = icalproperty_get_dtstamp( prop );
} else {
m_stamp->m_datetime = icaltime_null_time();
}
//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
@ -2667,12 +2705,18 @@ icalcomponent* oeICalEventImpl::AsIcalComponent()
if( starttzid )
nsMemory::Free( starttzid );
//stampdate
if( m_stamp && !icaltime_is_null_time( m_stamp->m_datetime ) ) {
//stampdate
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;

View File

@ -157,6 +157,7 @@ private:
oeDateTimeImpl *m_stamp;
oeDateTimeImpl *m_recurend;
icaltimetype m_lastalarmack;
icaltimetype m_lastmodified;
nsVoidArray m_exceptiondates;
nsVoidArray m_snoozetimes;
icaltimetype CalculateAlarmTime( icaltimetype date );

View File

@ -1021,27 +1021,11 @@ NS_IMETHODIMP oeICalImpl::ModifyEvent(oeIICalEvent *icalevent, char **retid)
return NS_OK;
}
//Update Last-Modified
icalevent->UpdateLastModified();
vcalendar = ((oeICalEventImpl *)icalevent)->AsIcalComponent();
//Add Last-Modified property
icalcomponent *vevent = icalcomponent_get_first_component( vcalendar, ICAL_VEVENT_COMPONENT );
if( vevent ) {
PRInt64 nowinusec = PR_Now();
PRExplodedTime ext;
PR_ExplodeTime( nowinusec, PR_GMTParameters, &ext);
icaltimetype now = icaltime_null_time();
now.year = ext.tm_year;
now.month = ext.tm_month + 1;
now.day = ext.tm_mday;
now.hour = ext.tm_hour;
now.minute = ext.tm_min;
now.second = ext.tm_sec;
now.is_utc = true;
icalproperty *prop = icalproperty_new_lastmodified( now );
icalcomponent_add_property( vevent, prop );
}
icalfileset_add_component( stream, vcalendar );
if( icalfileset_commit(stream) != ICAL_NO_ERROR ) {
@ -2181,6 +2165,9 @@ NS_IMETHODIMP oeICalImpl::ModifyTodo(oeIICalTodo *icalevent, char **retid)
return NS_OK;
}
//Update Last-Modified
icalevent->UpdateLastModified();
vcalendar = ((oeICalTodoImpl *)icalevent)->AsIcalComponent();
icalfileset_add_component( stream, vcalendar );
@ -2567,6 +2554,15 @@ 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;

View File

@ -106,6 +106,8 @@ interface oeIICalEvent : nsISupports
readonly attribute oeIDateTime stamp;
readonly attribute oeIICal parent;
readonly attribute Componenttype type;
readonly attribute PRTime lastModified;
attribute string id;
attribute AUTF8String title;
attribute AUTF8String description;
@ -161,6 +163,8 @@ interface oeIICalEvent : nsISupports
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)]