18
|
1 |
/*
|
|
2 |
* Copyright (c) 2005 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 "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: XDM Engine document
|
|
15 |
*
|
|
16 |
*/
|
|
17 |
|
|
18 |
|
|
19 |
|
|
20 |
|
|
21 |
// INCLUDE FILES
|
|
22 |
#include <f32file.h>
|
|
23 |
#include "XdmEngine.h"
|
|
24 |
#include "XdmProtocol.h"
|
|
25 |
#include "XdmDocument.h"
|
|
26 |
#include "XdmOperation.h"
|
|
27 |
#include "XdmDocumentNode.h"
|
|
28 |
#include "XdmNodeAttribute.h"
|
|
29 |
#include "XdmOperationFactory.h"
|
|
30 |
|
|
31 |
// ----------------------------------------------------------
|
|
32 |
// CXdmDocument::CXdmDocument
|
|
33 |
//
|
|
34 |
// ----------------------------------------------------------
|
|
35 |
//
|
|
36 |
EXPORT_C CXdmDocument::CXdmDocument( CXdmEngine& aXdmEngine ) :
|
|
37 |
CActive( EPriorityStandard ),
|
|
38 |
iDocSubset( EFalse ),
|
|
39 |
iXdmEngine( aXdmEngine )
|
|
40 |
|
|
41 |
{
|
|
42 |
}
|
|
43 |
|
|
44 |
// ----------------------------------------------------------
|
|
45 |
// CXdmDocument::BaseConstructL( 16-bit )
|
|
46 |
//
|
|
47 |
// ----------------------------------------------------------
|
|
48 |
//
|
|
49 |
EXPORT_C void CXdmDocument::BaseConstructL( TInt aOperationFactoryUid,
|
|
50 |
const TDesC& aDocumentName )
|
|
51 |
{
|
|
52 |
delete iDocumentName;
|
|
53 |
iDocumentName = NULL;
|
|
54 |
iDocumentName = HBufC::NewL( aDocumentName.Length() );
|
|
55 |
iDocumentName->Des().Copy( aDocumentName );
|
|
56 |
iOperationFactory = CXdmOperationFactory::NewL( aOperationFactoryUid );
|
|
57 |
}
|
|
58 |
|
|
59 |
// ----------------------------------------------------------
|
|
60 |
// CXdmDocument::BaseConstructL( 8-bit )
|
|
61 |
//
|
|
62 |
// ----------------------------------------------------------
|
|
63 |
//
|
|
64 |
EXPORT_C void CXdmDocument::BaseConstructL( TInt aOperationFactoryUid,
|
|
65 |
const TDesC8& aDocumentName )
|
|
66 |
{
|
|
67 |
delete iDocumentName;
|
|
68 |
iDocumentName = NULL;
|
|
69 |
iDocumentName = HBufC::NewL( aDocumentName.Length() );
|
|
70 |
iDocumentName->Des().Copy( aDocumentName );
|
|
71 |
iOperationFactory = CXdmOperationFactory::NewL( aOperationFactoryUid );
|
|
72 |
}
|
|
73 |
|
|
74 |
// ----------------------------------------------------
|
|
75 |
// CXdmDocument::~CXdmDocument
|
|
76 |
//
|
|
77 |
// ----------------------------------------------------
|
|
78 |
//
|
|
79 |
EXPORT_C CXdmDocument::~CXdmDocument()
|
|
80 |
{
|
|
81 |
#ifdef _DEBUG
|
|
82 |
iXdmEngine.WriteToLog( _L8( "CXdmDocument::~CXdmDocument()" ) );
|
|
83 |
#endif
|
|
84 |
delete iDocumentName;
|
|
85 |
EmptyOperationQueue();
|
|
86 |
iChangeRequests.Close();
|
|
87 |
delete iOperationFactory;
|
|
88 |
}
|
|
89 |
|
|
90 |
// ---------------------------------------------------------
|
|
91 |
// CXdmDocument::EmptyOperationQueue
|
|
92 |
//
|
|
93 |
// ---------------------------------------------------------
|
|
94 |
//
|
|
95 |
void CXdmDocument::EmptyOperationQueue()
|
|
96 |
{
|
|
97 |
#ifdef _DEBUG
|
|
98 |
iXdmEngine.WriteToLog( _L8( "CXdmDocument::EmptyOperationQueue()" ) );
|
|
99 |
#endif
|
|
100 |
|
|
101 |
while (iChangeRequests.Count())
|
|
102 |
{
|
|
103 |
MXdmOperation* operation = iChangeRequests[0];
|
|
104 |
iChangeRequests.Remove( 0 );
|
|
105 |
operation->Destroy();
|
|
106 |
operation = NULL;
|
|
107 |
}
|
|
108 |
}
|
|
109 |
|
|
110 |
// ----------------------------------------------------
|
|
111 |
// CXdmDocument::FetchDataL
|
|
112 |
//
|
|
113 |
// ----------------------------------------------------
|
|
114 |
//
|
|
115 |
EXPORT_C void CXdmDocument::FetchDataL( CXdmDocumentNode* aDocNode )
|
|
116 |
{
|
|
117 |
#ifdef _DEBUG
|
|
118 |
iXdmEngine.WriteToLog( _L8( "CXdmDocument::FetchDataL()" ) );
|
|
119 |
#endif
|
|
120 |
MXdmOperation* operation = iOperationFactory->FetchL( *this, aDocNode );
|
|
121 |
CleanupStack::PushL( operation );
|
|
122 |
User::LeaveIfError( iChangeRequests.Append( operation ) );
|
|
123 |
CleanupStack::Pop(); //operation
|
|
124 |
}
|
|
125 |
|
|
126 |
// ----------------------------------------------------
|
|
127 |
// CXdmDocument::ReplaceL
|
|
128 |
//
|
|
129 |
// ----------------------------------------------------
|
|
130 |
//
|
|
131 |
EXPORT_C void CXdmDocument::ReplaceL( CXdmDocumentNode* aOldNode,
|
|
132 |
CXdmDocumentNode* aNewNode )
|
|
133 |
{
|
|
134 |
#ifdef _DEBUG
|
|
135 |
iXdmEngine.WriteToLog( _L8( "CXdmDocument::ReplaceL()" ) );
|
|
136 |
#endif
|
|
137 |
if( aOldNode->Parent() == aNewNode->Parent() )
|
|
138 |
{
|
|
139 |
MXdmOperation* operation = iOperationFactory->ReplaceL(
|
|
140 |
*this, aOldNode, aNewNode );
|
|
141 |
CleanupStack::PushL( operation );
|
|
142 |
User::LeaveIfError( iChangeRequests.Append( operation ) );
|
|
143 |
CleanupStack::Pop(); //operation
|
|
144 |
}
|
|
145 |
else
|
|
146 |
{
|
|
147 |
#ifdef _DEBUG
|
|
148 |
iXdmEngine.WriteToLog( _L8( " Different parents, leaves!" ) );
|
|
149 |
#endif
|
|
150 |
User::Leave( KErrGeneral );
|
|
151 |
}
|
|
152 |
}
|
|
153 |
|
|
154 |
// ----------------------------------------------------
|
|
155 |
// CXdmDocument::ReplaceL
|
|
156 |
//
|
|
157 |
// ----------------------------------------------------
|
|
158 |
//
|
|
159 |
EXPORT_C void CXdmDocument::ReplaceL()
|
|
160 |
{
|
|
161 |
#ifdef _DEBUG
|
|
162 |
iXdmEngine.WriteToLog( _L8( "CXdmDocument::ReplaceL()" ) );
|
|
163 |
#endif
|
|
164 |
MXdmOperation* operation = iOperationFactory->ReplaceL( *this, NULL, NULL );
|
|
165 |
CleanupStack::PushL( operation );
|
|
166 |
User::LeaveIfError( iChangeRequests.Append( operation ) );
|
|
167 |
CleanupStack::Pop(); //operation
|
|
168 |
}
|
|
169 |
|
|
170 |
// ----------------------------------------------------
|
|
171 |
// CXdmDocument::InsertL
|
|
172 |
//
|
|
173 |
// ----------------------------------------------------
|
|
174 |
//
|
|
175 |
EXPORT_C void CXdmDocument::InsertL( CXdmDocumentNode* aDocNode )
|
|
176 |
{
|
|
177 |
#ifdef _DEBUG
|
|
178 |
iXdmEngine.WriteToLog( _L8( "CXdmDocument::InsertL()" ) );
|
|
179 |
#endif
|
|
180 |
__ASSERT_DEBUG( aDocNode != NULL, User::Panic( _L( "CXcapDocument" ), EDocNodeNull ) );
|
|
181 |
MXdmOperation* operation = iOperationFactory->InsertL(
|
|
182 |
*this, aDocNode );
|
|
183 |
CleanupStack::PushL( operation );
|
|
184 |
User::LeaveIfError( iChangeRequests.Append( operation ) );
|
|
185 |
CleanupStack::Pop(); //operation
|
|
186 |
}
|
|
187 |
|
|
188 |
// ----------------------------------------------------
|
|
189 |
// CXdmDocument::AppendL
|
|
190 |
//
|
|
191 |
// ----------------------------------------------------
|
|
192 |
//
|
|
193 |
EXPORT_C void CXdmDocument::AppendL( CXdmDocumentNode* aDocNode )
|
|
194 |
{
|
|
195 |
#ifdef _DEBUG
|
|
196 |
iXdmEngine.WriteToLog( _L8( "CXdmDocument::AppendL()" ) );
|
|
197 |
#endif
|
|
198 |
MXdmOperation* operation =
|
|
199 |
iOperationFactory->AppendL( *this, aDocNode );
|
|
200 |
CleanupStack::PushL( operation );
|
|
201 |
User::LeaveIfError( iChangeRequests.Append( operation ) );
|
|
202 |
CleanupStack::Pop(); //operation
|
|
203 |
}
|
|
204 |
|
|
205 |
// ----------------------------------------------------
|
|
206 |
// CXdmDocument::DeleteDataL
|
|
207 |
//
|
|
208 |
// ----------------------------------------------------
|
|
209 |
//
|
|
210 |
EXPORT_C void CXdmDocument::DeleteDataL( CXdmDocumentNode* aDocNode )
|
|
211 |
{
|
|
212 |
#ifdef _DEBUG
|
|
213 |
iXdmEngine.WriteToLog( _L8( "CXdmDocument::DeleteDataL()" ) );
|
|
214 |
#endif
|
|
215 |
MXdmOperation* operation = aDocNode == NULL ?
|
|
216 |
iOperationFactory->DeletionL( *this, NULL ) :
|
|
217 |
iOperationFactory->DeletionL( *this, aDocNode );
|
|
218 |
CleanupStack::PushL( operation );
|
|
219 |
User::LeaveIfError( iChangeRequests.Append( operation ) );
|
|
220 |
CleanupStack::Pop(); //operation
|
|
221 |
}
|
|
222 |
|
|
223 |
// ----------------------------------------------------
|
|
224 |
// CXdmDocument::Find
|
|
225 |
//
|
|
226 |
// ----------------------------------------------------
|
|
227 |
//
|
|
228 |
EXPORT_C TInt CXdmDocument::Find( const CXdmDocumentNode& aTargetNode,
|
|
229 |
RPointerArray<CXdmDocumentNode>& aResultArray ) const
|
|
230 |
{
|
|
231 |
#ifdef _DEBUG
|
|
232 |
iXdmEngine.WriteToLog( _L8( "CXdmDocument::Find()" ) );
|
|
233 |
#endif
|
|
234 |
TInt error = KErrNone;
|
|
235 |
CXdmDocumentNode* root = DocumentRoot();
|
|
236 |
__ASSERT_ALWAYS( root != NULL, User::Panic( _L( "CXcapDocument" ), EDocNodeNull ) );
|
|
237 |
if( root->NodeName().Compare( aTargetNode.NodeName() ) == 0 )
|
|
238 |
{
|
|
239 |
TBool found = EFalse;
|
|
240 |
TInt attrCount = root->AttributeCount();
|
|
241 |
TInt attrCount2 = aTargetNode.AttributeCount();
|
|
242 |
if( attrCount > 0 && attrCount == attrCount2 )
|
|
243 |
{
|
|
244 |
SXdmAttribute16 attribute;
|
|
245 |
for( TInt i = 0;i < attrCount;i++ )
|
|
246 |
{
|
|
247 |
attribute.iName.Set( aTargetNode.Attribute( i )->NodeName() );
|
|
248 |
attribute.iValue.Set( aTargetNode.Attribute( i )->AttributeValue() );
|
|
249 |
found = root->HasAttribute( attribute );
|
|
250 |
}
|
|
251 |
}
|
|
252 |
error = found ? aResultArray.Append( root ) : KErrNotFound;
|
|
253 |
}
|
|
254 |
else
|
|
255 |
{
|
|
256 |
#ifdef _DEBUG
|
|
257 |
iXdmEngine.WriteToLog( _L8( " Root does not match, search child nodes" ) );
|
|
258 |
#endif
|
|
259 |
error = root->Find( aTargetNode, aResultArray );
|
|
260 |
}
|
|
261 |
TInt count = aResultArray.Count();
|
|
262 |
return error == KErrNone && count > 0 ? count : KErrNotFound;
|
|
263 |
}
|
|
264 |
|
|
265 |
// ----------------------------------------------------
|
|
266 |
// CXdmDocument::Find
|
|
267 |
//
|
|
268 |
// ----------------------------------------------------
|
|
269 |
//
|
|
270 |
EXPORT_C TInt CXdmDocument::Find( const TDesC& aNodeName,
|
|
271 |
RPointerArray<CXdmDocumentNode>& aResultArray,
|
|
272 |
const RPointerArray<SXdmAttribute16>& aAttributeArray ) const
|
|
273 |
{
|
|
274 |
#ifdef _DEBUG
|
|
275 |
iXdmEngine.WriteToLog( _L8( "CXdmDocument::Find()" ) );
|
|
276 |
#endif
|
|
277 |
TInt error = KErrNone;
|
|
278 |
CXdmDocumentNode* root = DocumentRoot();
|
|
279 |
__ASSERT_ALWAYS( root != NULL, User::Panic( _L( "CXcapDocument" ), EDocNodeNull ) );
|
|
280 |
if( root->NodeName().Compare( aNodeName ) == 0 )
|
|
281 |
{
|
|
282 |
TBool found = EFalse;
|
|
283 |
TInt attrCount = root->AttributeCount();
|
|
284 |
if( attrCount > 0 )
|
|
285 |
{
|
|
286 |
for( TInt i = 0;i < attrCount;i++ )
|
|
287 |
found = root->HasAttribute( *aAttributeArray[i] );
|
|
288 |
}
|
|
289 |
error = found ? aResultArray.Append( root ) : KErrNotFound;
|
|
290 |
}
|
|
291 |
else
|
|
292 |
{
|
|
293 |
#ifdef _DEBUG
|
|
294 |
iXdmEngine.WriteToLog( _L8( " Root does not match, search child nodes" ) );
|
|
295 |
#endif
|
|
296 |
error = root->Find( aNodeName, aResultArray, aAttributeArray );
|
|
297 |
}
|
|
298 |
TInt count = aResultArray.Count();
|
|
299 |
return error == KErrNone && count > 0 ? count : KErrNotFound;
|
|
300 |
}
|
|
301 |
|
|
302 |
// ----------------------------------------------------
|
|
303 |
// CXdmDocument::Find
|
|
304 |
//
|
|
305 |
// ----------------------------------------------------
|
|
306 |
//
|
|
307 |
EXPORT_C TInt CXdmDocument::Find( const TDesC& aNodeName,
|
|
308 |
RPointerArray<CXdmDocumentNode>& aResultArray ) const
|
|
309 |
{
|
|
310 |
#ifdef _DEBUG
|
|
311 |
iXdmEngine.WriteToLog( _L8( "CXdmDocument::Find()" ) );
|
|
312 |
#endif
|
|
313 |
TInt error = KErrNone;
|
|
314 |
CXdmDocumentNode* root = DocumentRoot();
|
|
315 |
__ASSERT_ALWAYS( root != NULL, User::Panic( _L( "CXcapDocument" ), EDocNodeNull ) );
|
|
316 |
if( root->NodeName().Compare( aNodeName ) == 0 )
|
|
317 |
error = aResultArray.Append( root );
|
|
318 |
else
|
|
319 |
{
|
|
320 |
#ifdef _DEBUG
|
|
321 |
iXdmEngine.WriteToLog( _L8( " Root does not match, search child nodes" ) );
|
|
322 |
#endif
|
|
323 |
error = root->Find( aNodeName, aResultArray );
|
|
324 |
}
|
|
325 |
TInt count = aResultArray.Count();
|
|
326 |
return error == KErrNone && count > 0 ? count : KErrNotFound;
|
|
327 |
}
|
|
328 |
|
|
329 |
// ----------------------------------------------------
|
|
330 |
// CXcapDocument::operator==
|
|
331 |
//
|
|
332 |
// ----------------------------------------------------
|
|
333 |
//
|
|
334 |
EXPORT_C TBool CXdmDocument::operator==( CXdmDocument& aDocument ) const
|
|
335 |
{
|
|
336 |
CXdmDocumentNode* root1 = DocumentRoot();
|
|
337 |
CXdmDocumentNode* root2 = aDocument.DocumentRoot();
|
|
338 |
__ASSERT_ALWAYS( root1 != NULL, User::Panic( _L( "CXcapDocument" ), EDocNodeNull ) );
|
|
339 |
__ASSERT_ALWAYS( root2 != NULL, User::Panic( _L( "CXcapDocument" ), EDocNodeNull ) );
|
|
340 |
return Name().Compare( aDocument.Name() ) == 0 ? *root1 == *root2 : EFalse;
|
|
341 |
}
|
|
342 |
|
|
343 |
// ----------------------------------------------------
|
|
344 |
// CXdmDocument::Name
|
|
345 |
//
|
|
346 |
// ----------------------------------------------------
|
|
347 |
//
|
|
348 |
EXPORT_C TPtrC CXdmDocument::Name() const
|
|
349 |
{
|
|
350 |
return iDocumentName != NULL ? iDocumentName->Des() : TPtrC();
|
|
351 |
}
|
|
352 |
|
|
353 |
// ----------------------------------------------------
|
|
354 |
// CXdmDocument::Find
|
|
355 |
//
|
|
356 |
// ----------------------------------------------------
|
|
357 |
//
|
|
358 |
EXPORT_C TInt CXdmDocument::Find( const TDesC& aAttributeName,
|
|
359 |
RPointerArray<CXdmNodeAttribute>& aResultArray ) const
|
|
360 |
{
|
|
361 |
#ifdef _DEBUG
|
|
362 |
iXdmEngine.WriteToLog( _L8( "CXdmDocument::Find()" ) );
|
|
363 |
#endif
|
|
364 |
TInt error = KErrNone;
|
|
365 |
CXdmDocumentNode* root = DocumentRoot();
|
|
366 |
__ASSERT_ALWAYS( root != NULL, User::Panic( _L( "CXdmDocument" ), EDocNodeNull ) );
|
|
367 |
error = DoFindAttributes( root, aAttributeName, aResultArray );
|
|
368 |
TInt count = aResultArray.Count();
|
|
369 |
return error == KErrNone && count > 0 ? count : KErrNotFound;
|
|
370 |
}
|
|
371 |
|
|
372 |
// ----------------------------------------------------
|
|
373 |
// CXdmDocument::RemoveFromModelL
|
|
374 |
//
|
|
375 |
// ----------------------------------------------------
|
|
376 |
//
|
|
377 |
EXPORT_C void CXdmDocument::RemoveFromModelL( CXdmDocumentNode* aChileNode )
|
|
378 |
{
|
|
379 |
#ifdef _DEBUG
|
|
380 |
iXdmEngine.WriteToLog( _L8( "CXdmDocument::RemoveFromModel()" ) );
|
|
381 |
#endif
|
|
382 |
if( !iDocSubset )
|
|
383 |
{
|
|
384 |
CXdmDocumentNode* parent = aChileNode->Parent();
|
|
385 |
parent != NULL ? parent->RemoveChileNodeL( aChileNode ) : User::Leave( KErrArgument);
|
|
386 |
}
|
|
387 |
else User::Leave( KErrGeneral );
|
|
388 |
}
|
|
389 |
|
|
390 |
// ----------------------------------------------------
|
|
391 |
// CXdmDocument::ResetSubset
|
|
392 |
//
|
|
393 |
// ----------------------------------------------------
|
|
394 |
//
|
|
395 |
EXPORT_C void CXdmDocument::ResetSubset()
|
|
396 |
{
|
|
397 |
iDocSubset = EFalse;
|
|
398 |
}
|
|
399 |
|
|
400 |
// ----------------------------------------------------
|
|
401 |
// CXdmDocument::AppendToModelL
|
|
402 |
//
|
|
403 |
// ----------------------------------------------------
|
|
404 |
//
|
|
405 |
EXPORT_C void CXdmDocument::AppendToModelL( CXdmDocumentNode* aNewNode,
|
|
406 |
CXdmDocumentNode* aParentNode )
|
|
407 |
{
|
|
408 |
#ifdef _DEBUG
|
|
409 |
iXdmEngine.WriteToLog( _L8( "CXdmDocument::AppendToModelL()" ) );
|
|
410 |
#endif
|
|
411 |
if( !iDocSubset )
|
|
412 |
{
|
|
413 |
if( aNewNode != NULL && aParentNode != NULL )
|
|
414 |
aParentNode->AppendChileNodeL( aNewNode );
|
|
415 |
}
|
|
416 |
else User::Leave( KErrGeneral );
|
|
417 |
}
|
|
418 |
|
|
419 |
// ----------------------------------------------------
|
|
420 |
// CXdmDocument::ReplaceInModelL
|
|
421 |
//
|
|
422 |
// ----------------------------------------------------
|
|
423 |
//
|
|
424 |
EXPORT_C void CXdmDocument::ReplaceInModelL( CXdmDocumentNode* aNewNode,
|
|
425 |
CXdmDocumentNode* aTargetNode )
|
|
426 |
{
|
|
427 |
#ifdef _DEBUG
|
|
428 |
iXdmEngine.WriteToLog( _L8( "CXdmDocument::ReplaceInModelL()" ) );
|
|
429 |
#endif
|
|
430 |
if( !iDocSubset )
|
|
431 |
{
|
|
432 |
CXdmDocumentNode* parent = aTargetNode->Parent();
|
|
433 |
parent != NULL ? parent->ReplaceChileNodeL( aNewNode, aTargetNode ) : User::Leave( KErrArgument);
|
|
434 |
}
|
|
435 |
else User::Leave( KErrGeneral );
|
|
436 |
}
|
|
437 |
|
|
438 |
// ----------------------------------------------------
|
|
439 |
// CXdmDocument::DocumentSubsetL
|
|
440 |
//
|
|
441 |
// ----------------------------------------------------
|
|
442 |
//
|
|
443 |
EXPORT_C CXdmDocumentNode* CXdmDocument::DocumentSubsetL( const TDesC& aNodePath )
|
|
444 |
{
|
|
445 |
#ifdef _DEBUG
|
|
446 |
iXdmEngine.WriteToLog( _L8( "CXdmDocument::DocumentSubsetL()" ) );
|
|
447 |
#endif
|
|
448 |
TBool ready = EFalse;
|
|
449 |
HBufC* temp = HBufC::NewLC( aNodePath.Length() );
|
|
450 |
temp->Des().Copy( aNodePath );
|
|
451 |
TPtr nodePath( temp->Des() );
|
|
452 |
while( !ready && nodePath.Length() != 0 )
|
|
453 |
{
|
|
454 |
TPtrC part;
|
|
455 |
TInt index = nodePath.LocateF( KXdmPathSeparatorChar );
|
|
456 |
if( index > 0 )
|
|
457 |
part.Set( nodePath.Left( index ) );
|
|
458 |
else
|
|
459 |
{
|
|
460 |
part.Set( nodePath );
|
|
461 |
ready = ETrue;
|
|
462 |
}
|
|
463 |
AppendPathPartL( part );
|
|
464 |
nodePath.Delete( 0, index + 1 );
|
|
465 |
}
|
|
466 |
iDocSubset = ETrue;
|
|
467 |
CleanupStack::PopAndDestroy(); //temp
|
|
468 |
return CurrentExtent();
|
|
469 |
}
|
|
470 |
|
|
471 |
// ----------------------------------------------------
|
|
472 |
// CXdmDocument::DoFindAttributes
|
|
473 |
//
|
|
474 |
// ----------------------------------------------------
|
|
475 |
//
|
|
476 |
TInt CXdmDocument::DoFindAttributes( CXdmDocumentNode* aNode,
|
|
477 |
const TDesC& aAttributeName,
|
|
478 |
RPointerArray<CXdmNodeAttribute>& aResultArray ) const
|
|
479 |
{
|
|
480 |
#ifdef _DEBUG
|
|
481 |
iXdmEngine.WriteToLog( _L8( "CXdmDocument::DoFindAttributes()" ) );
|
|
482 |
#endif
|
|
483 |
TInt error = KErrNone;
|
|
484 |
CXdmDocumentNode* node = aNode;
|
|
485 |
TInt attrCount = aNode->AttributeCount();
|
|
486 |
for( TInt i = 0; i < attrCount; i++ )
|
|
487 |
{
|
|
488 |
CXdmNodeAttribute* attr = node->Attribute( i );
|
|
489 |
if( !attr->NodeName().CompareF( aAttributeName ) )
|
|
490 |
error = aResultArray.Append( attr );
|
|
491 |
}
|
|
492 |
TInt nodeCount = node->NodeCount();
|
|
493 |
for( TInt i = 0; i < nodeCount; i++ )
|
|
494 |
{
|
|
495 |
CXdmDocumentNode* child = node->ChileNode( i );
|
|
496 |
DoFindAttributes ( child, aAttributeName, aResultArray );
|
|
497 |
}
|
|
498 |
TInt count = aResultArray.Count();
|
|
499 |
return error == KErrNone && count > 0 ? count : KErrNotFound;
|
|
500 |
}
|
|
501 |
|
|
502 |
|
|
503 |
|
|
504 |
|
|
505 |
|