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: Class for encapsulating the data source for objects. |
|
15 * |
|
16 */ |
|
17 |
|
18 #include <fbs.h> |
|
19 |
|
20 #include "thumbnailobjectsource.h" |
|
21 |
|
22 |
|
23 // ======== MEMBER FUNCTIONS ======== |
|
24 |
|
25 // --------------------------------------------------------------------------- |
|
26 // CThumbnailObjectSource::NewL() |
|
27 // CThumbnailObjectSource::NewLC() |
|
28 // Two-phased constructor. |
|
29 // --------------------------------------------------------------------------- |
|
30 // |
|
31 EXPORT_C CThumbnailObjectSource* CThumbnailObjectSource::NewL( const TDesC& |
|
32 aUri, const TDesC& aMimeType ) |
|
33 { |
|
34 CThumbnailObjectSource* self = CThumbnailObjectSource::NewLC( aUri, |
|
35 aMimeType ); |
|
36 CleanupStack::Pop( self ); |
|
37 return self; |
|
38 } |
|
39 |
|
40 EXPORT_C CThumbnailObjectSource* CThumbnailObjectSource::NewLC( const TDesC& |
|
41 aUri, const TDesC& aMimeType ) |
|
42 { |
|
43 CThumbnailObjectSource* self = new( ELeave )CThumbnailObjectSource(); |
|
44 CleanupStack::PushL( self ); |
|
45 self->ConstructL( aUri, aMimeType ); |
|
46 return self; |
|
47 } |
|
48 |
|
49 EXPORT_C CThumbnailObjectSource* CThumbnailObjectSource::NewL( const RFile64& |
|
50 aFile, const TDesC& aMimeType ) |
|
51 { |
|
52 CThumbnailObjectSource* self = CThumbnailObjectSource::NewLC( aFile, |
|
53 aMimeType ); |
|
54 CleanupStack::Pop( self ); |
|
55 return self; |
|
56 } |
|
57 |
|
58 EXPORT_C CThumbnailObjectSource* CThumbnailObjectSource::NewLC( const RFile64& |
|
59 aFile, const TDesC& aMimeType ) |
|
60 { |
|
61 CThumbnailObjectSource* self = new( ELeave )CThumbnailObjectSource(); |
|
62 CleanupStack::PushL( self ); |
|
63 self->ConstructL( aFile, aMimeType ); |
|
64 return self; |
|
65 } |
|
66 |
|
67 EXPORT_C CThumbnailObjectSource* CThumbnailObjectSource::NewL( CFbsBitmap* aBitmap, |
|
68 const TDesC& aUri ) |
|
69 { |
|
70 CThumbnailObjectSource* self = CThumbnailObjectSource::NewLC( aBitmap, aUri ); |
|
71 CleanupStack::Pop( self ); |
|
72 return self; |
|
73 } |
|
74 |
|
75 EXPORT_C CThumbnailObjectSource* CThumbnailObjectSource::NewLC( CFbsBitmap* aBitmap, |
|
76 const TDesC& aUri ) |
|
77 { |
|
78 CThumbnailObjectSource* self = new( ELeave )CThumbnailObjectSource(); |
|
79 CleanupStack::PushL( self ); |
|
80 self->ConstructL( aBitmap, aUri ); |
|
81 return self; |
|
82 } |
|
83 |
|
84 EXPORT_C CThumbnailObjectSource* CThumbnailObjectSource::NewL( TDesC8* aBuffer, |
|
85 TDesC& aMimeType, const TDesC& aUri) |
|
86 { |
|
87 CThumbnailObjectSource* self = CThumbnailObjectSource::NewLC( aBuffer, |
|
88 aMimeType, aUri ); |
|
89 CleanupStack::Pop( self ); |
|
90 return self; |
|
91 } |
|
92 |
|
93 EXPORT_C CThumbnailObjectSource* CThumbnailObjectSource::NewLC( TDesC8* aBuffer, |
|
94 TDesC& aMimeType, const TDesC& aUri) |
|
95 { |
|
96 CThumbnailObjectSource* self = new( ELeave )CThumbnailObjectSource(); |
|
97 CleanupStack::PushL( self ); |
|
98 self->ConstructL( aBuffer, aMimeType, aUri ); |
|
99 return self; |
|
100 } |
|
101 |
|
102 EXPORT_C CThumbnailObjectSource* CThumbnailObjectSource::NewL( const TDesC& |
|
103 aUri, const TThumbnailId aThumbnailId, const TDesC& aMimeType ) |
|
104 { |
|
105 CThumbnailObjectSource* self = CThumbnailObjectSource::NewLC( aUri, |
|
106 aThumbnailId, aMimeType ); |
|
107 CleanupStack::Pop( self ); |
|
108 return self; |
|
109 } |
|
110 |
|
111 EXPORT_C CThumbnailObjectSource* CThumbnailObjectSource::NewLC( const TDesC& aUri, |
|
112 const TThumbnailId aThumbnailId, const TDesC& aMimeType ) |
|
113 { |
|
114 CThumbnailObjectSource* self = new( ELeave )CThumbnailObjectSource(); |
|
115 CleanupStack::PushL( self ); |
|
116 self->ConstructL( aUri, aMimeType, aThumbnailId ); |
|
117 return self; |
|
118 } |
|
119 |
|
120 EXPORT_C CThumbnailObjectSource* CThumbnailObjectSource::NewL( const TDesC& aUri, |
|
121 const TDesC& aTargetUri, const TDesC& aMimeType ) |
|
122 { |
|
123 CThumbnailObjectSource* self = CThumbnailObjectSource::NewLC( aUri, aTargetUri, |
|
124 aMimeType ); |
|
125 CleanupStack::Pop( self ); |
|
126 return self; |
|
127 } |
|
128 |
|
129 EXPORT_C CThumbnailObjectSource* CThumbnailObjectSource::NewLC( const TDesC& aUri, |
|
130 const TDesC& aTargetUri, const TDesC& aMimeType ) |
|
131 { |
|
132 CThumbnailObjectSource* self = new( ELeave )CThumbnailObjectSource(); |
|
133 CleanupStack::PushL( self ); |
|
134 self->ConstructL( aUri, aTargetUri, aMimeType ); |
|
135 return self; |
|
136 } |
|
137 |
|
138 |
|
139 // --------------------------------------------------------------------------- |
|
140 // CThumbnailObjectSource::CThumbnailObjectSource() |
|
141 // C++ default constructor can NOT contain any code, that might leave. |
|
142 // --------------------------------------------------------------------------- |
|
143 // |
|
144 CThumbnailObjectSource::CThumbnailObjectSource() |
|
145 { |
|
146 // No implementation required |
|
147 } |
|
148 |
|
149 |
|
150 // --------------------------------------------------------------------------- |
|
151 // CThumbnailObjectSource::ConstructL() |
|
152 // Symbian 2nd phase constructor can leave. |
|
153 // --------------------------------------------------------------------------- |
|
154 // |
|
155 void CThumbnailObjectSource::ConstructL( const TDesC& aUri, const TDesC& |
|
156 aMimeType) |
|
157 { |
|
158 iUri = aUri.AllocL(); |
|
159 iMimeType = HBufC8::NewL( aMimeType.Length() ); |
|
160 iMimeType->Des().Copy( aMimeType ); |
|
161 iThumbnailId = 0; |
|
162 iBitmap = NULL; |
|
163 iTargetUri = NULL; |
|
164 } |
|
165 |
|
166 void CThumbnailObjectSource::ConstructL( const RFile64& aFile, const TDesC& |
|
167 aMimeType ) |
|
168 { |
|
169 iFile = aFile; |
|
170 iMimeType = HBufC8::NewL( aMimeType.Length() ); |
|
171 iMimeType->Des().Copy( aMimeType ); |
|
172 iThumbnailId = 0; |
|
173 iBitmap = NULL; |
|
174 iTargetUri = NULL; |
|
175 } |
|
176 |
|
177 void CThumbnailObjectSource::ConstructL( CFbsBitmap* aBitmap, const TDesC& |
|
178 aUri ) |
|
179 { |
|
180 iBitmap = aBitmap; |
|
181 iUri = aUri.AllocL(); |
|
182 iThumbnailId = 0; |
|
183 iTargetUri = NULL; |
|
184 } |
|
185 |
|
186 void CThumbnailObjectSource::ConstructL( TDesC8* aBuffer, const TDesC& |
|
187 aMimeType, const TDesC& aUri ) |
|
188 { |
|
189 iBuffer = aBuffer; |
|
190 iMimeType = HBufC8::NewL( aMimeType.Length() ); |
|
191 iMimeType->Des().Copy( aMimeType ); |
|
192 iUri = aUri.AllocL(); |
|
193 iThumbnailId = 0; |
|
194 iBitmap = NULL; |
|
195 iTargetUri = NULL; |
|
196 } |
|
197 |
|
198 void CThumbnailObjectSource::ConstructL( const TDesC& aUri, const TDesC& |
|
199 aMimeType, TThumbnailId aThumbnailId ) |
|
200 { |
|
201 iUri = aUri.AllocL(); |
|
202 iMimeType = HBufC8::NewL( aMimeType.Length() ); |
|
203 iMimeType->Des().Copy( aMimeType ); |
|
204 iThumbnailId = aThumbnailId; |
|
205 iTargetUri = NULL; |
|
206 } |
|
207 |
|
208 void CThumbnailObjectSource::ConstructL( const TDesC& aUri, const TDesC& |
|
209 aTargetUri, const TDesC& aMimeType ) |
|
210 { |
|
211 iUri = aUri.AllocL(); |
|
212 iTargetUri = aTargetUri.AllocL(); |
|
213 iMimeType = HBufC8::NewL( aMimeType.Length() ); |
|
214 iMimeType->Des().Copy( aMimeType ); |
|
215 iThumbnailId = 0; |
|
216 iBitmap = NULL; |
|
217 } |
|
218 |
|
219 |
|
220 // --------------------------------------------------------------------------- |
|
221 // CThumbnailObjectSource::~CThumbnailObjectSource()() |
|
222 // Destructor. |
|
223 // --------------------------------------------------------------------------- |
|
224 // |
|
225 CThumbnailObjectSource::~CThumbnailObjectSource() |
|
226 { |
|
227 delete iUri; |
|
228 iUri = NULL; |
|
229 delete iMimeType; |
|
230 iMimeType = NULL; |
|
231 delete iBuffer; |
|
232 iBuffer = NULL; |
|
233 delete iBitmap; |
|
234 iBitmap = NULL; |
|
235 } |
|
236 |
|
237 |
|
238 // --------------------------------------------------------------------------- |
|
239 // CThumbnailObjectSourceImpl::FileHandle() |
|
240 // --------------------------------------------------------------------------- |
|
241 // |
|
242 EXPORT_C RFile64& CThumbnailObjectSource::FileHandle() |
|
243 { |
|
244 return iFile; |
|
245 } |
|
246 |
|
247 // --------------------------------------------------------------------------- |
|
248 // CThumbnailObjectSourceImpl::Uri() |
|
249 // --------------------------------------------------------------------------- |
|
250 // |
|
251 EXPORT_C const TDesC& CThumbnailObjectSource::Uri() |
|
252 { |
|
253 if ( iUri ) |
|
254 { |
|
255 return * iUri; |
|
256 } |
|
257 return KNullDesC; |
|
258 } |
|
259 |
|
260 // --------------------------------------------------------------------------- |
|
261 // CThumbnailObjectSourceImpl::Buffer() |
|
262 // --------------------------------------------------------------------------- |
|
263 // |
|
264 EXPORT_C TDesC8* CThumbnailObjectSource::Buffer() |
|
265 { |
|
266 return iBuffer; |
|
267 } |
|
268 |
|
269 // --------------------------------------------------------------------------- |
|
270 // CThumbnailObjectSourceImpl::GetBufferOwnership() |
|
271 // --------------------------------------------------------------------------- |
|
272 // |
|
273 EXPORT_C TDesC8* CThumbnailObjectSource::GetBufferOwnership() |
|
274 { |
|
275 TDesC8* temp = iBuffer; |
|
276 iBuffer = NULL; |
|
277 return temp; |
|
278 } |
|
279 |
|
280 // --------------------------------------------------------------------------- |
|
281 // CThumbnailObjectSourceImpl::aMimeType() |
|
282 // --------------------------------------------------------------------------- |
|
283 // |
|
284 EXPORT_C const TDesC8& CThumbnailObjectSource::MimeType() |
|
285 { |
|
286 if ( iMimeType ) |
|
287 { |
|
288 return *iMimeType; |
|
289 } |
|
290 return KNullDesC8; |
|
291 } |
|
292 |
|
293 // --------------------------------------------------------------------------- |
|
294 // CThumbnailObjectSourceImpl::Id() |
|
295 // --------------------------------------------------------------------------- |
|
296 // |
|
297 EXPORT_C TThumbnailId CThumbnailObjectSource::Id() |
|
298 { |
|
299 return iThumbnailId; |
|
300 } |
|
301 |
|
302 // --------------------------------------------------------------------------- |
|
303 // CThumbnailObjectSourceImpl::Bitmap() |
|
304 // --------------------------------------------------------------------------- |
|
305 // |
|
306 EXPORT_C CFbsBitmap* CThumbnailObjectSource::Bitmap() |
|
307 { |
|
308 return iBitmap; |
|
309 } |
|
310 |
|
311 // --------------------------------------------------------------------------- |
|
312 // CThumbnailObjectSourceImpl::GetBitmapOwnership() |
|
313 // --------------------------------------------------------------------------- |
|
314 // |
|
315 EXPORT_C CFbsBitmap* CThumbnailObjectSource::GetBitmapOwnership() |
|
316 { |
|
317 CFbsBitmap* temp = iBitmap; |
|
318 iBitmap = NULL; |
|
319 return temp; |
|
320 } |
|
321 |
|
322 // --------------------------------------------------------------------------- |
|
323 // CThumbnailObjectSourceImpl::TargetUri() |
|
324 // --------------------------------------------------------------------------- |
|
325 // |
|
326 EXPORT_C const TDesC& CThumbnailObjectSource::TargetUri() |
|
327 { |
|
328 if ( iTargetUri ) |
|
329 { |
|
330 return * iTargetUri; |
|
331 } |
|
332 return KNullDesC; |
|
333 } |
|
334 |
|
335 |
|
336 // End of file |
|