contextframework/cfwplugins/PSStateSourcePlugIn/src/psstatemapper.cpp
changeset 0 2e3d3ce01487
equal deleted inserted replaced
-1:000000000000 0:2e3d3ce01487
       
     1 /*
       
     2 * Copyright (c) 2006-2006 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:  CPSStateMapper class implementation.
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #include "psstatemapper.h"
       
    20 #include "psstatemapperint.h"
       
    21 
       
    22 namespace
       
    23     {
       
    24     #ifdef _DEBUG
       
    25     
       
    26     // Panic category
       
    27     _LIT( KPanicCat, "PSStateMap" );
       
    28     
       
    29     // Panic codes
       
    30     enum TPanicReason
       
    31         {
       
    32         EInvalidConstructionParameters,
       
    33         EPropertyAlreadySubscribed
       
    34         };
       
    35         
       
    36     // Local panic function
       
    37     LOCAL_C void Panic( TInt aCode )
       
    38         {
       
    39         User::Panic( KPanicCat, aCode );
       
    40         }
       
    41     
       
    42     #endif
       
    43     }
       
    44   
       
    45 // Destructor
       
    46 CPSStateMapper::~CPSStateMapper()
       
    47     {
       
    48     Cancel();
       
    49     iProperty.Close();
       
    50     delete iSource;
       
    51     delete iType;
       
    52     delete iContext;
       
    53     }
       
    54 
       
    55 CPSStateMapper::CPSStateMapper( MCFContextInterface& aCF ) : 
       
    56 	CActive( EPriorityStandard ),
       
    57 	iCF (aCF)
       
    58     {
       
    59     CActiveScheduler::Add( this );
       
    60     }
       
    61     
       
    62 void CPSStateMapper::ConstructL( )
       
    63     {
       
    64     iContext = CCFContextObject::NewL();
       
    65     }
       
    66 
       
    67 // METHODS
       
    68 
       
    69 
       
    70 void CPSStateMapper::SetPSCategory (TUid aPSCategory)
       
    71 	{
       
    72 	iPSCategory = aPSCategory;	
       
    73 	}
       
    74 
       
    75 void CPSStateMapper::SetPSKey (TUint32 aKey)
       
    76 	{
       
    77 	iPSKey = aKey;	
       
    78 	}
       
    79 
       
    80 void CPSStateMapper::SetSecurityPolicy (const TSecurityPolicy& aSecurityPolicy)
       
    81 	{
       
    82 	iSecurityPolicy = aSecurityPolicy;	
       
    83 	}
       
    84 
       
    85 void CPSStateMapper::SetSourceL ( const TDesC& aSource )
       
    86 	{
       
    87 	delete iSource;
       
    88 	iSource = NULL;
       
    89 	iSource = aSource.AllocL();
       
    90 	}
       
    91 
       
    92 
       
    93 
       
    94 void CPSStateMapper::SetTypeL ( const TDesC& aType )
       
    95 	{
       
    96 	delete iType;
       
    97 	iType = NULL;
       
    98 	iType = aType.AllocL();	
       
    99 	}    
       
   100 
       
   101 void CPSStateMapper::SetPassThrough(TBool aPassThrough)
       
   102 	{
       
   103 	iPassThrough = aPassThrough;
       
   104 	}
       
   105 
       
   106 //-----------------------------------------------------------------------------
       
   107 // CPSStateMapper::Source
       
   108 //-----------------------------------------------------------------------------
       
   109 //
       
   110 const TDesC& CPSStateMapper::Source() const
       
   111     {
       
   112     return *iSource;
       
   113     }
       
   114 
       
   115 //-----------------------------------------------------------------------------
       
   116 // CPSStateMapper::Type
       
   117 //-----------------------------------------------------------------------------
       
   118 //
       
   119 const TDesC& CPSStateMapper::Type() const
       
   120     {
       
   121     return *iType;
       
   122     }
       
   123 
       
   124 //-----------------------------------------------------------------------------
       
   125 // CPSStateMapper::SecurityPolicy
       
   126 //-----------------------------------------------------------------------------
       
   127 //
       
   128 const TSecurityPolicy& CPSStateMapper::SecurityPolicy() const
       
   129     {
       
   130     return iSecurityPolicy;
       
   131     }
       
   132 
       
   133 //-----------------------------------------------------------------------------
       
   134 // CPSStateMapper::Subscribe
       
   135 //-----------------------------------------------------------------------------
       
   136 //
       
   137 void CPSStateMapper::Subscribe()
       
   138     {
       
   139     __ASSERT_DEBUG( !IsActive(), Panic( EPropertyAlreadySubscribed ) );
       
   140     
       
   141     iProperty.Subscribe( iStatus );
       
   142     SetActive();
       
   143     }
       
   144 
       
   145 //-----------------------------------------------------------------------------
       
   146 // CPSStateMapper::RunL
       
   147 //-----------------------------------------------------------------------------
       
   148 //
       
   149 void CPSStateMapper::RunL()
       
   150     {
       
   151     if( iStatus == KErrNone )
       
   152         {
       
   153         ProperyChangedL();
       
   154         }
       
   155         
       
   156     Subscribe();
       
   157     }
       
   158 
       
   159 //-----------------------------------------------------------------------------
       
   160 // CPSStateMapper::DoCancel
       
   161 //-----------------------------------------------------------------------------
       
   162 //
       
   163 void CPSStateMapper::DoCancel()
       
   164     {
       
   165     iProperty.Cancel();
       
   166     }
       
   167 
       
   168 //-----------------------------------------------------------------------------
       
   169 // CPSStateMapper::RunError
       
   170 //-----------------------------------------------------------------------------
       
   171 //
       
   172 TInt CPSStateMapper::RunError( TInt /*aError*/ )
       
   173     {
       
   174     Subscribe();
       
   175     
       
   176     return KErrNone;
       
   177     }