|
1 /* |
|
2 * Copyright (c) 2006 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 for client-server comms |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 |
|
21 |
|
22 |
|
23 // INCLUDE FILES |
|
24 |
|
25 #include "upnpavrequest.h" |
|
26 |
|
27 #include <upnpitem.h> |
|
28 |
|
29 // CONSTANTS |
|
30 _LIT( KURIRequestPanicText, "CUpnpAVRequest" ); |
|
31 const TInt KMaxStringLen = 256; |
|
32 const TInt KMaxStringLenLong = 1024; |
|
33 const TInt KBufferGranularity = 100; |
|
34 |
|
35 // ============================ MEMBER FUNCTIONS ============================ |
|
36 |
|
37 // -------------------------------------------------------------------------- |
|
38 // CUpnpAVRequest::CUpnpAVRequest |
|
39 // C++ default constructor can NOT contain any code, that |
|
40 // might leave. |
|
41 // -------------------------------------------------------------------------- |
|
42 inline CUpnpAVRequest::CUpnpAVRequest() |
|
43 { |
|
44 } |
|
45 |
|
46 // -------------------------------------------------------------------------- |
|
47 // CUpnpAVRequest::ConstructL |
|
48 // Symbian 2nd phase constructor can leave. |
|
49 // -------------------------------------------------------------------------- |
|
50 inline void CUpnpAVRequest::ConstructL() |
|
51 { |
|
52 iId = KNullDesC8().AllocL(); |
|
53 iUuid = KNullDesC8().AllocL(); |
|
54 iFilePath = KNullDesC().AllocL();; |
|
55 iURI = KNullDesC8().AllocL(); |
|
56 //iItem = CUpnpItem::NewL(); |
|
57 } |
|
58 |
|
59 // -------------------------------------------------------------------------- |
|
60 // CUpnpAVRequest::NewL |
|
61 // Two-phased constructor. |
|
62 // -------------------------------------------------------------------------- |
|
63 inline CUpnpAVRequest* CUpnpAVRequest::NewL() |
|
64 { |
|
65 CUpnpAVRequest* self = NewLC(); |
|
66 CleanupStack::Pop( self ); |
|
67 return self; |
|
68 } |
|
69 |
|
70 // -------------------------------------------------------------------------- |
|
71 // CUpnpAVRequest::NewLC |
|
72 // Two-phased constructor. |
|
73 // -------------------------------------------------------------------------- |
|
74 inline CUpnpAVRequest* CUpnpAVRequest::NewLC() |
|
75 { |
|
76 CUpnpAVRequest* self = new( ELeave ) |
|
77 CUpnpAVRequest; |
|
78 CleanupStack::PushL( self ); |
|
79 self->ConstructL(); |
|
80 return self; |
|
81 } |
|
82 |
|
83 |
|
84 // -------------------------------------------------------------------------- |
|
85 // CUpnpAVRequest::~CUpnpAVRequest |
|
86 // Destructor |
|
87 // -------------------------------------------------------------------------- |
|
88 inline CUpnpAVRequest::~CUpnpAVRequest() |
|
89 { |
|
90 delete iId; |
|
91 delete iUuid; |
|
92 delete iFilePath; |
|
93 delete iURI; |
|
94 } |
|
95 |
|
96 // -------------------------------------------------------------------------- |
|
97 // CUpnpAVRequest::ExternalizeL |
|
98 // Externatizes object |
|
99 // -------------------------------------------------------------------------- |
|
100 inline void CUpnpAVRequest::ExternalizeL( RWriteStream& aStream ) const |
|
101 { |
|
102 aStream << *iId; |
|
103 aStream << *iUuid; |
|
104 aStream << *iFilePath; |
|
105 aStream << *iURI; |
|
106 aStream.WriteInt16L( (TInt)iRequiresBrowse ); |
|
107 aStream.WriteInt16L( (TInt)iMemoryType ); |
|
108 aStream.WriteInt16L( (TInt)iFileSharing ); |
|
109 } |
|
110 |
|
111 // -------------------------------------------------------------------------- |
|
112 // CUpnpAVRequest::InternalizeL |
|
113 // Internalizes object |
|
114 // -------------------------------------------------------------------------- |
|
115 inline void CUpnpAVRequest::InternalizeL( RReadStream& aStream ) |
|
116 { |
|
117 delete iId; iId = NULL; |
|
118 iId = HBufC8::NewL( aStream, KMaxStringLen ); |
|
119 |
|
120 delete iUuid; iUuid = NULL; |
|
121 iUuid = HBufC8::NewL( aStream, KMaxStringLen ); |
|
122 |
|
123 delete iFilePath; iFilePath = NULL; |
|
124 iFilePath = HBufC::NewL( aStream, KMaxStringLen ); |
|
125 |
|
126 delete iURI; iURI = NULL; |
|
127 iURI = HBufC8::NewL( aStream, KMaxStringLenLong ); |
|
128 |
|
129 iRequiresBrowse = (TBool)aStream.ReadInt16L(); |
|
130 |
|
131 iMemoryType = (MUPnPAVBrowsingSession::TMemoryType)aStream.ReadInt16L(); |
|
132 |
|
133 iFileSharing = (MUPnPAVBrowsingSession::TFileSharing) |
|
134 aStream.ReadInt16L(); |
|
135 } |
|
136 |
|
137 // -------------------------------------------------------------------------- |
|
138 // CUpnpAVRequest::ToDes8L |
|
139 // Externalizes object to a heap descriptor |
|
140 // -------------------------------------------------------------------------- |
|
141 inline HBufC8* CUpnpAVRequest::ToDes8L() const |
|
142 { |
|
143 // serialize object |
|
144 CBufFlat* tempFlatBuf = CBufFlat::NewL( KBufferGranularity ); |
|
145 CleanupStack::PushL( tempFlatBuf ); |
|
146 |
|
147 RBufWriteStream stream( *tempFlatBuf ); |
|
148 CleanupClosePushL( stream ); |
|
149 |
|
150 stream << *this; |
|
151 |
|
152 // create heap descriptor |
|
153 HBufC8* tempBuf = HBufC8::NewLC( tempFlatBuf->Size() ); |
|
154 TPtr8 ptr( tempBuf->Des() ); |
|
155 tempFlatBuf->Read( 0, ptr, tempFlatBuf->Size() ); |
|
156 |
|
157 // clean up |
|
158 CleanupStack::Pop( tempBuf ); |
|
159 CleanupStack::PopAndDestroy( &stream ); |
|
160 CleanupStack::PopAndDestroy( tempFlatBuf ); |
|
161 |
|
162 return tempBuf; |
|
163 } |
|
164 |
|
165 // -------------------------------------------------------------------------- |
|
166 // CUpnpAVRequest::SetIdL |
|
167 // Sets id |
|
168 // -------------------------------------------------------------------------- |
|
169 inline void CUpnpAVRequest::SetIdL( const TDesC8& aId ) |
|
170 { |
|
171 HBufC8* tempBuf = aId.AllocL(); |
|
172 delete iId; |
|
173 iId = tempBuf; |
|
174 } |
|
175 |
|
176 // -------------------------------------------------------------------------- |
|
177 // CUpnpAVRequest::Id |
|
178 // Returns id |
|
179 // -------------------------------------------------------------------------- |
|
180 inline const TDesC8& CUpnpAVRequest::Id() |
|
181 { |
|
182 if( iId ) |
|
183 { |
|
184 return *iId; |
|
185 } |
|
186 else |
|
187 { |
|
188 return KNullDesC8; |
|
189 } |
|
190 } |
|
191 |
|
192 // -------------------------------------------------------------------------- |
|
193 // CUpnpAVRequest::SetUuidL |
|
194 // Sets uuid |
|
195 // -------------------------------------------------------------------------- |
|
196 inline void CUpnpAVRequest::SetUuidL( const TDesC8& aUuid ) |
|
197 { |
|
198 HBufC8* tempBuf = aUuid.AllocL(); |
|
199 delete iUuid; |
|
200 iUuid = tempBuf; |
|
201 } |
|
202 |
|
203 // -------------------------------------------------------------------------- |
|
204 // CUpnpAVRequest::Uuid |
|
205 // Returns uuid |
|
206 // -------------------------------------------------------------------------- |
|
207 inline const TDesC8& CUpnpAVRequest::Uuid() |
|
208 { |
|
209 if( iUuid ) |
|
210 { |
|
211 return *iUuid; |
|
212 } |
|
213 else |
|
214 { |
|
215 return KNullDesC8; |
|
216 } |
|
217 } |
|
218 |
|
219 // -------------------------------------------------------------------------- |
|
220 // CUpnpAVRequest::SetFilePathL |
|
221 // Sets filepath |
|
222 // -------------------------------------------------------------------------- |
|
223 inline void CUpnpAVRequest::SetFilePathL( const TDesC& aFilePath ) |
|
224 { |
|
225 HBufC* tempBuf = aFilePath.AllocL(); |
|
226 delete iFilePath; |
|
227 iFilePath = tempBuf; |
|
228 } |
|
229 |
|
230 // -------------------------------------------------------------------------- |
|
231 // CUpnpAVRequest::FilePath |
|
232 // Returns filepath |
|
233 // -------------------------------------------------------------------------- |
|
234 inline const TDesC& CUpnpAVRequest::FilePath() |
|
235 { |
|
236 if( iFilePath ) |
|
237 { |
|
238 return *iFilePath; |
|
239 } |
|
240 else |
|
241 { |
|
242 return KNullDesC; |
|
243 } |
|
244 } |
|
245 |
|
246 // -------------------------------------------------------------------------- |
|
247 // CUpnpAVRequest::SetURIL |
|
248 // Sets URI |
|
249 // -------------------------------------------------------------------------- |
|
250 inline void CUpnpAVRequest::SetURIL( const TDesC8& aURI ) |
|
251 { |
|
252 HBufC8* tempBuf = aURI.AllocL(); |
|
253 delete iURI; |
|
254 iURI = tempBuf; |
|
255 } |
|
256 |
|
257 // -------------------------------------------------------------------------- |
|
258 // CUpnpAVRequest::URI |
|
259 // Returns URI |
|
260 // -------------------------------------------------------------------------- |
|
261 inline const TDesC8& CUpnpAVRequest::URI() |
|
262 { |
|
263 if( iURI ) |
|
264 { |
|
265 return *iURI; |
|
266 } |
|
267 else |
|
268 { |
|
269 return KNullDesC8; |
|
270 } |
|
271 } |
|
272 |
|
273 // -------------------------------------------------------------------------- |
|
274 // CUpnpAVRequest::SetRequiresBrowse |
|
275 // |
|
276 // -------------------------------------------------------------------------- |
|
277 inline void CUpnpAVRequest::SetRequiresBrowse( TBool aBrowse ) |
|
278 { |
|
279 iRequiresBrowse = aBrowse; |
|
280 } |
|
281 |
|
282 // -------------------------------------------------------------------------- |
|
283 // CUpnpAVRequest::RequiresBrowse |
|
284 // |
|
285 // -------------------------------------------------------------------------- |
|
286 inline TBool CUpnpAVRequest::RequiresBrowse() |
|
287 { |
|
288 return iRequiresBrowse; |
|
289 } |
|
290 |
|
291 // -------------------------------------------------------------------------- |
|
292 // CUpnpAVRequest::SetMemoryType |
|
293 // Sets used memory type |
|
294 // -------------------------------------------------------------------------- |
|
295 inline void CUpnpAVRequest::SetMemoryType( |
|
296 MUPnPAVBrowsingSession::TMemoryType aMemoryType ) |
|
297 { |
|
298 iMemoryType = aMemoryType; |
|
299 } |
|
300 |
|
301 // -------------------------------------------------------------------------- |
|
302 // CUpnpAVRequest::MemoryType |
|
303 // Returns used memory type |
|
304 // -------------------------------------------------------------------------- |
|
305 inline MUPnPAVBrowsingSession::TMemoryType CUpnpAVRequest::MemoryType() |
|
306 { |
|
307 return iMemoryType; |
|
308 } |
|
309 |
|
310 // -------------------------------------------------------------------------- |
|
311 // CUpnpAVRequest::SetFileSharing |
|
312 // Sets the state of filesharing |
|
313 // -------------------------------------------------------------------------- |
|
314 inline void CUpnpAVRequest::SetFileSharing( |
|
315 MUPnPAVBrowsingSession::TFileSharing aFileSharing ) |
|
316 { |
|
317 iFileSharing = aFileSharing; |
|
318 } |
|
319 |
|
320 // -------------------------------------------------------------------------- |
|
321 // CUpnpAVRequest::FileSharing |
|
322 // Returns the state of filesharing |
|
323 // -------------------------------------------------------------------------- |
|
324 inline MUPnPAVBrowsingSession::TFileSharing CUpnpAVRequest::FileSharing() |
|
325 { |
|
326 return iFileSharing; |
|
327 } |
|
328 |
|
329 // End of File |
|
330 |