author | Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com> |
Tue, 24 Nov 2009 08:56:33 +0200 | |
changeset 33 | 50974a8b132e |
parent 19 | 989d2f495d90 |
permissions | -rw-r--r-- |
19 | 1 |
/* |
2 |
* Copyright (c) 2002 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 the License "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: CLandmarkDatabaseIterable class implementation |
|
15 |
* |
|
16 |
*/ |
|
17 |
||
18 |
#include <liwgenericparam.h> |
|
33
50974a8b132e
Revision: 200945
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
19 |
#include <EPos_CPosLmDatabaseManager.h> |
19 | 20 |
#include "clandmarkdatabaseiterable.h" |
21 |
#include "landmarkliwparams.hrh" |
|
22 |
||
23 |
// ----------------------------------------------------------------------------- |
|
24 |
// ----------------------------------------------------------------------------- |
|
25 |
// |
|
26 |
CDatabaseIterable* CDatabaseIterable::NewL( CDesCArray* aDbList ) |
|
27 |
{ |
|
28 |
CDatabaseIterable* self = new (ELeave) CDatabaseIterable(aDbList); |
|
29 |
CleanupStack::PushL(self); |
|
30 |
self->ConstructL(); |
|
31 |
CleanupStack::Pop(self); |
|
32 |
return self; |
|
33 |
} |
|
34 |
||
35 |
// ----------------------------------------------------------------------------- |
|
36 |
// ----------------------------------------------------------------------------- |
|
37 |
// |
|
38 |
CDatabaseIterable::CDatabaseIterable( CDesCArray* aDbList ) |
|
39 |
:iDatabaseList(aDbList), |
|
40 |
iIndex(0) |
|
41 |
{ |
|
42 |
iCount = iDatabaseList->Count(); |
|
43 |
} |
|
44 |
||
45 |
// ----------------------------------------------------------------------------- |
|
46 |
// ----------------------------------------------------------------------------- |
|
47 |
// |
|
48 |
CDatabaseIterable::~CDatabaseIterable() |
|
49 |
{ |
|
50 |
delete iDatabaseList; |
|
51 |
delete iDbManager; |
|
52 |
} |
|
53 |
||
54 |
// ----------------------------------------------------------------------------- |
|
55 |
// ----------------------------------------------------------------------------- |
|
56 |
// |
|
57 |
void CDatabaseIterable::ConstructL() |
|
58 |
{ |
|
59 |
iDbManager = CPosLmDatabaseManager::NewL(); |
|
60 |
} |
|
61 |
// ----------------------------------------------------------------------------- |
|
62 |
// ----------------------------------------------------------------------------- |
|
63 |
// |
|
64 |
TBool CDatabaseIterable::NextL( TLiwVariant& aEntry ) |
|
65 |
{ |
|
66 |
||
67 |
if ( iIndex < iCount ) |
|
68 |
{ |
|
69 |
TPtrC DbUri = (*iDatabaseList)[iIndex]; |
|
70 |
TBuf<KMaxDriveLength> drive(KNullDesC); |
|
71 |
drive.FillZ(); |
|
72 |
HPosLmDatabaseInfo* info = HPosLmDatabaseInfo::NewLC(DbUri); |
|
73 |
iDbManager->GetDatabaseInfoL(*info); |
|
74 |
CLiwMap* database = CLiwDefaultMap::NewL(); |
|
75 |
CleanupClosePushL (*database ); |
|
76 |
const TPosLmDatabaseSettings settings = info->Settings(); |
|
77 |
TPtrC dbname = settings.DatabaseName(); |
|
78 |
database->InsertL(KDbUri,TLiwVariant(DbUri)); |
|
79 |
database->InsertL(KDbName,TLiwVariant(dbname)); |
|
80 |
database->InsertL(KDbProtocol,TLiwVariant(info->Protocol())); |
|
81 |
database->InsertL(KDbActive,TLiwVariant(info->IsDefault())); |
|
82 |
drive.Append(info->DatabaseDrive()); |
|
83 |
database->InsertL(KDbSize,TLiwVariant((TInt32)info->Size())); |
|
84 |
database->InsertL(KDbDrive,TLiwVariant(drive)); |
|
85 |
database->InsertL(KDbMedia,TLiwVariant((TInt32)info->DatabaseMedia())); |
|
86 |
aEntry.SetL(database); |
|
87 |
CleanupStack::PopAndDestroy (database ); |
|
88 |
CleanupStack::PopAndDestroy (info ); |
|
89 |
iIndex++; |
|
90 |
return ETrue; |
|
91 |
} |
|
92 |
else |
|
93 |
return EFalse; |
|
94 |
} |
|
95 |
// ----------------------------------------------------------------------------- |
|
96 |
// ----------------------------------------------------------------------------- |
|
97 |
// |
|
98 |
void CDatabaseIterable::Reset() |
|
99 |
{ |
|
100 |
iIndex = 0; |
|
101 |
} |
|
102 |
||
103 |
//end of file |