meetingrequest/mrpolicy/mrentryresolver/src/cmrentrypolicyresolver.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:  ESMR service policy checker implementation
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #include "cmrentrypolicyresolver.h"
       
    20 #include "cmrpolicyresourceiterator.h"
       
    21 #include "cesmrpolicy.h"
       
    22 #include "esmrhelper.h"
       
    23 #include "tesmrscenariodata.h"
       
    24 
       
    25 #include <esmrpolicies.rsg>
       
    26 #include <data_caging_path_literals.hrh>
       
    27 
       
    28 #include "emailtrace.h"
       
    29 
       
    30 namespace // codescanner::namespace
       
    31     {
       
    32     _LIT( KPolicyResourceFile, "esmrpolicies.rsc" );
       
    33     }
       
    34 
       
    35 // ======== MEMBER FUNCTIONS ========
       
    36 
       
    37 // ---------------------------------------------------------------------------
       
    38 // CMREntryPolicyResolver::CMREntryPolicyResolver
       
    39 // ---------------------------------------------------------------------------
       
    40 //
       
    41 CMREntryPolicyResolver::CMREntryPolicyResolver()
       
    42     {
       
    43     FUNC_LOG;
       
    44     // Do nothing
       
    45     }
       
    46 
       
    47 // ---------------------------------------------------------------------------
       
    48 // CMREntryPolicyResolver::~CMREntryPolicyResolver
       
    49 // ---------------------------------------------------------------------------
       
    50 //
       
    51 CMREntryPolicyResolver::~CMREntryPolicyResolver()
       
    52     {
       
    53     FUNC_LOG;
       
    54     
       
    55     delete iIterator;
       
    56     }
       
    57 
       
    58 // ---------------------------------------------------------------------------
       
    59 // CMREntryPolicyResolver::NewL
       
    60 // ---------------------------------------------------------------------------
       
    61 //
       
    62 CMREntryPolicyResolver* CMREntryPolicyResolver::NewL()
       
    63     {
       
    64     FUNC_LOG;
       
    65     CMREntryPolicyResolver* self = new (ELeave) CMREntryPolicyResolver;
       
    66     CleanupStack::PushL( self );
       
    67     self->ConstructL();
       
    68     CleanupStack::Pop( self );
       
    69     return self;
       
    70     }
       
    71 
       
    72 // ---------------------------------------------------------------------------
       
    73 // CMREntryPolicyResolver::ResolveL
       
    74 // ---------------------------------------------------------------------------
       
    75 //
       
    76 CESMRPolicy* CMREntryPolicyResolver::ResolveL( const TESMRScenarioData& aScenData )
       
    77     {
       
    78     iIterator->Reset();
       
    79     
       
    80     CESMRPolicy* policy = NULL;
       
    81     
       
    82     while ( !policy && iIterator->HasNext() )
       
    83         {
       
    84         policy = iIterator->NextPolicyLC();
       
    85         
       
    86         if ( MatchesL( *policy, aScenData ) )
       
    87             {
       
    88             CleanupStack::Pop( policy );
       
    89             }
       
    90         else
       
    91             {
       
    92             CleanupStack::PopAndDestroy( policy );
       
    93             policy = NULL;
       
    94             }
       
    95         }
       
    96     
       
    97     if ( !policy )
       
    98         {
       
    99         User::Leave( KErrNotFound );
       
   100         }
       
   101     
       
   102     return policy;
       
   103     }
       
   104 
       
   105 // ---------------------------------------------------------------------------
       
   106 // CMREntryPolicyResolver::SupportsTypeL
       
   107 // ---------------------------------------------------------------------------
       
   108 //
       
   109 TBool CMREntryPolicyResolver::SupportsTypeL( TESMRCalendarEventType aType )
       
   110     {
       
   111     return ( EESMREventTypeMeetingRequest == aType );
       
   112     }
       
   113 
       
   114 // ---------------------------------------------------------------------------
       
   115 // CMREntryPolicyResolver::MatchesL
       
   116 // ---------------------------------------------------------------------------
       
   117 //
       
   118 TBool CMREntryPolicyResolver::MatchesL(
       
   119     const CESMRPolicy& aPolicy,
       
   120     const TESMRScenarioData& aScenData )
       
   121     {
       
   122     FUNC_LOG;
       
   123     TBool matches( ETrue );
       
   124 
       
   125     if (  aPolicy.ViewMode() != aScenData.iViewMode ||
       
   126          !aPolicy.IsRoleIncluded( aScenData.iRole ) ||
       
   127           aPolicy.AllowedApp() != aScenData.iCallingApp )
       
   128         {
       
   129         matches = EFalse;
       
   130         }
       
   131 
       
   132     return matches;
       
   133     }
       
   134 
       
   135 // ---------------------------------------------------------------------------
       
   136 // CMREntryPolicyResolver::ConstructL
       
   137 // ---------------------------------------------------------------------------
       
   138 //
       
   139 void CMREntryPolicyResolver::ConstructL()
       
   140     {
       
   141     FUNC_LOG;
       
   142     
       
   143     TFileName resource;
       
   144     User::LeaveIfError( ESMRHelper::LocateResourceFile(
       
   145             KPolicyResourceFile,
       
   146             KDC_RESOURCE_FILES_DIR,
       
   147             resource,
       
   148             NULL ) );
       
   149     
       
   150     iIterator = CMRPolicyResourceIterator::NewL(
       
   151             resource,
       
   152             R_ESMR_POLICIES );
       
   153     }
       
   154 
       
   155 // EOF
       
   156