|
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: Utilities for DS Loader Framework |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 // INCLUDE FILES |
|
20 #include <badesca.h> |
|
21 |
|
22 #include "nsmldsdpinformation.h" |
|
23 |
|
24 // ================================= MEMBER FUNCTIONS ============================================= |
|
25 |
|
26 // ------------------------------------------------------------------------------------------------ |
|
27 // CNSmlDPInformation::NewL |
|
28 // Creates new instance of CNSmlDPInformation based class. |
|
29 // ------------------------------------------------------------------------------------------------ |
|
30 EXPORT_C CNSmlDPInformation* CNSmlDPInformation::NewL() |
|
31 { |
|
32 CNSmlDPInformation* self = NewLC(); |
|
33 CleanupStack::Pop(); |
|
34 return self; |
|
35 } |
|
36 |
|
37 // ------------------------------------------------------------------------------------------------ |
|
38 // CNSmlDPInformation::NewLC |
|
39 // Creates new instance of CNSmlDPInformation based class. |
|
40 // ------------------------------------------------------------------------------------------------ |
|
41 EXPORT_C CNSmlDPInformation* CNSmlDPInformation::NewLC() |
|
42 { |
|
43 CNSmlDPInformation* self = new (ELeave) CNSmlDPInformation(); |
|
44 CleanupStack::PushL( self ); |
|
45 self->ConstructL(); |
|
46 return self; |
|
47 } |
|
48 |
|
49 // ------------------------------------------------------------------------------------------------ |
|
50 // CNSmlDPInformation::CNSmlDPInformation |
|
51 // C++ Destructor. |
|
52 // ------------------------------------------------------------------------------------------------ |
|
53 EXPORT_C CNSmlDPInformation::~CNSmlDPInformation() |
|
54 { |
|
55 if ( iInfo ) |
|
56 { |
|
57 delete iInfo->iDisplayName; |
|
58 delete iInfo->iMimeTypes; |
|
59 delete iInfo->iMimeVersions; |
|
60 delete iInfo; |
|
61 } |
|
62 } |
|
63 |
|
64 // ------------------------------------------------------------------------------------------------ |
|
65 // CNSmlDPInformation::SetId |
|
66 // ------------------------------------------------------------------------------------------------ |
|
67 EXPORT_C void CNSmlDPInformation::SetId(TSmlDataProviderId aId) const |
|
68 { |
|
69 iInfo->iId = aId; |
|
70 } |
|
71 // ------------------------------------------------------------------------------------------------ |
|
72 // CNSmlDPInformation::DisplayName |
|
73 // ------------------------------------------------------------------------------------------------ |
|
74 EXPORT_C const HBufC* CNSmlDPInformation::DisplayName() const |
|
75 { |
|
76 return iInfo->iDisplayName; |
|
77 } |
|
78 |
|
79 // ------------------------------------------------------------------------------------------------ |
|
80 // CNSmlDPInformation::SetDisplayName |
|
81 // ------------------------------------------------------------------------------------------------ |
|
82 EXPORT_C void CNSmlDPInformation::SetDisplayNameL( const TDesC& aDisplayName ) |
|
83 { |
|
84 delete iInfo->iDisplayName; |
|
85 iInfo->iDisplayName = NULL; |
|
86 iInfo->iDisplayName = aDisplayName.AllocL(); |
|
87 } |
|
88 |
|
89 // ------------------------------------------------------------------------------------------------ |
|
90 // CNSmlDPInformation::MimeType |
|
91 // ------------------------------------------------------------------------------------------------ |
|
92 EXPORT_C const CDesC8Array* CNSmlDPInformation::MimeTypes() const |
|
93 { |
|
94 return iInfo->iMimeTypes; |
|
95 } |
|
96 |
|
97 // ------------------------------------------------------------------------------------------------ |
|
98 // CNSmlDPInformation::SetMimeTypeL |
|
99 // ------------------------------------------------------------------------------------------------ |
|
100 EXPORT_C void CNSmlDPInformation::SetMimeTypesL( CDesC8Array* aMimeTypes ) |
|
101 { |
|
102 delete iInfo->iMimeTypes; |
|
103 iInfo->iMimeTypes = aMimeTypes; |
|
104 } |
|
105 |
|
106 // ------------------------------------------------------------------------------------------------ |
|
107 // CNSmlDPInformation::MimeVer |
|
108 // ------------------------------------------------------------------------------------------------ |
|
109 EXPORT_C const CDesC8Array* CNSmlDPInformation::MimeVers() const |
|
110 { |
|
111 return iInfo->iMimeVersions; |
|
112 } |
|
113 |
|
114 // ------------------------------------------------------------------------------------------------ |
|
115 // CNSmlDPInformation::SetMimeVerL |
|
116 // ------------------------------------------------------------------------------------------------ |
|
117 EXPORT_C void CNSmlDPInformation::SetMimeVersL( CDesC8Array* aMimeVersions ) |
|
118 { |
|
119 delete iInfo->iMimeVersions; |
|
120 iInfo->iMimeVersions = aMimeVersions; |
|
121 } |
|
122 |
|
123 // ------------------------------------------------------------------------------------------------ |
|
124 // CNSmlDPInformation::ProtocolVersion |
|
125 // ------------------------------------------------------------------------------------------------ |
|
126 EXPORT_C TSmlProtocolVersion CNSmlDPInformation::ProtocolVersion() const |
|
127 { |
|
128 return iInfo->iProtocolVer; |
|
129 } |
|
130 |
|
131 // ------------------------------------------------------------------------------------------------ |
|
132 // CNSmlDPInformation::SetProtocolVersion |
|
133 // ------------------------------------------------------------------------------------------------ |
|
134 EXPORT_C void CNSmlDPInformation::SetProtocolVersion( TSmlProtocolVersion aProtocol ) |
|
135 { |
|
136 iInfo->iProtocolVer = aProtocol; |
|
137 } |
|
138 |
|
139 // ------------------------------------------------------------------------------------------------ |
|
140 // CNSmlDPInformation::Version |
|
141 // ------------------------------------------------------------------------------------------------ |
|
142 EXPORT_C const TVersion& CNSmlDPInformation::Version() const |
|
143 { |
|
144 return iInfo->iVersion; |
|
145 } |
|
146 |
|
147 // ------------------------------------------------------------------------------------------------ |
|
148 // CNSmlDPInformation::SetVersion |
|
149 // ------------------------------------------------------------------------------------------------ |
|
150 EXPORT_C void CNSmlDPInformation::SetVersion( const TVersion& aVersion ) |
|
151 { |
|
152 iInfo->iVersion = aVersion; |
|
153 } |
|
154 |
|
155 // ------------------------------------------------------------------------------------------------ |
|
156 // CNSmlDPInformation::InformationD |
|
157 // ------------------------------------------------------------------------------------------------ |
|
158 EXPORT_C TNSmlDPInformation* CNSmlDPInformation::InformationD() |
|
159 { |
|
160 TNSmlDPInformation* ret = iInfo; |
|
161 iInfo = NULL; |
|
162 delete this; |
|
163 return ret; |
|
164 } |
|
165 |
|
166 // ------------------------------------------------------------------------------------------------ |
|
167 // CNSmlDPInformation::ExternalizeL |
|
168 // ------------------------------------------------------------------------------------------------ |
|
169 EXPORT_C void CNSmlDPInformation::ExternalizeL( RWriteStream& aStream ) const |
|
170 { |
|
171 TPckgC<TSmlDataProviderId> id( iInfo->iId ); |
|
172 aStream.WriteL( id ); |
|
173 |
|
174 //version |
|
175 aStream.WriteInt32L( iInfo->iVersion.iMajor ); |
|
176 aStream.WriteInt32L( iInfo->iVersion.iMinor ); |
|
177 aStream.WriteInt32L( iInfo->iVersion.iBuild ); |
|
178 |
|
179 aStream.WriteInt32L( iInfo->iProtocolVer ); |
|
180 |
|
181 aStream.WriteUint32L( iInfo->iDisplayName->Length() ); |
|
182 aStream << *iInfo->iDisplayName; |
|
183 |
|
184 TInt mimetypesCount( iInfo->iMimeTypes->Count() ); |
|
185 aStream.WriteUint32L( mimetypesCount ); |
|
186 |
|
187 for (TInt i = 0; i < mimetypesCount; i++ ) |
|
188 { |
|
189 const TDesC8& mimetype = (*iInfo->iMimeTypes)[i]; |
|
190 aStream.WriteUint32L( mimetype.Length() ); |
|
191 aStream << mimetype; |
|
192 } |
|
193 |
|
194 TInt mimeversCount( iInfo->iMimeVersions->Count() ); |
|
195 aStream.WriteUint32L( mimeversCount ); |
|
196 |
|
197 for (TInt i = 0; i < mimeversCount; i++ ) |
|
198 { |
|
199 const TDesC8& mimever = (*iInfo->iMimeVersions)[i]; |
|
200 aStream.WriteUint32L( mimever.Length() ); |
|
201 aStream << mimever; |
|
202 } |
|
203 } |
|
204 |
|
205 // ------------------------------------------------------------------------------------------------ |
|
206 // CNSmlDPInformation::InternalizeL |
|
207 // ------------------------------------------------------------------------------------------------ |
|
208 EXPORT_C void CNSmlDPInformation::InternalizeL( RReadStream& aStream ) |
|
209 { |
|
210 TPckg<TSmlDataProviderId> id( iInfo->iId ); |
|
211 aStream.ReadL( id ); |
|
212 |
|
213 iInfo->iVersion.iMajor = aStream.ReadInt32L(); |
|
214 iInfo->iVersion.iMinor = aStream.ReadInt32L(); |
|
215 iInfo->iVersion.iBuild = aStream.ReadInt32L(); |
|
216 |
|
217 iInfo->iProtocolVer = static_cast<TSmlProtocolVersion>( aStream.ReadInt32L() ); |
|
218 |
|
219 delete iInfo->iDisplayName; |
|
220 iInfo->iDisplayName = NULL; |
|
221 iInfo->iDisplayName = HBufC::NewL( aStream, aStream.ReadUint32L() ); |
|
222 |
|
223 delete iInfo->iMimeTypes; |
|
224 iInfo->iMimeTypes = NULL; |
|
225 TInt mimetypesCount = aStream.ReadUint32L(); |
|
226 CDesC8Array* mimetypes = new (ELeave) CDesC8ArrayFlat( Max<TInt>( 2, mimetypesCount ) ); |
|
227 CleanupStack::PushL( mimetypes ); |
|
228 |
|
229 for (TInt i = 0 ; i < mimetypesCount; i++ ) |
|
230 { |
|
231 HBufC8* tempBuf8 = HBufC8::NewLC( aStream, aStream.ReadUint32L() ); |
|
232 mimetypes->AppendL( *tempBuf8 ); |
|
233 CleanupStack::PopAndDestroy(); // tempBuf8 |
|
234 } |
|
235 |
|
236 delete iInfo->iMimeVersions; |
|
237 iInfo->iMimeVersions = NULL; |
|
238 TInt mimeversCount = aStream.ReadUint32L(); |
|
239 CDesC8Array* mimevers = new (ELeave) CDesC8ArrayFlat( Max<TInt>( 2, mimeversCount ) ); |
|
240 CleanupStack::PushL( mimevers ); |
|
241 |
|
242 for (TInt i = 0 ; i < mimeversCount; i++ ) |
|
243 { |
|
244 HBufC8* tempBuf8 = HBufC8::NewLC( aStream, aStream.ReadUint32L() ); |
|
245 mimevers->AppendL( *tempBuf8 ); |
|
246 CleanupStack::PopAndDestroy(); // tempBuf8 |
|
247 } |
|
248 |
|
249 iInfo->iMimeTypes = mimetypes; |
|
250 iInfo->iMimeVersions = mimevers; |
|
251 |
|
252 CleanupStack::Pop(2); // mimetypes, mimevers |
|
253 } |
|
254 |
|
255 // ------------------------------------------------------------------------------------------------ |
|
256 // CNSmlDPInformation::CNSmlDPInformation |
|
257 // ------------------------------------------------------------------------------------------------ |
|
258 CNSmlDPInformation::CNSmlDPInformation() : iInfo( NULL ) |
|
259 { |
|
260 |
|
261 } |
|
262 |
|
263 // ------------------------------------------------------------------------------------------------ |
|
264 // CNSmlDPInformation::ConstructL |
|
265 // ------------------------------------------------------------------------------------------------ |
|
266 void CNSmlDPInformation::ConstructL() |
|
267 { |
|
268 iInfo = new ( ELeave ) TNSmlDPInformation; |
|
269 iInfo->iId = 0; |
|
270 iInfo->iProtocolVer = ESmlVersion1_1_2; |
|
271 iInfo->iDisplayName = NULL; |
|
272 iInfo->iMimeTypes = NULL; |
|
273 iInfo->iMimeVersions = NULL; |
|
274 |
|
275 iInfo->iDisplayName = HBufC::NewL( 0 ); |
|
276 iInfo->iMimeTypes = new ( ELeave ) CDesC8ArrayFlat( 2 ); |
|
277 iInfo->iMimeVersions = new ( ELeave ) CDesC8ArrayFlat( 2 ); |
|
278 } |
|
279 |
|
280 // End of File |