wlanutilities/wlansniffer/wlaninfosorting/src/wsfwlaninfosortingdbchangenotifier.cpp
author Pat Downey <patd@symbian.org>
Wed, 01 Sep 2010 12:20:32 +0100
branchRCL_3
changeset 25 f28ada11abbf
parent 0 56b72877c1cb
permissions -rw-r--r--
Revert incorrect RCL_3 drop: Revision: 201029 Kit: 201035

/*
* Copyright (c) 2007-2008 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 CWsfWlanInfoSortingDbChangeNotifier
*
*/



//  CLASS HEADER
#include "wsfwlaninfosortingdbchangenotifier.h"

// INTERNAL INCLUDES
#include "wsfwlaninfosortingfiltervisitor.h"



// ----------------------------------------------------------------------------
// CWsfWlanInfoSortingDbChangeNotifier::NewLC
// ----------------------------------------------------------------------------
//
CWsfWlanInfoSortingDbChangeNotifier* 
           CWsfWlanInfoSortingDbChangeNotifier::NewLC( RDbDatabase& aDatabase )
	{
	CWsfWlanInfoSortingDbChangeNotifier* thisPtr = 
	             new (ELeave) CWsfWlanInfoSortingDbChangeNotifier( aDatabase );
	CleanupStack::PushL( thisPtr );
	thisPtr->ConstructL();
	return thisPtr;
	}


// ----------------------------------------------------------------------------
// CWsfWlanInfoSortingDbChangeNotifier::NewL
// ----------------------------------------------------------------------------
//
CWsfWlanInfoSortingDbChangeNotifier* CWsfWlanInfoSortingDbChangeNotifier::NewL(
                                                       RDbDatabase& aDatabase )
	{
	CWsfWlanInfoSortingDbChangeNotifier* thisPtr = NewLC( aDatabase );
	CleanupStack::Pop( thisPtr );
	return thisPtr;
	}


// ----------------------------------------------------------------------------
// CWsfWlanInfoSortingDbChangeNotifier::~CWsfWlanInfoSortingDbChangeNotifier
// ----------------------------------------------------------------------------
//
CWsfWlanInfoSortingDbChangeNotifier::~CWsfWlanInfoSortingDbChangeNotifier()
	{
	Cancel();
	iDbAwareFilters.Reset();
	iNotifier.Close();
	}


// ----------------------------------------------------------------------------
// CWsfWlanInfoSortingDbChangeNotifier::CWsfWlanInfoSortingDbChangeNotifier
// ----------------------------------------------------------------------------
//
CWsfWlanInfoSortingDbChangeNotifier::CWsfWlanInfoSortingDbChangeNotifier( 
                                                      RDbDatabase& aDatabase ):
	CActive( CActive::EPriorityLow ),
	iDatabase( &aDatabase )
	{
	}


// ----------------------------------------------------------------------------
// CWsfWlanInfoSortingDbChangeNotifier::ConstructL
// ----------------------------------------------------------------------------
//
void CWsfWlanInfoSortingDbChangeNotifier::ConstructL()
	{
	User::LeaveIfError( iNotifier.Open( *iDatabase ) );
	CActiveScheduler::Add( this );

	}


// ----------------------------------------------------------------------------
// CWsfWlanInfoSortingDbChangeNotifier::StartDbObservation
// ----------------------------------------------------------------------------
//
void CWsfWlanInfoSortingDbChangeNotifier::StartDbObservation()
	{
	iNotifier.NotifyChange( iStatus );
	SetActive();
	}


// ----------------------------------------------------------------------------
// CWsfWlanInfoSortingDbChangeNotifier::DoCancel
// ----------------------------------------------------------------------------
//
void CWsfWlanInfoSortingDbChangeNotifier::DoCancel()
	{
	iNotifier.Cancel();
	}


// ----------------------------------------------------------------------------
// CWsfWlanInfoSortingDbChangeNotifier::RunL
// ----------------------------------------------------------------------------
//
void CWsfWlanInfoSortingDbChangeNotifier::RunL()
	{
	if ( iStatus.Int() >= RDbNotifier::ECommit )
		{
		TInt dbAwareFiltersCount( iDbAwareFilters.Count() );
		if ( dbAwareFiltersCount )
			{
			TInt i( 0 );
			for ( ; i < dbAwareFiltersCount ; i++ )
				{
				(iDbAwareFilters)[i]->ReadFilterDefsL();
				}
			}
		}
	StartDbObservation();
	}


// ----------------------------------------------------------------------------
// CWsfWlanInfoSortingDbChangeNotifier::AppendDbRelatedFilterL
// ----------------------------------------------------------------------------
//
void CWsfWlanInfoSortingDbChangeNotifier::AppendDbRelatedFilterL( 
                             MWsfWlanInfoSortingFilterVisitor* aRelatedFilter )
	{
	iDbAwareFilters.AppendL( aRelatedFilter );
	}


// ----------------------------------------------------------------------------
// CWsfWlanInfoSortingDbChangeNotifier::RemoveDbRelatedFilter
// ----------------------------------------------------------------------------
//
void CWsfWlanInfoSortingDbChangeNotifier::RemoveDbRelatedFilter( 
                             MWsfWlanInfoSortingFilterVisitor* aRelatedFilter )
	{
	TInt index = iDbAwareFilters.Find( aRelatedFilter );
    if ( index != KErrNotFound )
    	{
    	iDbAwareFilters.Remove( index );
    	}
	}