meetingrequest/mricalviewer/src/cesmrmrinfoicalretriever.cpp
changeset 0 8466d47a6819
child 8 e1b6206813b4
equal deleted inserted replaced
-1:000000000000 0:8466d47a6819
       
     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 mrinfo calendar entry retriever implementation
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #include "emailtrace.h"
       
    20 #include "cesmrmrinfoicalretriever.h"
       
    21 #include "cesmrinforecurrencehandler.h"
       
    22 #include "cesmrattachmentinfo.h"
       
    23 #include "mesmricalviewerobserver.h"
       
    24 #include "tesmrinputparams.h"
       
    25 #include "esmricalviewerutils.h"
       
    26 #include "esmrconfig.hrh"
       
    27 
       
    28 //<cmail>
       
    29 #include "esmricalvieweropcodes.hrh"
       
    30 #include "CFSMailClient.h"
       
    31 #include "CFSMailBox.h"
       
    32 #include "CFSMailMessage.h"
       
    33 #include "CFSMailMessagePart.h"
       
    34 #include "CFSMailCommon.h"
       
    35 #include "mmrinfoprocessor.h"
       
    36 #include "mmrattendee.h"
       
    37 #include "mmrrecurrencerule.h"
       
    38 //</cmail>
       
    39 
       
    40 #include <calentry.h>
       
    41 #include <caluser.h>
       
    42 #include <calalarm.h>
       
    43 #include <CalenInterimUtils2.h>
       
    44 #include <utf.h>
       
    45 
       
    46 // Unnamed namespace for local definitions and functions
       
    47 namespace {
       
    48 
       
    49 /**
       
    50  * Raises system leave if parameter is different than KErrNone.
       
    51  *
       
    52  * @param aError Error code
       
    53  */
       
    54 void LeaveIfError( TInt aError )
       
    55     {
       
    56     if ( KErrNone != aError )
       
    57         {
       
    58 
       
    59         User::Leave( aError );
       
    60         }
       
    61     }
       
    62 
       
    63 /**
       
    64  * Tests if certain field is supported by MRINFO object.
       
    65  * @param aFields Reference to MRINFO fields'
       
    66  * @param aFieldType Tested fieldtype
       
    67  */
       
    68 TBool IsFieldSupported(
       
    69         RArray<MMRInfoObject::TESMRInfoField>& aFields,
       
    70         MMRInfoObject::TESMRInfoField aFieldType)
       
    71     {
       
    72     TInt fieldSupported( ETrue );
       
    73 
       
    74     TInt fieldCount( aFields.Count() );
       
    75     for (TInt i=0; i < fieldCount; ++i)
       
    76         {
       
    77         if (aFields[i] == aFieldType)
       
    78             {
       
    79             fieldSupported = ETrue;
       
    80             break;
       
    81             }
       
    82         }
       
    83     return fieldSupported;
       
    84     }
       
    85 
       
    86 /**
       
    87  * Converts MRINFO method to CCalEntry method.
       
    88  * @param aMRMethod MRINFO method.
       
    89  * @return CCalEntry method.
       
    90  */
       
    91 CCalEntry::TMethod ConverMRMethodToCalEntryMethod(
       
    92         MMRInfoObject::TMRMethod aMRMethod )
       
    93     {
       
    94     CCalEntry::TMethod ret(CCalEntry::EMethodNone);
       
    95     switch (aMRMethod)
       
    96         {
       
    97         case MMRInfoObject::EMRMethodRequest:
       
    98             {
       
    99             ret = CCalEntry::EMethodRequest;
       
   100             break;
       
   101             }
       
   102          case MMRInfoObject::EMRMethodCancel:
       
   103             {
       
   104             ret = CCalEntry::EMethodCancel;
       
   105             break;
       
   106             }
       
   107          case MMRInfoObject::EMRMethodResponse:
       
   108             {
       
   109             ret = CCalEntry::EMethodReply;
       
   110             break;
       
   111             }
       
   112          default:
       
   113             break;
       
   114         }
       
   115     return ret;
       
   116     }
       
   117 
       
   118 /**
       
   119  * Converts MMRINFO response status to CCalEntry response status.
       
   120  * @param aMRResponseStatus MRINFO response status.
       
   121  * @return CCalEntry response status.
       
   122  */
       
   123 CCalEntry::TStatus ConvertMRResponseToCalEntryStatus(
       
   124         MMRInfoObject::TResponse aMRResponseStatus )
       
   125     {
       
   126     FUNC_LOG;
       
   127     CCalEntry::TStatus ret(CCalEntry::ENullStatus);
       
   128     switch (aMRResponseStatus)
       
   129         {
       
   130         case MMRInfoObject::EMrCmdResponseAccept:
       
   131             {
       
   132             ret = CCalEntry::EConfirmed;
       
   133             break;
       
   134             }
       
   135          case MMRInfoObject::EMrCmdResponseTentative:
       
   136             {
       
   137             ret = CCalEntry::ETentative;
       
   138             break;
       
   139             }
       
   140          case MMRInfoObject::EMrCmdResponseDecline:
       
   141             {
       
   142             ret = CCalEntry::ECancelled;
       
   143             break;
       
   144             }
       
   145          default:
       
   146             break;
       
   147         }
       
   148     return ret;
       
   149     }
       
   150 
       
   151 /**
       
   152  * Converts MRINFO attendee role to MRINFO attendee role.
       
   153  * @param aMRRole MRINFO attendee role.
       
   154  * @return CCalEntry attendee role.
       
   155  */
       
   156 CCalAttendee::TCalRole ConvertMRAttendeeRoleToCalEntryRole(
       
   157         MMRAttendee::TAttendeeRole aMRRole)
       
   158     {
       
   159     CCalAttendee::TCalRole ret(CCalAttendee::ENonParticipant);
       
   160     switch (aMRRole)
       
   161         {
       
   162         case MMRAttendee::EMRAttendeeNotSet:
       
   163             {
       
   164             ret = CCalAttendee::ENonParticipant;
       
   165             break;
       
   166             }
       
   167          case MMRAttendee::EMRAttendeeChair:
       
   168             {
       
   169             ret = CCalAttendee::EChair;
       
   170             break;
       
   171             }
       
   172          case MMRAttendee::EMRAttendeeParticipant:
       
   173             {
       
   174             ret = CCalAttendee::EReqParticipant;
       
   175             break;
       
   176             }
       
   177          case MMRAttendee::EMRAttendeeOptionalParticipant:
       
   178             {
       
   179             ret = CCalAttendee::EOptParticipant;
       
   180             break;
       
   181             }
       
   182          case MMRAttendee::EMRAttendeeNonParticipant:
       
   183             {
       
   184             ret = CCalAttendee::ENonParticipant;
       
   185             break;
       
   186             }
       
   187          default:
       
   188             break;
       
   189         }
       
   190     return ret;
       
   191     }
       
   192 
       
   193 /**
       
   194  * Converts MMRINFO response status to CCalEntry response status.
       
   195  * @param aMRStatus MRINFO response status.
       
   196  * @return CCalEntry response status.
       
   197  */
       
   198 CCalAttendee::TCalStatus ConvertMRAttendeeStatusToCalEntryStatus(
       
   199         MMRAttendee::TAttendeeStatus aMRStatus )
       
   200     {
       
   201     FUNC_LOG;
       
   202     CCalAttendee::TCalStatus ret(CCalAttendee::ENeedsAction);
       
   203     switch (aMRStatus)
       
   204         {
       
   205         case MMRAttendee::EMRAttendeeActionNotSet:
       
   206             {
       
   207             ret = CCalAttendee::ENeedsAction;
       
   208             break;
       
   209             }
       
   210          case MMRAttendee::EMRAttendeeActionNeeded:
       
   211             {
       
   212             ret = CCalAttendee::ENeedsAction;
       
   213             break;
       
   214             }
       
   215          case MMRAttendee::EMRAttendeeActionAccepted:
       
   216             {
       
   217             ret = CCalAttendee::EAccepted;
       
   218             break;
       
   219             }
       
   220          case MMRAttendee::EMRAttendeeActionTentative:
       
   221             {
       
   222             ret = CCalAttendee::ETentative;
       
   223             break;
       
   224             }
       
   225          case MMRAttendee::EMRAttendeeActionConfirmed:
       
   226             {
       
   227             ret = CCalAttendee::EConfirmed;
       
   228             break;
       
   229             }
       
   230          case MMRAttendee::EMRAttendeeActionDeclined:
       
   231             {
       
   232             ret = CCalAttendee::EDeclined;
       
   233             break;
       
   234             }
       
   235         case MMRAttendee::EMRAttendeeActionCompleted:
       
   236             {
       
   237             ret = CCalAttendee::ECompleted;
       
   238             break;
       
   239             }
       
   240         default:
       
   241            break;
       
   242         }
       
   243     return ret;
       
   244     }
       
   245 
       
   246 /**
       
   247  * Copies attendees from MRINFO object to CCalEntry object.
       
   248  * @param attendeesArray array of meeting request attendees
       
   249  * @param calendar entry of the meeting request
       
   250  */
       
   251 void FillAttendeesL(
       
   252         RPointerArray<MMRAttendee>& attendeesArray,
       
   253         CCalEntry& aEntry)
       
   254     {
       
   255 
       
   256     CCalAttendee* attendee = NULL;
       
   257     TInt attendeeArrayCount( attendeesArray.Count() );
       
   258     for (TInt i=0; i < attendeeArrayCount; ++i)
       
   259         {
       
   260         // New attendee + address
       
   261         attendee = CCalAttendee::NewL( attendeesArray[i]->Address() );
       
   262         CleanupStack::PushL(attendee);
       
   263         // Common name:
       
   264         if ( attendeesArray[i]->CommonName().Length() > 0 )
       
   265             {
       
   266             attendee->SetCommonNameL( attendeesArray[i]->CommonName() );
       
   267             }
       
   268 
       
   269         // Set attendeee role:
       
   270         attendee->SetRoleL(
       
   271                 ConvertMRAttendeeRoleToCalEntryRole(
       
   272                         attendeesArray[i]->AttendeeRole() ) );
       
   273 
       
   274         // add attendee status:
       
   275         attendee->SetStatusL(
       
   276                 ConvertMRAttendeeStatusToCalEntryStatus(
       
   277                         attendeesArray[i]->AttendeeStatus() ) );
       
   278 
       
   279         // add attendee to entry
       
   280         aEntry.AddAttendeeL( attendee );
       
   281         CleanupStack::Pop(attendee);
       
   282         }
       
   283     }
       
   284 
       
   285 /**
       
   286  * Tests if MRINFO object is modifying entry
       
   287  * @param aEntry Reference to MRINFO object.
       
   288  */
       
   289 TBool IsModifyingEntryL(
       
   290         MMRInfoObject& aEntry )
       
   291     {
       
   292     TBool modifying( EFalse );
       
   293     TTime recurrenceId = aEntry.MRRecurrenceId();
       
   294 
       
   295     if ( recurrenceId != Time::NullTTime() )
       
   296         {
       
   297         modifying = ETrue;
       
   298         }
       
   299 
       
   300     return modifying;
       
   301     }
       
   302 
       
   303 }//namespace
       
   304 
       
   305 // ======== MEMBER FUNCTIONS ========
       
   306 
       
   307 // ---------------------------------------------------------------------------
       
   308 // CESMRInfoIcalRetrieverCmd::CESMRInfoIcalRetrieverCmd
       
   309 // ---------------------------------------------------------------------------
       
   310 //
       
   311 CESMRInfoIcalRetrieverCmd::CESMRInfoIcalRetrieverCmd(
       
   312         CCalSession& aCalSession,
       
   313         TESMRInputParams& aInputParameters )
       
   314 :   CESMRIcalViewerCommandBase( EESMRLoadMRInfoData, aCalSession ),
       
   315     iInputParameters( aInputParameters )
       
   316     {
       
   317     FUNC_LOG;
       
   318     //do nothing
       
   319     }
       
   320 
       
   321 // ---------------------------------------------------------------------------
       
   322 // CESMRInfoIcalRetrieverCmd::~CESMRInfoIcalRetrieverCmd
       
   323 // ---------------------------------------------------------------------------
       
   324 //
       
   325 CESMRInfoIcalRetrieverCmd::~CESMRInfoIcalRetrieverCmd()
       
   326     {
       
   327     FUNC_LOG;
       
   328     iSupportedFields.Reset();
       
   329     iSupportedFields.Close();
       
   330     delete iAttachmentInfo;
       
   331     delete iConvertedEntry;
       
   332     }
       
   333 
       
   334 // ---------------------------------------------------------------------------
       
   335 // CESMRInfoIcalRetriever::NewL
       
   336 // ---------------------------------------------------------------------------
       
   337 //
       
   338 CESMRInfoIcalRetrieverCmd* CESMRInfoIcalRetrieverCmd::NewL(
       
   339         CCalSession& aCalSession,
       
   340         TESMRInputParams& aInputParameters )
       
   341     {
       
   342     FUNC_LOG;
       
   343     CESMRInfoIcalRetrieverCmd* self =
       
   344             new (ELeave) CESMRInfoIcalRetrieverCmd( aCalSession, aInputParameters );
       
   345     CleanupStack::PushL( self );
       
   346     self->ConstructL();
       
   347     CleanupStack::Pop( self );
       
   348     return self;
       
   349     }
       
   350 
       
   351 // ---------------------------------------------------------------------------
       
   352 // CESMRInfoIcalRetrieverCmd::ConstructL
       
   353 // ---------------------------------------------------------------------------
       
   354 //
       
   355 void CESMRInfoIcalRetrieverCmd::ConstructL()
       
   356     {
       
   357     FUNC_LOG;
       
   358     //do nothing
       
   359     }
       
   360 
       
   361 // ---------------------------------------------------------------------------
       
   362 // CESMRInfoIcalRetriever::ExecuteCommandL
       
   363 // ---------------------------------------------------------------------------
       
   364 //
       
   365 void CESMRInfoIcalRetrieverCmd::ExecuteCommandL(
       
   366         CFSMailMessage& aMessage,
       
   367         MESMRIcalViewerObserver& aObserver )
       
   368     {
       
   369     FUNC_LOG;
       
   370     SetMessage( &aMessage );
       
   371     SetObserver( &aObserver );
       
   372 
       
   373     iResult.iOpType     = OperationType();
       
   374     iResult.iResultCode = KErrNone;
       
   375     iResult.iMessage    = &aMessage;
       
   376 
       
   377     // Fetch MRINFO object
       
   378     if ( !aMessage.IsMRInfoSet() )
       
   379         {
       
   380         iResult.iResultCode = KErrNotFound;
       
   381         aObserver.OperationError( iResult );
       
   382         }
       
   383     else
       
   384         {
       
   385         iMRInfoObject =  &(aMessage.GetMRInfo());
       
   386 
       
   387         CreateEntryL();
       
   388         FillCommonFieldsL();
       
   389 
       
   390         if ( !IsModifyingEntryL( *iMRInfoObject ) )
       
   391             {
       
   392             FillRecurrenceL();
       
   393             }
       
   394 
       
   395         FillAttachmentInfoL();
       
   396 
       
   397         // Fill input parameters
       
   398         // Ownership is not trasferred
       
   399         iInputParameters.iCalEntry = iConvertedEntry;
       
   400 
       
   401         iInputParameters.iMRInfoObject = iMRInfoObject;
       
   402         iMRInfoObject = NULL;
       
   403 
       
   404         aObserver.OperationCompleted( iResult );
       
   405         }
       
   406     }
       
   407 
       
   408 // ---------------------------------------------------------------------------
       
   409 // CESMRInfoIcalRetrieverCmd::CancelCommand
       
   410 // ---------------------------------------------------------------------------
       
   411 //
       
   412 void CESMRInfoIcalRetrieverCmd::CancelCommand()
       
   413     {
       
   414     FUNC_LOG;
       
   415     // No implementation required because this is synchronous command
       
   416     }
       
   417 
       
   418 // ---------------------------------------------------------------------------
       
   419 // CESMRInfoIcalRetrieverCmd::CreateEntryL
       
   420 // ---------------------------------------------------------------------------
       
   421 //
       
   422 void CESMRInfoIcalRetrieverCmd::CreateEntryL()
       
   423     {
       
   424     FUNC_LOG;
       
   425     iMRInfoObject->SupportedFields( iSupportedFields );
       
   426 
       
   427     HBufC8* uid8 = NULL;        // buffer for UID
       
   428     TInt seqNum(0);             // Sequence Number
       
   429     CCalEntry::TMethod method( CCalEntry::EMethodNone );  // Method
       
   430 
       
   431     // fetch the UID
       
   432     if (IsFieldSupported(iSupportedFields, MMRInfoObject::EESMRInfoFieldId))
       
   433         {
       
   434         // CnvUtfConverter
       
   435         TPtrC uid16( iMRInfoObject->UidL() );
       
   436         uid8 = CnvUtfConverter::ConvertFromUnicodeToUtf8L( uid16 );
       
   437 
       
   438         CleanupStack::PushL( uid8 );
       
   439         }
       
   440     else
       
   441         {
       
   442         User::Leave( KErrCorrupt );
       
   443         }
       
   444 
       
   445     // Fetch the sequence nunber
       
   446     if (IsFieldSupported(iSupportedFields, MMRInfoObject::EESMRInfoFieldSeqNo))
       
   447         {
       
   448         seqNum = iMRInfoObject->MRSequenceNumberL();
       
   449         }
       
   450 
       
   451     // Fetch the method
       
   452     if ( IsFieldSupported(iSupportedFields, MMRInfoObject::EESMRInfoFieldMethod) )
       
   453         {
       
   454         MMRInfoObject::TMRMethod mrMethod = iMRInfoObject->MRMethodL();
       
   455         method = ConverMRMethodToCalEntryMethod(mrMethod);
       
   456         if (method == CCalEntry::EMethodNone)
       
   457             {
       
   458             LeaveIfError( KErrCorrupt );
       
   459             }
       
   460         }
       
   461     else
       
   462         {
       
   463         LeaveIfError( KErrCorrupt );
       
   464         }
       
   465 
       
   466     // create new entry:
       
   467     delete iConvertedEntry; iConvertedEntry = NULL;
       
   468 
       
   469     if ( !IsModifyingEntryL( *iMRInfoObject ) )
       
   470         {
       
   471         iConvertedEntry = CCalEntry::NewL (CCalEntry::EAppt,
       
   472                                             uid8,
       
   473                                             method,
       
   474                                             seqNum );
       
   475         }
       
   476     else
       
   477         {
       
   478         TBool seqNoSupported(
       
   479                 IsFieldSupported( iSupportedFields, MMRInfoObject::EESMRInfoFieldSeqNo ) );
       
   480 
       
   481         if( !seqNoSupported )
       
   482             {
       
   483              LeaveIfError( KErrCorrupt );
       
   484             }
       
   485 
       
   486         TInt seqwNo( iMRInfoObject->MRSequenceNumberL() );
       
   487         TCalTime recurrenceID;
       
   488         recurrenceID.SetTimeLocalL( iMRInfoObject->MRRecurrenceId() );
       
   489 
       
   490         iConvertedEntry = CCalEntry::NewL(
       
   491                                 CCalEntry::EAppt,
       
   492                                 uid8,
       
   493                                 method,
       
   494                                 seqwNo,
       
   495                                 recurrenceID,
       
   496                                 CalCommon::EThisOnly );
       
   497         }
       
   498 
       
   499     CleanupStack::Pop(uid8 );
       
   500     }
       
   501 
       
   502 // ---------------------------------------------------------------------------
       
   503 // CESMRInfoIcalRetrieverCmd::FillCommonFieldsL
       
   504 // ---------------------------------------------------------------------------
       
   505 //
       
   506 void CESMRInfoIcalRetrieverCmd::FillCommonFieldsL()
       
   507     {
       
   508     FUNC_LOG;
       
   509     if (IsFieldSupported(
       
   510             iSupportedFields,
       
   511             MMRInfoObject::EESMRInfoFieldMStatus))
       
   512         {
       
   513         CCalEntry::TStatus status =
       
   514             ConvertMRResponseToCalEntryStatus(iMRInfoObject->MRResponse());
       
   515         iConvertedEntry->SetStatusL(status);
       
   516         }
       
   517 
       
   518     if (IsFieldSupported(
       
   519                 iSupportedFields,
       
   520                 MMRInfoObject::EESMRInfoFieldCreationDateTime))
       
   521         {
       
   522         TTime creationTime = iMRInfoObject->CreationTimeInUtcL();
       
   523         iConvertedEntry->SetLastModifiedDateL();
       
   524         }
       
   525 
       
   526     if (IsFieldSupported(
       
   527                 iSupportedFields,
       
   528                 MMRInfoObject::EESMRInfoFieldOrganizer))
       
   529         {
       
   530         MMROrganizer* mrOrganizer = &iMRInfoObject->MROrganizerL();
       
   531         CCalUser* organizer = CCalUser::NewL(mrOrganizer->Address());
       
   532         CleanupStack::PushL(organizer);
       
   533         if ( mrOrganizer->CommonName().Length() > 0 )
       
   534             {
       
   535             organizer->SetCommonNameL(mrOrganizer->CommonName());
       
   536             }
       
   537 
       
   538         iConvertedEntry->SetOrganizerL(organizer);
       
   539         CleanupStack::Pop(organizer);
       
   540         }
       
   541 
       
   542     if (IsFieldSupported(
       
   543             iSupportedFields, MMRInfoObject::EESMRInfoFieldAttendee) ||
       
   544         IsFieldSupported(
       
   545                 iSupportedFields, MMRInfoObject::EESMRInfoFieldOptAttendee) )
       
   546         {
       
   547         RPointerArray<MMRAttendee> attendeesArray = iMRInfoObject->AttendeesL();
       
   548         // go through attendee array and append attendees
       
   549         FillAttendeesL(attendeesArray, *iConvertedEntry );
       
   550         }
       
   551 
       
   552     if (IsFieldSupported(iSupportedFields, MMRInfoObject::EESMRInfoFieldStartDateTime) &&
       
   553         IsFieldSupported(iSupportedFields, MMRInfoObject::EESMRInfoFieldStopDateTime) )
       
   554         {
       
   555         TTime start = iMRInfoObject->StartTimeInUtcL();
       
   556         TTime end = iMRInfoObject->EndTimeInUtcL();
       
   557         TCalTime calStart;
       
   558         calStart.SetTimeUtcL(start);
       
   559         TCalTime calEnd;
       
   560         calEnd.SetTimeUtcL(end);
       
   561         iConvertedEntry->SetStartAndEndTimeL(calStart, calEnd);
       
   562         }
       
   563 
       
   564 
       
   565     if (IsFieldSupported(iSupportedFields, MMRInfoObject::EESMRInfoFieldLocation))
       
   566         {
       
   567         TPtrC location( iMRInfoObject->LocationL() );
       
   568         iConvertedEntry->SetLocationL( location );
       
   569         }
       
   570 
       
   571     if ( IsFieldSupported(iSupportedFields, MMRInfoObject::EESMRInfoFieldStartDateTime) &&
       
   572          IsFieldSupported(iSupportedFields, MMRInfoObject::EESMRInfoFieldAlarm))
       
   573         {
       
   574         CCalAlarm* alarm = CCalAlarm::NewL();
       
   575         CleanupStack::PushL( alarm );
       
   576 
       
   577         TTime start = iMRInfoObject->StartTimeInUtcL();
       
   578         TTime alarmTime = iMRInfoObject->AlarmInUtcL();
       
   579 
       
   580         TDateTime startDateTime = start.DateTime();
       
   581         TDateTime alarmDateTime = alarmTime.DateTime();
       
   582 
       
   583         TTimeIntervalMinutes minutesBetween;
       
   584         TInt err = start.MinutesFrom(alarmTime, minutesBetween);
       
   585 
       
   586         if ( KErrNone == err && minutesBetween.Int() > 0 )
       
   587             {
       
   588             alarm->SetTimeOffset( minutesBetween );
       
   589             // this method copies alarm details and does not take ownership 
       
   590             iConvertedEntry->SetAlarmL( alarm );
       
   591             }
       
   592         // that's why we can destroy it here
       
   593         CleanupStack::PopAndDestroy( alarm );
       
   594         }
       
   595 
       
   596     if (IsFieldSupported(iSupportedFields, MMRInfoObject::EESMRInfoFieldSubject))
       
   597         {
       
   598         TPtrC summary( iMRInfoObject->SubjectL() );
       
   599         iConvertedEntry->SetSummaryL(summary);
       
   600         }
       
   601 
       
   602     if (IsFieldSupported(iSupportedFields, MMRInfoObject::EESMRInfoFieldDescription))
       
   603         {
       
   604         TPtrC description( iMRInfoObject->DescriptionL() );
       
   605         iConvertedEntry->SetDescriptionL(description);
       
   606         }
       
   607 
       
   608     if (IsFieldSupported(iSupportedFields, MMRInfoObject::EESMRInfoFieldPriority))
       
   609         {
       
   610         iConvertedEntry->SetPriorityL( iMRInfoObject->PriorityL() );
       
   611         }
       
   612     }
       
   613 
       
   614 // ---------------------------------------------------------------------------
       
   615 // CESMRInfoIcalRetrieverCmd::FillCommonFieldsL
       
   616 // ---------------------------------------------------------------------------
       
   617 //
       
   618 void CESMRInfoIcalRetrieverCmd::FillRecurrenceL()
       
   619     {
       
   620     FUNC_LOG;
       
   621     if (IsFieldSupported(
       
   622             iSupportedFields,
       
   623             MMRInfoObject::EESMRInfoFieldRecurrence))
       
   624         {
       
   625         CESMRInfoRecurrenceHandler* recurrenceHandler =
       
   626                 CESMRInfoRecurrenceHandler::NewLC();
       
   627 
       
   628         recurrenceHandler->ParseRecurrenceInforationL(
       
   629                     *iConvertedEntry,
       
   630                     *iMRInfoObject );
       
   631 
       
   632         CleanupStack::PopAndDestroy( recurrenceHandler );
       
   633         }
       
   634     }
       
   635 
       
   636 // ---------------------------------------------------------------------------
       
   637 // CESMRInfoIcalRetrieverCmd::FillAttachmentInfoL
       
   638 // ---------------------------------------------------------------------------
       
   639 //
       
   640 void CESMRInfoIcalRetrieverCmd::FillAttachmentInfoL()
       
   641     {
       
   642     FUNC_LOG;
       
   643     CFSMailMessage* msg = Message();
       
   644 
       
   645     if ( msg->IsFlagSet( EFSMsgFlag_Attachments ) )
       
   646         {
       
   647         RPointerArray<CFSMailMessagePart> attachmentParts;
       
   648         CleanupStack::PushL(
       
   649                 TCleanupItem(
       
   650                     ESMRIcalViewerUtils::MessagePartPointerArrayCleanup,
       
   651                     &attachmentParts    ) );
       
   652 
       
   653         msg->AttachmentListL( attachmentParts );
       
   654 
       
   655         TInt attachmentCount( attachmentParts.Count() );
       
   656         if ( attachmentCount > 0 )
       
   657             {
       
   658             delete iAttachmentInfo;
       
   659             iAttachmentInfo = NULL;
       
   660             
       
   661             iInputParameters.iAttachmentInfo = NULL;
       
   662 
       
   663             CESMRAttachmentInfo* attachmentInfo = CESMRAttachmentInfo::NewL();
       
   664             CleanupStack::PushL( attachmentInfo );
       
   665 
       
   666             for( TInt i(0); i < attachmentCount; ++i )
       
   667                 {
       
   668                 CESMRAttachment::TESMRAttachmentState state(
       
   669                         CESMRAttachment::EAttachmentStateDownloaded );
       
   670 
       
   671                 if ( EFSFull != attachmentParts[i]->FetchLoadState() )
       
   672                     {
       
   673                     state = CESMRAttachment::EAttachmentStateNotDownloaded;
       
   674                     }
       
   675 
       
   676                 TInt contentSize( attachmentParts[i]->ContentSize() );
       
   677                 TPtrC attachmentName( attachmentParts[i]->AttachmentNameL() );
       
   678                 if ( contentSize >= 0 && attachmentName.Length() )
       
   679                     {
       
   680                     attachmentInfo->AddAttachmentInfoL(
       
   681                             attachmentName,
       
   682                             contentSize,
       
   683                             state );
       
   684                     }
       
   685                 }
       
   686 
       
   687             if ( attachmentInfo->AttachmentCount() )
       
   688                 {
       
   689                 iAttachmentInfo = attachmentInfo;
       
   690                 CleanupStack::Pop( attachmentInfo );
       
   691                 // ownership does not change
       
   692                 iInputParameters.iAttachmentInfo = iAttachmentInfo;
       
   693                 }
       
   694             else
       
   695                 {
       
   696                 CleanupStack::PopAndDestroy( attachmentInfo );
       
   697                 }
       
   698 
       
   699             attachmentInfo = NULL;
       
   700             }
       
   701         CleanupStack::PopAndDestroy(); // attachmentparts
       
   702         }
       
   703     }
       
   704 
       
   705 // EOF
       
   706