wvuing/wvuiave/AppSrc/CCAPSPropWatcher.cpp
branchRCL_3
changeset 13 a941bc465d9f
parent 0 094583676ce7
equal deleted inserted replaced
12:6ca72c0fe49a 13:a941bc465d9f
       
     1 /*
       
     2 * Copyright (c) 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:  Publish & Subscribe property watcher
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 // INCLUDE FILES
       
    21 #include    "CCAPSPropWatcher.h"
       
    22 #include    "MCAPSPropChangeObserver.h"
       
    23 
       
    24 
       
    25 // ============================ MEMBER FUNCTIONS ===============================
       
    26 
       
    27 // -----------------------------------------------------------------------------
       
    28 // CCAPSPropWatcher::CCAPSPropWatcher
       
    29 // C++ default constructor can NOT contain any code, that
       
    30 // might leave.
       
    31 // -----------------------------------------------------------------------------
       
    32 //
       
    33 CCAPSPropWatcher::CCAPSPropWatcher( MCAPSPropChangeObserver* aObserver )
       
    34         : CActive( CActive::EPriorityIdle ),
       
    35         iObserver( aObserver )
       
    36     {
       
    37 
       
    38     }
       
    39 
       
    40 // -----------------------------------------------------------------------------
       
    41 // CCAPSPropWatcher::ConstructL
       
    42 // Symbian 2nd phase constructor can leave.
       
    43 // -----------------------------------------------------------------------------
       
    44 //
       
    45 void CCAPSPropWatcher::ConstructL( TUid aCategory, TUint aKey )
       
    46     {
       
    47     User::LeaveIfError( iProperty.Attach( aCategory, aKey ) );
       
    48     CActiveScheduler::Add( this );
       
    49     RunL();
       
    50     }
       
    51 
       
    52 // -----------------------------------------------------------------------------
       
    53 // CCAPSPropWatcher::NewL
       
    54 // Two-phased constructor.
       
    55 // -----------------------------------------------------------------------------
       
    56 //
       
    57 CCAPSPropWatcher* CCAPSPropWatcher::NewL( MCAPSPropChangeObserver* aObserver, TUid aCategory, TUint aKey )
       
    58     {
       
    59     CCAPSPropWatcher* self = new( ELeave ) CCAPSPropWatcher( aObserver );
       
    60 
       
    61     CleanupStack::PushL( self );
       
    62     self->ConstructL( aCategory, aKey );
       
    63     CleanupStack::Pop();
       
    64 
       
    65     return self;
       
    66     }
       
    67 
       
    68 
       
    69 // Destructor
       
    70 CCAPSPropWatcher::~CCAPSPropWatcher()
       
    71     {
       
    72     Cancel();
       
    73     iProperty.Close();
       
    74     }
       
    75 
       
    76 
       
    77 // -----------------------------------------------------------------------------
       
    78 // CCAPSPropWatcher::RunL
       
    79 // (other items were commented in a header).
       
    80 // -----------------------------------------------------------------------------
       
    81 //
       
    82 void CCAPSPropWatcher::RunL()
       
    83     {
       
    84     iProperty.Subscribe( iStatus );
       
    85     SetActive();
       
    86     if ( iObserver )
       
    87         {
       
    88         iObserver->HandlePropertyChanged();
       
    89         }
       
    90     }
       
    91 
       
    92 // -----------------------------------------------------------------------------
       
    93 // CCAPSPropWatcher::DoCancel
       
    94 // (other items were commented in a header).
       
    95 // -----------------------------------------------------------------------------
       
    96 //
       
    97 void CCAPSPropWatcher::DoCancel()
       
    98     {
       
    99     iProperty.Cancel();
       
   100     }
       
   101 
       
   102 //  End of File