callcontinuity/vcc/src/vccengpsproperty.cpp
changeset 0 a4daefaec16c
child 11 bddb6d4447db
equal deleted inserted replaced
-1:000000000000 0:a4daefaec16c
       
     1 /*
       
     2 * Copyright (c) 2007 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:   P&S property writer/reader
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #include "vccengpsproperty.h"
       
    20 #include "rubydebug.h"
       
    21 
       
    22 // ======== MEMBER FUNCTIONS ========
       
    23 
       
    24 // ---------------------------------------------------------------------------
       
    25 // Constructor
       
    26 // ---------------------------------------------------------------------------
       
    27 //
       
    28 CVccEngPsProperty::CVccEngPsProperty()
       
    29 	{
       
    30 	RUBY_DEBUG_BLOCK( "CVccEngPsProperty::CVccEngPsProperty" );
       
    31 	}
       
    32 
       
    33 // ---------------------------------------------------------------------------
       
    34 // Destructor
       
    35 // ---------------------------------------------------------------------------
       
    36 //
       
    37 CVccEngPsProperty::~CVccEngPsProperty()
       
    38 	{
       
    39     RUBY_DEBUG0( "CVccEngPsProperty::~CVccEngPsProperty() - ENTER" );
       
    40     iHoStatusKey.Close();
       
    41     iErrorCodeKey.Close();
       
    42     RUBY_DEBUG0( "CVccEngPsProperty::~CVccEngPsProperty() - EXIT" );
       
    43 	}
       
    44 
       
    45 // ---------------------------------------------------------------------------
       
    46 // 2nd phase constructor
       
    47 // ---------------------------------------------------------------------------
       
    48 //
       
    49 void CVccEngPsProperty::ConstructL()
       
    50     {
       
    51     RUBY_DEBUG_BLOCKL( "CVccEngPsProperty::ConstructL" );
       
    52    
       
    53     DefineKeysL();
       
    54     CreateHandlesL();
       
    55     }
       
    56 
       
    57 // ---------------------------------------------------------------------------
       
    58 // Symbian constructor
       
    59 // ---------------------------------------------------------------------------
       
    60 //
       
    61 CVccEngPsProperty* CVccEngPsProperty::NewL()
       
    62     {
       
    63     RUBY_DEBUG_BLOCKL( "CVccEngPsProperty::NewL" );
       
    64    
       
    65     CVccEngPsProperty* self = new ( ELeave ) CVccEngPsProperty();
       
    66     CleanupStack::PushL( self );
       
    67     self->ConstructL();
       
    68     CleanupStack::Pop( self );
       
    69     
       
    70     return self;
       
    71     }
       
    72 
       
    73 // ---------------------------------------------------------------------------
       
    74 // Sets the value of a VCC property
       
    75 // ---------------------------------------------------------------------------
       
    76 //
       
    77 void CVccEngPsProperty::NotifySubscriberL( TVccHoStatus aStatus, 
       
    78 		TInt aErrorCode )
       
    79 	{
       
    80     RUBY_DEBUG_BLOCKL( "CVccEngPsProperty::NotifySubscriberL" );
       
    81     RUBY_DEBUG1( " -status = %d", aStatus );
       
    82     RUBY_DEBUG1( " -errorcode = %d", aErrorCode);
       
    83    
       
    84 	switch( aStatus )
       
    85 		{
       
    86 		case EVccHoStateIdle:
       
    87 		case EVccCsToPsHoStarted:
       
    88 		case EVccPsToCsHoStarted:
       
    89 		case EVccCsToPsHoInprogress:
       
    90 		case EVccCsToPsHoSuccessful:
       
    91 		case EVccCsToPsHoFailure:
       
    92         case EVccHoUnavailable:
       
    93         case EVccCsToPsNotAllowed:
       
    94         case EVccPsToCsNotAllowed:
       
    95         case EVccHoStateIdleIfSingleCall:
       
    96         case EVccHoAllowedToCsIfSingleCall:
       
    97         case EVccHoAllowedToPsIfSingleCall:
       
    98 			{
       
    99 	  	    RUBY_DEBUG0( " -updating keys" );
       
   100     
       
   101 			User::LeaveIfError( iHoStatusKey.Set( aStatus ));	
       
   102 			User::LeaveIfError( iErrorCodeKey.Set( aErrorCode ));
       
   103             break;
       
   104 			}
       
   105 		case EVccHoStateUnknown:	
       
   106 		default:
       
   107 			{
       
   108 	  	    RUBY_DEBUG0( " -Error, unknown key!!" );
       
   109 
       
   110 			User::Leave( KErrNotFound );
       
   111             break;
       
   112 			}
       
   113 		}
       
   114     }
       
   115 
       
   116 // ---------------------------------------------------------------------------
       
   117 // Gets the Ho status property
       
   118 // ---------------------------------------------------------------------------
       
   119 //
       
   120 TInt CVccEngPsProperty::GetCurrentHoStatus(  TVccHoStatus& aStatus )
       
   121 	{
       
   122     RUBY_DEBUG_BLOCK( "CVccEngPsProperty::GetCurrentHoStatus" );
       
   123    
       
   124 	TInt value ( EVccHoStateUnknown );
       
   125 	TInt err = iHoStatusKey.Get( value );
       
   126 	aStatus = ( TVccHoStatus ) value;
       
   127 	return err;
       
   128 	}
       
   129 
       
   130 // ---------------------------------------------------------------------------
       
   131 // Gets the error code 
       
   132 // ---------------------------------------------------------------------------
       
   133 //
       
   134 TInt CVccEngPsProperty::GetCurrentErrorCode(  TInt& aErrorCode )
       
   135 	{
       
   136 	RUBY_DEBUG_BLOCK( "CVccEngPsProperty::GetCurrentErrorCode" );
       
   137    
       
   138 	TInt err = iErrorCodeKey.Get( aErrorCode );
       
   139 	return err;
       
   140 	}
       
   141 
       
   142 // ---------------------------------------------------------------------------
       
   143 // Defines the keys the UI can update
       
   144 // ---------------------------------------------------------------------------
       
   145 //
       
   146 void CVccEngPsProperty::DefineKeysL()
       
   147 	{
       
   148 	RUBY_DEBUG_BLOCK( "CVccEngPsProperty::DefineKeysL" );
       
   149    
       
   150 	RProcess myProcess;
       
   151 	    
       
   152 	_LIT_SECURITY_POLICY_PASS(KPassReadPolicy);
       
   153 	_LIT_SECURITY_POLICY_S0( KAllowSidPolicy, myProcess.SecureId() );
       
   154 
       
   155 	TInt err = RProperty::Define( KPSVccPropertyCategory,
       
   156 								  KVccPropKeyHoStatus,
       
   157 								  RProperty::EInt,
       
   158 								  KPassReadPolicy,
       
   159 								  KAllowSidPolicy );
       
   160 
       
   161 	if ( err != KErrNone && err != KErrAlreadyExists )
       
   162 		{
       
   163 		User::Leave( err );		
       
   164 		}
       
   165 	
       
   166 	err = RProperty::Define( KPSVccPropertyCategory,
       
   167 							 KVccPropKeyHoError,
       
   168 							 RProperty::EInt,
       
   169 							 KPassReadPolicy,
       
   170 							 KAllowSidPolicy );
       
   171 
       
   172 	if ( err != KErrNone && err != KErrAlreadyExists )
       
   173 		{
       
   174 		User::Leave( err );		
       
   175 		}	
       
   176 	}
       
   177 
       
   178 // ---------------------------------------------------------------------------
       
   179 // Defines the keys the UI can update
       
   180 // ---------------------------------------------------------------------------
       
   181 //
       
   182 void CVccEngPsProperty::CreateHandlesL()
       
   183 	{
       
   184 	RUBY_DEBUG_BLOCKL( "CVccEngPsProperty::CreateHandlesL" );
       
   185    
       
   186 	User::LeaveIfError( iHoStatusKey.Attach( KPSVccPropertyCategory,
       
   187 			KVccPropKeyHoStatus ));
       
   188 	User::LeaveIfError( iErrorCodeKey.Attach( KPSVccPropertyCategory,
       
   189 			KVccPropKeyHoError ));
       
   190 	}