19
|
1 |
/*
|
|
2 |
* Copyright (c) 2007-2007 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: Implements CLiwIterable type
|
|
15 |
*
|
|
16 |
*/
|
|
17 |
|
|
18 |
|
|
19 |
#include"serviceregistryiterator.h"
|
|
20 |
|
|
21 |
#include "serviceregistryservice.hrh"
|
|
22 |
|
|
23 |
|
|
24 |
|
|
25 |
// Two-phased constructor.
|
|
26 |
|
|
27 |
CSvcRegIterator* CSvcRegIterator :: NewL()
|
|
28 |
{
|
|
29 |
return(new(ELeave) CSvcRegIterator());
|
|
30 |
}
|
|
31 |
|
|
32 |
|
|
33 |
/**
|
|
34 |
* Default constructor.
|
|
35 |
*/
|
|
36 |
CSvcRegIterator::CSvcRegIterator():iCount(0),
|
|
37 |
iIndex(0)
|
|
38 |
{
|
|
39 |
|
|
40 |
}
|
|
41 |
|
|
42 |
/**
|
|
43 |
* destructor.
|
|
44 |
*/
|
|
45 |
CSvcRegIterator::~CSvcRegIterator()
|
|
46 |
{
|
|
47 |
if(iProviderDataList)
|
|
48 |
{
|
|
49 |
iProviderDataList->ResetAndDestroy();
|
|
50 |
delete iProviderDataList;
|
|
51 |
}
|
|
52 |
}
|
|
53 |
|
|
54 |
//sets the provider list
|
|
55 |
void CSvcRegIterator::SetProviderDataList(RCriteriaArray* aList)
|
|
56 |
{
|
|
57 |
iProviderDataList = aList;
|
|
58 |
}
|
|
59 |
|
|
60 |
|
|
61 |
|
|
62 |
//this methods fills the metadata map of the providers.If the end of the list is reached returns false.
|
|
63 |
TBool CSvcRegIterator::NextL(TLiwVariant& aItem)
|
|
64 |
{
|
|
65 |
if(iIndex < iProviderDataList->Count())
|
|
66 |
{
|
|
67 |
CLiwDefaultMap* pMap = CLiwDefaultMap :: NewL();
|
|
68 |
CleanupStack::PushL(pMap);
|
|
69 |
|
|
70 |
CLiwDefaultList* verList = CLiwDefaultList :: NewL();
|
|
71 |
CleanupStack::PushL(verList);
|
|
72 |
|
|
73 |
CLiwCriteriaItem* provInfo = (*iProviderDataList)[iIndex++];
|
|
74 |
|
|
75 |
//retrieving the content type or the interface name of the provider (e.g IDataSource)
|
|
76 |
TPtrC8 intfName = provInfo-> ServiceCmdStr();
|
|
77 |
|
|
78 |
HBufC* infaceName = HBufC :: NewL(intfName.Length());
|
|
79 |
infaceName->Des().Copy(intfName);
|
|
80 |
CleanupStack::PushL(infaceName);
|
|
81 |
|
|
82 |
pMap->InsertL(KInterfaceName, TLiwVariant(infaceName));
|
|
83 |
|
|
84 |
//retrieving the service command name of the provider (e.g s60.Messaging)
|
|
85 |
TPtrC8 servName = provInfo-> ContentType();
|
|
86 |
|
|
87 |
HBufC* svcName = HBufC :: NewL(servName.Length());
|
|
88 |
svcName->Des().Copy(servName);
|
|
89 |
CleanupStack::PushL(svcName);
|
|
90 |
|
|
91 |
pMap->InsertL(KServiceName, TLiwVariant(svcName));
|
|
92 |
|
|
93 |
TLiwVariant provMetadata;
|
|
94 |
provInfo->GetMetaDataOptions(provMetadata);
|
|
95 |
|
|
96 |
//getting metadata from the provider (contains version information)
|
|
97 |
const CLiwMap* metaDataMap = provMetadata.AsMap();
|
|
98 |
|
|
99 |
if(metaDataMap)
|
|
100 |
{
|
|
101 |
TLiwVariant versionVar;
|
|
102 |
//If false, then there is no version information in the provider metadata.
|
|
103 |
if(metaDataMap->FindL(KVersion, versionVar))
|
|
104 |
{
|
|
105 |
/*
|
|
106 |
Structure of Version information in metadata of the provider.
|
|
107 |
-------------------------------------
|
|
108 |
|
|
109 |
| key | value |
|
|
110 |
| | |
|
|
111 |
| ver | (List) 2.2 |
|
|
112 |
-------------------------------------
|
|
113 |
*/
|
|
114 |
const CLiwList* pVersionList = versionVar.AsList();
|
|
115 |
if(pVersionList)
|
|
116 |
{
|
|
117 |
TLiwVariant verCheck;
|
|
118 |
for(TInt idx=0; idx < pVersionList->Count(); ++idx)
|
|
119 |
{
|
|
120 |
if(pVersionList->AtL(idx,verCheck))
|
|
121 |
{
|
|
122 |
verList->AppendL(TLiwVariant(verCheck.AsTReal()));
|
|
123 |
}
|
|
124 |
verCheck.Reset();
|
|
125 |
}
|
|
126 |
}
|
|
127 |
}
|
|
128 |
versionVar.Reset();
|
|
129 |
}
|
|
130 |
provMetadata.Reset();
|
|
131 |
|
|
132 |
//insert the version map into the map.
|
|
133 |
pMap->InsertL(KVersionList, TLiwVariant(verList));
|
|
134 |
verList->DecRef();
|
|
135 |
|
|
136 |
aItem.SetL(pMap);
|
|
137 |
pMap->DecRef();
|
|
138 |
|
|
139 |
CleanupStack::PopAndDestroy(svcName);
|
|
140 |
CleanupStack::PopAndDestroy(infaceName);
|
|
141 |
CleanupStack::Pop(verList);
|
|
142 |
CleanupStack::Pop(pMap);
|
|
143 |
return ETrue;
|
|
144 |
}
|
|
145 |
return EFalse;
|
|
146 |
}
|
|
147 |
|
|
148 |
//Resets the iterator to point to the starting of the list.
|
|
149 |
void CSvcRegIterator :: Reset()
|
|
150 |
{
|
|
151 |
iIndex = 0;
|
|
152 |
}
|