callcontinuity/vccpropertyhandler/src/vccuipsproperty.cpp
branchRCL_3
changeset 21 f742655b05bf
parent 20 65a3ef1d5bd0
child 22 d38647835c2e
equal deleted inserted replaced
20:65a3ef1d5bd0 21:f742655b05bf
     1 /*
       
     2 * Copyright (c) 2007-2008 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:   VCC property manager on the UI side
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 #include <e32cmn.h>
       
    21 #include <vccsubscribekeys.h>
       
    22 
       
    23 #include "vccuipsproperty.h"
       
    24 #include "rubydebug.h"
       
    25 
       
    26 // ======== MEMBER FUNCTIONS ========
       
    27 
       
    28 // ---------------------------------------------------------------------------
       
    29 // Constructor
       
    30 // ---------------------------------------------------------------------------
       
    31 //
       
    32 CVccUiPsProperty::CVccUiPsProperty()
       
    33     {
       
    34     RUBY_DEBUG_BLOCK( "CVccUiPsProperty::CVccUiPsProperty" );
       
    35     }
       
    36 
       
    37 // ---------------------------------------------------------------------------
       
    38 // 2nd phase constructor
       
    39 // ---------------------------------------------------------------------------
       
    40 //
       
    41 void CVccUiPsProperty::ConstructL()
       
    42     {
       
    43     RUBY_DEBUG_BLOCKL( "CVccUiPsProperty::ConstructL" );
       
    44 
       
    45     DefineKeysL();
       
    46     CreateHandlesL();
       
    47     }
       
    48 
       
    49 // ---------------------------------------------------------------------------
       
    50 // Symbian constructor
       
    51 // ---------------------------------------------------------------------------
       
    52 //
       
    53 EXPORT_C CVccUiPsProperty* CVccUiPsProperty::NewL()
       
    54     {
       
    55     RUBY_DEBUG_BLOCKL( "CVccUiPsProperty::NewL" );
       
    56 
       
    57     CVccUiPsProperty* self = new ( ELeave ) CVccUiPsProperty();
       
    58     CleanupStack::PushL( self );
       
    59     self->ConstructL();
       
    60     CleanupStack::Pop( self );
       
    61 
       
    62     return self;
       
    63     }
       
    64 
       
    65 // ---------------------------------------------------------------------------
       
    66 // Destructor
       
    67 // ---------------------------------------------------------------------------
       
    68 //
       
    69 EXPORT_C CVccUiPsProperty::~CVccUiPsProperty()
       
    70     {
       
    71     RUBY_DEBUG0( "CVccUiPsProperty::~CVccUiPsProperty() - ENTER" );
       
    72     iHoRequestKey.Close();
       
    73     RUBY_DEBUG0( "CVccUiPsProperty::~CVccUiPsProperty() - EXIT" );
       
    74     }
       
    75 
       
    76 // ---------------------------------------------------------------------------
       
    77 // Sets the value of a VCC property
       
    78 // ---------------------------------------------------------------------------
       
    79 //
       
    80 
       
    81 EXPORT_C void CVccUiPsProperty::NotifySubscriberL( TVccHoRequest aValue )
       
    82     {
       
    83     RUBY_DEBUG_BLOCKL( "CVccUiPsProperty::NotifySubscriberL" );
       
    84     RUBY_DEBUG1( " -value [%d]", aValue);
       
    85 
       
    86     TVccHoRequest currVal;
       
    87 
       
    88     GetCurrentRequest( currVal );
       
    89 
       
    90     RUBY_DEBUG1( " -current value [%d]", currVal);
       
    91 
       
    92     switch( aValue )
       
    93         {
       
    94         case EVccNoRequestOngoing:
       
    95         case EVccManualStartCsToPsHoRequest:
       
    96         case EVccManualCancelCsToPsHoRequest:
       
    97         case EVccManualStartPsToCsHoRequest:
       
    98         case EVccManualCancelPsToCsHoRequest:
       
    99         case EVccAutomaticStartCsToPsHoRequest:
       
   100         case EVccAutomaticStartCsToPsHoRequestIfSingleCall:    
       
   101         case EVccAutomaticCancelCsToPsHoRequest:
       
   102         case EVccAutomaticStartPsToCsHoRequest:
       
   103         case EVccAutomaticStartPsToCsHoRequestIfSingleCall:
       
   104         case EVccAutomaticCancelPsToCsHoRequest:        
       
   105             {
       
   106             RUBY_DEBUG0( " -setting key");
       
   107 
       
   108             User::LeaveIfError( iHoRequestKey.Set( aValue ));
       
   109 
       
   110             break;
       
   111             }
       
   112 
       
   113         case EVccUndefinedRequest:
       
   114         default:
       
   115             {
       
   116             RUBY_DEBUG0( " -Undefined key!!");
       
   117 
       
   118             User::Leave( KErrNotFound );
       
   119 
       
   120             break;
       
   121             }
       
   122         }
       
   123     }
       
   124 
       
   125 // ---------------------------------------------------------------------------
       
   126 // Gets the value of a VCC property
       
   127 // ---------------------------------------------------------------------------
       
   128 //
       
   129 EXPORT_C TInt CVccUiPsProperty::GetCurrentRequest(  TVccHoRequest& aValue )
       
   130     {
       
   131     RUBY_DEBUG_BLOCK( "CVccUiPsProperty::GetCurrentRequest" );
       
   132 
       
   133     TInt value(0);
       
   134     TInt err = iHoRequestKey.Get( value );
       
   135     aValue = static_cast<TVccHoRequest>( value );
       
   136 
       
   137     return err;
       
   138     }
       
   139 
       
   140 // ---------------------------------------------------------------------------
       
   141 // Deletes the keys used by ui
       
   142 // ---------------------------------------------------------------------------
       
   143 //
       
   144 EXPORT_C TInt CVccUiPsProperty::DeleteKeys()
       
   145     {
       
   146     RUBY_DEBUG_BLOCK( "CVccUiPsProperty::DeleteKeys" );
       
   147 
       
   148     iHoRequestKey.Close();
       
   149     TInt err = RProperty::Delete( KPSVccPropertyCategory, KVccPropKeyHoRequest );
       
   150     return err;
       
   151     }
       
   152 
       
   153 // ---------------------------------------------------------------------------
       
   154 // Defines the keys the UI can update
       
   155 // ---------------------------------------------------------------------------
       
   156 //
       
   157 void CVccUiPsProperty::DefineKeysL()
       
   158     {
       
   159     RUBY_DEBUG_BLOCKL( "CVccUiPsProperty::DefineKeysL" );
       
   160 
       
   161     RProcess myProcess;
       
   162 
       
   163     _LIT_SECURITY_POLICY_PASS( KPassReadPolicy );
       
   164     _LIT_SECURITY_POLICY_S0( KAllowSidPolicy, myProcess.SecureId() );
       
   165 
       
   166     TInt err = RProperty::Define( KPSVccPropertyCategory,
       
   167                                   KVccPropKeyHoRequest,
       
   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 CVccUiPsProperty::CreateHandlesL()
       
   183     {
       
   184     RUBY_DEBUG_BLOCKL( "CVccUiPsProperty::CreateHandlesL" );
       
   185 
       
   186     User::LeaveIfError( iHoRequestKey.Attach( KPSVccPropertyCategory,
       
   187               KVccPropKeyHoRequest ));
       
   188     }