|
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 |
|
21 #include <thumbnailmanager.h> |
|
22 |
|
23 #include "thumbnailcenrep.h" |
|
24 #include "thumbnailmanageruids.hrh" |
|
25 #include "thumbnailstore.h" |
|
26 #include "thumbnailmanagerconstants.h" |
|
27 #include "thumbnailmanagerprivatecrkeys.h" |
|
28 |
|
29 // --------------------------------------------------------------------------- |
|
30 // TThumbnailPersistentSize::TThumbnailPersistentSize |
|
31 // --------------------------------------------------------------------------- |
|
32 // |
|
33 TThumbnailPersistentSize::TThumbnailPersistentSize( const TSize& aSize, TBool |
|
34 aCrop, TDisplayMode aMode, TInt aFormat ): iSize( aSize ), iCrop( aCrop ), |
|
35 iMode( aMode ), iFormat( aFormat ) |
|
36 { |
|
37 iType = EUnknownThumbnailSize; |
|
38 iSourceType = EUnknownSourceType; |
|
39 iAutoCreate = ETrue; |
|
40 } |
|
41 |
|
42 // --------------------------------------------------------------------------- |
|
43 // TThumbnailPersistentSize::TThumbnailPersistentSize |
|
44 // --------------------------------------------------------------------------- |
|
45 // |
|
46 TThumbnailPersistentSize::TThumbnailPersistentSize( TThumbnailSize aType, |
|
47 const TSize& aSize, TBool aCrop, TDisplayMode aMode, TInt aFormat, |
|
48 TBool aAutoCreate ) |
|
49 : iType( aType ), iSize( aSize ), iCrop( aCrop ), iMode( aMode ), |
|
50 iFormat( aFormat ), iAutoCreate( aAutoCreate ) |
|
51 { |
|
52 switch ( aType ) |
|
53 { |
|
54 case EImageGridThumbnailSize: |
|
55 case EImageListThumbnailSize: |
|
56 case EImageFullScreenThumbnailSize: |
|
57 iSourceType = EImage; |
|
58 break; |
|
59 case EVideoGridThumbnailSize: |
|
60 case EVideoListThumbnailSize: |
|
61 case EVideoFullScreenThumbnailSize: |
|
62 iSourceType = EVideo; |
|
63 break; |
|
64 case EAudioGridThumbnailSize: |
|
65 case EAudioListThumbnailSize: |
|
66 case EAudioFullScreenThumbnailSize: |
|
67 iSourceType = EAudio; |
|
68 break; |
|
69 default: |
|
70 iSourceType = EUnknownSourceType; |
|
71 } |
|
72 |
|
73 } |
|
74 |
|
75 // --------------------------------------------------------------------------- |
|
76 // TThumbnailAutoCreate::TThumbnailAutoCreate |
|
77 // --------------------------------------------------------------------------- |
|
78 // |
|
79 TThumbnailAutoCreate::TThumbnailAutoCreate() |
|
80 : iImageGrid(EFalse), iImageList(EFalse), iImageFullscreen(EFalse), |
|
81 iVideoGrid(EFalse), iVideoList(EFalse), iVideoFullscreen(EFalse), |
|
82 iAudioGrid(EFalse), iAudioList(EFalse), iAudioFullscreen(EFalse) |
|
83 { |
|
84 // No implementation required |
|
85 } |
|
86 |
|
87 // ======== MEMBER FUNCTIONS ======== |
|
88 |
|
89 // --------------------------------------------------------------------------- |
|
90 // CThumbnailCenRep::CThumbnailCenRep() |
|
91 // C++ default constructor can NOT contain any code, that might leave. |
|
92 // --------------------------------------------------------------------------- |
|
93 // |
|
94 CThumbnailCenRep::CThumbnailCenRep() |
|
95 { |
|
96 // No implementation required |
|
97 } |
|
98 |
|
99 |
|
100 // --------------------------------------------------------------------------- |
|
101 // CThumbnailCenRep::~CThumbnailCenRep() |
|
102 // Destructor. |
|
103 // --------------------------------------------------------------------------- |
|
104 // |
|
105 CThumbnailCenRep::~CThumbnailCenRep() |
|
106 { |
|
107 iPersistentSizes.Close(); |
|
108 delete iAutoCreate; |
|
109 delete iRepository; |
|
110 } |
|
111 |
|
112 // --------------------------------------------------------------------------- |
|
113 // CThumbnailCenRep::NewL() |
|
114 // Two-phased constructor. |
|
115 // --------------------------------------------------------------------------- |
|
116 // |
|
117 CThumbnailCenRep* CThumbnailCenRep::NewL() |
|
118 { |
|
119 CThumbnailCenRep* self = new( ELeave )CThumbnailCenRep(); |
|
120 CleanupStack::PushL( self ); |
|
121 self->ConstructL(); |
|
122 CleanupStack::Pop( self ); |
|
123 return self; |
|
124 } |
|
125 |
|
126 // --------------------------------------------------------------------------- |
|
127 // CThumbnailCenRep::ConstructL() |
|
128 // Returns id of specific task. |
|
129 // --------------------------------------------------------------------------- |
|
130 // |
|
131 void CThumbnailCenRep::ConstructL() |
|
132 { |
|
133 iRepository = CRepository::NewL( TUid::Uid( THUMBNAIL_CENREP_UID )); |
|
134 |
|
135 TInt xSize( 0 ); |
|
136 TInt ySize( 0 ); |
|
137 TBool flags( EFalse ); |
|
138 const TBool KGridAndListThumbnailCropped = ETrue; |
|
139 TInt raw_mode( KThumbnailDefaultDisplayMode ); |
|
140 TInt format( 0 ); |
|
141 TBool autoCreate( EFalse ); |
|
142 |
|
143 User::LeaveIfError( iRepository->Get( KSizeImageGridWidth, xSize )); |
|
144 User::LeaveIfError( iRepository->Get( KSizeImageGridHeight, ySize )); |
|
145 User::LeaveIfError( iRepository->Get( KAutoCreateImageGrid, autoCreate )); |
|
146 |
|
147 iPersistentSizes.AppendL( TThumbnailPersistentSize( EImageGridThumbnailSize, TSize( xSize, ySize ), |
|
148 KGridAndListThumbnailCropped, static_cast <TDisplayMode> (raw_mode), format, autoCreate )); |
|
149 |
|
150 User::LeaveIfError( iRepository->Get( KSizeImageListWidth, xSize )); |
|
151 User::LeaveIfError( iRepository->Get( KSizeImageListHeight, ySize )); |
|
152 User::LeaveIfError( iRepository->Get( KAutoCreateImageList, autoCreate )); |
|
153 |
|
154 iPersistentSizes.AppendL( TThumbnailPersistentSize( EImageListThumbnailSize, TSize( xSize, ySize ), |
|
155 KGridAndListThumbnailCropped, static_cast <TDisplayMode> (raw_mode), format, autoCreate )); |
|
156 |
|
157 User::LeaveIfError( iRepository->Get( KSizeImageFullscreenWidth, xSize )); |
|
158 User::LeaveIfError( iRepository->Get( KSizeImageFullscreenHeight, ySize )); |
|
159 User::LeaveIfError( iRepository->Get( KAutoCreateImageFullscreen, autoCreate )); |
|
160 |
|
161 iPersistentSizes.AppendL( TThumbnailPersistentSize( EImageFullScreenThumbnailSize, TSize( xSize, ySize ), |
|
162 flags, static_cast <TDisplayMode> (raw_mode), format, autoCreate )); |
|
163 |
|
164 User::LeaveIfError( iRepository->Get( KSizeVideoGridWidth, xSize )); |
|
165 User::LeaveIfError( iRepository->Get( KSizeVideoGridHeight, ySize )); |
|
166 User::LeaveIfError( iRepository->Get( KAutoCreateVideoGrid, autoCreate )); |
|
167 |
|
168 iPersistentSizes.AppendL( TThumbnailPersistentSize( EVideoGridThumbnailSize, TSize( xSize, ySize ), |
|
169 KGridAndListThumbnailCropped, static_cast <TDisplayMode> (raw_mode), format, autoCreate )); |
|
170 |
|
171 User::LeaveIfError( iRepository->Get( KSizeVideoListWidth, xSize )); |
|
172 User::LeaveIfError( iRepository->Get( KSizeVideoListHeight, ySize )); |
|
173 User::LeaveIfError( iRepository->Get( KAutoCreateVideoList, autoCreate )); |
|
174 |
|
175 iPersistentSizes.AppendL( TThumbnailPersistentSize( EVideoListThumbnailSize, TSize( xSize, ySize ), |
|
176 KGridAndListThumbnailCropped, static_cast <TDisplayMode> (raw_mode), format, autoCreate )); |
|
177 |
|
178 User::LeaveIfError( iRepository->Get( KSizeVideoFullscreenWidth, xSize )); |
|
179 User::LeaveIfError( iRepository->Get( KSizeVideoFullscreenHeight, ySize )); |
|
180 User::LeaveIfError( iRepository->Get( KAutoCreateVideoFullscreen, autoCreate )); |
|
181 |
|
182 iPersistentSizes.AppendL( TThumbnailPersistentSize( EVideoFullScreenThumbnailSize, TSize( xSize, ySize ), |
|
183 flags, static_cast <TDisplayMode> (raw_mode), format, autoCreate )); |
|
184 |
|
185 User::LeaveIfError( iRepository->Get( KSizeAudioGridWidth, xSize )); |
|
186 User::LeaveIfError( iRepository->Get( KSizeAudioGridHeight, ySize )); |
|
187 User::LeaveIfError( iRepository->Get( KAutoCreateAudioGrid, autoCreate )); |
|
188 |
|
189 iPersistentSizes.AppendL( TThumbnailPersistentSize( EAudioGridThumbnailSize, TSize( xSize, ySize ), |
|
190 KGridAndListThumbnailCropped, static_cast <TDisplayMode> (raw_mode), format, autoCreate )); |
|
191 |
|
192 User::LeaveIfError( iRepository->Get( KSizeAudioListWidth, xSize )); |
|
193 User::LeaveIfError( iRepository->Get( KSizeAudioListHeight, ySize )); |
|
194 User::LeaveIfError( iRepository->Get( KAutoCreateAudioList, autoCreate )); |
|
195 |
|
196 iPersistentSizes.AppendL( TThumbnailPersistentSize( EAudioListThumbnailSize, TSize( xSize, ySize ), |
|
197 KGridAndListThumbnailCropped, static_cast <TDisplayMode> (raw_mode), format, autoCreate )); |
|
198 |
|
199 User::LeaveIfError( iRepository->Get( KSizeAudioFullscreenWidth, xSize )); |
|
200 User::LeaveIfError( iRepository->Get( KSizeAudioFullscreenHeight, ySize )); |
|
201 User::LeaveIfError( iRepository->Get( KAutoCreateAudioFullscreen, autoCreate )); |
|
202 |
|
203 iPersistentSizes.AppendL( TThumbnailPersistentSize( EAudioFullScreenThumbnailSize, TSize( xSize, ySize ), |
|
204 flags, static_cast <TDisplayMode> (raw_mode), format, autoCreate )); |
|
205 |
|
206 iAutoCreate = new (ELeave) TThumbnailAutoCreate(); |
|
207 |
|
208 User::LeaveIfError( iRepository->Get( KAutoCreateImageGrid, iAutoCreate->iImageGrid )); |
|
209 User::LeaveIfError( iRepository->Get( KAutoCreateImageList, iAutoCreate->iImageList )); |
|
210 User::LeaveIfError( iRepository->Get( KAutoCreateImageFullscreen, iAutoCreate->iImageFullscreen )); |
|
211 User::LeaveIfError( iRepository->Get( KAutoCreateVideoGrid, iAutoCreate->iVideoGrid )); |
|
212 User::LeaveIfError( iRepository->Get( KAutoCreateVideoList, iAutoCreate->iVideoList )); |
|
213 User::LeaveIfError( iRepository->Get( KAutoCreateVideoFullscreen, iAutoCreate->iVideoFullscreen )); |
|
214 User::LeaveIfError( iRepository->Get( KAutoCreateAudioGrid, iAutoCreate->iAudioGrid )); |
|
215 User::LeaveIfError( iRepository->Get( KAutoCreateAudioList, iAutoCreate->iAudioList )); |
|
216 User::LeaveIfError( iRepository->Get( KAutoCreateAudioFullscreen, iAutoCreate->iAudioFullscreen )); |
|
217 } |
|
218 |
|
219 // --------------------------------------------------------------------------- |
|
220 // CThumbnailCenRep::GetPersistentSizes() |
|
221 // --------------------------------------------------------------------------- |
|
222 // |
|
223 RArray < TThumbnailPersistentSize > & CThumbnailCenRep::GetPersistentSizes() |
|
224 { |
|
225 return iPersistentSizes; |
|
226 } |
|
227 |
|
228 // --------------------------------------------------------------------------- |
|
229 // CThumbnailCenRep::GetAutoCreateParams() |
|
230 // --------------------------------------------------------------------------- |
|
231 // |
|
232 TThumbnailAutoCreate & CThumbnailCenRep::GetAutoCreateParams() |
|
233 { |
|
234 return *iAutoCreate; |
|
235 } |
|
236 |
|
237 TThumbnailPersistentSize & CThumbnailCenRep::PersistentSizeL( TThumbnailSize |
|
238 aThumbnailSize ) |
|
239 { |
|
240 TThumbnailPersistentSize* persistentSize = NULL; |
|
241 TInt i = iPersistentSizes.Count(); |
|
242 for ( ; --i >= 0; ) |
|
243 { |
|
244 persistentSize = &iPersistentSizes[i]; |
|
245 if ( persistentSize->iType == aThumbnailSize ) |
|
246 { |
|
247 break; |
|
248 } |
|
249 } |
|
250 if ( i < 0 ) |
|
251 { // size not found |
|
252 User::Leave( KErrNotFound ); |
|
253 } |
|
254 |
|
255 return *persistentSize; |
|
256 } |
|
257 |
|
258 // End of file |