emailservices/emailstore/base_plugin/src/basepluginfetch.cpp
changeset 0 8466d47a6819
child 8 e1b6206813b4
equal deleted inserted replaced
-1:000000000000 0:8466d47a6819
       
     1 /*
       
     2 * Copyright (c) 2007 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:  Request fetcher implementation.
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 #include "BasePlugin.h"
       
    21 
       
    22 
       
    23 /**
       
    24  * Note that aPreferredByteCount is ignored.
       
    25  */
       
    26 EXPORT_C void CBasePlugin::FetchMessagePartsL(
       
    27     const TFSMailMsgId& aMailBoxId,
       
    28 	const TFSMailMsgId& /*aFolderId*/,
       
    29 	const TFSMailMsgId& aMessageId,
       
    30     const RArray<TFSMailMsgId>& aMessagePartIds,
       
    31 	MFSMailRequestObserver& aOperationObserver,
       
    32 	const TInt aRequestId,
       
    33 	const TUint /*aPreferredByteCount*/ )
       
    34     
       
    35     {
       
    36     CFetchRequester* req = CFetchRequester::NewL(   
       
    37         *this, aMailBoxId, aMessageId, aMessagePartIds, aOperationObserver, aRequestId );
       
    38     CleanupStack::PushL( req );
       
    39     iReqs.AppendL( req );
       
    40     CleanupStack::Pop( req );
       
    41     }
       
    42 
       
    43 
       
    44 #pragma mark CFetchRequester
       
    45 
       
    46 
       
    47 /**
       
    48  *
       
    49  */
       
    50 CFetchRequester::CFetchRequester(
       
    51     CBasePlugin& aPlugin,
       
    52     const TFSMailMsgId& aMailBoxId,
       
    53     const TFSMailMsgId& aMessageId,
       
    54     MFSMailRequestObserver& aObserver,
       
    55     TInt aRequestId )
       
    56     :
       
    57     iPlugin( aPlugin ),
       
    58     iObserver( aObserver ),
       
    59     iMailBoxId( aMailBoxId ),
       
    60     iMessageId( aMessageId ),
       
    61     iRequestId( aRequestId )
       
    62     {
       
    63     }
       
    64 
       
    65 
       
    66 /**
       
    67  *
       
    68  */
       
    69 CFetchRequester* CFetchRequester::NewL(
       
    70     CBasePlugin& aPlugin,
       
    71     const TFSMailMsgId& aMailBoxId,
       
    72     const TFSMailMsgId& iMessageId,
       
    73     const RArray<TFSMailMsgId>& aMessages,
       
    74     MFSMailRequestObserver& aObserver,
       
    75     TInt aRequestId )
       
    76    
       
    77     {
       
    78     CFetchRequester* self = new (ELeave) CFetchRequester(
       
    79         aPlugin, aMailBoxId, iMessageId, aObserver, aRequestId );
       
    80    
       
    81     CleanupStack::PushL( self );
       
    82     self->ConstructL( aMessages );
       
    83     CleanupStack::Pop( self );
       
    84    
       
    85     return self;
       
    86     }
       
    87 
       
    88 
       
    89 /**
       
    90  *
       
    91  */
       
    92 void CFetchRequester::ConstructL( const RArray<TFSMailMsgId>& aMessages )
       
    93     {
       
    94     __LOG_CONSTRUCT( "baseplugin", "CFetchRequester" )
       
    95    
       
    96     __LOG_ENTER( "ConstructL." );
       
    97 
       
    98     __LOG_WRITE_FORMAT1_INFO( "iMailBoxId = 0x%X.", iMailBoxId.Id() );
       
    99     __LOG_WRITE_FORMAT1_INFO( "iMessageId = 0x%X.", iMessageId.Id() );
       
   100     __LOG_WRITE_FORMAT1_INFO( "iRequestId = 0x%X.", iRequestId );
       
   101 
       
   102    TInt count = aMessages.Count();
       
   103    
       
   104    for ( TInt i = 0; i < count; i++ )
       
   105       {
       
   106       iParts.AppendL( aMessages[i] );
       
   107       __LOG_WRITE_FORMAT1_INFO( "iMessages[%d] =", i );
       
   108       __LOG_WRITE_FORMAT1_INFO( "0x%X.", aMessages[i].Id() );
       
   109       }   
       
   110    
       
   111    __LOG_EXIT;
       
   112    }
       
   113 
       
   114 
       
   115 /**
       
   116  *
       
   117  */
       
   118 CFetchRequester::~CFetchRequester() 
       
   119     {
       
   120     iParts.Close();
       
   121     __LOG_DESTRUCT
       
   122     }