bluetoothengine/btpbap/src/DisconnectHelper.cpp
author Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
Mon, 18 Jan 2010 20:28:57 +0200
changeset 0 f63038272f30
permissions -rw-r--r--
Revision: 201001 Kit: 201003

/*
* Copyright (c) 2007-2007 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:  This is the bteng ecom plugin class implementation.
*
*/


#include "DisconnectHelper.h"
#include "debug.h"


// ---------------------------------------------------------------------------
// NewL
// ---------------------------------------------------------------------------
CDisconnectHelper* CDisconnectHelper::NewL( MDisconnectionCallback* aObserver )    
    {
    TRACE_FUNC
    CDisconnectHelper* self = new (ELeave) CDisconnectHelper( aObserver );
    CleanupStack::PushL( self );
    self->ConstructL();
    CleanupStack::Pop( self );
    return self;
    }

// ---------------------------------------------------------------------------
// Destructor
// ---------------------------------------------------------------------------
CDisconnectHelper::~CDisconnectHelper()
    {
    TRACE_FUNC_ENTRY                 
    Cancel();    
    TRACE_FUNC_EXIT
    }
       
// ---------------------------------------------------------------------------
// Constructor
// ---------------------------------------------------------------------------
//
CDisconnectHelper::CDisconnectHelper( MDisconnectionCallback* aObserver ):    
                                     CActive( CActive::EPriorityStandard ),
                                     iObserver( aObserver )                                     
    {           
    }
    
// ---------------------------------------------------------------------------
// ConstructL
// ---------------------------------------------------------------------------
//
void CDisconnectHelper::ConstructL()
    {    
    TRACE_FUNC      
    if ( !iObserver )          
        {
        User::Leave(KErrArgument);    
        }
    CActiveScheduler::Add( this );             
    }
        
// ---------------------------------------------------------
// CPBAPplugin::Activate
// ---------------------------------------------------------
//
TInt CDisconnectHelper::Activate() 
    {        
    if ( IsActive() )
        {
        return KErrInUse; 
        }
    iStatus = KRequestPending;
    SetActive();
    TRequestStatus* status = &iStatus;
    User::RequestComplete( status, KErrNone );    
    return KErrNone;
    }    
    
// ---------------------------------------------------------
// From class CActive
// CPBAPplugin::RunL
// ---------------------------------------------------------
//
void CDisconnectHelper::RunL( ) 
    {        
    if ( iObserver )
        {
        iObserver->CompleteDisconnection();    
        }  
    }      
    
// ---------------------------------------------------------
// From class CActive
// CPBAPplugin::DoCancel
// ---------------------------------------------------------
//
void CDisconnectHelper::DoCancel()
    {            
    }