diff -r a3a1ae9acec6 -r da5135c61bad meetingrequest/mrentry/src/cesmrmeetingrequestentry.cpp --- a/meetingrequest/mrentry/src/cesmrmeetingrequestentry.cpp Mon Mar 15 12:39:10 2010 +0200 +++ b/meetingrequest/mrentry/src/cesmrmeetingrequestentry.cpp Wed Mar 31 21:08:33 2010 +0300 @@ -1,5 +1,5 @@ /* -* Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies). +* Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies). * All rights reserved. * This component and the accompanying materials are made available * under the terms of "Eclipse Public License v1.0" @@ -17,14 +17,6 @@ // INCLUDE FILES -// -#include "emailtrace.h" -#include "cesmralarminfohandler.h" -#include "cesmrrecurrenceinfohandler.h" -// -#include -#include - #include "cesmrmeetingrequestentry.h" #include "cesmrfsmailboxutils.h" #include "cesmrcaldbmgr.h" @@ -32,25 +24,37 @@ #include "esmrentryhelper.h" #include "cesmrconflictchecker.h" #include "cesmrcaluserutil.h" +#include "cesmralarminfohandler.h" +#include "cesmrrecurrenceinfohandler.h" +#include "mmrinfoobject.h" +#include "mmrattendee.h" + +#include "CFSMailMessage.h" + #include "esmrconfig.hrh" +#include "cesmrfeaturesettings.h" + +#include "emailtrace.h" #include #include #include #include #include -#include +#include +#include #include #include -// -#include "mmrinfoobject.h" -#include "mmrattendee.h" -// -#include +#include +#include +#include #include #include #include #include +#include +#include +#include /// Unnamed namespace for local definitions namespace { @@ -58,18 +62,6 @@ // Alarm resource file location _LIT( KAlarmInfoResource, "esmralarminfo.rsc" ); -// Definition for first index -const TInt KFirstIndex = 0; - -// Definition for 0 -const TInt KZero = 0; - -// Definition for 1 -const TInt KOne = 1; - -// Definition for number of hours within day -const TInt KHoursInDay = 24; - // Definition for default alarm time for meeting const TInt KDefaultMeetingAlarmMinutes( 15 ); @@ -77,63 +69,41 @@ _LIT( KLineFeed, "\x2029"); /** - * Finds matching calendar instance from calendar db. Ownership is - * transferred, If instance cannot be found, NULL is returned. - * - * @param aCalDb Reference to cal db manager. - * @param aEntry Reference to calendar entry - * @return Pointer to calendar entry instance. + * Sets phone owner to entry. + * @param aMbUtils Reference to mailbox utils. + * @param aEntry Reference to calendar entry. */ -CCalInstance* FindInstanceL( - MESMRCalDbMgr& aCalDb, +void SetPhoneOwnerL( + CMRMailboxUtils& aMbUtils, CCalEntry& aEntry ) { - CCalInstance* instance = NULL; - RCPointerArray calInstances; - CleanupClosePushL( calInstances ); - - CCalInstanceView* instanceView = - aCalDb.NormalDbInstanceView(); - - CalCommon::TCalViewFilter instanceFilter = - CalCommon::EIncludeAppts | - CalCommon::EIncludeEvents; - - // Removing one seconds from start time and adding one second to stop - // time. Otherwise wanted entry is not included into results. - TCalTime startTime; - startTime.SetTimeLocalL( - aEntry.StartTimeL().TimeLocalL() - TTimeIntervalSeconds(KOne) ); - TCalTime endTime; - endTime.SetTimeLocalL( - aEntry.EndTimeL().TimeLocalL() + TTimeIntervalSeconds(KOne) ); - - TDateTime start = startTime.TimeLocalL().DateTime(); - TDateTime end = endTime.TimeLocalL().DateTime(); - - CalCommon::TCalTimeRange timeRange( - startTime, - endTime ); - - instanceView->FindInstanceL( - calInstances, - instanceFilter, - timeRange); - - TInt instanceCount( calInstances.Count() ); - for (TInt i = 0; (i < instanceCount && !instance); ++i) - { - CCalEntry& entry = calInstances[i]->Entry(); - - // Finding the entry we are intrested for - if ( !entry.UidL().Compare( aEntry.UidL() ) ) - { - instance = calInstances[i]; - calInstances.Remove( i ); - } - } - CleanupStack::PopAndDestroy(); // arrayCleanup - return instance; + CESMRFsMailboxUtils* fsMbUtils = + CESMRFsMailboxUtils::NewL( aMbUtils ); + CleanupStack::PushL( fsMbUtils ); + + fsMbUtils->SetPhoneOwnerL( aEntry ); + CleanupStack::PopAndDestroy( fsMbUtils ); + fsMbUtils = NULL; + } + +/** + * Makes copy of the entry and sets phone owner accordingly + * @param aMbUtils Reference to mailbox utils. + * @param aEntry Reference to calendar entry. + */ +CCalEntry* CopyEntryL( + CMRMailboxUtils& aMbUtils, + const CCalEntry& aEntry ) + { + CCalEntry* entry = ESMRHelper::CopyEntryL( + aEntry, + aEntry.MethodL(), + ESMRHelper::ECopyFull, + EESMREventTypeMeetingRequest ); + + SetPhoneOwnerL( aMbUtils, *entry ); + + return entry; } #ifdef _DEBUG @@ -183,7 +153,8 @@ : iMRMailboxUtils( aMRMailboxUtils ), iConflictsExists( aConflictsExists), iCalDb( aCalDb ), - iESMRInputParams( aESMRInputParams ) + iESMRInputParams( aESMRInputParams ), + iSendCanellation( ETrue ) { FUNC_LOG; // Not yet implementation @@ -193,21 +164,20 @@ // CESMRMeetingRequestEntry::~CESMRMeetingRequestEntry // --------------------------------------------------------------------------- // -CESMRMeetingRequestEntry::~CESMRMeetingRequestEntry() +EXPORT_C CESMRMeetingRequestEntry::~CESMRMeetingRequestEntry() { FUNC_LOG; delete iEntry; delete iForwardEntry; delete iOrginalEntry; delete iParameterEntry; - delete iBackupEntry; } // --------------------------------------------------------------------------- // CESMRMeetingRequestEntry::NewL // --------------------------------------------------------------------------- // -CESMRMeetingRequestEntry* CESMRMeetingRequestEntry::NewL( +EXPORT_C CESMRMeetingRequestEntry* CESMRMeetingRequestEntry::NewL( const CCalEntry& aEntry, CMRMailboxUtils& aMRMailboxUtils, MESMRCalDbMgr& aCalDb, @@ -238,31 +208,12 @@ const CCalEntry& aEntry ) { FUNC_LOG; - - iParameterEntry = ESMRHelper::CopyEntryL( - aEntry, - aEntry.MethodL(), - ESMRHelper::ECopyFull ); - iBackupEntry=ESMRHelper::CopyEntryL( - aEntry, - aEntry.MethodL(), - ESMRHelper::ECopyFull ); - iEntry = ESMRHelper::CopyEntryL( - aEntry, - aEntry.MethodL(), - ESMRHelper::ECopyFull ); - - if ( !IsStoredL() && !IsOpenedFromMail() ) - { - // by default when creating a meeting the priority value is normal - SetPriorityL( EFSCalenMRPriorityNormal ); - } - - iOrginalEntry = ESMRHelper::CopyEntryL( - aEntry, - aEntry.MethodL(), - ESMRHelper::ECopyFull ); - + + iParameterEntry = CopyEntryL( iMRMailboxUtils, aEntry ); + iEntry = CopyEntryL( iMRMailboxUtils, aEntry ); + + iOrginalEntry = CopyEntryL( iMRMailboxUtils, aEntry ); + if ( EESMRRoleOrganizer == RoleL() && IsStoredL() ) { // Increase sequence number @@ -281,39 +232,52 @@ } HBufC* newDescription = ReplaceCharactersFromBufferLC( - iEntry->DescriptionL(), + iEntry->DescriptionL(), KReplaceLineFeedChar(), KLineFeed() ); iEntry->SetDescriptionL( *newDescription ); + iOrginalEntry->SetDescriptionL( *newDescription ); + CleanupStack::PopAndDestroy( newDescription ); - + + __ASSERT_DEBUG( iEntry->PhoneOwnerL(), Panic( EESMRPhoneOwnerNotSet) ); + + CESMRFeatureSettings* settings = CESMRFeatureSettings::NewL(); + if ( settings->FeatureSupported( + CESMRFeatureSettings::EMRUIMeetingRequestViewerCmailOnly ) ) + { + // Meeting request viewer available only from email. + // Remove attachments from entry. + iRemoveAttachments = ETrue; + } + delete settings; } // --------------------------------------------------------------------------- // CESMRMeetingRequestEntry::ReplaceCharactersFromBufferL // --------------------------------------------------------------------------- // -HBufC* CESMRMeetingRequestEntry::ReplaceCharactersFromBufferLC( const TDesC& aTarget, - const TDesC& aFindString, +HBufC* CESMRMeetingRequestEntry::ReplaceCharactersFromBufferLC( const TDesC& aTarget, + const TDesC& aFindString, const TDesC& aReplacement ) { FUNC_LOG; HBufC* newBuffer = aTarget.AllocLC(); TPtr16 ptr = newBuffer->Des(); - + // find next occurance: TInt offset = ptr.Find(aFindString); while ( offset != KErrNotFound ) { // replace the data: ptr.Replace( offset, aFindString.Length(), aReplacement); - + // find next occurance: offset = ptr.Find(aFindString); } - + return newBuffer; - } + } // --------------------------------------------------------------------------- // CESMRMeetingRequestEntry::Type @@ -390,24 +354,21 @@ CCalInstance* instance = NULL; - instance = FindInstanceL( iCalDb, *iEntry ); + instance = iCalDb.FindInstanceL( *iEntry ); if ( !instance ) { // Instance not found by using the edited entry // Trying with orginal. - instance = FindInstanceL( iCalDb, *iOrginalEntry ); + instance = iCalDb.FindInstanceL( *iOrginalEntry ); } if ( !instance ) { // Instance not found by using edited or orginal entry. // --> Leave - - User::Leave( KErrNotFound ); } - return instance; } @@ -422,7 +383,7 @@ __ASSERT_DEBUG( iEntry, Panic(EESMREntryNotExist ) ); TBool canSetRecurrence( ETrue ); - + if ( iEntry->EntryTypeL() == CCalEntry::EAppt && ESMREntryHelper::IsRepeatingMeetingL(*iEntry) && (!ESMREntryHelper::IsModifyingEntryL(*iEntry) && @@ -454,7 +415,7 @@ // Ownership is transferred CCalInstance* instance = NULL; TRAPD(err, instance = InstanceL() ); - if ( KErrNotFound != err&&err!=KErrNone ) + if ( KErrNotFound != err ) { User::LeaveIfError( err ); } @@ -540,11 +501,10 @@ __ASSERT_DEBUG( iEntry, Panic(EESMREntryNotExist ) ); CESMRRecurrenceInfoHandler* recurrenceHandler = - CESMRRecurrenceInfoHandler::NewLC( *iEntry ); + CESMRRecurrenceInfoHandler::NewLC( *iEntry, &iCalDb ); recurrenceHandler->GetRecurrenceL( aRecurrence, aUntil ); CleanupStack::PopAndDestroy( recurrenceHandler ); - } // --------------------------------------------------------------------------- @@ -562,7 +522,7 @@ // --------------------------------------------------------------------------- // void CESMRMeetingRequestEntry::SetModifyingRuleL( - TESMRRecurrenceModifyingRule aRule ) + TESMRRecurrenceModifyingRule aRule, const TBool aTypeChanging ) { FUNC_LOG; @@ -578,18 +538,16 @@ recHandler->GetRecurrenceL( orginalRecurrence, orginalUntil); - CleanupStack::PopAndDestroy( recHandler ); recHandler = NULL; + TBool modifyingEntry( ESMREntryHelper::IsModifyingEntryL( *iEntry ) ); if ( MESMRCalEntry::EESMRAllInSeries == aRule && - IsStoredL() && !IsForwardedL() && !IsOpenedFromMail() ) + IsStoredL() && !IsForwardedL() && !IsOpenedFromMail() && !aTypeChanging ) { // When we want to modify series of recurrence entries --> // Parent entry is modified - - TBool modifyingEntry( ESMREntryHelper::IsModifyingEntryL( *iEntry ) ); if ( ERecurrenceNot == orginalRecurrence && !modifyingEntry ) { // Orginal entry was not recurrent event @@ -611,27 +569,24 @@ CleanupStack::PushL( instance ); CCalEntry::TMethod entryMethod( iEntry->MethodL() ); - CCalEntry* iBackupEntry=ESMRHelper::CopyEntryL( - *iEntry, - entryMethod, - ESMRHelper::ECopyFull); - delete iEntry; + + delete iEntry; iEntry = NULL; - - delete iForwardEntry; + + delete iForwardEntry; iForwardEntry = NULL; - - delete iOrginalEntry; + + delete iOrginalEntry; iOrginalEntry = NULL; RCPointerArray entries; CleanupClosePushL( entries ); - iCalDb.NormalDbEntryView()->FetchL( + iCalDb.EntryViewL( instance->Entry() )->FetchL( instance->Entry().UidL(), entries ); TInt parentIndex( KErrNotFound ); - TInt entryCount( entries.Count() ); + TInt entryCount( entries.Count() ); for ( TInt i(0); i < entryCount && KErrNotFound == parentIndex; ++i ) { TBool modifyingEntry( ESMREntryHelper::IsModifyingEntryL( *entries[i]) ); @@ -642,24 +597,13 @@ } __ASSERT_DEBUG( KErrNotFound != parentIndex, Panic(EESMRParentNotFound) ); - + CCalEntry& parent = *entries[parentIndex]; TPtrC description( parent.DescriptionL() ); - - iEntry = ESMRHelper::CopyEntryL( - parent, - parent.MethodL(), - ESMRHelper::ECopyFull ); - - CESMRFsMailboxUtils* fsMbUtils = - CESMRFsMailboxUtils::NewL( iMRMailboxUtils ); - CleanupStack::PushL( fsMbUtils ); - - fsMbUtils->SetPhoneOwnerL( *iBackupEntry ); - CleanupStack::PopAndDestroy( fsMbUtils ); - fsMbUtils = NULL; - + + iEntry = CopyEntryL( iMRMailboxUtils, parent ); + // Adjust parent entry's start and end time to entry TCalTime start; TCalTime end; @@ -673,10 +617,7 @@ iEntry->SetStartAndEndTimeL( start, end ); - iOrginalEntry = ESMRHelper::CopyEntryL( - *iEntry, - iEntry->MethodL(), - ESMRHelper::ECopyFull ); + iOrginalEntry = CopyEntryL( iMRMailboxUtils, *iEntry ); if ( iEntry->MethodL() != entryMethod ) { @@ -686,8 +627,7 @@ iEntry->SetDescriptionL( description ); iOrginalEntry->SetDescriptionL( description ); - iEntry=ESMRHelper::CopyEntryL(*iBackupEntry,iBackupEntry->MethodL(),ESMRHelper::ECopyFull); - + CleanupStack::PopAndDestroy(); // entries CleanupStack::PopAndDestroy( instance ); @@ -700,7 +640,15 @@ } } } - + else if ( ERecurrenceNot != orginalRecurrence && + aTypeChanging && !modifyingEntry ) + { + // if entry( in the memory) is a recurrent event + // ,and if entry type is changing, and not in modifying status then EESMRAllInSeries + iRecurrenceModRule = EESMRAllInSeries ; + return; + } + iRecurrenceModRule = aRule; } @@ -728,10 +676,10 @@ start.Set( aStartDate.DateTime().Year(), aStartDate.DateTime().Month(), aStartDate.DateTime().Day(), - KZero, - KZero, - KZero, - KZero); + 0, + 0, + 0, + 0); // set the end date to next day from given end date since // all day event should last 24 hours. @@ -739,10 +687,10 @@ end.Set( endDate.DateTime().Year(), endDate.DateTime().Month(), endDate.DateTime().Day(), - KZero, - KZero, - KZero, - KZero ); + 0, + 0, + 0, + 0 ); startTime.SetTimeLocalL( start ); stopTime.SetTimeLocalL( end ); @@ -762,34 +710,11 @@ __ASSERT_DEBUG( iEntry, Panic(EESMREntryNotExist ) ); - TBool allDayEvent(EFalse); - - TCalTime startTime = iEntry->StartTimeL(); - TCalTime stopTime = iEntry->EndTimeL(); - - TTimeIntervalHours hoursBetweenStartAndEnd; - stopTime.TimeLocalL().HoursFrom( - startTime.TimeLocalL(), - hoursBetweenStartAndEnd ); - - TCalTime::TTimeMode mode = startTime.TimeMode(); - - TInt hoursBetweenStartAndEndAsInt( hoursBetweenStartAndEnd.Int() ); - TInt alldayDivident( hoursBetweenStartAndEndAsInt % KHoursInDay ); - - if ( hoursBetweenStartAndEndAsInt&& KZero == alldayDivident ) - { - TDateTime startTimeLocal = startTime.TimeLocalL().DateTime(); - TDateTime stopTimeLocal = stopTime.TimeLocalL().DateTime(); - - if ( startTimeLocal.Hour() == stopTimeLocal.Hour() && - startTimeLocal.Minute() == stopTimeLocal.Minute() && - startTimeLocal.Second() == stopTimeLocal.Second() ) - { - allDayEvent = ETrue; - } - } - + CESMRCalUserUtil* entryUtil = CESMRCalUserUtil::NewLC( *iEntry ); + + TBool allDayEvent( entryUtil->IsAlldayEventL() ); + + CleanupStack::PopAndDestroy( entryUtil ); return allDayEvent; } @@ -806,16 +731,16 @@ TBool ret(EFalse); CCalEntry* dbEntry = NULL; - + TRAPD( err, dbEntry = iCalDb.FetchEntryL( iEntry->UidL(), iEntry->RecurrenceIdL() ) ); - + if ( KErrNotFound == err ) { - // Error has occured while retrieving an entry + // Error has occured while retrieving an entry ret = EFalse; - } + } else if ( dbEntry) { // Entry was found from the calendar db --> it is stored for sure. @@ -844,7 +769,7 @@ { CCalEntry::TStatus status( iOrginalEntry->StatusL() ); if ( CCalEntry::ENullStatus != status ) - { // When we send a request for the first time we set + { // When we send a request for the first time we set // it's status to some other value than ENullStatus retVal = ETrue; } @@ -852,10 +777,12 @@ else { // In attendee mode, we have sent the entry, if it is stored to - // calendar db and status is not declined. Declined entries are - // not stored to calendar db. + // calendar db and status is known and not declined. + // Declined entries are not stored to calendar db. TESMRAttendeeStatus currentStatus( AttendeeStatusL() ); - if ( IsStoredL() && EESMRAttendeeStatusDecline != currentStatus) + if ( IsStoredL() + && EESMRAttendeeStatusUnknown != currentStatus + && EESMRAttendeeStatusDecline != currentStatus ) { retVal = ETrue; } @@ -924,6 +851,13 @@ edited = ETrue; } + if( IsStoredL() ) + { + if ( iCalDb.EntryViewL( *iEntry ) != iCalDb.EntryView() ) + { + edited = ETrue; + } + } } @@ -932,6 +866,17 @@ } // --------------------------------------------------------------------------- +// CESMRMeetingRequestEntry::IsEntryTypeChangedL +// --------------------------------------------------------------------------- +// +TBool CESMRMeetingRequestEntry::IsEntryTypeChangedL() const + { + FUNC_LOG; + + return iTypeChanged; + } + +// --------------------------------------------------------------------------- // CESMRMeetingRequestEntry::GetAlarmL // --------------------------------------------------------------------------- // @@ -967,7 +912,7 @@ { aAlarmType = MESMRCalEntry::EESMRAlarmAbsolute; - // only meeting request that is not allday event can have + // only meeting request that is not allday event can have // relative alarm: if ( !IsAllDayEventL() ) { @@ -978,7 +923,7 @@ if ( KErrNone == err ) { aAlarmType = MESMRCalEntry::EESMRAlarmRelative; - if( alarmInfo.iRelativeAlarmInSeconds < KZero ) + if( alarmInfo.iRelativeAlarmInSeconds < 0 ) { aAlarmType = MESMRCalEntry::EESMRAlarmNotFound; } @@ -1003,6 +948,192 @@ // --------------------------------------------------------------------------- +// CESMRMeetingRequestEntry::UpdateEntryAfterStoringL +// --------------------------------------------------------------------------- +// +void CESMRMeetingRequestEntry::UpdateEntryAfterStoringL() + { + FUNC_LOG; + + __ASSERT_DEBUG( iEntry, Panic(EESMREntryNotExist ) ); + + CCalEntry* storedEntry = NULL; + + + if ( IsRecurrentEventL() && + EESMRThisOnly == iRecurrenceModRule && + !IsForwardedL() && IsStoredL() && + !ESMREntryHelper::IsModifyingEntryL(*iEntry) ) + { + // We have stored one instance of series. + storedEntry = iCalDb.FetchEntryL( + iEntry->UidL(), + iOrginalEntry->StartTimeL() ); + } + else + { + // We are dealing with single instance or with the series + storedEntry = iCalDb.FetchEntryL( + iEntry->UidL(), + iEntry->RecurrenceIdL() ); + } + + + __ASSERT_DEBUG( storedEntry, Panic( EESMREntryNotExist ) ); + CleanupStack::PushL( storedEntry ); + + // Description needs to be fecthed explicitly into memory + TPtrC description( storedEntry->DescriptionL() ); + + + delete iEntry; + iEntry = NULL; + iEntry = CopyEntryL( iMRMailboxUtils, *storedEntry ); + + if ( MESMRCalEntry::EESMRAllInSeries == iRecurrenceModRule && + IsRecurrentEventL() ) + { + // Adjust parent entry's start and end time to entry + TCalTime start; + TCalTime end; + + CESMRRecurrenceInfoHandler* recurrenceHandler = + CESMRRecurrenceInfoHandler::NewLC( *iEntry ); + + recurrenceHandler->GetFirstInstanceTimeL( start, end ); + CleanupStack::PopAndDestroy( recurrenceHandler ); + recurrenceHandler = NULL; + + iEntry->SetStartAndEndTimeL( start, end ); + iEntry->SetDescriptionL( description ); + } + + CCalEntry* temp = CopyEntryL( iMRMailboxUtils, *iEntry ); + + delete iOrginalEntry; + iOrginalEntry = temp; + + CleanupStack::PopAndDestroy( storedEntry ); + } + +// ---------------------------------------------------------------------------- +// CMRCalEntry::UpdateComparativeEntry +// ---------------------------------------------------------------------------- +// +void CESMRMeetingRequestEntry::UpdateComparativeEntry( + CCalEntry* aNewComparativeEntry ) + { + FUNC_LOG; + + if( iOrginalEntry ) // Update comparative entry + { + delete iOrginalEntry; + iOrginalEntry = NULL; + + iOrginalEntry = aNewComparativeEntry; + } + + } + +// --------------------------------------------------------------------------- +// CESMRMeetingRequestEntry::SetDefaultValuesToEntryL +// --------------------------------------------------------------------------- +// +void CESMRMeetingRequestEntry::SetDefaultValuesToEntryL() + { + FUNC_LOG; + + if ( !IsStoredL() ) + { + SetPriorityL( EFSCalenMRPriorityNormal ); + + // Get default alarm time from central repository + TInt defaultAlarmTime=0; + CRepository* repository = CRepository::NewLC( KCRUidCalendar ); + + TInt err = KErrNotFound; + + if ( repository ) + { + err = repository->Get( + KCalendarDefaultAlarmTime, + defaultAlarmTime ); + CleanupStack::PopAndDestroy( repository ); + } + + if ( err != KErrNone ) + { + // By default 15 minutes if not found from central repository + defaultAlarmTime = KDefaultMeetingAlarmMinutes; + } + + // Getting current time + TTime currentTime; + currentTime.HomeTime(); + + // Getting meeting start time + TTime start = iEntry->StartTimeL().TimeLocalL(); + + // Create default alarm + CCalAlarm* alarm = CCalAlarm::NewL(); + CleanupStack::PushL( alarm ); + + TTimeIntervalMinutes alarmOffset( defaultAlarmTime ); + + // If alarm time is in past + if ( ( start - alarmOffset ) < currentTime ) + { + // Setting alarm off + iEntry->SetAlarmL( NULL ); + } + else + { + // Set default alarm time + alarm->SetTimeOffset( alarmOffset ); + iEntry->SetAlarmL( alarm ); + } + CleanupStack::PopAndDestroy( alarm ); + } + + // Set the default end time if not set by client + if ( iEntry->StartTimeL().TimeUtcL() == iEntry->EndTimeL().TimeUtcL() ) + { + // This value might also be read from cenrep + TTimeIntervalHours KDefaultMeetingDuration(1); + + TCalTime newEndTime; + newEndTime.SetTimeUtcL( + iEntry->StartTimeL().TimeUtcL() + KDefaultMeetingDuration ); + iEntry->SetStartAndEndTimeL(iEntry->StartTimeL(), newEndTime); + } + + iEntry->SetReplicationStatusL( CCalEntry::EOpen ); + + //Original entry must be stored after the default values are set. + //Otherwise it looks like settings are changed even though they haven't + CCalEntry* temp = CopyEntryL( iMRMailboxUtils, *iEntry ); + + delete iOrginalEntry; + iOrginalEntry = temp; + } + +// --------------------------------------------------------------------------- +// CESMRMeetingRequestEntry::CloneEntryLC +// --------------------------------------------------------------------------- +// +CCalEntry* CESMRMeetingRequestEntry::CloneEntryLC( + TESMRCalEntryType aType ) const + { + CCalEntry* entry = + ESMRHelper::CopyEntryLC( *iEntry, + iEntry->MethodL(), + ESMRHelper::ECopyFull, + TESMRCalendarEventType( aType ) ); + + return entry; + } + +// --------------------------------------------------------------------------- // CESMRMeetingRequestEntry::RoleL // --------------------------------------------------------------------------- // @@ -1108,7 +1239,7 @@ attendee->SetStatusL(status); iEntry->SetStatusL(entryStatus); - + iEntry->SetMethodL( CCalEntry::EMethodReply ); } @@ -1127,11 +1258,11 @@ TBool outOfDate( EFalse ); CCalEntry::TMethod method( iEntry->MethodL() ); - if ( IsOpenedFromMail() && + if ( IsOpenedFromMail() && CCalEntry::EMethodCancel != method ) { CCalEntry* dbEntry = NULL; - + TRAP_IGNORE( dbEntry = iCalDb.FetchEntryL( iEntry->UidL(), iEntry->RecurrenceIdL() ) ); @@ -1205,6 +1336,10 @@ CCalAttendee::TCalStatus attendeeStatus( attendee->StatusL() ); switch ( attendeeStatus ) { + case CCalAttendee::ENeedsAction: + status = EESMRAttendeeStatusUnknown; + break; + case CCalAttendee::EAccepted: status = EESMRAttendeeStatusAccept; break; @@ -1254,13 +1389,10 @@ FUNC_LOG; __ASSERT_DEBUG( iEntry, Panic(EESMREntryNotExist ) ); - - CCalEntry* temp = ESMRHelper::CopyEntryL( - *iEntry, - iEntry->MethodL(), - ESMRHelper::ECopyFull ); - - delete iForwardEntry; + + CCalEntry* temp = CopyEntryL( iMRMailboxUtils, *iEntry ); + + delete iForwardEntry; iForwardEntry = temp; RPointerArray& attendeeList = @@ -1269,7 +1401,7 @@ while ( attendeeList.Count() ) { //remove attendees from entry that is to be forwarded - iForwardEntry->DeleteAttendeeL( KFirstIndex ); + iForwardEntry->DeleteAttendeeL( 0 ); } } @@ -1308,11 +1440,11 @@ iForwardEntry->SetStatusL( CCalEntry::EConfirmed ); } else if ( RoleL() == EESMRRoleOrganizer || - iEntry->StatusL() == CCalEntry::ENullStatus ) + iEntry->StatusL() == CCalEntry::ENullStatus ) { iEntry->SetStatusL( CCalEntry::EConfirmed ); } - + } // --------------------------------------------------------------------------- @@ -1364,8 +1496,6 @@ MESMRMeetingRequestEntry::TESMREntryInfo info = EESMREntryInfoNormal; - TBool isSent( IsSentL() ); - if ( IsEntryOutOfDateL() ) { info = EESMREntryInfoOutOfDate; @@ -1374,7 +1504,7 @@ { info = EESMREntryInfoCancelled; } - else if ( isSent ) + else if ( IsSentL() ) { info = EESMREntryInfoAccepted; if ( EESMRAttendeeStatusTentative == attendeeStatus ) @@ -1386,10 +1516,6 @@ { info = EESMREntryInfoOccursInPast; } - else if ( iConflictsExists ) - { - info = EESMREntryInfoConflicts; - } return info; @@ -1466,10 +1592,7 @@ if ( iForwardEntry ) { - entry = ESMRHelper::CopyEntryL( - *iForwardEntry, - iForwardEntry->MethodL(), - ESMRHelper::ECopyFull ); + entry = CopyEntryL( iMRMailboxUtils, *iForwardEntry ); } if ( !entry && IsRecurrentEventL() && @@ -1506,15 +1629,15 @@ parent.EntryTypeL(), guid, parent.MethodL(), - KZero, + 0, iOrginalEntry->StartTimeL(), CalCommon::EThisOnly ); - CleanupStack::Pop( guid ); + CleanupStack::Pop( guid ); guid = NULL; // ownership transferred } - CleanupStack::PopAndDestroy( instance ); + CleanupStack::PopAndDestroy( instance ); instance = NULL; // instance CleanupStack::PushL( entry ); @@ -1522,11 +1645,12 @@ CCalEntry::TMethod method( iEntry->MethodL() ); entry->CopyFromL( *iEntry, CCalEntry::EDontCopyId ); - entry->SetSequenceNumberL( KZero ); + entry->SetSequenceNumberL( 0 ); entry->SetMethodL( method ); entry->SetSummaryL( iEntry->SummaryL() ); entry->SetLocalUidL( TCalLocalUid( 0 ) ); entry->ClearRepeatingPropertiesL(); + iMRMailboxUtils.SetPhoneOwnerL( *entry ); CleanupStack::Pop( entry ); } @@ -1534,14 +1658,20 @@ if ( !entry ) { - - entry = ESMRHelper::CopyEntryL( - *iEntry, - iEntry->MethodL(), - ESMRHelper::ECopyFull ); - + entry = CopyEntryL( iMRMailboxUtils, *iEntry ); } + if ( iRemoveAttachments ) + { + // Remove attachments from the entry + TInt count( entry->AttachmentCountL() ); + + for ( TInt i = 0; i < count; ++i ) + { + CCalAttachment* attachment = entry->AttachmentL( i ); + entry->DeleteAttachmentL( *attachment ); + } + } return entry; } @@ -1635,7 +1765,7 @@ TPtrC calEntryAddress( thisAttendee->Address() ); TPtrC infoAddress( attendee->Address() ); - if ( KZero == infoAddress.Compare(calEntryAddress ) ) + if ( 0 == infoAddress.Compare(calEntryAddress ) ) { found = ETrue; @@ -1687,8 +1817,7 @@ aStartupParams.iCalEntry = iESMRInputParams->iCalEntry; aStartupParams.iMRInfoObject = iESMRInputParams->iMRInfoObject; aStartupParams.iMailMessage = iESMRInputParams->iMailMessage; - aStartupParams.iMailClient = iESMRInputParams->iMailClient; - aStartupParams.iAttachmentInfo = iESMRInputParams->iAttachmentInfo; + aStartupParams.iMailClient = iESMRInputParams->iMailClient; aStartupParams.iSpare = iESMRInputParams->iSpare; } return retValue; @@ -1779,94 +1908,6 @@ } // --------------------------------------------------------------------------- -// CESMRMeetingRequestEntry::SetDefaultValuesToEntryL -// --------------------------------------------------------------------------- -// -void CESMRMeetingRequestEntry::SetDefaultValuesToEntryL() - { - FUNC_LOG; - - if ( !IsStoredL() ) - { - SetPriorityL( EFSCalenMRPriorityNormal ); - - // Get default alarm time from central repository - TInt defaultAlarmTime=0; - CRepository* repository = CRepository::NewLC( KCRUidCalendar ); - - TInt err = KErrNotFound; - - if ( repository ) - { - err = repository->Get( - KCalendarDefaultAlarmTime, - defaultAlarmTime ); - CleanupStack::PopAndDestroy( repository ); - } - - if ( err != KErrNone ) - { - // By default 15 minutes if not found from central repository - defaultAlarmTime = KDefaultMeetingAlarmMinutes; - } - - // Getting current time - TTime currentTime; - currentTime.HomeTime(); - - // Getting meeting start time - TTime start = iEntry->StartTimeL().TimeLocalL(); - - // Create default alarm - CCalAlarm* alarm = CCalAlarm::NewL(); - CleanupStack::PushL( alarm ); - - TTimeIntervalMinutes alarmOffset( defaultAlarmTime ); - - // If alarm time is in past - if ( ( start - alarmOffset ) < currentTime ) - { - // Setting alarm off - iEntry->SetAlarmL( NULL ); - } - else - { - // Set default alarm time - alarm->SetTimeOffset( alarmOffset ); - iEntry->SetAlarmL( alarm ); - } - CleanupStack::PopAndDestroy( alarm ); - } - - // Set the default end time if not set by client - if ( iEntry->StartTimeL().TimeUtcL() == iEntry->EndTimeL().TimeUtcL() ) - { - // This value might also be read from cenrep - TTimeIntervalHours KDefaultMeetingDuration(1); - - TCalTime newEndTime; - newEndTime.SetTimeUtcL( - iEntry->StartTimeL().TimeUtcL() + KDefaultMeetingDuration ); - iEntry->SetStartAndEndTimeL(iEntry->StartTimeL(), newEndTime); - } - - iEntry->SetReplicationStatusL( CCalEntry::EOpen ); - - //Original entry must be stored after the default values are set. - //Otherwise it looks like settings are changed even though they haven't - - CCalEntry* temp = ESMRHelper::CopyEntryL( - *iEntry, - iEntry->MethodL(), - ESMRHelper::ECopyFull ); - - delete iOrginalEntry; - iOrginalEntry = temp; - - } - - -// --------------------------------------------------------------------------- // CESMRMeetingRequestEntry::IsOpenedFromMail // --------------------------------------------------------------------------- // @@ -2000,78 +2041,58 @@ } // --------------------------------------------------------------------------- -// CESMRMeetingRequestEntry::UpdateEntryAfterStoringL -// --------------------------------------------------------------------------- -// -void CESMRMeetingRequestEntry::UpdateEntryAfterStoringL() - { - FUNC_LOG; - - __ASSERT_DEBUG( iEntry, Panic(EESMREntryNotExist ) ); - - CCalEntry* temp = ESMRHelper::CopyEntryL( - *iEntry, - iEntry->MethodL(), - ESMRHelper::ECopyFull ); - - delete iOrginalEntry; - iOrginalEntry = temp; - - } - -// --------------------------------------------------------------------------- // CESMRMeetingRequestEntry::UpdateChildEntriesSeqNumbersL // --------------------------------------------------------------------------- // void CESMRMeetingRequestEntry::UpdateChildEntriesSeqNumbersL() - { + { FUNC_LOG; - if ( MESMRCalEntry::EESMRAllInSeries == iRecurrenceModRule && - IsStoredL() ) - { - RCPointerArray childEntries; - CleanupClosePushL( childEntries ); - - // Fetch all entries (this and child entries - iCalDb.NormalDbEntryView()->FetchL( - iEntry->UidL(), - childEntries ); - - // Next: Remove parent entry from the array - TBool removed( EFalse ); - TInt entryCount( childEntries.Count() ); - for ( TInt i(0); (i < entryCount) && !removed; ++i ) - { - CCalEntry* entry = childEntries[i]; - - if ( !ESMREntryHelper::IsModifyingEntryL( *entry) ) - { - removed = ETrue; - childEntries.Remove( i ); - delete entry; - } - entry = NULL; - } - - TInt childCount( childEntries.Count() ); - if ( childCount ) - { - for (TInt i(0); i < childCount; ++i ) - { - CCalEntry* child = childEntries[i]; - TInt childSeqNo( child->SequenceNumberL() ); - child->SetSequenceNumberL( childSeqNo + 1); - } - - TInt updatedChilds; - iCalDb.NormalDbEntryView()->StoreL(childEntries, updatedChilds); - } - - CleanupStack::PopAndDestroy(); // childEntries - } - - } + if ( MESMRCalEntry::EESMRAllInSeries == iRecurrenceModRule && + IsStoredL() ) + { + RCPointerArray childEntries; + CleanupClosePushL( childEntries ); + + // Fetch all entries (this and child entries + iCalDb.EntryView()->FetchL( + iEntry->UidL(), + childEntries ); + + // Next: Remove parent entry from the array + TBool removed( EFalse ); + TInt entryCount( childEntries.Count() ); + for ( TInt i(0); (i < entryCount) && !removed; ++i ) + { + CCalEntry* entry = childEntries[i]; + + if ( !ESMREntryHelper::IsModifyingEntryL( *entry) ) + { + removed = ETrue; + childEntries.Remove( i ); + delete entry; + } + entry = NULL; + } + + TInt childCount( childEntries.Count() ); + if ( childCount ) + { + for (TInt i(0); i < childCount; ++i ) + { + CCalEntry* child = childEntries[i]; + TInt childSeqNo( child->SequenceNumberL() ); + child->SetSequenceNumberL( childSeqNo + 1); + } + + TInt updatedChilds; + iCalDb.EntryView()->StoreL(childEntries, updatedChilds); + } + + CleanupStack::PopAndDestroy(); // childEntries + } + + } // --------------------------------------------------------------------------- // CESMRMeetingRequestEntry::CurrentPluginL @@ -2083,35 +2104,19 @@ if ( EESMRUnknownPlugin == iCurrentFSEmailPlugin) { - CESMRFsMailboxUtils* fsMbUtils = + CESMRFsMailboxUtils* fsMbUtils = CESMRFsMailboxUtils::NewL( iMRMailboxUtils ); CleanupStack::PushL( fsMbUtils ); - + iCurrentFSEmailPlugin = fsMbUtils->FSEmailPluginForEntryL( *iEntry ); CleanupStack::PopAndDestroy( fsMbUtils ); - fsMbUtils = NULL; + fsMbUtils = NULL; } - return iCurrentFSEmailPlugin; } // --------------------------------------------------------------------------- -// CESMRMeetingRequestEntry::CurrentMailBoxIdL -// --------------------------------------------------------------------------- -// -TFSMailMsgId CESMRMeetingRequestEntry::CurrentMailBoxIdL() - { - FUNC_LOG; - CESMRFsMailboxUtils* fsMbUtils = - CESMRFsMailboxUtils::NewL( iMRMailboxUtils ); - CleanupStack::PushL( fsMbUtils ); - TFSMailMsgId retVal = fsMbUtils->FSEmailMailBoxForEntryL( *iEntry ); - CleanupStack::PopAndDestroy( fsMbUtils ); - return retVal; - } - -// --------------------------------------------------------------------------- // CESMRMeetingRequestEntry::UpdateTimeStampL // --------------------------------------------------------------------------- // @@ -2119,49 +2124,204 @@ { FUNC_LOG; __ASSERT_DEBUG( iEntry, Panic(EESMREntryNotExist ) ); - + TTime currentUTCTime; currentUTCTime.UniversalTime(); TCalTime currentTime; currentTime.SetTimeUtcL( currentUTCTime ); - iEntry->SetDTStampL( currentTime ); + iEntry->SetDTStampL( currentTime ); } // --------------------------------------------------------------------------- -// CESMRMeetingRequestEntry::UpdateTimeStampL +// CESMRMeetingRequestEntry::AnyInstancesBetweenTimePeriodL // --------------------------------------------------------------------------- // -TBool CESMRMeetingRequestEntry::AnyInstanceOnDayL( +TBool CESMRMeetingRequestEntry::AnyInstancesBetweenTimePeriodL( + TTime& aStart, + TTime& aEnd ) + { + FUNC_LOG; + + __ASSERT_DEBUG( iEntry, Panic(EESMREntryNotExist ) ); + __ASSERT_DEBUG( iOrginalEntry, Panic(EESMREntryNotExist ) ); + + TBool retValue( EFalse ); + + RCPointerArray entries; + CleanupClosePushL( entries ); + + CESMRConflictChecker* conflictCheckker = + CESMRConflictChecker::NewL( iCalDb ); + CleanupStack::PushL( conflictCheckker ); + + CCalInstance* instance = InstanceL(); + CleanupStack::PushL( instance ); + + TCalCollectionId colId = instance->InstanceIdL().iCollectionId; + CleanupStack::PopAndDestroy( instance ); + + conflictCheckker->FindInstancesForEntryL( aStart, + aEnd, + *iEntry, + colId, + entries ); + + if ( entries.Count() ) + { + retValue = ETrue; + } + + CleanupStack::PopAndDestroy( conflictCheckker ); + CleanupStack::PopAndDestroy(); // entries + + return retValue; + } + +// --------------------------------------------------------------------------- +// CESMRMeetingRequestEntry::GetFirstInstanceStartAndEndTimeL +// --------------------------------------------------------------------------- +// +void CESMRMeetingRequestEntry::GetFirstInstanceStartAndEndTimeL( TTime& aStart, TTime& aEnd ) { FUNC_LOG; + + __ASSERT_DEBUG( iEntry, Panic(EESMREntryNotExist ) ); + + // This fetches the parent entry + TCalTime recurrenceId; + recurrenceId.SetTimeLocalL( Time::NullTTime() ); + CCalEntry* parent = iCalDb.FetchEntryL( + iEntry->UidL(), + recurrenceId ); + + CleanupStack::PushL( parent ); + + aStart = parent->StartTimeL().TimeLocalL(); + aEnd = parent->EndTimeL().TimeLocalL(); + + CleanupStack::PopAndDestroy( parent ); + } + +// --------------------------------------------------------------------------- +// CESMRMeetingRequestEntry::CalendarOwnerAddressL +// --------------------------------------------------------------------------- +// +const TDesC& CESMRMeetingRequestEntry::CalendarOwnerAddressL() const + { + FUNC_LOG; + + __ASSERT_DEBUG( iEntry, Panic( EESMREntryNotExist ) ); + + CCalUser* po = iEntry->PhoneOwnerL(); + + __ASSERT_DEBUG( po, Panic( EESMRPhoneOwnerNotSet ) ); + + return po->Address(); + } + +// --------------------------------------------------------------------------- +// CESMRMeetingRequestEntry::MailboxUtils +// --------------------------------------------------------------------------- +// +CMRMailboxUtils& CESMRMeetingRequestEntry::MailboxUtils() const + { + return iMRMailboxUtils; + } + +// --------------------------------------------------------------------------- +// CESMRMeetingRequestEntry::GetDBMgr +// --------------------------------------------------------------------------- +// +MESMRCalDbMgr& CESMRMeetingRequestEntry::GetDBMgr() + { + return iCalDb; + } + +// --------------------------------------------------------------------------- +// CESMRMeetingRequestEntry::SupportsCapabilityL +// --------------------------------------------------------------------------- +// +TBool CESMRMeetingRequestEntry::SupportsCapabilityL( + MESMRCalEntry::TMREntryCapability aCapability ) const + { TBool retValue( EFalse ); - RCPointerArray entries; - CleanupClosePushL( entries ); - - CESMRConflictChecker* conflictCheckker = - CESMRConflictChecker::NewL( iCalDb ); - CleanupStack::PushL( conflictCheckker ); - - conflictCheckker->FindInstancesForEntryL( aStart, - aEnd, - *iEntry, - entries ); - - if ( entries.Count() ) + switch( aCapability ) { - retValue = ETrue; - } - - CleanupStack::PopAndDestroy( conflictCheckker ); - CleanupStack::PopAndDestroy(); // entries + case MESMRCalEntry::EMRCapabilityAttachments: + { + CESMRFsMailboxUtils* fsMbUtils = + CESMRFsMailboxUtils::NewL( iMRMailboxUtils ); + CleanupStack::PushL( fsMbUtils ); + + retValue = fsMbUtils->DefaultMailboxSupportCapabilityL( + CESMRFsMailboxUtils::EMRCapabilityAttachment ); + CleanupStack::PopAndDestroy( fsMbUtils ); + } + break; + } return retValue; } +// --------------------------------------------------------------------------- +// CESMRMeetingRequestEntry::ContainsRemoteAttachmentsL +// --------------------------------------------------------------------------- +// +TBool CESMRMeetingRequestEntry::ContainsRemoteAttachmentsL() + { + FUNC_LOG; + + TBool retValue( EFalse ); + + TInt attachmentCount( iEntry->AttachmentCountL() ); + + for ( TInt i(0); i < attachmentCount && !retValue; ++i ) + { + CCalAttachment* attachment = iEntry->AttachmentL(i); + CCalAttachment::TType type( attachment->Type() ); + + if ( CCalAttachment::EFile != type ) + { + retValue = ETrue; + } + } + + return retValue; + } + +// --------------------------------------------------------------------------- +// CESMRMeetingRequestEntry::SendCanellationAvailable +// --------------------------------------------------------------------------- +// +TBool CESMRMeetingRequestEntry::SendCanellationAvailable () + { + return iSendCanellation; + } + +// --------------------------------------------------------------------------- +// CESMRMeetingRequestEntry::SetSendCanellationAvailable +// --------------------------------------------------------------------------- +// +void CESMRMeetingRequestEntry::SetSendCanellationAvailable ( + TBool aSendCanellation ) + { + iSendCanellation = aSendCanellation; + } + +// --------------------------------------------------------------------------- +// CESMRMeetingRequestEntry::SetTypeChanged +// --------------------------------------------------------------------------- +// +void CESMRMeetingRequestEntry::SetTypeChanged( TBool aTypeChanged ) + { + FUNC_LOG; + + iTypeChanged = aTypeChanged; + } + // EOF -