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 and store file lists |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 |
|
21 |
|
22 |
|
23 #include <e32std.h> |
|
24 #include <s32mem.h> |
|
25 #include "cmbaselistitem.h" |
|
26 #include "msdebug.h" |
|
27 |
|
28 // ======== LOCAL FUNCTIONS ======== |
|
29 // --------------------------------------------------------------------------- |
|
30 // NewL |
|
31 // --------------------------------------------------------------------------- |
|
32 // |
|
33 EXPORT_C CCmBaseListItem* CCmBaseListItem::NewL() |
|
34 { |
|
35 CCmBaseListItem* self = CCmBaseListItem::NewLC(); |
|
36 CleanupStack::Pop( self ); |
|
37 return self; |
|
38 } |
|
39 |
|
40 // --------------------------------------------------------------------------- |
|
41 // NewLC |
|
42 // --------------------------------------------------------------------------- |
|
43 // |
|
44 EXPORT_C CCmBaseListItem* CCmBaseListItem::NewLC() |
|
45 { |
|
46 CCmBaseListItem* self = new ( ELeave ) CCmBaseListItem(); |
|
47 CleanupStack::PushL( self ); |
|
48 self->ConstructL(); |
|
49 return self; |
|
50 } |
|
51 |
|
52 // --------------------------------------------------------------------------- |
|
53 // Destructor |
|
54 // --------------------------------------------------------------------------- |
|
55 // |
|
56 EXPORT_C CCmBaseListItem::~CCmBaseListItem() |
|
57 { |
|
58 delete iPrimaryText; |
|
59 delete iSecondaryText; |
|
60 delete iPath; |
|
61 } |
|
62 |
|
63 |
|
64 // --------------------------------------------------------------------------- |
|
65 // CCmBaseListItem::SetPrimaryTextL |
|
66 // --------------------------------------------------------------------------- |
|
67 // |
|
68 EXPORT_C void CCmBaseListItem::SetPrimaryTextL( const TDesC& aText ) |
|
69 { |
|
70 if( &aText ) |
|
71 { |
|
72 delete iPrimaryText; |
|
73 iPrimaryText = NULL; |
|
74 iPrimaryText = aText.AllocL(); |
|
75 } |
|
76 else |
|
77 { |
|
78 delete iPrimaryText; |
|
79 iPrimaryText = NULL; |
|
80 iPrimaryText = KNullDesC().AllocL(); |
|
81 } |
|
82 } |
|
83 |
|
84 // --------------------------------------------------------------------------- |
|
85 // CCmBaseListItem::SetSecondaryTextL |
|
86 // --------------------------------------------------------------------------- |
|
87 // |
|
88 EXPORT_C void CCmBaseListItem::SetSecondaryTextL( const TDesC& aText ) |
|
89 { |
|
90 if( &aText ) |
|
91 { |
|
92 delete iSecondaryText; |
|
93 iSecondaryText = NULL; |
|
94 iSecondaryText = aText.AllocL(); |
|
95 } |
|
96 else |
|
97 { |
|
98 delete iSecondaryText; |
|
99 iSecondaryText = NULL; |
|
100 iSecondaryText = KNullDesC().AllocL(); |
|
101 } |
|
102 } |
|
103 |
|
104 // --------------------------------------------------------------------------- |
|
105 // CCmBaseListItem::SetPathL |
|
106 // --------------------------------------------------------------------------- |
|
107 // |
|
108 EXPORT_C void CCmBaseListItem::SetPathL( const TDesC& aText ) |
|
109 { |
|
110 if( &aText ) |
|
111 { |
|
112 delete iPath; |
|
113 iPath = NULL; |
|
114 iPath = aText.AllocL(); |
|
115 } |
|
116 else |
|
117 { |
|
118 delete iPath; |
|
119 iPath = NULL; |
|
120 iPath = KNullDesC().AllocL(); |
|
121 } |
|
122 } |
|
123 |
|
124 // --------------------------------------------------------------------------- |
|
125 // CCmBaseListItem::SetSize |
|
126 // --------------------------------------------------------------------------- |
|
127 // |
|
128 EXPORT_C void CCmBaseListItem::SetSize( const TUint32 aSize ) |
|
129 { |
|
130 iSize = aSize; |
|
131 } |
|
132 |
|
133 // --------------------------------------------------------------------------- |
|
134 // CCmBaseListItem::SetDate |
|
135 // --------------------------------------------------------------------------- |
|
136 // |
|
137 EXPORT_C void CCmBaseListItem::SetDate( const TTime aDate ) |
|
138 { |
|
139 iDate = aDate; |
|
140 } |
|
141 |
|
142 // --------------------------------------------------------------------------- |
|
143 // CCmBaseListItem::SetStatus |
|
144 // --------------------------------------------------------------------------- |
|
145 // |
|
146 EXPORT_C void CCmBaseListItem::SetStatus( const TCmListItemStatus aStatus ) |
|
147 { |
|
148 iStatus = aStatus; |
|
149 } |
|
150 |
|
151 // --------------------------------------------------------------------------- |
|
152 // CCmBaseListItem::SetDbId |
|
153 // --------------------------------------------------------------------------- |
|
154 // |
|
155 EXPORT_C void CCmBaseListItem::SetDbId( const TUint64 aId ) |
|
156 { |
|
157 iId = aId; |
|
158 } |
|
159 |
|
160 // --------------------------------------------------------------------------- |
|
161 // CCmBaseListItem::SetRefId |
|
162 // --------------------------------------------------------------------------- |
|
163 // |
|
164 EXPORT_C void CCmBaseListItem::SetRefId( const TUint64 aId ) |
|
165 { |
|
166 iRefId = aId; |
|
167 } |
|
168 |
|
169 // --------------------------------------------------------------------------- |
|
170 // CCmBaseListItem::SetMediaType |
|
171 // --------------------------------------------------------------------------- |
|
172 // |
|
173 EXPORT_C void CCmBaseListItem::SetMediaType( const TCmMediaType aMediaType ) |
|
174 { |
|
175 iMediaType = aMediaType; |
|
176 } |
|
177 |
|
178 |
|
179 // --------------------------------------------------------------------------- |
|
180 // CCmBaseListItem::PrimaryText |
|
181 // --------------------------------------------------------------------------- |
|
182 // |
|
183 EXPORT_C TDesC& CCmBaseListItem::PrimaryText() const |
|
184 { |
|
185 return *iPrimaryText; |
|
186 } |
|
187 |
|
188 // --------------------------------------------------------------------------- |
|
189 // CCmBaseListItem::SecondaryText |
|
190 // --------------------------------------------------------------------------- |
|
191 // |
|
192 EXPORT_C TDesC& CCmBaseListItem::SecondaryText() const |
|
193 { |
|
194 return *iSecondaryText; |
|
195 } |
|
196 |
|
197 // --------------------------------------------------------------------------- |
|
198 // CCmBaseListItem::Path |
|
199 // --------------------------------------------------------------------------- |
|
200 // |
|
201 EXPORT_C TDesC& CCmBaseListItem::Path() const |
|
202 { |
|
203 return *iPath; |
|
204 } |
|
205 |
|
206 // --------------------------------------------------------------------------- |
|
207 // CCmBaseListItem::Size |
|
208 // --------------------------------------------------------------------------- |
|
209 // |
|
210 EXPORT_C TUint32 CCmBaseListItem::Size() const |
|
211 { |
|
212 return iSize; |
|
213 } |
|
214 |
|
215 // --------------------------------------------------------------------------- |
|
216 // CCmBaseListItem::Date |
|
217 // --------------------------------------------------------------------------- |
|
218 // |
|
219 EXPORT_C TTime CCmBaseListItem::Date() const |
|
220 { |
|
221 return iDate; |
|
222 } |
|
223 |
|
224 // --------------------------------------------------------------------------- |
|
225 // CCmBaseListItem::Status |
|
226 // --------------------------------------------------------------------------- |
|
227 // |
|
228 EXPORT_C TCmListItemStatus CCmBaseListItem::Status() const |
|
229 { |
|
230 return iStatus; |
|
231 } |
|
232 |
|
233 // --------------------------------------------------------------------------- |
|
234 // CCmBaseListItem::DbId |
|
235 // --------------------------------------------------------------------------- |
|
236 // |
|
237 EXPORT_C TUint64 CCmBaseListItem::DbId() const |
|
238 { |
|
239 return iId; |
|
240 } |
|
241 |
|
242 // --------------------------------------------------------------------------- |
|
243 // CCmBaseListItem::RefId |
|
244 // --------------------------------------------------------------------------- |
|
245 // |
|
246 EXPORT_C TUint64 CCmBaseListItem::RefId() const |
|
247 { |
|
248 return iRefId; |
|
249 } |
|
250 |
|
251 // --------------------------------------------------------------------------- |
|
252 // CCmBaseListItem::MediaType |
|
253 // --------------------------------------------------------------------------- |
|
254 // |
|
255 EXPORT_C TCmMediaType CCmBaseListItem::MediaType() const |
|
256 { |
|
257 return iMediaType; |
|
258 } |
|
259 |
|
260 // --------------------------------------------------------------------------- |
|
261 // CCmBaseListItem::ExternalizeL |
|
262 // --------------------------------------------------------------------------- |
|
263 // |
|
264 EXPORT_C void CCmBaseListItem::ExternalizeL( RWriteStream& aStream ) const |
|
265 { |
|
266 aStream.WriteInt32L( iPrimaryText->Length() ); |
|
267 if ( iPrimaryText ) |
|
268 { |
|
269 aStream << *iPrimaryText; |
|
270 } |
|
271 else |
|
272 { |
|
273 aStream << KNullDesC(); |
|
274 } |
|
275 aStream.WriteInt32L( iSecondaryText->Length() ); |
|
276 if ( iSecondaryText ) |
|
277 { |
|
278 aStream << *iSecondaryText; |
|
279 } |
|
280 else |
|
281 { |
|
282 aStream << KNullDesC(); |
|
283 } |
|
284 |
|
285 aStream.WriteInt32L( iPath->Length() ); |
|
286 if ( iPath ) |
|
287 { |
|
288 aStream << *iPath; |
|
289 } |
|
290 else |
|
291 { |
|
292 aStream << KNullDesC(); |
|
293 } |
|
294 |
|
295 aStream.WriteInt32L( iSize ); |
|
296 aStream.WriteUint32L( iDate.Int64() ); |
|
297 aStream.WriteInt32L( iStatus ); |
|
298 aStream.WriteUint32L( iId ); |
|
299 aStream.WriteUint32L( iRefId ); |
|
300 aStream.WriteInt32L( iMediaType ); |
|
301 } |
|
302 |
|
303 // --------------------------------------------------------------------------- |
|
304 // CCmBaseListItem::InternalizeL |
|
305 // --------------------------------------------------------------------------- |
|
306 // |
|
307 EXPORT_C void CCmBaseListItem::InternalizeL( RReadStream& aStream ) |
|
308 { |
|
309 // Content |
|
310 delete iPrimaryText; |
|
311 iPrimaryText = NULL; |
|
312 |
|
313 TInt bufLength = aStream.ReadInt32L(); |
|
314 iPrimaryText = HBufC::NewL( aStream, bufLength ); |
|
315 |
|
316 delete iSecondaryText; |
|
317 iSecondaryText = NULL; |
|
318 |
|
319 bufLength = aStream.ReadInt32L(); |
|
320 iSecondaryText = HBufC::NewL( aStream, bufLength ); |
|
321 |
|
322 delete iPath; |
|
323 iPath = NULL; |
|
324 |
|
325 bufLength = aStream.ReadInt32L(); |
|
326 iPath = HBufC::NewL( aStream, bufLength ); |
|
327 iSize = aStream.ReadInt32L(); |
|
328 iDate = aStream.ReadUint32L(); |
|
329 iStatus = (TCmListItemStatus)aStream.ReadInt32L(); |
|
330 iId = aStream.ReadUint32L(); |
|
331 iRefId = aStream.ReadUint32L(); |
|
332 iMediaType = static_cast<TCmMediaType>( aStream.ReadInt32L() ); |
|
333 } |
|
334 |
|
335 // --------------------------------------------------------------------------- |
|
336 // Default constructor |
|
337 // --------------------------------------------------------------------------- |
|
338 // |
|
339 CCmBaseListItem::CCmBaseListItem() |
|
340 { |
|
341 } |
|
342 |
|
343 // --------------------------------------------------------------------------- |
|
344 // ConstructL |
|
345 // --------------------------------------------------------------------------- |
|
346 // |
|
347 void CCmBaseListItem::ConstructL() |
|
348 { |
|
349 iPrimaryText = KNullDesC().AllocL(); |
|
350 iSecondaryText = KNullDesC().AllocL(); |
|
351 iPath = KNullDesC().AllocL(); |
|
352 } |
|
353 |
|
354 // End of file |
|
355 |
|