vtengines/videoteleng/Src/Base/CVtEngPubSubsListener.cpp
changeset 0 ed9695c8bcbe
equal deleted inserted replaced
-1:000000000000 0:ed9695c8bcbe
       
     1 /*
       
     2 * Copyright (c) 2004-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 and subscribe settings listener.
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 // INCLUDE FILES
       
    20 #include    "CVTEngPubSubsListener.h"
       
    21 #include    "MVtEngSettingPSObserver.h"
       
    22 #include    <cvtlogger.h>
       
    23 
       
    24 
       
    25 // ============================ MEMBER FUNCTIONS ===============================
       
    26 
       
    27 // -----------------------------------------------------------------------------
       
    28 // CVtEngPubSubsListener::CVtEngPubSubsListener
       
    29 // C++ constructor can NOT contain any code, that
       
    30 // might leave.
       
    31 // -----------------------------------------------------------------------------
       
    32 //
       
    33 CVtEngPubSubsListener::CVtEngPubSubsListener(
       
    34     const TUid aUid, const TInt aKey, MVtEngSettingPSObserver* aObserver ) :
       
    35         CActive( CActive::EPriorityStandard ),
       
    36         iUid( aUid ), iId( aKey ), iCallback( aObserver )
       
    37     {
       
    38     __VTPRINT( DEBUG_CONSTRUCT, "CVtEngPubSubsListener C++" )
       
    39     }
       
    40 
       
    41 // -----------------------------------------------------------------------------
       
    42 // CVtEngPubSubsListener::~CVtEngPubSubsListener
       
    43 // Destructor.
       
    44 // -----------------------------------------------------------------------------
       
    45 //
       
    46 CVtEngPubSubsListener::~CVtEngPubSubsListener()
       
    47     {
       
    48     __VTPRINTENTER( "PSLis.~" )
       
    49     Cancel();
       
    50     iProperty.Close();
       
    51     __VTPRINTEXIT( "PSLis.~" )
       
    52     }
       
    53 
       
    54 // -----------------------------------------------------------------------------
       
    55 // CVtEngPubSubsListener::RunL
       
    56 // From CActive.
       
    57 // -----------------------------------------------------------------------------
       
    58 //
       
    59 void CVtEngPubSubsListener::RunL()
       
    60     {
       
    61     __VTPRINTENTER( "PSLis.RunL" )
       
    62     const TRequestStatus status( iStatus );
       
    63     StartListening();
       
    64     iCallback->HandleNotifyPSL( iUid, iId, status );
       
    65     __VTPRINTEXIT( "PSLis.RunL" )
       
    66     }
       
    67 
       
    68 // -----------------------------------------------------------------------------
       
    69 // CVtEngPubSubsListener::DoCancel
       
    70 // From CActive.
       
    71 // -----------------------------------------------------------------------------
       
    72 //
       
    73 void CVtEngPubSubsListener::DoCancel()
       
    74     {
       
    75     __VTPRINTENTER( "PSLis.DoCancel" )
       
    76     iProperty.Cancel();
       
    77     __VTPRINTEXIT( "PSLis.DoCancel" )
       
    78     }
       
    79 
       
    80 // -----------------------------------------------------------------------------
       
    81 // CVtEngPubSubsListener::RunError
       
    82 // From CActive.
       
    83 // -----------------------------------------------------------------------------
       
    84 //
       
    85 TInt CVtEngPubSubsListener::RunError( TInt /*aError*/ )
       
    86     {
       
    87     __VTPRINTENTER( "PSLis.RunError" )
       
    88     __VTPRINTEXIT( "PSLis.RunError" )
       
    89     return KErrNone;
       
    90     }
       
    91 
       
    92 // -----------------------------------------------------------------------------
       
    93 // CVtEngPubSubsListener::NewL
       
    94 // -----------------------------------------------------------------------------
       
    95 //
       
    96 CVtEngPubSubsListener* CVtEngPubSubsListener::NewL( const TUid aUid, 
       
    97     const TInt aKey, MVtEngSettingPSObserver* aObserver )
       
    98     {
       
    99     __VTPRINTENTER( "PSLis.NewL" )
       
   100     CVtEngPubSubsListener* self = new( ELeave ) 
       
   101         CVtEngPubSubsListener( aUid, aKey, aObserver );
       
   102     CleanupStack::PushL( self );
       
   103     self->ConstructL();
       
   104     CleanupStack::Pop();
       
   105     __VTPRINTEXIT( "PSLis.NewL" )
       
   106     return self;
       
   107     }
       
   108 
       
   109 // -----------------------------------------------------------------------------
       
   110 // CVtEngPubSubsListener::StartListening
       
   111 // -----------------------------------------------------------------------------
       
   112 //
       
   113 void CVtEngPubSubsListener::StartListening() 
       
   114     {
       
   115     iProperty.Subscribe( iStatus );
       
   116     SetActive();
       
   117     }
       
   118 
       
   119 // -----------------------------------------------------------------------------
       
   120 // CVtEngPubSubsListener::ConstructL
       
   121 // -----------------------------------------------------------------------------
       
   122 //
       
   123 void CVtEngPubSubsListener::ConstructL()
       
   124     {
       
   125     CActiveScheduler::Add( this );
       
   126     
       
   127     User::LeaveIfError ( iProperty.Attach( iUid, iId, EOwnerThread ) );
       
   128     StartListening();
       
   129     }
       
   130 
       
   131 // -----------------------------------------------------------------------------
       
   132 // CVtEngPubSubsListener::Get
       
   133 // Read integer value.
       
   134 // -----------------------------------------------------------------------------
       
   135 //
       
   136 TInt CVtEngPubSubsListener::Get( TInt& aVal )
       
   137     {
       
   138     return iProperty.Get( iUid, iId, aVal );
       
   139     }
       
   140 
       
   141 // -----------------------------------------------------------------------------
       
   142 // CVtEngPubSubsListener::Get
       
   143 // Read binary value.
       
   144 // -----------------------------------------------------------------------------
       
   145 //
       
   146 TInt CVtEngPubSubsListener::Get( TDes8& aVal )
       
   147     {
       
   148     return iProperty.Get( iUid, iId, aVal );
       
   149     }
       
   150   
       
   151 // -----------------------------------------------------------------------------
       
   152 // CVtEngPubSubsListener::Get
       
   153 // Read string value.
       
   154 // -----------------------------------------------------------------------------
       
   155 //      
       
   156 TInt CVtEngPubSubsListener::Get( TDes16& aVal )
       
   157     {
       
   158     return iProperty.Get( iUid, iId, aVal );
       
   159     }
       
   160 
       
   161 // End of File