diff -r a36b1e19a461 -r 989d2f495d90 serviceproviders/sapi_landmarks/src/clandmarkdatabaseiterable.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/serviceproviders/sapi_landmarks/src/clandmarkdatabaseiterable.cpp Fri Jul 03 15:51:24 2009 +0100 @@ -0,0 +1,103 @@ +/* +* Copyright (c) 2002 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "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: CLandmarkDatabaseIterable class implementation +* +*/ + +#include +#include +#include "clandmarkdatabaseiterable.h" +#include "landmarkliwparams.hrh" + +// ----------------------------------------------------------------------------- +// ----------------------------------------------------------------------------- +// +CDatabaseIterable* CDatabaseIterable::NewL( CDesCArray* aDbList ) + { + CDatabaseIterable* self = new (ELeave) CDatabaseIterable(aDbList); + CleanupStack::PushL(self); + self->ConstructL(); + CleanupStack::Pop(self); + return self; + } + +// ----------------------------------------------------------------------------- +// ----------------------------------------------------------------------------- +// +CDatabaseIterable::CDatabaseIterable( CDesCArray* aDbList ) + :iDatabaseList(aDbList), + iIndex(0) + { + iCount = iDatabaseList->Count(); + } + +// ----------------------------------------------------------------------------- +// ----------------------------------------------------------------------------- +// +CDatabaseIterable::~CDatabaseIterable() + { + delete iDatabaseList; + delete iDbManager; + } + +// ----------------------------------------------------------------------------- +// ----------------------------------------------------------------------------- +// +void CDatabaseIterable::ConstructL() + { + iDbManager = CPosLmDatabaseManager::NewL(); + } +// ----------------------------------------------------------------------------- +// ----------------------------------------------------------------------------- +// +TBool CDatabaseIterable::NextL( TLiwVariant& aEntry ) + { + + if ( iIndex < iCount ) + { + TPtrC DbUri = (*iDatabaseList)[iIndex]; + TBuf drive(KNullDesC); + drive.FillZ(); + HPosLmDatabaseInfo* info = HPosLmDatabaseInfo::NewLC(DbUri); + iDbManager->GetDatabaseInfoL(*info); + CLiwMap* database = CLiwDefaultMap::NewL(); + CleanupClosePushL (*database ); + const TPosLmDatabaseSettings settings = info->Settings(); + TPtrC dbname = settings.DatabaseName(); + database->InsertL(KDbUri,TLiwVariant(DbUri)); + database->InsertL(KDbName,TLiwVariant(dbname)); + database->InsertL(KDbProtocol,TLiwVariant(info->Protocol())); + database->InsertL(KDbActive,TLiwVariant(info->IsDefault())); + drive.Append(info->DatabaseDrive()); + database->InsertL(KDbSize,TLiwVariant((TInt32)info->Size())); + database->InsertL(KDbDrive,TLiwVariant(drive)); + database->InsertL(KDbMedia,TLiwVariant((TInt32)info->DatabaseMedia())); + aEntry.SetL(database); + CleanupStack::PopAndDestroy (database ); + CleanupStack::PopAndDestroy (info ); + iIndex++; + return ETrue; + } + else + return EFalse; + } +// ----------------------------------------------------------------------------- +// ----------------------------------------------------------------------------- +// +void CDatabaseIterable::Reset() + { + iIndex = 0; + } + +//end of file