meetingrequest/mrentry/src/cesmrmeetingrequestentry.cpp
branchRCL_3
changeset 64 3533d4323edc
equal deleted inserted replaced
63:d189ee25cf9d 64:3533d4323edc
       
     1 /*
       
     2 * Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description:  ESMR MR Entry implementation
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 // INCLUDE FILES
       
    20 #include "cesmrmeetingrequestentry.h"
       
    21 #include "cesmrfsmailboxutils.h"
       
    22 #include "cesmrcaldbmgr.h"
       
    23 #include "esmrhelper.h"
       
    24 #include "esmrentryhelper.h"
       
    25 #include "cesmrconflictchecker.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 
       
    34 #include "esmrconfig.hrh"
       
    35 #include "cesmrfeaturesettings.h"
       
    36 
       
    37 #include "emailtrace.h"
       
    38 
       
    39 #include <esmralarminfo.rsg>
       
    40 #include <calentry.h>
       
    41 #include <calinstance.h>
       
    42 #include <calinstanceview.h>
       
    43 #include <caluser.h>
       
    44 #include <calattachment.h>
       
    45 #include <CalenInterimUtils2.h>
       
    46 #include <cmrmailboxutils.h>
       
    47 #include <calrrule.h>
       
    48 #include <centralrepository.h>
       
    49 #include <calalarm.h>
       
    50 #include <CalendarInternalCRKeys.h>
       
    51 #include <data_caging_path_literals.hrh>
       
    52 #include <coemain.h>
       
    53 #include <calentryview.h>
       
    54 #include <ct/rcpointerarray.h>
       
    55 #include <apmstd.h>
       
    56 #include <apgcli.h>
       
    57 #include <apmrec.h>
       
    58 
       
    59 /// Unnamed namespace for local definitions
       
    60 namespace {
       
    61 
       
    62 // Alarm resource file location
       
    63 _LIT( KAlarmInfoResource, "esmralarminfo.rsc" );
       
    64 
       
    65 // Definition for default alarm time for meeting
       
    66 const TInt KDefaultMeetingAlarmMinutes( 15 );
       
    67 
       
    68 _LIT( KReplaceLineFeedChar, "\n" );
       
    69 _LIT( KLineFeed, "\x2029");
       
    70 
       
    71 /**
       
    72  * Sets phone owner to entry.
       
    73  * @param aMbUtils Reference to mailbox utils.
       
    74  * @param aEntry Reference to calendar entry.
       
    75  */
       
    76 void SetPhoneOwnerL(
       
    77         CMRMailboxUtils& aMbUtils,
       
    78         CCalEntry& aEntry )
       
    79     {
       
    80     CESMRFsMailboxUtils* fsMbUtils =
       
    81             CESMRFsMailboxUtils::NewL( aMbUtils );
       
    82     CleanupStack::PushL( fsMbUtils );
       
    83 
       
    84     fsMbUtils->SetPhoneOwnerL( aEntry );
       
    85     CleanupStack::PopAndDestroy( fsMbUtils );
       
    86     fsMbUtils = NULL;
       
    87     }
       
    88 
       
    89 /**
       
    90  * Makes copy of the entry and sets phone owner accordingly
       
    91  * @param aMbUtils Reference to mailbox utils.
       
    92  * @param aEntry Reference to calendar entry.
       
    93  */
       
    94 CCalEntry* CopyEntryL(
       
    95         CMRMailboxUtils& aMbUtils,
       
    96         const CCalEntry& aEntry )
       
    97     {
       
    98     CCalEntry* entry = ESMRHelper::CopyEntryL(
       
    99                             aEntry,
       
   100                             aEntry.MethodL(),
       
   101                             ESMRHelper::ECopyFull,
       
   102                             EESMREventTypeMeetingRequest );
       
   103 
       
   104     SetPhoneOwnerL( aMbUtils, *entry );
       
   105 
       
   106     return entry;
       
   107     }
       
   108 
       
   109 #ifdef _DEBUG
       
   110 
       
   111 // Definition for panic text
       
   112 _LIT( KESMREntryPanicTxt, "ESMRMeetingRequestEntry" );
       
   113 
       
   114 /**
       
   115  * ES MR Entry panic codes
       
   116  */
       
   117 enum TESMRMeetingRequestEntry
       
   118     {
       
   119     EESMREntryNotExist = 1, // Entry does not exist
       
   120     EESMRInvalidRole,       // Phone owner has invalid role
       
   121     EESMRNoInfoObjectAttendeeFound,
       
   122     EESMRPhoneOwnerNotSet,
       
   123     EESMRRecurrenceError,
       
   124     EESMRInvalidReplyType,
       
   125     EESMRInvalidInvalidAttendeeStatus,
       
   126     EESMRParentNotFound
       
   127     };
       
   128 
       
   129 /**
       
   130  * Raises panic.
       
   131  * @param aPanic Panic code
       
   132  */
       
   133 void Panic(TESMRMeetingRequestEntry aPanic)
       
   134     {
       
   135     User::Panic( KESMREntryPanicTxt, aPanic);
       
   136     }
       
   137 
       
   138 #endif // _DEBUG
       
   139 
       
   140 }  // namespace
       
   141 
       
   142 // ======== MEMBER FUNCTIONS ========
       
   143 
       
   144 // ---------------------------------------------------------------------------
       
   145 // CESMRMeetingRequestEntry::CESMRMeetingRequestEntry
       
   146 // ---------------------------------------------------------------------------
       
   147 //
       
   148 inline CESMRMeetingRequestEntry::CESMRMeetingRequestEntry(
       
   149         CMRMailboxUtils& aMRMailboxUtils,
       
   150         MESMRCalDbMgr& aCalDb,
       
   151         TBool aConflictsExists,
       
   152         TESMRInputParams* aESMRInputParams )
       
   153 :   iMRMailboxUtils( aMRMailboxUtils ),
       
   154     iConflictsExists( aConflictsExists),
       
   155     iCalDb( aCalDb ),
       
   156     iESMRInputParams( aESMRInputParams ),
       
   157     iSendCanellation( ETrue )
       
   158     {
       
   159     FUNC_LOG;
       
   160     // Not yet implementation
       
   161     }
       
   162 
       
   163 // ---------------------------------------------------------------------------
       
   164 // CESMRMeetingRequestEntry::~CESMRMeetingRequestEntry
       
   165 // ---------------------------------------------------------------------------
       
   166 //
       
   167 EXPORT_C CESMRMeetingRequestEntry::~CESMRMeetingRequestEntry()
       
   168     {
       
   169     FUNC_LOG;
       
   170     delete iEntry;
       
   171     delete iForwardEntry;
       
   172     delete iOrginalEntry;
       
   173     delete iParameterEntry;
       
   174     }
       
   175 
       
   176 // ---------------------------------------------------------------------------
       
   177 // CESMRMeetingRequestEntry::NewL
       
   178 // ---------------------------------------------------------------------------
       
   179 //
       
   180 EXPORT_C CESMRMeetingRequestEntry* CESMRMeetingRequestEntry::NewL(
       
   181         const CCalEntry& aEntry,
       
   182         CMRMailboxUtils& aMRMailboxUtils,
       
   183         MESMRCalDbMgr& aCalDb,
       
   184         TBool aConflictsExists,
       
   185         TESMRInputParams* aESMRInputParams )
       
   186     {
       
   187     FUNC_LOG;
       
   188 
       
   189     CESMRMeetingRequestEntry* self =
       
   190             new (ELeave) CESMRMeetingRequestEntry(
       
   191                 aMRMailboxUtils,
       
   192                 aCalDb,
       
   193                 aConflictsExists,
       
   194                 aESMRInputParams );
       
   195 
       
   196     CleanupStack::PushL( self );
       
   197     self->ConstructL( aEntry );
       
   198     CleanupStack::Pop( self );
       
   199 
       
   200     return self;
       
   201     }
       
   202 
       
   203 // ---------------------------------------------------------------------------
       
   204 // CESMRMeetingRequestEntry::ConstructL
       
   205 // ---------------------------------------------------------------------------
       
   206 //
       
   207 void CESMRMeetingRequestEntry::ConstructL(
       
   208         const CCalEntry& aEntry )
       
   209     {
       
   210     FUNC_LOG;
       
   211 
       
   212     iParameterEntry = CopyEntryL( iMRMailboxUtils, aEntry );
       
   213     iEntry = CopyEntryL( iMRMailboxUtils, aEntry );
       
   214 
       
   215     iOrginalEntry  = CopyEntryL( iMRMailboxUtils, aEntry );
       
   216 
       
   217     if ( EESMRRoleOrganizer == RoleL() && IsStoredL() )
       
   218         {
       
   219         // Increase sequence number
       
   220         TInt seqNo( iEntry->SequenceNumberL() + 1);
       
   221         iEntry->SetSequenceNumberL( seqNo );
       
   222         iOrginalEntry->SetSequenceNumberL( seqNo );
       
   223         }
       
   224 
       
   225 
       
   226     CCalEntry::TMethod method( iEntry->MethodL() );
       
   227 
       
   228     if ( CCalEntry::EMethodNone == method )
       
   229         {
       
   230         iEntry->SetMethodL( CCalEntry::EMethodRequest );
       
   231         iOrginalEntry->SetMethodL( CCalEntry::EMethodRequest );
       
   232         }
       
   233 
       
   234     HBufC* newDescription = ReplaceCharactersFromBufferLC(
       
   235                                     iEntry->DescriptionL(),
       
   236                                     KReplaceLineFeedChar(),
       
   237                                     KLineFeed() );
       
   238     iEntry->SetDescriptionL( *newDescription );
       
   239     iOrginalEntry->SetDescriptionL( *newDescription );
       
   240 
       
   241     CleanupStack::PopAndDestroy( newDescription );
       
   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;
       
   254 
       
   255     if ( CurrentPluginL() == EESMRActiveSync )
       
   256         {
       
   257         // Set correct calendar database
       
   258         SetDefaultDatabaseL();
       
   259         }
       
   260     }
       
   261 
       
   262 // ---------------------------------------------------------------------------
       
   263 // CESMRMeetingRequestEntry::ReplaceCharactersFromBufferL
       
   264 // ---------------------------------------------------------------------------
       
   265 //
       
   266 HBufC* CESMRMeetingRequestEntry::ReplaceCharactersFromBufferLC( const TDesC& aTarget,
       
   267                               const TDesC& aFindString,
       
   268                               const TDesC& aReplacement )
       
   269     {
       
   270     FUNC_LOG;
       
   271     HBufC* newBuffer = aTarget.AllocLC();
       
   272     TPtr16 ptr = newBuffer->Des();
       
   273 
       
   274     // find next occurance:
       
   275     TInt offset = ptr.Find(aFindString);
       
   276     while ( offset != KErrNotFound )
       
   277         {
       
   278         // replace the data:
       
   279         ptr.Replace( offset, aFindString.Length(), aReplacement);
       
   280 
       
   281         // find next occurance:
       
   282         offset = ptr.Find(aFindString);
       
   283         }
       
   284 
       
   285     return newBuffer;
       
   286     }
       
   287 
       
   288 // ---------------------------------------------------------------------------
       
   289 // CESMRMeetingRequestEntry::Type
       
   290 // ---------------------------------------------------------------------------
       
   291 //
       
   292 MESMRCalEntry::TESMRCalEntryType CESMRMeetingRequestEntry::Type() const
       
   293     {
       
   294     FUNC_LOG;
       
   295     // This is meeting request
       
   296     return MESMRCalEntry::EESMRCalEntryMeetingRequest;
       
   297     }
       
   298 
       
   299 // ---------------------------------------------------------------------------
       
   300 // CESMRMeetingRequestEntry::MESMRCalEntryRef
       
   301 // ---------------------------------------------------------------------------
       
   302 //
       
   303 MESMRCalEntry& CESMRMeetingRequestEntry::MESMRCalEntryRef()
       
   304     {
       
   305     FUNC_LOG;
       
   306     return *this;
       
   307     }
       
   308 
       
   309 // ---------------------------------------------------------------------------
       
   310 // CESMRMeetingRequestEntry::MESMRCalEntryRef
       
   311 // ---------------------------------------------------------------------------
       
   312 //
       
   313 const MESMRCalEntry& CESMRMeetingRequestEntry::MESMRCalEntryRef() const
       
   314     {
       
   315     FUNC_LOG;
       
   316     return *this;
       
   317     }
       
   318 // ---------------------------------------------------------------------------
       
   319 // CESMRMeetingRequestEntry::Entry
       
   320 // ---------------------------------------------------------------------------
       
   321 //
       
   322 CCalEntry& CESMRMeetingRequestEntry::Entry()
       
   323     {
       
   324     FUNC_LOG;
       
   325     __ASSERT_DEBUG( iEntry, Panic(EESMREntryNotExist ) );
       
   326 
       
   327     if ( iForwardEntry )
       
   328         {
       
   329         return *iForwardEntry;
       
   330         }
       
   331 
       
   332     return *iEntry;
       
   333     }
       
   334 
       
   335 // ---------------------------------------------------------------------------
       
   336 // CESMRMeetingRequestEntry::Entry
       
   337 // ---------------------------------------------------------------------------
       
   338 //
       
   339 const CCalEntry& CESMRMeetingRequestEntry::Entry() const
       
   340     {
       
   341     FUNC_LOG;
       
   342     __ASSERT_DEBUG( iEntry, Panic(EESMREntryNotExist ) );
       
   343     if ( iForwardEntry )
       
   344         {
       
   345         return *iForwardEntry;
       
   346         }
       
   347     return *iEntry;
       
   348     }
       
   349 
       
   350 // ---------------------------------------------------------------------------
       
   351 // CESMRMeetingRequestEntry::InstanceL
       
   352 // ---------------------------------------------------------------------------
       
   353 //
       
   354 CCalInstance* CESMRMeetingRequestEntry::InstanceL() const
       
   355     {
       
   356     FUNC_LOG;
       
   357 
       
   358     __ASSERT_DEBUG( iEntry, Panic(EESMREntryNotExist ) );
       
   359     __ASSERT_DEBUG( iOrginalEntry, Panic(EESMREntryNotExist ) );
       
   360 
       
   361     CCalInstance* instance = NULL;
       
   362 
       
   363     instance = iCalDb.FindInstanceL( *iEntry );
       
   364     if ( !instance )
       
   365         {
       
   366         // Instance not found by using the edited entry
       
   367         // Trying with orginal.
       
   368         instance = iCalDb.FindInstanceL( *iOrginalEntry );
       
   369         }
       
   370 
       
   371     if ( !instance )
       
   372         {
       
   373         // Instance not found by using edited or orginal entry.
       
   374         // --> Leave
       
   375         User::Leave( KErrNotFound );
       
   376         }
       
   377 
       
   378     return instance;
       
   379     }
       
   380 
       
   381 // ---------------------------------------------------------------------------
       
   382 // CESMRMeetingRequestEntry::CanSetRecurrenceL
       
   383 // ---------------------------------------------------------------------------
       
   384 //
       
   385 TBool CESMRMeetingRequestEntry::CanSetRecurrenceL() const
       
   386     {
       
   387     FUNC_LOG;
       
   388 
       
   389     __ASSERT_DEBUG( iEntry, Panic(EESMREntryNotExist ) );
       
   390 
       
   391     TBool canSetRecurrence( ETrue );
       
   392 
       
   393     if ( iEntry->EntryTypeL() == CCalEntry::EAppt &&
       
   394             ESMREntryHelper::IsRepeatingMeetingL(*iEntry) &&
       
   395         (!ESMREntryHelper::IsModifyingEntryL(*iEntry) &&
       
   396           MESMRCalEntry::EESMRThisOnly == iRecurrenceModRule ))
       
   397         {
       
   398         canSetRecurrence = EFalse;
       
   399         }
       
   400 
       
   401 
       
   402     return canSetRecurrence;
       
   403     }
       
   404 
       
   405 // ---------------------------------------------------------------------------
       
   406 // CESMRMeetingRequestEntry::IsRecurrentEventL
       
   407 // ---------------------------------------------------------------------------
       
   408 //
       
   409 TBool CESMRMeetingRequestEntry::IsRecurrentEventL() const
       
   410     {
       
   411     FUNC_LOG;
       
   412 
       
   413     __ASSERT_DEBUG( iEntry, Panic(EESMREntryNotExist ) );
       
   414 
       
   415     TBool recurrenceEvent( EFalse );
       
   416     if ( IsStoredL() )
       
   417         {
       
   418         // Entry is stored in calendar db
       
   419         // Lets look recurrence using instance
       
   420 
       
   421         // Ownership is transferred
       
   422         CCalInstance* instance = NULL;
       
   423         TRAPD(err, instance = InstanceL() );
       
   424         if ( KErrNotFound != err )
       
   425             {
       
   426             User::LeaveIfError( err );
       
   427             }
       
   428 
       
   429         if ( instance )
       
   430             {
       
   431             CleanupStack::PushL( instance );
       
   432 
       
   433             CCalEntry& instanceParentEntry = instance->Entry();
       
   434 
       
   435             if ( ESMREntryHelper::IsRepeatingMeetingL( instanceParentEntry ) )
       
   436                 {
       
   437                 recurrenceEvent = ETrue;
       
   438                 }
       
   439             CleanupStack::PopAndDestroy( instance );
       
   440             }
       
   441         else if ( ESMREntryHelper::IsRepeatingMeetingL( *iEntry ) )
       
   442             {
       
   443             recurrenceEvent = ETrue;
       
   444             }
       
   445         }
       
   446     else
       
   447         {
       
   448         // Entry is not stored in calendar db
       
   449         if ( ESMREntryHelper::IsRepeatingMeetingL( *iEntry ) )
       
   450             {
       
   451             // This is repeating meeting
       
   452             recurrenceEvent = ETrue;
       
   453             }
       
   454         }
       
   455 
       
   456 
       
   457     return recurrenceEvent;
       
   458     }
       
   459 
       
   460 // ---------------------------------------------------------------------------
       
   461 // CESMRMeetingRequestEntry::SetRecurrenceL
       
   462 //
       
   463 // ---------------------------------------------------------------------------
       
   464 //
       
   465 void CESMRMeetingRequestEntry::SetRecurrenceL(
       
   466         TESMRRecurrenceValue aRecurrence,
       
   467         TTime aUntil )
       
   468     {
       
   469     FUNC_LOG;
       
   470 
       
   471     __ASSERT_DEBUG( iEntry, Panic(EESMREntryNotExist ) );
       
   472 
       
   473     // Check if this entry's recurrence can be edited
       
   474     if ( !CanSetRecurrenceL() )
       
   475         {
       
   476         User::Leave( KErrNotSupported );
       
   477         }
       
   478 
       
   479     if ( aRecurrence != ERecurrenceNot &&
       
   480             MESMRCalEntry::EESMRAllInSeries != iRecurrenceModRule )
       
   481         {
       
   482         // Make sure that mod rule is correct
       
   483         SetModifyingRuleL(
       
   484                 MESMRCalEntry::EESMRAllInSeries );
       
   485         }
       
   486 
       
   487     CESMRRecurrenceInfoHandler* recurrenceHandler =
       
   488             CESMRRecurrenceInfoHandler::NewLC( *iEntry );
       
   489 
       
   490     recurrenceHandler->SetRecurrenceL( aRecurrence, aUntil );
       
   491 
       
   492     CleanupStack::PopAndDestroy( recurrenceHandler );
       
   493 
       
   494     }
       
   495 
       
   496 // ---------------------------------------------------------------------------
       
   497 // CESMRMeetingRequestEntry::GetRecurrenceL
       
   498 //
       
   499 // ---------------------------------------------------------------------------
       
   500 //
       
   501 void CESMRMeetingRequestEntry::GetRecurrenceL(
       
   502         TESMRRecurrenceValue& aRecurrence,
       
   503         TTime& aUntil) const
       
   504     {
       
   505     FUNC_LOG;
       
   506 
       
   507     __ASSERT_DEBUG( iEntry, Panic(EESMREntryNotExist ) );
       
   508 
       
   509     CESMRRecurrenceInfoHandler* recurrenceHandler =
       
   510             CESMRRecurrenceInfoHandler::NewLC( *iEntry, &iCalDb );
       
   511 
       
   512     recurrenceHandler->GetRecurrenceL( aRecurrence, aUntil );
       
   513     CleanupStack::PopAndDestroy( recurrenceHandler );
       
   514     }
       
   515 
       
   516 // ---------------------------------------------------------------------------
       
   517 // CESMRMeetingRequestEntry::RecurrenceModRule
       
   518 // ---------------------------------------------------------------------------
       
   519 //
       
   520 MESMRCalEntry::TESMRRecurrenceModifyingRule
       
   521     CESMRMeetingRequestEntry::RecurrenceModRule() const
       
   522     {
       
   523     return iRecurrenceModRule;
       
   524     }
       
   525 
       
   526 // ---------------------------------------------------------------------------
       
   527 // CESMRMeetingRequestEntry::SetModifyingRuleL
       
   528 // ---------------------------------------------------------------------------
       
   529 //
       
   530 void CESMRMeetingRequestEntry::SetModifyingRuleL(
       
   531         TESMRRecurrenceModifyingRule aRule, const TBool aTypeChanging )
       
   532     {
       
   533     FUNC_LOG;
       
   534 
       
   535     __ASSERT_DEBUG( iEntry, Panic(EESMREntryNotExist ) );
       
   536 
       
   537     CESMRRecurrenceInfoHandler* recHandler =
       
   538             CESMRRecurrenceInfoHandler::NewL( *iOrginalEntry );
       
   539     CleanupStack::PushL( recHandler );
       
   540 
       
   541     TESMRRecurrenceValue orginalRecurrence;
       
   542     TTime orginalUntil;
       
   543 
       
   544     recHandler->GetRecurrenceL(
       
   545             orginalRecurrence,
       
   546             orginalUntil);
       
   547     CleanupStack::PopAndDestroy( recHandler );
       
   548     recHandler = NULL;
       
   549 
       
   550     TBool modifyingEntry( ESMREntryHelper::IsModifyingEntryL( *iEntry ) );
       
   551 
       
   552     if ( MESMRCalEntry::EESMRAllInSeries == aRule &&
       
   553          IsStoredL() && !IsForwardedL() && !IsOpenedFromMail() && !aTypeChanging )
       
   554         {
       
   555         // When we want to modify series of recurrence entries -->
       
   556         // Parent entry is modified
       
   557         if ( ERecurrenceNot == orginalRecurrence && !modifyingEntry )
       
   558             {
       
   559             // Orginal entry was not recurrent event
       
   560             // No need to fect instance at all
       
   561             // For modifying entries we need to fetch the original parent entry
       
   562             iRecurrenceModRule = aRule;
       
   563             return;
       
   564             }
       
   565 
       
   566         CCalInstance* instance = NULL;
       
   567         TRAPD(err, instance = InstanceL() );
       
   568         if( KErrNotFound != err )
       
   569             {
       
   570             User::LeaveIfError( err );
       
   571             }
       
   572 
       
   573         if ( instance )
       
   574             {
       
   575             CleanupStack::PushL( instance );
       
   576 
       
   577             CCalEntry::TMethod entryMethod( iEntry->MethodL() );
       
   578 
       
   579             delete iEntry;
       
   580             iEntry = NULL;
       
   581 
       
   582             delete iForwardEntry;
       
   583             iForwardEntry = NULL;
       
   584 
       
   585             delete iOrginalEntry;
       
   586             iOrginalEntry = NULL;
       
   587 
       
   588             RCPointerArray<CCalEntry> entries;
       
   589             CleanupClosePushL( entries );
       
   590 
       
   591             iCalDb.EntryViewL( instance->Entry() )->FetchL(
       
   592                     instance->Entry().UidL(), entries );
       
   593 
       
   594             TInt parentIndex( KErrNotFound );
       
   595             TInt entryCount( entries.Count() );
       
   596             for ( TInt i(0); i < entryCount && KErrNotFound == parentIndex; ++i )
       
   597                 {
       
   598                 TBool modifyingEntry( ESMREntryHelper::IsModifyingEntryL( *entries[i]) );
       
   599                 if ( !modifyingEntry )
       
   600                     {
       
   601                     parentIndex = i;
       
   602                     }
       
   603                 }
       
   604 
       
   605             __ASSERT_DEBUG( KErrNotFound != parentIndex, Panic(EESMRParentNotFound) );
       
   606 
       
   607             CCalEntry& parent = *entries[parentIndex];
       
   608 
       
   609             TPtrC description( parent.DescriptionL() );
       
   610 
       
   611             iEntry = CopyEntryL( iMRMailboxUtils, parent );
       
   612 
       
   613             // Adjust parent entry's start and end time to entry
       
   614             TCalTime start;
       
   615             TCalTime end;
       
   616 
       
   617             CESMRRecurrenceInfoHandler* recurrenceHandler =
       
   618                     CESMRRecurrenceInfoHandler::NewLC( parent );
       
   619 
       
   620             recurrenceHandler->GetFirstInstanceTimeL( start, end );
       
   621             CleanupStack::PopAndDestroy( recurrenceHandler );
       
   622             recurrenceHandler = NULL;
       
   623 
       
   624             iEntry->SetStartAndEndTimeL( start, end );
       
   625 
       
   626             iOrginalEntry = CopyEntryL( iMRMailboxUtils, *iEntry );
       
   627 
       
   628             if ( iEntry->MethodL() != entryMethod )
       
   629                 {
       
   630                 iEntry->SetMethodL( entryMethod );
       
   631                 iOrginalEntry->SetMethodL( entryMethod );
       
   632                 }
       
   633 
       
   634             iEntry->SetDescriptionL( description );
       
   635             iOrginalEntry->SetDescriptionL( description );
       
   636 
       
   637             CleanupStack::PopAndDestroy(); // entries
       
   638             CleanupStack::PopAndDestroy( instance );
       
   639 
       
   640             if ( EESMRRoleOrganizer == RoleL() && IsStoredL() )
       
   641                 {
       
   642                 // Increase sequence number
       
   643                 TInt seqNo( iEntry->SequenceNumberL() + 1);
       
   644                 iEntry->SetSequenceNumberL( seqNo );
       
   645                 iOrginalEntry->SetSequenceNumberL( seqNo );
       
   646                 }
       
   647             }
       
   648         }
       
   649     else if ( ERecurrenceNot != orginalRecurrence &&
       
   650     		aTypeChanging && !modifyingEntry )
       
   651     	{
       
   652 		// if entry( in the memory) is a recurrent event
       
   653 		// ,and if entry type is changing, and not in modifying status then EESMRAllInSeries
       
   654 		iRecurrenceModRule = EESMRAllInSeries ;
       
   655 		return;
       
   656     	}
       
   657 
       
   658     iRecurrenceModRule = aRule;
       
   659 
       
   660     }
       
   661 
       
   662 // ---------------------------------------------------------------------------
       
   663 // CESMRMeetingRequestEntry::SetAllDayEventL
       
   664 //
       
   665 // ---------------------------------------------------------------------------
       
   666 //
       
   667 void CESMRMeetingRequestEntry::SetAllDayEventL(
       
   668         TTime aStartDate,
       
   669         TTime aEndDate )
       
   670     {
       
   671     FUNC_LOG;
       
   672 
       
   673     __ASSERT_DEBUG( iEntry, Panic(EESMREntryNotExist ) );
       
   674 
       
   675     TCalTime startTime;
       
   676     TCalTime stopTime;
       
   677 
       
   678     TDateTime start;
       
   679     TDateTime end;
       
   680 
       
   681     // set the start time to 0:00
       
   682     start.Set( aStartDate.DateTime().Year(),
       
   683                aStartDate.DateTime().Month(),
       
   684                aStartDate.DateTime().Day(),
       
   685                0,
       
   686                0,
       
   687                0,
       
   688                0);
       
   689 
       
   690     // set the end date to next day from given end date since
       
   691     // all day event should last 24 hours.
       
   692     TTime endDate = aEndDate + TTimeIntervalDays( 1 );
       
   693     end.Set( endDate.DateTime().Year(),
       
   694              endDate.DateTime().Month(),
       
   695              endDate.DateTime().Day(),
       
   696              0,
       
   697              0,
       
   698              0,
       
   699              0 );
       
   700 
       
   701     startTime.SetTimeLocalL( start );
       
   702     stopTime.SetTimeLocalL( end );
       
   703 
       
   704     iEntry->SetStartAndEndTimeL( startTime, stopTime );
       
   705 
       
   706     }
       
   707 
       
   708 // ---------------------------------------------------------------------------
       
   709 // CESMRMeetingRequestEntry::IsAllDayEventL
       
   710 //
       
   711 // ---------------------------------------------------------------------------
       
   712 //
       
   713 TBool CESMRMeetingRequestEntry::IsAllDayEventL() const
       
   714     {
       
   715     FUNC_LOG;
       
   716 
       
   717     __ASSERT_DEBUG( iEntry, Panic(EESMREntryNotExist ) );
       
   718 
       
   719     CESMRCalUserUtil* entryUtil = CESMRCalUserUtil::NewLC( *iEntry );
       
   720 
       
   721     TBool allDayEvent( entryUtil->IsAlldayEventL() );
       
   722 
       
   723     CleanupStack::PopAndDestroy( entryUtil );
       
   724 
       
   725     return allDayEvent;
       
   726     }
       
   727 
       
   728 // ---------------------------------------------------------------------------
       
   729 // CESMRMeetingRequestEntry::IsStoredL
       
   730 // ---------------------------------------------------------------------------
       
   731 //
       
   732 TBool CESMRMeetingRequestEntry::IsStoredL() const
       
   733     {
       
   734     FUNC_LOG;
       
   735 
       
   736     __ASSERT_DEBUG( iEntry, Panic(EESMREntryNotExist ) );
       
   737 
       
   738     TBool ret(EFalse);
       
   739     CCalEntry* dbEntry = NULL;
       
   740 
       
   741     TRAPD( err, dbEntry = iCalDb.FetchEntryL(
       
   742                                 iEntry->UidL(),
       
   743                                 iEntry->RecurrenceIdL() ) );
       
   744 
       
   745     if ( KErrNotFound == err )
       
   746         {
       
   747         // Error has occured while retrieving an entry
       
   748         ret = EFalse;
       
   749         }
       
   750     else if ( dbEntry)
       
   751         {
       
   752         // Entry was found from the calendar db --> it is stored for sure.
       
   753         ret = ETrue;
       
   754         }
       
   755 
       
   756     delete dbEntry;
       
   757 
       
   758 
       
   759     return ret;
       
   760     }
       
   761 
       
   762 // ---------------------------------------------------------------------------
       
   763 // CESMRMeetingRequestEntry::IsSentL
       
   764 // ---------------------------------------------------------------------------
       
   765 //
       
   766 TBool CESMRMeetingRequestEntry::IsSentL() const
       
   767     {
       
   768     FUNC_LOG;
       
   769 
       
   770     __ASSERT_DEBUG( iOrginalEntry, Panic(EESMREntryNotExist ) );
       
   771 
       
   772     TBool retVal( EFalse );
       
   773 
       
   774     if ( EESMRRoleOrganizer == RoleL()  )
       
   775         {
       
   776         CCalEntry::TStatus status( iOrginalEntry->StatusL() );
       
   777         if ( CCalEntry::ENullStatus != status )
       
   778             { // When we send a request for the first time we set
       
   779               // it's status to some other value than ENullStatus
       
   780             retVal = ETrue;
       
   781             }
       
   782         }
       
   783     else
       
   784         {
       
   785         // In attendee mode, we have sent the entry, if it is stored to
       
   786         // calendar db and status is known and not declined.
       
   787         // Declined entries are not stored to calendar db.
       
   788         TESMRAttendeeStatus currentStatus( AttendeeStatusL() );
       
   789         if ( IsStoredL()
       
   790              && EESMRAttendeeStatusUnknown != currentStatus
       
   791              && EESMRAttendeeStatusDecline != currentStatus )
       
   792             {
       
   793             retVal = ETrue;
       
   794             }
       
   795         }
       
   796 
       
   797 
       
   798     return retVal;
       
   799     }
       
   800 
       
   801 // ---------------------------------------------------------------------------
       
   802 // CESMRMeetingRequestEntry::IsEntryEditedL
       
   803 //
       
   804 // ---------------------------------------------------------------------------
       
   805 //
       
   806 TBool CESMRMeetingRequestEntry::IsEntryEditedL() const
       
   807     {
       
   808     FUNC_LOG;
       
   809 
       
   810     __ASSERT_DEBUG( iEntry, Panic(EESMREntryNotExist ) );
       
   811     __ASSERT_DEBUG( iOrginalEntry, Panic(EESMREntryNotExist ) );
       
   812 
       
   813     TBool edited( EFalse );
       
   814 
       
   815     if ( iOrginalEntry )
       
   816         { // edited if differs from the db entry
       
   817         edited = !( iEntry->CompareL( *iOrginalEntry ) );
       
   818 
       
   819         TESMRRole role( RoleL() );
       
   820         if ( !edited && EESMRRoleOrganizer != role )
       
   821             {
       
   822             // CCalEntry::CompareL does not compare attedee statuses
       
   823             CCalAttendee* dbAttendee =
       
   824                     iMRMailboxUtils.ThisAttendeeL( *iOrginalEntry );
       
   825 
       
   826             CCalAttendee* me =
       
   827                     iMRMailboxUtils.ThisAttendeeL( *iEntry );
       
   828 
       
   829             if ( dbAttendee &&  me )
       
   830                 {
       
   831                 edited = dbAttendee->StatusL() != me->StatusL();
       
   832                 }
       
   833             }
       
   834         if ( !edited && EESMRRoleOrganizer == role &&
       
   835               iEntry->MethodL() != iOrginalEntry->MethodL() )
       
   836             {
       
   837             // For organizer CCalEntry::Compare does not compare entry's
       
   838             // method at all --> Need to compare ourselves.
       
   839             edited = ETrue;
       
   840             }
       
   841 
       
   842         // CCalEntry's CompareL doesn't check the priority value:
       
   843         if ( iOrginalEntry->PriorityL() != iEntry->PriorityL() )
       
   844             {
       
   845             edited = ETrue;
       
   846             }
       
   847 
       
   848         TPtrC description( iEntry->DescriptionL() );
       
   849         if ( description.CompareF( iOrginalEntry->DescriptionL() ) )
       
   850             {
       
   851             edited = ETrue;
       
   852             }
       
   853 
       
   854         TPtrC location( iEntry->LocationL() );
       
   855         if ( location.CompareF( iOrginalEntry->LocationL() ) )
       
   856             {
       
   857             edited = ETrue;
       
   858             }
       
   859 
       
   860         if( IsStoredL() )
       
   861             {
       
   862             if ( iCalDb.EntryViewL( *iEntry ) != iCalDb.EntryView() )
       
   863                 {
       
   864                 edited = ETrue;
       
   865                 }
       
   866             }
       
   867         }
       
   868 
       
   869 
       
   870 
       
   871     return edited;
       
   872     }
       
   873 
       
   874 // ---------------------------------------------------------------------------
       
   875 // CESMRMeetingRequestEntry::IsEntryTypeChangedL
       
   876 // ---------------------------------------------------------------------------
       
   877 //
       
   878 TBool CESMRMeetingRequestEntry::IsEntryTypeChangedL() const
       
   879     {
       
   880     FUNC_LOG;
       
   881 
       
   882     return iTypeChanged;
       
   883     }
       
   884 
       
   885 // ---------------------------------------------------------------------------
       
   886 // CESMRMeetingRequestEntry::GetAlarmL
       
   887 // ---------------------------------------------------------------------------
       
   888 //
       
   889 void CESMRMeetingRequestEntry::GetAlarmL(
       
   890         MESMRCalEntry::TESMRAlarmType& aAlarmType,
       
   891         TTime &aAlarmTime )
       
   892     {
       
   893     FUNC_LOG;
       
   894 
       
   895     __ASSERT_DEBUG( iEntry, Panic(EESMREntryNotExist ) );
       
   896 
       
   897     aAlarmType = MESMRCalEntry::EESMRAlarmNotFound;
       
   898     aAlarmTime = Time::NullTTime();
       
   899 
       
   900     TFileName alarmInfoResource;
       
   901     ESMRHelper::LocateResourceFile(
       
   902             KAlarmInfoResource,
       
   903             KDC_RESOURCE_FILES_DIR,
       
   904             alarmInfoResource);
       
   905 
       
   906 
       
   907     CESMRAlarmInfoHandler* alarmInfoHandler =
       
   908             CESMRAlarmInfoHandler::NewLC();
       
   909 
       
   910     alarmInfoHandler->ReadFromResourceL(
       
   911             alarmInfoResource,
       
   912             ESRM_ALARM_INFO_TABLE );
       
   913 
       
   914     TRAPD( err,
       
   915             alarmInfoHandler->GetAbsoluteAlarmTimeL(*iEntry, aAlarmTime) );
       
   916 
       
   917     if ( KErrNone == err )
       
   918         {
       
   919         aAlarmType = MESMRCalEntry::EESMRAlarmAbsolute;
       
   920 
       
   921         // only meeting request that is not allday event can have
       
   922         // relative alarm:
       
   923         if ( !IsAllDayEventL() )
       
   924             {
       
   925             TESMRAlarmInfo alarmInfo;
       
   926             TRAP( err,
       
   927                   alarmInfoHandler->GetAlarmInfoObjectL(*iEntry, alarmInfo) );
       
   928 
       
   929             if ( KErrNone == err )
       
   930                 {
       
   931                 aAlarmType = MESMRCalEntry::EESMRAlarmRelative;
       
   932                 if( alarmInfo.iRelativeAlarmInSeconds < 0 )
       
   933                     {
       
   934                     aAlarmType = MESMRCalEntry::EESMRAlarmNotFound;
       
   935                     }
       
   936                 }
       
   937             }
       
   938         }
       
   939 
       
   940     CleanupStack::PopAndDestroy( alarmInfoHandler );
       
   941 
       
   942     }
       
   943 
       
   944 
       
   945 // ---------------------------------------------------------------------------
       
   946 // CESMRMeetingRequestEntry::OriginalEntry
       
   947 // ---------------------------------------------------------------------------
       
   948 //
       
   949 const CCalEntry& CESMRMeetingRequestEntry::OriginalEntry()
       
   950     {
       
   951     FUNC_LOG;
       
   952     return *iOrginalEntry;
       
   953     }
       
   954 
       
   955 
       
   956 // ---------------------------------------------------------------------------
       
   957 // CESMRMeetingRequestEntry::UpdateEntryAfterStoringL
       
   958 // ---------------------------------------------------------------------------
       
   959 //
       
   960 void CESMRMeetingRequestEntry::UpdateEntryAfterStoringL()
       
   961     {
       
   962     FUNC_LOG;
       
   963 
       
   964     __ASSERT_DEBUG( iEntry, Panic(EESMREntryNotExist ) );
       
   965 
       
   966     CCalEntry* storedEntry = NULL;
       
   967 
       
   968 
       
   969     if ( IsRecurrentEventL() &&
       
   970          EESMRThisOnly == iRecurrenceModRule &&
       
   971          !IsForwardedL() && IsStoredL() &&
       
   972          !ESMREntryHelper::IsModifyingEntryL(*iEntry) )
       
   973         {
       
   974         // We have stored one instance of series.
       
   975         storedEntry = iCalDb.FetchEntryL(
       
   976                     iEntry->UidL(),
       
   977                     iOrginalEntry->StartTimeL() );
       
   978         }
       
   979     else
       
   980         {
       
   981         // We are dealing with single instance or with the series
       
   982         storedEntry = iCalDb.FetchEntryL(
       
   983                     iEntry->UidL(),
       
   984                     iEntry->RecurrenceIdL() );
       
   985         }
       
   986 
       
   987 
       
   988     __ASSERT_DEBUG( storedEntry, Panic( EESMREntryNotExist ) );
       
   989     CleanupStack::PushL( storedEntry );
       
   990 
       
   991     // Description needs to be fecthed explicitly into memory
       
   992     TPtrC description( storedEntry->DescriptionL() );
       
   993 
       
   994 
       
   995     delete iEntry;
       
   996     iEntry = NULL;
       
   997     iEntry = CopyEntryL( iMRMailboxUtils, *storedEntry );
       
   998 
       
   999     if ( MESMRCalEntry::EESMRAllInSeries == iRecurrenceModRule &&
       
  1000          IsRecurrentEventL() )
       
  1001         {
       
  1002         // Adjust parent entry's start and end time to entry
       
  1003         TCalTime start;
       
  1004         TCalTime end;
       
  1005 
       
  1006         CESMRRecurrenceInfoHandler* recurrenceHandler =
       
  1007                 CESMRRecurrenceInfoHandler::NewLC( *iEntry );
       
  1008 
       
  1009         recurrenceHandler->GetFirstInstanceTimeL( start, end );
       
  1010         CleanupStack::PopAndDestroy( recurrenceHandler );
       
  1011         recurrenceHandler = NULL;
       
  1012 
       
  1013         iEntry->SetStartAndEndTimeL( start, end );
       
  1014         iEntry->SetDescriptionL( description );
       
  1015         }
       
  1016 
       
  1017     CCalEntry* temp  = CopyEntryL( iMRMailboxUtils, *iEntry );
       
  1018 
       
  1019     delete iOrginalEntry;
       
  1020     iOrginalEntry = temp;
       
  1021 
       
  1022     CleanupStack::PopAndDestroy( storedEntry );
       
  1023     }
       
  1024 
       
  1025 // ----------------------------------------------------------------------------
       
  1026 // CMRCalEntry::UpdateComparativeEntry
       
  1027 // ----------------------------------------------------------------------------
       
  1028 //
       
  1029 void CESMRMeetingRequestEntry::UpdateComparativeEntry(
       
  1030         CCalEntry* aNewComparativeEntry )
       
  1031     {
       
  1032     FUNC_LOG;
       
  1033 
       
  1034     if( iOrginalEntry ) // Update comparative entry
       
  1035         {
       
  1036         delete iOrginalEntry;
       
  1037         iOrginalEntry = NULL;
       
  1038 
       
  1039         iOrginalEntry = aNewComparativeEntry;
       
  1040         }
       
  1041 
       
  1042     }
       
  1043 
       
  1044 // ---------------------------------------------------------------------------
       
  1045 // CESMRMeetingRequestEntry::SetDefaultValuesToEntryL
       
  1046 // ---------------------------------------------------------------------------
       
  1047 //
       
  1048 void CESMRMeetingRequestEntry::SetDefaultValuesToEntryL()
       
  1049     {
       
  1050     FUNC_LOG;
       
  1051 
       
  1052     if ( !IsStoredL() )
       
  1053         {
       
  1054         SetPriorityL( EFSCalenMRPriorityNormal );
       
  1055 
       
  1056         // Get default alarm time from central repository
       
  1057         TInt defaultAlarmTime=0;
       
  1058         CRepository* repository = CRepository::NewLC( KCRUidCalendar );
       
  1059 
       
  1060         TInt err = KErrNotFound;
       
  1061 
       
  1062         if ( repository )
       
  1063             {
       
  1064             err = repository->Get(
       
  1065                     KCalendarDefaultAlarmTime,
       
  1066                     defaultAlarmTime );
       
  1067             CleanupStack::PopAndDestroy( repository );
       
  1068             }
       
  1069 
       
  1070         if ( err != KErrNone )
       
  1071             {
       
  1072             // By default 15 minutes if not found from central repository
       
  1073             defaultAlarmTime = KDefaultMeetingAlarmMinutes;
       
  1074             }
       
  1075 
       
  1076         // Getting current time
       
  1077         TTime currentTime;
       
  1078         currentTime.HomeTime();
       
  1079 
       
  1080         // Getting meeting start time
       
  1081         TTime start = iEntry->StartTimeL().TimeLocalL();
       
  1082 
       
  1083         // Create default alarm
       
  1084         CCalAlarm* alarm = CCalAlarm::NewL();
       
  1085         CleanupStack::PushL( alarm );
       
  1086 
       
  1087         TTimeIntervalMinutes alarmOffset( defaultAlarmTime );
       
  1088 
       
  1089         // If alarm time is in past
       
  1090         if ( ( start - alarmOffset ) < currentTime )
       
  1091             {
       
  1092             // Setting alarm off
       
  1093             iEntry->SetAlarmL( NULL );
       
  1094             }
       
  1095         else
       
  1096             {
       
  1097             // Set default alarm time
       
  1098             alarm->SetTimeOffset( alarmOffset );
       
  1099             iEntry->SetAlarmL( alarm );
       
  1100             }
       
  1101         CleanupStack::PopAndDestroy( alarm );
       
  1102         }
       
  1103 
       
  1104     // Set the default end time if not set by client
       
  1105     if ( iEntry->StartTimeL().TimeUtcL() == iEntry->EndTimeL().TimeUtcL() )
       
  1106         {
       
  1107         // This value might also be read from cenrep
       
  1108         TTimeIntervalHours KDefaultMeetingDuration(1);
       
  1109 
       
  1110         TCalTime newEndTime;
       
  1111         newEndTime.SetTimeUtcL(
       
  1112                 iEntry->StartTimeL().TimeUtcL() + KDefaultMeetingDuration );
       
  1113         iEntry->SetStartAndEndTimeL(iEntry->StartTimeL(), newEndTime);
       
  1114         }
       
  1115 
       
  1116     iEntry->SetReplicationStatusL( CCalEntry::EOpen );
       
  1117 
       
  1118     //Original entry must be stored after the default values are set.
       
  1119     //Otherwise it looks like settings are changed even though they haven't
       
  1120     CCalEntry* temp = CopyEntryL( iMRMailboxUtils, *iEntry );
       
  1121 
       
  1122     delete iOrginalEntry;
       
  1123     iOrginalEntry = temp;
       
  1124     }
       
  1125 
       
  1126 // ---------------------------------------------------------------------------
       
  1127 // CESMRMeetingRequestEntry::CloneEntryLC
       
  1128 // ---------------------------------------------------------------------------
       
  1129 //
       
  1130 CCalEntry* CESMRMeetingRequestEntry::CloneEntryLC(
       
  1131         TESMRCalEntryType aType ) const
       
  1132     {
       
  1133     CCalEntry* entry =
       
  1134         ESMRHelper::CopyEntryLC( *iEntry,
       
  1135                                  iEntry->MethodL(),
       
  1136                                  ESMRHelper::ECopyFull,
       
  1137                                  TESMRCalendarEventType( aType ) );
       
  1138 
       
  1139     return entry;
       
  1140     }
       
  1141 
       
  1142 // ---------------------------------------------------------------------------
       
  1143 // CESMRMeetingRequestEntry::RoleL
       
  1144 // ---------------------------------------------------------------------------
       
  1145 //
       
  1146 TESMRRole CESMRMeetingRequestEntry::RoleL() const
       
  1147     {
       
  1148     FUNC_LOG;
       
  1149 
       
  1150     __ASSERT_DEBUG( iEntry, Panic(EESMREntryNotExist ) );
       
  1151 
       
  1152     CESMRCalUserUtil* caluserUtil = CESMRCalUserUtil::NewLC( *iEntry );
       
  1153     TESMRRole role = caluserUtil->PhoneOwnerRoleL();
       
  1154     CleanupStack::PopAndDestroy( caluserUtil );
       
  1155 
       
  1156 
       
  1157     return role;
       
  1158     }
       
  1159 
       
  1160 // ---------------------------------------------------------------------------
       
  1161 // CESMRMeetingRequestEntry::Conflicts
       
  1162 // ---------------------------------------------------------------------------
       
  1163 //
       
  1164 TBool CESMRMeetingRequestEntry::Conflicts() const
       
  1165     {
       
  1166     FUNC_LOG;
       
  1167     return iConflictsExists;
       
  1168     }
       
  1169 
       
  1170 // ---------------------------------------------------------------------------
       
  1171 // CESMRMeetingRequestEntry::MarkMeetingCancelledL
       
  1172 // ---------------------------------------------------------------------------
       
  1173 //
       
  1174 void CESMRMeetingRequestEntry::MarkMeetingCancelledL()
       
  1175     {
       
  1176     FUNC_LOG;
       
  1177 
       
  1178     __ASSERT_DEBUG( iEntry, Panic(EESMREntryNotExist ) );
       
  1179 
       
  1180     TESMRRole role = RoleL();
       
  1181 
       
  1182     if ( EESMRRoleOrganizer == role )
       
  1183         {
       
  1184         iEntry->SetMethodL( CCalEntry::EMethodCancel );
       
  1185         iEntry->SetStatusL( CCalEntry::ECancelled );
       
  1186         }
       
  1187     else if ( EESMRRoleRequiredAttendee == role ||
       
  1188               EESMRRoleOptionalAttendee == role ||
       
  1189               EESMRRoleNonParticipant == role )
       
  1190         {
       
  1191         ConstructReplyL( EESMRAttendeeStatusDecline );
       
  1192         }
       
  1193 
       
  1194     }
       
  1195 
       
  1196 // ---------------------------------------------------------------------------
       
  1197 // CESMRMeetingRequestEntry::ConstructReplyL
       
  1198 //
       
  1199 // ---------------------------------------------------------------------------
       
  1200 //
       
  1201 void CESMRMeetingRequestEntry::ConstructReplyL(
       
  1202             TESMRAttendeeStatus aStatus )
       
  1203     {
       
  1204     FUNC_LOG;
       
  1205 
       
  1206     __ASSERT_DEBUG( iEntry, Panic(EESMREntryNotExist ) );
       
  1207 
       
  1208     CCalAttendee* attendee =
       
  1209             iMRMailboxUtils.ThisAttendeeL( *iEntry );
       
  1210 
       
  1211     if ( !attendee )
       
  1212         {
       
  1213 
       
  1214         User::Leave( KErrNotFound );
       
  1215         }
       
  1216 
       
  1217     CCalAttendee::TCalStatus status(
       
  1218             CCalAttendee::EDeclined );
       
  1219 
       
  1220     CCalEntry::TStatus entryStatus = CCalEntry::ENullStatus;
       
  1221     switch ( aStatus )
       
  1222         {
       
  1223         case EESMRAttendeeStatusAccept:
       
  1224             status = CCalAttendee::EAccepted;
       
  1225             entryStatus = CCalEntry::EConfirmed;
       
  1226             break;
       
  1227 
       
  1228         case EESMRAttendeeStatusTentative:
       
  1229             status = CCalAttendee::ETentative;
       
  1230             entryStatus = CCalEntry::ETentative;
       
  1231             break;
       
  1232         case EESMRAttendeeStatusDecline:
       
  1233             status = CCalAttendee::EDeclined;
       
  1234             entryStatus = CCalEntry::ECancelled;
       
  1235             break;
       
  1236         default:
       
  1237             // This should not occur
       
  1238             __ASSERT_DEBUG(
       
  1239                     EFalse,
       
  1240                     Panic( EESMRInvalidReplyType ) );
       
  1241 
       
  1242             User::Leave( KErrArgument );
       
  1243             break;
       
  1244         }
       
  1245 
       
  1246     attendee->SetStatusL(status);
       
  1247     iEntry->SetStatusL(entryStatus);
       
  1248 
       
  1249     iEntry->SetMethodL( CCalEntry::EMethodReply );
       
  1250 
       
  1251     }
       
  1252 
       
  1253 // ---------------------------------------------------------------------------
       
  1254 // CESMRMeetingRequestEntry::IsEntryOutOfDateL
       
  1255 //
       
  1256 // ---------------------------------------------------------------------------
       
  1257 //
       
  1258 TBool CESMRMeetingRequestEntry::IsEntryOutOfDateL() const
       
  1259     {
       
  1260     FUNC_LOG;
       
  1261 
       
  1262     __ASSERT_DEBUG( iEntry, Panic(EESMREntryNotExist ) );
       
  1263 
       
  1264     TBool outOfDate( EFalse );
       
  1265 
       
  1266     CCalEntry::TMethod method( iEntry->MethodL() );
       
  1267     if ( IsOpenedFromMail() &&
       
  1268          CCalEntry::EMethodCancel != method )
       
  1269         {
       
  1270         CCalEntry* dbEntry = NULL;
       
  1271 
       
  1272         TRAP_IGNORE( dbEntry = iCalDb.FetchEntryL( iEntry->UidL(),
       
  1273                                                  iEntry->RecurrenceIdL() ) );
       
  1274 
       
  1275         CleanupStack::PushL( dbEntry );
       
  1276         if ( dbEntry )
       
  1277             {
       
  1278             TInt currentSeqNo( iEntry->SequenceNumberL() );
       
  1279             TInt dbEntrySeqNo( dbEntry->SequenceNumberL() );
       
  1280 
       
  1281             if ( currentSeqNo < dbEntrySeqNo )
       
  1282                 {
       
  1283                 outOfDate = ETrue;
       
  1284                 }
       
  1285             }
       
  1286         CleanupStack::PopAndDestroy( dbEntry );
       
  1287         }
       
  1288 
       
  1289 
       
  1290     return outOfDate;
       
  1291     }
       
  1292 
       
  1293 // ---------------------------------------------------------------------------
       
  1294 // CESMRMeetingRequestEntry::IsMeetingCancelledL
       
  1295 //
       
  1296 // ---------------------------------------------------------------------------
       
  1297 //
       
  1298 TBool CESMRMeetingRequestEntry::IsMeetingCancelledL() const
       
  1299     {
       
  1300     FUNC_LOG;
       
  1301     __ASSERT_DEBUG( iEntry, Panic(EESMREntryNotExist ) );
       
  1302 
       
  1303     TBool retValue( EFalse );
       
  1304 
       
  1305     CCalEntry::TMethod method( iEntry->MethodL() );
       
  1306 
       
  1307     if ( CCalEntry::ECancelled == iEntry->StatusL() ||
       
  1308          CCalEntry::EMethodCancel == method )
       
  1309         {
       
  1310         retValue = ETrue;
       
  1311         }
       
  1312 
       
  1313     return retValue;
       
  1314     }
       
  1315 
       
  1316 // ---------------------------------------------------------------------------
       
  1317 // CESMRMeetingRequestEntry::AttendeeStatusL
       
  1318 //
       
  1319 // ---------------------------------------------------------------------------
       
  1320 //
       
  1321 TESMRAttendeeStatus CESMRMeetingRequestEntry::AttendeeStatusL() const
       
  1322     {
       
  1323     FUNC_LOG;
       
  1324 
       
  1325     __ASSERT_DEBUG( iEntry, Panic(EESMREntryNotExist ) );
       
  1326 
       
  1327     TESMRAttendeeStatus status(
       
  1328             EESMRAttendeeStatusDecline );
       
  1329 
       
  1330     if ( iMRMailboxUtils.IsOrganizerL( *iEntry ) )
       
  1331         {
       
  1332 
       
  1333         User::Leave( KErrNotFound );
       
  1334         }
       
  1335 
       
  1336     CCalAttendee* attendee = iMRMailboxUtils.ThisAttendeeL( *iEntry );
       
  1337     if (!attendee )
       
  1338         {
       
  1339         User::Leave( KErrNotFound );
       
  1340         }
       
  1341 
       
  1342     CCalAttendee::TCalStatus attendeeStatus( attendee->StatusL() );
       
  1343     switch ( attendeeStatus )
       
  1344         {
       
  1345         case CCalAttendee::ENeedsAction:
       
  1346             status = EESMRAttendeeStatusUnknown;
       
  1347             break;
       
  1348 
       
  1349         case CCalAttendee::EAccepted:
       
  1350             status = EESMRAttendeeStatusAccept;
       
  1351             break;
       
  1352 
       
  1353         case CCalAttendee::ETentative:
       
  1354             status = EESMRAttendeeStatusTentative;
       
  1355             break;
       
  1356 
       
  1357         case CCalAttendee::EDeclined:
       
  1358             status = EESMRAttendeeStatusDecline;
       
  1359             break;
       
  1360 
       
  1361         default:
       
  1362             status = EESMRAttendeeStatusDecline;
       
  1363             break;
       
  1364         }
       
  1365 
       
  1366 
       
  1367     return status;
       
  1368     }
       
  1369 
       
  1370 // ---------------------------------------------------------------------------
       
  1371 // CESMRMeetingRequestEntry::IsForwardedL
       
  1372 //
       
  1373 // ---------------------------------------------------------------------------
       
  1374 //
       
  1375 TBool CESMRMeetingRequestEntry::IsForwardedL() const
       
  1376     {
       
  1377     FUNC_LOG;
       
  1378     __ASSERT_DEBUG( iEntry, Panic(EESMREntryNotExist ) );
       
  1379 
       
  1380     TBool retValue( EFalse );
       
  1381     if ( iForwardEntry )
       
  1382         {
       
  1383         retValue = ETrue;
       
  1384         }
       
  1385     return retValue;
       
  1386     }
       
  1387 
       
  1388 // ---------------------------------------------------------------------------
       
  1389 // CESMRMeetingRequestEntry::SwitchToForwardL
       
  1390 //
       
  1391 // ---------------------------------------------------------------------------
       
  1392 //
       
  1393 void CESMRMeetingRequestEntry::SwitchToForwardL()
       
  1394     {
       
  1395     FUNC_LOG;
       
  1396 
       
  1397     __ASSERT_DEBUG( iEntry, Panic(EESMREntryNotExist ) );
       
  1398 
       
  1399     CCalEntry* temp = CopyEntryL( iMRMailboxUtils, *iEntry );
       
  1400 
       
  1401     delete iForwardEntry;
       
  1402     iForwardEntry = temp;
       
  1403 
       
  1404     RPointerArray<CCalAttendee>& attendeeList =
       
  1405                                     iForwardEntry->AttendeesL();
       
  1406 
       
  1407     while ( attendeeList.Count() )
       
  1408         {
       
  1409         //remove attendees from entry that is to be forwarded
       
  1410         iForwardEntry->DeleteAttendeeL( 0 );
       
  1411         }
       
  1412 
       
  1413     }
       
  1414 
       
  1415 // ---------------------------------------------------------------------------
       
  1416 // CESMRMeetingRequestEntry::SwitchToOrginalL
       
  1417 //
       
  1418 // ---------------------------------------------------------------------------
       
  1419 //
       
  1420 void CESMRMeetingRequestEntry::SwitchToOrginalL()
       
  1421     {
       
  1422     FUNC_LOG;
       
  1423 
       
  1424     __ASSERT_DEBUG( iEntry, Panic(EESMREntryNotExist ) );
       
  1425 
       
  1426     // We just delete the forwarded entry
       
  1427     delete iForwardEntry;
       
  1428     iForwardEntry = NULL;
       
  1429 
       
  1430     }
       
  1431 
       
  1432 // ---------------------------------------------------------------------------
       
  1433 // CESMRMeetingRequestEntry::SwitchToOrginalL
       
  1434 //
       
  1435 // ---------------------------------------------------------------------------
       
  1436 //
       
  1437 void CESMRMeetingRequestEntry::ConfirmEntryL()
       
  1438     {
       
  1439     FUNC_LOG;
       
  1440 
       
  1441     __ASSERT_DEBUG( iEntry, Panic(EESMREntryNotExist ) );
       
  1442 
       
  1443     if ( iForwardEntry &&
       
  1444          iForwardEntry->StatusL() == CCalEntry::ENullStatus )
       
  1445         {
       
  1446         iForwardEntry->SetStatusL( CCalEntry::EConfirmed );
       
  1447         }
       
  1448     else if ( RoleL() == EESMRRoleOrganizer ||
       
  1449             iEntry->StatusL() == CCalEntry::ENullStatus )
       
  1450         {
       
  1451         iEntry->SetStatusL( CCalEntry::EConfirmed );
       
  1452         }
       
  1453 
       
  1454     }
       
  1455 
       
  1456 // ---------------------------------------------------------------------------
       
  1457 // CESMRMeetingRequestEntry::OccursInPastL
       
  1458 // ---------------------------------------------------------------------------
       
  1459 //
       
  1460 TBool CESMRMeetingRequestEntry::OccursInPastL() const
       
  1461     {
       
  1462     FUNC_LOG;
       
  1463 
       
  1464     __ASSERT_DEBUG( iEntry, Panic(EESMREntryNotExist ) );
       
  1465 
       
  1466     TTime currentTimeUtc;
       
  1467     currentTimeUtc.UniversalTime();
       
  1468 
       
  1469     TTime startTimeUtc = iEntry->StartTimeL().TimeUtcL();
       
  1470     
       
  1471     if( IsRecurrentEventL() &&
       
  1472     		IsOpenedFromMail() &&
       
  1473     		EESMRAllInSeries == iRecurrenceModRule )
       
  1474     	{
       
  1475 		// Get recurrence
       
  1476 		TESMRRecurrenceValue recValue( ERecurrenceNot ); 
       
  1477 		GetRecurrenceL( recValue, startTimeUtc );
       
  1478     	}
       
  1479 
       
  1480     return (startTimeUtc < currentTimeUtc);
       
  1481     }
       
  1482 
       
  1483 // ---------------------------------------------------------------------------
       
  1484 // CESMRMeetingRequestEntry::EntryAttendeeInfoL
       
  1485 // ---------------------------------------------------------------------------
       
  1486 //
       
  1487 MESMRMeetingRequestEntry::TESMREntryInfo
       
  1488         CESMRMeetingRequestEntry::EntryAttendeeInfoL() const
       
  1489     {
       
  1490     FUNC_LOG;
       
  1491 
       
  1492     __ASSERT_DEBUG( iEntry, Panic(EESMREntryNotExist ) );
       
  1493 
       
  1494 #ifdef _DEBUG
       
  1495 
       
  1496     __ASSERT_DEBUG( EESMRRoleOrganizer != RoleL(), Panic(EESMRInvalidRole) );
       
  1497 
       
  1498 #else
       
  1499 
       
  1500     if ( EESMRRoleOrganizer == RoleL() )
       
  1501         {
       
  1502         // Info cannot be resolved in organzier role
       
  1503         User::Leave( KErrNotSupported );
       
  1504         }
       
  1505 #endif
       
  1506 
       
  1507     TESMRAttendeeStatus attendeeStatus(
       
  1508             AttendeeStatusL() );
       
  1509 
       
  1510     MESMRMeetingRequestEntry::TESMREntryInfo info =
       
  1511             EESMREntryInfoNormal;
       
  1512 
       
  1513     if ( IsEntryOutOfDateL() )
       
  1514         {
       
  1515         info = EESMREntryInfoOutOfDate;
       
  1516         }
       
  1517     else if( IsMeetingCancelledL() )
       
  1518         {
       
  1519         info = EESMREntryInfoCancelled;
       
  1520         }
       
  1521     else if ( IsSentL() )
       
  1522         {
       
  1523         info = EESMREntryInfoAccepted;
       
  1524         if ( EESMRAttendeeStatusTentative == attendeeStatus )
       
  1525             {
       
  1526             info = EESMREntryInfoTentativelyAccepted;
       
  1527             }
       
  1528         }
       
  1529     else if ( OccursInPastL() )
       
  1530         {
       
  1531         info = EESMREntryInfoOccursInPast;
       
  1532         }
       
  1533 
       
  1534 
       
  1535     return info;
       
  1536     }
       
  1537 
       
  1538 // ---------------------------------------------------------------------------
       
  1539 // CESMRMeetingRequestEntry::SetPriorityL
       
  1540 // ---------------------------------------------------------------------------
       
  1541 //
       
  1542 void CESMRMeetingRequestEntry::SetPriorityL(
       
  1543         TUint aPriority )
       
  1544     {
       
  1545     FUNC_LOG;
       
  1546 
       
  1547     __ASSERT_DEBUG( iEntry, Panic(EESMREntryNotExist ) );
       
  1548 
       
  1549     iEntry->SetPriorityL( aPriority );
       
  1550 
       
  1551     }
       
  1552 
       
  1553 // ---------------------------------------------------------------------------
       
  1554 // CESMRMeetingRequestEntry::GetPriorityL
       
  1555 // ---------------------------------------------------------------------------
       
  1556 //
       
  1557 TUint CESMRMeetingRequestEntry::GetPriorityL() const
       
  1558     {
       
  1559     FUNC_LOG;
       
  1560 
       
  1561     __ASSERT_DEBUG( iEntry, Panic(EESMREntryNotExist ) );
       
  1562 
       
  1563     TUint entryPriority = iEntry->PriorityL();
       
  1564 
       
  1565     if ( entryPriority != EFSCalenMRPriorityLow &&
       
  1566          entryPriority != EFSCalenMRPriorityNormal &&
       
  1567          entryPriority != EFSCalenMRPriorityHigh )
       
  1568         {
       
  1569         entryPriority = EFSCalenMRPriorityNormal;
       
  1570         }
       
  1571 
       
  1572 
       
  1573     return entryPriority;
       
  1574     }
       
  1575 
       
  1576 // ---------------------------------------------------------------------------
       
  1577 // CESMRMeetingRequestEntry::GetAttendeesL
       
  1578 // ---------------------------------------------------------------------------
       
  1579 //
       
  1580 void CESMRMeetingRequestEntry::GetAttendeesL(
       
  1581         RArray<CCalAttendee*>& aAttendeeArray,
       
  1582         TUint aFilterFlags ) const
       
  1583     {
       
  1584     FUNC_LOG;
       
  1585 
       
  1586     __ASSERT_DEBUG( iEntry, Panic(EESMREntryNotExist ) );
       
  1587 
       
  1588     CESMRCalUserUtil* caluserUtil = CESMRCalUserUtil::NewLC( *iEntry );
       
  1589     caluserUtil->GetAttendeesL( aAttendeeArray, aFilterFlags );
       
  1590     CleanupStack::PopAndDestroy( caluserUtil );
       
  1591 
       
  1592     }
       
  1593 
       
  1594 // ---------------------------------------------------------------------------
       
  1595 // CESMRMeetingRequestEntry::ValidateEntryL
       
  1596 // ---------------------------------------------------------------------------
       
  1597 //
       
  1598 CCalEntry* CESMRMeetingRequestEntry::ValidateEntryL()
       
  1599     {
       
  1600     FUNC_LOG;
       
  1601 
       
  1602     __ASSERT_DEBUG( iEntry, Panic(EESMREntryNotExist ) );
       
  1603     __ASSERT_DEBUG( iOrginalEntry, Panic(EESMREntryNotExist ) );
       
  1604 
       
  1605     CCalEntry* entry = NULL;
       
  1606 
       
  1607     if ( iForwardEntry )
       
  1608         {
       
  1609         entry = CopyEntryL( iMRMailboxUtils, *iForwardEntry );
       
  1610         }
       
  1611 
       
  1612     if ( !entry && IsRecurrentEventL() &&
       
  1613          EESMRThisOnly == iRecurrenceModRule &&
       
  1614          !IsForwardedL() && IsStoredL() &&
       
  1615          !ESMREntryHelper::IsModifyingEntryL(*iEntry) )
       
  1616         {
       
  1617 
       
  1618         CCalInstance* instance = NULL;
       
  1619         TRAPD( err, instance = InstanceL() );
       
  1620         if( KErrNotFound != err )
       
  1621             {
       
  1622             User::LeaveIfError( err );
       
  1623             }
       
  1624 
       
  1625         if ( instance )
       
  1626             {
       
  1627 
       
  1628             CleanupStack::PushL( instance );
       
  1629             CCalEntry& parent = instance->Entry();
       
  1630 
       
  1631             entry = iCalDb.FetchEntryL(
       
  1632                             parent.UidL(),
       
  1633                             iOrginalEntry->StartTimeL() );
       
  1634 
       
  1635             if ( !entry )
       
  1636                 {
       
  1637 
       
  1638                 // copy global UID from the original entry
       
  1639                 HBufC8* guid = parent.UidL().AllocLC();
       
  1640 
       
  1641                 // create new (child) entry
       
  1642                 entry = CCalEntry::NewL(
       
  1643                                 parent.EntryTypeL(),
       
  1644                                 guid,
       
  1645                                 parent.MethodL(),
       
  1646                                 0,
       
  1647                                 iOrginalEntry->StartTimeL(),
       
  1648                                 CalCommon::EThisOnly );
       
  1649 
       
  1650                 CleanupStack::Pop( guid );
       
  1651                 guid = NULL; // ownership transferred
       
  1652                 }
       
  1653 
       
  1654             CleanupStack::PopAndDestroy( instance );
       
  1655             instance = NULL; // instance
       
  1656             CleanupStack::PushL( entry );
       
  1657 
       
  1658 
       
  1659             CCalEntry::TMethod method( iEntry->MethodL() );
       
  1660 
       
  1661             entry->CopyFromL( *iEntry, CCalEntry::EDontCopyId );
       
  1662             entry->SetSequenceNumberL( 0 );
       
  1663             entry->SetMethodL( method );
       
  1664             entry->SetSummaryL( iEntry->SummaryL() );
       
  1665             entry->SetLocalUidL( TCalLocalUid( 0 ) );
       
  1666             entry->ClearRepeatingPropertiesL();
       
  1667             iMRMailboxUtils.SetPhoneOwnerL( *entry );
       
  1668 
       
  1669             CleanupStack::Pop( entry );
       
  1670             }
       
  1671         }
       
  1672 
       
  1673     if ( !entry )
       
  1674         {
       
  1675         entry = CopyEntryL( iMRMailboxUtils, *iEntry );
       
  1676         }
       
  1677 
       
  1678     if ( iRemoveAttachments )
       
  1679         {
       
  1680         // Remove attachments from the entry
       
  1681         TInt count( entry->AttachmentCountL() );
       
  1682 
       
  1683         for ( TInt i = 0; i < count; ++i )
       
  1684             {
       
  1685             CCalAttachment* attachment = entry->AttachmentL( i );
       
  1686             entry->DeleteAttachmentL( *attachment );
       
  1687             }
       
  1688         }
       
  1689 
       
  1690     return entry;
       
  1691     }
       
  1692 
       
  1693 // ---------------------------------------------------------------------------
       
  1694 // CESMRMeetingRequestEntry::FetchConflictingEntriesL
       
  1695 // ---------------------------------------------------------------------------
       
  1696 //
       
  1697 TInt CESMRMeetingRequestEntry::FetchConflictingEntriesL(
       
  1698         RPointerArray<CCalEntry>& aEntryArray)
       
  1699     {
       
  1700     FUNC_LOG;
       
  1701 
       
  1702     TInt ret( KErrNone );
       
  1703 
       
  1704     CESMRConflictChecker* conflictChecker =
       
  1705                 CESMRConflictChecker::NewL(iCalDb);
       
  1706     CleanupStack::PushL( conflictChecker );
       
  1707 
       
  1708 
       
  1709     conflictChecker->FindConflictsL( *iEntry, aEntryArray );
       
  1710 
       
  1711     CleanupStack::PopAndDestroy( conflictChecker );
       
  1712 
       
  1713     if ( aEntryArray.Count() == 0 )
       
  1714         {
       
  1715         ret = KErrNotFound;
       
  1716         }
       
  1717 
       
  1718 
       
  1719     return ret;
       
  1720     }
       
  1721 
       
  1722 // ---------------------------------------------------------------------------
       
  1723 // CESMRMeetingRequestEntry::IsSyncObjectPresent
       
  1724 // ---------------------------------------------------------------------------
       
  1725 //
       
  1726 TBool CESMRMeetingRequestEntry::IsSyncObjectPresent() const
       
  1727     {
       
  1728     FUNC_LOG;
       
  1729     TBool retValue(EFalse);
       
  1730 
       
  1731     if ( iESMRInputParams && iESMRInputParams->iMRInfoObject)
       
  1732         {
       
  1733         retValue = ETrue;
       
  1734         }
       
  1735 
       
  1736     return retValue;
       
  1737     }
       
  1738 
       
  1739 // ---------------------------------------------------------------------------
       
  1740 // CESMRMeetingRequestEntry::SyncObjectL
       
  1741 // ---------------------------------------------------------------------------
       
  1742 //
       
  1743 MMRInfoObject& CESMRMeetingRequestEntry::SyncObjectL()
       
  1744     {
       
  1745     FUNC_LOG;
       
  1746     if ( !IsSyncObjectPresent() )
       
  1747         {
       
  1748         User::Leave(KErrNotSupported);
       
  1749         }
       
  1750 
       
  1751     return *iESMRInputParams->iMRInfoObject;
       
  1752     }
       
  1753 
       
  1754 // ---------------------------------------------------------------------------
       
  1755 // CESMRMeetingRequestEntry::ValidateSyncObjectL
       
  1756 // ---------------------------------------------------------------------------
       
  1757 //
       
  1758 MMRInfoObject& CESMRMeetingRequestEntry::ValidateSyncObjectL()
       
  1759     {
       
  1760     FUNC_LOG;
       
  1761     if ( EESMRRoleOrganizer == RoleL() )
       
  1762         {
       
  1763         User::Leave( KErrNotSupported );
       
  1764         }
       
  1765 
       
  1766     MMRInfoObject& syncObject = SyncObjectL();
       
  1767 
       
  1768     CCalAttendee* thisAttendee =
       
  1769             iMRMailboxUtils.ThisAttendeeL( *iEntry );
       
  1770 
       
  1771     RPointerArray<MMRAttendee> attendeeArray =
       
  1772             syncObject.AttendeesL();
       
  1773 
       
  1774     TBool found( EFalse );
       
  1775     TInt attendeeCount( attendeeArray.Count() );
       
  1776     for (TInt i (0); i < attendeeCount && !found; ++i )
       
  1777         {
       
  1778         MMRAttendee* attendee = attendeeArray[i];
       
  1779 
       
  1780         TPtrC calEntryAddress( thisAttendee->Address() );
       
  1781         TPtrC infoAddress( attendee->Address() );
       
  1782         if ( 0 == infoAddress.Compare(calEntryAddress ) )
       
  1783             {
       
  1784             found = ETrue;
       
  1785 
       
  1786             MMRInfoObject::TResponse entryResp(
       
  1787                     MMRInfoObject::EMrCmdResponseAccept );
       
  1788 
       
  1789             CCalAttendee::TCalStatus calEntryAttStatus(
       
  1790                     thisAttendee->StatusL() );
       
  1791 
       
  1792             MMRAttendee::TAttendeeStatus infoAttStatus(
       
  1793                     MMRAttendee::EMRAttendeeActionAccepted );
       
  1794 
       
  1795             if ( CCalAttendee::ETentative == calEntryAttStatus)
       
  1796                 {
       
  1797                 infoAttStatus = MMRAttendee::EMRAttendeeActionTentative;
       
  1798                 entryResp = MMRInfoObject::EMrCmdResponseTentative;
       
  1799                 }
       
  1800             else if ( CCalAttendee::EDeclined == calEntryAttStatus ||
       
  1801                       CCalEntry::EMethodCancel == iEntry->MethodL() )
       
  1802                 {
       
  1803                 infoAttStatus = MMRAttendee::EMRAttendeeActionDeclined;
       
  1804                 entryResp = MMRInfoObject::EMrCmdResponseDecline;
       
  1805                 }
       
  1806 
       
  1807             attendee->SetAttendeeStatusL(infoAttStatus);
       
  1808             syncObject.SetMRResponseL( entryResp );
       
  1809             }
       
  1810         }
       
  1811 
       
  1812     __ASSERT_DEBUG( found, Panic(EESMRNoInfoObjectAttendeeFound) );
       
  1813 
       
  1814     return syncObject;
       
  1815     }
       
  1816 
       
  1817 // ---------------------------------------------------------------------------
       
  1818 // CESMRMeetingRequestEntry::StartupParameters
       
  1819 // ---------------------------------------------------------------------------
       
  1820 //
       
  1821 TBool CESMRMeetingRequestEntry::StartupParameters(
       
  1822         TESMRInputParams& aStartupParams) const
       
  1823     {
       
  1824     FUNC_LOG;
       
  1825     TBool retValue( EFalse );
       
  1826 
       
  1827     if ( iESMRInputParams )
       
  1828         {
       
  1829         retValue = ETrue;
       
  1830 
       
  1831         aStartupParams.iCalEntry       = iESMRInputParams->iCalEntry;
       
  1832         aStartupParams.iMRInfoObject   = iESMRInputParams->iMRInfoObject;
       
  1833         aStartupParams.iMailMessage    = iESMRInputParams->iMailMessage;
       
  1834         aStartupParams.iMailClient     = iESMRInputParams->iMailClient;
       
  1835         aStartupParams.iSpare          = iESMRInputParams->iSpare;
       
  1836         }
       
  1837     return retValue;
       
  1838     }
       
  1839 
       
  1840 // ---------------------------------------------------------------------------
       
  1841 // CESMRMeetingRequestEntry::AttendeeCountL
       
  1842 // ---------------------------------------------------------------------------
       
  1843 //
       
  1844 TInt CESMRMeetingRequestEntry::AttendeeCountL(
       
  1845         TUint aFilterFlags ) const
       
  1846     {
       
  1847     FUNC_LOG;
       
  1848 
       
  1849     TInt attendeeCount(0);
       
  1850 
       
  1851     RArray<CCalAttendee*> attendeeArray;
       
  1852     CleanupClosePushL( attendeeArray );
       
  1853 
       
  1854     GetAttendeesL(
       
  1855             attendeeArray,
       
  1856             aFilterFlags );
       
  1857 
       
  1858     attendeeCount = attendeeArray.Count();
       
  1859 
       
  1860     CleanupStack::PopAndDestroy( &attendeeArray );
       
  1861 
       
  1862 
       
  1863     return attendeeCount;
       
  1864     }
       
  1865 
       
  1866 // ---------------------------------------------------------------------------
       
  1867 // CESMRMeetingRequestEntry::RemoveInstanceFromSeriesL
       
  1868 // ---------------------------------------------------------------------------
       
  1869 //
       
  1870 CCalEntry* CESMRMeetingRequestEntry::RemoveInstanceFromSeriesL()
       
  1871     {
       
  1872     FUNC_LOG;
       
  1873 
       
  1874     CCalEntry* retEntry = NULL;
       
  1875 
       
  1876     if ( IsRecurrentEventL() &&
       
  1877             EESMRThisOnly == iRecurrenceModRule &&
       
  1878             !IsForwardedL() )
       
  1879            {
       
  1880            CCalInstance* instance = NULL;
       
  1881            TRAPD( err, instance = InstanceL() );
       
  1882            if( KErrNotFound != err )
       
  1883                {
       
  1884                User::LeaveIfError( err );
       
  1885                }
       
  1886 
       
  1887            if ( instance )
       
  1888                {
       
  1889                CleanupStack::PushL( instance );
       
  1890 
       
  1891                CCalEntry& parentEntry = instance->Entry();
       
  1892                retEntry = ESMRHelper::CopyEntryL(
       
  1893                         parentEntry,
       
  1894                         parentEntry.MethodL(),
       
  1895                         ESMRHelper::ECopyFull );
       
  1896 
       
  1897                CleanupStack::PopAndDestroy( instance );
       
  1898                instance = NULL;
       
  1899 
       
  1900                CleanupStack::PushL( retEntry );
       
  1901 
       
  1902                CESMRRecurrenceInfoHandler* recurrenceHandler =
       
  1903                         CESMRRecurrenceInfoHandler::NewLC( *retEntry );
       
  1904 
       
  1905                TCalTime orginalInstanceTime;
       
  1906                orginalInstanceTime.SetTimeUtcL(
       
  1907                         iOrginalEntry->StartTimeL().TimeUtcL() );
       
  1908 
       
  1909                recurrenceHandler->RemoveInstanceL( orginalInstanceTime );
       
  1910 
       
  1911                CleanupStack::PopAndDestroy( recurrenceHandler );
       
  1912                CleanupStack::Pop( retEntry );
       
  1913                }
       
  1914            }
       
  1915     else
       
  1916         {
       
  1917         User::Leave( KErrNotSupported );
       
  1918         }
       
  1919 
       
  1920 
       
  1921     return retEntry;
       
  1922     }
       
  1923 
       
  1924 // ---------------------------------------------------------------------------
       
  1925 // CESMRMeetingRequestEntry::IsOpenedFromMail
       
  1926 // ---------------------------------------------------------------------------
       
  1927 //
       
  1928 TBool CESMRMeetingRequestEntry::IsOpenedFromMail() const
       
  1929     {
       
  1930     FUNC_LOG;
       
  1931     TBool openedFromMail( EFalse );
       
  1932 
       
  1933     if ( iESMRInputParams )
       
  1934         {
       
  1935         openedFromMail = ETrue;
       
  1936         }
       
  1937 
       
  1938     return openedFromMail;
       
  1939     }
       
  1940 
       
  1941 // ---------------------------------------------------------------------------
       
  1942 // CESMRMeetingRequestEntry::GetAddedAttendeesL
       
  1943 // ---------------------------------------------------------------------------
       
  1944 //
       
  1945 void CESMRMeetingRequestEntry::GetAddedAttendeesL(
       
  1946         RArray<CCalAttendee*>& aAttendeeArray,
       
  1947         TUint aFilterFlags ) const
       
  1948     {
       
  1949     FUNC_LOG;
       
  1950 
       
  1951     __ASSERT_DEBUG( iEntry, Panic(EESMREntryNotExist ) );
       
  1952 
       
  1953     CESMRCalUserUtil* caluserUtil = CESMRCalUserUtil::NewLC( *iEntry );
       
  1954     caluserUtil->GetAttendeesL( aAttendeeArray, aFilterFlags );
       
  1955     CleanupStack::PopAndDestroy( caluserUtil );
       
  1956     caluserUtil = NULL;
       
  1957 
       
  1958     RArray<CCalAttendee*> orgAttendees;
       
  1959     CleanupClosePushL( orgAttendees );
       
  1960 
       
  1961     caluserUtil = CESMRCalUserUtil::NewLC( *iParameterEntry );
       
  1962     caluserUtil->GetAttendeesL( orgAttendees, aFilterFlags );
       
  1963 
       
  1964     CleanupStack::PopAndDestroy( caluserUtil );
       
  1965     caluserUtil = NULL;
       
  1966 
       
  1967     TInt index( 0 );
       
  1968     while( index < aAttendeeArray.Count() )
       
  1969         {
       
  1970         TPtrC attendeeEmail( aAttendeeArray[index]->Address() );
       
  1971 
       
  1972         TBool found( EFalse );
       
  1973         TInt orgAttendeeCount( orgAttendees.Count() );
       
  1974         for( TInt i(0); (i < orgAttendeeCount) && !found; ++i )
       
  1975             {
       
  1976             TPtrC orgAttendeeEmail( orgAttendees[i]->Address() );
       
  1977             if ( 0 == attendeeEmail.CompareF(orgAttendeeEmail) )
       
  1978                 {
       
  1979                 found = ETrue;
       
  1980                 }
       
  1981             }
       
  1982 
       
  1983         if ( found )
       
  1984             {
       
  1985             // Attendee was not found from orginal list
       
  1986             // --> it is added
       
  1987             aAttendeeArray.Remove( index );
       
  1988             }
       
  1989         else
       
  1990             {
       
  1991             ++index;
       
  1992             }
       
  1993         }
       
  1994 
       
  1995     CleanupStack::PopAndDestroy( &orgAttendees );
       
  1996 
       
  1997     }
       
  1998 
       
  1999 // ---------------------------------------------------------------------------
       
  2000 // CESMRMeetingRequestEntry::GetRemovedAttendeesL
       
  2001 // ---------------------------------------------------------------------------
       
  2002 //
       
  2003 void CESMRMeetingRequestEntry::GetRemovedAttendeesL(
       
  2004         RArray<CCalAttendee*>& aAttendeeArray,
       
  2005         TUint aFilterFlags ) const
       
  2006     {
       
  2007     FUNC_LOG;
       
  2008 
       
  2009     __ASSERT_DEBUG( iEntry, Panic(EESMREntryNotExist ) );
       
  2010 
       
  2011     CESMRCalUserUtil* caluserUtil = CESMRCalUserUtil::NewLC( *iParameterEntry );
       
  2012     caluserUtil->GetAttendeesL( aAttendeeArray, aFilterFlags );
       
  2013     CleanupStack::PopAndDestroy( caluserUtil );
       
  2014     caluserUtil = NULL;
       
  2015 
       
  2016     RArray<CCalAttendee*> currentAttendees;
       
  2017     CleanupClosePushL( currentAttendees );
       
  2018 
       
  2019     caluserUtil = CESMRCalUserUtil::NewLC( *iEntry );
       
  2020     caluserUtil->GetAttendeesL( currentAttendees, aFilterFlags );
       
  2021 
       
  2022     CleanupStack::PopAndDestroy( caluserUtil );
       
  2023     caluserUtil = NULL;
       
  2024 
       
  2025     TInt index( 0 );
       
  2026     while( index < aAttendeeArray.Count() )
       
  2027         {
       
  2028         TPtrC attendeeEmail( aAttendeeArray[index]->Address() );
       
  2029 
       
  2030         TBool found( EFalse );
       
  2031         TInt orgAttendeeCount( currentAttendees.Count() );
       
  2032         for( TInt i(0); (i < orgAttendeeCount) && !found; ++i )
       
  2033             {
       
  2034             TPtrC curAttendeeEmail( currentAttendees[i]->Address() );
       
  2035             if ( 0 == attendeeEmail.CompareF(curAttendeeEmail) )
       
  2036                 {
       
  2037                 found = ETrue;
       
  2038                 }
       
  2039             }
       
  2040 
       
  2041         if ( found )
       
  2042             {
       
  2043             // Attendee was found from orginal list
       
  2044             // --> It has not been removed from MR
       
  2045             aAttendeeArray.Remove( index );
       
  2046             }
       
  2047         else
       
  2048             {
       
  2049             ++index;
       
  2050             }
       
  2051         }
       
  2052 
       
  2053     CleanupStack::PopAndDestroy( &currentAttendees );
       
  2054 
       
  2055     }
       
  2056 
       
  2057 // ---------------------------------------------------------------------------
       
  2058 // CESMRMeetingRequestEntry::UpdateChildEntriesSeqNumbersL
       
  2059 // ---------------------------------------------------------------------------
       
  2060 //
       
  2061 void CESMRMeetingRequestEntry::UpdateChildEntriesSeqNumbersL()
       
  2062     {
       
  2063     FUNC_LOG;
       
  2064 
       
  2065     if ( MESMRCalEntry::EESMRAllInSeries == iRecurrenceModRule &&
       
  2066          IsStoredL() )
       
  2067         {
       
  2068         RCPointerArray<CCalEntry> childEntries;
       
  2069         CleanupClosePushL( childEntries );
       
  2070 
       
  2071         // Fetch all entries (this and child entries
       
  2072         iCalDb.EntryView()->FetchL(
       
  2073                 iEntry->UidL(),
       
  2074                 childEntries );
       
  2075 
       
  2076         // Next: Remove parent entry from the array
       
  2077         TBool removed( EFalse );
       
  2078         TInt entryCount( childEntries.Count() );
       
  2079         for ( TInt i(0); (i < entryCount) && !removed; ++i  )
       
  2080             {
       
  2081             CCalEntry* entry = childEntries[i];
       
  2082 
       
  2083             if ( !ESMREntryHelper::IsModifyingEntryL( *entry) )
       
  2084                 {
       
  2085                 removed = ETrue;
       
  2086                 childEntries.Remove( i );
       
  2087                 delete entry;
       
  2088                 }
       
  2089             entry = NULL;
       
  2090             }
       
  2091 
       
  2092         TInt childCount( childEntries.Count() );
       
  2093         if ( childCount )
       
  2094             {
       
  2095             for (TInt i(0); i < childCount; ++i )
       
  2096                 {
       
  2097                 CCalEntry* child = childEntries[i];
       
  2098                 TInt childSeqNo( child->SequenceNumberL() );
       
  2099                 child->SetSequenceNumberL( childSeqNo + 1);
       
  2100                 }
       
  2101 
       
  2102             TInt updatedChilds;
       
  2103             iCalDb.EntryView()->StoreL(childEntries, updatedChilds);
       
  2104             }
       
  2105 
       
  2106         CleanupStack::PopAndDestroy(); // childEntries
       
  2107         }
       
  2108 
       
  2109     }
       
  2110 
       
  2111 // ---------------------------------------------------------------------------
       
  2112 // CESMRMeetingRequestEntry::CurrentPluginL
       
  2113 // ---------------------------------------------------------------------------
       
  2114 //
       
  2115 TESMRMailPlugin CESMRMeetingRequestEntry::CurrentPluginL()
       
  2116     {
       
  2117     FUNC_LOG;
       
  2118 
       
  2119     if ( EESMRUnknownPlugin == iCurrentFSEmailPlugin)
       
  2120         {
       
  2121         CESMRFsMailboxUtils* fsMbUtils =
       
  2122                 CESMRFsMailboxUtils::NewL( iMRMailboxUtils );
       
  2123         CleanupStack::PushL( fsMbUtils );
       
  2124 
       
  2125         iCurrentFSEmailPlugin = fsMbUtils->FSEmailPluginForEntryL( *iEntry );
       
  2126         CleanupStack::PopAndDestroy( fsMbUtils );
       
  2127         fsMbUtils = NULL;
       
  2128         }
       
  2129 
       
  2130     return iCurrentFSEmailPlugin;
       
  2131     }
       
  2132 
       
  2133 // ---------------------------------------------------------------------------
       
  2134 // CESMRMeetingRequestEntry::UpdateTimeStampL
       
  2135 // ---------------------------------------------------------------------------
       
  2136 //
       
  2137 void CESMRMeetingRequestEntry::UpdateTimeStampL()
       
  2138     {
       
  2139     FUNC_LOG;
       
  2140     __ASSERT_DEBUG( iEntry, Panic(EESMREntryNotExist ) );
       
  2141 
       
  2142     TTime currentUTCTime;
       
  2143     currentUTCTime.UniversalTime();
       
  2144 
       
  2145     TCalTime currentTime;
       
  2146     currentTime.SetTimeUtcL( currentUTCTime );
       
  2147 
       
  2148     iEntry->SetDTStampL( currentTime );
       
  2149     }
       
  2150 
       
  2151 // ---------------------------------------------------------------------------
       
  2152 // CESMRMeetingRequestEntry::AnyInstancesBetweenTimePeriodL
       
  2153 // ---------------------------------------------------------------------------
       
  2154 //
       
  2155 TBool CESMRMeetingRequestEntry::AnyInstancesBetweenTimePeriodL(
       
  2156             TTime& aStart,
       
  2157             TTime& aEnd )
       
  2158     {
       
  2159     FUNC_LOG;
       
  2160 
       
  2161     __ASSERT_DEBUG( iEntry, Panic(EESMREntryNotExist ) );
       
  2162     __ASSERT_DEBUG( iOrginalEntry, Panic(EESMREntryNotExist ) );
       
  2163 
       
  2164     TBool retValue( EFalse );
       
  2165 
       
  2166     RCPointerArray<CCalEntry> entries;
       
  2167     CleanupClosePushL( entries );
       
  2168 
       
  2169     CESMRConflictChecker* conflictCheckker =
       
  2170         CESMRConflictChecker::NewL( iCalDb );
       
  2171     CleanupStack::PushL( conflictCheckker );
       
  2172 
       
  2173     CCalInstance* instance = InstanceL();
       
  2174     CleanupStack::PushL( instance );
       
  2175 
       
  2176     TCalCollectionId colId = instance->InstanceIdL().iCollectionId;
       
  2177     CleanupStack::PopAndDestroy( instance );
       
  2178 
       
  2179     conflictCheckker->FindInstancesForEntryL( aStart,
       
  2180                                               aEnd,
       
  2181                                               *iEntry,
       
  2182                                               colId,
       
  2183                                               entries );
       
  2184 
       
  2185     if ( entries.Count() )
       
  2186         {
       
  2187         retValue = ETrue;
       
  2188         }
       
  2189 
       
  2190     CleanupStack::PopAndDestroy( conflictCheckker );
       
  2191     CleanupStack::PopAndDestroy(); // entries
       
  2192 
       
  2193     return retValue;
       
  2194     }
       
  2195 
       
  2196 // ---------------------------------------------------------------------------
       
  2197 // CESMRMeetingRequestEntry::GetFirstInstanceStartAndEndTimeL
       
  2198 // ---------------------------------------------------------------------------
       
  2199 //
       
  2200 void CESMRMeetingRequestEntry::GetFirstInstanceStartAndEndTimeL(
       
  2201             TTime& aStart,
       
  2202             TTime& aEnd )
       
  2203     {
       
  2204     FUNC_LOG;
       
  2205 
       
  2206     __ASSERT_DEBUG( iEntry, Panic(EESMREntryNotExist ) );
       
  2207 
       
  2208     // This fetches the parent entry
       
  2209     TCalTime recurrenceId;
       
  2210     recurrenceId.SetTimeLocalL( Time::NullTTime() );
       
  2211     CCalEntry* parent = iCalDb.FetchEntryL(
       
  2212                 iEntry->UidL(),
       
  2213                 recurrenceId );
       
  2214 
       
  2215     CleanupStack::PushL( parent );
       
  2216 
       
  2217     aStart = parent->StartTimeL().TimeLocalL();
       
  2218     aEnd = parent->EndTimeL().TimeLocalL();
       
  2219 
       
  2220     CleanupStack::PopAndDestroy( parent );
       
  2221     }
       
  2222 
       
  2223 // ---------------------------------------------------------------------------
       
  2224 // CESMRMeetingRequestEntry::CalendarOwnerAddressL
       
  2225 // ---------------------------------------------------------------------------
       
  2226 //
       
  2227 const TDesC& CESMRMeetingRequestEntry::CalendarOwnerAddressL() const
       
  2228     {
       
  2229     FUNC_LOG;
       
  2230 
       
  2231     __ASSERT_DEBUG( iEntry, Panic( EESMREntryNotExist ) );
       
  2232 
       
  2233     CCalUser* po = iEntry->PhoneOwnerL();
       
  2234 
       
  2235     __ASSERT_DEBUG( po, Panic( EESMRPhoneOwnerNotSet ) );
       
  2236 
       
  2237     return po->Address();
       
  2238     }
       
  2239 
       
  2240 // ---------------------------------------------------------------------------
       
  2241 // CESMRMeetingRequestEntry::MailboxUtils
       
  2242 // ---------------------------------------------------------------------------
       
  2243 //
       
  2244 CMRMailboxUtils& CESMRMeetingRequestEntry::MailboxUtils() const
       
  2245     {
       
  2246     return iMRMailboxUtils;
       
  2247     }
       
  2248 
       
  2249 // ---------------------------------------------------------------------------
       
  2250 // CESMRMeetingRequestEntry::GetDBMgr
       
  2251 // ---------------------------------------------------------------------------
       
  2252 //
       
  2253 MESMRCalDbMgr& CESMRMeetingRequestEntry::GetDBMgr()
       
  2254     {
       
  2255     return iCalDb;
       
  2256     }
       
  2257 
       
  2258 // ---------------------------------------------------------------------------
       
  2259 // CESMRMeetingRequestEntry::SupportsCapabilityL
       
  2260 // ---------------------------------------------------------------------------
       
  2261 //
       
  2262 TBool CESMRMeetingRequestEntry::SupportsCapabilityL(
       
  2263         MESMRCalEntry::TMREntryCapability aCapability ) const
       
  2264     {
       
  2265     TBool retValue( EFalse );
       
  2266 
       
  2267     switch( aCapability )
       
  2268         {
       
  2269         case MESMRCalEntry::EMRCapabilityAttachments:
       
  2270             {
       
  2271             CESMRFsMailboxUtils* fsMbUtils =
       
  2272                     CESMRFsMailboxUtils::NewL( iMRMailboxUtils );
       
  2273             CleanupStack::PushL( fsMbUtils );
       
  2274 
       
  2275             retValue = fsMbUtils->DefaultMailboxSupportCapabilityL(
       
  2276                     CESMRFsMailboxUtils::EMRCapabilityAttachment );
       
  2277             CleanupStack::PopAndDestroy( fsMbUtils );
       
  2278             }
       
  2279             break;
       
  2280         }
       
  2281 
       
  2282     return retValue;
       
  2283     }
       
  2284 
       
  2285 // ---------------------------------------------------------------------------
       
  2286 // CESMRMeetingRequestEntry::ContainsRemoteAttachmentsL
       
  2287 // ---------------------------------------------------------------------------
       
  2288 //
       
  2289 TBool CESMRMeetingRequestEntry::ContainsRemoteAttachmentsL()
       
  2290     {
       
  2291     FUNC_LOG;
       
  2292 
       
  2293     TBool retValue( EFalse );
       
  2294 
       
  2295     TInt attachmentCount( iEntry->AttachmentCountL() );
       
  2296 
       
  2297     for ( TInt i(0); i < attachmentCount && !retValue; ++i )
       
  2298         {
       
  2299         CCalAttachment* attachment = iEntry->AttachmentL(i);
       
  2300         CCalAttachment::TType type( attachment->Type() );
       
  2301 
       
  2302         if ( CCalAttachment::EFile != type )
       
  2303             {
       
  2304             retValue = ETrue;
       
  2305             }
       
  2306         }
       
  2307 
       
  2308     return retValue;
       
  2309     }
       
  2310 
       
  2311 // ---------------------------------------------------------------------------
       
  2312 // CESMRMeetingRequestEntry::SendCanellationAvailable
       
  2313 // ---------------------------------------------------------------------------
       
  2314 //
       
  2315 TBool CESMRMeetingRequestEntry::SendCanellationAvailable ()
       
  2316 	{
       
  2317 	return iSendCanellation;
       
  2318 	}
       
  2319 
       
  2320 // ---------------------------------------------------------------------------
       
  2321 // CESMRMeetingRequestEntry::SetSendCanellationAvailable
       
  2322 // ---------------------------------------------------------------------------
       
  2323 //
       
  2324 void CESMRMeetingRequestEntry::SetSendCanellationAvailable (
       
  2325         TBool aSendCanellation )
       
  2326 	{
       
  2327 	iSendCanellation = aSendCanellation;
       
  2328 	}
       
  2329 
       
  2330 // ---------------------------------------------------------------------------
       
  2331 // CESMRMeetingRequestEntry::SetTypeChanged
       
  2332 // ---------------------------------------------------------------------------
       
  2333 //
       
  2334 void CESMRMeetingRequestEntry::SetTypeChanged( TBool aTypeChanged )
       
  2335     {
       
  2336     FUNC_LOG;
       
  2337 
       
  2338     iTypeChanged = aTypeChanged;
       
  2339     }
       
  2340 
       
  2341 // ---------------------------------------------------------------------------
       
  2342 // CESMRMeetingRequestEntry::SetDefaultDatabaseL
       
  2343 // ---------------------------------------------------------------------------
       
  2344 //
       
  2345 void CESMRMeetingRequestEntry::SetDefaultDatabaseL()
       
  2346     {
       
  2347     FUNC_LOG;
       
  2348 
       
  2349     if ( !IsStoredL() )
       
  2350         {
       
  2351         // If entry has not been stored, set database manager to use correct
       
  2352         // database supported by plugin sync solution.
       
  2353         CESMRFsMailboxUtils* fsMbUtils =
       
  2354                 CESMRFsMailboxUtils::NewL( iMRMailboxUtils );
       
  2355         CleanupStack::PushL( fsMbUtils );
       
  2356         TCalFileId aDbId( KNullFileId );
       
  2357         fsMbUtils->GetCalendarDatabaseIdL( CurrentPluginL(), aDbId );
       
  2358         CleanupStack::PopAndDestroy( fsMbUtils );
       
  2359 
       
  2360         if ( aDbId != KNullFileId )
       
  2361             {
       
  2362             iCalDb.SetCurCalendarByDbIdL( aDbId );
       
  2363             }
       
  2364         else if ( CurrentPluginL() == EESMRActiveSync )
       
  2365             {
       
  2366             _LIT( KMfeDb, "Mail for Exchange" );
       
  2367             iCalDb.SetCurCalendarByNameL( KMfeDb );
       
  2368             }
       
  2369         }
       
  2370     }
       
  2371 
       
  2372 // EOF