meetingui/meetingrequestviewers/src/CMRCancelModel.cpp
changeset 0 f979ecb2b13e
equal deleted inserted replaced
-1:000000000000 0:f979ecb2b13e
       
     1 /*
       
     2 * Copyright (c) 2002-2004 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:   Model for method CANCEL
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 
       
    21 // INCLUDE FILES
       
    22 #include "CMRCancelModel.h"
       
    23 #include "CMRModelBase.h"
       
    24 #include "ProcessingStructs.h" //meeting request scenarios
       
    25 #include "MMRDataFillerInterface.h"
       
    26 #include "MREntryConsultant.h"
       
    27 #include "CMRProcessor.h"
       
    28 #include "CMRDataFillerCancel.h"
       
    29 #include <eikenv.h> //CEikonEnv
       
    30 #include <CRichBio.h> //rich bio
       
    31 #include "CMRUtilsInternal.h" //MR utils
       
    32 #include <stringloader.h>
       
    33 #include <avkon.rsg> // resouce identifiers
       
    34 #include "meetingrequestviewers.hrh"
       
    35 #include <senduimtmuids.h> //mailbox id's
       
    36 #include "MRViewersPanic.h" //panic enums
       
    37 #include <meetingrequestviewersuires.rsg> // resource identifiers
       
    38 
       
    39 // CONSTANTS
       
    40 /// Unnamed namespace for local definitions
       
    41 namespace {
       
    42 
       
    43 _LIT( KPanicMsg, "CMRCancelModel" );
       
    44 
       
    45 void Panic( TPanicCode aReason )
       
    46     {
       
    47     User::Panic( KPanicMsg, aReason );
       
    48     }
       
    49 }  // namespace
       
    50 
       
    51 
       
    52 // ============================ MEMBER FUNCTIONS ===============================
       
    53 
       
    54 // -----------------------------------------------------------------------------
       
    55 // ?classname::?classname
       
    56 // C++ default constructor can NOT contain any code, that
       
    57 // might leave.
       
    58 // -----------------------------------------------------------------------------
       
    59 //
       
    60 CMRCancelModel::CMRCancelModel(
       
    61     CMRMailboxUtils& aMRMailboxUtils,
       
    62     CMRUtilsInternal& aMRUtils,
       
    63     const MAgnEntryUi::TAgnEntryUiInParams& aInParams )
       
    64     : CMRModelBase( aMRMailboxUtils, aMRUtils, aInParams )
       
    65     {
       
    66     }
       
    67 
       
    68 // -----------------------------------------------------------------------------
       
    69 // ?classname::ConstructL
       
    70 // Symbian 2nd phase constructor can leave.
       
    71 // -----------------------------------------------------------------------------
       
    72 //
       
    73 void CMRCancelModel::ConstructL( RPointerArray<CCalEntry>& aEntries )
       
    74     {
       
    75     CMRModelBase::ConstructL( aEntries );
       
    76     }
       
    77 
       
    78 // -----------------------------------------------------------------------------
       
    79 // ?classname::NewL
       
    80 // Two-phased constructor.
       
    81 // -----------------------------------------------------------------------------
       
    82 //
       
    83 CMRCancelModel* CMRCancelModel::NewL(
       
    84     RPointerArray<CCalEntry>& aEntries,
       
    85     CMRMailboxUtils& aMRMailboxUtils,
       
    86     CMRUtilsInternal& aMRUtils,
       
    87     const MAgnEntryUi::TAgnEntryUiInParams& aInParams)
       
    88     {
       
    89     CMRCancelModel* self = new( ELeave ) CMRCancelModel( aMRMailboxUtils,
       
    90                                                          aMRUtils,
       
    91                                                          aInParams );
       
    92 
       
    93     CleanupStack::PushL( self );
       
    94     self->ConstructL( aEntries );
       
    95     CleanupStack::Pop();
       
    96 
       
    97     return self;
       
    98     }
       
    99 
       
   100 // Destructor
       
   101 CMRCancelModel::~CMRCancelModel()
       
   102     {
       
   103     }
       
   104 	
       
   105 MMRModelInterface::TClosingStatus CMRCancelModel::ClosingStatusL()
       
   106 	{
       
   107 	TClosingStatus retVal( ENone );
       
   108 	return retVal;
       
   109 	}
       
   110 	
       
   111 MMRDataFillerInterface* CMRCancelModel::DataFillerL(CRichBio* aRichBio)
       
   112 	{
       
   113 	__ASSERT_DEBUG( aRichBio, Panic( ECRichBioNull ) );
       
   114 	MMRDataFillerInterface* dataFillerInterface(NULL);
       
   115 	dataFillerInterface = CMRDataFillerCancel::NewL( *aRichBio,
       
   116 	                                                 *this,
       
   117 	                                                 *CEikonEnv::Static(),
       
   118 	                                                 iMRMailboxUtils,
       
   119 	                                                 iInParams );
       
   120 	return dataFillerInterface;
       
   121 	}
       
   122 
       
   123 TBool CMRCancelModel::IsCmdAvailableL( TInt aCommandId )
       
   124     {
       
   125     TInt retVal( EFalse );
       
   126     switch ( aCommandId )
       
   127         {
       
   128         case EMRCommandReplyToOrganiser:
       
   129             {
       
   130             retVal = CanReplyToOrganiserL();            
       
   131             break;
       
   132             }
       
   133         case EMRCommandReplyToSender:
       
   134             {
       
   135             retVal = CanReplyToSenderL();            
       
   136             break;
       
   137             }
       
   138         case EMRCommandReplyToAll:
       
   139             {
       
   140             retVal = CanReplyToAllL();            
       
   141             break;
       
   142             }
       
   143         case EMRCommandForward:
       
   144             {
       
   145             retVal = CanForwardL();            
       
   146             break;
       
   147             }
       
   148         case EMRCommandRemoveFromCalendar:
       
   149             {
       
   150             retVal = CanRemoveFromCalendarL();            
       
   151             break;
       
   152             }            
       
   153         default:
       
   154             {
       
   155             retVal = CMRModelBase::IsCmdAvailableL( aCommandId );
       
   156             break;
       
   157             }                                     
       
   158         }
       
   159     return retVal;
       
   160     }
       
   161 
       
   162 TBool CMRCancelModel::CanReplyToOrganiserL()
       
   163     {
       
   164     TBool retVal( EFalse );
       
   165     if ( iMRProcessor->OwnerRole() != CMRProcessor::EOrganiser )
       
   166         {        
       
   167         retVal = ETrue;
       
   168         }
       
   169 	return retVal;
       
   170     }
       
   171 
       
   172 TBool CMRCancelModel::CanReplyToSenderL()
       
   173     {    
       
   174     TBool retVal( EFalse );    
       
   175 	if ( iInParams.iCallingApp.iUid == KUidMailApplication )
       
   176 		{
       
   177         if ( iMRProcessor->OwnerRole() != CMRProcessor::EOrganiser )
       
   178             { // can reply to sender if sender is not also organizer
       
   179             retVal = !IsSenderOrganizerL();
       
   180             }
       
   181 		}
       
   182 	return retVal;
       
   183     }
       
   184 
       
   185 TBool CMRCancelModel::CanReplyToAllL()
       
   186     {    
       
   187 	return ETrue;
       
   188     }
       
   189 
       
   190 TBool CMRCancelModel::CanForwardL()
       
   191 	{
       
   192 	TBool retVal( EFalse );
       
   193 	const CCalEntry& entry = *( CombinedEntry() );
       
   194 	if ( iInParams.iCallingApp.iUid == KUidMailApplication &&
       
   195 	     IsEntryUsableL( entry ) )
       
   196 		{
       
   197         return ETrue;
       
   198 		}
       
   199 	return retVal;
       
   200 	}
       
   201 	
       
   202 TBool CMRCancelModel::CanRemoveFromCalendarL()
       
   203 	{
       
   204 	const CCalEntry& entry = *( CombinedEntry() );
       
   205 	return MREntryConsultant::ExistsInDbL( entry, iMRUtils );
       
   206 	}
       
   207 
       
   208 //  End of File