meetingrequest/mrbcplugin/bcmrevent/src/cmrbcplugincmdhandler.cpp
branchRCL_3
changeset 16 4ce476e64c59
child 24 b5fbb9b25d57
equal deleted inserted replaced
13:0396474f30f5 16:4ce476e64c59
       
     1 /*
       
     2 * Copyright (c) 2009-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:  Class implementing the RECAL customisation interface
       
    15 *
       
    16 */
       
    17 
       
    18 #include "cmrbcplugincmdhandler.h"
       
    19 #include "cmrbcplugincreatenewmrcmd.h"
       
    20 #include "cmrbcpluginopenmrviewercmd.h"
       
    21 #include "cmrbcpluginresourcereader.h"
       
    22 #include "cmrbcpluginentryloader.h"
       
    23 #include "tmrbcplugincommand.h"
       
    24 #include "cmrbcpluginnewcaleventcommand.h"
       
    25 
       
    26 #include <calenservices.h>
       
    27 #include <caleninterimutils2.h>
       
    28 #include <calencommands.hrh>
       
    29 #include <calenlauncher.h>
       
    30 #include "emailtrace.h"
       
    31 
       
    32 namespace { // codescanner::namespace
       
    33 
       
    34 #ifdef _DEBUG
       
    35 
       
    36 _LIT( KMRBCPluginCmdHandler, "MRBCPluginCmdHandler" );
       
    37 
       
    38 enum TMRBCPluginCmdHandlerPanic
       
    39     {
       
    40     EInvalidCommand // Invalid command
       
    41     };
       
    42 
       
    43 void Panic( TMRBCPluginCmdHandlerPanic aPanic )
       
    44     {    
       
    45     User::Panic( KMRBCPluginCmdHandler, aPanic );
       
    46     }
       
    47 
       
    48 #endif // _DEBUG
       
    49 
       
    50 CCalEntry::TType CommandToType(
       
    51         TInt aCommand )
       
    52     {
       
    53     CCalEntry::TType calEntryType( CCalEntry::EAppt );
       
    54     
       
    55     switch( aCommand )
       
    56         {
       
    57         case ECalenNewMeeting:
       
    58             {
       
    59             calEntryType = CCalEntry::EAppt;
       
    60             }
       
    61             break;
       
    62 
       
    63         case ECalenNewTodo:
       
    64             {
       
    65             calEntryType = CCalEntry::ETodo;
       
    66             }
       
    67             break;
       
    68 
       
    69         case ECalenNewAnniv:
       
    70             {
       
    71             calEntryType = CCalEntry::EAnniv;
       
    72             }
       
    73             break;
       
    74             
       
    75         case ECalenNewDayNote:
       
    76             {
       
    77             calEntryType = CCalEntry::EEvent;
       
    78             }
       
    79             break;            
       
    80         }
       
    81     
       
    82     return calEntryType;
       
    83     }
       
    84 
       
    85 } // namespace
       
    86 
       
    87 // -----------------------------------------------------------------------------
       
    88 // CMRBCPluginCmdHandler::CMRBCPluginCmdHandler
       
    89 // -----------------------------------------------------------------------------
       
    90 //
       
    91 CMRBCPluginCmdHandler::CMRBCPluginCmdHandler( 
       
    92         MCalenServices& aServices )
       
    93 :   iServices( aServices )
       
    94     {
       
    95     FUNC_LOG;
       
    96     }
       
    97 
       
    98 // -----------------------------------------------------------------------------
       
    99 // CMRBCPluginCmdHandler::~CMRBCPluginCmdHandler
       
   100 // -----------------------------------------------------------------------------
       
   101 //
       
   102 CMRBCPluginCmdHandler::~CMRBCPluginCmdHandler()
       
   103     {
       
   104     FUNC_LOG;
       
   105     }
       
   106 
       
   107 // -----------------------------------------------------------------------------
       
   108 // CMRBCPluginCmdHandler::NewL
       
   109 // -----------------------------------------------------------------------------
       
   110 //
       
   111 CMRBCPluginCmdHandler* CMRBCPluginCmdHandler::NewL(
       
   112         MCalenServices& aServices )
       
   113     {
       
   114     FUNC_LOG;
       
   115     
       
   116     CMRBCPluginCmdHandler* self = 
       
   117             new (ELeave) CMRBCPluginCmdHandler(
       
   118                     aServices );
       
   119     
       
   120     CleanupStack::PushL( self );
       
   121     self->ConstructL();
       
   122     CleanupStack::Pop( self );
       
   123     return self;
       
   124     }
       
   125 
       
   126 // -----------------------------------------------------------------------------
       
   127 // CMRBCPluginCmdHandler::ConstructL
       
   128 // -----------------------------------------------------------------------------
       
   129 //
       
   130 void CMRBCPluginCmdHandler::ConstructL()
       
   131     {
       
   132     FUNC_LOG;
       
   133     }
       
   134 
       
   135 // -----------------------------------------------------------------------------
       
   136 // CMRBCPluginCmdHandler::HandleCommandL
       
   137 // -----------------------------------------------------------------------------
       
   138 //
       
   139 TBool CMRBCPluginCmdHandler::HandleCommandL( 
       
   140         const TCalenCommand& aCommand )
       
   141     {
       
   142     FUNC_LOG;
       
   143     
       
   144     MMRBCPluginCommand* command = NULL;
       
   145     TInt commandCode( aCommand.Command() );
       
   146     
       
   147     if ( ECalenNewMeetingTimeSpan == commandCode )
       
   148         {
       
   149         // command is triggered from day view bt using visual 
       
   150         // selection. We need to check whether MR is enabled or not.
       
   151         
       
   152         commandCode = ECalenNewMeeting;
       
   153         if ( iServices.InterimUtilsL().MRViewersEnabledL() )
       
   154             {
       
   155             commandCode = ECalenNewMeetingRequest;
       
   156             }        
       
   157         }    
       
   158     
       
   159     switch ( commandCode )
       
   160         {
       
   161         case ECalenNewMeetingRequest:            
       
   162             {
       
   163             command = CMRBCPluginCreateNewMRCmd::NewL( iServices );
       
   164             break;
       
   165             }
       
   166             
       
   167         case ECalenEventView:
       
   168             {
       
   169             command = CMRBCPluginOpenMRViewerCmd::NewL( iServices );
       
   170             break;
       
   171             }
       
   172             
       
   173         case ECalenNewMeeting:
       
   174         case ECalenNewTodo:
       
   175         case ECalenNewAnniv:
       
   176         case ECalenNewDayNote:
       
   177             {
       
   178             command = CMRPluginNewCalEntryCommand::NewL(
       
   179                     iServices,
       
   180                     CommandToType( aCommand.Command() ) );
       
   181             break;
       
   182             }
       
   183             
       
   184         default:
       
   185             {
       
   186             __ASSERT_DEBUG( command, Panic(EInvalidCommand) );
       
   187             ERROR( KErrArgument, "Invalid command" );
       
   188             User::Leave( KErrArgument );
       
   189             break;
       
   190             }
       
   191         }
       
   192     
       
   193     CleanupDeletePushL( command );
       
   194     command->ExecuteCommandL( aCommand );
       
   195     
       
   196     CleanupStack::PopAndDestroy( command ); // codescanner::cleanup
       
   197     
       
   198     // Returning EFalse means that command is not continued
       
   199     return EFalse;
       
   200     }
       
   201 
       
   202 // -----------------------------------------------------------------------------
       
   203 // CMRBCPluginCmdHandler::CalenCommandHandlerExtensionL
       
   204 // -----------------------------------------------------------------------------
       
   205 //
       
   206 TAny* CMRBCPluginCmdHandler::CalenCommandHandlerExtensionL( 
       
   207         TUid /* aExtensionUid */ )
       
   208     {
       
   209     FUNC_LOG;
       
   210     return NULL;
       
   211     }
       
   212 
       
   213 // EOF