meetingrequest/mrtasks/mrcaleventtaskplugin/src/cmrcaleventtaskplugin.cpp
branchRCL_3
changeset 12 4ce476e64c59
equal deleted inserted replaced
11:0396474f30f5 12:4ce476e64c59
       
     1 /*
       
     2 * Copyright (c) 2008 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: MR Cal Event Task Plugin implementation
       
    15 *
       
    16 */
       
    17 #include "cmrcaleventtaskplugin.h"
       
    18 
       
    19 #include "cmrstorecaleventtask.h"
       
    20 #include "cmrcalentryuideletetask.h"
       
    21 #include "cmrcalentryuiedittask.h"
       
    22 #include "cmrtodomarkasdonetask.h"
       
    23 #include "cmrtodomarkasnotdonetask.h"
       
    24 #include "cesmrcombinedtask.h"
       
    25 
       
    26 #include "emailtrace.h"
       
    27 
       
    28 namespace { // codescanner::namespace
       
    29 
       
    30 #ifdef _DEBUG
       
    31 
       
    32 // Panic literal for ESMRTaskFactory
       
    33 _LIT( KESMRTaskFactoryPanicTxt, "MRCalEventTaskPlugin" );
       
    34 
       
    35 /** Panic code definitions */
       
    36 enum TESMRTaskFactoryPanic
       
    37     {
       
    38     EESMRTaskFactoryInvalidTask // Trying to create invalid task
       
    39     };
       
    40 
       
    41 
       
    42 // ---------------------------------------------------------------------------
       
    43 // Panic wrapper method
       
    44 // ---------------------------------------------------------------------------
       
    45 //
       
    46 void Panic( TESMRTaskFactoryPanic aPanic )
       
    47     {
       
    48 
       
    49     User::Panic( KESMRTaskFactoryPanicTxt, aPanic );
       
    50     }
       
    51 
       
    52 #endif // _DEBUG
       
    53 
       
    54 } // namespace
       
    55 
       
    56 // -----------------------------------------------------------------------------
       
    57 // CMRCalEventTaskPlugin::CMRCalEventTaskPlugin
       
    58 // -----------------------------------------------------------------------------
       
    59 //
       
    60 CMRCalEventTaskPlugin::CMRCalEventTaskPlugin( MESMRCalDbMgr& aCalDbMgr )
       
    61     : iCalDbMgr( aCalDbMgr )
       
    62     {
       
    63     FUNC_LOG;
       
    64     }
       
    65 
       
    66 // -----------------------------------------------------------------------------
       
    67 // CMRCalEventTaskPlugin::~CMRCalEventTaskPlugin
       
    68 // -----------------------------------------------------------------------------
       
    69 //
       
    70 CMRCalEventTaskPlugin::~CMRCalEventTaskPlugin()
       
    71     {
       
    72     FUNC_LOG;
       
    73     }
       
    74 
       
    75 // -----------------------------------------------------------------------------
       
    76 // CMRCalEventTaskPlugin::NewL
       
    77 // -----------------------------------------------------------------------------
       
    78 //
       
    79 CMRCalEventTaskPlugin* CMRCalEventTaskPlugin::NewL( TAny* aCalDbMgr )
       
    80     {
       
    81     FUNC_LOG;
       
    82     MESMRCalDbMgr* calDbMgr = static_cast< MESMRCalDbMgr* >( aCalDbMgr );
       
    83 
       
    84     CMRCalEventTaskPlugin* self =
       
    85         new( ELeave )CMRCalEventTaskPlugin( *calDbMgr );
       
    86 
       
    87     return self;
       
    88     }
       
    89 
       
    90 // ---------------------------------------------------------------------------
       
    91 // CMRCalEventTaskPlugin::CreateTaskL
       
    92 // ---------------------------------------------------------------------------
       
    93 //
       
    94 MESMRTask* CMRCalEventTaskPlugin::CreateTaskL(
       
    95             TESMRCommand aCommand,
       
    96             MESMRCalEntry& aEntry )
       
    97     {
       
    98     FUNC_LOG;
       
    99 
       
   100     MESMRTask* task = NULL;
       
   101 
       
   102     switch( aCommand )
       
   103         {
       
   104         case EESMRCmdSaveMR:
       
   105         case EESMRCmdCalEntryUISave:
       
   106             {
       
   107             task = CreateStoreCalEventToDBTaskL( aEntry );
       
   108             }
       
   109             break;
       
   110             
       
   111         case EESMRCmdCalEntryUIDelete:
       
   112             {
       
   113             task = CreateCalEntryUiDeleteTaskL( aEntry );
       
   114             }
       
   115             break;
       
   116             
       
   117         case EESMRCmdTodoMarkAsDone:
       
   118             {
       
   119             task = CreateTodoMarkAsDoneTaskL( aEntry );
       
   120             }
       
   121             break;
       
   122 
       
   123         case EESMRCmdTodoMarkAsNotDone:
       
   124             {
       
   125             task = CreateTodoMarkAsNotDoneTaskL( aEntry );
       
   126             }
       
   127             break;
       
   128 
       
   129         case EESMRCmdCalendarChange:
       
   130             {
       
   131             task = CreateMoveCalEntryToCurrentDBTaskL( aEntry );
       
   132             }
       
   133             break;
       
   134 
       
   135         default:
       
   136             __ASSERT_DEBUG( EFalse, Panic( EESMRTaskFactoryInvalidTask ) );
       
   137             User::Leave( KErrNotSupported );
       
   138             break;
       
   139         }
       
   140 
       
   141     return task;
       
   142     }
       
   143 
       
   144 // ---------------------------------------------------------------------------
       
   145 // CMRCalEventTaskPlugin::CreateStoreCalEventToDBTaskL
       
   146 // ---------------------------------------------------------------------------
       
   147 //
       
   148 MESMRTask* CMRCalEventTaskPlugin::CreateStoreCalEventToDBTaskL(
       
   149             MESMRCalEntry& aEntry )
       
   150     {
       
   151     FUNC_LOG;
       
   152 
       
   153     // Store calendar event to calendar database task
       
   154     return CESMRStoreCalEventTask::NewL( aEntry, iCalDbMgr );
       
   155     }
       
   156 
       
   157 // ---------------------------------------------------------------------------
       
   158 // CMRCalEventTaskPlugin::CreateCalEntryUiDeleteTaskL
       
   159 // ---------------------------------------------------------------------------
       
   160 //
       
   161 MESMRTask* CMRCalEventTaskPlugin::CreateCalEntryUiDeleteTaskL(
       
   162             MESMRCalEntry& aEntry )
       
   163     {
       
   164     FUNC_LOG;
       
   165 
       
   166     // Delete calendar event from calendar database task
       
   167     return CESMRCalEntryUiDeleteTask::NewL( aEntry, iCalDbMgr );
       
   168     }
       
   169 
       
   170 // ---------------------------------------------------------------------------
       
   171 // CMRCalEventTaskPlugin::CreateCalEntryUiEditTaskL
       
   172 // ---------------------------------------------------------------------------
       
   173 //
       
   174 MESMRTask* CMRCalEventTaskPlugin::CreateCalEntryUiEditTaskL(
       
   175             MESMRCalEntry& aEntry )
       
   176     {
       
   177     FUNC_LOG;
       
   178 
       
   179     // Edit calendar event task
       
   180     return CESMRCalEntryUiEditTask::NewL( aEntry );
       
   181     }
       
   182 
       
   183 // ---------------------------------------------------------------------------
       
   184 // CMRCalEventTaskPlugin::CreateTodoMarkAsDoneTaskL
       
   185 // ---------------------------------------------------------------------------
       
   186 //
       
   187 MESMRTask* CMRCalEventTaskPlugin::CreateTodoMarkAsDoneTaskL(
       
   188             MESMRCalEntry& aEntry )
       
   189     {
       
   190     FUNC_LOG;
       
   191 
       
   192     // Mark to-do as done task
       
   193     return CESMRTodoMarkAsDoneTask::NewL( aEntry, iCalDbMgr );
       
   194     }
       
   195 
       
   196 // ---------------------------------------------------------------------------
       
   197 // CMRCalEventTaskPlugin::CreateTodoMarkAsNotDoneTaskL
       
   198 // ---------------------------------------------------------------------------
       
   199 //
       
   200 MESMRTask* CMRCalEventTaskPlugin::CreateTodoMarkAsNotDoneTaskL(
       
   201             MESMRCalEntry& aEntry )
       
   202     {
       
   203     FUNC_LOG;
       
   204 
       
   205     // Mark to-do as not done task
       
   206     return CESMRTodoMarkAsNotDoneTask::NewL( aEntry, iCalDbMgr );
       
   207     }
       
   208 
       
   209 // ---------------------------------------------------------------------------
       
   210 // CMRCalEventTaskPlugin::CreateMoveCalEntryToCurrentDBTaskL
       
   211 // ---------------------------------------------------------------------------
       
   212 //
       
   213 MESMRTask* CMRCalEventTaskPlugin::CreateMoveCalEntryToCurrentDBTaskL(
       
   214             MESMRCalEntry& aEntry )
       
   215     {
       
   216     FUNC_LOG;
       
   217 
       
   218     CESMRCombinedTask* task = CESMRCombinedTask::NewL(
       
   219             aEntry,
       
   220             CESMRCombinedTask::EESMRTrap );
       
   221     CleanupStack::PushL( task );
       
   222 
       
   223     AppendTaskL( *task, CreateCalEntryUiDeleteTaskL( aEntry ) );
       
   224     AppendTaskL( *task, CreateStoreCalEventToDBTaskL( aEntry ) );
       
   225 
       
   226     CleanupStack::Pop( task );
       
   227     return task;
       
   228     }
       
   229 
       
   230 // EOF