|
1 /* |
|
2 * Copyright (c) 2008 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: Task monitor engine |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #ifndef TSFSWENGINE_H |
|
20 #define TSFSWENGINE_H |
|
21 |
|
22 #include <e32base.h> |
|
23 #include <e32cmn.h> |
|
24 #include <s32strm.h> |
|
25 #include <fbs.h> |
|
26 #include <eikenv.h> |
|
27 #include <w32std.h> |
|
28 #include <e32hashtab.h> |
|
29 #include <apgcli.h> |
|
30 #include <e32property.h> |
|
31 #include "tspreviewobserver.h" |
|
32 #include "tsfswentry.h" |
|
33 #include "tsfswobservers.h" |
|
34 |
|
35 class MTsFswEngineObserver; |
|
36 class CTsFastSwapPreviewProvider; |
|
37 class CApaWindowGroupName; |
|
38 class CBitmapRotator; |
|
39 class CTsRotationTask; |
|
40 class CTSCpsNotifier; |
|
41 |
|
42 class CTsFswDataList; |
|
43 |
|
44 // descriptor big enough to store hex repr of 32-bit integer plus 0x prefix |
|
45 typedef TBuf<10> TAppUidHexString; |
|
46 |
|
47 /** |
|
48 * Engine for fast swap server. |
|
49 * Performs task monitoring, notifications about wg changes are |
|
50 * received from the appui. |
|
51 */ |
|
52 NONSHARABLE_CLASS( CTsFswEngine ) : public CActive, |
|
53 public MTsFswTaskListObserver, |
|
54 public MTsFswResourceObserver, |
|
55 public MTsFsHiddenAppListObserver, |
|
56 public MTsFastSwapPreviewObserver |
|
57 { |
|
58 public: |
|
59 /** |
|
60 * Creates a new instance. |
|
61 * @param aObserver ref to observer |
|
62 */ |
|
63 IMPORT_C static CTsFswEngine* NewL( MTsFswEngineObserver& aObserver ); |
|
64 |
|
65 /** |
|
66 * @copydoc NewL |
|
67 */ |
|
68 IMPORT_C static CTsFswEngine* NewLC( MTsFswEngineObserver& aObserver ); |
|
69 |
|
70 /** |
|
71 * Destructor. |
|
72 */ |
|
73 ~CTsFswEngine(); |
|
74 |
|
75 /** |
|
76 * Returns a reference to the current content. |
|
77 * Also performs sanity checks, e.g. associates application icons |
|
78 * when no screenshot has been received. |
|
79 * @return ref to content array |
|
80 */ |
|
81 IMPORT_C const RTsFswArray& FswDataL(); |
|
82 |
|
83 /** |
|
84 * Tries to close the given app. |
|
85 * @param aWgId value given by WgId() for an entry in iData |
|
86 */ |
|
87 IMPORT_C void CloseAppL( TInt aWgId ); |
|
88 |
|
89 /** |
|
90 * Brings the given app to foreground. |
|
91 * @param aWgId value given by WgId() for an entry in iData |
|
92 */ |
|
93 IMPORT_C void SwitchToAppL( TInt aWgId ); |
|
94 |
|
95 /** |
|
96 * Returns the uid of the foreground app or KNullUid. |
|
97 * Will never return hidden apps, only those which can |
|
98 * also be seen in the array returned by FswDataL. |
|
99 * |
|
100 * In case of embedded apps the behaviour is controlled |
|
101 * by aType: it will return either the uid of the embedded |
|
102 * application or the container app. |
|
103 * |
|
104 * @param aType @see CTsFswClient::TTsFswFgAppType |
|
105 */ |
|
106 IMPORT_C TUid ForegroundAppUidL( TInt aType ); |
|
107 |
|
108 public: |
|
109 /** |
|
110 * Callback for rotation completion. Takes ownership of a given |
|
111 * bitmap. |
|
112 */ |
|
113 void RotationComplete( TInt aWgId, |
|
114 CFbsBitmap* aBitmap, |
|
115 CTsRotationTask* aCompletedTask, |
|
116 TInt aError ); |
|
117 |
|
118 /** |
|
119 * Called by CPS publisher when changes occours on widgets' CPS data. |
|
120 * Copies screenshot with use of delivered bitmap handle. |
|
121 * Moves last changed widget with entry into start position. |
|
122 */ |
|
123 void HandleWidgetUpdateL( TInt aWidgetId, TInt aBitmapHandle ); |
|
124 |
|
125 private: |
|
126 // from CActive |
|
127 void RunL(); |
|
128 TInt RunError( TInt aError ); |
|
129 void DoCancel(); |
|
130 |
|
131 // from MTsFswTaskListObserver |
|
132 void UpdateTaskList(); |
|
133 |
|
134 // from MTsFswResourceObserver |
|
135 void HandleResourceChange( TInt aType ); |
|
136 |
|
137 // from MTsFsHiddenAppListObserver |
|
138 void HiddenAppListUpdated(); |
|
139 |
|
140 // from MTsFastSwapPreviewObserver |
|
141 void HandleFswPpApplicationChange( TInt aWgId, TInt aFbsHandle ); |
|
142 void HandleFswPpApplicationUnregistered( TInt aWgId ); |
|
143 void HandleFswPpApplicationBitmapRotation( TInt aWgId, TBool aClockwise ); |
|
144 |
|
145 void RotateL( CFbsBitmap& aBitmap, TInt aWgId, TBool aClockwise ); |
|
146 |
|
147 private: |
|
148 /** |
|
149 * Constructor. |
|
150 */ |
|
151 CTsFswEngine( MTsFswEngineObserver& aObserver ); |
|
152 |
|
153 /** |
|
154 * Performs 2nd phase construction. |
|
155 */ |
|
156 void ConstructL(); |
|
157 |
|
158 /** |
|
159 * Gets the window group list and reconstructs the fsw content. |
|
160 * @return TBool ETrue if the list has been modified |
|
161 */ |
|
162 TBool CollectTasksL(); |
|
163 |
|
164 |
|
165 /** |
|
166 * Makes a copy of the bitmap with the given handle. |
|
167 * @param aFbsHandle bitmap handle |
|
168 * @param aKeepAspectRatio if true then aspect ratio is kept |
|
169 * @return CFbsBitmap* the copy, ownership transferred to caller |
|
170 */ |
|
171 CFbsBitmap* CopyBitmapL( TInt aFbsHandle, TBool aKeepAspectRatio ); |
|
172 |
|
173 /** |
|
174 * Callback for the iUpdateStarter timer. |
|
175 * Calls CollectTasksL and notifies the observer if the task list |
|
176 * has really been modified. |
|
177 */ |
|
178 static TInt UpdateStarterCallback( TAny* aParam ); |
|
179 |
|
180 /** |
|
181 * Brings the given web widget to foreground. |
|
182 * @param aWidgetIndex index in the list of running widgets |
|
183 */ |
|
184 void SwitchToWidgetL( TInt aWidgetIndex ); |
|
185 |
|
186 /** |
|
187 * Configues the preview provider with current screen size. |
|
188 */ |
|
189 void SetPreviewParams(); |
|
190 |
|
191 /** |
|
192 * Registers and unregisters window groups to iPreviewProvider |
|
193 * if the window group list has been changed. |
|
194 */ |
|
195 void UpdatePreviewContent(); |
|
196 |
|
197 /** |
|
198 * Gets and publishes the foreground app uid to CFW. |
|
199 */ |
|
200 void PublishFgAppUidL(); |
|
201 |
|
202 /** |
|
203 * Close running widget |
|
204 * @param aOffset - widget info offset |
|
205 */ |
|
206 void CloseWidgetL( TInt aOffset ); |
|
207 |
|
208 /** |
|
209 * Removes screenshot bitmap from contained iDataList |
|
210 */ |
|
211 void RemoveScreenshot( TInt aWgId ); |
|
212 |
|
213 /** |
|
214 * Add or overwrite screenshot datamap into iDataList |
|
215 * @return ETrue if content was changed |
|
216 */ |
|
217 TBool StoreScreenshot( TInt aWgId, CFbsBitmap* aBmp ); |
|
218 |
|
219 private: |
|
220 // data |
|
221 MTsFswEngineObserver& iObserver; |
|
222 CEikonEnv* iEnv; // not own |
|
223 |
|
224 // window server session |
|
225 RWsSession iWsSession; |
|
226 |
|
227 // apparc session |
|
228 RApaLsSession iAppArcSession; |
|
229 |
|
230 // preview provider instance, own |
|
231 CTsFastSwapPreviewProvider* iPreviewProvider; |
|
232 |
|
233 // timer to defer content refresh |
|
234 CPeriodic* iUpdateStarter; |
|
235 |
|
236 // true if web widgets are supported by the system |
|
237 TBool iWidgetsSupported; |
|
238 |
|
239 // PS property to listen for swi status changes |
|
240 RProperty iSwiProp; |
|
241 |
|
242 // window group ids returned by last WindowGroupList call |
|
243 RArray<TInt> iWgIds; |
|
244 |
|
245 TUid iFgAppUid; |
|
246 |
|
247 // For rotating bitmaps |
|
248 RPointerArray<CTsRotationTask> iRotaTasks; |
|
249 |
|
250 CTsFswDataList* iDataList;//own |
|
251 |
|
252 //Used to observ wigets' actions on CPS service |
|
253 CTSCpsNotifier* iCpsWidgetPublisher;//owned |
|
254 }; |
|
255 |
|
256 /** |
|
257 * Listener for rotation complete event |
|
258 */ |
|
259 NONSHARABLE_CLASS( CTsRotationTask ) : public CActive |
|
260 { |
|
261 public: |
|
262 CTsRotationTask( CTsFswEngine& aEngine ); |
|
263 ~CTsRotationTask(); |
|
264 void StartLD( TInt aWgId, CFbsBitmap* aBitmapHandle, TBool aClockwise ); |
|
265 private: |
|
266 void RunL(); |
|
267 void DoCancel(); |
|
268 private: |
|
269 // Data |
|
270 CTsFswEngine& iEngine; |
|
271 TInt iWgId; |
|
272 CFbsBitmap* iBitmap; // owned for the duration of transformation |
|
273 CBitmapRotator* iRotator; // owned |
|
274 }; |
|
275 |
|
276 #endif |