accessoryservices/pluggeddisplay/tsrc/stubs/tvoutconfig/src/tvoutstubeventlistener.cpp
author Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
Tue, 02 Feb 2010 00:53:00 +0200
changeset 0 4e1aa6a622a0
child 70 653a8b91b95e
permissions -rw-r--r--
Revision: 201003

/*
* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
* All rights reserved.
* This component and the accompanying materials are made available
* under the terms of "Eclipse Public License v1.0"
* which accompanies this distribution, and is available
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
*
* Initial Contributors:
* Nokia Corporation - initial contribution.
*
* Contributors:
*
* Description:  Implementation of CTVOutStubEventListener class.
*
*/

#include "tvoutconfigstatuscontrol.h"
#include "tvoutstubeventlistener.h"
#include "tvoutstubeventsender.h"

// ======== MEMBER FUNCTIONS ========

// ---------------------------------------------------------------------------
// ?description_if_needed
// ---------------------------------------------------------------------------
//
CTVOutStubEventListener::CTVOutStubEventListener( MTVOutStubEventSender& aSender )
  : CActive( EPriorityStandard ),
    iSender( aSender )
    {
    CActiveScheduler::Add( this );
    }

// ---------------------------------------------------------------------------
// ?description_if_needed
// ---------------------------------------------------------------------------
//
void CTVOutStubEventListener::ConstructL( TUid aCategory, TUint aKey )
    {
    //RProperty::Define( KTVOutStatusControlCategory, KTVOutStatusControlCableConnect, RProperty::EInt );
    RProperty::Define( aCategory, aKey, RProperty::EInt );
    User::LeaveIfError( iProperty.Attach( aCategory, aKey ) );
    iCategory = aCategory;
    iKey = aKey;
    iProperty.Set( 0 );
    iProperty.Subscribe( iStatus );
    SetActive();
    }

// ---------------------------------------------------------------------------
// ?description_if_needed
// ---------------------------------------------------------------------------
//
CTVOutStubEventListener* CTVOutStubEventListener::NewL(
        MTVOutStubEventSender& aSender,
        TUid aCategory,
        TUint aKey )
    {
    CTVOutStubEventListener* self = new( ELeave ) CTVOutStubEventListener( aSender );
    CleanupStack::PushL( self );
    self->ConstructL( aCategory, aKey );
    CleanupStack::Pop( self );
    return self;
    }

// ---------------------------------------------------------------------------
// ?description_if_needed
// ---------------------------------------------------------------------------
//
CTVOutStubEventListener::~CTVOutStubEventListener()
    {
    Cancel();

    iProperty.Close();
    }

// ---------------------------------------------------------------------------
// From class CActive.
// ---------------------------------------------------------------------------
//
void CTVOutStubEventListener::DoCancel()
    {
    iProperty.Cancel();
    }

// ---------------------------------------------------------------------------
// From class CActive.
// ---------------------------------------------------------------------------
//
void CTVOutStubEventListener::RunL()
    {
    if ( iStatus == KErrNone )
        {
        TInt value;
        TInt errorCode = iProperty.Get( value );

        if ( errorCode == KErrNone )
            {
            iSender.SendEvent( iCategory, iKey, value );
            }
        }

    if ( iStatus != KErrCancel )
        {
        iProperty.Subscribe( iStatus );
        SetActive();
        }
    }