|
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: CLocalRetrieval |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 |
|
21 // INCLUDES |
|
22 #include "XdmXmlParser.h" |
|
23 #include "LocalProtocol.h" |
|
24 #include "LocalDocument.h" |
|
25 #include "LocalRetrieval.h" |
|
26 #include "LocalDocumentNode.h" |
|
27 #include "LocalOperationFactory.h" |
|
28 |
|
29 // --------------------------------------------------------- |
|
30 // CLocalRetrieval::CLocalRetrieval |
|
31 // |
|
32 // --------------------------------------------------------- |
|
33 // |
|
34 CLocalRetrieval::CLocalRetrieval( CLocalDocument& aTargetDoc, |
|
35 CLocalDocumentNode* aDocumentSubset, |
|
36 CLocalOperationFactory& aOperationFactory ) : |
|
37 CLocalOperationBase( aTargetDoc, aOperationFactory ), |
|
38 iDocumentSubset( aDocumentSubset ), |
|
39 iOperationType( aDocumentSubset == NULL ? |
|
40 EXdmDocument : EXdmPartialDocument ) |
|
41 |
|
42 { |
|
43 } |
|
44 |
|
45 // --------------------------------------------------------- |
|
46 // CLocalRetrieval::NewL |
|
47 // |
|
48 // --------------------------------------------------------- |
|
49 // |
|
50 CLocalRetrieval* CLocalRetrieval::NewL( CLocalDocument& aParentDoc, |
|
51 CLocalDocumentNode* aDocumentSubset, |
|
52 CLocalOperationFactory& aOperationFactory ) |
|
53 { |
|
54 CLocalRetrieval* self = new ( ELeave ) CLocalRetrieval( aParentDoc, aDocumentSubset, aOperationFactory ); |
|
55 CleanupStack::PushL( self ); |
|
56 self->BaseConstructL(); |
|
57 CleanupStack::Pop(); |
|
58 return self; |
|
59 } |
|
60 |
|
61 // --------------------------------------------------------- |
|
62 // CLocalRetrieval::ExecuteL |
|
63 // |
|
64 // --------------------------------------------------------- |
|
65 // |
|
66 void CLocalRetrieval::ExecuteL() |
|
67 { |
|
68 #ifdef _DEBUG |
|
69 iOperationFactory.WriteToLog( _L8( "CLocalRetrieval::ExecuteL()" ) ); |
|
70 #endif |
|
71 HBufC8* data = NULL; |
|
72 TInt error = KErrNone; |
|
73 TInt length = OpenDataFileL( iTargetDoc.XmlFilePath() ); |
|
74 TRAP( error, data = FetchXmlDataL( length ) ); |
|
75 CleanupStack::PushL( data ); |
|
76 if( data != NULL ) |
|
77 { |
|
78 if( iDocumentSubset == NULL ) |
|
79 { |
|
80 TRAP( error, iXmlParser->ParseDocumentL( &iTargetDoc, *data ) ); |
|
81 #ifdef _DEBUG |
|
82 iOperationFactory.WriteToLog( _L8( " Document fetch complete - Error: %d" ), error ); |
|
83 #endif |
|
84 } |
|
85 else |
|
86 { |
|
87 iDocumentSubset->SetEmptyNode( ETrue ); |
|
88 iDocumentSubset->SetEmptyNode( EFalse ); |
|
89 TRAP( error, iXmlParser->ParseDocumentL( &iTargetDoc, *data, ( CXdmDocumentNode* )iDocumentSubset ) ); |
|
90 #ifdef _DEBUG |
|
91 iOperationFactory.WriteToLog( _L8( " Document fetch complete: %d" ), error ); |
|
92 #endif |
|
93 } |
|
94 } |
|
95 else |
|
96 { |
|
97 #ifdef _DEBUG |
|
98 iOperationFactory.WriteToLog( _L8( " Reading of the document data failed: %d" ), error ); |
|
99 #endif |
|
100 User::Leave( error ); |
|
101 } |
|
102 CleanupStack::PopAndDestroy(); //data |
|
103 iXmlFile.Close(); |
|
104 } |
|
105 |
|
106 // --------------------------------------------------------- |
|
107 // CLocalRetrieval::Destroy |
|
108 // |
|
109 // --------------------------------------------------------- |
|
110 // |
|
111 void CLocalRetrieval::Destroy() |
|
112 { |
|
113 delete this; |
|
114 } |
|
115 |
|
116 // --------------------------------------------------------- |
|
117 // CLocalRetrieval::~CLocalRetrieval |
|
118 // |
|
119 // --------------------------------------------------------- |
|
120 // |
|
121 CLocalRetrieval::~CLocalRetrieval() |
|
122 { |
|
123 |
|
124 } |
|
125 |
|
126 // End of File |
|
127 |