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 handling central repositoty data |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #include <centralrepository.h> |
|
20 #include <thumbnailmanager.h> |
|
21 |
|
22 #include "thumbnailcenrep.h" |
|
23 |
|
24 |
|
25 #define THUMBNAIL_CENREP_UID 0x102830B0 |
|
26 |
|
27 const TUint32 KSizeImageGridWidth = 0x0; |
|
28 const TUint32 KSizeImageGridHeight = 0x1; |
|
29 const TUint32 KSizeImageListWidth = 0x2; |
|
30 const TUint32 KSizeImageListHeight = 0x3; |
|
31 const TUint32 KSizeImageFullscreenWidth = 0x4; |
|
32 const TUint32 KSizeImageFullscreenHeight = 0x5; |
|
33 const TUint32 KSizeVideoGridWidth = 0x6; |
|
34 const TUint32 KSizeVideoGridHeight = 0x7; |
|
35 const TUint32 KSizeVideoListWidth = 0x8; |
|
36 const TUint32 KSizeVideoListHeight = 0x9; |
|
37 const TUint32 KSizeVideoFullscreenWidth = 0x10; |
|
38 const TUint32 KSizeVideoFullscreenHeight = 0x11; |
|
39 const TUint32 KSizeAudioGridWidth = 0x12; |
|
40 const TUint32 KSizeAudioGridHeight = 0x13; |
|
41 const TUint32 KSizeAudioListWidth = 0x14; |
|
42 const TUint32 KSizeAudioListHeight = 0x15; |
|
43 const TUint32 KSizeAudioFullscreenWidth = 0x16; |
|
44 const TUint32 KSizeAudioFullscreenHeight = 0x17; |
|
45 const TUint32 KSizeContactListWidth = 0x18; |
|
46 const TUint32 KSizeContactListHeight = 0x19; |
|
47 const TUint32 KSizeContactGridWidth = 0x20; |
|
48 const TUint32 KSizeContactGridHeight = 0x21; |
|
49 const TUint32 KSizeContactFullscreenWidth = 0x22; |
|
50 const TUint32 KSizeContactFullscreenHeight = 0x23; |
|
51 |
|
52 const TUint32 KAutoCreateImageGrid = 0x100; |
|
53 const TUint32 KAutoCreateImageList = 0x101; |
|
54 const TUint32 KAutoCreateImageFullscreen = 0x102; |
|
55 const TUint32 KAutoCreateVideoGrid = 0x103; |
|
56 const TUint32 KAutoCreateVideoList = 0x104; |
|
57 const TUint32 KAutoCreateVideoFullscreen = 0x105; |
|
58 const TUint32 KAutoCreateAudioGrid = 0x106; |
|
59 const TUint32 KAutoCreateAudioList = 0x107; |
|
60 const TUint32 KAutoCreateAudioFullscreen = 0x108; |
|
61 const TUint32 KAutoCreateContactGrid = 0x109; |
|
62 const TUint32 KAutoCreateContactList = 0x110; |
|
63 const TUint32 KAutoCreateContactFullscreen = 0x111; |
|
64 |
|
65 |
|
66 // --------------------------------------------------------------------------- |
|
67 // TThumbnailPersistentSize::TThumbnailPersistentSize |
|
68 // --------------------------------------------------------------------------- |
|
69 // |
|
70 TThumbnailPersistentSize::TThumbnailPersistentSize( const TSize& aSize, TBool |
|
71 aCrop, TDisplayMode aMode, TInt aFormat ): iSize( aSize ), iCrop( aCrop ), |
|
72 iMode( aMode ), iFormat( aFormat ) |
|
73 { |
|
74 iType = EUnknownThumbnailSize; |
|
75 iSourceType = EUnknownSourceType; |
|
76 iAutoCreate = ETrue; |
|
77 } |
|
78 |
|
79 // --------------------------------------------------------------------------- |
|
80 // TThumbnailPersistentSize::TThumbnailPersistentSize |
|
81 // --------------------------------------------------------------------------- |
|
82 // |
|
83 TThumbnailPersistentSize::TThumbnailPersistentSize( TThumbnailSize aType, |
|
84 const TSize& aSize, TBool aCrop, TDisplayMode aMode, TInt aFormat, |
|
85 TBool aAutoCreate ) |
|
86 : iType( aType ), iSize( aSize ), iCrop( aCrop ), iMode( aMode ), |
|
87 iFormat( aFormat ), iAutoCreate( aAutoCreate ) |
|
88 { |
|
89 switch ( aType ) |
|
90 { |
|
91 case EImageGridThumbnailSize: |
|
92 case EImageListThumbnailSize: |
|
93 case EImageFullScreenThumbnailSize: |
|
94 iSourceType = EImage; |
|
95 break; |
|
96 case EVideoGridThumbnailSize: |
|
97 case EVideoListThumbnailSize: |
|
98 case EVideoFullScreenThumbnailSize: |
|
99 iSourceType = EVideo; |
|
100 break; |
|
101 case EAudioGridThumbnailSize: |
|
102 case EAudioListThumbnailSize: |
|
103 case EAudioFullScreenThumbnailSize: |
|
104 iSourceType = EAudio; |
|
105 break; |
|
106 case EContactGridThumbnailSize: |
|
107 case EContactListThumbnailSize: |
|
108 case EContactFullScreenThumbnailSize: |
|
109 iSourceType = EContact; |
|
110 break; |
|
111 default: |
|
112 iSourceType = EUnknownSourceType; |
|
113 } |
|
114 |
|
115 } |
|
116 |
|
117 // --------------------------------------------------------------------------- |
|
118 // TThumbnailAutoCreate::TThumbnailAutoCreate |
|
119 // --------------------------------------------------------------------------- |
|
120 // |
|
121 TThumbnailAutoCreate::TThumbnailAutoCreate() |
|
122 : iImageGrid(EFalse), iImageList(EFalse), iImageFullscreen(EFalse), |
|
123 iVideoGrid(EFalse), iVideoList(EFalse), iVideoFullscreen(EFalse), |
|
124 iAudioGrid(EFalse), iAudioList(EFalse), iAudioFullscreen(EFalse), |
|
125 iContactGrid(EFalse), iContactList(EFalse), iContactFullscreen(EFalse) |
|
126 { |
|
127 // No implementation required |
|
128 } |
|
129 |
|
130 // ======== MEMBER FUNCTIONS ======== |
|
131 |
|
132 // --------------------------------------------------------------------------- |
|
133 // CThumbnailCenRep::CThumbnailCenRep() |
|
134 // C++ default constructor can NOT contain any code, that might leave. |
|
135 // --------------------------------------------------------------------------- |
|
136 // |
|
137 CThumbnailCenRep::CThumbnailCenRep() |
|
138 { |
|
139 // No implementation required |
|
140 } |
|
141 |
|
142 |
|
143 // --------------------------------------------------------------------------- |
|
144 // CThumbnailCenRep::~CThumbnailCenRep() |
|
145 // Destructor. |
|
146 // --------------------------------------------------------------------------- |
|
147 // |
|
148 CThumbnailCenRep::~CThumbnailCenRep() |
|
149 { |
|
150 iPersistentSizes.Close(); |
|
151 delete iAutoCreate; |
|
152 delete iRepository; |
|
153 } |
|
154 |
|
155 // --------------------------------------------------------------------------- |
|
156 // CThumbnailCenRep::NewL() |
|
157 // Two-phased constructor. |
|
158 // --------------------------------------------------------------------------- |
|
159 // |
|
160 CThumbnailCenRep* CThumbnailCenRep::NewL() |
|
161 { |
|
162 CThumbnailCenRep* self = new( ELeave )CThumbnailCenRep(); |
|
163 CleanupStack::PushL( self ); |
|
164 self->ConstructL(); |
|
165 CleanupStack::Pop( self ); |
|
166 return self; |
|
167 } |
|
168 |
|
169 // --------------------------------------------------------------------------- |
|
170 // CThumbnailCenRep::ConstructL() |
|
171 // Returns id of specific task. |
|
172 // --------------------------------------------------------------------------- |
|
173 // |
|
174 void CThumbnailCenRep::ConstructL() |
|
175 { |
|
176 iRepository = CRepository::NewL( TUid::Uid( THUMBNAIL_CENREP_UID )); |
|
177 |
|
178 TInt xSize( 0 ); |
|
179 TInt ySize( 0 ); |
|
180 TBool flags( EFalse ); |
|
181 const TBool KGridAndListThumbnailCropped = ETrue; |
|
182 TInt raw_mode( EColor64K ); |
|
183 TInt format( 0 ); |
|
184 TBool autoCreate( EFalse ); |
|
185 |
|
186 User::LeaveIfError( iRepository->Get( KSizeImageGridWidth, xSize )); |
|
187 User::LeaveIfError( iRepository->Get( KSizeImageGridHeight, ySize )); |
|
188 User::LeaveIfError( iRepository->Get( KAutoCreateImageGrid, autoCreate )); |
|
189 |
|
190 iPersistentSizes.AppendL( TThumbnailPersistentSize( EImageGridThumbnailSize, TSize( xSize, ySize ), |
|
191 KGridAndListThumbnailCropped, static_cast <TDisplayMode> (raw_mode), format, autoCreate )); |
|
192 |
|
193 User::LeaveIfError( iRepository->Get( KSizeImageListWidth, xSize )); |
|
194 User::LeaveIfError( iRepository->Get( KSizeImageListHeight, ySize )); |
|
195 User::LeaveIfError( iRepository->Get( KAutoCreateImageList, autoCreate )); |
|
196 |
|
197 iPersistentSizes.AppendL( TThumbnailPersistentSize( EImageListThumbnailSize, TSize( xSize, ySize ), |
|
198 KGridAndListThumbnailCropped, static_cast <TDisplayMode> (raw_mode), format, autoCreate )); |
|
199 |
|
200 User::LeaveIfError( iRepository->Get( KSizeImageFullscreenWidth, xSize )); |
|
201 User::LeaveIfError( iRepository->Get( KSizeImageFullscreenHeight, ySize )); |
|
202 User::LeaveIfError( iRepository->Get( KAutoCreateImageFullscreen, autoCreate )); |
|
203 |
|
204 iPersistentSizes.AppendL( TThumbnailPersistentSize( EImageFullScreenThumbnailSize, TSize( xSize, ySize ), |
|
205 flags, static_cast <TDisplayMode> (raw_mode), format, autoCreate )); |
|
206 |
|
207 User::LeaveIfError( iRepository->Get( KSizeVideoGridWidth, xSize )); |
|
208 User::LeaveIfError( iRepository->Get( KSizeVideoGridHeight, ySize )); |
|
209 User::LeaveIfError( iRepository->Get( KAutoCreateVideoGrid, autoCreate )); |
|
210 |
|
211 iPersistentSizes.AppendL( TThumbnailPersistentSize( EVideoGridThumbnailSize, TSize( xSize, ySize ), |
|
212 KGridAndListThumbnailCropped, static_cast <TDisplayMode> (raw_mode), format, autoCreate )); |
|
213 |
|
214 User::LeaveIfError( iRepository->Get( KSizeVideoListWidth, xSize )); |
|
215 User::LeaveIfError( iRepository->Get( KSizeVideoListHeight, ySize )); |
|
216 User::LeaveIfError( iRepository->Get( KAutoCreateVideoList, autoCreate )); |
|
217 |
|
218 iPersistentSizes.AppendL( TThumbnailPersistentSize( EVideoListThumbnailSize, TSize( xSize, ySize ), |
|
219 KGridAndListThumbnailCropped, static_cast <TDisplayMode> (raw_mode), format, autoCreate )); |
|
220 |
|
221 User::LeaveIfError( iRepository->Get( KSizeVideoFullscreenWidth, xSize )); |
|
222 User::LeaveIfError( iRepository->Get( KSizeVideoFullscreenHeight, ySize )); |
|
223 User::LeaveIfError( iRepository->Get( KAutoCreateVideoFullscreen, autoCreate )); |
|
224 |
|
225 iPersistentSizes.AppendL( TThumbnailPersistentSize( EVideoFullScreenThumbnailSize, TSize( xSize, ySize ), |
|
226 flags, static_cast <TDisplayMode> (raw_mode), format, autoCreate )); |
|
227 |
|
228 User::LeaveIfError( iRepository->Get( KSizeAudioGridWidth, xSize )); |
|
229 User::LeaveIfError( iRepository->Get( KSizeAudioGridHeight, ySize )); |
|
230 User::LeaveIfError( iRepository->Get( KAutoCreateAudioGrid, autoCreate )); |
|
231 |
|
232 iPersistentSizes.AppendL( TThumbnailPersistentSize( EAudioGridThumbnailSize, TSize( xSize, ySize ), |
|
233 KGridAndListThumbnailCropped, static_cast <TDisplayMode> (raw_mode), format, autoCreate )); |
|
234 |
|
235 User::LeaveIfError( iRepository->Get( KSizeAudioListWidth, xSize )); |
|
236 User::LeaveIfError( iRepository->Get( KSizeAudioListHeight, ySize )); |
|
237 User::LeaveIfError( iRepository->Get( KAutoCreateAudioList, autoCreate )); |
|
238 |
|
239 iPersistentSizes.AppendL( TThumbnailPersistentSize( EAudioListThumbnailSize, TSize( xSize, ySize ), |
|
240 KGridAndListThumbnailCropped, static_cast <TDisplayMode> (raw_mode), format, autoCreate )); |
|
241 |
|
242 User::LeaveIfError( iRepository->Get( KSizeAudioFullscreenWidth, xSize )); |
|
243 User::LeaveIfError( iRepository->Get( KSizeAudioFullscreenHeight, ySize )); |
|
244 User::LeaveIfError( iRepository->Get( KAutoCreateAudioFullscreen, autoCreate )); |
|
245 |
|
246 iPersistentSizes.AppendL( TThumbnailPersistentSize( EAudioFullScreenThumbnailSize, TSize( xSize, ySize ), |
|
247 flags, static_cast <TDisplayMode> (raw_mode), format, autoCreate )); |
|
248 |
|
249 User::LeaveIfError( iRepository->Get( KSizeContactGridWidth, xSize )); |
|
250 User::LeaveIfError( iRepository->Get( KSizeContactGridHeight, ySize )); |
|
251 User::LeaveIfError( iRepository->Get( KAutoCreateContactGrid, autoCreate )); |
|
252 |
|
253 iPersistentSizes.AppendL( TThumbnailPersistentSize( EContactGridThumbnailSize, TSize( xSize, ySize ), |
|
254 KGridAndListThumbnailCropped, static_cast <TDisplayMode> (raw_mode), format, autoCreate )); |
|
255 |
|
256 User::LeaveIfError( iRepository->Get( KSizeContactListWidth, xSize )); |
|
257 User::LeaveIfError( iRepository->Get( KSizeContactListHeight, ySize )); |
|
258 User::LeaveIfError( iRepository->Get( KAutoCreateContactList, autoCreate )); |
|
259 |
|
260 iPersistentSizes.AppendL( TThumbnailPersistentSize( EContactListThumbnailSize, TSize( xSize, ySize ), |
|
261 KGridAndListThumbnailCropped, static_cast <TDisplayMode> (raw_mode), format, autoCreate )); |
|
262 |
|
263 User::LeaveIfError( iRepository->Get( KSizeContactFullscreenWidth, xSize )); |
|
264 User::LeaveIfError( iRepository->Get( KSizeContactFullscreenHeight, ySize )); |
|
265 User::LeaveIfError( iRepository->Get( KAutoCreateContactFullscreen, autoCreate )); |
|
266 |
|
267 iPersistentSizes.AppendL( TThumbnailPersistentSize( EContactFullScreenThumbnailSize, TSize( xSize, ySize ), |
|
268 flags, static_cast <TDisplayMode> (raw_mode), format, autoCreate )); |
|
269 |
|
270 iAutoCreate = new (ELeave) TThumbnailAutoCreate(); |
|
271 |
|
272 User::LeaveIfError( iRepository->Get( KAutoCreateImageGrid, iAutoCreate->iImageGrid )); |
|
273 User::LeaveIfError( iRepository->Get( KAutoCreateImageList, iAutoCreate->iImageList )); |
|
274 User::LeaveIfError( iRepository->Get( KAutoCreateImageFullscreen, iAutoCreate->iImageFullscreen )); |
|
275 User::LeaveIfError( iRepository->Get( KAutoCreateVideoGrid, iAutoCreate->iVideoGrid )); |
|
276 User::LeaveIfError( iRepository->Get( KAutoCreateVideoList, iAutoCreate->iVideoList )); |
|
277 User::LeaveIfError( iRepository->Get( KAutoCreateVideoFullscreen, iAutoCreate->iVideoFullscreen )); |
|
278 User::LeaveIfError( iRepository->Get( KAutoCreateAudioGrid, iAutoCreate->iAudioGrid )); |
|
279 User::LeaveIfError( iRepository->Get( KAutoCreateAudioList, iAutoCreate->iAudioList )); |
|
280 User::LeaveIfError( iRepository->Get( KAutoCreateAudioFullscreen, iAutoCreate->iAudioFullscreen )); |
|
281 User::LeaveIfError( iRepository->Get( KAutoCreateContactGrid, iAutoCreate->iContactGrid )); |
|
282 User::LeaveIfError( iRepository->Get( KAutoCreateContactList, iAutoCreate->iContactList )); |
|
283 User::LeaveIfError( iRepository->Get( KAutoCreateContactFullscreen, iAutoCreate->iContactFullscreen )); |
|
284 } |
|
285 |
|
286 // --------------------------------------------------------------------------- |
|
287 // CThumbnailCenRep::GetPersistentSizes() |
|
288 // --------------------------------------------------------------------------- |
|
289 // |
|
290 RArray < TThumbnailPersistentSize > & CThumbnailCenRep::GetPersistentSizes() |
|
291 { |
|
292 return iPersistentSizes; |
|
293 } |
|
294 |
|
295 // --------------------------------------------------------------------------- |
|
296 // CThumbnailCenRep::GetAutoCreateParams() |
|
297 // --------------------------------------------------------------------------- |
|
298 // |
|
299 TThumbnailAutoCreate & CThumbnailCenRep::GetAutoCreateParams() |
|
300 { |
|
301 return *iAutoCreate; |
|
302 } |
|
303 |
|
304 TThumbnailPersistentSize & CThumbnailCenRep::PersistentSizeL( TThumbnailSize |
|
305 aThumbnailSize ) |
|
306 { |
|
307 TThumbnailPersistentSize* persistentSize = NULL; |
|
308 TInt i = iPersistentSizes.Count(); |
|
309 for ( ; --i >= 0; ) |
|
310 { |
|
311 persistentSize = &iPersistentSizes[i]; |
|
312 if ( persistentSize->iType == aThumbnailSize ) |
|
313 { |
|
314 break; |
|
315 } |
|
316 } |
|
317 if ( i < 0 ) |
|
318 { // size not found |
|
319 User::Leave( KErrNotFound ); |
|
320 } |
|
321 |
|
322 return *persistentSize; |
|
323 } |
|
324 |
|
325 // End of file |
|