devencdiskutils/DevEncStarter/src/DevEncStarterPropertyObserver.cpp
changeset 0 164170e6151a
equal deleted inserted replaced
-1:000000000000 0:164170e6151a
       
     1 /*
       
     2 * Copyright (c) 2005 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:  
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 // INCLUDE FILES
       
    20 #include "DevEncStarterPropertyObserver.h"
       
    21 
       
    22 // ============================ MEMBER FUNCTIONS ===============================
       
    23 
       
    24 // -----------------------------------------------------------------------------
       
    25 // CDevEncStarterPropertyObserver::CPropertyObserver
       
    26 // C++ default constructor can NOT contain any code, that
       
    27 // might leave.
       
    28 // -----------------------------------------------------------------------------
       
    29 //
       
    30 CDevEncStarterPropertyObserver::CDevEncStarterPropertyObserver(
       
    31                                MDevEncStarterPropertyChangeObserver& aObserver,
       
    32                                const TUid& aCategory,
       
    33                                const TUint aKey )
       
    34     : CActive( CActive::EPriorityStandard ),
       
    35     iObserver( aObserver ),
       
    36     iCategory( aCategory ),
       
    37     iKey( aKey )
       
    38     {
       
    39     }
       
    40 
       
    41 // -----------------------------------------------------------------------------
       
    42 // CDevEncStarterPropertyObserver::ConstructL
       
    43 // Symbian 2nd phase constructor can leave.
       
    44 // -----------------------------------------------------------------------------
       
    45 //
       
    46 void CDevEncStarterPropertyObserver::ConstructL()
       
    47     {
       
    48     User::LeaveIfError( iProperty.Attach( iCategory, iKey ) );
       
    49     CActiveScheduler::Add( this );
       
    50     iProperty.Subscribe( iStatus );
       
    51     SetActive();
       
    52     }
       
    53 
       
    54 // -----------------------------------------------------------------------------
       
    55 // CDevEncStarterPropertyObserver::NewL
       
    56 // Two-phased constructor.
       
    57 // -----------------------------------------------------------------------------
       
    58 //
       
    59 CDevEncStarterPropertyObserver* CDevEncStarterPropertyObserver::NewL(
       
    60                                MDevEncStarterPropertyChangeObserver& aObserver,
       
    61                                const TUid& aCategory,
       
    62                                const TUint aKey )
       
    63     {
       
    64     CDevEncStarterPropertyObserver* self =
       
    65         new ( ELeave ) CDevEncStarterPropertyObserver( aObserver, aCategory, aKey );
       
    66     CleanupStack::PushL( self );
       
    67     self->ConstructL();
       
    68     CleanupStack::Pop( self );
       
    69     return self;
       
    70     }
       
    71 
       
    72 // Destructor
       
    73 CDevEncStarterPropertyObserver::~CDevEncStarterPropertyObserver()
       
    74     {
       
    75     Cancel();
       
    76     iProperty.Close();
       
    77     }
       
    78 
       
    79 // -----------------------------------------------------------------------------
       
    80 // CDevEncStarterPropertyObserver::RunL
       
    81 //
       
    82 // (other items were commented in a header).
       
    83 // -----------------------------------------------------------------------------
       
    84 //
       
    85 void CDevEncStarterPropertyObserver::RunL()
       
    86     {
       
    87     iProperty.Subscribe( iStatus );
       
    88     SetActive();
       
    89     TInt err = iProperty.Get( iValue );
       
    90     if ( err )
       
    91         {
       
    92         iObserver.HandlePropertyChangeErrorL( iCategory, iKey, err );
       
    93         }
       
    94     else
       
    95         {
       
    96         iObserver.HandlePropertyChangeL( iCategory, iKey, iValue );
       
    97         }
       
    98     }
       
    99 
       
   100 // -----------------------------------------------------------------------------
       
   101 // CDevEncStarterPropertyObserver::DoCancel
       
   102 // Cancels an outstanding active request
       
   103 // (other items were commented in a header).
       
   104 // -----------------------------------------------------------------------------
       
   105 //
       
   106 void CDevEncStarterPropertyObserver::DoCancel()
       
   107     {
       
   108     iProperty.Cancel();
       
   109     }
       
   110 
       
   111 // -----------------------------------------------------------------------------
       
   112 // CDevEncStarterPropertyObserver::GetValue
       
   113 // Returns KErrNone if operation was successful
       
   114 // Actual value is written to aValue
       
   115 // (other items were commented in a header).
       
   116 // -----------------------------------------------------------------------------
       
   117 //
       
   118 void CDevEncStarterPropertyObserver::GetValue( TInt& aValue ) const
       
   119     {
       
   120     aValue = iValue;
       
   121     }
       
   122 
       
   123 // End of File