|
1 /* |
|
2 * Copyright (c) 2007 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: a data class containing browse-related data |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 |
|
21 |
|
22 |
|
23 // INCLUDE FILES |
|
24 #include "upnpfiletransferitem.h" |
|
25 |
|
26 // CONSTANTS |
|
27 const TInt KBrowseBufferGranularity = 100; |
|
28 |
|
29 // ============================ MEMBER FUNCTIONS ============================ |
|
30 |
|
31 // -------------------------------------------------------------------------- |
|
32 // CUpnpFileTransferItem::CUpnpFileTransferItem |
|
33 // C++ default constructor can NOT contain any code, that |
|
34 // might leave. |
|
35 // -------------------------------------------------------------------------- |
|
36 inline CUpnpFileTransferItem::CUpnpFileTransferItem() |
|
37 { |
|
38 } |
|
39 |
|
40 // -------------------------------------------------------------------------- |
|
41 // CUpnpFileTransferItem::ConstructL |
|
42 // Symbian 2nd phase constructor can leave. |
|
43 // -------------------------------------------------------------------------- |
|
44 inline void CUpnpFileTransferItem::ConstructL() |
|
45 { |
|
46 iUri = KNullDesC8().AllocL(); |
|
47 iTitle = KNullDesC8().AllocL(); |
|
48 iProtocolInfo = KNullDesC8().AllocL(); |
|
49 iPath = KNullDesC().AllocL(); |
|
50 } |
|
51 |
|
52 // -------------------------------------------------------------------------- |
|
53 // CUpnpFileTransferItem::NewL |
|
54 // Two-phased constructor. |
|
55 // -------------------------------------------------------------------------- |
|
56 inline CUpnpFileTransferItem* CUpnpFileTransferItem::NewL() |
|
57 { |
|
58 CUpnpFileTransferItem* self = NewLC(); |
|
59 CleanupStack::Pop( self ); |
|
60 return self; |
|
61 } |
|
62 |
|
63 // -------------------------------------------------------------------------- |
|
64 // CUpnpFileTransferItem::NewLC |
|
65 // Two-phased constructor. |
|
66 // -------------------------------------------------------------------------- |
|
67 inline CUpnpFileTransferItem* CUpnpFileTransferItem::NewLC() |
|
68 { |
|
69 CUpnpFileTransferItem* self = new( ELeave ) |
|
70 CUpnpFileTransferItem; |
|
71 CleanupStack::PushL( self ); |
|
72 self->ConstructL(); |
|
73 return self; |
|
74 } |
|
75 |
|
76 // -------------------------------------------------------------------------- |
|
77 // CUpnpFileTransferItem::NewLC |
|
78 // Two-phased constructor. |
|
79 // -------------------------------------------------------------------------- |
|
80 inline CUpnpFileTransferItem::~CUpnpFileTransferItem() |
|
81 { |
|
82 delete iUri; |
|
83 delete iTitle; |
|
84 delete iProtocolInfo; |
|
85 delete iPath; |
|
86 } |
|
87 |
|
88 // -------------------------------------------------------------------------- |
|
89 // CUpnpFileTransferItem::NewLC |
|
90 // Two-phased constructor. |
|
91 // -------------------------------------------------------------------------- |
|
92 inline void CUpnpFileTransferItem::ExternalizeL( RWriteStream& aStream ) const |
|
93 { |
|
94 aStream.WriteInt16L( iUri->Length() ); |
|
95 aStream << *iUri; |
|
96 |
|
97 aStream.WriteInt16L( iTitle->Length() ); |
|
98 aStream << *iTitle; |
|
99 |
|
100 aStream.WriteInt16L( iProtocolInfo->Length() ); |
|
101 aStream << *iProtocolInfo; |
|
102 |
|
103 aStream.WriteInt16L( iPath->Length() ); |
|
104 aStream << *iPath; |
|
105 |
|
106 aStream.WriteInt16L( iKey ); |
|
107 //aStream.WriteL( (TUint8*)(&iEvent), |
|
108 // sizeof(TUpnpFileTransferEvent) ); |
|
109 } |
|
110 |
|
111 // -------------------------------------------------------------------------- |
|
112 // CUpnpFileTransferItem::InternalizeL |
|
113 // Internalizes object |
|
114 // -------------------------------------------------------------------------- |
|
115 inline void CUpnpFileTransferItem::InternalizeL( RReadStream& aStream ) |
|
116 { |
|
117 TInt length = aStream.ReadInt16L(); |
|
118 delete iUri; iUri = NULL; |
|
119 iUri = HBufC8::NewL( aStream, length ); |
|
120 |
|
121 length = aStream.ReadInt16L(); |
|
122 delete iTitle; iTitle = NULL; |
|
123 iTitle = HBufC8::NewL( aStream, length ); |
|
124 |
|
125 length = aStream.ReadInt16L(); |
|
126 delete iProtocolInfo; iProtocolInfo = NULL; |
|
127 iProtocolInfo = HBufC8::NewL( aStream, length ); |
|
128 |
|
129 length = aStream.ReadInt16L(); |
|
130 delete iPath; iPath = NULL; |
|
131 iPath = HBufC::NewL( aStream, length ); |
|
132 |
|
133 iKey = aStream.ReadInt16L(); |
|
134 } |
|
135 |
|
136 // -------------------------------------------------------------------------- |
|
137 // CUpnpFileTransferItem::ToDes8L |
|
138 // Externalizes object to a heap descriptor |
|
139 // -------------------------------------------------------------------------- |
|
140 inline HBufC8* CUpnpFileTransferItem::ToDes8L() const |
|
141 { |
|
142 // serialize object |
|
143 CBufFlat* tempFlatBuf = CBufFlat::NewL( KBrowseBufferGranularity ); |
|
144 CleanupStack::PushL( tempFlatBuf ); |
|
145 |
|
146 RBufWriteStream stream( *tempFlatBuf ); |
|
147 CleanupClosePushL( stream ); |
|
148 |
|
149 stream << *this; |
|
150 |
|
151 // create heap descriptor |
|
152 HBufC8* tempBuf = HBufC8::NewLC( tempFlatBuf->Size() ); |
|
153 TPtr8 ptr( tempBuf->Des() ); |
|
154 tempFlatBuf->Read( 0, ptr, tempFlatBuf->Size() ); |
|
155 |
|
156 // clean up |
|
157 CleanupStack::Pop( tempBuf ); |
|
158 CleanupStack::PopAndDestroy( &stream ); |
|
159 CleanupStack::PopAndDestroy( tempFlatBuf ); |
|
160 |
|
161 return tempBuf; |
|
162 } |
|
163 |
|
164 // -------------------------------------------------------------------------- |
|
165 // CUpnpFileTransferItem::SetUriL |
|
166 // See upnpfiletransferitem.h |
|
167 // -------------------------------------------------------------------------- |
|
168 inline void CUpnpFileTransferItem::SetUriL( const TDesC8& aUri ) |
|
169 { |
|
170 HBufC8* tmp = aUri.AllocL(); |
|
171 delete iUri; |
|
172 iUri = tmp; |
|
173 } |
|
174 |
|
175 // -------------------------------------------------------------------------- |
|
176 // CUpnpFileTransferItem::Uri |
|
177 // See upnpfiletransferitem.h |
|
178 // -------------------------------------------------------------------------- |
|
179 inline const TDesC8& CUpnpFileTransferItem::Uri() const |
|
180 { |
|
181 if( iUri ) |
|
182 { |
|
183 return *iUri; |
|
184 } |
|
185 else |
|
186 { |
|
187 return KNullDesC8; |
|
188 } |
|
189 } |
|
190 |
|
191 // -------------------------------------------------------------------------- |
|
192 // CUpnpFileTransferItem::SetTitleL |
|
193 // See upnpfiletransferitem.h |
|
194 // -------------------------------------------------------------------------- |
|
195 inline void CUpnpFileTransferItem::SetTitleL( const TDesC8& aTitle ) |
|
196 { |
|
197 HBufC8* tmp = aTitle.AllocL(); |
|
198 delete iTitle; |
|
199 iTitle = tmp; |
|
200 } |
|
201 |
|
202 // -------------------------------------------------------------------------- |
|
203 // CUpnpFileTransferItem::Title |
|
204 // See upnpfiletransferitem.h |
|
205 // -------------------------------------------------------------------------- |
|
206 inline const TDesC8& CUpnpFileTransferItem::Title() const |
|
207 { |
|
208 if( iTitle ) |
|
209 { |
|
210 return *iTitle; |
|
211 } |
|
212 else |
|
213 { |
|
214 return KNullDesC8; |
|
215 } |
|
216 } |
|
217 |
|
218 // -------------------------------------------------------------------------- |
|
219 // CUpnpFileTransferItem::SetProtocolInfoL |
|
220 // See upnpfiletransferitem.h |
|
221 // -------------------------------------------------------------------------- |
|
222 inline void CUpnpFileTransferItem::SetProtocolInfoL( |
|
223 const TDesC8& aProtocolInfo ) |
|
224 { |
|
225 HBufC8* tmp = aProtocolInfo.AllocL(); |
|
226 delete iProtocolInfo; |
|
227 iProtocolInfo = tmp; |
|
228 } |
|
229 |
|
230 // -------------------------------------------------------------------------- |
|
231 // CUpnpFileTransferItem::ProtocolInfo |
|
232 // See upnpfiletransferitem.h |
|
233 // -------------------------------------------------------------------------- |
|
234 inline const TDesC8& CUpnpFileTransferItem::ProtocolInfo() const |
|
235 { |
|
236 if( iProtocolInfo ) |
|
237 { |
|
238 return *iProtocolInfo; |
|
239 } |
|
240 else |
|
241 { |
|
242 return KNullDesC8; |
|
243 } |
|
244 } |
|
245 |
|
246 // -------------------------------------------------------------------------- |
|
247 // CUpnpFileTransferItem::SetPathL |
|
248 // See upnpfiletransferitem.h |
|
249 // -------------------------------------------------------------------------- |
|
250 inline void CUpnpFileTransferItem::SetPathL( const TDesC& aPath ) |
|
251 { |
|
252 HBufC* tmp = aPath.AllocL(); |
|
253 delete iPath; |
|
254 iPath = tmp; |
|
255 } |
|
256 |
|
257 // -------------------------------------------------------------------------- |
|
258 // CUpnpFileTransferItem::Path |
|
259 // See upnpfiletransferitem.h |
|
260 // -------------------------------------------------------------------------- |
|
261 inline const TDesC& CUpnpFileTransferItem::Path() const |
|
262 { |
|
263 if( iPath ) |
|
264 { |
|
265 return *iPath; |
|
266 } |
|
267 else |
|
268 { |
|
269 return KNullDesC; |
|
270 } |
|
271 } |
|
272 |
|
273 // -------------------------------------------------------------------------- |
|
274 // CUpnpFileTransferItem::SetKey |
|
275 // See upnpfiletransferitem.h |
|
276 // -------------------------------------------------------------------------- |
|
277 inline void CUpnpFileTransferItem::SetKey( TInt aKey ) |
|
278 { |
|
279 iKey = aKey; |
|
280 } |
|
281 |
|
282 // -------------------------------------------------------------------------- |
|
283 // CUpnpFileTransferItem::Key |
|
284 // See upnpfiletransferitem.h |
|
285 // -------------------------------------------------------------------------- |
|
286 inline TInt CUpnpFileTransferItem::Key() |
|
287 { |
|
288 return iKey; |
|
289 } |
|
290 |
|
291 // End of File |