meetingrequest/mricalviewer/src/cesmrmrinfoicalretriever.cpp
branchRCL_3
changeset 12 4ce476e64c59
parent 8 e1b6206813b4
child 16 b5fbb9b25d57
equal deleted inserted replaced
11:0396474f30f5 12:4ce476e64c59
     1 /*
     1 /*
     2 * Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies). 
     2 * Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
     3 * All rights reserved.
     3 * All rights reserved.
     4 * This component and the accompanying materials are made available
     4 * This component and the accompanying materials are made available
     5 * under the terms of "Eclipse Public License v1.0"
     5 * under the terms of "Eclipse Public License v1.0"
     6 * which accompanies this distribution, and is available
     6 * which accompanies this distribution, and is available
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
    17 
    17 
    18 
    18 
    19 #include "emailtrace.h"
    19 #include "emailtrace.h"
    20 #include "cesmrmrinfoicalretriever.h"
    20 #include "cesmrmrinfoicalretriever.h"
    21 #include "cesmrinforecurrencehandler.h"
    21 #include "cesmrinforecurrencehandler.h"
    22 #include "cesmrattachmentinfo.h"
       
    23 #include "mesmricalviewerobserver.h"
    22 #include "mesmricalviewerobserver.h"
    24 #include "tesmrinputparams.h"
    23 #include "tesmrinputparams.h"
    25 #include "esmricalviewerutils.h"
    24 #include "esmricalviewerutils.h"
    26 #include "esmrconfig.hrh"
    25 #include "esmrconfig.hrh"
    27 
    26 
    38 //</cmail>
    37 //</cmail>
    39 
    38 
    40 #include <calentry.h>
    39 #include <calentry.h>
    41 #include <caluser.h>
    40 #include <caluser.h>
    42 #include <calalarm.h>
    41 #include <calalarm.h>
    43 #include <CalenInterimUtils2.h>
    42 #include <caleninterimutils2.h>
    44 #include <utf.h>
    43 #include <utf.h>
    45 
    44 
    46 // Unnamed namespace for local definitions and functions
    45 // Unnamed namespace for local definitions and functions
    47 namespace {
    46 namespace {
    48 
    47 
   325 CESMRInfoIcalRetrieverCmd::~CESMRInfoIcalRetrieverCmd()
   324 CESMRInfoIcalRetrieverCmd::~CESMRInfoIcalRetrieverCmd()
   326     {
   325     {
   327     FUNC_LOG;
   326     FUNC_LOG;
   328     iSupportedFields.Reset();
   327     iSupportedFields.Reset();
   329     iSupportedFields.Close();
   328     iSupportedFields.Close();
   330     delete iAttachmentInfo;
       
   331     delete iConvertedEntry;
   329     delete iConvertedEntry;
   332     }
   330     }
   333 
   331 
   334 // ---------------------------------------------------------------------------
   332 // ---------------------------------------------------------------------------
   335 // CESMRInfoIcalRetriever::NewL
   333 // CESMRInfoIcalRetriever::NewL
   389 
   387 
   390         if ( !IsModifyingEntryL( *iMRInfoObject ) )
   388         if ( !IsModifyingEntryL( *iMRInfoObject ) )
   391             {
   389             {
   392             FillRecurrenceL();
   390             FillRecurrenceL();
   393             }
   391             }
   394 
       
   395         FillAttachmentInfoL();
       
   396 
   392 
   397         // Fill input parameters
   393         // Fill input parameters
   398         // Ownership is not trasferred
   394         // Ownership is not trasferred
   399         iInputParameters.iCalEntry = iConvertedEntry;
   395         iInputParameters.iCalEntry = iConvertedEntry;
   400 
   396 
   584         TInt err = start.MinutesFrom(alarmTime, minutesBetween);
   580         TInt err = start.MinutesFrom(alarmTime, minutesBetween);
   585 
   581 
   586         if ( KErrNone == err && minutesBetween.Int() > 0 )
   582         if ( KErrNone == err && minutesBetween.Int() > 0 )
   587             {
   583             {
   588             alarm->SetTimeOffset( minutesBetween );
   584             alarm->SetTimeOffset( minutesBetween );
   589             // this method copies alarm details and does not take ownership 
   585             // this method copies alarm details and does not take ownership
   590             iConvertedEntry->SetAlarmL( alarm );
   586             iConvertedEntry->SetAlarmL( alarm );
   591             }
   587             }
   592         // that's why we can destroy it here
   588         // that's why we can destroy it here
   593         CleanupStack::PopAndDestroy( alarm );
   589         CleanupStack::PopAndDestroy( alarm );
   594         }
   590         }
   631 
   627 
   632         CleanupStack::PopAndDestroy( recurrenceHandler );
   628         CleanupStack::PopAndDestroy( recurrenceHandler );
   633         }
   629         }
   634     }
   630     }
   635 
   631 
   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
   632 // EOF
   706 
   633