meetingrequest/mrentry/src/cesmrmeetingrequestentry.cpp
branchRCL_3
changeset 12 4ce476e64c59
parent 1 12c456ceeff2
child 14 b13141f05c3d
equal deleted inserted replaced
11:0396474f30f5 12:4ce476e64c59
     1 /*
     1 /*
     2 * Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies). 
     2 * Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
     3 * All rights reserved.
     3 * All rights reserved.
     4 * This component and the accompanying materials are made available
     4 * This component and the accompanying materials are made available
     5 * under the terms of "Eclipse Public License v1.0"
     5 * under the terms of "Eclipse Public License v1.0"
     6 * which accompanies this distribution, and is available
     6 * which accompanies this distribution, and is available
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
    15 *
    15 *
    16 */
    16 */
    17 
    17 
    18 
    18 
    19 // INCLUDE FILES
    19 // INCLUDE FILES
    20 //<cmail>
       
    21 #include "emailtrace.h"
       
    22 #include "cesmralarminfohandler.h"
       
    23 #include "cesmrrecurrenceinfohandler.h"
       
    24 //</cmail>
       
    25 #include <centralrepository.h>
       
    26 #include <calalarm.h>
       
    27 
       
    28 #include "cesmrmeetingrequestentry.h"
    20 #include "cesmrmeetingrequestentry.h"
    29 #include "cesmrfsmailboxutils.h"
    21 #include "cesmrfsmailboxutils.h"
    30 #include "cesmrcaldbmgr.h"
    22 #include "cesmrcaldbmgr.h"
    31 #include "esmrhelper.h"
    23 #include "esmrhelper.h"
    32 #include "esmrentryhelper.h"
    24 #include "esmrentryhelper.h"
    33 #include "cesmrconflictchecker.h"
    25 #include "cesmrconflictchecker.h"
    34 #include "cesmrcaluserutil.h"
    26 #include "cesmrcaluserutil.h"
       
    27 #include "cesmralarminfohandler.h"
       
    28 #include "cesmrrecurrenceinfohandler.h"
       
    29 #include "mmrinfoobject.h"
       
    30 #include "mmrattendee.h"
       
    31 
       
    32 #include "CFSMailMessage.h"
       
    33 
    35 #include "esmrconfig.hrh"
    34 #include "esmrconfig.hrh"
       
    35 #include "cesmrfeaturesettings.h"
       
    36 
       
    37 #include "emailtrace.h"
    36 
    38 
    37 #include <esmralarminfo.rsg>
    39 #include <esmralarminfo.rsg>
    38 #include <calentry.h>
    40 #include <calentry.h>
    39 #include <calinstance.h>
    41 #include <calinstance.h>
    40 #include <calinstanceview.h>
    42 #include <calinstanceview.h>
    41 #include <caluser.h>
    43 #include <caluser.h>
    42 #include <CalenInterimUtils2.h>
    44 #include <calattachment.h>
       
    45 #include <caleninterimutils2.h>
    43 #include <cmrmailboxutils.h>
    46 #include <cmrmailboxutils.h>
    44 #include <calrrule.h>
    47 #include <calrrule.h>
    45 //<cmail>
    48 #include <centralrepository.h>
    46 #include "mmrinfoobject.h"
    49 #include <calalarm.h>
    47 #include "mmrattendee.h"
    50 #include <calendarinternalcrkeys.h>
    48 //</cmail>
       
    49 #include <CalendarInternalCRKeys.h>
       
    50 #include <data_caging_path_literals.hrh>
    51 #include <data_caging_path_literals.hrh>
    51 #include <coemain.h>
    52 #include <coemain.h>
    52 #include <calentryview.h>
    53 #include <calentryview.h>
    53 #include <ct/rcpointerarray.h>
    54 #include <ct/rcpointerarray.h>
       
    55 #include <apmstd.h>
       
    56 #include <apgcli.h>
       
    57 #include <apmrec.h>
    54 
    58 
    55 /// Unnamed namespace for local definitions
    59 /// Unnamed namespace for local definitions
    56 namespace {
    60 namespace {
    57 
    61 
    58 // Alarm resource file location
    62 // Alarm resource file location
    59 _LIT( KAlarmInfoResource, "esmralarminfo.rsc" );
    63 _LIT( KAlarmInfoResource, "esmralarminfo.rsc" );
    60 
    64 
    61 // Definition for first index
       
    62 const TInt KFirstIndex = 0;
       
    63 
       
    64 // Definition for 0
       
    65 const TInt KZero = 0;
       
    66 
       
    67 // Definition for 1
       
    68 const TInt KOne = 1;
       
    69 
       
    70 // Definition for number of hours within day
       
    71 const TInt KHoursInDay = 24;
       
    72 
       
    73 // Definition for default alarm time for meeting
    65 // Definition for default alarm time for meeting
    74 const TInt KDefaultMeetingAlarmMinutes( 15 );
    66 const TInt KDefaultMeetingAlarmMinutes( 15 );
    75 
    67 
    76 _LIT( KReplaceLineFeedChar, "\n" );
    68 _LIT( KReplaceLineFeedChar, "\n" );
    77 _LIT( KLineFeed, "\x2029");
    69 _LIT( KLineFeed, "\x2029");
    78 
    70 
    79 /**
    71 /**
    80  * Finds matching calendar instance from calendar db. Ownership is
    72  * Sets phone owner to entry.
    81  * transferred, If instance cannot be found, NULL is returned.
    73  * @param aMbUtils Reference to mailbox utils.
    82  *
    74  * @param aEntry Reference to calendar entry.
    83  * @param aCalDb Reference to cal db manager.
       
    84  * @param aEntry Reference to calendar entry
       
    85  * @return Pointer to calendar entry instance.
       
    86  */
    75  */
    87 CCalInstance* FindInstanceL(
    76 void SetPhoneOwnerL(
    88         MESMRCalDbMgr& aCalDb,
    77         CMRMailboxUtils& aMbUtils,
    89         CCalEntry& aEntry )
    78         CCalEntry& aEntry )
    90     {
    79     {
    91     CCalInstance* instance = NULL;
    80     CESMRFsMailboxUtils* fsMbUtils =
    92     RCPointerArray<CCalInstance> calInstances;
    81             CESMRFsMailboxUtils::NewL( aMbUtils );
    93     CleanupClosePushL( calInstances );
    82     CleanupStack::PushL( fsMbUtils );
    94 
    83 
    95     CCalInstanceView* instanceView =
    84     fsMbUtils->SetPhoneOwnerL( aEntry );
    96             aCalDb.NormalDbInstanceView();
    85     CleanupStack::PopAndDestroy( fsMbUtils );
    97 
    86     fsMbUtils = NULL;
    98     CalCommon::TCalViewFilter instanceFilter =
    87     }
    99             CalCommon::EIncludeAppts |
    88 
   100             CalCommon::EIncludeEvents;
    89 /**
   101 
    90  * Makes copy of the entry and sets phone owner accordingly
   102     // Removing one seconds from start time and adding one second to stop
    91  * @param aMbUtils Reference to mailbox utils.
   103     // time. Otherwise wanted entry is not included into results.
    92  * @param aEntry Reference to calendar entry.
   104     TCalTime startTime;
    93  */
   105     startTime.SetTimeLocalL(
    94 CCalEntry* CopyEntryL(
   106         aEntry.StartTimeL().TimeLocalL() - TTimeIntervalSeconds(KOne) );
    95         CMRMailboxUtils& aMbUtils,
   107     TCalTime endTime;
    96         const CCalEntry& aEntry )
   108     endTime.SetTimeLocalL(
    97     {
   109         aEntry.EndTimeL().TimeLocalL() + TTimeIntervalSeconds(KOne) );
    98     CCalEntry* entry = ESMRHelper::CopyEntryL(
   110 
    99                             aEntry,
   111     TDateTime start = startTime.TimeLocalL().DateTime();
   100                             aEntry.MethodL(),
   112     TDateTime end   = endTime.TimeLocalL().DateTime();
   101                             ESMRHelper::ECopyFull,
   113 
   102                             EESMREventTypeMeetingRequest );
   114     CalCommon::TCalTimeRange timeRange(
   103 
   115             startTime,
   104     SetPhoneOwnerL( aMbUtils, *entry );
   116             endTime );
   105 
   117 
   106     return entry;
   118     instanceView->FindInstanceL(
       
   119             calInstances,
       
   120             instanceFilter,
       
   121             timeRange);
       
   122 
       
   123     TInt instanceCount( calInstances.Count() );
       
   124     for (TInt i = 0; (i < instanceCount && !instance); ++i)
       
   125         {
       
   126         CCalEntry& entry = calInstances[i]->Entry();
       
   127 
       
   128         // Finding the entry we are intrested for
       
   129         if ( !entry.UidL().Compare( aEntry.UidL() ) )
       
   130             {
       
   131             instance = calInstances[i];
       
   132             calInstances.Remove( i );
       
   133             }
       
   134         }
       
   135     CleanupStack::PopAndDestroy(); // arrayCleanup
       
   136     return instance;
       
   137     }
   107     }
   138 
   108 
   139 #ifdef _DEBUG
   109 #ifdef _DEBUG
   140 
   110 
   141 // Definition for panic text
   111 // Definition for panic text
   181         TBool aConflictsExists,
   151         TBool aConflictsExists,
   182         TESMRInputParams* aESMRInputParams )
   152         TESMRInputParams* aESMRInputParams )
   183 :   iMRMailboxUtils( aMRMailboxUtils ),
   153 :   iMRMailboxUtils( aMRMailboxUtils ),
   184     iConflictsExists( aConflictsExists),
   154     iConflictsExists( aConflictsExists),
   185     iCalDb( aCalDb ),
   155     iCalDb( aCalDb ),
   186     iESMRInputParams( aESMRInputParams )
   156     iESMRInputParams( aESMRInputParams ),
       
   157     iSendCanellation( ETrue )
   187     {
   158     {
   188     FUNC_LOG;
   159     FUNC_LOG;
   189     // Not yet implementation
   160     // Not yet implementation
   190     }
   161     }
   191 
   162 
   192 // ---------------------------------------------------------------------------
   163 // ---------------------------------------------------------------------------
   193 // CESMRMeetingRequestEntry::~CESMRMeetingRequestEntry
   164 // CESMRMeetingRequestEntry::~CESMRMeetingRequestEntry
   194 // ---------------------------------------------------------------------------
   165 // ---------------------------------------------------------------------------
   195 //
   166 //
   196 CESMRMeetingRequestEntry::~CESMRMeetingRequestEntry()
   167 EXPORT_C CESMRMeetingRequestEntry::~CESMRMeetingRequestEntry()
   197     {
   168     {
   198     FUNC_LOG;
   169     FUNC_LOG;
   199     delete iEntry;
   170     delete iEntry;
   200     delete iForwardEntry;
   171     delete iForwardEntry;
   201     delete iOrginalEntry;
   172     delete iOrginalEntry;
   202     delete iParameterEntry;
   173     delete iParameterEntry;
   203     delete iBackupEntry;
       
   204     }
   174     }
   205 
   175 
   206 // ---------------------------------------------------------------------------
   176 // ---------------------------------------------------------------------------
   207 // CESMRMeetingRequestEntry::NewL
   177 // CESMRMeetingRequestEntry::NewL
   208 // ---------------------------------------------------------------------------
   178 // ---------------------------------------------------------------------------
   209 //
   179 //
   210 CESMRMeetingRequestEntry* CESMRMeetingRequestEntry::NewL(
   180 EXPORT_C CESMRMeetingRequestEntry* CESMRMeetingRequestEntry::NewL(
   211         const CCalEntry& aEntry,
   181         const CCalEntry& aEntry,
   212         CMRMailboxUtils& aMRMailboxUtils,
   182         CMRMailboxUtils& aMRMailboxUtils,
   213         MESMRCalDbMgr& aCalDb,
   183         MESMRCalDbMgr& aCalDb,
   214         TBool aConflictsExists,
   184         TBool aConflictsExists,
   215         TESMRInputParams* aESMRInputParams )
   185         TESMRInputParams* aESMRInputParams )
   236 //
   206 //
   237 void CESMRMeetingRequestEntry::ConstructL(
   207 void CESMRMeetingRequestEntry::ConstructL(
   238         const CCalEntry& aEntry )
   208         const CCalEntry& aEntry )
   239     {
   209     {
   240     FUNC_LOG;
   210     FUNC_LOG;
   241     
   211 
   242     iParameterEntry = ESMRHelper::CopyEntryL(
   212     iParameterEntry = CopyEntryL( iMRMailboxUtils, aEntry );
   243         aEntry,
   213     iEntry = CopyEntryL( iMRMailboxUtils, aEntry );
   244         aEntry.MethodL(),
   214 
   245         ESMRHelper::ECopyFull );    
   215     iOrginalEntry  = CopyEntryL( iMRMailboxUtils, aEntry );
   246     iBackupEntry=ESMRHelper::CopyEntryL(
   216 
   247             aEntry,
       
   248             aEntry.MethodL(),
       
   249             ESMRHelper::ECopyFull ); 
       
   250     iEntry = ESMRHelper::CopyEntryL(
       
   251         aEntry,
       
   252         aEntry.MethodL(),
       
   253         ESMRHelper::ECopyFull );
       
   254 
       
   255     if ( !IsStoredL() && !IsOpenedFromMail() )
       
   256         {
       
   257         // by default when creating a meeting the priority value is normal
       
   258         SetPriorityL( EFSCalenMRPriorityNormal );
       
   259         }
       
   260 
       
   261     iOrginalEntry  = ESMRHelper::CopyEntryL(
       
   262         aEntry,
       
   263         aEntry.MethodL(),
       
   264         ESMRHelper::ECopyFull );
       
   265     
       
   266     if ( EESMRRoleOrganizer == RoleL() && IsStoredL() )
   217     if ( EESMRRoleOrganizer == RoleL() && IsStoredL() )
   267         {
   218         {
   268         // Increase sequence number
   219         // Increase sequence number
   269         TInt seqNo( iEntry->SequenceNumberL() + 1);
   220         TInt seqNo( iEntry->SequenceNumberL() + 1);
   270         iEntry->SetSequenceNumberL( seqNo );
   221         iEntry->SetSequenceNumberL( seqNo );
   279         iEntry->SetMethodL( CCalEntry::EMethodRequest );
   230         iEntry->SetMethodL( CCalEntry::EMethodRequest );
   280         iOrginalEntry->SetMethodL( CCalEntry::EMethodRequest );
   231         iOrginalEntry->SetMethodL( CCalEntry::EMethodRequest );
   281         }
   232         }
   282 
   233 
   283     HBufC* newDescription = ReplaceCharactersFromBufferLC(
   234     HBufC* newDescription = ReplaceCharactersFromBufferLC(
   284                                     iEntry->DescriptionL(),       
   235                                     iEntry->DescriptionL(),
   285                                     KReplaceLineFeedChar(),
   236                                     KReplaceLineFeedChar(),
   286                                     KLineFeed() );
   237                                     KLineFeed() );
   287     iEntry->SetDescriptionL( *newDescription );
   238     iEntry->SetDescriptionL( *newDescription );
       
   239     iOrginalEntry->SetDescriptionL( *newDescription );
       
   240 
   288     CleanupStack::PopAndDestroy( newDescription );
   241     CleanupStack::PopAndDestroy( newDescription );
   289         
   242 
       
   243     __ASSERT_DEBUG( iEntry->PhoneOwnerL(), Panic( EESMRPhoneOwnerNotSet) );
       
   244     
       
   245     CESMRFeatureSettings* settings = CESMRFeatureSettings::NewL();
       
   246     if ( settings->FeatureSupported(
       
   247             CESMRFeatureSettings::EMRUIMeetingRequestViewerCmailOnly ) )
       
   248         {
       
   249         // Meeting request viewer available only from email.
       
   250         // Remove attachments from entry.  
       
   251         iRemoveAttachments = ETrue;
       
   252         }
       
   253     delete settings;
   290     }
   254     }
   291 
   255 
   292 // ---------------------------------------------------------------------------
   256 // ---------------------------------------------------------------------------
   293 // CESMRMeetingRequestEntry::ReplaceCharactersFromBufferL
   257 // CESMRMeetingRequestEntry::ReplaceCharactersFromBufferL
   294 // ---------------------------------------------------------------------------
   258 // ---------------------------------------------------------------------------
   295 //
   259 //
   296 HBufC* CESMRMeetingRequestEntry::ReplaceCharactersFromBufferLC( const TDesC& aTarget, 
   260 HBufC* CESMRMeetingRequestEntry::ReplaceCharactersFromBufferLC( const TDesC& aTarget,
   297                               const TDesC& aFindString, 
   261                               const TDesC& aFindString,
   298                               const TDesC& aReplacement )
   262                               const TDesC& aReplacement )
   299     {
   263     {
   300     FUNC_LOG;
   264     FUNC_LOG;
   301     HBufC* newBuffer = aTarget.AllocLC();
   265     HBufC* newBuffer = aTarget.AllocLC();
   302     TPtr16 ptr = newBuffer->Des();
   266     TPtr16 ptr = newBuffer->Des();
   303     
   267 
   304     // find next occurance:
   268     // find next occurance:
   305     TInt offset = ptr.Find(aFindString);
   269     TInt offset = ptr.Find(aFindString);
   306     while ( offset != KErrNotFound )
   270     while ( offset != KErrNotFound )
   307         {
   271         {
   308         // replace the data:
   272         // replace the data:
   309         ptr.Replace( offset, aFindString.Length(), aReplacement);
   273         ptr.Replace( offset, aFindString.Length(), aReplacement);
   310         
   274 
   311         // find next occurance:
   275         // find next occurance:
   312         offset = ptr.Find(aFindString);
   276         offset = ptr.Find(aFindString);
   313         }
   277         }
   314     
   278 
   315     return newBuffer;
   279     return newBuffer;
   316     }         
   280     }
   317 
   281 
   318 // ---------------------------------------------------------------------------
   282 // ---------------------------------------------------------------------------
   319 // CESMRMeetingRequestEntry::Type
   283 // CESMRMeetingRequestEntry::Type
   320 // ---------------------------------------------------------------------------
   284 // ---------------------------------------------------------------------------
   321 //
   285 //
   388     __ASSERT_DEBUG( iEntry, Panic(EESMREntryNotExist ) );
   352     __ASSERT_DEBUG( iEntry, Panic(EESMREntryNotExist ) );
   389     __ASSERT_DEBUG( iOrginalEntry, Panic(EESMREntryNotExist ) );
   353     __ASSERT_DEBUG( iOrginalEntry, Panic(EESMREntryNotExist ) );
   390 
   354 
   391     CCalInstance* instance = NULL;
   355     CCalInstance* instance = NULL;
   392 
   356 
   393     instance = FindInstanceL( iCalDb, *iEntry );
   357     instance = iCalDb.FindInstanceL( *iEntry );
   394     if ( !instance )
   358     if ( !instance )
   395         {
   359         {
   396         // Instance not found by using the edited entry
   360         // Instance not found by using the edited entry
   397         // Trying with orginal.
   361         // Trying with orginal.
   398         instance = FindInstanceL( iCalDb, *iOrginalEntry );
   362         instance = iCalDb.FindInstanceL( *iOrginalEntry );
   399         }
   363         }
   400 
   364 
   401     if ( !instance )
   365     if ( !instance )
   402         {
   366         {
   403         // Instance not found by using edited or orginal entry.
   367         // Instance not found by using edited or orginal entry.
   404         // --> Leave
   368         // --> Leave
   405 
       
   406 
       
   407         User::Leave( KErrNotFound );
   369         User::Leave( KErrNotFound );
   408         }
   370         }
   409 
   371 
   410 
       
   411     return instance;
   372     return instance;
   412     }
   373     }
   413 
   374 
   414 // ---------------------------------------------------------------------------
   375 // ---------------------------------------------------------------------------
   415 // CESMRMeetingRequestEntry::CanSetRecurrenceL
   376 // CESMRMeetingRequestEntry::CanSetRecurrenceL
   420     FUNC_LOG;
   381     FUNC_LOG;
   421 
   382 
   422     __ASSERT_DEBUG( iEntry, Panic(EESMREntryNotExist ) );
   383     __ASSERT_DEBUG( iEntry, Panic(EESMREntryNotExist ) );
   423 
   384 
   424     TBool canSetRecurrence( ETrue );
   385     TBool canSetRecurrence( ETrue );
   425 
   386     
   426     if ( iEntry->EntryTypeL() == CCalEntry::EAppt &&
   387     if ( iEntry->EntryTypeL() == CCalEntry::EAppt &&
   427             ESMREntryHelper::IsRepeatingMeetingL(*iEntry) &&
   388             ESMREntryHelper::IsRepeatingMeetingL(*iEntry) &&
   428         (!ESMREntryHelper::IsModifyingEntryL(*iEntry) &&
   389         (!ESMREntryHelper::IsModifyingEntryL(*iEntry) &&
   429           MESMRCalEntry::EESMRThisOnly == iRecurrenceModRule ))
   390           MESMRCalEntry::EESMRThisOnly == iRecurrenceModRule ))
   430         {
   391         {
   452         // Lets look recurrence using instance
   413         // Lets look recurrence using instance
   453 
   414 
   454         // Ownership is transferred
   415         // Ownership is transferred
   455         CCalInstance* instance = NULL;
   416         CCalInstance* instance = NULL;
   456         TRAPD(err, instance = InstanceL() );
   417         TRAPD(err, instance = InstanceL() );
   457         if ( KErrNotFound != err&&err!=KErrNone )
   418         if ( KErrNotFound != err )
   458             {
   419             {
   459             User::LeaveIfError( err );
   420             User::LeaveIfError( err );
   460             }
   421             }
   461 
   422 
   462         if ( instance )
   423         if ( instance )
   538     FUNC_LOG;
   499     FUNC_LOG;
   539 
   500 
   540     __ASSERT_DEBUG( iEntry, Panic(EESMREntryNotExist ) );
   501     __ASSERT_DEBUG( iEntry, Panic(EESMREntryNotExist ) );
   541 
   502 
   542     CESMRRecurrenceInfoHandler* recurrenceHandler =
   503     CESMRRecurrenceInfoHandler* recurrenceHandler =
   543             CESMRRecurrenceInfoHandler::NewLC( *iEntry );
   504             CESMRRecurrenceInfoHandler::NewLC( *iEntry, &iCalDb );
   544 
   505 
   545     recurrenceHandler->GetRecurrenceL( aRecurrence, aUntil );
   506     recurrenceHandler->GetRecurrenceL( aRecurrence, aUntil );
   546     CleanupStack::PopAndDestroy( recurrenceHandler );
   507     CleanupStack::PopAndDestroy( recurrenceHandler );
   547 
       
   548     }
   508     }
   549 
   509 
   550 // ---------------------------------------------------------------------------
   510 // ---------------------------------------------------------------------------
   551 // CESMRMeetingRequestEntry::RecurrenceModRule
   511 // CESMRMeetingRequestEntry::RecurrenceModRule
   552 // ---------------------------------------------------------------------------
   512 // ---------------------------------------------------------------------------
   560 // ---------------------------------------------------------------------------
   520 // ---------------------------------------------------------------------------
   561 // CESMRMeetingRequestEntry::SetModifyingRuleL
   521 // CESMRMeetingRequestEntry::SetModifyingRuleL
   562 // ---------------------------------------------------------------------------
   522 // ---------------------------------------------------------------------------
   563 //
   523 //
   564 void CESMRMeetingRequestEntry::SetModifyingRuleL(
   524 void CESMRMeetingRequestEntry::SetModifyingRuleL(
   565         TESMRRecurrenceModifyingRule aRule )
   525         TESMRRecurrenceModifyingRule aRule, const TBool aTypeChanging )
   566     {
   526     {
   567     FUNC_LOG;
   527     FUNC_LOG;
   568 
   528 
   569     __ASSERT_DEBUG( iEntry, Panic(EESMREntryNotExist ) );
   529     __ASSERT_DEBUG( iEntry, Panic(EESMREntryNotExist ) );
   570 
   530 
   576     TTime orginalUntil;
   536     TTime orginalUntil;
   577 
   537 
   578     recHandler->GetRecurrenceL(
   538     recHandler->GetRecurrenceL(
   579             orginalRecurrence,
   539             orginalRecurrence,
   580             orginalUntil);
   540             orginalUntil);
   581 
       
   582     CleanupStack::PopAndDestroy( recHandler );
   541     CleanupStack::PopAndDestroy( recHandler );
   583     recHandler = NULL;
   542     recHandler = NULL;
   584 
   543 
       
   544     TBool modifyingEntry( ESMREntryHelper::IsModifyingEntryL( *iEntry ) );
   585 
   545 
   586     if ( MESMRCalEntry::EESMRAllInSeries == aRule &&
   546     if ( MESMRCalEntry::EESMRAllInSeries == aRule &&
   587          IsStoredL() && !IsForwardedL() && !IsOpenedFromMail() )
   547          IsStoredL() && !IsForwardedL() && !IsOpenedFromMail() && !aTypeChanging )
   588         {
   548         {
   589         // When we want to modify series of recurrence entries -->
   549         // When we want to modify series of recurrence entries -->
   590         // Parent entry is modified
   550         // Parent entry is modified
   591 
       
   592         TBool modifyingEntry( ESMREntryHelper::IsModifyingEntryL( *iEntry ) );        
       
   593         if ( ERecurrenceNot == orginalRecurrence && !modifyingEntry )
   551         if ( ERecurrenceNot == orginalRecurrence && !modifyingEntry )
   594             {
   552             {
   595             // Orginal entry was not recurrent event
   553             // Orginal entry was not recurrent event
   596             // No need to fect instance at all
   554             // No need to fect instance at all
   597             // For modifying entries we need to fetch the original parent entry
   555             // For modifying entries we need to fetch the original parent entry
   609         if ( instance )
   567         if ( instance )
   610             {
   568             {
   611             CleanupStack::PushL( instance );
   569             CleanupStack::PushL( instance );
   612 
   570 
   613             CCalEntry::TMethod entryMethod( iEntry->MethodL() );
   571             CCalEntry::TMethod entryMethod( iEntry->MethodL() );
   614             CCalEntry* iBackupEntry=ESMRHelper::CopyEntryL(
   572 
   615                     *iEntry,
   573             delete iEntry;
   616                     entryMethod,
       
   617                     ESMRHelper::ECopyFull);
       
   618             delete iEntry; 
       
   619             iEntry = NULL;
   574             iEntry = NULL;
   620             
   575 
   621             delete iForwardEntry; 
   576             delete iForwardEntry;
   622             iForwardEntry = NULL;
   577             iForwardEntry = NULL;
   623             
   578 
   624             delete iOrginalEntry; 
   579             delete iOrginalEntry;
   625             iOrginalEntry = NULL;
   580             iOrginalEntry = NULL;
   626 
   581 
   627             RCPointerArray<CCalEntry> entries;
   582             RCPointerArray<CCalEntry> entries;
   628             CleanupClosePushL( entries );
   583             CleanupClosePushL( entries );
   629 
   584 
   630             iCalDb.NormalDbEntryView()->FetchL(
   585             iCalDb.EntryViewL( instance->Entry() )->FetchL(
   631                     instance->Entry().UidL(), entries );
   586                     instance->Entry().UidL(), entries );
   632 
   587 
   633             TInt parentIndex( KErrNotFound );
   588             TInt parentIndex( KErrNotFound );
   634             TInt entryCount( entries.Count() );            
   589             TInt entryCount( entries.Count() );
   635             for ( TInt i(0); i < entryCount && KErrNotFound == parentIndex; ++i )
   590             for ( TInt i(0); i < entryCount && KErrNotFound == parentIndex; ++i )
   636                 {
   591                 {
   637                 TBool modifyingEntry( ESMREntryHelper::IsModifyingEntryL( *entries[i]) );
   592                 TBool modifyingEntry( ESMREntryHelper::IsModifyingEntryL( *entries[i]) );
   638                 if ( !modifyingEntry )
   593                 if ( !modifyingEntry )
   639                     {
   594                     {
   640                     parentIndex = i;
   595                     parentIndex = i;
   641                     }
   596                     }
   642                 }
   597                 }
   643 
   598 
   644             __ASSERT_DEBUG( KErrNotFound != parentIndex, Panic(EESMRParentNotFound) );
   599             __ASSERT_DEBUG( KErrNotFound != parentIndex, Panic(EESMRParentNotFound) );
   645             
   600 
   646             CCalEntry& parent = *entries[parentIndex];
   601             CCalEntry& parent = *entries[parentIndex];
   647 
   602 
   648             TPtrC description( parent.DescriptionL() );
   603             TPtrC description( parent.DescriptionL() );
   649             
   604 
   650             iEntry = ESMRHelper::CopyEntryL(
   605             iEntry = CopyEntryL( iMRMailboxUtils, parent );
   651                             parent,
   606 
   652                             parent.MethodL(),
       
   653                             ESMRHelper::ECopyFull );
       
   654             
       
   655             CESMRFsMailboxUtils* fsMbUtils = 
       
   656                     CESMRFsMailboxUtils::NewL( iMRMailboxUtils );
       
   657             CleanupStack::PushL( fsMbUtils );
       
   658             
       
   659             fsMbUtils->SetPhoneOwnerL( *iBackupEntry );
       
   660             CleanupStack::PopAndDestroy( fsMbUtils );
       
   661             fsMbUtils = NULL;
       
   662             
       
   663             // Adjust parent entry's start and end time to entry
   607             // Adjust parent entry's start and end time to entry
   664             TCalTime start;
   608             TCalTime start;
   665             TCalTime end;
   609             TCalTime end;
   666 
   610 
   667             CESMRRecurrenceInfoHandler* recurrenceHandler =
   611             CESMRRecurrenceInfoHandler* recurrenceHandler =
   671             CleanupStack::PopAndDestroy( recurrenceHandler );
   615             CleanupStack::PopAndDestroy( recurrenceHandler );
   672             recurrenceHandler = NULL;
   616             recurrenceHandler = NULL;
   673 
   617 
   674             iEntry->SetStartAndEndTimeL( start, end );
   618             iEntry->SetStartAndEndTimeL( start, end );
   675 
   619 
   676             iOrginalEntry = ESMRHelper::CopyEntryL(
   620             iOrginalEntry = CopyEntryL( iMRMailboxUtils, *iEntry );
   677                                     *iEntry,
       
   678                                     iEntry->MethodL(),
       
   679                                     ESMRHelper::ECopyFull );
       
   680 
   621 
   681             if ( iEntry->MethodL() != entryMethod )
   622             if ( iEntry->MethodL() != entryMethod )
   682                 {
   623                 {
   683                 iEntry->SetMethodL( entryMethod );
   624                 iEntry->SetMethodL( entryMethod );
   684                 iOrginalEntry->SetMethodL( entryMethod );
   625                 iOrginalEntry->SetMethodL( entryMethod );
   685                 }
   626                 }
   686 
   627 
   687             iEntry->SetDescriptionL( description );
   628             iEntry->SetDescriptionL( description );
   688             iOrginalEntry->SetDescriptionL( description );
   629             iOrginalEntry->SetDescriptionL( description );
   689             iEntry=ESMRHelper::CopyEntryL(*iBackupEntry,iBackupEntry->MethodL(),ESMRHelper::ECopyFull);
   630 
   690             
       
   691             CleanupStack::PopAndDestroy(); // entries
   631             CleanupStack::PopAndDestroy(); // entries
   692             CleanupStack::PopAndDestroy( instance );
   632             CleanupStack::PopAndDestroy( instance );
   693 
   633 
   694             if ( EESMRRoleOrganizer == RoleL() && IsStoredL() )
   634             if ( EESMRRoleOrganizer == RoleL() && IsStoredL() )
   695                 {
   635                 {
   698                 iEntry->SetSequenceNumberL( seqNo );
   638                 iEntry->SetSequenceNumberL( seqNo );
   699                 iOrginalEntry->SetSequenceNumberL( seqNo );
   639                 iOrginalEntry->SetSequenceNumberL( seqNo );
   700                 }
   640                 }
   701             }
   641             }
   702         }
   642         }
   703 
   643     else if ( ERecurrenceNot != orginalRecurrence && 
       
   644     		aTypeChanging && !modifyingEntry )
       
   645     	{
       
   646 		// if entry( in the memory) is a recurrent event 
       
   647 		// ,and if entry type is changing, and not in modifying status then EESMRAllInSeries
       
   648 		iRecurrenceModRule = EESMRAllInSeries ;
       
   649 		return;
       
   650     	}
       
   651     
   704     iRecurrenceModRule = aRule;
   652     iRecurrenceModRule = aRule;
   705 
   653 
   706     }
   654     }
   707 
   655 
   708 // ---------------------------------------------------------------------------
   656 // ---------------------------------------------------------------------------
   726 
   674 
   727     // set the start time to 0:00
   675     // set the start time to 0:00
   728     start.Set( aStartDate.DateTime().Year(),
   676     start.Set( aStartDate.DateTime().Year(),
   729                aStartDate.DateTime().Month(),
   677                aStartDate.DateTime().Month(),
   730                aStartDate.DateTime().Day(),
   678                aStartDate.DateTime().Day(),
   731                KZero,
   679                0,
   732                KZero,
   680                0,
   733                KZero,
   681                0,
   734                KZero);
   682                0);
   735 
   683 
   736     // set the end date to next day from given end date since
   684     // set the end date to next day from given end date since
   737     // all day event should last 24 hours.
   685     // all day event should last 24 hours.
   738     TTime endDate = aEndDate + TTimeIntervalDays( 1 );
   686     TTime endDate = aEndDate + TTimeIntervalDays( 1 );
   739     end.Set( endDate.DateTime().Year(),
   687     end.Set( endDate.DateTime().Year(),
   740              endDate.DateTime().Month(),
   688              endDate.DateTime().Month(),
   741              endDate.DateTime().Day(),
   689              endDate.DateTime().Day(),
   742              KZero,
   690              0,
   743              KZero,
   691              0,
   744              KZero,
   692              0,
   745              KZero );
   693              0 );
   746 
   694 
   747     startTime.SetTimeLocalL( start );
   695     startTime.SetTimeLocalL( start );
   748     stopTime.SetTimeLocalL( end );
   696     stopTime.SetTimeLocalL( end );
   749 
   697 
   750     iEntry->SetStartAndEndTimeL( startTime, stopTime );
   698     iEntry->SetStartAndEndTimeL( startTime, stopTime );
   760     {
   708     {
   761     FUNC_LOG;
   709     FUNC_LOG;
   762 
   710 
   763     __ASSERT_DEBUG( iEntry, Panic(EESMREntryNotExist ) );
   711     __ASSERT_DEBUG( iEntry, Panic(EESMREntryNotExist ) );
   764 
   712 
   765     TBool allDayEvent(EFalse);
   713     CESMRCalUserUtil* entryUtil = CESMRCalUserUtil::NewLC( *iEntry );
   766 
   714 
   767     TCalTime startTime = iEntry->StartTimeL();
   715     TBool allDayEvent( entryUtil->IsAlldayEventL() );
   768     TCalTime stopTime  = iEntry->EndTimeL();
   716 
   769 
   717     CleanupStack::PopAndDestroy( entryUtil );
   770     TTimeIntervalHours hoursBetweenStartAndEnd;
       
   771     stopTime.TimeLocalL().HoursFrom(
       
   772             startTime.TimeLocalL(),
       
   773             hoursBetweenStartAndEnd );
       
   774 
       
   775     TCalTime::TTimeMode mode = startTime.TimeMode();
       
   776 
       
   777     TInt hoursBetweenStartAndEndAsInt(  hoursBetweenStartAndEnd.Int() );
       
   778     TInt alldayDivident(  hoursBetweenStartAndEndAsInt % KHoursInDay );
       
   779 
       
   780     if ( hoursBetweenStartAndEndAsInt&& KZero == alldayDivident )
       
   781         {
       
   782         TDateTime startTimeLocal = startTime.TimeLocalL().DateTime();
       
   783         TDateTime stopTimeLocal =  stopTime.TimeLocalL().DateTime();
       
   784 
       
   785         if ( startTimeLocal.Hour() == stopTimeLocal.Hour() &&
       
   786              startTimeLocal.Minute() == stopTimeLocal.Minute() &&
       
   787              startTimeLocal.Second() == stopTimeLocal.Second() )
       
   788             {
       
   789             allDayEvent = ETrue;
       
   790             }
       
   791         }
       
   792 
       
   793 
   718 
   794     return allDayEvent;
   719     return allDayEvent;
   795     }
   720     }
   796 
   721 
   797 // ---------------------------------------------------------------------------
   722 // ---------------------------------------------------------------------------
   804 
   729 
   805     __ASSERT_DEBUG( iEntry, Panic(EESMREntryNotExist ) );
   730     __ASSERT_DEBUG( iEntry, Panic(EESMREntryNotExist ) );
   806 
   731 
   807     TBool ret(EFalse);
   732     TBool ret(EFalse);
   808     CCalEntry* dbEntry = NULL;
   733     CCalEntry* dbEntry = NULL;
   809     
   734 
   810     TRAPD( err, dbEntry = iCalDb.FetchEntryL(
   735     TRAPD( err, dbEntry = iCalDb.FetchEntryL(
   811                                 iEntry->UidL(),
   736                                 iEntry->UidL(),
   812                                 iEntry->RecurrenceIdL() ) );
   737                                 iEntry->RecurrenceIdL() ) );
   813     
   738 
   814     if ( KErrNotFound == err )
   739     if ( KErrNotFound == err )
   815         {
   740         {
   816         // Error has occured while retrieving an entry        
   741         // Error has occured while retrieving an entry
   817         ret = EFalse;
   742         ret = EFalse;
   818         }    
   743         }
   819     else if ( dbEntry)
   744     else if ( dbEntry)
   820         {
   745         {
   821         // Entry was found from the calendar db --> it is stored for sure.
   746         // Entry was found from the calendar db --> it is stored for sure.
   822         ret = ETrue;
   747         ret = ETrue;
   823         }
   748         }
   842 
   767 
   843     if ( EESMRRoleOrganizer == RoleL()  )
   768     if ( EESMRRoleOrganizer == RoleL()  )
   844         {
   769         {
   845         CCalEntry::TStatus status( iOrginalEntry->StatusL() );
   770         CCalEntry::TStatus status( iOrginalEntry->StatusL() );
   846         if ( CCalEntry::ENullStatus != status )
   771         if ( CCalEntry::ENullStatus != status )
   847             { // When we send a request for the first time we set 
   772             { // When we send a request for the first time we set
   848               // it's status to some other value than ENullStatus
   773               // it's status to some other value than ENullStatus
   849             retVal = ETrue;
   774             retVal = ETrue;
   850             }
   775             }
   851         }
   776         }
   852     else
   777     else
   853         {
   778         {
   854         // In attendee mode, we have sent the entry, if it is stored to
   779         // In attendee mode, we have sent the entry, if it is stored to
   855         // calendar db and status is not declined. Declined entries are
   780         // calendar db and status is known and not declined.
   856         // not stored to calendar db.
   781         // Declined entries are not stored to calendar db.
   857         TESMRAttendeeStatus currentStatus( AttendeeStatusL() );
   782         TESMRAttendeeStatus currentStatus( AttendeeStatusL() );
   858         if ( IsStoredL() && EESMRAttendeeStatusDecline != currentStatus)
   783         if ( IsStoredL()
       
   784              && EESMRAttendeeStatusUnknown != currentStatus
       
   785              && EESMRAttendeeStatusDecline != currentStatus )
   859             {
   786             {
   860             retVal = ETrue;
   787             retVal = ETrue;
   861             }
   788             }
   862         }
   789         }
   863 
   790 
   922         if ( location.CompareF( iOrginalEntry->LocationL() ) )
   849         if ( location.CompareF( iOrginalEntry->LocationL() ) )
   923             {
   850             {
   924             edited = ETrue;
   851             edited = ETrue;
   925             }
   852             }
   926 
   853 
       
   854         if( IsStoredL() )
       
   855             {
       
   856             if ( iCalDb.EntryViewL( *iEntry ) != iCalDb.EntryView() )
       
   857                 {
       
   858                 edited = ETrue;
       
   859                 }
       
   860             }
   927         }
   861         }
   928 
   862 
   929 
   863 
   930 
   864 
   931     return edited;
   865     return edited;
       
   866     }
       
   867 
       
   868 // ---------------------------------------------------------------------------
       
   869 // CESMRMeetingRequestEntry::IsEntryTypeChangedL
       
   870 // ---------------------------------------------------------------------------
       
   871 //
       
   872 TBool CESMRMeetingRequestEntry::IsEntryTypeChangedL() const
       
   873     {
       
   874     FUNC_LOG;
       
   875     
       
   876     return iTypeChanged;
   932     }
   877     }
   933 
   878 
   934 // ---------------------------------------------------------------------------
   879 // ---------------------------------------------------------------------------
   935 // CESMRMeetingRequestEntry::GetAlarmL
   880 // CESMRMeetingRequestEntry::GetAlarmL
   936 // ---------------------------------------------------------------------------
   881 // ---------------------------------------------------------------------------
   965 
   910 
   966     if ( KErrNone == err )
   911     if ( KErrNone == err )
   967         {
   912         {
   968         aAlarmType = MESMRCalEntry::EESMRAlarmAbsolute;
   913         aAlarmType = MESMRCalEntry::EESMRAlarmAbsolute;
   969 
   914 
   970         // only meeting request that is not allday event can have 
   915         // only meeting request that is not allday event can have
   971         // relative alarm:
   916         // relative alarm:
   972         if ( !IsAllDayEventL() )
   917         if ( !IsAllDayEventL() )
   973             {
   918             {
   974             TESMRAlarmInfo alarmInfo;
   919             TESMRAlarmInfo alarmInfo;
   975             TRAP( err,
   920             TRAP( err,
   976                   alarmInfoHandler->GetAlarmInfoObjectL(*iEntry, alarmInfo) );
   921                   alarmInfoHandler->GetAlarmInfoObjectL(*iEntry, alarmInfo) );
   977 
   922 
   978             if ( KErrNone == err )
   923             if ( KErrNone == err )
   979                 {
   924                 {
   980                 aAlarmType = MESMRCalEntry::EESMRAlarmRelative;
   925                 aAlarmType = MESMRCalEntry::EESMRAlarmRelative;
   981                 if( alarmInfo.iRelativeAlarmInSeconds < KZero )
   926                 if( alarmInfo.iRelativeAlarmInSeconds < 0 )
   982                     {
   927                     {
   983                     aAlarmType = MESMRCalEntry::EESMRAlarmNotFound;
   928                     aAlarmType = MESMRCalEntry::EESMRAlarmNotFound;
   984                     }
   929                     }
   985                 }
   930                 }
   986             }
   931             }
   999     {
   944     {
  1000     FUNC_LOG;
   945     FUNC_LOG;
  1001     return *iOrginalEntry;
   946     return *iOrginalEntry;
  1002     }
   947     }
  1003 
   948 
       
   949 
       
   950 // ---------------------------------------------------------------------------
       
   951 // CESMRMeetingRequestEntry::UpdateEntryAfterStoringL
       
   952 // ---------------------------------------------------------------------------
       
   953 //
       
   954 void CESMRMeetingRequestEntry::UpdateEntryAfterStoringL()
       
   955     {
       
   956     FUNC_LOG;
       
   957 
       
   958     __ASSERT_DEBUG( iEntry, Panic(EESMREntryNotExist ) );
       
   959 
       
   960     CCalEntry* storedEntry = NULL;
       
   961 
       
   962 
       
   963     if ( IsRecurrentEventL() &&
       
   964          EESMRThisOnly == iRecurrenceModRule &&
       
   965          !IsForwardedL() && IsStoredL() &&
       
   966          !ESMREntryHelper::IsModifyingEntryL(*iEntry) )
       
   967         {
       
   968         // We have stored one instance of series.
       
   969         storedEntry = iCalDb.FetchEntryL(
       
   970                     iEntry->UidL(),
       
   971                     iOrginalEntry->StartTimeL() );
       
   972         }
       
   973     else
       
   974         {
       
   975         // We are dealing with single instance or with the series
       
   976         storedEntry = iCalDb.FetchEntryL(
       
   977                     iEntry->UidL(),
       
   978                     iEntry->RecurrenceIdL() );
       
   979         }
       
   980 
       
   981 
       
   982     __ASSERT_DEBUG( storedEntry, Panic( EESMREntryNotExist ) );
       
   983     CleanupStack::PushL( storedEntry );
       
   984 
       
   985     // Description needs to be fecthed explicitly into memory
       
   986     TPtrC description( storedEntry->DescriptionL() );
       
   987 
       
   988 
       
   989     delete iEntry;
       
   990     iEntry = NULL;
       
   991     iEntry = CopyEntryL( iMRMailboxUtils, *storedEntry );
       
   992 
       
   993     if ( MESMRCalEntry::EESMRAllInSeries == iRecurrenceModRule &&
       
   994          IsRecurrentEventL() )
       
   995         {
       
   996         // Adjust parent entry's start and end time to entry
       
   997         TCalTime start;
       
   998         TCalTime end;
       
   999 
       
  1000         CESMRRecurrenceInfoHandler* recurrenceHandler =
       
  1001                 CESMRRecurrenceInfoHandler::NewLC( *iEntry );
       
  1002 
       
  1003         recurrenceHandler->GetFirstInstanceTimeL( start, end );
       
  1004         CleanupStack::PopAndDestroy( recurrenceHandler );
       
  1005         recurrenceHandler = NULL;
       
  1006 
       
  1007         iEntry->SetStartAndEndTimeL( start, end );
       
  1008         iEntry->SetDescriptionL( description );
       
  1009         }
       
  1010 
       
  1011     CCalEntry* temp  = CopyEntryL( iMRMailboxUtils, *iEntry );
       
  1012 
       
  1013     delete iOrginalEntry;
       
  1014     iOrginalEntry = temp;
       
  1015 
       
  1016     CleanupStack::PopAndDestroy( storedEntry );
       
  1017     }
       
  1018 
       
  1019 // ----------------------------------------------------------------------------
       
  1020 // CMRCalEntry::UpdateComparativeEntry
       
  1021 // ----------------------------------------------------------------------------
       
  1022 //
       
  1023 void CESMRMeetingRequestEntry::UpdateComparativeEntry(
       
  1024         CCalEntry* aNewComparativeEntry )
       
  1025     {
       
  1026     FUNC_LOG;
       
  1027 
       
  1028     if( iOrginalEntry ) // Update comparative entry
       
  1029         {
       
  1030         delete iOrginalEntry;
       
  1031         iOrginalEntry = NULL;
       
  1032 
       
  1033         iOrginalEntry = aNewComparativeEntry;
       
  1034         }
       
  1035 
       
  1036     }
       
  1037 
       
  1038 // ---------------------------------------------------------------------------
       
  1039 // CESMRMeetingRequestEntry::SetDefaultValuesToEntryL
       
  1040 // ---------------------------------------------------------------------------
       
  1041 //
       
  1042 void CESMRMeetingRequestEntry::SetDefaultValuesToEntryL()
       
  1043     {
       
  1044     FUNC_LOG;
       
  1045 
       
  1046     if ( !IsStoredL() )
       
  1047         {
       
  1048         SetPriorityL( EFSCalenMRPriorityNormal );
       
  1049 
       
  1050         // Get default alarm time from central repository
       
  1051         TInt defaultAlarmTime=0;
       
  1052         CRepository* repository = CRepository::NewLC( KCRUidCalendar );
       
  1053 
       
  1054         TInt err = KErrNotFound;
       
  1055 
       
  1056         if ( repository )
       
  1057             {
       
  1058             err = repository->Get(
       
  1059                     KCalendarDefaultAlarmTime,
       
  1060                     defaultAlarmTime );
       
  1061             CleanupStack::PopAndDestroy( repository );
       
  1062             }
       
  1063 
       
  1064         if ( err != KErrNone )
       
  1065             {
       
  1066             // By default 15 minutes if not found from central repository
       
  1067             defaultAlarmTime = KDefaultMeetingAlarmMinutes;
       
  1068             }
       
  1069 
       
  1070         // Getting current time
       
  1071         TTime currentTime;
       
  1072         currentTime.HomeTime();
       
  1073 
       
  1074         // Getting meeting start time
       
  1075         TTime start = iEntry->StartTimeL().TimeLocalL();
       
  1076 
       
  1077         // Create default alarm
       
  1078         CCalAlarm* alarm = CCalAlarm::NewL();
       
  1079         CleanupStack::PushL( alarm );
       
  1080 
       
  1081         TTimeIntervalMinutes alarmOffset( defaultAlarmTime );
       
  1082 
       
  1083         // If alarm time is in past
       
  1084         if ( ( start - alarmOffset ) < currentTime )
       
  1085             {
       
  1086             // Setting alarm off
       
  1087             iEntry->SetAlarmL( NULL );
       
  1088             }
       
  1089         else
       
  1090             {
       
  1091             // Set default alarm time
       
  1092             alarm->SetTimeOffset( alarmOffset );
       
  1093             iEntry->SetAlarmL( alarm );
       
  1094             }
       
  1095         CleanupStack::PopAndDestroy( alarm );
       
  1096         }
       
  1097 
       
  1098     // Set the default end time if not set by client
       
  1099     if ( iEntry->StartTimeL().TimeUtcL() == iEntry->EndTimeL().TimeUtcL() )
       
  1100         {
       
  1101         // This value might also be read from cenrep
       
  1102         TTimeIntervalHours KDefaultMeetingDuration(1);
       
  1103 
       
  1104         TCalTime newEndTime;
       
  1105         newEndTime.SetTimeUtcL(
       
  1106                 iEntry->StartTimeL().TimeUtcL() + KDefaultMeetingDuration );
       
  1107         iEntry->SetStartAndEndTimeL(iEntry->StartTimeL(), newEndTime);
       
  1108         }
       
  1109 
       
  1110     iEntry->SetReplicationStatusL( CCalEntry::EOpen );
       
  1111 
       
  1112     //Original entry must be stored after the default values are set.
       
  1113     //Otherwise it looks like settings are changed even though they haven't
       
  1114     CCalEntry* temp = CopyEntryL( iMRMailboxUtils, *iEntry );
       
  1115 
       
  1116     delete iOrginalEntry;
       
  1117     iOrginalEntry = temp;
       
  1118     }
       
  1119 
       
  1120 // ---------------------------------------------------------------------------
       
  1121 // CESMRMeetingRequestEntry::CloneEntryLC
       
  1122 // ---------------------------------------------------------------------------
       
  1123 //
       
  1124 CCalEntry* CESMRMeetingRequestEntry::CloneEntryLC(
       
  1125         TESMRCalEntryType aType ) const
       
  1126     {
       
  1127     CCalEntry* entry =
       
  1128         ESMRHelper::CopyEntryLC( *iEntry,
       
  1129                                  iEntry->MethodL(),
       
  1130                                  ESMRHelper::ECopyFull,
       
  1131                                  TESMRCalendarEventType( aType ) );
       
  1132 
       
  1133     return entry;
       
  1134     }
  1004 
  1135 
  1005 // ---------------------------------------------------------------------------
  1136 // ---------------------------------------------------------------------------
  1006 // CESMRMeetingRequestEntry::RoleL
  1137 // CESMRMeetingRequestEntry::RoleL
  1007 // ---------------------------------------------------------------------------
  1138 // ---------------------------------------------------------------------------
  1008 //
  1139 //
  1106             break;
  1237             break;
  1107         }
  1238         }
  1108 
  1239 
  1109     attendee->SetStatusL(status);
  1240     attendee->SetStatusL(status);
  1110     iEntry->SetStatusL(entryStatus);
  1241     iEntry->SetStatusL(entryStatus);
  1111     
  1242 
  1112     iEntry->SetMethodL( CCalEntry::EMethodReply );
  1243     iEntry->SetMethodL( CCalEntry::EMethodReply );
  1113 
  1244 
  1114     }
  1245     }
  1115 
  1246 
  1116 // ---------------------------------------------------------------------------
  1247 // ---------------------------------------------------------------------------
  1125     __ASSERT_DEBUG( iEntry, Panic(EESMREntryNotExist ) );
  1256     __ASSERT_DEBUG( iEntry, Panic(EESMREntryNotExist ) );
  1126 
  1257 
  1127     TBool outOfDate( EFalse );
  1258     TBool outOfDate( EFalse );
  1128 
  1259 
  1129     CCalEntry::TMethod method( iEntry->MethodL() );
  1260     CCalEntry::TMethod method( iEntry->MethodL() );
  1130     if ( IsOpenedFromMail() && 
  1261     if ( IsOpenedFromMail() &&
  1131          CCalEntry::EMethodCancel != method )
  1262          CCalEntry::EMethodCancel != method )
  1132         {
  1263         {
  1133         CCalEntry* dbEntry = NULL;
  1264         CCalEntry* dbEntry = NULL;
  1134         
  1265 
  1135         TRAP_IGNORE( dbEntry = iCalDb.FetchEntryL( iEntry->UidL(),
  1266         TRAP_IGNORE( dbEntry = iCalDb.FetchEntryL( iEntry->UidL(),
  1136                                                  iEntry->RecurrenceIdL() ) );
  1267                                                  iEntry->RecurrenceIdL() ) );
  1137 
  1268 
  1138         CleanupStack::PushL( dbEntry );
  1269         CleanupStack::PushL( dbEntry );
  1139         if ( dbEntry )
  1270         if ( dbEntry )
  1203         }
  1334         }
  1204 
  1335 
  1205     CCalAttendee::TCalStatus attendeeStatus( attendee->StatusL() );
  1336     CCalAttendee::TCalStatus attendeeStatus( attendee->StatusL() );
  1206     switch ( attendeeStatus )
  1337     switch ( attendeeStatus )
  1207         {
  1338         {
       
  1339         case CCalAttendee::ENeedsAction:
       
  1340             status = EESMRAttendeeStatusUnknown;
       
  1341             break;
       
  1342 
  1208         case CCalAttendee::EAccepted:
  1343         case CCalAttendee::EAccepted:
  1209             status = EESMRAttendeeStatusAccept;
  1344             status = EESMRAttendeeStatusAccept;
  1210             break;
  1345             break;
  1211 
  1346 
  1212         case CCalAttendee::ETentative:
  1347         case CCalAttendee::ETentative:
  1252 void CESMRMeetingRequestEntry::SwitchToForwardL()
  1387 void CESMRMeetingRequestEntry::SwitchToForwardL()
  1253     {
  1388     {
  1254     FUNC_LOG;
  1389     FUNC_LOG;
  1255 
  1390 
  1256     __ASSERT_DEBUG( iEntry, Panic(EESMREntryNotExist ) );
  1391     __ASSERT_DEBUG( iEntry, Panic(EESMREntryNotExist ) );
  1257     
  1392 
  1258     CCalEntry* temp = ESMRHelper::CopyEntryL(
  1393     CCalEntry* temp = CopyEntryL( iMRMailboxUtils, *iEntry );
  1259         *iEntry,
  1394 
  1260         iEntry->MethodL(),
  1395     delete iForwardEntry;
  1261         ESMRHelper::ECopyFull );
       
  1262     
       
  1263     delete iForwardEntry; 
       
  1264     iForwardEntry = temp;
  1396     iForwardEntry = temp;
  1265 
  1397 
  1266     RPointerArray<CCalAttendee>& attendeeList =
  1398     RPointerArray<CCalAttendee>& attendeeList =
  1267                                     iForwardEntry->AttendeesL();
  1399                                     iForwardEntry->AttendeesL();
  1268 
  1400 
  1269     while ( attendeeList.Count() )
  1401     while ( attendeeList.Count() )
  1270         {
  1402         {
  1271         //remove attendees from entry that is to be forwarded
  1403         //remove attendees from entry that is to be forwarded
  1272         iForwardEntry->DeleteAttendeeL( KFirstIndex );
  1404         iForwardEntry->DeleteAttendeeL( 0 );
  1273         }
  1405         }
  1274 
  1406 
  1275     }
  1407     }
  1276 
  1408 
  1277 // ---------------------------------------------------------------------------
  1409 // ---------------------------------------------------------------------------
  1306          iForwardEntry->StatusL() == CCalEntry::ENullStatus )
  1438          iForwardEntry->StatusL() == CCalEntry::ENullStatus )
  1307         {
  1439         {
  1308         iForwardEntry->SetStatusL( CCalEntry::EConfirmed );
  1440         iForwardEntry->SetStatusL( CCalEntry::EConfirmed );
  1309         }
  1441         }
  1310     else if ( RoleL() == EESMRRoleOrganizer ||
  1442     else if ( RoleL() == EESMRRoleOrganizer ||
  1311     		iEntry->StatusL() == CCalEntry::ENullStatus )
  1443             iEntry->StatusL() == CCalEntry::ENullStatus )
  1312         {
  1444         {
  1313         iEntry->SetStatusL( CCalEntry::EConfirmed );
  1445         iEntry->SetStatusL( CCalEntry::EConfirmed );
  1314         }
  1446         }
  1315  
  1447 
  1316     }
  1448     }
  1317 
  1449 
  1318 // ---------------------------------------------------------------------------
  1450 // ---------------------------------------------------------------------------
  1319 // CESMRMeetingRequestEntry::OccursInPastL
  1451 // CESMRMeetingRequestEntry::OccursInPastL
  1320 // ---------------------------------------------------------------------------
  1452 // ---------------------------------------------------------------------------
  1362             AttendeeStatusL() );
  1494             AttendeeStatusL() );
  1363 
  1495 
  1364     MESMRMeetingRequestEntry::TESMREntryInfo info =
  1496     MESMRMeetingRequestEntry::TESMREntryInfo info =
  1365             EESMREntryInfoNormal;
  1497             EESMREntryInfoNormal;
  1366 
  1498 
  1367     TBool isSent( IsSentL() );
       
  1368 
       
  1369     if ( IsEntryOutOfDateL() )
  1499     if ( IsEntryOutOfDateL() )
  1370         {
  1500         {
  1371         info = EESMREntryInfoOutOfDate;
  1501         info = EESMREntryInfoOutOfDate;
  1372         }
  1502         }
  1373     else if( IsMeetingCancelledL() )
  1503     else if( IsMeetingCancelledL() )
  1374         {
  1504         {
  1375         info = EESMREntryInfoCancelled;
  1505         info = EESMREntryInfoCancelled;
  1376         }
  1506         }
  1377     else if ( isSent )
  1507     else if ( IsSentL() )
  1378         {
  1508         {
  1379         info = EESMREntryInfoAccepted;
  1509         info = EESMREntryInfoAccepted;
  1380         if ( EESMRAttendeeStatusTentative == attendeeStatus )
  1510         if ( EESMRAttendeeStatusTentative == attendeeStatus )
  1381             {
  1511             {
  1382             info = EESMREntryInfoTentativelyAccepted;
  1512             info = EESMREntryInfoTentativelyAccepted;
  1383             }
  1513             }
  1384         }
  1514         }
  1385     else if ( OccursInPastL() )
  1515     else if ( OccursInPastL() )
  1386         {
  1516         {
  1387         info = EESMREntryInfoOccursInPast;
  1517         info = EESMREntryInfoOccursInPast;
  1388         }
       
  1389     else if ( iConflictsExists )
       
  1390         {
       
  1391         info = EESMREntryInfoConflicts;
       
  1392         }
  1518         }
  1393 
  1519 
  1394 
  1520 
  1395     return info;
  1521     return info;
  1396     }
  1522     }
  1464 
  1590 
  1465     CCalEntry* entry = NULL;
  1591     CCalEntry* entry = NULL;
  1466 
  1592 
  1467     if ( iForwardEntry )
  1593     if ( iForwardEntry )
  1468         {
  1594         {
  1469         entry = ESMRHelper::CopyEntryL(
  1595         entry = CopyEntryL( iMRMailboxUtils, *iForwardEntry );
  1470                 *iForwardEntry,
       
  1471                 iForwardEntry->MethodL(),
       
  1472                 ESMRHelper::ECopyFull );
       
  1473         }
  1596         }
  1474 
  1597 
  1475     if ( !entry && IsRecurrentEventL() &&
  1598     if ( !entry && IsRecurrentEventL() &&
  1476          EESMRThisOnly == iRecurrenceModRule &&
  1599          EESMRThisOnly == iRecurrenceModRule &&
  1477          !IsForwardedL() && IsStoredL() &&
  1600          !IsForwardedL() && IsStoredL() &&
  1504                 // create new (child) entry
  1627                 // create new (child) entry
  1505                 entry = CCalEntry::NewL(
  1628                 entry = CCalEntry::NewL(
  1506                                 parent.EntryTypeL(),
  1629                                 parent.EntryTypeL(),
  1507                                 guid,
  1630                                 guid,
  1508                                 parent.MethodL(),
  1631                                 parent.MethodL(),
  1509                                 KZero,
  1632                                 0,
  1510                                 iOrginalEntry->StartTimeL(),
  1633                                 iOrginalEntry->StartTimeL(),
  1511                                 CalCommon::EThisOnly );
  1634                                 CalCommon::EThisOnly );
  1512 
  1635 
  1513                 CleanupStack::Pop( guid ); 
  1636                 CleanupStack::Pop( guid );
  1514                 guid = NULL; // ownership transferred
  1637                 guid = NULL; // ownership transferred
  1515                 }
  1638                 }
  1516 
  1639 
  1517             CleanupStack::PopAndDestroy( instance );  
  1640             CleanupStack::PopAndDestroy( instance );
  1518             instance = NULL; // instance
  1641             instance = NULL; // instance
  1519             CleanupStack::PushL( entry );
  1642             CleanupStack::PushL( entry );
  1520 
  1643 
  1521 
  1644 
  1522             CCalEntry::TMethod method( iEntry->MethodL() );
  1645             CCalEntry::TMethod method( iEntry->MethodL() );
  1523 
  1646 
  1524             entry->CopyFromL( *iEntry, CCalEntry::EDontCopyId );
  1647             entry->CopyFromL( *iEntry, CCalEntry::EDontCopyId );
  1525             entry->SetSequenceNumberL( KZero );
  1648             entry->SetSequenceNumberL( 0 );
  1526             entry->SetMethodL( method );
  1649             entry->SetMethodL( method );
  1527             entry->SetSummaryL( iEntry->SummaryL() );
  1650             entry->SetSummaryL( iEntry->SummaryL() );
  1528             entry->SetLocalUidL( TCalLocalUid( 0 ) );
  1651             entry->SetLocalUidL( TCalLocalUid( 0 ) );
  1529             entry->ClearRepeatingPropertiesL();
  1652             entry->ClearRepeatingPropertiesL();
       
  1653             iMRMailboxUtils.SetPhoneOwnerL( *entry );
  1530 
  1654 
  1531             CleanupStack::Pop( entry );
  1655             CleanupStack::Pop( entry );
  1532             }
  1656             }
  1533         }
  1657         }
  1534 
  1658 
  1535     if ( !entry )
  1659     if ( !entry )
  1536         {
  1660         {
  1537 
  1661         entry = CopyEntryL( iMRMailboxUtils, *iEntry );
  1538         entry = ESMRHelper::CopyEntryL(
  1662         }
  1539                 *iEntry,
  1663 
  1540                 iEntry->MethodL(),
  1664     if ( iRemoveAttachments )
  1541                 ESMRHelper::ECopyFull );
  1665         {
  1542 
  1666         // Remove attachments from the entry
  1543         }
  1667         TInt count( entry->AttachmentCountL() );
  1544 
  1668         
       
  1669         for ( TInt i = 0; i < count; ++i )
       
  1670             {
       
  1671             CCalAttachment* attachment = entry->AttachmentL( i );
       
  1672             entry->DeleteAttachmentL( *attachment );
       
  1673             }
       
  1674         }
  1545 
  1675 
  1546     return entry;
  1676     return entry;
  1547     }
  1677     }
  1548 
  1678 
  1549 // ---------------------------------------------------------------------------
  1679 // ---------------------------------------------------------------------------
  1633         {
  1763         {
  1634         MMRAttendee* attendee = attendeeArray[i];
  1764         MMRAttendee* attendee = attendeeArray[i];
  1635 
  1765 
  1636         TPtrC calEntryAddress( thisAttendee->Address() );
  1766         TPtrC calEntryAddress( thisAttendee->Address() );
  1637         TPtrC infoAddress( attendee->Address() );
  1767         TPtrC infoAddress( attendee->Address() );
  1638         if ( KZero == infoAddress.Compare(calEntryAddress ) )
  1768         if ( 0 == infoAddress.Compare(calEntryAddress ) )
  1639             {
  1769             {
  1640             found = ETrue;
  1770             found = ETrue;
  1641 
  1771 
  1642             MMRInfoObject::TResponse entryResp(
  1772             MMRInfoObject::TResponse entryResp(
  1643                     MMRInfoObject::EMrCmdResponseAccept );
  1773                     MMRInfoObject::EMrCmdResponseAccept );
  1685         retValue = ETrue;
  1815         retValue = ETrue;
  1686 
  1816 
  1687         aStartupParams.iCalEntry       = iESMRInputParams->iCalEntry;
  1817         aStartupParams.iCalEntry       = iESMRInputParams->iCalEntry;
  1688         aStartupParams.iMRInfoObject   = iESMRInputParams->iMRInfoObject;
  1818         aStartupParams.iMRInfoObject   = iESMRInputParams->iMRInfoObject;
  1689         aStartupParams.iMailMessage    = iESMRInputParams->iMailMessage;
  1819         aStartupParams.iMailMessage    = iESMRInputParams->iMailMessage;
  1690         aStartupParams.iMailClient     = iESMRInputParams->iMailClient;
  1820         aStartupParams.iMailClient     = iESMRInputParams->iMailClient;        
  1691         aStartupParams.iAttachmentInfo = iESMRInputParams->iAttachmentInfo;
       
  1692         aStartupParams.iSpare          = iESMRInputParams->iSpare;
  1821         aStartupParams.iSpare          = iESMRInputParams->iSpare;
  1693         }
  1822         }
  1694     return retValue;
  1823     return retValue;
  1695     }
  1824     }
  1696 
  1825 
  1777 
  1906 
  1778     return retEntry;
  1907     return retEntry;
  1779     }
  1908     }
  1780 
  1909 
  1781 // ---------------------------------------------------------------------------
  1910 // ---------------------------------------------------------------------------
  1782 // CESMRMeetingRequestEntry::SetDefaultValuesToEntryL
       
  1783 // ---------------------------------------------------------------------------
       
  1784 //
       
  1785 void CESMRMeetingRequestEntry::SetDefaultValuesToEntryL()
       
  1786     {
       
  1787     FUNC_LOG;
       
  1788 
       
  1789     if ( !IsStoredL() )
       
  1790         {
       
  1791         SetPriorityL( EFSCalenMRPriorityNormal );
       
  1792 
       
  1793         // Get default alarm time from central repository
       
  1794         TInt defaultAlarmTime=0;
       
  1795         CRepository* repository = CRepository::NewLC( KCRUidCalendar );
       
  1796         
       
  1797         TInt err = KErrNotFound; 
       
  1798         
       
  1799         if ( repository )
       
  1800             {
       
  1801             err = repository->Get(
       
  1802                     KCalendarDefaultAlarmTime,
       
  1803                     defaultAlarmTime );
       
  1804             CleanupStack::PopAndDestroy( repository );
       
  1805             }
       
  1806 
       
  1807         if ( err != KErrNone )
       
  1808             {
       
  1809             // By default 15 minutes if not found from central repository
       
  1810             defaultAlarmTime = KDefaultMeetingAlarmMinutes;
       
  1811             }
       
  1812 
       
  1813         // Getting current time
       
  1814         TTime currentTime;
       
  1815         currentTime.HomeTime();
       
  1816 
       
  1817         // Getting meeting start time
       
  1818         TTime start = iEntry->StartTimeL().TimeLocalL();
       
  1819 
       
  1820         // Create default alarm
       
  1821         CCalAlarm* alarm = CCalAlarm::NewL();
       
  1822         CleanupStack::PushL( alarm );
       
  1823 
       
  1824         TTimeIntervalMinutes alarmOffset( defaultAlarmTime );
       
  1825 
       
  1826         // If alarm time is in past
       
  1827         if ( ( start - alarmOffset ) < currentTime )
       
  1828             {
       
  1829             // Setting alarm off
       
  1830             iEntry->SetAlarmL( NULL );
       
  1831             }
       
  1832         else
       
  1833             {
       
  1834             // Set default alarm time
       
  1835             alarm->SetTimeOffset( alarmOffset );
       
  1836             iEntry->SetAlarmL( alarm );
       
  1837             }
       
  1838         CleanupStack::PopAndDestroy( alarm );
       
  1839         }
       
  1840 
       
  1841     // Set the default end time if not set by client
       
  1842     if ( iEntry->StartTimeL().TimeUtcL() == iEntry->EndTimeL().TimeUtcL() )
       
  1843         {
       
  1844         // This value might also be read from cenrep
       
  1845         TTimeIntervalHours KDefaultMeetingDuration(1);
       
  1846 
       
  1847         TCalTime newEndTime;
       
  1848         newEndTime.SetTimeUtcL(
       
  1849                 iEntry->StartTimeL().TimeUtcL() + KDefaultMeetingDuration );
       
  1850         iEntry->SetStartAndEndTimeL(iEntry->StartTimeL(), newEndTime);
       
  1851         }
       
  1852 
       
  1853     iEntry->SetReplicationStatusL( CCalEntry::EOpen );
       
  1854 
       
  1855     //Original entry must be stored after the default values are set.
       
  1856     //Otherwise it looks like settings are changed even though they haven't    
       
  1857 
       
  1858     CCalEntry* temp = ESMRHelper::CopyEntryL(
       
  1859                                         *iEntry,
       
  1860                                         iEntry->MethodL(),
       
  1861                                         ESMRHelper::ECopyFull );
       
  1862     
       
  1863     delete iOrginalEntry;
       
  1864     iOrginalEntry = temp;
       
  1865 
       
  1866     }
       
  1867 
       
  1868 
       
  1869 // ---------------------------------------------------------------------------
       
  1870 // CESMRMeetingRequestEntry::IsOpenedFromMail
  1911 // CESMRMeetingRequestEntry::IsOpenedFromMail
  1871 // ---------------------------------------------------------------------------
  1912 // ---------------------------------------------------------------------------
  1872 //
  1913 //
  1873 TBool CESMRMeetingRequestEntry::IsOpenedFromMail() const
  1914 TBool CESMRMeetingRequestEntry::IsOpenedFromMail() const
  1874     {
  1915     {
  1998     CleanupStack::PopAndDestroy( &currentAttendees );
  2039     CleanupStack::PopAndDestroy( &currentAttendees );
  1999 
  2040 
  2000     }
  2041     }
  2001 
  2042 
  2002 // ---------------------------------------------------------------------------
  2043 // ---------------------------------------------------------------------------
  2003 // CESMRMeetingRequestEntry::UpdateEntryAfterStoringL
       
  2004 // ---------------------------------------------------------------------------
       
  2005 //
       
  2006 void CESMRMeetingRequestEntry::UpdateEntryAfterStoringL()
       
  2007     {
       
  2008     FUNC_LOG;
       
  2009 
       
  2010     __ASSERT_DEBUG( iEntry, Panic(EESMREntryNotExist ) );
       
  2011 
       
  2012      CCalEntry* temp  = ESMRHelper::CopyEntryL(
       
  2013         *iEntry,
       
  2014         iEntry->MethodL(),
       
  2015         ESMRHelper::ECopyFull );
       
  2016      
       
  2017      delete iOrginalEntry;
       
  2018      iOrginalEntry = temp;
       
  2019 
       
  2020     }
       
  2021 
       
  2022 // ---------------------------------------------------------------------------
       
  2023 // CESMRMeetingRequestEntry::UpdateChildEntriesSeqNumbersL
  2044 // CESMRMeetingRequestEntry::UpdateChildEntriesSeqNumbersL
  2024 // ---------------------------------------------------------------------------
  2045 // ---------------------------------------------------------------------------
  2025 //
  2046 //
  2026 void CESMRMeetingRequestEntry::UpdateChildEntriesSeqNumbersL()
  2047 void CESMRMeetingRequestEntry::UpdateChildEntriesSeqNumbersL()
  2027 	{
  2048     {
  2028     FUNC_LOG;
  2049     FUNC_LOG;
  2029 
  2050 
  2030     if ( MESMRCalEntry::EESMRAllInSeries == iRecurrenceModRule && 
  2051     if ( MESMRCalEntry::EESMRAllInSeries == iRecurrenceModRule &&
  2031     	 IsStoredL() )
  2052          IsStoredL() )
  2032     	{
  2053         {
  2033 		RCPointerArray<CCalEntry> childEntries;    	
  2054         RCPointerArray<CCalEntry> childEntries;
  2034 		CleanupClosePushL( childEntries );
  2055         CleanupClosePushL( childEntries );
  2035 		
  2056 
  2036     	// Fetch all entries (this and child entries
  2057         // Fetch all entries (this and child entries
  2037 		iCalDb.NormalDbEntryView()->FetchL(
  2058         iCalDb.EntryView()->FetchL(
  2038 				iEntry->UidL(),
  2059                 iEntry->UidL(),
  2039 				childEntries );    	
  2060                 childEntries );
  2040     	
  2061 
  2041     	// Next: Remove parent entry from the array		
  2062         // Next: Remove parent entry from the array
  2042 		TBool removed( EFalse );
  2063         TBool removed( EFalse );
  2043 		TInt entryCount( childEntries.Count() );
  2064         TInt entryCount( childEntries.Count() );
  2044 		for ( TInt i(0); (i < entryCount) && !removed; ++i  )
  2065         for ( TInt i(0); (i < entryCount) && !removed; ++i  )
  2045 			{
  2066             {
  2046 			CCalEntry* entry = childEntries[i];
  2067             CCalEntry* entry = childEntries[i];
  2047 			
  2068 
  2048 			if ( !ESMREntryHelper::IsModifyingEntryL( *entry) )
  2069             if ( !ESMREntryHelper::IsModifyingEntryL( *entry) )
  2049 				{
  2070                 {
  2050 				removed = ETrue;
  2071                 removed = ETrue;
  2051 				childEntries.Remove( i );
  2072                 childEntries.Remove( i );
  2052 				delete entry;
  2073                 delete entry;
  2053 				}
  2074                 }
  2054 			entry = NULL;
  2075             entry = NULL;
  2055 			}
  2076             }
  2056     
  2077 
  2057 		TInt childCount( childEntries.Count() );
  2078         TInt childCount( childEntries.Count() );
  2058 		if ( childCount )
  2079         if ( childCount )
  2059 			{
  2080             {
  2060 			for (TInt i(0); i < childCount; ++i )
  2081             for (TInt i(0); i < childCount; ++i )
  2061 				{
  2082                 {
  2062 				CCalEntry* child = childEntries[i];
  2083                 CCalEntry* child = childEntries[i];
  2063 				TInt childSeqNo( child->SequenceNumberL() );
  2084                 TInt childSeqNo( child->SequenceNumberL() );
  2064 				child->SetSequenceNumberL( childSeqNo + 1);
  2085                 child->SetSequenceNumberL( childSeqNo + 1);
  2065 				}		
  2086                 }
  2066 			
  2087 
  2067 			TInt updatedChilds;
  2088             TInt updatedChilds;
  2068 			iCalDb.NormalDbEntryView()->StoreL(childEntries, updatedChilds);
  2089             iCalDb.EntryView()->StoreL(childEntries, updatedChilds);
  2069 			}
  2090             }
  2070 		
  2091 
  2071     	CleanupStack::PopAndDestroy(); // childEntries
  2092         CleanupStack::PopAndDestroy(); // childEntries
  2072     	}
  2093         }
  2073     
  2094 
  2074 	}
  2095     }
  2075 
  2096 
  2076 // ---------------------------------------------------------------------------
  2097 // ---------------------------------------------------------------------------
  2077 // CESMRMeetingRequestEntry::CurrentPluginL
  2098 // CESMRMeetingRequestEntry::CurrentPluginL
  2078 // ---------------------------------------------------------------------------
  2099 // ---------------------------------------------------------------------------
  2079 //
  2100 //
  2081     {
  2102     {
  2082     FUNC_LOG;
  2103     FUNC_LOG;
  2083 
  2104 
  2084     if ( EESMRUnknownPlugin == iCurrentFSEmailPlugin)
  2105     if ( EESMRUnknownPlugin == iCurrentFSEmailPlugin)
  2085         {
  2106         {
  2086         CESMRFsMailboxUtils* fsMbUtils = 
  2107         CESMRFsMailboxUtils* fsMbUtils =
  2087                 CESMRFsMailboxUtils::NewL( iMRMailboxUtils );
  2108                 CESMRFsMailboxUtils::NewL( iMRMailboxUtils );
  2088         CleanupStack::PushL( fsMbUtils );
  2109         CleanupStack::PushL( fsMbUtils );
  2089         
  2110 
  2090         iCurrentFSEmailPlugin = fsMbUtils->FSEmailPluginForEntryL( *iEntry );
  2111         iCurrentFSEmailPlugin = fsMbUtils->FSEmailPluginForEntryL( *iEntry );
  2091         CleanupStack::PopAndDestroy( fsMbUtils );
  2112         CleanupStack::PopAndDestroy( fsMbUtils );
  2092         fsMbUtils = NULL;        
  2113         fsMbUtils = NULL;
  2093         }
  2114         }
  2094 
       
  2095 
  2115 
  2096     return iCurrentFSEmailPlugin;
  2116     return iCurrentFSEmailPlugin;
  2097     }
  2117     }
  2098 
  2118 
  2099 // ---------------------------------------------------------------------------
  2119 // ---------------------------------------------------------------------------
  2100 // CESMRMeetingRequestEntry::CurrentMailBoxIdL
       
  2101 // ---------------------------------------------------------------------------
       
  2102 //
       
  2103 TFSMailMsgId CESMRMeetingRequestEntry::CurrentMailBoxIdL()
       
  2104     {
       
  2105     FUNC_LOG;
       
  2106     CESMRFsMailboxUtils* fsMbUtils = 
       
  2107         CESMRFsMailboxUtils::NewL( iMRMailboxUtils );
       
  2108     CleanupStack::PushL( fsMbUtils );
       
  2109     TFSMailMsgId retVal = fsMbUtils->FSEmailMailBoxForEntryL( *iEntry );
       
  2110     CleanupStack::PopAndDestroy( fsMbUtils );
       
  2111     return retVal;
       
  2112     }
       
  2113 
       
  2114 // ---------------------------------------------------------------------------
       
  2115 // CESMRMeetingRequestEntry::UpdateTimeStampL
  2120 // CESMRMeetingRequestEntry::UpdateTimeStampL
  2116 // ---------------------------------------------------------------------------
  2121 // ---------------------------------------------------------------------------
  2117 //
  2122 //
  2118 void CESMRMeetingRequestEntry::UpdateTimeStampL()
  2123 void CESMRMeetingRequestEntry::UpdateTimeStampL()
  2119     {
  2124     {
  2120     FUNC_LOG;
  2125     FUNC_LOG;
  2121     __ASSERT_DEBUG( iEntry, Panic(EESMREntryNotExist ) );
  2126     __ASSERT_DEBUG( iEntry, Panic(EESMREntryNotExist ) );
  2122     
  2127 
  2123     TTime currentUTCTime;
  2128     TTime currentUTCTime;
  2124     currentUTCTime.UniversalTime();
  2129     currentUTCTime.UniversalTime();
  2125 
  2130 
  2126     TCalTime currentTime;
  2131     TCalTime currentTime;
  2127     currentTime.SetTimeUtcL( currentUTCTime );
  2132     currentTime.SetTimeUtcL( currentUTCTime );
  2128 
  2133 
  2129     iEntry->SetDTStampL( currentTime );    
  2134     iEntry->SetDTStampL( currentTime );
  2130     }
  2135     }
  2131 
  2136 
  2132 // ---------------------------------------------------------------------------
  2137 // ---------------------------------------------------------------------------
  2133 // CESMRMeetingRequestEntry::UpdateTimeStampL
  2138 // CESMRMeetingRequestEntry::AnyInstancesBetweenTimePeriodL
  2134 // ---------------------------------------------------------------------------
  2139 // ---------------------------------------------------------------------------
  2135 //
  2140 //
  2136 TBool CESMRMeetingRequestEntry::AnyInstanceOnDayL(
  2141 TBool CESMRMeetingRequestEntry::AnyInstancesBetweenTimePeriodL(
  2137             TTime& aStart,
  2142             TTime& aStart,
  2138             TTime& aEnd )
  2143             TTime& aEnd )
  2139     {
  2144     {
  2140     FUNC_LOG;
  2145     FUNC_LOG;
       
  2146 
       
  2147     __ASSERT_DEBUG( iEntry, Panic(EESMREntryNotExist ) );
       
  2148     __ASSERT_DEBUG( iOrginalEntry, Panic(EESMREntryNotExist ) );
       
  2149 
       
  2150     TBool retValue( EFalse );
       
  2151 
       
  2152     RCPointerArray<CCalEntry> entries;
       
  2153     CleanupClosePushL( entries );
       
  2154 
       
  2155     CESMRConflictChecker* conflictCheckker =
       
  2156         CESMRConflictChecker::NewL( iCalDb );
       
  2157     CleanupStack::PushL( conflictCheckker );
       
  2158 
       
  2159     CCalInstance* instance = InstanceL();
       
  2160     CleanupStack::PushL( instance );
       
  2161     
       
  2162     TCalCollectionId colId = instance->InstanceIdL().iCollectionId;
       
  2163     CleanupStack::PopAndDestroy( instance );
       
  2164     
       
  2165     conflictCheckker->FindInstancesForEntryL( aStart,
       
  2166                                               aEnd,
       
  2167                                               *iEntry,
       
  2168                                               colId, 
       
  2169                                               entries );
       
  2170 
       
  2171     if ( entries.Count() )
       
  2172         {
       
  2173         retValue = ETrue;
       
  2174         }
       
  2175 
       
  2176     CleanupStack::PopAndDestroy( conflictCheckker );
       
  2177     CleanupStack::PopAndDestroy(); // entries
       
  2178 
       
  2179     return retValue;
       
  2180     }
       
  2181 
       
  2182 // ---------------------------------------------------------------------------
       
  2183 // CESMRMeetingRequestEntry::GetFirstInstanceStartAndEndTimeL
       
  2184 // ---------------------------------------------------------------------------
       
  2185 //
       
  2186 void CESMRMeetingRequestEntry::GetFirstInstanceStartAndEndTimeL(
       
  2187             TTime& aStart,
       
  2188             TTime& aEnd )
       
  2189     {
       
  2190     FUNC_LOG;
       
  2191 
       
  2192     __ASSERT_DEBUG( iEntry, Panic(EESMREntryNotExist ) );
       
  2193 
       
  2194     // This fetches the parent entry
       
  2195     TCalTime recurrenceId;
       
  2196     recurrenceId.SetTimeLocalL( Time::NullTTime() );
       
  2197     CCalEntry* parent = iCalDb.FetchEntryL(
       
  2198                 iEntry->UidL(),
       
  2199                 recurrenceId );
       
  2200 
       
  2201     CleanupStack::PushL( parent );
       
  2202 
       
  2203     aStart = parent->StartTimeL().TimeLocalL();
       
  2204     aEnd = parent->EndTimeL().TimeLocalL();
       
  2205 
       
  2206     CleanupStack::PopAndDestroy( parent );
       
  2207     }
       
  2208 
       
  2209 // ---------------------------------------------------------------------------
       
  2210 // CESMRMeetingRequestEntry::CalendarOwnerAddressL
       
  2211 // ---------------------------------------------------------------------------
       
  2212 //
       
  2213 const TDesC& CESMRMeetingRequestEntry::CalendarOwnerAddressL() const
       
  2214     {
       
  2215     FUNC_LOG;
       
  2216 
       
  2217     __ASSERT_DEBUG( iEntry, Panic( EESMREntryNotExist ) );
       
  2218 
       
  2219     CCalUser* po = iEntry->PhoneOwnerL();
       
  2220 
       
  2221     __ASSERT_DEBUG( po, Panic( EESMRPhoneOwnerNotSet ) );
       
  2222 
       
  2223     return po->Address();
       
  2224     }
       
  2225 
       
  2226 // ---------------------------------------------------------------------------
       
  2227 // CESMRMeetingRequestEntry::MailboxUtils
       
  2228 // ---------------------------------------------------------------------------
       
  2229 //
       
  2230 CMRMailboxUtils& CESMRMeetingRequestEntry::MailboxUtils() const
       
  2231     {
       
  2232     return iMRMailboxUtils;
       
  2233     }
       
  2234 
       
  2235 // ---------------------------------------------------------------------------
       
  2236 // CESMRMeetingRequestEntry::GetDBMgr
       
  2237 // ---------------------------------------------------------------------------
       
  2238 //
       
  2239 MESMRCalDbMgr& CESMRMeetingRequestEntry::GetDBMgr()
       
  2240     {
       
  2241     return iCalDb;
       
  2242     }
       
  2243 
       
  2244 // ---------------------------------------------------------------------------
       
  2245 // CESMRMeetingRequestEntry::SupportsCapabilityL
       
  2246 // ---------------------------------------------------------------------------
       
  2247 //
       
  2248 TBool CESMRMeetingRequestEntry::SupportsCapabilityL( 
       
  2249         MESMRCalEntry::TMREntryCapability aCapability ) const
       
  2250     {
  2141     TBool retValue( EFalse );
  2251     TBool retValue( EFalse );
  2142     
  2252     
  2143     RCPointerArray<CCalEntry> entries;
  2253     switch( aCapability )
  2144     CleanupClosePushL( entries );
  2254         {
  2145     
  2255         case MESMRCalEntry::EMRCapabilityAttachments:
  2146     CESMRConflictChecker* conflictCheckker = 
  2256             {
  2147         CESMRConflictChecker::NewL( iCalDb );
  2257             CESMRFsMailboxUtils* fsMbUtils =
  2148     CleanupStack::PushL( conflictCheckker );    
  2258                     CESMRFsMailboxUtils::NewL( iMRMailboxUtils );
  2149     
  2259             CleanupStack::PushL( fsMbUtils );
  2150     conflictCheckker->FindInstancesForEntryL( aStart, 
  2260 
  2151                                               aEnd,
  2261             retValue = fsMbUtils->DefaultMailboxSupportCapabilityL(
  2152                                               *iEntry,
  2262                     CESMRFsMailboxUtils::EMRCapabilityAttachment );
  2153                                               entries );
  2263             CleanupStack::PopAndDestroy( fsMbUtils );        
  2154     
  2264             }
  2155     if ( entries.Count() )
  2265             break;
  2156         {
  2266         }
  2157         retValue = ETrue;
       
  2158         }    
       
  2159     
       
  2160     CleanupStack::PopAndDestroy( conflictCheckker );
       
  2161     CleanupStack::PopAndDestroy(); // entries
       
  2162     
  2267     
  2163     return retValue;
  2268     return retValue;
  2164     }
  2269     }
  2165 
  2270 
       
  2271 // ---------------------------------------------------------------------------
       
  2272 // CESMRMeetingRequestEntry::ContainsRemoteAttachmentsL
       
  2273 // ---------------------------------------------------------------------------
       
  2274 //
       
  2275 TBool CESMRMeetingRequestEntry::ContainsRemoteAttachmentsL()
       
  2276     {
       
  2277     FUNC_LOG;
       
  2278     
       
  2279     TBool retValue( EFalse );
       
  2280     
       
  2281     TInt attachmentCount( iEntry->AttachmentCountL() );
       
  2282     
       
  2283     for ( TInt i(0); i < attachmentCount && !retValue; ++i )
       
  2284         {
       
  2285         CCalAttachment* attachment = iEntry->AttachmentL(i);        
       
  2286         CCalAttachment::TType type( attachment->Type() );
       
  2287         
       
  2288         if ( CCalAttachment::EFile != type )
       
  2289             {
       
  2290             retValue = ETrue;
       
  2291             }        
       
  2292         }
       
  2293     
       
  2294     return retValue;
       
  2295     }
       
  2296 
       
  2297 // ---------------------------------------------------------------------------
       
  2298 // CESMRMeetingRequestEntry::SendCanellationAvailable
       
  2299 // ---------------------------------------------------------------------------
       
  2300 //
       
  2301 TBool CESMRMeetingRequestEntry::SendCanellationAvailable ()
       
  2302 	{
       
  2303 	return iSendCanellation;
       
  2304 	}
       
  2305 
       
  2306 // ---------------------------------------------------------------------------
       
  2307 // CESMRMeetingRequestEntry::SetSendCanellationAvailable
       
  2308 // ---------------------------------------------------------------------------
       
  2309 //
       
  2310 void CESMRMeetingRequestEntry::SetSendCanellationAvailable (
       
  2311         TBool aSendCanellation )
       
  2312 	{
       
  2313 	iSendCanellation = aSendCanellation;
       
  2314 	}
       
  2315 
       
  2316 // ---------------------------------------------------------------------------
       
  2317 // CESMRMeetingRequestEntry::SetTypeChanged
       
  2318 // ---------------------------------------------------------------------------
       
  2319 //
       
  2320 void CESMRMeetingRequestEntry::SetTypeChanged( TBool aTypeChanged )
       
  2321     {
       
  2322     FUNC_LOG;
       
  2323     
       
  2324     iTypeChanged = aTypeChanged;
       
  2325     }
       
  2326 
  2166 // EOF
  2327 // EOF
  2167