From cfecb5d07fdbd2cd78ca9db3ec16bbe963cc57bb Mon Sep 17 00:00:00 2001 From: "mostafah%oeone.com" Date: Thu, 12 Feb 2004 22:42:32 +0000 Subject: [PATCH] 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 --- .../libxpical/oeICalContainerImpl.cpp | 13 ++++- .../calendar/libxpical/oeICalEventImpl.cpp | 50 +++++++++++++++++-- mozilla/calendar/libxpical/oeICalEventImpl.h | 1 + mozilla/calendar/libxpical/oeICalImpl.cpp | 34 ++++++------- mozilla/calendar/libxpical/oeIICal.idl | 4 ++ 5 files changed, 79 insertions(+), 23 deletions(-) diff --git a/mozilla/calendar/libxpical/oeICalContainerImpl.cpp b/mozilla/calendar/libxpical/oeICalContainerImpl.cpp index aede51885b7..d674fc8104d 100644 --- a/mozilla/calendar/libxpical/oeICalContainerImpl.cpp +++ b/mozilla/calendar/libxpical/oeICalContainerImpl.cpp @@ -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; diff --git a/mozilla/calendar/libxpical/oeICalEventImpl.cpp b/mozilla/calendar/libxpical/oeICalEventImpl.cpp index 0873df740b6..677c0798e5c 100644 --- a/mozilla/calendar/libxpical/oeICalEventImpl.cpp +++ b/mozilla/calendar/libxpical/oeICalEventImpl.cpp @@ -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; diff --git a/mozilla/calendar/libxpical/oeICalEventImpl.h b/mozilla/calendar/libxpical/oeICalEventImpl.h index e0688f94d24..31cd877b344 100644 --- a/mozilla/calendar/libxpical/oeICalEventImpl.h +++ b/mozilla/calendar/libxpical/oeICalEventImpl.h @@ -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 ); diff --git a/mozilla/calendar/libxpical/oeICalImpl.cpp b/mozilla/calendar/libxpical/oeICalImpl.cpp index e029f36242d..25e2467e673 100644 --- a/mozilla/calendar/libxpical/oeICalImpl.cpp +++ b/mozilla/calendar/libxpical/oeICalImpl.cpp @@ -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; diff --git a/mozilla/calendar/libxpical/oeIICal.idl b/mozilla/calendar/libxpical/oeIICal.idl index 44eb7f59ba4..768a8cbca2e 100644 --- a/mozilla/calendar/libxpical/oeIICal.idl +++ b/mozilla/calendar/libxpical/oeIICal.idl @@ -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)]