|
1 /* |
|
2 * Copyright (c) 2008 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: |
|
15 * |
|
16 */ |
|
17 |
|
18 // System include files |
|
19 #include <utf.h> |
|
20 |
|
21 // User include files |
|
22 #include "hscontentinfo.h" |
|
23 |
|
24 // Local constants |
|
25 |
|
26 // ======== MEMBER FUNCTIONS ======== |
|
27 |
|
28 // ----------------------------------------------------------------------- |
|
29 // CHsContentInfo::NewL() |
|
30 // ----------------------------------------------------------------------- |
|
31 // |
|
32 EXPORT_C CHsContentInfo* CHsContentInfo::NewL() |
|
33 { |
|
34 CHsContentInfo* self = CHsContentInfo::NewLC(); |
|
35 CleanupStack::Pop( self ); |
|
36 return self; |
|
37 } |
|
38 |
|
39 // ----------------------------------------------------------------------- |
|
40 // CHsContentInfo::NewL() |
|
41 // ----------------------------------------------------------------------- |
|
42 // |
|
43 EXPORT_C CHsContentInfo* CHsContentInfo::NewL( RReadStream& aStream ) |
|
44 { |
|
45 CHsContentInfo* self = new ( ELeave ) CHsContentInfo(); |
|
46 CleanupStack::PushL( self ); |
|
47 self->InternalizeL( aStream ); |
|
48 CleanupStack::Pop( self ); |
|
49 return self; |
|
50 } |
|
51 |
|
52 // ----------------------------------------------------------------------- |
|
53 // CHsContentInfo::NewLC() |
|
54 // ----------------------------------------------------------------------- |
|
55 // |
|
56 EXPORT_C CHsContentInfo* CHsContentInfo::NewLC() |
|
57 { |
|
58 CHsContentInfo* self = new ( ELeave ) CHsContentInfo(); |
|
59 CleanupStack::PushL( self ); |
|
60 self->ConstructL(); |
|
61 return self; |
|
62 } |
|
63 |
|
64 // ----------------------------------------------------------------------- |
|
65 // CHsContentInfo::CloneL() |
|
66 // ----------------------------------------------------------------------- |
|
67 // |
|
68 EXPORT_C CHsContentInfo* CHsContentInfo::CloneL() |
|
69 { |
|
70 CHsContentInfo* clone = new ( ELeave ) CHsContentInfo(); |
|
71 CleanupStack::PushL( clone ); |
|
72 |
|
73 clone->iName = Name().AllocL(); |
|
74 clone->iUid = Uid().AllocL(); |
|
75 clone->iPluginId = PluginId().AllocL(); |
|
76 clone->iType = Type().AllocL(); |
|
77 clone->iPublisherId = PublisherId().AllocL(); |
|
78 clone->iDescription = Description().AllocL(); |
|
79 clone->iIconPath = IconPath().AllocL(); |
|
80 clone->iMaxInstance = iMaxInstance; |
|
81 clone->iCanBeAdded = iCanBeAdded; |
|
82 clone->iCanBeRemoved = iCanBeRemoved; |
|
83 clone->iInstallationTime = iInstallationTime; |
|
84 clone->iPublisherUid = PublisherUid().AllocL(); |
|
85 clone->iIsWrt = iIsWrt; |
|
86 |
|
87 CleanupStack::Pop(); |
|
88 return clone; |
|
89 } |
|
90 |
|
91 // ----------------------------------------------------------------------- |
|
92 // CHsContentInfo::ConstructL() |
|
93 // ----------------------------------------------------------------------- |
|
94 // |
|
95 void CHsContentInfo::ConstructL() |
|
96 { |
|
97 } |
|
98 |
|
99 // ----------------------------------------------------------------------- |
|
100 // CHsContentInfo::CHsContentInfo() |
|
101 // ----------------------------------------------------------------------- |
|
102 // |
|
103 CHsContentInfo::CHsContentInfo() |
|
104 { |
|
105 } |
|
106 |
|
107 // ----------------------------------------------------------------------- |
|
108 // CHsContentInfo::~CHsContentInfo() |
|
109 // ----------------------------------------------------------------------- |
|
110 // |
|
111 CHsContentInfo::~CHsContentInfo() |
|
112 { |
|
113 delete iName; |
|
114 delete iUid; |
|
115 delete iPluginId; |
|
116 delete iType; |
|
117 delete iPublisherId; |
|
118 delete iDescription; |
|
119 delete iIconPath; |
|
120 delete iPublisherUid; |
|
121 } |
|
122 |
|
123 // --------------------------------------------------------------------------- |
|
124 // CHsContentInfo::SetNameL |
|
125 // --------------------------------------------------------------------------- |
|
126 // |
|
127 EXPORT_C void CHsContentInfo::SetNameL( const TDesC8& aName ) |
|
128 { |
|
129 delete iName; |
|
130 iName = 0; |
|
131 iName = CnvUtfConverter::ConvertToUnicodeFromUtf8L( aName ); |
|
132 } |
|
133 |
|
134 // --------------------------------------------------------------------------- |
|
135 // CHsContentInfo::SetNameL |
|
136 // --------------------------------------------------------------------------- |
|
137 // |
|
138 EXPORT_C void CHsContentInfo::SetNameL( const TDesC& aName ) |
|
139 { |
|
140 delete iName; |
|
141 iName = 0; |
|
142 iName = aName.AllocL(); |
|
143 } |
|
144 |
|
145 // --------------------------------------------------------------------------- |
|
146 // CHsContentInfo::SetPublisherIdL |
|
147 // --------------------------------------------------------------------------- |
|
148 // |
|
149 EXPORT_C void CHsContentInfo::SetPublisherIdL( |
|
150 const TDesC& aPublisherId ) |
|
151 { |
|
152 delete iPublisherId; |
|
153 iPublisherId = 0; |
|
154 iPublisherId = aPublisherId.AllocL(); |
|
155 } |
|
156 |
|
157 // --------------------------------------------------------------------------- |
|
158 // CHsContentInfo::SetUidL |
|
159 // --------------------------------------------------------------------------- |
|
160 // |
|
161 EXPORT_C void CHsContentInfo::SetUidL( const TDesC8& aUid ) |
|
162 { |
|
163 delete iUid; |
|
164 iUid = 0; |
|
165 iUid = aUid.AllocL(); |
|
166 } |
|
167 |
|
168 // --------------------------------------------------------------------------- |
|
169 // CHsContentInfo::SetPluginIdL |
|
170 // --------------------------------------------------------------------------- |
|
171 // |
|
172 EXPORT_C void CHsContentInfo::SetPluginIdL( const TDesC8& aId ) |
|
173 { |
|
174 delete iPluginId; |
|
175 iPluginId = 0; |
|
176 iPluginId = aId.AllocL(); |
|
177 } |
|
178 |
|
179 // --------------------------------------------------------------------------- |
|
180 // CHsContentInfo::SetTypeL |
|
181 // --------------------------------------------------------------------------- |
|
182 // |
|
183 EXPORT_C void CHsContentInfo::SetTypeL( const TDesC8& aType ) |
|
184 { |
|
185 delete iType; |
|
186 iType = 0; |
|
187 iType = aType.AllocL(); |
|
188 } |
|
189 |
|
190 // --------------------------------------------------------------------------- |
|
191 // CHsContentInfo::Name |
|
192 // --------------------------------------------------------------------------- |
|
193 // |
|
194 EXPORT_C const TDesC& CHsContentInfo::Name()const |
|
195 { |
|
196 return ( iName ) ? *iName : KNullDesC(); |
|
197 } |
|
198 |
|
199 // --------------------------------------------------------------------------- |
|
200 // CHsContentInfo::PublisherId |
|
201 // --------------------------------------------------------------------------- |
|
202 // |
|
203 EXPORT_C const TDesC& CHsContentInfo::PublisherId()const |
|
204 { |
|
205 return ( iPublisherId ) ? *iPublisherId : KNullDesC(); |
|
206 } |
|
207 |
|
208 // --------------------------------------------------------------------------- |
|
209 // CHsContentInfo::Uid |
|
210 // --------------------------------------------------------------------------- |
|
211 // |
|
212 EXPORT_C const TDesC8& CHsContentInfo::Uid()const |
|
213 { |
|
214 return ( iUid ) ? *iUid : KNullDesC8(); |
|
215 } |
|
216 |
|
217 // --------------------------------------------------------------------------- |
|
218 // CHsContentInfo::NameAs8BitLC |
|
219 // --------------------------------------------------------------------------- |
|
220 // |
|
221 EXPORT_C HBufC8* CHsContentInfo::NameAs8BitLC()const |
|
222 { |
|
223 HBufC8* ret( CnvUtfConverter::ConvertFromUnicodeToUtf8L( Name() ) ); |
|
224 CleanupStack::PushL( ret ); |
|
225 |
|
226 return ret; |
|
227 } |
|
228 |
|
229 // --------------------------------------------------------------------------- |
|
230 // CHsContentInfo::PluginId |
|
231 // --------------------------------------------------------------------------- |
|
232 // |
|
233 EXPORT_C const TDesC8& CHsContentInfo::PluginId()const |
|
234 { |
|
235 return ( iPluginId ) ? *iPluginId : KNullDesC8(); |
|
236 } |
|
237 |
|
238 // --------------------------------------------------------------------------- |
|
239 // CHsContentInfo::Type |
|
240 // --------------------------------------------------------------------------- |
|
241 // |
|
242 EXPORT_C const TDesC8& CHsContentInfo::Type()const |
|
243 { |
|
244 return ( iType ) ? *iType : KNullDesC8(); |
|
245 } |
|
246 |
|
247 // ----------------------------------------------------------------------- |
|
248 // CPublisherInfo::SetMaxWidgets() |
|
249 // ----------------------------------------------------------------------- |
|
250 // |
|
251 EXPORT_C void CHsContentInfo::SetMaxWidgets( TInt aMaxWidget ) |
|
252 { |
|
253 iMaxInstance = aMaxWidget; |
|
254 } |
|
255 |
|
256 // ----------------------------------------------------------------------- |
|
257 // CPublisherInfo::MaxWidgets() |
|
258 // ----------------------------------------------------------------------- |
|
259 // |
|
260 EXPORT_C TInt CHsContentInfo::MaxWidgets() const |
|
261 { |
|
262 return iMaxInstance; |
|
263 } |
|
264 |
|
265 // ----------------------------------------------------------------------- |
|
266 // CHsContentInfo::ExternalizeL() |
|
267 // ----------------------------------------------------------------------- |
|
268 // |
|
269 EXPORT_C void CHsContentInfo::ExternalizeL( RWriteStream& aStream ) |
|
270 { |
|
271 // Keep this externalize routine in-sync with header file's members |
|
272 |
|
273 // externalize iName |
|
274 aStream.WriteInt16L( Name().Size() ); |
|
275 aStream << Name(); |
|
276 |
|
277 // externalize iUid |
|
278 aStream.WriteInt16L( Uid().Size() ); |
|
279 aStream << Uid(); |
|
280 |
|
281 // externalize iPluginId; |
|
282 aStream.WriteInt16L( PluginId().Size() ); |
|
283 aStream << PluginId(); |
|
284 |
|
285 // externalize iType; |
|
286 aStream.WriteInt16L( Type().Size() ); |
|
287 aStream << Type(); |
|
288 |
|
289 // externalize iPublisherId; |
|
290 aStream.WriteInt16L( PublisherId().Size() ); |
|
291 aStream << PublisherId(); |
|
292 |
|
293 // externalize iDescription; |
|
294 aStream.WriteInt16L( Description().Size() ); |
|
295 aStream << Description(); |
|
296 |
|
297 // externalize iIconPath; |
|
298 aStream.WriteInt16L( IconPath().Size() ); |
|
299 aStream << IconPath(); |
|
300 |
|
301 // externalize iMaxInstance |
|
302 aStream.WriteInt16L( iMaxInstance ); |
|
303 // externalize iCanBeAdded |
|
304 aStream.WriteInt16L( iCanBeAdded ); |
|
305 // externalize iCanBeRemoved |
|
306 aStream.WriteInt16L( iCanBeRemoved ); |
|
307 |
|
308 TInt64 time( iInstallationTime.Int64() ); |
|
309 |
|
310 TUint32 low( I64LOW( time ) ); |
|
311 TUint32 high( I64HIGH( time ) ); |
|
312 |
|
313 // externalize iInstallationTime |
|
314 aStream.WriteUint32L( low ); |
|
315 aStream.WriteUint32L( high ); |
|
316 |
|
317 // externalize iPublisherUid |
|
318 aStream.WriteInt16L( PublisherUid().Size() ); |
|
319 aStream << PublisherUid(); |
|
320 |
|
321 // externalise iIsWrt |
|
322 aStream.WriteInt16L( iIsWrt ); |
|
323 } |
|
324 |
|
325 // ----------------------------------------------------------------------- |
|
326 // CHsContentInfo::SetCanBeAdded() |
|
327 // ----------------------------------------------------------------------- |
|
328 // |
|
329 EXPORT_C void CHsContentInfo::SetCanBeAdded( TBool aValue ) |
|
330 { |
|
331 iCanBeAdded = aValue; |
|
332 } |
|
333 |
|
334 // ----------------------------------------------------------------------- |
|
335 // CHsContentInfo::CanBeAdded() |
|
336 // ----------------------------------------------------------------------- |
|
337 // |
|
338 EXPORT_C TBool CHsContentInfo::CanBeAdded() const |
|
339 { |
|
340 return iCanBeAdded; |
|
341 } |
|
342 |
|
343 // ----------------------------------------------------------------------- |
|
344 // CHsContentInfo::SetCanBeRemoved() |
|
345 // ----------------------------------------------------------------------- |
|
346 // |
|
347 EXPORT_C void CHsContentInfo::SetCanBeRemoved( TBool aValue ) |
|
348 { |
|
349 iCanBeRemoved = aValue; |
|
350 } |
|
351 |
|
352 // ----------------------------------------------------------------------- |
|
353 // CHsContentInfo::CanBeRemoved() |
|
354 // ----------------------------------------------------------------------- |
|
355 // |
|
356 EXPORT_C TBool CHsContentInfo::CanBeRemoved() const |
|
357 { |
|
358 return iCanBeRemoved; |
|
359 } |
|
360 |
|
361 // ----------------------------------------------------------------------- |
|
362 // CHsContentInfo::SetInstallationTime() |
|
363 // ----------------------------------------------------------------------- |
|
364 // |
|
365 EXPORT_C void CHsContentInfo::SetInstallationTime( TTime& aTime ) |
|
366 { |
|
367 iInstallationTime = aTime; |
|
368 } |
|
369 |
|
370 // ----------------------------------------------------------------------- |
|
371 // CHsContentInfo::InstallationTime() |
|
372 // ----------------------------------------------------------------------- |
|
373 // |
|
374 EXPORT_C TTime CHsContentInfo::InstallationTime() const |
|
375 { |
|
376 return iInstallationTime; |
|
377 } |
|
378 |
|
379 // ----------------------------------------------------------------------- |
|
380 // CHsContentInfo::SetDescriptionL() |
|
381 // ----------------------------------------------------------------------- |
|
382 // |
|
383 EXPORT_C void CHsContentInfo::SetDescriptionL( const TDesC& aDescription ) |
|
384 { |
|
385 delete iDescription; |
|
386 iDescription = NULL; |
|
387 |
|
388 iDescription = aDescription.AllocL(); |
|
389 } |
|
390 |
|
391 // ----------------------------------------------------------------------- |
|
392 // CHsContentInfo::Description() |
|
393 // ----------------------------------------------------------------------- |
|
394 // |
|
395 EXPORT_C const TDesC& CHsContentInfo::Description() const |
|
396 { |
|
397 return ( iDescription ) ? *iDescription : KNullDesC(); |
|
398 } |
|
399 |
|
400 // ----------------------------------------------------------------------- |
|
401 // CHsContentInfo::SetIconPathL() |
|
402 // ----------------------------------------------------------------------- |
|
403 // |
|
404 EXPORT_C void CHsContentInfo::SetIconPathL( const TDesC& aIconPath ) |
|
405 { |
|
406 delete iIconPath; |
|
407 iIconPath = NULL; |
|
408 |
|
409 iIconPath = aIconPath.AllocL(); |
|
410 } |
|
411 |
|
412 // ----------------------------------------------------------------------- |
|
413 // CHsContentInfo::IconPath() |
|
414 // ----------------------------------------------------------------------- |
|
415 // |
|
416 EXPORT_C const TDesC& CHsContentInfo::IconPath() const |
|
417 { |
|
418 return ( iIconPath ) ? *iIconPath : KNullDesC(); |
|
419 } |
|
420 |
|
421 // ----------------------------------------------------------------------- |
|
422 // CHsContentInfo::InternalizeL() |
|
423 // ----------------------------------------------------------------------- |
|
424 // |
|
425 EXPORT_C void CHsContentInfo::InternalizeL( RReadStream& aStream ) |
|
426 { |
|
427 TInt length( 0 ); |
|
428 |
|
429 // internalize iName |
|
430 length = aStream.ReadInt16L(); |
|
431 delete iName; |
|
432 iName = NULL; |
|
433 iName = HBufC::NewL( aStream, length ); |
|
434 |
|
435 // internalize iUid |
|
436 length = aStream.ReadInt16L(); |
|
437 delete iUid; |
|
438 iUid = NULL; |
|
439 iUid = HBufC8::NewL( aStream, length ); |
|
440 |
|
441 // internalize iPluginId |
|
442 length = aStream.ReadInt16L(); |
|
443 delete iPluginId; |
|
444 iPluginId = NULL; |
|
445 iPluginId = HBufC8::NewL( aStream, length ); |
|
446 |
|
447 // internalize iType |
|
448 length = aStream.ReadInt16L(); |
|
449 delete iType; |
|
450 iType = NULL; |
|
451 iType = HBufC8::NewL( aStream, length ); |
|
452 |
|
453 // internalize iPlublisherId; |
|
454 length = aStream.ReadInt16L(); |
|
455 delete iPublisherId; |
|
456 iPublisherId = NULL; |
|
457 iPublisherId = HBufC16::NewL( aStream, length ); |
|
458 |
|
459 // internalize iDescription; |
|
460 length = aStream.ReadInt16L(); |
|
461 delete iDescription; |
|
462 iDescription = NULL; |
|
463 iDescription = HBufC16::NewL( aStream, length ); |
|
464 |
|
465 // internalize iIconPath; |
|
466 length = aStream.ReadInt16L(); |
|
467 delete iIconPath; |
|
468 iIconPath = NULL; |
|
469 iIconPath = HBufC16::NewL( aStream, length ); |
|
470 |
|
471 // internalize iMaxInstance |
|
472 iMaxInstance = aStream.ReadInt16L(); |
|
473 // internalize iCanBeAdded |
|
474 iCanBeAdded = aStream.ReadInt16L(); |
|
475 // internalize iCanBeRemoved |
|
476 iCanBeRemoved = aStream.ReadInt16L(); |
|
477 |
|
478 TUint32 low( aStream.ReadUint32L() ); |
|
479 TUint32 high( aStream.ReadUint32L() ); |
|
480 |
|
481 iInstallationTime = TTime( MAKE_TINT64( high, low ) ); |
|
482 |
|
483 // internalize iPublisherUid |
|
484 length = aStream.ReadInt16L(); |
|
485 delete iPublisherUid; |
|
486 iPublisherUid = NULL; |
|
487 iPublisherUid = HBufC8::NewL( aStream, length ); |
|
488 |
|
489 // internalize iIsWrt |
|
490 iIsWrt = aStream.ReadInt16L(); |
|
491 } |
|
492 |
|
493 // ----------------------------------------------------------------------- |
|
494 // CHsContentInfo::Size() |
|
495 // ----------------------------------------------------------------------- |
|
496 // |
|
497 EXPORT_C TInt CHsContentInfo::Size( ) |
|
498 { |
|
499 TInt size( 0 ); |
|
500 size = size + Name().Size(); // name |
|
501 size = size + Uid().Size(); // uid |
|
502 size = size + PluginId().Size(); // plugin id |
|
503 size = size + Type().Size(); // type |
|
504 size = size + PublisherId().Size(); // publisher id |
|
505 size = size + Description().Size(); // description |
|
506 size = size + IconPath().Size(); // icon path |
|
507 size = size + sizeof( TInt16 ); // max instance |
|
508 size = size + sizeof( TInt16 ); // can be added |
|
509 size = size + sizeof( TInt16 ); // can be removed |
|
510 size = size + sizeof( TUint32 ); // installation time low |
|
511 size = size + sizeof( TUint32 ); // installation time high |
|
512 size = size + PublisherUid().Size();// publisher uid |
|
513 size = size + sizeof( TInt16 ); // is wrt |
|
514 |
|
515 return size; |
|
516 } |
|
517 |
|
518 // ----------------------------------------------------------------------- |
|
519 // CHsContentInfo::SetPublisherUidL() |
|
520 // ----------------------------------------------------------------------- |
|
521 // |
|
522 EXPORT_C void CHsContentInfo::SetPublisherUidL( |
|
523 const TDesC8& aPublisherUid ) |
|
524 { |
|
525 delete iPublisherUid; |
|
526 iPublisherUid = 0; |
|
527 iPublisherUid = aPublisherUid.AllocL(); |
|
528 } |
|
529 |
|
530 // ----------------------------------------------------------------------- |
|
531 // CHsContentInfo::PublisherUid() |
|
532 // ----------------------------------------------------------------------- |
|
533 // |
|
534 EXPORT_C const TDesC8& CHsContentInfo::PublisherUid() const |
|
535 { |
|
536 return ( iPublisherUid ) ? *iPublisherUid : KNullDesC8(); |
|
537 } |
|
538 |
|
539 // ----------------------------------------------------------------------- |
|
540 // CHsContentInfo::SetIsWrt() |
|
541 // ----------------------------------------------------------------------- |
|
542 // |
|
543 EXPORT_C void CHsContentInfo::SetIsWrt( TBool aIsWrt ) |
|
544 { |
|
545 iIsWrt = aIsWrt; |
|
546 } |
|
547 |
|
548 // ----------------------------------------------------------------------- |
|
549 // CHsContentInfo::IsWrt() |
|
550 // ----------------------------------------------------------------------- |
|
551 // |
|
552 EXPORT_C TBool CHsContentInfo::IsWrt() const |
|
553 { |
|
554 return iIsWrt; |
|
555 } |
|
556 |
|
557 // ----------------------------------------------------------------------- |
|
558 // CHsContentInfo::MarshalL() |
|
559 // ----------------------------------------------------------------------- |
|
560 // |
|
561 EXPORT_C HBufC8* CHsContentInfo::MarshalL( ) |
|
562 { |
|
563 |
|
564 // Externalize message |
|
565 CBufFlat* reqBuf = CBufFlat::NewL( Size() ); |
|
566 CleanupStack::PushL( reqBuf ); |
|
567 RBufWriteStream reqStream( *reqBuf ); |
|
568 CleanupClosePushL( reqStream ); |
|
569 ExternalizeL( reqStream ); |
|
570 CleanupStack::PopAndDestroy( &reqStream ); |
|
571 |
|
572 // Append externalized messgae to a descriptor |
|
573 HBufC8* msgDesc = HBufC8::NewL( reqBuf->Size() ); |
|
574 TPtr8 msgPtr( NULL, 0 ); |
|
575 msgPtr.Set( msgDesc->Des() ); |
|
576 reqBuf->Read( 0, msgPtr, reqBuf->Size() ); |
|
577 CleanupStack::PopAndDestroy( reqBuf ); |
|
578 |
|
579 return msgDesc; |
|
580 |
|
581 } |
|
582 |
|
583 // End of file |