meetingrequest/mricalviewer/src/cesmricalviewerresolvemrmethodsync.cpp
branchRCL_3
changeset 25 3533d4323edc
parent 0 8466d47a6819
equal deleted inserted replaced
24:d189ee25cf9d 25:3533d4323edc
       
     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:  Resolve meeting request method sync command
       
    15 *
       
    16 */
       
    17 
       
    18 #include "emailtrace.h"
       
    19 #include "cesmricalviewerresolvemrmethodsync.h"
       
    20 #include "cesmrmrinfoicalretriever.h"
       
    21 #include "esmricalviewerutils.h"
       
    22 //<cmail>
       
    23 #include "esmricalvieweropcodes.hrh"
       
    24 #include <calentry.h>
       
    25 #include "esmrdef.h"
       
    26 //</cmail>
       
    27 
       
    28 // ======== MEMBER FUNCTIONS ========
       
    29 
       
    30 // -----------------------------------------------------------------------------
       
    31 // CESMRIcalViewerResolveMRMethodSyncCmd::CESMRIcalViewerResolveMRMethodSyncCmd
       
    32 // -----------------------------------------------------------------------------
       
    33 //
       
    34 CESMRIcalViewerResolveMRMethodSyncCmd::CESMRIcalViewerResolveMRMethodSyncCmd(
       
    35         CCalSession& aCalSession,
       
    36         CFSMailClient& aMailClient,
       
    37         TESMRMeetingRequestMethod& aMRMethod )
       
    38 :   CESMRIcalViewerCommandBase(
       
    39         EESMRResolveMRMethodSync,
       
    40         aCalSession ),
       
    41         iMailClient( aMailClient ),
       
    42         iMRMethod( aMRMethod )
       
    43     {
       
    44     FUNC_LOG;
       
    45     iMRMethod = EESMRMeetingRequestMethodUnknown;
       
    46     }
       
    47 
       
    48 // -----------------------------------------------------------------------------
       
    49 // CESMRIcalViewerResolveMRMethodSyncCmd::~CESMRIcalViewerResolveMRMethodSyncCmd
       
    50 // -----------------------------------------------------------------------------
       
    51 //
       
    52 CESMRIcalViewerResolveMRMethodSyncCmd::~CESMRIcalViewerResolveMRMethodSyncCmd()
       
    53     {
       
    54     FUNC_LOG;
       
    55     CancelCommand();
       
    56     delete iMRInfoRetrieverCmd;
       
    57     }
       
    58 
       
    59 // -----------------------------------------------------------------------------
       
    60 // CESMRIcalViewerResolveMRMethodSyncCmd::NewL
       
    61 // -----------------------------------------------------------------------------
       
    62 //
       
    63 CESMRIcalViewerResolveMRMethodSyncCmd*
       
    64         CESMRIcalViewerResolveMRMethodSyncCmd::NewL(
       
    65                 CCalSession& aCalSession,
       
    66                 CFSMailClient& aMailClient,
       
    67                 TESMRMeetingRequestMethod& aMRMethod )
       
    68     {
       
    69     CESMRIcalViewerResolveMRMethodSyncCmd* self =
       
    70             new (ELeave) CESMRIcalViewerResolveMRMethodSyncCmd(
       
    71                     aCalSession,
       
    72                     aMailClient,
       
    73                     aMRMethod);
       
    74 
       
    75     CleanupStack::PushL( self );
       
    76     self->ConstructL();
       
    77     CleanupStack::Pop( self );
       
    78 
       
    79     return self;
       
    80     }
       
    81 
       
    82 // -----------------------------------------------------------------------------
       
    83 // CESMRIcalViewerResolveMRMethodSyncCmd::ConstructL
       
    84 // -----------------------------------------------------------------------------
       
    85 //
       
    86 void CESMRIcalViewerResolveMRMethodSyncCmd::ConstructL()
       
    87     {
       
    88     FUNC_LOG;
       
    89     BaseConstructL();
       
    90     }
       
    91 
       
    92 // -----------------------------------------------------------------------------
       
    93 // CESMRIcalViewerResolveMRMethodSyncCmd::OperationCompleted
       
    94 // -----------------------------------------------------------------------------
       
    95 //
       
    96 void CESMRIcalViewerResolveMRMethodSyncCmd::OperationCompleted(
       
    97         MESMRIcalViewerObserver::TIcalViewerOperationResult aResult )
       
    98     {
       
    99     FUNC_LOG;
       
   100     if ( EESMRLoadMRInfoData == aResult.iOpType )
       
   101         {
       
   102         // MRINFO data was parsed succesfully
       
   103         CCalEntry::TMethod method( CCalEntry::EMethodNone );
       
   104         // If this leaves we just go to case default.
       
   105         TRAP_IGNORE( method = iESMRInputParams.iCalEntry->MethodL() );
       
   106 
       
   107         switch ( method )
       
   108             {
       
   109             case CCalEntry::EMethodRequest:
       
   110                 {
       
   111                 iMRMethod = EESMRMeetingRequestMethodRequest;
       
   112                 }
       
   113                 break;
       
   114             case CCalEntry::EMethodReply:
       
   115                 {
       
   116                 iMRMethod = EESMRMeetingRequestMethodResponse;
       
   117                 }
       
   118                 break;
       
   119             case CCalEntry::EMethodCancel:
       
   120                 {
       
   121                 iMRMethod = EESMRMeetingRequestMethodCancellation;
       
   122                 }
       
   123                 break;
       
   124             default:
       
   125                 {
       
   126                 iMRMethod = EESMRMeetingRequestMethodUnknown;
       
   127                 }
       
   128                 break;
       
   129             }
       
   130 
       
   131         aResult.iOpType = OperationType();
       
   132         aResult.iMethod = iMRMethod;
       
   133         aResult.iMessage = Message();
       
   134 
       
   135         TBool isAttendee = EFalse;
       
   136         TRAP_IGNORE( isAttendee = ESMRIcalViewerUtils::IsMailboxOwnerAttendeeL(
       
   137                             *(iESMRInputParams.iCalEntry),
       
   138                             iMailClient,
       
   139                             *Message() ) );
       
   140 
       
   141         if ( !isAttendee )
       
   142             {
       
   143             iMRMethod = EESMRMeetingRequestMethodUnknown;
       
   144             aResult.iMethod = EESMRMeetingRequestMethodUnknown;
       
   145             }
       
   146 
       
   147         Observer()->OperationCompleted( aResult );
       
   148         }
       
   149     }
       
   150 
       
   151 // -----------------------------------------------------------------------------
       
   152 // CESMRIcalViewerResolveMRMethodSyncCmd::OperationError
       
   153 // -----------------------------------------------------------------------------
       
   154 //
       
   155 void CESMRIcalViewerResolveMRMethodSyncCmd::OperationError(
       
   156         MESMRIcalViewerObserver::TIcalViewerOperationResult aResult )
       
   157     {
       
   158     FUNC_LOG;
       
   159     aResult.iOpType = OperationType();
       
   160     aResult.iMethod = iMRMethod;
       
   161     aResult.iMessage = Message();
       
   162 
       
   163     Observer()->OperationError( aResult );
       
   164     }
       
   165 
       
   166 // -----------------------------------------------------------------------------
       
   167 // CESMRIcalViewerResolveMRMethodSyncCmd::ExecuteCommandL
       
   168 // -----------------------------------------------------------------------------
       
   169 //
       
   170 void CESMRIcalViewerResolveMRMethodSyncCmd::ExecuteCommandL(
       
   171         CFSMailMessage& aMessage,
       
   172         MESMRIcalViewerObserver& aObserver )
       
   173     {
       
   174     FUNC_LOG;
       
   175     SetObserver( &aObserver );
       
   176     SetMessage( &aMessage );
       
   177 
       
   178     iMRInfoRetrieverCmd = CESMRInfoIcalRetrieverCmd::NewL(
       
   179                                 CalSession(),
       
   180                                 iESMRInputParams );
       
   181 
       
   182     iMRInfoRetrieverCmd->ExecuteCommandL( aMessage, *this );
       
   183     }
       
   184 
       
   185 // -----------------------------------------------------------------------------
       
   186 // CESMRIcalViewerResolveMRMethodSyncCmd::CancelCommand
       
   187 // -----------------------------------------------------------------------------
       
   188 //
       
   189 void CESMRIcalViewerResolveMRMethodSyncCmd::CancelCommand()
       
   190     {
       
   191     FUNC_LOG;
       
   192     if ( iMRInfoRetrieverCmd )
       
   193         {
       
   194         iMRInfoRetrieverCmd->CancelCommand();
       
   195         }
       
   196     }
       
   197 
       
   198 // EOF
       
   199