psln/Src/PslnPropertySubscriber.cpp
changeset 0 2f259fa3e83a
equal deleted inserted replaced
-1:000000000000 0:2f259fa3e83a
       
     1 /*
       
     2 * Copyright (c) 2005-2006 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:  Starts subscribing PubSub key.
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 // INCLUDE FILES
       
    21 #include    "PslnPropertySubscriber.h"
       
    22 
       
    23 // ============================ MEMBER FUNCTIONS ===============================
       
    24 
       
    25 // -----------------------------------------------------------------------------
       
    26 // C++ constructor can NOT contain any code, that might leave.
       
    27 // 
       
    28 // NOTE that callback method is NOT allowed to leave.
       
    29 // -----------------------------------------------------------------------------
       
    30 //
       
    31 CPslnPropertySubscriber::CPslnPropertySubscriber(
       
    32     TCallBack aCallBack, RProperty& aProperty )
       
    33     : CActive( CActive::EPriorityStandard ), iCallBack( aCallBack ), 
       
    34     iProperty( aProperty )
       
    35     {
       
    36     CActiveScheduler::Add( this );
       
    37     }
       
    38     
       
    39 // Destructor
       
    40 CPslnPropertySubscriber::~CPslnPropertySubscriber()
       
    41     {
       
    42     Cancel();    
       
    43     }
       
    44 
       
    45 // -----------------------------------------------------------------------------
       
    46 // CPslnPropertySubscriber::Subscribe
       
    47 // -----------------------------------------------------------------------------
       
    48 //
       
    49 void CPslnPropertySubscriber::Subscribe()
       
    50     {
       
    51     if ( !IsActive() )
       
    52         {
       
    53         iProperty.Subscribe( iStatus );
       
    54         SetActive();
       
    55         }
       
    56     }
       
    57 
       
    58 // -----------------------------------------------------------------------------
       
    59 // CPslnPropertySubscriber::RunL
       
    60 // -----------------------------------------------------------------------------
       
    61 //
       
    62 void CPslnPropertySubscriber::RunL()
       
    63     {
       
    64     if ( iStatus.Int() == KErrNone )
       
    65         {
       
    66         Subscribe();
       
    67         iCallBack.CallBack();
       
    68         }
       
    69     }
       
    70 
       
    71 // -----------------------------------------------------------------------------
       
    72 // CPslnPropertySubscriber::DoCancel
       
    73 // -----------------------------------------------------------------------------
       
    74 //
       
    75 void CPslnPropertySubscriber::DoCancel()
       
    76     {
       
    77     iProperty.Cancel();
       
    78     }
       
    79 
       
    80 //  End of File