meetingrequest/mrtasks/mrcaleventtaskplugin/src/cmrtodomarkasnotdonetask.cpp
branchRCL_3
changeset 12 4ce476e64c59
equal deleted inserted replaced
11:0396474f30f5 12:4ce476e64c59
       
     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 calendar event task
       
    15 *
       
    16 */
       
    17 
       
    18 #include "cmrtodomarkasnotdonetask.h"
       
    19 #include "cesmrcaldbmgr.h"
       
    20 #include "mesmrcalentry.h"
       
    21 
       
    22 #include <caltime.h>
       
    23 #include <calentry.h>
       
    24 
       
    25 #include "emailtrace.h"
       
    26 
       
    27 namespace { // codescanner::namespace
       
    28 
       
    29 }//namespace
       
    30 
       
    31 // ======== MEMBER FUNCTIONS ========
       
    32 
       
    33 // ---------------------------------------------------------------------------
       
    34 // CESMRTodoMarkAsNotDoneTask::CESMRTodoMarkAsNotDoneTask
       
    35 // ---------------------------------------------------------------------------
       
    36 //
       
    37 CESMRTodoMarkAsNotDoneTask::CESMRTodoMarkAsNotDoneTask( MESMRCalEntry& aEntry, 
       
    38         MESMRCalDbMgr& aCalDbMgr )
       
    39 :   iEntry( aEntry ), 
       
    40     iCalDbMgr( aCalDbMgr )
       
    41     {
       
    42     FUNC_LOG;
       
    43     //do nothing
       
    44     }
       
    45 
       
    46 // ---------------------------------------------------------------------------
       
    47 // CESMRTodoMarkAsNotDoneTask::~CESMRTodoMarkAsNotDoneTask
       
    48 // ---------------------------------------------------------------------------
       
    49 //
       
    50 CESMRTodoMarkAsNotDoneTask::~CESMRTodoMarkAsNotDoneTask()
       
    51     {
       
    52     FUNC_LOG;
       
    53     //do nothing
       
    54     }
       
    55 
       
    56 // ---------------------------------------------------------------------------
       
    57 // CESMRTodoMarkAsNotDoneTask::NewL
       
    58 // ---------------------------------------------------------------------------
       
    59 //
       
    60 CESMRTodoMarkAsNotDoneTask* CESMRTodoMarkAsNotDoneTask::NewL( 
       
    61         MESMRCalEntry& aEntry, 
       
    62         MESMRCalDbMgr& aCalDbMgr )
       
    63     {
       
    64     FUNC_LOG;
       
    65     CESMRTodoMarkAsNotDoneTask* self = 
       
    66         new (ELeave) CESMRTodoMarkAsNotDoneTask( aEntry, aCalDbMgr );
       
    67     CleanupStack::PushL(self);
       
    68     self->ConstructL();
       
    69     CleanupStack::Pop(self);
       
    70     return self;
       
    71     }
       
    72 
       
    73 // ---------------------------------------------------------------------------
       
    74 // CESMRTodoMarkAsNotDoneTask::ConstructL
       
    75 // ---------------------------------------------------------------------------
       
    76 //
       
    77 void CESMRTodoMarkAsNotDoneTask::ConstructL()
       
    78     {
       
    79     FUNC_LOG;
       
    80     }
       
    81 
       
    82 // ---------------------------------------------------------------------------
       
    83 // CESMRTodoMarkAsNotDoneTask::ExecuteTaskL
       
    84 // ---------------------------------------------------------------------------
       
    85 //
       
    86 void CESMRTodoMarkAsNotDoneTask::ExecuteTaskL()
       
    87     {
       
    88     FUNC_LOG;
       
    89 
       
    90     // Mark to-do as not done
       
    91     MarkTodoAsNotDoneL();
       
    92     }
       
    93 
       
    94 // ---------------------------------------------------------------------------
       
    95 // CESMRTodoMarkAsNotDoneTask::MarkTodoAsNotDoneL
       
    96 // ---------------------------------------------------------------------------
       
    97 //
       
    98 void CESMRTodoMarkAsNotDoneTask::MarkTodoAsNotDoneL()
       
    99     {
       
   100     FUNC_LOG;
       
   101     
       
   102     TTime now;
       
   103     now.HomeTime();
       
   104     TCalTime caltime;
       
   105     caltime.SetTimeLocalL( now );
       
   106 
       
   107     // Set to-do as completed
       
   108     TRAPD( err, iEntry.Entry().SetCompletedL( EFalse, caltime ) );
       
   109 
       
   110     // Update entry time stamp before storing
       
   111     iEntry.UpdateTimeStampL();    
       
   112     
       
   113     if( err == KErrNone )
       
   114         {
       
   115         // Check storing result
       
   116         MESMRUtilsTombsExt::TESMRUtilsDbResult res =
       
   117            iCalDbMgr.StoreEntryCondL( iEntry.Entry(), EFalse, ETrue );
       
   118         
       
   119         // Check that entry can be saved
       
   120         if ( MESMRUtilsTombsExt::ECheckedValidNew == res ||
       
   121             MESMRUtilsTombsExt::ECheckedValidUpdate == res || 
       
   122             iEntry.IsEntryEditedL() )
       
   123            {
       
   124            // Validate entry before storing it to calendar db
       
   125            CCalEntry* validatedEntry = iEntry.ValidateEntryL();
       
   126            CleanupStack::PushL( validatedEntry );
       
   127         
       
   128            iCalDbMgr.StoreEntryCondL( *validatedEntry, EFalse );
       
   129            
       
   130            CleanupStack::PopAndDestroy( validatedEntry );
       
   131            
       
   132            iEntry.UpdateEntryAfterStoringL();
       
   133            }
       
   134         }
       
   135     }
       
   136 
       
   137 // EOF
       
   138