|
1 /* |
|
2 * Copyright (c) 2006 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: Application server |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 #ifndef C_ALFAPPSERVER_H |
|
21 #define C_ALFAPPSERVER_H |
|
22 |
|
23 #include <AknServerApp.h> |
|
24 #include <w32std.h> |
|
25 #include <alf/alfmetricsinterface.h> |
|
26 #include <alf/alfappui.h> |
|
27 #include <alf/alfextensionfactory.h> |
|
28 #include <alf/alfconstants.h> |
|
29 #include <uiacceltk/HuiCommand.h> |
|
30 #include <uiacceltk/HuiEnv.h> |
|
31 #include <uiacceltk/HuiDisplay.h> |
|
32 |
|
33 class CApaAppServiceBase; |
|
34 class CAlfAppSrvSessionBase; |
|
35 class CAlfEcomUtil; |
|
36 class MWindowVisibilityObserver; |
|
37 class CAlfSrvSubSessionBase; |
|
38 class CAlfSrvTransEffect; |
|
39 class CAlfAppSrvSession; |
|
40 class CAlfSrvTextureManager; |
|
41 class MTransitionServer2; |
|
42 class CAlfSrvScreenBufferManager; |
|
43 |
|
44 /** |
|
45 * Application server class. |
|
46 * |
|
47 * The server class is responsible of managing the sessions/services. |
|
48 * |
|
49 * @since S60 v3.2 |
|
50 */ |
|
51 NONSHARABLE_CLASS(CAlfAppServer) : public CAknAppServer |
|
52 { |
|
53 |
|
54 public: |
|
55 |
|
56 // Window group position compared to the client wg (=parent) |
|
57 enum TAlfWGPostion |
|
58 { |
|
59 EBehindOfParent, |
|
60 EOnTopOfParent, |
|
61 EAbsoluteBackground, |
|
62 EAlfWindowSize |
|
63 }; |
|
64 |
|
65 |
|
66 /** |
|
67 * Static constructor. |
|
68 */ |
|
69 IMPORT_C static CAlfAppServer* NewAppServerL(); |
|
70 |
|
71 /** |
|
72 * Destructor. |
|
73 */ |
|
74 ~CAlfAppServer(); |
|
75 |
|
76 /** |
|
77 * Client is about to exit, free all resources for the specific client |
|
78 * |
|
79 * @param aClientId Unique identifier of client, usually address of client's |
|
80 * instance pointer |
|
81 */ //Todo: as this is called from base class inside library, no need to export ? |
|
82 IMPORT_C void HandleClientExit(TInt aClientId); |
|
83 |
|
84 /** |
|
85 * Moves the server window group relative to the clinet (parent) wg. |
|
86 * |
|
87 * @param aWindowGroup Server window group |
|
88 * @param aParentIdentifier Client side window group |
|
89 * @param aPosition Server's wg position compared to the client's wg. |
|
90 */ |
|
91 IMPORT_C void AdjustWindowGroupPositionL( |
|
92 RWindowGroup& aWindowGroup, |
|
93 TInt aParentIdentifier, |
|
94 TAlfWGPostion aPosition ); |
|
95 |
|
96 /** |
|
97 * Get server's window server session. |
|
98 * |
|
99 * @return Window server session reference. |
|
100 */ |
|
101 IMPORT_C RWsSession& WsSession() const; |
|
102 |
|
103 /** |
|
104 * Get metrics interface |
|
105 * |
|
106 * @return Metrics API. NULL if not set. Ownership not transferred. |
|
107 */ |
|
108 IMPORT_C MAlfMetricsInterface* MetricsInterface(); |
|
109 IMPORT_C const MAlfMetricsInterface* MetricsInterface() const; |
|
110 |
|
111 /** |
|
112 * Set metrics interface |
|
113 * |
|
114 * @param aMetricsInterface Metrics API. Ownership not transferred. |
|
115 */ |
|
116 IMPORT_C void SetMetricsInterface(MAlfMetricsInterface* aMetricsInterface); |
|
117 |
|
118 /** |
|
119 * Sets AppUi pointer. |
|
120 * |
|
121 * @param aAppUi AppUi pointer. Ownership not transferred. |
|
122 */ |
|
123 void SetAppUi(CAlfAppUi* aAppUi); |
|
124 |
|
125 /** |
|
126 * Get AppUi pointer |
|
127 * |
|
128 * @return AppUi pointer. NULL if not set. Ownership not transferred. |
|
129 */ |
|
130 IMPORT_C CAlfAppUi* AppUi(); |
|
131 |
|
132 /** |
|
133 * Called when the focused window group is changed |
|
134 * |
|
135 * @param aSession Pointer to focused session |
|
136 * @param aWgId Window group identifier of new session, needed only when embedded apps transition takes place |
|
137 */ |
|
138 void FocusedWindowGroupChangedL( CAlfAppSrvSessionBase* aSession, TInt aWgId = KErrNotFound ); |
|
139 |
|
140 /** |
|
141 * Called when window visibility changes. |
|
142 * |
|
143 * @param aVisibilityFlags Visibility flags - see TWsVisibilityChangedEvent |
|
144 * @param aDestination Associated window-owning control. |
|
145 */ |
|
146 void WindowVisiblityChangedL( TUint aVisibilityFlags, CCoeControl* aDestination ); |
|
147 |
|
148 /** |
|
149 * Checks ECom plug-ins. |
|
150 */ |
|
151 void CheckForEcomPluginInstallUninstallL(); |
|
152 |
|
153 /** |
|
154 * For setting observers which will receive notify when window visibility changes. |
|
155 * |
|
156 * @param aObserver observer implementing MWindowVisibilityObserver interface |
|
157 * @param aClientId Identifier of a session so observer can be removed on queue when the session is terminated |
|
158 */ |
|
159 IMPORT_C void SetWindowChangeObserverL(MWindowVisibilityObserver* aObserver, TInt aClientId); |
|
160 |
|
161 /** |
|
162 * Returns a new container for sub sessions. |
|
163 * |
|
164 * @return Container. Ownership not transferred. |
|
165 */ |
|
166 CObjectCon* NewContainerL(); |
|
167 |
|
168 // from base class CAknAppServer |
|
169 |
|
170 /** |
|
171 * From CAknAppServer |
|
172 * Creates session/service based on the given service type. |
|
173 * This is called by the framework when a client opens session with the |
|
174 * server. |
|
175 * |
|
176 * @param aServiceType Service type, which identifies the service. |
|
177 * @return New service/session instance. Ownership transferred. |
|
178 */ |
|
179 CApaAppServiceBase* CreateServiceL( TUid aServiceType ) const; |
|
180 |
|
181 /** |
|
182 * From CAknAppServer |
|
183 * Called when all client have exited. |
|
184 */ |
|
185 void HandleAllClientsClosed(); |
|
186 |
|
187 public: // internals |
|
188 |
|
189 /** |
|
190 * Used by callback for asynchronous ecom implementation removal |
|
191 */ |
|
192 void DoSynchEcomImplementations(); |
|
193 |
|
194 MAlfExtension* CreateExtensionL(TInt aImplementationUid, TInt aImplementationId, const RMessage2 & aMessage ); |
|
195 |
|
196 void DestroyedObject(TInt aFactoryUid); |
|
197 |
|
198 void CreateTransitionEffectsL(); |
|
199 |
|
200 CAlfSrvTransEffect* TransitionEffects(); |
|
201 |
|
202 TInt CreateTfxServerPlugin(); |
|
203 |
|
204 MTransitionServer2* TfxServer(); |
|
205 |
|
206 /** |
|
207 * Sends an event to all clients. This method can be used for general purpose server to client |
|
208 * notifications e.g. when server receives resource changed event or ws-events or |
|
209 * something else as long as the clientside knows how to handle the event. |
|
210 */ |
|
211 void TriggerSystemEvent(TInt aEvent); |
|
212 |
|
213 void StartBackgroundTimerL(TInt aClientWg); |
|
214 |
|
215 void CancelBackgroundTimer(); |
|
216 |
|
217 /** |
|
218 * Returns maximum length of common command batch buffer. |
|
219 * @return maximum length of common command batch buffer. |
|
220 */ |
|
221 TInt CommonCommandBatchBufferMaxLength() const; |
|
222 |
|
223 /** |
|
224 * Gets common command batch buffer (unless it is already in use). |
|
225 * Client must call ReleaseCommonCommandBatchBuffer to release buffer for |
|
226 * global use. |
|
227 * @param aBuffer pointer descriptor which will point to common buffer. |
|
228 * @return ETrue if common command batch buffer was given to client, EFalse otherwise. |
|
229 */ |
|
230 TBool AcquireCommonCommandBatchBuffer( TPtr8& aBuffer ); |
|
231 |
|
232 /** |
|
233 * Releases common command batch buffer for global use. |
|
234 */ |
|
235 void ReleaseCommonCommandBatchBuffer(); |
|
236 |
|
237 /** |
|
238 * Returns reference to texture manager. |
|
239 * @return reference to texture manager. |
|
240 */ |
|
241 CAlfSrvTextureManager& TextureManager(); |
|
242 |
|
243 /** |
|
244 * Returns reference to screen buffer manager. |
|
245 * @return reference to screen buffer manager. |
|
246 */ |
|
247 CAlfSrvScreenBufferManager& ScreenBufferManager(); |
|
248 |
|
249 /** |
|
250 * Goes through all the sessions and checks if one of them has the keyboard focus |
|
251 */ |
|
252 TBool AlfClientHasFocus(); |
|
253 |
|
254 /** |
|
255 * This is typically called by the session when it receives EAlfNotifyAppVisibility event that |
|
256 * it's windowgroup is getting hidden. |
|
257 * |
|
258 * The session can query if there is some other alf application's window group above it |
|
259 * and set that other session as a new activesession |
|
260 */ |
|
261 CAlfAppSrvSessionBase* UpMostClientAboveWg( TInt aWgId ); |
|
262 |
|
263 public: |
|
264 |
|
265 CAlfAppSrvSessionBase* iOldSession; |
|
266 |
|
267 /** |
|
268 * Second phase constructor. Called by framework. |
|
269 * @param aFixedServerName server name. |
|
270 */ |
|
271 void ConstructL( const TDesC& aFixedServerName ); |
|
272 |
|
273 private: |
|
274 |
|
275 // private default constructor |
|
276 CAlfAppServer(); |
|
277 |
|
278 /** |
|
279 * Checks if implementation exists. |
|
280 */ |
|
281 TBool ImplementationExists(TUid aServiceType) const; |
|
282 |
|
283 /** |
|
284 * Loads extension. |
|
285 */ |
|
286 CAlfAppSrvSessionBase* LoadServiceExtensionL(TUid aServiceType); |
|
287 |
|
288 /** |
|
289 * Creates new session implementation. |
|
290 */ |
|
291 CAlfAppSrvSessionBase* NewImplementationL(TUid aServiceType); |
|
292 |
|
293 /** |
|
294 * Initiate callback for asynchronous ecom implementation removal |
|
295 */ |
|
296 void SyncEcomImplementations(TInt aClientId); |
|
297 |
|
298 /** |
|
299 * Rnd: logs the window groups |
|
300 */ |
|
301 void LogWindowGroupsL() const; |
|
302 |
|
303 /** |
|
304 * Ecom factory has been removed, command sessions to close assosiated objects |
|
305 */ |
|
306 void NotifySessionsAboutDestroyedImplementation(TInt aFactoryUid); |
|
307 |
|
308 private: |
|
309 |
|
310 // just to allow accessing Cone's session without CCoeStatic |
|
311 RWsSession* iWs; |
|
312 |
|
313 // backdrop window group identifier, cahcing this value allows us find status pane window group much faster |
|
314 // should be initialized in leaving constructor once that is implemented |
|
315 TInt iBackDropWgIdentifier; |
|
316 |
|
317 // Metrics API. Not owned. |
|
318 MAlfMetricsInterface* iMetricsInterface; |
|
319 |
|
320 // AppUi pointer. Not owned. |
|
321 CAlfAppUi* iAppUi; |
|
322 |
|
323 // Window group id of the client |
|
324 // This is updated when the client becomes focused. |
|
325 TInt iLastActiveClientWg; |
|
326 |
|
327 // ECom observer. |
|
328 CAlfEcomUtil* iEcomWatcher; |
|
329 |
|
330 struct TWindowChangeObserver |
|
331 { |
|
332 TWindowChangeObserver(MWindowVisibilityObserver* aObserver, TInt aClientId):iId(aClientId), iPtr(aObserver){} |
|
333 TInt iId; |
|
334 MWindowVisibilityObserver* iPtr; |
|
335 }; |
|
336 |
|
337 // list of sessions which are interested about window visibility changes |
|
338 RArray<TWindowChangeObserver> iWindowChangeObservers; |
|
339 |
|
340 struct TServiceExtension |
|
341 { |
|
342 TServiceExtension():iImpl(0){} |
|
343 operator==(const TInt aId) |
|
344 { |
|
345 return TInt(iImpl)==aId; |
|
346 } |
|
347 TUid iDestructorUid; |
|
348 TUid iServiceUid; |
|
349 CAlfAppSrvSessionBase* iImpl; |
|
350 }; |
|
351 |
|
352 // list of ecom based sessions |
|
353 RArray<TServiceExtension> iCustomSessions; |
|
354 |
|
355 // list of ecom based sessions that have been already destructed, |
|
356 // but the ECom Fw has not been notified yet |
|
357 RArray<TInt> iRemovedArray; |
|
358 |
|
359 // Async callback for ecom callbacks |
|
360 CAsyncCallBack* iAsynchOneShot; |
|
361 |
|
362 // For sub session objects. Own. |
|
363 CObjectConIx* iObjectConIx; |
|
364 |
|
365 |
|
366 struct TAlfElementFactory |
|
367 { |
|
368 TAlfElementFactory():iImpl(0), iAccessCount(0){} |
|
369 operator==(const TInt aId) |
|
370 { |
|
371 return iUid.iUid==aId; |
|
372 } |
|
373 |
|
374 TUid iDestructorUid; |
|
375 TUid iUid; |
|
376 MAlfExtensionFactory* iImpl; |
|
377 TInt iAccessCount; |
|
378 }; |
|
379 |
|
380 RArray<TAlfElementFactory> iFactories; |
|
381 |
|
382 TInt iTransitionEffect; |
|
383 |
|
384 // Transition effects framework |
|
385 CAlfSrvTransEffect* iTransitionEffects; |
|
386 |
|
387 // Tfx Server API (ECom plugin) |
|
388 MTransitionServer2* iTfxServer; |
|
389 |
|
390 // Tfx Server API destructor uid |
|
391 TUid iTfxServerEComDestructorUID; |
|
392 |
|
393 CPeriodic* iBackgroundTimer; |
|
394 |
|
395 /** |
|
396 * Command batch buffer. This buffer is shared between all sessions. |
|
397 * Owned. |
|
398 */ |
|
399 HBufC8* iCommonCommandBatchBuffer; |
|
400 |
|
401 /** |
|
402 * Boolean variable indicating if common command batch buffer is in use. |
|
403 */ |
|
404 TBool iCommonCommandBatchBufferInUse; |
|
405 |
|
406 /** |
|
407 * Server side texture manager. |
|
408 * Owned. |
|
409 */ |
|
410 CAlfSrvTextureManager* iTextureManager; |
|
411 |
|
412 /** |
|
413 * Server side screen buffer manager. |
|
414 * Owned. |
|
415 */ |
|
416 CAlfSrvScreenBufferManager* iScreenBufferManager; |
|
417 |
|
418 }; |
|
419 |
|
420 #endif // C_ALFAPPSERVER_H |