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: Shrinker class in the Memory manager component |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #ifndef C_CMMMSHRINKER_H |
|
20 #define C_CMMMSHRINKER_H |
|
21 |
|
22 #include <e32base.h> |
|
23 #include "cmcommon.h" // TCmListItemStatus |
|
24 |
|
25 /* Forward declarations. */ |
|
26 class MCmMmObserver; |
|
27 class CCmMmImageMetadataResolver; |
|
28 class CFbsBitmap; |
|
29 class CImageDecoder; |
|
30 class CBitmapScaler; |
|
31 class CImageEncoder; |
|
32 class CCmDmMain; |
|
33 |
|
34 /** |
|
35 * CCmMmShrinker class |
|
36 * |
|
37 * @lib cmmemorymanager.lib |
|
38 * @since S60 v3.1 |
|
39 */ |
|
40 class CCmMmShrinker : public CActive |
|
41 { |
|
42 |
|
43 // States |
|
44 enum TImageState |
|
45 { |
|
46 EIdle = 0, |
|
47 EDecode, |
|
48 EScale, |
|
49 EEncode, |
|
50 EReplace |
|
51 }; |
|
52 |
|
53 public: // Constructors and destructor |
|
54 |
|
55 /** |
|
56 * Creates new CCmMmShrinker class and opens connection to database |
|
57 * |
|
58 * @since S60 3.1 |
|
59 * @param aDbManager |
|
60 * @return pointer to CCmMmShrinker object |
|
61 */ |
|
62 static CCmMmShrinker* NewL( CCmDmMain& aDbManager ); |
|
63 |
|
64 /** |
|
65 * Creates new CCmMmShrinker class and opens connection to database and |
|
66 * leaves the instance in the cleanup stack |
|
67 * |
|
68 * @since S60 3.1 |
|
69 * @param aDbManager |
|
70 * @return pointer to CCmMmShrinker object |
|
71 */ |
|
72 static CCmMmShrinker* NewLC( CCmDmMain& aDbManager ); |
|
73 |
|
74 /** |
|
75 * C++ destructor |
|
76 * |
|
77 * @since S60 3.1 |
|
78 */ |
|
79 virtual ~CCmMmShrinker(); |
|
80 |
|
81 public: // New functions |
|
82 |
|
83 /** |
|
84 * Shrinks given images. |
|
85 * |
|
86 * @since S60 3.1 |
|
87 * @param aFiles |
|
88 */ |
|
89 void ShrinkImagesL( CDesCArray& aFiles ); |
|
90 |
|
91 /** |
|
92 * Sets memory manager observer |
|
93 * |
|
94 * @since S60 3.1 |
|
95 * @param aObserver |
|
96 */ |
|
97 void SetObserver ( MCmMmObserver* aObserver ); |
|
98 |
|
99 protected: // Functions from base class |
|
100 |
|
101 /** |
|
102 * From CActive |
|
103 * Cancels any outstanding operation |
|
104 * |
|
105 * @since S60 3.1 |
|
106 */ |
|
107 void DoCancel(); |
|
108 |
|
109 /** |
|
110 * Handles a leave occurring in the request |
|
111 * completion event handler RunL() |
|
112 * |
|
113 * @since S60 3.1 |
|
114 * @param aError |
|
115 * @return error value |
|
116 */ |
|
117 TInt RunError( TInt aError ); |
|
118 |
|
119 /** |
|
120 * From CActive |
|
121 * Callback function |
|
122 * Invoked to handle responses from the server |
|
123 * |
|
124 * @since S60 3.1 |
|
125 */ |
|
126 void RunL(); |
|
127 |
|
128 private: // New methods |
|
129 |
|
130 /** |
|
131 * Return screensize |
|
132 * |
|
133 * @since S60 3.1 |
|
134 * @return screensize |
|
135 */ |
|
136 TSize ScreenSizeL(); |
|
137 |
|
138 /** |
|
139 * Returns the private path according to the specified file name |
|
140 * |
|
141 * @since S60 3.1 |
|
142 * @param aFs handle to file server |
|
143 * @param aPrivatePath reference to descriptor where private path is |
|
144 modified. |
|
145 * @param aOriginal original file path used to define drive and file name |
|
146 */ |
|
147 void PrivatePath( RFs& aFs, |
|
148 TFileName& aPrivatePath, |
|
149 const TFileName& aOriginal ); |
|
150 |
|
151 /** |
|
152 * Clear shrinker mermber variables |
|
153 * |
|
154 * @since S60 3.1 |
|
155 * @param None |
|
156 */ |
|
157 void ClearShrinker(); |
|
158 |
|
159 private: |
|
160 |
|
161 /** |
|
162 * C++ constructor |
|
163 * |
|
164 * @since S60 3.1 |
|
165 * @param aDbManager |
|
166 */ |
|
167 CCmMmShrinker( CCmDmMain& aDbManager ); |
|
168 |
|
169 /** |
|
170 * Second-phase constructor. |
|
171 * |
|
172 * @since S60 3.1 |
|
173 * @param aFiles |
|
174 */ |
|
175 void ConstructL(); |
|
176 |
|
177 |
|
178 |
|
179 private: // data |
|
180 RFs iFileSession; |
|
181 TSize iScreenSize; |
|
182 TInt iShrinkIndex; |
|
183 TTime iStartTime; |
|
184 TImageState iState; |
|
185 TTime iStopTime; |
|
186 MCmMmObserver* iObserver; // not owned |
|
187 CCmDmMain& iDbManager; |
|
188 CFbsBitmap* iBitmap; // owned |
|
189 CBitmapScaler* iBitmapScaler; // owned |
|
190 CDesCArray* iFiles; // owned |
|
191 CImageDecoder* iImageDecoder; // owned |
|
192 CImageEncoder* iImageEncoder; // owned |
|
193 TFileName iTempFilename; |
|
194 CCmMmImageMetadataResolver* iImageMetadataResolver; |
|
195 }; |
|
196 |
|
197 #endif // C_CMMMSHRINKER_H |
|