meetingrequest/mricalviewer/src/cesmricalviewerloadmrdatacmd.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:  Loading MR data command implemenation
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 // INCLUDE FILES
       
    20 #include "emailtrace.h"
       
    21 #include "cesmricalviewerloadmrdatacmd.h"
       
    22 //<cmail>
       
    23 #include "esmricalvieweropcodes.hrh"
       
    24 #include <calsession.h>
       
    25 #include "CFSMailClient.h"
       
    26 //</cmail>
       
    27 
       
    28 #include "cesmrmrinfoicalretriever.h"
       
    29 #include "cesmrimapicalretriever.h"
       
    30 
       
    31 // ======== MEMBER FUNCTIONS ========
       
    32 
       
    33 // -----------------------------------------------------------------------------
       
    34 // CESMRIcalViewerLoadMRDataCmd::CESMRIcalViewerLoadMRDataCmd
       
    35 // -----------------------------------------------------------------------------
       
    36 //
       
    37 CESMRIcalViewerLoadMRDataCmd::CESMRIcalViewerLoadMRDataCmd(
       
    38         CCalSession& aCalSession,
       
    39         CFSMailClient& aMailClient,
       
    40         TESMRInputParams& aESMRInputParams )
       
    41 :   CESMRIcalViewerAsyncCommand( EESMRLoadMRData, aCalSession ),
       
    42     iESMRInputParams( aESMRInputParams ),
       
    43     iMailClient( aMailClient )
       
    44     {
       
    45     FUNC_LOG;
       
    46     //do nothing
       
    47     }
       
    48 
       
    49 // -----------------------------------------------------------------------------
       
    50 // CESMRIcalViewerLoadMRDataCmd::~CESMRIcalViewerLoadMRDataCmd
       
    51 // -----------------------------------------------------------------------------
       
    52 //
       
    53 CESMRIcalViewerLoadMRDataCmd::~CESMRIcalViewerLoadMRDataCmd()
       
    54     {
       
    55     FUNC_LOG;
       
    56     CancelCommand();
       
    57     iMRRetrieverCommands.ResetAndDestroy();
       
    58     iMRRetrieverCommands.Close();
       
    59     }
       
    60 
       
    61 // -----------------------------------------------------------------------------
       
    62 // CESMRIcalViewerLoadMRDataCmd::NewL
       
    63 // -----------------------------------------------------------------------------
       
    64 //
       
    65 CESMRIcalViewerLoadMRDataCmd* CESMRIcalViewerLoadMRDataCmd::NewL(
       
    66         CCalSession& aCalSession,
       
    67         CFSMailClient& aMailClient,
       
    68         TESMRInputParams& aESMRInputParams )
       
    69     {
       
    70     FUNC_LOG;
       
    71     CESMRIcalViewerLoadMRDataCmd* self =
       
    72             new (ELeave) CESMRIcalViewerLoadMRDataCmd(
       
    73                     aCalSession, aMailClient, aESMRInputParams );
       
    74 
       
    75     CleanupStack::PushL( self );
       
    76     self->ConstructL();
       
    77     CleanupStack::Pop( self );
       
    78     return self;
       
    79     }
       
    80 
       
    81 // -----------------------------------------------------------------------------
       
    82 // CESMRIcalViewerLoadMRDataCmd::ConstructL
       
    83 // -----------------------------------------------------------------------------
       
    84 //
       
    85 void CESMRIcalViewerLoadMRDataCmd::ConstructL()
       
    86     {
       
    87     FUNC_LOG;
       
    88     BaseConstructL();
       
    89     }
       
    90 
       
    91 // -----------------------------------------------------------------------------
       
    92 // CESMRIcalViewerLoadMRDataCmd::OperationCompleted
       
    93 // -----------------------------------------------------------------------------
       
    94 //
       
    95 void CESMRIcalViewerLoadMRDataCmd::OperationCompleted(
       
    96         MESMRIcalViewerObserver::TIcalViewerOperationResult aResult )
       
    97     {
       
    98     FUNC_LOG;
       
    99     if ( aResult.iOpType == EESMRLoadMRInfoData ||
       
   100          aResult.iOpType == EESMRLoadMRIcalData     )
       
   101         {
       
   102         aResult.iOpType = OperationType();
       
   103         Observer()->OperationCompleted( aResult );
       
   104         }
       
   105     }
       
   106 
       
   107 // -----------------------------------------------------------------------------
       
   108 // CESMRIcalViewerLoadMRDataCmd::OperationError
       
   109 // -----------------------------------------------------------------------------
       
   110 //
       
   111 void CESMRIcalViewerLoadMRDataCmd::OperationError(
       
   112         MESMRIcalViewerObserver::TIcalViewerOperationResult aResult )
       
   113     {
       
   114     FUNC_LOG;
       
   115     if ( aResult.iOpType == EESMRLoadMRInfoData )
       
   116         {
       
   117         if ( aResult.iResultCode == KErrNotFound )
       
   118             {
       
   119             if(iMRRetrieverCommands.Count() > iCurrentCommand + 1)
       
   120             	{
       
   121                 TRAPD(error, iMRRetrieverCommands[++iCurrentCommand]->ExecuteCommandL(
       
   122                              *Message(),
       
   123                              *this )     );
       
   124 
       
   125                 if ( error != KErrNone )
       
   126                     {
       
   127                     aResult.iOpType = OperationType();
       
   128                     aResult.iResultCode = error;
       
   129                     Observer()->OperationError( aResult );
       
   130                     }
       
   131             	}
       
   132             }
       
   133         else
       
   134             {
       
   135             aResult.iOpType = OperationType();
       
   136             Observer()->OperationError( aResult );
       
   137             }
       
   138         }
       
   139     else
       
   140         {
       
   141         aResult.iOpType = OperationType();
       
   142         Observer()->OperationError( aResult );
       
   143         }
       
   144     }
       
   145 
       
   146 // -----------------------------------------------------------------------------
       
   147 // CESMRIcalViewerLoadMRDataCmd::ExecuteAsyncCommandL
       
   148 // -----------------------------------------------------------------------------
       
   149 //
       
   150 void CESMRIcalViewerLoadMRDataCmd::ExecuteAsyncCommandL()
       
   151     {
       
   152     FUNC_LOG;
       
   153     CESMRInfoIcalRetrieverCmd* cmd = CESMRInfoIcalRetrieverCmd::NewL(
       
   154                 CalSession(),
       
   155                 iESMRInputParams );
       
   156 
       
   157     CleanupStack::PushL( cmd );
       
   158     User::LeaveIfError(
       
   159             iMRRetrieverCommands.Append( cmd ) );
       
   160     CleanupStack::Pop( cmd ); cmd = NULL;
       
   161 
       
   162     CESMRImapIcalRetrieverCmd* cmd2 =
       
   163         CESMRImapIcalRetrieverCmd::NewL(
       
   164             CalSession(),
       
   165             iMailClient,
       
   166             iESMRInputParams );
       
   167 
       
   168     CleanupStack::PushL( cmd2 );
       
   169     User::LeaveIfError(
       
   170             iMRRetrieverCommands.Append( cmd2 ) );
       
   171     CleanupStack::Pop( cmd2 ); 
       
   172     cmd2 = NULL;
       
   173 
       
   174     iCurrentCommand = 0;
       
   175     
       
   176     if(iMRRetrieverCommands.Count() > iCurrentCommand)
       
   177     	{
       
   178         iMRRetrieverCommands[iCurrentCommand]->ExecuteCommandL(
       
   179                 *Message(),
       
   180                 *this );
       
   181     	}
       
   182     else
       
   183     	{
       
   184     	User::Leave(KErrOverflow);
       
   185     	}
       
   186     }
       
   187 
       
   188 // -----------------------------------------------------------------------------
       
   189 // CESMRIcalViewerLoadMRDataCmd::CancelAsyncCommand
       
   190 // -----------------------------------------------------------------------------
       
   191 //
       
   192 void CESMRIcalViewerLoadMRDataCmd::CancelAsyncCommand()
       
   193     {
       
   194     FUNC_LOG;
       
   195     TInt commandCount( iMRRetrieverCommands.Count() );
       
   196 
       
   197     for ( TInt i(0); i < commandCount; ++i )
       
   198         {
       
   199         iMRRetrieverCommands[iCurrentCommand]->CancelCommand();
       
   200         }
       
   201     }
       
   202 
       
   203 // EOF
       
   204