meetingrequest/mrtasks/mrcaleventtaskplugin/src/cmrstorecaleventtask.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 "cmrstorecaleventtask.h"
       
    19 #include "cesmrcaldbmgr.h"
       
    20 #include "mesmrcalentry.h"
       
    21 
       
    22 #include <calrrule.h>
       
    23 
       
    24 #include "emailtrace.h"
       
    25 
       
    26 namespace { // codescanner::namespace
       
    27 
       
    28 }//namespace
       
    29 
       
    30 // ======== MEMBER FUNCTIONS ========
       
    31 
       
    32 // ---------------------------------------------------------------------------
       
    33 // CESMRStoreCalEventTask::CESMRStoreCalEventTask
       
    34 // ---------------------------------------------------------------------------
       
    35 //
       
    36 CESMRStoreCalEventTask::CESMRStoreCalEventTask( MESMRCalEntry& aEntry, 
       
    37                                                 MESMRCalDbMgr& aCalDbMgr )
       
    38 :   iEntry( aEntry ), 
       
    39     iCalDbMgr( aCalDbMgr )
       
    40     {
       
    41     FUNC_LOG;
       
    42     //do nothing
       
    43     }
       
    44 
       
    45 // ---------------------------------------------------------------------------
       
    46 // CESMRStoreCalEventTask::~CESMRStoreCalEventTask
       
    47 // ---------------------------------------------------------------------------
       
    48 //
       
    49 CESMRStoreCalEventTask::~CESMRStoreCalEventTask()
       
    50     {
       
    51     FUNC_LOG;
       
    52     //do nothing
       
    53     }
       
    54 
       
    55 // ---------------------------------------------------------------------------
       
    56 // CESMRStoreCalEventTask::NewL
       
    57 // ---------------------------------------------------------------------------
       
    58 //
       
    59 CESMRStoreCalEventTask* CESMRStoreCalEventTask::NewL( 
       
    60         MESMRCalEntry& aEntry, 
       
    61         MESMRCalDbMgr& aCalDbMgr )
       
    62     {
       
    63     FUNC_LOG;
       
    64     CESMRStoreCalEventTask* self = 
       
    65         new (ELeave) CESMRStoreCalEventTask( aEntry, aCalDbMgr );
       
    66     CleanupStack::PushL(self);
       
    67     self->ConstructL();
       
    68     CleanupStack::Pop(self);
       
    69     return self;
       
    70     }
       
    71 
       
    72 // ---------------------------------------------------------------------------
       
    73 // CESMRStoreCalEventTask::ConstructL
       
    74 // ---------------------------------------------------------------------------
       
    75 //
       
    76 void CESMRStoreCalEventTask::ConstructL()
       
    77     {
       
    78     FUNC_LOG;
       
    79     }
       
    80 
       
    81 // ---------------------------------------------------------------------------
       
    82 // CESMRStoreCalEventTask::ExecuteTaskL
       
    83 // ---------------------------------------------------------------------------
       
    84 //
       
    85 void CESMRStoreCalEventTask::ExecuteTaskL()
       
    86     {
       
    87     FUNC_LOG;
       
    88 
       
    89     // Store to calendar DB
       
    90     StoreCalEventToDbL();
       
    91     }
       
    92 
       
    93 // ---------------------------------------------------------------------------
       
    94 // CESMRStoreCalEventTask::StoreEntryToDbL
       
    95 // ---------------------------------------------------------------------------
       
    96 //
       
    97 void CESMRStoreCalEventTask::StoreCalEventToDbL()
       
    98     {
       
    99     FUNC_LOG;
       
   100     
       
   101     // Update entry time stamp before storing
       
   102     iEntry.UpdateTimeStampL();
       
   103     
       
   104     // Check storing result
       
   105     MESMRUtilsTombsExt::TESMRUtilsDbResult res =
       
   106        iCalDbMgr.StoreEntryCondL( iEntry.Entry(), EFalse, ETrue );
       
   107     
       
   108     // Check that entry can be saved
       
   109     if ( MESMRUtilsTombsExt::ECheckedValidNew == res ||
       
   110         MESMRUtilsTombsExt::ECheckedValidUpdate == res || 
       
   111         iEntry.IsEntryEditedL() )
       
   112        {
       
   113        // Validate entry before storing it to calendar db
       
   114        CCalEntry* validatedEntry = iEntry.ValidateEntryL();
       
   115        CleanupStack::PushL( validatedEntry );
       
   116     
       
   117        iCalDbMgr.StoreEntryCondL( *validatedEntry, EFalse );
       
   118        
       
   119        CleanupStack::PopAndDestroy( validatedEntry );
       
   120        
       
   121        iEntry.UpdateEntryAfterStoringL();
       
   122        }
       
   123     }
       
   124 
       
   125 // EOF
       
   126