meetingrequest/mricalviewer/src/cesmrimapicalretriever.cpp
branchRCL_3
changeset 16 4ce476e64c59
parent 8 e1b6206813b4
child 24 b5fbb9b25d57
equal deleted inserted replaced
13:0396474f30f5 16: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 "cesmrimapicalretriever.h"
    20 #include "cesmrimapicalretriever.h"
    21 #include "cesmrimapmailfetcher.h"
    21 #include "cesmrimapmailfetcher.h"
    22 #include "cesmrattachmentinfo.h"
       
    23 #include "tesmrinputparams.h"
    22 #include "tesmrinputparams.h"
    24 #include "esmricalviewerutils.h"
    23 #include "esmricalviewerutils.h"
    25 #include "esmrconfig.hrh"
    24 #include "esmrconfig.hrh"
    26 
    25 
    27 //<cmail>
    26 //<cmail>
    38 #include "esmrhelper.h"
    37 #include "esmrhelper.h"
    39 //</cmail>
    38 //</cmail>
    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 <s32file.h>
    43 #include <s32file.h>
    45 #include <eikenv.h>
    44 #include <eikenv.h>
    46 
    45 
    47 // Unnamed namespace for local definitions
    46 // Unnamed namespace for local definitions
    48 namespace {
    47 namespace {
    50 // Mime type literal for text/calendar
    49 // Mime type literal for text/calendar
    51 _LIT8(  KTextCalendar8,  "text/calendar" );
    50 _LIT8(  KTextCalendar8,  "text/calendar" );
    52 
    51 
    53 // Literal for received ics filename
    52 // Literal for received ics filename
    54 //<cmail> hard coded path removal, store goes to process's own private directory
    53 //<cmail> hard coded path removal, store goes to process's own private directory
    55 //_LIT( KTempReceivedIcsFile, 
    54 //_LIT( KTempReceivedIcsFile,
    56 //	  "c:\\temp\\tempreceived.ics" ); //codescanner::driveletters
    55 //	  "c:\\temp\\tempreceived.ics" ); //codescanner::driveletters
    57 _LIT( KTempReceivedIcsFileName, "temp\\tempreceived.ics" );
    56 _LIT( KTempReceivedIcsFileName, "temp\\tempreceived.ics" );
    58 //</cmail>
    57 //</cmail>
    59 
    58 
    60 // Definition for temporary folder
    59 // Definition for temporary folder
    62 //_LIT( KTempFolder, "c:\\temp\\" ); //codescanner::driveletters
    61 //_LIT( KTempFolder, "c:\\temp\\" ); //codescanner::driveletters
    63 //</cmail>
    62 //</cmail>
    64 
    63 
    65 // Definition for first position
    64 // Definition for first position
    66 const TInt KFirstPos(0);
    65 const TInt KFirstPos(0);
    67 
       
    68 /**
       
    69  * Cleanup operations for RPointerArray.
       
    70  *
       
    71  * @param aArray Pointer to RPointerArray.
       
    72  */
       
    73 void MessagePartPointerArrayCleanup( TAny* aArray )
       
    74     {
       
    75     RPointerArray<CFSMailMessagePart>* messagePartArray =
       
    76         static_cast<RPointerArray<CFSMailMessagePart>*>( aArray );
       
    77 
       
    78     messagePartArray->ResetAndDestroy();
       
    79     messagePartArray->Close();
       
    80     }
       
    81 
    66 
    82 /**
    67 /**
    83  * Cleanup operations for RPointerArray.
    68  * Cleanup operations for RPointerArray.
    84  *
    69  *
    85  * @param aArray Pointer to RPointerArray.
    70  * @param aArray Pointer to RPointerArray.
   124     CancelCommand();
   109     CancelCommand();
   125     delete iCalImporter;
   110     delete iCalImporter;
   126     delete iMailFetcher;
   111     delete iMailFetcher;
   127     delete iConvertedEntry;
   112     delete iConvertedEntry;
   128     delete iIcsFilename;
   113     delete iIcsFilename;
   129     delete iAttachmentInfo;
       
   130     }
   114     }
   131 
   115 
   132 // ---------------------------------------------------------------------------
   116 // ---------------------------------------------------------------------------
   133 // CESMRImapIcalRetriever::NewL
   117 // CESMRImapIcalRetriever::NewL
   134 // ---------------------------------------------------------------------------
   118 // ---------------------------------------------------------------------------
   273         // message does not contain calendar part at all
   257         // message does not contain calendar part at all
   274         iResult.iResultCode = KErrNotFound;
   258         iResult.iResultCode = KErrNotFound;
   275         User::Leave( KErrNotFound );
   259         User::Leave( KErrNotFound );
   276         }
   260         }
   277     CleanupStack::PushL( calendarPart );
   261     CleanupStack::PushL( calendarPart );
   278     
   262 
   279     CreateEntryL( *calendarPart, *msg );
   263     CreateEntryL( *calendarPart, *msg );
   280     iInputParameters.iCalEntry = iConvertedEntry;
   264     iInputParameters.iCalEntry = iConvertedEntry;
   281     iCalendarPartId = calendarPart->GetPartId();
   265     iCalendarPartId = calendarPart->GetPartId();
   282 
       
   283     CheckAttachmentDataL( *message );
       
   284 
   266 
   285     CleanupStack::PopAndDestroy( calendarPart );
   267     CleanupStack::PopAndDestroy( calendarPart );
   286     CleanupStack::PopAndDestroy( message );
   268     CleanupStack::PopAndDestroy( message );
   287     }
   269     }
   288 
   270 
   365             CleanupStack::Pop( organizer ); // Ownership trasferred
   347             CleanupStack::Pop( organizer ); // Ownership trasferred
   366             }
   348             }
   367         }
   349         }
   368     }
   350     }
   369 
   351 
   370 // ---------------------------------------------------------------------------
       
   371 // CESMRImapIcalRetriever::CheckAttachmentDataL
       
   372 // ---------------------------------------------------------------------------
       
   373 //
       
   374 void CESMRImapIcalRetrieverCmd::CheckAttachmentDataL(
       
   375         CFSMailMessage& aMessage )
       
   376     {
       
   377     FUNC_LOG;
       
   378     if ( aMessage.IsFlagSet( EFSMsgFlag_Attachments ) )
       
   379         {
       
   380         RPointerArray<CFSMailMessagePart> attachmentParts;
       
   381         CleanupStack::PushL(
       
   382                 TCleanupItem(
       
   383                     MessagePartPointerArrayCleanup,
       
   384                     &attachmentParts    ) );
       
   385 
       
   386         aMessage.AttachmentListL( attachmentParts );
       
   387 
       
   388         TInt attachmentCount( attachmentParts.Count() );
       
   389         if ( attachmentCount > 0 )
       
   390             {
       
   391             delete iAttachmentInfo;
       
   392             iAttachmentInfo = NULL;
       
   393             
       
   394             iInputParameters.iAttachmentInfo = NULL;
       
   395 
       
   396             CESMRAttachmentInfo* attachmentInfo = CESMRAttachmentInfo::NewL();
       
   397             CleanupStack::PushL( attachmentInfo );
       
   398 
       
   399             for( TInt i(0); i < attachmentCount; ++i )
       
   400                 {
       
   401                 CESMRAttachment::TESMRAttachmentState state(
       
   402                         CESMRAttachment::EAttachmentStateDownloaded );
       
   403 
       
   404                 if ( EFSFull != attachmentParts[i]->FetchLoadState() )
       
   405                     {
       
   406                     state = CESMRAttachment::EAttachmentStateNotDownloaded;
       
   407                     }
       
   408 
       
   409                 TInt contentSize( attachmentParts[i]->ContentSize() );
       
   410                 TPtrC attachmentName( attachmentParts[i]->AttachmentNameL() );
       
   411 
       
   412                 if ( contentSize >= 0 && attachmentName.Length() &&
       
   413                         iCalendarPartId !=  attachmentParts[i]->GetPartId() )
       
   414                     {
       
   415                     attachmentInfo->AddAttachmentInfoL(
       
   416                             attachmentName,
       
   417                             contentSize,
       
   418                             state );
       
   419                     }
       
   420                 }
       
   421 
       
   422             if ( attachmentInfo->AttachmentCount() )
       
   423                 {
       
   424                 iAttachmentInfo = attachmentInfo;
       
   425                 CleanupStack::Pop( attachmentInfo );
       
   426                 // ownership does not change
       
   427                 iInputParameters.iAttachmentInfo = iAttachmentInfo;
       
   428                 }
       
   429             else
       
   430                 {
       
   431                 CleanupStack::PopAndDestroy( attachmentInfo );
       
   432                 }
       
   433 
       
   434             attachmentInfo = NULL;
       
   435 
       
   436             }
       
   437         CleanupStack::PopAndDestroy(); // attachmentparts
       
   438         }
       
   439     }
       
   440 
       
   441 // EOF
   352 // EOF
   442 
   353