meetingrequest/mrtasks/src/cesmrcombinedtask.cpp
changeset 0 8466d47a6819
child 12 4ce476e64c59
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:  Implementation for ESMR base task
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #include "emailtrace.h"
       
    20 #include "cesmrcombinedtask.h"
       
    21 #include "mesmrmeetingrequestentry.h"
       
    22 #include <e32cmn.h>
       
    23 
       
    24 // ======== MEMBER FUNCTIONS ========
       
    25 
       
    26 // ---------------------------------------------------------------------------
       
    27 // CESMRCombinedTask::CESMRCombinedTask
       
    28 // ---------------------------------------------------------------------------
       
    29 //
       
    30 CESMRCombinedTask::CESMRCombinedTask(
       
    31         MESMRCalDbMgr& aCalDbMgr,
       
    32         MESMRMeetingRequestEntry& aEntry,
       
    33         CMRMailboxUtils& aMRMailboxUtils,
       
    34         TESMRExecutionRule aRule )
       
    35 :   CESMRTaskBase( aCalDbMgr, aEntry, aMRMailboxUtils ),
       
    36     iExecutionRule( aRule )
       
    37     {
       
    38     FUNC_LOG;
       
    39     //do nothing
       
    40     }
       
    41 
       
    42 // ---------------------------------------------------------------------------
       
    43 // CESMRCombinedTask::~CESMRCombinedTask
       
    44 // ---------------------------------------------------------------------------
       
    45 //
       
    46 CESMRCombinedTask::~CESMRCombinedTask()
       
    47     {
       
    48     FUNC_LOG;
       
    49     iTasks.ResetAndDestroy();
       
    50     iTasks.Close();
       
    51     }
       
    52 
       
    53 // ---------------------------------------------------------------------------
       
    54 // CESMRCombinedTask::NewL
       
    55 // ---------------------------------------------------------------------------
       
    56 //
       
    57 CESMRCombinedTask* CESMRCombinedTask::NewL(
       
    58         MESMRCalDbMgr& aCalDbMgr,
       
    59         MESMRMeetingRequestEntry& aEntry,
       
    60         CMRMailboxUtils& aMRMailboxUtils,
       
    61         TESMRExecutionRule aRule )
       
    62     {
       
    63     FUNC_LOG;
       
    64     CESMRCombinedTask* self =
       
    65         new (ELeave) CESMRCombinedTask(
       
    66             aCalDbMgr,
       
    67             aEntry,
       
    68             aMRMailboxUtils,
       
    69             aRule );
       
    70 
       
    71     CleanupStack::PushL(self);
       
    72     self->ConstructL();
       
    73     CleanupStack::Pop(self);
       
    74     return self;
       
    75     }
       
    76 
       
    77 // ---------------------------------------------------------------------------
       
    78 // CESMRCombinedTask::ConstructL
       
    79 // ---------------------------------------------------------------------------
       
    80 //
       
    81 void CESMRCombinedTask::ConstructL()
       
    82     {
       
    83     FUNC_LOG;
       
    84     BaseConstructL();
       
    85     }
       
    86 
       
    87 // ---------------------------------------------------------------------------
       
    88 // CESMRCombinedTask::AppendTaskL
       
    89 // ---------------------------------------------------------------------------
       
    90 //
       
    91 void CESMRCombinedTask::AppendTaskL( MESMRTask* aTask )
       
    92     {
       
    93     FUNC_LOG;
       
    94     User::LeaveIfError( iTasks.Append(aTask ) );
       
    95     }
       
    96 
       
    97 // ---------------------------------------------------------------------------
       
    98 // CESMRCombinedTask::RemoveTaskL
       
    99 // ---------------------------------------------------------------------------
       
   100 //
       
   101 MESMRTask* CESMRCombinedTask::RemoveTaskL( MESMRTask* aTask )
       
   102     {
       
   103     FUNC_LOG;
       
   104     TInt index = iTasks.Find( aTask );
       
   105     if ( KErrNotFound == index )
       
   106         {
       
   107         User::Leave( KErrNotFound );
       
   108         }
       
   109 
       
   110     MESMRTask* task = iTasks[index];
       
   111     iTasks.Remove( index );
       
   112 
       
   113     return task;
       
   114     }
       
   115 
       
   116 // ---------------------------------------------------------------------------
       
   117 // CESMRCombinedTask::ExecuteTaskL
       
   118 // ---------------------------------------------------------------------------
       
   119 //
       
   120 void CESMRCombinedTask::ExecuteTaskL()
       
   121     {
       
   122     FUNC_LOG;
       
   123 
       
   124     TInt err( KErrNone );
       
   125     TInt taskCount( iTasks.Count() );
       
   126     
       
   127     MESMRMeetingRequestEntry& mrEntry( ESMREntry() );    
       
   128     if ( mrEntry.IsEntryEditedL() )
       
   129         {
       
   130         mrEntry.UpdateTimeStampL();
       
   131         }
       
   132     
       
   133     for( TInt i(0); i < taskCount; ++i )
       
   134         {
       
   135         MESMRTask* task = iTasks[i];
       
   136 
       
   137         if ( EESMRTrap == iExecutionRule )
       
   138             {
       
   139             TRAPD( taskErr, task->ExecuteTaskL() );
       
   140 
       
   141 
       
   142             if ( taskErr == KErrCancel )
       
   143                 {
       
   144                 // Task cancellation is leaved
       
   145                 User::Leave( KErrCancel );
       
   146                 }
       
   147             else if ( KErrNone != taskErr )
       
   148                 {
       
   149                 err = taskErr;
       
   150                 }
       
   151             }
       
   152         else if ( EESMRLeave == iExecutionRule )
       
   153             {
       
   154             task->ExecuteTaskL();
       
   155             }
       
   156         }
       
   157 
       
   158     User::LeaveIfError( err );
       
   159 
       
   160     }
       
   161