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