|
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 #include <hscontentinfo.h> |
|
21 |
|
22 // User include files |
|
23 #include "hscontentinfoarray.h" |
|
24 |
|
25 // Local constants |
|
26 |
|
27 // ======== MEMBER FUNCTIONS ======== |
|
28 |
|
29 // ----------------------------------------------------------------------- |
|
30 // CHsContentInfoArray::NewL() |
|
31 // ----------------------------------------------------------------------- |
|
32 // |
|
33 EXPORT_C CHsContentInfoArray* CHsContentInfoArray::NewL() |
|
34 { |
|
35 CHsContentInfoArray* self = new ( ELeave ) CHsContentInfoArray(); |
|
36 CleanupStack::PushL( self ); |
|
37 self->ConstructL(); |
|
38 CleanupStack::Pop( self ); |
|
39 return self; |
|
40 } |
|
41 |
|
42 // ----------------------------------------------------------------------- |
|
43 // CHsContentInfoArray::NewL() |
|
44 // ----------------------------------------------------------------------- |
|
45 // |
|
46 EXPORT_C CHsContentInfoArray* CHsContentInfoArray::NewL( RReadStream& aStream ) |
|
47 { |
|
48 CHsContentInfoArray* self = new ( ELeave ) CHsContentInfoArray(); |
|
49 CleanupStack::PushL( self ); |
|
50 self->InternalizeL( aStream ); |
|
51 CleanupStack::Pop( self ); |
|
52 return self; |
|
53 } |
|
54 |
|
55 // ----------------------------------------------------------------------- |
|
56 // CHsContentInfoArray::ConstructL() |
|
57 // ----------------------------------------------------------------------- |
|
58 // |
|
59 void CHsContentInfoArray::ConstructL() |
|
60 { |
|
61 } |
|
62 |
|
63 // ----------------------------------------------------------------------- |
|
64 // CHsContentInfoArray::CHsContentInfoArray() |
|
65 // ----------------------------------------------------------------------- |
|
66 // |
|
67 CHsContentInfoArray::CHsContentInfoArray() |
|
68 { |
|
69 } |
|
70 |
|
71 // ----------------------------------------------------------------------- |
|
72 // CHsContentInfoArray::~CHsContentInfoArray() |
|
73 // ----------------------------------------------------------------------- |
|
74 // |
|
75 CHsContentInfoArray::~CHsContentInfoArray() |
|
76 { |
|
77 iArray.ResetAndDestroy(); |
|
78 } |
|
79 |
|
80 // ----------------------------------------------------------------------- |
|
81 // CHsContentInfoArray::Array() |
|
82 // ----------------------------------------------------------------------- |
|
83 // |
|
84 EXPORT_C RPointerArray< CHsContentInfo >& CHsContentInfoArray::Array() |
|
85 { |
|
86 return iArray; |
|
87 } |
|
88 |
|
89 // ----------------------------------------------------------------------- |
|
90 // CHsContentInfoArray::ExternalizeL() |
|
91 // ----------------------------------------------------------------------- |
|
92 // |
|
93 EXPORT_C void CHsContentInfoArray::ExternalizeL( RWriteStream& aStream ) |
|
94 { |
|
95 aStream.WriteInt16L( iArray.Count() ); |
|
96 |
|
97 for( int i = 0; i < iArray.Count(); i++ ) |
|
98 { |
|
99 CHsContentInfo* info = iArray[i]; |
|
100 info->ExternalizeL( aStream ); |
|
101 } |
|
102 } |
|
103 |
|
104 |
|
105 // ----------------------------------------------------------------------- |
|
106 // CHsContentInfoArray::InternalizeL() |
|
107 // ----------------------------------------------------------------------- |
|
108 // |
|
109 EXPORT_C void CHsContentInfoArray::InternalizeL( RReadStream& aStream ) |
|
110 { |
|
111 TInt count = aStream.ReadInt16L(); |
|
112 |
|
113 for( int i = 0; i < count; i++ ) |
|
114 { |
|
115 CHsContentInfo* info = CHsContentInfo::NewL( aStream ); |
|
116 iArray.AppendL( info ); |
|
117 } |
|
118 } |
|
119 |
|
120 // ----------------------------------------------------------------------- |
|
121 // CHsContentInfoArray::Size() |
|
122 // ----------------------------------------------------------------------- |
|
123 // |
|
124 EXPORT_C TInt CHsContentInfoArray::Size( ) |
|
125 { |
|
126 TInt size( sizeof( TInt16 ) ); |
|
127 for ( TInt i = 0; i < iArray.Count(); i++ ) |
|
128 { |
|
129 size = size + iArray[ i ]->Size(); |
|
130 } |
|
131 return size; |
|
132 } |
|
133 |
|
134 // ----------------------------------------------------------------------- |
|
135 // CHsContentInfoArray::MarshalL() |
|
136 // ----------------------------------------------------------------------- |
|
137 // |
|
138 EXPORT_C HBufC8* CHsContentInfoArray::MarshalL( ) |
|
139 { |
|
140 |
|
141 // Externalize message |
|
142 CBufFlat* reqBuf = CBufFlat::NewL( Size() ); |
|
143 CleanupStack::PushL( reqBuf ); |
|
144 RBufWriteStream reqStream( *reqBuf ); |
|
145 CleanupClosePushL( reqStream ); |
|
146 ExternalizeL( reqStream ); |
|
147 CleanupStack::PopAndDestroy( &reqStream ); |
|
148 |
|
149 // Append externalized messgae to a descriptor |
|
150 HBufC8* msgDesc = HBufC8::NewL( reqBuf->Size() ); |
|
151 TPtr8 msgPtr( NULL, 0 ); |
|
152 msgPtr.Set( msgDesc->Des() ); |
|
153 reqBuf->Read( 0, msgPtr, reqBuf->Size() ); |
|
154 CleanupStack::PopAndDestroy( reqBuf ); |
|
155 |
|
156 return msgDesc; |
|
157 |
|
158 } |
|
159 |
|
160 // End of file |