|
1 /* |
|
2 * Copyright (c) 2004 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: |
|
15 * Wrapper functions and classes for cXmlLibrary (NW_...) functionality. |
|
16 * |
|
17 * |
|
18 */ |
|
19 |
|
20 |
|
21 // INCLUDE FILES |
|
22 |
|
23 #include "NwUtil.h" |
|
24 #include "CodError.h" |
|
25 #include "CodPanic.h" |
|
26 #include <nw_dom_document.h> |
|
27 |
|
28 // ================= LOCAL FUNCTIONS ======================= |
|
29 |
|
30 /** |
|
31 * Cleanup function of type TCleanupOperation. Calls NW_String_deleteStorage |
|
32 * for aString. |
|
33 * @param aString NW_String_t* string. |
|
34 */ |
|
35 LOCAL_C void NwStringDeleteStorage( TAny* aString ) |
|
36 { |
|
37 NW_String_deleteStorage( STATIC_CAST( NW_String_t*, aString ) ); |
|
38 } |
|
39 |
|
40 // ================= GLOBAL FUNCTIONS ======================= |
|
41 |
|
42 // --------------------------------------------------------- |
|
43 // NwStatus2Error() |
|
44 // --------------------------------------------------------- |
|
45 // |
|
46 TInt NwStatus2Error( NW_Status_t aNwStatus ) |
|
47 { |
|
48 TInt ret( KErrGeneral ); |
|
49 |
|
50 switch ( aNwStatus ) |
|
51 { |
|
52 case NW_STAT_SUCCESS: |
|
53 { |
|
54 ret = KErrNone; |
|
55 break; |
|
56 } |
|
57 |
|
58 case NW_STAT_OUT_OF_MEMORY: |
|
59 { |
|
60 ret = KErrNoMemory; |
|
61 break; |
|
62 } |
|
63 |
|
64 case NW_STAT_CANCELLED: |
|
65 case NW_STAT_CONN_CANCELLED: |
|
66 { |
|
67 ret = KErrCancel; |
|
68 break; |
|
69 } |
|
70 |
|
71 default: |
|
72 { |
|
73 // XML parser returns NW_STAT_FAILURE for practically any error |
|
74 // except OOM. Let's say it's an ill-formed XML. |
|
75 ret = KErrCodInvalidDescriptor; |
|
76 break; |
|
77 } |
|
78 } |
|
79 |
|
80 return ret; |
|
81 } |
|
82 |
|
83 // --------------------------------------------------------- |
|
84 // CleanupNwUcs2PushL() |
|
85 // --------------------------------------------------------- |
|
86 // |
|
87 void CleanupNwUcs2PushL( NW_Ucs2* aUcs2 ) |
|
88 { |
|
89 // TODO: replace 'free' with NW_Mem_Free, when they export it! |
|
90 // That will remove our dependency on STLIB. |
|
91 __ASSERT_DEBUG( aUcs2, CodPanic( ECodInternal ) ); |
|
92 CleanupStack::PushL( TCleanupItem( free, aUcs2 ) ); |
|
93 } |
|
94 |
|
95 // --------------------------------------------------------- |
|
96 // CleanupNwStringStoragePushL() |
|
97 // --------------------------------------------------------- |
|
98 // |
|
99 void CleanupNwStringStoragePushL( NW_String_t* aString ) |
|
100 { |
|
101 __ASSERT_DEBUG( aString, CodPanic( ECodInternal ) ); |
|
102 CleanupStack::PushL( TCleanupItem( NwStringDeleteStorage, aString ) ); |
|
103 } |
|
104 |
|
105 // ================= MEMBER FUNCTIONS ======================= |
|
106 |
|
107 // --------------------------------------------------------- |
|
108 // RNwWbxmlDictionary::Initialize() |
|
109 // --------------------------------------------------------- |
|
110 // |
|
111 TInt RNwWbxmlDictionary::Initialize |
|
112 ( NW_Int32 aCount, NW_WBXML_Dictionary_t* aDictArray[] ) |
|
113 { |
|
114 return NwStatus2Error |
|
115 ( NW_WBXML_Dictionary_initialize( aCount, aDictArray ) ); |
|
116 } |
|
117 |
|
118 // --------------------------------------------------------- |
|
119 // RNwWbxmlDictionary::Close() |
|
120 // --------------------------------------------------------- |
|
121 // |
|
122 void RNwWbxmlDictionary::Close() |
|
123 { |
|
124 NW_WBXML_Dictionary_destroy(); |
|
125 } |
|
126 |
|
127 // --------------------------------------------------------- |
|
128 // CNwDomDocumentNode::~CNwDomDocumentNode() |
|
129 // --------------------------------------------------------- |
|
130 // |
|
131 CNwDomDocumentNode::~CNwDomDocumentNode() |
|
132 { |
|
133 if ( iDocNode ) |
|
134 { |
|
135 NW_DOM_DocumentNode_Delete( iDocNode ); |
|
136 } |
|
137 } |