19
|
1 |
/*
|
|
2 |
* Copyright (c) 2006-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: ?Description
|
|
15 |
*
|
|
16 |
*/
|
|
17 |
|
|
18 |
|
|
19 |
|
|
20 |
// INCLUDE FILES
|
|
21 |
#include <e32svr.h>
|
|
22 |
|
|
23 |
#include <LiwServiceHandler.h>
|
|
24 |
#include <Liwbufferextension.h>
|
|
25 |
#include <gmxmldocument.h>
|
|
26 |
#include <gmxmlelement.h>
|
|
27 |
#include <gmxmlcharacterdata.h>
|
|
28 |
#include <charconv.H>
|
|
29 |
#include <gmxmltext.h>
|
|
30 |
|
|
31 |
#include "txmlconvertor.h"
|
|
32 |
|
|
33 |
#include <f32file.h>
|
|
34 |
#include <e32des16.h>
|
|
35 |
#include <e32base.h>
|
|
36 |
|
|
37 |
#include "tprovidertestobserver.h"
|
|
38 |
|
|
39 |
_LIT8(KErrorCode,"ErrorCode");
|
|
40 |
|
|
41 |
|
|
42 |
// Define constants
|
|
43 |
const TInt KTYPE_ID_LEN = 7;
|
|
44 |
const TInt KENTRY_LEN = 5;
|
|
45 |
const TInt KINT_LEN = 3;
|
|
46 |
const TInt KBOOL_LEN = 4;
|
|
47 |
const TInt KDATE_LEN = 4;
|
|
48 |
const TInt KFLOAT_LEN = 5;
|
|
49 |
const TInt KMAX_LEN = 255;
|
|
50 |
const TInt KSTRING_LEN = 8;
|
|
51 |
const TInt KLIST_LEN = 4;
|
|
52 |
const TInt KITER_LEN = 8;
|
|
53 |
const TInt KMAP_LEN = 3;
|
|
54 |
const TInt KKEY_LEN = 3;
|
|
55 |
const TInt KNAME_LEN = 4;
|
|
56 |
const TInt KPARAMS_LEN = 6;
|
|
57 |
const TInt KPARAM_LEN = 5;
|
|
58 |
const TInt KDateLen = 25;
|
|
59 |
|
|
60 |
const TInt KMaxOutputLen = 1000;
|
|
61 |
|
|
62 |
|
|
63 |
|
|
64 |
_LIT(KAttribute, "type_id");
|
|
65 |
_LIT(KKeyAttribute, "name");
|
|
66 |
_LIT(KInt, "int");
|
|
67 |
_LIT(KFloat, "float");
|
|
68 |
_LIT(KString, "string");
|
|
69 |
_LIT(KString8, "string8");
|
|
70 |
_LIT(KList, "list");
|
|
71 |
_LIT(KMap, "map");
|
|
72 |
_LIT(KKey, "key");
|
|
73 |
_LIT(KBool, "bool");
|
|
74 |
_LIT(KDate, "date");
|
|
75 |
|
|
76 |
_LIT(KEntry, "entry");
|
|
77 |
_LIT(KIterator, "iterator");
|
|
78 |
_LIT(KOpenTag, "<");
|
|
79 |
_LIT(KFinalCloseTag, "/>");
|
|
80 |
_LIT(KCloseTag, ">");
|
|
81 |
_LIT(KOpenTagSlash, "</");
|
|
82 |
_LIT(KParams, "params");
|
|
83 |
_LIT(KParam, "param");
|
|
84 |
_LIT(KNameAttribute, "name");
|
|
85 |
_LIT(KSTDDATE, "19700001:000000.000000");
|
|
86 |
|
|
87 |
|
|
88 |
|
|
89 |
// Converts the output params from LIW specific data type to xml based flash
|
|
90 |
// specific data type.
|
|
91 |
|
|
92 |
void CXmlConvertor::BuildOutputTreeL(CLiwGenericParamList& aOutParamList,TPtrC& aPtr)
|
|
93 |
{
|
|
94 |
CMDXMLDocument* pDocNode = CMDXMLDocument::NewLC();
|
|
95 |
if (pDocNode)
|
|
96 |
{
|
|
97 |
TBuf<KPARAMS_LEN> paramsNode(KParams);
|
|
98 |
CMDXMLElement* pParamsNode = CMDXMLElement::NewLC(ETrue,pDocNode,paramsNode);
|
|
99 |
|
|
100 |
if (pParamsNode)
|
|
101 |
{
|
|
102 |
for(TInt i=0; i < aOutParamList.Count(); ++i)
|
|
103 |
{
|
|
104 |
//create <param name=""/> tag
|
|
105 |
TBuf<KPARAM_LEN> paramNode(KParam);
|
|
106 |
CMDXMLElement* pParamNode = CMDXMLElement::NewLC(ETrue,pDocNode,paramNode);
|
|
107 |
if (pParamNode)
|
|
108 |
{
|
|
109 |
TBuf<KMAX_LEN> paramName;
|
|
110 |
TLiwGenericParam outParam = aOutParamList[i];
|
|
111 |
|
|
112 |
if(outParam.Name().Length()!=0)
|
|
113 |
{
|
|
114 |
paramName.Copy(outParam.Name());
|
|
115 |
}
|
|
116 |
else
|
|
117 |
{
|
|
118 |
TInt semID = outParam.SemanticId();
|
|
119 |
const TDesC8& strParam = this->GetParamAsString(semID);
|
|
120 |
paramName.Copy(strParam);
|
|
121 |
}
|
|
122 |
|
|
123 |
TBuf<KNAME_LEN> nameAttr(KKeyAttribute);
|
|
124 |
//Create an attribute "name"
|
|
125 |
pParamNode->SetAttributeL(nameAttr,paramName);
|
|
126 |
|
|
127 |
pParamsNode->AppendChild(pParamNode);
|
|
128 |
|
|
129 |
AppendOutParamL(pDocNode,pParamNode,outParam.Value());
|
|
130 |
CleanupStack::Pop(pParamNode);
|
|
131 |
}
|
|
132 |
}
|
|
133 |
// Convert the output to string.
|
|
134 |
ToStringL(pParamsNode, aPtr);
|
|
135 |
|
|
136 |
CleanupStack::PopAndDestroy(pParamsNode);
|
|
137 |
}
|
|
138 |
CleanupStack::PopAndDestroy(pDocNode);
|
|
139 |
}
|
|
140 |
}
|
|
141 |
|
|
142 |
|
|
143 |
// Converts the TGenericParamId passed by the service provider
|
|
144 |
// to string, as we can pass only string values to flash content.
|
|
145 |
const TDesC8& CXmlConvertor::GetParamAsString(TGenericParamId aParamID)
|
|
146 |
{
|
|
147 |
switch(aParamID)
|
|
148 |
{
|
|
149 |
case EGenericParamError:
|
|
150 |
{
|
|
151 |
return KErrorCode();
|
|
152 |
}
|
|
153 |
|
|
154 |
//Convert other generic param IDs if required
|
|
155 |
default:
|
|
156 |
break;
|
|
157 |
}
|
|
158 |
return KNullDesC8();
|
|
159 |
}
|
|
160 |
|
|
161 |
|
|
162 |
|
|
163 |
|
|
164 |
|
|
165 |
|
|
166 |
|
|
167 |
//Output parameter processing
|
|
168 |
// Appends the value in TLiwVariant to the XML tree.
|
|
169 |
void CXmlConvertor::AppendOutParamL(CMDXMLDocument* aDocNode, CMDXMLElement* aParentNode,
|
|
170 |
const TLiwVariant& aParamVar)
|
|
171 |
{
|
|
172 |
if (aDocNode && aParentNode)
|
|
173 |
{
|
|
174 |
TBuf<KTYPE_ID_LEN> typeIdAttr(KAttribute);
|
|
175 |
TBuf<KENTRY_LEN> entryNode(KEntry);
|
|
176 |
CMDXMLElement* pEntryNode = CMDXMLElement::NewL(ETrue,aDocNode,entryNode);
|
|
177 |
if (pEntryNode)
|
|
178 |
{
|
|
179 |
CleanupStack::PushL(pEntryNode);
|
|
180 |
|
|
181 |
if(aParamVar.TypeId()==EVariantTypeTInt32)
|
|
182 |
{
|
|
183 |
//Form attribute "name" with value "int"
|
|
184 |
TBuf<KINT_LEN> typeIdValue(KInt);
|
|
185 |
pEntryNode->SetAttributeL(typeIdAttr,typeIdValue);
|
|
186 |
|
|
187 |
//Create text node with value equivalent to aParamVar.AsTInt32()
|
|
188 |
CMDXMLText* pValueNode = CMDXMLText::NewL(aDocNode);
|
|
189 |
CleanupStack::PushL(pValueNode);
|
|
190 |
|
|
191 |
TInt intValue = aParamVar.AsTInt32();
|
|
192 |
TInt len = GetLengthToStoreInt(intValue);
|
|
193 |
HBufC* hInt = HBufC::NewLC(len+1);
|
|
194 |
TPtr intPtr(hInt->Des());
|
|
195 |
intPtr.Num(intValue);
|
|
196 |
|
|
197 |
pValueNode->SetDataL(intPtr);
|
|
198 |
pEntryNode->AppendChild(pValueNode);
|
|
199 |
|
|
200 |
CleanupStack::PopAndDestroy(hInt);
|
|
201 |
CleanupStack::Pop(pValueNode);
|
|
202 |
}
|
|
203 |
else if(aParamVar.TypeId()==EVariantTypeTBool)
|
|
204 |
{
|
|
205 |
//Form attribute "name" with value "bool"
|
|
206 |
TBuf<KBOOL_LEN> typeIdValue(_L("bool"));
|
|
207 |
pEntryNode->SetAttributeL(typeIdAttr,typeIdValue);
|
|
208 |
|
|
209 |
//Create text node with value equivalent to aParamVar.AsTBool()
|
|
210 |
CMDXMLText* pValueNode=CMDXMLText::NewL(aDocNode);
|
|
211 |
CleanupStack::PushL(pValueNode);
|
|
212 |
|
|
213 |
TBuf<KMAX_LEN> value;
|
|
214 |
value.Num(aParamVar.AsTBool());
|
|
215 |
|
|
216 |
pValueNode->SetDataL(value);
|
|
217 |
pEntryNode->AppendChild(pValueNode);
|
|
218 |
CleanupStack::Pop(pValueNode);
|
|
219 |
}
|
|
220 |
else if(aParamVar.TypeId()==EVariantTypeDesC8)
|
|
221 |
{
|
|
222 |
//Form attribute "name" with value "string"
|
|
223 |
TBuf<KSTRING_LEN> typeIdValue(KString8);
|
|
224 |
pEntryNode->SetAttributeL(typeIdAttr,typeIdValue);
|
|
225 |
|
|
226 |
//Create text node with value equivalent to aParamVar.AsDes()
|
|
227 |
CMDXMLText* pValueNode=CMDXMLText::NewL(aDocNode);
|
|
228 |
CleanupStack::PushL(pValueNode);
|
|
229 |
|
|
230 |
TPtrC8 pValue;
|
|
231 |
aParamVar.Get(pValue);
|
|
232 |
HBufC* heapBuffer = HBufC::NewL( pValue.Length() );
|
|
233 |
CleanupStack::PushL( heapBuffer );
|
|
234 |
TPtr value( heapBuffer->Des() );
|
|
235 |
value.Copy( pValue );
|
|
236 |
pValueNode->SetDataL(value);
|
|
237 |
CleanupStack::PopAndDestroy();
|
|
238 |
|
|
239 |
pEntryNode->AppendChild(pValueNode);
|
|
240 |
CleanupStack::Pop(pValueNode);
|
|
241 |
}
|
|
242 |
|
|
243 |
else if(aParamVar.TypeId()==EVariantTypeTTime)
|
|
244 |
{
|
|
245 |
//Form attribute "name" with value "date"
|
|
246 |
TBuf<KDATE_LEN> typeIdValue(_L("date"));
|
|
247 |
pEntryNode->SetAttributeL(typeIdAttr,typeIdValue);
|
|
248 |
|
|
249 |
//Create text node with value equivalent to aParamVar.AsTTime()
|
|
250 |
CMDXMLText* pValueNode=CMDXMLText::NewL(aDocNode);
|
|
251 |
CleanupStack::PushL(pValueNode);
|
|
252 |
|
|
253 |
// Convert the date as ActionScript requires that the date be passed as
|
|
254 |
// milliseconds since midnight January 1, 1970.
|
|
255 |
TBuf<KDateLen> dateBuf(KSTDDATE);
|
|
256 |
TTime std(dateBuf);
|
|
257 |
|
|
258 |
TTime timeVal = aParamVar.AsTTime();
|
|
259 |
|
|
260 |
//Convert microseconds to milliseconds.
|
|
261 |
TTimeIntervalMicroSeconds timeMS = timeVal.MicroSecondsFrom(std);
|
|
262 |
TInt64 timeInt = timeMS.Int64();
|
|
263 |
timeInt = timeInt/1000;
|
|
264 |
|
|
265 |
TInt64 len = GetLengthToStoreInt64(timeInt);
|
|
266 |
HBufC* hInt = HBufC::NewLC(len);
|
|
267 |
TPtr intPtr(hInt->Des());
|
|
268 |
intPtr.Num(timeInt);
|
|
269 |
|
|
270 |
pValueNode->SetDataL(intPtr);
|
|
271 |
|
|
272 |
pEntryNode->AppendChild(pValueNode);
|
|
273 |
|
|
274 |
CleanupStack::PopAndDestroy(hInt);
|
|
275 |
CleanupStack::Pop(pValueNode);
|
|
276 |
}
|
|
277 |
else if(aParamVar.TypeId()==EVariantTypeTReal)
|
|
278 |
{
|
|
279 |
//Form attribute "name" with value "float"
|
|
280 |
TBuf<KFLOAT_LEN> typeIdValue(KFloat);
|
|
281 |
pEntryNode->SetAttributeL(typeIdAttr,typeIdValue);
|
|
282 |
|
|
283 |
//Create text node with value equivalent to aParamVar.AsReal()
|
|
284 |
CMDXMLText* pValueNode=CMDXMLText::NewL(aDocNode);
|
|
285 |
CleanupStack::PushL(pValueNode);
|
|
286 |
|
|
287 |
TRealFormat format;
|
|
288 |
format.iType = KRealFormatGeneral;
|
|
289 |
|
|
290 |
TBuf<KMAX_LEN> value;
|
|
291 |
value.Num(aParamVar.AsTReal(),format);
|
|
292 |
|
|
293 |
|
|
294 |
pValueNode->SetDataL(value);
|
|
295 |
pEntryNode->AppendChild(pValueNode);
|
|
296 |
CleanupStack::Pop(pValueNode);
|
|
297 |
}
|
|
298 |
else if(aParamVar.TypeId()==EVariantTypeDesC)
|
|
299 |
{
|
|
300 |
//Form attribute "name" with value "string"
|
|
301 |
TBuf<KSTRING_LEN> typeIdValue(KString);
|
|
302 |
pEntryNode->SetAttributeL(typeIdAttr,typeIdValue);
|
|
303 |
|
|
304 |
//Create text node with value equivalent to aParamVar.AsDes()
|
|
305 |
CMDXMLText* pValueNode=CMDXMLText::NewL(aDocNode);
|
|
306 |
CleanupStack::PushL(pValueNode);
|
|
307 |
|
|
308 |
TPtrC pValue=aParamVar.AsDes();
|
|
309 |
pValueNode->SetDataL(pValue);
|
|
310 |
|
|
311 |
pEntryNode->AppendChild(pValueNode);
|
|
312 |
CleanupStack::Pop(pValueNode);
|
|
313 |
}
|
|
314 |
else if( aParamVar.TypeId()==EVariantTypeList)
|
|
315 |
{
|
|
316 |
//Form attribute "name" with value "list"
|
|
317 |
TBuf<KLIST_LEN> typeIdValue(KList);
|
|
318 |
pEntryNode->SetAttributeL(typeIdAttr,typeIdValue);
|
|
319 |
const CLiwList* pList=aParamVar.AsList();
|
|
320 |
if ( pList )
|
|
321 |
{
|
|
322 |
CleanupStack::PushL(const_cast<CLiwList*>(pList));
|
|
323 |
for(TInt l=0; l != pList->Count(); ++l)
|
|
324 |
{
|
|
325 |
TLiwVariant listEntry;
|
|
326 |
pList->AtL(l,listEntry);
|
|
327 |
this->AppendOutParamL(aDocNode,pEntryNode,listEntry);
|
|
328 |
listEntry.Reset();
|
|
329 |
}
|
|
330 |
CleanupStack::Pop(const_cast<CLiwList*>(pList));
|
|
331 |
}
|
|
332 |
}
|
|
333 |
else if(aParamVar.TypeId()==EVariantTypeIterable)
|
|
334 |
{
|
|
335 |
//Handling is same as that of list, accessor
|
|
336 |
//method is different (AsIterable)
|
|
337 |
//Form attribute "name" with value "iterator"
|
|
338 |
|
|
339 |
TBuf<KITER_LEN> typeIdValue(KIterator);
|
|
340 |
pEntryNode->SetAttributeL(typeIdAttr,typeIdValue);
|
|
341 |
|
|
342 |
CLiwIterable* pIter=aParamVar.AsIterable();
|
|
343 |
if (pIter)
|
|
344 |
{
|
|
345 |
CleanupStack::PushL(pIter);
|
|
346 |
|
|
347 |
TLiwVariant entry;
|
|
348 |
while(EFalse != pIter->NextL(entry))
|
|
349 |
{
|
|
350 |
this->AppendOutParamL(aDocNode,pEntryNode,entry);
|
|
351 |
entry.Reset();
|
|
352 |
}
|
|
353 |
entry.Reset();
|
|
354 |
CleanupStack::Pop(pIter);
|
|
355 |
}
|
|
356 |
}
|
|
357 |
else if(aParamVar.TypeId()==EVariantTypeMap)
|
|
358 |
{
|
|
359 |
//Form attribute "name" with value "list"
|
|
360 |
TBuf<KMAP_LEN> typeIdValue(KMap);
|
|
361 |
pEntryNode->SetAttributeL(typeIdAttr,typeIdValue);
|
|
362 |
const CLiwMap* pMap=aParamVar.AsMap();
|
|
363 |
if ( pMap )
|
|
364 |
{
|
|
365 |
CleanupStack::PushL(const_cast<CLiwMap*>(pMap));
|
|
366 |
for(TInt m=0; m!=pMap->Count();++m)
|
|
367 |
{
|
|
368 |
TBuf8<KMAX_LEN> mapKey;
|
|
369 |
pMap->AtL(m,mapKey);
|
|
370 |
TBuf<KMAX_LEN> mapKey16;
|
|
371 |
mapKey16.Copy(mapKey);
|
|
372 |
|
|
373 |
//Add key node as child of entry node
|
|
374 |
TBuf<KKEY_LEN> keyNode(KKey);
|
|
375 |
TBuf<KNAME_LEN> nameAttr(KKeyAttribute);
|
|
376 |
CMDXMLElement* pKeyNode = CMDXMLElement::NewL(ETrue,aDocNode,keyNode);
|
|
377 |
if (pKeyNode)
|
|
378 |
{
|
|
379 |
CleanupStack::PushL(pKeyNode);
|
|
380 |
pKeyNode->SetAttributeL(nameAttr,mapKey16);
|
|
381 |
pEntryNode->AppendChild(pKeyNode);
|
|
382 |
|
|
383 |
TLiwVariant fndEntry;
|
|
384 |
TBool found = pMap->FindL(mapKey,fndEntry);
|
|
385 |
if ( found )
|
|
386 |
{
|
|
387 |
this->AppendOutParamL(aDocNode,pKeyNode,fndEntry);
|
|
388 |
fndEntry.Reset();
|
|
389 |
}
|
|
390 |
CleanupStack::Pop(pKeyNode);
|
|
391 |
}
|
|
392 |
}
|
|
393 |
CleanupStack::Pop(const_cast<CLiwMap*>(pMap));
|
|
394 |
}
|
|
395 |
}
|
|
396 |
aParentNode->AppendChild(pEntryNode);
|
|
397 |
CleanupStack::Pop(pEntryNode);
|
|
398 |
}
|
|
399 |
}
|
|
400 |
}
|
|
401 |
|
|
402 |
|
|
403 |
|
|
404 |
|
|
405 |
// The ouput XML tree contains the output params. This function converts the output to the
|
|
406 |
// string representation of the xml based flash specific data type.
|
|
407 |
void CXmlConvertor::ToStringL(CMDXMLElement* aRootNode,TPtrC& aPtr)
|
|
408 |
{
|
|
409 |
delete iOutputBuffer;
|
|
410 |
iOutputBuffer = NULL;
|
|
411 |
iOutputBuffer = HBufC::NewL(KMaxOutputLen);
|
|
412 |
WriteElementL(aRootNode);
|
|
413 |
aPtr.Set(*iOutputBuffer);
|
|
414 |
}
|
|
415 |
|
|
416 |
// This function writes the contents of the XML node to the output.
|
|
417 |
void CXmlConvertor::WriteElementL(CMDXMLElement* aElemNode)
|
|
418 |
{
|
|
419 |
if (aElemNode)
|
|
420 |
{
|
|
421 |
//write start element tag i.e <element_name>
|
|
422 |
WriteStartElementTagL(aElemNode);
|
|
423 |
if(aElemNode->HasChildNodes()==0)
|
|
424 |
{
|
|
425 |
AppendStringL(KFinalCloseTag);
|
|
426 |
return;
|
|
427 |
}
|
|
428 |
else //write end element tag i.e </element_name>
|
|
429 |
{
|
|
430 |
AppendStringL(KCloseTag);
|
|
431 |
|
|
432 |
for(CMDXMLNode* pCurrNode = aElemNode->FirstChild();
|
|
433 |
NULL != pCurrNode;
|
|
434 |
pCurrNode = pCurrNode->NextSibling()
|
|
435 |
)
|
|
436 |
{
|
|
437 |
if(CMDXMLNode::EElementNode==pCurrNode->NodeType())
|
|
438 |
{
|
|
439 |
WriteElementL((CMDXMLElement*)pCurrNode);
|
|
440 |
}
|
|
441 |
else if(CMDXMLNode::ETextNode==pCurrNode->NodeType())
|
|
442 |
{
|
|
443 |
AppendStringL(((CMDXMLCharacterData*)pCurrNode)->Data());
|
|
444 |
}
|
|
445 |
}
|
|
446 |
|
|
447 |
WriteEndElementTagL(aElemNode);
|
|
448 |
}
|
|
449 |
}
|
|
450 |
}
|
|
451 |
|
|
452 |
// This function writes the start element tag and the attributes of the node
|
|
453 |
// to the output.
|
|
454 |
void CXmlConvertor::WriteStartElementTagL(CMDXMLElement* aElemNode)
|
|
455 |
{
|
|
456 |
if (aElemNode)
|
|
457 |
{
|
|
458 |
AppendStringL(KOpenTag); //<
|
|
459 |
AppendStringL(aElemNode->NodeName()); //<element_name
|
|
460 |
if(aElemNode->NumAttributes()>0)
|
|
461 |
{
|
|
462 |
WriteAttributeTagL(aElemNode);
|
|
463 |
}
|
|
464 |
}
|
|
465 |
}
|
|
466 |
|
|
467 |
// This function writes the end element tag to the output.
|
|
468 |
void CXmlConvertor::WriteEndElementTagL(CMDXMLElement* aElemNode)
|
|
469 |
{
|
|
470 |
if(aElemNode && aElemNode->HasChildNodes())
|
|
471 |
{
|
|
472 |
AppendStringL(KOpenTagSlash);
|
|
473 |
AppendStringL(aElemNode->NodeName());
|
|
474 |
AppendStringL(KCloseTag);
|
|
475 |
}
|
|
476 |
else
|
|
477 |
{
|
|
478 |
AppendStringL(KFinalCloseTag);
|
|
479 |
}
|
|
480 |
}
|
|
481 |
|
|
482 |
|
|
483 |
// This function writes the attributes of the node to the output.
|
|
484 |
void CXmlConvertor::WriteAttributeTagL(CMDXMLElement* aElemNode)
|
|
485 |
{
|
|
486 |
//Add a space before adding attr
|
|
487 |
if(aElemNode && aElemNode->NumAttributes()>0)
|
|
488 |
{
|
|
489 |
TPtrC attributeValue;
|
|
490 |
TPtrC attributeName;
|
|
491 |
for(TInt i=0; i!=aElemNode->NumAttributes(); ++i)
|
|
492 |
{
|
|
493 |
AppendStringL(KSingleSpace);
|
|
494 |
aElemNode->AttributeDetails(i, attributeName, attributeValue);
|
|
495 |
AppendStringL(attributeName);
|
|
496 |
AppendStringL(KEqualSign);
|
|
497 |
|
|
498 |
AppendStringL(KQuotation);
|
|
499 |
AppendStringL(attributeValue);
|
|
500 |
AppendStringL(KQuotation);
|
|
501 |
}
|
|
502 |
}
|
|
503 |
}
|
|
504 |
|
|
505 |
|
|
506 |
|
|
507 |
// Appends the output to the output buffer.
|
|
508 |
void CXmlConvertor::AppendStringL(const TDesC& aStr)
|
|
509 |
{
|
|
510 |
TPtr bufPtr(iOutputBuffer->Des());
|
|
511 |
TInt maxLen = bufPtr.MaxLength();
|
|
512 |
|
|
513 |
TInt outLen = iOutputBuffer->Length();
|
|
514 |
TInt strLen = aStr.Length();
|
|
515 |
|
|
516 |
TInt remLen = maxLen - outLen;
|
|
517 |
// ReAlloc if more space is required.
|
|
518 |
if ( strLen > remLen)
|
|
519 |
{
|
|
520 |
iOutputBuffer = iOutputBuffer->ReAllocL(maxLen+strLen);
|
|
521 |
}
|
|
522 |
TPtr outPtr(iOutputBuffer->Des());
|
|
523 |
outPtr.Append(aStr);
|
|
524 |
}
|
|
525 |
|
|
526 |
|
|
527 |
// Calculates the length of the string needed to store the integer.
|
|
528 |
TInt CXmlConvertor::GetLengthToStoreInt(TInt aNum)
|
|
529 |
{
|
|
530 |
TInt num = Abs(aNum);
|
|
531 |
TInt len = 0;
|
|
532 |
while(num)
|
|
533 |
{
|
|
534 |
len++;
|
|
535 |
num=num/10;
|
|
536 |
}
|
|
537 |
return len;
|
|
538 |
}
|
|
539 |
|
|
540 |
|
|
541 |
// Calculates the length of the string needed to store the 64 bit integer.
|
|
542 |
TInt64 CXmlConvertor::GetLengthToStoreInt64(TInt64 aNum)
|
|
543 |
{
|
|
544 |
TInt64 len = 0;
|
|
545 |
while(aNum)
|
|
546 |
{
|
|
547 |
len++;
|
|
548 |
aNum=aNum/10;
|
|
549 |
}
|
|
550 |
return len;
|
|
551 |
}
|
|
552 |
|
|
553 |
|
|
554 |
|
|
555 |
CXmlConvertor:: ~CXmlConvertor()
|
|
556 |
{
|
|
557 |
if (iOutputBuffer)
|
|
558 |
{
|
|
559 |
delete iOutputBuffer;
|
|
560 |
iOutputBuffer = NULL;
|
|
561 |
}
|
|
562 |
}
|
|
563 |
|
|
564 |
|
|
565 |
CXmlConvertor* CXmlConvertor:: NewL()
|
|
566 |
{
|
|
567 |
CXmlConvertor* temp = new(ELeave)CXmlConvertor();
|
|
568 |
CleanupStack::PushL(temp);
|
|
569 |
temp->ConstructL();
|
|
570 |
CleanupStack::Pop(temp);
|
|
571 |
return temp;
|
|
572 |
}
|
|
573 |
|
|
574 |
|
|
575 |
void CXmlConvertor:: ConstructL()
|
|
576 |
{
|
|
577 |
|
|
578 |
}
|
|
579 |
// ========================== OTHER EXPORTED FUNCTIONS =========================
|
|
580 |
// None
|
|
581 |
|
|
582 |
// End of File
|