uifw/AvKon/AknTransitionUtils/src/aknpsobserver.cpp
changeset 0 2f259fa3e83a
equal deleted inserted replaced
-1:000000000000 0:2f259fa3e83a
       
     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:  Transition utilities.
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #include <e32property.h>
       
    20 
       
    21 #include "aknpsobserver.h"
       
    22 
       
    23 //----------------------------------------------------------------------------
       
    24 //----------------------------------------------------------------------------
       
    25 //
       
    26 CAknPsObserver* CAknPsObserver::NewL( MAknPsObserver* aClient, 
       
    27                                       const TUid aCategory, 
       
    28                                       const TUint aKey )
       
    29     {
       
    30     CAknPsObserver* self = new ( ELeave ) CAknPsObserver( aClient, aCategory, 
       
    31                                                           aKey);
       
    32     CleanupStack::PushL( self );
       
    33     self->Construct( aCategory, aKey );
       
    34     CleanupStack::Pop();
       
    35     return self;
       
    36     }
       
    37 
       
    38 //----------------------------------------------------------------------------
       
    39 //----------------------------------------------------------------------------
       
    40 //
       
    41 CAknPsObserver* CAknPsObserver::New( MAknPsObserver* aClient, 
       
    42                                      const TUid aCategory, 
       
    43                                      const TUint aKey )
       
    44     {
       
    45     CAknPsObserver* self = new CAknPsObserver( aClient, aCategory, aKey);
       
    46     if(self)
       
    47     	{
       
    48 	    self->Construct( aCategory, aKey );
       
    49     	}
       
    50     return self;
       
    51     }
       
    52     
       
    53 //----------------------------------------------------------------------------
       
    54 //----------------------------------------------------------------------------
       
    55 //
       
    56 CAknPsObserver::~CAknPsObserver()
       
    57     {
       
    58     Cancel();
       
    59     iProperty.Close();
       
    60     }
       
    61     
       
    62 //----------------------------------------------------------------------------
       
    63 //----------------------------------------------------------------------------
       
    64 //
       
    65 void CAknPsObserver::DoCancel()
       
    66     {
       
    67     iProperty.Cancel();
       
    68     }
       
    69     
       
    70 //----------------------------------------------------------------------------
       
    71 //----------------------------------------------------------------------------
       
    72 //
       
    73 void CAknPsObserver::RunL()
       
    74     {
       
    75     if ( iStatus.Int() == KErrNone)
       
    76         {
       
    77         TInt val;
       
    78         iProperty.Subscribe( iStatus );
       
    79         iProperty.Get( val );
       
    80         SetActive();
       
    81         iClient->PsValueUpdated( iCategory, iKey, val );
       
    82         }
       
    83     }
       
    84 
       
    85 //----------------------------------------------------------------------------
       
    86 //----------------------------------------------------------------------------
       
    87 //
       
    88 void CAknPsObserver::Construct( const TUid aCategory, const TUint aKey )
       
    89     {
       
    90     CActiveScheduler::Add( this );
       
    91     iProperty.Attach( aCategory, aKey );
       
    92     iProperty.Subscribe( iStatus );
       
    93     SetActive();
       
    94     }
       
    95 
       
    96 //----------------------------------------------------------------------------
       
    97 //----------------------------------------------------------------------------
       
    98 //
       
    99 TInt CAknPsObserver::GetCurrentValue( TInt& aValue )
       
   100     {
       
   101     return iProperty.Get( aValue );
       
   102     }
       
   103 
       
   104 //----------------------------------------------------------------------------
       
   105 //----------------------------------------------------------------------------
       
   106 //
       
   107 CAknPsObserver::CAknPsObserver( MAknPsObserver* aClient, const TUid aCategory,
       
   108                                 const TUint aKey )
       
   109     : CActive( EPriorityStandard ), iClient( aClient ),
       
   110       iCategory( aCategory ), iKey( aKey )
       
   111     {
       
   112     }
       
   113