1 /* |
|
2 * Copyright (c) 2006-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: Capsulating fill file list item |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 |
|
21 |
|
22 |
|
23 #include <e32std.h> |
|
24 #include <s32mem.h> |
|
25 #include "cmfilllistitem.h" |
|
26 #include "msdebug.h" |
|
27 |
|
28 |
|
29 // ======== LOCAL FUNCTIONS ======== |
|
30 // --------------------------------------------------------------------------- |
|
31 // NewL |
|
32 // --------------------------------------------------------------------------- |
|
33 // |
|
34 EXPORT_C CCmFillListItem* CCmFillListItem::NewL() |
|
35 { |
|
36 CCmFillListItem* self = CCmFillListItem::NewLC(); |
|
37 CleanupStack::Pop( self ); |
|
38 return self; |
|
39 } |
|
40 |
|
41 // --------------------------------------------------------------------------- |
|
42 // NewLC |
|
43 // --------------------------------------------------------------------------- |
|
44 // |
|
45 EXPORT_C CCmFillListItem* CCmFillListItem::NewLC() |
|
46 { |
|
47 CCmFillListItem* self = new ( ELeave ) CCmFillListItem(); |
|
48 CleanupStack::PushL( self ); |
|
49 self->ConstructL(); |
|
50 return self; |
|
51 } |
|
52 |
|
53 // --------------------------------------------------------------------------- |
|
54 // NewLC with parameters |
|
55 // --------------------------------------------------------------------------- |
|
56 // |
|
57 EXPORT_C CCmFillListItem* CCmFillListItem::NewLC( const TUint aPriority, |
|
58 const TUint aListId, const TUint aStatus, |
|
59 const TCmFillRuleStatus aSelected ) |
|
60 { |
|
61 CCmFillListItem* self = new ( ELeave ) CCmFillListItem(); |
|
62 CleanupStack::PushL( self ); |
|
63 self->ConstructL( aPriority, aListId, aStatus, aSelected ); |
|
64 return self; |
|
65 } |
|
66 |
|
67 // --------------------------------------------------------------------------- |
|
68 // Destructor |
|
69 // --------------------------------------------------------------------------- |
|
70 // |
|
71 EXPORT_C CCmFillListItem::~CCmFillListItem() |
|
72 { |
|
73 delete iUpnpClass; |
|
74 delete iUri; |
|
75 delete iItemId; |
|
76 } |
|
77 |
|
78 // --------------------------------------------------------------------------- |
|
79 // CCmFillListItem::SetUpnpClassL |
|
80 // --------------------------------------------------------------------------- |
|
81 // |
|
82 EXPORT_C void CCmFillListItem::SetUpnpClassL( const TDesC& aUpnpClass ) |
|
83 { |
|
84 if( &aUpnpClass ) |
|
85 { |
|
86 delete iUpnpClass; |
|
87 iUpnpClass = NULL; |
|
88 iUpnpClass = aUpnpClass.AllocL(); |
|
89 } |
|
90 else |
|
91 { |
|
92 delete iUpnpClass; |
|
93 iUpnpClass = NULL; |
|
94 iUpnpClass = KNullDesC().AllocL(); |
|
95 } |
|
96 } |
|
97 |
|
98 // --------------------------------------------------------------------------- |
|
99 // CCmFillListItem::SetUriL |
|
100 // --------------------------------------------------------------------------- |
|
101 // |
|
102 EXPORT_C void CCmFillListItem::SetUriL( const TDesC8& aUri ) |
|
103 { |
|
104 if( &aUri ) |
|
105 { |
|
106 delete iUri; |
|
107 iUri = NULL; |
|
108 iUri = aUri.AllocL(); |
|
109 } |
|
110 else |
|
111 { |
|
112 delete iUri; |
|
113 iUri = NULL; |
|
114 iUri = KNullDesC8().AllocL(); |
|
115 } |
|
116 } |
|
117 |
|
118 // --------------------------------------------------------------------------- |
|
119 // CCmFillListItem::SetItemIdL |
|
120 // --------------------------------------------------------------------------- |
|
121 // |
|
122 EXPORT_C void CCmFillListItem::SetItemIdL( const TDesC8& aItemId ) |
|
123 { |
|
124 if( &aItemId ) |
|
125 { |
|
126 delete iItemId; |
|
127 iItemId = NULL; |
|
128 iItemId = aItemId.AllocL(); |
|
129 } |
|
130 else |
|
131 { |
|
132 delete iItemId; |
|
133 iItemId = NULL; |
|
134 iItemId = KNullDesC8().AllocL(); |
|
135 } |
|
136 } |
|
137 |
|
138 // --------------------------------------------------------------------------- |
|
139 // CCmFillListItem::SetListId |
|
140 // --------------------------------------------------------------------------- |
|
141 // |
|
142 EXPORT_C void CCmFillListItem::SetListId( const TUint aId ) |
|
143 { |
|
144 iListId = aId; |
|
145 } |
|
146 |
|
147 // --------------------------------------------------------------------------- |
|
148 // CCmFillListItem::SetDevId |
|
149 // --------------------------------------------------------------------------- |
|
150 // |
|
151 EXPORT_C void CCmFillListItem::SetDevId( const TUint8 aDevId ) |
|
152 { |
|
153 iDevId = aDevId; |
|
154 } |
|
155 |
|
156 // --------------------------------------------------------------------------- |
|
157 // CCmFillListItem::SetPriority |
|
158 // --------------------------------------------------------------------------- |
|
159 // |
|
160 EXPORT_C void CCmFillListItem::SetPriority( const TUint8 aPriority ) |
|
161 { |
|
162 iPriority = aPriority; |
|
163 } |
|
164 |
|
165 // --------------------------------------------------------------------------- |
|
166 // CCmFillListItem::SetSelected |
|
167 // --------------------------------------------------------------------------- |
|
168 // |
|
169 EXPORT_C void CCmFillListItem::SetSelected( |
|
170 TCmFillRuleStatus aSelected ) |
|
171 { |
|
172 iSelected = aSelected; |
|
173 } |
|
174 |
|
175 // --------------------------------------------------------------------------- |
|
176 // CCmFillListItem::SetDriveId |
|
177 // --------------------------------------------------------------------------- |
|
178 // |
|
179 EXPORT_C void CCmFillListItem::SetDriveId( const TUint aDriveId ) |
|
180 { |
|
181 iDriveId = aDriveId; |
|
182 } |
|
183 |
|
184 // --------------------------------------------------------------------------- |
|
185 // CCmFillListItem::SetDriveNumber |
|
186 // --------------------------------------------------------------------------- |
|
187 // |
|
188 EXPORT_C void CCmFillListItem::SetDriveNumber( const TInt aDriveNumber ) |
|
189 { |
|
190 iDriveNumber = aDriveNumber; |
|
191 } |
|
192 |
|
193 // --------------------------------------------------------------------------- |
|
194 // CCmFillListItem::UpnpClass |
|
195 // --------------------------------------------------------------------------- |
|
196 // |
|
197 EXPORT_C TDesC& CCmFillListItem::UpnpClass() const |
|
198 { |
|
199 return *iUpnpClass; |
|
200 } |
|
201 |
|
202 // --------------------------------------------------------------------------- |
|
203 // CCmFillListItem::Uri |
|
204 // --------------------------------------------------------------------------- |
|
205 // |
|
206 EXPORT_C TDesC8& CCmFillListItem::Uri() const |
|
207 { |
|
208 return *iUri; |
|
209 } |
|
210 |
|
211 // --------------------------------------------------------------------------- |
|
212 // CCmFillListItem::ItemId |
|
213 // --------------------------------------------------------------------------- |
|
214 // |
|
215 EXPORT_C TDesC8& CCmFillListItem::ItemId() const |
|
216 { |
|
217 return *iItemId; |
|
218 } |
|
219 |
|
220 // --------------------------------------------------------------------------- |
|
221 // CCmFillListItem::ListId |
|
222 // --------------------------------------------------------------------------- |
|
223 // |
|
224 EXPORT_C TUint CCmFillListItem::ListId() const |
|
225 { |
|
226 return iListId; |
|
227 } |
|
228 |
|
229 // --------------------------------------------------------------------------- |
|
230 // CCmFillListItem::DevId |
|
231 // --------------------------------------------------------------------------- |
|
232 // |
|
233 EXPORT_C TUint8 CCmFillListItem::DevId() const |
|
234 { |
|
235 return iDevId; |
|
236 } |
|
237 |
|
238 // --------------------------------------------------------------------------- |
|
239 // CCmFillListItem::Priority |
|
240 // --------------------------------------------------------------------------- |
|
241 // |
|
242 EXPORT_C TUint8 CCmFillListItem::Priority() const |
|
243 { |
|
244 return iPriority; |
|
245 } |
|
246 |
|
247 // --------------------------------------------------------------------------- |
|
248 // CCmFillListItem::Selected |
|
249 // --------------------------------------------------------------------------- |
|
250 // |
|
251 EXPORT_C TCmFillRuleStatus CCmFillListItem::Selected() const |
|
252 { |
|
253 return iSelected; |
|
254 } |
|
255 |
|
256 // --------------------------------------------------------------------------- |
|
257 // CCmFillListItem::DriveId |
|
258 // --------------------------------------------------------------------------- |
|
259 // |
|
260 EXPORT_C TUint CCmFillListItem::DriveId() const |
|
261 { |
|
262 return iDriveId; |
|
263 } |
|
264 |
|
265 // --------------------------------------------------------------------------- |
|
266 // CCmFillListItem::DriveNumber |
|
267 // --------------------------------------------------------------------------- |
|
268 // |
|
269 EXPORT_C TInt CCmFillListItem::DriveNumber() const |
|
270 { |
|
271 return iDriveNumber; |
|
272 } |
|
273 |
|
274 // --------------------------------------------------------------------------- |
|
275 // CCmFillListItem::ExternalizeL |
|
276 // --------------------------------------------------------------------------- |
|
277 // |
|
278 EXPORT_C void CCmFillListItem::ExternalizeL( RWriteStream& aStream ) const |
|
279 { |
|
280 aStream.WriteInt32L( iUpnpClass->Length() ); |
|
281 if ( iUpnpClass ) |
|
282 { |
|
283 aStream << *iUpnpClass; |
|
284 } |
|
285 else |
|
286 { |
|
287 aStream << KNullDesC(); |
|
288 } |
|
289 aStream.WriteInt32L( iUri->Length() ); |
|
290 if ( iUri ) |
|
291 { |
|
292 aStream << *iUri; |
|
293 } |
|
294 else |
|
295 { |
|
296 aStream << KNullDesC(); |
|
297 } |
|
298 aStream.WriteInt32L( iItemId->Length() ); |
|
299 if ( iItemId ) |
|
300 { |
|
301 aStream << *iItemId; |
|
302 } |
|
303 else |
|
304 { |
|
305 aStream << KNullDesC(); |
|
306 } |
|
307 |
|
308 aStream.WriteUint16L( iListId ); |
|
309 aStream.WriteUint8L( iDevId ); |
|
310 aStream.WriteUint8L( iPriority ); |
|
311 aStream.WriteInt32L( iSelected ); |
|
312 aStream.WriteUint32L( iDriveId ); |
|
313 aStream.WriteInt32L( iDriveNumber ); |
|
314 CCmBaseListItem::ExternalizeL(aStream); |
|
315 } |
|
316 |
|
317 // --------------------------------------------------------------------------- |
|
318 // CCmFillListItem::InternalizeL |
|
319 // --------------------------------------------------------------------------- |
|
320 // |
|
321 EXPORT_C void CCmFillListItem::InternalizeL( RReadStream& aStream ) |
|
322 { |
|
323 // Content |
|
324 if ( iUpnpClass ) |
|
325 { |
|
326 delete iUpnpClass; |
|
327 iUpnpClass = NULL; |
|
328 } |
|
329 TInt bufLength = aStream.ReadInt32L(); |
|
330 iUpnpClass = HBufC::NewL( aStream, bufLength ); |
|
331 if ( iUri ) |
|
332 { |
|
333 delete iUri; |
|
334 iUri = NULL; |
|
335 } |
|
336 bufLength = aStream.ReadInt32L(); |
|
337 iUri = HBufC8::NewL( aStream, bufLength ); |
|
338 if ( iItemId ) |
|
339 { |
|
340 delete iItemId; |
|
341 iItemId = NULL; |
|
342 } |
|
343 bufLength = aStream.ReadInt32L(); |
|
344 iItemId = HBufC8::NewL( aStream, bufLength ); |
|
345 iListId = aStream.ReadUint16L(); |
|
346 iDevId = aStream.ReadUint8L(); |
|
347 iPriority = aStream.ReadUint8L(); |
|
348 iSelected = (TCmFillRuleStatus)aStream.ReadInt32L(); |
|
349 iDriveId = aStream.ReadUint32L(); |
|
350 iDriveNumber = aStream.ReadInt32L(); |
|
351 CCmBaseListItem::InternalizeL(aStream); |
|
352 } |
|
353 |
|
354 // --------------------------------------------------------------------------- |
|
355 // Default constructor |
|
356 // --------------------------------------------------------------------------- |
|
357 // |
|
358 CCmFillListItem::CCmFillListItem() |
|
359 { |
|
360 } |
|
361 |
|
362 // --------------------------------------------------------------------------- |
|
363 // ConstructL |
|
364 // --------------------------------------------------------------------------- |
|
365 // |
|
366 void CCmFillListItem::ConstructL() |
|
367 { |
|
368 // construct base class |
|
369 CCmBaseListItem::ConstructL(); |
|
370 |
|
371 // then construct the rest |
|
372 iUpnpClass = KNullDesC().AllocL(); |
|
373 iUri = KNullDesC8().AllocL(); |
|
374 iItemId = KNullDesC8().AllocL(); |
|
375 } |
|
376 |
|
377 // --------------------------------------------------------------------------- |
|
378 // ConstructL with parameters |
|
379 // --------------------------------------------------------------------------- |
|
380 // |
|
381 void CCmFillListItem::ConstructL( const TUint aPriority, const TUint aListId, |
|
382 const TUint aStatus, const TCmFillRuleStatus aSelected ) |
|
383 { |
|
384 // construct base class |
|
385 CCmBaseListItem::ConstructL(); |
|
386 |
|
387 SetPriority( aPriority ); |
|
388 SetListId( aListId ); |
|
389 SetStatus( (TCmListItemStatus)aStatus ); |
|
390 SetSelected( aSelected ); |
|
391 iUpnpClass = KNullDesC().AllocL(); |
|
392 iUri = KNullDesC8().AllocL(); |
|
393 iItemId = KNullDesC8().AllocL(); |
|
394 } |
|
395 |
|
396 // End of file |
|
397 |
|