meetingrequest/mrpolicy/mrcalentryresolver/src/cmrcalentrypolicyresolver.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:  MR Cal Entry policy resolver ECom plugin implementation
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #include "cmrcalentrypolicyresolver.h"
       
    20 #include "cmrpolicyresourceiterator.h"
       
    21 #include "cesmrpolicy.h"
       
    22 #include "esmrhelper.h"
       
    23 #include "tesmrscenariodata.h"
       
    24 
       
    25 #include <bccaleventpolicies.rsg>
       
    26 #include <data_caging_path_literals.hrh>
       
    27 
       
    28 #include "emailtrace.h"
       
    29 
       
    30 namespace // codescanner::namespace
       
    31     {
       
    32     _LIT( KPolicyResourceFile, "bccaleventpolicies.rsc" );
       
    33     }
       
    34 
       
    35 // ======== MEMBER FUNCTIONS ========
       
    36 
       
    37 // ---------------------------------------------------------------------------
       
    38 // CMRCalEntryPolicyResolver::CMRCalEntryPolicyResolver
       
    39 // ---------------------------------------------------------------------------
       
    40 //
       
    41 CMRCalEntryPolicyResolver::CMRCalEntryPolicyResolver()
       
    42     {
       
    43     FUNC_LOG;
       
    44     // Do nothing
       
    45     }
       
    46 
       
    47 // ---------------------------------------------------------------------------
       
    48 // CMRCalEntryPolicyResolver::~CMRCalEntryPolicyResolver
       
    49 // ---------------------------------------------------------------------------
       
    50 //
       
    51 CMRCalEntryPolicyResolver::~CMRCalEntryPolicyResolver()
       
    52     {
       
    53     FUNC_LOG;
       
    54     
       
    55     delete iIterator;
       
    56     }
       
    57 
       
    58 // ---------------------------------------------------------------------------
       
    59 // CMRCalEntryPolicyResolver::NewL
       
    60 // ---------------------------------------------------------------------------
       
    61 //
       
    62 CMRCalEntryPolicyResolver* CMRCalEntryPolicyResolver::NewL()
       
    63     {
       
    64     FUNC_LOG;
       
    65     CMRCalEntryPolicyResolver* self = new (ELeave) CMRCalEntryPolicyResolver;
       
    66     CleanupStack::PushL( self );
       
    67     self->ConstructL();
       
    68     CleanupStack::Pop( self );
       
    69     return self;
       
    70     }
       
    71 
       
    72 // ---------------------------------------------------------------------------
       
    73 // CMRCalEntryPolicyResolver::ResolveL
       
    74 // ---------------------------------------------------------------------------
       
    75 //
       
    76 CESMRPolicy* CMRCalEntryPolicyResolver::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 // CMRCalEntryPolicyResolver::SupportsTypeL
       
   107 // ---------------------------------------------------------------------------
       
   108 //
       
   109 TBool CMRCalEntryPolicyResolver::SupportsTypeL( TESMRCalendarEventType aType )
       
   110     {
       
   111     switch ( aType )
       
   112         {
       
   113         case EESMREventTypeAppt:
       
   114         case EESMREventTypeETodo:
       
   115         case EESMREventTypeEEvent:
       
   116         case EESMREventTypeEReminder:
       
   117         case EESMREventTypeEAnniv:
       
   118             {
       
   119             return ETrue;
       
   120             }
       
   121         default:
       
   122             {
       
   123             return EFalse;
       
   124             }
       
   125         }
       
   126     }
       
   127 
       
   128 // ---------------------------------------------------------------------------
       
   129 // CMRCalEntryPolicyResolver::MatchesL
       
   130 // ---------------------------------------------------------------------------
       
   131 //
       
   132 TBool CMRCalEntryPolicyResolver::MatchesL(
       
   133     const CESMRPolicy& aPolicy,
       
   134     const TESMRScenarioData& aScenData )
       
   135     {
       
   136     FUNC_LOG;
       
   137     TBool matches( ETrue );
       
   138         
       
   139     if ( aPolicy.ViewMode() != aScenData.iViewMode
       
   140          || aPolicy.EventType() != aScenData.iEntryType
       
   141          || aPolicy.AllowedApp() != aScenData.iCallingApp )
       
   142         {
       
   143         matches = EFalse;
       
   144         }
       
   145         
       
   146     return matches;
       
   147     }
       
   148 
       
   149 // ---------------------------------------------------------------------------
       
   150 // CMRCalEntryPolicyResolver::ConstructL
       
   151 // ---------------------------------------------------------------------------
       
   152 //
       
   153 void CMRCalEntryPolicyResolver::ConstructL()
       
   154     {
       
   155     FUNC_LOG;
       
   156     
       
   157     TFileName resource;
       
   158     User::LeaveIfError( ESMRHelper::LocateResourceFile(
       
   159             KPolicyResourceFile,
       
   160             KDC_RESOURCE_FILES_DIR,
       
   161             resource,
       
   162             NULL ) );
       
   163     
       
   164     iIterator = CMRPolicyResourceIterator::NewL(
       
   165             resource,
       
   166             R_BCCALEVENT_POLICIES );
       
   167     }
       
   168 
       
   169 // EOF
       
   170